atcommand.c 321 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669
  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/showmsg.h"
  8. #include "../common/malloc.h"
  9. #include "../common/random.h"
  10. #include "../common/socket.h"
  11. #include "../common/strlib.h"
  12. #include "../common/utils.h"
  13. #include "../common/conf.h"
  14. #include "map.h"
  15. #include "atcommand.h"
  16. #include "battle.h"
  17. #include "chat.h"
  18. #include "channel.h"
  19. #include "chrif.h"
  20. #include "duel.h"
  21. #include "instance.h"
  22. #include "intif.h"
  23. #include "pet.h"
  24. #include "homunculus.h"
  25. #include "mail.h"
  26. #include "mercenary.h"
  27. #include "elemental.h"
  28. #include "party.h"
  29. #include "script.h"
  30. #include "storage.h"
  31. #include "trade.h"
  32. #include "mapreg.h"
  33. #include "quest.h"
  34. #include "pc.h"
  35. #include <stdlib.h>
  36. #include <math.h>
  37. #define ATCOMMAND_LENGTH 50
  38. #define ACMD_FUNC(x) static int atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message)
  39. typedef struct AtCommandInfo AtCommandInfo;
  40. typedef struct AliasInfo AliasInfo;
  41. int atcmd_binding_count = 0;
  42. /// Atcommand restriction usage
  43. enum e_atcmd_restict {
  44. ATCMD_NOCONSOLE = 0x1, /// Cannot be used via console (is_atcommand type 2)
  45. ATCMD_NOSCRIPT = 0x2, /// Cannot be used via script command 'atcommand' or 'useatcmd' (is_atcommand type 0 and 3)
  46. ATCMD_NOAUTOTRADE = 0x4, /// Like ATCMD_NOSCRIPT, but if the player is autotrader. Example: atcommand "@kick "+strcharinfo(0);
  47. };
  48. struct AtCommandInfo {
  49. char command[ATCOMMAND_LENGTH];
  50. AtCommandFunc func;
  51. char* at_groups; /// Quick @commands "can-use" lookup
  52. char* char_groups; /// Quick @charcommands "can-use" lookup
  53. uint8 restriction; /// Restrictions see enum e_restict
  54. };
  55. struct AliasInfo {
  56. AtCommandInfo *command;
  57. char alias[ATCOMMAND_LENGTH];
  58. };
  59. char atcommand_symbol = '@'; // first char of the commands
  60. char charcommand_symbol = '#';
  61. static DBMap* atcommand_db = NULL; //name -> AtCommandInfo
  62. static DBMap* atcommand_alias_db = NULL; //alias -> AtCommandInfo
  63. static config_t atcommand_config;
  64. static char atcmd_output[CHAT_SIZE_MAX];
  65. static char atcmd_player_name[NAME_LENGTH];
  66. const char *parent_cmd;
  67. static AtCommandInfo* get_atcommandinfo_byname(const char *name); // @help
  68. static const char* atcommand_checkalias(const char *aliasname); // @help
  69. static void atcommand_get_suggestions(struct map_session_data* sd, const char *name, bool atcommand); // @help
  70. static void warp_get_suggestions(struct map_session_data* sd, const char *name); // @rura, @warp, @mapmove
  71. // @commands (script-based)
  72. struct atcmd_binding_data* get_atcommandbind_byname(const char* name) {
  73. int i = 0;
  74. if( *name == atcommand_symbol || *name == charcommand_symbol )
  75. name++; // for backwards compatibility
  76. ARR_FIND( 0, atcmd_binding_count, i, strcmpi(atcmd_binding[i]->command, name) == 0 );
  77. return ( i < atcmd_binding_count ) ? atcmd_binding[i] : NULL;
  78. }
  79. /**
  80. * retrieves the help string associated with a given command.
  81. *
  82. * @param name the name of the command to retrieve help information for
  83. * @return the string associated with the command, or NULL
  84. */
  85. static const char* atcommand_help_string(const char* command)
  86. {
  87. const char* str = NULL;
  88. config_setting_t* info;
  89. if( *command == atcommand_symbol || *command == charcommand_symbol )
  90. {// remove the prefix symbol for the raw name of the command
  91. command ++;
  92. }
  93. // convert alias to the real command name
  94. command = atcommand_checkalias(command);
  95. // attempt to find the first default help command
  96. info = config_lookup(&atcommand_config, "help");
  97. if( info == NULL )
  98. {// failed to find the help property in the configuration file
  99. return NULL;
  100. }
  101. if( !config_setting_lookup_string( info, command, &str ) )
  102. {// failed to find the matching help string
  103. return NULL;
  104. }
  105. // push the result from the method
  106. return str;
  107. }
  108. /*==========================================
  109. * @send (used for testing packet sends from the client)
  110. *------------------------------------------*/
  111. ACMD_FUNC(send)
  112. {
  113. int len=0,type;
  114. // read message type as hex number (without the 0x)
  115. if(!message || !*message ||
  116. !((sscanf(message, "len %8x", &type)==1 && (len=1))
  117. || sscanf(message, "%8x", &type)==1) )
  118. {
  119. int i;
  120. for (i = 900; i <= 903; ++i)
  121. clif_displaymessage(fd, msg_txt(sd,i));
  122. return -1;
  123. }
  124. #define PARSE_ERROR(error,p) \
  125. {\
  126. clif_displaymessage(fd, (error));\
  127. sprintf(atcmd_output, ">%s", (p));\
  128. clif_displaymessage(fd, atcmd_output);\
  129. }
  130. //define PARSE_ERROR
  131. #define CHECK_EOS(p) \
  132. if(*(p) == 0){\
  133. clif_displaymessage(fd, "Unexpected end of string");\
  134. return -1;\
  135. }
  136. //define CHECK_EOS
  137. #define SKIP_VALUE(p) \
  138. {\
  139. while(*(p) && !ISSPACE(*(p))) ++(p); /* non-space */\
  140. while(*(p) && ISSPACE(*(p))) ++(p); /* space */\
  141. }
  142. //define SKIP_VALUE
  143. #define GET_VALUE(p,num) \
  144. {\
  145. if(sscanf((p), "x%16lx", &(num)) < 1 && sscanf((p), "%20ld ", &(num)) < 1){\
  146. PARSE_ERROR("Invalid number in:",(p));\
  147. return -1;\
  148. }\
  149. }
  150. //define GET_VALUE
  151. if (type > 0 && type < MAX_PACKET_DB) {
  152. int off,end;
  153. long num;
  154. if(len)
  155. {// show packet length
  156. sprintf(atcmd_output, msg_txt(sd,904), type, packet_db[sd->packet_ver][type].len); // Packet 0x%x length: %d
  157. clif_displaymessage(fd, atcmd_output);
  158. return 0;
  159. }
  160. len=packet_db[sd->packet_ver][type].len;
  161. off=2;
  162. if(len == 0)
  163. {// unknown packet - ERROR
  164. sprintf(atcmd_output, msg_txt(sd,905), type); // Unknown packet: 0x%x
  165. clif_displaymessage(fd, atcmd_output);
  166. return -1;
  167. } else if(len == -1)
  168. {// dynamic packet
  169. len=SHRT_MAX-4; // maximum length
  170. off=4;
  171. }
  172. WFIFOHEAD(fd, len);
  173. WFIFOW(fd,0)=TOW(type);
  174. // parse packet contents
  175. SKIP_VALUE(message);
  176. while(*message != 0 && off < len){
  177. if(ISDIGIT(*message) || *message == '-' || *message == '+')
  178. {// default (byte)
  179. GET_VALUE(message,num);
  180. WFIFOB(fd,off)=TOB(num);
  181. ++off;
  182. } else if(TOUPPER(*message) == 'B')
  183. {// byte
  184. ++message;
  185. GET_VALUE(message,num);
  186. WFIFOB(fd,off)=TOB(num);
  187. ++off;
  188. } else if(TOUPPER(*message) == 'W')
  189. {// word (2 bytes)
  190. ++message;
  191. GET_VALUE(message,num);
  192. WFIFOW(fd,off)=TOW(num);
  193. off+=2;
  194. } else if(TOUPPER(*message) == 'L')
  195. {// long word (4 bytes)
  196. ++message;
  197. GET_VALUE(message,num);
  198. WFIFOL(fd,off)=TOL(num);
  199. off+=4;
  200. } else if(TOUPPER(*message) == 'S')
  201. {// string - escapes are valid
  202. // get string length - num <= 0 means not fixed length (default)
  203. ++message;
  204. if(*message == '"'){
  205. num=0;
  206. } else {
  207. GET_VALUE(message,num);
  208. while(*message != '"')
  209. {// find start of string
  210. if(*message == 0 || ISSPACE(*message)){
  211. PARSE_ERROR(msg_txt(sd,906),message); // Not a string:
  212. return -1;
  213. }
  214. ++message;
  215. }
  216. }
  217. // parse string
  218. ++message;
  219. CHECK_EOS(message);
  220. end=(num<=0? 0: min(off+((int)num),len));
  221. for(; *message != '"' && (off < end || end == 0); ++off){
  222. if(*message == '\\'){
  223. ++message;
  224. CHECK_EOS(message);
  225. switch(*message){
  226. case 'a': num=0x07; break; // Bell
  227. case 'b': num=0x08; break; // Backspace
  228. case 't': num=0x09; break; // Horizontal tab
  229. case 'n': num=0x0A; break; // Line feed
  230. case 'v': num=0x0B; break; // Vertical tab
  231. case 'f': num=0x0C; break; // Form feed
  232. case 'r': num=0x0D; break; // Carriage return
  233. case 'e': num=0x1B; break; // Escape
  234. default: num=*message; break;
  235. case 'x': // Hexadecimal
  236. {
  237. ++message;
  238. CHECK_EOS(message);
  239. if(!ISXDIGIT(*message)){
  240. PARSE_ERROR(msg_txt(sd,907),message); // Not a hexadecimal digit:
  241. return -1;
  242. }
  243. num=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  244. if(ISXDIGIT(*message)){
  245. ++message;
  246. CHECK_EOS(message);
  247. num<<=8;
  248. num+=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  249. }
  250. WFIFOB(fd,off)=TOB(num);
  251. ++message;
  252. CHECK_EOS(message);
  253. continue;
  254. }
  255. case '0':
  256. case '1':
  257. case '2':
  258. case '3':
  259. case '4':
  260. case '5':
  261. case '6':
  262. case '7': // Octal
  263. {
  264. num=*message-'0'; // 1st octal digit
  265. ++message;
  266. CHECK_EOS(message);
  267. if(ISDIGIT(*message) && *message < '8'){
  268. num<<=3;
  269. num+=*message-'0'; // 2nd octal digit
  270. ++message;
  271. CHECK_EOS(message);
  272. if(ISDIGIT(*message) && *message < '8'){
  273. num<<=3;
  274. num+=*message-'0'; // 3rd octal digit
  275. ++message;
  276. CHECK_EOS(message);
  277. }
  278. }
  279. WFIFOB(fd,off)=TOB(num);
  280. continue;
  281. }
  282. }
  283. } else
  284. num=*message;
  285. WFIFOB(fd,off)=TOB(num);
  286. ++message;
  287. CHECK_EOS(message);
  288. }//for
  289. while(*message != '"')
  290. {// ignore extra characters
  291. ++message;
  292. CHECK_EOS(message);
  293. }
  294. // terminate the string
  295. if(off < end)
  296. {// fill the rest with 0's
  297. memset(WFIFOP(fd,off),0,end-off);
  298. off=end;
  299. }
  300. } else
  301. {// unknown
  302. PARSE_ERROR(msg_txt(sd,908),message); // Unknown type of value in:
  303. return -1;
  304. }
  305. SKIP_VALUE(message);
  306. }
  307. if(packet_db[sd->packet_ver][type].len == -1)
  308. {// send dynamic packet
  309. WFIFOW(fd,2)=TOW(off);
  310. WFIFOSET(fd,off);
  311. } else
  312. {// send static packet
  313. if(off < len)
  314. memset(WFIFOP(fd,off),0,len-off);
  315. WFIFOSET(fd,len);
  316. }
  317. } else {
  318. clif_displaymessage(fd, msg_txt(sd,259)); // Invalid packet
  319. return -1;
  320. }
  321. sprintf (atcmd_output, msg_txt(sd,258), type, type); // Sent packet 0x%x (%d)
  322. clif_displaymessage(fd, atcmd_output);
  323. return 0;
  324. #undef PARSE_ERROR
  325. #undef CHECK_EOS
  326. #undef SKIP_VALUE
  327. #undef GET_VALUE
  328. }
  329. /**
  330. * Retrieves map name suggestions for a given string.
  331. * This will first check if any map names contain the given string, and will
  332. * print out MAX_SUGGESTIONS results if any maps are found.
  333. * Otherwise, suggestions will be calculated through Levenshtein distance,
  334. * and up to 5 of the closest matches will be printed.
  335. *
  336. * @author Euphy
  337. */
  338. static void warp_get_suggestions(struct map_session_data* sd, const char *name) {
  339. char buffer[512];
  340. int i, count = 0;
  341. if (strlen(name) < 2)
  342. return;
  343. // build the suggestion string
  344. strcpy(buffer, msg_txt(sd, 205)); // Maybe you meant:
  345. strcat(buffer, "\n");
  346. // check for maps that contain string
  347. for (i = 0; i < MAX_MAP_PER_SERVER; i++) {
  348. if (count < MAX_SUGGESTIONS && strstr(map[i].name, name) != NULL) {
  349. strcat(buffer, map[i].name);
  350. strcat(buffer, " ");
  351. if (++count >= MAX_SUGGESTIONS)
  352. break;
  353. }
  354. }
  355. // if no maps found, search by edit distance
  356. if (!count) {
  357. unsigned int distance[MAX_MAP_PER_SERVER][2];
  358. int j;
  359. // calculate Levenshtein distance for all maps
  360. for (i = 0; i < MAX_MAP_PER_SERVER; i++) {
  361. if (strlen(map[i].name) < 4) // invalid map name?
  362. distance[i][0] = INT_MAX;
  363. else {
  364. distance[i][0] = levenshtein(map[i].name, name);
  365. distance[i][1] = i;
  366. }
  367. }
  368. // selection sort elements as needed
  369. count = min(MAX_SUGGESTIONS, 5); // results past 5 aren't worth showing
  370. for (i = 0; i < count; i++) {
  371. int min = i;
  372. for (j = i+1; j < MAX_MAP_PER_SERVER; j++) {
  373. if (distance[j][0] < distance[min][0])
  374. min = j;
  375. }
  376. // print map name
  377. if (distance[min][0] > 4) { // awful results, don't bother
  378. if (!i) return;
  379. break;
  380. }
  381. strcat(buffer, map[distance[min][1]].name);
  382. strcat(buffer, " ");
  383. // swap elements
  384. swap(distance[i][0], distance[min][0]);
  385. swap(distance[i][1], distance[min][1]);
  386. }
  387. }
  388. clif_displaymessage(sd->fd, buffer);
  389. }
  390. /*==========================================
  391. * @rura, @warp, @mapmove
  392. *------------------------------------------*/
  393. ACMD_FUNC(mapmove)
  394. {
  395. char map_name[MAP_NAME_LENGTH_EXT];
  396. unsigned short mapindex;
  397. short x = 0, y = 0;
  398. int16 m = -1;
  399. nullpo_retr(-1, sd);
  400. memset(map_name, '\0', sizeof(map_name));
  401. if (!message || !*message ||
  402. (sscanf(message, "%15s %6hd %6hd", map_name, &x, &y) < 3 &&
  403. sscanf(message, "%15[^,],%6hd,%6hd", map_name, &x, &y) < 1)) {
  404. clif_displaymessage(fd, msg_txt(sd,909)); // Please enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).
  405. return -1;
  406. }
  407. mapindex = mapindex_name2id(map_name);
  408. if (mapindex)
  409. m = map_mapindex2mapid(mapindex);
  410. if (!mapindex) { // m < 0 means on different server! [Kevin]
  411. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  412. if (battle_config.warp_suggestions_enabled)
  413. warp_get_suggestions(sd, map_name);
  414. return -1;
  415. }
  416. if ((x || y) && map_getcell(m, x, y, CELL_CHKNOPASS))
  417. { //This is to prevent the pc_setpos call from printing an error.
  418. clif_displaymessage(fd, msg_txt(sd,2));
  419. if (!map_search_freecell(NULL, m, &x, &y, 10, 10, 1))
  420. x = y = 0; //Invalid cell, use random spot.
  421. }
  422. if ((map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) || !pc_job_can_entermap((enum e_job)sd->status.class_, m, sd->group_level)) {
  423. clif_displaymessage(fd, msg_txt(sd,247));
  424. return -1;
  425. }
  426. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  427. clif_displaymessage(fd, msg_txt(sd,248));
  428. return -1;
  429. }
  430. if (pc_setpos(sd, mapindex, x, y, CLR_TELEPORT) != SETPOS_OK) {
  431. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  432. return -1;
  433. }
  434. clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
  435. return 0;
  436. }
  437. /*==========================================
  438. * Displays where a character is. Corrected version by Silent. [Skotlex]
  439. *------------------------------------------*/
  440. ACMD_FUNC(where)
  441. {
  442. struct map_session_data* pl_sd;
  443. nullpo_retr(-1, sd);
  444. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  445. if (!message || !*message || sscanf(message, "%23s[^\n]", atcmd_player_name) < 1) {
  446. clif_displaymessage(fd, msg_txt(sd,910)); // Please enter a player name (usage: @where <char name>).
  447. return -1;
  448. }
  449. pl_sd = map_nick2sd(atcmd_player_name,true);
  450. if (pl_sd == NULL ||
  451. strncmp(pl_sd->status.name, atcmd_player_name, NAME_LENGTH) != 0 ||
  452. (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))
  453. ) {
  454. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  455. return -1;
  456. }
  457. 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);
  458. clif_displaymessage(fd, atcmd_output);
  459. return 0;
  460. }
  461. /*==========================================
  462. *
  463. *------------------------------------------*/
  464. ACMD_FUNC(jumpto)
  465. {
  466. struct map_session_data *pl_sd = NULL;
  467. nullpo_retr(-1, sd);
  468. if (!message || !*message) {
  469. clif_displaymessage(fd, msg_txt(sd,911)); // Please enter a player name (usage: @jumpto/@warpto/@goto <char name/ID>).
  470. return -1;
  471. }
  472. if((pl_sd=map_nick2sd((char *)message,true)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  473. {
  474. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  475. return -1;
  476. }
  477. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  478. {
  479. clif_displaymessage(fd, msg_txt(sd,247)); // You are not authorized to warp to this map.
  480. return -1;
  481. }
  482. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  483. {
  484. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  485. return -1;
  486. }
  487. if( pc_isdead(sd) )
  488. {
  489. clif_displaymessage(fd, msg_txt(sd,664));
  490. return -1;
  491. }
  492. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  493. sprintf(atcmd_output, msg_txt(sd,4), pl_sd->status.name); // Jumped to %s
  494. clif_displaymessage(fd, atcmd_output);
  495. return 0;
  496. }
  497. /*==========================================
  498. *
  499. *------------------------------------------*/
  500. ACMD_FUNC(jump)
  501. {
  502. short x = 0, y = 0;
  503. nullpo_retr(-1, sd);
  504. memset(atcmd_output, '\0', sizeof(atcmd_output));
  505. sscanf(message, "%6hd %6hd", &x, &y);
  506. if (map[sd->bl.m].flag.noteleport && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  507. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  508. return -1;
  509. }
  510. if( pc_isdead(sd) )
  511. {
  512. clif_displaymessage(fd, msg_txt(sd,664));
  513. return -1;
  514. }
  515. if ((x || y) && map_getcell(sd->bl.m, x, y, CELL_CHKNOPASS))
  516. { //This is to prevent the pc_setpos call from printing an error.
  517. clif_displaymessage(fd, msg_txt(sd,2));
  518. if (!map_search_freecell(NULL, sd->bl.m, &x, &y, 10, 10, 1))
  519. x = y = 0; //Invalid cell, use random spot.
  520. }
  521. pc_setpos(sd, sd->mapindex, x, y, CLR_TELEPORT);
  522. sprintf(atcmd_output, msg_txt(sd,5), sd->bl.x, sd->bl.y); // Jumped to %d %d
  523. clif_displaymessage(fd, atcmd_output);
  524. return 0;
  525. }
  526. /*==========================================
  527. * Display list of online characters with
  528. * various info.
  529. *------------------------------------------*/
  530. ACMD_FUNC(who) {
  531. struct map_session_data *pl_sd = NULL;
  532. struct s_mapiterator *iter = NULL;
  533. char player_name[NAME_LENGTH] = "";
  534. int count = 0;
  535. int level = 0;
  536. StringBuf buf;
  537. /**
  538. * 1 = @who : Player name, [Title], [Party name], [Guild name]
  539. * 2 = @who2 : Player name, [Title], BLvl, JLvl, Job
  540. * 3 = @who3 : [CID/AID] Player name [Title], Map, X, Y
  541. */
  542. int display_type = 1;
  543. int map_id = -1;
  544. nullpo_retr(-1, sd);
  545. if (strstr(command, "map") != NULL) {
  546. char map_name[MAP_NAME_LENGTH_EXT] = "";
  547. if (sscanf(message, "%15s %23s", map_name, player_name) < 1 || (map_id = map_mapname2mapid(map_name)) < 0)
  548. map_id = sd->bl.m;
  549. } else {
  550. sscanf(message, "%23s", player_name);
  551. }
  552. if (strstr(command, "2") != NULL)
  553. display_type = 2;
  554. else if (strstr(command, "3") != NULL)
  555. display_type = 3;
  556. level = pc_get_group_level(sd);
  557. StringBuf_Init(&buf);
  558. iter = mapit_getallusers();
  559. for (pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter)) {
  560. if (!((pc_has_permission(pl_sd, PC_PERM_HIDE_SESSION) || pc_isinvisible(pl_sd)) && pc_get_group_level(pl_sd) > level)) { // you can look only lower or same level
  561. if (stristr(pl_sd->status.name, player_name) == NULL // search with no case sensitive
  562. || (map_id >= 0 && pl_sd->bl.m != map_id))
  563. continue;
  564. switch (display_type) {
  565. case 2: {
  566. StringBuf_Printf(&buf, msg_txt(sd,343), pl_sd->status.name); // "Name: %s "
  567. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  568. StringBuf_Printf(&buf, msg_txt(sd,344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
  569. StringBuf_Printf(&buf, msg_txt(sd,347), pl_sd->status.base_level, pl_sd->status.job_level,
  570. job_name(pl_sd->status.class_)); // "| Lv:%d/%d | Job: %s"
  571. break;
  572. }
  573. case 3: {
  574. if (pc_has_permission(sd, PC_PERM_WHO_DISPLAY_AID))
  575. StringBuf_Printf(&buf, msg_txt(sd,912), pl_sd->status.char_id, pl_sd->status.account_id); // "(CID:%d/AID:%d) "
  576. StringBuf_Printf(&buf, msg_txt(sd,343), pl_sd->status.name); // "Name: %s "
  577. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  578. StringBuf_Printf(&buf, msg_txt(sd,344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
  579. StringBuf_Printf(&buf, msg_txt(sd,348), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y); // "| Location: %s %d %d"
  580. break;
  581. }
  582. default: {
  583. struct party_data *p = party_search(pl_sd->status.party_id);
  584. struct guild *g = pl_sd->guild;
  585. StringBuf_Printf(&buf, msg_txt(sd,343), pl_sd->status.name); // "Name: %s "
  586. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  587. StringBuf_Printf(&buf, msg_txt(sd,344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
  588. if (p != NULL)
  589. StringBuf_Printf(&buf, msg_txt(sd,345), p->party.name); // " | Party: '%s'"
  590. if (g != NULL)
  591. StringBuf_Printf(&buf, msg_txt(sd,346), g->name); // " | Guild: '%s'"
  592. break;
  593. }
  594. }
  595. clif_displaymessage(fd, StringBuf_Value(&buf));
  596. StringBuf_Clear(&buf);
  597. count++;
  598. }
  599. }
  600. mapit_free(iter);
  601. if (map_id < 0) {
  602. if (count == 0)
  603. StringBuf_Printf(&buf, msg_txt(sd,28)); // No player found.
  604. else if (count == 1)
  605. StringBuf_Printf(&buf, msg_txt(sd,29)); // 1 player found.
  606. else
  607. StringBuf_Printf(&buf, msg_txt(sd,30), count); // %d players found.
  608. } else {
  609. if (count == 0)
  610. StringBuf_Printf(&buf, msg_txt(sd,54), map[map_id].name); // No player found in map '%s'.
  611. else if (count == 1)
  612. StringBuf_Printf(&buf, msg_txt(sd,55), map[map_id].name); // 1 player found in map '%s'.
  613. else
  614. StringBuf_Printf(&buf, msg_txt(sd,56), count, map[map_id].name); // %d players found in map '%s'.
  615. }
  616. clif_displaymessage(fd, StringBuf_Value(&buf));
  617. StringBuf_Destroy(&buf);
  618. return 0;
  619. }
  620. /*==========================================
  621. *
  622. *------------------------------------------*/
  623. ACMD_FUNC(whogm)
  624. {
  625. struct map_session_data* pl_sd;
  626. struct s_mapiterator* iter;
  627. int j, count;
  628. int level;
  629. char match_text[CHAT_SIZE_MAX];
  630. char player_name[NAME_LENGTH];
  631. struct guild *g;
  632. struct party_data *p;
  633. nullpo_retr(-1, sd);
  634. memset(atcmd_output, '\0', sizeof(atcmd_output));
  635. memset(match_text, '\0', sizeof(match_text));
  636. memset(player_name, '\0', sizeof(player_name));
  637. if (sscanf(message, "%255[^\n]", match_text) < 1)
  638. strcpy(match_text, "");
  639. for (j = 0; match_text[j]; j++)
  640. match_text[j] = TOLOWER(match_text[j]);
  641. count = 0;
  642. level = pc_get_group_level(sd);
  643. iter = mapit_getallusers();
  644. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  645. {
  646. int pl_level = pc_get_group_level(pl_sd);
  647. if (!pl_level)
  648. continue;
  649. if (match_text[0])
  650. {
  651. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  652. for (j = 0; player_name[j]; j++)
  653. player_name[j] = TOLOWER(player_name[j]);
  654. // search with no case sensitive
  655. if (strstr(player_name, match_text) == NULL)
  656. continue;
  657. }
  658. if (pl_level > level) {
  659. if (pc_isinvisible(pl_sd))
  660. continue;
  661. sprintf(atcmd_output, msg_txt(sd,913), pl_sd->status.name); // Name: %s (GM)
  662. clif_displaymessage(fd, atcmd_output);
  663. count++;
  664. continue;
  665. }
  666. sprintf(atcmd_output, msg_txt(sd,914), // Name: %s (GM:%d) | Location: %s %d %d
  667. pl_sd->status.name, pl_level,
  668. mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  669. clif_displaymessage(fd, atcmd_output);
  670. sprintf(atcmd_output, msg_txt(sd,915), // BLvl: %d | Job: %s (Lvl: %d)
  671. pl_sd->status.base_level,
  672. job_name(pl_sd->status.class_), pl_sd->status.job_level);
  673. clif_displaymessage(fd, atcmd_output);
  674. p = party_search(pl_sd->status.party_id);
  675. g = pl_sd->guild;
  676. sprintf(atcmd_output,msg_txt(sd,916), // Party: '%s' | Guild: '%s'
  677. p?p->party.name:msg_txt(sd,917), g?g->name:msg_txt(sd,917)); // None.
  678. clif_displaymessage(fd, atcmd_output);
  679. count++;
  680. }
  681. mapit_free(iter);
  682. if (count == 0)
  683. clif_displaymessage(fd, msg_txt(sd,150)); // No GM found.
  684. else if (count == 1)
  685. clif_displaymessage(fd, msg_txt(sd,151)); // 1 GM found.
  686. else {
  687. sprintf(atcmd_output, msg_txt(sd,152), count); // %d GMs found.
  688. clif_displaymessage(fd, atcmd_output);
  689. }
  690. return 0;
  691. }
  692. /*==========================================
  693. *
  694. *------------------------------------------*/
  695. ACMD_FUNC(save)
  696. {
  697. nullpo_retr(-1, sd);
  698. if( map[sd->bl.m].instance_id ) {
  699. clif_displaymessage(fd, msg_txt(sd,383)); // You cannot create a savepoint in an instance.
  700. return 1;
  701. }
  702. pc_setsavepoint(sd, sd->mapindex, sd->bl.x, sd->bl.y);
  703. if (sd->status.pet_id > 0 && sd->pd)
  704. intif_save_petdata(sd->status.account_id, &sd->pd->pet);
  705. chrif_save(sd,0);
  706. clif_displaymessage(fd, msg_txt(sd,6)); // Your save point has been changed.
  707. return 0;
  708. }
  709. /*==========================================
  710. *
  711. *------------------------------------------*/
  712. ACMD_FUNC(load)
  713. {
  714. int16 m;
  715. nullpo_retr(-1, sd);
  716. m = map_mapindex2mapid(sd->status.save_point.map);
  717. if (m >= 0 && map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  718. clif_displaymessage(fd, msg_txt(sd,249)); // You are not authorized to warp to your save map.
  719. return -1;
  720. }
  721. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  722. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  723. return -1;
  724. }
  725. pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, CLR_OUTSIGHT);
  726. clif_displaymessage(fd, msg_txt(sd,7)); // Warping to save point..
  727. return 0;
  728. }
  729. /*==========================================
  730. *
  731. *------------------------------------------*/
  732. ACMD_FUNC(speed)
  733. {
  734. short speed;
  735. nullpo_retr(-1, sd);
  736. memset(atcmd_output, '\0', sizeof(atcmd_output));
  737. if (!message || !*message || sscanf(message, "%6hd", &speed) < 1) {
  738. sprintf(atcmd_output, msg_txt(sd,918), MIN_WALK_SPEED, MAX_WALK_SPEED); // Please enter a speed value (usage: @speed <%d-%d>).
  739. clif_displaymessage(fd, atcmd_output);
  740. return -1;
  741. }
  742. sd->state.permanent_speed = 0; // Remove lock when set back to default speed.
  743. if (speed < 0)
  744. sd->base_status.speed = DEFAULT_WALK_SPEED;
  745. else
  746. sd->base_status.speed = cap_value(speed, MIN_WALK_SPEED, MAX_WALK_SPEED);
  747. if (sd->base_status.speed != DEFAULT_WALK_SPEED) {
  748. sd->state.permanent_speed = 1; // Set lock when set to non-default speed.
  749. clif_displaymessage(fd, msg_txt(sd,8)); // Speed changed.
  750. } else
  751. clif_displaymessage(fd, msg_txt(sd,389)); // Speed returned to normal.
  752. status_calc_bl(&sd->bl, SCB_SPEED);
  753. return 0;
  754. }
  755. /*==========================================
  756. *
  757. *------------------------------------------*/
  758. ACMD_FUNC(storage)
  759. {
  760. nullpo_retr(-1, sd);
  761. if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading || sd->state.storage_flag)
  762. return -1;
  763. if (storage_storageopen(sd) == 1)
  764. { //Already open.
  765. clif_displaymessage(fd, msg_txt(sd,250));
  766. return -1;
  767. }
  768. clif_displaymessage(fd, msg_txt(sd,919)); // Storage opened.
  769. return 0;
  770. }
  771. /*==========================================
  772. *
  773. *------------------------------------------*/
  774. ACMD_FUNC(guildstorage)
  775. {
  776. nullpo_retr(-1, sd);
  777. if (!sd->status.guild_id) {
  778. clif_displaymessage(fd, msg_txt(sd,252));
  779. return -1;
  780. }
  781. if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading)
  782. return -1;
  783. if (sd->state.storage_flag == 1) {
  784. clif_displaymessage(fd, msg_txt(sd,250));
  785. return -1;
  786. }
  787. if (sd->state.storage_flag == 2) {
  788. clif_displaymessage(fd, msg_txt(sd,251));
  789. return -1;
  790. }
  791. if (sd->state.storage_flag == 3) {
  792. clif_displaymessage(fd, msg_txt(sd,250));
  793. return -1;
  794. }
  795. storage_guild_storageopen(sd);
  796. clif_displaymessage(fd, msg_txt(sd,920)); // Guild storage opened.
  797. return 0;
  798. }
  799. /*==========================================
  800. *
  801. *------------------------------------------*/
  802. ACMD_FUNC(option)
  803. {
  804. int param1 = 0, param2 = 0, param3 = 0;
  805. nullpo_retr(-1, sd);
  806. if (!message || !*message || sscanf(message, "%11d %11d %11d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0)
  807. {// failed to match the parameters so inform the user of the options
  808. const char* text;
  809. // attempt to find the setting information for this command
  810. text = atcommand_help_string( command );
  811. // notify the user of the requirement to enter an option
  812. clif_displaymessage(fd, msg_txt(sd,921)); // Please enter at least one option.
  813. if( text )
  814. {// send the help text associated with this command
  815. clif_displaymessage( fd, text );
  816. }
  817. return -1;
  818. }
  819. sd->sc.opt1 = param1;
  820. sd->sc.opt2 = param2;
  821. pc_setoption(sd, param3);
  822. clif_displaymessage(fd, msg_txt(sd,9)); // Options changed.
  823. return 0;
  824. }
  825. /*==========================================
  826. *
  827. *------------------------------------------*/
  828. ACMD_FUNC(hide)
  829. {
  830. nullpo_retr(-1, sd);
  831. if (pc_isinvisible(sd)) {
  832. sd->sc.option &= ~OPTION_INVISIBLE;
  833. if (sd->disguise)
  834. status_set_viewdata(&sd->bl, sd->disguise);
  835. else
  836. status_set_viewdata(&sd->bl, sd->status.class_);
  837. clif_displaymessage(fd, msg_txt(sd,10)); // Invisible: Off
  838. // increment the number of pvp players on the map
  839. map[sd->bl.m].users_pvp++;
  840. if( !battle_config.pk_mode && map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.pvp_nocalcrank )
  841. {// register the player for ranking calculations
  842. sd->pvp_timer = add_timer( gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0 );
  843. }
  844. //bugreport:2266
  845. map_foreachinmovearea(clif_insight, &sd->bl, AREA_SIZE, sd->bl.x, sd->bl.y, BL_ALL, &sd->bl);
  846. } else {
  847. sd->sc.option |= OPTION_INVISIBLE;
  848. sd->vd.class_ = INVISIBLE_CLASS;
  849. clif_displaymessage(fd, msg_txt(sd,11)); // Invisible: On
  850. // decrement the number of pvp players on the map
  851. map[sd->bl.m].users_pvp--;
  852. if( map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.pvp_nocalcrank && sd->pvp_timer != INVALID_TIMER )
  853. {// unregister the player for ranking
  854. delete_timer( sd->pvp_timer, pc_calc_pvprank_timer );
  855. sd->pvp_timer = INVALID_TIMER;
  856. }
  857. }
  858. clif_changeoption(&sd->bl);
  859. return 0;
  860. }
  861. /*==========================================
  862. * Changes a character's class
  863. *------------------------------------------*/
  864. ACMD_FUNC(jobchange)
  865. {
  866. int job = 0, upper = 0;
  867. const char* text;
  868. nullpo_retr(-1, sd);
  869. if (!message || !*message || sscanf(message, "%11d %11d", &job, &upper) < 1) {
  870. int i;
  871. bool found = false;
  872. upper = 0;
  873. // Normal Jobs
  874. for( i = JOB_NOVICE; i < JOB_MAX_BASIC && !found; i++ ) {
  875. if (strncmpi(message, job_name(i), 16) == 0) {
  876. job = i;
  877. found = true;
  878. }
  879. }
  880. // High Jobs, Babys and Third
  881. for( i = JOB_NOVICE_HIGH; i < JOB_MAX && !found; i++ ) {
  882. if (strncmpi(message, job_name(i), 16) == 0) {
  883. job = i;
  884. found = true;
  885. }
  886. }
  887. if (!found) {
  888. text = atcommand_help_string(command);
  889. if (text)
  890. clif_displaymessage(fd, text);
  891. return -1;
  892. }
  893. }
  894. if (job == JOB_KNIGHT2 || job == JOB_CRUSADER2 || job == JOB_WEDDING || job == JOB_XMAS || job == JOB_SUMMER || job == JOB_HANBOK || job == JOB_OKTOBERFEST
  895. || job == JOB_LORD_KNIGHT2 || job == JOB_PALADIN2 || job == JOB_BABY_KNIGHT2 || job == JOB_BABY_CRUSADER2 || job == JOB_STAR_GLADIATOR2
  896. || (job >= JOB_RUNE_KNIGHT2 && job <= JOB_MECHANIC_T2) || (job >= JOB_BABY_RUNE2 && job <= JOB_BABY_MECHANIC2))
  897. { // Deny direct transformation into dummy jobs
  898. clif_displaymessage(fd, msg_txt(sd,923)); //"You can not change to this job by command."
  899. return 0;
  900. }
  901. if (pcdb_checkid(job))
  902. {
  903. if (pc_jobchange(sd, job, upper))
  904. clif_displaymessage(fd, msg_txt(sd,12)); // Your job has been changed.
  905. else {
  906. clif_displaymessage(fd, msg_txt(sd,155)); // You are unable to change your job.
  907. return -1;
  908. }
  909. } else {
  910. text = atcommand_help_string(command);
  911. if (text)
  912. clif_displaymessage(fd, text);
  913. return -1;
  914. }
  915. return 0;
  916. }
  917. /*==========================================
  918. *
  919. *------------------------------------------*/
  920. ACMD_FUNC(kill)
  921. {
  922. nullpo_retr(-1, sd);
  923. status_kill(&sd->bl);
  924. clif_displaymessage(sd->fd, msg_txt(sd,13)); // A pity! You've died.
  925. if (fd != sd->fd)
  926. clif_displaymessage(fd, msg_txt(sd,14)); // Character killed.
  927. return 0;
  928. }
  929. /*==========================================
  930. *
  931. *------------------------------------------*/
  932. ACMD_FUNC(alive)
  933. {
  934. nullpo_retr(-1, sd);
  935. if (!status_revive(&sd->bl, 100, 100))
  936. {
  937. clif_displaymessage(fd, msg_txt(sd,667));
  938. return -1;
  939. }
  940. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  941. clif_displaymessage(fd, msg_txt(sd,16)); // You've been revived! It's a miracle!
  942. return 0;
  943. }
  944. /*==========================================
  945. * +kamic [LuzZza]
  946. *------------------------------------------*/
  947. ACMD_FUNC(kami)
  948. {
  949. unsigned long color=0;
  950. nullpo_retr(-1, sd);
  951. memset(atcmd_output, '\0', sizeof(atcmd_output));
  952. if(*(command + 5) != 'c' && *(command + 5) != 'C') {
  953. if (!message || !*message) {
  954. clif_displaymessage(fd, msg_txt(sd,980)); // Please enter a message (usage: @kami <message>).
  955. return -1;
  956. }
  957. sscanf(message, "%255[^\n]", atcmd_output);
  958. if (strstr(command, "l") != NULL)
  959. clif_broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT, ALL_SAMEMAP);
  960. else
  961. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, (*(command + 5) == 'b' || *(command + 5) == 'B') ? BC_BLUE : BC_DEFAULT);
  962. } else {
  963. if(!message || !*message || (sscanf(message, "%20lx %199[^\n]", &color, atcmd_output) < 2)) {
  964. clif_displaymessage(fd, msg_txt(sd,981)); // Please enter color and message (usage: @kamic <color> <message>).
  965. return -1;
  966. }
  967. if(color > 0xFFFFFF) {
  968. clif_displaymessage(fd, msg_txt(sd,982)); // Invalid color.
  969. return -1;
  970. }
  971. intif_broadcast2(atcmd_output, strlen(atcmd_output) + 1, color, 0x190, 12, 0, 0);
  972. }
  973. return 0;
  974. }
  975. /*==========================================
  976. *
  977. *------------------------------------------*/
  978. ACMD_FUNC(heal)
  979. {
  980. int hp = 0, sp = 0; // [Valaris] thanks to fov
  981. nullpo_retr(-1, sd);
  982. sscanf(message, "%11d %11d", &hp, &sp);
  983. // some overflow checks
  984. if( hp == INT_MIN ) hp++;
  985. if( sp == INT_MIN ) sp++;
  986. if ( hp == 0 && sp == 0 ) {
  987. if (!status_percent_heal(&sd->bl, 100, 100))
  988. clif_displaymessage(fd, msg_txt(sd,157)); // HP and SP have already been recovered.
  989. else
  990. clif_displaymessage(fd, msg_txt(sd,17)); // HP, SP recovered.
  991. return 0;
  992. }
  993. if ( hp > 0 && sp >= 0 ) {
  994. if(!status_heal(&sd->bl, hp, sp, 0))
  995. clif_displaymessage(fd, msg_txt(sd,157)); // HP and SP are already with the good value.
  996. else
  997. clif_displaymessage(fd, msg_txt(sd,17)); // HP, SP recovered.
  998. return 0;
  999. }
  1000. if ( hp < 0 && sp <= 0 ) {
  1001. status_damage(NULL, &sd->bl, -hp, -sp, 0, 0);
  1002. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, DMG_ENDURE, 0, false);
  1003. clif_displaymessage(fd, msg_txt(sd,156)); // HP or/and SP modified.
  1004. return 0;
  1005. }
  1006. //Opposing signs.
  1007. if ( hp ) {
  1008. if (hp > 0)
  1009. status_heal(&sd->bl, hp, 0, 0);
  1010. else {
  1011. status_damage(NULL, &sd->bl, -hp, 0, 0, 0);
  1012. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, DMG_ENDURE, 0, false);
  1013. }
  1014. }
  1015. if ( sp ) {
  1016. if (sp > 0)
  1017. status_heal(&sd->bl, 0, sp, 0);
  1018. else
  1019. status_damage(NULL, &sd->bl, 0, -sp, 0, 0);
  1020. }
  1021. clif_displaymessage(fd, msg_txt(sd,156)); // HP or/and SP modified.
  1022. return 0;
  1023. }
  1024. /*==========================================
  1025. * @item command (usage: @item <itemdid1:itemid2:itemname:..> <quantity>) (modified by [Yor] for pet_egg)
  1026. * @itembound command (usage: @itembound <name/id_of_item> <quantity> <bound_type>)
  1027. *------------------------------------------*/
  1028. ACMD_FUNC(item)
  1029. {
  1030. char item_name[100];
  1031. int number = 0, bound = BOUND_NONE;
  1032. char flag = 0;
  1033. struct item item_tmp;
  1034. struct item_data *item_data[10];
  1035. int get_count, i, j=0;
  1036. char *itemlist;
  1037. nullpo_retr(-1, sd);
  1038. memset(item_name, '\0', sizeof(item_name));
  1039. parent_cmd = atcommand_checkalias(command+1);
  1040. if (!strcmpi(parent_cmd,"itembound")) {
  1041. if (!message || !*message || (
  1042. sscanf(message, "\"%99[^\"]\" %11d %11d", item_name, &number, &bound) < 3 &&
  1043. sscanf(message, "%99s %11d %11d", item_name, &number, &bound) < 3))
  1044. {
  1045. clif_displaymessage(fd, msg_txt(sd,295)); // Please enter an item name or ID (usage: @item <item name/ID> <quantity> <bound_type>).
  1046. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1047. return -1;
  1048. }
  1049. if( bound <= BOUND_NONE || bound >= BOUND_MAX ) {
  1050. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1051. return -1;
  1052. }
  1053. } else if (!message || !*message || (
  1054. sscanf(message, "\"%99[^\"]\" %11d", item_name, &number) < 1 &&
  1055. sscanf(message, "%99s %11d", item_name, &number) < 1
  1056. )) {
  1057. clif_displaymessage(fd, msg_txt(sd,983)); // Please enter an item name or ID (usage: @item <item name/ID> <quantity>).
  1058. return -1;
  1059. }
  1060. itemlist = strtok(item_name, ":");
  1061. while (itemlist != NULL && j<10) {
  1062. if ((item_data[j] = itemdb_searchname(itemlist)) == NULL &&
  1063. (item_data[j] = itemdb_exists(atoi(itemlist))) == NULL){
  1064. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  1065. return -1;
  1066. }
  1067. itemlist = strtok(NULL, ":"); //next itemline
  1068. j++;
  1069. }
  1070. if (number <= 0)
  1071. number = 1;
  1072. get_count = number;
  1073. for(j--; j>=0; j--){ //produce items in list
  1074. unsigned short item_id = item_data[j]->nameid;
  1075. //Check if it's stackable.
  1076. if (!itemdb_isstackable2(item_data[j]))
  1077. get_count = 1;
  1078. for (i = 0; i < number; i += get_count) {
  1079. // if not pet egg
  1080. if (!pet_create_egg(sd, item_id)) {
  1081. memset(&item_tmp, 0, sizeof(item_tmp));
  1082. item_tmp.nameid = item_id;
  1083. item_tmp.identify = 1;
  1084. item_tmp.bound = bound;
  1085. if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
  1086. clif_additem(sd, 0, 0, flag);
  1087. }
  1088. }
  1089. }
  1090. if (flag == 0)
  1091. clif_displaymessage(fd, msg_txt(sd,18)); // Item created.
  1092. return 0;
  1093. }
  1094. /*==========================================
  1095. *
  1096. *------------------------------------------*/
  1097. ACMD_FUNC(item2)
  1098. {
  1099. struct item item_tmp;
  1100. struct item_data *item_data;
  1101. char item_name[100];
  1102. unsigned short item_id;
  1103. int number = 0, bound = BOUND_NONE;
  1104. int identify = 0, refine = 0, attr = 0;
  1105. int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  1106. nullpo_retr(-1, sd);
  1107. memset(item_name, '\0', sizeof(item_name));
  1108. parent_cmd = atcommand_checkalias(command+1);
  1109. if (!strcmpi(parent_cmd+1,"itembound2")) {
  1110. if (!message || !*message || (
  1111. sscanf(message, "\"%99[^\"]\" %11d %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4, &bound) < 10 &&
  1112. sscanf(message, "%99s %11d %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4, &bound) < 10 ))
  1113. {
  1114. clif_displaymessage(fd, msg_txt(sd,296)); // Please enter all parameters (usage: @item2 <item name/ID> <quantity>
  1115. clif_displaymessage(fd, msg_txt(sd,297)); // <identify_flag> <refine> <attribute> <card1> <card2> <card3> <card4> <bound_type>).
  1116. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1117. return -1;
  1118. }
  1119. if( bound <= BOUND_NONE || bound >= BOUND_MAX ) {
  1120. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1121. return -1;
  1122. }
  1123. } else if ( !message || !*message || (
  1124. sscanf(message, "\"%99[^\"]\" %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9 &&
  1125. sscanf(message, "%99s %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9
  1126. )) {
  1127. clif_displaymessage(fd, msg_txt(sd,984)); // Please enter all parameters (usage: @item2 <item name/ID> <quantity>
  1128. clif_displaymessage(fd, msg_txt(sd,985)); // <identify_flag> <refine> <attribute> <card1> <card2> <card3> <card4>).
  1129. return -1;
  1130. }
  1131. if (number <= 0)
  1132. number = 1;
  1133. item_id = 0;
  1134. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  1135. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  1136. item_id = item_data->nameid;
  1137. if (item_id > 500) {
  1138. int loop, get_count, i;
  1139. char flag = 0;
  1140. //Check if it's stackable.
  1141. if(!itemdb_isstackable2(item_data)){
  1142. loop = number;
  1143. get_count = 1;
  1144. }else{
  1145. loop = 1;
  1146. get_count = number;
  1147. }
  1148. if( itemdb_isequip2(item_data ) ){
  1149. refine = cap_value( refine, 0, MAX_REFINE );
  1150. }else{
  1151. // All other items cannot be refined and are always identified
  1152. identify = 1;
  1153. refine = attr = 0;
  1154. }
  1155. for (i = 0; i < loop; i++) {
  1156. // if not pet egg
  1157. if (!pet_create_egg(sd, item_id)) {
  1158. memset(&item_tmp, 0, sizeof(item_tmp));
  1159. item_tmp.nameid = item_id;
  1160. item_tmp.identify = identify;
  1161. item_tmp.refine = refine;
  1162. item_tmp.attribute = attr;
  1163. item_tmp.card[0] = c1;
  1164. item_tmp.card[1] = c2;
  1165. item_tmp.card[2] = c3;
  1166. item_tmp.card[3] = c4;
  1167. item_tmp.bound = bound;
  1168. if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
  1169. clif_additem(sd, 0, 0, flag);
  1170. }
  1171. }
  1172. if (flag == 0)
  1173. clif_displaymessage(fd, msg_txt(sd,18)); // Item created.
  1174. } else {
  1175. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  1176. return -1;
  1177. }
  1178. return 0;
  1179. }
  1180. /*==========================================
  1181. *
  1182. *------------------------------------------*/
  1183. ACMD_FUNC(itemreset)
  1184. {
  1185. int i;
  1186. nullpo_retr(-1, sd);
  1187. for (i = 0; i < MAX_INVENTORY; i++) {
  1188. if (sd->inventory.u.items_inventory[i].amount && sd->inventory.u.items_inventory[i].equip == 0) {
  1189. pc_delitem(sd, i, sd->inventory.u.items_inventory[i].amount, 0, 0, LOG_TYPE_COMMAND);
  1190. }
  1191. }
  1192. clif_displaymessage(fd, msg_txt(sd,20)); // All of your items have been removed.
  1193. return 0;
  1194. }
  1195. /*==========================================
  1196. * Atcommand @lvlup
  1197. *------------------------------------------*/
  1198. ACMD_FUNC(baselevelup)
  1199. {
  1200. int level=0, i=0, status_point=0;
  1201. nullpo_retr(-1, sd);
  1202. level = atoi(message);
  1203. if (!message || !*message || !level) {
  1204. clif_displaymessage(fd, msg_txt(sd,986)); // Please enter a level adjustment (usage: @lvup/@blevel/@baselvlup <number of levels>).
  1205. return -1;
  1206. }
  1207. if (level > 0) {
  1208. if (sd->status.base_level >= pc_maxbaselv(sd)) { // check for max level by Valaris
  1209. clif_displaymessage(fd, msg_txt(sd,47)); // Base level can't go any higher.
  1210. return -1;
  1211. } // End Addition
  1212. if ((unsigned int)level > pc_maxbaselv(sd) || (unsigned int)level > pc_maxbaselv(sd) - sd->status.base_level) // fix positive overflow
  1213. level = pc_maxbaselv(sd) - sd->status.base_level;
  1214. for (i = 0; i < level; i++)
  1215. status_point += pc_gets_status_point(sd->status.base_level + i);
  1216. sd->status.status_point += status_point;
  1217. sd->status.base_level += (unsigned int)level;
  1218. status_calc_pc(sd, SCO_FORCE);
  1219. status_percent_heal(&sd->bl, 100, 100);
  1220. clif_misceffect(&sd->bl, 0);
  1221. clif_displaymessage(fd, msg_txt(sd,21)); // Base level raised.
  1222. } else {
  1223. if (sd->status.base_level == 1) {
  1224. clif_displaymessage(fd, msg_txt(sd,158)); // Base level can't go any lower.
  1225. return -1;
  1226. }
  1227. level*=-1;
  1228. if ((unsigned int)level >= sd->status.base_level)
  1229. level = sd->status.base_level-1;
  1230. for (i = 0; i > -level; i--)
  1231. status_point += pc_gets_status_point(sd->status.base_level + i - 1);
  1232. if (sd->status.status_point < status_point)
  1233. pc_resetstate(sd);
  1234. if (sd->status.status_point < status_point)
  1235. sd->status.status_point = 0;
  1236. else
  1237. sd->status.status_point -= status_point;
  1238. sd->status.base_level -= (unsigned int)level;
  1239. clif_displaymessage(fd, msg_txt(sd,22)); // Base level lowered.
  1240. status_calc_pc(sd, SCO_FORCE);
  1241. level*=-1;
  1242. }
  1243. sd->status.base_exp = 0;
  1244. clif_updatestatus(sd, SP_STATUSPOINT);
  1245. clif_updatestatus(sd, SP_BASELEVEL);
  1246. clif_updatestatus(sd, SP_BASEEXP);
  1247. clif_updatestatus(sd, SP_NEXTBASEEXP);
  1248. pc_baselevelchanged(sd);
  1249. if(sd->status.party_id)
  1250. party_send_levelup(sd);
  1251. if( level > 0 && battle_config.atcommand_levelup_events )
  1252. npc_script_event(sd,NPCE_BASELVUP);
  1253. return 0;
  1254. }
  1255. /*==========================================
  1256. *
  1257. *------------------------------------------*/
  1258. ACMD_FUNC(joblevelup)
  1259. {
  1260. int level=0;
  1261. nullpo_retr(-1, sd);
  1262. level = atoi(message);
  1263. if (!message || !*message || !level) {
  1264. clif_displaymessage(fd, msg_txt(sd,987)); // Please enter a level adjustment (usage: @joblvup/@jlevel/@joblvlup <number of levels>).
  1265. return -1;
  1266. }
  1267. if (level > 0) {
  1268. if (sd->status.job_level >= pc_maxjoblv(sd)) {
  1269. clif_displaymessage(fd, msg_txt(sd,23)); // Job level can't go any higher.
  1270. return -1;
  1271. }
  1272. if ((unsigned int)level > pc_maxjoblv(sd) || (unsigned int)level > pc_maxjoblv(sd) - sd->status.job_level) // fix positive overflow
  1273. level = pc_maxjoblv(sd) - sd->status.job_level;
  1274. sd->status.job_level += (unsigned int)level;
  1275. sd->status.skill_point += level;
  1276. clif_misceffect(&sd->bl, 1);
  1277. clif_displaymessage(fd, msg_txt(sd,24)); // Job level raised.
  1278. } else {
  1279. if (sd->status.job_level == 1) {
  1280. clif_displaymessage(fd, msg_txt(sd,159)); // Job level can't go any lower.
  1281. return -1;
  1282. }
  1283. level *=-1;
  1284. if ((unsigned int)level >= sd->status.job_level) // fix negative overflow
  1285. level = sd->status.job_level-1;
  1286. sd->status.job_level -= (unsigned int)level;
  1287. if (sd->status.skill_point < level)
  1288. pc_resetskill(sd,0); //Reset skills since we need to subtract more points.
  1289. if (sd->status.skill_point < level)
  1290. sd->status.skill_point = 0;
  1291. else
  1292. sd->status.skill_point -= level;
  1293. clif_displaymessage(fd, msg_txt(sd,25)); // Job level lowered.
  1294. level *=-1;
  1295. }
  1296. sd->status.job_exp = 0;
  1297. clif_updatestatus(sd, SP_JOBLEVEL);
  1298. clif_updatestatus(sd, SP_JOBEXP);
  1299. clif_updatestatus(sd, SP_NEXTJOBEXP);
  1300. clif_updatestatus(sd, SP_SKILLPOINT);
  1301. status_calc_pc(sd, SCO_FORCE);
  1302. if( level > 0 && battle_config.atcommand_levelup_events )
  1303. npc_script_event(sd,NPCE_JOBLVUP);
  1304. return 0;
  1305. }
  1306. /*==========================================
  1307. * @help
  1308. *------------------------------------------*/
  1309. ACMD_FUNC(help)
  1310. {
  1311. config_setting_t *help;
  1312. const char *text = NULL;
  1313. const char *command_name = NULL;
  1314. char *default_command = "help";
  1315. nullpo_retr(-1, sd);
  1316. help = config_lookup(&atcommand_config, "help");
  1317. if (help == NULL) {
  1318. clif_displaymessage(fd, msg_txt(sd,27)); // "Commands help is not available."
  1319. return -1;
  1320. }
  1321. if (!message || !*message) {
  1322. command_name = default_command; // If no command_name specified, display help for @help.
  1323. } else {
  1324. if (*message == atcommand_symbol || *message == charcommand_symbol)
  1325. ++message;
  1326. command_name = atcommand_checkalias(message);
  1327. }
  1328. if (!pc_can_use_command(sd, command_name, COMMAND_ATCOMMAND)) {
  1329. sprintf(atcmd_output, msg_txt(sd,153), message); // "%s is Unknown Command"
  1330. clif_displaymessage(fd, atcmd_output);
  1331. atcommand_get_suggestions(sd, command_name, true);
  1332. return -1;
  1333. }
  1334. if (!config_setting_lookup_string(help, command_name, &text)) {
  1335. sprintf(atcmd_output, msg_txt(sd,988), atcommand_symbol, command_name); // There is no help for %c%s.
  1336. clif_displaymessage(fd, atcmd_output);
  1337. atcommand_get_suggestions(sd, command_name, true);
  1338. return -1;
  1339. }
  1340. sprintf(atcmd_output, msg_txt(sd,989), atcommand_symbol, command_name); // Help for command %c%s:
  1341. clif_displaymessage(fd, atcmd_output);
  1342. { // Display aliases
  1343. DBIterator* iter;
  1344. AtCommandInfo *command_info;
  1345. AliasInfo *alias_info = NULL;
  1346. StringBuf buf;
  1347. bool has_aliases = false;
  1348. StringBuf_Init(&buf);
  1349. StringBuf_AppendStr(&buf, msg_txt(sd,990)); // Available aliases:
  1350. command_info = get_atcommandinfo_byname(command_name);
  1351. iter = db_iterator(atcommand_alias_db);
  1352. for (alias_info = (AliasInfo *)dbi_first(iter); dbi_exists(iter); alias_info = (AliasInfo *)dbi_next(iter)) {
  1353. if (alias_info->command == command_info) {
  1354. StringBuf_Printf(&buf, " %s", alias_info->alias);
  1355. has_aliases = true;
  1356. }
  1357. }
  1358. dbi_destroy(iter);
  1359. if (has_aliases)
  1360. clif_displaymessage(fd, StringBuf_Value(&buf));
  1361. StringBuf_Destroy(&buf);
  1362. }
  1363. // Display help contents
  1364. clif_displaymessage(fd, text);
  1365. return 0;
  1366. }
  1367. // helper function, used in foreach calls to stop auto-attack timers
  1368. // parameter: '0' - everyone, 'id' - only those attacking someone with that id
  1369. static int atcommand_stopattack(struct block_list *bl,va_list ap)
  1370. {
  1371. struct unit_data *ud = unit_bl2ud(bl);
  1372. int id = va_arg(ap, int);
  1373. if (ud && ud->attacktimer != INVALID_TIMER && (!id || id == ud->target))
  1374. {
  1375. unit_stop_attack(bl);
  1376. return 1;
  1377. }
  1378. return 0;
  1379. }
  1380. /*==========================================
  1381. *
  1382. *------------------------------------------*/
  1383. static int atcommand_pvpoff_sub(struct block_list *bl,va_list ap)
  1384. {
  1385. TBL_PC* sd = (TBL_PC*)bl;
  1386. clif_pvpset(sd, 0, 0, 2);
  1387. if (sd->pvp_timer != INVALID_TIMER) {
  1388. delete_timer(sd->pvp_timer, pc_calc_pvprank_timer);
  1389. sd->pvp_timer = INVALID_TIMER;
  1390. }
  1391. return 0;
  1392. }
  1393. ACMD_FUNC(pvpoff)
  1394. {
  1395. nullpo_retr(-1, sd);
  1396. if (!map[sd->bl.m].flag.pvp) {
  1397. clif_displaymessage(fd, msg_txt(sd,160)); // PvP is already Off.
  1398. return -1;
  1399. }
  1400. map[sd->bl.m].flag.pvp = 0;
  1401. if (!battle_config.pk_mode){
  1402. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING);
  1403. }
  1404. map_foreachinmap(atcommand_pvpoff_sub,sd->bl.m, BL_PC);
  1405. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  1406. clif_displaymessage(fd, msg_txt(sd,31)); // PvP: Off.
  1407. return 0;
  1408. }
  1409. /*==========================================
  1410. *
  1411. *------------------------------------------*/
  1412. static int atcommand_pvpon_sub(struct block_list *bl,va_list ap)
  1413. {
  1414. TBL_PC* sd = (TBL_PC*)bl;
  1415. if (sd->pvp_timer == INVALID_TIMER) {
  1416. sd->pvp_timer = add_timer(gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0);
  1417. sd->pvp_rank = 0;
  1418. sd->pvp_lastusers = 0;
  1419. sd->pvp_point = 5;
  1420. sd->pvp_won = 0;
  1421. sd->pvp_lost = 0;
  1422. }
  1423. return 0;
  1424. }
  1425. ACMD_FUNC(pvpon)
  1426. {
  1427. nullpo_retr(-1, sd);
  1428. if (map[sd->bl.m].flag.pvp) {
  1429. clif_displaymessage(fd, msg_txt(sd,161)); // PvP is already On.
  1430. return -1;
  1431. }
  1432. map[sd->bl.m].flag.pvp = 1;
  1433. if (!battle_config.pk_mode) {// display pvp circle and rank
  1434. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_FREEPVPZONE);
  1435. map_foreachinmap(atcommand_pvpon_sub,sd->bl.m, BL_PC);
  1436. }
  1437. clif_displaymessage(fd, msg_txt(sd,32)); // PvP: On.
  1438. return 0;
  1439. }
  1440. /*==========================================
  1441. *
  1442. *------------------------------------------*/
  1443. ACMD_FUNC(gvgoff)
  1444. {
  1445. nullpo_retr(-1, sd);
  1446. if (!map[sd->bl.m].flag.gvg) {
  1447. clif_displaymessage(fd, msg_txt(sd,162)); // GvG is already Off.
  1448. return -1;
  1449. }
  1450. map[sd->bl.m].flag.gvg = 0;
  1451. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING);
  1452. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  1453. clif_displaymessage(fd, msg_txt(sd,33)); // GvG: Off.
  1454. return 0;
  1455. }
  1456. /*==========================================
  1457. *
  1458. *------------------------------------------*/
  1459. ACMD_FUNC(gvgon)
  1460. {
  1461. nullpo_retr(-1, sd);
  1462. if (map[sd->bl.m].flag.gvg) {
  1463. clif_displaymessage(fd, msg_txt(sd,163)); // GvG is already On.
  1464. return -1;
  1465. }
  1466. map[sd->bl.m].flag.gvg = 1;
  1467. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_AGITZONE);
  1468. clif_displaymessage(fd, msg_txt(sd,34)); // GvG: On.
  1469. return 0;
  1470. }
  1471. /*==========================================
  1472. *
  1473. *------------------------------------------*/
  1474. ACMD_FUNC(model)
  1475. {
  1476. int hair_style = 0, hair_color = 0, cloth_color = 0;
  1477. nullpo_retr(-1, sd);
  1478. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1479. if (!message || !*message || sscanf(message, "%11d %11d %11d", &hair_style, &hair_color, &cloth_color) < 1) {
  1480. sprintf(atcmd_output, msg_txt(sd,991), // Please enter at least one value (usage: @model <hair ID: %d-%d> <hair color: %d-%d> <clothes color: %d-%d>).
  1481. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  1482. clif_displaymessage(fd, atcmd_output);
  1483. return -1;
  1484. }
  1485. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  1486. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  1487. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1488. pc_changelook(sd, LOOK_HAIR, hair_style);
  1489. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1490. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1491. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1492. } else {
  1493. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1494. return -1;
  1495. }
  1496. return 0;
  1497. }
  1498. /*==========================================
  1499. * @bodystyle [Rytech]
  1500. *------------------------------------------*/
  1501. ACMD_FUNC(bodystyle)
  1502. {
  1503. int body_style = 0;
  1504. nullpo_retr(-1, sd);
  1505. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1506. // Limit body styles to certain jobs since not all of them are released yet.
  1507. if (!((sd->class_&MAPID_THIRDMASK) == MAPID_GUILLOTINE_CROSS || (sd->class_&MAPID_THIRDMASK) == MAPID_GENETIC
  1508. || (sd->class_&MAPID_THIRDMASK) == MAPID_MECHANIC || (sd->class_&MAPID_THIRDMASK) == MAPID_ROYAL_GUARD
  1509. || (sd->class_&MAPID_THIRDMASK) == MAPID_ARCH_BISHOP || (sd->class_&MAPID_THIRDMASK) == MAPID_RANGER
  1510. || (sd->class_&MAPID_THIRDMASK) == MAPID_WARLOCK)) {
  1511. clif_displaymessage(fd, msg_txt(sd,740)); // This job has no alternate body styles.
  1512. return -1;
  1513. }
  1514. if (!message || !*message || sscanf(message, "%d", &body_style) < 1) {
  1515. sprintf(atcmd_output, msg_txt(sd,739), MIN_BODY_STYLE, MAX_BODY_STYLE); // Please enter a body style (usage: @bodystyle <body ID: %d-%d>).
  1516. clif_displaymessage(fd, atcmd_output);
  1517. return -1;
  1518. }
  1519. if (body_style >= MIN_BODY_STYLE && body_style <= MAX_BODY_STYLE) {
  1520. pc_changelook(sd, LOOK_BODY2, body_style);
  1521. clif_displaymessage(fd, msg_txt(sd,36)); // Appearence changed.
  1522. } else {
  1523. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1524. return -1;
  1525. }
  1526. return 0;
  1527. }
  1528. /*==========================================
  1529. * @dye && @ccolor
  1530. *------------------------------------------*/
  1531. ACMD_FUNC(dye)
  1532. {
  1533. int cloth_color = 0;
  1534. nullpo_retr(-1, sd);
  1535. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1536. if (!message || !*message || sscanf(message, "%11d", &cloth_color) < 1) {
  1537. sprintf(atcmd_output, msg_txt(sd,992), MIN_CLOTH_COLOR, MAX_CLOTH_COLOR); // Please enter a clothes color (usage: @dye/@ccolor <clothes color: %d-%d>).
  1538. clif_displaymessage(fd, atcmd_output);
  1539. return -1;
  1540. }
  1541. if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1542. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1543. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1544. } else {
  1545. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1546. return -1;
  1547. }
  1548. return 0;
  1549. }
  1550. /*==========================================
  1551. * @hairstyle && @hstyle
  1552. *------------------------------------------*/
  1553. ACMD_FUNC(hair_style)
  1554. {
  1555. int hair_style = 0;
  1556. nullpo_retr(-1, sd);
  1557. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1558. if (!message || !*message || sscanf(message, "%11d", &hair_style) < 1) {
  1559. sprintf(atcmd_output, msg_txt(sd,993), MIN_HAIR_STYLE, MAX_HAIR_STYLE); // Please enter a hair style (usage: @hairstyle/@hstyle <hair ID: %d-%d>).
  1560. clif_displaymessage(fd, atcmd_output);
  1561. return -1;
  1562. }
  1563. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
  1564. pc_changelook(sd, LOOK_HAIR, hair_style);
  1565. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1566. } else {
  1567. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1568. return -1;
  1569. }
  1570. return 0;
  1571. }
  1572. /*==========================================
  1573. * @haircolor && @hcolor
  1574. *------------------------------------------*/
  1575. ACMD_FUNC(hair_color)
  1576. {
  1577. int hair_color = 0;
  1578. nullpo_retr(-1, sd);
  1579. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1580. if (!message || !*message || sscanf(message, "%11d", &hair_color) < 1) {
  1581. sprintf(atcmd_output, msg_txt(sd,994), MIN_HAIR_COLOR, MAX_HAIR_COLOR); // Please enter a hair color (usage: @haircolor/@hcolor <hair color: %d-%d>).
  1582. clif_displaymessage(fd, atcmd_output);
  1583. return -1;
  1584. }
  1585. if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
  1586. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1587. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1588. } else {
  1589. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1590. return -1;
  1591. }
  1592. return 0;
  1593. }
  1594. /*==========================================
  1595. * @go [city_number or city_name] - Updated by Harbin
  1596. *------------------------------------------*/
  1597. ACMD_FUNC(go)
  1598. {
  1599. int i;
  1600. int town;
  1601. char map_name[MAP_NAME_LENGTH];
  1602. const struct {
  1603. char map[MAP_NAME_LENGTH];
  1604. int x, y;
  1605. } data[] = {
  1606. { MAP_PRONTERA, 156, 191 }, // 0=Prontera
  1607. { MAP_MORROC, 156, 93 }, // 1=Morroc
  1608. { MAP_GEFFEN, 119, 59 }, // 2=Geffen
  1609. { MAP_PAYON, 162, 233 }, // 3=Payon
  1610. { MAP_ALBERTA, 192, 147 }, // 4=Alberta
  1611. #ifdef RENEWAL
  1612. { MAP_IZLUDE, 128, 146 }, // 5=Izlude (Renewal)
  1613. #else
  1614. { MAP_IZLUDE, 128, 114 }, // 5=Izlude
  1615. #endif
  1616. { MAP_ALDEBARAN, 140, 131 }, // 6=Al de Baran
  1617. { MAP_LUTIE, 147, 134 }, // 7=Lutie
  1618. { MAP_COMODO, 209, 143 }, // 8=Comodo
  1619. { MAP_YUNO, 157, 51 }, // 9=Yuno
  1620. { MAP_AMATSU, 198, 84 }, // 10=Amatsu
  1621. { MAP_GONRYUN, 160, 120 }, // 11=Gonryun
  1622. { MAP_UMBALA, 89, 157 }, // 12=Umbala
  1623. { MAP_NIFLHEIM, 21, 153 }, // 13=Niflheim
  1624. { MAP_LOUYANG, 217, 40 }, // 14=Louyang
  1625. #ifdef RENEWAL
  1626. { MAP_NOVICE, 97, 90 }, // 15=Training Grounds (Renewal)
  1627. #else
  1628. { MAP_NOVICE, 53, 111 }, // 15=Training Grounds
  1629. #endif
  1630. { MAP_JAIL, 23, 61 }, // 16=Prison
  1631. { MAP_JAWAII, 249, 127 }, // 17=Jawaii
  1632. { MAP_AYOTHAYA, 151, 117 }, // 18=Ayothaya
  1633. { MAP_EINBROCH, 64, 200 }, // 19=Einbroch
  1634. { MAP_LIGHTHALZEN, 158, 92 }, // 20=Lighthalzen
  1635. { MAP_EINBECH, 70, 95 }, // 21=Einbech
  1636. { MAP_HUGEL, 96, 145 }, // 22=Hugel
  1637. { MAP_RACHEL, 130, 110 }, // 23=Rachel
  1638. { MAP_VEINS, 216, 123 }, // 24=Veins
  1639. { MAP_MOSCOVIA, 223, 184 }, // 25=Moscovia
  1640. { MAP_MIDCAMP, 180, 240 }, // 26=Midgard Camp
  1641. { MAP_MANUK, 282, 138 }, // 27=Manuk
  1642. { MAP_SPLENDIDE, 201, 147 }, // 28=Splendide
  1643. { MAP_BRASILIS, 182, 239 }, // 29=Brasilis
  1644. { MAP_DICASTES, 198, 187 }, // 30=El Dicastes
  1645. { MAP_MORA, 44, 151 }, // 31=Mora
  1646. { MAP_DEWATA, 200, 180 }, // 32=Dewata
  1647. { MAP_MALANGDO, 140, 114 }, // 33=Malangdo Island
  1648. { MAP_MALAYA, 242, 211 }, // 34=Malaya Port
  1649. { MAP_ECLAGE, 110, 39 }, // 35=Eclage
  1650. };
  1651. nullpo_retr(-1, sd);
  1652. if( map[sd->bl.m].flag.nogo && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE) ) {
  1653. clif_displaymessage(sd->fd,msg_txt(sd,995)); // You cannot use @go on this map.
  1654. return 0;
  1655. }
  1656. memset(map_name, '\0', sizeof(map_name));
  1657. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1658. // get the number
  1659. town = atoi(message);
  1660. if (!message || !*message || sscanf(message, "%11s", map_name) < 1 || town < 0 || town >= ARRAYLENGTH(data))
  1661. {// no value matched so send the list of locations
  1662. const char* text;
  1663. // attempt to find the text help string
  1664. text = atcommand_help_string( command );
  1665. clif_displaymessage(fd, msg_txt(sd,38)); // Invalid location number, or name.
  1666. if( text )
  1667. {// send the text to the client
  1668. clif_displaymessage( fd, text );
  1669. }
  1670. return -1;
  1671. }
  1672. // get possible name of the city
  1673. map_name[MAP_NAME_LENGTH-1] = '\0';
  1674. for (i = 0; map_name[i]; i++)
  1675. map_name[i] = TOLOWER(map_name[i]);
  1676. // try to identify the map name
  1677. if (strncmp(map_name, "prontera", 3) == 0) {
  1678. town = 0;
  1679. } else if (strncmp(map_name, "morocc", 4) == 0 ||
  1680. strncmp(map_name, "morroc", 4) == 0) {
  1681. town = 1;
  1682. } else if (strncmp(map_name, "geffen", 3) == 0) {
  1683. town = 2;
  1684. } else if (strncmp(map_name, "payon", 3) == 0) {
  1685. town = 3;
  1686. } else if (strncmp(map_name, "alberta", 3) == 0) {
  1687. town = 4;
  1688. } else if (strncmp(map_name, "izlude", 3) == 0) {
  1689. town = 5;
  1690. } else if (strncmp(map_name, "aldebaran", 3) == 0) {
  1691. town = 6;
  1692. } else if (strncmp(map_name, "lutie", 3) == 0 ||
  1693. strcmp(map_name, "christmas") == 0 ||
  1694. strncmp(map_name, "xmas", 3) == 0 ||
  1695. strncmp(map_name, "x-mas", 3) == 0) {
  1696. town = 7;
  1697. } else if (strncmp(map_name, "comodo", 3) == 0) {
  1698. town = 8;
  1699. } else if (strncmp(map_name, "juno", 3) == 0 ||
  1700. strncmp(map_name, "yuno", 3) == 0) {
  1701. town = 9;
  1702. } else if (strncmp(map_name, "amatsu", 3) == 0) {
  1703. town = 10;
  1704. } else if (strncmp(map_name, "kunlun", 3) == 0 ||
  1705. strncmp(map_name, "gonryun", 3) == 0) {
  1706. town = 11;
  1707. } else if (strncmp(map_name, "umbala", 3) == 0) {
  1708. town = 12;
  1709. } else if (strncmp(map_name, "niflheim", 3) == 0) {
  1710. town = 13;
  1711. } else if (strncmp(map_name, "louyang", 3) == 0) {
  1712. town = 14;
  1713. } else if (strncmp(map_name, "new_1-1", 3) == 0 ||
  1714. strncmp(map_name, "startpoint", 3) == 0 ||
  1715. strncmp(map_name, "beginning", 3) == 0) {
  1716. town = 15;
  1717. } else if (strncmp(map_name, "sec_pri", 3) == 0 ||
  1718. strncmp(map_name, "prison", 3) == 0 ||
  1719. strncmp(map_name, "jail", 3) == 0) {
  1720. town = 16;
  1721. } else if (strncmp(map_name, "jawaii", 3) == 0) {
  1722. town = 17;
  1723. } else if (strncmp(map_name, "ayothaya", 3) == 0) {
  1724. town = 18;
  1725. } else if (strncmp(map_name, "einbroch", 5) == 0) {
  1726. town = 19;
  1727. } else if (strncmp(map_name, "lighthalzen", 3) == 0) {
  1728. town = 20;
  1729. } else if (strncmp(map_name, "einbech", 5) == 0) {
  1730. town = 21;
  1731. } else if (strncmp(map_name, "hugel", 3) == 0) {
  1732. town = 22;
  1733. } else if (strncmp(map_name, "rachel", 3) == 0) {
  1734. town = 23;
  1735. } else if (strncmp(map_name, "veins", 3) == 0) {
  1736. town = 24;
  1737. } else if (strncmp(map_name, "moscovia", 3) == 0) {
  1738. town = 25;
  1739. } else if (strncmp(map_name, "mid_camp", 3) == 0) {
  1740. town = 26;
  1741. } else if (strncmp(map_name, "manuk", 3) == 0) {
  1742. town = 27;
  1743. } else if (strncmp(map_name, "splendide", 3) == 0) {
  1744. town = 28;
  1745. } else if (strncmp(map_name, "brasilis", 3) == 0) {
  1746. town = 29;
  1747. } else if (strncmp(map_name, "dicastes01", 3) == 0) {
  1748. town = 30;
  1749. } else if (strcmp(map_name, "mora") == 0) {
  1750. town = 31;
  1751. } else if (strncmp(map_name, "dewata", 3) == 0) {
  1752. town = 32;
  1753. } else if (strncmp(map_name, "malangdo", 5) == 0) {
  1754. town = 33;
  1755. } else if (strncmp(map_name, "malaya", 5) == 0) {
  1756. town = 34;
  1757. } else if (strncmp(map_name, "eclage", 3) == 0) {
  1758. town = 35;
  1759. }
  1760. if (town >= 0 && town < ARRAYLENGTH(data))
  1761. {
  1762. int16 m = map_mapname2mapid(data[town].map);
  1763. if (m >= 0 && map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  1764. clif_displaymessage(fd, msg_txt(sd,247));
  1765. return -1;
  1766. }
  1767. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  1768. clif_displaymessage(fd, msg_txt(sd,248));
  1769. return -1;
  1770. }
  1771. if (pc_setpos(sd, mapindex_name2id(data[town].map), data[town].x, data[town].y, CLR_TELEPORT) == SETPOS_OK) {
  1772. clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
  1773. } else {
  1774. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  1775. return -1;
  1776. }
  1777. } else { // if you arrive here, you have an error in town variable when reading of names
  1778. clif_displaymessage(fd, msg_txt(sd,38)); // Invalid location number or name.
  1779. return -1;
  1780. }
  1781. return 0;
  1782. }
  1783. /*==========================================
  1784. *
  1785. *------------------------------------------*/
  1786. ACMD_FUNC(monster)
  1787. {
  1788. char name[NAME_LENGTH];
  1789. char monster[NAME_LENGTH];
  1790. char eventname[EVENT_NAME_LENGTH] = "";
  1791. int mob_id;
  1792. int number = 0;
  1793. int count;
  1794. int i, range;
  1795. short mx, my;
  1796. unsigned int size;
  1797. nullpo_retr(-1, sd);
  1798. memset(name, '\0', sizeof(name));
  1799. memset(monster, '\0', sizeof(monster));
  1800. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1801. if (!message || !*message) {
  1802. clif_displaymessage(fd, msg_txt(sd,80)); // Give the display name or monster name/id please.
  1803. return -1;
  1804. }
  1805. if (sscanf(message, "\"%23[^\"]\" %23s %11d", name, monster, &number) > 1 ||
  1806. sscanf(message, "%23s \"%23[^\"]\" %11d", monster, name, &number) > 1) {
  1807. //All data can be left as it is.
  1808. } else if ((count=sscanf(message, "%23s %11d %23s", monster, &number, name)) > 1) {
  1809. //Here, it is possible name was not given and we are using monster for it.
  1810. if (count < 3) //Blank mob's name.
  1811. name[0] = '\0';
  1812. } else if (sscanf(message, "%23s %23s %11d", name, monster, &number) > 1) {
  1813. //All data can be left as it is.
  1814. } else if (sscanf(message, "%23s", monster) > 0) {
  1815. //As before, name may be already filled.
  1816. name[0] = '\0';
  1817. } else {
  1818. clif_displaymessage(fd, msg_txt(sd,80)); // Give a display name and monster name/id please.
  1819. return -1;
  1820. }
  1821. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  1822. mob_id = mobdb_checkid(atoi(monster));
  1823. if (mob_id == 0) {
  1824. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  1825. return -1;
  1826. }
  1827. if (mob_id == MOBID_EMPERIUM) {
  1828. clif_displaymessage(fd, msg_txt(sd,83)); // Monster 'Emperium' cannot be spawned.
  1829. return -1;
  1830. }
  1831. if (number <= 0)
  1832. number = 1;
  1833. if( !name[0] )
  1834. strcpy(name, "--ja--");
  1835. // 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
  1836. if (battle_config.atc_spawn_quantity_limit && number > battle_config.atc_spawn_quantity_limit)
  1837. number = battle_config.atc_spawn_quantity_limit;
  1838. parent_cmd = atcommand_checkalias(command+1);
  1839. if (strcmp(parent_cmd, "monstersmall") == 0)
  1840. size = SZ_MEDIUM; // This is just gorgeous [mkbu95]
  1841. else if (strcmp(parent_cmd, "monsterbig") == 0)
  1842. size = SZ_BIG;
  1843. else
  1844. size = SZ_SMALL;
  1845. if (battle_config.etc_log)
  1846. 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);
  1847. count = 0;
  1848. range = (int)sqrt((float)number) +2; // calculation of an odd number (+ 4 area around)
  1849. for (i = 0; i < number; i++) {
  1850. int k;
  1851. map_search_freecell(&sd->bl, 0, &mx, &my, range, range, 0);
  1852. k = mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, eventname, size, AI_NONE);
  1853. if(k) {
  1854. //mapreg_setreg(reference_uid(add_str("$@mobid"), i),k); //retain created mobid in array uncomment if needed
  1855. count ++;
  1856. }
  1857. }
  1858. if (count != 0)
  1859. if (number == count)
  1860. clif_displaymessage(fd, msg_txt(sd,39)); // All monster summoned!
  1861. else {
  1862. sprintf(atcmd_output, msg_txt(sd,240), count); // %d monster(s) summoned!
  1863. clif_displaymessage(fd, atcmd_output);
  1864. }
  1865. else {
  1866. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  1867. return -1;
  1868. }
  1869. return 0;
  1870. }
  1871. /*==========================================
  1872. *
  1873. *------------------------------------------*/
  1874. static int atkillmonster_sub(struct block_list *bl, va_list ap)
  1875. {
  1876. struct mob_data *md;
  1877. int flag;
  1878. nullpo_ret(md=(struct mob_data *)bl);
  1879. flag = va_arg(ap, int);
  1880. if (md->guardian_data)
  1881. return 0; //Do not touch WoE mobs!
  1882. if (flag)
  1883. status_zap(bl,md->status.hp, 0);
  1884. else
  1885. status_kill(bl);
  1886. return 1;
  1887. }
  1888. ACMD_FUNC(killmonster)
  1889. {
  1890. int map_id, drop_flag;
  1891. char map_name[MAP_NAME_LENGTH_EXT];
  1892. nullpo_retr(-1, sd);
  1893. memset(map_name, '\0', sizeof(map_name));
  1894. if (!message || !*message || sscanf(message, "%15s", map_name) < 1)
  1895. map_id = sd->bl.m;
  1896. else {
  1897. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1898. map_id = sd->bl.m;
  1899. }
  1900. parent_cmd = atcommand_checkalias(command+1);
  1901. drop_flag = strcmp(parent_cmd, "killmonster2");
  1902. map_foreachinmap(atkillmonster_sub, map_id, BL_MOB, -drop_flag);
  1903. clif_displaymessage(fd, msg_txt(sd,165)); // All monsters killed!
  1904. return 0;
  1905. }
  1906. /*==========================================
  1907. *
  1908. *------------------------------------------*/
  1909. ACMD_FUNC(refine)
  1910. {
  1911. int j, position = 0, refine = 0, current_position, final_refine;
  1912. int count;
  1913. nullpo_retr(-1, sd);
  1914. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1915. if (!message || !*message || sscanf(message, "%11d %11d", &position, &refine) < 2) {
  1916. clif_displaymessage(fd, msg_txt(sd,996)); // Please enter a position and an amount (usage: @refine <equip position> <+/- amount>).
  1917. sprintf(atcmd_output, msg_txt(sd,997), EQP_HEAD_LOW); // %d: Lower Headgear
  1918. clif_displaymessage(fd, atcmd_output);
  1919. sprintf(atcmd_output, msg_txt(sd,998), EQP_HAND_R); // %d: Right Hand
  1920. clif_displaymessage(fd, atcmd_output);
  1921. sprintf(atcmd_output, msg_txt(sd,999), EQP_GARMENT); // %d: Garment
  1922. clif_displaymessage(fd, atcmd_output);
  1923. sprintf(atcmd_output, msg_txt(sd,1000), EQP_ACC_L); // %d: Left Accessory
  1924. clif_displaymessage(fd, atcmd_output);
  1925. sprintf(atcmd_output, msg_txt(sd,1001), EQP_ARMOR); // %d: Body Armor
  1926. clif_displaymessage(fd, atcmd_output);
  1927. sprintf(atcmd_output, msg_txt(sd,1002), EQP_HAND_L); // %d: Left Hand
  1928. clif_displaymessage(fd, atcmd_output);
  1929. sprintf(atcmd_output, msg_txt(sd,1003), EQP_SHOES); // %d: Shoes
  1930. clif_displaymessage(fd, atcmd_output);
  1931. sprintf(atcmd_output, msg_txt(sd,1004), EQP_ACC_R); // %d: Right Accessory
  1932. clif_displaymessage(fd, atcmd_output);
  1933. sprintf(atcmd_output, msg_txt(sd,1005), EQP_HEAD_TOP); // %d: Top Headgear
  1934. clif_displaymessage(fd, atcmd_output);
  1935. sprintf(atcmd_output, msg_txt(sd,1006), EQP_HEAD_MID); // %d: Mid Headgear
  1936. clif_displaymessage(fd, atcmd_output);
  1937. return -1;
  1938. }
  1939. refine = cap_value(refine, -MAX_REFINE, MAX_REFINE);
  1940. count = 0;
  1941. for (j = 0; j < EQI_MAX; j++) {
  1942. int i;
  1943. if ((i = sd->equip_index[j]) < 0)
  1944. continue;
  1945. if(j == EQI_AMMO)
  1946. continue;
  1947. if (pc_is_same_equip_index((enum equip_index)j, sd->equip_index, i))
  1948. continue;
  1949. if(position && !(sd->inventory.u.items_inventory[i].equip & position))
  1950. continue;
  1951. final_refine = cap_value(sd->inventory.u.items_inventory[i].refine + refine, 0, MAX_REFINE);
  1952. if (sd->inventory.u.items_inventory[i].refine != final_refine) {
  1953. sd->inventory.u.items_inventory[i].refine = final_refine;
  1954. current_position = sd->inventory.u.items_inventory[i].equip;
  1955. pc_unequipitem(sd, i, 3);
  1956. clif_refine(fd, 0, i, sd->inventory.u.items_inventory[i].refine);
  1957. clif_delitem(sd, i, 1, 3);
  1958. clif_additem(sd, i, 1, 0);
  1959. pc_equipitem(sd, i, current_position);
  1960. clif_misceffect(&sd->bl, 3);
  1961. count++;
  1962. }
  1963. }
  1964. if (count == 0)
  1965. clif_displaymessage(fd, msg_txt(sd,166)); // No item has been refined.
  1966. else if (count == 1)
  1967. clif_displaymessage(fd, msg_txt(sd,167)); // 1 item has been refined.
  1968. else {
  1969. sprintf(atcmd_output, msg_txt(sd,168), count); // %d items have been refined.
  1970. clif_displaymessage(fd, atcmd_output);
  1971. }
  1972. return 0;
  1973. }
  1974. /*==========================================
  1975. *
  1976. *------------------------------------------*/
  1977. ACMD_FUNC(produce)
  1978. {
  1979. char item_name[100];
  1980. unsigned short item_id;
  1981. int attribute = 0, star = 0;
  1982. struct item_data *item_data;
  1983. struct item tmp_item;
  1984. nullpo_retr(-1, sd);
  1985. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1986. memset(item_name, '\0', sizeof(item_name));
  1987. if (!message || !*message || (
  1988. sscanf(message, "\"%99[^\"]\" %11d %11d", item_name, &attribute, &star) < 1 &&
  1989. sscanf(message, "%99s %11d %11d", item_name, &attribute, &star) < 1
  1990. )) {
  1991. clif_displaymessage(fd, msg_txt(sd,1007)); // Please enter at least one item name/ID (usage: @produce <equip name/ID> <element> <# of very's>).
  1992. return -1;
  1993. }
  1994. if ( (item_data = itemdb_searchname(item_name)) == NULL &&
  1995. (item_data = itemdb_exists(atoi(item_name))) == NULL ) {
  1996. clif_displaymessage(fd, msg_txt(sd,170)); //This item is not an equipment.
  1997. return -1;
  1998. }
  1999. item_id = item_data->nameid;
  2000. if (itemdb_isequip2(item_data)) {
  2001. char flag = 0;
  2002. if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
  2003. attribute = ATTRIBUTE_NORMAL;
  2004. if (star < MIN_STAR || star > MAX_STAR)
  2005. star = 0;
  2006. memset(&tmp_item, 0, sizeof tmp_item);
  2007. tmp_item.nameid = item_id;
  2008. tmp_item.amount = 1;
  2009. tmp_item.identify = 1;
  2010. tmp_item.card[0] = CARD0_FORGE;
  2011. tmp_item.card[1] = item_data->type==IT_WEAPON?
  2012. ((star*5) << 8) + attribute:0;
  2013. tmp_item.card[2] = GetWord(sd->status.char_id, 0);
  2014. tmp_item.card[3] = GetWord(sd->status.char_id, 1);
  2015. clif_produceeffect(sd, 0, item_id);
  2016. clif_misceffect(&sd->bl, 3);
  2017. if ((flag = pc_additem(sd, &tmp_item, 1, LOG_TYPE_COMMAND)))
  2018. clif_additem(sd, 0, 0, flag);
  2019. } else {
  2020. sprintf(atcmd_output, msg_txt(sd,169), item_id, item_data->name); // The item (%hu: '%s') is not equipable.
  2021. clif_displaymessage(fd, atcmd_output);
  2022. return -1;
  2023. }
  2024. return 0;
  2025. }
  2026. /*==========================================
  2027. *
  2028. *------------------------------------------*/
  2029. ACMD_FUNC(memo)
  2030. {
  2031. int position = 0;
  2032. nullpo_retr(-1, sd);
  2033. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2034. if( !message || !*message || sscanf(message, "%11d", &position) < 1 )
  2035. {
  2036. int i;
  2037. clif_displaymessage(sd->fd, msg_txt(sd,668));
  2038. for( i = 0; i < MAX_MEMOPOINTS; i++ )
  2039. {
  2040. if( sd->status.memo_point[i].map )
  2041. 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);
  2042. else
  2043. sprintf(atcmd_output, msg_txt(sd,171), i); // %d - void
  2044. clif_displaymessage(sd->fd, atcmd_output);
  2045. }
  2046. return 0;
  2047. }
  2048. if( position < 0 || position >= MAX_MEMOPOINTS )
  2049. {
  2050. sprintf(atcmd_output, msg_txt(sd,1008), 0, MAX_MEMOPOINTS-1); // Please enter a valid position (usage: @memo <memo_position:%d-%d>).
  2051. clif_displaymessage(fd, atcmd_output);
  2052. return -1;
  2053. }
  2054. return !pc_memo( sd, position );
  2055. }
  2056. /*==========================================
  2057. *
  2058. *------------------------------------------*/
  2059. ACMD_FUNC(gat)
  2060. {
  2061. int y;
  2062. nullpo_retr(-1, sd);
  2063. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2064. for (y = 2; y >= -2; y--) {
  2065. sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
  2066. map[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y,
  2067. map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE),
  2068. map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE),
  2069. map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE),
  2070. map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE),
  2071. map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE));
  2072. clif_displaymessage(fd, atcmd_output);
  2073. }
  2074. return 0;
  2075. }
  2076. /*==========================================
  2077. *
  2078. *------------------------------------------*/
  2079. ACMD_FUNC(displaystatus)
  2080. {
  2081. int i, type, flag, tick, val1 = 0, val2 = 0, val3 = 0;
  2082. nullpo_retr(-1, sd);
  2083. if (!message || !*message || (i = sscanf(message, "%11d %11d %11d %11d %11d %11d", &type, &flag, &tick, &val1, &val2, &val3)) < 1) {
  2084. clif_displaymessage(fd, msg_txt(sd,1009)); // Please enter a status type/flag (usage: @displaystatus <status type> <flag> <tick> {<val1> {<val2> {<val3>}}}).
  2085. return -1;
  2086. }
  2087. if (i < 2) flag = 1;
  2088. if (i < 3) tick = 0;
  2089. clif_status_change(&sd->bl, type, flag, tick, val1, val2, val3);
  2090. return 0;
  2091. }
  2092. /*==========================================
  2093. * @stpoint (Rewritten by [Yor])
  2094. *------------------------------------------*/
  2095. ACMD_FUNC(statuspoint)
  2096. {
  2097. int point;
  2098. unsigned int new_status_point;
  2099. if (!message || !*message || (point = atoi(message)) == 0) {
  2100. clif_displaymessage(fd, msg_txt(sd,1010)); // Please enter a number (usage: @stpoint <number of points>).
  2101. return -1;
  2102. }
  2103. if(point < 0)
  2104. {
  2105. if(sd->status.status_point < (unsigned int)(-point))
  2106. {
  2107. new_status_point = 0;
  2108. }
  2109. else
  2110. {
  2111. new_status_point = sd->status.status_point + point;
  2112. }
  2113. }
  2114. else if(UINT_MAX - sd->status.status_point < (unsigned int)point)
  2115. {
  2116. new_status_point = UINT_MAX;
  2117. }
  2118. else
  2119. {
  2120. new_status_point = sd->status.status_point + point;
  2121. }
  2122. if (new_status_point != sd->status.status_point) {
  2123. sd->status.status_point = new_status_point;
  2124. clif_updatestatus(sd, SP_STATUSPOINT);
  2125. clif_displaymessage(fd, msg_txt(sd,174)); // Number of status points changed.
  2126. } else {
  2127. if (point < 0)
  2128. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2129. else
  2130. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2131. return -1;
  2132. }
  2133. return 0;
  2134. }
  2135. /*==========================================
  2136. * @skpoint (Rewritten by [Yor])
  2137. *------------------------------------------*/
  2138. ACMD_FUNC(skillpoint)
  2139. {
  2140. int point;
  2141. unsigned int new_skill_point;
  2142. nullpo_retr(-1, sd);
  2143. if (!message || !*message || (point = atoi(message)) == 0) {
  2144. clif_displaymessage(fd, msg_txt(sd,1011)); // Please enter a number (usage: @skpoint <number of points>).
  2145. return -1;
  2146. }
  2147. if(point < 0)
  2148. {
  2149. if(sd->status.skill_point < (unsigned int)(-point))
  2150. {
  2151. new_skill_point = 0;
  2152. }
  2153. else
  2154. {
  2155. new_skill_point = sd->status.skill_point + point;
  2156. }
  2157. }
  2158. else if(UINT_MAX - sd->status.skill_point < (unsigned int)point)
  2159. {
  2160. new_skill_point = UINT_MAX;
  2161. }
  2162. else
  2163. {
  2164. new_skill_point = sd->status.skill_point + point;
  2165. }
  2166. if (new_skill_point != sd->status.skill_point) {
  2167. sd->status.skill_point = new_skill_point;
  2168. clif_updatestatus(sd, SP_SKILLPOINT);
  2169. clif_displaymessage(fd, msg_txt(sd,175)); // Number of skill points changed.
  2170. } else {
  2171. if (point < 0)
  2172. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2173. else
  2174. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2175. return -1;
  2176. }
  2177. return 0;
  2178. }
  2179. /*==========================================
  2180. * @zeny
  2181. *------------------------------------------*/
  2182. ACMD_FUNC(zeny)
  2183. {
  2184. int zeny=0, ret=-1;
  2185. nullpo_retr(-1, sd);
  2186. if (!message || !*message || (zeny = atoi(message)) == 0) {
  2187. clif_displaymessage(fd, msg_txt(sd,1012)); // Please enter an amount (usage: @zeny <amount>).
  2188. return -1;
  2189. }
  2190. if(zeny > 0){
  2191. if((ret=pc_getzeny(sd,zeny,LOG_TYPE_COMMAND,NULL)) == 1)
  2192. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2193. }
  2194. else {
  2195. if( sd->status.zeny < -zeny ) zeny = -sd->status.zeny;
  2196. if((ret=pc_payzeny(sd,-zeny,LOG_TYPE_COMMAND,NULL)) == 1)
  2197. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2198. }
  2199. if(!ret) clif_displaymessage(fd, msg_txt(sd,176)); //ret=0 mean cmd success
  2200. return 0;
  2201. }
  2202. /*==========================================
  2203. *
  2204. *------------------------------------------*/
  2205. ACMD_FUNC(param)
  2206. {
  2207. uint8 i;
  2208. int value = 0;
  2209. const char* param[] = { "str", "agi", "vit", "int", "dex", "luk" };
  2210. unsigned short new_value, *status[6], max_status[6];
  2211. //we don't use direct initialization because it isn't part of the c standard.
  2212. nullpo_retr(-1, sd);
  2213. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2214. if (!message || !*message || sscanf(message, "%11d", &value) < 1 || value == 0) {
  2215. clif_displaymessage(fd, msg_txt(sd,1013)); // Please enter a valid value (usage: @str/@agi/@vit/@int/@dex/@luk <+/-adjustment>).
  2216. return -1;
  2217. }
  2218. ARR_FIND( 0, ARRAYLENGTH(param), i, strcmpi(command+1, param[i]) == 0 );
  2219. if( i == ARRAYLENGTH(param) || i > MAX_STATUS_TYPE) { // normally impossible...
  2220. clif_displaymessage(fd, msg_txt(sd,1013)); // Please enter a valid value (usage: @str/@agi/@vit/@int/@dex/@luk <+/-adjustment>).
  2221. return -1;
  2222. }
  2223. status[0] = &sd->status.str;
  2224. status[1] = &sd->status.agi;
  2225. status[2] = &sd->status.vit;
  2226. status[3] = &sd->status.int_;
  2227. status[4] = &sd->status.dex;
  2228. status[5] = &sd->status.luk;
  2229. if( pc_has_permission(sd, PC_PERM_BYPASS_MAX_STAT) )
  2230. max_status[0] = max_status[1] = max_status[2] = max_status[3] = max_status[4] = max_status[5] = SHRT_MAX;
  2231. else {
  2232. max_status[0] = pc_maxparameter(sd,PARAM_STR);
  2233. max_status[1] = pc_maxparameter(sd,PARAM_AGI);
  2234. max_status[2] = pc_maxparameter(sd,PARAM_VIT);
  2235. max_status[3] = pc_maxparameter(sd,PARAM_INT);
  2236. max_status[4] = pc_maxparameter(sd,PARAM_DEX);
  2237. max_status[5] = pc_maxparameter(sd,PARAM_LUK);
  2238. }
  2239. if(value > 0 && *status[i] + value >= max_status[i])
  2240. new_value = max_status[i];
  2241. else if(value < 0 && *status[i] <= -value)
  2242. new_value = 1;
  2243. else
  2244. new_value = *status[i] + value;
  2245. if (new_value != *status[i]) {
  2246. *status[i] = new_value;
  2247. clif_updatestatus(sd, SP_STR + i);
  2248. clif_updatestatus(sd, SP_USTR + i);
  2249. status_calc_pc(sd, SCO_FORCE);
  2250. clif_displaymessage(fd, msg_txt(sd,42)); // Stat changed.
  2251. } else {
  2252. if (value < 0)
  2253. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2254. else
  2255. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2256. return -1;
  2257. }
  2258. return 0;
  2259. }
  2260. /*==========================================
  2261. * Stat all by fritz (rewritten by [Yor])
  2262. *------------------------------------------*/
  2263. ACMD_FUNC(stat_all)
  2264. {
  2265. int value = 0;
  2266. uint8 count, i;
  2267. unsigned short *status[PARAM_MAX], max_status[PARAM_MAX];
  2268. //we don't use direct initialization because it isn't part of the c standard.
  2269. nullpo_retr(-1, sd);
  2270. status[0] = &sd->status.str;
  2271. status[1] = &sd->status.agi;
  2272. status[2] = &sd->status.vit;
  2273. status[3] = &sd->status.int_;
  2274. status[4] = &sd->status.dex;
  2275. status[5] = &sd->status.luk;
  2276. if (!message || !*message || sscanf(message, "%11d", &value) < 1 || value == 0) {
  2277. max_status[0] = pc_maxparameter(sd,PARAM_STR);
  2278. max_status[1] = pc_maxparameter(sd,PARAM_AGI);
  2279. max_status[2] = pc_maxparameter(sd,PARAM_VIT);
  2280. max_status[3] = pc_maxparameter(sd,PARAM_INT);
  2281. max_status[4] = pc_maxparameter(sd,PARAM_DEX);
  2282. max_status[5] = pc_maxparameter(sd,PARAM_LUK);
  2283. value = SHRT_MAX;
  2284. } else {
  2285. if( pc_has_permission(sd, PC_PERM_BYPASS_MAX_STAT) )
  2286. max_status[0] = max_status[1] = max_status[2] = max_status[3] = max_status[4] = max_status[5] = SHRT_MAX;
  2287. else {
  2288. max_status[0] = pc_maxparameter(sd,PARAM_STR);
  2289. max_status[1] = pc_maxparameter(sd,PARAM_AGI);
  2290. max_status[2] = pc_maxparameter(sd,PARAM_VIT);
  2291. max_status[3] = pc_maxparameter(sd,PARAM_INT);
  2292. max_status[4] = pc_maxparameter(sd,PARAM_DEX);
  2293. max_status[5] = pc_maxparameter(sd,PARAM_LUK);
  2294. }
  2295. }
  2296. count = 0;
  2297. for (i = 0; i < ARRAYLENGTH(status); i++) {
  2298. short new_value;
  2299. if (value > 0 && *status[i] + value >= max_status[i])
  2300. new_value = max_status[i];
  2301. else if (value < 0 && *status[i] <= -value)
  2302. new_value = 1;
  2303. else
  2304. new_value = *status[i] + value;
  2305. if (new_value != *status[i]) {
  2306. *status[i] = new_value;
  2307. clif_updatestatus(sd, SP_STR + i);
  2308. clif_updatestatus(sd, SP_USTR + i);
  2309. count++;
  2310. }
  2311. }
  2312. if (count > 0) { // if at least 1 stat modified
  2313. status_calc_pc(sd, SCO_FORCE);
  2314. clif_displaymessage(fd, msg_txt(sd,84)); // All stats changed!
  2315. } else {
  2316. if (value < 0)
  2317. clif_displaymessage(fd, msg_txt(sd,177)); // You cannot decrease that stat anymore.
  2318. else
  2319. clif_displaymessage(fd, msg_txt(sd,178)); // You cannot increase that stat anymore.
  2320. return -1;
  2321. }
  2322. return 0;
  2323. }
  2324. /*==========================================
  2325. *
  2326. *------------------------------------------*/
  2327. ACMD_FUNC(guildlevelup) {
  2328. int level = 0;
  2329. short added_level;
  2330. struct guild *guild_info;
  2331. nullpo_retr(-1, sd);
  2332. if (!message || !*message || sscanf(message, "%11d", &level) < 1 || level == 0) {
  2333. clif_displaymessage(fd, msg_txt(sd,1014)); // Please enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).
  2334. return -1;
  2335. }
  2336. if (sd->status.guild_id <= 0 || (guild_info = sd->guild) == NULL) {
  2337. clif_displaymessage(fd, msg_txt(sd,43)); // You're not in a guild.
  2338. return -1;
  2339. }
  2340. //if (strcmp(sd->status.name, guild_info->master) != 0) {
  2341. // clif_displaymessage(fd, msg_txt(sd,44)); // You're not the master of your guild.
  2342. // return -1;
  2343. //}
  2344. added_level = (short)level;
  2345. if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild_lv))) // fix positive overflow
  2346. added_level = (short)MAX_GUILDLEVEL - guild_info->guild_lv;
  2347. else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild_lv))) // fix negative overflow
  2348. added_level = 1 - guild_info->guild_lv;
  2349. if (added_level != 0) {
  2350. intif_guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, sizeof(added_level));
  2351. clif_displaymessage(fd, msg_txt(sd,179)); // Guild level changed.
  2352. } else {
  2353. clif_displaymessage(fd, msg_txt(sd,45)); // Guild level change failed.
  2354. return -1;
  2355. }
  2356. return 0;
  2357. }
  2358. /*==========================================
  2359. *
  2360. *------------------------------------------*/
  2361. ACMD_FUNC(makeegg) {
  2362. struct item_data *item_data;
  2363. int id, pet_id;
  2364. nullpo_retr(-1, sd);
  2365. if (!message || !*message) {
  2366. clif_displaymessage(fd, msg_txt(sd,1015)); // Please enter a monster/egg name/ID (usage: @makeegg <pet>).
  2367. return -1;
  2368. }
  2369. if ((item_data = itemdb_searchname(message)) != NULL) // for egg name
  2370. id = item_data->nameid;
  2371. else
  2372. if ((id = mobdb_searchname(message)) != 0) // for monster name
  2373. ;
  2374. else
  2375. id = atoi(message);
  2376. pet_id = search_petDB_index(id, PET_CLASS);
  2377. if (pet_id < 0)
  2378. pet_id = search_petDB_index(id, PET_EGG);
  2379. if (pet_id >= 0) {
  2380. sd->catch_target_class = pet_db[pet_id].class_;
  2381. intif_create_pet(
  2382. sd->status.account_id, sd->status.char_id,
  2383. (short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv,
  2384. (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
  2385. 100, 0, 1, pet_db[pet_id].jname);
  2386. } else {
  2387. clif_displaymessage(fd, msg_txt(sd,180)); // The monster/egg name/id doesn't exist.
  2388. return -1;
  2389. }
  2390. return 0;
  2391. }
  2392. /*==========================================
  2393. *
  2394. *------------------------------------------*/
  2395. ACMD_FUNC(hatch) {
  2396. nullpo_retr(-1, sd);
  2397. if (sd->status.pet_id <= 0)
  2398. clif_sendegg(sd);
  2399. else {
  2400. clif_displaymessage(fd, msg_txt(sd,181)); // You already have a pet.
  2401. return -1;
  2402. }
  2403. return 0;
  2404. }
  2405. /*==========================================
  2406. *
  2407. *------------------------------------------*/
  2408. ACMD_FUNC(petfriendly) {
  2409. int friendly;
  2410. struct pet_data *pd;
  2411. nullpo_retr(-1, sd);
  2412. if (!message || !*message || (friendly = atoi(message)) < 0) {
  2413. clif_displaymessage(fd, msg_txt(sd,1016)); // Please enter a valid value (usage: @petfriendly <0-1000>).
  2414. return -1;
  2415. }
  2416. pd = sd->pd;
  2417. if (!pd) {
  2418. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2419. return -1;
  2420. }
  2421. if (friendly < 0 || friendly > 1000)
  2422. {
  2423. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  2424. return -1;
  2425. }
  2426. if (friendly == pd->pet.intimate) {
  2427. clif_displaymessage(fd, msg_txt(sd,183)); // Pet intimacy is already at maximum.
  2428. return -1;
  2429. }
  2430. pet_set_intimate(pd, friendly);
  2431. clif_send_petstatus(sd);
  2432. clif_displaymessage(fd, msg_txt(sd,182)); // Pet intimacy changed.
  2433. return 0;
  2434. }
  2435. /*==========================================
  2436. *
  2437. *------------------------------------------*/
  2438. ACMD_FUNC(pethungry)
  2439. {
  2440. int hungry;
  2441. struct pet_data *pd;
  2442. nullpo_retr(-1, sd);
  2443. if (!message || !*message || (hungry = atoi(message)) < 0) {
  2444. clif_displaymessage(fd, msg_txt(sd,1017)); // Please enter a valid number (usage: @pethungry <0-100>).
  2445. return -1;
  2446. }
  2447. pd = sd->pd;
  2448. if (!sd->status.pet_id || !pd) {
  2449. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2450. return -1;
  2451. }
  2452. if (hungry < 0 || hungry > 100) {
  2453. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  2454. return -1;
  2455. }
  2456. if (hungry == pd->pet.hungry) {
  2457. clif_displaymessage(fd, msg_txt(sd,186)); // Pet hunger is already at maximum.
  2458. return -1;
  2459. }
  2460. pd->pet.hungry = hungry;
  2461. clif_send_petstatus(sd);
  2462. clif_displaymessage(fd, msg_txt(sd,185)); // Pet hunger changed.
  2463. return 0;
  2464. }
  2465. /*==========================================
  2466. *
  2467. *------------------------------------------*/
  2468. ACMD_FUNC(petrename)
  2469. {
  2470. struct pet_data *pd;
  2471. nullpo_retr(-1, sd);
  2472. if (!sd->status.pet_id || !sd->pd) {
  2473. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2474. return -1;
  2475. }
  2476. pd = sd->pd;
  2477. if (!pd->pet.rename_flag) {
  2478. clif_displaymessage(fd, msg_txt(sd,188)); // You can already rename your pet.
  2479. return -1;
  2480. }
  2481. pd->pet.rename_flag = 0;
  2482. intif_save_petdata(sd->status.account_id, &pd->pet);
  2483. clif_send_petstatus(sd);
  2484. clif_displaymessage(fd, msg_txt(sd,187)); // You can now rename your pet.
  2485. return 0;
  2486. }
  2487. /*==========================================
  2488. *
  2489. *------------------------------------------*/
  2490. ACMD_FUNC(recall) {
  2491. struct map_session_data *pl_sd = NULL;
  2492. nullpo_retr(-1, sd);
  2493. if (!message || !*message) {
  2494. clif_displaymessage(fd, msg_txt(sd,1018)); // Please enter a player name (usage: @recall <char name/ID>).
  2495. return -1;
  2496. }
  2497. if((pl_sd=map_nick2sd((char *)message,true)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  2498. {
  2499. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  2500. return -1;
  2501. }
  2502. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  2503. {
  2504. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level doesn't authorize you to preform this action on the specified player.
  2505. return -1;
  2506. }
  2507. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2508. clif_displaymessage(fd, msg_txt(sd,1019)); // You are not authorized to warp someone to this map.
  2509. return -1;
  2510. }
  2511. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2512. clif_displaymessage(fd, msg_txt(sd,1020)); // You are not authorized to warp this player from their map.
  2513. return -1;
  2514. }
  2515. if (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y) {
  2516. return -1;
  2517. }
  2518. if( pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN) == SETPOS_AUTOTRADE ){
  2519. clif_displaymessage(fd, msg_txt(sd,1025)); // The player is currently autotrading and cannot be recalled.
  2520. return -1;
  2521. }
  2522. sprintf(atcmd_output, msg_txt(sd,46), pl_sd->status.name); // %s recalled!
  2523. clif_displaymessage(fd, atcmd_output);
  2524. return 0;
  2525. }
  2526. /*==========================================
  2527. * charblock command (usage: charblock <player_name>)
  2528. * This command do a definitiv ban on a player
  2529. *------------------------------------------*/
  2530. ACMD_FUNC(char_block)
  2531. {
  2532. nullpo_retr(-1, sd);
  2533. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2534. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2535. sprintf(atcmd_output, msg_txt(sd, 1021), command); // Please enter a player name (usage: %s <char name>).
  2536. clif_displaymessage(fd, atcmd_output);
  2537. return -1;
  2538. }
  2539. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, CHRIF_OP_LOGIN_BLOCK, 0, 0, 0);
  2540. sprintf(atcmd_output, msg_txt(sd,88), "login"); // Sending request to %s server...
  2541. clif_displaymessage(fd, atcmd_output);
  2542. return 0;
  2543. }
  2544. /*==========================================
  2545. * accountban command (usage: ban <%time> <player_name>)
  2546. * charban command (usage: charban <%time> <player_name>)
  2547. * %time see common/timer.c::solve_time()
  2548. *------------------------------------------*/
  2549. ACMD_FUNC(char_ban)
  2550. {
  2551. char *modif_p, output[CHAT_SIZE_MAX];
  2552. int32 timediff = 0; //don't set this as uint as we may want to decrease banned time
  2553. enum chrif_req_op bantype;
  2554. nullpo_retr(-1, sd);
  2555. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2556. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2557. parent_cmd = atcommand_checkalias(command+1);
  2558. if (strcmpi(parent_cmd,"charban") == 0)
  2559. bantype = CHRIF_OP_BAN;
  2560. else if (strcmpi(parent_cmd,"ban") == 0)
  2561. bantype = CHRIF_OP_LOGIN_BAN;
  2562. else
  2563. return -1;
  2564. if (!message || !*message || sscanf(message, "%255s %23[^\n]", atcmd_output, atcmd_player_name) < 2) {
  2565. sprintf(output, msg_txt(sd,1022), command); // Please enter ban time and a player name (usage: %s <time> <char name>).
  2566. clif_displaymessage(fd, output);
  2567. return -1;
  2568. }
  2569. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  2570. modif_p = atcmd_output;
  2571. timediff = (int32)solve_time(modif_p); //discard seconds
  2572. if (timediff == 0) { //allow negative ?
  2573. safesnprintf(output, sizeof(output), msg_txt(sd,85), command, timediff); // Invalid time for %s command (time=%d)
  2574. clif_displaymessage(fd, output);
  2575. clif_displaymessage(fd, msg_txt(sd,702)); // Time parameter format is +/-<value> to alter. y/a = Year, m = Month, d/j = Day, h = Hour, n/mn = Minute, s = Second.
  2576. return -1;
  2577. }
  2578. if( timediff < 0 && (
  2579. (bantype == CHRIF_OP_LOGIN_BAN && !pc_can_use_command(sd, "unban", COMMAND_ATCOMMAND))
  2580. || (bantype == CHRIF_OP_BAN && !pc_can_use_command(sd, "charunban", COMMAND_ATCOMMAND))
  2581. ))
  2582. {
  2583. clif_displaymessage(fd,msg_txt(sd,1023)); // You are not allowed to alter the time of a ban.
  2584. return -1;
  2585. }
  2586. if (bantype == CHRIF_OP_BAN)
  2587. chrif_req_charban(sd->status.account_id, atcmd_player_name,timediff);
  2588. else
  2589. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, bantype, timediff, 0, 0);
  2590. safesnprintf(output, sizeof(output), msg_txt(sd,88), bantype == CHRIF_OP_BAN ? "char" : "login"); // Sending request to %s server...
  2591. clif_displaymessage(fd, output);
  2592. return 0;
  2593. }
  2594. /*==========================================
  2595. * charunblock command (usage: charunblock <player_name>)
  2596. *------------------------------------------*/
  2597. ACMD_FUNC(char_unblock)
  2598. {
  2599. nullpo_retr(-1, sd);
  2600. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2601. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2602. sprintf(atcmd_output, msg_txt(sd, 1021), command); // Please enter a player name (usage: %s <char name>).
  2603. clif_displaymessage(fd, atcmd_output);
  2604. return -1;
  2605. }
  2606. // send answer to login server via char-server
  2607. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, CHRIF_OP_LOGIN_UNBLOCK, 0, 0, 0);
  2608. sprintf(atcmd_output, msg_txt(sd,88), "login"); // Sending request to %s server...
  2609. clif_displaymessage(fd, atcmd_output);
  2610. return 0;
  2611. }
  2612. /*==========================================
  2613. * acc unban command (usage: unban <player_name>)
  2614. * char unban command (usage: charunban <player_name>)
  2615. *------------------------------------------*/
  2616. ACMD_FUNC(char_unban){
  2617. enum chrif_req_op unbantype;
  2618. nullpo_retr(-1, sd);
  2619. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2620. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2621. parent_cmd = atcommand_checkalias(command+1);
  2622. if (strcmpi(parent_cmd,"charunban") == 0)
  2623. unbantype = CHRIF_OP_UNBAN;
  2624. else if (strcmpi(parent_cmd,"unban") == 0)
  2625. unbantype = CHRIF_OP_LOGIN_UNBAN;
  2626. else
  2627. return -1;
  2628. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2629. sprintf(atcmd_output, msg_txt(sd,435), command); // Please enter a player name (usage: %s <char name>).
  2630. clif_displaymessage(fd, atcmd_output);
  2631. return -1;
  2632. }
  2633. if (unbantype == CHRIF_OP_UNBAN)
  2634. chrif_req_charunban(sd->status.account_id,atcmd_player_name);
  2635. else
  2636. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, unbantype, 0, 0, 0);
  2637. sprintf(atcmd_output, msg_txt(sd,88), unbantype == CHRIF_OP_UNBAN ? "char":"login"); // Sending request to %s server...
  2638. clif_displaymessage(fd, atcmd_output);
  2639. return 0;
  2640. }
  2641. /*==========================================
  2642. *
  2643. *------------------------------------------*/
  2644. ACMD_FUNC(night)
  2645. {
  2646. nullpo_retr(-1, sd);
  2647. if (night_flag != 1) {
  2648. map_night_timer(night_timer_tid, 0, 0, 1);
  2649. } else {
  2650. clif_displaymessage(fd, msg_txt(sd,89)); // Night mode is already enabled.
  2651. return -1;
  2652. }
  2653. return 0;
  2654. }
  2655. /*==========================================
  2656. *
  2657. *------------------------------------------*/
  2658. ACMD_FUNC(day)
  2659. {
  2660. nullpo_retr(-1, sd);
  2661. if (night_flag != 0) {
  2662. map_day_timer(day_timer_tid, 0, 0, 1);
  2663. } else {
  2664. clif_displaymessage(fd, msg_txt(sd,90)); // Day mode is already enabled.
  2665. return -1;
  2666. }
  2667. return 0;
  2668. }
  2669. /*==========================================
  2670. *
  2671. *------------------------------------------*/
  2672. ACMD_FUNC(doom)
  2673. {
  2674. struct map_session_data* pl_sd;
  2675. struct s_mapiterator* iter;
  2676. nullpo_retr(-1, sd);
  2677. iter = mapit_getallusers();
  2678. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2679. {
  2680. if (pl_sd->fd != fd && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  2681. {
  2682. status_kill(&pl_sd->bl);
  2683. clif_specialeffect(&pl_sd->bl,450,AREA);
  2684. clif_displaymessage(pl_sd->fd, msg_txt(sd,61)); // The holy messenger has given judgement.
  2685. }
  2686. }
  2687. mapit_free(iter);
  2688. clif_displaymessage(fd, msg_txt(sd,62)); // Judgement was made.
  2689. return 0;
  2690. }
  2691. /*==========================================
  2692. *
  2693. *------------------------------------------*/
  2694. ACMD_FUNC(doommap)
  2695. {
  2696. struct map_session_data* pl_sd;
  2697. struct s_mapiterator* iter;
  2698. nullpo_retr(-1, sd);
  2699. iter = mapit_getallusers();
  2700. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2701. {
  2702. if (pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  2703. {
  2704. status_kill(&pl_sd->bl);
  2705. clif_specialeffect(&pl_sd->bl,450,AREA);
  2706. clif_displaymessage(pl_sd->fd, msg_txt(sd,61)); // The holy messenger has given judgement.
  2707. }
  2708. }
  2709. mapit_free(iter);
  2710. clif_displaymessage(fd, msg_txt(sd,62)); // Judgement was made.
  2711. return 0;
  2712. }
  2713. /*==========================================
  2714. *
  2715. *------------------------------------------*/
  2716. static void atcommand_raise_sub(struct map_session_data* sd) {
  2717. status_revive(&sd->bl, 100, 100);
  2718. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  2719. clif_displaymessage(sd->fd, msg_txt(sd,63)); // Mercy has been shown.
  2720. }
  2721. /*==========================================
  2722. *
  2723. *------------------------------------------*/
  2724. ACMD_FUNC(raise)
  2725. {
  2726. struct map_session_data* pl_sd;
  2727. struct s_mapiterator* iter;
  2728. nullpo_retr(-1, sd);
  2729. iter = mapit_getallusers();
  2730. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2731. if( pc_isdead(pl_sd) )
  2732. atcommand_raise_sub(pl_sd);
  2733. mapit_free(iter);
  2734. clif_displaymessage(fd, msg_txt(sd,64)); // Mercy has been granted.
  2735. return 0;
  2736. }
  2737. /*==========================================
  2738. *
  2739. *------------------------------------------*/
  2740. ACMD_FUNC(raisemap)
  2741. {
  2742. struct map_session_data* pl_sd;
  2743. struct s_mapiterator* iter;
  2744. nullpo_retr(-1, sd);
  2745. iter = mapit_getallusers();
  2746. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2747. if (sd->bl.m == pl_sd->bl.m && pc_isdead(pl_sd) )
  2748. atcommand_raise_sub(pl_sd);
  2749. mapit_free(iter);
  2750. clif_displaymessage(fd, msg_txt(sd,64)); // Mercy has been granted.
  2751. return 0;
  2752. }
  2753. /*==========================================
  2754. *
  2755. *------------------------------------------*/
  2756. ACMD_FUNC(kick)
  2757. {
  2758. struct map_session_data *pl_sd;
  2759. nullpo_retr(-1, sd);
  2760. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2761. if (!message || !*message) {
  2762. clif_displaymessage(fd, msg_txt(sd,1026)); // Please enter a player name (usage: @kick <char name/ID>).
  2763. return -1;
  2764. }
  2765. if((pl_sd=map_nick2sd((char *)message,false)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  2766. {
  2767. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  2768. return -1;
  2769. }
  2770. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  2771. {
  2772. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  2773. return -1;
  2774. }
  2775. clif_GM_kick(sd, pl_sd);
  2776. return 0;
  2777. }
  2778. /*==========================================
  2779. *
  2780. *------------------------------------------*/
  2781. ACMD_FUNC(kickall)
  2782. {
  2783. struct map_session_data* pl_sd;
  2784. struct s_mapiterator* iter;
  2785. nullpo_retr(-1, sd);
  2786. iter = mapit_getallusers();
  2787. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2788. {
  2789. if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kick only lower or same gm level
  2790. if (sd->status.account_id != pl_sd->status.account_id)
  2791. clif_GM_kick(NULL, pl_sd);
  2792. }
  2793. }
  2794. mapit_free(iter);
  2795. clif_displaymessage(fd, msg_txt(sd,195)); // All players have been kicked!
  2796. return 0;
  2797. }
  2798. /*==========================================
  2799. *
  2800. *------------------------------------------*/
  2801. ACMD_FUNC(allskill)
  2802. {
  2803. nullpo_retr(-1, sd);
  2804. pc_allskillup(sd); // all skills
  2805. sd->status.skill_point = 0; // 0 skill points
  2806. clif_updatestatus(sd, SP_SKILLPOINT); // update
  2807. clif_displaymessage(fd, msg_txt(sd,76)); // All skills have been added to your skill tree.
  2808. return 0;
  2809. }
  2810. /*==========================================
  2811. *
  2812. *------------------------------------------*/
  2813. ACMD_FUNC(questskill)
  2814. {
  2815. uint16 skill_id;
  2816. nullpo_retr(-1, sd);
  2817. if (!message || !*message || (skill_id = atoi(message)) <= 0)
  2818. {// also send a list of skills applicable to this command
  2819. const char* text;
  2820. // attempt to find the text corresponding to this command
  2821. text = atcommand_help_string( command );
  2822. // send the error message as always
  2823. clif_displaymessage(fd, msg_txt(sd,1027)); // Please enter a quest skill number.
  2824. if( text )
  2825. {// send the skill ID list associated with this command
  2826. clif_displaymessage( fd, text );
  2827. }
  2828. return -1;
  2829. }
  2830. if (skill_id >= MAX_SKILL_ID) {
  2831. clif_displaymessage(fd, msg_txt(sd,198)); // This skill number doesn't exist.
  2832. return -1;
  2833. }
  2834. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  2835. clif_displaymessage(fd, msg_txt(sd,197)); // This skill number doesn't exist or isn't a quest skill.
  2836. return -1;
  2837. }
  2838. if (pc_checkskill(sd, skill_id) > 0) {
  2839. clif_displaymessage(fd, msg_txt(sd,196)); // You already have this quest skill.
  2840. return -1;
  2841. }
  2842. pc_skill(sd, skill_id, 1, ADDSKILL_PERMANENT);
  2843. clif_displaymessage(fd, msg_txt(sd,70)); // You have learned the skill.
  2844. return 0;
  2845. }
  2846. /*==========================================
  2847. *
  2848. *------------------------------------------*/
  2849. ACMD_FUNC(lostskill)
  2850. {
  2851. uint16 skill_id = 0, sk_idx = 0;
  2852. nullpo_retr(-1, sd);
  2853. if (!message || !*message || (skill_id = atoi(message)) <= 0)
  2854. {// also send a list of skills applicable to this command
  2855. const char* text;
  2856. // attempt to find the text corresponding to this command
  2857. text = atcommand_help_string( command );
  2858. // send the error message as always
  2859. clif_displaymessage(fd, msg_txt(sd,1027)); // Please enter a quest skill number.
  2860. if( text )
  2861. {// send the skill ID list associated with this command
  2862. clif_displaymessage( fd, text );
  2863. }
  2864. return -1;
  2865. }
  2866. if (!(sk_idx = skill_get_index(skill_id))) {
  2867. clif_displaymessage(fd, msg_txt(sd,198)); // This skill number doesn't exist.
  2868. return -1;
  2869. }
  2870. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  2871. clif_displaymessage(fd, msg_txt(sd,197)); // This skill number doesn't exist or isn't a quest skill.
  2872. return -1;
  2873. }
  2874. if (pc_checkskill(sd, skill_id) == 0) {
  2875. clif_displaymessage(fd, msg_txt(sd,201)); // You don't have this quest skill.
  2876. return -1;
  2877. }
  2878. sd->status.skill[sk_idx].lv = 0;
  2879. sd->status.skill[sk_idx].flag = SKILL_FLAG_PERMANENT;
  2880. clif_deleteskill(sd,skill_id);
  2881. clif_displaymessage(fd, msg_txt(sd,71)); // You have forgotten the skill.
  2882. return 0;
  2883. }
  2884. /*==========================================
  2885. *
  2886. *------------------------------------------*/
  2887. ACMD_FUNC(spiritball)
  2888. {
  2889. uint32 max_spiritballs;
  2890. int number;
  2891. nullpo_retr(-1, sd);
  2892. max_spiritballs = zmin(ARRAYLENGTH(sd->spirit_timer), 0x7FFF);
  2893. if( !message || !*message || (number = atoi(message)) < 0 || number > max_spiritballs )
  2894. {
  2895. char msg[CHAT_SIZE_MAX];
  2896. safesnprintf(msg, sizeof(msg), msg_txt(sd,1028), max_spiritballs); // Please enter a party name (usage: @party <party_name>).
  2897. clif_displaymessage(fd, msg);
  2898. return -1;
  2899. }
  2900. if( sd->spiritball > 0 )
  2901. pc_delspiritball(sd, sd->spiritball, 1);
  2902. sd->spiritball = number;
  2903. clif_spiritball(&sd->bl);
  2904. // no message, player can look the difference
  2905. return 0;
  2906. }
  2907. /*==========================================
  2908. *
  2909. *------------------------------------------*/
  2910. ACMD_FUNC(party)
  2911. {
  2912. char party[NAME_LENGTH];
  2913. nullpo_retr(-1, sd);
  2914. memset(party, '\0', sizeof(party));
  2915. if (!message || !*message || sscanf(message, "%23[^\n]", party) < 1) {
  2916. clif_displaymessage(fd, msg_txt(sd,1029)); // Please enter a party name (usage: @party <party_name>).
  2917. return -1;
  2918. }
  2919. party_create(sd, party, 0, 0);
  2920. return 0;
  2921. }
  2922. /*==========================================
  2923. *
  2924. *------------------------------------------*/
  2925. ACMD_FUNC(guild)
  2926. {
  2927. char guild[NAME_LENGTH];
  2928. int prev;
  2929. nullpo_retr(-1, sd);
  2930. memset(guild, '\0', sizeof(guild));
  2931. if (sd->clan) {
  2932. clif_displaymessage(fd, msg_txt(sd, 1498)); // You cannot create a guild because you are in a clan.
  2933. return -1;
  2934. }
  2935. if (!message || !*message || sscanf(message, "%23[^\n]", guild) < 1) {
  2936. clif_displaymessage(fd, msg_txt(sd,1030)); // Please enter a guild name (usage: @guild <guild_name>).
  2937. return -1;
  2938. }
  2939. prev = battle_config.guild_emperium_check;
  2940. battle_config.guild_emperium_check = 0;
  2941. guild_create(sd, guild);
  2942. battle_config.guild_emperium_check = prev;
  2943. return 0;
  2944. }
  2945. ACMD_FUNC(breakguild)
  2946. {
  2947. nullpo_retr(-1, sd);
  2948. if (sd->status.guild_id) { // Check if the player has a guild
  2949. struct guild *g;
  2950. g = sd->guild; // Search the guild
  2951. if (g) { // Check if guild was found
  2952. if (sd->state.gmaster_flag) { // Check if player is guild master
  2953. int ret = 0;
  2954. ret = guild_break(sd, g->name); // Break guild
  2955. if (ret) { // Check if anything went wrong
  2956. return 0; // Guild was broken
  2957. } else {
  2958. return -1; // Something went wrong
  2959. }
  2960. } else { // Not guild master
  2961. clif_displaymessage(fd, msg_txt(sd,1181)); // You need to be a Guild Master to use this command.
  2962. return -1;
  2963. }
  2964. } else { // Guild was not found. HOW?
  2965. clif_displaymessage(fd, msg_txt(sd,252)); // You are not in a guild.
  2966. return -1;
  2967. }
  2968. } else { // Player does not have a guild
  2969. clif_displaymessage(fd, msg_txt(sd,252)); // You are not in a guild.
  2970. return -1;
  2971. }
  2972. }
  2973. /**
  2974. * Start WoE:FE
  2975. */
  2976. ACMD_FUNC(agitstart)
  2977. {
  2978. nullpo_retr(-1, sd);
  2979. if( guild_agit_start() ){
  2980. clif_displaymessage(fd, msg_txt(sd,72)); // War of Emperium has been initiated.
  2981. return 0;
  2982. }else{
  2983. clif_displaymessage(fd, msg_txt(sd,73)); // War of Emperium is currently in progress.
  2984. return -1;
  2985. }
  2986. }
  2987. /**
  2988. * Start WoE:SE
  2989. */
  2990. ACMD_FUNC(agitstart2)
  2991. {
  2992. nullpo_retr(-1, sd);
  2993. if( guild_agit2_start() ){
  2994. clif_displaymessage(fd, msg_txt(sd,403)); // "War of Emperium SE has been initiated."
  2995. return 0;
  2996. }else{
  2997. clif_displaymessage(fd, msg_txt(sd,404)); // "War of Emperium SE is currently in progress."
  2998. return -1;
  2999. }
  3000. }
  3001. /**
  3002. * Start WoE:TE
  3003. */
  3004. ACMD_FUNC(agitstart3)
  3005. {
  3006. nullpo_retr(-1, sd);
  3007. if( guild_agit3_start() ){
  3008. clif_displaymessage(fd, msg_txt(sd,749)); // "War of Emperium TE has been initiated."
  3009. return 0;
  3010. }else{
  3011. clif_displaymessage(fd, msg_txt(sd,750)); // "War of Emperium TE is currently in progress."
  3012. return -1;
  3013. }
  3014. }
  3015. /**
  3016. * End WoE:FE
  3017. */
  3018. ACMD_FUNC(agitend)
  3019. {
  3020. nullpo_retr(-1, sd);
  3021. if( guild_agit_end() ){
  3022. clif_displaymessage(fd, msg_txt(sd,74)); // War of Emperium has been ended.
  3023. return 0;
  3024. }else{
  3025. clif_displaymessage(fd, msg_txt(sd,75)); // War of Emperium is currently not in progress.
  3026. return -1;
  3027. }
  3028. }
  3029. /**
  3030. * End WoE:SE
  3031. */
  3032. ACMD_FUNC(agitend2)
  3033. {
  3034. nullpo_retr(-1, sd);
  3035. if( guild_agit2_end() ){
  3036. clif_displaymessage(fd, msg_txt(sd,405)); // "War of Emperium SE has been ended."
  3037. return 0;
  3038. }else{
  3039. clif_displaymessage(fd, msg_txt(sd,406)); // "War of Emperium SE is currently not in progress."
  3040. return -1;
  3041. }
  3042. }
  3043. /**
  3044. * End WoE:TE
  3045. */
  3046. ACMD_FUNC(agitend3)
  3047. {
  3048. nullpo_retr(-1, sd);
  3049. if( guild_agit3_end() ){
  3050. clif_displaymessage(fd, msg_txt(sd,751));// War of Emperium TE has been ended.
  3051. return 0;
  3052. }else{
  3053. clif_displaymessage(fd, msg_txt(sd,752));// War of Emperium TE is currently not in progress.
  3054. return -1;
  3055. }
  3056. }
  3057. /*==========================================
  3058. * @mapexit - shuts down the map server
  3059. *------------------------------------------*/
  3060. ACMD_FUNC(mapexit)
  3061. {
  3062. nullpo_retr(-1, sd);
  3063. do_shutdown();
  3064. return 0;
  3065. }
  3066. /*==========================================
  3067. * idsearch <part_of_name>: revrited by [Yor]
  3068. *------------------------------------------*/
  3069. ACMD_FUNC(idsearch)
  3070. {
  3071. char item_name[100];
  3072. unsigned int i, match;
  3073. struct item_data *item_array[MAX_SEARCH];
  3074. nullpo_retr(-1, sd);
  3075. memset(item_name, '\0', sizeof(item_name));
  3076. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3077. if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
  3078. clif_displaymessage(fd, msg_txt(sd,1031)); // Please enter part of an item name (usage: @idsearch <part_of_item_name>).
  3079. return -1;
  3080. }
  3081. sprintf(atcmd_output, msg_txt(sd,77), item_name); // The reference result of '%s' (name: id):
  3082. clif_displaymessage(fd, atcmd_output);
  3083. match = itemdb_searchname_array(item_array, MAX_SEARCH, item_name);
  3084. if (match == MAX_SEARCH) {
  3085. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH); // Displaying first %d matches
  3086. clif_displaymessage(fd, atcmd_output);
  3087. }
  3088. for(i = 0; i < match; i++) {
  3089. sprintf(atcmd_output, msg_txt(sd,78), item_array[i]->jname, item_array[i]->nameid); // %s: %d
  3090. clif_displaymessage(fd, atcmd_output);
  3091. }
  3092. sprintf(atcmd_output, msg_txt(sd,79), match); // It is %d affair above.
  3093. clif_displaymessage(fd, atcmd_output);
  3094. return 0;
  3095. }
  3096. /*==========================================
  3097. * Recall All Characters Online To Your Location
  3098. *------------------------------------------*/
  3099. ACMD_FUNC(recallall)
  3100. {
  3101. struct map_session_data* pl_sd;
  3102. struct s_mapiterator* iter;
  3103. int count;
  3104. nullpo_retr(-1, sd);
  3105. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3106. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3107. clif_displaymessage(fd, msg_txt(sd,1032)); // You are not authorized to warp someone to your current map.
  3108. return -1;
  3109. }
  3110. count = 0;
  3111. iter = mapit_getallusers();
  3112. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3113. {
  3114. if (sd->status.account_id != pl_sd->status.account_id && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  3115. {
  3116. if (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y)
  3117. continue; // Don't waste time warping the character to the same place.
  3118. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3119. count++;
  3120. else {
  3121. if( pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN) == SETPOS_AUTOTRADE ){
  3122. count++;
  3123. }
  3124. }
  3125. }
  3126. }
  3127. mapit_free(iter);
  3128. clif_displaymessage(fd, msg_txt(sd,92)); // All characters recalled!
  3129. if (count) {
  3130. sprintf(atcmd_output, msg_txt(sd,1033), count); // Because you are not authorized to warp from some maps, %d player(s) have not been recalled.
  3131. clif_displaymessage(fd, atcmd_output);
  3132. }
  3133. return 0;
  3134. }
  3135. /*==========================================
  3136. * Recall online characters of a guild to your location
  3137. *------------------------------------------*/
  3138. ACMD_FUNC(guildrecall)
  3139. {
  3140. struct map_session_data* pl_sd;
  3141. struct s_mapiterator* iter;
  3142. int count;
  3143. char guild_name[NAME_LENGTH];
  3144. struct guild *g;
  3145. nullpo_retr(-1, sd);
  3146. memset(guild_name, '\0', sizeof(guild_name));
  3147. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3148. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  3149. clif_displaymessage(fd, msg_txt(sd,1034)); // Please enter a guild name/ID (usage: @guildrecall <guild_name/ID>).
  3150. return -1;
  3151. }
  3152. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3153. clif_displaymessage(fd, msg_txt(sd,1032)); // You are not authorized to warp someone to your current map.
  3154. return -1;
  3155. }
  3156. if ((g = guild_searchname(guild_name)) == NULL && // name first to avoid error when name begin with a number
  3157. (g = guild_search(atoi(message))) == NULL)
  3158. {
  3159. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  3160. return -1;
  3161. }
  3162. count = 0;
  3163. iter = mapit_getallusers();
  3164. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3165. {
  3166. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.guild_id == g->guild_id)
  3167. {
  3168. 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))
  3169. continue; // Skip GMs greater than you... or chars already on the cell
  3170. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3171. count++;
  3172. else{
  3173. if( pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN) == SETPOS_AUTOTRADE ){
  3174. count++;
  3175. }
  3176. }
  3177. }
  3178. }
  3179. mapit_free(iter);
  3180. sprintf(atcmd_output, msg_txt(sd,93), g->name); // All online characters of the %s guild have been recalled to your position.
  3181. clif_displaymessage(fd, atcmd_output);
  3182. if (count) {
  3183. sprintf(atcmd_output, msg_txt(sd,1033), count); // Because you are not authorized to warp from some maps, %d player(s) have not been recalled.
  3184. clif_displaymessage(fd, atcmd_output);
  3185. }
  3186. return 0;
  3187. }
  3188. /*==========================================
  3189. * Recall online characters of a party to your location
  3190. *------------------------------------------*/
  3191. ACMD_FUNC(partyrecall)
  3192. {
  3193. struct map_session_data* pl_sd;
  3194. struct s_mapiterator* iter;
  3195. char party_name[NAME_LENGTH];
  3196. struct party_data *p;
  3197. int count;
  3198. nullpo_retr(-1, sd);
  3199. memset(party_name, '\0', sizeof(party_name));
  3200. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3201. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3202. clif_displaymessage(fd, msg_txt(sd,1035)); // Please enter a party name/ID (usage: @partyrecall <party_name/ID>).
  3203. return -1;
  3204. }
  3205. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3206. clif_displaymessage(fd, msg_txt(sd,1032)); // You are not authorized to warp someone to your current map.
  3207. return -1;
  3208. }
  3209. if ((p = party_searchname(party_name)) == NULL && // name first to avoid error when name begin with a number
  3210. (p = party_search(atoi(message))) == NULL)
  3211. {
  3212. clif_displaymessage(fd, msg_txt(sd,96)); // Incorrect name or ID, or no one from the party is online.
  3213. return -1;
  3214. }
  3215. count = 0;
  3216. iter = mapit_getallusers();
  3217. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3218. {
  3219. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.party_id == p->party.party_id)
  3220. {
  3221. 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))
  3222. continue; // Skip GMs greater than you... or chars already on the cell
  3223. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3224. count++;
  3225. else{
  3226. if( pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN) == SETPOS_AUTOTRADE ){
  3227. count++;
  3228. }
  3229. }
  3230. }
  3231. }
  3232. mapit_free(iter);
  3233. sprintf(atcmd_output, msg_txt(sd,95), p->party.name); // All online characters of the %s party have been recalled to your position.
  3234. clif_displaymessage(fd, atcmd_output);
  3235. if (count) {
  3236. sprintf(atcmd_output, msg_txt(sd,1033), count); // Because you are not authorized to warp from some maps, %d player(s) have not been recalled.
  3237. clif_displaymessage(fd, atcmd_output);
  3238. }
  3239. return 0;
  3240. }
  3241. /*==========================================
  3242. *
  3243. *------------------------------------------*/
  3244. void atcommand_doload();
  3245. ACMD_FUNC(reload) {
  3246. nullpo_retr(-1, sd);
  3247. if ((strlen(command) < 8 ) && (!message || !*message)) {
  3248. const char* text;
  3249. text = atcommand_help_string( command );
  3250. if(text)
  3251. clif_displaymessage( fd, text );
  3252. return -1;
  3253. }
  3254. if (strstr(command, "itemdb") || strncmp(message, "itemdb", 4) == 0) {
  3255. itemdb_reload();
  3256. clif_displaymessage(fd, msg_txt(sd,97)); // Item database has been reloaded.
  3257. } else if (strstr(command, "mobdb") || strncmp(message, "mobdb", 3) == 0) {
  3258. mob_reload();
  3259. read_petdb();
  3260. hom_reload();
  3261. mercenary_readdb();
  3262. mercenary_read_skilldb();
  3263. reload_elementaldb();
  3264. clif_displaymessage(fd, msg_txt(sd,98)); // Monster database has been reloaded.
  3265. } else if (strstr(command, "skilldb") || strncmp(message, "skilldb", 4) == 0) {
  3266. skill_reload();
  3267. hom_reload_skill();
  3268. reload_elemental_skilldb();
  3269. mercenary_read_skilldb();
  3270. clif_displaymessage(fd, msg_txt(sd,99)); // Skill database has been reloaded.
  3271. } else if (strstr(command, "atcommand") || strncmp(message, "atcommand", 4) == 0) {
  3272. config_t run_test;
  3273. if (conf_read_file(&run_test, "conf/groups.conf")) {
  3274. clif_displaymessage(fd, msg_txt(sd,1036)); // Error reading groups.conf, reload failed.
  3275. return -1;
  3276. }
  3277. config_destroy(&run_test);
  3278. if (conf_read_file(&run_test, ATCOMMAND_CONF_FILENAME)) {
  3279. clif_displaymessage(fd, msg_txt(sd,1037)); // Error reading atcommand_athena.conf, reload failed.
  3280. return -1;
  3281. }
  3282. config_destroy(&run_test);
  3283. atcommand_doload();
  3284. pc_groups_reload();
  3285. clif_displaymessage(fd, msg_txt(sd,254));
  3286. } else if (strstr(command, "battleconf") || strncmp(message, "battleconf", 3) == 0) {
  3287. struct Battle_Config prev_config;
  3288. memcpy(&prev_config, &battle_config, sizeof(prev_config));
  3289. battle_config_read(BATTLE_CONF_FILENAME);
  3290. if( prev_config.item_rate_mvp != battle_config.item_rate_mvp
  3291. || prev_config.item_rate_common != battle_config.item_rate_common
  3292. || prev_config.item_rate_common_boss != battle_config.item_rate_common_boss
  3293. || prev_config.item_rate_common_mvp != battle_config.item_rate_common_mvp
  3294. || prev_config.item_rate_card != battle_config.item_rate_card
  3295. || prev_config.item_rate_card_boss != battle_config.item_rate_card_boss
  3296. || prev_config.item_rate_card_mvp != battle_config.item_rate_card_mvp
  3297. || prev_config.item_rate_equip != battle_config.item_rate_equip
  3298. || prev_config.item_rate_equip_boss != battle_config.item_rate_equip_boss
  3299. || prev_config.item_rate_equip_mvp != battle_config.item_rate_equip_mvp
  3300. || prev_config.item_rate_heal != battle_config.item_rate_heal
  3301. || prev_config.item_rate_heal_boss != battle_config.item_rate_heal_boss
  3302. || prev_config.item_rate_heal_mvp != battle_config.item_rate_heal_mvp
  3303. || prev_config.item_rate_use != battle_config.item_rate_use
  3304. || prev_config.item_rate_use_boss != battle_config.item_rate_use_boss
  3305. || prev_config.item_rate_use_mvp != battle_config.item_rate_use_mvp
  3306. || prev_config.item_rate_treasure != battle_config.item_rate_treasure
  3307. || prev_config.item_rate_adddrop != battle_config.item_rate_adddrop
  3308. || prev_config.logarithmic_drops != battle_config.logarithmic_drops
  3309. || prev_config.item_drop_common_min != battle_config.item_drop_common_min
  3310. || prev_config.item_drop_common_max != battle_config.item_drop_common_max
  3311. || prev_config.item_drop_card_min != battle_config.item_drop_card_min
  3312. || prev_config.item_drop_card_max != battle_config.item_drop_card_max
  3313. || prev_config.item_drop_equip_min != battle_config.item_drop_equip_min
  3314. || prev_config.item_drop_equip_max != battle_config.item_drop_equip_max
  3315. || prev_config.item_drop_mvp_min != battle_config.item_drop_mvp_min
  3316. || prev_config.item_drop_mvp_max != battle_config.item_drop_mvp_max
  3317. || prev_config.item_drop_heal_min != battle_config.item_drop_heal_min
  3318. || prev_config.item_drop_heal_max != battle_config.item_drop_heal_max
  3319. || prev_config.item_drop_use_min != battle_config.item_drop_use_min
  3320. || prev_config.item_drop_use_max != battle_config.item_drop_use_max
  3321. || prev_config.item_drop_treasure_min != battle_config.item_drop_treasure_min
  3322. || prev_config.item_drop_treasure_max != battle_config.item_drop_treasure_max
  3323. || prev_config.base_exp_rate != battle_config.base_exp_rate
  3324. || prev_config.job_exp_rate != battle_config.job_exp_rate
  3325. )
  3326. { // Exp or Drop rates changed.
  3327. mob_reload(); //Needed as well so rate changes take effect.
  3328. chrif_ragsrvinfo(battle_config.base_exp_rate, battle_config.job_exp_rate, battle_config.item_rate_common);
  3329. }
  3330. clif_displaymessage(fd, msg_txt(sd,255));
  3331. } else if (strstr(command, "statusdb") || strncmp(message, "statusdb", 3) == 0) {
  3332. status_readdb();
  3333. clif_displaymessage(fd, msg_txt(sd,256));
  3334. } else if (strstr(command, "pcdb") || strncmp(message, "pcdb", 2) == 0) {
  3335. pc_readdb();
  3336. clif_displaymessage(fd, msg_txt(sd,257));
  3337. } else if (strstr(command, "motd") || strncmp(message, "motd", 4) == 0) {
  3338. pc_read_motd();
  3339. clif_displaymessage(fd, msg_txt(sd,268));
  3340. } else if (strstr(command, "script") || strncmp(message, "script", 3) == 0) {
  3341. struct s_mapiterator* iter;
  3342. struct map_session_data* pl_sd;
  3343. //atcommand_broadcast( fd, sd, "@broadcast", "Server is reloading scripts..." );
  3344. //atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
  3345. iter = mapit_getallusers();
  3346. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3347. pc_close_npc(pl_sd,2);
  3348. mapit_free(iter);
  3349. flush_fifos();
  3350. map_reloadnpc(true); // reload config files seeking for npcs
  3351. script_reload();
  3352. npc_reload();
  3353. clif_displaymessage(fd, msg_txt(sd,100)); // Scripts have been reloaded.
  3354. } else if (strstr(command, "msgconf") || strncmp(message, "msgconf", 3) == 0) {
  3355. map_msg_reload();
  3356. clif_displaymessage(fd, msg_txt(sd,463)); // Message configuration has been reloaded.
  3357. } else if (strstr(command, "questdb") || strncmp(message, "questdb", 3) == 0) {
  3358. do_reload_quest();
  3359. clif_displaymessage(fd, msg_txt(sd,1377)); // Quest database has been reloaded.
  3360. } else if (strstr(command, "packetdb") || strncmp(message, "packetdb", 4) == 0) {
  3361. packetdb_readdb(true);
  3362. clif_displaymessage(fd, msg_txt(sd,1477)); // Packet database has been reloaded.
  3363. } else if (strstr(command, "instancedb") || strncmp(message, "instancedb", 4) == 0) {
  3364. instance_reload();
  3365. clif_displaymessage(fd, msg_txt(sd,516)); // Instance database has been reloaded.
  3366. }
  3367. return 0;
  3368. }
  3369. /*==========================================
  3370. * @partysharelvl <share_range> [Akinari]
  3371. * Updates char server party share level range in runtime
  3372. * Temporary - Permanent update in inter_athena.conf
  3373. *------------------------------------------*/
  3374. ACMD_FUNC(partysharelvl) {
  3375. unsigned int share_lvl;
  3376. nullpo_retr(-1, sd);
  3377. if(!message || !*message) {
  3378. clif_displaymessage(fd, msg_txt(sd,1322)); // Please enter an amount.
  3379. return -1;
  3380. } else {
  3381. share_lvl = min(abs(atoi(message)),MAX_LEVEL);
  3382. }
  3383. if(intif_party_sharelvlupdate(share_lvl)) //Successfully updated
  3384. clif_displaymessage(fd, msg_txt(sd,1478)); // Party share level range has been changed successfully.
  3385. else //Char server offline
  3386. clif_displaymessage(fd, msg_txt(sd,1479)); // Failed to update configuration. Character server is offline.
  3387. return 0;
  3388. }
  3389. /*==========================================
  3390. * @mapinfo [0-3] <map name> by MC_Cameri
  3391. * => Shows information about the map [map name]
  3392. * 0 = no additional information
  3393. * 1 = Show users in that map and their location
  3394. * 2 = Shows NPCs in that map
  3395. * 3 = Shows the chats in that map
  3396. *------------------------------------------*/
  3397. ACMD_FUNC(mapinfo) {
  3398. struct map_session_data* pl_sd;
  3399. struct s_mapiterator* iter;
  3400. struct chat_data *cd = NULL;
  3401. char direction[12];
  3402. int i, m_id, chat_num = 0, list = 0, vend_num = 0;
  3403. unsigned short m_index;
  3404. char mapname[24];
  3405. nullpo_retr(-1, sd);
  3406. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3407. memset(mapname, '\0', sizeof(mapname));
  3408. memset(direction, '\0', sizeof(direction));
  3409. sscanf(message, "%11d %23[^\n]", &list, mapname);
  3410. if (list < 0 || list > 3) {
  3411. clif_displaymessage(fd, msg_txt(sd,1038)); // Please enter at least one valid list number (usage: @mapinfo <0-3> <map>).
  3412. return -1;
  3413. }
  3414. if (mapname[0] == '\0') {
  3415. safestrncpy(mapname, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
  3416. m_id = map_mapindex2mapid(sd->mapindex);
  3417. } else {
  3418. m_id = map_mapname2mapid(mapname);
  3419. }
  3420. if (m_id < 0) {
  3421. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  3422. return -1;
  3423. }
  3424. m_index = mapindex_name2id(mapname); //This one shouldn't fail since the previous seek did not.
  3425. clif_displaymessage(fd, msg_txt(sd,1039)); // ------ Map Info ------
  3426. // count chats (for initial message)
  3427. chat_num = 0;
  3428. iter = mapit_getallusers();
  3429. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) {
  3430. if( pl_sd->mapindex == m_index ) {
  3431. if( pl_sd->state.vending )
  3432. vend_num++;
  3433. else if( (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL && cd->usersd[0] == pl_sd )
  3434. chat_num++;
  3435. }
  3436. }
  3437. mapit_free(iter);
  3438. sprintf(atcmd_output, msg_txt(sd,1040), mapname, map[m_id].users, map[m_id].npc_num, chat_num, vend_num); // Map: %s | Players: %d | NPCs: %d | Chats: %d | Vendings: %d
  3439. clif_displaymessage(fd, atcmd_output);
  3440. clif_displaymessage(fd, msg_txt(sd,1041)); // ------ Map Flags ------
  3441. if (map[m_id].flag.town)
  3442. clif_displaymessage(fd, msg_txt(sd,1042)); // Town Map
  3443. if (map[m_id].flag.restricted){
  3444. sprintf(atcmd_output, " Restricted (zone %d)",map[m_id].zone);
  3445. clif_displaymessage(fd, atcmd_output);
  3446. }
  3447. if (battle_config.autotrade_mapflag == map[m_id].flag.autotrade)
  3448. clif_displaymessage(fd, msg_txt(sd,1043)); // Autotrade Enabled
  3449. else
  3450. clif_displaymessage(fd, msg_txt(sd,1044)); // Autotrade Disabled
  3451. if (map[m_id].flag.battleground){
  3452. sprintf(atcmd_output, msg_txt(sd,1045),map[m_id].flag.battleground); // Battlegrounds ON (type %d)
  3453. clif_displaymessage(fd, atcmd_output);
  3454. }
  3455. /* Skill damage adjustment info [Cydh] */
  3456. #ifdef ADJUST_SKILL_DAMAGE
  3457. if (map[m_id].flag.skill_damage) {
  3458. clif_displaymessage(fd,msg_txt(sd,1052)); // Skill Damage Adjustments:
  3459. sprintf(atcmd_output," > [Map] %d%%, %d%%, %d%%, %d%% | Caster:%d"
  3460. ,map[m_id].adjust.damage.pc
  3461. ,map[m_id].adjust.damage.mob
  3462. ,map[m_id].adjust.damage.boss
  3463. ,map[m_id].adjust.damage.other
  3464. ,map[m_id].adjust.damage.caster);
  3465. clif_displaymessage(fd, atcmd_output);
  3466. if (map[m_id].skill_damage.count) {
  3467. uint8 j;
  3468. clif_displaymessage(fd," > [Map Skill] Name : Player, Monster, Boss Monster, Other | Caster");
  3469. for (j = 0; j < map[m_id].skill_damage.count; j++) {
  3470. sprintf(atcmd_output," %d. %s : %d%%, %d%%, %d%%, %d%% | %d"
  3471. ,j+1
  3472. ,skill_get_name(map[m_id].skill_damage.entries[j]->skill_id)
  3473. ,map[m_id].skill_damage.entries[j]->pc
  3474. ,map[m_id].skill_damage.entries[j]->mob
  3475. ,map[m_id].skill_damage.entries[j]->boss
  3476. ,map[m_id].skill_damage.entries[j]->other
  3477. ,map[m_id].skill_damage.entries[j]->caster);
  3478. clif_displaymessage(fd,atcmd_output);
  3479. }
  3480. }
  3481. }
  3482. #endif
  3483. strcpy(atcmd_output,msg_txt(sd,1046)); // PvP Flags:
  3484. if (map[m_id].flag.pvp)
  3485. strcat(atcmd_output, " Pvp ON |");
  3486. if (map[m_id].flag.pvp_noguild)
  3487. strcat(atcmd_output, " NoGuild |");
  3488. if (map[m_id].flag.pvp_noparty)
  3489. strcat(atcmd_output, " NoParty |");
  3490. if (map[m_id].flag.pvp_nightmaredrop)
  3491. strcat(atcmd_output, " NightmareDrop |");
  3492. if (map[m_id].flag.pvp_nocalcrank)
  3493. strcat(atcmd_output, " NoCalcRank |");
  3494. clif_displaymessage(fd, atcmd_output);
  3495. strcpy(atcmd_output,msg_txt(sd,1047)); // GvG Flags:
  3496. if (map[m_id].flag.gvg)
  3497. strcat(atcmd_output, " GvG ON |");
  3498. if (map[m_id].flag.gvg_dungeon)
  3499. strcat(atcmd_output, " GvG Dungeon |");
  3500. if (map[m_id].flag.gvg_castle)
  3501. strcat(atcmd_output, " GvG Castle |");
  3502. if (map[m_id].flag.gvg_te)
  3503. strcat(atcmd_output, " GvG TE |");
  3504. if (map[m_id].flag.gvg_te_castle)
  3505. strcat(atcmd_output, " GvG TE Castle |");
  3506. if (map[m_id].flag.gvg_noparty)
  3507. strcat(atcmd_output, " NoParty |");
  3508. clif_displaymessage(fd, atcmd_output);
  3509. strcpy(atcmd_output,msg_txt(sd,1048)); // Teleport Flags:
  3510. if (map[m_id].flag.noteleport)
  3511. strcat(atcmd_output, " NoTeleport |");
  3512. if (map[m_id].flag.monster_noteleport)
  3513. strcat(atcmd_output, " Monster NoTeleport |");
  3514. if (map[m_id].flag.nowarp)
  3515. strcat(atcmd_output, " NoWarp |");
  3516. if (map[m_id].flag.nowarpto)
  3517. strcat(atcmd_output, " NoWarpTo |");
  3518. if (map[m_id].flag.noreturn)
  3519. strcat(atcmd_output, " NoReturn |");
  3520. if (map[m_id].flag.nogo)
  3521. strcat(atcmd_output, " NoGo |"); //
  3522. if (map[m_id].flag.nomemo)
  3523. strcat(atcmd_output, " NoMemo |");
  3524. clif_displaymessage(fd, atcmd_output);
  3525. sprintf(atcmd_output, msg_txt(sd,1065), // No Exp Penalty: %s | No Zeny Penalty: %s
  3526. (map[m_id].flag.noexppenalty) ? msg_txt(sd,1066) : msg_txt(sd,1067), (map[m_id].flag.nozenypenalty) ? msg_txt(sd,1066) : msg_txt(sd,1067)); // On / Off
  3527. clif_displaymessage(fd, atcmd_output);
  3528. if (map[m_id].flag.nosave) {
  3529. if (!map[m_id].save.map)
  3530. clif_displaymessage(fd, msg_txt(sd,1068)); // No Save (Return to last Save Point)
  3531. else if (map[m_id].save.x == -1 || map[m_id].save.y == -1 ) {
  3532. sprintf(atcmd_output, msg_txt(sd,1069), mapindex_id2name(map[m_id].save.map)); // No Save, Save Point: %s,Random
  3533. clif_displaymessage(fd, atcmd_output);
  3534. }
  3535. else {
  3536. sprintf(atcmd_output, msg_txt(sd,1070), // No Save, Save Point: %s,%d,%d
  3537. mapindex_id2name(map[m_id].save.map),map[m_id].save.x,map[m_id].save.y);
  3538. clif_displaymessage(fd, atcmd_output);
  3539. }
  3540. }
  3541. strcpy(atcmd_output,msg_txt(sd,1049)); // Weather Flags:
  3542. if (map[m_id].flag.snow)
  3543. strcat(atcmd_output, " Snow |");
  3544. if (map[m_id].flag.fog)
  3545. strcat(atcmd_output, " Fog |");
  3546. if (map[m_id].flag.sakura)
  3547. strcat(atcmd_output, " Sakura |");
  3548. if (map[m_id].flag.clouds)
  3549. strcat(atcmd_output, " Clouds |");
  3550. if (map[m_id].flag.clouds2)
  3551. strcat(atcmd_output, " Clouds2 |");
  3552. if (map[m_id].flag.fireworks)
  3553. strcat(atcmd_output, " Fireworks |");
  3554. if (map[m_id].flag.leaves)
  3555. strcat(atcmd_output, " Leaves |");
  3556. if (map[m_id].flag.nightenabled)
  3557. strcat(atcmd_output, " Displays Night |");
  3558. clif_displaymessage(fd, atcmd_output);
  3559. strcpy(atcmd_output,msg_txt(sd,1050)); // Other Flags:
  3560. if (map[m_id].flag.nobranch)
  3561. strcat(atcmd_output, " NoBranch |");
  3562. if (map[m_id].flag.notrade)
  3563. strcat(atcmd_output, " NoTrade |");
  3564. if (map[m_id].flag.novending)
  3565. strcat(atcmd_output, " NoVending |");
  3566. if (map[m_id].flag.nodrop)
  3567. strcat(atcmd_output, " NoDrop |");
  3568. if (map[m_id].flag.noskill)
  3569. strcat(atcmd_output, " NoSkill |");
  3570. if (map[m_id].flag.noicewall)
  3571. strcat(atcmd_output, " NoIcewall |");
  3572. if (map[m_id].flag.allowks)
  3573. strcat(atcmd_output, " AllowKS |");
  3574. if (map[m_id].flag.reset)
  3575. strcat(atcmd_output, " Reset |");
  3576. if (map[m_id].flag.hidemobhpbar)
  3577. strcat(atcmd_output, " HideMobHPBar |");
  3578. clif_displaymessage(fd, atcmd_output);
  3579. strcpy(atcmd_output,msg_txt(sd,1051)); // Other Flags2:
  3580. if (map[m_id].nocommand)
  3581. strcat(atcmd_output, " NoCommand |");
  3582. if (map[m_id].flag.nobaseexp)
  3583. strcat(atcmd_output, " NoBaseEXP |");
  3584. if (map[m_id].flag.nojobexp)
  3585. strcat(atcmd_output, " NoJobEXP |");
  3586. if (map[m_id].flag.nomobloot)
  3587. strcat(atcmd_output, " NoMobLoot |");
  3588. if (map[m_id].flag.nomvploot)
  3589. strcat(atcmd_output, " NoMVPLoot |");
  3590. if (map[m_id].flag.partylock)
  3591. strcat(atcmd_output, " PartyLock |");
  3592. if (map[m_id].flag.guildlock)
  3593. strcat(atcmd_output, " GuildLock |");
  3594. if (map[m_id].flag.loadevent)
  3595. strcat(atcmd_output, " Loadevent |");
  3596. if (map[m_id].flag.chmautojoin)
  3597. strcat(atcmd_output, " Chmautojoin |");
  3598. if (map[m_id].flag.nousecart)
  3599. strcat(atcmd_output, " NoUsecart |");
  3600. if (map[m_id].flag.noitemconsumption)
  3601. strcat(atcmd_output, " NoItemConsumption |");
  3602. if (map[m_id].flag.nosumstarmiracle)
  3603. strcat(atcmd_output, " NoSumStarMiracle |");
  3604. if (map[m_id].flag.nomineeffect)
  3605. strcat(atcmd_output, " NoMineEffect |");
  3606. if (map[m_id].flag.nolockon)
  3607. strcat(atcmd_output, " NoLockOn |");
  3608. if (map[m_id].flag.notomb)
  3609. strcat(atcmd_output, " NoTomb |");
  3610. if (map[m_id].flag.nocostume)
  3611. strcat(atcmd_output, " NoCostume |");
  3612. clif_displaymessage(fd, atcmd_output);
  3613. switch (list) {
  3614. case 0:
  3615. // Do nothing. It's list 0, no additional display.
  3616. break;
  3617. case 1:
  3618. clif_displaymessage(fd, msg_txt(sd,480)); // ----- Players in Map -----
  3619. iter = mapit_getallusers();
  3620. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3621. {
  3622. if (pl_sd->mapindex == m_index) {
  3623. sprintf(atcmd_output, msg_txt(sd,481), // Player '%s' (session #%d) | Location: %d,%d
  3624. pl_sd->status.name, pl_sd->fd, pl_sd->bl.x, pl_sd->bl.y);
  3625. clif_displaymessage(fd, atcmd_output);
  3626. }
  3627. }
  3628. mapit_free(iter);
  3629. break;
  3630. case 2:
  3631. clif_displaymessage(fd, msg_txt(sd,482)); // ----- NPCs in Map -----
  3632. for (i = 0; i < map[m_id].npc_num;)
  3633. {
  3634. struct npc_data *nd = map[m_id].npc[i];
  3635. switch(nd->ud.dir) {
  3636. case 0: strcpy(direction, msg_txt(sd,491)); break; // North
  3637. case 1: strcpy(direction, msg_txt(sd,492)); break; // North West
  3638. case 2: strcpy(direction, msg_txt(sd,493)); break; // West
  3639. case 3: strcpy(direction, msg_txt(sd,494)); break; // South West
  3640. case 4: strcpy(direction, msg_txt(sd,495)); break; // South
  3641. case 5: strcpy(direction, msg_txt(sd,496)); break; // South East
  3642. case 6: strcpy(direction, msg_txt(sd,497)); break; // East
  3643. case 7: strcpy(direction, msg_txt(sd,498)); break; // North East
  3644. case 9: strcpy(direction, msg_txt(sd,491)); break; // North
  3645. default: strcpy(direction, msg_txt(sd,499)); break; // Unknown
  3646. }
  3647. if(strcmp(nd->name,nd->exname) == 0)
  3648. sprintf(atcmd_output, msg_txt(sd,490), // NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d
  3649. ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
  3650. else
  3651. sprintf(atcmd_output, msg_txt(sd,489), // NPC %d: %s::%s | Direction: %s | Sprite: %d | Location: %d %d
  3652. ++i, nd->name, nd->exname, direction, nd->class_, nd->bl.x, nd->bl.y);
  3653. clif_displaymessage(fd, atcmd_output);
  3654. }
  3655. break;
  3656. case 3:
  3657. clif_displaymessage(fd, msg_txt(sd,483)); // ----- Chats in Map -----
  3658. iter = mapit_getallusers();
  3659. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3660. {
  3661. if ((cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL &&
  3662. pl_sd->mapindex == m_index &&
  3663. cd->usersd[0] == pl_sd)
  3664. {
  3665. sprintf(atcmd_output, msg_txt(sd,484), // Chat: %s | Player: %s | Location: %d %d
  3666. cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
  3667. clif_displaymessage(fd, atcmd_output);
  3668. sprintf(atcmd_output, msg_txt(sd,485), // Users: %d/%d | Password: %s | Public: %s
  3669. cd->users, cd->limit, cd->pass, (cd->pub) ? msg_txt(sd,486) : msg_txt(sd,487)); // Yes / No
  3670. clif_displaymessage(fd, atcmd_output);
  3671. }
  3672. }
  3673. mapit_free(iter);
  3674. break;
  3675. default: // normally impossible to arrive here
  3676. clif_displaymessage(fd, msg_txt(sd,488)); // Please enter at least one valid list number (usage: @mapinfo <0-3> <map>).
  3677. return -1;
  3678. break;
  3679. }
  3680. return 0;
  3681. }
  3682. /*==========================================
  3683. *
  3684. *------------------------------------------*/
  3685. ACMD_FUNC(mount_peco)
  3686. {
  3687. nullpo_retr(-1, sd);
  3688. if (sd->disguise) {
  3689. clif_displaymessage(fd, msg_txt(sd,212)); // Cannot mount while in disguise.
  3690. return -1;
  3691. }
  3692. if( (sd->class_&MAPID_THIRDMASK) == MAPID_RUNE_KNIGHT && pc_checkskill(sd,RK_DRAGONTRAINING) > 0 ) {
  3693. if( !(sd->sc.option&OPTION_DRAGON) ) {
  3694. unsigned int option = OPTION_DRAGON1;
  3695. if( message[0] ) {
  3696. int color = atoi(message);
  3697. option = ( color == 2 ? OPTION_DRAGON2 :
  3698. color == 3 ? OPTION_DRAGON3 :
  3699. color == 4 ? OPTION_DRAGON4 :
  3700. color == 5 ? OPTION_DRAGON5 :
  3701. OPTION_DRAGON1 );
  3702. }
  3703. clif_displaymessage(sd->fd,msg_txt(sd,1119)); // You have mounted your Dragon.
  3704. pc_setoption(sd, sd->sc.option|option);
  3705. } else {
  3706. clif_displaymessage(sd->fd,msg_txt(sd,1120)); // You have released your Dragon.
  3707. pc_setoption(sd, sd->sc.option&~OPTION_DRAGON);
  3708. }
  3709. return 0;
  3710. }
  3711. if( (sd->class_&MAPID_THIRDMASK) == MAPID_RANGER && pc_checkskill(sd,RA_WUGRIDER) > 0 && (!pc_isfalcon(sd) || battle_config.warg_can_falcon) ) {
  3712. if( !pc_isridingwug(sd) ) {
  3713. clif_displaymessage(sd->fd,msg_txt(sd,1121)); // You have mounted your Warg.
  3714. pc_setoption(sd, sd->sc.option|OPTION_WUGRIDER);
  3715. } else {
  3716. clif_displaymessage(sd->fd,msg_txt(sd,1122)); // You have released your Warg.
  3717. pc_setoption(sd, sd->sc.option&~OPTION_WUGRIDER);
  3718. }
  3719. return 0;
  3720. }
  3721. if( (sd->class_&MAPID_THIRDMASK) == MAPID_MECHANIC ) {
  3722. if( !pc_ismadogear(sd) ) {
  3723. clif_displaymessage(sd->fd,msg_txt(sd,1123)); // You have mounted your Mado Gear.
  3724. pc_setoption(sd, sd->sc.option|OPTION_MADOGEAR);
  3725. } else {
  3726. clif_displaymessage(sd->fd,msg_txt(sd,1124)); // You have released your Mado Gear.
  3727. pc_setoption(sd, sd->sc.option&~OPTION_MADOGEAR);
  3728. }
  3729. return 0;
  3730. }
  3731. if (!pc_isriding(sd)) { // if actually no peco
  3732. if (!pc_checkskill(sd, KN_RIDING)) {
  3733. clif_displaymessage(fd, msg_txt(sd,213)); // You can not mount a Peco Peco with your current job.
  3734. return -1;
  3735. }
  3736. pc_setoption(sd, sd->sc.option | OPTION_RIDING);
  3737. clif_displaymessage(fd, msg_txt(sd,102)); // You have mounted a Peco Peco.
  3738. } else {//Dismount
  3739. pc_setoption(sd, sd->sc.option & ~OPTION_RIDING);
  3740. clif_displaymessage(fd, msg_txt(sd,214)); // You have released your Peco Peco.
  3741. }
  3742. return 0;
  3743. }
  3744. /*==========================================
  3745. *Spy Commands by Syrus22
  3746. *------------------------------------------*/
  3747. ACMD_FUNC(guildspy)
  3748. {
  3749. char guild_name[NAME_LENGTH];
  3750. struct guild *g;
  3751. nullpo_retr(-1, sd);
  3752. memset(guild_name, '\0', sizeof(guild_name));
  3753. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3754. if (!enable_spy)
  3755. {
  3756. clif_displaymessage(fd, msg_txt(sd,1125)); // The mapserver has spy command support disabled.
  3757. return -1;
  3758. }
  3759. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  3760. clif_displaymessage(fd, msg_txt(sd,1126)); // Please enter a guild name/ID (usage: @guildspy <guild_name/ID>).
  3761. return -1;
  3762. }
  3763. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  3764. (g = guild_search(atoi(message))) != NULL) {
  3765. if (sd->guildspy == g->guild_id) {
  3766. sd->guildspy = 0;
  3767. sprintf(atcmd_output, msg_txt(sd,103), g->name); // No longer spying on the %s guild.
  3768. clif_displaymessage(fd, atcmd_output);
  3769. } else {
  3770. sd->guildspy = g->guild_id;
  3771. sprintf(atcmd_output, msg_txt(sd,104), g->name); // Spying on the %s guild.
  3772. clif_displaymessage(fd, atcmd_output);
  3773. }
  3774. } else {
  3775. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the specified guild is online.
  3776. return -1;
  3777. }
  3778. return 0;
  3779. }
  3780. /*==========================================
  3781. *
  3782. *------------------------------------------*/
  3783. ACMD_FUNC(partyspy)
  3784. {
  3785. char party_name[NAME_LENGTH];
  3786. struct party_data *p;
  3787. nullpo_retr(-1, sd);
  3788. memset(party_name, '\0', sizeof(party_name));
  3789. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3790. if (!enable_spy)
  3791. {
  3792. clif_displaymessage(fd, msg_txt(sd,1125)); // The mapserver has spy command support disabled.
  3793. return -1;
  3794. }
  3795. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3796. clif_displaymessage(fd, msg_txt(sd,1127)); // Please enter a party name/ID (usage: @partyspy <party_name/ID>).
  3797. return -1;
  3798. }
  3799. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  3800. (p = party_search(atoi(message))) != NULL) {
  3801. if (sd->partyspy == p->party.party_id) {
  3802. sd->partyspy = 0;
  3803. sprintf(atcmd_output, msg_txt(sd,105), p->party.name); // No longer spying on the %s party.
  3804. clif_displaymessage(fd, atcmd_output);
  3805. } else {
  3806. sd->partyspy = p->party.party_id;
  3807. sprintf(atcmd_output, msg_txt(sd,106), p->party.name); // Spying on the %s party.
  3808. clif_displaymessage(fd, atcmd_output);
  3809. }
  3810. } else {
  3811. clif_displaymessage(fd, msg_txt(sd,96)); // Incorrect name/ID, or no one from the specified party is online.
  3812. return -1;
  3813. }
  3814. return 0;
  3815. }
  3816. ACMD_FUNC(clanspy){
  3817. char clan_name[NAME_LENGTH];
  3818. struct clan* c;
  3819. nullpo_retr(-1, sd);
  3820. memset(clan_name, '\0', sizeof(clan_name));
  3821. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3822. if( !enable_spy ){
  3823. clif_displaymessage(fd, msg_txt(sd, 1125)); // The mapserver has spy command support disabled.
  3824. return -1;
  3825. }
  3826. if( !message || !*message || sscanf( message, "%23[^\n]", clan_name ) < 1 ){
  3827. clif_displaymessage(fd, msg_txt(sd, 1499)); // Please enter a clan name/ID (usage: @clanspy <clan_name/ID>).
  3828. return -1;
  3829. }
  3830. if ((c = clan_searchname(clan_name)) != NULL || // name first to avoid error when name begin with a number
  3831. (c = clan_search(atoi(message))) != NULL) {
  3832. if (sd->clanspy == c->id) {
  3833. sd->clanspy = 0;
  3834. sprintf(atcmd_output, msg_txt(sd, 1500), c->name); // No longer spying on the %s clan.
  3835. clif_displaymessage(fd, atcmd_output);
  3836. }
  3837. else {
  3838. sd->clanspy = c->id;
  3839. sprintf(atcmd_output, msg_txt(sd, 1501), c->name); // Spying on the %s clan.
  3840. clif_displaymessage(fd, atcmd_output);
  3841. }
  3842. }
  3843. else {
  3844. clif_displaymessage(fd, msg_txt(sd, 1502)); // Incorrect clan name/ID.
  3845. return -1;
  3846. }
  3847. return 0;
  3848. }
  3849. /*==========================================
  3850. * @repairall [Valaris]
  3851. *------------------------------------------*/
  3852. ACMD_FUNC(repairall)
  3853. {
  3854. int count, i;
  3855. nullpo_retr(-1, sd);
  3856. count = 0;
  3857. for (i = 0; i < MAX_INVENTORY; i++) {
  3858. if (sd->inventory.u.items_inventory[i].nameid && sd->inventory.u.items_inventory[i].attribute == 1) {
  3859. sd->inventory.u.items_inventory[i].attribute = 0;
  3860. clif_produceeffect(sd, 0, sd->inventory.u.items_inventory[i].nameid);
  3861. count++;
  3862. }
  3863. }
  3864. if (count > 0) {
  3865. clif_misceffect(&sd->bl, 3);
  3866. clif_equiplist(sd);
  3867. clif_displaymessage(fd, msg_txt(sd,107)); // All items have been repaired.
  3868. } else {
  3869. clif_displaymessage(fd, msg_txt(sd,108)); // No item need to be repaired.
  3870. return -1;
  3871. }
  3872. return 0;
  3873. }
  3874. /*==========================================
  3875. * @nuke [Valaris]
  3876. *------------------------------------------*/
  3877. ACMD_FUNC(nuke)
  3878. {
  3879. struct map_session_data *pl_sd;
  3880. nullpo_retr(-1, sd);
  3881. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3882. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3883. clif_displaymessage(fd, msg_txt(sd,1128)); // Please enter a player name (usage: @nuke <char name>).
  3884. return -1;
  3885. }
  3886. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) != NULL) {
  3887. if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kill only lower or same GM level
  3888. skill_castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
  3889. clif_displaymessage(fd, msg_txt(sd,109)); // Player has been nuked!
  3890. } else {
  3891. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  3892. return -1;
  3893. }
  3894. } else {
  3895. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  3896. return -1;
  3897. }
  3898. return 0;
  3899. }
  3900. /*==========================================
  3901. * @tonpc
  3902. *------------------------------------------*/
  3903. ACMD_FUNC(tonpc)
  3904. {
  3905. char npcname[NPC_NAME_LENGTH];
  3906. struct npc_data *nd;
  3907. nullpo_retr(-1, sd);
  3908. memset(npcname, 0, sizeof(npcname));
  3909. if (!message || !*message || sscanf(message, "%49[^\n]", npcname) < 1) {
  3910. clif_displaymessage(fd, msg_txt(sd,1129)); // Please enter a NPC name (usage: @tonpc <NPC_name>).
  3911. return -1;
  3912. }
  3913. if ((nd = npc_name2id(npcname)) != NULL) {
  3914. if (pc_setpos(sd, map_id2index(nd->bl.m), nd->bl.x, nd->bl.y, CLR_TELEPORT) == SETPOS_OK)
  3915. clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
  3916. else
  3917. return -1;
  3918. } else {
  3919. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  3920. return -1;
  3921. }
  3922. return 0;
  3923. }
  3924. /*==========================================
  3925. *
  3926. *------------------------------------------*/
  3927. ACMD_FUNC(shownpc)
  3928. {
  3929. char NPCname[NPC_NAME_LENGTH];
  3930. nullpo_retr(-1, sd);
  3931. memset(NPCname, '\0', sizeof(NPCname));
  3932. if (!message || !*message || sscanf(message, "%49[^\n]", NPCname) < 1) {
  3933. clif_displaymessage(fd, msg_txt(sd,1130)); // Please enter a NPC name (usage: @enablenpc <NPC_name>).
  3934. return -1;
  3935. }
  3936. if (npc_name2id(NPCname) != NULL) {
  3937. npc_enable(NPCname, 1);
  3938. clif_displaymessage(fd, msg_txt(sd,110)); // Npc Enabled.
  3939. } else {
  3940. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  3941. return -1;
  3942. }
  3943. return 0;
  3944. }
  3945. /*==========================================
  3946. *
  3947. *------------------------------------------*/
  3948. ACMD_FUNC(hidenpc)
  3949. {
  3950. char NPCname[NPC_NAME_LENGTH];
  3951. nullpo_retr(-1, sd);
  3952. memset(NPCname, '\0', sizeof(NPCname));
  3953. if (!message || !*message || sscanf(message, "%49[^\n]", NPCname) < 1) {
  3954. clif_displaymessage(fd, msg_txt(sd,1131)); // Please enter a NPC name (usage: @hidenpc <NPC_name>).
  3955. return -1;
  3956. }
  3957. if (npc_name2id(NPCname) == NULL) {
  3958. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  3959. return -1;
  3960. }
  3961. npc_enable(NPCname, 0);
  3962. clif_displaymessage(fd, msg_txt(sd,112)); // Npc Disabled.
  3963. return 0;
  3964. }
  3965. ACMD_FUNC(loadnpc)
  3966. {
  3967. if (!message || !*message) {
  3968. clif_displaymessage(fd, msg_txt(sd,1132)); // Please enter a script file name (usage: @loadnpc <file name>).
  3969. return -1;
  3970. }
  3971. if (!npc_addsrcfile(message, true)) {
  3972. clif_displaymessage(fd, msg_txt(sd,261));
  3973. return -1;
  3974. }
  3975. npc_read_event_script();
  3976. clif_displaymessage(fd, msg_txt(sd,262));
  3977. return 0;
  3978. }
  3979. ACMD_FUNC(unloadnpc)
  3980. {
  3981. struct npc_data *nd;
  3982. char NPCname[NPC_NAME_LENGTH];
  3983. nullpo_retr(-1, sd);
  3984. memset(NPCname, '\0', sizeof(NPCname));
  3985. if (!message || !*message || sscanf(message, "%49[^\n]", NPCname) < 1) {
  3986. clif_displaymessage(fd, msg_txt(sd,1133)); // Please enter a NPC name (usage: @unloadnpc <NPC_name>).
  3987. return -1;
  3988. }
  3989. if ((nd = npc_name2id(NPCname)) == NULL) {
  3990. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  3991. return -1;
  3992. }
  3993. npc_unload_duplicates(nd);
  3994. npc_unload(nd,true);
  3995. npc_read_event_script();
  3996. clif_displaymessage(fd, msg_txt(sd,112)); // Npc Disabled.
  3997. return 0;
  3998. }
  3999. ACMD_FUNC(reloadnpc) {
  4000. if (!message || !*message) {
  4001. clif_displaymessage(fd, msg_txt(sd,733)); // Please enter a NPC name (usage: @reloadnpc <NPC_name>).
  4002. return -1;
  4003. }
  4004. if (npc_unloadfile(message))
  4005. clif_displaymessage(fd, msg_txt(sd,1386)); // File unloaded. Be aware that mapflags and monsters spawned directly are not removed.
  4006. if (!npc_addsrcfile(message, true)) {
  4007. clif_displaymessage(fd, msg_txt(sd,261));
  4008. return -1;
  4009. }
  4010. npc_read_event_script();
  4011. clif_displaymessage(fd, msg_txt(sd,262));
  4012. return 0;
  4013. }
  4014. /*==========================================
  4015. * time in txt for time command (by [Yor])
  4016. *------------------------------------------*/
  4017. char* txt_time(unsigned int duration)
  4018. {
  4019. int days, hours, minutes, seconds;
  4020. char temp[CHAT_SIZE_MAX];
  4021. static char temp1[CHAT_SIZE_MAX];
  4022. memset(temp, '\0', sizeof(temp));
  4023. memset(temp1, '\0', sizeof(temp1));
  4024. days = duration / (60 * 60 * 24);
  4025. duration = duration - (60 * 60 * 24 * days);
  4026. hours = duration / (60 * 60);
  4027. duration = duration - (60 * 60 * hours);
  4028. minutes = duration / 60;
  4029. seconds = duration - (60 * minutes);
  4030. if (days == 1)
  4031. sprintf(temp, msg_txt(NULL,219), days); // %d day
  4032. else if (days > 1)
  4033. sprintf(temp, msg_txt(NULL,220), days); // %d days
  4034. if (hours == 1)
  4035. sprintf(temp1, msg_txt(NULL,221), temp, hours); // %s %d hour
  4036. else if (hours > 1)
  4037. sprintf(temp1, msg_txt(NULL,222), temp, hours); // %s %d hours
  4038. if (minutes < 2)
  4039. sprintf(temp, msg_txt(NULL,223), temp1, minutes); // %s %d minute
  4040. else
  4041. sprintf(temp, msg_txt(NULL,224), temp1, minutes); // %s %d minutes
  4042. if (seconds == 1)
  4043. sprintf(temp1, msg_txt(NULL,225), temp, seconds); // %s and %d second
  4044. else if (seconds > 1)
  4045. sprintf(temp1, msg_txt(NULL,226), temp, seconds); // %s and %d seconds
  4046. return temp1;
  4047. }
  4048. /*==========================================
  4049. * @time/@date/@serverdate/@servertime: Display the date/time of the server (by [Yor]
  4050. * Calculation management of GM modification (@day/@night GM commands) is done
  4051. *------------------------------------------*/
  4052. ACMD_FUNC(servertime)
  4053. {
  4054. const struct TimerData * timer_data;
  4055. time_t time_server; // variable for number of seconds (used with time() function)
  4056. struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
  4057. char temp[CHAT_SIZE_MAX];
  4058. nullpo_retr(-1, sd);
  4059. memset(temp, '\0', sizeof(temp));
  4060. time(&time_server); // get time in seconds since 1/1/1970
  4061. datetime = localtime(&time_server); // convert seconds in structure
  4062. // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
  4063. strftime(temp, sizeof(temp)-1, msg_txt(sd,230), datetime); // Server time (normal time): %A, %B %d %Y %X.
  4064. clif_displaymessage(fd, temp);
  4065. if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
  4066. if (night_flag == 0)
  4067. clif_displaymessage(fd, msg_txt(sd,231)); // Game time: The game is in permanent daylight.
  4068. else
  4069. clif_displaymessage(fd, msg_txt(sd,232)); // Game time: The game is in permanent night.
  4070. } else if (battle_config.night_duration == 0)
  4071. if (night_flag == 1) { // we start with night
  4072. timer_data = get_timer(day_timer_tid);
  4073. sprintf(temp, msg_txt(sd,233), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is in night for %s.
  4074. clif_displaymessage(fd, temp);
  4075. clif_displaymessage(fd, msg_txt(sd,234)); // Game time: After, the game will be in permanent daylight.
  4076. } else
  4077. clif_displaymessage(fd, msg_txt(sd,231)); // Game time: The game is in permanent daylight.
  4078. else if (battle_config.day_duration == 0)
  4079. if (night_flag == 0) { // we start with day
  4080. timer_data = get_timer(night_timer_tid);
  4081. sprintf(temp, msg_txt(sd,235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is in daylight for %s.
  4082. clif_displaymessage(fd, temp);
  4083. clif_displaymessage(fd, msg_txt(sd,236)); // Game time: After, the game will be in permanent night.
  4084. } else
  4085. clif_displaymessage(fd, msg_txt(sd,232)); // Game time: The game is in permanent night.
  4086. else {
  4087. const struct TimerData * timer_data2;
  4088. if (night_flag == 0) {
  4089. timer_data = get_timer(night_timer_tid);
  4090. timer_data2 = get_timer(day_timer_tid);
  4091. sprintf(temp, msg_txt(sd,235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is in daylight for %s.
  4092. clif_displaymessage(fd, temp);
  4093. if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0)
  4094. sprintf(temp, msg_txt(sd,237), txt_time(DIFF_TICK(timer_data->interval,DIFF_TICK(timer_data->tick,timer_data2->tick)) / 1000)); // Game time: After, the game will be in night for %s.
  4095. else
  4096. sprintf(temp, msg_txt(sd,237), txt_time(DIFF_TICK(timer_data2->tick,timer_data->tick)/1000)); // Game time: After, the game will be in night for %s.
  4097. clif_displaymessage(fd, temp);
  4098. sprintf(temp, msg_txt(sd,238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  4099. clif_displaymessage(fd, temp);
  4100. } else {
  4101. timer_data = get_timer(day_timer_tid);
  4102. timer_data2 = get_timer(night_timer_tid);
  4103. sprintf(temp, msg_txt(sd,233), txt_time(DIFF_TICK(timer_data->tick,gettick()) / 1000)); // Game time: The game is in night for %s.
  4104. clif_displaymessage(fd, temp);
  4105. if (DIFF_TICK(timer_data->tick,timer_data2->tick) > 0)
  4106. sprintf(temp, msg_txt(sd,239), txt_time((timer_data->interval - DIFF_TICK(timer_data->tick, timer_data2->tick)) / 1000)); // Game time: After, the game will be in daylight for %s.
  4107. else
  4108. sprintf(temp, msg_txt(sd,239), txt_time(DIFF_TICK(timer_data2->tick, timer_data->tick) / 1000)); // Game time: After, the game will be in daylight for %s.
  4109. clif_displaymessage(fd, temp);
  4110. sprintf(temp, msg_txt(sd,238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  4111. clif_displaymessage(fd, temp);
  4112. }
  4113. }
  4114. return 0;
  4115. }
  4116. /*==========================================
  4117. * @jail <char_name> by [Yor]
  4118. * Special warp! No check with nowarp and nowarpto flag
  4119. *------------------------------------------*/
  4120. ACMD_FUNC(jail)
  4121. {
  4122. struct map_session_data *pl_sd;
  4123. int x, y;
  4124. unsigned short m_index;
  4125. nullpo_retr(-1, sd);
  4126. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4127. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4128. clif_displaymessage(fd, msg_txt(sd,1134)); // Please enter a player name (usage: @jail <char_name>).
  4129. return -1;
  4130. }
  4131. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL) {
  4132. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4133. return -1;
  4134. }
  4135. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) { // you can jail only lower or same GM
  4136. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4137. return -1;
  4138. }
  4139. if (pl_sd->sc.data[SC_JAILED]) {
  4140. clif_displaymessage(fd, msg_txt(sd,118)); // Player warped in jails.
  4141. return -1;
  4142. }
  4143. switch(rnd() % 2) { //Jail Locations
  4144. case 0:
  4145. m_index = mapindex_name2id(MAP_JAIL);
  4146. x = 24;
  4147. y = 75;
  4148. break;
  4149. default:
  4150. m_index = mapindex_name2id(MAP_JAIL);
  4151. x = 49;
  4152. y = 75;
  4153. break;
  4154. }
  4155. //Duration of INT_MAX to specify infinity.
  4156. sc_start4(NULL,&pl_sd->bl,SC_JAILED,100,INT_MAX,m_index,x,y,1000);
  4157. clif_displaymessage(pl_sd->fd, msg_txt(sd,117)); // GM has send you in jails.
  4158. clif_displaymessage(fd, msg_txt(sd,118)); // Player warped in jails.
  4159. return 0;
  4160. }
  4161. /*==========================================
  4162. * @unjail/@discharge <char_name> by [Yor]
  4163. * Special warp! No check with nowarp and nowarpto flag
  4164. *------------------------------------------*/
  4165. ACMD_FUNC(unjail)
  4166. {
  4167. struct map_session_data *pl_sd;
  4168. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4169. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4170. clif_displaymessage(fd, msg_txt(sd,1135)); // Please enter a player name (usage: @unjail/@discharge <char_name>).
  4171. return -1;
  4172. }
  4173. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL) {
  4174. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4175. return -1;
  4176. }
  4177. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) { // you can jail only lower or same GM
  4178. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4179. return -1;
  4180. }
  4181. if (!pl_sd->sc.data[SC_JAILED]) {
  4182. clif_displaymessage(fd, msg_txt(sd,119)); // This player is not in jails.
  4183. return -1;
  4184. }
  4185. //Reset jail time to 1 sec.
  4186. sc_start(NULL,&pl_sd->bl,SC_JAILED,100,1,1000);
  4187. clif_displaymessage(pl_sd->fd, msg_txt(sd,120)); // A GM has discharged you from jail.
  4188. clif_displaymessage(fd, msg_txt(sd,121)); // Player unjailed.
  4189. return 0;
  4190. }
  4191. ACMD_FUNC(jailfor) {
  4192. struct map_session_data *pl_sd = NULL;
  4193. char * modif_p;
  4194. int jailtime = 0,x,y;
  4195. short m_index = 0;
  4196. nullpo_retr(-1, sd);
  4197. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4198. if (!message || !*message || sscanf(message, "%255s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
  4199. clif_displaymessage(fd, msg_txt(sd,400)); //Usage: @jailfor <time> <character name>
  4200. return -1;
  4201. }
  4202. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  4203. modif_p = atcmd_output;
  4204. jailtime = (int)solve_time(modif_p)/60; // Change to minutes
  4205. if (jailtime == 0) {
  4206. clif_displaymessage(fd, msg_txt(sd,1136)); // Invalid time for jail command.
  4207. clif_displaymessage(fd, msg_txt(sd,702)); // Time parameter format is +/-<value> to alter. y/a = Year, m = Month, d/j = Day, h = Hour, n/mn = Minute, s = Second.
  4208. return -1;
  4209. }
  4210. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL) {
  4211. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4212. return -1;
  4213. }
  4214. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  4215. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4216. return -1;
  4217. }
  4218. // Added by Coltaro
  4219. if(pl_sd->sc.data[SC_JAILED] && pl_sd->sc.data[SC_JAILED]->val1 != INT_MAX) { // Update the player's jail time
  4220. jailtime += pl_sd->sc.data[SC_JAILED]->val1;
  4221. if (jailtime <= 0) {
  4222. jailtime = 0;
  4223. clif_displaymessage(pl_sd->fd, msg_txt(sd,120)); // GM has discharge you.
  4224. clif_displaymessage(fd, msg_txt(sd,121)); // Player unjailed
  4225. } else {
  4226. int year = 0, month = 0, day = 0, hour = 0, minute = 0, second = 0;
  4227. char timestr[21];
  4228. time_t now=time(NULL);
  4229. split_time(jailtime*60,&year,&month,&day,&hour,&minute,&second);
  4230. sprintf(atcmd_output,msg_txt(sd,402),msg_txt(sd,1137),year,month,day,hour,minute); // %s in jail for %d years, %d months, %d days, %d hours and %d minutes
  4231. clif_displaymessage(pl_sd->fd, atcmd_output);
  4232. sprintf(atcmd_output,msg_txt(sd,402),msg_txt(sd,1138),year,month,day,hour,minute); // This player is now in jail for %d years, %d months, %d days, %d hours and %d minutes
  4233. clif_displaymessage(fd, atcmd_output);
  4234. timestamp2string(timestr,20,now+jailtime*60,"%Y-%m-%d %H:%M");
  4235. sprintf(atcmd_output,"Release date is: %s",timestr);
  4236. clif_displaymessage(pl_sd->fd, atcmd_output);
  4237. clif_displaymessage(fd, atcmd_output);
  4238. }
  4239. } else if (jailtime < 0) {
  4240. clif_displaymessage(fd, msg_txt(sd,1136));
  4241. return -1;
  4242. }
  4243. // Jail locations, add more as you wish.
  4244. switch(rnd()%2) {
  4245. case 1: // Jail #1
  4246. m_index = mapindex_name2id(MAP_JAIL);
  4247. x = 49; y = 75;
  4248. break;
  4249. default: // Default Jail
  4250. m_index = mapindex_name2id(MAP_JAIL);
  4251. x = 24; y = 75;
  4252. break;
  4253. }
  4254. 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).
  4255. return 0;
  4256. }
  4257. //By Coltaro
  4258. ACMD_FUNC(jailtime){
  4259. int year, month, day, hour, minute, second;
  4260. char timestr[21];
  4261. time_t now = time(NULL);
  4262. nullpo_retr(-1, sd);
  4263. if (!sd->sc.data[SC_JAILED]) {
  4264. clif_displaymessage(fd, msg_txt(sd,1139)); // You are not in jail.
  4265. return -1;
  4266. }
  4267. if (sd->sc.data[SC_JAILED]->val1 == INT_MAX) {
  4268. clif_displaymessage(fd, msg_txt(sd,1140)); // You have been jailed indefinitely.
  4269. return 0;
  4270. }
  4271. if (sd->sc.data[SC_JAILED]->val1 <= 0) { // Was not jailed with @jailfor (maybe @jail? or warped there? or got recalled?)
  4272. clif_displaymessage(fd, msg_txt(sd,1141)); // You have been jailed for an unknown amount of time.
  4273. return -1;
  4274. }
  4275. // Get remaining jail time
  4276. split_time(sd->sc.data[SC_JAILED]->val1*60,&year,&month,&day,&hour,&minute,&second);
  4277. sprintf(atcmd_output,msg_txt(sd,402),msg_txt(sd,1142),year,month,day,hour,minute); // You will remain in jail for %d years, %d months, %d days, %d hours and %d minutes
  4278. clif_displaymessage(fd, atcmd_output);
  4279. timestamp2string(timestr,20,now+sd->sc.data[SC_JAILED]->val1*60,"%Y-%m-%d %H:%M");
  4280. sprintf(atcmd_output,"Release date is: %s",timestr);
  4281. clif_displaymessage(fd, atcmd_output);
  4282. return 0;
  4283. }
  4284. /*==========================================
  4285. * @disguise <mob_id> by [Valaris] (simplified by [Yor])
  4286. *------------------------------------------*/
  4287. ACMD_FUNC(disguise)
  4288. {
  4289. int id = 0;
  4290. nullpo_retr(-1, sd);
  4291. if (!message || !*message) {
  4292. clif_displaymessage(fd, msg_txt(sd,1143)); // Please enter a Monster/NPC name/ID (usage: @disguise <name/ID>).
  4293. return -1;
  4294. }
  4295. if ((id = atoi(message)) > 0)
  4296. { //Acquired an ID
  4297. if (!mobdb_checkid(id) && !npcdb_checkid(id))
  4298. id = 0; //Invalid id for either mobs or npcs.
  4299. } else { //Acquired a Name
  4300. if ((id = mobdb_searchname(message)) == 0)
  4301. {
  4302. struct npc_data* nd = npc_name2id(message);
  4303. if (nd != NULL)
  4304. id = nd->class_;
  4305. }
  4306. }
  4307. if (id == 0)
  4308. {
  4309. clif_displaymessage(fd, msg_txt(sd,123)); // Invalid Monster/NPC name/ID specified.
  4310. return -1;
  4311. }
  4312. if(pc_isriding(sd))
  4313. {
  4314. clif_displaymessage(fd, msg_txt(sd,1144)); // Character cannot be disguised while mounted.
  4315. return -1;
  4316. }
  4317. if (sd->sc.data[SC_MONSTER_TRANSFORM] || sd->sc.data[SC_ACTIVE_MONSTER_TRANSFORM]) {
  4318. clif_displaymessage(fd, msg_txt(sd,730)); // Character cannot be disguised while in monster transform.
  4319. return -1;
  4320. }
  4321. pc_disguise(sd, id);
  4322. clif_displaymessage(fd, msg_txt(sd,122)); // Disguise applied.
  4323. return 0;
  4324. }
  4325. /*==========================================
  4326. * DisguiseAll
  4327. *------------------------------------------*/
  4328. ACMD_FUNC(disguiseall)
  4329. {
  4330. int mob_id=0;
  4331. struct map_session_data *pl_sd;
  4332. struct s_mapiterator* iter;
  4333. nullpo_retr(-1, sd);
  4334. if (!message || !*message) {
  4335. clif_displaymessage(fd, msg_txt(sd,1145)); // Please enter a Monster/NPC name/ID (usage: @disguiseall <name/ID>).
  4336. return -1;
  4337. }
  4338. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name beginning by a number)
  4339. mob_id = atoi(message);
  4340. if (!mobdb_checkid(mob_id) && !npcdb_checkid(mob_id)) { //if mob or npc...
  4341. clif_displaymessage(fd, msg_txt(sd,123)); // Monster/NPC name/id not found.
  4342. return -1;
  4343. }
  4344. iter = mapit_getallusers();
  4345. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4346. pc_disguise(pl_sd, mob_id);
  4347. mapit_free(iter);
  4348. clif_displaymessage(fd, msg_txt(sd,122)); // Disguise applied.
  4349. return 0;
  4350. }
  4351. /*==========================================
  4352. * DisguiseGuild
  4353. *------------------------------------------*/
  4354. ACMD_FUNC(disguiseguild)
  4355. {
  4356. int id = 0, i;
  4357. char monster[NAME_LENGTH], guild[NAME_LENGTH];
  4358. struct guild *g;
  4359. memset(monster, '\0', sizeof(monster));
  4360. memset(guild, '\0', sizeof(guild));
  4361. if( !message || !*message || sscanf(message, "%23[^,], %23[^\r\n]", monster, guild) < 2 ) {
  4362. clif_displaymessage(fd, msg_txt(sd,1146)); // Please enter a mob name/ID and guild name/ID (usage: @disguiseguild <mob name/ID>, <guild name/ID>).
  4363. return -1;
  4364. }
  4365. if( (id = atoi(monster)) > 0 ) {
  4366. if( !mobdb_checkid(id) && !npcdb_checkid(id) )
  4367. id = 0;
  4368. } else {
  4369. if( (id = mobdb_searchname(monster)) == 0 ) {
  4370. struct npc_data* nd = npc_name2id(monster);
  4371. if( nd != NULL )
  4372. id = nd->class_;
  4373. }
  4374. }
  4375. if( id == 0 ) {
  4376. clif_displaymessage(fd, msg_txt(sd,123)); // Monster/NPC name/id hasn't been found.
  4377. return -1;
  4378. }
  4379. if( (g = guild_searchname(guild)) == NULL && (g = guild_search(atoi(guild))) == NULL ) {
  4380. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  4381. return -1;
  4382. }
  4383. for( i = 0; i < g->max_member; i++ ){
  4384. struct map_session_data *pl_sd;
  4385. if( (pl_sd = g->member[i].sd) && !pc_isriding(pl_sd) )
  4386. pc_disguise(pl_sd, id);
  4387. }
  4388. clif_displaymessage(fd, msg_txt(sd,122)); // Disguise applied.
  4389. return 0;
  4390. }
  4391. /*==========================================
  4392. * @undisguise by [Yor]
  4393. *------------------------------------------*/
  4394. ACMD_FUNC(undisguise)
  4395. {
  4396. nullpo_retr(-1, sd);
  4397. if (sd->disguise) {
  4398. pc_disguise(sd, 0);
  4399. clif_displaymessage(fd, msg_txt(sd,124)); // Undisguise applied.
  4400. } else {
  4401. clif_displaymessage(fd, msg_txt(sd,125)); // You're not disguised.
  4402. return -1;
  4403. }
  4404. return 0;
  4405. }
  4406. /*==========================================
  4407. * UndisguiseAll
  4408. *------------------------------------------*/
  4409. ACMD_FUNC(undisguiseall)
  4410. {
  4411. struct map_session_data *pl_sd;
  4412. struct s_mapiterator* iter;
  4413. nullpo_retr(-1, sd);
  4414. iter = mapit_getallusers();
  4415. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4416. if( pl_sd->disguise )
  4417. pc_disguise(pl_sd, 0);
  4418. mapit_free(iter);
  4419. clif_displaymessage(fd, msg_txt(sd,124)); // Undisguise applied.
  4420. return 0;
  4421. }
  4422. /*==========================================
  4423. * UndisguiseGuild
  4424. *------------------------------------------*/
  4425. ACMD_FUNC(undisguiseguild)
  4426. {
  4427. char guild_name[NAME_LENGTH];
  4428. struct guild *g;
  4429. int i;
  4430. nullpo_retr(-1, sd);
  4431. memset(guild_name, '\0', sizeof(guild_name));
  4432. if(!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  4433. clif_displaymessage(fd, msg_txt(sd,1147)); // Please enter guild name/ID (usage: @undisguiseguild <guild name/ID>).
  4434. return -1;
  4435. }
  4436. if( (g = guild_searchname(guild_name)) == NULL && (g = guild_search(atoi(message))) == NULL ) {
  4437. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  4438. return -1;
  4439. }
  4440. for(i = 0; i < g->max_member; i++){
  4441. struct map_session_data *pl_sd;
  4442. if( (pl_sd = g->member[i].sd) && pl_sd->disguise )
  4443. pc_disguise(pl_sd, 0);
  4444. }
  4445. clif_displaymessage(fd, msg_txt(sd,124)); // Undisguise applied.
  4446. return 0;
  4447. }
  4448. /*==========================================
  4449. * @exp by [Skotlex]
  4450. *------------------------------------------*/
  4451. ACMD_FUNC(exp)
  4452. {
  4453. char output[CHAT_SIZE_MAX];
  4454. double nextb, nextj;
  4455. nullpo_retr(-1, sd);
  4456. memset(output, '\0', sizeof(output));
  4457. nextb = pc_nextbaseexp(sd);
  4458. if (nextb)
  4459. nextb = sd->status.base_exp*100.0/nextb;
  4460. nextj = pc_nextjobexp(sd);
  4461. if (nextj)
  4462. nextj = sd->status.job_exp*100.0/nextj;
  4463. sprintf(output, msg_txt(sd,1148), sd->status.base_level, nextb, sd->status.job_level, nextj); // Base Level: %d (%.3f%%) | Job Level: %d (%.3f%%)
  4464. clif_displaymessage(fd, output);
  4465. return 0;
  4466. }
  4467. /*==========================================
  4468. * @broadcast by [Valaris]
  4469. *------------------------------------------*/
  4470. ACMD_FUNC(broadcast)
  4471. {
  4472. nullpo_retr(-1, sd);
  4473. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4474. if (!message || !*message) {
  4475. clif_displaymessage(fd, msg_txt(sd,1149)); // Please enter a message (usage: @broadcast <message>).
  4476. return -1;
  4477. }
  4478. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4479. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT);
  4480. return 0;
  4481. }
  4482. /*==========================================
  4483. * @localbroadcast by [Valaris]
  4484. *------------------------------------------*/
  4485. ACMD_FUNC(localbroadcast)
  4486. {
  4487. nullpo_retr(-1, sd);
  4488. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4489. if (!message || !*message) {
  4490. clif_displaymessage(fd, msg_txt(sd,1150)); // Please enter a message (usage: @localbroadcast <message>).
  4491. return -1;
  4492. }
  4493. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4494. clif_broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT, ALL_SAMEMAP);
  4495. return 0;
  4496. }
  4497. /*==========================================
  4498. * @email <actual@email> <new@email> by [Yor]
  4499. *------------------------------------------*/
  4500. ACMD_FUNC(email)
  4501. {
  4502. char actual_email[100];
  4503. char new_email[100];
  4504. nullpo_retr(-1, sd);
  4505. memset(actual_email, '\0', sizeof(actual_email));
  4506. memset(new_email, '\0', sizeof(new_email));
  4507. if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
  4508. clif_displaymessage(fd, msg_txt(sd,1151)); // Please enter 2 emails (usage: @email <actual@email> <new@email>).
  4509. return -1;
  4510. }
  4511. if (e_mail_check(actual_email) == 0) {
  4512. clif_displaymessage(fd, msg_txt(sd,144)); // Invalid actual email. If you have default e-mail, give a@a.com.
  4513. return -1;
  4514. } else if (e_mail_check(new_email) == 0) {
  4515. clif_displaymessage(fd, msg_txt(sd,145)); // Invalid new email. Please enter a real e-mail.
  4516. return -1;
  4517. } else if (strcmpi(new_email, "a@a.com") == 0) {
  4518. clif_displaymessage(fd, msg_txt(sd,146)); // New email must be a real e-mail.
  4519. return -1;
  4520. } else if (strcmpi(actual_email, new_email) == 0) {
  4521. clif_displaymessage(fd, msg_txt(sd,147)); // New email must be different of the actual e-mail.
  4522. return -1;
  4523. }
  4524. chrif_changeemail(sd->status.account_id, actual_email, new_email);
  4525. clif_displaymessage(fd, msg_txt(sd,148)); // Information sent to login-server via char-server.
  4526. return 0;
  4527. }
  4528. /*==========================================
  4529. *@effect
  4530. *------------------------------------------*/
  4531. ACMD_FUNC(effect)
  4532. {
  4533. int type = 0, flag = 0;
  4534. nullpo_retr(-1, sd);
  4535. if (!message || !*message || sscanf(message, "%11d", &type) < 1) {
  4536. clif_displaymessage(fd, msg_txt(sd,1152)); // Please enter an effect number (usage: @effect <effect number>).
  4537. return -1;
  4538. }
  4539. clif_specialeffect(&sd->bl, type, (send_target)flag);
  4540. clif_displaymessage(fd, msg_txt(sd,229)); // Your effect has changed.
  4541. return 0;
  4542. }
  4543. /*==========================================
  4544. * @killer by MouseJstr
  4545. * enable killing players even when not in pvp
  4546. *------------------------------------------*/
  4547. ACMD_FUNC(killer)
  4548. {
  4549. nullpo_retr(-1, sd);
  4550. sd->state.killer = !sd->state.killer;
  4551. if(sd->state.killer)
  4552. clif_displaymessage(fd, msg_txt(sd,241));
  4553. else {
  4554. clif_displaymessage(fd, msg_txt(sd,292));
  4555. pc_stop_attack(sd);
  4556. }
  4557. return 0;
  4558. }
  4559. /*==========================================
  4560. * @killable by MouseJstr
  4561. * enable other people killing you
  4562. *------------------------------------------*/
  4563. ACMD_FUNC(killable)
  4564. {
  4565. nullpo_retr(-1, sd);
  4566. sd->state.killable = !sd->state.killable;
  4567. if(sd->state.killable)
  4568. clif_displaymessage(fd, msg_txt(sd,242));
  4569. else {
  4570. clif_displaymessage(fd, msg_txt(sd,288));
  4571. map_foreachinrange(atcommand_stopattack,&sd->bl, AREA_SIZE, BL_CHAR, sd->bl.id);
  4572. }
  4573. return 0;
  4574. }
  4575. /*==========================================
  4576. * @skillon by MouseJstr
  4577. * turn skills on for the map
  4578. *------------------------------------------*/
  4579. ACMD_FUNC(skillon)
  4580. {
  4581. nullpo_retr(-1, sd);
  4582. map[sd->bl.m].flag.noskill = 0;
  4583. clif_displaymessage(fd, msg_txt(sd,244));
  4584. return 0;
  4585. }
  4586. /*==========================================
  4587. * @skilloff by MouseJstr
  4588. * Turn skills off on the map
  4589. *------------------------------------------*/
  4590. ACMD_FUNC(skilloff)
  4591. {
  4592. nullpo_retr(-1, sd);
  4593. map[sd->bl.m].flag.noskill = 1;
  4594. clif_displaymessage(fd, msg_txt(sd,243));
  4595. return 0;
  4596. }
  4597. /*==========================================
  4598. * @npcmove by MouseJstr
  4599. * move a npc
  4600. *------------------------------------------*/
  4601. ACMD_FUNC(npcmove)
  4602. {
  4603. short x = 0, y = 0, m;
  4604. struct npc_data *nd = 0;
  4605. char npc_name[NPC_NAME_LENGTH];
  4606. nullpo_retr(-1, sd);
  4607. memset(npc_name, '\0', sizeof npc_name);
  4608. if (!message || !*message || sscanf(message, "%6hd %6hd %49[^\n]", &x, &y, npc_name) < 3) {
  4609. clif_displaymessage(fd, msg_txt(sd,1153)); // Usage: @npcmove <X> <Y> <npc_name>
  4610. return -1;
  4611. }
  4612. if ((nd = npc_name2id(npc_name)) == NULL)
  4613. {
  4614. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  4615. return -1;
  4616. }
  4617. if ((m=nd->bl.m) < 0 || nd->bl.prev == NULL)
  4618. {
  4619. clif_displaymessage(fd, msg_txt(sd,1154)); // NPC is not on this map.
  4620. return -1; //Not on a map.
  4621. }
  4622. x = cap_value(x, 0, map[m].xs-1);
  4623. y = cap_value(y, 0, map[m].ys-1);
  4624. map_foreachinrange(clif_outsight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  4625. map_moveblock(&nd->bl, x, y, gettick());
  4626. map_foreachinrange(clif_insight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  4627. clif_displaymessage(fd, msg_txt(sd,1155)); // NPC moved.
  4628. return 0;
  4629. }
  4630. /*==========================================
  4631. * @addwarp by MouseJstr
  4632. * Create a new static warp point.
  4633. *------------------------------------------*/
  4634. ACMD_FUNC(addwarp)
  4635. {
  4636. char mapname[MAP_NAME_LENGTH_EXT], warpname[NPC_NAME_LENGTH];
  4637. short x,y;
  4638. unsigned short m;
  4639. struct npc_data* nd;
  4640. nullpo_retr(-1, sd);
  4641. memset(warpname, '\0', sizeof(warpname));
  4642. if (!message || !*message || sscanf(message, "%15s %6hd %6hd %49[^\n]", mapname, &x, &y, warpname) < 4) {
  4643. clif_displaymessage(fd, msg_txt(sd,1156)); // Usage: @addwarp <mapname> <X> <Y> <npc name>
  4644. return -1;
  4645. }
  4646. m = mapindex_name2id(mapname);
  4647. if( m == 0 )
  4648. {
  4649. sprintf(atcmd_output, msg_txt(sd,1157), mapname); // Unknown map '%s'.
  4650. clif_displaymessage(fd, atcmd_output);
  4651. return -1;
  4652. }
  4653. nd = npc_add_warp(warpname, sd->bl.m, sd->bl.x, sd->bl.y, 2, 2, m, x, y);
  4654. if( nd == NULL )
  4655. return -1;
  4656. sprintf(atcmd_output, msg_txt(sd,1158), nd->exname); // New warp NPC '%s' created.
  4657. clif_displaymessage(fd, atcmd_output);
  4658. return 0;
  4659. }
  4660. /*==========================================
  4661. * @follow by [MouseJstr]
  4662. * Follow a player .. staying no more then 5 spaces away
  4663. *------------------------------------------*/
  4664. ACMD_FUNC(follow)
  4665. {
  4666. struct map_session_data *pl_sd = NULL;
  4667. nullpo_retr(-1, sd);
  4668. if (!message || !*message) {
  4669. if (sd->followtarget == -1)
  4670. return -1;
  4671. pc_stop_following (sd);
  4672. clif_displaymessage(fd, msg_txt(sd,1159)); // Follow mode OFF.
  4673. return 0;
  4674. }
  4675. if ( (pl_sd = map_nick2sd((char *)message,true)) == NULL )
  4676. {
  4677. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4678. return -1;
  4679. }
  4680. if (sd->followtarget == pl_sd->bl.id) {
  4681. pc_stop_following (sd);
  4682. clif_displaymessage(fd, msg_txt(sd,1159)); // Follow mode OFF.
  4683. } else {
  4684. pc_follow(sd, pl_sd->bl.id);
  4685. clif_displaymessage(fd, msg_txt(sd,1160)); // Follow mode ON.
  4686. }
  4687. return 0;
  4688. }
  4689. /*==========================================
  4690. * @dropall by [MouseJstr] and [Xantara]
  4691. * Drops all your possession on the ground based on item type
  4692. *------------------------------------------*/
  4693. ACMD_FUNC(dropall)
  4694. {
  4695. int8 type = -1;
  4696. uint16 i, count = 0, count2 = 0;
  4697. struct item_data *item_data = NULL;
  4698. nullpo_retr(-1, sd);
  4699. if( message[0] ) {
  4700. type = atoi(message);
  4701. if( type != -1 && type != IT_HEALING && type != IT_USABLE && type != IT_ETC && type != IT_WEAPON &&
  4702. type != IT_ARMOR && type != IT_CARD && type != IT_PETEGG && type != IT_PETARMOR && type != IT_AMMO )
  4703. {
  4704. clif_displaymessage(fd, msg_txt(sd,1492));
  4705. clif_displaymessage(fd, msg_txt(sd,1493));
  4706. return -1;
  4707. }
  4708. }
  4709. for( i = 0; i < MAX_INVENTORY; i++ ) {
  4710. if( sd->inventory.u.items_inventory[i].amount ) {
  4711. if( (item_data = itemdb_exists(sd->inventory.u.items_inventory[i].nameid)) == NULL ) {
  4712. ShowDebug("Non-existant item %d on dropall list (account_id: %d, char_id: %d)\n", sd->inventory.u.items_inventory[i].nameid, sd->status.account_id, sd->status.char_id);
  4713. continue;
  4714. }
  4715. if( !pc_candrop(sd,&sd->inventory.u.items_inventory[i]) )
  4716. continue;
  4717. if( type == -1 || type == (uint8)item_data->type ) {
  4718. if( sd->inventory.u.items_inventory[i].equip != 0 )
  4719. pc_unequipitem(sd, i, 3);
  4720. if(pc_dropitem(sd, i, sd->inventory.u.items_inventory[i].amount))
  4721. count += sd->inventory.u.items_inventory[i].amount;
  4722. else count2 += sd->inventory.u.items_inventory[i].amount;
  4723. }
  4724. }
  4725. }
  4726. sprintf(atcmd_output, msg_txt(sd,1494), count,count2); // %d items are dropped (%d skipped)!
  4727. clif_displaymessage(fd, atcmd_output);
  4728. return 0;
  4729. }
  4730. /*==========================================
  4731. * @storeall by [MouseJstr]
  4732. * Put everything into storage
  4733. *------------------------------------------*/
  4734. ACMD_FUNC(storeall)
  4735. {
  4736. int i;
  4737. nullpo_retr(-1, sd);
  4738. if (sd->state.storage_flag != 1)
  4739. { //Open storage.
  4740. if( storage_storageopen(sd) == 1 ) {
  4741. clif_displaymessage(fd, msg_txt(sd,1161)); // You currently cannot open your storage.
  4742. return -1;
  4743. }
  4744. }
  4745. for (i = 0; i < MAX_INVENTORY; i++) {
  4746. if (sd->inventory.u.items_inventory[i].amount) {
  4747. if(sd->inventory.u.items_inventory[i].equip != 0)
  4748. pc_unequipitem(sd, i, 3);
  4749. storage_storageadd(sd, &sd->storage, i, sd->inventory.u.items_inventory[i].amount);
  4750. }
  4751. }
  4752. storage_storageclose(sd);
  4753. clif_displaymessage(fd, msg_txt(sd,1162)); // All items stored.
  4754. return 0;
  4755. }
  4756. ACMD_FUNC(clearstorage)
  4757. {
  4758. int i, j;
  4759. nullpo_retr(-1, sd);
  4760. if (sd->state.storage_flag == 1) {
  4761. clif_displaymessage(fd, msg_txt(sd,250));
  4762. return -1;
  4763. }
  4764. if (sd->state.storage_flag == 3) {
  4765. clif_displaymessage(fd, msg_txt(sd,250));
  4766. return -1;
  4767. }
  4768. j = sd->storage.amount;
  4769. for (i = 0; i < j; ++i) {
  4770. storage_delitem(sd, &sd->storage, i, sd->storage.u.items_storage[i].amount);
  4771. }
  4772. sd->state.storage_flag = 1;
  4773. storage_storageclose(sd);
  4774. clif_displaymessage(fd, msg_txt(sd,1394)); // Your storage was cleaned.
  4775. return 0;
  4776. }
  4777. ACMD_FUNC(cleargstorage)
  4778. {
  4779. int i, j;
  4780. struct guild *g;
  4781. struct s_storage *gstorage;
  4782. nullpo_retr(-1, sd);
  4783. g = sd->guild;
  4784. if (g == NULL) {
  4785. clif_displaymessage(fd, msg_txt(sd,43));
  4786. return -1;
  4787. }
  4788. if (sd->state.storage_flag == 1) {
  4789. clif_displaymessage(fd, msg_txt(sd,250));
  4790. return -1;
  4791. }
  4792. if (sd->state.storage_flag == 2) {
  4793. clif_displaymessage(fd, msg_txt(sd,251));
  4794. return -1;
  4795. }
  4796. if (sd->state.storage_flag == 3) {
  4797. clif_displaymessage(fd, msg_txt(sd,250));
  4798. return -1;
  4799. }
  4800. gstorage = guild2storage2(sd->status.guild_id);
  4801. if (gstorage == NULL) { // Doesn't have opened @gstorage yet, so we skip the deletion since *shouldn't* have any item there.
  4802. return -1;
  4803. }
  4804. j = gstorage->amount;
  4805. gstorage->lock = true; // Lock @gstorage: do not allow any item to be retrieved or stored from any guild member
  4806. for (i = 0; i < j; ++i) {
  4807. storage_guild_delitem(sd, gstorage, i, gstorage->u.items_guild[i].amount);
  4808. }
  4809. storage_guild_storageclose(sd);
  4810. gstorage->lock = false; // Cleaning done, release lock
  4811. clif_displaymessage(fd, msg_txt(sd,1395)); // Your guild storage was cleaned.
  4812. return 0;
  4813. }
  4814. ACMD_FUNC(clearcart)
  4815. {
  4816. int i;
  4817. nullpo_retr(-1, sd);
  4818. if (pc_iscarton(sd) == 0) {
  4819. clif_displaymessage(fd, msg_txt(sd,1396)); // You do not have a cart to be cleaned.
  4820. return -1;
  4821. }
  4822. if (sd->state.vending == 1) { //Somehow...
  4823. return -1;
  4824. }
  4825. for (i = 0; i < MAX_CART; i++) {
  4826. if (sd->cart.u.items_cart[i].nameid > 0)
  4827. pc_cart_delitem(sd, i, sd->cart.u.items_cart[i].amount, 1, LOG_TYPE_OTHER);
  4828. }
  4829. clif_clearcart(fd);
  4830. clif_updatestatus(sd,SP_CARTINFO);
  4831. clif_displaymessage(fd, msg_txt(sd,1397)); // Your cart was cleaned.
  4832. return 0;
  4833. }
  4834. /*==========================================
  4835. * @skillid by [MouseJstr]
  4836. * lookup a skill by name
  4837. *------------------------------------------*/
  4838. #define MAX_SKILLID_PARTIAL_RESULTS 5
  4839. #define MAX_SKILLID_PARTIAL_RESULTS_LEN 74 // "skill " (6) + "%d:" (up to 5) + "%s" (up to 30) + " (%s)" (up to 33)
  4840. ACMD_FUNC(skillid) {
  4841. int skillen, i, found = 0;
  4842. DBIterator* iter;
  4843. DBKey key;
  4844. DBData *data;
  4845. char partials[MAX_SKILLID_PARTIAL_RESULTS][MAX_SKILLID_PARTIAL_RESULTS_LEN];
  4846. nullpo_retr(-1, sd);
  4847. if (!message || !*message) {
  4848. clif_displaymessage(fd, msg_txt(sd,1163)); // Please enter a skill name to look up (usage: @skillid <skill name>).
  4849. return -1;
  4850. }
  4851. skillen = strlen(message);
  4852. iter = db_iterator(skilldb_name2id);
  4853. for( data = iter->first(iter,&key); iter->exists(iter); data = iter->next(iter,&key) ) {
  4854. int idx = skill_get_index(db_data2i(data));
  4855. if (strnicmp(key.str, message, skillen) == 0 || strnicmp(skill_db[idx]->desc, message, skillen) == 0) {
  4856. sprintf(atcmd_output, msg_txt(sd,1164), db_data2i(data), skill_db[idx]->desc, key.str); // skill %d: %s (%s)
  4857. clif_displaymessage(fd, atcmd_output);
  4858. } else if ( found < MAX_SKILLID_PARTIAL_RESULTS && ( stristr(key.str,message) || stristr(skill_db[idx]->desc,message) ) ) {
  4859. snprintf(partials[found++], MAX_SKILLID_PARTIAL_RESULTS_LEN, msg_txt(sd,1164), db_data2i(data), skill_db[idx]->desc, key.str);
  4860. }
  4861. }
  4862. dbi_destroy(iter);
  4863. if( found ) {
  4864. sprintf(atcmd_output, msg_txt(sd,1398), found); // -- Displaying first %d partial matches
  4865. clif_displaymessage(fd, atcmd_output);
  4866. }
  4867. for(i = 0; i < found; i++) { /* partials */
  4868. clif_displaymessage(fd, partials[i]);
  4869. }
  4870. return 0;
  4871. }
  4872. /*==========================================
  4873. * @useskill by [MouseJstr]
  4874. * A way of using skills without having to find them in the skills menu
  4875. *------------------------------------------*/
  4876. ACMD_FUNC(useskill)
  4877. {
  4878. struct map_session_data *pl_sd = NULL;
  4879. struct block_list *bl;
  4880. uint16 skill_id;
  4881. uint16 skill_lv;
  4882. char target[100];
  4883. nullpo_retr(-1, sd);
  4884. if(!message || !*message || sscanf(message, "%6hu %6hu %23[^\n]", &skill_id, &skill_lv, target) != 3) {
  4885. clif_displaymessage(fd, msg_txt(sd,1165)); // Usage: @useskill <skill ID> <skill level> <target>
  4886. return -1;
  4887. }
  4888. if(!strcmp(target,"self")) pl_sd = sd; //quick keyword
  4889. else if ( (pl_sd = map_nick2sd(target,true)) == NULL ){
  4890. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4891. return -1;
  4892. }
  4893. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  4894. {
  4895. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4896. return -1;
  4897. }
  4898. if (SKILL_CHK_HOMUN(skill_id)
  4899. && sd->hd && hom_is_active(sd->hd)) // (If used with @useskill, put the homunc as dest)
  4900. bl = &sd->hd->bl;
  4901. else
  4902. bl = &sd->bl;
  4903. if (skill_get_inf(skill_id)&INF_GROUND_SKILL)
  4904. unit_skilluse_pos(bl, pl_sd->bl.x, pl_sd->bl.y, skill_id, skill_lv);
  4905. else
  4906. unit_skilluse_id(bl, pl_sd->bl.id, skill_id, skill_lv);
  4907. return 0;
  4908. }
  4909. /*==========================================
  4910. * @displayskill by [Skotlex]
  4911. * Debug command to locate new skill IDs. It sends the
  4912. * three possible skill-effect packets to the area.
  4913. *------------------------------------------*/
  4914. ACMD_FUNC(displayskill)
  4915. {
  4916. struct status_data * status;
  4917. unsigned int tick;
  4918. uint16 skill_id;
  4919. uint16 skill_lv = 1;
  4920. nullpo_retr(-1, sd);
  4921. if (!message || !*message || sscanf(message, "%6hu %6hu", &skill_id, &skill_lv) < 1)
  4922. {
  4923. clif_displaymessage(fd, msg_txt(sd,1166)); // Usage: @displayskill <skill ID> {<skill level>}
  4924. return -1;
  4925. }
  4926. status = status_get_status_data(&sd->bl);
  4927. tick = gettick();
  4928. clif_skill_damage(&sd->bl,&sd->bl, tick, status->amotion, status->dmotion, 1, 1, skill_id, skill_lv, DMG_SPLASH);
  4929. clif_skill_nodamage(&sd->bl, &sd->bl, skill_id, skill_lv, 1);
  4930. clif_skill_poseffect(&sd->bl, skill_id, skill_lv, sd->bl.x, sd->bl.y, tick);
  4931. return 0;
  4932. }
  4933. /*==========================================
  4934. * @skilltree by [MouseJstr]
  4935. * prints the skill tree for a player required to get to a skill
  4936. *------------------------------------------*/
  4937. ACMD_FUNC(skilltree)
  4938. {
  4939. struct map_session_data *pl_sd = NULL;
  4940. uint16 skill_id;
  4941. int meets, i, j, c=0;
  4942. char target[NAME_LENGTH];
  4943. struct skill_tree_entry *ent;
  4944. nullpo_retr(-1, sd);
  4945. if(!message || !*message || sscanf(message, "%6hu %23[^\r\n]", &skill_id, target) != 2) {
  4946. clif_displaymessage(fd, msg_txt(sd,1167)); // Usage: @skilltree <skill ID> <target>
  4947. return -1;
  4948. }
  4949. if ( (pl_sd = map_nick2sd(target,true)) == NULL )
  4950. {
  4951. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4952. return -1;
  4953. }
  4954. i = pc_calc_skilltree_normalize_job(pl_sd);
  4955. c = pc_mapid2jobid(i, pl_sd->status.sex);
  4956. sprintf(atcmd_output, msg_txt(sd,1168), job_name(c), pc_checkskill(pl_sd, NV_BASIC)); // Player is using %s skill tree (%d basic points).
  4957. clif_displaymessage(fd, atcmd_output);
  4958. c = pc_class2idx(c);
  4959. ARR_FIND( 0, MAX_SKILL_TREE, j, skill_tree[c][j].skill_id == 0 || skill_tree[c][j].skill_id == skill_id );
  4960. if( j == MAX_SKILL_TREE || skill_tree[c][j].skill_id == 0 )
  4961. {
  4962. clif_displaymessage(fd, msg_txt(sd,1169)); // The player cannot use that skill.
  4963. return 0;
  4964. }
  4965. ent = &skill_tree[c][j];
  4966. meets = 1;
  4967. for(j=0;j<MAX_PC_SKILL_REQUIRE;j++)
  4968. {
  4969. if( ent->need[j].skill_id && pc_checkskill(sd,ent->need[j].skill_id) < ent->need[j].skill_lv)
  4970. {
  4971. sprintf(atcmd_output, msg_txt(sd,1170), ent->need[j].skill_lv, skill_db[skill_get_index(ent->need[j].skill_id)]->desc); // Player requires level %d of skill %s.
  4972. clif_displaymessage(fd, atcmd_output);
  4973. meets = 0;
  4974. }
  4975. }
  4976. if (meets == 1) {
  4977. clif_displaymessage(fd, msg_txt(sd,1171)); // The player meets all the requirements for that skill.
  4978. }
  4979. return 0;
  4980. }
  4981. // Hand a ring with partners name on it to this char
  4982. void getring (struct map_session_data* sd)
  4983. {
  4984. char flag = 0;
  4985. unsigned short item_id;
  4986. struct item item_tmp;
  4987. item_id = (sd->status.sex) ? WEDDING_RING_M : WEDDING_RING_F;
  4988. memset(&item_tmp, 0, sizeof(item_tmp));
  4989. item_tmp.nameid = item_id;
  4990. item_tmp.identify = 1;
  4991. item_tmp.card[0] = 255;
  4992. item_tmp.card[2] = sd->status.partner_id;
  4993. item_tmp.card[3] = sd->status.partner_id >> 16;
  4994. if((flag = pc_additem(sd,&item_tmp,1,LOG_TYPE_COMMAND))) {
  4995. clif_additem(sd,0,0,flag);
  4996. map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,4,0);
  4997. }
  4998. }
  4999. /*==========================================
  5000. * @marry by [MouseJstr], fixed by Lupus
  5001. * Marry two players
  5002. *------------------------------------------*/
  5003. ACMD_FUNC(marry)
  5004. {
  5005. struct map_session_data *pl_sd = NULL;
  5006. char player_name[NAME_LENGTH] = "";
  5007. nullpo_retr(-1, sd);
  5008. if (!message || !*message || sscanf(message, "%23[^\n]", player_name) != 1) {
  5009. clif_displaymessage(fd, msg_txt(sd,1172)); // Usage: @marry <char name>
  5010. return -1;
  5011. }
  5012. if ((pl_sd = map_nick2sd(player_name,false)) == NULL) {
  5013. clif_displaymessage(fd, msg_txt(sd,3));
  5014. return -1;
  5015. }
  5016. if (pc_marriage(sd, pl_sd)) {
  5017. clif_displaymessage(fd, msg_txt(sd,1173)); // They are married... wish them well.
  5018. clif_wedding_effect(&pl_sd->bl); //wedding effect and music [Lupus]
  5019. if( pl_sd->bl.m != sd->bl.m )
  5020. clif_wedding_effect(&sd->bl);
  5021. getring(sd); // Auto-give named rings (Aru)
  5022. getring(pl_sd);
  5023. return 0;
  5024. }
  5025. clif_displaymessage(fd, msg_txt(sd,1174)); // The two cannot wed because one is either a baby or already married.
  5026. return -1;
  5027. }
  5028. /*==========================================
  5029. * @divorce by [MouseJstr], fixed by [Lupus]
  5030. * divorce two players
  5031. *------------------------------------------*/
  5032. ACMD_FUNC(divorce)
  5033. {
  5034. nullpo_retr(-1, sd);
  5035. if (!pc_divorce(sd)) {
  5036. sprintf(atcmd_output, msg_txt(sd,1175), sd->status.name); // '%s' is not married.
  5037. clif_displaymessage(fd, atcmd_output);
  5038. return -1;
  5039. }
  5040. sprintf(atcmd_output, msg_txt(sd,1176), sd->status.name); // '%s' and his/her partner are now divorced.
  5041. clif_displaymessage(fd, atcmd_output);
  5042. return 0;
  5043. }
  5044. /*==========================================
  5045. * @changelook by [Celest]
  5046. *------------------------------------------*/
  5047. ACMD_FUNC(changelook)
  5048. {
  5049. int i, j = 0, k = 0;
  5050. int pos[8] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES,LOOK_ROBE, LOOK_BODY2 };
  5051. if((i = sscanf(message, "%11d %11d", &j, &k)) < 1) {
  5052. clif_displaymessage(fd, msg_txt(sd,1177)); // Usage: @changelook {<position>} <view id>
  5053. clif_displaymessage(fd, msg_txt(sd,1178)); // Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield 6-Shoes 7-Robe 8-Body
  5054. return -1;
  5055. } else if ( i == 2 ) {
  5056. if (j < 1 || j > 8)
  5057. j = 1;
  5058. j = pos[j - 1];
  5059. } else if( i == 1 ) { // position not defined, use HEAD_TOP as default
  5060. k = j; // swap
  5061. j = LOOK_HEAD_TOP;
  5062. }
  5063. clif_changelook(&sd->bl,j,k);
  5064. return 0;
  5065. }
  5066. /*==========================================
  5067. * @autotrade by durf [Lupus] [Paradox924X]
  5068. * Turns on/off Autotrade for a specific player
  5069. *------------------------------------------*/
  5070. ACMD_FUNC(autotrade) {
  5071. nullpo_retr(-1, sd);
  5072. if( map[sd->bl.m].flag.autotrade != battle_config.autotrade_mapflag ) {
  5073. clif_displaymessage(fd, msg_txt(sd,1179)); // Autotrade is not allowed on this map.
  5074. return -1;
  5075. }
  5076. if( pc_isdead(sd) ) {
  5077. clif_displaymessage(fd, msg_txt(sd,1180)); // You cannot autotrade when dead.
  5078. return -1;
  5079. }
  5080. if( !sd->state.vending && !sd->state.buyingstore ) { //check if player is vending or buying
  5081. clif_displaymessage(fd, msg_txt(sd,549)); // "You should have a shop open to use @autotrade."
  5082. return -1;
  5083. }
  5084. sd->state.autotrade = 1;
  5085. if (battle_config.autotrade_monsterignore)
  5086. sd->state.monster_ignore = 1;
  5087. if( sd->state.vending ){
  5088. if( Sql_Query( mmysql_handle, "UPDATE `%s` SET `autotrade` = 1 WHERE `id` = %d;", vendings_db, sd->vender_id ) != SQL_SUCCESS ){
  5089. Sql_ShowDebug( mmysql_handle );
  5090. }
  5091. }else if( sd->state.buyingstore ){
  5092. if( Sql_Query( mmysql_handle, "UPDATE `%s` SET `autotrade` = 1 WHERE `id` = %d;", buyingstores_db, sd->buyer_id ) != SQL_SUCCESS ){
  5093. Sql_ShowDebug( mmysql_handle );
  5094. }
  5095. }
  5096. if( battle_config.at_timeout ) {
  5097. int timeout = atoi(message);
  5098. status_change_start(NULL,&sd->bl, SC_AUTOTRADE, 10000, 0, 0, 0, 0, ((timeout > 0) ? min(timeout,battle_config.at_timeout) : battle_config.at_timeout) * 60000, SCSTART_NONE);
  5099. }
  5100. channel_pcquit(sd,0xF); //leave all chan
  5101. clif_authfail_fd(sd->fd, 15);
  5102. chrif_save(sd,3);
  5103. return 0;
  5104. }
  5105. /*==========================================
  5106. * @changegm by durf (changed by Lupus)
  5107. * Changes Master of your Guild to a specified guild member
  5108. *------------------------------------------*/
  5109. ACMD_FUNC(changegm)
  5110. {
  5111. struct guild *g;
  5112. struct map_session_data *pl_sd;
  5113. nullpo_retr(-1, sd);
  5114. if (sd->status.guild_id == 0 || (g = sd->guild) == NULL || strcmp(g->master,sd->status.name)) {
  5115. clif_displaymessage(fd, msg_txt(sd,1181)); // You need to be a Guild Master to use this command.
  5116. return -1;
  5117. }
  5118. if( map[sd->bl.m].flag.guildlock || map[sd->bl.m].flag.gvg_castle ) {
  5119. clif_displaymessage(fd, msg_txt(sd,1182)); // You cannot change guild leaders on this map.
  5120. return -1;
  5121. }
  5122. if( !message[0] ) {
  5123. clif_displaymessage(fd, msg_txt(sd,1183)); // Usage: @changegm <guild_member_name>
  5124. return -1;
  5125. }
  5126. if((pl_sd=map_nick2sd((char *) message,false)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) {
  5127. clif_displaymessage(fd, msg_txt(sd,1184)); // Target character must be online and be a guild member.
  5128. return -1;
  5129. }
  5130. guild_gm_change(sd->status.guild_id, pl_sd);
  5131. return 0;
  5132. }
  5133. /*==========================================
  5134. * @changeleader by Skotlex
  5135. * Changes the leader of a party.
  5136. *------------------------------------------*/
  5137. ACMD_FUNC(changeleader)
  5138. {
  5139. nullpo_retr(-1, sd);
  5140. if( !message[0] )
  5141. {
  5142. clif_displaymessage(fd, msg_txt(sd,1185)); // Usage: @changeleader <party_member_name>
  5143. return -1;
  5144. }
  5145. if (party_changeleader(sd, map_nick2sd((char *) message,false),NULL))
  5146. return 0;
  5147. return -1;
  5148. }
  5149. /*==========================================
  5150. * @partyoption by Skotlex
  5151. * Used to change the item share setting of a party.
  5152. *------------------------------------------*/
  5153. ACMD_FUNC(partyoption)
  5154. {
  5155. struct party_data *p;
  5156. int mi, option;
  5157. char w1[16], w2[16];
  5158. nullpo_retr(-1, sd);
  5159. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
  5160. {
  5161. clif_displaymessage(fd, msg_txt(sd,282));
  5162. return -1;
  5163. }
  5164. ARR_FIND( 0, MAX_PARTY, mi, p->data[mi].sd == sd );
  5165. if (mi == MAX_PARTY)
  5166. return -1; //Shouldn't happen
  5167. if (!p->party.member[mi].leader)
  5168. {
  5169. clif_displaymessage(fd, msg_txt(sd,282));
  5170. return -1;
  5171. }
  5172. if(!message || !*message || sscanf(message, "%15s %15s", w1, w2) < 2)
  5173. {
  5174. clif_displaymessage(fd, msg_txt(sd,1186)); // Usage: @partyoption <pickup share: yes/no> <item distribution: yes/no>
  5175. return -1;
  5176. }
  5177. option = (config_switch(w1)?1:0)|(config_switch(w2)?2:0);
  5178. //Change item share type.
  5179. if (option != p->party.item)
  5180. party_changeoption(sd, p->party.exp, option);
  5181. else
  5182. clif_displaymessage(fd, msg_txt(sd,286));
  5183. return 0;
  5184. }
  5185. /*==========================================
  5186. * @autoloot by Upa-Kun
  5187. * Turns on/off AutoLoot for a specific player
  5188. *------------------------------------------*/
  5189. ACMD_FUNC(autoloot)
  5190. {
  5191. int rate;
  5192. nullpo_retr(-1, sd);
  5193. // autoloot command without value
  5194. if(!message || !*message)
  5195. {
  5196. if (sd->state.autoloot)
  5197. rate = 0;
  5198. else
  5199. rate = 10000;
  5200. } else {
  5201. double drate;
  5202. drate = atof(message);
  5203. rate = (int)(drate*100);
  5204. }
  5205. if (rate < 0) rate = 0;
  5206. if (rate > 10000) rate = 10000;
  5207. sd->state.autoloot = rate;
  5208. if (sd->state.autoloot) {
  5209. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1187),((double)sd->state.autoloot)/100.); // Autolooting items with drop rates of %0.02f%% and below.
  5210. clif_displaymessage(fd, atcmd_output);
  5211. }else
  5212. clif_displaymessage(fd, msg_txt(sd,1188)); // Autoloot is now off.
  5213. return 0;
  5214. }
  5215. /*==========================================
  5216. * @alootid
  5217. *------------------------------------------*/
  5218. ACMD_FUNC(autolootitem)
  5219. {
  5220. struct item_data *item_data = NULL;
  5221. int i;
  5222. int action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset
  5223. nullpo_retr(-1, sd);
  5224. if (message && *message) {
  5225. if (message[0] == '+') {
  5226. message++;
  5227. action = 1;
  5228. }
  5229. else if (message[0] == '-') {
  5230. message++;
  5231. action = 2;
  5232. }
  5233. else if (!strcmp(message,"reset"))
  5234. action = 4;
  5235. }
  5236. if (action < 3) // add or remove
  5237. {
  5238. if ((item_data = itemdb_exists(atoi(message))) == NULL)
  5239. item_data = itemdb_searchname(message);
  5240. if (!item_data) {
  5241. // No items founds in the DB with Id or Name
  5242. clif_displaymessage(fd, msg_txt(sd,1189)); // Item not found.
  5243. return -1;
  5244. }
  5245. }
  5246. switch(action) {
  5247. case 1:
  5248. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
  5249. if (i != AUTOLOOTITEM_SIZE) {
  5250. clif_displaymessage(fd, msg_txt(sd,1190)); // You're already autolooting this item.
  5251. return -1;
  5252. }
  5253. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == 0);
  5254. if (i == AUTOLOOTITEM_SIZE) {
  5255. clif_displaymessage(fd, msg_txt(sd,1191)); // Your autolootitem list is full. Remove some items first with @autolootid -<item name or ID>.
  5256. return -1;
  5257. }
  5258. sd->state.autolootid[i] = item_data->nameid; // Autoloot Activated
  5259. sprintf(atcmd_output, msg_txt(sd,1192), item_data->name, item_data->jname, item_data->nameid); // Autolooting item: '%s'/'%s' {%d}
  5260. clif_displaymessage(fd, atcmd_output);
  5261. sd->state.autolooting = 1;
  5262. break;
  5263. case 2:
  5264. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
  5265. if (i == AUTOLOOTITEM_SIZE) {
  5266. clif_displaymessage(fd, msg_txt(sd,1193)); // You're currently not autolooting this item.
  5267. return -1;
  5268. }
  5269. sd->state.autolootid[i] = 0;
  5270. sprintf(atcmd_output, msg_txt(sd,1194), item_data->name, item_data->jname, item_data->nameid); // Removed item: '%s'/'%s' {%d} from your autolootitem list.
  5271. clif_displaymessage(fd, atcmd_output);
  5272. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
  5273. if (i == AUTOLOOTITEM_SIZE) {
  5274. sd->state.autolooting = 0;
  5275. }
  5276. break;
  5277. case 3:
  5278. sprintf(atcmd_output, msg_txt(sd,1195), AUTOLOOTITEM_SIZE); // You can have %d items on your autolootitem list.
  5279. clif_displaymessage(fd, atcmd_output);
  5280. clif_displaymessage(fd, msg_txt(sd,1196)); // To add an item to the list, use "@alootid +<item name or ID>". To remove an item, use "@alootid -<item name or ID>".
  5281. clif_displaymessage(fd, msg_txt(sd,1197)); // "@alootid reset" will clear your autolootitem list.
  5282. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
  5283. if (i == AUTOLOOTITEM_SIZE) {
  5284. clif_displaymessage(fd, msg_txt(sd,1198)); // Your autolootitem list is empty.
  5285. } else {
  5286. clif_displaymessage(fd, msg_txt(sd,1199)); // Items on your autolootitem list:
  5287. for(i = 0; i < AUTOLOOTITEM_SIZE; i++)
  5288. {
  5289. if (sd->state.autolootid[i] == 0)
  5290. continue;
  5291. if (!(item_data = itemdb_exists(sd->state.autolootid[i]))) {
  5292. 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);
  5293. continue;
  5294. }
  5295. sprintf(atcmd_output, "'%s'/'%s' {%hu}", item_data->name, item_data->jname, item_data->nameid);
  5296. clif_displaymessage(fd, atcmd_output);
  5297. }
  5298. }
  5299. break;
  5300. case 4:
  5301. memset(sd->state.autolootid, 0, sizeof(sd->state.autolootid));
  5302. clif_displaymessage(fd, msg_txt(sd,1200)); // Your autolootitem list has been reset.
  5303. sd->state.autolooting = 0;
  5304. break;
  5305. }
  5306. return 0;
  5307. }
  5308. /*==========================================
  5309. * @autoloottype
  5310. * Flags:
  5311. * 1: IT_HEALING, 2: IT_UNKNOWN, 4: IT_USABLE, 8: IT_ETC,
  5312. * 16: IT_ARMOR, 32: IT_WEAPON, 64: IT_CARD, 128: IT_PETEGG,
  5313. * 256: IT_PETARMOR, 512: IT_UNKNOWN2, 1024: IT_AMMO, 2048: IT_DELAYCONSUME
  5314. * 262144: IT_CASH
  5315. *------------------------------------------
  5316. * Credits:
  5317. * chriser
  5318. * Aleos
  5319. *------------------------------------------*/
  5320. ACMD_FUNC(autoloottype)
  5321. {
  5322. uint8 action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset
  5323. enum item_types type = -1;
  5324. int ITEM_MAX = 1533;
  5325. nullpo_retr(-1, sd);
  5326. if (message && *message) {
  5327. if (message[0] == '+') {
  5328. message++;
  5329. action = 1;
  5330. }
  5331. else if (message[0] == '-') {
  5332. message++;
  5333. action = 2;
  5334. }
  5335. else if (!strcmp(message,"reset"))
  5336. action = 4;
  5337. }
  5338. if (action < 3) { // add or remove
  5339. if ((strncmp(message, "healing", 3) == 0) || (atoi(message) == 0))
  5340. type = IT_HEALING;
  5341. else if ((strncmp(message, "usable", 3) == 0) || (atoi(message) == 2))
  5342. type = IT_USABLE;
  5343. else if ((strncmp(message, "etc", 3) == 0) || (atoi(message) == 3))
  5344. type = IT_ETC;
  5345. else if ((strncmp(message, "armor", 3) == 0) || (atoi(message) == 4))
  5346. type = IT_ARMOR;
  5347. else if ((strncmp(message, "weapon", 3) == 0) || (atoi(message) == 5))
  5348. type = IT_WEAPON;
  5349. else if ((strncmp(message, "card", 3) == 0) || (atoi(message) == 6))
  5350. type = IT_CARD;
  5351. else if ((strncmp(message, "petegg", 4) == 0) || (atoi(message) == 7))
  5352. type = IT_PETEGG;
  5353. else if ((strncmp(message, "petarmor", 4) == 0) || (atoi(message) == 8))
  5354. type = IT_PETARMOR;
  5355. else if ((strncmp(message, "ammo", 3) == 0) || (atoi(message) == 10))
  5356. type = IT_AMMO;
  5357. else {
  5358. clif_displaymessage(fd, msg_txt(sd,1480)); // Item type not found.
  5359. return -1;
  5360. }
  5361. }
  5362. switch (action) {
  5363. case 1:
  5364. if (sd->state.autoloottype&(1<<type)) {
  5365. clif_displaymessage(fd, msg_txt(sd,1481)); // You're already autolooting this item type.
  5366. return -1;
  5367. }
  5368. if (sd->state.autoloottype == ITEM_MAX) {
  5369. clif_displaymessage(fd, msg_txt(sd,1482)); // Your autoloottype list has all item types. You can remove some items with @autoloottype -<type name or ID>.
  5370. return -1;
  5371. }
  5372. sd->state.autoloottype |= (1<<type); // Stores the type
  5373. sprintf(atcmd_output, msg_txt(sd,1483), itemdb_typename(type), type); // Autolooting item type: '%s' {%d}
  5374. clif_displaymessage(fd, atcmd_output);
  5375. break;
  5376. case 2:
  5377. if (!(sd->state.autoloottype&(1<<type))) {
  5378. clif_displaymessage(fd, msg_txt(sd,1484)); // You're currently not autolooting this item type.
  5379. return -1;
  5380. }
  5381. sd->state.autoloottype &= ~(1<<type);
  5382. sprintf(atcmd_output, msg_txt(sd,1485), itemdb_typename(type), type); // Removed item type: '%s' {%d} from your autoloottype list.
  5383. clif_displaymessage(fd, atcmd_output);
  5384. break;
  5385. case 3:
  5386. clif_displaymessage(fd, msg_txt(sd,1486)); // To add an item type to the list, use "@aloottype +<type name or ID>". To remove an item type, use "@aloottype -<type name or ID>".
  5387. clif_displaymessage(fd, msg_txt(sd,1487)); // Type List: healing = 0, usable = 2, etc = 3, armor = 4, weapon = 5, card = 6, petegg = 7, petarmor = 8, ammo = 10
  5388. clif_displaymessage(fd, msg_txt(sd,1488)); // "@aloottype reset" will clear your autoloottype list.
  5389. if (sd->state.autoloottype == 0)
  5390. clif_displaymessage(fd, msg_txt(sd,1489)); // Your autoloottype list is empty.
  5391. else {
  5392. uint8 i = 0;
  5393. clif_displaymessage(fd, msg_txt(sd,1490)); // Item types on your autoloottype list:
  5394. while (i < IT_MAX) {
  5395. if (sd->state.autoloottype&(1<<i)) {
  5396. sprintf(atcmd_output, " '%s' {%d}", itemdb_typename(i), i);
  5397. clif_displaymessage(fd, atcmd_output);
  5398. }
  5399. i++;
  5400. }
  5401. }
  5402. break;
  5403. case 4:
  5404. sd->state.autoloottype = 0;
  5405. clif_displaymessage(fd, msg_txt(sd,1491)); // Your autoloottype list has been reset.
  5406. break;
  5407. }
  5408. return 0;
  5409. }
  5410. /**
  5411. * No longer available, keeping here just in case it's back someday. [Ind]
  5412. **/
  5413. /*==========================================
  5414. * It is made to rain.
  5415. *------------------------------------------*/
  5416. //ACMD_FUNC(rain)
  5417. //{
  5418. // nullpo_retr(-1, sd);
  5419. // if (map[sd->bl.m].flag.rain) {
  5420. // map[sd->bl.m].flag.rain=0;
  5421. // clif_weather(sd->bl.m);
  5422. // clif_displaymessage(fd, msg_txt(sd,1201)); // The rain has stopped.
  5423. // } else {
  5424. // map[sd->bl.m].flag.rain=1;
  5425. // clif_weather(sd->bl.m);
  5426. // clif_displaymessage(fd, msg_txt(sd,1202)); // It has started to rain.
  5427. // }
  5428. // return 0;
  5429. //}
  5430. /*==========================================
  5431. * It is made to snow.
  5432. *------------------------------------------*/
  5433. ACMD_FUNC(snow)
  5434. {
  5435. nullpo_retr(-1, sd);
  5436. if (map[sd->bl.m].flag.snow) {
  5437. map[sd->bl.m].flag.snow=0;
  5438. clif_weather(sd->bl.m);
  5439. clif_displaymessage(fd, msg_txt(sd,1203)); // Snow has stopped falling.
  5440. } else {
  5441. map[sd->bl.m].flag.snow=1;
  5442. clif_weather(sd->bl.m);
  5443. clif_displaymessage(fd, msg_txt(sd,1204)); // It has started to snow.
  5444. }
  5445. return 0;
  5446. }
  5447. /*==========================================
  5448. * Cherry tree snowstorm is made to fall. (Sakura)
  5449. *------------------------------------------*/
  5450. ACMD_FUNC(sakura)
  5451. {
  5452. nullpo_retr(-1, sd);
  5453. if (map[sd->bl.m].flag.sakura) {
  5454. map[sd->bl.m].flag.sakura=0;
  5455. clif_weather(sd->bl.m);
  5456. clif_displaymessage(fd, msg_txt(sd,1205)); // Cherry tree leaves no longer fall.
  5457. } else {
  5458. map[sd->bl.m].flag.sakura=1;
  5459. clif_weather(sd->bl.m);
  5460. clif_displaymessage(fd, msg_txt(sd,1206)); // Cherry tree leaves have begun to fall.
  5461. }
  5462. return 0;
  5463. }
  5464. /*==========================================
  5465. * Clouds appear.
  5466. *------------------------------------------*/
  5467. ACMD_FUNC(clouds)
  5468. {
  5469. nullpo_retr(-1, sd);
  5470. if (map[sd->bl.m].flag.clouds) {
  5471. map[sd->bl.m].flag.clouds=0;
  5472. clif_weather(sd->bl.m);
  5473. clif_displaymessage(fd, msg_txt(sd,1207)); // The clouds has disappear.
  5474. } else {
  5475. map[sd->bl.m].flag.clouds=1;
  5476. clif_weather(sd->bl.m);
  5477. clif_displaymessage(fd, msg_txt(sd,1208)); // Clouds appear.
  5478. }
  5479. return 0;
  5480. }
  5481. /*==========================================
  5482. * Different type of clouds using effect 516
  5483. *------------------------------------------*/
  5484. ACMD_FUNC(clouds2)
  5485. {
  5486. nullpo_retr(-1, sd);
  5487. if (map[sd->bl.m].flag.clouds2) {
  5488. map[sd->bl.m].flag.clouds2=0;
  5489. clif_weather(sd->bl.m);
  5490. clif_displaymessage(fd, msg_txt(sd,1209)); // The alternative clouds disappear.
  5491. } else {
  5492. map[sd->bl.m].flag.clouds2=1;
  5493. clif_weather(sd->bl.m);
  5494. clif_displaymessage(fd, msg_txt(sd,1210)); // Alternative clouds appear.
  5495. }
  5496. return 0;
  5497. }
  5498. /*==========================================
  5499. * Fog hangs over.
  5500. *------------------------------------------*/
  5501. ACMD_FUNC(fog)
  5502. {
  5503. nullpo_retr(-1, sd);
  5504. if (map[sd->bl.m].flag.fog) {
  5505. map[sd->bl.m].flag.fog=0;
  5506. clif_weather(sd->bl.m);
  5507. clif_displaymessage(fd, msg_txt(sd,1211)); // The fog has gone.
  5508. } else {
  5509. map[sd->bl.m].flag.fog=1;
  5510. clif_weather(sd->bl.m);
  5511. clif_displaymessage(fd, msg_txt(sd,1212)); // Fog hangs over.
  5512. }
  5513. return 0;
  5514. }
  5515. /*==========================================
  5516. * Fallen leaves fall.
  5517. *------------------------------------------*/
  5518. ACMD_FUNC(leaves)
  5519. {
  5520. nullpo_retr(-1, sd);
  5521. if (map[sd->bl.m].flag.leaves) {
  5522. map[sd->bl.m].flag.leaves=0;
  5523. clif_weather(sd->bl.m);
  5524. clif_displaymessage(fd, msg_txt(sd,1213)); // Leaves no longer fall.
  5525. } else {
  5526. map[sd->bl.m].flag.leaves=1;
  5527. clif_weather(sd->bl.m);
  5528. clif_displaymessage(fd, msg_txt(sd,1214)); // Fallen leaves fall.
  5529. }
  5530. return 0;
  5531. }
  5532. /*==========================================
  5533. * Fireworks appear.
  5534. *------------------------------------------*/
  5535. ACMD_FUNC(fireworks)
  5536. {
  5537. nullpo_retr(-1, sd);
  5538. if (map[sd->bl.m].flag.fireworks) {
  5539. map[sd->bl.m].flag.fireworks=0;
  5540. clif_weather(sd->bl.m);
  5541. clif_displaymessage(fd, msg_txt(sd,1215)); // Fireworks have ended.
  5542. } else {
  5543. map[sd->bl.m].flag.fireworks=1;
  5544. clif_weather(sd->bl.m);
  5545. clif_displaymessage(fd, msg_txt(sd,1216)); // Fireworks have launched.
  5546. }
  5547. return 0;
  5548. }
  5549. /*==========================================
  5550. * Clearing Weather Effects by Dexity
  5551. *------------------------------------------*/
  5552. ACMD_FUNC(clearweather)
  5553. {
  5554. nullpo_retr(-1, sd);
  5555. /**
  5556. * No longer available, keeping here just in case it's back someday. [Ind]
  5557. **/
  5558. //map[sd->bl.m].flag.rain=0;
  5559. map[sd->bl.m].flag.snow=0;
  5560. map[sd->bl.m].flag.sakura=0;
  5561. map[sd->bl.m].flag.clouds=0;
  5562. map[sd->bl.m].flag.clouds2=0;
  5563. map[sd->bl.m].flag.fog=0;
  5564. map[sd->bl.m].flag.fireworks=0;
  5565. map[sd->bl.m].flag.leaves=0;
  5566. clif_weather(sd->bl.m);
  5567. clif_displaymessage(fd, msg_txt(sd,291));
  5568. return 0;
  5569. }
  5570. /*===============================================================
  5571. * Sound Command - plays a sound for everyone around! [Codemaster]
  5572. *---------------------------------------------------------------*/
  5573. ACMD_FUNC(sound)
  5574. {
  5575. char sound_file[100];
  5576. memset(sound_file, '\0', sizeof(sound_file));
  5577. if(!message || !*message || sscanf(message, "%99[^\n]", sound_file) < 1) {
  5578. clif_displaymessage(fd, msg_txt(sd,1217)); // Please enter a sound filename (usage: @sound <filename>).
  5579. return -1;
  5580. }
  5581. if(strstr(sound_file, ".wav") == NULL)
  5582. strcat(sound_file, ".wav");
  5583. clif_soundeffectall(&sd->bl, sound_file, 0, AREA);
  5584. return 0;
  5585. }
  5586. /*==========================================
  5587. * MOB Search
  5588. *------------------------------------------*/
  5589. ACMD_FUNC(mobsearch)
  5590. {
  5591. char mob_name[100];
  5592. int mob_id;
  5593. int number = 0;
  5594. struct s_mapiterator* it;
  5595. nullpo_retr(-1, sd);
  5596. if (!message || !*message || sscanf(message, "%99[^\n]", mob_name) < 1) {
  5597. clif_displaymessage(fd, msg_txt(sd,1218)); // Please enter a monster name (usage: @mobsearch <monster name>).
  5598. return -1;
  5599. }
  5600. if ((mob_id = atoi(mob_name)) == 0)
  5601. mob_id = mobdb_searchname(mob_name);
  5602. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  5603. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1219),mob_name); // Invalid mob ID %s!
  5604. clif_displaymessage(fd, atcmd_output);
  5605. return -1;
  5606. }
  5607. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  5608. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  5609. // strcpy(mob_name,mob_db(mob_id)->name); // --en--
  5610. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1220), mob_name, mapindex_id2name(sd->mapindex)); // Mob Search... %s %s
  5611. clif_displaymessage(fd, atcmd_output);
  5612. it = mapit_geteachmob();
  5613. for(;;)
  5614. {
  5615. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  5616. if( md == NULL )
  5617. break;// no more mobs
  5618. if( md->bl.m != sd->bl.m )
  5619. continue;
  5620. if( mob_id != -1 && md->mob_id != mob_id )
  5621. continue;
  5622. ++number;
  5623. if( md->spawn_timer == INVALID_TIMER )
  5624. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%3d:%3d] %s", number, md->bl.x, md->bl.y, md->name);
  5625. else
  5626. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%s] %s", number, "dead", md->name);
  5627. clif_displaymessage(fd, atcmd_output);
  5628. }
  5629. mapit_free(it);
  5630. return 0;
  5631. }
  5632. /*==========================================
  5633. * @cleanmap - cleans items on the ground
  5634. * @cleanarea - cleans items on the ground within an specified area
  5635. *------------------------------------------*/
  5636. static int atcommand_cleanfloor_sub(struct block_list *bl, va_list ap)
  5637. {
  5638. nullpo_ret(bl);
  5639. map_clearflooritem(bl);
  5640. return 0;
  5641. }
  5642. ACMD_FUNC(cleanmap)
  5643. {
  5644. map_foreachinmap(atcommand_cleanfloor_sub, sd->bl.m, BL_ITEM);
  5645. clif_displaymessage(fd, msg_txt(sd,1221)); // All dropped items have been cleaned up.
  5646. return 0;
  5647. }
  5648. ACMD_FUNC(cleanarea)
  5649. {
  5650. short x0 = 0, y0 = 0, x1 = 0, y1 = 0;
  5651. if (!message || !*message || sscanf(message, "%6hd %6hd %6hd %6hd", &x0, &y0, &x1, &y1) < 1) {
  5652. 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);
  5653. }
  5654. else if (sscanf(message, "%6hd %6hd %6hd %6hd", &x0, &y0, &x1, &y1) == 1) {
  5655. 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);
  5656. }
  5657. else if (sscanf(message, "%6hd %6hd %6hd %6hd", &x0, &y0, &x1, &y1) == 4) {
  5658. map_foreachinarea(atcommand_cleanfloor_sub, sd->bl.m, x0, y0, x1, y1, BL_ITEM);
  5659. }
  5660. clif_displaymessage(fd, msg_txt(sd,1221)); // All dropped items have been cleaned up.
  5661. return 0;
  5662. }
  5663. /*==========================================
  5664. * make a NPC/PET talk
  5665. * @npctalkc [SnakeDrak]
  5666. *------------------------------------------*/
  5667. ACMD_FUNC(npctalk)
  5668. {
  5669. char name[NPC_NAME_LENGTH],mes[100],temp[100];
  5670. struct npc_data *nd;
  5671. bool ifcolor=(*(command + 8) != 'c' && *(command + 8) != 'C')?0:1;
  5672. unsigned long color=0;
  5673. if (sd->sc.cant.chat)
  5674. return -1; //no "chatting" while muted.
  5675. if(!ifcolor) {
  5676. if (!message || !*message || sscanf(message, "%49[^,], %99[^\n]", name, mes) < 2) {
  5677. clif_displaymessage(fd, msg_txt(sd,1222)); // Please enter the correct parameters (usage: @npctalk <npc name>, <message>).
  5678. return -1;
  5679. }
  5680. }
  5681. else {
  5682. if (!message || !*message || sscanf(message, "%16lx %23[^,], %99[^\n]", &color, name, mes) < 3) {
  5683. clif_displaymessage(fd, msg_txt(sd,1223)); // Please enter the correct parameters (usage: @npctalkc <color> <npc name>, <message>).
  5684. return -1;
  5685. }
  5686. }
  5687. if (!(nd = npc_name2id(name))) {
  5688. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist
  5689. return -1;
  5690. }
  5691. strtok(name, "#"); // discard extra name identifier if present
  5692. snprintf(temp, sizeof(temp), "%s : %s", name, mes);
  5693. if(ifcolor) clif_messagecolor(&nd->bl,color,temp,true,AREA_CHAT_WOC);
  5694. else clif_disp_overhead(&nd->bl, temp);
  5695. return 0;
  5696. }
  5697. ACMD_FUNC(pettalk)
  5698. {
  5699. char mes[100],temp[100];
  5700. struct pet_data *pd;
  5701. nullpo_retr(-1, sd);
  5702. if ( battle_config.min_chat_delay ) {
  5703. if( DIFF_TICK(sd->cantalk_tick, gettick()) > 0 )
  5704. return 0;
  5705. sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
  5706. }
  5707. if(!sd->status.pet_id || !(pd=sd->pd))
  5708. {
  5709. clif_displaymessage(fd, msg_txt(sd,184));
  5710. return -1;
  5711. }
  5712. if (sd->sc.cant.chat)
  5713. return -1; //no "chatting" while muted.
  5714. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  5715. clif_displaymessage(fd, msg_txt(sd,1224)); // Please enter a message (usage: @pettalk <message>).
  5716. return -1;
  5717. }
  5718. if (message[0] == '/')
  5719. {// pet emotion processing
  5720. const char* emo[] = {
  5721. "/!", "/?", "/ho", "/lv", "/swt", "/ic", "/an", "/ag", "/$", "/...",
  5722. "/scissors", "/rock", "/paper", "/korea", "/lv2", "/thx", "/wah", "/sry", "/heh", "/swt2",
  5723. "/hmm", "/no1", "/??", "/omg", "/O", "/X", "/hlp", "/go", "/sob", "/gg",
  5724. "/kis", "/kis2", "/pif", "/ok", "-?-", "/indonesia", "/bzz", "/rice", "/awsm", "/meh",
  5725. "/shy", "/pat", "/mp", "/slur", "/com", "/yawn", "/grat", "/hp", "/philippines", "/malaysia",
  5726. "/singapore", "/brazil", "/fsh", "/spin", "/sigh", "/dum", "/crwd", "/desp", "/dice", "-dice2",
  5727. "-dice3", "-dice4", "-dice5", "-dice6", "/india", "/love", "/russia", "-?-", "/mobile", "/mail",
  5728. "/chinese", "/antenna1", "/antenna2", "/antenna3", "/hum", "/abs", "/oops", "/spit", "/ene", "/panic",
  5729. "/whisp"
  5730. };
  5731. int i;
  5732. ARR_FIND( 0, ARRAYLENGTH(emo), i, stricmp(message, emo[i]) == 0 );
  5733. if( i == E_DICE1 ) i = rnd()%6 + E_DICE1; // randomize /dice
  5734. if( i < ARRAYLENGTH(emo) )
  5735. {
  5736. if (sd->emotionlasttime + 1 >= time(NULL)) { // not more than 1 per second
  5737. sd->emotionlasttime = time(NULL);
  5738. return 0;
  5739. }
  5740. sd->emotionlasttime = time(NULL);
  5741. clif_emotion(&pd->bl, i);
  5742. return 0;
  5743. }
  5744. }
  5745. snprintf(temp, sizeof temp ,"%s : %s", pd->pet.name, mes);
  5746. clif_disp_overhead(&pd->bl, temp);
  5747. return 0;
  5748. }
  5749. /// @users - displays the number of players present on each map (and percentage)
  5750. /// #users displays on the target user instead of self
  5751. ACMD_FUNC(users)
  5752. {
  5753. char buf[CHAT_SIZE_MAX];
  5754. int i;
  5755. int users[MAX_MAPINDEX];
  5756. int users_all;
  5757. struct s_mapiterator* iter;
  5758. memset(users, 0, sizeof(users));
  5759. users_all = 0;
  5760. // count users on each map
  5761. iter = mapit_getallusers();
  5762. for(;;)
  5763. {
  5764. struct map_session_data* sd2 = (struct map_session_data*)mapit_next(iter);
  5765. if( sd2 == NULL )
  5766. break;// no more users
  5767. if( sd2->mapindex >= MAX_MAPINDEX )
  5768. continue;// invalid mapindex
  5769. if( users[sd2->mapindex] < INT_MAX ) ++users[sd2->mapindex];
  5770. if( users_all < INT_MAX ) ++users_all;
  5771. }
  5772. mapit_free(iter);
  5773. // display results for each map
  5774. for( i = 0; i < MAX_MAPINDEX; ++i )
  5775. {
  5776. if( users[i] == 0 )
  5777. continue;// empty
  5778. safesnprintf(buf, sizeof(buf), "%s: %d (%.2f%%)", mapindex_id2name(i), users[i], (float)(100.0f*users[i]/users_all));
  5779. clif_displaymessage(sd->fd, buf);
  5780. }
  5781. // display overall count
  5782. safesnprintf(buf, sizeof(buf), "all: %d", users_all);
  5783. clif_displaymessage(sd->fd, buf);
  5784. return 0;
  5785. }
  5786. /*==========================================
  5787. *
  5788. *------------------------------------------*/
  5789. ACMD_FUNC(reset)
  5790. {
  5791. pc_resetstate(sd);
  5792. pc_resetskill(sd,1);
  5793. sprintf(atcmd_output, msg_txt(sd,208), sd->status.name); // '%s' skill and stats points reseted!
  5794. clif_displaymessage(fd, atcmd_output);
  5795. return 0;
  5796. }
  5797. /*==========================================
  5798. *
  5799. *------------------------------------------*/
  5800. ACMD_FUNC(summon)
  5801. {
  5802. char name[NAME_LENGTH];
  5803. int mob_id = 0;
  5804. int duration = 0;
  5805. struct mob_data *md;
  5806. unsigned int tick=gettick();
  5807. nullpo_retr(-1, sd);
  5808. if (!message || !*message || sscanf(message, "%23s %11d", name, &duration) < 1)
  5809. {
  5810. clif_displaymessage(fd, msg_txt(sd,1225)); // Please enter a monster name (usage: @summon <monster name> {duration}).
  5811. return -1;
  5812. }
  5813. if (duration < 1)
  5814. duration =1;
  5815. else if (duration > 60)
  5816. duration =60;
  5817. if ((mob_id = atoi(name)) == 0)
  5818. mob_id = mobdb_searchname(name);
  5819. if(mob_id == 0 || mobdb_checkid(mob_id) == 0)
  5820. {
  5821. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  5822. return -1;
  5823. }
  5824. md = mob_once_spawn_sub(&sd->bl, sd->bl.m, -1, -1, "--ja--", mob_id, "", SZ_SMALL, AI_NONE);
  5825. if(!md)
  5826. return -1;
  5827. md->master_id=sd->bl.id;
  5828. md->special_state.ai=AI_ATTACK;
  5829. md->deletetimer=add_timer(tick+(duration*60000),mob_timer_delete,md->bl.id,0);
  5830. clif_specialeffect(&md->bl,344,AREA);
  5831. mob_spawn(md);
  5832. sc_start4(NULL,&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000);
  5833. clif_skill_poseffect(&sd->bl,AM_CALLHOMUN,1,md->bl.x,md->bl.y,tick);
  5834. clif_displaymessage(fd, msg_txt(sd,39)); // All monster summoned!
  5835. return 0;
  5836. }
  5837. /*==========================================
  5838. * @adjgroup
  5839. * Temporarily move player to another group
  5840. * Useful during beta testing to allow players to use GM commands for short periods of time
  5841. *------------------------------------------*/
  5842. ACMD_FUNC(adjgroup)
  5843. {
  5844. int new_group = 0;
  5845. nullpo_retr(-1, sd);
  5846. if (!message || !*message || sscanf(message, "%11d", &new_group) != 1) {
  5847. clif_displaymessage(fd, msg_txt(sd,1226)); // Usage: @adjgroup <group_id>
  5848. return -1;
  5849. }
  5850. if (!pc_group_exists(new_group)) {
  5851. clif_displaymessage(fd, msg_txt(sd,1227)); // Specified group does not exist.
  5852. return -1;
  5853. }
  5854. sd->group_id = new_group;
  5855. pc_group_pc_load(sd);/* update cache */
  5856. clif_displaymessage(fd, msg_txt(sd,1228)); // Group changed successfully.
  5857. clif_displaymessage(sd->fd, msg_txt(sd,1229)); // Your group has changed.
  5858. return 0;
  5859. }
  5860. /*==========================================
  5861. * @trade by [MouseJstr]
  5862. * Open a trade window with a remote player
  5863. *------------------------------------------*/
  5864. ACMD_FUNC(trade)
  5865. {
  5866. struct map_session_data *pl_sd = NULL;
  5867. nullpo_retr(-1, sd);
  5868. if (!message || !*message) {
  5869. clif_displaymessage(fd, msg_txt(sd,1230)); // Please enter a player name (usage: @trade <char name>).
  5870. return -1;
  5871. }
  5872. if ( (pl_sd = map_nick2sd((char *)message,true)) == NULL )
  5873. {
  5874. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5875. return -1;
  5876. }
  5877. trade_traderequest(sd, pl_sd);
  5878. return 0;
  5879. }
  5880. /*==========================================
  5881. * @setbattleflag by [MouseJstr]
  5882. * set a battle_config flag without having to reboot
  5883. *------------------------------------------*/
  5884. ACMD_FUNC(setbattleflag)
  5885. {
  5886. char flag[128], value[128];
  5887. nullpo_retr(-1, sd);
  5888. if (!message || !*message || sscanf(message, "%127s %127s", flag, value) != 2) {
  5889. clif_displaymessage(fd, msg_txt(sd,1231)); // Usage: @setbattleflag <flag> <value>
  5890. return -1;
  5891. }
  5892. if (battle_set_value(flag, value) == 0)
  5893. {
  5894. clif_displaymessage(fd, msg_txt(sd,1232)); // Unknown battle_config flag.
  5895. return -1;
  5896. }
  5897. clif_displaymessage(fd, msg_txt(sd,1233)); // Set battle_config as requested.
  5898. return 0;
  5899. }
  5900. /*==========================================
  5901. * @unmute [Valaris]
  5902. *------------------------------------------*/
  5903. ACMD_FUNC(unmute)
  5904. {
  5905. struct map_session_data *pl_sd = NULL;
  5906. nullpo_retr(-1, sd);
  5907. if (!message || !*message) {
  5908. clif_displaymessage(fd, msg_txt(sd,1234)); // Please enter a player name (usage: @unmute <char name>).
  5909. return -1;
  5910. }
  5911. if ( (pl_sd = map_nick2sd((char *)message,false)) == NULL )
  5912. {
  5913. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5914. return -1;
  5915. }
  5916. if(!pl_sd->sc.data[SC_NOCHAT]) {
  5917. clif_displaymessage(sd->fd,msg_txt(sd,1235)); // Player is not muted.
  5918. return -1;
  5919. }
  5920. pl_sd->status.manner = 0;
  5921. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  5922. clif_displaymessage(sd->fd,msg_txt(sd,1236)); // Player unmuted.
  5923. return 0;
  5924. }
  5925. /*==========================================
  5926. * @uptime by MC Cameri
  5927. *------------------------------------------*/
  5928. ACMD_FUNC(uptime)
  5929. {
  5930. unsigned long seconds = 0, day = 24*60*60, hour = 60*60,
  5931. minute = 60, days = 0, hours = 0, minutes = 0;
  5932. nullpo_retr(-1, sd);
  5933. seconds = get_uptime();
  5934. days = seconds/day;
  5935. seconds -= (seconds/day>0)?(seconds/day)*day:0;
  5936. hours = seconds/hour;
  5937. seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
  5938. minutes = seconds/minute;
  5939. seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
  5940. snprintf(atcmd_output, sizeof(atcmd_output), msg_txt(sd,245), days, hours, minutes, seconds);
  5941. clif_displaymessage(fd, atcmd_output);
  5942. return 0;
  5943. }
  5944. /*==========================================
  5945. * @changesex
  5946. * => Changes one's account sex. Switch from male to female or visversa
  5947. *------------------------------------------*/
  5948. ACMD_FUNC(changesex)
  5949. {
  5950. int i;
  5951. nullpo_retr(-1, sd);
  5952. pc_resetskill(sd,4);
  5953. // to avoid any problem with equipment and invalid sex, equipment is unequiped.
  5954. for (i = 0; i < EQI_MAX; i++) {
  5955. if (sd->equip_index[i] >= 0)
  5956. pc_unequipitem(sd, sd->equip_index[i], 3);
  5957. }
  5958. chrif_changesex(sd, true);
  5959. return 0;
  5960. }
  5961. /*==========================================
  5962. * @changecharsex
  5963. * => Changes one's character sex. Switch from male to female or visversa.
  5964. *------------------------------------------*/
  5965. ACMD_FUNC(changecharsex)
  5966. {
  5967. int i;
  5968. nullpo_retr(-1, sd);
  5969. pc_resetskill(sd,4);
  5970. // to avoid any problem with equipment and invalid sex, equipment is unequiped.
  5971. for (i = 0; i < EQI_MAX; i++) {
  5972. if (sd->equip_index[i] >= 0)
  5973. pc_unequipitem(sd, sd->equip_index[i], 3);
  5974. }
  5975. chrif_changesex(sd, false);
  5976. return 0;
  5977. }
  5978. /*================================================
  5979. * @mute - Mutes a player for a set amount of time
  5980. *------------------------------------------------*/
  5981. ACMD_FUNC(mute)
  5982. {
  5983. struct map_session_data *pl_sd = NULL;
  5984. int manner;
  5985. nullpo_retr(-1, sd);
  5986. if (!message || !*message || sscanf(message, "%11d %23[^\n]", &manner, atcmd_player_name) < 1) {
  5987. clif_displaymessage(fd, msg_txt(sd,1237)); // Usage: @mute <time> <char name>
  5988. return -1;
  5989. }
  5990. if ( (pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL )
  5991. {
  5992. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5993. return -1;
  5994. }
  5995. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  5996. {
  5997. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  5998. return -1;
  5999. }
  6000. clif_manner_message(sd, 0);
  6001. clif_manner_message(pl_sd, 5);
  6002. if( pl_sd->status.manner < manner ) {
  6003. pl_sd->status.manner -= manner;
  6004. sc_start(NULL,&pl_sd->bl,SC_NOCHAT,100,0,0);
  6005. } else {
  6006. pl_sd->status.manner = 0;
  6007. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  6008. }
  6009. clif_GM_silence(sd, pl_sd, (manner > 0 ? 1 : 0));
  6010. return 0;
  6011. }
  6012. /*==========================================
  6013. * @refresh (like @jumpto <<yourself>>)
  6014. *------------------------------------------*/
  6015. ACMD_FUNC(refresh)
  6016. {
  6017. nullpo_retr(-1, sd);
  6018. clif_refresh(sd);
  6019. return 0;
  6020. }
  6021. ACMD_FUNC(refreshall)
  6022. {
  6023. struct map_session_data* iter_sd;
  6024. struct s_mapiterator* iter;
  6025. nullpo_retr(-1, sd);
  6026. iter = mapit_getallusers();
  6027. for (iter_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); iter_sd = (TBL_PC*)mapit_next(iter))
  6028. clif_refresh(iter_sd);
  6029. mapit_free(iter);
  6030. return 0;
  6031. }
  6032. /*==========================================
  6033. * @identify
  6034. * => GM's magnifier.
  6035. *------------------------------------------*/
  6036. ACMD_FUNC(identify)
  6037. {
  6038. int i,num;
  6039. nullpo_retr(-1, sd);
  6040. for(i=num=0;i<MAX_INVENTORY;i++){
  6041. if(sd->inventory.u.items_inventory[i].nameid > 0 && sd->inventory.u.items_inventory[i].identify != 1) {
  6042. num++;
  6043. }
  6044. }
  6045. if (num > 0) {
  6046. clif_item_identify_list(sd);
  6047. } else {
  6048. clif_displaymessage(fd,msg_txt(sd,1238)); // There are no items to appraise.
  6049. }
  6050. return 0;
  6051. }
  6052. /*===============================================
  6053. * @identifyall
  6054. * => Indentify all items in inventory - Akinari
  6055. *-----------------------------------------------*/
  6056. ACMD_FUNC(identifyall)
  6057. {
  6058. int i;
  6059. nullpo_retr(-1, sd);
  6060. for(i=0; i<MAX_INVENTORY; i++) {
  6061. if (sd->inventory.u.items_inventory[i].nameid > 0 && sd->inventory.u.items_inventory[i].identify != 1) {
  6062. sd->inventory.u.items_inventory[i].identify = 1;
  6063. clif_item_identified(sd,i,0);
  6064. }
  6065. }
  6066. return 0;
  6067. }
  6068. /*==========================================
  6069. * @gmotd (Global MOTD)
  6070. * by davidsiaw :P
  6071. *------------------------------------------*/
  6072. ACMD_FUNC(gmotd)
  6073. {
  6074. FILE* fp;
  6075. if( ( fp = fopen(motd_txt, "r") ) != NULL )
  6076. {
  6077. char buf[CHAT_SIZE_MAX];
  6078. size_t len;
  6079. while( fgets(buf, sizeof(buf), fp) )
  6080. {
  6081. if( buf[0] == '/' && buf[1] == '/' )
  6082. {
  6083. continue;
  6084. }
  6085. len = strlen(buf);
  6086. while( len && ( buf[len-1] == '\r' || buf[len-1] == '\n' ) )
  6087. {// strip trailing EOL characters
  6088. len--;
  6089. }
  6090. if( len )
  6091. {
  6092. buf[len] = 0;
  6093. intif_broadcast(buf, len+1, 0);
  6094. }
  6095. }
  6096. fclose(fp);
  6097. }
  6098. return 0;
  6099. }
  6100. ACMD_FUNC(misceffect)
  6101. {
  6102. int effect = 0;
  6103. nullpo_retr(-1, sd);
  6104. if (!message || !*message)
  6105. return -1;
  6106. if (sscanf(message, "%11d", &effect) < 1)
  6107. return -1;
  6108. clif_misceffect(&sd->bl,effect);
  6109. return 0;
  6110. }
  6111. /*==========================================
  6112. * MAIL SYSTEM
  6113. *------------------------------------------*/
  6114. ACMD_FUNC(mail)
  6115. {
  6116. nullpo_ret(sd);
  6117. mail_openmail(sd);
  6118. return 0;
  6119. }
  6120. /*==========================================
  6121. * Show Monster DB Info v 1.0
  6122. * originally by [Lupus]
  6123. *------------------------------------------*/
  6124. ACMD_FUNC(mobinfo)
  6125. {
  6126. unsigned char msize[SZ_ALL][7] = { "Small", "Medium", "Large" };
  6127. unsigned char mrace[RC_ALL][11] = { "Formless", "Undead", "Beast", "Plant", "Insect", "Fish", "Demon", "Demi-Human", "Angel", "Dragon", "Player" };
  6128. unsigned char melement[ELE_ALL][8] = { "Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead" };
  6129. char atcmd_output2[CHAT_SIZE_MAX];
  6130. struct item_data *item_data;
  6131. struct mob_db *mob, *mob_array[MAX_SEARCH];
  6132. int count;
  6133. int i, k;
  6134. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6135. memset(atcmd_output2, '\0', sizeof(atcmd_output2));
  6136. if (!message || !*message) {
  6137. clif_displaymessage(fd, msg_txt(sd,1239)); // Please enter a monster name/ID (usage: @mobinfo <monster_name_or_monster_ID>).
  6138. return -1;
  6139. }
  6140. // If monster identifier/name argument is a name
  6141. if ((i = mobdb_checkid(atoi(message))))
  6142. {
  6143. mob_array[0] = mob_db(i);
  6144. count = 1;
  6145. } else
  6146. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  6147. if (!count) {
  6148. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  6149. return -1;
  6150. }
  6151. if (count >= MAX_SEARCH) {
  6152. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH); // Displaying first %d matches
  6153. clif_displaymessage(fd, atcmd_output);
  6154. count = MAX_SEARCH;
  6155. }
  6156. for (k = 0; k < count; k++) {
  6157. unsigned int j,base_exp,job_exp;
  6158. mob = mob_array[k];
  6159. base_exp = mob->base_exp;
  6160. job_exp = mob->job_exp;
  6161. if (pc_isvip(sd)) { // Display EXP rate increase for VIP
  6162. base_exp = (base_exp * battle_config.vip_base_exp_increase) / 100;
  6163. job_exp = (job_exp * battle_config.vip_job_exp_increase) / 100;
  6164. }
  6165. #ifdef RENEWAL_EXP
  6166. if( battle_config.atcommand_mobinfo_type ) {
  6167. base_exp = base_exp * pc_level_penalty_mod(mob->lv - sd->status.base_level, mob->status.class_, mob->status.mode, 1) / 100;
  6168. job_exp = job_exp * pc_level_penalty_mod(mob->lv - sd->status.base_level, mob->status.class_, mob->status.mode, 1) / 100;
  6169. }
  6170. #endif
  6171. // stats
  6172. if (mob->mexp)
  6173. sprintf(atcmd_output, msg_txt(sd,1240), mob->name, mob->jname, mob->sprite, mob->vd.class_); // MVP Monster: '%s'/'%s'/'%s' (%d)
  6174. else
  6175. sprintf(atcmd_output, msg_txt(sd,1241), mob->name, mob->jname, mob->sprite, mob->vd.class_); // Monster: '%s'/'%s'/'%s' (%d)
  6176. clif_displaymessage(fd, atcmd_output);
  6177. sprintf(atcmd_output, msg_txt(sd,1242), mob->lv, mob->status.max_hp, base_exp, job_exp, MOB_HIT(mob), MOB_FLEE(mob)); // Lv:%d HP:%d Base EXP:%u Job EXP:%u HIT:%d FLEE:%d
  6178. clif_displaymessage(fd, atcmd_output);
  6179. sprintf(atcmd_output, msg_txt(sd,1243), // DEF:%d MDEF:%d STR:%d AGI:%d VIT:%d INT:%d DEX:%d LUK:%d
  6180. mob->status.def, mob->status.mdef,mob->status.str, mob->status.agi,
  6181. mob->status.vit, mob->status.int_, mob->status.dex, mob->status.luk);
  6182. clif_displaymessage(fd, atcmd_output);
  6183. sprintf(atcmd_output, msg_txt(sd,1244), // ATK:%d~%d Range:%d~%d~%d Size:%s Race: %s Element: %s (Lv:%d)
  6184. mob->status.rhw.atk, mob->status.rhw.atk2, mob->status.rhw.range,
  6185. mob->range2 , mob->range3, msize[mob->status.size],
  6186. mrace[mob->status.race], melement[mob->status.def_ele], mob->status.ele_lv);
  6187. clif_displaymessage(fd, atcmd_output);
  6188. // drops
  6189. clif_displaymessage(fd, msg_txt(sd,1245)); // Drops:
  6190. strcpy(atcmd_output, " ");
  6191. j = 0;
  6192. for (i = 0; i < MAX_MOB_DROP; i++) {
  6193. int droprate;
  6194. if (mob->dropitem[i].nameid <= 0 || mob->dropitem[i].p < 1 || (item_data = itemdb_exists(mob->dropitem[i].nameid)) == NULL)
  6195. continue;
  6196. droprate = mob->dropitem[i].p;
  6197. #ifdef RENEWAL_DROP
  6198. if( battle_config.atcommand_mobinfo_type ) {
  6199. droprate = droprate * pc_level_penalty_mod(mob->lv - sd->status.base_level, mob->status.class_, mob->status.mode, 2) / 100;
  6200. if (droprate <= 0 && !battle_config.drop_rate0item)
  6201. droprate = 1;
  6202. }
  6203. #endif
  6204. if (pc_isvip(sd)) // Display drop rate increase for VIP
  6205. droprate += (droprate * battle_config.vip_drop_increase) / 100;
  6206. if (item_data->slot)
  6207. sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, (float)droprate / 100);
  6208. else
  6209. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)droprate / 100);
  6210. strcat(atcmd_output, atcmd_output2);
  6211. if (++j % 3 == 0) {
  6212. clif_displaymessage(fd, atcmd_output);
  6213. strcpy(atcmd_output, " ");
  6214. }
  6215. }
  6216. if (j == 0)
  6217. clif_displaymessage(fd, msg_txt(sd,1246)); // This monster has no drops.
  6218. else if (j % 3 != 0)
  6219. clif_displaymessage(fd, atcmd_output);
  6220. // mvp
  6221. if (mob->mexp) {
  6222. float mvppercent, mvpremain;
  6223. sprintf(atcmd_output, msg_txt(sd,1247), mob->mexp); // MVP Bonus EXP:%u
  6224. clif_displaymessage(fd, atcmd_output);
  6225. strcpy(atcmd_output, msg_txt(sd,1248)); // MVP Items:
  6226. mvpremain = 100.0; //Remaining drop chance for official mvp drop mode
  6227. j = 0;
  6228. for (i = 0; i < MAX_MVP_DROP; i++) {
  6229. if (mob->mvpitem[i].nameid <= 0 || (item_data = itemdb_exists(mob->mvpitem[i].nameid)) == NULL)
  6230. continue;
  6231. //Because if there are 3 MVP drops at 50%, the first has a chance of 50%, the second 25% and the third 12.5%
  6232. mvppercent = (float)mob->mvpitem[i].p * mvpremain / 10000.0f;
  6233. if(battle_config.item_drop_mvp_mode == 0) {
  6234. mvpremain -= mvppercent;
  6235. }
  6236. if (mvppercent > 0) {
  6237. j++;
  6238. if (j == 1) {
  6239. if (item_data->slot)
  6240. sprintf(atcmd_output2, " %s[%d] %02.02f%%", item_data->jname, item_data->slot, mvppercent);
  6241. else
  6242. sprintf(atcmd_output2, " %s %02.02f%%", item_data->jname, mvppercent);
  6243. } else {
  6244. if (item_data->slot)
  6245. sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, mvppercent);
  6246. else
  6247. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, mvppercent);
  6248. }
  6249. strcat(atcmd_output, atcmd_output2);
  6250. }
  6251. }
  6252. if (j == 0)
  6253. clif_displaymessage(fd, msg_txt(sd,1249)); // This monster has no MVP prizes.
  6254. else
  6255. clif_displaymessage(fd, atcmd_output);
  6256. }
  6257. }
  6258. return 0;
  6259. }
  6260. /*=========================================
  6261. * @showmobs by KarLaeda
  6262. * => For 15 sec displays the mobs on minimap
  6263. *------------------------------------------*/
  6264. ACMD_FUNC(showmobs)
  6265. {
  6266. char mob_name[100];
  6267. int mob_id;
  6268. int number = 0;
  6269. struct s_mapiterator* it;
  6270. nullpo_retr(-1, sd);
  6271. if(sscanf(message, "%99[^\n]", mob_name) < 0)
  6272. return -1;
  6273. if((mob_id = atoi(mob_name)) == 0)
  6274. mob_id = mobdb_searchname(mob_name);
  6275. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  6276. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1250),mob_name); // Invalid mob id %s!
  6277. clif_displaymessage(fd, atcmd_output);
  6278. return 0;
  6279. }
  6280. if(status_has_mode(&mob_db(mob_id)->status,MD_STATUS_IMMUNE) && !pc_has_permission(sd, PC_PERM_SHOW_BOSS)){ // If player group does not have access to boss mobs.
  6281. clif_displaymessage(fd, msg_txt(sd,1251)); // Can't show boss mobs!
  6282. return 0;
  6283. }
  6284. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  6285. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  6286. //strcpy(mob_name,mob_db(mob_id)->name); // --en--
  6287. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1252), // Mob Search... %s %s
  6288. mob_name, mapindex_id2name(sd->mapindex));
  6289. clif_displaymessage(fd, atcmd_output);
  6290. it = mapit_geteachmob();
  6291. for(;;)
  6292. {
  6293. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  6294. if( md == NULL )
  6295. break;// no more mobs
  6296. if( md->bl.m != sd->bl.m )
  6297. continue;
  6298. if( mob_id != -1 && md->mob_id != mob_id )
  6299. continue;
  6300. if( md->special_state.ai || md->master_id )
  6301. continue; // hide slaves and player summoned mobs
  6302. if( md->spawn_timer != INVALID_TIMER )
  6303. continue; // hide mobs waiting for respawn
  6304. ++number;
  6305. clif_viewpoint(sd, 1, 0, md->bl.x, md->bl.y, number, 0xFFFFFF);
  6306. }
  6307. mapit_free(it);
  6308. return 0;
  6309. }
  6310. /*==========================================
  6311. * homunculus level up [orn]
  6312. *------------------------------------------*/
  6313. ACMD_FUNC(homlevel)
  6314. {
  6315. TBL_HOM * hd;
  6316. int level = 0, i = 0;
  6317. nullpo_retr(-1, sd);
  6318. if ( !message || !*message || ( level = atoi(message) ) < 1 ) {
  6319. clif_displaymessage(fd, msg_txt(sd,1253)); // Please enter a level adjustment (usage: @homlevel <number of levels>).
  6320. return -1;
  6321. }
  6322. if ( !hom_is_active(sd->hd) ) {
  6323. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6324. return -1;
  6325. }
  6326. hd = sd->hd;
  6327. for (i = 1; i <= level && hd->exp_next; i++){
  6328. hd->homunculus.exp += hd->exp_next;
  6329. if( !hom_levelup(hd) )
  6330. break;
  6331. }
  6332. status_calc_homunculus(hd, SCO_NONE);
  6333. status_percent_heal(&hd->bl, 100, 100);
  6334. clif_specialeffect(&hd->bl,568,AREA);
  6335. return 0;
  6336. }
  6337. /*==========================================
  6338. * homunculus evolution H [orn]
  6339. *------------------------------------------*/
  6340. ACMD_FUNC(homevolution)
  6341. {
  6342. nullpo_retr(-1, sd);
  6343. if ( !hom_is_active(sd->hd) ) {
  6344. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6345. return -1;
  6346. }
  6347. if ( !hom_evolution(sd->hd) ) {
  6348. clif_displaymessage(fd, msg_txt(sd,1255)); // Your homunculus doesn't evolve.
  6349. return -1;
  6350. }
  6351. clif_homskillinfoblock(sd);
  6352. return 0;
  6353. }
  6354. ACMD_FUNC(hommutate)
  6355. {
  6356. int homun_id, m_class = 0, m_id;
  6357. nullpo_retr(-1, sd);
  6358. if (!hom_is_active(sd->hd)) {
  6359. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6360. return -1;
  6361. }
  6362. if (!message || !*message) {
  6363. homun_id = 6048 + (rnd() % 4);
  6364. } else {
  6365. homun_id = atoi(message);
  6366. }
  6367. m_class = hom_class2mapid(sd->hd->homunculus.class_);
  6368. m_id = hom_class2mapid(homun_id);
  6369. if (m_class != -1 && m_id != -1 && m_class&HOM_EVO && m_id&HOM_S && sd->hd->homunculus.level >= 99) {
  6370. hom_mutate(sd->hd, homun_id);
  6371. } else {
  6372. clif_emotion(&sd->hd->bl, E_SWT);
  6373. }
  6374. return 0;
  6375. }
  6376. /*==========================================
  6377. * call choosen homunculus [orn]
  6378. *------------------------------------------*/
  6379. ACMD_FUNC(makehomun)
  6380. {
  6381. int homunid;
  6382. nullpo_retr(-1, sd);
  6383. if ( sd->status.hom_id ) {
  6384. clif_displaymessage(fd, msg_txt(sd,450));
  6385. return -1;
  6386. }
  6387. if (!message || !*message) {
  6388. clif_displaymessage(fd, msg_txt(sd,1256)); // Please enter a homunculus ID (usage: @makehomun <homunculus id>).
  6389. return -1;
  6390. }
  6391. homunid = atoi(message);
  6392. if( homunid < HM_CLASS_BASE || homunid > HM_CLASS_BASE + MAX_HOMUNCULUS_CLASS - 1 )
  6393. {
  6394. clif_displaymessage(fd, msg_txt(sd,1257)); // Invalid Homunculus ID.
  6395. return -1;
  6396. }
  6397. hom_create_request(sd,homunid);
  6398. return 0;
  6399. }
  6400. /*==========================================
  6401. * modify homunculus intimacy [orn]
  6402. *------------------------------------------*/
  6403. ACMD_FUNC(homfriendly)
  6404. {
  6405. int friendly = 0;
  6406. nullpo_retr(-1, sd);
  6407. if ( !hom_is_active(sd->hd) ) {
  6408. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6409. return -1;
  6410. }
  6411. if (!message || !*message) {
  6412. clif_displaymessage(fd, msg_txt(sd,1258)); // Please enter a friendly value (usage: @homfriendly <friendly value [0-1000]>).
  6413. return -1;
  6414. }
  6415. friendly = atoi(message);
  6416. friendly = cap_value(friendly, 0, 1000);
  6417. sd->hd->homunculus.intimacy = friendly * 100 ;
  6418. clif_send_homdata(sd,SP_INTIMATE,friendly);
  6419. return 0;
  6420. }
  6421. /*==========================================
  6422. * modify homunculus hunger [orn]
  6423. *------------------------------------------*/
  6424. ACMD_FUNC(homhungry)
  6425. {
  6426. int hungry = 0;
  6427. nullpo_retr(-1, sd);
  6428. if ( !hom_is_active(sd->hd) ) {
  6429. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6430. return -1;
  6431. }
  6432. if (!message || !*message) {
  6433. clif_displaymessage(fd, msg_txt(sd,1259)); // Please enter a hunger value (usage: @homhungry <hunger value [0-100]>).
  6434. return -1;
  6435. }
  6436. hungry = atoi(message);
  6437. hungry = cap_value(hungry, 0, 100);
  6438. sd->hd->homunculus.hunger = hungry;
  6439. clif_send_homdata(sd,SP_HUNGRY,hungry);
  6440. return 0;
  6441. }
  6442. /*==========================================
  6443. * make the homunculus speak [orn]
  6444. *------------------------------------------*/
  6445. ACMD_FUNC(homtalk)
  6446. {
  6447. char mes[100],temp[100];
  6448. nullpo_retr(-1, sd);
  6449. if ( battle_config.min_chat_delay ) {
  6450. if( DIFF_TICK(sd->cantalk_tick, gettick()) > 0 )
  6451. return 0;
  6452. sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
  6453. }
  6454. if (sd->sc.cant.chat)
  6455. return -1; //no "chatting" while muted.
  6456. if ( !hom_is_active(sd->hd) ) {
  6457. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6458. return -1;
  6459. }
  6460. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  6461. clif_displaymessage(fd, msg_txt(sd,1260)); // Please enter a message (usage: @homtalk <message>).
  6462. return -1;
  6463. }
  6464. snprintf(temp, sizeof temp ,"%s : %s", sd->hd->homunculus.name, mes);
  6465. clif_disp_overhead(&sd->hd->bl, temp);
  6466. return 0;
  6467. }
  6468. /*==========================================
  6469. * Show homunculus stats
  6470. *------------------------------------------*/
  6471. ACMD_FUNC(hominfo)
  6472. {
  6473. struct homun_data *hd;
  6474. struct status_data *status;
  6475. nullpo_retr(-1, sd);
  6476. if ( !hom_is_active(sd->hd) ) {
  6477. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6478. return -1;
  6479. }
  6480. hd = sd->hd;
  6481. status = status_get_status_data(&hd->bl);
  6482. clif_displaymessage(fd, msg_txt(sd,1261)); // Homunculus stats:
  6483. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1262), // HP: %d/%d - SP: %d/%d
  6484. status->hp, status->max_hp, status->sp, status->max_sp);
  6485. clif_displaymessage(fd, atcmd_output);
  6486. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1263), // ATK: %d - MATK: %d~%d
  6487. status->rhw.atk2 +status->batk, status->matk_min, status->matk_max);
  6488. clif_displaymessage(fd, atcmd_output);
  6489. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1264), // Hungry: %d - Intimacy: %u
  6490. hd->homunculus.hunger, hd->homunculus.intimacy/100);
  6491. clif_displaymessage(fd, atcmd_output);
  6492. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6493. msg_txt(sd,1265), // Stats: Str %d / Agi %d / Vit %d / Int %d / Dex %d / Luk %d
  6494. status->str, status->agi, status->vit,
  6495. status->int_, status->dex, status->luk);
  6496. clif_displaymessage(fd, atcmd_output);
  6497. return 0;
  6498. }
  6499. ACMD_FUNC(homstats)
  6500. {
  6501. struct homun_data *hd;
  6502. struct s_homunculus_db *db;
  6503. struct s_homunculus *hom;
  6504. int lv, min, max, evo;
  6505. nullpo_retr(-1, sd);
  6506. if ( !hom_is_active(sd->hd) ) {
  6507. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6508. return -1;
  6509. }
  6510. hd = sd->hd;
  6511. hom = &hd->homunculus;
  6512. db = hd->homunculusDB;
  6513. lv = hom->level;
  6514. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6515. msg_txt(sd,1266), lv, db->name); // Homunculus growth stats (Lv %d %s):
  6516. clif_displaymessage(fd, atcmd_output);
  6517. lv--; //Since the first increase is at level 2.
  6518. evo = (hom->class_ == db->evo_class);
  6519. min = db->base.HP +lv*db->gmin.HP +(evo?db->emin.HP:0);
  6520. max = db->base.HP +lv*db->gmax.HP +(evo?db->emax.HP:0);;
  6521. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1267), hom->max_hp, min, max); // Max HP: %d (%d~%d)
  6522. clif_displaymessage(fd, atcmd_output);
  6523. min = db->base.SP +lv*db->gmin.SP +(evo?db->emin.SP:0);
  6524. max = db->base.SP +lv*db->gmax.SP +(evo?db->emax.SP:0);;
  6525. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1268), hom->max_sp, min, max); // Max SP: %d (%d~%d)
  6526. clif_displaymessage(fd, atcmd_output);
  6527. min = db->base.str +lv*(db->gmin.str/10) +(evo?db->emin.str:0);
  6528. max = db->base.str +lv*(db->gmax.str/10) +(evo?db->emax.str:0);;
  6529. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1269), hom->str/10, min, max); // Str: %d (%d~%d)
  6530. clif_displaymessage(fd, atcmd_output);
  6531. min = db->base.agi +lv*(db->gmin.agi/10) +(evo?db->emin.agi:0);
  6532. max = db->base.agi +lv*(db->gmax.agi/10) +(evo?db->emax.agi:0);;
  6533. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1270), hom->agi/10, min, max); // Agi: %d (%d~%d)
  6534. clif_displaymessage(fd, atcmd_output);
  6535. min = db->base.vit +lv*(db->gmin.vit/10) +(evo?db->emin.vit:0);
  6536. max = db->base.vit +lv*(db->gmax.vit/10) +(evo?db->emax.vit:0);;
  6537. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1271), hom->vit/10, min, max); // Vit: %d (%d~%d)
  6538. clif_displaymessage(fd, atcmd_output);
  6539. min = db->base.int_ +lv*(db->gmin.int_/10) +(evo?db->emin.int_:0);
  6540. max = db->base.int_ +lv*(db->gmax.int_/10) +(evo?db->emax.int_:0);;
  6541. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1272), hom->int_/10, min, max); // Int: %d (%d~%d)
  6542. clif_displaymessage(fd, atcmd_output);
  6543. min = db->base.dex +lv*(db->gmin.dex/10) +(evo?db->emin.dex:0);
  6544. max = db->base.dex +lv*(db->gmax.dex/10) +(evo?db->emax.dex:0);;
  6545. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1273), hom->dex/10, min, max); // Dex: %d (%d~%d)
  6546. clif_displaymessage(fd, atcmd_output);
  6547. min = db->base.luk +lv*(db->gmin.luk/10) +(evo?db->emin.luk:0);
  6548. max = db->base.luk +lv*(db->gmax.luk/10) +(evo?db->emax.luk:0);;
  6549. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1274), hom->luk/10, min, max); // Luk: %d (%d~%d)
  6550. clif_displaymessage(fd, atcmd_output);
  6551. return 0;
  6552. }
  6553. ACMD_FUNC(homshuffle)
  6554. {
  6555. nullpo_retr(-1, sd);
  6556. if(!sd->hd)
  6557. return -1; // nothing to do
  6558. if(!hom_shuffle(sd->hd))
  6559. return -1;
  6560. clif_displaymessage(sd->fd, msg_txt(sd,1275)); // Homunculus stats altered.
  6561. atcommand_homstats(fd, sd, command, message); //Print out the new stats
  6562. return 0;
  6563. }
  6564. /*==========================================
  6565. * Show Items DB Info v 1.0
  6566. * originally by [Lupus]
  6567. *------------------------------------------*/
  6568. ACMD_FUNC(iteminfo)
  6569. {
  6570. struct item_data *item_array[MAX_SEARCH];
  6571. int i, count = 1;
  6572. if (!message || !*message) {
  6573. clif_displaymessage(fd, msg_txt(sd,1276)); // Please enter an item name/ID (usage: @ii/@iteminfo <item name/ID>).
  6574. return -1;
  6575. }
  6576. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  6577. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  6578. if (!count) {
  6579. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  6580. return -1;
  6581. }
  6582. if (count == MAX_SEARCH) {
  6583. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH); // Displaying first %d matches
  6584. clif_displaymessage(fd, atcmd_output);
  6585. }
  6586. for (i = 0; i < count; i++) {
  6587. struct item_data * item_data = item_array[i];
  6588. sprintf(atcmd_output, msg_txt(sd,1277), // Item: '%s'/'%s'[%d] (%hu) Type: %s | Extra Effect: %s
  6589. item_data->name,item_data->jname,item_data->slot,item_data->nameid,
  6590. (item_data->type != IT_AMMO) ? itemdb_typename((enum item_types)item_data->type) : itemdb_typename_ammo((enum e_item_ammo)item_data->look),
  6591. (item_data->script==NULL)? msg_txt(sd,1278) : msg_txt(sd,1279) // None / With script
  6592. );
  6593. clif_displaymessage(fd, atcmd_output);
  6594. sprintf(atcmd_output, msg_txt(sd,1280), item_data->value_buy, item_data->value_sell, item_data->weight/10. ); // NPC Buy:%dz, Sell:%dz | Weight: %.1f
  6595. clif_displaymessage(fd, atcmd_output);
  6596. if (item_data->maxchance == -1) {
  6597. strcpy(atcmd_output, msg_txt(sd,1281)); // - Available in the shops only.
  6598. clif_displaymessage(fd, atcmd_output);
  6599. }
  6600. else if (!battle_config.atcommand_mobinfo_type) {
  6601. if (item_data->maxchance)
  6602. sprintf(atcmd_output, msg_txt(sd,1282), (float)item_data->maxchance / 100 ); // - Maximal monsters drop chance: %02.02f%%
  6603. else
  6604. strcpy(atcmd_output, msg_txt(sd,1283)); // - Monsters don't drop this item.
  6605. clif_displaymessage(fd, atcmd_output);
  6606. }
  6607. }
  6608. return 0;
  6609. }
  6610. /*==========================================
  6611. * Show who drops the item.
  6612. *------------------------------------------*/
  6613. ACMD_FUNC(whodrops)
  6614. {
  6615. struct item_data *item_data, *item_array[MAX_SEARCH];
  6616. int i,j, count = 1;
  6617. if (!message || !*message) {
  6618. clif_displaymessage(fd, msg_txt(sd,1284)); // Please enter item name/ID (usage: @whodrops <item name/ID>).
  6619. return -1;
  6620. }
  6621. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  6622. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  6623. if (!count) {
  6624. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  6625. return -1;
  6626. }
  6627. if (count == MAX_SEARCH) {
  6628. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH); // Displaying first %d matches
  6629. clif_displaymessage(fd, atcmd_output);
  6630. }
  6631. for (i = 0; i < count; i++) {
  6632. item_data = item_array[i];
  6633. sprintf(atcmd_output, msg_txt(sd,1285), item_data->jname, item_data->slot, item_data->nameid); // Item: '%s'[%d] (ID:%hu)
  6634. clif_displaymessage(fd, atcmd_output);
  6635. if (item_data->mob[0].chance == 0) {
  6636. strcpy(atcmd_output, msg_txt(sd,1286)); // - Item is not dropped by mobs.
  6637. clif_displaymessage(fd, atcmd_output);
  6638. } else {
  6639. sprintf(atcmd_output, msg_txt(sd,1287), MAX_SEARCH); // - Common mobs with highest drop chance (only max %d are listed):
  6640. clif_displaymessage(fd, atcmd_output);
  6641. for (j=0; j < MAX_SEARCH && item_data->mob[j].chance > 0; j++)
  6642. {
  6643. int dropchance = item_data->mob[j].chance;
  6644. #ifdef RENEWAL_DROP
  6645. if( battle_config.atcommand_mobinfo_type )
  6646. dropchance = dropchance * pc_level_penalty_mod(mob_db(item_data->mob[j].id)->lv - sd->status.base_level, mob_db(item_data->mob[j].id)->status.class_, mob_db(item_data->mob[j].id)->status.mode, 2) / 100;
  6647. #endif
  6648. if (pc_isvip(sd)) // Display item rate increase for VIP
  6649. dropchance += (dropchance * battle_config.vip_drop_increase) / 100;
  6650. sprintf(atcmd_output, "- %s (%d): %02.02f%%", mob_db(item_data->mob[j].id)->jname, item_data->mob[j].id, dropchance/100.);
  6651. clif_displaymessage(fd, atcmd_output);
  6652. }
  6653. }
  6654. }
  6655. return 0;
  6656. }
  6657. ACMD_FUNC(whereis)
  6658. {
  6659. struct mob_db *mob_array[MAX_SEARCH];
  6660. int count;
  6661. int i, j, k;
  6662. if (!message || !*message) {
  6663. clif_displaymessage(fd, msg_txt(sd,1288)); // Please enter a monster name/ID (usage: @whereis <monster_name_or_monster_ID>).
  6664. return -1;
  6665. }
  6666. // If monster identifier/name argument is a name
  6667. if ((i = mobdb_checkid(atoi(message))))
  6668. {
  6669. mob_array[0] = mob_db(i);
  6670. count = 1;
  6671. } else
  6672. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  6673. if (!count) {
  6674. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  6675. return -1;
  6676. }
  6677. if (count >= MAX_SEARCH) {
  6678. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH); // Displaying first %d matches
  6679. clif_displaymessage(fd, atcmd_output);
  6680. count = MAX_SEARCH;
  6681. }
  6682. for (k = 0; k < count; k++) {
  6683. struct mob_db *mob = mob_array[k];
  6684. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1289), mob->jname); // %s spawns in:
  6685. clif_displaymessage(fd, atcmd_output);
  6686. for (i = 0; i < ARRAYLENGTH(mob->spawn) && mob->spawn[i].qty; i++)
  6687. {
  6688. j = map_mapindex2mapid(mob->spawn[i].mapindex);
  6689. if (j < 0) continue;
  6690. snprintf(atcmd_output, sizeof atcmd_output, "%s (%d)", map[j].name, mob->spawn[i].qty);
  6691. clif_displaymessage(fd, atcmd_output);
  6692. }
  6693. if (i == 0)
  6694. clif_displaymessage(fd, msg_txt(sd,1290)); // This monster does not spawn normally.
  6695. }
  6696. return 0;
  6697. }
  6698. ACMD_FUNC(version)
  6699. {
  6700. pc_show_version(sd);
  6701. return 0;
  6702. }
  6703. /*==========================================
  6704. * @mutearea by MouseJstr
  6705. *------------------------------------------*/
  6706. static int atcommand_mutearea_sub(struct block_list *bl,va_list ap)
  6707. {
  6708. int time, id;
  6709. struct map_session_data *pl_sd = (struct map_session_data *)bl;
  6710. if (pl_sd == NULL)
  6711. return 0;
  6712. id = va_arg(ap, int);
  6713. time = va_arg(ap, int);
  6714. if (id != bl->id && !pc_get_group_level(pl_sd)) {
  6715. pl_sd->status.manner -= time;
  6716. if (pl_sd->status.manner < 0)
  6717. sc_start(NULL,&pl_sd->bl,SC_NOCHAT,100,0,0);
  6718. else
  6719. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  6720. }
  6721. return 0;
  6722. }
  6723. ACMD_FUNC(mutearea)
  6724. {
  6725. int time;
  6726. nullpo_ret(sd);
  6727. if (!message || !*message) {
  6728. clif_displaymessage(fd, msg_txt(sd,1297)); // Please enter a time in minutes (usage: @mutearea/@stfu <time in minutes>).
  6729. return -1;
  6730. }
  6731. time = atoi(message);
  6732. map_foreachinarea(atcommand_mutearea_sub,sd->bl.m,
  6733. sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE,
  6734. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time);
  6735. return 0;
  6736. }
  6737. ACMD_FUNC(rates)
  6738. {
  6739. char buf[CHAT_SIZE_MAX];
  6740. nullpo_ret(sd);
  6741. memset(buf, '\0', sizeof(buf));
  6742. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1298), // Experience rates: Base %.2fx / Job %.2fx
  6743. (battle_config.base_exp_rate + (pc_isvip(sd) ? (battle_config.vip_base_exp_increase * battle_config.base_exp_rate) / 100 : 0)) / 100.,
  6744. (battle_config.job_exp_rate + (pc_isvip(sd) ? (battle_config.vip_job_exp_increase * battle_config.job_exp_rate) / 100 : 0)) / 100.);
  6745. clif_displaymessage(fd, buf);
  6746. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1299), // Normal Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  6747. (battle_config.item_rate_common + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_common) / 100 : 0)) / 100.,
  6748. (battle_config.item_rate_heal + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_heal) / 100 : 0)) / 100.,
  6749. (battle_config.item_rate_use + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_use) / 100 : 0)) / 100.,
  6750. (battle_config.item_rate_equip + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_equip) / 100 : 0)) / 100.,
  6751. (battle_config.item_rate_card + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_card) / 100 : 0)) / 100.);
  6752. clif_displaymessage(fd, buf);
  6753. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1300), // Boss Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  6754. (battle_config.item_rate_common_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_common_boss) / 100 : 0)) / 100.,
  6755. (battle_config.item_rate_heal_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_heal_boss) / 100 : 0)) / 100.,
  6756. (battle_config.item_rate_use_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_use_boss) / 100 : 0)) / 100.,
  6757. (battle_config.item_rate_equip_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_equip_boss) / 100 : 0)) / 100.,
  6758. (battle_config.item_rate_card_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_card_boss) / 100 : 0)) / 100.);
  6759. clif_displaymessage(fd, buf);
  6760. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1024), // MVP Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  6761. (battle_config.item_rate_common_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_common_mvp) / 100 : 0)) / 100.,
  6762. (battle_config.item_rate_heal_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_heal_mvp) / 100 : 0)) / 100.,
  6763. (battle_config.item_rate_use_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_use_mvp) / 100 : 0)) / 100.,
  6764. (battle_config.item_rate_equip_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_equip_mvp) / 100 : 0)) / 100.,
  6765. (battle_config.item_rate_card_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_card_mvp) / 100 : 0)) / 100.);
  6766. clif_displaymessage(fd, buf);
  6767. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1301), // Other Drop Rates: MvP %.2fx / Card-Based %.2fx / Treasure %.2fx
  6768. (battle_config.item_rate_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_mvp) / 100 : 0)) / 100.,
  6769. (battle_config.item_rate_adddrop + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_adddrop) / 100 : 0)) / 100.,
  6770. (battle_config.item_rate_treasure + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_treasure) / 100 : 0)) / 100.);
  6771. clif_displaymessage(fd, buf);
  6772. return 0;
  6773. }
  6774. /*==========================================
  6775. * @me by lordalfa
  6776. * => Displays the OUTPUT string on top of the Visible players Heads.
  6777. *------------------------------------------*/
  6778. ACMD_FUNC(me)
  6779. {
  6780. char tempmes[CHAT_SIZE_MAX];
  6781. nullpo_retr(-1, sd);
  6782. memset(tempmes, '\0', sizeof(tempmes));
  6783. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6784. if (sd->sc.cant.chat)
  6785. return -1; //no "chatting" while muted.
  6786. if (!message || !*message || sscanf(message, "%255[^\n]", tempmes) < 0) {
  6787. clif_displaymessage(fd, msg_txt(sd,1302)); // Please enter a message (usage: @me <message>).
  6788. return -1;
  6789. }
  6790. sprintf(atcmd_output, msg_txt(sd,270), sd->status.name, tempmes); // *%s %s*
  6791. clif_disp_overhead(&sd->bl, atcmd_output);
  6792. return 0;
  6793. }
  6794. /*==========================================
  6795. * @size
  6796. * => Resize your character sprite. [Valaris]
  6797. *------------------------------------------*/
  6798. ACMD_FUNC(size)
  6799. {
  6800. int size = SZ_SMALL;
  6801. nullpo_retr(-1, sd);
  6802. size = cap_value(atoi(message),SZ_SMALL,SZ_BIG);
  6803. if(sd->state.size) {
  6804. sd->state.size = SZ_SMALL;
  6805. pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_TELEPORT);
  6806. }
  6807. sd->state.size = size;
  6808. if( size == SZ_MEDIUM )
  6809. clif_specialeffect(&sd->bl,420,AREA);
  6810. else if( size == SZ_BIG )
  6811. clif_specialeffect(&sd->bl,422,AREA);
  6812. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  6813. return 0;
  6814. }
  6815. ACMD_FUNC(sizeall)
  6816. {
  6817. int size;
  6818. struct map_session_data *pl_sd;
  6819. struct s_mapiterator* iter;
  6820. size = atoi(message);
  6821. size = cap_value(size,SZ_SMALL,SZ_BIG);
  6822. iter = mapit_getallusers();
  6823. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) {
  6824. if( pl_sd->state.size != size ) {
  6825. if( pl_sd->state.size ) {
  6826. pl_sd->state.size = SZ_SMALL;
  6827. pc_setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  6828. }
  6829. pl_sd->state.size = size;
  6830. if( size == SZ_MEDIUM )
  6831. clif_specialeffect(&pl_sd->bl,420,AREA);
  6832. else if( size == SZ_BIG )
  6833. clif_specialeffect(&pl_sd->bl,422,AREA);
  6834. }
  6835. }
  6836. mapit_free(iter);
  6837. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  6838. return 0;
  6839. }
  6840. ACMD_FUNC(sizeguild)
  6841. {
  6842. int size = SZ_SMALL, i;
  6843. char guild[NAME_LENGTH];
  6844. struct map_session_data *pl_sd;
  6845. struct guild *g;
  6846. nullpo_retr(-1, sd);
  6847. memset(guild, '\0', sizeof(guild));
  6848. if( !message || !*message || sscanf(message, "%11d %23[^\n]", &size, guild) < 2 ) {
  6849. clif_displaymessage(fd, msg_txt(sd,1304)); // Please enter guild name/ID (usage: @sizeguild <size> <guild name/ID>).
  6850. return -1;
  6851. }
  6852. if( (g = guild_searchname(guild)) == NULL && (g = guild_search(atoi(guild))) == NULL ) {
  6853. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  6854. return -1;
  6855. }
  6856. size = cap_value(size,SZ_SMALL,SZ_BIG);
  6857. for( i = 0; i < g->max_member; i++ ) {
  6858. if( (pl_sd = g->member[i].sd) && pl_sd->state.size != size ) {
  6859. if( pl_sd->state.size ) {
  6860. pl_sd->state.size = SZ_SMALL;
  6861. pc_setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  6862. }
  6863. pl_sd->state.size = size;
  6864. if( size == SZ_MEDIUM )
  6865. clif_specialeffect(&pl_sd->bl,420,AREA);
  6866. else if( size == SZ_BIG )
  6867. clif_specialeffect(&pl_sd->bl,422,AREA);
  6868. }
  6869. }
  6870. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  6871. return 0;
  6872. }
  6873. /*==========================================
  6874. * @monsterignore
  6875. * => Makes monsters ignore you. [Valaris]
  6876. *------------------------------------------*/
  6877. ACMD_FUNC(monsterignore)
  6878. {
  6879. nullpo_retr(-1, sd);
  6880. if (!sd->state.monster_ignore) {
  6881. sd->state.monster_ignore = 1;
  6882. clif_displaymessage(sd->fd, msg_txt(sd,1305)); // You are now immune to attacks.
  6883. } else {
  6884. sd->state.monster_ignore = 0;
  6885. clif_displaymessage(sd->fd, msg_txt(sd,1306)); // Returned to normal state.
  6886. }
  6887. return 0;
  6888. }
  6889. /*==========================================
  6890. * @fakename
  6891. * => Gives your character a fake name. [Valaris]
  6892. *------------------------------------------*/
  6893. ACMD_FUNC(fakename)
  6894. {
  6895. nullpo_retr(-1, sd);
  6896. if( !message || !*message )
  6897. {
  6898. if( sd->fakename[0] )
  6899. {
  6900. sd->fakename[0] = '\0';
  6901. clif_name_area(&sd->bl);
  6902. if (sd->disguise)
  6903. clif_name_self(&sd->bl);
  6904. clif_displaymessage(sd->fd, msg_txt(sd,1307)); // Returned to real name.
  6905. return 0;
  6906. }
  6907. clif_displaymessage(sd->fd, msg_txt(sd,1308)); // You must enter a name.
  6908. return -1;
  6909. }
  6910. if( strlen(message) < 2 )
  6911. {
  6912. clif_displaymessage(sd->fd, msg_txt(sd,1309)); // Fake name must be at least two characters.
  6913. return -1;
  6914. }
  6915. safestrncpy(sd->fakename, message, sizeof(sd->fakename));
  6916. clif_name_area(&sd->bl);
  6917. if (sd->disguise) // Another packet should be sent so the client updates the name for sd
  6918. clif_name_self(&sd->bl);
  6919. clif_displaymessage(sd->fd, msg_txt(sd,1310)); // Fake name enabled.
  6920. return 0;
  6921. }
  6922. /*==========================================
  6923. * Ragnarok Resources
  6924. *------------------------------------------*/
  6925. ACMD_FUNC(mapflag) {
  6926. #define checkflag( cmd ) if ( map[ sd->bl.m ].flag.cmd ) clif_displaymessage(sd->fd,#cmd)
  6927. #define setflag( cmd ) \
  6928. if ( strcmp( flag_name , #cmd ) == 0 ){\
  6929. map[ sd->bl.m ].flag.cmd = flag;\
  6930. sprintf(atcmd_output,"[ @mapflag ] %s flag has been set to %s value = %hd",#cmd,flag?"On":"Off",flag);\
  6931. clif_displaymessage(sd->fd,atcmd_output);\
  6932. return 0;\
  6933. }
  6934. char flag_name[100];
  6935. short flag=0,i;
  6936. nullpo_retr(-1, sd);
  6937. memset(flag_name, '\0', sizeof(flag_name));
  6938. if (!message || !*message || (sscanf(message, "%99s %6hd", flag_name, &flag) < 1)) {
  6939. clif_displaymessage(sd->fd,msg_txt(sd,1311)); // Enabled Mapflags in this map:
  6940. clif_displaymessage(sd->fd,"----------------------------------");
  6941. checkflag(town); checkflag(autotrade); checkflag(allowks); checkflag(nomemo);
  6942. checkflag(noteleport); checkflag(noreturn); checkflag(monster_noteleport); checkflag(nosave);
  6943. checkflag(nobranch); checkflag(noexppenalty); checkflag(pvp); checkflag(pvp_noparty);
  6944. checkflag(pvp_noguild); checkflag(pvp_nightmaredrop); checkflag(pvp_nocalcrank); checkflag(gvg_castle);
  6945. checkflag(gvg); checkflag(gvg_dungeon); checkflag(gvg_noparty); checkflag(battleground);
  6946. checkflag(nozenypenalty); checkflag(notrade); checkflag(noskill); checkflag(nowarp);
  6947. checkflag(nowarpto); checkflag(noicewall); checkflag(snow); checkflag(clouds);
  6948. checkflag(clouds2); checkflag(fog); checkflag(fireworks); checkflag(sakura);
  6949. checkflag(leaves); checkflag(nogo); checkflag(nobaseexp); checkflag(nojobexp);
  6950. checkflag(nomobloot); checkflag(nomvploot); checkflag(nightenabled); checkflag(restricted);
  6951. checkflag(nodrop); checkflag(novending); checkflag(loadevent); checkflag(nochat);
  6952. checkflag(partylock); checkflag(guildlock); checkflag(reset); checkflag(chmautojoin);
  6953. checkflag(nousecart); checkflag(noitemconsumption); checkflag(nosumstarmiracle); checkflag(nomineeffect);
  6954. checkflag(nolockon); checkflag(notomb); checkflag(nocostume); checkflag(gvg_te);
  6955. checkflag(gvg_te_castle); checkflag(hidemobhpbar);
  6956. #ifdef ADJUST_SKILL_DAMAGE
  6957. checkflag(skill_damage);
  6958. #endif
  6959. clif_displaymessage(sd->fd," ");
  6960. clif_displaymessage(sd->fd,msg_txt(sd,1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On)
  6961. clif_displaymessage(sd->fd,msg_txt(sd,1313)); // Type "@mapflag available" to list the available mapflags.
  6962. return 1;
  6963. }
  6964. for (i = 0; flag_name[i]; i++) flag_name[i] = (char)tolower(flag_name[i]); //lowercase
  6965. setflag(town); setflag(autotrade); setflag(allowks); setflag(nomemo);
  6966. setflag(noteleport); setflag(noreturn); setflag(monster_noteleport); setflag(nosave);
  6967. setflag(nobranch); setflag(noexppenalty); setflag(pvp); setflag(pvp_noparty);
  6968. setflag(pvp_noguild); setflag(pvp_nightmaredrop); setflag(pvp_nocalcrank); setflag(gvg_castle);
  6969. setflag(gvg); setflag(gvg_dungeon); setflag(gvg_noparty); setflag(battleground);
  6970. setflag(nozenypenalty); setflag(notrade); setflag(noskill); setflag(nowarp);
  6971. setflag(nowarpto); setflag(noicewall); setflag(snow); setflag(clouds);
  6972. setflag(clouds2); setflag(fog); setflag(fireworks); setflag(sakura);
  6973. setflag(leaves); setflag(nogo); setflag(nobaseexp); setflag(nojobexp);
  6974. setflag(nomobloot); setflag(nomvploot); setflag(nightenabled); setflag(restricted);
  6975. setflag(nodrop); setflag(novending); setflag(loadevent); setflag(nochat);
  6976. setflag(partylock); setflag(guildlock); setflag(reset); setflag(chmautojoin);
  6977. setflag(nousecart); setflag(noitemconsumption); setflag(nosumstarmiracle); setflag(nomineeffect);
  6978. setflag(nolockon); setflag(notomb); setflag(nocostume); setflag(gvg_te);
  6979. setflag(gvg_te_castle); setflag(hidemobhpbar);
  6980. #ifdef ADJUST_SKILL_DAMAGE
  6981. setflag(skill_damage);
  6982. #endif
  6983. clif_displaymessage(sd->fd,msg_txt(sd,1314)); // Invalid flag name or flag.
  6984. clif_displaymessage(sd->fd,msg_txt(sd,1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On)
  6985. clif_displaymessage(sd->fd,msg_txt(sd,1315)); // Available Flags:
  6986. clif_displaymessage(sd->fd,"----------------------------------");
  6987. clif_displaymessage(sd->fd,"town, autotrade, allowks, nomemo, noteleport, noreturn, monster_noteleport, nosave,");
  6988. clif_displaymessage(sd->fd,"nobranch, noexppenalty, pvp, pvp_noparty, pvp_noguild, pvp_nightmaredrop,");
  6989. clif_displaymessage(sd->fd,"pvp_nocalcrank, gvg_castle, gvg, gvg_dungeon, gvg_noparty, battleground,");
  6990. clif_displaymessage(sd->fd,"nozenypenalty, notrade, noskill, nowarp, nowarpto, noicewall, snow, clouds, clouds2,");
  6991. clif_displaymessage(sd->fd,"fog, fireworks, sakura, leaves, nogo, nobaseexp, nojobexp, nomobloot, nomvploot,");
  6992. clif_displaymessage(sd->fd,"nightenabled, restricted, nodrop, novending, loadevent, nochat, partylock, guildlock,");
  6993. clif_displaymessage(sd->fd,"reset, chmautojoin, nousecart, noitemconsumption, nosumstarmiracle, nolockon, notomb,");
  6994. clif_displaymessage(sd->fd,"nocostume, gvg_te, gvg_te_castle, hidemobhpbar");
  6995. #ifdef ADJUST_SKILL_DAMAGE
  6996. clif_displaymessage(sd->fd,"skill_damage");
  6997. #endif
  6998. #undef checkflag
  6999. #undef setflag
  7000. return 0;
  7001. }
  7002. /*===================================
  7003. * Remove some messages
  7004. *-----------------------------------*/
  7005. ACMD_FUNC(showexp)
  7006. {
  7007. if (sd->state.showexp) {
  7008. sd->state.showexp = 0;
  7009. clif_displaymessage(fd, msg_txt(sd,1316)); // Gained exp will not be shown.
  7010. return 0;
  7011. }
  7012. sd->state.showexp = 1;
  7013. clif_displaymessage(fd, msg_txt(sd,1317)); // Gained exp is now shown.
  7014. return 0;
  7015. }
  7016. ACMD_FUNC(showzeny)
  7017. {
  7018. if (sd->state.showzeny) {
  7019. sd->state.showzeny = 0;
  7020. clif_displaymessage(fd, msg_txt(sd,1318)); // Gained zeny will not be shown.
  7021. return 0;
  7022. }
  7023. sd->state.showzeny = 1;
  7024. clif_displaymessage(fd, msg_txt(sd,1319)); // Gained zeny is now shown.
  7025. return 0;
  7026. }
  7027. ACMD_FUNC(showdelay)
  7028. {
  7029. if (sd->state.showdelay) {
  7030. sd->state.showdelay = 0;
  7031. clif_displaymessage(fd, msg_txt(sd,1320)); // Skill delay failures will not be shown.
  7032. return 0;
  7033. }
  7034. sd->state.showdelay = 1;
  7035. clif_displaymessage(fd, msg_txt(sd,1321)); // Skill delay failures are now shown.
  7036. return 0;
  7037. }
  7038. /*==========================================
  7039. * Duel organizing functions [LuzZza]
  7040. *
  7041. * @duel [limit|nick] - create a duel
  7042. * @invite <nick> - invite player
  7043. * @accept - accept invitation
  7044. * @reject - reject invitation
  7045. * @leave - leave duel
  7046. *------------------------------------------*/
  7047. ACMD_FUNC(invite)
  7048. {
  7049. unsigned int did = sd->duel_group;
  7050. struct map_session_data *target_sd = map_nick2sd((char *)message,true);
  7051. if(did == 0) {
  7052. // "Duel: @invite without @duel."
  7053. clif_displaymessage(fd, msg_txt(sd,350));
  7054. return 0;
  7055. }
  7056. if(duel_list[did].max_players_limit > 0 &&
  7057. duel_list[did].members_count >= duel_list[did].max_players_limit) {
  7058. // "Duel: Limit of players is reached."
  7059. clif_displaymessage(fd, msg_txt(sd,351));
  7060. return 0;
  7061. }
  7062. if(target_sd == NULL) {
  7063. // "Duel: Player not found."
  7064. clif_displaymessage(fd, msg_txt(sd,352));
  7065. return 0;
  7066. }
  7067. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  7068. // "Duel: Player already in duel."
  7069. clif_displaymessage(fd, msg_txt(sd,353));
  7070. return 0;
  7071. }
  7072. if(battle_config.duel_only_on_same_map && target_sd->bl.m != sd->bl.m)
  7073. {
  7074. sprintf(atcmd_output, msg_txt(sd,364), message);
  7075. clif_displaymessage(fd, atcmd_output);
  7076. return 0;
  7077. }
  7078. duel_invite(did, sd, target_sd);
  7079. // "Duel: Invitation has been sent."
  7080. clif_displaymessage(fd, msg_txt(sd,354));
  7081. return 0;
  7082. }
  7083. ACMD_FUNC(duel)
  7084. {
  7085. unsigned int maxpl = 0;
  7086. if(sd->duel_group > 0) {
  7087. duel_showinfo(sd->duel_group, sd);
  7088. return 0;
  7089. }
  7090. if(sd->duel_invite > 0) {
  7091. // "Duel: @duel without @reject."
  7092. clif_displaymessage(fd, msg_txt(sd,355));
  7093. return 0;
  7094. }
  7095. if(!duel_checktime(sd)) {
  7096. char output[CHAT_SIZE_MAX];
  7097. // "Duel: You can take part in duel only one time per %d minutes."
  7098. sprintf(output, msg_txt(sd,356), battle_config.duel_time_interval);
  7099. clif_displaymessage(fd, output);
  7100. return 0;
  7101. }
  7102. if( message[0] ) {
  7103. if(sscanf(message, "%11u", &maxpl) >= 1) {
  7104. if(maxpl < 2 || maxpl > 65535) {
  7105. clif_displaymessage(fd, msg_txt(sd,357)); // "Duel: Invalid value."
  7106. return 0;
  7107. }
  7108. duel_create(sd, maxpl);
  7109. } else {
  7110. struct map_session_data *target_sd;
  7111. target_sd = map_nick2sd((char *)message,true);
  7112. if(target_sd != NULL) {
  7113. unsigned int newduel;
  7114. if((newduel = duel_create(sd, 2)) != -1) {
  7115. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  7116. clif_displaymessage(fd, msg_txt(sd,353)); // "Duel: Player already in duel."
  7117. return 0;
  7118. }
  7119. duel_invite(newduel, sd, target_sd);
  7120. clif_displaymessage(fd, msg_txt(sd,354)); // "Duel: Invitation has been sent."
  7121. }
  7122. } else {
  7123. // "Duel: Player not found."
  7124. clif_displaymessage(fd, msg_txt(sd,352));
  7125. return 0;
  7126. }
  7127. }
  7128. } else
  7129. duel_create(sd, 0);
  7130. return 0;
  7131. }
  7132. ACMD_FUNC(leave)
  7133. {
  7134. if(sd->duel_group <= 0) {
  7135. // "Duel: @leave without @duel."
  7136. clif_displaymessage(fd, msg_txt(sd,358));
  7137. return 0;
  7138. }
  7139. duel_leave(sd->duel_group, sd);
  7140. clif_displaymessage(fd, msg_txt(sd,359)); // "Duel: You left the duel."
  7141. return 0;
  7142. }
  7143. ACMD_FUNC(accept)
  7144. {
  7145. if(!duel_checktime(sd)) {
  7146. char output[CHAT_SIZE_MAX];
  7147. // "Duel: You can take part in duel only one time per %d minutes."
  7148. sprintf(output, msg_txt(sd,356), battle_config.duel_time_interval);
  7149. clif_displaymessage(fd, output);
  7150. return 0;
  7151. }
  7152. if(sd->duel_invite <= 0) {
  7153. // "Duel: @accept without invititation."
  7154. clif_displaymessage(fd, msg_txt(sd,360));
  7155. return 0;
  7156. }
  7157. 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 )
  7158. {
  7159. // "Duel: Limit of players is reached."
  7160. clif_displaymessage(fd, msg_txt(sd,351));
  7161. return 0;
  7162. }
  7163. duel_accept(sd->duel_invite, sd);
  7164. // "Duel: Invitation has been accepted."
  7165. clif_displaymessage(fd, msg_txt(sd,361));
  7166. return 0;
  7167. }
  7168. ACMD_FUNC(reject)
  7169. {
  7170. if(sd->duel_invite <= 0) {
  7171. // "Duel: @reject without invititation."
  7172. clif_displaymessage(fd, msg_txt(sd,362));
  7173. return 0;
  7174. }
  7175. duel_reject(sd->duel_invite, sd);
  7176. // "Duel: Invitation has been rejected."
  7177. clif_displaymessage(fd, msg_txt(sd,363));
  7178. return 0;
  7179. }
  7180. /*===================================
  7181. * Cash Points
  7182. *-----------------------------------*/
  7183. ACMD_FUNC(cash)
  7184. {
  7185. char output[128];
  7186. int value;
  7187. int ret=0;
  7188. nullpo_retr(-1, sd);
  7189. if( !message || !*message || (value = atoi(message)) == 0 ) {
  7190. clif_displaymessage(fd, msg_txt(sd,1322)); // Please enter an amount.
  7191. return -1;
  7192. }
  7193. parent_cmd = atcommand_checkalias(command+1);
  7194. if( !strcmpi(parent_cmd,"cash") )
  7195. {
  7196. if( value > 0 ) {
  7197. if( (ret=pc_getcash(sd, value, 0, LOG_TYPE_COMMAND)) >= 0){
  7198. // If this option is set, the message is already sent by pc function
  7199. if( !battle_config.cashshop_show_points ){
  7200. sprintf(output, msg_txt(sd,505), ret, sd->cashPoints);
  7201. clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], output, false, SELF);
  7202. }
  7203. }
  7204. else clif_displaymessage(fd, msg_txt(sd,149)); // Unable to decrease the number/value.
  7205. } else {
  7206. if (-value > sd->cashPoints) //By command, if cash < value, force it to remove all
  7207. value = -sd->cashPoints;
  7208. if( (ret=pc_paycash(sd, -value, 0, LOG_TYPE_COMMAND)) >= 0){
  7209. // If this option is set, the message is already sent by pc function
  7210. if( !battle_config.cashshop_show_points ){
  7211. sprintf(output, msg_txt(sd,410), ret, sd->cashPoints);
  7212. clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], output, false, SELF);
  7213. }
  7214. }
  7215. else clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  7216. }
  7217. }
  7218. else
  7219. { // @points
  7220. if( value > 0 ) {
  7221. if( (ret=pc_getcash(sd, 0, value, LOG_TYPE_COMMAND)) >= 0){
  7222. sprintf(output, msg_txt(sd,506), ret, sd->kafraPoints);
  7223. clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], output, false, SELF);
  7224. }
  7225. else clif_displaymessage(fd, msg_txt(sd,149)); // Unable to decrease the number/value.
  7226. } else {
  7227. if( (ret=pc_paycash(sd, -value, -value, LOG_TYPE_COMMAND)) >= 0){
  7228. sprintf(output, msg_txt(sd,411), ret, sd->kafraPoints);
  7229. clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], output, false, SELF);
  7230. }
  7231. else clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  7232. }
  7233. }
  7234. return 0;
  7235. }
  7236. // @clone/@slaveclone/@evilclone <playername> [Valaris]
  7237. ACMD_FUNC(clone)
  7238. {
  7239. int x=0,y=0,flag=0,master=0,i=0;
  7240. struct map_session_data *pl_sd=NULL;
  7241. if (!message || !*message) {
  7242. clif_displaymessage(sd->fd,msg_txt(sd,1323)); // You must enter a player name or ID.
  7243. return 0;
  7244. }
  7245. if((pl_sd=map_nick2sd((char *)message,true)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL) {
  7246. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  7247. return 0;
  7248. }
  7249. if(pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  7250. clif_displaymessage(fd, msg_txt(sd,126)); // Cannot clone a player of higher GM level than yourself.
  7251. return 0;
  7252. }
  7253. parent_cmd = atcommand_checkalias(command+1);
  7254. if (strcmpi(parent_cmd, "clone") == 0)
  7255. flag = 1;
  7256. else if (strcmpi(parent_cmd, "slaveclone") == 0) {
  7257. flag = 2;
  7258. if(pc_isdead(sd)){
  7259. clif_displaymessage(fd, msg_txt(sd,129+flag*2));
  7260. return 0;
  7261. }
  7262. master = sd->bl.id;
  7263. if (battle_config.atc_slave_clone_limit
  7264. && mob_countslave(&sd->bl) >= battle_config.atc_slave_clone_limit) {
  7265. clif_displaymessage(fd, msg_txt(sd,127)); // You've reached your slave clones limit.
  7266. return 0;
  7267. }
  7268. }
  7269. do {
  7270. x = sd->bl.x + (rnd() % 10 - 5);
  7271. y = sd->bl.y + (rnd() % 10 - 5);
  7272. } while (map_getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10);
  7273. if (i >= 10) {
  7274. x = sd->bl.x;
  7275. y = sd->bl.y;
  7276. }
  7277. if((x = mob_clone_spawn(pl_sd, sd->bl.m, x, y, "", master, 0, flag?1:0, 0)) > 0) {
  7278. clif_displaymessage(fd, msg_txt(sd,128+flag*2)); // Evil Clone spawned. Clone spawned. Slave clone spawned.
  7279. return 0;
  7280. }
  7281. clif_displaymessage(fd, msg_txt(sd,129+flag*2)); // Unable to spawn evil clone. Unable to spawn clone. Unable to spawn slave clone.
  7282. return 0;
  7283. }
  7284. /*=====================================
  7285. * Autorejecting Invites/Deals [LuzZza]
  7286. * Usage: @noask
  7287. *-------------------------------------*/
  7288. ACMD_FUNC(noask)
  7289. {
  7290. if(sd->state.noask) {
  7291. clif_displaymessage(fd, msg_txt(sd,391)); // Autorejecting is deactivated.
  7292. sd->state.noask = 0;
  7293. } else {
  7294. clif_displaymessage(fd, msg_txt(sd,390)); // Autorejecting is activated.
  7295. sd->state.noask = 1;
  7296. }
  7297. return 0;
  7298. }
  7299. /*=====================================
  7300. * Send a @request message to all GMs of lowest_gm_level.
  7301. * Usage: @request <petition>
  7302. *-------------------------------------*/
  7303. ACMD_FUNC(request)
  7304. {
  7305. if (!message || !*message) {
  7306. clif_displaymessage(sd->fd,msg_txt(sd,277)); // Usage: @request <petition/message to online GMs>.
  7307. return -1;
  7308. }
  7309. sprintf(atcmd_output, msg_txt(sd,278), message); // (@request): %s
  7310. intif_wis_message_to_gm(sd->status.name, PC_PERM_RECEIVE_REQUESTS, atcmd_output);
  7311. clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], atcmd_output, false, SELF);
  7312. clif_displaymessage(sd->fd,msg_txt(sd,279)); // @request sent.
  7313. return 0;
  7314. }
  7315. /*==========================================
  7316. * Feel (SG save map) Reset [HiddenDragon]
  7317. *------------------------------------------*/
  7318. ACMD_FUNC(feelreset)
  7319. {
  7320. pc_resetfeel(sd);
  7321. clif_displaymessage(fd, msg_txt(sd,1324)); // Reset 'Feeling' maps.
  7322. return 0;
  7323. }
  7324. /*==========================================
  7325. * AUCTION SYSTEM
  7326. *------------------------------------------*/
  7327. ACMD_FUNC(auction)
  7328. {
  7329. nullpo_ret(sd);
  7330. if (!battle_config.feature_auction) {
  7331. clif_messagecolor(&sd->bl, color_table[COLOR_RED], msg_txt(sd, 517), false, SELF);
  7332. return 0;
  7333. }
  7334. clif_Auction_openwindow(sd);
  7335. return 0;
  7336. }
  7337. /*==========================================
  7338. * Kill Steal Protection
  7339. *------------------------------------------*/
  7340. ACMD_FUNC(ksprotection)
  7341. {
  7342. nullpo_retr(-1,sd);
  7343. if( sd->state.noks ) {
  7344. sd->state.noks = 0;
  7345. clif_displaymessage(fd, msg_txt(sd,1325)); // [ K.S Protection Inactive ]
  7346. }
  7347. else
  7348. {
  7349. if( !message || !*message || !strcmpi(message, "party") )
  7350. { // Default is Party
  7351. sd->state.noks = 2;
  7352. clif_displaymessage(fd, msg_txt(sd,1326)); // [ K.S Protection Active - Option: Party ]
  7353. }
  7354. else if( !strcmpi(message, "self") )
  7355. {
  7356. sd->state.noks = 1;
  7357. clif_displaymessage(fd, msg_txt(sd,1327)); // [ K.S Protection Active - Option: Self ]
  7358. }
  7359. else if( !strcmpi(message, "guild") )
  7360. {
  7361. sd->state.noks = 3;
  7362. clif_displaymessage(fd, msg_txt(sd,1328)); // [ K.S Protection Active - Option: Guild ]
  7363. }
  7364. else
  7365. clif_displaymessage(fd, msg_txt(sd,1329)); // Usage: @noks <self|party|guild>
  7366. }
  7367. return 0;
  7368. }
  7369. /*==========================================
  7370. * Map Kill Steal Protection Setting
  7371. *------------------------------------------*/
  7372. ACMD_FUNC(allowks)
  7373. {
  7374. nullpo_retr(-1,sd);
  7375. if( map[sd->bl.m].flag.allowks ) {
  7376. map[sd->bl.m].flag.allowks = 0;
  7377. clif_displaymessage(fd, msg_txt(sd,1330)); // [ Map K.S Protection Active ]
  7378. } else {
  7379. map[sd->bl.m].flag.allowks = 1;
  7380. clif_displaymessage(fd, msg_txt(sd,1331)); // [ Map K.S Protection Inactive ]
  7381. }
  7382. return 0;
  7383. }
  7384. ACMD_FUNC(resetstat)
  7385. {
  7386. nullpo_retr(-1, sd);
  7387. pc_resetstate(sd);
  7388. sprintf(atcmd_output, msg_txt(sd,207), sd->status.name);
  7389. clif_displaymessage(fd, atcmd_output);
  7390. return 0;
  7391. }
  7392. ACMD_FUNC(resetskill)
  7393. {
  7394. nullpo_retr(-1,sd);
  7395. pc_resetskill(sd,1);
  7396. sprintf(atcmd_output, msg_txt(sd,206), sd->status.name);
  7397. clif_displaymessage(fd, atcmd_output);
  7398. return 0;
  7399. }
  7400. /*==========================================
  7401. * #storagelist: Displays the items list of a player's storage.
  7402. * #cartlist: Displays contents of target's cart.
  7403. * #itemlist: Displays contents of target's inventory.
  7404. *------------------------------------------*/
  7405. ACMD_FUNC(itemlist)
  7406. {
  7407. int i, j, count, counter;
  7408. const char* location;
  7409. const struct item* items;
  7410. int size;
  7411. StringBuf buf;
  7412. nullpo_retr(-1, sd);
  7413. parent_cmd = atcommand_checkalias(command+1);
  7414. if( strcmp(parent_cmd, "storagelist") == 0 ) {
  7415. location = "storage";
  7416. items = sd->storage.u.items_storage;
  7417. size = sd->storage.max_amount;
  7418. } else if( strcmp(parent_cmd, "cartlist") == 0 ) {
  7419. location = "cart";
  7420. items = sd->cart.u.items_cart;
  7421. size = MAX_CART;
  7422. } else if( strcmp(parent_cmd, "itemlist") == 0 ) {
  7423. location = "inventory";
  7424. items = sd->inventory.u.items_inventory;
  7425. size = MAX_INVENTORY;
  7426. } else
  7427. return 1;
  7428. StringBuf_Init(&buf);
  7429. count = 0; // total slots occupied
  7430. counter = 0; // total items found
  7431. for( i = 0; i < size; ++i ) {
  7432. const struct item* it = &items[i];
  7433. struct item_data* itd;
  7434. if( it->nameid == 0 || (itd = itemdb_exists(it->nameid)) == NULL )
  7435. continue;
  7436. counter += it->amount;
  7437. count++;
  7438. if( count == 1 ) {
  7439. StringBuf_Printf(&buf, msg_txt(sd,1332), location, sd->status.name); // ------ %s items list of '%s' ------
  7440. clif_displaymessage(fd, StringBuf_Value(&buf));
  7441. StringBuf_Clear(&buf);
  7442. }
  7443. if( it->refine )
  7444. StringBuf_Printf(&buf, "%d %s %+d (%s, id: %d)", it->amount, itd->jname, it->refine, itd->name, it->nameid);
  7445. else
  7446. StringBuf_Printf(&buf, "%d %s (%s, id: %d)", it->amount, itd->jname, itd->name, it->nameid);
  7447. if( it->equip ) {
  7448. char equipstr[CHAT_SIZE_MAX];
  7449. strcpy(equipstr, msg_txt(sd,1333)); // | Equipped:
  7450. if( it->equip&EQP_GARMENT )
  7451. strcat(equipstr, msg_txt(sd,1334)); // Robe,
  7452. if( it->equip&EQP_ACC_L )
  7453. strcat(equipstr, msg_txt(sd,1335)); // Left Accessory,
  7454. if( it->equip&EQP_ARMOR )
  7455. strcat(equipstr, msg_txt(sd,1336)); // Body/Armor,
  7456. if( (it->equip&EQP_ARMS) == EQP_HAND_R )
  7457. strcat(equipstr, msg_txt(sd,1337)); // Right Hand,
  7458. if( (it->equip&EQP_ARMS) == EQP_HAND_L )
  7459. strcat(equipstr, msg_txt(sd,1338)); // Left Hand,
  7460. if( (it->equip&EQP_ARMS) == EQP_ARMS )
  7461. strcat(equipstr, msg_txt(sd,1339)); // Both Hands,
  7462. if( it->equip&EQP_SHOES )
  7463. strcat(equipstr, msg_txt(sd,1340)); // Shoes,
  7464. if( it->equip&EQP_ACC_R )
  7465. strcat(equipstr, msg_txt(sd,1341)); // Right Accessory,
  7466. if( (it->equip&EQP_HELM) == EQP_HEAD_LOW )
  7467. strcat(equipstr, msg_txt(sd,1342)); // Lower Head,
  7468. if( (it->equip&EQP_HELM) == EQP_HEAD_TOP )
  7469. strcat(equipstr, msg_txt(sd,1343)); // Top Head,
  7470. if( (it->equip&EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_TOP) )
  7471. strcat(equipstr, msg_txt(sd,1344)); // Top/Lower Head,
  7472. if( (it->equip&EQP_HELM) == EQP_HEAD_MID )
  7473. strcat(equipstr, msg_txt(sd,1345)); // Mid Head,
  7474. if( (it->equip&EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_MID) )
  7475. strcat(equipstr, msg_txt(sd,1346)); // Mid/Lower Head,
  7476. if( (it->equip&EQP_HELM) == EQP_HELM )
  7477. strcat(equipstr, msg_txt(sd,1347)); // Top/Mid/Lower Head,
  7478. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HEAD_LOW )
  7479. strcat(equipstr, msg_txt(sd,518));
  7480. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HEAD_TOP )
  7481. strcat(equipstr, msg_txt(sd,519));
  7482. if( (it->equip&EQP_COSTUME_HELM) == (EQP_COSTUME_HEAD_LOW|EQP_COSTUME_HEAD_TOP) )
  7483. strcat(equipstr, msg_txt(sd,520));
  7484. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HEAD_MID )
  7485. strcat(equipstr, msg_txt(sd,521));
  7486. if( (it->equip&EQP_COSTUME_HELM) == (EQP_COSTUME_HEAD_LOW|EQP_COSTUME_HEAD_MID) )
  7487. strcat(equipstr, msg_txt(sd,522));
  7488. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HELM )
  7489. strcat(equipstr, msg_txt(sd,523));
  7490. if( it->equip&EQP_COSTUME_GARMENT )
  7491. strcat(equipstr, msg_txt(sd,524));
  7492. //if( it->equip&EQP_COSTUME_FLOOR )
  7493. //strcat(equipstr, msg_txt(sd,525));
  7494. if( it->equip&EQP_AMMO )
  7495. strcat(equipstr, msg_txt(sd,526));
  7496. if( it->equip&EQP_SHADOW_ARMOR )
  7497. strcat(equipstr, msg_txt(sd,527));
  7498. if( (it->equip&EQP_SHADOW_ARMS) == EQP_SHADOW_WEAPON )
  7499. strcat(equipstr, msg_txt(sd,528));
  7500. if( (it->equip&EQP_SHADOW_ARMS) == EQP_SHADOW_SHIELD )
  7501. strcat(equipstr, msg_txt(sd,529));
  7502. if( (it->equip&EQP_SHADOW_ARMS) == EQP_SHADOW_ARMS )
  7503. strcat(equipstr, msg_txt(sd,530));
  7504. if( it->equip&EQP_SHADOW_SHOES )
  7505. strcat(equipstr, msg_txt(sd,531));
  7506. if( it->equip&EQP_SHADOW_ACC_R )
  7507. strcat(equipstr, msg_txt(sd,532));
  7508. if( it->equip&EQP_SHADOW_ACC_L )
  7509. strcat(equipstr, msg_txt(sd,533));
  7510. // remove final ', '
  7511. equipstr[strlen(equipstr) - 2] = '\0';
  7512. StringBuf_AppendStr(&buf, equipstr);
  7513. }
  7514. clif_displaymessage(fd, StringBuf_Value(&buf));
  7515. StringBuf_Clear(&buf);
  7516. if( it->card[0] == CARD0_PET ) { // pet egg
  7517. if (it->card[3])
  7518. StringBuf_Printf(&buf, msg_txt(sd,1348), (unsigned int)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, named)
  7519. else
  7520. StringBuf_Printf(&buf, msg_txt(sd,1349), (unsigned int)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, unnamed)
  7521. } else if(it->card[0] == CARD0_FORGE) { // forged item
  7522. StringBuf_Printf(&buf, msg_txt(sd,1350), (unsigned int)MakeDWord(it->card[2], it->card[3]), it->card[1]>>8, it->card[1]&0x0f); // -> (crafted item, creator id: %u, star crumbs %d, element %d)
  7523. } else if(it->card[0] == CARD0_CREATE) { // created item
  7524. StringBuf_Printf(&buf, msg_txt(sd,1351), (unsigned int)MakeDWord(it->card[2], it->card[3])); // -> (produced item, creator id: %u)
  7525. } else { // normal item
  7526. int counter2 = 0;
  7527. for( j = 0; j < itd->slot; ++j ) {
  7528. struct item_data* card;
  7529. if( it->card[j] == 0 || (card = itemdb_exists(it->card[j])) == NULL )
  7530. continue;
  7531. counter2++;
  7532. if( counter2 == 1 )
  7533. StringBuf_AppendStr(&buf, msg_txt(sd,1352)); // -> (card(s):
  7534. if( counter2 != 1 )
  7535. StringBuf_AppendStr(&buf, ", ");
  7536. StringBuf_Printf(&buf, "#%d %s (id: %d)", counter2, card->jname, card->nameid);
  7537. }
  7538. if( counter2 > 0 )
  7539. StringBuf_AppendStr(&buf, ")");
  7540. }
  7541. if( StringBuf_Length(&buf) > 0 )
  7542. clif_displaymessage(fd, StringBuf_Value(&buf));
  7543. StringBuf_Clear(&buf);
  7544. }
  7545. if( count == 0 )
  7546. StringBuf_Printf(&buf, msg_txt(sd,1353), location); // No item found in this player's %s.
  7547. else
  7548. StringBuf_Printf(&buf, msg_txt(sd,1354), counter, count, location); // %d item(s) found in %d %s slots.
  7549. clif_displaymessage(fd, StringBuf_Value(&buf));
  7550. StringBuf_Destroy(&buf);
  7551. return 0;
  7552. }
  7553. ACMD_FUNC(stats)
  7554. {
  7555. char job_jobname[100];
  7556. char output[CHAT_SIZE_MAX];
  7557. int i;
  7558. struct {
  7559. const char* format;
  7560. int value;
  7561. } output_table[] = {
  7562. { "Base Level - %d", 0 },
  7563. { NULL, 0 },
  7564. { "Hp - %d", 0 },
  7565. { "MaxHp - %d", 0 },
  7566. { "Sp - %d", 0 },
  7567. { "MaxSp - %d", 0 },
  7568. { "Str - %3d", 0 },
  7569. { "Agi - %3d", 0 },
  7570. { "Vit - %3d", 0 },
  7571. { "Int - %3d", 0 },
  7572. { "Dex - %3d", 0 },
  7573. { "Luk - %3d", 0 },
  7574. { "Zeny - %d", 0 },
  7575. { "Free SK Points - %d", 0 },
  7576. { "JobChangeLvl (2nd) - %d", 0 },
  7577. { "JobChangeLvl (3rd) - %d", 0 },
  7578. { NULL, 0 }
  7579. };
  7580. memset(job_jobname, '\0', sizeof(job_jobname));
  7581. memset(output, '\0', sizeof(output));
  7582. //direct array initialization with variables is not standard C compliant.
  7583. output_table[0].value = sd->status.base_level;
  7584. output_table[1].format = job_jobname;
  7585. output_table[1].value = sd->status.job_level;
  7586. output_table[2].value = sd->status.hp;
  7587. output_table[3].value = sd->status.max_hp;
  7588. output_table[4].value = sd->status.sp;
  7589. output_table[5].value = sd->status.max_sp;
  7590. output_table[6].value = sd->status.str;
  7591. output_table[7].value = sd->status.agi;
  7592. output_table[8].value = sd->status.vit;
  7593. output_table[9].value = sd->status.int_;
  7594. output_table[10].value = sd->status.dex;
  7595. output_table[11].value = sd->status.luk;
  7596. output_table[12].value = sd->status.zeny;
  7597. output_table[13].value = sd->status.skill_point;
  7598. output_table[14].value = sd->change_level_2nd;
  7599. output_table[15].value = sd->change_level_3rd;
  7600. sprintf(job_jobname, "Job - %s %s", job_name(sd->status.class_), "(level %d)");
  7601. sprintf(output, msg_txt(sd,53), sd->status.name); // '%s' stats:
  7602. clif_displaymessage(fd, output);
  7603. for (i = 0; output_table[i].format != NULL; i++) {
  7604. sprintf(output, output_table[i].format, output_table[i].value);
  7605. clif_displaymessage(fd, output);
  7606. }
  7607. return 0;
  7608. }
  7609. ACMD_FUNC(delitem)
  7610. {
  7611. char item_name[100];
  7612. unsigned short nameid;
  7613. int amount = 0, total, idx;
  7614. struct item_data* id;
  7615. nullpo_retr(-1, sd);
  7616. if( !message || !*message || ( sscanf(message, "\"%99[^\"]\" %11d", item_name, &amount) < 2 && sscanf(message, "%99s %11d", item_name, &amount) < 2 ) || amount < 1 )
  7617. {
  7618. clif_displaymessage(fd, msg_txt(sd,1355)); // Please enter an item name/ID, a quantity, and a player name (usage: #delitem <player> <item_name_or_ID> <quantity>).
  7619. return -1;
  7620. }
  7621. if( ( id = itemdb_searchname(item_name) ) != NULL || ( id = itemdb_exists(atoi(item_name)) ) != NULL )
  7622. {
  7623. nameid = id->nameid;
  7624. }
  7625. else
  7626. {
  7627. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  7628. return -1;
  7629. }
  7630. total = amount;
  7631. // delete items
  7632. while( amount && ( idx = pc_search_inventory(sd, nameid) ) != -1 )
  7633. {
  7634. int delamount = ( amount < sd->inventory.u.items_inventory[idx].amount ) ? amount : sd->inventory.u.items_inventory[idx].amount;
  7635. if( sd->inventory_data[idx]->type == IT_PETEGG && sd->inventory.u.items_inventory[idx].card[0] == CARD0_PET )
  7636. {// delete pet
  7637. intif_delete_petdata(MakeDWord(sd->inventory.u.items_inventory[idx].card[1], sd->inventory.u.items_inventory[idx].card[2]));
  7638. }
  7639. pc_delitem(sd, idx, delamount, 0, 0, LOG_TYPE_COMMAND);
  7640. amount-= delamount;
  7641. }
  7642. // notify target
  7643. sprintf(atcmd_output, msg_txt(sd,113), total-amount); // %d item(s) removed by a GM.
  7644. clif_displaymessage(sd->fd, atcmd_output);
  7645. // notify source
  7646. if( amount == total )
  7647. {
  7648. clif_displaymessage(fd, msg_txt(sd,116)); // Character does not have the item.
  7649. }
  7650. else if( amount )
  7651. {
  7652. sprintf(atcmd_output, msg_txt(sd,115), total-amount, total-amount, total); // %d item(s) removed. Player had only %d on %d items.
  7653. clif_displaymessage(fd, atcmd_output);
  7654. }
  7655. else
  7656. {
  7657. sprintf(atcmd_output, msg_txt(sd,114), total); // %d item(s) removed from the player.
  7658. clif_displaymessage(fd, atcmd_output);
  7659. }
  7660. return 0;
  7661. }
  7662. /*==========================================
  7663. * Custom Fonts
  7664. *------------------------------------------*/
  7665. ACMD_FUNC(font)
  7666. {
  7667. int font_id;
  7668. nullpo_retr(-1,sd);
  7669. font_id = atoi(message);
  7670. if( font_id == 0 ) {
  7671. if( sd->status.font ) {
  7672. sd->status.font = 0;
  7673. clif_displaymessage(fd, msg_txt(sd,1356)); // Returning to normal font.
  7674. clif_font(sd);
  7675. } else {
  7676. clif_displaymessage(fd, msg_txt(sd,1357)); // Use @font <1-9> to change your message font.
  7677. clif_displaymessage(fd, msg_txt(sd,1358)); // Use 0 or no parameter to return to normal font.
  7678. }
  7679. } else if( font_id < 0 || font_id > 9 )
  7680. clif_displaymessage(fd, msg_txt(sd,1359)); // Invalid font. Use a value from 0 to 9.
  7681. else if( font_id != sd->status.font ) {
  7682. sd->status.font = font_id;
  7683. clif_font(sd);
  7684. clif_displaymessage(fd, msg_txt(sd,1360)); // Font changed.
  7685. } else
  7686. clif_displaymessage(fd, msg_txt(sd,1361)); // Already using this font.
  7687. return 0;
  7688. }
  7689. /*==========================================
  7690. * type: 1 = commands (@), 2 = charcommands (#)
  7691. *------------------------------------------*/
  7692. static void atcommand_commands_sub(struct map_session_data* sd, const int fd, AtCommandType type)
  7693. {
  7694. char line_buff[CHATBOX_SIZE];
  7695. char* cur = line_buff;
  7696. AtCommandInfo* cmd;
  7697. DBIterator *iter = db_iterator(atcommand_db);
  7698. int count = 0;
  7699. memset(line_buff,' ',CHATBOX_SIZE);
  7700. line_buff[CHATBOX_SIZE-1] = 0;
  7701. clif_displaymessage(fd, msg_txt(sd,273)); // "Commands available:"
  7702. for (cmd = (AtCommandInfo*)dbi_first(iter); dbi_exists(iter); cmd = (AtCommandInfo*)dbi_next(iter)) {
  7703. unsigned int slen = 0;
  7704. switch( type ) {
  7705. case COMMAND_CHARCOMMAND:
  7706. if( cmd->char_groups[sd->group_pos] == 0 )
  7707. continue;
  7708. break;
  7709. case COMMAND_ATCOMMAND:
  7710. if( cmd->at_groups[sd->group_pos] == 0 )
  7711. continue;
  7712. break;
  7713. default:
  7714. continue;
  7715. }
  7716. slen = strlen(cmd->command);
  7717. // flush the text buffer if this command won't fit into it
  7718. if (slen + cur - line_buff >= CHATBOX_SIZE) {
  7719. clif_displaymessage(fd,line_buff);
  7720. cur = line_buff;
  7721. memset(line_buff,' ',CHATBOX_SIZE);
  7722. line_buff[CHATBOX_SIZE-1] = 0;
  7723. }
  7724. memcpy(cur,cmd->command,slen);
  7725. cur += slen+(10-slen%10);
  7726. count++;
  7727. }
  7728. dbi_destroy(iter);
  7729. clif_displaymessage(fd,line_buff);
  7730. if ( atcmd_binding_count ) {
  7731. int i, count_bind, gm_lvl = pc_get_group_level(sd);
  7732. for( i = count_bind = 0; i < atcmd_binding_count; i++ ) {
  7733. if ( gm_lvl >= ( (type - 1) ? atcmd_binding[i]->level2 : atcmd_binding[i]->level ) ) {
  7734. unsigned int slen = strlen(atcmd_binding[i]->command);
  7735. if ( count_bind == 0 ) {
  7736. cur = line_buff;
  7737. memset(line_buff,' ',CHATBOX_SIZE);
  7738. line_buff[CHATBOX_SIZE-1] = 0;
  7739. clif_displaymessage(fd, "-----------------");
  7740. clif_displaymessage(fd, msg_txt(sd,509)); // Script-bound commands:
  7741. }
  7742. if (slen + cur - line_buff >= CHATBOX_SIZE) {
  7743. clif_displaymessage(fd,line_buff);
  7744. cur = line_buff;
  7745. memset(line_buff,' ',CHATBOX_SIZE);
  7746. line_buff[CHATBOX_SIZE-1] = 0;
  7747. }
  7748. memcpy(cur,atcmd_binding[i]->command,slen);
  7749. cur += slen+(10-slen%10);
  7750. count_bind++;
  7751. }
  7752. }
  7753. if ( count_bind )
  7754. clif_displaymessage(fd,line_buff);// last one
  7755. count += count_bind;
  7756. }
  7757. sprintf(atcmd_output, msg_txt(sd,274), count); // "%d commands found."
  7758. clif_displaymessage(fd, atcmd_output);
  7759. return;
  7760. }
  7761. /*==========================================
  7762. * @commands Lists available @ commands to you
  7763. *------------------------------------------*/
  7764. ACMD_FUNC(commands)
  7765. {
  7766. atcommand_commands_sub(sd, fd, COMMAND_ATCOMMAND);
  7767. return 0;
  7768. }
  7769. /*==========================================
  7770. * @charcommands Lists available # commands to you
  7771. *------------------------------------------*/
  7772. ACMD_FUNC(charcommands) {
  7773. atcommand_commands_sub(sd, fd, COMMAND_CHARCOMMAND);
  7774. return 0;
  7775. }
  7776. /* for new mounts */
  7777. ACMD_FUNC(mount2) {
  7778. clif_displaymessage(sd->fd,msg_txt(sd,1362)); // NOTICE: If you crash with mount your LUA is outdated.
  7779. if (!&sd->sc || !(sd->sc.data[SC_ALL_RIDING])) {
  7780. clif_displaymessage(sd->fd,msg_txt(sd,1363)); // You have mounted.
  7781. sc_start(NULL, &sd->bl, SC_ALL_RIDING, 10000, 1, INVALID_TIMER);
  7782. } else {
  7783. clif_displaymessage(sd->fd,msg_txt(sd,1364)); // You have released your mount.
  7784. if (&sd->sc)
  7785. status_change_end(&sd->bl, SC_ALL_RIDING, INVALID_TIMER);
  7786. }
  7787. return 0;
  7788. }
  7789. ACMD_FUNC(accinfo) {
  7790. char query[NAME_LENGTH];
  7791. char type = 0; // type = 1, get only account name
  7792. if (!message || !*message || strlen(message) > NAME_LENGTH
  7793. || ( sscanf(message, "%23s %c", query, &type) < 1))
  7794. {
  7795. clif_displaymessage(fd, msg_txt(sd,1365)); // Usage: @accinfo/@accountinfo <account_id/char name>
  7796. clif_displaymessage(fd, msg_txt(sd,1366)); // You may search partial name by making use of '%' in the search, ex. "@accinfo %Mario%" lists all characters whose name contains "Mario".
  7797. return -1;
  7798. } else if (type != 0) {
  7799. type = type-'0'; //make it int
  7800. if (type != 1) {
  7801. clif_displaymessage(fd, "accinfo : Unknow type specified\n");
  7802. return -1;
  7803. }
  7804. }
  7805. intif_request_accinfo( sd->fd, sd->bl.id, pc_get_group_level(sd), query, type);
  7806. return 0;
  7807. }
  7808. /**
  7809. * @set <variable name{[index]}>{ <value>}
  7810. *
  7811. * Gets or sets a value of a non server variable.
  7812. * If a value is specified it is used to set the variable's value,
  7813. * if not the variable's value is read.
  7814. * In any case it reads and displays the variable's value.
  7815. *
  7816. * Original implementation by Ind
  7817. */
  7818. ACMD_FUNC(set) {
  7819. char reg[46], val[128], name[32];
  7820. int toset = 0, len, index;
  7821. bool is_str = false;
  7822. int64 uid;
  7823. if( !message || !*message || (toset = sscanf(message, "%45s %127[^\n]s", reg, val)) < 1 ) {
  7824. clif_displaymessage(fd, msg_txt(sd,1367)); // Usage: @set <variable name> <value>
  7825. clif_displaymessage(fd, msg_txt(sd,1368)); // Usage: ex. "@set PoringCharVar 50"
  7826. clif_displaymessage(fd, msg_txt(sd,1369)); // Usage: ex. "@set PoringCharVarSTR$ Super Duper String"
  7827. clif_displaymessage(fd, msg_txt(sd,1370)); // Usage: ex. "@set PoringCharVarSTR$" outputs its value, Super Duper String.
  7828. return -1;
  7829. }
  7830. /* disabled variable types (they require a proper script state to function, so allowing them would crash the server) */
  7831. if( reg[0] == '.' ) {
  7832. clif_displaymessage(fd, msg_txt(sd,1371)); // NPC variables may not be used with @set.
  7833. return -1;
  7834. } else if( reg[0] == '\'' ) {
  7835. clif_displaymessage(fd, msg_txt(sd,1372)); // Instance variables may not be used with @set.
  7836. return -1;
  7837. }
  7838. // Check if the user wanted to set an array
  7839. if( sscanf( reg, "%31[^[][%11d]", name, &index ) < 2 ){
  7840. // The user did not specify array brackets, so we set the index to zero
  7841. index = 0;
  7842. }
  7843. is_str = is_string_variable(name);
  7844. if( ( len = strlen(val) ) > 1 ) {
  7845. if( val[0] == '"' && val[len-1] == '"') {
  7846. val[len-1] = '\0'; //Strip quotes.
  7847. memmove(val, val+1, len-1);
  7848. }
  7849. }
  7850. // Only set the variable if there is a value for it
  7851. if( toset >= 2 ){
  7852. setd_sub( NULL, sd, name, index, is_str ? (void*)val : (void*)__64BPRTSIZE((atoi(val))), NULL );
  7853. }
  7854. uid = reference_uid( add_str( name ), index );
  7855. if( is_str ) {// string variable
  7856. char* value;
  7857. switch( reg[0] ) {
  7858. case '@':
  7859. value = pc_readregstr(sd, uid);
  7860. break;
  7861. case '$':
  7862. value = mapreg_readregstr(uid);
  7863. break;
  7864. case '#':
  7865. if( reg[1] == '#' )
  7866. value = pc_readaccountreg2str(sd, uid);// global
  7867. else
  7868. value = pc_readaccountregstr(sd, uid);// local
  7869. break;
  7870. default:
  7871. value = pc_readglobalreg_str(sd, uid);
  7872. break;
  7873. }
  7874. if( value == NULL || value == '\0' ){// empty string
  7875. sprintf(atcmd_output,msg_txt(sd,1375),reg); // %s is empty
  7876. }else{
  7877. sprintf(atcmd_output,msg_txt(sd,1374),reg,value); // %s value is now :%s
  7878. }
  7879. } else {// integer variable
  7880. int value;
  7881. switch( reg[0] ) {
  7882. case '@':
  7883. value = pc_readreg(sd, uid);
  7884. break;
  7885. case '$':
  7886. value = mapreg_readreg(uid);
  7887. break;
  7888. case '#':
  7889. if( reg[1] == '#' )
  7890. value = pc_readaccountreg2(sd, uid);// global
  7891. else
  7892. value = pc_readaccountreg(sd, uid);// local
  7893. break;
  7894. default:
  7895. value = pc_readglobalreg(sd, uid);
  7896. break;
  7897. }
  7898. sprintf(atcmd_output,msg_txt(sd,1373),reg,value); // %s value is now :%d
  7899. }
  7900. clif_displaymessage(fd, atcmd_output);
  7901. return 0;
  7902. }
  7903. ACMD_FUNC(addperm) {
  7904. int perm_size = ARRAYLENGTH(pc_g_permission_name);
  7905. bool add;
  7906. int i;
  7907. parent_cmd = atcommand_checkalias(command+1);
  7908. add = (strcmpi(parent_cmd, "addperm") == 0);
  7909. if( !message || !*message ) {
  7910. sprintf(atcmd_output, msg_txt(sd,1378),command); // Usage: %s <permission_name>
  7911. clif_displaymessage(fd, atcmd_output);
  7912. clif_displaymessage(fd, msg_txt(sd,1379)); // -- Permission List
  7913. for( i = 0; i < perm_size; i++ ) {
  7914. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  7915. clif_displaymessage(fd, atcmd_output);
  7916. }
  7917. return -1;
  7918. }
  7919. ARR_FIND(0, perm_size, i, strcmpi(pc_g_permission_name[i].name, message) == 0);
  7920. if( i == perm_size ) {
  7921. sprintf(atcmd_output,msg_txt(sd,1380),message); // '%s' is not a known permission.
  7922. clif_displaymessage(fd, atcmd_output);
  7923. clif_displaymessage(fd, msg_txt(sd,1379)); // -- Permission List
  7924. for( i = 0; i < perm_size; i++ ) {
  7925. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  7926. clif_displaymessage(fd, atcmd_output);
  7927. }
  7928. return -1;
  7929. }
  7930. if( add && (sd->permissions&pc_g_permission_name[i].permission) ) {
  7931. sprintf(atcmd_output, msg_txt(sd,1381),sd->status.name,pc_g_permission_name[i].name); // User '%s' already possesses the '%s' permission.
  7932. clif_displaymessage(fd, atcmd_output);
  7933. return -1;
  7934. } else if ( !add && !(sd->permissions&pc_g_permission_name[i].permission) ) {
  7935. sprintf(atcmd_output, msg_txt(sd,1382),sd->status.name,pc_g_permission_name[i].name); // User '%s' doesn't possess the '%s' permission.
  7936. clif_displaymessage(fd, atcmd_output);
  7937. sprintf(atcmd_output,msg_txt(sd,1383),sd->status.name); // -- User '%s' Permissions
  7938. clif_displaymessage(fd, atcmd_output);
  7939. for( i = 0; i < perm_size; i++ ) {
  7940. if( sd->permissions&pc_g_permission_name[i].permission ) {
  7941. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  7942. clif_displaymessage(fd, atcmd_output);
  7943. }
  7944. }
  7945. return -1;
  7946. }
  7947. if( add )
  7948. sd->permissions |= pc_g_permission_name[i].permission;
  7949. else
  7950. sd->permissions &=~ pc_g_permission_name[i].permission;
  7951. sprintf(atcmd_output, msg_txt(sd,1384),sd->status.name); // User '%s' permissions updated successfully. The changes are temporary.
  7952. clif_displaymessage(fd, atcmd_output);
  7953. return 0;
  7954. }
  7955. ACMD_FUNC(unloadnpcfile) {
  7956. if( !message || !*message ) {
  7957. clif_displaymessage(fd, msg_txt(sd,1385)); // Usage: @unloadnpcfile <file name>
  7958. return -1;
  7959. }
  7960. if( npc_unloadfile(message) )
  7961. clif_displaymessage(fd, msg_txt(sd,1386)); // File unloaded. Be aware that mapflags and monsters spawned directly are not removed.
  7962. else {
  7963. clif_displaymessage(fd, msg_txt(sd,1387)); // File not found.
  7964. return -1;
  7965. }
  7966. return 0;
  7967. }
  7968. ACMD_FUNC(cart) {
  7969. #define MC_CART_MDFY(idx, x) \
  7970. sd->status.skill[(idx)].id = (x)?MC_PUSHCART:0; \
  7971. sd->status.skill[(idx)].lv = (x)?1:0; \
  7972. sd->status.skill[(idx)].flag = (x)?SKILL_FLAG_TEMPORARY:SKILL_FLAG_PERMANENT;
  7973. int val = atoi(message);
  7974. bool need_skill = (pc_checkskill(sd, MC_PUSHCART) == 0);
  7975. uint16 sk_idx = 0;
  7976. if( !message || !*message || val < 0 || val > MAX_CARTS ) {
  7977. sprintf(atcmd_output, msg_txt(sd,1390),command,MAX_CARTS); // Unknown Cart (usage: %s <0-%d>).
  7978. clif_displaymessage(fd, atcmd_output);
  7979. return -1;
  7980. }
  7981. if( val == 0 && !pc_iscarton(sd) ) {
  7982. clif_displaymessage(fd, msg_txt(sd,1391)); // You do not possess a cart to be removed
  7983. return -1;
  7984. }
  7985. if (!(sk_idx = skill_get_index(MC_PUSHCART)))
  7986. return -1;
  7987. if( need_skill ) {
  7988. MC_CART_MDFY(sk_idx,1);
  7989. }
  7990. if( !pc_setcart(sd, val) ) {
  7991. if( need_skill ) {
  7992. MC_CART_MDFY(sk_idx,0);
  7993. }
  7994. return -1;/* @cart failed */
  7995. }
  7996. if( need_skill ) {
  7997. MC_CART_MDFY(sk_idx,0);
  7998. }
  7999. clif_displaymessage(fd, msg_txt(sd,1392)); // Cart Added
  8000. return 0;
  8001. #undef MC_CART_MDFY
  8002. }
  8003. /* Channel System [Ind] */
  8004. ACMD_FUNC(join){
  8005. char chname[CHAN_NAME_LENGTH], pass[CHAN_NAME_LENGTH];
  8006. if( !message || !*message || sscanf(message, "%19s %19s", chname, pass) < 1 ) {
  8007. sprintf(atcmd_output, msg_txt(sd,1399),command); // Unknown channel (usage: %s <#channel_name>).
  8008. clif_displaymessage(fd, atcmd_output);
  8009. return -1;
  8010. }
  8011. return channel_pcjoin(sd, chname, pass);
  8012. }
  8013. /*
  8014. * Display available option for @channel command
  8015. * @command : the name of used command (for alias case)
  8016. */
  8017. static inline void atcmd_channel_help(struct map_session_data *sd, const char *command)
  8018. {
  8019. int fd = sd->fd;
  8020. bool can_delete = pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN);
  8021. bool can_create = (can_delete || channel_config.user_chenable);
  8022. clif_displaymessage(fd, msg_txt(sd,1414));// ---- Available options:
  8023. //option create
  8024. if( can_create ) {
  8025. sprintf(atcmd_output, msg_txt(sd,1415),command);// * %s create <#channel_name> <channel_password>
  8026. clif_displaymessage(fd, atcmd_output);
  8027. clif_displaymessage(fd, msg_txt(sd,1416));// -- Creates a new channel.
  8028. }
  8029. //option delete
  8030. if(can_delete){
  8031. sprintf(atcmd_output, msg_txt(sd,1469),command);// * %s delete <#channel_name>
  8032. clif_displaymessage(fd, atcmd_output);
  8033. clif_displaymessage(fd, msg_txt(sd,1470)); // -- Destroys the specified channel.
  8034. }
  8035. //option list
  8036. sprintf(atcmd_output, msg_txt(sd,1417),command);// * %s list
  8037. clif_displaymessage(fd, atcmd_output);
  8038. clif_displaymessage(fd, msg_txt(sd,1418));// -- Lists all public channels.
  8039. sprintf(atcmd_output, msg_txt(sd,1471),command);// * %s list mine
  8040. clif_displaymessage(fd, atcmd_output);
  8041. clif_displaymessage(fd, msg_txt(sd,1472));// -- Lists all channels you have joined.
  8042. if( can_create ) {
  8043. sprintf(atcmd_output, msg_txt(sd,1419),command);// * %s list colors
  8044. clif_displaymessage(fd, atcmd_output);
  8045. clif_displaymessage(fd, msg_txt(sd,1420));// -- Lists all available colors for custom channels.
  8046. }
  8047. //option setcolor
  8048. if(can_create){
  8049. sprintf(atcmd_output, msg_txt(sd,1421),command);// * %s setcolor <#channel_name> <color_name>
  8050. clif_displaymessage(fd, atcmd_output);
  8051. clif_displaymessage(fd, msg_txt(sd,1422));// -- Changes channel text to the specified color (channel owners only).
  8052. }
  8053. //option join
  8054. sprintf(atcmd_output, msg_txt(sd,1473),command);// * %s join <#channel_name> <channel_password>
  8055. clif_displaymessage(fd, atcmd_output);
  8056. clif_displaymessage(fd, msg_txt(sd,1474));// -- Joins the specified channel.
  8057. //option leave
  8058. sprintf(atcmd_output, msg_txt(sd,1423),command);// * %s leave <#channel_name>
  8059. clif_displaymessage(fd, atcmd_output);
  8060. clif_displaymessage(fd, msg_txt(sd,1424));// -- Leaves the specified channel.
  8061. //option bindto
  8062. sprintf(atcmd_output, msg_txt(sd,1427),command);// * %s bindto <#channel_name>
  8063. clif_displaymessage(fd, atcmd_output);
  8064. clif_displaymessage(fd, msg_txt(sd,1428));// -- Binds your global chat to the specified channel, sending all global messages to that channel.
  8065. //option unbind
  8066. sprintf(atcmd_output, msg_txt(sd,1429),command);// * %s unbind
  8067. clif_displaymessage(fd, atcmd_output);
  8068. clif_displaymessage(fd, msg_txt(sd,1430));// -- Unbinds your global chat from the attached channel, if any.
  8069. //option ban/unban/banlist
  8070. if( can_create ) {
  8071. sprintf(atcmd_output, msg_txt(sd,1456),command);// * %s ban <#channel_name> <player>
  8072. clif_displaymessage(fd, atcmd_output);
  8073. clif_displaymessage(fd, msg_txt(sd,1457));// -- Bans the specified player from the channel.
  8074. sprintf(atcmd_output, msg_txt(sd,1458),command);// * %s banlist <#channel_name>
  8075. clif_displaymessage(fd, atcmd_output);
  8076. clif_displaymessage(fd, msg_txt(sd,1459));// -- Lists all players banned from the specified channel.
  8077. sprintf(atcmd_output, msg_txt(sd,1460),command);// * %s unban <#channel_name> <player>
  8078. clif_displaymessage(fd, atcmd_output);
  8079. clif_displaymessage(fd, msg_txt(sd,1461));// -- Unbans the specified player from the channel.
  8080. sprintf(atcmd_output, msg_txt(sd,1467),command);// * %s unbanall <#channel_name>
  8081. clif_displaymessage(fd, atcmd_output);
  8082. clif_displaymessage(fd, msg_txt(sd,1468));// -- Clears all bans from the specified channel.
  8083. }
  8084. //option setopt
  8085. if(can_create){
  8086. sprintf(atcmd_output, msg_txt(sd,1462),command);// * %s setopt <#channel_name> <option> <value>
  8087. clif_displaymessage(fd, atcmd_output);
  8088. clif_displaymessage(fd, msg_txt(sd,1463));// -- Sets an option and value for the specified channel.
  8089. }
  8090. sprintf(atcmd_output, msg_txt(sd,1404),command); // %s failed.
  8091. clif_displaymessage(fd, atcmd_output);
  8092. }
  8093. ACMD_FUNC(channel) {
  8094. char key[NAME_LENGTH], sub1[CHAN_NAME_LENGTH], sub2[64];
  8095. sub1[0] = sub2[0] = '\0';
  8096. if( !message || !*message || sscanf(message, "%23s %19s %63[^\n]", key, sub1, sub2) < 1 ) {
  8097. atcmd_channel_help(sd,command);
  8098. return 0;
  8099. }
  8100. if( strcmpi(key,"delete") == 0 && pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) ) {
  8101. return channel_pcdelete(sd,sub1);
  8102. } else if ( strcmpi(key,"list") == 0 ) {
  8103. return channel_display_list(sd,sub1);
  8104. } else if ( strcmpi(key,"setcolor") == 0 ) {
  8105. return channel_pccolor(sd, sub1, sub2);
  8106. } else if ( strcmpi(key,"join") == 0 ) {
  8107. return channel_pcjoin(sd, sub1, sub2);
  8108. }else if ( strcmpi(key,"leave") == 0 ) {
  8109. return channel_pcleave(sd, sub1);
  8110. } else if ( strcmpi(key,"bindto") == 0 ) {
  8111. return channel_pcbind(sd, sub1);
  8112. } else if ( strcmpi(key,"unbind") == 0 ) {
  8113. return channel_pcunbind(sd);
  8114. } else if ( strcmpi(key,"ban") == 0 ) {
  8115. return channel_pcban(sd,sub1,sub2,0);
  8116. } else if ( strcmpi(key,"banlist") == 0 ) {
  8117. return channel_pcban(sd,sub1,NULL,3);
  8118. } else if ( strcmpi(key,"unban") == 0 ) {
  8119. return channel_pcban(sd,sub1,sub2,1);
  8120. } else if ( strcmpi(key,"unbanall") == 0 ) {
  8121. return channel_pcban(sd,sub1,NULL,2);
  8122. } else {
  8123. char sub3[CHAN_NAME_LENGTH], sub4[CHAN_NAME_LENGTH];
  8124. sub3[0] = sub4[0] = '\0';
  8125. sscanf(sub2, "%19s %19s", sub3, sub4);
  8126. if( strcmpi(key,"create") == 0 && ( channel_config.user_chenable || pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) ) ) {
  8127. if (sub4[0] != '\0') {
  8128. clif_displaymessage(fd, msg_txt(sd, 1408)); // Channel password may not contain spaces.
  8129. return -1;
  8130. }
  8131. return channel_pccreate(sd,sub1,sub3);
  8132. } else if ( strcmpi(key,"setopt") == 0 ) {
  8133. return channel_pcsetopt(sd,sub1,sub3,sub4);
  8134. }
  8135. atcmd_channel_help(sd,command);
  8136. }
  8137. return 0;
  8138. }
  8139. ACMD_FUNC(fontcolor)
  8140. {
  8141. if( !message || !*message ) {
  8142. channel_display_list(sd,"colors");
  8143. return -1;
  8144. }
  8145. if( strcmpi(message,"Normal") == 0 ) {
  8146. sd->fontcolor = 0;
  8147. } else {
  8148. unsigned char k;
  8149. ARR_FIND(0,channel_config.colors_count,k,( strcmpi(message,channel_config.colors_name[k]) == 0 ));
  8150. if( k == channel_config.colors_count ) {
  8151. sprintf(atcmd_output, msg_txt(sd,1411), message);// Unknown color '%s'.
  8152. clif_displaymessage(fd, atcmd_output);
  8153. return -1;
  8154. }
  8155. sd->fontcolor = k;
  8156. }
  8157. sprintf(atcmd_output, msg_txt(sd,1454), message);// Color set to '%s'.
  8158. clif_displaymessage(fd, atcmd_output);
  8159. return 0;
  8160. }
  8161. ACMD_FUNC(langtype)
  8162. {
  8163. char langstr[8];
  8164. int i=0, fail=0;
  8165. memset(langstr, '\0', sizeof(langstr));
  8166. if(sscanf(message, "%3s", langstr) >= 1){
  8167. int lang=0;
  8168. lang = msg_langstr2langtype(langstr); //Switch langstr to associated langtype
  8169. if( msg_checklangtype(lang,false) == 1 ){ //Verify it's enabled and set it
  8170. char output[100];
  8171. pc_setaccountreg(sd, add_str("#langtype"), lang); //For login/char
  8172. sd->langtype = lang;
  8173. sprintf(output,msg_txt(sd,461),msg_langtype2langstr(lang)); // Language is now set to %s.
  8174. clif_displaymessage(fd,output);
  8175. return 0;
  8176. } else if (lang != -1) { //defined langage but failed check
  8177. clif_displaymessage(fd,msg_txt(sd,462)); // This langage is currently disabled.
  8178. return -1;
  8179. }
  8180. }
  8181. //wrong or no entry
  8182. clif_displaymessage(fd,msg_txt(sd,460)); // Please enter a valid language (usage: @langtype <language>).
  8183. clif_displaymessage(fd,msg_txt(sd,464)); // ---- Available languages:
  8184. while(fail != -1){ //out of range
  8185. fail = msg_checklangtype(i,false);
  8186. if(fail == 1)
  8187. clif_displaymessage(fd,msg_langtype2langstr(i));
  8188. i++;
  8189. }
  8190. return -1;
  8191. }
  8192. #ifdef VIP_ENABLE
  8193. ACMD_FUNC(vip) {
  8194. struct map_session_data *pl_sd = NULL;
  8195. char * modif_p;
  8196. int32 vipdifftime = 0;
  8197. time_t now=time(NULL);
  8198. nullpo_retr(-1, sd);
  8199. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8200. if (!message || !*message || sscanf(message, "%255s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
  8201. clif_displaymessage(fd, msg_txt(sd,700)); //Usage: @vip <timef> <character name>
  8202. return -1;
  8203. }
  8204. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  8205. modif_p = atcmd_output;
  8206. vipdifftime = (int32)solve_time(modif_p);
  8207. if (vipdifftime == 0) {
  8208. clif_displaymessage(fd, msg_txt(sd,701)); // Invalid time for vip command.
  8209. clif_displaymessage(fd, msg_txt(sd,702)); // Time parameter format is +/-<value> to alter. y/a = Year, m = Month, d/j = Day, h = Hour, n/mn = Minute, s = Second.
  8210. return -1;
  8211. }
  8212. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL) {
  8213. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  8214. return -1;
  8215. }
  8216. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  8217. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  8218. return -1;
  8219. }
  8220. if(pl_sd->vip.time==0) pl_sd->vip.time=now;
  8221. pl_sd->vip.time += vipdifftime; //increase or reduce VIP duration
  8222. if (pl_sd->vip.time <= now) {
  8223. clif_displaymessage(pl_sd->fd, msg_txt(pl_sd,703)); // GM has removed your VIP time.
  8224. clif_displaymessage(fd, msg_txt(sd,704)); // Player is no longer VIP.
  8225. } else {
  8226. int year,month,day,hour,minute,second;
  8227. char timestr[21];
  8228. split_time((int)(pl_sd->vip.time-now),&year,&month,&day,&hour,&minute,&second);
  8229. sprintf(atcmd_output,msg_txt(pl_sd,705),year,month,day,hour,minute); // Your VIP status is valid for %d years, %d months, %d days, %d hours and %d minutes.
  8230. clif_displaymessage(pl_sd->fd,atcmd_output);
  8231. timestamp2string(timestr,20,pl_sd->vip.time,"%Y-%m-%d %H:%M");
  8232. sprintf(atcmd_output,msg_txt(pl_sd,707),timestr); // You are VIP until : %s
  8233. clif_displaymessage(pl_sd->fd,atcmd_output);
  8234. if (pl_sd != sd) {
  8235. sprintf(atcmd_output,msg_txt(sd,706),pl_sd->status.name,year,month,day,hour,minute); // Player '%s' is now VIP for %d years, %d months, %d days, %d hours and %d minutes.
  8236. clif_displaymessage(fd,atcmd_output);
  8237. sprintf(atcmd_output,msg_txt(sd,708),timestr); // The player is now VIP until : %s
  8238. clif_displaymessage(fd,atcmd_output);
  8239. }
  8240. }
  8241. chrif_req_login_operation(pl_sd->status.account_id, pl_sd->status.name, CHRIF_OP_LOGIN_VIP, vipdifftime, 7, 0);
  8242. return 0;
  8243. }
  8244. /** Enable/disable rate info */
  8245. ACMD_FUNC(showrate) {
  8246. nullpo_retr(-1,sd);
  8247. if (!sd->vip.disableshowrate) {
  8248. safestrncpy(atcmd_output,msg_txt(sd,718),CHAT_SIZE_MAX); //Personal rate information is not displayed now.
  8249. sd->vip.disableshowrate = 1;
  8250. } else {
  8251. safestrncpy(atcmd_output,msg_txt(sd,719),CHAT_SIZE_MAX); //Personal rate information will be shown.
  8252. sd->vip.disableshowrate = 0;
  8253. }
  8254. clif_displaymessage(fd,atcmd_output);
  8255. return 0;
  8256. }
  8257. #endif
  8258. ACMD_FUNC(fullstrip) {
  8259. int i;
  8260. TBL_PC *tsd;
  8261. nullpo_retr(-1,sd);
  8262. if (!message || !*message) {
  8263. clif_displaymessage(fd, msg_txt(sd,349)); // Please enter a player name (usage: @fullstrip/@warpto/@goto <char name/ID>).
  8264. return -1;
  8265. }
  8266. if((tsd=map_nick2sd((char *)message,false)) == NULL && (tsd=map_id2sd(atoi(message))) == NULL){
  8267. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  8268. return -1;
  8269. }
  8270. for( i = 0; i < EQI_MAX; i++ ) {
  8271. if( tsd->equip_index[ i ] >= 0 )
  8272. pc_unequipitem( tsd , tsd->equip_index[ i ] , 2 );
  8273. }
  8274. return 0;
  8275. }
  8276. ACMD_FUNC(costume) {
  8277. const char* names[] = {
  8278. "Wedding",
  8279. "Xmas",
  8280. "Summer",
  8281. "Hanbok",
  8282. "Oktoberfest",
  8283. };
  8284. const int name2id[] = {
  8285. SC_WEDDING,
  8286. SC_XMAS,
  8287. SC_SUMMER,
  8288. SC_HANBOK,
  8289. SC_OKTOBERFEST
  8290. };
  8291. unsigned short k = 0, len = ARRAYLENGTH(names);
  8292. if( !message || !*message ) {
  8293. for( k = 0; k < len; k++ ) {
  8294. if( sd->sc.data[name2id[k]] ) {
  8295. sprintf(atcmd_output, msg_txt(sd, 727), names[k]); // '%s' Costume removed.
  8296. clif_displaymessage(sd->fd, atcmd_output);
  8297. status_change_end(&sd->bl, (sc_type)name2id[k], INVALID_TIMER);
  8298. return 0;
  8299. }
  8300. }
  8301. clif_displaymessage(sd->fd, msg_txt(sd, 726)); // Available Costumes
  8302. for( k = 0; k < len; k++ ) {
  8303. sprintf(atcmd_output, msg_txt(sd, 725), names[k]); // -- %s
  8304. clif_displaymessage(sd->fd, atcmd_output);
  8305. }
  8306. return -1;
  8307. }
  8308. for( k = 0; k < len; k++ ) {
  8309. if( sd->sc.data[name2id[k]] ) {
  8310. sprintf(atcmd_output, msg_txt(sd, 724), names[k]); // You're already wearing a(n) '%s' costume, type '@costume' to remove it.
  8311. clif_displaymessage(sd->fd, atcmd_output);
  8312. return -1;
  8313. }
  8314. }
  8315. for( k = 0; k < len; k++ )
  8316. if( strcmpi(message, names[k]) == 0 )
  8317. break;
  8318. if( k == len ) {
  8319. sprintf(atcmd_output, msg_txt(sd, 723), message); // '%s' is an unknown costume
  8320. clif_displaymessage(sd->fd, atcmd_output);
  8321. return -1;
  8322. }
  8323. sc_start(&sd->bl, &sd->bl, (sc_type)name2id[k], 100, 0, -1);
  8324. return 0;
  8325. }
  8326. /**
  8327. * Clone other player's equipments
  8328. * Usage: @cloneequip <char_id or "char name">
  8329. * http://rathena.org/board/topic/95076-new-atcommands-suggestion/
  8330. * @author [Cydh], [Antares]
  8331. */
  8332. ACMD_FUNC(cloneequip) {
  8333. struct map_session_data *pl_sd;
  8334. uint32 char_id = 0;
  8335. nullpo_retr(-1, sd);
  8336. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8337. if( !message || !*message || (sscanf(message, "%11d", &char_id) < 1 && sscanf(message, "\"%23[^\"]\"", atcmd_output) < 1) ) {
  8338. clif_displaymessage(fd, msg_txt(sd, 735)); // Please enter char_id or \"char name\".
  8339. return -1;
  8340. }
  8341. if (char_id)
  8342. pl_sd = map_charid2sd(char_id);
  8343. else
  8344. pl_sd = map_nick2sd(atcmd_output,true);
  8345. if (!pl_sd) {
  8346. clif_displaymessage(fd, msg_txt(sd, 3));
  8347. return -1;
  8348. }
  8349. if (sd == pl_sd) {
  8350. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8351. sprintf(atcmd_output, msg_txt(sd, 734), "equip"); // Cannot clone your own %.
  8352. clif_displaymessage(fd, atcmd_output);
  8353. return -1;
  8354. }
  8355. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) {
  8356. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8357. sprintf(atcmd_output, msg_txt(sd, 736), "equip"); // Cannot clone %s from this player.
  8358. clif_displaymessage(fd, atcmd_output);
  8359. return -1;
  8360. }
  8361. else {
  8362. int8 i;
  8363. for (i = 0; i < EQI_MAX; i++) {
  8364. short idx;
  8365. char flag = 0;
  8366. struct item tmp_item;
  8367. if ((idx = pl_sd->equip_index[i]) < 0)
  8368. continue;
  8369. if (i == EQI_AMMO)
  8370. continue;
  8371. if (pc_is_same_equip_index((enum equip_index) i, pl_sd->equip_index, idx))
  8372. continue;
  8373. tmp_item = pl_sd->inventory.u.items_inventory[idx];
  8374. if (itemdb_isspecial(tmp_item.card[0]))
  8375. memset(tmp_item.card, 0, sizeof(tmp_item.card));
  8376. tmp_item.bound = 0;
  8377. tmp_item.expire_time = 0;
  8378. tmp_item.unique_id = 0;
  8379. tmp_item.favorite = 0;
  8380. tmp_item.amount = 1;
  8381. if ((flag = pc_additem(sd, &tmp_item, 1, LOG_TYPE_COMMAND)))
  8382. clif_additem(sd, 0, 0, flag);
  8383. else
  8384. pc_equipitem(sd, sd->last_addeditem_index, itemdb_equip(tmp_item.nameid));
  8385. }
  8386. }
  8387. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8388. sprintf(atcmd_output, msg_txt(sd, 738), "equip");
  8389. clif_displaymessage(fd, atcmd_output);
  8390. return 0;
  8391. }
  8392. /**
  8393. * Clone other player's statuses/parameters using method same like ACMD_FUNC(param), doesn't use stat point
  8394. * Usage: @clonestat <char_id or "char name">
  8395. * http://rathena.org/board/topic/95076-new-atcommands-suggestion/
  8396. * @author [Cydh], [Antares]
  8397. */
  8398. ACMD_FUNC(clonestat) {
  8399. struct map_session_data *pl_sd;
  8400. uint32 char_id = 0;
  8401. nullpo_retr(-1, sd);
  8402. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8403. if( !message || !*message || (sscanf(message, "%11d", &char_id) < 1 && sscanf(message, "\"%23[^\"]\"", atcmd_output) < 1) ) {
  8404. clif_displaymessage(fd, msg_txt(sd, 735)); // Please enter char_id or \"char name\".
  8405. return -1;
  8406. }
  8407. if (char_id)
  8408. pl_sd = map_charid2sd(char_id);
  8409. else
  8410. pl_sd = map_nick2sd(atcmd_output,true);
  8411. if (!pl_sd) {
  8412. clif_displaymessage(fd, msg_txt(sd, 3));
  8413. return -1;
  8414. }
  8415. if (sd == pl_sd) {
  8416. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8417. sprintf(atcmd_output, msg_txt(sd, 734), "status"); // Cannot clone your own %.
  8418. clif_displaymessage(fd, atcmd_output);
  8419. return -1;
  8420. }
  8421. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) {
  8422. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8423. sprintf(atcmd_output, msg_txt(sd, 736), "status"); // Cannot clone %s from this player.
  8424. clif_displaymessage(fd, atcmd_output);
  8425. return -1;
  8426. }
  8427. else {
  8428. uint8 i;
  8429. short max_status[6];
  8430. pc_resetstate(sd);
  8431. if (pc_has_permission(sd, PC_PERM_BYPASS_STAT_ONCLONE))
  8432. max_status[0] = max_status[1] = max_status[2] = max_status[3] = max_status[4] = max_status[5] = SHRT_MAX;
  8433. else {
  8434. max_status[0] = pc_maxparameter(sd, PARAM_STR);
  8435. max_status[1] = pc_maxparameter(sd, PARAM_AGI);
  8436. max_status[2] = pc_maxparameter(sd, PARAM_VIT);
  8437. max_status[3] = pc_maxparameter(sd, PARAM_INT);
  8438. max_status[4] = pc_maxparameter(sd, PARAM_DEX);
  8439. max_status[5] = pc_maxparameter(sd, PARAM_LUK);
  8440. }
  8441. #define clonestat_check(cmd,stat)\
  8442. {\
  8443. memset(atcmd_output, '\0', sizeof(atcmd_output));\
  8444. if (pl_sd->status.cmd > max_status[(stat)]) {\
  8445. sprintf(atcmd_output, msg_txt(sd, 737), #cmd, pl_sd->status.cmd, max_status[(stat)]);\
  8446. clif_displaymessage(fd, atcmd_output);\
  8447. sd->status.cmd = max_status[(stat)];\
  8448. }\
  8449. else\
  8450. sd->status.cmd = pl_sd->status.cmd;\
  8451. }
  8452. clonestat_check(str, PARAM_STR);
  8453. clonestat_check(agi, PARAM_AGI);
  8454. clonestat_check(vit, PARAM_VIT);
  8455. clonestat_check(int_, PARAM_INT);
  8456. clonestat_check(dex, PARAM_DEX);
  8457. clonestat_check(luk, PARAM_LUK);
  8458. for (i = 0; i < PARAM_MAX; i++) {
  8459. clif_updatestatus(sd, SP_STR + i);
  8460. clif_updatestatus(sd, SP_USTR + i);
  8461. }
  8462. status_calc_pc(sd, SCO_FORCE);
  8463. }
  8464. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8465. sprintf(atcmd_output, msg_txt(sd, 738), "status");
  8466. clif_displaymessage(fd, atcmd_output);
  8467. #undef clonestat_check
  8468. return 0;
  8469. }
  8470. /**
  8471. * Adopt a character.
  8472. * Usage: @adopt <char name>
  8473. * https://rathena.org/board/topic/104014-suggestion-add-adopt-or-etc/
  8474. */
  8475. ACMD_FUNC(adopt)
  8476. {
  8477. TBL_PC *b_sd;
  8478. enum adopt_responses response;
  8479. nullpo_retr(-1, sd);
  8480. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8481. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  8482. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  8483. sprintf(atcmd_output, msg_txt(sd, 435), command); // Please enter a player name (usage: %s <char name>).
  8484. clif_displaymessage(fd, atcmd_output);
  8485. return -1;
  8486. }
  8487. if ((b_sd = map_nick2sd((char *)atcmd_player_name,false)) == NULL) {
  8488. clif_displaymessage(fd, msg_txt(sd, 3)); // Character not found.
  8489. return -1;
  8490. }
  8491. response = pc_try_adopt(sd, map_charid2sd(sd->status.partner_id), b_sd);
  8492. if (response == ADOPT_ALLOWED) {
  8493. TBL_PC *p_sd = map_charid2sd(sd->status.partner_id);
  8494. b_sd->adopt_invite = sd->status.account_id;
  8495. clif_Adopt_request(b_sd, sd, p_sd->status.account_id);
  8496. return 0;
  8497. }
  8498. if (response < ADOPT_MORE_CHILDREN) // No displaymessage for client-type responses
  8499. clif_displaymessage(fd, msg_txt(sd, 744 + response - 1));
  8500. return -1;
  8501. }
  8502. #include "../custom/atcommand.inc"
  8503. /**
  8504. * Fills the reference of available commands in atcommand DBMap
  8505. **/
  8506. #define ACMD_DEF(x) { #x, atcommand_ ## x, NULL, NULL, 0 }
  8507. #define ACMD_DEF2(x2, x) { x2, atcommand_ ## x, NULL, NULL, 0 }
  8508. // Define with restriction
  8509. #define ACMD_DEFR(x, r) { #x, atcommand_ ## x, NULL, NULL, r }
  8510. #define ACMD_DEF2R(x2, x, r) { x2, atcommand_ ## x, NULL, NULL, r }
  8511. void atcommand_basecommands(void) {
  8512. /**
  8513. * Command reference list, place the base of your commands here
  8514. * TODO: List all commands that causing crash
  8515. **/
  8516. AtCommandInfo atcommand_base[] = {
  8517. #include "../custom/atcommand_def.inc"
  8518. ACMD_DEF2R("warp", mapmove, ATCMD_NOCONSOLE),
  8519. ACMD_DEF(where),
  8520. ACMD_DEF(jumpto),
  8521. ACMD_DEF(jump),
  8522. ACMD_DEF(who),
  8523. ACMD_DEF2("who2", who),
  8524. ACMD_DEF2("who3", who),
  8525. ACMD_DEF2("whomap", who),
  8526. ACMD_DEF2("whomap2", who),
  8527. ACMD_DEF2("whomap3", who),
  8528. ACMD_DEF(whogm),
  8529. ACMD_DEF(save),
  8530. ACMD_DEF(load),
  8531. ACMD_DEF(speed),
  8532. ACMD_DEF(storage),
  8533. ACMD_DEF(guildstorage),
  8534. ACMD_DEF(option),
  8535. ACMD_DEF(hide), // + /hide
  8536. ACMD_DEFR(jobchange, ATCMD_NOCONSOLE),
  8537. ACMD_DEF(kill),
  8538. ACMD_DEF(alive),
  8539. ACMD_DEF(kami),
  8540. ACMD_DEF2("kamib", kami),
  8541. ACMD_DEF2("kamic", kami),
  8542. ACMD_DEF2("lkami", kami),
  8543. ACMD_DEF(heal),
  8544. ACMD_DEF(item),
  8545. ACMD_DEF(item2),
  8546. ACMD_DEF2("itembound",item),
  8547. ACMD_DEF2("itembound2",item2),
  8548. ACMD_DEF(itemreset),
  8549. ACMD_DEF(clearstorage),
  8550. ACMD_DEF(cleargstorage),
  8551. ACMD_DEF(clearcart),
  8552. ACMD_DEF2R("blvl", baselevelup, ATCMD_NOCONSOLE),
  8553. ACMD_DEF2("jlvl", joblevelup),
  8554. ACMD_DEF(help),
  8555. ACMD_DEF(pvpoff),
  8556. ACMD_DEF(pvpon),
  8557. ACMD_DEF(gvgoff),
  8558. ACMD_DEF(gvgon),
  8559. ACMD_DEF(model),
  8560. ACMD_DEFR(go, ATCMD_NOCONSOLE),
  8561. ACMD_DEF(monster),
  8562. ACMD_DEF2("monstersmall", monster),
  8563. ACMD_DEF2("monsterbig", monster),
  8564. ACMD_DEF(killmonster),
  8565. ACMD_DEF2("killmonster2", killmonster),
  8566. ACMD_DEF(refine),
  8567. ACMD_DEF(produce),
  8568. ACMD_DEF(memo),
  8569. ACMD_DEF(gat),
  8570. ACMD_DEF(displaystatus),
  8571. ACMD_DEF2("stpoint", statuspoint),
  8572. ACMD_DEF2("skpoint", skillpoint),
  8573. ACMD_DEF(zeny),
  8574. ACMD_DEF2("str", param),
  8575. ACMD_DEF2("agi", param),
  8576. ACMD_DEF2("vit", param),
  8577. ACMD_DEF2("int", param),
  8578. ACMD_DEF2("dex", param),
  8579. ACMD_DEF2("luk", param),
  8580. ACMD_DEF2("glvl", guildlevelup),
  8581. ACMD_DEF(makeegg),
  8582. ACMD_DEF(hatch),
  8583. ACMD_DEF(petfriendly),
  8584. ACMD_DEF(pethungry),
  8585. ACMD_DEF(petrename),
  8586. ACMD_DEF(recall), // + /recall
  8587. ACMD_DEF(night),
  8588. ACMD_DEF(day),
  8589. ACMD_DEF(doom),
  8590. ACMD_DEF(doommap),
  8591. ACMD_DEF(raise),
  8592. ACMD_DEF(raisemap),
  8593. ACMD_DEFR(kick,ATCMD_NOAUTOTRADE), // + right click menu for GM "(name) force to quit"
  8594. ACMD_DEF(kickall),
  8595. ACMD_DEF(allskill),
  8596. ACMD_DEF(questskill),
  8597. ACMD_DEF(lostskill),
  8598. ACMD_DEF(spiritball),
  8599. ACMD_DEF(party),
  8600. ACMD_DEF(guild),
  8601. ACMD_DEF(breakguild),
  8602. ACMD_DEF(agitstart),
  8603. ACMD_DEF(agitend),
  8604. ACMD_DEF(mapexit),
  8605. ACMD_DEF(idsearch),
  8606. ACMD_DEF(broadcast), // + /b and /nb
  8607. ACMD_DEF(localbroadcast), // + /lb and /nlb
  8608. ACMD_DEF(recallall),
  8609. ACMD_DEFR(reload,ATCMD_NOSCRIPT),
  8610. ACMD_DEF2("reloaditemdb", reload),
  8611. ACMD_DEF2("reloadmobdb", reload),
  8612. ACMD_DEF2("reloadskilldb", reload),
  8613. ACMD_DEF2R("reloadscript", reload, ATCMD_NOSCRIPT),
  8614. ACMD_DEF2("reloadatcommand", reload),
  8615. ACMD_DEF2("reloadbattleconf", reload),
  8616. ACMD_DEF2("reloadstatusdb", reload),
  8617. ACMD_DEF2("reloadpcdb", reload),
  8618. ACMD_DEF2("reloadmotd", reload),
  8619. ACMD_DEF2("reloadquestdb", reload),
  8620. ACMD_DEF2("reloadmsgconf", reload),
  8621. ACMD_DEF2("reloadpacketdb", reload),
  8622. ACMD_DEF2("reloadinstancedb", reload),
  8623. ACMD_DEF(partysharelvl),
  8624. ACMD_DEF(mapinfo),
  8625. ACMD_DEF(dye),
  8626. ACMD_DEF2("hairstyle", hair_style),
  8627. ACMD_DEF2("haircolor", hair_color),
  8628. ACMD_DEF2("allstats", stat_all),
  8629. ACMD_DEF2("block", char_block),
  8630. ACMD_DEF2("ban", char_ban),
  8631. ACMD_DEF2("unblock", char_unblock),
  8632. ACMD_DEF2("unban", char_unban),
  8633. ACMD_DEF2("charban", char_ban),
  8634. ACMD_DEF2("charunban", char_unban),
  8635. ACMD_DEF2("mount", mount_peco),
  8636. ACMD_DEF(guildspy),
  8637. ACMD_DEF(partyspy),
  8638. ACMD_DEF(clanspy),
  8639. ACMD_DEF(repairall),
  8640. ACMD_DEF(guildrecall),
  8641. ACMD_DEF(partyrecall),
  8642. ACMD_DEF(nuke),
  8643. ACMD_DEF(shownpc),
  8644. ACMD_DEF(hidenpc),
  8645. ACMD_DEF(loadnpc),
  8646. ACMD_DEF(unloadnpc),
  8647. ACMD_DEF(reloadnpc),
  8648. ACMD_DEF2("time", servertime),
  8649. ACMD_DEF(jail),
  8650. ACMD_DEF(unjail),
  8651. ACMD_DEF(jailfor),
  8652. ACMD_DEF(jailtime),
  8653. ACMD_DEF(disguise),
  8654. ACMD_DEF(undisguise),
  8655. ACMD_DEF(email),
  8656. ACMD_DEF(effect),
  8657. ACMD_DEF(follow),
  8658. ACMD_DEF(addwarp),
  8659. ACMD_DEF(skillon),
  8660. ACMD_DEF(skilloff),
  8661. ACMD_DEF(killer),
  8662. ACMD_DEF(npcmove),
  8663. ACMD_DEF(killable),
  8664. ACMD_DEF(dropall),
  8665. ACMD_DEF(storeall),
  8666. ACMD_DEF(skillid),
  8667. ACMD_DEF(useskill),
  8668. ACMD_DEF(displayskill),
  8669. ACMD_DEF(snow),
  8670. ACMD_DEF(sakura),
  8671. ACMD_DEF(clouds),
  8672. ACMD_DEF(clouds2),
  8673. ACMD_DEF(fog),
  8674. ACMD_DEF(fireworks),
  8675. ACMD_DEF(leaves),
  8676. ACMD_DEF(summon),
  8677. ACMD_DEF(adjgroup),
  8678. ACMD_DEF(trade),
  8679. ACMD_DEF(send),
  8680. ACMD_DEF(setbattleflag),
  8681. ACMD_DEF(unmute),
  8682. ACMD_DEF(clearweather),
  8683. ACMD_DEF(uptime),
  8684. ACMD_DEF(changesex),
  8685. ACMD_DEF(changecharsex),
  8686. ACMD_DEF(mute),
  8687. ACMD_DEF(refresh),
  8688. ACMD_DEF(refreshall),
  8689. ACMD_DEF(identify),
  8690. ACMD_DEF(identifyall),
  8691. ACMD_DEF(gmotd),
  8692. ACMD_DEF(misceffect),
  8693. ACMD_DEF(mobsearch),
  8694. ACMD_DEF(cleanmap),
  8695. ACMD_DEF(cleanarea),
  8696. ACMD_DEF(npctalk),
  8697. ACMD_DEF(pettalk),
  8698. ACMD_DEF(users),
  8699. ACMD_DEF(reset),
  8700. ACMD_DEF(skilltree),
  8701. ACMD_DEF(marry),
  8702. ACMD_DEF(divorce),
  8703. ACMD_DEF(sound),
  8704. ACMD_DEF(undisguiseall),
  8705. ACMD_DEF(disguiseall),
  8706. ACMD_DEF(changelook),
  8707. ACMD_DEF(autoloot),
  8708. ACMD_DEF2("alootid", autolootitem),
  8709. ACMD_DEF(autoloottype),
  8710. ACMD_DEF(mobinfo),
  8711. ACMD_DEF(exp),
  8712. ACMD_DEF(version),
  8713. ACMD_DEF(mutearea),
  8714. ACMD_DEF(rates),
  8715. ACMD_DEF(iteminfo),
  8716. ACMD_DEF(whodrops),
  8717. ACMD_DEF(whereis),
  8718. ACMD_DEF(mapflag),
  8719. ACMD_DEF(me),
  8720. ACMD_DEF(monsterignore),
  8721. ACMD_DEF(fakename),
  8722. ACMD_DEF(size),
  8723. ACMD_DEF(showexp),
  8724. ACMD_DEF(showzeny),
  8725. ACMD_DEF(showdelay),
  8726. ACMD_DEF(autotrade),
  8727. ACMD_DEF(changegm),
  8728. ACMD_DEF(changeleader),
  8729. ACMD_DEF(partyoption),
  8730. ACMD_DEF(invite),
  8731. ACMD_DEF(duel),
  8732. ACMD_DEF(leave),
  8733. ACMD_DEF(accept),
  8734. ACMD_DEF(reject),
  8735. ACMD_DEF(clone),
  8736. ACMD_DEF2("slaveclone", clone),
  8737. ACMD_DEF2("evilclone", clone),
  8738. ACMD_DEF(tonpc),
  8739. ACMD_DEF(commands),
  8740. ACMD_DEF(noask),
  8741. ACMD_DEF(request),
  8742. ACMD_DEF(homlevel),
  8743. ACMD_DEF(homevolution),
  8744. ACMD_DEF(hommutate),
  8745. ACMD_DEF(makehomun),
  8746. ACMD_DEF(homfriendly),
  8747. ACMD_DEF(homhungry),
  8748. ACMD_DEF(homtalk),
  8749. ACMD_DEF(hominfo),
  8750. ACMD_DEF(homstats),
  8751. ACMD_DEF(homshuffle),
  8752. ACMD_DEF(showmobs),
  8753. ACMD_DEF(feelreset),
  8754. ACMD_DEF(auction),
  8755. ACMD_DEF(mail),
  8756. ACMD_DEF2("noks", ksprotection),
  8757. ACMD_DEF(allowks),
  8758. ACMD_DEF(cash),
  8759. ACMD_DEF2("points", cash),
  8760. ACMD_DEF(agitstart2),
  8761. ACMD_DEF(agitend2),
  8762. ACMD_DEF(resetskill),
  8763. ACMD_DEF(resetstat),
  8764. ACMD_DEF2("storagelist", itemlist),
  8765. ACMD_DEF2("cartlist", itemlist),
  8766. ACMD_DEF2("itemlist", itemlist),
  8767. ACMD_DEF(stats),
  8768. ACMD_DEF(delitem),
  8769. ACMD_DEF(charcommands),
  8770. ACMD_DEF(font),
  8771. ACMD_DEF(accinfo),
  8772. ACMD_DEF(set),
  8773. ACMD_DEF(undisguiseguild),
  8774. ACMD_DEF(disguiseguild),
  8775. ACMD_DEF(sizeall),
  8776. ACMD_DEF(sizeguild),
  8777. ACMD_DEF(addperm),
  8778. ACMD_DEF2("rmvperm", addperm),
  8779. ACMD_DEF(unloadnpcfile),
  8780. ACMD_DEF(cart),
  8781. ACMD_DEF(mount2),
  8782. ACMD_DEF(join),
  8783. ACMD_DEFR(channel,ATCMD_NOSCRIPT),
  8784. ACMD_DEF(fontcolor),
  8785. ACMD_DEF(langtype),
  8786. #ifdef VIP_ENABLE
  8787. ACMD_DEF(vip),
  8788. ACMD_DEF(showrate),
  8789. #endif
  8790. ACMD_DEF(fullstrip),
  8791. ACMD_DEF(costume),
  8792. ACMD_DEF(cloneequip),
  8793. ACMD_DEF(clonestat),
  8794. ACMD_DEF(bodystyle),
  8795. ACMD_DEF(adopt),
  8796. ACMD_DEF(agitstart3),
  8797. ACMD_DEF(agitend3),
  8798. };
  8799. AtCommandInfo* atcommand;
  8800. int i;
  8801. for( i = 0; i < ARRAYLENGTH(atcommand_base); i++ ) {
  8802. if(atcommand_exists(atcommand_base[i].command)) { // Should not happen if atcommand_base[] array is OK
  8803. ShowDebug("atcommand_basecommands: duplicate ACMD_DEF for '%s'.\n", atcommand_base[i].command);
  8804. continue;
  8805. }
  8806. CREATE(atcommand, AtCommandInfo, 1);
  8807. safestrncpy(atcommand->command, atcommand_base[i].command, sizeof(atcommand->command));
  8808. atcommand->func = atcommand_base[i].func;
  8809. atcommand->restriction = atcommand_base[i].restriction;
  8810. strdb_put(atcommand_db, atcommand->command, atcommand);
  8811. }
  8812. return;
  8813. }
  8814. /*==========================================
  8815. * Command lookup functions
  8816. *------------------------------------------*/
  8817. bool atcommand_exists(const char* name)
  8818. {
  8819. return strdb_exists(atcommand_db, name);
  8820. }
  8821. static AtCommandInfo* get_atcommandinfo_byname(const char *name)
  8822. {
  8823. if (strdb_exists(atcommand_db, name))
  8824. return (AtCommandInfo*)strdb_get(atcommand_db, name);
  8825. return NULL;
  8826. }
  8827. static const char* atcommand_checkalias(const char *aliasname)
  8828. {
  8829. AliasInfo *alias_info = NULL;
  8830. if ((alias_info = (AliasInfo*)strdb_get(atcommand_alias_db, aliasname)) != NULL)
  8831. return alias_info->command->command;
  8832. return aliasname;
  8833. }
  8834. /// AtCommand suggestion
  8835. static void atcommand_get_suggestions(struct map_session_data* sd, const char *name, bool atcommand) {
  8836. DBIterator* atcommand_iter;
  8837. DBIterator* alias_iter;
  8838. AtCommandInfo* command_info = NULL;
  8839. AliasInfo* alias_info = NULL;
  8840. AtCommandType type = atcommand ? COMMAND_ATCOMMAND : COMMAND_CHARCOMMAND;
  8841. char* full_match[MAX_SUGGESTIONS];
  8842. char* suggestions[MAX_SUGGESTIONS];
  8843. char* match;
  8844. int prefix_count = 0, full_count = 0;
  8845. bool can_use;
  8846. if (!battle_config.atcommand_suggestions_enabled)
  8847. return;
  8848. atcommand_iter = db_iterator(atcommand_db);
  8849. alias_iter = db_iterator(atcommand_alias_db);
  8850. // Build the matches
  8851. for (command_info = (AtCommandInfo*)dbi_first(atcommand_iter); dbi_exists(atcommand_iter); command_info = (AtCommandInfo*)dbi_next(atcommand_iter)) {
  8852. match = strstr(command_info->command, name);
  8853. can_use = pc_can_use_command(sd, command_info->command, type);
  8854. if ( prefix_count < MAX_SUGGESTIONS && match == command_info->command && can_use ) {
  8855. suggestions[prefix_count] = command_info->command;
  8856. ++prefix_count;
  8857. }
  8858. if ( full_count < MAX_SUGGESTIONS && match != NULL && match != command_info->command && can_use ) {
  8859. full_match[full_count] = command_info->command;
  8860. ++full_count;
  8861. }
  8862. }
  8863. for (alias_info = (AliasInfo *)dbi_first(alias_iter); dbi_exists(alias_iter); alias_info = (AliasInfo *)dbi_next(alias_iter)) {
  8864. match = strstr(alias_info->alias, name);
  8865. can_use = pc_can_use_command(sd, alias_info->command->command, type);
  8866. if ( prefix_count < MAX_SUGGESTIONS && match == alias_info->alias && can_use) {
  8867. suggestions[prefix_count] = alias_info->alias;
  8868. ++prefix_count;
  8869. }
  8870. if ( full_count < MAX_SUGGESTIONS && match != NULL && match != alias_info->alias && can_use ) {
  8871. full_match[full_count] = alias_info->alias;
  8872. ++full_count;
  8873. }
  8874. }
  8875. if ((full_count+prefix_count) > 0) {
  8876. char buffer[512];
  8877. int i;
  8878. // Merge full match and prefix match results
  8879. if (prefix_count < MAX_SUGGESTIONS) {
  8880. memmove(&suggestions[prefix_count], full_match, sizeof(char*) * (MAX_SUGGESTIONS-prefix_count));
  8881. prefix_count = min(prefix_count+full_count, MAX_SUGGESTIONS);
  8882. }
  8883. // Build the suggestion string
  8884. strcpy(buffer, msg_txt(sd,205));
  8885. strcat(buffer,"\n");
  8886. for(i=0; i < prefix_count; ++i) {
  8887. strcat(buffer,suggestions[i]);
  8888. strcat(buffer," ");
  8889. }
  8890. clif_displaymessage(sd->fd, buffer);
  8891. }
  8892. dbi_destroy(atcommand_iter);
  8893. dbi_destroy(alias_iter);
  8894. }
  8895. /**
  8896. * Executes an at-command
  8897. * @param fd
  8898. * @param sd
  8899. * @param message
  8900. * @param type
  8901. * 0 : script call (atcommand)
  8902. * 1 : normal player @atcommand
  8903. * 2 : console (admin:@atcommand)
  8904. * 3 : script call (useatcmd)
  8905. */
  8906. bool is_atcommand(const int fd, struct map_session_data* sd, const char* message, int type)
  8907. {
  8908. char command[CHAT_SIZE_MAX], params[CHAT_SIZE_MAX];
  8909. char output[CHAT_SIZE_MAX];
  8910. //Reconstructed message
  8911. char atcmd_msg[CHAT_SIZE_MAX];
  8912. TBL_PC * ssd = NULL; //sd for target
  8913. AtCommandInfo * info;
  8914. bool is_atcommand = true; // false if it's a charcommand
  8915. nullpo_retr(false, sd);
  8916. //Shouldn't happen
  8917. if ( !message || !*message )
  8918. return false;
  8919. //If cannot use atcomamnd while talking with NPC [Kichi]
  8920. if (type == 1 && sd->npc_id && sd->state.disable_atcommand_on_npc)
  8921. return false;
  8922. //Block NOCHAT but do not display it as a normal message
  8923. if ( sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCOMMAND )
  8924. return true;
  8925. // skip 10/11-langtype's codepage indicator, if detected
  8926. if ( message[0] == '|' && strlen(message) >= 4 && (message[3] == atcommand_symbol || message[3] == charcommand_symbol) )
  8927. message += 3;
  8928. //Should display as a normal message
  8929. if ( *message != atcommand_symbol && *message != charcommand_symbol )
  8930. return false;
  8931. // type value 0|2 = script|console invoked: bypass restrictions
  8932. if ( type == 1 || type == 3) {
  8933. //Commands are disabled on maps flagged as 'nocommand'
  8934. if ( map[sd->bl.m].nocommand && pc_get_group_level(sd) < map[sd->bl.m].nocommand ) {
  8935. clif_displaymessage(fd, msg_txt(sd,143));
  8936. return false;
  8937. }
  8938. }
  8939. if (*message == charcommand_symbol)
  8940. is_atcommand = false;
  8941. if (is_atcommand) { // @command
  8942. sprintf(atcmd_msg, "%s", message);
  8943. ssd = sd;
  8944. } else { // #command
  8945. char charname[NAME_LENGTH];
  8946. int n;
  8947. //Checks to see if #command has a name or a name + parameters.
  8948. if ((n = sscanf(message, "%255s \"%23[^\"]\" %255[^\n]", command, charname, params)) < 2
  8949. && (n = sscanf(message, "%255s %23s %255[^\n]", command, charname, params)) < 2
  8950. ) {
  8951. if (pc_get_group_level(sd) == 0) {
  8952. if (n < 1)
  8953. return false; // No command found. Display as normal message.
  8954. info = get_atcommandinfo_byname(atcommand_checkalias(command + 1));
  8955. 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
  8956. return false;
  8957. }
  8958. sprintf(output, msg_txt(sd,1388), charcommand_symbol); // Charcommand failed (usage: %c<command> <char name> <parameters>).
  8959. clif_displaymessage(fd, output);
  8960. return true;
  8961. }
  8962. ssd = map_nick2sd(charname,true);
  8963. if (ssd == NULL) {
  8964. sprintf(output, msg_txt(sd,1389), command); // %s failed. Player not found.
  8965. clif_displaymessage(fd, output);
  8966. return true;
  8967. }
  8968. if (n > 2)
  8969. sprintf(atcmd_msg, "%s %s", command, params);
  8970. else
  8971. sprintf(atcmd_msg, "%s", command);
  8972. }
  8973. if (battle_config.idletime_option&IDLE_ATCOMMAND)
  8974. sd->idletime = last_tick;
  8975. //Clearing these to be used once more.
  8976. memset(command, '\0', sizeof(command));
  8977. memset(params, '\0', sizeof(params));
  8978. //check to see if any params exist within this command
  8979. if( sscanf(atcmd_msg, "%255s %255[^\n]", command, params) < 2 )
  8980. params[0] = '\0';
  8981. // @commands (script based)
  8982. if((type == 1 || type == 3) && atcmd_binding_count > 0) {
  8983. struct atcmd_binding_data *binding = get_atcommandbind_byname(command);
  8984. // Check if the binding isn't NULL and there is a NPC event, level of usage met, et cetera
  8985. if( binding != NULL && binding->npc_event[0] &&
  8986. ((is_atcommand && pc_get_group_level(sd) >= binding->level) ||
  8987. (!is_atcommand && pc_get_group_level(sd) >= binding->level2)))
  8988. {
  8989. // Check if self or character invoking; if self == character invoked, then self invoke.
  8990. npc_do_atcmd_event(ssd, command, params, binding->npc_event);
  8991. return true;
  8992. }
  8993. }
  8994. //Grab the command information and check for the proper GM level required to use it or if the command exists
  8995. info = get_atcommandinfo_byname(atcommand_checkalias(command + 1));
  8996. if (info == NULL) {
  8997. if (pc_get_group_level(sd) == 0) // TODO: remove or replace with proper permission
  8998. return false;
  8999. sprintf(output, msg_txt(sd,153), command); // "%s is Unknown Command."
  9000. clif_displaymessage(fd, output);
  9001. atcommand_get_suggestions(sd, command + 1, is_atcommand);
  9002. return true;
  9003. }
  9004. //check restriction
  9005. if (info->restriction) {
  9006. if (info->restriction&ATCMD_NOCONSOLE && type == 2) //console prevent
  9007. return true;
  9008. if (info->restriction&ATCMD_NOSCRIPT && (type == 0 || type == 3)) //scripts prevent
  9009. return true;
  9010. if (info->restriction&ATCMD_NOAUTOTRADE && (type == 0 || type == 3)
  9011. && ((is_atcommand && sd && sd->state.autotrade) || (ssd && ssd->state.autotrade)))
  9012. return true;
  9013. }
  9014. // type == 1 : player invoked
  9015. if (type == 1) {
  9016. if ((is_atcommand && info->at_groups[sd->group_pos] == 0) ||
  9017. (!is_atcommand && info->char_groups[sd->group_pos] == 0) )
  9018. return false;
  9019. if( pc_isdead(sd) && pc_has_permission(sd,PC_PERM_DISABLE_CMD_DEAD) ) {
  9020. clif_displaymessage(fd, msg_txt(sd,1393)); // You can't use commands while dead
  9021. return true;
  9022. }
  9023. }
  9024. //Attempt to use the command
  9025. if ( (info->func(fd, ssd, command, params) != 0) )
  9026. {
  9027. sprintf(output,msg_txt(sd,154), command); // %s failed.
  9028. clif_displaymessage(fd, output);
  9029. return true;
  9030. }
  9031. //Log only if successful.
  9032. log_atcommand(sd, is_atcommand ? atcmd_msg : message);
  9033. return true;
  9034. }
  9035. /*==========================================
  9036. *
  9037. *------------------------------------------*/
  9038. static void atcommand_config_read(const char* config_filename)
  9039. {
  9040. config_setting_t *aliases = NULL, *help = NULL;
  9041. const char *symbol = NULL;
  9042. int num_aliases = 0;
  9043. if (conf_read_file(&atcommand_config, config_filename))
  9044. return;
  9045. // Command symbols
  9046. if (config_lookup_string(&atcommand_config, "atcommand_symbol", &symbol)) {
  9047. if (ISPRINT(*symbol) && // no control characters
  9048. *symbol != '/' && // symbol of client commands
  9049. *symbol != '%' && // symbol of party chat
  9050. *symbol != '$' && // symbol of guild chat
  9051. *symbol != charcommand_symbol)
  9052. atcommand_symbol = *symbol;
  9053. }
  9054. if (config_lookup_string(&atcommand_config, "charcommand_symbol", &symbol)) {
  9055. if (ISPRINT(*symbol) && // no control characters
  9056. *symbol != '/' && // symbol of client commands
  9057. *symbol != '%' && // symbol of party chat
  9058. *symbol != '$' && // symbol of guild chat
  9059. *symbol != atcommand_symbol)
  9060. charcommand_symbol = *symbol;
  9061. }
  9062. // Command aliases
  9063. aliases = config_lookup(&atcommand_config, "aliases");
  9064. if (aliases != NULL) {
  9065. int i = 0;
  9066. int count = config_setting_length(aliases);
  9067. for (i = 0; i < count; ++i) {
  9068. config_setting_t *command;
  9069. const char *commandname = NULL;
  9070. int j = 0, alias_count = 0;
  9071. AtCommandInfo *commandinfo = NULL;
  9072. command = config_setting_get_elem(aliases, i);
  9073. if (config_setting_type(command) != CONFIG_TYPE_ARRAY)
  9074. continue;
  9075. commandname = config_setting_name(command);
  9076. if (!atcommand_exists(commandname)) {
  9077. ShowConfigWarning(command, "atcommand_config_read: can not set alias for non-existent command %s", commandname);
  9078. continue;
  9079. }
  9080. commandinfo = get_atcommandinfo_byname(commandname);
  9081. alias_count = config_setting_length(command);
  9082. for (j = 0; j < alias_count; ++j) {
  9083. const char *alias = config_setting_get_string_elem(command, j);
  9084. if (alias != NULL) {
  9085. AliasInfo *alias_info;
  9086. if (strdb_exists(atcommand_alias_db, alias)) {
  9087. ShowConfigWarning(command, "atcommand_config_read: alias %s already exists", alias);
  9088. continue;
  9089. }
  9090. CREATE(alias_info, AliasInfo, 1);
  9091. alias_info->command = commandinfo;
  9092. safestrncpy(alias_info->alias, alias, sizeof(alias_info->alias));
  9093. strdb_put(atcommand_alias_db, alias, alias_info);
  9094. ++num_aliases;
  9095. }
  9096. }
  9097. }
  9098. }
  9099. // Commands help
  9100. // We only check if all commands exist
  9101. help = config_lookup(&atcommand_config, "help");
  9102. if (help != NULL) {
  9103. int count = config_setting_length(help);
  9104. int i;
  9105. for (i = 0; i < count; ++i) {
  9106. config_setting_t *command;
  9107. const char *commandname;
  9108. command = config_setting_get_elem(help, i);
  9109. commandname = config_setting_name(command);
  9110. if (!atcommand_exists(commandname))
  9111. ShowConfigWarning(command, "atcommand_config_read: command %s does not exist", commandname);
  9112. }
  9113. }
  9114. ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' command aliases in '"CL_WHITE"%s"CL_RESET"'.\n", num_aliases, config_filename);
  9115. return;
  9116. }
  9117. void atcommand_db_load_groups(int* group_ids) {
  9118. DBIterator *iter = db_iterator(atcommand_db);
  9119. AtCommandInfo* cmd;
  9120. int i;
  9121. for (cmd = (AtCommandInfo*)dbi_first(iter); dbi_exists(iter); cmd = (AtCommandInfo*)dbi_next(iter)) {
  9122. cmd->at_groups = (char*)aMalloc( pc_group_max * sizeof(char) );
  9123. cmd->char_groups = (char*)aMalloc( pc_group_max * sizeof(char) );
  9124. for(i = 0; i < pc_group_max; i++) {
  9125. if( pc_group_can_use_command(group_ids[i], cmd->command, COMMAND_ATCOMMAND ) )
  9126. cmd->at_groups[i] = 1;
  9127. else
  9128. cmd->at_groups[i] = 0;
  9129. if( pc_group_can_use_command(group_ids[i], cmd->command, COMMAND_CHARCOMMAND ) )
  9130. cmd->char_groups[i] = 1;
  9131. else
  9132. cmd->char_groups[i] = 0;
  9133. }
  9134. }
  9135. dbi_destroy(iter);
  9136. return;
  9137. }
  9138. void atcommand_db_clear(void) {
  9139. if (atcommand_db != NULL) {
  9140. DBIterator *iter = db_iterator(atcommand_db);
  9141. AtCommandInfo* cmd;
  9142. for (cmd = (AtCommandInfo*)dbi_first(iter); dbi_exists(iter); cmd = (AtCommandInfo*)dbi_next(iter)) {
  9143. aFree(cmd->at_groups);
  9144. aFree(cmd->char_groups);
  9145. }
  9146. dbi_destroy(iter);
  9147. db_destroy(atcommand_db);
  9148. }
  9149. if (atcommand_alias_db != NULL)
  9150. db_destroy(atcommand_alias_db);
  9151. config_destroy(&atcommand_config);
  9152. }
  9153. void atcommand_doload(void) {
  9154. atcommand_db_clear();
  9155. atcommand_db = stridb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, ATCOMMAND_LENGTH);
  9156. atcommand_alias_db = stridb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, ATCOMMAND_LENGTH);
  9157. atcommand_basecommands(); //fills initial atcommand_db with known commands
  9158. atcommand_config_read(ATCOMMAND_CONF_FILENAME);
  9159. }
  9160. void do_init_atcommand(void) {
  9161. atcommand_doload();
  9162. }
  9163. void do_final_atcommand(void) {
  9164. atcommand_db_clear();
  9165. }