atcommand.cpp 330 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906
  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 and Third
  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. { // Deny direct transformation into dummy jobs
  998. clif_displaymessage(fd, msg_txt(sd,923)); //"You can not change to this job by command."
  999. return 0;
  1000. }
  1001. if (pcdb_checkid(job))
  1002. {
  1003. if (pc_jobchange(sd, job, upper))
  1004. clif_displaymessage(fd, msg_txt(sd,12)); // Your job has been changed.
  1005. else {
  1006. clif_displaymessage(fd, msg_txt(sd,155)); // You are unable to change your job.
  1007. return -1;
  1008. }
  1009. } else {
  1010. text = atcommand_help_string(command);
  1011. if (text)
  1012. clif_displaymessage(fd, text);
  1013. return -1;
  1014. }
  1015. return 0;
  1016. }
  1017. /*==========================================
  1018. *
  1019. *------------------------------------------*/
  1020. ACMD_FUNC(kill)
  1021. {
  1022. nullpo_retr(-1, sd);
  1023. status_kill(&sd->bl);
  1024. clif_displaymessage(sd->fd, msg_txt(sd,13)); // A pity! You've died.
  1025. if (fd != sd->fd)
  1026. clif_displaymessage(fd, msg_txt(sd,14)); // Character killed.
  1027. return 0;
  1028. }
  1029. /*==========================================
  1030. *
  1031. *------------------------------------------*/
  1032. ACMD_FUNC(alive)
  1033. {
  1034. nullpo_retr(-1, sd);
  1035. if (!status_revive(&sd->bl, 100, 100))
  1036. {
  1037. clif_displaymessage(fd, msg_txt(sd,667)); // You're not dead.
  1038. return -1;
  1039. }
  1040. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  1041. clif_displaymessage(fd, msg_txt(sd,16)); // You've been revived! It's a miracle!
  1042. return 0;
  1043. }
  1044. /*==========================================
  1045. * +kamic [LuzZza]
  1046. *------------------------------------------*/
  1047. ACMD_FUNC(kami)
  1048. {
  1049. unsigned long color=0;
  1050. nullpo_retr(-1, sd);
  1051. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1052. if(*(command + 5) != 'c' && *(command + 5) != 'C') {
  1053. if (!message || !*message) {
  1054. clif_displaymessage(fd, msg_txt(sd,980)); // Please enter a message (usage: @kami <message>).
  1055. return -1;
  1056. }
  1057. sscanf(message, "%255[^\n]", atcmd_output);
  1058. if (strstr(command, "l") != NULL)
  1059. clif_broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT, ALL_SAMEMAP);
  1060. else
  1061. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, (*(command + 5) == 'b' || *(command + 5) == 'B') ? BC_BLUE : BC_DEFAULT);
  1062. } else {
  1063. if(!message || !*message || (sscanf(message, "%20lx %199[^\n]", &color, atcmd_output) < 2)) {
  1064. clif_displaymessage(fd, msg_txt(sd,981)); // Please enter color and message (usage: @kamic <color> <message>).
  1065. return -1;
  1066. }
  1067. if(color > 0xFFFFFF) {
  1068. clif_displaymessage(fd, msg_txt(sd,982)); // Invalid color.
  1069. return -1;
  1070. }
  1071. intif_broadcast2(atcmd_output, strlen(atcmd_output) + 1, color, 0x190, 12, 0, 0);
  1072. }
  1073. return 0;
  1074. }
  1075. /*==========================================
  1076. *
  1077. *------------------------------------------*/
  1078. ACMD_FUNC(heal)
  1079. {
  1080. int hp = 0, sp = 0; // [Valaris] thanks to fov
  1081. nullpo_retr(-1, sd);
  1082. sscanf(message, "%11d %11d", &hp, &sp);
  1083. // some overflow checks
  1084. if( hp == INT_MIN ) hp++;
  1085. if( sp == INT_MIN ) sp++;
  1086. if ( hp == 0 && sp == 0 ) {
  1087. if (!status_percent_heal(&sd->bl, 100, 100))
  1088. clif_displaymessage(fd, msg_txt(sd,157)); // HP and SP have already been recovered.
  1089. else
  1090. clif_displaymessage(fd, msg_txt(sd,17)); // HP, SP recovered.
  1091. return 0;
  1092. }
  1093. if ( hp > 0 && sp >= 0 ) {
  1094. if(!status_heal(&sd->bl, hp, sp, 0))
  1095. clif_displaymessage(fd, msg_txt(sd,157)); // HP and SP are already with the good value.
  1096. else
  1097. clif_displaymessage(fd, msg_txt(sd,17)); // HP, SP recovered.
  1098. return 0;
  1099. }
  1100. if ( hp < 0 && sp <= 0 ) {
  1101. status_damage(NULL, &sd->bl, -hp, -sp, 0, 0, 0);
  1102. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, DMG_ENDURE, 0, false);
  1103. clif_displaymessage(fd, msg_txt(sd,156)); // HP or/and SP modified.
  1104. return 0;
  1105. }
  1106. //Opposing signs.
  1107. if ( hp ) {
  1108. if (hp > 0)
  1109. status_heal(&sd->bl, hp, 0, 0);
  1110. else {
  1111. status_damage(NULL, &sd->bl, -hp, 0, 0, 0, 0);
  1112. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, DMG_ENDURE, 0, false);
  1113. }
  1114. }
  1115. if ( sp ) {
  1116. if (sp > 0)
  1117. status_heal(&sd->bl, 0, sp, 0);
  1118. else
  1119. status_damage(NULL, &sd->bl, 0, -sp, 0, 0, 0);
  1120. }
  1121. clif_displaymessage(fd, msg_txt(sd,156)); // HP or/and SP modified.
  1122. return 0;
  1123. }
  1124. /*==========================================
  1125. * @item command (usage: @item <itemdid1:itemid2:itemname:..> <quantity>) (modified by [Yor] for pet_egg)
  1126. * @itembound command (usage: @itembound <name/id_of_item> <quantity> <bound_type>)
  1127. *------------------------------------------*/
  1128. ACMD_FUNC(item)
  1129. {
  1130. char item_name[100];
  1131. int number = 0, bound = BOUND_NONE;
  1132. char flag = 0;
  1133. struct item item_tmp;
  1134. struct item_data *item_data[10];
  1135. int get_count, i, j=0;
  1136. char *itemlist;
  1137. nullpo_retr(-1, sd);
  1138. memset(item_name, '\0', sizeof(item_name));
  1139. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  1140. if (!strcmpi(parent_cmd,"itembound")) {
  1141. if (!message || !*message || (
  1142. sscanf(message, "\"%99[^\"]\" %11d %11d", item_name, &number, &bound) < 3 &&
  1143. sscanf(message, "%99s %11d %11d", item_name, &number, &bound) < 3))
  1144. {
  1145. clif_displaymessage(fd, msg_txt(sd,295)); // Please enter an item name or ID (usage: @item <item name/ID> <quantity> <bound_type>).
  1146. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1147. return -1;
  1148. }
  1149. if( bound <= BOUND_NONE || bound >= BOUND_MAX ) {
  1150. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1151. return -1;
  1152. }
  1153. } else if (!message || !*message || (
  1154. sscanf(message, "\"%99[^\"]\" %11d", item_name, &number) < 1 &&
  1155. sscanf(message, "%99s %11d", item_name, &number) < 1
  1156. )) {
  1157. clif_displaymessage(fd, msg_txt(sd,983)); // Please enter an item name or ID (usage: @item <item name/ID> <quantity>).
  1158. return -1;
  1159. }
  1160. itemlist = strtok(item_name, ":");
  1161. while (itemlist != NULL && j<10) {
  1162. if ((item_data[j] = itemdb_searchname(itemlist)) == NULL &&
  1163. (item_data[j] = itemdb_exists(atoi(itemlist))) == NULL){
  1164. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  1165. return -1;
  1166. }
  1167. itemlist = strtok(NULL, ":"); //next itemline
  1168. j++;
  1169. }
  1170. if (number <= 0)
  1171. number = 1;
  1172. get_count = number;
  1173. for(j--; j>=0; j--){ //produce items in list
  1174. unsigned short item_id = item_data[j]->nameid;
  1175. //Check if it's stackable.
  1176. if (!itemdb_isstackable2(item_data[j]))
  1177. get_count = 1;
  1178. for (i = 0; i < number; i += get_count) {
  1179. // if not pet egg
  1180. if (!pet_create_egg(sd, item_id)) {
  1181. memset(&item_tmp, 0, sizeof(item_tmp));
  1182. item_tmp.nameid = item_id;
  1183. item_tmp.identify = 1;
  1184. item_tmp.bound = bound;
  1185. if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
  1186. clif_additem(sd, 0, 0, flag);
  1187. }
  1188. }
  1189. }
  1190. if (flag == 0)
  1191. clif_displaymessage(fd, msg_txt(sd,18)); // Item created.
  1192. return 0;
  1193. }
  1194. /*==========================================
  1195. *
  1196. *------------------------------------------*/
  1197. ACMD_FUNC(item2)
  1198. {
  1199. struct item item_tmp;
  1200. struct item_data *item_data;
  1201. char item_name[100];
  1202. unsigned short item_id;
  1203. int number = 0, bound = BOUND_NONE;
  1204. int identify = 0, refine = 0, attr = 0;
  1205. int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  1206. nullpo_retr(-1, sd);
  1207. memset(item_name, '\0', sizeof(item_name));
  1208. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  1209. if (!strcmpi(parent_cmd+1,"itembound2")) {
  1210. if (!message || !*message || (
  1211. sscanf(message, "\"%99[^\"]\" %11d %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4, &bound) < 10 &&
  1212. sscanf(message, "%99s %11d %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4, &bound) < 10 ))
  1213. {
  1214. clif_displaymessage(fd, msg_txt(sd,296)); // Please enter all parameters (usage: @item2 <item name/ID> <quantity>
  1215. clif_displaymessage(fd, msg_txt(sd,297)); // <identify_flag> <refine> <attribute> <card1> <card2> <card3> <card4> <bound_type>).
  1216. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1217. return -1;
  1218. }
  1219. if( bound <= BOUND_NONE || bound >= BOUND_MAX ) {
  1220. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1221. return -1;
  1222. }
  1223. } else if ( !message || !*message || (
  1224. sscanf(message, "\"%99[^\"]\" %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9 &&
  1225. sscanf(message, "%99s %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9
  1226. )) {
  1227. clif_displaymessage(fd, msg_txt(sd,984)); // Please enter all parameters (usage: @item2 <item name/ID> <quantity>
  1228. clif_displaymessage(fd, msg_txt(sd,985)); // <identify_flag> <refine> <attribute> <card1> <card2> <card3> <card4>).
  1229. return -1;
  1230. }
  1231. if (number <= 0)
  1232. number = 1;
  1233. item_id = 0;
  1234. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  1235. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  1236. item_id = item_data->nameid;
  1237. if (item_id > 500) {
  1238. int loop, get_count, i;
  1239. char flag = 0;
  1240. //Check if it's stackable.
  1241. if(!itemdb_isstackable2(item_data)){
  1242. loop = number;
  1243. get_count = 1;
  1244. }else{
  1245. loop = 1;
  1246. get_count = number;
  1247. }
  1248. if( itemdb_isequip2(item_data ) ){
  1249. refine = cap_value( refine, 0, MAX_REFINE );
  1250. }else{
  1251. // All other items cannot be refined and are always identified
  1252. identify = 1;
  1253. refine = attr = 0;
  1254. }
  1255. for (i = 0; i < loop; i++) {
  1256. // if not pet egg
  1257. if (!pet_create_egg(sd, item_id)) {
  1258. memset(&item_tmp, 0, sizeof(item_tmp));
  1259. item_tmp.nameid = item_id;
  1260. item_tmp.identify = identify;
  1261. item_tmp.refine = refine;
  1262. item_tmp.attribute = attr;
  1263. item_tmp.card[0] = c1;
  1264. item_tmp.card[1] = c2;
  1265. item_tmp.card[2] = c3;
  1266. item_tmp.card[3] = c4;
  1267. item_tmp.bound = bound;
  1268. if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
  1269. clif_additem(sd, 0, 0, flag);
  1270. }
  1271. }
  1272. if (flag == 0)
  1273. clif_displaymessage(fd, msg_txt(sd,18)); // Item created.
  1274. } else {
  1275. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  1276. return -1;
  1277. }
  1278. return 0;
  1279. }
  1280. /*==========================================
  1281. *
  1282. *------------------------------------------*/
  1283. ACMD_FUNC(itemreset)
  1284. {
  1285. int i;
  1286. nullpo_retr(-1, sd);
  1287. for (i = 0; i < MAX_INVENTORY; i++) {
  1288. 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])) {
  1289. pc_delitem(sd, i, sd->inventory.u.items_inventory[i].amount, 0, 0, LOG_TYPE_COMMAND);
  1290. }
  1291. }
  1292. clif_displaymessage(fd, msg_txt(sd,20)); // All of your items have been removed.
  1293. return 0;
  1294. }
  1295. /*==========================================
  1296. * Atcommand @lvlup
  1297. *------------------------------------------*/
  1298. ACMD_FUNC(baselevelup)
  1299. {
  1300. int level=0, i=0, status_point=0;
  1301. nullpo_retr(-1, sd);
  1302. level = atoi(message);
  1303. if (!message || !*message || !level) {
  1304. clif_displaymessage(fd, msg_txt(sd,986)); // Please enter a level adjustment (usage: @lvup/@blevel/@baselvlup <number of levels>).
  1305. return -1;
  1306. }
  1307. if (level > 0) {
  1308. if (sd->status.base_level >= pc_maxbaselv(sd)) { // check for max level by Valaris
  1309. clif_displaymessage(fd, msg_txt(sd,47)); // Base level can't go any higher.
  1310. return -1;
  1311. } // End Addition
  1312. if ((unsigned int)level > pc_maxbaselv(sd) || (unsigned int)level > pc_maxbaselv(sd) - sd->status.base_level) // fix positive overflow
  1313. level = pc_maxbaselv(sd) - sd->status.base_level;
  1314. for (i = 0; i < level; i++)
  1315. status_point += pc_gets_status_point(sd->status.base_level + i);
  1316. sd->status.status_point += status_point;
  1317. sd->status.base_level += (unsigned int)level;
  1318. status_calc_pc(sd, SCO_FORCE);
  1319. status_percent_heal(&sd->bl, 100, 100);
  1320. clif_misceffect(&sd->bl, 0);
  1321. achievement_update_objective(sd, AG_GOAL_LEVEL, 1, sd->status.base_level);
  1322. achievement_update_objective(sd, AG_GOAL_STATUS, 2, sd->status.base_level, sd->status.class_);
  1323. clif_displaymessage(fd, msg_txt(sd,21)); // Base level raised.
  1324. } else {
  1325. if (sd->status.base_level == 1) {
  1326. clif_displaymessage(fd, msg_txt(sd,158)); // Base level can't go any lower.
  1327. return -1;
  1328. }
  1329. level*=-1;
  1330. if ((unsigned int)level >= sd->status.base_level)
  1331. level = sd->status.base_level-1;
  1332. for (i = 0; i > -level; i--)
  1333. status_point += pc_gets_status_point(sd->status.base_level + i - 1);
  1334. if (sd->status.status_point < status_point)
  1335. pc_resetstate(sd);
  1336. if (sd->status.status_point < status_point)
  1337. sd->status.status_point = 0;
  1338. else
  1339. sd->status.status_point -= status_point;
  1340. sd->status.base_level -= (unsigned int)level;
  1341. clif_displaymessage(fd, msg_txt(sd,22)); // Base level lowered.
  1342. status_calc_pc(sd, SCO_FORCE);
  1343. level*=-1;
  1344. }
  1345. sd->status.base_exp = 0;
  1346. clif_updatestatus(sd, SP_STATUSPOINT);
  1347. clif_updatestatus(sd, SP_BASELEVEL);
  1348. clif_updatestatus(sd, SP_BASEEXP);
  1349. clif_updatestatus(sd, SP_NEXTBASEEXP);
  1350. pc_baselevelchanged(sd);
  1351. if(sd->status.party_id)
  1352. party_send_levelup(sd);
  1353. if( level > 0 && battle_config.atcommand_levelup_events )
  1354. npc_script_event(sd,NPCE_BASELVUP);
  1355. return 0;
  1356. }
  1357. /*==========================================
  1358. *
  1359. *------------------------------------------*/
  1360. ACMD_FUNC(joblevelup)
  1361. {
  1362. int level=0;
  1363. nullpo_retr(-1, sd);
  1364. level = atoi(message);
  1365. if (!message || !*message || !level) {
  1366. clif_displaymessage(fd, msg_txt(sd,987)); // Please enter a level adjustment (usage: @joblvup/@jlevel/@joblvlup <number of levels>).
  1367. return -1;
  1368. }
  1369. if (level > 0) {
  1370. if (sd->status.job_level >= pc_maxjoblv(sd)) {
  1371. clif_displaymessage(fd, msg_txt(sd,23)); // Job level can't go any higher.
  1372. return -1;
  1373. }
  1374. if ((unsigned int)level > pc_maxjoblv(sd) || (unsigned int)level > pc_maxjoblv(sd) - sd->status.job_level) // fix positive overflow
  1375. level = pc_maxjoblv(sd) - sd->status.job_level;
  1376. sd->status.job_level += (unsigned int)level;
  1377. sd->status.skill_point += level;
  1378. clif_misceffect(&sd->bl, 1);
  1379. achievement_update_objective(sd, AG_GOAL_LEVEL, 1, sd->status.job_level);
  1380. clif_displaymessage(fd, msg_txt(sd,24)); // Job level raised.
  1381. } else {
  1382. if (sd->status.job_level == 1) {
  1383. clif_displaymessage(fd, msg_txt(sd,159)); // Job level can't go any lower.
  1384. return -1;
  1385. }
  1386. level *=-1;
  1387. if ((unsigned int)level >= sd->status.job_level) // fix negative overflow
  1388. level = sd->status.job_level-1;
  1389. sd->status.job_level -= (unsigned int)level;
  1390. if (sd->status.skill_point < level)
  1391. pc_resetskill(sd,0); //Reset skills since we need to subtract more points.
  1392. if (sd->status.skill_point < level)
  1393. sd->status.skill_point = 0;
  1394. else
  1395. sd->status.skill_point -= level;
  1396. clif_displaymessage(fd, msg_txt(sd,25)); // Job level lowered.
  1397. level *=-1;
  1398. }
  1399. sd->status.job_exp = 0;
  1400. clif_updatestatus(sd, SP_JOBLEVEL);
  1401. clif_updatestatus(sd, SP_JOBEXP);
  1402. clif_updatestatus(sd, SP_NEXTJOBEXP);
  1403. clif_updatestatus(sd, SP_SKILLPOINT);
  1404. status_calc_pc(sd, SCO_FORCE);
  1405. if( level > 0 && battle_config.atcommand_levelup_events )
  1406. npc_script_event(sd,NPCE_JOBLVUP);
  1407. return 0;
  1408. }
  1409. /*==========================================
  1410. * @help
  1411. *------------------------------------------*/
  1412. ACMD_FUNC(help){
  1413. const char *command_name = nullptr;
  1414. nullpo_retr(-1, sd);
  1415. if (!message || !*message) {
  1416. command_name = "help"; // If no command_name specified, display help for @help.
  1417. } else {
  1418. if (*message == atcommand_symbol || *message == charcommand_symbol)
  1419. ++message;
  1420. command_name = atcommand_alias_db.checkAlias(message);
  1421. }
  1422. if (!pc_can_use_command(sd, command_name, COMMAND_ATCOMMAND)) {
  1423. sprintf(atcmd_output, msg_txt(sd,153), message); // "%s is Unknown Command"
  1424. clif_displaymessage(fd, atcmd_output);
  1425. atcommand_get_suggestions(sd, command_name, true);
  1426. return -1;
  1427. }
  1428. // attempt to find the first default help command
  1429. std::shared_ptr<s_atcommand_alias_info> info = atcommand_alias_db.find( command_name );
  1430. const char* text = info != nullptr ? info->help.c_str() : nullptr;
  1431. if( text == nullptr ){
  1432. sprintf(atcmd_output, msg_txt(sd,988), atcommand_symbol, command_name); // There is no help for %c%s.
  1433. clif_displaymessage(fd, atcmd_output);
  1434. atcommand_get_suggestions(sd, command_name, true);
  1435. return -1;
  1436. }
  1437. sprintf(atcmd_output, msg_txt(sd,989), atcommand_symbol, command_name); // Help for command %c%s:
  1438. clif_displaymessage(fd, atcmd_output);
  1439. { // Display aliases
  1440. StringBuf buf;
  1441. bool has_aliases = false;
  1442. StringBuf_Init(&buf);
  1443. StringBuf_AppendStr(&buf, msg_txt(sd,990)); // Available aliases:
  1444. for( const std::string& alias : info->aliases ){
  1445. StringBuf_Printf( &buf, " %s", alias.c_str() );
  1446. has_aliases = true;
  1447. }
  1448. if (has_aliases)
  1449. clif_displaymessage(fd, StringBuf_Value(&buf));
  1450. StringBuf_Destroy(&buf);
  1451. }
  1452. // Display help contents
  1453. clif_displaymessage(fd, text);
  1454. return 0;
  1455. }
  1456. /*==========================================
  1457. *
  1458. *------------------------------------------*/
  1459. ACMD_FUNC(pvpoff)
  1460. {
  1461. nullpo_retr(-1, sd);
  1462. if (!map_getmapflag(sd->bl.m, MF_PVP)) {
  1463. clif_displaymessage(fd, msg_txt(sd,160)); // PvP is already Off.
  1464. return -1;
  1465. }
  1466. map_setmapflag(sd->bl.m, MF_PVP, false);
  1467. clif_displaymessage(fd, msg_txt(sd,31)); // PvP: Off.
  1468. return 0;
  1469. }
  1470. /*==========================================
  1471. *
  1472. *------------------------------------------*/
  1473. ACMD_FUNC(pvpon)
  1474. {
  1475. nullpo_retr(-1, sd);
  1476. if (map_getmapflag(sd->bl.m, MF_PVP)) {
  1477. clif_displaymessage(fd, msg_txt(sd,161)); // PvP is already On.
  1478. return -1;
  1479. }
  1480. map_setmapflag(sd->bl.m, MF_PVP, true);
  1481. clif_displaymessage(fd, msg_txt(sd,32)); // PvP: On.
  1482. return 0;
  1483. }
  1484. /*==========================================
  1485. *
  1486. *------------------------------------------*/
  1487. ACMD_FUNC(gvgoff)
  1488. {
  1489. nullpo_retr(-1, sd);
  1490. if (!map_getmapflag(sd->bl.m, MF_GVG)) {
  1491. clif_displaymessage(fd, msg_txt(sd,162)); // GvG is already Off.
  1492. return -1;
  1493. }
  1494. map_setmapflag(sd->bl.m, MF_GVG, false);
  1495. clif_displaymessage(fd, msg_txt(sd,33)); // GvG: Off.
  1496. return 0;
  1497. }
  1498. /*==========================================
  1499. *
  1500. *------------------------------------------*/
  1501. ACMD_FUNC(gvgon)
  1502. {
  1503. nullpo_retr(-1, sd);
  1504. if (map_getmapflag(sd->bl.m, MF_GVG)) {
  1505. clif_displaymessage(fd, msg_txt(sd,163)); // GvG is already On.
  1506. return -1;
  1507. }
  1508. map_setmapflag(sd->bl.m, MF_GVG, true);
  1509. clif_displaymessage(fd, msg_txt(sd,34)); // GvG: On.
  1510. return 0;
  1511. }
  1512. /*==========================================
  1513. *
  1514. *------------------------------------------*/
  1515. ACMD_FUNC(model)
  1516. {
  1517. int hair_style = 0, hair_color = 0, cloth_color = 0;
  1518. nullpo_retr(-1, sd);
  1519. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1520. if (!message || !*message || sscanf(message, "%11d %11d %11d", &hair_style, &hair_color, &cloth_color) < 1) {
  1521. 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>).
  1522. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  1523. clif_displaymessage(fd, atcmd_output);
  1524. return -1;
  1525. }
  1526. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  1527. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  1528. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1529. pc_changelook(sd, LOOK_HAIR, hair_style);
  1530. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1531. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1532. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1533. } else {
  1534. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1535. return -1;
  1536. }
  1537. return 0;
  1538. }
  1539. /*==========================================
  1540. * @bodystyle [Rytech]
  1541. *------------------------------------------*/
  1542. ACMD_FUNC(bodystyle)
  1543. {
  1544. int body_style = 0;
  1545. nullpo_retr(-1, sd);
  1546. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1547. if (!(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) {
  1548. clif_displaymessage(fd, msg_txt(sd,740)); // This job has no alternate body styles.
  1549. return -1;
  1550. }
  1551. if (!message || !*message || sscanf(message, "%d", &body_style) < 1) {
  1552. sprintf(atcmd_output, msg_txt(sd,739), MIN_BODY_STYLE, MAX_BODY_STYLE); // Please enter a body style (usage: @bodystyle <body ID: %d-%d>).
  1553. clif_displaymessage(fd, atcmd_output);
  1554. return -1;
  1555. }
  1556. if (body_style >= MIN_BODY_STYLE && body_style <= MAX_BODY_STYLE) {
  1557. pc_changelook(sd, LOOK_BODY2, body_style);
  1558. clif_displaymessage(fd, msg_txt(sd,36)); // Appearence changed.
  1559. } else {
  1560. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1561. return -1;
  1562. }
  1563. return 0;
  1564. }
  1565. /*==========================================
  1566. * @dye && @ccolor
  1567. *------------------------------------------*/
  1568. ACMD_FUNC(dye)
  1569. {
  1570. int cloth_color = 0;
  1571. nullpo_retr(-1, sd);
  1572. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1573. if (!message || !*message || sscanf(message, "%11d", &cloth_color) < 1) {
  1574. 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>).
  1575. clif_displaymessage(fd, atcmd_output);
  1576. return -1;
  1577. }
  1578. if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1579. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1580. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1581. } else {
  1582. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1583. return -1;
  1584. }
  1585. return 0;
  1586. }
  1587. /*==========================================
  1588. * @hairstyle && @hstyle
  1589. *------------------------------------------*/
  1590. ACMD_FUNC(hair_style)
  1591. {
  1592. int hair_style = 0;
  1593. nullpo_retr(-1, sd);
  1594. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1595. if (!message || !*message || sscanf(message, "%11d", &hair_style) < 1) {
  1596. 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>).
  1597. clif_displaymessage(fd, atcmd_output);
  1598. return -1;
  1599. }
  1600. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
  1601. pc_changelook(sd, LOOK_HAIR, hair_style);
  1602. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1603. } else {
  1604. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1605. return -1;
  1606. }
  1607. return 0;
  1608. }
  1609. /*==========================================
  1610. * @haircolor && @hcolor
  1611. *------------------------------------------*/
  1612. ACMD_FUNC(hair_color)
  1613. {
  1614. int hair_color = 0;
  1615. nullpo_retr(-1, sd);
  1616. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1617. if (!message || !*message || sscanf(message, "%11d", &hair_color) < 1) {
  1618. 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>).
  1619. clif_displaymessage(fd, atcmd_output);
  1620. return -1;
  1621. }
  1622. if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
  1623. pc_changelook(sd, LOOK_HAIR_COLOR, hair_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. * @go [city_number or city_name] - Updated by Harbin
  1633. *------------------------------------------*/
  1634. ACMD_FUNC(go)
  1635. {
  1636. int i;
  1637. int town;
  1638. char map_name[MAP_NAME_LENGTH];
  1639. const struct {
  1640. char map[MAP_NAME_LENGTH];
  1641. int x, y;
  1642. } data[] = {
  1643. { MAP_PRONTERA, 156, 191 }, // 0=Prontera
  1644. { MAP_MORROC, 156, 93 }, // 1=Morroc
  1645. { MAP_GEFFEN, 119, 59 }, // 2=Geffen
  1646. { MAP_PAYON, 162, 233 }, // 3=Payon
  1647. { MAP_ALBERTA, 192, 147 }, // 4=Alberta
  1648. #ifdef RENEWAL
  1649. { MAP_IZLUDE, 128, 146 }, // 5=Izlude (Renewal)
  1650. #else
  1651. { MAP_IZLUDE, 128, 114 }, // 5=Izlude
  1652. #endif
  1653. { MAP_ALDEBARAN, 140, 131 }, // 6=Al de Baran
  1654. { MAP_LUTIE, 147, 134 }, // 7=Lutie
  1655. { MAP_COMODO, 209, 143 }, // 8=Comodo
  1656. { MAP_YUNO, 157, 51 }, // 9=Yuno
  1657. { MAP_AMATSU, 198, 84 }, // 10=Amatsu
  1658. { MAP_GONRYUN, 160, 120 }, // 11=Gonryun
  1659. { MAP_UMBALA, 89, 157 }, // 12=Umbala
  1660. { MAP_NIFLHEIM, 21, 153 }, // 13=Niflheim
  1661. { MAP_LOUYANG, 217, 40 }, // 14=Louyang
  1662. #ifdef RENEWAL
  1663. { MAP_NOVICE, 18, 26 }, // 15=Training Grounds (Renewal)
  1664. #else
  1665. { MAP_NOVICE, 53, 111 }, // 15=Training Grounds
  1666. #endif
  1667. { MAP_JAIL, 23, 61 }, // 16=Prison
  1668. { MAP_JAWAII, 249, 127 }, // 17=Jawaii
  1669. { MAP_AYOTHAYA, 151, 117 }, // 18=Ayothaya
  1670. { MAP_EINBROCH, 64, 200 }, // 19=Einbroch
  1671. { MAP_LIGHTHALZEN, 158, 92 }, // 20=Lighthalzen
  1672. { MAP_EINBECH, 70, 95 }, // 21=Einbech
  1673. { MAP_HUGEL, 96, 145 }, // 22=Hugel
  1674. { MAP_RACHEL, 130, 110 }, // 23=Rachel
  1675. { MAP_VEINS, 216, 123 }, // 24=Veins
  1676. { MAP_MOSCOVIA, 223, 184 }, // 25=Moscovia
  1677. { MAP_MIDCAMP, 180, 240 }, // 26=Midgard Camp
  1678. { MAP_MANUK, 282, 138 }, // 27=Manuk
  1679. { MAP_SPLENDIDE, 201, 147 }, // 28=Splendide
  1680. { MAP_BRASILIS, 182, 239 }, // 29=Brasilis
  1681. { MAP_DICASTES, 198, 187 }, // 30=El Dicastes
  1682. { MAP_MORA, 44, 151 }, // 31=Mora
  1683. { MAP_DEWATA, 200, 180 }, // 32=Dewata
  1684. { MAP_MALANGDO, 140, 114 }, // 33=Malangdo Island
  1685. { MAP_MALAYA, 242, 211 }, // 34=Malaya Port
  1686. { MAP_ECLAGE, 110, 39 }, // 35=Eclage
  1687. { MAP_LASAGNA, 193, 182 }, // 36=Lasagna
  1688. };
  1689. nullpo_retr(-1, sd);
  1690. if( map_getmapflag(sd->bl.m, MF_NOGO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE) ) {
  1691. clif_displaymessage(sd->fd,msg_txt(sd,995)); // You cannot use @go on this map.
  1692. return 0;
  1693. }
  1694. memset(map_name, '\0', sizeof(map_name));
  1695. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1696. // get the number
  1697. town = atoi(message);
  1698. if (!message || !*message || sscanf(message, "%11s", map_name) < 1 || town < 0 || town >= ARRAYLENGTH(data))
  1699. {// no value matched so send the list of locations
  1700. const char* text;
  1701. // attempt to find the text help string
  1702. text = atcommand_help_string( command );
  1703. clif_displaymessage(fd, msg_txt(sd,38)); // Invalid location number, or name.
  1704. if( text )
  1705. {// send the text to the client
  1706. clif_displaymessage( fd, text );
  1707. }
  1708. return -1;
  1709. }
  1710. // get possible name of the city
  1711. map_name[MAP_NAME_LENGTH-1] = '\0';
  1712. for (i = 0; map_name[i]; i++)
  1713. map_name[i] = TOLOWER(map_name[i]);
  1714. // try to identify the map name
  1715. if (strncmp(map_name, "prontera", 3) == 0) {
  1716. town = 0;
  1717. } else if (strncmp(map_name, "morocc", 4) == 0 ||
  1718. strncmp(map_name, "morroc", 4) == 0) {
  1719. town = 1;
  1720. } else if (strncmp(map_name, "geffen", 3) == 0) {
  1721. town = 2;
  1722. } else if (strncmp(map_name, "payon", 3) == 0) {
  1723. town = 3;
  1724. } else if (strncmp(map_name, "alberta", 3) == 0) {
  1725. town = 4;
  1726. } else if (strncmp(map_name, "izlude", 3) == 0) {
  1727. town = 5;
  1728. } else if (strncmp(map_name, "aldebaran", 3) == 0) {
  1729. town = 6;
  1730. } else if (strncmp(map_name, "lutie", 3) == 0 ||
  1731. strcmp(map_name, "christmas") == 0 ||
  1732. strncmp(map_name, "xmas", 3) == 0 ||
  1733. strncmp(map_name, "x-mas", 3) == 0) {
  1734. town = 7;
  1735. } else if (strncmp(map_name, "comodo", 3) == 0) {
  1736. town = 8;
  1737. } else if (strncmp(map_name, "juno", 3) == 0 ||
  1738. strncmp(map_name, "yuno", 3) == 0) {
  1739. town = 9;
  1740. } else if (strncmp(map_name, "amatsu", 3) == 0) {
  1741. town = 10;
  1742. } else if (strncmp(map_name, "kunlun", 3) == 0 ||
  1743. strncmp(map_name, "gonryun", 3) == 0) {
  1744. town = 11;
  1745. } else if (strncmp(map_name, "umbala", 3) == 0) {
  1746. town = 12;
  1747. } else if (strncmp(map_name, "niflheim", 3) == 0) {
  1748. town = 13;
  1749. } else if (strncmp(map_name, "louyang", 3) == 0) {
  1750. town = 14;
  1751. } else if (strncmp(map_name, "new_1-1", 3) == 0 ||
  1752. strncmp(map_name, "startpoint", 3) == 0 ||
  1753. strncmp(map_name, "beginning", 3) == 0) {
  1754. town = 15;
  1755. } else if (strncmp(map_name, "sec_pri", 3) == 0 ||
  1756. strncmp(map_name, "prison", 3) == 0 ||
  1757. strncmp(map_name, "jail", 3) == 0) {
  1758. town = 16;
  1759. } else if (strncmp(map_name, "jawaii", 3) == 0) {
  1760. town = 17;
  1761. } else if (strncmp(map_name, "ayothaya", 3) == 0) {
  1762. town = 18;
  1763. } else if (strncmp(map_name, "einbroch", 5) == 0) {
  1764. town = 19;
  1765. } else if (strncmp(map_name, "lighthalzen", 3) == 0) {
  1766. town = 20;
  1767. } else if (strncmp(map_name, "einbech", 5) == 0) {
  1768. town = 21;
  1769. } else if (strncmp(map_name, "hugel", 3) == 0) {
  1770. town = 22;
  1771. } else if (strncmp(map_name, "rachel", 3) == 0) {
  1772. town = 23;
  1773. } else if (strncmp(map_name, "veins", 3) == 0) {
  1774. town = 24;
  1775. } else if (strncmp(map_name, "moscovia", 3) == 0) {
  1776. town = 25;
  1777. } else if (strncmp(map_name, "mid_camp", 3) == 0) {
  1778. town = 26;
  1779. } else if (strncmp(map_name, "manuk", 3) == 0) {
  1780. town = 27;
  1781. } else if (strncmp(map_name, "splendide", 3) == 0) {
  1782. town = 28;
  1783. } else if (strncmp(map_name, "brasilis", 3) == 0) {
  1784. town = 29;
  1785. } else if (strncmp(map_name, "dicastes01", 3) == 0) {
  1786. town = 30;
  1787. } else if (strcmp(map_name, "mora") == 0) {
  1788. town = 31;
  1789. } else if (strncmp(map_name, "dewata", 3) == 0) {
  1790. town = 32;
  1791. } else if (strncmp(map_name, "malangdo", 5) == 0) {
  1792. town = 33;
  1793. } else if (strncmp(map_name, "malaya", 5) == 0) {
  1794. town = 34;
  1795. } else if (strncmp(map_name, "eclage", 3) == 0) {
  1796. town = 35;
  1797. } else if (strncmp(map_name, "lasagna", 2) == 0) {
  1798. town = 36;
  1799. }
  1800. if (town >= 0 && town < ARRAYLENGTH(data))
  1801. {
  1802. int16 m = map_mapname2mapid(data[town].map);
  1803. if (m >= 0 && map_getmapflag(m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  1804. clif_displaymessage(fd, msg_txt(sd,247)); // You are not authorized to warp to this map.
  1805. return -1;
  1806. }
  1807. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  1808. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  1809. return -1;
  1810. }
  1811. if (pc_setpos(sd, mapindex_name2id(data[town].map), data[town].x, data[town].y, CLR_TELEPORT) == SETPOS_OK) {
  1812. clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
  1813. } else {
  1814. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  1815. return -1;
  1816. }
  1817. } else { // if you arrive here, you have an error in town variable when reading of names
  1818. clif_displaymessage(fd, msg_txt(sd,38)); // Invalid location number or name.
  1819. return -1;
  1820. }
  1821. return 0;
  1822. }
  1823. /*==========================================
  1824. *
  1825. *------------------------------------------*/
  1826. ACMD_FUNC(monster)
  1827. {
  1828. char name[NAME_LENGTH];
  1829. char monster[NAME_LENGTH];
  1830. char eventname[EVENT_NAME_LENGTH] = "";
  1831. int mob_id;
  1832. int number = 0;
  1833. int count;
  1834. int i, range;
  1835. short mx, my;
  1836. unsigned int size;
  1837. nullpo_retr(-1, sd);
  1838. memset(name, '\0', sizeof(name));
  1839. memset(monster, '\0', sizeof(monster));
  1840. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1841. if (!message || !*message) {
  1842. clif_displaymessage(fd, msg_txt(sd,80)); // Give the display name or monster name/id please.
  1843. return -1;
  1844. }
  1845. if (sscanf(message, "\"%23[^\"]\" %23s %11d", name, monster, &number) > 1 ||
  1846. sscanf(message, "%23s \"%23[^\"]\" %11d", monster, name, &number) > 1) {
  1847. //All data can be left as it is.
  1848. } else if ((count=sscanf(message, "%23s %11d %23s", monster, &number, name)) > 1) {
  1849. //Here, it is possible name was not given and we are using monster for it.
  1850. if (count < 3) //Blank mob's name.
  1851. name[0] = '\0';
  1852. } else if (sscanf(message, "%23s %23s %11d", name, monster, &number) > 1) {
  1853. //All data can be left as it is.
  1854. } else if (sscanf(message, "%23s", monster) > 0) {
  1855. //As before, name may be already filled.
  1856. name[0] = '\0';
  1857. } else {
  1858. clif_displaymessage(fd, msg_txt(sd,80)); // Give a display name and monster name/id please.
  1859. return -1;
  1860. }
  1861. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  1862. mob_id = mobdb_checkid(atoi(monster));
  1863. if (mob_id == 0) {
  1864. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  1865. return -1;
  1866. }
  1867. if (mob_id == MOBID_EMPERIUM) {
  1868. clif_displaymessage(fd, msg_txt(sd,83)); // Monster 'Emperium' cannot be spawned.
  1869. return -1;
  1870. }
  1871. if (number <= 0)
  1872. number = 1;
  1873. if( !name[0] )
  1874. strcpy(name, "--ja--");
  1875. // 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
  1876. if (battle_config.atc_spawn_quantity_limit && number > battle_config.atc_spawn_quantity_limit)
  1877. number = battle_config.atc_spawn_quantity_limit;
  1878. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  1879. if (strcmp(parent_cmd, "monstersmall") == 0)
  1880. size = SZ_MEDIUM; // This is just gorgeous [mkbu95]
  1881. else if (strcmp(parent_cmd, "monsterbig") == 0)
  1882. size = SZ_BIG;
  1883. else
  1884. size = SZ_SMALL;
  1885. if (battle_config.etc_log)
  1886. 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);
  1887. count = 0;
  1888. range = (int)sqrt((float)number) +2; // calculation of an odd number (+ 4 area around)
  1889. for (i = 0; i < number; i++) {
  1890. int k;
  1891. map_search_freecell(&sd->bl, 0, &mx, &my, range, range, 0);
  1892. k = mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, eventname, size, AI_NONE);
  1893. if(k) {
  1894. //mapreg_setreg(reference_uid(add_str("$@mobid"), i),k); //retain created mobid in array uncomment if needed
  1895. count ++;
  1896. }
  1897. }
  1898. if (count != 0)
  1899. if (number == count)
  1900. clif_displaymessage(fd, msg_txt(sd,39)); // All monster summoned!
  1901. else {
  1902. sprintf(atcmd_output, msg_txt(sd,240), count); // %d monster(s) summoned!
  1903. clif_displaymessage(fd, atcmd_output);
  1904. }
  1905. else {
  1906. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  1907. return -1;
  1908. }
  1909. return 0;
  1910. }
  1911. /*==========================================
  1912. *
  1913. *------------------------------------------*/
  1914. static int atkillmonster_sub(struct block_list *bl, va_list ap)
  1915. {
  1916. struct mob_data *md;
  1917. int flag;
  1918. nullpo_ret(md=(struct mob_data *)bl);
  1919. flag = va_arg(ap, int);
  1920. if (md->guardian_data)
  1921. return 0; //Do not touch WoE mobs!
  1922. if (flag)
  1923. status_zap(bl,md->status.hp, 0);
  1924. else
  1925. status_kill(bl);
  1926. return 1;
  1927. }
  1928. ACMD_FUNC(killmonster)
  1929. {
  1930. int map_id, drop_flag;
  1931. char map_name[MAP_NAME_LENGTH_EXT];
  1932. nullpo_retr(-1, sd);
  1933. memset(map_name, '\0', sizeof(map_name));
  1934. if (!message || !*message || sscanf(message, "%15s", map_name) < 1)
  1935. map_id = sd->bl.m;
  1936. else {
  1937. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1938. map_id = sd->bl.m;
  1939. }
  1940. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  1941. drop_flag = strcmp(parent_cmd, "killmonster2");
  1942. map_foreachinmap(atkillmonster_sub, map_id, BL_MOB, -drop_flag);
  1943. clif_displaymessage(fd, msg_txt(sd,165)); // All monsters killed!
  1944. return 0;
  1945. }
  1946. /*==========================================
  1947. *
  1948. *------------------------------------------*/
  1949. ACMD_FUNC(refine)
  1950. {
  1951. int j, position = 0, refine = 0, current_position, final_refine;
  1952. int count;
  1953. nullpo_retr(-1, sd);
  1954. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1955. if (!message || !*message || sscanf(message, "%11d %11d", &position, &refine) < 2) {
  1956. clif_displaymessage(fd, msg_txt(sd,996)); // Please enter a position and an amount (usage: @refine <equip position> <+/- amount>).
  1957. sprintf(atcmd_output, msg_txt(sd,997), EQP_HEAD_LOW); // %d: Lower Headgear
  1958. clif_displaymessage(fd, atcmd_output);
  1959. sprintf(atcmd_output, msg_txt(sd,998), EQP_HAND_R); // %d: Right Hand
  1960. clif_displaymessage(fd, atcmd_output);
  1961. sprintf(atcmd_output, msg_txt(sd,999), EQP_GARMENT); // %d: Garment
  1962. clif_displaymessage(fd, atcmd_output);
  1963. sprintf(atcmd_output, msg_txt(sd,1000), EQP_ACC_L); // %d: Left Accessory
  1964. clif_displaymessage(fd, atcmd_output);
  1965. sprintf(atcmd_output, msg_txt(sd,1001), EQP_ARMOR); // %d: Body Armor
  1966. clif_displaymessage(fd, atcmd_output);
  1967. sprintf(atcmd_output, msg_txt(sd,1002), EQP_HAND_L); // %d: Left Hand
  1968. clif_displaymessage(fd, atcmd_output);
  1969. sprintf(atcmd_output, msg_txt(sd,1003), EQP_SHOES); // %d: Shoes
  1970. clif_displaymessage(fd, atcmd_output);
  1971. sprintf(atcmd_output, msg_txt(sd,1004), EQP_ACC_R); // %d: Right Accessory
  1972. clif_displaymessage(fd, atcmd_output);
  1973. sprintf(atcmd_output, msg_txt(sd,1005), EQP_HEAD_TOP); // %d: Top Headgear
  1974. clif_displaymessage(fd, atcmd_output);
  1975. sprintf(atcmd_output, msg_txt(sd,1006), EQP_HEAD_MID); // %d: Mid Headgear
  1976. clif_displaymessage(fd, atcmd_output);
  1977. return -1;
  1978. }
  1979. refine = cap_value(refine, -MAX_REFINE, MAX_REFINE);
  1980. count = 0;
  1981. for (j = 0; j < EQI_MAX; j++) {
  1982. int i;
  1983. if ((i = sd->equip_index[j]) < 0)
  1984. continue;
  1985. if(j == EQI_AMMO)
  1986. continue;
  1987. if (pc_is_same_equip_index((enum equip_index)j, sd->equip_index, i))
  1988. continue;
  1989. if(position && !(sd->inventory.u.items_inventory[i].equip & position))
  1990. continue;
  1991. final_refine = cap_value(sd->inventory.u.items_inventory[i].refine + refine, 0, MAX_REFINE);
  1992. if (sd->inventory.u.items_inventory[i].refine != final_refine) {
  1993. sd->inventory.u.items_inventory[i].refine = final_refine;
  1994. current_position = sd->inventory.u.items_inventory[i].equip;
  1995. pc_unequipitem(sd, i, 3);
  1996. clif_refine(fd, 0, i, sd->inventory.u.items_inventory[i].refine);
  1997. clif_delitem(sd, i, 1, 3);
  1998. clif_additem(sd, i, 1, 0);
  1999. pc_equipitem(sd, i, current_position);
  2000. clif_misceffect(&sd->bl, 3);
  2001. achievement_update_objective(sd, AG_REFINE_SUCCESS, 2, sd->inventory_data[i]->wlv, sd->inventory.u.items_inventory[i].refine);
  2002. count++;
  2003. }
  2004. }
  2005. if (count == 0)
  2006. clif_displaymessage(fd, msg_txt(sd,166)); // No item has been refined.
  2007. else if (count == 1)
  2008. clif_displaymessage(fd, msg_txt(sd,167)); // 1 item has been refined.
  2009. else {
  2010. sprintf(atcmd_output, msg_txt(sd,168), count); // %d items have been refined.
  2011. clif_displaymessage(fd, atcmd_output);
  2012. }
  2013. return 0;
  2014. }
  2015. /*==========================================
  2016. *
  2017. *------------------------------------------*/
  2018. ACMD_FUNC(produce)
  2019. {
  2020. char item_name[100];
  2021. unsigned short item_id;
  2022. int attribute = 0, star = 0;
  2023. struct item_data *item_data;
  2024. struct item tmp_item;
  2025. nullpo_retr(-1, sd);
  2026. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2027. memset(item_name, '\0', sizeof(item_name));
  2028. if (!message || !*message || (
  2029. sscanf(message, "\"%99[^\"]\" %11d %11d", item_name, &attribute, &star) < 1 &&
  2030. sscanf(message, "%99s %11d %11d", item_name, &attribute, &star) < 1
  2031. )) {
  2032. clif_displaymessage(fd, msg_txt(sd,1007)); // Please enter at least one item name/ID (usage: @produce <equip name/ID> <element> <# of very's>).
  2033. return -1;
  2034. }
  2035. if ( (item_data = itemdb_searchname(item_name)) == NULL &&
  2036. (item_data = itemdb_exists(atoi(item_name))) == NULL ) {
  2037. clif_displaymessage(fd, msg_txt(sd,170)); //This item is not an equipment.
  2038. return -1;
  2039. }
  2040. item_id = item_data->nameid;
  2041. if (itemdb_isequip2(item_data)) {
  2042. char flag = 0;
  2043. if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
  2044. attribute = ATTRIBUTE_NORMAL;
  2045. if (star < MIN_STAR || star > MAX_STAR)
  2046. star = 0;
  2047. memset(&tmp_item, 0, sizeof tmp_item);
  2048. tmp_item.nameid = item_id;
  2049. tmp_item.amount = 1;
  2050. tmp_item.identify = 1;
  2051. tmp_item.card[0] = CARD0_FORGE;
  2052. tmp_item.card[1] = item_data->type==IT_WEAPON?
  2053. ((star*5) << 8) + attribute:0;
  2054. tmp_item.card[2] = GetWord(sd->status.char_id, 0);
  2055. tmp_item.card[3] = GetWord(sd->status.char_id, 1);
  2056. clif_produceeffect(sd, 0, item_id);
  2057. clif_misceffect(&sd->bl, 3);
  2058. if ((flag = pc_additem(sd, &tmp_item, 1, LOG_TYPE_COMMAND)))
  2059. clif_additem(sd, 0, 0, flag);
  2060. } else {
  2061. sprintf(atcmd_output, msg_txt(sd,169), item_id, item_data->name); // The item (%hu: '%s') is not equipable.
  2062. clif_displaymessage(fd, atcmd_output);
  2063. return -1;
  2064. }
  2065. return 0;
  2066. }
  2067. /*==========================================
  2068. *
  2069. *------------------------------------------*/
  2070. ACMD_FUNC(memo)
  2071. {
  2072. int position = 0;
  2073. nullpo_retr(-1, sd);
  2074. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2075. if( !message || !*message || sscanf(message, "%11d", &position) < 1 )
  2076. {
  2077. int i;
  2078. clif_displaymessage(sd->fd, msg_txt(sd,668)); // Your actual memo positions are:
  2079. for( i = 0; i < MAX_MEMOPOINTS; i++ )
  2080. {
  2081. if( sd->status.memo_point[i].map )
  2082. 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);
  2083. else
  2084. sprintf(atcmd_output, msg_txt(sd,171), i); // %d - void
  2085. clif_displaymessage(sd->fd, atcmd_output);
  2086. }
  2087. return 0;
  2088. }
  2089. if( position < 0 || position >= MAX_MEMOPOINTS )
  2090. {
  2091. sprintf(atcmd_output, msg_txt(sd,1008), 0, MAX_MEMOPOINTS-1); // Please enter a valid position (usage: @memo <memo_position:%d-%d>).
  2092. clif_displaymessage(fd, atcmd_output);
  2093. return -1;
  2094. }
  2095. return !pc_memo( sd, position );
  2096. }
  2097. /*==========================================
  2098. *
  2099. *------------------------------------------*/
  2100. ACMD_FUNC(gat)
  2101. {
  2102. int y;
  2103. nullpo_retr(-1, sd);
  2104. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2105. for (y = 2; y >= -2; y--) {
  2106. sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
  2107. map_getmapdata(sd->bl.m)->name, sd->bl.x - 2, sd->bl.y + y,
  2108. map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE),
  2109. map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE),
  2110. map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE),
  2111. map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE),
  2112. map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE));
  2113. clif_displaymessage(fd, atcmd_output);
  2114. }
  2115. return 0;
  2116. }
  2117. /*==========================================
  2118. *
  2119. *------------------------------------------*/
  2120. ACMD_FUNC(displaystatus)
  2121. {
  2122. int i, type, flag, tick, val1 = 0, val2 = 0, val3 = 0;
  2123. nullpo_retr(-1, sd);
  2124. if (!message || !*message || (i = sscanf(message, "%11d %11d %11d %11d %11d %11d", &type, &flag, &tick, &val1, &val2, &val3)) < 1) {
  2125. clif_displaymessage(fd, msg_txt(sd,1009)); // Please enter a status type/flag (usage: @displaystatus <status type> <flag> <tick> {<val1> {<val2> {<val3>}}}).
  2126. return -1;
  2127. }
  2128. if (i < 2) flag = 1;
  2129. if (i < 3) tick = 0;
  2130. clif_status_change(&sd->bl, type, flag, tick, val1, val2, val3);
  2131. return 0;
  2132. }
  2133. /*==========================================
  2134. * @stpoint (Rewritten by [Yor])
  2135. *------------------------------------------*/
  2136. ACMD_FUNC(statuspoint)
  2137. {
  2138. int point;
  2139. unsigned int new_status_point;
  2140. if (!message || !*message || (point = atoi(message)) == 0) {
  2141. clif_displaymessage(fd, msg_txt(sd,1010)); // Please enter a number (usage: @stpoint <number of points>).
  2142. return -1;
  2143. }
  2144. if(point < 0)
  2145. {
  2146. if(sd->status.status_point < (unsigned int)(-point))
  2147. {
  2148. new_status_point = 0;
  2149. }
  2150. else
  2151. {
  2152. new_status_point = sd->status.status_point + point;
  2153. }
  2154. }
  2155. else if(UINT_MAX - sd->status.status_point < (unsigned int)point)
  2156. {
  2157. new_status_point = UINT_MAX;
  2158. }
  2159. else
  2160. {
  2161. new_status_point = sd->status.status_point + point;
  2162. }
  2163. if (new_status_point != sd->status.status_point) {
  2164. sd->status.status_point = new_status_point;
  2165. clif_updatestatus(sd, SP_STATUSPOINT);
  2166. clif_displaymessage(fd, msg_txt(sd,174)); // Number of status points changed.
  2167. } else {
  2168. if (point < 0)
  2169. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2170. else
  2171. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2172. return -1;
  2173. }
  2174. return 0;
  2175. }
  2176. /*==========================================
  2177. * @skpoint (Rewritten by [Yor])
  2178. *------------------------------------------*/
  2179. ACMD_FUNC(skillpoint)
  2180. {
  2181. int point;
  2182. unsigned int new_skill_point;
  2183. nullpo_retr(-1, sd);
  2184. if (!message || !*message || (point = atoi(message)) == 0) {
  2185. clif_displaymessage(fd, msg_txt(sd,1011)); // Please enter a number (usage: @skpoint <number of points>).
  2186. return -1;
  2187. }
  2188. if(point < 0)
  2189. {
  2190. if(sd->status.skill_point < (unsigned int)(-point))
  2191. {
  2192. new_skill_point = 0;
  2193. }
  2194. else
  2195. {
  2196. new_skill_point = sd->status.skill_point + point;
  2197. }
  2198. }
  2199. else if(UINT_MAX - sd->status.skill_point < (unsigned int)point)
  2200. {
  2201. new_skill_point = UINT_MAX;
  2202. }
  2203. else
  2204. {
  2205. new_skill_point = sd->status.skill_point + point;
  2206. }
  2207. if (new_skill_point != sd->status.skill_point) {
  2208. sd->status.skill_point = new_skill_point;
  2209. clif_updatestatus(sd, SP_SKILLPOINT);
  2210. clif_displaymessage(fd, msg_txt(sd,175)); // Number of skill points changed.
  2211. } else {
  2212. if (point < 0)
  2213. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2214. else
  2215. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2216. return -1;
  2217. }
  2218. return 0;
  2219. }
  2220. /*==========================================
  2221. * @zeny
  2222. *------------------------------------------*/
  2223. ACMD_FUNC(zeny)
  2224. {
  2225. int zeny=0, ret=-1;
  2226. nullpo_retr(-1, sd);
  2227. if (!message || !*message || (zeny = atoi(message)) == 0) {
  2228. clif_displaymessage(fd, msg_txt(sd,1012)); // Please enter an amount (usage: @zeny <amount>).
  2229. return -1;
  2230. }
  2231. if(zeny > 0){
  2232. if((ret=pc_getzeny(sd,zeny,LOG_TYPE_COMMAND,NULL)) == 1)
  2233. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2234. }
  2235. else {
  2236. if( sd->status.zeny < -zeny ) zeny = -sd->status.zeny;
  2237. if((ret=pc_payzeny(sd,-zeny,LOG_TYPE_COMMAND,NULL)) == 1)
  2238. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2239. }
  2240. if(!ret) clif_displaymessage(fd, msg_txt(sd,176)); //ret=0 mean cmd success
  2241. return 0;
  2242. }
  2243. /*==========================================
  2244. *
  2245. *------------------------------------------*/
  2246. ACMD_FUNC(param)
  2247. {
  2248. uint8 i;
  2249. int value = 0;
  2250. const char* param[] = { "str", "agi", "vit", "int", "dex", "luk" };
  2251. unsigned short new_value, *status[6], max_status[6];
  2252. //we don't use direct initialization because it isn't part of the c standard.
  2253. nullpo_retr(-1, sd);
  2254. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2255. if (!message || !*message || sscanf(message, "%11d", &value) < 1 || value == 0) {
  2256. clif_displaymessage(fd, msg_txt(sd,1013)); // Please enter a valid value (usage: @str/@agi/@vit/@int/@dex/@luk <+/-adjustment>).
  2257. return -1;
  2258. }
  2259. ARR_FIND( 0, ARRAYLENGTH(param), i, strcmpi(command+1, param[i]) == 0 );
  2260. if( i == ARRAYLENGTH(param) || i > MAX_STATUS_TYPE) { // normally impossible...
  2261. clif_displaymessage(fd, msg_txt(sd,1013)); // Please enter a valid value (usage: @str/@agi/@vit/@int/@dex/@luk <+/-adjustment>).
  2262. return -1;
  2263. }
  2264. status[0] = &sd->status.str;
  2265. status[1] = &sd->status.agi;
  2266. status[2] = &sd->status.vit;
  2267. status[3] = &sd->status.int_;
  2268. status[4] = &sd->status.dex;
  2269. status[5] = &sd->status.luk;
  2270. if( pc_has_permission(sd, PC_PERM_BYPASS_MAX_STAT) )
  2271. max_status[0] = max_status[1] = max_status[2] = max_status[3] = max_status[4] = max_status[5] = SHRT_MAX;
  2272. else {
  2273. max_status[0] = pc_maxparameter(sd,PARAM_STR);
  2274. max_status[1] = pc_maxparameter(sd,PARAM_AGI);
  2275. max_status[2] = pc_maxparameter(sd,PARAM_VIT);
  2276. max_status[3] = pc_maxparameter(sd,PARAM_INT);
  2277. max_status[4] = pc_maxparameter(sd,PARAM_DEX);
  2278. max_status[5] = pc_maxparameter(sd,PARAM_LUK);
  2279. }
  2280. if(value > 0 && *status[i] + value >= max_status[i])
  2281. new_value = max_status[i];
  2282. else if(value < 0 && *status[i] <= -value)
  2283. new_value = 1;
  2284. else
  2285. new_value = *status[i] + value;
  2286. if (new_value != *status[i]) {
  2287. *status[i] = new_value;
  2288. clif_updatestatus(sd, SP_STR + i);
  2289. clif_updatestatus(sd, SP_USTR + i);
  2290. status_calc_pc(sd, SCO_FORCE);
  2291. clif_displaymessage(fd, msg_txt(sd,42)); // Stat changed.
  2292. achievement_update_objective(sd, AG_GOAL_STATUS, 0);
  2293. } else {
  2294. if (value < 0)
  2295. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2296. else
  2297. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2298. return -1;
  2299. }
  2300. return 0;
  2301. }
  2302. /*==========================================
  2303. * Stat all by fritz (rewritten by [Yor])
  2304. *------------------------------------------*/
  2305. ACMD_FUNC(stat_all)
  2306. {
  2307. int value = 0;
  2308. uint8 count, i;
  2309. unsigned short *status[PARAM_MAX], max_status[PARAM_MAX];
  2310. //we don't use direct initialization because it isn't part of the c standard.
  2311. nullpo_retr(-1, sd);
  2312. status[0] = &sd->status.str;
  2313. status[1] = &sd->status.agi;
  2314. status[2] = &sd->status.vit;
  2315. status[3] = &sd->status.int_;
  2316. status[4] = &sd->status.dex;
  2317. status[5] = &sd->status.luk;
  2318. if (!message || !*message || sscanf(message, "%11d", &value) < 1 || value == 0) {
  2319. max_status[0] = pc_maxparameter(sd,PARAM_STR);
  2320. max_status[1] = pc_maxparameter(sd,PARAM_AGI);
  2321. max_status[2] = pc_maxparameter(sd,PARAM_VIT);
  2322. max_status[3] = pc_maxparameter(sd,PARAM_INT);
  2323. max_status[4] = pc_maxparameter(sd,PARAM_DEX);
  2324. max_status[5] = pc_maxparameter(sd,PARAM_LUK);
  2325. value = SHRT_MAX;
  2326. } else {
  2327. if( pc_has_permission(sd, PC_PERM_BYPASS_MAX_STAT) )
  2328. max_status[0] = max_status[1] = max_status[2] = max_status[3] = max_status[4] = max_status[5] = SHRT_MAX;
  2329. else {
  2330. max_status[0] = pc_maxparameter(sd,PARAM_STR);
  2331. max_status[1] = pc_maxparameter(sd,PARAM_AGI);
  2332. max_status[2] = pc_maxparameter(sd,PARAM_VIT);
  2333. max_status[3] = pc_maxparameter(sd,PARAM_INT);
  2334. max_status[4] = pc_maxparameter(sd,PARAM_DEX);
  2335. max_status[5] = pc_maxparameter(sd,PARAM_LUK);
  2336. }
  2337. }
  2338. count = 0;
  2339. for (i = 0; i < ARRAYLENGTH(status); i++) {
  2340. short new_value;
  2341. if (value > 0 && *status[i] + value >= max_status[i])
  2342. new_value = max_status[i];
  2343. else if (value < 0 && *status[i] <= -value)
  2344. new_value = 1;
  2345. else
  2346. new_value = *status[i] + value;
  2347. if (new_value != *status[i]) {
  2348. *status[i] = new_value;
  2349. clif_updatestatus(sd, SP_STR + i);
  2350. clif_updatestatus(sd, SP_USTR + i);
  2351. count++;
  2352. }
  2353. }
  2354. if (count > 0) { // if at least 1 stat modified
  2355. status_calc_pc(sd, SCO_FORCE);
  2356. clif_displaymessage(fd, msg_txt(sd,84)); // All stats changed!
  2357. achievement_update_objective(sd, AG_GOAL_STATUS, 0);
  2358. } else {
  2359. if (value < 0)
  2360. clif_displaymessage(fd, msg_txt(sd,177)); // You cannot decrease that stat anymore.
  2361. else
  2362. clif_displaymessage(fd, msg_txt(sd,178)); // You cannot increase that stat anymore.
  2363. return -1;
  2364. }
  2365. return 0;
  2366. }
  2367. /*==========================================
  2368. *
  2369. *------------------------------------------*/
  2370. ACMD_FUNC(guildlevelup) {
  2371. int level = 0;
  2372. short added_level;
  2373. struct guild *guild_info;
  2374. nullpo_retr(-1, sd);
  2375. if (!message || !*message || sscanf(message, "%11d", &level) < 1 || level == 0) {
  2376. clif_displaymessage(fd, msg_txt(sd,1014)); // Please enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).
  2377. return -1;
  2378. }
  2379. if (sd->status.guild_id <= 0 || (guild_info = sd->guild) == NULL) {
  2380. clif_displaymessage(fd, msg_txt(sd,43)); // You're not in a guild.
  2381. return -1;
  2382. }
  2383. //if (strcmp(sd->status.name, guild_info->master) != 0) {
  2384. // clif_displaymessage(fd, msg_txt(sd,44)); // You're not the master of your guild.
  2385. // return -1;
  2386. //}
  2387. added_level = (short)level;
  2388. if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild_lv))) // fix positive overflow
  2389. added_level = (short)MAX_GUILDLEVEL - guild_info->guild_lv;
  2390. else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild_lv))) // fix negative overflow
  2391. added_level = 1 - guild_info->guild_lv;
  2392. if (added_level != 0) {
  2393. intif_guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, sizeof(added_level));
  2394. clif_displaymessage(fd, msg_txt(sd,179)); // Guild level changed.
  2395. } else {
  2396. clif_displaymessage(fd, msg_txt(sd,45)); // Guild level change failed.
  2397. return -1;
  2398. }
  2399. return 0;
  2400. }
  2401. /*==========================================
  2402. *
  2403. *------------------------------------------*/
  2404. ACMD_FUNC(makeegg) {
  2405. struct item_data *item_data;
  2406. int id;
  2407. nullpo_retr(-1, sd);
  2408. if (!message || !*message) {
  2409. clif_displaymessage(fd, msg_txt(sd,1015)); // Please enter a monster/egg name/ID (usage: @makeegg <pet>).
  2410. return -1;
  2411. }
  2412. if ((item_data = itemdb_searchname(message)) != NULL) // for egg name
  2413. id = item_data->nameid;
  2414. else
  2415. if ((id = mobdb_searchname(message)) != 0) // for monster name
  2416. ;
  2417. else
  2418. id = atoi(message);
  2419. std::shared_ptr<s_pet_db> pet = pet_db.find(id);
  2420. if( pet == nullptr ){
  2421. pet = pet_db_search(id, PET_EGG);
  2422. }
  2423. if (pet != nullptr) {
  2424. sd->catch_target_class = pet->class_;
  2425. struct mob_db* mdb = mob_db(pet->class_);
  2426. 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);
  2427. } else {
  2428. clif_displaymessage(fd, msg_txt(sd,180)); // The monster/egg name/id doesn't exist.
  2429. return -1;
  2430. }
  2431. return 0;
  2432. }
  2433. /*==========================================
  2434. *
  2435. *------------------------------------------*/
  2436. ACMD_FUNC(hatch) {
  2437. nullpo_retr(-1, sd);
  2438. if (sd->status.pet_id <= 0)
  2439. clif_sendegg(sd);
  2440. else {
  2441. clif_displaymessage(fd, msg_txt(sd,181)); // You already have a pet.
  2442. return -1;
  2443. }
  2444. return 0;
  2445. }
  2446. /*==========================================
  2447. *
  2448. *------------------------------------------*/
  2449. ACMD_FUNC(petfriendly) {
  2450. int friendly;
  2451. struct pet_data *pd;
  2452. nullpo_retr(-1, sd);
  2453. if (!message || !*message || (friendly = atoi(message)) < 0) {
  2454. clif_displaymessage(fd, msg_txt(sd,1016)); // Please enter a valid value (usage: @petfriendly <0-1000>).
  2455. return -1;
  2456. }
  2457. pd = sd->pd;
  2458. if (!pd) {
  2459. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2460. return -1;
  2461. }
  2462. if (friendly < 0 || friendly > 1000)
  2463. {
  2464. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  2465. return -1;
  2466. }
  2467. if (friendly == pd->pet.intimate) {
  2468. clif_displaymessage(fd, msg_txt(sd,183)); // Pet intimacy is already at maximum.
  2469. return -1;
  2470. }
  2471. pet_set_intimate(pd, friendly);
  2472. clif_send_petstatus(sd);
  2473. clif_displaymessage(fd, msg_txt(sd,182)); // Pet intimacy changed.
  2474. return 0;
  2475. }
  2476. /*==========================================
  2477. *
  2478. *------------------------------------------*/
  2479. ACMD_FUNC(pethungry)
  2480. {
  2481. int hungry;
  2482. struct pet_data *pd;
  2483. nullpo_retr(-1, sd);
  2484. if (!message || !*message || (hungry = atoi(message)) < 0) {
  2485. clif_displaymessage(fd, msg_txt(sd,1017)); // Please enter a valid number (usage: @pethungry <0-100>).
  2486. return -1;
  2487. }
  2488. pd = sd->pd;
  2489. if (!sd->status.pet_id || !pd) {
  2490. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2491. return -1;
  2492. }
  2493. if (hungry < 0 || hungry > 100) {
  2494. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  2495. return -1;
  2496. }
  2497. if (hungry == pd->pet.hungry) {
  2498. clif_displaymessage(fd, msg_txt(sd,186)); // Pet hunger is already at maximum.
  2499. return -1;
  2500. }
  2501. pd->pet.hungry = hungry;
  2502. clif_send_petstatus(sd);
  2503. clif_displaymessage(fd, msg_txt(sd,185)); // Pet hunger changed.
  2504. return 0;
  2505. }
  2506. /*==========================================
  2507. *
  2508. *------------------------------------------*/
  2509. ACMD_FUNC(petrename)
  2510. {
  2511. struct pet_data *pd;
  2512. nullpo_retr(-1, sd);
  2513. if (!sd->status.pet_id || !sd->pd) {
  2514. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2515. return -1;
  2516. }
  2517. pd = sd->pd;
  2518. if (!pd->pet.rename_flag) {
  2519. clif_displaymessage(fd, msg_txt(sd,188)); // You can already rename your pet.
  2520. return -1;
  2521. }
  2522. pd->pet.rename_flag = 0;
  2523. intif_save_petdata(sd->status.account_id, &pd->pet);
  2524. clif_send_petstatus(sd);
  2525. clif_displaymessage(fd, msg_txt(sd,187)); // You can now rename your pet.
  2526. return 0;
  2527. }
  2528. /*==========================================
  2529. *
  2530. *------------------------------------------*/
  2531. ACMD_FUNC(recall) {
  2532. struct map_session_data *pl_sd = NULL;
  2533. nullpo_retr(-1, sd);
  2534. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2535. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2536. clif_displaymessage(fd, msg_txt(sd,1018)); // Please enter a player name (usage: @recall <char name/ID>).
  2537. return -1;
  2538. }
  2539. if((pl_sd=map_nick2sd(atcmd_player_name,true)) == NULL && (pl_sd=map_charid2sd(atoi(atcmd_player_name))) == NULL)
  2540. {
  2541. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  2542. return -1;
  2543. }
  2544. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  2545. {
  2546. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level doesn't authorize you to preform this action on the specified player.
  2547. return -1;
  2548. }
  2549. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2550. clif_displaymessage(fd, msg_txt(sd,1019)); // You are not authorized to warp someone to this map.
  2551. return -1;
  2552. }
  2553. if (pl_sd->bl.m >= 0 && map_getmapflag(pl_sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2554. clif_displaymessage(fd, msg_txt(sd,1020)); // You are not authorized to warp this player from their map.
  2555. return -1;
  2556. }
  2557. if (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y) {
  2558. return -1;
  2559. }
  2560. if( pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN) == SETPOS_AUTOTRADE ){
  2561. clif_displaymessage(fd, msg_txt(sd,1025)); // The player is currently autotrading and cannot be recalled.
  2562. return -1;
  2563. }
  2564. sprintf(atcmd_output, msg_txt(sd,46), pl_sd->status.name); // %s recalled!
  2565. clif_displaymessage(fd, atcmd_output);
  2566. return 0;
  2567. }
  2568. /*==========================================
  2569. * charblock command (usage: charblock <player_name>)
  2570. * This command do a definitiv ban on a player
  2571. *------------------------------------------*/
  2572. ACMD_FUNC(char_block)
  2573. {
  2574. nullpo_retr(-1, sd);
  2575. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2576. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2577. sprintf(atcmd_output, msg_txt(sd, 1021), command); // Please enter a player name (usage: %s <char name>).
  2578. clif_displaymessage(fd, atcmd_output);
  2579. return -1;
  2580. }
  2581. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, CHRIF_OP_LOGIN_BLOCK, 0, 0, 0);
  2582. sprintf(atcmd_output, msg_txt(sd,88), "login"); // Sending request to %s server...
  2583. clif_displaymessage(fd, atcmd_output);
  2584. return 0;
  2585. }
  2586. /*==========================================
  2587. * accountban command (usage: ban <%time> <player_name>)
  2588. * charban command (usage: charban <%time> <player_name>)
  2589. * %time see common/timer.cpp::solve_time()
  2590. *------------------------------------------*/
  2591. ACMD_FUNC(char_ban)
  2592. {
  2593. char *modif_p, output[CHAT_SIZE_MAX];
  2594. int32 timediff = 0; //don't set this as uint as we may want to decrease banned time
  2595. enum chrif_req_op bantype;
  2596. nullpo_retr(-1, sd);
  2597. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2598. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2599. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  2600. if (strcmpi(parent_cmd,"charban") == 0)
  2601. bantype = CHRIF_OP_BAN;
  2602. else if (strcmpi(parent_cmd,"ban") == 0)
  2603. bantype = CHRIF_OP_LOGIN_BAN;
  2604. else
  2605. return -1;
  2606. if (!message || !*message || sscanf(message, "%255s %23[^\n]", atcmd_output, atcmd_player_name) < 2) {
  2607. sprintf(output, msg_txt(sd,1022), command); // Please enter ban time and a player name (usage: %s <time> <char name>).
  2608. clif_displaymessage(fd, output);
  2609. return -1;
  2610. }
  2611. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  2612. modif_p = atcmd_output;
  2613. timediff = (int32)solve_time(modif_p); //discard seconds
  2614. if (timediff == 0) { //allow negative ?
  2615. safesnprintf(output, sizeof(output), msg_txt(sd,85), command, timediff); // Invalid time for %s command (time=%d)
  2616. clif_displaymessage(fd, output);
  2617. 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.
  2618. return -1;
  2619. }
  2620. if( timediff < 0 && (
  2621. (bantype == CHRIF_OP_LOGIN_BAN && !pc_can_use_command(sd, "unban", COMMAND_ATCOMMAND))
  2622. || (bantype == CHRIF_OP_BAN && !pc_can_use_command(sd, "charunban", COMMAND_ATCOMMAND))
  2623. ))
  2624. {
  2625. clif_displaymessage(fd,msg_txt(sd,1023)); // You are not allowed to alter the time of a ban.
  2626. return -1;
  2627. }
  2628. if (bantype == CHRIF_OP_BAN)
  2629. chrif_req_charban(sd->status.account_id, atcmd_player_name,timediff);
  2630. else
  2631. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, bantype, timediff, 0, 0);
  2632. safesnprintf(output, sizeof(output), msg_txt(sd,88), bantype == CHRIF_OP_BAN ? "char" : "login"); // Sending request to %s server...
  2633. clif_displaymessage(fd, output);
  2634. return 0;
  2635. }
  2636. /*==========================================
  2637. * charunblock command (usage: charunblock <player_name>)
  2638. *------------------------------------------*/
  2639. ACMD_FUNC(char_unblock)
  2640. {
  2641. nullpo_retr(-1, sd);
  2642. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2643. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2644. sprintf(atcmd_output, msg_txt(sd, 1021), command); // Please enter a player name (usage: %s <char name>).
  2645. clif_displaymessage(fd, atcmd_output);
  2646. return -1;
  2647. }
  2648. // send answer to login server via char-server
  2649. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, CHRIF_OP_LOGIN_UNBLOCK, 0, 0, 0);
  2650. sprintf(atcmd_output, msg_txt(sd,88), "login"); // Sending request to %s server...
  2651. clif_displaymessage(fd, atcmd_output);
  2652. return 0;
  2653. }
  2654. /*==========================================
  2655. * acc unban command (usage: unban <player_name>)
  2656. * char unban command (usage: charunban <player_name>)
  2657. *------------------------------------------*/
  2658. ACMD_FUNC(char_unban){
  2659. enum chrif_req_op unbantype;
  2660. nullpo_retr(-1, sd);
  2661. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2662. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2663. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  2664. if (strcmpi(parent_cmd,"charunban") == 0)
  2665. unbantype = CHRIF_OP_UNBAN;
  2666. else if (strcmpi(parent_cmd,"unban") == 0)
  2667. unbantype = CHRIF_OP_LOGIN_UNBAN;
  2668. else
  2669. return -1;
  2670. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2671. sprintf(atcmd_output, msg_txt(sd,435), command); // Please enter a player name (usage: %s <char name>).
  2672. clif_displaymessage(fd, atcmd_output);
  2673. return -1;
  2674. }
  2675. if (unbantype == CHRIF_OP_UNBAN)
  2676. chrif_req_charunban(sd->status.account_id,atcmd_player_name);
  2677. else
  2678. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, unbantype, 0, 0, 0);
  2679. sprintf(atcmd_output, msg_txt(sd,88), unbantype == CHRIF_OP_UNBAN ? "char":"login"); // Sending request to %s server...
  2680. clif_displaymessage(fd, atcmd_output);
  2681. return 0;
  2682. }
  2683. /*==========================================
  2684. *
  2685. *------------------------------------------*/
  2686. ACMD_FUNC(night)
  2687. {
  2688. nullpo_retr(-1, sd);
  2689. if (night_flag != 1) {
  2690. map_night_timer(night_timer_tid, 0, 0, 1);
  2691. } else {
  2692. clif_displaymessage(fd, msg_txt(sd,89)); // Night mode is already enabled.
  2693. return -1;
  2694. }
  2695. return 0;
  2696. }
  2697. /*==========================================
  2698. *
  2699. *------------------------------------------*/
  2700. ACMD_FUNC(day)
  2701. {
  2702. nullpo_retr(-1, sd);
  2703. if (night_flag != 0) {
  2704. map_day_timer(day_timer_tid, 0, 0, 1);
  2705. } else {
  2706. clif_displaymessage(fd, msg_txt(sd,90)); // Day mode is already enabled.
  2707. return -1;
  2708. }
  2709. return 0;
  2710. }
  2711. /*==========================================
  2712. *
  2713. *------------------------------------------*/
  2714. ACMD_FUNC(doom)
  2715. {
  2716. struct map_session_data* pl_sd;
  2717. struct s_mapiterator* iter;
  2718. nullpo_retr(-1, sd);
  2719. iter = mapit_getallusers();
  2720. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2721. {
  2722. if (pl_sd->fd != fd && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  2723. {
  2724. status_kill(&pl_sd->bl);
  2725. clif_specialeffect(&pl_sd->bl,EF_GRANDCROSS2,AREA);
  2726. clif_displaymessage(pl_sd->fd, msg_txt(sd,61)); // The holy messenger has given judgement.
  2727. }
  2728. }
  2729. mapit_free(iter);
  2730. clif_displaymessage(fd, msg_txt(sd,62)); // Judgement was made.
  2731. return 0;
  2732. }
  2733. /*==========================================
  2734. *
  2735. *------------------------------------------*/
  2736. ACMD_FUNC(doommap)
  2737. {
  2738. struct map_session_data* pl_sd;
  2739. struct s_mapiterator* iter;
  2740. nullpo_retr(-1, sd);
  2741. iter = mapit_getallusers();
  2742. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2743. {
  2744. if (pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  2745. {
  2746. status_kill(&pl_sd->bl);
  2747. clif_specialeffect(&pl_sd->bl,EF_GRANDCROSS2,AREA);
  2748. clif_displaymessage(pl_sd->fd, msg_txt(sd,61)); // The holy messenger has given judgement.
  2749. }
  2750. }
  2751. mapit_free(iter);
  2752. clif_displaymessage(fd, msg_txt(sd,62)); // Judgement was made.
  2753. return 0;
  2754. }
  2755. /*==========================================
  2756. *
  2757. *------------------------------------------*/
  2758. static void atcommand_raise_sub(struct map_session_data* sd) {
  2759. status_revive(&sd->bl, 100, 100);
  2760. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  2761. clif_displaymessage(sd->fd, msg_txt(sd,63)); // Mercy has been shown.
  2762. }
  2763. /*==========================================
  2764. *
  2765. *------------------------------------------*/
  2766. ACMD_FUNC(raise)
  2767. {
  2768. struct map_session_data* pl_sd;
  2769. struct s_mapiterator* iter;
  2770. nullpo_retr(-1, sd);
  2771. iter = mapit_getallusers();
  2772. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2773. if( pc_isdead(pl_sd) )
  2774. atcommand_raise_sub(pl_sd);
  2775. mapit_free(iter);
  2776. clif_displaymessage(fd, msg_txt(sd,64)); // Mercy has been granted.
  2777. return 0;
  2778. }
  2779. /*==========================================
  2780. *
  2781. *------------------------------------------*/
  2782. ACMD_FUNC(raisemap)
  2783. {
  2784. struct map_session_data* pl_sd;
  2785. struct s_mapiterator* iter;
  2786. nullpo_retr(-1, sd);
  2787. iter = mapit_getallusers();
  2788. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2789. if (sd->bl.m == pl_sd->bl.m && pc_isdead(pl_sd) )
  2790. atcommand_raise_sub(pl_sd);
  2791. mapit_free(iter);
  2792. clif_displaymessage(fd, msg_txt(sd,64)); // Mercy has been granted.
  2793. return 0;
  2794. }
  2795. /*==========================================
  2796. *
  2797. *------------------------------------------*/
  2798. ACMD_FUNC(kick)
  2799. {
  2800. struct map_session_data *pl_sd;
  2801. nullpo_retr(-1, sd);
  2802. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2803. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2804. clif_displaymessage(fd, msg_txt(sd,1026)); // Please enter a player name (usage: @kick <char name/ID>).
  2805. return -1;
  2806. }
  2807. if((pl_sd=map_nick2sd(atcmd_player_name,false)) == NULL && (pl_sd=map_charid2sd(atoi(atcmd_player_name))) == NULL)
  2808. {
  2809. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  2810. return -1;
  2811. }
  2812. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  2813. {
  2814. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  2815. return -1;
  2816. }
  2817. clif_GM_kick(sd, pl_sd);
  2818. return 0;
  2819. }
  2820. /*==========================================
  2821. *
  2822. *------------------------------------------*/
  2823. ACMD_FUNC(kickall)
  2824. {
  2825. struct map_session_data* pl_sd;
  2826. struct s_mapiterator* iter;
  2827. nullpo_retr(-1, sd);
  2828. iter = mapit_getallusers();
  2829. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2830. {
  2831. if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kick only lower or same gm level
  2832. if (sd->status.account_id != pl_sd->status.account_id)
  2833. clif_GM_kick(NULL, pl_sd);
  2834. }
  2835. }
  2836. mapit_free(iter);
  2837. clif_displaymessage(fd, msg_txt(sd,195)); // All players have been kicked!
  2838. return 0;
  2839. }
  2840. /*==========================================
  2841. *
  2842. *------------------------------------------*/
  2843. ACMD_FUNC(allskill)
  2844. {
  2845. nullpo_retr(-1, sd);
  2846. pc_allskillup(sd); // all skills
  2847. sd->status.skill_point = 0; // 0 skill points
  2848. clif_updatestatus(sd, SP_SKILLPOINT); // update
  2849. clif_displaymessage(fd, msg_txt(sd,76)); // All skills have been added to your skill tree.
  2850. return 0;
  2851. }
  2852. /*==========================================
  2853. *
  2854. *------------------------------------------*/
  2855. ACMD_FUNC(questskill)
  2856. {
  2857. uint16 skill_id;
  2858. nullpo_retr(-1, sd);
  2859. if (!message || !*message || (skill_id = atoi(message)) <= 0)
  2860. {// also send a list of skills applicable to this command
  2861. const char* text;
  2862. // attempt to find the text corresponding to this command
  2863. text = atcommand_help_string( command );
  2864. // send the error message as always
  2865. clif_displaymessage(fd, msg_txt(sd,1027)); // Please enter a quest skill number.
  2866. if( text )
  2867. {// send the skill ID list associated with this command
  2868. clif_displaymessage( fd, text );
  2869. }
  2870. return -1;
  2871. }
  2872. if (skill_id >= MAX_SKILL_ID) {
  2873. clif_displaymessage(fd, msg_txt(sd,198)); // This skill number doesn't exist.
  2874. return -1;
  2875. }
  2876. if (!skill_get_inf2(skill_id, INF2_ISQUEST)) {
  2877. clif_displaymessage(fd, msg_txt(sd,197)); // This skill number doesn't exist or isn't a quest skill.
  2878. return -1;
  2879. }
  2880. if (pc_checkskill(sd, skill_id) > 0) {
  2881. clif_displaymessage(fd, msg_txt(sd,196)); // You already have this quest skill.
  2882. return -1;
  2883. }
  2884. pc_skill(sd, skill_id, 1, ADDSKILL_PERMANENT);
  2885. clif_displaymessage(fd, msg_txt(sd,70)); // You have learned the skill.
  2886. return 0;
  2887. }
  2888. /*==========================================
  2889. *
  2890. *------------------------------------------*/
  2891. ACMD_FUNC(lostskill)
  2892. {
  2893. uint16 skill_id = 0, sk_idx = 0;
  2894. nullpo_retr(-1, sd);
  2895. if (!message || !*message || (skill_id = atoi(message)) <= 0)
  2896. {// also send a list of skills applicable to this command
  2897. const char* text;
  2898. // attempt to find the text corresponding to this command
  2899. text = atcommand_help_string( command );
  2900. // send the error message as always
  2901. clif_displaymessage(fd, msg_txt(sd,1027)); // Please enter a quest skill number.
  2902. if( text )
  2903. {// send the skill ID list associated with this command
  2904. clif_displaymessage( fd, text );
  2905. }
  2906. return -1;
  2907. }
  2908. if (!(sk_idx = skill_get_index(skill_id))) {
  2909. clif_displaymessage(fd, msg_txt(sd,198)); // This skill number doesn't exist.
  2910. return -1;
  2911. }
  2912. if (!skill_get_inf2(skill_id, INF2_ISQUEST)) {
  2913. clif_displaymessage(fd, msg_txt(sd,197)); // This skill number doesn't exist or isn't a quest skill.
  2914. return -1;
  2915. }
  2916. if (pc_checkskill(sd, skill_id) == 0) {
  2917. clif_displaymessage(fd, msg_txt(sd,201)); // You don't have this quest skill.
  2918. return -1;
  2919. }
  2920. sd->status.skill[sk_idx].lv = 0;
  2921. sd->status.skill[sk_idx].flag = SKILL_FLAG_PERMANENT;
  2922. clif_deleteskill(sd,skill_id);
  2923. clif_displaymessage(fd, msg_txt(sd,71)); // You have forgotten the skill.
  2924. return 0;
  2925. }
  2926. /*==========================================
  2927. *
  2928. *------------------------------------------*/
  2929. ACMD_FUNC(spiritball)
  2930. {
  2931. uint32 max_spiritballs;
  2932. int number;
  2933. nullpo_retr(-1, sd);
  2934. max_spiritballs = zmin(ARRAYLENGTH(sd->spirit_timer), 0x7FFF);
  2935. if( !message || !*message || (number = atoi(message)) < 0 || number > max_spiritballs )
  2936. {
  2937. char msg[CHAT_SIZE_MAX];
  2938. safesnprintf(msg, sizeof(msg), msg_txt(sd,1028), max_spiritballs); // Please enter a party name (usage: @party <party_name>).
  2939. clif_displaymessage(fd, msg);
  2940. return -1;
  2941. }
  2942. if( sd->spiritball > 0 )
  2943. pc_delspiritball(sd, sd->spiritball, 1);
  2944. sd->spiritball = number;
  2945. clif_spiritball(&sd->bl);
  2946. // no message, player can look the difference
  2947. return 0;
  2948. }
  2949. ACMD_FUNC(soulball)
  2950. {
  2951. int number;
  2952. nullpo_retr(-1, sd);
  2953. if (!message || !*message || (number = atoi(message)) < 0 || number > MAX_SOUL_BALL) {
  2954. char msg[CHAT_SIZE_MAX];
  2955. safesnprintf(msg, sizeof(msg), "Usage: @soulball <number: 0-%d>", MAX_SOUL_BALL);
  2956. clif_displaymessage(fd, msg);
  2957. return -1;
  2958. }
  2959. if (sd->soulball > 0)
  2960. pc_delsoulball(sd, sd->soulball, true);
  2961. sd->soulball = number;
  2962. clif_soulball(sd);
  2963. return 0;
  2964. }
  2965. /*==========================================
  2966. *
  2967. *------------------------------------------*/
  2968. ACMD_FUNC(party)
  2969. {
  2970. char party[NAME_LENGTH];
  2971. nullpo_retr(-1, sd);
  2972. memset(party, '\0', sizeof(party));
  2973. if (!message || !*message || sscanf(message, "%23[^\n]", party) < 1) {
  2974. clif_displaymessage(fd, msg_txt(sd,1029)); // Please enter a party name (usage: @party <party_name>).
  2975. return -1;
  2976. }
  2977. party_create(sd, party, 0, 0);
  2978. return 0;
  2979. }
  2980. /*==========================================
  2981. *
  2982. *------------------------------------------*/
  2983. ACMD_FUNC(guild)
  2984. {
  2985. char guild[NAME_LENGTH];
  2986. int prev;
  2987. nullpo_retr(-1, sd);
  2988. memset(guild, '\0', sizeof(guild));
  2989. if (sd->clan) {
  2990. clif_displaymessage(fd, msg_txt(sd, 1498)); // You cannot create a guild because you are in a clan.
  2991. return -1;
  2992. }
  2993. if (!message || !*message || sscanf(message, "%23[^\n]", guild) < 1) {
  2994. clif_displaymessage(fd, msg_txt(sd,1030)); // Please enter a guild name (usage: @guild <guild_name>).
  2995. return -1;
  2996. }
  2997. prev = battle_config.guild_emperium_check;
  2998. battle_config.guild_emperium_check = 0;
  2999. guild_create(sd, guild);
  3000. battle_config.guild_emperium_check = prev;
  3001. return 0;
  3002. }
  3003. ACMD_FUNC(breakguild)
  3004. {
  3005. nullpo_retr(-1, sd);
  3006. if (sd->status.guild_id) { // Check if the player has a guild
  3007. struct guild *g;
  3008. g = sd->guild; // Search the guild
  3009. if (g) { // Check if guild was found
  3010. if (sd->state.gmaster_flag) { // Check if player is guild master
  3011. int ret = 0;
  3012. ret = guild_break(sd, g->name); // Break guild
  3013. if (ret) { // Check if anything went wrong
  3014. return 0; // Guild was broken
  3015. } else {
  3016. return -1; // Something went wrong
  3017. }
  3018. } else { // Not guild master
  3019. clif_displaymessage(fd, msg_txt(sd,1181)); // You need to be a Guild Master to use this command.
  3020. return -1;
  3021. }
  3022. } else { // Guild was not found. HOW?
  3023. clif_displaymessage(fd, msg_txt(sd,252)); // You are not in a guild.
  3024. return -1;
  3025. }
  3026. } else { // Player does not have a guild
  3027. clif_displaymessage(fd, msg_txt(sd,252)); // You are not in a guild.
  3028. return -1;
  3029. }
  3030. }
  3031. /**
  3032. * Start WoE:FE
  3033. */
  3034. ACMD_FUNC(agitstart)
  3035. {
  3036. nullpo_retr(-1, sd);
  3037. if( guild_agit_start() ){
  3038. clif_displaymessage(fd, msg_txt(sd,72)); // War of Emperium has been initiated.
  3039. return 0;
  3040. }else{
  3041. clif_displaymessage(fd, msg_txt(sd,73)); // War of Emperium is currently in progress.
  3042. return -1;
  3043. }
  3044. }
  3045. /**
  3046. * Start WoE:SE
  3047. */
  3048. ACMD_FUNC(agitstart2)
  3049. {
  3050. nullpo_retr(-1, sd);
  3051. if( guild_agit2_start() ){
  3052. clif_displaymessage(fd, msg_txt(sd,403)); // "War of Emperium SE has been initiated."
  3053. return 0;
  3054. }else{
  3055. clif_displaymessage(fd, msg_txt(sd,404)); // "War of Emperium SE is currently in progress."
  3056. return -1;
  3057. }
  3058. }
  3059. /**
  3060. * Start WoE:TE
  3061. */
  3062. ACMD_FUNC(agitstart3)
  3063. {
  3064. nullpo_retr(-1, sd);
  3065. if( guild_agit3_start() ){
  3066. clif_displaymessage(fd, msg_txt(sd,749)); // "War of Emperium TE has been initiated."
  3067. return 0;
  3068. }else{
  3069. clif_displaymessage(fd, msg_txt(sd,750)); // "War of Emperium TE is currently in progress."
  3070. return -1;
  3071. }
  3072. }
  3073. /**
  3074. * End WoE:FE
  3075. */
  3076. ACMD_FUNC(agitend)
  3077. {
  3078. nullpo_retr(-1, sd);
  3079. if( guild_agit_end() ){
  3080. clif_displaymessage(fd, msg_txt(sd,74)); // War of Emperium has been ended.
  3081. return 0;
  3082. }else{
  3083. clif_displaymessage(fd, msg_txt(sd,75)); // War of Emperium is currently not in progress.
  3084. return -1;
  3085. }
  3086. }
  3087. /**
  3088. * End WoE:SE
  3089. */
  3090. ACMD_FUNC(agitend2)
  3091. {
  3092. nullpo_retr(-1, sd);
  3093. if( guild_agit2_end() ){
  3094. clif_displaymessage(fd, msg_txt(sd,405)); // "War of Emperium SE has been ended."
  3095. return 0;
  3096. }else{
  3097. clif_displaymessage(fd, msg_txt(sd,406)); // "War of Emperium SE is currently not in progress."
  3098. return -1;
  3099. }
  3100. }
  3101. /**
  3102. * End WoE:TE
  3103. */
  3104. ACMD_FUNC(agitend3)
  3105. {
  3106. nullpo_retr(-1, sd);
  3107. if( guild_agit3_end() ){
  3108. clif_displaymessage(fd, msg_txt(sd,751));// War of Emperium TE has been ended.
  3109. return 0;
  3110. }else{
  3111. clif_displaymessage(fd, msg_txt(sd,752));// War of Emperium TE is currently not in progress.
  3112. return -1;
  3113. }
  3114. }
  3115. /*==========================================
  3116. * @mapexit - shuts down the map server
  3117. *------------------------------------------*/
  3118. ACMD_FUNC(mapexit)
  3119. {
  3120. nullpo_retr(-1, sd);
  3121. do_shutdown();
  3122. return 0;
  3123. }
  3124. /*==========================================
  3125. * idsearch <part_of_name>: revrited by [Yor]
  3126. *------------------------------------------*/
  3127. ACMD_FUNC(idsearch)
  3128. {
  3129. char item_name[100];
  3130. unsigned int i, match;
  3131. struct item_data *item_array[MAX_SEARCH];
  3132. nullpo_retr(-1, sd);
  3133. memset(item_name, '\0', sizeof(item_name));
  3134. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3135. if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
  3136. clif_displaymessage(fd, msg_txt(sd,1031)); // Please enter part of an item name (usage: @idsearch <part_of_item_name>).
  3137. return -1;
  3138. }
  3139. sprintf(atcmd_output, msg_txt(sd,77), item_name); // The reference result of '%s' (name: id):
  3140. clif_displaymessage(fd, atcmd_output);
  3141. match = itemdb_searchname_array(item_array, MAX_SEARCH, item_name);
  3142. if (match == MAX_SEARCH) {
  3143. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH); // Displaying first %d matches
  3144. clif_displaymessage(fd, atcmd_output);
  3145. }
  3146. for(i = 0; i < match; i++) {
  3147. sprintf(atcmd_output, msg_txt(sd,78), item_array[i]->jname, item_array[i]->nameid); // %s: %d
  3148. clif_displaymessage(fd, atcmd_output);
  3149. }
  3150. sprintf(atcmd_output, msg_txt(sd,79), match); // It is %d affair above.
  3151. clif_displaymessage(fd, atcmd_output);
  3152. return 0;
  3153. }
  3154. /*==========================================
  3155. * Recall All Characters Online To Your Location
  3156. *------------------------------------------*/
  3157. ACMD_FUNC(recallall)
  3158. {
  3159. struct map_session_data* pl_sd;
  3160. struct s_mapiterator* iter;
  3161. int count;
  3162. nullpo_retr(-1, sd);
  3163. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3164. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3165. clif_displaymessage(fd, msg_txt(sd,1032)); // You are not authorized to warp someone to your current map.
  3166. return -1;
  3167. }
  3168. count = 0;
  3169. iter = mapit_getallusers();
  3170. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3171. {
  3172. if (sd->status.account_id != pl_sd->status.account_id && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  3173. {
  3174. if (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y)
  3175. continue; // Don't waste time warping the character to the same place.
  3176. if (pl_sd->bl.m >= 0 && map_getmapflag(pl_sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3177. count++;
  3178. else {
  3179. if( pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN) == SETPOS_AUTOTRADE ){
  3180. count++;
  3181. }
  3182. }
  3183. }
  3184. }
  3185. mapit_free(iter);
  3186. clif_displaymessage(fd, msg_txt(sd,92)); // All characters recalled!
  3187. if (count) {
  3188. 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.
  3189. clif_displaymessage(fd, atcmd_output);
  3190. }
  3191. return 0;
  3192. }
  3193. /*==========================================
  3194. * Recall online characters of a guild to your location
  3195. *------------------------------------------*/
  3196. ACMD_FUNC(guildrecall)
  3197. {
  3198. struct map_session_data* pl_sd;
  3199. struct s_mapiterator* iter;
  3200. int count;
  3201. char guild_name[NAME_LENGTH];
  3202. struct guild *g;
  3203. nullpo_retr(-1, sd);
  3204. memset(guild_name, '\0', sizeof(guild_name));
  3205. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3206. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  3207. clif_displaymessage(fd, msg_txt(sd,1034)); // Please enter a guild name/ID (usage: @guildrecall <guild_name/ID>).
  3208. return -1;
  3209. }
  3210. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3211. clif_displaymessage(fd, msg_txt(sd,1032)); // You are not authorized to warp someone to your current map.
  3212. return -1;
  3213. }
  3214. if ((g = guild_searchname(guild_name)) == NULL && // name first to avoid error when name begin with a number
  3215. (g = guild_search(atoi(message))) == NULL)
  3216. {
  3217. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  3218. return -1;
  3219. }
  3220. count = 0;
  3221. iter = mapit_getallusers();
  3222. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3223. {
  3224. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.guild_id == g->guild_id)
  3225. {
  3226. 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))
  3227. continue; // Skip GMs greater than you... or chars already on the cell
  3228. if (pl_sd->bl.m >= 0 && map_getmapflag(pl_sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3229. count++;
  3230. else{
  3231. if( pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN) == SETPOS_AUTOTRADE ){
  3232. count++;
  3233. }
  3234. }
  3235. }
  3236. }
  3237. mapit_free(iter);
  3238. sprintf(atcmd_output, msg_txt(sd,93), g->name); // All online characters of the %s guild have been recalled to your position.
  3239. clif_displaymessage(fd, atcmd_output);
  3240. if (count) {
  3241. 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.
  3242. clif_displaymessage(fd, atcmd_output);
  3243. }
  3244. return 0;
  3245. }
  3246. /*==========================================
  3247. * Recall online characters of a party to your location
  3248. *------------------------------------------*/
  3249. ACMD_FUNC(partyrecall)
  3250. {
  3251. struct map_session_data* pl_sd;
  3252. struct s_mapiterator* iter;
  3253. char party_name[NAME_LENGTH];
  3254. struct party_data *p;
  3255. int count;
  3256. nullpo_retr(-1, sd);
  3257. memset(party_name, '\0', sizeof(party_name));
  3258. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3259. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3260. clif_displaymessage(fd, msg_txt(sd,1035)); // Please enter a party name/ID (usage: @partyrecall <party_name/ID>).
  3261. return -1;
  3262. }
  3263. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3264. clif_displaymessage(fd, msg_txt(sd,1032)); // You are not authorized to warp someone to your current map.
  3265. return -1;
  3266. }
  3267. if ((p = party_searchname(party_name)) == NULL && // name first to avoid error when name begin with a number
  3268. (p = party_search(atoi(message))) == NULL)
  3269. {
  3270. clif_displaymessage(fd, msg_txt(sd,96)); // Incorrect name or ID, or no one from the party is online.
  3271. return -1;
  3272. }
  3273. count = 0;
  3274. iter = mapit_getallusers();
  3275. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3276. {
  3277. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.party_id == p->party.party_id)
  3278. {
  3279. 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))
  3280. continue; // Skip GMs greater than you... or chars already on the cell
  3281. if (pl_sd->bl.m >= 0 && map_getmapflag(pl_sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3282. count++;
  3283. else{
  3284. if( pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN) == SETPOS_AUTOTRADE ){
  3285. count++;
  3286. }
  3287. }
  3288. }
  3289. }
  3290. mapit_free(iter);
  3291. sprintf(atcmd_output, msg_txt(sd,95), p->party.name); // All online characters of the %s party have been recalled to your position.
  3292. clif_displaymessage(fd, atcmd_output);
  3293. if (count) {
  3294. 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.
  3295. clif_displaymessage(fd, atcmd_output);
  3296. }
  3297. return 0;
  3298. }
  3299. /*==========================================
  3300. *
  3301. *------------------------------------------*/
  3302. void atcommand_doload();
  3303. ACMD_FUNC(reload) {
  3304. nullpo_retr(-1, sd);
  3305. if ((strlen(command) < 8 ) && (!message || !*message)) {
  3306. const char* text;
  3307. text = atcommand_help_string( command );
  3308. if(text)
  3309. clif_displaymessage( fd, text );
  3310. return -1;
  3311. }
  3312. if (strstr(command, "itemdb") || strncmp(message, "itemdb", 4) == 0) {
  3313. itemdb_reload();
  3314. clif_displaymessage(fd, msg_txt(sd,97)); // Item database has been reloaded.
  3315. } else if (strstr(command, "mobdb") || strncmp(message, "mobdb", 3) == 0) {
  3316. mob_reload();
  3317. pet_db.reload();
  3318. hom_reload();
  3319. mercenary_readdb();
  3320. mercenary_read_skilldb();
  3321. reload_elementaldb();
  3322. clif_displaymessage(fd, msg_txt(sd,98)); // Monster database has been reloaded.
  3323. } else if (strstr(command, "skilldb") || strncmp(message, "skilldb", 4) == 0) {
  3324. skill_reload();
  3325. hom_reload_skill();
  3326. reload_elemental_skilldb();
  3327. mercenary_read_skilldb();
  3328. clif_displaymessage(fd, msg_txt(sd,99)); // Skill database has been reloaded.
  3329. } else if (strstr(command, "atcommand") || strncmp(message, "atcommand", 4) == 0) {
  3330. config_t run_test;
  3331. if (conf_read_file(&run_test, "conf/groups.conf")) {
  3332. clif_displaymessage(fd, msg_txt(sd,1036)); // Error reading groups.conf, reload failed.
  3333. return -1;
  3334. }
  3335. config_destroy(&run_test);
  3336. atcommand_doload();
  3337. pc_groups_reload();
  3338. clif_displaymessage(fd, msg_txt(sd,254)); // GM command configuration has been reloaded.
  3339. } else if (strstr(command, "battleconf") || strncmp(message, "battleconf", 3) == 0) {
  3340. struct Battle_Config prev_config;
  3341. memcpy(&prev_config, &battle_config, sizeof(prev_config));
  3342. battle_config_read(BATTLE_CONF_FILENAME);
  3343. if( prev_config.item_rate_mvp != battle_config.item_rate_mvp
  3344. || prev_config.item_rate_common != battle_config.item_rate_common
  3345. || prev_config.item_rate_common_boss != battle_config.item_rate_common_boss
  3346. || prev_config.item_rate_common_mvp != battle_config.item_rate_common_mvp
  3347. || prev_config.item_rate_card != battle_config.item_rate_card
  3348. || prev_config.item_rate_card_boss != battle_config.item_rate_card_boss
  3349. || prev_config.item_rate_card_mvp != battle_config.item_rate_card_mvp
  3350. || prev_config.item_rate_equip != battle_config.item_rate_equip
  3351. || prev_config.item_rate_equip_boss != battle_config.item_rate_equip_boss
  3352. || prev_config.item_rate_equip_mvp != battle_config.item_rate_equip_mvp
  3353. || prev_config.item_rate_heal != battle_config.item_rate_heal
  3354. || prev_config.item_rate_heal_boss != battle_config.item_rate_heal_boss
  3355. || prev_config.item_rate_heal_mvp != battle_config.item_rate_heal_mvp
  3356. || prev_config.item_rate_use != battle_config.item_rate_use
  3357. || prev_config.item_rate_use_boss != battle_config.item_rate_use_boss
  3358. || prev_config.item_rate_use_mvp != battle_config.item_rate_use_mvp
  3359. || prev_config.item_rate_treasure != battle_config.item_rate_treasure
  3360. || prev_config.item_rate_adddrop != battle_config.item_rate_adddrop
  3361. || prev_config.logarithmic_drops != battle_config.logarithmic_drops
  3362. || prev_config.item_drop_common_min != battle_config.item_drop_common_min
  3363. || prev_config.item_drop_common_max != battle_config.item_drop_common_max
  3364. || prev_config.item_drop_card_min != battle_config.item_drop_card_min
  3365. || prev_config.item_drop_card_max != battle_config.item_drop_card_max
  3366. || prev_config.item_drop_equip_min != battle_config.item_drop_equip_min
  3367. || prev_config.item_drop_equip_max != battle_config.item_drop_equip_max
  3368. || prev_config.item_drop_mvp_min != battle_config.item_drop_mvp_min
  3369. || prev_config.item_drop_mvp_max != battle_config.item_drop_mvp_max
  3370. || prev_config.item_drop_heal_min != battle_config.item_drop_heal_min
  3371. || prev_config.item_drop_heal_max != battle_config.item_drop_heal_max
  3372. || prev_config.item_drop_use_min != battle_config.item_drop_use_min
  3373. || prev_config.item_drop_use_max != battle_config.item_drop_use_max
  3374. || prev_config.item_drop_treasure_min != battle_config.item_drop_treasure_min
  3375. || prev_config.item_drop_treasure_max != battle_config.item_drop_treasure_max
  3376. || prev_config.base_exp_rate != battle_config.base_exp_rate
  3377. || prev_config.job_exp_rate != battle_config.job_exp_rate
  3378. )
  3379. { // Exp or Drop rates changed.
  3380. mob_reload(); //Needed as well so rate changes take effect.
  3381. }
  3382. clif_displaymessage(fd, msg_txt(sd,255)); // Battle configuration has been reloaded.
  3383. } else if (strstr(command, "statusdb") || strncmp(message, "statusdb", 3) == 0) {
  3384. status_readdb();
  3385. clif_displaymessage(fd, msg_txt(sd,256)); // Status database has been reloaded.
  3386. } else if (strstr(command, "pcdb") || strncmp(message, "pcdb", 2) == 0) {
  3387. pc_readdb();
  3388. clif_displaymessage(fd, msg_txt(sd,257)); // Player database has been reloaded.
  3389. } else if (strstr(command, "motd") || strncmp(message, "motd", 4) == 0) {
  3390. pc_read_motd();
  3391. clif_displaymessage(fd, msg_txt(sd,268)); // Reloaded the Message of the Day.
  3392. } else if (strstr(command, "script") || strncmp(message, "script", 3) == 0) {
  3393. struct s_mapiterator* iter;
  3394. struct map_session_data* pl_sd;
  3395. //atcommand_broadcast( fd, sd, "@broadcast", "Server is reloading scripts..." );
  3396. //atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
  3397. iter = mapit_getallusers();
  3398. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ){
  3399. pc_close_npc(pl_sd,1);
  3400. clif_cutin(pl_sd, "", 255);
  3401. pl_sd->state.block_action &= ~(PCBLOCK_ALL ^ PCBLOCK_IMMUNE);
  3402. }
  3403. mapit_free(iter);
  3404. flush_fifos();
  3405. map_reloadnpc(true); // reload config files seeking for npcs
  3406. script_reload();
  3407. npc_reload();
  3408. clif_displaymessage(fd, msg_txt(sd,100)); // Scripts have been reloaded.
  3409. } else if (strstr(command, "msgconf") || strncmp(message, "msgconf", 3) == 0) {
  3410. map_msg_reload();
  3411. clif_displaymessage(fd, msg_txt(sd,463)); // Message configuration has been reloaded.
  3412. } else if (strstr(command, "questdb") || strncmp(message, "questdb", 3) == 0) {
  3413. if (quest_db.reload())
  3414. clif_displaymessage(fd, msg_txt(sd,1377)); // Quest database has been reloaded.
  3415. } else if (strstr(command, "instancedb") || strncmp(message, "instancedb", 4) == 0) {
  3416. if (instance_db.reload())
  3417. clif_displaymessage(fd, msg_txt(sd,516)); // Instance database has been reloaded.
  3418. } else if (strstr(command, "achievementdb") || strncmp(message, "achievementdb", 4) == 0) {
  3419. achievement_db_reload();
  3420. clif_displaymessage(fd, msg_txt(sd,771)); // Achievement database has been reloaded.
  3421. } else if (strstr(command, "attendancedb") || strncmp(message, "attendancedb", 4) == 0) {
  3422. attendance_db.reload();
  3423. clif_displaymessage(fd, msg_txt(sd, 795)); // Attendance database has been reloaded.
  3424. }
  3425. return 0;
  3426. }
  3427. /*==========================================
  3428. * @partysharelvl <share_range> [Akinari]
  3429. * Updates char server party share level range in runtime
  3430. * Temporary - Permanent update in inter_athena.conf
  3431. *------------------------------------------*/
  3432. ACMD_FUNC(partysharelvl) {
  3433. unsigned int share_lvl;
  3434. nullpo_retr(-1, sd);
  3435. if(!message || !*message) {
  3436. clif_displaymessage(fd, msg_txt(sd,1322)); // Please enter an amount.
  3437. return -1;
  3438. } else {
  3439. share_lvl = min(abs(atoi(message)),MAX_LEVEL);
  3440. }
  3441. if(intif_party_sharelvlupdate(share_lvl)) //Successfully updated
  3442. clif_displaymessage(fd, msg_txt(sd,1478)); // Party share level range has been changed successfully.
  3443. else //Char server offline
  3444. clif_displaymessage(fd, msg_txt(sd,1479)); // Failed to update configuration. Character server is offline.
  3445. return 0;
  3446. }
  3447. /*==========================================
  3448. * @mapinfo [0-3] <map name> by MC_Cameri
  3449. * => Shows information about the map [map name]
  3450. * 0 = no additional information
  3451. * 1 = Show users in that map and their location
  3452. * 2 = Shows NPCs in that map
  3453. * 3 = Shows the chats in that map
  3454. *------------------------------------------*/
  3455. ACMD_FUNC(mapinfo) {
  3456. struct map_session_data* pl_sd;
  3457. struct s_mapiterator* iter;
  3458. struct chat_data *cd = NULL;
  3459. char direction[12];
  3460. int i, m_id, chat_num = 0, list = 0, vend_num = 0;
  3461. unsigned short m_index;
  3462. char mapname[MAP_NAME_LENGTH];
  3463. nullpo_retr(-1, sd);
  3464. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3465. memset(mapname, '\0', sizeof(mapname));
  3466. memset(direction, '\0', sizeof(direction));
  3467. sscanf(message, "%11d %11[^\n]", &list, mapname);
  3468. if (list < 0 || list > 3) {
  3469. clif_displaymessage(fd, msg_txt(sd,1038)); // Please enter at least one valid list number (usage: @mapinfo <0-3> <map>).
  3470. return -1;
  3471. }
  3472. if (mapname[0] == '\0') {
  3473. safestrncpy(mapname, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
  3474. m_id = map_mapindex2mapid(sd->mapindex);
  3475. } else {
  3476. m_id = map_mapname2mapid(mapname);
  3477. }
  3478. if (m_id < 0) {
  3479. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  3480. return -1;
  3481. }
  3482. m_index = mapindex_name2id(mapname); //This one shouldn't fail since the previous seek did not.
  3483. clif_displaymessage(fd, msg_txt(sd,1039)); // ------ Map Info ------
  3484. // count chats (for initial message)
  3485. chat_num = 0;
  3486. iter = mapit_getallusers();
  3487. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) {
  3488. if( pl_sd->mapindex == m_index ) {
  3489. if( pl_sd->state.vending )
  3490. vend_num++;
  3491. else if( (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL && cd->usersd[0] == pl_sd )
  3492. chat_num++;
  3493. }
  3494. }
  3495. mapit_free(iter);
  3496. struct map_data *mapdata = map_getmapdata(m_id);
  3497. 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
  3498. clif_displaymessage(fd, atcmd_output);
  3499. clif_displaymessage(fd, msg_txt(sd,1041)); // ------ Map Flags ------
  3500. if (map_getmapflag(m_id, MF_TOWN))
  3501. clif_displaymessage(fd, msg_txt(sd,1042)); // Town Map
  3502. if (map_getmapflag(m_id, MF_RESTRICTED)){
  3503. sprintf(atcmd_output, " Restricted (zone %d)",mapdata->zone);
  3504. clif_displaymessage(fd, atcmd_output);
  3505. }
  3506. if (battle_config.autotrade_mapflag == map_getmapflag(m_id, MF_AUTOTRADE))
  3507. clif_displaymessage(fd, msg_txt(sd,1043)); // Autotrade Enabled
  3508. else
  3509. clif_displaymessage(fd, msg_txt(sd,1044)); // Autotrade Disabled
  3510. if (map_getmapflag(m_id, MF_BATTLEGROUND)){
  3511. sprintf(atcmd_output, msg_txt(sd,1045),map_getmapflag(m_id, MF_BATTLEGROUND)); // Battlegrounds ON (type %d)
  3512. clif_displaymessage(fd, atcmd_output);
  3513. }
  3514. /* Skill damage adjustment info [Cydh] */
  3515. if (mapdata->flag[MF_SKILL_DAMAGE]) {
  3516. clif_displaymessage(fd,msg_txt(sd,1052)); // Skill Damage Adjustments:
  3517. sprintf(atcmd_output, msg_txt(sd, 1053), // > [Map] %d%%, %d%%, %d%%, %d%% | Caster:%d
  3518. mapdata->damage_adjust.rate[SKILLDMG_PC],
  3519. mapdata->damage_adjust.rate[SKILLDMG_MOB],
  3520. mapdata->damage_adjust.rate[SKILLDMG_BOSS],
  3521. mapdata->damage_adjust.rate[SKILLDMG_OTHER],
  3522. mapdata->damage_adjust.caster);
  3523. clif_displaymessage(fd, atcmd_output);
  3524. if (!mapdata->skill_damage.empty()) {
  3525. clif_displaymessage(fd, msg_txt(sd, 1054)); // > [Map Skill] Name : Player, Monster, Boss Monster, Other | Caster
  3526. for (auto skilldmg : mapdata->skill_damage) {
  3527. sprintf(atcmd_output," %s : %d%%, %d%%, %d%%, %d%% | %d",
  3528. skill_get_name(skilldmg.first),
  3529. skilldmg.second.rate[SKILLDMG_PC],
  3530. skilldmg.second.rate[SKILLDMG_MOB],
  3531. skilldmg.second.rate[SKILLDMG_BOSS],
  3532. skilldmg.second.rate[SKILLDMG_OTHER],
  3533. skilldmg.second.caster);
  3534. clif_displaymessage(fd,atcmd_output);
  3535. }
  3536. }
  3537. }
  3538. if (map_getmapflag(m_id, MF_SKILL_DURATION)) {
  3539. clif_displaymessage(fd, msg_txt(sd, 1055)); // Skill Duration Adjustments:
  3540. for (const auto &it : mapdata->skill_duration) {
  3541. sprintf(atcmd_output, " > %s : %d%%", skill_get_name(it.first), it.second);
  3542. clif_displaymessage(fd, atcmd_output);
  3543. }
  3544. }
  3545. strcpy(atcmd_output,msg_txt(sd,1046)); // PvP Flags:
  3546. if (map_getmapflag(m_id, MF_PVP))
  3547. strcat(atcmd_output, " Pvp ON |");
  3548. if (map_getmapflag(m_id, MF_PVP_NOGUILD))
  3549. strcat(atcmd_output, " NoGuild |");
  3550. if (map_getmapflag(m_id, MF_PVP_NOPARTY))
  3551. strcat(atcmd_output, " NoParty |");
  3552. if (map_getmapflag(m_id, MF_PVP_NIGHTMAREDROP))
  3553. strcat(atcmd_output, " NightmareDrop |");
  3554. if (map_getmapflag(m_id, MF_PVP_NOCALCRANK))
  3555. strcat(atcmd_output, " NoCalcRank |");
  3556. clif_displaymessage(fd, atcmd_output);
  3557. strcpy(atcmd_output,msg_txt(sd,1047)); // GvG Flags:
  3558. if (map_getmapflag(m_id, MF_GVG))
  3559. strcat(atcmd_output, " GvG ON |");
  3560. if (map_getmapflag(m_id, MF_GVG_DUNGEON))
  3561. strcat(atcmd_output, " GvG Dungeon |");
  3562. if (map_getmapflag(m_id, MF_GVG_CASTLE))
  3563. strcat(atcmd_output, " GvG Castle |");
  3564. if (map_getmapflag(m_id, MF_GVG_TE))
  3565. strcat(atcmd_output, " GvG TE |");
  3566. if (map_getmapflag(m_id, MF_GVG_TE_CASTLE))
  3567. strcat(atcmd_output, " GvG TE Castle |");
  3568. if (map_getmapflag(m_id, MF_GVG_NOPARTY))
  3569. strcat(atcmd_output, " NoParty |");
  3570. clif_displaymessage(fd, atcmd_output);
  3571. strcpy(atcmd_output,msg_txt(sd,1048)); // Teleport Flags:
  3572. if (map_getmapflag(m_id, MF_NOTELEPORT))
  3573. strcat(atcmd_output, " NoTeleport |");
  3574. if (map_getmapflag(m_id, MF_MONSTER_NOTELEPORT))
  3575. strcat(atcmd_output, " Monster NoTeleport |");
  3576. if (map_getmapflag(m_id, MF_NOWARP))
  3577. strcat(atcmd_output, " NoWarp |");
  3578. if (map_getmapflag(m_id, MF_NOWARPTO))
  3579. strcat(atcmd_output, " NoWarpTo |");
  3580. if (map_getmapflag(m_id, MF_NORETURN))
  3581. strcat(atcmd_output, " NoReturn |");
  3582. if (map_getmapflag(m_id, MF_NOGO))
  3583. strcat(atcmd_output, " NoGo |"); //
  3584. if (map_getmapflag(m_id, MF_NOMEMO))
  3585. strcat(atcmd_output, " NoMemo |");
  3586. clif_displaymessage(fd, atcmd_output);
  3587. sprintf(atcmd_output, msg_txt(sd,1065), // No Exp Penalty: %s | No Zeny Penalty: %s
  3588. (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
  3589. clif_displaymessage(fd, atcmd_output);
  3590. if (map_getmapflag(m_id, MF_NOSAVE)) {
  3591. if (!mapdata->save.map)
  3592. clif_displaymessage(fd, msg_txt(sd,1068)); // No Save (Return to last Save Point)
  3593. else if (mapdata->save.x == -1 || mapdata->save.y == -1 ) {
  3594. sprintf(atcmd_output, msg_txt(sd,1069), mapindex_id2name(mapdata->save.map)); // No Save, Save Point: %s,Random
  3595. clif_displaymessage(fd, atcmd_output);
  3596. }
  3597. else {
  3598. sprintf(atcmd_output, msg_txt(sd,1070), // No Save, Save Point: %s,%d,%d
  3599. mapindex_id2name(mapdata->save.map),mapdata->save.x,mapdata->save.y);
  3600. clif_displaymessage(fd, atcmd_output);
  3601. }
  3602. }
  3603. strcpy(atcmd_output,msg_txt(sd,1049)); // Weather Flags:
  3604. if (map_getmapflag(m_id, MF_SNOW))
  3605. strcat(atcmd_output, " Snow |");
  3606. if (map_getmapflag(m_id, MF_FOG))
  3607. strcat(atcmd_output, " Fog |");
  3608. if (map_getmapflag(m_id, MF_SAKURA))
  3609. strcat(atcmd_output, " Sakura |");
  3610. if (map_getmapflag(m_id, MF_CLOUDS))
  3611. strcat(atcmd_output, " Clouds |");
  3612. if (map_getmapflag(m_id, MF_CLOUDS2))
  3613. strcat(atcmd_output, " Clouds2 |");
  3614. if (map_getmapflag(m_id, MF_FIREWORKS))
  3615. strcat(atcmd_output, " Fireworks |");
  3616. if (map_getmapflag(m_id, MF_LEAVES))
  3617. strcat(atcmd_output, " Leaves |");
  3618. if (map_getmapflag(m_id, MF_NIGHTENABLED))
  3619. strcat(atcmd_output, " Displays Night |");
  3620. clif_displaymessage(fd, atcmd_output);
  3621. strcpy(atcmd_output,msg_txt(sd,1050)); // Other Flags:
  3622. if (map_getmapflag(m_id, MF_NOBRANCH))
  3623. strcat(atcmd_output, " NoBranch |");
  3624. if (map_getmapflag(m_id, MF_NOTRADE))
  3625. strcat(atcmd_output, " NoTrade |");
  3626. if (map_getmapflag(m_id, MF_NOVENDING))
  3627. strcat(atcmd_output, " NoVending |");
  3628. if (map_getmapflag(m_id, MF_NODROP))
  3629. strcat(atcmd_output, " NoDrop |");
  3630. if (map_getmapflag(m_id, MF_NOSKILL))
  3631. strcat(atcmd_output, " NoSkill |");
  3632. if (map_getmapflag(m_id, MF_NOICEWALL))
  3633. strcat(atcmd_output, " NoIcewall |");
  3634. if (map_getmapflag(m_id, MF_ALLOWKS))
  3635. strcat(atcmd_output, " AllowKS |");
  3636. if (map_getmapflag(m_id, MF_RESET))
  3637. strcat(atcmd_output, " Reset |");
  3638. if (map_getmapflag(m_id, MF_HIDEMOBHPBAR))
  3639. strcat(atcmd_output, " HideMobHPBar |");
  3640. clif_displaymessage(fd, atcmd_output);
  3641. strcpy(atcmd_output,msg_txt(sd,1051)); // Other Flags2:
  3642. if (map_getmapflag(m_id, MF_NOCOMMAND))
  3643. strcat(atcmd_output, " NoCommand |");
  3644. if (map_getmapflag(m_id, MF_NOBASEEXP))
  3645. strcat(atcmd_output, " NoBaseEXP |");
  3646. if (map_getmapflag(m_id, MF_NOJOBEXP))
  3647. strcat(atcmd_output, " NoJobEXP |");
  3648. if (map_getmapflag(m_id, MF_NOMOBLOOT))
  3649. strcat(atcmd_output, " NoMobLoot |");
  3650. if (map_getmapflag(m_id, MF_NOMVPLOOT))
  3651. strcat(atcmd_output, " NoMVPLoot |");
  3652. if (map_getmapflag(m_id, MF_PARTYLOCK))
  3653. strcat(atcmd_output, " PartyLock |");
  3654. if (map_getmapflag(m_id, MF_GUILDLOCK))
  3655. strcat(atcmd_output, " GuildLock |");
  3656. if (map_getmapflag(m_id, MF_LOADEVENT))
  3657. strcat(atcmd_output, " Loadevent |");
  3658. if (map_getmapflag(m_id, MF_NOMAPCHANNELAUTOJOIN))
  3659. strcat(atcmd_output, " NoMapChannelAutoJoin |");
  3660. if (map_getmapflag(m_id, MF_NOUSECART))
  3661. strcat(atcmd_output, " NoUsecart |");
  3662. if (map_getmapflag(m_id, MF_NOITEMCONSUMPTION))
  3663. strcat(atcmd_output, " NoItemConsumption |");
  3664. if (map_getmapflag(m_id, MF_NOSUNMOONSTARMIRACLE))
  3665. strcat(atcmd_output, " NoSunMoonStarMiracle |");
  3666. if (map_getmapflag(m_id, MF_NOMINEEFFECT))
  3667. strcat(atcmd_output, " NoMineEffect |");
  3668. if (map_getmapflag(m_id, MF_NOLOCKON))
  3669. strcat(atcmd_output, " NoLockOn |");
  3670. if (map_getmapflag(m_id, MF_NOTOMB))
  3671. strcat(atcmd_output, " NoTomb |");
  3672. if (map_getmapflag(m_id, MF_NOCOSTUME))
  3673. strcat(atcmd_output, " NoCostume |");
  3674. clif_displaymessage(fd, atcmd_output);
  3675. switch (list) {
  3676. case 0:
  3677. // Do nothing. It's list 0, no additional display.
  3678. break;
  3679. case 1:
  3680. clif_displaymessage(fd, msg_txt(sd,480)); // ----- Players in Map -----
  3681. iter = mapit_getallusers();
  3682. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3683. {
  3684. if (pl_sd->mapindex == m_index) {
  3685. sprintf(atcmd_output, msg_txt(sd,481), // Player '%s' (session #%d) | Location: %d,%d
  3686. pl_sd->status.name, pl_sd->fd, pl_sd->bl.x, pl_sd->bl.y);
  3687. clif_displaymessage(fd, atcmd_output);
  3688. }
  3689. }
  3690. mapit_free(iter);
  3691. break;
  3692. case 2:
  3693. clif_displaymessage(fd, msg_txt(sd,482)); // ----- NPCs in Map -----
  3694. for (i = 0; i < mapdata->npc_num;)
  3695. {
  3696. struct npc_data *nd = mapdata->npc[i];
  3697. switch(nd->ud.dir) {
  3698. case DIR_NORTH: strcpy(direction, msg_txt(sd,491)); break; // North
  3699. case DIR_NORTHWEST: strcpy(direction, msg_txt(sd,492)); break; // North West
  3700. case DIR_WEST: strcpy(direction, msg_txt(sd,493)); break; // West
  3701. case DIR_SOUTHWEST: strcpy(direction, msg_txt(sd,494)); break; // South West
  3702. case DIR_SOUTH: strcpy(direction, msg_txt(sd,495)); break; // South
  3703. case DIR_SOUTHEAST: strcpy(direction, msg_txt(sd,496)); break; // South East
  3704. case DIR_EAST: strcpy(direction, msg_txt(sd,497)); break; // East
  3705. case DIR_NORTHEAST: strcpy(direction, msg_txt(sd,498)); break; // North East
  3706. default: strcpy(direction, msg_txt(sd,499)); break; // Unknown
  3707. }
  3708. if(strcmp(nd->name,nd->exname) == 0)
  3709. sprintf(atcmd_output, msg_txt(sd,490), // NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d
  3710. ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
  3711. else
  3712. sprintf(atcmd_output, msg_txt(sd,489), // NPC %d: %s::%s | Direction: %s | Sprite: %d | Location: %d %d
  3713. ++i, nd->name, nd->exname, direction, nd->class_, nd->bl.x, nd->bl.y);
  3714. clif_displaymessage(fd, atcmd_output);
  3715. }
  3716. break;
  3717. case 3:
  3718. clif_displaymessage(fd, msg_txt(sd,483)); // ----- Chats in Map -----
  3719. iter = mapit_getallusers();
  3720. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3721. {
  3722. if ((cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL &&
  3723. pl_sd->mapindex == m_index &&
  3724. cd->usersd[0] == pl_sd)
  3725. {
  3726. sprintf(atcmd_output, msg_txt(sd,484), // Chat: %s | Player: %s | Location: %d %d
  3727. cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
  3728. clif_displaymessage(fd, atcmd_output);
  3729. sprintf(atcmd_output, msg_txt(sd,485), // Users: %d/%d | Password: %s | Public: %s
  3730. cd->users, cd->limit, cd->pass, (cd->pub) ? msg_txt(sd,486) : msg_txt(sd,487)); // Yes / No
  3731. clif_displaymessage(fd, atcmd_output);
  3732. }
  3733. }
  3734. mapit_free(iter);
  3735. break;
  3736. default: // normally impossible to arrive here
  3737. clif_displaymessage(fd, msg_txt(sd,488)); // Please enter at least one valid list number (usage: @mapinfo <0-3> <map>).
  3738. return -1;
  3739. break;
  3740. }
  3741. return 0;
  3742. }
  3743. /*==========================================
  3744. *
  3745. *------------------------------------------*/
  3746. ACMD_FUNC(mount_peco)
  3747. {
  3748. nullpo_retr(-1, sd);
  3749. if (sd->disguise) {
  3750. clif_displaymessage(fd, msg_txt(sd,212)); // Cannot mount while in disguise.
  3751. return -1;
  3752. }
  3753. if( (sd->class_&MAPID_THIRDMASK) == MAPID_RUNE_KNIGHT && pc_checkskill(sd,RK_DRAGONTRAINING) > 0 ) {
  3754. if( !(sd->sc.option&OPTION_DRAGON) ) {
  3755. unsigned int option = OPTION_DRAGON1;
  3756. if( message[0] ) {
  3757. int color = atoi(message);
  3758. option = ( color == 2 ? OPTION_DRAGON2 :
  3759. color == 3 ? OPTION_DRAGON3 :
  3760. color == 4 ? OPTION_DRAGON4 :
  3761. color == 5 ? OPTION_DRAGON5 :
  3762. OPTION_DRAGON1 );
  3763. }
  3764. clif_displaymessage(sd->fd,msg_txt(sd,1119)); // You have mounted your Dragon.
  3765. pc_setoption(sd, sd->sc.option|option);
  3766. } else {
  3767. clif_displaymessage(sd->fd,msg_txt(sd,1120)); // You have released your Dragon.
  3768. pc_setoption(sd, sd->sc.option&~OPTION_DRAGON);
  3769. }
  3770. return 0;
  3771. }
  3772. if( (sd->class_&MAPID_THIRDMASK) == MAPID_RANGER && pc_checkskill(sd,RA_WUGRIDER) > 0 && (!pc_isfalcon(sd) || battle_config.warg_can_falcon) ) {
  3773. if( !pc_isridingwug(sd) ) {
  3774. clif_displaymessage(sd->fd,msg_txt(sd,1121)); // You have mounted your Warg.
  3775. pc_setoption(sd, sd->sc.option|OPTION_WUGRIDER);
  3776. } else {
  3777. clif_displaymessage(sd->fd,msg_txt(sd,1122)); // You have released your Warg.
  3778. pc_setoption(sd, sd->sc.option&~OPTION_WUGRIDER);
  3779. }
  3780. return 0;
  3781. }
  3782. if( (sd->class_&MAPID_THIRDMASK) == MAPID_MECHANIC ) {
  3783. if( !pc_ismadogear(sd) ) {
  3784. clif_displaymessage(sd->fd,msg_txt(sd,1123)); // You have mounted your Mado Gear.
  3785. pc_setoption(sd, sd->sc.option|OPTION_MADOGEAR);
  3786. } else {
  3787. clif_displaymessage(sd->fd,msg_txt(sd,1124)); // You have released your Mado Gear.
  3788. pc_setoption(sd, sd->sc.option&~OPTION_MADOGEAR);
  3789. }
  3790. return 0;
  3791. }
  3792. if (!pc_isriding(sd)) { // if actually no peco
  3793. if (!pc_checkskill(sd, KN_RIDING)) {
  3794. clif_displaymessage(fd, msg_txt(sd,213)); // You can not mount a Peco Peco with your current job.
  3795. return -1;
  3796. }
  3797. pc_setoption(sd, sd->sc.option | OPTION_RIDING);
  3798. clif_displaymessage(fd, msg_txt(sd,102)); // You have mounted a Peco Peco.
  3799. } else {//Dismount
  3800. pc_setoption(sd, sd->sc.option & ~OPTION_RIDING);
  3801. clif_displaymessage(fd, msg_txt(sd,214)); // You have released your Peco Peco.
  3802. }
  3803. return 0;
  3804. }
  3805. /*==========================================
  3806. *Spy Commands by Syrus22
  3807. *------------------------------------------*/
  3808. ACMD_FUNC(guildspy)
  3809. {
  3810. char guild_name[NAME_LENGTH];
  3811. struct guild *g;
  3812. nullpo_retr(-1, sd);
  3813. memset(guild_name, '\0', sizeof(guild_name));
  3814. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3815. if (!enable_spy)
  3816. {
  3817. clif_displaymessage(fd, msg_txt(sd,1125)); // The mapserver has spy command support disabled.
  3818. return -1;
  3819. }
  3820. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  3821. clif_displaymessage(fd, msg_txt(sd,1126)); // Please enter a guild name/ID (usage: @guildspy <guild_name/ID>).
  3822. return -1;
  3823. }
  3824. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  3825. (g = guild_search(atoi(message))) != NULL) {
  3826. if (sd->guildspy == g->guild_id) {
  3827. sd->guildspy = 0;
  3828. sprintf(atcmd_output, msg_txt(sd,103), g->name); // No longer spying on the %s guild.
  3829. clif_displaymessage(fd, atcmd_output);
  3830. } else {
  3831. sd->guildspy = g->guild_id;
  3832. sprintf(atcmd_output, msg_txt(sd,104), g->name); // Spying on the %s guild.
  3833. clif_displaymessage(fd, atcmd_output);
  3834. }
  3835. } else {
  3836. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the specified guild is online.
  3837. return -1;
  3838. }
  3839. return 0;
  3840. }
  3841. /*==========================================
  3842. *
  3843. *------------------------------------------*/
  3844. ACMD_FUNC(partyspy)
  3845. {
  3846. char party_name[NAME_LENGTH];
  3847. struct party_data *p;
  3848. nullpo_retr(-1, sd);
  3849. memset(party_name, '\0', sizeof(party_name));
  3850. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3851. if (!enable_spy)
  3852. {
  3853. clif_displaymessage(fd, msg_txt(sd,1125)); // The mapserver has spy command support disabled.
  3854. return -1;
  3855. }
  3856. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3857. clif_displaymessage(fd, msg_txt(sd,1127)); // Please enter a party name/ID (usage: @partyspy <party_name/ID>).
  3858. return -1;
  3859. }
  3860. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  3861. (p = party_search(atoi(message))) != NULL) {
  3862. if (sd->partyspy == p->party.party_id) {
  3863. sd->partyspy = 0;
  3864. sprintf(atcmd_output, msg_txt(sd,105), p->party.name); // No longer spying on the %s party.
  3865. clif_displaymessage(fd, atcmd_output);
  3866. } else {
  3867. sd->partyspy = p->party.party_id;
  3868. sprintf(atcmd_output, msg_txt(sd,106), p->party.name); // Spying on the %s party.
  3869. clif_displaymessage(fd, atcmd_output);
  3870. }
  3871. } else {
  3872. clif_displaymessage(fd, msg_txt(sd,96)); // Incorrect name/ID, or no one from the specified party is online.
  3873. return -1;
  3874. }
  3875. return 0;
  3876. }
  3877. ACMD_FUNC(clanspy){
  3878. char clan_name[NAME_LENGTH];
  3879. struct clan* c;
  3880. nullpo_retr(-1, sd);
  3881. memset(clan_name, '\0', sizeof(clan_name));
  3882. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3883. if( !enable_spy ){
  3884. clif_displaymessage(fd, msg_txt(sd, 1125)); // The mapserver has spy command support disabled.
  3885. return -1;
  3886. }
  3887. if( !message || !*message || sscanf( message, "%23[^\n]", clan_name ) < 1 ){
  3888. clif_displaymessage(fd, msg_txt(sd, 1499)); // Please enter a clan name/ID (usage: @clanspy <clan_name/ID>).
  3889. return -1;
  3890. }
  3891. if ((c = clan_searchname(clan_name)) != NULL || // name first to avoid error when name begin with a number
  3892. (c = clan_search(atoi(message))) != NULL) {
  3893. if (sd->clanspy == c->id) {
  3894. sd->clanspy = 0;
  3895. sprintf(atcmd_output, msg_txt(sd, 1500), c->name); // No longer spying on the %s clan.
  3896. clif_displaymessage(fd, atcmd_output);
  3897. }
  3898. else {
  3899. sd->clanspy = c->id;
  3900. sprintf(atcmd_output, msg_txt(sd, 1501), c->name); // Spying on the %s clan.
  3901. clif_displaymessage(fd, atcmd_output);
  3902. }
  3903. }
  3904. else {
  3905. clif_displaymessage(fd, msg_txt(sd, 1502)); // Incorrect clan name/ID.
  3906. return -1;
  3907. }
  3908. return 0;
  3909. }
  3910. /*==========================================
  3911. * @repairall [Valaris]
  3912. *------------------------------------------*/
  3913. ACMD_FUNC(repairall)
  3914. {
  3915. int count, i;
  3916. nullpo_retr(-1, sd);
  3917. count = 0;
  3918. for (i = 0; i < MAX_INVENTORY; i++) {
  3919. 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])) {
  3920. sd->inventory.u.items_inventory[i].attribute = 0;
  3921. clif_produceeffect(sd, 0, sd->inventory.u.items_inventory[i].nameid);
  3922. count++;
  3923. }
  3924. }
  3925. if (count > 0) {
  3926. clif_misceffect(&sd->bl, 3);
  3927. clif_equiplist(sd);
  3928. clif_displaymessage(fd, msg_txt(sd,107)); // All items have been repaired.
  3929. } else {
  3930. clif_displaymessage(fd, msg_txt(sd,108)); // No item need to be repaired.
  3931. return -1;
  3932. }
  3933. return 0;
  3934. }
  3935. /*==========================================
  3936. * @nuke [Valaris]
  3937. *------------------------------------------*/
  3938. ACMD_FUNC(nuke)
  3939. {
  3940. struct map_session_data *pl_sd;
  3941. nullpo_retr(-1, sd);
  3942. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3943. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3944. clif_displaymessage(fd, msg_txt(sd,1128)); // Please enter a player name (usage: @nuke <char name>).
  3945. return -1;
  3946. }
  3947. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) != NULL) {
  3948. if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kill only lower or same GM level
  3949. skill_castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
  3950. clif_displaymessage(fd, msg_txt(sd,109)); // Player has been nuked!
  3951. } else {
  3952. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  3953. return -1;
  3954. }
  3955. } else {
  3956. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  3957. return -1;
  3958. }
  3959. return 0;
  3960. }
  3961. /*==========================================
  3962. * @tonpc
  3963. *------------------------------------------*/
  3964. ACMD_FUNC(tonpc)
  3965. {
  3966. char npcname[NPC_NAME_LENGTH];
  3967. struct npc_data *nd;
  3968. nullpo_retr(-1, sd);
  3969. memset(npcname, 0, sizeof(npcname));
  3970. if (!message || !*message || sscanf(message, "%49[^\n]", npcname) < 1) {
  3971. clif_displaymessage(fd, msg_txt(sd,1129)); // Please enter a NPC name (usage: @tonpc <NPC_name>).
  3972. return -1;
  3973. }
  3974. if ((nd = npc_name2id(npcname)) != NULL) {
  3975. if (pc_setpos(sd, map_id2index(nd->bl.m), nd->bl.x, nd->bl.y, CLR_TELEPORT) == SETPOS_OK)
  3976. clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
  3977. else
  3978. return -1;
  3979. } else {
  3980. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  3981. return -1;
  3982. }
  3983. return 0;
  3984. }
  3985. /*==========================================
  3986. *
  3987. *------------------------------------------*/
  3988. ACMD_FUNC(shownpc)
  3989. {
  3990. char NPCname[NPC_NAME_LENGTH];
  3991. nullpo_retr(-1, sd);
  3992. memset(NPCname, '\0', sizeof(NPCname));
  3993. if (!message || !*message || sscanf(message, "%49[^\n]", NPCname) < 1) {
  3994. clif_displaymessage(fd, msg_txt(sd,1130)); // Please enter a NPC name (usage: @enablenpc <NPC_name>).
  3995. return -1;
  3996. }
  3997. if (npc_name2id(NPCname) != NULL) {
  3998. npc_enable(NPCname, 1);
  3999. clif_displaymessage(fd, msg_txt(sd,110)); // Npc Enabled.
  4000. } else {
  4001. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  4002. return -1;
  4003. }
  4004. return 0;
  4005. }
  4006. /*==========================================
  4007. *
  4008. *------------------------------------------*/
  4009. ACMD_FUNC(hidenpc)
  4010. {
  4011. char NPCname[NPC_NAME_LENGTH];
  4012. nullpo_retr(-1, sd);
  4013. memset(NPCname, '\0', sizeof(NPCname));
  4014. if (!message || !*message || sscanf(message, "%49[^\n]", NPCname) < 1) {
  4015. clif_displaymessage(fd, msg_txt(sd,1131)); // Please enter a NPC name (usage: @hidenpc <NPC_name>).
  4016. return -1;
  4017. }
  4018. if (npc_name2id(NPCname) == NULL) {
  4019. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  4020. return -1;
  4021. }
  4022. npc_enable(NPCname, 0);
  4023. clif_displaymessage(fd, msg_txt(sd,112)); // Npc Disabled.
  4024. return 0;
  4025. }
  4026. ACMD_FUNC(loadnpc)
  4027. {
  4028. if (!message || !*message) {
  4029. clif_displaymessage(fd, msg_txt(sd,1132)); // Please enter a script file name (usage: @loadnpc <file name>).
  4030. return -1;
  4031. }
  4032. if (!npc_addsrcfile(message, true)) {
  4033. clif_displaymessage(fd, msg_txt(sd,261)); // Script could not be loaded.
  4034. return -1;
  4035. }
  4036. npc_read_event_script();
  4037. clif_displaymessage(fd, msg_txt(sd,262)); // Script loaded.
  4038. return 0;
  4039. }
  4040. ACMD_FUNC(unloadnpc)
  4041. {
  4042. struct npc_data *nd;
  4043. char NPCname[NPC_NAME_LENGTH];
  4044. nullpo_retr(-1, sd);
  4045. memset(NPCname, '\0', sizeof(NPCname));
  4046. if (!message || !*message || sscanf(message, "%49[^\n]", NPCname) < 1) {
  4047. clif_displaymessage(fd, msg_txt(sd,1133)); // Please enter a NPC name (usage: @unloadnpc <NPC_name>).
  4048. return -1;
  4049. }
  4050. if ((nd = npc_name2id(NPCname)) == NULL) {
  4051. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  4052. return -1;
  4053. }
  4054. npc_unload_duplicates(nd);
  4055. npc_unload(nd,true);
  4056. npc_read_event_script();
  4057. clif_displaymessage(fd, msg_txt(sd,112)); // Npc Disabled.
  4058. return 0;
  4059. }
  4060. ACMD_FUNC(reloadnpcfile) {
  4061. if (!message || !*message) {
  4062. clif_displaymessage(fd, msg_txt(sd,733)); // Please enter a NPC file name (usage: @reloadnpcfile <file name>).
  4063. return -1;
  4064. }
  4065. if (npc_unloadfile(message))
  4066. clif_displaymessage(fd, msg_txt(sd,1386)); // File unloaded. Be aware that mapflags and monsters spawned directly are not removed.
  4067. if (!npc_addsrcfile(message, true)) {
  4068. clif_displaymessage(fd, msg_txt(sd,261)); // Script could not be loaded.
  4069. return -1;
  4070. }
  4071. npc_read_event_script();
  4072. clif_displaymessage(fd, msg_txt(sd,262)); // Script loaded.
  4073. return 0;
  4074. }
  4075. /*==========================================
  4076. * time in txt for time command (by [Yor])
  4077. *------------------------------------------*/
  4078. char* txt_time(t_tick duration_)
  4079. {
  4080. int days, hours, minutes, seconds;
  4081. char temp[CHAT_SIZE_MAX];
  4082. static char temp1[CHAT_SIZE_MAX];
  4083. memset(temp, '\0', sizeof(temp));
  4084. memset(temp1, '\0', sizeof(temp1));
  4085. // Cap it
  4086. int duration = (int)duration_;
  4087. days = duration / (60 * 60 * 24);
  4088. duration = duration - (60 * 60 * 24 * days);
  4089. hours = duration / (60 * 60);
  4090. duration = duration - (60 * 60 * hours);
  4091. minutes = duration / 60;
  4092. seconds = duration - (60 * minutes);
  4093. if (days == 1)
  4094. sprintf(temp, msg_txt(NULL,219), days); // %d day
  4095. else if (days > 1)
  4096. sprintf(temp, msg_txt(NULL,220), days); // %d days
  4097. if (hours == 1)
  4098. sprintf(temp1, msg_txt(NULL,221), temp, hours); // %s %d hour
  4099. else if (hours > 1)
  4100. sprintf(temp1, msg_txt(NULL,222), temp, hours); // %s %d hours
  4101. if (minutes < 2)
  4102. sprintf(temp, msg_txt(NULL,223), temp1, minutes); // %s %d minute
  4103. else
  4104. sprintf(temp, msg_txt(NULL,224), temp1, minutes); // %s %d minutes
  4105. if (seconds == 1)
  4106. sprintf(temp1, msg_txt(NULL,225), temp, seconds); // %s and %d second
  4107. else if (seconds > 1)
  4108. sprintf(temp1, msg_txt(NULL,226), temp, seconds); // %s and %d seconds
  4109. return temp1;
  4110. }
  4111. /*==========================================
  4112. * @time/@date/@serverdate/@servertime: Display the date/time of the server (by [Yor]
  4113. * Calculation management of GM modification (@day/@night GM commands) is done
  4114. *------------------------------------------*/
  4115. ACMD_FUNC(servertime)
  4116. {
  4117. const struct TimerData * timer_data;
  4118. time_t time_server; // variable for number of seconds (used with time() function)
  4119. struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
  4120. char temp[CHAT_SIZE_MAX];
  4121. nullpo_retr(-1, sd);
  4122. memset(temp, '\0', sizeof(temp));
  4123. time(&time_server); // get time in seconds since 1/1/1970
  4124. datetime = localtime(&time_server); // convert seconds in structure
  4125. // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
  4126. strftime(temp, sizeof(temp)-1, msg_txt(sd,230), datetime); // Server time (normal time): %A, %B %d %Y %X.
  4127. clif_displaymessage(fd, temp);
  4128. if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
  4129. if (night_flag == 0)
  4130. clif_displaymessage(fd, msg_txt(sd,231)); // Game time: The game is in permanent daylight.
  4131. else
  4132. clif_displaymessage(fd, msg_txt(sd,232)); // Game time: The game is in permanent night.
  4133. } else if (battle_config.night_duration == 0)
  4134. if (night_flag == 1) { // we start with night
  4135. if ((timer_data = get_timer(day_timer_tid)) != nullptr) {
  4136. sprintf(temp, msg_txt(sd,233), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is in night for %s.
  4137. clif_displaymessage(fd, temp);
  4138. clif_displaymessage(fd, msg_txt(sd,234)); // Game time: After, the game will be in permanent daylight.
  4139. } else
  4140. clif_displaymessage(fd, msg_txt(sd,232)); // Game time: The game is in permanent night.
  4141. } else
  4142. clif_displaymessage(fd, msg_txt(sd,231)); // Game time: The game is in permanent daylight.
  4143. else if (battle_config.day_duration == 0)
  4144. if (night_flag == 0) { // we start with day
  4145. if ((timer_data = get_timer(night_timer_tid)) != nullptr) {
  4146. sprintf(temp, msg_txt(sd,235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is in daylight for %s.
  4147. clif_displaymessage(fd, temp);
  4148. clif_displaymessage(fd, msg_txt(sd,236)); // Game time: After, the game will be in permanent night.
  4149. } else
  4150. clif_displaymessage(fd, msg_txt(sd,231)); // Game time: The game is in permanent daylight.
  4151. } else
  4152. clif_displaymessage(fd, msg_txt(sd,232)); // Game time: The game is in permanent night.
  4153. else {
  4154. const struct TimerData * timer_data2;
  4155. if (night_flag == 0) {
  4156. timer_data = get_timer(night_timer_tid);
  4157. timer_data2 = get_timer(day_timer_tid);
  4158. sprintf(temp, msg_txt(sd,235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is in daylight for %s.
  4159. clif_displaymessage(fd, temp);
  4160. if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0)
  4161. 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.
  4162. else
  4163. 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.
  4164. clif_displaymessage(fd, temp);
  4165. sprintf(temp, msg_txt(sd,238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  4166. clif_displaymessage(fd, temp);
  4167. } else {
  4168. timer_data = get_timer(day_timer_tid);
  4169. timer_data2 = get_timer(night_timer_tid);
  4170. sprintf(temp, msg_txt(sd,233), txt_time(DIFF_TICK(timer_data->tick,gettick()) / 1000)); // Game time: The game is in night for %s.
  4171. clif_displaymessage(fd, temp);
  4172. if (DIFF_TICK(timer_data->tick,timer_data2->tick) > 0)
  4173. 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.
  4174. else
  4175. 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.
  4176. clif_displaymessage(fd, temp);
  4177. sprintf(temp, msg_txt(sd,238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  4178. clif_displaymessage(fd, temp);
  4179. }
  4180. }
  4181. return 0;
  4182. }
  4183. /*==========================================
  4184. * @jail <char_name> by [Yor]
  4185. * Special warp! No check with nowarp and nowarpto flag
  4186. *------------------------------------------*/
  4187. ACMD_FUNC(jail)
  4188. {
  4189. struct map_session_data *pl_sd;
  4190. int x, y;
  4191. unsigned short m_index;
  4192. nullpo_retr(-1, sd);
  4193. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4194. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4195. clif_displaymessage(fd, msg_txt(sd,1134)); // Please enter a player name (usage: @jail <char_name>).
  4196. return -1;
  4197. }
  4198. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL) {
  4199. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4200. return -1;
  4201. }
  4202. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) { // you can jail only lower or same GM
  4203. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4204. return -1;
  4205. }
  4206. if (pl_sd->sc.data[SC_JAILED]) {
  4207. clif_displaymessage(fd, msg_txt(sd,118)); // Player warped in jails.
  4208. return -1;
  4209. }
  4210. switch(rnd() % 2) { //Jail Locations
  4211. case 0:
  4212. m_index = mapindex_name2id(MAP_JAIL);
  4213. x = 24;
  4214. y = 75;
  4215. break;
  4216. default:
  4217. m_index = mapindex_name2id(MAP_JAIL);
  4218. x = 49;
  4219. y = 75;
  4220. break;
  4221. }
  4222. //Duration of INT_MAX to specify infinity.
  4223. sc_start4(NULL,&pl_sd->bl,SC_JAILED,100,INT_MAX,m_index,x,y,1000);
  4224. clif_displaymessage(pl_sd->fd, msg_txt(sd,117)); // GM has send you in jails.
  4225. clif_displaymessage(fd, msg_txt(sd,118)); // Player warped in jails.
  4226. return 0;
  4227. }
  4228. /*==========================================
  4229. * @unjail/@discharge <char_name> by [Yor]
  4230. * Special warp! No check with nowarp and nowarpto flag
  4231. *------------------------------------------*/
  4232. ACMD_FUNC(unjail)
  4233. {
  4234. struct map_session_data *pl_sd;
  4235. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4236. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4237. clif_displaymessage(fd, msg_txt(sd,1135)); // Please enter a player name (usage: @unjail/@discharge <char_name>).
  4238. return -1;
  4239. }
  4240. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL) {
  4241. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4242. return -1;
  4243. }
  4244. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) { // you can jail only lower or same GM
  4245. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4246. return -1;
  4247. }
  4248. if (!pl_sd->sc.data[SC_JAILED]) {
  4249. clif_displaymessage(fd, msg_txt(sd,119)); // This player is not in jails.
  4250. return -1;
  4251. }
  4252. //Reset jail time to 1 sec.
  4253. sc_start(NULL,&pl_sd->bl,SC_JAILED,100,1,1000);
  4254. clif_displaymessage(pl_sd->fd, msg_txt(sd,120)); // A GM has discharged you from jail.
  4255. clif_displaymessage(fd, msg_txt(sd,121)); // Player unjailed.
  4256. return 0;
  4257. }
  4258. ACMD_FUNC(jailfor) {
  4259. struct map_session_data *pl_sd = NULL;
  4260. char * modif_p;
  4261. int jailtime = 0,x,y;
  4262. short m_index = 0;
  4263. nullpo_retr(-1, sd);
  4264. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4265. if (!message || !*message || sscanf(message, "%255s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
  4266. clif_displaymessage(fd, msg_txt(sd,400)); //Usage: @jailfor <time> <character name>
  4267. return -1;
  4268. }
  4269. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  4270. modif_p = atcmd_output;
  4271. jailtime = (int)solve_time(modif_p)/60; // Change to minutes
  4272. if (jailtime == 0) {
  4273. clif_displaymessage(fd, msg_txt(sd,1136)); // Invalid time for jail command.
  4274. 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.
  4275. return -1;
  4276. }
  4277. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL) {
  4278. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4279. return -1;
  4280. }
  4281. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  4282. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4283. return -1;
  4284. }
  4285. // Added by Coltaro
  4286. if(pl_sd->sc.data[SC_JAILED] && pl_sd->sc.data[SC_JAILED]->val1 != INT_MAX) { // Update the player's jail time
  4287. jailtime += pl_sd->sc.data[SC_JAILED]->val1;
  4288. if (jailtime <= 0) {
  4289. jailtime = 0;
  4290. clif_displaymessage(pl_sd->fd, msg_txt(sd,120)); // GM has discharge you.
  4291. clif_displaymessage(fd, msg_txt(sd,121)); // Player unjailed
  4292. } else {
  4293. int year = 0, month = 0, day = 0, hour = 0, minute = 0, second = 0;
  4294. char timestr[21];
  4295. time_t now=time(NULL);
  4296. split_time(jailtime*60,&year,&month,&day,&hour,&minute,&second);
  4297. 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
  4298. clif_displaymessage(pl_sd->fd, atcmd_output);
  4299. 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
  4300. clif_displaymessage(fd, atcmd_output);
  4301. timestamp2string(timestr,20,now+jailtime*60,"%Y-%m-%d %H:%M");
  4302. sprintf(atcmd_output,"Release date is: %s",timestr);
  4303. clif_displaymessage(pl_sd->fd, atcmd_output);
  4304. clif_displaymessage(fd, atcmd_output);
  4305. }
  4306. } else if (jailtime < 0) {
  4307. clif_displaymessage(fd, msg_txt(sd,1136)); // Invalid time for jail command.
  4308. return -1;
  4309. }
  4310. // Jail locations, add more as you wish.
  4311. switch(rnd()%2) {
  4312. case 1: // Jail #1
  4313. m_index = mapindex_name2id(MAP_JAIL);
  4314. x = 49; y = 75;
  4315. break;
  4316. default: // Default Jail
  4317. m_index = mapindex_name2id(MAP_JAIL);
  4318. x = 24; y = 75;
  4319. break;
  4320. }
  4321. 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).
  4322. return 0;
  4323. }
  4324. //By Coltaro
  4325. ACMD_FUNC(jailtime){
  4326. int year, month, day, hour, minute, second;
  4327. char timestr[21];
  4328. time_t now = time(NULL);
  4329. nullpo_retr(-1, sd);
  4330. if (!sd->sc.data[SC_JAILED]) {
  4331. clif_displaymessage(fd, msg_txt(sd,1139)); // You are not in jail.
  4332. return -1;
  4333. }
  4334. if (sd->sc.data[SC_JAILED]->val1 == INT_MAX) {
  4335. clif_displaymessage(fd, msg_txt(sd,1140)); // You have been jailed indefinitely.
  4336. return 0;
  4337. }
  4338. if (sd->sc.data[SC_JAILED]->val1 <= 0) { // Was not jailed with @jailfor (maybe @jail? or warped there? or got recalled?)
  4339. clif_displaymessage(fd, msg_txt(sd,1141)); // You have been jailed for an unknown amount of time.
  4340. return -1;
  4341. }
  4342. // Get remaining jail time
  4343. split_time(sd->sc.data[SC_JAILED]->val1*60,&year,&month,&day,&hour,&minute,&second);
  4344. 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
  4345. clif_displaymessage(fd, atcmd_output);
  4346. timestamp2string(timestr,20,now+sd->sc.data[SC_JAILED]->val1*60,"%Y-%m-%d %H:%M");
  4347. sprintf(atcmd_output,"Release date is: %s",timestr);
  4348. clif_displaymessage(fd, atcmd_output);
  4349. return 0;
  4350. }
  4351. /*==========================================
  4352. * @disguise <mob_id> by [Valaris] (simplified by [Yor])
  4353. *------------------------------------------*/
  4354. ACMD_FUNC(disguise)
  4355. {
  4356. int id = 0;
  4357. nullpo_retr(-1, sd);
  4358. if (!message || !*message) {
  4359. clif_displaymessage(fd, msg_txt(sd,1143)); // Please enter a Monster/NPC name/ID (usage: @disguise <name/ID>).
  4360. return -1;
  4361. }
  4362. if ((id = atoi(message)) > 0)
  4363. { //Acquired an ID
  4364. if (!mobdb_checkid(id) && !npcdb_checkid(id))
  4365. id = 0; //Invalid id for either mobs or npcs.
  4366. } else { //Acquired a Name
  4367. if ((id = mobdb_searchname(message)) == 0)
  4368. {
  4369. struct npc_data* nd = npc_name2id(message);
  4370. if (nd != NULL)
  4371. id = nd->class_;
  4372. }
  4373. }
  4374. if (id == 0)
  4375. {
  4376. clif_displaymessage(fd, msg_txt(sd,123)); // Invalid Monster/NPC name/ID specified.
  4377. return -1;
  4378. }
  4379. if(pc_isriding(sd))
  4380. {
  4381. clif_displaymessage(fd, msg_txt(sd,1144)); // Character cannot be disguised while mounted.
  4382. return -1;
  4383. }
  4384. if (sd->sc.data[SC_MONSTER_TRANSFORM] || sd->sc.data[SC_ACTIVE_MONSTER_TRANSFORM]) {
  4385. clif_displaymessage(fd, msg_txt(sd,730)); // Character cannot be disguised while in monster transform.
  4386. return -1;
  4387. }
  4388. pc_disguise(sd, id);
  4389. clif_displaymessage(fd, msg_txt(sd,122)); // Disguise applied.
  4390. return 0;
  4391. }
  4392. /*==========================================
  4393. * DisguiseAll
  4394. *------------------------------------------*/
  4395. ACMD_FUNC(disguiseall)
  4396. {
  4397. int mob_id=0;
  4398. struct map_session_data *pl_sd;
  4399. struct s_mapiterator* iter;
  4400. nullpo_retr(-1, sd);
  4401. if (!message || !*message) {
  4402. clif_displaymessage(fd, msg_txt(sd,1145)); // Please enter a Monster/NPC name/ID (usage: @disguiseall <name/ID>).
  4403. return -1;
  4404. }
  4405. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name beginning by a number)
  4406. mob_id = atoi(message);
  4407. if (!mobdb_checkid(mob_id) && !npcdb_checkid(mob_id)) { //if mob or npc...
  4408. clif_displaymessage(fd, msg_txt(sd,123)); // Monster/NPC name/id not found.
  4409. return -1;
  4410. }
  4411. iter = mapit_getallusers();
  4412. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4413. pc_disguise(pl_sd, mob_id);
  4414. mapit_free(iter);
  4415. clif_displaymessage(fd, msg_txt(sd,122)); // Disguise applied.
  4416. return 0;
  4417. }
  4418. /*==========================================
  4419. * DisguiseGuild
  4420. *------------------------------------------*/
  4421. ACMD_FUNC(disguiseguild)
  4422. {
  4423. int id = 0, i;
  4424. char monster[NAME_LENGTH], guild[NAME_LENGTH];
  4425. struct guild *g;
  4426. memset(monster, '\0', sizeof(monster));
  4427. memset(guild, '\0', sizeof(guild));
  4428. if( !message || !*message || sscanf(message, "%23[^,], %23[^\r\n]", monster, guild) < 2 ) {
  4429. 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>).
  4430. return -1;
  4431. }
  4432. if( (id = atoi(monster)) > 0 ) {
  4433. if( !mobdb_checkid(id) && !npcdb_checkid(id) )
  4434. id = 0;
  4435. } else {
  4436. if( (id = mobdb_searchname(monster)) == 0 ) {
  4437. struct npc_data* nd = npc_name2id(monster);
  4438. if( nd != NULL )
  4439. id = nd->class_;
  4440. }
  4441. }
  4442. if( id == 0 ) {
  4443. clif_displaymessage(fd, msg_txt(sd,123)); // Monster/NPC name/id hasn't been found.
  4444. return -1;
  4445. }
  4446. if( (g = guild_searchname(guild)) == NULL && (g = guild_search(atoi(guild))) == NULL ) {
  4447. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  4448. return -1;
  4449. }
  4450. for( i = 0; i < g->max_member; i++ ){
  4451. struct map_session_data *pl_sd;
  4452. if( (pl_sd = g->member[i].sd) && !pc_isriding(pl_sd) )
  4453. pc_disguise(pl_sd, id);
  4454. }
  4455. clif_displaymessage(fd, msg_txt(sd,122)); // Disguise applied.
  4456. return 0;
  4457. }
  4458. /*==========================================
  4459. * @undisguise by [Yor]
  4460. *------------------------------------------*/
  4461. ACMD_FUNC(undisguise)
  4462. {
  4463. nullpo_retr(-1, sd);
  4464. if (sd->disguise) {
  4465. pc_disguise(sd, 0);
  4466. clif_displaymessage(fd, msg_txt(sd,124)); // Undisguise applied.
  4467. } else {
  4468. clif_displaymessage(fd, msg_txt(sd,125)); // You're not disguised.
  4469. return -1;
  4470. }
  4471. return 0;
  4472. }
  4473. /*==========================================
  4474. * UndisguiseAll
  4475. *------------------------------------------*/
  4476. ACMD_FUNC(undisguiseall)
  4477. {
  4478. struct map_session_data *pl_sd;
  4479. struct s_mapiterator* iter;
  4480. nullpo_retr(-1, sd);
  4481. iter = mapit_getallusers();
  4482. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4483. if( pl_sd->disguise )
  4484. pc_disguise(pl_sd, 0);
  4485. mapit_free(iter);
  4486. clif_displaymessage(fd, msg_txt(sd,124)); // Undisguise applied.
  4487. return 0;
  4488. }
  4489. /*==========================================
  4490. * UndisguiseGuild
  4491. *------------------------------------------*/
  4492. ACMD_FUNC(undisguiseguild)
  4493. {
  4494. char guild_name[NAME_LENGTH];
  4495. struct guild *g;
  4496. int i;
  4497. nullpo_retr(-1, sd);
  4498. memset(guild_name, '\0', sizeof(guild_name));
  4499. if(!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  4500. clif_displaymessage(fd, msg_txt(sd,1147)); // Please enter guild name/ID (usage: @undisguiseguild <guild name/ID>).
  4501. return -1;
  4502. }
  4503. if( (g = guild_searchname(guild_name)) == NULL && (g = guild_search(atoi(message))) == NULL ) {
  4504. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  4505. return -1;
  4506. }
  4507. for(i = 0; i < g->max_member; i++){
  4508. struct map_session_data *pl_sd;
  4509. if( (pl_sd = g->member[i].sd) && pl_sd->disguise )
  4510. pc_disguise(pl_sd, 0);
  4511. }
  4512. clif_displaymessage(fd, msg_txt(sd,124)); // Undisguise applied.
  4513. return 0;
  4514. }
  4515. /*==========================================
  4516. * @exp by [Skotlex]
  4517. *------------------------------------------*/
  4518. ACMD_FUNC(exp)
  4519. {
  4520. char output[CHAT_SIZE_MAX];
  4521. double nextb, nextj;
  4522. nullpo_retr(-1, sd);
  4523. memset(output, '\0', sizeof(output));
  4524. nextb = (double)pc_nextbaseexp(sd);
  4525. if (nextb)
  4526. nextb = sd->status.base_exp*100.0/nextb;
  4527. nextj = (double)pc_nextjobexp(sd);
  4528. if (nextj)
  4529. nextj = sd->status.job_exp*100.0/nextj;
  4530. sprintf(output, msg_txt(sd,1148), sd->status.base_level, nextb, sd->status.job_level, nextj); // Base Level: %d (%.3f%%) | Job Level: %d (%.3f%%)
  4531. clif_displaymessage(fd, output);
  4532. return 0;
  4533. }
  4534. /*==========================================
  4535. * @broadcast by [Valaris]
  4536. *------------------------------------------*/
  4537. ACMD_FUNC(broadcast)
  4538. {
  4539. nullpo_retr(-1, sd);
  4540. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4541. if (!message || !*message) {
  4542. clif_displaymessage(fd, msg_txt(sd,1149)); // Please enter a message (usage: @broadcast <message>).
  4543. return -1;
  4544. }
  4545. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4546. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT);
  4547. return 0;
  4548. }
  4549. /*==========================================
  4550. * @localbroadcast by [Valaris]
  4551. *------------------------------------------*/
  4552. ACMD_FUNC(localbroadcast)
  4553. {
  4554. nullpo_retr(-1, sd);
  4555. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4556. if (!message || !*message) {
  4557. clif_displaymessage(fd, msg_txt(sd,1150)); // Please enter a message (usage: @localbroadcast <message>).
  4558. return -1;
  4559. }
  4560. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4561. clif_broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT, ALL_SAMEMAP);
  4562. return 0;
  4563. }
  4564. /*==========================================
  4565. * @email <actual@email> <new@email> by [Yor]
  4566. *------------------------------------------*/
  4567. ACMD_FUNC(email)
  4568. {
  4569. char actual_email[100];
  4570. char new_email[100];
  4571. nullpo_retr(-1, sd);
  4572. memset(actual_email, '\0', sizeof(actual_email));
  4573. memset(new_email, '\0', sizeof(new_email));
  4574. if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
  4575. clif_displaymessage(fd, msg_txt(sd,1151)); // Please enter 2 emails (usage: @email <actual@email> <new@email>).
  4576. return -1;
  4577. }
  4578. if (e_mail_check(actual_email) == 0) {
  4579. clif_displaymessage(fd, msg_txt(sd,144)); // Invalid actual email. If you have default e-mail, give a@a.com.
  4580. return -1;
  4581. } else if (e_mail_check(new_email) == 0) {
  4582. clif_displaymessage(fd, msg_txt(sd,145)); // Invalid new email. Please enter a real e-mail.
  4583. return -1;
  4584. } else if (strcmpi(new_email, "a@a.com") == 0) {
  4585. clif_displaymessage(fd, msg_txt(sd,146)); // New email must be a real e-mail.
  4586. return -1;
  4587. } else if (strcmpi(actual_email, new_email) == 0) {
  4588. clif_displaymessage(fd, msg_txt(sd,147)); // New email must be different of the actual e-mail.
  4589. return -1;
  4590. }
  4591. chrif_changeemail(sd->status.account_id, actual_email, new_email);
  4592. clif_displaymessage(fd, msg_txt(sd,148)); // Information sent to login-server via char-server.
  4593. return 0;
  4594. }
  4595. /*==========================================
  4596. *@effect
  4597. *------------------------------------------*/
  4598. ACMD_FUNC(effect)
  4599. {
  4600. int type = EF_NONE;
  4601. nullpo_retr(-1, sd);
  4602. if (!message || !*message || sscanf(message, "%11d", &type) < 1) {
  4603. clif_displaymessage(fd, msg_txt(sd,1152)); // Please enter an effect number (usage: @effect <effect number>).
  4604. return -1;
  4605. }
  4606. if( type <= EF_NONE || type >= EF_MAX ){
  4607. 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.
  4608. clif_displaymessage(fd, atcmd_output);
  4609. return -1;
  4610. }
  4611. clif_specialeffect(&sd->bl, type, ALL_CLIENT);
  4612. clif_displaymessage(fd, msg_txt(sd,229)); // Your effect has changed.
  4613. return 0;
  4614. }
  4615. /*==========================================
  4616. * @killer by MouseJstr
  4617. * enable killing players even when not in pvp
  4618. *------------------------------------------*/
  4619. ACMD_FUNC(killer)
  4620. {
  4621. nullpo_retr(-1, sd);
  4622. sd->state.killer = !sd->state.killer;
  4623. if(sd->state.killer)
  4624. clif_displaymessage(fd, msg_txt(sd,241)); // You can now attack and kill players freely.
  4625. else {
  4626. clif_displaymessage(fd, msg_txt(sd,292)); // Killer state reset.
  4627. pc_stop_attack(sd);
  4628. }
  4629. return 0;
  4630. }
  4631. /*==========================================
  4632. * @killable by MouseJstr
  4633. * enable other people killing you
  4634. *------------------------------------------*/
  4635. ACMD_FUNC(killable)
  4636. {
  4637. nullpo_retr(-1, sd);
  4638. sd->state.killable = !sd->state.killable;
  4639. if(sd->state.killable)
  4640. clif_displaymessage(fd, msg_txt(sd,242)); // You can now be attacked and killed by players.
  4641. else {
  4642. clif_displaymessage(fd, msg_txt(sd,288)); // You are no longer killable.
  4643. map_foreachinallrange(unit_stopattack,&sd->bl, AREA_SIZE, BL_CHAR, sd->bl.id);
  4644. }
  4645. return 0;
  4646. }
  4647. /*==========================================
  4648. * @skillon by MouseJstr
  4649. * turn skills on for the map
  4650. *------------------------------------------*/
  4651. ACMD_FUNC(skillon)
  4652. {
  4653. nullpo_retr(-1, sd);
  4654. map_setmapflag(sd->bl.m, MF_NOSKILL, false);
  4655. clif_displaymessage(fd, msg_txt(sd,244)); // Skills have been enabled on this map.
  4656. return 0;
  4657. }
  4658. /*==========================================
  4659. * @skilloff by MouseJstr
  4660. * Turn skills off on the map
  4661. *------------------------------------------*/
  4662. ACMD_FUNC(skilloff)
  4663. {
  4664. nullpo_retr(-1, sd);
  4665. map_setmapflag(sd->bl.m, MF_NOSKILL, true);
  4666. clif_displaymessage(fd, msg_txt(sd,243)); // Skills have been disabled on this map.
  4667. return 0;
  4668. }
  4669. /*==========================================
  4670. * @npcmove by MouseJstr
  4671. * move a npc
  4672. *------------------------------------------*/
  4673. ACMD_FUNC(npcmove)
  4674. {
  4675. short x = 0, y = 0;
  4676. struct npc_data *nd = 0;
  4677. char npc_name[NPC_NAME_LENGTH];
  4678. nullpo_retr(-1, sd);
  4679. memset(npc_name, '\0', sizeof npc_name);
  4680. if (!message || !*message || sscanf(message, "%6hd %6hd %49[^\n]", &x, &y, npc_name) < 3) {
  4681. clif_displaymessage(fd, msg_txt(sd,1153)); // Usage: @npcmove <X> <Y> <npc_name>
  4682. return -1;
  4683. }
  4684. if ((nd = npc_name2id(npc_name)) == NULL)
  4685. {
  4686. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  4687. return -1;
  4688. }
  4689. if ( npc_movenpc( nd, x, y ) )
  4690. { //actually failed to move
  4691. clif_displaymessage(fd, msg_txt(sd,1154)); // NPC is not on this map.
  4692. return -1; //Not on a map.
  4693. } else
  4694. clif_displaymessage(fd, msg_txt(sd,1155)); // NPC moved
  4695. return 0;
  4696. }
  4697. /*==========================================
  4698. * @addwarp by MouseJstr
  4699. * Create a new static warp point.
  4700. *------------------------------------------*/
  4701. ACMD_FUNC(addwarp)
  4702. {
  4703. char mapname[MAP_NAME_LENGTH_EXT], warpname[NPC_NAME_LENGTH];
  4704. short x,y;
  4705. unsigned short m;
  4706. struct npc_data* nd;
  4707. nullpo_retr(-1, sd);
  4708. memset(warpname, '\0', sizeof(warpname));
  4709. if (!message || !*message || sscanf(message, "%15s %6hd %6hd %49[^\n]", mapname, &x, &y, warpname) < 4) {
  4710. clif_displaymessage(fd, msg_txt(sd,1156)); // Usage: @addwarp <mapname> <X> <Y> <npc name>
  4711. return -1;
  4712. }
  4713. m = mapindex_name2id(mapname);
  4714. if( m == 0 )
  4715. {
  4716. sprintf(atcmd_output, msg_txt(sd,1157), mapname); // Unknown map '%s'.
  4717. clif_displaymessage(fd, atcmd_output);
  4718. return -1;
  4719. }
  4720. nd = npc_add_warp(warpname, sd->bl.m, sd->bl.x, sd->bl.y, 2, 2, m, x, y);
  4721. if( nd == NULL )
  4722. return -1;
  4723. sprintf(atcmd_output, msg_txt(sd,1158), nd->exname); // New warp NPC '%s' created.
  4724. clif_displaymessage(fd, atcmd_output);
  4725. return 0;
  4726. }
  4727. /*==========================================
  4728. * @follow by [MouseJstr]
  4729. * Follow a player .. staying no more then 5 spaces away
  4730. *------------------------------------------*/
  4731. ACMD_FUNC(follow)
  4732. {
  4733. struct map_session_data *pl_sd = NULL;
  4734. nullpo_retr(-1, sd);
  4735. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4736. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4737. if (sd->followtarget == -1)
  4738. return -1;
  4739. pc_stop_following (sd);
  4740. clif_displaymessage(fd, msg_txt(sd,1159)); // Follow mode OFF.
  4741. return 0;
  4742. }
  4743. if ( (pl_sd = map_nick2sd(atcmd_player_name,true)) == NULL )
  4744. {
  4745. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4746. return -1;
  4747. }
  4748. if (sd->followtarget == pl_sd->bl.id) {
  4749. pc_stop_following (sd);
  4750. clif_displaymessage(fd, msg_txt(sd,1159)); // Follow mode OFF.
  4751. } else {
  4752. pc_follow(sd, pl_sd->bl.id);
  4753. clif_displaymessage(fd, msg_txt(sd,1160)); // Follow mode ON.
  4754. }
  4755. return 0;
  4756. }
  4757. /*==========================================
  4758. * @dropall by [MouseJstr] and [Xantara]
  4759. * Drops all your possession on the ground based on item type
  4760. *------------------------------------------*/
  4761. ACMD_FUNC(dropall)
  4762. {
  4763. int8 type = -1;
  4764. uint16 i, count = 0, count2 = 0;
  4765. struct item_data *item_data = NULL;
  4766. nullpo_retr(-1, sd);
  4767. if( message[0] ) {
  4768. type = atoi(message);
  4769. if( type != -1 && type != IT_HEALING && type != IT_USABLE && type != IT_ETC && type != IT_WEAPON &&
  4770. type != IT_ARMOR && type != IT_CARD && type != IT_PETEGG && type != IT_PETARMOR && type != IT_AMMO )
  4771. {
  4772. clif_displaymessage(fd, msg_txt(sd,1492)); // Usage: @dropall {<type>}
  4773. 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
  4774. return -1;
  4775. }
  4776. }
  4777. for( i = 0; i < MAX_INVENTORY; i++ ) {
  4778. if( sd->inventory.u.items_inventory[i].amount ) {
  4779. if( (item_data = itemdb_exists(sd->inventory.u.items_inventory[i].nameid)) == NULL ) {
  4780. 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);
  4781. continue;
  4782. }
  4783. if( !pc_candrop(sd,&sd->inventory.u.items_inventory[i]) )
  4784. continue;
  4785. if( type == -1 || type == (uint8)item_data->type ) {
  4786. if( sd->inventory.u.items_inventory[i].equip != 0 )
  4787. pc_unequipitem(sd, i, 3);
  4788. if( itemdb_ishatched_egg( &sd->inventory.u.items_inventory[i] ) ){
  4789. pet_return_egg( sd, sd->pd );
  4790. }
  4791. pc_equipswitch_remove(sd, i);
  4792. int amount = sd->inventory.u.items_inventory[i].amount;
  4793. if(pc_dropitem(sd, i, amount))
  4794. count += amount;
  4795. else count2 += amount;
  4796. }
  4797. }
  4798. }
  4799. sprintf(atcmd_output, msg_txt(sd,1494), count,count2); // %d items are dropped (%d skipped)!
  4800. clif_displaymessage(fd, atcmd_output);
  4801. return 0;
  4802. }
  4803. /*==========================================
  4804. * @storeall by [MouseJstr]
  4805. * Put everything into storage
  4806. *------------------------------------------*/
  4807. ACMD_FUNC(storeall)
  4808. {
  4809. int i;
  4810. nullpo_retr(-1, sd);
  4811. if (sd->state.storage_flag != 1)
  4812. { //Open storage.
  4813. if( storage_storageopen(sd) == 1 ) {
  4814. clif_displaymessage(fd, msg_txt(sd,1161)); // You currently cannot open your storage.
  4815. return -1;
  4816. }
  4817. }
  4818. for (i = 0; i < MAX_INVENTORY; i++) {
  4819. if (sd->inventory.u.items_inventory[i].amount) {
  4820. if(sd->inventory.u.items_inventory[i].equip != 0)
  4821. pc_unequipitem(sd, i, 3);
  4822. if( itemdb_ishatched_egg( &sd->inventory.u.items_inventory[i] ) ){
  4823. pet_return_egg( sd, sd->pd );
  4824. }
  4825. pc_equipswitch_remove(sd, i);
  4826. storage_storageadd(sd, &sd->storage, i, sd->inventory.u.items_inventory[i].amount);
  4827. }
  4828. }
  4829. storage_storageclose(sd);
  4830. clif_displaymessage(fd, msg_txt(sd,1162)); // All items stored.
  4831. return 0;
  4832. }
  4833. ACMD_FUNC(clearstorage)
  4834. {
  4835. int i, j;
  4836. nullpo_retr(-1, sd);
  4837. if (sd->state.storage_flag == 1) {
  4838. clif_displaymessage(fd, msg_txt(sd,250)); // You have already opened your storage. Close it first.
  4839. return -1;
  4840. }
  4841. if (sd->state.storage_flag == 3) {
  4842. clif_displaymessage(fd, msg_txt(sd,250)); // You have already opened your storage. Close it first.
  4843. return -1;
  4844. }
  4845. j = sd->storage.amount;
  4846. for (i = 0; i < j; ++i) {
  4847. storage_delitem(sd, &sd->storage, i, sd->storage.u.items_storage[i].amount);
  4848. }
  4849. sd->state.storage_flag = 1;
  4850. storage_storageclose(sd);
  4851. clif_displaymessage(fd, msg_txt(sd,1394)); // Your storage was cleaned.
  4852. return 0;
  4853. }
  4854. ACMD_FUNC(cleargstorage)
  4855. {
  4856. int i, j;
  4857. struct guild *g;
  4858. struct s_storage *gstorage;
  4859. nullpo_retr(-1, sd);
  4860. g = sd->guild;
  4861. if (g == NULL) {
  4862. clif_displaymessage(fd, msg_txt(sd,43)); // You're not in a guild.
  4863. return -1;
  4864. }
  4865. if (sd->state.storage_flag == 1) {
  4866. clif_displaymessage(fd, msg_txt(sd,250)); // You have already opened your storage. Close it first.
  4867. return -1;
  4868. }
  4869. if (sd->state.storage_flag == 2) {
  4870. clif_displaymessage(fd, msg_txt(sd,251)); // You have already opened your guild storage. Close it first.
  4871. return -1;
  4872. }
  4873. if (sd->state.storage_flag == 3) {
  4874. clif_displaymessage(fd, msg_txt(sd,250)); // You have already opened your storage. Close it first.
  4875. return -1;
  4876. }
  4877. gstorage = guild2storage2(sd->status.guild_id);
  4878. if (gstorage == NULL) { // Doesn't have opened @gstorage yet, so we skip the deletion since *shouldn't* have any item there.
  4879. return -1;
  4880. }
  4881. j = gstorage->amount;
  4882. gstorage->lock = true; // Lock @gstorage: do not allow any item to be retrieved or stored from any guild member
  4883. for (i = 0; i < j; ++i) {
  4884. storage_guild_delitem(sd, gstorage, i, gstorage->u.items_guild[i].amount);
  4885. }
  4886. storage_guild_storageclose(sd);
  4887. gstorage->lock = false; // Cleaning done, release lock
  4888. clif_displaymessage(fd, msg_txt(sd,1395)); // Your guild storage was cleaned.
  4889. return 0;
  4890. }
  4891. ACMD_FUNC(clearcart)
  4892. {
  4893. int i;
  4894. nullpo_retr(-1, sd);
  4895. if (pc_iscarton(sd) == 0) {
  4896. clif_displaymessage(fd, msg_txt(sd,1396)); // You do not have a cart to be cleaned.
  4897. return -1;
  4898. }
  4899. if (sd->state.vending == 1) { //Somehow...
  4900. return -1;
  4901. }
  4902. for (i = 0; i < MAX_CART; i++) {
  4903. if (sd->cart.u.items_cart[i].nameid > 0)
  4904. pc_cart_delitem(sd, i, sd->cart.u.items_cart[i].amount, 1, LOG_TYPE_OTHER);
  4905. }
  4906. clif_clearcart(fd);
  4907. clif_updatestatus(sd,SP_CARTINFO);
  4908. clif_displaymessage(fd, msg_txt(sd,1397)); // Your cart was cleaned.
  4909. return 0;
  4910. }
  4911. /*==========================================
  4912. * @skillid by [MouseJstr]
  4913. * lookup a skill by name
  4914. *------------------------------------------*/
  4915. #define MAX_SKILLID_PARTIAL_RESULTS 5
  4916. #define MAX_SKILLID_PARTIAL_RESULTS_LEN 74 // "skill " (6) + "%d:" (up to 5) + "%s" (up to 30) + " (%s)" (up to 33)
  4917. ACMD_FUNC(skillid) {
  4918. int skillen, i, found = 0;
  4919. char partials[MAX_SKILLID_PARTIAL_RESULTS][MAX_SKILLID_PARTIAL_RESULTS_LEN];
  4920. nullpo_retr(-1, sd);
  4921. if (!message || !*message) {
  4922. clif_displaymessage(fd, msg_txt(sd,1163)); // Please enter a skill name to look up (usage: @skillid <skill name>).
  4923. return -1;
  4924. }
  4925. skillen = strlen(message);
  4926. for(const auto & skill : skill_db) {
  4927. uint16 skill_id = skill.second->nameid;
  4928. uint16 idx = skill_get_index(skill_id);
  4929. const char *name = skill.second->name;
  4930. const char *desc = skill.second->desc;
  4931. if (strnicmp(name, message, skillen) == 0 || strnicmp(desc, message, skillen) == 0) {
  4932. sprintf(atcmd_output, msg_txt(sd,1164), skill_id, desc, name); // skill %d: %s (%s)
  4933. clif_displaymessage(fd, atcmd_output);
  4934. } else if ( found < MAX_SKILLID_PARTIAL_RESULTS && ( stristr(name,message) || stristr(desc,message) ) ) {
  4935. snprintf(partials[found++], MAX_SKILLID_PARTIAL_RESULTS_LEN, msg_txt(sd,1164), skill_id, desc, name); // // skill %d: %s (%s)
  4936. }
  4937. }
  4938. if( found ) {
  4939. sprintf(atcmd_output, msg_txt(sd,1398), found); // -- Displaying first %d partial matches
  4940. clif_displaymessage(fd, atcmd_output);
  4941. }
  4942. for(i = 0; i < found; i++) { /* partials */
  4943. clif_displaymessage(fd, partials[i]);
  4944. }
  4945. return 0;
  4946. }
  4947. /*==========================================
  4948. * @useskill by [MouseJstr]
  4949. * A way of using skills without having to find them in the skills menu
  4950. *------------------------------------------*/
  4951. ACMD_FUNC(useskill)
  4952. {
  4953. struct map_session_data *pl_sd = NULL;
  4954. struct block_list *bl;
  4955. uint16 skill_id;
  4956. uint16 skill_lv;
  4957. nullpo_retr(-1, sd);
  4958. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4959. if(!message || !*message || sscanf(message, "%6hu %6hu %23[^\n]", &skill_id, &skill_lv, atcmd_player_name) != 3) {
  4960. clif_displaymessage(fd, msg_txt(sd,1165)); // Usage: @useskill <skill ID> <skill level> <char name>
  4961. return -1;
  4962. }
  4963. if (!skill_id || !skill_db.find(skill_id)) {
  4964. clif_displaymessage(fd, msg_txt(sd, 198)); // This skill number doesn't exist.
  4965. return -1;
  4966. }
  4967. if (!skill_lv)
  4968. skill_lv = 1;
  4969. if(!strcmp(atcmd_player_name,"self"))
  4970. pl_sd = sd; //quick keyword
  4971. else if ( (pl_sd = map_nick2sd(atcmd_player_name,true)) == NULL ){
  4972. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4973. return -1;
  4974. }
  4975. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  4976. {
  4977. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4978. return -1;
  4979. }
  4980. if (SKILL_CHK_HOMUN(skill_id) && hom_is_active(sd->hd)) // (If used with @useskill, put the homunc as dest)
  4981. bl = &sd->hd->bl;
  4982. else
  4983. bl = &sd->bl;
  4984. if (skill_get_inf(skill_id)&INF_GROUND_SKILL)
  4985. unit_skilluse_pos(bl, pl_sd->bl.x, pl_sd->bl.y, skill_id, skill_lv);
  4986. else
  4987. unit_skilluse_id(bl, pl_sd->bl.id, skill_id, skill_lv);
  4988. return 0;
  4989. }
  4990. /*==========================================
  4991. * @displayskill by [Skotlex]
  4992. * Debug command to locate new skill IDs. It sends the
  4993. * three possible skill-effect packets to the area.
  4994. *------------------------------------------*/
  4995. ACMD_FUNC(displayskill)
  4996. {
  4997. struct status_data * status;
  4998. t_tick tick;
  4999. uint16 skill_id;
  5000. uint16 skill_lv = 1;
  5001. nullpo_retr(-1, sd);
  5002. if (!message || !*message || sscanf(message, "%6hu %6hu", &skill_id, &skill_lv) < 1)
  5003. {
  5004. clif_displaymessage(fd, msg_txt(sd,1166)); // Usage: @displayskill <skill ID> {<skill level>}
  5005. return -1;
  5006. }
  5007. status = status_get_status_data(&sd->bl);
  5008. tick = gettick();
  5009. clif_skill_damage(&sd->bl,&sd->bl, tick, status->amotion, status->dmotion, 1, 1, skill_id, skill_lv, DMG_SPLASH);
  5010. clif_skill_nodamage(&sd->bl, &sd->bl, skill_id, skill_lv, 1);
  5011. clif_skill_poseffect(&sd->bl, skill_id, skill_lv, sd->bl.x, sd->bl.y, tick);
  5012. return 0;
  5013. }
  5014. /*==========================================
  5015. * @skilltree by [MouseJstr]
  5016. * prints the skill tree for a player required to get to a skill
  5017. *------------------------------------------*/
  5018. ACMD_FUNC(skilltree)
  5019. {
  5020. struct map_session_data *pl_sd = NULL;
  5021. uint16 skill_id;
  5022. int meets, i, j, c=0;
  5023. struct skill_tree_entry *ent;
  5024. nullpo_retr(-1, sd);
  5025. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5026. if(!message || !*message || sscanf(message, "%6hu %23[^\n]", &skill_id, atcmd_player_name) != 2) {
  5027. clif_displaymessage(fd, msg_txt(sd,1167)); // Usage: @skilltree <skill ID> <char name>
  5028. return -1;
  5029. }
  5030. if ( (pl_sd = map_nick2sd(atcmd_player_name,true)) == NULL )
  5031. {
  5032. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5033. return -1;
  5034. }
  5035. i = pc_calc_skilltree_normalize_job(pl_sd);
  5036. c = pc_mapid2jobid(i, pl_sd->status.sex);
  5037. 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).
  5038. clif_displaymessage(fd, atcmd_output);
  5039. c = pc_class2idx(c);
  5040. ARR_FIND( 0, MAX_SKILL_TREE, j, skill_tree[c][j].skill_id == 0 || skill_tree[c][j].skill_id == skill_id );
  5041. if( j == MAX_SKILL_TREE || skill_tree[c][j].skill_id == 0 )
  5042. {
  5043. clif_displaymessage(fd, msg_txt(sd,1169)); // The player cannot use that skill.
  5044. return 0;
  5045. }
  5046. ent = &skill_tree[c][j];
  5047. meets = 1;
  5048. for(j=0;j<MAX_PC_SKILL_REQUIRE;j++)
  5049. {
  5050. if( ent->need[j].skill_id && pc_checkskill(sd,ent->need[j].skill_id) < ent->need[j].skill_lv)
  5051. {
  5052. sprintf(atcmd_output, msg_txt(sd,1170), ent->need[j].skill_lv, skill_get_desc(ent->need[j].skill_id)); // Player requires level %d of skill %s.
  5053. clif_displaymessage(fd, atcmd_output);
  5054. meets = 0;
  5055. }
  5056. }
  5057. if (meets == 1) {
  5058. clif_displaymessage(fd, msg_txt(sd,1171)); // The player meets all the requirements for that skill.
  5059. }
  5060. return 0;
  5061. }
  5062. // Hand a ring with partners name on it to this char
  5063. void getring (struct map_session_data* sd)
  5064. {
  5065. char flag = 0;
  5066. unsigned short item_id;
  5067. struct item item_tmp;
  5068. item_id = (sd->status.sex) ? WEDDING_RING_M : WEDDING_RING_F;
  5069. memset(&item_tmp, 0, sizeof(item_tmp));
  5070. item_tmp.nameid = item_id;
  5071. item_tmp.identify = 1;
  5072. item_tmp.card[0] = CARD0_FORGE;
  5073. item_tmp.card[2] = sd->status.partner_id;
  5074. item_tmp.card[3] = sd->status.partner_id >> 16;
  5075. if((flag = pc_additem(sd,&item_tmp,1,LOG_TYPE_COMMAND))) {
  5076. clif_additem(sd,0,0,flag);
  5077. map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,4,0);
  5078. }
  5079. }
  5080. /*==========================================
  5081. * @marry by [MouseJstr], fixed by Lupus
  5082. * Marry two players
  5083. *------------------------------------------*/
  5084. ACMD_FUNC(marry)
  5085. {
  5086. struct map_session_data *pl_sd = NULL;
  5087. nullpo_retr(-1, sd);
  5088. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5089. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5090. clif_displaymessage(fd, msg_txt(sd,1172)); // Usage: @marry <char name>
  5091. return -1;
  5092. }
  5093. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL) {
  5094. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5095. return -1;
  5096. }
  5097. if (pc_marriage(sd, pl_sd)) {
  5098. clif_displaymessage(fd, msg_txt(sd,1173)); // They are married... wish them well.
  5099. clif_wedding_effect(&pl_sd->bl); //wedding effect and music [Lupus]
  5100. if( pl_sd->bl.m != sd->bl.m )
  5101. clif_wedding_effect(&sd->bl);
  5102. getring(sd); // Auto-give named rings (Aru)
  5103. getring(pl_sd);
  5104. return 0;
  5105. }
  5106. clif_displaymessage(fd, msg_txt(sd,1174)); // The two cannot wed because one is either a baby or already married.
  5107. return -1;
  5108. }
  5109. /*==========================================
  5110. * @divorce by [MouseJstr], fixed by [Lupus]
  5111. * divorce two players
  5112. *------------------------------------------*/
  5113. ACMD_FUNC(divorce)
  5114. {
  5115. nullpo_retr(-1, sd);
  5116. if (!pc_divorce(sd)) {
  5117. sprintf(atcmd_output, msg_txt(sd,1175), sd->status.name); // '%s' is not married.
  5118. clif_displaymessage(fd, atcmd_output);
  5119. return -1;
  5120. }
  5121. sprintf(atcmd_output, msg_txt(sd,1176), sd->status.name); // '%s' and his/her partner are now divorced.
  5122. clif_displaymessage(fd, atcmd_output);
  5123. return 0;
  5124. }
  5125. /*==========================================
  5126. * @changelook by [Celest]
  5127. *------------------------------------------*/
  5128. ACMD_FUNC(changelook)
  5129. {
  5130. int i, j = 0, k = 0;
  5131. int pos[8] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES,LOOK_ROBE, LOOK_BODY2 };
  5132. if((i = sscanf(message, "%11d %11d", &j, &k)) < 1) {
  5133. clif_displaymessage(fd, msg_txt(sd,1177)); // Usage: @changelook {<position>} <view id>
  5134. clif_displaymessage(fd, msg_txt(sd,1178)); // Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield 6-Shoes 7-Robe 8-Body
  5135. return -1;
  5136. } else if ( i == 2 ) {
  5137. if (j < 1 || j > 8)
  5138. j = 1;
  5139. j = pos[j - 1];
  5140. } else if( i == 1 ) { // position not defined, use HEAD_TOP as default
  5141. k = j; // swap
  5142. j = LOOK_HEAD_TOP;
  5143. }
  5144. clif_changelook(&sd->bl,j,k);
  5145. return 0;
  5146. }
  5147. /*==========================================
  5148. * @autotrade by durf [Lupus] [Paradox924X]
  5149. * Turns on/off Autotrade for a specific player
  5150. *------------------------------------------*/
  5151. ACMD_FUNC(autotrade) {
  5152. nullpo_retr(-1, sd);
  5153. if( map_getmapflag(sd->bl.m, MF_AUTOTRADE) != battle_config.autotrade_mapflag ) {
  5154. clif_displaymessage(fd, msg_txt(sd,1179)); // Autotrade is not allowed on this map.
  5155. return -1;
  5156. }
  5157. if( pc_isdead(sd) ) {
  5158. clif_displaymessage(fd, msg_txt(sd,1180)); // You cannot autotrade when dead.
  5159. return -1;
  5160. }
  5161. if( !sd->state.vending && !sd->state.buyingstore ) { //check if player is vending or buying
  5162. clif_displaymessage(fd, msg_txt(sd,549)); // "You should have a shop open to use @autotrade."
  5163. return -1;
  5164. }
  5165. sd->state.autotrade = 1;
  5166. if (battle_config.autotrade_monsterignore)
  5167. sd->state.block_action |= PCBLOCK_IMMUNE;
  5168. if( sd->state.vending ){
  5169. if( Sql_Query( mmysql_handle, "UPDATE `%s` SET `autotrade` = 1 WHERE `id` = %d;", vendings_table, sd->vender_id ) != SQL_SUCCESS ){
  5170. Sql_ShowDebug( mmysql_handle );
  5171. }
  5172. }else if( sd->state.buyingstore ){
  5173. if( Sql_Query( mmysql_handle, "UPDATE `%s` SET `autotrade` = 1 WHERE `id` = %d;", buyingstores_table, sd->buyer_id ) != SQL_SUCCESS ){
  5174. Sql_ShowDebug( mmysql_handle );
  5175. }
  5176. }
  5177. if( battle_config.at_timeout ) {
  5178. int timeout = atoi(message);
  5179. 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);
  5180. }
  5181. if (battle_config.at_logout_event)
  5182. npc_script_event(sd, NPCE_LOGOUT); //Logout Event
  5183. channel_pcquit(sd,0xF); //leave all chan
  5184. clif_authfail_fd(sd->fd, 15);
  5185. chrif_save(sd, CSAVE_AUTOTRADE);
  5186. return 0;
  5187. }
  5188. /*==========================================
  5189. * @changegm by durf (changed by Lupus)
  5190. * Changes Master of your Guild to a specified guild member
  5191. *------------------------------------------*/
  5192. ACMD_FUNC(changegm)
  5193. {
  5194. struct guild *g;
  5195. struct map_session_data *pl_sd;
  5196. nullpo_retr(-1, sd);
  5197. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5198. if (sd->status.guild_id == 0 || (g = sd->guild) == NULL || strcmp(g->master,sd->status.name)) {
  5199. clif_displaymessage(fd, msg_txt(sd,1181)); // You need to be a Guild Master to use this command.
  5200. return -1;
  5201. }
  5202. if( map_getmapflag(sd->bl.m, MF_GUILDLOCK) || map_getmapflag(sd->bl.m, MF_GVG_CASTLE) ) {
  5203. clif_displaymessage(fd, msg_txt(sd,1182)); // You cannot change guild leaders on this map.
  5204. return -1;
  5205. }
  5206. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5207. clif_displaymessage(fd, msg_txt(sd,1183)); // Usage: @changegm <guild_member_name>
  5208. return -1;
  5209. }
  5210. if((pl_sd=map_nick2sd(atcmd_player_name,false)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) {
  5211. clif_displaymessage(fd, msg_txt(sd,1184)); // Target character must be online and be a guild member.
  5212. return -1;
  5213. }
  5214. if( !battle_config.guild_leaderchange_woe && is_agit_start() ){
  5215. #if PACKETVER >= 20151001
  5216. clif_msg(sd, GUILD_MASTER_WOE);
  5217. #else
  5218. clif_displaymessage(fd, msg_txt(sd,1513)); // Currently in WoE hours, unable to delegate Guild leader
  5219. #endif
  5220. return -1;
  5221. }
  5222. if( battle_config.guild_leaderchange_delay && DIFF_TICK(time(NULL),sd->guild->last_leader_change) < battle_config.guild_leaderchange_delay ){
  5223. #if PACKETVER >= 20151001
  5224. clif_msg(sd, GUILD_MASTER_DELAY);
  5225. #else
  5226. clif_displaymessage(fd, msg_txt(sd,1514)); // You have to wait for a while before delegating a new Guild leader
  5227. #endif
  5228. return -1;
  5229. }
  5230. guild_gm_change(sd->status.guild_id, pl_sd->status.char_id);
  5231. return 0;
  5232. }
  5233. /*==========================================
  5234. * @changeleader by Skotlex
  5235. * Changes the leader of a party.
  5236. *------------------------------------------*/
  5237. ACMD_FUNC(changeleader)
  5238. {
  5239. nullpo_retr(-1, sd);
  5240. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5241. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5242. clif_displaymessage(fd, msg_txt(sd,1185)); // Usage: @changeleader <party_member_name>
  5243. return -1;
  5244. }
  5245. party_changeleader(sd, map_nick2sd(atcmd_player_name,false),NULL);
  5246. return 0;
  5247. }
  5248. /*==========================================
  5249. * @partyoption by Skotlex
  5250. * Used to change the item share setting of a party.
  5251. *------------------------------------------*/
  5252. ACMD_FUNC(partyoption)
  5253. {
  5254. struct party_data *p;
  5255. int mi, option;
  5256. char w1[16], w2[16];
  5257. nullpo_retr(-1, sd);
  5258. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
  5259. {
  5260. clif_displaymessage(fd, msg_txt(sd,282)); // You need to be a party leader to use this command.
  5261. return -1;
  5262. }
  5263. ARR_FIND( 0, MAX_PARTY, mi, p->data[mi].sd == sd );
  5264. if (mi == MAX_PARTY)
  5265. return -1; //Shouldn't happen
  5266. if (!p->party.member[mi].leader)
  5267. {
  5268. clif_displaymessage(fd, msg_txt(sd,282)); // You need to be a party leader to use this command.
  5269. return -1;
  5270. }
  5271. if(!message || !*message || sscanf(message, "%15s %15s", w1, w2) < 2)
  5272. {
  5273. clif_displaymessage(fd, msg_txt(sd,1186)); // Usage: @partyoption <pickup share: yes/no> <item distribution: yes/no>
  5274. return -1;
  5275. }
  5276. option = (config_switch(w1)?1:0)|(config_switch(w2)?2:0);
  5277. //Change item share type.
  5278. if (option != p->party.item)
  5279. party_changeoption(sd, p->party.exp, option);
  5280. else
  5281. clif_displaymessage(fd, msg_txt(sd,286)); // There's been no change in the setting.
  5282. return 0;
  5283. }
  5284. /*==========================================
  5285. * @autoloot by Upa-Kun
  5286. * Turns on/off AutoLoot for a specific player
  5287. *------------------------------------------*/
  5288. ACMD_FUNC(autoloot)
  5289. {
  5290. int rate;
  5291. nullpo_retr(-1, sd);
  5292. // autoloot command without value
  5293. if(!message || !*message)
  5294. {
  5295. if (sd->state.autoloot)
  5296. rate = 0;
  5297. else
  5298. rate = 10000;
  5299. } else {
  5300. double drate;
  5301. drate = atof(message);
  5302. rate = (int)(drate*100);
  5303. }
  5304. if (rate < 0) rate = 0;
  5305. if (rate > 10000) rate = 10000;
  5306. sd->state.autoloot = rate;
  5307. if (sd->state.autoloot) {
  5308. 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.
  5309. clif_displaymessage(fd, atcmd_output);
  5310. }else
  5311. clif_displaymessage(fd, msg_txt(sd,1188)); // Autoloot is now off.
  5312. return 0;
  5313. }
  5314. /*==========================================
  5315. * @alootid
  5316. *------------------------------------------*/
  5317. ACMD_FUNC(autolootitem)
  5318. {
  5319. struct item_data *item_data = NULL;
  5320. int i;
  5321. int action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset
  5322. nullpo_retr(-1, sd);
  5323. if (message && *message) {
  5324. if (message[0] == '+') {
  5325. message++;
  5326. action = 1;
  5327. }
  5328. else if (message[0] == '-') {
  5329. message++;
  5330. action = 2;
  5331. }
  5332. else if (!strcmp(message,"reset"))
  5333. action = 4;
  5334. }
  5335. if (action < 3) // add or remove
  5336. {
  5337. if ((item_data = itemdb_exists(atoi(message))) == NULL)
  5338. item_data = itemdb_searchname(message);
  5339. if (!item_data) {
  5340. // No items founds in the DB with Id or Name
  5341. clif_displaymessage(fd, msg_txt(sd,1189)); // Item not found.
  5342. return -1;
  5343. }
  5344. }
  5345. switch(action) {
  5346. case 1:
  5347. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
  5348. if (i != AUTOLOOTITEM_SIZE) {
  5349. clif_displaymessage(fd, msg_txt(sd,1190)); // You're already autolooting this item.
  5350. return -1;
  5351. }
  5352. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == 0);
  5353. if (i == AUTOLOOTITEM_SIZE) {
  5354. clif_displaymessage(fd, msg_txt(sd,1191)); // Your autolootitem list is full. Remove some items first with @autolootid -<item name or ID>.
  5355. return -1;
  5356. }
  5357. sd->state.autolootid[i] = item_data->nameid; // Autoloot Activated
  5358. sprintf(atcmd_output, msg_txt(sd,1192), item_data->name, item_data->jname, item_data->nameid); // Autolooting item: '%s'/'%s' {%d}
  5359. clif_displaymessage(fd, atcmd_output);
  5360. sd->state.autolooting = 1;
  5361. break;
  5362. case 2:
  5363. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
  5364. if (i == AUTOLOOTITEM_SIZE) {
  5365. clif_displaymessage(fd, msg_txt(sd,1193)); // You're currently not autolooting this item.
  5366. return -1;
  5367. }
  5368. sd->state.autolootid[i] = 0;
  5369. sprintf(atcmd_output, msg_txt(sd,1194), item_data->name, item_data->jname, item_data->nameid); // Removed item: '%s'/'%s' {%d} from your autolootitem list.
  5370. clif_displaymessage(fd, atcmd_output);
  5371. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
  5372. if (i == AUTOLOOTITEM_SIZE) {
  5373. sd->state.autolooting = 0;
  5374. }
  5375. break;
  5376. case 3:
  5377. sprintf(atcmd_output, msg_txt(sd,1195), AUTOLOOTITEM_SIZE); // You can have %d items on your autolootitem list.
  5378. clif_displaymessage(fd, atcmd_output);
  5379. 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>".
  5380. clif_displaymessage(fd, msg_txt(sd,1197)); // "@alootid reset" will clear your autolootitem list.
  5381. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
  5382. if (i == AUTOLOOTITEM_SIZE) {
  5383. clif_displaymessage(fd, msg_txt(sd,1198)); // Your autolootitem list is empty.
  5384. } else {
  5385. clif_displaymessage(fd, msg_txt(sd,1199)); // Items on your autolootitem list:
  5386. for(i = 0; i < AUTOLOOTITEM_SIZE; i++)
  5387. {
  5388. if (sd->state.autolootid[i] == 0)
  5389. continue;
  5390. if (!(item_data = itemdb_exists(sd->state.autolootid[i]))) {
  5391. 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);
  5392. continue;
  5393. }
  5394. sprintf(atcmd_output, "'%s'/'%s' {%hu}", item_data->name, item_data->jname, item_data->nameid);
  5395. clif_displaymessage(fd, atcmd_output);
  5396. }
  5397. }
  5398. break;
  5399. case 4:
  5400. memset(sd->state.autolootid, 0, sizeof(sd->state.autolootid));
  5401. clif_displaymessage(fd, msg_txt(sd,1200)); // Your autolootitem list has been reset.
  5402. sd->state.autolooting = 0;
  5403. break;
  5404. }
  5405. return 0;
  5406. }
  5407. /*==========================================
  5408. * @autoloottype
  5409. * Flags:
  5410. * 1: IT_HEALING, 2: IT_UNKNOWN, 4: IT_USABLE, 8: IT_ETC,
  5411. * 16: IT_ARMOR, 32: IT_WEAPON, 64: IT_CARD, 128: IT_PETEGG,
  5412. * 256: IT_PETARMOR, 512: IT_UNKNOWN2, 1024: IT_AMMO, 2048: IT_DELAYCONSUME
  5413. * 262144: IT_CASH
  5414. *------------------------------------------
  5415. * Credits:
  5416. * chriser
  5417. * Aleos
  5418. *------------------------------------------*/
  5419. ACMD_FUNC(autoloottype)
  5420. {
  5421. uint8 action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset
  5422. enum item_types type= IT_UNKNOWN;
  5423. int ITEM_MAX = 1533;
  5424. nullpo_retr(-1, sd);
  5425. if (message && *message) {
  5426. if (message[0] == '+') {
  5427. message++;
  5428. action = 1;
  5429. }
  5430. else if (message[0] == '-') {
  5431. message++;
  5432. action = 2;
  5433. }
  5434. else if (!strcmp(message,"reset"))
  5435. action = 4;
  5436. }
  5437. if (action < 3) { // add or remove
  5438. if ((strncmp(message, "healing", 3) == 0) || (atoi(message) == 0))
  5439. type = IT_HEALING;
  5440. else if ((strncmp(message, "usable", 3) == 0) || (atoi(message) == 2))
  5441. type = IT_USABLE;
  5442. else if ((strncmp(message, "etc", 3) == 0) || (atoi(message) == 3))
  5443. type = IT_ETC;
  5444. else if ((strncmp(message, "armor", 3) == 0) || (atoi(message) == 4))
  5445. type = IT_ARMOR;
  5446. else if ((strncmp(message, "weapon", 3) == 0) || (atoi(message) == 5))
  5447. type = IT_WEAPON;
  5448. else if ((strncmp(message, "card", 3) == 0) || (atoi(message) == 6))
  5449. type = IT_CARD;
  5450. else if ((strncmp(message, "petegg", 4) == 0) || (atoi(message) == 7))
  5451. type = IT_PETEGG;
  5452. else if ((strncmp(message, "petarmor", 4) == 0) || (atoi(message) == 8))
  5453. type = IT_PETARMOR;
  5454. else if ((strncmp(message, "ammo", 3) == 0) || (atoi(message) == 10))
  5455. type = IT_AMMO;
  5456. else {
  5457. clif_displaymessage(fd, msg_txt(sd,1480)); // Item type not found.
  5458. return -1;
  5459. }
  5460. }
  5461. switch (action) {
  5462. case 1:
  5463. if (sd->state.autoloottype&(1<<type)) {
  5464. clif_displaymessage(fd, msg_txt(sd,1481)); // You're already autolooting this item type.
  5465. return -1;
  5466. }
  5467. if (sd->state.autoloottype == ITEM_MAX) {
  5468. 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>.
  5469. return -1;
  5470. }
  5471. sd->state.autoloottype |= (1<<type); // Stores the type
  5472. sprintf(atcmd_output, msg_txt(sd,1483), itemdb_typename(type), type); // Autolooting item type: '%s' {%d}
  5473. clif_displaymessage(fd, atcmd_output);
  5474. break;
  5475. case 2:
  5476. if (!(sd->state.autoloottype&(1<<type))) {
  5477. clif_displaymessage(fd, msg_txt(sd,1484)); // You're currently not autolooting this item type.
  5478. return -1;
  5479. }
  5480. sd->state.autoloottype &= ~(1<<type);
  5481. sprintf(atcmd_output, msg_txt(sd,1485), itemdb_typename(type), type); // Removed item type: '%s' {%d} from your autoloottype list.
  5482. clif_displaymessage(fd, atcmd_output);
  5483. break;
  5484. case 3:
  5485. 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>".
  5486. 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
  5487. clif_displaymessage(fd, msg_txt(sd,1488)); // "@aloottype reset" will clear your autoloottype list.
  5488. if (sd->state.autoloottype == 0)
  5489. clif_displaymessage(fd, msg_txt(sd,1489)); // Your autoloottype list is empty.
  5490. else {
  5491. uint8 i = 0;
  5492. clif_displaymessage(fd, msg_txt(sd,1490)); // Item types on your autoloottype list:
  5493. while (i < IT_MAX) {
  5494. if (sd->state.autoloottype&(1<<i)) {
  5495. sprintf(atcmd_output, " '%s' {%d}", itemdb_typename(static_cast<item_types>(i)), i);
  5496. clif_displaymessage(fd, atcmd_output);
  5497. }
  5498. i++;
  5499. }
  5500. }
  5501. break;
  5502. case 4:
  5503. sd->state.autoloottype = 0;
  5504. clif_displaymessage(fd, msg_txt(sd,1491)); // Your autoloottype list has been reset.
  5505. break;
  5506. }
  5507. return 0;
  5508. }
  5509. /*==========================================
  5510. * It is made to rain.
  5511. * No longer available, keeping here just in case it's back someday. [Ind]
  5512. *------------------------------------------*/
  5513. //ACMD_FUNC(rain)
  5514. //{
  5515. // nullpo_retr(-1, sd);
  5516. // if (map_getmapflag(sd->bl.m, MF_RAIN)) {
  5517. // map_setmapflag(sd->bl.m, MF_RAIN, false);
  5518. // clif_weather(sd->bl.m);
  5519. // clif_displaymessage(fd, msg_txt(sd,1201)); // The rain has stopped.
  5520. // } else {
  5521. // map_setmapflag(sd->bl.m, MF_RAIN, true);
  5522. // clif_weather(sd->bl.m);
  5523. // clif_displaymessage(fd, msg_txt(sd,1202)); // It has started to rain.
  5524. // }
  5525. // return 0;
  5526. //}
  5527. /*==========================================
  5528. * It is made to snow.
  5529. *------------------------------------------*/
  5530. ACMD_FUNC(snow)
  5531. {
  5532. nullpo_retr(-1, sd);
  5533. if (map_getmapflag(sd->bl.m, MF_SNOW)) {
  5534. map_setmapflag(sd->bl.m, MF_SNOW, false);
  5535. clif_weather(sd->bl.m);
  5536. clif_displaymessage(fd, msg_txt(sd,1203)); // Snow has stopped falling.
  5537. } else {
  5538. map_setmapflag(sd->bl.m, MF_SNOW, true);
  5539. clif_weather(sd->bl.m);
  5540. clif_displaymessage(fd, msg_txt(sd,1204)); // It has started to snow.
  5541. }
  5542. return 0;
  5543. }
  5544. /*==========================================
  5545. * Cherry tree snowstorm is made to fall. (Sakura)
  5546. *------------------------------------------*/
  5547. ACMD_FUNC(sakura)
  5548. {
  5549. nullpo_retr(-1, sd);
  5550. if (map_getmapflag(sd->bl.m, MF_SAKURA)) {
  5551. map_setmapflag(sd->bl.m, MF_SAKURA, false);
  5552. clif_weather(sd->bl.m);
  5553. clif_displaymessage(fd, msg_txt(sd,1205)); // Cherry tree leaves no longer fall.
  5554. } else {
  5555. map_setmapflag(sd->bl.m, MF_SAKURA, true);
  5556. clif_weather(sd->bl.m);
  5557. clif_displaymessage(fd, msg_txt(sd,1206)); // Cherry tree leaves have begun to fall.
  5558. }
  5559. return 0;
  5560. }
  5561. /*==========================================
  5562. * Clouds appear.
  5563. *------------------------------------------*/
  5564. ACMD_FUNC(clouds)
  5565. {
  5566. nullpo_retr(-1, sd);
  5567. if (map_getmapflag(sd->bl.m, MF_CLOUDS)) {
  5568. map_setmapflag(sd->bl.m, MF_CLOUDS, false);
  5569. clif_weather(sd->bl.m);
  5570. clif_displaymessage(fd, msg_txt(sd,1207)); // The clouds has disappear.
  5571. } else {
  5572. map_setmapflag(sd->bl.m, MF_CLOUDS, true);
  5573. clif_weather(sd->bl.m);
  5574. clif_displaymessage(fd, msg_txt(sd,1208)); // Clouds appear.
  5575. }
  5576. return 0;
  5577. }
  5578. /*==========================================
  5579. * Different type of clouds using effect 516
  5580. *------------------------------------------*/
  5581. ACMD_FUNC(clouds2)
  5582. {
  5583. nullpo_retr(-1, sd);
  5584. if (map_getmapflag(sd->bl.m, MF_CLOUDS2)) {
  5585. map_setmapflag(sd->bl.m, MF_CLOUDS2, false);
  5586. clif_weather(sd->bl.m);
  5587. clif_displaymessage(fd, msg_txt(sd,1209)); // The alternative clouds disappear.
  5588. } else {
  5589. map_setmapflag(sd->bl.m, MF_CLOUDS2, true);
  5590. clif_weather(sd->bl.m);
  5591. clif_displaymessage(fd, msg_txt(sd,1210)); // Alternative clouds appear.
  5592. }
  5593. return 0;
  5594. }
  5595. /*==========================================
  5596. * Fog hangs over.
  5597. *------------------------------------------*/
  5598. ACMD_FUNC(fog)
  5599. {
  5600. nullpo_retr(-1, sd);
  5601. if (map_getmapflag(sd->bl.m, MF_FOG)) {
  5602. map_setmapflag(sd->bl.m, MF_FOG, false);
  5603. clif_weather(sd->bl.m);
  5604. clif_displaymessage(fd, msg_txt(sd,1211)); // The fog has gone.
  5605. } else {
  5606. map_setmapflag(sd->bl.m, MF_FOG, true);
  5607. clif_weather(sd->bl.m);
  5608. clif_displaymessage(fd, msg_txt(sd,1212)); // Fog hangs over.
  5609. }
  5610. return 0;
  5611. }
  5612. /*==========================================
  5613. * Fallen leaves fall.
  5614. *------------------------------------------*/
  5615. ACMD_FUNC(leaves)
  5616. {
  5617. nullpo_retr(-1, sd);
  5618. if (map_getmapflag(sd->bl.m, MF_LEAVES)) {
  5619. map_setmapflag(sd->bl.m, MF_LEAVES, false);
  5620. clif_weather(sd->bl.m);
  5621. clif_displaymessage(fd, msg_txt(sd,1213)); // Leaves no longer fall.
  5622. } else {
  5623. map_setmapflag(sd->bl.m, MF_LEAVES, true);
  5624. clif_weather(sd->bl.m);
  5625. clif_displaymessage(fd, msg_txt(sd,1214)); // Fallen leaves fall.
  5626. }
  5627. return 0;
  5628. }
  5629. /*==========================================
  5630. * Fireworks appear.
  5631. *------------------------------------------*/
  5632. ACMD_FUNC(fireworks)
  5633. {
  5634. nullpo_retr(-1, sd);
  5635. if (map_getmapflag(sd->bl.m, MF_FIREWORKS)) {
  5636. map_setmapflag(sd->bl.m, MF_FIREWORKS, false);
  5637. clif_weather(sd->bl.m);
  5638. clif_displaymessage(fd, msg_txt(sd,1215)); // Fireworks have ended.
  5639. } else {
  5640. map_setmapflag(sd->bl.m, MF_FIREWORKS, true);
  5641. clif_weather(sd->bl.m);
  5642. clif_displaymessage(fd, msg_txt(sd,1216)); // Fireworks have launched.
  5643. }
  5644. return 0;
  5645. }
  5646. /*==========================================
  5647. * Clearing Weather Effects by Dexity
  5648. *------------------------------------------*/
  5649. ACMD_FUNC(clearweather)
  5650. {
  5651. nullpo_retr(-1, sd);
  5652. //map_setmapflag(sd->bl.m, MF_RAIN, false); // No longer available, keeping here just in case it's back someday. [Ind]
  5653. map_setmapflag(sd->bl.m, MF_SNOW, false);
  5654. map_setmapflag(sd->bl.m, MF_SAKURA, false);
  5655. map_setmapflag(sd->bl.m, MF_CLOUDS, false);
  5656. map_setmapflag(sd->bl.m, MF_CLOUDS2, false);
  5657. map_setmapflag(sd->bl.m, MF_FOG, false);
  5658. map_setmapflag(sd->bl.m, MF_FIREWORKS, false);
  5659. map_setmapflag(sd->bl.m, MF_LEAVES, false);
  5660. clif_weather(sd->bl.m);
  5661. clif_displaymessage(fd, msg_txt(sd,291)); // Weather effects will dispell on warp/refresh
  5662. return 0;
  5663. }
  5664. /*===============================================================
  5665. * Sound Command - plays a sound for everyone around! [Codemaster]
  5666. *---------------------------------------------------------------*/
  5667. ACMD_FUNC(sound)
  5668. {
  5669. char sound_file[100];
  5670. memset(sound_file, '\0', sizeof(sound_file));
  5671. if(!message || !*message || sscanf(message, "%99[^\n]", sound_file) < 1) {
  5672. clif_displaymessage(fd, msg_txt(sd,1217)); // Please enter a sound filename (usage: @sound <filename>).
  5673. return -1;
  5674. }
  5675. if(strstr(sound_file, ".wav") == NULL)
  5676. strcat(sound_file, ".wav");
  5677. clif_soundeffectall(&sd->bl, sound_file, 0, AREA);
  5678. return 0;
  5679. }
  5680. /*==========================================
  5681. * MOB Search
  5682. *------------------------------------------*/
  5683. ACMD_FUNC(mobsearch)
  5684. {
  5685. char mob_name[100];
  5686. int mob_id;
  5687. int number = 0;
  5688. struct s_mapiterator* it;
  5689. nullpo_retr(-1, sd);
  5690. if (!message || !*message || sscanf(message, "%99[^\n]", mob_name) < 1) {
  5691. clif_displaymessage(fd, msg_txt(sd,1218)); // Please enter a monster name (usage: @mobsearch <monster name>).
  5692. return -1;
  5693. }
  5694. if ((mob_id = atoi(mob_name)) == 0)
  5695. mob_id = mobdb_searchname(mob_name);
  5696. if( mobdb_checkid(mob_id) == 0){
  5697. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1219),mob_name); // Invalid mob ID %s!
  5698. clif_displaymessage(fd, atcmd_output);
  5699. return -1;
  5700. }
  5701. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  5702. // strcpy(mob_name,mob_db(mob_id)->name); // --en--
  5703. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1220), mob_name, mapindex_id2name(sd->mapindex)); // Mob Search... %s %s
  5704. clif_displaymessage(fd, atcmd_output);
  5705. it = mapit_geteachmob();
  5706. for(;;)
  5707. {
  5708. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  5709. if( md == NULL )
  5710. break;// no more mobs
  5711. if( md->bl.m != sd->bl.m )
  5712. continue;
  5713. if( md->mob_id != mob_id )
  5714. continue;
  5715. ++number;
  5716. if( md->spawn_timer == INVALID_TIMER )
  5717. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%3d:%3d] %s", number, md->bl.x, md->bl.y, md->name);
  5718. else
  5719. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%s] %s", number, "dead", md->name);
  5720. clif_displaymessage(fd, atcmd_output);
  5721. }
  5722. mapit_free(it);
  5723. return 0;
  5724. }
  5725. /*==========================================
  5726. * @cleanmap - cleans items on the ground
  5727. * @cleanarea - cleans items on the ground within an specified area
  5728. *------------------------------------------*/
  5729. static int atcommand_cleanfloor_sub(struct block_list *bl, va_list ap)
  5730. {
  5731. nullpo_ret(bl);
  5732. map_clearflooritem(bl);
  5733. return 0;
  5734. }
  5735. ACMD_FUNC(cleanmap)
  5736. {
  5737. map_foreachinmap(atcommand_cleanfloor_sub, sd->bl.m, BL_ITEM);
  5738. clif_displaymessage(fd, msg_txt(sd,1221)); // All dropped items have been cleaned up.
  5739. return 0;
  5740. }
  5741. ACMD_FUNC(cleanarea)
  5742. {
  5743. short x0 = 0, y0 = 0, x1 = 0, y1 = 0;
  5744. if (!message || !*message || sscanf(message, "%6hd %6hd %6hd %6hd", &x0, &y0, &x1, &y1) < 1) {
  5745. 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);
  5746. }
  5747. else if (sscanf(message, "%6hd %6hd %6hd %6hd", &x0, &y0, &x1, &y1) == 1) {
  5748. 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);
  5749. }
  5750. else if (sscanf(message, "%6hd %6hd %6hd %6hd", &x0, &y0, &x1, &y1) == 4) {
  5751. map_foreachinallarea(atcommand_cleanfloor_sub, sd->bl.m, x0, y0, x1, y1, BL_ITEM);
  5752. }
  5753. clif_displaymessage(fd, msg_txt(sd,1221)); // All dropped items have been cleaned up.
  5754. return 0;
  5755. }
  5756. /*==========================================
  5757. * make a NPC/PET talk
  5758. * @npctalkc [SnakeDrak]
  5759. *------------------------------------------*/
  5760. ACMD_FUNC(npctalk)
  5761. {
  5762. char name[NPC_NAME_LENGTH],mes[100],temp[CHAT_SIZE_MAX];
  5763. struct npc_data *nd;
  5764. bool ifcolor=(*(command + 8) != 'c' && *(command + 8) != 'C')?0:1;
  5765. unsigned long color=0;
  5766. if (sd->sc.cant.chat || (sd->state.block_action & PCBLOCK_CHAT))
  5767. return -1; //no "chatting" while muted.
  5768. if(!ifcolor) {
  5769. if (!message || !*message || sscanf(message, "%49[^,], %99[^\n]", name, mes) < 2) {
  5770. clif_displaymessage(fd, msg_txt(sd,1222)); // Please enter the correct parameters (usage: @npctalk <npc name>, <message>).
  5771. return -1;
  5772. }
  5773. }
  5774. else {
  5775. if (!message || !*message || sscanf(message, "%16lx %23[^,], %99[^\n]", &color, name, mes) < 3) {
  5776. clif_displaymessage(fd, msg_txt(sd,1223)); // Please enter the correct parameters (usage: @npctalkc <color> <npc name>, <message>).
  5777. return -1;
  5778. }
  5779. }
  5780. if (!(nd = npc_name2id(name))) {
  5781. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist
  5782. return -1;
  5783. }
  5784. strtok(name, "#"); // discard extra name identifier if present
  5785. snprintf(temp, sizeof(temp), "%s : %s", name, mes);
  5786. if(ifcolor) clif_messagecolor(&nd->bl,color,temp,true,AREA_CHAT_WOC);
  5787. else clif_disp_overhead(&nd->bl, temp);
  5788. return 0;
  5789. }
  5790. ACMD_FUNC(pettalk)
  5791. {
  5792. char mes[100],temp[CHAT_SIZE_MAX];
  5793. struct pet_data *pd;
  5794. nullpo_retr(-1, sd);
  5795. if ( battle_config.min_chat_delay ) {
  5796. if( DIFF_TICK(sd->cantalk_tick, gettick()) > 0 )
  5797. return 0;
  5798. sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
  5799. }
  5800. if(!sd->status.pet_id || !(pd=sd->pd))
  5801. {
  5802. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  5803. return -1;
  5804. }
  5805. if (sd->sc.cant.chat || (sd->state.block_action & PCBLOCK_CHAT))
  5806. return -1; //no "chatting" while muted.
  5807. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  5808. clif_displaymessage(fd, msg_txt(sd,1224)); // Please enter a message (usage: @pettalk <message>).
  5809. return -1;
  5810. }
  5811. if (message[0] == '/')
  5812. {// pet emotion processing
  5813. const char* emo[] = {
  5814. "/!", "/?", "/ho", "/lv", "/swt", "/ic", "/an", "/ag", "/$", "/...",
  5815. "/scissors", "/rock", "/paper", "/korea", "/lv2", "/thx", "/wah", "/sry", "/heh", "/swt2",
  5816. "/hmm", "/no1", "/??", "/omg", "/O", "/X", "/hlp", "/go", "/sob", "/gg",
  5817. "/kis", "/kis2", "/pif", "/ok", "-?-", "/indonesia", "/bzz", "/rice", "/awsm", "/meh",
  5818. "/shy", "/pat", "/mp", "/slur", "/com", "/yawn", "/grat", "/hp", "/philippines", "/malaysia",
  5819. "/singapore", "/brazil", "/fsh", "/spin", "/sigh", "/dum", "/crwd", "/desp", "/dice", "-dice2",
  5820. "-dice3", "-dice4", "-dice5", "-dice6", "/india", "/love", "/russia", "-?-", "/mobile", "/mail",
  5821. "/chinese", "/antenna1", "/antenna2", "/antenna3", "/hum", "/abs", "/oops", "/spit", "/ene", "/panic",
  5822. "/whisp"
  5823. };
  5824. int i;
  5825. ARR_FIND( 0, ARRAYLENGTH(emo), i, stricmp(message, emo[i]) == 0 );
  5826. if( i == ET_DICE1 ) i = rnd()%6 + ET_DICE1; // randomize /dice
  5827. if( i < ARRAYLENGTH(emo) )
  5828. {
  5829. if (sd->emotionlasttime + 1 >= time(NULL)) { // not more than 1 per second
  5830. sd->emotionlasttime = time(NULL);
  5831. return 0;
  5832. }
  5833. sd->emotionlasttime = time(NULL);
  5834. clif_emotion(&pd->bl, i);
  5835. return 0;
  5836. }
  5837. }
  5838. snprintf(temp, sizeof temp ,"%s : %s", pd->pet.name, mes);
  5839. clif_disp_overhead(&pd->bl, temp);
  5840. return 0;
  5841. }
  5842. /// @users - displays the number of players present on each map (and percentage)
  5843. /// #users displays on the target user instead of self
  5844. ACMD_FUNC(users)
  5845. {
  5846. char buf[CHAT_SIZE_MAX];
  5847. int i;
  5848. int users[MAX_MAPINDEX];
  5849. int users_all;
  5850. struct s_mapiterator* iter;
  5851. memset(users, 0, sizeof(users));
  5852. users_all = 0;
  5853. // count users on each map
  5854. iter = mapit_getallusers();
  5855. for(;;)
  5856. {
  5857. struct map_session_data* sd2 = (struct map_session_data*)mapit_next(iter);
  5858. if( sd2 == NULL )
  5859. break;// no more users
  5860. if( sd2->mapindex >= MAX_MAPINDEX )
  5861. continue;// invalid mapindex
  5862. if( users[sd2->mapindex] < INT_MAX ) ++users[sd2->mapindex];
  5863. if( users_all < INT_MAX ) ++users_all;
  5864. }
  5865. mapit_free(iter);
  5866. // display results for each map
  5867. for( i = 0; i < MAX_MAPINDEX; ++i )
  5868. {
  5869. if( users[i] == 0 )
  5870. continue;// empty
  5871. safesnprintf(buf, sizeof(buf), "%s: %d (%.2f%%)", mapindex_id2name(i), users[i], (float)(100.0f*users[i]/users_all));
  5872. clif_displaymessage(sd->fd, buf);
  5873. }
  5874. // display overall count
  5875. safesnprintf(buf, sizeof(buf), "all: %d", users_all);
  5876. clif_displaymessage(sd->fd, buf);
  5877. return 0;
  5878. }
  5879. /*==========================================
  5880. *
  5881. *------------------------------------------*/
  5882. ACMD_FUNC(reset)
  5883. {
  5884. pc_resetstate(sd);
  5885. pc_resetskill(sd,1);
  5886. sprintf(atcmd_output, msg_txt(sd,208), sd->status.name); // '%s' skill and stats points reseted!
  5887. clif_displaymessage(fd, atcmd_output);
  5888. return 0;
  5889. }
  5890. /*==========================================
  5891. *
  5892. *------------------------------------------*/
  5893. ACMD_FUNC(summon)
  5894. {
  5895. char name[NAME_LENGTH];
  5896. int mob_id = 0;
  5897. int duration = 0;
  5898. struct mob_data *md;
  5899. t_tick tick=gettick();
  5900. nullpo_retr(-1, sd);
  5901. if (!message || !*message || sscanf(message, "%23s %11d", name, &duration) < 1)
  5902. {
  5903. clif_displaymessage(fd, msg_txt(sd,1225)); // Please enter a monster name (usage: @summon <monster name> {duration}).
  5904. return -1;
  5905. }
  5906. if (duration < 1)
  5907. duration =1;
  5908. else if (duration > 60)
  5909. duration =60;
  5910. if ((mob_id = atoi(name)) == 0)
  5911. mob_id = mobdb_searchname(name);
  5912. if(mob_id == 0 || mobdb_checkid(mob_id) == 0)
  5913. {
  5914. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  5915. return -1;
  5916. }
  5917. md = mob_once_spawn_sub(&sd->bl, sd->bl.m, -1, -1, "--ja--", mob_id, "", SZ_SMALL, AI_NONE);
  5918. if(!md)
  5919. return -1;
  5920. md->master_id=sd->bl.id;
  5921. md->special_state.ai=AI_ATTACK;
  5922. md->deletetimer=add_timer(tick+(duration*60000),mob_timer_delete,md->bl.id,0);
  5923. clif_specialeffect(&md->bl,EF_ENTRY2,AREA);
  5924. mob_spawn(md);
  5925. sc_start4(NULL,&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000);
  5926. clif_skill_poseffect(&sd->bl,AM_CALLHOMUN,1,md->bl.x,md->bl.y,tick);
  5927. clif_displaymessage(fd, msg_txt(sd,39)); // All monster summoned!
  5928. return 0;
  5929. }
  5930. /*==========================================
  5931. * @adjgroup
  5932. * Temporarily move player to another group
  5933. * Useful during beta testing to allow players to use GM commands for short periods of time
  5934. *------------------------------------------*/
  5935. ACMD_FUNC(adjgroup)
  5936. {
  5937. int new_group = 0;
  5938. nullpo_retr(-1, sd);
  5939. if (!message || !*message || sscanf(message, "%11d", &new_group) != 1) {
  5940. clif_displaymessage(fd, msg_txt(sd,1226)); // Usage: @adjgroup <group_id>
  5941. return -1;
  5942. }
  5943. if (!pc_group_exists(new_group)) {
  5944. clif_displaymessage(fd, msg_txt(sd,1227)); // Specified group does not exist.
  5945. return -1;
  5946. }
  5947. sd->group_id = new_group;
  5948. pc_group_pc_load(sd);/* update cache */
  5949. clif_displaymessage(fd, msg_txt(sd,1228)); // Group changed successfully.
  5950. clif_displaymessage(sd->fd, msg_txt(sd,1229)); // Your group has changed.
  5951. return 0;
  5952. }
  5953. /*==========================================
  5954. * @trade by [MouseJstr]
  5955. * Open a trade window with a remote player
  5956. *------------------------------------------*/
  5957. ACMD_FUNC(trade)
  5958. {
  5959. struct map_session_data *pl_sd = NULL;
  5960. nullpo_retr(-1, sd);
  5961. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5962. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5963. clif_displaymessage(fd, msg_txt(sd,1230)); // Please enter a player name (usage: @trade <char name>).
  5964. return -1;
  5965. }
  5966. if ( (pl_sd = map_nick2sd(atcmd_player_name,true)) == NULL )
  5967. {
  5968. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5969. return -1;
  5970. }
  5971. trade_traderequest(sd, pl_sd);
  5972. return 0;
  5973. }
  5974. /*==========================================
  5975. * @setbattleflag by [MouseJstr]
  5976. * set a battle_config flag without having to reboot
  5977. *------------------------------------------*/
  5978. ACMD_FUNC(setbattleflag)
  5979. {
  5980. char flag[128], value[128];
  5981. int reload = 0;
  5982. nullpo_retr(-1, sd);
  5983. if (!message || !*message || sscanf(message, "%127s %127s %11d", flag, value, &reload) != 2) {
  5984. clif_displaymessage(fd, msg_txt(sd,1231)); // Usage: @setbattleflag <flag> <value> {<reload>}
  5985. return -1;
  5986. }
  5987. if (battle_set_value(flag, value) == 0)
  5988. {
  5989. clif_displaymessage(fd, msg_txt(sd,1232)); // Unknown battle_config flag.
  5990. return -1;
  5991. }
  5992. clif_displaymessage(fd, msg_txt(sd,1233)); // Set battle_config as requested.
  5993. if (reload)
  5994. mob_reload();
  5995. return 0;
  5996. }
  5997. /*==========================================
  5998. * @unmute [Valaris]
  5999. *------------------------------------------*/
  6000. ACMD_FUNC(unmute)
  6001. {
  6002. struct map_session_data *pl_sd = NULL;
  6003. nullpo_retr(-1, sd);
  6004. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  6005. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  6006. clif_displaymessage(fd, msg_txt(sd,1234)); // Please enter a player name (usage: @unmute <char name>).
  6007. return -1;
  6008. }
  6009. if ( (pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL )
  6010. {
  6011. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  6012. return -1;
  6013. }
  6014. if(!pl_sd->sc.data[SC_NOCHAT]) {
  6015. clif_displaymessage(sd->fd,msg_txt(sd,1235)); // Player is not muted.
  6016. return -1;
  6017. }
  6018. pl_sd->status.manner = 0;
  6019. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  6020. clif_displaymessage(sd->fd,msg_txt(sd,1236)); // Player unmuted.
  6021. return 0;
  6022. }
  6023. /*==========================================
  6024. * @uptime by MC Cameri
  6025. *------------------------------------------*/
  6026. ACMD_FUNC(uptime)
  6027. {
  6028. unsigned long seconds = 0, day = 24*60*60, hour = 60*60,
  6029. minute = 60, days = 0, hours = 0, minutes = 0;
  6030. nullpo_retr(-1, sd);
  6031. seconds = get_uptime();
  6032. days = seconds/day;
  6033. seconds -= (seconds/day>0)?(seconds/day)*day:0;
  6034. hours = seconds/hour;
  6035. seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
  6036. minutes = seconds/minute;
  6037. seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
  6038. snprintf(atcmd_output, sizeof(atcmd_output), msg_txt(sd,245), days, hours, minutes, seconds); // Server Uptime: %ld days, %ld hours, %ld minutes, %ld seconds.
  6039. clif_displaymessage(fd, atcmd_output);
  6040. return 0;
  6041. }
  6042. /*==========================================
  6043. * @changesex
  6044. * => Changes one's account sex. Switch from male to female or visversa
  6045. *------------------------------------------*/
  6046. ACMD_FUNC(changesex)
  6047. {
  6048. int i;
  6049. nullpo_retr(-1, sd);
  6050. pc_resetskill(sd,4);
  6051. // to avoid any problem with equipment and invalid sex, equipment is unequiped.
  6052. for (i = 0; i < EQI_MAX; i++) {
  6053. if (sd->equip_index[i] >= 0)
  6054. pc_unequipitem(sd, sd->equip_index[i], 3);
  6055. }
  6056. chrif_changesex(sd, true);
  6057. return 0;
  6058. }
  6059. /*==========================================
  6060. * @changecharsex
  6061. * => Changes one's character sex. Switch from male to female or visversa.
  6062. *------------------------------------------*/
  6063. ACMD_FUNC(changecharsex)
  6064. {
  6065. int i;
  6066. nullpo_retr(-1, sd);
  6067. pc_resetskill(sd,4);
  6068. // to avoid any problem with equipment and invalid sex, equipment is unequiped.
  6069. for (i = 0; i < EQI_MAX; i++) {
  6070. if (sd->equip_index[i] >= 0)
  6071. pc_unequipitem(sd, sd->equip_index[i], 3);
  6072. }
  6073. chrif_changesex(sd, false);
  6074. return 0;
  6075. }
  6076. /*================================================
  6077. * @mute - Mutes a player for a set amount of time
  6078. *------------------------------------------------*/
  6079. ACMD_FUNC(mute)
  6080. {
  6081. struct map_session_data *pl_sd = NULL;
  6082. int manner;
  6083. nullpo_retr(-1, sd);
  6084. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  6085. if (!message || !*message || sscanf(message, "%11d %23[^\n]", &manner, atcmd_player_name) < 1) {
  6086. clif_displaymessage(fd, msg_txt(sd,1237)); // Usage: @mute <time> <char name>
  6087. return -1;
  6088. }
  6089. if ( (pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL )
  6090. {
  6091. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  6092. return -1;
  6093. }
  6094. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  6095. {
  6096. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  6097. return -1;
  6098. }
  6099. clif_manner_message(sd, 0);
  6100. clif_manner_message(pl_sd, 5);
  6101. if( pl_sd->status.manner < manner ) {
  6102. pl_sd->status.manner -= manner;
  6103. sc_start(NULL,&pl_sd->bl,SC_NOCHAT,100,0,0);
  6104. } else {
  6105. pl_sd->status.manner = 0;
  6106. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  6107. }
  6108. clif_GM_silence(sd, pl_sd, (manner > 0 ? 1 : 0));
  6109. return 0;
  6110. }
  6111. /*==========================================
  6112. * @refresh (like @jumpto <<yourself>>)
  6113. *------------------------------------------*/
  6114. ACMD_FUNC(refresh)
  6115. {
  6116. nullpo_retr(-1, sd);
  6117. clif_refresh(sd);
  6118. return 0;
  6119. }
  6120. ACMD_FUNC(refreshall)
  6121. {
  6122. struct map_session_data* iter_sd;
  6123. struct s_mapiterator* iter;
  6124. nullpo_retr(-1, sd);
  6125. iter = mapit_getallusers();
  6126. for (iter_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); iter_sd = (TBL_PC*)mapit_next(iter))
  6127. clif_refresh(iter_sd);
  6128. mapit_free(iter);
  6129. return 0;
  6130. }
  6131. /*==========================================
  6132. * @identify
  6133. * => GM's magnifier.
  6134. *------------------------------------------*/
  6135. ACMD_FUNC(identify)
  6136. {
  6137. int i,num;
  6138. nullpo_retr(-1, sd);
  6139. for(i=num=0;i<MAX_INVENTORY;i++){
  6140. if(sd->inventory.u.items_inventory[i].nameid > 0 && sd->inventory.u.items_inventory[i].identify != 1) {
  6141. num++;
  6142. }
  6143. }
  6144. if (num > 0) {
  6145. clif_item_identify_list(sd);
  6146. } else {
  6147. clif_displaymessage(fd,msg_txt(sd,1238)); // There are no items to appraise.
  6148. }
  6149. return 0;
  6150. }
  6151. /*===============================================
  6152. * @identifyall
  6153. * => Indentify all items in inventory - Akinari
  6154. *-----------------------------------------------*/
  6155. ACMD_FUNC(identifyall)
  6156. {
  6157. nullpo_retr(-1, sd);
  6158. pc_identifyall(sd, true);
  6159. return 0;
  6160. }
  6161. /*==========================================
  6162. * @gmotd (Global MOTD)
  6163. * by davidsiaw :P
  6164. *------------------------------------------*/
  6165. ACMD_FUNC(gmotd)
  6166. {
  6167. FILE* fp;
  6168. if( ( fp = fopen(motd_txt, "r") ) != NULL )
  6169. {
  6170. char buf[CHAT_SIZE_MAX];
  6171. size_t len;
  6172. while( fgets(buf, sizeof(buf), fp) )
  6173. {
  6174. if( buf[0] == '/' && buf[1] == '/' )
  6175. {
  6176. continue;
  6177. }
  6178. len = strlen(buf);
  6179. while( len && ( buf[len-1] == '\r' || buf[len-1] == '\n' ) )
  6180. {// strip trailing EOL characters
  6181. len--;
  6182. }
  6183. if( len )
  6184. {
  6185. buf[len] = 0;
  6186. intif_broadcast(buf, len+1, 0);
  6187. }
  6188. }
  6189. fclose(fp);
  6190. }
  6191. return 0;
  6192. }
  6193. ACMD_FUNC(misceffect)
  6194. {
  6195. int effect = 0;
  6196. nullpo_retr(-1, sd);
  6197. if (!message || !*message)
  6198. return -1;
  6199. if (sscanf(message, "%11d", &effect) < 1)
  6200. return -1;
  6201. clif_misceffect(&sd->bl,effect);
  6202. return 0;
  6203. }
  6204. /*==========================================
  6205. * MAIL SYSTEM
  6206. *------------------------------------------*/
  6207. ACMD_FUNC(mail)
  6208. {
  6209. nullpo_ret(sd);
  6210. mail_openmail(sd);
  6211. return 0;
  6212. }
  6213. /*==========================================
  6214. * Show Monster DB Info v 1.0
  6215. * originally by [Lupus]
  6216. *------------------------------------------*/
  6217. ACMD_FUNC(mobinfo)
  6218. {
  6219. unsigned char msize[SZ_ALL][7] = { "Small", "Medium", "Large" };
  6220. unsigned char mrace[RC_ALL][11] = { "Formless", "Undead", "Beast", "Plant", "Insect", "Fish", "Demon", "Demi-Human", "Angel", "Dragon", "Player" };
  6221. unsigned char melement[ELE_ALL][8] = { "Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead" };
  6222. char atcmd_output2[CHAT_SIZE_MAX];
  6223. struct item_data *item_data;
  6224. struct mob_db *mob;
  6225. uint16 mob_ids[MAX_SEARCH];
  6226. int count;
  6227. int i, k;
  6228. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6229. memset(atcmd_output2, '\0', sizeof(atcmd_output2));
  6230. if (!message || !*message) {
  6231. clif_displaymessage(fd, msg_txt(sd,1239)); // Please enter a monster name/ID (usage: @mobinfo <monster_name_or_monster_ID>).
  6232. return -1;
  6233. }
  6234. // If monster identifier/name argument is a name
  6235. if ((i = mobdb_checkid(atoi(message))))
  6236. {
  6237. mob_ids[0] = i;
  6238. count = 1;
  6239. } else
  6240. count = mobdb_searchname_array(message, mob_ids, MAX_SEARCH);
  6241. if (!count) {
  6242. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  6243. return -1;
  6244. }
  6245. if (count >= MAX_SEARCH) {
  6246. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH); // Displaying first %d matches
  6247. clif_displaymessage(fd, atcmd_output);
  6248. count = MAX_SEARCH;
  6249. }
  6250. for (k = 0; k < count; k++) {
  6251. unsigned int j,base_exp,job_exp;
  6252. mob = mob_db(mob_ids[k]);
  6253. base_exp = mob->base_exp;
  6254. job_exp = mob->job_exp;
  6255. if (pc_isvip(sd)) { // Display EXP rate increase for VIP
  6256. base_exp += (base_exp * battle_config.vip_base_exp_increase) / 100;
  6257. job_exp += (job_exp * battle_config.vip_job_exp_increase) / 100;
  6258. }
  6259. #ifdef RENEWAL_EXP
  6260. if( battle_config.atcommand_mobinfo_type ) {
  6261. base_exp = base_exp * pc_level_penalty_mod(mob->lv - sd->status.base_level, mob->status.class_, mob->status.mode, 1) / 100;
  6262. job_exp = job_exp * pc_level_penalty_mod(mob->lv - sd->status.base_level, mob->status.class_, mob->status.mode, 1) / 100;
  6263. }
  6264. #endif
  6265. // stats
  6266. if (mob->mexp)
  6267. sprintf(atcmd_output, msg_txt(sd,1240), mob->name, mob->jname, mob->sprite, mob->vd.class_); // MVP Monster: '%s'/'%s'/'%s' (%d)
  6268. else
  6269. sprintf(atcmd_output, msg_txt(sd,1241), mob->name, mob->jname, mob->sprite, mob->vd.class_); // Monster: '%s'/'%s'/'%s' (%d)
  6270. clif_displaymessage(fd, atcmd_output);
  6271. sprintf(atcmd_output, msg_txt(sd,1242), mob->lv, mob->status.max_hp, base_exp, job_exp, MOB_HIT(mob), MOB_FLEE(mob)); // Lv:%d HP:%d Base EXP:%u Job EXP:%u HIT:%d FLEE:%d
  6272. clif_displaymessage(fd, atcmd_output);
  6273. sprintf(atcmd_output, msg_txt(sd,1243), // DEF:%d MDEF:%d STR:%d AGI:%d VIT:%d INT:%d DEX:%d LUK:%d
  6274. mob->status.def, mob->status.mdef,mob->status.str, mob->status.agi,
  6275. mob->status.vit, mob->status.int_, mob->status.dex, mob->status.luk);
  6276. clif_displaymessage(fd, atcmd_output);
  6277. sprintf(atcmd_output, msg_txt(sd,1244), // ATK:%d~%d Range:%d~%d~%d Size:%s Race: %s Element: %s (Lv:%d)
  6278. mob->status.batk + mob->status.rhw.atk, mob->status.batk + mob->status.rhw.atk2, mob->status.rhw.range,
  6279. mob->range2 , mob->range3, msize[mob->status.size],
  6280. mrace[mob->status.race], melement[mob->status.def_ele], mob->status.ele_lv);
  6281. clif_displaymessage(fd, atcmd_output);
  6282. // drops
  6283. clif_displaymessage(fd, msg_txt(sd,1245)); // Drops:
  6284. strcpy(atcmd_output, " ");
  6285. j = 0;
  6286. for (i = 0; i < MAX_MOB_DROP_TOTAL; i++) {
  6287. int droprate;
  6288. if (mob->dropitem[i].nameid <= 0 || mob->dropitem[i].p < 1 || (item_data = itemdb_exists(mob->dropitem[i].nameid)) == NULL)
  6289. continue;
  6290. droprate = mob->dropitem[i].p;
  6291. #ifdef RENEWAL_DROP
  6292. if( battle_config.atcommand_mobinfo_type ) {
  6293. droprate = droprate * pc_level_penalty_mod(mob->lv - sd->status.base_level, mob->status.class_, mob->status.mode, 2) / 100;
  6294. if (droprate <= 0 && !battle_config.drop_rate0item)
  6295. droprate = 1;
  6296. }
  6297. #endif
  6298. if (pc_isvip(sd)) // Display drop rate increase for VIP
  6299. droprate += (droprate * battle_config.vip_drop_increase) / 100;
  6300. if (item_data->slot)
  6301. sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, (float)droprate / 100);
  6302. else
  6303. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)droprate / 100);
  6304. strcat(atcmd_output, atcmd_output2);
  6305. if (++j % 3 == 0) {
  6306. clif_displaymessage(fd, atcmd_output);
  6307. strcpy(atcmd_output, " ");
  6308. }
  6309. }
  6310. if (j == 0)
  6311. clif_displaymessage(fd, msg_txt(sd,1246)); // This monster has no drops.
  6312. else if (j % 3 != 0)
  6313. clif_displaymessage(fd, atcmd_output);
  6314. // mvp
  6315. if (mob->mexp) {
  6316. float mvppercent, mvpremain;
  6317. sprintf(atcmd_output, msg_txt(sd,1247), mob->mexp); // MVP Bonus EXP:%u
  6318. clif_displaymessage(fd, atcmd_output);
  6319. strcpy(atcmd_output, msg_txt(sd,1248)); // MVP Items:
  6320. mvpremain = 100.0; //Remaining drop chance for official mvp drop mode
  6321. j = 0;
  6322. for (i = 0; i < MAX_MVP_DROP_TOTAL; i++) {
  6323. if (mob->mvpitem[i].nameid <= 0 || (item_data = itemdb_exists(mob->mvpitem[i].nameid)) == NULL)
  6324. continue;
  6325. //Because if there are 3 MVP drops at 50%, the first has a chance of 50%, the second 25% and the third 12.5%
  6326. mvppercent = (float)mob->mvpitem[i].p * mvpremain / 10000.0f;
  6327. if(battle_config.item_drop_mvp_mode == 0) {
  6328. mvpremain -= mvppercent;
  6329. }
  6330. if (mvppercent > 0) {
  6331. j++;
  6332. if (j == 1) {
  6333. if (item_data->slot)
  6334. sprintf(atcmd_output2, " %s[%d] %02.02f%%", item_data->jname, item_data->slot, mvppercent);
  6335. else
  6336. sprintf(atcmd_output2, " %s %02.02f%%", item_data->jname, mvppercent);
  6337. } else {
  6338. if (item_data->slot)
  6339. sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, mvppercent);
  6340. else
  6341. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, mvppercent);
  6342. }
  6343. strcat(atcmd_output, atcmd_output2);
  6344. }
  6345. }
  6346. if (j == 0)
  6347. clif_displaymessage(fd, msg_txt(sd,1249)); // This monster has no MVP prizes.
  6348. else
  6349. clif_displaymessage(fd, atcmd_output);
  6350. }
  6351. }
  6352. return 0;
  6353. }
  6354. /*=========================================
  6355. * @showmobs by KarLaeda
  6356. * => For 15 sec displays the mobs on minimap
  6357. *------------------------------------------*/
  6358. ACMD_FUNC(showmobs)
  6359. {
  6360. char mob_name[100];
  6361. int mob_id;
  6362. int number = 0;
  6363. struct s_mapiterator* it;
  6364. nullpo_retr(-1, sd);
  6365. if(sscanf(message, "%99[^\n]", mob_name) < 0)
  6366. return -1;
  6367. if((mob_id = atoi(mob_name)) == 0)
  6368. mob_id = mobdb_searchname(mob_name);
  6369. if(mobdb_checkid(mob_id) == 0){
  6370. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1250),mob_name); // Invalid mob id %s!
  6371. clif_displaymessage(fd, atcmd_output);
  6372. return 0;
  6373. }
  6374. if(status_has_mode(&mob_db(mob_id)->status,MD_STATUS_IMMUNE) && !pc_has_permission(sd, PC_PERM_SHOW_BOSS)){ // If player group does not have access to boss mobs.
  6375. clif_displaymessage(fd, msg_txt(sd,1251)); // Can't show boss mobs!
  6376. return 0;
  6377. }
  6378. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname[0])
  6379. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  6380. //strcpy(mob_name,mob_db(mob_id)->name); // --en--
  6381. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1252), // Mob Search... %s %s
  6382. mob_name, mapindex_id2name(sd->mapindex));
  6383. clif_displaymessage(fd, atcmd_output);
  6384. it = mapit_geteachmob();
  6385. for(;;)
  6386. {
  6387. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  6388. if( md == NULL )
  6389. break;// no more mobs
  6390. if( md->bl.m != sd->bl.m )
  6391. continue;
  6392. if( mob_id != -1 && md->mob_id != mob_id )
  6393. continue;
  6394. if( md->special_state.ai || md->master_id )
  6395. continue; // hide slaves and player summoned mobs
  6396. if( md->spawn_timer != INVALID_TIMER )
  6397. continue; // hide mobs waiting for respawn
  6398. ++number;
  6399. clif_viewpoint(sd, 1, 0, md->bl.x, md->bl.y, number, 0xFFFFFF);
  6400. }
  6401. mapit_free(it);
  6402. return 0;
  6403. }
  6404. /*==========================================
  6405. * homunculus level up [orn]
  6406. *------------------------------------------*/
  6407. ACMD_FUNC(homlevel)
  6408. {
  6409. TBL_HOM * hd;
  6410. int level = 0, i = 0;
  6411. nullpo_retr(-1, sd);
  6412. if ( !message || !*message || ( level = atoi(message) ) < 1 ) {
  6413. clif_displaymessage(fd, msg_txt(sd,1253)); // Please enter a level adjustment (usage: @homlevel <number of levels>).
  6414. return -1;
  6415. }
  6416. if ( !hom_is_active(sd->hd) ) {
  6417. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6418. return -1;
  6419. }
  6420. hd = sd->hd;
  6421. for (i = 1; i <= level && hd->exp_next; i++){
  6422. hd->homunculus.exp += hd->exp_next;
  6423. if( !hom_levelup(hd) )
  6424. break;
  6425. }
  6426. status_calc_homunculus(hd, SCO_NONE);
  6427. status_percent_heal(&hd->bl, 100, 100);
  6428. clif_specialeffect(&hd->bl,EF_HO_UP,AREA);
  6429. return 0;
  6430. }
  6431. /*==========================================
  6432. * homunculus evolution H [orn]
  6433. *------------------------------------------*/
  6434. ACMD_FUNC(homevolution)
  6435. {
  6436. nullpo_retr(-1, sd);
  6437. if ( !hom_is_active(sd->hd) ) {
  6438. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6439. return -1;
  6440. }
  6441. if ( !hom_evolution(sd->hd) ) {
  6442. clif_displaymessage(fd, msg_txt(sd,1255)); // Your homunculus doesn't evolve.
  6443. return -1;
  6444. }
  6445. clif_homskillinfoblock(sd);
  6446. return 0;
  6447. }
  6448. ACMD_FUNC(hommutate)
  6449. {
  6450. int homun_id, m_class = 0, m_id;
  6451. nullpo_retr(-1, sd);
  6452. if (!hom_is_active(sd->hd)) {
  6453. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6454. return -1;
  6455. }
  6456. if (!message || !*message) {
  6457. homun_id = 6048 + (rnd() % 4);
  6458. } else {
  6459. homun_id = atoi(message);
  6460. }
  6461. m_class = hom_class2mapid(sd->hd->homunculus.class_);
  6462. m_id = hom_class2mapid(homun_id);
  6463. if (m_class != -1 && m_id != -1 && m_class&HOM_EVO && m_id&HOM_S && sd->hd->homunculus.level >= 99) {
  6464. hom_mutate(sd->hd, homun_id);
  6465. } else {
  6466. clif_emotion(&sd->hd->bl, ET_SWEAT);
  6467. }
  6468. return 0;
  6469. }
  6470. /*==========================================
  6471. * call choosen homunculus [orn]
  6472. *------------------------------------------*/
  6473. ACMD_FUNC(makehomun)
  6474. {
  6475. int homunid;
  6476. nullpo_retr(-1, sd);
  6477. if ( sd->status.hom_id ) {
  6478. clif_displaymessage(fd, msg_txt(sd,450)); // You already have a homunculus
  6479. return -1;
  6480. }
  6481. if (!message || !*message) {
  6482. clif_displaymessage(fd, msg_txt(sd,1256)); // Please enter a homunculus ID (usage: @makehomun <homunculus id>).
  6483. return -1;
  6484. }
  6485. homunid = atoi(message);
  6486. if( homunid < HM_CLASS_BASE || homunid > HM_CLASS_BASE + MAX_HOMUNCULUS_CLASS - 1 )
  6487. {
  6488. clif_displaymessage(fd, msg_txt(sd,1257)); // Invalid Homunculus ID.
  6489. return -1;
  6490. }
  6491. hom_create_request(sd,homunid);
  6492. return 0;
  6493. }
  6494. /*==========================================
  6495. * modify homunculus intimacy [orn]
  6496. *------------------------------------------*/
  6497. ACMD_FUNC(homfriendly)
  6498. {
  6499. int friendly = 0;
  6500. nullpo_retr(-1, sd);
  6501. if ( !hom_is_active(sd->hd) ) {
  6502. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6503. return -1;
  6504. }
  6505. if (!message || !*message) {
  6506. clif_displaymessage(fd, msg_txt(sd,1258)); // Please enter a friendly value (usage: @homfriendly <friendly value [0-1000]>).
  6507. return -1;
  6508. }
  6509. friendly = atoi(message);
  6510. friendly = cap_value(friendly, 0, 1000);
  6511. sd->hd->homunculus.intimacy = friendly * 100 ;
  6512. clif_send_homdata(sd,SP_INTIMATE,friendly);
  6513. return 0;
  6514. }
  6515. /*==========================================
  6516. * modify homunculus hunger [orn]
  6517. *------------------------------------------*/
  6518. ACMD_FUNC(homhungry)
  6519. {
  6520. int hungry = 0;
  6521. nullpo_retr(-1, sd);
  6522. if ( !hom_is_active(sd->hd) ) {
  6523. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6524. return -1;
  6525. }
  6526. if (!message || !*message) {
  6527. clif_displaymessage(fd, msg_txt(sd,1259)); // Please enter a hunger value (usage: @homhungry <hunger value [0-100]>).
  6528. return -1;
  6529. }
  6530. hungry = atoi(message);
  6531. hungry = cap_value(hungry, 0, 100);
  6532. sd->hd->homunculus.hunger = hungry;
  6533. clif_send_homdata(sd,SP_HUNGRY,hungry);
  6534. return 0;
  6535. }
  6536. /*==========================================
  6537. * make the homunculus speak [orn]
  6538. *------------------------------------------*/
  6539. ACMD_FUNC(homtalk)
  6540. {
  6541. char mes[100],temp[CHAT_SIZE_MAX];
  6542. nullpo_retr(-1, sd);
  6543. if ( battle_config.min_chat_delay ) {
  6544. if( DIFF_TICK(sd->cantalk_tick, gettick()) > 0 )
  6545. return 0;
  6546. sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
  6547. }
  6548. if (sd->sc.cant.chat || (sd->state.block_action & PCBLOCK_CHAT))
  6549. return -1; //no "chatting" while muted.
  6550. if ( !hom_is_active(sd->hd) ) {
  6551. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6552. return -1;
  6553. }
  6554. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  6555. clif_displaymessage(fd, msg_txt(sd,1260)); // Please enter a message (usage: @homtalk <message>).
  6556. return -1;
  6557. }
  6558. snprintf(temp, sizeof temp ,"%s : %s", sd->hd->homunculus.name, mes);
  6559. clif_disp_overhead(&sd->hd->bl, temp);
  6560. return 0;
  6561. }
  6562. /*==========================================
  6563. * Show homunculus stats
  6564. *------------------------------------------*/
  6565. ACMD_FUNC(hominfo)
  6566. {
  6567. struct homun_data *hd;
  6568. struct status_data *status;
  6569. nullpo_retr(-1, sd);
  6570. if ( !hom_is_active(sd->hd) ) {
  6571. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6572. return -1;
  6573. }
  6574. hd = sd->hd;
  6575. status = status_get_status_data(&hd->bl);
  6576. clif_displaymessage(fd, msg_txt(sd,1261)); // Homunculus stats:
  6577. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1262), // HP: %d/%d - SP: %d/%d
  6578. status->hp, status->max_hp, status->sp, status->max_sp);
  6579. clif_displaymessage(fd, atcmd_output);
  6580. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1263), // ATK: %d - MATK: %d~%d
  6581. status->rhw.atk2 +status->batk, status->matk_min, status->matk_max);
  6582. clif_displaymessage(fd, atcmd_output);
  6583. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1264), // Hungry: %d - Intimacy: %u
  6584. hd->homunculus.hunger, hd->homunculus.intimacy/100);
  6585. clif_displaymessage(fd, atcmd_output);
  6586. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6587. msg_txt(sd,1265), // Stats: Str %d / Agi %d / Vit %d / Int %d / Dex %d / Luk %d
  6588. status->str, status->agi, status->vit,
  6589. status->int_, status->dex, status->luk);
  6590. clif_displaymessage(fd, atcmd_output);
  6591. return 0;
  6592. }
  6593. ACMD_FUNC(homstats)
  6594. {
  6595. struct homun_data *hd;
  6596. struct s_homunculus_db *db;
  6597. struct s_homunculus *hom;
  6598. int lv, min, max, evo;
  6599. nullpo_retr(-1, sd);
  6600. if ( !hom_is_active(sd->hd) ) {
  6601. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6602. return -1;
  6603. }
  6604. hd = sd->hd;
  6605. hom = &hd->homunculus;
  6606. db = hd->homunculusDB;
  6607. lv = hom->level;
  6608. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6609. msg_txt(sd,1266), lv, db->name); // Homunculus growth stats (Lv %d %s):
  6610. clif_displaymessage(fd, atcmd_output);
  6611. lv--; //Since the first increase is at level 2.
  6612. evo = (hom->class_ == db->evo_class);
  6613. min = db->base.HP +lv*db->gmin.HP +(evo?db->emin.HP:0);
  6614. max = db->base.HP +lv*db->gmax.HP +(evo?db->emax.HP:0);;
  6615. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1267), hom->max_hp, min, max); // Max HP: %d (%d~%d)
  6616. clif_displaymessage(fd, atcmd_output);
  6617. min = db->base.SP +lv*db->gmin.SP +(evo?db->emin.SP:0);
  6618. max = db->base.SP +lv*db->gmax.SP +(evo?db->emax.SP:0);;
  6619. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1268), hom->max_sp, min, max); // Max SP: %d (%d~%d)
  6620. clif_displaymessage(fd, atcmd_output);
  6621. min = db->base.str +lv*(db->gmin.str/10) +(evo?db->emin.str:0);
  6622. max = db->base.str +lv*(db->gmax.str/10) +(evo?db->emax.str:0);;
  6623. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1269), hom->str/10, min, max); // Str: %d (%d~%d)
  6624. clif_displaymessage(fd, atcmd_output);
  6625. min = db->base.agi +lv*(db->gmin.agi/10) +(evo?db->emin.agi:0);
  6626. max = db->base.agi +lv*(db->gmax.agi/10) +(evo?db->emax.agi:0);;
  6627. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1270), hom->agi/10, min, max); // Agi: %d (%d~%d)
  6628. clif_displaymessage(fd, atcmd_output);
  6629. min = db->base.vit +lv*(db->gmin.vit/10) +(evo?db->emin.vit:0);
  6630. max = db->base.vit +lv*(db->gmax.vit/10) +(evo?db->emax.vit:0);;
  6631. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1271), hom->vit/10, min, max); // Vit: %d (%d~%d)
  6632. clif_displaymessage(fd, atcmd_output);
  6633. min = db->base.int_ +lv*(db->gmin.int_/10) +(evo?db->emin.int_:0);
  6634. max = db->base.int_ +lv*(db->gmax.int_/10) +(evo?db->emax.int_:0);;
  6635. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1272), hom->int_/10, min, max); // Int: %d (%d~%d)
  6636. clif_displaymessage(fd, atcmd_output);
  6637. min = db->base.dex +lv*(db->gmin.dex/10) +(evo?db->emin.dex:0);
  6638. max = db->base.dex +lv*(db->gmax.dex/10) +(evo?db->emax.dex:0);;
  6639. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1273), hom->dex/10, min, max); // Dex: %d (%d~%d)
  6640. clif_displaymessage(fd, atcmd_output);
  6641. min = db->base.luk +lv*(db->gmin.luk/10) +(evo?db->emin.luk:0);
  6642. max = db->base.luk +lv*(db->gmax.luk/10) +(evo?db->emax.luk:0);;
  6643. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1274), hom->luk/10, min, max); // Luk: %d (%d~%d)
  6644. clif_displaymessage(fd, atcmd_output);
  6645. return 0;
  6646. }
  6647. ACMD_FUNC(homshuffle)
  6648. {
  6649. nullpo_retr(-1, sd);
  6650. if(!sd->hd)
  6651. return -1; // nothing to do
  6652. if(!hom_shuffle(sd->hd))
  6653. return -1;
  6654. clif_displaymessage(sd->fd, msg_txt(sd,1275)); // Homunculus stats altered.
  6655. atcommand_homstats(fd, sd, command, message); //Print out the new stats
  6656. return 0;
  6657. }
  6658. /*==========================================
  6659. * Show Items DB Info v 1.0
  6660. * originally by [Lupus]
  6661. *------------------------------------------*/
  6662. ACMD_FUNC(iteminfo)
  6663. {
  6664. struct item_data *item_array[MAX_SEARCH];
  6665. int i, count = 1;
  6666. if (!message || !*message) {
  6667. clif_displaymessage(fd, msg_txt(sd,1276)); // Please enter an item name/ID (usage: @ii/@iteminfo <item name/ID>).
  6668. return -1;
  6669. }
  6670. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  6671. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  6672. if (!count) {
  6673. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  6674. return -1;
  6675. }
  6676. if (count == MAX_SEARCH) {
  6677. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH); // Displaying first %d matches
  6678. clif_displaymessage(fd, atcmd_output);
  6679. }
  6680. for (i = 0; i < count; i++) {
  6681. struct item_data * item_data = item_array[i];
  6682. sprintf(atcmd_output, msg_txt(sd,1277), // Item: '%s'/'%s'[%d] (%hu) Type: %s | Extra Effect: %s
  6683. item_data->name,item_data->jname,item_data->slot,item_data->nameid,
  6684. (item_data->type != IT_AMMO) ? itemdb_typename((enum item_types)item_data->type) : itemdb_typename_ammo((enum e_item_ammo)item_data->look),
  6685. (item_data->script==NULL)? msg_txt(sd,1278) : msg_txt(sd,1279) // None / With script
  6686. );
  6687. clif_displaymessage(fd, atcmd_output);
  6688. 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
  6689. clif_displaymessage(fd, atcmd_output);
  6690. if (item_data->maxchance == -1) {
  6691. strcpy(atcmd_output, msg_txt(sd,1281)); // - Available in the shops only.
  6692. clif_displaymessage(fd, atcmd_output);
  6693. }
  6694. else if (!battle_config.atcommand_mobinfo_type) {
  6695. if (item_data->maxchance)
  6696. sprintf(atcmd_output, msg_txt(sd,1282), (float)item_data->maxchance / 100 ); // - Maximal monsters drop chance: %02.02f%%
  6697. else
  6698. strcpy(atcmd_output, msg_txt(sd,1283)); // - Monsters don't drop this item.
  6699. clif_displaymessage(fd, atcmd_output);
  6700. }
  6701. }
  6702. return 0;
  6703. }
  6704. /*==========================================
  6705. * Show who drops the item.
  6706. *------------------------------------------*/
  6707. ACMD_FUNC(whodrops)
  6708. {
  6709. struct item_data *item_data, *item_array[MAX_SEARCH];
  6710. int i,j, count = 1;
  6711. if (!message || !*message) {
  6712. clif_displaymessage(fd, msg_txt(sd,1284)); // Please enter item name/ID (usage: @whodrops <item name/ID>).
  6713. return -1;
  6714. }
  6715. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  6716. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  6717. if (!count) {
  6718. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  6719. return -1;
  6720. }
  6721. if (count == MAX_SEARCH) {
  6722. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH); // Displaying first %d matches
  6723. clif_displaymessage(fd, atcmd_output);
  6724. }
  6725. for (i = 0; i < count; i++) {
  6726. item_data = item_array[i];
  6727. sprintf(atcmd_output, msg_txt(sd,1285), item_data->jname, item_data->slot, item_data->nameid); // Item: '%s'[%d] (ID:%hu)
  6728. clif_displaymessage(fd, atcmd_output);
  6729. if (item_data->mob[0].chance == 0) {
  6730. strcpy(atcmd_output, msg_txt(sd,1286)); // - Item is not dropped by mobs.
  6731. clif_displaymessage(fd, atcmd_output);
  6732. } else {
  6733. sprintf(atcmd_output, msg_txt(sd,1287), MAX_SEARCH); // - Common mobs with highest drop chance (only max %d are listed):
  6734. clif_displaymessage(fd, atcmd_output);
  6735. for (j=0; j < MAX_SEARCH && item_data->mob[j].chance > 0; j++)
  6736. {
  6737. int dropchance = item_data->mob[j].chance;
  6738. #ifdef RENEWAL_DROP
  6739. if( battle_config.atcommand_mobinfo_type )
  6740. dropchance = dropchance * pc_level_penalty_mod(mob_db(item_data->mob[j].id)->lv - sd->status.base_level, mob_db(item_data->mob[j].id)->status.class_, mob_db(item_data->mob[j].id)->status.mode, 2) / 100;
  6741. #endif
  6742. if (pc_isvip(sd)) // Display item rate increase for VIP
  6743. dropchance += (dropchance * battle_config.vip_drop_increase) / 100;
  6744. sprintf(atcmd_output, "- %s (%d): %02.02f%%", mob_db(item_data->mob[j].id)->jname, item_data->mob[j].id, dropchance/100.);
  6745. clif_displaymessage(fd, atcmd_output);
  6746. }
  6747. }
  6748. }
  6749. return 0;
  6750. }
  6751. ACMD_FUNC(whereis)
  6752. {
  6753. uint16 mob_ids[MAX_SEARCH] = {0};
  6754. int count = 0;
  6755. if (!message || !*message) {
  6756. clif_displaymessage(fd, msg_txt(sd,1288)); // Please enter a monster name/ID (usage: @whereis <monster_name_or_monster_ID>).
  6757. return -1;
  6758. }
  6759. int i_message = atoi(message);
  6760. if (mobdb_checkid(i_message)) {
  6761. // ID given
  6762. mob_ids[0] = i_message;
  6763. count = 1;
  6764. } else {
  6765. // Name given, get all monster associated whith this name
  6766. count = mobdb_searchname_array(message, mob_ids, MAX_SEARCH);
  6767. }
  6768. if (count <= 0) {
  6769. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  6770. return -1;
  6771. }
  6772. if (count >= MAX_SEARCH) {
  6773. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH); // Displaying first %d matches
  6774. clif_displaymessage(fd, atcmd_output);
  6775. count = MAX_SEARCH;
  6776. }
  6777. for (int i = 0; i < count; i++) {
  6778. uint16 mob_id = mob_ids[i];
  6779. struct mob_db * mob = mob_db(mob_id);
  6780. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1289), mob->jname); // %s spawns in:
  6781. clif_displaymessage(fd, atcmd_output);
  6782. const std::vector<spawn_info> spawns = mob_get_spawns(mob_id);
  6783. if (spawns.size() <= 0) {
  6784. // This monster does not spawn normally.
  6785. clif_displaymessage(fd, msg_txt(sd,1290));
  6786. } else {
  6787. for(auto& spawn : spawns)
  6788. {
  6789. int16 mapid = map_mapindex2mapid(spawn.mapindex);
  6790. if (mapid < 0)
  6791. continue;
  6792. snprintf(atcmd_output, sizeof atcmd_output, "%s (%d)", map_getmapdata(mapid)->name, spawn.qty);
  6793. clif_displaymessage(fd, atcmd_output);
  6794. }
  6795. }
  6796. }
  6797. return 0;
  6798. }
  6799. ACMD_FUNC(version)
  6800. {
  6801. pc_show_version(sd);
  6802. return 0;
  6803. }
  6804. /*==========================================
  6805. * @mutearea by MouseJstr
  6806. *------------------------------------------*/
  6807. static int atcommand_mutearea_sub(struct block_list *bl,va_list ap)
  6808. {
  6809. int time, id;
  6810. struct map_session_data *pl_sd = (struct map_session_data *)bl;
  6811. if (pl_sd == NULL)
  6812. return 0;
  6813. id = va_arg(ap, int);
  6814. time = va_arg(ap, int);
  6815. if (id != bl->id && !pc_get_group_level(pl_sd)) {
  6816. pl_sd->status.manner -= time;
  6817. if (pl_sd->status.manner < 0)
  6818. sc_start(NULL,&pl_sd->bl,SC_NOCHAT,100,0,0);
  6819. else
  6820. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  6821. }
  6822. return 0;
  6823. }
  6824. ACMD_FUNC(mutearea)
  6825. {
  6826. int time;
  6827. nullpo_ret(sd);
  6828. if (!message || !*message) {
  6829. clif_displaymessage(fd, msg_txt(sd,1297)); // Please enter a time in minutes (usage: @mutearea/@stfu <time in minutes>).
  6830. return -1;
  6831. }
  6832. time = atoi(message);
  6833. map_foreachinallarea(atcommand_mutearea_sub,sd->bl.m,
  6834. sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE,
  6835. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time);
  6836. return 0;
  6837. }
  6838. ACMD_FUNC(rates)
  6839. {
  6840. char buf[CHAT_SIZE_MAX];
  6841. nullpo_ret(sd);
  6842. memset(buf, '\0', sizeof(buf));
  6843. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1298), // Experience rates: Base %.2fx / Job %.2fx
  6844. (battle_config.base_exp_rate + (pc_isvip(sd) ? (battle_config.vip_base_exp_increase * battle_config.base_exp_rate) / 100 : 0)) / 100.,
  6845. (battle_config.job_exp_rate + (pc_isvip(sd) ? (battle_config.vip_job_exp_increase * battle_config.job_exp_rate) / 100 : 0)) / 100.);
  6846. clif_displaymessage(fd, buf);
  6847. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1299), // Normal Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  6848. (battle_config.item_rate_common + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_common) / 100 : 0)) / 100.,
  6849. (battle_config.item_rate_heal + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_heal) / 100 : 0)) / 100.,
  6850. (battle_config.item_rate_use + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_use) / 100 : 0)) / 100.,
  6851. (battle_config.item_rate_equip + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_equip) / 100 : 0)) / 100.,
  6852. (battle_config.item_rate_card + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_card) / 100 : 0)) / 100.);
  6853. clif_displaymessage(fd, buf);
  6854. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1300), // Boss Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  6855. (battle_config.item_rate_common_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_common_boss) / 100 : 0)) / 100.,
  6856. (battle_config.item_rate_heal_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_heal_boss) / 100 : 0)) / 100.,
  6857. (battle_config.item_rate_use_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_use_boss) / 100 : 0)) / 100.,
  6858. (battle_config.item_rate_equip_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_equip_boss) / 100 : 0)) / 100.,
  6859. (battle_config.item_rate_card_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_card_boss) / 100 : 0)) / 100.);
  6860. clif_displaymessage(fd, buf);
  6861. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1024), // MVP Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  6862. (battle_config.item_rate_common_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_common_mvp) / 100 : 0)) / 100.,
  6863. (battle_config.item_rate_heal_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_heal_mvp) / 100 : 0)) / 100.,
  6864. (battle_config.item_rate_use_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_use_mvp) / 100 : 0)) / 100.,
  6865. (battle_config.item_rate_equip_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_equip_mvp) / 100 : 0)) / 100.,
  6866. (battle_config.item_rate_card_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_card_mvp) / 100 : 0)) / 100.);
  6867. clif_displaymessage(fd, buf);
  6868. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1301), // Other Drop Rates: MvP %.2fx / Card-Based %.2fx / Treasure %.2fx
  6869. (battle_config.item_rate_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_mvp) / 100 : 0)) / 100.,
  6870. (battle_config.item_rate_adddrop + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_adddrop) / 100 : 0)) / 100.,
  6871. (battle_config.item_rate_treasure + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_treasure) / 100 : 0)) / 100.);
  6872. clif_displaymessage(fd, buf);
  6873. return 0;
  6874. }
  6875. /*==========================================
  6876. * @me by lordalfa
  6877. * => Displays the OUTPUT string on top of the Visible players Heads.
  6878. *------------------------------------------*/
  6879. ACMD_FUNC(me)
  6880. {
  6881. char tempmes[CHAT_SIZE_MAX];
  6882. nullpo_retr(-1, sd);
  6883. memset(tempmes, '\0', sizeof(tempmes));
  6884. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6885. if (sd->sc.cant.chat || (sd->state.block_action & PCBLOCK_CHAT))
  6886. return -1; //no "chatting" while muted.
  6887. if (!message || !*message || sscanf(message, "%255[^\n]", tempmes) < 0) {
  6888. clif_displaymessage(fd, msg_txt(sd,1302)); // Please enter a message (usage: @me <message>).
  6889. return -1;
  6890. }
  6891. sprintf(atcmd_output, msg_txt(sd,270), sd->status.name, tempmes); // *%s %s*
  6892. clif_disp_overhead(&sd->bl, atcmd_output);
  6893. return 0;
  6894. }
  6895. /*==========================================
  6896. * @size
  6897. * => Resize your character sprite. [Valaris]
  6898. *------------------------------------------*/
  6899. ACMD_FUNC(size)
  6900. {
  6901. int size = SZ_SMALL;
  6902. nullpo_retr(-1, sd);
  6903. size = cap_value(atoi(message),SZ_SMALL,SZ_BIG);
  6904. if(sd->state.size) {
  6905. sd->state.size = SZ_SMALL;
  6906. pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_TELEPORT);
  6907. }
  6908. sd->state.size = size;
  6909. if( size == SZ_MEDIUM )
  6910. clif_specialeffect(&sd->bl,EF_BABYBODY,AREA);
  6911. else if( size == SZ_BIG )
  6912. clif_specialeffect(&sd->bl,EF_GIANTBODY,AREA);
  6913. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  6914. return 0;
  6915. }
  6916. ACMD_FUNC(sizeall)
  6917. {
  6918. int size;
  6919. struct map_session_data *pl_sd;
  6920. struct s_mapiterator* iter;
  6921. size = atoi(message);
  6922. size = cap_value(size,SZ_SMALL,SZ_BIG);
  6923. iter = mapit_getallusers();
  6924. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) {
  6925. if( pl_sd->state.size != size ) {
  6926. if( pl_sd->state.size ) {
  6927. pl_sd->state.size = SZ_SMALL;
  6928. pc_setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  6929. }
  6930. pl_sd->state.size = size;
  6931. if( size == SZ_MEDIUM )
  6932. clif_specialeffect(&pl_sd->bl,EF_BABYBODY,AREA);
  6933. else if( size == SZ_BIG )
  6934. clif_specialeffect(&pl_sd->bl,EF_GIANTBODY,AREA);
  6935. }
  6936. }
  6937. mapit_free(iter);
  6938. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  6939. return 0;
  6940. }
  6941. ACMD_FUNC(sizeguild)
  6942. {
  6943. int size = SZ_SMALL, i;
  6944. char guild[NAME_LENGTH];
  6945. struct map_session_data *pl_sd;
  6946. struct guild *g;
  6947. nullpo_retr(-1, sd);
  6948. memset(guild, '\0', sizeof(guild));
  6949. if( !message || !*message || sscanf(message, "%11d %23[^\n]", &size, guild) < 2 ) {
  6950. clif_displaymessage(fd, msg_txt(sd,1304)); // Please enter guild name/ID (usage: @sizeguild <size> <guild name/ID>).
  6951. return -1;
  6952. }
  6953. if( (g = guild_searchname(guild)) == NULL && (g = guild_search(atoi(guild))) == NULL ) {
  6954. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  6955. return -1;
  6956. }
  6957. size = cap_value(size,SZ_SMALL,SZ_BIG);
  6958. for( i = 0; i < g->max_member; i++ ) {
  6959. if( (pl_sd = g->member[i].sd) && pl_sd->state.size != size ) {
  6960. if( pl_sd->state.size ) {
  6961. pl_sd->state.size = SZ_SMALL;
  6962. pc_setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  6963. }
  6964. pl_sd->state.size = size;
  6965. if( size == SZ_MEDIUM )
  6966. clif_specialeffect(&pl_sd->bl,EF_BABYBODY,AREA);
  6967. else if( size == SZ_BIG )
  6968. clif_specialeffect(&pl_sd->bl,EF_GIANTBODY,AREA);
  6969. }
  6970. }
  6971. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  6972. return 0;
  6973. }
  6974. /*==========================================
  6975. * @monsterignore
  6976. * => Makes monsters ignore you. [Valaris]
  6977. *------------------------------------------*/
  6978. ACMD_FUNC(monsterignore)
  6979. {
  6980. nullpo_retr(-1, sd);
  6981. if (sd->state.block_action & PCBLOCK_IMMUNE) {
  6982. sd->state.block_action &= ~PCBLOCK_IMMUNE;
  6983. clif_displaymessage(sd->fd, msg_txt(sd,1306)); // Returned to normal state.
  6984. } else {
  6985. sd->state.block_action |= PCBLOCK_IMMUNE;
  6986. clif_displaymessage(sd->fd, msg_txt(sd,1305)); // You are now immune to attacks.
  6987. }
  6988. return 0;
  6989. }
  6990. /*==========================================
  6991. * @fakename
  6992. * => Gives your character a fake name. [Valaris]
  6993. *------------------------------------------*/
  6994. ACMD_FUNC(fakename)
  6995. {
  6996. nullpo_retr(-1, sd);
  6997. if( !message || !*message )
  6998. {
  6999. if( sd->fakename[0] )
  7000. {
  7001. sd->fakename[0] = '\0';
  7002. clif_name_area(&sd->bl);
  7003. if (sd->disguise)
  7004. clif_name_self(&sd->bl);
  7005. clif_displaymessage(sd->fd, msg_txt(sd,1307)); // Returned to real name.
  7006. return 0;
  7007. }
  7008. clif_displaymessage(sd->fd, msg_txt(sd,1308)); // You must enter a name.
  7009. return -1;
  7010. }
  7011. if( strlen(message) < 2 )
  7012. {
  7013. clif_displaymessage(sd->fd, msg_txt(sd,1309)); // Fake name must be at least two characters.
  7014. return -1;
  7015. }
  7016. safestrncpy(sd->fakename, message, sizeof(sd->fakename));
  7017. clif_name_area(&sd->bl);
  7018. if (sd->disguise) // Another packet should be sent so the client updates the name for sd
  7019. clif_name_self(&sd->bl);
  7020. clif_displaymessage(sd->fd, msg_txt(sd,1310)); // Fake name enabled.
  7021. return 0;
  7022. }
  7023. /*==========================================
  7024. * Ragnarok Resources
  7025. *------------------------------------------*/
  7026. ACMD_FUNC(mapflag) {
  7027. char flag_name[50];
  7028. short flag = 0, i, j;
  7029. std::string buf;
  7030. nullpo_retr(-1, sd);
  7031. memset(flag_name, '\0', sizeof(flag_name));
  7032. if (!message || !*message || (sscanf(message, "%49s %6hd", flag_name, &flag) < 1)) {
  7033. clif_displaymessage(sd->fd,msg_txt(sd,1311)); // Enabled Mapflags in this map:
  7034. clif_displaymessage(sd->fd,"----------------------------------");
  7035. for( i = MF_MIN; i < MF_MAX; i++ ){
  7036. union u_mapflag_args args = {};
  7037. if( map_getmapflag_name(static_cast<e_mapflag>(i), flag_name) && map_getmapflag_sub( sd->bl.m, static_cast<e_mapflag>(i), &args ) ){
  7038. clif_displaymessage(sd->fd, flag_name);
  7039. }
  7040. }
  7041. clif_displaymessage(sd->fd," ");
  7042. clif_displaymessage(sd->fd,msg_txt(sd,1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On)
  7043. clif_displaymessage(sd->fd,msg_txt(sd,1313)); // Type "@mapflag available" to list the available mapflags.
  7044. return 1;
  7045. }
  7046. // Check if the list of mapflags was requested
  7047. if( strcasecmp(flag_name,"available") ){
  7048. for (i = 0; flag_name[i]; i++) flag_name[i] = (char)tolower(flag_name[i]); //lowercase
  7049. enum e_mapflag mapflag = map_getmapflag_by_name(flag_name);
  7050. if( mapflag != MF_INVALID ){
  7051. std::vector<e_mapflag> disabled_mf = { MF_NOSAVE,
  7052. MF_PVP_NIGHTMAREDROP,
  7053. MF_RESTRICTED,
  7054. MF_NOCOMMAND,
  7055. MF_BEXP,
  7056. MF_JEXP,
  7057. MF_BATTLEGROUND,
  7058. MF_SKILL_DAMAGE,
  7059. MF_SKILL_DURATION };
  7060. if (flag && std::find(disabled_mf.begin(), disabled_mf.end(), mapflag) != disabled_mf.end()) {
  7061. sprintf(atcmd_output,"[ @mapflag ] %s flag cannot be enabled as it requires unique values.", flag_name);
  7062. clif_displaymessage(sd->fd,atcmd_output);
  7063. } else {
  7064. map_setmapflag(sd->bl.m, mapflag, flag != 0);
  7065. sprintf(atcmd_output,"[ @mapflag ] %s flag has been set to %s value = %hd",flag_name,flag?"On":"Off",flag);
  7066. clif_displaymessage(sd->fd,atcmd_output);
  7067. }
  7068. return 0;
  7069. }else{
  7070. clif_displaymessage(sd->fd, msg_txt(sd, 1314)); // Invalid flag name or flag.
  7071. clif_displaymessage(sd->fd, msg_txt(sd, 1313)); // Type "@mapflag available" to list the available mapflags.
  7072. return 1;
  7073. }
  7074. }
  7075. clif_displaymessage(sd->fd,msg_txt(sd,1315)); // Available Flags:
  7076. clif_displaymessage(sd->fd,"----------------------------------");
  7077. for( i = MF_MIN, j = 0; i < MF_MAX; i++ ){
  7078. if( map_getmapflag_name( static_cast<e_mapflag>(i), flag_name ) ){
  7079. buf.append(flag_name);
  7080. if( (i + 1) < MF_MAX )
  7081. buf.append(", ");
  7082. j++;
  7083. }
  7084. if( i > MF_MIN && ( j == 6 || ( i + 1 ) == MF_MAX ) ){
  7085. clif_displaymessage(sd->fd, buf.c_str() );
  7086. buf.clear();
  7087. j = 0;
  7088. }
  7089. }
  7090. clif_displaymessage(sd->fd, msg_txt(sd, 1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On)
  7091. return 0;
  7092. }
  7093. /*===================================
  7094. * Remove some messages
  7095. *-----------------------------------*/
  7096. ACMD_FUNC(showexp)
  7097. {
  7098. if (sd->state.showexp) {
  7099. sd->state.showexp = 0;
  7100. clif_displaymessage(fd, msg_txt(sd,1316)); // Gained exp will not be shown.
  7101. return 0;
  7102. }
  7103. sd->state.showexp = 1;
  7104. clif_displaymessage(fd, msg_txt(sd,1317)); // Gained exp is now shown.
  7105. return 0;
  7106. }
  7107. ACMD_FUNC(showzeny)
  7108. {
  7109. if (sd->state.showzeny) {
  7110. sd->state.showzeny = 0;
  7111. clif_displaymessage(fd, msg_txt(sd,1318)); // Gained zeny will not be shown.
  7112. return 0;
  7113. }
  7114. sd->state.showzeny = 1;
  7115. clif_displaymessage(fd, msg_txt(sd,1319)); // Gained zeny is now shown.
  7116. return 0;
  7117. }
  7118. ACMD_FUNC(showdelay)
  7119. {
  7120. if (sd->state.showdelay) {
  7121. sd->state.showdelay = 0;
  7122. clif_displaymessage(fd, msg_txt(sd,1320)); // Skill delay failures will not be shown.
  7123. return 0;
  7124. }
  7125. sd->state.showdelay = 1;
  7126. clif_displaymessage(fd, msg_txt(sd,1321)); // Skill delay failures are now shown.
  7127. return 0;
  7128. }
  7129. /*==========================================
  7130. * Duel organizing functions [LuzZza]
  7131. *
  7132. * @duel [limit|nick] - create a duel
  7133. * @invite <nick> - invite player
  7134. * @accept - accept invitation
  7135. * @reject - reject invitation
  7136. * @leave - leave duel
  7137. *------------------------------------------*/
  7138. ACMD_FUNC(invite)
  7139. {
  7140. unsigned int did = sd->duel_group;
  7141. struct map_session_data *target_sd = NULL;
  7142. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7143. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7144. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  7145. sprintf(atcmd_output, msg_txt(sd, 435), command); // Please enter a player name (usage: %s <char name>).
  7146. clif_displaymessage(fd, atcmd_output);
  7147. return -1;
  7148. }
  7149. if(did == 0 || !duel_exist(did) ) {
  7150. clif_displaymessage(fd, msg_txt(sd,350)); // "Duel: @invite without @duel."
  7151. return 0;
  7152. }
  7153. if( !duel_check_player_limit( duel_get_duelid(did) ) ){
  7154. clif_displaymessage(fd, msg_txt(sd,351)); // "Duel: Limit of players is reached."
  7155. return 0;
  7156. }
  7157. if((target_sd = map_nick2sd(atcmd_player_name, true)) == NULL) {
  7158. clif_displaymessage(fd, msg_txt(sd,352)); // "Duel: Player not found."
  7159. return 0;
  7160. }
  7161. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  7162. clif_displaymessage(fd, msg_txt(sd,353)); // "Duel: Player already in duel."
  7163. return 0;
  7164. }
  7165. if(battle_config.duel_only_on_same_map && target_sd->bl.m != sd->bl.m)
  7166. {
  7167. 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.
  7168. clif_displaymessage(fd, atcmd_output);
  7169. return 0;
  7170. }
  7171. duel_invite(did, sd, target_sd);
  7172. clif_displaymessage(fd, msg_txt(sd,354)); // "Duel: Invitation has been sent."
  7173. return 0;
  7174. }
  7175. ACMD_FUNC(duel)
  7176. {
  7177. unsigned int maxpl = 0;
  7178. if(sd->duel_group > 0) {
  7179. duel_showinfo(sd->duel_group, sd);
  7180. return 0;
  7181. }
  7182. if(sd->duel_invite > 0) {
  7183. clif_displaymessage(fd, msg_txt(sd,355)); // "Duel: @duel without @reject."
  7184. return 0;
  7185. }
  7186. if(!duel_checktime(sd)) {
  7187. char output[CHAT_SIZE_MAX];
  7188. sprintf(output, msg_txt(sd,356), battle_config.duel_time_interval); // "Duel: You can take part in duel only one time per %d minutes."
  7189. clif_displaymessage(fd, output);
  7190. return 0;
  7191. }
  7192. if( message[0] ) {
  7193. if(sscanf(message, "%11u", &maxpl) >= 1) {
  7194. if(maxpl < 2 || maxpl > 65535) {
  7195. clif_displaymessage(fd, msg_txt(sd,357)); // "Duel: Invalid value."
  7196. return 0;
  7197. }
  7198. duel_create(sd, maxpl);
  7199. } else {
  7200. struct map_session_data *target_sd = NULL;
  7201. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7202. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7203. if (sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  7204. sprintf(atcmd_output, msg_txt(sd, 435), command); // Please enter a player name (usage: %s <char name>).
  7205. clif_displaymessage(fd, atcmd_output);
  7206. return -1;
  7207. }
  7208. target_sd = map_nick2sd(atcmd_player_name,true);
  7209. if(target_sd != NULL) {
  7210. unsigned int newduel;
  7211. if((newduel = duel_create(sd, 2)) != -1) {
  7212. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  7213. clif_displaymessage(fd, msg_txt(sd,353)); // "Duel: Player already in duel."
  7214. return 0;
  7215. }
  7216. duel_invite(newduel, sd, target_sd);
  7217. clif_displaymessage(fd, msg_txt(sd,354)); // "Duel: Invitation has been sent."
  7218. }
  7219. } else {
  7220. clif_displaymessage(fd, msg_txt(sd,352)); // "Duel: Player not found."
  7221. return 0;
  7222. }
  7223. }
  7224. } else
  7225. duel_create(sd, 0);
  7226. return 0;
  7227. }
  7228. ACMD_FUNC(leave)
  7229. {
  7230. if(sd->duel_group <= 0) {
  7231. clif_displaymessage(fd, msg_txt(sd,358)); // "Duel: @leave without @duel."
  7232. return 0;
  7233. }
  7234. duel_leave(sd->duel_group, sd);
  7235. clif_displaymessage(fd, msg_txt(sd,359)); // "Duel: You left the duel."
  7236. return 0;
  7237. }
  7238. ACMD_FUNC(accept)
  7239. {
  7240. if(!duel_checktime(sd)) {
  7241. char output[CHAT_SIZE_MAX];
  7242. sprintf(output, msg_txt(sd,356), battle_config.duel_time_interval); // "Duel: You can take part in duel only one time per %d minutes."
  7243. clif_displaymessage(fd, output);
  7244. return 0;
  7245. }
  7246. if(sd->duel_invite <= 0 || !duel_exist(sd->duel_invite) ) {
  7247. clif_displaymessage(fd, msg_txt(sd,360)); // "Duel: @accept without invititation."
  7248. return 0;
  7249. }
  7250. if( !duel_check_player_limit( duel_get_duelid( sd->duel_invite ) ) )
  7251. {
  7252. clif_displaymessage(fd, msg_txt(sd,351)); // "Duel: Limit of players is reached."
  7253. return 0;
  7254. }
  7255. duel_accept(sd->duel_invite, sd);
  7256. clif_displaymessage(fd, msg_txt(sd,361)); // "Duel: Invitation has been accepted."
  7257. return 0;
  7258. }
  7259. ACMD_FUNC(reject)
  7260. {
  7261. if(sd->duel_invite <= 0) {
  7262. clif_displaymessage(fd, msg_txt(sd,362)); // "Duel: @reject without invititation."
  7263. return 0;
  7264. }
  7265. duel_reject(sd->duel_invite, sd);
  7266. clif_displaymessage(fd, msg_txt(sd,363)); // "Duel: Invitation has been rejected."
  7267. return 0;
  7268. }
  7269. /*===================================
  7270. * Cash Points
  7271. *-----------------------------------*/
  7272. ACMD_FUNC(cash)
  7273. {
  7274. char output[128];
  7275. int value;
  7276. int ret=0;
  7277. nullpo_retr(-1, sd);
  7278. // Since there is no cashpoint update packet we need to force updating like this
  7279. if( sd->state.cashshop_open ){
  7280. clif_displaymessage(fd, msg_txt(sd, 1376)); // Please close the cashshop before using this command.
  7281. return -1;
  7282. }
  7283. if( !message || !*message || (value = atoi(message)) == 0 ) {
  7284. clif_displaymessage(fd, msg_txt(sd,1322)); // Please enter an amount.
  7285. return -1;
  7286. }
  7287. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  7288. if( !strcmpi(parent_cmd,"cash") )
  7289. {
  7290. if( value > 0 ) {
  7291. if( (ret=pc_getcash(sd, value, 0, LOG_TYPE_COMMAND)) >= 0){
  7292. // If this option is set, the message is already sent by pc function
  7293. if( !battle_config.cashshop_show_points ){
  7294. sprintf(output, msg_txt(sd,505), ret, sd->cashPoints); // Gained %d cash points. Total %d points.
  7295. clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], output, false, SELF);
  7296. }
  7297. }
  7298. else clif_displaymessage(fd, msg_txt(sd,149)); // Impossible to increase the number/value.
  7299. } else {
  7300. if (-value > sd->cashPoints) //By command, if cash < value, force it to remove all
  7301. value = -sd->cashPoints;
  7302. if( (ret=pc_paycash(sd, -value, 0, LOG_TYPE_COMMAND)) >= 0){
  7303. // If this option is set, the message is already sent by pc function
  7304. if( !battle_config.cashshop_show_points ){
  7305. sprintf(output, msg_txt(sd,410), ret, sd->cashPoints); // Removed %d cash points. Total %d points.
  7306. clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], output, false, SELF);
  7307. }
  7308. }
  7309. else clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  7310. }
  7311. }
  7312. else
  7313. { // @points
  7314. if( value > 0 ) {
  7315. if( (ret=pc_getcash(sd, 0, value, LOG_TYPE_COMMAND)) >= 0){
  7316. sprintf(output, msg_txt(sd,506), ret, sd->kafraPoints); // Gained %d kafra points. Total %d points.
  7317. clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], output, false, SELF);
  7318. }
  7319. else clif_displaymessage(fd, msg_txt(sd,149)); // Impossible to increase the number/value.
  7320. } else {
  7321. if (-value > sd->kafraPoints) //By command, if cash < value, force it to remove all
  7322. value = -sd->kafraPoints;
  7323. if( (ret=pc_paycash(sd, 0, -value, LOG_TYPE_COMMAND)) >= 0){
  7324. sprintf(output, msg_txt(sd,411), ret, sd->kafraPoints); // Removed %d kafra points. Total %d points.
  7325. clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], output, false, SELF);
  7326. }
  7327. else clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  7328. }
  7329. }
  7330. return 0;
  7331. }
  7332. // @clone/@slaveclone/@evilclone <playername> [Valaris]
  7333. ACMD_FUNC(clone)
  7334. {
  7335. int x=0,y=0,flag=0,master=0,i=0;
  7336. struct map_session_data *pl_sd=NULL;
  7337. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7338. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  7339. clif_displaymessage(sd->fd,msg_txt(sd,1323)); // You must enter a player name or ID.
  7340. return 0;
  7341. }
  7342. if((pl_sd=map_nick2sd(atcmd_player_name,true)) == NULL && (pl_sd=map_charid2sd(atoi(atcmd_player_name))) == NULL) {
  7343. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  7344. return 0;
  7345. }
  7346. if(pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  7347. clif_displaymessage(fd, msg_txt(sd,126)); // Cannot clone a player of higher GM level than yourself.
  7348. return 0;
  7349. }
  7350. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  7351. if (strcmpi(parent_cmd, "clone") == 0)
  7352. flag = 1;
  7353. else if (strcmpi(parent_cmd, "slaveclone") == 0) {
  7354. flag = 2;
  7355. if(pc_isdead(sd)){
  7356. clif_displaymessage(fd, msg_txt(sd,129+flag*2));
  7357. return 0;
  7358. }
  7359. master = sd->bl.id;
  7360. if (battle_config.atc_slave_clone_limit
  7361. && mob_countslave(&sd->bl) >= battle_config.atc_slave_clone_limit) {
  7362. clif_displaymessage(fd, msg_txt(sd,127)); // You've reached your slave clones limit.
  7363. return 0;
  7364. }
  7365. }
  7366. do {
  7367. x = sd->bl.x + (rnd() % 10 - 5);
  7368. y = sd->bl.y + (rnd() % 10 - 5);
  7369. } while (map_getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10);
  7370. if (i >= 10) {
  7371. x = sd->bl.x;
  7372. y = sd->bl.y;
  7373. }
  7374. if((x = mob_clone_spawn(pl_sd, sd->bl.m, x, y, "", master, MD_NONE, flag?1:0, 0)) > 0) {
  7375. clif_displaymessage(fd, msg_txt(sd,128+flag*2)); // Evil Clone spawned. Clone spawned. Slave clone spawned.
  7376. return 0;
  7377. }
  7378. clif_displaymessage(fd, msg_txt(sd,129+flag*2)); // Unable to spawn evil clone. Unable to spawn clone. Unable to spawn slave clone.
  7379. return 0;
  7380. }
  7381. /*=====================================
  7382. * Autorejecting Invites/Deals [LuzZza]
  7383. * Usage: @noask
  7384. *-------------------------------------*/
  7385. ACMD_FUNC(noask)
  7386. {
  7387. if(sd->state.noask) {
  7388. clif_displaymessage(fd, msg_txt(sd,391)); // Autorejecting is deactivated.
  7389. sd->state.noask = 0;
  7390. } else {
  7391. clif_displaymessage(fd, msg_txt(sd,390)); // Autorejecting is activated.
  7392. sd->state.noask = 1;
  7393. }
  7394. return 0;
  7395. }
  7396. /*=====================================
  7397. * Send a @request message to all GMs of lowest_gm_level.
  7398. * Usage: @request <petition>
  7399. *-------------------------------------*/
  7400. ACMD_FUNC(request)
  7401. {
  7402. if (!message || !*message) {
  7403. clif_displaymessage(sd->fd,msg_txt(sd,277)); // Usage: @request <petition/message to online GMs>.
  7404. return -1;
  7405. }
  7406. sprintf(atcmd_output, msg_txt(sd,278), message); // (@request): %s
  7407. intif_wis_message_to_gm(sd->status.name, PC_PERM_RECEIVE_REQUESTS, atcmd_output);
  7408. clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], atcmd_output, false, SELF);
  7409. clif_displaymessage(sd->fd,msg_txt(sd,279)); // @request sent.
  7410. return 0;
  7411. }
  7412. /*==========================================
  7413. * Feel (SG save map) Reset [HiddenDragon]
  7414. *------------------------------------------*/
  7415. ACMD_FUNC(feelreset)
  7416. {
  7417. pc_resetfeel(sd);
  7418. clif_displaymessage(fd, msg_txt(sd,1324)); // Reset 'Feeling' maps.
  7419. return 0;
  7420. }
  7421. /*==========================================
  7422. * AUCTION SYSTEM
  7423. *------------------------------------------*/
  7424. ACMD_FUNC(auction)
  7425. {
  7426. nullpo_ret(sd);
  7427. if (!battle_config.feature_auction) {
  7428. clif_messagecolor(&sd->bl, color_table[COLOR_RED], msg_txt(sd, 517), false, SELF);
  7429. return 0;
  7430. }
  7431. clif_Auction_openwindow(sd);
  7432. return 0;
  7433. }
  7434. /*==========================================
  7435. * Kill Steal Protection
  7436. *------------------------------------------*/
  7437. ACMD_FUNC(ksprotection)
  7438. {
  7439. nullpo_retr(-1,sd);
  7440. if( sd->state.noks ) {
  7441. sd->state.noks = 0;
  7442. clif_displaymessage(fd, msg_txt(sd,1325)); // [ K.S Protection Inactive ]
  7443. }
  7444. else
  7445. {
  7446. if( !message || !*message || !strcmpi(message, "party") )
  7447. { // Default is Party
  7448. sd->state.noks = 2;
  7449. clif_displaymessage(fd, msg_txt(sd,1326)); // [ K.S Protection Active - Option: Party ]
  7450. }
  7451. else if( !strcmpi(message, "self") )
  7452. {
  7453. sd->state.noks = 1;
  7454. clif_displaymessage(fd, msg_txt(sd,1327)); // [ K.S Protection Active - Option: Self ]
  7455. }
  7456. else if( !strcmpi(message, "guild") )
  7457. {
  7458. sd->state.noks = 3;
  7459. clif_displaymessage(fd, msg_txt(sd,1328)); // [ K.S Protection Active - Option: Guild ]
  7460. }
  7461. else
  7462. clif_displaymessage(fd, msg_txt(sd,1329)); // Usage: @noks <self|party|guild>
  7463. }
  7464. return 0;
  7465. }
  7466. /*==========================================
  7467. * Map Kill Steal Protection Setting
  7468. *------------------------------------------*/
  7469. ACMD_FUNC(allowks)
  7470. {
  7471. nullpo_retr(-1,sd);
  7472. if( map_getmapflag(sd->bl.m, MF_ALLOWKS) ) {
  7473. map_setmapflag(sd->bl.m, MF_ALLOWKS, false);
  7474. clif_displaymessage(fd, msg_txt(sd,1330)); // [ Map K.S Protection Active ]
  7475. } else {
  7476. map_setmapflag(sd->bl.m, MF_ALLOWKS, true);
  7477. clif_displaymessage(fd, msg_txt(sd,1331)); // [ Map K.S Protection Inactive ]
  7478. }
  7479. return 0;
  7480. }
  7481. ACMD_FUNC(resetstat)
  7482. {
  7483. nullpo_retr(-1, sd);
  7484. pc_resetstate(sd);
  7485. sprintf(atcmd_output, msg_txt(sd,207), sd->status.name); // '%s' stats points reset.
  7486. clif_displaymessage(fd, atcmd_output);
  7487. return 0;
  7488. }
  7489. ACMD_FUNC(resetskill)
  7490. {
  7491. nullpo_retr(-1,sd);
  7492. pc_resetskill(sd,1);
  7493. sprintf(atcmd_output, msg_txt(sd,206), sd->status.name); // '%s' skill points reset.
  7494. clif_displaymessage(fd, atcmd_output);
  7495. return 0;
  7496. }
  7497. /*==========================================
  7498. * #storagelist: Displays the items list of a player's storage.
  7499. * #cartlist: Displays contents of target's cart.
  7500. * #itemlist: Displays contents of target's inventory.
  7501. *------------------------------------------*/
  7502. ACMD_FUNC(itemlist)
  7503. {
  7504. int i, j, count, counter;
  7505. const char* location;
  7506. const struct item* items;
  7507. int size;
  7508. StringBuf buf;
  7509. nullpo_retr(-1, sd);
  7510. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  7511. if( strcmp(parent_cmd, "storagelist") == 0 ) {
  7512. location = "storage";
  7513. items = sd->storage.u.items_storage;
  7514. size = sd->storage.max_amount;
  7515. } else if( strcmp(parent_cmd, "cartlist") == 0 ) {
  7516. location = "cart";
  7517. items = sd->cart.u.items_cart;
  7518. size = MAX_CART;
  7519. } else if( strcmp(parent_cmd, "itemlist") == 0 ) {
  7520. location = "inventory";
  7521. items = sd->inventory.u.items_inventory;
  7522. size = MAX_INVENTORY;
  7523. } else
  7524. return 1;
  7525. StringBuf_Init(&buf);
  7526. count = 0; // total slots occupied
  7527. counter = 0; // total items found
  7528. for( i = 0; i < size; ++i ) {
  7529. const struct item* it = &items[i];
  7530. struct item_data* itd;
  7531. if( it->nameid == 0 || (itd = itemdb_exists(it->nameid)) == NULL )
  7532. continue;
  7533. counter += it->amount;
  7534. count++;
  7535. if( count == 1 ) {
  7536. StringBuf_Printf(&buf, msg_txt(sd,1332), location, sd->status.name); // ------ %s items list of '%s' ------
  7537. clif_displaymessage(fd, StringBuf_Value(&buf));
  7538. StringBuf_Clear(&buf);
  7539. }
  7540. if( it->refine )
  7541. StringBuf_Printf(&buf, "%d %s %+d (%s, id: %d)", it->amount, itd->jname, it->refine, itd->name, it->nameid);
  7542. else
  7543. StringBuf_Printf(&buf, "%d %s (%s, id: %d)", it->amount, itd->jname, itd->name, it->nameid);
  7544. if( it->equip ) {
  7545. char equipstr[CHAT_SIZE_MAX];
  7546. strcpy(equipstr, msg_txt(sd,1333)); // | Equipped:
  7547. if( it->equip&EQP_GARMENT )
  7548. strcat(equipstr, msg_txt(sd,1334)); // Robe,
  7549. if( it->equip&EQP_ACC_L )
  7550. strcat(equipstr, msg_txt(sd,1335)); // Left Accessory,
  7551. if( it->equip&EQP_ARMOR )
  7552. strcat(equipstr, msg_txt(sd,1336)); // Body/Armor,
  7553. if( (it->equip&EQP_ARMS) == EQP_HAND_R )
  7554. strcat(equipstr, msg_txt(sd,1337)); // Right Hand,
  7555. if( (it->equip&EQP_ARMS) == EQP_HAND_L )
  7556. strcat(equipstr, msg_txt(sd,1338)); // Left Hand,
  7557. if( (it->equip&EQP_ARMS) == EQP_ARMS )
  7558. strcat(equipstr, msg_txt(sd,1339)); // Both Hands,
  7559. if( it->equip&EQP_SHOES )
  7560. strcat(equipstr, msg_txt(sd,1340)); // Shoes,
  7561. if( it->equip&EQP_ACC_R )
  7562. strcat(equipstr, msg_txt(sd,1341)); // Right Accessory,
  7563. if( (it->equip&EQP_HELM) == EQP_HEAD_LOW )
  7564. strcat(equipstr, msg_txt(sd,1342)); // Lower Head,
  7565. if( (it->equip&EQP_HELM) == EQP_HEAD_TOP )
  7566. strcat(equipstr, msg_txt(sd,1343)); // Top Head,
  7567. if( (it->equip&EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_TOP) )
  7568. strcat(equipstr, msg_txt(sd,1344)); // Top/Lower Head,
  7569. if( (it->equip&EQP_HELM) == EQP_HEAD_MID )
  7570. strcat(equipstr, msg_txt(sd,1345)); // Mid Head,
  7571. if( (it->equip&EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_MID) )
  7572. strcat(equipstr, msg_txt(sd,1346)); // Mid/Lower Head,
  7573. if( (it->equip&EQP_HELM) == EQP_HELM )
  7574. strcat(equipstr, msg_txt(sd,1347)); // Top/Mid/Lower Head,
  7575. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HEAD_LOW )
  7576. strcat(equipstr, msg_txt(sd,518)); // Lower Costume Head,
  7577. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HEAD_TOP )
  7578. strcat(equipstr, msg_txt(sd,519)); // Top Costume Head,
  7579. if( (it->equip&EQP_COSTUME_HELM) == (EQP_COSTUME_HEAD_LOW|EQP_COSTUME_HEAD_TOP) )
  7580. strcat(equipstr, msg_txt(sd,520)); // Top/Lower Costume Head,
  7581. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HEAD_MID )
  7582. strcat(equipstr, msg_txt(sd,521)); // Mid Costume Head,
  7583. if( (it->equip&EQP_COSTUME_HELM) == (EQP_COSTUME_HEAD_LOW|EQP_COSTUME_HEAD_MID) )
  7584. strcat(equipstr, msg_txt(sd,522)); // Mid/Lower Costume Head,
  7585. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HELM )
  7586. strcat(equipstr, msg_txt(sd,523)); // Top/Mid/Lower Costume Head,
  7587. if( it->equip&EQP_COSTUME_GARMENT )
  7588. strcat(equipstr, msg_txt(sd,524)); // Costume Robe,
  7589. //if( it->equip&EQP_COSTUME_FLOOR )
  7590. //strcat(equipstr, msg_txt(sd,525)); // Costume Floor,
  7591. if( it->equip&EQP_AMMO )
  7592. strcat(equipstr, msg_txt(sd,526)); // Ammo,
  7593. if( it->equip&EQP_SHADOW_ARMOR )
  7594. strcat(equipstr, msg_txt(sd,527)); // Shadow Body,
  7595. if( (it->equip&EQP_SHADOW_ARMS) == EQP_SHADOW_WEAPON )
  7596. strcat(equipstr, msg_txt(sd,528)); // Shadow Right Hand,
  7597. if( (it->equip&EQP_SHADOW_ARMS) == EQP_SHADOW_SHIELD )
  7598. strcat(equipstr, msg_txt(sd,529)); // Shadow Left Hand,
  7599. if( (it->equip&EQP_SHADOW_ARMS) == EQP_SHADOW_ARMS )
  7600. strcat(equipstr, msg_txt(sd,530)); // Shadow Both Hands,
  7601. if( it->equip&EQP_SHADOW_SHOES )
  7602. strcat(equipstr, msg_txt(sd,531)); // Shadow Shoes,
  7603. if( it->equip&EQP_SHADOW_ACC_R )
  7604. strcat(equipstr, msg_txt(sd,532)); // Shadow Right Accessory,
  7605. if( it->equip&EQP_SHADOW_ACC_L )
  7606. strcat(equipstr, msg_txt(sd,533)); // Shadow Left Accessory,
  7607. // remove final ', '
  7608. equipstr[strlen(equipstr) - 2] = '\0';
  7609. StringBuf_AppendStr(&buf, equipstr);
  7610. }
  7611. clif_displaymessage(fd, StringBuf_Value(&buf));
  7612. StringBuf_Clear(&buf);
  7613. if( it->card[0] == CARD0_PET ) { // pet egg
  7614. if (it->card[3]&1)
  7615. StringBuf_Printf(&buf, msg_txt(sd,1348), (unsigned int)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, named)
  7616. else
  7617. StringBuf_Printf(&buf, msg_txt(sd,1349), (unsigned int)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, unnamed)
  7618. } else if(it->card[0] == CARD0_FORGE) { // forged item
  7619. 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)
  7620. } else if(it->card[0] == CARD0_CREATE) { // created item
  7621. StringBuf_Printf(&buf, msg_txt(sd,1351), (unsigned int)MakeDWord(it->card[2], it->card[3])); // -> (produced item, creator id: %u)
  7622. } else { // normal item
  7623. int counter2 = 0;
  7624. for( j = 0; j < itd->slot; ++j ) {
  7625. struct item_data* card;
  7626. if( it->card[j] == 0 || (card = itemdb_exists(it->card[j])) == NULL )
  7627. continue;
  7628. counter2++;
  7629. if( counter2 == 1 )
  7630. StringBuf_AppendStr(&buf, msg_txt(sd,1352)); // -> (card(s):
  7631. if( counter2 != 1 )
  7632. StringBuf_AppendStr(&buf, ", ");
  7633. StringBuf_Printf(&buf, "#%d %s (id: %d)", counter2, card->jname, card->nameid);
  7634. }
  7635. if( counter2 > 0 )
  7636. StringBuf_AppendStr(&buf, ")");
  7637. }
  7638. if( StringBuf_Length(&buf) > 0 )
  7639. clif_displaymessage(fd, StringBuf_Value(&buf));
  7640. StringBuf_Clear(&buf);
  7641. }
  7642. if( count == 0 )
  7643. StringBuf_Printf(&buf, msg_txt(sd,1353), location); // No item found in this player's %s.
  7644. else
  7645. StringBuf_Printf(&buf, msg_txt(sd,1354), counter, count, location); // %d item(s) found in %d %s slots.
  7646. clif_displaymessage(fd, StringBuf_Value(&buf));
  7647. StringBuf_Destroy(&buf);
  7648. return 0;
  7649. }
  7650. ACMD_FUNC(stats)
  7651. {
  7652. char job_jobname[100];
  7653. char output[CHAT_SIZE_MAX];
  7654. int i;
  7655. struct {
  7656. const char* format;
  7657. int value;
  7658. } output_table[] = {
  7659. { "Base Level - %d", 0 },
  7660. { NULL, 0 },
  7661. { "Hp - %d", 0 },
  7662. { "MaxHp - %d", 0 },
  7663. { "Sp - %d", 0 },
  7664. { "MaxSp - %d", 0 },
  7665. { "Str - %3d", 0 },
  7666. { "Agi - %3d", 0 },
  7667. { "Vit - %3d", 0 },
  7668. { "Int - %3d", 0 },
  7669. { "Dex - %3d", 0 },
  7670. { "Luk - %3d", 0 },
  7671. { "Zeny - %d", 0 },
  7672. { "Free SK Points - %d", 0 },
  7673. { "JobChangeLvl (2nd) - %d", 0 },
  7674. { "JobChangeLvl (3rd) - %d", 0 },
  7675. { NULL, 0 }
  7676. };
  7677. memset(job_jobname, '\0', sizeof(job_jobname));
  7678. memset(output, '\0', sizeof(output));
  7679. //direct array initialization with variables is not standard C compliant.
  7680. output_table[0].value = sd->status.base_level;
  7681. output_table[1].format = job_jobname;
  7682. output_table[1].value = sd->status.job_level;
  7683. output_table[2].value = sd->status.hp;
  7684. output_table[3].value = sd->status.max_hp;
  7685. output_table[4].value = sd->status.sp;
  7686. output_table[5].value = sd->status.max_sp;
  7687. output_table[6].value = sd->status.str;
  7688. output_table[7].value = sd->status.agi;
  7689. output_table[8].value = sd->status.vit;
  7690. output_table[9].value = sd->status.int_;
  7691. output_table[10].value = sd->status.dex;
  7692. output_table[11].value = sd->status.luk;
  7693. output_table[12].value = sd->status.zeny;
  7694. output_table[13].value = sd->status.skill_point;
  7695. output_table[14].value = sd->change_level_2nd;
  7696. output_table[15].value = sd->change_level_3rd;
  7697. sprintf(job_jobname, "Job - %s %s", job_name(sd->status.class_), "(level %d)");
  7698. sprintf(output, msg_txt(sd,53), sd->status.name); // '%s' stats:
  7699. clif_displaymessage(fd, output);
  7700. for (i = 0; output_table[i].format != NULL; i++) {
  7701. sprintf(output, output_table[i].format, output_table[i].value);
  7702. clif_displaymessage(fd, output);
  7703. }
  7704. return 0;
  7705. }
  7706. ACMD_FUNC(delitem)
  7707. {
  7708. char item_name[100];
  7709. unsigned short nameid;
  7710. int amount = 0, total, idx;
  7711. struct item_data* id;
  7712. nullpo_retr(-1, sd);
  7713. if( !message || !*message || ( sscanf(message, "\"%99[^\"]\" %11d", item_name, &amount) < 2 && sscanf(message, "%99s %11d", item_name, &amount) < 2 ) || amount < 1 )
  7714. {
  7715. 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>).
  7716. return -1;
  7717. }
  7718. if( ( id = itemdb_searchname(item_name) ) != NULL || ( id = itemdb_exists(atoi(item_name)) ) != NULL )
  7719. {
  7720. nameid = id->nameid;
  7721. }
  7722. else
  7723. {
  7724. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  7725. return -1;
  7726. }
  7727. total = amount;
  7728. // delete items
  7729. while( amount && ( idx = pc_search_inventory(sd, nameid) ) != -1 )
  7730. {
  7731. int delamount = ( amount < sd->inventory.u.items_inventory[idx].amount ) ? amount : sd->inventory.u.items_inventory[idx].amount;
  7732. if( sd->inventory_data[idx]->type == IT_PETEGG && sd->inventory.u.items_inventory[idx].card[0] == CARD0_PET )
  7733. {// delete pet
  7734. intif_delete_petdata(MakeDWord(sd->inventory.u.items_inventory[idx].card[1], sd->inventory.u.items_inventory[idx].card[2]));
  7735. }
  7736. pc_delitem(sd, idx, delamount, 0, 0, LOG_TYPE_COMMAND);
  7737. amount-= delamount;
  7738. }
  7739. // notify target
  7740. sprintf(atcmd_output, msg_txt(sd,113), total-amount); // %d item(s) removed by a GM.
  7741. clif_displaymessage(sd->fd, atcmd_output);
  7742. // notify source
  7743. if( amount == total )
  7744. {
  7745. clif_displaymessage(fd, msg_txt(sd,116)); // Character does not have the item.
  7746. }
  7747. else if( amount )
  7748. {
  7749. sprintf(atcmd_output, msg_txt(sd,115), total-amount, total-amount, total); // %d item(s) removed. Player had only %d on %d items.
  7750. clif_displaymessage(fd, atcmd_output);
  7751. }
  7752. else
  7753. {
  7754. sprintf(atcmd_output, msg_txt(sd,114), total); // %d item(s) removed from the player.
  7755. clif_displaymessage(fd, atcmd_output);
  7756. }
  7757. return 0;
  7758. }
  7759. /*==========================================
  7760. * Custom Fonts
  7761. *------------------------------------------*/
  7762. ACMD_FUNC(font)
  7763. {
  7764. int font_id;
  7765. nullpo_retr(-1,sd);
  7766. font_id = atoi(message);
  7767. if( font_id == 0 ) {
  7768. if( sd->status.font ) {
  7769. sd->status.font = 0;
  7770. clif_displaymessage(fd, msg_txt(sd,1356)); // Returning to normal font.
  7771. clif_font(sd);
  7772. } else {
  7773. clif_displaymessage(fd, msg_txt(sd,1357)); // Use @font <1-9> to change your message font.
  7774. clif_displaymessage(fd, msg_txt(sd,1358)); // Use 0 or no parameter to return to normal font.
  7775. }
  7776. } else if( font_id < 0 || font_id > 9 )
  7777. clif_displaymessage(fd, msg_txt(sd,1359)); // Invalid font. Use a value from 0 to 9.
  7778. else if( font_id != sd->status.font ) {
  7779. sd->status.font = font_id;
  7780. clif_font(sd);
  7781. clif_displaymessage(fd, msg_txt(sd,1360)); // Font changed.
  7782. } else
  7783. clif_displaymessage(fd, msg_txt(sd,1361)); // Already using this font.
  7784. return 0;
  7785. }
  7786. /*==========================================
  7787. * type: 1 = commands (@), 2 = charcommands (#)
  7788. *------------------------------------------*/
  7789. static void atcommand_commands_sub(struct map_session_data* sd, const int fd, AtCommandType type)
  7790. {
  7791. char line_buff[CHATBOX_SIZE];
  7792. char* cur = line_buff;
  7793. AtCommandInfo* cmd;
  7794. DBIterator *iter = db_iterator(atcommand_db);
  7795. int count = 0;
  7796. memset(line_buff,' ',CHATBOX_SIZE);
  7797. line_buff[CHATBOX_SIZE-1] = 0;
  7798. clif_displaymessage(fd, msg_txt(sd,273)); // "Commands available:"
  7799. for (cmd = (AtCommandInfo*)dbi_first(iter); dbi_exists(iter); cmd = (AtCommandInfo*)dbi_next(iter)) {
  7800. unsigned int slen = 0;
  7801. switch( type ) {
  7802. case COMMAND_CHARCOMMAND:
  7803. if( cmd->char_groups[sd->group_pos] == 0 )
  7804. continue;
  7805. break;
  7806. case COMMAND_ATCOMMAND:
  7807. if( cmd->at_groups[sd->group_pos] == 0 )
  7808. continue;
  7809. break;
  7810. default:
  7811. continue;
  7812. }
  7813. slen = strlen(cmd->command);
  7814. // flush the text buffer if this command won't fit into it
  7815. if (slen + cur - line_buff >= CHATBOX_SIZE) {
  7816. clif_displaymessage(fd,line_buff);
  7817. cur = line_buff;
  7818. memset(line_buff,' ',CHATBOX_SIZE);
  7819. line_buff[CHATBOX_SIZE-1] = 0;
  7820. }
  7821. memcpy(cur,cmd->command,slen);
  7822. cur += slen+(10-slen%10);
  7823. count++;
  7824. }
  7825. dbi_destroy(iter);
  7826. clif_displaymessage(fd,line_buff);
  7827. if ( atcmd_binding_count ) {
  7828. int i, count_bind, gm_lvl = pc_get_group_level(sd);
  7829. for( i = count_bind = 0; i < atcmd_binding_count; i++ ) {
  7830. if ( gm_lvl >= ( (type - 1) ? atcmd_binding[i]->level2 : atcmd_binding[i]->level ) ) {
  7831. unsigned int slen = strlen(atcmd_binding[i]->command);
  7832. if ( count_bind == 0 ) {
  7833. cur = line_buff;
  7834. memset(line_buff,' ',CHATBOX_SIZE);
  7835. line_buff[CHATBOX_SIZE-1] = 0;
  7836. clif_displaymessage(fd, "-----------------");
  7837. clif_displaymessage(fd, msg_txt(sd,509)); // Script-bound commands:
  7838. }
  7839. if (slen + cur - line_buff >= CHATBOX_SIZE) {
  7840. clif_displaymessage(fd,line_buff);
  7841. cur = line_buff;
  7842. memset(line_buff,' ',CHATBOX_SIZE);
  7843. line_buff[CHATBOX_SIZE-1] = 0;
  7844. }
  7845. memcpy(cur,atcmd_binding[i]->command,slen);
  7846. cur += slen+(10-slen%10);
  7847. count_bind++;
  7848. }
  7849. }
  7850. if ( count_bind )
  7851. clif_displaymessage(fd,line_buff);// last one
  7852. count += count_bind;
  7853. }
  7854. sprintf(atcmd_output, msg_txt(sd,274), count); // "%d commands found."
  7855. clif_displaymessage(fd, atcmd_output);
  7856. return;
  7857. }
  7858. /*==========================================
  7859. * @commands Lists available @ commands to you
  7860. *------------------------------------------*/
  7861. ACMD_FUNC(commands)
  7862. {
  7863. atcommand_commands_sub(sd, fd, COMMAND_ATCOMMAND);
  7864. return 0;
  7865. }
  7866. /*==========================================
  7867. * @charcommands Lists available # commands to you
  7868. *------------------------------------------*/
  7869. ACMD_FUNC(charcommands) {
  7870. atcommand_commands_sub(sd, fd, COMMAND_CHARCOMMAND);
  7871. return 0;
  7872. }
  7873. /* for new mounts */
  7874. ACMD_FUNC(mount2) {
  7875. clif_displaymessage(sd->fd,msg_txt(sd,1362)); // NOTICE: If you crash with mount your LUA is outdated.
  7876. if (!sd->sc.data[SC_ALL_RIDING]) {
  7877. clif_displaymessage(sd->fd,msg_txt(sd,1363)); // You have mounted.
  7878. sc_start(NULL, &sd->bl, SC_ALL_RIDING, 10000, 1, INFINITE_TICK);
  7879. } else {
  7880. clif_displaymessage(sd->fd,msg_txt(sd,1364)); // You have released your mount.
  7881. status_change_end(&sd->bl, SC_ALL_RIDING, INVALID_TIMER);
  7882. }
  7883. return 0;
  7884. }
  7885. ACMD_FUNC(accinfo) {
  7886. char query[NAME_LENGTH];
  7887. char type = 0; // type = 1, get only account name
  7888. if (!message || !*message || strlen(message) > NAME_LENGTH
  7889. || ( sscanf(message, "%23s %c", query, &type) < 1))
  7890. {
  7891. clif_displaymessage(fd, msg_txt(sd,1365)); // Usage: @accinfo/@accountinfo <account_id/char name>
  7892. 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".
  7893. return -1;
  7894. } else if (type != 0) {
  7895. type = type-'0'; //make it int
  7896. if (type != 1) {
  7897. clif_displaymessage(fd, "accinfo : Unknow type specified\n");
  7898. return -1;
  7899. }
  7900. }
  7901. intif_request_accinfo( sd->fd, sd->bl.id, pc_get_group_level(sd), query, type);
  7902. return 0;
  7903. }
  7904. /**
  7905. * @set <variable name{[index]}>{ <value>}
  7906. *
  7907. * Gets or sets a value of a non server variable.
  7908. * If a value is specified it is used to set the variable's value,
  7909. * if not the variable's value is read.
  7910. * In any case it reads and displays the variable's value.
  7911. *
  7912. * Original implementation by Ind
  7913. */
  7914. ACMD_FUNC(set) {
  7915. char reg[46], val[128], name[32];
  7916. int toset = 0, len;
  7917. uint32 index;
  7918. bool is_str = false;
  7919. int64 uid;
  7920. if( !message || !*message || (toset = sscanf(message, "%45s %127[^\n]s", reg, val)) < 1 ) {
  7921. clif_displaymessage(fd, msg_txt(sd,1367)); // Usage: @set <variable name> <value>
  7922. clif_displaymessage(fd, msg_txt(sd,1368)); // Usage: ex. "@set PoringCharVar 50"
  7923. clif_displaymessage(fd, msg_txt(sd,1369)); // Usage: ex. "@set PoringCharVarSTR$ Super Duper String"
  7924. clif_displaymessage(fd, msg_txt(sd,1370)); // Usage: ex. "@set PoringCharVarSTR$" outputs its value, Super Duper String.
  7925. return -1;
  7926. }
  7927. /* disabled variable types (they require a proper script state to function, so allowing them would crash the server) */
  7928. if( reg[0] == '.' ) {
  7929. clif_displaymessage(fd, msg_txt(sd,1371)); // NPC variables may not be used with @set.
  7930. return -1;
  7931. } else if( reg[0] == '\'' ) {
  7932. clif_displaymessage(fd, msg_txt(sd,1372)); // Instance variables may not be used with @set.
  7933. return -1;
  7934. }
  7935. // Check if the user wanted to set an array
  7936. if( sscanf( reg, "%31[^[][%" PRIu32 "]", name, &index ) < 2 ){
  7937. // The user did not specify array brackets, so we set the index to zero
  7938. index = 0;
  7939. }
  7940. is_str = is_string_variable(name);
  7941. if( ( len = strlen(val) ) > 1 ) {
  7942. if( val[0] == '"' && val[len-1] == '"') {
  7943. val[len-1] = '\0'; //Strip quotes.
  7944. memmove(val, val+1, len-1);
  7945. }
  7946. }
  7947. // Only set the variable if there is a value for it
  7948. if( toset >= 2 ){
  7949. if( is_str ){
  7950. setd_sub_str( NULL, sd, name, index, val, NULL );
  7951. }else{
  7952. setd_sub_num( NULL, sd, name, index, strtoll( val, NULL, 10 ), NULL );
  7953. }
  7954. }
  7955. uid = reference_uid( add_str( name ), index );
  7956. if( is_str ) {// string variable
  7957. char* value;
  7958. switch( reg[0] ) {
  7959. case '@':
  7960. value = pc_readregstr(sd, uid);
  7961. break;
  7962. case '$':
  7963. value = mapreg_readregstr(uid);
  7964. break;
  7965. case '#':
  7966. if( reg[1] == '#' )
  7967. value = pc_readaccountreg2str(sd, uid);// global
  7968. else
  7969. value = pc_readaccountregstr(sd, uid);// local
  7970. break;
  7971. default:
  7972. value = pc_readglobalreg_str(sd, uid);
  7973. break;
  7974. }
  7975. if( value == NULL || *value == '\0' ){// empty string
  7976. sprintf(atcmd_output,msg_txt(sd,1375),reg); // %s is empty
  7977. }else{
  7978. sprintf(atcmd_output,msg_txt(sd,1374),reg,value); // %s value is now: %s
  7979. }
  7980. } else {// integer variable
  7981. int64 value;
  7982. switch( reg[0] ) {
  7983. case '@':
  7984. value = pc_readreg(sd, uid);
  7985. break;
  7986. case '$':
  7987. value = mapreg_readreg(uid);
  7988. break;
  7989. case '#':
  7990. if( reg[1] == '#' )
  7991. value = pc_readaccountreg2(sd, uid);// global
  7992. else
  7993. value = pc_readaccountreg(sd, uid);// local
  7994. break;
  7995. default:
  7996. value = pc_readglobalreg(sd, uid);
  7997. break;
  7998. }
  7999. sprintf(atcmd_output,msg_txt(sd,1373),reg,value); // %s value is now: %lld
  8000. }
  8001. clif_displaymessage(fd, atcmd_output);
  8002. return 0;
  8003. }
  8004. ACMD_FUNC(addperm) {
  8005. int perm_size = ARRAYLENGTH(pc_g_permission_name);
  8006. bool add;
  8007. int i;
  8008. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  8009. add = (strcmpi(parent_cmd, "addperm") == 0);
  8010. if( !message || !*message ) {
  8011. sprintf(atcmd_output, msg_txt(sd,1378),command); // Usage: %s <permission_name>
  8012. clif_displaymessage(fd, atcmd_output);
  8013. clif_displaymessage(fd, msg_txt(sd,1379)); // -- Permission List
  8014. for( i = 0; i < perm_size; i++ ) {
  8015. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  8016. clif_displaymessage(fd, atcmd_output);
  8017. }
  8018. return -1;
  8019. }
  8020. ARR_FIND(0, perm_size, i, strcmpi(pc_g_permission_name[i].name, message) == 0);
  8021. if( i == perm_size ) {
  8022. sprintf(atcmd_output,msg_txt(sd,1380),message); // '%s' is not a known permission.
  8023. clif_displaymessage(fd, atcmd_output);
  8024. clif_displaymessage(fd, msg_txt(sd,1379)); // -- Permission List
  8025. for( i = 0; i < perm_size; i++ ) {
  8026. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  8027. clif_displaymessage(fd, atcmd_output);
  8028. }
  8029. return -1;
  8030. }
  8031. if( add && (sd->permissions&pc_g_permission_name[i].permission) ) {
  8032. sprintf(atcmd_output, msg_txt(sd,1381),sd->status.name,pc_g_permission_name[i].name); // User '%s' already possesses the '%s' permission.
  8033. clif_displaymessage(fd, atcmd_output);
  8034. return -1;
  8035. } else if ( !add && !(sd->permissions&pc_g_permission_name[i].permission) ) {
  8036. sprintf(atcmd_output, msg_txt(sd,1382),sd->status.name,pc_g_permission_name[i].name); // User '%s' doesn't possess the '%s' permission.
  8037. clif_displaymessage(fd, atcmd_output);
  8038. sprintf(atcmd_output,msg_txt(sd,1383),sd->status.name); // -- User '%s' Permissions
  8039. clif_displaymessage(fd, atcmd_output);
  8040. for( i = 0; i < perm_size; i++ ) {
  8041. if( sd->permissions&pc_g_permission_name[i].permission ) {
  8042. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  8043. clif_displaymessage(fd, atcmd_output);
  8044. }
  8045. }
  8046. return -1;
  8047. }
  8048. if( add )
  8049. sd->permissions |= pc_g_permission_name[i].permission;
  8050. else
  8051. sd->permissions &=~ pc_g_permission_name[i].permission;
  8052. sprintf(atcmd_output, msg_txt(sd,1384),sd->status.name); // User '%s' permissions updated successfully. The changes are temporary.
  8053. clif_displaymessage(fd, atcmd_output);
  8054. return 0;
  8055. }
  8056. ACMD_FUNC(unloadnpcfile) {
  8057. if( !message || !*message ) {
  8058. clif_displaymessage(fd, msg_txt(sd,1385)); // Usage: @unloadnpcfile <file name>
  8059. return -1;
  8060. }
  8061. if( npc_unloadfile(message) )
  8062. clif_displaymessage(fd, msg_txt(sd,1386)); // File unloaded. Be aware that mapflags and monsters spawned directly are not removed.
  8063. else {
  8064. clif_displaymessage(fd, msg_txt(sd,1387)); // File not found.
  8065. return -1;
  8066. }
  8067. return 0;
  8068. }
  8069. ACMD_FUNC(cart) {
  8070. #define MC_CART_MDFY(idx, x) \
  8071. sd->status.skill[(idx)].id = (x)?MC_PUSHCART:0; \
  8072. sd->status.skill[(idx)].lv = (x)?1:0; \
  8073. sd->status.skill[(idx)].flag = (x)?SKILL_FLAG_TEMPORARY:SKILL_FLAG_PERMANENT;
  8074. int val = atoi(message);
  8075. bool need_skill = (pc_checkskill(sd, MC_PUSHCART) == 0);
  8076. uint16 sk_idx = 0;
  8077. if( !message || !*message || val < 0 || val > MAX_CARTS ) {
  8078. sprintf(atcmd_output, msg_txt(sd,1390),command,MAX_CARTS); // Unknown Cart (usage: %s <0-%d>).
  8079. clif_displaymessage(fd, atcmd_output);
  8080. return -1;
  8081. }
  8082. if( val == 0 && !pc_iscarton(sd) ) {
  8083. clif_displaymessage(fd, msg_txt(sd,1391)); // You do not possess a cart to be removed
  8084. return -1;
  8085. }
  8086. if (!(sk_idx = skill_get_index(MC_PUSHCART)))
  8087. return -1;
  8088. if( need_skill ) {
  8089. MC_CART_MDFY(sk_idx,1);
  8090. }
  8091. if( !pc_setcart(sd, val) ) {
  8092. if( need_skill ) {
  8093. MC_CART_MDFY(sk_idx,0);
  8094. }
  8095. return -1;/* @cart failed */
  8096. }
  8097. if( need_skill ) {
  8098. MC_CART_MDFY(sk_idx,0);
  8099. }
  8100. clif_displaymessage(fd, msg_txt(sd,1392)); // Cart Added
  8101. return 0;
  8102. #undef MC_CART_MDFY
  8103. }
  8104. /* Channel System [Ind] */
  8105. ACMD_FUNC(join){
  8106. char chname[CHAN_NAME_LENGTH], pass[CHAN_NAME_LENGTH];
  8107. if( !message || !*message || sscanf(message, "%19s %19s", chname, pass) < 1 ) {
  8108. sprintf(atcmd_output, msg_txt(sd,1399),command); // Unknown channel (usage: %s <#channel_name>).
  8109. clif_displaymessage(fd, atcmd_output);
  8110. return -1;
  8111. }
  8112. return channel_pcjoin(sd, chname, pass);
  8113. }
  8114. /*
  8115. * Display available option for @channel command
  8116. * @command : the name of used command (for alias case)
  8117. */
  8118. static inline void atcmd_channel_help(struct map_session_data *sd, const char *command)
  8119. {
  8120. int fd = sd->fd;
  8121. bool can_delete = pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN);
  8122. bool can_create = (can_delete || channel_config.private_channel.allow);
  8123. clif_displaymessage(fd, msg_txt(sd,1414));// ---- Available options:
  8124. //option create
  8125. if( can_create ) {
  8126. sprintf(atcmd_output, msg_txt(sd,1415),command);// * %s create <#channel_name> <channel_password>
  8127. clif_displaymessage(fd, atcmd_output);
  8128. clif_displaymessage(fd, msg_txt(sd,1416));// -- Creates a new channel.
  8129. }
  8130. //option delete
  8131. if(can_delete){
  8132. sprintf(atcmd_output, msg_txt(sd,1469),command);// * %s delete <#channel_name>
  8133. clif_displaymessage(fd, atcmd_output);
  8134. clif_displaymessage(fd, msg_txt(sd,1470)); // -- Destroys the specified channel.
  8135. }
  8136. //option list
  8137. sprintf(atcmd_output, msg_txt(sd,1417),command);// * %s list
  8138. clif_displaymessage(fd, atcmd_output);
  8139. clif_displaymessage(fd, msg_txt(sd,1418));// -- Lists all public channels.
  8140. sprintf(atcmd_output, msg_txt(sd,1471),command);// * %s list mine
  8141. clif_displaymessage(fd, atcmd_output);
  8142. clif_displaymessage(fd, msg_txt(sd,1472));// -- Lists all channels you have joined.
  8143. if( can_create ) {
  8144. sprintf(atcmd_output, msg_txt(sd,1419),command);// * %s list colors
  8145. clif_displaymessage(fd, atcmd_output);
  8146. clif_displaymessage(fd, msg_txt(sd,1420));// -- Lists all available colors for custom channels.
  8147. }
  8148. //option setcolor
  8149. if(can_create){
  8150. sprintf(atcmd_output, msg_txt(sd,1421),command);// * %s setcolor <#channel_name> <color_name>
  8151. clif_displaymessage(fd, atcmd_output);
  8152. clif_displaymessage(fd, msg_txt(sd,1422));// -- Changes channel text to the specified color (channel owners only).
  8153. }
  8154. //option join
  8155. sprintf(atcmd_output, msg_txt(sd,1473),command);// * %s join <#channel_name> <channel_password>
  8156. clif_displaymessage(fd, atcmd_output);
  8157. clif_displaymessage(fd, msg_txt(sd,1474));// -- Joins the specified channel.
  8158. //option leave
  8159. sprintf(atcmd_output, msg_txt(sd,1423),command);// * %s leave <#channel_name>
  8160. clif_displaymessage(fd, atcmd_output);
  8161. clif_displaymessage(fd, msg_txt(sd,1424));// -- Leaves the specified channel.
  8162. //option bindto
  8163. sprintf(atcmd_output, msg_txt(sd,1427),command);// * %s bindto <#channel_name>
  8164. clif_displaymessage(fd, atcmd_output);
  8165. clif_displaymessage(fd, msg_txt(sd,1428));// -- Binds your global chat to the specified channel, sending all global messages to that channel.
  8166. //option unbind
  8167. sprintf(atcmd_output, msg_txt(sd,1429),command);// * %s unbind
  8168. clif_displaymessage(fd, atcmd_output);
  8169. clif_displaymessage(fd, msg_txt(sd,1430));// -- Unbinds your global chat from the attached channel, if any.
  8170. //option ban/unban/banlist
  8171. if( can_create ) {
  8172. sprintf(atcmd_output, msg_txt(sd,1456),command);// * %s ban <#channel_name> <player>
  8173. clif_displaymessage(fd, atcmd_output);
  8174. clif_displaymessage(fd, msg_txt(sd,1457));// -- Bans the specified player from the channel.
  8175. sprintf(atcmd_output, msg_txt(sd,1458),command);// * %s banlist <#channel_name>
  8176. clif_displaymessage(fd, atcmd_output);
  8177. clif_displaymessage(fd, msg_txt(sd,1459));// -- Lists all players banned from the specified channel.
  8178. sprintf(atcmd_output, msg_txt(sd,1460),command);// * %s unban <#channel_name> <player>
  8179. clif_displaymessage(fd, atcmd_output);
  8180. clif_displaymessage(fd, msg_txt(sd,1461));// -- Unbans the specified player from the channel.
  8181. sprintf(atcmd_output, msg_txt(sd,1467),command);// * %s unbanall <#channel_name>
  8182. clif_displaymessage(fd, atcmd_output);
  8183. clif_displaymessage(fd, msg_txt(sd,1468));// -- Clears all bans from the specified channel.
  8184. }
  8185. //option setopt
  8186. if(can_create){
  8187. sprintf(atcmd_output, msg_txt(sd,1462),command);// * %s setopt <#channel_name> <option> <value>
  8188. clif_displaymessage(fd, atcmd_output);
  8189. clif_displaymessage(fd, msg_txt(sd,1463));// -- Sets an option and value for the specified channel.
  8190. }
  8191. sprintf(atcmd_output, msg_txt(sd,1404),command); // %s failed.
  8192. clif_displaymessage(fd, atcmd_output);
  8193. }
  8194. ACMD_FUNC(channel) {
  8195. char key[NAME_LENGTH], sub1[CHAN_NAME_LENGTH], sub2[64];
  8196. sub1[0] = sub2[0] = '\0';
  8197. if( !message || !*message || sscanf(message, "%23s %19s %63[^\n]", key, sub1, sub2) < 1 ) {
  8198. atcmd_channel_help(sd,command);
  8199. return 0;
  8200. }
  8201. if( strcmpi(key,"delete") == 0 && pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) ) {
  8202. return channel_pcdelete(sd,sub1);
  8203. } else if ( strcmpi(key,"list") == 0 ) {
  8204. return channel_display_list(sd,sub1);
  8205. } else if ( strcmpi(key,"setcolor") == 0 ) {
  8206. return channel_pccolor(sd, sub1, sub2);
  8207. } else if ( strcmpi(key,"join") == 0 ) {
  8208. return channel_pcjoin(sd, sub1, sub2);
  8209. }else if ( strcmpi(key,"leave") == 0 ) {
  8210. return channel_pcleave(sd, sub1);
  8211. } else if ( strcmpi(key,"bindto") == 0 ) {
  8212. return channel_pcbind(sd, sub1);
  8213. } else if ( strcmpi(key,"unbind") == 0 ) {
  8214. return channel_pcunbind(sd);
  8215. } else if ( strcmpi(key,"ban") == 0 ) {
  8216. return channel_pcban(sd,sub1,sub2,0);
  8217. } else if ( strcmpi(key,"kick") == 0 ) {
  8218. return channel_pckick(sd,sub1,sub2);
  8219. } else if ( strcmpi(key,"banlist") == 0 ) {
  8220. return channel_pcban(sd,sub1,NULL,3);
  8221. } else if ( strcmpi(key,"unban") == 0 ) {
  8222. return channel_pcban(sd,sub1,sub2,1);
  8223. } else if ( strcmpi(key,"unbanall") == 0 ) {
  8224. return channel_pcban(sd,sub1,NULL,2);
  8225. } else {
  8226. char sub3[CHAN_NAME_LENGTH], sub4[CHAN_NAME_LENGTH];
  8227. sub3[0] = sub4[0] = '\0';
  8228. sscanf(sub2, "%19s %19s", sub3, sub4);
  8229. if( strcmpi(key,"create") == 0 && ( channel_config.private_channel.allow || pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) ) ) {
  8230. if (sub4[0] != '\0') {
  8231. clif_displaymessage(fd, msg_txt(sd, 1408)); // Channel password may not contain spaces.
  8232. return -1;
  8233. }
  8234. return channel_pccreate(sd,sub1,sub3);
  8235. } else if ( strcmpi(key,"setopt") == 0 ) {
  8236. return channel_pcsetopt(sd,sub1,sub3,sub4);
  8237. }
  8238. atcmd_channel_help(sd,command);
  8239. }
  8240. return 0;
  8241. }
  8242. ACMD_FUNC(fontcolor)
  8243. {
  8244. if( !message || !*message ) {
  8245. channel_display_list(sd,"colors");
  8246. return -1;
  8247. }
  8248. if( strcmpi(message,"Normal") == 0 ) {
  8249. sd->fontcolor = 0;
  8250. } else {
  8251. unsigned char k;
  8252. ARR_FIND(0,channel_config.colors_count,k,( strcmpi(message,channel_config.colors_name[k]) == 0 ));
  8253. if( k == channel_config.colors_count ) {
  8254. sprintf(atcmd_output, msg_txt(sd,1411), message);// Unknown color '%s'.
  8255. clif_displaymessage(fd, atcmd_output);
  8256. return -1;
  8257. }
  8258. sd->fontcolor = k;
  8259. }
  8260. sprintf(atcmd_output, msg_txt(sd,1454), message);// Color set to '%s'.
  8261. clif_displaymessage(fd, atcmd_output);
  8262. return 0;
  8263. }
  8264. ACMD_FUNC(langtype)
  8265. {
  8266. char langstr[8];
  8267. int i=0, fail=0;
  8268. memset(langstr, '\0', sizeof(langstr));
  8269. if(sscanf(message, "%3s", langstr) >= 1){
  8270. int lang=0;
  8271. lang = msg_langstr2langtype(langstr); //Switch langstr to associated langtype
  8272. if( msg_checklangtype(lang,false) == 1 ){ //Verify it's enabled and set it
  8273. char output[100];
  8274. pc_setaccountreg(sd, add_str(LANGTYPE_VAR), lang); //For login/char
  8275. sd->langtype = lang;
  8276. sprintf(output,msg_txt(sd,461),msg_langtype2langstr(lang)); // Language is now set to %s.
  8277. clif_displaymessage(fd,output);
  8278. return 0;
  8279. } else if (lang != -1) { //defined langage but failed check
  8280. clif_displaymessage(fd,msg_txt(sd,462)); // This langage is currently disabled.
  8281. return -1;
  8282. }
  8283. }
  8284. //wrong or no entry
  8285. clif_displaymessage(fd,msg_txt(sd,460)); // Please enter a valid language (usage: @langtype <language>).
  8286. clif_displaymessage(fd,msg_txt(sd,464)); // ---- Available languages:
  8287. while(fail != -1){ //out of range
  8288. fail = msg_checklangtype(i,false);
  8289. if(fail == 1)
  8290. clif_displaymessage(fd,msg_langtype2langstr(i));
  8291. i++;
  8292. }
  8293. return -1;
  8294. }
  8295. #ifdef VIP_ENABLE
  8296. ACMD_FUNC(vip) {
  8297. struct map_session_data *pl_sd = NULL;
  8298. char * modif_p;
  8299. int32 vipdifftime = 0;
  8300. time_t now=time(NULL);
  8301. nullpo_retr(-1, sd);
  8302. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8303. if (!message || !*message || sscanf(message, "%255s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
  8304. clif_displaymessage(fd, msg_txt(sd,700)); //Usage: @vip <timef> <character name>
  8305. return -1;
  8306. }
  8307. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  8308. modif_p = atcmd_output;
  8309. vipdifftime = (int32)solve_time(modif_p);
  8310. if (vipdifftime == 0) {
  8311. clif_displaymessage(fd, msg_txt(sd,701)); // Invalid time for vip command.
  8312. 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.
  8313. return -1;
  8314. }
  8315. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL) {
  8316. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  8317. return -1;
  8318. }
  8319. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  8320. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  8321. return -1;
  8322. }
  8323. if(pl_sd->vip.time==0) pl_sd->vip.time=now;
  8324. pl_sd->vip.time += vipdifftime; //increase or reduce VIP duration
  8325. if (pl_sd->vip.time <= now) {
  8326. clif_displaymessage(pl_sd->fd, msg_txt(pl_sd,703)); // GM has removed your VIP time.
  8327. clif_displaymessage(fd, msg_txt(sd,704)); // Player is no longer VIP.
  8328. } else {
  8329. int year,month,day,hour,minute,second;
  8330. char timestr[21];
  8331. split_time((int)(pl_sd->vip.time-now),&year,&month,&day,&hour,&minute,&second);
  8332. 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.
  8333. clif_displaymessage(pl_sd->fd,atcmd_output);
  8334. timestamp2string(timestr,20,pl_sd->vip.time,"%Y-%m-%d %H:%M");
  8335. sprintf(atcmd_output,msg_txt(pl_sd,707),timestr); // You are VIP until : %s
  8336. clif_displaymessage(pl_sd->fd,atcmd_output);
  8337. if (pl_sd != sd) {
  8338. 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.
  8339. clif_displaymessage(fd,atcmd_output);
  8340. sprintf(atcmd_output,msg_txt(sd,708),timestr); // The player is now VIP until : %s
  8341. clif_displaymessage(fd,atcmd_output);
  8342. }
  8343. }
  8344. chrif_req_login_operation(pl_sd->status.account_id, pl_sd->status.name, CHRIF_OP_LOGIN_VIP, vipdifftime, 7, 0);
  8345. return 0;
  8346. }
  8347. /** Enable/disable rate info */
  8348. ACMD_FUNC(showrate) {
  8349. nullpo_retr(-1,sd);
  8350. if (!sd->vip.disableshowrate) {
  8351. safestrncpy(atcmd_output,msg_txt(sd,718),CHAT_SIZE_MAX); //Personal rate information is not displayed now.
  8352. sd->vip.disableshowrate = 1;
  8353. } else {
  8354. safestrncpy(atcmd_output,msg_txt(sd,719),CHAT_SIZE_MAX); //Personal rate information will be shown.
  8355. sd->vip.disableshowrate = 0;
  8356. }
  8357. clif_displaymessage(fd,atcmd_output);
  8358. return 0;
  8359. }
  8360. #endif
  8361. ACMD_FUNC(fullstrip) {
  8362. int i;
  8363. TBL_PC *tsd;
  8364. nullpo_retr(-1,sd);
  8365. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  8366. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  8367. clif_displaymessage(fd, msg_txt(sd,349)); // Please enter a player name (usage: @fullstrip/@warpto/@goto <char name/ID>).
  8368. return -1;
  8369. }
  8370. if((tsd=map_nick2sd(atcmd_player_name,false)) == NULL && (tsd=map_id2sd(atoi(atcmd_player_name))) == NULL){
  8371. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  8372. return -1;
  8373. }
  8374. for( i = 0; i < EQI_MAX; i++ ) {
  8375. if( tsd->equip_index[ i ] >= 0 )
  8376. pc_unequipitem( tsd , tsd->equip_index[ i ] , 2 );
  8377. }
  8378. return 0;
  8379. }
  8380. ACMD_FUNC(changedress){
  8381. sc_type name2id[] = {
  8382. SC_WEDDING,
  8383. SC_XMAS,
  8384. SC_SUMMER,
  8385. SC_DRESSUP,
  8386. SC_HANBOK,
  8387. SC_OKTOBERFEST
  8388. };
  8389. for( sc_type type : name2id ) {
  8390. if( sd->sc.data[type] ) {
  8391. status_change_end( &sd->bl, type, INVALID_TIMER );
  8392. // You should only be able to have one - so we cancel here
  8393. break;
  8394. }
  8395. }
  8396. return 0;
  8397. }
  8398. ACMD_FUNC(costume) {
  8399. const char* names[] = {
  8400. "Wedding",
  8401. "Xmas",
  8402. "Summer",
  8403. "Summer2",
  8404. "Hanbok",
  8405. "Oktoberfest"
  8406. };
  8407. const int name2id[] = {
  8408. SC_WEDDING,
  8409. SC_XMAS,
  8410. SC_SUMMER,
  8411. SC_DRESSUP,
  8412. SC_HANBOK,
  8413. SC_OKTOBERFEST
  8414. };
  8415. unsigned short k = 0, len = ARRAYLENGTH(names);
  8416. if( !message || !*message ) {
  8417. for( k = 0; k < len; k++ ) {
  8418. if( sd->sc.data[name2id[k]] ) {
  8419. sprintf(atcmd_output, msg_txt(sd, 727), names[k]); // '%s' Costume removed.
  8420. clif_displaymessage(sd->fd, atcmd_output);
  8421. status_change_end(&sd->bl, (sc_type)name2id[k], INVALID_TIMER);
  8422. return 0;
  8423. }
  8424. }
  8425. clif_displaymessage(sd->fd, msg_txt(sd, 726)); // Available Costumes
  8426. for( k = 0; k < len; k++ ) {
  8427. sprintf(atcmd_output, msg_txt(sd, 725), names[k]); // -- %s
  8428. clif_displaymessage(sd->fd, atcmd_output);
  8429. }
  8430. return -1;
  8431. }
  8432. for( k = 0; k < len; k++ ) {
  8433. if( sd->sc.data[name2id[k]] ) {
  8434. sprintf(atcmd_output, msg_txt(sd, 724), names[k]); // You're already wearing a(n) '%s' costume, type '@costume' to remove it.
  8435. clif_displaymessage(sd->fd, atcmd_output);
  8436. return -1;
  8437. }
  8438. }
  8439. for( k = 0; k < len; k++ )
  8440. if( strcmpi(message, names[k]) == 0 )
  8441. break;
  8442. if( k == len ) {
  8443. sprintf(atcmd_output, msg_txt(sd, 723), message); // '%s' is an unknown costume
  8444. clif_displaymessage(sd->fd, atcmd_output);
  8445. return -1;
  8446. }
  8447. sc_start(&sd->bl, &sd->bl, (sc_type)name2id[k], 100, name2id[k] == SC_DRESSUP ? 1 : 0, INFINITE_TICK);
  8448. return 0;
  8449. }
  8450. /**
  8451. * Clone other player's equipments
  8452. * Usage: @cloneequip <char name/ID>
  8453. * http://rathena.org/board/topic/95076-new-atcommands-suggestion/
  8454. * @author [Cydh], [Antares]
  8455. */
  8456. ACMD_FUNC(cloneequip) {
  8457. struct map_session_data *pl_sd;
  8458. nullpo_retr(-1, sd);
  8459. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  8460. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8461. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  8462. sprintf(atcmd_output, msg_txt(sd, 735), command); // Usage: %s <char name/ID>
  8463. clif_displaymessage(fd, atcmd_output);
  8464. return -1;
  8465. }
  8466. if (!(pl_sd = map_nick2sd(atcmd_player_name, true)) && !(pl_sd = map_charid2sd(atoi(atcmd_player_name)))) {
  8467. clif_displaymessage(fd, msg_txt(sd, 3));
  8468. return -1;
  8469. }
  8470. if (sd == pl_sd) {
  8471. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8472. sprintf(atcmd_output, msg_txt(sd, 734), "equip"); // Cannot clone your own %.
  8473. clif_displaymessage(fd, atcmd_output);
  8474. return -1;
  8475. }
  8476. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) {
  8477. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8478. sprintf(atcmd_output, msg_txt(sd, 736), "equip"); // Cannot clone %s from this player.
  8479. clif_displaymessage(fd, atcmd_output);
  8480. return -1;
  8481. }
  8482. else {
  8483. int8 i;
  8484. for (i = 0; i < EQI_MAX; i++) {
  8485. short idx;
  8486. char flag = 0;
  8487. struct item tmp_item;
  8488. if ((idx = pl_sd->equip_index[i]) < 0)
  8489. continue;
  8490. if (i == EQI_AMMO)
  8491. continue;
  8492. if (pc_is_same_equip_index((enum equip_index) i, pl_sd->equip_index, idx))
  8493. continue;
  8494. tmp_item = pl_sd->inventory.u.items_inventory[idx];
  8495. if (itemdb_isspecial(tmp_item.card[0]))
  8496. memset(tmp_item.card, 0, sizeof(tmp_item.card));
  8497. tmp_item.bound = 0;
  8498. tmp_item.expire_time = 0;
  8499. tmp_item.unique_id = 0;
  8500. tmp_item.favorite = 0;
  8501. tmp_item.amount = 1;
  8502. if ((flag = pc_additem(sd, &tmp_item, 1, LOG_TYPE_COMMAND)))
  8503. clif_additem(sd, 0, 0, flag);
  8504. else
  8505. pc_equipitem(sd, sd->last_addeditem_index, itemdb_equip(tmp_item.nameid));
  8506. }
  8507. }
  8508. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8509. sprintf(atcmd_output, msg_txt(sd, 738), "equip"); // Clone '%s' is done.
  8510. clif_displaymessage(fd, atcmd_output);
  8511. return 0;
  8512. }
  8513. /**
  8514. * Clone other player's statuses/parameters using method same like ACMD_FUNC(param), doesn't use stat point
  8515. * Usage: @clonestat <char name/ID>
  8516. * http://rathena.org/board/topic/95076-new-atcommands-suggestion/
  8517. * @author [Cydh], [Antares]
  8518. */
  8519. ACMD_FUNC(clonestat) {
  8520. struct map_session_data *pl_sd;
  8521. nullpo_retr(-1, sd);
  8522. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  8523. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8524. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  8525. sprintf(atcmd_output, msg_txt(sd, 735), command); // Usage: %s <char name/ID>
  8526. clif_displaymessage(fd, atcmd_output);
  8527. return -1;
  8528. }
  8529. if (!(pl_sd = map_nick2sd(atcmd_player_name, true)) && !(pl_sd = map_charid2sd(atoi(atcmd_player_name)))) {
  8530. clif_displaymessage(fd, msg_txt(sd, 3)); // Character not found.
  8531. return -1;
  8532. }
  8533. if (sd == pl_sd) {
  8534. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8535. sprintf(atcmd_output, msg_txt(sd, 734), "status"); // Cannot clone your own %.
  8536. clif_displaymessage(fd, atcmd_output);
  8537. return -1;
  8538. }
  8539. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) {
  8540. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8541. sprintf(atcmd_output, msg_txt(sd, 736), "status"); // Cannot clone %s from this player.
  8542. clif_displaymessage(fd, atcmd_output);
  8543. return -1;
  8544. }
  8545. else {
  8546. uint8 i;
  8547. short max_status[6];
  8548. pc_resetstate(sd);
  8549. if (pc_has_permission(sd, PC_PERM_BYPASS_STAT_ONCLONE))
  8550. max_status[0] = max_status[1] = max_status[2] = max_status[3] = max_status[4] = max_status[5] = SHRT_MAX;
  8551. else {
  8552. max_status[0] = pc_maxparameter(sd, PARAM_STR);
  8553. max_status[1] = pc_maxparameter(sd, PARAM_AGI);
  8554. max_status[2] = pc_maxparameter(sd, PARAM_VIT);
  8555. max_status[3] = pc_maxparameter(sd, PARAM_INT);
  8556. max_status[4] = pc_maxparameter(sd, PARAM_DEX);
  8557. max_status[5] = pc_maxparameter(sd, PARAM_LUK);
  8558. }
  8559. #define clonestat_check(cmd,stat)\
  8560. {\
  8561. memset(atcmd_output, '\0', sizeof(atcmd_output));\
  8562. if (pl_sd->status.cmd > max_status[(stat)]) {\
  8563. sprintf(atcmd_output, msg_txt(sd, 737), #cmd, pl_sd->status.cmd, max_status[(stat)]);\
  8564. clif_displaymessage(fd, atcmd_output);\
  8565. sd->status.cmd = max_status[(stat)];\
  8566. }\
  8567. else\
  8568. sd->status.cmd = pl_sd->status.cmd;\
  8569. }
  8570. clonestat_check(str, PARAM_STR);
  8571. clonestat_check(agi, PARAM_AGI);
  8572. clonestat_check(vit, PARAM_VIT);
  8573. clonestat_check(int_, PARAM_INT);
  8574. clonestat_check(dex, PARAM_DEX);
  8575. clonestat_check(luk, PARAM_LUK);
  8576. for (i = 0; i < PARAM_MAX; i++) {
  8577. clif_updatestatus(sd, SP_STR + i);
  8578. clif_updatestatus(sd, SP_USTR + i);
  8579. }
  8580. status_calc_pc(sd, SCO_FORCE);
  8581. }
  8582. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8583. sprintf(atcmd_output, msg_txt(sd, 738), "status"); // Clone '%s' is done.
  8584. clif_displaymessage(fd, atcmd_output);
  8585. #undef clonestat_check
  8586. return 0;
  8587. }
  8588. /**
  8589. * Adopt a character.
  8590. * Usage: @adopt <char name>
  8591. * https://rathena.org/board/topic/104014-suggestion-add-adopt-or-etc/
  8592. */
  8593. ACMD_FUNC(adopt)
  8594. {
  8595. TBL_PC *b_sd;
  8596. enum adopt_responses response;
  8597. nullpo_retr(-1, sd);
  8598. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8599. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  8600. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  8601. sprintf(atcmd_output, msg_txt(sd, 435), command); // Please enter a player name (usage: %s <char name>).
  8602. clif_displaymessage(fd, atcmd_output);
  8603. return -1;
  8604. }
  8605. if ((b_sd = map_nick2sd(atcmd_player_name,false)) == NULL) {
  8606. clif_displaymessage(fd, msg_txt(sd, 3)); // Character not found.
  8607. return -1;
  8608. }
  8609. response = pc_try_adopt(sd, map_charid2sd(sd->status.partner_id), b_sd);
  8610. if (response == ADOPT_ALLOWED) {
  8611. TBL_PC *p_sd = map_charid2sd(sd->status.partner_id);
  8612. b_sd->adopt_invite = sd->status.account_id;
  8613. clif_Adopt_request(b_sd, sd, p_sd->status.account_id);
  8614. return 0;
  8615. }
  8616. if (response < ADOPT_MORE_CHILDREN) // No displaymessage for client-type responses
  8617. clif_displaymessage(fd, msg_txt(sd, 744 + response - 1));
  8618. return -1;
  8619. }
  8620. /**
  8621. * Opens the limited sale window.
  8622. * Usage: @limitedsale or client command /limitedsale on supported clients
  8623. */
  8624. ACMD_FUNC(limitedsale){
  8625. nullpo_retr(-1, sd);
  8626. clif_sale_open(sd);
  8627. return 0;
  8628. }
  8629. /**
  8630. * Displays camera information from the client.
  8631. * Usage: @camerainfo or client command /viewpointvalue or /setcamera on supported clients
  8632. */
  8633. ACMD_FUNC(camerainfo){
  8634. nullpo_retr(-1, sd);
  8635. if( message == nullptr || message[0] == '\0' ){
  8636. clif_camerainfo( sd, true );
  8637. return 0;
  8638. }
  8639. float range = 0;
  8640. float rotation = 0;
  8641. float latitude = 0;
  8642. if( sscanf( message, "%f %f %f", &range, &rotation, &latitude ) < 3 ){
  8643. clif_displaymessage( fd, msg_txt( sd, 793 ) ); // Usage @camerainfo range rotation latitude
  8644. return -1;
  8645. }
  8646. clif_camerainfo( sd, false, range, rotation, latitude );
  8647. return 0;
  8648. }
  8649. ACMD_FUNC(resurrect) {
  8650. nullpo_retr(-1, sd);
  8651. if (!pc_revive_item(sd))
  8652. return -1;
  8653. return 0;
  8654. }
  8655. ACMD_FUNC(quest) {
  8656. uint8 i;
  8657. int quest_id = 0;
  8658. nullpo_retr(-1, sd);
  8659. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8660. if (!message || !*message || sscanf(message, "%11d", &quest_id) < 1 || quest_id == 0) {
  8661. sprintf(atcmd_output, msg_txt(sd,1505), command); // Usage: %s <quest ID>
  8662. clif_displaymessage(fd, atcmd_output);
  8663. return -1;
  8664. }
  8665. if (!quest_search(quest_id)) {
  8666. sprintf(atcmd_output, msg_txt(sd,1506), quest_id); // Quest %d not found in DB.
  8667. clif_displaymessage(fd, atcmd_output);
  8668. return -1;
  8669. }
  8670. const char* type[] = { "setquest", "erasequest", "completequest", "checkquest" };
  8671. ARR_FIND( 0, ARRAYLENGTH(type), i, strcmpi(command+1, type[i]) == 0 );
  8672. switch(i) {
  8673. case 0:
  8674. if (quest_check(sd, quest_id, HAVEQUEST) >= 0) {
  8675. sprintf(atcmd_output, msg_txt(sd,1507), quest_id); // Character already has quest %d.
  8676. clif_displaymessage(fd, atcmd_output);
  8677. return -1;
  8678. }
  8679. quest_add(sd, quest_id);
  8680. pc_show_questinfo(sd);
  8681. break;
  8682. case 1:
  8683. if (quest_check(sd, quest_id, HAVEQUEST) < 0) {
  8684. sprintf(atcmd_output, msg_txt(sd,1508), quest_id); // Character doesn't have quest %d.
  8685. clif_displaymessage(fd, atcmd_output);
  8686. return -1;
  8687. }
  8688. quest_delete(sd, quest_id);
  8689. pc_show_questinfo(sd);
  8690. break;
  8691. case 2:
  8692. if (quest_check(sd, quest_id, HAVEQUEST) < 0)
  8693. quest_add(sd, quest_id);
  8694. if (quest_check(sd, quest_id, HAVEQUEST) < 2)
  8695. quest_update_status(sd, quest_id, Q_COMPLETE);
  8696. pc_show_questinfo(sd);
  8697. break;
  8698. case 3:
  8699. sprintf(atcmd_output, msg_txt(sd,1509), quest_id); // Checkquest value for quest %d
  8700. clif_displaymessage(fd, atcmd_output);
  8701. sprintf(atcmd_output, msg_txt(sd,1510), quest_check(sd, quest_id, HAVEQUEST)); // HAVEQUEST : %d
  8702. clif_displaymessage(fd, atcmd_output);
  8703. sprintf(atcmd_output, msg_txt(sd,1511), quest_check(sd, quest_id, HUNTING)); // HUNTING : %d
  8704. clif_displaymessage(fd, atcmd_output);
  8705. sprintf(atcmd_output, msg_txt(sd,1512), quest_check(sd, quest_id, PLAYTIME)); // PLAYTIME : %d
  8706. clif_displaymessage(fd, atcmd_output);
  8707. break;
  8708. }
  8709. return 0;
  8710. }
  8711. #include "../custom/atcommand.inc"
  8712. /**
  8713. * Fills the reference of available commands in atcommand DBMap
  8714. **/
  8715. #define ACMD_DEF(x) { #x, atcommand_ ## x, NULL, NULL, 0 }
  8716. #define ACMD_DEF2(x2, x) { x2, atcommand_ ## x, NULL, NULL, 0 }
  8717. // Define with restriction
  8718. #define ACMD_DEFR(x, r) { #x, atcommand_ ## x, NULL, NULL, r }
  8719. #define ACMD_DEF2R(x2, x, r) { x2, atcommand_ ## x, NULL, NULL, r }
  8720. void atcommand_basecommands(void) {
  8721. /**
  8722. * Command reference list, place the base of your commands here
  8723. * TODO: List all commands that causing crash
  8724. **/
  8725. AtCommandInfo atcommand_base[] = {
  8726. #include "../custom/atcommand_def.inc"
  8727. ACMD_DEF2R("warp", mapmove, ATCMD_NOCONSOLE),
  8728. ACMD_DEF(where),
  8729. ACMD_DEF(jumpto),
  8730. ACMD_DEF(jump),
  8731. ACMD_DEF(who),
  8732. ACMD_DEF2("who2", who),
  8733. ACMD_DEF2("who3", who),
  8734. ACMD_DEF2("whomap", who),
  8735. ACMD_DEF2("whomap2", who),
  8736. ACMD_DEF2("whomap3", who),
  8737. ACMD_DEF(whogm),
  8738. ACMD_DEF(save),
  8739. ACMD_DEF(load),
  8740. ACMD_DEF(speed),
  8741. ACMD_DEF(storage),
  8742. ACMD_DEF(guildstorage),
  8743. ACMD_DEF(option),
  8744. ACMD_DEF(hide), // + /hide
  8745. ACMD_DEFR(jobchange, ATCMD_NOCONSOLE),
  8746. ACMD_DEF(kill),
  8747. ACMD_DEF(alive),
  8748. ACMD_DEF(kami),
  8749. ACMD_DEF2("kamib", kami),
  8750. ACMD_DEF2("kamic", kami),
  8751. ACMD_DEF2("lkami", kami),
  8752. ACMD_DEF(heal),
  8753. ACMD_DEF(item),
  8754. ACMD_DEF(item2),
  8755. ACMD_DEF2("itembound",item),
  8756. ACMD_DEF2("itembound2",item2),
  8757. ACMD_DEF(itemreset),
  8758. ACMD_DEF(clearstorage),
  8759. ACMD_DEF(cleargstorage),
  8760. ACMD_DEF(clearcart),
  8761. ACMD_DEF2R("blvl", baselevelup, ATCMD_NOCONSOLE),
  8762. ACMD_DEF2("jlvl", joblevelup),
  8763. ACMD_DEF(help),
  8764. ACMD_DEF(pvpoff),
  8765. ACMD_DEF(pvpon),
  8766. ACMD_DEF(gvgoff),
  8767. ACMD_DEF(gvgon),
  8768. ACMD_DEF(model),
  8769. ACMD_DEFR(go, ATCMD_NOCONSOLE),
  8770. ACMD_DEF(monster),
  8771. ACMD_DEF2("monstersmall", monster),
  8772. ACMD_DEF2("monsterbig", monster),
  8773. ACMD_DEF(killmonster),
  8774. ACMD_DEF2("killmonster2", killmonster),
  8775. ACMD_DEF(refine),
  8776. ACMD_DEF(produce),
  8777. ACMD_DEF(memo),
  8778. ACMD_DEF(gat),
  8779. ACMD_DEF(displaystatus),
  8780. ACMD_DEF2("stpoint", statuspoint),
  8781. ACMD_DEF2("skpoint", skillpoint),
  8782. ACMD_DEF(zeny),
  8783. ACMD_DEF2("str", param),
  8784. ACMD_DEF2("agi", param),
  8785. ACMD_DEF2("vit", param),
  8786. ACMD_DEF2("int", param),
  8787. ACMD_DEF2("dex", param),
  8788. ACMD_DEF2("luk", param),
  8789. ACMD_DEF2("glvl", guildlevelup),
  8790. ACMD_DEF(makeegg),
  8791. ACMD_DEF(hatch),
  8792. ACMD_DEF(petfriendly),
  8793. ACMD_DEF(pethungry),
  8794. ACMD_DEF(petrename),
  8795. ACMD_DEF(recall), // + /recall
  8796. ACMD_DEF(night),
  8797. ACMD_DEF(day),
  8798. ACMD_DEF(doom),
  8799. ACMD_DEF(doommap),
  8800. ACMD_DEF(raise),
  8801. ACMD_DEF(raisemap),
  8802. ACMD_DEFR(kick,ATCMD_NOAUTOTRADE), // + right click menu for GM "(name) force to quit"
  8803. ACMD_DEF(kickall),
  8804. ACMD_DEF(allskill),
  8805. ACMD_DEF(questskill),
  8806. ACMD_DEF(lostskill),
  8807. ACMD_DEF(spiritball),
  8808. ACMD_DEF(soulball),
  8809. ACMD_DEF(party),
  8810. ACMD_DEF(guild),
  8811. ACMD_DEF(breakguild),
  8812. ACMD_DEF(agitstart),
  8813. ACMD_DEF(agitend),
  8814. ACMD_DEF(mapexit),
  8815. ACMD_DEF(idsearch),
  8816. ACMD_DEF(broadcast), // + /b and /nb
  8817. ACMD_DEF(localbroadcast), // + /lb and /nlb
  8818. ACMD_DEF(recallall),
  8819. ACMD_DEFR(reload,ATCMD_NOSCRIPT),
  8820. ACMD_DEF2("reloaditemdb", reload),
  8821. ACMD_DEF2("reloadmobdb", reload),
  8822. ACMD_DEF2("reloadskilldb", reload),
  8823. ACMD_DEF2R("reloadscript", reload, ATCMD_NOSCRIPT),
  8824. ACMD_DEF2("reloadatcommand", reload),
  8825. ACMD_DEF2("reloadbattleconf", reload),
  8826. ACMD_DEF2("reloadstatusdb", reload),
  8827. ACMD_DEF2("reloadpcdb", reload),
  8828. ACMD_DEF2("reloadmotd", reload),
  8829. ACMD_DEF2("reloadquestdb", reload),
  8830. ACMD_DEF2("reloadmsgconf", reload),
  8831. ACMD_DEF2("reloadinstancedb", reload),
  8832. ACMD_DEF2("reloadachievementdb",reload),
  8833. ACMD_DEF2("reloadattendancedb",reload),
  8834. ACMD_DEF(partysharelvl),
  8835. ACMD_DEF(mapinfo),
  8836. ACMD_DEF(dye),
  8837. ACMD_DEF2("hairstyle", hair_style),
  8838. ACMD_DEF2("haircolor", hair_color),
  8839. ACMD_DEF2("allstats", stat_all),
  8840. ACMD_DEF2("block", char_block),
  8841. ACMD_DEF2("ban", char_ban),
  8842. ACMD_DEF2("unblock", char_unblock),
  8843. ACMD_DEF2("unban", char_unban),
  8844. ACMD_DEF2("charban", char_ban),
  8845. ACMD_DEF2("charunban", char_unban),
  8846. ACMD_DEF2("mount", mount_peco),
  8847. ACMD_DEF(guildspy),
  8848. ACMD_DEF(partyspy),
  8849. ACMD_DEF(clanspy),
  8850. ACMD_DEF(repairall),
  8851. ACMD_DEF(guildrecall),
  8852. ACMD_DEF(partyrecall),
  8853. ACMD_DEF(nuke),
  8854. ACMD_DEF(shownpc),
  8855. ACMD_DEF(hidenpc),
  8856. ACMD_DEF(loadnpc),
  8857. ACMD_DEF(unloadnpc),
  8858. ACMD_DEF(reloadnpcfile),
  8859. ACMD_DEF2("time", servertime),
  8860. ACMD_DEF(jail),
  8861. ACMD_DEF(unjail),
  8862. ACMD_DEF(jailfor),
  8863. ACMD_DEF(jailtime),
  8864. ACMD_DEF(disguise),
  8865. ACMD_DEF(undisguise),
  8866. ACMD_DEF(email),
  8867. ACMD_DEF(effect),
  8868. ACMD_DEF(follow),
  8869. ACMD_DEF(addwarp),
  8870. ACMD_DEF(skillon),
  8871. ACMD_DEF(skilloff),
  8872. ACMD_DEF(killer),
  8873. ACMD_DEF(npcmove),
  8874. ACMD_DEF(killable),
  8875. ACMD_DEF(dropall),
  8876. ACMD_DEF(storeall),
  8877. ACMD_DEF(skillid),
  8878. ACMD_DEF(useskill),
  8879. ACMD_DEF(displayskill),
  8880. ACMD_DEF(snow),
  8881. ACMD_DEF(sakura),
  8882. ACMD_DEF(clouds),
  8883. ACMD_DEF(clouds2),
  8884. ACMD_DEF(fog),
  8885. ACMD_DEF(fireworks),
  8886. ACMD_DEF(leaves),
  8887. ACMD_DEF(summon),
  8888. ACMD_DEF(adjgroup),
  8889. ACMD_DEF(trade),
  8890. ACMD_DEF(send),
  8891. ACMD_DEF(setbattleflag),
  8892. ACMD_DEF(unmute),
  8893. ACMD_DEF(clearweather),
  8894. ACMD_DEF(uptime),
  8895. ACMD_DEF(changesex),
  8896. ACMD_DEF(changecharsex),
  8897. ACMD_DEF(mute),
  8898. ACMD_DEF(refresh),
  8899. ACMD_DEF(refreshall),
  8900. ACMD_DEF(identify),
  8901. ACMD_DEF(identifyall),
  8902. ACMD_DEF(gmotd),
  8903. ACMD_DEF(misceffect),
  8904. ACMD_DEF(mobsearch),
  8905. ACMD_DEF(cleanmap),
  8906. ACMD_DEF(cleanarea),
  8907. ACMD_DEF(npctalk),
  8908. ACMD_DEF(pettalk),
  8909. ACMD_DEF(users),
  8910. ACMD_DEF(reset),
  8911. ACMD_DEF(skilltree),
  8912. ACMD_DEF(marry),
  8913. ACMD_DEF(divorce),
  8914. ACMD_DEF(sound),
  8915. ACMD_DEF(undisguiseall),
  8916. ACMD_DEF(disguiseall),
  8917. ACMD_DEF(changelook),
  8918. ACMD_DEF(autoloot),
  8919. ACMD_DEF2("alootid", autolootitem),
  8920. ACMD_DEF(autoloottype),
  8921. ACMD_DEF(mobinfo),
  8922. ACMD_DEF(exp),
  8923. ACMD_DEF(version),
  8924. ACMD_DEF(mutearea),
  8925. ACMD_DEF(rates),
  8926. ACMD_DEF(iteminfo),
  8927. ACMD_DEF(whodrops),
  8928. ACMD_DEF(whereis),
  8929. ACMD_DEF(mapflag),
  8930. ACMD_DEF(me),
  8931. ACMD_DEF(monsterignore),
  8932. ACMD_DEF(fakename),
  8933. ACMD_DEF(size),
  8934. ACMD_DEF(showexp),
  8935. ACMD_DEF(showzeny),
  8936. ACMD_DEF(showdelay),
  8937. ACMD_DEF(autotrade),
  8938. ACMD_DEF(changegm),
  8939. ACMD_DEF(changeleader),
  8940. ACMD_DEF(partyoption),
  8941. ACMD_DEF(invite),
  8942. ACMD_DEF(duel),
  8943. ACMD_DEF(leave),
  8944. ACMD_DEF(accept),
  8945. ACMD_DEF(reject),
  8946. ACMD_DEF(clone),
  8947. ACMD_DEF2("slaveclone", clone),
  8948. ACMD_DEF2("evilclone", clone),
  8949. ACMD_DEF(tonpc),
  8950. ACMD_DEF(commands),
  8951. ACMD_DEF(noask),
  8952. ACMD_DEF(request),
  8953. ACMD_DEF(homlevel),
  8954. ACMD_DEF(homevolution),
  8955. ACMD_DEF(hommutate),
  8956. ACMD_DEF(makehomun),
  8957. ACMD_DEF(homfriendly),
  8958. ACMD_DEF(homhungry),
  8959. ACMD_DEF(homtalk),
  8960. ACMD_DEF(hominfo),
  8961. ACMD_DEF(homstats),
  8962. ACMD_DEF(homshuffle),
  8963. ACMD_DEF(showmobs),
  8964. ACMD_DEF(feelreset),
  8965. ACMD_DEF(auction),
  8966. ACMD_DEF(mail),
  8967. ACMD_DEF2("noks", ksprotection),
  8968. ACMD_DEF(allowks),
  8969. ACMD_DEF(cash),
  8970. ACMD_DEF2("points", cash),
  8971. ACMD_DEF(agitstart2),
  8972. ACMD_DEF(agitend2),
  8973. ACMD_DEF(resetskill),
  8974. ACMD_DEF(resetstat),
  8975. ACMD_DEF2("storagelist", itemlist),
  8976. ACMD_DEF2("cartlist", itemlist),
  8977. ACMD_DEF2("itemlist", itemlist),
  8978. ACMD_DEF(stats),
  8979. ACMD_DEF(delitem),
  8980. ACMD_DEF(charcommands),
  8981. ACMD_DEF(font),
  8982. ACMD_DEF(accinfo),
  8983. ACMD_DEF(set),
  8984. ACMD_DEF(undisguiseguild),
  8985. ACMD_DEF(disguiseguild),
  8986. ACMD_DEF(sizeall),
  8987. ACMD_DEF(sizeguild),
  8988. ACMD_DEF(addperm),
  8989. ACMD_DEF2("rmvperm", addperm),
  8990. ACMD_DEF(unloadnpcfile),
  8991. ACMD_DEF(cart),
  8992. ACMD_DEF(mount2),
  8993. ACMD_DEF(join),
  8994. ACMD_DEFR(channel,ATCMD_NOSCRIPT),
  8995. ACMD_DEF(fontcolor),
  8996. ACMD_DEF(langtype),
  8997. #ifdef VIP_ENABLE
  8998. ACMD_DEF(vip),
  8999. ACMD_DEF(showrate),
  9000. #endif
  9001. ACMD_DEF(fullstrip),
  9002. ACMD_DEF(costume),
  9003. ACMD_DEF(cloneequip),
  9004. ACMD_DEF(clonestat),
  9005. ACMD_DEF(bodystyle),
  9006. ACMD_DEF(adopt),
  9007. ACMD_DEF(agitstart3),
  9008. ACMD_DEF(agitend3),
  9009. ACMD_DEFR(limitedsale, ATCMD_NOCONSOLE|ATCMD_NOAUTOTRADE),
  9010. ACMD_DEFR(changedress, ATCMD_NOCONSOLE|ATCMD_NOAUTOTRADE),
  9011. ACMD_DEFR(camerainfo, ATCMD_NOCONSOLE|ATCMD_NOAUTOTRADE),
  9012. ACMD_DEFR(resurrect, ATCMD_NOCONSOLE),
  9013. ACMD_DEF2("setquest", quest),
  9014. ACMD_DEF2("erasequest", quest),
  9015. ACMD_DEF2("completequest", quest),
  9016. ACMD_DEF2("checkquest", quest),
  9017. };
  9018. AtCommandInfo* atcommand;
  9019. int i;
  9020. for( i = 0; i < ARRAYLENGTH(atcommand_base); i++ ) {
  9021. if(atcommand_exists(atcommand_base[i].command)) { // Should not happen if atcommand_base[] array is OK
  9022. ShowDebug("atcommand_basecommands: duplicate ACMD_DEF for '%s'.\n", atcommand_base[i].command);
  9023. continue;
  9024. }
  9025. CREATE(atcommand, AtCommandInfo, 1);
  9026. safestrncpy(atcommand->command, atcommand_base[i].command, sizeof(atcommand->command));
  9027. atcommand->func = atcommand_base[i].func;
  9028. atcommand->restriction = atcommand_base[i].restriction;
  9029. strdb_put(atcommand_db, atcommand->command, atcommand);
  9030. }
  9031. return;
  9032. }
  9033. /*==========================================
  9034. * Command lookup functions
  9035. *------------------------------------------*/
  9036. bool atcommand_exists(const char* name)
  9037. {
  9038. return strdb_exists(atcommand_db, name);
  9039. }
  9040. static AtCommandInfo* get_atcommandinfo_byname(const char *name)
  9041. {
  9042. if (strdb_exists(atcommand_db, name))
  9043. return (AtCommandInfo*)strdb_get(atcommand_db, name);
  9044. return NULL;
  9045. }
  9046. /// AtCommand suggestion
  9047. static void atcommand_get_suggestions(struct map_session_data* sd, const char *name, bool atcommand) {
  9048. DBIterator* atcommand_iter;
  9049. AtCommandInfo* command_info = NULL;
  9050. AtCommandType type = atcommand ? COMMAND_ATCOMMAND : COMMAND_CHARCOMMAND;
  9051. char* full_match[MAX_SUGGESTIONS];
  9052. char* suggestions[MAX_SUGGESTIONS];
  9053. char* match;
  9054. int prefix_count = 0, full_count = 0;
  9055. bool can_use;
  9056. if (!battle_config.atcommand_suggestions_enabled)
  9057. return;
  9058. atcommand_iter = db_iterator(atcommand_db);
  9059. // Build the matches
  9060. for (command_info = (AtCommandInfo*)dbi_first(atcommand_iter); dbi_exists(atcommand_iter); command_info = (AtCommandInfo*)dbi_next(atcommand_iter)) {
  9061. match = strstr(command_info->command, name);
  9062. can_use = pc_can_use_command(sd, command_info->command, type);
  9063. if ( prefix_count < MAX_SUGGESTIONS && match == command_info->command && can_use ) {
  9064. suggestions[prefix_count] = command_info->command;
  9065. ++prefix_count;
  9066. }
  9067. if ( full_count < MAX_SUGGESTIONS && match != NULL && match != command_info->command && can_use ) {
  9068. full_match[full_count] = command_info->command;
  9069. ++full_count;
  9070. }
  9071. }
  9072. for( auto& pair : atcommand_alias_db ){
  9073. std::shared_ptr<s_atcommand_alias_info> info = pair.second;
  9074. if( pc_can_use_command( sd, info->command->command, type ) ){
  9075. for( const std::string& alias_str : info->aliases ){
  9076. char* alias = const_cast<char *>(alias_str.c_str());
  9077. match = strstr( alias, name );
  9078. if( prefix_count < MAX_SUGGESTIONS && match == alias ){
  9079. suggestions[prefix_count] = alias;
  9080. ++prefix_count;
  9081. }
  9082. if( full_count < MAX_SUGGESTIONS && match != NULL && match != alias ){
  9083. full_match[full_count] = alias;
  9084. ++full_count;
  9085. }
  9086. }
  9087. }
  9088. }
  9089. if ((full_count+prefix_count) > 0) {
  9090. char buffer[512];
  9091. int i;
  9092. // Merge full match and prefix match results
  9093. if (prefix_count < MAX_SUGGESTIONS) {
  9094. memmove(&suggestions[prefix_count], full_match, sizeof(char*) * (MAX_SUGGESTIONS-prefix_count));
  9095. prefix_count = min(prefix_count+full_count, MAX_SUGGESTIONS);
  9096. }
  9097. // Build the suggestion string
  9098. strcpy(buffer, msg_txt(sd,205)); // Maybe you meant:
  9099. strcat(buffer,"\n");
  9100. for(i=0; i < prefix_count; ++i) {
  9101. strcat(buffer,suggestions[i]);
  9102. strcat(buffer," ");
  9103. }
  9104. clif_displaymessage(sd->fd, buffer);
  9105. }
  9106. dbi_destroy(atcommand_iter);
  9107. }
  9108. /**
  9109. * Executes an at-command
  9110. * @param fd
  9111. * @param sd
  9112. * @param message
  9113. * @param type
  9114. * 0 : script call (atcommand)
  9115. * 1 : normal player @atcommand
  9116. * 2 : console (admin:@atcommand)
  9117. * 3 : script call (useatcmd)
  9118. */
  9119. bool is_atcommand(const int fd, struct map_session_data* sd, const char* message, int type)
  9120. {
  9121. char command[CHAT_SIZE_MAX], params[CHAT_SIZE_MAX];
  9122. char output[CHAT_SIZE_MAX];
  9123. //Reconstructed message
  9124. char atcmd_msg[CHAT_SIZE_MAX * 2];
  9125. TBL_PC * ssd = NULL; //sd for target
  9126. AtCommandInfo * info;
  9127. bool is_atcommand = true; // false if it's a charcommand
  9128. nullpo_retr(false, sd);
  9129. //Shouldn't happen
  9130. if ( !message || !*message )
  9131. return false;
  9132. //If cannot use atcomamnd while talking with NPC [Kichi]
  9133. if (type == 1 && sd->npc_id && sd->state.disable_atcommand_on_npc)
  9134. return false;
  9135. //Block NOCHAT but do not display it as a normal message
  9136. if ( sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCOMMAND )
  9137. return true;
  9138. // skip 10/11-langtype's codepage indicator, if detected
  9139. if ( message[0] == '|' && strlen(message) >= 4 && (message[3] == atcommand_symbol || message[3] == charcommand_symbol) )
  9140. message += 3;
  9141. //Should display as a normal message
  9142. if ( *message != atcommand_symbol && *message != charcommand_symbol )
  9143. return false;
  9144. // type value 0|2 = script|console invoked: bypass restrictions
  9145. if ( type == 1 || type == 3) {
  9146. //Commands are disabled on maps flagged as 'nocommand'
  9147. if ( pc_get_group_level(sd) < map_getmapflag(sd->bl.m, MF_NOCOMMAND) ) {
  9148. clif_displaymessage(fd, msg_txt(sd,143)); // Commands are disabled on this map.
  9149. return false;
  9150. }
  9151. }
  9152. if (*message == charcommand_symbol)
  9153. is_atcommand = false;
  9154. if (is_atcommand) { // @command
  9155. sprintf(atcmd_msg, "%s", message);
  9156. ssd = sd;
  9157. } else { // #command
  9158. char charname[NAME_LENGTH];
  9159. int n;
  9160. //Checks to see if #command has a name or a name + parameters.
  9161. if ((n = sscanf(message, "%255s \"%23[^\"]\" %255[^\n]", command, charname, params)) < 2
  9162. && (n = sscanf(message, "%255s %23s %255[^\n]", command, charname, params)) < 2
  9163. ) {
  9164. if (pc_get_group_level(sd) == 0) {
  9165. if (n < 1)
  9166. return false; // No command found. Display as normal message.
  9167. info = get_atcommandinfo_byname(atcommand_alias_db.checkAlias(command + 1));
  9168. 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
  9169. return false;
  9170. }
  9171. sprintf(output, msg_txt(sd,1388), charcommand_symbol); // Charcommand failed (usage: %c<command> <char name> <parameters>).
  9172. clif_displaymessage(fd, output);
  9173. return true;
  9174. }
  9175. ssd = map_nick2sd(charname,true);
  9176. if (ssd == NULL) {
  9177. sprintf(output, msg_txt(sd,1389), command); // %s failed. Player not found.
  9178. clif_displaymessage(fd, output);
  9179. return true;
  9180. }
  9181. if (n > 2)
  9182. sprintf(atcmd_msg, "%s %s", command, params);
  9183. else
  9184. sprintf(atcmd_msg, "%s", command);
  9185. }
  9186. if (battle_config.idletime_option&IDLE_ATCOMMAND)
  9187. sd->idletime = last_tick;
  9188. if (battle_config.hom_idle_no_share && sd->hd && battle_config.idletime_hom_option&IDLE_ATCOMMAND)
  9189. sd->idletime_hom = last_tick;
  9190. //Clearing these to be used once more.
  9191. memset(command, '\0', sizeof(command));
  9192. memset(params, '\0', sizeof(params));
  9193. //check to see if any params exist within this command
  9194. if( sscanf(atcmd_msg, "%255s %255[^\n]", command, params) < 2 )
  9195. params[0] = '\0';
  9196. if (type == 1 && (sd->state.block_action & PCBLOCK_COMMANDS)) {
  9197. sprintf(output,msg_txt(sd,154), command); // %s failed.
  9198. clif_displaymessage(fd, output);
  9199. return true;
  9200. }
  9201. // @commands (script based)
  9202. if((type == 1 || type == 3) && atcmd_binding_count > 0) {
  9203. struct atcmd_binding_data *binding = get_atcommandbind_byname(command);
  9204. // Check if the binding isn't NULL and there is a NPC event, level of usage met, et cetera
  9205. if( binding != NULL && binding->npc_event[0] &&
  9206. ((is_atcommand && pc_get_group_level(sd) >= binding->level) ||
  9207. (!is_atcommand && pc_get_group_level(sd) >= binding->level2)))
  9208. {
  9209. // Check if self or character invoking; if self == character invoked, then self invoke.
  9210. npc_do_atcmd_event(ssd, command, params, binding->npc_event);
  9211. return true;
  9212. }
  9213. }
  9214. //Grab the command information and check for the proper GM level required to use it or if the command exists
  9215. info = get_atcommandinfo_byname(atcommand_alias_db.checkAlias(command + 1));
  9216. if (info == NULL) {
  9217. if (pc_get_group_level(sd) == 0) // TODO: remove or replace with proper permission
  9218. return false;
  9219. sprintf(output, msg_txt(sd,153), command); // "%s is Unknown Command."
  9220. clif_displaymessage(fd, output);
  9221. atcommand_get_suggestions(sd, command + 1, is_atcommand);
  9222. return true;
  9223. }
  9224. //check restriction
  9225. if (info->restriction) {
  9226. if (info->restriction&ATCMD_NOCONSOLE && type == 2) //console prevent
  9227. return true;
  9228. if (info->restriction&ATCMD_NOSCRIPT && (type == 0 || type == 3)) //scripts prevent
  9229. return true;
  9230. if (info->restriction&ATCMD_NOAUTOTRADE && (type == 0 || type == 3)
  9231. && ((is_atcommand && sd && sd->state.autotrade) || (ssd && ssd->state.autotrade)))
  9232. return true;
  9233. }
  9234. // type == 1 : player invoked
  9235. if (type == 1) {
  9236. if ((is_atcommand && info->at_groups[sd->group_pos] == 0) ||
  9237. (!is_atcommand && info->char_groups[sd->group_pos] == 0) )
  9238. return false;
  9239. if( pc_isdead(sd) && pc_has_permission(sd,PC_PERM_DISABLE_CMD_DEAD) ) {
  9240. clif_displaymessage(fd, msg_txt(sd,1393)); // You can't use commands while dead
  9241. return true;
  9242. }
  9243. }
  9244. //Attempt to use the command
  9245. if ( (info->func(fd, ssd, command, params) != 0) )
  9246. {
  9247. sprintf(output,msg_txt(sd,154), command); // %s failed.
  9248. clif_displaymessage(fd, output);
  9249. return true;
  9250. }
  9251. //Log only if successful.
  9252. log_atcommand(sd, is_atcommand ? atcmd_msg : message);
  9253. return true;
  9254. }
  9255. void atcommand_db_load_groups(int* group_ids) {
  9256. DBIterator *iter = db_iterator(atcommand_db);
  9257. AtCommandInfo* cmd;
  9258. int i;
  9259. for (cmd = (AtCommandInfo*)dbi_first(iter); dbi_exists(iter); cmd = (AtCommandInfo*)dbi_next(iter)) {
  9260. cmd->at_groups = (char*)aMalloc( pc_group_max * sizeof(char) );
  9261. cmd->char_groups = (char*)aMalloc( pc_group_max * sizeof(char) );
  9262. for(i = 0; i < pc_group_max; i++) {
  9263. if( pc_group_can_use_command(group_ids[i], cmd->command, COMMAND_ATCOMMAND ) )
  9264. cmd->at_groups[i] = 1;
  9265. else
  9266. cmd->at_groups[i] = 0;
  9267. if( pc_group_can_use_command(group_ids[i], cmd->command, COMMAND_CHARCOMMAND ) )
  9268. cmd->char_groups[i] = 1;
  9269. else
  9270. cmd->char_groups[i] = 0;
  9271. }
  9272. }
  9273. dbi_destroy(iter);
  9274. return;
  9275. }
  9276. void atcommand_db_clear(void) {
  9277. if (atcommand_db != NULL) {
  9278. DBIterator *iter = db_iterator(atcommand_db);
  9279. AtCommandInfo* cmd;
  9280. for (cmd = (AtCommandInfo*)dbi_first(iter); dbi_exists(iter); cmd = (AtCommandInfo*)dbi_next(iter)) {
  9281. aFree(cmd->at_groups);
  9282. aFree(cmd->char_groups);
  9283. }
  9284. dbi_destroy(iter);
  9285. db_destroy(atcommand_db);
  9286. }
  9287. atcommand_alias_db.clear();
  9288. }
  9289. void atcommand_doload(void) {
  9290. atcommand_db_clear();
  9291. atcommand_db = stridb_alloc((DBOptions)(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA), ATCOMMAND_LENGTH);
  9292. atcommand_basecommands(); //fills initial atcommand_db with known commands
  9293. atcommand_alias_db.load();
  9294. }
  9295. void do_init_atcommand(void) {
  9296. atcommand_doload();
  9297. }
  9298. void do_final_atcommand(void) {
  9299. atcommand_db_clear();
  9300. }