atcommand.c 284 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650
  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 "atcommand.h"
  16. #include "battle.h"
  17. #include "chat.h"
  18. #include "channel.h"
  19. #include "clif.h"
  20. #include "chrif.h"
  21. #include "duel.h"
  22. #include "intif.h"
  23. #include "itemdb.h"
  24. #include "log.h"
  25. #include "map.h"
  26. #include "pc.h"
  27. #include "pc_groups.h" // groupid2name
  28. #include "status.h"
  29. #include "skill.h"
  30. #include "mob.h"
  31. #include "npc.h"
  32. #include "pet.h"
  33. #include "homunculus.h"
  34. #include "mail.h"
  35. #include "mercenary.h"
  36. #include "elemental.h"
  37. #include "party.h"
  38. #include "guild.h"
  39. #include "script.h"
  40. #include "storage.h"
  41. #include "trade.h"
  42. #include "unit.h"
  43. #include "mapreg.h"
  44. #include "quest.h"
  45. #include <stdio.h>
  46. #include <stdlib.h>
  47. #include <string.h>
  48. #include <math.h>
  49. #define ATCOMMAND_LENGTH 50
  50. #define ACMD_FUNC(x) static int atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message)
  51. typedef struct AtCommandInfo AtCommandInfo;
  52. typedef struct AliasInfo AliasInfo;
  53. int atcmd_binding_count = 0;
  54. struct AtCommandInfo {
  55. char command[ATCOMMAND_LENGTH];
  56. AtCommandFunc func;
  57. char* at_groups;/* quick @commands "can-use" lookup */
  58. char* char_groups;/* quick @charcommands "can-use" lookup */
  59. };
  60. struct AliasInfo {
  61. AtCommandInfo *command;
  62. char alias[ATCOMMAND_LENGTH];
  63. };
  64. char atcommand_symbol = '@'; // first char of the commands
  65. char charcommand_symbol = '#';
  66. static DBMap* atcommand_db = NULL; //name -> AtCommandInfo
  67. static DBMap* atcommand_alias_db = NULL; //alias -> AtCommandInfo
  68. static config_t atcommand_config;
  69. static char atcmd_output[CHAT_SIZE_MAX];
  70. static char atcmd_player_name[NAME_LENGTH];
  71. static AtCommandInfo* get_atcommandinfo_byname(const char *name); // @help
  72. static const char* atcommand_checkalias(const char *aliasname); // @help
  73. static void atcommand_get_suggestions(struct map_session_data* sd, const char *name, bool atcommand); // @help
  74. // @commands (script-based)
  75. struct atcmd_binding_data* get_atcommandbind_byname(const char* name) {
  76. int i = 0;
  77. if( *name == atcommand_symbol || *name == charcommand_symbol )
  78. name++; // for backwards compatibility
  79. ARR_FIND( 0, atcmd_binding_count, i, strcmp(atcmd_binding[i]->command, name) == 0 );
  80. return ( i < atcmd_binding_count ) ? atcmd_binding[i] : NULL;
  81. }
  82. /**
  83. * retrieves the help string associated with a given command.
  84. *
  85. * @param name the name of the command to retrieve help information for
  86. * @return the string associated with the command, or NULL
  87. */
  88. static const char* atcommand_help_string(const char* command)
  89. {
  90. const char* str = NULL;
  91. config_setting_t* info;
  92. if( *command == atcommand_symbol || *command == charcommand_symbol )
  93. {// remove the prefix symbol for the raw name of the command
  94. command ++;
  95. }
  96. // convert alias to the real command name
  97. command = atcommand_checkalias(command);
  98. // attept to find the first default help command
  99. info = config_lookup(&atcommand_config, "help");
  100. if( info == NULL )
  101. {// failed to find the help property in the configuration file
  102. return NULL;
  103. }
  104. if( !config_setting_lookup_string( info, command, &str ) )
  105. {// failed to find the matching help string
  106. return NULL;
  107. }
  108. // push the result from the method
  109. return str;
  110. }
  111. /*==========================================
  112. * @send (used for testing packet sends from the client)
  113. *------------------------------------------*/
  114. ACMD_FUNC(send)
  115. {
  116. int len=0,off,end,type;
  117. long num;
  118. // read message type as hex number (without the 0x)
  119. if(!message || !*message ||
  120. !((sscanf(message, "len %x", &type)==1 && (len=1))
  121. || sscanf(message, "%x", &type)==1) )
  122. {
  123. int i;
  124. for (i = 900; i <= 903; ++i)
  125. clif_displaymessage(fd, msg_txt(sd,i));
  126. return -1;
  127. }
  128. #define PARSE_ERROR(error,p) \
  129. {\
  130. clif_displaymessage(fd, (error));\
  131. sprintf(atcmd_output, ">%s", (p));\
  132. clif_displaymessage(fd, atcmd_output);\
  133. }
  134. //define PARSE_ERROR
  135. #define CHECK_EOS(p) \
  136. if(*(p) == 0){\
  137. clif_displaymessage(fd, "Unexpected end of string");\
  138. return -1;\
  139. }
  140. //define CHECK_EOS
  141. #define SKIP_VALUE(p) \
  142. {\
  143. while(*(p) && !ISSPACE(*(p))) ++(p); /* non-space */\
  144. while(*(p) && ISSPACE(*(p))) ++(p); /* space */\
  145. }
  146. //define SKIP_VALUE
  147. #define GET_VALUE(p,num) \
  148. {\
  149. if(sscanf((p), "x%lx", &(num)) < 1 && sscanf((p), "%ld ", &(num)) < 1){\
  150. PARSE_ERROR("Invalid number in:",(p));\
  151. return -1;\
  152. }\
  153. }
  154. //define GET_VALUE
  155. if (type > 0 && type < MAX_PACKET_DB) {
  156. if(len)
  157. {// show packet length
  158. sprintf(atcmd_output, msg_txt(sd,904), type, packet_db[sd->packet_ver][type].len); // Packet 0x%x length: %d
  159. clif_displaymessage(fd, atcmd_output);
  160. return 0;
  161. }
  162. len=packet_db[sd->packet_ver][type].len;
  163. off=2;
  164. if(len == 0)
  165. {// unknown packet - ERROR
  166. sprintf(atcmd_output, msg_txt(sd,905), type); // Unknown packet: 0x%x
  167. clif_displaymessage(fd, atcmd_output);
  168. return -1;
  169. } else if(len == -1)
  170. {// dynamic packet
  171. len=SHRT_MAX-4; // maximum length
  172. off=4;
  173. }
  174. WFIFOHEAD(fd, len);
  175. WFIFOW(fd,0)=TOW(type);
  176. // parse packet contents
  177. SKIP_VALUE(message);
  178. while(*message != 0 && off < len){
  179. if(ISDIGIT(*message) || *message == '-' || *message == '+')
  180. {// default (byte)
  181. GET_VALUE(message,num);
  182. WFIFOB(fd,off)=TOB(num);
  183. ++off;
  184. } else if(TOUPPER(*message) == 'B')
  185. {// byte
  186. ++message;
  187. GET_VALUE(message,num);
  188. WFIFOB(fd,off)=TOB(num);
  189. ++off;
  190. } else if(TOUPPER(*message) == 'W')
  191. {// word (2 bytes)
  192. ++message;
  193. GET_VALUE(message,num);
  194. WFIFOW(fd,off)=TOW(num);
  195. off+=2;
  196. } else if(TOUPPER(*message) == 'L')
  197. {// long word (4 bytes)
  198. ++message;
  199. GET_VALUE(message,num);
  200. WFIFOL(fd,off)=TOL(num);
  201. off+=4;
  202. } else if(TOUPPER(*message) == 'S')
  203. {// string - escapes are valid
  204. // get string length - num <= 0 means not fixed length (default)
  205. ++message;
  206. if(*message == '"'){
  207. num=0;
  208. } else {
  209. GET_VALUE(message,num);
  210. while(*message != '"')
  211. {// find start of string
  212. if(*message == 0 || ISSPACE(*message)){
  213. PARSE_ERROR(msg_txt(sd,906),message); // Not a string:
  214. return -1;
  215. }
  216. ++message;
  217. }
  218. }
  219. // parse string
  220. ++message;
  221. CHECK_EOS(message);
  222. end=(num<=0? 0: min(off+((int)num),len));
  223. for(; *message != '"' && (off < end || end == 0); ++off){
  224. if(*message == '\\'){
  225. ++message;
  226. CHECK_EOS(message);
  227. switch(*message){
  228. case 'a': num=0x07; break; // Bell
  229. case 'b': num=0x08; break; // Backspace
  230. case 't': num=0x09; break; // Horizontal tab
  231. case 'n': num=0x0A; break; // Line feed
  232. case 'v': num=0x0B; break; // Vertical tab
  233. case 'f': num=0x0C; break; // Form feed
  234. case 'r': num=0x0D; break; // Carriage return
  235. case 'e': num=0x1B; break; // Escape
  236. default: num=*message; break;
  237. case 'x': // Hexadecimal
  238. {
  239. ++message;
  240. CHECK_EOS(message);
  241. if(!ISXDIGIT(*message)){
  242. PARSE_ERROR(msg_txt(sd,907),message); // Not a hexadecimal digit:
  243. return -1;
  244. }
  245. num=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  246. if(ISXDIGIT(*message)){
  247. ++message;
  248. CHECK_EOS(message);
  249. num<<=8;
  250. num+=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  251. }
  252. WFIFOB(fd,off)=TOB(num);
  253. ++message;
  254. CHECK_EOS(message);
  255. continue;
  256. }
  257. case '0':
  258. case '1':
  259. case '2':
  260. case '3':
  261. case '4':
  262. case '5':
  263. case '6':
  264. case '7': // Octal
  265. {
  266. num=*message-'0'; // 1st octal digit
  267. ++message;
  268. CHECK_EOS(message);
  269. if(ISDIGIT(*message) && *message < '8'){
  270. num<<=3;
  271. num+=*message-'0'; // 2nd octal digit
  272. ++message;
  273. CHECK_EOS(message);
  274. if(ISDIGIT(*message) && *message < '8'){
  275. num<<=3;
  276. num+=*message-'0'; // 3rd octal digit
  277. ++message;
  278. CHECK_EOS(message);
  279. }
  280. }
  281. WFIFOB(fd,off)=TOB(num);
  282. continue;
  283. }
  284. }
  285. } else
  286. num=*message;
  287. WFIFOB(fd,off)=TOB(num);
  288. ++message;
  289. CHECK_EOS(message);
  290. }//for
  291. while(*message != '"')
  292. {// ignore extra characters
  293. ++message;
  294. CHECK_EOS(message);
  295. }
  296. // terminate the string
  297. if(off < end)
  298. {// fill the rest with 0's
  299. memset(WFIFOP(fd,off),0,end-off);
  300. off=end;
  301. }
  302. } else
  303. {// unknown
  304. PARSE_ERROR(msg_txt(sd,908),message); // Unknown type of value in:
  305. return -1;
  306. }
  307. SKIP_VALUE(message);
  308. }
  309. if(packet_db[sd->packet_ver][type].len == -1)
  310. {// send dynamic packet
  311. WFIFOW(fd,2)=TOW(off);
  312. WFIFOSET(fd,off);
  313. } else
  314. {// send static packet
  315. if(off < len)
  316. memset(WFIFOP(fd,off),0,len-off);
  317. WFIFOSET(fd,len);
  318. }
  319. } else {
  320. clif_displaymessage(fd, msg_txt(sd,259)); // Invalid packet
  321. return -1;
  322. }
  323. sprintf (atcmd_output, msg_txt(sd,258), type, type); // Sent packet 0x%x (%d)
  324. clif_displaymessage(fd, atcmd_output);
  325. return 0;
  326. #undef PARSE_ERROR
  327. #undef CHECK_EOS
  328. #undef SKIP_VALUE
  329. #undef GET_VALUE
  330. }
  331. /*==========================================
  332. * @rura, @warp, @mapmove
  333. *------------------------------------------*/
  334. ACMD_FUNC(mapmove)
  335. {
  336. char map_name[MAP_NAME_LENGTH_EXT];
  337. unsigned short mapindex;
  338. short x = 0, y = 0;
  339. int16 m = -1;
  340. nullpo_retr(-1, sd);
  341. memset(map_name, '\0', sizeof(map_name));
  342. if (!message || !*message ||
  343. (sscanf(message, "%15s %hd %hd", map_name, &x, &y) < 3 &&
  344. sscanf(message, "%15[^,],%hd,%hd", map_name, &x, &y) < 1)) {
  345. clif_displaymessage(fd, msg_txt(sd,909)); // Please enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).
  346. return -1;
  347. }
  348. mapindex = mapindex_name2id(map_name);
  349. if (mapindex)
  350. m = map_mapindex2mapid(mapindex);
  351. if (!mapindex) { // m < 0 means on different server! [Kevin]
  352. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  353. return -1;
  354. }
  355. if ((x || y) && map_getcell(m, x, y, CELL_CHKNOPASS))
  356. { //This is to prevent the pc_setpos call from printing an error.
  357. clif_displaymessage(fd, msg_txt(sd,2));
  358. if (!map_search_freecell(NULL, m, &x, &y, 10, 10, 1))
  359. x = y = 0; //Invalid cell, use random spot.
  360. }
  361. if (map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  362. clif_displaymessage(fd, msg_txt(sd,247));
  363. return -1;
  364. }
  365. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  366. clif_displaymessage(fd, msg_txt(sd,248));
  367. return -1;
  368. }
  369. if (pc_setpos(sd, mapindex, x, y, CLR_TELEPORT) != 0) {
  370. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  371. return -1;
  372. }
  373. clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
  374. return 0;
  375. }
  376. /*==========================================
  377. * Displays where a character is. Corrected version by Silent. [Skotlex]
  378. *------------------------------------------*/
  379. ACMD_FUNC(where)
  380. {
  381. struct map_session_data* pl_sd;
  382. nullpo_retr(-1, sd);
  383. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  384. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  385. clif_displaymessage(fd, msg_txt(sd,910)); // Please enter a player name (usage: @where <char name>).
  386. return -1;
  387. }
  388. pl_sd = map_nick2sd(atcmd_player_name);
  389. if (pl_sd == NULL ||
  390. strncmp(pl_sd->status.name, atcmd_player_name, NAME_LENGTH) != 0 ||
  391. (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))
  392. ) {
  393. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  394. return -1;
  395. }
  396. 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);
  397. clif_displaymessage(fd, atcmd_output);
  398. return 0;
  399. }
  400. /*==========================================
  401. *
  402. *------------------------------------------*/
  403. ACMD_FUNC(jumpto)
  404. {
  405. struct map_session_data *pl_sd = NULL;
  406. nullpo_retr(-1, sd);
  407. if (!message || !*message) {
  408. clif_displaymessage(fd, msg_txt(sd,911)); // Please enter a player name (usage: @jumpto/@warpto/@goto <char name/ID>).
  409. return -1;
  410. }
  411. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  412. {
  413. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  414. return -1;
  415. }
  416. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  417. {
  418. clif_displaymessage(fd, msg_txt(sd,247)); // You are not authorized to warp to this map.
  419. return -1;
  420. }
  421. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  422. {
  423. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  424. return -1;
  425. }
  426. if( pc_isdead(sd) )
  427. {
  428. clif_displaymessage(fd, msg_txt(sd,664));
  429. return -1;
  430. }
  431. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  432. sprintf(atcmd_output, msg_txt(sd,4), pl_sd->status.name); // Jumped to %s
  433. clif_displaymessage(fd, atcmd_output);
  434. return 0;
  435. }
  436. /*==========================================
  437. *
  438. *------------------------------------------*/
  439. ACMD_FUNC(jump)
  440. {
  441. short x = 0, y = 0;
  442. nullpo_retr(-1, sd);
  443. memset(atcmd_output, '\0', sizeof(atcmd_output));
  444. sscanf(message, "%hd %hd", &x, &y);
  445. if (map[sd->bl.m].flag.noteleport && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  446. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  447. return -1;
  448. }
  449. if( pc_isdead(sd) )
  450. {
  451. clif_displaymessage(fd, msg_txt(sd,664));
  452. return -1;
  453. }
  454. if ((x || y) && map_getcell(sd->bl.m, x, y, CELL_CHKNOPASS))
  455. { //This is to prevent the pc_setpos call from printing an error.
  456. clif_displaymessage(fd, msg_txt(sd,2));
  457. if (!map_search_freecell(NULL, sd->bl.m, &x, &y, 10, 10, 1))
  458. x = y = 0; //Invalid cell, use random spot.
  459. }
  460. pc_setpos(sd, sd->mapindex, x, y, CLR_TELEPORT);
  461. sprintf(atcmd_output, msg_txt(sd,5), sd->bl.x, sd->bl.y); // Jumped to %d %d
  462. clif_displaymessage(fd, atcmd_output);
  463. return 0;
  464. }
  465. /*==========================================
  466. * Display list of online characters with
  467. * various info.
  468. *------------------------------------------*/
  469. ACMD_FUNC(who)
  470. {
  471. struct map_session_data *pl_sd = NULL;
  472. struct s_mapiterator *iter = NULL;
  473. char map_name[MAP_NAME_LENGTH_EXT] = "";
  474. char player_name[NAME_LENGTH] = "";
  475. int count = 0;
  476. int level = 0;
  477. StringBuf buf;
  478. /**
  479. * 1 = @who : Player name, [Title], [Party name], [Guild name]
  480. * 2 = @who2 : Player name, [Title], BLvl, JLvl, Job
  481. * 3 = @who3 : [CID/AID] Player name [Title], Map, X, Y
  482. */
  483. int display_type = 1;
  484. int map_id = -1;
  485. nullpo_retr(-1, sd);
  486. if (strstr(command, "map") != NULL) {
  487. if (sscanf(message, "%15s %23s", map_name, player_name) < 1 || (map_id = map_mapname2mapid(map_name)) < 0)
  488. map_id = sd->bl.m;
  489. } else {
  490. sscanf(message, "%23s", player_name);
  491. }
  492. if (strstr(command, "2") != NULL)
  493. display_type = 2;
  494. else if (strstr(command, "3") != NULL)
  495. display_type = 3;
  496. level = pc_get_group_level(sd);
  497. StringBuf_Init(&buf);
  498. iter = mapit_getallusers();
  499. for (pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter)) {
  500. 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
  501. if (stristr(pl_sd->status.name, player_name) == NULL // search with no case sensitive
  502. || (map_id >= 0 && pl_sd->bl.m != map_id))
  503. continue;
  504. switch (display_type) {
  505. case 2: {
  506. StringBuf_Printf(&buf, msg_txt(sd,343), pl_sd->status.name); // "Name: %s "
  507. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  508. StringBuf_Printf(&buf, msg_txt(sd,344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
  509. StringBuf_Printf(&buf, msg_txt(sd,347), pl_sd->status.base_level, pl_sd->status.job_level,
  510. job_name(pl_sd->status.class_)); // "| Lv:%d/%d | Job: %s"
  511. break;
  512. }
  513. case 3: {
  514. if (pc_has_permission(sd, PC_PERM_WHO_DISPLAY_AID))
  515. StringBuf_Printf(&buf, msg_txt(sd,912), pl_sd->status.char_id, pl_sd->status.account_id); // "(CID:%d/AID:%d) "
  516. StringBuf_Printf(&buf, msg_txt(sd,343), pl_sd->status.name); // "Name: %s "
  517. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  518. StringBuf_Printf(&buf, msg_txt(sd,344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
  519. StringBuf_Printf(&buf, msg_txt(sd,348), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y); // "| Location: %s %d %d"
  520. break;
  521. }
  522. default: {
  523. struct party_data *p = party_search(pl_sd->status.party_id);
  524. struct guild *g = pl_sd->guild;
  525. StringBuf_Printf(&buf, msg_txt(sd,343), pl_sd->status.name); // "Name: %s "
  526. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  527. StringBuf_Printf(&buf, msg_txt(sd,344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
  528. if (p != NULL)
  529. StringBuf_Printf(&buf, msg_txt(sd,345), p->party.name); // " | Party: '%s'"
  530. if (g != NULL)
  531. StringBuf_Printf(&buf, msg_txt(sd,346), g->name); // " | Guild: '%s'"
  532. break;
  533. }
  534. }
  535. clif_displaymessage(fd, StringBuf_Value(&buf));
  536. StringBuf_Clear(&buf);
  537. count++;
  538. }
  539. }
  540. mapit_free(iter);
  541. if (map_id < 0) {
  542. if (count == 0)
  543. StringBuf_Printf(&buf, msg_txt(sd,28)); // No player found.
  544. else if (count == 1)
  545. StringBuf_Printf(&buf, msg_txt(sd,29)); // 1 player found.
  546. else
  547. StringBuf_Printf(&buf, msg_txt(sd,30), count); // %d players found.
  548. } else {
  549. if (count == 0)
  550. StringBuf_Printf(&buf, msg_txt(sd,54), map[map_id].name); // No player found in map '%s'.
  551. else if (count == 1)
  552. StringBuf_Printf(&buf, msg_txt(sd,55), map[map_id].name); // 1 player found in map '%s'.
  553. else
  554. StringBuf_Printf(&buf, msg_txt(sd,56), count, map[map_id].name); // %d players found in map '%s'.
  555. }
  556. clif_displaymessage(fd, StringBuf_Value(&buf));
  557. StringBuf_Destroy(&buf);
  558. return 0;
  559. }
  560. /*==========================================
  561. *
  562. *------------------------------------------*/
  563. ACMD_FUNC(whogm)
  564. {
  565. struct map_session_data* pl_sd;
  566. struct s_mapiterator* iter;
  567. int j, count;
  568. int pl_level, level;
  569. char match_text[CHAT_SIZE_MAX];
  570. char player_name[NAME_LENGTH];
  571. struct guild *g;
  572. struct party_data *p;
  573. nullpo_retr(-1, sd);
  574. memset(atcmd_output, '\0', sizeof(atcmd_output));
  575. memset(match_text, '\0', sizeof(match_text));
  576. memset(player_name, '\0', sizeof(player_name));
  577. if (sscanf(message, "%199[^\n]", match_text) < 1)
  578. strcpy(match_text, "");
  579. for (j = 0; match_text[j]; j++)
  580. match_text[j] = TOLOWER(match_text[j]);
  581. count = 0;
  582. level = pc_get_group_level(sd);
  583. iter = mapit_getallusers();
  584. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  585. {
  586. pl_level = pc_get_group_level(pl_sd);
  587. if (!pl_level)
  588. continue;
  589. if (match_text[0])
  590. {
  591. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  592. for (j = 0; player_name[j]; j++)
  593. player_name[j] = TOLOWER(player_name[j]);
  594. // search with no case sensitive
  595. if (strstr(player_name, match_text) == NULL)
  596. continue;
  597. }
  598. if (pl_level > level) {
  599. if (pl_sd->sc.option & OPTION_INVISIBLE)
  600. continue;
  601. sprintf(atcmd_output, msg_txt(sd,913), pl_sd->status.name); // Name: %s (GM)
  602. clif_displaymessage(fd, atcmd_output);
  603. count++;
  604. continue;
  605. }
  606. sprintf(atcmd_output, msg_txt(sd,914), // Name: %s (GM:%d) | Location: %s %d %d
  607. pl_sd->status.name, pl_level,
  608. mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  609. clif_displaymessage(fd, atcmd_output);
  610. sprintf(atcmd_output, msg_txt(sd,915), // BLvl: %d | Job: %s (Lvl: %d)
  611. pl_sd->status.base_level,
  612. job_name(pl_sd->status.class_), pl_sd->status.job_level);
  613. clif_displaymessage(fd, atcmd_output);
  614. p = party_search(pl_sd->status.party_id);
  615. g = pl_sd->guild;
  616. sprintf(atcmd_output,msg_txt(sd,916), // Party: '%s' | Guild: '%s'
  617. p?p->party.name:msg_txt(sd,917), g?g->name:msg_txt(sd,917)); // None.
  618. clif_displaymessage(fd, atcmd_output);
  619. count++;
  620. }
  621. mapit_free(iter);
  622. if (count == 0)
  623. clif_displaymessage(fd, msg_txt(sd,150)); // No GM found.
  624. else if (count == 1)
  625. clif_displaymessage(fd, msg_txt(sd,151)); // 1 GM found.
  626. else {
  627. sprintf(atcmd_output, msg_txt(sd,152), count); // %d GMs found.
  628. clif_displaymessage(fd, atcmd_output);
  629. }
  630. return 0;
  631. }
  632. /*==========================================
  633. *
  634. *------------------------------------------*/
  635. ACMD_FUNC(save)
  636. {
  637. nullpo_retr(-1, sd);
  638. pc_setsavepoint(sd, sd->mapindex, sd->bl.x, sd->bl.y);
  639. if (sd->status.pet_id > 0 && sd->pd)
  640. intif_save_petdata(sd->status.account_id, &sd->pd->pet);
  641. chrif_save(sd,0);
  642. clif_displaymessage(fd, msg_txt(sd,6)); // Your save point has been changed.
  643. return 0;
  644. }
  645. /*==========================================
  646. *
  647. *------------------------------------------*/
  648. ACMD_FUNC(load)
  649. {
  650. int16 m;
  651. nullpo_retr(-1, sd);
  652. m = map_mapindex2mapid(sd->status.save_point.map);
  653. if (m >= 0 && map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  654. clif_displaymessage(fd, msg_txt(sd,249)); // You are not authorized to warp to your save map.
  655. return -1;
  656. }
  657. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  658. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  659. return -1;
  660. }
  661. pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, CLR_OUTSIGHT);
  662. clif_displaymessage(fd, msg_txt(sd,7)); // Warping to save point..
  663. return 0;
  664. }
  665. /*==========================================
  666. *
  667. *------------------------------------------*/
  668. ACMD_FUNC(speed)
  669. {
  670. int speed;
  671. nullpo_retr(-1, sd);
  672. memset(atcmd_output, '\0', sizeof(atcmd_output));
  673. if (!message || !*message || sscanf(message, "%d", &speed) < 1) {
  674. sprintf(atcmd_output, msg_txt(sd,918), MIN_WALK_SPEED, MAX_WALK_SPEED); // Please enter a speed value (usage: @speed <%d-%d>).
  675. clif_displaymessage(fd, atcmd_output);
  676. return -1;
  677. }
  678. if (speed < 0) {
  679. sd->base_status.speed = DEFAULT_WALK_SPEED;
  680. sd->state.permanent_speed = 0; // Remove lock when set back to default speed.
  681. } else {
  682. sd->base_status.speed = cap_value(speed, MIN_WALK_SPEED, MAX_WALK_SPEED);
  683. sd->state.permanent_speed = 1; // Set lock when set to non-default speed.
  684. }
  685. status_calc_bl(&sd->bl, SCB_SPEED);
  686. clif_displaymessage(fd, msg_txt(sd,8)); // Speed changed.
  687. return 0;
  688. }
  689. /*==========================================
  690. *
  691. *------------------------------------------*/
  692. ACMD_FUNC(storage)
  693. {
  694. nullpo_retr(-1, sd);
  695. if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading || sd->state.storage_flag)
  696. return -1;
  697. if (storage_storageopen(sd) == 1)
  698. { //Already open.
  699. clif_displaymessage(fd, msg_txt(sd,250));
  700. return -1;
  701. }
  702. clif_displaymessage(fd, msg_txt(sd,919)); // Storage opened.
  703. return 0;
  704. }
  705. /*==========================================
  706. *
  707. *------------------------------------------*/
  708. ACMD_FUNC(guildstorage)
  709. {
  710. nullpo_retr(-1, sd);
  711. if (!sd->status.guild_id) {
  712. clif_displaymessage(fd, msg_txt(sd,252));
  713. return -1;
  714. }
  715. if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading)
  716. return -1;
  717. if (sd->state.storage_flag == 1) {
  718. clif_displaymessage(fd, msg_txt(sd,250));
  719. return -1;
  720. }
  721. if (sd->state.storage_flag == 2) {
  722. clif_displaymessage(fd, msg_txt(sd,251));
  723. return -1;
  724. }
  725. storage_guild_storageopen(sd);
  726. clif_displaymessage(fd, msg_txt(sd,920)); // Guild storage opened.
  727. return 0;
  728. }
  729. /*==========================================
  730. *
  731. *------------------------------------------*/
  732. ACMD_FUNC(option)
  733. {
  734. int param1 = 0, param2 = 0, param3 = 0;
  735. nullpo_retr(-1, sd);
  736. if (!message || !*message || sscanf(message, "%d %d %d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0)
  737. {// failed to match the parameters so inform the user of the options
  738. const char* text;
  739. // attempt to find the setting information for this command
  740. text = atcommand_help_string( command );
  741. // notify the user of the requirement to enter an option
  742. clif_displaymessage(fd, msg_txt(sd,921)); // Please enter at least one option.
  743. if( text )
  744. {// send the help text associated with this command
  745. clif_displaymessage( fd, text );
  746. }
  747. return -1;
  748. }
  749. sd->sc.opt1 = param1;
  750. sd->sc.opt2 = param2;
  751. pc_setoption(sd, param3);
  752. clif_displaymessage(fd, msg_txt(sd,9)); // Options changed.
  753. return 0;
  754. }
  755. /*==========================================
  756. *
  757. *------------------------------------------*/
  758. ACMD_FUNC(hide)
  759. {
  760. nullpo_retr(-1, sd);
  761. if (sd->sc.option & OPTION_INVISIBLE) {
  762. sd->sc.option &= ~OPTION_INVISIBLE;
  763. if (sd->disguise)
  764. status_set_viewdata(&sd->bl, sd->disguise);
  765. else
  766. status_set_viewdata(&sd->bl, sd->status.class_);
  767. clif_displaymessage(fd, msg_txt(sd,10)); // Invisible: Off
  768. // increment the number of pvp players on the map
  769. map[sd->bl.m].users_pvp++;
  770. if( map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.pvp_nocalcrank )
  771. {// register the player for ranking calculations
  772. sd->pvp_timer = add_timer( gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0 );
  773. }
  774. //bugreport:2266
  775. map_foreachinmovearea(clif_insight, &sd->bl, AREA_SIZE, sd->bl.x, sd->bl.y, BL_ALL, &sd->bl);
  776. } else {
  777. sd->sc.option |= OPTION_INVISIBLE;
  778. sd->vd.class_ = INVISIBLE_CLASS;
  779. clif_displaymessage(fd, msg_txt(sd,11)); // Invisible: On
  780. // decrement the number of pvp players on the map
  781. map[sd->bl.m].users_pvp--;
  782. if( map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.pvp_nocalcrank && sd->pvp_timer != INVALID_TIMER )
  783. {// unregister the player for ranking
  784. delete_timer( sd->pvp_timer, pc_calc_pvprank_timer );
  785. sd->pvp_timer = INVALID_TIMER;
  786. }
  787. }
  788. clif_changeoption(&sd->bl);
  789. return 0;
  790. }
  791. /*==========================================
  792. * Changes a character's class
  793. *------------------------------------------*/
  794. ACMD_FUNC(jobchange)
  795. {
  796. int job = 0, upper = 0;
  797. const char* text;
  798. nullpo_retr(-1, sd);
  799. if (!message || !*message || sscanf(message, "%d %d", &job, &upper) < 1) {
  800. int i;
  801. bool found = false;
  802. upper = 0;
  803. // Normal Jobs
  804. for( i = JOB_NOVICE; i < JOB_MAX_BASIC && !found; i++ ){
  805. if (strncmpi(message, job_name(i), 16) == 0) {
  806. job = i;
  807. found = true;
  808. }
  809. }
  810. // High Jobs, Babys and Third
  811. for( i = JOB_NOVICE_HIGH; i < JOB_MAX && !found; i++ ){
  812. if (strncmpi(message, job_name(i), 16) == 0) {
  813. job = i;
  814. found = true;
  815. }
  816. }
  817. if (!found) {
  818. text = atcommand_help_string(command);
  819. if (text)
  820. clif_displaymessage(fd, text);
  821. return -1;
  822. }
  823. }
  824. if (job == JOB_KNIGHT2 || job == JOB_CRUSADER2 || job == JOB_WEDDING || job == JOB_XMAS || job == JOB_SUMMER || job == JOB_HANBOK
  825. || job == JOB_LORD_KNIGHT2 || job == JOB_PALADIN2 || job == JOB_BABY_KNIGHT2 || job == JOB_BABY_CRUSADER2 || job == JOB_STAR_GLADIATOR2
  826. || (job >= JOB_RUNE_KNIGHT2 && job <= JOB_MECHANIC_T2) || (job >= JOB_BABY_RUNE2 && job <= JOB_BABY_MECHANIC2)
  827. ){ // Deny direct transformation into dummy jobs
  828. clif_displaymessage(fd, msg_txt(sd,923)); //"You can not change to this job by command."
  829. return 0;
  830. }
  831. if (pcdb_checkid(job))
  832. {
  833. if (pc_jobchange(sd, job, upper) == 0)
  834. clif_displaymessage(fd, msg_txt(sd,12)); // Your job has been changed.
  835. else {
  836. clif_displaymessage(fd, msg_txt(sd,155)); // You are unable to change your job.
  837. return -1;
  838. }
  839. } else {
  840. text = atcommand_help_string(command);
  841. if (text)
  842. clif_displaymessage(fd, text);
  843. return -1;
  844. }
  845. return 0;
  846. }
  847. /*==========================================
  848. *
  849. *------------------------------------------*/
  850. ACMD_FUNC(kill)
  851. {
  852. nullpo_retr(-1, sd);
  853. status_kill(&sd->bl);
  854. clif_displaymessage(sd->fd, msg_txt(sd,13)); // A pity! You've died.
  855. if (fd != sd->fd)
  856. clif_displaymessage(fd, msg_txt(sd,14)); // Character killed.
  857. return 0;
  858. }
  859. /*==========================================
  860. *
  861. *------------------------------------------*/
  862. ACMD_FUNC(alive)
  863. {
  864. nullpo_retr(-1, sd);
  865. if (!status_revive(&sd->bl, 100, 100))
  866. {
  867. clif_displaymessage(fd, msg_txt(sd,667));
  868. return -1;
  869. }
  870. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  871. clif_displaymessage(fd, msg_txt(sd,16)); // You've been revived! It's a miracle!
  872. return 0;
  873. }
  874. /*==========================================
  875. * +kamic [LuzZza]
  876. *------------------------------------------*/
  877. ACMD_FUNC(kami)
  878. {
  879. unsigned long color=0;
  880. nullpo_retr(-1, sd);
  881. memset(atcmd_output, '\0', sizeof(atcmd_output));
  882. if(*(command + 5) != 'c' && *(command + 5) != 'C') {
  883. if (!message || !*message) {
  884. clif_displaymessage(fd, msg_txt(sd,980)); // Please enter a message (usage: @kami <message>).
  885. return -1;
  886. }
  887. sscanf(message, "%199[^\n]", atcmd_output);
  888. if (strstr(command, "l") != NULL)
  889. clif_broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, 0, ALL_SAMEMAP);
  890. else
  891. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, (*(command + 5) == 'b' || *(command + 5) == 'B') ? 0x10 : 0);
  892. } else {
  893. if(!message || !*message || (sscanf(message, "%lx %199[^\n]", &color, atcmd_output) < 2)) {
  894. clif_displaymessage(fd, msg_txt(sd,981)); // Please enter color and message (usage: @kamic <color> <message>).
  895. return -1;
  896. }
  897. if(color > 0xFFFFFF) {
  898. clif_displaymessage(fd, msg_txt(sd,982)); // Invalid color.
  899. return -1;
  900. }
  901. intif_broadcast2(atcmd_output, strlen(atcmd_output) + 1, color, 0x190, 12, 0, 0);
  902. }
  903. return 0;
  904. }
  905. /*==========================================
  906. *
  907. *------------------------------------------*/
  908. ACMD_FUNC(heal)
  909. {
  910. int hp = 0, sp = 0; // [Valaris] thanks to fov
  911. nullpo_retr(-1, sd);
  912. sscanf(message, "%d %d", &hp, &sp);
  913. // some overflow checks
  914. if( hp == INT_MIN ) hp++;
  915. if( sp == INT_MIN ) sp++;
  916. if ( hp == 0 && sp == 0 ) {
  917. if (!status_percent_heal(&sd->bl, 100, 100))
  918. clif_displaymessage(fd, msg_txt(sd,157)); // HP and SP have already been recovered.
  919. else
  920. clif_displaymessage(fd, msg_txt(sd,17)); // HP, SP recovered.
  921. return 0;
  922. }
  923. if ( hp > 0 && sp >= 0 ) {
  924. if(!status_heal(&sd->bl, hp, sp, 0))
  925. clif_displaymessage(fd, msg_txt(sd,157)); // HP and SP are already with the good value.
  926. else
  927. clif_displaymessage(fd, msg_txt(sd,17)); // HP, SP recovered.
  928. return 0;
  929. }
  930. if ( hp < 0 && sp <= 0 ) {
  931. status_damage(NULL, &sd->bl, -hp, -sp, 0, 0);
  932. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, 4, 0);
  933. clif_displaymessage(fd, msg_txt(sd,156)); // HP or/and SP modified.
  934. return 0;
  935. }
  936. //Opposing signs.
  937. if ( hp ) {
  938. if (hp > 0)
  939. status_heal(&sd->bl, hp, 0, 0);
  940. else {
  941. status_damage(NULL, &sd->bl, -hp, 0, 0, 0);
  942. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, 4, 0);
  943. }
  944. }
  945. if ( sp ) {
  946. if (sp > 0)
  947. status_heal(&sd->bl, 0, sp, 0);
  948. else
  949. status_damage(NULL, &sd->bl, 0, -sp, 0, 0);
  950. }
  951. clif_displaymessage(fd, msg_txt(sd,156)); // HP or/and SP modified.
  952. return 0;
  953. }
  954. /*==========================================
  955. * @item command (usage: @item <name/id_of_item> <quantity>) (modified by [Yor] for pet_egg)
  956. *------------------------------------------*/
  957. ACMD_FUNC(item)
  958. {
  959. char item_name[100];
  960. int number = 0, item_id, flag = 0;
  961. struct item item_tmp;
  962. struct item_data *item_data;
  963. int get_count, i;
  964. nullpo_retr(-1, sd);
  965. memset(item_name, '\0', sizeof(item_name));
  966. if (!message || !*message || (
  967. sscanf(message, "\"%99[^\"]\" %d", item_name, &number) < 1 &&
  968. sscanf(message, "%99s %d", item_name, &number) < 1
  969. )) {
  970. clif_displaymessage(fd, msg_txt(sd,983)); // Please enter an item name or ID (usage: @item <item name/ID> <quantity>).
  971. return -1;
  972. }
  973. if (number <= 0)
  974. number = 1;
  975. if ((item_data = itemdb_searchname(item_name)) == NULL &&
  976. (item_data = itemdb_exists(atoi(item_name))) == NULL)
  977. {
  978. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  979. return -1;
  980. }
  981. item_id = item_data->nameid;
  982. get_count = number;
  983. //Check if it's stackable.
  984. if (!itemdb_isstackable2(item_data))
  985. get_count = 1;
  986. for (i = 0; i < number; i += get_count) {
  987. // if not pet egg
  988. if (!pet_create_egg(sd, item_id)) {
  989. memset(&item_tmp, 0, sizeof(item_tmp));
  990. item_tmp.nameid = item_id;
  991. item_tmp.identify = 1;
  992. if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
  993. clif_additem(sd, 0, 0, flag);
  994. }
  995. }
  996. if (flag == 0)
  997. clif_displaymessage(fd, msg_txt(sd,18)); // Item created.
  998. return 0;
  999. }
  1000. /*==========================================
  1001. *
  1002. *------------------------------------------*/
  1003. ACMD_FUNC(item2)
  1004. {
  1005. struct item item_tmp;
  1006. struct item_data *item_data;
  1007. char item_name[100];
  1008. int item_id, number = 0;
  1009. int identify = 0, refine = 0, attr = 0;
  1010. int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  1011. nullpo_retr(-1, sd);
  1012. memset(item_name, '\0', sizeof(item_name));
  1013. if (!message || !*message || (
  1014. sscanf(message, "\"%99[^\"]\" %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9 &&
  1015. sscanf(message, "%99s %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9
  1016. )) {
  1017. clif_displaymessage(fd, msg_txt(sd,984)); // Please enter all parameters (usage: @item2 <item name/ID> <quantity>
  1018. clif_displaymessage(fd, msg_txt(sd,985)); // <identify_flag> <refine> <attribute> <card1> <card2> <card3> <card4>).
  1019. return -1;
  1020. }
  1021. if (number <= 0)
  1022. number = 1;
  1023. item_id = 0;
  1024. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  1025. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  1026. item_id = item_data->nameid;
  1027. if (item_id > 500) {
  1028. int flag = 0;
  1029. int loop, get_count, i;
  1030. loop = 1;
  1031. get_count = number;
  1032. if (item_data->type == IT_WEAPON || item_data->type == IT_ARMOR ||
  1033. item_data->type == IT_PETEGG || item_data->type == IT_PETARMOR) {
  1034. loop = number;
  1035. get_count = 1;
  1036. if (item_data->type == IT_PETEGG) {
  1037. identify = 1;
  1038. refine = 0;
  1039. }
  1040. if (item_data->type == IT_PETARMOR)
  1041. refine = 0;
  1042. if (refine > MAX_REFINE)
  1043. refine = MAX_REFINE;
  1044. } else {
  1045. identify = 1;
  1046. refine = attr = 0;
  1047. }
  1048. for (i = 0; i < loop; i++) {
  1049. memset(&item_tmp, 0, sizeof(item_tmp));
  1050. item_tmp.nameid = item_id;
  1051. item_tmp.identify = identify;
  1052. item_tmp.refine = refine;
  1053. item_tmp.attribute = attr;
  1054. item_tmp.card[0] = c1;
  1055. item_tmp.card[1] = c2;
  1056. item_tmp.card[2] = c3;
  1057. item_tmp.card[3] = c4;
  1058. if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
  1059. clif_additem(sd, 0, 0, flag);
  1060. }
  1061. if (flag == 0)
  1062. clif_displaymessage(fd, msg_txt(sd,18)); // Item created.
  1063. } else {
  1064. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  1065. return -1;
  1066. }
  1067. return 0;
  1068. }
  1069. /*==========================================
  1070. *
  1071. *------------------------------------------*/
  1072. ACMD_FUNC(itemreset)
  1073. {
  1074. int i;
  1075. nullpo_retr(-1, sd);
  1076. for (i = 0; i < MAX_INVENTORY; i++) {
  1077. if (sd->status.inventory[i].amount && sd->status.inventory[i].equip == 0) {
  1078. pc_delitem(sd, i, sd->status.inventory[i].amount, 0, 0, LOG_TYPE_COMMAND);
  1079. }
  1080. }
  1081. clif_displaymessage(fd, msg_txt(sd,20)); // All of your items have been removed.
  1082. return 0;
  1083. }
  1084. /*==========================================
  1085. * Atcommand @lvlup
  1086. *------------------------------------------*/
  1087. ACMD_FUNC(baselevelup)
  1088. {
  1089. int level=0, i=0, status_point=0;
  1090. nullpo_retr(-1, sd);
  1091. level = atoi(message);
  1092. if (!message || !*message || !level) {
  1093. clif_displaymessage(fd, msg_txt(sd,986)); // Please enter a level adjustment (usage: @lvup/@blevel/@baselvlup <number of levels>).
  1094. return -1;
  1095. }
  1096. if (level > 0) {
  1097. if (sd->status.base_level >= pc_maxbaselv(sd)) { // check for max level by Valaris
  1098. clif_displaymessage(fd, msg_txt(sd,47)); // Base level can't go any higher.
  1099. return -1;
  1100. } // End Addition
  1101. if ((unsigned int)level > pc_maxbaselv(sd) || (unsigned int)level > pc_maxbaselv(sd) - sd->status.base_level) // fix positiv overflow
  1102. level = pc_maxbaselv(sd) - sd->status.base_level;
  1103. for (i = 0; i < level; i++)
  1104. status_point += pc_gets_status_point(sd->status.base_level + i);
  1105. sd->status.status_point += status_point;
  1106. sd->status.base_level += (unsigned int)level;
  1107. status_percent_heal(&sd->bl, 100, 100);
  1108. clif_misceffect(&sd->bl, 0);
  1109. clif_displaymessage(fd, msg_txt(sd,21)); // Base level raised.
  1110. } else {
  1111. if (sd->status.base_level == 1) {
  1112. clif_displaymessage(fd, msg_txt(sd,158)); // Base level can't go any lower.
  1113. return -1;
  1114. }
  1115. level*=-1;
  1116. if ((unsigned int)level >= sd->status.base_level)
  1117. level = sd->status.base_level-1;
  1118. for (i = 0; i > -level; i--)
  1119. status_point += pc_gets_status_point(sd->status.base_level + i - 1);
  1120. if (sd->status.status_point < status_point)
  1121. pc_resetstate(sd);
  1122. if (sd->status.status_point < status_point)
  1123. sd->status.status_point = 0;
  1124. else
  1125. sd->status.status_point -= status_point;
  1126. sd->status.base_level -= (unsigned int)level;
  1127. clif_displaymessage(fd, msg_txt(sd,22)); // Base level lowered.
  1128. }
  1129. sd->status.base_exp = 0;
  1130. clif_updatestatus(sd, SP_STATUSPOINT);
  1131. clif_updatestatus(sd, SP_BASELEVEL);
  1132. clif_updatestatus(sd, SP_BASEEXP);
  1133. clif_updatestatus(sd, SP_NEXTBASEEXP);
  1134. status_calc_pc(sd, 0);
  1135. pc_baselevelchanged(sd);
  1136. if(sd->status.party_id)
  1137. party_send_levelup(sd);
  1138. return 0;
  1139. }
  1140. /*==========================================
  1141. *
  1142. *------------------------------------------*/
  1143. ACMD_FUNC(joblevelup)
  1144. {
  1145. int level=0;
  1146. nullpo_retr(-1, sd);
  1147. level = atoi(message);
  1148. if (!message || !*message || !level) {
  1149. clif_displaymessage(fd, msg_txt(sd,987)); // Please enter a level adjustment (usage: @joblvup/@jlevel/@joblvlup <number of levels>).
  1150. return -1;
  1151. }
  1152. if (level > 0) {
  1153. if (sd->status.job_level >= pc_maxjoblv(sd)) {
  1154. clif_displaymessage(fd, msg_txt(sd,23)); // Job level can't go any higher.
  1155. return -1;
  1156. }
  1157. if ((unsigned int)level > pc_maxjoblv(sd) || (unsigned int)level > pc_maxjoblv(sd) - sd->status.job_level) // fix positiv overflow
  1158. level = pc_maxjoblv(sd) - sd->status.job_level;
  1159. sd->status.job_level += (unsigned int)level;
  1160. sd->status.skill_point += level;
  1161. clif_misceffect(&sd->bl, 1);
  1162. clif_displaymessage(fd, msg_txt(sd,24)); // Job level raised.
  1163. } else {
  1164. if (sd->status.job_level == 1) {
  1165. clif_displaymessage(fd, msg_txt(sd,159)); // Job level can't go any lower.
  1166. return -1;
  1167. }
  1168. level *=-1;
  1169. if ((unsigned int)level >= sd->status.job_level) // fix negativ overflow
  1170. level = sd->status.job_level-1;
  1171. sd->status.job_level -= (unsigned int)level;
  1172. if (sd->status.skill_point < level)
  1173. pc_resetskill(sd,0); //Reset skills since we need to substract more points.
  1174. if (sd->status.skill_point < level)
  1175. sd->status.skill_point = 0;
  1176. else
  1177. sd->status.skill_point -= level;
  1178. clif_displaymessage(fd, msg_txt(sd,25)); // Job level lowered.
  1179. }
  1180. sd->status.job_exp = 0;
  1181. clif_updatestatus(sd, SP_JOBLEVEL);
  1182. clif_updatestatus(sd, SP_JOBEXP);
  1183. clif_updatestatus(sd, SP_NEXTJOBEXP);
  1184. clif_updatestatus(sd, SP_SKILLPOINT);
  1185. status_calc_pc(sd, 0);
  1186. return 0;
  1187. }
  1188. /*==========================================
  1189. * @help
  1190. *------------------------------------------*/
  1191. ACMD_FUNC(help)
  1192. {
  1193. config_setting_t *help;
  1194. const char *text = NULL;
  1195. const char *command_name = NULL;
  1196. char *default_command = "help";
  1197. nullpo_retr(-1, sd);
  1198. help = config_lookup(&atcommand_config, "help");
  1199. if (help == NULL) {
  1200. clif_displaymessage(fd, msg_txt(sd,27)); // "Commands help is not available."
  1201. return -1;
  1202. }
  1203. if (!message || !*message) {
  1204. command_name = default_command; // If no command_name specified, display help for @help.
  1205. } else {
  1206. if (*message == atcommand_symbol || *message == charcommand_symbol)
  1207. ++message;
  1208. command_name = atcommand_checkalias(message);
  1209. }
  1210. if (!pc_can_use_command(sd, command_name, COMMAND_ATCOMMAND)) {
  1211. sprintf(atcmd_output, msg_txt(sd,153), message); // "%s is Unknown Command"
  1212. clif_displaymessage(fd, atcmd_output);
  1213. atcommand_get_suggestions(sd, command_name, true);
  1214. return -1;
  1215. }
  1216. if (!config_setting_lookup_string(help, command_name, &text)) {
  1217. sprintf(atcmd_output, msg_txt(sd,988), atcommand_symbol, command_name); // There is no help for %c%s.
  1218. clif_displaymessage(fd, atcmd_output);
  1219. atcommand_get_suggestions(sd, command_name, true);
  1220. return -1;
  1221. }
  1222. sprintf(atcmd_output, msg_txt(sd,989), atcommand_symbol, command_name); // Help for command %c%s:
  1223. clif_displaymessage(fd, atcmd_output);
  1224. { // Display aliases
  1225. DBIterator* iter;
  1226. AtCommandInfo *command_info;
  1227. AliasInfo *alias_info = NULL;
  1228. StringBuf buf;
  1229. bool has_aliases = false;
  1230. StringBuf_Init(&buf);
  1231. StringBuf_AppendStr(&buf, msg_txt(sd,990)); // Available aliases:
  1232. command_info = get_atcommandinfo_byname(command_name);
  1233. iter = db_iterator(atcommand_alias_db);
  1234. for (alias_info = dbi_first(iter); dbi_exists(iter); alias_info = dbi_next(iter)) {
  1235. if (alias_info->command == command_info) {
  1236. StringBuf_Printf(&buf, " %s", alias_info->alias);
  1237. has_aliases = true;
  1238. }
  1239. }
  1240. dbi_destroy(iter);
  1241. if (has_aliases)
  1242. clif_displaymessage(fd, StringBuf_Value(&buf));
  1243. StringBuf_Destroy(&buf);
  1244. }
  1245. // Display help contents
  1246. clif_displaymessage(fd, text);
  1247. return 0;
  1248. }
  1249. // helper function, used in foreach calls to stop auto-attack timers
  1250. // parameter: '0' - everyone, 'id' - only those attacking someone with that id
  1251. static int atcommand_stopattack(struct block_list *bl,va_list ap)
  1252. {
  1253. struct unit_data *ud = unit_bl2ud(bl);
  1254. int id = va_arg(ap, int);
  1255. if (ud && ud->attacktimer != INVALID_TIMER && (!id || id == ud->target))
  1256. {
  1257. unit_stop_attack(bl);
  1258. return 1;
  1259. }
  1260. return 0;
  1261. }
  1262. /*==========================================
  1263. *
  1264. *------------------------------------------*/
  1265. static int atcommand_pvpoff_sub(struct block_list *bl,va_list ap)
  1266. {
  1267. TBL_PC* sd = (TBL_PC*)bl;
  1268. clif_pvpset(sd, 0, 0, 2);
  1269. if (sd->pvp_timer != INVALID_TIMER) {
  1270. delete_timer(sd->pvp_timer, pc_calc_pvprank_timer);
  1271. sd->pvp_timer = INVALID_TIMER;
  1272. }
  1273. return 0;
  1274. }
  1275. ACMD_FUNC(pvpoff)
  1276. {
  1277. nullpo_retr(-1, sd);
  1278. if (!map[sd->bl.m].flag.pvp) {
  1279. clif_displaymessage(fd, msg_txt(sd,160)); // PvP is already Off.
  1280. return -1;
  1281. }
  1282. map[sd->bl.m].flag.pvp = 0;
  1283. if (!battle_config.pk_mode){
  1284. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING);
  1285. clif_maptypeproperty2(&sd->bl,ALL_SAMEMAP);
  1286. }
  1287. map_foreachinmap(atcommand_pvpoff_sub,sd->bl.m, BL_PC);
  1288. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  1289. clif_displaymessage(fd, msg_txt(sd,31)); // PvP: Off.
  1290. return 0;
  1291. }
  1292. /*==========================================
  1293. *
  1294. *------------------------------------------*/
  1295. static int atcommand_pvpon_sub(struct block_list *bl,va_list ap)
  1296. {
  1297. TBL_PC* sd = (TBL_PC*)bl;
  1298. if (sd->pvp_timer == INVALID_TIMER) {
  1299. sd->pvp_timer = add_timer(gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0);
  1300. sd->pvp_rank = 0;
  1301. sd->pvp_lastusers = 0;
  1302. sd->pvp_point = 5;
  1303. sd->pvp_won = 0;
  1304. sd->pvp_lost = 0;
  1305. }
  1306. return 0;
  1307. }
  1308. ACMD_FUNC(pvpon)
  1309. {
  1310. nullpo_retr(-1, sd);
  1311. if (map[sd->bl.m].flag.pvp) {
  1312. clif_displaymessage(fd, msg_txt(sd,161)); // PvP is already On.
  1313. return -1;
  1314. }
  1315. map[sd->bl.m].flag.pvp = 1;
  1316. if (!battle_config.pk_mode) {// display pvp circle and rank
  1317. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_FREEPVPZONE);
  1318. clif_maptypeproperty2(&sd->bl,ALL_SAMEMAP);
  1319. map_foreachinmap(atcommand_pvpon_sub,sd->bl.m, BL_PC);
  1320. }
  1321. clif_displaymessage(fd, msg_txt(sd,32)); // PvP: On.
  1322. return 0;
  1323. }
  1324. /*==========================================
  1325. *
  1326. *------------------------------------------*/
  1327. ACMD_FUNC(gvgoff)
  1328. {
  1329. nullpo_retr(-1, sd);
  1330. if (!map[sd->bl.m].flag.gvg) {
  1331. clif_displaymessage(fd, msg_txt(sd,162)); // GvG is already Off.
  1332. return -1;
  1333. }
  1334. map[sd->bl.m].flag.gvg = 0;
  1335. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING);
  1336. clif_maptypeproperty2(&sd->bl,ALL_SAMEMAP);
  1337. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  1338. clif_displaymessage(fd, msg_txt(sd,33)); // GvG: Off.
  1339. return 0;
  1340. }
  1341. /*==========================================
  1342. *
  1343. *------------------------------------------*/
  1344. ACMD_FUNC(gvgon)
  1345. {
  1346. nullpo_retr(-1, sd);
  1347. if (map[sd->bl.m].flag.gvg) {
  1348. clif_displaymessage(fd, msg_txt(sd,163)); // GvG is already On.
  1349. return -1;
  1350. }
  1351. map[sd->bl.m].flag.gvg = 1;
  1352. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_AGITZONE);
  1353. clif_maptypeproperty2(&sd->bl,ALL_SAMEMAP);
  1354. clif_displaymessage(fd, msg_txt(sd,34)); // GvG: On.
  1355. return 0;
  1356. }
  1357. /*==========================================
  1358. *
  1359. *------------------------------------------*/
  1360. ACMD_FUNC(model)
  1361. {
  1362. int hair_style = 0, hair_color = 0, cloth_color = 0;
  1363. nullpo_retr(-1, sd);
  1364. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1365. if (!message || !*message || sscanf(message, "%d %d %d", &hair_style, &hair_color, &cloth_color) < 1) {
  1366. 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>).
  1367. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  1368. clif_displaymessage(fd, atcmd_output);
  1369. return -1;
  1370. }
  1371. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  1372. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  1373. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1374. pc_changelook(sd, LOOK_HAIR, hair_style);
  1375. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1376. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1377. clif_displaymessage(fd, msg_txt(sd,36)); // Appearence changed.
  1378. } else {
  1379. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1380. return -1;
  1381. }
  1382. return 0;
  1383. }
  1384. /*==========================================
  1385. * @dye && @ccolor
  1386. *------------------------------------------*/
  1387. ACMD_FUNC(dye)
  1388. {
  1389. int cloth_color = 0;
  1390. nullpo_retr(-1, sd);
  1391. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1392. if (!message || !*message || sscanf(message, "%d", &cloth_color) < 1) {
  1393. 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>).
  1394. clif_displaymessage(fd, atcmd_output);
  1395. return -1;
  1396. }
  1397. if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1398. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1399. clif_displaymessage(fd, msg_txt(sd,36)); // Appearence changed.
  1400. } else {
  1401. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1402. return -1;
  1403. }
  1404. return 0;
  1405. }
  1406. /*==========================================
  1407. * @hairstyle && @hstyle
  1408. *------------------------------------------*/
  1409. ACMD_FUNC(hair_style)
  1410. {
  1411. int hair_style = 0;
  1412. nullpo_retr(-1, sd);
  1413. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1414. if (!message || !*message || sscanf(message, "%d", &hair_style) < 1) {
  1415. 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>).
  1416. clif_displaymessage(fd, atcmd_output);
  1417. return -1;
  1418. }
  1419. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
  1420. pc_changelook(sd, LOOK_HAIR, hair_style);
  1421. clif_displaymessage(fd, msg_txt(sd,36)); // Appearence changed.
  1422. } else {
  1423. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1424. return -1;
  1425. }
  1426. return 0;
  1427. }
  1428. /*==========================================
  1429. * @haircolor && @hcolor
  1430. *------------------------------------------*/
  1431. ACMD_FUNC(hair_color)
  1432. {
  1433. int hair_color = 0;
  1434. nullpo_retr(-1, sd);
  1435. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1436. if (!message || !*message || sscanf(message, "%d", &hair_color) < 1) {
  1437. 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>).
  1438. clif_displaymessage(fd, atcmd_output);
  1439. return -1;
  1440. }
  1441. if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
  1442. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1443. clif_displaymessage(fd, msg_txt(sd,36)); // Appearence changed.
  1444. } else {
  1445. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1446. return -1;
  1447. }
  1448. return 0;
  1449. }
  1450. /*==========================================
  1451. * @go [city_number or city_name] - Updated by Harbin
  1452. *------------------------------------------*/
  1453. ACMD_FUNC(go)
  1454. {
  1455. int i;
  1456. int town;
  1457. char map_name[MAP_NAME_LENGTH];
  1458. int16 m;
  1459. const struct {
  1460. char map[MAP_NAME_LENGTH];
  1461. int x, y;
  1462. } data[] = {
  1463. { MAP_PRONTERA, 156, 191 }, // 0=Prontera
  1464. { MAP_MORROC, 156, 93 }, // 1=Morroc
  1465. { MAP_GEFFEN, 119, 59 }, // 2=Geffen
  1466. { MAP_PAYON, 162, 233 }, // 3=Payon
  1467. { MAP_ALBERTA, 192, 147 }, // 4=Alberta
  1468. #ifdef RENEWAL
  1469. { MAP_IZLUDE, 128, 146 }, // 5=Izlude (Renewal)
  1470. #else
  1471. { MAP_IZLUDE, 128, 114 }, // 5=Izlude
  1472. #endif
  1473. { MAP_ALDEBARAN, 140, 131 }, // 6=Al de Baran
  1474. { MAP_LUTIE, 147, 134 }, // 7=Lutie
  1475. { MAP_COMODO, 209, 143 }, // 8=Comodo
  1476. { MAP_YUNO, 157, 51 }, // 9=Yuno
  1477. { MAP_AMATSU, 198, 84 }, // 10=Amatsu
  1478. { MAP_GONRYUN, 160, 120 }, // 11=Gonryun
  1479. { MAP_UMBALA, 89, 157 }, // 12=Umbala
  1480. { MAP_NIFLHEIM, 21, 153 }, // 13=Niflheim
  1481. { MAP_LOUYANG, 217, 40 }, // 14=Louyang
  1482. { MAP_NOVICE, 53, 111 }, // 15=Training Grounds
  1483. { MAP_JAIL, 23, 61 }, // 16=Prison
  1484. { MAP_JAWAII, 249, 127 }, // 17=Jawaii
  1485. { MAP_AYOTHAYA, 151, 117 }, // 18=Ayothaya
  1486. { MAP_EINBROCH, 64, 200 }, // 19=Einbroch
  1487. { MAP_LIGHTHALZEN, 158, 92 }, // 20=Lighthalzen
  1488. { MAP_EINBECH, 70, 95 }, // 21=Einbech
  1489. { MAP_HUGEL, 96, 145 }, // 22=Hugel
  1490. { MAP_RACHEL, 130, 110 }, // 23=Rachel
  1491. { MAP_VEINS, 216, 123 }, // 24=Veins
  1492. { MAP_MOSCOVIA, 223, 184 }, // 25=Moscovia
  1493. { MAP_MIDCAMP, 180, 240 }, // 26=Midgard Camp
  1494. { MAP_MANUK, 282, 138 }, // 27=Manuk
  1495. { MAP_SPLENDIDE, 201, 147 }, // 28=Splendide
  1496. { MAP_BRASILIS, 182, 239 }, // 29=Brasilis
  1497. { MAP_DICASTES, 198, 187 }, // 30=El Dicastes
  1498. { MAP_MORA, 44, 151 }, // 31=Mora
  1499. { MAP_DEWATA, 200, 180 }, // 32=Dewata
  1500. { MAP_MALANGDO, 140, 114 }, // 33=Malangdo Island
  1501. { MAP_MALAYA, 242, 211 }, // 34=Malaya Port
  1502. { MAP_ECLAGE, 110, 39 }, // 35=Eclage
  1503. };
  1504. nullpo_retr(-1, sd);
  1505. if( map[sd->bl.m].flag.nogo && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE) ) {
  1506. clif_displaymessage(sd->fd,msg_txt(sd,995)); // You cannot use @go on this map.
  1507. return 0;
  1508. }
  1509. memset(map_name, '\0', sizeof(map_name));
  1510. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1511. // get the number
  1512. town = atoi(message);
  1513. if (!message || !*message || sscanf(message, "%11s", map_name) < 1 || town < 0 || town >= ARRAYLENGTH(data))
  1514. {// no value matched so send the list of locations
  1515. const char* text;
  1516. // attempt to find the text help string
  1517. text = atcommand_help_string( command );
  1518. clif_displaymessage(fd, msg_txt(sd,38)); // Invalid location number, or name.
  1519. if( text )
  1520. {// send the text to the client
  1521. clif_displaymessage( fd, text );
  1522. }
  1523. return -1;
  1524. }
  1525. // get possible name of the city
  1526. map_name[MAP_NAME_LENGTH-1] = '\0';
  1527. for (i = 0; map_name[i]; i++)
  1528. map_name[i] = TOLOWER(map_name[i]);
  1529. // try to identify the map name
  1530. if (strncmp(map_name, "prontera", 3) == 0) {
  1531. town = 0;
  1532. } else if (strncmp(map_name, "morocc", 4) == 0 ||
  1533. strncmp(map_name, "morroc", 4) == 0) {
  1534. town = 1;
  1535. } else if (strncmp(map_name, "geffen", 3) == 0) {
  1536. town = 2;
  1537. } else if (strncmp(map_name, "payon", 3) == 0) {
  1538. town = 3;
  1539. } else if (strncmp(map_name, "alberta", 3) == 0) {
  1540. town = 4;
  1541. } else if (strncmp(map_name, "izlude", 3) == 0) {
  1542. town = 5;
  1543. } else if (strncmp(map_name, "aldebaran", 3) == 0) {
  1544. town = 6;
  1545. } else if (strncmp(map_name, "lutie", 3) == 0 ||
  1546. strcmp(map_name, "christmas") == 0 ||
  1547. strncmp(map_name, "xmas", 3) == 0 ||
  1548. strncmp(map_name, "x-mas", 3) == 0) {
  1549. town = 7;
  1550. } else if (strncmp(map_name, "comodo", 3) == 0) {
  1551. town = 8;
  1552. } else if (strncmp(map_name, "juno", 3) == 0 ||
  1553. strncmp(map_name, "yuno", 3) == 0) {
  1554. town = 9;
  1555. } else if (strncmp(map_name, "amatsu", 3) == 0) {
  1556. town = 10;
  1557. } else if (strncmp(map_name, "kunlun", 3) == 0 ||
  1558. strncmp(map_name, "gonryun", 3) == 0) {
  1559. town = 11;
  1560. } else if (strncmp(map_name, "umbala", 3) == 0) {
  1561. town = 12;
  1562. } else if (strncmp(map_name, "niflheim", 3) == 0) {
  1563. town = 13;
  1564. } else if (strncmp(map_name, "louyang", 3) == 0) {
  1565. town = 14;
  1566. } else if (strncmp(map_name, "new_1-1", 3) == 0 ||
  1567. strncmp(map_name, "startpoint", 3) == 0 ||
  1568. strncmp(map_name, "beginning", 3) == 0) {
  1569. town = 15;
  1570. } else if (strncmp(map_name, "sec_pri", 3) == 0 ||
  1571. strncmp(map_name, "prison", 3) == 0 ||
  1572. strncmp(map_name, "jail", 3) == 0) {
  1573. town = 16;
  1574. } else if (strncmp(map_name, "jawaii", 3) == 0) {
  1575. town = 17;
  1576. } else if (strncmp(map_name, "ayothaya", 3) == 0) {
  1577. town = 18;
  1578. } else if (strncmp(map_name, "einbroch", 5) == 0) {
  1579. town = 19;
  1580. } else if (strncmp(map_name, "lighthalzen", 3) == 0) {
  1581. town = 20;
  1582. } else if (strncmp(map_name, "einbech", 5) == 0) {
  1583. town = 21;
  1584. } else if (strncmp(map_name, "hugel", 3) == 0) {
  1585. town = 22;
  1586. } else if (strncmp(map_name, "rachel", 3) == 0) {
  1587. town = 23;
  1588. } else if (strncmp(map_name, "veins", 3) == 0) {
  1589. town = 24;
  1590. } else if (strncmp(map_name, "moscovia", 3) == 0) {
  1591. town = 25;
  1592. } else if (strncmp(map_name, "mid_camp", 3) == 0) {
  1593. town = 26;
  1594. } else if (strncmp(map_name, "manuk", 3) == 0) {
  1595. town = 27;
  1596. } else if (strncmp(map_name, "splendide", 3) == 0) {
  1597. town = 28;
  1598. } else if (strncmp(map_name, "brasilis", 3) == 0) {
  1599. town = 29;
  1600. } else if (strncmp(map_name, "dicastes01", 3) == 0) {
  1601. town = 30;
  1602. } else if (strcmp(map_name, "mora") == 0) {
  1603. town = 31;
  1604. } else if (strncmp(map_name, "dewata", 3) == 0) {
  1605. town = 32;
  1606. } else if (strncmp(map_name, "malangdo", 5) == 0) {
  1607. town = 33;
  1608. } else if (strncmp(map_name, "malaya", 5) == 0) {
  1609. town = 34;
  1610. } else if (strncmp(map_name, "eclage", 3) == 0) {
  1611. town = 35;
  1612. }
  1613. if (town >= 0 && town < ARRAYLENGTH(data))
  1614. {
  1615. m = map_mapname2mapid(data[town].map);
  1616. if (m >= 0 && map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  1617. clif_displaymessage(fd, msg_txt(sd,247));
  1618. return -1;
  1619. }
  1620. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  1621. clif_displaymessage(fd, msg_txt(sd,248));
  1622. return -1;
  1623. }
  1624. if (pc_setpos(sd, mapindex_name2id(data[town].map), data[town].x, data[town].y, CLR_TELEPORT) == 0) {
  1625. clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
  1626. } else {
  1627. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  1628. return -1;
  1629. }
  1630. } else { // if you arrive here, you have an error in town variable when reading of names
  1631. clif_displaymessage(fd, msg_txt(sd,38)); // Invalid location number or name.
  1632. return -1;
  1633. }
  1634. return 0;
  1635. }
  1636. /*==========================================
  1637. *
  1638. *------------------------------------------*/
  1639. ACMD_FUNC(monster)
  1640. {
  1641. char name[NAME_LENGTH];
  1642. char monster[NAME_LENGTH];
  1643. char eventname[EVENT_NAME_LENGTH] = "";
  1644. int mob_id;
  1645. int number = 0;
  1646. int count;
  1647. int i, k, range;
  1648. short mx, my;
  1649. unsigned int size;
  1650. nullpo_retr(-1, sd);
  1651. memset(name, '\0', sizeof(name));
  1652. memset(monster, '\0', sizeof(monster));
  1653. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1654. if (!message || !*message) {
  1655. clif_displaymessage(fd, msg_txt(sd,80)); // Give the display name or monster name/id please.
  1656. return -1;
  1657. }
  1658. if (sscanf(message, "\"%23[^\"]\" %23s %d", name, monster, &number) > 1 ||
  1659. sscanf(message, "%23s \"%23[^\"]\" %d", monster, name, &number) > 1) {
  1660. //All data can be left as it is.
  1661. } else if ((count=sscanf(message, "%23s %d %23s", monster, &number, name)) > 1) {
  1662. //Here, it is possible name was not given and we are using monster for it.
  1663. if (count < 3) //Blank mob's name.
  1664. name[0] = '\0';
  1665. } else if (sscanf(message, "%23s %23s %d", name, monster, &number) > 1) {
  1666. //All data can be left as it is.
  1667. } else if (sscanf(message, "%23s", monster) > 0) {
  1668. //As before, name may be already filled.
  1669. name[0] = '\0';
  1670. } else {
  1671. clif_displaymessage(fd, msg_txt(sd,80)); // Give a display name and monster name/id please.
  1672. return -1;
  1673. }
  1674. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  1675. mob_id = mobdb_checkid(atoi(monster));
  1676. if (mob_id == 0) {
  1677. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  1678. return -1;
  1679. }
  1680. if (mob_id == MOBID_EMPERIUM) {
  1681. clif_displaymessage(fd, msg_txt(sd,83)); // Monster 'Emperium' cannot be spawned.
  1682. return -1;
  1683. }
  1684. if (number <= 0)
  1685. number = 1;
  1686. if( !name[0] )
  1687. strcpy(name, "--ja--");
  1688. // 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
  1689. if (battle_config.atc_spawn_quantity_limit && number > battle_config.atc_spawn_quantity_limit)
  1690. number = battle_config.atc_spawn_quantity_limit;
  1691. if (strcmp(command+1, "monstersmall") == 0)
  1692. size = SZ_MEDIUM; // This is just gorgeous [mkbu95]
  1693. else if (strcmp(command+1, "monsterbig") == 0)
  1694. size = SZ_BIG;
  1695. else
  1696. size = SZ_SMALL;
  1697. if (battle_config.etc_log)
  1698. 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);
  1699. count = 0;
  1700. range = (int)sqrt((float)number) +2; // calculation of an odd number (+ 4 area around)
  1701. for (i = 0; i < number; i++) {
  1702. map_search_freecell(&sd->bl, 0, &mx, &my, range, range, 0);
  1703. k = mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, eventname, size, AI_NONE);
  1704. count += (k != 0) ? 1 : 0;
  1705. }
  1706. if (count != 0)
  1707. if (number == count)
  1708. clif_displaymessage(fd, msg_txt(sd,39)); // All monster summoned!
  1709. else {
  1710. sprintf(atcmd_output, msg_txt(sd,240), count); // %d monster(s) summoned!
  1711. clif_displaymessage(fd, atcmd_output);
  1712. }
  1713. else {
  1714. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  1715. return -1;
  1716. }
  1717. return 0;
  1718. }
  1719. /*==========================================
  1720. *
  1721. *------------------------------------------*/
  1722. static int atkillmonster_sub(struct block_list *bl, va_list ap)
  1723. {
  1724. struct mob_data *md;
  1725. int flag;
  1726. nullpo_ret(md=(struct mob_data *)bl);
  1727. flag = va_arg(ap, int);
  1728. if (md->guardian_data)
  1729. return 0; //Do not touch WoE mobs!
  1730. if (flag)
  1731. status_zap(bl,md->status.hp, 0);
  1732. else
  1733. status_kill(bl);
  1734. return 1;
  1735. }
  1736. ACMD_FUNC(killmonster)
  1737. {
  1738. int map_id, drop_flag;
  1739. char map_name[MAP_NAME_LENGTH_EXT];
  1740. nullpo_retr(-1, sd);
  1741. memset(map_name, '\0', sizeof(map_name));
  1742. if (!message || !*message || sscanf(message, "%15s", map_name) < 1)
  1743. map_id = sd->bl.m;
  1744. else {
  1745. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1746. map_id = sd->bl.m;
  1747. }
  1748. drop_flag = strcmp(command+1, "killmonster2");
  1749. map_foreachinmap(atkillmonster_sub, map_id, BL_MOB, -drop_flag);
  1750. clif_displaymessage(fd, msg_txt(sd,165)); // All monsters killed!
  1751. return 0;
  1752. }
  1753. /*==========================================
  1754. *
  1755. *------------------------------------------*/
  1756. ACMD_FUNC(refine)
  1757. {
  1758. int i,j, position = 0, refine = 0, current_position, final_refine;
  1759. int count;
  1760. nullpo_retr(-1, sd);
  1761. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1762. if (!message || !*message || sscanf(message, "%d %d", &position, &refine) < 2) {
  1763. clif_displaymessage(fd, msg_txt(sd,996)); // Please enter a position and an amount (usage: @refine <equip position> <+/- amount>).
  1764. sprintf(atcmd_output, msg_txt(sd,997), EQP_HEAD_LOW); // %d: Lower Headgear
  1765. clif_displaymessage(fd, atcmd_output);
  1766. sprintf(atcmd_output, msg_txt(sd,998), EQP_HAND_R); // %d: Right Hand
  1767. clif_displaymessage(fd, atcmd_output);
  1768. sprintf(atcmd_output, msg_txt(sd,999), EQP_GARMENT); // %d: Garment
  1769. clif_displaymessage(fd, atcmd_output);
  1770. sprintf(atcmd_output, msg_txt(sd,1000), EQP_ACC_L); // %d: Left Accessory
  1771. clif_displaymessage(fd, atcmd_output);
  1772. sprintf(atcmd_output, msg_txt(sd,1001), EQP_ARMOR); // %d: Body Armor
  1773. clif_displaymessage(fd, atcmd_output);
  1774. sprintf(atcmd_output, msg_txt(sd,1002), EQP_HAND_L); // %d: Left Hand
  1775. clif_displaymessage(fd, atcmd_output);
  1776. sprintf(atcmd_output, msg_txt(sd,1003), EQP_SHOES); // %d: Shoes
  1777. clif_displaymessage(fd, atcmd_output);
  1778. sprintf(atcmd_output, msg_txt(sd,1004), EQP_ACC_R); // %d: Right Accessory
  1779. clif_displaymessage(fd, atcmd_output);
  1780. sprintf(atcmd_output, msg_txt(sd,1005), EQP_HEAD_TOP); // %d: Top Headgear
  1781. clif_displaymessage(fd, atcmd_output);
  1782. sprintf(atcmd_output, msg_txt(sd,1006), EQP_HEAD_MID); // %d: Mid Headgear
  1783. clif_displaymessage(fd, atcmd_output);
  1784. return -1;
  1785. }
  1786. refine = cap_value(refine, -MAX_REFINE, MAX_REFINE);
  1787. count = 0;
  1788. for (j = 0; j < EQI_MAX-1; j++) {
  1789. if ((i = sd->equip_index[j]) < 0)
  1790. continue;
  1791. if(j == EQI_HAND_R && sd->equip_index[EQI_HAND_L] == i)
  1792. continue;
  1793. if(j == EQI_HEAD_MID && sd->equip_index[EQI_HEAD_LOW] == i)
  1794. continue;
  1795. if(j == EQI_HEAD_TOP && (sd->equip_index[EQI_HEAD_MID] == i || sd->equip_index[EQI_HEAD_LOW] == i))
  1796. continue;
  1797. if(position && !(sd->status.inventory[i].equip & position))
  1798. continue;
  1799. final_refine = cap_value(sd->status.inventory[i].refine + refine, 0, MAX_REFINE);
  1800. if (sd->status.inventory[i].refine != final_refine) {
  1801. sd->status.inventory[i].refine = final_refine;
  1802. current_position = sd->status.inventory[i].equip;
  1803. pc_unequipitem(sd, i, 3);
  1804. clif_refine(fd, 0, i, sd->status.inventory[i].refine);
  1805. clif_delitem(sd, i, 1, 3);
  1806. clif_additem(sd, i, 1, 0);
  1807. pc_equipitem(sd, i, current_position);
  1808. clif_misceffect(&sd->bl, 3);
  1809. count++;
  1810. }
  1811. }
  1812. if (count == 0)
  1813. clif_displaymessage(fd, msg_txt(sd,166)); // No item has been refined.
  1814. else if (count == 1)
  1815. clif_displaymessage(fd, msg_txt(sd,167)); // 1 item has been refined.
  1816. else {
  1817. sprintf(atcmd_output, msg_txt(sd,168), count); // %d items have been refined.
  1818. clif_displaymessage(fd, atcmd_output);
  1819. }
  1820. return 0;
  1821. }
  1822. /*==========================================
  1823. *
  1824. *------------------------------------------*/
  1825. ACMD_FUNC(produce)
  1826. {
  1827. char item_name[100];
  1828. int item_id, attribute = 0, star = 0;
  1829. struct item_data *item_data;
  1830. struct item tmp_item;
  1831. nullpo_retr(-1, sd);
  1832. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1833. memset(item_name, '\0', sizeof(item_name));
  1834. if (!message || !*message || (
  1835. sscanf(message, "\"%99[^\"]\" %d %d", item_name, &attribute, &star) < 1 &&
  1836. sscanf(message, "%99s %d %d", item_name, &attribute, &star) < 1
  1837. )) {
  1838. clif_displaymessage(fd, msg_txt(sd,1007)); // Please enter at least one item name/ID (usage: @produce <equip name/ID> <element> <# of very's>).
  1839. return -1;
  1840. }
  1841. if ( (item_data = itemdb_searchname(item_name)) == NULL &&
  1842. (item_data = itemdb_exists(atoi(item_name))) == NULL ) {
  1843. clif_displaymessage(fd, msg_txt(sd,170)); //This item is not an equipment.
  1844. return -1;
  1845. }
  1846. item_id = item_data->nameid;
  1847. if (itemdb_isequip2(item_data)) {
  1848. int flag = 0;
  1849. if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
  1850. attribute = ATTRIBUTE_NORMAL;
  1851. if (star < MIN_STAR || star > MAX_STAR)
  1852. star = 0;
  1853. memset(&tmp_item, 0, sizeof tmp_item);
  1854. tmp_item.nameid = item_id;
  1855. tmp_item.amount = 1;
  1856. tmp_item.identify = 1;
  1857. tmp_item.card[0] = CARD0_FORGE;
  1858. tmp_item.card[1] = item_data->type==IT_WEAPON?
  1859. ((star*5) << 8) + attribute:0;
  1860. tmp_item.card[2] = GetWord(sd->status.char_id, 0);
  1861. tmp_item.card[3] = GetWord(sd->status.char_id, 1);
  1862. clif_produceeffect(sd, 0, item_id);
  1863. clif_misceffect(&sd->bl, 3);
  1864. if ((flag = pc_additem(sd, &tmp_item, 1, LOG_TYPE_COMMAND)))
  1865. clif_additem(sd, 0, 0, flag);
  1866. } else {
  1867. sprintf(atcmd_output, msg_txt(sd,169), item_id, item_data->name); // The item (%d: '%s') is not equipable.
  1868. clif_displaymessage(fd, atcmd_output);
  1869. return -1;
  1870. }
  1871. return 0;
  1872. }
  1873. /*==========================================
  1874. *
  1875. *------------------------------------------*/
  1876. ACMD_FUNC(memo)
  1877. {
  1878. int position = 0;
  1879. nullpo_retr(-1, sd);
  1880. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1881. if( !message || !*message || sscanf(message, "%d", &position) < 1 )
  1882. {
  1883. int i;
  1884. clif_displaymessage(sd->fd, msg_txt(sd,668));
  1885. for( i = 0; i < MAX_MEMOPOINTS; i++ )
  1886. {
  1887. if( sd->status.memo_point[i].map )
  1888. 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);
  1889. else
  1890. sprintf(atcmd_output, msg_txt(sd,171), i); // %d - void
  1891. clif_displaymessage(sd->fd, atcmd_output);
  1892. }
  1893. return 0;
  1894. }
  1895. if( position < 0 || position >= MAX_MEMOPOINTS )
  1896. {
  1897. sprintf(atcmd_output, msg_txt(sd,1008), 0, MAX_MEMOPOINTS-1); // Please enter a valid position (usage: @memo <memo_position:%d-%d>).
  1898. clif_displaymessage(fd, atcmd_output);
  1899. return -1;
  1900. }
  1901. pc_memo(sd, position);
  1902. return 0;
  1903. }
  1904. /*==========================================
  1905. *
  1906. *------------------------------------------*/
  1907. ACMD_FUNC(gat)
  1908. {
  1909. int y;
  1910. nullpo_retr(-1, sd);
  1911. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1912. for (y = 2; y >= -2; y--) {
  1913. sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
  1914. map[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y,
  1915. map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE),
  1916. map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE),
  1917. map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE),
  1918. map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE),
  1919. map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE));
  1920. clif_displaymessage(fd, atcmd_output);
  1921. }
  1922. return 0;
  1923. }
  1924. /*==========================================
  1925. *
  1926. *------------------------------------------*/
  1927. ACMD_FUNC(displaystatus)
  1928. {
  1929. int i, type, flag, tick, val1 = 0, val2 = 0, val3 = 0;
  1930. nullpo_retr(-1, sd);
  1931. if (!message || !*message || (i = sscanf(message, "%d %d %d %d %d %d", &type, &flag, &tick, &val1, &val2, &val3)) < 1) {
  1932. clif_displaymessage(fd, msg_txt(sd,1009)); // Please enter a status type/flag (usage: @displaystatus <status type> <flag> <tick> {<val1> {<val2> {<val3>}}}).
  1933. return -1;
  1934. }
  1935. if (i < 2) flag = 1;
  1936. if (i < 3) tick = 0;
  1937. clif_status_change(&sd->bl, type, flag, tick, val1, val2, val3);
  1938. return 0;
  1939. }
  1940. /*==========================================
  1941. * @stpoint (Rewritten by [Yor])
  1942. *------------------------------------------*/
  1943. ACMD_FUNC(statuspoint)
  1944. {
  1945. int point;
  1946. unsigned int new_status_point;
  1947. if (!message || !*message || (point = atoi(message)) == 0) {
  1948. clif_displaymessage(fd, msg_txt(sd,1010)); // Please enter a number (usage: @stpoint <number of points>).
  1949. return -1;
  1950. }
  1951. if(point < 0)
  1952. {
  1953. if(sd->status.status_point < (unsigned int)(-point))
  1954. {
  1955. new_status_point = 0;
  1956. }
  1957. else
  1958. {
  1959. new_status_point = sd->status.status_point + point;
  1960. }
  1961. }
  1962. else if(UINT_MAX - sd->status.status_point < (unsigned int)point)
  1963. {
  1964. new_status_point = UINT_MAX;
  1965. }
  1966. else
  1967. {
  1968. new_status_point = sd->status.status_point + point;
  1969. }
  1970. if (new_status_point != sd->status.status_point) {
  1971. sd->status.status_point = new_status_point;
  1972. clif_updatestatus(sd, SP_STATUSPOINT);
  1973. clif_displaymessage(fd, msg_txt(sd,174)); // Number of status points changed.
  1974. } else {
  1975. if (point < 0)
  1976. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  1977. else
  1978. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  1979. return -1;
  1980. }
  1981. return 0;
  1982. }
  1983. /*==========================================
  1984. * @skpoint (Rewritten by [Yor])
  1985. *------------------------------------------*/
  1986. ACMD_FUNC(skillpoint)
  1987. {
  1988. int point;
  1989. unsigned int new_skill_point;
  1990. nullpo_retr(-1, sd);
  1991. if (!message || !*message || (point = atoi(message)) == 0) {
  1992. clif_displaymessage(fd, msg_txt(sd,1011)); // Please enter a number (usage: @skpoint <number of points>).
  1993. return -1;
  1994. }
  1995. if(point < 0)
  1996. {
  1997. if(sd->status.skill_point < (unsigned int)(-point))
  1998. {
  1999. new_skill_point = 0;
  2000. }
  2001. else
  2002. {
  2003. new_skill_point = sd->status.skill_point + point;
  2004. }
  2005. }
  2006. else if(UINT_MAX - sd->status.skill_point < (unsigned int)point)
  2007. {
  2008. new_skill_point = UINT_MAX;
  2009. }
  2010. else
  2011. {
  2012. new_skill_point = sd->status.skill_point + point;
  2013. }
  2014. if (new_skill_point != sd->status.skill_point) {
  2015. sd->status.skill_point = new_skill_point;
  2016. clif_updatestatus(sd, SP_SKILLPOINT);
  2017. clif_displaymessage(fd, msg_txt(sd,175)); // Number of skill points changed.
  2018. } else {
  2019. if (point < 0)
  2020. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2021. else
  2022. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2023. return -1;
  2024. }
  2025. return 0;
  2026. }
  2027. /*==========================================
  2028. * @zeny
  2029. *------------------------------------------*/
  2030. ACMD_FUNC(zeny)
  2031. {
  2032. int zeny=0, ret=-1;
  2033. nullpo_retr(-1, sd);
  2034. if (!message || !*message || (zeny = atoi(message)) == 0) {
  2035. clif_displaymessage(fd, msg_txt(sd,1012)); // Please enter an amount (usage: @zeny <amount>).
  2036. return -1;
  2037. }
  2038. if(zeny > 0){
  2039. if((ret=pc_getzeny(sd,zeny,LOG_TYPE_COMMAND,NULL)) == 1)
  2040. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2041. }
  2042. else {
  2043. if( sd->status.zeny < -zeny ) zeny = -sd->status.zeny;
  2044. if((ret=pc_payzeny(sd,-zeny,LOG_TYPE_COMMAND,NULL)) == 1)
  2045. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2046. }
  2047. if(!ret) clif_displaymessage(fd, msg_txt(sd,176)); //ret=0 mean cmd success
  2048. return 0;
  2049. }
  2050. /*==========================================
  2051. *
  2052. *------------------------------------------*/
  2053. ACMD_FUNC(param)
  2054. {
  2055. int i, value = 0, new_value, max;
  2056. const char* param[] = { "str", "agi", "vit", "int", "dex", "luk" };
  2057. short* status[6];
  2058. //we don't use direct initialization because it isn't part of the c standard.
  2059. nullpo_retr(-1, sd);
  2060. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2061. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  2062. clif_displaymessage(fd, msg_txt(sd,1013)); // Please enter a valid value (usage: @str/@agi/@vit/@int/@dex/@luk <+/-adjustment>).
  2063. return -1;
  2064. }
  2065. ARR_FIND( 0, ARRAYLENGTH(param), i, strcmpi(command+1, param[i]) == 0 );
  2066. if( i == ARRAYLENGTH(param) || i > MAX_STATUS_TYPE) { // normally impossible...
  2067. clif_displaymessage(fd, msg_txt(sd,1013)); // Please enter a valid value (usage: @str/@agi/@vit/@int/@dex/@luk <+/-adjustment>).
  2068. return -1;
  2069. }
  2070. status[0] = &sd->status.str;
  2071. status[1] = &sd->status.agi;
  2072. status[2] = &sd->status.vit;
  2073. status[3] = &sd->status.int_;
  2074. status[4] = &sd->status.dex;
  2075. status[5] = &sd->status.luk;
  2076. if( battle_config.atcommand_max_stat_bypass )
  2077. max = SHRT_MAX;
  2078. else
  2079. max = pc_maxparameter(sd);
  2080. if(value < 0 && *status[i] <= -value) {
  2081. new_value = 1;
  2082. } else if(max - *status[i] < value) {
  2083. new_value = max;
  2084. } else {
  2085. new_value = *status[i] + value;
  2086. }
  2087. if (new_value != *status[i]) {
  2088. *status[i] = new_value;
  2089. clif_updatestatus(sd, SP_STR + i);
  2090. clif_updatestatus(sd, SP_USTR + i);
  2091. status_calc_pc(sd, 0);
  2092. clif_displaymessage(fd, msg_txt(sd,42)); // Stat changed.
  2093. } else {
  2094. if (value < 0)
  2095. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2096. else
  2097. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2098. return -1;
  2099. }
  2100. return 0;
  2101. }
  2102. /*==========================================
  2103. * Stat all by fritz (rewritten by [Yor])
  2104. *------------------------------------------*/
  2105. ACMD_FUNC(stat_all)
  2106. {
  2107. int index, count, value, max, new_value;
  2108. short* status[6];
  2109. //we don't use direct initialization because it isn't part of the c standard.
  2110. nullpo_retr(-1, sd);
  2111. status[0] = &sd->status.str;
  2112. status[1] = &sd->status.agi;
  2113. status[2] = &sd->status.vit;
  2114. status[3] = &sd->status.int_;
  2115. status[4] = &sd->status.dex;
  2116. status[5] = &sd->status.luk;
  2117. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  2118. value = pc_maxparameter(sd);
  2119. max = pc_maxparameter(sd);
  2120. } else {
  2121. if( battle_config.atcommand_max_stat_bypass )
  2122. max = SHRT_MAX;
  2123. else
  2124. max = pc_maxparameter(sd);
  2125. }
  2126. count = 0;
  2127. for (index = 0; index < ARRAYLENGTH(status); index++) {
  2128. if (value > 0 && *status[index] > max - value)
  2129. new_value = max;
  2130. else if (value < 0 && *status[index] <= -value)
  2131. new_value = 1;
  2132. else
  2133. new_value = *status[index] +value;
  2134. if (new_value != (int)*status[index]) {
  2135. *status[index] = new_value;
  2136. clif_updatestatus(sd, SP_STR + index);
  2137. clif_updatestatus(sd, SP_USTR + index);
  2138. count++;
  2139. }
  2140. }
  2141. if (count > 0) { // if at least 1 stat modified
  2142. status_calc_pc(sd, 0);
  2143. clif_displaymessage(fd, msg_txt(sd,84)); // All stats changed!
  2144. } else {
  2145. if (value < 0)
  2146. clif_displaymessage(fd, msg_txt(sd,177)); // You cannot decrease that stat anymore.
  2147. else
  2148. clif_displaymessage(fd, msg_txt(sd,178)); // You cannot increase that stat anymore.
  2149. return -1;
  2150. }
  2151. return 0;
  2152. }
  2153. /*==========================================
  2154. *
  2155. *------------------------------------------*/
  2156. ACMD_FUNC(guildlevelup)
  2157. {
  2158. int level = 0;
  2159. short added_level;
  2160. struct guild *guild_info;
  2161. nullpo_retr(-1, sd);
  2162. if (!message || !*message || sscanf(message, "%d", &level) < 1 || level == 0) {
  2163. clif_displaymessage(fd, msg_txt(sd,1014)); // Please enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).
  2164. return -1;
  2165. }
  2166. if (sd->status.guild_id <= 0 || (guild_info = sd->guild) == NULL) {
  2167. clif_displaymessage(fd, msg_txt(sd,43)); // You're not in a guild.
  2168. return -1;
  2169. }
  2170. //if (strcmp(sd->status.name, guild_info->master) != 0) {
  2171. // clif_displaymessage(fd, msg_txt(sd,44)); // You're not the master of your guild.
  2172. // return -1;
  2173. //}
  2174. added_level = (short)level;
  2175. if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild_lv))) // fix positiv overflow
  2176. added_level = (short)MAX_GUILDLEVEL - guild_info->guild_lv;
  2177. else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild_lv))) // fix negativ overflow
  2178. added_level = 1 - guild_info->guild_lv;
  2179. if (added_level != 0) {
  2180. intif_guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, sizeof(added_level));
  2181. clif_displaymessage(fd, msg_txt(sd,179)); // Guild level changed.
  2182. } else {
  2183. clif_displaymessage(fd, msg_txt(sd,45)); // Guild level change failed.
  2184. return -1;
  2185. }
  2186. return 0;
  2187. }
  2188. /*==========================================
  2189. *
  2190. *------------------------------------------*/
  2191. ACMD_FUNC(makeegg)
  2192. {
  2193. struct item_data *item_data;
  2194. int id, pet_id;
  2195. nullpo_retr(-1, sd);
  2196. if (!message || !*message) {
  2197. clif_displaymessage(fd, msg_txt(sd,1015)); // Please enter a monster/egg name/ID (usage: @makeegg <pet>).
  2198. return -1;
  2199. }
  2200. if ((item_data = itemdb_searchname(message)) != NULL) // for egg name
  2201. id = item_data->nameid;
  2202. else
  2203. if ((id = mobdb_searchname(message)) != 0) // for monster name
  2204. ;
  2205. else
  2206. id = atoi(message);
  2207. pet_id = search_petDB_index(id, PET_CLASS);
  2208. if (pet_id < 0)
  2209. pet_id = search_petDB_index(id, PET_EGG);
  2210. if (pet_id >= 0) {
  2211. sd->catch_target_class = pet_db[pet_id].class_;
  2212. intif_create_pet(
  2213. sd->status.account_id, sd->status.char_id,
  2214. (short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv,
  2215. (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
  2216. 100, 0, 1, pet_db[pet_id].jname);
  2217. } else {
  2218. clif_displaymessage(fd, msg_txt(sd,180)); // The monster/egg name/id doesn't exist.
  2219. return -1;
  2220. }
  2221. return 0;
  2222. }
  2223. /*==========================================
  2224. *
  2225. *------------------------------------------*/
  2226. ACMD_FUNC(hatch)
  2227. {
  2228. nullpo_retr(-1, sd);
  2229. if (sd->status.pet_id <= 0)
  2230. clif_sendegg(sd);
  2231. else {
  2232. clif_displaymessage(fd, msg_txt(sd,181)); // You already have a pet.
  2233. return -1;
  2234. }
  2235. return 0;
  2236. }
  2237. /*==========================================
  2238. *
  2239. *------------------------------------------*/
  2240. ACMD_FUNC(petfriendly)
  2241. {
  2242. int friendly;
  2243. struct pet_data *pd;
  2244. nullpo_retr(-1, sd);
  2245. if (!message || !*message || (friendly = atoi(message)) < 0) {
  2246. clif_displaymessage(fd, msg_txt(sd,1016)); // Please enter a valid value (usage: @petfriendly <0-1000>).
  2247. return -1;
  2248. }
  2249. pd = sd->pd;
  2250. if (!pd) {
  2251. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2252. return -1;
  2253. }
  2254. if (friendly < 0 || friendly > 1000)
  2255. {
  2256. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  2257. return -1;
  2258. }
  2259. if (friendly == pd->pet.intimate) {
  2260. clif_displaymessage(fd, msg_txt(sd,183)); // Pet intimacy is already at maximum.
  2261. return -1;
  2262. }
  2263. pet_set_intimate(pd, friendly);
  2264. clif_send_petstatus(sd);
  2265. clif_displaymessage(fd, msg_txt(sd,182)); // Pet intimacy changed.
  2266. return 0;
  2267. }
  2268. /*==========================================
  2269. *
  2270. *------------------------------------------*/
  2271. ACMD_FUNC(pethungry)
  2272. {
  2273. int hungry;
  2274. struct pet_data *pd;
  2275. nullpo_retr(-1, sd);
  2276. if (!message || !*message || (hungry = atoi(message)) < 0) {
  2277. clif_displaymessage(fd, msg_txt(sd,1017)); // Please enter a valid number (usage: @pethungry <0-100>).
  2278. return -1;
  2279. }
  2280. pd = sd->pd;
  2281. if (!sd->status.pet_id || !pd) {
  2282. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2283. return -1;
  2284. }
  2285. if (hungry < 0 || hungry > 100) {
  2286. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  2287. return -1;
  2288. }
  2289. if (hungry == pd->pet.hungry) {
  2290. clif_displaymessage(fd, msg_txt(sd,186)); // Pet hunger is already at maximum.
  2291. return -1;
  2292. }
  2293. pd->pet.hungry = hungry;
  2294. clif_send_petstatus(sd);
  2295. clif_displaymessage(fd, msg_txt(sd,185)); // Pet hunger changed.
  2296. return 0;
  2297. }
  2298. /*==========================================
  2299. *
  2300. *------------------------------------------*/
  2301. ACMD_FUNC(petrename)
  2302. {
  2303. struct pet_data *pd;
  2304. nullpo_retr(-1, sd);
  2305. if (!sd->status.pet_id || !sd->pd) {
  2306. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2307. return -1;
  2308. }
  2309. pd = sd->pd;
  2310. if (!pd->pet.rename_flag) {
  2311. clif_displaymessage(fd, msg_txt(sd,188)); // You can already rename your pet.
  2312. return -1;
  2313. }
  2314. pd->pet.rename_flag = 0;
  2315. intif_save_petdata(sd->status.account_id, &pd->pet);
  2316. clif_send_petstatus(sd);
  2317. clif_displaymessage(fd, msg_txt(sd,187)); // You can now rename your pet.
  2318. return 0;
  2319. }
  2320. /*==========================================
  2321. *
  2322. *------------------------------------------*/
  2323. ACMD_FUNC(recall) {
  2324. struct map_session_data *pl_sd = NULL;
  2325. nullpo_retr(-1, sd);
  2326. if (!message || !*message) {
  2327. clif_displaymessage(fd, msg_txt(sd,1018)); // Please enter a player name (usage: @recall <char name/ID>).
  2328. return -1;
  2329. }
  2330. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  2331. {
  2332. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  2333. return -1;
  2334. }
  2335. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  2336. {
  2337. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level doesn't authorize you to preform this action on the specified player.
  2338. return -1;
  2339. }
  2340. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2341. clif_displaymessage(fd, msg_txt(sd,1019)); // You are not authorized to warp someone to this map.
  2342. return -1;
  2343. }
  2344. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2345. clif_displaymessage(fd, msg_txt(sd,1020)); // You are not authorized to warp this player from their map.
  2346. return -1;
  2347. }
  2348. if (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y) {
  2349. return -1;
  2350. }
  2351. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  2352. sprintf(atcmd_output, msg_txt(sd,46), pl_sd->status.name); // %s recalled!
  2353. clif_displaymessage(fd, atcmd_output);
  2354. return 0;
  2355. }
  2356. /*==========================================
  2357. * charblock command (usage: charblock <player_name>)
  2358. * This command do a definitiv ban on a player
  2359. *------------------------------------------*/
  2360. ACMD_FUNC(char_block)
  2361. {
  2362. nullpo_retr(-1, sd);
  2363. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2364. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2365. clif_displaymessage(fd, msg_txt(sd,1021)); // Please enter a player name (usage: @charblock/@block <char name>).
  2366. return -1;
  2367. }
  2368. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block
  2369. clif_displaymessage(fd, msg_txt(sd,88)); // Character name sent to char-server to ask it.
  2370. return 0;
  2371. }
  2372. /*==========================================
  2373. * charban command (usage: charban <time> <player_name>)
  2374. * This command do a limited ban on a player
  2375. * Time is done as follows:
  2376. * Adjustment value (-1, 1, +1, etc...)
  2377. * Modified element:
  2378. * a or y: year
  2379. * m: month
  2380. * j or d: day
  2381. * h: hour
  2382. * mn: minute
  2383. * s: second
  2384. * <example> @ban +1m-2mn1s-6y test_player
  2385. * this example adds 1 month and 1 second, and substracts 2 minutes and 6 years at the same time.
  2386. *------------------------------------------*/
  2387. ACMD_FUNC(char_ban)
  2388. {
  2389. char * modif_p;
  2390. int year, month, day, hour, minute, second, value;
  2391. time_t timestamp;
  2392. struct tm *tmtime;
  2393. nullpo_retr(-1, sd);
  2394. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2395. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2396. if (!message || !*message || sscanf(message, "%255s %23[^\n]", atcmd_output, atcmd_player_name) < 2) {
  2397. clif_displaymessage(fd, msg_txt(sd,1022)); // Please enter ban time and a player name (usage: @charban/@ban/@banish/@charbanish <time> <char name>).
  2398. return -1;
  2399. }
  2400. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  2401. modif_p = atcmd_output;
  2402. year = month = day = hour = minute = second = 0;
  2403. while (modif_p[0] != '\0') {
  2404. value = atoi(modif_p);
  2405. if (value == 0)
  2406. modif_p++;
  2407. else {
  2408. if (modif_p[0] == '-' || modif_p[0] == '+')
  2409. modif_p++;
  2410. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  2411. modif_p++;
  2412. if (modif_p[0] == 's') {
  2413. second = value;
  2414. modif_p++;
  2415. } else if (modif_p[0] == 'n') {
  2416. minute = value;
  2417. modif_p++;
  2418. } else if (modif_p[0] == 'm' && modif_p[1] == 'n') {
  2419. minute = value;
  2420. modif_p = modif_p + 2;
  2421. } else if (modif_p[0] == 'h') {
  2422. hour = value;
  2423. modif_p++;
  2424. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  2425. day = value;
  2426. modif_p++;
  2427. } else if (modif_p[0] == 'm') {
  2428. month = value;
  2429. modif_p++;
  2430. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  2431. year = value;
  2432. modif_p++;
  2433. } else if (modif_p[0] != '\0') {
  2434. modif_p++;
  2435. }
  2436. }
  2437. }
  2438. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0 && second == 0) {
  2439. clif_displaymessage(fd, msg_txt(sd,85)); // Invalid time for ban command.
  2440. return -1;
  2441. }
  2442. /**
  2443. * We now check if you can adjust the ban to negative (and if this is the case)
  2444. **/
  2445. timestamp = time(NULL);
  2446. tmtime = localtime(&timestamp);
  2447. tmtime->tm_year = tmtime->tm_year + year;
  2448. tmtime->tm_mon = tmtime->tm_mon + month;
  2449. tmtime->tm_mday = tmtime->tm_mday + day;
  2450. tmtime->tm_hour = tmtime->tm_hour + hour;
  2451. tmtime->tm_min = tmtime->tm_min + minute;
  2452. tmtime->tm_sec = tmtime->tm_sec + second;
  2453. timestamp = mktime(tmtime);
  2454. if( timestamp <= time(NULL) && !pc_can_use_command(sd, "unban", COMMAND_ATCOMMAND) ) {
  2455. clif_displaymessage(fd,msg_txt(sd,1023)); // You are not allowed to reduce the length of a ban.
  2456. return -1;
  2457. }
  2458. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 2, year, month, day, hour, minute, second); // type: 2 - ban
  2459. clif_displaymessage(fd, msg_txt(sd,88)); // Character name sent to char-server to ask it.
  2460. return 0;
  2461. }
  2462. /*==========================================
  2463. * charunblock command (usage: charunblock <player_name>)
  2464. *------------------------------------------*/
  2465. ACMD_FUNC(char_unblock)
  2466. {
  2467. nullpo_retr(-1, sd);
  2468. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2469. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2470. clif_displaymessage(fd, msg_txt(sd,1024)); // Please enter a player name (usage: @charunblock <char name>).
  2471. return -1;
  2472. }
  2473. // send answer to login server via char-server
  2474. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 3, 0, 0, 0, 0, 0, 0); // type: 3 - unblock
  2475. clif_displaymessage(fd, msg_txt(sd,88)); // Character name sent to char-server to ask it.
  2476. return 0;
  2477. }
  2478. /*==========================================
  2479. * charunban command (usage: charunban <player_name>)
  2480. *------------------------------------------*/
  2481. ACMD_FUNC(char_unban)
  2482. {
  2483. nullpo_retr(-1, sd);
  2484. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2485. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2486. clif_displaymessage(fd, msg_txt(sd,1025)); // Please enter a player name (usage: @charunban <char name>).
  2487. return -1;
  2488. }
  2489. // send answer to login server via char-server
  2490. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 4, 0, 0, 0, 0, 0, 0); // type: 4 - unban
  2491. clif_displaymessage(fd, msg_txt(sd,88)); // Character name sent to char-server to ask it.
  2492. return 0;
  2493. }
  2494. /*==========================================
  2495. *
  2496. *------------------------------------------*/
  2497. ACMD_FUNC(night)
  2498. {
  2499. nullpo_retr(-1, sd);
  2500. if (night_flag != 1) {
  2501. map_night_timer(night_timer_tid, 0, 0, 1);
  2502. } else {
  2503. clif_displaymessage(fd, msg_txt(sd,89)); // Night mode is already enabled.
  2504. return -1;
  2505. }
  2506. return 0;
  2507. }
  2508. /*==========================================
  2509. *
  2510. *------------------------------------------*/
  2511. ACMD_FUNC(day)
  2512. {
  2513. nullpo_retr(-1, sd);
  2514. if (night_flag != 0) {
  2515. map_day_timer(day_timer_tid, 0, 0, 1);
  2516. } else {
  2517. clif_displaymessage(fd, msg_txt(sd,90)); // Day mode is already enabled.
  2518. return -1;
  2519. }
  2520. return 0;
  2521. }
  2522. /*==========================================
  2523. *
  2524. *------------------------------------------*/
  2525. ACMD_FUNC(doom)
  2526. {
  2527. struct map_session_data* pl_sd;
  2528. struct s_mapiterator* iter;
  2529. nullpo_retr(-1, sd);
  2530. iter = mapit_getallusers();
  2531. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2532. {
  2533. if (pl_sd->fd != fd && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  2534. {
  2535. status_kill(&pl_sd->bl);
  2536. clif_specialeffect(&pl_sd->bl,450,AREA);
  2537. clif_displaymessage(pl_sd->fd, msg_txt(sd,61)); // The holy messenger has given judgement.
  2538. }
  2539. }
  2540. mapit_free(iter);
  2541. clif_displaymessage(fd, msg_txt(sd,62)); // Judgement was made.
  2542. return 0;
  2543. }
  2544. /*==========================================
  2545. *
  2546. *------------------------------------------*/
  2547. ACMD_FUNC(doommap)
  2548. {
  2549. struct map_session_data* pl_sd;
  2550. struct s_mapiterator* iter;
  2551. nullpo_retr(-1, sd);
  2552. iter = mapit_getallusers();
  2553. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2554. {
  2555. if (pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  2556. {
  2557. status_kill(&pl_sd->bl);
  2558. clif_specialeffect(&pl_sd->bl,450,AREA);
  2559. clif_displaymessage(pl_sd->fd, msg_txt(sd,61)); // The holy messenger has given judgement.
  2560. }
  2561. }
  2562. mapit_free(iter);
  2563. clif_displaymessage(fd, msg_txt(sd,62)); // Judgement was made.
  2564. return 0;
  2565. }
  2566. /*==========================================
  2567. *
  2568. *------------------------------------------*/
  2569. static void atcommand_raise_sub(struct map_session_data* sd) {
  2570. status_revive(&sd->bl, 100, 100);
  2571. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  2572. clif_displaymessage(sd->fd, msg_txt(sd,63)); // Mercy has been shown.
  2573. }
  2574. /*==========================================
  2575. *
  2576. *------------------------------------------*/
  2577. ACMD_FUNC(raise)
  2578. {
  2579. struct map_session_data* pl_sd;
  2580. struct s_mapiterator* iter;
  2581. nullpo_retr(-1, sd);
  2582. iter = mapit_getallusers();
  2583. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2584. if( pc_isdead(pl_sd) )
  2585. atcommand_raise_sub(pl_sd);
  2586. mapit_free(iter);
  2587. clif_displaymessage(fd, msg_txt(sd,64)); // Mercy has been granted.
  2588. return 0;
  2589. }
  2590. /*==========================================
  2591. *
  2592. *------------------------------------------*/
  2593. ACMD_FUNC(raisemap)
  2594. {
  2595. struct map_session_data* pl_sd;
  2596. struct s_mapiterator* iter;
  2597. nullpo_retr(-1, sd);
  2598. iter = mapit_getallusers();
  2599. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2600. if (sd->bl.m == pl_sd->bl.m && pc_isdead(pl_sd) )
  2601. atcommand_raise_sub(pl_sd);
  2602. mapit_free(iter);
  2603. clif_displaymessage(fd, msg_txt(sd,64)); // Mercy has been granted.
  2604. return 0;
  2605. }
  2606. /*==========================================
  2607. *
  2608. *------------------------------------------*/
  2609. ACMD_FUNC(kick)
  2610. {
  2611. struct map_session_data *pl_sd;
  2612. nullpo_retr(-1, sd);
  2613. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2614. if (!message || !*message) {
  2615. clif_displaymessage(fd, msg_txt(sd,1026)); // Please enter a player name (usage: @kick <char name/ID>).
  2616. return -1;
  2617. }
  2618. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  2619. {
  2620. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  2621. return -1;
  2622. }
  2623. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  2624. {
  2625. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  2626. return -1;
  2627. }
  2628. clif_GM_kick(sd, pl_sd);
  2629. return 0;
  2630. }
  2631. /*==========================================
  2632. *
  2633. *------------------------------------------*/
  2634. ACMD_FUNC(kickall)
  2635. {
  2636. struct map_session_data* pl_sd;
  2637. struct s_mapiterator* iter;
  2638. nullpo_retr(-1, sd);
  2639. iter = mapit_getallusers();
  2640. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2641. {
  2642. if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kick only lower or same gm level
  2643. if (sd->status.account_id != pl_sd->status.account_id)
  2644. clif_GM_kick(NULL, pl_sd);
  2645. }
  2646. }
  2647. mapit_free(iter);
  2648. clif_displaymessage(fd, msg_txt(sd,195)); // All players have been kicked!
  2649. return 0;
  2650. }
  2651. /*==========================================
  2652. *
  2653. *------------------------------------------*/
  2654. ACMD_FUNC(allskill)
  2655. {
  2656. nullpo_retr(-1, sd);
  2657. pc_allskillup(sd); // all skills
  2658. sd->status.skill_point = 0; // 0 skill points
  2659. clif_updatestatus(sd, SP_SKILLPOINT); // update
  2660. clif_displaymessage(fd, msg_txt(sd,76)); // All skills have been added to your skill tree.
  2661. return 0;
  2662. }
  2663. /*==========================================
  2664. *
  2665. *------------------------------------------*/
  2666. ACMD_FUNC(questskill)
  2667. {
  2668. uint16 skill_id;
  2669. nullpo_retr(-1, sd);
  2670. if (!message || !*message || (skill_id = atoi(message)) <= 0)
  2671. {// also send a list of skills applicable to this command
  2672. const char* text;
  2673. // attempt to find the text corresponding to this command
  2674. text = atcommand_help_string( command );
  2675. // send the error message as always
  2676. clif_displaymessage(fd, msg_txt(sd,1027)); // Please enter a quest skill number.
  2677. if( text )
  2678. {// send the skill ID list associated with this command
  2679. clif_displaymessage( fd, text );
  2680. }
  2681. return -1;
  2682. }
  2683. if (skill_id >= MAX_SKILL_DB) {
  2684. clif_displaymessage(fd, msg_txt(sd,198)); // This skill number doesn't exist.
  2685. return -1;
  2686. }
  2687. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  2688. clif_displaymessage(fd, msg_txt(sd,197)); // This skill number doesn't exist or isn't a quest skill.
  2689. return -1;
  2690. }
  2691. if (pc_checkskill(sd, skill_id) > 0) {
  2692. clif_displaymessage(fd, msg_txt(sd,196)); // You already have this quest skill.
  2693. return -1;
  2694. }
  2695. pc_skill(sd, skill_id, 1, 0);
  2696. clif_displaymessage(fd, msg_txt(sd,70)); // You have learned the skill.
  2697. return 0;
  2698. }
  2699. /*==========================================
  2700. *
  2701. *------------------------------------------*/
  2702. ACMD_FUNC(lostskill)
  2703. {
  2704. uint16 skill_id;
  2705. nullpo_retr(-1, sd);
  2706. if (!message || !*message || (skill_id = atoi(message)) <= 0)
  2707. {// also send a list of skills applicable to this command
  2708. const char* text;
  2709. // attempt to find the text corresponding to this command
  2710. text = atcommand_help_string( command );
  2711. // send the error message as always
  2712. clif_displaymessage(fd, msg_txt(sd,1027)); // Please enter a quest skill number.
  2713. if( text )
  2714. {// send the skill ID list associated with this command
  2715. clif_displaymessage( fd, text );
  2716. }
  2717. return -1;
  2718. }
  2719. if (skill_id >= MAX_SKILL) {
  2720. clif_displaymessage(fd, msg_txt(sd,198)); // This skill number doesn't exist.
  2721. return -1;
  2722. }
  2723. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  2724. clif_displaymessage(fd, msg_txt(sd,197)); // This skill number doesn't exist or isn't a quest skill.
  2725. return -1;
  2726. }
  2727. if (pc_checkskill(sd, skill_id) == 0) {
  2728. clif_displaymessage(fd, msg_txt(sd,201)); // You don't have this quest skill.
  2729. return -1;
  2730. }
  2731. sd->status.skill[skill_id].lv = 0;
  2732. sd->status.skill[skill_id].flag = SKILL_FLAG_PERMANENT;
  2733. clif_deleteskill(sd,skill_id);
  2734. clif_displaymessage(fd, msg_txt(sd,71)); // You have forgotten the skill.
  2735. return 0;
  2736. }
  2737. /*==========================================
  2738. *
  2739. *------------------------------------------*/
  2740. ACMD_FUNC(spiritball)
  2741. {
  2742. int max_spiritballs;
  2743. int number;
  2744. nullpo_retr(-1, sd);
  2745. max_spiritballs = min(ARRAYLENGTH(sd->spirit_timer), 0x7FFF);
  2746. if( !message || !*message || (number = atoi(message)) < 0 || number > max_spiritballs )
  2747. {
  2748. char msg[CHAT_SIZE_MAX];
  2749. safesnprintf(msg, sizeof(msg), msg_txt(sd,1028), max_spiritballs); // Please enter a party name (usage: @party <party_name>).
  2750. clif_displaymessage(fd, msg);
  2751. return -1;
  2752. }
  2753. if( sd->spiritball > 0 )
  2754. pc_delspiritball(sd, sd->spiritball, 1);
  2755. sd->spiritball = number;
  2756. clif_spiritball(&sd->bl);
  2757. // no message, player can look the difference
  2758. return 0;
  2759. }
  2760. /*==========================================
  2761. *
  2762. *------------------------------------------*/
  2763. ACMD_FUNC(party)
  2764. {
  2765. char party[NAME_LENGTH];
  2766. nullpo_retr(-1, sd);
  2767. memset(party, '\0', sizeof(party));
  2768. if (!message || !*message || sscanf(message, "%23[^\n]", party) < 1) {
  2769. clif_displaymessage(fd, msg_txt(sd,1029)); // Please enter a party name (usage: @party <party_name>).
  2770. return -1;
  2771. }
  2772. party_create(sd, party, 0, 0);
  2773. return 0;
  2774. }
  2775. /*==========================================
  2776. *
  2777. *------------------------------------------*/
  2778. ACMD_FUNC(guild)
  2779. {
  2780. char guild[NAME_LENGTH];
  2781. int prev;
  2782. nullpo_retr(-1, sd);
  2783. memset(guild, '\0', sizeof(guild));
  2784. if (!message || !*message || sscanf(message, "%23[^\n]", guild) < 1) {
  2785. clif_displaymessage(fd, msg_txt(sd,1030)); // Please enter a guild name (usage: @guild <guild_name>).
  2786. return -1;
  2787. }
  2788. prev = battle_config.guild_emperium_check;
  2789. battle_config.guild_emperium_check = 0;
  2790. guild_create(sd, guild);
  2791. battle_config.guild_emperium_check = prev;
  2792. return 0;
  2793. }
  2794. ACMD_FUNC(breakguild)
  2795. {
  2796. nullpo_retr(-1, sd);
  2797. if (sd->status.guild_id) { // Check if the player has a guild
  2798. struct guild *g;
  2799. g = sd->guild; // Search the guild
  2800. if (g) { // Check if guild was found
  2801. if (sd->state.gmaster_flag) { // Check if player is guild master
  2802. int ret = 0;
  2803. ret = guild_break(sd, g->name); // Break guild
  2804. if (ret) { // Check if anything went wrong
  2805. return 0; // Guild was broken
  2806. } else {
  2807. return -1; // Something went wrong
  2808. }
  2809. } else { // Not guild master
  2810. clif_displaymessage(fd, msg_txt(sd,1181)); // You need to be a Guild Master to use this command.
  2811. return -1;
  2812. }
  2813. } else { // Guild was not found. HOW?
  2814. clif_displaymessage(fd, msg_txt(sd,252)); // You are not in a guild.
  2815. return -1;
  2816. }
  2817. } else { // Player does not have a guild
  2818. clif_displaymessage(fd, msg_txt(sd,252)); // You are not in a guild.
  2819. return -1;
  2820. }
  2821. return 0;
  2822. }
  2823. /*==========================================
  2824. *
  2825. *------------------------------------------*/
  2826. ACMD_FUNC(agitstart)
  2827. {
  2828. nullpo_retr(-1, sd);
  2829. if (agit_flag == 1) {
  2830. clif_displaymessage(fd, msg_txt(sd,73)); // War of Emperium is currently in progress.
  2831. return -1;
  2832. }
  2833. agit_flag = 1;
  2834. guild_agit_start();
  2835. clif_displaymessage(fd, msg_txt(sd,72)); // War of Emperium has been initiated.
  2836. return 0;
  2837. }
  2838. /*==========================================
  2839. *
  2840. *------------------------------------------*/
  2841. ACMD_FUNC(agitstart2)
  2842. {
  2843. nullpo_retr(-1, sd);
  2844. if (agit2_flag == 1) {
  2845. clif_displaymessage(fd, msg_txt(sd,404)); // "War of Emperium SE is currently in progress."
  2846. return -1;
  2847. }
  2848. agit2_flag = 1;
  2849. guild_agit2_start();
  2850. clif_displaymessage(fd, msg_txt(sd,403)); // "War of Emperium SE has been initiated."
  2851. return 0;
  2852. }
  2853. /*==========================================
  2854. *
  2855. *------------------------------------------*/
  2856. ACMD_FUNC(agitend)
  2857. {
  2858. nullpo_retr(-1, sd);
  2859. if (agit_flag == 0) {
  2860. clif_displaymessage(fd, msg_txt(sd,75)); // War of Emperium is currently not in progress.
  2861. return -1;
  2862. }
  2863. agit_flag = 0;
  2864. guild_agit_end();
  2865. clif_displaymessage(fd, msg_txt(sd,74)); // War of Emperium has been ended.
  2866. return 0;
  2867. }
  2868. /*==========================================
  2869. *
  2870. *------------------------------------------*/
  2871. ACMD_FUNC(agitend2)
  2872. {
  2873. nullpo_retr(-1, sd);
  2874. if (agit2_flag == 0) {
  2875. clif_displaymessage(fd, msg_txt(sd,406)); // "War of Emperium SE is currently not in progress."
  2876. return -1;
  2877. }
  2878. agit2_flag = 0;
  2879. guild_agit2_end();
  2880. clif_displaymessage(fd, msg_txt(sd,405)); // "War of Emperium SE has been ended."
  2881. return 0;
  2882. }
  2883. /*==========================================
  2884. * @mapexit - shuts down the map server
  2885. *------------------------------------------*/
  2886. ACMD_FUNC(mapexit)
  2887. {
  2888. nullpo_retr(-1, sd);
  2889. do_shutdown();
  2890. return 0;
  2891. }
  2892. /*==========================================
  2893. * idsearch <part_of_name>: revrited by [Yor]
  2894. *------------------------------------------*/
  2895. ACMD_FUNC(idsearch)
  2896. {
  2897. char item_name[100];
  2898. unsigned int i, match;
  2899. struct item_data *item_array[MAX_SEARCH];
  2900. nullpo_retr(-1, sd);
  2901. memset(item_name, '\0', sizeof(item_name));
  2902. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2903. if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
  2904. clif_displaymessage(fd, msg_txt(sd,1031)); // Please enter part of an item name (usage: @idsearch <part_of_item_name>).
  2905. return -1;
  2906. }
  2907. sprintf(atcmd_output, msg_txt(sd,77), item_name); // The reference result of '%s' (name: id):
  2908. clif_displaymessage(fd, atcmd_output);
  2909. match = itemdb_searchname_array(item_array, MAX_SEARCH, item_name);
  2910. if (match > MAX_SEARCH) {
  2911. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH, match);
  2912. clif_displaymessage(fd, atcmd_output);
  2913. match = MAX_SEARCH;
  2914. }
  2915. for(i = 0; i < match; i++) {
  2916. sprintf(atcmd_output, msg_txt(sd,78), item_array[i]->jname, item_array[i]->nameid); // %s: %d
  2917. clif_displaymessage(fd, atcmd_output);
  2918. }
  2919. sprintf(atcmd_output, msg_txt(sd,79), match); // It is %d affair above.
  2920. clif_displaymessage(fd, atcmd_output);
  2921. return 0;
  2922. }
  2923. /*==========================================
  2924. * Recall All Characters Online To Your Location
  2925. *------------------------------------------*/
  2926. ACMD_FUNC(recallall)
  2927. {
  2928. struct map_session_data* pl_sd;
  2929. struct s_mapiterator* iter;
  2930. int count;
  2931. nullpo_retr(-1, sd);
  2932. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2933. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2934. clif_displaymessage(fd, msg_txt(sd,1032)); // You are not authorized to warp somenone to your current map.
  2935. return -1;
  2936. }
  2937. count = 0;
  2938. iter = mapit_getallusers();
  2939. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2940. {
  2941. if (sd->status.account_id != pl_sd->status.account_id && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  2942. {
  2943. if (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y)
  2944. continue; // Don't waste time warping the character to the same place.
  2945. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  2946. count++;
  2947. else {
  2948. if (pc_isdead(pl_sd)) { //Wake them up
  2949. pc_setstand(pl_sd);
  2950. pc_setrestartvalue(pl_sd,1);
  2951. }
  2952. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  2953. }
  2954. }
  2955. }
  2956. mapit_free(iter);
  2957. clif_displaymessage(fd, msg_txt(sd,92)); // All characters recalled!
  2958. if (count) {
  2959. 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.
  2960. clif_displaymessage(fd, atcmd_output);
  2961. }
  2962. return 0;
  2963. }
  2964. /*==========================================
  2965. * Recall online characters of a guild to your location
  2966. *------------------------------------------*/
  2967. ACMD_FUNC(guildrecall)
  2968. {
  2969. struct map_session_data* pl_sd;
  2970. struct s_mapiterator* iter;
  2971. int count;
  2972. char guild_name[NAME_LENGTH];
  2973. struct guild *g;
  2974. nullpo_retr(-1, sd);
  2975. memset(guild_name, '\0', sizeof(guild_name));
  2976. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2977. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  2978. clif_displaymessage(fd, msg_txt(sd,1034)); // Please enter a guild name/ID (usage: @guildrecall <guild_name/ID>).
  2979. return -1;
  2980. }
  2981. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2982. clif_displaymessage(fd, msg_txt(sd,1032)); // You are not authorized to warp somenone to your current map.
  2983. return -1;
  2984. }
  2985. if ((g = guild_searchname(guild_name)) == NULL && // name first to avoid error when name begin with a number
  2986. (g = guild_search(atoi(message))) == NULL)
  2987. {
  2988. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  2989. return -1;
  2990. }
  2991. count = 0;
  2992. iter = mapit_getallusers();
  2993. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2994. {
  2995. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.guild_id == g->guild_id)
  2996. {
  2997. 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))
  2998. continue; // Skip GMs greater than you... or chars already on the cell
  2999. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3000. count++;
  3001. else
  3002. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  3003. }
  3004. }
  3005. mapit_free(iter);
  3006. sprintf(atcmd_output, msg_txt(sd,93), g->name); // All online characters of the %s guild have been recalled to your position.
  3007. clif_displaymessage(fd, atcmd_output);
  3008. if (count) {
  3009. 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.
  3010. clif_displaymessage(fd, atcmd_output);
  3011. }
  3012. return 0;
  3013. }
  3014. /*==========================================
  3015. * Recall online characters of a party to your location
  3016. *------------------------------------------*/
  3017. ACMD_FUNC(partyrecall)
  3018. {
  3019. struct map_session_data* pl_sd;
  3020. struct s_mapiterator* iter;
  3021. char party_name[NAME_LENGTH];
  3022. struct party_data *p;
  3023. int count;
  3024. nullpo_retr(-1, sd);
  3025. memset(party_name, '\0', sizeof(party_name));
  3026. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3027. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3028. clif_displaymessage(fd, msg_txt(sd,1035)); // Please enter a party name/ID (usage: @partyrecall <party_name/ID>).
  3029. return -1;
  3030. }
  3031. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3032. clif_displaymessage(fd, msg_txt(sd,1032)); // You are not authorized to warp somenone to your current map.
  3033. return -1;
  3034. }
  3035. if ((p = party_searchname(party_name)) == NULL && // name first to avoid error when name begin with a number
  3036. (p = party_search(atoi(message))) == NULL)
  3037. {
  3038. clif_displaymessage(fd, msg_txt(sd,96)); // Incorrect name or ID, or no one from the party is online.
  3039. return -1;
  3040. }
  3041. count = 0;
  3042. iter = mapit_getallusers();
  3043. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3044. {
  3045. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.party_id == p->party.party_id)
  3046. {
  3047. 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))
  3048. continue; // Skip GMs greater than you... or chars already on the cell
  3049. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3050. count++;
  3051. else
  3052. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  3053. }
  3054. }
  3055. mapit_free(iter);
  3056. sprintf(atcmd_output, msg_txt(sd,95), p->party.name); // All online characters of the %s party have been recalled to your position.
  3057. clif_displaymessage(fd, atcmd_output);
  3058. if (count) {
  3059. 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.
  3060. clif_displaymessage(fd, atcmd_output);
  3061. }
  3062. return 0;
  3063. }
  3064. /*==========================================
  3065. *
  3066. *------------------------------------------*/
  3067. void atcommand_doload();
  3068. ACMD_FUNC(reload)
  3069. {
  3070. nullpo_retr(-1, sd);
  3071. if ((strlen(command) < 8 ) && (!message || !*message)) {
  3072. const char* text;
  3073. text = atcommand_help_string( command );
  3074. if(text)
  3075. clif_displaymessage( fd, text );
  3076. return -1;
  3077. }
  3078. if (strstr(command, "itemdb") || strncmp(message, "itemdb", 4) == 0) {
  3079. itemdb_reload();
  3080. clif_displaymessage(fd, msg_txt(sd,97)); // Item database has been reloaded.
  3081. } else if (strstr(command, "mobdb") || strncmp(message, "mobdb", 3) == 0) {
  3082. mob_reload();
  3083. read_petdb();
  3084. merc_reload();
  3085. read_mercenarydb();
  3086. read_mercenary_skilldb();
  3087. reload_elementaldb();
  3088. clif_displaymessage(fd, msg_txt(sd,98)); // Monster database has been reloaded.
  3089. } else if (strstr(command, "skilldb") || strncmp(message, "skilldb", 4) == 0) {
  3090. skill_reload();
  3091. merc_skill_reload();
  3092. reload_elemental_skilldb();
  3093. read_mercenary_skilldb();
  3094. clif_displaymessage(fd, msg_txt(sd,99)); // Skill database has been reloaded.
  3095. } else if (strstr(command, "atcommand") || strncmp(message, "atcommand", 4) == 0) {
  3096. config_t run_test;
  3097. if (conf_read_file(&run_test, "conf/groups.conf")) {
  3098. clif_displaymessage(fd, msg_txt(sd,1036)); // Error reading groups.conf, reload failed.
  3099. return -1;
  3100. }
  3101. config_destroy(&run_test);
  3102. if (conf_read_file(&run_test, ATCOMMAND_CONF_FILENAME)) {
  3103. clif_displaymessage(fd, msg_txt(sd,1037)); // Error reading atcommand_athena.conf, reload failed.
  3104. return -1;
  3105. }
  3106. config_destroy(&run_test);
  3107. atcommand_doload();
  3108. pc_groups_reload();
  3109. clif_displaymessage(fd, msg_txt(sd,254));
  3110. } else if (strstr(command, "battleconf") || strncmp(message, "battleconf", 3) == 0) {
  3111. struct Battle_Config prev_config;
  3112. memcpy(&prev_config, &battle_config, sizeof(prev_config));
  3113. battle_config_read(BATTLE_CONF_FILENAME);
  3114. if( prev_config.item_rate_mvp != battle_config.item_rate_mvp
  3115. || prev_config.item_rate_common != battle_config.item_rate_common
  3116. || prev_config.item_rate_common_boss != battle_config.item_rate_common_boss
  3117. || prev_config.item_rate_card != battle_config.item_rate_card
  3118. || prev_config.item_rate_card_boss != battle_config.item_rate_card_boss
  3119. || prev_config.item_rate_equip != battle_config.item_rate_equip
  3120. || prev_config.item_rate_equip_boss != battle_config.item_rate_equip_boss
  3121. || prev_config.item_rate_heal != battle_config.item_rate_heal
  3122. || prev_config.item_rate_heal_boss != battle_config.item_rate_heal_boss
  3123. || prev_config.item_rate_use != battle_config.item_rate_use
  3124. || prev_config.item_rate_use_boss != battle_config.item_rate_use_boss
  3125. || prev_config.item_rate_treasure != battle_config.item_rate_treasure
  3126. || prev_config.item_rate_adddrop != battle_config.item_rate_adddrop
  3127. || prev_config.logarithmic_drops != battle_config.logarithmic_drops
  3128. || prev_config.item_drop_common_min != battle_config.item_drop_common_min
  3129. || prev_config.item_drop_common_max != battle_config.item_drop_common_max
  3130. || prev_config.item_drop_card_min != battle_config.item_drop_card_min
  3131. || prev_config.item_drop_card_max != battle_config.item_drop_card_max
  3132. || prev_config.item_drop_equip_min != battle_config.item_drop_equip_min
  3133. || prev_config.item_drop_equip_max != battle_config.item_drop_equip_max
  3134. || prev_config.item_drop_mvp_min != battle_config.item_drop_mvp_min
  3135. || prev_config.item_drop_mvp_max != battle_config.item_drop_mvp_max
  3136. || prev_config.item_drop_heal_min != battle_config.item_drop_heal_min
  3137. || prev_config.item_drop_heal_max != battle_config.item_drop_heal_max
  3138. || prev_config.item_drop_use_min != battle_config.item_drop_use_min
  3139. || prev_config.item_drop_use_max != battle_config.item_drop_use_max
  3140. || prev_config.item_drop_treasure_min != battle_config.item_drop_treasure_min
  3141. || prev_config.item_drop_treasure_max != battle_config.item_drop_treasure_max
  3142. || prev_config.base_exp_rate != battle_config.base_exp_rate
  3143. || prev_config.job_exp_rate != battle_config.job_exp_rate
  3144. )
  3145. { // Exp or Drop rates changed.
  3146. mob_reload(); //Needed as well so rate changes take effect.
  3147. chrif_ragsrvinfo(battle_config.base_exp_rate, battle_config.job_exp_rate, battle_config.item_rate_common);
  3148. }
  3149. clif_displaymessage(fd, msg_txt(sd,255));
  3150. } else if (strstr(command, "statusdb") || strncmp(message, "statusdb", 3) == 0) {
  3151. status_readdb();
  3152. clif_displaymessage(fd, msg_txt(sd,256));
  3153. } else if (strstr(command, "pcdb") || strncmp(message, "pcdb", 2) == 0) {
  3154. pc_readdb();
  3155. clif_displaymessage(fd, msg_txt(sd,257));
  3156. } else if (strstr(command, "motd") || strncmp(message, "motd", 4) == 0) {
  3157. pc_read_motd();
  3158. clif_displaymessage(fd, msg_txt(sd,268));
  3159. } else if (strstr(command, "script") || strncmp(message, "script", 3) == 0) {
  3160. struct s_mapiterator* iter;
  3161. struct map_session_data* pl_sd;
  3162. //atcommand_broadcast( fd, sd, "@broadcast", "Server is reloading scripts..." );
  3163. //atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
  3164. iter = mapit_getallusers();
  3165. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3166. pc_close_npc(pl_sd,2);
  3167. mapit_free(iter);
  3168. flush_fifos();
  3169. map_reloadnpc(true); // reload config files seeking for npcs
  3170. script_reload();
  3171. npc_reload();
  3172. clif_displaymessage(fd, msg_txt(sd,100)); // Scripts have been reloaded.
  3173. } else if (strstr(command, "msgconf") || strncmp(message, "msgconf", 3) == 0) {
  3174. map_msg_reload();
  3175. clif_displaymessage(fd, msg_txt(sd,463)); // Message configuration has been reloaded.
  3176. } else if (strstr(command, "questdb") || strncmp(message, "questdb", 3) == 0) {
  3177. do_reload_quest();
  3178. clif_displaymessage(fd, msg_txt(sd,1377)); // Quest database has been reloaded.
  3179. } else if (strstr(command, "packetdb") || strncmp(message, "packetdb", 4) == 0) {
  3180. packetdb_readdb();
  3181. clif_displaymessage(fd, msg_txt(sd,1477)); // Packet database has been reloaded.
  3182. }
  3183. return 0;
  3184. }
  3185. /*==========================================
  3186. * @mapinfo [0-3] <map name> by MC_Cameri
  3187. * => Shows information about the map [map name]
  3188. * 0 = no additional information
  3189. * 1 = Show users in that map and their location
  3190. * 2 = Shows NPCs in that map
  3191. * 3 = Shows the chats in that map
  3192. *------------------------------------------*/
  3193. ACMD_FUNC(mapinfo) {
  3194. struct map_session_data* pl_sd;
  3195. struct s_mapiterator* iter;
  3196. struct npc_data *nd = NULL;
  3197. struct chat_data *cd = NULL;
  3198. char direction[12];
  3199. int i, m_id, chat_num = 0, list = 0, vend_num = 0;
  3200. unsigned short m_index;
  3201. char mapname[24];
  3202. nullpo_retr(-1, sd);
  3203. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3204. memset(mapname, '\0', sizeof(mapname));
  3205. memset(direction, '\0', sizeof(direction));
  3206. sscanf(message, "%d %23[^\n]", &list, mapname);
  3207. if (list < 0 || list > 3) {
  3208. clif_displaymessage(fd, msg_txt(sd,1038)); // Please enter at least one valid list number (usage: @mapinfo <0-3> <map>).
  3209. return -1;
  3210. }
  3211. if (mapname[0] == '\0') {
  3212. safestrncpy(mapname, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
  3213. m_id = map_mapindex2mapid(sd->mapindex);
  3214. } else {
  3215. m_id = map_mapname2mapid(mapname);
  3216. }
  3217. if (m_id < 0) {
  3218. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  3219. return -1;
  3220. }
  3221. m_index = mapindex_name2id(mapname); //This one shouldn't fail since the previous seek did not.
  3222. clif_displaymessage(fd, msg_txt(sd,1039)); // ------ Map Info ------
  3223. // count chats (for initial message)
  3224. chat_num = 0;
  3225. iter = mapit_getallusers();
  3226. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) {
  3227. if( pl_sd->mapindex == m_index ) {
  3228. if( pl_sd->state.vending )
  3229. vend_num++;
  3230. else if( (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL && cd->usersd[0] == pl_sd )
  3231. chat_num++;
  3232. }
  3233. }
  3234. mapit_free(iter);
  3235. 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
  3236. clif_displaymessage(fd, atcmd_output);
  3237. clif_displaymessage(fd, msg_txt(sd,1041)); // ------ Map Flags ------
  3238. if (map[m_id].flag.town)
  3239. clif_displaymessage(fd, msg_txt(sd,1042)); // Town Map
  3240. if (battle_config.autotrade_mapflag == map[m_id].flag.autotrade)
  3241. clif_displaymessage(fd, msg_txt(sd,1043)); // Autotrade Enabled
  3242. else
  3243. clif_displaymessage(fd, msg_txt(sd,1044)); // Autotrade Disabled
  3244. if (map[m_id].flag.battleground)
  3245. clif_displaymessage(fd, msg_txt(sd,1045)); // Battlegrounds ON
  3246. strcpy(atcmd_output,msg_txt(sd,1046)); // PvP Flags:
  3247. if (map[m_id].flag.pvp)
  3248. strcat(atcmd_output, msg_txt(sd,1047)); // Pvp ON |
  3249. if (map[m_id].flag.pvp_noguild)
  3250. strcat(atcmd_output, msg_txt(sd,1048)); // NoGuild |
  3251. if (map[m_id].flag.pvp_noparty)
  3252. strcat(atcmd_output, msg_txt(sd,1049)); // NoParty |
  3253. if (map[m_id].flag.pvp_nightmaredrop)
  3254. strcat(atcmd_output, msg_txt(sd,1050)); // NightmareDrop |
  3255. if (map[m_id].flag.pvp_nocalcrank)
  3256. strcat(atcmd_output, msg_txt(sd,1051)); // NoCalcRank |
  3257. clif_displaymessage(fd, atcmd_output);
  3258. strcpy(atcmd_output,msg_txt(sd,1052)); // GvG Flags:
  3259. if (map[m_id].flag.gvg)
  3260. strcat(atcmd_output, msg_txt(sd,1053)); // GvG ON |
  3261. if (map[m_id].flag.gvg_dungeon)
  3262. strcat(atcmd_output, msg_txt(sd,1054)); // GvG Dungeon |
  3263. if (map[m_id].flag.gvg_castle)
  3264. strcat(atcmd_output, msg_txt(sd,1055)); // GvG Castle |
  3265. if (map[m_id].flag.gvg_noparty)
  3266. strcat(atcmd_output, msg_txt(sd,1056)); // NoParty |
  3267. clif_displaymessage(fd, atcmd_output);
  3268. strcpy(atcmd_output,msg_txt(sd,1057)); // Teleport Flags:
  3269. if (map[m_id].flag.noteleport)
  3270. strcat(atcmd_output, msg_txt(sd,1058)); // NoTeleport |
  3271. if (map[m_id].flag.monster_noteleport)
  3272. strcat(atcmd_output, msg_txt(sd,1059)); // Monster NoTeleport |
  3273. if (map[m_id].flag.nowarp)
  3274. strcat(atcmd_output, msg_txt(sd,1060)); // NoWarp |
  3275. if (map[m_id].flag.nowarpto)
  3276. strcat(atcmd_output, msg_txt(sd,1061)); // NoWarpTo |
  3277. if (map[m_id].flag.noreturn)
  3278. strcat(atcmd_output, msg_txt(sd,1062)); // NoReturn |
  3279. if (map[m_id].flag.nogo)
  3280. strcat(atcmd_output, msg_txt(sd,1063)); // NoGo |
  3281. if (map[m_id].flag.nomemo)
  3282. strcat(atcmd_output, msg_txt(sd,1064)); // NoMemo |
  3283. clif_displaymessage(fd, atcmd_output);
  3284. sprintf(atcmd_output, msg_txt(sd,1065), // No Exp Penalty: %s | No Zeny Penalty: %s
  3285. (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
  3286. clif_displaymessage(fd, atcmd_output);
  3287. if (map[m_id].flag.nosave) {
  3288. if (!map[m_id].save.map)
  3289. clif_displaymessage(fd, msg_txt(sd,1068)); // No Save (Return to last Save Point)
  3290. else if (map[m_id].save.x == -1 || map[m_id].save.y == -1 ) {
  3291. sprintf(atcmd_output, msg_txt(sd,1069), mapindex_id2name(map[m_id].save.map)); // No Save, Save Point: %s,Random
  3292. clif_displaymessage(fd, atcmd_output);
  3293. }
  3294. else {
  3295. sprintf(atcmd_output, msg_txt(sd,1070), // No Save, Save Point: %s,%d,%d
  3296. mapindex_id2name(map[m_id].save.map),map[m_id].save.x,map[m_id].save.y);
  3297. clif_displaymessage(fd, atcmd_output);
  3298. }
  3299. }
  3300. strcpy(atcmd_output,msg_txt(sd,1071)); // Weather Flags:
  3301. if (map[m_id].flag.snow)
  3302. strcat(atcmd_output, msg_txt(sd,1072)); // Snow |
  3303. if (map[m_id].flag.fog)
  3304. strcat(atcmd_output, msg_txt(sd,1073)); // Fog |
  3305. if (map[m_id].flag.sakura)
  3306. strcat(atcmd_output, msg_txt(sd,1074)); // Sakura |
  3307. if (map[m_id].flag.clouds)
  3308. strcat(atcmd_output, msg_txt(sd,1075)); // Clouds |
  3309. if (map[m_id].flag.clouds2)
  3310. strcat(atcmd_output, msg_txt(sd,1076)); // Clouds2 |
  3311. if (map[m_id].flag.fireworks)
  3312. strcat(atcmd_output, msg_txt(sd,1077)); // Fireworks |
  3313. if (map[m_id].flag.leaves)
  3314. strcat(atcmd_output, msg_txt(sd,1078)); // Leaves |
  3315. if (map[m_id].flag.nightenabled)
  3316. strcat(atcmd_output, msg_txt(sd,1080)); // Displays Night |
  3317. clif_displaymessage(fd, atcmd_output);
  3318. strcpy(atcmd_output,msg_txt(sd,1081)); // Other Flags:
  3319. if (map[m_id].flag.nobranch)
  3320. strcat(atcmd_output, msg_txt(sd,1082)); // NoBranch |
  3321. if (map[m_id].flag.notrade)
  3322. strcat(atcmd_output, msg_txt(sd,1083)); // NoTrade |
  3323. if (map[m_id].flag.novending)
  3324. strcat(atcmd_output, msg_txt(sd,1084)); // NoVending |
  3325. if (map[m_id].flag.nodrop)
  3326. strcat(atcmd_output, msg_txt(sd,1085)); // NoDrop |
  3327. if (map[m_id].flag.noskill)
  3328. strcat(atcmd_output, msg_txt(sd,1086)); // NoSkill |
  3329. if (map[m_id].flag.noicewall)
  3330. strcat(atcmd_output, msg_txt(sd,1087)); // NoIcewall |
  3331. if (map[m_id].flag.allowks)
  3332. strcat(atcmd_output, msg_txt(sd,1088)); // AllowKS |
  3333. if (map[m_id].flag.reset)
  3334. strcat(atcmd_output, msg_txt(sd,1089)); // Reset |
  3335. clif_displaymessage(fd, atcmd_output);
  3336. strcpy(atcmd_output,msg_txt(sd,1090)); // Other Flags:
  3337. if (map[m_id].nocommand)
  3338. strcat(atcmd_output, msg_txt(sd,1091)); // NoCommand |
  3339. if (map[m_id].flag.nobaseexp)
  3340. strcat(atcmd_output, msg_txt(sd,1092)); // NoBaseEXP |
  3341. if (map[m_id].flag.nojobexp)
  3342. strcat(atcmd_output, msg_txt(sd,1093)); // NoJobEXP |
  3343. if (map[m_id].flag.nomobloot)
  3344. strcat(atcmd_output, msg_txt(sd,1094)); // NoMobLoot |
  3345. if (map[m_id].flag.nomvploot)
  3346. strcat(atcmd_output, msg_txt(sd,1095)); // NoMVPLoot |
  3347. if (map[m_id].flag.partylock)
  3348. strcat(atcmd_output, msg_txt(sd,1096)); // PartyLock |
  3349. if (map[m_id].flag.guildlock)
  3350. strcat(atcmd_output, msg_txt(sd,1097)); // GuildLock |
  3351. clif_displaymessage(fd, atcmd_output);
  3352. switch (list) {
  3353. case 0:
  3354. // Do nothing. It's list 0, no additional display.
  3355. break;
  3356. case 1:
  3357. clif_displaymessage(fd, msg_txt(sd,1098)); // ----- Players in Map -----
  3358. iter = mapit_getallusers();
  3359. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3360. {
  3361. if (pl_sd->mapindex == m_index) {
  3362. sprintf(atcmd_output, msg_txt(sd,1099), // Player '%s' (session #%d) | Location: %d,%d
  3363. pl_sd->status.name, pl_sd->fd, pl_sd->bl.x, pl_sd->bl.y);
  3364. clif_displaymessage(fd, atcmd_output);
  3365. }
  3366. }
  3367. mapit_free(iter);
  3368. break;
  3369. case 2:
  3370. clif_displaymessage(fd, msg_txt(sd,1100)); // ----- NPCs in Map -----
  3371. for (i = 0; i < map[m_id].npc_num;)
  3372. {
  3373. nd = map[m_id].npc[i];
  3374. switch(nd->ud.dir) {
  3375. case 0: strcpy(direction, msg_txt(sd,1101)); break; // North
  3376. case 1: strcpy(direction, msg_txt(sd,1102)); break; // North West
  3377. case 2: strcpy(direction, msg_txt(sd,1103)); break; // West
  3378. case 3: strcpy(direction, msg_txt(sd,1104)); break; // South West
  3379. case 4: strcpy(direction, msg_txt(sd,1105)); break; // South
  3380. case 5: strcpy(direction, msg_txt(sd,1106)); break; // South East
  3381. case 6: strcpy(direction, msg_txt(sd,1107)); break; // East
  3382. case 7: strcpy(direction, msg_txt(sd,1108)); break; // North East
  3383. case 9: strcpy(direction, msg_txt(sd,1109)); break; // North
  3384. default: strcpy(direction, msg_txt(sd,1110)); break; // Unknown
  3385. }
  3386. if(strcmp(nd->name,nd->exname) == 0)
  3387. sprintf(atcmd_output, msg_txt(sd,1111), // NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d
  3388. ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
  3389. else
  3390. sprintf(atcmd_output, msg_txt(sd,1112), // NPC %d: %s::%s | Direction: %s | Sprite: %d | Location: %d %d
  3391. ++i, nd->name, nd->exname, direction, nd->class_, nd->bl.x, nd->bl.y);
  3392. clif_displaymessage(fd, atcmd_output);
  3393. }
  3394. break;
  3395. case 3:
  3396. clif_displaymessage(fd, msg_txt(sd,1113)); // ----- Chats in Map -----
  3397. iter = mapit_getallusers();
  3398. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3399. {
  3400. if ((cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL &&
  3401. pl_sd->mapindex == m_index &&
  3402. cd->usersd[0] == pl_sd)
  3403. {
  3404. sprintf(atcmd_output, msg_txt(sd,1114), // Chat: %s | Player: %s | Location: %d %d
  3405. cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
  3406. clif_displaymessage(fd, atcmd_output);
  3407. sprintf(atcmd_output, msg_txt(sd,1115), // Users: %d/%d | Password: %s | Public: %s
  3408. cd->users, cd->limit, cd->pass, (cd->pub) ? msg_txt(sd,1116) : msg_txt(sd,1117)); // Yes / No
  3409. clif_displaymessage(fd, atcmd_output);
  3410. }
  3411. }
  3412. mapit_free(iter);
  3413. break;
  3414. default: // normally impossible to arrive here
  3415. clif_displaymessage(fd, msg_txt(sd,1118)); // Please enter at least one valid list number (usage: @mapinfo <0-3> <map>).
  3416. return -1;
  3417. break;
  3418. }
  3419. return 0;
  3420. }
  3421. /*==========================================
  3422. *
  3423. *------------------------------------------*/
  3424. ACMD_FUNC(mount_peco)
  3425. {
  3426. nullpo_retr(-1, sd);
  3427. if (sd->disguise) {
  3428. clif_displaymessage(fd, msg_txt(sd,212)); // Cannot mount while in disguise.
  3429. return -1;
  3430. }
  3431. if( (sd->class_&MAPID_THIRDMASK) == MAPID_RUNE_KNIGHT && pc_checkskill(sd,RK_DRAGONTRAINING) > 0 ) {
  3432. if( !(sd->sc.option&OPTION_DRAGON1) ) {
  3433. clif_displaymessage(sd->fd,msg_txt(sd,1119)); // You have mounted your Dragon.
  3434. pc_setoption(sd, sd->sc.option|OPTION_DRAGON1);
  3435. } else {
  3436. clif_displaymessage(sd->fd,msg_txt(sd,1120)); // You have released your Dragon.
  3437. pc_setoption(sd, sd->sc.option&~OPTION_DRAGON1);
  3438. }
  3439. return 0;
  3440. }
  3441. if( (sd->class_&MAPID_THIRDMASK) == MAPID_RANGER && pc_checkskill(sd,RA_WUGRIDER) > 0 ) {
  3442. if( !pc_isridingwug(sd) ) {
  3443. clif_displaymessage(sd->fd,msg_txt(sd,1121)); // You have mounted your Warg.
  3444. pc_setoption(sd, sd->sc.option|OPTION_WUGRIDER);
  3445. } else {
  3446. clif_displaymessage(sd->fd,msg_txt(sd,1122)); // You have released your Warg.
  3447. pc_setoption(sd, sd->sc.option&~OPTION_WUGRIDER);
  3448. }
  3449. return 0;
  3450. }
  3451. if( (sd->class_&MAPID_THIRDMASK) == MAPID_MECHANIC ) {
  3452. if( !pc_ismadogear(sd) ) {
  3453. clif_displaymessage(sd->fd,msg_txt(sd,1123)); // You have mounted your Mado Gear.
  3454. pc_setoption(sd, sd->sc.option|OPTION_MADOGEAR);
  3455. } else {
  3456. clif_displaymessage(sd->fd,msg_txt(sd,1124)); // You have released your Mado Gear.
  3457. pc_setoption(sd, sd->sc.option&~OPTION_MADOGEAR);
  3458. }
  3459. return 0;
  3460. }
  3461. if (!pc_isriding(sd)) { // if actually no peco
  3462. if (!pc_checkskill(sd, KN_RIDING)) {
  3463. clif_displaymessage(fd, msg_txt(sd,213)); // You can not mount a Peco Peco with your current job.
  3464. return -1;
  3465. }
  3466. pc_setoption(sd, sd->sc.option | OPTION_RIDING);
  3467. clif_displaymessage(fd, msg_txt(sd,102)); // You have mounted a Peco Peco.
  3468. } else {//Dismount
  3469. pc_setoption(sd, sd->sc.option & ~OPTION_RIDING);
  3470. clif_displaymessage(fd, msg_txt(sd,214)); // You have released your Peco Peco.
  3471. }
  3472. return 0;
  3473. }
  3474. /*==========================================
  3475. *Spy Commands by Syrus22
  3476. *------------------------------------------*/
  3477. ACMD_FUNC(guildspy)
  3478. {
  3479. char guild_name[NAME_LENGTH];
  3480. struct guild *g;
  3481. nullpo_retr(-1, sd);
  3482. memset(guild_name, '\0', sizeof(guild_name));
  3483. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3484. if (!enable_spy)
  3485. {
  3486. clif_displaymessage(fd, msg_txt(sd,1125)); // The mapserver has spy command support disabled.
  3487. return -1;
  3488. }
  3489. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  3490. clif_displaymessage(fd, msg_txt(sd,1126)); // Please enter a guild name/ID (usage: @guildspy <guild_name/ID>).
  3491. return -1;
  3492. }
  3493. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  3494. (g = guild_search(atoi(message))) != NULL) {
  3495. if (sd->guildspy == g->guild_id) {
  3496. sd->guildspy = 0;
  3497. sprintf(atcmd_output, msg_txt(sd,103), g->name); // No longer spying on the %s guild.
  3498. clif_displaymessage(fd, atcmd_output);
  3499. } else {
  3500. sd->guildspy = g->guild_id;
  3501. sprintf(atcmd_output, msg_txt(sd,104), g->name); // Spying on the %s guild.
  3502. clif_displaymessage(fd, atcmd_output);
  3503. }
  3504. } else {
  3505. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the specified guild is online.
  3506. return -1;
  3507. }
  3508. return 0;
  3509. }
  3510. /*==========================================
  3511. *
  3512. *------------------------------------------*/
  3513. ACMD_FUNC(partyspy)
  3514. {
  3515. char party_name[NAME_LENGTH];
  3516. struct party_data *p;
  3517. nullpo_retr(-1, sd);
  3518. memset(party_name, '\0', sizeof(party_name));
  3519. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3520. if (!enable_spy)
  3521. {
  3522. clif_displaymessage(fd, msg_txt(sd,1125)); // The mapserver has spy command support disabled.
  3523. return -1;
  3524. }
  3525. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3526. clif_displaymessage(fd, msg_txt(sd,1127)); // Please enter a party name/ID (usage: @partyspy <party_name/ID>).
  3527. return -1;
  3528. }
  3529. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  3530. (p = party_search(atoi(message))) != NULL) {
  3531. if (sd->partyspy == p->party.party_id) {
  3532. sd->partyspy = 0;
  3533. sprintf(atcmd_output, msg_txt(sd,105), p->party.name); // No longer spying on the %s party.
  3534. clif_displaymessage(fd, atcmd_output);
  3535. } else {
  3536. sd->partyspy = p->party.party_id;
  3537. sprintf(atcmd_output, msg_txt(sd,106), p->party.name); // Spying on the %s party.
  3538. clif_displaymessage(fd, atcmd_output);
  3539. }
  3540. } else {
  3541. clif_displaymessage(fd, msg_txt(sd,96)); // Incorrect name/ID, or no one from the specified party is online.
  3542. return -1;
  3543. }
  3544. return 0;
  3545. }
  3546. /*==========================================
  3547. * @repairall [Valaris]
  3548. *------------------------------------------*/
  3549. ACMD_FUNC(repairall)
  3550. {
  3551. int count, i;
  3552. nullpo_retr(-1, sd);
  3553. count = 0;
  3554. for (i = 0; i < MAX_INVENTORY; i++) {
  3555. if (sd->status.inventory[i].nameid && sd->status.inventory[i].attribute == 1) {
  3556. sd->status.inventory[i].attribute = 0;
  3557. clif_produceeffect(sd, 0, sd->status.inventory[i].nameid);
  3558. count++;
  3559. }
  3560. }
  3561. if (count > 0) {
  3562. clif_misceffect(&sd->bl, 3);
  3563. clif_equiplist(sd);
  3564. clif_displaymessage(fd, msg_txt(sd,107)); // All items have been repaired.
  3565. } else {
  3566. clif_displaymessage(fd, msg_txt(sd,108)); // No item need to be repaired.
  3567. return -1;
  3568. }
  3569. return 0;
  3570. }
  3571. /*==========================================
  3572. * @nuke [Valaris]
  3573. *------------------------------------------*/
  3574. ACMD_FUNC(nuke)
  3575. {
  3576. struct map_session_data *pl_sd;
  3577. nullpo_retr(-1, sd);
  3578. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3579. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3580. clif_displaymessage(fd, msg_txt(sd,1128)); // Please enter a player name (usage: @nuke <char name>).
  3581. return -1;
  3582. }
  3583. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  3584. if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kill only lower or same GM level
  3585. skill_castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
  3586. clif_displaymessage(fd, msg_txt(sd,109)); // Player has been nuked!
  3587. } else {
  3588. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  3589. return -1;
  3590. }
  3591. } else {
  3592. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  3593. return -1;
  3594. }
  3595. return 0;
  3596. }
  3597. /*==========================================
  3598. * @tonpc
  3599. *------------------------------------------*/
  3600. ACMD_FUNC(tonpc)
  3601. {
  3602. char npcname[NAME_LENGTH+1];
  3603. struct npc_data *nd;
  3604. nullpo_retr(-1, sd);
  3605. memset(npcname, 0, sizeof(npcname));
  3606. if (!message || !*message || sscanf(message, "%23[^\n]", npcname) < 1) {
  3607. clif_displaymessage(fd, msg_txt(sd,1129)); // Please enter a NPC name (usage: @tonpc <NPC_name>).
  3608. return -1;
  3609. }
  3610. if ((nd = npc_name2id(npcname)) != NULL) {
  3611. if (pc_setpos(sd, map_id2index(nd->bl.m), nd->bl.x, nd->bl.y, CLR_TELEPORT) == 0)
  3612. clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
  3613. else
  3614. return -1;
  3615. } else {
  3616. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  3617. return -1;
  3618. }
  3619. return 0;
  3620. }
  3621. /*==========================================
  3622. *
  3623. *------------------------------------------*/
  3624. ACMD_FUNC(shownpc)
  3625. {
  3626. char NPCname[NAME_LENGTH+1];
  3627. nullpo_retr(-1, sd);
  3628. memset(NPCname, '\0', sizeof(NPCname));
  3629. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  3630. clif_displaymessage(fd, msg_txt(sd,1130)); // Please enter a NPC name (usage: @enablenpc <NPC_name>).
  3631. return -1;
  3632. }
  3633. if (npc_name2id(NPCname) != NULL) {
  3634. npc_enable(NPCname, 1);
  3635. clif_displaymessage(fd, msg_txt(sd,110)); // Npc Enabled.
  3636. } else {
  3637. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  3638. return -1;
  3639. }
  3640. return 0;
  3641. }
  3642. /*==========================================
  3643. *
  3644. *------------------------------------------*/
  3645. ACMD_FUNC(hidenpc)
  3646. {
  3647. char NPCname[NAME_LENGTH+1];
  3648. nullpo_retr(-1, sd);
  3649. memset(NPCname, '\0', sizeof(NPCname));
  3650. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  3651. clif_displaymessage(fd, msg_txt(sd,1131)); // Please enter a NPC name (usage: @hidenpc <NPC_name>).
  3652. return -1;
  3653. }
  3654. if (npc_name2id(NPCname) == NULL) {
  3655. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  3656. return -1;
  3657. }
  3658. npc_enable(NPCname, 0);
  3659. clif_displaymessage(fd, msg_txt(sd,112)); // Npc Disabled.
  3660. return 0;
  3661. }
  3662. ACMD_FUNC(loadnpc)
  3663. {
  3664. FILE *fp;
  3665. if (!message || !*message) {
  3666. clif_displaymessage(fd, msg_txt(sd,1132)); // Please enter a script file name (usage: @loadnpc <file name>).
  3667. return -1;
  3668. }
  3669. // check if script file exists
  3670. if ((fp = fopen(message, "r")) == NULL) {
  3671. clif_displaymessage(fd, msg_txt(sd,261));
  3672. return -1;
  3673. }
  3674. fclose(fp);
  3675. // add to list of script sources and run it
  3676. npc_addsrcfile(message);
  3677. npc_parsesrcfile(message,true);
  3678. npc_read_event_script();
  3679. clif_displaymessage(fd, msg_txt(sd,262));
  3680. return 0;
  3681. }
  3682. ACMD_FUNC(unloadnpc)
  3683. {
  3684. struct npc_data *nd;
  3685. char NPCname[NAME_LENGTH+1];
  3686. nullpo_retr(-1, sd);
  3687. memset(NPCname, '\0', sizeof(NPCname));
  3688. if (!message || !*message || sscanf(message, "%24[^\n]", NPCname) < 1) {
  3689. clif_displaymessage(fd, msg_txt(sd,1133)); // Please enter a NPC name (usage: @npcoff <NPC_name>).
  3690. return -1;
  3691. }
  3692. if ((nd = npc_name2id(NPCname)) == NULL) {
  3693. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  3694. return -1;
  3695. }
  3696. npc_unload_duplicates(nd);
  3697. npc_unload(nd,true);
  3698. npc_read_event_script();
  3699. clif_displaymessage(fd, msg_txt(sd,112)); // Npc Disabled.
  3700. return 0;
  3701. }
  3702. /*==========================================
  3703. * time in txt for time command (by [Yor])
  3704. *------------------------------------------*/
  3705. char* txt_time(unsigned int duration)
  3706. {
  3707. int days, hours, minutes, seconds;
  3708. char temp[CHAT_SIZE_MAX];
  3709. static char temp1[CHAT_SIZE_MAX];
  3710. memset(temp, '\0', sizeof(temp));
  3711. memset(temp1, '\0', sizeof(temp1));
  3712. days = duration / (60 * 60 * 24);
  3713. duration = duration - (60 * 60 * 24 * days);
  3714. hours = duration / (60 * 60);
  3715. duration = duration - (60 * 60 * hours);
  3716. minutes = duration / 60;
  3717. seconds = duration - (60 * minutes);
  3718. if (days == 1)
  3719. sprintf(temp, msg_txt(NULL,219), days); // %d day
  3720. else if (days > 1)
  3721. sprintf(temp, msg_txt(NULL,220), days); // %d days
  3722. if (hours == 1)
  3723. sprintf(temp1, msg_txt(NULL,221), temp, hours); // %s %d hour
  3724. else if (hours > 1)
  3725. sprintf(temp1, msg_txt(NULL,222), temp, hours); // %s %d hours
  3726. if (minutes < 2)
  3727. sprintf(temp, msg_txt(NULL,223), temp1, minutes); // %s %d minute
  3728. else
  3729. sprintf(temp, msg_txt(NULL,224), temp1, minutes); // %s %d minutes
  3730. if (seconds == 1)
  3731. sprintf(temp1, msg_txt(NULL,225), temp, seconds); // %s and %d second
  3732. else if (seconds > 1)
  3733. sprintf(temp1, msg_txt(NULL,226), temp, seconds); // %s and %d seconds
  3734. return temp1;
  3735. }
  3736. /*==========================================
  3737. * @time/@date/@serverdate/@servertime: Display the date/time of the server (by [Yor]
  3738. * Calculation management of GM modification (@day/@night GM commands) is done
  3739. *------------------------------------------*/
  3740. ACMD_FUNC(servertime)
  3741. {
  3742. const struct TimerData * timer_data;
  3743. const struct TimerData * timer_data2;
  3744. time_t time_server; // variable for number of seconds (used with time() function)
  3745. struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
  3746. char temp[CHAT_SIZE_MAX];
  3747. nullpo_retr(-1, sd);
  3748. memset(temp, '\0', sizeof(temp));
  3749. time(&time_server); // get time in seconds since 1/1/1970
  3750. datetime = localtime(&time_server); // convert seconds in structure
  3751. // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
  3752. strftime(temp, sizeof(temp)-1, msg_txt(sd,230), datetime); // Server time (normal time): %A, %B %d %Y %X.
  3753. clif_displaymessage(fd, temp);
  3754. if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
  3755. if (night_flag == 0)
  3756. clif_displaymessage(fd, msg_txt(sd,231)); // Game time: The game is in permanent daylight.
  3757. else
  3758. clif_displaymessage(fd, msg_txt(sd,232)); // Game time: The game is in permanent night.
  3759. } else if (battle_config.night_duration == 0)
  3760. if (night_flag == 1) { // we start with night
  3761. timer_data = get_timer(day_timer_tid);
  3762. sprintf(temp, msg_txt(sd,233), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in night for %s.
  3763. clif_displaymessage(fd, temp);
  3764. clif_displaymessage(fd, msg_txt(sd,234)); // Game time: After, the game will be in permanent daylight.
  3765. } else
  3766. clif_displaymessage(fd, msg_txt(sd,231)); // Game time: The game is in permanent daylight.
  3767. else if (battle_config.day_duration == 0)
  3768. if (night_flag == 0) { // we start with day
  3769. timer_data = get_timer(night_timer_tid);
  3770. sprintf(temp, msg_txt(sd,235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  3771. clif_displaymessage(fd, temp);
  3772. clif_displaymessage(fd, msg_txt(sd,236)); // Game time: After, the game will be in permanent night.
  3773. } else
  3774. clif_displaymessage(fd, msg_txt(sd,232)); // Game time: The game is in permanent night.
  3775. else {
  3776. if (night_flag == 0) {
  3777. timer_data = get_timer(night_timer_tid);
  3778. timer_data2 = get_timer(day_timer_tid);
  3779. sprintf(temp, msg_txt(sd,235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  3780. clif_displaymessage(fd, temp);
  3781. if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0)
  3782. 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.
  3783. else
  3784. 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.
  3785. clif_displaymessage(fd, temp);
  3786. sprintf(temp, msg_txt(sd,238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  3787. clif_displaymessage(fd, temp);
  3788. } else {
  3789. timer_data = get_timer(day_timer_tid);
  3790. timer_data2 = get_timer(night_timer_tid);
  3791. sprintf(temp, msg_txt(sd,233), txt_time(DIFF_TICK(timer_data->tick,gettick()) / 1000)); // Game time: The game is actualy in night for %s.
  3792. clif_displaymessage(fd, temp);
  3793. if (DIFF_TICK(timer_data->tick,timer_data2->tick) > 0)
  3794. 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.
  3795. else
  3796. 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.
  3797. clif_displaymessage(fd, temp);
  3798. sprintf(temp, msg_txt(sd,238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  3799. clif_displaymessage(fd, temp);
  3800. }
  3801. }
  3802. return 0;
  3803. }
  3804. //Added by Coltaro
  3805. //We're using this function here instead of using time_t so that it only counts player's jail time when he/she's online (and since the idea is to reduce the amount of minutes one by one in status_change_timer...).
  3806. //Well, using time_t could still work but for some reason that looks like more coding x_x
  3807. static void get_jail_time(int jailtime, int* year, int* month, int* day, int* hour, int* minute)
  3808. {
  3809. const int factor_year = 518400; //12*30*24*60 = 518400
  3810. const int factor_month = 43200; //30*24*60 = 43200
  3811. const int factor_day = 1440; //24*60 = 1440
  3812. const int factor_hour = 60;
  3813. *year = jailtime/factor_year;
  3814. jailtime -= *year*factor_year;
  3815. *month = jailtime/factor_month;
  3816. jailtime -= *month*factor_month;
  3817. *day = jailtime/factor_day;
  3818. jailtime -= *day*factor_day;
  3819. *hour = jailtime/factor_hour;
  3820. jailtime -= *hour*factor_hour;
  3821. *minute = jailtime;
  3822. *year = *year > 0? *year : 0;
  3823. *month = *month > 0? *month : 0;
  3824. *day = *day > 0? *day : 0;
  3825. *hour = *hour > 0? *hour : 0;
  3826. *minute = *minute > 0? *minute : 0;
  3827. return;
  3828. }
  3829. /*==========================================
  3830. * @jail <char_name> by [Yor]
  3831. * Special warp! No check with nowarp and nowarpto flag
  3832. *------------------------------------------*/
  3833. ACMD_FUNC(jail)
  3834. {
  3835. struct map_session_data *pl_sd;
  3836. int x, y;
  3837. unsigned short m_index;
  3838. nullpo_retr(-1, sd);
  3839. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3840. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3841. clif_displaymessage(fd, msg_txt(sd,1134)); // Please enter a player name (usage: @jail <char_name>).
  3842. return -1;
  3843. }
  3844. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  3845. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  3846. return -1;
  3847. }
  3848. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd))
  3849. { // you can jail only lower or same GM
  3850. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  3851. return -1;
  3852. }
  3853. if (pl_sd->sc.data[SC_JAILED])
  3854. {
  3855. clif_displaymessage(fd, msg_txt(sd,118)); // Player warped in jails.
  3856. return -1;
  3857. }
  3858. switch(rnd() % 2) { //Jail Locations
  3859. case 0:
  3860. m_index = mapindex_name2id(MAP_JAIL);
  3861. x = 24;
  3862. y = 75;
  3863. break;
  3864. default:
  3865. m_index = mapindex_name2id(MAP_JAIL);
  3866. x = 49;
  3867. y = 75;
  3868. break;
  3869. }
  3870. //Duration of INT_MAX to specify infinity.
  3871. sc_start4(NULL,&pl_sd->bl,SC_JAILED,100,INT_MAX,m_index,x,y,1000);
  3872. clif_displaymessage(pl_sd->fd, msg_txt(sd,117)); // GM has send you in jails.
  3873. clif_displaymessage(fd, msg_txt(sd,118)); // Player warped in jails.
  3874. return 0;
  3875. }
  3876. /*==========================================
  3877. * @unjail/@discharge <char_name> by [Yor]
  3878. * Special warp! No check with nowarp and nowarpto flag
  3879. *------------------------------------------*/
  3880. ACMD_FUNC(unjail)
  3881. {
  3882. struct map_session_data *pl_sd;
  3883. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3884. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3885. clif_displaymessage(fd, msg_txt(sd,1135)); // Please enter a player name (usage: @unjail/@discharge <char_name>).
  3886. return -1;
  3887. }
  3888. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  3889. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  3890. return -1;
  3891. }
  3892. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) { // you can jail only lower or same GM
  3893. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  3894. return -1;
  3895. }
  3896. if (!pl_sd->sc.data[SC_JAILED])
  3897. {
  3898. clif_displaymessage(fd, msg_txt(sd,119)); // This player is not in jails.
  3899. return -1;
  3900. }
  3901. //Reset jail time to 1 sec.
  3902. sc_start(NULL,&pl_sd->bl,SC_JAILED,100,1,1000);
  3903. clif_displaymessage(pl_sd->fd, msg_txt(sd,120)); // A GM has discharged you from jail.
  3904. clif_displaymessage(fd, msg_txt(sd,121)); // Player unjailed.
  3905. return 0;
  3906. }
  3907. ACMD_FUNC(jailfor)
  3908. {
  3909. struct map_session_data *pl_sd = NULL;
  3910. int year, month, day, hour, minute, value;
  3911. char * modif_p;
  3912. int jailtime = 0,x,y;
  3913. short m_index = 0;
  3914. nullpo_retr(-1, sd);
  3915. if (!message || !*message || sscanf(message, "%255s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
  3916. clif_displaymessage(fd, msg_txt(sd,400)); //Usage: @jailfor <time> <character name>
  3917. return -1;
  3918. }
  3919. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  3920. modif_p = atcmd_output;
  3921. year = month = day = hour = minute = 0;
  3922. while (modif_p[0] != '\0') {
  3923. value = atoi(modif_p);
  3924. if (value == 0)
  3925. modif_p++;
  3926. else {
  3927. if (modif_p[0] == '-' || modif_p[0] == '+')
  3928. modif_p++;
  3929. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  3930. modif_p++;
  3931. if (modif_p[0] == 'n') {
  3932. minute = value;
  3933. modif_p++;
  3934. } else if (modif_p[0] == 'm' && modif_p[1] == 'n') {
  3935. minute = value;
  3936. modif_p = modif_p + 2;
  3937. } else if (modif_p[0] == 'h') {
  3938. hour = value;
  3939. modif_p++;
  3940. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  3941. day = value;
  3942. modif_p++;
  3943. } else if (modif_p[0] == 'm') {
  3944. month = value;
  3945. modif_p++;
  3946. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  3947. year = value;
  3948. modif_p++;
  3949. } else if (modif_p[0] != '\0') {
  3950. modif_p++;
  3951. }
  3952. }
  3953. }
  3954. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0) {
  3955. clif_displaymessage(fd, msg_txt(sd,1136)); // Invalid time for jail command.
  3956. return -1;
  3957. }
  3958. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  3959. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  3960. return -1;
  3961. }
  3962. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  3963. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  3964. return -1;
  3965. }
  3966. jailtime = year*12*30*24*60 + month*30*24*60 + day*24*60 + hour*60 + minute; //In minutes
  3967. if(jailtime==0) {
  3968. clif_displaymessage(fd, msg_txt(sd,1136)); // Invalid time for jail command.
  3969. return -1;
  3970. }
  3971. //Added by Coltaro
  3972. if(pl_sd->sc.data[SC_JAILED] &&
  3973. pl_sd->sc.data[SC_JAILED]->val1 != INT_MAX)
  3974. { //Update the player's jail time
  3975. jailtime += pl_sd->sc.data[SC_JAILED]->val1;
  3976. if (jailtime <= 0) {
  3977. jailtime = 0;
  3978. clif_displaymessage(pl_sd->fd, msg_txt(sd,120)); // GM has discharge you.
  3979. clif_displaymessage(fd, msg_txt(sd,121)); // Player unjailed
  3980. } else {
  3981. get_jail_time(jailtime,&year,&month,&day,&hour,&minute);
  3982. 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
  3983. clif_displaymessage(pl_sd->fd, atcmd_output);
  3984. 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
  3985. clif_displaymessage(fd, atcmd_output);
  3986. }
  3987. } else if (jailtime < 0) {
  3988. clif_displaymessage(fd, msg_txt(sd,1136));
  3989. return -1;
  3990. }
  3991. //Jail locations, add more as you wish.
  3992. switch(rnd()%2)
  3993. {
  3994. case 1: //Jail #1
  3995. m_index = mapindex_name2id(MAP_JAIL);
  3996. x = 49; y = 75;
  3997. break;
  3998. default: //Default Jail
  3999. m_index = mapindex_name2id(MAP_JAIL);
  4000. x = 24; y = 75;
  4001. break;
  4002. }
  4003. 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).
  4004. return 0;
  4005. }
  4006. //By Coltaro
  4007. ACMD_FUNC(jailtime)
  4008. {
  4009. int year, month, day, hour, minute;
  4010. nullpo_retr(-1, sd);
  4011. if (!sd->sc.data[SC_JAILED]) {
  4012. clif_displaymessage(fd, msg_txt(sd,1139)); // You are not in jail.
  4013. return -1;
  4014. }
  4015. if (sd->sc.data[SC_JAILED]->val1 == INT_MAX) {
  4016. clif_displaymessage(fd, msg_txt(sd,1140)); // You have been jailed indefinitely.
  4017. return 0;
  4018. }
  4019. if (sd->sc.data[SC_JAILED]->val1 <= 0) { // Was not jailed with @jailfor (maybe @jail? or warped there? or got recalled?)
  4020. clif_displaymessage(fd, msg_txt(sd,1141)); // You have been jailed for an unknown amount of time.
  4021. return -1;
  4022. }
  4023. //Get remaining jail time
  4024. get_jail_time(sd->sc.data[SC_JAILED]->val1,&year,&month,&day,&hour,&minute);
  4025. 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
  4026. clif_displaymessage(fd, atcmd_output);
  4027. return 0;
  4028. }
  4029. /*==========================================
  4030. * @disguise <mob_id> by [Valaris] (simplified by [Yor])
  4031. *------------------------------------------*/
  4032. ACMD_FUNC(disguise)
  4033. {
  4034. int id = 0;
  4035. nullpo_retr(-1, sd);
  4036. if (!message || !*message) {
  4037. clif_displaymessage(fd, msg_txt(sd,1143)); // Please enter a Monster/NPC name/ID (usage: @disguise <name/ID>).
  4038. return -1;
  4039. }
  4040. if ((id = atoi(message)) > 0)
  4041. { //Acquired an ID
  4042. if (!mobdb_checkid(id) && !npcdb_checkid(id))
  4043. id = 0; //Invalid id for either mobs or npcs.
  4044. } else { //Acquired a Name
  4045. if ((id = mobdb_searchname(message)) == 0)
  4046. {
  4047. struct npc_data* nd = npc_name2id(message);
  4048. if (nd != NULL)
  4049. id = nd->class_;
  4050. }
  4051. }
  4052. if (id == 0)
  4053. {
  4054. clif_displaymessage(fd, msg_txt(sd,123)); // Invalid Monster/NPC name/ID specified.
  4055. return -1;
  4056. }
  4057. if(pc_isriding(sd))
  4058. {
  4059. clif_displaymessage(fd, msg_txt(sd,1144)); // Character cannot be disguised while mounted.
  4060. return -1;
  4061. }
  4062. pc_disguise(sd, id);
  4063. clif_displaymessage(fd, msg_txt(sd,122)); // Disguise applied.
  4064. return 0;
  4065. }
  4066. /*==========================================
  4067. * DisguiseAll
  4068. *------------------------------------------*/
  4069. ACMD_FUNC(disguiseall)
  4070. {
  4071. int mob_id=0;
  4072. struct map_session_data *pl_sd;
  4073. struct s_mapiterator* iter;
  4074. nullpo_retr(-1, sd);
  4075. if (!message || !*message) {
  4076. clif_displaymessage(fd, msg_txt(sd,1145)); // Please enter a Monster/NPC name/ID (usage: @disguiseall <name/ID>).
  4077. return -1;
  4078. }
  4079. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name begining by a number)
  4080. mob_id = atoi(message);
  4081. if (!mobdb_checkid(mob_id) && !npcdb_checkid(mob_id)) { //if mob or npc...
  4082. clif_displaymessage(fd, msg_txt(sd,123)); // Monster/NPC name/id not found.
  4083. return -1;
  4084. }
  4085. iter = mapit_getallusers();
  4086. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4087. pc_disguise(pl_sd, mob_id);
  4088. mapit_free(iter);
  4089. clif_displaymessage(fd, msg_txt(sd,122)); // Disguise applied.
  4090. return 0;
  4091. }
  4092. /*==========================================
  4093. * DisguiseGuild
  4094. *------------------------------------------*/
  4095. ACMD_FUNC(disguiseguild)
  4096. {
  4097. int id = 0, i;
  4098. char monster[NAME_LENGTH], guild[NAME_LENGTH];
  4099. struct map_session_data *pl_sd;
  4100. struct guild *g;
  4101. memset(monster, '\0', sizeof(monster));
  4102. memset(guild, '\0', sizeof(guild));
  4103. if( !message || !*message || sscanf(message, "%23[^,], %23[^\r\n]", monster, guild) < 2 ) {
  4104. 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>).
  4105. return -1;
  4106. }
  4107. if( (id = atoi(monster)) > 0 ) {
  4108. if( !mobdb_checkid(id) && !npcdb_checkid(id) )
  4109. id = 0;
  4110. } else {
  4111. if( (id = mobdb_searchname(monster)) == 0 ) {
  4112. struct npc_data* nd = npc_name2id(monster);
  4113. if( nd != NULL )
  4114. id = nd->class_;
  4115. }
  4116. }
  4117. if( id == 0 ) {
  4118. clif_displaymessage(fd, msg_txt(sd,123)); // Monster/NPC name/id hasn't been found.
  4119. return -1;
  4120. }
  4121. if( (g = guild_searchname(guild)) == NULL && (g = guild_search(atoi(guild))) == NULL ) {
  4122. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  4123. return -1;
  4124. }
  4125. for( i = 0; i < g->max_member; i++ )
  4126. if( (pl_sd = g->member[i].sd) && !pc_isriding(pl_sd) )
  4127. pc_disguise(pl_sd, id);
  4128. clif_displaymessage(fd, msg_txt(sd,122)); // Disguise applied.
  4129. return 0;
  4130. }
  4131. /*==========================================
  4132. * @undisguise by [Yor]
  4133. *------------------------------------------*/
  4134. ACMD_FUNC(undisguise)
  4135. {
  4136. nullpo_retr(-1, sd);
  4137. if (sd->disguise) {
  4138. pc_disguise(sd, 0);
  4139. clif_displaymessage(fd, msg_txt(sd,124)); // Undisguise applied.
  4140. } else {
  4141. clif_displaymessage(fd, msg_txt(sd,125)); // You're not disguised.
  4142. return -1;
  4143. }
  4144. return 0;
  4145. }
  4146. /*==========================================
  4147. * UndisguiseAll
  4148. *------------------------------------------*/
  4149. ACMD_FUNC(undisguiseall)
  4150. {
  4151. struct map_session_data *pl_sd;
  4152. struct s_mapiterator* iter;
  4153. nullpo_retr(-1, sd);
  4154. iter = mapit_getallusers();
  4155. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4156. if( pl_sd->disguise )
  4157. pc_disguise(pl_sd, 0);
  4158. mapit_free(iter);
  4159. clif_displaymessage(fd, msg_txt(sd,124)); // Undisguise applied.
  4160. return 0;
  4161. }
  4162. /*==========================================
  4163. * UndisguiseGuild
  4164. *------------------------------------------*/
  4165. ACMD_FUNC(undisguiseguild)
  4166. {
  4167. char guild_name[NAME_LENGTH];
  4168. struct map_session_data *pl_sd;
  4169. struct guild *g;
  4170. int i;
  4171. nullpo_retr(-1, sd);
  4172. memset(guild_name, '\0', sizeof(guild_name));
  4173. if(!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  4174. clif_displaymessage(fd, msg_txt(sd,1147)); // Please enter guild name/ID (usage: @undisguiseguild <guild name/ID>).
  4175. return -1;
  4176. }
  4177. if( (g = guild_searchname(guild_name)) == NULL && (g = guild_search(atoi(message))) == NULL ) {
  4178. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  4179. return -1;
  4180. }
  4181. for(i = 0; i < g->max_member; i++)
  4182. if( (pl_sd = g->member[i].sd) && pl_sd->disguise )
  4183. pc_disguise(pl_sd, 0);
  4184. clif_displaymessage(fd, msg_txt(sd,124)); // Undisguise applied.
  4185. return 0;
  4186. }
  4187. /*==========================================
  4188. * @exp by [Skotlex]
  4189. *------------------------------------------*/
  4190. ACMD_FUNC(exp)
  4191. {
  4192. char output[CHAT_SIZE_MAX];
  4193. double nextb, nextj;
  4194. nullpo_retr(-1, sd);
  4195. memset(output, '\0', sizeof(output));
  4196. nextb = pc_nextbaseexp(sd);
  4197. if (nextb)
  4198. nextb = sd->status.base_exp*100.0/nextb;
  4199. nextj = pc_nextjobexp(sd);
  4200. if (nextj)
  4201. nextj = sd->status.job_exp*100.0/nextj;
  4202. sprintf(output, msg_txt(sd,1148), sd->status.base_level, nextb, sd->status.job_level, nextj); // Base Level: %d (%.3f%%) | Job Level: %d (%.3f%%)
  4203. clif_displaymessage(fd, output);
  4204. return 0;
  4205. }
  4206. /*==========================================
  4207. * @broadcast by [Valaris]
  4208. *------------------------------------------*/
  4209. ACMD_FUNC(broadcast)
  4210. {
  4211. nullpo_retr(-1, sd);
  4212. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4213. if (!message || !*message) {
  4214. clif_displaymessage(fd, msg_txt(sd,1149)); // Please enter a message (usage: @broadcast <message>).
  4215. return -1;
  4216. }
  4217. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4218. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, 0);
  4219. return 0;
  4220. }
  4221. /*==========================================
  4222. * @localbroadcast by [Valaris]
  4223. *------------------------------------------*/
  4224. ACMD_FUNC(localbroadcast)
  4225. {
  4226. nullpo_retr(-1, sd);
  4227. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4228. if (!message || !*message) {
  4229. clif_displaymessage(fd, msg_txt(sd,1150)); // Please enter a message (usage: @localbroadcast <message>).
  4230. return -1;
  4231. }
  4232. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4233. clif_broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, 0, ALL_SAMEMAP);
  4234. return 0;
  4235. }
  4236. /*==========================================
  4237. * @email <actual@email> <new@email> by [Yor]
  4238. *------------------------------------------*/
  4239. ACMD_FUNC(email)
  4240. {
  4241. char actual_email[100];
  4242. char new_email[100];
  4243. nullpo_retr(-1, sd);
  4244. memset(actual_email, '\0', sizeof(actual_email));
  4245. memset(new_email, '\0', sizeof(new_email));
  4246. if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
  4247. clif_displaymessage(fd, msg_txt(sd,1151)); // Please enter 2 emails (usage: @email <actual@email> <new@email>).
  4248. return -1;
  4249. }
  4250. if (e_mail_check(actual_email) == 0) {
  4251. clif_displaymessage(fd, msg_txt(sd,144)); // Invalid actual email. If you have default e-mail, give a@a.com.
  4252. return -1;
  4253. } else if (e_mail_check(new_email) == 0) {
  4254. clif_displaymessage(fd, msg_txt(sd,145)); // Invalid new email. Please enter a real e-mail.
  4255. return -1;
  4256. } else if (strcmpi(new_email, "a@a.com") == 0) {
  4257. clif_displaymessage(fd, msg_txt(sd,146)); // New email must be a real e-mail.
  4258. return -1;
  4259. } else if (strcmpi(actual_email, new_email) == 0) {
  4260. clif_displaymessage(fd, msg_txt(sd,147)); // New email must be different of the actual e-mail.
  4261. return -1;
  4262. }
  4263. chrif_changeemail(sd->status.account_id, actual_email, new_email);
  4264. clif_displaymessage(fd, msg_txt(sd,148)); // Information sended to login-server via char-server.
  4265. return 0;
  4266. }
  4267. /*==========================================
  4268. *@effect
  4269. *------------------------------------------*/
  4270. ACMD_FUNC(effect)
  4271. {
  4272. int type = 0, flag = 0;
  4273. nullpo_retr(-1, sd);
  4274. if (!message || !*message || sscanf(message, "%d", &type) < 1) {
  4275. clif_displaymessage(fd, msg_txt(sd,1152)); // Please enter an effect number (usage: @effect <effect number>).
  4276. return -1;
  4277. }
  4278. clif_specialeffect(&sd->bl, type, (send_target)flag);
  4279. clif_displaymessage(fd, msg_txt(sd,229)); // Your effect has changed.
  4280. return 0;
  4281. }
  4282. /*==========================================
  4283. * @killer by MouseJstr
  4284. * enable killing players even when not in pvp
  4285. *------------------------------------------*/
  4286. ACMD_FUNC(killer)
  4287. {
  4288. nullpo_retr(-1, sd);
  4289. sd->state.killer = !sd->state.killer;
  4290. if(sd->state.killer)
  4291. clif_displaymessage(fd, msg_txt(sd,241));
  4292. else {
  4293. clif_displaymessage(fd, msg_txt(sd,292));
  4294. pc_stop_attack(sd);
  4295. }
  4296. return 0;
  4297. }
  4298. /*==========================================
  4299. * @killable by MouseJstr
  4300. * enable other people killing you
  4301. *------------------------------------------*/
  4302. ACMD_FUNC(killable)
  4303. {
  4304. nullpo_retr(-1, sd);
  4305. sd->state.killable = !sd->state.killable;
  4306. if(sd->state.killable)
  4307. clif_displaymessage(fd, msg_txt(sd,242));
  4308. else {
  4309. clif_displaymessage(fd, msg_txt(sd,288));
  4310. map_foreachinrange(atcommand_stopattack,&sd->bl, AREA_SIZE, BL_CHAR, sd->bl.id);
  4311. }
  4312. return 0;
  4313. }
  4314. /*==========================================
  4315. * @skillon by MouseJstr
  4316. * turn skills on for the map
  4317. *------------------------------------------*/
  4318. ACMD_FUNC(skillon)
  4319. {
  4320. nullpo_retr(-1, sd);
  4321. map[sd->bl.m].flag.noskill = 0;
  4322. clif_displaymessage(fd, msg_txt(sd,244));
  4323. return 0;
  4324. }
  4325. /*==========================================
  4326. * @skilloff by MouseJstr
  4327. * Turn skills off on the map
  4328. *------------------------------------------*/
  4329. ACMD_FUNC(skilloff)
  4330. {
  4331. nullpo_retr(-1, sd);
  4332. map[sd->bl.m].flag.noskill = 1;
  4333. clif_displaymessage(fd, msg_txt(sd,243));
  4334. return 0;
  4335. }
  4336. /*==========================================
  4337. * @npcmove by MouseJstr
  4338. * move a npc
  4339. *------------------------------------------*/
  4340. ACMD_FUNC(npcmove)
  4341. {
  4342. int x = 0, y = 0, m;
  4343. struct npc_data *nd = 0;
  4344. nullpo_retr(-1, sd);
  4345. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  4346. if (!message || !*message || sscanf(message, "%d %d %23[^\n]", &x, &y, atcmd_player_name) < 3) {
  4347. clif_displaymessage(fd, msg_txt(sd,1153)); // Usage: @npcmove <X> <Y> <npc_name>
  4348. return -1;
  4349. }
  4350. if ((nd = npc_name2id(atcmd_player_name)) == NULL)
  4351. {
  4352. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  4353. return -1;
  4354. }
  4355. if ((m=nd->bl.m) < 0 || nd->bl.prev == NULL)
  4356. {
  4357. clif_displaymessage(fd, msg_txt(sd,1154)); // NPC is not on this map.
  4358. return -1; //Not on a map.
  4359. }
  4360. x = cap_value(x, 0, map[m].xs-1);
  4361. y = cap_value(y, 0, map[m].ys-1);
  4362. map_foreachinrange(clif_outsight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  4363. map_moveblock(&nd->bl, x, y, gettick());
  4364. map_foreachinrange(clif_insight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  4365. clif_displaymessage(fd, msg_txt(sd,1155)); // NPC moved.
  4366. return 0;
  4367. }
  4368. /*==========================================
  4369. * @addwarp by MouseJstr
  4370. * Create a new static warp point.
  4371. *------------------------------------------*/
  4372. ACMD_FUNC(addwarp)
  4373. {
  4374. char mapname[32], warpname[NAME_LENGTH+1];
  4375. int x,y;
  4376. unsigned short m;
  4377. struct npc_data* nd;
  4378. nullpo_retr(-1, sd);
  4379. memset(warpname, '\0', sizeof(warpname));
  4380. if (!message || !*message || sscanf(message, "%31s %d %d %23[^\n]", mapname, &x, &y, warpname) < 4) {
  4381. clif_displaymessage(fd, msg_txt(sd,1156)); // Usage: @addwarp <mapname> <X> <Y> <npc name>
  4382. return -1;
  4383. }
  4384. m = mapindex_name2id(mapname);
  4385. if( m == 0 )
  4386. {
  4387. sprintf(atcmd_output, msg_txt(sd,1157), mapname); // Unknown map '%s'.
  4388. clif_displaymessage(fd, atcmd_output);
  4389. return -1;
  4390. }
  4391. nd = npc_add_warp(warpname, sd->bl.m, sd->bl.x, sd->bl.y, 2, 2, m, x, y);
  4392. if( nd == NULL )
  4393. return -1;
  4394. sprintf(atcmd_output, msg_txt(sd,1158), nd->exname); // New warp NPC '%s' created.
  4395. clif_displaymessage(fd, atcmd_output);
  4396. return 0;
  4397. }
  4398. /*==========================================
  4399. * @follow by [MouseJstr]
  4400. * Follow a player .. staying no more then 5 spaces away
  4401. *------------------------------------------*/
  4402. ACMD_FUNC(follow)
  4403. {
  4404. struct map_session_data *pl_sd = NULL;
  4405. nullpo_retr(-1, sd);
  4406. if (!message || !*message) {
  4407. if (sd->followtarget == -1)
  4408. return -1;
  4409. pc_stop_following (sd);
  4410. clif_displaymessage(fd, msg_txt(sd,1159)); // Follow mode OFF.
  4411. return 0;
  4412. }
  4413. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  4414. {
  4415. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4416. return -1;
  4417. }
  4418. if (sd->followtarget == pl_sd->bl.id) {
  4419. pc_stop_following (sd);
  4420. clif_displaymessage(fd, msg_txt(sd,1159)); // Follow mode OFF.
  4421. } else {
  4422. pc_follow(sd, pl_sd->bl.id);
  4423. clif_displaymessage(fd, msg_txt(sd,1160)); // Follow mode ON.
  4424. }
  4425. return 0;
  4426. }
  4427. /*==========================================
  4428. * @dropall by [MouseJstr]
  4429. * Drop all your possession on the ground
  4430. *------------------------------------------*/
  4431. ACMD_FUNC(dropall)
  4432. {
  4433. int i;
  4434. nullpo_retr(-1, sd);
  4435. for (i = 0; i < MAX_INVENTORY; i++) {
  4436. if (sd->status.inventory[i].amount) {
  4437. if(sd->status.inventory[i].equip != 0)
  4438. pc_unequipitem(sd, i, 3);
  4439. pc_dropitem(sd, i, sd->status.inventory[i].amount);
  4440. }
  4441. }
  4442. return 0;
  4443. }
  4444. /*==========================================
  4445. * @storeall by [MouseJstr]
  4446. * Put everything into storage
  4447. *------------------------------------------*/
  4448. ACMD_FUNC(storeall)
  4449. {
  4450. int i;
  4451. nullpo_retr(-1, sd);
  4452. if (sd->state.storage_flag != 1)
  4453. { //Open storage.
  4454. if( storage_storageopen(sd) == 1 ) {
  4455. clif_displaymessage(fd, msg_txt(sd,1161)); // You currently cannot open your storage.
  4456. return -1;
  4457. }
  4458. }
  4459. for (i = 0; i < MAX_INVENTORY; i++) {
  4460. if (sd->status.inventory[i].amount) {
  4461. if(sd->status.inventory[i].equip != 0)
  4462. pc_unequipitem(sd, i, 3);
  4463. storage_storageadd(sd, i, sd->status.inventory[i].amount);
  4464. }
  4465. }
  4466. storage_storageclose(sd);
  4467. clif_displaymessage(fd, msg_txt(sd,1162)); // All items stored.
  4468. return 0;
  4469. }
  4470. ACMD_FUNC(clearstorage)
  4471. {
  4472. int i, j;
  4473. nullpo_retr(-1, sd);
  4474. if (sd->state.storage_flag == 1) {
  4475. clif_displaymessage(fd, msg_txt(sd,250));
  4476. return -1;
  4477. }
  4478. j = sd->status.storage.storage_amount;
  4479. for (i = 0; i < j; ++i) {
  4480. storage_delitem(sd, i, sd->status.storage.items[i].amount);
  4481. }
  4482. storage_storageclose(sd);
  4483. clif_displaymessage(fd, msg_txt(sd,1394)); // Your storage was cleaned.
  4484. return 0;
  4485. }
  4486. ACMD_FUNC(cleargstorage)
  4487. {
  4488. int i, j;
  4489. struct guild *g;
  4490. struct guild_storage *gstorage;
  4491. nullpo_retr(-1, sd);
  4492. g = sd->guild;
  4493. if (g == NULL) {
  4494. clif_displaymessage(fd, msg_txt(sd,43));
  4495. return -1;
  4496. }
  4497. if (sd->state.storage_flag == 1) {
  4498. clif_displaymessage(fd, msg_txt(sd,250));
  4499. return -1;
  4500. }
  4501. if (sd->state.storage_flag == 2) {
  4502. clif_displaymessage(fd, msg_txt(sd,251));
  4503. return -1;
  4504. }
  4505. gstorage = guild2storage2(sd->status.guild_id);
  4506. if (gstorage == NULL) {// Doesn't have opened @gstorage yet, so we skip the deletion since *shouldn't* have any item there.
  4507. return -1;
  4508. }
  4509. j = gstorage->storage_amount;
  4510. gstorage->lock = 1; // Lock @gstorage: do not allow any item to be retrieved or stored from any guild member
  4511. for (i = 0; i < j; ++i) {
  4512. guild_storage_delitem(sd, gstorage, i, gstorage->items[i].amount);
  4513. }
  4514. storage_guild_storageclose(sd);
  4515. gstorage->lock = 0; // Cleaning done, release lock
  4516. clif_displaymessage(fd, msg_txt(sd,1395)); // Your guild storage was cleaned.
  4517. return 0;
  4518. }
  4519. ACMD_FUNC(clearcart)
  4520. {
  4521. int i;
  4522. nullpo_retr(-1, sd);
  4523. if (pc_iscarton(sd) == 0) {
  4524. clif_displaymessage(fd, msg_txt(sd,1396)); // You do not have a cart to be cleaned.
  4525. return -1;
  4526. }
  4527. if (sd->state.vending == 1) { //Somehow...
  4528. return -1;
  4529. }
  4530. for( i = 0; i < MAX_CART; i++ )
  4531. if(sd->status.cart[i].nameid > 0)
  4532. pc_cart_delitem(sd, i, sd->status.cart[i].amount, 1, LOG_TYPE_OTHER);
  4533. clif_clearcart(fd);
  4534. clif_updatestatus(sd,SP_CARTINFO);
  4535. clif_displaymessage(fd, msg_txt(sd,1397)); // Your cart was cleaned.
  4536. return 0;
  4537. }
  4538. /*==========================================
  4539. * @skillid by [MouseJstr]
  4540. * lookup a skill by name
  4541. *------------------------------------------*/
  4542. #define MAX_SKILLID_PARTIAL_RESULTS 5
  4543. #define MAX_SKILLID_PARTIAL_RESULTS_LEN 74 // "skill " (6) + "%d:" (up to 5) + "%s" (up to 30) + " (%s)" (up to 33)
  4544. ACMD_FUNC(skillid) {
  4545. int skillen, idx, i, found = 0;
  4546. DBIterator* iter;
  4547. DBKey key;
  4548. DBData *data;
  4549. char partials[MAX_SKILLID_PARTIAL_RESULTS][MAX_SKILLID_PARTIAL_RESULTS_LEN];
  4550. nullpo_retr(-1, sd);
  4551. if (!message || !*message) {
  4552. clif_displaymessage(fd, msg_txt(sd,1163)); // Please enter a skill name to look up (usage: @skillid <skill name>).
  4553. return -1;
  4554. }
  4555. skillen = strlen(message);
  4556. iter = db_iterator(skilldb_name2id);
  4557. for( data = iter->first(iter,&key); iter->exists(iter); data = iter->next(iter,&key) ) {
  4558. idx = skill_get_index(db_data2i(data));
  4559. if (strnicmp(key.str, message, skillen) == 0 || strnicmp(skill_db[idx].desc, message, skillen) == 0) {
  4560. sprintf(atcmd_output, msg_txt(sd,1164), db_data2i(data), skill_db[idx].desc, key.str); // skill %d: %s (%s)
  4561. clif_displaymessage(fd, atcmd_output);
  4562. } else if ( found < MAX_SKILLID_PARTIAL_RESULTS && ( stristr(key.str,message) || stristr(skill_db[idx].desc,message) ) ) {
  4563. snprintf(partials[found++], MAX_SKILLID_PARTIAL_RESULTS_LEN, msg_txt(sd,1164), db_data2i(data), skill_db[idx].desc, key.str);
  4564. }
  4565. }
  4566. dbi_destroy(iter);
  4567. if( found ) {
  4568. sprintf(atcmd_output, msg_txt(sd,1398), found); // -- Displaying first %d partial matches
  4569. clif_displaymessage(fd, atcmd_output);
  4570. }
  4571. for(i = 0; i < found; i++) { /* partials */
  4572. clif_displaymessage(fd, partials[i]);
  4573. }
  4574. return 0;
  4575. }
  4576. /*==========================================
  4577. * @useskill by [MouseJstr]
  4578. * A way of using skills without having to find them in the skills menu
  4579. *------------------------------------------*/
  4580. ACMD_FUNC(useskill)
  4581. {
  4582. struct map_session_data *pl_sd = NULL;
  4583. struct block_list *bl;
  4584. uint16 skill_id;
  4585. uint16 skill_lv;
  4586. char target[100];
  4587. nullpo_retr(-1, sd);
  4588. if(!message || !*message || sscanf(message, "%hu %hu %23[^\n]", &skill_id, &skill_lv, target) != 3) {
  4589. clif_displaymessage(fd, msg_txt(sd,1165)); // Usage: @useskill <skill ID> <skill level> <target>
  4590. return -1;
  4591. }
  4592. if(!strcmp(target,"self")) pl_sd = sd; //quick keyword
  4593. else if ( (pl_sd = map_nick2sd(target)) == NULL ){
  4594. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4595. return -1;
  4596. }
  4597. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  4598. {
  4599. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4600. return -1;
  4601. }
  4602. if (skill_id >= HM_SKILLBASE && skill_id < HM_SKILLBASE+MAX_HOMUNSKILL
  4603. && sd->hd && merc_is_hom_active(sd->hd)) // (If used with @useskill, put the homunc as dest)
  4604. bl = &sd->hd->bl;
  4605. else
  4606. bl = &sd->bl;
  4607. if (skill_get_inf(skill_id)&INF_GROUND_SKILL)
  4608. unit_skilluse_pos(bl, pl_sd->bl.x, pl_sd->bl.y, skill_id, skill_lv);
  4609. else
  4610. unit_skilluse_id(bl, pl_sd->bl.id, skill_id, skill_lv);
  4611. return 0;
  4612. }
  4613. /*==========================================
  4614. * @displayskill by [Skotlex]
  4615. * Debug command to locate new skill IDs. It sends the
  4616. * three possible skill-effect packets to the area.
  4617. *------------------------------------------*/
  4618. ACMD_FUNC(displayskill)
  4619. {
  4620. struct status_data * status;
  4621. unsigned int tick;
  4622. uint16 skill_id;
  4623. uint16 skill_lv = 1;
  4624. nullpo_retr(-1, sd);
  4625. if (!message || !*message || sscanf(message, "%hu %hu", &skill_id, &skill_lv) < 1)
  4626. {
  4627. clif_displaymessage(fd, msg_txt(sd,1166)); // Usage: @displayskill <skill ID> {<skill level>}
  4628. return -1;
  4629. }
  4630. status = status_get_status_data(&sd->bl);
  4631. tick = gettick();
  4632. clif_skill_damage(&sd->bl,&sd->bl, tick, status->amotion, status->dmotion, 1, 1, skill_id, skill_lv, 5);
  4633. clif_skill_nodamage(&sd->bl, &sd->bl, skill_id, skill_lv, 1);
  4634. clif_skill_poseffect(&sd->bl, skill_id, skill_lv, sd->bl.x, sd->bl.y, tick);
  4635. return 0;
  4636. }
  4637. /*==========================================
  4638. * @skilltree by [MouseJstr]
  4639. * prints the skill tree for a player required to get to a skill
  4640. *------------------------------------------*/
  4641. ACMD_FUNC(skilltree)
  4642. {
  4643. struct map_session_data *pl_sd = NULL;
  4644. uint16 skill_id;
  4645. int meets, j, c=0;
  4646. char target[NAME_LENGTH];
  4647. struct skill_tree_entry *ent;
  4648. nullpo_retr(-1, sd);
  4649. if(!message || !*message || sscanf(message, "%hu %23[^\r\n]", &skill_id, target) != 2) {
  4650. clif_displaymessage(fd, msg_txt(sd,1167)); // Usage: @skilltree <skill ID> <target>
  4651. return -1;
  4652. }
  4653. if ( (pl_sd = map_nick2sd(target)) == NULL )
  4654. {
  4655. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4656. return -1;
  4657. }
  4658. c = pc_calc_skilltree_normalize_job(pl_sd);
  4659. c = pc_mapid2jobid(c, pl_sd->status.sex);
  4660. 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).
  4661. clif_displaymessage(fd, atcmd_output);
  4662. ARR_FIND( 0, MAX_SKILL_TREE, j, skill_tree[c][j].id == 0 || skill_tree[c][j].id == skill_id );
  4663. if( j == MAX_SKILL_TREE || skill_tree[c][j].id == 0 )
  4664. {
  4665. clif_displaymessage(fd, msg_txt(sd,1169)); // The player cannot use that skill.
  4666. return 0;
  4667. }
  4668. ent = &skill_tree[c][j];
  4669. meets = 1;
  4670. for(j=0;j<MAX_PC_SKILL_REQUIRE;j++)
  4671. {
  4672. if( ent->need[j].id && pc_checkskill(sd,ent->need[j].id) < ent->need[j].lv)
  4673. {
  4674. 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.
  4675. clif_displaymessage(fd, atcmd_output);
  4676. meets = 0;
  4677. }
  4678. }
  4679. if (meets == 1) {
  4680. clif_displaymessage(fd, msg_txt(sd,1171)); // The player meets all the requirements for that skill.
  4681. }
  4682. return 0;
  4683. }
  4684. // Hand a ring with partners name on it to this char
  4685. void getring (struct map_session_data* sd)
  4686. {
  4687. int flag, item_id;
  4688. struct item item_tmp;
  4689. item_id = (sd->status.sex) ? WEDDING_RING_M : WEDDING_RING_F;
  4690. memset(&item_tmp, 0, sizeof(item_tmp));
  4691. item_tmp.nameid = item_id;
  4692. item_tmp.identify = 1;
  4693. item_tmp.card[0] = 255;
  4694. item_tmp.card[2] = sd->status.partner_id;
  4695. item_tmp.card[3] = sd->status.partner_id >> 16;
  4696. if((flag = pc_additem(sd,&item_tmp,1,LOG_TYPE_COMMAND))) {
  4697. clif_additem(sd,0,0,flag);
  4698. map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,4);
  4699. }
  4700. }
  4701. /*==========================================
  4702. * @marry by [MouseJstr], fixed by Lupus
  4703. * Marry two players
  4704. *------------------------------------------*/
  4705. ACMD_FUNC(marry)
  4706. {
  4707. struct map_session_data *pl_sd = NULL;
  4708. char player_name[NAME_LENGTH] = "";
  4709. nullpo_retr(-1, sd);
  4710. if (!message || !*message || sscanf(message, "%23s", player_name) != 1) {
  4711. clif_displaymessage(fd, msg_txt(sd,1172)); // Usage: @marry <char name>
  4712. return -1;
  4713. }
  4714. if ((pl_sd = map_nick2sd(player_name)) == NULL) {
  4715. clif_displaymessage(fd, msg_txt(sd,3));
  4716. return -1;
  4717. }
  4718. if (pc_marriage(sd, pl_sd) == 0) {
  4719. clif_displaymessage(fd, msg_txt(sd,1173)); // They are married... wish them well.
  4720. clif_wedding_effect(&pl_sd->bl); //wedding effect and music [Lupus]
  4721. getring(sd); // Auto-give named rings (Aru)
  4722. getring(pl_sd);
  4723. return 0;
  4724. }
  4725. clif_displaymessage(fd, msg_txt(sd,1174)); // The two cannot wed because one is either a baby or already married.
  4726. return -1;
  4727. }
  4728. /*==========================================
  4729. * @divorce by [MouseJstr], fixed by [Lupus]
  4730. * divorce two players
  4731. *------------------------------------------*/
  4732. ACMD_FUNC(divorce)
  4733. {
  4734. nullpo_retr(-1, sd);
  4735. if (pc_divorce(sd) != 0) {
  4736. sprintf(atcmd_output, msg_txt(sd,1175), sd->status.name); // '%s' is not married.
  4737. clif_displaymessage(fd, atcmd_output);
  4738. return -1;
  4739. }
  4740. sprintf(atcmd_output, msg_txt(sd,1176), sd->status.name); // '%s' and his/her partner are now divorced.
  4741. clif_displaymessage(fd, atcmd_output);
  4742. return 0;
  4743. }
  4744. /*==========================================
  4745. * @changelook by [Celest]
  4746. *------------------------------------------*/
  4747. ACMD_FUNC(changelook)
  4748. {
  4749. int i, j = 0, k = 0;
  4750. int pos[7] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES,LOOK_ROBE };
  4751. if((i = sscanf(message, "%d %d", &j, &k)) < 1) {
  4752. clif_displaymessage(fd, msg_txt(sd,1177)); // Usage: @changelook {<position>} <view id>
  4753. clif_displaymessage(fd, msg_txt(sd,1178)); // Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield 6-Shoes 7-Robe
  4754. return -1;
  4755. } else if ( i == 2 ) {
  4756. if (j < 1 || j > 7)
  4757. j = 1;
  4758. j = pos[j - 1];
  4759. } else if( i == 1 ) { // position not defined, use HEAD_TOP as default
  4760. k = j; // swap
  4761. j = LOOK_HEAD_TOP;
  4762. }
  4763. clif_changelook(&sd->bl,j,k);
  4764. return 0;
  4765. }
  4766. /*==========================================
  4767. * @autotrade by durf [Lupus] [Paradox924X]
  4768. * Turns on/off Autotrade for a specific player
  4769. *------------------------------------------*/
  4770. ACMD_FUNC(autotrade) {
  4771. nullpo_retr(-1, sd);
  4772. if( map[sd->bl.m].flag.autotrade != battle_config.autotrade_mapflag ) {
  4773. clif_displaymessage(fd, msg_txt(sd,1179)); // Autotrade is not allowed on this map.
  4774. return -1;
  4775. }
  4776. if( pc_isdead(sd) ) {
  4777. clif_displaymessage(fd, msg_txt(sd,1180)); // You cannot autotrade when dead.
  4778. return -1;
  4779. }
  4780. if( !sd->state.vending && !sd->state.buyingstore ) { //check if player is vending or buying
  4781. clif_displaymessage(fd, msg_txt(sd,549)); // "You should have a shop open to use @autotrade."
  4782. return -1;
  4783. }
  4784. sd->state.autotrade = 1;
  4785. if( battle_config.at_timeout ) {
  4786. int timeout = atoi(message);
  4787. 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);
  4788. }
  4789. channel_pcquit(sd,0xF); //leave all chan
  4790. clif_authfail_fd(sd->fd, 15);
  4791. return 0;
  4792. }
  4793. /*==========================================
  4794. * @changegm by durf (changed by Lupus)
  4795. * Changes Master of your Guild to a specified guild member
  4796. *------------------------------------------*/
  4797. ACMD_FUNC(changegm)
  4798. {
  4799. struct guild *g;
  4800. struct map_session_data *pl_sd;
  4801. nullpo_retr(-1, sd);
  4802. if (sd->status.guild_id == 0 || (g = sd->guild) == NULL || strcmp(g->master,sd->status.name)) {
  4803. clif_displaymessage(fd, msg_txt(sd,1181)); // You need to be a Guild Master to use this command.
  4804. return -1;
  4805. }
  4806. if( map[sd->bl.m].flag.guildlock || map[sd->bl.m].flag.gvg_castle ) {
  4807. clif_displaymessage(fd, msg_txt(sd,1182)); // You cannot change guild leaders on this map.
  4808. return -1;
  4809. }
  4810. if( !message[0] ) {
  4811. clif_displaymessage(fd, msg_txt(sd,1183)); // Usage: @changegm <guild_member_name>
  4812. return -1;
  4813. }
  4814. if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) {
  4815. clif_displaymessage(fd, msg_txt(sd,1184)); // Target character must be online and be a guild member.
  4816. return -1;
  4817. }
  4818. guild_gm_change(sd->status.guild_id, pl_sd);
  4819. return 0;
  4820. }
  4821. /*==========================================
  4822. * @changeleader by Skotlex
  4823. * Changes the leader of a party.
  4824. *------------------------------------------*/
  4825. ACMD_FUNC(changeleader)
  4826. {
  4827. nullpo_retr(-1, sd);
  4828. if( !message[0] )
  4829. {
  4830. clif_displaymessage(fd, msg_txt(sd,1185)); // Usage: @changeleader <party_member_name>
  4831. return -1;
  4832. }
  4833. if (party_changeleader(sd, map_nick2sd((char *) message)))
  4834. return 0;
  4835. return -1;
  4836. }
  4837. /*==========================================
  4838. * @partyoption by Skotlex
  4839. * Used to change the item share setting of a party.
  4840. *------------------------------------------*/
  4841. ACMD_FUNC(partyoption)
  4842. {
  4843. struct party_data *p;
  4844. int mi, option;
  4845. char w1[16], w2[16];
  4846. nullpo_retr(-1, sd);
  4847. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
  4848. {
  4849. clif_displaymessage(fd, msg_txt(sd,282));
  4850. return -1;
  4851. }
  4852. ARR_FIND( 0, MAX_PARTY, mi, p->data[mi].sd == sd );
  4853. if (mi == MAX_PARTY)
  4854. return -1; //Shouldn't happen
  4855. if (!p->party.member[mi].leader)
  4856. {
  4857. clif_displaymessage(fd, msg_txt(sd,282));
  4858. return -1;
  4859. }
  4860. if(!message || !*message || sscanf(message, "%15s %15s", w1, w2) < 2)
  4861. {
  4862. clif_displaymessage(fd, msg_txt(sd,1186)); // Usage: @partyoption <pickup share: yes/no> <item distribution: yes/no>
  4863. return -1;
  4864. }
  4865. option = (config_switch(w1)?1:0)|(config_switch(w2)?2:0);
  4866. //Change item share type.
  4867. if (option != p->party.item)
  4868. party_changeoption(sd, p->party.exp, option);
  4869. else
  4870. clif_displaymessage(fd, msg_txt(sd,286));
  4871. return 0;
  4872. }
  4873. /*==========================================
  4874. * @autoloot by Upa-Kun
  4875. * Turns on/off AutoLoot for a specific player
  4876. *------------------------------------------*/
  4877. ACMD_FUNC(autoloot)
  4878. {
  4879. int rate;
  4880. nullpo_retr(-1, sd);
  4881. // autoloot command without value
  4882. if(!message || !*message)
  4883. {
  4884. if (sd->state.autoloot)
  4885. rate = 0;
  4886. else
  4887. rate = 10000;
  4888. } else {
  4889. double drate;
  4890. drate = atof(message);
  4891. rate = (int)(drate*100);
  4892. }
  4893. if (rate < 0) rate = 0;
  4894. if (rate > 10000) rate = 10000;
  4895. sd->state.autoloot = rate;
  4896. if (sd->state.autoloot) {
  4897. 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.
  4898. clif_displaymessage(fd, atcmd_output);
  4899. }else
  4900. clif_displaymessage(fd, msg_txt(sd,1188)); // Autoloot is now off.
  4901. return 0;
  4902. }
  4903. /*==========================================
  4904. * @alootid
  4905. *------------------------------------------*/
  4906. ACMD_FUNC(autolootitem)
  4907. {
  4908. struct item_data *item_data = NULL;
  4909. int i;
  4910. int action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset
  4911. if (message && *message) {
  4912. if (message[0] == '+') {
  4913. message++;
  4914. action = 1;
  4915. }
  4916. else if (message[0] == '-') {
  4917. message++;
  4918. action = 2;
  4919. }
  4920. else if (!strcmp(message,"reset"))
  4921. action = 4;
  4922. }
  4923. if (action < 3) // add or remove
  4924. {
  4925. if ((item_data = itemdb_exists(atoi(message))) == NULL)
  4926. item_data = itemdb_searchname(message);
  4927. if (!item_data) {
  4928. // No items founds in the DB with Id or Name
  4929. clif_displaymessage(fd, msg_txt(sd,1189)); // Item not found.
  4930. return -1;
  4931. }
  4932. }
  4933. switch(action) {
  4934. case 1:
  4935. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
  4936. if (i != AUTOLOOTITEM_SIZE) {
  4937. clif_displaymessage(fd, msg_txt(sd,1190)); // You're already autolooting this item.
  4938. return -1;
  4939. }
  4940. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == 0);
  4941. if (i == AUTOLOOTITEM_SIZE) {
  4942. clif_displaymessage(fd, msg_txt(sd,1191)); // Your autolootitem list is full. Remove some items first with @autolootid -<item name or ID>.
  4943. return -1;
  4944. }
  4945. sd->state.autolootid[i] = item_data->nameid; // Autoloot Activated
  4946. sprintf(atcmd_output, msg_txt(sd,1192), item_data->name, item_data->jname, item_data->nameid); // Autolooting item: '%s'/'%s' {%d}
  4947. clif_displaymessage(fd, atcmd_output);
  4948. sd->state.autolooting = 1;
  4949. break;
  4950. case 2:
  4951. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
  4952. if (i == AUTOLOOTITEM_SIZE) {
  4953. clif_displaymessage(fd, msg_txt(sd,1193)); // You're currently not autolooting this item.
  4954. return -1;
  4955. }
  4956. sd->state.autolootid[i] = 0;
  4957. 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.
  4958. clif_displaymessage(fd, atcmd_output);
  4959. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
  4960. if (i == AUTOLOOTITEM_SIZE) {
  4961. sd->state.autolooting = 0;
  4962. }
  4963. break;
  4964. case 3:
  4965. sprintf(atcmd_output, msg_txt(sd,1195), AUTOLOOTITEM_SIZE); // You can have %d items on your autolootitem list.
  4966. clif_displaymessage(fd, atcmd_output);
  4967. 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>".
  4968. clif_displaymessage(fd, msg_txt(sd,1197)); // "@alootid reset" will clear your autolootitem list.
  4969. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
  4970. if (i == AUTOLOOTITEM_SIZE) {
  4971. clif_displaymessage(fd, msg_txt(sd,1198)); // Your autolootitem list is empty.
  4972. } else {
  4973. clif_displaymessage(fd, msg_txt(sd,1199)); // Items on your autolootitem list:
  4974. for(i = 0; i < AUTOLOOTITEM_SIZE; i++)
  4975. {
  4976. if (sd->state.autolootid[i] == 0)
  4977. continue;
  4978. if (!(item_data = itemdb_exists(sd->state.autolootid[i]))) {
  4979. 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);
  4980. continue;
  4981. }
  4982. sprintf(atcmd_output, "'%s'/'%s' {%d}", item_data->name, item_data->jname, item_data->nameid);
  4983. clif_displaymessage(fd, atcmd_output);
  4984. }
  4985. }
  4986. break;
  4987. case 4:
  4988. memset(sd->state.autolootid, 0, sizeof(sd->state.autolootid));
  4989. clif_displaymessage(fd, msg_txt(sd,1200)); // Your autolootitem list has been reset.
  4990. sd->state.autolooting = 0;
  4991. break;
  4992. }
  4993. return 0;
  4994. }
  4995. /**
  4996. * No longer available, keeping here just in case it's back someday. [Ind]
  4997. **/
  4998. /*==========================================
  4999. * It is made to rain.
  5000. *------------------------------------------*/
  5001. //ACMD_FUNC(rain)
  5002. //{
  5003. // nullpo_retr(-1, sd);
  5004. // if (map[sd->bl.m].flag.rain) {
  5005. // map[sd->bl.m].flag.rain=0;
  5006. // clif_weather(sd->bl.m);
  5007. // clif_displaymessage(fd, msg_txt(sd,1201)); // The rain has stopped.
  5008. // } else {
  5009. // map[sd->bl.m].flag.rain=1;
  5010. // clif_weather(sd->bl.m);
  5011. // clif_displaymessage(fd, msg_txt(sd,1202)); // It has started to rain.
  5012. // }
  5013. // return 0;
  5014. //}
  5015. /*==========================================
  5016. * It is made to snow.
  5017. *------------------------------------------*/
  5018. ACMD_FUNC(snow)
  5019. {
  5020. nullpo_retr(-1, sd);
  5021. if (map[sd->bl.m].flag.snow) {
  5022. map[sd->bl.m].flag.snow=0;
  5023. clif_weather(sd->bl.m);
  5024. clif_displaymessage(fd, msg_txt(sd,1203)); // Snow has stopped falling.
  5025. } else {
  5026. map[sd->bl.m].flag.snow=1;
  5027. clif_weather(sd->bl.m);
  5028. clif_displaymessage(fd, msg_txt(sd,1204)); // It has started to snow.
  5029. }
  5030. return 0;
  5031. }
  5032. /*==========================================
  5033. * Cherry tree snowstorm is made to fall. (Sakura)
  5034. *------------------------------------------*/
  5035. ACMD_FUNC(sakura)
  5036. {
  5037. nullpo_retr(-1, sd);
  5038. if (map[sd->bl.m].flag.sakura) {
  5039. map[sd->bl.m].flag.sakura=0;
  5040. clif_weather(sd->bl.m);
  5041. clif_displaymessage(fd, msg_txt(sd,1205)); // Cherry tree leaves no longer fall.
  5042. } else {
  5043. map[sd->bl.m].flag.sakura=1;
  5044. clif_weather(sd->bl.m);
  5045. clif_displaymessage(fd, msg_txt(sd,1206)); // Cherry tree leaves have begun to fall.
  5046. }
  5047. return 0;
  5048. }
  5049. /*==========================================
  5050. * Clouds appear.
  5051. *------------------------------------------*/
  5052. ACMD_FUNC(clouds)
  5053. {
  5054. nullpo_retr(-1, sd);
  5055. if (map[sd->bl.m].flag.clouds) {
  5056. map[sd->bl.m].flag.clouds=0;
  5057. clif_weather(sd->bl.m);
  5058. clif_displaymessage(fd, msg_txt(sd,1207)); // The clouds has disappear.
  5059. } else {
  5060. map[sd->bl.m].flag.clouds=1;
  5061. clif_weather(sd->bl.m);
  5062. clif_displaymessage(fd, msg_txt(sd,1208)); // Clouds appear.
  5063. }
  5064. return 0;
  5065. }
  5066. /*==========================================
  5067. * Different type of clouds using effect 516
  5068. *------------------------------------------*/
  5069. ACMD_FUNC(clouds2)
  5070. {
  5071. nullpo_retr(-1, sd);
  5072. if (map[sd->bl.m].flag.clouds2) {
  5073. map[sd->bl.m].flag.clouds2=0;
  5074. clif_weather(sd->bl.m);
  5075. clif_displaymessage(fd, msg_txt(sd,1209)); // The alternative clouds disappear.
  5076. } else {
  5077. map[sd->bl.m].flag.clouds2=1;
  5078. clif_weather(sd->bl.m);
  5079. clif_displaymessage(fd, msg_txt(sd,1210)); // Alternative clouds appear.
  5080. }
  5081. return 0;
  5082. }
  5083. /*==========================================
  5084. * Fog hangs over.
  5085. *------------------------------------------*/
  5086. ACMD_FUNC(fog)
  5087. {
  5088. nullpo_retr(-1, sd);
  5089. if (map[sd->bl.m].flag.fog) {
  5090. map[sd->bl.m].flag.fog=0;
  5091. clif_weather(sd->bl.m);
  5092. clif_displaymessage(fd, msg_txt(sd,1211)); // The fog has gone.
  5093. } else {
  5094. map[sd->bl.m].flag.fog=1;
  5095. clif_weather(sd->bl.m);
  5096. clif_displaymessage(fd, msg_txt(sd,1212)); // Fog hangs over.
  5097. }
  5098. return 0;
  5099. }
  5100. /*==========================================
  5101. * Fallen leaves fall.
  5102. *------------------------------------------*/
  5103. ACMD_FUNC(leaves)
  5104. {
  5105. nullpo_retr(-1, sd);
  5106. if (map[sd->bl.m].flag.leaves) {
  5107. map[sd->bl.m].flag.leaves=0;
  5108. clif_weather(sd->bl.m);
  5109. clif_displaymessage(fd, msg_txt(sd,1213)); // Leaves no longer fall.
  5110. } else {
  5111. map[sd->bl.m].flag.leaves=1;
  5112. clif_weather(sd->bl.m);
  5113. clif_displaymessage(fd, msg_txt(sd,1214)); // Fallen leaves fall.
  5114. }
  5115. return 0;
  5116. }
  5117. /*==========================================
  5118. * Fireworks appear.
  5119. *------------------------------------------*/
  5120. ACMD_FUNC(fireworks)
  5121. {
  5122. nullpo_retr(-1, sd);
  5123. if (map[sd->bl.m].flag.fireworks) {
  5124. map[sd->bl.m].flag.fireworks=0;
  5125. clif_weather(sd->bl.m);
  5126. clif_displaymessage(fd, msg_txt(sd,1215)); // Fireworks have ended.
  5127. } else {
  5128. map[sd->bl.m].flag.fireworks=1;
  5129. clif_weather(sd->bl.m);
  5130. clif_displaymessage(fd, msg_txt(sd,1216)); // Fireworks have launched.
  5131. }
  5132. return 0;
  5133. }
  5134. /*==========================================
  5135. * Clearing Weather Effects by Dexity
  5136. *------------------------------------------*/
  5137. ACMD_FUNC(clearweather)
  5138. {
  5139. nullpo_retr(-1, sd);
  5140. /**
  5141. * No longer available, keeping here just in case it's back someday. [Ind]
  5142. **/
  5143. //map[sd->bl.m].flag.rain=0;
  5144. map[sd->bl.m].flag.snow=0;
  5145. map[sd->bl.m].flag.sakura=0;
  5146. map[sd->bl.m].flag.clouds=0;
  5147. map[sd->bl.m].flag.clouds2=0;
  5148. map[sd->bl.m].flag.fog=0;
  5149. map[sd->bl.m].flag.fireworks=0;
  5150. map[sd->bl.m].flag.leaves=0;
  5151. clif_weather(sd->bl.m);
  5152. clif_displaymessage(fd, msg_txt(sd,291));
  5153. return 0;
  5154. }
  5155. /*===============================================================
  5156. * Sound Command - plays a sound for everyone around! [Codemaster]
  5157. *---------------------------------------------------------------*/
  5158. ACMD_FUNC(sound)
  5159. {
  5160. char sound_file[100];
  5161. memset(sound_file, '\0', sizeof(sound_file));
  5162. if(!message || !*message || sscanf(message, "%99[^\n]", sound_file) < 1) {
  5163. clif_displaymessage(fd, msg_txt(sd,1217)); // Please enter a sound filename (usage: @sound <filename>).
  5164. return -1;
  5165. }
  5166. if(strstr(sound_file, ".wav") == NULL)
  5167. strcat(sound_file, ".wav");
  5168. clif_soundeffectall(&sd->bl, sound_file, 0, AREA);
  5169. return 0;
  5170. }
  5171. /*==========================================
  5172. * MOB Search
  5173. *------------------------------------------*/
  5174. ACMD_FUNC(mobsearch)
  5175. {
  5176. char mob_name[100];
  5177. int mob_id;
  5178. int number = 0;
  5179. struct s_mapiterator* it;
  5180. nullpo_retr(-1, sd);
  5181. if (!message || !*message || sscanf(message, "%99[^\n]", mob_name) < 1) {
  5182. clif_displaymessage(fd, msg_txt(sd,1218)); // Please enter a monster name (usage: @mobsearch <monster name>).
  5183. return -1;
  5184. }
  5185. if ((mob_id = atoi(mob_name)) == 0)
  5186. mob_id = mobdb_searchname(mob_name);
  5187. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  5188. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1219),mob_name); // Invalid mob ID %s!
  5189. clif_displaymessage(fd, atcmd_output);
  5190. return -1;
  5191. }
  5192. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  5193. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  5194. // strcpy(mob_name,mob_db(mob_id)->name); // --en--
  5195. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1220), mob_name, mapindex_id2name(sd->mapindex)); // Mob Search... %s %s
  5196. clif_displaymessage(fd, atcmd_output);
  5197. it = mapit_geteachmob();
  5198. for(;;)
  5199. {
  5200. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  5201. if( md == NULL )
  5202. break;// no more mobs
  5203. if( md->bl.m != sd->bl.m )
  5204. continue;
  5205. if( mob_id != -1 && md->class_ != mob_id )
  5206. continue;
  5207. ++number;
  5208. if( md->spawn_timer == INVALID_TIMER )
  5209. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%3d:%3d] %s", number, md->bl.x, md->bl.y, md->name);
  5210. else
  5211. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%s] %s", number, "dead", md->name);
  5212. clif_displaymessage(fd, atcmd_output);
  5213. }
  5214. mapit_free(it);
  5215. return 0;
  5216. }
  5217. /*==========================================
  5218. * @cleanmap - cleans items on the ground
  5219. * @cleanarea - cleans items on the ground within an specified area
  5220. *------------------------------------------*/
  5221. static int atcommand_cleanfloor_sub(struct block_list *bl, va_list ap)
  5222. {
  5223. nullpo_ret(bl);
  5224. map_clearflooritem(bl);
  5225. return 0;
  5226. }
  5227. ACMD_FUNC(cleanmap)
  5228. {
  5229. map_foreachinmap(atcommand_cleanfloor_sub, sd->bl.m, BL_ITEM);
  5230. clif_displaymessage(fd, msg_txt(sd,1221)); // All dropped items have been cleaned up.
  5231. return 0;
  5232. }
  5233. ACMD_FUNC(cleanarea)
  5234. {
  5235. int x0 = 0, y0 = 0, x1 = 0, y1 = 0;
  5236. if (!message || !*message || sscanf(message, "%d %d %d %d", &x0, &y0, &x1, &y1) < 1) {
  5237. 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);
  5238. }
  5239. else if (sscanf(message, "%d %d %d %d", &x0, &y0, &x1, &y1) == 1) {
  5240. 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);
  5241. }
  5242. else if (sscanf(message, "%d %d %d %d", &x0, &y0, &x1, &y1) == 4) {
  5243. map_foreachinarea(atcommand_cleanfloor_sub, sd->bl.m, x0, y0, x1, y1, BL_ITEM);
  5244. }
  5245. clif_displaymessage(fd, msg_txt(sd,1221)); // All dropped items have been cleaned up.
  5246. return 0;
  5247. }
  5248. /*==========================================
  5249. * make a NPC/PET talk
  5250. * @npctalkc [SnakeDrak]
  5251. *------------------------------------------*/
  5252. ACMD_FUNC(npctalk)
  5253. {
  5254. char name[NAME_LENGTH],mes[100],temp[100];
  5255. struct npc_data *nd;
  5256. bool ifcolor=(*(command + 8) != 'c' && *(command + 8) != 'C')?0:1;
  5257. unsigned long color=0;
  5258. if (sd->sc.count && //no "chatting" while muted.
  5259. (sd->sc.data[SC_BERSERK] || sd->sc.data[SC__BLOODYLUST] ||
  5260. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  5261. return -1;
  5262. if(!ifcolor) {
  5263. if (!message || !*message || sscanf(message, "%23[^,], %99[^\n]", name, mes) < 2) {
  5264. clif_displaymessage(fd, msg_txt(sd,1222)); // Please enter the correct parameters (usage: @npctalk <npc name>, <message>).
  5265. return -1;
  5266. }
  5267. }
  5268. else {
  5269. if (!message || !*message || sscanf(message, "%lx %23[^,], %99[^\n]", &color, name, mes) < 3) {
  5270. clif_displaymessage(fd, msg_txt(sd,1223)); // Please enter the correct parameters (usage: @npctalkc <color> <npc name>, <message>).
  5271. return -1;
  5272. }
  5273. }
  5274. if (!(nd = npc_name2id(name))) {
  5275. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist
  5276. return -1;
  5277. }
  5278. strtok(name, "#"); // discard extra name identifier if present
  5279. snprintf(temp, sizeof(temp), "%s : %s", name, mes);
  5280. if(ifcolor) clif_messagecolor(&nd->bl,color,temp);
  5281. else clif_disp_overhead(&nd->bl, temp);
  5282. return 0;
  5283. }
  5284. ACMD_FUNC(pettalk)
  5285. {
  5286. char mes[100],temp[100];
  5287. struct pet_data *pd;
  5288. nullpo_retr(-1, sd);
  5289. if ( battle_config.min_chat_delay ) {
  5290. if( DIFF_TICK(sd->cantalk_tick, gettick()) > 0 )
  5291. return 0;
  5292. sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
  5293. }
  5294. if(!sd->status.pet_id || !(pd=sd->pd))
  5295. {
  5296. clif_displaymessage(fd, msg_txt(sd,184));
  5297. return -1;
  5298. }
  5299. if (sd->sc.count && //no "chatting" while muted.
  5300. (sd->sc.data[SC_BERSERK] || sd->sc.data[SC__BLOODYLUST] ||
  5301. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  5302. return -1;
  5303. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  5304. clif_displaymessage(fd, msg_txt(sd,1224)); // Please enter a message (usage: @pettalk <message>).
  5305. return -1;
  5306. }
  5307. if (message[0] == '/')
  5308. {// pet emotion processing
  5309. const char* emo[] = {
  5310. "/!", "/?", "/ho", "/lv", "/swt", "/ic", "/an", "/ag", "/$", "/...",
  5311. "/scissors", "/rock", "/paper", "/korea", "/lv2", "/thx", "/wah", "/sry", "/heh", "/swt2",
  5312. "/hmm", "/no1", "/??", "/omg", "/O", "/X", "/hlp", "/go", "/sob", "/gg",
  5313. "/kis", "/kis2", "/pif", "/ok", "-?-", "/indonesia", "/bzz", "/rice", "/awsm", "/meh",
  5314. "/shy", "/pat", "/mp", "/slur", "/com", "/yawn", "/grat", "/hp", "/philippines", "/malaysia",
  5315. "/singapore", "/brazil", "/fsh", "/spin", "/sigh", "/dum", "/crwd", "/desp", "/dice", "-dice2",
  5316. "-dice3", "-dice4", "-dice5", "-dice6", "/india", "/love", "/russia", "-?-", "/mobile", "/mail",
  5317. "/chinese", "/antenna1", "/antenna2", "/antenna3", "/hum", "/abs", "/oops", "/spit", "/ene", "/panic",
  5318. "/whisp"
  5319. };
  5320. int i;
  5321. ARR_FIND( 0, ARRAYLENGTH(emo), i, stricmp(message, emo[i]) == 0 );
  5322. if( i == E_DICE1 ) i = rnd()%6 + E_DICE1; // randomize /dice
  5323. if( i < ARRAYLENGTH(emo) )
  5324. {
  5325. if (sd->emotionlasttime + 1 >= time(NULL)) { // not more than 1 per second
  5326. sd->emotionlasttime = time(NULL);
  5327. return 0;
  5328. }
  5329. sd->emotionlasttime = time(NULL);
  5330. clif_emotion(&pd->bl, i);
  5331. return 0;
  5332. }
  5333. }
  5334. snprintf(temp, sizeof temp ,"%s : %s", pd->pet.name, mes);
  5335. clif_disp_overhead(&pd->bl, temp);
  5336. return 0;
  5337. }
  5338. /// @users - displays the number of players present on each map (and percentage)
  5339. /// #users displays on the target user instead of self
  5340. ACMD_FUNC(users)
  5341. {
  5342. char buf[CHAT_SIZE_MAX];
  5343. int i;
  5344. int users[MAX_MAPINDEX];
  5345. int users_all;
  5346. struct s_mapiterator* iter;
  5347. memset(users, 0, sizeof(users));
  5348. users_all = 0;
  5349. // count users on each map
  5350. iter = mapit_getallusers();
  5351. for(;;)
  5352. {
  5353. struct map_session_data* sd2 = (struct map_session_data*)mapit_next(iter);
  5354. if( sd2 == NULL )
  5355. break;// no more users
  5356. if( sd2->mapindex >= MAX_MAPINDEX )
  5357. continue;// invalid mapindex
  5358. if( users[sd2->mapindex] < INT_MAX ) ++users[sd2->mapindex];
  5359. if( users_all < INT_MAX ) ++users_all;
  5360. }
  5361. mapit_free(iter);
  5362. // display results for each map
  5363. for( i = 0; i < MAX_MAPINDEX; ++i )
  5364. {
  5365. if( users[i] == 0 )
  5366. continue;// empty
  5367. safesnprintf(buf, sizeof(buf), "%s: %d (%.2f%%)", mapindex_id2name(i), users[i], (float)(100.0f*users[i]/users_all));
  5368. clif_displaymessage(sd->fd, buf);
  5369. }
  5370. // display overall count
  5371. safesnprintf(buf, sizeof(buf), "all: %d", users_all);
  5372. clif_displaymessage(sd->fd, buf);
  5373. return 0;
  5374. }
  5375. /*==========================================
  5376. *
  5377. *------------------------------------------*/
  5378. ACMD_FUNC(reset)
  5379. {
  5380. pc_resetstate(sd);
  5381. pc_resetskill(sd,1);
  5382. sprintf(atcmd_output, msg_txt(sd,208), sd->status.name); // '%s' skill and stats points reseted!
  5383. clif_displaymessage(fd, atcmd_output);
  5384. return 0;
  5385. }
  5386. /*==========================================
  5387. *
  5388. *------------------------------------------*/
  5389. ACMD_FUNC(summon)
  5390. {
  5391. char name[NAME_LENGTH];
  5392. int mob_id = 0;
  5393. int duration = 0;
  5394. struct mob_data *md;
  5395. unsigned int tick=gettick();
  5396. nullpo_retr(-1, sd);
  5397. if (!message || !*message || sscanf(message, "%23s %d", name, &duration) < 1)
  5398. {
  5399. clif_displaymessage(fd, msg_txt(sd,1225)); // Please enter a monster name (usage: @summon <monster name> {duration}).
  5400. return -1;
  5401. }
  5402. if (duration < 1)
  5403. duration =1;
  5404. else if (duration > 60)
  5405. duration =60;
  5406. if ((mob_id = atoi(name)) == 0)
  5407. mob_id = mobdb_searchname(name);
  5408. if(mob_id == 0 || mobdb_checkid(mob_id) == 0)
  5409. {
  5410. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  5411. return -1;
  5412. }
  5413. md = mob_once_spawn_sub(&sd->bl, sd->bl.m, -1, -1, "--ja--", mob_id, "", SZ_SMALL, AI_NONE);
  5414. if(!md)
  5415. return -1;
  5416. md->master_id=sd->bl.id;
  5417. md->special_state.ai=1;
  5418. md->deletetimer=add_timer(tick+(duration*60000),mob_timer_delete,md->bl.id,0);
  5419. clif_specialeffect(&md->bl,344,AREA);
  5420. mob_spawn(md);
  5421. sc_start4(NULL,&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000);
  5422. clif_skill_poseffect(&sd->bl,AM_CALLHOMUN,1,md->bl.x,md->bl.y,tick);
  5423. clif_displaymessage(fd, msg_txt(sd,39)); // All monster summoned!
  5424. return 0;
  5425. }
  5426. /*==========================================
  5427. * @adjgroup
  5428. * Temporarily move player to another group
  5429. * Useful during beta testing to allow players to use GM commands for short periods of time
  5430. *------------------------------------------*/
  5431. ACMD_FUNC(adjgroup)
  5432. {
  5433. int new_group = 0;
  5434. nullpo_retr(-1, sd);
  5435. if (!message || !*message || sscanf(message, "%d", &new_group) != 1) {
  5436. clif_displaymessage(fd, msg_txt(sd,1226)); // Usage: @adjgroup <group_id>
  5437. return -1;
  5438. }
  5439. if (!pc_group_exists(new_group)) {
  5440. clif_displaymessage(fd, msg_txt(sd,1227)); // Specified group does not exist.
  5441. return -1;
  5442. }
  5443. sd->group_id = new_group;
  5444. pc_group_pc_load(sd);/* update cache */
  5445. clif_displaymessage(fd, msg_txt(sd,1228)); // Group changed successfully.
  5446. clif_displaymessage(sd->fd, msg_txt(sd,1229)); // Your group has changed.
  5447. return 0;
  5448. }
  5449. /*==========================================
  5450. * @trade by [MouseJstr]
  5451. * Open a trade window with a remote player
  5452. *------------------------------------------*/
  5453. ACMD_FUNC(trade)
  5454. {
  5455. struct map_session_data *pl_sd = NULL;
  5456. nullpo_retr(-1, sd);
  5457. if (!message || !*message) {
  5458. clif_displaymessage(fd, msg_txt(sd,1230)); // Please enter a player name (usage: @trade <char name>).
  5459. return -1;
  5460. }
  5461. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  5462. {
  5463. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5464. return -1;
  5465. }
  5466. trade_traderequest(sd, pl_sd);
  5467. return 0;
  5468. }
  5469. /*==========================================
  5470. * @setbattleflag by [MouseJstr]
  5471. * set a battle_config flag without having to reboot
  5472. *------------------------------------------*/
  5473. ACMD_FUNC(setbattleflag)
  5474. {
  5475. char flag[128], value[128];
  5476. nullpo_retr(-1, sd);
  5477. if (!message || !*message || sscanf(message, "%127s %127s", flag, value) != 2) {
  5478. clif_displaymessage(fd, msg_txt(sd,1231)); // Usage: @setbattleflag <flag> <value>
  5479. return -1;
  5480. }
  5481. if (battle_set_value(flag, value) == 0)
  5482. {
  5483. clif_displaymessage(fd, msg_txt(sd,1232)); // Unknown battle_config flag.
  5484. return -1;
  5485. }
  5486. clif_displaymessage(fd, msg_txt(sd,1233)); // Set battle_config as requested.
  5487. return 0;
  5488. }
  5489. /*==========================================
  5490. * @unmute [Valaris]
  5491. *------------------------------------------*/
  5492. ACMD_FUNC(unmute)
  5493. {
  5494. struct map_session_data *pl_sd = NULL;
  5495. nullpo_retr(-1, sd);
  5496. if (!message || !*message) {
  5497. clif_displaymessage(fd, msg_txt(sd,1234)); // Please enter a player name (usage: @unmute <char name>).
  5498. return -1;
  5499. }
  5500. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  5501. {
  5502. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5503. return -1;
  5504. }
  5505. if(!pl_sd->sc.data[SC_NOCHAT]) {
  5506. clif_displaymessage(sd->fd,msg_txt(sd,1235)); // Player is not muted.
  5507. return -1;
  5508. }
  5509. pl_sd->status.manner = 0;
  5510. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  5511. clif_displaymessage(sd->fd,msg_txt(sd,1236)); // Player unmuted.
  5512. return 0;
  5513. }
  5514. /*==========================================
  5515. * @uptime by MC Cameri
  5516. *------------------------------------------*/
  5517. ACMD_FUNC(uptime)
  5518. {
  5519. unsigned long seconds = 0, day = 24*60*60, hour = 60*60,
  5520. minute = 60, days = 0, hours = 0, minutes = 0;
  5521. nullpo_retr(-1, sd);
  5522. seconds = get_uptime();
  5523. days = seconds/day;
  5524. seconds -= (seconds/day>0)?(seconds/day)*day:0;
  5525. hours = seconds/hour;
  5526. seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
  5527. minutes = seconds/minute;
  5528. seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
  5529. snprintf(atcmd_output, sizeof(atcmd_output), msg_txt(sd,245), days, hours, minutes, seconds);
  5530. clif_displaymessage(fd, atcmd_output);
  5531. return 0;
  5532. }
  5533. /*==========================================
  5534. * @changesex <sex>
  5535. * => Changes one's sex. Argument sex can be 0 or 1, m or f, male or female.
  5536. *------------------------------------------*/
  5537. ACMD_FUNC(changesex)
  5538. {
  5539. int i;
  5540. nullpo_retr(-1, sd);
  5541. pc_resetskill(sd,4);
  5542. // to avoid any problem with equipment and invalid sex, equipment is unequiped.
  5543. for( i=0; i<EQI_MAX; i++ )
  5544. if( sd->equip_index[i] >= 0 ) pc_unequipitem(sd, sd->equip_index[i], 3);
  5545. chrif_changesex(sd);
  5546. return 0;
  5547. }
  5548. /*================================================
  5549. * @mute - Mutes a player for a set amount of time
  5550. *------------------------------------------------*/
  5551. ACMD_FUNC(mute)
  5552. {
  5553. struct map_session_data *pl_sd = NULL;
  5554. int manner;
  5555. nullpo_retr(-1, sd);
  5556. if (!message || !*message || sscanf(message, "%d %23[^\n]", &manner, atcmd_player_name) < 1) {
  5557. clif_displaymessage(fd, msg_txt(sd,1237)); // Usage: @mute <time> <char name>
  5558. return -1;
  5559. }
  5560. if ( (pl_sd = map_nick2sd(atcmd_player_name)) == NULL )
  5561. {
  5562. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5563. return -1;
  5564. }
  5565. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  5566. {
  5567. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  5568. return -1;
  5569. }
  5570. clif_manner_message(sd, 0);
  5571. clif_manner_message(pl_sd, 5);
  5572. if( pl_sd->status.manner < manner ) {
  5573. pl_sd->status.manner -= manner;
  5574. sc_start(NULL,&pl_sd->bl,SC_NOCHAT,100,0,0);
  5575. } else {
  5576. pl_sd->status.manner = 0;
  5577. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  5578. }
  5579. clif_GM_silence(sd, pl_sd, (manner > 0 ? 1 : 0));
  5580. return 0;
  5581. }
  5582. /*==========================================
  5583. * @refresh (like @jumpto <<yourself>>)
  5584. *------------------------------------------*/
  5585. ACMD_FUNC(refresh)
  5586. {
  5587. nullpo_retr(-1, sd);
  5588. clif_refresh(sd);
  5589. return 0;
  5590. }
  5591. ACMD_FUNC(refreshall)
  5592. {
  5593. struct map_session_data* iter_sd;
  5594. struct s_mapiterator* iter;
  5595. nullpo_retr(-1, sd);
  5596. iter = mapit_getallusers();
  5597. for (iter_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); iter_sd = (TBL_PC*)mapit_next(iter))
  5598. clif_refresh(iter_sd);
  5599. mapit_free(iter);
  5600. return 0;
  5601. }
  5602. /*==========================================
  5603. * @identify
  5604. * => GM's magnifier.
  5605. *------------------------------------------*/
  5606. ACMD_FUNC(identify)
  5607. {
  5608. int i,num;
  5609. nullpo_retr(-1, sd);
  5610. for(i=num=0;i<MAX_INVENTORY;i++){
  5611. if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1){
  5612. num++;
  5613. }
  5614. }
  5615. if (num > 0) {
  5616. clif_item_identify_list(sd);
  5617. } else {
  5618. clif_displaymessage(fd,msg_txt(sd,1238)); // There are no items to appraise.
  5619. }
  5620. return 0;
  5621. }
  5622. /*==========================================
  5623. * @gmotd (Global MOTD)
  5624. * by davidsiaw :P
  5625. *------------------------------------------*/
  5626. ACMD_FUNC(gmotd)
  5627. {
  5628. FILE* fp;
  5629. if( ( fp = fopen(motd_txt, "r") ) != NULL )
  5630. {
  5631. char buf[CHAT_SIZE_MAX];
  5632. size_t len;
  5633. while( fgets(buf, sizeof(buf), fp) )
  5634. {
  5635. if( buf[0] == '/' && buf[1] == '/' )
  5636. {
  5637. continue;
  5638. }
  5639. len = strlen(buf);
  5640. while( len && ( buf[len-1] == '\r' || buf[len-1] == '\n' ) )
  5641. {// strip trailing EOL characters
  5642. len--;
  5643. }
  5644. if( len )
  5645. {
  5646. buf[len] = 0;
  5647. intif_broadcast(buf, len+1, 0);
  5648. }
  5649. }
  5650. fclose(fp);
  5651. }
  5652. return 0;
  5653. }
  5654. ACMD_FUNC(misceffect)
  5655. {
  5656. int effect = 0;
  5657. nullpo_retr(-1, sd);
  5658. if (!message || !*message)
  5659. return -1;
  5660. if (sscanf(message, "%d", &effect) < 1)
  5661. return -1;
  5662. clif_misceffect(&sd->bl,effect);
  5663. return 0;
  5664. }
  5665. /*==========================================
  5666. * MAIL SYSTEM
  5667. *------------------------------------------*/
  5668. ACMD_FUNC(mail)
  5669. {
  5670. nullpo_ret(sd);
  5671. mail_openmail(sd);
  5672. return 0;
  5673. }
  5674. /*==========================================
  5675. * Show Monster DB Info v 1.0
  5676. * originally by [Lupus]
  5677. *------------------------------------------*/
  5678. ACMD_FUNC(mobinfo)
  5679. {
  5680. unsigned char msize[3][7] = {"Small", "Medium", "Large"};
  5681. unsigned char mrace[12][11] = {"Formless", "Undead", "Beast", "Plant", "Insect", "Fish", "Demon", "Demi-Human", "Angel", "Dragon", "Boss", "Non-Boss"};
  5682. unsigned char melement[10][8] = {"Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead"};
  5683. char atcmd_output2[CHAT_SIZE_MAX];
  5684. struct item_data *item_data;
  5685. struct mob_db *mob, *mob_array[MAX_SEARCH];
  5686. int count;
  5687. int i, j, k;
  5688. unsigned int base_exp, job_exp;
  5689. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5690. memset(atcmd_output2, '\0', sizeof(atcmd_output2));
  5691. if (!message || !*message) {
  5692. clif_displaymessage(fd, msg_txt(sd,1239)); // Please enter a monster name/ID (usage: @mobinfo <monster_name_or_monster_ID>).
  5693. return -1;
  5694. }
  5695. // If monster identifier/name argument is a name
  5696. if ((i = mobdb_checkid(atoi(message))))
  5697. {
  5698. mob_array[0] = mob_db(i);
  5699. count = 1;
  5700. } else
  5701. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  5702. if (!count) {
  5703. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  5704. return -1;
  5705. }
  5706. if (count > MAX_SEARCH) {
  5707. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH, count);
  5708. clif_displaymessage(fd, atcmd_output);
  5709. count = MAX_SEARCH;
  5710. }
  5711. for (k = 0; k < count; k++) {
  5712. mob = mob_array[k];
  5713. base_exp = mob->base_exp;
  5714. job_exp = mob->job_exp;
  5715. #ifdef RENEWAL_EXP
  5716. if( battle_config.atcommand_mobinfo_type ) {
  5717. base_exp = base_exp * pc_level_penalty_mod(sd, mob->lv, mob->status.race, mob->status.mode, 1) / 100;
  5718. job_exp = job_exp * pc_level_penalty_mod(sd, mob->lv, mob->status.race, mob->status.mode, 1) / 100;
  5719. }
  5720. #endif
  5721. // stats
  5722. if (mob->mexp)
  5723. sprintf(atcmd_output, msg_txt(sd,1240), mob->name, mob->jname, mob->sprite, mob->vd.class_); // MVP Monster: '%s'/'%s'/'%s' (%d)
  5724. else
  5725. sprintf(atcmd_output, msg_txt(sd,1241), mob->name, mob->jname, mob->sprite, mob->vd.class_); // Monster: '%s'/'%s'/'%s' (%d)
  5726. clif_displaymessage(fd, atcmd_output);
  5727. 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
  5728. clif_displaymessage(fd, atcmd_output);
  5729. sprintf(atcmd_output, msg_txt(sd,1243), // DEF:%d MDEF:%d STR:%d AGI:%d VIT:%d INT:%d DEX:%d LUK:%d
  5730. mob->status.def, mob->status.mdef,mob->status.str, mob->status.agi,
  5731. mob->status.vit, mob->status.int_, mob->status.dex, mob->status.luk);
  5732. clif_displaymessage(fd, atcmd_output);
  5733. sprintf(atcmd_output, msg_txt(sd,1244), // ATK:%d~%d Range:%d~%d~%d Size:%s Race: %s Element: %s (Lv:%d)
  5734. mob->status.rhw.atk, mob->status.rhw.atk2, mob->status.rhw.range,
  5735. mob->range2 , mob->range3, msize[mob->status.size],
  5736. mrace[mob->status.race], melement[mob->status.def_ele], mob->status.ele_lv);
  5737. clif_displaymessage(fd, atcmd_output);
  5738. // drops
  5739. clif_displaymessage(fd, msg_txt(sd,1245)); // Drops:
  5740. strcpy(atcmd_output, " ");
  5741. j = 0;
  5742. for (i = 0; i < MAX_MOB_DROP; i++) {
  5743. int droprate;
  5744. if (mob->dropitem[i].nameid <= 0 || mob->dropitem[i].p < 1 || (item_data = itemdb_exists(mob->dropitem[i].nameid)) == NULL)
  5745. continue;
  5746. droprate = mob->dropitem[i].p;
  5747. #ifdef RENEWAL_DROP
  5748. if( battle_config.atcommand_mobinfo_type )
  5749. droprate = droprate * pc_level_penalty_mod(sd, mob->lv, mob->status.race, mob->status.mode, 2) / 100;
  5750. #endif
  5751. if (item_data->slot)
  5752. sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, (float)droprate / 100);
  5753. else
  5754. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)droprate / 100);
  5755. strcat(atcmd_output, atcmd_output2);
  5756. if (++j % 3 == 0) {
  5757. clif_displaymessage(fd, atcmd_output);
  5758. strcpy(atcmd_output, " ");
  5759. }
  5760. }
  5761. if (j == 0)
  5762. clif_displaymessage(fd, msg_txt(sd,1246)); // This monster has no drops.
  5763. else if (j % 3 != 0)
  5764. clif_displaymessage(fd, atcmd_output);
  5765. // mvp
  5766. if (mob->mexp) {
  5767. sprintf(atcmd_output, msg_txt(sd,1247), mob->mexp); // MVP Bonus EXP:%u
  5768. clif_displaymessage(fd, atcmd_output);
  5769. strcpy(atcmd_output, msg_txt(sd,1248)); // MVP Items:
  5770. j = 0;
  5771. for (i = 0; i < MAX_MVP_DROP; i++) {
  5772. if (mob->mvpitem[i].nameid <= 0 || (item_data = itemdb_exists(mob->mvpitem[i].nameid)) == NULL)
  5773. continue;
  5774. if (mob->mvpitem[i].p > 0) {
  5775. j++;
  5776. if (j == 1)
  5777. sprintf(atcmd_output2, " %s %02.02f%%", item_data->jname, (float)mob->mvpitem[i].p / 100);
  5778. else
  5779. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)mob->mvpitem[i].p / 100);
  5780. strcat(atcmd_output, atcmd_output2);
  5781. }
  5782. }
  5783. if (j == 0)
  5784. clif_displaymessage(fd, msg_txt(sd,1249)); // This monster has no MVP prizes.
  5785. else
  5786. clif_displaymessage(fd, atcmd_output);
  5787. }
  5788. }
  5789. return 0;
  5790. }
  5791. /*=========================================
  5792. * @showmobs by KarLaeda
  5793. * => For 15 sec displays the mobs on minimap
  5794. *------------------------------------------*/
  5795. ACMD_FUNC(showmobs)
  5796. {
  5797. char mob_name[100];
  5798. int mob_id;
  5799. int number = 0;
  5800. struct s_mapiterator* it;
  5801. nullpo_retr(-1, sd);
  5802. if(sscanf(message, "%99[^\n]", mob_name) < 0)
  5803. return -1;
  5804. if((mob_id = atoi(mob_name)) == 0)
  5805. mob_id = mobdb_searchname(mob_name);
  5806. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  5807. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1250),mob_name); // Invalid mob id %s!
  5808. clif_displaymessage(fd, atcmd_output);
  5809. return 0;
  5810. }
  5811. 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.
  5812. clif_displaymessage(fd, msg_txt(sd,1251)); // Can't show boss mobs!
  5813. return 0;
  5814. }
  5815. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  5816. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  5817. //strcpy(mob_name,mob_db(mob_id)->name); // --en--
  5818. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1252), // Mob Search... %s %s
  5819. mob_name, mapindex_id2name(sd->mapindex));
  5820. clif_displaymessage(fd, atcmd_output);
  5821. it = mapit_geteachmob();
  5822. for(;;)
  5823. {
  5824. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  5825. if( md == NULL )
  5826. break;// no more mobs
  5827. if( md->bl.m != sd->bl.m )
  5828. continue;
  5829. if( mob_id != -1 && md->class_ != mob_id )
  5830. continue;
  5831. if( md->special_state.ai || md->master_id )
  5832. continue; // hide slaves and player summoned mobs
  5833. if( md->spawn_timer != INVALID_TIMER )
  5834. continue; // hide mobs waiting for respawn
  5835. ++number;
  5836. clif_viewpoint(sd, 1, 0, md->bl.x, md->bl.y, number, 0xFFFFFF);
  5837. }
  5838. mapit_free(it);
  5839. return 0;
  5840. }
  5841. /*==========================================
  5842. * homunculus level up [orn]
  5843. *------------------------------------------*/
  5844. ACMD_FUNC(homlevel)
  5845. {
  5846. TBL_HOM * hd;
  5847. int level = 0, i = 0;
  5848. nullpo_retr(-1, sd);
  5849. if ( !message || !*message || ( level = atoi(message) ) < 1 ) {
  5850. clif_displaymessage(fd, msg_txt(sd,1253)); // Please enter a level adjustment (usage: @homlevel <number of levels>).
  5851. return -1;
  5852. }
  5853. if ( !merc_is_hom_active(sd->hd) ) {
  5854. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  5855. return -1;
  5856. }
  5857. hd = sd->hd;
  5858. for (i = 1; i <= level && hd->exp_next; i++){
  5859. hd->homunculus.exp += hd->exp_next;
  5860. if( !merc_hom_levelup(hd) ){
  5861. break;
  5862. }
  5863. }
  5864. status_calc_homunculus(hd,0);
  5865. status_percent_heal(&hd->bl, 100, 100);
  5866. clif_specialeffect(&hd->bl,568,AREA);
  5867. return 0;
  5868. }
  5869. /*==========================================
  5870. * homunculus evolution H [orn]
  5871. *------------------------------------------*/
  5872. ACMD_FUNC(homevolution)
  5873. {
  5874. nullpo_retr(-1, sd);
  5875. if ( !merc_is_hom_active(sd->hd) ) {
  5876. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  5877. return -1;
  5878. }
  5879. if ( !merc_hom_evolution(sd->hd) ) {
  5880. clif_displaymessage(fd, msg_txt(sd,1255)); // Your homunculus doesn't evolve.
  5881. return -1;
  5882. }
  5883. clif_homskillinfoblock(sd);
  5884. return 0;
  5885. }
  5886. ACMD_FUNC(hommutate)
  5887. {
  5888. int homun_id, m_class = 0, m_id;
  5889. nullpo_retr(-1, sd);
  5890. if (!merc_is_hom_active(sd->hd)) {
  5891. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  5892. return -1;
  5893. }
  5894. if (!message || !*message) {
  5895. homun_id = 6048 + (rnd() % 4);
  5896. } else {
  5897. homun_id = atoi(message);
  5898. }
  5899. m_class = hom_class2mapid(sd->hd->homunculus.class_);
  5900. m_id = hom_class2mapid(homun_id);
  5901. if (m_class != -1 && m_id != -1 && m_class&HOM_EVO && m_id&HOM_S && sd->hd->homunculus.level >= 99) {
  5902. hom_mutate(sd->hd, homun_id);
  5903. } else {
  5904. clif_emotion(&sd->hd->bl, E_SWT);
  5905. }
  5906. return 0;
  5907. }
  5908. /*==========================================
  5909. * call choosen homunculus [orn]
  5910. *------------------------------------------*/
  5911. ACMD_FUNC(makehomun)
  5912. {
  5913. int homunid;
  5914. nullpo_retr(-1, sd);
  5915. if ( sd->status.hom_id ) {
  5916. clif_displaymessage(fd, msg_txt(sd,450));
  5917. return -1;
  5918. }
  5919. if (!message || !*message) {
  5920. clif_displaymessage(fd, msg_txt(sd,1256)); // Please enter a homunculus ID (usage: @makehomun <homunculus id>).
  5921. return -1;
  5922. }
  5923. homunid = atoi(message);
  5924. if( homunid < HM_CLASS_BASE || homunid > HM_CLASS_BASE + MAX_HOMUNCULUS_CLASS - 1 )
  5925. {
  5926. clif_displaymessage(fd, msg_txt(sd,1257)); // Invalid Homunculus ID.
  5927. return -1;
  5928. }
  5929. merc_create_homunculus_request(sd,homunid);
  5930. return 0;
  5931. }
  5932. /*==========================================
  5933. * modify homunculus intimacy [orn]
  5934. *------------------------------------------*/
  5935. ACMD_FUNC(homfriendly)
  5936. {
  5937. int friendly = 0;
  5938. nullpo_retr(-1, sd);
  5939. if ( !merc_is_hom_active(sd->hd) ) {
  5940. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  5941. return -1;
  5942. }
  5943. if (!message || !*message) {
  5944. clif_displaymessage(fd, msg_txt(sd,1258)); // Please enter a friendly value (usage: @homfriendly <friendly value [0-1000]>).
  5945. return -1;
  5946. }
  5947. friendly = atoi(message);
  5948. friendly = cap_value(friendly, 0, 1000);
  5949. sd->hd->homunculus.intimacy = friendly * 100 ;
  5950. clif_send_homdata(sd,SP_INTIMATE,friendly);
  5951. return 0;
  5952. }
  5953. /*==========================================
  5954. * modify homunculus hunger [orn]
  5955. *------------------------------------------*/
  5956. ACMD_FUNC(homhungry)
  5957. {
  5958. int hungry = 0;
  5959. nullpo_retr(-1, sd);
  5960. if ( !merc_is_hom_active(sd->hd) ) {
  5961. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  5962. return -1;
  5963. }
  5964. if (!message || !*message) {
  5965. clif_displaymessage(fd, msg_txt(sd,1259)); // Please enter a hunger value (usage: @homhungry <hunger value [0-100]>).
  5966. return -1;
  5967. }
  5968. hungry = atoi(message);
  5969. hungry = cap_value(hungry, 0, 100);
  5970. sd->hd->homunculus.hunger = hungry;
  5971. clif_send_homdata(sd,SP_HUNGRY,hungry);
  5972. return 0;
  5973. }
  5974. /*==========================================
  5975. * make the homunculus speak [orn]
  5976. *------------------------------------------*/
  5977. ACMD_FUNC(homtalk)
  5978. {
  5979. char mes[100],temp[100];
  5980. nullpo_retr(-1, sd);
  5981. if ( battle_config.min_chat_delay ) {
  5982. if( DIFF_TICK(sd->cantalk_tick, gettick()) > 0 )
  5983. return 0;
  5984. sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
  5985. }
  5986. if (sd->sc.count && //no "chatting" while muted.
  5987. (sd->sc.data[SC_BERSERK] || sd->sc.data[SC__BLOODYLUST] ||
  5988. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  5989. return -1;
  5990. if ( !merc_is_hom_active(sd->hd) ) {
  5991. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  5992. return -1;
  5993. }
  5994. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  5995. clif_displaymessage(fd, msg_txt(sd,1260)); // Please enter a message (usage: @homtalk <message>).
  5996. return -1;
  5997. }
  5998. snprintf(temp, sizeof temp ,"%s : %s", sd->hd->homunculus.name, mes);
  5999. clif_disp_overhead(&sd->hd->bl, temp);
  6000. return 0;
  6001. }
  6002. /*==========================================
  6003. * Show homunculus stats
  6004. *------------------------------------------*/
  6005. ACMD_FUNC(hominfo)
  6006. {
  6007. struct homun_data *hd;
  6008. struct status_data *status;
  6009. nullpo_retr(-1, sd);
  6010. if ( !merc_is_hom_active(sd->hd) ) {
  6011. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6012. return -1;
  6013. }
  6014. hd = sd->hd;
  6015. status = status_get_status_data(&hd->bl);
  6016. clif_displaymessage(fd, msg_txt(sd,1261)); // Homunculus stats:
  6017. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1262), // HP: %d/%d - SP: %d/%d
  6018. status->hp, status->max_hp, status->sp, status->max_sp);
  6019. clif_displaymessage(fd, atcmd_output);
  6020. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1263), // ATK: %d - MATK: %d~%d
  6021. status->rhw.atk2 +status->batk, status->matk_min, status->matk_max);
  6022. clif_displaymessage(fd, atcmd_output);
  6023. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1264), // Hungry: %d - Intimacy: %u
  6024. hd->homunculus.hunger, hd->homunculus.intimacy/100);
  6025. clif_displaymessage(fd, atcmd_output);
  6026. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6027. msg_txt(sd,1265), // Stats: Str %d / Agi %d / Vit %d / Int %d / Dex %d / Luk %d
  6028. status->str, status->agi, status->vit,
  6029. status->int_, status->dex, status->luk);
  6030. clif_displaymessage(fd, atcmd_output);
  6031. return 0;
  6032. }
  6033. ACMD_FUNC(homstats)
  6034. {
  6035. struct homun_data *hd;
  6036. struct s_homunculus_db *db;
  6037. struct s_homunculus *hom;
  6038. int lv, min, max, evo;
  6039. nullpo_retr(-1, sd);
  6040. if ( !merc_is_hom_active(sd->hd) ) {
  6041. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6042. return -1;
  6043. }
  6044. hd = sd->hd;
  6045. hom = &hd->homunculus;
  6046. db = hd->homunculusDB;
  6047. lv = hom->level;
  6048. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6049. msg_txt(sd,1266), lv, db->name); // Homunculus growth stats (Lv %d %s):
  6050. clif_displaymessage(fd, atcmd_output);
  6051. lv--; //Since the first increase is at level 2.
  6052. evo = (hom->class_ == db->evo_class);
  6053. min = db->base.HP +lv*db->gmin.HP +(evo?db->emin.HP:0);
  6054. max = db->base.HP +lv*db->gmax.HP +(evo?db->emax.HP:0);;
  6055. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1267), hom->max_hp, min, max); // Max HP: %d (%d~%d)
  6056. clif_displaymessage(fd, atcmd_output);
  6057. min = db->base.SP +lv*db->gmin.SP +(evo?db->emin.SP:0);
  6058. max = db->base.SP +lv*db->gmax.SP +(evo?db->emax.SP:0);;
  6059. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1268), hom->max_sp, min, max); // Max SP: %d (%d~%d)
  6060. clif_displaymessage(fd, atcmd_output);
  6061. min = db->base.str +lv*(db->gmin.str/10) +(evo?db->emin.str:0);
  6062. max = db->base.str +lv*(db->gmax.str/10) +(evo?db->emax.str:0);;
  6063. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1269), hom->str/10, min, max); // Str: %d (%d~%d)
  6064. clif_displaymessage(fd, atcmd_output);
  6065. min = db->base.agi +lv*(db->gmin.agi/10) +(evo?db->emin.agi:0);
  6066. max = db->base.agi +lv*(db->gmax.agi/10) +(evo?db->emax.agi:0);;
  6067. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1270), hom->agi/10, min, max); // Agi: %d (%d~%d)
  6068. clif_displaymessage(fd, atcmd_output);
  6069. min = db->base.vit +lv*(db->gmin.vit/10) +(evo?db->emin.vit:0);
  6070. max = db->base.vit +lv*(db->gmax.vit/10) +(evo?db->emax.vit:0);;
  6071. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1271), hom->vit/10, min, max); // Vit: %d (%d~%d)
  6072. clif_displaymessage(fd, atcmd_output);
  6073. min = db->base.int_ +lv*(db->gmin.int_/10) +(evo?db->emin.int_:0);
  6074. max = db->base.int_ +lv*(db->gmax.int_/10) +(evo?db->emax.int_:0);;
  6075. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1272), hom->int_/10, min, max); // Int: %d (%d~%d)
  6076. clif_displaymessage(fd, atcmd_output);
  6077. min = db->base.dex +lv*(db->gmin.dex/10) +(evo?db->emin.dex:0);
  6078. max = db->base.dex +lv*(db->gmax.dex/10) +(evo?db->emax.dex:0);;
  6079. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1273), hom->dex/10, min, max); // Dex: %d (%d~%d)
  6080. clif_displaymessage(fd, atcmd_output);
  6081. min = db->base.luk +lv*(db->gmin.luk/10) +(evo?db->emin.luk:0);
  6082. max = db->base.luk +lv*(db->gmax.luk/10) +(evo?db->emax.luk:0);;
  6083. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1274), hom->luk/10, min, max); // Luk: %d (%d~%d)
  6084. clif_displaymessage(fd, atcmd_output);
  6085. return 0;
  6086. }
  6087. ACMD_FUNC(homshuffle)
  6088. {
  6089. nullpo_retr(-1, sd);
  6090. if(!sd->hd)
  6091. return -1; // nothing to do
  6092. if(!merc_hom_shuffle(sd->hd))
  6093. return -1;
  6094. clif_displaymessage(sd->fd, msg_txt(sd,1275)); // Homunculus stats altered.
  6095. atcommand_homstats(fd, sd, command, message); //Print out the new stats
  6096. return 0;
  6097. }
  6098. /*==========================================
  6099. * Show Items DB Info v 1.0
  6100. * originally by [Lupus]
  6101. *------------------------------------------*/
  6102. ACMD_FUNC(iteminfo)
  6103. {
  6104. struct item_data *item_data, *item_array[MAX_SEARCH];
  6105. int i, count = 1;
  6106. if (!message || !*message) {
  6107. clif_displaymessage(fd, msg_txt(sd,1276)); // Please enter an item name/ID (usage: @ii/@iteminfo <item name/ID>).
  6108. return -1;
  6109. }
  6110. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  6111. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  6112. if (!count) {
  6113. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  6114. return -1;
  6115. }
  6116. if (count > MAX_SEARCH) {
  6117. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH, count); // Displaying first %d out of %d matches
  6118. clif_displaymessage(fd, atcmd_output);
  6119. count = MAX_SEARCH;
  6120. }
  6121. for (i = 0; i < count; i++) {
  6122. item_data = item_array[i];
  6123. sprintf(atcmd_output, msg_txt(sd,1277), // Item: '%s'/'%s'[%d] (%d) Type: %s | Extra Effect: %s
  6124. item_data->name,item_data->jname,item_data->slot,item_data->nameid,
  6125. itemdb_typename(item_data->type),
  6126. (item_data->script==NULL)? msg_txt(sd,1278) : msg_txt(sd,1279) // None / With script
  6127. );
  6128. clif_displaymessage(fd, atcmd_output);
  6129. 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
  6130. clif_displaymessage(fd, atcmd_output);
  6131. if (item_data->maxchance == -1)
  6132. strcpy(atcmd_output, msg_txt(sd,1281)); // - Available in the shops only.
  6133. else if (!battle_config.atcommand_mobinfo_type && item_data->maxchance)
  6134. sprintf(atcmd_output, msg_txt(sd,1282), (float)item_data->maxchance / 100 ); // - Maximal monsters drop chance: %02.02f%%
  6135. else
  6136. strcpy(atcmd_output, msg_txt(sd,1283)); // - Monsters don't drop this item.
  6137. clif_displaymessage(fd, atcmd_output);
  6138. }
  6139. return 0;
  6140. }
  6141. /*==========================================
  6142. * Show who drops the item.
  6143. *------------------------------------------*/
  6144. ACMD_FUNC(whodrops)
  6145. {
  6146. struct item_data *item_data, *item_array[MAX_SEARCH];
  6147. int i,j, count = 1;
  6148. if (!message || !*message) {
  6149. clif_displaymessage(fd, msg_txt(sd,1284)); // Please enter item name/ID (usage: @whodrops <item name/ID>).
  6150. return -1;
  6151. }
  6152. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  6153. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  6154. if (!count) {
  6155. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  6156. return -1;
  6157. }
  6158. if (count > MAX_SEARCH) {
  6159. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH, count); // Displaying first %d out of %d matches
  6160. clif_displaymessage(fd, atcmd_output);
  6161. count = MAX_SEARCH;
  6162. }
  6163. for (i = 0; i < count; i++) {
  6164. item_data = item_array[i];
  6165. sprintf(atcmd_output, msg_txt(sd,1285), item_data->jname,item_data->slot); // Item: '%s'[%d]
  6166. clif_displaymessage(fd, atcmd_output);
  6167. if (item_data->mob[0].chance == 0) {
  6168. strcpy(atcmd_output, msg_txt(sd,1286)); // - Item is not dropped by mobs.
  6169. clif_displaymessage(fd, atcmd_output);
  6170. } else {
  6171. sprintf(atcmd_output, msg_txt(sd,1287), MAX_SEARCH); // - Common mobs with highest drop chance (only max %d are listed):
  6172. clif_displaymessage(fd, atcmd_output);
  6173. for (j=0; j < MAX_SEARCH && item_data->mob[j].chance > 0; j++)
  6174. {
  6175. int dropchance = item_data->mob[j].chance;
  6176. #ifdef RENEWAL_DROP
  6177. if( battle_config.atcommand_mobinfo_type )
  6178. dropchance = dropchance * pc_level_penalty_mod(sd, mob_db(item_data->mob[j].id)->lv, mob_db(item_data->mob[j].id)->status.race, mob_db(item_data->mob[j].id)->status.mode, 2) / 100;
  6179. #endif
  6180. sprintf(atcmd_output, "- %s (%02.02f%%)", mob_db(item_data->mob[j].id)->jname, dropchance/100.);
  6181. clif_displaymessage(fd, atcmd_output);
  6182. }
  6183. }
  6184. }
  6185. return 0;
  6186. }
  6187. ACMD_FUNC(whereis)
  6188. {
  6189. struct mob_db *mob, *mob_array[MAX_SEARCH];
  6190. int count;
  6191. int i, j, k;
  6192. if (!message || !*message) {
  6193. clif_displaymessage(fd, msg_txt(sd,1288)); // Please enter a monster name/ID (usage: @whereis <monster_name_or_monster_ID>).
  6194. return -1;
  6195. }
  6196. // If monster identifier/name argument is a name
  6197. if ((i = mobdb_checkid(atoi(message))))
  6198. {
  6199. mob_array[0] = mob_db(i);
  6200. count = 1;
  6201. } else
  6202. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  6203. if (!count) {
  6204. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  6205. return -1;
  6206. }
  6207. if (count > MAX_SEARCH) {
  6208. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH, count);
  6209. clif_displaymessage(fd, atcmd_output);
  6210. count = MAX_SEARCH;
  6211. }
  6212. for (k = 0; k < count; k++) {
  6213. mob = mob_array[k];
  6214. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1289), mob->jname); // %s spawns in:
  6215. clif_displaymessage(fd, atcmd_output);
  6216. for (i = 0; i < ARRAYLENGTH(mob->spawn) && mob->spawn[i].qty; i++)
  6217. {
  6218. j = map_mapindex2mapid(mob->spawn[i].mapindex);
  6219. if (j < 0) continue;
  6220. snprintf(atcmd_output, sizeof atcmd_output, "%s (%d)", map[j].name, mob->spawn[i].qty);
  6221. clif_displaymessage(fd, atcmd_output);
  6222. }
  6223. if (i == 0)
  6224. clif_displaymessage(fd, msg_txt(sd,1290)); // This monster does not spawn normally.
  6225. }
  6226. return 0;
  6227. }
  6228. ACMD_FUNC(version)
  6229. {
  6230. const char * revision;
  6231. if ((revision = get_svn_revision()) != 0) {
  6232. sprintf(atcmd_output,msg_txt(sd,1295),revision); // rAthena Version SVN r%s
  6233. clif_displaymessage(fd,atcmd_output);
  6234. } else
  6235. clif_displaymessage(fd,msg_txt(sd,1296)); // Cannot determine SVN revision.
  6236. return 0;
  6237. }
  6238. /*==========================================
  6239. * @mutearea by MouseJstr
  6240. *------------------------------------------*/
  6241. static int atcommand_mutearea_sub(struct block_list *bl,va_list ap)
  6242. {
  6243. int time, id;
  6244. struct map_session_data *pl_sd = (struct map_session_data *)bl;
  6245. if (pl_sd == NULL)
  6246. return 0;
  6247. id = va_arg(ap, int);
  6248. time = va_arg(ap, int);
  6249. if (id != bl->id && !pc_get_group_level(pl_sd)) {
  6250. pl_sd->status.manner -= time;
  6251. if (pl_sd->status.manner < 0)
  6252. sc_start(NULL,&pl_sd->bl,SC_NOCHAT,100,0,0);
  6253. else
  6254. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  6255. }
  6256. return 0;
  6257. }
  6258. ACMD_FUNC(mutearea)
  6259. {
  6260. int time;
  6261. nullpo_ret(sd);
  6262. if (!message || !*message) {
  6263. clif_displaymessage(fd, msg_txt(sd,1297)); // Please enter a time in minutes (usage: @mutearea/@stfu <time in minutes>).
  6264. return -1;
  6265. }
  6266. time = atoi(message);
  6267. map_foreachinarea(atcommand_mutearea_sub,sd->bl.m,
  6268. sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE,
  6269. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time);
  6270. return 0;
  6271. }
  6272. ACMD_FUNC(rates)
  6273. {
  6274. char buf[CHAT_SIZE_MAX];
  6275. nullpo_ret(sd);
  6276. memset(buf, '\0', sizeof(buf));
  6277. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1298), // Experience rates: Base %.2fx / Job %.2fx
  6278. battle_config.base_exp_rate/100., battle_config.job_exp_rate/100.);
  6279. clif_displaymessage(fd, buf);
  6280. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1299), // Normal Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  6281. battle_config.item_rate_common/100., battle_config.item_rate_heal/100., battle_config.item_rate_use/100., battle_config.item_rate_equip/100., battle_config.item_rate_card/100.);
  6282. clif_displaymessage(fd, buf);
  6283. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1300), // Boss Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  6284. battle_config.item_rate_common_boss/100., battle_config.item_rate_heal_boss/100., battle_config.item_rate_use_boss/100., battle_config.item_rate_equip_boss/100., battle_config.item_rate_card_boss/100.);
  6285. clif_displaymessage(fd, buf);
  6286. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1301), // Other Drop Rates: MvP %.2fx / Card-Based %.2fx / Treasure %.2fx
  6287. battle_config.item_rate_mvp/100., battle_config.item_rate_adddrop/100., battle_config.item_rate_treasure/100.);
  6288. clif_displaymessage(fd, buf);
  6289. return 0;
  6290. }
  6291. /*==========================================
  6292. * @me by lordalfa
  6293. * => Displays the OUTPUT string on top of the Visible players Heads.
  6294. *------------------------------------------*/
  6295. ACMD_FUNC(me)
  6296. {
  6297. char tempmes[CHAT_SIZE_MAX];
  6298. nullpo_retr(-1, sd);
  6299. memset(tempmes, '\0', sizeof(tempmes));
  6300. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6301. if (sd->sc.count && //no "chatting" while muted.
  6302. (sd->sc.data[SC_BERSERK] || sd->sc.data[SC__BLOODYLUST] ||
  6303. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  6304. return -1;
  6305. if (!message || !*message || sscanf(message, "%199[^\n]", tempmes) < 0) {
  6306. clif_displaymessage(fd, msg_txt(sd,1302)); // Please enter a message (usage: @me <message>).
  6307. return -1;
  6308. }
  6309. sprintf(atcmd_output, msg_txt(sd,270), sd->status.name, tempmes); // *%s %s*
  6310. clif_disp_overhead(&sd->bl, atcmd_output);
  6311. return 0;
  6312. }
  6313. /*==========================================
  6314. * @size
  6315. * => Resize your character sprite. [Valaris]
  6316. *------------------------------------------*/
  6317. ACMD_FUNC(size)
  6318. {
  6319. int size = 0;
  6320. nullpo_retr(-1, sd);
  6321. size = cap_value(atoi(message),SZ_SMALL,SZ_BIG);
  6322. if(sd->state.size) {
  6323. sd->state.size = SZ_SMALL;
  6324. pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_TELEPORT);
  6325. }
  6326. sd->state.size = size;
  6327. if( size == SZ_MEDIUM )
  6328. clif_specialeffect(&sd->bl,420,AREA);
  6329. else if( size == SZ_BIG )
  6330. clif_specialeffect(&sd->bl,422,AREA);
  6331. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  6332. return 0;
  6333. }
  6334. ACMD_FUNC(sizeall)
  6335. {
  6336. int size;
  6337. struct map_session_data *pl_sd;
  6338. struct s_mapiterator* iter;
  6339. size = atoi(message);
  6340. size = cap_value(size,0,2);
  6341. iter = mapit_getallusers();
  6342. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) {
  6343. if( pl_sd->state.size != size ) {
  6344. if( pl_sd->state.size ) {
  6345. pl_sd->state.size = SZ_SMALL;
  6346. pc_setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  6347. }
  6348. pl_sd->state.size = size;
  6349. if( size == SZ_MEDIUM )
  6350. clif_specialeffect(&pl_sd->bl,420,AREA);
  6351. else if( size == SZ_BIG )
  6352. clif_specialeffect(&pl_sd->bl,422,AREA);
  6353. }
  6354. }
  6355. mapit_free(iter);
  6356. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  6357. return 0;
  6358. }
  6359. ACMD_FUNC(sizeguild)
  6360. {
  6361. int size = 0, i;
  6362. char guild[NAME_LENGTH];
  6363. struct map_session_data *pl_sd;
  6364. struct guild *g;
  6365. nullpo_retr(-1, sd);
  6366. memset(guild, '\0', sizeof(guild));
  6367. if( !message || !*message || sscanf(message, "%d %23[^\n]", &size, guild) < 2 ) {
  6368. clif_displaymessage(fd, msg_txt(sd,1304)); // Please enter guild name/ID (usage: @sizeguild <size> <guild name/ID>).
  6369. return -1;
  6370. }
  6371. if( (g = guild_searchname(guild)) == NULL && (g = guild_search(atoi(guild))) == NULL ) {
  6372. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  6373. return -1;
  6374. }
  6375. size = cap_value(size,SZ_SMALL,SZ_BIG);
  6376. for( i = 0; i < g->max_member; i++ ) {
  6377. if( (pl_sd = g->member[i].sd) && pl_sd->state.size != size ) {
  6378. if( pl_sd->state.size ) {
  6379. pl_sd->state.size = SZ_SMALL;
  6380. pc_setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  6381. }
  6382. pl_sd->state.size = size;
  6383. if( size == SZ_MEDIUM )
  6384. clif_specialeffect(&pl_sd->bl,420,AREA);
  6385. else if( size == SZ_BIG )
  6386. clif_specialeffect(&pl_sd->bl,422,AREA);
  6387. }
  6388. }
  6389. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  6390. return 0;
  6391. }
  6392. /*==========================================
  6393. * @monsterignore
  6394. * => Makes monsters ignore you. [Valaris]
  6395. *------------------------------------------*/
  6396. ACMD_FUNC(monsterignore)
  6397. {
  6398. nullpo_retr(-1, sd);
  6399. if (!sd->state.monster_ignore) {
  6400. sd->state.monster_ignore = 1;
  6401. clif_displaymessage(sd->fd, msg_txt(sd,1305)); // You are now immune to attacks.
  6402. } else {
  6403. sd->state.monster_ignore = 0;
  6404. clif_displaymessage(sd->fd, msg_txt(sd,1306)); // Returned to normal state.
  6405. }
  6406. return 0;
  6407. }
  6408. /*==========================================
  6409. * @fakename
  6410. * => Gives your character a fake name. [Valaris]
  6411. *------------------------------------------*/
  6412. ACMD_FUNC(fakename)
  6413. {
  6414. nullpo_retr(-1, sd);
  6415. if( !message || !*message )
  6416. {
  6417. if( sd->fakename[0] )
  6418. {
  6419. sd->fakename[0] = '\0';
  6420. clif_charnameack(0, &sd->bl);
  6421. clif_displaymessage(sd->fd, msg_txt(sd,1307)); // Returned to real name.
  6422. return 0;
  6423. }
  6424. clif_displaymessage(sd->fd, msg_txt(sd,1308)); // You must enter a name.
  6425. return -1;
  6426. }
  6427. if( strlen(message) < 2 )
  6428. {
  6429. clif_displaymessage(sd->fd, msg_txt(sd,1309)); // Fake name must be at least two characters.
  6430. return -1;
  6431. }
  6432. safestrncpy(sd->fakename, message, sizeof(sd->fakename));
  6433. clif_charnameack(0, &sd->bl);
  6434. clif_displaymessage(sd->fd, msg_txt(sd,1310)); // Fake name enabled.
  6435. return 0;
  6436. }
  6437. /*==========================================
  6438. * Ragnarok Resources
  6439. *------------------------------------------*/
  6440. ACMD_FUNC(mapflag) {
  6441. #define checkflag( cmd ) if ( map[ sd->bl.m ].flag.cmd ) clif_displaymessage(sd->fd,#cmd)
  6442. #define setflag( cmd ) \
  6443. if ( strcmp( flag_name , #cmd ) == 0 ){\
  6444. map[ sd->bl.m ].flag.cmd = flag;\
  6445. sprintf(atcmd_output,"[ @mapflag ] %s flag has been set to %s value = %hd",#cmd,flag?"On":"Off",flag);\
  6446. clif_displaymessage(sd->fd,atcmd_output);\
  6447. return 0;\
  6448. }
  6449. char flag_name[100];
  6450. short flag=0,i;
  6451. nullpo_retr(-1, sd);
  6452. memset(flag_name, '\0', sizeof(flag_name));
  6453. if (!message || !*message || (sscanf(message, "%99s %hd", flag_name, &flag) < 1)) {
  6454. clif_displaymessage(sd->fd,msg_txt(sd,1311)); // Enabled Mapflags in this map:
  6455. clif_displaymessage(sd->fd,"----------------------------------");
  6456. checkflag(autotrade); checkflag(allowks); checkflag(nomemo); checkflag(noteleport);
  6457. checkflag(noreturn); checkflag(monster_noteleport); checkflag(nosave); checkflag(nobranch);
  6458. checkflag(noexppenalty); checkflag(pvp); checkflag(pvp_noparty); checkflag(pvp_noguild);
  6459. checkflag(pvp_nightmaredrop); checkflag(pvp_nocalcrank); checkflag(gvg_castle); checkflag(gvg);
  6460. checkflag(gvg_dungeon); checkflag(gvg_noparty); checkflag(battleground);checkflag(nozenypenalty);
  6461. checkflag(notrade); checkflag(noskill); checkflag(nowarp); checkflag(nowarpto);
  6462. checkflag(noicewall); checkflag(snow); checkflag(clouds); checkflag(clouds2);
  6463. checkflag(fog); checkflag(fireworks); checkflag(sakura); checkflag(leaves);
  6464. checkflag(nogo); checkflag(nobaseexp);
  6465. checkflag(nojobexp); checkflag(nomobloot); checkflag(nomvploot); checkflag(nightenabled);
  6466. checkflag(restricted); checkflag(nodrop); checkflag(novending); checkflag(loadevent);
  6467. checkflag(nochat); checkflag(partylock); checkflag(guildlock); checkflag(src4instance);
  6468. clif_displaymessage(sd->fd," ");
  6469. clif_displaymessage(sd->fd,msg_txt(sd,1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On)
  6470. clif_displaymessage(sd->fd,msg_txt(sd,1313)); // Type "@mapflag available" to list the available mapflags.
  6471. return 1;
  6472. }
  6473. for (i = 0; flag_name[i]; i++) flag_name[i] = (char)tolower(flag_name[i]); //lowercase
  6474. setflag(autotrade); setflag(allowks); setflag(nomemo); setflag(noteleport);
  6475. setflag(noreturn); setflag(monster_noteleport);setflag(nosave); setflag(nobranch);
  6476. setflag(noexppenalty); setflag(pvp); setflag(pvp_noparty); setflag(pvp_noguild);
  6477. setflag(pvp_nightmaredrop); setflag(pvp_nocalcrank); setflag(gvg_castle); setflag(gvg);
  6478. setflag(gvg_dungeon); setflag(gvg_noparty); setflag(battleground); setflag(nozenypenalty);
  6479. setflag(notrade); setflag(noskill); setflag(nowarp); setflag(nowarpto);
  6480. setflag(noicewall); setflag(snow); setflag(clouds); setflag(clouds2);
  6481. setflag(fog); setflag(fireworks); setflag(sakura); setflag(leaves);
  6482. setflag(nogo); setflag(nobaseexp);
  6483. setflag(nojobexp); setflag(nomobloot); setflag(nomvploot); setflag(nightenabled);
  6484. setflag(restricted); setflag(nodrop); setflag(novending); setflag(loadevent);
  6485. setflag(nochat); setflag(partylock); setflag(guildlock); setflag(src4instance);
  6486. clif_displaymessage(sd->fd,msg_txt(sd,1314)); // Invalid flag name or flag.
  6487. clif_displaymessage(sd->fd,msg_txt(sd,1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On)
  6488. clif_displaymessage(sd->fd,msg_txt(sd,1315)); // Available Flags:
  6489. clif_displaymessage(sd->fd,"----------------------------------");
  6490. clif_displaymessage(sd->fd,"town, autotrade, allowks, nomemo, noteleport, noreturn, monster_noteleport, nosave,");
  6491. clif_displaymessage(sd->fd,"nobranch, noexppenalty, pvp, pvp_noparty, pvp_noguild, pvp_nightmaredrop,");
  6492. clif_displaymessage(sd->fd,"pvp_nocalcrank, gvg_castle, gvg, gvg_dungeon, gvg_noparty, battleground,");
  6493. clif_displaymessage(sd->fd,"nozenypenalty, notrade, noskill, nowarp, nowarpto, noicewall, snow, clouds, clouds2,");
  6494. clif_displaymessage(sd->fd,"fog, fireworks, sakura, leaves, nogo, nobaseexp, nojobexp, nomobloot,");
  6495. clif_displaymessage(sd->fd,"nomvploot, nightenabled, restricted, nodrop, novending, loadevent, nochat, partylock,");
  6496. clif_displaymessage(sd->fd,"guildlock, src4instance");
  6497. #undef checkflag
  6498. #undef setflag
  6499. return 0;
  6500. }
  6501. /*===================================
  6502. * Remove some messages
  6503. *-----------------------------------*/
  6504. ACMD_FUNC(showexp)
  6505. {
  6506. if (sd->state.showexp) {
  6507. sd->state.showexp = 0;
  6508. clif_displaymessage(fd, msg_txt(sd,1316)); // Gained exp will not be shown.
  6509. return 0;
  6510. }
  6511. sd->state.showexp = 1;
  6512. clif_displaymessage(fd, msg_txt(sd,1317)); // Gained exp is now shown.
  6513. return 0;
  6514. }
  6515. ACMD_FUNC(showzeny)
  6516. {
  6517. if (sd->state.showzeny) {
  6518. sd->state.showzeny = 0;
  6519. clif_displaymessage(fd, msg_txt(sd,1318)); // Gained zeny will not be shown.
  6520. return 0;
  6521. }
  6522. sd->state.showzeny = 1;
  6523. clif_displaymessage(fd, msg_txt(sd,1319)); // Gained zeny is now shown.
  6524. return 0;
  6525. }
  6526. ACMD_FUNC(showdelay)
  6527. {
  6528. if (sd->state.showdelay) {
  6529. sd->state.showdelay = 0;
  6530. clif_displaymessage(fd, msg_txt(sd,1320)); // Skill delay failures will not be shown.
  6531. return 0;
  6532. }
  6533. sd->state.showdelay = 1;
  6534. clif_displaymessage(fd, msg_txt(sd,1321)); // Skill delay failures are now shown.
  6535. return 0;
  6536. }
  6537. /*==========================================
  6538. * Duel organizing functions [LuzZza]
  6539. *
  6540. * @duel [limit|nick] - create a duel
  6541. * @invite <nick> - invite player
  6542. * @accept - accept invitation
  6543. * @reject - reject invitation
  6544. * @leave - leave duel
  6545. *------------------------------------------*/
  6546. ACMD_FUNC(invite)
  6547. {
  6548. unsigned int did = sd->duel_group;
  6549. struct map_session_data *target_sd = map_nick2sd((char *)message);
  6550. if(did == 0) {
  6551. // "Duel: @invite without @duel."
  6552. clif_displaymessage(fd, msg_txt(sd,350));
  6553. return 0;
  6554. }
  6555. if(duel_list[did].max_players_limit > 0 &&
  6556. duel_list[did].members_count >= duel_list[did].max_players_limit) {
  6557. // "Duel: Limit of players is reached."
  6558. clif_displaymessage(fd, msg_txt(sd,351));
  6559. return 0;
  6560. }
  6561. if(target_sd == NULL) {
  6562. // "Duel: Player not found."
  6563. clif_displaymessage(fd, msg_txt(sd,352));
  6564. return 0;
  6565. }
  6566. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  6567. // "Duel: Player already in duel."
  6568. clif_displaymessage(fd, msg_txt(sd,353));
  6569. return 0;
  6570. }
  6571. if(battle_config.duel_only_on_same_map && target_sd->bl.m != sd->bl.m)
  6572. {
  6573. sprintf(atcmd_output, msg_txt(sd,364), message);
  6574. clif_displaymessage(fd, atcmd_output);
  6575. return 0;
  6576. }
  6577. duel_invite(did, sd, target_sd);
  6578. // "Duel: Invitation has been sent."
  6579. clif_displaymessage(fd, msg_txt(sd,354));
  6580. return 0;
  6581. }
  6582. ACMD_FUNC(duel)
  6583. {
  6584. unsigned int maxpl = 0;
  6585. if(sd->duel_group > 0) {
  6586. duel_showinfo(sd->duel_group, sd);
  6587. return 0;
  6588. }
  6589. if(sd->duel_invite > 0) {
  6590. // "Duel: @duel without @reject."
  6591. clif_displaymessage(fd, msg_txt(sd,355));
  6592. return 0;
  6593. }
  6594. if(!duel_checktime(sd)) {
  6595. char output[CHAT_SIZE_MAX];
  6596. // "Duel: You can take part in duel only one time per %d minutes."
  6597. sprintf(output, msg_txt(sd,356), battle_config.duel_time_interval);
  6598. clif_displaymessage(fd, output);
  6599. return 0;
  6600. }
  6601. if( message[0] ) {
  6602. if(sscanf(message, "%d", &maxpl) >= 1) {
  6603. if(maxpl < 2 || maxpl > 65535) {
  6604. clif_displaymessage(fd, msg_txt(sd,357)); // "Duel: Invalid value."
  6605. return 0;
  6606. }
  6607. duel_create(sd, maxpl);
  6608. } else {
  6609. struct map_session_data *target_sd;
  6610. target_sd = map_nick2sd((char *)message);
  6611. if(target_sd != NULL) {
  6612. unsigned int maxpl=0, newduel;
  6613. if((newduel = duel_create(sd, 2)) != -1) {
  6614. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  6615. clif_displaymessage(fd, msg_txt(sd,353)); // "Duel: Player already in duel."
  6616. return 0;
  6617. }
  6618. duel_invite(newduel, sd, target_sd);
  6619. clif_displaymessage(fd, msg_txt(sd,354)); // "Duel: Invitation has been sent."
  6620. }
  6621. } else {
  6622. // "Duel: Player not found."
  6623. clif_displaymessage(fd, msg_txt(sd,352));
  6624. return 0;
  6625. }
  6626. }
  6627. } else
  6628. duel_create(sd, 0);
  6629. return 0;
  6630. }
  6631. ACMD_FUNC(leave)
  6632. {
  6633. if(sd->duel_group <= 0) {
  6634. // "Duel: @leave without @duel."
  6635. clif_displaymessage(fd, msg_txt(sd,358));
  6636. return 0;
  6637. }
  6638. duel_leave(sd->duel_group, sd);
  6639. clif_displaymessage(fd, msg_txt(sd,359)); // "Duel: You left the duel."
  6640. return 0;
  6641. }
  6642. ACMD_FUNC(accept)
  6643. {
  6644. if(!duel_checktime(sd)) {
  6645. char output[CHAT_SIZE_MAX];
  6646. // "Duel: You can take part in duel only one time per %d minutes."
  6647. sprintf(output, msg_txt(sd,356), battle_config.duel_time_interval);
  6648. clif_displaymessage(fd, output);
  6649. return 0;
  6650. }
  6651. if(sd->duel_invite <= 0) {
  6652. // "Duel: @accept without invititation."
  6653. clif_displaymessage(fd, msg_txt(sd,360));
  6654. return 0;
  6655. }
  6656. 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 )
  6657. {
  6658. // "Duel: Limit of players is reached."
  6659. clif_displaymessage(fd, msg_txt(sd,351));
  6660. return 0;
  6661. }
  6662. duel_accept(sd->duel_invite, sd);
  6663. // "Duel: Invitation has been accepted."
  6664. clif_displaymessage(fd, msg_txt(sd,361));
  6665. return 0;
  6666. }
  6667. ACMD_FUNC(reject)
  6668. {
  6669. if(sd->duel_invite <= 0) {
  6670. // "Duel: @reject without invititation."
  6671. clif_displaymessage(fd, msg_txt(sd,362));
  6672. return 0;
  6673. }
  6674. duel_reject(sd->duel_invite, sd);
  6675. // "Duel: Invitation has been rejected."
  6676. clif_displaymessage(fd, msg_txt(sd,363));
  6677. return 0;
  6678. }
  6679. /*===================================
  6680. * Cash Points
  6681. *-----------------------------------*/
  6682. ACMD_FUNC(cash)
  6683. {
  6684. char output[128];
  6685. int value;
  6686. int ret=0;
  6687. nullpo_retr(-1, sd);
  6688. if( !message || !*message || (value = atoi(message)) == 0 ) {
  6689. clif_displaymessage(fd, msg_txt(sd,1322)); // Please enter an amount.
  6690. return -1;
  6691. }
  6692. if( !strcmpi(command+1,"cash") )
  6693. {
  6694. if( value > 0 ) {
  6695. if( (ret=pc_getcash(sd, value, 0, LOG_TYPE_COMMAND)) >= 0){
  6696. // If this option is set, the message is already sent by pc function
  6697. if( !battle_config.cashshop_show_points ){
  6698. sprintf(output, msg_txt(sd,505), ret, sd->cashPoints);
  6699. clif_disp_onlyself(sd, output, strlen(output));
  6700. }
  6701. }
  6702. else clif_displaymessage(fd, msg_txt(sd,149)); // Unable to decrease the number/value.
  6703. } else {
  6704. if( (ret=pc_paycash(sd, -value, 0, LOG_TYPE_COMMAND)) >= 0){
  6705. // If this option is set, the message is already sent by pc function
  6706. if( !battle_config.cashshop_show_points ){
  6707. sprintf(output, msg_txt(sd,410), ret, sd->cashPoints);
  6708. clif_disp_onlyself(sd, output, strlen(output));
  6709. }
  6710. }
  6711. else clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  6712. }
  6713. }
  6714. else
  6715. { // @points
  6716. if( value > 0 ) {
  6717. if( (ret=pc_getcash(sd, 0, value, LOG_TYPE_COMMAND)) >= 0){
  6718. sprintf(output, msg_txt(sd,506), ret, sd->kafraPoints);
  6719. clif_disp_onlyself(sd, output, strlen(output));
  6720. }
  6721. else clif_displaymessage(fd, msg_txt(sd,149)); // Unable to decrease the number/value.
  6722. } else {
  6723. if( (ret=pc_paycash(sd, -value, -value, LOG_TYPE_COMMAND)) >= 0){
  6724. sprintf(output, msg_txt(sd,411), ret, sd->kafraPoints);
  6725. clif_disp_onlyself(sd, output, strlen(output));
  6726. }
  6727. else clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  6728. }
  6729. }
  6730. return 0;
  6731. }
  6732. // @clone/@slaveclone/@evilclone <playername> [Valaris]
  6733. ACMD_FUNC(clone)
  6734. {
  6735. int x=0,y=0,flag=0,master=0,i=0;
  6736. struct map_session_data *pl_sd=NULL;
  6737. if (!message || !*message) {
  6738. clif_displaymessage(sd->fd,msg_txt(sd,1323)); // You must enter a player name or ID.
  6739. return 0;
  6740. }
  6741. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL) {
  6742. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  6743. return 0;
  6744. }
  6745. if(pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  6746. clif_displaymessage(fd, msg_txt(sd,126)); // Cannot clone a player of higher GM level than yourself.
  6747. return 0;
  6748. }
  6749. if (strcmpi(command+1, "clone") == 0)
  6750. flag = 1;
  6751. else if (strcmpi(command+1, "slaveclone") == 0) {
  6752. flag = 2;
  6753. if(pc_isdead(sd)){
  6754. clif_displaymessage(fd, msg_txt(sd,129+flag*2));
  6755. return 0;
  6756. }
  6757. master = sd->bl.id;
  6758. if (battle_config.atc_slave_clone_limit
  6759. && mob_countslave(&sd->bl) >= battle_config.atc_slave_clone_limit) {
  6760. clif_displaymessage(fd, msg_txt(sd,127)); // You've reached your slave clones limit.
  6761. return 0;
  6762. }
  6763. }
  6764. do {
  6765. x = sd->bl.x + (rnd() % 10 - 5);
  6766. y = sd->bl.y + (rnd() % 10 - 5);
  6767. } while (map_getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10);
  6768. if (i >= 10) {
  6769. x = sd->bl.x;
  6770. y = sd->bl.y;
  6771. }
  6772. if((x = mob_clone_spawn(pl_sd, sd->bl.m, x, y, "", master, 0, flag?1:0, 0)) > 0) {
  6773. clif_displaymessage(fd, msg_txt(sd,128+flag*2)); // Evil Clone spawned. Clone spawned. Slave clone spawned.
  6774. return 0;
  6775. }
  6776. clif_displaymessage(fd, msg_txt(sd,129+flag*2)); // Unable to spawn evil clone. Unable to spawn clone. Unable to spawn slave clone.
  6777. return 0;
  6778. }
  6779. /*=====================================
  6780. * Autorejecting Invites/Deals [LuzZza]
  6781. * Usage: @noask
  6782. *-------------------------------------*/
  6783. ACMD_FUNC(noask)
  6784. {
  6785. if(sd->state.noask) {
  6786. clif_displaymessage(fd, msg_txt(sd,391)); // Autorejecting is deactivated.
  6787. sd->state.noask = 0;
  6788. } else {
  6789. clif_displaymessage(fd, msg_txt(sd,390)); // Autorejecting is activated.
  6790. sd->state.noask = 1;
  6791. }
  6792. return 0;
  6793. }
  6794. /*=====================================
  6795. * Send a @request message to all GMs of lowest_gm_level.
  6796. * Usage: @request <petition>
  6797. *-------------------------------------*/
  6798. ACMD_FUNC(request)
  6799. {
  6800. if (!message || !*message) {
  6801. clif_displaymessage(sd->fd,msg_txt(sd,277)); // Usage: @request <petition/message to online GMs>.
  6802. return -1;
  6803. }
  6804. sprintf(atcmd_output, msg_txt(sd,278), message); // (@request): %s
  6805. intif_wis_message_to_gm(sd->status.name, PC_PERM_RECEIVE_REQUESTS, atcmd_output);
  6806. clif_disp_onlyself(sd, atcmd_output, strlen(atcmd_output));
  6807. clif_displaymessage(sd->fd,msg_txt(sd,279)); // @request sent.
  6808. return 0;
  6809. }
  6810. /*==========================================
  6811. * Feel (SG save map) Reset [HiddenDragon]
  6812. *------------------------------------------*/
  6813. ACMD_FUNC(feelreset)
  6814. {
  6815. pc_resetfeel(sd);
  6816. clif_displaymessage(fd, msg_txt(sd,1324)); // Reset 'Feeling' maps.
  6817. return 0;
  6818. }
  6819. /*==========================================
  6820. * AUCTION SYSTEM
  6821. *------------------------------------------*/
  6822. ACMD_FUNC(auction)
  6823. {
  6824. nullpo_ret(sd);
  6825. clif_Auction_openwindow(sd);
  6826. return 0;
  6827. }
  6828. /*==========================================
  6829. * Kill Steal Protection
  6830. *------------------------------------------*/
  6831. ACMD_FUNC(ksprotection)
  6832. {
  6833. nullpo_retr(-1,sd);
  6834. if( sd->state.noks ) {
  6835. sd->state.noks = 0;
  6836. clif_displaymessage(fd, msg_txt(sd,1325)); // [ K.S Protection Inactive ]
  6837. }
  6838. else
  6839. {
  6840. if( !message || !*message || !strcmpi(message, "party") )
  6841. { // Default is Party
  6842. sd->state.noks = 2;
  6843. clif_displaymessage(fd, msg_txt(sd,1326)); // [ K.S Protection Active - Option: Party ]
  6844. }
  6845. else if( !strcmpi(message, "self") )
  6846. {
  6847. sd->state.noks = 1;
  6848. clif_displaymessage(fd, msg_txt(sd,1327)); // [ K.S Protection Active - Option: Self ]
  6849. }
  6850. else if( !strcmpi(message, "guild") )
  6851. {
  6852. sd->state.noks = 3;
  6853. clif_displaymessage(fd, msg_txt(sd,1328)); // [ K.S Protection Active - Option: Guild ]
  6854. }
  6855. else
  6856. clif_displaymessage(fd, msg_txt(sd,1329)); // Usage: @noks <self|party|guild>
  6857. }
  6858. return 0;
  6859. }
  6860. /*==========================================
  6861. * Map Kill Steal Protection Setting
  6862. *------------------------------------------*/
  6863. ACMD_FUNC(allowks)
  6864. {
  6865. nullpo_retr(-1,sd);
  6866. if( map[sd->bl.m].flag.allowks ) {
  6867. map[sd->bl.m].flag.allowks = 0;
  6868. clif_displaymessage(fd, msg_txt(sd,1330)); // [ Map K.S Protection Active ]
  6869. } else {
  6870. map[sd->bl.m].flag.allowks = 1;
  6871. clif_displaymessage(fd, msg_txt(sd,1331)); // [ Map K.S Protection Inactive ]
  6872. }
  6873. return 0;
  6874. }
  6875. ACMD_FUNC(resetstat)
  6876. {
  6877. nullpo_retr(-1, sd);
  6878. pc_resetstate(sd);
  6879. sprintf(atcmd_output, msg_txt(sd,207), sd->status.name);
  6880. clif_displaymessage(fd, atcmd_output);
  6881. return 0;
  6882. }
  6883. ACMD_FUNC(resetskill)
  6884. {
  6885. nullpo_retr(-1,sd);
  6886. pc_resetskill(sd,1);
  6887. sprintf(atcmd_output, msg_txt(sd,206), sd->status.name);
  6888. clif_displaymessage(fd, atcmd_output);
  6889. return 0;
  6890. }
  6891. /*==========================================
  6892. * #storagelist: Displays the items list of a player's storage.
  6893. * #cartlist: Displays contents of target's cart.
  6894. * #itemlist: Displays contents of target's inventory.
  6895. *------------------------------------------*/
  6896. ACMD_FUNC(itemlist)
  6897. {
  6898. int i, j, count, counter;
  6899. const char* location;
  6900. const struct item* items;
  6901. int size;
  6902. StringBuf buf;
  6903. nullpo_retr(-1, sd);
  6904. if( strcmp(command+1, "storagelist") == 0 )
  6905. {
  6906. location = "storage";
  6907. items = sd->status.storage.items;
  6908. size = MAX_STORAGE;
  6909. }
  6910. else
  6911. if( strcmp(command+1, "cartlist") == 0 )
  6912. {
  6913. location = "cart";
  6914. items = sd->status.cart;
  6915. size = MAX_CART;
  6916. }
  6917. else
  6918. if( strcmp(command+1, "itemlist") == 0 )
  6919. {
  6920. location = "inventory";
  6921. items = sd->status.inventory;
  6922. size = MAX_INVENTORY;
  6923. }
  6924. else
  6925. return 1;
  6926. StringBuf_Init(&buf);
  6927. count = 0; // total slots occupied
  6928. counter = 0; // total items found
  6929. for( i = 0; i < size; ++i )
  6930. {
  6931. const struct item* it = &items[i];
  6932. struct item_data* itd;
  6933. if( it->nameid == 0 || (itd = itemdb_exists(it->nameid)) == NULL )
  6934. continue;
  6935. counter += it->amount;
  6936. count++;
  6937. if( count == 1 )
  6938. {
  6939. StringBuf_Printf(&buf, msg_txt(sd,1332), location, sd->status.name); // ------ %s items list of '%s' ------
  6940. clif_displaymessage(fd, StringBuf_Value(&buf));
  6941. StringBuf_Clear(&buf);
  6942. }
  6943. if( it->refine )
  6944. StringBuf_Printf(&buf, "%d %s %+d (%s, id: %d)", it->amount, itd->jname, it->refine, itd->name, it->nameid);
  6945. else
  6946. StringBuf_Printf(&buf, "%d %s (%s, id: %d)", it->amount, itd->jname, itd->name, it->nameid);
  6947. if( it->equip )
  6948. {
  6949. char equipstr[CHAT_SIZE_MAX];
  6950. strcpy(equipstr, msg_txt(sd,1333)); // | equipped:
  6951. if( it->equip & EQP_GARMENT )
  6952. strcat(equipstr, msg_txt(sd,1334)); // garment,
  6953. if( it->equip & EQP_ACC_L )
  6954. strcat(equipstr, msg_txt(sd,1335)); // left accessory,
  6955. if( it->equip & EQP_ARMOR )
  6956. strcat(equipstr, msg_txt(sd,1336)); // body/armor,
  6957. if( (it->equip & EQP_ARMS) == EQP_HAND_R )
  6958. strcat(equipstr, msg_txt(sd,1337)); // right hand,
  6959. if( (it->equip & EQP_ARMS) == EQP_HAND_L )
  6960. strcat(equipstr, msg_txt(sd,1338)); // left hand,
  6961. if( (it->equip & EQP_ARMS) == EQP_ARMS )
  6962. strcat(equipstr, msg_txt(sd,1339)); // both hands,
  6963. if( it->equip & EQP_SHOES )
  6964. strcat(equipstr, msg_txt(sd,1340)); // feet,
  6965. if( it->equip & EQP_ACC_R )
  6966. strcat(equipstr, msg_txt(sd,1341)); // right accessory,
  6967. if( (it->equip & EQP_HELM) == EQP_HEAD_LOW )
  6968. strcat(equipstr, msg_txt(sd,1342)); // lower head,
  6969. if( (it->equip & EQP_HELM) == EQP_HEAD_TOP )
  6970. strcat(equipstr, msg_txt(sd,1343)); // top head,
  6971. if( (it->equip & EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_TOP) )
  6972. strcat(equipstr, msg_txt(sd,1344)); // lower/top head,
  6973. if( (it->equip & EQP_HELM) == EQP_HEAD_MID )
  6974. strcat(equipstr, msg_txt(sd,1345)); // mid head,
  6975. if( (it->equip & EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_MID) )
  6976. strcat(equipstr, msg_txt(sd,1346)); // lower/mid head,
  6977. if( (it->equip & EQP_HELM) == EQP_HELM )
  6978. strcat(equipstr, msg_txt(sd,1347)); // lower/mid/top head,
  6979. // remove final ', '
  6980. equipstr[strlen(equipstr) - 2] = '\0';
  6981. StringBuf_AppendStr(&buf, equipstr);
  6982. }
  6983. clif_displaymessage(fd, StringBuf_Value(&buf));
  6984. StringBuf_Clear(&buf);
  6985. if( it->card[0] == CARD0_PET )
  6986. {// pet egg
  6987. if (it->card[3])
  6988. StringBuf_Printf(&buf, msg_txt(sd,1348), (unsigned int)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, named)
  6989. else
  6990. StringBuf_Printf(&buf, msg_txt(sd,1349), (unsigned int)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, unnamed)
  6991. }
  6992. else
  6993. if(it->card[0] == CARD0_FORGE)
  6994. {// forged item
  6995. 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)
  6996. }
  6997. else
  6998. if(it->card[0] == CARD0_CREATE)
  6999. {// created item
  7000. StringBuf_Printf(&buf, msg_txt(sd,1351), (unsigned int)MakeDWord(it->card[2], it->card[3])); // -> (produced item, creator id: %u)
  7001. }
  7002. else
  7003. {// normal item
  7004. int counter2 = 0;
  7005. for( j = 0; j < itd->slot; ++j )
  7006. {
  7007. struct item_data* card;
  7008. if( it->card[j] == 0 || (card = itemdb_exists(it->card[j])) == NULL )
  7009. continue;
  7010. counter2++;
  7011. if( counter2 == 1 )
  7012. StringBuf_AppendStr(&buf, msg_txt(sd,1352)); // -> (card(s):
  7013. if( counter2 != 1 )
  7014. StringBuf_AppendStr(&buf, ", ");
  7015. StringBuf_Printf(&buf, "#%d %s (id: %d)", counter2, card->jname, card->nameid);
  7016. }
  7017. if( counter2 > 0 )
  7018. StringBuf_AppendStr(&buf, ")");
  7019. }
  7020. if( StringBuf_Length(&buf) > 0 )
  7021. clif_displaymessage(fd, StringBuf_Value(&buf));
  7022. StringBuf_Clear(&buf);
  7023. }
  7024. if( count == 0 )
  7025. StringBuf_Printf(&buf, msg_txt(sd,1353), location); // No item found in this player's %s.
  7026. else
  7027. StringBuf_Printf(&buf, msg_txt(sd,1354), counter, count, location); // %d item(s) found in %d %s slots.
  7028. clif_displaymessage(fd, StringBuf_Value(&buf));
  7029. StringBuf_Destroy(&buf);
  7030. return 0;
  7031. }
  7032. ACMD_FUNC(stats)
  7033. {
  7034. char job_jobname[100];
  7035. char output[CHAT_SIZE_MAX];
  7036. int i;
  7037. struct {
  7038. const char* format;
  7039. int value;
  7040. } output_table[] = {
  7041. { "Base Level - %d", 0 },
  7042. { NULL, 0 },
  7043. { "Hp - %d", 0 },
  7044. { "MaxHp - %d", 0 },
  7045. { "Sp - %d", 0 },
  7046. { "MaxSp - %d", 0 },
  7047. { "Str - %3d", 0 },
  7048. { "Agi - %3d", 0 },
  7049. { "Vit - %3d", 0 },
  7050. { "Int - %3d", 0 },
  7051. { "Dex - %3d", 0 },
  7052. { "Luk - %3d", 0 },
  7053. { "Zeny - %d", 0 },
  7054. { "Free SK Points - %d", 0 },
  7055. { "JobChangeLvl (2nd) - %d", 0 },
  7056. { "JobChangeLvl (3rd) - %d", 0 },
  7057. { NULL, 0 }
  7058. };
  7059. memset(job_jobname, '\0', sizeof(job_jobname));
  7060. memset(output, '\0', sizeof(output));
  7061. //direct array initialization with variables is not standard C compliant.
  7062. output_table[0].value = sd->status.base_level;
  7063. output_table[1].format = job_jobname;
  7064. output_table[1].value = sd->status.job_level;
  7065. output_table[2].value = sd->status.hp;
  7066. output_table[3].value = sd->status.max_hp;
  7067. output_table[4].value = sd->status.sp;
  7068. output_table[5].value = sd->status.max_sp;
  7069. output_table[6].value = sd->status.str;
  7070. output_table[7].value = sd->status.agi;
  7071. output_table[8].value = sd->status.vit;
  7072. output_table[9].value = sd->status.int_;
  7073. output_table[10].value = sd->status.dex;
  7074. output_table[11].value = sd->status.luk;
  7075. output_table[12].value = sd->status.zeny;
  7076. output_table[13].value = sd->status.skill_point;
  7077. output_table[14].value = sd->change_level_2nd;
  7078. output_table[15].value = sd->change_level_3rd;
  7079. sprintf(job_jobname, "Job - %s %s", job_name(sd->status.class_), "(level %d)");
  7080. sprintf(output, msg_txt(sd,53), sd->status.name); // '%s' stats:
  7081. clif_displaymessage(fd, output);
  7082. for (i = 0; output_table[i].format != NULL; i++) {
  7083. sprintf(output, output_table[i].format, output_table[i].value);
  7084. clif_displaymessage(fd, output);
  7085. }
  7086. return 0;
  7087. }
  7088. ACMD_FUNC(delitem)
  7089. {
  7090. char item_name[100];
  7091. int nameid, amount = 0, total, idx;
  7092. struct item_data* id;
  7093. nullpo_retr(-1, sd);
  7094. if( !message || !*message || ( sscanf(message, "\"%99[^\"]\" %d", item_name, &amount) < 2 && sscanf(message, "%99s %d", item_name, &amount) < 2 ) || amount < 1 )
  7095. {
  7096. 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>).
  7097. return -1;
  7098. }
  7099. if( ( id = itemdb_searchname(item_name) ) != NULL || ( id = itemdb_exists(atoi(item_name)) ) != NULL )
  7100. {
  7101. nameid = id->nameid;
  7102. }
  7103. else
  7104. {
  7105. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  7106. return -1;
  7107. }
  7108. total = amount;
  7109. // delete items
  7110. while( amount && ( idx = pc_search_inventory(sd, nameid) ) != -1 )
  7111. {
  7112. int delamount = ( amount < sd->status.inventory[idx].amount ) ? amount : sd->status.inventory[idx].amount;
  7113. if( sd->inventory_data[idx]->type == IT_PETEGG && sd->status.inventory[idx].card[0] == CARD0_PET )
  7114. {// delete pet
  7115. intif_delete_petdata(MakeDWord(sd->status.inventory[idx].card[1], sd->status.inventory[idx].card[2]));
  7116. }
  7117. pc_delitem(sd, idx, delamount, 0, 0, LOG_TYPE_COMMAND);
  7118. amount-= delamount;
  7119. }
  7120. // notify target
  7121. sprintf(atcmd_output, msg_txt(sd,113), total-amount); // %d item(s) removed by a GM.
  7122. clif_displaymessage(sd->fd, atcmd_output);
  7123. // notify source
  7124. if( amount == total )
  7125. {
  7126. clif_displaymessage(fd, msg_txt(sd,116)); // Character does not have the item.
  7127. }
  7128. else if( amount )
  7129. {
  7130. sprintf(atcmd_output, msg_txt(sd,115), total-amount, total-amount, total); // %d item(s) removed. Player had only %d on %d items.
  7131. clif_displaymessage(fd, atcmd_output);
  7132. }
  7133. else
  7134. {
  7135. sprintf(atcmd_output, msg_txt(sd,114), total); // %d item(s) removed from the player.
  7136. clif_displaymessage(fd, atcmd_output);
  7137. }
  7138. return 0;
  7139. }
  7140. /*==========================================
  7141. * Custom Fonts
  7142. *------------------------------------------*/
  7143. ACMD_FUNC(font)
  7144. {
  7145. int font_id;
  7146. nullpo_retr(-1,sd);
  7147. font_id = atoi(message);
  7148. if( font_id == 0 )
  7149. {
  7150. if( sd->user_font )
  7151. {
  7152. sd->user_font = 0;
  7153. clif_displaymessage(fd, msg_txt(sd,1356)); // Returning to normal font.
  7154. clif_font(sd);
  7155. }
  7156. else
  7157. {
  7158. clif_displaymessage(fd, msg_txt(sd,1357)); // Use @font <1-9> to change your message font.
  7159. clif_displaymessage(fd, msg_txt(sd,1358)); // Use 0 or no parameter to return to normal font.
  7160. }
  7161. }
  7162. else if( font_id < 0 || font_id > 9 )
  7163. clif_displaymessage(fd, msg_txt(sd,1359)); // Invalid font. Use a value from 0 to 9.
  7164. else if( font_id != sd->user_font )
  7165. {
  7166. sd->user_font = font_id;
  7167. clif_font(sd);
  7168. clif_displaymessage(fd, msg_txt(sd,1360)); // Font changed.
  7169. }
  7170. else
  7171. clif_displaymessage(fd, msg_txt(sd,1361)); // Already using this font.
  7172. return 0;
  7173. }
  7174. /*==========================================
  7175. * type: 1 = commands (@), 2 = charcommands (#)
  7176. *------------------------------------------*/
  7177. static void atcommand_commands_sub(struct map_session_data* sd, const int fd, AtCommandType type)
  7178. {
  7179. char line_buff[CHATBOX_SIZE];
  7180. char* cur = line_buff;
  7181. AtCommandInfo* cmd;
  7182. DBIterator *iter = db_iterator(atcommand_db);
  7183. int count = 0;
  7184. memset(line_buff,' ',CHATBOX_SIZE);
  7185. line_buff[CHATBOX_SIZE-1] = 0;
  7186. clif_displaymessage(fd, msg_txt(sd,273)); // "Commands available:"
  7187. for (cmd = dbi_first(iter); dbi_exists(iter); cmd = dbi_next(iter)) {
  7188. unsigned int slen = 0;
  7189. switch( type ) {
  7190. case COMMAND_CHARCOMMAND:
  7191. if( cmd->char_groups[sd->group_pos] == 0 )
  7192. continue;
  7193. break;
  7194. case COMMAND_ATCOMMAND:
  7195. if( cmd->at_groups[sd->group_pos] == 0 )
  7196. continue;
  7197. break;
  7198. default:
  7199. continue;
  7200. }
  7201. slen = strlen(cmd->command);
  7202. // flush the text buffer if this command won't fit into it
  7203. if ( slen + cur - line_buff >= CHATBOX_SIZE )
  7204. {
  7205. clif_displaymessage(fd,line_buff);
  7206. cur = line_buff;
  7207. memset(line_buff,' ',CHATBOX_SIZE);
  7208. line_buff[CHATBOX_SIZE-1] = 0;
  7209. }
  7210. memcpy(cur,cmd->command,slen);
  7211. cur += slen+(10-slen%10);
  7212. count++;
  7213. }
  7214. dbi_destroy(iter);
  7215. clif_displaymessage(fd,line_buff);
  7216. sprintf(atcmd_output, msg_txt(sd,274), count); // "%d commands found."
  7217. clif_displaymessage(fd, atcmd_output);
  7218. return;
  7219. }
  7220. /*==========================================
  7221. * @commands Lists available @ commands to you
  7222. *------------------------------------------*/
  7223. ACMD_FUNC(commands)
  7224. {
  7225. atcommand_commands_sub(sd, fd, COMMAND_ATCOMMAND);
  7226. return 0;
  7227. }
  7228. /*==========================================
  7229. * @charcommands Lists available # commands to you
  7230. *------------------------------------------*/
  7231. ACMD_FUNC(charcommands)
  7232. {
  7233. atcommand_commands_sub(sd, fd, COMMAND_CHARCOMMAND);
  7234. return 0;
  7235. }
  7236. /* for new mounts */
  7237. ACMD_FUNC(mount2) {
  7238. clif_displaymessage(sd->fd,msg_txt(sd,1362)); // NOTICE: If you crash with mount your LUA is outdated.
  7239. if( !(sd->sc.option&OPTION_MOUNTING) ) {
  7240. clif_displaymessage(sd->fd,msg_txt(sd,1363)); // You have mounted.
  7241. pc_setoption(sd, sd->sc.option|OPTION_MOUNTING);
  7242. } else {
  7243. clif_displaymessage(sd->fd,msg_txt(sd,1364)); // You have released your mount.
  7244. pc_setoption(sd, sd->sc.option&~OPTION_MOUNTING);
  7245. }
  7246. return 0;
  7247. }
  7248. ACMD_FUNC(accinfo) {
  7249. char query[NAME_LENGTH];
  7250. if (!message || !*message || strlen(message) > NAME_LENGTH ) {
  7251. clif_displaymessage(fd, msg_txt(sd,1365)); // Usage: @accinfo/@accountinfo <account_id/char name>
  7252. 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".
  7253. return -1;
  7254. }
  7255. //remove const type
  7256. safestrncpy(query, message, NAME_LENGTH);
  7257. intif_request_accinfo( sd->fd, sd->bl.id, pc_get_group_level(sd), query );
  7258. return 0;
  7259. }
  7260. /* [Ind] */
  7261. ACMD_FUNC(set) {
  7262. char reg[32], val[128];
  7263. struct script_data* data;
  7264. int toset = 0, len;
  7265. bool is_str = false;
  7266. if( !message || !*message || (toset = sscanf(message, "%31s %128[^\n]s", reg, val)) < 1 ) {
  7267. clif_displaymessage(fd, msg_txt(sd,1367)); // Usage: @set <variable name> <value>
  7268. clif_displaymessage(fd, msg_txt(sd,1368)); // Usage: ex. "@set PoringCharVar 50"
  7269. clif_displaymessage(fd, msg_txt(sd,1369)); // Usage: ex. "@set PoringCharVarSTR$ Super Duper String"
  7270. clif_displaymessage(fd, msg_txt(sd,1370)); // Usage: ex. "@set PoringCharVarSTR$" outputs its value, Super Duper String.
  7271. return -1;
  7272. }
  7273. /* disabled variable types (they require a proper script state to function, so allowing them would crash the server) */
  7274. if( reg[0] == '.' ) {
  7275. clif_displaymessage(fd, msg_txt(sd,1371)); // NPC variables may not be used with @set.
  7276. return -1;
  7277. } else if( reg[0] == '\'' ) {
  7278. clif_displaymessage(fd, msg_txt(sd,1372)); // Instance variables may not be used with @set.
  7279. return -1;
  7280. }
  7281. is_str = ( reg[strlen(reg) - 1] == '$' ) ? true : false;
  7282. if( ( len = strlen(val) ) > 1 ) {
  7283. if( val[0] == '"' && val[len-1] == '"') {
  7284. val[len-1] = '\0'; //Strip quotes.
  7285. memmove(val, val+1, len-1);
  7286. }
  7287. }
  7288. if( toset >= 2 ) {/* we only set the var if there is an val, otherwise we only output the value */
  7289. if( is_str )
  7290. set_var(sd, reg, (void*) val);
  7291. else
  7292. set_var(sd, reg, (void*)__64BPRTSIZE((atoi(val))));
  7293. }
  7294. CREATE(data, struct script_data,1);
  7295. if( is_str ) {// string variable
  7296. switch( reg[0] ) {
  7297. case '@':
  7298. data->u.str = pc_readregstr(sd, add_str(reg));
  7299. break;
  7300. case '$':
  7301. data->u.str = mapreg_readregstr(add_str(reg));
  7302. break;
  7303. case '#':
  7304. if( reg[1] == '#' )
  7305. data->u.str = pc_readaccountreg2str(sd, reg);// global
  7306. else
  7307. data->u.str = pc_readaccountregstr(sd, reg);// local
  7308. break;
  7309. default:
  7310. data->u.str = pc_readglobalreg_str(sd, reg);
  7311. break;
  7312. }
  7313. if( data->u.str == NULL || data->u.str[0] == '\0' ) {// empty string
  7314. data->type = C_CONSTSTR;
  7315. data->u.str = "";
  7316. } else {// duplicate string
  7317. data->type = C_STR;
  7318. data->u.str = aStrdup(data->u.str);
  7319. }
  7320. } else {// integer variable
  7321. data->type = C_INT;
  7322. switch( reg[0] ) {
  7323. case '@':
  7324. data->u.num = pc_readreg(sd, add_str(reg));
  7325. break;
  7326. case '$':
  7327. data->u.num = mapreg_readreg(add_str(reg));
  7328. break;
  7329. case '#':
  7330. if( reg[1] == '#' )
  7331. data->u.num = pc_readaccountreg2(sd, reg);// global
  7332. else
  7333. data->u.num = pc_readaccountreg(sd, reg);// local
  7334. break;
  7335. default:
  7336. data->u.num = pc_readglobalreg(sd, reg);
  7337. break;
  7338. }
  7339. }
  7340. switch( data->type ) {
  7341. case C_INT:
  7342. sprintf(atcmd_output,msg_txt(sd,1373),reg,data->u.num); // %s value is now :%d
  7343. break;
  7344. case C_STR:
  7345. sprintf(atcmd_output,msg_txt(sd,1374),reg,data->u.str); // %s value is now :%s
  7346. break;
  7347. case C_CONSTSTR:
  7348. sprintf(atcmd_output,msg_txt(sd,1375),reg); // %s is empty
  7349. break;
  7350. default:
  7351. sprintf(atcmd_output,msg_txt(sd,1376),reg,data->type); // %s data type is not supported :%u
  7352. break;
  7353. }
  7354. clif_displaymessage(fd, atcmd_output);
  7355. aFree(data);
  7356. return 0;
  7357. }
  7358. ACMD_FUNC(addperm) {
  7359. int perm_size = ARRAYLENGTH(pc_g_permission_name);
  7360. bool add = (strcmpi(command+1, "addperm") == 0) ? true : false;
  7361. int i;
  7362. if( !message || !*message ) {
  7363. sprintf(atcmd_output, msg_txt(sd,1378),command); // Usage: %s <permission_name>
  7364. clif_displaymessage(fd, atcmd_output);
  7365. clif_displaymessage(fd, msg_txt(sd,1379)); // -- Permission List
  7366. for( i = 0; i < perm_size; i++ ) {
  7367. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  7368. clif_displaymessage(fd, atcmd_output);
  7369. }
  7370. return -1;
  7371. }
  7372. ARR_FIND(0, perm_size, i, strcmpi(pc_g_permission_name[i].name, message) == 0);
  7373. if( i == perm_size ) {
  7374. sprintf(atcmd_output,msg_txt(sd,1380),message); // '%s' is not a known permission.
  7375. clif_displaymessage(fd, atcmd_output);
  7376. clif_displaymessage(fd, msg_txt(sd,1379)); // -- Permission List
  7377. for( i = 0; i < perm_size; i++ ) {
  7378. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  7379. clif_displaymessage(fd, atcmd_output);
  7380. }
  7381. return -1;
  7382. }
  7383. if( add && (sd->permissions&pc_g_permission_name[i].permission) ) {
  7384. sprintf(atcmd_output, msg_txt(sd,1381),sd->status.name,pc_g_permission_name[i].name); // User '%s' already possesses the '%s' permission.
  7385. clif_displaymessage(fd, atcmd_output);
  7386. return -1;
  7387. } else if ( !add && !(sd->permissions&pc_g_permission_name[i].permission) ) {
  7388. sprintf(atcmd_output, msg_txt(sd,1382),sd->status.name,pc_g_permission_name[i].name); // User '%s' doesn't possess the '%s' permission.
  7389. clif_displaymessage(fd, atcmd_output);
  7390. sprintf(atcmd_output,msg_txt(sd,1383),sd->status.name); // -- User '%s' Permissions
  7391. clif_displaymessage(fd, atcmd_output);
  7392. for( i = 0; i < perm_size; i++ ) {
  7393. if( sd->permissions&pc_g_permission_name[i].permission ) {
  7394. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  7395. clif_displaymessage(fd, atcmd_output);
  7396. }
  7397. }
  7398. return -1;
  7399. }
  7400. if( add )
  7401. sd->permissions |= pc_g_permission_name[i].permission;
  7402. else
  7403. sd->permissions &=~ pc_g_permission_name[i].permission;
  7404. sprintf(atcmd_output, msg_txt(sd,1384),sd->status.name); // User '%s' permissions updated successfully. The changes are temporary.
  7405. clif_displaymessage(fd, atcmd_output);
  7406. return 0;
  7407. }
  7408. ACMD_FUNC(unloadnpcfile) {
  7409. if( !message || !*message ) {
  7410. clif_displaymessage(fd, msg_txt(sd,1385)); // Usage: @unloadnpcfile <file name>
  7411. return -1;
  7412. }
  7413. if( npc_unloadfile(message) )
  7414. clif_displaymessage(fd, msg_txt(sd,1386)); // File unloaded. Be aware that mapflags and monsters spawned directly are not removed.
  7415. else {
  7416. clif_displaymessage(fd, msg_txt(sd,1387)); // File not found.
  7417. return -1;
  7418. }
  7419. return 0;
  7420. }
  7421. ACMD_FUNC(cart) {
  7422. #define MC_CART_MDFY(x) \
  7423. sd->status.skill[MC_PUSHCART].id = x?MC_PUSHCART:0; \
  7424. sd->status.skill[MC_PUSHCART].lv = x?1:0; \
  7425. sd->status.skill[MC_PUSHCART].flag = x?SKILL_FLAG_TEMPORARY:SKILL_FLAG_PERMANENT;
  7426. int val = atoi(message);
  7427. bool need_skill = pc_checkskill(sd, MC_PUSHCART) ? false : true;
  7428. if( !message || !*message || val < 0 || val > MAX_CARTS ) {
  7429. sprintf(atcmd_output, msg_txt(sd,1390),command,MAX_CARTS); // Unknown Cart (usage: %s <0-%d>).
  7430. clif_displaymessage(fd, atcmd_output);
  7431. return -1;
  7432. }
  7433. if( val == 0 && !pc_iscarton(sd) ) {
  7434. clif_displaymessage(fd, msg_txt(sd,1391)); // You do not possess a cart to be removed
  7435. return -1;
  7436. }
  7437. if( need_skill ) {
  7438. MC_CART_MDFY(1);
  7439. }
  7440. if( pc_setcart(sd, val) ) {
  7441. if( need_skill ) {
  7442. MC_CART_MDFY(0);
  7443. }
  7444. return -1;/* @cart failed */
  7445. }
  7446. if( need_skill ) {
  7447. MC_CART_MDFY(0);
  7448. }
  7449. clif_displaymessage(fd, msg_txt(sd,1392)); // Cart Added
  7450. return 0;
  7451. #undef MC_CART_MDFY
  7452. }
  7453. /* Channel System [Ind] */
  7454. ACMD_FUNC(join){
  7455. char chname[CHAN_NAME_LENGTH], pass[CHAN_NAME_LENGTH];
  7456. if( !message || !*message || sscanf(message, "%s %s", chname, pass) < 1 ) {
  7457. sprintf(atcmd_output, msg_txt(sd,1399),command); // Unknown channel (usage: %s <#channel_name>).
  7458. clif_displaymessage(fd, atcmd_output);
  7459. return -1;
  7460. }
  7461. return channel_pcjoin(sd, chname, pass);
  7462. }
  7463. /*
  7464. * Display available option for @channel command
  7465. * @command : the name of used command (for alias case)
  7466. */
  7467. static inline void atcmd_channel_help(struct map_session_data *sd, const char *command)
  7468. {
  7469. int fd = sd->fd;
  7470. bool can_delete = pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN);
  7471. bool can_create = (can_delete || Channel_Config.user_chenable);
  7472. clif_displaymessage(fd, msg_txt(sd,1414));// ---- Available options:
  7473. //option create
  7474. if( can_create ) {
  7475. sprintf(atcmd_output, msg_txt(sd,1415),command);// * %s create <#channel_name> <channel_password>
  7476. clif_displaymessage(fd, atcmd_output);
  7477. clif_displaymessage(fd, msg_txt(sd,1416));// -- Creates a new channel.
  7478. }
  7479. //option delete
  7480. if(can_delete){
  7481. sprintf(atcmd_output, msg_txt(sd,1469),command);// * %s delete <#channel_name>
  7482. clif_displaymessage(fd, atcmd_output);
  7483. clif_displaymessage(fd, msg_txt(sd,1470)); // -- Destroys the specified channel.
  7484. }
  7485. //option list
  7486. sprintf(atcmd_output, msg_txt(sd,1417),command);// * %s list
  7487. clif_displaymessage(fd, atcmd_output);
  7488. clif_displaymessage(fd, msg_txt(sd,1418));// -- Lists all public channels.
  7489. sprintf(atcmd_output, msg_txt(sd,1471),command);// * %s list mine
  7490. clif_displaymessage(fd, atcmd_output);
  7491. clif_displaymessage(fd, msg_txt(sd,1472));// -- Lists all channels you have joined.
  7492. if( can_create ) {
  7493. sprintf(atcmd_output, msg_txt(sd,1419),command);// * %s list colors
  7494. clif_displaymessage(fd, atcmd_output);
  7495. clif_displaymessage(fd, msg_txt(sd,1420));// -- Lists all available colors for custom channels.
  7496. }
  7497. //option setcolor
  7498. if(can_create){
  7499. sprintf(atcmd_output, msg_txt(sd,1421),command);// * %s setcolor <#channel_name> <color_name>
  7500. clif_displaymessage(fd, atcmd_output);
  7501. clif_displaymessage(fd, msg_txt(sd,1422));// -- Changes channel text to the specified color (channel owners only).
  7502. }
  7503. //option join
  7504. sprintf(atcmd_output, msg_txt(sd,1473),command);// * %s join <#channel_name> <channel_password>
  7505. clif_displaymessage(fd, atcmd_output);
  7506. clif_displaymessage(fd, msg_txt(sd,1474));// -- Joins the specified channel.
  7507. //option leave
  7508. sprintf(atcmd_output, msg_txt(sd,1423),command);// * %s leave <#channel_name>
  7509. clif_displaymessage(fd, atcmd_output);
  7510. clif_displaymessage(fd, msg_txt(sd,1424));// -- Leaves the specified channel.
  7511. //option bindto
  7512. sprintf(atcmd_output, msg_txt(sd,1427),command);// * %s bindto <#channel_name>
  7513. clif_displaymessage(fd, atcmd_output);
  7514. clif_displaymessage(fd, msg_txt(sd,1428));// -- Binds your global chat to the specified channel, sending all global messages to that channel.
  7515. //option unbind
  7516. sprintf(atcmd_output, msg_txt(sd,1429),command);// * %s unbind
  7517. clif_displaymessage(fd, atcmd_output);
  7518. clif_displaymessage(fd, msg_txt(sd,1430));// -- Unbinds your global chat from the attached channel, if any.
  7519. //option ban/unban/banlist
  7520. if( can_create ) {
  7521. sprintf(atcmd_output, msg_txt(sd,1456),command);// * %s ban <#channel_name> <player>
  7522. clif_displaymessage(fd, atcmd_output);
  7523. clif_displaymessage(fd, msg_txt(sd,1457));// -- Bans the specified player from the channel.
  7524. sprintf(atcmd_output, msg_txt(sd,1458),command);// * %s banlist <#channel_name>
  7525. clif_displaymessage(fd, atcmd_output);
  7526. clif_displaymessage(fd, msg_txt(sd,1459));// -- Lists all players banned from the specified channel.
  7527. sprintf(atcmd_output, msg_txt(sd,1460),command);// * %s unban <#channel_name> <player>
  7528. clif_displaymessage(fd, atcmd_output);
  7529. clif_displaymessage(fd, msg_txt(sd,1461));// -- Unbans the specified player from the channel.
  7530. sprintf(atcmd_output, msg_txt(sd,1467),command);// * %s unbanall <#channel_name>
  7531. clif_displaymessage(fd, atcmd_output);
  7532. clif_displaymessage(fd, msg_txt(sd,1468));// -- Clears all bans from the specified channel.
  7533. }
  7534. //option setopt
  7535. if(can_create){
  7536. sprintf(atcmd_output, msg_txt(sd,1462),command);// * %s setopt <#channel_name> <option> <value>
  7537. clif_displaymessage(fd, atcmd_output);
  7538. clif_displaymessage(fd, msg_txt(sd,1463));// -- Sets an option and value for the specified channel.
  7539. }
  7540. sprintf(atcmd_output, msg_txt(sd,1404),command); // %s failed.
  7541. clif_displaymessage(fd, atcmd_output);
  7542. }
  7543. ACMD_FUNC(channel) {
  7544. char key[CHAN_NAME_LENGTH], sub1[CHAN_NAME_LENGTH], sub2[CHAN_NAME_LENGTH], sub3[CHAN_NAME_LENGTH];
  7545. sub1[0] = sub2[0] = sub3[0] = '\0';
  7546. if( !message || !*message || sscanf(message, "%s %s %s %s", key, sub1, sub2, sub3) < 1 ) {
  7547. atcmd_channel_help(sd,command);
  7548. return 0;
  7549. }
  7550. if( strcmpi(key,"create") == 0 && ( Channel_Config.user_chenable || pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) ) ) {
  7551. if(sub3[0] != '\0'){
  7552. clif_displaymessage(fd, msg_txt(sd,1408)); // Channel password may not contain spaces.
  7553. return -1;
  7554. }
  7555. return channel_pccreate(sd,sub1,sub2);
  7556. } else if( strcmpi(key,"delete") == 0 && pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) ) {
  7557. return channel_pcdelete(sd,sub1);
  7558. } else if ( strcmpi(key,"list") == 0 ) {
  7559. return channel_display_list(sd,sub1);
  7560. } else if ( strcmpi(key,"setcolor") == 0 ) {
  7561. return channel_pccolor(sd, sub1, sub2);
  7562. } else if ( strcmpi(key,"join") == 0 ) {
  7563. return channel_pcjoin(sd, sub1, sub2);
  7564. }else if ( strcmpi(key,"leave") == 0 ) {
  7565. return channel_pcleave(sd, sub1);
  7566. } else if ( strcmpi(key,"bindto") == 0 ) {
  7567. return channel_pcbind(sd, sub1);
  7568. } else if ( strcmpi(key,"unbind") == 0 ) {
  7569. return channel_pcunbind(sd);
  7570. } else if ( strcmpi(key,"ban") == 0 ) {
  7571. return channel_pcban(sd,sub1,map_nick2sd(sub2),0);
  7572. } else if ( strcmpi(key,"banlist") == 0 ) {
  7573. return channel_pcban(sd,sub1,NULL,3);
  7574. } else if ( strcmpi(key,"unban") == 0 ) {
  7575. return channel_pcban(sd,sub1,map_nick2sd(sub2),1);
  7576. } else if ( strcmpi(key,"unbanall") == 0 ) {
  7577. return channel_pcban(sd,sub1,NULL,2);
  7578. } else if ( strcmpi(key,"setopt") == 0 ) {
  7579. return channel_pcsetopt(sd,sub1,sub2,sub3);
  7580. } else {
  7581. atcmd_channel_help(sd,command);
  7582. }
  7583. return 0;
  7584. }
  7585. ACMD_FUNC(fontcolor)
  7586. {
  7587. unsigned char k;
  7588. if( !message || !*message ) {
  7589. channel_display_list(sd,"colors");
  7590. return -1;
  7591. }
  7592. if( strcmpi(message,"Normal") == 0 ) {
  7593. sd->fontcolor = 0;
  7594. } else {
  7595. ARR_FIND(0,Channel_Config.colors_count,k,( strcmpi(message,Channel_Config.colors_name[k]) == 0 ));
  7596. if( k == Channel_Config.colors_count ) {
  7597. sprintf(atcmd_output, msg_txt(sd,1411), message);// Unknown color '%s'.
  7598. clif_displaymessage(fd, atcmd_output);
  7599. return -1;
  7600. }
  7601. sd->fontcolor = k;
  7602. }
  7603. sprintf(atcmd_output, msg_txt(sd,1454), message);// Color set to '%s'.
  7604. clif_displaymessage(fd, atcmd_output);
  7605. return 0;
  7606. }
  7607. ACMD_FUNC(langtype)
  7608. {
  7609. char langstr[8];
  7610. int i=0, test=0;
  7611. memset(langstr, '\0', sizeof(langstr));
  7612. if(sscanf(message, "%3s", langstr) >= 1){
  7613. int lang=-1;
  7614. lang = msg_langstr2langtype(langstr); //Switch langstr to associated langtype
  7615. if( msg_checklangtype(lang,false) == 1 ){ //Verify it's enabled and set it
  7616. char output[100];
  7617. pc_setaccountreg(sd, "#langtype", lang); //For login/char
  7618. sd->langtype = lang;
  7619. sprintf(output,msg_txt(sd,461),msg_langtype2langstr(lang)); // Language is now set to %s.
  7620. clif_displaymessage(fd,output);
  7621. return 0;
  7622. } else if (lang != -1) { //defined langage but failed check
  7623. clif_displaymessage(fd,msg_txt(sd,462)); // This langage is currently disabled.
  7624. return -1;
  7625. }
  7626. }
  7627. //wrong or no entry
  7628. clif_displaymessage(fd,msg_txt(sd,460)); // Please enter a valid language (usage: @langtype <language>).
  7629. clif_displaymessage(fd,msg_txt(sd,464)); // ---- Available languages:
  7630. while(test!=-1){ //out of range
  7631. test = msg_checklangtype(i,false);
  7632. if(test == 1)
  7633. clif_displaymessage(fd,msg_langtype2langstr(i));
  7634. i++;
  7635. }
  7636. return -1;
  7637. }
  7638. /**
  7639. * Fills the reference of available commands in atcommand DBMap
  7640. **/
  7641. #define ACMD_DEF(x) { #x, atcommand_ ## x, NULL, NULL }
  7642. #define ACMD_DEF2(x2, x) { x2, atcommand_ ## x, NULL, NULL }
  7643. void atcommand_basecommands(void) {
  7644. /**
  7645. * Command reference list, place the base of your commands here
  7646. **/
  7647. AtCommandInfo atcommand_base[] = {
  7648. ACMD_DEF2("warp", mapmove),
  7649. ACMD_DEF(where),
  7650. ACMD_DEF(jumpto),
  7651. ACMD_DEF(jump),
  7652. ACMD_DEF(who),
  7653. ACMD_DEF2("who2", who),
  7654. ACMD_DEF2("who3", who),
  7655. ACMD_DEF2("whomap", who),
  7656. ACMD_DEF2("whomap2", who),
  7657. ACMD_DEF2("whomap3", who),
  7658. ACMD_DEF(whogm),
  7659. ACMD_DEF(save),
  7660. ACMD_DEF(load),
  7661. ACMD_DEF(speed),
  7662. ACMD_DEF(storage),
  7663. ACMD_DEF(guildstorage),
  7664. ACMD_DEF(option),
  7665. ACMD_DEF(hide), // + /hide
  7666. ACMD_DEF(jobchange),
  7667. ACMD_DEF(kill),
  7668. ACMD_DEF(alive),
  7669. ACMD_DEF(kami),
  7670. ACMD_DEF2("kamib", kami),
  7671. ACMD_DEF2("kamic", kami),
  7672. ACMD_DEF2("lkami", kami),
  7673. ACMD_DEF(heal),
  7674. ACMD_DEF(item),
  7675. ACMD_DEF(item2),
  7676. ACMD_DEF(itemreset),
  7677. ACMD_DEF(clearstorage),
  7678. ACMD_DEF(cleargstorage),
  7679. ACMD_DEF(clearcart),
  7680. ACMD_DEF2("blvl", baselevelup),
  7681. ACMD_DEF2("jlvl", joblevelup),
  7682. ACMD_DEF(help),
  7683. ACMD_DEF(pvpoff),
  7684. ACMD_DEF(pvpon),
  7685. ACMD_DEF(gvgoff),
  7686. ACMD_DEF(gvgon),
  7687. ACMD_DEF(model),
  7688. ACMD_DEF(go),
  7689. ACMD_DEF(monster),
  7690. ACMD_DEF2("monstersmall", monster),
  7691. ACMD_DEF2("monsterbig", monster),
  7692. ACMD_DEF(killmonster),
  7693. ACMD_DEF2("killmonster2", killmonster),
  7694. ACMD_DEF(refine),
  7695. ACMD_DEF(produce),
  7696. ACMD_DEF(memo),
  7697. ACMD_DEF(gat),
  7698. ACMD_DEF(displaystatus),
  7699. ACMD_DEF2("stpoint", statuspoint),
  7700. ACMD_DEF2("skpoint", skillpoint),
  7701. ACMD_DEF(zeny),
  7702. ACMD_DEF2("str", param),
  7703. ACMD_DEF2("agi", param),
  7704. ACMD_DEF2("vit", param),
  7705. ACMD_DEF2("int", param),
  7706. ACMD_DEF2("dex", param),
  7707. ACMD_DEF2("luk", param),
  7708. ACMD_DEF2("glvl", guildlevelup),
  7709. ACMD_DEF(makeegg),
  7710. ACMD_DEF(hatch),
  7711. ACMD_DEF(petfriendly),
  7712. ACMD_DEF(pethungry),
  7713. ACMD_DEF(petrename),
  7714. ACMD_DEF(recall), // + /recall
  7715. ACMD_DEF(night),
  7716. ACMD_DEF(day),
  7717. ACMD_DEF(doom),
  7718. ACMD_DEF(doommap),
  7719. ACMD_DEF(raise),
  7720. ACMD_DEF(raisemap),
  7721. ACMD_DEF(kick), // + right click menu for GM "(name) force to quit"
  7722. ACMD_DEF(kickall),
  7723. ACMD_DEF(allskill),
  7724. ACMD_DEF(questskill),
  7725. ACMD_DEF(lostskill),
  7726. ACMD_DEF(spiritball),
  7727. ACMD_DEF(party),
  7728. ACMD_DEF(guild),
  7729. ACMD_DEF(breakguild),
  7730. ACMD_DEF(agitstart),
  7731. ACMD_DEF(agitend),
  7732. ACMD_DEF(mapexit),
  7733. ACMD_DEF(idsearch),
  7734. ACMD_DEF(broadcast), // + /b and /nb
  7735. ACMD_DEF(localbroadcast), // + /lb and /nlb
  7736. ACMD_DEF(recallall),
  7737. ACMD_DEF(reload),
  7738. ACMD_DEF2("reloaditemdb", reload),
  7739. ACMD_DEF2("reloadmobdb", reload),
  7740. ACMD_DEF2("reloadskilldb", reload),
  7741. ACMD_DEF2("reloadscript", reload),
  7742. ACMD_DEF2("reloadatcommand", reload),
  7743. ACMD_DEF2("reloadbattleconf", reload),
  7744. ACMD_DEF2("reloadstatusdb", reload),
  7745. ACMD_DEF2("reloadpcdb", reload),
  7746. ACMD_DEF2("reloadmotd", reload),
  7747. ACMD_DEF2("reloadquestdb", reload),
  7748. ACMD_DEF2("reloadmsgconf", reload),
  7749. ACMD_DEF2("reloadpacketdb", reload),
  7750. ACMD_DEF(mapinfo),
  7751. ACMD_DEF(dye),
  7752. ACMD_DEF2("hairstyle", hair_style),
  7753. ACMD_DEF2("haircolor", hair_color),
  7754. ACMD_DEF2("allstats", stat_all),
  7755. ACMD_DEF2("block", char_block),
  7756. ACMD_DEF2("ban", char_ban),
  7757. ACMD_DEF2("unblock", char_unblock),
  7758. ACMD_DEF2("unban", char_unban),
  7759. ACMD_DEF2("mount", mount_peco),
  7760. ACMD_DEF(guildspy),
  7761. ACMD_DEF(partyspy),
  7762. ACMD_DEF(repairall),
  7763. ACMD_DEF(guildrecall),
  7764. ACMD_DEF(partyrecall),
  7765. ACMD_DEF(nuke),
  7766. ACMD_DEF(shownpc),
  7767. ACMD_DEF(hidenpc),
  7768. ACMD_DEF(loadnpc),
  7769. ACMD_DEF(unloadnpc),
  7770. ACMD_DEF2("time", servertime),
  7771. ACMD_DEF(jail),
  7772. ACMD_DEF(unjail),
  7773. ACMD_DEF(jailfor),
  7774. ACMD_DEF(jailtime),
  7775. ACMD_DEF(disguise),
  7776. ACMD_DEF(undisguise),
  7777. ACMD_DEF(email),
  7778. ACMD_DEF(effect),
  7779. ACMD_DEF(follow),
  7780. ACMD_DEF(addwarp),
  7781. ACMD_DEF(skillon),
  7782. ACMD_DEF(skilloff),
  7783. ACMD_DEF(killer),
  7784. ACMD_DEF(npcmove),
  7785. ACMD_DEF(killable),
  7786. ACMD_DEF(dropall),
  7787. ACMD_DEF(storeall),
  7788. ACMD_DEF(skillid),
  7789. ACMD_DEF(useskill),
  7790. ACMD_DEF(displayskill),
  7791. ACMD_DEF(snow),
  7792. ACMD_DEF(sakura),
  7793. ACMD_DEF(clouds),
  7794. ACMD_DEF(clouds2),
  7795. ACMD_DEF(fog),
  7796. ACMD_DEF(fireworks),
  7797. ACMD_DEF(leaves),
  7798. ACMD_DEF(summon),
  7799. ACMD_DEF(adjgroup),
  7800. ACMD_DEF(trade),
  7801. ACMD_DEF(send),
  7802. ACMD_DEF(setbattleflag),
  7803. ACMD_DEF(unmute),
  7804. ACMD_DEF(clearweather),
  7805. ACMD_DEF(uptime),
  7806. ACMD_DEF(changesex),
  7807. ACMD_DEF(mute),
  7808. ACMD_DEF(refresh),
  7809. ACMD_DEF(refreshall),
  7810. ACMD_DEF(identify),
  7811. ACMD_DEF(gmotd),
  7812. ACMD_DEF(misceffect),
  7813. ACMD_DEF(mobsearch),
  7814. ACMD_DEF(cleanmap),
  7815. ACMD_DEF(cleanarea),
  7816. ACMD_DEF(npctalk),
  7817. ACMD_DEF(pettalk),
  7818. ACMD_DEF(users),
  7819. ACMD_DEF(reset),
  7820. ACMD_DEF(skilltree),
  7821. ACMD_DEF(marry),
  7822. ACMD_DEF(divorce),
  7823. ACMD_DEF(sound),
  7824. ACMD_DEF(undisguiseall),
  7825. ACMD_DEF(disguiseall),
  7826. ACMD_DEF(changelook),
  7827. ACMD_DEF(autoloot),
  7828. ACMD_DEF2("alootid", autolootitem),
  7829. ACMD_DEF(mobinfo),
  7830. ACMD_DEF(exp),
  7831. ACMD_DEF(version),
  7832. ACMD_DEF(mutearea),
  7833. ACMD_DEF(rates),
  7834. ACMD_DEF(iteminfo),
  7835. ACMD_DEF(whodrops),
  7836. ACMD_DEF(whereis),
  7837. ACMD_DEF(mapflag),
  7838. ACMD_DEF(me),
  7839. ACMD_DEF(monsterignore),
  7840. ACMD_DEF(fakename),
  7841. ACMD_DEF(size),
  7842. ACMD_DEF(showexp),
  7843. ACMD_DEF(showzeny),
  7844. ACMD_DEF(showdelay),
  7845. ACMD_DEF(autotrade),
  7846. ACMD_DEF(changegm),
  7847. ACMD_DEF(changeleader),
  7848. ACMD_DEF(partyoption),
  7849. ACMD_DEF(invite),
  7850. ACMD_DEF(duel),
  7851. ACMD_DEF(leave),
  7852. ACMD_DEF(accept),
  7853. ACMD_DEF(reject),
  7854. ACMD_DEF(clone),
  7855. ACMD_DEF2("slaveclone", clone),
  7856. ACMD_DEF2("evilclone", clone),
  7857. ACMD_DEF(tonpc),
  7858. ACMD_DEF(commands),
  7859. ACMD_DEF(noask),
  7860. ACMD_DEF(request),
  7861. ACMD_DEF(homlevel),
  7862. ACMD_DEF(homevolution),
  7863. ACMD_DEF(hommutate),
  7864. ACMD_DEF(makehomun),
  7865. ACMD_DEF(homfriendly),
  7866. ACMD_DEF(homhungry),
  7867. ACMD_DEF(homtalk),
  7868. ACMD_DEF(hominfo),
  7869. ACMD_DEF(homstats),
  7870. ACMD_DEF(homshuffle),
  7871. ACMD_DEF(showmobs),
  7872. ACMD_DEF(feelreset),
  7873. ACMD_DEF(auction),
  7874. ACMD_DEF(mail),
  7875. ACMD_DEF2("noks", ksprotection),
  7876. ACMD_DEF(allowks),
  7877. ACMD_DEF(cash),
  7878. ACMD_DEF2("points", cash),
  7879. ACMD_DEF(agitstart2),
  7880. ACMD_DEF(agitend2),
  7881. ACMD_DEF2("skreset", resetskill),
  7882. ACMD_DEF2("streset", resetstat),
  7883. ACMD_DEF2("storagelist", itemlist),
  7884. ACMD_DEF2("cartlist", itemlist),
  7885. ACMD_DEF2("itemlist", itemlist),
  7886. ACMD_DEF(stats),
  7887. ACMD_DEF(delitem),
  7888. ACMD_DEF(charcommands),
  7889. ACMD_DEF(font),
  7890. ACMD_DEF(accinfo),
  7891. ACMD_DEF(set),
  7892. ACMD_DEF(undisguiseguild),
  7893. ACMD_DEF(disguiseguild),
  7894. ACMD_DEF(sizeall),
  7895. ACMD_DEF(sizeguild),
  7896. ACMD_DEF(addperm),
  7897. ACMD_DEF2("rmvperm", addperm),
  7898. ACMD_DEF(unloadnpcfile),
  7899. ACMD_DEF(cart),
  7900. ACMD_DEF(mount2),
  7901. ACMD_DEF(join),
  7902. ACMD_DEF(channel),
  7903. ACMD_DEF(fontcolor),
  7904. ACMD_DEF(langtype),
  7905. };
  7906. AtCommandInfo* atcommand;
  7907. int i;
  7908. for( i = 0; i < ARRAYLENGTH(atcommand_base); i++ ) {
  7909. if(atcommand_exists(atcommand_base[i].command)) { // Should not happen if atcommand_base[] array is OK
  7910. ShowDebug("atcommand_basecommands: duplicate ACMD_DEF for '%s'.\n", atcommand_base[i].command);
  7911. continue;
  7912. }
  7913. CREATE(atcommand, AtCommandInfo, 1);
  7914. safestrncpy(atcommand->command, atcommand_base[i].command, sizeof(atcommand->command));
  7915. atcommand->func = atcommand_base[i].func;
  7916. strdb_put(atcommand_db, atcommand->command, atcommand);
  7917. }
  7918. return;
  7919. }
  7920. /*==========================================
  7921. * Command lookup functions
  7922. *------------------------------------------*/
  7923. bool atcommand_exists(const char* name)
  7924. {
  7925. return strdb_exists(atcommand_db, name);
  7926. }
  7927. static AtCommandInfo* get_atcommandinfo_byname(const char *name)
  7928. {
  7929. if (strdb_exists(atcommand_db, name))
  7930. return (AtCommandInfo*)strdb_get(atcommand_db, name);
  7931. return NULL;
  7932. }
  7933. static const char* atcommand_checkalias(const char *aliasname)
  7934. {
  7935. AliasInfo *alias_info = NULL;
  7936. if ((alias_info = (AliasInfo*)strdb_get(atcommand_alias_db, aliasname)) != NULL)
  7937. return alias_info->command->command;
  7938. return aliasname;
  7939. }
  7940. /// AtCommand suggestion
  7941. static void atcommand_get_suggestions(struct map_session_data* sd, const char *name, bool atcommand) {
  7942. DBIterator* atcommand_iter;
  7943. DBIterator* alias_iter;
  7944. AtCommandInfo* command_info = NULL;
  7945. AliasInfo* alias_info = NULL;
  7946. AtCommandType type = atcommand ? COMMAND_ATCOMMAND : COMMAND_CHARCOMMAND;
  7947. char* full_match[MAX_SUGGESTIONS];
  7948. char* suggestions[MAX_SUGGESTIONS];
  7949. char* match;
  7950. int prefix_count = 0, full_count = 0;
  7951. bool can_use;
  7952. if (!battle_config.atcommand_suggestions_enabled)
  7953. return;
  7954. atcommand_iter = db_iterator(atcommand_db);
  7955. alias_iter = db_iterator(atcommand_alias_db);
  7956. // Build the matches
  7957. for (command_info = dbi_first(atcommand_iter); dbi_exists(atcommand_iter); command_info = dbi_next(atcommand_iter)) {
  7958. match = strstr(command_info->command, name);
  7959. can_use = pc_can_use_command(sd, command_info->command, type);
  7960. if ( prefix_count < MAX_SUGGESTIONS && match == command_info->command && can_use ) {
  7961. suggestions[prefix_count] = command_info->command;
  7962. ++prefix_count;
  7963. }
  7964. if ( full_count < MAX_SUGGESTIONS && match != NULL && match != command_info->command && can_use ) {
  7965. full_match[full_count] = command_info->command;
  7966. ++full_count;
  7967. }
  7968. }
  7969. for (alias_info = dbi_first(alias_iter); dbi_exists(alias_iter); alias_info = dbi_next(alias_iter)) {
  7970. match = strstr(alias_info->alias, name);
  7971. can_use = pc_can_use_command(sd, alias_info->command->command, type);
  7972. if ( prefix_count < MAX_SUGGESTIONS && match == alias_info->alias && can_use) {
  7973. suggestions[prefix_count] = alias_info->alias;
  7974. ++prefix_count;
  7975. }
  7976. if ( full_count < MAX_SUGGESTIONS && match != NULL && match != alias_info->alias && can_use ) {
  7977. full_match[full_count] = alias_info->alias;
  7978. ++full_count;
  7979. }
  7980. }
  7981. if ((full_count+prefix_count) > 0) {
  7982. char buffer[512];
  7983. int i;
  7984. // Merge full match and prefix match results
  7985. if (prefix_count < MAX_SUGGESTIONS) {
  7986. memmove(&suggestions[prefix_count], full_match, sizeof(char*) * (MAX_SUGGESTIONS-prefix_count));
  7987. prefix_count = min(prefix_count+full_count, MAX_SUGGESTIONS);
  7988. }
  7989. // Build the suggestion string
  7990. strcpy(buffer, msg_txt(sd,205));
  7991. strcat(buffer,"\n");
  7992. for(i=0; i < prefix_count; ++i) {
  7993. strcat(buffer,suggestions[i]);
  7994. strcat(buffer," ");
  7995. }
  7996. clif_displaymessage(sd->fd, buffer);
  7997. }
  7998. dbi_destroy(atcommand_iter);
  7999. dbi_destroy(alias_iter);
  8000. }
  8001. /// Executes an at-command.
  8002. bool is_atcommand(const int fd, struct map_session_data* sd, const char* message, int type)
  8003. {
  8004. char charname[NAME_LENGTH], params[100];
  8005. char charname2[NAME_LENGTH], params2[100];
  8006. char command[100];
  8007. char output[CHAT_SIZE_MAX];
  8008. //Reconstructed message
  8009. char atcmd_msg[CHAT_SIZE_MAX];
  8010. TBL_PC * ssd = NULL; //sd for target
  8011. AtCommandInfo * info;
  8012. nullpo_retr(false, sd);
  8013. //Shouldn't happen
  8014. if ( !message || !*message )
  8015. return false;
  8016. //Block NOCHAT but do not display it as a normal message
  8017. if ( sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCOMMAND )
  8018. return true;
  8019. // skip 10/11-langtype's codepage indicator, if detected
  8020. if ( message[0] == '|' && strlen(message) >= 4 && (message[3] == atcommand_symbol || message[3] == charcommand_symbol) )
  8021. message += 3;
  8022. //Should display as a normal message
  8023. if ( *message != atcommand_symbol && *message != charcommand_symbol )
  8024. return false;
  8025. // type value 0 = server invoked: bypass restrictions
  8026. // 1 = player invoked
  8027. if ( type == 1) {
  8028. //Commands are disabled on maps flagged as 'nocommand'
  8029. if ( map[sd->bl.m].nocommand && pc_get_group_level(sd) < map[sd->bl.m].nocommand ) {
  8030. clif_displaymessage(fd, msg_txt(sd,143));
  8031. return false;
  8032. }
  8033. }
  8034. if (*message == charcommand_symbol) {
  8035. do {
  8036. int x, y, z;
  8037. //Checks to see if #command has a name or a name + parameters.
  8038. x = sscanf(message, "%99s \"%23[^\"]\" %99[^\n]", command, charname, params);
  8039. y = sscanf(message, "%99s %23s %99[^\n]", command, charname2, params2);
  8040. //z always has the value of the scan that was successful
  8041. z = ( x > 1 ) ? x : y;
  8042. //#command + name means the sufficient target was used and anything else after
  8043. //can be looked at by the actual command function since most scan to see if the
  8044. //right parameters are used.
  8045. if ( x > 2 ) {
  8046. sprintf(atcmd_msg, "%s %s", command, params);
  8047. break;
  8048. }
  8049. else if ( y > 2 ) {
  8050. sprintf(atcmd_msg, "%s %s", command, params2);
  8051. break;
  8052. }
  8053. //Regardless of what style the #command is used, if it's correct, it will always have
  8054. //this value if there is no parameter. Send it as just the #command
  8055. else if ( z == 2 ) {
  8056. sprintf(atcmd_msg, "%s", command);
  8057. break;
  8058. }
  8059. if( !pc_get_group_level(sd) ) {
  8060. if( x >= 1 || y >= 1 ) { /* we have command */
  8061. info = get_atcommandinfo_byname(atcommand_checkalias(command + 1));
  8062. 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 */
  8063. return false;
  8064. } else
  8065. return false;/* display as normal message */
  8066. }
  8067. sprintf(output, msg_txt(sd,1388), charcommand_symbol); // Charcommand failed (usage: %c<command> <char name> <parameters>).
  8068. clif_displaymessage(fd, output);
  8069. return true;
  8070. } while(0);
  8071. }
  8072. else if (*message == atcommand_symbol) {
  8073. //atcmd_msg is constructed above differently for charcommands
  8074. //it's copied from message if not a charcommand so it can
  8075. //pass through the rest of the code compatible with both symbols
  8076. sprintf(atcmd_msg, "%s", message);
  8077. }
  8078. //Clearing these to be used once more.
  8079. memset(command, '\0', sizeof(command));
  8080. memset(params, '\0', sizeof(params));
  8081. //check to see if any params exist within this command
  8082. if( sscanf(atcmd_msg, "%99s %99[^\n]", command, params) < 2 )
  8083. params[0] = '\0';
  8084. // @commands (script based)
  8085. if(type == 1 && atcmd_binding_count > 0) {
  8086. struct atcmd_binding_data * binding;
  8087. // Check if the command initiated is a character command
  8088. if (*message == charcommand_symbol &&
  8089. (ssd = map_nick2sd(charname)) == NULL && (ssd = map_nick2sd(charname2)) == NULL ) {
  8090. sprintf(output, msg_txt(sd,1389), command); // %s failed. Player not found.
  8091. clif_displaymessage(fd, output);
  8092. return true;
  8093. }
  8094. // Get atcommand binding
  8095. binding = get_atcommandbind_byname(command);
  8096. // Check if the binding isn't NULL and there is a NPC event, level of usage met, et cetera
  8097. if( binding != NULL && binding->npc_event[0] &&
  8098. ((*atcmd_msg == atcommand_symbol && pc_get_group_level(sd) >= binding->level) ||
  8099. (*atcmd_msg == charcommand_symbol && pc_get_group_level(sd) >= binding->level2)))
  8100. {
  8101. // Check if self or character invoking; if self == character invoked, then self invoke.
  8102. bool invokeFlag = ((*atcmd_msg == atcommand_symbol) ? 1 : 0);
  8103. npc_do_atcmd_event((invokeFlag ? sd : ssd), command, params, binding->npc_event);
  8104. return true;
  8105. }
  8106. }
  8107. //Grab the command information and check for the proper GM level required to use it or if the command exists
  8108. info = get_atcommandinfo_byname(atcommand_checkalias(command + 1));
  8109. if (info == NULL) {
  8110. if( pc_get_group_level(sd) ) { // TODO: remove or replace with proper permission
  8111. sprintf(output, msg_txt(sd,153), command); // "%s is Unknown Command."
  8112. clif_displaymessage(fd, output);
  8113. atcommand_get_suggestions(sd, command + 1, *message == atcommand_symbol);
  8114. return true;
  8115. } else
  8116. return false;
  8117. }
  8118. // type == 1 : player invoked
  8119. if (type == 1) {
  8120. if ((*command == atcommand_symbol && info->at_groups[sd->group_pos] == 0) ||
  8121. (*command == charcommand_symbol && info->char_groups[sd->group_pos] == 0) ) {
  8122. return false;
  8123. }
  8124. if( pc_isdead(sd) && pc_has_permission(sd,PC_PERM_DISABLE_CMD_DEAD) ) {
  8125. clif_displaymessage(fd, msg_txt(sd,1393)); // You can't use commands while dead
  8126. return true;
  8127. }
  8128. }
  8129. // Check if target is valid only if confirmed that player can use command.
  8130. if (*message == charcommand_symbol &&
  8131. (ssd = map_nick2sd(charname)) == NULL && (ssd = map_nick2sd(charname2)) == NULL ) {
  8132. sprintf(output, msg_txt(sd,1389), command); // %s failed. Player not found.
  8133. clif_displaymessage(fd, output);
  8134. return true;
  8135. }
  8136. //Attempt to use the command
  8137. if ( (info->func(fd, (*atcmd_msg == atcommand_symbol) ? sd : ssd, command, params) != 0) )
  8138. {
  8139. sprintf(output,msg_txt(sd,154), command); // %s failed.
  8140. clif_displaymessage(fd, output);
  8141. return true;
  8142. }
  8143. //Log only if successful.
  8144. if ( *atcmd_msg == atcommand_symbol )
  8145. log_atcommand(sd, atcmd_msg);
  8146. else if ( *atcmd_msg == charcommand_symbol )
  8147. log_atcommand(sd, message);
  8148. return true;
  8149. }
  8150. /*==========================================
  8151. *
  8152. *------------------------------------------*/
  8153. static void atcommand_config_read(const char* config_filename)
  8154. {
  8155. config_setting_t *aliases = NULL, *help = NULL;
  8156. const char *symbol = NULL;
  8157. int num_aliases = 0;
  8158. if (conf_read_file(&atcommand_config, config_filename))
  8159. return;
  8160. // Command symbols
  8161. if (config_lookup_string(&atcommand_config, "atcommand_symbol", &symbol)) {
  8162. if (ISPRINT(*symbol) && // no control characters
  8163. *symbol != '/' && // symbol of client commands
  8164. *symbol != '%' && // symbol of party chat
  8165. *symbol != '$' && // symbol of guild chat
  8166. *symbol != charcommand_symbol)
  8167. atcommand_symbol = *symbol;
  8168. }
  8169. if (config_lookup_string(&atcommand_config, "charcommand_symbol", &symbol)) {
  8170. if (ISPRINT(*symbol) && // no control characters
  8171. *symbol != '/' && // symbol of client commands
  8172. *symbol != '%' && // symbol of party chat
  8173. *symbol != '$' && // symbol of guild chat
  8174. *symbol != atcommand_symbol)
  8175. charcommand_symbol = *symbol;
  8176. }
  8177. // Command aliases
  8178. aliases = config_lookup(&atcommand_config, "aliases");
  8179. if (aliases != NULL) {
  8180. int i = 0;
  8181. int count = config_setting_length(aliases);
  8182. for (i = 0; i < count; ++i) {
  8183. config_setting_t *command;
  8184. const char *commandname = NULL;
  8185. int j = 0, alias_count = 0;
  8186. AtCommandInfo *commandinfo = NULL;
  8187. command = config_setting_get_elem(aliases, i);
  8188. if (config_setting_type(command) != CONFIG_TYPE_ARRAY)
  8189. continue;
  8190. commandname = config_setting_name(command);
  8191. if (!atcommand_exists(commandname)) {
  8192. ShowConfigWarning(command, "atcommand_config_read: can not set alias for non-existent command %s", commandname);
  8193. continue;
  8194. }
  8195. commandinfo = get_atcommandinfo_byname(commandname);
  8196. alias_count = config_setting_length(command);
  8197. for (j = 0; j < alias_count; ++j) {
  8198. const char *alias = config_setting_get_string_elem(command, j);
  8199. if (alias != NULL) {
  8200. AliasInfo *alias_info;
  8201. if (strdb_exists(atcommand_alias_db, alias)) {
  8202. ShowConfigWarning(command, "atcommand_config_read: alias %s already exists", alias);
  8203. continue;
  8204. }
  8205. CREATE(alias_info, AliasInfo, 1);
  8206. alias_info->command = commandinfo;
  8207. safestrncpy(alias_info->alias, alias, sizeof(alias_info->alias));
  8208. strdb_put(atcommand_alias_db, alias, alias_info);
  8209. ++num_aliases;
  8210. }
  8211. }
  8212. }
  8213. }
  8214. // Commands help
  8215. // We only check if all commands exist
  8216. help = config_lookup(&atcommand_config, "help");
  8217. if (help != NULL) {
  8218. int count = config_setting_length(help);
  8219. int i;
  8220. for (i = 0; i < count; ++i) {
  8221. config_setting_t *command;
  8222. const char *commandname;
  8223. command = config_setting_get_elem(help, i);
  8224. commandname = config_setting_name(command);
  8225. if (!atcommand_exists(commandname))
  8226. ShowConfigWarning(command, "atcommand_config_read: command %s does not exist", commandname);
  8227. }
  8228. }
  8229. ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' command aliases in '"CL_WHITE"%s"CL_RESET"'.\n", num_aliases, config_filename);
  8230. return;
  8231. }
  8232. void atcommand_db_load_groups(int* group_ids) {
  8233. DBIterator *iter = db_iterator(atcommand_db);
  8234. AtCommandInfo* cmd;
  8235. int i;
  8236. for (cmd = dbi_first(iter); dbi_exists(iter); cmd = dbi_next(iter)) {
  8237. cmd->at_groups = aMalloc( pc_group_max * sizeof(char) );
  8238. cmd->char_groups = aMalloc( pc_group_max * sizeof(char) );
  8239. for(i = 0; i < pc_group_max; i++) {
  8240. if( pc_group_can_use_command(group_ids[i], cmd->command, COMMAND_ATCOMMAND ) )
  8241. cmd->at_groups[i] = 1;
  8242. else
  8243. cmd->at_groups[i] = 0;
  8244. if( pc_group_can_use_command(group_ids[i], cmd->command, COMMAND_CHARCOMMAND ) )
  8245. cmd->char_groups[i] = 1;
  8246. else
  8247. cmd->char_groups[i] = 0;
  8248. }
  8249. }
  8250. dbi_destroy(iter);
  8251. return;
  8252. }
  8253. void atcommand_db_clear(void) {
  8254. if (atcommand_db != NULL) {
  8255. DBIterator *iter = db_iterator(atcommand_db);
  8256. AtCommandInfo* cmd;
  8257. for (cmd = dbi_first(iter); dbi_exists(iter); cmd = dbi_next(iter)) {
  8258. aFree(cmd->at_groups);
  8259. aFree(cmd->char_groups);
  8260. }
  8261. dbi_destroy(iter);
  8262. db_destroy(atcommand_db);
  8263. }
  8264. if (atcommand_alias_db != NULL)
  8265. db_destroy(atcommand_alias_db);
  8266. config_destroy(&atcommand_config);
  8267. }
  8268. void atcommand_doload(void) {
  8269. atcommand_db_clear();
  8270. atcommand_db = stridb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, ATCOMMAND_LENGTH);
  8271. atcommand_alias_db = stridb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, ATCOMMAND_LENGTH);
  8272. atcommand_basecommands(); //fills initial atcommand_db with known commands
  8273. atcommand_config_read(ATCOMMAND_CONF_FILENAME);
  8274. }
  8275. void do_init_atcommand(void) {
  8276. atcommand_doload();
  8277. }
  8278. void do_final_atcommand(void) {
  8279. atcommand_db_clear();
  8280. }