atcommand.c 304 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210
  1. // Copyright (c) Athena Dev Teams - Licensed under GNU GPL
  2. // For more information, see LICENCE in the main folder
  3. #include "../common/cbasetypes.h"
  4. #include "../common/mmo.h"
  5. #include "../common/timer.h"
  6. #include "../common/nullpo.h"
  7. #include "../common/core.h"
  8. #include "../common/showmsg.h"
  9. #include "../common/malloc.h"
  10. #include "../common/random.h"
  11. #include "../common/socket.h"
  12. #include "../common/strlib.h"
  13. #include "../common/utils.h"
  14. #include "../common/conf.h"
  15. #include "map.h"
  16. #include "atcommand.h"
  17. #include "battle.h"
  18. #include "chat.h"
  19. #include "channel.h"
  20. #include "clif.h"
  21. #include "chrif.h"
  22. #include "duel.h"
  23. #include "instance.h"
  24. #include "intif.h"
  25. #include "itemdb.h"
  26. #include "log.h"
  27. #include "pc.h"
  28. #include "pc_groups.h" // groupid2name
  29. #include "status.h"
  30. #include "skill.h"
  31. #include "mob.h"
  32. #include "npc.h"
  33. #include "pet.h"
  34. #include "homunculus.h"
  35. #include "mail.h"
  36. #include "mercenary.h"
  37. #include "elemental.h"
  38. #include "party.h"
  39. #include "guild.h"
  40. #include "script.h"
  41. #include "storage.h"
  42. #include "trade.h"
  43. #include "unit.h"
  44. #include "mapreg.h"
  45. #include "quest.h"
  46. #include <stdio.h>
  47. #include <stdlib.h>
  48. #include <string.h>
  49. #include <math.h>
  50. #define ATCOMMAND_LENGTH 50
  51. #define ACMD_FUNC(x) static int atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message)
  52. typedef struct AtCommandInfo AtCommandInfo;
  53. typedef struct AliasInfo AliasInfo;
  54. int atcmd_binding_count = 0;
  55. struct AtCommandInfo {
  56. char command[ATCOMMAND_LENGTH];
  57. AtCommandFunc func;
  58. char* at_groups;/* quick @commands "can-use" lookup */
  59. char* char_groups;/* quick @charcommands "can-use" lookup */
  60. int restriction; //prevent : 1 console, 2 script...
  61. };
  62. struct AliasInfo {
  63. AtCommandInfo *command;
  64. char alias[ATCOMMAND_LENGTH];
  65. };
  66. char atcommand_symbol = '@'; // first char of the commands
  67. char charcommand_symbol = '#';
  68. static DBMap* atcommand_db = NULL; //name -> AtCommandInfo
  69. static DBMap* atcommand_alias_db = NULL; //alias -> AtCommandInfo
  70. static config_t atcommand_config;
  71. static char atcmd_output[CHAT_SIZE_MAX];
  72. static char atcmd_player_name[NAME_LENGTH];
  73. static AtCommandInfo* get_atcommandinfo_byname(const char *name); // @help
  74. static const char* atcommand_checkalias(const char *aliasname); // @help
  75. static void atcommand_get_suggestions(struct map_session_data* sd, const char *name, bool atcommand); // @help
  76. static void warp_get_suggestions(struct map_session_data* sd, const char *name); // @rura, @warp, @mapmove
  77. // @commands (script-based)
  78. struct atcmd_binding_data* get_atcommandbind_byname(const char* name) {
  79. int i = 0;
  80. if( *name == atcommand_symbol || *name == charcommand_symbol )
  81. name++; // for backwards compatibility
  82. ARR_FIND( 0, atcmd_binding_count, i, strcmpi(atcmd_binding[i]->command, name) == 0 );
  83. return ( i < atcmd_binding_count ) ? atcmd_binding[i] : NULL;
  84. }
  85. /**
  86. * retrieves the help string associated with a given command.
  87. *
  88. * @param name the name of the command to retrieve help information for
  89. * @return the string associated with the command, or NULL
  90. */
  91. static const char* atcommand_help_string(const char* command)
  92. {
  93. const char* str = NULL;
  94. config_setting_t* info;
  95. if( *command == atcommand_symbol || *command == charcommand_symbol )
  96. {// remove the prefix symbol for the raw name of the command
  97. command ++;
  98. }
  99. // convert alias to the real command name
  100. command = atcommand_checkalias(command);
  101. // attempt to find the first default help command
  102. info = config_lookup(&atcommand_config, "help");
  103. if( info == NULL )
  104. {// failed to find the help property in the configuration file
  105. return NULL;
  106. }
  107. if( !config_setting_lookup_string( info, command, &str ) )
  108. {// failed to find the matching help string
  109. return NULL;
  110. }
  111. // push the result from the method
  112. return str;
  113. }
  114. /*==========================================
  115. * @send (used for testing packet sends from the client)
  116. *------------------------------------------*/
  117. ACMD_FUNC(send)
  118. {
  119. int len=0,type;
  120. // read message type as hex number (without the 0x)
  121. if(!message || !*message ||
  122. !((sscanf(message, "len %x", &type)==1 && (len=1))
  123. || sscanf(message, "%x", &type)==1) )
  124. {
  125. int i;
  126. for (i = 900; i <= 903; ++i)
  127. clif_displaymessage(fd, msg_txt(sd,i));
  128. return -1;
  129. }
  130. #define PARSE_ERROR(error,p) \
  131. {\
  132. clif_displaymessage(fd, (error));\
  133. sprintf(atcmd_output, ">%s", (p));\
  134. clif_displaymessage(fd, atcmd_output);\
  135. }
  136. //define PARSE_ERROR
  137. #define CHECK_EOS(p) \
  138. if(*(p) == 0){\
  139. clif_displaymessage(fd, "Unexpected end of string");\
  140. return -1;\
  141. }
  142. //define CHECK_EOS
  143. #define SKIP_VALUE(p) \
  144. {\
  145. while(*(p) && !ISSPACE(*(p))) ++(p); /* non-space */\
  146. while(*(p) && ISSPACE(*(p))) ++(p); /* space */\
  147. }
  148. //define SKIP_VALUE
  149. #define GET_VALUE(p,num) \
  150. {\
  151. if(sscanf((p), "x%lx", &(num)) < 1 && sscanf((p), "%ld ", &(num)) < 1){\
  152. PARSE_ERROR("Invalid number in:",(p));\
  153. return -1;\
  154. }\
  155. }
  156. //define GET_VALUE
  157. if (type > 0 && type < MAX_PACKET_DB) {
  158. int off,end;
  159. long num;
  160. if(len)
  161. {// show packet length
  162. sprintf(atcmd_output, msg_txt(sd,904), type, packet_db[sd->packet_ver][type].len); // Packet 0x%x length: %d
  163. clif_displaymessage(fd, atcmd_output);
  164. return 0;
  165. }
  166. len=packet_db[sd->packet_ver][type].len;
  167. off=2;
  168. if(len == 0)
  169. {// unknown packet - ERROR
  170. sprintf(atcmd_output, msg_txt(sd,905), type); // Unknown packet: 0x%x
  171. clif_displaymessage(fd, atcmd_output);
  172. return -1;
  173. } else if(len == -1)
  174. {// dynamic packet
  175. len=SHRT_MAX-4; // maximum length
  176. off=4;
  177. }
  178. WFIFOHEAD(fd, len);
  179. WFIFOW(fd,0)=TOW(type);
  180. // parse packet contents
  181. SKIP_VALUE(message);
  182. while(*message != 0 && off < len){
  183. if(ISDIGIT(*message) || *message == '-' || *message == '+')
  184. {// default (byte)
  185. GET_VALUE(message,num);
  186. WFIFOB(fd,off)=TOB(num);
  187. ++off;
  188. } else if(TOUPPER(*message) == 'B')
  189. {// byte
  190. ++message;
  191. GET_VALUE(message,num);
  192. WFIFOB(fd,off)=TOB(num);
  193. ++off;
  194. } else if(TOUPPER(*message) == 'W')
  195. {// word (2 bytes)
  196. ++message;
  197. GET_VALUE(message,num);
  198. WFIFOW(fd,off)=TOW(num);
  199. off+=2;
  200. } else if(TOUPPER(*message) == 'L')
  201. {// long word (4 bytes)
  202. ++message;
  203. GET_VALUE(message,num);
  204. WFIFOL(fd,off)=TOL(num);
  205. off+=4;
  206. } else if(TOUPPER(*message) == 'S')
  207. {// string - escapes are valid
  208. // get string length - num <= 0 means not fixed length (default)
  209. ++message;
  210. if(*message == '"'){
  211. num=0;
  212. } else {
  213. GET_VALUE(message,num);
  214. while(*message != '"')
  215. {// find start of string
  216. if(*message == 0 || ISSPACE(*message)){
  217. PARSE_ERROR(msg_txt(sd,906),message); // Not a string:
  218. return -1;
  219. }
  220. ++message;
  221. }
  222. }
  223. // parse string
  224. ++message;
  225. CHECK_EOS(message);
  226. end=(num<=0? 0: min(off+((int)num),len));
  227. for(; *message != '"' && (off < end || end == 0); ++off){
  228. if(*message == '\\'){
  229. ++message;
  230. CHECK_EOS(message);
  231. switch(*message){
  232. case 'a': num=0x07; break; // Bell
  233. case 'b': num=0x08; break; // Backspace
  234. case 't': num=0x09; break; // Horizontal tab
  235. case 'n': num=0x0A; break; // Line feed
  236. case 'v': num=0x0B; break; // Vertical tab
  237. case 'f': num=0x0C; break; // Form feed
  238. case 'r': num=0x0D; break; // Carriage return
  239. case 'e': num=0x1B; break; // Escape
  240. default: num=*message; break;
  241. case 'x': // Hexadecimal
  242. {
  243. ++message;
  244. CHECK_EOS(message);
  245. if(!ISXDIGIT(*message)){
  246. PARSE_ERROR(msg_txt(sd,907),message); // Not a hexadecimal digit:
  247. return -1;
  248. }
  249. num=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  250. if(ISXDIGIT(*message)){
  251. ++message;
  252. CHECK_EOS(message);
  253. num<<=8;
  254. num+=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  255. }
  256. WFIFOB(fd,off)=TOB(num);
  257. ++message;
  258. CHECK_EOS(message);
  259. continue;
  260. }
  261. case '0':
  262. case '1':
  263. case '2':
  264. case '3':
  265. case '4':
  266. case '5':
  267. case '6':
  268. case '7': // Octal
  269. {
  270. num=*message-'0'; // 1st octal digit
  271. ++message;
  272. CHECK_EOS(message);
  273. if(ISDIGIT(*message) && *message < '8'){
  274. num<<=3;
  275. num+=*message-'0'; // 2nd octal digit
  276. ++message;
  277. CHECK_EOS(message);
  278. if(ISDIGIT(*message) && *message < '8'){
  279. num<<=3;
  280. num+=*message-'0'; // 3rd octal digit
  281. ++message;
  282. CHECK_EOS(message);
  283. }
  284. }
  285. WFIFOB(fd,off)=TOB(num);
  286. continue;
  287. }
  288. }
  289. } else
  290. num=*message;
  291. WFIFOB(fd,off)=TOB(num);
  292. ++message;
  293. CHECK_EOS(message);
  294. }//for
  295. while(*message != '"')
  296. {// ignore extra characters
  297. ++message;
  298. CHECK_EOS(message);
  299. }
  300. // terminate the string
  301. if(off < end)
  302. {// fill the rest with 0's
  303. memset(WFIFOP(fd,off),0,end-off);
  304. off=end;
  305. }
  306. } else
  307. {// unknown
  308. PARSE_ERROR(msg_txt(sd,908),message); // Unknown type of value in:
  309. return -1;
  310. }
  311. SKIP_VALUE(message);
  312. }
  313. if(packet_db[sd->packet_ver][type].len == -1)
  314. {// send dynamic packet
  315. WFIFOW(fd,2)=TOW(off);
  316. WFIFOSET(fd,off);
  317. } else
  318. {// send static packet
  319. if(off < len)
  320. memset(WFIFOP(fd,off),0,len-off);
  321. WFIFOSET(fd,len);
  322. }
  323. } else {
  324. clif_displaymessage(fd, msg_txt(sd,259)); // Invalid packet
  325. return -1;
  326. }
  327. sprintf (atcmd_output, msg_txt(sd,258), type, type); // Sent packet 0x%x (%d)
  328. clif_displaymessage(fd, atcmd_output);
  329. return 0;
  330. #undef PARSE_ERROR
  331. #undef CHECK_EOS
  332. #undef SKIP_VALUE
  333. #undef GET_VALUE
  334. }
  335. /**
  336. * Retrieves map name suggestions for a given string.
  337. * This will first check if any map names contain the given string, and will
  338. * print out MAX_SUGGESTIONS results if any maps are found.
  339. * Otherwise, suggestions will be calculated through Levenshtein distance,
  340. * and up to 5 of the closest matches will be printed.
  341. *
  342. * @author Euphy
  343. */
  344. static void warp_get_suggestions(struct map_session_data* sd, const char *name) {
  345. char buffer[512];
  346. int i, count = 0;
  347. if (strlen(name) < 2)
  348. return;
  349. // build the suggestion string
  350. strcpy(buffer, msg_txt(sd, 205)); // Maybe you meant:
  351. strcat(buffer, "\n");
  352. // check for maps that contain string
  353. for (i = 0; i < MAX_MAP_PER_SERVER; i++) {
  354. if (count < MAX_SUGGESTIONS && strstr(map[i].name, name) != NULL) {
  355. strcat(buffer, map[i].name);
  356. strcat(buffer, " ");
  357. if (++count >= MAX_SUGGESTIONS)
  358. break;
  359. }
  360. }
  361. // if no maps found, search by edit distance
  362. if (!count) {
  363. unsigned int distance[MAX_MAP_PER_SERVER][2];
  364. int j;
  365. // calculate Levenshtein distance for all maps
  366. for (i = 0; i < MAX_MAP_PER_SERVER; i++) {
  367. if (strlen(map[i].name) < 4) // invalid map name?
  368. distance[i][0] = INT_MAX;
  369. else {
  370. distance[i][0] = levenshtein(map[i].name, name);
  371. distance[i][1] = i;
  372. }
  373. }
  374. // selection sort elements as needed
  375. count = min(MAX_SUGGESTIONS, 5); // results past 5 aren't worth showing
  376. for (i = 0; i < count; i++) {
  377. int min = i;
  378. for (j = i+1; j < MAX_MAP_PER_SERVER; j++) {
  379. if (distance[j][0] < distance[min][0])
  380. min = j;
  381. }
  382. // print map name
  383. if (distance[min][0] > 4) { // awful results, don't bother
  384. if (!i) return;
  385. break;
  386. }
  387. strcat(buffer, map[distance[min][1]].name);
  388. strcat(buffer, " ");
  389. // swap elements
  390. swap(distance[i][0], distance[min][0]);
  391. swap(distance[i][1], distance[min][1]);
  392. }
  393. }
  394. clif_displaymessage(sd->fd, buffer);
  395. }
  396. /*==========================================
  397. * @rura, @warp, @mapmove
  398. *------------------------------------------*/
  399. ACMD_FUNC(mapmove)
  400. {
  401. char map_name[MAP_NAME_LENGTH_EXT];
  402. unsigned short mapindex;
  403. short x = 0, y = 0;
  404. int16 m = -1;
  405. nullpo_retr(-1, sd);
  406. memset(map_name, '\0', sizeof(map_name));
  407. if (!message || !*message ||
  408. (sscanf(message, "%15s %hd %hd", map_name, &x, &y) < 3 &&
  409. sscanf(message, "%15[^,],%hd,%hd", map_name, &x, &y) < 1)) {
  410. clif_displaymessage(fd, msg_txt(sd,909)); // Please enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).
  411. return -1;
  412. }
  413. mapindex = mapindex_name2id(map_name);
  414. if (mapindex)
  415. m = map_mapindex2mapid(mapindex);
  416. if (!mapindex) { // m < 0 means on different server! [Kevin]
  417. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  418. if (battle_config.warp_suggestions_enabled)
  419. warp_get_suggestions(sd, map_name);
  420. return -1;
  421. }
  422. if ((x || y) && map_getcell(m, x, y, CELL_CHKNOPASS))
  423. { //This is to prevent the pc_setpos call from printing an error.
  424. clif_displaymessage(fd, msg_txt(sd,2));
  425. if (!map_search_freecell(NULL, m, &x, &y, 10, 10, 1))
  426. x = y = 0; //Invalid cell, use random spot.
  427. }
  428. if (map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  429. clif_displaymessage(fd, msg_txt(sd,247));
  430. return -1;
  431. }
  432. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  433. clif_displaymessage(fd, msg_txt(sd,248));
  434. return -1;
  435. }
  436. if (pc_setpos(sd, mapindex, x, y, CLR_TELEPORT) != 0) {
  437. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  438. return -1;
  439. }
  440. clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
  441. return 0;
  442. }
  443. /*==========================================
  444. * Displays where a character is. Corrected version by Silent. [Skotlex]
  445. *------------------------------------------*/
  446. ACMD_FUNC(where)
  447. {
  448. struct map_session_data* pl_sd;
  449. nullpo_retr(-1, sd);
  450. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  451. if (!message || !*message || sscanf(message, "%23s[^\n]", atcmd_player_name) < 1) {
  452. clif_displaymessage(fd, msg_txt(sd,910)); // Please enter a player name (usage: @where <char name>).
  453. return -1;
  454. }
  455. pl_sd = map_nick2sd(atcmd_player_name);
  456. if (pl_sd == NULL ||
  457. strncmp(pl_sd->status.name, atcmd_player_name, NAME_LENGTH) != 0 ||
  458. (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))
  459. ) {
  460. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  461. return -1;
  462. }
  463. 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);
  464. clif_displaymessage(fd, atcmd_output);
  465. return 0;
  466. }
  467. /*==========================================
  468. *
  469. *------------------------------------------*/
  470. ACMD_FUNC(jumpto)
  471. {
  472. struct map_session_data *pl_sd = NULL;
  473. nullpo_retr(-1, sd);
  474. if (!message || !*message) {
  475. clif_displaymessage(fd, msg_txt(sd,911)); // Please enter a player name (usage: @jumpto/@warpto/@goto <char name/ID>).
  476. return -1;
  477. }
  478. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  479. {
  480. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  481. return -1;
  482. }
  483. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  484. {
  485. clif_displaymessage(fd, msg_txt(sd,247)); // You are not authorized to warp to this map.
  486. return -1;
  487. }
  488. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  489. {
  490. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  491. return -1;
  492. }
  493. if( pc_isdead(sd) )
  494. {
  495. clif_displaymessage(fd, msg_txt(sd,664));
  496. return -1;
  497. }
  498. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  499. sprintf(atcmd_output, msg_txt(sd,4), pl_sd->status.name); // Jumped to %s
  500. clif_displaymessage(fd, atcmd_output);
  501. return 0;
  502. }
  503. /*==========================================
  504. *
  505. *------------------------------------------*/
  506. ACMD_FUNC(jump)
  507. {
  508. short x = 0, y = 0;
  509. nullpo_retr(-1, sd);
  510. memset(atcmd_output, '\0', sizeof(atcmd_output));
  511. sscanf(message, "%hd %hd", &x, &y);
  512. if (map[sd->bl.m].flag.noteleport && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  513. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  514. return -1;
  515. }
  516. if( pc_isdead(sd) )
  517. {
  518. clif_displaymessage(fd, msg_txt(sd,664));
  519. return -1;
  520. }
  521. if ((x || y) && map_getcell(sd->bl.m, x, y, CELL_CHKNOPASS))
  522. { //This is to prevent the pc_setpos call from printing an error.
  523. clif_displaymessage(fd, msg_txt(sd,2));
  524. if (!map_search_freecell(NULL, sd->bl.m, &x, &y, 10, 10, 1))
  525. x = y = 0; //Invalid cell, use random spot.
  526. }
  527. pc_setpos(sd, sd->mapindex, x, y, CLR_TELEPORT);
  528. sprintf(atcmd_output, msg_txt(sd,5), sd->bl.x, sd->bl.y); // Jumped to %d %d
  529. clif_displaymessage(fd, atcmd_output);
  530. return 0;
  531. }
  532. /*==========================================
  533. * Display list of online characters with
  534. * various info.
  535. *------------------------------------------*/
  536. ACMD_FUNC(who) {
  537. struct map_session_data *pl_sd = NULL;
  538. struct s_mapiterator *iter = NULL;
  539. char player_name[NAME_LENGTH] = "";
  540. int count = 0;
  541. int level = 0;
  542. StringBuf buf;
  543. /**
  544. * 1 = @who : Player name, [Title], [Party name], [Guild name]
  545. * 2 = @who2 : Player name, [Title], BLvl, JLvl, Job
  546. * 3 = @who3 : [CID/AID] Player name [Title], Map, X, Y
  547. */
  548. int display_type = 1;
  549. int map_id = -1;
  550. nullpo_retr(-1, sd);
  551. if (strstr(command, "map") != NULL) {
  552. char map_name[MAP_NAME_LENGTH_EXT] = "";
  553. if (sscanf(message, "%15s %23s", map_name, player_name) < 1 || (map_id = map_mapname2mapid(map_name)) < 0)
  554. map_id = sd->bl.m;
  555. } else {
  556. sscanf(message, "%23s", player_name);
  557. }
  558. if (strstr(command, "2") != NULL)
  559. display_type = 2;
  560. else if (strstr(command, "3") != NULL)
  561. display_type = 3;
  562. level = pc_get_group_level(sd);
  563. StringBuf_Init(&buf);
  564. iter = mapit_getallusers();
  565. for (pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter)) {
  566. if (!((pc_has_permission(pl_sd, PC_PERM_HIDE_SESSION) || (pl_sd->sc.option & OPTION_INVISIBLE)) && pc_get_group_level(pl_sd) > level)) { // you can look only lower or same level
  567. if (stristr(pl_sd->status.name, player_name) == NULL // search with no case sensitive
  568. || (map_id >= 0 && pl_sd->bl.m != map_id))
  569. continue;
  570. switch (display_type) {
  571. case 2: {
  572. StringBuf_Printf(&buf, msg_txt(sd,343), pl_sd->status.name); // "Name: %s "
  573. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  574. StringBuf_Printf(&buf, msg_txt(sd,344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
  575. StringBuf_Printf(&buf, msg_txt(sd,347), pl_sd->status.base_level, pl_sd->status.job_level,
  576. job_name(pl_sd->status.class_)); // "| Lv:%d/%d | Job: %s"
  577. break;
  578. }
  579. case 3: {
  580. if (pc_has_permission(sd, PC_PERM_WHO_DISPLAY_AID))
  581. StringBuf_Printf(&buf, msg_txt(sd,912), pl_sd->status.char_id, pl_sd->status.account_id); // "(CID:%d/AID:%d) "
  582. StringBuf_Printf(&buf, msg_txt(sd,343), pl_sd->status.name); // "Name: %s "
  583. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  584. StringBuf_Printf(&buf, msg_txt(sd,344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
  585. StringBuf_Printf(&buf, msg_txt(sd,348), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y); // "| Location: %s %d %d"
  586. break;
  587. }
  588. default: {
  589. struct party_data *p = party_search(pl_sd->status.party_id);
  590. struct guild *g = pl_sd->guild;
  591. StringBuf_Printf(&buf, msg_txt(sd,343), pl_sd->status.name); // "Name: %s "
  592. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  593. StringBuf_Printf(&buf, msg_txt(sd,344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
  594. if (p != NULL)
  595. StringBuf_Printf(&buf, msg_txt(sd,345), p->party.name); // " | Party: '%s'"
  596. if (g != NULL)
  597. StringBuf_Printf(&buf, msg_txt(sd,346), g->name); // " | Guild: '%s'"
  598. break;
  599. }
  600. }
  601. clif_displaymessage(fd, StringBuf_Value(&buf));
  602. StringBuf_Clear(&buf);
  603. count++;
  604. }
  605. }
  606. mapit_free(iter);
  607. if (map_id < 0) {
  608. if (count == 0)
  609. StringBuf_Printf(&buf, msg_txt(sd,28)); // No player found.
  610. else if (count == 1)
  611. StringBuf_Printf(&buf, msg_txt(sd,29)); // 1 player found.
  612. else
  613. StringBuf_Printf(&buf, msg_txt(sd,30), count); // %d players found.
  614. } else {
  615. if (count == 0)
  616. StringBuf_Printf(&buf, msg_txt(sd,54), map[map_id].name); // No player found in map '%s'.
  617. else if (count == 1)
  618. StringBuf_Printf(&buf, msg_txt(sd,55), map[map_id].name); // 1 player found in map '%s'.
  619. else
  620. StringBuf_Printf(&buf, msg_txt(sd,56), count, map[map_id].name); // %d players found in map '%s'.
  621. }
  622. clif_displaymessage(fd, StringBuf_Value(&buf));
  623. StringBuf_Destroy(&buf);
  624. return 0;
  625. }
  626. /*==========================================
  627. *
  628. *------------------------------------------*/
  629. ACMD_FUNC(whogm)
  630. {
  631. struct map_session_data* pl_sd;
  632. struct s_mapiterator* iter;
  633. int j, count;
  634. int level;
  635. char match_text[CHAT_SIZE_MAX];
  636. char player_name[NAME_LENGTH];
  637. struct guild *g;
  638. struct party_data *p;
  639. nullpo_retr(-1, sd);
  640. memset(atcmd_output, '\0', sizeof(atcmd_output));
  641. memset(match_text, '\0', sizeof(match_text));
  642. memset(player_name, '\0', sizeof(player_name));
  643. if (sscanf(message, "%199[^\n]", match_text) < 1)
  644. strcpy(match_text, "");
  645. for (j = 0; match_text[j]; j++)
  646. match_text[j] = TOLOWER(match_text[j]);
  647. count = 0;
  648. level = pc_get_group_level(sd);
  649. iter = mapit_getallusers();
  650. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  651. {
  652. int pl_level = pc_get_group_level(pl_sd);
  653. if (!pl_level)
  654. continue;
  655. if (match_text[0])
  656. {
  657. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  658. for (j = 0; player_name[j]; j++)
  659. player_name[j] = TOLOWER(player_name[j]);
  660. // search with no case sensitive
  661. if (strstr(player_name, match_text) == NULL)
  662. continue;
  663. }
  664. if (pl_level > level) {
  665. if (pl_sd->sc.option & OPTION_INVISIBLE)
  666. continue;
  667. sprintf(atcmd_output, msg_txt(sd,913), pl_sd->status.name); // Name: %s (GM)
  668. clif_displaymessage(fd, atcmd_output);
  669. count++;
  670. continue;
  671. }
  672. sprintf(atcmd_output, msg_txt(sd,914), // Name: %s (GM:%d) | Location: %s %d %d
  673. pl_sd->status.name, pl_level,
  674. mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  675. clif_displaymessage(fd, atcmd_output);
  676. sprintf(atcmd_output, msg_txt(sd,915), // BLvl: %d | Job: %s (Lvl: %d)
  677. pl_sd->status.base_level,
  678. job_name(pl_sd->status.class_), pl_sd->status.job_level);
  679. clif_displaymessage(fd, atcmd_output);
  680. p = party_search(pl_sd->status.party_id);
  681. g = pl_sd->guild;
  682. sprintf(atcmd_output,msg_txt(sd,916), // Party: '%s' | Guild: '%s'
  683. p?p->party.name:msg_txt(sd,917), g?g->name:msg_txt(sd,917)); // None.
  684. clif_displaymessage(fd, atcmd_output);
  685. count++;
  686. }
  687. mapit_free(iter);
  688. if (count == 0)
  689. clif_displaymessage(fd, msg_txt(sd,150)); // No GM found.
  690. else if (count == 1)
  691. clif_displaymessage(fd, msg_txt(sd,151)); // 1 GM found.
  692. else {
  693. sprintf(atcmd_output, msg_txt(sd,152), count); // %d GMs found.
  694. clif_displaymessage(fd, atcmd_output);
  695. }
  696. return 0;
  697. }
  698. /*==========================================
  699. *
  700. *------------------------------------------*/
  701. ACMD_FUNC(save)
  702. {
  703. nullpo_retr(-1, sd);
  704. if( map[sd->bl.m].instance_id ) {
  705. clif_displaymessage(fd, msg_txt(sd,383)); // You cannot create a savepoint in an instance.
  706. return 1;
  707. }
  708. pc_setsavepoint(sd, sd->mapindex, sd->bl.x, sd->bl.y);
  709. if (sd->status.pet_id > 0 && sd->pd)
  710. intif_save_petdata(sd->status.account_id, &sd->pd->pet);
  711. chrif_save(sd,0);
  712. clif_displaymessage(fd, msg_txt(sd,6)); // Your save point has been changed.
  713. return 0;
  714. }
  715. /*==========================================
  716. *
  717. *------------------------------------------*/
  718. ACMD_FUNC(load)
  719. {
  720. int16 m;
  721. nullpo_retr(-1, sd);
  722. m = map_mapindex2mapid(sd->status.save_point.map);
  723. if (m >= 0 && map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  724. clif_displaymessage(fd, msg_txt(sd,249)); // You are not authorized to warp to your save map.
  725. return -1;
  726. }
  727. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  728. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  729. return -1;
  730. }
  731. pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, CLR_OUTSIGHT);
  732. clif_displaymessage(fd, msg_txt(sd,7)); // Warping to save point..
  733. return 0;
  734. }
  735. /*==========================================
  736. *
  737. *------------------------------------------*/
  738. ACMD_FUNC(speed)
  739. {
  740. int speed;
  741. nullpo_retr(-1, sd);
  742. memset(atcmd_output, '\0', sizeof(atcmd_output));
  743. if (!message || !*message || sscanf(message, "%d", &speed) < 1) {
  744. sprintf(atcmd_output, msg_txt(sd,918), MIN_WALK_SPEED, MAX_WALK_SPEED); // Please enter a speed value (usage: @speed <%d-%d>).
  745. clif_displaymessage(fd, atcmd_output);
  746. return -1;
  747. }
  748. if (speed < 0) {
  749. sd->base_status.speed = DEFAULT_WALK_SPEED;
  750. sd->state.permanent_speed = 0; // Remove lock when set back to default speed.
  751. } else {
  752. sd->base_status.speed = cap_value(speed, MIN_WALK_SPEED, MAX_WALK_SPEED);
  753. sd->state.permanent_speed = 1; // Set lock when set to non-default speed.
  754. }
  755. status_calc_bl(&sd->bl, SCB_SPEED);
  756. clif_displaymessage(fd, msg_txt(sd,8)); // Speed changed.
  757. return 0;
  758. }
  759. /*==========================================
  760. *
  761. *------------------------------------------*/
  762. ACMD_FUNC(storage)
  763. {
  764. nullpo_retr(-1, sd);
  765. if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading || sd->state.storage_flag)
  766. return -1;
  767. if (storage_storageopen(sd) == 1)
  768. { //Already open.
  769. clif_displaymessage(fd, msg_txt(sd,250));
  770. return -1;
  771. }
  772. clif_displaymessage(fd, msg_txt(sd,919)); // Storage opened.
  773. return 0;
  774. }
  775. /*==========================================
  776. *
  777. *------------------------------------------*/
  778. ACMD_FUNC(guildstorage)
  779. {
  780. nullpo_retr(-1, sd);
  781. if (!sd->status.guild_id) {
  782. clif_displaymessage(fd, msg_txt(sd,252));
  783. return -1;
  784. }
  785. if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading)
  786. return -1;
  787. if (sd->state.storage_flag == 1) {
  788. clif_displaymessage(fd, msg_txt(sd,250));
  789. return -1;
  790. }
  791. if (sd->state.storage_flag == 2) {
  792. clif_displaymessage(fd, msg_txt(sd,251));
  793. return -1;
  794. }
  795. storage_guild_storageopen(sd);
  796. clif_displaymessage(fd, msg_txt(sd,920)); // Guild storage opened.
  797. return 0;
  798. }
  799. /*==========================================
  800. *
  801. *------------------------------------------*/
  802. ACMD_FUNC(option)
  803. {
  804. int param1 = 0, param2 = 0, param3 = 0;
  805. nullpo_retr(-1, sd);
  806. if (!message || !*message || sscanf(message, "%d %d %d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0)
  807. {// failed to match the parameters so inform the user of the options
  808. const char* text;
  809. // attempt to find the setting information for this command
  810. text = atcommand_help_string( command );
  811. // notify the user of the requirement to enter an option
  812. clif_displaymessage(fd, msg_txt(sd,921)); // Please enter at least one option.
  813. if( text )
  814. {// send the help text associated with this command
  815. clif_displaymessage( fd, text );
  816. }
  817. return -1;
  818. }
  819. sd->sc.opt1 = param1;
  820. sd->sc.opt2 = param2;
  821. pc_setoption(sd, param3);
  822. clif_displaymessage(fd, msg_txt(sd,9)); // Options changed.
  823. return 0;
  824. }
  825. /*==========================================
  826. *
  827. *------------------------------------------*/
  828. ACMD_FUNC(hide)
  829. {
  830. nullpo_retr(-1, sd);
  831. if (sd->sc.option & OPTION_INVISIBLE) {
  832. sd->sc.option &= ~OPTION_INVISIBLE;
  833. if (sd->disguise)
  834. status_set_viewdata(&sd->bl, sd->disguise);
  835. else
  836. status_set_viewdata(&sd->bl, sd->status.class_);
  837. clif_displaymessage(fd, msg_txt(sd,10)); // Invisible: Off
  838. // increment the number of pvp players on the map
  839. map[sd->bl.m].users_pvp++;
  840. if( map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.pvp_nocalcrank )
  841. {// register the player for ranking calculations
  842. sd->pvp_timer = add_timer( gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0 );
  843. }
  844. //bugreport:2266
  845. map_foreachinmovearea(clif_insight, &sd->bl, AREA_SIZE, sd->bl.x, sd->bl.y, BL_ALL, &sd->bl);
  846. } else {
  847. sd->sc.option |= OPTION_INVISIBLE;
  848. sd->vd.class_ = INVISIBLE_CLASS;
  849. clif_displaymessage(fd, msg_txt(sd,11)); // Invisible: On
  850. // decrement the number of pvp players on the map
  851. map[sd->bl.m].users_pvp--;
  852. if( map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.pvp_nocalcrank && sd->pvp_timer != INVALID_TIMER )
  853. {// unregister the player for ranking
  854. delete_timer( sd->pvp_timer, pc_calc_pvprank_timer );
  855. sd->pvp_timer = INVALID_TIMER;
  856. }
  857. }
  858. clif_changeoption(&sd->bl);
  859. return 0;
  860. }
  861. /*==========================================
  862. * Changes a character's class
  863. *------------------------------------------*/
  864. ACMD_FUNC(jobchange)
  865. {
  866. int job = 0, upper = 0;
  867. const char* text;
  868. nullpo_retr(-1, sd);
  869. if (!message || !*message || sscanf(message, "%d %d", &job, &upper) < 1) {
  870. int i;
  871. bool found = false;
  872. upper = 0;
  873. // Normal Jobs
  874. for( i = JOB_NOVICE; i < JOB_MAX_BASIC && !found; i++ ) {
  875. if (strncmpi(message, job_name(i), 16) == 0) {
  876. job = i;
  877. found = true;
  878. }
  879. }
  880. // High Jobs, Babys and Third
  881. for( i = JOB_NOVICE_HIGH; i < JOB_MAX && !found; i++ ) {
  882. if (strncmpi(message, job_name(i), 16) == 0) {
  883. job = i;
  884. found = true;
  885. }
  886. }
  887. if (!found) {
  888. text = atcommand_help_string(command);
  889. if (text)
  890. clif_displaymessage(fd, text);
  891. return -1;
  892. }
  893. }
  894. if (job == JOB_KNIGHT2 || job == JOB_CRUSADER2 || job == JOB_WEDDING || job == JOB_XMAS || job == JOB_SUMMER || job == JOB_HANBOK || job == JOB_OKTOBERFEST
  895. || job == JOB_LORD_KNIGHT2 || job == JOB_PALADIN2 || job == JOB_BABY_KNIGHT2 || job == JOB_BABY_CRUSADER2 || job == JOB_STAR_GLADIATOR2
  896. || (job >= JOB_RUNE_KNIGHT2 && job <= JOB_MECHANIC_T2) || (job >= JOB_BABY_RUNE2 && job <= JOB_BABY_MECHANIC2))
  897. { // Deny direct transformation into dummy jobs
  898. clif_displaymessage(fd, msg_txt(sd,923)); //"You can not change to this job by command."
  899. return 0;
  900. }
  901. if (pcdb_checkid(job))
  902. {
  903. if (pc_jobchange(sd, job, upper) == 0)
  904. clif_displaymessage(fd, msg_txt(sd,12)); // Your job has been changed.
  905. else {
  906. clif_displaymessage(fd, msg_txt(sd,155)); // You are unable to change your job.
  907. return -1;
  908. }
  909. } else {
  910. text = atcommand_help_string(command);
  911. if (text)
  912. clif_displaymessage(fd, text);
  913. return -1;
  914. }
  915. return 0;
  916. }
  917. /*==========================================
  918. *
  919. *------------------------------------------*/
  920. ACMD_FUNC(kill)
  921. {
  922. nullpo_retr(-1, sd);
  923. status_kill(&sd->bl);
  924. clif_displaymessage(sd->fd, msg_txt(sd,13)); // A pity! You've died.
  925. if (fd != sd->fd)
  926. clif_displaymessage(fd, msg_txt(sd,14)); // Character killed.
  927. return 0;
  928. }
  929. /*==========================================
  930. *
  931. *------------------------------------------*/
  932. ACMD_FUNC(alive)
  933. {
  934. nullpo_retr(-1, sd);
  935. if (!status_revive(&sd->bl, 100, 100))
  936. {
  937. clif_displaymessage(fd, msg_txt(sd,667));
  938. return -1;
  939. }
  940. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  941. clif_displaymessage(fd, msg_txt(sd,16)); // You've been revived! It's a miracle!
  942. return 0;
  943. }
  944. /*==========================================
  945. * +kamic [LuzZza]
  946. *------------------------------------------*/
  947. ACMD_FUNC(kami)
  948. {
  949. unsigned long color=0;
  950. nullpo_retr(-1, sd);
  951. memset(atcmd_output, '\0', sizeof(atcmd_output));
  952. if(*(command + 5) != 'c' && *(command + 5) != 'C') {
  953. if (!message || !*message) {
  954. clif_displaymessage(fd, msg_txt(sd,980)); // Please enter a message (usage: @kami <message>).
  955. return -1;
  956. }
  957. sscanf(message, "%199[^\n]", atcmd_output);
  958. if (strstr(command, "l") != NULL)
  959. clif_broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT, ALL_SAMEMAP);
  960. else
  961. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, (*(command + 5) == 'b' || *(command + 5) == 'B') ? BC_BLUE : BC_DEFAULT);
  962. } else {
  963. if(!message || !*message || (sscanf(message, "%lx %199[^\n]", &color, atcmd_output) < 2)) {
  964. clif_displaymessage(fd, msg_txt(sd,981)); // Please enter color and message (usage: @kamic <color> <message>).
  965. return -1;
  966. }
  967. if(color > 0xFFFFFF) {
  968. clif_displaymessage(fd, msg_txt(sd,982)); // Invalid color.
  969. return -1;
  970. }
  971. intif_broadcast2(atcmd_output, strlen(atcmd_output) + 1, color, 0x190, 12, 0, 0);
  972. }
  973. return 0;
  974. }
  975. /*==========================================
  976. *
  977. *------------------------------------------*/
  978. ACMD_FUNC(heal)
  979. {
  980. int hp = 0, sp = 0; // [Valaris] thanks to fov
  981. nullpo_retr(-1, sd);
  982. sscanf(message, "%d %d", &hp, &sp);
  983. // some overflow checks
  984. if( hp == INT_MIN ) hp++;
  985. if( sp == INT_MIN ) sp++;
  986. if ( hp == 0 && sp == 0 ) {
  987. if (!status_percent_heal(&sd->bl, 100, 100))
  988. clif_displaymessage(fd, msg_txt(sd,157)); // HP and SP have already been recovered.
  989. else
  990. clif_displaymessage(fd, msg_txt(sd,17)); // HP, SP recovered.
  991. return 0;
  992. }
  993. if ( hp > 0 && sp >= 0 ) {
  994. if(!status_heal(&sd->bl, hp, sp, 0))
  995. clif_displaymessage(fd, msg_txt(sd,157)); // HP and SP are already with the good value.
  996. else
  997. clif_displaymessage(fd, msg_txt(sd,17)); // HP, SP recovered.
  998. return 0;
  999. }
  1000. if ( hp < 0 && sp <= 0 ) {
  1001. status_damage(NULL, &sd->bl, -hp, -sp, 0, 0);
  1002. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, 4, 0);
  1003. clif_displaymessage(fd, msg_txt(sd,156)); // HP or/and SP modified.
  1004. return 0;
  1005. }
  1006. //Opposing signs.
  1007. if ( hp ) {
  1008. if (hp > 0)
  1009. status_heal(&sd->bl, hp, 0, 0);
  1010. else {
  1011. status_damage(NULL, &sd->bl, -hp, 0, 0, 0);
  1012. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, 4, 0);
  1013. }
  1014. }
  1015. if ( sp ) {
  1016. if (sp > 0)
  1017. status_heal(&sd->bl, 0, sp, 0);
  1018. else
  1019. status_damage(NULL, &sd->bl, 0, -sp, 0, 0);
  1020. }
  1021. clif_displaymessage(fd, msg_txt(sd,156)); // HP or/and SP modified.
  1022. return 0;
  1023. }
  1024. /*==========================================
  1025. * @item command (usage: @item <itemdid1:itemid2:itemname:..> <quantity>) (modified by [Yor] for pet_egg)
  1026. * @itembound command (usage: @itembound <name/id_of_item> <quantity> <bound_type>)
  1027. *------------------------------------------*/
  1028. ACMD_FUNC(item)
  1029. {
  1030. char item_name[100];
  1031. int number = 0, flag = 0, bound = 0;
  1032. struct item item_tmp;
  1033. struct item_data *item_data[10];
  1034. int get_count, i, j=0;
  1035. char *itemlist;
  1036. nullpo_retr(-1, sd);
  1037. memset(item_name, '\0', sizeof(item_name));
  1038. if (!strcmpi(command+1,"itembound") && (!message || !*message || (
  1039. sscanf(message, "\"%99[^\"]\" %d %d", item_name, &number, &bound) < 2 &&
  1040. sscanf(message, "%99s %d %d", item_name, &number, &bound) < 2
  1041. ))) {
  1042. clif_displaymessage(fd, msg_txt(sd,295)); // Please enter an item name or ID (usage: @item <item name/ID> <quantity> <bound_type>).
  1043. return -1;
  1044. } else if (!message || !*message || (
  1045. sscanf(message, "\"%99[^\"]\" %d", item_name, &number) < 1 &&
  1046. sscanf(message, "%99s %d", item_name, &number) < 1
  1047. )) {
  1048. clif_displaymessage(fd, msg_txt(sd,983)); // Please enter an item name or ID (usage: @item <item name/ID> <quantity>).
  1049. return -1;
  1050. }
  1051. itemlist = strtok(item_name, ":");
  1052. while (itemlist != NULL && j<10) {
  1053. if ((item_data[j] = itemdb_searchname(itemlist)) == NULL &&
  1054. (item_data[j] = itemdb_exists(atoi(itemlist))) == NULL){
  1055. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  1056. return -1;
  1057. }
  1058. itemlist = strtok(NULL, ":"); //next itemline
  1059. j++;
  1060. }
  1061. if( bound < 0 || bound > 4 ) {
  1062. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1063. return -1;
  1064. }
  1065. if (number <= 0)
  1066. number = 1;
  1067. get_count = number;
  1068. for(j--; j>=0; j--){ //produce items in list
  1069. int16 item_id = item_data[j]->nameid;
  1070. //Check if it's stackable.
  1071. if (!itemdb_isstackable2(item_data[j]))
  1072. get_count = 1;
  1073. for (i = 0; i < number; i += get_count) {
  1074. // if not pet egg
  1075. if (!pet_create_egg(sd, item_id)) {
  1076. memset(&item_tmp, 0, sizeof(item_tmp));
  1077. item_tmp.nameid = item_id;
  1078. item_tmp.identify = 1;
  1079. item_tmp.bound = bound;
  1080. if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
  1081. clif_additem(sd, 0, 0, flag);
  1082. }
  1083. }
  1084. }
  1085. if (flag == 0)
  1086. clif_displaymessage(fd, msg_txt(sd,18)); // Item created.
  1087. return 0;
  1088. }
  1089. /*==========================================
  1090. *
  1091. *------------------------------------------*/
  1092. ACMD_FUNC(item2)
  1093. {
  1094. struct item item_tmp;
  1095. struct item_data *item_data;
  1096. char item_name[100];
  1097. int item_id, number = 0, bound = 0;
  1098. int identify = 0, refine = 0, attr = 0;
  1099. int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  1100. nullpo_retr(-1, sd);
  1101. memset(item_name, '\0', sizeof(item_name));
  1102. if (!strcmpi(command+1,"itembound2") && (!message || !*message || (
  1103. sscanf(message, "\"%99[^\"]\" %d %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4, &bound) < 10 &&
  1104. sscanf(message, "%99s %d %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4, &bound) < 10 ))) {
  1105. clif_displaymessage(fd, msg_txt(sd,296)); // Please enter all parameters (usage: @item2 <item name/ID> <quantity>
  1106. clif_displaymessage(fd, msg_txt(sd,297)); // <identify_flag> <refine> <attribute> <card1> <card2> <card3> <card4> <bound_type>).
  1107. return -1;
  1108. } else if ( !message || !*message || (
  1109. sscanf(message, "\"%99[^\"]\" %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9 &&
  1110. sscanf(message, "%99s %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9
  1111. )) {
  1112. clif_displaymessage(fd, msg_txt(sd,984)); // Please enter all parameters (usage: @item2 <item name/ID> <quantity>
  1113. clif_displaymessage(fd, msg_txt(sd,985)); // <identify_flag> <refine> <attribute> <card1> <card2> <card3> <card4>).
  1114. return -1;
  1115. }
  1116. if (number <= 0)
  1117. number = 1;
  1118. if( bound < 0 || bound > 4 ) {
  1119. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1120. return -1;
  1121. }
  1122. item_id = 0;
  1123. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  1124. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  1125. item_id = item_data->nameid;
  1126. if (item_id > 500) {
  1127. int flag = 0;
  1128. int loop, get_count, i;
  1129. loop = 1;
  1130. get_count = number;
  1131. if (item_data->type == IT_WEAPON || item_data->type == IT_ARMOR ||
  1132. item_data->type == IT_PETEGG || item_data->type == IT_PETARMOR) {
  1133. loop = number;
  1134. get_count = 1;
  1135. if (item_data->type == IT_PETEGG) {
  1136. identify = 1;
  1137. refine = 0;
  1138. }
  1139. if (item_data->type == IT_PETARMOR)
  1140. refine = 0;
  1141. if (refine > MAX_REFINE)
  1142. refine = MAX_REFINE;
  1143. } else {
  1144. identify = 1;
  1145. refine = attr = 0;
  1146. }
  1147. for (i = 0; i < loop; i++) {
  1148. memset(&item_tmp, 0, sizeof(item_tmp));
  1149. item_tmp.nameid = item_id;
  1150. item_tmp.identify = identify;
  1151. item_tmp.refine = refine;
  1152. item_tmp.attribute = attr;
  1153. item_tmp.card[0] = c1;
  1154. item_tmp.card[1] = c2;
  1155. item_tmp.card[2] = c3;
  1156. item_tmp.card[3] = c4;
  1157. item_tmp.bound = bound;
  1158. if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
  1159. clif_additem(sd, 0, 0, flag);
  1160. }
  1161. if (flag == 0)
  1162. clif_displaymessage(fd, msg_txt(sd,18)); // Item created.
  1163. } else {
  1164. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  1165. return -1;
  1166. }
  1167. return 0;
  1168. }
  1169. /*==========================================
  1170. *
  1171. *------------------------------------------*/
  1172. ACMD_FUNC(itemreset)
  1173. {
  1174. int i;
  1175. nullpo_retr(-1, sd);
  1176. for (i = 0; i < MAX_INVENTORY; i++) {
  1177. if (sd->status.inventory[i].amount && sd->status.inventory[i].equip == 0) {
  1178. pc_delitem(sd, i, sd->status.inventory[i].amount, 0, 0, LOG_TYPE_COMMAND);
  1179. }
  1180. }
  1181. clif_displaymessage(fd, msg_txt(sd,20)); // All of your items have been removed.
  1182. return 0;
  1183. }
  1184. /*==========================================
  1185. * Atcommand @lvlup
  1186. *------------------------------------------*/
  1187. ACMD_FUNC(baselevelup)
  1188. {
  1189. int level=0, i=0, status_point=0;
  1190. nullpo_retr(-1, sd);
  1191. level = atoi(message);
  1192. if (!message || !*message || !level) {
  1193. clif_displaymessage(fd, msg_txt(sd,986)); // Please enter a level adjustment (usage: @lvup/@blevel/@baselvlup <number of levels>).
  1194. return -1;
  1195. }
  1196. if (level > 0) {
  1197. if (sd->status.base_level >= pc_maxbaselv(sd)) { // check for max level by Valaris
  1198. clif_displaymessage(fd, msg_txt(sd,47)); // Base level can't go any higher.
  1199. return -1;
  1200. } // End Addition
  1201. if ((unsigned int)level > pc_maxbaselv(sd) || (unsigned int)level > pc_maxbaselv(sd) - sd->status.base_level) // fix positive overflow
  1202. level = pc_maxbaselv(sd) - sd->status.base_level;
  1203. for (i = 0; i < level; i++)
  1204. status_point += pc_gets_status_point(sd->status.base_level + i);
  1205. sd->status.status_point += status_point;
  1206. sd->status.base_level += (unsigned int)level;
  1207. status_percent_heal(&sd->bl, 100, 100);
  1208. clif_misceffect(&sd->bl, 0);
  1209. clif_displaymessage(fd, msg_txt(sd,21)); // Base level raised.
  1210. } else {
  1211. if (sd->status.base_level == 1) {
  1212. clif_displaymessage(fd, msg_txt(sd,158)); // Base level can't go any lower.
  1213. return -1;
  1214. }
  1215. level*=-1;
  1216. if ((unsigned int)level >= sd->status.base_level)
  1217. level = sd->status.base_level-1;
  1218. for (i = 0; i > -level; i--)
  1219. status_point += pc_gets_status_point(sd->status.base_level + i - 1);
  1220. if (sd->status.status_point < status_point)
  1221. pc_resetstate(sd);
  1222. if (sd->status.status_point < status_point)
  1223. sd->status.status_point = 0;
  1224. else
  1225. sd->status.status_point -= status_point;
  1226. sd->status.base_level -= (unsigned int)level;
  1227. clif_displaymessage(fd, msg_txt(sd,22)); // Base level lowered.
  1228. }
  1229. sd->status.base_exp = 0;
  1230. clif_updatestatus(sd, SP_STATUSPOINT);
  1231. clif_updatestatus(sd, SP_BASELEVEL);
  1232. clif_updatestatus(sd, SP_BASEEXP);
  1233. clif_updatestatus(sd, SP_NEXTBASEEXP);
  1234. status_calc_pc(sd, 0);
  1235. pc_baselevelchanged(sd);
  1236. if(sd->status.party_id)
  1237. party_send_levelup(sd);
  1238. return 0;
  1239. }
  1240. /*==========================================
  1241. *
  1242. *------------------------------------------*/
  1243. ACMD_FUNC(joblevelup)
  1244. {
  1245. int level=0;
  1246. nullpo_retr(-1, sd);
  1247. level = atoi(message);
  1248. if (!message || !*message || !level) {
  1249. clif_displaymessage(fd, msg_txt(sd,987)); // Please enter a level adjustment (usage: @joblvup/@jlevel/@joblvlup <number of levels>).
  1250. return -1;
  1251. }
  1252. if (level > 0) {
  1253. if (sd->status.job_level >= pc_maxjoblv(sd)) {
  1254. clif_displaymessage(fd, msg_txt(sd,23)); // Job level can't go any higher.
  1255. return -1;
  1256. }
  1257. if ((unsigned int)level > pc_maxjoblv(sd) || (unsigned int)level > pc_maxjoblv(sd) - sd->status.job_level) // fix positive overflow
  1258. level = pc_maxjoblv(sd) - sd->status.job_level;
  1259. sd->status.job_level += (unsigned int)level;
  1260. sd->status.skill_point += level;
  1261. clif_misceffect(&sd->bl, 1);
  1262. clif_displaymessage(fd, msg_txt(sd,24)); // Job level raised.
  1263. } else {
  1264. if (sd->status.job_level == 1) {
  1265. clif_displaymessage(fd, msg_txt(sd,159)); // Job level can't go any lower.
  1266. return -1;
  1267. }
  1268. level *=-1;
  1269. if ((unsigned int)level >= sd->status.job_level) // fix negative overflow
  1270. level = sd->status.job_level-1;
  1271. sd->status.job_level -= (unsigned int)level;
  1272. if (sd->status.skill_point < level)
  1273. pc_resetskill(sd,0); //Reset skills since we need to subtract more points.
  1274. if (sd->status.skill_point < level)
  1275. sd->status.skill_point = 0;
  1276. else
  1277. sd->status.skill_point -= level;
  1278. clif_displaymessage(fd, msg_txt(sd,25)); // Job level lowered.
  1279. }
  1280. sd->status.job_exp = 0;
  1281. clif_updatestatus(sd, SP_JOBLEVEL);
  1282. clif_updatestatus(sd, SP_JOBEXP);
  1283. clif_updatestatus(sd, SP_NEXTJOBEXP);
  1284. clif_updatestatus(sd, SP_SKILLPOINT);
  1285. status_calc_pc(sd, 0);
  1286. return 0;
  1287. }
  1288. /*==========================================
  1289. * @help
  1290. *------------------------------------------*/
  1291. ACMD_FUNC(help)
  1292. {
  1293. config_setting_t *help;
  1294. const char *text = NULL;
  1295. const char *command_name = NULL;
  1296. char *default_command = "help";
  1297. nullpo_retr(-1, sd);
  1298. help = config_lookup(&atcommand_config, "help");
  1299. if (help == NULL) {
  1300. clif_displaymessage(fd, msg_txt(sd,27)); // "Commands help is not available."
  1301. return -1;
  1302. }
  1303. if (!message || !*message) {
  1304. command_name = default_command; // If no command_name specified, display help for @help.
  1305. } else {
  1306. if (*message == atcommand_symbol || *message == charcommand_symbol)
  1307. ++message;
  1308. command_name = atcommand_checkalias(message);
  1309. }
  1310. if (!pc_can_use_command(sd, command_name, COMMAND_ATCOMMAND)) {
  1311. sprintf(atcmd_output, msg_txt(sd,153), message); // "%s is Unknown Command"
  1312. clif_displaymessage(fd, atcmd_output);
  1313. atcommand_get_suggestions(sd, command_name, true);
  1314. return -1;
  1315. }
  1316. if (!config_setting_lookup_string(help, command_name, &text)) {
  1317. sprintf(atcmd_output, msg_txt(sd,988), atcommand_symbol, command_name); // There is no help for %c%s.
  1318. clif_displaymessage(fd, atcmd_output);
  1319. atcommand_get_suggestions(sd, command_name, true);
  1320. return -1;
  1321. }
  1322. sprintf(atcmd_output, msg_txt(sd,989), atcommand_symbol, command_name); // Help for command %c%s:
  1323. clif_displaymessage(fd, atcmd_output);
  1324. { // Display aliases
  1325. DBIterator* iter;
  1326. AtCommandInfo *command_info;
  1327. AliasInfo *alias_info = NULL;
  1328. StringBuf buf;
  1329. bool has_aliases = false;
  1330. StringBuf_Init(&buf);
  1331. StringBuf_AppendStr(&buf, msg_txt(sd,990)); // Available aliases:
  1332. command_info = get_atcommandinfo_byname(command_name);
  1333. iter = db_iterator(atcommand_alias_db);
  1334. for (alias_info = dbi_first(iter); dbi_exists(iter); alias_info = dbi_next(iter)) {
  1335. if (alias_info->command == command_info) {
  1336. StringBuf_Printf(&buf, " %s", alias_info->alias);
  1337. has_aliases = true;
  1338. }
  1339. }
  1340. dbi_destroy(iter);
  1341. if (has_aliases)
  1342. clif_displaymessage(fd, StringBuf_Value(&buf));
  1343. StringBuf_Destroy(&buf);
  1344. }
  1345. // Display help contents
  1346. clif_displaymessage(fd, text);
  1347. return 0;
  1348. }
  1349. // helper function, used in foreach calls to stop auto-attack timers
  1350. // parameter: '0' - everyone, 'id' - only those attacking someone with that id
  1351. static int atcommand_stopattack(struct block_list *bl,va_list ap)
  1352. {
  1353. struct unit_data *ud = unit_bl2ud(bl);
  1354. int id = va_arg(ap, int);
  1355. if (ud && ud->attacktimer != INVALID_TIMER && (!id || id == ud->target))
  1356. {
  1357. unit_stop_attack(bl);
  1358. return 1;
  1359. }
  1360. return 0;
  1361. }
  1362. /*==========================================
  1363. *
  1364. *------------------------------------------*/
  1365. static int atcommand_pvpoff_sub(struct block_list *bl,va_list ap)
  1366. {
  1367. TBL_PC* sd = (TBL_PC*)bl;
  1368. clif_pvpset(sd, 0, 0, 2);
  1369. if (sd->pvp_timer != INVALID_TIMER) {
  1370. delete_timer(sd->pvp_timer, pc_calc_pvprank_timer);
  1371. sd->pvp_timer = INVALID_TIMER;
  1372. }
  1373. return 0;
  1374. }
  1375. ACMD_FUNC(pvpoff)
  1376. {
  1377. nullpo_retr(-1, sd);
  1378. if (!map[sd->bl.m].flag.pvp) {
  1379. clif_displaymessage(fd, msg_txt(sd,160)); // PvP is already Off.
  1380. return -1;
  1381. }
  1382. map[sd->bl.m].flag.pvp = 0;
  1383. if (!battle_config.pk_mode){
  1384. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING);
  1385. clif_maptypeproperty2(&sd->bl,ALL_SAMEMAP);
  1386. }
  1387. map_foreachinmap(atcommand_pvpoff_sub,sd->bl.m, BL_PC);
  1388. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  1389. clif_displaymessage(fd, msg_txt(sd,31)); // PvP: Off.
  1390. return 0;
  1391. }
  1392. /*==========================================
  1393. *
  1394. *------------------------------------------*/
  1395. static int atcommand_pvpon_sub(struct block_list *bl,va_list ap)
  1396. {
  1397. TBL_PC* sd = (TBL_PC*)bl;
  1398. if (sd->pvp_timer == INVALID_TIMER) {
  1399. sd->pvp_timer = add_timer(gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0);
  1400. sd->pvp_rank = 0;
  1401. sd->pvp_lastusers = 0;
  1402. sd->pvp_point = 5;
  1403. sd->pvp_won = 0;
  1404. sd->pvp_lost = 0;
  1405. }
  1406. return 0;
  1407. }
  1408. ACMD_FUNC(pvpon)
  1409. {
  1410. nullpo_retr(-1, sd);
  1411. if (map[sd->bl.m].flag.pvp) {
  1412. clif_displaymessage(fd, msg_txt(sd,161)); // PvP is already On.
  1413. return -1;
  1414. }
  1415. map[sd->bl.m].flag.pvp = 1;
  1416. if (!battle_config.pk_mode) {// display pvp circle and rank
  1417. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_FREEPVPZONE);
  1418. clif_maptypeproperty2(&sd->bl,ALL_SAMEMAP);
  1419. map_foreachinmap(atcommand_pvpon_sub,sd->bl.m, BL_PC);
  1420. }
  1421. clif_displaymessage(fd, msg_txt(sd,32)); // PvP: On.
  1422. return 0;
  1423. }
  1424. /*==========================================
  1425. *
  1426. *------------------------------------------*/
  1427. ACMD_FUNC(gvgoff)
  1428. {
  1429. nullpo_retr(-1, sd);
  1430. if (!map[sd->bl.m].flag.gvg) {
  1431. clif_displaymessage(fd, msg_txt(sd,162)); // GvG is already Off.
  1432. return -1;
  1433. }
  1434. map[sd->bl.m].flag.gvg = 0;
  1435. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING);
  1436. clif_maptypeproperty2(&sd->bl,ALL_SAMEMAP);
  1437. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  1438. clif_displaymessage(fd, msg_txt(sd,33)); // GvG: Off.
  1439. return 0;
  1440. }
  1441. /*==========================================
  1442. *
  1443. *------------------------------------------*/
  1444. ACMD_FUNC(gvgon)
  1445. {
  1446. nullpo_retr(-1, sd);
  1447. if (map[sd->bl.m].flag.gvg) {
  1448. clif_displaymessage(fd, msg_txt(sd,163)); // GvG is already On.
  1449. return -1;
  1450. }
  1451. map[sd->bl.m].flag.gvg = 1;
  1452. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_AGITZONE);
  1453. clif_maptypeproperty2(&sd->bl,ALL_SAMEMAP);
  1454. clif_displaymessage(fd, msg_txt(sd,34)); // GvG: On.
  1455. return 0;
  1456. }
  1457. /*==========================================
  1458. *
  1459. *------------------------------------------*/
  1460. ACMD_FUNC(model)
  1461. {
  1462. int hair_style = 0, hair_color = 0, cloth_color = 0;
  1463. nullpo_retr(-1, sd);
  1464. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1465. if (!message || !*message || sscanf(message, "%d %d %d", &hair_style, &hair_color, &cloth_color) < 1) {
  1466. 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>).
  1467. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  1468. clif_displaymessage(fd, atcmd_output);
  1469. return -1;
  1470. }
  1471. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  1472. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  1473. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1474. pc_changelook(sd, LOOK_HAIR, hair_style);
  1475. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1476. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1477. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1478. } else {
  1479. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1480. return -1;
  1481. }
  1482. return 0;
  1483. }
  1484. /*==========================================
  1485. * @dye && @ccolor
  1486. *------------------------------------------*/
  1487. ACMD_FUNC(dye)
  1488. {
  1489. int cloth_color = 0;
  1490. nullpo_retr(-1, sd);
  1491. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1492. if (!message || !*message || sscanf(message, "%d", &cloth_color) < 1) {
  1493. 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>).
  1494. clif_displaymessage(fd, atcmd_output);
  1495. return -1;
  1496. }
  1497. if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1498. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1499. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1500. } else {
  1501. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1502. return -1;
  1503. }
  1504. return 0;
  1505. }
  1506. /*==========================================
  1507. * @hairstyle && @hstyle
  1508. *------------------------------------------*/
  1509. ACMD_FUNC(hair_style)
  1510. {
  1511. int hair_style = 0;
  1512. nullpo_retr(-1, sd);
  1513. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1514. if (!message || !*message || sscanf(message, "%d", &hair_style) < 1) {
  1515. 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>).
  1516. clif_displaymessage(fd, atcmd_output);
  1517. return -1;
  1518. }
  1519. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
  1520. pc_changelook(sd, LOOK_HAIR, hair_style);
  1521. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1522. } else {
  1523. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1524. return -1;
  1525. }
  1526. return 0;
  1527. }
  1528. /*==========================================
  1529. * @haircolor && @hcolor
  1530. *------------------------------------------*/
  1531. ACMD_FUNC(hair_color)
  1532. {
  1533. int hair_color = 0;
  1534. nullpo_retr(-1, sd);
  1535. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1536. if (!message || !*message || sscanf(message, "%d", &hair_color) < 1) {
  1537. 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>).
  1538. clif_displaymessage(fd, atcmd_output);
  1539. return -1;
  1540. }
  1541. if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
  1542. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1543. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1544. } else {
  1545. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1546. return -1;
  1547. }
  1548. return 0;
  1549. }
  1550. /*==========================================
  1551. * @go [city_number or city_name] - Updated by Harbin
  1552. *------------------------------------------*/
  1553. ACMD_FUNC(go)
  1554. {
  1555. int i;
  1556. int town;
  1557. char map_name[MAP_NAME_LENGTH];
  1558. int16 m;
  1559. const struct {
  1560. char map[MAP_NAME_LENGTH];
  1561. int x, y;
  1562. } data[] = {
  1563. { MAP_PRONTERA, 156, 191 }, // 0=Prontera
  1564. { MAP_MORROC, 156, 93 }, // 1=Morroc
  1565. { MAP_GEFFEN, 119, 59 }, // 2=Geffen
  1566. { MAP_PAYON, 162, 233 }, // 3=Payon
  1567. { MAP_ALBERTA, 192, 147 }, // 4=Alberta
  1568. #ifdef RENEWAL
  1569. { MAP_IZLUDE, 128, 146 }, // 5=Izlude (Renewal)
  1570. #else
  1571. { MAP_IZLUDE, 128, 114 }, // 5=Izlude
  1572. #endif
  1573. { MAP_ALDEBARAN, 140, 131 }, // 6=Al de Baran
  1574. { MAP_LUTIE, 147, 134 }, // 7=Lutie
  1575. { MAP_COMODO, 209, 143 }, // 8=Comodo
  1576. { MAP_YUNO, 157, 51 }, // 9=Yuno
  1577. { MAP_AMATSU, 198, 84 }, // 10=Amatsu
  1578. { MAP_GONRYUN, 160, 120 }, // 11=Gonryun
  1579. { MAP_UMBALA, 89, 157 }, // 12=Umbala
  1580. { MAP_NIFLHEIM, 21, 153 }, // 13=Niflheim
  1581. { MAP_LOUYANG, 217, 40 }, // 14=Louyang
  1582. { MAP_NOVICE, 53, 111 }, // 15=Training Grounds
  1583. { MAP_JAIL, 23, 61 }, // 16=Prison
  1584. { MAP_JAWAII, 249, 127 }, // 17=Jawaii
  1585. { MAP_AYOTHAYA, 151, 117 }, // 18=Ayothaya
  1586. { MAP_EINBROCH, 64, 200 }, // 19=Einbroch
  1587. { MAP_LIGHTHALZEN, 158, 92 }, // 20=Lighthalzen
  1588. { MAP_EINBECH, 70, 95 }, // 21=Einbech
  1589. { MAP_HUGEL, 96, 145 }, // 22=Hugel
  1590. { MAP_RACHEL, 130, 110 }, // 23=Rachel
  1591. { MAP_VEINS, 216, 123 }, // 24=Veins
  1592. { MAP_MOSCOVIA, 223, 184 }, // 25=Moscovia
  1593. { MAP_MIDCAMP, 180, 240 }, // 26=Midgard Camp
  1594. { MAP_MANUK, 282, 138 }, // 27=Manuk
  1595. { MAP_SPLENDIDE, 201, 147 }, // 28=Splendide
  1596. { MAP_BRASILIS, 182, 239 }, // 29=Brasilis
  1597. { MAP_DICASTES, 198, 187 }, // 30=El Dicastes
  1598. { MAP_MORA, 44, 151 }, // 31=Mora
  1599. { MAP_DEWATA, 200, 180 }, // 32=Dewata
  1600. { MAP_MALANGDO, 140, 114 }, // 33=Malangdo Island
  1601. { MAP_MALAYA, 242, 211 }, // 34=Malaya Port
  1602. { MAP_ECLAGE, 110, 39 }, // 35=Eclage
  1603. };
  1604. nullpo_retr(-1, sd);
  1605. if( map[sd->bl.m].flag.nogo && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE) ) {
  1606. clif_displaymessage(sd->fd,msg_txt(sd,995)); // You cannot use @go on this map.
  1607. return 0;
  1608. }
  1609. memset(map_name, '\0', sizeof(map_name));
  1610. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1611. // get the number
  1612. town = atoi(message);
  1613. if (!message || !*message || sscanf(message, "%11s", map_name) < 1 || town < 0 || town >= ARRAYLENGTH(data))
  1614. {// no value matched so send the list of locations
  1615. const char* text;
  1616. // attempt to find the text help string
  1617. text = atcommand_help_string( command );
  1618. clif_displaymessage(fd, msg_txt(sd,38)); // Invalid location number, or name.
  1619. if( text )
  1620. {// send the text to the client
  1621. clif_displaymessage( fd, text );
  1622. }
  1623. return -1;
  1624. }
  1625. // get possible name of the city
  1626. map_name[MAP_NAME_LENGTH-1] = '\0';
  1627. for (i = 0; map_name[i]; i++)
  1628. map_name[i] = TOLOWER(map_name[i]);
  1629. // try to identify the map name
  1630. if (strncmp(map_name, "prontera", 3) == 0) {
  1631. town = 0;
  1632. } else if (strncmp(map_name, "morocc", 4) == 0 ||
  1633. strncmp(map_name, "morroc", 4) == 0) {
  1634. town = 1;
  1635. } else if (strncmp(map_name, "geffen", 3) == 0) {
  1636. town = 2;
  1637. } else if (strncmp(map_name, "payon", 3) == 0) {
  1638. town = 3;
  1639. } else if (strncmp(map_name, "alberta", 3) == 0) {
  1640. town = 4;
  1641. } else if (strncmp(map_name, "izlude", 3) == 0) {
  1642. town = 5;
  1643. } else if (strncmp(map_name, "aldebaran", 3) == 0) {
  1644. town = 6;
  1645. } else if (strncmp(map_name, "lutie", 3) == 0 ||
  1646. strcmp(map_name, "christmas") == 0 ||
  1647. strncmp(map_name, "xmas", 3) == 0 ||
  1648. strncmp(map_name, "x-mas", 3) == 0) {
  1649. town = 7;
  1650. } else if (strncmp(map_name, "comodo", 3) == 0) {
  1651. town = 8;
  1652. } else if (strncmp(map_name, "juno", 3) == 0 ||
  1653. strncmp(map_name, "yuno", 3) == 0) {
  1654. town = 9;
  1655. } else if (strncmp(map_name, "amatsu", 3) == 0) {
  1656. town = 10;
  1657. } else if (strncmp(map_name, "kunlun", 3) == 0 ||
  1658. strncmp(map_name, "gonryun", 3) == 0) {
  1659. town = 11;
  1660. } else if (strncmp(map_name, "umbala", 3) == 0) {
  1661. town = 12;
  1662. } else if (strncmp(map_name, "niflheim", 3) == 0) {
  1663. town = 13;
  1664. } else if (strncmp(map_name, "louyang", 3) == 0) {
  1665. town = 14;
  1666. } else if (strncmp(map_name, "new_1-1", 3) == 0 ||
  1667. strncmp(map_name, "startpoint", 3) == 0 ||
  1668. strncmp(map_name, "beginning", 3) == 0) {
  1669. town = 15;
  1670. } else if (strncmp(map_name, "sec_pri", 3) == 0 ||
  1671. strncmp(map_name, "prison", 3) == 0 ||
  1672. strncmp(map_name, "jail", 3) == 0) {
  1673. town = 16;
  1674. } else if (strncmp(map_name, "jawaii", 3) == 0) {
  1675. town = 17;
  1676. } else if (strncmp(map_name, "ayothaya", 3) == 0) {
  1677. town = 18;
  1678. } else if (strncmp(map_name, "einbroch", 5) == 0) {
  1679. town = 19;
  1680. } else if (strncmp(map_name, "lighthalzen", 3) == 0) {
  1681. town = 20;
  1682. } else if (strncmp(map_name, "einbech", 5) == 0) {
  1683. town = 21;
  1684. } else if (strncmp(map_name, "hugel", 3) == 0) {
  1685. town = 22;
  1686. } else if (strncmp(map_name, "rachel", 3) == 0) {
  1687. town = 23;
  1688. } else if (strncmp(map_name, "veins", 3) == 0) {
  1689. town = 24;
  1690. } else if (strncmp(map_name, "moscovia", 3) == 0) {
  1691. town = 25;
  1692. } else if (strncmp(map_name, "mid_camp", 3) == 0) {
  1693. town = 26;
  1694. } else if (strncmp(map_name, "manuk", 3) == 0) {
  1695. town = 27;
  1696. } else if (strncmp(map_name, "splendide", 3) == 0) {
  1697. town = 28;
  1698. } else if (strncmp(map_name, "brasilis", 3) == 0) {
  1699. town = 29;
  1700. } else if (strncmp(map_name, "dicastes01", 3) == 0) {
  1701. town = 30;
  1702. } else if (strcmp(map_name, "mora") == 0) {
  1703. town = 31;
  1704. } else if (strncmp(map_name, "dewata", 3) == 0) {
  1705. town = 32;
  1706. } else if (strncmp(map_name, "malangdo", 5) == 0) {
  1707. town = 33;
  1708. } else if (strncmp(map_name, "malaya", 5) == 0) {
  1709. town = 34;
  1710. } else if (strncmp(map_name, "eclage", 3) == 0) {
  1711. town = 35;
  1712. }
  1713. if (town >= 0 && town < ARRAYLENGTH(data))
  1714. {
  1715. m = map_mapname2mapid(data[town].map);
  1716. if (m >= 0 && map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  1717. clif_displaymessage(fd, msg_txt(sd,247));
  1718. return -1;
  1719. }
  1720. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  1721. clif_displaymessage(fd, msg_txt(sd,248));
  1722. return -1;
  1723. }
  1724. if (pc_setpos(sd, mapindex_name2id(data[town].map), data[town].x, data[town].y, CLR_TELEPORT) == 0) {
  1725. clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
  1726. } else {
  1727. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  1728. return -1;
  1729. }
  1730. } else { // if you arrive here, you have an error in town variable when reading of names
  1731. clif_displaymessage(fd, msg_txt(sd,38)); // Invalid location number or name.
  1732. return -1;
  1733. }
  1734. return 0;
  1735. }
  1736. /*==========================================
  1737. *
  1738. *------------------------------------------*/
  1739. ACMD_FUNC(monster)
  1740. {
  1741. char name[NAME_LENGTH];
  1742. char monster[NAME_LENGTH];
  1743. char eventname[EVENT_NAME_LENGTH] = "";
  1744. int mob_id;
  1745. int number = 0;
  1746. int count;
  1747. int i, range;
  1748. short mx, my;
  1749. unsigned int size;
  1750. nullpo_retr(-1, sd);
  1751. memset(name, '\0', sizeof(name));
  1752. memset(monster, '\0', sizeof(monster));
  1753. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1754. if (!message || !*message) {
  1755. clif_displaymessage(fd, msg_txt(sd,80)); // Give the display name or monster name/id please.
  1756. return -1;
  1757. }
  1758. if (sscanf(message, "\"%23[^\"]\" %23s %d", name, monster, &number) > 1 ||
  1759. sscanf(message, "%23s \"%23[^\"]\" %d", monster, name, &number) > 1) {
  1760. //All data can be left as it is.
  1761. } else if ((count=sscanf(message, "%23s %d %23s", monster, &number, name)) > 1) {
  1762. //Here, it is possible name was not given and we are using monster for it.
  1763. if (count < 3) //Blank mob's name.
  1764. name[0] = '\0';
  1765. } else if (sscanf(message, "%23s %23s %d", name, monster, &number) > 1) {
  1766. //All data can be left as it is.
  1767. } else if (sscanf(message, "%23s", monster) > 0) {
  1768. //As before, name may be already filled.
  1769. name[0] = '\0';
  1770. } else {
  1771. clif_displaymessage(fd, msg_txt(sd,80)); // Give a display name and monster name/id please.
  1772. return -1;
  1773. }
  1774. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  1775. mob_id = mobdb_checkid(atoi(monster));
  1776. if (mob_id == 0) {
  1777. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  1778. return -1;
  1779. }
  1780. if (mob_id == MOBID_EMPERIUM) {
  1781. clif_displaymessage(fd, msg_txt(sd,83)); // Monster 'Emperium' cannot be spawned.
  1782. return -1;
  1783. }
  1784. if (number <= 0)
  1785. number = 1;
  1786. if( !name[0] )
  1787. strcpy(name, "--ja--");
  1788. // 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
  1789. if (battle_config.atc_spawn_quantity_limit && number > battle_config.atc_spawn_quantity_limit)
  1790. number = battle_config.atc_spawn_quantity_limit;
  1791. if (strcmp(command+1, "monstersmall") == 0)
  1792. size = SZ_MEDIUM; // This is just gorgeous [mkbu95]
  1793. else if (strcmp(command+1, "monsterbig") == 0)
  1794. size = SZ_BIG;
  1795. else
  1796. size = SZ_SMALL;
  1797. if (battle_config.etc_log)
  1798. 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);
  1799. count = 0;
  1800. range = (int)sqrt((float)number) +2; // calculation of an odd number (+ 4 area around)
  1801. for (i = 0; i < number; i++) {
  1802. int k;
  1803. map_search_freecell(&sd->bl, 0, &mx, &my, range, range, 0);
  1804. k = mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, eventname, size, AI_NONE);
  1805. if(k) {
  1806. //mapreg_setreg(reference_uid(add_str("$@mobid"), i),k); //retain created mobid in array uncomment if needed
  1807. count ++;
  1808. }
  1809. }
  1810. if (count != 0)
  1811. if (number == count)
  1812. clif_displaymessage(fd, msg_txt(sd,39)); // All monster summoned!
  1813. else {
  1814. sprintf(atcmd_output, msg_txt(sd,240), count); // %d monster(s) summoned!
  1815. clif_displaymessage(fd, atcmd_output);
  1816. }
  1817. else {
  1818. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  1819. return -1;
  1820. }
  1821. return 0;
  1822. }
  1823. /*==========================================
  1824. *
  1825. *------------------------------------------*/
  1826. static int atkillmonster_sub(struct block_list *bl, va_list ap)
  1827. {
  1828. struct mob_data *md;
  1829. int flag;
  1830. nullpo_ret(md=(struct mob_data *)bl);
  1831. flag = va_arg(ap, int);
  1832. if (md->guardian_data)
  1833. return 0; //Do not touch WoE mobs!
  1834. if (flag)
  1835. status_zap(bl,md->status.hp, 0);
  1836. else
  1837. status_kill(bl);
  1838. return 1;
  1839. }
  1840. ACMD_FUNC(killmonster)
  1841. {
  1842. int map_id, drop_flag;
  1843. char map_name[MAP_NAME_LENGTH_EXT];
  1844. nullpo_retr(-1, sd);
  1845. memset(map_name, '\0', sizeof(map_name));
  1846. if (!message || !*message || sscanf(message, "%15s", map_name) < 1)
  1847. map_id = sd->bl.m;
  1848. else {
  1849. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1850. map_id = sd->bl.m;
  1851. }
  1852. drop_flag = strcmp(command+1, "killmonster2");
  1853. map_foreachinmap(atkillmonster_sub, map_id, BL_MOB, -drop_flag);
  1854. clif_displaymessage(fd, msg_txt(sd,165)); // All monsters killed!
  1855. return 0;
  1856. }
  1857. /*==========================================
  1858. *
  1859. *------------------------------------------*/
  1860. ACMD_FUNC(refine)
  1861. {
  1862. int j, position = 0, refine = 0, current_position, final_refine;
  1863. int count;
  1864. nullpo_retr(-1, sd);
  1865. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1866. if (!message || !*message || sscanf(message, "%d %d", &position, &refine) < 2) {
  1867. clif_displaymessage(fd, msg_txt(sd,996)); // Please enter a position and an amount (usage: @refine <equip position> <+/- amount>).
  1868. sprintf(atcmd_output, msg_txt(sd,997), EQP_HEAD_LOW); // %d: Lower Headgear
  1869. clif_displaymessage(fd, atcmd_output);
  1870. sprintf(atcmd_output, msg_txt(sd,998), EQP_HAND_R); // %d: Right Hand
  1871. clif_displaymessage(fd, atcmd_output);
  1872. sprintf(atcmd_output, msg_txt(sd,999), EQP_GARMENT); // %d: Garment
  1873. clif_displaymessage(fd, atcmd_output);
  1874. sprintf(atcmd_output, msg_txt(sd,1000), EQP_ACC_L); // %d: Left Accessory
  1875. clif_displaymessage(fd, atcmd_output);
  1876. sprintf(atcmd_output, msg_txt(sd,1001), EQP_ARMOR); // %d: Body Armor
  1877. clif_displaymessage(fd, atcmd_output);
  1878. sprintf(atcmd_output, msg_txt(sd,1002), EQP_HAND_L); // %d: Left Hand
  1879. clif_displaymessage(fd, atcmd_output);
  1880. sprintf(atcmd_output, msg_txt(sd,1003), EQP_SHOES); // %d: Shoes
  1881. clif_displaymessage(fd, atcmd_output);
  1882. sprintf(atcmd_output, msg_txt(sd,1004), EQP_ACC_R); // %d: Right Accessory
  1883. clif_displaymessage(fd, atcmd_output);
  1884. sprintf(atcmd_output, msg_txt(sd,1005), EQP_HEAD_TOP); // %d: Top Headgear
  1885. clif_displaymessage(fd, atcmd_output);
  1886. sprintf(atcmd_output, msg_txt(sd,1006), EQP_HEAD_MID); // %d: Mid Headgear
  1887. clif_displaymessage(fd, atcmd_output);
  1888. return -1;
  1889. }
  1890. refine = cap_value(refine, -MAX_REFINE, MAX_REFINE);
  1891. count = 0;
  1892. for (j = 0; j < EQI_MAX; j++) {
  1893. int i;
  1894. if ((i = sd->equip_index[j]) < 0)
  1895. continue;
  1896. if(j == EQI_AMMO) continue;
  1897. if(j == EQI_HAND_R && sd->equip_index[EQI_HAND_L] == i)
  1898. continue;
  1899. if(j == EQI_HEAD_MID && sd->equip_index[EQI_HEAD_LOW] == i)
  1900. continue;
  1901. if(j == EQI_HEAD_TOP && (sd->equip_index[EQI_HEAD_MID] == i || sd->equip_index[EQI_HEAD_LOW] == i))
  1902. continue;
  1903. if(position && !(sd->status.inventory[i].equip & position))
  1904. continue;
  1905. final_refine = cap_value(sd->status.inventory[i].refine + refine, 0, MAX_REFINE);
  1906. if (sd->status.inventory[i].refine != final_refine) {
  1907. sd->status.inventory[i].refine = final_refine;
  1908. current_position = sd->status.inventory[i].equip;
  1909. pc_unequipitem(sd, i, 3);
  1910. clif_refine(fd, 0, i, sd->status.inventory[i].refine);
  1911. clif_delitem(sd, i, 1, 3);
  1912. clif_additem(sd, i, 1, 0);
  1913. pc_equipitem(sd, i, current_position);
  1914. clif_misceffect(&sd->bl, 3);
  1915. count++;
  1916. }
  1917. }
  1918. if (count == 0)
  1919. clif_displaymessage(fd, msg_txt(sd,166)); // No item has been refined.
  1920. else if (count == 1)
  1921. clif_displaymessage(fd, msg_txt(sd,167)); // 1 item has been refined.
  1922. else {
  1923. sprintf(atcmd_output, msg_txt(sd,168), count); // %d items have been refined.
  1924. clif_displaymessage(fd, atcmd_output);
  1925. }
  1926. return 0;
  1927. }
  1928. /*==========================================
  1929. *
  1930. *------------------------------------------*/
  1931. ACMD_FUNC(produce)
  1932. {
  1933. char item_name[100];
  1934. int item_id, attribute = 0, star = 0;
  1935. struct item_data *item_data;
  1936. struct item tmp_item;
  1937. nullpo_retr(-1, sd);
  1938. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1939. memset(item_name, '\0', sizeof(item_name));
  1940. if (!message || !*message || (
  1941. sscanf(message, "\"%99[^\"]\" %d %d", item_name, &attribute, &star) < 1 &&
  1942. sscanf(message, "%99s %d %d", item_name, &attribute, &star) < 1
  1943. )) {
  1944. clif_displaymessage(fd, msg_txt(sd,1007)); // Please enter at least one item name/ID (usage: @produce <equip name/ID> <element> <# of very's>).
  1945. return -1;
  1946. }
  1947. if ( (item_data = itemdb_searchname(item_name)) == NULL &&
  1948. (item_data = itemdb_exists(atoi(item_name))) == NULL ) {
  1949. clif_displaymessage(fd, msg_txt(sd,170)); //This item is not an equipment.
  1950. return -1;
  1951. }
  1952. item_id = item_data->nameid;
  1953. if (itemdb_isequip2(item_data)) {
  1954. int flag = 0;
  1955. if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
  1956. attribute = ATTRIBUTE_NORMAL;
  1957. if (star < MIN_STAR || star > MAX_STAR)
  1958. star = 0;
  1959. memset(&tmp_item, 0, sizeof tmp_item);
  1960. tmp_item.nameid = item_id;
  1961. tmp_item.amount = 1;
  1962. tmp_item.identify = 1;
  1963. tmp_item.card[0] = CARD0_FORGE;
  1964. tmp_item.card[1] = item_data->type==IT_WEAPON?
  1965. ((star*5) << 8) + attribute:0;
  1966. tmp_item.card[2] = GetWord(sd->status.char_id, 0);
  1967. tmp_item.card[3] = GetWord(sd->status.char_id, 1);
  1968. clif_produceeffect(sd, 0, item_id);
  1969. clif_misceffect(&sd->bl, 3);
  1970. if ((flag = pc_additem(sd, &tmp_item, 1, LOG_TYPE_COMMAND)))
  1971. clif_additem(sd, 0, 0, flag);
  1972. } else {
  1973. sprintf(atcmd_output, msg_txt(sd,169), item_id, item_data->name); // The item (%d: '%s') is not equipable.
  1974. clif_displaymessage(fd, atcmd_output);
  1975. return -1;
  1976. }
  1977. return 0;
  1978. }
  1979. /*==========================================
  1980. *
  1981. *------------------------------------------*/
  1982. ACMD_FUNC(memo)
  1983. {
  1984. int position = 0;
  1985. nullpo_retr(-1, sd);
  1986. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1987. if( !message || !*message || sscanf(message, "%d", &position) < 1 )
  1988. {
  1989. int i;
  1990. clif_displaymessage(sd->fd, msg_txt(sd,668));
  1991. for( i = 0; i < MAX_MEMOPOINTS; i++ )
  1992. {
  1993. if( sd->status.memo_point[i].map )
  1994. 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);
  1995. else
  1996. sprintf(atcmd_output, msg_txt(sd,171), i); // %d - void
  1997. clif_displaymessage(sd->fd, atcmd_output);
  1998. }
  1999. return 0;
  2000. }
  2001. if( position < 0 || position >= MAX_MEMOPOINTS )
  2002. {
  2003. sprintf(atcmd_output, msg_txt(sd,1008), 0, MAX_MEMOPOINTS-1); // Please enter a valid position (usage: @memo <memo_position:%d-%d>).
  2004. clif_displaymessage(fd, atcmd_output);
  2005. return -1;
  2006. }
  2007. return !pc_memo( sd, position );
  2008. }
  2009. /*==========================================
  2010. *
  2011. *------------------------------------------*/
  2012. ACMD_FUNC(gat)
  2013. {
  2014. int y;
  2015. nullpo_retr(-1, sd);
  2016. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2017. for (y = 2; y >= -2; y--) {
  2018. sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
  2019. map[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y,
  2020. map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE),
  2021. map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE),
  2022. map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE),
  2023. map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE),
  2024. map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE));
  2025. clif_displaymessage(fd, atcmd_output);
  2026. }
  2027. return 0;
  2028. }
  2029. /*==========================================
  2030. *
  2031. *------------------------------------------*/
  2032. ACMD_FUNC(displaystatus)
  2033. {
  2034. int i, type, flag, tick, val1 = 0, val2 = 0, val3 = 0;
  2035. nullpo_retr(-1, sd);
  2036. if (!message || !*message || (i = sscanf(message, "%d %d %d %d %d %d", &type, &flag, &tick, &val1, &val2, &val3)) < 1) {
  2037. clif_displaymessage(fd, msg_txt(sd,1009)); // Please enter a status type/flag (usage: @displaystatus <status type> <flag> <tick> {<val1> {<val2> {<val3>}}}).
  2038. return -1;
  2039. }
  2040. if (i < 2) flag = 1;
  2041. if (i < 3) tick = 0;
  2042. clif_status_change(&sd->bl, type, flag, tick, val1, val2, val3);
  2043. return 0;
  2044. }
  2045. /*==========================================
  2046. * @stpoint (Rewritten by [Yor])
  2047. *------------------------------------------*/
  2048. ACMD_FUNC(statuspoint)
  2049. {
  2050. int point;
  2051. unsigned int new_status_point;
  2052. if (!message || !*message || (point = atoi(message)) == 0) {
  2053. clif_displaymessage(fd, msg_txt(sd,1010)); // Please enter a number (usage: @stpoint <number of points>).
  2054. return -1;
  2055. }
  2056. if(point < 0)
  2057. {
  2058. if(sd->status.status_point < (unsigned int)(-point))
  2059. {
  2060. new_status_point = 0;
  2061. }
  2062. else
  2063. {
  2064. new_status_point = sd->status.status_point + point;
  2065. }
  2066. }
  2067. else if(UINT_MAX - sd->status.status_point < (unsigned int)point)
  2068. {
  2069. new_status_point = UINT_MAX;
  2070. }
  2071. else
  2072. {
  2073. new_status_point = sd->status.status_point + point;
  2074. }
  2075. if (new_status_point != sd->status.status_point) {
  2076. sd->status.status_point = new_status_point;
  2077. clif_updatestatus(sd, SP_STATUSPOINT);
  2078. clif_displaymessage(fd, msg_txt(sd,174)); // Number of status points changed.
  2079. } else {
  2080. if (point < 0)
  2081. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2082. else
  2083. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2084. return -1;
  2085. }
  2086. return 0;
  2087. }
  2088. /*==========================================
  2089. * @skpoint (Rewritten by [Yor])
  2090. *------------------------------------------*/
  2091. ACMD_FUNC(skillpoint)
  2092. {
  2093. int point;
  2094. unsigned int new_skill_point;
  2095. nullpo_retr(-1, sd);
  2096. if (!message || !*message || (point = atoi(message)) == 0) {
  2097. clif_displaymessage(fd, msg_txt(sd,1011)); // Please enter a number (usage: @skpoint <number of points>).
  2098. return -1;
  2099. }
  2100. if(point < 0)
  2101. {
  2102. if(sd->status.skill_point < (unsigned int)(-point))
  2103. {
  2104. new_skill_point = 0;
  2105. }
  2106. else
  2107. {
  2108. new_skill_point = sd->status.skill_point + point;
  2109. }
  2110. }
  2111. else if(UINT_MAX - sd->status.skill_point < (unsigned int)point)
  2112. {
  2113. new_skill_point = UINT_MAX;
  2114. }
  2115. else
  2116. {
  2117. new_skill_point = sd->status.skill_point + point;
  2118. }
  2119. if (new_skill_point != sd->status.skill_point) {
  2120. sd->status.skill_point = new_skill_point;
  2121. clif_updatestatus(sd, SP_SKILLPOINT);
  2122. clif_displaymessage(fd, msg_txt(sd,175)); // Number of skill points changed.
  2123. } else {
  2124. if (point < 0)
  2125. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2126. else
  2127. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2128. return -1;
  2129. }
  2130. return 0;
  2131. }
  2132. /*==========================================
  2133. * @zeny
  2134. *------------------------------------------*/
  2135. ACMD_FUNC(zeny)
  2136. {
  2137. int zeny=0, ret=-1;
  2138. nullpo_retr(-1, sd);
  2139. if (!message || !*message || (zeny = atoi(message)) == 0) {
  2140. clif_displaymessage(fd, msg_txt(sd,1012)); // Please enter an amount (usage: @zeny <amount>).
  2141. return -1;
  2142. }
  2143. if(zeny > 0){
  2144. if((ret=pc_getzeny(sd,zeny,LOG_TYPE_COMMAND,NULL)) == 1)
  2145. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2146. }
  2147. else {
  2148. if( sd->status.zeny < -zeny ) zeny = -sd->status.zeny;
  2149. if((ret=pc_payzeny(sd,-zeny,LOG_TYPE_COMMAND,NULL)) == 1)
  2150. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2151. }
  2152. if(!ret) clif_displaymessage(fd, msg_txt(sd,176)); //ret=0 mean cmd success
  2153. return 0;
  2154. }
  2155. /*==========================================
  2156. *
  2157. *------------------------------------------*/
  2158. ACMD_FUNC(param)
  2159. {
  2160. uint8 i;
  2161. int value = 0;
  2162. const char* param[] = { "str", "agi", "vit", "int", "dex", "luk" };
  2163. short new_value, *status[6], max_status[6];
  2164. //we don't use direct initialization because it isn't part of the c standard.
  2165. nullpo_retr(-1, sd);
  2166. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2167. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  2168. clif_displaymessage(fd, msg_txt(sd,1013)); // Please enter a valid value (usage: @str/@agi/@vit/@int/@dex/@luk <+/-adjustment>).
  2169. return -1;
  2170. }
  2171. ARR_FIND( 0, ARRAYLENGTH(param), i, strcmpi(command+1, param[i]) == 0 );
  2172. if( i == ARRAYLENGTH(param) || i > MAX_STATUS_TYPE) { // normally impossible...
  2173. clif_displaymessage(fd, msg_txt(sd,1013)); // Please enter a valid value (usage: @str/@agi/@vit/@int/@dex/@luk <+/-adjustment>).
  2174. return -1;
  2175. }
  2176. status[0] = &sd->status.str;
  2177. status[1] = &sd->status.agi;
  2178. status[2] = &sd->status.vit;
  2179. status[3] = &sd->status.int_;
  2180. status[4] = &sd->status.dex;
  2181. status[5] = &sd->status.luk;
  2182. if( battle_config.atcommand_max_stat_bypass )
  2183. max_status[0] = max_status[1] = max_status[2] = max_status[3] = max_status[4] = max_status[5] = SHRT_MAX;
  2184. else {
  2185. max_status[0] = pc_maxparameter(sd,PARAM_STR);
  2186. max_status[1] = pc_maxparameter(sd,PARAM_AGI);
  2187. max_status[2] = pc_maxparameter(sd,PARAM_VIT);
  2188. max_status[3] = pc_maxparameter(sd,PARAM_INT);
  2189. max_status[4] = pc_maxparameter(sd,PARAM_DEX);
  2190. max_status[5] = pc_maxparameter(sd,PARAM_LUK);
  2191. }
  2192. if(value > 0 && *status[i] + value >= max_status[i])
  2193. new_value = max_status[i];
  2194. else if(value < 0 && *status[i] <= -value)
  2195. new_value = 1;
  2196. else
  2197. new_value = *status[i] + value;
  2198. if (new_value != *status[i]) {
  2199. *status[i] = new_value;
  2200. clif_updatestatus(sd, SP_STR + i);
  2201. clif_updatestatus(sd, SP_USTR + i);
  2202. status_calc_pc(sd, 0);
  2203. clif_displaymessage(fd, msg_txt(sd,42)); // Stat changed.
  2204. } else {
  2205. if (value < 0)
  2206. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2207. else
  2208. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2209. return -1;
  2210. }
  2211. return 0;
  2212. }
  2213. /*==========================================
  2214. * Stat all by fritz (rewritten by [Yor])
  2215. *------------------------------------------*/
  2216. ACMD_FUNC(stat_all)
  2217. {
  2218. int value = 0;
  2219. uint8 count, i;
  2220. short *status[PARAM_MAX], max_status[PARAM_MAX];
  2221. //we don't use direct initialization because it isn't part of the c standard.
  2222. nullpo_retr(-1, sd);
  2223. status[0] = &sd->status.str;
  2224. status[1] = &sd->status.agi;
  2225. status[2] = &sd->status.vit;
  2226. status[3] = &sd->status.int_;
  2227. status[4] = &sd->status.dex;
  2228. status[5] = &sd->status.luk;
  2229. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  2230. max_status[0] = pc_maxparameter(sd,PARAM_STR);
  2231. max_status[1] = pc_maxparameter(sd,PARAM_AGI);
  2232. max_status[2] = pc_maxparameter(sd,PARAM_VIT);
  2233. max_status[3] = pc_maxparameter(sd,PARAM_INT);
  2234. max_status[4] = pc_maxparameter(sd,PARAM_DEX);
  2235. max_status[5] = pc_maxparameter(sd,PARAM_LUK);
  2236. value = SHRT_MAX;
  2237. } else {
  2238. if( battle_config.atcommand_max_stat_bypass )
  2239. max_status[0] = max_status[1] = max_status[2] = max_status[3] = max_status[4] = max_status[5] = SHRT_MAX;
  2240. else {
  2241. max_status[0] = pc_maxparameter(sd,PARAM_STR);
  2242. max_status[1] = pc_maxparameter(sd,PARAM_AGI);
  2243. max_status[2] = pc_maxparameter(sd,PARAM_VIT);
  2244. max_status[3] = pc_maxparameter(sd,PARAM_INT);
  2245. max_status[4] = pc_maxparameter(sd,PARAM_DEX);
  2246. max_status[5] = pc_maxparameter(sd,PARAM_LUK);
  2247. }
  2248. }
  2249. count = 0;
  2250. for (i = 0; i < ARRAYLENGTH(status); i++) {
  2251. short new_value;
  2252. if (value > 0 && *status[i] + value >= max_status[i])
  2253. new_value = max_status[i];
  2254. else if (value < 0 && *status[i] <= -value)
  2255. new_value = 1;
  2256. else
  2257. new_value = *status[i] + value;
  2258. if (new_value != *status[i]) {
  2259. *status[i] = new_value;
  2260. clif_updatestatus(sd, SP_STR + i);
  2261. clif_updatestatus(sd, SP_USTR + i);
  2262. count++;
  2263. }
  2264. }
  2265. if (count > 0) { // if at least 1 stat modified
  2266. status_calc_pc(sd, 0);
  2267. clif_displaymessage(fd, msg_txt(sd,84)); // All stats changed!
  2268. } else {
  2269. if (value < 0)
  2270. clif_displaymessage(fd, msg_txt(sd,177)); // You cannot decrease that stat anymore.
  2271. else
  2272. clif_displaymessage(fd, msg_txt(sd,178)); // You cannot increase that stat anymore.
  2273. return -1;
  2274. }
  2275. return 0;
  2276. }
  2277. /*==========================================
  2278. *
  2279. *------------------------------------------*/
  2280. ACMD_FUNC(guildlevelup) {
  2281. int level = 0;
  2282. short added_level;
  2283. struct guild *guild_info;
  2284. nullpo_retr(-1, sd);
  2285. if (!message || !*message || sscanf(message, "%d", &level) < 1 || level == 0) {
  2286. clif_displaymessage(fd, msg_txt(sd,1014)); // Please enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).
  2287. return -1;
  2288. }
  2289. if (sd->status.guild_id <= 0 || (guild_info = sd->guild) == NULL) {
  2290. clif_displaymessage(fd, msg_txt(sd,43)); // You're not in a guild.
  2291. return -1;
  2292. }
  2293. //if (strcmp(sd->status.name, guild_info->master) != 0) {
  2294. // clif_displaymessage(fd, msg_txt(sd,44)); // You're not the master of your guild.
  2295. // return -1;
  2296. //}
  2297. added_level = (short)level;
  2298. if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild_lv))) // fix positive overflow
  2299. added_level = (short)MAX_GUILDLEVEL - guild_info->guild_lv;
  2300. else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild_lv))) // fix negative overflow
  2301. added_level = 1 - guild_info->guild_lv;
  2302. if (added_level != 0) {
  2303. intif_guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, sizeof(added_level));
  2304. clif_displaymessage(fd, msg_txt(sd,179)); // Guild level changed.
  2305. } else {
  2306. clif_displaymessage(fd, msg_txt(sd,45)); // Guild level change failed.
  2307. return -1;
  2308. }
  2309. return 0;
  2310. }
  2311. /*==========================================
  2312. *
  2313. *------------------------------------------*/
  2314. ACMD_FUNC(makeegg) {
  2315. struct item_data *item_data;
  2316. int id, pet_id;
  2317. nullpo_retr(-1, sd);
  2318. if (!message || !*message) {
  2319. clif_displaymessage(fd, msg_txt(sd,1015)); // Please enter a monster/egg name/ID (usage: @makeegg <pet>).
  2320. return -1;
  2321. }
  2322. if ((item_data = itemdb_searchname(message)) != NULL) // for egg name
  2323. id = item_data->nameid;
  2324. else
  2325. if ((id = mobdb_searchname(message)) != 0) // for monster name
  2326. ;
  2327. else
  2328. id = atoi(message);
  2329. pet_id = search_petDB_index(id, PET_CLASS);
  2330. if (pet_id < 0)
  2331. pet_id = search_petDB_index(id, PET_EGG);
  2332. if (pet_id >= 0) {
  2333. sd->catch_target_class = pet_db[pet_id].class_;
  2334. intif_create_pet(
  2335. sd->status.account_id, sd->status.char_id,
  2336. (short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv,
  2337. (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
  2338. 100, 0, 1, pet_db[pet_id].jname);
  2339. } else {
  2340. clif_displaymessage(fd, msg_txt(sd,180)); // The monster/egg name/id doesn't exist.
  2341. return -1;
  2342. }
  2343. return 0;
  2344. }
  2345. /*==========================================
  2346. *
  2347. *------------------------------------------*/
  2348. ACMD_FUNC(hatch) {
  2349. nullpo_retr(-1, sd);
  2350. if (sd->status.pet_id <= 0)
  2351. clif_sendegg(sd);
  2352. else {
  2353. clif_displaymessage(fd, msg_txt(sd,181)); // You already have a pet.
  2354. return -1;
  2355. }
  2356. return 0;
  2357. }
  2358. /*==========================================
  2359. *
  2360. *------------------------------------------*/
  2361. ACMD_FUNC(petfriendly) {
  2362. int friendly;
  2363. struct pet_data *pd;
  2364. nullpo_retr(-1, sd);
  2365. if (!message || !*message || (friendly = atoi(message)) < 0) {
  2366. clif_displaymessage(fd, msg_txt(sd,1016)); // Please enter a valid value (usage: @petfriendly <0-1000>).
  2367. return -1;
  2368. }
  2369. pd = sd->pd;
  2370. if (!pd) {
  2371. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2372. return -1;
  2373. }
  2374. if (friendly < 0 || friendly > 1000)
  2375. {
  2376. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  2377. return -1;
  2378. }
  2379. if (friendly == pd->pet.intimate) {
  2380. clif_displaymessage(fd, msg_txt(sd,183)); // Pet intimacy is already at maximum.
  2381. return -1;
  2382. }
  2383. pet_set_intimate(pd, friendly);
  2384. clif_send_petstatus(sd);
  2385. clif_displaymessage(fd, msg_txt(sd,182)); // Pet intimacy changed.
  2386. return 0;
  2387. }
  2388. /*==========================================
  2389. *
  2390. *------------------------------------------*/
  2391. ACMD_FUNC(pethungry)
  2392. {
  2393. int hungry;
  2394. struct pet_data *pd;
  2395. nullpo_retr(-1, sd);
  2396. if (!message || !*message || (hungry = atoi(message)) < 0) {
  2397. clif_displaymessage(fd, msg_txt(sd,1017)); // Please enter a valid number (usage: @pethungry <0-100>).
  2398. return -1;
  2399. }
  2400. pd = sd->pd;
  2401. if (!sd->status.pet_id || !pd) {
  2402. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2403. return -1;
  2404. }
  2405. if (hungry < 0 || hungry > 100) {
  2406. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  2407. return -1;
  2408. }
  2409. if (hungry == pd->pet.hungry) {
  2410. clif_displaymessage(fd, msg_txt(sd,186)); // Pet hunger is already at maximum.
  2411. return -1;
  2412. }
  2413. pd->pet.hungry = hungry;
  2414. clif_send_petstatus(sd);
  2415. clif_displaymessage(fd, msg_txt(sd,185)); // Pet hunger changed.
  2416. return 0;
  2417. }
  2418. /*==========================================
  2419. *
  2420. *------------------------------------------*/
  2421. ACMD_FUNC(petrename)
  2422. {
  2423. struct pet_data *pd;
  2424. nullpo_retr(-1, sd);
  2425. if (!sd->status.pet_id || !sd->pd) {
  2426. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2427. return -1;
  2428. }
  2429. pd = sd->pd;
  2430. if (!pd->pet.rename_flag) {
  2431. clif_displaymessage(fd, msg_txt(sd,188)); // You can already rename your pet.
  2432. return -1;
  2433. }
  2434. pd->pet.rename_flag = 0;
  2435. intif_save_petdata(sd->status.account_id, &pd->pet);
  2436. clif_send_petstatus(sd);
  2437. clif_displaymessage(fd, msg_txt(sd,187)); // You can now rename your pet.
  2438. return 0;
  2439. }
  2440. /*==========================================
  2441. *
  2442. *------------------------------------------*/
  2443. ACMD_FUNC(recall) {
  2444. struct map_session_data *pl_sd = NULL;
  2445. nullpo_retr(-1, sd);
  2446. if (!message || !*message) {
  2447. clif_displaymessage(fd, msg_txt(sd,1018)); // Please enter a player name (usage: @recall <char name/ID>).
  2448. return -1;
  2449. }
  2450. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  2451. {
  2452. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  2453. return -1;
  2454. }
  2455. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  2456. {
  2457. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level doesn't authorize you to preform this action on the specified player.
  2458. return -1;
  2459. }
  2460. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2461. clif_displaymessage(fd, msg_txt(sd,1019)); // You are not authorized to warp someone to this map.
  2462. return -1;
  2463. }
  2464. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2465. clif_displaymessage(fd, msg_txt(sd,1020)); // You are not authorized to warp this player from their map.
  2466. return -1;
  2467. }
  2468. if (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y) {
  2469. return -1;
  2470. }
  2471. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  2472. sprintf(atcmd_output, msg_txt(sd,46), pl_sd->status.name); // %s recalled!
  2473. clif_displaymessage(fd, atcmd_output);
  2474. return 0;
  2475. }
  2476. /*==========================================
  2477. * charblock command (usage: charblock <player_name>)
  2478. * This command do a definitiv ban on a player
  2479. *------------------------------------------*/
  2480. ACMD_FUNC(char_block)
  2481. {
  2482. nullpo_retr(-1, sd);
  2483. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2484. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2485. clif_displaymessage(fd, msg_txt(sd,1021)); // Please enter a player name (usage: @charblock/@block <char name>).
  2486. return -1;
  2487. }
  2488. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, 1, 0, 0, 0); // type: 1 - block
  2489. clif_displaymessage(fd, msg_txt(sd,88)); // Character name sent to char-server to ask it.
  2490. return 0;
  2491. }
  2492. /*==========================================
  2493. * accountban command (usage: ban <%time> <player_name>)
  2494. * charban command (usage: charban <%time> <player_name>)
  2495. * %time see common/timer.c::solve_time()
  2496. *------------------------------------------*/
  2497. ACMD_FUNC(char_ban)
  2498. {
  2499. char * modif_p;
  2500. int32 timediff=0; //don't set this as uint as we may want to decrease banned time
  2501. int bantype=0; //2=account block, 6=char specific
  2502. char output[256];
  2503. nullpo_retr(-1, sd);
  2504. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2505. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2506. bantype = strcmpi(command+1,"charban")?2:6; //! FIXME this breaking alias recognition
  2507. if (!message || !*message || sscanf(message, "%255s %23[^\n]", atcmd_output, atcmd_player_name) < 2) {
  2508. clif_displaymessage(fd, msg_txt(sd,1022)); // Please enter ban time and a player name (usage: @charban/@ban/@banish/@charbanish <time> <char name>).
  2509. return -1;
  2510. }
  2511. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  2512. modif_p = atcmd_output;
  2513. timediff = (int32)solve_time(modif_p); //discard seconds
  2514. if (timediff == 0) { //allow negative ?
  2515. char output[256];
  2516. safesnprintf(output,sizeof(output),msg_txt(sd,85),bantype==6?"charban":"ban",timediff); // Invalid time for %s command (time=%d)
  2517. clif_displaymessage(fd, output);
  2518. 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.
  2519. return -1;
  2520. }
  2521. if( timediff<0 && (
  2522. ( bantype==2 && !pc_can_use_command(sd, "unban", COMMAND_ATCOMMAND) )
  2523. || ( bantype==6 && !pc_can_use_command(sd, "charunban", COMMAND_ATCOMMAND)) )
  2524. ){
  2525. clif_displaymessage(fd,msg_txt(sd,1023)); // You are not allowed to alter the time of a ban.
  2526. return -1;
  2527. }
  2528. if(bantype==2)
  2529. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, 2, timediff, 0, 0); // type: 2 - ban
  2530. else
  2531. chrif_req_charban(sd->status.account_id, atcmd_player_name,timediff);
  2532. safesnprintf(output,sizeof(output),msg_txt(sd,88),bantype==6?"char":"login"); // Sending request to %s server...
  2533. clif_displaymessage(fd, output);
  2534. return 0;
  2535. }
  2536. /*==========================================
  2537. * charunblock command (usage: charunblock <player_name>)
  2538. *------------------------------------------*/
  2539. ACMD_FUNC(char_unblock)
  2540. {
  2541. nullpo_retr(-1, sd);
  2542. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2543. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2544. clif_displaymessage(fd, msg_txt(sd,1024)); // Please enter a player name (usage: @charunblock <char name>).
  2545. return -1;
  2546. }
  2547. // send answer to login server via char-server
  2548. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, 3, 0, 0, 0); // type: 3 - unblock
  2549. clif_displaymessage(fd, msg_txt(sd,88)); // Character name sent to char-server to ask it.
  2550. return 0;
  2551. }
  2552. /*==========================================
  2553. * acc unban command (usage: unban <player_name>)
  2554. * char unban command (usage: charunban <player_name>)
  2555. *------------------------------------------*/
  2556. ACMD_FUNC(char_unban){
  2557. int unbantype=0;
  2558. nullpo_retr(-1, sd);
  2559. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2560. unbantype = strcmpi(command+1,"charunban")?4:7; //! FIXME this breaking alias recognition
  2561. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2562. if(unbantype==4) clif_displaymessage(fd, msg_txt(sd,1025)); // Please enter a player name (usage: @unblock <char name>).
  2563. else clif_displaymessage(fd, msg_txt(sd,435)); //Please enter a player name (usage: @charunban <char name>).
  2564. return -1;
  2565. }
  2566. if(unbantype==4) // send answer to login server via char-server
  2567. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, 4, 0, 0, 0); // type: 4 - unban
  2568. else //directly unban via char-serv
  2569. chrif_req_charunban(sd->status.char_id);
  2570. clif_displaymessage(fd, msg_txt(sd,88)); // Character name sent to char-server to ask it.
  2571. return 0;
  2572. }
  2573. /*==========================================
  2574. *
  2575. *------------------------------------------*/
  2576. ACMD_FUNC(night)
  2577. {
  2578. nullpo_retr(-1, sd);
  2579. if (night_flag != 1) {
  2580. map_night_timer(night_timer_tid, 0, 0, 1);
  2581. } else {
  2582. clif_displaymessage(fd, msg_txt(sd,89)); // Night mode is already enabled.
  2583. return -1;
  2584. }
  2585. return 0;
  2586. }
  2587. /*==========================================
  2588. *
  2589. *------------------------------------------*/
  2590. ACMD_FUNC(day)
  2591. {
  2592. nullpo_retr(-1, sd);
  2593. if (night_flag != 0) {
  2594. map_day_timer(day_timer_tid, 0, 0, 1);
  2595. } else {
  2596. clif_displaymessage(fd, msg_txt(sd,90)); // Day mode is already enabled.
  2597. return -1;
  2598. }
  2599. return 0;
  2600. }
  2601. /*==========================================
  2602. *
  2603. *------------------------------------------*/
  2604. ACMD_FUNC(doom)
  2605. {
  2606. struct map_session_data* pl_sd;
  2607. struct s_mapiterator* iter;
  2608. nullpo_retr(-1, sd);
  2609. iter = mapit_getallusers();
  2610. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2611. {
  2612. if (pl_sd->fd != fd && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  2613. {
  2614. status_kill(&pl_sd->bl);
  2615. clif_specialeffect(&pl_sd->bl,450,AREA);
  2616. clif_displaymessage(pl_sd->fd, msg_txt(sd,61)); // The holy messenger has given judgement.
  2617. }
  2618. }
  2619. mapit_free(iter);
  2620. clif_displaymessage(fd, msg_txt(sd,62)); // Judgement was made.
  2621. return 0;
  2622. }
  2623. /*==========================================
  2624. *
  2625. *------------------------------------------*/
  2626. ACMD_FUNC(doommap)
  2627. {
  2628. struct map_session_data* pl_sd;
  2629. struct s_mapiterator* iter;
  2630. nullpo_retr(-1, sd);
  2631. iter = mapit_getallusers();
  2632. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2633. {
  2634. if (pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  2635. {
  2636. status_kill(&pl_sd->bl);
  2637. clif_specialeffect(&pl_sd->bl,450,AREA);
  2638. clif_displaymessage(pl_sd->fd, msg_txt(sd,61)); // The holy messenger has given judgement.
  2639. }
  2640. }
  2641. mapit_free(iter);
  2642. clif_displaymessage(fd, msg_txt(sd,62)); // Judgement was made.
  2643. return 0;
  2644. }
  2645. /*==========================================
  2646. *
  2647. *------------------------------------------*/
  2648. static void atcommand_raise_sub(struct map_session_data* sd) {
  2649. status_revive(&sd->bl, 100, 100);
  2650. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  2651. clif_displaymessage(sd->fd, msg_txt(sd,63)); // Mercy has been shown.
  2652. }
  2653. /*==========================================
  2654. *
  2655. *------------------------------------------*/
  2656. ACMD_FUNC(raise)
  2657. {
  2658. struct map_session_data* pl_sd;
  2659. struct s_mapiterator* iter;
  2660. nullpo_retr(-1, sd);
  2661. iter = mapit_getallusers();
  2662. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2663. if( pc_isdead(pl_sd) )
  2664. atcommand_raise_sub(pl_sd);
  2665. mapit_free(iter);
  2666. clif_displaymessage(fd, msg_txt(sd,64)); // Mercy has been granted.
  2667. return 0;
  2668. }
  2669. /*==========================================
  2670. *
  2671. *------------------------------------------*/
  2672. ACMD_FUNC(raisemap)
  2673. {
  2674. struct map_session_data* pl_sd;
  2675. struct s_mapiterator* iter;
  2676. nullpo_retr(-1, sd);
  2677. iter = mapit_getallusers();
  2678. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2679. if (sd->bl.m == pl_sd->bl.m && pc_isdead(pl_sd) )
  2680. atcommand_raise_sub(pl_sd);
  2681. mapit_free(iter);
  2682. clif_displaymessage(fd, msg_txt(sd,64)); // Mercy has been granted.
  2683. return 0;
  2684. }
  2685. /*==========================================
  2686. *
  2687. *------------------------------------------*/
  2688. ACMD_FUNC(kick)
  2689. {
  2690. struct map_session_data *pl_sd;
  2691. nullpo_retr(-1, sd);
  2692. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2693. if (!message || !*message) {
  2694. clif_displaymessage(fd, msg_txt(sd,1026)); // Please enter a player name (usage: @kick <char name/ID>).
  2695. return -1;
  2696. }
  2697. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  2698. {
  2699. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  2700. return -1;
  2701. }
  2702. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  2703. {
  2704. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  2705. return -1;
  2706. }
  2707. clif_GM_kick(sd, pl_sd);
  2708. return 0;
  2709. }
  2710. /*==========================================
  2711. *
  2712. *------------------------------------------*/
  2713. ACMD_FUNC(kickall)
  2714. {
  2715. struct map_session_data* pl_sd;
  2716. struct s_mapiterator* iter;
  2717. nullpo_retr(-1, sd);
  2718. iter = mapit_getallusers();
  2719. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2720. {
  2721. if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kick only lower or same gm level
  2722. if (sd->status.account_id != pl_sd->status.account_id)
  2723. clif_GM_kick(NULL, pl_sd);
  2724. }
  2725. }
  2726. mapit_free(iter);
  2727. clif_displaymessage(fd, msg_txt(sd,195)); // All players have been kicked!
  2728. return 0;
  2729. }
  2730. /*==========================================
  2731. *
  2732. *------------------------------------------*/
  2733. ACMD_FUNC(allskill)
  2734. {
  2735. nullpo_retr(-1, sd);
  2736. pc_allskillup(sd); // all skills
  2737. sd->status.skill_point = 0; // 0 skill points
  2738. clif_updatestatus(sd, SP_SKILLPOINT); // update
  2739. clif_displaymessage(fd, msg_txt(sd,76)); // All skills have been added to your skill tree.
  2740. return 0;
  2741. }
  2742. /*==========================================
  2743. *
  2744. *------------------------------------------*/
  2745. ACMD_FUNC(questskill)
  2746. {
  2747. uint16 skill_id;
  2748. nullpo_retr(-1, sd);
  2749. if (!message || !*message || (skill_id = atoi(message)) <= 0)
  2750. {// also send a list of skills applicable to this command
  2751. const char* text;
  2752. // attempt to find the text corresponding to this command
  2753. text = atcommand_help_string( command );
  2754. // send the error message as always
  2755. clif_displaymessage(fd, msg_txt(sd,1027)); // Please enter a quest skill number.
  2756. if( text )
  2757. {// send the skill ID list associated with this command
  2758. clif_displaymessage( fd, text );
  2759. }
  2760. return -1;
  2761. }
  2762. if (skill_id >= MAX_SKILL_DB) {
  2763. clif_displaymessage(fd, msg_txt(sd,198)); // This skill number doesn't exist.
  2764. return -1;
  2765. }
  2766. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  2767. clif_displaymessage(fd, msg_txt(sd,197)); // This skill number doesn't exist or isn't a quest skill.
  2768. return -1;
  2769. }
  2770. if (pc_checkskill(sd, skill_id) > 0) {
  2771. clif_displaymessage(fd, msg_txt(sd,196)); // You already have this quest skill.
  2772. return -1;
  2773. }
  2774. pc_skill(sd, skill_id, 1, 0);
  2775. clif_displaymessage(fd, msg_txt(sd,70)); // You have learned the skill.
  2776. return 0;
  2777. }
  2778. /*==========================================
  2779. *
  2780. *------------------------------------------*/
  2781. ACMD_FUNC(lostskill)
  2782. {
  2783. uint16 skill_id;
  2784. nullpo_retr(-1, sd);
  2785. if (!message || !*message || (skill_id = atoi(message)) <= 0)
  2786. {// also send a list of skills applicable to this command
  2787. const char* text;
  2788. // attempt to find the text corresponding to this command
  2789. text = atcommand_help_string( command );
  2790. // send the error message as always
  2791. clif_displaymessage(fd, msg_txt(sd,1027)); // Please enter a quest skill number.
  2792. if( text )
  2793. {// send the skill ID list associated with this command
  2794. clif_displaymessage( fd, text );
  2795. }
  2796. return -1;
  2797. }
  2798. if (skill_id >= MAX_SKILL) {
  2799. clif_displaymessage(fd, msg_txt(sd,198)); // This skill number doesn't exist.
  2800. return -1;
  2801. }
  2802. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  2803. clif_displaymessage(fd, msg_txt(sd,197)); // This skill number doesn't exist or isn't a quest skill.
  2804. return -1;
  2805. }
  2806. if (pc_checkskill(sd, skill_id) == 0) {
  2807. clif_displaymessage(fd, msg_txt(sd,201)); // You don't have this quest skill.
  2808. return -1;
  2809. }
  2810. sd->status.skill[skill_id].lv = 0;
  2811. sd->status.skill[skill_id].flag = SKILL_FLAG_PERMANENT;
  2812. clif_deleteskill(sd,skill_id);
  2813. clif_displaymessage(fd, msg_txt(sd,71)); // You have forgotten the skill.
  2814. return 0;
  2815. }
  2816. /*==========================================
  2817. *
  2818. *------------------------------------------*/
  2819. ACMD_FUNC(spiritball)
  2820. {
  2821. int max_spiritballs;
  2822. int number;
  2823. nullpo_retr(-1, sd);
  2824. max_spiritballs = min(ARRAYLENGTH(sd->spirit_timer), 0x7FFF);
  2825. if( !message || !*message || (number = atoi(message)) < 0 || number > max_spiritballs )
  2826. {
  2827. char msg[CHAT_SIZE_MAX];
  2828. safesnprintf(msg, sizeof(msg), msg_txt(sd,1028), max_spiritballs); // Please enter a party name (usage: @party <party_name>).
  2829. clif_displaymessage(fd, msg);
  2830. return -1;
  2831. }
  2832. if( sd->spiritball > 0 )
  2833. pc_delspiritball(sd, sd->spiritball, 1);
  2834. sd->spiritball = number;
  2835. clif_spiritball(&sd->bl);
  2836. // no message, player can look the difference
  2837. return 0;
  2838. }
  2839. /*==========================================
  2840. *
  2841. *------------------------------------------*/
  2842. ACMD_FUNC(party)
  2843. {
  2844. char party[NAME_LENGTH];
  2845. nullpo_retr(-1, sd);
  2846. memset(party, '\0', sizeof(party));
  2847. if (!message || !*message || sscanf(message, "%23[^\n]", party) < 1) {
  2848. clif_displaymessage(fd, msg_txt(sd,1029)); // Please enter a party name (usage: @party <party_name>).
  2849. return -1;
  2850. }
  2851. party_create(sd, party, 0, 0);
  2852. return 0;
  2853. }
  2854. /*==========================================
  2855. *
  2856. *------------------------------------------*/
  2857. ACMD_FUNC(guild)
  2858. {
  2859. char guild[NAME_LENGTH];
  2860. int prev;
  2861. nullpo_retr(-1, sd);
  2862. memset(guild, '\0', sizeof(guild));
  2863. if (!message || !*message || sscanf(message, "%23[^\n]", guild) < 1) {
  2864. clif_displaymessage(fd, msg_txt(sd,1030)); // Please enter a guild name (usage: @guild <guild_name>).
  2865. return -1;
  2866. }
  2867. prev = battle_config.guild_emperium_check;
  2868. battle_config.guild_emperium_check = 0;
  2869. guild_create(sd, guild);
  2870. battle_config.guild_emperium_check = prev;
  2871. return 0;
  2872. }
  2873. ACMD_FUNC(breakguild)
  2874. {
  2875. nullpo_retr(-1, sd);
  2876. if (sd->status.guild_id) { // Check if the player has a guild
  2877. struct guild *g;
  2878. g = sd->guild; // Search the guild
  2879. if (g) { // Check if guild was found
  2880. if (sd->state.gmaster_flag) { // Check if player is guild master
  2881. int ret = 0;
  2882. ret = guild_break(sd, g->name); // Break guild
  2883. if (ret) { // Check if anything went wrong
  2884. return 0; // Guild was broken
  2885. } else {
  2886. return -1; // Something went wrong
  2887. }
  2888. } else { // Not guild master
  2889. clif_displaymessage(fd, msg_txt(sd,1181)); // You need to be a Guild Master to use this command.
  2890. return -1;
  2891. }
  2892. } else { // Guild was not found. HOW?
  2893. clif_displaymessage(fd, msg_txt(sd,252)); // You are not in a guild.
  2894. return -1;
  2895. }
  2896. } else { // Player does not have a guild
  2897. clif_displaymessage(fd, msg_txt(sd,252)); // You are not in a guild.
  2898. return -1;
  2899. }
  2900. return 0;
  2901. }
  2902. /*==========================================
  2903. *
  2904. *------------------------------------------*/
  2905. ACMD_FUNC(agitstart)
  2906. {
  2907. nullpo_retr(-1, sd);
  2908. if (agit_flag == 1) {
  2909. clif_displaymessage(fd, msg_txt(sd,73)); // War of Emperium is currently in progress.
  2910. return -1;
  2911. }
  2912. agit_flag = 1;
  2913. guild_agit_start();
  2914. clif_displaymessage(fd, msg_txt(sd,72)); // War of Emperium has been initiated.
  2915. return 0;
  2916. }
  2917. /*==========================================
  2918. *
  2919. *------------------------------------------*/
  2920. ACMD_FUNC(agitstart2)
  2921. {
  2922. nullpo_retr(-1, sd);
  2923. if (agit2_flag == 1) {
  2924. clif_displaymessage(fd, msg_txt(sd,404)); // "War of Emperium SE is currently in progress."
  2925. return -1;
  2926. }
  2927. agit2_flag = 1;
  2928. guild_agit2_start();
  2929. clif_displaymessage(fd, msg_txt(sd,403)); // "War of Emperium SE has been initiated."
  2930. return 0;
  2931. }
  2932. /*==========================================
  2933. *
  2934. *------------------------------------------*/
  2935. ACMD_FUNC(agitend)
  2936. {
  2937. nullpo_retr(-1, sd);
  2938. if (agit_flag == 0) {
  2939. clif_displaymessage(fd, msg_txt(sd,75)); // War of Emperium is currently not in progress.
  2940. return -1;
  2941. }
  2942. agit_flag = 0;
  2943. guild_agit_end();
  2944. clif_displaymessage(fd, msg_txt(sd,74)); // War of Emperium has been ended.
  2945. return 0;
  2946. }
  2947. /*==========================================
  2948. *
  2949. *------------------------------------------*/
  2950. ACMD_FUNC(agitend2)
  2951. {
  2952. nullpo_retr(-1, sd);
  2953. if (agit2_flag == 0) {
  2954. clif_displaymessage(fd, msg_txt(sd,406)); // "War of Emperium SE is currently not in progress."
  2955. return -1;
  2956. }
  2957. agit2_flag = 0;
  2958. guild_agit2_end();
  2959. clif_displaymessage(fd, msg_txt(sd,405)); // "War of Emperium SE has been ended."
  2960. return 0;
  2961. }
  2962. /*==========================================
  2963. * @mapexit - shuts down the map server
  2964. *------------------------------------------*/
  2965. ACMD_FUNC(mapexit)
  2966. {
  2967. nullpo_retr(-1, sd);
  2968. do_shutdown();
  2969. return 0;
  2970. }
  2971. /*==========================================
  2972. * idsearch <part_of_name>: revrited by [Yor]
  2973. *------------------------------------------*/
  2974. ACMD_FUNC(idsearch)
  2975. {
  2976. char item_name[100];
  2977. unsigned int i, match;
  2978. struct item_data *item_array[MAX_SEARCH];
  2979. nullpo_retr(-1, sd);
  2980. memset(item_name, '\0', sizeof(item_name));
  2981. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2982. if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
  2983. clif_displaymessage(fd, msg_txt(sd,1031)); // Please enter part of an item name (usage: @idsearch <part_of_item_name>).
  2984. return -1;
  2985. }
  2986. sprintf(atcmd_output, msg_txt(sd,77), item_name); // The reference result of '%s' (name: id):
  2987. clif_displaymessage(fd, atcmd_output);
  2988. match = itemdb_searchname_array(item_array, MAX_SEARCH, item_name);
  2989. if (match > MAX_SEARCH) {
  2990. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH, match);
  2991. clif_displaymessage(fd, atcmd_output);
  2992. match = MAX_SEARCH;
  2993. }
  2994. for(i = 0; i < match; i++) {
  2995. sprintf(atcmd_output, msg_txt(sd,78), item_array[i]->jname, item_array[i]->nameid); // %s: %d
  2996. clif_displaymessage(fd, atcmd_output);
  2997. }
  2998. sprintf(atcmd_output, msg_txt(sd,79), match); // It is %d affair above.
  2999. clif_displaymessage(fd, atcmd_output);
  3000. return 0;
  3001. }
  3002. /*==========================================
  3003. * Recall All Characters Online To Your Location
  3004. *------------------------------------------*/
  3005. ACMD_FUNC(recallall)
  3006. {
  3007. struct map_session_data* pl_sd;
  3008. struct s_mapiterator* iter;
  3009. int count;
  3010. nullpo_retr(-1, sd);
  3011. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3012. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3013. clif_displaymessage(fd, msg_txt(sd,1032)); // You are not authorized to warp someone to your current map.
  3014. return -1;
  3015. }
  3016. count = 0;
  3017. iter = mapit_getallusers();
  3018. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3019. {
  3020. if (sd->status.account_id != pl_sd->status.account_id && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  3021. {
  3022. if (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y)
  3023. continue; // Don't waste time warping the character to the same place.
  3024. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3025. count++;
  3026. else {
  3027. if (pc_isdead(pl_sd)) { //Wake them up
  3028. pc_setstand(pl_sd);
  3029. pc_setrestartvalue(pl_sd,1);
  3030. }
  3031. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  3032. }
  3033. }
  3034. }
  3035. mapit_free(iter);
  3036. clif_displaymessage(fd, msg_txt(sd,92)); // All characters recalled!
  3037. if (count) {
  3038. 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.
  3039. clif_displaymessage(fd, atcmd_output);
  3040. }
  3041. return 0;
  3042. }
  3043. /*==========================================
  3044. * Recall online characters of a guild to your location
  3045. *------------------------------------------*/
  3046. ACMD_FUNC(guildrecall)
  3047. {
  3048. struct map_session_data* pl_sd;
  3049. struct s_mapiterator* iter;
  3050. int count;
  3051. char guild_name[NAME_LENGTH];
  3052. struct guild *g;
  3053. nullpo_retr(-1, sd);
  3054. memset(guild_name, '\0', sizeof(guild_name));
  3055. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3056. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  3057. clif_displaymessage(fd, msg_txt(sd,1034)); // Please enter a guild name/ID (usage: @guildrecall <guild_name/ID>).
  3058. return -1;
  3059. }
  3060. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3061. clif_displaymessage(fd, msg_txt(sd,1032)); // You are not authorized to warp someone to your current map.
  3062. return -1;
  3063. }
  3064. if ((g = guild_searchname(guild_name)) == NULL && // name first to avoid error when name begin with a number
  3065. (g = guild_search(atoi(message))) == NULL)
  3066. {
  3067. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  3068. return -1;
  3069. }
  3070. count = 0;
  3071. iter = mapit_getallusers();
  3072. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3073. {
  3074. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.guild_id == g->guild_id)
  3075. {
  3076. 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))
  3077. continue; // Skip GMs greater than you... or chars already on the cell
  3078. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3079. count++;
  3080. else
  3081. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  3082. }
  3083. }
  3084. mapit_free(iter);
  3085. sprintf(atcmd_output, msg_txt(sd,93), g->name); // All online characters of the %s guild have been recalled to your position.
  3086. clif_displaymessage(fd, atcmd_output);
  3087. if (count) {
  3088. 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.
  3089. clif_displaymessage(fd, atcmd_output);
  3090. }
  3091. return 0;
  3092. }
  3093. /*==========================================
  3094. * Recall online characters of a party to your location
  3095. *------------------------------------------*/
  3096. ACMD_FUNC(partyrecall)
  3097. {
  3098. struct map_session_data* pl_sd;
  3099. struct s_mapiterator* iter;
  3100. char party_name[NAME_LENGTH];
  3101. struct party_data *p;
  3102. int count;
  3103. nullpo_retr(-1, sd);
  3104. memset(party_name, '\0', sizeof(party_name));
  3105. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3106. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3107. clif_displaymessage(fd, msg_txt(sd,1035)); // Please enter a party name/ID (usage: @partyrecall <party_name/ID>).
  3108. return -1;
  3109. }
  3110. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3111. clif_displaymessage(fd, msg_txt(sd,1032)); // You are not authorized to warp someone to your current map.
  3112. return -1;
  3113. }
  3114. if ((p = party_searchname(party_name)) == NULL && // name first to avoid error when name begin with a number
  3115. (p = party_search(atoi(message))) == NULL)
  3116. {
  3117. clif_displaymessage(fd, msg_txt(sd,96)); // Incorrect name or ID, or no one from the party is online.
  3118. return -1;
  3119. }
  3120. count = 0;
  3121. iter = mapit_getallusers();
  3122. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3123. {
  3124. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.party_id == p->party.party_id)
  3125. {
  3126. 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))
  3127. continue; // Skip GMs greater than you... or chars already on the cell
  3128. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3129. count++;
  3130. else
  3131. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  3132. }
  3133. }
  3134. mapit_free(iter);
  3135. sprintf(atcmd_output, msg_txt(sd,95), p->party.name); // All online characters of the %s party have been recalled to your position.
  3136. clif_displaymessage(fd, atcmd_output);
  3137. if (count) {
  3138. 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.
  3139. clif_displaymessage(fd, atcmd_output);
  3140. }
  3141. return 0;
  3142. }
  3143. /*==========================================
  3144. *
  3145. *------------------------------------------*/
  3146. void atcommand_doload();
  3147. ACMD_FUNC(reload) {
  3148. nullpo_retr(-1, sd);
  3149. if ((strlen(command) < 8 ) && (!message || !*message)) {
  3150. const char* text;
  3151. text = atcommand_help_string( command );
  3152. if(text)
  3153. clif_displaymessage( fd, text );
  3154. return -1;
  3155. }
  3156. if (strstr(command, "itemdb") || strncmp(message, "itemdb", 4) == 0) {
  3157. itemdb_reload();
  3158. clif_displaymessage(fd, msg_txt(sd,97)); // Item database has been reloaded.
  3159. } else if (strstr(command, "mobdb") || strncmp(message, "mobdb", 3) == 0) {
  3160. mob_reload();
  3161. read_petdb();
  3162. hom_reload();
  3163. mercenary_readdb();
  3164. mercenary_read_skilldb();
  3165. reload_elementaldb();
  3166. clif_displaymessage(fd, msg_txt(sd,98)); // Monster database has been reloaded.
  3167. } else if (strstr(command, "skilldb") || strncmp(message, "skilldb", 4) == 0) {
  3168. skill_reload();
  3169. hom_reload_skill();
  3170. reload_elemental_skilldb();
  3171. mercenary_read_skilldb();
  3172. clif_displaymessage(fd, msg_txt(sd,99)); // Skill database has been reloaded.
  3173. } else if (strstr(command, "atcommand") || strncmp(message, "atcommand", 4) == 0) {
  3174. config_t run_test;
  3175. if (conf_read_file(&run_test, "conf/groups.conf")) {
  3176. clif_displaymessage(fd, msg_txt(sd,1036)); // Error reading groups.conf, reload failed.
  3177. return -1;
  3178. }
  3179. config_destroy(&run_test);
  3180. if (conf_read_file(&run_test, ATCOMMAND_CONF_FILENAME)) {
  3181. clif_displaymessage(fd, msg_txt(sd,1037)); // Error reading atcommand_athena.conf, reload failed.
  3182. return -1;
  3183. }
  3184. config_destroy(&run_test);
  3185. atcommand_doload();
  3186. pc_groups_reload();
  3187. clif_displaymessage(fd, msg_txt(sd,254));
  3188. } else if (strstr(command, "battleconf") || strncmp(message, "battleconf", 3) == 0) {
  3189. struct Battle_Config prev_config;
  3190. memcpy(&prev_config, &battle_config, sizeof(prev_config));
  3191. battle_config_read(BATTLE_CONF_FILENAME);
  3192. if( prev_config.item_rate_mvp != battle_config.item_rate_mvp
  3193. || prev_config.item_rate_common != battle_config.item_rate_common
  3194. || prev_config.item_rate_common_boss != battle_config.item_rate_common_boss
  3195. || prev_config.item_rate_card != battle_config.item_rate_card
  3196. || prev_config.item_rate_card_boss != battle_config.item_rate_card_boss
  3197. || prev_config.item_rate_equip != battle_config.item_rate_equip
  3198. || prev_config.item_rate_equip_boss != battle_config.item_rate_equip_boss
  3199. || prev_config.item_rate_heal != battle_config.item_rate_heal
  3200. || prev_config.item_rate_heal_boss != battle_config.item_rate_heal_boss
  3201. || prev_config.item_rate_use != battle_config.item_rate_use
  3202. || prev_config.item_rate_use_boss != battle_config.item_rate_use_boss
  3203. || prev_config.item_rate_treasure != battle_config.item_rate_treasure
  3204. || prev_config.item_rate_adddrop != battle_config.item_rate_adddrop
  3205. || prev_config.logarithmic_drops != battle_config.logarithmic_drops
  3206. || prev_config.item_drop_common_min != battle_config.item_drop_common_min
  3207. || prev_config.item_drop_common_max != battle_config.item_drop_common_max
  3208. || prev_config.item_drop_card_min != battle_config.item_drop_card_min
  3209. || prev_config.item_drop_card_max != battle_config.item_drop_card_max
  3210. || prev_config.item_drop_equip_min != battle_config.item_drop_equip_min
  3211. || prev_config.item_drop_equip_max != battle_config.item_drop_equip_max
  3212. || prev_config.item_drop_mvp_min != battle_config.item_drop_mvp_min
  3213. || prev_config.item_drop_mvp_max != battle_config.item_drop_mvp_max
  3214. || prev_config.item_drop_heal_min != battle_config.item_drop_heal_min
  3215. || prev_config.item_drop_heal_max != battle_config.item_drop_heal_max
  3216. || prev_config.item_drop_use_min != battle_config.item_drop_use_min
  3217. || prev_config.item_drop_use_max != battle_config.item_drop_use_max
  3218. || prev_config.item_drop_treasure_min != battle_config.item_drop_treasure_min
  3219. || prev_config.item_drop_treasure_max != battle_config.item_drop_treasure_max
  3220. || prev_config.base_exp_rate != battle_config.base_exp_rate
  3221. || prev_config.job_exp_rate != battle_config.job_exp_rate
  3222. )
  3223. { // Exp or Drop rates changed.
  3224. mob_reload(); //Needed as well so rate changes take effect.
  3225. chrif_ragsrvinfo(battle_config.base_exp_rate, battle_config.job_exp_rate, battle_config.item_rate_common);
  3226. }
  3227. clif_displaymessage(fd, msg_txt(sd,255));
  3228. } else if (strstr(command, "statusdb") || strncmp(message, "statusdb", 3) == 0) {
  3229. status_readdb();
  3230. clif_displaymessage(fd, msg_txt(sd,256));
  3231. } else if (strstr(command, "pcdb") || strncmp(message, "pcdb", 2) == 0) {
  3232. pc_readdb();
  3233. clif_displaymessage(fd, msg_txt(sd,257));
  3234. } else if (strstr(command, "motd") || strncmp(message, "motd", 4) == 0) {
  3235. pc_read_motd();
  3236. clif_displaymessage(fd, msg_txt(sd,268));
  3237. } else if (strstr(command, "script") || strncmp(message, "script", 3) == 0) {
  3238. struct s_mapiterator* iter;
  3239. struct map_session_data* pl_sd;
  3240. //atcommand_broadcast( fd, sd, "@broadcast", "Server is reloading scripts..." );
  3241. //atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
  3242. iter = mapit_getallusers();
  3243. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3244. pc_close_npc(pl_sd,2);
  3245. mapit_free(iter);
  3246. flush_fifos();
  3247. map_reloadnpc(true); // reload config files seeking for npcs
  3248. script_reload();
  3249. npc_reload();
  3250. clif_displaymessage(fd, msg_txt(sd,100)); // Scripts have been reloaded.
  3251. } else if (strstr(command, "msgconf") || strncmp(message, "msgconf", 3) == 0) {
  3252. map_msg_reload();
  3253. clif_displaymessage(fd, msg_txt(sd,463)); // Message configuration has been reloaded.
  3254. } else if (strstr(command, "questdb") || strncmp(message, "questdb", 3) == 0) {
  3255. do_reload_quest();
  3256. clif_displaymessage(fd, msg_txt(sd,1377)); // Quest database has been reloaded.
  3257. } else if (strstr(command, "packetdb") || strncmp(message, "packetdb", 4) == 0) {
  3258. packetdb_readdb();
  3259. clif_displaymessage(fd, msg_txt(sd,1477)); // Packet database has been reloaded.
  3260. } else if (strstr(command, "instancedb") || strncmp(message, "instancedb", 4) == 0) {
  3261. instance_readdb();
  3262. clif_displaymessage(fd, msg_txt(sd,516)); // Instance database has been reloaded.
  3263. }
  3264. return 0;
  3265. }
  3266. /*==========================================
  3267. * @partysharelvl <share_range> [Akinari]
  3268. * Updates char server party share level range in runtime
  3269. * Temporary - Permanent update in inter_athena.conf
  3270. *------------------------------------------*/
  3271. ACMD_FUNC(partysharelvl) {
  3272. unsigned int share_lvl;
  3273. nullpo_retr(-1, sd);
  3274. if(!message || !*message) {
  3275. clif_displaymessage(fd, msg_txt(sd,1322)); // Please enter an amount.
  3276. return -1;
  3277. } else
  3278. share_lvl = min(abs(atoi(message)),MAX_LEVEL);
  3279. if(intif_party_sharelvlupdate(share_lvl)) //Successfully updated
  3280. clif_displaymessage(fd, msg_txt(sd,1478)); // Party share level range has been changed successfully.
  3281. else //Char server offline
  3282. clif_displaymessage(fd, msg_txt(sd,1479)); // Failed to update configuration. Character server is offline.
  3283. return 0;
  3284. }
  3285. /*==========================================
  3286. * @mapinfo [0-3] <map name> by MC_Cameri
  3287. * => Shows information about the map [map name]
  3288. * 0 = no additional information
  3289. * 1 = Show users in that map and their location
  3290. * 2 = Shows NPCs in that map
  3291. * 3 = Shows the chats in that map
  3292. *------------------------------------------*/
  3293. ACMD_FUNC(mapinfo) {
  3294. struct map_session_data* pl_sd;
  3295. struct s_mapiterator* iter;
  3296. struct chat_data *cd = NULL;
  3297. char direction[12];
  3298. int i, m_id, chat_num = 0, list = 0, vend_num = 0;
  3299. unsigned short m_index;
  3300. char mapname[24];
  3301. nullpo_retr(-1, sd);
  3302. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3303. memset(mapname, '\0', sizeof(mapname));
  3304. memset(direction, '\0', sizeof(direction));
  3305. sscanf(message, "%d %23[^\n]", &list, mapname);
  3306. if (list < 0 || list > 3) {
  3307. clif_displaymessage(fd, msg_txt(sd,1038)); // Please enter at least one valid list number (usage: @mapinfo <0-3> <map>).
  3308. return -1;
  3309. }
  3310. if (mapname[0] == '\0') {
  3311. safestrncpy(mapname, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
  3312. m_id = map_mapindex2mapid(sd->mapindex);
  3313. } else {
  3314. m_id = map_mapname2mapid(mapname);
  3315. }
  3316. if (m_id < 0) {
  3317. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  3318. return -1;
  3319. }
  3320. m_index = mapindex_name2id(mapname); //This one shouldn't fail since the previous seek did not.
  3321. clif_displaymessage(fd, msg_txt(sd,1039)); // ------ Map Info ------
  3322. // count chats (for initial message)
  3323. chat_num = 0;
  3324. iter = mapit_getallusers();
  3325. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) {
  3326. if( pl_sd->mapindex == m_index ) {
  3327. if( pl_sd->state.vending )
  3328. vend_num++;
  3329. else if( (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL && cd->usersd[0] == pl_sd )
  3330. chat_num++;
  3331. }
  3332. }
  3333. mapit_free(iter);
  3334. sprintf(atcmd_output, msg_txt(sd,1040), mapname, map[m_id].users, map[m_id].npc_num, chat_num, vend_num); // Map: %s | Players: %d | NPCs: %d | Chats: %d | Vendings: %d
  3335. clif_displaymessage(fd, atcmd_output);
  3336. clif_displaymessage(fd, msg_txt(sd,1041)); // ------ Map Flags ------
  3337. if (map[m_id].flag.town)
  3338. clif_displaymessage(fd, msg_txt(sd,1042)); // Town Map
  3339. if (map[m_id].flag.restricted){
  3340. sprintf(atcmd_output, " Restricted (zone %d)",map[m_id].zone);
  3341. clif_displaymessage(fd, atcmd_output);
  3342. }
  3343. if (battle_config.autotrade_mapflag == map[m_id].flag.autotrade)
  3344. clif_displaymessage(fd, msg_txt(sd,1043)); // Autotrade Enabled
  3345. else
  3346. clif_displaymessage(fd, msg_txt(sd,1044)); // Autotrade Disabled
  3347. if (map[m_id].flag.battleground){
  3348. sprintf(atcmd_output, msg_txt(sd,1045),map[m_id].flag.battleground); // Battlegrounds ON (type %d)
  3349. clif_displaymessage(fd, atcmd_output);
  3350. }
  3351. /* Skill damage adjustment info [Cydh] */
  3352. #ifdef ADJUST_SKILL_DAMAGE
  3353. if (map[m_id].flag.skill_damage) {
  3354. int j;
  3355. clif_displaymessage(fd,msg_txt(sd,1052)); // Skill Damage Adjustments:
  3356. sprintf(atcmd_output," > [Map] %d%%, %d%%, %d%%, %d%% | Caster:%d"
  3357. ,map[m_id].adjust.damage.pc
  3358. ,map[m_id].adjust.damage.mob
  3359. ,map[m_id].adjust.damage.boss
  3360. ,map[m_id].adjust.damage.other
  3361. ,map[m_id].adjust.damage.caster);
  3362. clif_displaymessage(fd, atcmd_output);
  3363. if (map[m_id].skill_damage[0].skill_id) {
  3364. clif_displaymessage(fd," > [Map Skill] Name : Player, Monster, Boss Monster, Other | Caster");
  3365. for (j = 0; j < MAX_MAP_SKILL_MODIFIER; j++) {
  3366. if (map[m_id].skill_damage[j].skill_id) {
  3367. sprintf(atcmd_output," %d. %s : %d%%, %d%%, %d%%, %d%% | %d"
  3368. ,j+1
  3369. ,skill_db[skill_get_index(map[m_id].skill_damage[j].skill_id)].name
  3370. ,map[m_id].skill_damage[j].pc
  3371. ,map[m_id].skill_damage[j].mob
  3372. ,map[m_id].skill_damage[j].boss
  3373. ,map[m_id].skill_damage[j].other
  3374. ,map[m_id].skill_damage[j].caster);
  3375. clif_displaymessage(fd,atcmd_output);
  3376. }
  3377. }
  3378. }
  3379. }
  3380. #endif
  3381. strcpy(atcmd_output,msg_txt(sd,1046)); // PvP Flags:
  3382. if (map[m_id].flag.pvp)
  3383. strcat(atcmd_output, " Pvp ON |");
  3384. if (map[m_id].flag.pvp_noguild)
  3385. strcat(atcmd_output, " NoGuild |");
  3386. if (map[m_id].flag.pvp_noparty)
  3387. strcat(atcmd_output, " NoParty |");
  3388. if (map[m_id].flag.pvp_nightmaredrop)
  3389. strcat(atcmd_output, " NightmareDrop |");
  3390. if (map[m_id].flag.pvp_nocalcrank)
  3391. strcat(atcmd_output, " NoCalcRank |");
  3392. clif_displaymessage(fd, atcmd_output);
  3393. strcpy(atcmd_output,msg_txt(sd,1047)); // GvG Flags:
  3394. if (map[m_id].flag.gvg)
  3395. strcat(atcmd_output, " GvG ON |");
  3396. if (map[m_id].flag.gvg_dungeon)
  3397. strcat(atcmd_output, " GvG Dungeon |");
  3398. if (map[m_id].flag.gvg_castle)
  3399. strcat(atcmd_output, " GvG Castle |");
  3400. if (map[m_id].flag.gvg_noparty)
  3401. strcat(atcmd_output, " NoParty |");
  3402. clif_displaymessage(fd, atcmd_output);
  3403. strcpy(atcmd_output,msg_txt(sd,1048)); // Teleport Flags:
  3404. if (map[m_id].flag.noteleport)
  3405. strcat(atcmd_output, " NoTeleport |");
  3406. if (map[m_id].flag.monster_noteleport)
  3407. strcat(atcmd_output, " Monster NoTeleport |");
  3408. if (map[m_id].flag.nowarp)
  3409. strcat(atcmd_output, " NoWarp |");
  3410. if (map[m_id].flag.nowarpto)
  3411. strcat(atcmd_output, " NoWarpTo |");
  3412. if (map[m_id].flag.noreturn)
  3413. strcat(atcmd_output, " NoReturn |");
  3414. if (map[m_id].flag.nogo)
  3415. strcat(atcmd_output, " NoGo |"); //
  3416. if (map[m_id].flag.nomemo)
  3417. strcat(atcmd_output, " NoMemo |");
  3418. clif_displaymessage(fd, atcmd_output);
  3419. sprintf(atcmd_output, msg_txt(sd,1065), // No Exp Penalty: %s | No Zeny Penalty: %s
  3420. (map[m_id].flag.noexppenalty) ? msg_txt(sd,1066) : msg_txt(sd,1067), (map[m_id].flag.nozenypenalty) ? msg_txt(sd,1066) : msg_txt(sd,1067)); // On / Off
  3421. clif_displaymessage(fd, atcmd_output);
  3422. if (map[m_id].flag.nosave) {
  3423. if (!map[m_id].save.map)
  3424. clif_displaymessage(fd, msg_txt(sd,1068)); // No Save (Return to last Save Point)
  3425. else if (map[m_id].save.x == -1 || map[m_id].save.y == -1 ) {
  3426. sprintf(atcmd_output, msg_txt(sd,1069), mapindex_id2name(map[m_id].save.map)); // No Save, Save Point: %s,Random
  3427. clif_displaymessage(fd, atcmd_output);
  3428. }
  3429. else {
  3430. sprintf(atcmd_output, msg_txt(sd,1070), // No Save, Save Point: %s,%d,%d
  3431. mapindex_id2name(map[m_id].save.map),map[m_id].save.x,map[m_id].save.y);
  3432. clif_displaymessage(fd, atcmd_output);
  3433. }
  3434. }
  3435. strcpy(atcmd_output,msg_txt(sd,1049)); // Weather Flags:
  3436. if (map[m_id].flag.snow)
  3437. strcat(atcmd_output, " Snow |");
  3438. if (map[m_id].flag.fog)
  3439. strcat(atcmd_output, " Fog |");
  3440. if (map[m_id].flag.sakura)
  3441. strcat(atcmd_output, " Sakura |");
  3442. if (map[m_id].flag.clouds)
  3443. strcat(atcmd_output, " Clouds |");
  3444. if (map[m_id].flag.clouds2)
  3445. strcat(atcmd_output, " Clouds2 |");
  3446. if (map[m_id].flag.fireworks)
  3447. strcat(atcmd_output, " Fireworks |");
  3448. if (map[m_id].flag.leaves)
  3449. strcat(atcmd_output, " Leaves |");
  3450. if (map[m_id].flag.nightenabled)
  3451. strcat(atcmd_output, " Displays Night |");
  3452. clif_displaymessage(fd, atcmd_output);
  3453. strcpy(atcmd_output,msg_txt(sd,1050)); // Other Flags:
  3454. if (map[m_id].flag.nobranch)
  3455. strcat(atcmd_output, " NoBranch |");
  3456. if (map[m_id].flag.notrade)
  3457. strcat(atcmd_output, " NoTrade |");
  3458. if (map[m_id].flag.novending)
  3459. strcat(atcmd_output, " NoVending |");
  3460. if (map[m_id].flag.nodrop)
  3461. strcat(atcmd_output, " NoDrop |");
  3462. if (map[m_id].flag.noskill)
  3463. strcat(atcmd_output, " NoSkill |");
  3464. if (map[m_id].flag.noicewall)
  3465. strcat(atcmd_output, " NoIcewall |");
  3466. if (map[m_id].flag.allowks)
  3467. strcat(atcmd_output, " AllowKS |");
  3468. if (map[m_id].flag.reset)
  3469. strcat(atcmd_output, " Reset |");
  3470. clif_displaymessage(fd, atcmd_output);
  3471. strcpy(atcmd_output,msg_txt(sd,1051)); // Other Flags2:
  3472. if (map[m_id].nocommand)
  3473. strcat(atcmd_output, " NoCommand |");
  3474. if (map[m_id].flag.nobaseexp)
  3475. strcat(atcmd_output, " NoBaseEXP |");
  3476. if (map[m_id].flag.nojobexp)
  3477. strcat(atcmd_output, " NoJobEXP |");
  3478. if (map[m_id].flag.nomobloot)
  3479. strcat(atcmd_output, " NoMobLoot |");
  3480. if (map[m_id].flag.nomvploot)
  3481. strcat(atcmd_output, " NoMVPLoot |");
  3482. if (map[m_id].flag.partylock)
  3483. strcat(atcmd_output, " PartyLock |");
  3484. if (map[m_id].flag.guildlock)
  3485. strcat(atcmd_output, " GuildLock |");
  3486. if (map[m_id].flag.loadevent)
  3487. strcat(atcmd_output, " Loadevent |");
  3488. if (map[m_id].flag.chmautojoin)
  3489. strcat(atcmd_output, " Chmautojoin |");
  3490. if (map[m_id].flag.nousecart)
  3491. strcat(atcmd_output, " NoUsecart |");
  3492. if (map[m_id].flag.noitemconsumption)
  3493. strcat(atcmd_output, " NoItemConsumption |");
  3494. if (map[m_id].flag.nosumstarmiracle)
  3495. strcat(atcmd_output, " NoSumStarMiracle |");
  3496. if (map[m_id].flag.nomineeffect)
  3497. strcat(atcmd_output, " NoMineEffect |");
  3498. if (map[m_id].flag.nolockon)
  3499. strcat(atcmd_output, " NoLockOn |");
  3500. if (map[m_id].flag.notomb)
  3501. strcat(atcmd_output, " NoTomb |");
  3502. clif_displaymessage(fd, atcmd_output);
  3503. switch (list) {
  3504. case 0:
  3505. // Do nothing. It's list 0, no additional display.
  3506. break;
  3507. case 1:
  3508. clif_displaymessage(fd, msg_txt(sd,480)); // ----- Players in Map -----
  3509. iter = mapit_getallusers();
  3510. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3511. {
  3512. if (pl_sd->mapindex == m_index) {
  3513. sprintf(atcmd_output, msg_txt(sd,481), // Player '%s' (session #%d) | Location: %d,%d
  3514. pl_sd->status.name, pl_sd->fd, pl_sd->bl.x, pl_sd->bl.y);
  3515. clif_displaymessage(fd, atcmd_output);
  3516. }
  3517. }
  3518. mapit_free(iter);
  3519. break;
  3520. case 2:
  3521. clif_displaymessage(fd, msg_txt(sd,482)); // ----- NPCs in Map -----
  3522. for (i = 0; i < map[m_id].npc_num;)
  3523. {
  3524. struct npc_data *nd = map[m_id].npc[i];
  3525. switch(nd->ud.dir) {
  3526. case 0: strcpy(direction, msg_txt(sd,491)); break; // North
  3527. case 1: strcpy(direction, msg_txt(sd,492)); break; // North West
  3528. case 2: strcpy(direction, msg_txt(sd,493)); break; // West
  3529. case 3: strcpy(direction, msg_txt(sd,494)); break; // South West
  3530. case 4: strcpy(direction, msg_txt(sd,495)); break; // South
  3531. case 5: strcpy(direction, msg_txt(sd,496)); break; // South East
  3532. case 6: strcpy(direction, msg_txt(sd,497)); break; // East
  3533. case 7: strcpy(direction, msg_txt(sd,498)); break; // North East
  3534. case 9: strcpy(direction, msg_txt(sd,491)); break; // North
  3535. default: strcpy(direction, msg_txt(sd,499)); break; // Unknown
  3536. }
  3537. if(strcmp(nd->name,nd->exname) == 0)
  3538. sprintf(atcmd_output, msg_txt(sd,490), // NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d
  3539. ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
  3540. else
  3541. sprintf(atcmd_output, msg_txt(sd,489), // NPC %d: %s::%s | Direction: %s | Sprite: %d | Location: %d %d
  3542. ++i, nd->name, nd->exname, direction, nd->class_, nd->bl.x, nd->bl.y);
  3543. clif_displaymessage(fd, atcmd_output);
  3544. }
  3545. break;
  3546. case 3:
  3547. clif_displaymessage(fd, msg_txt(sd,483)); // ----- Chats in Map -----
  3548. iter = mapit_getallusers();
  3549. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3550. {
  3551. if ((cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL &&
  3552. pl_sd->mapindex == m_index &&
  3553. cd->usersd[0] == pl_sd)
  3554. {
  3555. sprintf(atcmd_output, msg_txt(sd,484), // Chat: %s | Player: %s | Location: %d %d
  3556. cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
  3557. clif_displaymessage(fd, atcmd_output);
  3558. sprintf(atcmd_output, msg_txt(sd,485), // Users: %d/%d | Password: %s | Public: %s
  3559. cd->users, cd->limit, cd->pass, (cd->pub) ? msg_txt(sd,486) : msg_txt(sd,487)); // Yes / No
  3560. clif_displaymessage(fd, atcmd_output);
  3561. }
  3562. }
  3563. mapit_free(iter);
  3564. break;
  3565. default: // normally impossible to arrive here
  3566. clif_displaymessage(fd, msg_txt(sd,488)); // Please enter at least one valid list number (usage: @mapinfo <0-3> <map>).
  3567. return -1;
  3568. break;
  3569. }
  3570. return 0;
  3571. }
  3572. /*==========================================
  3573. *
  3574. *------------------------------------------*/
  3575. ACMD_FUNC(mount_peco)
  3576. {
  3577. nullpo_retr(-1, sd);
  3578. if (sd->disguise) {
  3579. clif_displaymessage(fd, msg_txt(sd,212)); // Cannot mount while in disguise.
  3580. return -1;
  3581. }
  3582. if( (sd->class_&MAPID_THIRDMASK) == MAPID_RUNE_KNIGHT && pc_checkskill(sd,RK_DRAGONTRAINING) > 0 ) {
  3583. if( !(sd->sc.option&OPTION_DRAGON) ) {
  3584. unsigned int option = OPTION_DRAGON1;
  3585. if( message[0] ) {
  3586. int color = atoi(message);
  3587. option = ( color == 2 ? OPTION_DRAGON2 :
  3588. color == 3 ? OPTION_DRAGON3 :
  3589. color == 4 ? OPTION_DRAGON4 :
  3590. color == 5 ? OPTION_DRAGON5 :
  3591. OPTION_DRAGON1 );
  3592. }
  3593. clif_displaymessage(sd->fd,msg_txt(sd,1119)); // You have mounted your Dragon.
  3594. pc_setoption(sd, sd->sc.option|option);
  3595. } else {
  3596. clif_displaymessage(sd->fd,msg_txt(sd,1120)); // You have released your Dragon.
  3597. pc_setoption(sd, sd->sc.option&~OPTION_DRAGON);
  3598. }
  3599. return 0;
  3600. }
  3601. if( (sd->class_&MAPID_THIRDMASK) == MAPID_RANGER && pc_checkskill(sd,RA_WUGRIDER) > 0 && (!pc_isfalcon(sd) || battle_config.warg_can_falcon) ) {
  3602. if( !pc_isridingwug(sd) ) {
  3603. clif_displaymessage(sd->fd,msg_txt(sd,1121)); // You have mounted your Warg.
  3604. pc_setoption(sd, sd->sc.option|OPTION_WUGRIDER);
  3605. } else {
  3606. clif_displaymessage(sd->fd,msg_txt(sd,1122)); // You have released your Warg.
  3607. pc_setoption(sd, sd->sc.option&~OPTION_WUGRIDER);
  3608. }
  3609. return 0;
  3610. }
  3611. if( (sd->class_&MAPID_THIRDMASK) == MAPID_MECHANIC ) {
  3612. if( !pc_ismadogear(sd) ) {
  3613. clif_displaymessage(sd->fd,msg_txt(sd,1123)); // You have mounted your Mado Gear.
  3614. pc_setoption(sd, sd->sc.option|OPTION_MADOGEAR);
  3615. } else {
  3616. clif_displaymessage(sd->fd,msg_txt(sd,1124)); // You have released your Mado Gear.
  3617. pc_setoption(sd, sd->sc.option&~OPTION_MADOGEAR);
  3618. }
  3619. return 0;
  3620. }
  3621. if (!pc_isriding(sd)) { // if actually no peco
  3622. if (!pc_checkskill(sd, KN_RIDING)) {
  3623. clif_displaymessage(fd, msg_txt(sd,213)); // You can not mount a Peco Peco with your current job.
  3624. return -1;
  3625. }
  3626. pc_setoption(sd, sd->sc.option | OPTION_RIDING);
  3627. clif_displaymessage(fd, msg_txt(sd,102)); // You have mounted a Peco Peco.
  3628. } else {//Dismount
  3629. pc_setoption(sd, sd->sc.option & ~OPTION_RIDING);
  3630. clif_displaymessage(fd, msg_txt(sd,214)); // You have released your Peco Peco.
  3631. }
  3632. return 0;
  3633. }
  3634. /*==========================================
  3635. *Spy Commands by Syrus22
  3636. *------------------------------------------*/
  3637. ACMD_FUNC(guildspy)
  3638. {
  3639. char guild_name[NAME_LENGTH];
  3640. struct guild *g;
  3641. nullpo_retr(-1, sd);
  3642. memset(guild_name, '\0', sizeof(guild_name));
  3643. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3644. if (!enable_spy)
  3645. {
  3646. clif_displaymessage(fd, msg_txt(sd,1125)); // The mapserver has spy command support disabled.
  3647. return -1;
  3648. }
  3649. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  3650. clif_displaymessage(fd, msg_txt(sd,1126)); // Please enter a guild name/ID (usage: @guildspy <guild_name/ID>).
  3651. return -1;
  3652. }
  3653. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  3654. (g = guild_search(atoi(message))) != NULL) {
  3655. if (sd->guildspy == g->guild_id) {
  3656. sd->guildspy = 0;
  3657. sprintf(atcmd_output, msg_txt(sd,103), g->name); // No longer spying on the %s guild.
  3658. clif_displaymessage(fd, atcmd_output);
  3659. } else {
  3660. sd->guildspy = g->guild_id;
  3661. sprintf(atcmd_output, msg_txt(sd,104), g->name); // Spying on the %s guild.
  3662. clif_displaymessage(fd, atcmd_output);
  3663. }
  3664. } else {
  3665. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the specified guild is online.
  3666. return -1;
  3667. }
  3668. return 0;
  3669. }
  3670. /*==========================================
  3671. *
  3672. *------------------------------------------*/
  3673. ACMD_FUNC(partyspy)
  3674. {
  3675. char party_name[NAME_LENGTH];
  3676. struct party_data *p;
  3677. nullpo_retr(-1, sd);
  3678. memset(party_name, '\0', sizeof(party_name));
  3679. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3680. if (!enable_spy)
  3681. {
  3682. clif_displaymessage(fd, msg_txt(sd,1125)); // The mapserver has spy command support disabled.
  3683. return -1;
  3684. }
  3685. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3686. clif_displaymessage(fd, msg_txt(sd,1127)); // Please enter a party name/ID (usage: @partyspy <party_name/ID>).
  3687. return -1;
  3688. }
  3689. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  3690. (p = party_search(atoi(message))) != NULL) {
  3691. if (sd->partyspy == p->party.party_id) {
  3692. sd->partyspy = 0;
  3693. sprintf(atcmd_output, msg_txt(sd,105), p->party.name); // No longer spying on the %s party.
  3694. clif_displaymessage(fd, atcmd_output);
  3695. } else {
  3696. sd->partyspy = p->party.party_id;
  3697. sprintf(atcmd_output, msg_txt(sd,106), p->party.name); // Spying on the %s party.
  3698. clif_displaymessage(fd, atcmd_output);
  3699. }
  3700. } else {
  3701. clif_displaymessage(fd, msg_txt(sd,96)); // Incorrect name/ID, or no one from the specified party is online.
  3702. return -1;
  3703. }
  3704. return 0;
  3705. }
  3706. /*==========================================
  3707. * @repairall [Valaris]
  3708. *------------------------------------------*/
  3709. ACMD_FUNC(repairall)
  3710. {
  3711. int count, i;
  3712. nullpo_retr(-1, sd);
  3713. count = 0;
  3714. for (i = 0; i < MAX_INVENTORY; i++) {
  3715. if (sd->status.inventory[i].nameid && sd->status.inventory[i].attribute == 1) {
  3716. sd->status.inventory[i].attribute = 0;
  3717. clif_produceeffect(sd, 0, sd->status.inventory[i].nameid);
  3718. count++;
  3719. }
  3720. }
  3721. if (count > 0) {
  3722. clif_misceffect(&sd->bl, 3);
  3723. clif_equiplist(sd);
  3724. clif_displaymessage(fd, msg_txt(sd,107)); // All items have been repaired.
  3725. } else {
  3726. clif_displaymessage(fd, msg_txt(sd,108)); // No item need to be repaired.
  3727. return -1;
  3728. }
  3729. return 0;
  3730. }
  3731. /*==========================================
  3732. * @nuke [Valaris]
  3733. *------------------------------------------*/
  3734. ACMD_FUNC(nuke)
  3735. {
  3736. struct map_session_data *pl_sd;
  3737. nullpo_retr(-1, sd);
  3738. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3739. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3740. clif_displaymessage(fd, msg_txt(sd,1128)); // Please enter a player name (usage: @nuke <char name>).
  3741. return -1;
  3742. }
  3743. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  3744. if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kill only lower or same GM level
  3745. skill_castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
  3746. clif_displaymessage(fd, msg_txt(sd,109)); // Player has been nuked!
  3747. } else {
  3748. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  3749. return -1;
  3750. }
  3751. } else {
  3752. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  3753. return -1;
  3754. }
  3755. return 0;
  3756. }
  3757. /*==========================================
  3758. * @tonpc
  3759. *------------------------------------------*/
  3760. ACMD_FUNC(tonpc)
  3761. {
  3762. char npcname[NAME_LENGTH+1];
  3763. struct npc_data *nd;
  3764. nullpo_retr(-1, sd);
  3765. memset(npcname, 0, sizeof(npcname));
  3766. if (!message || !*message || sscanf(message, "%23[^\n]", npcname) < 1) {
  3767. clif_displaymessage(fd, msg_txt(sd,1129)); // Please enter a NPC name (usage: @tonpc <NPC_name>).
  3768. return -1;
  3769. }
  3770. if ((nd = npc_name2id(npcname)) != NULL) {
  3771. if (pc_setpos(sd, map_id2index(nd->bl.m), nd->bl.x, nd->bl.y, CLR_TELEPORT) == 0)
  3772. clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
  3773. else
  3774. return -1;
  3775. } else {
  3776. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  3777. return -1;
  3778. }
  3779. return 0;
  3780. }
  3781. /*==========================================
  3782. *
  3783. *------------------------------------------*/
  3784. ACMD_FUNC(shownpc)
  3785. {
  3786. char NPCname[NAME_LENGTH+1];
  3787. nullpo_retr(-1, sd);
  3788. memset(NPCname, '\0', sizeof(NPCname));
  3789. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  3790. clif_displaymessage(fd, msg_txt(sd,1130)); // Please enter a NPC name (usage: @enablenpc <NPC_name>).
  3791. return -1;
  3792. }
  3793. if (npc_name2id(NPCname) != NULL) {
  3794. npc_enable(NPCname, 1);
  3795. clif_displaymessage(fd, msg_txt(sd,110)); // Npc Enabled.
  3796. } else {
  3797. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  3798. return -1;
  3799. }
  3800. return 0;
  3801. }
  3802. /*==========================================
  3803. *
  3804. *------------------------------------------*/
  3805. ACMD_FUNC(hidenpc)
  3806. {
  3807. char NPCname[NAME_LENGTH+1];
  3808. nullpo_retr(-1, sd);
  3809. memset(NPCname, '\0', sizeof(NPCname));
  3810. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  3811. clif_displaymessage(fd, msg_txt(sd,1131)); // Please enter a NPC name (usage: @hidenpc <NPC_name>).
  3812. return -1;
  3813. }
  3814. if (npc_name2id(NPCname) == NULL) {
  3815. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  3816. return -1;
  3817. }
  3818. npc_enable(NPCname, 0);
  3819. clif_displaymessage(fd, msg_txt(sd,112)); // Npc Disabled.
  3820. return 0;
  3821. }
  3822. ACMD_FUNC(loadnpc)
  3823. {
  3824. FILE *fp;
  3825. if (!message || !*message) {
  3826. clif_displaymessage(fd, msg_txt(sd,1132)); // Please enter a script file name (usage: @loadnpc <file name>).
  3827. return -1;
  3828. }
  3829. // check if script file exists
  3830. if ((fp = fopen(message, "r")) == NULL) {
  3831. clif_displaymessage(fd, msg_txt(sd,261));
  3832. return -1;
  3833. }
  3834. fclose(fp);
  3835. // add to list of script sources and run it
  3836. npc_addsrcfile(message);
  3837. npc_parsesrcfile(message,true);
  3838. npc_read_event_script();
  3839. clif_displaymessage(fd, msg_txt(sd,262));
  3840. return 0;
  3841. }
  3842. ACMD_FUNC(unloadnpc)
  3843. {
  3844. struct npc_data *nd;
  3845. char NPCname[NAME_LENGTH];
  3846. nullpo_retr(-1, sd);
  3847. memset(NPCname, '\0', sizeof(NPCname));
  3848. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  3849. clif_displaymessage(fd, msg_txt(sd,1133)); // Please enter a NPC name (usage: @unloadnpc <NPC_name>).
  3850. return -1;
  3851. }
  3852. if ((nd = npc_name2id(NPCname)) == NULL) {
  3853. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  3854. return -1;
  3855. }
  3856. npc_unload_duplicates(nd);
  3857. npc_unload(nd,true);
  3858. npc_read_event_script();
  3859. clif_displaymessage(fd, msg_txt(sd,112)); // Npc Disabled.
  3860. return 0;
  3861. }
  3862. /*==========================================
  3863. * time in txt for time command (by [Yor])
  3864. *------------------------------------------*/
  3865. char* txt_time(unsigned int duration)
  3866. {
  3867. int days, hours, minutes, seconds;
  3868. char temp[CHAT_SIZE_MAX];
  3869. static char temp1[CHAT_SIZE_MAX];
  3870. memset(temp, '\0', sizeof(temp));
  3871. memset(temp1, '\0', sizeof(temp1));
  3872. days = duration / (60 * 60 * 24);
  3873. duration = duration - (60 * 60 * 24 * days);
  3874. hours = duration / (60 * 60);
  3875. duration = duration - (60 * 60 * hours);
  3876. minutes = duration / 60;
  3877. seconds = duration - (60 * minutes);
  3878. if (days == 1)
  3879. sprintf(temp, msg_txt(NULL,219), days); // %d day
  3880. else if (days > 1)
  3881. sprintf(temp, msg_txt(NULL,220), days); // %d days
  3882. if (hours == 1)
  3883. sprintf(temp1, msg_txt(NULL,221), temp, hours); // %s %d hour
  3884. else if (hours > 1)
  3885. sprintf(temp1, msg_txt(NULL,222), temp, hours); // %s %d hours
  3886. if (minutes < 2)
  3887. sprintf(temp, msg_txt(NULL,223), temp1, minutes); // %s %d minute
  3888. else
  3889. sprintf(temp, msg_txt(NULL,224), temp1, minutes); // %s %d minutes
  3890. if (seconds == 1)
  3891. sprintf(temp1, msg_txt(NULL,225), temp, seconds); // %s and %d second
  3892. else if (seconds > 1)
  3893. sprintf(temp1, msg_txt(NULL,226), temp, seconds); // %s and %d seconds
  3894. return temp1;
  3895. }
  3896. /*==========================================
  3897. * @time/@date/@serverdate/@servertime: Display the date/time of the server (by [Yor]
  3898. * Calculation management of GM modification (@day/@night GM commands) is done
  3899. *------------------------------------------*/
  3900. ACMD_FUNC(servertime)
  3901. {
  3902. const struct TimerData * timer_data;
  3903. time_t time_server; // variable for number of seconds (used with time() function)
  3904. struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
  3905. char temp[CHAT_SIZE_MAX];
  3906. nullpo_retr(-1, sd);
  3907. memset(temp, '\0', sizeof(temp));
  3908. time(&time_server); // get time in seconds since 1/1/1970
  3909. datetime = localtime(&time_server); // convert seconds in structure
  3910. // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
  3911. strftime(temp, sizeof(temp)-1, msg_txt(sd,230), datetime); // Server time (normal time): %A, %B %d %Y %X.
  3912. clif_displaymessage(fd, temp);
  3913. if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
  3914. if (night_flag == 0)
  3915. clif_displaymessage(fd, msg_txt(sd,231)); // Game time: The game is in permanent daylight.
  3916. else
  3917. clif_displaymessage(fd, msg_txt(sd,232)); // Game time: The game is in permanent night.
  3918. } else if (battle_config.night_duration == 0)
  3919. if (night_flag == 1) { // we start with night
  3920. timer_data = get_timer(day_timer_tid);
  3921. sprintf(temp, msg_txt(sd,233), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is in night for %s.
  3922. clif_displaymessage(fd, temp);
  3923. clif_displaymessage(fd, msg_txt(sd,234)); // Game time: After, the game will be in permanent daylight.
  3924. } else
  3925. clif_displaymessage(fd, msg_txt(sd,231)); // Game time: The game is in permanent daylight.
  3926. else if (battle_config.day_duration == 0)
  3927. if (night_flag == 0) { // we start with day
  3928. timer_data = get_timer(night_timer_tid);
  3929. sprintf(temp, msg_txt(sd,235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is in daylight for %s.
  3930. clif_displaymessage(fd, temp);
  3931. clif_displaymessage(fd, msg_txt(sd,236)); // Game time: After, the game will be in permanent night.
  3932. } else
  3933. clif_displaymessage(fd, msg_txt(sd,232)); // Game time: The game is in permanent night.
  3934. else {
  3935. const struct TimerData * timer_data2;
  3936. if (night_flag == 0) {
  3937. timer_data = get_timer(night_timer_tid);
  3938. timer_data2 = get_timer(day_timer_tid);
  3939. sprintf(temp, msg_txt(sd,235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is in daylight for %s.
  3940. clif_displaymessage(fd, temp);
  3941. if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0)
  3942. 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.
  3943. else
  3944. 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.
  3945. clif_displaymessage(fd, temp);
  3946. sprintf(temp, msg_txt(sd,238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  3947. clif_displaymessage(fd, temp);
  3948. } else {
  3949. timer_data = get_timer(day_timer_tid);
  3950. timer_data2 = get_timer(night_timer_tid);
  3951. sprintf(temp, msg_txt(sd,233), txt_time(DIFF_TICK(timer_data->tick,gettick()) / 1000)); // Game time: The game is in night for %s.
  3952. clif_displaymessage(fd, temp);
  3953. if (DIFF_TICK(timer_data->tick,timer_data2->tick) > 0)
  3954. 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.
  3955. else
  3956. 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.
  3957. clif_displaymessage(fd, temp);
  3958. sprintf(temp, msg_txt(sd,238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  3959. clif_displaymessage(fd, temp);
  3960. }
  3961. }
  3962. return 0;
  3963. }
  3964. /*==========================================
  3965. * @jail <char_name> by [Yor]
  3966. * Special warp! No check with nowarp and nowarpto flag
  3967. *------------------------------------------*/
  3968. ACMD_FUNC(jail)
  3969. {
  3970. struct map_session_data *pl_sd;
  3971. int x, y;
  3972. unsigned short m_index;
  3973. nullpo_retr(-1, sd);
  3974. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3975. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3976. clif_displaymessage(fd, msg_txt(sd,1134)); // Please enter a player name (usage: @jail <char_name>).
  3977. return -1;
  3978. }
  3979. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  3980. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  3981. return -1;
  3982. }
  3983. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) { // you can jail only lower or same GM
  3984. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  3985. return -1;
  3986. }
  3987. if (pl_sd->sc.data[SC_JAILED]) {
  3988. clif_displaymessage(fd, msg_txt(sd,118)); // Player warped in jails.
  3989. return -1;
  3990. }
  3991. switch(rnd() % 2) { //Jail Locations
  3992. case 0:
  3993. m_index = mapindex_name2id(MAP_JAIL);
  3994. x = 24;
  3995. y = 75;
  3996. break;
  3997. default:
  3998. m_index = mapindex_name2id(MAP_JAIL);
  3999. x = 49;
  4000. y = 75;
  4001. break;
  4002. }
  4003. //Duration of INT_MAX to specify infinity.
  4004. sc_start4(NULL,&pl_sd->bl,SC_JAILED,100,INT_MAX,m_index,x,y,1000);
  4005. clif_displaymessage(pl_sd->fd, msg_txt(sd,117)); // GM has send you in jails.
  4006. clif_displaymessage(fd, msg_txt(sd,118)); // Player warped in jails.
  4007. return 0;
  4008. }
  4009. /*==========================================
  4010. * @unjail/@discharge <char_name> by [Yor]
  4011. * Special warp! No check with nowarp and nowarpto flag
  4012. *------------------------------------------*/
  4013. ACMD_FUNC(unjail)
  4014. {
  4015. struct map_session_data *pl_sd;
  4016. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4017. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4018. clif_displaymessage(fd, msg_txt(sd,1135)); // Please enter a player name (usage: @unjail/@discharge <char_name>).
  4019. return -1;
  4020. }
  4021. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  4022. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4023. return -1;
  4024. }
  4025. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) { // you can jail only lower or same GM
  4026. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4027. return -1;
  4028. }
  4029. if (!pl_sd->sc.data[SC_JAILED]) {
  4030. clif_displaymessage(fd, msg_txt(sd,119)); // This player is not in jails.
  4031. return -1;
  4032. }
  4033. //Reset jail time to 1 sec.
  4034. sc_start(NULL,&pl_sd->bl,SC_JAILED,100,1,1000);
  4035. clif_displaymessage(pl_sd->fd, msg_txt(sd,120)); // A GM has discharged you from jail.
  4036. clif_displaymessage(fd, msg_txt(sd,121)); // Player unjailed.
  4037. return 0;
  4038. }
  4039. ACMD_FUNC(jailfor) {
  4040. struct map_session_data *pl_sd = NULL;
  4041. char * modif_p;
  4042. int jailtime = 0,x,y;
  4043. short m_index = 0;
  4044. nullpo_retr(-1, sd);
  4045. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4046. if (!message || !*message || sscanf(message, "%255s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
  4047. clif_displaymessage(fd, msg_txt(sd,400)); //Usage: @jailfor <time> <character name>
  4048. return -1;
  4049. }
  4050. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  4051. modif_p = atcmd_output;
  4052. jailtime = (int)solve_time(modif_p)/60; // Change to minutes
  4053. if (jailtime == 0) {
  4054. clif_displaymessage(fd, msg_txt(sd,1136)); // Invalid time for jail command.
  4055. 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.
  4056. return -1;
  4057. }
  4058. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  4059. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4060. return -1;
  4061. }
  4062. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  4063. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4064. return -1;
  4065. }
  4066. // Added by Coltaro
  4067. if(pl_sd->sc.data[SC_JAILED] && pl_sd->sc.data[SC_JAILED]->val1 != INT_MAX) { // Update the player's jail time
  4068. jailtime += pl_sd->sc.data[SC_JAILED]->val1;
  4069. if (jailtime <= 0) {
  4070. jailtime = 0;
  4071. clif_displaymessage(pl_sd->fd, msg_txt(sd,120)); // GM has discharge you.
  4072. clif_displaymessage(fd, msg_txt(sd,121)); // Player unjailed
  4073. } else {
  4074. int year = 0, month = 0, day = 0, hour = 0, minute = 0, second = 0;
  4075. char timestr[21];
  4076. time_t now=time(NULL);
  4077. split_time(jailtime*60,&year,&month,&day,&hour,&minute,&second);
  4078. 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
  4079. clif_displaymessage(pl_sd->fd, atcmd_output);
  4080. 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
  4081. clif_displaymessage(fd, atcmd_output);
  4082. timestamp2string(timestr,20,now+jailtime*60,"%Y-%m-%d %H:%M");
  4083. sprintf(atcmd_output,"Release date is: %s",timestr);
  4084. clif_displaymessage(pl_sd->fd, atcmd_output);
  4085. clif_displaymessage(fd, atcmd_output);
  4086. }
  4087. } else if (jailtime < 0) {
  4088. clif_displaymessage(fd, msg_txt(sd,1136));
  4089. return -1;
  4090. }
  4091. // Jail locations, add more as you wish.
  4092. switch(rnd()%2) {
  4093. case 1: // Jail #1
  4094. m_index = mapindex_name2id(MAP_JAIL);
  4095. x = 49; y = 75;
  4096. break;
  4097. default: // Default Jail
  4098. m_index = mapindex_name2id(MAP_JAIL);
  4099. x = 24; y = 75;
  4100. break;
  4101. }
  4102. 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).
  4103. return 0;
  4104. }
  4105. //By Coltaro
  4106. ACMD_FUNC(jailtime){
  4107. int year, month, day, hour, minute, second;
  4108. char timestr[21];
  4109. time_t now = time(NULL);
  4110. nullpo_retr(-1, sd);
  4111. if (!sd->sc.data[SC_JAILED]) {
  4112. clif_displaymessage(fd, msg_txt(sd,1139)); // You are not in jail.
  4113. return -1;
  4114. }
  4115. if (sd->sc.data[SC_JAILED]->val1 == INT_MAX) {
  4116. clif_displaymessage(fd, msg_txt(sd,1140)); // You have been jailed indefinitely.
  4117. return 0;
  4118. }
  4119. if (sd->sc.data[SC_JAILED]->val1 <= 0) { // Was not jailed with @jailfor (maybe @jail? or warped there? or got recalled?)
  4120. clif_displaymessage(fd, msg_txt(sd,1141)); // You have been jailed for an unknown amount of time.
  4121. return -1;
  4122. }
  4123. // Get remaining jail time
  4124. split_time(sd->sc.data[SC_JAILED]->val1*60,&year,&month,&day,&hour,&minute,&second);
  4125. 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
  4126. clif_displaymessage(fd, atcmd_output);
  4127. timestamp2string(timestr,20,now+sd->sc.data[SC_JAILED]->val1*60,"%Y-%m-%d %H:%M");
  4128. sprintf(atcmd_output,"Release date is: %s",timestr);
  4129. clif_displaymessage(fd, atcmd_output);
  4130. return 0;
  4131. }
  4132. /*==========================================
  4133. * @disguise <mob_id> by [Valaris] (simplified by [Yor])
  4134. *------------------------------------------*/
  4135. ACMD_FUNC(disguise)
  4136. {
  4137. int id = 0;
  4138. nullpo_retr(-1, sd);
  4139. if (!message || !*message) {
  4140. clif_displaymessage(fd, msg_txt(sd,1143)); // Please enter a Monster/NPC name/ID (usage: @disguise <name/ID>).
  4141. return -1;
  4142. }
  4143. if ((id = atoi(message)) > 0)
  4144. { //Acquired an ID
  4145. if (!mobdb_checkid(id) && !npcdb_checkid(id))
  4146. id = 0; //Invalid id for either mobs or npcs.
  4147. } else { //Acquired a Name
  4148. if ((id = mobdb_searchname(message)) == 0)
  4149. {
  4150. struct npc_data* nd = npc_name2id(message);
  4151. if (nd != NULL)
  4152. id = nd->class_;
  4153. }
  4154. }
  4155. if (id == 0)
  4156. {
  4157. clif_displaymessage(fd, msg_txt(sd,123)); // Invalid Monster/NPC name/ID specified.
  4158. return -1;
  4159. }
  4160. if(pc_isriding(sd))
  4161. {
  4162. clif_displaymessage(fd, msg_txt(sd,1144)); // Character cannot be disguised while mounted.
  4163. return -1;
  4164. }
  4165. if (sd->sc.data[SC_MONSTER_TRANSFORM]) {
  4166. clif_displaymessage(fd, msg_txt(sd,730)); // Character cannot be disguised while in monster transform.
  4167. return -1;
  4168. }
  4169. pc_disguise(sd, id);
  4170. clif_displaymessage(fd, msg_txt(sd,122)); // Disguise applied.
  4171. return 0;
  4172. }
  4173. /*==========================================
  4174. * DisguiseAll
  4175. *------------------------------------------*/
  4176. ACMD_FUNC(disguiseall)
  4177. {
  4178. int mob_id=0;
  4179. struct map_session_data *pl_sd;
  4180. struct s_mapiterator* iter;
  4181. nullpo_retr(-1, sd);
  4182. if (!message || !*message) {
  4183. clif_displaymessage(fd, msg_txt(sd,1145)); // Please enter a Monster/NPC name/ID (usage: @disguiseall <name/ID>).
  4184. return -1;
  4185. }
  4186. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name beginning by a number)
  4187. mob_id = atoi(message);
  4188. if (!mobdb_checkid(mob_id) && !npcdb_checkid(mob_id)) { //if mob or npc...
  4189. clif_displaymessage(fd, msg_txt(sd,123)); // Monster/NPC name/id not found.
  4190. return -1;
  4191. }
  4192. iter = mapit_getallusers();
  4193. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4194. pc_disguise(pl_sd, mob_id);
  4195. mapit_free(iter);
  4196. clif_displaymessage(fd, msg_txt(sd,122)); // Disguise applied.
  4197. return 0;
  4198. }
  4199. /*==========================================
  4200. * DisguiseGuild
  4201. *------------------------------------------*/
  4202. ACMD_FUNC(disguiseguild)
  4203. {
  4204. int id = 0, i;
  4205. char monster[NAME_LENGTH], guild[NAME_LENGTH];
  4206. struct guild *g;
  4207. memset(monster, '\0', sizeof(monster));
  4208. memset(guild, '\0', sizeof(guild));
  4209. if( !message || !*message || sscanf(message, "%23[^,], %23[^\r\n]", monster, guild) < 2 ) {
  4210. 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>).
  4211. return -1;
  4212. }
  4213. if( (id = atoi(monster)) > 0 ) {
  4214. if( !mobdb_checkid(id) && !npcdb_checkid(id) )
  4215. id = 0;
  4216. } else {
  4217. if( (id = mobdb_searchname(monster)) == 0 ) {
  4218. struct npc_data* nd = npc_name2id(monster);
  4219. if( nd != NULL )
  4220. id = nd->class_;
  4221. }
  4222. }
  4223. if( id == 0 ) {
  4224. clif_displaymessage(fd, msg_txt(sd,123)); // Monster/NPC name/id hasn't been found.
  4225. return -1;
  4226. }
  4227. if( (g = guild_searchname(guild)) == NULL && (g = guild_search(atoi(guild))) == NULL ) {
  4228. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  4229. return -1;
  4230. }
  4231. for( i = 0; i < g->max_member; i++ ){
  4232. struct map_session_data *pl_sd;
  4233. if( (pl_sd = g->member[i].sd) && !pc_isriding(pl_sd) )
  4234. pc_disguise(pl_sd, id);
  4235. }
  4236. clif_displaymessage(fd, msg_txt(sd,122)); // Disguise applied.
  4237. return 0;
  4238. }
  4239. /*==========================================
  4240. * @undisguise by [Yor]
  4241. *------------------------------------------*/
  4242. ACMD_FUNC(undisguise)
  4243. {
  4244. nullpo_retr(-1, sd);
  4245. if (sd->disguise) {
  4246. pc_disguise(sd, 0);
  4247. clif_displaymessage(fd, msg_txt(sd,124)); // Undisguise applied.
  4248. } else {
  4249. clif_displaymessage(fd, msg_txt(sd,125)); // You're not disguised.
  4250. return -1;
  4251. }
  4252. return 0;
  4253. }
  4254. /*==========================================
  4255. * UndisguiseAll
  4256. *------------------------------------------*/
  4257. ACMD_FUNC(undisguiseall)
  4258. {
  4259. struct map_session_data *pl_sd;
  4260. struct s_mapiterator* iter;
  4261. nullpo_retr(-1, sd);
  4262. iter = mapit_getallusers();
  4263. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4264. if( pl_sd->disguise )
  4265. pc_disguise(pl_sd, 0);
  4266. mapit_free(iter);
  4267. clif_displaymessage(fd, msg_txt(sd,124)); // Undisguise applied.
  4268. return 0;
  4269. }
  4270. /*==========================================
  4271. * UndisguiseGuild
  4272. *------------------------------------------*/
  4273. ACMD_FUNC(undisguiseguild)
  4274. {
  4275. char guild_name[NAME_LENGTH];
  4276. struct guild *g;
  4277. int i;
  4278. nullpo_retr(-1, sd);
  4279. memset(guild_name, '\0', sizeof(guild_name));
  4280. if(!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  4281. clif_displaymessage(fd, msg_txt(sd,1147)); // Please enter guild name/ID (usage: @undisguiseguild <guild name/ID>).
  4282. return -1;
  4283. }
  4284. if( (g = guild_searchname(guild_name)) == NULL && (g = guild_search(atoi(message))) == NULL ) {
  4285. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  4286. return -1;
  4287. }
  4288. for(i = 0; i < g->max_member; i++){
  4289. struct map_session_data *pl_sd;
  4290. if( (pl_sd = g->member[i].sd) && pl_sd->disguise )
  4291. pc_disguise(pl_sd, 0);
  4292. }
  4293. clif_displaymessage(fd, msg_txt(sd,124)); // Undisguise applied.
  4294. return 0;
  4295. }
  4296. /*==========================================
  4297. * @exp by [Skotlex]
  4298. *------------------------------------------*/
  4299. ACMD_FUNC(exp)
  4300. {
  4301. char output[CHAT_SIZE_MAX];
  4302. double nextb, nextj;
  4303. nullpo_retr(-1, sd);
  4304. memset(output, '\0', sizeof(output));
  4305. nextb = pc_nextbaseexp(sd);
  4306. if (nextb)
  4307. nextb = sd->status.base_exp*100.0/nextb;
  4308. nextj = pc_nextjobexp(sd);
  4309. if (nextj)
  4310. nextj = sd->status.job_exp*100.0/nextj;
  4311. sprintf(output, msg_txt(sd,1148), sd->status.base_level, nextb, sd->status.job_level, nextj); // Base Level: %d (%.3f%%) | Job Level: %d (%.3f%%)
  4312. clif_displaymessage(fd, output);
  4313. return 0;
  4314. }
  4315. /*==========================================
  4316. * @broadcast by [Valaris]
  4317. *------------------------------------------*/
  4318. ACMD_FUNC(broadcast)
  4319. {
  4320. nullpo_retr(-1, sd);
  4321. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4322. if (!message || !*message) {
  4323. clif_displaymessage(fd, msg_txt(sd,1149)); // Please enter a message (usage: @broadcast <message>).
  4324. return -1;
  4325. }
  4326. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4327. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT);
  4328. return 0;
  4329. }
  4330. /*==========================================
  4331. * @localbroadcast by [Valaris]
  4332. *------------------------------------------*/
  4333. ACMD_FUNC(localbroadcast)
  4334. {
  4335. nullpo_retr(-1, sd);
  4336. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4337. if (!message || !*message) {
  4338. clif_displaymessage(fd, msg_txt(sd,1150)); // Please enter a message (usage: @localbroadcast <message>).
  4339. return -1;
  4340. }
  4341. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4342. clif_broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT, ALL_SAMEMAP);
  4343. return 0;
  4344. }
  4345. /*==========================================
  4346. * @email <actual@email> <new@email> by [Yor]
  4347. *------------------------------------------*/
  4348. ACMD_FUNC(email)
  4349. {
  4350. char actual_email[100];
  4351. char new_email[100];
  4352. nullpo_retr(-1, sd);
  4353. memset(actual_email, '\0', sizeof(actual_email));
  4354. memset(new_email, '\0', sizeof(new_email));
  4355. if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
  4356. clif_displaymessage(fd, msg_txt(sd,1151)); // Please enter 2 emails (usage: @email <actual@email> <new@email>).
  4357. return -1;
  4358. }
  4359. if (e_mail_check(actual_email) == 0) {
  4360. clif_displaymessage(fd, msg_txt(sd,144)); // Invalid actual email. If you have default e-mail, give a@a.com.
  4361. return -1;
  4362. } else if (e_mail_check(new_email) == 0) {
  4363. clif_displaymessage(fd, msg_txt(sd,145)); // Invalid new email. Please enter a real e-mail.
  4364. return -1;
  4365. } else if (strcmpi(new_email, "a@a.com") == 0) {
  4366. clif_displaymessage(fd, msg_txt(sd,146)); // New email must be a real e-mail.
  4367. return -1;
  4368. } else if (strcmpi(actual_email, new_email) == 0) {
  4369. clif_displaymessage(fd, msg_txt(sd,147)); // New email must be different of the actual e-mail.
  4370. return -1;
  4371. }
  4372. chrif_changeemail(sd->status.account_id, actual_email, new_email);
  4373. clif_displaymessage(fd, msg_txt(sd,148)); // Information sent to login-server via char-server.
  4374. return 0;
  4375. }
  4376. /*==========================================
  4377. *@effect
  4378. *------------------------------------------*/
  4379. ACMD_FUNC(effect)
  4380. {
  4381. int type = 0, flag = 0;
  4382. nullpo_retr(-1, sd);
  4383. if (!message || !*message || sscanf(message, "%d", &type) < 1) {
  4384. clif_displaymessage(fd, msg_txt(sd,1152)); // Please enter an effect number (usage: @effect <effect number>).
  4385. return -1;
  4386. }
  4387. clif_specialeffect(&sd->bl, type, (send_target)flag);
  4388. clif_displaymessage(fd, msg_txt(sd,229)); // Your effect has changed.
  4389. return 0;
  4390. }
  4391. /*==========================================
  4392. * @killer by MouseJstr
  4393. * enable killing players even when not in pvp
  4394. *------------------------------------------*/
  4395. ACMD_FUNC(killer)
  4396. {
  4397. nullpo_retr(-1, sd);
  4398. sd->state.killer = !sd->state.killer;
  4399. if(sd->state.killer)
  4400. clif_displaymessage(fd, msg_txt(sd,241));
  4401. else {
  4402. clif_displaymessage(fd, msg_txt(sd,292));
  4403. pc_stop_attack(sd);
  4404. }
  4405. return 0;
  4406. }
  4407. /*==========================================
  4408. * @killable by MouseJstr
  4409. * enable other people killing you
  4410. *------------------------------------------*/
  4411. ACMD_FUNC(killable)
  4412. {
  4413. nullpo_retr(-1, sd);
  4414. sd->state.killable = !sd->state.killable;
  4415. if(sd->state.killable)
  4416. clif_displaymessage(fd, msg_txt(sd,242));
  4417. else {
  4418. clif_displaymessage(fd, msg_txt(sd,288));
  4419. map_foreachinrange(atcommand_stopattack,&sd->bl, AREA_SIZE, BL_CHAR, sd->bl.id);
  4420. }
  4421. return 0;
  4422. }
  4423. /*==========================================
  4424. * @skillon by MouseJstr
  4425. * turn skills on for the map
  4426. *------------------------------------------*/
  4427. ACMD_FUNC(skillon)
  4428. {
  4429. nullpo_retr(-1, sd);
  4430. map[sd->bl.m].flag.noskill = 0;
  4431. clif_displaymessage(fd, msg_txt(sd,244));
  4432. return 0;
  4433. }
  4434. /*==========================================
  4435. * @skilloff by MouseJstr
  4436. * Turn skills off on the map
  4437. *------------------------------------------*/
  4438. ACMD_FUNC(skilloff)
  4439. {
  4440. nullpo_retr(-1, sd);
  4441. map[sd->bl.m].flag.noskill = 1;
  4442. clif_displaymessage(fd, msg_txt(sd,243));
  4443. return 0;
  4444. }
  4445. /*==========================================
  4446. * @npcmove by MouseJstr
  4447. * move a npc
  4448. *------------------------------------------*/
  4449. ACMD_FUNC(npcmove)
  4450. {
  4451. int x = 0, y = 0, m;
  4452. struct npc_data *nd = 0;
  4453. nullpo_retr(-1, sd);
  4454. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  4455. if (!message || !*message || sscanf(message, "%d %d %23[^\n]", &x, &y, atcmd_player_name) < 3) {
  4456. clif_displaymessage(fd, msg_txt(sd,1153)); // Usage: @npcmove <X> <Y> <npc_name>
  4457. return -1;
  4458. }
  4459. if ((nd = npc_name2id(atcmd_player_name)) == NULL)
  4460. {
  4461. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  4462. return -1;
  4463. }
  4464. if ((m=nd->bl.m) < 0 || nd->bl.prev == NULL)
  4465. {
  4466. clif_displaymessage(fd, msg_txt(sd,1154)); // NPC is not on this map.
  4467. return -1; //Not on a map.
  4468. }
  4469. x = cap_value(x, 0, map[m].xs-1);
  4470. y = cap_value(y, 0, map[m].ys-1);
  4471. map_foreachinrange(clif_outsight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  4472. map_moveblock(&nd->bl, x, y, gettick());
  4473. map_foreachinrange(clif_insight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  4474. clif_displaymessage(fd, msg_txt(sd,1155)); // NPC moved.
  4475. return 0;
  4476. }
  4477. /*==========================================
  4478. * @addwarp by MouseJstr
  4479. * Create a new static warp point.
  4480. *------------------------------------------*/
  4481. ACMD_FUNC(addwarp)
  4482. {
  4483. char mapname[32], warpname[NAME_LENGTH+1];
  4484. int x,y;
  4485. unsigned short m;
  4486. struct npc_data* nd;
  4487. nullpo_retr(-1, sd);
  4488. memset(warpname, '\0', sizeof(warpname));
  4489. if (!message || !*message || sscanf(message, "%31s %d %d %23[^\n]", mapname, &x, &y, warpname) < 4) {
  4490. clif_displaymessage(fd, msg_txt(sd,1156)); // Usage: @addwarp <mapname> <X> <Y> <npc name>
  4491. return -1;
  4492. }
  4493. m = mapindex_name2id(mapname);
  4494. if( m == 0 )
  4495. {
  4496. sprintf(atcmd_output, msg_txt(sd,1157), mapname); // Unknown map '%s'.
  4497. clif_displaymessage(fd, atcmd_output);
  4498. return -1;
  4499. }
  4500. nd = npc_add_warp(warpname, sd->bl.m, sd->bl.x, sd->bl.y, 2, 2, m, x, y);
  4501. if( nd == NULL )
  4502. return -1;
  4503. sprintf(atcmd_output, msg_txt(sd,1158), nd->exname); // New warp NPC '%s' created.
  4504. clif_displaymessage(fd, atcmd_output);
  4505. return 0;
  4506. }
  4507. /*==========================================
  4508. * @follow by [MouseJstr]
  4509. * Follow a player .. staying no more then 5 spaces away
  4510. *------------------------------------------*/
  4511. ACMD_FUNC(follow)
  4512. {
  4513. struct map_session_data *pl_sd = NULL;
  4514. nullpo_retr(-1, sd);
  4515. if (!message || !*message) {
  4516. if (sd->followtarget == -1)
  4517. return -1;
  4518. pc_stop_following (sd);
  4519. clif_displaymessage(fd, msg_txt(sd,1159)); // Follow mode OFF.
  4520. return 0;
  4521. }
  4522. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  4523. {
  4524. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4525. return -1;
  4526. }
  4527. if (sd->followtarget == pl_sd->bl.id) {
  4528. pc_stop_following (sd);
  4529. clif_displaymessage(fd, msg_txt(sd,1159)); // Follow mode OFF.
  4530. } else {
  4531. pc_follow(sd, pl_sd->bl.id);
  4532. clif_displaymessage(fd, msg_txt(sd,1160)); // Follow mode ON.
  4533. }
  4534. return 0;
  4535. }
  4536. /*==========================================
  4537. * @dropall by [MouseJstr] and [Xantara]
  4538. * Drops all your possession on the ground based on item type
  4539. *------------------------------------------*/
  4540. ACMD_FUNC(dropall)
  4541. {
  4542. int8 type = -1;
  4543. uint16 i, count = 0, count2 = 0;
  4544. struct item_data *item_data = NULL;
  4545. nullpo_retr(-1, sd);
  4546. if( message[0] ) {
  4547. type = atoi(message);
  4548. if( type != -1 && type != IT_HEALING && type != IT_USABLE && type != IT_ETC && type != IT_WEAPON &&
  4549. type != IT_ARMOR && type != IT_CARD && type != IT_PETEGG && type != IT_PETARMOR && type != IT_AMMO )
  4550. {
  4551. clif_displaymessage(fd, msg_txt(sd,1492));
  4552. clif_displaymessage(fd, msg_txt(sd,1493));
  4553. return -1;
  4554. }
  4555. }
  4556. for( i = 0; i < MAX_INVENTORY; i++ ) {
  4557. if( sd->status.inventory[i].amount ) {
  4558. if( (item_data = itemdb_exists(sd->status.inventory[i].nameid)) == NULL ) {
  4559. ShowDebug("Non-existant item %d on dropall list (account_id: %d, char_id: %d)\n", sd->status.inventory[i].nameid, sd->status.account_id, sd->status.char_id);
  4560. continue;
  4561. }
  4562. if( !pc_candrop(sd,&sd->status.inventory[i]) )
  4563. continue;
  4564. if( type == -1 || type == (uint8)item_data->type ) {
  4565. if( sd->status.inventory[i].equip != 0 )
  4566. pc_unequipitem(sd, i, 3);
  4567. if(pc_dropitem(sd, i, sd->status.inventory[i].amount))
  4568. count += sd->status.inventory[i].amount;
  4569. else count2 += sd->status.inventory[i].amount;
  4570. }
  4571. }
  4572. }
  4573. sprintf(atcmd_output, msg_txt(sd,1494), count,count2); // %d items are dropped (%d skipped)!
  4574. clif_displaymessage(fd, atcmd_output);
  4575. return 0;
  4576. }
  4577. /*==========================================
  4578. * @storeall by [MouseJstr]
  4579. * Put everything into storage
  4580. *------------------------------------------*/
  4581. ACMD_FUNC(storeall)
  4582. {
  4583. int i;
  4584. nullpo_retr(-1, sd);
  4585. if (sd->state.storage_flag != 1)
  4586. { //Open storage.
  4587. if( storage_storageopen(sd) == 1 ) {
  4588. clif_displaymessage(fd, msg_txt(sd,1161)); // You currently cannot open your storage.
  4589. return -1;
  4590. }
  4591. }
  4592. for (i = 0; i < MAX_INVENTORY; i++) {
  4593. if (sd->status.inventory[i].amount) {
  4594. if(sd->status.inventory[i].equip != 0)
  4595. pc_unequipitem(sd, i, 3);
  4596. storage_storageadd(sd, i, sd->status.inventory[i].amount);
  4597. }
  4598. }
  4599. storage_storageclose(sd);
  4600. clif_displaymessage(fd, msg_txt(sd,1162)); // All items stored.
  4601. return 0;
  4602. }
  4603. ACMD_FUNC(clearstorage)
  4604. {
  4605. int i, j;
  4606. nullpo_retr(-1, sd);
  4607. if (sd->state.storage_flag == 1) {
  4608. clif_displaymessage(fd, msg_txt(sd,250));
  4609. return -1;
  4610. }
  4611. j = sd->status.storage.storage_amount;
  4612. for (i = 0; i < j; ++i) {
  4613. storage_delitem(sd, i, sd->status.storage.items[i].amount);
  4614. }
  4615. storage_storageclose(sd);
  4616. clif_displaymessage(fd, msg_txt(sd,1394)); // Your storage was cleaned.
  4617. return 0;
  4618. }
  4619. ACMD_FUNC(cleargstorage)
  4620. {
  4621. int i, j;
  4622. struct guild *g;
  4623. struct guild_storage *gstorage;
  4624. nullpo_retr(-1, sd);
  4625. g = sd->guild;
  4626. if (g == NULL) {
  4627. clif_displaymessage(fd, msg_txt(sd,43));
  4628. return -1;
  4629. }
  4630. if (sd->state.storage_flag == 1) {
  4631. clif_displaymessage(fd, msg_txt(sd,250));
  4632. return -1;
  4633. }
  4634. if (sd->state.storage_flag == 2) {
  4635. clif_displaymessage(fd, msg_txt(sd,251));
  4636. return -1;
  4637. }
  4638. gstorage = guild2storage2(sd->status.guild_id);
  4639. if (gstorage == NULL) {// Doesn't have opened @gstorage yet, so we skip the deletion since *shouldn't* have any item there.
  4640. return -1;
  4641. }
  4642. j = gstorage->storage_amount;
  4643. gstorage->lock = 1; // Lock @gstorage: do not allow any item to be retrieved or stored from any guild member
  4644. for (i = 0; i < j; ++i) {
  4645. guild_storage_delitem(sd, gstorage, i, gstorage->items[i].amount);
  4646. }
  4647. storage_guild_storageclose(sd);
  4648. gstorage->lock = 0; // Cleaning done, release lock
  4649. clif_displaymessage(fd, msg_txt(sd,1395)); // Your guild storage was cleaned.
  4650. return 0;
  4651. }
  4652. ACMD_FUNC(clearcart)
  4653. {
  4654. int i;
  4655. nullpo_retr(-1, sd);
  4656. if (pc_iscarton(sd) == 0) {
  4657. clif_displaymessage(fd, msg_txt(sd,1396)); // You do not have a cart to be cleaned.
  4658. return -1;
  4659. }
  4660. if (sd->state.vending == 1) { //Somehow...
  4661. return -1;
  4662. }
  4663. for( i = 0; i < MAX_CART; i++ )
  4664. if(sd->status.cart[i].nameid > 0)
  4665. pc_cart_delitem(sd, i, sd->status.cart[i].amount, 1, LOG_TYPE_OTHER);
  4666. clif_clearcart(fd);
  4667. clif_updatestatus(sd,SP_CARTINFO);
  4668. clif_displaymessage(fd, msg_txt(sd,1397)); // Your cart was cleaned.
  4669. return 0;
  4670. }
  4671. /*==========================================
  4672. * @skillid by [MouseJstr]
  4673. * lookup a skill by name
  4674. *------------------------------------------*/
  4675. #define MAX_SKILLID_PARTIAL_RESULTS 5
  4676. #define MAX_SKILLID_PARTIAL_RESULTS_LEN 74 // "skill " (6) + "%d:" (up to 5) + "%s" (up to 30) + " (%s)" (up to 33)
  4677. ACMD_FUNC(skillid) {
  4678. int skillen, i, found = 0;
  4679. DBIterator* iter;
  4680. DBKey key;
  4681. DBData *data;
  4682. char partials[MAX_SKILLID_PARTIAL_RESULTS][MAX_SKILLID_PARTIAL_RESULTS_LEN];
  4683. nullpo_retr(-1, sd);
  4684. if (!message || !*message) {
  4685. clif_displaymessage(fd, msg_txt(sd,1163)); // Please enter a skill name to look up (usage: @skillid <skill name>).
  4686. return -1;
  4687. }
  4688. skillen = strlen(message);
  4689. iter = db_iterator(skilldb_name2id);
  4690. for( data = iter->first(iter,&key); iter->exists(iter); data = iter->next(iter,&key) ) {
  4691. int idx = skill_get_index(db_data2i(data));
  4692. if (strnicmp(key.str, message, skillen) == 0 || strnicmp(skill_db[idx].desc, message, skillen) == 0) {
  4693. sprintf(atcmd_output, msg_txt(sd,1164), db_data2i(data), skill_db[idx].desc, key.str); // skill %d: %s (%s)
  4694. clif_displaymessage(fd, atcmd_output);
  4695. } else if ( found < MAX_SKILLID_PARTIAL_RESULTS && ( stristr(key.str,message) || stristr(skill_db[idx].desc,message) ) ) {
  4696. snprintf(partials[found++], MAX_SKILLID_PARTIAL_RESULTS_LEN, msg_txt(sd,1164), db_data2i(data), skill_db[idx].desc, key.str);
  4697. }
  4698. }
  4699. dbi_destroy(iter);
  4700. if( found ) {
  4701. sprintf(atcmd_output, msg_txt(sd,1398), found); // -- Displaying first %d partial matches
  4702. clif_displaymessage(fd, atcmd_output);
  4703. }
  4704. for(i = 0; i < found; i++) { /* partials */
  4705. clif_displaymessage(fd, partials[i]);
  4706. }
  4707. return 0;
  4708. }
  4709. /*==========================================
  4710. * @useskill by [MouseJstr]
  4711. * A way of using skills without having to find them in the skills menu
  4712. *------------------------------------------*/
  4713. ACMD_FUNC(useskill)
  4714. {
  4715. struct map_session_data *pl_sd = NULL;
  4716. struct block_list *bl;
  4717. uint16 skill_id;
  4718. uint16 skill_lv;
  4719. char target[100];
  4720. nullpo_retr(-1, sd);
  4721. if(!message || !*message || sscanf(message, "%hu %hu %23[^\n]", &skill_id, &skill_lv, target) != 3) {
  4722. clif_displaymessage(fd, msg_txt(sd,1165)); // Usage: @useskill <skill ID> <skill level> <target>
  4723. return -1;
  4724. }
  4725. if(!strcmp(target,"self")) pl_sd = sd; //quick keyword
  4726. else if ( (pl_sd = map_nick2sd(target)) == NULL ){
  4727. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4728. return -1;
  4729. }
  4730. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  4731. {
  4732. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4733. return -1;
  4734. }
  4735. if (skill_id >= HM_SKILLBASE && skill_id < HM_SKILLBASE+MAX_HOMUNSKILL
  4736. && sd->hd && hom_is_active(sd->hd)) // (If used with @useskill, put the homunc as dest)
  4737. bl = &sd->hd->bl;
  4738. else
  4739. bl = &sd->bl;
  4740. if (skill_get_inf(skill_id)&INF_GROUND_SKILL)
  4741. unit_skilluse_pos(bl, pl_sd->bl.x, pl_sd->bl.y, skill_id, skill_lv);
  4742. else
  4743. unit_skilluse_id(bl, pl_sd->bl.id, skill_id, skill_lv);
  4744. return 0;
  4745. }
  4746. /*==========================================
  4747. * @displayskill by [Skotlex]
  4748. * Debug command to locate new skill IDs. It sends the
  4749. * three possible skill-effect packets to the area.
  4750. *------------------------------------------*/
  4751. ACMD_FUNC(displayskill)
  4752. {
  4753. struct status_data * status;
  4754. unsigned int tick;
  4755. uint16 skill_id;
  4756. uint16 skill_lv = 1;
  4757. nullpo_retr(-1, sd);
  4758. if (!message || !*message || sscanf(message, "%hu %hu", &skill_id, &skill_lv) < 1)
  4759. {
  4760. clif_displaymessage(fd, msg_txt(sd,1166)); // Usage: @displayskill <skill ID> {<skill level>}
  4761. return -1;
  4762. }
  4763. status = status_get_status_data(&sd->bl);
  4764. tick = gettick();
  4765. clif_skill_damage(&sd->bl,&sd->bl, tick, status->amotion, status->dmotion, 1, 1, skill_id, skill_lv, 5);
  4766. clif_skill_nodamage(&sd->bl, &sd->bl, skill_id, skill_lv, 1);
  4767. clif_skill_poseffect(&sd->bl, skill_id, skill_lv, sd->bl.x, sd->bl.y, tick);
  4768. return 0;
  4769. }
  4770. /*==========================================
  4771. * @skilltree by [MouseJstr]
  4772. * prints the skill tree for a player required to get to a skill
  4773. *------------------------------------------*/
  4774. ACMD_FUNC(skilltree)
  4775. {
  4776. struct map_session_data *pl_sd = NULL;
  4777. uint16 skill_id;
  4778. int meets, j, c=0;
  4779. char target[NAME_LENGTH];
  4780. struct skill_tree_entry *ent;
  4781. nullpo_retr(-1, sd);
  4782. if(!message || !*message || sscanf(message, "%hu %23[^\r\n]", &skill_id, target) != 2) {
  4783. clif_displaymessage(fd, msg_txt(sd,1167)); // Usage: @skilltree <skill ID> <target>
  4784. return -1;
  4785. }
  4786. if ( (pl_sd = map_nick2sd(target)) == NULL )
  4787. {
  4788. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4789. return -1;
  4790. }
  4791. c = pc_calc_skilltree_normalize_job(pl_sd);
  4792. c = pc_mapid2jobid(c, pl_sd->status.sex);
  4793. 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).
  4794. clif_displaymessage(fd, atcmd_output);
  4795. ARR_FIND( 0, MAX_SKILL_TREE, j, skill_tree[c][j].id == 0 || skill_tree[c][j].id == skill_id );
  4796. if( j == MAX_SKILL_TREE || skill_tree[c][j].id == 0 )
  4797. {
  4798. clif_displaymessage(fd, msg_txt(sd,1169)); // The player cannot use that skill.
  4799. return 0;
  4800. }
  4801. ent = &skill_tree[c][j];
  4802. meets = 1;
  4803. for(j=0;j<MAX_PC_SKILL_REQUIRE;j++)
  4804. {
  4805. if( ent->need[j].id && pc_checkskill(sd,ent->need[j].id) < ent->need[j].lv)
  4806. {
  4807. sprintf(atcmd_output, msg_txt(sd,1170), ent->need[j].lv, skill_db[ent->need[j].id].desc); // Player requires level %d of skill %s.
  4808. clif_displaymessage(fd, atcmd_output);
  4809. meets = 0;
  4810. }
  4811. }
  4812. if (meets == 1) {
  4813. clif_displaymessage(fd, msg_txt(sd,1171)); // The player meets all the requirements for that skill.
  4814. }
  4815. return 0;
  4816. }
  4817. // Hand a ring with partners name on it to this char
  4818. void getring (struct map_session_data* sd)
  4819. {
  4820. int flag, item_id;
  4821. struct item item_tmp;
  4822. item_id = (sd->status.sex) ? WEDDING_RING_M : WEDDING_RING_F;
  4823. memset(&item_tmp, 0, sizeof(item_tmp));
  4824. item_tmp.nameid = item_id;
  4825. item_tmp.identify = 1;
  4826. item_tmp.card[0] = 255;
  4827. item_tmp.card[2] = sd->status.partner_id;
  4828. item_tmp.card[3] = sd->status.partner_id >> 16;
  4829. if((flag = pc_additem(sd,&item_tmp,1,LOG_TYPE_COMMAND))) {
  4830. clif_additem(sd,0,0,flag);
  4831. map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,4);
  4832. }
  4833. }
  4834. /*==========================================
  4835. * @marry by [MouseJstr], fixed by Lupus
  4836. * Marry two players
  4837. *------------------------------------------*/
  4838. ACMD_FUNC(marry)
  4839. {
  4840. struct map_session_data *pl_sd = NULL;
  4841. char player_name[NAME_LENGTH] = "";
  4842. nullpo_retr(-1, sd);
  4843. if (!message || !*message || sscanf(message, "%23s", player_name) != 1) {
  4844. clif_displaymessage(fd, msg_txt(sd,1172)); // Usage: @marry <char name>
  4845. return -1;
  4846. }
  4847. if ((pl_sd = map_nick2sd(player_name)) == NULL) {
  4848. clif_displaymessage(fd, msg_txt(sd,3));
  4849. return -1;
  4850. }
  4851. if (pc_marriage(sd, pl_sd)) {
  4852. clif_displaymessage(fd, msg_txt(sd,1173)); // They are married... wish them well.
  4853. clif_wedding_effect(&pl_sd->bl); //wedding effect and music [Lupus]
  4854. getring(sd); // Auto-give named rings (Aru)
  4855. getring(pl_sd);
  4856. return 0;
  4857. }
  4858. clif_displaymessage(fd, msg_txt(sd,1174)); // The two cannot wed because one is either a baby or already married.
  4859. return -1;
  4860. }
  4861. /*==========================================
  4862. * @divorce by [MouseJstr], fixed by [Lupus]
  4863. * divorce two players
  4864. *------------------------------------------*/
  4865. ACMD_FUNC(divorce)
  4866. {
  4867. nullpo_retr(-1, sd);
  4868. if (!pc_divorce(sd)) {
  4869. sprintf(atcmd_output, msg_txt(sd,1175), sd->status.name); // '%s' is not married.
  4870. clif_displaymessage(fd, atcmd_output);
  4871. return -1;
  4872. }
  4873. sprintf(atcmd_output, msg_txt(sd,1176), sd->status.name); // '%s' and his/her partner are now divorced.
  4874. clif_displaymessage(fd, atcmd_output);
  4875. return 0;
  4876. }
  4877. /*==========================================
  4878. * @changelook by [Celest]
  4879. *------------------------------------------*/
  4880. ACMD_FUNC(changelook)
  4881. {
  4882. int i, j = 0, k = 0;
  4883. int pos[7] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES,LOOK_ROBE };
  4884. if((i = sscanf(message, "%d %d", &j, &k)) < 1) {
  4885. clif_displaymessage(fd, msg_txt(sd,1177)); // Usage: @changelook {<position>} <view id>
  4886. clif_displaymessage(fd, msg_txt(sd,1178)); // Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield 6-Shoes 7-Robe
  4887. return -1;
  4888. } else if ( i == 2 ) {
  4889. if (j < 1 || j > 7)
  4890. j = 1;
  4891. j = pos[j - 1];
  4892. } else if( i == 1 ) { // position not defined, use HEAD_TOP as default
  4893. k = j; // swap
  4894. j = LOOK_HEAD_TOP;
  4895. }
  4896. clif_changelook(&sd->bl,j,k);
  4897. return 0;
  4898. }
  4899. /*==========================================
  4900. * @autotrade by durf [Lupus] [Paradox924X]
  4901. * Turns on/off Autotrade for a specific player
  4902. *------------------------------------------*/
  4903. ACMD_FUNC(autotrade) {
  4904. nullpo_retr(-1, sd);
  4905. if( map[sd->bl.m].flag.autotrade != battle_config.autotrade_mapflag ) {
  4906. clif_displaymessage(fd, msg_txt(sd,1179)); // Autotrade is not allowed on this map.
  4907. return -1;
  4908. }
  4909. if( pc_isdead(sd) ) {
  4910. clif_displaymessage(fd, msg_txt(sd,1180)); // You cannot autotrade when dead.
  4911. return -1;
  4912. }
  4913. if( !sd->state.vending && !sd->state.buyingstore ) { //check if player is vending or buying
  4914. clif_displaymessage(fd, msg_txt(sd,549)); // "You should have a shop open to use @autotrade."
  4915. return -1;
  4916. }
  4917. sd->state.autotrade = 1;
  4918. if( sd->state.vending ){
  4919. if( Sql_Query( mmysql_handle, "UPDATE `%s` SET `autotrade` = 1 WHERE `id` = %d;", vendings_db, sd->vender_id ) != SQL_SUCCESS ){
  4920. Sql_ShowDebug( mmysql_handle );
  4921. }
  4922. }else if( sd->state.buyingstore ){
  4923. if( Sql_Query( mmysql_handle, "UPDATE `%s` SET `autotrade` = 1 WHERE `id` = %d;", buyingstore_db, sd->buyer_id ) != SQL_SUCCESS ){
  4924. Sql_ShowDebug( mmysql_handle );
  4925. }
  4926. }
  4927. if( battle_config.at_timeout ) {
  4928. int timeout = atoi(message);
  4929. 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, 0);
  4930. }
  4931. channel_pcquit(sd,0xF); //leave all chan
  4932. clif_authfail_fd(sd->fd, 15);
  4933. chrif_save(sd,3);
  4934. return 0;
  4935. }
  4936. /*==========================================
  4937. * @changegm by durf (changed by Lupus)
  4938. * Changes Master of your Guild to a specified guild member
  4939. *------------------------------------------*/
  4940. ACMD_FUNC(changegm)
  4941. {
  4942. struct guild *g;
  4943. struct map_session_data *pl_sd;
  4944. nullpo_retr(-1, sd);
  4945. if (sd->status.guild_id == 0 || (g = sd->guild) == NULL || strcmp(g->master,sd->status.name)) {
  4946. clif_displaymessage(fd, msg_txt(sd,1181)); // You need to be a Guild Master to use this command.
  4947. return -1;
  4948. }
  4949. if( map[sd->bl.m].flag.guildlock || map[sd->bl.m].flag.gvg_castle ) {
  4950. clif_displaymessage(fd, msg_txt(sd,1182)); // You cannot change guild leaders on this map.
  4951. return -1;
  4952. }
  4953. if( !message[0] ) {
  4954. clif_displaymessage(fd, msg_txt(sd,1183)); // Usage: @changegm <guild_member_name>
  4955. return -1;
  4956. }
  4957. if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) {
  4958. clif_displaymessage(fd, msg_txt(sd,1184)); // Target character must be online and be a guild member.
  4959. return -1;
  4960. }
  4961. guild_gm_change(sd->status.guild_id, pl_sd);
  4962. return 0;
  4963. }
  4964. /*==========================================
  4965. * @changeleader by Skotlex
  4966. * Changes the leader of a party.
  4967. *------------------------------------------*/
  4968. ACMD_FUNC(changeleader)
  4969. {
  4970. nullpo_retr(-1, sd);
  4971. if( !message[0] )
  4972. {
  4973. clif_displaymessage(fd, msg_txt(sd,1185)); // Usage: @changeleader <party_member_name>
  4974. return -1;
  4975. }
  4976. if (party_changeleader(sd, map_nick2sd((char *) message),NULL))
  4977. return 0;
  4978. return -1;
  4979. }
  4980. /*==========================================
  4981. * @partyoption by Skotlex
  4982. * Used to change the item share setting of a party.
  4983. *------------------------------------------*/
  4984. ACMD_FUNC(partyoption)
  4985. {
  4986. struct party_data *p;
  4987. int mi, option;
  4988. char w1[16], w2[16];
  4989. nullpo_retr(-1, sd);
  4990. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
  4991. {
  4992. clif_displaymessage(fd, msg_txt(sd,282));
  4993. return -1;
  4994. }
  4995. ARR_FIND( 0, MAX_PARTY, mi, p->data[mi].sd == sd );
  4996. if (mi == MAX_PARTY)
  4997. return -1; //Shouldn't happen
  4998. if (!p->party.member[mi].leader)
  4999. {
  5000. clif_displaymessage(fd, msg_txt(sd,282));
  5001. return -1;
  5002. }
  5003. if(!message || !*message || sscanf(message, "%15s %15s", w1, w2) < 2)
  5004. {
  5005. clif_displaymessage(fd, msg_txt(sd,1186)); // Usage: @partyoption <pickup share: yes/no> <item distribution: yes/no>
  5006. return -1;
  5007. }
  5008. option = (config_switch(w1)?1:0)|(config_switch(w2)?2:0);
  5009. //Change item share type.
  5010. if (option != p->party.item)
  5011. party_changeoption(sd, p->party.exp, option);
  5012. else
  5013. clif_displaymessage(fd, msg_txt(sd,286));
  5014. return 0;
  5015. }
  5016. /*==========================================
  5017. * @autoloot by Upa-Kun
  5018. * Turns on/off AutoLoot for a specific player
  5019. *------------------------------------------*/
  5020. ACMD_FUNC(autoloot)
  5021. {
  5022. int rate;
  5023. nullpo_retr(-1, sd);
  5024. // autoloot command without value
  5025. if(!message || !*message)
  5026. {
  5027. if (sd->state.autoloot)
  5028. rate = 0;
  5029. else
  5030. rate = 10000;
  5031. } else {
  5032. double drate;
  5033. drate = atof(message);
  5034. rate = (int)(drate*100);
  5035. }
  5036. if (rate < 0) rate = 0;
  5037. if (rate > 10000) rate = 10000;
  5038. sd->state.autoloot = rate;
  5039. if (sd->state.autoloot) {
  5040. 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.
  5041. clif_displaymessage(fd, atcmd_output);
  5042. }else
  5043. clif_displaymessage(fd, msg_txt(sd,1188)); // Autoloot is now off.
  5044. return 0;
  5045. }
  5046. /*==========================================
  5047. * @alootid
  5048. *------------------------------------------*/
  5049. ACMD_FUNC(autolootitem)
  5050. {
  5051. struct item_data *item_data = NULL;
  5052. int i;
  5053. int action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset
  5054. nullpo_retr(-1, sd);
  5055. if (message && *message) {
  5056. if (message[0] == '+') {
  5057. message++;
  5058. action = 1;
  5059. }
  5060. else if (message[0] == '-') {
  5061. message++;
  5062. action = 2;
  5063. }
  5064. else if (!strcmp(message,"reset"))
  5065. action = 4;
  5066. }
  5067. if (action < 3) // add or remove
  5068. {
  5069. if ((item_data = itemdb_exists(atoi(message))) == NULL)
  5070. item_data = itemdb_searchname(message);
  5071. if (!item_data) {
  5072. // No items founds in the DB with Id or Name
  5073. clif_displaymessage(fd, msg_txt(sd,1189)); // Item not found.
  5074. return -1;
  5075. }
  5076. }
  5077. switch(action) {
  5078. case 1:
  5079. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
  5080. if (i != AUTOLOOTITEM_SIZE) {
  5081. clif_displaymessage(fd, msg_txt(sd,1190)); // You're already autolooting this item.
  5082. return -1;
  5083. }
  5084. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == 0);
  5085. if (i == AUTOLOOTITEM_SIZE) {
  5086. clif_displaymessage(fd, msg_txt(sd,1191)); // Your autolootitem list is full. Remove some items first with @autolootid -<item name or ID>.
  5087. return -1;
  5088. }
  5089. sd->state.autolootid[i] = item_data->nameid; // Autoloot Activated
  5090. sprintf(atcmd_output, msg_txt(sd,1192), item_data->name, item_data->jname, item_data->nameid); // Autolooting item: '%s'/'%s' {%d}
  5091. clif_displaymessage(fd, atcmd_output);
  5092. sd->state.autolooting = 1;
  5093. break;
  5094. case 2:
  5095. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
  5096. if (i == AUTOLOOTITEM_SIZE) {
  5097. clif_displaymessage(fd, msg_txt(sd,1193)); // You're currently not autolooting this item.
  5098. return -1;
  5099. }
  5100. sd->state.autolootid[i] = 0;
  5101. 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.
  5102. clif_displaymessage(fd, atcmd_output);
  5103. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
  5104. if (i == AUTOLOOTITEM_SIZE) {
  5105. sd->state.autolooting = 0;
  5106. }
  5107. break;
  5108. case 3:
  5109. sprintf(atcmd_output, msg_txt(sd,1195), AUTOLOOTITEM_SIZE); // You can have %d items on your autolootitem list.
  5110. clif_displaymessage(fd, atcmd_output);
  5111. 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>".
  5112. clif_displaymessage(fd, msg_txt(sd,1197)); // "@alootid reset" will clear your autolootitem list.
  5113. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
  5114. if (i == AUTOLOOTITEM_SIZE) {
  5115. clif_displaymessage(fd, msg_txt(sd,1198)); // Your autolootitem list is empty.
  5116. } else {
  5117. clif_displaymessage(fd, msg_txt(sd,1199)); // Items on your autolootitem list:
  5118. for(i = 0; i < AUTOLOOTITEM_SIZE; i++)
  5119. {
  5120. if (sd->state.autolootid[i] == 0)
  5121. continue;
  5122. if (!(item_data = itemdb_exists(sd->state.autolootid[i]))) {
  5123. 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);
  5124. continue;
  5125. }
  5126. sprintf(atcmd_output, "'%s'/'%s' {%d}", item_data->name, item_data->jname, item_data->nameid);
  5127. clif_displaymessage(fd, atcmd_output);
  5128. }
  5129. }
  5130. break;
  5131. case 4:
  5132. memset(sd->state.autolootid, 0, sizeof(sd->state.autolootid));
  5133. clif_displaymessage(fd, msg_txt(sd,1200)); // Your autolootitem list has been reset.
  5134. sd->state.autolooting = 0;
  5135. break;
  5136. }
  5137. return 0;
  5138. }
  5139. /*==========================================
  5140. * @autoloottype
  5141. * Flags:
  5142. * 1: IT_HEALING, 2: IT_UNKNOWN, 4: IT_USABLE, 8: IT_ETC,
  5143. * 16: IT_ARMOR, 32: IT_WEAPON, 64: IT_CARD, 128: IT_PETEGG,
  5144. * 256: IT_PETARMOR, 512: IT_UNKNOWN2, 1024: IT_AMMO, 2048: IT_DELAYCONSUME
  5145. * 262144: IT_CASH
  5146. *------------------------------------------
  5147. * Credits:
  5148. * chriser
  5149. * Aleos
  5150. *------------------------------------------*/
  5151. ACMD_FUNC(autoloottype)
  5152. {
  5153. uint8 i = 0, action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset
  5154. enum item_types type = -1;
  5155. int ITEM_MAX = 1533;
  5156. nullpo_retr(-1, sd);
  5157. if (message && *message) {
  5158. if (message[0] == '+') {
  5159. message++;
  5160. action = 1;
  5161. }
  5162. else if (message[0] == '-') {
  5163. message++;
  5164. action = 2;
  5165. }
  5166. else if (!strcmp(message,"reset"))
  5167. action = 4;
  5168. }
  5169. if (action < 3) { // add or remove
  5170. if ((strncmp(message, "healing", 3) == 0) || (atoi(message) == 0))
  5171. type = IT_HEALING;
  5172. else if ((strncmp(message, "usable", 3) == 0) || (atoi(message) == 2))
  5173. type = IT_USABLE;
  5174. else if ((strncmp(message, "etc", 3) == 0) || (atoi(message) == 3))
  5175. type = IT_ETC;
  5176. else if ((strncmp(message, "armor", 3) == 0) || (atoi(message) == 4))
  5177. type = IT_ARMOR;
  5178. else if ((strncmp(message, "weapon", 3) == 0) || (atoi(message) == 5))
  5179. type = IT_WEAPON;
  5180. else if ((strncmp(message, "card", 3) == 0) || (atoi(message) == 6))
  5181. type = IT_CARD;
  5182. else if ((strncmp(message, "petegg", 4) == 0) || (atoi(message) == 7))
  5183. type = IT_PETEGG;
  5184. else if ((strncmp(message, "petarmor", 4) == 0) || (atoi(message) == 8))
  5185. type = IT_PETARMOR;
  5186. else if ((strncmp(message, "ammo", 3) == 0) || (atoi(message) == 10))
  5187. type = IT_AMMO;
  5188. else {
  5189. clif_displaymessage(fd, msg_txt(sd,1480)); // Item type not found.
  5190. return -1;
  5191. }
  5192. }
  5193. switch (action) {
  5194. case 1:
  5195. if (sd->state.autoloottype&(1<<type)) {
  5196. clif_displaymessage(fd, msg_txt(sd,1481)); // You're already autolooting this item type.
  5197. return -1;
  5198. }
  5199. if (sd->state.autoloottype == ITEM_MAX) {
  5200. 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>.
  5201. return -1;
  5202. }
  5203. sd->state.autoloottype |= (1<<type); // Stores the type
  5204. sprintf(atcmd_output, msg_txt(sd,1483), itemdb_typename(type), type); // Autolooting item type: '%s' {%d}
  5205. clif_displaymessage(fd, atcmd_output);
  5206. break;
  5207. case 2:
  5208. if (!(sd->state.autoloottype&(1<<type))) {
  5209. clif_displaymessage(fd, msg_txt(sd,1484)); // You're currently not autolooting this item type.
  5210. return -1;
  5211. }
  5212. sd->state.autoloottype &= ~(1<<type);
  5213. sprintf(atcmd_output, msg_txt(sd,1485), itemdb_typename(type), type); // Removed item type: '%s' {%d} from your autoloottype list.
  5214. clif_displaymessage(fd, atcmd_output);
  5215. break;
  5216. case 3:
  5217. 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>".
  5218. 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
  5219. clif_displaymessage(fd, msg_txt(sd,1488)); // "@aloottype reset" will clear your autoloottype list.
  5220. if (sd->state.autoloottype == 0)
  5221. clif_displaymessage(fd, msg_txt(sd,1489)); // Your autoloottype list is empty.
  5222. else {
  5223. clif_displaymessage(fd, msg_txt(sd,1490)); // Item types on your autoloottype list:
  5224. while (i < IT_MAX) {
  5225. if (sd->state.autoloottype&(1<<i)) {
  5226. sprintf(atcmd_output, " '%s' {%d}", itemdb_typename(i), i);
  5227. clif_displaymessage(fd, atcmd_output);
  5228. }
  5229. i++;
  5230. }
  5231. }
  5232. break;
  5233. case 4:
  5234. sd->state.autoloottype = 0;
  5235. clif_displaymessage(fd, msg_txt(sd,1491)); // Your autoloottype list has been reset.
  5236. break;
  5237. }
  5238. return 0;
  5239. }
  5240. /**
  5241. * No longer available, keeping here just in case it's back someday. [Ind]
  5242. **/
  5243. /*==========================================
  5244. * It is made to rain.
  5245. *------------------------------------------*/
  5246. //ACMD_FUNC(rain)
  5247. //{
  5248. // nullpo_retr(-1, sd);
  5249. // if (map[sd->bl.m].flag.rain) {
  5250. // map[sd->bl.m].flag.rain=0;
  5251. // clif_weather(sd->bl.m);
  5252. // clif_displaymessage(fd, msg_txt(sd,1201)); // The rain has stopped.
  5253. // } else {
  5254. // map[sd->bl.m].flag.rain=1;
  5255. // clif_weather(sd->bl.m);
  5256. // clif_displaymessage(fd, msg_txt(sd,1202)); // It has started to rain.
  5257. // }
  5258. // return 0;
  5259. //}
  5260. /*==========================================
  5261. * It is made to snow.
  5262. *------------------------------------------*/
  5263. ACMD_FUNC(snow)
  5264. {
  5265. nullpo_retr(-1, sd);
  5266. if (map[sd->bl.m].flag.snow) {
  5267. map[sd->bl.m].flag.snow=0;
  5268. clif_weather(sd->bl.m);
  5269. clif_displaymessage(fd, msg_txt(sd,1203)); // Snow has stopped falling.
  5270. } else {
  5271. map[sd->bl.m].flag.snow=1;
  5272. clif_weather(sd->bl.m);
  5273. clif_displaymessage(fd, msg_txt(sd,1204)); // It has started to snow.
  5274. }
  5275. return 0;
  5276. }
  5277. /*==========================================
  5278. * Cherry tree snowstorm is made to fall. (Sakura)
  5279. *------------------------------------------*/
  5280. ACMD_FUNC(sakura)
  5281. {
  5282. nullpo_retr(-1, sd);
  5283. if (map[sd->bl.m].flag.sakura) {
  5284. map[sd->bl.m].flag.sakura=0;
  5285. clif_weather(sd->bl.m);
  5286. clif_displaymessage(fd, msg_txt(sd,1205)); // Cherry tree leaves no longer fall.
  5287. } else {
  5288. map[sd->bl.m].flag.sakura=1;
  5289. clif_weather(sd->bl.m);
  5290. clif_displaymessage(fd, msg_txt(sd,1206)); // Cherry tree leaves have begun to fall.
  5291. }
  5292. return 0;
  5293. }
  5294. /*==========================================
  5295. * Clouds appear.
  5296. *------------------------------------------*/
  5297. ACMD_FUNC(clouds)
  5298. {
  5299. nullpo_retr(-1, sd);
  5300. if (map[sd->bl.m].flag.clouds) {
  5301. map[sd->bl.m].flag.clouds=0;
  5302. clif_weather(sd->bl.m);
  5303. clif_displaymessage(fd, msg_txt(sd,1207)); // The clouds has disappear.
  5304. } else {
  5305. map[sd->bl.m].flag.clouds=1;
  5306. clif_weather(sd->bl.m);
  5307. clif_displaymessage(fd, msg_txt(sd,1208)); // Clouds appear.
  5308. }
  5309. return 0;
  5310. }
  5311. /*==========================================
  5312. * Different type of clouds using effect 516
  5313. *------------------------------------------*/
  5314. ACMD_FUNC(clouds2)
  5315. {
  5316. nullpo_retr(-1, sd);
  5317. if (map[sd->bl.m].flag.clouds2) {
  5318. map[sd->bl.m].flag.clouds2=0;
  5319. clif_weather(sd->bl.m);
  5320. clif_displaymessage(fd, msg_txt(sd,1209)); // The alternative clouds disappear.
  5321. } else {
  5322. map[sd->bl.m].flag.clouds2=1;
  5323. clif_weather(sd->bl.m);
  5324. clif_displaymessage(fd, msg_txt(sd,1210)); // Alternative clouds appear.
  5325. }
  5326. return 0;
  5327. }
  5328. /*==========================================
  5329. * Fog hangs over.
  5330. *------------------------------------------*/
  5331. ACMD_FUNC(fog)
  5332. {
  5333. nullpo_retr(-1, sd);
  5334. if (map[sd->bl.m].flag.fog) {
  5335. map[sd->bl.m].flag.fog=0;
  5336. clif_weather(sd->bl.m);
  5337. clif_displaymessage(fd, msg_txt(sd,1211)); // The fog has gone.
  5338. } else {
  5339. map[sd->bl.m].flag.fog=1;
  5340. clif_weather(sd->bl.m);
  5341. clif_displaymessage(fd, msg_txt(sd,1212)); // Fog hangs over.
  5342. }
  5343. return 0;
  5344. }
  5345. /*==========================================
  5346. * Fallen leaves fall.
  5347. *------------------------------------------*/
  5348. ACMD_FUNC(leaves)
  5349. {
  5350. nullpo_retr(-1, sd);
  5351. if (map[sd->bl.m].flag.leaves) {
  5352. map[sd->bl.m].flag.leaves=0;
  5353. clif_weather(sd->bl.m);
  5354. clif_displaymessage(fd, msg_txt(sd,1213)); // Leaves no longer fall.
  5355. } else {
  5356. map[sd->bl.m].flag.leaves=1;
  5357. clif_weather(sd->bl.m);
  5358. clif_displaymessage(fd, msg_txt(sd,1214)); // Fallen leaves fall.
  5359. }
  5360. return 0;
  5361. }
  5362. /*==========================================
  5363. * Fireworks appear.
  5364. *------------------------------------------*/
  5365. ACMD_FUNC(fireworks)
  5366. {
  5367. nullpo_retr(-1, sd);
  5368. if (map[sd->bl.m].flag.fireworks) {
  5369. map[sd->bl.m].flag.fireworks=0;
  5370. clif_weather(sd->bl.m);
  5371. clif_displaymessage(fd, msg_txt(sd,1215)); // Fireworks have ended.
  5372. } else {
  5373. map[sd->bl.m].flag.fireworks=1;
  5374. clif_weather(sd->bl.m);
  5375. clif_displaymessage(fd, msg_txt(sd,1216)); // Fireworks have launched.
  5376. }
  5377. return 0;
  5378. }
  5379. /*==========================================
  5380. * Clearing Weather Effects by Dexity
  5381. *------------------------------------------*/
  5382. ACMD_FUNC(clearweather)
  5383. {
  5384. nullpo_retr(-1, sd);
  5385. /**
  5386. * No longer available, keeping here just in case it's back someday. [Ind]
  5387. **/
  5388. //map[sd->bl.m].flag.rain=0;
  5389. map[sd->bl.m].flag.snow=0;
  5390. map[sd->bl.m].flag.sakura=0;
  5391. map[sd->bl.m].flag.clouds=0;
  5392. map[sd->bl.m].flag.clouds2=0;
  5393. map[sd->bl.m].flag.fog=0;
  5394. map[sd->bl.m].flag.fireworks=0;
  5395. map[sd->bl.m].flag.leaves=0;
  5396. clif_weather(sd->bl.m);
  5397. clif_displaymessage(fd, msg_txt(sd,291));
  5398. return 0;
  5399. }
  5400. /*===============================================================
  5401. * Sound Command - plays a sound for everyone around! [Codemaster]
  5402. *---------------------------------------------------------------*/
  5403. ACMD_FUNC(sound)
  5404. {
  5405. char sound_file[100];
  5406. memset(sound_file, '\0', sizeof(sound_file));
  5407. if(!message || !*message || sscanf(message, "%99[^\n]", sound_file) < 1) {
  5408. clif_displaymessage(fd, msg_txt(sd,1217)); // Please enter a sound filename (usage: @sound <filename>).
  5409. return -1;
  5410. }
  5411. if(strstr(sound_file, ".wav") == NULL)
  5412. strcat(sound_file, ".wav");
  5413. clif_soundeffectall(&sd->bl, sound_file, 0, AREA);
  5414. return 0;
  5415. }
  5416. /*==========================================
  5417. * MOB Search
  5418. *------------------------------------------*/
  5419. ACMD_FUNC(mobsearch)
  5420. {
  5421. char mob_name[100];
  5422. int mob_id;
  5423. int number = 0;
  5424. struct s_mapiterator* it;
  5425. nullpo_retr(-1, sd);
  5426. if (!message || !*message || sscanf(message, "%99[^\n]", mob_name) < 1) {
  5427. clif_displaymessage(fd, msg_txt(sd,1218)); // Please enter a monster name (usage: @mobsearch <monster name>).
  5428. return -1;
  5429. }
  5430. if ((mob_id = atoi(mob_name)) == 0)
  5431. mob_id = mobdb_searchname(mob_name);
  5432. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  5433. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1219),mob_name); // Invalid mob ID %s!
  5434. clif_displaymessage(fd, atcmd_output);
  5435. return -1;
  5436. }
  5437. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  5438. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  5439. // strcpy(mob_name,mob_db(mob_id)->name); // --en--
  5440. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1220), mob_name, mapindex_id2name(sd->mapindex)); // Mob Search... %s %s
  5441. clif_displaymessage(fd, atcmd_output);
  5442. it = mapit_geteachmob();
  5443. for(;;)
  5444. {
  5445. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  5446. if( md == NULL )
  5447. break;// no more mobs
  5448. if( md->bl.m != sd->bl.m )
  5449. continue;
  5450. if( mob_id != -1 && md->mob_id != mob_id )
  5451. continue;
  5452. ++number;
  5453. if( md->spawn_timer == INVALID_TIMER )
  5454. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%3d:%3d] %s", number, md->bl.x, md->bl.y, md->name);
  5455. else
  5456. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%s] %s", number, "dead", md->name);
  5457. clif_displaymessage(fd, atcmd_output);
  5458. }
  5459. mapit_free(it);
  5460. return 0;
  5461. }
  5462. /*==========================================
  5463. * @cleanmap - cleans items on the ground
  5464. * @cleanarea - cleans items on the ground within an specified area
  5465. *------------------------------------------*/
  5466. static int atcommand_cleanfloor_sub(struct block_list *bl, va_list ap)
  5467. {
  5468. nullpo_ret(bl);
  5469. map_clearflooritem(bl);
  5470. return 0;
  5471. }
  5472. ACMD_FUNC(cleanmap)
  5473. {
  5474. map_foreachinmap(atcommand_cleanfloor_sub, sd->bl.m, BL_ITEM);
  5475. clif_displaymessage(fd, msg_txt(sd,1221)); // All dropped items have been cleaned up.
  5476. return 0;
  5477. }
  5478. ACMD_FUNC(cleanarea)
  5479. {
  5480. int x0 = 0, y0 = 0, x1 = 0, y1 = 0;
  5481. if (!message || !*message || sscanf(message, "%d %d %d %d", &x0, &y0, &x1, &y1) < 1) {
  5482. map_foreachinarea(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);
  5483. }
  5484. else if (sscanf(message, "%d %d %d %d", &x0, &y0, &x1, &y1) == 1) {
  5485. map_foreachinarea(atcommand_cleanfloor_sub, sd->bl.m, sd->bl.x - x0, sd->bl.y - x0, sd->bl.x + x0, sd->bl.y + x0, BL_ITEM);
  5486. }
  5487. else if (sscanf(message, "%d %d %d %d", &x0, &y0, &x1, &y1) == 4) {
  5488. map_foreachinarea(atcommand_cleanfloor_sub, sd->bl.m, x0, y0, x1, y1, BL_ITEM);
  5489. }
  5490. clif_displaymessage(fd, msg_txt(sd,1221)); // All dropped items have been cleaned up.
  5491. return 0;
  5492. }
  5493. /*==========================================
  5494. * make a NPC/PET talk
  5495. * @npctalkc [SnakeDrak]
  5496. *------------------------------------------*/
  5497. ACMD_FUNC(npctalk)
  5498. {
  5499. char name[NAME_LENGTH],mes[100],temp[100];
  5500. struct npc_data *nd;
  5501. bool ifcolor=(*(command + 8) != 'c' && *(command + 8) != 'C')?0:1;
  5502. unsigned long color=0;
  5503. if (sd->sc.cant.chat)
  5504. return -1; //no "chatting" while muted.
  5505. if(!ifcolor) {
  5506. if (!message || !*message || sscanf(message, "%23[^,], %99[^\n]", name, mes) < 2) {
  5507. clif_displaymessage(fd, msg_txt(sd,1222)); // Please enter the correct parameters (usage: @npctalk <npc name>, <message>).
  5508. return -1;
  5509. }
  5510. }
  5511. else {
  5512. if (!message || !*message || sscanf(message, "%lx %23[^,], %99[^\n]", &color, name, mes) < 3) {
  5513. clif_displaymessage(fd, msg_txt(sd,1223)); // Please enter the correct parameters (usage: @npctalkc <color> <npc name>, <message>).
  5514. return -1;
  5515. }
  5516. }
  5517. if (!(nd = npc_name2id(name))) {
  5518. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist
  5519. return -1;
  5520. }
  5521. strtok(name, "#"); // discard extra name identifier if present
  5522. snprintf(temp, sizeof(temp), "%s : %s", name, mes);
  5523. if(ifcolor) clif_messagecolor(&nd->bl,color,temp);
  5524. else clif_disp_overhead(&nd->bl, temp);
  5525. return 0;
  5526. }
  5527. ACMD_FUNC(pettalk)
  5528. {
  5529. char mes[100],temp[100];
  5530. struct pet_data *pd;
  5531. nullpo_retr(-1, sd);
  5532. if ( battle_config.min_chat_delay ) {
  5533. if( DIFF_TICK(sd->cantalk_tick, gettick()) > 0 )
  5534. return 0;
  5535. sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
  5536. }
  5537. if(!sd->status.pet_id || !(pd=sd->pd))
  5538. {
  5539. clif_displaymessage(fd, msg_txt(sd,184));
  5540. return -1;
  5541. }
  5542. if (sd->sc.cant.chat)
  5543. return -1; //no "chatting" while muted.
  5544. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  5545. clif_displaymessage(fd, msg_txt(sd,1224)); // Please enter a message (usage: @pettalk <message>).
  5546. return -1;
  5547. }
  5548. if (message[0] == '/')
  5549. {// pet emotion processing
  5550. const char* emo[] = {
  5551. "/!", "/?", "/ho", "/lv", "/swt", "/ic", "/an", "/ag", "/$", "/...",
  5552. "/scissors", "/rock", "/paper", "/korea", "/lv2", "/thx", "/wah", "/sry", "/heh", "/swt2",
  5553. "/hmm", "/no1", "/??", "/omg", "/O", "/X", "/hlp", "/go", "/sob", "/gg",
  5554. "/kis", "/kis2", "/pif", "/ok", "-?-", "/indonesia", "/bzz", "/rice", "/awsm", "/meh",
  5555. "/shy", "/pat", "/mp", "/slur", "/com", "/yawn", "/grat", "/hp", "/philippines", "/malaysia",
  5556. "/singapore", "/brazil", "/fsh", "/spin", "/sigh", "/dum", "/crwd", "/desp", "/dice", "-dice2",
  5557. "-dice3", "-dice4", "-dice5", "-dice6", "/india", "/love", "/russia", "-?-", "/mobile", "/mail",
  5558. "/chinese", "/antenna1", "/antenna2", "/antenna3", "/hum", "/abs", "/oops", "/spit", "/ene", "/panic",
  5559. "/whisp"
  5560. };
  5561. int i;
  5562. ARR_FIND( 0, ARRAYLENGTH(emo), i, stricmp(message, emo[i]) == 0 );
  5563. if( i == E_DICE1 ) i = rnd()%6 + E_DICE1; // randomize /dice
  5564. if( i < ARRAYLENGTH(emo) )
  5565. {
  5566. if (sd->emotionlasttime + 1 >= time(NULL)) { // not more than 1 per second
  5567. sd->emotionlasttime = time(NULL);
  5568. return 0;
  5569. }
  5570. sd->emotionlasttime = time(NULL);
  5571. clif_emotion(&pd->bl, i);
  5572. return 0;
  5573. }
  5574. }
  5575. snprintf(temp, sizeof temp ,"%s : %s", pd->pet.name, mes);
  5576. clif_disp_overhead(&pd->bl, temp);
  5577. return 0;
  5578. }
  5579. /// @users - displays the number of players present on each map (and percentage)
  5580. /// #users displays on the target user instead of self
  5581. ACMD_FUNC(users)
  5582. {
  5583. char buf[CHAT_SIZE_MAX];
  5584. int i;
  5585. int users[MAX_MAPINDEX];
  5586. int users_all;
  5587. struct s_mapiterator* iter;
  5588. memset(users, 0, sizeof(users));
  5589. users_all = 0;
  5590. // count users on each map
  5591. iter = mapit_getallusers();
  5592. for(;;)
  5593. {
  5594. struct map_session_data* sd2 = (struct map_session_data*)mapit_next(iter);
  5595. if( sd2 == NULL )
  5596. break;// no more users
  5597. if( sd2->mapindex >= MAX_MAPINDEX )
  5598. continue;// invalid mapindex
  5599. if( users[sd2->mapindex] < INT_MAX ) ++users[sd2->mapindex];
  5600. if( users_all < INT_MAX ) ++users_all;
  5601. }
  5602. mapit_free(iter);
  5603. // display results for each map
  5604. for( i = 0; i < MAX_MAPINDEX; ++i )
  5605. {
  5606. if( users[i] == 0 )
  5607. continue;// empty
  5608. safesnprintf(buf, sizeof(buf), "%s: %d (%.2f%%)", mapindex_id2name(i), users[i], (float)(100.0f*users[i]/users_all));
  5609. clif_displaymessage(sd->fd, buf);
  5610. }
  5611. // display overall count
  5612. safesnprintf(buf, sizeof(buf), "all: %d", users_all);
  5613. clif_displaymessage(sd->fd, buf);
  5614. return 0;
  5615. }
  5616. /*==========================================
  5617. *
  5618. *------------------------------------------*/
  5619. ACMD_FUNC(reset)
  5620. {
  5621. pc_resetstate(sd);
  5622. pc_resetskill(sd,1);
  5623. sprintf(atcmd_output, msg_txt(sd,208), sd->status.name); // '%s' skill and stats points reseted!
  5624. clif_displaymessage(fd, atcmd_output);
  5625. return 0;
  5626. }
  5627. /*==========================================
  5628. *
  5629. *------------------------------------------*/
  5630. ACMD_FUNC(summon)
  5631. {
  5632. char name[NAME_LENGTH];
  5633. int mob_id = 0;
  5634. int duration = 0;
  5635. struct mob_data *md;
  5636. unsigned int tick=gettick();
  5637. nullpo_retr(-1, sd);
  5638. if (!message || !*message || sscanf(message, "%23s %d", name, &duration) < 1)
  5639. {
  5640. clif_displaymessage(fd, msg_txt(sd,1225)); // Please enter a monster name (usage: @summon <monster name> {duration}).
  5641. return -1;
  5642. }
  5643. if (duration < 1)
  5644. duration =1;
  5645. else if (duration > 60)
  5646. duration =60;
  5647. if ((mob_id = atoi(name)) == 0)
  5648. mob_id = mobdb_searchname(name);
  5649. if(mob_id == 0 || mobdb_checkid(mob_id) == 0)
  5650. {
  5651. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  5652. return -1;
  5653. }
  5654. md = mob_once_spawn_sub(&sd->bl, sd->bl.m, -1, -1, "--ja--", mob_id, "", SZ_SMALL, AI_NONE);
  5655. if(!md)
  5656. return -1;
  5657. md->master_id=sd->bl.id;
  5658. md->special_state.ai=AI_ATTACK;
  5659. md->deletetimer=add_timer(tick+(duration*60000),mob_timer_delete,md->bl.id,0);
  5660. clif_specialeffect(&md->bl,344,AREA);
  5661. mob_spawn(md);
  5662. sc_start4(NULL,&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000);
  5663. clif_skill_poseffect(&sd->bl,AM_CALLHOMUN,1,md->bl.x,md->bl.y,tick);
  5664. clif_displaymessage(fd, msg_txt(sd,39)); // All monster summoned!
  5665. return 0;
  5666. }
  5667. /*==========================================
  5668. * @adjgroup
  5669. * Temporarily move player to another group
  5670. * Useful during beta testing to allow players to use GM commands for short periods of time
  5671. *------------------------------------------*/
  5672. ACMD_FUNC(adjgroup)
  5673. {
  5674. int new_group = 0;
  5675. nullpo_retr(-1, sd);
  5676. if (!message || !*message || sscanf(message, "%d", &new_group) != 1) {
  5677. clif_displaymessage(fd, msg_txt(sd,1226)); // Usage: @adjgroup <group_id>
  5678. return -1;
  5679. }
  5680. if (!pc_group_exists(new_group)) {
  5681. clif_displaymessage(fd, msg_txt(sd,1227)); // Specified group does not exist.
  5682. return -1;
  5683. }
  5684. sd->group_id = new_group;
  5685. pc_group_pc_load(sd);/* update cache */
  5686. clif_displaymessage(fd, msg_txt(sd,1228)); // Group changed successfully.
  5687. clif_displaymessage(sd->fd, msg_txt(sd,1229)); // Your group has changed.
  5688. return 0;
  5689. }
  5690. /*==========================================
  5691. * @trade by [MouseJstr]
  5692. * Open a trade window with a remote player
  5693. *------------------------------------------*/
  5694. ACMD_FUNC(trade)
  5695. {
  5696. struct map_session_data *pl_sd = NULL;
  5697. nullpo_retr(-1, sd);
  5698. if (!message || !*message) {
  5699. clif_displaymessage(fd, msg_txt(sd,1230)); // Please enter a player name (usage: @trade <char name>).
  5700. return -1;
  5701. }
  5702. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  5703. {
  5704. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5705. return -1;
  5706. }
  5707. trade_traderequest(sd, pl_sd);
  5708. return 0;
  5709. }
  5710. /*==========================================
  5711. * @setbattleflag by [MouseJstr]
  5712. * set a battle_config flag without having to reboot
  5713. *------------------------------------------*/
  5714. ACMD_FUNC(setbattleflag)
  5715. {
  5716. char flag[128], value[128];
  5717. nullpo_retr(-1, sd);
  5718. if (!message || !*message || sscanf(message, "%127s %127s", flag, value) != 2) {
  5719. clif_displaymessage(fd, msg_txt(sd,1231)); // Usage: @setbattleflag <flag> <value>
  5720. return -1;
  5721. }
  5722. if (battle_set_value(flag, value) == 0)
  5723. {
  5724. clif_displaymessage(fd, msg_txt(sd,1232)); // Unknown battle_config flag.
  5725. return -1;
  5726. }
  5727. clif_displaymessage(fd, msg_txt(sd,1233)); // Set battle_config as requested.
  5728. return 0;
  5729. }
  5730. /*==========================================
  5731. * @unmute [Valaris]
  5732. *------------------------------------------*/
  5733. ACMD_FUNC(unmute)
  5734. {
  5735. struct map_session_data *pl_sd = NULL;
  5736. nullpo_retr(-1, sd);
  5737. if (!message || !*message) {
  5738. clif_displaymessage(fd, msg_txt(sd,1234)); // Please enter a player name (usage: @unmute <char name>).
  5739. return -1;
  5740. }
  5741. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  5742. {
  5743. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5744. return -1;
  5745. }
  5746. if(!pl_sd->sc.data[SC_NOCHAT]) {
  5747. clif_displaymessage(sd->fd,msg_txt(sd,1235)); // Player is not muted.
  5748. return -1;
  5749. }
  5750. pl_sd->status.manner = 0;
  5751. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  5752. clif_displaymessage(sd->fd,msg_txt(sd,1236)); // Player unmuted.
  5753. return 0;
  5754. }
  5755. /*==========================================
  5756. * @uptime by MC Cameri
  5757. *------------------------------------------*/
  5758. ACMD_FUNC(uptime)
  5759. {
  5760. unsigned long seconds = 0, day = 24*60*60, hour = 60*60,
  5761. minute = 60, days = 0, hours = 0, minutes = 0;
  5762. nullpo_retr(-1, sd);
  5763. seconds = get_uptime();
  5764. days = seconds/day;
  5765. seconds -= (seconds/day>0)?(seconds/day)*day:0;
  5766. hours = seconds/hour;
  5767. seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
  5768. minutes = seconds/minute;
  5769. seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
  5770. snprintf(atcmd_output, sizeof(atcmd_output), msg_txt(sd,245), days, hours, minutes, seconds);
  5771. clif_displaymessage(fd, atcmd_output);
  5772. return 0;
  5773. }
  5774. /*==========================================
  5775. * @changesex <sex>
  5776. * => Changes one's sex. Argument sex can be 0 or 1, m or f, male or female.
  5777. *------------------------------------------*/
  5778. ACMD_FUNC(changesex)
  5779. {
  5780. int i;
  5781. nullpo_retr(-1, sd);
  5782. pc_resetskill(sd,4);
  5783. // to avoid any problem with equipment and invalid sex, equipment is unequiped.
  5784. for( i=0; i<EQI_MAX; i++ )
  5785. if( sd->equip_index[i] >= 0 ) pc_unequipitem(sd, sd->equip_index[i], 3);
  5786. chrif_changesex(sd);
  5787. return 0;
  5788. }
  5789. /*================================================
  5790. * @mute - Mutes a player for a set amount of time
  5791. *------------------------------------------------*/
  5792. ACMD_FUNC(mute)
  5793. {
  5794. struct map_session_data *pl_sd = NULL;
  5795. int manner;
  5796. nullpo_retr(-1, sd);
  5797. if (!message || !*message || sscanf(message, "%d %23[^\n]", &manner, atcmd_player_name) < 1) {
  5798. clif_displaymessage(fd, msg_txt(sd,1237)); // Usage: @mute <time> <char name>
  5799. return -1;
  5800. }
  5801. if ( (pl_sd = map_nick2sd(atcmd_player_name)) == NULL )
  5802. {
  5803. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5804. return -1;
  5805. }
  5806. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  5807. {
  5808. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  5809. return -1;
  5810. }
  5811. clif_manner_message(sd, 0);
  5812. clif_manner_message(pl_sd, 5);
  5813. if( pl_sd->status.manner < manner ) {
  5814. pl_sd->status.manner -= manner;
  5815. sc_start(NULL,&pl_sd->bl,SC_NOCHAT,100,0,0);
  5816. } else {
  5817. pl_sd->status.manner = 0;
  5818. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  5819. }
  5820. clif_GM_silence(sd, pl_sd, (manner > 0 ? 1 : 0));
  5821. return 0;
  5822. }
  5823. /*==========================================
  5824. * @refresh (like @jumpto <<yourself>>)
  5825. *------------------------------------------*/
  5826. ACMD_FUNC(refresh)
  5827. {
  5828. nullpo_retr(-1, sd);
  5829. clif_refresh(sd);
  5830. return 0;
  5831. }
  5832. ACMD_FUNC(refreshall)
  5833. {
  5834. struct map_session_data* iter_sd;
  5835. struct s_mapiterator* iter;
  5836. nullpo_retr(-1, sd);
  5837. iter = mapit_getallusers();
  5838. for (iter_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); iter_sd = (TBL_PC*)mapit_next(iter))
  5839. clif_refresh(iter_sd);
  5840. mapit_free(iter);
  5841. return 0;
  5842. }
  5843. /*==========================================
  5844. * @identify
  5845. * => GM's magnifier.
  5846. *------------------------------------------*/
  5847. ACMD_FUNC(identify)
  5848. {
  5849. int i,num;
  5850. nullpo_retr(-1, sd);
  5851. for(i=num=0;i<MAX_INVENTORY;i++){
  5852. if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1){
  5853. num++;
  5854. }
  5855. }
  5856. if (num > 0) {
  5857. clif_item_identify_list(sd);
  5858. } else {
  5859. clif_displaymessage(fd,msg_txt(sd,1238)); // There are no items to appraise.
  5860. }
  5861. return 0;
  5862. }
  5863. /*===============================================
  5864. * @identifyall
  5865. * => Indentify all items in inventory - Akinari
  5866. *-----------------------------------------------*/
  5867. ACMD_FUNC(identifyall)
  5868. {
  5869. int i;
  5870. nullpo_retr(-1, sd);
  5871. for(i=0; i<MAX_INVENTORY; i++) {
  5872. if (sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1) {
  5873. sd->status.inventory[i].identify=1;
  5874. clif_item_identified(sd,i,0);
  5875. }
  5876. }
  5877. return 0;
  5878. }
  5879. /*==========================================
  5880. * @gmotd (Global MOTD)
  5881. * by davidsiaw :P
  5882. *------------------------------------------*/
  5883. ACMD_FUNC(gmotd)
  5884. {
  5885. FILE* fp;
  5886. if( ( fp = fopen(motd_txt, "r") ) != NULL )
  5887. {
  5888. char buf[CHAT_SIZE_MAX];
  5889. size_t len;
  5890. while( fgets(buf, sizeof(buf), fp) )
  5891. {
  5892. if( buf[0] == '/' && buf[1] == '/' )
  5893. {
  5894. continue;
  5895. }
  5896. len = strlen(buf);
  5897. while( len && ( buf[len-1] == '\r' || buf[len-1] == '\n' ) )
  5898. {// strip trailing EOL characters
  5899. len--;
  5900. }
  5901. if( len )
  5902. {
  5903. buf[len] = 0;
  5904. intif_broadcast(buf, len+1, 0);
  5905. }
  5906. }
  5907. fclose(fp);
  5908. }
  5909. return 0;
  5910. }
  5911. ACMD_FUNC(misceffect)
  5912. {
  5913. int effect = 0;
  5914. nullpo_retr(-1, sd);
  5915. if (!message || !*message)
  5916. return -1;
  5917. if (sscanf(message, "%d", &effect) < 1)
  5918. return -1;
  5919. clif_misceffect(&sd->bl,effect);
  5920. return 0;
  5921. }
  5922. /*==========================================
  5923. * MAIL SYSTEM
  5924. *------------------------------------------*/
  5925. ACMD_FUNC(mail)
  5926. {
  5927. nullpo_ret(sd);
  5928. mail_openmail(sd);
  5929. return 0;
  5930. }
  5931. /*==========================================
  5932. * Show Monster DB Info v 1.0
  5933. * originally by [Lupus]
  5934. *------------------------------------------*/
  5935. ACMD_FUNC(mobinfo)
  5936. {
  5937. unsigned char msize[3][7] = {"Small", "Medium", "Large"};
  5938. unsigned char mrace[12][11] = {"Formless", "Undead", "Beast", "Plant", "Insect", "Fish", "Demon", "Demi-Human", "Angel", "Dragon", "Boss", "Non-Boss"};
  5939. unsigned char melement[10][8] = {"Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead"};
  5940. char atcmd_output2[CHAT_SIZE_MAX];
  5941. struct item_data *item_data;
  5942. struct mob_db *mob, *mob_array[MAX_SEARCH];
  5943. int count;
  5944. int i, k;
  5945. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5946. memset(atcmd_output2, '\0', sizeof(atcmd_output2));
  5947. if (!message || !*message) {
  5948. clif_displaymessage(fd, msg_txt(sd,1239)); // Please enter a monster name/ID (usage: @mobinfo <monster_name_or_monster_ID>).
  5949. return -1;
  5950. }
  5951. // If monster identifier/name argument is a name
  5952. if ((i = mobdb_checkid(atoi(message))))
  5953. {
  5954. mob_array[0] = mob_db(i);
  5955. count = 1;
  5956. } else
  5957. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  5958. if (!count) {
  5959. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  5960. return -1;
  5961. }
  5962. if (count > MAX_SEARCH) {
  5963. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH, count);
  5964. clif_displaymessage(fd, atcmd_output);
  5965. count = MAX_SEARCH;
  5966. }
  5967. for (k = 0; k < count; k++) {
  5968. unsigned int j,base_exp,job_exp;
  5969. mob = mob_array[k];
  5970. base_exp = mob->base_exp;
  5971. job_exp = mob->job_exp;
  5972. #ifdef RENEWAL_EXP
  5973. if( battle_config.atcommand_mobinfo_type ) {
  5974. base_exp = base_exp * pc_level_penalty_mod(sd, mob->lv, mob->status.class_, 1) / 100;
  5975. job_exp = job_exp * pc_level_penalty_mod(sd, mob->lv, mob->status.class_, 1) / 100;
  5976. }
  5977. #endif
  5978. #ifdef VIP_ENABLE
  5979. // Display EXP rate increase for VIP.
  5980. if (pc_isvip(sd) && (battle_config.vip_base_exp_increase || battle_config.vip_job_exp_increase)) {
  5981. base_exp += battle_config.vip_base_exp_increase;
  5982. job_exp += battle_config.vip_job_exp_increase;
  5983. }
  5984. #endif
  5985. // stats
  5986. if (mob->mexp)
  5987. sprintf(atcmd_output, msg_txt(sd,1240), mob->name, mob->jname, mob->sprite, mob->vd.class_); // MVP Monster: '%s'/'%s'/'%s' (%d)
  5988. else
  5989. sprintf(atcmd_output, msg_txt(sd,1241), mob->name, mob->jname, mob->sprite, mob->vd.class_); // Monster: '%s'/'%s'/'%s' (%d)
  5990. clif_displaymessage(fd, atcmd_output);
  5991. 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
  5992. clif_displaymessage(fd, atcmd_output);
  5993. sprintf(atcmd_output, msg_txt(sd,1243), // DEF:%d MDEF:%d STR:%d AGI:%d VIT:%d INT:%d DEX:%d LUK:%d
  5994. mob->status.def, mob->status.mdef,mob->status.str, mob->status.agi,
  5995. mob->status.vit, mob->status.int_, mob->status.dex, mob->status.luk);
  5996. clif_displaymessage(fd, atcmd_output);
  5997. sprintf(atcmd_output, msg_txt(sd,1244), // ATK:%d~%d Range:%d~%d~%d Size:%s Race: %s Element: %s (Lv:%d)
  5998. mob->status.rhw.atk, mob->status.rhw.atk2, mob->status.rhw.range,
  5999. mob->range2 , mob->range3, msize[mob->status.size],
  6000. mrace[mob->status.race], melement[mob->status.def_ele], mob->status.ele_lv);
  6001. clif_displaymessage(fd, atcmd_output);
  6002. // drops
  6003. clif_displaymessage(fd, msg_txt(sd,1245)); // Drops:
  6004. strcpy(atcmd_output, " ");
  6005. j = 0;
  6006. for (i = 0; i < MAX_MOB_DROP; i++) {
  6007. int droprate;
  6008. if (mob->dropitem[i].nameid <= 0 || mob->dropitem[i].p < 1 || (item_data = itemdb_exists(mob->dropitem[i].nameid)) == NULL)
  6009. continue;
  6010. droprate = mob->dropitem[i].p;
  6011. #ifdef RENEWAL_DROP
  6012. if( battle_config.atcommand_mobinfo_type ) {
  6013. droprate = droprate * pc_level_penalty_mod(sd, mob->lv, mob->status.class_, 2) / 100;
  6014. if (droprate <= 0 && !battle_config.drop_rate0item)
  6015. droprate = 1;
  6016. }
  6017. #endif
  6018. #ifdef VIP_ENABLE
  6019. // Display item rate increase for VIP.
  6020. if (pc_isvip(sd) && battle_config.vip_drop_increase)
  6021. droprate += battle_config.vip_drop_increase;
  6022. #endif
  6023. if (item_data->slot)
  6024. sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, (float)droprate / 100);
  6025. else
  6026. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)droprate / 100);
  6027. strcat(atcmd_output, atcmd_output2);
  6028. if (++j % 3 == 0) {
  6029. clif_displaymessage(fd, atcmd_output);
  6030. strcpy(atcmd_output, " ");
  6031. }
  6032. }
  6033. if (j == 0)
  6034. clif_displaymessage(fd, msg_txt(sd,1246)); // This monster has no drops.
  6035. else if (j % 3 != 0)
  6036. clif_displaymessage(fd, atcmd_output);
  6037. // mvp
  6038. if (mob->mexp) {
  6039. sprintf(atcmd_output, msg_txt(sd,1247), mob->mexp); // MVP Bonus EXP:%u
  6040. clif_displaymessage(fd, atcmd_output);
  6041. strcpy(atcmd_output, msg_txt(sd,1248)); // MVP Items:
  6042. j = 0;
  6043. for (i = 0; i < MAX_MVP_DROP; i++) {
  6044. if (mob->mvpitem[i].nameid <= 0 || (item_data = itemdb_exists(mob->mvpitem[i].nameid)) == NULL)
  6045. continue;
  6046. if (mob->mvpitem[i].p > 0) {
  6047. j++;
  6048. if (j == 1) {
  6049. if (item_data->slot)
  6050. sprintf(atcmd_output2, " %s[%d] %02.02f%%", item_data->jname, item_data->slot, (float)mob->mvpitem[i].p / 100);
  6051. else
  6052. sprintf(atcmd_output2, " %s %02.02f%%", item_data->jname, (float)mob->mvpitem[i].p / 100);
  6053. } else {
  6054. if (item_data->slot)
  6055. sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, (float)mob->mvpitem[i].p / 100);
  6056. else
  6057. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)mob->mvpitem[i].p / 100);
  6058. }
  6059. strcat(atcmd_output, atcmd_output2);
  6060. }
  6061. }
  6062. if (j == 0)
  6063. clif_displaymessage(fd, msg_txt(sd,1249)); // This monster has no MVP prizes.
  6064. else
  6065. clif_displaymessage(fd, atcmd_output);
  6066. }
  6067. }
  6068. return 0;
  6069. }
  6070. /*=========================================
  6071. * @showmobs by KarLaeda
  6072. * => For 15 sec displays the mobs on minimap
  6073. *------------------------------------------*/
  6074. ACMD_FUNC(showmobs)
  6075. {
  6076. char mob_name[100];
  6077. int mob_id;
  6078. int number = 0;
  6079. struct s_mapiterator* it;
  6080. nullpo_retr(-1, sd);
  6081. if(sscanf(message, "%99[^\n]", mob_name) < 0)
  6082. return -1;
  6083. if((mob_id = atoi(mob_name)) == 0)
  6084. mob_id = mobdb_searchname(mob_name);
  6085. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  6086. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1250),mob_name); // Invalid mob id %s!
  6087. clif_displaymessage(fd, atcmd_output);
  6088. return 0;
  6089. }
  6090. if(mob_db(mob_id)->status.mode&MD_BOSS && !pc_has_permission(sd, PC_PERM_SHOW_BOSS)){ // If player group does not have access to boss mobs.
  6091. clif_displaymessage(fd, msg_txt(sd,1251)); // Can't show boss mobs!
  6092. return 0;
  6093. }
  6094. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  6095. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  6096. //strcpy(mob_name,mob_db(mob_id)->name); // --en--
  6097. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1252), // Mob Search... %s %s
  6098. mob_name, mapindex_id2name(sd->mapindex));
  6099. clif_displaymessage(fd, atcmd_output);
  6100. it = mapit_geteachmob();
  6101. for(;;)
  6102. {
  6103. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  6104. if( md == NULL )
  6105. break;// no more mobs
  6106. if( md->bl.m != sd->bl.m )
  6107. continue;
  6108. if( mob_id != -1 && md->mob_id != mob_id )
  6109. continue;
  6110. if( md->special_state.ai || md->master_id )
  6111. continue; // hide slaves and player summoned mobs
  6112. if( md->spawn_timer != INVALID_TIMER )
  6113. continue; // hide mobs waiting for respawn
  6114. ++number;
  6115. clif_viewpoint(sd, 1, 0, md->bl.x, md->bl.y, number, 0xFFFFFF);
  6116. }
  6117. mapit_free(it);
  6118. return 0;
  6119. }
  6120. /*==========================================
  6121. * homunculus level up [orn]
  6122. *------------------------------------------*/
  6123. ACMD_FUNC(homlevel)
  6124. {
  6125. TBL_HOM * hd;
  6126. int level = 0, i = 0;
  6127. nullpo_retr(-1, sd);
  6128. if ( !message || !*message || ( level = atoi(message) ) < 1 ) {
  6129. clif_displaymessage(fd, msg_txt(sd,1253)); // Please enter a level adjustment (usage: @homlevel <number of levels>).
  6130. return -1;
  6131. }
  6132. if ( !hom_is_active(sd->hd) ) {
  6133. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6134. return -1;
  6135. }
  6136. hd = sd->hd;
  6137. for (i = 1; i <= level && hd->exp_next; i++){
  6138. hd->homunculus.exp += hd->exp_next;
  6139. if( !hom_levelup(hd) ){
  6140. break;
  6141. }
  6142. }
  6143. status_calc_homunculus(hd,0);
  6144. status_percent_heal(&hd->bl, 100, 100);
  6145. clif_specialeffect(&hd->bl,568,AREA);
  6146. return 0;
  6147. }
  6148. /*==========================================
  6149. * homunculus evolution H [orn]
  6150. *------------------------------------------*/
  6151. ACMD_FUNC(homevolution)
  6152. {
  6153. nullpo_retr(-1, sd);
  6154. if ( !hom_is_active(sd->hd) ) {
  6155. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6156. return -1;
  6157. }
  6158. if ( !hom_evolution(sd->hd) ) {
  6159. clif_displaymessage(fd, msg_txt(sd,1255)); // Your homunculus doesn't evolve.
  6160. return -1;
  6161. }
  6162. clif_homskillinfoblock(sd);
  6163. return 0;
  6164. }
  6165. ACMD_FUNC(hommutate)
  6166. {
  6167. int homun_id, m_class = 0, m_id;
  6168. nullpo_retr(-1, sd);
  6169. if (!hom_is_active(sd->hd)) {
  6170. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6171. return -1;
  6172. }
  6173. if (!message || !*message) {
  6174. homun_id = 6048 + (rnd() % 4);
  6175. } else {
  6176. homun_id = atoi(message);
  6177. }
  6178. m_class = hom_class2mapid(sd->hd->homunculus.class_);
  6179. m_id = hom_class2mapid(homun_id);
  6180. if (m_class != -1 && m_id != -1 && m_class&HOM_EVO && m_id&HOM_S && sd->hd->homunculus.level >= 99) {
  6181. hom_mutate(sd->hd, homun_id);
  6182. } else {
  6183. clif_emotion(&sd->hd->bl, E_SWT);
  6184. }
  6185. return 0;
  6186. }
  6187. /*==========================================
  6188. * call choosen homunculus [orn]
  6189. *------------------------------------------*/
  6190. ACMD_FUNC(makehomun)
  6191. {
  6192. int homunid;
  6193. nullpo_retr(-1, sd);
  6194. if ( sd->status.hom_id ) {
  6195. clif_displaymessage(fd, msg_txt(sd,450));
  6196. return -1;
  6197. }
  6198. if (!message || !*message) {
  6199. clif_displaymessage(fd, msg_txt(sd,1256)); // Please enter a homunculus ID (usage: @makehomun <homunculus id>).
  6200. return -1;
  6201. }
  6202. homunid = atoi(message);
  6203. if( homunid < HM_CLASS_BASE || homunid > HM_CLASS_BASE + MAX_HOMUNCULUS_CLASS - 1 )
  6204. {
  6205. clif_displaymessage(fd, msg_txt(sd,1257)); // Invalid Homunculus ID.
  6206. return -1;
  6207. }
  6208. hom_create_request(sd,homunid);
  6209. return 0;
  6210. }
  6211. /*==========================================
  6212. * modify homunculus intimacy [orn]
  6213. *------------------------------------------*/
  6214. ACMD_FUNC(homfriendly)
  6215. {
  6216. int friendly = 0;
  6217. nullpo_retr(-1, sd);
  6218. if ( !hom_is_active(sd->hd) ) {
  6219. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6220. return -1;
  6221. }
  6222. if (!message || !*message) {
  6223. clif_displaymessage(fd, msg_txt(sd,1258)); // Please enter a friendly value (usage: @homfriendly <friendly value [0-1000]>).
  6224. return -1;
  6225. }
  6226. friendly = atoi(message);
  6227. friendly = cap_value(friendly, 0, 1000);
  6228. sd->hd->homunculus.intimacy = friendly * 100 ;
  6229. clif_send_homdata(sd,SP_INTIMATE,friendly);
  6230. return 0;
  6231. }
  6232. /*==========================================
  6233. * modify homunculus hunger [orn]
  6234. *------------------------------------------*/
  6235. ACMD_FUNC(homhungry)
  6236. {
  6237. int hungry = 0;
  6238. nullpo_retr(-1, sd);
  6239. if ( !hom_is_active(sd->hd) ) {
  6240. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6241. return -1;
  6242. }
  6243. if (!message || !*message) {
  6244. clif_displaymessage(fd, msg_txt(sd,1259)); // Please enter a hunger value (usage: @homhungry <hunger value [0-100]>).
  6245. return -1;
  6246. }
  6247. hungry = atoi(message);
  6248. hungry = cap_value(hungry, 0, 100);
  6249. sd->hd->homunculus.hunger = hungry;
  6250. clif_send_homdata(sd,SP_HUNGRY,hungry);
  6251. return 0;
  6252. }
  6253. /*==========================================
  6254. * make the homunculus speak [orn]
  6255. *------------------------------------------*/
  6256. ACMD_FUNC(homtalk)
  6257. {
  6258. char mes[100],temp[100];
  6259. nullpo_retr(-1, sd);
  6260. if ( battle_config.min_chat_delay ) {
  6261. if( DIFF_TICK(sd->cantalk_tick, gettick()) > 0 )
  6262. return 0;
  6263. sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
  6264. }
  6265. if (sd->sc.cant.chat)
  6266. return -1; //no "chatting" while muted.
  6267. if ( !hom_is_active(sd->hd) ) {
  6268. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6269. return -1;
  6270. }
  6271. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  6272. clif_displaymessage(fd, msg_txt(sd,1260)); // Please enter a message (usage: @homtalk <message>).
  6273. return -1;
  6274. }
  6275. snprintf(temp, sizeof temp ,"%s : %s", sd->hd->homunculus.name, mes);
  6276. clif_disp_overhead(&sd->hd->bl, temp);
  6277. return 0;
  6278. }
  6279. /*==========================================
  6280. * Show homunculus stats
  6281. *------------------------------------------*/
  6282. ACMD_FUNC(hominfo)
  6283. {
  6284. struct homun_data *hd;
  6285. struct status_data *status;
  6286. nullpo_retr(-1, sd);
  6287. if ( !hom_is_active(sd->hd) ) {
  6288. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6289. return -1;
  6290. }
  6291. hd = sd->hd;
  6292. status = status_get_status_data(&hd->bl);
  6293. clif_displaymessage(fd, msg_txt(sd,1261)); // Homunculus stats:
  6294. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1262), // HP: %d/%d - SP: %d/%d
  6295. status->hp, status->max_hp, status->sp, status->max_sp);
  6296. clif_displaymessage(fd, atcmd_output);
  6297. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1263), // ATK: %d - MATK: %d~%d
  6298. status->rhw.atk2 +status->batk, status->matk_min, status->matk_max);
  6299. clif_displaymessage(fd, atcmd_output);
  6300. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1264), // Hungry: %d - Intimacy: %u
  6301. hd->homunculus.hunger, hd->homunculus.intimacy/100);
  6302. clif_displaymessage(fd, atcmd_output);
  6303. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6304. msg_txt(sd,1265), // Stats: Str %d / Agi %d / Vit %d / Int %d / Dex %d / Luk %d
  6305. status->str, status->agi, status->vit,
  6306. status->int_, status->dex, status->luk);
  6307. clif_displaymessage(fd, atcmd_output);
  6308. return 0;
  6309. }
  6310. ACMD_FUNC(homstats)
  6311. {
  6312. struct homun_data *hd;
  6313. struct s_homunculus_db *db;
  6314. struct s_homunculus *hom;
  6315. int lv, min, max, evo;
  6316. nullpo_retr(-1, sd);
  6317. if ( !hom_is_active(sd->hd) ) {
  6318. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6319. return -1;
  6320. }
  6321. hd = sd->hd;
  6322. hom = &hd->homunculus;
  6323. db = hd->homunculusDB;
  6324. lv = hom->level;
  6325. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6326. msg_txt(sd,1266), lv, db->name); // Homunculus growth stats (Lv %d %s):
  6327. clif_displaymessage(fd, atcmd_output);
  6328. lv--; //Since the first increase is at level 2.
  6329. evo = (hom->class_ == db->evo_class);
  6330. min = db->base.HP +lv*db->gmin.HP +(evo?db->emin.HP:0);
  6331. max = db->base.HP +lv*db->gmax.HP +(evo?db->emax.HP:0);;
  6332. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1267), hom->max_hp, min, max); // Max HP: %d (%d~%d)
  6333. clif_displaymessage(fd, atcmd_output);
  6334. min = db->base.SP +lv*db->gmin.SP +(evo?db->emin.SP:0);
  6335. max = db->base.SP +lv*db->gmax.SP +(evo?db->emax.SP:0);;
  6336. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1268), hom->max_sp, min, max); // Max SP: %d (%d~%d)
  6337. clif_displaymessage(fd, atcmd_output);
  6338. min = db->base.str +lv*(db->gmin.str/10) +(evo?db->emin.str:0);
  6339. max = db->base.str +lv*(db->gmax.str/10) +(evo?db->emax.str:0);;
  6340. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1269), hom->str/10, min, max); // Str: %d (%d~%d)
  6341. clif_displaymessage(fd, atcmd_output);
  6342. min = db->base.agi +lv*(db->gmin.agi/10) +(evo?db->emin.agi:0);
  6343. max = db->base.agi +lv*(db->gmax.agi/10) +(evo?db->emax.agi:0);;
  6344. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1270), hom->agi/10, min, max); // Agi: %d (%d~%d)
  6345. clif_displaymessage(fd, atcmd_output);
  6346. min = db->base.vit +lv*(db->gmin.vit/10) +(evo?db->emin.vit:0);
  6347. max = db->base.vit +lv*(db->gmax.vit/10) +(evo?db->emax.vit:0);;
  6348. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1271), hom->vit/10, min, max); // Vit: %d (%d~%d)
  6349. clif_displaymessage(fd, atcmd_output);
  6350. min = db->base.int_ +lv*(db->gmin.int_/10) +(evo?db->emin.int_:0);
  6351. max = db->base.int_ +lv*(db->gmax.int_/10) +(evo?db->emax.int_:0);;
  6352. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1272), hom->int_/10, min, max); // Int: %d (%d~%d)
  6353. clif_displaymessage(fd, atcmd_output);
  6354. min = db->base.dex +lv*(db->gmin.dex/10) +(evo?db->emin.dex:0);
  6355. max = db->base.dex +lv*(db->gmax.dex/10) +(evo?db->emax.dex:0);;
  6356. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1273), hom->dex/10, min, max); // Dex: %d (%d~%d)
  6357. clif_displaymessage(fd, atcmd_output);
  6358. min = db->base.luk +lv*(db->gmin.luk/10) +(evo?db->emin.luk:0);
  6359. max = db->base.luk +lv*(db->gmax.luk/10) +(evo?db->emax.luk:0);;
  6360. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1274), hom->luk/10, min, max); // Luk: %d (%d~%d)
  6361. clif_displaymessage(fd, atcmd_output);
  6362. return 0;
  6363. }
  6364. ACMD_FUNC(homshuffle)
  6365. {
  6366. nullpo_retr(-1, sd);
  6367. if(!sd->hd)
  6368. return -1; // nothing to do
  6369. if(!hom_shuffle(sd->hd))
  6370. return -1;
  6371. clif_displaymessage(sd->fd, msg_txt(sd,1275)); // Homunculus stats altered.
  6372. atcommand_homstats(fd, sd, command, message); //Print out the new stats
  6373. return 0;
  6374. }
  6375. /*==========================================
  6376. * Show Items DB Info v 1.0
  6377. * originally by [Lupus]
  6378. *------------------------------------------*/
  6379. ACMD_FUNC(iteminfo)
  6380. {
  6381. struct item_data *item_array[MAX_SEARCH];
  6382. int i, count = 1;
  6383. if (!message || !*message) {
  6384. clif_displaymessage(fd, msg_txt(sd,1276)); // Please enter an item name/ID (usage: @ii/@iteminfo <item name/ID>).
  6385. return -1;
  6386. }
  6387. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  6388. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  6389. if (!count) {
  6390. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  6391. return -1;
  6392. }
  6393. if (count > MAX_SEARCH) {
  6394. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH, count); // Displaying first %d out of %d matches
  6395. clif_displaymessage(fd, atcmd_output);
  6396. count = MAX_SEARCH;
  6397. }
  6398. for (i = 0; i < count; i++) {
  6399. struct item_data * item_data = item_array[i];
  6400. sprintf(atcmd_output, msg_txt(sd,1277), // Item: '%s'/'%s'[%d] (%d) Type: %s | Extra Effect: %s
  6401. item_data->name,item_data->jname,item_data->slot,item_data->nameid,
  6402. (item_data->type != IT_AMMO) ? itemdb_typename((enum item_types)item_data->type) : itemdb_typename_ammo((enum e_item_ammo)item_data->look),
  6403. (item_data->script==NULL)? msg_txt(sd,1278) : msg_txt(sd,1279) // None / With script
  6404. );
  6405. clif_displaymessage(fd, atcmd_output);
  6406. 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
  6407. clif_displaymessage(fd, atcmd_output);
  6408. if (item_data->maxchance == -1)
  6409. strcpy(atcmd_output, msg_txt(sd,1281)); // - Available in the shops only.
  6410. else if (!battle_config.atcommand_mobinfo_type && item_data->maxchance)
  6411. sprintf(atcmd_output, msg_txt(sd,1282), (float)item_data->maxchance / 100 ); // - Maximal monsters drop chance: %02.02f%%
  6412. else
  6413. strcpy(atcmd_output, msg_txt(sd,1283)); // - Monsters don't drop this item.
  6414. clif_displaymessage(fd, atcmd_output);
  6415. }
  6416. return 0;
  6417. }
  6418. /*==========================================
  6419. * Show who drops the item.
  6420. *------------------------------------------*/
  6421. ACMD_FUNC(whodrops)
  6422. {
  6423. struct item_data *item_data, *item_array[MAX_SEARCH];
  6424. int i,j, count = 1;
  6425. if (!message || !*message) {
  6426. clif_displaymessage(fd, msg_txt(sd,1284)); // Please enter item name/ID (usage: @whodrops <item name/ID>).
  6427. return -1;
  6428. }
  6429. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  6430. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  6431. if (!count) {
  6432. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  6433. return -1;
  6434. }
  6435. if (count > MAX_SEARCH) {
  6436. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH, count); // Displaying first %d out of %d matches
  6437. clif_displaymessage(fd, atcmd_output);
  6438. count = MAX_SEARCH;
  6439. }
  6440. for (i = 0; i < count; i++) {
  6441. item_data = item_array[i];
  6442. sprintf(atcmd_output, msg_txt(sd,1285), item_data->jname, item_data->slot, item_data->nameid); // Item: '%s'[%d] (ID:%d)
  6443. clif_displaymessage(fd, atcmd_output);
  6444. if (item_data->mob[0].chance == 0) {
  6445. strcpy(atcmd_output, msg_txt(sd,1286)); // - Item is not dropped by mobs.
  6446. clif_displaymessage(fd, atcmd_output);
  6447. } else {
  6448. sprintf(atcmd_output, msg_txt(sd,1287), MAX_SEARCH); // - Common mobs with highest drop chance (only max %d are listed):
  6449. clif_displaymessage(fd, atcmd_output);
  6450. for (j=0; j < MAX_SEARCH && item_data->mob[j].chance > 0; j++)
  6451. {
  6452. int dropchance = item_data->mob[j].chance;
  6453. #ifdef RENEWAL_DROP
  6454. if( battle_config.atcommand_mobinfo_type )
  6455. dropchance = dropchance * pc_level_penalty_mod(sd, mob_db(item_data->mob[j].id)->lv, mob_db(item_data->mob[j].id)->status.class_, 2) / 100;
  6456. #endif
  6457. #ifdef VIP_ENABLE
  6458. // Display item rate increase for VIP.
  6459. if (pc_isvip(sd) && battle_config.vip_drop_increase)
  6460. dropchance += battle_config.vip_drop_increase;
  6461. #endif
  6462. sprintf(atcmd_output, "- %s (%02.02f%%)", mob_db(item_data->mob[j].id)->jname, dropchance/100.);
  6463. clif_displaymessage(fd, atcmd_output);
  6464. }
  6465. }
  6466. }
  6467. return 0;
  6468. }
  6469. ACMD_FUNC(whereis)
  6470. {
  6471. struct mob_db *mob_array[MAX_SEARCH];
  6472. int count;
  6473. int i, j, k;
  6474. if (!message || !*message) {
  6475. clif_displaymessage(fd, msg_txt(sd,1288)); // Please enter a monster name/ID (usage: @whereis <monster_name_or_monster_ID>).
  6476. return -1;
  6477. }
  6478. // If monster identifier/name argument is a name
  6479. if ((i = mobdb_checkid(atoi(message))))
  6480. {
  6481. mob_array[0] = mob_db(i);
  6482. count = 1;
  6483. } else
  6484. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  6485. if (!count) {
  6486. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  6487. return -1;
  6488. }
  6489. if (count > MAX_SEARCH) {
  6490. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH, count);
  6491. clif_displaymessage(fd, atcmd_output);
  6492. count = MAX_SEARCH;
  6493. }
  6494. for (k = 0; k < count; k++) {
  6495. struct mob_db *mob = mob_array[k];
  6496. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1289), mob->jname); // %s spawns in:
  6497. clif_displaymessage(fd, atcmd_output);
  6498. for (i = 0; i < ARRAYLENGTH(mob->spawn) && mob->spawn[i].qty; i++)
  6499. {
  6500. j = map_mapindex2mapid(mob->spawn[i].mapindex);
  6501. if (j < 0) continue;
  6502. snprintf(atcmd_output, sizeof atcmd_output, "%s (%d)", map[j].name, mob->spawn[i].qty);
  6503. clif_displaymessage(fd, atcmd_output);
  6504. }
  6505. if (i == 0)
  6506. clif_displaymessage(fd, msg_txt(sd,1290)); // This monster does not spawn normally.
  6507. }
  6508. return 0;
  6509. }
  6510. ACMD_FUNC(version)
  6511. {
  6512. pc_show_version(sd);
  6513. return 0;
  6514. }
  6515. /*==========================================
  6516. * @mutearea by MouseJstr
  6517. *------------------------------------------*/
  6518. static int atcommand_mutearea_sub(struct block_list *bl,va_list ap)
  6519. {
  6520. int time, id;
  6521. struct map_session_data *pl_sd = (struct map_session_data *)bl;
  6522. if (pl_sd == NULL)
  6523. return 0;
  6524. id = va_arg(ap, int);
  6525. time = va_arg(ap, int);
  6526. if (id != bl->id && !pc_get_group_level(pl_sd)) {
  6527. pl_sd->status.manner -= time;
  6528. if (pl_sd->status.manner < 0)
  6529. sc_start(NULL,&pl_sd->bl,SC_NOCHAT,100,0,0);
  6530. else
  6531. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  6532. }
  6533. return 0;
  6534. }
  6535. ACMD_FUNC(mutearea)
  6536. {
  6537. int time;
  6538. nullpo_ret(sd);
  6539. if (!message || !*message) {
  6540. clif_displaymessage(fd, msg_txt(sd,1297)); // Please enter a time in minutes (usage: @mutearea/@stfu <time in minutes>).
  6541. return -1;
  6542. }
  6543. time = atoi(message);
  6544. map_foreachinarea(atcommand_mutearea_sub,sd->bl.m,
  6545. sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE,
  6546. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time);
  6547. return 0;
  6548. }
  6549. ACMD_FUNC(rates)
  6550. {
  6551. char buf[CHAT_SIZE_MAX];
  6552. int base_exp_rate = 0, job_exp_rate = 0, item_rate = 0;
  6553. nullpo_ret(sd);
  6554. memset(buf, '\0', sizeof(buf));
  6555. #ifdef VIP_ENABLE
  6556. // Display EXP and item rate increase for VIP.
  6557. if (pc_isvip(sd) && (battle_config.vip_base_exp_increase || battle_config.vip_job_exp_increase || battle_config.vip_drop_increase)) {
  6558. base_exp_rate += battle_config.vip_base_exp_increase;
  6559. job_exp_rate += battle_config.vip_job_exp_increase;
  6560. item_rate += battle_config.vip_drop_increase;
  6561. }
  6562. #endif
  6563. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1298), // Experience rates: Base %.2fx / Job %.2fx
  6564. (battle_config.base_exp_rate+base_exp_rate)/100., (battle_config.job_exp_rate+job_exp_rate)/100.);
  6565. clif_displaymessage(fd, buf);
  6566. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1299), // Normal Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  6567. (battle_config.item_rate_common+item_rate)/100., (battle_config.item_rate_heal+item_rate)/100., (battle_config.item_rate_use+item_rate)/100., (battle_config.item_rate_equip+item_rate)/100., (battle_config.item_rate_card+item_rate)/100.);
  6568. clif_displaymessage(fd, buf);
  6569. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1300), // Boss Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  6570. (battle_config.item_rate_common_boss+item_rate)/100., (battle_config.item_rate_heal_boss+item_rate)/100., (battle_config.item_rate_use_boss+item_rate)/100., (battle_config.item_rate_equip_boss+item_rate)/100., (battle_config.item_rate_card_boss+item_rate)/100.);
  6571. clif_displaymessage(fd, buf);
  6572. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1301), // Other Drop Rates: MvP %.2fx / Card-Based %.2fx / Treasure %.2fx
  6573. (battle_config.item_rate_mvp+item_rate)/100., (battle_config.item_rate_adddrop+item_rate)/100., (battle_config.item_rate_treasure+item_rate)/100.);
  6574. clif_displaymessage(fd, buf);
  6575. return 0;
  6576. }
  6577. /*==========================================
  6578. * @me by lordalfa
  6579. * => Displays the OUTPUT string on top of the Visible players Heads.
  6580. *------------------------------------------*/
  6581. ACMD_FUNC(me)
  6582. {
  6583. char tempmes[CHAT_SIZE_MAX];
  6584. nullpo_retr(-1, sd);
  6585. memset(tempmes, '\0', sizeof(tempmes));
  6586. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6587. if (sd->sc.cant.chat)
  6588. return -1; //no "chatting" while muted.
  6589. if (!message || !*message || sscanf(message, "%199[^\n]", tempmes) < 0) {
  6590. clif_displaymessage(fd, msg_txt(sd,1302)); // Please enter a message (usage: @me <message>).
  6591. return -1;
  6592. }
  6593. sprintf(atcmd_output, msg_txt(sd,270), sd->status.name, tempmes); // *%s %s*
  6594. clif_disp_overhead(&sd->bl, atcmd_output);
  6595. return 0;
  6596. }
  6597. /*==========================================
  6598. * @size
  6599. * => Resize your character sprite. [Valaris]
  6600. *------------------------------------------*/
  6601. ACMD_FUNC(size)
  6602. {
  6603. int size = 0;
  6604. nullpo_retr(-1, sd);
  6605. size = cap_value(atoi(message),SZ_SMALL,SZ_BIG);
  6606. if(sd->state.size) {
  6607. sd->state.size = SZ_SMALL;
  6608. pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_TELEPORT);
  6609. }
  6610. sd->state.size = size;
  6611. if( size == SZ_MEDIUM )
  6612. clif_specialeffect(&sd->bl,420,AREA);
  6613. else if( size == SZ_BIG )
  6614. clif_specialeffect(&sd->bl,422,AREA);
  6615. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  6616. return 0;
  6617. }
  6618. ACMD_FUNC(sizeall)
  6619. {
  6620. int size;
  6621. struct map_session_data *pl_sd;
  6622. struct s_mapiterator* iter;
  6623. size = atoi(message);
  6624. size = cap_value(size,0,2);
  6625. iter = mapit_getallusers();
  6626. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) {
  6627. if( pl_sd->state.size != size ) {
  6628. if( pl_sd->state.size ) {
  6629. pl_sd->state.size = SZ_SMALL;
  6630. pc_setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  6631. }
  6632. pl_sd->state.size = size;
  6633. if( size == SZ_MEDIUM )
  6634. clif_specialeffect(&pl_sd->bl,420,AREA);
  6635. else if( size == SZ_BIG )
  6636. clif_specialeffect(&pl_sd->bl,422,AREA);
  6637. }
  6638. }
  6639. mapit_free(iter);
  6640. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  6641. return 0;
  6642. }
  6643. ACMD_FUNC(sizeguild)
  6644. {
  6645. int size = 0, i;
  6646. char guild[NAME_LENGTH];
  6647. struct map_session_data *pl_sd;
  6648. struct guild *g;
  6649. nullpo_retr(-1, sd);
  6650. memset(guild, '\0', sizeof(guild));
  6651. if( !message || !*message || sscanf(message, "%d %23[^\n]", &size, guild) < 2 ) {
  6652. clif_displaymessage(fd, msg_txt(sd,1304)); // Please enter guild name/ID (usage: @sizeguild <size> <guild name/ID>).
  6653. return -1;
  6654. }
  6655. if( (g = guild_searchname(guild)) == NULL && (g = guild_search(atoi(guild))) == NULL ) {
  6656. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  6657. return -1;
  6658. }
  6659. size = cap_value(size,SZ_SMALL,SZ_BIG);
  6660. for( i = 0; i < g->max_member; i++ ) {
  6661. if( (pl_sd = g->member[i].sd) && pl_sd->state.size != size ) {
  6662. if( pl_sd->state.size ) {
  6663. pl_sd->state.size = SZ_SMALL;
  6664. pc_setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  6665. }
  6666. pl_sd->state.size = size;
  6667. if( size == SZ_MEDIUM )
  6668. clif_specialeffect(&pl_sd->bl,420,AREA);
  6669. else if( size == SZ_BIG )
  6670. clif_specialeffect(&pl_sd->bl,422,AREA);
  6671. }
  6672. }
  6673. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  6674. return 0;
  6675. }
  6676. /*==========================================
  6677. * @monsterignore
  6678. * => Makes monsters ignore you. [Valaris]
  6679. *------------------------------------------*/
  6680. ACMD_FUNC(monsterignore)
  6681. {
  6682. nullpo_retr(-1, sd);
  6683. if (!sd->state.monster_ignore) {
  6684. sd->state.monster_ignore = 1;
  6685. clif_displaymessage(sd->fd, msg_txt(sd,1305)); // You are now immune to attacks.
  6686. } else {
  6687. sd->state.monster_ignore = 0;
  6688. clif_displaymessage(sd->fd, msg_txt(sd,1306)); // Returned to normal state.
  6689. }
  6690. return 0;
  6691. }
  6692. /*==========================================
  6693. * @fakename
  6694. * => Gives your character a fake name. [Valaris]
  6695. *------------------------------------------*/
  6696. ACMD_FUNC(fakename)
  6697. {
  6698. nullpo_retr(-1, sd);
  6699. if( !message || !*message )
  6700. {
  6701. if( sd->fakename[0] )
  6702. {
  6703. sd->fakename[0] = '\0';
  6704. clif_charnameack(0, &sd->bl);
  6705. clif_displaymessage(sd->fd, msg_txt(sd,1307)); // Returned to real name.
  6706. return 0;
  6707. }
  6708. clif_displaymessage(sd->fd, msg_txt(sd,1308)); // You must enter a name.
  6709. return -1;
  6710. }
  6711. if( strlen(message) < 2 )
  6712. {
  6713. clif_displaymessage(sd->fd, msg_txt(sd,1309)); // Fake name must be at least two characters.
  6714. return -1;
  6715. }
  6716. safestrncpy(sd->fakename, message, sizeof(sd->fakename));
  6717. clif_charnameack(0, &sd->bl);
  6718. clif_displaymessage(sd->fd, msg_txt(sd,1310)); // Fake name enabled.
  6719. return 0;
  6720. }
  6721. /*==========================================
  6722. * Ragnarok Resources
  6723. *------------------------------------------*/
  6724. ACMD_FUNC(mapflag) {
  6725. #define checkflag( cmd ) if ( map[ sd->bl.m ].flag.cmd ) clif_displaymessage(sd->fd,#cmd)
  6726. #define setflag( cmd ) \
  6727. if ( strcmp( flag_name , #cmd ) == 0 ){\
  6728. map[ sd->bl.m ].flag.cmd = flag;\
  6729. sprintf(atcmd_output,"[ @mapflag ] %s flag has been set to %s value = %hd",#cmd,flag?"On":"Off",flag);\
  6730. clif_displaymessage(sd->fd,atcmd_output);\
  6731. return 0;\
  6732. }
  6733. char flag_name[100];
  6734. short flag=0,i;
  6735. nullpo_retr(-1, sd);
  6736. memset(flag_name, '\0', sizeof(flag_name));
  6737. if (!message || !*message || (sscanf(message, "%99s %hd", flag_name, &flag) < 1)) {
  6738. clif_displaymessage(sd->fd,msg_txt(sd,1311)); // Enabled Mapflags in this map:
  6739. clif_displaymessage(sd->fd,"----------------------------------");
  6740. checkflag(town); checkflag(autotrade); checkflag(allowks); checkflag(nomemo);
  6741. checkflag(noteleport); checkflag(noreturn); checkflag(monster_noteleport); checkflag(nosave);
  6742. checkflag(nobranch); checkflag(noexppenalty); checkflag(pvp); checkflag(pvp_noparty);
  6743. checkflag(pvp_noguild); checkflag(pvp_nightmaredrop); checkflag(pvp_nocalcrank); checkflag(gvg_castle);
  6744. checkflag(gvg); checkflag(gvg_dungeon); checkflag(gvg_noparty); checkflag(battleground);
  6745. checkflag(nozenypenalty); checkflag(notrade); checkflag(noskill); checkflag(nowarp);
  6746. checkflag(nowarpto); checkflag(noicewall); checkflag(snow); checkflag(clouds);
  6747. checkflag(clouds2); checkflag(fog); checkflag(fireworks); checkflag(sakura);
  6748. checkflag(leaves); checkflag(nogo); checkflag(nobaseexp); checkflag(nojobexp);
  6749. checkflag(nomobloot); checkflag(nomvploot); checkflag(nightenabled); checkflag(restricted);
  6750. checkflag(nodrop); checkflag(novending); checkflag(loadevent); checkflag(nochat);
  6751. checkflag(partylock); checkflag(guildlock); checkflag(reset); checkflag(chmautojoin);
  6752. checkflag(nousecart); checkflag(noitemconsumption); checkflag(nosumstarmiracle); checkflag(nomineeffect);
  6753. checkflag(nolockon); checkflag(notomb);
  6754. #ifdef ADJUST_SKILL_DAMAGE
  6755. checkflag(skill_damage);
  6756. #endif
  6757. clif_displaymessage(sd->fd," ");
  6758. clif_displaymessage(sd->fd,msg_txt(sd,1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On)
  6759. clif_displaymessage(sd->fd,msg_txt(sd,1313)); // Type "@mapflag available" to list the available mapflags.
  6760. return 1;
  6761. }
  6762. for (i = 0; flag_name[i]; i++) flag_name[i] = (char)tolower(flag_name[i]); //lowercase
  6763. setflag(town); setflag(autotrade); setflag(allowks); setflag(nomemo);
  6764. setflag(noteleport); setflag(noreturn); setflag(monster_noteleport); setflag(nosave);
  6765. setflag(nobranch); setflag(noexppenalty); setflag(pvp); setflag(pvp_noparty);
  6766. setflag(pvp_noguild); setflag(pvp_nightmaredrop); setflag(pvp_nocalcrank); setflag(gvg_castle);
  6767. setflag(gvg); setflag(gvg_dungeon); setflag(gvg_noparty); setflag(battleground);
  6768. setflag(nozenypenalty); setflag(notrade); setflag(noskill); setflag(nowarp);
  6769. setflag(nowarpto); setflag(noicewall); setflag(snow); setflag(clouds);
  6770. setflag(clouds2); setflag(fog); setflag(fireworks); setflag(sakura);
  6771. setflag(leaves); setflag(nogo); setflag(nobaseexp); setflag(nojobexp);
  6772. setflag(nomobloot); setflag(nomvploot); setflag(nightenabled); setflag(restricted);
  6773. setflag(nodrop); setflag(novending); setflag(loadevent); setflag(nochat);
  6774. setflag(partylock); setflag(guildlock); setflag(reset); setflag(chmautojoin);
  6775. setflag(nousecart); setflag(noitemconsumption); setflag(nosumstarmiracle); setflag(nomineeffect);
  6776. setflag(nolockon); setflag(notomb);
  6777. #ifdef ADJUST_SKILL_DAMAGE
  6778. setflag(skill_damage);
  6779. #endif
  6780. clif_displaymessage(sd->fd,msg_txt(sd,1314)); // Invalid flag name or flag.
  6781. clif_displaymessage(sd->fd,msg_txt(sd,1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On)
  6782. clif_displaymessage(sd->fd,msg_txt(sd,1315)); // Available Flags:
  6783. clif_displaymessage(sd->fd,"----------------------------------");
  6784. clif_displaymessage(sd->fd,"town, autotrade, allowks, nomemo, noteleport, noreturn, monster_noteleport, nosave,");
  6785. clif_displaymessage(sd->fd,"nobranch, noexppenalty, pvp, pvp_noparty, pvp_noguild, pvp_nightmaredrop,");
  6786. clif_displaymessage(sd->fd,"pvp_nocalcrank, gvg_castle, gvg, gvg_dungeon, gvg_noparty, battleground,");
  6787. clif_displaymessage(sd->fd,"nozenypenalty, notrade, noskill, nowarp, nowarpto, noicewall, snow, clouds, clouds2,");
  6788. clif_displaymessage(sd->fd,"fog, fireworks, sakura, leaves, nogo, nobaseexp, nojobexp, nomobloot, nomvploot,");
  6789. clif_displaymessage(sd->fd,"nightenabled, restricted, nodrop, novending, loadevent, nochat, partylock, guildlock,");
  6790. clif_displaymessage(sd->fd,"reset, chmautojoin, nousecart, noitemconsumption, nosumstarmiracle, nolockon, notomb");
  6791. #ifdef ADJUST_SKILL_DAMAGE
  6792. clif_displaymessage(sd->fd,"skill_damage");
  6793. #endif
  6794. #undef checkflag
  6795. #undef setflag
  6796. return 0;
  6797. }
  6798. /*===================================
  6799. * Remove some messages
  6800. *-----------------------------------*/
  6801. ACMD_FUNC(showexp)
  6802. {
  6803. if (sd->state.showexp) {
  6804. sd->state.showexp = 0;
  6805. clif_displaymessage(fd, msg_txt(sd,1316)); // Gained exp will not be shown.
  6806. return 0;
  6807. }
  6808. sd->state.showexp = 1;
  6809. clif_displaymessage(fd, msg_txt(sd,1317)); // Gained exp is now shown.
  6810. return 0;
  6811. }
  6812. ACMD_FUNC(showzeny)
  6813. {
  6814. if (sd->state.showzeny) {
  6815. sd->state.showzeny = 0;
  6816. clif_displaymessage(fd, msg_txt(sd,1318)); // Gained zeny will not be shown.
  6817. return 0;
  6818. }
  6819. sd->state.showzeny = 1;
  6820. clif_displaymessage(fd, msg_txt(sd,1319)); // Gained zeny is now shown.
  6821. return 0;
  6822. }
  6823. ACMD_FUNC(showdelay)
  6824. {
  6825. if (sd->state.showdelay) {
  6826. sd->state.showdelay = 0;
  6827. clif_displaymessage(fd, msg_txt(sd,1320)); // Skill delay failures will not be shown.
  6828. return 0;
  6829. }
  6830. sd->state.showdelay = 1;
  6831. clif_displaymessage(fd, msg_txt(sd,1321)); // Skill delay failures are now shown.
  6832. return 0;
  6833. }
  6834. /*==========================================
  6835. * Duel organizing functions [LuzZza]
  6836. *
  6837. * @duel [limit|nick] - create a duel
  6838. * @invite <nick> - invite player
  6839. * @accept - accept invitation
  6840. * @reject - reject invitation
  6841. * @leave - leave duel
  6842. *------------------------------------------*/
  6843. ACMD_FUNC(invite)
  6844. {
  6845. unsigned int did = sd->duel_group;
  6846. struct map_session_data *target_sd = map_nick2sd((char *)message);
  6847. if(did == 0) {
  6848. // "Duel: @invite without @duel."
  6849. clif_displaymessage(fd, msg_txt(sd,350));
  6850. return 0;
  6851. }
  6852. if(duel_list[did].max_players_limit > 0 &&
  6853. duel_list[did].members_count >= duel_list[did].max_players_limit) {
  6854. // "Duel: Limit of players is reached."
  6855. clif_displaymessage(fd, msg_txt(sd,351));
  6856. return 0;
  6857. }
  6858. if(target_sd == NULL) {
  6859. // "Duel: Player not found."
  6860. clif_displaymessage(fd, msg_txt(sd,352));
  6861. return 0;
  6862. }
  6863. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  6864. // "Duel: Player already in duel."
  6865. clif_displaymessage(fd, msg_txt(sd,353));
  6866. return 0;
  6867. }
  6868. if(battle_config.duel_only_on_same_map && target_sd->bl.m != sd->bl.m)
  6869. {
  6870. sprintf(atcmd_output, msg_txt(sd,364), message);
  6871. clif_displaymessage(fd, atcmd_output);
  6872. return 0;
  6873. }
  6874. duel_invite(did, sd, target_sd);
  6875. // "Duel: Invitation has been sent."
  6876. clif_displaymessage(fd, msg_txt(sd,354));
  6877. return 0;
  6878. }
  6879. ACMD_FUNC(duel)
  6880. {
  6881. unsigned int maxpl = 0;
  6882. if(sd->duel_group > 0) {
  6883. duel_showinfo(sd->duel_group, sd);
  6884. return 0;
  6885. }
  6886. if(sd->duel_invite > 0) {
  6887. // "Duel: @duel without @reject."
  6888. clif_displaymessage(fd, msg_txt(sd,355));
  6889. return 0;
  6890. }
  6891. if(!duel_checktime(sd)) {
  6892. char output[CHAT_SIZE_MAX];
  6893. // "Duel: You can take part in duel only one time per %d minutes."
  6894. sprintf(output, msg_txt(sd,356), battle_config.duel_time_interval);
  6895. clif_displaymessage(fd, output);
  6896. return 0;
  6897. }
  6898. if( message[0] ) {
  6899. if(sscanf(message, "%u", &maxpl) >= 1) {
  6900. if(maxpl < 2 || maxpl > 65535) {
  6901. clif_displaymessage(fd, msg_txt(sd,357)); // "Duel: Invalid value."
  6902. return 0;
  6903. }
  6904. duel_create(sd, maxpl);
  6905. } else {
  6906. struct map_session_data *target_sd;
  6907. target_sd = map_nick2sd((char *)message);
  6908. if(target_sd != NULL) {
  6909. unsigned int newduel;
  6910. if((newduel = duel_create(sd, 2)) != -1) {
  6911. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  6912. clif_displaymessage(fd, msg_txt(sd,353)); // "Duel: Player already in duel."
  6913. return 0;
  6914. }
  6915. duel_invite(newduel, sd, target_sd);
  6916. clif_displaymessage(fd, msg_txt(sd,354)); // "Duel: Invitation has been sent."
  6917. }
  6918. } else {
  6919. // "Duel: Player not found."
  6920. clif_displaymessage(fd, msg_txt(sd,352));
  6921. return 0;
  6922. }
  6923. }
  6924. } else
  6925. duel_create(sd, 0);
  6926. return 0;
  6927. }
  6928. ACMD_FUNC(leave)
  6929. {
  6930. if(sd->duel_group <= 0) {
  6931. // "Duel: @leave without @duel."
  6932. clif_displaymessage(fd, msg_txt(sd,358));
  6933. return 0;
  6934. }
  6935. duel_leave(sd->duel_group, sd);
  6936. clif_displaymessage(fd, msg_txt(sd,359)); // "Duel: You left the duel."
  6937. return 0;
  6938. }
  6939. ACMD_FUNC(accept)
  6940. {
  6941. if(!duel_checktime(sd)) {
  6942. char output[CHAT_SIZE_MAX];
  6943. // "Duel: You can take part in duel only one time per %d minutes."
  6944. sprintf(output, msg_txt(sd,356), battle_config.duel_time_interval);
  6945. clif_displaymessage(fd, output);
  6946. return 0;
  6947. }
  6948. if(sd->duel_invite <= 0) {
  6949. // "Duel: @accept without invititation."
  6950. clif_displaymessage(fd, msg_txt(sd,360));
  6951. return 0;
  6952. }
  6953. if( duel_list[sd->duel_invite].max_players_limit > 0 && duel_list[sd->duel_invite].members_count >= duel_list[sd->duel_invite].max_players_limit )
  6954. {
  6955. // "Duel: Limit of players is reached."
  6956. clif_displaymessage(fd, msg_txt(sd,351));
  6957. return 0;
  6958. }
  6959. duel_accept(sd->duel_invite, sd);
  6960. // "Duel: Invitation has been accepted."
  6961. clif_displaymessage(fd, msg_txt(sd,361));
  6962. return 0;
  6963. }
  6964. ACMD_FUNC(reject)
  6965. {
  6966. if(sd->duel_invite <= 0) {
  6967. // "Duel: @reject without invititation."
  6968. clif_displaymessage(fd, msg_txt(sd,362));
  6969. return 0;
  6970. }
  6971. duel_reject(sd->duel_invite, sd);
  6972. // "Duel: Invitation has been rejected."
  6973. clif_displaymessage(fd, msg_txt(sd,363));
  6974. return 0;
  6975. }
  6976. /*===================================
  6977. * Cash Points
  6978. *-----------------------------------*/
  6979. ACMD_FUNC(cash)
  6980. {
  6981. char output[128];
  6982. int value;
  6983. int ret=0;
  6984. nullpo_retr(-1, sd);
  6985. if( !message || !*message || (value = atoi(message)) == 0 ) {
  6986. clif_displaymessage(fd, msg_txt(sd,1322)); // Please enter an amount.
  6987. return -1;
  6988. }
  6989. if( !strcmpi(command+1,"cash") )
  6990. {
  6991. if( value > 0 ) {
  6992. if( (ret=pc_getcash(sd, value, 0, LOG_TYPE_COMMAND)) >= 0){
  6993. // If this option is set, the message is already sent by pc function
  6994. if( !battle_config.cashshop_show_points ){
  6995. sprintf(output, msg_txt(sd,505), ret, sd->cashPoints);
  6996. clif_disp_onlyself(sd, output, strlen(output));
  6997. }
  6998. }
  6999. else clif_displaymessage(fd, msg_txt(sd,149)); // Unable to decrease the number/value.
  7000. } else {
  7001. if (-value > sd->cashPoints) //By command, if cash < value, force it to remove all
  7002. value = -sd->cashPoints;
  7003. if( (ret=pc_paycash(sd, -value, 0, LOG_TYPE_COMMAND)) >= 0){
  7004. // If this option is set, the message is already sent by pc function
  7005. if( !battle_config.cashshop_show_points ){
  7006. sprintf(output, msg_txt(sd,410), ret, sd->cashPoints);
  7007. clif_disp_onlyself(sd, output, strlen(output));
  7008. }
  7009. }
  7010. else clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  7011. }
  7012. }
  7013. else
  7014. { // @points
  7015. if( value > 0 ) {
  7016. if( (ret=pc_getcash(sd, 0, value, LOG_TYPE_COMMAND)) >= 0){
  7017. sprintf(output, msg_txt(sd,506), ret, sd->kafraPoints);
  7018. clif_disp_onlyself(sd, output, strlen(output));
  7019. }
  7020. else clif_displaymessage(fd, msg_txt(sd,149)); // Unable to decrease the number/value.
  7021. } else {
  7022. if( (ret=pc_paycash(sd, -value, -value, LOG_TYPE_COMMAND)) >= 0){
  7023. sprintf(output, msg_txt(sd,411), ret, sd->kafraPoints);
  7024. clif_disp_onlyself(sd, output, strlen(output));
  7025. }
  7026. else clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  7027. }
  7028. }
  7029. return 0;
  7030. }
  7031. // @clone/@slaveclone/@evilclone <playername> [Valaris]
  7032. ACMD_FUNC(clone)
  7033. {
  7034. int x=0,y=0,flag=0,master=0,i=0;
  7035. struct map_session_data *pl_sd=NULL;
  7036. if (!message || !*message) {
  7037. clif_displaymessage(sd->fd,msg_txt(sd,1323)); // You must enter a player name or ID.
  7038. return 0;
  7039. }
  7040. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL) {
  7041. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  7042. return 0;
  7043. }
  7044. if(pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  7045. clif_displaymessage(fd, msg_txt(sd,126)); // Cannot clone a player of higher GM level than yourself.
  7046. return 0;
  7047. }
  7048. if (strcmpi(command+1, "clone") == 0)
  7049. flag = 1;
  7050. else if (strcmpi(command+1, "slaveclone") == 0) {
  7051. flag = 2;
  7052. if(pc_isdead(sd)){
  7053. clif_displaymessage(fd, msg_txt(sd,129+flag*2));
  7054. return 0;
  7055. }
  7056. master = sd->bl.id;
  7057. if (battle_config.atc_slave_clone_limit
  7058. && mob_countslave(&sd->bl) >= battle_config.atc_slave_clone_limit) {
  7059. clif_displaymessage(fd, msg_txt(sd,127)); // You've reached your slave clones limit.
  7060. return 0;
  7061. }
  7062. }
  7063. do {
  7064. x = sd->bl.x + (rnd() % 10 - 5);
  7065. y = sd->bl.y + (rnd() % 10 - 5);
  7066. } while (map_getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10);
  7067. if (i >= 10) {
  7068. x = sd->bl.x;
  7069. y = sd->bl.y;
  7070. }
  7071. if((x = mob_clone_spawn(pl_sd, sd->bl.m, x, y, "", master, 0, flag?1:0, 0)) > 0) {
  7072. clif_displaymessage(fd, msg_txt(sd,128+flag*2)); // Evil Clone spawned. Clone spawned. Slave clone spawned.
  7073. return 0;
  7074. }
  7075. clif_displaymessage(fd, msg_txt(sd,129+flag*2)); // Unable to spawn evil clone. Unable to spawn clone. Unable to spawn slave clone.
  7076. return 0;
  7077. }
  7078. /*=====================================
  7079. * Autorejecting Invites/Deals [LuzZza]
  7080. * Usage: @noask
  7081. *-------------------------------------*/
  7082. ACMD_FUNC(noask)
  7083. {
  7084. if(sd->state.noask) {
  7085. clif_displaymessage(fd, msg_txt(sd,391)); // Autorejecting is deactivated.
  7086. sd->state.noask = 0;
  7087. } else {
  7088. clif_displaymessage(fd, msg_txt(sd,390)); // Autorejecting is activated.
  7089. sd->state.noask = 1;
  7090. }
  7091. return 0;
  7092. }
  7093. /*=====================================
  7094. * Send a @request message to all GMs of lowest_gm_level.
  7095. * Usage: @request <petition>
  7096. *-------------------------------------*/
  7097. ACMD_FUNC(request)
  7098. {
  7099. if (!message || !*message) {
  7100. clif_displaymessage(sd->fd,msg_txt(sd,277)); // Usage: @request <petition/message to online GMs>.
  7101. return -1;
  7102. }
  7103. sprintf(atcmd_output, msg_txt(sd,278), message); // (@request): %s
  7104. intif_wis_message_to_gm(sd->status.name, PC_PERM_RECEIVE_REQUESTS, atcmd_output);
  7105. clif_disp_onlyself(sd, atcmd_output, strlen(atcmd_output));
  7106. clif_displaymessage(sd->fd,msg_txt(sd,279)); // @request sent.
  7107. return 0;
  7108. }
  7109. /*==========================================
  7110. * Feel (SG save map) Reset [HiddenDragon]
  7111. *------------------------------------------*/
  7112. ACMD_FUNC(feelreset)
  7113. {
  7114. pc_resetfeel(sd);
  7115. clif_displaymessage(fd, msg_txt(sd,1324)); // Reset 'Feeling' maps.
  7116. return 0;
  7117. }
  7118. /*==========================================
  7119. * AUCTION SYSTEM
  7120. *------------------------------------------*/
  7121. ACMD_FUNC(auction)
  7122. {
  7123. nullpo_ret(sd);
  7124. if (!battle_config.feature_auction) {
  7125. clif_colormes(sd, color_table[COLOR_RED], msg_txt(517));
  7126. return 0;
  7127. }
  7128. clif_Auction_openwindow(sd);
  7129. return 0;
  7130. }
  7131. /*==========================================
  7132. * Kill Steal Protection
  7133. *------------------------------------------*/
  7134. ACMD_FUNC(ksprotection)
  7135. {
  7136. nullpo_retr(-1,sd);
  7137. if( sd->state.noks ) {
  7138. sd->state.noks = 0;
  7139. clif_displaymessage(fd, msg_txt(sd,1325)); // [ K.S Protection Inactive ]
  7140. }
  7141. else
  7142. {
  7143. if( !message || !*message || !strcmpi(message, "party") )
  7144. { // Default is Party
  7145. sd->state.noks = 2;
  7146. clif_displaymessage(fd, msg_txt(sd,1326)); // [ K.S Protection Active - Option: Party ]
  7147. }
  7148. else if( !strcmpi(message, "self") )
  7149. {
  7150. sd->state.noks = 1;
  7151. clif_displaymessage(fd, msg_txt(sd,1327)); // [ K.S Protection Active - Option: Self ]
  7152. }
  7153. else if( !strcmpi(message, "guild") )
  7154. {
  7155. sd->state.noks = 3;
  7156. clif_displaymessage(fd, msg_txt(sd,1328)); // [ K.S Protection Active - Option: Guild ]
  7157. }
  7158. else
  7159. clif_displaymessage(fd, msg_txt(sd,1329)); // Usage: @noks <self|party|guild>
  7160. }
  7161. return 0;
  7162. }
  7163. /*==========================================
  7164. * Map Kill Steal Protection Setting
  7165. *------------------------------------------*/
  7166. ACMD_FUNC(allowks)
  7167. {
  7168. nullpo_retr(-1,sd);
  7169. if( map[sd->bl.m].flag.allowks ) {
  7170. map[sd->bl.m].flag.allowks = 0;
  7171. clif_displaymessage(fd, msg_txt(sd,1330)); // [ Map K.S Protection Active ]
  7172. } else {
  7173. map[sd->bl.m].flag.allowks = 1;
  7174. clif_displaymessage(fd, msg_txt(sd,1331)); // [ Map K.S Protection Inactive ]
  7175. }
  7176. return 0;
  7177. }
  7178. ACMD_FUNC(resetstat)
  7179. {
  7180. nullpo_retr(-1, sd);
  7181. pc_resetstate(sd);
  7182. sprintf(atcmd_output, msg_txt(sd,207), sd->status.name);
  7183. clif_displaymessage(fd, atcmd_output);
  7184. return 0;
  7185. }
  7186. ACMD_FUNC(resetskill)
  7187. {
  7188. nullpo_retr(-1,sd);
  7189. pc_resetskill(sd,1);
  7190. sprintf(atcmd_output, msg_txt(sd,206), sd->status.name);
  7191. clif_displaymessage(fd, atcmd_output);
  7192. return 0;
  7193. }
  7194. /*==========================================
  7195. * #storagelist: Displays the items list of a player's storage.
  7196. * #cartlist: Displays contents of target's cart.
  7197. * #itemlist: Displays contents of target's inventory.
  7198. *------------------------------------------*/
  7199. ACMD_FUNC(itemlist)
  7200. {
  7201. int i, j, count, counter;
  7202. const char* location;
  7203. const struct item* items;
  7204. int size;
  7205. StringBuf buf;
  7206. nullpo_retr(-1, sd);
  7207. if( strcmp(command+1, "storagelist") == 0 )
  7208. {
  7209. location = "storage";
  7210. items = sd->status.storage.items;
  7211. size = sd->storage_size;
  7212. }
  7213. else
  7214. if( strcmp(command+1, "cartlist") == 0 )
  7215. {
  7216. location = "cart";
  7217. items = sd->status.cart;
  7218. size = MAX_CART;
  7219. }
  7220. else
  7221. if( strcmp(command+1, "itemlist") == 0 )
  7222. {
  7223. location = "inventory";
  7224. items = sd->status.inventory;
  7225. size = MAX_INVENTORY;
  7226. }
  7227. else
  7228. return 1;
  7229. StringBuf_Init(&buf);
  7230. count = 0; // total slots occupied
  7231. counter = 0; // total items found
  7232. for( i = 0; i < size; ++i )
  7233. {
  7234. const struct item* it = &items[i];
  7235. struct item_data* itd;
  7236. if( it->nameid == 0 || (itd = itemdb_exists(it->nameid)) == NULL )
  7237. continue;
  7238. counter += it->amount;
  7239. count++;
  7240. if( count == 1 )
  7241. {
  7242. StringBuf_Printf(&buf, msg_txt(sd,1332), location, sd->status.name); // ------ %s items list of '%s' ------
  7243. clif_displaymessage(fd, StringBuf_Value(&buf));
  7244. StringBuf_Clear(&buf);
  7245. }
  7246. if( it->refine )
  7247. StringBuf_Printf(&buf, "%d %s %+d (%s, id: %d)", it->amount, itd->jname, it->refine, itd->name, it->nameid);
  7248. else
  7249. StringBuf_Printf(&buf, "%d %s (%s, id: %d)", it->amount, itd->jname, itd->name, it->nameid);
  7250. if( it->equip )
  7251. {
  7252. char equipstr[CHAT_SIZE_MAX];
  7253. strcpy(equipstr, msg_txt(sd,1333)); // | equipped:
  7254. if( it->equip & EQP_GARMENT )
  7255. strcat(equipstr, msg_txt(sd,1334)); // garment,
  7256. if( it->equip & EQP_ACC_L )
  7257. strcat(equipstr, msg_txt(sd,1335)); // left accessory,
  7258. if( it->equip & EQP_ARMOR )
  7259. strcat(equipstr, msg_txt(sd,1336)); // body/armor,
  7260. if( (it->equip & EQP_ARMS) == EQP_HAND_R )
  7261. strcat(equipstr, msg_txt(sd,1337)); // right hand,
  7262. if( (it->equip & EQP_ARMS) == EQP_HAND_L )
  7263. strcat(equipstr, msg_txt(sd,1338)); // left hand,
  7264. if( (it->equip & EQP_ARMS) == EQP_ARMS )
  7265. strcat(equipstr, msg_txt(sd,1339)); // both hands,
  7266. if( it->equip & EQP_SHOES )
  7267. strcat(equipstr, msg_txt(sd,1340)); // feet,
  7268. if( it->equip & EQP_ACC_R )
  7269. strcat(equipstr, msg_txt(sd,1341)); // right accessory,
  7270. if( (it->equip & EQP_HELM) == EQP_HEAD_LOW )
  7271. strcat(equipstr, msg_txt(sd,1342)); // lower head,
  7272. if( (it->equip & EQP_HELM) == EQP_HEAD_TOP )
  7273. strcat(equipstr, msg_txt(sd,1343)); // top head,
  7274. if( (it->equip & EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_TOP) )
  7275. strcat(equipstr, msg_txt(sd,1344)); // lower/top head,
  7276. if( (it->equip & EQP_HELM) == EQP_HEAD_MID )
  7277. strcat(equipstr, msg_txt(sd,1345)); // mid head,
  7278. if( (it->equip & EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_MID) )
  7279. strcat(equipstr, msg_txt(sd,1346)); // lower/mid head,
  7280. if( (it->equip & EQP_HELM) == EQP_HELM )
  7281. strcat(equipstr, msg_txt(sd,1347)); // lower/mid/top head,
  7282. // remove final ', '
  7283. equipstr[strlen(equipstr) - 2] = '\0';
  7284. StringBuf_AppendStr(&buf, equipstr);
  7285. }
  7286. clif_displaymessage(fd, StringBuf_Value(&buf));
  7287. StringBuf_Clear(&buf);
  7288. if( it->card[0] == CARD0_PET )
  7289. {// pet egg
  7290. if (it->card[3])
  7291. StringBuf_Printf(&buf, msg_txt(sd,1348), (unsigned int)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, named)
  7292. else
  7293. StringBuf_Printf(&buf, msg_txt(sd,1349), (unsigned int)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, unnamed)
  7294. }
  7295. else
  7296. if(it->card[0] == CARD0_FORGE)
  7297. {// forged item
  7298. 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)
  7299. }
  7300. else
  7301. if(it->card[0] == CARD0_CREATE)
  7302. {// created item
  7303. StringBuf_Printf(&buf, msg_txt(sd,1351), (unsigned int)MakeDWord(it->card[2], it->card[3])); // -> (produced item, creator id: %u)
  7304. }
  7305. else
  7306. {// normal item
  7307. int counter2 = 0;
  7308. for( j = 0; j < itd->slot; ++j )
  7309. {
  7310. struct item_data* card;
  7311. if( it->card[j] == 0 || (card = itemdb_exists(it->card[j])) == NULL )
  7312. continue;
  7313. counter2++;
  7314. if( counter2 == 1 )
  7315. StringBuf_AppendStr(&buf, msg_txt(sd,1352)); // -> (card(s):
  7316. if( counter2 != 1 )
  7317. StringBuf_AppendStr(&buf, ", ");
  7318. StringBuf_Printf(&buf, "#%d %s (id: %d)", counter2, card->jname, card->nameid);
  7319. }
  7320. if( counter2 > 0 )
  7321. StringBuf_AppendStr(&buf, ")");
  7322. }
  7323. if( StringBuf_Length(&buf) > 0 )
  7324. clif_displaymessage(fd, StringBuf_Value(&buf));
  7325. StringBuf_Clear(&buf);
  7326. }
  7327. if( count == 0 )
  7328. StringBuf_Printf(&buf, msg_txt(sd,1353), location); // No item found in this player's %s.
  7329. else
  7330. StringBuf_Printf(&buf, msg_txt(sd,1354), counter, count, location); // %d item(s) found in %d %s slots.
  7331. clif_displaymessage(fd, StringBuf_Value(&buf));
  7332. StringBuf_Destroy(&buf);
  7333. return 0;
  7334. }
  7335. ACMD_FUNC(stats)
  7336. {
  7337. char job_jobname[100];
  7338. char output[CHAT_SIZE_MAX];
  7339. int i;
  7340. struct {
  7341. const char* format;
  7342. int value;
  7343. } output_table[] = {
  7344. { "Base Level - %d", 0 },
  7345. { NULL, 0 },
  7346. { "Hp - %d", 0 },
  7347. { "MaxHp - %d", 0 },
  7348. { "Sp - %d", 0 },
  7349. { "MaxSp - %d", 0 },
  7350. { "Str - %3d", 0 },
  7351. { "Agi - %3d", 0 },
  7352. { "Vit - %3d", 0 },
  7353. { "Int - %3d", 0 },
  7354. { "Dex - %3d", 0 },
  7355. { "Luk - %3d", 0 },
  7356. { "Zeny - %d", 0 },
  7357. { "Free SK Points - %d", 0 },
  7358. { "JobChangeLvl (2nd) - %d", 0 },
  7359. { "JobChangeLvl (3rd) - %d", 0 },
  7360. { NULL, 0 }
  7361. };
  7362. memset(job_jobname, '\0', sizeof(job_jobname));
  7363. memset(output, '\0', sizeof(output));
  7364. //direct array initialization with variables is not standard C compliant.
  7365. output_table[0].value = sd->status.base_level;
  7366. output_table[1].format = job_jobname;
  7367. output_table[1].value = sd->status.job_level;
  7368. output_table[2].value = sd->status.hp;
  7369. output_table[3].value = sd->status.max_hp;
  7370. output_table[4].value = sd->status.sp;
  7371. output_table[5].value = sd->status.max_sp;
  7372. output_table[6].value = sd->status.str;
  7373. output_table[7].value = sd->status.agi;
  7374. output_table[8].value = sd->status.vit;
  7375. output_table[9].value = sd->status.int_;
  7376. output_table[10].value = sd->status.dex;
  7377. output_table[11].value = sd->status.luk;
  7378. output_table[12].value = sd->status.zeny;
  7379. output_table[13].value = sd->status.skill_point;
  7380. output_table[14].value = sd->change_level_2nd;
  7381. output_table[15].value = sd->change_level_3rd;
  7382. sprintf(job_jobname, "Job - %s %s", job_name(sd->status.class_), "(level %d)");
  7383. sprintf(output, msg_txt(sd,53), sd->status.name); // '%s' stats:
  7384. clif_displaymessage(fd, output);
  7385. for (i = 0; output_table[i].format != NULL; i++) {
  7386. sprintf(output, output_table[i].format, output_table[i].value);
  7387. clif_displaymessage(fd, output);
  7388. }
  7389. return 0;
  7390. }
  7391. ACMD_FUNC(delitem)
  7392. {
  7393. char item_name[100];
  7394. int nameid, amount = 0, total, idx;
  7395. struct item_data* id;
  7396. nullpo_retr(-1, sd);
  7397. if( !message || !*message || ( sscanf(message, "\"%99[^\"]\" %d", item_name, &amount) < 2 && sscanf(message, "%99s %d", item_name, &amount) < 2 ) || amount < 1 )
  7398. {
  7399. 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>).
  7400. return -1;
  7401. }
  7402. if( ( id = itemdb_searchname(item_name) ) != NULL || ( id = itemdb_exists(atoi(item_name)) ) != NULL )
  7403. {
  7404. nameid = id->nameid;
  7405. }
  7406. else
  7407. {
  7408. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  7409. return -1;
  7410. }
  7411. total = amount;
  7412. // delete items
  7413. while( amount && ( idx = pc_search_inventory(sd, nameid) ) != -1 )
  7414. {
  7415. int delamount = ( amount < sd->status.inventory[idx].amount ) ? amount : sd->status.inventory[idx].amount;
  7416. if( sd->inventory_data[idx]->type == IT_PETEGG && sd->status.inventory[idx].card[0] == CARD0_PET )
  7417. {// delete pet
  7418. intif_delete_petdata(MakeDWord(sd->status.inventory[idx].card[1], sd->status.inventory[idx].card[2]));
  7419. }
  7420. pc_delitem(sd, idx, delamount, 0, 0, LOG_TYPE_COMMAND);
  7421. amount-= delamount;
  7422. }
  7423. // notify target
  7424. sprintf(atcmd_output, msg_txt(sd,113), total-amount); // %d item(s) removed by a GM.
  7425. clif_displaymessage(sd->fd, atcmd_output);
  7426. // notify source
  7427. if( amount == total )
  7428. {
  7429. clif_displaymessage(fd, msg_txt(sd,116)); // Character does not have the item.
  7430. }
  7431. else if( amount )
  7432. {
  7433. sprintf(atcmd_output, msg_txt(sd,115), total-amount, total-amount, total); // %d item(s) removed. Player had only %d on %d items.
  7434. clif_displaymessage(fd, atcmd_output);
  7435. }
  7436. else
  7437. {
  7438. sprintf(atcmd_output, msg_txt(sd,114), total); // %d item(s) removed from the player.
  7439. clif_displaymessage(fd, atcmd_output);
  7440. }
  7441. return 0;
  7442. }
  7443. /*==========================================
  7444. * Custom Fonts
  7445. *------------------------------------------*/
  7446. ACMD_FUNC(font)
  7447. {
  7448. int font_id;
  7449. nullpo_retr(-1,sd);
  7450. font_id = atoi(message);
  7451. if( font_id == 0 )
  7452. {
  7453. if( sd->user_font )
  7454. {
  7455. sd->user_font = 0;
  7456. clif_displaymessage(fd, msg_txt(sd,1356)); // Returning to normal font.
  7457. clif_font(sd);
  7458. }
  7459. else
  7460. {
  7461. clif_displaymessage(fd, msg_txt(sd,1357)); // Use @font <1-9> to change your message font.
  7462. clif_displaymessage(fd, msg_txt(sd,1358)); // Use 0 or no parameter to return to normal font.
  7463. }
  7464. }
  7465. else if( font_id < 0 || font_id > 9 )
  7466. clif_displaymessage(fd, msg_txt(sd,1359)); // Invalid font. Use a value from 0 to 9.
  7467. else if( font_id != sd->user_font )
  7468. {
  7469. sd->user_font = font_id;
  7470. clif_font(sd);
  7471. clif_displaymessage(fd, msg_txt(sd,1360)); // Font changed.
  7472. }
  7473. else
  7474. clif_displaymessage(fd, msg_txt(sd,1361)); // Already using this font.
  7475. return 0;
  7476. }
  7477. /*==========================================
  7478. * type: 1 = commands (@), 2 = charcommands (#)
  7479. *------------------------------------------*/
  7480. static void atcommand_commands_sub(struct map_session_data* sd, const int fd, AtCommandType type)
  7481. {
  7482. char line_buff[CHATBOX_SIZE];
  7483. char* cur = line_buff;
  7484. AtCommandInfo* cmd;
  7485. DBIterator *iter = db_iterator(atcommand_db);
  7486. int count = 0;
  7487. memset(line_buff,' ',CHATBOX_SIZE);
  7488. line_buff[CHATBOX_SIZE-1] = 0;
  7489. clif_displaymessage(fd, msg_txt(sd,273)); // "Commands available:"
  7490. for (cmd = dbi_first(iter); dbi_exists(iter); cmd = dbi_next(iter)) {
  7491. unsigned int slen = 0;
  7492. switch( type ) {
  7493. case COMMAND_CHARCOMMAND:
  7494. if( cmd->char_groups[sd->group_pos] == 0 )
  7495. continue;
  7496. break;
  7497. case COMMAND_ATCOMMAND:
  7498. if( cmd->at_groups[sd->group_pos] == 0 )
  7499. continue;
  7500. break;
  7501. default:
  7502. continue;
  7503. }
  7504. slen = strlen(cmd->command);
  7505. // flush the text buffer if this command won't fit into it
  7506. if (slen + cur - line_buff >= CHATBOX_SIZE) {
  7507. clif_displaymessage(fd,line_buff);
  7508. cur = line_buff;
  7509. memset(line_buff,' ',CHATBOX_SIZE);
  7510. line_buff[CHATBOX_SIZE-1] = 0;
  7511. }
  7512. memcpy(cur,cmd->command,slen);
  7513. cur += slen+(10-slen%10);
  7514. count++;
  7515. }
  7516. dbi_destroy(iter);
  7517. clif_displaymessage(fd,line_buff);
  7518. if ( atcmd_binding_count ) {
  7519. int i, count_bind, gm_lvl = pc_get_group_level(sd);
  7520. for( i = count_bind = 0; i < atcmd_binding_count; i++ ) {
  7521. if ( gm_lvl >= ( (type - 1) ? atcmd_binding[i]->level2 : atcmd_binding[i]->level ) ) {
  7522. unsigned int slen = strlen(atcmd_binding[i]->command);
  7523. if ( count_bind == 0 ) {
  7524. cur = line_buff;
  7525. memset(line_buff,' ',CHATBOX_SIZE);
  7526. line_buff[CHATBOX_SIZE-1] = 0;
  7527. clif_displaymessage(fd, "-----------------");
  7528. clif_displaymessage(fd, msg_txt(sd,509)); // Script-bound commands:
  7529. }
  7530. if (slen + cur - line_buff >= CHATBOX_SIZE) {
  7531. clif_displaymessage(fd,line_buff);
  7532. cur = line_buff;
  7533. memset(line_buff,' ',CHATBOX_SIZE);
  7534. line_buff[CHATBOX_SIZE-1] = 0;
  7535. }
  7536. memcpy(cur,atcmd_binding[i]->command,slen);
  7537. cur += slen+(10-slen%10);
  7538. count_bind++;
  7539. }
  7540. }
  7541. if ( count_bind )
  7542. clif_displaymessage(fd,line_buff);// last one
  7543. count += count_bind;
  7544. }
  7545. sprintf(atcmd_output, msg_txt(sd,274), count); // "%d commands found."
  7546. clif_displaymessage(fd, atcmd_output);
  7547. return;
  7548. }
  7549. /*==========================================
  7550. * @commands Lists available @ commands to you
  7551. *------------------------------------------*/
  7552. ACMD_FUNC(commands)
  7553. {
  7554. atcommand_commands_sub(sd, fd, COMMAND_ATCOMMAND);
  7555. return 0;
  7556. }
  7557. /*==========================================
  7558. * @charcommands Lists available # commands to you
  7559. *------------------------------------------*/
  7560. ACMD_FUNC(charcommands) {
  7561. atcommand_commands_sub(sd, fd, COMMAND_CHARCOMMAND);
  7562. return 0;
  7563. }
  7564. /* for new mounts */
  7565. ACMD_FUNC(mount2) {
  7566. clif_displaymessage(sd->fd,msg_txt(sd,1362)); // NOTICE: If you crash with mount your LUA is outdated.
  7567. if (!&sd->sc || !(sd->sc.data[SC_ALL_RIDING])) {
  7568. clif_displaymessage(sd->fd,msg_txt(sd,1363)); // You have mounted.
  7569. sc_start(NULL, &sd->bl, SC_ALL_RIDING, 10000, 1, INVALID_TIMER);
  7570. } else {
  7571. clif_displaymessage(sd->fd,msg_txt(sd,1364)); // You have released your mount.
  7572. if (&sd->sc)
  7573. status_change_end(&sd->bl, SC_ALL_RIDING, INVALID_TIMER);
  7574. }
  7575. return 0;
  7576. }
  7577. ACMD_FUNC(accinfo) {
  7578. char query[NAME_LENGTH];
  7579. if (!message || !*message || strlen(message) > NAME_LENGTH ) {
  7580. clif_displaymessage(fd, msg_txt(sd,1365)); // Usage: @accinfo/@accountinfo <account_id/char name>
  7581. 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".
  7582. return -1;
  7583. }
  7584. //remove const type
  7585. safestrncpy(query, message, NAME_LENGTH);
  7586. intif_request_accinfo( sd->fd, sd->bl.id, pc_get_group_level(sd), query );
  7587. return 0;
  7588. }
  7589. /* [Ind] */
  7590. ACMD_FUNC(set) {
  7591. char reg[32], val[128];
  7592. struct script_data* data;
  7593. int toset = 0, len;
  7594. bool is_str = false;
  7595. if( !message || !*message || (toset = sscanf(message, "%31s %128[^\n]s", reg, val)) < 1 ) {
  7596. clif_displaymessage(fd, msg_txt(sd,1367)); // Usage: @set <variable name> <value>
  7597. clif_displaymessage(fd, msg_txt(sd,1368)); // Usage: ex. "@set PoringCharVar 50"
  7598. clif_displaymessage(fd, msg_txt(sd,1369)); // Usage: ex. "@set PoringCharVarSTR$ Super Duper String"
  7599. clif_displaymessage(fd, msg_txt(sd,1370)); // Usage: ex. "@set PoringCharVarSTR$" outputs its value, Super Duper String.
  7600. return -1;
  7601. }
  7602. /* disabled variable types (they require a proper script state to function, so allowing them would crash the server) */
  7603. if( reg[0] == '.' ) {
  7604. clif_displaymessage(fd, msg_txt(sd,1371)); // NPC variables may not be used with @set.
  7605. return -1;
  7606. } else if( reg[0] == '\'' ) {
  7607. clif_displaymessage(fd, msg_txt(sd,1372)); // Instance variables may not be used with @set.
  7608. return -1;
  7609. }
  7610. is_str = ( reg[strlen(reg) - 1] == '$' ) ? true : false;
  7611. if( ( len = strlen(val) ) > 1 ) {
  7612. if( val[0] == '"' && val[len-1] == '"') {
  7613. val[len-1] = '\0'; //Strip quotes.
  7614. memmove(val, val+1, len-1);
  7615. }
  7616. }
  7617. if( toset >= 2 ) {/* we only set the var if there is an val, otherwise we only output the value */
  7618. if( is_str )
  7619. set_var(sd, reg, (void*) val);
  7620. else
  7621. set_var(sd, reg, (void*)__64BPRTSIZE((atoi(val))));
  7622. }
  7623. CREATE(data, struct script_data,1);
  7624. if( is_str ) {// string variable
  7625. switch( reg[0] ) {
  7626. case '@':
  7627. data->u.str = pc_readregstr(sd, add_str(reg));
  7628. break;
  7629. case '$':
  7630. data->u.str = mapreg_readregstr(add_str(reg));
  7631. break;
  7632. case '#':
  7633. if( reg[1] == '#' )
  7634. data->u.str = pc_readaccountreg2str(sd, reg);// global
  7635. else
  7636. data->u.str = pc_readaccountregstr(sd, reg);// local
  7637. break;
  7638. default:
  7639. data->u.str = pc_readglobalreg_str(sd, reg);
  7640. break;
  7641. }
  7642. if( data->u.str == NULL || data->u.str[0] == '\0' ) {// empty string
  7643. data->type = C_CONSTSTR;
  7644. data->u.str = "";
  7645. } else {// duplicate string
  7646. data->type = C_STR;
  7647. data->u.str = aStrdup(data->u.str);
  7648. }
  7649. } else {// integer variable
  7650. data->type = C_INT;
  7651. switch( reg[0] ) {
  7652. case '@':
  7653. data->u.num = pc_readreg(sd, add_str(reg));
  7654. break;
  7655. case '$':
  7656. data->u.num = mapreg_readreg(add_str(reg));
  7657. break;
  7658. case '#':
  7659. if( reg[1] == '#' )
  7660. data->u.num = pc_readaccountreg2(sd, reg);// global
  7661. else
  7662. data->u.num = pc_readaccountreg(sd, reg);// local
  7663. break;
  7664. default:
  7665. data->u.num = pc_readglobalreg(sd, reg);
  7666. break;
  7667. }
  7668. }
  7669. switch( data->type ) {
  7670. case C_INT:
  7671. sprintf(atcmd_output,msg_txt(sd,1373),reg,data->u.num); // %s value is now :%d
  7672. break;
  7673. case C_STR:
  7674. sprintf(atcmd_output,msg_txt(sd,1374),reg,data->u.str); // %s value is now :%s
  7675. break;
  7676. case C_CONSTSTR:
  7677. sprintf(atcmd_output,msg_txt(sd,1375),reg); // %s is empty
  7678. break;
  7679. default:
  7680. sprintf(atcmd_output,msg_txt(sd,1376),reg,data->type); // %s data type is not supported :%u
  7681. break;
  7682. }
  7683. clif_displaymessage(fd, atcmd_output);
  7684. aFree(data);
  7685. return 0;
  7686. }
  7687. ACMD_FUNC(addperm) {
  7688. int perm_size = ARRAYLENGTH(pc_g_permission_name);
  7689. bool add = (strcmpi(command+1, "addperm") == 0) ? true : false;
  7690. int i;
  7691. if( !message || !*message ) {
  7692. sprintf(atcmd_output, msg_txt(sd,1378),command); // Usage: %s <permission_name>
  7693. clif_displaymessage(fd, atcmd_output);
  7694. clif_displaymessage(fd, msg_txt(sd,1379)); // -- Permission List
  7695. for( i = 0; i < perm_size; i++ ) {
  7696. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  7697. clif_displaymessage(fd, atcmd_output);
  7698. }
  7699. return -1;
  7700. }
  7701. ARR_FIND(0, perm_size, i, strcmpi(pc_g_permission_name[i].name, message) == 0);
  7702. if( i == perm_size ) {
  7703. sprintf(atcmd_output,msg_txt(sd,1380),message); // '%s' is not a known permission.
  7704. clif_displaymessage(fd, atcmd_output);
  7705. clif_displaymessage(fd, msg_txt(sd,1379)); // -- Permission List
  7706. for( i = 0; i < perm_size; i++ ) {
  7707. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  7708. clif_displaymessage(fd, atcmd_output);
  7709. }
  7710. return -1;
  7711. }
  7712. if( add && (sd->permissions&pc_g_permission_name[i].permission) ) {
  7713. sprintf(atcmd_output, msg_txt(sd,1381),sd->status.name,pc_g_permission_name[i].name); // User '%s' already possesses the '%s' permission.
  7714. clif_displaymessage(fd, atcmd_output);
  7715. return -1;
  7716. } else if ( !add && !(sd->permissions&pc_g_permission_name[i].permission) ) {
  7717. sprintf(atcmd_output, msg_txt(sd,1382),sd->status.name,pc_g_permission_name[i].name); // User '%s' doesn't possess the '%s' permission.
  7718. clif_displaymessage(fd, atcmd_output);
  7719. sprintf(atcmd_output,msg_txt(sd,1383),sd->status.name); // -- User '%s' Permissions
  7720. clif_displaymessage(fd, atcmd_output);
  7721. for( i = 0; i < perm_size; i++ ) {
  7722. if( sd->permissions&pc_g_permission_name[i].permission ) {
  7723. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  7724. clif_displaymessage(fd, atcmd_output);
  7725. }
  7726. }
  7727. return -1;
  7728. }
  7729. if( add )
  7730. sd->permissions |= pc_g_permission_name[i].permission;
  7731. else
  7732. sd->permissions &=~ pc_g_permission_name[i].permission;
  7733. sprintf(atcmd_output, msg_txt(sd,1384),sd->status.name); // User '%s' permissions updated successfully. The changes are temporary.
  7734. clif_displaymessage(fd, atcmd_output);
  7735. return 0;
  7736. }
  7737. ACMD_FUNC(unloadnpcfile) {
  7738. if( !message || !*message ) {
  7739. clif_displaymessage(fd, msg_txt(sd,1385)); // Usage: @unloadnpcfile <file name>
  7740. return -1;
  7741. }
  7742. if( npc_unloadfile(message) )
  7743. clif_displaymessage(fd, msg_txt(sd,1386)); // File unloaded. Be aware that mapflags and monsters spawned directly are not removed.
  7744. else {
  7745. clif_displaymessage(fd, msg_txt(sd,1387)); // File not found.
  7746. return -1;
  7747. }
  7748. return 0;
  7749. }
  7750. ACMD_FUNC(cart) {
  7751. #define MC_CART_MDFY(x) \
  7752. sd->status.skill[MC_PUSHCART].id = x?MC_PUSHCART:0; \
  7753. sd->status.skill[MC_PUSHCART].lv = x?1:0; \
  7754. sd->status.skill[MC_PUSHCART].flag = x?SKILL_FLAG_TEMPORARY:SKILL_FLAG_PERMANENT;
  7755. int val = atoi(message);
  7756. bool need_skill = pc_checkskill(sd, MC_PUSHCART) ? false : true;
  7757. if( !message || !*message || val < 0 || val > MAX_CARTS ) {
  7758. sprintf(atcmd_output, msg_txt(sd,1390),command,MAX_CARTS); // Unknown Cart (usage: %s <0-%d>).
  7759. clif_displaymessage(fd, atcmd_output);
  7760. return -1;
  7761. }
  7762. if( val == 0 && !pc_iscarton(sd) ) {
  7763. clif_displaymessage(fd, msg_txt(sd,1391)); // You do not possess a cart to be removed
  7764. return -1;
  7765. }
  7766. if( need_skill ) {
  7767. MC_CART_MDFY(1);
  7768. }
  7769. if( !pc_setcart(sd, val) ) {
  7770. if( need_skill ) {
  7771. MC_CART_MDFY(0);
  7772. }
  7773. return -1;/* @cart failed */
  7774. }
  7775. if( need_skill ) {
  7776. MC_CART_MDFY(0);
  7777. }
  7778. clif_displaymessage(fd, msg_txt(sd,1392)); // Cart Added
  7779. return 0;
  7780. #undef MC_CART_MDFY
  7781. }
  7782. /* Channel System [Ind] */
  7783. ACMD_FUNC(join){
  7784. char chname[CHAN_NAME_LENGTH], pass[CHAN_NAME_LENGTH];
  7785. if( !message || !*message || sscanf(message, "%19s %19s", chname, pass) < 1 ) {
  7786. sprintf(atcmd_output, msg_txt(sd,1399),command); // Unknown channel (usage: %s <#channel_name>).
  7787. clif_displaymessage(fd, atcmd_output);
  7788. return -1;
  7789. }
  7790. return channel_pcjoin(sd, chname, pass);
  7791. }
  7792. /*
  7793. * Display available option for @channel command
  7794. * @command : the name of used command (for alias case)
  7795. */
  7796. static inline void atcmd_channel_help(struct map_session_data *sd, const char *command)
  7797. {
  7798. int fd = sd->fd;
  7799. bool can_delete = pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN);
  7800. bool can_create = (can_delete || Channel_Config.user_chenable);
  7801. clif_displaymessage(fd, msg_txt(sd,1414));// ---- Available options:
  7802. //option create
  7803. if( can_create ) {
  7804. sprintf(atcmd_output, msg_txt(sd,1415),command);// * %s create <#channel_name> <channel_password>
  7805. clif_displaymessage(fd, atcmd_output);
  7806. clif_displaymessage(fd, msg_txt(sd,1416));// -- Creates a new channel.
  7807. }
  7808. //option delete
  7809. if(can_delete){
  7810. sprintf(atcmd_output, msg_txt(sd,1469),command);// * %s delete <#channel_name>
  7811. clif_displaymessage(fd, atcmd_output);
  7812. clif_displaymessage(fd, msg_txt(sd,1470)); // -- Destroys the specified channel.
  7813. }
  7814. //option list
  7815. sprintf(atcmd_output, msg_txt(sd,1417),command);// * %s list
  7816. clif_displaymessage(fd, atcmd_output);
  7817. clif_displaymessage(fd, msg_txt(sd,1418));// -- Lists all public channels.
  7818. sprintf(atcmd_output, msg_txt(sd,1471),command);// * %s list mine
  7819. clif_displaymessage(fd, atcmd_output);
  7820. clif_displaymessage(fd, msg_txt(sd,1472));// -- Lists all channels you have joined.
  7821. if( can_create ) {
  7822. sprintf(atcmd_output, msg_txt(sd,1419),command);// * %s list colors
  7823. clif_displaymessage(fd, atcmd_output);
  7824. clif_displaymessage(fd, msg_txt(sd,1420));// -- Lists all available colors for custom channels.
  7825. }
  7826. //option setcolor
  7827. if(can_create){
  7828. sprintf(atcmd_output, msg_txt(sd,1421),command);// * %s setcolor <#channel_name> <color_name>
  7829. clif_displaymessage(fd, atcmd_output);
  7830. clif_displaymessage(fd, msg_txt(sd,1422));// -- Changes channel text to the specified color (channel owners only).
  7831. }
  7832. //option join
  7833. sprintf(atcmd_output, msg_txt(sd,1473),command);// * %s join <#channel_name> <channel_password>
  7834. clif_displaymessage(fd, atcmd_output);
  7835. clif_displaymessage(fd, msg_txt(sd,1474));// -- Joins the specified channel.
  7836. //option leave
  7837. sprintf(atcmd_output, msg_txt(sd,1423),command);// * %s leave <#channel_name>
  7838. clif_displaymessage(fd, atcmd_output);
  7839. clif_displaymessage(fd, msg_txt(sd,1424));// -- Leaves the specified channel.
  7840. //option bindto
  7841. sprintf(atcmd_output, msg_txt(sd,1427),command);// * %s bindto <#channel_name>
  7842. clif_displaymessage(fd, atcmd_output);
  7843. clif_displaymessage(fd, msg_txt(sd,1428));// -- Binds your global chat to the specified channel, sending all global messages to that channel.
  7844. //option unbind
  7845. sprintf(atcmd_output, msg_txt(sd,1429),command);// * %s unbind
  7846. clif_displaymessage(fd, atcmd_output);
  7847. clif_displaymessage(fd, msg_txt(sd,1430));// -- Unbinds your global chat from the attached channel, if any.
  7848. //option ban/unban/banlist
  7849. if( can_create ) {
  7850. sprintf(atcmd_output, msg_txt(sd,1456),command);// * %s ban <#channel_name> <player>
  7851. clif_displaymessage(fd, atcmd_output);
  7852. clif_displaymessage(fd, msg_txt(sd,1457));// -- Bans the specified player from the channel.
  7853. sprintf(atcmd_output, msg_txt(sd,1458),command);// * %s banlist <#channel_name>
  7854. clif_displaymessage(fd, atcmd_output);
  7855. clif_displaymessage(fd, msg_txt(sd,1459));// -- Lists all players banned from the specified channel.
  7856. sprintf(atcmd_output, msg_txt(sd,1460),command);// * %s unban <#channel_name> <player>
  7857. clif_displaymessage(fd, atcmd_output);
  7858. clif_displaymessage(fd, msg_txt(sd,1461));// -- Unbans the specified player from the channel.
  7859. sprintf(atcmd_output, msg_txt(sd,1467),command);// * %s unbanall <#channel_name>
  7860. clif_displaymessage(fd, atcmd_output);
  7861. clif_displaymessage(fd, msg_txt(sd,1468));// -- Clears all bans from the specified channel.
  7862. }
  7863. //option setopt
  7864. if(can_create){
  7865. sprintf(atcmd_output, msg_txt(sd,1462),command);// * %s setopt <#channel_name> <option> <value>
  7866. clif_displaymessage(fd, atcmd_output);
  7867. clif_displaymessage(fd, msg_txt(sd,1463));// -- Sets an option and value for the specified channel.
  7868. }
  7869. sprintf(atcmd_output, msg_txt(sd,1404),command); // %s failed.
  7870. clif_displaymessage(fd, atcmd_output);
  7871. }
  7872. ACMD_FUNC(channel) {
  7873. char key[CHAN_NAME_LENGTH], sub1[CHAN_NAME_LENGTH], sub2[CHAN_NAME_LENGTH], sub3[CHAN_NAME_LENGTH];
  7874. sub1[0] = sub2[0] = sub3[0] = '\0';
  7875. if( !message || !*message || sscanf(message, "%19s %19s %19s %19s", key, sub1, sub2, sub3) < 1 ) {
  7876. atcmd_channel_help(sd,command);
  7877. return 0;
  7878. }
  7879. if( strcmpi(key,"create") == 0 && ( Channel_Config.user_chenable || pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) ) ) {
  7880. if(sub3[0] != '\0'){
  7881. clif_displaymessage(fd, msg_txt(sd,1408)); // Channel password may not contain spaces.
  7882. return -1;
  7883. }
  7884. return channel_pccreate(sd,sub1,sub2);
  7885. } else if( strcmpi(key,"delete") == 0 && pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) ) {
  7886. return channel_pcdelete(sd,sub1);
  7887. } else if ( strcmpi(key,"list") == 0 ) {
  7888. return channel_display_list(sd,sub1);
  7889. } else if ( strcmpi(key,"setcolor") == 0 ) {
  7890. return channel_pccolor(sd, sub1, sub2);
  7891. } else if ( strcmpi(key,"join") == 0 ) {
  7892. return channel_pcjoin(sd, sub1, sub2);
  7893. }else if ( strcmpi(key,"leave") == 0 ) {
  7894. return channel_pcleave(sd, sub1);
  7895. } else if ( strcmpi(key,"bindto") == 0 ) {
  7896. return channel_pcbind(sd, sub1);
  7897. } else if ( strcmpi(key,"unbind") == 0 ) {
  7898. return channel_pcunbind(sd);
  7899. } else if ( strcmpi(key,"ban") == 0 ) {
  7900. return channel_pcban(sd,sub1,map_nick2sd(sub2),0);
  7901. } else if ( strcmpi(key,"banlist") == 0 ) {
  7902. return channel_pcban(sd,sub1,NULL,3);
  7903. } else if ( strcmpi(key,"unban") == 0 ) {
  7904. return channel_pcban(sd,sub1,map_nick2sd(sub2),1);
  7905. } else if ( strcmpi(key,"unbanall") == 0 ) {
  7906. return channel_pcban(sd,sub1,NULL,2);
  7907. } else if ( strcmpi(key,"setopt") == 0 ) {
  7908. return channel_pcsetopt(sd,sub1,sub2,sub3);
  7909. } else {
  7910. atcmd_channel_help(sd,command);
  7911. }
  7912. return 0;
  7913. }
  7914. ACMD_FUNC(fontcolor)
  7915. {
  7916. if( !message || !*message ) {
  7917. channel_display_list(sd,"colors");
  7918. return -1;
  7919. }
  7920. if( strcmpi(message,"Normal") == 0 ) {
  7921. sd->fontcolor = 0;
  7922. } else {
  7923. unsigned char k;
  7924. ARR_FIND(0,Channel_Config.colors_count,k,( strcmpi(message,Channel_Config.colors_name[k]) == 0 ));
  7925. if( k == Channel_Config.colors_count ) {
  7926. sprintf(atcmd_output, msg_txt(sd,1411), message);// Unknown color '%s'.
  7927. clif_displaymessage(fd, atcmd_output);
  7928. return -1;
  7929. }
  7930. sd->fontcolor = k;
  7931. }
  7932. sprintf(atcmd_output, msg_txt(sd,1454), message);// Color set to '%s'.
  7933. clif_displaymessage(fd, atcmd_output);
  7934. return 0;
  7935. }
  7936. ACMD_FUNC(langtype)
  7937. {
  7938. char langstr[8];
  7939. int i=0, fail=0;
  7940. memset(langstr, '\0', sizeof(langstr));
  7941. if(sscanf(message, "%3s", langstr) >= 1){
  7942. int lang=0;
  7943. lang = msg_langstr2langtype(langstr); //Switch langstr to associated langtype
  7944. if( msg_checklangtype(lang,false) == 1 ){ //Verify it's enabled and set it
  7945. char output[100];
  7946. pc_setaccountreg(sd, "#langtype", lang); //For login/char
  7947. sd->langtype = lang;
  7948. sprintf(output,msg_txt(sd,461),msg_langtype2langstr(lang)); // Language is now set to %s.
  7949. clif_displaymessage(fd,output);
  7950. return 0;
  7951. } else if (lang != -1) { //defined langage but failed check
  7952. clif_displaymessage(fd,msg_txt(sd,462)); // This langage is currently disabled.
  7953. return -1;
  7954. }
  7955. }
  7956. //wrong or no entry
  7957. clif_displaymessage(fd,msg_txt(sd,460)); // Please enter a valid language (usage: @langtype <language>).
  7958. clif_displaymessage(fd,msg_txt(sd,464)); // ---- Available languages:
  7959. while(fail != -1){ //out of range
  7960. fail = msg_checklangtype(i,false);
  7961. if(fail == 1)
  7962. clif_displaymessage(fd,msg_langtype2langstr(i));
  7963. i++;
  7964. }
  7965. return -1;
  7966. }
  7967. #ifdef VIP_ENABLE
  7968. ACMD_FUNC(vip) {
  7969. struct map_session_data *pl_sd = NULL;
  7970. char * modif_p;
  7971. int32 vipdifftime = 0;
  7972. time_t now=time(NULL);
  7973. nullpo_retr(-1, sd);
  7974. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7975. if (!message || !*message || sscanf(message, "%255s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
  7976. clif_displaymessage(fd, msg_txt(sd,700)); //Usage: @vip <timef> <character name>
  7977. return -1;
  7978. }
  7979. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  7980. modif_p = atcmd_output;
  7981. vipdifftime = (int32)solve_time(modif_p);
  7982. if (vipdifftime == 0) {
  7983. clif_displaymessage(fd, msg_txt(sd,701)); // Invalid time for vip command.
  7984. 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.
  7985. return -1;
  7986. }
  7987. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  7988. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  7989. return -1;
  7990. }
  7991. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  7992. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  7993. return -1;
  7994. }
  7995. if(pl_sd->vip.time==0) pl_sd->vip.time=now;
  7996. pl_sd->vip.time += vipdifftime; //increase or reduce VIP duration
  7997. if (pl_sd->vip.time <= now) {
  7998. pl_sd->vip.time = 0;
  7999. pl_sd->vip.enabled = 0;
  8000. clif_displaymessage(pl_sd->fd, msg_txt(pl_sd,703)); // GM has removed your VIP time.
  8001. clif_displaymessage(fd, msg_txt(sd,704)); // Player is no longer VIP.
  8002. } else {
  8003. int year,month,day,hour,minute,second;
  8004. char timestr[21];
  8005. split_time((int)(pl_sd->vip.time-now),&year,&month,&day,&hour,&minute,&second);
  8006. 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.
  8007. clif_displaymessage(pl_sd->fd,atcmd_output);
  8008. timestamp2string(timestr,20,pl_sd->vip.time,"%Y-%m-%d %H:%M");
  8009. sprintf(atcmd_output,msg_txt(pl_sd,707),timestr); // You are VIP until : %s
  8010. clif_displaymessage(pl_sd->fd,atcmd_output);
  8011. if (pl_sd != sd) {
  8012. 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.
  8013. clif_displaymessage(fd,atcmd_output);
  8014. sprintf(atcmd_output,msg_txt(sd,708),timestr); // The player is now VIP until : %s
  8015. clif_displaymessage(fd,atcmd_output);
  8016. }
  8017. }
  8018. chrif_req_login_operation(pl_sd->status.account_id, pl_sd->status.name, 6, vipdifftime, 7, 0);
  8019. return 0;
  8020. }
  8021. /** Enable/disable rate info */
  8022. ACMD_FUNC(showrate) {
  8023. nullpo_retr(-1,sd);
  8024. if (!sd->disableshowrate) {
  8025. sprintf(atcmd_output,msg_txt(sd,718)); //Personal rate information is not displayed now.
  8026. sd->disableshowrate = 1;
  8027. }
  8028. else {
  8029. sprintf(atcmd_output,msg_txt(sd,719)); //Personal rate information will be shown.
  8030. sd->disableshowrate = 0;
  8031. }
  8032. clif_displaymessage(fd,atcmd_output);
  8033. return 0;
  8034. }
  8035. #endif
  8036. ACMD_FUNC(fullstrip) {
  8037. int i;
  8038. TBL_PC *tsd;
  8039. nullpo_retr(-1,sd);
  8040. if (!message || !*message) {
  8041. clif_displaymessage(fd, msg_txt(sd,349)); // Please enter a player name (usage: @fullstrip/@warpto/@goto <char name/ID>).
  8042. return -1;
  8043. }
  8044. if((tsd=map_nick2sd((char *)message)) == NULL && (tsd=map_id2sd(atoi(message))) == NULL){
  8045. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  8046. return -1;
  8047. }
  8048. for( i = 0; i < EQI_MAX; i++ ) {
  8049. if( tsd->equip_index[ i ] >= 0 )
  8050. pc_unequipitem( tsd , tsd->equip_index[ i ] , 2 );
  8051. }
  8052. return 0;
  8053. }
  8054. ACMD_FUNC(costume) {
  8055. const char* names[] = {
  8056. "Wedding",
  8057. "Xmas",
  8058. "Summer",
  8059. "Hanbok",
  8060. "Oktoberfest",
  8061. };
  8062. const int name2id[] = {
  8063. SC_WEDDING,
  8064. SC_XMAS,
  8065. SC_SUMMER,
  8066. SC_HANBOK,
  8067. SC_OKTOBERFEST
  8068. };
  8069. unsigned short k = 0, len = ARRAYLENGTH(names);
  8070. if( !message || !*message ) {
  8071. for( k = 0; k < len; k++ ) {
  8072. if( sd->sc.data[name2id[k]] ) {
  8073. sprintf(atcmd_output, msg_txt(sd, 727), names[k]); // '%s' Costume removed.
  8074. clif_displaymessage(sd->fd, atcmd_output);
  8075. status_change_end(&sd->bl, (sc_type)name2id[k], INVALID_TIMER);
  8076. return 0;
  8077. }
  8078. }
  8079. clif_displaymessage(sd->fd, msg_txt(sd, 726)); // Available Costumes
  8080. for( k = 0; k < len; k++ ) {
  8081. sprintf(atcmd_output, msg_txt(sd, 725), names[k]); // -- %s
  8082. clif_displaymessage(sd->fd, atcmd_output);
  8083. }
  8084. return -1;
  8085. }
  8086. for( k = 0; k < len; k++ ) {
  8087. if( sd->sc.data[name2id[k]] ) {
  8088. sprintf(atcmd_output, msg_txt(sd, 724), names[k]); // You're already wearing a(n) '%s' costume, type '@costume' to remove it.
  8089. clif_displaymessage(sd->fd, atcmd_output);
  8090. return -1;
  8091. }
  8092. }
  8093. for( k = 0; k < len; k++ )
  8094. if( strcmpi(message, names[k]) == 0 )
  8095. break;
  8096. if( k == len ) {
  8097. sprintf(atcmd_output, msg_txt(sd, 723), message); // '%s' is an unknown costume
  8098. clif_displaymessage(sd->fd, atcmd_output);
  8099. return -1;
  8100. }
  8101. sc_start(&sd->bl, &sd->bl, (sc_type)name2id[k], 100, 0, -1);
  8102. return 0;
  8103. }
  8104. #include "../custom/atcommand.inc"
  8105. /**
  8106. * Fills the reference of available commands in atcommand DBMap
  8107. **/
  8108. #define ACMD_DEF(x) { #x, atcommand_ ## x, NULL, NULL, 0 }
  8109. #define ACMD_DEF2(x2, x) { x2, atcommand_ ## x, NULL, NULL, 0 }
  8110. //define with restriction
  8111. #define ACMD_DEFR(x, r) { #x, atcommand_ ## x, NULL, NULL, r }
  8112. #define ACMD_DEF2R(x2, x, r) { x2, atcommand_ ## x, NULL, NULL, r }
  8113. void atcommand_basecommands(void) {
  8114. /**
  8115. * Command reference list, place the base of your commands here
  8116. * TODO : all restricted command are crashing case, please look into it
  8117. **/
  8118. AtCommandInfo atcommand_base[] = {
  8119. #include "../custom/atcommand_def.inc"
  8120. ACMD_DEF2R("warp", mapmove, 1),
  8121. ACMD_DEF(where),
  8122. ACMD_DEF(jumpto),
  8123. ACMD_DEF(jump),
  8124. ACMD_DEF(who),
  8125. ACMD_DEF2("who2", who),
  8126. ACMD_DEF2("who3", who),
  8127. ACMD_DEF2("whomap", who),
  8128. ACMD_DEF2("whomap2", who),
  8129. ACMD_DEF2("whomap3", who),
  8130. ACMD_DEF(whogm),
  8131. ACMD_DEF(save),
  8132. ACMD_DEF(load),
  8133. ACMD_DEF(speed),
  8134. ACMD_DEF(storage),
  8135. ACMD_DEF(guildstorage),
  8136. ACMD_DEF(option),
  8137. ACMD_DEF(hide), // + /hide
  8138. ACMD_DEFR(jobchange, 1),
  8139. ACMD_DEF(kill),
  8140. ACMD_DEF(alive),
  8141. ACMD_DEF(kami),
  8142. ACMD_DEF2("kamib", kami),
  8143. ACMD_DEF2("kamic", kami),
  8144. ACMD_DEF2("lkami", kami),
  8145. ACMD_DEF(heal),
  8146. ACMD_DEF(item),
  8147. ACMD_DEF(item2),
  8148. ACMD_DEF2("itembound",item),
  8149. ACMD_DEF2("itembound2",item2),
  8150. ACMD_DEF(itemreset),
  8151. ACMD_DEF(clearstorage),
  8152. ACMD_DEF(cleargstorage),
  8153. ACMD_DEF(clearcart),
  8154. ACMD_DEF2R("blvl", baselevelup, 1),
  8155. ACMD_DEF2("jlvl", joblevelup),
  8156. ACMD_DEF(help),
  8157. ACMD_DEF(pvpoff),
  8158. ACMD_DEF(pvpon),
  8159. ACMD_DEF(gvgoff),
  8160. ACMD_DEF(gvgon),
  8161. ACMD_DEF(model),
  8162. ACMD_DEFR(go, 1),
  8163. ACMD_DEF(monster),
  8164. ACMD_DEF2("monstersmall", monster),
  8165. ACMD_DEF2("monsterbig", monster),
  8166. ACMD_DEF(killmonster),
  8167. ACMD_DEF2("killmonster2", killmonster),
  8168. ACMD_DEF(refine),
  8169. ACMD_DEF(produce),
  8170. ACMD_DEF(memo),
  8171. ACMD_DEF(gat),
  8172. ACMD_DEF(displaystatus),
  8173. ACMD_DEF2("stpoint", statuspoint),
  8174. ACMD_DEF2("skpoint", skillpoint),
  8175. ACMD_DEF(zeny),
  8176. ACMD_DEF2("str", param),
  8177. ACMD_DEF2("agi", param),
  8178. ACMD_DEF2("vit", param),
  8179. ACMD_DEF2("int", param),
  8180. ACMD_DEF2("dex", param),
  8181. ACMD_DEF2("luk", param),
  8182. ACMD_DEF2("glvl", guildlevelup),
  8183. ACMD_DEF(makeegg),
  8184. ACMD_DEF(hatch),
  8185. ACMD_DEF(petfriendly),
  8186. ACMD_DEF(pethungry),
  8187. ACMD_DEF(petrename),
  8188. ACMD_DEF(recall), // + /recall
  8189. ACMD_DEF(night),
  8190. ACMD_DEF(day),
  8191. ACMD_DEF(doom),
  8192. ACMD_DEF(doommap),
  8193. ACMD_DEF(raise),
  8194. ACMD_DEF(raisemap),
  8195. ACMD_DEF(kick), // + right click menu for GM "(name) force to quit"
  8196. ACMD_DEF(kickall),
  8197. ACMD_DEF(allskill),
  8198. ACMD_DEF(questskill),
  8199. ACMD_DEF(lostskill),
  8200. ACMD_DEF(spiritball),
  8201. ACMD_DEF(party),
  8202. ACMD_DEF(guild),
  8203. ACMD_DEF(breakguild),
  8204. ACMD_DEF(agitstart),
  8205. ACMD_DEF(agitend),
  8206. ACMD_DEF(mapexit),
  8207. ACMD_DEF(idsearch),
  8208. ACMD_DEF(broadcast), // + /b and /nb
  8209. ACMD_DEF(localbroadcast), // + /lb and /nlb
  8210. ACMD_DEF(recallall),
  8211. ACMD_DEFR(reload,2),
  8212. ACMD_DEF2("reloaditemdb", reload),
  8213. ACMD_DEF2("reloadmobdb", reload),
  8214. ACMD_DEF2("reloadskilldb", reload),
  8215. ACMD_DEF2R("reloadscript", reload,2),
  8216. ACMD_DEF2("reloadatcommand", reload),
  8217. ACMD_DEF2("reloadbattleconf", reload),
  8218. ACMD_DEF2("reloadstatusdb", reload),
  8219. ACMD_DEF2("reloadpcdb", reload),
  8220. ACMD_DEF2("reloadmotd", reload),
  8221. ACMD_DEF2("reloadquestdb", reload),
  8222. ACMD_DEF2("reloadmsgconf", reload),
  8223. ACMD_DEF2("reloadpacketdb", reload),
  8224. ACMD_DEF2("reloadinstancedb", reload),
  8225. ACMD_DEF(partysharelvl),
  8226. ACMD_DEF(mapinfo),
  8227. ACMD_DEF(dye),
  8228. ACMD_DEF2("hairstyle", hair_style),
  8229. ACMD_DEF2("haircolor", hair_color),
  8230. ACMD_DEF2("allstats", stat_all),
  8231. ACMD_DEF2("block", char_block),
  8232. ACMD_DEF2("ban", char_ban),
  8233. ACMD_DEF2("unblock", char_unblock),
  8234. ACMD_DEF2("unban", char_unban),
  8235. ACMD_DEF2("charban", char_ban),
  8236. ACMD_DEF2("charunban", char_unban),
  8237. ACMD_DEF2("mount", mount_peco),
  8238. ACMD_DEF(guildspy),
  8239. ACMD_DEF(partyspy),
  8240. ACMD_DEF(repairall),
  8241. ACMD_DEF(guildrecall),
  8242. ACMD_DEF(partyrecall),
  8243. ACMD_DEF(nuke),
  8244. ACMD_DEF(shownpc),
  8245. ACMD_DEF(hidenpc),
  8246. ACMD_DEF(loadnpc),
  8247. ACMD_DEF(unloadnpc),
  8248. ACMD_DEF2("time", servertime),
  8249. ACMD_DEF(jail),
  8250. ACMD_DEF(unjail),
  8251. ACMD_DEF(jailfor),
  8252. ACMD_DEF(jailtime),
  8253. ACMD_DEF(disguise),
  8254. ACMD_DEF(undisguise),
  8255. ACMD_DEF(email),
  8256. ACMD_DEF(effect),
  8257. ACMD_DEF(follow),
  8258. ACMD_DEF(addwarp),
  8259. ACMD_DEF(skillon),
  8260. ACMD_DEF(skilloff),
  8261. ACMD_DEF(killer),
  8262. ACMD_DEF(npcmove),
  8263. ACMD_DEF(killable),
  8264. ACMD_DEF(dropall),
  8265. ACMD_DEF(storeall),
  8266. ACMD_DEF(skillid),
  8267. ACMD_DEF(useskill),
  8268. ACMD_DEF(displayskill),
  8269. ACMD_DEF(snow),
  8270. ACMD_DEF(sakura),
  8271. ACMD_DEF(clouds),
  8272. ACMD_DEF(clouds2),
  8273. ACMD_DEF(fog),
  8274. ACMD_DEF(fireworks),
  8275. ACMD_DEF(leaves),
  8276. ACMD_DEF(summon),
  8277. ACMD_DEF(adjgroup),
  8278. ACMD_DEF(trade),
  8279. ACMD_DEF(send),
  8280. ACMD_DEF(setbattleflag),
  8281. ACMD_DEF(unmute),
  8282. ACMD_DEF(clearweather),
  8283. ACMD_DEF(uptime),
  8284. ACMD_DEF(changesex),
  8285. ACMD_DEF(mute),
  8286. ACMD_DEF(refresh),
  8287. ACMD_DEF(refreshall),
  8288. ACMD_DEF(identify),
  8289. ACMD_DEF(identifyall),
  8290. ACMD_DEF(gmotd),
  8291. ACMD_DEF(misceffect),
  8292. ACMD_DEF(mobsearch),
  8293. ACMD_DEF(cleanmap),
  8294. ACMD_DEF(cleanarea),
  8295. ACMD_DEF(npctalk),
  8296. ACMD_DEF(pettalk),
  8297. ACMD_DEF(users),
  8298. ACMD_DEF(reset),
  8299. ACMD_DEF(skilltree),
  8300. ACMD_DEF(marry),
  8301. ACMD_DEF(divorce),
  8302. ACMD_DEF(sound),
  8303. ACMD_DEF(undisguiseall),
  8304. ACMD_DEF(disguiseall),
  8305. ACMD_DEF(changelook),
  8306. ACMD_DEF(autoloot),
  8307. ACMD_DEF2("alootid", autolootitem),
  8308. ACMD_DEF(autoloottype),
  8309. ACMD_DEF(mobinfo),
  8310. ACMD_DEF(exp),
  8311. ACMD_DEF(version),
  8312. ACMD_DEF(mutearea),
  8313. ACMD_DEF(rates),
  8314. ACMD_DEF(iteminfo),
  8315. ACMD_DEF(whodrops),
  8316. ACMD_DEF(whereis),
  8317. ACMD_DEF(mapflag),
  8318. ACMD_DEF(me),
  8319. ACMD_DEF(monsterignore),
  8320. ACMD_DEF(fakename),
  8321. ACMD_DEF(size),
  8322. ACMD_DEF(showexp),
  8323. ACMD_DEF(showzeny),
  8324. ACMD_DEF(showdelay),
  8325. ACMD_DEF(autotrade),
  8326. ACMD_DEF(changegm),
  8327. ACMD_DEF(changeleader),
  8328. ACMD_DEF(partyoption),
  8329. ACMD_DEF(invite),
  8330. ACMD_DEF(duel),
  8331. ACMD_DEF(leave),
  8332. ACMD_DEF(accept),
  8333. ACMD_DEF(reject),
  8334. ACMD_DEF(clone),
  8335. ACMD_DEF2("slaveclone", clone),
  8336. ACMD_DEF2("evilclone", clone),
  8337. ACMD_DEF(tonpc),
  8338. ACMD_DEF(commands),
  8339. ACMD_DEF(noask),
  8340. ACMD_DEF(request),
  8341. ACMD_DEF(homlevel),
  8342. ACMD_DEF(homevolution),
  8343. ACMD_DEF(hommutate),
  8344. ACMD_DEF(makehomun),
  8345. ACMD_DEF(homfriendly),
  8346. ACMD_DEF(homhungry),
  8347. ACMD_DEF(homtalk),
  8348. ACMD_DEF(hominfo),
  8349. ACMD_DEF(homstats),
  8350. ACMD_DEF(homshuffle),
  8351. ACMD_DEF(showmobs),
  8352. ACMD_DEF(feelreset),
  8353. ACMD_DEF(auction),
  8354. ACMD_DEF(mail),
  8355. ACMD_DEF2("noks", ksprotection),
  8356. ACMD_DEF(allowks),
  8357. ACMD_DEF(cash),
  8358. ACMD_DEF2("points", cash),
  8359. ACMD_DEF(agitstart2),
  8360. ACMD_DEF(agitend2),
  8361. ACMD_DEF(resetskill),
  8362. ACMD_DEF(resetstat),
  8363. ACMD_DEF2("storagelist", itemlist),
  8364. ACMD_DEF2("cartlist", itemlist),
  8365. ACMD_DEF2("itemlist", itemlist),
  8366. ACMD_DEF(stats),
  8367. ACMD_DEF(delitem),
  8368. ACMD_DEF(charcommands),
  8369. ACMD_DEF(font),
  8370. ACMD_DEF(accinfo),
  8371. ACMD_DEF(set),
  8372. ACMD_DEF(undisguiseguild),
  8373. ACMD_DEF(disguiseguild),
  8374. ACMD_DEF(sizeall),
  8375. ACMD_DEF(sizeguild),
  8376. ACMD_DEF(addperm),
  8377. ACMD_DEF2("rmvperm", addperm),
  8378. ACMD_DEF(unloadnpcfile),
  8379. ACMD_DEF(cart),
  8380. ACMD_DEF(mount2),
  8381. ACMD_DEF(join),
  8382. ACMD_DEF(channel),
  8383. ACMD_DEF(fontcolor),
  8384. ACMD_DEF(langtype),
  8385. #ifdef VIP_ENABLE
  8386. ACMD_DEF(vip),
  8387. ACMD_DEF(showrate),
  8388. #endif
  8389. ACMD_DEF(fullstrip),
  8390. ACMD_DEF(costume),
  8391. };
  8392. AtCommandInfo* atcommand;
  8393. int i;
  8394. for( i = 0; i < ARRAYLENGTH(atcommand_base); i++ ) {
  8395. if(atcommand_exists(atcommand_base[i].command)) { // Should not happen if atcommand_base[] array is OK
  8396. ShowDebug("atcommand_basecommands: duplicate ACMD_DEF for '%s'.\n", atcommand_base[i].command);
  8397. continue;
  8398. }
  8399. CREATE(atcommand, AtCommandInfo, 1);
  8400. safestrncpy(atcommand->command, atcommand_base[i].command, sizeof(atcommand->command));
  8401. atcommand->func = atcommand_base[i].func;
  8402. atcommand->restriction = atcommand_base[i].restriction;
  8403. strdb_put(atcommand_db, atcommand->command, atcommand);
  8404. }
  8405. return;
  8406. }
  8407. /*==========================================
  8408. * Command lookup functions
  8409. *------------------------------------------*/
  8410. bool atcommand_exists(const char* name)
  8411. {
  8412. return strdb_exists(atcommand_db, name);
  8413. }
  8414. static AtCommandInfo* get_atcommandinfo_byname(const char *name)
  8415. {
  8416. if (strdb_exists(atcommand_db, name))
  8417. return (AtCommandInfo*)strdb_get(atcommand_db, name);
  8418. return NULL;
  8419. }
  8420. static const char* atcommand_checkalias(const char *aliasname)
  8421. {
  8422. AliasInfo *alias_info = NULL;
  8423. if ((alias_info = (AliasInfo*)strdb_get(atcommand_alias_db, aliasname)) != NULL)
  8424. return alias_info->command->command;
  8425. return aliasname;
  8426. }
  8427. /// AtCommand suggestion
  8428. static void atcommand_get_suggestions(struct map_session_data* sd, const char *name, bool atcommand) {
  8429. DBIterator* atcommand_iter;
  8430. DBIterator* alias_iter;
  8431. AtCommandInfo* command_info = NULL;
  8432. AliasInfo* alias_info = NULL;
  8433. AtCommandType type = atcommand ? COMMAND_ATCOMMAND : COMMAND_CHARCOMMAND;
  8434. char* full_match[MAX_SUGGESTIONS];
  8435. char* suggestions[MAX_SUGGESTIONS];
  8436. char* match;
  8437. int prefix_count = 0, full_count = 0;
  8438. bool can_use;
  8439. if (!battle_config.atcommand_suggestions_enabled)
  8440. return;
  8441. atcommand_iter = db_iterator(atcommand_db);
  8442. alias_iter = db_iterator(atcommand_alias_db);
  8443. // Build the matches
  8444. for (command_info = dbi_first(atcommand_iter); dbi_exists(atcommand_iter); command_info = dbi_next(atcommand_iter)) {
  8445. match = strstr(command_info->command, name);
  8446. can_use = pc_can_use_command(sd, command_info->command, type);
  8447. if ( prefix_count < MAX_SUGGESTIONS && match == command_info->command && can_use ) {
  8448. suggestions[prefix_count] = command_info->command;
  8449. ++prefix_count;
  8450. }
  8451. if ( full_count < MAX_SUGGESTIONS && match != NULL && match != command_info->command && can_use ) {
  8452. full_match[full_count] = command_info->command;
  8453. ++full_count;
  8454. }
  8455. }
  8456. for (alias_info = dbi_first(alias_iter); dbi_exists(alias_iter); alias_info = dbi_next(alias_iter)) {
  8457. match = strstr(alias_info->alias, name);
  8458. can_use = pc_can_use_command(sd, alias_info->command->command, type);
  8459. if ( prefix_count < MAX_SUGGESTIONS && match == alias_info->alias && can_use) {
  8460. suggestions[prefix_count] = alias_info->alias;
  8461. ++prefix_count;
  8462. }
  8463. if ( full_count < MAX_SUGGESTIONS && match != NULL && match != alias_info->alias && can_use ) {
  8464. full_match[full_count] = alias_info->alias;
  8465. ++full_count;
  8466. }
  8467. }
  8468. if ((full_count+prefix_count) > 0) {
  8469. char buffer[512];
  8470. int i;
  8471. // Merge full match and prefix match results
  8472. if (prefix_count < MAX_SUGGESTIONS) {
  8473. memmove(&suggestions[prefix_count], full_match, sizeof(char*) * (MAX_SUGGESTIONS-prefix_count));
  8474. prefix_count = min(prefix_count+full_count, MAX_SUGGESTIONS);
  8475. }
  8476. // Build the suggestion string
  8477. strcpy(buffer, msg_txt(sd,205));
  8478. strcat(buffer,"\n");
  8479. for(i=0; i < prefix_count; ++i) {
  8480. strcat(buffer,suggestions[i]);
  8481. strcat(buffer," ");
  8482. }
  8483. clif_displaymessage(sd->fd, buffer);
  8484. }
  8485. dbi_destroy(atcommand_iter);
  8486. dbi_destroy(alias_iter);
  8487. }
  8488. /*
  8489. * Executes an at-command
  8490. * \param type :
  8491. * 0 : script call (atcommand)
  8492. * 1 : normal player @atcommand
  8493. * 2 : console
  8494. * 3 : script call (useatcmd)
  8495. */
  8496. bool is_atcommand(const int fd, struct map_session_data* sd, const char* message, int type)
  8497. {
  8498. char charname[NAME_LENGTH], params[100];
  8499. char charname2[NAME_LENGTH];
  8500. char command[100];
  8501. char output[CHAT_SIZE_MAX];
  8502. //Reconstructed message
  8503. char atcmd_msg[CHAT_SIZE_MAX];
  8504. TBL_PC * ssd = NULL; //sd for target
  8505. AtCommandInfo * info;
  8506. nullpo_retr(false, sd);
  8507. //Shouldn't happen
  8508. if ( !message || !*message )
  8509. return false;
  8510. //If cannot use atcomamnd while talking with NPC [Kichi]
  8511. if (sd->npc_id && sd->state.disable_atcommand_on_npc)
  8512. return false;
  8513. //Block NOCHAT but do not display it as a normal message
  8514. if ( sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCOMMAND )
  8515. return true;
  8516. // skip 10/11-langtype's codepage indicator, if detected
  8517. if ( message[0] == '|' && strlen(message) >= 4 && (message[3] == atcommand_symbol || message[3] == charcommand_symbol) )
  8518. message += 3;
  8519. //Should display as a normal message
  8520. if ( *message != atcommand_symbol && *message != charcommand_symbol )
  8521. return false;
  8522. // type value 0|2 = script|console invoked: bypass restrictions
  8523. if ( type == 1 || type == 3) {
  8524. //Commands are disabled on maps flagged as 'nocommand'
  8525. if ( map[sd->bl.m].nocommand && pc_get_group_level(sd) < map[sd->bl.m].nocommand ) {
  8526. clif_displaymessage(fd, msg_txt(sd,143));
  8527. return false;
  8528. }
  8529. }
  8530. if (*message == charcommand_symbol) {
  8531. do {
  8532. int x, y, z;
  8533. char params2[100];
  8534. //Checks to see if #command has a name or a name + parameters.
  8535. x = sscanf(message, "%99s \"%23[^\"]\" %99[^\n]", command, charname, params);
  8536. y = sscanf(message, "%99s %23s %99[^\n]", command, charname2, params2);
  8537. //z always has the value of the scan that was successful
  8538. z = ( x > 1 ) ? x : y;
  8539. //#command + name means the sufficient target was used and anything else after
  8540. //can be looked at by the actual command function since most scan to see if the
  8541. //right parameters are used.
  8542. if ( x > 2 ) {
  8543. sprintf(atcmd_msg, "%s %s", command, params);
  8544. break;
  8545. }
  8546. else if ( y > 2 ) {
  8547. sprintf(atcmd_msg, "%s %s", command, params2);
  8548. break;
  8549. }
  8550. //Regardless of what style the #command is used, if it's correct, it will always have
  8551. //this value if there is no parameter. Send it as just the #command
  8552. else if ( z == 2 ) {
  8553. sprintf(atcmd_msg, "%s", command);
  8554. break;
  8555. }
  8556. if( !pc_get_group_level(sd) ) {
  8557. if( x >= 1 || y >= 1 ) { /* we have command */
  8558. info = get_atcommandinfo_byname(atcommand_checkalias(command + 1));
  8559. 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 */
  8560. return false;
  8561. } else
  8562. return false;/* display as normal message */
  8563. }
  8564. sprintf(output, msg_txt(sd,1388), charcommand_symbol); // Charcommand failed (usage: %c<command> <char name> <parameters>).
  8565. clif_displaymessage(fd, output);
  8566. return true;
  8567. } while(0);
  8568. }
  8569. else if (*message == atcommand_symbol) {
  8570. //atcmd_msg is constructed above differently for charcommands
  8571. //it's copied from message if not a charcommand so it can
  8572. //pass through the rest of the code compatible with both symbols
  8573. sprintf(atcmd_msg, "%s", message);
  8574. }
  8575. //Clearing these to be used once more.
  8576. memset(command, '\0', sizeof(command));
  8577. memset(params, '\0', sizeof(params));
  8578. //check to see if any params exist within this command
  8579. if( sscanf(atcmd_msg, "%99s %99[^\n]", command, params) < 2 )
  8580. params[0] = '\0';
  8581. // @commands (script based)
  8582. if((type == 1 || type == 3) && atcmd_binding_count > 0) {
  8583. struct atcmd_binding_data * binding;
  8584. // Check if the command initiated is a character command
  8585. if (*message == charcommand_symbol &&
  8586. (ssd = map_nick2sd(charname)) == NULL && (ssd = map_nick2sd(charname2)) == NULL ) {
  8587. sprintf(output, msg_txt(sd,1389), command); // %s failed. Player not found.
  8588. clif_displaymessage(fd, output);
  8589. return true;
  8590. }
  8591. // Get atcommand binding
  8592. binding = get_atcommandbind_byname(command);
  8593. // Check if the binding isn't NULL and there is a NPC event, level of usage met, et cetera
  8594. if( binding != NULL && binding->npc_event[0] &&
  8595. ((*atcmd_msg == atcommand_symbol && pc_get_group_level(sd) >= binding->level) ||
  8596. (*atcmd_msg == charcommand_symbol && pc_get_group_level(sd) >= binding->level2)))
  8597. {
  8598. // Check if self or character invoking; if self == character invoked, then self invoke.
  8599. bool invokeFlag = ((*atcmd_msg == atcommand_symbol) ? 1 : 0);
  8600. npc_do_atcmd_event((invokeFlag ? sd : ssd), command, params, binding->npc_event);
  8601. return true;
  8602. }
  8603. }
  8604. //Grab the command information and check for the proper GM level required to use it or if the command exists
  8605. info = get_atcommandinfo_byname(atcommand_checkalias(command + 1));
  8606. if (info == NULL) {
  8607. if( pc_get_group_level(sd) ) { // TODO: remove or replace with proper permission
  8608. sprintf(output, msg_txt(sd,153), command); // "%s is Unknown Command."
  8609. clif_displaymessage(fd, output);
  8610. atcommand_get_suggestions(sd, command + 1, *message == atcommand_symbol);
  8611. return true;
  8612. } else
  8613. return false;
  8614. }
  8615. //check restriction
  8616. if(info->restriction){
  8617. if(info->restriction&1 && type == 2) //console prevent
  8618. return true;
  8619. if(info->restriction&2 && (type == 0 || type == 3) ) //scripts prevent
  8620. return true;
  8621. }
  8622. // type == 1 : player invoked
  8623. if (type == 1) {
  8624. if ((*command == atcommand_symbol && info->at_groups[sd->group_pos] == 0) ||
  8625. (*command == charcommand_symbol && info->char_groups[sd->group_pos] == 0) ) {
  8626. return false;
  8627. }
  8628. if( pc_isdead(sd) && pc_has_permission(sd,PC_PERM_DISABLE_CMD_DEAD) ) {
  8629. clif_displaymessage(fd, msg_txt(sd,1393)); // You can't use commands while dead
  8630. return true;
  8631. }
  8632. }
  8633. // Check if target is valid only if confirmed that player can use command.
  8634. if (*message == charcommand_symbol &&
  8635. (ssd = map_nick2sd(charname)) == NULL && (ssd = map_nick2sd(charname2)) == NULL ) {
  8636. sprintf(output, msg_txt(sd,1389), command); // %s failed. Player not found.
  8637. clif_displaymessage(fd, output);
  8638. return true;
  8639. }
  8640. //Attempt to use the command
  8641. if ( (info->func(fd, (*atcmd_msg == atcommand_symbol) ? sd : ssd, command, params) != 0) )
  8642. {
  8643. sprintf(output,msg_txt(sd,154), command); // %s failed.
  8644. clif_displaymessage(fd, output);
  8645. return true;
  8646. }
  8647. //Log only if successful.
  8648. if ( *atcmd_msg == atcommand_symbol )
  8649. log_atcommand(sd, atcmd_msg);
  8650. else if ( *atcmd_msg == charcommand_symbol )
  8651. log_atcommand(sd, message);
  8652. return true;
  8653. }
  8654. /*==========================================
  8655. *
  8656. *------------------------------------------*/
  8657. static void atcommand_config_read(const char* config_filename)
  8658. {
  8659. config_setting_t *aliases = NULL, *help = NULL;
  8660. const char *symbol = NULL;
  8661. int num_aliases = 0;
  8662. if (conf_read_file(&atcommand_config, config_filename))
  8663. return;
  8664. // Command symbols
  8665. if (config_lookup_string(&atcommand_config, "atcommand_symbol", &symbol)) {
  8666. if (ISPRINT(*symbol) && // no control characters
  8667. *symbol != '/' && // symbol of client commands
  8668. *symbol != '%' && // symbol of party chat
  8669. *symbol != '$' && // symbol of guild chat
  8670. *symbol != charcommand_symbol)
  8671. atcommand_symbol = *symbol;
  8672. }
  8673. if (config_lookup_string(&atcommand_config, "charcommand_symbol", &symbol)) {
  8674. if (ISPRINT(*symbol) && // no control characters
  8675. *symbol != '/' && // symbol of client commands
  8676. *symbol != '%' && // symbol of party chat
  8677. *symbol != '$' && // symbol of guild chat
  8678. *symbol != atcommand_symbol)
  8679. charcommand_symbol = *symbol;
  8680. }
  8681. // Command aliases
  8682. aliases = config_lookup(&atcommand_config, "aliases");
  8683. if (aliases != NULL) {
  8684. int i = 0;
  8685. int count = config_setting_length(aliases);
  8686. for (i = 0; i < count; ++i) {
  8687. config_setting_t *command;
  8688. const char *commandname = NULL;
  8689. int j = 0, alias_count = 0;
  8690. AtCommandInfo *commandinfo = NULL;
  8691. command = config_setting_get_elem(aliases, i);
  8692. if (config_setting_type(command) != CONFIG_TYPE_ARRAY)
  8693. continue;
  8694. commandname = config_setting_name(command);
  8695. if (!atcommand_exists(commandname)) {
  8696. ShowConfigWarning(command, "atcommand_config_read: can not set alias for non-existent command %s", commandname);
  8697. continue;
  8698. }
  8699. commandinfo = get_atcommandinfo_byname(commandname);
  8700. alias_count = config_setting_length(command);
  8701. for (j = 0; j < alias_count; ++j) {
  8702. const char *alias = config_setting_get_string_elem(command, j);
  8703. if (alias != NULL) {
  8704. AliasInfo *alias_info;
  8705. if (strdb_exists(atcommand_alias_db, alias)) {
  8706. ShowConfigWarning(command, "atcommand_config_read: alias %s already exists", alias);
  8707. continue;
  8708. }
  8709. CREATE(alias_info, AliasInfo, 1);
  8710. alias_info->command = commandinfo;
  8711. safestrncpy(alias_info->alias, alias, sizeof(alias_info->alias));
  8712. strdb_put(atcommand_alias_db, alias, alias_info);
  8713. ++num_aliases;
  8714. }
  8715. }
  8716. }
  8717. }
  8718. // Commands help
  8719. // We only check if all commands exist
  8720. help = config_lookup(&atcommand_config, "help");
  8721. if (help != NULL) {
  8722. int count = config_setting_length(help);
  8723. int i;
  8724. for (i = 0; i < count; ++i) {
  8725. config_setting_t *command;
  8726. const char *commandname;
  8727. command = config_setting_get_elem(help, i);
  8728. commandname = config_setting_name(command);
  8729. if (!atcommand_exists(commandname))
  8730. ShowConfigWarning(command, "atcommand_config_read: command %s does not exist", commandname);
  8731. }
  8732. }
  8733. ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' command aliases in '"CL_WHITE"%s"CL_RESET"'.\n", num_aliases, config_filename);
  8734. return;
  8735. }
  8736. void atcommand_db_load_groups(int* group_ids) {
  8737. DBIterator *iter = db_iterator(atcommand_db);
  8738. AtCommandInfo* cmd;
  8739. int i;
  8740. for (cmd = dbi_first(iter); dbi_exists(iter); cmd = dbi_next(iter)) {
  8741. cmd->at_groups = aMalloc( pc_group_max * sizeof(char) );
  8742. cmd->char_groups = aMalloc( pc_group_max * sizeof(char) );
  8743. for(i = 0; i < pc_group_max; i++) {
  8744. if( pc_group_can_use_command(group_ids[i], cmd->command, COMMAND_ATCOMMAND ) )
  8745. cmd->at_groups[i] = 1;
  8746. else
  8747. cmd->at_groups[i] = 0;
  8748. if( pc_group_can_use_command(group_ids[i], cmd->command, COMMAND_CHARCOMMAND ) )
  8749. cmd->char_groups[i] = 1;
  8750. else
  8751. cmd->char_groups[i] = 0;
  8752. }
  8753. }
  8754. dbi_destroy(iter);
  8755. return;
  8756. }
  8757. void atcommand_db_clear(void) {
  8758. if (atcommand_db != NULL) {
  8759. DBIterator *iter = db_iterator(atcommand_db);
  8760. AtCommandInfo* cmd;
  8761. for (cmd = dbi_first(iter); dbi_exists(iter); cmd = dbi_next(iter)) {
  8762. aFree(cmd->at_groups);
  8763. aFree(cmd->char_groups);
  8764. }
  8765. dbi_destroy(iter);
  8766. db_destroy(atcommand_db);
  8767. }
  8768. if (atcommand_alias_db != NULL)
  8769. db_destroy(atcommand_alias_db);
  8770. config_destroy(&atcommand_config);
  8771. }
  8772. void atcommand_doload(void) {
  8773. atcommand_db_clear();
  8774. atcommand_db = stridb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, ATCOMMAND_LENGTH);
  8775. atcommand_alias_db = stridb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, ATCOMMAND_LENGTH);
  8776. atcommand_basecommands(); //fills initial atcommand_db with known commands
  8777. atcommand_config_read(ATCOMMAND_CONF_FILENAME);
  8778. }
  8779. void do_init_atcommand(void) {
  8780. atcommand_doload();
  8781. }
  8782. void do_final_atcommand(void) {
  8783. atcommand_db_clear();
  8784. }