atcommand.c 283 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758
  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 "clif.h"
  19. #include "chrif.h"
  20. #include "duel.h"
  21. #include "intif.h"
  22. #include "itemdb.h"
  23. #include "log.h"
  24. #include "map.h"
  25. #include "pc.h"
  26. #include "pc_groups.h" // groupid2name
  27. #include "status.h"
  28. #include "skill.h"
  29. #include "mob.h"
  30. #include "npc.h"
  31. #include "pet.h"
  32. #include "homunculus.h"
  33. #include "mail.h"
  34. #include "mercenary.h"
  35. #include "elemental.h"
  36. #include "party.h"
  37. #include "guild.h"
  38. #include "script.h"
  39. #include "storage.h"
  40. #include "trade.h"
  41. #include "unit.h"
  42. #include "mapreg.h"
  43. #include "quest.h"
  44. #include <stdio.h>
  45. #include <stdlib.h>
  46. #include <string.h>
  47. #include <math.h>
  48. #define ATCOMMAND_LENGTH 50
  49. #define ACMD_FUNC(x) static int atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message)
  50. typedef struct AtCommandInfo AtCommandInfo;
  51. typedef struct AliasInfo AliasInfo;
  52. int atcmd_binding_count = 0;
  53. struct AtCommandInfo {
  54. char command[ATCOMMAND_LENGTH];
  55. AtCommandFunc func;
  56. char* at_groups;/* quick @commands "can-use" lookup */
  57. char* char_groups;/* quick @charcommands "can-use" lookup */
  58. };
  59. struct AliasInfo {
  60. AtCommandInfo *command;
  61. char alias[ATCOMMAND_LENGTH];
  62. };
  63. char atcommand_symbol = '@'; // first char of the commands
  64. char charcommand_symbol = '#';
  65. static DBMap* atcommand_db = NULL; //name -> AtCommandInfo
  66. static DBMap* atcommand_alias_db = NULL; //alias -> AtCommandInfo
  67. static config_t atcommand_config;
  68. static char atcmd_output[CHAT_SIZE_MAX];
  69. static char atcmd_player_name[NAME_LENGTH];
  70. static AtCommandInfo* get_atcommandinfo_byname(const char *name); // @help
  71. static const char* atcommand_checkalias(const char *aliasname); // @help
  72. static void atcommand_get_suggestions(struct map_session_data* sd, const char *name, bool atcommand); // @help
  73. // @commands (script-based)
  74. struct atcmd_binding_data* get_atcommandbind_byname(const char* name) {
  75. int i = 0;
  76. if( *name == atcommand_symbol || *name == charcommand_symbol )
  77. name++; // for backwards compatibility
  78. ARR_FIND( 0, atcmd_binding_count, i, strcmp(atcmd_binding[i]->command, name) == 0 );
  79. return ( i < atcmd_binding_count ) ? atcmd_binding[i] : NULL;
  80. }
  81. /**
  82. * retrieves the help string associated with a given command.
  83. *
  84. * @param name the name of the command to retrieve help information for
  85. * @return the string associated with the command, or NULL
  86. */
  87. static const char* atcommand_help_string(const char* command)
  88. {
  89. const char* str = NULL;
  90. config_setting_t* info;
  91. if( *command == atcommand_symbol || *command == charcommand_symbol )
  92. {// remove the prefix symbol for the raw name of the command
  93. command ++;
  94. }
  95. // convert alias to the real command name
  96. command = atcommand_checkalias(command);
  97. // attept to find the first default help command
  98. info = config_lookup(&atcommand_config, "help");
  99. if( info == NULL )
  100. {// failed to find the help property in the configuration file
  101. return NULL;
  102. }
  103. if( !config_setting_lookup_string( info, command, &str ) )
  104. {// failed to find the matching help string
  105. return NULL;
  106. }
  107. // push the result from the method
  108. return str;
  109. }
  110. /*==========================================
  111. * @send (used for testing packet sends from the client)
  112. *------------------------------------------*/
  113. ACMD_FUNC(send)
  114. {
  115. int len=0,off,end,type;
  116. long num;
  117. // read message type as hex number (without the 0x)
  118. if(!message || !*message ||
  119. !((sscanf(message, "len %x", &type)==1 && (len=1))
  120. || sscanf(message, "%x", &type)==1) )
  121. {
  122. int i;
  123. for (i = 900; i <= 903; ++i)
  124. clif_displaymessage(fd, msg_txt(i));
  125. return -1;
  126. }
  127. #define PARSE_ERROR(error,p) \
  128. {\
  129. clif_displaymessage(fd, (error));\
  130. sprintf(atcmd_output, ">%s", (p));\
  131. clif_displaymessage(fd, atcmd_output);\
  132. }
  133. //define PARSE_ERROR
  134. #define CHECK_EOS(p) \
  135. if(*(p) == 0){\
  136. clif_displaymessage(fd, "Unexpected end of string");\
  137. return -1;\
  138. }
  139. //define CHECK_EOS
  140. #define SKIP_VALUE(p) \
  141. {\
  142. while(*(p) && !ISSPACE(*(p))) ++(p); /* non-space */\
  143. while(*(p) && ISSPACE(*(p))) ++(p); /* space */\
  144. }
  145. //define SKIP_VALUE
  146. #define GET_VALUE(p,num) \
  147. {\
  148. if(sscanf((p), "x%lx", &(num)) < 1 && sscanf((p), "%ld ", &(num)) < 1){\
  149. PARSE_ERROR("Invalid number in:",(p));\
  150. return -1;\
  151. }\
  152. }
  153. //define GET_VALUE
  154. if (type > 0 && type < MAX_PACKET_DB) {
  155. if(len)
  156. {// show packet length
  157. sprintf(atcmd_output, msg_txt(904), type, packet_db[sd->packet_ver][type].len); // Packet 0x%x length: %d
  158. clif_displaymessage(fd, atcmd_output);
  159. return 0;
  160. }
  161. len=packet_db[sd->packet_ver][type].len;
  162. off=2;
  163. if(len == 0)
  164. {// unknown packet - ERROR
  165. sprintf(atcmd_output, msg_txt(905), type); // Unknown packet: 0x%x
  166. clif_displaymessage(fd, atcmd_output);
  167. return -1;
  168. } else if(len == -1)
  169. {// dynamic packet
  170. len=SHRT_MAX-4; // maximum length
  171. off=4;
  172. }
  173. WFIFOHEAD(fd, len);
  174. WFIFOW(fd,0)=TOW(type);
  175. // parse packet contents
  176. SKIP_VALUE(message);
  177. while(*message != 0 && off < len){
  178. if(ISDIGIT(*message) || *message == '-' || *message == '+')
  179. {// default (byte)
  180. GET_VALUE(message,num);
  181. WFIFOB(fd,off)=TOB(num);
  182. ++off;
  183. } else if(TOUPPER(*message) == 'B')
  184. {// byte
  185. ++message;
  186. GET_VALUE(message,num);
  187. WFIFOB(fd,off)=TOB(num);
  188. ++off;
  189. } else if(TOUPPER(*message) == 'W')
  190. {// word (2 bytes)
  191. ++message;
  192. GET_VALUE(message,num);
  193. WFIFOW(fd,off)=TOW(num);
  194. off+=2;
  195. } else if(TOUPPER(*message) == 'L')
  196. {// long word (4 bytes)
  197. ++message;
  198. GET_VALUE(message,num);
  199. WFIFOL(fd,off)=TOL(num);
  200. off+=4;
  201. } else if(TOUPPER(*message) == 'S')
  202. {// string - escapes are valid
  203. // get string length - num <= 0 means not fixed length (default)
  204. ++message;
  205. if(*message == '"'){
  206. num=0;
  207. } else {
  208. GET_VALUE(message,num);
  209. while(*message != '"')
  210. {// find start of string
  211. if(*message == 0 || ISSPACE(*message)){
  212. PARSE_ERROR(msg_txt(906),message); // Not a string:
  213. return -1;
  214. }
  215. ++message;
  216. }
  217. }
  218. // parse string
  219. ++message;
  220. CHECK_EOS(message);
  221. end=(num<=0? 0: min(off+((int)num),len));
  222. for(; *message != '"' && (off < end || end == 0); ++off){
  223. if(*message == '\\'){
  224. ++message;
  225. CHECK_EOS(message);
  226. switch(*message){
  227. case 'a': num=0x07; break; // Bell
  228. case 'b': num=0x08; break; // Backspace
  229. case 't': num=0x09; break; // Horizontal tab
  230. case 'n': num=0x0A; break; // Line feed
  231. case 'v': num=0x0B; break; // Vertical tab
  232. case 'f': num=0x0C; break; // Form feed
  233. case 'r': num=0x0D; break; // Carriage return
  234. case 'e': num=0x1B; break; // Escape
  235. default: num=*message; break;
  236. case 'x': // Hexadecimal
  237. {
  238. ++message;
  239. CHECK_EOS(message);
  240. if(!ISXDIGIT(*message)){
  241. PARSE_ERROR(msg_txt(907),message); // Not a hexadecimal digit:
  242. return -1;
  243. }
  244. num=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  245. if(ISXDIGIT(*message)){
  246. ++message;
  247. CHECK_EOS(message);
  248. num<<=8;
  249. num+=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  250. }
  251. WFIFOB(fd,off)=TOB(num);
  252. ++message;
  253. CHECK_EOS(message);
  254. continue;
  255. }
  256. case '0':
  257. case '1':
  258. case '2':
  259. case '3':
  260. case '4':
  261. case '5':
  262. case '6':
  263. case '7': // Octal
  264. {
  265. num=*message-'0'; // 1st octal digit
  266. ++message;
  267. CHECK_EOS(message);
  268. if(ISDIGIT(*message) && *message < '8'){
  269. num<<=3;
  270. num+=*message-'0'; // 2nd octal digit
  271. ++message;
  272. CHECK_EOS(message);
  273. if(ISDIGIT(*message) && *message < '8'){
  274. num<<=3;
  275. num+=*message-'0'; // 3rd octal digit
  276. ++message;
  277. CHECK_EOS(message);
  278. }
  279. }
  280. WFIFOB(fd,off)=TOB(num);
  281. continue;
  282. }
  283. }
  284. } else
  285. num=*message;
  286. WFIFOB(fd,off)=TOB(num);
  287. ++message;
  288. CHECK_EOS(message);
  289. }//for
  290. while(*message != '"')
  291. {// ignore extra characters
  292. ++message;
  293. CHECK_EOS(message);
  294. }
  295. // terminate the string
  296. if(off < end)
  297. {// fill the rest with 0's
  298. memset(WFIFOP(fd,off),0,end-off);
  299. off=end;
  300. }
  301. } else
  302. {// unknown
  303. PARSE_ERROR(msg_txt(908),message); // Unknown type of value in:
  304. return -1;
  305. }
  306. SKIP_VALUE(message);
  307. }
  308. if(packet_db[sd->packet_ver][type].len == -1)
  309. {// send dynamic packet
  310. WFIFOW(fd,2)=TOW(off);
  311. WFIFOSET(fd,off);
  312. } else
  313. {// send static packet
  314. if(off < len)
  315. memset(WFIFOP(fd,off),0,len-off);
  316. WFIFOSET(fd,len);
  317. }
  318. } else {
  319. clif_displaymessage(fd, msg_txt(259)); // Invalid packet
  320. return -1;
  321. }
  322. sprintf (atcmd_output, msg_txt(258), type, type); // Sent packet 0x%x (%d)
  323. clif_displaymessage(fd, atcmd_output);
  324. return 0;
  325. #undef PARSE_ERROR
  326. #undef CHECK_EOS
  327. #undef SKIP_VALUE
  328. #undef GET_VALUE
  329. }
  330. /*==========================================
  331. * @rura, @warp, @mapmove
  332. *------------------------------------------*/
  333. ACMD_FUNC(mapmove)
  334. {
  335. char map_name[MAP_NAME_LENGTH_EXT];
  336. unsigned short mapindex;
  337. short x = 0, y = 0;
  338. int16 m = -1;
  339. nullpo_retr(-1, sd);
  340. memset(map_name, '\0', sizeof(map_name));
  341. if (!message || !*message ||
  342. (sscanf(message, "%15s %hd %hd", map_name, &x, &y) < 3 &&
  343. sscanf(message, "%15[^,],%hd,%hd", map_name, &x, &y) < 1)) {
  344. clif_displaymessage(fd, msg_txt(909)); // Please enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).
  345. return -1;
  346. }
  347. mapindex = mapindex_name2id(map_name);
  348. if (mapindex)
  349. m = map_mapindex2mapid(mapindex);
  350. if (!mapindex) { // m < 0 means on different server! [Kevin]
  351. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  352. return -1;
  353. }
  354. if ((x || y) && map_getcell(m, x, y, CELL_CHKNOPASS))
  355. { //This is to prevent the pc_setpos call from printing an error.
  356. clif_displaymessage(fd, msg_txt(2));
  357. if (!map_search_freecell(NULL, m, &x, &y, 10, 10, 1))
  358. x = y = 0; //Invalid cell, use random spot.
  359. }
  360. if (map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  361. clif_displaymessage(fd, msg_txt(247));
  362. return -1;
  363. }
  364. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  365. clif_displaymessage(fd, msg_txt(248));
  366. return -1;
  367. }
  368. if (pc_setpos(sd, mapindex, x, y, CLR_TELEPORT) != 0) {
  369. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  370. return -1;
  371. }
  372. clif_displaymessage(fd, msg_txt(0)); // Warped.
  373. return 0;
  374. }
  375. /*==========================================
  376. * Displays where a character is. Corrected version by Silent. [Skotlex]
  377. *------------------------------------------*/
  378. ACMD_FUNC(where)
  379. {
  380. struct map_session_data* pl_sd;
  381. nullpo_retr(-1, sd);
  382. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  383. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  384. clif_displaymessage(fd, msg_txt(910)); // Please enter a player name (usage: @where <char name>).
  385. return -1;
  386. }
  387. pl_sd = map_nick2sd(atcmd_player_name);
  388. if (pl_sd == NULL ||
  389. strncmp(pl_sd->status.name, atcmd_player_name, NAME_LENGTH) != 0 ||
  390. (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))
  391. ) {
  392. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  393. return -1;
  394. }
  395. 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);
  396. clif_displaymessage(fd, atcmd_output);
  397. return 0;
  398. }
  399. /*==========================================
  400. *
  401. *------------------------------------------*/
  402. ACMD_FUNC(jumpto)
  403. {
  404. struct map_session_data *pl_sd = NULL;
  405. nullpo_retr(-1, sd);
  406. if (!message || !*message) {
  407. clif_displaymessage(fd, msg_txt(911)); // Please enter a player name (usage: @jumpto/@warpto/@goto <char name/ID>).
  408. return -1;
  409. }
  410. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  411. {
  412. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  413. return -1;
  414. }
  415. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  416. {
  417. clif_displaymessage(fd, msg_txt(247)); // You are not authorized to warp to this map.
  418. return -1;
  419. }
  420. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  421. {
  422. clif_displaymessage(fd, msg_txt(248)); // You are not authorized to warp from your current map.
  423. return -1;
  424. }
  425. if( pc_isdead(sd) )
  426. {
  427. clif_displaymessage(fd, msg_txt(664));
  428. return -1;
  429. }
  430. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  431. sprintf(atcmd_output, msg_txt(4), pl_sd->status.name); // Jumped to %s
  432. clif_displaymessage(fd, atcmd_output);
  433. return 0;
  434. }
  435. /*==========================================
  436. *
  437. *------------------------------------------*/
  438. ACMD_FUNC(jump)
  439. {
  440. short x = 0, y = 0;
  441. nullpo_retr(-1, sd);
  442. memset(atcmd_output, '\0', sizeof(atcmd_output));
  443. sscanf(message, "%hd %hd", &x, &y);
  444. if (map[sd->bl.m].flag.noteleport && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  445. clif_displaymessage(fd, msg_txt(248)); // You are not authorized to warp from your current map.
  446. return -1;
  447. }
  448. if( pc_isdead(sd) )
  449. {
  450. clif_displaymessage(fd, msg_txt(664));
  451. return -1;
  452. }
  453. if ((x || y) && map_getcell(sd->bl.m, x, y, CELL_CHKNOPASS))
  454. { //This is to prevent the pc_setpos call from printing an error.
  455. clif_displaymessage(fd, msg_txt(2));
  456. if (!map_search_freecell(NULL, sd->bl.m, &x, &y, 10, 10, 1))
  457. x = y = 0; //Invalid cell, use random spot.
  458. }
  459. pc_setpos(sd, sd->mapindex, x, y, CLR_TELEPORT);
  460. sprintf(atcmd_output, msg_txt(5), sd->bl.x, sd->bl.y); // Jumped to %d %d
  461. clif_displaymessage(fd, atcmd_output);
  462. return 0;
  463. }
  464. /*==========================================
  465. * Display list of online characters with
  466. * various info.
  467. *------------------------------------------*/
  468. ACMD_FUNC(who)
  469. {
  470. struct map_session_data *pl_sd = NULL;
  471. struct s_mapiterator *iter = NULL;
  472. char map_name[MAP_NAME_LENGTH_EXT] = "";
  473. char player_name[NAME_LENGTH] = "";
  474. int count = 0;
  475. int level = 0;
  476. StringBuf buf;
  477. /**
  478. * 1 = @who : Player name, [Title], [Party name], [Guild name]
  479. * 2 = @who2 : Player name, [Title], BLvl, JLvl, Job
  480. * 3 = @who3 : [CID/AID] Player name [Title], Map, X, Y
  481. */
  482. int display_type = 1;
  483. int map_id = -1;
  484. nullpo_retr(-1, sd);
  485. if (strstr(command, "map") != NULL) {
  486. if (sscanf(message, "%15s %23s", map_name, player_name) < 1 || (map_id = map_mapname2mapid(map_name)) < 0)
  487. map_id = sd->bl.m;
  488. } else {
  489. sscanf(message, "%23s", player_name);
  490. }
  491. if (strstr(command, "2") != NULL)
  492. display_type = 2;
  493. else if (strstr(command, "3") != NULL)
  494. display_type = 3;
  495. level = pc_get_group_level(sd);
  496. StringBuf_Init(&buf);
  497. iter = mapit_getallusers();
  498. for (pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter)) {
  499. 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
  500. if (stristr(pl_sd->status.name, player_name) == NULL // search with no case sensitive
  501. || (map_id >= 0 && pl_sd->bl.m != map_id))
  502. continue;
  503. switch (display_type) {
  504. case 2: {
  505. StringBuf_Printf(&buf, msg_txt(343), pl_sd->status.name); // "Name: %s "
  506. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  507. StringBuf_Printf(&buf, msg_txt(344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
  508. StringBuf_Printf(&buf, msg_txt(347), pl_sd->status.base_level, pl_sd->status.job_level,
  509. job_name(pl_sd->status.class_)); // "| Lv:%d/%d | Job: %s"
  510. break;
  511. }
  512. case 3: {
  513. if (pc_has_permission(sd, PC_PERM_WHO_DISPLAY_AID))
  514. StringBuf_Printf(&buf, msg_txt(912), pl_sd->status.char_id, pl_sd->status.account_id); // "(CID:%d/AID:%d) "
  515. StringBuf_Printf(&buf, msg_txt(343), pl_sd->status.name); // "Name: %s "
  516. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  517. StringBuf_Printf(&buf, msg_txt(344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
  518. StringBuf_Printf(&buf, msg_txt(348), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y); // "| Location: %s %d %d"
  519. break;
  520. }
  521. default: {
  522. struct party_data *p = party_search(pl_sd->status.party_id);
  523. struct guild *g = pl_sd->guild;
  524. StringBuf_Printf(&buf, msg_txt(343), pl_sd->status.name); // "Name: %s "
  525. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  526. StringBuf_Printf(&buf, msg_txt(344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
  527. if (p != NULL)
  528. StringBuf_Printf(&buf, msg_txt(345), p->party.name); // " | Party: '%s'"
  529. if (g != NULL)
  530. StringBuf_Printf(&buf, msg_txt(346), g->name); // " | Guild: '%s'"
  531. break;
  532. }
  533. }
  534. clif_displaymessage(fd, StringBuf_Value(&buf));
  535. StringBuf_Clear(&buf);
  536. count++;
  537. }
  538. }
  539. mapit_free(iter);
  540. if (map_id < 0) {
  541. if (count == 0)
  542. StringBuf_Printf(&buf, msg_txt(28)); // No player found.
  543. else if (count == 1)
  544. StringBuf_Printf(&buf, msg_txt(29)); // 1 player found.
  545. else
  546. StringBuf_Printf(&buf, msg_txt(30), count); // %d players found.
  547. } else {
  548. if (count == 0)
  549. StringBuf_Printf(&buf, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  550. else if (count == 1)
  551. StringBuf_Printf(&buf, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  552. else
  553. StringBuf_Printf(&buf, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  554. }
  555. clif_displaymessage(fd, StringBuf_Value(&buf));
  556. StringBuf_Destroy(&buf);
  557. return 0;
  558. }
  559. /*==========================================
  560. *
  561. *------------------------------------------*/
  562. ACMD_FUNC(whogm)
  563. {
  564. struct map_session_data* pl_sd;
  565. struct s_mapiterator* iter;
  566. int j, count;
  567. int pl_level, level;
  568. char match_text[CHAT_SIZE_MAX];
  569. char player_name[NAME_LENGTH];
  570. struct guild *g;
  571. struct party_data *p;
  572. nullpo_retr(-1, sd);
  573. memset(atcmd_output, '\0', sizeof(atcmd_output));
  574. memset(match_text, '\0', sizeof(match_text));
  575. memset(player_name, '\0', sizeof(player_name));
  576. if (sscanf(message, "%199[^\n]", match_text) < 1)
  577. strcpy(match_text, "");
  578. for (j = 0; match_text[j]; j++)
  579. match_text[j] = TOLOWER(match_text[j]);
  580. count = 0;
  581. level = pc_get_group_level(sd);
  582. iter = mapit_getallusers();
  583. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  584. {
  585. pl_level = pc_get_group_level(pl_sd);
  586. if (!pl_level)
  587. continue;
  588. if (match_text[0])
  589. {
  590. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  591. for (j = 0; player_name[j]; j++)
  592. player_name[j] = TOLOWER(player_name[j]);
  593. // search with no case sensitive
  594. if (strstr(player_name, match_text) == NULL)
  595. continue;
  596. }
  597. if (pl_level > level) {
  598. if (pl_sd->sc.option & OPTION_INVISIBLE)
  599. continue;
  600. sprintf(atcmd_output, msg_txt(913), pl_sd->status.name); // Name: %s (GM)
  601. clif_displaymessage(fd, atcmd_output);
  602. count++;
  603. continue;
  604. }
  605. sprintf(atcmd_output, msg_txt(914), // Name: %s (GM:%d) | Location: %s %d %d
  606. pl_sd->status.name, pl_level,
  607. mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  608. clif_displaymessage(fd, atcmd_output);
  609. sprintf(atcmd_output, msg_txt(915), // BLvl: %d | Job: %s (Lvl: %d)
  610. pl_sd->status.base_level,
  611. job_name(pl_sd->status.class_), pl_sd->status.job_level);
  612. clif_displaymessage(fd, atcmd_output);
  613. p = party_search(pl_sd->status.party_id);
  614. g = pl_sd->guild;
  615. sprintf(atcmd_output,msg_txt(916), // Party: '%s' | Guild: '%s'
  616. p?p->party.name:msg_txt(917), g?g->name:msg_txt(917)); // None.
  617. clif_displaymessage(fd, atcmd_output);
  618. count++;
  619. }
  620. mapit_free(iter);
  621. if (count == 0)
  622. clif_displaymessage(fd, msg_txt(150)); // No GM found.
  623. else if (count == 1)
  624. clif_displaymessage(fd, msg_txt(151)); // 1 GM found.
  625. else {
  626. sprintf(atcmd_output, msg_txt(152), count); // %d GMs found.
  627. clif_displaymessage(fd, atcmd_output);
  628. }
  629. return 0;
  630. }
  631. /*==========================================
  632. *
  633. *------------------------------------------*/
  634. ACMD_FUNC(save)
  635. {
  636. nullpo_retr(-1, sd);
  637. pc_setsavepoint(sd, sd->mapindex, sd->bl.x, sd->bl.y);
  638. if (sd->status.pet_id > 0 && sd->pd)
  639. intif_save_petdata(sd->status.account_id, &sd->pd->pet);
  640. chrif_save(sd,0);
  641. clif_displaymessage(fd, msg_txt(6)); // Your save point has been changed.
  642. return 0;
  643. }
  644. /*==========================================
  645. *
  646. *------------------------------------------*/
  647. ACMD_FUNC(load)
  648. {
  649. int16 m;
  650. nullpo_retr(-1, sd);
  651. m = map_mapindex2mapid(sd->status.save_point.map);
  652. if (m >= 0 && map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  653. clif_displaymessage(fd, msg_txt(249)); // You are not authorized to warp to your save map.
  654. return -1;
  655. }
  656. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  657. clif_displaymessage(fd, msg_txt(248)); // You are not authorized to warp from your current map.
  658. return -1;
  659. }
  660. pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, CLR_OUTSIGHT);
  661. clif_displaymessage(fd, msg_txt(7)); // Warping to save point..
  662. return 0;
  663. }
  664. /*==========================================
  665. *
  666. *------------------------------------------*/
  667. ACMD_FUNC(speed)
  668. {
  669. int speed;
  670. nullpo_retr(-1, sd);
  671. memset(atcmd_output, '\0', sizeof(atcmd_output));
  672. if (!message || !*message || sscanf(message, "%d", &speed) < 1) {
  673. sprintf(atcmd_output, msg_txt(918), MIN_WALK_SPEED, MAX_WALK_SPEED); // Please enter a speed value (usage: @speed <%d-%d>).
  674. clif_displaymessage(fd, atcmd_output);
  675. return -1;
  676. }
  677. sd->base_status.speed = cap_value(speed, MIN_WALK_SPEED, MAX_WALK_SPEED);
  678. status_calc_bl(&sd->bl, SCB_SPEED);
  679. clif_displaymessage(fd, msg_txt(8)); // Speed changed.
  680. return 0;
  681. }
  682. /*==========================================
  683. *
  684. *------------------------------------------*/
  685. ACMD_FUNC(storage)
  686. {
  687. nullpo_retr(-1, sd);
  688. if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading || sd->state.storage_flag)
  689. return -1;
  690. if (storage_storageopen(sd) == 1)
  691. { //Already open.
  692. clif_displaymessage(fd, msg_txt(250));
  693. return -1;
  694. }
  695. clif_displaymessage(fd, msg_txt(919)); // Storage opened.
  696. return 0;
  697. }
  698. /*==========================================
  699. *
  700. *------------------------------------------*/
  701. ACMD_FUNC(guildstorage)
  702. {
  703. nullpo_retr(-1, sd);
  704. if (!sd->status.guild_id) {
  705. clif_displaymessage(fd, msg_txt(252));
  706. return -1;
  707. }
  708. if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading)
  709. return -1;
  710. if (sd->state.storage_flag == 1) {
  711. clif_displaymessage(fd, msg_txt(250));
  712. return -1;
  713. }
  714. if (sd->state.storage_flag == 2) {
  715. clif_displaymessage(fd, msg_txt(251));
  716. return -1;
  717. }
  718. storage_guild_storageopen(sd);
  719. clif_displaymessage(fd, msg_txt(920)); // Guild storage opened.
  720. return 0;
  721. }
  722. /*==========================================
  723. *
  724. *------------------------------------------*/
  725. ACMD_FUNC(option)
  726. {
  727. int param1 = 0, param2 = 0, param3 = 0;
  728. nullpo_retr(-1, sd);
  729. if (!message || !*message || sscanf(message, "%d %d %d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0)
  730. {// failed to match the parameters so inform the user of the options
  731. const char* text;
  732. // attempt to find the setting information for this command
  733. text = atcommand_help_string( command );
  734. // notify the user of the requirement to enter an option
  735. clif_displaymessage(fd, msg_txt(921)); // Please enter at least one option.
  736. if( text )
  737. {// send the help text associated with this command
  738. clif_displaymessage( fd, text );
  739. }
  740. return -1;
  741. }
  742. sd->sc.opt1 = param1;
  743. sd->sc.opt2 = param2;
  744. pc_setoption(sd, param3);
  745. clif_displaymessage(fd, msg_txt(9)); // Options changed.
  746. return 0;
  747. }
  748. /*==========================================
  749. *
  750. *------------------------------------------*/
  751. ACMD_FUNC(hide)
  752. {
  753. nullpo_retr(-1, sd);
  754. if (sd->sc.option & OPTION_INVISIBLE) {
  755. sd->sc.option &= ~OPTION_INVISIBLE;
  756. if (sd->disguise)
  757. status_set_viewdata(&sd->bl, sd->disguise);
  758. else
  759. status_set_viewdata(&sd->bl, sd->status.class_);
  760. clif_displaymessage(fd, msg_txt(10)); // Invisible: Off
  761. // increment the number of pvp players on the map
  762. map[sd->bl.m].users_pvp++;
  763. if( map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.pvp_nocalcrank )
  764. {// register the player for ranking calculations
  765. sd->pvp_timer = add_timer( gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0 );
  766. }
  767. //bugreport:2266
  768. map_foreachinmovearea(clif_insight, &sd->bl, AREA_SIZE, sd->bl.x, sd->bl.y, BL_ALL, &sd->bl);
  769. } else {
  770. sd->sc.option |= OPTION_INVISIBLE;
  771. sd->vd.class_ = INVISIBLE_CLASS;
  772. clif_displaymessage(fd, msg_txt(11)); // Invisible: On
  773. // decrement the number of pvp players on the map
  774. map[sd->bl.m].users_pvp--;
  775. if( map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.pvp_nocalcrank && sd->pvp_timer != INVALID_TIMER )
  776. {// unregister the player for ranking
  777. delete_timer( sd->pvp_timer, pc_calc_pvprank_timer );
  778. sd->pvp_timer = INVALID_TIMER;
  779. }
  780. }
  781. clif_changeoption(&sd->bl);
  782. return 0;
  783. }
  784. /*==========================================
  785. * Changes a character's class
  786. *------------------------------------------*/
  787. ACMD_FUNC(jobchange)
  788. {
  789. int job = 0, upper = 0;
  790. const char* text;
  791. nullpo_retr(-1, sd);
  792. if (!message || !*message || sscanf(message, "%d %d", &job, &upper) < 1) {
  793. int i, found = 0;
  794. for (i = JOB_NOVICE; i < JOB_MAX; ++i) {
  795. if (strncmpi(message, job_name(i), 16) == 0) {
  796. job = i;
  797. upper = 0;
  798. found = 1;
  799. break;
  800. }
  801. }
  802. if (!found) {
  803. text = atcommand_help_string(command);
  804. if (text)
  805. clif_displaymessage(fd, text);
  806. return -1;
  807. }
  808. }
  809. if (job == JOB_KNIGHT2 || job == JOB_CRUSADER2 || job == JOB_WEDDING || job == JOB_XMAS || job == JOB_SUMMER || job == JOB_HANBOK
  810. || job == JOB_LORD_KNIGHT2 || job == JOB_PALADIN2 || job == JOB_BABY_KNIGHT2 || job == JOB_BABY_CRUSADER2 || job == JOB_STAR_GLADIATOR2
  811. || (job >= JOB_RUNE_KNIGHT2 && job <= JOB_MECHANIC_T2) || (job >= JOB_BABY_RUNE2 && job <= JOB_BABY_MECHANIC2)
  812. ) // Deny direct transformation into dummy jobs
  813. {clif_displaymessage(fd, msg_txt(923)); //"You can not change to this job by command."
  814. return 0;}
  815. if (pcdb_checkid(job))
  816. {
  817. if (pc_jobchange(sd, job, upper) == 0)
  818. clif_displaymessage(fd, msg_txt(12)); // Your job has been changed.
  819. else {
  820. clif_displaymessage(fd, msg_txt(155)); // You are unable to change your job.
  821. return -1;
  822. }
  823. } else {
  824. text = atcommand_help_string(command);
  825. if (text)
  826. clif_displaymessage(fd, text);
  827. return -1;
  828. }
  829. return 0;
  830. }
  831. /*==========================================
  832. *
  833. *------------------------------------------*/
  834. ACMD_FUNC(kill)
  835. {
  836. nullpo_retr(-1, sd);
  837. status_kill(&sd->bl);
  838. clif_displaymessage(sd->fd, msg_txt(13)); // A pity! You've died.
  839. if (fd != sd->fd)
  840. clif_displaymessage(fd, msg_txt(14)); // Character killed.
  841. return 0;
  842. }
  843. /*==========================================
  844. *
  845. *------------------------------------------*/
  846. ACMD_FUNC(alive)
  847. {
  848. nullpo_retr(-1, sd);
  849. if (!status_revive(&sd->bl, 100, 100))
  850. {
  851. clif_displaymessage(fd, msg_txt(667));
  852. return -1;
  853. }
  854. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  855. clif_displaymessage(fd, msg_txt(16)); // You've been revived! It's a miracle!
  856. return 0;
  857. }
  858. /*==========================================
  859. * +kamic [LuzZza]
  860. *------------------------------------------*/
  861. ACMD_FUNC(kami)
  862. {
  863. unsigned long color=0;
  864. nullpo_retr(-1, sd);
  865. memset(atcmd_output, '\0', sizeof(atcmd_output));
  866. if(*(command + 5) != 'c' && *(command + 5) != 'C') {
  867. if (!message || !*message) {
  868. clif_displaymessage(fd, msg_txt(980)); // Please enter a message (usage: @kami <message>).
  869. return -1;
  870. }
  871. sscanf(message, "%199[^\n]", atcmd_output);
  872. if (strstr(command, "l") != NULL)
  873. clif_broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, 0, ALL_SAMEMAP);
  874. else
  875. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, (*(command + 5) == 'b' || *(command + 5) == 'B') ? 0x10 : 0);
  876. } else {
  877. if(!message || !*message || (sscanf(message, "%lx %199[^\n]", &color, atcmd_output) < 2)) {
  878. clif_displaymessage(fd, msg_txt(981)); // Please enter color and message (usage: @kamic <color> <message>).
  879. return -1;
  880. }
  881. if(color > 0xFFFFFF) {
  882. clif_displaymessage(fd, msg_txt(982)); // Invalid color.
  883. return -1;
  884. }
  885. intif_broadcast2(atcmd_output, strlen(atcmd_output) + 1, color, 0x190, 12, 0, 0);
  886. }
  887. return 0;
  888. }
  889. /*==========================================
  890. *
  891. *------------------------------------------*/
  892. ACMD_FUNC(heal)
  893. {
  894. int hp = 0, sp = 0; // [Valaris] thanks to fov
  895. nullpo_retr(-1, sd);
  896. sscanf(message, "%d %d", &hp, &sp);
  897. // some overflow checks
  898. if( hp == INT_MIN ) hp++;
  899. if( sp == INT_MIN ) sp++;
  900. if ( hp == 0 && sp == 0 ) {
  901. if (!status_percent_heal(&sd->bl, 100, 100))
  902. clif_displaymessage(fd, msg_txt(157)); // HP and SP have already been recovered.
  903. else
  904. clif_displaymessage(fd, msg_txt(17)); // HP, SP recovered.
  905. return 0;
  906. }
  907. if ( hp > 0 && sp >= 0 ) {
  908. if(!status_heal(&sd->bl, hp, sp, 0))
  909. clif_displaymessage(fd, msg_txt(157)); // HP and SP are already with the good value.
  910. else
  911. clif_displaymessage(fd, msg_txt(17)); // HP, SP recovered.
  912. return 0;
  913. }
  914. if ( hp < 0 && sp <= 0 ) {
  915. status_damage(NULL, &sd->bl, -hp, -sp, 0, 0);
  916. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, 4, 0);
  917. clif_displaymessage(fd, msg_txt(156)); // HP or/and SP modified.
  918. return 0;
  919. }
  920. //Opposing signs.
  921. if ( hp ) {
  922. if (hp > 0)
  923. status_heal(&sd->bl, hp, 0, 0);
  924. else {
  925. status_damage(NULL, &sd->bl, -hp, 0, 0, 0);
  926. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, 4, 0);
  927. }
  928. }
  929. if ( sp ) {
  930. if (sp > 0)
  931. status_heal(&sd->bl, 0, sp, 0);
  932. else
  933. status_damage(NULL, &sd->bl, 0, -sp, 0, 0);
  934. }
  935. clif_displaymessage(fd, msg_txt(156)); // HP or/and SP modified.
  936. return 0;
  937. }
  938. /*==========================================
  939. * @item command (usage: @item <name/id_of_item> <quantity>) (modified by [Yor] for pet_egg)
  940. *------------------------------------------*/
  941. ACMD_FUNC(item)
  942. {
  943. char item_name[100];
  944. int number = 0, item_id, flag = 0;
  945. struct item item_tmp;
  946. struct item_data *item_data;
  947. int get_count, i;
  948. nullpo_retr(-1, sd);
  949. memset(item_name, '\0', sizeof(item_name));
  950. if (!message || !*message || (
  951. sscanf(message, "\"%99[^\"]\" %d", item_name, &number) < 1 &&
  952. sscanf(message, "%99s %d", item_name, &number) < 1
  953. )) {
  954. clif_displaymessage(fd, msg_txt(983)); // Please enter an item name or ID (usage: @item <item name/ID> <quantity>).
  955. return -1;
  956. }
  957. if (number <= 0)
  958. number = 1;
  959. if ((item_data = itemdb_searchname(item_name)) == NULL &&
  960. (item_data = itemdb_exists(atoi(item_name))) == NULL)
  961. {
  962. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  963. return -1;
  964. }
  965. item_id = item_data->nameid;
  966. get_count = number;
  967. //Check if it's stackable.
  968. if (!itemdb_isstackable2(item_data))
  969. get_count = 1;
  970. for (i = 0; i < number; i += get_count) {
  971. // if not pet egg
  972. if (!pet_create_egg(sd, item_id)) {
  973. memset(&item_tmp, 0, sizeof(item_tmp));
  974. item_tmp.nameid = item_id;
  975. item_tmp.identify = 1;
  976. if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
  977. clif_additem(sd, 0, 0, flag);
  978. }
  979. }
  980. if (flag == 0)
  981. clif_displaymessage(fd, msg_txt(18)); // Item created.
  982. return 0;
  983. }
  984. /*==========================================
  985. *
  986. *------------------------------------------*/
  987. ACMD_FUNC(item2)
  988. {
  989. struct item item_tmp;
  990. struct item_data *item_data;
  991. char item_name[100];
  992. int item_id, number = 0;
  993. int identify = 0, refine = 0, attr = 0;
  994. int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  995. nullpo_retr(-1, sd);
  996. memset(item_name, '\0', sizeof(item_name));
  997. if (!message || !*message || (
  998. sscanf(message, "\"%99[^\"]\" %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9 &&
  999. sscanf(message, "%99s %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9
  1000. )) {
  1001. clif_displaymessage(fd, msg_txt(984)); // Please enter all parameters (usage: @item2 <item name/ID> <quantity>
  1002. clif_displaymessage(fd, msg_txt(985)); // <identify_flag> <refine> <attribute> <card1> <card2> <card3> <card4>).
  1003. return -1;
  1004. }
  1005. if (number <= 0)
  1006. number = 1;
  1007. item_id = 0;
  1008. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  1009. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  1010. item_id = item_data->nameid;
  1011. if (item_id > 500) {
  1012. int flag = 0;
  1013. int loop, get_count, i;
  1014. loop = 1;
  1015. get_count = number;
  1016. if (item_data->type == IT_WEAPON || item_data->type == IT_ARMOR ||
  1017. item_data->type == IT_PETEGG || item_data->type == IT_PETARMOR) {
  1018. loop = number;
  1019. get_count = 1;
  1020. if (item_data->type == IT_PETEGG) {
  1021. identify = 1;
  1022. refine = 0;
  1023. }
  1024. if (item_data->type == IT_PETARMOR)
  1025. refine = 0;
  1026. if (refine > MAX_REFINE)
  1027. refine = MAX_REFINE;
  1028. } else {
  1029. identify = 1;
  1030. refine = attr = 0;
  1031. }
  1032. for (i = 0; i < loop; i++) {
  1033. memset(&item_tmp, 0, sizeof(item_tmp));
  1034. item_tmp.nameid = item_id;
  1035. item_tmp.identify = identify;
  1036. item_tmp.refine = refine;
  1037. item_tmp.attribute = attr;
  1038. item_tmp.card[0] = c1;
  1039. item_tmp.card[1] = c2;
  1040. item_tmp.card[2] = c3;
  1041. item_tmp.card[3] = c4;
  1042. if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
  1043. clif_additem(sd, 0, 0, flag);
  1044. }
  1045. if (flag == 0)
  1046. clif_displaymessage(fd, msg_txt(18)); // Item created.
  1047. } else {
  1048. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  1049. return -1;
  1050. }
  1051. return 0;
  1052. }
  1053. /*==========================================
  1054. *
  1055. *------------------------------------------*/
  1056. ACMD_FUNC(itemreset)
  1057. {
  1058. int i;
  1059. nullpo_retr(-1, sd);
  1060. for (i = 0; i < MAX_INVENTORY; i++) {
  1061. if (sd->status.inventory[i].amount && sd->status.inventory[i].equip == 0) {
  1062. pc_delitem(sd, i, sd->status.inventory[i].amount, 0, 0, LOG_TYPE_COMMAND);
  1063. }
  1064. }
  1065. clif_displaymessage(fd, msg_txt(20)); // All of your items have been removed.
  1066. return 0;
  1067. }
  1068. /*==========================================
  1069. * Atcommand @lvlup
  1070. *------------------------------------------*/
  1071. ACMD_FUNC(baselevelup)
  1072. {
  1073. int level=0, i=0, status_point=0;
  1074. nullpo_retr(-1, sd);
  1075. level = atoi(message);
  1076. if (!message || !*message || !level) {
  1077. clif_displaymessage(fd, msg_txt(986)); // Please enter a level adjustment (usage: @lvup/@blevel/@baselvlup <number of levels>).
  1078. return -1;
  1079. }
  1080. if (level > 0) {
  1081. if (sd->status.base_level >= pc_maxbaselv(sd)) { // check for max level by Valaris
  1082. clif_displaymessage(fd, msg_txt(47)); // Base level can't go any higher.
  1083. return -1;
  1084. } // End Addition
  1085. if ((unsigned int)level > pc_maxbaselv(sd) || (unsigned int)level > pc_maxbaselv(sd) - sd->status.base_level) // fix positiv overflow
  1086. level = pc_maxbaselv(sd) - sd->status.base_level;
  1087. for (i = 0; i < level; i++)
  1088. status_point += pc_gets_status_point(sd->status.base_level + i);
  1089. sd->status.status_point += status_point;
  1090. sd->status.base_level += (unsigned int)level;
  1091. status_percent_heal(&sd->bl, 100, 100);
  1092. clif_misceffect(&sd->bl, 0);
  1093. clif_displaymessage(fd, msg_txt(21)); // Base level raised.
  1094. } else {
  1095. if (sd->status.base_level == 1) {
  1096. clif_displaymessage(fd, msg_txt(158)); // Base level can't go any lower.
  1097. return -1;
  1098. }
  1099. level*=-1;
  1100. if ((unsigned int)level >= sd->status.base_level)
  1101. level = sd->status.base_level-1;
  1102. for (i = 0; i > -level; i--)
  1103. status_point += pc_gets_status_point(sd->status.base_level + i - 1);
  1104. if (sd->status.status_point < status_point)
  1105. pc_resetstate(sd);
  1106. if (sd->status.status_point < status_point)
  1107. sd->status.status_point = 0;
  1108. else
  1109. sd->status.status_point -= status_point;
  1110. sd->status.base_level -= (unsigned int)level;
  1111. clif_displaymessage(fd, msg_txt(22)); // Base level lowered.
  1112. }
  1113. sd->status.base_exp = 0;
  1114. clif_updatestatus(sd, SP_STATUSPOINT);
  1115. clif_updatestatus(sd, SP_BASELEVEL);
  1116. clif_updatestatus(sd, SP_BASEEXP);
  1117. clif_updatestatus(sd, SP_NEXTBASEEXP);
  1118. status_calc_pc(sd, 0);
  1119. pc_baselevelchanged(sd);
  1120. if(sd->status.party_id)
  1121. party_send_levelup(sd);
  1122. return 0;
  1123. }
  1124. /*==========================================
  1125. *
  1126. *------------------------------------------*/
  1127. ACMD_FUNC(joblevelup)
  1128. {
  1129. int level=0;
  1130. nullpo_retr(-1, sd);
  1131. level = atoi(message);
  1132. if (!message || !*message || !level) {
  1133. clif_displaymessage(fd, msg_txt(987)); // Please enter a level adjustment (usage: @joblvup/@jlevel/@joblvlup <number of levels>).
  1134. return -1;
  1135. }
  1136. if (level > 0) {
  1137. if (sd->status.job_level >= pc_maxjoblv(sd)) {
  1138. clif_displaymessage(fd, msg_txt(23)); // Job level can't go any higher.
  1139. return -1;
  1140. }
  1141. if ((unsigned int)level > pc_maxjoblv(sd) || (unsigned int)level > pc_maxjoblv(sd) - sd->status.job_level) // fix positiv overflow
  1142. level = pc_maxjoblv(sd) - sd->status.job_level;
  1143. sd->status.job_level += (unsigned int)level;
  1144. sd->status.skill_point += level;
  1145. clif_misceffect(&sd->bl, 1);
  1146. clif_displaymessage(fd, msg_txt(24)); // Job level raised.
  1147. } else {
  1148. if (sd->status.job_level == 1) {
  1149. clif_displaymessage(fd, msg_txt(159)); // Job level can't go any lower.
  1150. return -1;
  1151. }
  1152. level *=-1;
  1153. if ((unsigned int)level >= sd->status.job_level) // fix negativ overflow
  1154. level = sd->status.job_level-1;
  1155. sd->status.job_level -= (unsigned int)level;
  1156. if (sd->status.skill_point < level)
  1157. pc_resetskill(sd,0); //Reset skills since we need to substract more points.
  1158. if (sd->status.skill_point < level)
  1159. sd->status.skill_point = 0;
  1160. else
  1161. sd->status.skill_point -= level;
  1162. clif_displaymessage(fd, msg_txt(25)); // Job level lowered.
  1163. }
  1164. sd->status.job_exp = 0;
  1165. clif_updatestatus(sd, SP_JOBLEVEL);
  1166. clif_updatestatus(sd, SP_JOBEXP);
  1167. clif_updatestatus(sd, SP_NEXTJOBEXP);
  1168. clif_updatestatus(sd, SP_SKILLPOINT);
  1169. status_calc_pc(sd, 0);
  1170. return 0;
  1171. }
  1172. /*==========================================
  1173. * @help
  1174. *------------------------------------------*/
  1175. ACMD_FUNC(help)
  1176. {
  1177. config_setting_t *help;
  1178. const char *text = NULL;
  1179. const char *command_name = NULL;
  1180. char *default_command = "help";
  1181. nullpo_retr(-1, sd);
  1182. help = config_lookup(&atcommand_config, "help");
  1183. if (help == NULL) {
  1184. clif_displaymessage(fd, msg_txt(27)); // "Commands help is not available."
  1185. return -1;
  1186. }
  1187. if (!message || !*message) {
  1188. command_name = default_command; // If no command_name specified, display help for @help.
  1189. } else {
  1190. if (*message == atcommand_symbol || *message == charcommand_symbol)
  1191. ++message;
  1192. command_name = atcommand_checkalias(message);
  1193. }
  1194. if (!pc_can_use_command(sd, command_name, COMMAND_ATCOMMAND)) {
  1195. sprintf(atcmd_output, msg_txt(153), message); // "%s is Unknown Command"
  1196. clif_displaymessage(fd, atcmd_output);
  1197. atcommand_get_suggestions(sd, command_name, true);
  1198. return -1;
  1199. }
  1200. if (!config_setting_lookup_string(help, command_name, &text)) {
  1201. sprintf(atcmd_output, msg_txt(988), atcommand_symbol, command_name); // There is no help for %c%s.
  1202. clif_displaymessage(fd, atcmd_output);
  1203. atcommand_get_suggestions(sd, command_name, true);
  1204. return -1;
  1205. }
  1206. sprintf(atcmd_output, msg_txt(989), atcommand_symbol, command_name); // Help for command %c%s:
  1207. clif_displaymessage(fd, atcmd_output);
  1208. { // Display aliases
  1209. DBIterator* iter;
  1210. AtCommandInfo *command_info;
  1211. AliasInfo *alias_info = NULL;
  1212. StringBuf buf;
  1213. bool has_aliases = false;
  1214. StringBuf_Init(&buf);
  1215. StringBuf_AppendStr(&buf, msg_txt(990)); // Available aliases:
  1216. command_info = get_atcommandinfo_byname(command_name);
  1217. iter = db_iterator(atcommand_alias_db);
  1218. for (alias_info = dbi_first(iter); dbi_exists(iter); alias_info = dbi_next(iter)) {
  1219. if (alias_info->command == command_info) {
  1220. StringBuf_Printf(&buf, " %s", alias_info->alias);
  1221. has_aliases = true;
  1222. }
  1223. }
  1224. dbi_destroy(iter);
  1225. if (has_aliases)
  1226. clif_displaymessage(fd, StringBuf_Value(&buf));
  1227. StringBuf_Destroy(&buf);
  1228. }
  1229. // Display help contents
  1230. clif_displaymessage(fd, text);
  1231. return 0;
  1232. }
  1233. // helper function, used in foreach calls to stop auto-attack timers
  1234. // parameter: '0' - everyone, 'id' - only those attacking someone with that id
  1235. static int atcommand_stopattack(struct block_list *bl,va_list ap)
  1236. {
  1237. struct unit_data *ud = unit_bl2ud(bl);
  1238. int id = va_arg(ap, int);
  1239. if (ud && ud->attacktimer != INVALID_TIMER && (!id || id == ud->target))
  1240. {
  1241. unit_stop_attack(bl);
  1242. return 1;
  1243. }
  1244. return 0;
  1245. }
  1246. /*==========================================
  1247. *
  1248. *------------------------------------------*/
  1249. static int atcommand_pvpoff_sub(struct block_list *bl,va_list ap)
  1250. {
  1251. TBL_PC* sd = (TBL_PC*)bl;
  1252. clif_pvpset(sd, 0, 0, 2);
  1253. if (sd->pvp_timer != INVALID_TIMER) {
  1254. delete_timer(sd->pvp_timer, pc_calc_pvprank_timer);
  1255. sd->pvp_timer = INVALID_TIMER;
  1256. }
  1257. return 0;
  1258. }
  1259. ACMD_FUNC(pvpoff)
  1260. {
  1261. nullpo_retr(-1, sd);
  1262. if (!map[sd->bl.m].flag.pvp) {
  1263. clif_displaymessage(fd, msg_txt(160)); // PvP is already Off.
  1264. return -1;
  1265. }
  1266. map[sd->bl.m].flag.pvp = 0;
  1267. if (!battle_config.pk_mode)
  1268. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING);
  1269. map_foreachinmap(atcommand_pvpoff_sub,sd->bl.m, BL_PC);
  1270. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  1271. clif_displaymessage(fd, msg_txt(31)); // PvP: Off.
  1272. return 0;
  1273. }
  1274. /*==========================================
  1275. *
  1276. *------------------------------------------*/
  1277. static int atcommand_pvpon_sub(struct block_list *bl,va_list ap)
  1278. {
  1279. TBL_PC* sd = (TBL_PC*)bl;
  1280. if (sd->pvp_timer == INVALID_TIMER) {
  1281. sd->pvp_timer = add_timer(gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0);
  1282. sd->pvp_rank = 0;
  1283. sd->pvp_lastusers = 0;
  1284. sd->pvp_point = 5;
  1285. sd->pvp_won = 0;
  1286. sd->pvp_lost = 0;
  1287. }
  1288. return 0;
  1289. }
  1290. ACMD_FUNC(pvpon)
  1291. {
  1292. nullpo_retr(-1, sd);
  1293. if (map[sd->bl.m].flag.pvp) {
  1294. clif_displaymessage(fd, msg_txt(161)); // PvP is already On.
  1295. return -1;
  1296. }
  1297. map[sd->bl.m].flag.pvp = 1;
  1298. if (!battle_config.pk_mode)
  1299. {// display pvp circle and rank
  1300. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_FREEPVPZONE);
  1301. map_foreachinmap(atcommand_pvpon_sub,sd->bl.m, BL_PC);
  1302. }
  1303. clif_displaymessage(fd, msg_txt(32)); // PvP: On.
  1304. return 0;
  1305. }
  1306. /*==========================================
  1307. *
  1308. *------------------------------------------*/
  1309. ACMD_FUNC(gvgoff)
  1310. {
  1311. nullpo_retr(-1, sd);
  1312. if (!map[sd->bl.m].flag.gvg) {
  1313. clif_displaymessage(fd, msg_txt(162)); // GvG is already Off.
  1314. return -1;
  1315. }
  1316. map[sd->bl.m].flag.gvg = 0;
  1317. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING);
  1318. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  1319. clif_displaymessage(fd, msg_txt(33)); // GvG: Off.
  1320. return 0;
  1321. }
  1322. /*==========================================
  1323. *
  1324. *------------------------------------------*/
  1325. ACMD_FUNC(gvgon)
  1326. {
  1327. nullpo_retr(-1, sd);
  1328. if (map[sd->bl.m].flag.gvg) {
  1329. clif_displaymessage(fd, msg_txt(163)); // GvG is already On.
  1330. return -1;
  1331. }
  1332. map[sd->bl.m].flag.gvg = 1;
  1333. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_AGITZONE);
  1334. clif_displaymessage(fd, msg_txt(34)); // GvG: On.
  1335. return 0;
  1336. }
  1337. /*==========================================
  1338. *
  1339. *------------------------------------------*/
  1340. ACMD_FUNC(model)
  1341. {
  1342. int hair_style = 0, hair_color = 0, cloth_color = 0;
  1343. nullpo_retr(-1, sd);
  1344. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1345. if (!message || !*message || sscanf(message, "%d %d %d", &hair_style, &hair_color, &cloth_color) < 1) {
  1346. sprintf(atcmd_output, msg_txt(991), // Please enter at least one value (usage: @model <hair ID: %d-%d> <hair color: %d-%d> <clothes color: %d-%d>).
  1347. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  1348. clif_displaymessage(fd, atcmd_output);
  1349. return -1;
  1350. }
  1351. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  1352. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  1353. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1354. pc_changelook(sd, LOOK_HAIR, hair_style);
  1355. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1356. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1357. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  1358. } else {
  1359. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  1360. return -1;
  1361. }
  1362. return 0;
  1363. }
  1364. /*==========================================
  1365. * @dye && @ccolor
  1366. *------------------------------------------*/
  1367. ACMD_FUNC(dye)
  1368. {
  1369. int cloth_color = 0;
  1370. nullpo_retr(-1, sd);
  1371. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1372. if (!message || !*message || sscanf(message, "%d", &cloth_color) < 1) {
  1373. sprintf(atcmd_output, msg_txt(992), MIN_CLOTH_COLOR, MAX_CLOTH_COLOR); // Please enter a clothes color (usage: @dye/@ccolor <clothes color: %d-%d>).
  1374. clif_displaymessage(fd, atcmd_output);
  1375. return -1;
  1376. }
  1377. if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1378. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1379. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  1380. } else {
  1381. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  1382. return -1;
  1383. }
  1384. return 0;
  1385. }
  1386. /*==========================================
  1387. * @hairstyle && @hstyle
  1388. *------------------------------------------*/
  1389. ACMD_FUNC(hair_style)
  1390. {
  1391. int hair_style = 0;
  1392. nullpo_retr(-1, sd);
  1393. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1394. if (!message || !*message || sscanf(message, "%d", &hair_style) < 1) {
  1395. sprintf(atcmd_output, msg_txt(993), MIN_HAIR_STYLE, MAX_HAIR_STYLE); // Please enter a hair style (usage: @hairstyle/@hstyle <hair ID: %d-%d>).
  1396. clif_displaymessage(fd, atcmd_output);
  1397. return -1;
  1398. }
  1399. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
  1400. pc_changelook(sd, LOOK_HAIR, hair_style);
  1401. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  1402. } else {
  1403. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  1404. return -1;
  1405. }
  1406. return 0;
  1407. }
  1408. /*==========================================
  1409. * @haircolor && @hcolor
  1410. *------------------------------------------*/
  1411. ACMD_FUNC(hair_color)
  1412. {
  1413. int hair_color = 0;
  1414. nullpo_retr(-1, sd);
  1415. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1416. if (!message || !*message || sscanf(message, "%d", &hair_color) < 1) {
  1417. sprintf(atcmd_output, msg_txt(994), MIN_HAIR_COLOR, MAX_HAIR_COLOR); // Please enter a hair color (usage: @haircolor/@hcolor <hair color: %d-%d>).
  1418. clif_displaymessage(fd, atcmd_output);
  1419. return -1;
  1420. }
  1421. if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
  1422. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1423. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  1424. } else {
  1425. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  1426. return -1;
  1427. }
  1428. return 0;
  1429. }
  1430. /*==========================================
  1431. * @go [city_number or city_name] - Updated by Harbin
  1432. *------------------------------------------*/
  1433. ACMD_FUNC(go)
  1434. {
  1435. int i;
  1436. int town;
  1437. char map_name[MAP_NAME_LENGTH];
  1438. int16 m;
  1439. const struct {
  1440. char map[MAP_NAME_LENGTH];
  1441. int x, y;
  1442. } data[] = {
  1443. { MAP_PRONTERA, 156, 191 }, // 0=Prontera
  1444. { MAP_MORROC, 156, 93 }, // 1=Morroc
  1445. { MAP_GEFFEN, 119, 59 }, // 2=Geffen
  1446. { MAP_PAYON, 162, 233 }, // 3=Payon
  1447. { MAP_ALBERTA, 192, 147 }, // 4=Alberta
  1448. #ifdef RENEWAL
  1449. { MAP_IZLUDE, 128, 146 }, // 5=Izlude (Renewal)
  1450. #else
  1451. { MAP_IZLUDE, 128, 114 }, // 5=Izlude
  1452. #endif
  1453. { MAP_ALDEBARAN, 140, 131 }, // 6=Al de Baran
  1454. { MAP_LUTIE, 147, 134 }, // 7=Lutie
  1455. { MAP_COMODO, 209, 143 }, // 8=Comodo
  1456. { MAP_YUNO, 157, 51 }, // 9=Yuno
  1457. { MAP_AMATSU, 198, 84 }, // 10=Amatsu
  1458. { MAP_GONRYUN, 160, 120 }, // 11=Gonryun
  1459. { MAP_UMBALA, 89, 157 }, // 12=Umbala
  1460. { MAP_NIFLHEIM, 21, 153 }, // 13=Niflheim
  1461. { MAP_LOUYANG, 217, 40 }, // 14=Louyang
  1462. { MAP_NOVICE, 53, 111 }, // 15=Training Grounds
  1463. { MAP_JAIL, 23, 61 }, // 16=Prison
  1464. { MAP_JAWAII, 249, 127 }, // 17=Jawaii
  1465. { MAP_AYOTHAYA, 151, 117 }, // 18=Ayothaya
  1466. { MAP_EINBROCH, 64, 200 }, // 19=Einbroch
  1467. { MAP_LIGHTHALZEN, 158, 92 }, // 20=Lighthalzen
  1468. { MAP_EINBECH, 70, 95 }, // 21=Einbech
  1469. { MAP_HUGEL, 96, 145 }, // 22=Hugel
  1470. { MAP_RACHEL, 130, 110 }, // 23=Rachel
  1471. { MAP_VEINS, 216, 123 }, // 24=Veins
  1472. { MAP_MOSCOVIA, 223, 184 }, // 25=Moscovia
  1473. { MAP_MIDCAMP, 180, 240 }, // 26=Midgard Camp
  1474. { MAP_MANUK, 282, 138 }, // 27=Manuk
  1475. { MAP_SPLENDIDE, 197, 176 }, // 28=Splendide
  1476. { MAP_BRASILIS, 182, 239 }, // 29=Brasilis
  1477. { MAP_DICASTES, 198, 187 }, // 30=El Dicastes
  1478. { MAP_MORA, 44, 151 }, // 31=Mora
  1479. { MAP_DEWATA, 200, 180 }, // 32=Dewata
  1480. { MAP_MALANGDO, 140, 114 }, // 33=Malangdo Island
  1481. { MAP_MALAYA, 242, 211 }, // 34=Malaya Port
  1482. { MAP_ECLAGE, 110, 39 }, // 35=Eclage
  1483. };
  1484. nullpo_retr(-1, sd);
  1485. if( map[sd->bl.m].flag.nogo && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE) ) {
  1486. clif_displaymessage(sd->fd,msg_txt(995)); // You cannot use @go on this map.
  1487. return 0;
  1488. }
  1489. memset(map_name, '\0', sizeof(map_name));
  1490. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1491. // get the number
  1492. town = atoi(message);
  1493. if (!message || !*message || sscanf(message, "%11s", map_name) < 1 || town < 0 || town >= ARRAYLENGTH(data))
  1494. {// no value matched so send the list of locations
  1495. const char* text;
  1496. // attempt to find the text help string
  1497. text = atcommand_help_string( command );
  1498. clif_displaymessage(fd, msg_txt(38)); // Invalid location number, or name.
  1499. if( text )
  1500. {// send the text to the client
  1501. clif_displaymessage( fd, text );
  1502. }
  1503. return -1;
  1504. }
  1505. // get possible name of the city
  1506. map_name[MAP_NAME_LENGTH-1] = '\0';
  1507. for (i = 0; map_name[i]; i++)
  1508. map_name[i] = TOLOWER(map_name[i]);
  1509. // try to identify the map name
  1510. if (strncmp(map_name, "prontera", 3) == 0) {
  1511. town = 0;
  1512. } else if (strncmp(map_name, "morocc", 4) == 0 ||
  1513. strncmp(map_name, "morroc", 4) == 0) {
  1514. town = 1;
  1515. } else if (strncmp(map_name, "geffen", 3) == 0) {
  1516. town = 2;
  1517. } else if (strncmp(map_name, "payon", 3) == 0) {
  1518. town = 3;
  1519. } else if (strncmp(map_name, "alberta", 3) == 0) {
  1520. town = 4;
  1521. } else if (strncmp(map_name, "izlude", 3) == 0) {
  1522. town = 5;
  1523. } else if (strncmp(map_name, "aldebaran", 3) == 0) {
  1524. town = 6;
  1525. } else if (strncmp(map_name, "lutie", 3) == 0 ||
  1526. strcmp(map_name, "christmas") == 0 ||
  1527. strncmp(map_name, "xmas", 3) == 0 ||
  1528. strncmp(map_name, "x-mas", 3) == 0) {
  1529. town = 7;
  1530. } else if (strncmp(map_name, "comodo", 3) == 0) {
  1531. town = 8;
  1532. } else if (strncmp(map_name, "juno", 3) == 0 ||
  1533. strncmp(map_name, "yuno", 3) == 0) {
  1534. town = 9;
  1535. } else if (strncmp(map_name, "amatsu", 3) == 0) {
  1536. town = 10;
  1537. } else if (strncmp(map_name, "kunlun", 3) == 0 ||
  1538. strncmp(map_name, "gonryun", 3) == 0) {
  1539. town = 11;
  1540. } else if (strncmp(map_name, "umbala", 3) == 0) {
  1541. town = 12;
  1542. } else if (strncmp(map_name, "niflheim", 3) == 0) {
  1543. town = 13;
  1544. } else if (strncmp(map_name, "louyang", 3) == 0) {
  1545. town = 14;
  1546. } else if (strncmp(map_name, "new_1-1", 3) == 0 ||
  1547. strncmp(map_name, "startpoint", 3) == 0 ||
  1548. strncmp(map_name, "beginning", 3) == 0) {
  1549. town = 15;
  1550. } else if (strncmp(map_name, "sec_pri", 3) == 0 ||
  1551. strncmp(map_name, "prison", 3) == 0 ||
  1552. strncmp(map_name, "jail", 3) == 0) {
  1553. town = 16;
  1554. } else if (strncmp(map_name, "jawaii", 3) == 0) {
  1555. town = 17;
  1556. } else if (strncmp(map_name, "ayothaya", 3) == 0) {
  1557. town = 18;
  1558. } else if (strncmp(map_name, "einbroch", 5) == 0) {
  1559. town = 19;
  1560. } else if (strncmp(map_name, "lighthalzen", 3) == 0) {
  1561. town = 20;
  1562. } else if (strncmp(map_name, "einbech", 5) == 0) {
  1563. town = 21;
  1564. } else if (strncmp(map_name, "hugel", 3) == 0) {
  1565. town = 22;
  1566. } else if (strncmp(map_name, "rachel", 3) == 0) {
  1567. town = 23;
  1568. } else if (strncmp(map_name, "veins", 3) == 0) {
  1569. town = 24;
  1570. } else if (strncmp(map_name, "moscovia", 3) == 0) {
  1571. town = 25;
  1572. } else if (strncmp(map_name, "mid_camp", 3) == 0) {
  1573. town = 26;
  1574. } else if (strncmp(map_name, "manuk", 3) == 0) {
  1575. town = 27;
  1576. } else if (strncmp(map_name, "splendide", 3) == 0) {
  1577. town = 28;
  1578. } else if (strncmp(map_name, "brasilis", 3) == 0) {
  1579. town = 29;
  1580. } else if (strncmp(map_name, "dicastes01", 3) == 0) {
  1581. town = 30;
  1582. } else if (strcmp(map_name, "mora") == 0) {
  1583. town = 31;
  1584. } else if (strncmp(map_name, "dewata", 3) == 0) {
  1585. town = 32;
  1586. } else if (strncmp(map_name, "malangdo", 5) == 0) {
  1587. town = 33;
  1588. } else if (strncmp(map_name, "malaya", 5) == 0) {
  1589. town = 34;
  1590. } else if (strncmp(map_name, "eclage", 3) == 0) {
  1591. town = 35;
  1592. }
  1593. if (town >= 0 && town < ARRAYLENGTH(data))
  1594. {
  1595. m = map_mapname2mapid(data[town].map);
  1596. if (m >= 0 && map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  1597. clif_displaymessage(fd, msg_txt(247));
  1598. return -1;
  1599. }
  1600. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  1601. clif_displaymessage(fd, msg_txt(248));
  1602. return -1;
  1603. }
  1604. if (pc_setpos(sd, mapindex_name2id(data[town].map), data[town].x, data[town].y, CLR_TELEPORT) == 0) {
  1605. clif_displaymessage(fd, msg_txt(0)); // Warped.
  1606. } else {
  1607. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  1608. return -1;
  1609. }
  1610. } else { // if you arrive here, you have an error in town variable when reading of names
  1611. clif_displaymessage(fd, msg_txt(38)); // Invalid location number or name.
  1612. return -1;
  1613. }
  1614. return 0;
  1615. }
  1616. /*==========================================
  1617. *
  1618. *------------------------------------------*/
  1619. ACMD_FUNC(monster)
  1620. {
  1621. char name[NAME_LENGTH];
  1622. char monster[NAME_LENGTH];
  1623. char eventname[EVENT_NAME_LENGTH] = "";
  1624. int mob_id;
  1625. int number = 0;
  1626. int count;
  1627. int i, k, range;
  1628. short mx, my;
  1629. unsigned int size;
  1630. nullpo_retr(-1, sd);
  1631. memset(name, '\0', sizeof(name));
  1632. memset(monster, '\0', sizeof(monster));
  1633. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1634. if (!message || !*message) {
  1635. clif_displaymessage(fd, msg_txt(80)); // Give the display name or monster name/id please.
  1636. return -1;
  1637. }
  1638. if (sscanf(message, "\"%23[^\"]\" %23s %d", name, monster, &number) > 1 ||
  1639. sscanf(message, "%23s \"%23[^\"]\" %d", monster, name, &number) > 1) {
  1640. //All data can be left as it is.
  1641. } else if ((count=sscanf(message, "%23s %d %23s", monster, &number, name)) > 1) {
  1642. //Here, it is possible name was not given and we are using monster for it.
  1643. if (count < 3) //Blank mob's name.
  1644. name[0] = '\0';
  1645. } else if (sscanf(message, "%23s %23s %d", name, monster, &number) > 1) {
  1646. //All data can be left as it is.
  1647. } else if (sscanf(message, "%23s", monster) > 0) {
  1648. //As before, name may be already filled.
  1649. name[0] = '\0';
  1650. } else {
  1651. clif_displaymessage(fd, msg_txt(80)); // Give a display name and monster name/id please.
  1652. return -1;
  1653. }
  1654. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  1655. mob_id = mobdb_checkid(atoi(monster));
  1656. if (mob_id == 0) {
  1657. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  1658. return -1;
  1659. }
  1660. if (mob_id == MOBID_EMPERIUM) {
  1661. clif_displaymessage(fd, msg_txt(83)); // Monster 'Emperium' cannot be spawned.
  1662. return -1;
  1663. }
  1664. if (number <= 0)
  1665. number = 1;
  1666. if( !name[0] )
  1667. strcpy(name, "--ja--");
  1668. // 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
  1669. if (battle_config.atc_spawn_quantity_limit && number > battle_config.atc_spawn_quantity_limit)
  1670. number = battle_config.atc_spawn_quantity_limit;
  1671. if (strcmp(command+1, "monstersmall") == 0)
  1672. size = SZ_MEDIUM; // This is just gorgeous [mkbu95]
  1673. else if (strcmp(command+1, "monsterbig") == 0)
  1674. size = SZ_BIG;
  1675. else
  1676. size = SZ_SMALL;
  1677. if (battle_config.etc_log)
  1678. 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);
  1679. count = 0;
  1680. range = (int)sqrt((float)number) +2; // calculation of an odd number (+ 4 area around)
  1681. for (i = 0; i < number; i++) {
  1682. map_search_freecell(&sd->bl, 0, &mx, &my, range, range, 0);
  1683. k = mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, eventname, size, AI_NONE);
  1684. count += (k != 0) ? 1 : 0;
  1685. }
  1686. if (count != 0)
  1687. if (number == count)
  1688. clif_displaymessage(fd, msg_txt(39)); // All monster summoned!
  1689. else {
  1690. sprintf(atcmd_output, msg_txt(240), count); // %d monster(s) summoned!
  1691. clif_displaymessage(fd, atcmd_output);
  1692. }
  1693. else {
  1694. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  1695. return -1;
  1696. }
  1697. return 0;
  1698. }
  1699. /*==========================================
  1700. *
  1701. *------------------------------------------*/
  1702. static int atkillmonster_sub(struct block_list *bl, va_list ap)
  1703. {
  1704. struct mob_data *md;
  1705. int flag;
  1706. nullpo_ret(md=(struct mob_data *)bl);
  1707. flag = va_arg(ap, int);
  1708. if (md->guardian_data)
  1709. return 0; //Do not touch WoE mobs!
  1710. if (flag)
  1711. status_zap(bl,md->status.hp, 0);
  1712. else
  1713. status_kill(bl);
  1714. return 1;
  1715. }
  1716. ACMD_FUNC(killmonster)
  1717. {
  1718. int map_id, drop_flag;
  1719. char map_name[MAP_NAME_LENGTH_EXT];
  1720. nullpo_retr(-1, sd);
  1721. memset(map_name, '\0', sizeof(map_name));
  1722. if (!message || !*message || sscanf(message, "%15s", map_name) < 1)
  1723. map_id = sd->bl.m;
  1724. else {
  1725. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1726. map_id = sd->bl.m;
  1727. }
  1728. drop_flag = strcmp(command+1, "killmonster2");
  1729. map_foreachinmap(atkillmonster_sub, map_id, BL_MOB, -drop_flag);
  1730. clif_displaymessage(fd, msg_txt(165)); // All monsters killed!
  1731. return 0;
  1732. }
  1733. /*==========================================
  1734. *
  1735. *------------------------------------------*/
  1736. ACMD_FUNC(refine)
  1737. {
  1738. int i,j, position = 0, refine = 0, current_position, final_refine;
  1739. int count;
  1740. nullpo_retr(-1, sd);
  1741. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1742. if (!message || !*message || sscanf(message, "%d %d", &position, &refine) < 2) {
  1743. clif_displaymessage(fd, msg_txt(996)); // Please enter a position and an amount (usage: @refine <equip position> <+/- amount>).
  1744. sprintf(atcmd_output, msg_txt(997), EQP_HEAD_LOW); // %d: Lower Headgear
  1745. clif_displaymessage(fd, atcmd_output);
  1746. sprintf(atcmd_output, msg_txt(998), EQP_HAND_R); // %d: Right Hand
  1747. clif_displaymessage(fd, atcmd_output);
  1748. sprintf(atcmd_output, msg_txt(999), EQP_GARMENT); // %d: Garment
  1749. clif_displaymessage(fd, atcmd_output);
  1750. sprintf(atcmd_output, msg_txt(1000), EQP_ACC_L); // %d: Left Accessory
  1751. clif_displaymessage(fd, atcmd_output);
  1752. sprintf(atcmd_output, msg_txt(1001), EQP_ARMOR); // %d: Body Armor
  1753. clif_displaymessage(fd, atcmd_output);
  1754. sprintf(atcmd_output, msg_txt(1002), EQP_HAND_L); // %d: Left Hand
  1755. clif_displaymessage(fd, atcmd_output);
  1756. sprintf(atcmd_output, msg_txt(1003), EQP_SHOES); // %d: Shoes
  1757. clif_displaymessage(fd, atcmd_output);
  1758. sprintf(atcmd_output, msg_txt(1004), EQP_ACC_R); // %d: Right Accessory
  1759. clif_displaymessage(fd, atcmd_output);
  1760. sprintf(atcmd_output, msg_txt(1005), EQP_HEAD_TOP); // %d: Top Headgear
  1761. clif_displaymessage(fd, atcmd_output);
  1762. sprintf(atcmd_output, msg_txt(1006), EQP_HEAD_MID); // %d: Mid Headgear
  1763. clif_displaymessage(fd, atcmd_output);
  1764. return -1;
  1765. }
  1766. refine = cap_value(refine, -MAX_REFINE, MAX_REFINE);
  1767. count = 0;
  1768. for (j = 0; j < EQI_MAX-1; j++) {
  1769. if ((i = sd->equip_index[j]) < 0)
  1770. continue;
  1771. if(j == EQI_HAND_R && sd->equip_index[EQI_HAND_L] == i)
  1772. continue;
  1773. if(j == EQI_HEAD_MID && sd->equip_index[EQI_HEAD_LOW] == i)
  1774. continue;
  1775. if(j == EQI_HEAD_TOP && (sd->equip_index[EQI_HEAD_MID] == i || sd->equip_index[EQI_HEAD_LOW] == i))
  1776. continue;
  1777. if(position && !(sd->status.inventory[i].equip & position))
  1778. continue;
  1779. final_refine = cap_value(sd->status.inventory[i].refine + refine, 0, MAX_REFINE);
  1780. if (sd->status.inventory[i].refine != final_refine) {
  1781. sd->status.inventory[i].refine = final_refine;
  1782. current_position = sd->status.inventory[i].equip;
  1783. pc_unequipitem(sd, i, 3);
  1784. clif_refine(fd, 0, i, sd->status.inventory[i].refine);
  1785. clif_delitem(sd, i, 1, 3);
  1786. clif_additem(sd, i, 1, 0);
  1787. pc_equipitem(sd, i, current_position);
  1788. clif_misceffect(&sd->bl, 3);
  1789. count++;
  1790. }
  1791. }
  1792. if (count == 0)
  1793. clif_displaymessage(fd, msg_txt(166)); // No item has been refined.
  1794. else if (count == 1)
  1795. clif_displaymessage(fd, msg_txt(167)); // 1 item has been refined.
  1796. else {
  1797. sprintf(atcmd_output, msg_txt(168), count); // %d items have been refined.
  1798. clif_displaymessage(fd, atcmd_output);
  1799. }
  1800. return 0;
  1801. }
  1802. /*==========================================
  1803. *
  1804. *------------------------------------------*/
  1805. ACMD_FUNC(produce)
  1806. {
  1807. char item_name[100];
  1808. int item_id, attribute = 0, star = 0;
  1809. struct item_data *item_data;
  1810. struct item tmp_item;
  1811. nullpo_retr(-1, sd);
  1812. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1813. memset(item_name, '\0', sizeof(item_name));
  1814. if (!message || !*message || (
  1815. sscanf(message, "\"%99[^\"]\" %d %d", item_name, &attribute, &star) < 1 &&
  1816. sscanf(message, "%99s %d %d", item_name, &attribute, &star) < 1
  1817. )) {
  1818. clif_displaymessage(fd, msg_txt(1007)); // Please enter at least one item name/ID (usage: @produce <equip name/ID> <element> <# of very's>).
  1819. return -1;
  1820. }
  1821. if ( (item_data = itemdb_searchname(item_name)) == NULL &&
  1822. (item_data = itemdb_exists(atoi(item_name))) == NULL ) {
  1823. clif_displaymessage(fd, msg_txt(170)); //This item is not an equipment.
  1824. return -1;
  1825. }
  1826. item_id = item_data->nameid;
  1827. if (itemdb_isequip2(item_data)) {
  1828. int flag = 0;
  1829. if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
  1830. attribute = ATTRIBUTE_NORMAL;
  1831. if (star < MIN_STAR || star > MAX_STAR)
  1832. star = 0;
  1833. memset(&tmp_item, 0, sizeof tmp_item);
  1834. tmp_item.nameid = item_id;
  1835. tmp_item.amount = 1;
  1836. tmp_item.identify = 1;
  1837. tmp_item.card[0] = CARD0_FORGE;
  1838. tmp_item.card[1] = item_data->type==IT_WEAPON?
  1839. ((star*5) << 8) + attribute:0;
  1840. tmp_item.card[2] = GetWord(sd->status.char_id, 0);
  1841. tmp_item.card[3] = GetWord(sd->status.char_id, 1);
  1842. clif_produceeffect(sd, 0, item_id);
  1843. clif_misceffect(&sd->bl, 3);
  1844. if ((flag = pc_additem(sd, &tmp_item, 1, LOG_TYPE_COMMAND)))
  1845. clif_additem(sd, 0, 0, flag);
  1846. } else {
  1847. sprintf(atcmd_output, msg_txt(169), item_id, item_data->name); // The item (%d: '%s') is not equipable.
  1848. clif_displaymessage(fd, atcmd_output);
  1849. return -1;
  1850. }
  1851. return 0;
  1852. }
  1853. /*==========================================
  1854. *
  1855. *------------------------------------------*/
  1856. ACMD_FUNC(memo)
  1857. {
  1858. int position = 0;
  1859. nullpo_retr(-1, sd);
  1860. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1861. if( !message || !*message || sscanf(message, "%d", &position) < 1 )
  1862. {
  1863. int i;
  1864. clif_displaymessage(sd->fd, msg_txt(668));
  1865. for( i = 0; i < MAX_MEMOPOINTS; i++ )
  1866. {
  1867. if( sd->status.memo_point[i].map )
  1868. 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);
  1869. else
  1870. sprintf(atcmd_output, msg_txt(171), i); // %d - void
  1871. clif_displaymessage(sd->fd, atcmd_output);
  1872. }
  1873. return 0;
  1874. }
  1875. if( position < 0 || position >= MAX_MEMOPOINTS )
  1876. {
  1877. sprintf(atcmd_output, msg_txt(1008), 0, MAX_MEMOPOINTS-1); // Please enter a valid position (usage: @memo <memo_position:%d-%d>).
  1878. clif_displaymessage(fd, atcmd_output);
  1879. return -1;
  1880. }
  1881. pc_memo(sd, position);
  1882. return 0;
  1883. }
  1884. /*==========================================
  1885. *
  1886. *------------------------------------------*/
  1887. ACMD_FUNC(gat)
  1888. {
  1889. int y;
  1890. nullpo_retr(-1, sd);
  1891. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1892. for (y = 2; y >= -2; y--) {
  1893. sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
  1894. map[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y,
  1895. map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE),
  1896. map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE),
  1897. map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE),
  1898. map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE),
  1899. map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE));
  1900. clif_displaymessage(fd, atcmd_output);
  1901. }
  1902. return 0;
  1903. }
  1904. /*==========================================
  1905. *
  1906. *------------------------------------------*/
  1907. ACMD_FUNC(displaystatus)
  1908. {
  1909. int i, type, flag, tick, val1 = 0, val2 = 0, val3 = 0;
  1910. nullpo_retr(-1, sd);
  1911. if (!message || !*message || (i = sscanf(message, "%d %d %d %d %d %d", &type, &flag, &tick, &val1, &val2, &val3)) < 1) {
  1912. clif_displaymessage(fd, msg_txt(1009)); // Please enter a status type/flag (usage: @displaystatus <status type> <flag> <tick> {<val1> {<val2> {<val3>}}}).
  1913. return -1;
  1914. }
  1915. if (i < 2) flag = 1;
  1916. if (i < 3) tick = 0;
  1917. clif_status_change(&sd->bl, type, flag, tick, val1, val2, val3);
  1918. return 0;
  1919. }
  1920. /*==========================================
  1921. * @stpoint (Rewritten by [Yor])
  1922. *------------------------------------------*/
  1923. ACMD_FUNC(statuspoint)
  1924. {
  1925. int point;
  1926. unsigned int new_status_point;
  1927. if (!message || !*message || (point = atoi(message)) == 0) {
  1928. clif_displaymessage(fd, msg_txt(1010)); // Please enter a number (usage: @stpoint <number of points>).
  1929. return -1;
  1930. }
  1931. if(point < 0)
  1932. {
  1933. if(sd->status.status_point < (unsigned int)(-point))
  1934. {
  1935. new_status_point = 0;
  1936. }
  1937. else
  1938. {
  1939. new_status_point = sd->status.status_point + point;
  1940. }
  1941. }
  1942. else if(UINT_MAX - sd->status.status_point < (unsigned int)point)
  1943. {
  1944. new_status_point = UINT_MAX;
  1945. }
  1946. else
  1947. {
  1948. new_status_point = sd->status.status_point + point;
  1949. }
  1950. if (new_status_point != sd->status.status_point) {
  1951. sd->status.status_point = new_status_point;
  1952. clif_updatestatus(sd, SP_STATUSPOINT);
  1953. clif_displaymessage(fd, msg_txt(174)); // Number of status points changed.
  1954. } else {
  1955. if (point < 0)
  1956. clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
  1957. else
  1958. clif_displaymessage(fd, msg_txt(149)); // Unable to increase the number/value.
  1959. return -1;
  1960. }
  1961. return 0;
  1962. }
  1963. /*==========================================
  1964. * @skpoint (Rewritten by [Yor])
  1965. *------------------------------------------*/
  1966. ACMD_FUNC(skillpoint)
  1967. {
  1968. int point;
  1969. unsigned int new_skill_point;
  1970. nullpo_retr(-1, sd);
  1971. if (!message || !*message || (point = atoi(message)) == 0) {
  1972. clif_displaymessage(fd, msg_txt(1011)); // Please enter a number (usage: @skpoint <number of points>).
  1973. return -1;
  1974. }
  1975. if(point < 0)
  1976. {
  1977. if(sd->status.skill_point < (unsigned int)(-point))
  1978. {
  1979. new_skill_point = 0;
  1980. }
  1981. else
  1982. {
  1983. new_skill_point = sd->status.skill_point + point;
  1984. }
  1985. }
  1986. else if(UINT_MAX - sd->status.skill_point < (unsigned int)point)
  1987. {
  1988. new_skill_point = UINT_MAX;
  1989. }
  1990. else
  1991. {
  1992. new_skill_point = sd->status.skill_point + point;
  1993. }
  1994. if (new_skill_point != sd->status.skill_point) {
  1995. sd->status.skill_point = new_skill_point;
  1996. clif_updatestatus(sd, SP_SKILLPOINT);
  1997. clif_displaymessage(fd, msg_txt(175)); // Number of skill points changed.
  1998. } else {
  1999. if (point < 0)
  2000. clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
  2001. else
  2002. clif_displaymessage(fd, msg_txt(149)); // Unable to increase the number/value.
  2003. return -1;
  2004. }
  2005. return 0;
  2006. }
  2007. /*==========================================
  2008. * @zeny
  2009. *------------------------------------------*/
  2010. ACMD_FUNC(zeny)
  2011. {
  2012. int zeny=0, ret=-1;
  2013. nullpo_retr(-1, sd);
  2014. if (!message || !*message || (zeny = atoi(message)) == 0) {
  2015. clif_displaymessage(fd, msg_txt(1012)); // Please enter an amount (usage: @zeny <amount>).
  2016. return -1;
  2017. }
  2018. if(zeny > 0){
  2019. if((ret=pc_getzeny(sd,zeny,LOG_TYPE_COMMAND,NULL)) == 1)
  2020. clif_displaymessage(fd, msg_txt(149)); // Unable to increase the number/value.
  2021. }
  2022. else {
  2023. if( sd->status.zeny < -zeny ) zeny = -sd->status.zeny;
  2024. if((ret=pc_payzeny(sd,-zeny,LOG_TYPE_COMMAND,NULL)) == 1)
  2025. clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
  2026. }
  2027. if(!ret) clif_displaymessage(fd, msg_txt(176)); //ret=0 mean cmd success
  2028. return 0;
  2029. }
  2030. /*==========================================
  2031. *
  2032. *------------------------------------------*/
  2033. ACMD_FUNC(param)
  2034. {
  2035. int i, value = 0, new_value, max;
  2036. const char* param[] = { "str", "agi", "vit", "int", "dex", "luk" };
  2037. short* status[6];
  2038. //we don't use direct initialization because it isn't part of the c standard.
  2039. nullpo_retr(-1, sd);
  2040. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2041. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  2042. clif_displaymessage(fd, msg_txt(1013)); // Please enter a valid value (usage: @str/@agi/@vit/@int/@dex/@luk <+/-adjustment>).
  2043. return -1;
  2044. }
  2045. ARR_FIND( 0, ARRAYLENGTH(param), i, strcmpi(command+1, param[i]) == 0 );
  2046. if( i == ARRAYLENGTH(param) || i > MAX_STATUS_TYPE) { // normally impossible...
  2047. clif_displaymessage(fd, msg_txt(1013)); // Please enter a valid value (usage: @str/@agi/@vit/@int/@dex/@luk <+/-adjustment>).
  2048. return -1;
  2049. }
  2050. status[0] = &sd->status.str;
  2051. status[1] = &sd->status.agi;
  2052. status[2] = &sd->status.vit;
  2053. status[3] = &sd->status.int_;
  2054. status[4] = &sd->status.dex;
  2055. status[5] = &sd->status.luk;
  2056. if( battle_config.atcommand_max_stat_bypass )
  2057. max = SHRT_MAX;
  2058. else
  2059. max = pc_maxparameter(sd);
  2060. if(value < 0 && *status[i] <= -value) {
  2061. new_value = 1;
  2062. } else if(max - *status[i] < value) {
  2063. new_value = max;
  2064. } else {
  2065. new_value = *status[i] + value;
  2066. }
  2067. if (new_value != *status[i]) {
  2068. *status[i] = new_value;
  2069. clif_updatestatus(sd, SP_STR + i);
  2070. clif_updatestatus(sd, SP_USTR + i);
  2071. status_calc_pc(sd, 0);
  2072. clif_displaymessage(fd, msg_txt(42)); // Stat changed.
  2073. } else {
  2074. if (value < 0)
  2075. clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
  2076. else
  2077. clif_displaymessage(fd, msg_txt(149)); // Unable to increase the number/value.
  2078. return -1;
  2079. }
  2080. return 0;
  2081. }
  2082. /*==========================================
  2083. * Stat all by fritz (rewritten by [Yor])
  2084. *------------------------------------------*/
  2085. ACMD_FUNC(stat_all)
  2086. {
  2087. int index, count, value, max, new_value;
  2088. short* status[6];
  2089. //we don't use direct initialization because it isn't part of the c standard.
  2090. nullpo_retr(-1, sd);
  2091. status[0] = &sd->status.str;
  2092. status[1] = &sd->status.agi;
  2093. status[2] = &sd->status.vit;
  2094. status[3] = &sd->status.int_;
  2095. status[4] = &sd->status.dex;
  2096. status[5] = &sd->status.luk;
  2097. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  2098. value = pc_maxparameter(sd);
  2099. max = pc_maxparameter(sd);
  2100. } else {
  2101. if( battle_config.atcommand_max_stat_bypass )
  2102. max = SHRT_MAX;
  2103. else
  2104. max = pc_maxparameter(sd);
  2105. }
  2106. count = 0;
  2107. for (index = 0; index < ARRAYLENGTH(status); index++) {
  2108. if (value > 0 && *status[index] > max - value)
  2109. new_value = max;
  2110. else if (value < 0 && *status[index] <= -value)
  2111. new_value = 1;
  2112. else
  2113. new_value = *status[index] +value;
  2114. if (new_value != (int)*status[index]) {
  2115. *status[index] = new_value;
  2116. clif_updatestatus(sd, SP_STR + index);
  2117. clif_updatestatus(sd, SP_USTR + index);
  2118. count++;
  2119. }
  2120. }
  2121. if (count > 0) { // if at least 1 stat modified
  2122. status_calc_pc(sd, 0);
  2123. clif_displaymessage(fd, msg_txt(84)); // All stats changed!
  2124. } else {
  2125. if (value < 0)
  2126. clif_displaymessage(fd, msg_txt(177)); // You cannot decrease that stat anymore.
  2127. else
  2128. clif_displaymessage(fd, msg_txt(178)); // You cannot increase that stat anymore.
  2129. return -1;
  2130. }
  2131. return 0;
  2132. }
  2133. /*==========================================
  2134. *
  2135. *------------------------------------------*/
  2136. ACMD_FUNC(guildlevelup)
  2137. {
  2138. int level = 0;
  2139. short added_level;
  2140. struct guild *guild_info;
  2141. nullpo_retr(-1, sd);
  2142. if (!message || !*message || sscanf(message, "%d", &level) < 1 || level == 0) {
  2143. clif_displaymessage(fd, msg_txt(1014)); // Please enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).
  2144. return -1;
  2145. }
  2146. if (sd->status.guild_id <= 0 || (guild_info = sd->guild) == NULL) {
  2147. clif_displaymessage(fd, msg_txt(43)); // You're not in a guild.
  2148. return -1;
  2149. }
  2150. //if (strcmp(sd->status.name, guild_info->master) != 0) {
  2151. // clif_displaymessage(fd, msg_txt(44)); // You're not the master of your guild.
  2152. // return -1;
  2153. //}
  2154. added_level = (short)level;
  2155. if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild_lv))) // fix positiv overflow
  2156. added_level = (short)MAX_GUILDLEVEL - guild_info->guild_lv;
  2157. else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild_lv))) // fix negativ overflow
  2158. added_level = 1 - guild_info->guild_lv;
  2159. if (added_level != 0) {
  2160. intif_guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, sizeof(added_level));
  2161. clif_displaymessage(fd, msg_txt(179)); // Guild level changed.
  2162. } else {
  2163. clif_displaymessage(fd, msg_txt(45)); // Guild level change failed.
  2164. return -1;
  2165. }
  2166. return 0;
  2167. }
  2168. /*==========================================
  2169. *
  2170. *------------------------------------------*/
  2171. ACMD_FUNC(makeegg)
  2172. {
  2173. struct item_data *item_data;
  2174. int id, pet_id;
  2175. nullpo_retr(-1, sd);
  2176. if (!message || !*message) {
  2177. clif_displaymessage(fd, msg_txt(1015)); // Please enter a monster/egg name/ID (usage: @makeegg <pet>).
  2178. return -1;
  2179. }
  2180. if ((item_data = itemdb_searchname(message)) != NULL) // for egg name
  2181. id = item_data->nameid;
  2182. else
  2183. if ((id = mobdb_searchname(message)) != 0) // for monster name
  2184. ;
  2185. else
  2186. id = atoi(message);
  2187. pet_id = search_petDB_index(id, PET_CLASS);
  2188. if (pet_id < 0)
  2189. pet_id = search_petDB_index(id, PET_EGG);
  2190. if (pet_id >= 0) {
  2191. sd->catch_target_class = pet_db[pet_id].class_;
  2192. intif_create_pet(
  2193. sd->status.account_id, sd->status.char_id,
  2194. (short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv,
  2195. (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
  2196. 100, 0, 1, pet_db[pet_id].jname);
  2197. } else {
  2198. clif_displaymessage(fd, msg_txt(180)); // The monster/egg name/id doesn't exist.
  2199. return -1;
  2200. }
  2201. return 0;
  2202. }
  2203. /*==========================================
  2204. *
  2205. *------------------------------------------*/
  2206. ACMD_FUNC(hatch)
  2207. {
  2208. nullpo_retr(-1, sd);
  2209. if (sd->status.pet_id <= 0)
  2210. clif_sendegg(sd);
  2211. else {
  2212. clif_displaymessage(fd, msg_txt(181)); // You already have a pet.
  2213. return -1;
  2214. }
  2215. return 0;
  2216. }
  2217. /*==========================================
  2218. *
  2219. *------------------------------------------*/
  2220. ACMD_FUNC(petfriendly)
  2221. {
  2222. int friendly;
  2223. struct pet_data *pd;
  2224. nullpo_retr(-1, sd);
  2225. if (!message || !*message || (friendly = atoi(message)) < 0) {
  2226. clif_displaymessage(fd, msg_txt(1016)); // Please enter a valid value (usage: @petfriendly <0-1000>).
  2227. return -1;
  2228. }
  2229. pd = sd->pd;
  2230. if (!pd) {
  2231. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  2232. return -1;
  2233. }
  2234. if (friendly < 0 || friendly > 1000)
  2235. {
  2236. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2237. return -1;
  2238. }
  2239. if (friendly == pd->pet.intimate) {
  2240. clif_displaymessage(fd, msg_txt(183)); // Pet intimacy is already at maximum.
  2241. return -1;
  2242. }
  2243. pet_set_intimate(pd, friendly);
  2244. clif_send_petstatus(sd);
  2245. clif_displaymessage(fd, msg_txt(182)); // Pet intimacy changed.
  2246. return 0;
  2247. }
  2248. /*==========================================
  2249. *
  2250. *------------------------------------------*/
  2251. ACMD_FUNC(pethungry)
  2252. {
  2253. int hungry;
  2254. struct pet_data *pd;
  2255. nullpo_retr(-1, sd);
  2256. if (!message || !*message || (hungry = atoi(message)) < 0) {
  2257. clif_displaymessage(fd, msg_txt(1017)); // Please enter a valid number (usage: @pethungry <0-100>).
  2258. return -1;
  2259. }
  2260. pd = sd->pd;
  2261. if (!sd->status.pet_id || !pd) {
  2262. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  2263. return -1;
  2264. }
  2265. if (hungry < 0 || hungry > 100) {
  2266. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2267. return -1;
  2268. }
  2269. if (hungry == pd->pet.hungry) {
  2270. clif_displaymessage(fd, msg_txt(186)); // Pet hunger is already at maximum.
  2271. return -1;
  2272. }
  2273. pd->pet.hungry = hungry;
  2274. clif_send_petstatus(sd);
  2275. clif_displaymessage(fd, msg_txt(185)); // Pet hunger changed.
  2276. return 0;
  2277. }
  2278. /*==========================================
  2279. *
  2280. *------------------------------------------*/
  2281. ACMD_FUNC(petrename)
  2282. {
  2283. struct pet_data *pd;
  2284. nullpo_retr(-1, sd);
  2285. if (!sd->status.pet_id || !sd->pd) {
  2286. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  2287. return -1;
  2288. }
  2289. pd = sd->pd;
  2290. if (!pd->pet.rename_flag) {
  2291. clif_displaymessage(fd, msg_txt(188)); // You can already rename your pet.
  2292. return -1;
  2293. }
  2294. pd->pet.rename_flag = 0;
  2295. intif_save_petdata(sd->status.account_id, &pd->pet);
  2296. clif_send_petstatus(sd);
  2297. clif_displaymessage(fd, msg_txt(187)); // You can now rename your pet.
  2298. return 0;
  2299. }
  2300. /*==========================================
  2301. *
  2302. *------------------------------------------*/
  2303. ACMD_FUNC(recall) {
  2304. struct map_session_data *pl_sd = NULL;
  2305. nullpo_retr(-1, sd);
  2306. if (!message || !*message) {
  2307. clif_displaymessage(fd, msg_txt(1018)); // Please enter a player name (usage: @recall <char name/ID>).
  2308. return -1;
  2309. }
  2310. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  2311. {
  2312. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  2313. return -1;
  2314. }
  2315. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  2316. {
  2317. clif_displaymessage(fd, msg_txt(81)); // Your GM level doesn't authorize you to preform this action on the specified player.
  2318. return -1;
  2319. }
  2320. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2321. clif_displaymessage(fd, msg_txt(1019)); // You are not authorized to warp someone to this map.
  2322. return -1;
  2323. }
  2324. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2325. clif_displaymessage(fd, msg_txt(1020)); // You are not authorized to warp this player from their map.
  2326. return -1;
  2327. }
  2328. if (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y) {
  2329. return -1;
  2330. }
  2331. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  2332. sprintf(atcmd_output, msg_txt(46), pl_sd->status.name); // %s recalled!
  2333. clif_displaymessage(fd, atcmd_output);
  2334. return 0;
  2335. }
  2336. /*==========================================
  2337. * charblock command (usage: charblock <player_name>)
  2338. * This command do a definitiv ban on a player
  2339. *------------------------------------------*/
  2340. ACMD_FUNC(char_block)
  2341. {
  2342. nullpo_retr(-1, sd);
  2343. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2344. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2345. clif_displaymessage(fd, msg_txt(1021)); // Please enter a player name (usage: @charblock/@block <char name>).
  2346. return -1;
  2347. }
  2348. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block
  2349. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  2350. return 0;
  2351. }
  2352. /*==========================================
  2353. * charban command (usage: charban <time> <player_name>)
  2354. * This command do a limited ban on a player
  2355. * Time is done as follows:
  2356. * Adjustment value (-1, 1, +1, etc...)
  2357. * Modified element:
  2358. * a or y: year
  2359. * m: month
  2360. * j or d: day
  2361. * h: hour
  2362. * mn: minute
  2363. * s: second
  2364. * <example> @ban +1m-2mn1s-6y test_player
  2365. * this example adds 1 month and 1 second, and substracts 2 minutes and 6 years at the same time.
  2366. *------------------------------------------*/
  2367. ACMD_FUNC(char_ban)
  2368. {
  2369. char * modif_p;
  2370. int year, month, day, hour, minute, second, value;
  2371. time_t timestamp;
  2372. struct tm *tmtime;
  2373. nullpo_retr(-1, sd);
  2374. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2375. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2376. if (!message || !*message || sscanf(message, "%255s %23[^\n]", atcmd_output, atcmd_player_name) < 2) {
  2377. clif_displaymessage(fd, msg_txt(1022)); // Please enter ban time and a player name (usage: @charban/@ban/@banish/@charbanish <time> <char name>).
  2378. return -1;
  2379. }
  2380. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  2381. modif_p = atcmd_output;
  2382. year = month = day = hour = minute = second = 0;
  2383. while (modif_p[0] != '\0') {
  2384. value = atoi(modif_p);
  2385. if (value == 0)
  2386. modif_p++;
  2387. else {
  2388. if (modif_p[0] == '-' || modif_p[0] == '+')
  2389. modif_p++;
  2390. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  2391. modif_p++;
  2392. if (modif_p[0] == 's') {
  2393. second = value;
  2394. modif_p++;
  2395. } else if (modif_p[0] == 'n') {
  2396. minute = value;
  2397. modif_p++;
  2398. } else if (modif_p[0] == 'm' && modif_p[1] == 'n') {
  2399. minute = value;
  2400. modif_p = modif_p + 2;
  2401. } else if (modif_p[0] == 'h') {
  2402. hour = value;
  2403. modif_p++;
  2404. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  2405. day = value;
  2406. modif_p++;
  2407. } else if (modif_p[0] == 'm') {
  2408. month = value;
  2409. modif_p++;
  2410. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  2411. year = value;
  2412. modif_p++;
  2413. } else if (modif_p[0] != '\0') {
  2414. modif_p++;
  2415. }
  2416. }
  2417. }
  2418. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0 && second == 0) {
  2419. clif_displaymessage(fd, msg_txt(85)); // Invalid time for ban command.
  2420. return -1;
  2421. }
  2422. /**
  2423. * We now check if you can adjust the ban to negative (and if this is the case)
  2424. **/
  2425. timestamp = time(NULL);
  2426. tmtime = localtime(&timestamp);
  2427. tmtime->tm_year = tmtime->tm_year + year;
  2428. tmtime->tm_mon = tmtime->tm_mon + month;
  2429. tmtime->tm_mday = tmtime->tm_mday + day;
  2430. tmtime->tm_hour = tmtime->tm_hour + hour;
  2431. tmtime->tm_min = tmtime->tm_min + minute;
  2432. tmtime->tm_sec = tmtime->tm_sec + second;
  2433. timestamp = mktime(tmtime);
  2434. if( timestamp <= time(NULL) && !pc_can_use_command(sd, "unban", COMMAND_ATCOMMAND) ) {
  2435. clif_displaymessage(fd,msg_txt(1023)); // You are not allowed to reduce the length of a ban.
  2436. return -1;
  2437. }
  2438. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 2, year, month, day, hour, minute, second); // type: 2 - ban
  2439. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  2440. return 0;
  2441. }
  2442. /*==========================================
  2443. * charunblock command (usage: charunblock <player_name>)
  2444. *------------------------------------------*/
  2445. ACMD_FUNC(char_unblock)
  2446. {
  2447. nullpo_retr(-1, sd);
  2448. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2449. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2450. clif_displaymessage(fd, msg_txt(1024)); // Please enter a player name (usage: @charunblock <char name>).
  2451. return -1;
  2452. }
  2453. // send answer to login server via char-server
  2454. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 3, 0, 0, 0, 0, 0, 0); // type: 3 - unblock
  2455. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  2456. return 0;
  2457. }
  2458. /*==========================================
  2459. * charunban command (usage: charunban <player_name>)
  2460. *------------------------------------------*/
  2461. ACMD_FUNC(char_unban)
  2462. {
  2463. nullpo_retr(-1, sd);
  2464. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2465. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2466. clif_displaymessage(fd, msg_txt(1025)); // Please enter a player name (usage: @charunban <char name>).
  2467. return -1;
  2468. }
  2469. // send answer to login server via char-server
  2470. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 4, 0, 0, 0, 0, 0, 0); // type: 4 - unban
  2471. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  2472. return 0;
  2473. }
  2474. /*==========================================
  2475. *
  2476. *------------------------------------------*/
  2477. ACMD_FUNC(night)
  2478. {
  2479. nullpo_retr(-1, sd);
  2480. if (night_flag != 1) {
  2481. map_night_timer(night_timer_tid, 0, 0, 1);
  2482. } else {
  2483. clif_displaymessage(fd, msg_txt(89)); // Night mode is already enabled.
  2484. return -1;
  2485. }
  2486. return 0;
  2487. }
  2488. /*==========================================
  2489. *
  2490. *------------------------------------------*/
  2491. ACMD_FUNC(day)
  2492. {
  2493. nullpo_retr(-1, sd);
  2494. if (night_flag != 0) {
  2495. map_day_timer(day_timer_tid, 0, 0, 1);
  2496. } else {
  2497. clif_displaymessage(fd, msg_txt(90)); // Day mode is already enabled.
  2498. return -1;
  2499. }
  2500. return 0;
  2501. }
  2502. /*==========================================
  2503. *
  2504. *------------------------------------------*/
  2505. ACMD_FUNC(doom)
  2506. {
  2507. struct map_session_data* pl_sd;
  2508. struct s_mapiterator* iter;
  2509. nullpo_retr(-1, sd);
  2510. iter = mapit_getallusers();
  2511. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2512. {
  2513. if (pl_sd->fd != fd && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  2514. {
  2515. status_kill(&pl_sd->bl);
  2516. clif_specialeffect(&pl_sd->bl,450,AREA);
  2517. clif_displaymessage(pl_sd->fd, msg_txt(61)); // The holy messenger has given judgement.
  2518. }
  2519. }
  2520. mapit_free(iter);
  2521. clif_displaymessage(fd, msg_txt(62)); // Judgement was made.
  2522. return 0;
  2523. }
  2524. /*==========================================
  2525. *
  2526. *------------------------------------------*/
  2527. ACMD_FUNC(doommap)
  2528. {
  2529. struct map_session_data* pl_sd;
  2530. struct s_mapiterator* iter;
  2531. nullpo_retr(-1, sd);
  2532. iter = mapit_getallusers();
  2533. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2534. {
  2535. if (pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  2536. {
  2537. status_kill(&pl_sd->bl);
  2538. clif_specialeffect(&pl_sd->bl,450,AREA);
  2539. clif_displaymessage(pl_sd->fd, msg_txt(61)); // The holy messenger has given judgement.
  2540. }
  2541. }
  2542. mapit_free(iter);
  2543. clif_displaymessage(fd, msg_txt(62)); // Judgement was made.
  2544. return 0;
  2545. }
  2546. /*==========================================
  2547. *
  2548. *------------------------------------------*/
  2549. static void atcommand_raise_sub(struct map_session_data* sd) {
  2550. status_revive(&sd->bl, 100, 100);
  2551. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  2552. clif_displaymessage(sd->fd, msg_txt(63)); // Mercy has been shown.
  2553. }
  2554. /*==========================================
  2555. *
  2556. *------------------------------------------*/
  2557. ACMD_FUNC(raise)
  2558. {
  2559. struct map_session_data* pl_sd;
  2560. struct s_mapiterator* iter;
  2561. nullpo_retr(-1, sd);
  2562. iter = mapit_getallusers();
  2563. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2564. if( pc_isdead(pl_sd) )
  2565. atcommand_raise_sub(pl_sd);
  2566. mapit_free(iter);
  2567. clif_displaymessage(fd, msg_txt(64)); // Mercy has been granted.
  2568. return 0;
  2569. }
  2570. /*==========================================
  2571. *
  2572. *------------------------------------------*/
  2573. ACMD_FUNC(raisemap)
  2574. {
  2575. struct map_session_data* pl_sd;
  2576. struct s_mapiterator* iter;
  2577. nullpo_retr(-1, sd);
  2578. iter = mapit_getallusers();
  2579. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2580. if (sd->bl.m == pl_sd->bl.m && pc_isdead(pl_sd) )
  2581. atcommand_raise_sub(pl_sd);
  2582. mapit_free(iter);
  2583. clif_displaymessage(fd, msg_txt(64)); // Mercy has been granted.
  2584. return 0;
  2585. }
  2586. /*==========================================
  2587. *
  2588. *------------------------------------------*/
  2589. ACMD_FUNC(kick)
  2590. {
  2591. struct map_session_data *pl_sd;
  2592. nullpo_retr(-1, sd);
  2593. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2594. if (!message || !*message) {
  2595. clif_displaymessage(fd, msg_txt(1026)); // Please enter a player name (usage: @kick <char name/ID>).
  2596. return -1;
  2597. }
  2598. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  2599. {
  2600. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  2601. return -1;
  2602. }
  2603. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  2604. {
  2605. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  2606. return -1;
  2607. }
  2608. clif_GM_kick(sd, pl_sd);
  2609. return 0;
  2610. }
  2611. /*==========================================
  2612. *
  2613. *------------------------------------------*/
  2614. ACMD_FUNC(kickall)
  2615. {
  2616. struct map_session_data* pl_sd;
  2617. struct s_mapiterator* iter;
  2618. nullpo_retr(-1, sd);
  2619. iter = mapit_getallusers();
  2620. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2621. {
  2622. if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kick only lower or same gm level
  2623. if (sd->status.account_id != pl_sd->status.account_id)
  2624. clif_GM_kick(NULL, pl_sd);
  2625. }
  2626. }
  2627. mapit_free(iter);
  2628. clif_displaymessage(fd, msg_txt(195)); // All players have been kicked!
  2629. return 0;
  2630. }
  2631. /*==========================================
  2632. *
  2633. *------------------------------------------*/
  2634. ACMD_FUNC(allskill)
  2635. {
  2636. nullpo_retr(-1, sd);
  2637. pc_allskillup(sd); // all skills
  2638. sd->status.skill_point = 0; // 0 skill points
  2639. clif_updatestatus(sd, SP_SKILLPOINT); // update
  2640. clif_displaymessage(fd, msg_txt(76)); // All skills have been added to your skill tree.
  2641. return 0;
  2642. }
  2643. /*==========================================
  2644. *
  2645. *------------------------------------------*/
  2646. ACMD_FUNC(questskill)
  2647. {
  2648. uint16 skill_id;
  2649. nullpo_retr(-1, sd);
  2650. if (!message || !*message || (skill_id = atoi(message)) <= 0)
  2651. {// also send a list of skills applicable to this command
  2652. const char* text;
  2653. // attempt to find the text corresponding to this command
  2654. text = atcommand_help_string( command );
  2655. // send the error message as always
  2656. clif_displaymessage(fd, msg_txt(1027)); // Please enter a quest skill number.
  2657. if( text )
  2658. {// send the skill ID list associated with this command
  2659. clif_displaymessage( fd, text );
  2660. }
  2661. return -1;
  2662. }
  2663. if (skill_id >= MAX_SKILL_DB) {
  2664. clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist.
  2665. return -1;
  2666. }
  2667. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  2668. clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill.
  2669. return -1;
  2670. }
  2671. if (pc_checkskill(sd, skill_id) > 0) {
  2672. clif_displaymessage(fd, msg_txt(196)); // You already have this quest skill.
  2673. return -1;
  2674. }
  2675. pc_skill(sd, skill_id, 1, 0);
  2676. clif_displaymessage(fd, msg_txt(70)); // You have learned the skill.
  2677. return 0;
  2678. }
  2679. /*==========================================
  2680. *
  2681. *------------------------------------------*/
  2682. ACMD_FUNC(lostskill)
  2683. {
  2684. uint16 skill_id;
  2685. nullpo_retr(-1, sd);
  2686. if (!message || !*message || (skill_id = atoi(message)) <= 0)
  2687. {// also send a list of skills applicable to this command
  2688. const char* text;
  2689. // attempt to find the text corresponding to this command
  2690. text = atcommand_help_string( command );
  2691. // send the error message as always
  2692. clif_displaymessage(fd, msg_txt(1027)); // Please enter a quest skill number.
  2693. if( text )
  2694. {// send the skill ID list associated with this command
  2695. clif_displaymessage( fd, text );
  2696. }
  2697. return -1;
  2698. }
  2699. if (skill_id >= MAX_SKILL) {
  2700. clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist.
  2701. return -1;
  2702. }
  2703. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  2704. clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill.
  2705. return -1;
  2706. }
  2707. if (pc_checkskill(sd, skill_id) == 0) {
  2708. clif_displaymessage(fd, msg_txt(201)); // You don't have this quest skill.
  2709. return -1;
  2710. }
  2711. sd->status.skill[skill_id].lv = 0;
  2712. sd->status.skill[skill_id].flag = SKILL_FLAG_PERMANENT;
  2713. clif_deleteskill(sd,skill_id);
  2714. clif_displaymessage(fd, msg_txt(71)); // You have forgotten the skill.
  2715. return 0;
  2716. }
  2717. /*==========================================
  2718. *
  2719. *------------------------------------------*/
  2720. ACMD_FUNC(spiritball)
  2721. {
  2722. int max_spiritballs;
  2723. int number;
  2724. nullpo_retr(-1, sd);
  2725. max_spiritballs = min(ARRAYLENGTH(sd->spirit_timer), 0x7FFF);
  2726. if( !message || !*message || (number = atoi(message)) < 0 || number > max_spiritballs )
  2727. {
  2728. char msg[CHAT_SIZE_MAX];
  2729. safesnprintf(msg, sizeof(msg), msg_txt(1028), max_spiritballs); // Please enter a party name (usage: @party <party_name>).
  2730. clif_displaymessage(fd, msg);
  2731. return -1;
  2732. }
  2733. if( sd->spiritball > 0 )
  2734. pc_delspiritball(sd, sd->spiritball, 1);
  2735. sd->spiritball = number;
  2736. clif_spiritball(&sd->bl);
  2737. // no message, player can look the difference
  2738. return 0;
  2739. }
  2740. /*==========================================
  2741. *
  2742. *------------------------------------------*/
  2743. ACMD_FUNC(party)
  2744. {
  2745. char party[NAME_LENGTH];
  2746. nullpo_retr(-1, sd);
  2747. memset(party, '\0', sizeof(party));
  2748. if (!message || !*message || sscanf(message, "%23[^\n]", party) < 1) {
  2749. clif_displaymessage(fd, msg_txt(1029)); // Please enter a party name (usage: @party <party_name>).
  2750. return -1;
  2751. }
  2752. party_create(sd, party, 0, 0);
  2753. return 0;
  2754. }
  2755. /*==========================================
  2756. *
  2757. *------------------------------------------*/
  2758. ACMD_FUNC(guild)
  2759. {
  2760. char guild[NAME_LENGTH];
  2761. int prev;
  2762. nullpo_retr(-1, sd);
  2763. memset(guild, '\0', sizeof(guild));
  2764. if (!message || !*message || sscanf(message, "%23[^\n]", guild) < 1) {
  2765. clif_displaymessage(fd, msg_txt(1030)); // Please enter a guild name (usage: @guild <guild_name>).
  2766. return -1;
  2767. }
  2768. prev = battle_config.guild_emperium_check;
  2769. battle_config.guild_emperium_check = 0;
  2770. guild_create(sd, guild);
  2771. battle_config.guild_emperium_check = prev;
  2772. return 0;
  2773. }
  2774. ACMD_FUNC(breakguild)
  2775. {
  2776. nullpo_retr(-1, sd);
  2777. if (sd->status.guild_id) { // Check if the player has a guild
  2778. struct guild *g;
  2779. g = sd->guild; // Search the guild
  2780. if (g) { // Check if guild was found
  2781. if (sd->state.gmaster_flag) { // Check if player is guild master
  2782. int ret = 0;
  2783. ret = guild_break(sd, g->name); // Break guild
  2784. if (ret) { // Check if anything went wrong
  2785. return 0; // Guild was broken
  2786. } else {
  2787. return -1; // Something went wrong
  2788. }
  2789. } else { // Not guild master
  2790. clif_displaymessage(fd, msg_txt(1181)); // You need to be a Guild Master to use this command.
  2791. return -1;
  2792. }
  2793. } else { // Guild was not found. HOW?
  2794. clif_displaymessage(fd, msg_txt(252)); // You are not in a guild.
  2795. return -1;
  2796. }
  2797. } else { // Player does not have a guild
  2798. clif_displaymessage(fd, msg_txt(252)); // You are not in a guild.
  2799. return -1;
  2800. }
  2801. return 0;
  2802. }
  2803. /*==========================================
  2804. *
  2805. *------------------------------------------*/
  2806. ACMD_FUNC(agitstart)
  2807. {
  2808. nullpo_retr(-1, sd);
  2809. if (agit_flag == 1) {
  2810. clif_displaymessage(fd, msg_txt(73)); // War of Emperium is currently in progress.
  2811. return -1;
  2812. }
  2813. agit_flag = 1;
  2814. guild_agit_start();
  2815. clif_displaymessage(fd, msg_txt(72)); // War of Emperium has been initiated.
  2816. return 0;
  2817. }
  2818. /*==========================================
  2819. *
  2820. *------------------------------------------*/
  2821. ACMD_FUNC(agitstart2)
  2822. {
  2823. nullpo_retr(-1, sd);
  2824. if (agit2_flag == 1) {
  2825. clif_displaymessage(fd, msg_txt(404)); // "War of Emperium SE is currently in progress."
  2826. return -1;
  2827. }
  2828. agit2_flag = 1;
  2829. guild_agit2_start();
  2830. clif_displaymessage(fd, msg_txt(403)); // "War of Emperium SE has been initiated."
  2831. return 0;
  2832. }
  2833. /*==========================================
  2834. *
  2835. *------------------------------------------*/
  2836. ACMD_FUNC(agitend)
  2837. {
  2838. nullpo_retr(-1, sd);
  2839. if (agit_flag == 0) {
  2840. clif_displaymessage(fd, msg_txt(75)); // War of Emperium is currently not in progress.
  2841. return -1;
  2842. }
  2843. agit_flag = 0;
  2844. guild_agit_end();
  2845. clif_displaymessage(fd, msg_txt(74)); // War of Emperium has been ended.
  2846. return 0;
  2847. }
  2848. /*==========================================
  2849. *
  2850. *------------------------------------------*/
  2851. ACMD_FUNC(agitend2)
  2852. {
  2853. nullpo_retr(-1, sd);
  2854. if (agit2_flag == 0) {
  2855. clif_displaymessage(fd, msg_txt(406)); // "War of Emperium SE is currently not in progress."
  2856. return -1;
  2857. }
  2858. agit2_flag = 0;
  2859. guild_agit2_end();
  2860. clif_displaymessage(fd, msg_txt(405)); // "War of Emperium SE has been ended."
  2861. return 0;
  2862. }
  2863. /*==========================================
  2864. * @mapexit - shuts down the map server
  2865. *------------------------------------------*/
  2866. ACMD_FUNC(mapexit)
  2867. {
  2868. nullpo_retr(-1, sd);
  2869. do_shutdown();
  2870. return 0;
  2871. }
  2872. /*==========================================
  2873. * idsearch <part_of_name>: revrited by [Yor]
  2874. *------------------------------------------*/
  2875. ACMD_FUNC(idsearch)
  2876. {
  2877. char item_name[100];
  2878. unsigned int i, match;
  2879. struct item_data *item_array[MAX_SEARCH];
  2880. nullpo_retr(-1, sd);
  2881. memset(item_name, '\0', sizeof(item_name));
  2882. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2883. if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
  2884. clif_displaymessage(fd, msg_txt(1031)); // Please enter part of an item name (usage: @idsearch <part_of_item_name>).
  2885. return -1;
  2886. }
  2887. sprintf(atcmd_output, msg_txt(77), item_name); // The reference result of '%s' (name: id):
  2888. clif_displaymessage(fd, atcmd_output);
  2889. match = itemdb_searchname_array(item_array, MAX_SEARCH, item_name);
  2890. if (match > MAX_SEARCH) {
  2891. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, match);
  2892. clif_displaymessage(fd, atcmd_output);
  2893. match = MAX_SEARCH;
  2894. }
  2895. for(i = 0; i < match; i++) {
  2896. sprintf(atcmd_output, msg_txt(78), item_array[i]->jname, item_array[i]->nameid); // %s: %d
  2897. clif_displaymessage(fd, atcmd_output);
  2898. }
  2899. sprintf(atcmd_output, msg_txt(79), match); // It is %d affair above.
  2900. clif_displaymessage(fd, atcmd_output);
  2901. return 0;
  2902. }
  2903. /*==========================================
  2904. * Recall All Characters Online To Your Location
  2905. *------------------------------------------*/
  2906. ACMD_FUNC(recallall)
  2907. {
  2908. struct map_session_data* pl_sd;
  2909. struct s_mapiterator* iter;
  2910. int count;
  2911. nullpo_retr(-1, sd);
  2912. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2913. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2914. clif_displaymessage(fd, msg_txt(1032)); // You are not authorized to warp somenone to your current map.
  2915. return -1;
  2916. }
  2917. count = 0;
  2918. iter = mapit_getallusers();
  2919. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2920. {
  2921. if (sd->status.account_id != pl_sd->status.account_id && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  2922. {
  2923. if (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y)
  2924. continue; // Don't waste time warping the character to the same place.
  2925. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  2926. count++;
  2927. else {
  2928. if (pc_isdead(pl_sd)) { //Wake them up
  2929. pc_setstand(pl_sd);
  2930. pc_setrestartvalue(pl_sd,1);
  2931. }
  2932. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  2933. }
  2934. }
  2935. }
  2936. mapit_free(iter);
  2937. clif_displaymessage(fd, msg_txt(92)); // All characters recalled!
  2938. if (count) {
  2939. sprintf(atcmd_output, msg_txt(1033), count); // Because you are not authorized to warp from some maps, %d player(s) have not been recalled.
  2940. clif_displaymessage(fd, atcmd_output);
  2941. }
  2942. return 0;
  2943. }
  2944. /*==========================================
  2945. * Recall online characters of a guild to your location
  2946. *------------------------------------------*/
  2947. ACMD_FUNC(guildrecall)
  2948. {
  2949. struct map_session_data* pl_sd;
  2950. struct s_mapiterator* iter;
  2951. int count;
  2952. char guild_name[NAME_LENGTH];
  2953. struct guild *g;
  2954. nullpo_retr(-1, sd);
  2955. memset(guild_name, '\0', sizeof(guild_name));
  2956. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2957. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  2958. clif_displaymessage(fd, msg_txt(1034)); // Please enter a guild name/ID (usage: @guildrecall <guild_name/ID>).
  2959. return -1;
  2960. }
  2961. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2962. clif_displaymessage(fd, msg_txt(1032)); // You are not authorized to warp somenone to your current map.
  2963. return -1;
  2964. }
  2965. if ((g = guild_searchname(guild_name)) == NULL && // name first to avoid error when name begin with a number
  2966. (g = guild_search(atoi(message))) == NULL)
  2967. {
  2968. clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online.
  2969. return -1;
  2970. }
  2971. count = 0;
  2972. iter = mapit_getallusers();
  2973. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2974. {
  2975. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.guild_id == g->guild_id)
  2976. {
  2977. 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))
  2978. continue; // Skip GMs greater than you... or chars already on the cell
  2979. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  2980. count++;
  2981. else
  2982. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  2983. }
  2984. }
  2985. mapit_free(iter);
  2986. sprintf(atcmd_output, msg_txt(93), g->name); // All online characters of the %s guild have been recalled to your position.
  2987. clif_displaymessage(fd, atcmd_output);
  2988. if (count) {
  2989. sprintf(atcmd_output, msg_txt(1033), count); // Because you are not authorized to warp from some maps, %d player(s) have not been recalled.
  2990. clif_displaymessage(fd, atcmd_output);
  2991. }
  2992. return 0;
  2993. }
  2994. /*==========================================
  2995. * Recall online characters of a party to your location
  2996. *------------------------------------------*/
  2997. ACMD_FUNC(partyrecall)
  2998. {
  2999. struct map_session_data* pl_sd;
  3000. struct s_mapiterator* iter;
  3001. char party_name[NAME_LENGTH];
  3002. struct party_data *p;
  3003. int count;
  3004. nullpo_retr(-1, sd);
  3005. memset(party_name, '\0', sizeof(party_name));
  3006. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3007. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3008. clif_displaymessage(fd, msg_txt(1035)); // Please enter a party name/ID (usage: @partyrecall <party_name/ID>).
  3009. return -1;
  3010. }
  3011. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3012. clif_displaymessage(fd, msg_txt(1032)); // You are not authorized to warp somenone to your current map.
  3013. return -1;
  3014. }
  3015. if ((p = party_searchname(party_name)) == NULL && // name first to avoid error when name begin with a number
  3016. (p = party_search(atoi(message))) == NULL)
  3017. {
  3018. clif_displaymessage(fd, msg_txt(96)); // Incorrect name or ID, or no one from the party is online.
  3019. return -1;
  3020. }
  3021. count = 0;
  3022. iter = mapit_getallusers();
  3023. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3024. {
  3025. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.party_id == p->party.party_id)
  3026. {
  3027. 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))
  3028. continue; // Skip GMs greater than you... or chars already on the cell
  3029. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3030. count++;
  3031. else
  3032. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  3033. }
  3034. }
  3035. mapit_free(iter);
  3036. sprintf(atcmd_output, msg_txt(95), p->party.name); // All online characters of the %s party have been recalled to your position.
  3037. clif_displaymessage(fd, atcmd_output);
  3038. if (count) {
  3039. sprintf(atcmd_output, msg_txt(1033), count); // Because you are not authorized to warp from some maps, %d player(s) have not been recalled.
  3040. clif_displaymessage(fd, atcmd_output);
  3041. }
  3042. return 0;
  3043. }
  3044. /*==========================================
  3045. *
  3046. *------------------------------------------*/
  3047. ACMD_FUNC(reloaditemdb)
  3048. {
  3049. nullpo_retr(-1, sd);
  3050. itemdb_reload();
  3051. clif_displaymessage(fd, msg_txt(97)); // Item database has been reloaded.
  3052. return 0;
  3053. }
  3054. /*==========================================
  3055. *
  3056. *------------------------------------------*/
  3057. ACMD_FUNC(reloadmobdb)
  3058. {
  3059. nullpo_retr(-1, sd);
  3060. mob_reload();
  3061. read_petdb();
  3062. merc_reload();
  3063. read_mercenarydb();
  3064. read_mercenary_skilldb();
  3065. reload_elementaldb();
  3066. clif_displaymessage(fd, msg_txt(98)); // Monster database has been reloaded.
  3067. return 0;
  3068. }
  3069. /*==========================================
  3070. *
  3071. *------------------------------------------*/
  3072. ACMD_FUNC(reloadskilldb)
  3073. {
  3074. nullpo_retr(-1, sd);
  3075. skill_reload();
  3076. merc_skill_reload();
  3077. reload_elemental_skilldb();
  3078. read_mercenary_skilldb();
  3079. clif_displaymessage(fd, msg_txt(99)); // Skill database has been reloaded.
  3080. return 0;
  3081. }
  3082. /*==========================================
  3083. * @reloadatcommand - reloads atcommand_athena.conf groups.conf
  3084. *------------------------------------------*/
  3085. void atcommand_doload();
  3086. ACMD_FUNC(reloadatcommand) {
  3087. config_t run_test;
  3088. if (conf_read_file(&run_test, "conf/groups.conf")) {
  3089. clif_displaymessage(fd, msg_txt(1036)); // Error reading groups.conf, reload failed.
  3090. return -1;
  3091. }
  3092. config_destroy(&run_test);
  3093. if (conf_read_file(&run_test, ATCOMMAND_CONF_FILENAME)) {
  3094. clif_displaymessage(fd, msg_txt(1037)); // Error reading atcommand_athena.conf, reload failed.
  3095. return -1;
  3096. }
  3097. config_destroy(&run_test);
  3098. atcommand_doload();
  3099. pc_groups_reload();
  3100. clif_displaymessage(fd, msg_txt(254));
  3101. return 0;
  3102. }
  3103. /*==========================================
  3104. * @reloadbattleconf - reloads battle_athena.conf
  3105. *------------------------------------------*/
  3106. ACMD_FUNC(reloadbattleconf)
  3107. {
  3108. struct Battle_Config prev_config;
  3109. memcpy(&prev_config, &battle_config, sizeof(prev_config));
  3110. battle_config_read(BATTLE_CONF_FILENAME);
  3111. if( prev_config.item_rate_mvp != battle_config.item_rate_mvp
  3112. || prev_config.item_rate_common != battle_config.item_rate_common
  3113. || prev_config.item_rate_common_boss != battle_config.item_rate_common_boss
  3114. || prev_config.item_rate_card != battle_config.item_rate_card
  3115. || prev_config.item_rate_card_boss != battle_config.item_rate_card_boss
  3116. || prev_config.item_rate_equip != battle_config.item_rate_equip
  3117. || prev_config.item_rate_equip_boss != battle_config.item_rate_equip_boss
  3118. || prev_config.item_rate_heal != battle_config.item_rate_heal
  3119. || prev_config.item_rate_heal_boss != battle_config.item_rate_heal_boss
  3120. || prev_config.item_rate_use != battle_config.item_rate_use
  3121. || prev_config.item_rate_use_boss != battle_config.item_rate_use_boss
  3122. || prev_config.item_rate_treasure != battle_config.item_rate_treasure
  3123. || prev_config.item_rate_adddrop != battle_config.item_rate_adddrop
  3124. || prev_config.logarithmic_drops != battle_config.logarithmic_drops
  3125. || prev_config.item_drop_common_min != battle_config.item_drop_common_min
  3126. || prev_config.item_drop_common_max != battle_config.item_drop_common_max
  3127. || prev_config.item_drop_card_min != battle_config.item_drop_card_min
  3128. || prev_config.item_drop_card_max != battle_config.item_drop_card_max
  3129. || prev_config.item_drop_equip_min != battle_config.item_drop_equip_min
  3130. || prev_config.item_drop_equip_max != battle_config.item_drop_equip_max
  3131. || prev_config.item_drop_mvp_min != battle_config.item_drop_mvp_min
  3132. || prev_config.item_drop_mvp_max != battle_config.item_drop_mvp_max
  3133. || prev_config.item_drop_heal_min != battle_config.item_drop_heal_min
  3134. || prev_config.item_drop_heal_max != battle_config.item_drop_heal_max
  3135. || prev_config.item_drop_use_min != battle_config.item_drop_use_min
  3136. || prev_config.item_drop_use_max != battle_config.item_drop_use_max
  3137. || prev_config.item_drop_treasure_min != battle_config.item_drop_treasure_min
  3138. || prev_config.item_drop_treasure_max != battle_config.item_drop_treasure_max
  3139. || prev_config.base_exp_rate != battle_config.base_exp_rate
  3140. || prev_config.job_exp_rate != battle_config.job_exp_rate
  3141. )
  3142. { // Exp or Drop rates changed.
  3143. mob_reload(); //Needed as well so rate changes take effect.
  3144. chrif_ragsrvinfo(battle_config.base_exp_rate, battle_config.job_exp_rate, battle_config.item_rate_common);
  3145. }
  3146. clif_displaymessage(fd, msg_txt(255));
  3147. return 0;
  3148. }
  3149. /*==========================================
  3150. * @reloadstatusdb - reloads job_db1.txt job_db2.txt job_db2-2.txt refine_db.txt size_fix.txt
  3151. *------------------------------------------*/
  3152. ACMD_FUNC(reloadstatusdb)
  3153. {
  3154. status_readdb();
  3155. clif_displaymessage(fd, msg_txt(256));
  3156. return 0;
  3157. }
  3158. /*==========================================
  3159. * @reloadpcdb - reloads exp.txt skill_tree.txt attr_fix.txt statpoint.txt
  3160. *------------------------------------------*/
  3161. ACMD_FUNC(reloadpcdb)
  3162. {
  3163. pc_readdb();
  3164. clif_displaymessage(fd, msg_txt(257));
  3165. return 0;
  3166. }
  3167. /*==========================================
  3168. * @reloadmotd - reloads motd.txt
  3169. *------------------------------------------*/
  3170. ACMD_FUNC(reloadmotd)
  3171. {
  3172. pc_read_motd();
  3173. clif_displaymessage(fd, msg_txt(268));
  3174. return 0;
  3175. }
  3176. /*==========================================
  3177. * @reloadscript - reloads all scripts (npcs, warps, mob spawns, ...)
  3178. *------------------------------------------*/
  3179. ACMD_FUNC(reloadscript)
  3180. {
  3181. nullpo_retr(-1, sd);
  3182. //atcommand_broadcast( fd, sd, "@broadcast", "Server is reloading scripts..." );
  3183. //atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
  3184. flush_fifos();
  3185. map_reloadnpc(true); // reload config files seeking for npcs
  3186. script_reload();
  3187. npc_reload();
  3188. clif_displaymessage(fd, msg_txt(100)); // Scripts have been reloaded.
  3189. return 0;
  3190. }
  3191. /*==========================================
  3192. * @mapinfo [0-3] <map name> by MC_Cameri
  3193. * => Shows information about the map [map name]
  3194. * 0 = no additional information
  3195. * 1 = Show users in that map and their location
  3196. * 2 = Shows NPCs in that map
  3197. * 3 = Shows the chats in that map
  3198. *------------------------------------------*/
  3199. ACMD_FUNC(mapinfo) {
  3200. struct map_session_data* pl_sd;
  3201. struct s_mapiterator* iter;
  3202. struct npc_data *nd = NULL;
  3203. struct chat_data *cd = NULL;
  3204. char direction[12];
  3205. int i, m_id, chat_num = 0, list = 0, vend_num = 0;
  3206. unsigned short m_index;
  3207. char mapname[24];
  3208. nullpo_retr(-1, sd);
  3209. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3210. memset(mapname, '\0', sizeof(mapname));
  3211. memset(direction, '\0', sizeof(direction));
  3212. sscanf(message, "%d %23[^\n]", &list, mapname);
  3213. if (list < 0 || list > 3) {
  3214. clif_displaymessage(fd, msg_txt(1038)); // Please enter at least one valid list number (usage: @mapinfo <0-3> <map>).
  3215. return -1;
  3216. }
  3217. if (mapname[0] == '\0') {
  3218. safestrncpy(mapname, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
  3219. m_id = map_mapindex2mapid(sd->mapindex);
  3220. } else {
  3221. m_id = map_mapname2mapid(mapname);
  3222. }
  3223. if (m_id < 0) {
  3224. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  3225. return -1;
  3226. }
  3227. m_index = mapindex_name2id(mapname); //This one shouldn't fail since the previous seek did not.
  3228. clif_displaymessage(fd, msg_txt(1039)); // ------ Map Info ------
  3229. // count chats (for initial message)
  3230. chat_num = 0;
  3231. iter = mapit_getallusers();
  3232. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) {
  3233. if( pl_sd->mapindex == m_index ) {
  3234. if( pl_sd->state.vending )
  3235. vend_num++;
  3236. else if( (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL && cd->usersd[0] == pl_sd )
  3237. chat_num++;
  3238. }
  3239. }
  3240. mapit_free(iter);
  3241. sprintf(atcmd_output, msg_txt(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
  3242. clif_displaymessage(fd, atcmd_output);
  3243. clif_displaymessage(fd, msg_txt(1041)); // ------ Map Flags ------
  3244. if (map[m_id].flag.town)
  3245. clif_displaymessage(fd, msg_txt(1042)); // Town Map
  3246. if (battle_config.autotrade_mapflag == map[m_id].flag.autotrade)
  3247. clif_displaymessage(fd, msg_txt(1043)); // Autotrade Enabled
  3248. else
  3249. clif_displaymessage(fd, msg_txt(1044)); // Autotrade Disabled
  3250. if (map[m_id].flag.battleground)
  3251. clif_displaymessage(fd, msg_txt(1045)); // Battlegrounds ON
  3252. strcpy(atcmd_output,msg_txt(1046)); // PvP Flags:
  3253. if (map[m_id].flag.pvp)
  3254. strcat(atcmd_output, msg_txt(1047)); // Pvp ON |
  3255. if (map[m_id].flag.pvp_noguild)
  3256. strcat(atcmd_output, msg_txt(1048)); // NoGuild |
  3257. if (map[m_id].flag.pvp_noparty)
  3258. strcat(atcmd_output, msg_txt(1049)); // NoParty |
  3259. if (map[m_id].flag.pvp_nightmaredrop)
  3260. strcat(atcmd_output, msg_txt(1050)); // NightmareDrop |
  3261. if (map[m_id].flag.pvp_nocalcrank)
  3262. strcat(atcmd_output, msg_txt(1051)); // NoCalcRank |
  3263. clif_displaymessage(fd, atcmd_output);
  3264. strcpy(atcmd_output,msg_txt(1052)); // GvG Flags:
  3265. if (map[m_id].flag.gvg)
  3266. strcat(atcmd_output, msg_txt(1053)); // GvG ON |
  3267. if (map[m_id].flag.gvg_dungeon)
  3268. strcat(atcmd_output, msg_txt(1054)); // GvG Dungeon |
  3269. if (map[m_id].flag.gvg_castle)
  3270. strcat(atcmd_output, msg_txt(1055)); // GvG Castle |
  3271. if (map[m_id].flag.gvg_noparty)
  3272. strcat(atcmd_output, msg_txt(1056)); // NoParty |
  3273. clif_displaymessage(fd, atcmd_output);
  3274. strcpy(atcmd_output,msg_txt(1057)); // Teleport Flags:
  3275. if (map[m_id].flag.noteleport)
  3276. strcat(atcmd_output, msg_txt(1058)); // NoTeleport |
  3277. if (map[m_id].flag.monster_noteleport)
  3278. strcat(atcmd_output, msg_txt(1059)); // Monster NoTeleport |
  3279. if (map[m_id].flag.nowarp)
  3280. strcat(atcmd_output, msg_txt(1060)); // NoWarp |
  3281. if (map[m_id].flag.nowarpto)
  3282. strcat(atcmd_output, msg_txt(1061)); // NoWarpTo |
  3283. if (map[m_id].flag.noreturn)
  3284. strcat(atcmd_output, msg_txt(1062)); // NoReturn |
  3285. if (map[m_id].flag.nogo)
  3286. strcat(atcmd_output, msg_txt(1063)); // NoGo |
  3287. if (map[m_id].flag.nomemo)
  3288. strcat(atcmd_output, msg_txt(1064)); // NoMemo |
  3289. clif_displaymessage(fd, atcmd_output);
  3290. sprintf(atcmd_output, msg_txt(1065), // No Exp Penalty: %s | No Zeny Penalty: %s
  3291. (map[m_id].flag.noexppenalty) ? msg_txt(1066) : msg_txt(1067), (map[m_id].flag.nozenypenalty) ? msg_txt(1066) : msg_txt(1067)); // On / Off
  3292. clif_displaymessage(fd, atcmd_output);
  3293. if (map[m_id].flag.nosave) {
  3294. if (!map[m_id].save.map)
  3295. clif_displaymessage(fd, msg_txt(1068)); // No Save (Return to last Save Point)
  3296. else if (map[m_id].save.x == -1 || map[m_id].save.y == -1 ) {
  3297. sprintf(atcmd_output, msg_txt(1069), mapindex_id2name(map[m_id].save.map)); // No Save, Save Point: %s,Random
  3298. clif_displaymessage(fd, atcmd_output);
  3299. }
  3300. else {
  3301. sprintf(atcmd_output, msg_txt(1070), // No Save, Save Point: %s,%d,%d
  3302. mapindex_id2name(map[m_id].save.map),map[m_id].save.x,map[m_id].save.y);
  3303. clif_displaymessage(fd, atcmd_output);
  3304. }
  3305. }
  3306. strcpy(atcmd_output,msg_txt(1071)); // Weather Flags:
  3307. if (map[m_id].flag.snow)
  3308. strcat(atcmd_output, msg_txt(1072)); // Snow |
  3309. if (map[m_id].flag.fog)
  3310. strcat(atcmd_output, msg_txt(1073)); // Fog |
  3311. if (map[m_id].flag.sakura)
  3312. strcat(atcmd_output, msg_txt(1074)); // Sakura |
  3313. if (map[m_id].flag.clouds)
  3314. strcat(atcmd_output, msg_txt(1075)); // Clouds |
  3315. if (map[m_id].flag.clouds2)
  3316. strcat(atcmd_output, msg_txt(1076)); // Clouds2 |
  3317. if (map[m_id].flag.fireworks)
  3318. strcat(atcmd_output, msg_txt(1077)); // Fireworks |
  3319. if (map[m_id].flag.leaves)
  3320. strcat(atcmd_output, msg_txt(1078)); // Leaves |
  3321. if (map[m_id].flag.nightenabled)
  3322. strcat(atcmd_output, msg_txt(1080)); // Displays Night |
  3323. clif_displaymessage(fd, atcmd_output);
  3324. strcpy(atcmd_output,msg_txt(1081)); // Other Flags:
  3325. if (map[m_id].flag.nobranch)
  3326. strcat(atcmd_output, msg_txt(1082)); // NoBranch |
  3327. if (map[m_id].flag.notrade)
  3328. strcat(atcmd_output, msg_txt(1083)); // NoTrade |
  3329. if (map[m_id].flag.novending)
  3330. strcat(atcmd_output, msg_txt(1084)); // NoVending |
  3331. if (map[m_id].flag.nodrop)
  3332. strcat(atcmd_output, msg_txt(1085)); // NoDrop |
  3333. if (map[m_id].flag.noskill)
  3334. strcat(atcmd_output, msg_txt(1086)); // NoSkill |
  3335. if (map[m_id].flag.noicewall)
  3336. strcat(atcmd_output, msg_txt(1087)); // NoIcewall |
  3337. if (map[m_id].flag.allowks)
  3338. strcat(atcmd_output, msg_txt(1088)); // AllowKS |
  3339. if (map[m_id].flag.reset)
  3340. strcat(atcmd_output, msg_txt(1089)); // Reset |
  3341. clif_displaymessage(fd, atcmd_output);
  3342. strcpy(atcmd_output,msg_txt(1090)); // Other Flags:
  3343. if (map[m_id].nocommand)
  3344. strcat(atcmd_output, msg_txt(1091)); // NoCommand |
  3345. if (map[m_id].flag.nobaseexp)
  3346. strcat(atcmd_output, msg_txt(1092)); // NoBaseEXP |
  3347. if (map[m_id].flag.nojobexp)
  3348. strcat(atcmd_output, msg_txt(1093)); // NoJobEXP |
  3349. if (map[m_id].flag.nomobloot)
  3350. strcat(atcmd_output, msg_txt(1094)); // NoMobLoot |
  3351. if (map[m_id].flag.nomvploot)
  3352. strcat(atcmd_output, msg_txt(1095)); // NoMVPLoot |
  3353. if (map[m_id].flag.partylock)
  3354. strcat(atcmd_output, msg_txt(1096)); // PartyLock |
  3355. if (map[m_id].flag.guildlock)
  3356. strcat(atcmd_output, msg_txt(1097)); // GuildLock |
  3357. clif_displaymessage(fd, atcmd_output);
  3358. switch (list) {
  3359. case 0:
  3360. // Do nothing. It's list 0, no additional display.
  3361. break;
  3362. case 1:
  3363. clif_displaymessage(fd, msg_txt(1098)); // ----- Players in Map -----
  3364. iter = mapit_getallusers();
  3365. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3366. {
  3367. if (pl_sd->mapindex == m_index) {
  3368. sprintf(atcmd_output, msg_txt(1099), // Player '%s' (session #%d) | Location: %d,%d
  3369. pl_sd->status.name, pl_sd->fd, pl_sd->bl.x, pl_sd->bl.y);
  3370. clif_displaymessage(fd, atcmd_output);
  3371. }
  3372. }
  3373. mapit_free(iter);
  3374. break;
  3375. case 2:
  3376. clif_displaymessage(fd, msg_txt(1100)); // ----- NPCs in Map -----
  3377. for (i = 0; i < map[m_id].npc_num;)
  3378. {
  3379. nd = map[m_id].npc[i];
  3380. switch(nd->ud.dir) {
  3381. case 0: strcpy(direction, msg_txt(1101)); break; // North
  3382. case 1: strcpy(direction, msg_txt(1102)); break; // North West
  3383. case 2: strcpy(direction, msg_txt(1103)); break; // West
  3384. case 3: strcpy(direction, msg_txt(1104)); break; // South West
  3385. case 4: strcpy(direction, msg_txt(1105)); break; // South
  3386. case 5: strcpy(direction, msg_txt(1106)); break; // South East
  3387. case 6: strcpy(direction, msg_txt(1107)); break; // East
  3388. case 7: strcpy(direction, msg_txt(1108)); break; // North East
  3389. case 9: strcpy(direction, msg_txt(1109)); break; // North
  3390. default: strcpy(direction, msg_txt(1110)); break; // Unknown
  3391. }
  3392. if(strcmp(nd->name,nd->exname) == 0)
  3393. sprintf(atcmd_output, msg_txt(1111), // NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d
  3394. ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
  3395. else
  3396. sprintf(atcmd_output, msg_txt(1112), // NPC %d: %s::%s | Direction: %s | Sprite: %d | Location: %d %d
  3397. ++i, nd->name, nd->exname, direction, nd->class_, nd->bl.x, nd->bl.y);
  3398. clif_displaymessage(fd, atcmd_output);
  3399. }
  3400. break;
  3401. case 3:
  3402. clif_displaymessage(fd, msg_txt(1113)); // ----- Chats in Map -----
  3403. iter = mapit_getallusers();
  3404. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3405. {
  3406. if ((cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL &&
  3407. pl_sd->mapindex == m_index &&
  3408. cd->usersd[0] == pl_sd)
  3409. {
  3410. sprintf(atcmd_output, msg_txt(1114), // Chat: %s | Player: %s | Location: %d %d
  3411. cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
  3412. clif_displaymessage(fd, atcmd_output);
  3413. sprintf(atcmd_output, msg_txt(1115), // Users: %d/%d | Password: %s | Public: %s
  3414. cd->users, cd->limit, cd->pass, (cd->pub) ? msg_txt(1116) : msg_txt(1117)); // Yes / No
  3415. clif_displaymessage(fd, atcmd_output);
  3416. }
  3417. }
  3418. mapit_free(iter);
  3419. break;
  3420. default: // normally impossible to arrive here
  3421. clif_displaymessage(fd, msg_txt(1118)); // Please enter at least one valid list number (usage: @mapinfo <0-3> <map>).
  3422. return -1;
  3423. break;
  3424. }
  3425. return 0;
  3426. }
  3427. /*==========================================
  3428. *
  3429. *------------------------------------------*/
  3430. ACMD_FUNC(mount_peco)
  3431. {
  3432. nullpo_retr(-1, sd);
  3433. if (sd->disguise) {
  3434. clif_displaymessage(fd, msg_txt(212)); // Cannot mount while in disguise.
  3435. return -1;
  3436. }
  3437. if( (sd->class_&MAPID_THIRDMASK) == MAPID_RUNE_KNIGHT && pc_checkskill(sd,RK_DRAGONTRAINING) > 0 ) {
  3438. if( !(sd->sc.option&OPTION_DRAGON1) ) {
  3439. clif_displaymessage(sd->fd,msg_txt(1119)); // You have mounted your Dragon.
  3440. pc_setoption(sd, sd->sc.option|OPTION_DRAGON1);
  3441. } else {
  3442. clif_displaymessage(sd->fd,msg_txt(1120)); // You have released your Dragon.
  3443. pc_setoption(sd, sd->sc.option&~OPTION_DRAGON1);
  3444. }
  3445. return 0;
  3446. }
  3447. if( (sd->class_&MAPID_THIRDMASK) == MAPID_RANGER && pc_checkskill(sd,RA_WUGRIDER) > 0 ) {
  3448. if( !pc_isridingwug(sd) ) {
  3449. clif_displaymessage(sd->fd,msg_txt(1121)); // You have mounted your Warg.
  3450. pc_setoption(sd, sd->sc.option|OPTION_WUGRIDER);
  3451. } else {
  3452. clif_displaymessage(sd->fd,msg_txt(1122)); // You have released your Warg.
  3453. pc_setoption(sd, sd->sc.option&~OPTION_WUGRIDER);
  3454. }
  3455. return 0;
  3456. }
  3457. if( (sd->class_&MAPID_THIRDMASK) == MAPID_MECHANIC ) {
  3458. if( !pc_ismadogear(sd) ) {
  3459. clif_displaymessage(sd->fd,msg_txt(1123)); // You have mounted your Mado Gear.
  3460. pc_setoption(sd, sd->sc.option|OPTION_MADOGEAR);
  3461. } else {
  3462. clif_displaymessage(sd->fd,msg_txt(1124)); // You have released your Mado Gear.
  3463. pc_setoption(sd, sd->sc.option&~OPTION_MADOGEAR);
  3464. }
  3465. return 0;
  3466. }
  3467. if (!pc_isriding(sd)) { // if actually no peco
  3468. if (!pc_checkskill(sd, KN_RIDING)) {
  3469. clif_displaymessage(fd, msg_txt(213)); // You can not mount a Peco Peco with your current job.
  3470. return -1;
  3471. }
  3472. pc_setoption(sd, sd->sc.option | OPTION_RIDING);
  3473. clif_displaymessage(fd, msg_txt(102)); // You have mounted a Peco Peco.
  3474. } else {//Dismount
  3475. pc_setoption(sd, sd->sc.option & ~OPTION_RIDING);
  3476. clif_displaymessage(fd, msg_txt(214)); // You have released your Peco Peco.
  3477. }
  3478. return 0;
  3479. }
  3480. /*==========================================
  3481. *Spy Commands by Syrus22
  3482. *------------------------------------------*/
  3483. ACMD_FUNC(guildspy)
  3484. {
  3485. char guild_name[NAME_LENGTH];
  3486. struct guild *g;
  3487. nullpo_retr(-1, sd);
  3488. memset(guild_name, '\0', sizeof(guild_name));
  3489. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3490. if (!enable_spy)
  3491. {
  3492. clif_displaymessage(fd, msg_txt(1125)); // The mapserver has spy command support disabled.
  3493. return -1;
  3494. }
  3495. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  3496. clif_displaymessage(fd, msg_txt(1126)); // Please enter a guild name/ID (usage: @guildspy <guild_name/ID>).
  3497. return -1;
  3498. }
  3499. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  3500. (g = guild_search(atoi(message))) != NULL) {
  3501. if (sd->guildspy == g->guild_id) {
  3502. sd->guildspy = 0;
  3503. sprintf(atcmd_output, msg_txt(103), g->name); // No longer spying on the %s guild.
  3504. clif_displaymessage(fd, atcmd_output);
  3505. } else {
  3506. sd->guildspy = g->guild_id;
  3507. sprintf(atcmd_output, msg_txt(104), g->name); // Spying on the %s guild.
  3508. clif_displaymessage(fd, atcmd_output);
  3509. }
  3510. } else {
  3511. clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the specified guild is online.
  3512. return -1;
  3513. }
  3514. return 0;
  3515. }
  3516. /*==========================================
  3517. *
  3518. *------------------------------------------*/
  3519. ACMD_FUNC(partyspy)
  3520. {
  3521. char party_name[NAME_LENGTH];
  3522. struct party_data *p;
  3523. nullpo_retr(-1, sd);
  3524. memset(party_name, '\0', sizeof(party_name));
  3525. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3526. if (!enable_spy)
  3527. {
  3528. clif_displaymessage(fd, msg_txt(1125)); // The mapserver has spy command support disabled.
  3529. return -1;
  3530. }
  3531. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3532. clif_displaymessage(fd, msg_txt(1127)); // Please enter a party name/ID (usage: @partyspy <party_name/ID>).
  3533. return -1;
  3534. }
  3535. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  3536. (p = party_search(atoi(message))) != NULL) {
  3537. if (sd->partyspy == p->party.party_id) {
  3538. sd->partyspy = 0;
  3539. sprintf(atcmd_output, msg_txt(105), p->party.name); // No longer spying on the %s party.
  3540. clif_displaymessage(fd, atcmd_output);
  3541. } else {
  3542. sd->partyspy = p->party.party_id;
  3543. sprintf(atcmd_output, msg_txt(106), p->party.name); // Spying on the %s party.
  3544. clif_displaymessage(fd, atcmd_output);
  3545. }
  3546. } else {
  3547. clif_displaymessage(fd, msg_txt(96)); // Incorrect name/ID, or no one from the specified party is online.
  3548. return -1;
  3549. }
  3550. return 0;
  3551. }
  3552. /*==========================================
  3553. * @repairall [Valaris]
  3554. *------------------------------------------*/
  3555. ACMD_FUNC(repairall)
  3556. {
  3557. int count, i;
  3558. nullpo_retr(-1, sd);
  3559. count = 0;
  3560. for (i = 0; i < MAX_INVENTORY; i++) {
  3561. if (sd->status.inventory[i].nameid && sd->status.inventory[i].attribute == 1) {
  3562. sd->status.inventory[i].attribute = 0;
  3563. clif_produceeffect(sd, 0, sd->status.inventory[i].nameid);
  3564. count++;
  3565. }
  3566. }
  3567. if (count > 0) {
  3568. clif_misceffect(&sd->bl, 3);
  3569. clif_equiplist(sd);
  3570. clif_displaymessage(fd, msg_txt(107)); // All items have been repaired.
  3571. } else {
  3572. clif_displaymessage(fd, msg_txt(108)); // No item need to be repaired.
  3573. return -1;
  3574. }
  3575. return 0;
  3576. }
  3577. /*==========================================
  3578. * @nuke [Valaris]
  3579. *------------------------------------------*/
  3580. ACMD_FUNC(nuke)
  3581. {
  3582. struct map_session_data *pl_sd;
  3583. nullpo_retr(-1, sd);
  3584. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3585. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3586. clif_displaymessage(fd, msg_txt(1128)); // Please enter a player name (usage: @nuke <char name>).
  3587. return -1;
  3588. }
  3589. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  3590. if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kill only lower or same GM level
  3591. skill_castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
  3592. clif_displaymessage(fd, msg_txt(109)); // Player has been nuked!
  3593. } else {
  3594. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  3595. return -1;
  3596. }
  3597. } else {
  3598. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  3599. return -1;
  3600. }
  3601. return 0;
  3602. }
  3603. /*==========================================
  3604. * @tonpc
  3605. *------------------------------------------*/
  3606. ACMD_FUNC(tonpc)
  3607. {
  3608. char npcname[NAME_LENGTH+1];
  3609. struct npc_data *nd;
  3610. nullpo_retr(-1, sd);
  3611. memset(npcname, 0, sizeof(npcname));
  3612. if (!message || !*message || sscanf(message, "%23[^\n]", npcname) < 1) {
  3613. clif_displaymessage(fd, msg_txt(1129)); // Please enter a NPC name (usage: @tonpc <NPC_name>).
  3614. return -1;
  3615. }
  3616. if ((nd = npc_name2id(npcname)) != NULL) {
  3617. if (pc_setpos(sd, map_id2index(nd->bl.m), nd->bl.x, nd->bl.y, CLR_TELEPORT) == 0)
  3618. clif_displaymessage(fd, msg_txt(0)); // Warped.
  3619. else
  3620. return -1;
  3621. } else {
  3622. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  3623. return -1;
  3624. }
  3625. return 0;
  3626. }
  3627. /*==========================================
  3628. *
  3629. *------------------------------------------*/
  3630. ACMD_FUNC(shownpc)
  3631. {
  3632. char NPCname[NAME_LENGTH+1];
  3633. nullpo_retr(-1, sd);
  3634. memset(NPCname, '\0', sizeof(NPCname));
  3635. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  3636. clif_displaymessage(fd, msg_txt(1130)); // Please enter a NPC name (usage: @enablenpc <NPC_name>).
  3637. return -1;
  3638. }
  3639. if (npc_name2id(NPCname) != NULL) {
  3640. npc_enable(NPCname, 1);
  3641. clif_displaymessage(fd, msg_txt(110)); // Npc Enabled.
  3642. } else {
  3643. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  3644. return -1;
  3645. }
  3646. return 0;
  3647. }
  3648. /*==========================================
  3649. *
  3650. *------------------------------------------*/
  3651. ACMD_FUNC(hidenpc)
  3652. {
  3653. char NPCname[NAME_LENGTH+1];
  3654. nullpo_retr(-1, sd);
  3655. memset(NPCname, '\0', sizeof(NPCname));
  3656. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  3657. clif_displaymessage(fd, msg_txt(1131)); // Please enter a NPC name (usage: @hidenpc <NPC_name>).
  3658. return -1;
  3659. }
  3660. if (npc_name2id(NPCname) == NULL) {
  3661. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  3662. return -1;
  3663. }
  3664. npc_enable(NPCname, 0);
  3665. clif_displaymessage(fd, msg_txt(112)); // Npc Disabled.
  3666. return 0;
  3667. }
  3668. ACMD_FUNC(loadnpc)
  3669. {
  3670. FILE *fp;
  3671. if (!message || !*message) {
  3672. clif_displaymessage(fd, msg_txt(1132)); // Please enter a script file name (usage: @loadnpc <file name>).
  3673. return -1;
  3674. }
  3675. // check if script file exists
  3676. if ((fp = fopen(message, "r")) == NULL) {
  3677. clif_displaymessage(fd, msg_txt(261));
  3678. return -1;
  3679. }
  3680. fclose(fp);
  3681. // add to list of script sources and run it
  3682. npc_addsrcfile(message);
  3683. npc_parsesrcfile(message,true);
  3684. npc_read_event_script();
  3685. clif_displaymessage(fd, msg_txt(262));
  3686. return 0;
  3687. }
  3688. ACMD_FUNC(unloadnpc)
  3689. {
  3690. struct npc_data *nd;
  3691. char NPCname[NAME_LENGTH+1];
  3692. nullpo_retr(-1, sd);
  3693. memset(NPCname, '\0', sizeof(NPCname));
  3694. if (!message || !*message || sscanf(message, "%24[^\n]", NPCname) < 1) {
  3695. clif_displaymessage(fd, msg_txt(1133)); // Please enter a NPC name (usage: @npcoff <NPC_name>).
  3696. return -1;
  3697. }
  3698. if ((nd = npc_name2id(NPCname)) == NULL) {
  3699. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  3700. return -1;
  3701. }
  3702. npc_unload_duplicates(nd);
  3703. npc_unload(nd,true);
  3704. npc_read_event_script();
  3705. clif_displaymessage(fd, msg_txt(112)); // Npc Disabled.
  3706. return 0;
  3707. }
  3708. /*==========================================
  3709. * time in txt for time command (by [Yor])
  3710. *------------------------------------------*/
  3711. char* txt_time(unsigned int duration)
  3712. {
  3713. int days, hours, minutes, seconds;
  3714. char temp[CHAT_SIZE_MAX];
  3715. static char temp1[CHAT_SIZE_MAX];
  3716. memset(temp, '\0', sizeof(temp));
  3717. memset(temp1, '\0', sizeof(temp1));
  3718. days = duration / (60 * 60 * 24);
  3719. duration = duration - (60 * 60 * 24 * days);
  3720. hours = duration / (60 * 60);
  3721. duration = duration - (60 * 60 * hours);
  3722. minutes = duration / 60;
  3723. seconds = duration - (60 * minutes);
  3724. if (days == 1)
  3725. sprintf(temp, msg_txt(219), days); // %d day
  3726. else if (days > 1)
  3727. sprintf(temp, msg_txt(220), days); // %d days
  3728. if (hours == 1)
  3729. sprintf(temp1, msg_txt(221), temp, hours); // %s %d hour
  3730. else if (hours > 1)
  3731. sprintf(temp1, msg_txt(222), temp, hours); // %s %d hours
  3732. if (minutes < 2)
  3733. sprintf(temp, msg_txt(223), temp1, minutes); // %s %d minute
  3734. else
  3735. sprintf(temp, msg_txt(224), temp1, minutes); // %s %d minutes
  3736. if (seconds == 1)
  3737. sprintf(temp1, msg_txt(225), temp, seconds); // %s and %d second
  3738. else if (seconds > 1)
  3739. sprintf(temp1, msg_txt(226), temp, seconds); // %s and %d seconds
  3740. return temp1;
  3741. }
  3742. /*==========================================
  3743. * @time/@date/@serverdate/@servertime: Display the date/time of the server (by [Yor]
  3744. * Calculation management of GM modification (@day/@night GM commands) is done
  3745. *------------------------------------------*/
  3746. ACMD_FUNC(servertime)
  3747. {
  3748. const struct TimerData * timer_data;
  3749. const struct TimerData * timer_data2;
  3750. time_t time_server; // variable for number of seconds (used with time() function)
  3751. struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
  3752. char temp[CHAT_SIZE_MAX];
  3753. nullpo_retr(-1, sd);
  3754. memset(temp, '\0', sizeof(temp));
  3755. time(&time_server); // get time in seconds since 1/1/1970
  3756. datetime = localtime(&time_server); // convert seconds in structure
  3757. // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
  3758. strftime(temp, sizeof(temp)-1, msg_txt(230), datetime); // Server time (normal time): %A, %B %d %Y %X.
  3759. clif_displaymessage(fd, temp);
  3760. if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
  3761. if (night_flag == 0)
  3762. clif_displaymessage(fd, msg_txt(231)); // Game time: The game is in permanent daylight.
  3763. else
  3764. clif_displaymessage(fd, msg_txt(232)); // Game time: The game is in permanent night.
  3765. } else if (battle_config.night_duration == 0)
  3766. if (night_flag == 1) { // we start with night
  3767. timer_data = get_timer(day_timer_tid);
  3768. sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in night for %s.
  3769. clif_displaymessage(fd, temp);
  3770. clif_displaymessage(fd, msg_txt(234)); // Game time: After, the game will be in permanent daylight.
  3771. } else
  3772. clif_displaymessage(fd, msg_txt(231)); // Game time: The game is in permanent daylight.
  3773. else if (battle_config.day_duration == 0)
  3774. if (night_flag == 0) { // we start with day
  3775. timer_data = get_timer(night_timer_tid);
  3776. sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  3777. clif_displaymessage(fd, temp);
  3778. clif_displaymessage(fd, msg_txt(236)); // Game time: After, the game will be in permanent night.
  3779. } else
  3780. clif_displaymessage(fd, msg_txt(232)); // Game time: The game is in permanent night.
  3781. else {
  3782. if (night_flag == 0) {
  3783. timer_data = get_timer(night_timer_tid);
  3784. timer_data2 = get_timer(day_timer_tid);
  3785. sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  3786. clif_displaymessage(fd, temp);
  3787. if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0)
  3788. sprintf(temp, msg_txt(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.
  3789. else
  3790. sprintf(temp, msg_txt(237), txt_time(DIFF_TICK(timer_data2->tick,timer_data->tick)/1000)); // Game time: After, the game will be in night for %s.
  3791. clif_displaymessage(fd, temp);
  3792. sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  3793. clif_displaymessage(fd, temp);
  3794. } else {
  3795. timer_data = get_timer(day_timer_tid);
  3796. timer_data2 = get_timer(night_timer_tid);
  3797. sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,gettick()) / 1000)); // Game time: The game is actualy in night for %s.
  3798. clif_displaymessage(fd, temp);
  3799. if (DIFF_TICK(timer_data->tick,timer_data2->tick) > 0)
  3800. sprintf(temp, msg_txt(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.
  3801. else
  3802. sprintf(temp, msg_txt(239), txt_time(DIFF_TICK(timer_data2->tick, timer_data->tick) / 1000)); // Game time: After, the game will be in daylight for %s.
  3803. clif_displaymessage(fd, temp);
  3804. sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  3805. clif_displaymessage(fd, temp);
  3806. }
  3807. }
  3808. return 0;
  3809. }
  3810. //Added by Coltaro
  3811. //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...).
  3812. //Well, using time_t could still work but for some reason that looks like more coding x_x
  3813. static void get_jail_time(int jailtime, int* year, int* month, int* day, int* hour, int* minute)
  3814. {
  3815. const int factor_year = 518400; //12*30*24*60 = 518400
  3816. const int factor_month = 43200; //30*24*60 = 43200
  3817. const int factor_day = 1440; //24*60 = 1440
  3818. const int factor_hour = 60;
  3819. *year = jailtime/factor_year;
  3820. jailtime -= *year*factor_year;
  3821. *month = jailtime/factor_month;
  3822. jailtime -= *month*factor_month;
  3823. *day = jailtime/factor_day;
  3824. jailtime -= *day*factor_day;
  3825. *hour = jailtime/factor_hour;
  3826. jailtime -= *hour*factor_hour;
  3827. *minute = jailtime;
  3828. *year = *year > 0? *year : 0;
  3829. *month = *month > 0? *month : 0;
  3830. *day = *day > 0? *day : 0;
  3831. *hour = *hour > 0? *hour : 0;
  3832. *minute = *minute > 0? *minute : 0;
  3833. return;
  3834. }
  3835. /*==========================================
  3836. * @jail <char_name> by [Yor]
  3837. * Special warp! No check with nowarp and nowarpto flag
  3838. *------------------------------------------*/
  3839. ACMD_FUNC(jail)
  3840. {
  3841. struct map_session_data *pl_sd;
  3842. int x, y;
  3843. unsigned short m_index;
  3844. nullpo_retr(-1, sd);
  3845. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3846. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3847. clif_displaymessage(fd, msg_txt(1134)); // Please enter a player name (usage: @jail <char_name>).
  3848. return -1;
  3849. }
  3850. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  3851. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  3852. return -1;
  3853. }
  3854. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd))
  3855. { // you can jail only lower or same GM
  3856. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  3857. return -1;
  3858. }
  3859. if (pl_sd->sc.data[SC_JAILED])
  3860. {
  3861. clif_displaymessage(fd, msg_txt(118)); // Player warped in jails.
  3862. return -1;
  3863. }
  3864. switch(rnd() % 2) { //Jail Locations
  3865. case 0:
  3866. m_index = mapindex_name2id(MAP_JAIL);
  3867. x = 24;
  3868. y = 75;
  3869. break;
  3870. default:
  3871. m_index = mapindex_name2id(MAP_JAIL);
  3872. x = 49;
  3873. y = 75;
  3874. break;
  3875. }
  3876. //Duration of INT_MAX to specify infinity.
  3877. sc_start4(NULL,&pl_sd->bl,SC_JAILED,100,INT_MAX,m_index,x,y,1000);
  3878. clif_displaymessage(pl_sd->fd, msg_txt(117)); // GM has send you in jails.
  3879. clif_displaymessage(fd, msg_txt(118)); // Player warped in jails.
  3880. return 0;
  3881. }
  3882. /*==========================================
  3883. * @unjail/@discharge <char_name> by [Yor]
  3884. * Special warp! No check with nowarp and nowarpto flag
  3885. *------------------------------------------*/
  3886. ACMD_FUNC(unjail)
  3887. {
  3888. struct map_session_data *pl_sd;
  3889. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3890. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3891. clif_displaymessage(fd, msg_txt(1135)); // Please enter a player name (usage: @unjail/@discharge <char_name>).
  3892. return -1;
  3893. }
  3894. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  3895. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  3896. return -1;
  3897. }
  3898. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) { // you can jail only lower or same GM
  3899. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  3900. return -1;
  3901. }
  3902. if (!pl_sd->sc.data[SC_JAILED])
  3903. {
  3904. clif_displaymessage(fd, msg_txt(119)); // This player is not in jails.
  3905. return -1;
  3906. }
  3907. //Reset jail time to 1 sec.
  3908. sc_start(NULL,&pl_sd->bl,SC_JAILED,100,1,1000);
  3909. clif_displaymessage(pl_sd->fd, msg_txt(120)); // A GM has discharged you from jail.
  3910. clif_displaymessage(fd, msg_txt(121)); // Player unjailed.
  3911. return 0;
  3912. }
  3913. ACMD_FUNC(jailfor)
  3914. {
  3915. struct map_session_data *pl_sd = NULL;
  3916. int year, month, day, hour, minute, value;
  3917. char * modif_p;
  3918. int jailtime = 0,x,y;
  3919. short m_index = 0;
  3920. nullpo_retr(-1, sd);
  3921. if (!message || !*message || sscanf(message, "%255s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
  3922. clif_displaymessage(fd, msg_txt(400)); //Usage: @jailfor <time> <character name>
  3923. return -1;
  3924. }
  3925. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  3926. modif_p = atcmd_output;
  3927. year = month = day = hour = minute = 0;
  3928. while (modif_p[0] != '\0') {
  3929. value = atoi(modif_p);
  3930. if (value == 0)
  3931. modif_p++;
  3932. else {
  3933. if (modif_p[0] == '-' || modif_p[0] == '+')
  3934. modif_p++;
  3935. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  3936. modif_p++;
  3937. if (modif_p[0] == 'n') {
  3938. minute = value;
  3939. modif_p++;
  3940. } else if (modif_p[0] == 'm' && modif_p[1] == 'n') {
  3941. minute = value;
  3942. modif_p = modif_p + 2;
  3943. } else if (modif_p[0] == 'h') {
  3944. hour = value;
  3945. modif_p++;
  3946. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  3947. day = value;
  3948. modif_p++;
  3949. } else if (modif_p[0] == 'm') {
  3950. month = value;
  3951. modif_p++;
  3952. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  3953. year = value;
  3954. modif_p++;
  3955. } else if (modif_p[0] != '\0') {
  3956. modif_p++;
  3957. }
  3958. }
  3959. }
  3960. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0) {
  3961. clif_displaymessage(fd, msg_txt(1136)); // Invalid time for jail command.
  3962. return -1;
  3963. }
  3964. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  3965. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  3966. return -1;
  3967. }
  3968. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  3969. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  3970. return -1;
  3971. }
  3972. jailtime = year*12*30*24*60 + month*30*24*60 + day*24*60 + hour*60 + minute; //In minutes
  3973. if(jailtime==0) {
  3974. clif_displaymessage(fd, msg_txt(1136)); // Invalid time for jail command.
  3975. return -1;
  3976. }
  3977. //Added by Coltaro
  3978. if(pl_sd->sc.data[SC_JAILED] &&
  3979. pl_sd->sc.data[SC_JAILED]->val1 != INT_MAX)
  3980. { //Update the player's jail time
  3981. jailtime += pl_sd->sc.data[SC_JAILED]->val1;
  3982. if (jailtime <= 0) {
  3983. jailtime = 0;
  3984. clif_displaymessage(pl_sd->fd, msg_txt(120)); // GM has discharge you.
  3985. clif_displaymessage(fd, msg_txt(121)); // Player unjailed
  3986. } else {
  3987. get_jail_time(jailtime,&year,&month,&day,&hour,&minute);
  3988. sprintf(atcmd_output,msg_txt(402),msg_txt(1137),year,month,day,hour,minute); //%s in jail for %d years, %d months, %d days, %d hours and %d minutes
  3989. clif_displaymessage(pl_sd->fd, atcmd_output);
  3990. sprintf(atcmd_output,msg_txt(402),msg_txt(1138),year,month,day,hour,minute); //This player is now in jail for %d years, %d months, %d days, %d hours and %d minutes
  3991. clif_displaymessage(fd, atcmd_output);
  3992. }
  3993. } else if (jailtime < 0) {
  3994. clif_displaymessage(fd, msg_txt(1136));
  3995. return -1;
  3996. }
  3997. //Jail locations, add more as you wish.
  3998. switch(rnd()%2)
  3999. {
  4000. case 1: //Jail #1
  4001. m_index = mapindex_name2id(MAP_JAIL);
  4002. x = 49; y = 75;
  4003. break;
  4004. default: //Default Jail
  4005. m_index = mapindex_name2id(MAP_JAIL);
  4006. x = 24; y = 75;
  4007. break;
  4008. }
  4009. 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).
  4010. return 0;
  4011. }
  4012. //By Coltaro
  4013. ACMD_FUNC(jailtime)
  4014. {
  4015. int year, month, day, hour, minute;
  4016. nullpo_retr(-1, sd);
  4017. if (!sd->sc.data[SC_JAILED]) {
  4018. clif_displaymessage(fd, msg_txt(1139)); // You are not in jail.
  4019. return -1;
  4020. }
  4021. if (sd->sc.data[SC_JAILED]->val1 == INT_MAX) {
  4022. clif_displaymessage(fd, msg_txt(1140)); // You have been jailed indefinitely.
  4023. return 0;
  4024. }
  4025. if (sd->sc.data[SC_JAILED]->val1 <= 0) { // Was not jailed with @jailfor (maybe @jail? or warped there? or got recalled?)
  4026. clif_displaymessage(fd, msg_txt(1141)); // You have been jailed for an unknown amount of time.
  4027. return -1;
  4028. }
  4029. //Get remaining jail time
  4030. get_jail_time(sd->sc.data[SC_JAILED]->val1,&year,&month,&day,&hour,&minute);
  4031. sprintf(atcmd_output,msg_txt(402),msg_txt(1142),year,month,day,hour,minute); // You will remain in jail for %d years, %d months, %d days, %d hours and %d minutes
  4032. clif_displaymessage(fd, atcmd_output);
  4033. return 0;
  4034. }
  4035. /*==========================================
  4036. * @disguise <mob_id> by [Valaris] (simplified by [Yor])
  4037. *------------------------------------------*/
  4038. ACMD_FUNC(disguise)
  4039. {
  4040. int id = 0;
  4041. nullpo_retr(-1, sd);
  4042. if (!message || !*message) {
  4043. clif_displaymessage(fd, msg_txt(1143)); // Please enter a Monster/NPC name/ID (usage: @disguise <name/ID>).
  4044. return -1;
  4045. }
  4046. if ((id = atoi(message)) > 0)
  4047. { //Acquired an ID
  4048. if (!mobdb_checkid(id) && !npcdb_checkid(id))
  4049. id = 0; //Invalid id for either mobs or npcs.
  4050. } else { //Acquired a Name
  4051. if ((id = mobdb_searchname(message)) == 0)
  4052. {
  4053. struct npc_data* nd = npc_name2id(message);
  4054. if (nd != NULL)
  4055. id = nd->class_;
  4056. }
  4057. }
  4058. if (id == 0)
  4059. {
  4060. clif_displaymessage(fd, msg_txt(123)); // Invalid Monster/NPC name/ID specified.
  4061. return -1;
  4062. }
  4063. if(pc_isriding(sd))
  4064. {
  4065. clif_displaymessage(fd, msg_txt(1144)); // Character cannot be disguised while mounted.
  4066. return -1;
  4067. }
  4068. pc_disguise(sd, id);
  4069. clif_displaymessage(fd, msg_txt(122)); // Disguise applied.
  4070. return 0;
  4071. }
  4072. /*==========================================
  4073. * DisguiseAll
  4074. *------------------------------------------*/
  4075. ACMD_FUNC(disguiseall)
  4076. {
  4077. int mob_id=0;
  4078. struct map_session_data *pl_sd;
  4079. struct s_mapiterator* iter;
  4080. nullpo_retr(-1, sd);
  4081. if (!message || !*message) {
  4082. clif_displaymessage(fd, msg_txt(1145)); // Please enter a Monster/NPC name/ID (usage: @disguiseall <name/ID>).
  4083. return -1;
  4084. }
  4085. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name begining by a number)
  4086. mob_id = atoi(message);
  4087. if (!mobdb_checkid(mob_id) && !npcdb_checkid(mob_id)) { //if mob or npc...
  4088. clif_displaymessage(fd, msg_txt(123)); // Monster/NPC name/id not found.
  4089. return -1;
  4090. }
  4091. iter = mapit_getallusers();
  4092. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4093. pc_disguise(pl_sd, mob_id);
  4094. mapit_free(iter);
  4095. clif_displaymessage(fd, msg_txt(122)); // Disguise applied.
  4096. return 0;
  4097. }
  4098. /*==========================================
  4099. * DisguiseGuild
  4100. *------------------------------------------*/
  4101. ACMD_FUNC(disguiseguild)
  4102. {
  4103. int id = 0, i;
  4104. char monster[NAME_LENGTH], guild[NAME_LENGTH];
  4105. struct map_session_data *pl_sd;
  4106. struct guild *g;
  4107. memset(monster, '\0', sizeof(monster));
  4108. memset(guild, '\0', sizeof(guild));
  4109. if( !message || !*message || sscanf(message, "%23[^,], %23[^\r\n]", monster, guild) < 2 ) {
  4110. clif_displaymessage(fd, msg_txt(1146)); // Please enter a mob name/ID and guild name/ID (usage: @disguiseguild <mob name/ID>, <guild name/ID>).
  4111. return -1;
  4112. }
  4113. if( (id = atoi(monster)) > 0 ) {
  4114. if( !mobdb_checkid(id) && !npcdb_checkid(id) )
  4115. id = 0;
  4116. } else {
  4117. if( (id = mobdb_searchname(monster)) == 0 ) {
  4118. struct npc_data* nd = npc_name2id(monster);
  4119. if( nd != NULL )
  4120. id = nd->class_;
  4121. }
  4122. }
  4123. if( id == 0 ) {
  4124. clif_displaymessage(fd, msg_txt(123)); // Monster/NPC name/id hasn't been found.
  4125. return -1;
  4126. }
  4127. if( (g = guild_searchname(guild)) == NULL && (g = guild_search(atoi(guild))) == NULL ) {
  4128. clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online.
  4129. return -1;
  4130. }
  4131. for( i = 0; i < g->max_member; i++ )
  4132. if( (pl_sd = g->member[i].sd) && !pc_isriding(pl_sd) )
  4133. pc_disguise(pl_sd, id);
  4134. clif_displaymessage(fd, msg_txt(122)); // Disguise applied.
  4135. return 0;
  4136. }
  4137. /*==========================================
  4138. * @undisguise by [Yor]
  4139. *------------------------------------------*/
  4140. ACMD_FUNC(undisguise)
  4141. {
  4142. nullpo_retr(-1, sd);
  4143. if (sd->disguise) {
  4144. pc_disguise(sd, 0);
  4145. clif_displaymessage(fd, msg_txt(124)); // Undisguise applied.
  4146. } else {
  4147. clif_displaymessage(fd, msg_txt(125)); // You're not disguised.
  4148. return -1;
  4149. }
  4150. return 0;
  4151. }
  4152. /*==========================================
  4153. * UndisguiseAll
  4154. *------------------------------------------*/
  4155. ACMD_FUNC(undisguiseall)
  4156. {
  4157. struct map_session_data *pl_sd;
  4158. struct s_mapiterator* iter;
  4159. nullpo_retr(-1, sd);
  4160. iter = mapit_getallusers();
  4161. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4162. if( pl_sd->disguise )
  4163. pc_disguise(pl_sd, 0);
  4164. mapit_free(iter);
  4165. clif_displaymessage(fd, msg_txt(124)); // Undisguise applied.
  4166. return 0;
  4167. }
  4168. /*==========================================
  4169. * UndisguiseGuild
  4170. *------------------------------------------*/
  4171. ACMD_FUNC(undisguiseguild)
  4172. {
  4173. char guild_name[NAME_LENGTH];
  4174. struct map_session_data *pl_sd;
  4175. struct guild *g;
  4176. int i;
  4177. nullpo_retr(-1, sd);
  4178. memset(guild_name, '\0', sizeof(guild_name));
  4179. if(!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  4180. clif_displaymessage(fd, msg_txt(1147)); // Please enter guild name/ID (usage: @undisguiseguild <guild name/ID>).
  4181. return -1;
  4182. }
  4183. if( (g = guild_searchname(guild_name)) == NULL && (g = guild_search(atoi(message))) == NULL ) {
  4184. clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online.
  4185. return -1;
  4186. }
  4187. for(i = 0; i < g->max_member; i++)
  4188. if( (pl_sd = g->member[i].sd) && pl_sd->disguise )
  4189. pc_disguise(pl_sd, 0);
  4190. clif_displaymessage(fd, msg_txt(124)); // Undisguise applied.
  4191. return 0;
  4192. }
  4193. /*==========================================
  4194. * @exp by [Skotlex]
  4195. *------------------------------------------*/
  4196. ACMD_FUNC(exp)
  4197. {
  4198. char output[CHAT_SIZE_MAX];
  4199. double nextb, nextj;
  4200. nullpo_retr(-1, sd);
  4201. memset(output, '\0', sizeof(output));
  4202. nextb = pc_nextbaseexp(sd);
  4203. if (nextb)
  4204. nextb = sd->status.base_exp*100.0/nextb;
  4205. nextj = pc_nextjobexp(sd);
  4206. if (nextj)
  4207. nextj = sd->status.job_exp*100.0/nextj;
  4208. sprintf(output, msg_txt(1148), sd->status.base_level, nextb, sd->status.job_level, nextj); // Base Level: %d (%.3f%%) | Job Level: %d (%.3f%%)
  4209. clif_displaymessage(fd, output);
  4210. return 0;
  4211. }
  4212. /*==========================================
  4213. * @broadcast by [Valaris]
  4214. *------------------------------------------*/
  4215. ACMD_FUNC(broadcast)
  4216. {
  4217. nullpo_retr(-1, sd);
  4218. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4219. if (!message || !*message) {
  4220. clif_displaymessage(fd, msg_txt(1149)); // Please enter a message (usage: @broadcast <message>).
  4221. return -1;
  4222. }
  4223. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4224. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, 0);
  4225. return 0;
  4226. }
  4227. /*==========================================
  4228. * @localbroadcast by [Valaris]
  4229. *------------------------------------------*/
  4230. ACMD_FUNC(localbroadcast)
  4231. {
  4232. nullpo_retr(-1, sd);
  4233. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4234. if (!message || !*message) {
  4235. clif_displaymessage(fd, msg_txt(1150)); // Please enter a message (usage: @localbroadcast <message>).
  4236. return -1;
  4237. }
  4238. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4239. clif_broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, 0, ALL_SAMEMAP);
  4240. return 0;
  4241. }
  4242. /*==========================================
  4243. * @email <actual@email> <new@email> by [Yor]
  4244. *------------------------------------------*/
  4245. ACMD_FUNC(email)
  4246. {
  4247. char actual_email[100];
  4248. char new_email[100];
  4249. nullpo_retr(-1, sd);
  4250. memset(actual_email, '\0', sizeof(actual_email));
  4251. memset(new_email, '\0', sizeof(new_email));
  4252. if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
  4253. clif_displaymessage(fd, msg_txt(1151)); // Please enter 2 emails (usage: @email <actual@email> <new@email>).
  4254. return -1;
  4255. }
  4256. if (e_mail_check(actual_email) == 0) {
  4257. clif_displaymessage(fd, msg_txt(144)); // Invalid actual email. If you have default e-mail, give a@a.com.
  4258. return -1;
  4259. } else if (e_mail_check(new_email) == 0) {
  4260. clif_displaymessage(fd, msg_txt(145)); // Invalid new email. Please enter a real e-mail.
  4261. return -1;
  4262. } else if (strcmpi(new_email, "a@a.com") == 0) {
  4263. clif_displaymessage(fd, msg_txt(146)); // New email must be a real e-mail.
  4264. return -1;
  4265. } else if (strcmpi(actual_email, new_email) == 0) {
  4266. clif_displaymessage(fd, msg_txt(147)); // New email must be different of the actual e-mail.
  4267. return -1;
  4268. }
  4269. chrif_changeemail(sd->status.account_id, actual_email, new_email);
  4270. clif_displaymessage(fd, msg_txt(148)); // Information sended to login-server via char-server.
  4271. return 0;
  4272. }
  4273. /*==========================================
  4274. *@effect
  4275. *------------------------------------------*/
  4276. ACMD_FUNC(effect)
  4277. {
  4278. int type = 0, flag = 0;
  4279. nullpo_retr(-1, sd);
  4280. if (!message || !*message || sscanf(message, "%d", &type) < 1) {
  4281. clif_displaymessage(fd, msg_txt(1152)); // Please enter an effect number (usage: @effect <effect number>).
  4282. return -1;
  4283. }
  4284. clif_specialeffect(&sd->bl, type, (send_target)flag);
  4285. clif_displaymessage(fd, msg_txt(229)); // Your effect has changed.
  4286. return 0;
  4287. }
  4288. /*==========================================
  4289. * @killer by MouseJstr
  4290. * enable killing players even when not in pvp
  4291. *------------------------------------------*/
  4292. ACMD_FUNC(killer)
  4293. {
  4294. nullpo_retr(-1, sd);
  4295. sd->state.killer = !sd->state.killer;
  4296. if(sd->state.killer)
  4297. clif_displaymessage(fd, msg_txt(241));
  4298. else {
  4299. clif_displaymessage(fd, msg_txt(292));
  4300. pc_stop_attack(sd);
  4301. }
  4302. return 0;
  4303. }
  4304. /*==========================================
  4305. * @killable by MouseJstr
  4306. * enable other people killing you
  4307. *------------------------------------------*/
  4308. ACMD_FUNC(killable)
  4309. {
  4310. nullpo_retr(-1, sd);
  4311. sd->state.killable = !sd->state.killable;
  4312. if(sd->state.killable)
  4313. clif_displaymessage(fd, msg_txt(242));
  4314. else {
  4315. clif_displaymessage(fd, msg_txt(288));
  4316. map_foreachinrange(atcommand_stopattack,&sd->bl, AREA_SIZE, BL_CHAR, sd->bl.id);
  4317. }
  4318. return 0;
  4319. }
  4320. /*==========================================
  4321. * @skillon by MouseJstr
  4322. * turn skills on for the map
  4323. *------------------------------------------*/
  4324. ACMD_FUNC(skillon)
  4325. {
  4326. nullpo_retr(-1, sd);
  4327. map[sd->bl.m].flag.noskill = 0;
  4328. clif_displaymessage(fd, msg_txt(244));
  4329. return 0;
  4330. }
  4331. /*==========================================
  4332. * @skilloff by MouseJstr
  4333. * Turn skills off on the map
  4334. *------------------------------------------*/
  4335. ACMD_FUNC(skilloff)
  4336. {
  4337. nullpo_retr(-1, sd);
  4338. map[sd->bl.m].flag.noskill = 1;
  4339. clif_displaymessage(fd, msg_txt(243));
  4340. return 0;
  4341. }
  4342. /*==========================================
  4343. * @npcmove by MouseJstr
  4344. * move a npc
  4345. *------------------------------------------*/
  4346. ACMD_FUNC(npcmove)
  4347. {
  4348. int x = 0, y = 0, m;
  4349. struct npc_data *nd = 0;
  4350. nullpo_retr(-1, sd);
  4351. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  4352. if (!message || !*message || sscanf(message, "%d %d %23[^\n]", &x, &y, atcmd_player_name) < 3) {
  4353. clif_displaymessage(fd, msg_txt(1153)); // Usage: @npcmove <X> <Y> <npc_name>
  4354. return -1;
  4355. }
  4356. if ((nd = npc_name2id(atcmd_player_name)) == NULL)
  4357. {
  4358. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4359. return -1;
  4360. }
  4361. if ((m=nd->bl.m) < 0 || nd->bl.prev == NULL)
  4362. {
  4363. clif_displaymessage(fd, msg_txt(1154)); // NPC is not on this map.
  4364. return -1; //Not on a map.
  4365. }
  4366. x = cap_value(x, 0, map[m].xs-1);
  4367. y = cap_value(y, 0, map[m].ys-1);
  4368. map_foreachinrange(clif_outsight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  4369. map_moveblock(&nd->bl, x, y, gettick());
  4370. map_foreachinrange(clif_insight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  4371. clif_displaymessage(fd, msg_txt(1155)); // NPC moved.
  4372. return 0;
  4373. }
  4374. /*==========================================
  4375. * @addwarp by MouseJstr
  4376. * Create a new static warp point.
  4377. *------------------------------------------*/
  4378. ACMD_FUNC(addwarp)
  4379. {
  4380. char mapname[32], warpname[NAME_LENGTH+1];
  4381. int x,y;
  4382. unsigned short m;
  4383. struct npc_data* nd;
  4384. nullpo_retr(-1, sd);
  4385. memset(warpname, '\0', sizeof(warpname));
  4386. if (!message || !*message || sscanf(message, "%31s %d %d %23[^\n]", mapname, &x, &y, warpname) < 4) {
  4387. clif_displaymessage(fd, msg_txt(1156)); // Usage: @addwarp <mapname> <X> <Y> <npc name>
  4388. return -1;
  4389. }
  4390. m = mapindex_name2id(mapname);
  4391. if( m == 0 )
  4392. {
  4393. sprintf(atcmd_output, msg_txt(1157), mapname); // Unknown map '%s'.
  4394. clif_displaymessage(fd, atcmd_output);
  4395. return -1;
  4396. }
  4397. nd = npc_add_warp(warpname, sd->bl.m, sd->bl.x, sd->bl.y, 2, 2, m, x, y);
  4398. if( nd == NULL )
  4399. return -1;
  4400. sprintf(atcmd_output, msg_txt(1158), nd->exname); // New warp NPC '%s' created.
  4401. clif_displaymessage(fd, atcmd_output);
  4402. return 0;
  4403. }
  4404. /*==========================================
  4405. * @follow by [MouseJstr]
  4406. * Follow a player .. staying no more then 5 spaces away
  4407. *------------------------------------------*/
  4408. ACMD_FUNC(follow)
  4409. {
  4410. struct map_session_data *pl_sd = NULL;
  4411. nullpo_retr(-1, sd);
  4412. if (!message || !*message) {
  4413. if (sd->followtarget == -1)
  4414. return -1;
  4415. pc_stop_following (sd);
  4416. clif_displaymessage(fd, msg_txt(1159)); // Follow mode OFF.
  4417. return 0;
  4418. }
  4419. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  4420. {
  4421. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4422. return -1;
  4423. }
  4424. if (sd->followtarget == pl_sd->bl.id) {
  4425. pc_stop_following (sd);
  4426. clif_displaymessage(fd, msg_txt(1159)); // Follow mode OFF.
  4427. } else {
  4428. pc_follow(sd, pl_sd->bl.id);
  4429. clif_displaymessage(fd, msg_txt(1160)); // Follow mode ON.
  4430. }
  4431. return 0;
  4432. }
  4433. /*==========================================
  4434. * @dropall by [MouseJstr]
  4435. * Drop all your possession on the ground
  4436. *------------------------------------------*/
  4437. ACMD_FUNC(dropall)
  4438. {
  4439. int i;
  4440. nullpo_retr(-1, sd);
  4441. for (i = 0; i < MAX_INVENTORY; i++) {
  4442. if (sd->status.inventory[i].amount) {
  4443. if(sd->status.inventory[i].equip != 0)
  4444. pc_unequipitem(sd, i, 3);
  4445. pc_dropitem(sd, i, sd->status.inventory[i].amount);
  4446. }
  4447. }
  4448. return 0;
  4449. }
  4450. /*==========================================
  4451. * @storeall by [MouseJstr]
  4452. * Put everything into storage
  4453. *------------------------------------------*/
  4454. ACMD_FUNC(storeall)
  4455. {
  4456. int i;
  4457. nullpo_retr(-1, sd);
  4458. if (sd->state.storage_flag != 1)
  4459. { //Open storage.
  4460. if( storage_storageopen(sd) == 1 ) {
  4461. clif_displaymessage(fd, msg_txt(1161)); // You currently cannot open your storage.
  4462. return -1;
  4463. }
  4464. }
  4465. for (i = 0; i < MAX_INVENTORY; i++) {
  4466. if (sd->status.inventory[i].amount) {
  4467. if(sd->status.inventory[i].equip != 0)
  4468. pc_unequipitem(sd, i, 3);
  4469. storage_storageadd(sd, i, sd->status.inventory[i].amount);
  4470. }
  4471. }
  4472. storage_storageclose(sd);
  4473. clif_displaymessage(fd, msg_txt(1162)); // All items stored.
  4474. return 0;
  4475. }
  4476. ACMD_FUNC(clearstorage)
  4477. {
  4478. int i, j;
  4479. nullpo_retr(-1, sd);
  4480. if (sd->state.storage_flag == 1) {
  4481. clif_displaymessage(fd, msg_txt(250));
  4482. return -1;
  4483. }
  4484. j = sd->status.storage.storage_amount;
  4485. for (i = 0; i < j; ++i) {
  4486. storage_delitem(sd, i, sd->status.storage.items[i].amount);
  4487. }
  4488. storage_storageclose(sd);
  4489. clif_displaymessage(fd, msg_txt(1394)); // Your storage was cleaned.
  4490. return 0;
  4491. }
  4492. ACMD_FUNC(cleargstorage)
  4493. {
  4494. int i, j;
  4495. struct guild *g;
  4496. struct guild_storage *gstorage;
  4497. nullpo_retr(-1, sd);
  4498. g = sd->guild;
  4499. if (g == NULL) {
  4500. clif_displaymessage(fd, msg_txt(43));
  4501. return -1;
  4502. }
  4503. if (sd->state.storage_flag == 1) {
  4504. clif_displaymessage(fd, msg_txt(250));
  4505. return -1;
  4506. }
  4507. if (sd->state.storage_flag == 2) {
  4508. clif_displaymessage(fd, msg_txt(251));
  4509. return -1;
  4510. }
  4511. gstorage = guild2storage2(sd->status.guild_id);
  4512. if (gstorage == NULL) {// Doesn't have opened @gstorage yet, so we skip the deletion since *shouldn't* have any item there.
  4513. return -1;
  4514. }
  4515. j = gstorage->storage_amount;
  4516. gstorage->lock = 1; // Lock @gstorage: do not allow any item to be retrieved or stored from any guild member
  4517. for (i = 0; i < j; ++i) {
  4518. guild_storage_delitem(sd, gstorage, i, gstorage->items[i].amount);
  4519. }
  4520. storage_guild_storageclose(sd);
  4521. gstorage->lock = 0; // Cleaning done, release lock
  4522. clif_displaymessage(fd, msg_txt(1395)); // Your guild storage was cleaned.
  4523. return 0;
  4524. }
  4525. ACMD_FUNC(clearcart)
  4526. {
  4527. int i;
  4528. nullpo_retr(-1, sd);
  4529. if (pc_iscarton(sd) == 0) {
  4530. clif_displaymessage(fd, msg_txt(1396)); // You do not have a cart to be cleaned.
  4531. return -1;
  4532. }
  4533. if (sd->state.vending == 1) { //Somehow...
  4534. return -1;
  4535. }
  4536. for( i = 0; i < MAX_CART; i++ )
  4537. if(sd->status.cart[i].nameid > 0)
  4538. pc_cart_delitem(sd, i, sd->status.cart[i].amount, 1, LOG_TYPE_OTHER);
  4539. clif_clearcart(fd);
  4540. clif_updatestatus(sd,SP_CARTINFO);
  4541. clif_displaymessage(fd, msg_txt(1397)); // Your cart was cleaned.
  4542. return 0;
  4543. }
  4544. /*==========================================
  4545. * @skillid by [MouseJstr]
  4546. * lookup a skill by name
  4547. *------------------------------------------*/
  4548. #define MAX_SKILLID_PARTIAL_RESULTS 5
  4549. #define MAX_SKILLID_PARTIAL_RESULTS_LEN 74 // "skill " (6) + "%d:" (up to 5) + "%s" (up to 30) + " (%s)" (up to 33)
  4550. ACMD_FUNC(skillid) {
  4551. int skillen, idx, i, found = 0;
  4552. DBIterator* iter;
  4553. DBKey key;
  4554. DBData *data;
  4555. char partials[MAX_SKILLID_PARTIAL_RESULTS][MAX_SKILLID_PARTIAL_RESULTS_LEN];
  4556. nullpo_retr(-1, sd);
  4557. if (!message || !*message) {
  4558. clif_displaymessage(fd, msg_txt(1163)); // Please enter a skill name to look up (usage: @skillid <skill name>).
  4559. return -1;
  4560. }
  4561. skillen = strlen(message);
  4562. iter = db_iterator(skilldb_name2id);
  4563. for( data = iter->first(iter,&key); iter->exists(iter); data = iter->next(iter,&key) ) {
  4564. idx = skill_get_index(db_data2i(data));
  4565. if (strnicmp(key.str, message, skillen) == 0 || strnicmp(skill_db[idx].desc, message, skillen) == 0) {
  4566. sprintf(atcmd_output, msg_txt(1164), db_data2i(data), skill_db[idx].desc, key.str); // skill %d: %s (%s)
  4567. clif_displaymessage(fd, atcmd_output);
  4568. } else if ( found < MAX_SKILLID_PARTIAL_RESULTS && ( stristr(key.str,message) || stristr(skill_db[idx].desc,message) ) ) {
  4569. snprintf(partials[found++], MAX_SKILLID_PARTIAL_RESULTS_LEN, msg_txt(1164), db_data2i(data), skill_db[idx].desc, key.str);
  4570. }
  4571. }
  4572. dbi_destroy(iter);
  4573. if( found ) {
  4574. sprintf(atcmd_output, msg_txt(1398), found); // -- Displaying first %d partial matches
  4575. clif_displaymessage(fd, atcmd_output);
  4576. }
  4577. for(i = 0; i < found; i++) { /* partials */
  4578. clif_displaymessage(fd, partials[i]);
  4579. }
  4580. return 0;
  4581. }
  4582. /*==========================================
  4583. * @useskill by [MouseJstr]
  4584. * A way of using skills without having to find them in the skills menu
  4585. *------------------------------------------*/
  4586. ACMD_FUNC(useskill)
  4587. {
  4588. struct map_session_data *pl_sd = NULL;
  4589. struct block_list *bl;
  4590. uint16 skill_id;
  4591. uint16 skill_lv;
  4592. char target[100];
  4593. nullpo_retr(-1, sd);
  4594. if(!message || !*message || sscanf(message, "%hu %hu %23[^\n]", &skill_id, &skill_lv, target) != 3) {
  4595. clif_displaymessage(fd, msg_txt(1165)); // Usage: @useskill <skill ID> <skill level> <target>
  4596. return -1;
  4597. }
  4598. if(!strcmp(target,"self")) pl_sd = sd; //quick keyword
  4599. else if ( (pl_sd = map_nick2sd(target)) == NULL ){
  4600. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4601. return -1;
  4602. }
  4603. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  4604. {
  4605. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4606. return -1;
  4607. }
  4608. if (skill_id >= HM_SKILLBASE && skill_id < HM_SKILLBASE+MAX_HOMUNSKILL
  4609. && sd->hd && merc_is_hom_active(sd->hd)) // (If used with @useskill, put the homunc as dest)
  4610. bl = &sd->hd->bl;
  4611. else
  4612. bl = &sd->bl;
  4613. if (skill_get_inf(skill_id)&INF_GROUND_SKILL)
  4614. unit_skilluse_pos(bl, pl_sd->bl.x, pl_sd->bl.y, skill_id, skill_lv);
  4615. else
  4616. unit_skilluse_id(bl, pl_sd->bl.id, skill_id, skill_lv);
  4617. return 0;
  4618. }
  4619. /*==========================================
  4620. * @displayskill by [Skotlex]
  4621. * Debug command to locate new skill IDs. It sends the
  4622. * three possible skill-effect packets to the area.
  4623. *------------------------------------------*/
  4624. ACMD_FUNC(displayskill)
  4625. {
  4626. struct status_data * status;
  4627. unsigned int tick;
  4628. uint16 skill_id;
  4629. uint16 skill_lv = 1;
  4630. nullpo_retr(-1, sd);
  4631. if (!message || !*message || sscanf(message, "%hu %hu", &skill_id, &skill_lv) < 1)
  4632. {
  4633. clif_displaymessage(fd, msg_txt(1166)); // Usage: @displayskill <skill ID> {<skill level>}
  4634. return -1;
  4635. }
  4636. status = status_get_status_data(&sd->bl);
  4637. tick = gettick();
  4638. clif_skill_damage(&sd->bl,&sd->bl, tick, status->amotion, status->dmotion, 1, 1, skill_id, skill_lv, 5);
  4639. clif_skill_nodamage(&sd->bl, &sd->bl, skill_id, skill_lv, 1);
  4640. clif_skill_poseffect(&sd->bl, skill_id, skill_lv, sd->bl.x, sd->bl.y, tick);
  4641. return 0;
  4642. }
  4643. /*==========================================
  4644. * @skilltree by [MouseJstr]
  4645. * prints the skill tree for a player required to get to a skill
  4646. *------------------------------------------*/
  4647. ACMD_FUNC(skilltree)
  4648. {
  4649. struct map_session_data *pl_sd = NULL;
  4650. uint16 skill_id;
  4651. int meets, j, c=0;
  4652. char target[NAME_LENGTH];
  4653. struct skill_tree_entry *ent;
  4654. nullpo_retr(-1, sd);
  4655. if(!message || !*message || sscanf(message, "%hu %23[^\r\n]", &skill_id, target) != 2) {
  4656. clif_displaymessage(fd, msg_txt(1167)); // Usage: @skilltree <skill ID> <target>
  4657. return -1;
  4658. }
  4659. if ( (pl_sd = map_nick2sd(target)) == NULL )
  4660. {
  4661. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4662. return -1;
  4663. }
  4664. c = pc_calc_skilltree_normalize_job(pl_sd);
  4665. c = pc_mapid2jobid(c, pl_sd->status.sex);
  4666. sprintf(atcmd_output, msg_txt(1168), job_name(c), pc_checkskill(pl_sd, NV_BASIC)); // Player is using %s skill tree (%d basic points).
  4667. clif_displaymessage(fd, atcmd_output);
  4668. ARR_FIND( 0, MAX_SKILL_TREE, j, skill_tree[c][j].id == 0 || skill_tree[c][j].id == skill_id );
  4669. if( j == MAX_SKILL_TREE || skill_tree[c][j].id == 0 )
  4670. {
  4671. clif_displaymessage(fd, msg_txt(1169)); // The player cannot use that skill.
  4672. return 0;
  4673. }
  4674. ent = &skill_tree[c][j];
  4675. meets = 1;
  4676. for(j=0;j<MAX_PC_SKILL_REQUIRE;j++)
  4677. {
  4678. if( ent->need[j].id && pc_checkskill(sd,ent->need[j].id) < ent->need[j].lv)
  4679. {
  4680. sprintf(atcmd_output, msg_txt(1170), ent->need[j].lv, skill_db[ent->need[j].id].desc); // Player requires level %d of skill %s.
  4681. clif_displaymessage(fd, atcmd_output);
  4682. meets = 0;
  4683. }
  4684. }
  4685. if (meets == 1) {
  4686. clif_displaymessage(fd, msg_txt(1171)); // The player meets all the requirements for that skill.
  4687. }
  4688. return 0;
  4689. }
  4690. // Hand a ring with partners name on it to this char
  4691. void getring (struct map_session_data* sd)
  4692. {
  4693. int flag, item_id;
  4694. struct item item_tmp;
  4695. item_id = (sd->status.sex) ? WEDDING_RING_M : WEDDING_RING_F;
  4696. memset(&item_tmp, 0, sizeof(item_tmp));
  4697. item_tmp.nameid = item_id;
  4698. item_tmp.identify = 1;
  4699. item_tmp.card[0] = 255;
  4700. item_tmp.card[2] = sd->status.partner_id;
  4701. item_tmp.card[3] = sd->status.partner_id >> 16;
  4702. if((flag = pc_additem(sd,&item_tmp,1,LOG_TYPE_COMMAND))) {
  4703. clif_additem(sd,0,0,flag);
  4704. map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
  4705. }
  4706. }
  4707. /*==========================================
  4708. * @marry by [MouseJstr], fixed by Lupus
  4709. * Marry two players
  4710. *------------------------------------------*/
  4711. ACMD_FUNC(marry)
  4712. {
  4713. struct map_session_data *pl_sd = NULL;
  4714. char player_name[NAME_LENGTH] = "";
  4715. nullpo_retr(-1, sd);
  4716. if (!message || !*message || sscanf(message, "%23s", player_name) != 1) {
  4717. clif_displaymessage(fd, msg_txt(1172)); // Usage: @marry <char name>
  4718. return -1;
  4719. }
  4720. if ((pl_sd = map_nick2sd(player_name)) == NULL) {
  4721. clif_displaymessage(fd, msg_txt(3));
  4722. return -1;
  4723. }
  4724. if (pc_marriage(sd, pl_sd) == 0) {
  4725. clif_displaymessage(fd, msg_txt(1173)); // They are married... wish them well.
  4726. clif_wedding_effect(&pl_sd->bl); //wedding effect and music [Lupus]
  4727. getring(sd); // Auto-give named rings (Aru)
  4728. getring(pl_sd);
  4729. return 0;
  4730. }
  4731. clif_displaymessage(fd, msg_txt(1174)); // The two cannot wed because one is either a baby or already married.
  4732. return -1;
  4733. }
  4734. /*==========================================
  4735. * @divorce by [MouseJstr], fixed by [Lupus]
  4736. * divorce two players
  4737. *------------------------------------------*/
  4738. ACMD_FUNC(divorce)
  4739. {
  4740. nullpo_retr(-1, sd);
  4741. if (pc_divorce(sd) != 0) {
  4742. sprintf(atcmd_output, msg_txt(1175), sd->status.name); // '%s' is not married.
  4743. clif_displaymessage(fd, atcmd_output);
  4744. return -1;
  4745. }
  4746. sprintf(atcmd_output, msg_txt(1176), sd->status.name); // '%s' and his/her partner are now divorced.
  4747. clif_displaymessage(fd, atcmd_output);
  4748. return 0;
  4749. }
  4750. /*==========================================
  4751. * @changelook by [Celest]
  4752. *------------------------------------------*/
  4753. ACMD_FUNC(changelook)
  4754. {
  4755. int i, j = 0, k = 0;
  4756. int pos[7] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES,LOOK_ROBE };
  4757. if((i = sscanf(message, "%d %d", &j, &k)) < 1) {
  4758. clif_displaymessage(fd, msg_txt(1177)); // Usage: @changelook {<position>} <view id>
  4759. clif_displaymessage(fd, msg_txt(1178)); // Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield 6-Shoes 7-Robe
  4760. return -1;
  4761. } else if ( i == 2 ) {
  4762. if (j < 1 || j > 7)
  4763. j = 1;
  4764. j = pos[j - 1];
  4765. } else if( i == 1 ) { // position not defined, use HEAD_TOP as default
  4766. k = j; // swap
  4767. j = LOOK_HEAD_TOP;
  4768. }
  4769. clif_changelook(&sd->bl,j,k);
  4770. return 0;
  4771. }
  4772. /*==========================================
  4773. * @autotrade by durf [Lupus] [Paradox924X]
  4774. * Turns on/off Autotrade for a specific player
  4775. *------------------------------------------*/
  4776. ACMD_FUNC(autotrade) {
  4777. int i;
  4778. nullpo_retr(-1, sd);
  4779. if( map[sd->bl.m].flag.autotrade != battle_config.autotrade_mapflag ) {
  4780. clif_displaymessage(fd, msg_txt(1179)); // Autotrade is not allowed on this map.
  4781. return -1;
  4782. }
  4783. if( pc_isdead(sd) ) {
  4784. clif_displaymessage(fd, msg_txt(1180)); // You cannot autotrade when dead.
  4785. return -1;
  4786. }
  4787. if( !sd->state.vending && !sd->state.buyingstore ) { //check if player is vending or buying
  4788. clif_displaymessage(fd, msg_txt(549)); // "You should have a shop open to use @autotrade."
  4789. return -1;
  4790. }
  4791. sd->state.autotrade = 1;
  4792. if( battle_config.at_timeout ) {
  4793. int timeout = atoi(message);
  4794. 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);
  4795. }
  4796. // Leave all chat channels.
  4797. if( raChSys.ally && sd->status.guild_id ) {
  4798. struct guild *g = sd->guild, *sg;
  4799. if( g ) {
  4800. if( idb_exists(((struct raChSysCh *)g->channel)->users, sd->status.char_id) )
  4801. clif_chsys_left((struct raChSysCh *)g->channel,sd);
  4802. for (i = 0; i < MAX_GUILDALLIANCE; i++) {
  4803. if( g->alliance[i].guild_id && (sg = guild_search(g->alliance[i].guild_id) ) ) {
  4804. if( idb_exists(((struct raChSysCh *)sg->channel)->users, sd->status.char_id) )
  4805. clif_chsys_left((struct raChSysCh *)sg->channel,sd);
  4806. break;
  4807. }
  4808. }
  4809. }
  4810. }
  4811. if( sd->channel_count ) { //quit all chan
  4812. uint8 count = sd->channel_count;
  4813. for( i = 0; i < count; i++ ) {
  4814. if( sd->channels[i] != NULL )
  4815. clif_chsys_left(sd->channels[i],sd);
  4816. }
  4817. }
  4818. clif_authfail_fd(sd->fd, 15);
  4819. return 0;
  4820. }
  4821. /*==========================================
  4822. * @changegm by durf (changed by Lupus)
  4823. * Changes Master of your Guild to a specified guild member
  4824. *------------------------------------------*/
  4825. ACMD_FUNC(changegm)
  4826. {
  4827. struct guild *g;
  4828. struct map_session_data *pl_sd;
  4829. nullpo_retr(-1, sd);
  4830. if (sd->status.guild_id == 0 || (g = sd->guild) == NULL || strcmp(g->master,sd->status.name)) {
  4831. clif_displaymessage(fd, msg_txt(1181)); // You need to be a Guild Master to use this command.
  4832. return -1;
  4833. }
  4834. if( map[sd->bl.m].flag.guildlock || map[sd->bl.m].flag.gvg_castle ) {
  4835. clif_displaymessage(fd, msg_txt(1182)); // You cannot change guild leaders on this map.
  4836. return -1;
  4837. }
  4838. if( !message[0] ) {
  4839. clif_displaymessage(fd, msg_txt(1183)); // Usage: @changegm <guild_member_name>
  4840. return -1;
  4841. }
  4842. if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) {
  4843. clif_displaymessage(fd, msg_txt(1184)); // Target character must be online and be a guild member.
  4844. return -1;
  4845. }
  4846. guild_gm_change(sd->status.guild_id, pl_sd);
  4847. return 0;
  4848. }
  4849. /*==========================================
  4850. * @changeleader by Skotlex
  4851. * Changes the leader of a party.
  4852. *------------------------------------------*/
  4853. ACMD_FUNC(changeleader)
  4854. {
  4855. nullpo_retr(-1, sd);
  4856. if( !message[0] )
  4857. {
  4858. clif_displaymessage(fd, msg_txt(1185)); // Usage: @changeleader <party_member_name>
  4859. return -1;
  4860. }
  4861. if (party_changeleader(sd, map_nick2sd((char *) message)))
  4862. return 0;
  4863. return -1;
  4864. }
  4865. /*==========================================
  4866. * @partyoption by Skotlex
  4867. * Used to change the item share setting of a party.
  4868. *------------------------------------------*/
  4869. ACMD_FUNC(partyoption)
  4870. {
  4871. struct party_data *p;
  4872. int mi, option;
  4873. char w1[16], w2[16];
  4874. nullpo_retr(-1, sd);
  4875. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
  4876. {
  4877. clif_displaymessage(fd, msg_txt(282));
  4878. return -1;
  4879. }
  4880. ARR_FIND( 0, MAX_PARTY, mi, p->data[mi].sd == sd );
  4881. if (mi == MAX_PARTY)
  4882. return -1; //Shouldn't happen
  4883. if (!p->party.member[mi].leader)
  4884. {
  4885. clif_displaymessage(fd, msg_txt(282));
  4886. return -1;
  4887. }
  4888. if(!message || !*message || sscanf(message, "%15s %15s", w1, w2) < 2)
  4889. {
  4890. clif_displaymessage(fd, msg_txt(1186)); // Usage: @partyoption <pickup share: yes/no> <item distribution: yes/no>
  4891. return -1;
  4892. }
  4893. option = (config_switch(w1)?1:0)|(config_switch(w2)?2:0);
  4894. //Change item share type.
  4895. if (option != p->party.item)
  4896. party_changeoption(sd, p->party.exp, option);
  4897. else
  4898. clif_displaymessage(fd, msg_txt(286));
  4899. return 0;
  4900. }
  4901. /*==========================================
  4902. * @autoloot by Upa-Kun
  4903. * Turns on/off AutoLoot for a specific player
  4904. *------------------------------------------*/
  4905. ACMD_FUNC(autoloot)
  4906. {
  4907. int rate;
  4908. nullpo_retr(-1, sd);
  4909. // autoloot command without value
  4910. if(!message || !*message)
  4911. {
  4912. if (sd->state.autoloot)
  4913. rate = 0;
  4914. else
  4915. rate = 10000;
  4916. } else {
  4917. double drate;
  4918. drate = atof(message);
  4919. rate = (int)(drate*100);
  4920. }
  4921. if (rate < 0) rate = 0;
  4922. if (rate > 10000) rate = 10000;
  4923. sd->state.autoloot = rate;
  4924. if (sd->state.autoloot) {
  4925. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(1187),((double)sd->state.autoloot)/100.); // Autolooting items with drop rates of %0.02f%% and below.
  4926. clif_displaymessage(fd, atcmd_output);
  4927. }else
  4928. clif_displaymessage(fd, msg_txt(1188)); // Autoloot is now off.
  4929. return 0;
  4930. }
  4931. /*==========================================
  4932. * @alootid
  4933. *------------------------------------------*/
  4934. ACMD_FUNC(autolootitem)
  4935. {
  4936. struct item_data *item_data = NULL;
  4937. int i;
  4938. int action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset
  4939. if (message && *message) {
  4940. if (message[0] == '+') {
  4941. message++;
  4942. action = 1;
  4943. }
  4944. else if (message[0] == '-') {
  4945. message++;
  4946. action = 2;
  4947. }
  4948. else if (!strcmp(message,"reset"))
  4949. action = 4;
  4950. }
  4951. if (action < 3) // add or remove
  4952. {
  4953. if ((item_data = itemdb_exists(atoi(message))) == NULL)
  4954. item_data = itemdb_searchname(message);
  4955. if (!item_data) {
  4956. // No items founds in the DB with Id or Name
  4957. clif_displaymessage(fd, msg_txt(1189)); // Item not found.
  4958. return -1;
  4959. }
  4960. }
  4961. switch(action) {
  4962. case 1:
  4963. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
  4964. if (i != AUTOLOOTITEM_SIZE) {
  4965. clif_displaymessage(fd, msg_txt(1190)); // You're already autolooting this item.
  4966. return -1;
  4967. }
  4968. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == 0);
  4969. if (i == AUTOLOOTITEM_SIZE) {
  4970. clif_displaymessage(fd, msg_txt(1191)); // Your autolootitem list is full. Remove some items first with @autolootid -<item name or ID>.
  4971. return -1;
  4972. }
  4973. sd->state.autolootid[i] = item_data->nameid; // Autoloot Activated
  4974. sprintf(atcmd_output, msg_txt(1192), item_data->name, item_data->jname, item_data->nameid); // Autolooting item: '%s'/'%s' {%d}
  4975. clif_displaymessage(fd, atcmd_output);
  4976. sd->state.autolooting = 1;
  4977. break;
  4978. case 2:
  4979. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
  4980. if (i == AUTOLOOTITEM_SIZE) {
  4981. clif_displaymessage(fd, msg_txt(1193)); // You're currently not autolooting this item.
  4982. return -1;
  4983. }
  4984. sd->state.autolootid[i] = 0;
  4985. sprintf(atcmd_output, msg_txt(1194), item_data->name, item_data->jname, item_data->nameid); // Removed item: '%s'/'%s' {%d} from your autolootitem list.
  4986. clif_displaymessage(fd, atcmd_output);
  4987. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
  4988. if (i == AUTOLOOTITEM_SIZE) {
  4989. sd->state.autolooting = 0;
  4990. }
  4991. break;
  4992. case 3:
  4993. sprintf(atcmd_output, msg_txt(1195), AUTOLOOTITEM_SIZE); // You can have %d items on your autolootitem list.
  4994. clif_displaymessage(fd, atcmd_output);
  4995. clif_displaymessage(fd, msg_txt(1196)); // To add an item to the list, use "@alootid +<item name or ID>". To remove an item, use "@alootid -<item name or ID>".
  4996. clif_displaymessage(fd, msg_txt(1197)); // "@alootid reset" will clear your autolootitem list.
  4997. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
  4998. if (i == AUTOLOOTITEM_SIZE) {
  4999. clif_displaymessage(fd, msg_txt(1198)); // Your autolootitem list is empty.
  5000. } else {
  5001. clif_displaymessage(fd, msg_txt(1199)); // Items on your autolootitem list:
  5002. for(i = 0; i < AUTOLOOTITEM_SIZE; i++)
  5003. {
  5004. if (sd->state.autolootid[i] == 0)
  5005. continue;
  5006. if (!(item_data = itemdb_exists(sd->state.autolootid[i]))) {
  5007. 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);
  5008. continue;
  5009. }
  5010. sprintf(atcmd_output, "'%s'/'%s' {%d}", item_data->name, item_data->jname, item_data->nameid);
  5011. clif_displaymessage(fd, atcmd_output);
  5012. }
  5013. }
  5014. break;
  5015. case 4:
  5016. memset(sd->state.autolootid, 0, sizeof(sd->state.autolootid));
  5017. clif_displaymessage(fd, msg_txt(1200)); // Your autolootitem list has been reset.
  5018. sd->state.autolooting = 0;
  5019. break;
  5020. }
  5021. return 0;
  5022. }
  5023. /**
  5024. * No longer available, keeping here just in case it's back someday. [Ind]
  5025. **/
  5026. /*==========================================
  5027. * It is made to rain.
  5028. *------------------------------------------*/
  5029. //ACMD_FUNC(rain)
  5030. //{
  5031. // nullpo_retr(-1, sd);
  5032. // if (map[sd->bl.m].flag.rain) {
  5033. // map[sd->bl.m].flag.rain=0;
  5034. // clif_weather(sd->bl.m);
  5035. // clif_displaymessage(fd, msg_txt(1201)); // The rain has stopped.
  5036. // } else {
  5037. // map[sd->bl.m].flag.rain=1;
  5038. // clif_weather(sd->bl.m);
  5039. // clif_displaymessage(fd, msg_txt(1202)); // It has started to rain.
  5040. // }
  5041. // return 0;
  5042. //}
  5043. /*==========================================
  5044. * It is made to snow.
  5045. *------------------------------------------*/
  5046. ACMD_FUNC(snow)
  5047. {
  5048. nullpo_retr(-1, sd);
  5049. if (map[sd->bl.m].flag.snow) {
  5050. map[sd->bl.m].flag.snow=0;
  5051. clif_weather(sd->bl.m);
  5052. clif_displaymessage(fd, msg_txt(1203)); // Snow has stopped falling.
  5053. } else {
  5054. map[sd->bl.m].flag.snow=1;
  5055. clif_weather(sd->bl.m);
  5056. clif_displaymessage(fd, msg_txt(1204)); // It has started to snow.
  5057. }
  5058. return 0;
  5059. }
  5060. /*==========================================
  5061. * Cherry tree snowstorm is made to fall. (Sakura)
  5062. *------------------------------------------*/
  5063. ACMD_FUNC(sakura)
  5064. {
  5065. nullpo_retr(-1, sd);
  5066. if (map[sd->bl.m].flag.sakura) {
  5067. map[sd->bl.m].flag.sakura=0;
  5068. clif_weather(sd->bl.m);
  5069. clif_displaymessage(fd, msg_txt(1205)); // Cherry tree leaves no longer fall.
  5070. } else {
  5071. map[sd->bl.m].flag.sakura=1;
  5072. clif_weather(sd->bl.m);
  5073. clif_displaymessage(fd, msg_txt(1206)); // Cherry tree leaves have begun to fall.
  5074. }
  5075. return 0;
  5076. }
  5077. /*==========================================
  5078. * Clouds appear.
  5079. *------------------------------------------*/
  5080. ACMD_FUNC(clouds)
  5081. {
  5082. nullpo_retr(-1, sd);
  5083. if (map[sd->bl.m].flag.clouds) {
  5084. map[sd->bl.m].flag.clouds=0;
  5085. clif_weather(sd->bl.m);
  5086. clif_displaymessage(fd, msg_txt(1207)); // The clouds has disappear.
  5087. } else {
  5088. map[sd->bl.m].flag.clouds=1;
  5089. clif_weather(sd->bl.m);
  5090. clif_displaymessage(fd, msg_txt(1208)); // Clouds appear.
  5091. }
  5092. return 0;
  5093. }
  5094. /*==========================================
  5095. * Different type of clouds using effect 516
  5096. *------------------------------------------*/
  5097. ACMD_FUNC(clouds2)
  5098. {
  5099. nullpo_retr(-1, sd);
  5100. if (map[sd->bl.m].flag.clouds2) {
  5101. map[sd->bl.m].flag.clouds2=0;
  5102. clif_weather(sd->bl.m);
  5103. clif_displaymessage(fd, msg_txt(1209)); // The alternative clouds disappear.
  5104. } else {
  5105. map[sd->bl.m].flag.clouds2=1;
  5106. clif_weather(sd->bl.m);
  5107. clif_displaymessage(fd, msg_txt(1210)); // Alternative clouds appear.
  5108. }
  5109. return 0;
  5110. }
  5111. /*==========================================
  5112. * Fog hangs over.
  5113. *------------------------------------------*/
  5114. ACMD_FUNC(fog)
  5115. {
  5116. nullpo_retr(-1, sd);
  5117. if (map[sd->bl.m].flag.fog) {
  5118. map[sd->bl.m].flag.fog=0;
  5119. clif_weather(sd->bl.m);
  5120. clif_displaymessage(fd, msg_txt(1211)); // The fog has gone.
  5121. } else {
  5122. map[sd->bl.m].flag.fog=1;
  5123. clif_weather(sd->bl.m);
  5124. clif_displaymessage(fd, msg_txt(1212)); // Fog hangs over.
  5125. }
  5126. return 0;
  5127. }
  5128. /*==========================================
  5129. * Fallen leaves fall.
  5130. *------------------------------------------*/
  5131. ACMD_FUNC(leaves)
  5132. {
  5133. nullpo_retr(-1, sd);
  5134. if (map[sd->bl.m].flag.leaves) {
  5135. map[sd->bl.m].flag.leaves=0;
  5136. clif_weather(sd->bl.m);
  5137. clif_displaymessage(fd, msg_txt(1213)); // Leaves no longer fall.
  5138. } else {
  5139. map[sd->bl.m].flag.leaves=1;
  5140. clif_weather(sd->bl.m);
  5141. clif_displaymessage(fd, msg_txt(1214)); // Fallen leaves fall.
  5142. }
  5143. return 0;
  5144. }
  5145. /*==========================================
  5146. * Fireworks appear.
  5147. *------------------------------------------*/
  5148. ACMD_FUNC(fireworks)
  5149. {
  5150. nullpo_retr(-1, sd);
  5151. if (map[sd->bl.m].flag.fireworks) {
  5152. map[sd->bl.m].flag.fireworks=0;
  5153. clif_weather(sd->bl.m);
  5154. clif_displaymessage(fd, msg_txt(1215)); // Fireworks have ended.
  5155. } else {
  5156. map[sd->bl.m].flag.fireworks=1;
  5157. clif_weather(sd->bl.m);
  5158. clif_displaymessage(fd, msg_txt(1216)); // Fireworks have launched.
  5159. }
  5160. return 0;
  5161. }
  5162. /*==========================================
  5163. * Clearing Weather Effects by Dexity
  5164. *------------------------------------------*/
  5165. ACMD_FUNC(clearweather)
  5166. {
  5167. nullpo_retr(-1, sd);
  5168. /**
  5169. * No longer available, keeping here just in case it's back someday. [Ind]
  5170. **/
  5171. //map[sd->bl.m].flag.rain=0;
  5172. map[sd->bl.m].flag.snow=0;
  5173. map[sd->bl.m].flag.sakura=0;
  5174. map[sd->bl.m].flag.clouds=0;
  5175. map[sd->bl.m].flag.clouds2=0;
  5176. map[sd->bl.m].flag.fog=0;
  5177. map[sd->bl.m].flag.fireworks=0;
  5178. map[sd->bl.m].flag.leaves=0;
  5179. clif_weather(sd->bl.m);
  5180. clif_displaymessage(fd, msg_txt(291));
  5181. return 0;
  5182. }
  5183. /*===============================================================
  5184. * Sound Command - plays a sound for everyone around! [Codemaster]
  5185. *---------------------------------------------------------------*/
  5186. ACMD_FUNC(sound)
  5187. {
  5188. char sound_file[100];
  5189. memset(sound_file, '\0', sizeof(sound_file));
  5190. if(!message || !*message || sscanf(message, "%99[^\n]", sound_file) < 1) {
  5191. clif_displaymessage(fd, msg_txt(1217)); // Please enter a sound filename (usage: @sound <filename>).
  5192. return -1;
  5193. }
  5194. if(strstr(sound_file, ".wav") == NULL)
  5195. strcat(sound_file, ".wav");
  5196. clif_soundeffectall(&sd->bl, sound_file, 0, AREA);
  5197. return 0;
  5198. }
  5199. /*==========================================
  5200. * MOB Search
  5201. *------------------------------------------*/
  5202. ACMD_FUNC(mobsearch)
  5203. {
  5204. char mob_name[100];
  5205. int mob_id;
  5206. int number = 0;
  5207. struct s_mapiterator* it;
  5208. nullpo_retr(-1, sd);
  5209. if (!message || !*message || sscanf(message, "%99[^\n]", mob_name) < 1) {
  5210. clif_displaymessage(fd, msg_txt(1218)); // Please enter a monster name (usage: @mobsearch <monster name>).
  5211. return -1;
  5212. }
  5213. if ((mob_id = atoi(mob_name)) == 0)
  5214. mob_id = mobdb_searchname(mob_name);
  5215. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  5216. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(1219),mob_name); // Invalid mob ID %s!
  5217. clif_displaymessage(fd, atcmd_output);
  5218. return -1;
  5219. }
  5220. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  5221. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  5222. // strcpy(mob_name,mob_db(mob_id)->name); // --en--
  5223. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(1220), mob_name, mapindex_id2name(sd->mapindex)); // Mob Search... %s %s
  5224. clif_displaymessage(fd, atcmd_output);
  5225. it = mapit_geteachmob();
  5226. for(;;)
  5227. {
  5228. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  5229. if( md == NULL )
  5230. break;// no more mobs
  5231. if( md->bl.m != sd->bl.m )
  5232. continue;
  5233. if( mob_id != -1 && md->class_ != mob_id )
  5234. continue;
  5235. ++number;
  5236. if( md->spawn_timer == INVALID_TIMER )
  5237. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%3d:%3d] %s", number, md->bl.x, md->bl.y, md->name);
  5238. else
  5239. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%s] %s", number, "dead", md->name);
  5240. clif_displaymessage(fd, atcmd_output);
  5241. }
  5242. mapit_free(it);
  5243. return 0;
  5244. }
  5245. /*==========================================
  5246. * @cleanmap - cleans items on the ground
  5247. * @cleanarea - cleans items on the ground within an specified area
  5248. *------------------------------------------*/
  5249. static int atcommand_cleanfloor_sub(struct block_list *bl, va_list ap)
  5250. {
  5251. nullpo_ret(bl);
  5252. map_clearflooritem(bl);
  5253. return 0;
  5254. }
  5255. ACMD_FUNC(cleanmap)
  5256. {
  5257. map_foreachinmap(atcommand_cleanfloor_sub, sd->bl.m, BL_ITEM);
  5258. clif_displaymessage(fd, msg_txt(1221)); // All dropped items have been cleaned up.
  5259. return 0;
  5260. }
  5261. ACMD_FUNC(cleanarea)
  5262. {
  5263. int x0 = 0, y0 = 0, x1 = 0, y1 = 0;
  5264. if (!message || !*message || sscanf(message, "%d %d %d %d", &x0, &y0, &x1, &y1) < 1) {
  5265. 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);
  5266. }
  5267. else if (sscanf(message, "%d %d %d %d", &x0, &y0, &x1, &y1) == 1) {
  5268. 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);
  5269. }
  5270. else if (sscanf(message, "%d %d %d %d", &x0, &y0, &x1, &y1) == 4) {
  5271. map_foreachinarea(atcommand_cleanfloor_sub, sd->bl.m, x0, y0, x1, y1, BL_ITEM);
  5272. }
  5273. clif_displaymessage(fd, msg_txt(1221)); // All dropped items have been cleaned up.
  5274. return 0;
  5275. }
  5276. /*==========================================
  5277. * make a NPC/PET talk
  5278. * @npctalkc [SnakeDrak]
  5279. *------------------------------------------*/
  5280. ACMD_FUNC(npctalk)
  5281. {
  5282. char name[NAME_LENGTH],mes[100],temp[100];
  5283. struct npc_data *nd;
  5284. bool ifcolor=(*(command + 8) != 'c' && *(command + 8) != 'C')?0:1;
  5285. unsigned long color=0;
  5286. if (sd->sc.count && //no "chatting" while muted.
  5287. (sd->sc.data[SC_BERSERK] || sd->sc.data[SC__BLOODYLUST] ||
  5288. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  5289. return -1;
  5290. if(!ifcolor) {
  5291. if (!message || !*message || sscanf(message, "%23[^,], %99[^\n]", name, mes) < 2) {
  5292. clif_displaymessage(fd, msg_txt(1222)); // Please enter the correct parameters (usage: @npctalk <npc name>, <message>).
  5293. return -1;
  5294. }
  5295. }
  5296. else {
  5297. if (!message || !*message || sscanf(message, "%lx %23[^,], %99[^\n]", &color, name, mes) < 3) {
  5298. clif_displaymessage(fd, msg_txt(1223)); // Please enter the correct parameters (usage: @npctalkc <color> <npc name>, <message>).
  5299. return -1;
  5300. }
  5301. }
  5302. if (!(nd = npc_name2id(name))) {
  5303. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist
  5304. return -1;
  5305. }
  5306. strtok(name, "#"); // discard extra name identifier if present
  5307. snprintf(temp, sizeof(temp), "%s : %s", name, mes);
  5308. if(ifcolor) clif_messagecolor(&nd->bl,color,temp);
  5309. else clif_disp_overhead(&nd->bl, temp);
  5310. return 0;
  5311. }
  5312. ACMD_FUNC(pettalk)
  5313. {
  5314. char mes[100],temp[100];
  5315. struct pet_data *pd;
  5316. nullpo_retr(-1, sd);
  5317. if ( battle_config.min_chat_delay ) {
  5318. if( DIFF_TICK(sd->cantalk_tick, gettick()) > 0 )
  5319. return 0;
  5320. sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
  5321. }
  5322. if(!sd->status.pet_id || !(pd=sd->pd))
  5323. {
  5324. clif_displaymessage(fd, msg_txt(184));
  5325. return -1;
  5326. }
  5327. if (sd->sc.count && //no "chatting" while muted.
  5328. (sd->sc.data[SC_BERSERK] || sd->sc.data[SC__BLOODYLUST] ||
  5329. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  5330. return -1;
  5331. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  5332. clif_displaymessage(fd, msg_txt(1224)); // Please enter a message (usage: @pettalk <message>).
  5333. return -1;
  5334. }
  5335. if (message[0] == '/')
  5336. {// pet emotion processing
  5337. const char* emo[] = {
  5338. "/!", "/?", "/ho", "/lv", "/swt", "/ic", "/an", "/ag", "/$", "/...",
  5339. "/scissors", "/rock", "/paper", "/korea", "/lv2", "/thx", "/wah", "/sry", "/heh", "/swt2",
  5340. "/hmm", "/no1", "/??", "/omg", "/O", "/X", "/hlp", "/go", "/sob", "/gg",
  5341. "/kis", "/kis2", "/pif", "/ok", "-?-", "/indonesia", "/bzz", "/rice", "/awsm", "/meh",
  5342. "/shy", "/pat", "/mp", "/slur", "/com", "/yawn", "/grat", "/hp", "/philippines", "/malaysia",
  5343. "/singapore", "/brazil", "/fsh", "/spin", "/sigh", "/dum", "/crwd", "/desp", "/dice", "-dice2",
  5344. "-dice3", "-dice4", "-dice5", "-dice6", "/india", "/love", "/russia", "-?-", "/mobile", "/mail",
  5345. "/chinese", "/antenna1", "/antenna2", "/antenna3", "/hum", "/abs", "/oops", "/spit", "/ene", "/panic",
  5346. "/whisp"
  5347. };
  5348. int i;
  5349. ARR_FIND( 0, ARRAYLENGTH(emo), i, stricmp(message, emo[i]) == 0 );
  5350. if( i == E_DICE1 ) i = rnd()%6 + E_DICE1; // randomize /dice
  5351. if( i < ARRAYLENGTH(emo) )
  5352. {
  5353. if (sd->emotionlasttime + 1 >= time(NULL)) { // not more than 1 per second
  5354. sd->emotionlasttime = time(NULL);
  5355. return 0;
  5356. }
  5357. sd->emotionlasttime = time(NULL);
  5358. clif_emotion(&pd->bl, i);
  5359. return 0;
  5360. }
  5361. }
  5362. snprintf(temp, sizeof temp ,"%s : %s", pd->pet.name, mes);
  5363. clif_disp_overhead(&pd->bl, temp);
  5364. return 0;
  5365. }
  5366. /// @users - displays the number of players present on each map (and percentage)
  5367. /// #users displays on the target user instead of self
  5368. ACMD_FUNC(users)
  5369. {
  5370. char buf[CHAT_SIZE_MAX];
  5371. int i;
  5372. int users[MAX_MAPINDEX];
  5373. int users_all;
  5374. struct s_mapiterator* iter;
  5375. memset(users, 0, sizeof(users));
  5376. users_all = 0;
  5377. // count users on each map
  5378. iter = mapit_getallusers();
  5379. for(;;)
  5380. {
  5381. struct map_session_data* sd2 = (struct map_session_data*)mapit_next(iter);
  5382. if( sd2 == NULL )
  5383. break;// no more users
  5384. if( sd2->mapindex >= MAX_MAPINDEX )
  5385. continue;// invalid mapindex
  5386. if( users[sd2->mapindex] < INT_MAX ) ++users[sd2->mapindex];
  5387. if( users_all < INT_MAX ) ++users_all;
  5388. }
  5389. mapit_free(iter);
  5390. // display results for each map
  5391. for( i = 0; i < MAX_MAPINDEX; ++i )
  5392. {
  5393. if( users[i] == 0 )
  5394. continue;// empty
  5395. safesnprintf(buf, sizeof(buf), "%s: %d (%.2f%%)", mapindex_id2name(i), users[i], (float)(100.0f*users[i]/users_all));
  5396. clif_displaymessage(sd->fd, buf);
  5397. }
  5398. // display overall count
  5399. safesnprintf(buf, sizeof(buf), "all: %d", users_all);
  5400. clif_displaymessage(sd->fd, buf);
  5401. return 0;
  5402. }
  5403. /*==========================================
  5404. *
  5405. *------------------------------------------*/
  5406. ACMD_FUNC(reset)
  5407. {
  5408. pc_resetstate(sd);
  5409. pc_resetskill(sd,1);
  5410. sprintf(atcmd_output, msg_txt(208), sd->status.name); // '%s' skill and stats points reseted!
  5411. clif_displaymessage(fd, atcmd_output);
  5412. return 0;
  5413. }
  5414. /*==========================================
  5415. *
  5416. *------------------------------------------*/
  5417. ACMD_FUNC(summon)
  5418. {
  5419. char name[NAME_LENGTH];
  5420. int mob_id = 0;
  5421. int duration = 0;
  5422. struct mob_data *md;
  5423. unsigned int tick=gettick();
  5424. nullpo_retr(-1, sd);
  5425. if (!message || !*message || sscanf(message, "%23s %d", name, &duration) < 1)
  5426. {
  5427. clif_displaymessage(fd, msg_txt(1225)); // Please enter a monster name (usage: @summon <monster name> {duration}).
  5428. return -1;
  5429. }
  5430. if (duration < 1)
  5431. duration =1;
  5432. else if (duration > 60)
  5433. duration =60;
  5434. if ((mob_id = atoi(name)) == 0)
  5435. mob_id = mobdb_searchname(name);
  5436. if(mob_id == 0 || mobdb_checkid(mob_id) == 0)
  5437. {
  5438. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  5439. return -1;
  5440. }
  5441. md = mob_once_spawn_sub(&sd->bl, sd->bl.m, -1, -1, "--ja--", mob_id, "", SZ_SMALL, AI_NONE);
  5442. if(!md)
  5443. return -1;
  5444. md->master_id=sd->bl.id;
  5445. md->special_state.ai=1;
  5446. md->deletetimer=add_timer(tick+(duration*60000),mob_timer_delete,md->bl.id,0);
  5447. clif_specialeffect(&md->bl,344,AREA);
  5448. mob_spawn(md);
  5449. sc_start4(NULL,&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000);
  5450. clif_skill_poseffect(&sd->bl,AM_CALLHOMUN,1,md->bl.x,md->bl.y,tick);
  5451. clif_displaymessage(fd, msg_txt(39)); // All monster summoned!
  5452. return 0;
  5453. }
  5454. /*==========================================
  5455. * @adjgroup
  5456. * Temporarily move player to another group
  5457. * Useful during beta testing to allow players to use GM commands for short periods of time
  5458. *------------------------------------------*/
  5459. ACMD_FUNC(adjgroup)
  5460. {
  5461. int new_group = 0;
  5462. nullpo_retr(-1, sd);
  5463. if (!message || !*message || sscanf(message, "%d", &new_group) != 1) {
  5464. clif_displaymessage(fd, msg_txt(1226)); // Usage: @adjgroup <group_id>
  5465. return -1;
  5466. }
  5467. if (!pc_group_exists(new_group)) {
  5468. clif_displaymessage(fd, msg_txt(1227)); // Specified group does not exist.
  5469. return -1;
  5470. }
  5471. sd->group_id = new_group;
  5472. pc_group_pc_load(sd);/* update cache */
  5473. clif_displaymessage(fd, msg_txt(1228)); // Group changed successfully.
  5474. clif_displaymessage(sd->fd, msg_txt(1229)); // Your group has changed.
  5475. return 0;
  5476. }
  5477. /*==========================================
  5478. * @trade by [MouseJstr]
  5479. * Open a trade window with a remote player
  5480. *------------------------------------------*/
  5481. ACMD_FUNC(trade)
  5482. {
  5483. struct map_session_data *pl_sd = NULL;
  5484. nullpo_retr(-1, sd);
  5485. if (!message || !*message) {
  5486. clif_displaymessage(fd, msg_txt(1230)); // Please enter a player name (usage: @trade <char name>).
  5487. return -1;
  5488. }
  5489. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  5490. {
  5491. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5492. return -1;
  5493. }
  5494. trade_traderequest(sd, pl_sd);
  5495. return 0;
  5496. }
  5497. /*==========================================
  5498. * @setbattleflag by [MouseJstr]
  5499. * set a battle_config flag without having to reboot
  5500. *------------------------------------------*/
  5501. ACMD_FUNC(setbattleflag)
  5502. {
  5503. char flag[128], value[128];
  5504. nullpo_retr(-1, sd);
  5505. if (!message || !*message || sscanf(message, "%127s %127s", flag, value) != 2) {
  5506. clif_displaymessage(fd, msg_txt(1231)); // Usage: @setbattleflag <flag> <value>
  5507. return -1;
  5508. }
  5509. if (battle_set_value(flag, value) == 0)
  5510. {
  5511. clif_displaymessage(fd, msg_txt(1232)); // Unknown battle_config flag.
  5512. return -1;
  5513. }
  5514. clif_displaymessage(fd, msg_txt(1233)); // Set battle_config as requested.
  5515. return 0;
  5516. }
  5517. /*==========================================
  5518. * @unmute [Valaris]
  5519. *------------------------------------------*/
  5520. ACMD_FUNC(unmute)
  5521. {
  5522. struct map_session_data *pl_sd = NULL;
  5523. nullpo_retr(-1, sd);
  5524. if (!message || !*message) {
  5525. clif_displaymessage(fd, msg_txt(1234)); // Please enter a player name (usage: @unmute <char name>).
  5526. return -1;
  5527. }
  5528. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  5529. {
  5530. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5531. return -1;
  5532. }
  5533. if(!pl_sd->sc.data[SC_NOCHAT]) {
  5534. clif_displaymessage(sd->fd,msg_txt(1235)); // Player is not muted.
  5535. return -1;
  5536. }
  5537. pl_sd->status.manner = 0;
  5538. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  5539. clif_displaymessage(sd->fd,msg_txt(1236)); // Player unmuted.
  5540. return 0;
  5541. }
  5542. /*==========================================
  5543. * @uptime by MC Cameri
  5544. *------------------------------------------*/
  5545. ACMD_FUNC(uptime)
  5546. {
  5547. unsigned long seconds = 0, day = 24*60*60, hour = 60*60,
  5548. minute = 60, days = 0, hours = 0, minutes = 0;
  5549. nullpo_retr(-1, sd);
  5550. seconds = get_uptime();
  5551. days = seconds/day;
  5552. seconds -= (seconds/day>0)?(seconds/day)*day:0;
  5553. hours = seconds/hour;
  5554. seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
  5555. minutes = seconds/minute;
  5556. seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
  5557. snprintf(atcmd_output, sizeof(atcmd_output), msg_txt(245), days, hours, minutes, seconds);
  5558. clif_displaymessage(fd, atcmd_output);
  5559. return 0;
  5560. }
  5561. /*==========================================
  5562. * @changesex <sex>
  5563. * => Changes one's sex. Argument sex can be 0 or 1, m or f, male or female.
  5564. *------------------------------------------*/
  5565. ACMD_FUNC(changesex)
  5566. {
  5567. int i;
  5568. nullpo_retr(-1, sd);
  5569. pc_resetskill(sd,4);
  5570. // to avoid any problem with equipment and invalid sex, equipment is unequiped.
  5571. for( i=0; i<EQI_MAX; i++ )
  5572. if( sd->equip_index[i] >= 0 ) pc_unequipitem(sd, sd->equip_index[i], 3);
  5573. chrif_changesex(sd);
  5574. return 0;
  5575. }
  5576. /*================================================
  5577. * @mute - Mutes a player for a set amount of time
  5578. *------------------------------------------------*/
  5579. ACMD_FUNC(mute)
  5580. {
  5581. struct map_session_data *pl_sd = NULL;
  5582. int manner;
  5583. nullpo_retr(-1, sd);
  5584. if (!message || !*message || sscanf(message, "%d %23[^\n]", &manner, atcmd_player_name) < 1) {
  5585. clif_displaymessage(fd, msg_txt(1237)); // Usage: @mute <time> <char name>
  5586. return -1;
  5587. }
  5588. if ( (pl_sd = map_nick2sd(atcmd_player_name)) == NULL )
  5589. {
  5590. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5591. return -1;
  5592. }
  5593. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  5594. {
  5595. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5596. return -1;
  5597. }
  5598. clif_manner_message(sd, 0);
  5599. clif_manner_message(pl_sd, 5);
  5600. if( pl_sd->status.manner < manner ) {
  5601. pl_sd->status.manner -= manner;
  5602. sc_start(NULL,&pl_sd->bl,SC_NOCHAT,100,0,0);
  5603. } else {
  5604. pl_sd->status.manner = 0;
  5605. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  5606. }
  5607. clif_GM_silence(sd, pl_sd, (manner > 0 ? 1 : 0));
  5608. return 0;
  5609. }
  5610. /*==========================================
  5611. * @refresh (like @jumpto <<yourself>>)
  5612. *------------------------------------------*/
  5613. ACMD_FUNC(refresh)
  5614. {
  5615. nullpo_retr(-1, sd);
  5616. clif_refresh(sd);
  5617. return 0;
  5618. }
  5619. ACMD_FUNC(refreshall)
  5620. {
  5621. struct map_session_data* iter_sd;
  5622. struct s_mapiterator* iter;
  5623. nullpo_retr(-1, sd);
  5624. iter = mapit_getallusers();
  5625. for (iter_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); iter_sd = (TBL_PC*)mapit_next(iter))
  5626. clif_refresh(iter_sd);
  5627. mapit_free(iter);
  5628. return 0;
  5629. }
  5630. /*==========================================
  5631. * @identify
  5632. * => GM's magnifier.
  5633. *------------------------------------------*/
  5634. ACMD_FUNC(identify)
  5635. {
  5636. int i,num;
  5637. nullpo_retr(-1, sd);
  5638. for(i=num=0;i<MAX_INVENTORY;i++){
  5639. if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1){
  5640. num++;
  5641. }
  5642. }
  5643. if (num > 0) {
  5644. clif_item_identify_list(sd);
  5645. } else {
  5646. clif_displaymessage(fd,msg_txt(1238)); // There are no items to appraise.
  5647. }
  5648. return 0;
  5649. }
  5650. /*==========================================
  5651. * @gmotd (Global MOTD)
  5652. * by davidsiaw :P
  5653. *------------------------------------------*/
  5654. ACMD_FUNC(gmotd)
  5655. {
  5656. FILE* fp;
  5657. if( ( fp = fopen(motd_txt, "r") ) != NULL )
  5658. {
  5659. char buf[CHAT_SIZE_MAX];
  5660. size_t len;
  5661. while( fgets(buf, sizeof(buf), fp) )
  5662. {
  5663. if( buf[0] == '/' && buf[1] == '/' )
  5664. {
  5665. continue;
  5666. }
  5667. len = strlen(buf);
  5668. while( len && ( buf[len-1] == '\r' || buf[len-1] == '\n' ) )
  5669. {// strip trailing EOL characters
  5670. len--;
  5671. }
  5672. if( len )
  5673. {
  5674. buf[len] = 0;
  5675. intif_broadcast(buf, len+1, 0);
  5676. }
  5677. }
  5678. fclose(fp);
  5679. }
  5680. return 0;
  5681. }
  5682. ACMD_FUNC(misceffect)
  5683. {
  5684. int effect = 0;
  5685. nullpo_retr(-1, sd);
  5686. if (!message || !*message)
  5687. return -1;
  5688. if (sscanf(message, "%d", &effect) < 1)
  5689. return -1;
  5690. clif_misceffect(&sd->bl,effect);
  5691. return 0;
  5692. }
  5693. /*==========================================
  5694. * MAIL SYSTEM
  5695. *------------------------------------------*/
  5696. ACMD_FUNC(mail)
  5697. {
  5698. nullpo_ret(sd);
  5699. mail_openmail(sd);
  5700. return 0;
  5701. }
  5702. /*==========================================
  5703. * Show Monster DB Info v 1.0
  5704. * originally by [Lupus]
  5705. *------------------------------------------*/
  5706. ACMD_FUNC(mobinfo)
  5707. {
  5708. unsigned char msize[3][7] = {"Small", "Medium", "Large"};
  5709. unsigned char mrace[12][11] = {"Formless", "Undead", "Beast", "Plant", "Insect", "Fish", "Demon", "Demi-Human", "Angel", "Dragon", "Boss", "Non-Boss"};
  5710. unsigned char melement[10][8] = {"Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead"};
  5711. char atcmd_output2[CHAT_SIZE_MAX];
  5712. struct item_data *item_data;
  5713. struct mob_db *mob, *mob_array[MAX_SEARCH];
  5714. int count;
  5715. int i, j, k;
  5716. unsigned int base_exp, job_exp;
  5717. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5718. memset(atcmd_output2, '\0', sizeof(atcmd_output2));
  5719. if (!message || !*message) {
  5720. clif_displaymessage(fd, msg_txt(1239)); // Please enter a monster name/ID (usage: @mobinfo <monster_name_or_monster_ID>).
  5721. return -1;
  5722. }
  5723. // If monster identifier/name argument is a name
  5724. if ((i = mobdb_checkid(atoi(message))))
  5725. {
  5726. mob_array[0] = mob_db(i);
  5727. count = 1;
  5728. } else
  5729. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  5730. if (!count) {
  5731. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  5732. return -1;
  5733. }
  5734. if (count > MAX_SEARCH) {
  5735. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
  5736. clif_displaymessage(fd, atcmd_output);
  5737. count = MAX_SEARCH;
  5738. }
  5739. for (k = 0; k < count; k++) {
  5740. mob = mob_array[k];
  5741. base_exp = mob->base_exp;
  5742. job_exp = mob->job_exp;
  5743. #ifdef RENEWAL_EXP
  5744. if( battle_config.atcommand_mobinfo_type ) {
  5745. base_exp = base_exp * pc_level_penalty_mod(sd, mob->lv, mob->status.race, mob->status.mode, 1) / 100;
  5746. job_exp = job_exp * pc_level_penalty_mod(sd, mob->lv, mob->status.race, mob->status.mode, 1) / 100;
  5747. }
  5748. #endif
  5749. // stats
  5750. if (mob->mexp)
  5751. sprintf(atcmd_output, msg_txt(1240), mob->name, mob->jname, mob->sprite, mob->vd.class_); // MVP Monster: '%s'/'%s'/'%s' (%d)
  5752. else
  5753. sprintf(atcmd_output, msg_txt(1241), mob->name, mob->jname, mob->sprite, mob->vd.class_); // Monster: '%s'/'%s'/'%s' (%d)
  5754. clif_displaymessage(fd, atcmd_output);
  5755. sprintf(atcmd_output, msg_txt(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
  5756. clif_displaymessage(fd, atcmd_output);
  5757. sprintf(atcmd_output, msg_txt(1243), // DEF:%d MDEF:%d STR:%d AGI:%d VIT:%d INT:%d DEX:%d LUK:%d
  5758. mob->status.def, mob->status.mdef,mob->status.str, mob->status.agi,
  5759. mob->status.vit, mob->status.int_, mob->status.dex, mob->status.luk);
  5760. clif_displaymessage(fd, atcmd_output);
  5761. sprintf(atcmd_output, msg_txt(1244), // ATK:%d~%d Range:%d~%d~%d Size:%s Race: %s Element: %s (Lv:%d)
  5762. mob->status.rhw.atk, mob->status.rhw.atk2, mob->status.rhw.range,
  5763. mob->range2 , mob->range3, msize[mob->status.size],
  5764. mrace[mob->status.race], melement[mob->status.def_ele], mob->status.ele_lv);
  5765. clif_displaymessage(fd, atcmd_output);
  5766. // drops
  5767. clif_displaymessage(fd, msg_txt(1245)); // Drops:
  5768. strcpy(atcmd_output, " ");
  5769. j = 0;
  5770. for (i = 0; i < MAX_MOB_DROP; i++) {
  5771. int droprate;
  5772. if (mob->dropitem[i].nameid <= 0 || mob->dropitem[i].p < 1 || (item_data = itemdb_exists(mob->dropitem[i].nameid)) == NULL)
  5773. continue;
  5774. droprate = mob->dropitem[i].p;
  5775. #ifdef RENEWAL_DROP
  5776. if( battle_config.atcommand_mobinfo_type )
  5777. droprate = droprate * pc_level_penalty_mod(sd, mob->lv, mob->status.race, mob->status.mode, 2) / 100;
  5778. #endif
  5779. if (item_data->slot)
  5780. sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, (float)droprate / 100);
  5781. else
  5782. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)droprate / 100);
  5783. strcat(atcmd_output, atcmd_output2);
  5784. if (++j % 3 == 0) {
  5785. clif_displaymessage(fd, atcmd_output);
  5786. strcpy(atcmd_output, " ");
  5787. }
  5788. }
  5789. if (j == 0)
  5790. clif_displaymessage(fd, msg_txt(1246)); // This monster has no drops.
  5791. else if (j % 3 != 0)
  5792. clif_displaymessage(fd, atcmd_output);
  5793. // mvp
  5794. if (mob->mexp) {
  5795. sprintf(atcmd_output, msg_txt(1247), mob->mexp); // MVP Bonus EXP:%u
  5796. clif_displaymessage(fd, atcmd_output);
  5797. strcpy(atcmd_output, msg_txt(1248)); // MVP Items:
  5798. j = 0;
  5799. for (i = 0; i < MAX_MVP_DROP; i++) {
  5800. if (mob->mvpitem[i].nameid <= 0 || (item_data = itemdb_exists(mob->mvpitem[i].nameid)) == NULL)
  5801. continue;
  5802. if (mob->mvpitem[i].p > 0) {
  5803. j++;
  5804. if (j == 1)
  5805. sprintf(atcmd_output2, " %s %02.02f%%", item_data->jname, (float)mob->mvpitem[i].p / 100);
  5806. else
  5807. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)mob->mvpitem[i].p / 100);
  5808. strcat(atcmd_output, atcmd_output2);
  5809. }
  5810. }
  5811. if (j == 0)
  5812. clif_displaymessage(fd, msg_txt(1249)); // This monster has no MVP prizes.
  5813. else
  5814. clif_displaymessage(fd, atcmd_output);
  5815. }
  5816. }
  5817. return 0;
  5818. }
  5819. /*=========================================
  5820. * @showmobs by KarLaeda
  5821. * => For 15 sec displays the mobs on minimap
  5822. *------------------------------------------*/
  5823. ACMD_FUNC(showmobs)
  5824. {
  5825. char mob_name[100];
  5826. int mob_id;
  5827. int number = 0;
  5828. struct s_mapiterator* it;
  5829. nullpo_retr(-1, sd);
  5830. if(sscanf(message, "%99[^\n]", mob_name) < 0)
  5831. return -1;
  5832. if((mob_id = atoi(mob_name)) == 0)
  5833. mob_id = mobdb_searchname(mob_name);
  5834. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  5835. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(1250),mob_name); // Invalid mob id %s!
  5836. clif_displaymessage(fd, atcmd_output);
  5837. return 0;
  5838. }
  5839. 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.
  5840. clif_displaymessage(fd, msg_txt(1251)); // Can't show boss mobs!
  5841. return 0;
  5842. }
  5843. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  5844. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  5845. //strcpy(mob_name,mob_db(mob_id)->name); // --en--
  5846. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(1252), // Mob Search... %s %s
  5847. mob_name, mapindex_id2name(sd->mapindex));
  5848. clif_displaymessage(fd, atcmd_output);
  5849. it = mapit_geteachmob();
  5850. for(;;)
  5851. {
  5852. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  5853. if( md == NULL )
  5854. break;// no more mobs
  5855. if( md->bl.m != sd->bl.m )
  5856. continue;
  5857. if( mob_id != -1 && md->class_ != mob_id )
  5858. continue;
  5859. if( md->special_state.ai || md->master_id )
  5860. continue; // hide slaves and player summoned mobs
  5861. if( md->spawn_timer != INVALID_TIMER )
  5862. continue; // hide mobs waiting for respawn
  5863. ++number;
  5864. clif_viewpoint(sd, 1, 0, md->bl.x, md->bl.y, number, 0xFFFFFF);
  5865. }
  5866. mapit_free(it);
  5867. return 0;
  5868. }
  5869. /*==========================================
  5870. * homunculus level up [orn]
  5871. *------------------------------------------*/
  5872. ACMD_FUNC(homlevel)
  5873. {
  5874. TBL_HOM * hd;
  5875. int level = 0, i = 0;
  5876. nullpo_retr(-1, sd);
  5877. if ( !message || !*message || ( level = atoi(message) ) < 1 ) {
  5878. clif_displaymessage(fd, msg_txt(1253)); // Please enter a level adjustment (usage: @homlevel <number of levels>).
  5879. return -1;
  5880. }
  5881. if ( !merc_is_hom_active(sd->hd) ) {
  5882. clif_displaymessage(fd, msg_txt(1254)); // You do not have a homunculus.
  5883. return -1;
  5884. }
  5885. hd = sd->hd;
  5886. for (i = 1; i <= level && hd->exp_next; i++){
  5887. hd->homunculus.exp += hd->exp_next;
  5888. if( !merc_hom_levelup(hd) ){
  5889. break;
  5890. }
  5891. }
  5892. status_calc_homunculus(hd,0);
  5893. status_percent_heal(&hd->bl, 100, 100);
  5894. clif_specialeffect(&hd->bl,568,AREA);
  5895. return 0;
  5896. }
  5897. /*==========================================
  5898. * homunculus evolution H [orn]
  5899. *------------------------------------------*/
  5900. ACMD_FUNC(homevolution)
  5901. {
  5902. nullpo_retr(-1, sd);
  5903. if ( !merc_is_hom_active(sd->hd) ) {
  5904. clif_displaymessage(fd, msg_txt(1254)); // You do not have a homunculus.
  5905. return -1;
  5906. }
  5907. if ( !merc_hom_evolution(sd->hd) ) {
  5908. clif_displaymessage(fd, msg_txt(1255)); // Your homunculus doesn't evolve.
  5909. return -1;
  5910. }
  5911. clif_homskillinfoblock(sd);
  5912. return 0;
  5913. }
  5914. ACMD_FUNC(hommutate)
  5915. {
  5916. int homun_id, m_class = 0, m_id;
  5917. nullpo_retr(-1, sd);
  5918. if (!merc_is_hom_active(sd->hd)) {
  5919. clif_displaymessage(fd, msg_txt(1254)); // You do not have a homunculus.
  5920. return -1;
  5921. }
  5922. if (!message || !*message) {
  5923. homun_id = 6048 + (rnd() % 4);
  5924. } else {
  5925. homun_id = atoi(message);
  5926. }
  5927. m_class = hom_class2mapid(sd->hd->homunculus.class_);
  5928. m_id = hom_class2mapid(homun_id);
  5929. if (m_class != -1 && m_id != -1 && m_class&HOM_EVO && m_id&HOM_S && sd->hd->homunculus.level >= 99) {
  5930. hom_mutate(sd->hd, homun_id);
  5931. } else {
  5932. clif_emotion(&sd->hd->bl, E_SWT);
  5933. }
  5934. return 0;
  5935. }
  5936. /*==========================================
  5937. * call choosen homunculus [orn]
  5938. *------------------------------------------*/
  5939. ACMD_FUNC(makehomun)
  5940. {
  5941. int homunid;
  5942. nullpo_retr(-1, sd);
  5943. if ( sd->status.hom_id ) {
  5944. clif_displaymessage(fd, msg_txt(450));
  5945. return -1;
  5946. }
  5947. if (!message || !*message) {
  5948. clif_displaymessage(fd, msg_txt(1256)); // Please enter a homunculus ID (usage: @makehomun <homunculus id>).
  5949. return -1;
  5950. }
  5951. homunid = atoi(message);
  5952. if( homunid < HM_CLASS_BASE || homunid > HM_CLASS_BASE + MAX_HOMUNCULUS_CLASS - 1 )
  5953. {
  5954. clif_displaymessage(fd, msg_txt(1257)); // Invalid Homunculus ID.
  5955. return -1;
  5956. }
  5957. merc_create_homunculus_request(sd,homunid);
  5958. return 0;
  5959. }
  5960. /*==========================================
  5961. * modify homunculus intimacy [orn]
  5962. *------------------------------------------*/
  5963. ACMD_FUNC(homfriendly)
  5964. {
  5965. int friendly = 0;
  5966. nullpo_retr(-1, sd);
  5967. if ( !merc_is_hom_active(sd->hd) ) {
  5968. clif_displaymessage(fd, msg_txt(1254)); // You do not have a homunculus.
  5969. return -1;
  5970. }
  5971. if (!message || !*message) {
  5972. clif_displaymessage(fd, msg_txt(1258)); // Please enter a friendly value (usage: @homfriendly <friendly value [0-1000]>).
  5973. return -1;
  5974. }
  5975. friendly = atoi(message);
  5976. friendly = cap_value(friendly, 0, 1000);
  5977. sd->hd->homunculus.intimacy = friendly * 100 ;
  5978. clif_send_homdata(sd,SP_INTIMATE,friendly);
  5979. return 0;
  5980. }
  5981. /*==========================================
  5982. * modify homunculus hunger [orn]
  5983. *------------------------------------------*/
  5984. ACMD_FUNC(homhungry)
  5985. {
  5986. int hungry = 0;
  5987. nullpo_retr(-1, sd);
  5988. if ( !merc_is_hom_active(sd->hd) ) {
  5989. clif_displaymessage(fd, msg_txt(1254)); // You do not have a homunculus.
  5990. return -1;
  5991. }
  5992. if (!message || !*message) {
  5993. clif_displaymessage(fd, msg_txt(1259)); // Please enter a hunger value (usage: @homhungry <hunger value [0-100]>).
  5994. return -1;
  5995. }
  5996. hungry = atoi(message);
  5997. hungry = cap_value(hungry, 0, 100);
  5998. sd->hd->homunculus.hunger = hungry;
  5999. clif_send_homdata(sd,SP_HUNGRY,hungry);
  6000. return 0;
  6001. }
  6002. /*==========================================
  6003. * make the homunculus speak [orn]
  6004. *------------------------------------------*/
  6005. ACMD_FUNC(homtalk)
  6006. {
  6007. char mes[100],temp[100];
  6008. nullpo_retr(-1, sd);
  6009. if ( battle_config.min_chat_delay ) {
  6010. if( DIFF_TICK(sd->cantalk_tick, gettick()) > 0 )
  6011. return 0;
  6012. sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
  6013. }
  6014. if (sd->sc.count && //no "chatting" while muted.
  6015. (sd->sc.data[SC_BERSERK] || sd->sc.data[SC__BLOODYLUST] ||
  6016. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  6017. return -1;
  6018. if ( !merc_is_hom_active(sd->hd) ) {
  6019. clif_displaymessage(fd, msg_txt(1254)); // You do not have a homunculus.
  6020. return -1;
  6021. }
  6022. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  6023. clif_displaymessage(fd, msg_txt(1260)); // Please enter a message (usage: @homtalk <message>).
  6024. return -1;
  6025. }
  6026. snprintf(temp, sizeof temp ,"%s : %s", sd->hd->homunculus.name, mes);
  6027. clif_disp_overhead(&sd->hd->bl, temp);
  6028. return 0;
  6029. }
  6030. /*==========================================
  6031. * Show homunculus stats
  6032. *------------------------------------------*/
  6033. ACMD_FUNC(hominfo)
  6034. {
  6035. struct homun_data *hd;
  6036. struct status_data *status;
  6037. nullpo_retr(-1, sd);
  6038. if ( !merc_is_hom_active(sd->hd) ) {
  6039. clif_displaymessage(fd, msg_txt(1254)); // You do not have a homunculus.
  6040. return -1;
  6041. }
  6042. hd = sd->hd;
  6043. status = status_get_status_data(&hd->bl);
  6044. clif_displaymessage(fd, msg_txt(1261)); // Homunculus stats:
  6045. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1262), // HP: %d/%d - SP: %d/%d
  6046. status->hp, status->max_hp, status->sp, status->max_sp);
  6047. clif_displaymessage(fd, atcmd_output);
  6048. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1263), // ATK: %d - MATK: %d~%d
  6049. status->rhw.atk2 +status->batk, status->matk_min, status->matk_max);
  6050. clif_displaymessage(fd, atcmd_output);
  6051. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1264), // Hungry: %d - Intimacy: %u
  6052. hd->homunculus.hunger, hd->homunculus.intimacy/100);
  6053. clif_displaymessage(fd, atcmd_output);
  6054. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6055. msg_txt(1265), // Stats: Str %d / Agi %d / Vit %d / Int %d / Dex %d / Luk %d
  6056. status->str, status->agi, status->vit,
  6057. status->int_, status->dex, status->luk);
  6058. clif_displaymessage(fd, atcmd_output);
  6059. return 0;
  6060. }
  6061. ACMD_FUNC(homstats)
  6062. {
  6063. struct homun_data *hd;
  6064. struct s_homunculus_db *db;
  6065. struct s_homunculus *hom;
  6066. int lv, min, max, evo;
  6067. nullpo_retr(-1, sd);
  6068. if ( !merc_is_hom_active(sd->hd) ) {
  6069. clif_displaymessage(fd, msg_txt(1254)); // You do not have a homunculus.
  6070. return -1;
  6071. }
  6072. hd = sd->hd;
  6073. hom = &hd->homunculus;
  6074. db = hd->homunculusDB;
  6075. lv = hom->level;
  6076. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6077. msg_txt(1266), lv, db->name); // Homunculus growth stats (Lv %d %s):
  6078. clif_displaymessage(fd, atcmd_output);
  6079. lv--; //Since the first increase is at level 2.
  6080. evo = (hom->class_ == db->evo_class);
  6081. min = db->base.HP +lv*db->gmin.HP +(evo?db->emin.HP:0);
  6082. max = db->base.HP +lv*db->gmax.HP +(evo?db->emax.HP:0);;
  6083. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1267), hom->max_hp, min, max); // Max HP: %d (%d~%d)
  6084. clif_displaymessage(fd, atcmd_output);
  6085. min = db->base.SP +lv*db->gmin.SP +(evo?db->emin.SP:0);
  6086. max = db->base.SP +lv*db->gmax.SP +(evo?db->emax.SP:0);;
  6087. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1268), hom->max_sp, min, max); // Max SP: %d (%d~%d)
  6088. clif_displaymessage(fd, atcmd_output);
  6089. min = db->base.str +lv*(db->gmin.str/10) +(evo?db->emin.str:0);
  6090. max = db->base.str +lv*(db->gmax.str/10) +(evo?db->emax.str:0);;
  6091. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1269), hom->str/10, min, max); // Str: %d (%d~%d)
  6092. clif_displaymessage(fd, atcmd_output);
  6093. min = db->base.agi +lv*(db->gmin.agi/10) +(evo?db->emin.agi:0);
  6094. max = db->base.agi +lv*(db->gmax.agi/10) +(evo?db->emax.agi:0);;
  6095. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1270), hom->agi/10, min, max); // Agi: %d (%d~%d)
  6096. clif_displaymessage(fd, atcmd_output);
  6097. min = db->base.vit +lv*(db->gmin.vit/10) +(evo?db->emin.vit:0);
  6098. max = db->base.vit +lv*(db->gmax.vit/10) +(evo?db->emax.vit:0);;
  6099. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1271), hom->vit/10, min, max); // Vit: %d (%d~%d)
  6100. clif_displaymessage(fd, atcmd_output);
  6101. min = db->base.int_ +lv*(db->gmin.int_/10) +(evo?db->emin.int_:0);
  6102. max = db->base.int_ +lv*(db->gmax.int_/10) +(evo?db->emax.int_:0);;
  6103. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1272), hom->int_/10, min, max); // Int: %d (%d~%d)
  6104. clif_displaymessage(fd, atcmd_output);
  6105. min = db->base.dex +lv*(db->gmin.dex/10) +(evo?db->emin.dex:0);
  6106. max = db->base.dex +lv*(db->gmax.dex/10) +(evo?db->emax.dex:0);;
  6107. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1273), hom->dex/10, min, max); // Dex: %d (%d~%d)
  6108. clif_displaymessage(fd, atcmd_output);
  6109. min = db->base.luk +lv*(db->gmin.luk/10) +(evo?db->emin.luk:0);
  6110. max = db->base.luk +lv*(db->gmax.luk/10) +(evo?db->emax.luk:0);;
  6111. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1274), hom->luk/10, min, max); // Luk: %d (%d~%d)
  6112. clif_displaymessage(fd, atcmd_output);
  6113. return 0;
  6114. }
  6115. ACMD_FUNC(homshuffle)
  6116. {
  6117. nullpo_retr(-1, sd);
  6118. if(!sd->hd)
  6119. return -1; // nothing to do
  6120. if(!merc_hom_shuffle(sd->hd))
  6121. return -1;
  6122. clif_displaymessage(sd->fd, msg_txt(1275)); // Homunculus stats altered.
  6123. atcommand_homstats(fd, sd, command, message); //Print out the new stats
  6124. return 0;
  6125. }
  6126. /*==========================================
  6127. * Show Items DB Info v 1.0
  6128. * originally by [Lupus]
  6129. *------------------------------------------*/
  6130. ACMD_FUNC(iteminfo)
  6131. {
  6132. struct item_data *item_data, *item_array[MAX_SEARCH];
  6133. int i, count = 1;
  6134. if (!message || !*message) {
  6135. clif_displaymessage(fd, msg_txt(1276)); // Please enter an item name/ID (usage: @ii/@iteminfo <item name/ID>).
  6136. return -1;
  6137. }
  6138. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  6139. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  6140. if (!count) {
  6141. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  6142. return -1;
  6143. }
  6144. if (count > MAX_SEARCH) {
  6145. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count); // Displaying first %d out of %d matches
  6146. clif_displaymessage(fd, atcmd_output);
  6147. count = MAX_SEARCH;
  6148. }
  6149. for (i = 0; i < count; i++) {
  6150. item_data = item_array[i];
  6151. sprintf(atcmd_output, msg_txt(1277), // Item: '%s'/'%s'[%d] (%d) Type: %s | Extra Effect: %s
  6152. item_data->name,item_data->jname,item_data->slot,item_data->nameid,
  6153. itemdb_typename(item_data->type),
  6154. (item_data->script==NULL)? msg_txt(1278) : msg_txt(1279) // None / With script
  6155. );
  6156. clif_displaymessage(fd, atcmd_output);
  6157. sprintf(atcmd_output, msg_txt(1280), item_data->value_buy, item_data->value_sell, item_data->weight/10. ); // NPC Buy:%dz, Sell:%dz | Weight: %.1f
  6158. clif_displaymessage(fd, atcmd_output);
  6159. if (item_data->maxchance == -1)
  6160. strcpy(atcmd_output, msg_txt(1281)); // - Available in the shops only.
  6161. else if (!battle_config.atcommand_mobinfo_type && item_data->maxchance)
  6162. sprintf(atcmd_output, msg_txt(1282), (float)item_data->maxchance / 100 ); // - Maximal monsters drop chance: %02.02f%%
  6163. else
  6164. strcpy(atcmd_output, msg_txt(1283)); // - Monsters don't drop this item.
  6165. clif_displaymessage(fd, atcmd_output);
  6166. }
  6167. return 0;
  6168. }
  6169. /*==========================================
  6170. * Show who drops the item.
  6171. *------------------------------------------*/
  6172. ACMD_FUNC(whodrops)
  6173. {
  6174. struct item_data *item_data, *item_array[MAX_SEARCH];
  6175. int i,j, count = 1;
  6176. if (!message || !*message) {
  6177. clif_displaymessage(fd, msg_txt(1284)); // Please enter item name/ID (usage: @whodrops <item name/ID>).
  6178. return -1;
  6179. }
  6180. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  6181. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  6182. if (!count) {
  6183. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  6184. return -1;
  6185. }
  6186. if (count > MAX_SEARCH) {
  6187. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count); // Displaying first %d out of %d matches
  6188. clif_displaymessage(fd, atcmd_output);
  6189. count = MAX_SEARCH;
  6190. }
  6191. for (i = 0; i < count; i++) {
  6192. item_data = item_array[i];
  6193. sprintf(atcmd_output, msg_txt(1285), item_data->jname,item_data->slot); // Item: '%s'[%d]
  6194. clif_displaymessage(fd, atcmd_output);
  6195. if (item_data->mob[0].chance == 0) {
  6196. strcpy(atcmd_output, msg_txt(1286)); // - Item is not dropped by mobs.
  6197. clif_displaymessage(fd, atcmd_output);
  6198. } else {
  6199. sprintf(atcmd_output, msg_txt(1287), MAX_SEARCH); // - Common mobs with highest drop chance (only max %d are listed):
  6200. clif_displaymessage(fd, atcmd_output);
  6201. for (j=0; j < MAX_SEARCH && item_data->mob[j].chance > 0; j++)
  6202. {
  6203. int dropchance = item_data->mob[j].chance;
  6204. #ifdef RENEWAL_DROP
  6205. if( battle_config.atcommand_mobinfo_type )
  6206. 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;
  6207. #endif
  6208. sprintf(atcmd_output, "- %s (%02.02f%%)", mob_db(item_data->mob[j].id)->jname, dropchance/100.);
  6209. clif_displaymessage(fd, atcmd_output);
  6210. }
  6211. }
  6212. }
  6213. return 0;
  6214. }
  6215. ACMD_FUNC(whereis)
  6216. {
  6217. struct mob_db *mob, *mob_array[MAX_SEARCH];
  6218. int count;
  6219. int i, j, k;
  6220. if (!message || !*message) {
  6221. clif_displaymessage(fd, msg_txt(1288)); // Please enter a monster name/ID (usage: @whereis <monster_name_or_monster_ID>).
  6222. return -1;
  6223. }
  6224. // If monster identifier/name argument is a name
  6225. if ((i = mobdb_checkid(atoi(message))))
  6226. {
  6227. mob_array[0] = mob_db(i);
  6228. count = 1;
  6229. } else
  6230. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  6231. if (!count) {
  6232. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  6233. return -1;
  6234. }
  6235. if (count > MAX_SEARCH) {
  6236. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
  6237. clif_displaymessage(fd, atcmd_output);
  6238. count = MAX_SEARCH;
  6239. }
  6240. for (k = 0; k < count; k++) {
  6241. mob = mob_array[k];
  6242. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(1289), mob->jname); // %s spawns in:
  6243. clif_displaymessage(fd, atcmd_output);
  6244. for (i = 0; i < ARRAYLENGTH(mob->spawn) && mob->spawn[i].qty; i++)
  6245. {
  6246. j = map_mapindex2mapid(mob->spawn[i].mapindex);
  6247. if (j < 0) continue;
  6248. snprintf(atcmd_output, sizeof atcmd_output, "%s (%d)", map[j].name, mob->spawn[i].qty);
  6249. clif_displaymessage(fd, atcmd_output);
  6250. }
  6251. if (i == 0)
  6252. clif_displaymessage(fd, msg_txt(1290)); // This monster does not spawn normally.
  6253. }
  6254. return 0;
  6255. }
  6256. ACMD_FUNC(version)
  6257. {
  6258. const char * revision;
  6259. if ((revision = get_svn_revision()) != 0) {
  6260. sprintf(atcmd_output,msg_txt(1295),revision); // rAthena Version SVN r%s
  6261. clif_displaymessage(fd,atcmd_output);
  6262. } else
  6263. clif_displaymessage(fd,msg_txt(1296)); // Cannot determine SVN revision.
  6264. return 0;
  6265. }
  6266. /*==========================================
  6267. * @mutearea by MouseJstr
  6268. *------------------------------------------*/
  6269. static int atcommand_mutearea_sub(struct block_list *bl,va_list ap)
  6270. {
  6271. int time, id;
  6272. struct map_session_data *pl_sd = (struct map_session_data *)bl;
  6273. if (pl_sd == NULL)
  6274. return 0;
  6275. id = va_arg(ap, int);
  6276. time = va_arg(ap, int);
  6277. if (id != bl->id && !pc_get_group_level(pl_sd)) {
  6278. pl_sd->status.manner -= time;
  6279. if (pl_sd->status.manner < 0)
  6280. sc_start(NULL,&pl_sd->bl,SC_NOCHAT,100,0,0);
  6281. else
  6282. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  6283. }
  6284. return 0;
  6285. }
  6286. ACMD_FUNC(mutearea)
  6287. {
  6288. int time;
  6289. nullpo_ret(sd);
  6290. if (!message || !*message) {
  6291. clif_displaymessage(fd, msg_txt(1297)); // Please enter a time in minutes (usage: @mutearea/@stfu <time in minutes>).
  6292. return -1;
  6293. }
  6294. time = atoi(message);
  6295. map_foreachinarea(atcommand_mutearea_sub,sd->bl.m,
  6296. sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE,
  6297. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time);
  6298. return 0;
  6299. }
  6300. ACMD_FUNC(rates)
  6301. {
  6302. char buf[CHAT_SIZE_MAX];
  6303. nullpo_ret(sd);
  6304. memset(buf, '\0', sizeof(buf));
  6305. snprintf(buf, CHAT_SIZE_MAX, msg_txt(1298), // Experience rates: Base %.2fx / Job %.2fx
  6306. battle_config.base_exp_rate/100., battle_config.job_exp_rate/100.);
  6307. clif_displaymessage(fd, buf);
  6308. snprintf(buf, CHAT_SIZE_MAX, msg_txt(1299), // Normal Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  6309. 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.);
  6310. clif_displaymessage(fd, buf);
  6311. snprintf(buf, CHAT_SIZE_MAX, msg_txt(1300), // Boss Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  6312. 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.);
  6313. clif_displaymessage(fd, buf);
  6314. snprintf(buf, CHAT_SIZE_MAX, msg_txt(1301), // Other Drop Rates: MvP %.2fx / Card-Based %.2fx / Treasure %.2fx
  6315. battle_config.item_rate_mvp/100., battle_config.item_rate_adddrop/100., battle_config.item_rate_treasure/100.);
  6316. clif_displaymessage(fd, buf);
  6317. return 0;
  6318. }
  6319. /*==========================================
  6320. * @me by lordalfa
  6321. * => Displays the OUTPUT string on top of the Visible players Heads.
  6322. *------------------------------------------*/
  6323. ACMD_FUNC(me)
  6324. {
  6325. char tempmes[CHAT_SIZE_MAX];
  6326. nullpo_retr(-1, sd);
  6327. memset(tempmes, '\0', sizeof(tempmes));
  6328. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6329. if (sd->sc.count && //no "chatting" while muted.
  6330. (sd->sc.data[SC_BERSERK] || sd->sc.data[SC__BLOODYLUST] ||
  6331. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  6332. return -1;
  6333. if (!message || !*message || sscanf(message, "%199[^\n]", tempmes) < 0) {
  6334. clif_displaymessage(fd, msg_txt(1302)); // Please enter a message (usage: @me <message>).
  6335. return -1;
  6336. }
  6337. sprintf(atcmd_output, msg_txt(270), sd->status.name, tempmes); // *%s %s*
  6338. clif_disp_overhead(&sd->bl, atcmd_output);
  6339. return 0;
  6340. }
  6341. /*==========================================
  6342. * @size
  6343. * => Resize your character sprite. [Valaris]
  6344. *------------------------------------------*/
  6345. ACMD_FUNC(size)
  6346. {
  6347. int size = 0;
  6348. nullpo_retr(-1, sd);
  6349. size = cap_value(atoi(message),SZ_SMALL,SZ_BIG);
  6350. if(sd->state.size) {
  6351. sd->state.size = SZ_SMALL;
  6352. pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_TELEPORT);
  6353. }
  6354. sd->state.size = size;
  6355. if( size == SZ_MEDIUM )
  6356. clif_specialeffect(&sd->bl,420,AREA);
  6357. else if( size == SZ_BIG )
  6358. clif_specialeffect(&sd->bl,422,AREA);
  6359. clif_displaymessage(fd, msg_txt(1303)); // Size change applied.
  6360. return 0;
  6361. }
  6362. ACMD_FUNC(sizeall)
  6363. {
  6364. int size;
  6365. struct map_session_data *pl_sd;
  6366. struct s_mapiterator* iter;
  6367. size = atoi(message);
  6368. size = cap_value(size,0,2);
  6369. iter = mapit_getallusers();
  6370. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) {
  6371. if( pl_sd->state.size != size ) {
  6372. if( pl_sd->state.size ) {
  6373. pl_sd->state.size = SZ_SMALL;
  6374. pc_setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  6375. }
  6376. pl_sd->state.size = size;
  6377. if( size == SZ_MEDIUM )
  6378. clif_specialeffect(&pl_sd->bl,420,AREA);
  6379. else if( size == SZ_BIG )
  6380. clif_specialeffect(&pl_sd->bl,422,AREA);
  6381. }
  6382. }
  6383. mapit_free(iter);
  6384. clif_displaymessage(fd, msg_txt(1303)); // Size change applied.
  6385. return 0;
  6386. }
  6387. ACMD_FUNC(sizeguild)
  6388. {
  6389. int size = 0, i;
  6390. char guild[NAME_LENGTH];
  6391. struct map_session_data *pl_sd;
  6392. struct guild *g;
  6393. nullpo_retr(-1, sd);
  6394. memset(guild, '\0', sizeof(guild));
  6395. if( !message || !*message || sscanf(message, "%d %23[^\n]", &size, guild) < 2 ) {
  6396. clif_displaymessage(fd, msg_txt(1304)); // Please enter guild name/ID (usage: @sizeguild <size> <guild name/ID>).
  6397. return -1;
  6398. }
  6399. if( (g = guild_searchname(guild)) == NULL && (g = guild_search(atoi(guild))) == NULL ) {
  6400. clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online.
  6401. return -1;
  6402. }
  6403. size = cap_value(size,SZ_SMALL,SZ_BIG);
  6404. for( i = 0; i < g->max_member; i++ ) {
  6405. if( (pl_sd = g->member[i].sd) && pl_sd->state.size != size ) {
  6406. if( pl_sd->state.size ) {
  6407. pl_sd->state.size = SZ_SMALL;
  6408. pc_setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  6409. }
  6410. pl_sd->state.size = size;
  6411. if( size == SZ_MEDIUM )
  6412. clif_specialeffect(&pl_sd->bl,420,AREA);
  6413. else if( size == SZ_BIG )
  6414. clif_specialeffect(&pl_sd->bl,422,AREA);
  6415. }
  6416. }
  6417. clif_displaymessage(fd, msg_txt(1303)); // Size change applied.
  6418. return 0;
  6419. }
  6420. /*==========================================
  6421. * @monsterignore
  6422. * => Makes monsters ignore you. [Valaris]
  6423. *------------------------------------------*/
  6424. ACMD_FUNC(monsterignore)
  6425. {
  6426. nullpo_retr(-1, sd);
  6427. if (!sd->state.monster_ignore) {
  6428. sd->state.monster_ignore = 1;
  6429. clif_displaymessage(sd->fd, msg_txt(1305)); // You are now immune to attacks.
  6430. } else {
  6431. sd->state.monster_ignore = 0;
  6432. clif_displaymessage(sd->fd, msg_txt(1306)); // Returned to normal state.
  6433. }
  6434. return 0;
  6435. }
  6436. /*==========================================
  6437. * @fakename
  6438. * => Gives your character a fake name. [Valaris]
  6439. *------------------------------------------*/
  6440. ACMD_FUNC(fakename)
  6441. {
  6442. nullpo_retr(-1, sd);
  6443. if( !message || !*message )
  6444. {
  6445. if( sd->fakename[0] )
  6446. {
  6447. sd->fakename[0] = '\0';
  6448. clif_charnameack(0, &sd->bl);
  6449. clif_displaymessage(sd->fd, msg_txt(1307)); // Returned to real name.
  6450. return 0;
  6451. }
  6452. clif_displaymessage(sd->fd, msg_txt(1308)); // You must enter a name.
  6453. return -1;
  6454. }
  6455. if( strlen(message) < 2 )
  6456. {
  6457. clif_displaymessage(sd->fd, msg_txt(1309)); // Fake name must be at least two characters.
  6458. return -1;
  6459. }
  6460. safestrncpy(sd->fakename, message, sizeof(sd->fakename));
  6461. clif_charnameack(0, &sd->bl);
  6462. clif_displaymessage(sd->fd, msg_txt(1310)); // Fake name enabled.
  6463. return 0;
  6464. }
  6465. /*==========================================
  6466. * Ragnarok Resources
  6467. *------------------------------------------*/
  6468. ACMD_FUNC(mapflag) {
  6469. #define checkflag( cmd ) if ( map[ sd->bl.m ].flag.cmd ) clif_displaymessage(sd->fd,#cmd)
  6470. #define setflag( cmd ) \
  6471. if ( strcmp( flag_name , #cmd ) == 0 ){\
  6472. map[ sd->bl.m ].flag.cmd = flag;\
  6473. sprintf(atcmd_output,"[ @mapflag ] %s flag has been set to %s value = %hd",#cmd,flag?"On":"Off",flag);\
  6474. clif_displaymessage(sd->fd,atcmd_output);\
  6475. return 0;\
  6476. }
  6477. char flag_name[100];
  6478. short flag=0,i;
  6479. nullpo_retr(-1, sd);
  6480. memset(flag_name, '\0', sizeof(flag_name));
  6481. if (!message || !*message || (sscanf(message, "%99s %hd", flag_name, &flag) < 1)) {
  6482. clif_displaymessage(sd->fd,msg_txt(1311)); // Enabled Mapflags in this map:
  6483. clif_displaymessage(sd->fd,"----------------------------------");
  6484. checkflag(autotrade); checkflag(allowks); checkflag(nomemo); checkflag(noteleport);
  6485. checkflag(noreturn); checkflag(monster_noteleport); checkflag(nosave); checkflag(nobranch);
  6486. checkflag(noexppenalty); checkflag(pvp); checkflag(pvp_noparty); checkflag(pvp_noguild);
  6487. checkflag(pvp_nightmaredrop); checkflag(pvp_nocalcrank); checkflag(gvg_castle); checkflag(gvg);
  6488. checkflag(gvg_dungeon); checkflag(gvg_noparty); checkflag(battleground);checkflag(nozenypenalty);
  6489. checkflag(notrade); checkflag(noskill); checkflag(nowarp); checkflag(nowarpto);
  6490. checkflag(noicewall); checkflag(snow); checkflag(clouds); checkflag(clouds2);
  6491. checkflag(fog); checkflag(fireworks); checkflag(sakura); checkflag(leaves);
  6492. checkflag(nogo); checkflag(nobaseexp);
  6493. checkflag(nojobexp); checkflag(nomobloot); checkflag(nomvploot); checkflag(nightenabled);
  6494. checkflag(restricted); checkflag(nodrop); checkflag(novending); checkflag(loadevent);
  6495. checkflag(nochat); checkflag(partylock); checkflag(guildlock); checkflag(src4instance);
  6496. clif_displaymessage(sd->fd," ");
  6497. clif_displaymessage(sd->fd,msg_txt(1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On)
  6498. clif_displaymessage(sd->fd,msg_txt(1313)); // Type "@mapflag available" to list the available mapflags.
  6499. return 1;
  6500. }
  6501. for (i = 0; flag_name[i]; i++) flag_name[i] = (char)tolower(flag_name[i]); //lowercase
  6502. setflag(autotrade); setflag(allowks); setflag(nomemo); setflag(noteleport);
  6503. setflag(noreturn); setflag(monster_noteleport);setflag(nosave); setflag(nobranch);
  6504. setflag(noexppenalty); setflag(pvp); setflag(pvp_noparty); setflag(pvp_noguild);
  6505. setflag(pvp_nightmaredrop); setflag(pvp_nocalcrank); setflag(gvg_castle); setflag(gvg);
  6506. setflag(gvg_dungeon); setflag(gvg_noparty); setflag(battleground); setflag(nozenypenalty);
  6507. setflag(notrade); setflag(noskill); setflag(nowarp); setflag(nowarpto);
  6508. setflag(noicewall); setflag(snow); setflag(clouds); setflag(clouds2);
  6509. setflag(fog); setflag(fireworks); setflag(sakura); setflag(leaves);
  6510. setflag(nogo); setflag(nobaseexp);
  6511. setflag(nojobexp); setflag(nomobloot); setflag(nomvploot); setflag(nightenabled);
  6512. setflag(restricted); setflag(nodrop); setflag(novending); setflag(loadevent);
  6513. setflag(nochat); setflag(partylock); setflag(guildlock); setflag(src4instance);
  6514. clif_displaymessage(sd->fd,msg_txt(1314)); // Invalid flag name or flag.
  6515. clif_displaymessage(sd->fd,msg_txt(1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On)
  6516. clif_displaymessage(sd->fd,msg_txt(1315)); // Available Flags:
  6517. clif_displaymessage(sd->fd,"----------------------------------");
  6518. clif_displaymessage(sd->fd,"town, autotrade, allowks, nomemo, noteleport, noreturn, monster_noteleport, nosave,");
  6519. clif_displaymessage(sd->fd,"nobranch, noexppenalty, pvp, pvp_noparty, pvp_noguild, pvp_nightmaredrop,");
  6520. clif_displaymessage(sd->fd,"pvp_nocalcrank, gvg_castle, gvg, gvg_dungeon, gvg_noparty, battleground,");
  6521. clif_displaymessage(sd->fd,"nozenypenalty, notrade, noskill, nowarp, nowarpto, noicewall, snow, clouds, clouds2,");
  6522. clif_displaymessage(sd->fd,"fog, fireworks, sakura, leaves, nogo, nobaseexp, nojobexp, nomobloot,");
  6523. clif_displaymessage(sd->fd,"nomvploot, nightenabled, restricted, nodrop, novending, loadevent, nochat, partylock,");
  6524. clif_displaymessage(sd->fd,"guildlock, src4instance");
  6525. #undef checkflag
  6526. #undef setflag
  6527. return 0;
  6528. }
  6529. /*===================================
  6530. * Remove some messages
  6531. *-----------------------------------*/
  6532. ACMD_FUNC(showexp)
  6533. {
  6534. if (sd->state.showexp) {
  6535. sd->state.showexp = 0;
  6536. clif_displaymessage(fd, msg_txt(1316)); // Gained exp will not be shown.
  6537. return 0;
  6538. }
  6539. sd->state.showexp = 1;
  6540. clif_displaymessage(fd, msg_txt(1317)); // Gained exp is now shown.
  6541. return 0;
  6542. }
  6543. ACMD_FUNC(showzeny)
  6544. {
  6545. if (sd->state.showzeny) {
  6546. sd->state.showzeny = 0;
  6547. clif_displaymessage(fd, msg_txt(1318)); // Gained zeny will not be shown.
  6548. return 0;
  6549. }
  6550. sd->state.showzeny = 1;
  6551. clif_displaymessage(fd, msg_txt(1319)); // Gained zeny is now shown.
  6552. return 0;
  6553. }
  6554. ACMD_FUNC(showdelay)
  6555. {
  6556. if (sd->state.showdelay) {
  6557. sd->state.showdelay = 0;
  6558. clif_displaymessage(fd, msg_txt(1320)); // Skill delay failures will not be shown.
  6559. return 0;
  6560. }
  6561. sd->state.showdelay = 1;
  6562. clif_displaymessage(fd, msg_txt(1321)); // Skill delay failures are now shown.
  6563. return 0;
  6564. }
  6565. /*==========================================
  6566. * Duel organizing functions [LuzZza]
  6567. *
  6568. * @duel [limit|nick] - create a duel
  6569. * @invite <nick> - invite player
  6570. * @accept - accept invitation
  6571. * @reject - reject invitation
  6572. * @leave - leave duel
  6573. *------------------------------------------*/
  6574. ACMD_FUNC(invite)
  6575. {
  6576. unsigned int did = sd->duel_group;
  6577. struct map_session_data *target_sd = map_nick2sd((char *)message);
  6578. if(did == 0) {
  6579. // "Duel: @invite without @duel."
  6580. clif_displaymessage(fd, msg_txt(350));
  6581. return 0;
  6582. }
  6583. if(duel_list[did].max_players_limit > 0 &&
  6584. duel_list[did].members_count >= duel_list[did].max_players_limit) {
  6585. // "Duel: Limit of players is reached."
  6586. clif_displaymessage(fd, msg_txt(351));
  6587. return 0;
  6588. }
  6589. if(target_sd == NULL) {
  6590. // "Duel: Player not found."
  6591. clif_displaymessage(fd, msg_txt(352));
  6592. return 0;
  6593. }
  6594. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  6595. // "Duel: Player already in duel."
  6596. clif_displaymessage(fd, msg_txt(353));
  6597. return 0;
  6598. }
  6599. if(battle_config.duel_only_on_same_map && target_sd->bl.m != sd->bl.m)
  6600. {
  6601. sprintf(atcmd_output, msg_txt(364), message);
  6602. clif_displaymessage(fd, atcmd_output);
  6603. return 0;
  6604. }
  6605. duel_invite(did, sd, target_sd);
  6606. // "Duel: Invitation has been sent."
  6607. clif_displaymessage(fd, msg_txt(354));
  6608. return 0;
  6609. }
  6610. ACMD_FUNC(duel)
  6611. {
  6612. unsigned int maxpl = 0;
  6613. if(sd->duel_group > 0) {
  6614. duel_showinfo(sd->duel_group, sd);
  6615. return 0;
  6616. }
  6617. if(sd->duel_invite > 0) {
  6618. // "Duel: @duel without @reject."
  6619. clif_displaymessage(fd, msg_txt(355));
  6620. return 0;
  6621. }
  6622. if(!duel_checktime(sd)) {
  6623. char output[CHAT_SIZE_MAX];
  6624. // "Duel: You can take part in duel only one time per %d minutes."
  6625. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  6626. clif_displaymessage(fd, output);
  6627. return 0;
  6628. }
  6629. if( message[0] ) {
  6630. if(sscanf(message, "%d", &maxpl) >= 1) {
  6631. if(maxpl < 2 || maxpl > 65535) {
  6632. clif_displaymessage(fd, msg_txt(357)); // "Duel: Invalid value."
  6633. return 0;
  6634. }
  6635. duel_create(sd, maxpl);
  6636. } else {
  6637. struct map_session_data *target_sd;
  6638. target_sd = map_nick2sd((char *)message);
  6639. if(target_sd != NULL) {
  6640. unsigned int maxpl=0, newduel;
  6641. if((newduel = duel_create(sd, 2)) != -1) {
  6642. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  6643. clif_displaymessage(fd, msg_txt(353)); // "Duel: Player already in duel."
  6644. return 0;
  6645. }
  6646. duel_invite(newduel, sd, target_sd);
  6647. clif_displaymessage(fd, msg_txt(354)); // "Duel: Invitation has been sent."
  6648. }
  6649. } else {
  6650. // "Duel: Player not found."
  6651. clif_displaymessage(fd, msg_txt(352));
  6652. return 0;
  6653. }
  6654. }
  6655. } else
  6656. duel_create(sd, 0);
  6657. return 0;
  6658. }
  6659. ACMD_FUNC(leave)
  6660. {
  6661. if(sd->duel_group <= 0) {
  6662. // "Duel: @leave without @duel."
  6663. clif_displaymessage(fd, msg_txt(358));
  6664. return 0;
  6665. }
  6666. duel_leave(sd->duel_group, sd);
  6667. clif_displaymessage(fd, msg_txt(359)); // "Duel: You left the duel."
  6668. return 0;
  6669. }
  6670. ACMD_FUNC(accept)
  6671. {
  6672. if(!duel_checktime(sd)) {
  6673. char output[CHAT_SIZE_MAX];
  6674. // "Duel: You can take part in duel only one time per %d minutes."
  6675. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  6676. clif_displaymessage(fd, output);
  6677. return 0;
  6678. }
  6679. if(sd->duel_invite <= 0) {
  6680. // "Duel: @accept without invititation."
  6681. clif_displaymessage(fd, msg_txt(360));
  6682. return 0;
  6683. }
  6684. 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 )
  6685. {
  6686. // "Duel: Limit of players is reached."
  6687. clif_displaymessage(fd, msg_txt(351));
  6688. return 0;
  6689. }
  6690. duel_accept(sd->duel_invite, sd);
  6691. // "Duel: Invitation has been accepted."
  6692. clif_displaymessage(fd, msg_txt(361));
  6693. return 0;
  6694. }
  6695. ACMD_FUNC(reject)
  6696. {
  6697. if(sd->duel_invite <= 0) {
  6698. // "Duel: @reject without invititation."
  6699. clif_displaymessage(fd, msg_txt(362));
  6700. return 0;
  6701. }
  6702. duel_reject(sd->duel_invite, sd);
  6703. // "Duel: Invitation has been rejected."
  6704. clif_displaymessage(fd, msg_txt(363));
  6705. return 0;
  6706. }
  6707. /*===================================
  6708. * Cash Points
  6709. *-----------------------------------*/
  6710. ACMD_FUNC(cash)
  6711. {
  6712. char output[128];
  6713. int value;
  6714. int ret=0;
  6715. nullpo_retr(-1, sd);
  6716. if( !message || !*message || (value = atoi(message)) == 0 ) {
  6717. clif_displaymessage(fd, msg_txt(1322)); // Please enter an amount.
  6718. return -1;
  6719. }
  6720. if( !strcmpi(command+1,"cash") )
  6721. {
  6722. if( value > 0 ) {
  6723. if( (ret=pc_getcash(sd, value, 0)) >= 0){
  6724. // If this option is set, the message is already sent by pc function
  6725. if( !battle_config.cashshop_show_points ){
  6726. sprintf(output, msg_txt(505), ret, sd->cashPoints);
  6727. clif_disp_onlyself(sd, output, strlen(output));
  6728. }
  6729. }
  6730. else clif_displaymessage(fd, msg_txt(149)); // Unable to decrease the number/value.
  6731. } else {
  6732. if( (ret=pc_paycash(sd, -value, 0)) >= 0){
  6733. // If this option is set, the message is already sent by pc function
  6734. if( !battle_config.cashshop_show_points ){
  6735. sprintf(output, msg_txt(410), ret, sd->cashPoints);
  6736. clif_disp_onlyself(sd, output, strlen(output));
  6737. }
  6738. }
  6739. else clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
  6740. }
  6741. }
  6742. else
  6743. { // @points
  6744. if( value > 0 ) {
  6745. if( (ret=pc_getcash(sd, 0, value)) >= 0){
  6746. sprintf(output, msg_txt(506), ret, sd->kafraPoints);
  6747. clif_disp_onlyself(sd, output, strlen(output));
  6748. }
  6749. else clif_displaymessage(fd, msg_txt(149)); // Unable to decrease the number/value.
  6750. } else {
  6751. if( (ret=pc_paycash(sd, -value, -value)) >= 0){
  6752. sprintf(output, msg_txt(411), ret, sd->kafraPoints);
  6753. clif_disp_onlyself(sd, output, strlen(output));
  6754. }
  6755. else clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
  6756. }
  6757. }
  6758. return 0;
  6759. }
  6760. // @clone/@slaveclone/@evilclone <playername> [Valaris]
  6761. ACMD_FUNC(clone)
  6762. {
  6763. int x=0,y=0,flag=0,master=0,i=0;
  6764. struct map_session_data *pl_sd=NULL;
  6765. if (!message || !*message) {
  6766. clif_displaymessage(sd->fd,msg_txt(1323)); // You must enter a player name or ID.
  6767. return 0;
  6768. }
  6769. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL) {
  6770. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  6771. return 0;
  6772. }
  6773. if(pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  6774. clif_displaymessage(fd, msg_txt(126)); // Cannot clone a player of higher GM level than yourself.
  6775. return 0;
  6776. }
  6777. if (strcmpi(command+1, "clone") == 0)
  6778. flag = 1;
  6779. else if (strcmpi(command+1, "slaveclone") == 0) {
  6780. flag = 2;
  6781. if(pc_isdead(sd)){
  6782. clif_displaymessage(fd, msg_txt(129+flag*2));
  6783. return 0;
  6784. }
  6785. master = sd->bl.id;
  6786. if (battle_config.atc_slave_clone_limit
  6787. && mob_countslave(&sd->bl) >= battle_config.atc_slave_clone_limit) {
  6788. clif_displaymessage(fd, msg_txt(127)); // You've reached your slave clones limit.
  6789. return 0;
  6790. }
  6791. }
  6792. do {
  6793. x = sd->bl.x + (rnd() % 10 - 5);
  6794. y = sd->bl.y + (rnd() % 10 - 5);
  6795. } while (map_getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10);
  6796. if (i >= 10) {
  6797. x = sd->bl.x;
  6798. y = sd->bl.y;
  6799. }
  6800. if((x = mob_clone_spawn(pl_sd, sd->bl.m, x, y, "", master, 0, flag?1:0, 0)) > 0) {
  6801. clif_displaymessage(fd, msg_txt(128+flag*2)); // Evil Clone spawned. Clone spawned. Slave clone spawned.
  6802. return 0;
  6803. }
  6804. clif_displaymessage(fd, msg_txt(129+flag*2)); // Unable to spawn evil clone. Unable to spawn clone. Unable to spawn slave clone.
  6805. return 0;
  6806. }
  6807. /*=====================================
  6808. * Autorejecting Invites/Deals [LuzZza]
  6809. * Usage: @noask
  6810. *-------------------------------------*/
  6811. ACMD_FUNC(noask)
  6812. {
  6813. if(sd->state.noask) {
  6814. clif_displaymessage(fd, msg_txt(391)); // Autorejecting is deactivated.
  6815. sd->state.noask = 0;
  6816. } else {
  6817. clif_displaymessage(fd, msg_txt(390)); // Autorejecting is activated.
  6818. sd->state.noask = 1;
  6819. }
  6820. return 0;
  6821. }
  6822. /*=====================================
  6823. * Send a @request message to all GMs of lowest_gm_level.
  6824. * Usage: @request <petition>
  6825. *-------------------------------------*/
  6826. ACMD_FUNC(request)
  6827. {
  6828. if (!message || !*message) {
  6829. clif_displaymessage(sd->fd,msg_txt(277)); // Usage: @request <petition/message to online GMs>.
  6830. return -1;
  6831. }
  6832. sprintf(atcmd_output, msg_txt(278), message); // (@request): %s
  6833. intif_wis_message_to_gm(sd->status.name, PC_PERM_RECEIVE_REQUESTS, atcmd_output);
  6834. clif_disp_onlyself(sd, atcmd_output, strlen(atcmd_output));
  6835. clif_displaymessage(sd->fd,msg_txt(279)); // @request sent.
  6836. return 0;
  6837. }
  6838. /*==========================================
  6839. * Feel (SG save map) Reset [HiddenDragon]
  6840. *------------------------------------------*/
  6841. ACMD_FUNC(feelreset)
  6842. {
  6843. pc_resetfeel(sd);
  6844. clif_displaymessage(fd, msg_txt(1324)); // Reset 'Feeling' maps.
  6845. return 0;
  6846. }
  6847. /*==========================================
  6848. * AUCTION SYSTEM
  6849. *------------------------------------------*/
  6850. ACMD_FUNC(auction)
  6851. {
  6852. nullpo_ret(sd);
  6853. clif_Auction_openwindow(sd);
  6854. return 0;
  6855. }
  6856. /*==========================================
  6857. * Kill Steal Protection
  6858. *------------------------------------------*/
  6859. ACMD_FUNC(ksprotection)
  6860. {
  6861. nullpo_retr(-1,sd);
  6862. if( sd->state.noks ) {
  6863. sd->state.noks = 0;
  6864. clif_displaymessage(fd, msg_txt(1325)); // [ K.S Protection Inactive ]
  6865. }
  6866. else
  6867. {
  6868. if( !message || !*message || !strcmpi(message, "party") )
  6869. { // Default is Party
  6870. sd->state.noks = 2;
  6871. clif_displaymessage(fd, msg_txt(1326)); // [ K.S Protection Active - Option: Party ]
  6872. }
  6873. else if( !strcmpi(message, "self") )
  6874. {
  6875. sd->state.noks = 1;
  6876. clif_displaymessage(fd, msg_txt(1327)); // [ K.S Protection Active - Option: Self ]
  6877. }
  6878. else if( !strcmpi(message, "guild") )
  6879. {
  6880. sd->state.noks = 3;
  6881. clif_displaymessage(fd, msg_txt(1328)); // [ K.S Protection Active - Option: Guild ]
  6882. }
  6883. else
  6884. clif_displaymessage(fd, msg_txt(1329)); // Usage: @noks <self|party|guild>
  6885. }
  6886. return 0;
  6887. }
  6888. /*==========================================
  6889. * Map Kill Steal Protection Setting
  6890. *------------------------------------------*/
  6891. ACMD_FUNC(allowks)
  6892. {
  6893. nullpo_retr(-1,sd);
  6894. if( map[sd->bl.m].flag.allowks ) {
  6895. map[sd->bl.m].flag.allowks = 0;
  6896. clif_displaymessage(fd, msg_txt(1330)); // [ Map K.S Protection Active ]
  6897. } else {
  6898. map[sd->bl.m].flag.allowks = 1;
  6899. clif_displaymessage(fd, msg_txt(1331)); // [ Map K.S Protection Inactive ]
  6900. }
  6901. return 0;
  6902. }
  6903. ACMD_FUNC(resetstat)
  6904. {
  6905. nullpo_retr(-1, sd);
  6906. pc_resetstate(sd);
  6907. sprintf(atcmd_output, msg_txt(207), sd->status.name);
  6908. clif_displaymessage(fd, atcmd_output);
  6909. return 0;
  6910. }
  6911. ACMD_FUNC(resetskill)
  6912. {
  6913. nullpo_retr(-1,sd);
  6914. pc_resetskill(sd,1);
  6915. sprintf(atcmd_output, msg_txt(206), sd->status.name);
  6916. clif_displaymessage(fd, atcmd_output);
  6917. return 0;
  6918. }
  6919. /*==========================================
  6920. * #storagelist: Displays the items list of a player's storage.
  6921. * #cartlist: Displays contents of target's cart.
  6922. * #itemlist: Displays contents of target's inventory.
  6923. *------------------------------------------*/
  6924. ACMD_FUNC(itemlist)
  6925. {
  6926. int i, j, count, counter;
  6927. const char* location;
  6928. const struct item* items;
  6929. int size;
  6930. StringBuf buf;
  6931. nullpo_retr(-1, sd);
  6932. if( strcmp(command+1, "storagelist") == 0 )
  6933. {
  6934. location = "storage";
  6935. items = sd->status.storage.items;
  6936. size = MAX_STORAGE;
  6937. }
  6938. else
  6939. if( strcmp(command+1, "cartlist") == 0 )
  6940. {
  6941. location = "cart";
  6942. items = sd->status.cart;
  6943. size = MAX_CART;
  6944. }
  6945. else
  6946. if( strcmp(command+1, "itemlist") == 0 )
  6947. {
  6948. location = "inventory";
  6949. items = sd->status.inventory;
  6950. size = MAX_INVENTORY;
  6951. }
  6952. else
  6953. return 1;
  6954. StringBuf_Init(&buf);
  6955. count = 0; // total slots occupied
  6956. counter = 0; // total items found
  6957. for( i = 0; i < size; ++i )
  6958. {
  6959. const struct item* it = &items[i];
  6960. struct item_data* itd;
  6961. if( it->nameid == 0 || (itd = itemdb_exists(it->nameid)) == NULL )
  6962. continue;
  6963. counter += it->amount;
  6964. count++;
  6965. if( count == 1 )
  6966. {
  6967. StringBuf_Printf(&buf, msg_txt(1332), location, sd->status.name); // ------ %s items list of '%s' ------
  6968. clif_displaymessage(fd, StringBuf_Value(&buf));
  6969. StringBuf_Clear(&buf);
  6970. }
  6971. if( it->refine )
  6972. StringBuf_Printf(&buf, "%d %s %+d (%s, id: %d)", it->amount, itd->jname, it->refine, itd->name, it->nameid);
  6973. else
  6974. StringBuf_Printf(&buf, "%d %s (%s, id: %d)", it->amount, itd->jname, itd->name, it->nameid);
  6975. if( it->equip )
  6976. {
  6977. char equipstr[CHAT_SIZE_MAX];
  6978. strcpy(equipstr, msg_txt(1333)); // | equipped:
  6979. if( it->equip & EQP_GARMENT )
  6980. strcat(equipstr, msg_txt(1334)); // garment,
  6981. if( it->equip & EQP_ACC_L )
  6982. strcat(equipstr, msg_txt(1335)); // left accessory,
  6983. if( it->equip & EQP_ARMOR )
  6984. strcat(equipstr, msg_txt(1336)); // body/armor,
  6985. if( (it->equip & EQP_ARMS) == EQP_HAND_R )
  6986. strcat(equipstr, msg_txt(1337)); // right hand,
  6987. if( (it->equip & EQP_ARMS) == EQP_HAND_L )
  6988. strcat(equipstr, msg_txt(1338)); // left hand,
  6989. if( (it->equip & EQP_ARMS) == EQP_ARMS )
  6990. strcat(equipstr, msg_txt(1339)); // both hands,
  6991. if( it->equip & EQP_SHOES )
  6992. strcat(equipstr, msg_txt(1340)); // feet,
  6993. if( it->equip & EQP_ACC_R )
  6994. strcat(equipstr, msg_txt(1341)); // right accessory,
  6995. if( (it->equip & EQP_HELM) == EQP_HEAD_LOW )
  6996. strcat(equipstr, msg_txt(1342)); // lower head,
  6997. if( (it->equip & EQP_HELM) == EQP_HEAD_TOP )
  6998. strcat(equipstr, msg_txt(1343)); // top head,
  6999. if( (it->equip & EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_TOP) )
  7000. strcat(equipstr, msg_txt(1344)); // lower/top head,
  7001. if( (it->equip & EQP_HELM) == EQP_HEAD_MID )
  7002. strcat(equipstr, msg_txt(1345)); // mid head,
  7003. if( (it->equip & EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_MID) )
  7004. strcat(equipstr, msg_txt(1346)); // lower/mid head,
  7005. if( (it->equip & EQP_HELM) == EQP_HELM )
  7006. strcat(equipstr, msg_txt(1347)); // lower/mid/top head,
  7007. // remove final ', '
  7008. equipstr[strlen(equipstr) - 2] = '\0';
  7009. StringBuf_AppendStr(&buf, equipstr);
  7010. }
  7011. clif_displaymessage(fd, StringBuf_Value(&buf));
  7012. StringBuf_Clear(&buf);
  7013. if( it->card[0] == CARD0_PET )
  7014. {// pet egg
  7015. if (it->card[3])
  7016. StringBuf_Printf(&buf, msg_txt(1348), (unsigned int)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, named)
  7017. else
  7018. StringBuf_Printf(&buf, msg_txt(1349), (unsigned int)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, unnamed)
  7019. }
  7020. else
  7021. if(it->card[0] == CARD0_FORGE)
  7022. {// forged item
  7023. StringBuf_Printf(&buf, msg_txt(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)
  7024. }
  7025. else
  7026. if(it->card[0] == CARD0_CREATE)
  7027. {// created item
  7028. StringBuf_Printf(&buf, msg_txt(1351), (unsigned int)MakeDWord(it->card[2], it->card[3])); // -> (produced item, creator id: %u)
  7029. }
  7030. else
  7031. {// normal item
  7032. int counter2 = 0;
  7033. for( j = 0; j < itd->slot; ++j )
  7034. {
  7035. struct item_data* card;
  7036. if( it->card[j] == 0 || (card = itemdb_exists(it->card[j])) == NULL )
  7037. continue;
  7038. counter2++;
  7039. if( counter2 == 1 )
  7040. StringBuf_AppendStr(&buf, msg_txt(1352)); // -> (card(s):
  7041. if( counter2 != 1 )
  7042. StringBuf_AppendStr(&buf, ", ");
  7043. StringBuf_Printf(&buf, "#%d %s (id: %d)", counter2, card->jname, card->nameid);
  7044. }
  7045. if( counter2 > 0 )
  7046. StringBuf_AppendStr(&buf, ")");
  7047. }
  7048. if( StringBuf_Length(&buf) > 0 )
  7049. clif_displaymessage(fd, StringBuf_Value(&buf));
  7050. StringBuf_Clear(&buf);
  7051. }
  7052. if( count == 0 )
  7053. StringBuf_Printf(&buf, msg_txt(1353), location); // No item found in this player's %s.
  7054. else
  7055. StringBuf_Printf(&buf, msg_txt(1354), counter, count, location); // %d item(s) found in %d %s slots.
  7056. clif_displaymessage(fd, StringBuf_Value(&buf));
  7057. StringBuf_Destroy(&buf);
  7058. return 0;
  7059. }
  7060. ACMD_FUNC(stats)
  7061. {
  7062. char job_jobname[100];
  7063. char output[CHAT_SIZE_MAX];
  7064. int i;
  7065. struct {
  7066. const char* format;
  7067. int value;
  7068. } output_table[] = {
  7069. { "Base Level - %d", 0 },
  7070. { NULL, 0 },
  7071. { "Hp - %d", 0 },
  7072. { "MaxHp - %d", 0 },
  7073. { "Sp - %d", 0 },
  7074. { "MaxSp - %d", 0 },
  7075. { "Str - %3d", 0 },
  7076. { "Agi - %3d", 0 },
  7077. { "Vit - %3d", 0 },
  7078. { "Int - %3d", 0 },
  7079. { "Dex - %3d", 0 },
  7080. { "Luk - %3d", 0 },
  7081. { "Zeny - %d", 0 },
  7082. { "Free SK Points - %d", 0 },
  7083. { "JobChangeLvl (2nd) - %d", 0 },
  7084. { "JobChangeLvl (3rd) - %d", 0 },
  7085. { NULL, 0 }
  7086. };
  7087. memset(job_jobname, '\0', sizeof(job_jobname));
  7088. memset(output, '\0', sizeof(output));
  7089. //direct array initialization with variables is not standard C compliant.
  7090. output_table[0].value = sd->status.base_level;
  7091. output_table[1].format = job_jobname;
  7092. output_table[1].value = sd->status.job_level;
  7093. output_table[2].value = sd->status.hp;
  7094. output_table[3].value = sd->status.max_hp;
  7095. output_table[4].value = sd->status.sp;
  7096. output_table[5].value = sd->status.max_sp;
  7097. output_table[6].value = sd->status.str;
  7098. output_table[7].value = sd->status.agi;
  7099. output_table[8].value = sd->status.vit;
  7100. output_table[9].value = sd->status.int_;
  7101. output_table[10].value = sd->status.dex;
  7102. output_table[11].value = sd->status.luk;
  7103. output_table[12].value = sd->status.zeny;
  7104. output_table[13].value = sd->status.skill_point;
  7105. output_table[14].value = sd->change_level_2nd;
  7106. output_table[15].value = sd->change_level_3rd;
  7107. sprintf(job_jobname, "Job - %s %s", job_name(sd->status.class_), "(level %d)");
  7108. sprintf(output, msg_txt(53), sd->status.name); // '%s' stats:
  7109. clif_displaymessage(fd, output);
  7110. for (i = 0; output_table[i].format != NULL; i++) {
  7111. sprintf(output, output_table[i].format, output_table[i].value);
  7112. clif_displaymessage(fd, output);
  7113. }
  7114. return 0;
  7115. }
  7116. ACMD_FUNC(delitem)
  7117. {
  7118. char item_name[100];
  7119. int nameid, amount = 0, total, idx;
  7120. struct item_data* id;
  7121. nullpo_retr(-1, sd);
  7122. if( !message || !*message || ( sscanf(message, "\"%99[^\"]\" %d", item_name, &amount) < 2 && sscanf(message, "%99s %d", item_name, &amount) < 2 ) || amount < 1 )
  7123. {
  7124. clif_displaymessage(fd, msg_txt(1355)); // Please enter an item name/ID, a quantity, and a player name (usage: #delitem <player> <item_name_or_ID> <quantity>).
  7125. return -1;
  7126. }
  7127. if( ( id = itemdb_searchname(item_name) ) != NULL || ( id = itemdb_exists(atoi(item_name)) ) != NULL )
  7128. {
  7129. nameid = id->nameid;
  7130. }
  7131. else
  7132. {
  7133. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  7134. return -1;
  7135. }
  7136. total = amount;
  7137. // delete items
  7138. while( amount && ( idx = pc_search_inventory(sd, nameid) ) != -1 )
  7139. {
  7140. int delamount = ( amount < sd->status.inventory[idx].amount ) ? amount : sd->status.inventory[idx].amount;
  7141. if( sd->inventory_data[idx]->type == IT_PETEGG && sd->status.inventory[idx].card[0] == CARD0_PET )
  7142. {// delete pet
  7143. intif_delete_petdata(MakeDWord(sd->status.inventory[idx].card[1], sd->status.inventory[idx].card[2]));
  7144. }
  7145. pc_delitem(sd, idx, delamount, 0, 0, LOG_TYPE_COMMAND);
  7146. amount-= delamount;
  7147. }
  7148. // notify target
  7149. sprintf(atcmd_output, msg_txt(113), total-amount); // %d item(s) removed by a GM.
  7150. clif_displaymessage(sd->fd, atcmd_output);
  7151. // notify source
  7152. if( amount == total )
  7153. {
  7154. clif_displaymessage(fd, msg_txt(116)); // Character does not have the item.
  7155. }
  7156. else if( amount )
  7157. {
  7158. sprintf(atcmd_output, msg_txt(115), total-amount, total-amount, total); // %d item(s) removed. Player had only %d on %d items.
  7159. clif_displaymessage(fd, atcmd_output);
  7160. }
  7161. else
  7162. {
  7163. sprintf(atcmd_output, msg_txt(114), total); // %d item(s) removed from the player.
  7164. clif_displaymessage(fd, atcmd_output);
  7165. }
  7166. return 0;
  7167. }
  7168. /*==========================================
  7169. * Custom Fonts
  7170. *------------------------------------------*/
  7171. ACMD_FUNC(font)
  7172. {
  7173. int font_id;
  7174. nullpo_retr(-1,sd);
  7175. font_id = atoi(message);
  7176. if( font_id == 0 )
  7177. {
  7178. if( sd->user_font )
  7179. {
  7180. sd->user_font = 0;
  7181. clif_displaymessage(fd, msg_txt(1356)); // Returning to normal font.
  7182. clif_font(sd);
  7183. }
  7184. else
  7185. {
  7186. clif_displaymessage(fd, msg_txt(1357)); // Use @font <1-9> to change your message font.
  7187. clif_displaymessage(fd, msg_txt(1358)); // Use 0 or no parameter to return to normal font.
  7188. }
  7189. }
  7190. else if( font_id < 0 || font_id > 9 )
  7191. clif_displaymessage(fd, msg_txt(1359)); // Invalid font. Use a value from 0 to 9.
  7192. else if( font_id != sd->user_font )
  7193. {
  7194. sd->user_font = font_id;
  7195. clif_font(sd);
  7196. clif_displaymessage(fd, msg_txt(1360)); // Font changed.
  7197. }
  7198. else
  7199. clif_displaymessage(fd, msg_txt(1361)); // Already using this font.
  7200. return 0;
  7201. }
  7202. /*==========================================
  7203. * type: 1 = commands (@), 2 = charcommands (#)
  7204. *------------------------------------------*/
  7205. static void atcommand_commands_sub(struct map_session_data* sd, const int fd, AtCommandType type)
  7206. {
  7207. char line_buff[CHATBOX_SIZE];
  7208. char* cur = line_buff;
  7209. AtCommandInfo* cmd;
  7210. DBIterator *iter = db_iterator(atcommand_db);
  7211. int count = 0;
  7212. memset(line_buff,' ',CHATBOX_SIZE);
  7213. line_buff[CHATBOX_SIZE-1] = 0;
  7214. clif_displaymessage(fd, msg_txt(273)); // "Commands available:"
  7215. for (cmd = dbi_first(iter); dbi_exists(iter); cmd = dbi_next(iter)) {
  7216. unsigned int slen = 0;
  7217. switch( type ) {
  7218. case COMMAND_CHARCOMMAND:
  7219. if( cmd->char_groups[sd->group_pos] == 0 )
  7220. continue;
  7221. break;
  7222. case COMMAND_ATCOMMAND:
  7223. if( cmd->at_groups[sd->group_pos] == 0 )
  7224. continue;
  7225. break;
  7226. default:
  7227. continue;
  7228. }
  7229. slen = strlen(cmd->command);
  7230. // flush the text buffer if this command won't fit into it
  7231. if ( slen + cur - line_buff >= CHATBOX_SIZE )
  7232. {
  7233. clif_displaymessage(fd,line_buff);
  7234. cur = line_buff;
  7235. memset(line_buff,' ',CHATBOX_SIZE);
  7236. line_buff[CHATBOX_SIZE-1] = 0;
  7237. }
  7238. memcpy(cur,cmd->command,slen);
  7239. cur += slen+(10-slen%10);
  7240. count++;
  7241. }
  7242. dbi_destroy(iter);
  7243. clif_displaymessage(fd,line_buff);
  7244. sprintf(atcmd_output, msg_txt(274), count); // "%d commands found."
  7245. clif_displaymessage(fd, atcmd_output);
  7246. return;
  7247. }
  7248. /*==========================================
  7249. * @commands Lists available @ commands to you
  7250. *------------------------------------------*/
  7251. ACMD_FUNC(commands)
  7252. {
  7253. atcommand_commands_sub(sd, fd, COMMAND_ATCOMMAND);
  7254. return 0;
  7255. }
  7256. /*==========================================
  7257. * @charcommands Lists available # commands to you
  7258. *------------------------------------------*/
  7259. ACMD_FUNC(charcommands)
  7260. {
  7261. atcommand_commands_sub(sd, fd, COMMAND_CHARCOMMAND);
  7262. return 0;
  7263. }
  7264. /* for new mounts */
  7265. ACMD_FUNC(mount2) {
  7266. clif_displaymessage(sd->fd,msg_txt(1362)); // NOTICE: If you crash with mount your LUA is outdated.
  7267. if( !(sd->sc.option&OPTION_MOUNTING) ) {
  7268. clif_displaymessage(sd->fd,msg_txt(1363)); // You have mounted.
  7269. pc_setoption(sd, sd->sc.option|OPTION_MOUNTING);
  7270. } else {
  7271. clif_displaymessage(sd->fd,msg_txt(1364)); // You have released your mount.
  7272. pc_setoption(sd, sd->sc.option&~OPTION_MOUNTING);
  7273. }
  7274. return 0;
  7275. }
  7276. ACMD_FUNC(accinfo) {
  7277. char query[NAME_LENGTH];
  7278. if (!message || !*message || strlen(message) > NAME_LENGTH ) {
  7279. clif_displaymessage(fd, msg_txt(1365)); // Usage: @accinfo/@accountinfo <account_id/char name>
  7280. clif_displaymessage(fd, msg_txt(1366)); // You may search partial name by making use of '%' in the search, ex. "@accinfo %Mario%" lists all characters whose name contains "Mario".
  7281. return -1;
  7282. }
  7283. //remove const type
  7284. safestrncpy(query, message, NAME_LENGTH);
  7285. intif_request_accinfo( sd->fd, sd->bl.id, pc_get_group_level(sd), query );
  7286. return 0;
  7287. }
  7288. /* [Ind] */
  7289. ACMD_FUNC(set) {
  7290. char reg[32], val[128];
  7291. struct script_data* data;
  7292. int toset = 0, len;
  7293. bool is_str = false;
  7294. if( !message || !*message || (toset = sscanf(message, "%31s %128[^\n]s", reg, val)) < 1 ) {
  7295. clif_displaymessage(fd, msg_txt(1367)); // Usage: @set <variable name> <value>
  7296. clif_displaymessage(fd, msg_txt(1368)); // Usage: ex. "@set PoringCharVar 50"
  7297. clif_displaymessage(fd, msg_txt(1369)); // Usage: ex. "@set PoringCharVarSTR$ Super Duper String"
  7298. clif_displaymessage(fd, msg_txt(1370)); // Usage: ex. "@set PoringCharVarSTR$" outputs its value, Super Duper String.
  7299. return -1;
  7300. }
  7301. /* disabled variable types (they require a proper script state to function, so allowing them would crash the server) */
  7302. if( reg[0] == '.' ) {
  7303. clif_displaymessage(fd, msg_txt(1371)); // NPC variables may not be used with @set.
  7304. return -1;
  7305. } else if( reg[0] == '\'' ) {
  7306. clif_displaymessage(fd, msg_txt(1372)); // Instance variables may not be used with @set.
  7307. return -1;
  7308. }
  7309. is_str = ( reg[strlen(reg) - 1] == '$' ) ? true : false;
  7310. if( ( len = strlen(val) ) > 1 ) {
  7311. if( val[0] == '"' && val[len-1] == '"') {
  7312. val[len-1] = '\0'; //Strip quotes.
  7313. memmove(val, val+1, len-1);
  7314. }
  7315. }
  7316. if( toset >= 2 ) {/* we only set the var if there is an val, otherwise we only output the value */
  7317. if( is_str )
  7318. set_var(sd, reg, (void*) val);
  7319. else
  7320. set_var(sd, reg, (void*)__64BPRTSIZE((atoi(val))));
  7321. }
  7322. CREATE(data, struct script_data,1);
  7323. if( is_str ) {// string variable
  7324. switch( reg[0] ) {
  7325. case '@':
  7326. data->u.str = pc_readregstr(sd, add_str(reg));
  7327. break;
  7328. case '$':
  7329. data->u.str = mapreg_readregstr(add_str(reg));
  7330. break;
  7331. case '#':
  7332. if( reg[1] == '#' )
  7333. data->u.str = pc_readaccountreg2str(sd, reg);// global
  7334. else
  7335. data->u.str = pc_readaccountregstr(sd, reg);// local
  7336. break;
  7337. default:
  7338. data->u.str = pc_readglobalreg_str(sd, reg);
  7339. break;
  7340. }
  7341. if( data->u.str == NULL || data->u.str[0] == '\0' ) {// empty string
  7342. data->type = C_CONSTSTR;
  7343. data->u.str = "";
  7344. } else {// duplicate string
  7345. data->type = C_STR;
  7346. data->u.str = aStrdup(data->u.str);
  7347. }
  7348. } else {// integer variable
  7349. data->type = C_INT;
  7350. switch( reg[0] ) {
  7351. case '@':
  7352. data->u.num = pc_readreg(sd, add_str(reg));
  7353. break;
  7354. case '$':
  7355. data->u.num = mapreg_readreg(add_str(reg));
  7356. break;
  7357. case '#':
  7358. if( reg[1] == '#' )
  7359. data->u.num = pc_readaccountreg2(sd, reg);// global
  7360. else
  7361. data->u.num = pc_readaccountreg(sd, reg);// local
  7362. break;
  7363. default:
  7364. data->u.num = pc_readglobalreg(sd, reg);
  7365. break;
  7366. }
  7367. }
  7368. switch( data->type ) {
  7369. case C_INT:
  7370. sprintf(atcmd_output,msg_txt(1373),reg,data->u.num); // %s value is now :%d
  7371. break;
  7372. case C_STR:
  7373. sprintf(atcmd_output,msg_txt(1374),reg,data->u.str); // %s value is now :%s
  7374. break;
  7375. case C_CONSTSTR:
  7376. sprintf(atcmd_output,msg_txt(1375),reg); // %s is empty
  7377. break;
  7378. default:
  7379. sprintf(atcmd_output,msg_txt(1376),reg,data->type); // %s data type is not supported :%u
  7380. break;
  7381. }
  7382. clif_displaymessage(fd, atcmd_output);
  7383. aFree(data);
  7384. return 0;
  7385. }
  7386. ACMD_FUNC(reloadquestdb) {
  7387. do_reload_quest();
  7388. clif_displaymessage(fd, msg_txt(1377)); // Quest database has been reloaded.
  7389. return 0;
  7390. }
  7391. ACMD_FUNC(addperm) {
  7392. int perm_size = ARRAYLENGTH(pc_g_permission_name);
  7393. bool add = (strcmpi(command+1, "addperm") == 0) ? true : false;
  7394. int i;
  7395. if( !message || !*message ) {
  7396. sprintf(atcmd_output, msg_txt(1378),command); // Usage: %s <permission_name>
  7397. clif_displaymessage(fd, atcmd_output);
  7398. clif_displaymessage(fd, msg_txt(1379)); // -- Permission List
  7399. for( i = 0; i < perm_size; i++ ) {
  7400. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  7401. clif_displaymessage(fd, atcmd_output);
  7402. }
  7403. return -1;
  7404. }
  7405. ARR_FIND(0, perm_size, i, strcmpi(pc_g_permission_name[i].name, message) == 0);
  7406. if( i == perm_size ) {
  7407. sprintf(atcmd_output,msg_txt(1380),message); // '%s' is not a known permission.
  7408. clif_displaymessage(fd, atcmd_output);
  7409. clif_displaymessage(fd, msg_txt(1379)); // -- Permission List
  7410. for( i = 0; i < perm_size; i++ ) {
  7411. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  7412. clif_displaymessage(fd, atcmd_output);
  7413. }
  7414. return -1;
  7415. }
  7416. if( add && (sd->permissions&pc_g_permission_name[i].permission) ) {
  7417. sprintf(atcmd_output, msg_txt(1381),sd->status.name,pc_g_permission_name[i].name); // User '%s' already possesses the '%s' permission.
  7418. clif_displaymessage(fd, atcmd_output);
  7419. return -1;
  7420. } else if ( !add && !(sd->permissions&pc_g_permission_name[i].permission) ) {
  7421. sprintf(atcmd_output, msg_txt(1382),sd->status.name,pc_g_permission_name[i].name); // User '%s' doesn't possess the '%s' permission.
  7422. clif_displaymessage(fd, atcmd_output);
  7423. sprintf(atcmd_output,msg_txt(1383),sd->status.name); // -- User '%s' Permissions
  7424. clif_displaymessage(fd, atcmd_output);
  7425. for( i = 0; i < perm_size; i++ ) {
  7426. if( sd->permissions&pc_g_permission_name[i].permission ) {
  7427. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  7428. clif_displaymessage(fd, atcmd_output);
  7429. }
  7430. }
  7431. return -1;
  7432. }
  7433. if( add )
  7434. sd->permissions |= pc_g_permission_name[i].permission;
  7435. else
  7436. sd->permissions &=~ pc_g_permission_name[i].permission;
  7437. sprintf(atcmd_output, msg_txt(1384),sd->status.name); // User '%s' permissions updated successfully. The changes are temporary.
  7438. clif_displaymessage(fd, atcmd_output);
  7439. return 0;
  7440. }
  7441. ACMD_FUNC(unloadnpcfile) {
  7442. if( !message || !*message ) {
  7443. clif_displaymessage(fd, msg_txt(1385)); // Usage: @unloadnpcfile <file name>
  7444. return -1;
  7445. }
  7446. if( npc_unloadfile(message) )
  7447. clif_displaymessage(fd, msg_txt(1386)); // File unloaded. Be aware that mapflags and monsters spawned directly are not removed.
  7448. else {
  7449. clif_displaymessage(fd, msg_txt(1387)); // File not found.
  7450. return -1;
  7451. }
  7452. return 0;
  7453. }
  7454. ACMD_FUNC(cart) {
  7455. #define MC_CART_MDFY(x) \
  7456. sd->status.skill[MC_PUSHCART].id = x?MC_PUSHCART:0; \
  7457. sd->status.skill[MC_PUSHCART].lv = x?1:0; \
  7458. sd->status.skill[MC_PUSHCART].flag = x?SKILL_FLAG_TEMPORARY:SKILL_FLAG_PERMANENT;
  7459. int val = atoi(message);
  7460. bool need_skill = pc_checkskill(sd, MC_PUSHCART) ? false : true;
  7461. if( !message || !*message || val < 0 || val > MAX_CARTS ) {
  7462. sprintf(atcmd_output, msg_txt(1390),command,MAX_CARTS); // Unknown Cart (usage: %s <0-%d>).
  7463. clif_displaymessage(fd, atcmd_output);
  7464. return -1;
  7465. }
  7466. if( val == 0 && !pc_iscarton(sd) ) {
  7467. clif_displaymessage(fd, msg_txt(1391)); // You do not possess a cart to be removed
  7468. return -1;
  7469. }
  7470. if( need_skill ) {
  7471. MC_CART_MDFY(1);
  7472. }
  7473. if( pc_setcart(sd, val) ) {
  7474. if( need_skill ) {
  7475. MC_CART_MDFY(0);
  7476. }
  7477. return -1;/* @cart failed */
  7478. }
  7479. if( need_skill ) {
  7480. MC_CART_MDFY(0);
  7481. }
  7482. clif_displaymessage(fd, msg_txt(1392)); // Cart Added
  7483. return 0;
  7484. #undef MC_CART_MDFY
  7485. }
  7486. /* Channel System [Ind] */
  7487. ACMD_FUNC(join) {
  7488. struct raChSysCh *channel;
  7489. char name[RACHSYS_NAME_LENGTH], pass[RACHSYS_NAME_LENGTH];
  7490. DBMap* channel_db = clif_get_channel_db();
  7491. if( !message || !*message || sscanf(message, "%s %s", name, pass) < 1 ) {
  7492. sprintf(atcmd_output, msg_txt(1399),command); // Unknown Channel (usage: %s <#channel_name>)
  7493. clif_displaymessage(fd, atcmd_output);
  7494. return -1;
  7495. }
  7496. if( raChSys.local && strcmpi(name + 1, raChSys.local_name) == 0 ) {
  7497. if( !map[sd->bl.m].channel ) {
  7498. clif_chsys_mjoin(sd);
  7499. return 0;
  7500. } else
  7501. channel = map[sd->bl.m].channel;
  7502. } else if( raChSys.ally && sd->status.guild_id && strcmpi(name + 1, raChSys.ally_name) == 0 ) {
  7503. struct guild *g = sd->guild;
  7504. if( !g ) return -1;/* unlikely, but we wont let it crash anyway. */
  7505. channel = (struct raChSysCh *)g->channel;
  7506. } else if( !( channel = strdb_get(channel_db, name + 1) ) ) {
  7507. sprintf(atcmd_output, msg_txt(1400),name,command); // Unknown Channel '%s' (usage: %s <#channel_name>)
  7508. clif_displaymessage(fd, atcmd_output);
  7509. return -1;
  7510. }
  7511. if( idb_exists(channel->users, sd->status.char_id) ) {
  7512. sprintf(atcmd_output, msg_txt(1434),name); // You're already in the '%s' channel.
  7513. clif_displaymessage(fd, atcmd_output);
  7514. return -1;
  7515. }
  7516. if( channel->pass[0] != '\0' && strcmp(channel->pass,pass) != 0 ) {
  7517. if( pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) ) {
  7518. sd->stealth = true;
  7519. } else {
  7520. sprintf(atcmd_output, msg_txt(1401),name,command); // '%s' Channel is password protected (usage: %s <#channel_name> <password>)
  7521. clif_displaymessage(fd, atcmd_output);
  7522. return -1;
  7523. }
  7524. }
  7525. if( !( channel->opt & raChSys_OPT_ANNOUNCE_JOIN ) ) {
  7526. sprintf(atcmd_output, msg_txt(1403),name); // You're now in the '%s' channel.
  7527. clif_displaymessage(fd, atcmd_output);
  7528. }
  7529. clif_chsys_join(channel,sd);
  7530. return 0;
  7531. }
  7532. inline void atcmd_channel_help(int fd, const char *command, bool can_create) {
  7533. sprintf(atcmd_output, msg_txt(1404),command); // %s failed.
  7534. clif_displaymessage(fd, atcmd_output);
  7535. clif_displaymessage(fd, msg_txt(1414));// ---- Available options:
  7536. if( can_create ) {
  7537. sprintf(atcmd_output, msg_txt(1415),command);// * %s create <#channel_name> <channel_password>
  7538. clif_displaymessage(fd, atcmd_output);
  7539. clif_displaymessage(fd, msg_txt(1416));// -- Creates a new channel.
  7540. }
  7541. sprintf(atcmd_output, msg_txt(1417),command);// * %s list
  7542. clif_displaymessage(fd, atcmd_output);
  7543. clif_displaymessage(fd, msg_txt(1418));// -- Lists all public channels.
  7544. if( can_create ) {
  7545. sprintf(atcmd_output, msg_txt(1419),command);// * %s list colors
  7546. clif_displaymessage(fd, atcmd_output);
  7547. clif_displaymessage(fd, msg_txt(1420));// -- Lists all available colors for custom channels.
  7548. sprintf(atcmd_output, msg_txt(1421),command);// * %s setcolor <#channel_name> <color_name>
  7549. clif_displaymessage(fd, atcmd_output);
  7550. clif_displaymessage(fd, msg_txt(1422));// -- Changes channel text to the specified color (channel owners only).
  7551. }
  7552. sprintf(atcmd_output, msg_txt(1423),command);// * %s leave <#channel_name>
  7553. clif_displaymessage(fd, atcmd_output);
  7554. clif_displaymessage(fd, msg_txt(1424));// -- Leaves the specified channel.
  7555. sprintf(atcmd_output, msg_txt(1427),command);// * %s bindto <#channel_name>
  7556. clif_displaymessage(fd, atcmd_output);
  7557. clif_displaymessage(fd, msg_txt(1428));// -- Binds your global chat to the specified channel, sending all global messages to that channel.
  7558. sprintf(atcmd_output, msg_txt(1429),command);// * %s unbind
  7559. clif_displaymessage(fd, atcmd_output);
  7560. clif_displaymessage(fd, msg_txt(1430));// -- Unbinds your global chat from the attached channel, if any.
  7561. }
  7562. ACMD_FUNC(channel) {
  7563. struct raChSysCh *channel;
  7564. char key[RACHSYS_NAME_LENGTH], sub1[RACHSYS_NAME_LENGTH], sub2[RACHSYS_NAME_LENGTH], sub3[RACHSYS_NAME_LENGTH];
  7565. unsigned char k = 0;
  7566. DBMap* channel_db = clif_get_channel_db();
  7567. sub1[0] = sub2[0] = sub3[0] = '\0';
  7568. if( !message || !*message || sscanf(message, "%s %s %s %s", key, sub1, sub2, sub3) < 1 ) {
  7569. atcmd_channel_help(fd,command,( raChSys.allow_user_channel_creation || pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) ));
  7570. return 0;
  7571. }
  7572. if( strcmpi(key,"create") == 0 && ( raChSys.allow_user_channel_creation || pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) ) ) {
  7573. if( sub1[0] != '#' ) {
  7574. clif_displaymessage(fd, msg_txt(1405));// Channel name must start with '#'.
  7575. return -1;
  7576. } else if ( strlen(sub1) < 3 || strlen(sub1) > RACHSYS_NAME_LENGTH ) {
  7577. sprintf(atcmd_output, msg_txt(1406), RACHSYS_NAME_LENGTH);// Channel length must be between 3 and %d.
  7578. clif_displaymessage(fd, atcmd_output);
  7579. return -1;
  7580. } else if ( sub3[0] != '\0' ) {
  7581. clif_displaymessage(fd, msg_txt(1408)); // Channel password may not contain spaces.
  7582. return -1;
  7583. }
  7584. if( strcmpi(sub1 + 1,raChSys.local_name) == 0 || strcmpi(sub1 + 1,raChSys.ally_name) == 0 || strdb_exists(channel_db, sub1 + 1) ) {
  7585. sprintf(atcmd_output, msg_txt(1407), sub1);// Channel '%s' is not available.
  7586. clif_displaymessage(fd, atcmd_output);
  7587. return -1;
  7588. }
  7589. CREATE( channel, struct raChSysCh, 1 );
  7590. clif_chsys_create(channel,sub1 + 1,sub2,0);
  7591. channel->owner = sd->status.char_id;
  7592. channel->type = raChSys_PRIVATE;
  7593. if( !( channel->opt & raChSys_OPT_ANNOUNCE_JOIN ) ) {
  7594. sprintf(atcmd_output, msg_txt(1403),sub1); // You're now in the '%s' channel.
  7595. clif_displaymessage(fd, atcmd_output);
  7596. }
  7597. clif_chsys_join(channel,sd);
  7598. } else if ( strcmpi(key,"list") == 0 ) {
  7599. if( sub1[0] != '\0' && strcmpi(sub1,"colors") == 0 ) {
  7600. char mout[40];
  7601. for( k = 0; k < raChSys.colors_count; k++ ) {
  7602. unsigned short msg_len = 1;
  7603. msg_len += sprintf(mout, "[ %s list colors ] : %s",command,raChSys.colors_name[k]);
  7604. WFIFOHEAD(fd,msg_len + 12);
  7605. WFIFOW(fd,0) = 0x2C1;
  7606. WFIFOW(fd,2) = msg_len + 12;
  7607. WFIFOL(fd,4) = 0;
  7608. WFIFOL(fd,8) = raChSys.colors[k];
  7609. safestrncpy((char*)WFIFOP(fd,12), mout, msg_len);
  7610. WFIFOSET(fd, msg_len + 12);
  7611. }
  7612. } else {
  7613. DBIterator *iter = db_iterator(channel_db);
  7614. bool show_all = pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) ? true : false;
  7615. clif_displaymessage(fd, msg_txt(1410)); // ---- Public Channels ----
  7616. if( raChSys.local ) {
  7617. sprintf(atcmd_output, msg_txt(1409), raChSys.local_name, map[sd->bl.m].channel ? db_size(map[sd->bl.m].channel->users) : 0);// - #%s ( %d users )
  7618. clif_displaymessage(fd, atcmd_output);
  7619. }
  7620. if( raChSys.ally && sd->status.guild_id ) {
  7621. struct guild *g = sd->guild;
  7622. if( !g ) return -1;
  7623. sprintf(atcmd_output, msg_txt(1409), raChSys.ally_name, db_size(((struct raChSysCh *)g->channel)->users));// - #%s ( %d users )
  7624. clif_displaymessage(fd, atcmd_output);
  7625. }
  7626. for(channel = dbi_first(iter); dbi_exists(iter); channel = dbi_next(iter)) {
  7627. if( show_all || channel->type == raChSys_PUBLIC ) {
  7628. sprintf(atcmd_output, msg_txt(1409), channel->name, db_size(channel->users));// - #%s (%d users)
  7629. clif_displaymessage(fd, atcmd_output);
  7630. }
  7631. }
  7632. dbi_destroy(iter);
  7633. }
  7634. } else if ( strcmpi(key,"setcolor") == 0 ) {
  7635. if( sub1[0] != '#' ) {
  7636. clif_displaymessage(fd, msg_txt(1405));// Channel name must start with '#'.
  7637. return -1;
  7638. }
  7639. if( !(channel = strdb_get(channel_db, sub1 + 1)) ) {
  7640. sprintf(atcmd_output, msg_txt(1407), sub1);// Channel '%s' is not available.
  7641. clif_displaymessage(fd, atcmd_output);
  7642. return -1;
  7643. }
  7644. if( channel->owner != sd->status.char_id && !pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) ) {
  7645. sprintf(atcmd_output, msg_txt(1412), sub1);// You're not the owner of channel '%s'.
  7646. clif_displaymessage(fd, atcmd_output);
  7647. return -1;
  7648. }
  7649. for( k = 0; k < raChSys.colors_count; k++ ) {
  7650. if( strcmpi(sub2,raChSys.colors_name[k]) == 0 )
  7651. break;
  7652. }
  7653. if( k == raChSys.colors_count ) {
  7654. sprintf(atcmd_output, msg_txt(1411), sub2);// Unknown color '%s'.
  7655. clif_displaymessage(fd, atcmd_output);
  7656. return -1;
  7657. }
  7658. channel->color = k;
  7659. sprintf(atcmd_output, msg_txt(1413),sub1,raChSys.colors_name[k]);// '%s' channel color updated to '%s'.
  7660. clif_displaymessage(fd, atcmd_output);
  7661. } else if ( strcmpi(key,"leave") == 0 ) {
  7662. if( sub1[0] != '#' ) {
  7663. clif_displaymessage(fd, msg_txt(1405));// Channel name must start with '#'.
  7664. return -1;
  7665. }
  7666. ARR_FIND(0, sd->channel_count, k, strcmpi(sub1+1,sd->channels[k]->name) == 0);
  7667. if( k == sd->channel_count ) {
  7668. sprintf(atcmd_output, msg_txt(1425),sub1);// You're not part of the '%s' channel.
  7669. clif_displaymessage(fd, atcmd_output);
  7670. return -1;
  7671. }
  7672. clif_chsys_left(sd->channels[k],sd);
  7673. sprintf(atcmd_output, msg_txt(1426),sub1); // You've left the '%s' channel.
  7674. clif_displaymessage(fd, atcmd_output);
  7675. } else if ( strcmpi(key,"bindto") == 0 ) {
  7676. if( sub1[0] != '#' ) {
  7677. clif_displaymessage(fd, msg_txt(1405));// Channel name must start with '#'.
  7678. return -1;
  7679. }
  7680. ARR_FIND(0, sd->channel_count, k, strcmpi(sub1+1,sd->channels[k]->name) == 0);
  7681. if( k == sd->channel_count ) {
  7682. sprintf(atcmd_output, msg_txt(1425),sub1);// You're not part of the '%s' channel.
  7683. clif_displaymessage(fd, atcmd_output);
  7684. return -1;
  7685. }
  7686. sd->gcbind = sd->channels[k];
  7687. sprintf(atcmd_output, msg_txt(1431),sub1); // Your global chat is now binded to the '%s' channel.
  7688. clif_displaymessage(fd, atcmd_output);
  7689. } else if ( strcmpi(key,"unbind") == 0 ) {
  7690. if( sd->gcbind == NULL ) {
  7691. clif_displaymessage(fd, msg_txt(1432));// Your global chat is not binded to any channel.
  7692. return -1;
  7693. }
  7694. sprintf(atcmd_output, msg_txt(1433),sd->gcbind->name); // Your global chat is now unbinded from the '#%s' channel.
  7695. clif_displaymessage(fd, atcmd_output);
  7696. sd->gcbind = NULL;
  7697. } else {
  7698. atcmd_channel_help(fd,command,( raChSys.allow_user_channel_creation || pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) ));
  7699. }
  7700. return 0;
  7701. }
  7702. ACMD_FUNC(fontcolor) {
  7703. unsigned char k;
  7704. if( !message || !*message ) {
  7705. char mout[40];
  7706. for( k = 0; k < raChSys.colors_count; k++ ) {
  7707. unsigned short msg_len = 1;
  7708. msg_len += sprintf(mout, "[ %s ] : %s",command,raChSys.colors_name[k]);
  7709. WFIFOHEAD(fd,msg_len + 12);
  7710. WFIFOW(fd,0) = 0x2C1;
  7711. WFIFOW(fd,2) = msg_len + 12;
  7712. WFIFOL(fd,4) = 0;
  7713. WFIFOL(fd,8) = raChSys.colors[k];
  7714. safestrncpy((char*)WFIFOP(fd,12), mout, msg_len);
  7715. WFIFOSET(fd, msg_len + 12);
  7716. }
  7717. return -1;
  7718. }
  7719. if( message[0] == '0' ) {
  7720. sd->fontcolor = 0;
  7721. pc_disguise(sd,0);
  7722. return 0;
  7723. }
  7724. for( k = 0; k < raChSys.colors_count; k++ ) {
  7725. if( strcmpi(message,raChSys.colors_name[k]) == 0 )
  7726. break;
  7727. }
  7728. if( k == raChSys.colors_count ) {
  7729. sprintf(atcmd_output, msg_txt(1411), message);// Unknown color '%s'.
  7730. clif_displaymessage(fd, atcmd_output);
  7731. return -1;
  7732. }
  7733. sd->fontcolor = k + 1;
  7734. pc_disguise(sd,sd->status.class_);
  7735. return 0;
  7736. }
  7737. /**
  7738. * Fills the reference of available commands in atcommand DBMap
  7739. **/
  7740. #define ACMD_DEF(x) { #x, atcommand_ ## x, NULL, NULL }
  7741. #define ACMD_DEF2(x2, x) { x2, atcommand_ ## x, NULL, NULL }
  7742. void atcommand_basecommands(void) {
  7743. /**
  7744. * Command reference list, place the base of your commands here
  7745. **/
  7746. AtCommandInfo atcommand_base[] = {
  7747. ACMD_DEF2("warp", mapmove),
  7748. ACMD_DEF(where),
  7749. ACMD_DEF(jumpto),
  7750. ACMD_DEF(jump),
  7751. ACMD_DEF(who),
  7752. ACMD_DEF2("who2", who),
  7753. ACMD_DEF2("who3", who),
  7754. ACMD_DEF2("whomap", who),
  7755. ACMD_DEF2("whomap2", who),
  7756. ACMD_DEF2("whomap3", who),
  7757. ACMD_DEF(whogm),
  7758. ACMD_DEF(save),
  7759. ACMD_DEF(load),
  7760. ACMD_DEF(speed),
  7761. ACMD_DEF(storage),
  7762. ACMD_DEF(guildstorage),
  7763. ACMD_DEF(option),
  7764. ACMD_DEF(hide), // + /hide
  7765. ACMD_DEF(jobchange),
  7766. ACMD_DEF(kill),
  7767. ACMD_DEF(alive),
  7768. ACMD_DEF(kami),
  7769. ACMD_DEF2("kamib", kami),
  7770. ACMD_DEF2("kamic", kami),
  7771. ACMD_DEF2("lkami", kami),
  7772. ACMD_DEF(heal),
  7773. ACMD_DEF(item),
  7774. ACMD_DEF(item2),
  7775. ACMD_DEF(itemreset),
  7776. ACMD_DEF(clearstorage),
  7777. ACMD_DEF(cleargstorage),
  7778. ACMD_DEF(clearcart),
  7779. ACMD_DEF2("blvl", baselevelup),
  7780. ACMD_DEF2("jlvl", joblevelup),
  7781. ACMD_DEF(help),
  7782. ACMD_DEF(pvpoff),
  7783. ACMD_DEF(pvpon),
  7784. ACMD_DEF(gvgoff),
  7785. ACMD_DEF(gvgon),
  7786. ACMD_DEF(model),
  7787. ACMD_DEF(go),
  7788. ACMD_DEF(monster),
  7789. ACMD_DEF2("monstersmall", monster),
  7790. ACMD_DEF2("monsterbig", monster),
  7791. ACMD_DEF(killmonster),
  7792. ACMD_DEF2("killmonster2", killmonster),
  7793. ACMD_DEF(refine),
  7794. ACMD_DEF(produce),
  7795. ACMD_DEF(memo),
  7796. ACMD_DEF(gat),
  7797. ACMD_DEF(displaystatus),
  7798. ACMD_DEF2("stpoint", statuspoint),
  7799. ACMD_DEF2("skpoint", skillpoint),
  7800. ACMD_DEF(zeny),
  7801. ACMD_DEF2("str", param),
  7802. ACMD_DEF2("agi", param),
  7803. ACMD_DEF2("vit", param),
  7804. ACMD_DEF2("int", param),
  7805. ACMD_DEF2("dex", param),
  7806. ACMD_DEF2("luk", param),
  7807. ACMD_DEF2("glvl", guildlevelup),
  7808. ACMD_DEF(makeegg),
  7809. ACMD_DEF(hatch),
  7810. ACMD_DEF(petfriendly),
  7811. ACMD_DEF(pethungry),
  7812. ACMD_DEF(petrename),
  7813. ACMD_DEF(recall), // + /recall
  7814. ACMD_DEF(night),
  7815. ACMD_DEF(day),
  7816. ACMD_DEF(doom),
  7817. ACMD_DEF(doommap),
  7818. ACMD_DEF(raise),
  7819. ACMD_DEF(raisemap),
  7820. ACMD_DEF(kick), // + right click menu for GM "(name) force to quit"
  7821. ACMD_DEF(kickall),
  7822. ACMD_DEF(allskill),
  7823. ACMD_DEF(questskill),
  7824. ACMD_DEF(lostskill),
  7825. ACMD_DEF(spiritball),
  7826. ACMD_DEF(party),
  7827. ACMD_DEF(guild),
  7828. ACMD_DEF(breakguild),
  7829. ACMD_DEF(agitstart),
  7830. ACMD_DEF(agitend),
  7831. ACMD_DEF(mapexit),
  7832. ACMD_DEF(idsearch),
  7833. ACMD_DEF(broadcast), // + /b and /nb
  7834. ACMD_DEF(localbroadcast), // + /lb and /nlb
  7835. ACMD_DEF(recallall),
  7836. ACMD_DEF(reloaditemdb),
  7837. ACMD_DEF(reloadmobdb),
  7838. ACMD_DEF(reloadskilldb),
  7839. ACMD_DEF(reloadscript),
  7840. ACMD_DEF(reloadatcommand),
  7841. ACMD_DEF(reloadbattleconf),
  7842. ACMD_DEF(reloadstatusdb),
  7843. ACMD_DEF(reloadpcdb),
  7844. ACMD_DEF(reloadmotd),
  7845. ACMD_DEF(mapinfo),
  7846. ACMD_DEF(dye),
  7847. ACMD_DEF2("hairstyle", hair_style),
  7848. ACMD_DEF2("haircolor", hair_color),
  7849. ACMD_DEF2("allstats", stat_all),
  7850. ACMD_DEF2("block", char_block),
  7851. ACMD_DEF2("ban", char_ban),
  7852. ACMD_DEF2("unblock", char_unblock),
  7853. ACMD_DEF2("unban", char_unban),
  7854. ACMD_DEF2("mount", mount_peco),
  7855. ACMD_DEF(guildspy),
  7856. ACMD_DEF(partyspy),
  7857. ACMD_DEF(repairall),
  7858. ACMD_DEF(guildrecall),
  7859. ACMD_DEF(partyrecall),
  7860. ACMD_DEF(nuke),
  7861. ACMD_DEF(shownpc),
  7862. ACMD_DEF(hidenpc),
  7863. ACMD_DEF(loadnpc),
  7864. ACMD_DEF(unloadnpc),
  7865. ACMD_DEF2("time", servertime),
  7866. ACMD_DEF(jail),
  7867. ACMD_DEF(unjail),
  7868. ACMD_DEF(jailfor),
  7869. ACMD_DEF(jailtime),
  7870. ACMD_DEF(disguise),
  7871. ACMD_DEF(undisguise),
  7872. ACMD_DEF(email),
  7873. ACMD_DEF(effect),
  7874. ACMD_DEF(follow),
  7875. ACMD_DEF(addwarp),
  7876. ACMD_DEF(skillon),
  7877. ACMD_DEF(skilloff),
  7878. ACMD_DEF(killer),
  7879. ACMD_DEF(npcmove),
  7880. ACMD_DEF(killable),
  7881. ACMD_DEF(dropall),
  7882. ACMD_DEF(storeall),
  7883. ACMD_DEF(skillid),
  7884. ACMD_DEF(useskill),
  7885. ACMD_DEF(displayskill),
  7886. ACMD_DEF(snow),
  7887. ACMD_DEF(sakura),
  7888. ACMD_DEF(clouds),
  7889. ACMD_DEF(clouds2),
  7890. ACMD_DEF(fog),
  7891. ACMD_DEF(fireworks),
  7892. ACMD_DEF(leaves),
  7893. ACMD_DEF(summon),
  7894. ACMD_DEF(adjgroup),
  7895. ACMD_DEF(trade),
  7896. ACMD_DEF(send),
  7897. ACMD_DEF(setbattleflag),
  7898. ACMD_DEF(unmute),
  7899. ACMD_DEF(clearweather),
  7900. ACMD_DEF(uptime),
  7901. ACMD_DEF(changesex),
  7902. ACMD_DEF(mute),
  7903. ACMD_DEF(refresh),
  7904. ACMD_DEF(refreshall),
  7905. ACMD_DEF(identify),
  7906. ACMD_DEF(gmotd),
  7907. ACMD_DEF(misceffect),
  7908. ACMD_DEF(mobsearch),
  7909. ACMD_DEF(cleanmap),
  7910. ACMD_DEF(cleanarea),
  7911. ACMD_DEF(npctalk),
  7912. ACMD_DEF(pettalk),
  7913. ACMD_DEF(users),
  7914. ACMD_DEF(reset),
  7915. ACMD_DEF(skilltree),
  7916. ACMD_DEF(marry),
  7917. ACMD_DEF(divorce),
  7918. ACMD_DEF(sound),
  7919. ACMD_DEF(undisguiseall),
  7920. ACMD_DEF(disguiseall),
  7921. ACMD_DEF(changelook),
  7922. ACMD_DEF(autoloot),
  7923. ACMD_DEF2("alootid", autolootitem),
  7924. ACMD_DEF(mobinfo),
  7925. ACMD_DEF(exp),
  7926. ACMD_DEF(version),
  7927. ACMD_DEF(mutearea),
  7928. ACMD_DEF(rates),
  7929. ACMD_DEF(iteminfo),
  7930. ACMD_DEF(whodrops),
  7931. ACMD_DEF(whereis),
  7932. ACMD_DEF(mapflag),
  7933. ACMD_DEF(me),
  7934. ACMD_DEF(monsterignore),
  7935. ACMD_DEF(fakename),
  7936. ACMD_DEF(size),
  7937. ACMD_DEF(showexp),
  7938. ACMD_DEF(showzeny),
  7939. ACMD_DEF(showdelay),
  7940. ACMD_DEF(autotrade),
  7941. ACMD_DEF(changegm),
  7942. ACMD_DEF(changeleader),
  7943. ACMD_DEF(partyoption),
  7944. ACMD_DEF(invite),
  7945. ACMD_DEF(duel),
  7946. ACMD_DEF(leave),
  7947. ACMD_DEF(accept),
  7948. ACMD_DEF(reject),
  7949. ACMD_DEF(clone),
  7950. ACMD_DEF2("slaveclone", clone),
  7951. ACMD_DEF2("evilclone", clone),
  7952. ACMD_DEF(tonpc),
  7953. ACMD_DEF(commands),
  7954. ACMD_DEF(noask),
  7955. ACMD_DEF(request),
  7956. ACMD_DEF(homlevel),
  7957. ACMD_DEF(homevolution),
  7958. ACMD_DEF(hommutate),
  7959. ACMD_DEF(makehomun),
  7960. ACMD_DEF(homfriendly),
  7961. ACMD_DEF(homhungry),
  7962. ACMD_DEF(homtalk),
  7963. ACMD_DEF(hominfo),
  7964. ACMD_DEF(homstats),
  7965. ACMD_DEF(homshuffle),
  7966. ACMD_DEF(showmobs),
  7967. ACMD_DEF(feelreset),
  7968. ACMD_DEF(auction),
  7969. ACMD_DEF(mail),
  7970. ACMD_DEF2("noks", ksprotection),
  7971. ACMD_DEF(allowks),
  7972. ACMD_DEF(cash),
  7973. ACMD_DEF2("points", cash),
  7974. ACMD_DEF(agitstart2),
  7975. ACMD_DEF(agitend2),
  7976. ACMD_DEF2("skreset", resetskill),
  7977. ACMD_DEF2("streset", resetstat),
  7978. ACMD_DEF2("storagelist", itemlist),
  7979. ACMD_DEF2("cartlist", itemlist),
  7980. ACMD_DEF2("itemlist", itemlist),
  7981. ACMD_DEF(stats),
  7982. ACMD_DEF(delitem),
  7983. ACMD_DEF(charcommands),
  7984. ACMD_DEF(font),
  7985. ACMD_DEF(accinfo),
  7986. ACMD_DEF(set),
  7987. ACMD_DEF(reloadquestdb),
  7988. ACMD_DEF(undisguiseguild),
  7989. ACMD_DEF(disguiseguild),
  7990. ACMD_DEF(sizeall),
  7991. ACMD_DEF(sizeguild),
  7992. ACMD_DEF(addperm),
  7993. ACMD_DEF2("rmvperm", addperm),
  7994. ACMD_DEF(unloadnpcfile),
  7995. ACMD_DEF(cart),
  7996. ACMD_DEF(mount2),
  7997. ACMD_DEF(join),
  7998. ACMD_DEF(channel),
  7999. ACMD_DEF(fontcolor)
  8000. };
  8001. AtCommandInfo* atcommand;
  8002. int i;
  8003. for( i = 0; i < ARRAYLENGTH(atcommand_base); i++ ) {
  8004. if(atcommand_exists(atcommand_base[i].command)) { // Should not happen if atcommand_base[] array is OK
  8005. ShowDebug("atcommand_basecommands: duplicate ACMD_DEF for '%s'.\n", atcommand_base[i].command);
  8006. continue;
  8007. }
  8008. CREATE(atcommand, AtCommandInfo, 1);
  8009. safestrncpy(atcommand->command, atcommand_base[i].command, sizeof(atcommand->command));
  8010. atcommand->func = atcommand_base[i].func;
  8011. strdb_put(atcommand_db, atcommand->command, atcommand);
  8012. }
  8013. return;
  8014. }
  8015. /*==========================================
  8016. * Command lookup functions
  8017. *------------------------------------------*/
  8018. bool atcommand_exists(const char* name)
  8019. {
  8020. return strdb_exists(atcommand_db, name);
  8021. }
  8022. static AtCommandInfo* get_atcommandinfo_byname(const char *name)
  8023. {
  8024. if (strdb_exists(atcommand_db, name))
  8025. return (AtCommandInfo*)strdb_get(atcommand_db, name);
  8026. return NULL;
  8027. }
  8028. static const char* atcommand_checkalias(const char *aliasname)
  8029. {
  8030. AliasInfo *alias_info = NULL;
  8031. if ((alias_info = (AliasInfo*)strdb_get(atcommand_alias_db, aliasname)) != NULL)
  8032. return alias_info->command->command;
  8033. return aliasname;
  8034. }
  8035. /// AtCommand suggestion
  8036. static void atcommand_get_suggestions(struct map_session_data* sd, const char *name, bool atcommand) {
  8037. DBIterator* atcommand_iter;
  8038. DBIterator* alias_iter;
  8039. AtCommandInfo* command_info = NULL;
  8040. AliasInfo* alias_info = NULL;
  8041. AtCommandType type = atcommand ? COMMAND_ATCOMMAND : COMMAND_CHARCOMMAND;
  8042. char* full_match[MAX_SUGGESTIONS];
  8043. char* suggestions[MAX_SUGGESTIONS];
  8044. char* match;
  8045. int prefix_count = 0, full_count = 0;
  8046. bool can_use;
  8047. if (!battle_config.atcommand_suggestions_enabled)
  8048. return;
  8049. atcommand_iter = db_iterator(atcommand_db);
  8050. alias_iter = db_iterator(atcommand_alias_db);
  8051. // Build the matches
  8052. for (command_info = dbi_first(atcommand_iter); dbi_exists(atcommand_iter); command_info = dbi_next(atcommand_iter)) {
  8053. match = strstr(command_info->command, name);
  8054. can_use = pc_can_use_command(sd, command_info->command, type);
  8055. if ( prefix_count < MAX_SUGGESTIONS && match == command_info->command && can_use ) {
  8056. suggestions[prefix_count] = command_info->command;
  8057. ++prefix_count;
  8058. }
  8059. if ( full_count < MAX_SUGGESTIONS && match != NULL && match != command_info->command && can_use ) {
  8060. full_match[full_count] = command_info->command;
  8061. ++full_count;
  8062. }
  8063. }
  8064. for (alias_info = dbi_first(alias_iter); dbi_exists(alias_iter); alias_info = dbi_next(alias_iter)) {
  8065. match = strstr(alias_info->alias, name);
  8066. can_use = pc_can_use_command(sd, alias_info->command->command, type);
  8067. if ( prefix_count < MAX_SUGGESTIONS && match == alias_info->alias && can_use) {
  8068. suggestions[prefix_count] = alias_info->alias;
  8069. ++prefix_count;
  8070. }
  8071. if ( full_count < MAX_SUGGESTIONS && match != NULL && match != alias_info->alias && can_use ) {
  8072. full_match[full_count] = alias_info->alias;
  8073. ++full_count;
  8074. }
  8075. }
  8076. if ((full_count+prefix_count) > 0) {
  8077. char buffer[512];
  8078. int i;
  8079. // Merge full match and prefix match results
  8080. if (prefix_count < MAX_SUGGESTIONS) {
  8081. memmove(&suggestions[prefix_count], full_match, sizeof(char*) * (MAX_SUGGESTIONS-prefix_count));
  8082. prefix_count = min(prefix_count+full_count, MAX_SUGGESTIONS);
  8083. }
  8084. // Build the suggestion string
  8085. strcpy(buffer, msg_txt(205));
  8086. strcat(buffer,"\n");
  8087. for(i=0; i < prefix_count; ++i) {
  8088. strcat(buffer,suggestions[i]);
  8089. strcat(buffer," ");
  8090. }
  8091. clif_displaymessage(sd->fd, buffer);
  8092. }
  8093. dbi_destroy(atcommand_iter);
  8094. dbi_destroy(alias_iter);
  8095. }
  8096. /// Executes an at-command.
  8097. bool is_atcommand(const int fd, struct map_session_data* sd, const char* message, int type)
  8098. {
  8099. char charname[NAME_LENGTH], params[100];
  8100. char charname2[NAME_LENGTH], params2[100];
  8101. char command[100];
  8102. char output[CHAT_SIZE_MAX];
  8103. //Reconstructed message
  8104. char atcmd_msg[CHAT_SIZE_MAX];
  8105. TBL_PC * ssd = NULL; //sd for target
  8106. AtCommandInfo * info;
  8107. nullpo_retr(false, sd);
  8108. //Shouldn't happen
  8109. if ( !message || !*message )
  8110. return false;
  8111. //Block NOCHAT but do not display it as a normal message
  8112. if ( sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCOMMAND )
  8113. return true;
  8114. // skip 10/11-langtype's codepage indicator, if detected
  8115. if ( message[0] == '|' && strlen(message) >= 4 && (message[3] == atcommand_symbol || message[3] == charcommand_symbol) )
  8116. message += 3;
  8117. //Should display as a normal message
  8118. if ( *message != atcommand_symbol && *message != charcommand_symbol )
  8119. return false;
  8120. // type value 0 = server invoked: bypass restrictions
  8121. // 1 = player invoked
  8122. if ( type == 1) {
  8123. //Commands are disabled on maps flagged as 'nocommand'
  8124. if ( map[sd->bl.m].nocommand && pc_get_group_level(sd) < map[sd->bl.m].nocommand ) {
  8125. clif_displaymessage(fd, msg_txt(143));
  8126. return false;
  8127. }
  8128. }
  8129. if (*message == charcommand_symbol) {
  8130. do {
  8131. int x, y, z;
  8132. //Checks to see if #command has a name or a name + parameters.
  8133. x = sscanf(message, "%99s \"%23[^\"]\" %99[^\n]", command, charname, params);
  8134. y = sscanf(message, "%99s %23s %99[^\n]", command, charname2, params2);
  8135. //z always has the value of the scan that was successful
  8136. z = ( x > 1 ) ? x : y;
  8137. //#command + name means the sufficient target was used and anything else after
  8138. //can be looked at by the actual command function since most scan to see if the
  8139. //right parameters are used.
  8140. if ( x > 2 ) {
  8141. sprintf(atcmd_msg, "%s %s", command, params);
  8142. break;
  8143. }
  8144. else if ( y > 2 ) {
  8145. sprintf(atcmd_msg, "%s %s", command, params2);
  8146. break;
  8147. }
  8148. //Regardless of what style the #command is used, if it's correct, it will always have
  8149. //this value if there is no parameter. Send it as just the #command
  8150. else if ( z == 2 ) {
  8151. sprintf(atcmd_msg, "%s", command);
  8152. break;
  8153. }
  8154. if( !pc_get_group_level(sd) ) {
  8155. if( x >= 1 || y >= 1 ) { /* we have command */
  8156. info = get_atcommandinfo_byname(atcommand_checkalias(command + 1));
  8157. 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 */
  8158. return false;
  8159. } else
  8160. return false;/* display as normal message */
  8161. }
  8162. sprintf(output, msg_txt(1388), charcommand_symbol); // Charcommand failed (usage: %c<command> <char name> <parameters>).
  8163. clif_displaymessage(fd, output);
  8164. return true;
  8165. } while(0);
  8166. }
  8167. else if (*message == atcommand_symbol) {
  8168. //atcmd_msg is constructed above differently for charcommands
  8169. //it's copied from message if not a charcommand so it can
  8170. //pass through the rest of the code compatible with both symbols
  8171. sprintf(atcmd_msg, "%s", message);
  8172. }
  8173. //Clearing these to be used once more.
  8174. memset(command, '\0', sizeof(command));
  8175. memset(params, '\0', sizeof(params));
  8176. //check to see if any params exist within this command
  8177. if( sscanf(atcmd_msg, "%99s %99[^\n]", command, params) < 2 )
  8178. params[0] = '\0';
  8179. // @commands (script based)
  8180. if(type == 1 && atcmd_binding_count > 0) {
  8181. struct atcmd_binding_data * binding;
  8182. // Check if the command initiated is a character command
  8183. if (*message == charcommand_symbol &&
  8184. (ssd = map_nick2sd(charname)) == NULL && (ssd = map_nick2sd(charname2)) == NULL ) {
  8185. sprintf(output, msg_txt(1389), command); // %s failed. Player not found.
  8186. clif_displaymessage(fd, output);
  8187. return true;
  8188. }
  8189. // Get atcommand binding
  8190. binding = get_atcommandbind_byname(command);
  8191. // Check if the binding isn't NULL and there is a NPC event, level of usage met, et cetera
  8192. if( binding != NULL && binding->npc_event[0] &&
  8193. ((*atcmd_msg == atcommand_symbol && pc_get_group_level(sd) >= binding->level) ||
  8194. (*atcmd_msg == charcommand_symbol && pc_get_group_level(sd) >= binding->level2)))
  8195. {
  8196. // Check if self or character invoking; if self == character invoked, then self invoke.
  8197. bool invokeFlag = ((*atcmd_msg == atcommand_symbol) ? 1 : 0);
  8198. npc_do_atcmd_event((invokeFlag ? sd : ssd), command, params, binding->npc_event);
  8199. return true;
  8200. }
  8201. }
  8202. //Grab the command information and check for the proper GM level required to use it or if the command exists
  8203. info = get_atcommandinfo_byname(atcommand_checkalias(command + 1));
  8204. if (info == NULL) {
  8205. if( pc_get_group_level(sd) ) { // TODO: remove or replace with proper permission
  8206. sprintf(output, msg_txt(153), command); // "%s is Unknown Command."
  8207. clif_displaymessage(fd, output);
  8208. atcommand_get_suggestions(sd, command + 1, *message == atcommand_symbol);
  8209. return true;
  8210. } else
  8211. return false;
  8212. }
  8213. // type == 1 : player invoked
  8214. if (type == 1) {
  8215. if ((*command == atcommand_symbol && info->at_groups[sd->group_pos] == 0) ||
  8216. (*command == charcommand_symbol && info->char_groups[sd->group_pos] == 0) ) {
  8217. return false;
  8218. }
  8219. if( pc_isdead(sd) && pc_has_permission(sd,PC_PERM_DISABLE_CMD_DEAD) ) {
  8220. clif_displaymessage(fd, msg_txt(1393)); // You can't use commands while dead
  8221. return true;
  8222. }
  8223. }
  8224. // Check if target is valid only if confirmed that player can use command.
  8225. if (*message == charcommand_symbol &&
  8226. (ssd = map_nick2sd(charname)) == NULL && (ssd = map_nick2sd(charname2)) == NULL ) {
  8227. sprintf(output, msg_txt(1389), command); // %s failed. Player not found.
  8228. clif_displaymessage(fd, output);
  8229. return true;
  8230. }
  8231. //Attempt to use the command
  8232. if ( (info->func(fd, (*atcmd_msg == atcommand_symbol) ? sd : ssd, command, params) != 0) )
  8233. {
  8234. sprintf(output,msg_txt(154), command); // %s failed.
  8235. clif_displaymessage(fd, output);
  8236. return true;
  8237. }
  8238. //Log only if successful.
  8239. if ( *atcmd_msg == atcommand_symbol )
  8240. log_atcommand(sd, atcmd_msg);
  8241. else if ( *atcmd_msg == charcommand_symbol )
  8242. log_atcommand(sd, message);
  8243. return true;
  8244. }
  8245. /*==========================================
  8246. *
  8247. *------------------------------------------*/
  8248. static void atcommand_config_read(const char* config_filename)
  8249. {
  8250. config_setting_t *aliases = NULL, *help = NULL;
  8251. const char *symbol = NULL;
  8252. int num_aliases = 0;
  8253. if (conf_read_file(&atcommand_config, config_filename))
  8254. return;
  8255. // Command symbols
  8256. if (config_lookup_string(&atcommand_config, "atcommand_symbol", &symbol)) {
  8257. if (ISPRINT(*symbol) && // no control characters
  8258. *symbol != '/' && // symbol of client commands
  8259. *symbol != '%' && // symbol of party chat
  8260. *symbol != '$' && // symbol of guild chat
  8261. *symbol != charcommand_symbol)
  8262. atcommand_symbol = *symbol;
  8263. }
  8264. if (config_lookup_string(&atcommand_config, "charcommand_symbol", &symbol)) {
  8265. if (ISPRINT(*symbol) && // no control characters
  8266. *symbol != '/' && // symbol of client commands
  8267. *symbol != '%' && // symbol of party chat
  8268. *symbol != '$' && // symbol of guild chat
  8269. *symbol != atcommand_symbol)
  8270. charcommand_symbol = *symbol;
  8271. }
  8272. // Command aliases
  8273. aliases = config_lookup(&atcommand_config, "aliases");
  8274. if (aliases != NULL) {
  8275. int i = 0;
  8276. int count = config_setting_length(aliases);
  8277. for (i = 0; i < count; ++i) {
  8278. config_setting_t *command;
  8279. const char *commandname = NULL;
  8280. int j = 0, alias_count = 0;
  8281. AtCommandInfo *commandinfo = NULL;
  8282. command = config_setting_get_elem(aliases, i);
  8283. if (config_setting_type(command) != CONFIG_TYPE_ARRAY)
  8284. continue;
  8285. commandname = config_setting_name(command);
  8286. if (!atcommand_exists(commandname)) {
  8287. ShowConfigWarning(command, "atcommand_config_read: can not set alias for non-existent command %s", commandname);
  8288. continue;
  8289. }
  8290. commandinfo = get_atcommandinfo_byname(commandname);
  8291. alias_count = config_setting_length(command);
  8292. for (j = 0; j < alias_count; ++j) {
  8293. const char *alias = config_setting_get_string_elem(command, j);
  8294. if (alias != NULL) {
  8295. AliasInfo *alias_info;
  8296. if (strdb_exists(atcommand_alias_db, alias)) {
  8297. ShowConfigWarning(command, "atcommand_config_read: alias %s already exists", alias);
  8298. continue;
  8299. }
  8300. CREATE(alias_info, AliasInfo, 1);
  8301. alias_info->command = commandinfo;
  8302. safestrncpy(alias_info->alias, alias, sizeof(alias_info->alias));
  8303. strdb_put(atcommand_alias_db, alias, alias_info);
  8304. ++num_aliases;
  8305. }
  8306. }
  8307. }
  8308. }
  8309. // Commands help
  8310. // We only check if all commands exist
  8311. help = config_lookup(&atcommand_config, "help");
  8312. if (help != NULL) {
  8313. int count = config_setting_length(help);
  8314. int i;
  8315. for (i = 0; i < count; ++i) {
  8316. config_setting_t *command;
  8317. const char *commandname;
  8318. command = config_setting_get_elem(help, i);
  8319. commandname = config_setting_name(command);
  8320. if (!atcommand_exists(commandname))
  8321. ShowConfigWarning(command, "atcommand_config_read: command %s does not exist", commandname);
  8322. }
  8323. }
  8324. ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' command aliases in '"CL_WHITE"%s"CL_RESET"'.\n", num_aliases, config_filename);
  8325. return;
  8326. }
  8327. void atcommand_db_load_groups(int* group_ids) {
  8328. DBIterator *iter = db_iterator(atcommand_db);
  8329. AtCommandInfo* cmd;
  8330. int i;
  8331. for (cmd = dbi_first(iter); dbi_exists(iter); cmd = dbi_next(iter)) {
  8332. cmd->at_groups = aMalloc( pc_group_max * sizeof(char) );
  8333. cmd->char_groups = aMalloc( pc_group_max * sizeof(char) );
  8334. for(i = 0; i < pc_group_max; i++) {
  8335. if( pc_group_can_use_command(group_ids[i], cmd->command, COMMAND_ATCOMMAND ) )
  8336. cmd->at_groups[i] = 1;
  8337. else
  8338. cmd->at_groups[i] = 0;
  8339. if( pc_group_can_use_command(group_ids[i], cmd->command, COMMAND_CHARCOMMAND ) )
  8340. cmd->char_groups[i] = 1;
  8341. else
  8342. cmd->char_groups[i] = 0;
  8343. }
  8344. }
  8345. dbi_destroy(iter);
  8346. return;
  8347. }
  8348. void atcommand_db_clear(void) {
  8349. if (atcommand_db != NULL) {
  8350. DBIterator *iter = db_iterator(atcommand_db);
  8351. AtCommandInfo* cmd;
  8352. for (cmd = dbi_first(iter); dbi_exists(iter); cmd = dbi_next(iter)) {
  8353. aFree(cmd->at_groups);
  8354. aFree(cmd->char_groups);
  8355. }
  8356. dbi_destroy(iter);
  8357. db_destroy(atcommand_db);
  8358. }
  8359. if (atcommand_alias_db != NULL)
  8360. db_destroy(atcommand_alias_db);
  8361. config_destroy(&atcommand_config);
  8362. }
  8363. void atcommand_doload(void) {
  8364. atcommand_db_clear();
  8365. atcommand_db = stridb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, ATCOMMAND_LENGTH);
  8366. atcommand_alias_db = stridb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, ATCOMMAND_LENGTH);
  8367. atcommand_basecommands(); //fills initial atcommand_db with known commands
  8368. atcommand_config_read(ATCOMMAND_CONF_FILENAME);
  8369. }
  8370. void do_init_atcommand(void) {
  8371. atcommand_doload();
  8372. }
  8373. void do_final_atcommand(void) {
  8374. atcommand_db_clear();
  8375. }