Commands.cpp 314 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882
  1. /*
  2. EQ2Emulator: Everquest II Server Emulator
  3. Copyright (C) 2007 EQ2EMulator Development Team (http://www.eq2emulator.net)
  4. This file is part of EQ2Emulator.
  5. EQ2Emulator is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. EQ2Emulator is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with EQ2Emulator. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #include <sys/types.h>
  17. #include "Commands.h"
  18. #include "../ClientPacketFunctions.h"
  19. #include "../../common/version.h"
  20. #include "../../common/seperator.h"
  21. #include "../../common/servertalk.h"
  22. #include "../WorldDatabase.h"
  23. #include "../World.h"
  24. #include "../../common/ConfigReader.h"
  25. #include "../VisualStates.h"
  26. #include "../../common/debug.h"
  27. #include "../LuaInterface.h"
  28. #include "../Quests.h"
  29. #include "../client.h"
  30. #include "../NPC.h"
  31. #include "../Guilds/Guild.h"
  32. #include "../SpellProcess.h"
  33. #include "../Tradeskills/Tradeskills.h"
  34. #include "../../common/Log.h"
  35. #include "../../common/MiscFunctions.h"
  36. #include "../Languages.h"
  37. #include "../IRC/IRC.h"
  38. #include "../Traits/Traits.h"
  39. #include "../Chat/Chat.h"
  40. #include "../Rules/Rules.h"
  41. #include "../AltAdvancement/AltAdvancement.h"
  42. #include "../RaceTypes/RaceTypes.h"
  43. #include "../classes.h"
  44. #include "../Transmute.h"
  45. extern WorldDatabase database;
  46. extern MasterSpellList master_spell_list;
  47. extern MasterTraitList master_trait_list;
  48. extern MasterRecipeList master_recipe_list;
  49. extern MasterRecipeBookList master_recipebook_list;
  50. extern World world;
  51. extern ClientList client_list;
  52. extern ConfigReader configReader;
  53. extern VisualStates visual_states;
  54. extern ZoneList zone_list;
  55. extern LuaInterface* lua_interface;
  56. extern MasterQuestList master_quest_list;
  57. extern MasterCollectionList master_collection_list;
  58. extern MasterSkillList master_skill_list;
  59. extern MasterFactionList master_faction_list;
  60. extern GuildList guild_list;
  61. extern MasterLanguagesList master_languages_list;
  62. extern IRC irc;
  63. extern Chat chat;
  64. extern RuleManager rule_manager;
  65. extern MasterAAList master_aa_list;
  66. extern MasterRaceTypeList race_types_list;
  67. extern Classes classes;
  68. EQ2Packet* RemoteCommands::serialize(){
  69. buffer.clear();
  70. vector<EQ2_RemoteCommandString>::iterator command_list;
  71. buffer.append((char*)&num_commands, sizeof(int16));
  72. for( command_list = commands.begin(); command_list != commands.end(); command_list++ ) {
  73. AddDataCommand(&(*command_list));
  74. }
  75. EQ2Packet* app = new EQ2Packet(OP_SetRemoteCmdsMsg, (uchar*)buffer.c_str(), buffer.length() + 1);
  76. return app;
  77. }
  78. Commands::Commands(){
  79. remote_commands = new RemoteCommands();
  80. spawn_set_values["list"] = SPAWN_SET_VALUE_LIST;
  81. spawn_set_values["name"] = SPAWN_SET_VALUE_NAME;
  82. spawn_set_values["level"] = SPAWN_SET_VALUE_LEVEL; // TODO: Fix this, min_level, max_level
  83. spawn_set_values["difficulty"] = SPAWN_SET_VALUE_DIFFICULTY;
  84. spawn_set_values["model_type"] = SPAWN_SET_VALUE_MODEL_TYPE;
  85. spawn_set_values["class"] = SPAWN_SET_VALUE_CLASS;
  86. spawn_set_values["gender"] = SPAWN_SET_VALUE_GENDER;
  87. spawn_set_values["show_name"] = SPAWN_SET_VALUE_SHOW_NAME;
  88. spawn_set_values["attackable"] = SPAWN_SET_VALUE_ATTACKABLE;
  89. spawn_set_values["show_level"] = SPAWN_SET_VALUE_SHOW_LEVEL;
  90. spawn_set_values["targetable"] = SPAWN_SET_VALUE_TARGETABLE;
  91. spawn_set_values["show_command_icon"] = SPAWN_SET_VALUE_SHOW_COMMAND_ICON;
  92. spawn_set_values["display_hand_icon"] = SPAWN_SET_VALUE_HAND_ICON;
  93. spawn_set_values["hair_type"] = SPAWN_SET_VALUE_HAIR_TYPE;
  94. spawn_set_values["facial_hair_type"] = SPAWN_SET_VALUE_FACIAL_HAIR_TYPE;
  95. spawn_set_values["wing_type"] = SPAWN_SET_VALUE_WING_TYPE;
  96. spawn_set_values["chest_type"] = SPAWN_SET_VALUE_CHEST_TYPE;
  97. spawn_set_values["legs_type"] = SPAWN_SET_VALUE_LEGS_TYPE;
  98. spawn_set_values["soga_hair_type"] = SPAWN_SET_VALUE_SOGA_HAIR_TYPE;
  99. spawn_set_values["soga_facial_hair_type"] = SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE;
  100. spawn_set_values["soga_model_type"] = SPAWN_SET_VALUE_SOGA_MODEL_TYPE;
  101. spawn_set_values["size"] = SPAWN_SET_VALUE_SIZE;
  102. spawn_set_values["hp"] = SPAWN_SET_VALUE_HP;
  103. spawn_set_values["power"] = SPAWN_SET_VALUE_POWER;
  104. spawn_set_values["heroic"] = SPAWN_SET_VALUE_HEROIC;
  105. spawn_set_values["respawn"] = SPAWN_SET_VALUE_RESPAWN;
  106. spawn_set_values["x"] = SPAWN_SET_VALUE_X;
  107. spawn_set_values["y"] = SPAWN_SET_VALUE_Y;
  108. spawn_set_values["z"] = SPAWN_SET_VALUE_Z;
  109. spawn_set_values["heading"] = SPAWN_SET_VALUE_HEADING;
  110. spawn_set_values["location"] = SPAWN_SET_VALUE_LOCATION;
  111. spawn_set_values["command_primary"] = SPAWN_SET_VALUE_COMMAND_PRIMARY;
  112. spawn_set_values["command_secondary"] = SPAWN_SET_VALUE_COMMAND_SECONDARY;
  113. spawn_set_values["visual_state"] = SPAWN_SET_VALUE_VISUAL_STATE;
  114. spawn_set_values["action_state"] = SPAWN_SET_VALUE_ACTION_STATE;
  115. spawn_set_values["mood_state"] = SPAWN_SET_VALUE_MOOD_STATE;
  116. spawn_set_values["initial_state"] = SPAWN_SET_VALUE_INITIAL_STATE;
  117. spawn_set_values["activity_state"] = SPAWN_SET_VALUE_ACTIVITY_STATE;
  118. spawn_set_values["collision_radius"] = SPAWN_SET_VALUE_COLLISION_RADIUS;
  119. spawn_set_values["faction"] = SPAWN_SET_VALUE_FACTION;
  120. spawn_set_values["spawn_script"] = SPAWN_SET_VALUE_SPAWN_SCRIPT;
  121. spawn_set_values["spawnentry_script"] = SPAWN_SET_VALUE_SPAWNENTRY_SCRIPT;
  122. spawn_set_values["spawnlocation_script"] = SPAWN_SET_VALUE_SPAWNLOCATION_SCRIPT;
  123. spawn_set_values["sub_title"] = SPAWN_SET_VALUE_SUB_TITLE;
  124. spawn_set_values["expire"] = SPAWN_SET_VALUE_EXPIRE;
  125. spawn_set_values["expire_offset"] = SPAWN_SET_VALUE_EXPIRE_OFFSET;
  126. spawn_set_values["x_offset"] = SPAWN_SET_VALUE_X_OFFSET;
  127. spawn_set_values["y_offset"] = SPAWN_SET_VALUE_Y_OFFSET;
  128. spawn_set_values["z_offset"] = SPAWN_SET_VALUE_Z_OFFSET;
  129. spawn_set_values["device_id"] = SPAWN_SET_VALUE_DEVICE_ID;
  130. spawn_set_values["pitch"] = SPAWN_SET_VALUE_PITCH;
  131. spawn_set_values["roll"] = SPAWN_SET_VALUE_ROLL;
  132. spawn_set_values["hide_hood"] = SPAWN_SET_VALUE_HIDE_HOOD;
  133. spawn_set_values["emote_state"] = SPAWN_SET_VALUE_EMOTE_STATE;
  134. spawn_set_values["icon"] = SPAWN_SET_VALUE_ICON;
  135. spawn_set_values["prefix"] = SPAWN_SET_VALUE_PREFIX;
  136. spawn_set_values["suffix"] = SPAWN_SET_VALUE_SUFFIX;
  137. spawn_set_values["lastname"] = SPAWN_SET_VALUE_LASTNAME;
  138. zone_set_values["expansion_id"] = ZONE_SET_VALUE_EXPANSION_ID;
  139. zone_set_values["name"] = ZONE_SET_VALUE_NAME;
  140. zone_set_values["file"] = ZONE_SET_VALUE_FILE ;
  141. zone_set_values["description"] = ZONE_SET_VALUE_DESCRIPTION;
  142. zone_set_values["safe_x"] = ZONE_SET_VALUE_SAFE_X;
  143. zone_set_values["safe_y"] = ZONE_SET_VALUE_SAFE_Y;
  144. zone_set_values["safe_z"] = ZONE_SET_VALUE_SAFE_Z;
  145. zone_set_values["underworld"] = ZONE_SET_VALUE_UNDERWORLD;
  146. zone_set_values["min_recommended"] = ZONE_SET_VALUE_MIN_RECOMMENDED;
  147. zone_set_values["max_recommended"] = ZONE_SET_VALUE_MAX_RECOMMENDED;
  148. zone_set_values["zone_type"] = ZONE_SET_VALUE_ZONE_TYPE;
  149. zone_set_values["always_loaded"] = ZONE_SET_VALUE_ALWAYS_LOADED;
  150. zone_set_values["city_zone"] = ZONE_SET_VALUE_CITY_ZONE;
  151. zone_set_values["weather_allowed"] = ZONE_SET_VALUE_WEATHER_ALLOWED;
  152. zone_set_values["min_status"] = ZONE_SET_VALUE_MIN_STATUS;
  153. zone_set_values["min_level"] = ZONE_SET_VALUE_MIN_LEVEL;
  154. zone_set_values["start_zone"] = ZONE_SET_VALUE_START_ZONE;
  155. zone_set_values["instance_type"] = ZONE_SET_VALUE_INSTANCE_TYPE;
  156. zone_set_values["default_reenter_time"] = ZONE_SET_VALUE_DEFAULT_REENTER_TIME;
  157. zone_set_values["default_reset_time"] = ZONE_SET_VALUE_DEFAULT_RESET_TIME;
  158. zone_set_values["default_lockout_time"] = ZONE_SET_VALUE_DEFAULT_LOCKOUT_TIME;
  159. zone_set_values["force_group_to_zone"] = ZONE_SET_VALUE_FORCE_GROUP_TO_ZONE;
  160. zone_set_values["lua_script"] = ZONE_SET_VALUE_LUA_SCRIPT;
  161. zone_set_values["shutdown_timer"] = ZONE_SET_VALUE_SHUTDOWN_TIMER;
  162. zone_set_values["zone_motd"] = ZONE_SET_VALUE_ZONE_MOTD;
  163. }
  164. Commands::~Commands() {
  165. safe_delete(remote_commands);
  166. }
  167. int32 Commands::GetSpawnSetType(string val){
  168. if(spawn_set_values.count(val) > 0)
  169. return spawn_set_values[val];
  170. return 0xFFFFFFFF;
  171. }
  172. bool Commands::SetSpawnCommand(Client* client, Spawn* target, int8 type, const char* value, bool send_update, bool temporary, string* temp_value){
  173. if(!target)
  174. return false;
  175. int32 val = 0;
  176. try{
  177. if(type != SPAWN_SET_VALUE_NAME && !(type >= SPAWN_SET_VALUE_SPAWN_SCRIPT && type <= SPAWN_SET_VALUE_SUB_TITLE) && !(type >= SPAWN_SET_VALUE_PREFIX && type <= SPAWN_SET_VALUE_LASTNAME))
  178. val = atoul(value);
  179. }
  180. catch(...){
  181. if(client)
  182. client->Message(CHANNEL_COLOR_RED, "Invalid numeric spawn value: %s", value);
  183. return false;
  184. }
  185. if(temporary && temp_value){
  186. char tmp[128] = {0};
  187. switch(type){
  188. case SPAWN_SET_VALUE_NAME:{
  189. sprintf(tmp, "%s", target->GetName());
  190. target->SetName(value);
  191. client->GetCurrentZone()->SendUpdateTitles(target);
  192. break;
  193. }
  194. case SPAWN_SET_VALUE_X_OFFSET:
  195. {
  196. sprintf(tmp, "%f", target->GetXOffset());
  197. target->SetXOffset(float(val));
  198. break;
  199. }
  200. case SPAWN_SET_VALUE_Y_OFFSET:
  201. {
  202. sprintf(tmp, "%f", target->GetYOffset());
  203. target->SetYOffset(float(val));
  204. break;
  205. }
  206. case SPAWN_SET_VALUE_Z_OFFSET:
  207. {
  208. sprintf(tmp, "%f", target->GetZOffset());
  209. target->SetZOffset(float(val));
  210. break;
  211. }
  212. case SPAWN_SET_VALUE_EXPIRE: {
  213. sprintf(tmp, "%u", target->GetExpireTime());
  214. target->SetExpireTime(val);
  215. break;
  216. }
  217. case SPAWN_SET_VALUE_EXPIRE_OFFSET: {
  218. sprintf(tmp, "%u", target->GetExpireOffsetTime());
  219. target->SetExpireOffsetTime(val);
  220. break;
  221. }
  222. case SPAWN_SET_VALUE_SUB_TITLE: {
  223. sprintf(tmp, "%s", target->GetSubTitle());
  224. target->SetSubTitle(value);
  225. client->GetCurrentZone()->SendUpdateTitles(target);
  226. break;
  227. }
  228. case SPAWN_SET_VALUE_LEVEL:{
  229. sprintf(tmp, "%i", target->GetLevel());
  230. target->SetLevel(val, send_update);
  231. break;
  232. }
  233. case SPAWN_SET_VALUE_DIFFICULTY:{
  234. sprintf(tmp, "%i", target->GetEncounterLevel());
  235. target->SetEncounterLevel(val, send_update);
  236. break;
  237. }
  238. case SPAWN_SET_VALUE_MODEL_TYPE:{
  239. sprintf(tmp, "%i", target->GetModelType());
  240. target->SetModelType(val, send_update);
  241. break;
  242. }
  243. case SPAWN_SET_VALUE_CLASS:{
  244. sprintf(tmp, "%i", target->GetAdventureClass());
  245. target->SetAdventureClass(val, send_update);
  246. break;
  247. }
  248. case SPAWN_SET_VALUE_GENDER:{
  249. sprintf(tmp, "%i", target->GetGender());
  250. target->SetGender(val, send_update);
  251. break;
  252. }
  253. case SPAWN_SET_VALUE_SHOW_NAME:{
  254. sprintf(tmp, "%i", target->GetShowName());
  255. target->SetShowName(val, send_update);
  256. break;
  257. }
  258. case SPAWN_SET_VALUE_ATTACKABLE:{
  259. sprintf(tmp, "%i", target->GetAttackable());
  260. target->SetAttackable(val, send_update);
  261. break;
  262. }
  263. case SPAWN_SET_VALUE_SHOW_LEVEL:{
  264. sprintf(tmp, "%i", target->GetShowLevel());
  265. target->SetShowLevel(val, send_update);
  266. break;
  267. }
  268. case SPAWN_SET_VALUE_TARGETABLE:{
  269. sprintf(tmp, "%i", target->GetTargetable());
  270. target->SetTargetable(val, send_update);
  271. break;
  272. }
  273. case SPAWN_SET_VALUE_SHOW_COMMAND_ICON:{
  274. sprintf(tmp, "%i", target->GetShowCommandIcon());
  275. target->SetShowCommandIcon(val, send_update);
  276. break;
  277. }
  278. case SPAWN_SET_VALUE_HAND_ICON:{
  279. sprintf(tmp, "%i", target->GetShowHandIcon());
  280. target->SetShowHandIcon(val, send_update);
  281. break;
  282. }
  283. case SPAWN_SET_VALUE_HAIR_TYPE:{
  284. if(target->IsEntity()){
  285. sprintf(tmp, "%i", ((Entity*)target)->GetHairType());
  286. ((Entity*)target)->SetHairType(val, send_update);
  287. }
  288. break;
  289. }
  290. case SPAWN_SET_VALUE_FACIAL_HAIR_TYPE:{
  291. if(target->IsEntity()){
  292. sprintf(tmp, "%i", ((Entity*)target)->GetHairType());
  293. ((Entity*)target)->SetHairType(val, send_update);
  294. }
  295. break;
  296. }
  297. case SPAWN_SET_VALUE_WING_TYPE:{
  298. if(target->IsEntity()){
  299. sprintf(tmp, "%i", ((Entity*)target)->GetWingType());
  300. ((Entity*)target)->SetWingType(val, send_update);
  301. }
  302. break;
  303. }
  304. case SPAWN_SET_VALUE_CHEST_TYPE:{
  305. if(target->IsEntity()){
  306. sprintf(tmp, "%i", ((Entity*)target)->GetChestType());
  307. ((Entity*)target)->SetChestType(val, send_update);
  308. }
  309. break;
  310. }
  311. case SPAWN_SET_VALUE_LEGS_TYPE:{
  312. if(target->IsEntity()){
  313. sprintf(tmp, "%i", ((Entity*)target)->GetLegsType());
  314. ((Entity*)target)->SetLegsType(val, send_update);
  315. }
  316. break;
  317. }
  318. case SPAWN_SET_VALUE_SOGA_HAIR_TYPE:{
  319. if(target->IsEntity()){
  320. sprintf(tmp, "%i", ((Entity*)target)->GetSogaHairType());
  321. ((Entity*)target)->SetSogaHairType(val, send_update);
  322. }
  323. break;
  324. }
  325. case SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE:{
  326. if(target->IsEntity()){
  327. sprintf(tmp, "%i", ((Entity*)target)->GetSogaFacialHairType());
  328. ((Entity*)target)->SetSogaFacialHairType(val, send_update);
  329. }
  330. break;
  331. }
  332. case SPAWN_SET_VALUE_SOGA_MODEL_TYPE:{
  333. sprintf(tmp, "%i", target->GetSogaModelType());
  334. target->SetSogaModelType(val, send_update);
  335. break;
  336. }
  337. case SPAWN_SET_VALUE_SIZE:{
  338. sprintf(tmp, "%i", target->GetSize());
  339. target->SetSize(val, send_update);
  340. break;
  341. }
  342. case SPAWN_SET_VALUE_HP:{
  343. sprintf(tmp, "%i", target->GetHP());
  344. target->SetHP(val, send_update);
  345. break;
  346. }
  347. case SPAWN_SET_VALUE_POWER:{
  348. sprintf(tmp, "%i", target->GetPower());
  349. target->SetPower(val, send_update);
  350. break;
  351. }
  352. case SPAWN_SET_VALUE_HEROIC:{
  353. sprintf(tmp, "%i", target->GetHeroic());
  354. target->SetHeroic(val, send_update);
  355. break;
  356. }
  357. case SPAWN_SET_VALUE_RESPAWN:{
  358. sprintf(tmp, "%u", target->GetRespawnTime());
  359. target->SetRespawnTime(val);
  360. break;
  361. }
  362. case SPAWN_SET_VALUE_X:{
  363. sprintf(tmp, "%f", target->GetX());
  364. target->SetX(atof(value), send_update);
  365. break;
  366. }
  367. case SPAWN_SET_VALUE_Y:{
  368. sprintf(tmp, "%f", target->GetY());
  369. target->SetY(atof(value), send_update);
  370. break;
  371. }
  372. case SPAWN_SET_VALUE_Z:{
  373. sprintf(tmp, "%f", target->GetZ());
  374. target->SetZ(atof(value), send_update);
  375. break;
  376. }
  377. case SPAWN_SET_VALUE_HEADING:{
  378. sprintf(tmp, "%f", target->GetHeading());
  379. target->SetHeading(atof(value) + 360, send_update);
  380. break;
  381. }
  382. case SPAWN_SET_VALUE_VISUAL_STATE:{
  383. sprintf(tmp, "%i", target->GetVisualState());
  384. target->SetVisualState(val, send_update);
  385. break;
  386. }
  387. case SPAWN_SET_VALUE_ACTION_STATE:{
  388. sprintf(tmp, "%i", target->GetActionState());
  389. target->SetActionState(val, send_update);
  390. break;
  391. }
  392. case SPAWN_SET_VALUE_MOOD_STATE:{
  393. sprintf(tmp, "%i", target->GetMoodState());
  394. target->SetMoodState(val, send_update);
  395. break;
  396. }
  397. case SPAWN_SET_VALUE_INITIAL_STATE:{
  398. sprintf(tmp, "%i", target->GetInitialState());
  399. target->SetInitialState(val, send_update);
  400. break;
  401. }
  402. case SPAWN_SET_VALUE_ACTIVITY_STATE:{
  403. sprintf(tmp, "%i", target->GetActivityStatus());
  404. target->SetActivityStatus(val, send_update);
  405. break;
  406. }
  407. case SPAWN_SET_VALUE_COLLISION_RADIUS:{
  408. sprintf(tmp, "%i", target->GetCollisionRadius());
  409. target->SetCollisionRadius(val, send_update);
  410. break;
  411. }
  412. case SPAWN_SET_VALUE_DEVICE_ID: {
  413. if (target->IsObject()) {
  414. sprintf(tmp, "%i", ((Object*)target)->GetDeviceID());
  415. ((Object*)target)->SetDeviceID(val);
  416. }
  417. break;
  418. }
  419. case SPAWN_SET_VALUE_PITCH: {
  420. sprintf(tmp, "%f", target->GetPitch());
  421. target->SetPitch(atof(value), send_update);
  422. break;
  423. }
  424. case SPAWN_SET_VALUE_ROLL: {
  425. sprintf(tmp, "%f", target->GetRoll());
  426. target->SetRoll(atof(value), send_update);
  427. break;
  428. }
  429. case SPAWN_SET_VALUE_HIDE_HOOD: {
  430. sprintf(tmp, "%i", target->appearance.hide_hood);
  431. target->SetHideHood(val);
  432. break;
  433. }
  434. case SPAWN_SET_VALUE_EMOTE_STATE: {
  435. sprintf(tmp, "%i", target->appearance.emote_state);
  436. target->SetEmoteState(val);
  437. break;
  438. }
  439. case SPAWN_SET_VALUE_ICON: {
  440. sprintf(tmp, "%i", target->GetIconValue());
  441. target->SetIcon(val);
  442. break;
  443. }
  444. case SPAWN_SET_VALUE_PREFIX: {
  445. sprintf(tmp, "%s", target->GetPrefixTitle());
  446. target->SetPrefixTitle(value);
  447. client->GetCurrentZone()->SendUpdateTitles(target);
  448. break;
  449. }
  450. case SPAWN_SET_VALUE_SUFFIX: {
  451. sprintf(tmp, "%s", target->GetSuffixTitle());
  452. target->SetSuffixTitle(value);
  453. client->GetCurrentZone()->SendUpdateTitles(target);
  454. break;
  455. }
  456. case SPAWN_SET_VALUE_LASTNAME: {
  457. sprintf(tmp, "%s", target->GetLastName());
  458. target->SetLastName(value);
  459. client->GetCurrentZone()->SendUpdateTitles(target);
  460. break;
  461. }
  462. *temp_value = string(tmp);
  463. }
  464. }
  465. else{
  466. switch(type){
  467. case SPAWN_SET_VALUE_NAME:{
  468. target->SetName(value);
  469. client->GetCurrentZone()->SendUpdateTitles(target);
  470. break;
  471. }
  472. case SPAWN_SET_VALUE_SUB_TITLE: {
  473. target->SetSubTitle(value);
  474. client->GetCurrentZone()->SendUpdateTitles(target);
  475. break;
  476. }
  477. case SPAWN_SET_VALUE_X_OFFSET:
  478. {
  479. target->SetXOffset(atof(value));
  480. break;
  481. }
  482. case SPAWN_SET_VALUE_Y_OFFSET:
  483. {
  484. target->SetYOffset(atof(value));
  485. break;
  486. }
  487. case SPAWN_SET_VALUE_Z_OFFSET:
  488. {
  489. target->SetZOffset(atof(value));
  490. break;
  491. }
  492. case SPAWN_SET_VALUE_EXPIRE: {
  493. target->SetExpireTime(val);
  494. break;
  495. }
  496. case SPAWN_SET_VALUE_EXPIRE_OFFSET: {
  497. target->SetExpireOffsetTime(val);
  498. break;
  499. }
  500. case SPAWN_SET_VALUE_LEVEL:{
  501. target->SetLevel(val, send_update);
  502. break;
  503. }
  504. case SPAWN_SET_VALUE_DIFFICULTY:{
  505. target->SetEncounterLevel(val, send_update);
  506. break;
  507. }
  508. case SPAWN_SET_VALUE_MODEL_TYPE:{
  509. target->SetModelType(val, send_update);
  510. break;
  511. }
  512. case SPAWN_SET_VALUE_CLASS:{
  513. target->SetAdventureClass(val, send_update);
  514. break;
  515. }
  516. case SPAWN_SET_VALUE_GENDER:{
  517. target->SetGender(val, send_update);
  518. break;
  519. }
  520. case SPAWN_SET_VALUE_SHOW_NAME:{
  521. target->SetShowName(val, send_update);
  522. break;
  523. }
  524. case SPAWN_SET_VALUE_ATTACKABLE:{
  525. target->SetAttackable(val, send_update);
  526. break;
  527. }
  528. case SPAWN_SET_VALUE_SHOW_LEVEL:{
  529. target->SetShowLevel(val, send_update);
  530. break;
  531. }
  532. case SPAWN_SET_VALUE_TARGETABLE:{
  533. target->SetTargetable(val, send_update);
  534. break;
  535. }
  536. case SPAWN_SET_VALUE_SHOW_COMMAND_ICON:{
  537. target->SetShowCommandIcon(val, send_update);
  538. break;
  539. }
  540. case SPAWN_SET_VALUE_HAND_ICON:{
  541. target->SetShowHandIcon(val, send_update);
  542. break;
  543. }
  544. case SPAWN_SET_VALUE_HAIR_TYPE:{
  545. if(target->IsEntity())
  546. ((Entity*)target)->SetHairType(val, send_update);
  547. break;
  548. }
  549. case SPAWN_SET_VALUE_FACIAL_HAIR_TYPE:{
  550. if(target->IsEntity())
  551. ((Entity*)target)->SetHairType(val, send_update);
  552. break;
  553. }
  554. case SPAWN_SET_VALUE_WING_TYPE:{
  555. if(target->IsEntity())
  556. ((Entity*)target)->SetWingType(val, send_update);
  557. break;
  558. }
  559. case SPAWN_SET_VALUE_CHEST_TYPE:{
  560. if(target->IsEntity())
  561. ((Entity*)target)->SetChestType(val, send_update);
  562. break;
  563. }
  564. case SPAWN_SET_VALUE_LEGS_TYPE:{
  565. if(target->IsEntity())
  566. ((Entity*)target)->SetLegsType(val, send_update);
  567. break;
  568. }
  569. case SPAWN_SET_VALUE_SOGA_HAIR_TYPE:{
  570. if(target->IsEntity())
  571. ((Entity*)target)->SetSogaHairType(val, send_update);
  572. break;
  573. }
  574. case SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE:{
  575. if(target->IsEntity())
  576. ((Entity*)target)->SetSogaFacialHairType(val, send_update);
  577. break;
  578. }
  579. case SPAWN_SET_VALUE_SOGA_MODEL_TYPE:{
  580. target->SetSogaModelType(val, send_update);
  581. break;
  582. }
  583. case SPAWN_SET_VALUE_SIZE:{
  584. target->SetSize(val, send_update);
  585. break;
  586. }
  587. case SPAWN_SET_VALUE_HP:{
  588. target->SetHP(val, send_update);
  589. break;
  590. }
  591. case SPAWN_SET_VALUE_POWER:{
  592. target->SetPower(val, send_update);
  593. break;
  594. }
  595. case SPAWN_SET_VALUE_HEROIC:{
  596. target->SetHeroic(val, send_update);
  597. break;
  598. }
  599. case SPAWN_SET_VALUE_RESPAWN:{
  600. target->SetRespawnTime(val);
  601. break;
  602. }
  603. case SPAWN_SET_VALUE_X:{
  604. target->SetX(atof(value), send_update);
  605. target->SetSpawnOrigX(target->GetX());
  606. break;
  607. }
  608. case SPAWN_SET_VALUE_Y:{
  609. target->SetY(atof(value), send_update);
  610. target->SetSpawnOrigY(target->GetY());
  611. break;
  612. }
  613. case SPAWN_SET_VALUE_Z:{
  614. target->SetZ(atof(value), send_update);
  615. target->SetSpawnOrigZ(target->GetZ());
  616. break;
  617. }
  618. case SPAWN_SET_VALUE_HEADING:{
  619. target->SetHeading(atof(value), send_update);
  620. target->SetSpawnOrigHeading(target->GetHeading());
  621. break;
  622. }
  623. case SPAWN_SET_VALUE_COMMAND_PRIMARY:{
  624. ZoneServer* zone = target->GetZone();
  625. if (!zone)
  626. zone = client->GetCurrentZone();
  627. if(zone->GetEntityCommandList(val))
  628. target->SetPrimaryCommands(zone->GetEntityCommandList(val));
  629. target->primary_command_list_id = val;
  630. break;
  631. }
  632. case SPAWN_SET_VALUE_COMMAND_SECONDARY:{
  633. ZoneServer* zone = target->GetZone();
  634. if (!zone)
  635. zone = client->GetCurrentZone();
  636. if (zone->GetEntityCommandList(val))
  637. target->SetSecondaryCommands(zone->GetEntityCommandList(val));
  638. target->secondary_command_list_id = val;
  639. break;
  640. }
  641. case SPAWN_SET_VALUE_VISUAL_STATE:{
  642. target->SetVisualState(val, send_update);
  643. break;
  644. }
  645. case SPAWN_SET_VALUE_ACTION_STATE:{
  646. target->SetActionState(val, send_update);
  647. break;
  648. }
  649. case SPAWN_SET_VALUE_MOOD_STATE:{
  650. target->SetMoodState(val, send_update);
  651. break;
  652. }
  653. case SPAWN_SET_VALUE_INITIAL_STATE:{
  654. target->SetInitialState(val, send_update);
  655. break;
  656. }
  657. case SPAWN_SET_VALUE_ACTIVITY_STATE:{
  658. target->SetActivityStatus(val, send_update);
  659. break;
  660. }
  661. case SPAWN_SET_VALUE_COLLISION_RADIUS:{
  662. target->SetCollisionRadius(val, send_update);
  663. break;
  664. }
  665. case SPAWN_SET_VALUE_FACTION:{
  666. ZoneServer* zone = target->GetZone();
  667. if (!zone)
  668. zone = client->GetCurrentZone();
  669. target->faction_id = val;
  670. zone->RemoveDeadEnemyList(target);
  671. if(target->IsNPC())
  672. zone->AddEnemyList((NPC*)target);
  673. break;
  674. }
  675. case SPAWN_SET_VALUE_DEVICE_ID:{
  676. if (target->IsObject())
  677. ((Object*)target)->SetDeviceID(val);
  678. break;
  679. }
  680. case SPAWN_SET_VALUE_PITCH: {
  681. target->SetPitch(atof(value), send_update);
  682. target->SetSpawnOrigPitch(atof(value));
  683. break;
  684. }
  685. case SPAWN_SET_VALUE_ROLL: {
  686. target->SetRoll(atof(value), send_update);
  687. target->SetSpawnOrigRoll(atof(value));
  688. break;
  689. }
  690. case SPAWN_SET_VALUE_HIDE_HOOD: {
  691. target->SetHideHood(val);
  692. break;
  693. }
  694. case SPAWN_SET_VALUE_EMOTE_STATE: {
  695. target->SetEmoteState(val);
  696. break;
  697. }
  698. case SPAWN_SET_VALUE_ICON: {
  699. target->SetIcon(val);
  700. break;
  701. }
  702. case SPAWN_SET_VALUE_PREFIX: {
  703. target->SetPrefixTitle(value);
  704. client->GetCurrentZone()->SendUpdateTitles(target);
  705. break;
  706. }
  707. case SPAWN_SET_VALUE_SUFFIX: {
  708. target->SetSuffixTitle(value);
  709. client->GetCurrentZone()->SendUpdateTitles(target);
  710. break;
  711. }
  712. case SPAWN_SET_VALUE_LASTNAME: {
  713. target->SetLastName(value);
  714. client->GetCurrentZone()->SendUpdateTitles(target);
  715. break;
  716. }
  717. case SPAWN_SET_VALUE_SPAWN_SCRIPT:{
  718. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  719. if(client){
  720. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  721. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawn_script 'SpawnScripts/example.lua'");
  722. }
  723. return false;
  724. }
  725. else if(!database.UpdateSpawnScriptData(target->GetDatabaseID(), 0, 0, value))
  726. return false;
  727. else{
  728. if(!world.GetSpawnLocationScript(target->GetSpawnLocationID()))
  729. target->SetSpawnScript(value);
  730. }
  731. break;
  732. }
  733. case SPAWN_SET_VALUE_SPAWNLOCATION_SCRIPT:{
  734. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  735. if(client){
  736. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  737. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawnlocation_script 'SpawnScripts/example.lua'");
  738. }
  739. return false;
  740. }
  741. else if(!database.UpdateSpawnScriptData(0, target->GetSpawnLocationID(), 0, value))
  742. return false;
  743. else{
  744. if(!world.GetSpawnEntryScript(target->GetSpawnEntryID()))
  745. target->SetSpawnScript(value);
  746. }
  747. break;
  748. }
  749. case SPAWN_SET_VALUE_SPAWNENTRY_SCRIPT:{
  750. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  751. if(client){
  752. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  753. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawnentry_script 'SpawnScripts/example.lua'");
  754. }
  755. return false;
  756. }
  757. else if(!database.UpdateSpawnScriptData(0, 0, target->GetSpawnEntryID(), value))
  758. return false;
  759. else
  760. target->SetSpawnScript(value);
  761. break;
  762. }
  763. }
  764. }
  765. return true;
  766. }
  767. /* The zone object will be NULL if the zone is not currently running. We pass both of these in so we can update
  768. the database fields always and also update the zone in memory if it's running. */
  769. bool Commands::SetZoneCommand(Client* client, int32 zone_id, ZoneServer* zone, int8 type, const char* value) {
  770. if (client && zone_id > 0 && type > 0 && value) {
  771. sint32 int_value = 0;
  772. float float_value = 0;
  773. if (type == ZONE_SET_VALUE_SAFE_X || type == ZONE_SET_VALUE_SAFE_Y || type == ZONE_SET_VALUE_SAFE_Z || type == ZONE_SET_VALUE_UNDERWORLD) {
  774. try {
  775. float_value = atof(value);
  776. }
  777. catch (...) {
  778. client->Message(CHANNEL_COLOR_RED, "Error converting '%s' to a float value", value);
  779. return false;
  780. }
  781. }
  782. else if (type != ZONE_SET_VALUE_NAME && type != ZONE_SET_VALUE_FILE && type != ZONE_SET_VALUE_DESCRIPTION && type != ZONE_SET_VALUE_ZONE_TYPE && type != ZONE_SET_VALUE_LUA_SCRIPT && type != ZONE_SET_VALUE_ZONE_MOTD) {
  783. try {
  784. int_value = atoi(value);
  785. }
  786. catch (...) {
  787. client->Message(CHANNEL_COLOR_RED, "Error converting '%s' to an integer value", value);
  788. return false;
  789. }
  790. }
  791. switch (type) {
  792. case ZONE_SET_VALUE_EXPANSION_ID: {
  793. break;
  794. }
  795. case ZONE_SET_VALUE_NAME: {
  796. if (zone)
  797. zone->SetZoneName(const_cast<char*>(value));
  798. database.SaveZoneInfo(zone_id, "name", value);
  799. break;
  800. }
  801. case ZONE_SET_VALUE_FILE: {
  802. if (zone)
  803. zone->SetZoneFile(const_cast<char*>(value));
  804. database.SaveZoneInfo(zone_id, "file", value);
  805. break;
  806. }
  807. case ZONE_SET_VALUE_DESCRIPTION: {
  808. if (zone)
  809. zone->SetZoneDescription(const_cast<char*>(value));
  810. database.SaveZoneInfo(zone_id, "description", value);
  811. break;
  812. }
  813. case ZONE_SET_VALUE_SAFE_X: {
  814. if (zone)
  815. zone->SetSafeX(float_value);
  816. database.SaveZoneInfo(zone_id, "safe_x", float_value);
  817. break;
  818. }
  819. case ZONE_SET_VALUE_SAFE_Y: {
  820. if (zone)
  821. zone->SetSafeY(float_value);
  822. database.SaveZoneInfo(zone_id, "safe_y", float_value);
  823. break;
  824. }
  825. case ZONE_SET_VALUE_SAFE_Z: {
  826. if (zone)
  827. zone->SetSafeZ(float_value);
  828. database.SaveZoneInfo(zone_id, "safe_z", float_value);
  829. break;
  830. }
  831. case ZONE_SET_VALUE_UNDERWORLD: {
  832. if (zone)
  833. zone->SetUnderWorld(float_value);
  834. database.SaveZoneInfo(zone_id, "underworld", float_value);
  835. break;
  836. }
  837. case ZONE_SET_VALUE_MIN_RECOMMENDED: {
  838. break;
  839. }
  840. case ZONE_SET_VALUE_MAX_RECOMMENDED: {
  841. break;
  842. }
  843. case ZONE_SET_VALUE_ZONE_TYPE: {
  844. break;
  845. }
  846. case ZONE_SET_VALUE_ALWAYS_LOADED: {
  847. if (zone)
  848. zone->SetAlwaysLoaded(int_value == 1);
  849. database.SaveZoneInfo(zone_id, "always_loaded", int_value);
  850. break;
  851. }
  852. case ZONE_SET_VALUE_CITY_ZONE: {
  853. if (zone)
  854. zone->SetCityZone(int_value == 1);
  855. database.SaveZoneInfo(zone_id, "city_zone", int_value);
  856. break;
  857. }
  858. case ZONE_SET_VALUE_WEATHER_ALLOWED: {
  859. if (zone)
  860. zone->SetWeatherAllowed(int_value == 1);
  861. database.SaveZoneInfo(zone_id, "weather_allowed", int_value);
  862. break;
  863. }
  864. case ZONE_SET_VALUE_MIN_STATUS: {
  865. if (zone)
  866. zone->SetMinimumStatus(int_value);
  867. database.SaveZoneInfo(zone_id, "min_status", int_value);
  868. break;
  869. }
  870. case ZONE_SET_VALUE_MIN_LEVEL: {
  871. if (zone)
  872. zone->SetMinimumLevel(int_value);
  873. database.SaveZoneInfo(zone_id, "min_level", int_value);
  874. break;
  875. }
  876. case ZONE_SET_VALUE_MAX_LEVEL: {
  877. if (zone)
  878. zone->SetMaximumLevel(int_value);
  879. database.SaveZoneInfo(zone_id, "max_level", int_value);
  880. break;
  881. }
  882. case ZONE_SET_VALUE_START_ZONE: {
  883. database.SaveZoneInfo(zone_id, "start_zone", int_value);
  884. break;
  885. }
  886. case ZONE_SET_VALUE_INSTANCE_TYPE: {
  887. if (zone)
  888. zone->SetInstanceType(int_value);
  889. database.SaveZoneInfo(zone_id, "instance_type", int_value);
  890. break;
  891. }
  892. case ZONE_SET_VALUE_DEFAULT_REENTER_TIME: {
  893. if (zone)
  894. zone->SetDefaultReenterTime(int_value);
  895. database.SaveZoneInfo(zone_id, "default_reenter_time", int_value);
  896. break;
  897. }
  898. case ZONE_SET_VALUE_DEFAULT_RESET_TIME: {
  899. if (zone)
  900. zone->SetDefaultResetTime(int_value);
  901. database.SaveZoneInfo(zone_id, "default_reset_time", int_value);
  902. break;
  903. }
  904. case ZONE_SET_VALUE_DEFAULT_LOCKOUT_TIME: {
  905. if (zone)
  906. zone->SetDefaultLockoutTime(int_value);
  907. database.SaveZoneInfo(zone_id, "default_lockout_time", int_value);
  908. break;
  909. }
  910. case ZONE_SET_VALUE_FORCE_GROUP_TO_ZONE: {
  911. if (zone)
  912. zone->SetForceGroupZoneOption(int_value);
  913. database.SaveZoneInfo(zone_id, "force_group_to_zone", int_value);
  914. break;
  915. }
  916. case ZONE_SET_VALUE_LUA_SCRIPT: {
  917. if (lua_interface && lua_interface->GetZoneScript(value) == 0) {
  918. client->Message(CHANNEL_COLOR_RED, "Invalid Zone Script file. Be sure you give the absolute path.");
  919. client->Message(CHANNEL_COLOR_RED, "Example: /zone set lua_script 'ZoneScripts/QueensColony.lua'");
  920. return false;
  921. }
  922. else {
  923. world.AddZoneScript(zone_id, const_cast<char*>(value));
  924. database.SaveZoneInfo(zone_id, "lua_script", value);
  925. }
  926. break;
  927. }
  928. case ZONE_SET_VALUE_SHUTDOWN_TIMER: {
  929. if (zone)
  930. zone->SetShutdownTimer(int_value);
  931. database.SaveZoneInfo(zone_id, "shutdown_timer", int_value);
  932. break;
  933. }
  934. case ZONE_SET_VALUE_ZONE_MOTD: {
  935. if (zone)
  936. zone->SetZoneMOTD(string(value));
  937. database.SaveZoneInfo(zone_id, "zone_motd", value);
  938. break;
  939. }
  940. default: {
  941. client->Message(CHANNEL_COLOR_RED, "Invalid zone attribute %i", type);
  942. return false;
  943. }
  944. }
  945. }
  946. else {
  947. if (client)
  948. client->SimpleMessage(CHANNEL_COLOR_RED, "An error occured saving new zone data.");
  949. return false;
  950. }
  951. return true;
  952. }
  953. void Commands::Process(int32 index, EQ2_16BitString* command_parms, Client* client, Spawn* targetOverride) {
  954. if (index >= remote_commands->commands.size()) {
  955. LogWrite(COMMAND__ERROR, 0, "Command", "Error, command handler of %u was requested, but max handler is %u", index, remote_commands->commands.size());
  956. return;
  957. }
  958. Spawn* cmdTarget = targetOverride ? targetOverride : client->GetPlayer()->GetTarget();
  959. EQ2_RemoteCommandString* parent_command = 0;
  960. EQ2_RemoteCommandString* command = &remote_commands->commands[index];
  961. Seperator* sep = 0;
  962. if (command_parms->size > 0) {
  963. sep = new Seperator(command_parms->data.c_str(), ' ', 10, 500, true);
  964. if (sep && sep->arg[0] && remote_commands->validSubCommand(command->command.data, string(sep->arg[0]))) {
  965. parent_command = command;
  966. command = &(remote_commands->subcommands[command->command.data][string(sep->arg[0])]);
  967. safe_delete(sep);
  968. if (command_parms->data.length() > (command->command.data.length() + 1))
  969. sep = new Seperator(command_parms->data.c_str() + (command->command.data.length() + 1), ' ', 10, 500, true);
  970. LogWrite(COMMAND__DEBUG, 1, "Command", "Handler: %u, COMMAND: '%s', SUBCOMMAND: '%s'", index, parent_command->command.data.c_str(), command->command.data.c_str());
  971. }
  972. else
  973. LogWrite(COMMAND__DEBUG, 1, "Command", "Handler: %u, COMMAND: '%s'", index, command->command.data.c_str());
  974. }
  975. int ndx = 0;
  976. if (command->required_status > client->GetAdminStatus())
  977. {
  978. LogWrite(COMMAND__ERROR, 0, "Command", "Player '%s' (%u) needs status %i to use command: %s", client->GetPlayer()->GetName(), client->GetAccountID(), command->required_status, command->command.data.c_str());
  979. safe_delete(sep);
  980. client->SimpleMessage(3, "Error: Your status is insufficient for this command.");
  981. return;
  982. }
  983. Player* player = client->GetPlayer();
  984. LogWrite(COMMAND__DEBUG, 0, "Command", "Player '%s' (%u), Command: %s", player->GetName(), client->GetAccountID(), command->command.data.c_str());
  985. switch (command->handler) {
  986. case COMMAND_RELOAD: {
  987. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reload commands:");
  988. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload structs");
  989. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload items");
  990. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload luasystem");
  991. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spawnscripts");
  992. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spells");
  993. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload quests");
  994. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spawns");
  995. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload groundspawns");
  996. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload zonescripts");
  997. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload entity_commands");
  998. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload factions");
  999. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload mail");
  1000. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload guilds");
  1001. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload locations");
  1002. break;
  1003. }
  1004. case COMMAND_RELOADSTRUCTS: {
  1005. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Structs...");
  1006. configReader.ReloadStructs();
  1007. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1008. break;
  1009. }
  1010. case COMMAND_RELOAD_QUESTS: {
  1011. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Quests...");
  1012. master_quest_list.Reload();
  1013. client_list.ReloadQuests();
  1014. zone_list.ReloadClientQuests();
  1015. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1016. break;
  1017. }
  1018. case COMMAND_RELOAD_SPAWNS: {
  1019. client->GetCurrentZone()->ReloadSpawns();
  1020. break;
  1021. }
  1022. case COMMAND_RELOAD_SPELLS: {
  1023. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spells...");
  1024. zone_list.DeleteSpellProcess();
  1025. master_spell_list.Reload();
  1026. if (lua_interface)
  1027. lua_interface->ReloadSpells();
  1028. zone_list.LoadSpellProcess();
  1029. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1030. break;
  1031. }
  1032. case COMMAND_RELOAD_GROUNDSPAWNS: {
  1033. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Groundspawn Entries...");
  1034. client->GetCurrentZone()->DeleteGroundSpawnItems();
  1035. client->GetCurrentZone()->LoadGroundSpawnEntries();
  1036. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1037. break;
  1038. }
  1039. case COMMAND_RELOAD_ZONESCRIPTS: {
  1040. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Zone Scripts...");
  1041. world.ResetZoneScripts();
  1042. database.LoadZoneScriptData();
  1043. if (lua_interface)
  1044. lua_interface->DestroyZoneScripts();
  1045. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1046. break;
  1047. }
  1048. case COMMAND_RELOAD_ENTITYCOMMANDS: {
  1049. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Entity Commands...");
  1050. client->GetCurrentZone()->ClearEntityCommands();
  1051. database.LoadEntityCommands(client->GetCurrentZone());
  1052. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1053. break;
  1054. }
  1055. case COMMAND_RELOAD_FACTIONS: {
  1056. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Factions...");
  1057. master_faction_list.Clear();
  1058. database.LoadFactionList();
  1059. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1060. break;
  1061. }
  1062. case COMMAND_RELOAD_MAIL: {
  1063. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Mail...");
  1064. zone_list.ReloadMail();
  1065. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1066. break;
  1067. }
  1068. case COMMAND_RELOAD_GUILDS: {
  1069. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Guilds...");
  1070. world.ReloadGuilds();
  1071. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1072. break;
  1073. }
  1074. case COMMAND_RELOAD_LOCATIONS: {
  1075. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Locations...");
  1076. client->GetPlayer()->GetZone()->RemoveLocationGrids();
  1077. database.LoadLocationGrids(client->GetPlayer()->GetZone());
  1078. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1079. break;
  1080. }
  1081. case COMMAND_READ: {
  1082. if (sep && sep->arg[1][0] && sep->IsNumber(1)) {
  1083. if (strcmp(sep->arg[0], "read") == 0) {
  1084. int32 item_index = atol(sep->arg[1]);
  1085. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  1086. if (item) {
  1087. Spawn* spawn = cmdTarget;
  1088. int8 numpages = item->book_pages.size();
  1089. string page1 = string(item->book_pages[0]->page_text.data);
  1090. PacketStruct* packet = configReader.getStruct("WS_EqShowBook", client->GetVersion());
  1091. string title = item->name;
  1092. if (packet) {
  1093. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  1094. packet->setDataByName("book_title", title.c_str());
  1095. packet->setDataByName("book_type", "simple");
  1096. packet->setDataByName("unknown2", 1);
  1097. packet->setDataByName("unknown5", 1, 4);
  1098. packet->setArrayLengthByName("num_pages", numpages);
  1099. for (int8 pages = 1; pages <= numpages; pages++) {
  1100. int8 pagenum = int8(item->book_pages[pages - 1]->page);
  1101. string page = string(item->book_pages[pages-1]->page_text.data);
  1102. int8 valign = int8(item->book_pages[pages - 1]->valign);
  1103. int8 halign = int8(item->book_pages[pages - 1]->halign);
  1104. packet->setArrayDataByName("page_text", page.c_str(), pagenum -1);
  1105. packet->setArrayDataByName("page_text_valign", valign , pagenum - 1);
  1106. packet->setArrayDataByName("page_text_halign", halign, pagenum - 1);
  1107. // Need to add support for images
  1108. }
  1109. client->QueuePacket(packet->serialize());
  1110. safe_delete(packet);
  1111. }
  1112. break;
  1113. }
  1114. }
  1115. }
  1116. }
  1117. case COMMAND_USEABILITY:{
  1118. if (sep && sep->arg[0][0] && sep->IsNumber(0)) {
  1119. if (client->GetPlayer()->GetHP() == 0) {
  1120. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot do that right now.");
  1121. }
  1122. else {
  1123. int32 spell_id = atoul(sep->arg[0]);
  1124. int8 spell_tier = 0;
  1125. if (sep->arg[1][0] && sep->IsNumber(1))
  1126. spell_tier = atoi(sep->arg[1]);
  1127. else
  1128. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  1129. if (!spell_tier)
  1130. spell_tier = 1;
  1131. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  1132. if (spell) {
  1133. if (strncmp(spell->GetName(), "Gathering", 9) == 0 || strncmp(spell->GetName(), "Mining", 6) == 0 || strncmp(spell->GetName(), "Trapping", 8) == 0 || strncmp(spell->GetName(), "Foresting", 9) == 0 || strncmp(spell->GetName(), "Fishing", 7) == 0 || strncmp(spell->GetName(), "Collecting", 10) == 0)
  1134. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), cmdTarget, true, true);
  1135. else
  1136. {
  1137. if (cmdTarget)
  1138. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), cmdTarget);
  1139. else
  1140. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  1141. }
  1142. }
  1143. }
  1144. }
  1145. else if (cmdTarget && cmdTarget->IsWidget())
  1146. {
  1147. Widget* widget = (Widget*)cmdTarget;
  1148. widget->HandleUse(client, "use", WIDGET_TYPE_DOOR);
  1149. }
  1150. else
  1151. {
  1152. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /useability {spell_id} [spell_tier]");
  1153. }
  1154. break;
  1155. }
  1156. case COMMAND_INFO:{
  1157. if(sep && sep->arg[1][0] && sep->IsNumber(1)){
  1158. if(strcmp(sep->arg[0], "inventory") == 0){
  1159. int32 item_index = atol(sep->arg[1]);
  1160. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  1161. if(item){
  1162. if (item->IsCollectable() && client->SendCollectionsForItem(item))
  1163. break;
  1164. EQ2Packet* app = item->serialize(client->GetVersion(), (!item->GetItemScript() || !lua_interface), client->GetPlayer());
  1165. //DumpPacket(app);
  1166. client->QueuePacket(app);
  1167. if(item->GetItemScript() && lua_interface)
  1168. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  1169. else if(item->generic_info.offers_quest_id > 0){ //leave the current functionality in place if it doesnt have an item script
  1170. Quest* quest = master_quest_list.GetQuest(item->generic_info.offers_quest_id);
  1171. if(quest && client->GetPlayer()->GetCompletedQuest(item->generic_info.offers_quest_id) == 0 && client->GetPlayer()->GetQuest(item->generic_info.offers_quest_id) == 0)
  1172. client->AddPendingQuest(quest);
  1173. }
  1174. }
  1175. else
  1176. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Index: %u", item_index);
  1177. }
  1178. else if(strcmp(sep->arg[0], "equipment") == 0){
  1179. int32 item_index = atol(sep->arg[1]);
  1180. Item* item = client->GetPlayer()->GetEquipmentList()->GetItem(item_index);
  1181. if(item){
  1182. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1183. client->QueuePacket(app);
  1184. if(item->GetItemScript() && lua_interface)
  1185. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  1186. }
  1187. else
  1188. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Index: %u", item_index);
  1189. }
  1190. else if(strcmp(sep->arg[0], "item") == 0 || strcmp(sep->arg[0], "merchant") == 0 || strcmp(sep->arg[0], "store") == 0 || strcmp(sep->arg[0], "buyback") == 0 || strcmp(sep->arg[0], "consignment") == 0){
  1191. int32 item_id = atoul(sep->arg[1]);
  1192. Item* item = master_item_list.GetItem(item_id);
  1193. if(item){
  1194. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1195. client->QueuePacket(app);
  1196. }
  1197. else
  1198. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Item ID: %u", item_id);
  1199. }
  1200. else if (strcmp(sep->arg[0], "spell") == 0) {
  1201. sint32 spell_id = atol(sep->arg[1]);
  1202. int8 tier = atoi(sep->arg[3]);
  1203. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, tier, client, true, 0x2A);
  1204. if (outapp)
  1205. client->QueuePacket(outapp);
  1206. else
  1207. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  1208. }
  1209. else if (strcmp(sep->arg[0], "achievement") == 0) {
  1210. sint32 spell_id = atol(sep->arg[2]);
  1211. int8 group = atoi(sep->arg[1]);
  1212. AltAdvanceData* data = 0;
  1213. SpellBookEntry* spellentry = 0;
  1214. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  1215. LogWrite(COMMAND__ERROR, 0, "Command", "AA Spell ID and/or Tier, ID: %u, Group: %i", spell_id, group);
  1216. EQ2Packet* outapp = master_spell_list.GetAASpellPacket(spell_id, tier, client, true, 0x45);
  1217. if (outapp)
  1218. client->QueuePacket(outapp);
  1219. else
  1220. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, group);
  1221. }
  1222. else if (strcmp(sep->arg[0], "spellbook") == 0) {
  1223. sint32 spell_id = atol(sep->arg[1]);
  1224. int8 tier = atoi(sep->arg[2]);
  1225. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, tier, client, true, 0x2A);
  1226. if (outapp)
  1227. client->QueuePacket(outapp);
  1228. else
  1229. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  1230. }
  1231. else if (strcmp(sep->arg[0], "recipe") == 0) {
  1232. sint32 recipe_id = atol(sep->arg[1]);
  1233. EQ2Packet* outapp = master_recipe_list.GetRecipePacket(recipe_id, client, true, 0x2C);
  1234. if(outapp)
  1235. client->QueuePacket(outapp);
  1236. else
  1237. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Recipe ID: %u", recipe_id);
  1238. }
  1239. else if (strcmp(sep->arg[0], "maintained") ==0) {
  1240. int32 slot = atol(sep->arg[1]);
  1241. int32 spell_id = atol(sep->arg[2]);
  1242. LogWrite(COMMAND__DEBUG, 5, "Command", "Unknown Spell ID - Slot: %u unknown: %u", slot, spell_id);
  1243. //int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  1244. MaintainedEffects* info = client->GetPlayer()->GetMaintainedSpellBySlot(slot);
  1245. EQ2Packet* outapp = master_spell_list.GetSpellPacket(info->spell_id, info->tier, client, true, 0x00);
  1246. if(outapp)
  1247. client->QueuePacket(outapp);
  1248. else
  1249. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID: %u", spell_id);
  1250. }
  1251. else if (strcmp(sep->arg[0], "effect") == 0) {
  1252. int32 spell_id = atol(sep->arg[1]);
  1253. LogWrite(COMMAND__DEBUG, 5, "Command", "Unknown Spell ID: %u", spell_id);
  1254. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  1255. EQ2Packet* outapp = master_spell_list.GetSpecialSpellPacket(spell_id, tier, client, true, 0x00);
  1256. if (outapp){
  1257. client->QueuePacket(outapp);
  1258. }
  1259. else
  1260. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID: %u", spell_id);
  1261. }
  1262. }
  1263. else if (sep && strcmp(sep->arg[0], "overflow") == 0) {
  1264. Item* item = player->item_list.GetOverflowItem();
  1265. if(item) {
  1266. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1267. client->QueuePacket(app);
  1268. }
  1269. else
  1270. LogWrite(COMMAND__ERROR, 0,"Command", "Unable to retrieve an overflow item.");
  1271. }
  1272. else
  1273. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /info {inventory|equipment|spell} {id}");
  1274. break;
  1275. }
  1276. case COMMAND_USE_EQUIPPED_ITEM:{
  1277. if (sep && sep->arg[0] && sep->IsNumber(0)){
  1278. int32 slot_id = atoul(sep->arg[0]);
  1279. Item* item = player->GetEquipmentList()->GetItem(slot_id);
  1280. if (item && item->generic_info.usable && item->GetItemScript())
  1281. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player);
  1282. }
  1283. break;
  1284. }
  1285. case COMMAND_USE_ITEM: {
  1286. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  1287. int32 item_index = atoul(sep->arg[0]);
  1288. Item* item = player->item_list.GetItemFromIndex(item_index);
  1289. if (item && item->GetItemScript()) {
  1290. if (item->generic_info.max_charges == 0 || item->generic_info.max_charges == 0xFFFF)
  1291. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player);
  1292. else {
  1293. if (item->generic_info.display_charges > 0) {
  1294. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player);
  1295. item->generic_info.display_charges -= 1;
  1296. item->save_needed = true;
  1297. client->QueuePacket(item->serialize(client->GetVersion(), false, client->GetPlayer()));
  1298. }
  1299. }
  1300. }
  1301. }
  1302. break;
  1303. }
  1304. case COMMAND_SCRIBE_SCROLL_ITEM: {
  1305. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  1306. Item* item = player->item_list.GetItemFromUniqueID(atoul(sep->arg[0]));
  1307. if (item) {
  1308. LogWrite(ITEM__DEBUG, 0, "Items", "ITEM ID: %u", item->details.item_id);
  1309. if(item->generic_info.item_type == 6) {
  1310. Spell* spell = master_spell_list.GetSpell(item->skill_info->spell_id, item->skill_info->spell_tier);
  1311. int8 old_slot = 0;
  1312. if (spell) {
  1313. if (!player->HasSpell(spell->GetSpellID(), spell->GetSpellTier(), true)) {
  1314. old_slot = player->GetSpellSlot(spell->GetSpellID());
  1315. player->RemoveSpellBookEntry(spell->GetSpellID());
  1316. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  1317. player->UnlockSpell(spell);
  1318. client->SendSpellUpdate(spell);
  1319. database.DeleteItem(client->GetCharacterID(), item, 0);
  1320. player->item_list.RemoveItem(item, true);
  1321. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  1322. client->QueuePacket(player->SendInventoryUpdate(client->GetVersion()));
  1323. }
  1324. }
  1325. else
  1326. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown spell ID: %u and tier: %u", item->skill_info->spell_id, item->skill_info->spell_tier);
  1327. }
  1328. else if(item->generic_info.item_type == 7){
  1329. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Scribing recipe book %s (%u) for player %s.", item->name.c_str(), item->details.item_id, player->GetName());
  1330. Recipe* recipe_book = new Recipe(master_recipebook_list.GetRecipeBooks(item->details.item_id));
  1331. // if valid recipe book and the player doesn't have it
  1332. if (recipe_book && recipe_book->GetLevel() > client->GetPlayer()->GetTSLevel()) {
  1333. client->Message(CHANNEL_COLOR_WHITE, "Your tradeskill level is not high enough to scribe this book.");
  1334. safe_delete(recipe_book);
  1335. }
  1336. else if (recipe_book && !(client->GetPlayer()->GetRecipeBookList()->HasRecipeBook(item->details.item_id))) {
  1337. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Valid recipe book that the player doesn't have");
  1338. // Add recipe book to the players list
  1339. client->GetPlayer()->GetRecipeBookList()->AddRecipeBook(recipe_book);
  1340. // Get a list of all recipes this book contains
  1341. vector<Recipe*>* book_recipes = master_recipe_list.GetRecipes(recipe_book->GetBookName());
  1342. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "%i recipes found for %s book", book_recipes->size(), recipe_book->GetBookName());
  1343. // Create the packet to send to update the players recipe list
  1344. PacketStruct* packet = 0;
  1345. if (client->GetRecipeListSent()) {
  1346. packet = configReader.getStruct("WS_RecipeList", client->GetVersion());
  1347. if (packet)
  1348. packet->setArrayLengthByName("num_recipes", book_recipes->size());
  1349. }
  1350. // loop through the list
  1351. vector<Recipe*>::iterator itr;
  1352. int16 i = 0;
  1353. for (itr = book_recipes->begin(); itr != book_recipes->end(); itr++) {
  1354. // check to see if the player already has this recipe some how
  1355. if (!client->GetPlayer()->GetRecipeList()->GetRecipe((*itr)->GetID())) {
  1356. // Player doesn't already have this recipe so lets add it
  1357. Recipe* recipe = new Recipe(master_recipe_list.GetRecipe((*itr)->GetID()));
  1358. client->GetPlayer()->GetRecipeList()->AddRecipe(recipe);
  1359. database.SavePlayerRecipe(client->GetPlayer(), recipe->GetID());
  1360. client->Message(CHANNEL_COLOR_WHITE, "Recipe: \"%s\" put in recipe book.", recipe->GetName());
  1361. if (packet && client->GetRecipeListSent()) {
  1362. packet->setArrayDataByName("id", recipe->GetID(), i);
  1363. packet->setArrayDataByName("tier", recipe->GetTier(), i);
  1364. packet->setArrayDataByName("level", recipe->GetLevel(), i);
  1365. packet->setArrayDataByName("icon", recipe->GetIcon(), i);
  1366. packet->setArrayDataByName("classes", recipe->GetClasses(), i);
  1367. packet->setArrayDataByName("skill", recipe->GetSkill(), i);
  1368. packet->setArrayDataByName("technique", recipe->GetTechnique(), i);
  1369. packet->setArrayDataByName("knowledge", recipe->GetKnowledge(), i);
  1370. packet->setArrayDataByName("unknown2", recipe->GetUnknown2(), i);
  1371. packet->setArrayDataByName("recipe_name", recipe->GetName(), i);
  1372. packet->setArrayDataByName("recipe_book", recipe->GetBook(), i);
  1373. packet->setArrayDataByName("unknown3", recipe->GetUnknown3(), i);
  1374. i++;
  1375. }
  1376. }
  1377. }
  1378. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Done adding recipes");
  1379. database.SavePlayerRecipeBook(client->GetPlayer(), recipe_book->GetBookID());
  1380. database.DeleteItem(client->GetCharacterID(), item, 0);
  1381. client->GetPlayer()->item_list.RemoveItem(item, true);
  1382. client->QueuePacket(client->GetPlayer()->SendInventoryUpdate(client->GetVersion()));
  1383. if (packet && client->GetRecipeListSent())
  1384. client->QueuePacket(packet->serialize());
  1385. safe_delete(packet);
  1386. }
  1387. else {
  1388. if (recipe_book)
  1389. client->Message(CHANNEL_COLOR_WHITE, "You have already learned all you can from this item.");
  1390. safe_delete(recipe_book);
  1391. }
  1392. }
  1393. }
  1394. else
  1395. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown unique item ID: %s", sep->arg[0]);
  1396. }
  1397. break;
  1398. }
  1399. case COMMAND_SUMMONITEM: {
  1400. if (sep && sep->IsNumber(0)) {
  1401. int32 item_id = atol(sep->arg[0]);
  1402. int32 quantity = 1;
  1403. if (sep->arg[1] && sep->IsNumber(1))
  1404. quantity = atoi(sep->arg[1]);
  1405. if (sep->arg[2] && strncasecmp(sep->arg[2], "bank", 4) == 0) {
  1406. client->AddItemToBank(item_id,quantity);
  1407. }
  1408. else {
  1409. client->AddItem(item_id, quantity);
  1410. }
  1411. }
  1412. else {
  1413. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} [quantity] or");
  1414. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} {quantity} [location] where location = bank");
  1415. }
  1416. break;
  1417. }
  1418. case COMMAND_COLLECTION_ADDITEM: {
  1419. // takes 2 params: collection_id, slot
  1420. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  1421. Item *item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(atoul(sep->arg[1]));
  1422. if (item)
  1423. client->HandleCollectionAddItem(atoul(sep->arg[0]), item);
  1424. else
  1425. LogWrite(COLLECTION__ERROR, 0, "Collect", "Error in 'COMMAND_COLLECTION_ADDITEM'. Unable to get item from player '%s' at index %u", client->GetPlayer()->GetName(), atoul(sep->arg[0]));
  1426. }
  1427. else
  1428. LogWrite(COLLECTION__ERROR, 0, "Collect", "Received command 'COMMAND_COLLECTION_ADDITEM' with unhandeled argument types");
  1429. break;
  1430. }
  1431. case COMMAND_COLLECTION_FILTER_MATCHITEM: {
  1432. // takes 1 param: slot
  1433. printf("COMMAND_COLLECTION_FILTER_MATCHITEM:\n");
  1434. int i = 0;
  1435. while (sep->arg[i] && strlen(sep->arg[i]) > 0) {
  1436. printf("\t%u: %s\n", i, sep->arg[i]);
  1437. i++;
  1438. }
  1439. break;
  1440. }
  1441. case COMMAND_WHO:{
  1442. const char* who = 0;
  1443. if(sep && sep->arg[0]){
  1444. //cout << "Who query: \n";
  1445. who = sep->argplus[0];
  1446. //cout << who << endl;
  1447. }
  1448. zone_list.ProcessWhoQuery(who, client);
  1449. break;
  1450. }
  1451. case COMMAND_SELECT_JUNCTION:{
  1452. LogWrite(MISC__TODO, 1, "TODO", "For access/travel selections (i.e. Mariner Bells, Player Death Window, etc.)\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1453. int32 choice = 0;
  1454. if(sep && sep->arg[0] && sep->IsNumber(0))
  1455. choice = atoul(sep->arg[0]);
  1456. if(client->GetPlayer()->GetHP() == 0){ //dead and this is a revive request
  1457. client->HandlePlayerRevive(choice);
  1458. }
  1459. break;
  1460. }
  1461. case COMMAND_SPAWN_MOVE:{
  1462. if(cmdTarget && cmdTarget->IsPlayer() == false){
  1463. PacketStruct* packet = configReader.getStruct("WS_MoveObjectMode", client->GetVersion());
  1464. if(packet){
  1465. float unknown2_3 = 0;
  1466. int8 placement_mode = 0;
  1467. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::DEFAULT);
  1468. if(sep && sep->arg[0][0]){
  1469. if(strcmp(sep->arg[0], "wall") == 0){
  1470. placement_mode = 2;
  1471. unknown2_3 = 150;
  1472. }
  1473. else if (strcmp(sep->arg[0], "ceiling") == 0)
  1474. placement_mode = 1;
  1475. else if (strcmp(sep->arg[0], "openheading") == 0 && cmdTarget->IsWidget())
  1476. {
  1477. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "[PlacementMode] WIDGET OPEN HEADING MODE");
  1478. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::OPEN_HEADING);
  1479. }
  1480. else if (strcmp(sep->arg[0], "closeheading") == 0 && cmdTarget->IsWidget())
  1481. {
  1482. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "[PlacementMode] WIDGET CLOSE HEADING MODE");
  1483. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::CLOSE_HEADING);
  1484. }
  1485. }
  1486. packet->setDataByName("placement_mode", placement_mode);
  1487. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget));
  1488. packet->setDataByName("model_type", cmdTarget->GetModelType());
  1489. packet->setDataByName("unknown", 1); //size
  1490. packet->setDataByName("unknown2", 1); //size 2
  1491. packet->setDataByName("unknown2", .5, 1); //size 3
  1492. packet->setDataByName("unknown2", 3, 2);
  1493. packet->setDataByName("unknown2", unknown2_3, 3);
  1494. packet->setDataByName("max_distance", 500);
  1495. packet->setDataByName("CoEunknown", 0xFFFFFFFF);
  1496. client->QueuePacket(packet->serialize());
  1497. safe_delete(packet);
  1498. }
  1499. }
  1500. else{
  1501. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /spawn move (wall OR ceiling)");
  1502. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Moves a spawn anywhere you like. Optionally wall/ceiling can be provided to place wall/ceiling items.");
  1503. }
  1504. break;
  1505. }
  1506. case COMMAND_HAIL:{
  1507. Spawn* spawn = cmdTarget;
  1508. if(spawn && spawn->GetTargetable())
  1509. {
  1510. char tmp[75] = {0};
  1511. sprintf(tmp, "Hail, %s", spawn->GetName());
  1512. bool show_bubble = true;
  1513. if (spawn->IsNPC())
  1514. show_bubble = false;
  1515. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp, HEAR_SPAWN_DISTANCE, 0, show_bubble);
  1516. if(spawn->IsPlayer() == false && spawn->GetDistance(client->GetPlayer()) < 30){
  1517. if(spawn->IsNPC() && ((NPC*)spawn)->EngagedInCombat())
  1518. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED_BUSY, client->GetPlayer());
  1519. else
  1520. spawn->ProcessMovement();
  1521. LogWrite(MISC__TODO, 0, "Check", "ProcessMovement has been called");
  1522. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED, client->GetPlayer());
  1523. }
  1524. }
  1525. else {
  1526. string tmp = "Hail";
  1527. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp.c_str(), HEAR_SPAWN_DISTANCE, 0, true);
  1528. }
  1529. break;
  1530. }
  1531. case COMMAND_SAY:{
  1532. if (sep && sep->arg[0][0]) {
  1533. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, sep->argplus[0], HEAR_SPAWN_DISTANCE);
  1534. if (cmdTarget && !(cmdTarget->IsPlayer()))
  1535. client->GetCurrentZone()->CallSpawnScript(cmdTarget, SPAWN_SCRIPT_HEAR_SAY, client->GetPlayer(), sep->argplus[0]);
  1536. }
  1537. else
  1538. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /say {message}");
  1539. break;
  1540. }
  1541. case COMMAND_TELL:{
  1542. if(sep && sep->arg[0] && sep->argplus[1]){
  1543. if(!zone_list.HandleGlobalChatMessage(client, sep->arg[0], CHANNEL_TELL, sep->argplus[1]))
  1544. client->Message(CHANNEL_COLOR_RED,"Unable to find client %s",sep->arg[0]);
  1545. }else
  1546. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /tell {character_name} {message}");
  1547. break;
  1548. }
  1549. case COMMAND_SHOUT:{
  1550. if(sep && sep->arg[0][0])
  1551. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SHOUT, sep->argplus[0]);
  1552. else
  1553. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /shout {message}");
  1554. break;
  1555. }
  1556. case COMMAND_AUCTION:{
  1557. if(sep && sep->arg[0][0])
  1558. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_AUCTION, sep->argplus[0]);
  1559. else
  1560. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /auction {message}");
  1561. break;
  1562. }
  1563. case COMMAND_OOC:{
  1564. //For now ooc will be the global chat channel, eventually when we create more channels we will create a global chat channel
  1565. if(sep && sep->arg[0][0])
  1566. zone_list.HandleGlobalChatMessage(client, 0, CHANNEL_OOC, sep->argplus[0]);
  1567. else
  1568. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /ooc {message}");
  1569. break;
  1570. }
  1571. case COMMAND_EMOTE:{
  1572. if(sep && sep->arg[0][0])
  1573. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_EMOTE, sep->argplus[0]);
  1574. else
  1575. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /emote {action}");
  1576. break;
  1577. }
  1578. case COMMAND_RACE:{
  1579. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  1580. if(sep->arg[1][0] && sep->IsNumber(1)){
  1581. client->GetPlayer()->GetInfoStruct()->race = atoi(sep->arg[1]);
  1582. client->GetPlayer()->SetRace(atoi(sep->arg[1]));
  1583. client->UpdateTimeStampFlag ( RACE_UPDATE_FLAG );
  1584. client->GetPlayer()->SetCharSheetChanged(true);
  1585. }
  1586. client->GetPlayer()->SetModelType(atoi(sep->arg[0]));
  1587. //EQ2Packet* outapp = client->GetPlayer()->spawn_update_packet(client->GetPlayer(), client->GetVersion(), client->GetPlayer()->GetFeatures());
  1588. //client->QueuePacket(outapp);
  1589. }
  1590. else{
  1591. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /race {race type id} {race id}");
  1592. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "{race id} is optional");
  1593. }
  1594. break;
  1595. }
  1596. case COMMAND_BANK_DEPOSIT:{
  1597. if(client->GetBanker() && sep && sep->arg[0]){
  1598. int64 amount = 0;
  1599. string deposit = string(sep->arg[0]);
  1600. amount = atoi64(deposit.c_str());
  1601. client->BankDeposit(amount);
  1602. }
  1603. break;
  1604. }
  1605. case COMMAND_BANK_WITHDRAWAL:{
  1606. if(client->GetBanker() && sep && sep->arg[0] && sep->IsNumber(0)){
  1607. int64 amount = 0;
  1608. string deposit = string(sep->arg[0]);
  1609. amount = atoi64(deposit.c_str());
  1610. client->BankWithdrawal(amount);
  1611. }
  1612. break;
  1613. }
  1614. case COMMAND_BANK_CANCEL:{
  1615. Spawn* banker = cmdTarget;
  1616. client->Bank(banker, true);
  1617. break;
  1618. }
  1619. case COMMAND_BANK:{
  1620. LogWrite(PLAYER__DEBUG, 0, "Players", "Open Player Personal Bank...");
  1621. Spawn* banker = cmdTarget;
  1622. client->Bank(banker);
  1623. break;
  1624. }
  1625. case COMMAND_GUILD_BANK:{
  1626. LogWrite(GUILD__DEBUG, 0, "Guilds", "Open Guild Bank...");
  1627. //Spawn* banker = client->GetPlayer()->GetTarget();
  1628. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will eventually open the guild bank!");
  1629. break;
  1630. }
  1631. case COMMAND_START_MAIL: {
  1632. client->SetMailTransaction(cmdTarget);
  1633. client->SendMailList();
  1634. break;
  1635. }
  1636. case COMMAND_CANCEL_MAIL: {
  1637. client->SetMailTransaction(0);
  1638. break;
  1639. }
  1640. case COMMAND_GET_MAIL_MESSAGE: {
  1641. if (sep && sep->arg[0] && sep->IsNumber(0))
  1642. client->DisplayMailMessage(atoul(sep->arg[0]));
  1643. break;
  1644. }
  1645. case COMMAND_ADD_MAIL_PLAT: {
  1646. if (sep && sep->arg[0] && sep->IsNumber(0))
  1647. client->AddMailCoin(0, 0, 0, atoul(sep->arg[0]));
  1648. break;
  1649. }
  1650. case COMMAND_ADD_MAIL_GOLD: {
  1651. if (sep && sep->arg[0] && sep->IsNumber(0))
  1652. client->AddMailCoin(0, 0, atoul(sep->arg[0]));
  1653. break;
  1654. }
  1655. case COMMAND_ADD_MAIL_SILVER: {
  1656. if (sep && sep->arg[0] && sep->IsNumber(0))
  1657. client->AddMailCoin(0, atoul(sep->arg[0]));
  1658. break;
  1659. }
  1660. case COMMAND_ADD_MAIL_COPPER: {
  1661. if (sep && sep->arg[0] && sep->IsNumber(0))
  1662. client->AddMailCoin(atoul(sep->arg[0]));
  1663. break;
  1664. }
  1665. case COMMAND_SET_MAIL_ITEM: {
  1666. LogWrite(MISC__TODO, 1, "TODO", " received set_mail_item\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1667. if (sep && sep->arg[0]) LogWrite(COMMAND__DEBUG, 0, "Command", "%s\n", sep->argplus[0]);
  1668. break;
  1669. }
  1670. case COMMAND_REMOVE_MAIL_PLAT: {
  1671. if (sep && sep->arg[0] && sep->IsNumber(0))
  1672. client->RemoveMailCoin(0, 0, 0, atoul(sep->arg[0]));
  1673. break;
  1674. }
  1675. case COMMAND_REMOVE_MAIL_GOLD: {
  1676. if (sep && sep->arg[0] && sep->IsNumber(0))
  1677. client->RemoveMailCoin(0, 0, atoul(sep->arg[0]));
  1678. break;
  1679. }
  1680. case COMMAND_REMOVE_MAIL_SILVER: {
  1681. if (sep && sep->arg[0] && sep->IsNumber(0))
  1682. client->RemoveMailCoin(0, atoul(sep->arg[0]));
  1683. break;
  1684. }
  1685. case COMMAND_REMOVE_MAIL_COPPER: {
  1686. if (sep && sep->arg[0] && sep->IsNumber(0))
  1687. client->RemoveMailCoin(atoul(sep->arg[0]));
  1688. break;
  1689. }
  1690. case COMMAND_TAKE_MAIL_ATTACHMENTS: {
  1691. if (sep && sep->arg[0] && sep->IsNumber(0))
  1692. client->TakeMailAttachments(atoul(sep->arg[0]));
  1693. break;
  1694. }
  1695. case COMMAND_CANCEL_SEND_MAIL: {
  1696. client->CancelSendMail();
  1697. break;
  1698. }
  1699. case COMMAND_DELETE_MAIL_MESSAGE: {
  1700. if (sep && sep->arg[0] && sep->IsNumber(0))
  1701. client->DeleteMail(atoul(sep->arg[0]), true);
  1702. break;
  1703. }
  1704. case COMMAND_REPORT_SPAM: {
  1705. LogWrite(MISC__TODO, 1, "TODO", " received reportspam\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1706. if (sep && sep->arg[0]) LogWrite(COMMAND__DEBUG, 0, "Command", "%s\n", sep->argplus[0]);
  1707. break;
  1708. }
  1709. case COMMAND_KILL:{
  1710. Spawn* dead = 0;
  1711. if (sep && sep->arg[0] && strncasecmp(sep->arg[0],"self",4)==0){
  1712. dead=client->GetPlayer();
  1713. client->GetPlayer()->SetHP(0);
  1714. client->GetPlayer()->KillSpawn(dead);
  1715. }else{
  1716. dead= cmdTarget;
  1717. if(dead && dead->IsPlayer() == false){
  1718. dead->SetHP(0);
  1719. if(sep && sep->arg[0] && sep->IsNumber(0) && atoi(sep->arg[0]) == 1)
  1720. client->GetCurrentZone()->RemoveSpawn(false, dead, true);
  1721. else
  1722. client->GetPlayer()->KillSpawn(dead);
  1723. }else{
  1724. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /kill (self)");
  1725. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Kills currently selected non-player target.");
  1726. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Optionally, self may be used to kill yourself");
  1727. }
  1728. }
  1729. break;
  1730. }
  1731. case COMMAND_LEVEL:{
  1732. if(sep && sep->arg[ndx][0] && sep->IsNumber(0)){
  1733. int16 new_level = atoi(sep->arg[ndx]);
  1734. if (!client->GetPlayer()->CheckLevelStatus(new_level))
  1735. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have the required status to level up anymore!");
  1736. else {
  1737. if (new_level < 1)
  1738. new_level = 1;
  1739. if (new_level > 255)
  1740. new_level = 255;
  1741. client->ChangeLevel(client->GetPlayer()->GetLevel(), new_level);
  1742. client->GetPlayer()->SetXP(1);
  1743. client->GetPlayer()->SetNeededXP();
  1744. }
  1745. }else
  1746. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /level {new_level}");
  1747. break;
  1748. }
  1749. case COMMAND_SIT: {
  1750. LogWrite(MISC__TODO, 1, "TODO", " Send update packet to all clients\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1751. if(client->GetPlayer()->GetHP() > 0){
  1752. client->QueuePacket(new EQ2Packet(OP_SitMsg, 0, 0));
  1753. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You sit down.");
  1754. client->GetPlayer()->set_character_flag(CF_IS_SITTING);
  1755. }
  1756. break;
  1757. }
  1758. case COMMAND_STAND: {
  1759. LogWrite(MISC__TODO, 1, "TODO", " Send update packet to all clients\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1760. if(client->GetPlayer()->GetHP() > 0){
  1761. client->QueuePacket(new EQ2Packet(OP_StandMsg, 0, 0));
  1762. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You stand up.");
  1763. client->GetPlayer()->reset_character_flag(CF_IS_SITTING);
  1764. }
  1765. break;
  1766. }
  1767. case COMMAND_CLASS:{
  1768. if(sep && sep->arg[ndx][0]){
  1769. client->GetPlayer()->SetPlayerAdventureClass(atoi(sep->arg[ndx]));
  1770. client->UpdateTimeStampFlag ( CLASS_UPDATE_FLAG );
  1771. }else
  1772. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /class {class_id}");
  1773. break;
  1774. }
  1775. case COMMAND_GENDER:{
  1776. if(sep && sep->arg[ndx][0]){
  1777. client->GetPlayer()->GetInfoStruct()->gender = atoi(sep->arg[ndx]);
  1778. client->GetPlayer()->SetCharSheetChanged(true);
  1779. client->UpdateTimeStampFlag ( GENDER_UPDATE_FLAG );
  1780. }else{
  1781. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /gender {new_gender_id}");
  1782. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Male: 1");
  1783. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Female: 2");
  1784. }
  1785. break;
  1786. }
  1787. case COMMAND_FLYMODE:{
  1788. if(sep && sep->arg[0] && sep->IsNumber(0)){
  1789. PrintSep(sep, "COMMAND_FLYMODE");
  1790. int8 val = atoi(sep->arg[0]);
  1791. ClientPacketFunctions::SendFlyMode(client, val);
  1792. }
  1793. else{
  1794. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage ON: /flymode 1");
  1795. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage OFF: /flymode 0");
  1796. }
  1797. break;
  1798. }
  1799. case COMMAND_LOOT_LIST:{
  1800. Spawn* spawn = cmdTarget;
  1801. if(spawn && spawn->IsEntity()){
  1802. if (sep && sep->arg[0]) {
  1803. if (!spawn->GetDatabaseID())
  1804. {
  1805. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn has no database id to assign to loottables.");
  1806. break;
  1807. }
  1808. else if (!spawn->IsNPC())
  1809. {
  1810. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "these /loot list [add/remove/clearall] sub-commands are only designed for an NPC.");
  1811. break;
  1812. }
  1813. bool reloadLoot = false;
  1814. if (!stricmp(sep->arg[0], "remove") && sep->arg[1] && sep->IsNumber(1))
  1815. {
  1816. int32 loottable_id = atoul(sep->arg[1]);
  1817. if (loottable_id > 0 && database.RemoveSpawnLootTable(spawn, loottable_id))
  1818. {
  1819. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u loot table %u removed.", spawn->GetDatabaseID(), loottable_id);
  1820. reloadLoot = true;
  1821. }
  1822. else
  1823. client->Message(CHANNEL_COLOR_YELLOW, "/loot list remove [loottableid] - could not match any spawn_id entries against loottable_id %u.", loottable_id);
  1824. }
  1825. else if (!stricmp(sep->arg[0], "add") && sep->arg[1] && sep->IsNumber(1))
  1826. {
  1827. int32 loottable_id = atoul(sep->arg[1]);
  1828. if (loottable_id > 0)
  1829. {
  1830. database.AddLootTableToSpawn(spawn, loottable_id);
  1831. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u loot table %u added.", spawn->GetDatabaseID(), loottable_id);
  1832. reloadLoot = true;
  1833. }
  1834. else
  1835. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list add [loottableid] - cannot add a loottable id of 0.");
  1836. }
  1837. else if (!stricmp(sep->arg[0], "clearall"))
  1838. {
  1839. if (database.RemoveSpawnLootTable(spawn, 0))
  1840. {
  1841. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn loot tables removed.");
  1842. reloadLoot = true;
  1843. }
  1844. else
  1845. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list clearall - could not match any spawn_id entries in loottable_id.");
  1846. }
  1847. else
  1848. {
  1849. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list argument not supported.");
  1850. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list add [loottableid] - add new loottable to spawn");
  1851. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list remove [loottableid] - remove existing loottable from spawn");
  1852. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list clearall - remove all loottables from spawn");
  1853. break;
  1854. }
  1855. if (reloadLoot)
  1856. {
  1857. database.LoadSpawnLoot(spawn->GetZone(), spawn);
  1858. if (spawn->IsNPC())
  1859. {
  1860. Entity* ent = (Entity*)spawn;
  1861. ent->SetLootCoins(0);
  1862. ent->ClearLootList();
  1863. spawn->GetZone()->AddLoot((NPC*)spawn);
  1864. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u active loot purged and reloaded.", spawn->GetDatabaseID());
  1865. }
  1866. }
  1867. break; // nothing further this is the end of these sub commands
  1868. }
  1869. else
  1870. {
  1871. vector<int32> loot_list = client->GetCurrentZone()->GetSpawnLootList(spawn->GetDatabaseID(), spawn->GetZone()->GetZoneID(), spawn->GetLevel(), race_types_list.GetRaceType(spawn->GetModelType()));
  1872. if (loot_list.size() > 0) {
  1873. client->Message(CHANNEL_COLOR_YELLOW, "%s belongs to the following loot lists: ", spawn->GetName());
  1874. vector<int32>::iterator list_itr;
  1875. LootTable* table = 0;
  1876. for (list_itr = loot_list.begin(); list_itr != loot_list.end(); list_itr++) {
  1877. table = client->GetCurrentZone()->GetLootTable(*list_itr);
  1878. if (table)
  1879. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", *list_itr, table->name.c_str());
  1880. }
  1881. }
  1882. Entity* target = (Entity*)spawn;
  1883. client->Message(CHANNEL_COLOR_YELLOW, "Coins being carried: %u", target->GetLootCoins());
  1884. vector<Item*>* items = target->GetLootItems();
  1885. if (items) {
  1886. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is carrying the following items: ");
  1887. vector<Item*>::iterator itr;
  1888. Item* item = 0;
  1889. for (itr = items->begin(); itr != items->end(); itr++) {
  1890. item = *itr;
  1891. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", item->details.item_id, item->name.c_str());
  1892. }
  1893. }
  1894. else
  1895. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is not carrying any items.");
  1896. }
  1897. }
  1898. break;
  1899. }
  1900. case COMMAND_LOOT_SETCOIN:{
  1901. Spawn* spawn = cmdTarget;
  1902. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  1903. Entity* target = (Entity*)spawn;
  1904. target->SetLootCoins(atoul(sep->arg[0]));
  1905. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully set coins.");
  1906. }
  1907. else
  1908. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot setcoin {amount}");
  1909. break;
  1910. }
  1911. case COMMAND_LOOT_ADDITEM:{
  1912. Spawn* spawn = cmdTarget;
  1913. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  1914. Entity* target = (Entity*)spawn;
  1915. int16 charges = 1;
  1916. if(sep->arg[1] && sep->IsNumber(1))
  1917. charges = atoi(sep->arg[1]);
  1918. target->AddLootItem(atoul(sep->arg[0]), charges);
  1919. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully added item.");
  1920. }
  1921. else
  1922. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot additem {item_id}");
  1923. break;
  1924. }
  1925. case COMMAND_LOOT_REMOVEITEM:{
  1926. Spawn* spawn = cmdTarget;
  1927. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  1928. Entity* target = (Entity*)spawn;
  1929. target->LootItem(atoul(sep->arg[0]));
  1930. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully removed item.");
  1931. }
  1932. else
  1933. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot removeitem {item_id}");
  1934. break;
  1935. }
  1936. case COMMAND_LOOT_CORPSE:
  1937. case COMMAND_LOOT:{
  1938. if (cmdTarget && ((Entity*)cmdTarget)->IsNPC() && cmdTarget->Alive())
  1939. {
  1940. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is not dead.");
  1941. break;
  1942. }
  1943. if(cmdTarget && cmdTarget->IsEntity()){
  1944. if (cmdTarget->GetDistance(client->GetPlayer()) <= 10){
  1945. client->Loot((Entity*)cmdTarget);
  1946. if (!((Entity*)cmdTarget)->HasLoot()){
  1947. if (((Entity*)cmdTarget)->IsNPC())
  1948. client->GetCurrentZone()->RemoveDeadSpawn(cmdTarget);
  1949. }
  1950. }
  1951. else
  1952. client->Message(CHANNEL_COLOR_YELLOW, "You are too far away to interact with that");
  1953. }
  1954. else if(!cmdTarget || cmdTarget->GetHP() > 0)
  1955. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid target.");
  1956. break;
  1957. }
  1958. case COMMAND_RELOADSPAWNSCRIPTS:{
  1959. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spawn Scripts....");
  1960. if (lua_interface)
  1961. lua_interface->SetSpawnScriptsReloading(true);
  1962. world.ResetSpawnScripts();
  1963. database.LoadSpawnScriptData();
  1964. if(lua_interface) {
  1965. lua_interface->DestroySpawnScripts();
  1966. lua_interface->SetSpawnScriptsReloading(false);
  1967. }
  1968. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Success!");
  1969. break;
  1970. }
  1971. case COMMAND_RELOADLUASYSTEM:{
  1972. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Attempting to reload entire LUA system....");
  1973. map<Client*, int32> debug_clients = lua_interface->GetDebugClients();
  1974. safe_delete(lua_interface);
  1975. lua_interface = new LuaInterface();
  1976. if(lua_interface)
  1977. lua_interface->SetSpawnScriptsReloading(true);
  1978. if(lua_interface && debug_clients.size() > 0){
  1979. map<Client*, int32>::iterator itr;
  1980. for(itr = debug_clients.begin(); itr != debug_clients .end(); itr++){
  1981. if(lua_interface)
  1982. lua_interface->UpdateDebugClients(itr->first);
  1983. }
  1984. }
  1985. world.ResetSpawnScripts();
  1986. database.LoadSpawnScriptData();
  1987. world.ResetZoneScripts();
  1988. database.LoadZoneScriptData();
  1989. int32 quest_count = database.LoadQuests();
  1990. zone_list.DeleteSpellProcess();
  1991. master_spell_list.Reload();
  1992. int32 spell_count = 0;
  1993. if(lua_interface) {
  1994. lua_interface->DestroySpawnScripts();
  1995. lua_interface->DestroySpells();
  1996. spell_count = database.LoadSpellScriptData();
  1997. lua_interface->SetSpawnScriptsReloading(false);
  1998. }
  1999. zone_list.LoadSpellProcess();
  2000. client->Message(CHANNEL_COLOR_YELLOW, "Successfully loaded %u spell(s), %u quest(s).", spell_count, quest_count);
  2001. break;
  2002. }
  2003. case COMMAND_DECLINE_QUEST:{
  2004. int32 quest_id = 0;
  2005. if(sep && sep->arg[0] && sep->IsNumber(0))
  2006. quest_id = atoul(sep->arg[0]);
  2007. if(quest_id > 0){
  2008. Quest* quest = client->GetPendingQuest(quest_id);
  2009. if(quest){
  2010. client->RemovePendingQuest(quest);
  2011. if(lua_interface)
  2012. lua_interface->CallQuestFunction(quest, "Declined", client->GetPlayer());
  2013. safe_delete(quest);
  2014. client->GetCurrentZone()->SendQuestUpdates(client);
  2015. }
  2016. }
  2017. break;
  2018. }
  2019. case COMMAND_DELETE_QUEST:{
  2020. int32 quest_id = 0;
  2021. if(sep && sep->arg[0] && sep->IsNumber(0))
  2022. quest_id = atoul(sep->arg[0]);
  2023. if(quest_id > 0){
  2024. if(lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0) {
  2025. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  2026. if (quest)
  2027. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  2028. }
  2029. client->RemovePlayerQuest(quest_id);
  2030. client->GetCurrentZone()->SendQuestUpdates(client);
  2031. }
  2032. break;
  2033. }
  2034. case COMMAND_ACCEPT_QUEST:{
  2035. int32 quest_id = 0;
  2036. if(sep && sep->arg[0] && sep->IsNumber(0))
  2037. quest_id = atoul(sep->arg[0]);
  2038. if(quest_id > 0){
  2039. Quest* quest = client->GetPendingQuest(quest_id);
  2040. if(quest){
  2041. client->RemovePendingQuest(quest);
  2042. client->AddPlayerQuest(quest);
  2043. client->GetCurrentZone()->SendQuestUpdates(client);
  2044. // If character has already completed this quest once update the given date in the database
  2045. if (client->GetPlayer()->GetCompletedPlayerQuests()->count(quest_id) > 0) {
  2046. Quest* quest2 = client->GetPlayer()->GetCompletedQuest(quest_id);
  2047. if (quest2)
  2048. quest->SetCompleteCount(quest2->GetCompleteCount());
  2049. database.SaveCharRepeatableQuest(client, quest_id, quest->GetCompleteCount());
  2050. }
  2051. }
  2052. }
  2053. break;
  2054. }
  2055. case COMMAND_NAME:{
  2056. if(sep && sep->arg[ndx][0]){
  2057. memset(client->GetPlayer()->GetInfoStruct()->name, 0, 40);
  2058. strncpy(client->GetPlayer()->GetInfoStruct()->name, sep->arg[ndx], 39);
  2059. client->GetPlayer()->SetCharSheetChanged(true);
  2060. }else
  2061. client->Message(CHANNEL_COLOR_YELLOW,"Usage: /name {new_name}");
  2062. break;
  2063. }
  2064. case COMMAND_GROUPSAY:{
  2065. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  2066. if(sep && sep->arg[0] && gmi)
  2067. world.GetGroupManager()->GroupChatMessage(gmi->group_id, client->GetPlayer(), sep->argplus[0]);
  2068. break;
  2069. }
  2070. case COMMAND_GROUPINVITE: {
  2071. Entity* target = 0;
  2072. Client* target_client = 0;
  2073. if (client->GetPlayer()->GetGroupMemberInfo() && !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  2074. client->SimpleMessage(CHANNEL_COMMANDS, "You must be the group leader to invite.");
  2075. return;
  2076. }
  2077. // name provided with command so it has to be a player, npc not supported here
  2078. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0){
  2079. target_client = zone_list.GetClientByCharName(sep->arg[0]);
  2080. if (target_client) {
  2081. if (!target_client->IsConnected() || !target_client->IsReadyForSpawns())
  2082. target = 0;
  2083. else
  2084. target = target_client->GetPlayer();
  2085. }
  2086. }
  2087. // if name was not provided use the players target, npc or player supported here
  2088. if (!target && client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  2089. target = (Entity*)client->GetPlayer()->GetTarget();
  2090. if (target->IsPlayer()) {
  2091. target_client = client->GetCurrentZone()->GetClientBySpawn(target);
  2092. }
  2093. }
  2094. int8 result = world.GetGroupManager()->Invite(client->GetPlayer(), target);
  2095. if (result == 0) {
  2096. client->Message(CHANNEL_COMMANDS, "You invite %s to group with you.", target->GetName());
  2097. if (target_client) {
  2098. PacketStruct* packet = configReader.getStruct("WS_ReceiveOffer", target_client->GetVersion());
  2099. if (packet) {
  2100. packet->setDataByName("type", 1);
  2101. packet->setDataByName("name", client->GetPlayer()->GetName());
  2102. packet->setDataByName("unknown2", 1);
  2103. target_client->QueuePacket(packet->serialize());
  2104. safe_delete(packet);
  2105. }
  2106. }
  2107. }
  2108. else if (result == 1)
  2109. client->SimpleMessage(CHANNEL_COMMANDS, "That player is already in a group.");
  2110. else if (result == 2)
  2111. client->SimpleMessage(CHANNEL_COMMANDS, "That player has been invited to another group.");
  2112. else if (result == 3)
  2113. client->SimpleMessage(CHANNEL_COMMANDS, "Your group is already full.");
  2114. else if (result == 4)
  2115. client->SimpleMessage(CHANNEL_COMMANDS, "You have a pending invitation, cancel it first.");
  2116. else if (result == 5)
  2117. client->SimpleMessage(CHANNEL_COMMANDS, "You cannot invite yourself!");
  2118. else if (result == 6)
  2119. client->SimpleMessage(CHANNEL_COMMANDS, "Could not locate the player.");
  2120. else
  2121. client->SimpleMessage(CHANNEL_COMMANDS, "Group invite failed, unknown error!");
  2122. break;
  2123. }
  2124. case COMMAND_GROUPDISBAND: {
  2125. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  2126. if (gmi) { // TODO: Leader check
  2127. // world.GetGroupManager()->SimpleGroupMessage(gmi->group_id, "Your group has been disbanded.");
  2128. world.GetGroupManager()->RemoveGroup(gmi->group_id);
  2129. }
  2130. break;
  2131. }
  2132. case COMMAND_GROUP_LEAVE: {
  2133. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  2134. if (gmi) {
  2135. int32 group_id = gmi->group_id;
  2136. world.GetGroupManager()->RemoveGroupMember(group_id, client->GetPlayer());
  2137. if (!world.GetGroupManager()->IsGroupIDValid(group_id)) {
  2138. // leader->Message(CHANNEL_COLOR_GROUP, "%s has left the group.", client->GetPlayer()->GetName());
  2139. }
  2140. else {
  2141. world.GetGroupManager()->GroupMessage(group_id, "%s has left the group.", client->GetPlayer()->GetName());
  2142. }
  2143. client->SimpleMessage(CHANNEL_COLOR_GROUP, "You have left the group");
  2144. }
  2145. break;
  2146. }
  2147. case COMMAND_FRIEND_ADD:{
  2148. string name = "";
  2149. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2150. name = database.GetPlayerName(sep->arg[0]);
  2151. else if(cmdTarget && cmdTarget->IsPlayer())
  2152. name = string(cmdTarget->GetName());
  2153. if(name.length() > 0){
  2154. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  2155. if(client->GetPlayer()->IsIgnored(name.c_str())){
  2156. client->GetPlayer()->RemoveIgnore(name.c_str());
  2157. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  2158. client->SendChatRelationship(3, name.c_str());
  2159. }
  2160. client->GetPlayer()->AddFriend(name.c_str(), true);
  2161. client->SendChatRelationship(0, name.c_str());
  2162. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added friend: %s", name.c_str());
  2163. if(zone_list.GetClientByCharName(name))
  2164. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Friend: %s has logged in.", name.c_str());
  2165. }
  2166. else
  2167. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot be more friendly towards yourself!");
  2168. }
  2169. else
  2170. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  2171. break;
  2172. }
  2173. case COMMAND_FRIEND_REMOVE:{
  2174. string name = "";
  2175. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2176. name = database.GetPlayerName(sep->arg[0]);
  2177. else if(cmdTarget && cmdTarget->IsPlayer())
  2178. name = string(cmdTarget->GetName());
  2179. if(name.length() > 0){
  2180. client->GetPlayer()->RemoveFriend(name.c_str());
  2181. client->SendChatRelationship(1, name.c_str());
  2182. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  2183. }
  2184. else
  2185. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  2186. break;
  2187. }
  2188. case COMMAND_FRIENDS:{
  2189. break;
  2190. }
  2191. case COMMAND_IGNORE_ADD:{
  2192. string name = "";
  2193. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2194. name = database.GetPlayerName(sep->arg[0]);
  2195. else if(cmdTarget && cmdTarget->IsPlayer())
  2196. name = string(cmdTarget->GetName());
  2197. if(name.length() > 0){
  2198. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  2199. if(client->GetPlayer()->IsFriend(name.c_str())){
  2200. client->GetPlayer()->RemoveFriend(name.c_str());
  2201. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  2202. client->SendChatRelationship(1, name.c_str());
  2203. }
  2204. client->GetPlayer()->AddIgnore(name.c_str(), true);
  2205. client->SendChatRelationship(2, name.c_str());
  2206. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added ignore: %s", name.c_str());
  2207. }
  2208. else
  2209. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot ignore yourself!");
  2210. }
  2211. else
  2212. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  2213. break;
  2214. }
  2215. case COMMAND_IGNORE_REMOVE:{
  2216. string name = "";
  2217. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2218. name = database.GetPlayerName(sep->arg[0]);
  2219. else if(cmdTarget && cmdTarget->IsPlayer())
  2220. name = string(cmdTarget->GetName());
  2221. if(name.length() > 0){
  2222. client->GetPlayer()->RemoveIgnore(name.c_str());
  2223. client->SendChatRelationship(3, name.c_str());
  2224. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  2225. }
  2226. break;
  2227. }
  2228. case COMMAND_IGNORES:{
  2229. break;
  2230. }
  2231. case COMMAND_GROUP_KICK:{
  2232. Entity* kicked = 0;
  2233. Client* kicked_client = 0;
  2234. int32 group_id = 0;
  2235. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader)
  2236. return;
  2237. LogWrite(MISC__TODO, 0, "TODO", "Add a check to see if the client using the command (COMMAND_GROUP_KICK) is the group leader");
  2238. if (sep && sep->arg[0]) {
  2239. kicked_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  2240. if (kicked_client)
  2241. kicked = kicked_client->GetPlayer();
  2242. }
  2243. else if (cmdTarget && cmdTarget->IsEntity()) {
  2244. kicked = (Entity*)cmdTarget;
  2245. }
  2246. group_id = client->GetPlayer()->GetGroupMemberInfo()->group_id;
  2247. bool send_kicked_message = world.GetGroupManager()->GetGroupSize(group_id) > 2;
  2248. if (kicked)
  2249. world.GetGroupManager()->RemoveGroupMember(group_id, kicked);
  2250. if(send_kicked_message)
  2251. world.GetGroupManager()->GroupMessage(group_id, "%s was kicked from the group.", kicked->GetName());
  2252. else
  2253. client->Message(CHANNEL_COLOR_GROUP, "You kicked %s from the group", kicked->GetName());
  2254. if (kicked_client)
  2255. kicked_client->SimpleMessage(CHANNEL_COLOR_GROUP, "You were kicked from the group");
  2256. break;
  2257. }
  2258. case COMMAND_GROUP_MAKE_LEADER:{
  2259. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  2260. client->SimpleMessage(CHANNEL_COMMANDS, "You are not a group leader.");
  2261. return;
  2262. }
  2263. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 1) {
  2264. Client* new_leader = zone_list.GetClientByCharName(sep->arg[0]);
  2265. if (new_leader) {
  2266. if (client->GetPlayer()->IsGroupMember(new_leader->GetPlayer())) {
  2267. world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, new_leader->GetPlayer());
  2268. }
  2269. }
  2270. else
  2271. client->SimpleMessage(CHANNEL_COMMANDS, "Unable to find the given player.");
  2272. }
  2273. else if (cmdTarget && cmdTarget->IsPlayer())
  2274. world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, (Entity*)cmdTarget);
  2275. else
  2276. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to change group leader.");
  2277. break;
  2278. }
  2279. case COMMAND_GROUP_ACCEPT_INVITE: {
  2280. if(sep && sep->arg[0] && strcmp(sep->arg[0], "group") == 0) {
  2281. int8 result = world.GetGroupManager()->AcceptInvite(client->GetPlayer());
  2282. if (result == 0)
  2283. client->SimpleMessage(CHANNEL_GROUP, "You have joined the group.");
  2284. else if (result == 1)
  2285. client->SimpleMessage(CHANNEL_GROUP, "You do not have a pending invite.");
  2286. else if (result == 2)
  2287. client->SimpleMessage(CHANNEL_GROUP, "Unable to join group - could not find leader.");
  2288. else
  2289. client->SimpleMessage(CHANNEL_GROUP, "Unable to join group - unknown error.");
  2290. }
  2291. break;
  2292. }
  2293. case COMMAND_GROUP_DECLINE_INVITE: {
  2294. if(sep && sep->arg[0] && strcmp(sep->arg[0], "group") == 0) {
  2295. world.GetGroupManager()->DeclineInvite(client->GetPlayer()); // TODO: Add message to leader
  2296. }
  2297. break;
  2298. }
  2299. case COMMAND_SUMMON:{
  2300. char* search_name = 0;
  2301. if(sep && sep->arg[0][0])
  2302. search_name = sep->arg[0];
  2303. if(!search_name && !cmdTarget){
  2304. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /summon [name]");
  2305. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Summons a targeted spawn or a spawn by name to you. If more than one spawn matches name, it will summon closest.");
  2306. }
  2307. else{
  2308. if(!client->Summon(search_name))
  2309. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  2310. }
  2311. break;
  2312. }
  2313. case COMMAND_GOTO:{
  2314. const char* search_name = 0;
  2315. if(sep && sep->arg[0][0])
  2316. search_name = sep->argplus[0];
  2317. if(!search_name && !cmdTarget){
  2318. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /goto [name]");
  2319. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Moves to targeted spawn or to a spawn by name. If more than one spawn matches name, you will move to closest.");
  2320. }
  2321. else{
  2322. if(!client->GotoSpawn(search_name))
  2323. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  2324. }
  2325. break;
  2326. }
  2327. case COMMAND_MOVE:{
  2328. bool success = false;
  2329. try{
  2330. if(sep && sep->arg[2][0] && sep->IsNumber(0) && sep->IsNumber(1) && sep->IsNumber(2)){
  2331. EQ2Packet* app = client->GetPlayer()->Move(atof(sep->arg[0]), atof(sep->arg[1]), atof(sep->arg[2]), client->GetVersion());
  2332. if(app){
  2333. client->QueuePacket(app);
  2334. success = true;
  2335. }
  2336. }
  2337. }
  2338. catch(...){}
  2339. if(!success){
  2340. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /move x y z");
  2341. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Moves the client to the given coordinates.");
  2342. }
  2343. break;
  2344. }
  2345. case COMMAND_SETTIME:{
  2346. if(sep && sep->arg[0]){
  2347. sscanf (sep->arg[0], "%d:%d", &world.GetWorldTimeStruct()->hour, &world.GetWorldTimeStruct()->minute);
  2348. if(sep->arg[1] && sep->IsNumber(1))
  2349. world.GetWorldTimeStruct()->month = atoi(sep->arg[1]) - 1; //zero based indexes
  2350. if(sep->arg[2] && sep->IsNumber(2))
  2351. world.GetWorldTimeStruct()->day = atoi(sep->arg[2]) - 1; //zero based indexes
  2352. if(sep->arg[3] && sep->IsNumber(3))
  2353. world.GetWorldTimeStruct()->year = atoi(sep->arg[3]);
  2354. client->GetCurrentZone()->SendTimeUpdateToAllClients();
  2355. }
  2356. else{
  2357. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /settime [hour:minute] (month) (day) (year)");
  2358. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Example: /settime 8:30");
  2359. }
  2360. break;
  2361. }
  2362. case COMMAND_VERSION:{
  2363. client->Message(CHANNEL_COLOR_YELLOW,"%s %s", EQ2EMU_MODULE, CURRENT_VERSION);
  2364. client->Message(CHANNEL_COLOR_YELLOW,"Last Compiled on %s %s", COMPILE_DATE, COMPILE_TIME);
  2365. break;
  2366. }
  2367. case COMMAND_ZONE:{
  2368. string* zonename = 0;
  2369. int32 instanceID = 0;
  2370. const char* zone = 0;
  2371. int32 zone_id = 0;
  2372. bool listSearch = false;
  2373. bool isInstance = false;
  2374. ZoneServer* zsZone = 0;
  2375. if(sep && sep->arg[0][0])
  2376. {
  2377. if(strncasecmp(sep->arg[0], "list", 4) == 0)
  2378. listSearch = true;
  2379. else if(strncasecmp(sep->arg[0], "active", 6) == 0)
  2380. {
  2381. zone_list.SendZoneList(client);
  2382. break;
  2383. }
  2384. else if(strncasecmp(sep->arg[0], "instance", 6) == 0)
  2385. {
  2386. if(sep->IsNumber(1))
  2387. instanceID = atol(sep->arg[1]);
  2388. }
  2389. else if(strncasecmp(sep->arg[0], "lock", 4) == 0)
  2390. {
  2391. PrintSep(sep, "ZONE LOCK");
  2392. if(sep->IsNumber(1))
  2393. zsZone = zone_list.Get(atoul(sep->arg[1]), false);
  2394. else
  2395. zsZone = zone_list.Get(sep->arg[1], false);
  2396. if( zsZone )
  2397. {
  2398. zsZone->SetZoneLockState(true);
  2399. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now locked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  2400. }
  2401. else
  2402. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be locked.", sep->arg[1]);
  2403. break;
  2404. }
  2405. else if(strncasecmp(sep->arg[0], "unlock", 6) == 0)
  2406. {
  2407. PrintSep(sep, "ZONE UNLOCK");
  2408. if(sep->IsNumber(1))
  2409. zsZone = zone_list.Get(atoul(sep->arg[1]), false);
  2410. else
  2411. zsZone = zone_list.Get(sep->arg[1], false);
  2412. if( zsZone )
  2413. {
  2414. zsZone->SetZoneLockState(false);
  2415. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now unlocked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  2416. }
  2417. else
  2418. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be unlocked.", sep->arg[1]);
  2419. break;
  2420. }
  2421. else
  2422. {
  2423. if(sep->IsNumber(0))
  2424. {
  2425. zone_id = atoul(sep->arg[0]);
  2426. zonename = database.GetZoneName(zone_id);
  2427. if(zonename)
  2428. zone = zonename->c_str();
  2429. }
  2430. else
  2431. zone = sep->arg[0];
  2432. }
  2433. if(instanceID > 0)
  2434. {
  2435. ZoneServer* zsInstance = zone_list.GetByInstanceID(instanceID);
  2436. if(zsInstance != NULL)
  2437. {
  2438. instanceID = zsInstance->GetInstanceID();
  2439. zone = zsInstance->GetZoneName();
  2440. zone_id = zsInstance->GetZoneID();
  2441. isInstance = true;
  2442. }
  2443. }
  2444. }
  2445. if(!listSearch)
  2446. {
  2447. if(!zone)
  2448. client->Message(CHANNEL_COLOR_RED, "Error: Invalid Zone");
  2449. else if(instanceID != client->GetCurrentZone()->GetInstanceID() ||
  2450. zone_id != client->GetCurrentZone()->GetZoneID())
  2451. {
  2452. if(database.VerifyZone(zone))
  2453. {
  2454. if(client->CheckZoneAccess(zone))
  2455. {
  2456. client->Message(CHANNEL_COLOR_YELLOW,"Zoning to %s...", zone);
  2457. if(isInstance)
  2458. client->Zone(instanceID,true,true);
  2459. else
  2460. client->Zone(zone);
  2461. }
  2462. }
  2463. else
  2464. client->Message(CHANNEL_COLOR_RED, "Error: Zone '%s' not found. To get a list type /zone list", zone);
  2465. }
  2466. else
  2467. client->Message(CHANNEL_COLOR_RED, "Error: You are already in that zone!");
  2468. }
  2469. else
  2470. {
  2471. const char* name = 0;
  2472. if(sep && sep->arg[1][0])
  2473. {
  2474. map<int32, string>* zone_names;
  2475. name = sep->argplus[1];
  2476. sint16 status = client->GetAdminStatus();
  2477. if( status > 0 )
  2478. {
  2479. client->SimpleMessage(CHANNEL_COLOR_RED, "ADMIN MODE");
  2480. zone_names = database.GetZoneList(name, true);
  2481. }
  2482. else
  2483. zone_names = database.GetZoneList(name);
  2484. if(!zone_names)
  2485. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No zones found.");
  2486. else
  2487. {
  2488. map<int32, string>::iterator itr;
  2489. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  2490. for(itr = zone_names->begin(); itr != zone_names->end(); itr++)
  2491. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  2492. safe_delete(zone_names);
  2493. }
  2494. }
  2495. else
  2496. {
  2497. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone [zone name]");
  2498. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone list [partial zone name]");
  2499. }
  2500. }
  2501. safe_delete(zonename);
  2502. break;
  2503. }
  2504. case COMMAND_USE: {
  2505. Spawn* target = cmdTarget;
  2506. if (target->IsWidget())
  2507. ((Widget*)target)->HandleUse(client, "use");
  2508. break;
  2509. }
  2510. case COMMAND_OPEN: {
  2511. Spawn* target = cmdTarget;
  2512. if (target->IsWidget())
  2513. ((Widget*)target)->HandleUse(client, "Open", WIDGET_TYPE_DOOR);
  2514. break;
  2515. }
  2516. case COMMAND_CASTSPELL: {
  2517. if (sep && sep->arg[0] && sep->IsNumber(0))
  2518. {
  2519. int8 tier = 1;
  2520. if (sep->arg[1] && sep->IsNumber(1))
  2521. tier = atoul(sep->arg[1]);
  2522. int32 spellid = atoul(sep->arg[0]);
  2523. Spell* spell = master_spell_list.GetSpell(spellid, tier);
  2524. if (spell)
  2525. {
  2526. client->Message(CHANNEL_COLOR_RED, "Casting spell %u.", spellid);
  2527. SpellProcess* spellProcess = 0;
  2528. // Get the current zones spell process
  2529. spellProcess = client->GetCurrentZone()->GetSpellProcess();
  2530. spellProcess->CastInstant(spell, (Entity*)client->GetPlayer(), (cmdTarget && cmdTarget->IsEntity()) ? (Entity*)cmdTarget : (Entity*)client->GetPlayer());
  2531. }
  2532. else
  2533. {
  2534. client->Message(CHANNEL_COLOR_RED, "Could not find spell %u.",spellid);
  2535. }
  2536. }
  2537. else if (sep && sep->arg[0])
  2538. {
  2539. database.FindSpell(client, (char*)sep->argplus[0]);
  2540. }
  2541. else
  2542. {
  2543. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellid] (tier=1) - Cast Spell with specified spell id, tier is optional, default of 1.");
  2544. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellname] - Find spells wildcard match with a partial spell name");
  2545. }
  2546. break;
  2547. }
  2548. case COMMAND_ATTACK:
  2549. case COMMAND_AUTO_ATTACK:{
  2550. int8 type = 1;
  2551. Player* player = client->GetPlayer();
  2552. if(!player)
  2553. break;
  2554. bool incombat = player->EngagedInCombat();
  2555. if(sep && sep->arg[0] && sep->IsNumber(0))
  2556. type = atoi(sep->arg[0]);
  2557. if(client->GetPlayer()->GetHP() == 0){
  2558. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  2559. break;
  2560. }
  2561. if(type == 0){
  2562. if(incombat)
  2563. client->SimpleMessage(CHANNEL_COLOR_COMBAT, "You stop fighting.");
  2564. player->InCombat(false);
  2565. player->InCombat(false, true);
  2566. player->SetRangeAttack(false);
  2567. }
  2568. else {
  2569. if(type == 2){
  2570. player->InCombat(false);
  2571. if(incombat && player->GetRangeAttack()){
  2572. player->SetRangeAttack(false);
  2573. player->InCombat(false, true);
  2574. client->SimpleMessage(CHANNEL_COLOR_COMBAT, "You stop fighting.");
  2575. }
  2576. else{
  2577. player->SetRangeAttack(true);
  2578. player->InCombat(true, true);
  2579. client->SimpleMessage(CHANNEL_COLOR_COMBAT, "You start fighting.");
  2580. }
  2581. }
  2582. else {
  2583. player->InCombat(false, true);
  2584. player->SetRangeAttack(false);
  2585. player->InCombat(true);
  2586. if(!incombat)
  2587. client->SimpleMessage(CHANNEL_COLOR_COMBAT, "You start fighting.");
  2588. }
  2589. /*else
  2590. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You cannot attack that!");*/
  2591. }
  2592. player->SetCharSheetChanged(true);
  2593. break;
  2594. }
  2595. case COMMAND_DEPOP:{
  2596. bool allow_respawns = false;
  2597. if(sep && sep->arg[0] && sep->IsNumber(0)){
  2598. if(atoi(sep->arg[0]) == 1)
  2599. allow_respawns = true;
  2600. }
  2601. client->GetCurrentZone()->Depop(allow_respawns);
  2602. break;
  2603. }
  2604. case COMMAND_REPOP:{
  2605. client->GetCurrentZone()->Depop(false, true);
  2606. break;
  2607. }
  2608. case COMMAND_BUYBACK:{
  2609. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  2610. // Item ID and Unique ID get combined in this command so we need to get the number as an int64 and break it into 2 int32's
  2611. int64 id = atoi64(sep->arg[0]);
  2612. // get the first int32, the item id
  2613. //int32 item_id = (int32)id;
  2614. // get the second int32, the unique id
  2615. int32 unique_id = (int32)(id>>32);
  2616. int8 quantity = atoi(sep->arg[1]);
  2617. if(quantity == 255)
  2618. quantity = 1;
  2619. client->BuyBack(unique_id, quantity);
  2620. }
  2621. break;
  2622. }
  2623. case COMMAND_MERCHANT_BUY:{
  2624. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  2625. int32 item_id = atoul(sep->arg[0]);
  2626. int8 quantity = atoi(sep->arg[1]);
  2627. client->BuyItem(item_id, quantity);
  2628. }
  2629. break;
  2630. }
  2631. case COMMAND_MERCHANT_SELL:{
  2632. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  2633. // Item ID and Unique ID get combined in this command so we need to get the number as an int64 and break it into 2 int32's
  2634. int64 id = atoi64(sep->arg[0]);
  2635. // get the first int32, the item id
  2636. int32 item_id = (int32)id;
  2637. // get the second int32, the unique id
  2638. int32 unique_id = (int32)(id>>32);
  2639. int8 quantity = atoi(sep->arg[1]);
  2640. LogWrite(MERCHANT__DEBUG, 0, "Merchant", "Selling Item: Item Id = %ul, unique id = %ul, Quantity = %i", item_id, unique_id, quantity);
  2641. client->SellItem(item_id, quantity, unique_id);
  2642. }
  2643. break;
  2644. }
  2645. case COMMAND_MENDER_REPAIR: {
  2646. if (sep && sep->arg[0] && sep->IsNumber(0))
  2647. client->RepairItem(atoul(sep->arg[0]));
  2648. break;
  2649. }
  2650. case COMMAND_MENDER_REPAIR_ALL: {
  2651. client->RepairAllItems();
  2652. break;
  2653. }
  2654. case COMMAND_CANCEL_MERCHANT:{
  2655. client->SetMerchantTransaction(0);
  2656. break;
  2657. }
  2658. case COMMAND_START_MERCHANT:{
  2659. break;
  2660. }
  2661. case COMMAND_INVULNERABLE:{
  2662. sint8 val = -1;
  2663. if(sep && sep->arg[0] && sep->IsNumber(0)){
  2664. val = atoi(sep->arg[0]);
  2665. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  2666. client->GetPlayer()->SetInvulnerable(val==1);
  2667. if(client->GetPlayer()->GetInvulnerable())
  2668. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are now invulnerable!");
  2669. else
  2670. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are no longer invulnerable!");
  2671. }
  2672. if(val == -1)
  2673. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /invulnerable [0/1]");
  2674. break;
  2675. }
  2676. case COMMAND_REPAIR: {
  2677. Spawn* spawn = cmdTarget;
  2678. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR) {
  2679. client->SetMerchantTransaction(spawn);
  2680. client->SendRepairList();
  2681. }
  2682. break;
  2683. }
  2684. case COMMAND_LOTTO: {
  2685. Spawn* spawn = cmdTarget;
  2686. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_LOTTO) {
  2687. client->SetMerchantTransaction(spawn);
  2688. client->ShowLottoWindow();
  2689. }
  2690. break;
  2691. }
  2692. case COMMAND_ACCEPT_REWARD:{
  2693. int32 unknown = 0;
  2694. int32 selectable_item_id = 0;
  2695. //Quest *quest = 0;
  2696. Collection *collection = 0;
  2697. /* no idea what the first argument is for (faction maybe?)
  2698. if the reward has a selectable item reward, it's sent as the second argument
  2699. if neither of these are included in the reward, there is no sep
  2700. since the regular item rewards are manditary to receive, we don't have to know what they are until we accept the collection or quest
  2701. only 1 quest or collection reward may be displayed at a time */
  2702. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  2703. unknown = atoul(sep->arg[0]);
  2704. selectable_item_id = atoul(sep->arg[1]);
  2705. }
  2706. //if ((quest = player->GetPendingQuestReward()))
  2707. // client->AcceptQuestRewards(quest, selectable_item_id);
  2708. /* the below needs to go away eventually and be redone */
  2709. int32 item_id = 0;
  2710. if(sep && sep->arg[0][0] && sep->IsNumber(0))
  2711. item_id = atoul(sep->arg[0]);
  2712. Quest* quest = client->GetPendingQuestAcceptance(item_id);
  2713. if(quest){
  2714. client->AcceptQuestReward(quest, item_id);
  2715. break;
  2716. }
  2717. if (collection = player->GetPendingCollectionReward())
  2718. client->AcceptCollectionRewards(collection, selectable_item_id);
  2719. else
  2720. LogWrite(COMMAND__ERROR, 0, "Command", "Error in COMMAND_ACCEPT_REWARD. No pending quest or collection reward was found (unknown=%u).", unknown);
  2721. break;
  2722. }
  2723. case COMMAND_BUY_FROM_BROKER:{
  2724. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  2725. int32 item_id = atoul(sep->arg[0]);
  2726. int16 quantity = atoul(sep->arg[1]);
  2727. client->AddItem(item_id, quantity);
  2728. }
  2729. break;
  2730. }
  2731. case COMMAND_SEARCH_STORES_PAGE:{
  2732. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  2733. int32 page = atoul(sep->arg[0]);
  2734. client->SearchStore(page);
  2735. }
  2736. break;
  2737. }
  2738. case COMMAND_SEARCH_STORES:{
  2739. if(sep && sep->arg[0][0]){
  2740. const char* values = sep->argplus[0];
  2741. if(values){
  2742. map<string, string> str_values = TranslateBrokerRequest(values);
  2743. vector<Item*>* items = master_item_list.GetItems(str_values);
  2744. if(items){
  2745. client->SetItemSearch(items);
  2746. client->SearchStore(0);
  2747. }
  2748. }
  2749. }
  2750. break;
  2751. }
  2752. case COMMAND_LUADEBUG:{
  2753. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "start") == 0){
  2754. client->SetLuaDebugClient(true);
  2755. if(lua_interface)
  2756. lua_interface->UpdateDebugClients(client);
  2757. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will now receive LUA error messages.");
  2758. }
  2759. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "stop") == 0){
  2760. client->SetLuaDebugClient(false);
  2761. if(lua_interface)
  2762. lua_interface->RemoveDebugClients(client);
  2763. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will no longer receive LUA error messages.");
  2764. }
  2765. else{
  2766. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /luadebug {start | stop}");
  2767. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will allow you to receive lua debug messages normally seen only in the console.");
  2768. }
  2769. break;
  2770. }
  2771. case COMMAND_SPAWN_GROUP:
  2772. {
  2773. Spawn* target = cmdTarget;
  2774. if(target && target->IsPlayer() == false)
  2775. {
  2776. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "create") == 0)
  2777. {
  2778. if(target->GetSpawnLocationPlacementID() > 0)
  2779. {
  2780. if(sep->arg[1] && !sep->IsNumber(1) && strlen(sep->arg[1]) > 0)
  2781. {
  2782. int32 id = database.CreateSpawnGroup(target, sep->arg[1]);
  2783. if(id > 0)
  2784. client->Message(CHANNEL_COLOR_YELLOW, "Successfully created new spawn group with id: %u", id);
  2785. else
  2786. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error creating group, check console for details.");
  2787. target->SetSpawnGroupID(id);
  2788. target->AddSpawnToGroup(target);
  2789. }
  2790. else
  2791. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group create [name]");
  2792. }
  2793. else
  2794. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Could not use spawn to create a new group. Likely cause would be a newly spawned spawn that did not exist when /reload spawns was last used.");
  2795. }
  2796. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "add") == 0)
  2797. {
  2798. if(sep->arg[1] && sep->IsNumber(1))
  2799. {
  2800. int32 group_id = atoul(sep->arg[1]);
  2801. Spawn* leader = client->GetCurrentZone()->GetSpawnGroup(group_id);
  2802. if(leader)
  2803. {
  2804. leader->AddSpawnToGroup(target);
  2805. target->SetSpawnGroupID(group_id);
  2806. if(database.SpawnGroupAddSpawn(target, group_id))
  2807. client->Message(CHANNEL_COLOR_YELLOW, "Successfully added '%s' to group id: %u", target->GetName(), group_id);
  2808. else
  2809. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error adding spawn to group, check console for details.");
  2810. }
  2811. else
  2812. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No spawns found in the current zone for that spawn group, be sure to use '/spawn group create' first!");
  2813. }
  2814. else
  2815. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group add [group id]");
  2816. }
  2817. else if(target->GetSpawnGroupID() == 0)
  2818. {
  2819. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That spawn is not in a group!");
  2820. }
  2821. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "remove") == 0)
  2822. {
  2823. int32 group_id = target->GetSpawnGroupID();
  2824. target->RemoveSpawnFromGroup();
  2825. if(database.SpawnGroupRemoveSpawn(target, group_id))
  2826. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed '%s' from group id: %u", target->GetName(), group_id);
  2827. else
  2828. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing spawn from group, check console for details.");
  2829. }
  2830. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "associate") == 0)
  2831. {
  2832. int32 group_id = target->GetSpawnGroupID();
  2833. if(sep->arg[1] && sep->IsNumber(1))
  2834. {
  2835. if(database.SpawnGroupAddAssociation(group_id, atoul(sep->arg[1])))
  2836. client->Message(CHANNEL_COLOR_YELLOW, "Successfully associated group id %u with group id %u", group_id, atoul(sep->arg[1]));
  2837. else
  2838. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error associating groups, check console for details.");
  2839. }
  2840. else
  2841. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Allows you to spawn only one associated group at once. Syntax: /spawn group associate [other group id]");
  2842. }
  2843. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "deassociate") == 0)
  2844. {
  2845. int32 group_id = target->GetSpawnGroupID();
  2846. if(sep->arg[1] && sep->IsNumber(1))
  2847. {
  2848. if(database.SpawnGroupRemoveAssociation(group_id, atoul(sep->arg[1])))
  2849. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed association between group id %u and group id %u", group_id, atoul(sep->arg[1]));
  2850. else
  2851. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing group associations, check console for details.");
  2852. }
  2853. else
  2854. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Removes previous group associations. Syntax: /spawn group deassociate [other group id]");
  2855. }
  2856. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "chance") == 0)
  2857. {
  2858. if(sep->arg[1] && sep->IsNumber(1))
  2859. {
  2860. if(database.SetGroupSpawnChance(target->GetSpawnGroupID(), atof(sep->arg[1])))
  2861. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set group spawn chance to %f for group id: %u", atof(sep->arg[1]), target->GetSpawnGroupID());
  2862. else
  2863. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error setting group spawn chance, check console for details.");
  2864. }
  2865. else
  2866. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group chance [group's spawn chance percentage]");
  2867. }
  2868. else
  2869. {
  2870. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command allows you to modify spawn groups.");
  2871. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group [create/add/remove/chance/associate/deassociate]");
  2872. }
  2873. }
  2874. else
  2875. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select a valid spawn to use this command.");
  2876. break;
  2877. }
  2878. case COMMAND_SPAWN_COMBINE:{
  2879. Spawn* spawn = cmdTarget;
  2880. float radius = 0;
  2881. bool failed = true;
  2882. if(spawn && !spawn->IsPlayer() && sep && sep->arg[0] && sep->arg[0][0]){
  2883. failed = false;
  2884. if(spawn->GetSpawnGroupID() > 0){
  2885. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Can not combine this spawn as it is in a spawn group. Remove it from the group and try again.");
  2886. }
  2887. else if(sep->IsNumber(0)){
  2888. radius = atof(sep->arg[0]);
  2889. client->CombineSpawns(radius, spawn);
  2890. }
  2891. else{
  2892. if(strncasecmp(sep->arg[0], "add", 3) == 0){
  2893. client->AddCombineSpawn(spawn);
  2894. }
  2895. else if(strncasecmp(sep->arg[0], "remove", 6) == 0){
  2896. client->RemoveCombineSpawn(spawn);
  2897. }
  2898. else if(strncasecmp(sep->arg[0], "save", 4) == 0){
  2899. const char* name = 0;
  2900. if(sep->arg[1] && sep->arg[1][0])
  2901. name = sep->argplus[1];
  2902. client->SaveCombineSpawns(name);
  2903. }
  2904. else
  2905. failed = true;
  2906. }
  2907. }
  2908. if(failed){
  2909. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command combines several spawns into a single spawn group.");
  2910. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn combine [radius/add/remove/save]");
  2911. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Ex: /spawn combine 1, /spawn combine save (spawn group name)");
  2912. }
  2913. break;
  2914. }
  2915. case COMMAND_SPAWN_CREATE:{
  2916. Spawn* spawn = 0;
  2917. if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "object", 6) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  2918. spawn = new Object();
  2919. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  2920. }
  2921. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "groundspawn", 11) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  2922. spawn = new GroundSpawn();
  2923. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  2924. }
  2925. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "sign", 4) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  2926. spawn = new Sign();
  2927. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  2928. }
  2929. else if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "npc", 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  2930. spawn = new NPC();
  2931. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  2932. spawn->appearance.pos.collision_radius = 32;
  2933. spawn->secondary_command_list_id = 0;
  2934. spawn->primary_command_list_id = 0;
  2935. spawn->appearance.display_name = 1;
  2936. spawn->appearance.show_level = 1;
  2937. spawn->appearance.attackable = 1;
  2938. }
  2939. else{
  2940. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn create [spawn type] [race type] [class type] [level] [name] (difficulty) (size)");
  2941. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are required except difficulty and size. Valid types are Object, NPC, Sign, or GroundSpawn");
  2942. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn create npc 203 1 50 'Lady Vox' 1 32");
  2943. break;
  2944. }
  2945. spawn->SetID(Spawn::NextID());
  2946. spawn->SetX(client->GetPlayer()->GetX());
  2947. spawn->SetY(client->GetPlayer()->GetY());
  2948. spawn->SetZ(client->GetPlayer()->GetZ());
  2949. spawn->SetHeading(client->GetPlayer()->GetHeading());
  2950. spawn->SetSpawnOrigX(spawn->GetX());
  2951. spawn->SetSpawnOrigY(spawn->GetY());
  2952. spawn->SetSpawnOrigZ(spawn->GetZ());
  2953. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  2954. spawn->appearance.targetable = 1;
  2955. spawn->appearance.race = 255;
  2956. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  2957. spawn->SetModelType(atoi(sep->arg[1]));
  2958. spawn->SetAdventureClass(atoi(sep->arg[2]));
  2959. spawn->SetLevel(atoi(sep->arg[3]));
  2960. spawn->SetName(sep->arg[4]);
  2961. if(sep->arg[5][0] && sep->IsNumber(5))
  2962. spawn->SetEncounterLevel(atoi(sep->arg[5]));
  2963. if(sep->arg[6][0] && sep->IsNumber(6))
  2964. spawn->size = atoi(sep->arg[6]);
  2965. if(spawn->GetTotalHP() == 0){
  2966. spawn->SetTotalHP(25*spawn->GetLevel() + 1);
  2967. spawn->SetHP(25*spawn->GetLevel() + 1);
  2968. }
  2969. if(spawn->GetTotalPower() == 0){
  2970. spawn->SetTotalPower(25*spawn->GetLevel() + 1);
  2971. spawn->SetPower(25*spawn->GetLevel() + 1);
  2972. }
  2973. client->GetCurrentZone()->AddSpawn(spawn);
  2974. break;
  2975. }
  2976. case COMMAND_SPAWN_EQUIPMENT:{
  2977. Spawn* spawn = cmdTarget;
  2978. if(spawn && sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1) && spawn->IsEntity()){
  2979. int8 slot = atoi(sep->arg[0]);
  2980. int16 type = atoi(sep->arg[1]);
  2981. int8 red = 0;
  2982. int8 green = 0;
  2983. int8 blue = 0;
  2984. int8 h_red = 0;
  2985. int8 h_green = 0;
  2986. int8 h_blue = 0;
  2987. if(sep->arg[2])
  2988. red = atoi(sep->arg[2]);
  2989. if(sep->arg[3])
  2990. green = atoi(sep->arg[3]);
  2991. if(sep->arg[4])
  2992. blue = atoi(sep->arg[4]);
  2993. if(sep->arg[5])
  2994. h_red = atoi(sep->arg[5]);
  2995. if(sep->arg[6])
  2996. h_green = atoi(sep->arg[6]);
  2997. if(sep->arg[7])
  2998. h_blue = atoi(sep->arg[7]);
  2999. ((Entity*)spawn)->SetEquipment(slot, type, red, green, blue, h_red, h_green, h_blue);
  3000. database.SaveNPCAppearanceEquipment(spawn->GetDatabaseID() , slot, type, red, green, blue, h_red, h_green, h_blue);
  3001. }
  3002. else{
  3003. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn equipment [slot] [appearance id] (red) (green) (blue) (highlight red) (hgreen) (hblue)");
  3004. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn's equipment. ");
  3005. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Slot is 0-24, Appearance ID from appearances table, Colors are 0-255");
  3006. }
  3007. break;
  3008. }
  3009. case COMMAND_SPAWN_DETAILS:{
  3010. Spawn* spawn = cmdTarget;
  3011. if(spawn){
  3012. const char* type = "NPC";
  3013. if(spawn->IsObject())
  3014. type = "Object";
  3015. else if(spawn->IsSign())
  3016. type = "Sign";
  3017. else if(spawn->IsWidget())
  3018. type = "Widget";
  3019. else if(spawn->IsGroundSpawn())
  3020. type = "GroundSpawn";
  3021. client->Message(CHANNEL_COLOR_YELLOW, "Name: %s, %s ID: %u", spawn->GetName(), type, spawn->GetDatabaseID());
  3022. client->Message(CHANNEL_COLOR_YELLOW, "Last Name: %s, Sub-Title: %s, Prefix: %s, Suffix: %s", spawn->GetLastName(), spawn->GetSubTitle(), spawn->GetPrefixTitle(), spawn->GetSuffixTitle());
  3023. client->Message(CHANNEL_COLOR_YELLOW, "Spawn Location ID: %u, Spawn Group ID: %u", spawn->GetSpawnLocationID(), spawn->GetSpawnGroupID());
  3024. client->Message(CHANNEL_COLOR_YELLOW, "Faction ID: %u, Merchant ID: %u, Transporter ID: %u", spawn->GetFactionID(), spawn->GetMerchantID(), spawn->GetTransporterID());
  3025. client->Message(CHANNEL_COLOR_YELLOW, "Grid ID: %u", spawn->GetLocation());
  3026. client->Message(CHANNEL_COLOR_YELLOW, "Race: %i, Class: %i, Gender: %i", spawn->GetRace(), spawn->GetAdventureClass(), spawn->GetGender());
  3027. client->Message(CHANNEL_COLOR_YELLOW, "Level: %i, HP: %u, Power: %u", spawn->GetLevel(), spawn->GetHP(), spawn->GetPower());
  3028. client->Message(CHANNEL_COLOR_YELLOW, "Respawn Time: %u (sec), X: %f, Y: %f, Z: %f Heading: %f", spawn->GetRespawnTime(), spawn->GetX(), spawn->GetY(), spawn->GetZ(), spawn->GetHeading());
  3029. client->Message(CHANNEL_COLOR_YELLOW, "Collision Radius: %i, Size: %i, Difficulty: %i, Heroic: %i", spawn->GetCollisionRadius(), spawn->GetSize(), spawn->GetEncounterLevel(), spawn->GetHeroic());
  3030. client->Message(CHANNEL_COLOR_YELLOW, "Targetable: %i, Show Name: %i, Attackable: %i, Show Level: %i", spawn->GetTargetable(), spawn->GetShowName(), spawn->GetAttackable(), spawn->GetShowLevel());
  3031. client->Message(CHANNEL_COLOR_YELLOW, "Show Command Icon: %i, Display Hand Icon: %i", spawn->GetShowCommandIcon(), spawn->GetShowHandIcon());
  3032. if(spawn->IsEntity()){
  3033. client->Message(CHANNEL_COLOR_YELLOW, "Facial Hair Type: %i, Hair Type: %i, Chest Type: %i, Legs Type: %i", ((Entity*)spawn)->GetFacialHairType(), ((Entity*)spawn)->GetHairType(), ((Entity*)spawn)->GetChestType(), ((Entity*)spawn)->GetLegsType());
  3034. client->Message(CHANNEL_COLOR_YELLOW, "Soga Facial Hair Type: %i, Soga Hair Type: %i, Wing Type: %i", ((Entity*)spawn)->GetSogaFacialHairType(), ((Entity*)spawn)->GetSogaHairType(), ((Entity*)spawn)->GetWingType());
  3035. }
  3036. client->Message(CHANNEL_COLOR_YELLOW, "Model Type: %i, Soga Race Type: %i", spawn->GetModelType(), spawn->GetSogaModelType());
  3037. client->Message(CHANNEL_COLOR_YELLOW, "Primary Command Type: %u, Secondary Command Type: %u", spawn->GetPrimaryCommandListID(), spawn->GetSecondaryCommandListID());
  3038. client->Message(CHANNEL_COLOR_YELLOW, "Visual State: %i, Action State: %i, Mood State: %i, Initial State: %i, Activity Status: %i", spawn->GetVisualState(), spawn->GetActionState(), spawn->GetMoodState(), spawn->GetInitialState(), spawn->GetActivityStatus());
  3039. client->Message(CHANNEL_COLOR_YELLOW, "Emote State: %i, Pitch: %f, Roll: %f, Hide Hood: %i", spawn->GetEmoteState(), spawn->GetPitch(), spawn->GetRoll(), spawn->appearance.hide_hood);
  3040. if (spawn->IsNPC())
  3041. client->Message(CHANNEL_COLOR_YELLOW, "Randomize: %u", ((NPC*)spawn)->GetRandomize());
  3042. PacketStruct* packet = configReader.getStruct("WS_EqShowBook", client->GetVersion());
  3043. if (packet) {
  3044. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  3045. string title = string(spawn->GetName()) + "(" + to_string(spawn->GetDatabaseID()) + ")";
  3046. packet->setDataByName("book_title", title.c_str());
  3047. packet->setDataByName("book_type", "simple");
  3048. packet->setDataByName("unknown2", 1);
  3049. packet->setDataByName("unknown5", 1, 4);
  3050. packet->setArrayLengthByName("num_pages", 4);
  3051. string details;
  3052. details += "\\#0000FFName: " + string(spawn->GetName()) + "\n";
  3053. details += "Type: " + string(type) + "\n";
  3054. details += "ID: " + to_string(spawn->GetDatabaseID()) + "\n";
  3055. details += "Last Name: " + string(spawn->GetLastName()) + "\n";
  3056. details += "Sub-Title: " + string(spawn->GetSubTitle()) + "\n";
  3057. details += "Prefix: " + string(spawn->GetPrefixTitle()) + "\n";
  3058. details += "Suffix: " + string(spawn->GetSuffixTitle()) + "\n";
  3059. details += "Race: " + to_string(spawn->GetRace()) + "\n";
  3060. details += "Class: " + to_string(spawn->GetAdventureClass()) + "\n";
  3061. details += "Gender: " + to_string(spawn->GetGender()) + "\n";
  3062. details += "Level: " + to_string(spawn->GetLevel()) + "\n";
  3063. details += "HP: " + to_string(spawn->GetHP()) + "\n";
  3064. details += "Power: " + to_string(spawn->GetPower()) + "\n";
  3065. details += "Difficulty: " + to_string(spawn->GetEncounterLevel()) + "\n";
  3066. details += "Heroic: " + to_string(spawn->GetHeroic()) + "\n";
  3067. details += "Group ID: " + to_string(spawn->GetSpawnGroupID()) + "\n";
  3068. details += "Faction ID: " + to_string(spawn->GetFactionID()) + "\n";
  3069. details += "Merchant ID: " + to_string(spawn->GetMerchantID()) + "\n";
  3070. details += "Transport ID: " + to_string(spawn->GetTransporterID()) + "\n";
  3071. details += "Location ID: " + to_string(spawn->GetSpawnLocationID()) + "\n";
  3072. char x[16];
  3073. sprintf(x, "%.2f", spawn->GetX());
  3074. char y[16];
  3075. sprintf(y, "%.2f", spawn->GetY());
  3076. char z[16];
  3077. sprintf(z, "%.2f", spawn->GetZ());
  3078. details += "Location: " + string(x) + ", " + string(y) + ", " + string(z) + "\n";
  3079. string details2;
  3080. details2 += "Heading: " + to_string(spawn->GetHeading()) + "\n";
  3081. details2 += "Grid ID: " + to_string(spawn->GetLocation()) + "\n";
  3082. details2 += "Size: " + to_string(spawn->GetSize()) + "\n";
  3083. details2 += "Collision Radius: " + to_string(spawn->GetCollisionRadius()) + "\n";
  3084. details2 += "Respawn Time: " + to_string(spawn->GetRespawnTime()) + "\n";
  3085. details2 += "Targetable: " + to_string(spawn->GetTargetable()) + "\n";
  3086. details2 += "Show Name: " + to_string(spawn->GetShowName()) + "\n";
  3087. details2 += "Attackable: " + to_string(spawn->GetAttackable()) + "\n";
  3088. details2 += "Show Level: " + to_string(spawn->GetShowLevel()) + "\n";
  3089. details2 += "Show Command Icon: " + to_string(spawn->GetShowCommandIcon()) + "\n";
  3090. details2 += "Display Hand Icon: " + to_string(spawn->GetShowHandIcon()) + "\n";
  3091. details2 += "Model Type: " + to_string(spawn->GetModelType()) + "\n";
  3092. details2 += "Soga Race Type: " + to_string(spawn->GetSogaModelType()) + "\n";
  3093. details2 += "Primary Command ID: " + to_string(spawn->GetPrimaryCommandListID()) + "\n";
  3094. details2 += "Secondary Cmd ID: " + to_string(spawn->GetSecondaryCommandListID()) + "\n";
  3095. details2 += "Visual State: " + to_string(spawn->GetVisualState()) + "\n";
  3096. details2 += "Action State: " + to_string(spawn->GetActionState()) + "\n";
  3097. details2 += "Mood State: " + to_string(spawn->GetMoodState()) + "\n";
  3098. details2 += "Initial State: " + to_string(spawn->GetInitialState()) + "\n";
  3099. details2 += "Activity Status: " + to_string(spawn->GetActivityStatus()) + "\n";
  3100. details2 += "Emote State: " + to_string(spawn->GetEmoteState()) + "\n";
  3101. string details3;
  3102. details3 += "Pitch: " + to_string(spawn->GetPitch()) + "\n";
  3103. details3 += "Roll: " + to_string(spawn->GetRoll()) + "\n";
  3104. details3 += "Hide Hood: " + to_string(spawn->appearance.hide_hood) + "\n";
  3105. string details4;
  3106. if (spawn->IsEntity()) {
  3107. details4 += "Facial Hair Type: " + to_string(((Entity*)spawn)->GetFacialHairType()) + "\n";
  3108. details4 += "Hair Type: " + to_string(((Entity*)spawn)->GetHairType()) + "\n";
  3109. details4 += "Chest Type: " + to_string(((Entity*)spawn)->GetChestType()) + "\n";
  3110. details4 += "Legs Type: " + to_string(((Entity*)spawn)->GetLegsType()) + "\n";
  3111. details4 += "Soga Facial Hair Type: " + to_string(((Entity*)spawn)->GetSogaFacialHairType()) + "\n";
  3112. details4 += "Soga Hair Type: " + to_string(((Entity*)spawn)->GetSogaHairType()) + "\n";
  3113. details4 += "Wing Type: " + to_string(((Entity*)spawn)->GetWingType()) + "\n";
  3114. if (spawn->IsNPC()) {
  3115. details4 += "\nRandomize: " + to_string(((NPC*)spawn)->GetRandomize()) + "\n";
  3116. }
  3117. }
  3118. //details2 += "" + to_string() + "\n";
  3119. packet->setArrayDataByName("page_text", details.c_str());
  3120. packet->setArrayDataByName("page_text", details2.c_str(), 1);
  3121. packet->setArrayDataByName("page_text", details3.c_str(), 2);
  3122. packet->setArrayDataByName("page_text", details4.c_str(), 3);
  3123. client->QueuePacket(packet->serialize());
  3124. safe_delete(packet);
  3125. }
  3126. }
  3127. else if (sep && sep->arg[0][0] && sep->IsNumber(0))
  3128. {
  3129. float radius = atof(sep->arg[0]);
  3130. if ( !client->GetCurrentZone()->SendRadiusSpawnInfo(client, radius) )
  3131. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No results in the radius were found.");
  3132. }
  3133. else {
  3134. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn details (radius)");
  3135. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will display information about the currently selected spawn, or in the case of specifying a numerical radius will show minor details about spawns in the players radius.");
  3136. }
  3137. break;
  3138. }
  3139. case COMMAND_SPAWN_TARGET:{
  3140. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  3141. int32 spawn_id = atoul(sep->arg[0]);
  3142. int16 response = client->GetCurrentZone()->SetSpawnTargetable(spawn_id);
  3143. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  3144. }
  3145. else if(sep && sep->arg[0][0] && sep->arg[1][0] && sep->IsNumber(1) && ToLower(string(sep->arg[0])) == "radius"){
  3146. float distance = atof(sep->arg[1]);
  3147. int16 response = client->GetCurrentZone()->SetSpawnTargetable(client->GetPlayer(), distance);
  3148. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  3149. }
  3150. else{
  3151. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn target [spawn id]");
  3152. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn as targetable. Used to change a spawn if it was set to untargetable.");
  3153. }
  3154. break;
  3155. }
  3156. case COMMAND_SPAWN_SET:
  3157. {
  3158. Spawn* spawn = cmdTarget;
  3159. sint16 set_type = -1;
  3160. string type_str;
  3161. if (spawn)
  3162. {
  3163. // check if parameters are (location or list or not player and not a 2nd param), and that there is at least 1 value
  3164. if(sep && ((sep->arg[0][0] && ToLower(string(sep->arg[0])) == "location") || (sep->arg[0][0] && ToLower(string(sep->arg[0])) == "list") || (spawn && spawn->IsPlayer() == false && sep->arg[1][0])) && spawn_set_values.count(ToLower(string(sep->arg[0]))) == 1)
  3165. {
  3166. // set the type, which will be 0 if location or list or invalid
  3167. set_type = spawn_set_values[ToLower(string(sep->arg[0]))];
  3168. }
  3169. if(set_type > 0)
  3170. {
  3171. // check if spawn set is NOT a char update, or not location, or isn't a number
  3172. if(!(set_type >= SPAWN_SET_VALUE_PREFIX) && !(set_type <= SPAWN_SET_VALUE_LASTNAME) && set_type != SPAWN_SET_VALUE_NAME && ((set_type < SPAWN_SET_VALUE_SPAWN_SCRIPT) || (set_type > SPAWN_SET_VALUE_SUB_TITLE)) && set_type != SPAWN_SET_VALUE_LOCATION && sep->IsNumber(1) == false)
  3173. {
  3174. client->SimpleMessage(CHANNEL_COLOR_RED, "Invalid value for set command.");
  3175. }
  3176. else
  3177. {
  3178. string name = string(spawn->GetName());
  3179. if(SetSpawnCommand(client, spawn, set_type, sep->arg[1]))
  3180. {
  3181. if(set_type == SPAWN_SET_VALUE_NAME)
  3182. {
  3183. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "New name will not be effective until zone reload.");
  3184. }
  3185. else if(set_type == SPAWN_SET_VALUE_LOCATION)
  3186. {
  3187. spawn->SetLocation(client->GetPlayer()->GetLocation());
  3188. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set '%s' to '%u' for spawn '%s'", sep->arg[0], client->GetPlayer()->GetLocation(), name.c_str());
  3189. }
  3190. else
  3191. {
  3192. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set '%s' to '%s' for spawn '%s'", sep->arg[0], sep->arg[1], name.c_str());
  3193. }
  3194. if(set_type != SPAWN_SET_VALUE_FACTION)
  3195. {
  3196. client->GetCurrentZone()->ApplySetSpawnCommand(client, spawn, set_type, sep->arg[1]);
  3197. }
  3198. if((set_type >= SPAWN_SET_VALUE_RESPAWN && set_type <=SPAWN_SET_VALUE_LOCATION) || (set_type >= SPAWN_SET_VALUE_EXPIRE && set_type <=SPAWN_SET_VALUE_Z_OFFSET) || (set_type == SPAWN_SET_VALUE_PITCH || set_type == SPAWN_SET_VALUE_ROLL))
  3199. {
  3200. if(spawn->GetSpawnLocationID() > 0 && database.UpdateSpawnLocationSpawns(spawn))
  3201. {
  3202. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information.");
  3203. }
  3204. else if(spawn->GetSpawnLocationID() > 0)
  3205. {
  3206. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn information, see console window for details.");
  3207. }
  3208. }
  3209. else
  3210. {
  3211. if(spawn->GetDatabaseID() > 0 && database.SaveSpawnInfo(spawn))
  3212. {
  3213. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully saved spawn.");
  3214. }
  3215. else if(spawn->GetDatabaseID() > 0)
  3216. {
  3217. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn, see console window for details.");
  3218. }
  3219. }
  3220. }
  3221. }
  3222. }
  3223. else if(set_type == 0)
  3224. {
  3225. // /spawn set list - lists all possible attributes that can be changed with this command, 10 per line.
  3226. map<string, int8>::iterator itr;
  3227. int i=0;
  3228. string list;
  3229. for(itr = spawn_set_values.begin(); itr != spawn_set_values.end(); itr++, i++)
  3230. {
  3231. if(i==10)
  3232. {
  3233. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  3234. i = 0;
  3235. }
  3236. if(i>0)
  3237. {
  3238. list.append(", ").append(itr->first);
  3239. }
  3240. else
  3241. {
  3242. list = itr->first;
  3243. }
  3244. }
  3245. if(list.length() > 0)
  3246. {
  3247. // if 1 or more, display in client.
  3248. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  3249. }
  3250. }
  3251. else
  3252. {
  3253. // syntax fail
  3254. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn set [type] [value]");
  3255. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used to change various settings for the targeted NPC or Object.");
  3256. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "For a list of changeable settings use /spawn set list");
  3257. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Note: /spawn set location does not require a value. The client's current location is used.");
  3258. }
  3259. }
  3260. break;
  3261. }
  3262. case COMMAND_SPAWN_REMOVE:{
  3263. Spawn* spawn = cmdTarget;
  3264. if(spawn && !spawn->IsPlayer()){
  3265. if(spawn->GetSpawnLocationID() > 0){
  3266. if(database.RemoveSpawnFromSpawnLocation(spawn)){
  3267. bool delete_spawn = false;
  3268. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  3269. if(atoi(sep->arg[0]) == 1)
  3270. delete_spawn = true;
  3271. }
  3272. if(delete_spawn)
  3273. client->GetCurrentZone()->RemoveSpawn(false, spawn, true, false);
  3274. else
  3275. spawn->SetSpawnLocationID(0);
  3276. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully removed spawn from zone");
  3277. }
  3278. else
  3279. client->SimpleMessage(CHANNEL_COLOR_RED, "Error removing spawn, see console window for details.");
  3280. }
  3281. else
  3282. client->SimpleMessage(CHANNEL_COLOR_RED, "This spawn does not have a spawn group associated with it");
  3283. }
  3284. else{
  3285. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn remove");
  3286. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for removing the targeted NPC or Object from the zone.");
  3287. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Optionally, you can supply a 1 after the command to despawn it as well. IE /spawn remove 1");
  3288. }
  3289. break;
  3290. }
  3291. case COMMAND_SPAWN_LIST:{
  3292. if(sep && sep->arg[0][0]){
  3293. vector<string>* results = database.GetSpawnNameList(sep->argplus[0]);
  3294. vector<string>::iterator itr;
  3295. if(results){
  3296. for(itr=results->begin();itr!=results->end();itr++){
  3297. client->SimpleMessage(CHANNEL_COLOR_YELLOW, (*itr).c_str());
  3298. }
  3299. safe_delete(results);
  3300. }
  3301. else
  3302. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found. ");
  3303. }
  3304. else{
  3305. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn list [name]");
  3306. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Name can be a partial match.");
  3307. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn list Qeynos Guard");
  3308. }
  3309. break;
  3310. }
  3311. case COMMAND_SPAWN_ADD:{
  3312. Spawn* spawn = cmdTarget;
  3313. if(spawn && sep && sep->arg[1][0] && (sep->IsNumber(0) || strncasecmp(sep->arg[0], "new", 3) == 0)){
  3314. if(spawn->GetSpawnLocationID() > 0){
  3315. client->Message(CHANNEL_COLOR_RED, "This spawn already has a spawn group id of %u, use /spawn remove to reassign it", spawn->GetSpawnLocationID());
  3316. break;
  3317. }
  3318. if(spawn->GetDatabaseID() == 0){
  3319. if(database.SaveSpawnInfo(spawn)) {
  3320. char spawn_type[32];
  3321. memset(spawn_type, 0, sizeof(spawn_type));
  3322. if (spawn->IsNPC())
  3323. strncpy(spawn_type, "NPC", sizeof(spawn_type) - 1);
  3324. else if (spawn->IsObject())
  3325. strncpy(spawn_type, "Object", sizeof(spawn_type) - 1);
  3326. else if (spawn->IsSign())
  3327. strncpy(spawn_type, "Sign", sizeof(spawn_type) - 1);
  3328. else if (spawn->IsGroundSpawn())
  3329. strncpy(spawn_type, "GroundSpawn", sizeof(spawn_type) - 1);
  3330. else
  3331. strncpy(spawn_type, "Unknown", sizeof(spawn_type) - 1);
  3332. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information with a %s id of %u", spawn_type, spawn->GetDatabaseID());
  3333. }
  3334. else
  3335. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn information, see console window for details.");
  3336. }
  3337. int32 spawn_group_id = 0;
  3338. if(strncasecmp(sep->arg[0], "new", 3) == 0)
  3339. spawn_group_id = database.GetNextSpawnLocation();
  3340. else
  3341. spawn_group_id = atol(sep->arg[0]);
  3342. int8 percent = 100;
  3343. if(sep->arg[2] && sep->IsNumber(2))
  3344. percent = atoi(sep->arg[2]);
  3345. spawn->SetSpawnLocationID(spawn_group_id);
  3346. float x_offset = database.GetSpawnLocationPlacementOffsetX(spawn->GetSpawnLocationID());
  3347. float y_offset = database.GetSpawnLocationPlacementOffsetY(spawn->GetSpawnLocationID());
  3348. float z_offset = database.GetSpawnLocationPlacementOffsetZ(spawn->GetSpawnLocationID());
  3349. if(database.SaveSpawnEntry(spawn, sep->arg[1], percent, x_offset, y_offset, z_offset))
  3350. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn location with a spawn group of %u", spawn->GetSpawnLocationID());
  3351. else
  3352. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn location, see console window for details.");
  3353. }
  3354. else{
  3355. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn add [spawn group id] [spawn group name] (percentage)");
  3356. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for adding the targeted NPC or Object to the database.");
  3357. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can substitute new for [spawn group id] to create a new one.");
  3358. }
  3359. break;
  3360. }
  3361. case COMMAND_SPAWN:{
  3362. int32 id = 0;
  3363. Spawn* spawn = 0;
  3364. if(sep && sep->arg[0] && sep->IsNumber(0)){
  3365. id = atol(sep->arg[0]);
  3366. spawn = client->GetCurrentZone()->GetSpawn(id);
  3367. }
  3368. if(id > 0 && spawn && spawn->appearance.name[0] == 0)
  3369. id = 0;
  3370. if(!id || !spawn){
  3371. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn [spawn id] (x) (y) (z) (heading) (location)");
  3372. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are optional except the id. The spawn id must be in the database.");
  3373. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn 1 0 0 0 0");
  3374. safe_delete(sep);
  3375. return;
  3376. }
  3377. if(sep && sep->arg[1][0]){
  3378. float x = atof(sep->arg[1]);
  3379. spawn->appearance.pos.X = x;
  3380. }
  3381. else
  3382. spawn->SetX(client->GetPlayer()->GetX(), false);
  3383. if(sep && sep->arg[2][0]){
  3384. float y = atof(sep->arg[2]);
  3385. spawn->appearance.pos.Y = y;
  3386. }
  3387. else
  3388. spawn->SetY(client->GetPlayer()->GetY(), false);
  3389. if(sep && sep->arg[3][0]){
  3390. float z = atof(sep->arg[3]);
  3391. spawn->appearance.pos.Z = z;
  3392. }
  3393. else
  3394. spawn->SetZ(client->GetPlayer()->GetZ(), false);
  3395. if(sep && sep->arg[4][0]){
  3396. float heading = atof(sep->arg[4]);
  3397. spawn->SetHeading(heading);
  3398. }
  3399. else
  3400. spawn->SetHeading(client->GetPlayer()->GetHeading(), false);
  3401. spawn->SetSpawnOrigX(spawn->GetX());
  3402. spawn->SetSpawnOrigY(spawn->GetY());
  3403. spawn->SetSpawnOrigZ(spawn->GetZ());
  3404. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  3405. if(sep && sep->arg[5][0])
  3406. spawn->appearance.pos.grid_id = atol(sep->arg[5]);
  3407. else
  3408. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  3409. if(spawn->IsNPC() && spawn->GetTotalHP() == 0){
  3410. spawn->SetTotalHP(spawn->GetLevel() * 15);
  3411. spawn->SetHP(spawn->GetTotalHP());
  3412. }
  3413. if(spawn->GetTotalPower() == 0){
  3414. spawn->SetTotalPower(spawn->GetLevel() * 15);
  3415. spawn->SetPower(spawn->GetTotalPower());
  3416. }
  3417. const char* script = world.GetSpawnScript(id);
  3418. if(script && lua_interface && lua_interface->GetSpawnScript(script) != 0)
  3419. spawn->SetSpawnScript(string(script));
  3420. client->GetCurrentZone()->AddSpawn(spawn);
  3421. if(spawn->IsNPC())
  3422. spawn->GetZone()->AddLoot((NPC*)spawn);
  3423. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_SPAWN);
  3424. LogWrite(COMMAND__INFO, 0, "Command", "Received spawn command - Parms: %s", command_parms->data.c_str());
  3425. break;
  3426. }
  3427. case COMMAND_ADMINFLAG:
  3428. {
  3429. if(sep && sep->arg[0]){
  3430. sint16 tmp_status = database.GetCharacterAdminStatus(sep->arg[0]);
  3431. sint16 new_status = atoi(sep->arg[1]);
  3432. if(tmp_status == -10)
  3433. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character does not exist.");
  3434. else if(tmp_status >= client->GetAdminStatus())
  3435. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character has same or higher level status.");
  3436. else if (new_status > client->GetAdminStatus())
  3437. client->SimpleMessage(CHANNEL_ERROR, "Unable to flag character. Reason: New status is higher then your status.");
  3438. else{
  3439. Client* client2 = client->GetCurrentZone()->GetClientByName(sep->arg[0]);
  3440. if (!client2)
  3441. client2 = zone_list.GetClientByCharName(sep->arg[0]);
  3442. if(database.UpdateAdminStatus(sep->arg[0],new_status)) {
  3443. client->Message(CHANNEL_COLOR_YELLOW,"Character status updated to %i for %s.",new_status,sep->arg[0]);
  3444. if (client2) {
  3445. client2->SetAdminStatus(new_status);
  3446. client2->Message(CHANNEL_COLOR_YELLOW, "%s has set your admin status to %i.", client->GetPlayer()->GetName(), new_status);
  3447. }
  3448. }
  3449. else
  3450. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Unknown reason.");
  3451. }
  3452. }else{
  3453. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /flag {name} {new_status}");
  3454. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Standard User: 0");
  3455. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Admin User: 100");
  3456. }
  3457. break;
  3458. }
  3459. case COMMAND_CANNEDEMOTE:{
  3460. client->GetCurrentZone()->HandleEmote(client, command_parms->data);
  3461. break;
  3462. }
  3463. case COMMAND_BROADCAST: {
  3464. if (sep && sep->arg[0])
  3465. zone_list.HandleGlobalBroadcast(sep->argplus[0]);
  3466. else
  3467. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /broadcast {message}");
  3468. break;
  3469. }
  3470. case COMMAND_ANNOUNCE: {
  3471. if (sep && sep->arg[0])
  3472. zone_list.HandleGlobalAnnouncement(sep->argplus[0]);
  3473. else
  3474. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /announce {message}");
  3475. break;
  3476. }
  3477. case COMMAND_RELOAD_ITEMS:{
  3478. LogWrite(COMMAND__INFO, 0, "Command", "Reloading items..");
  3479. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Started Reloading items (this might take a few minutes...)");
  3480. database.ReloadItemList();
  3481. database.LoadMerchantInformation();
  3482. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Finished Reloading items.");
  3483. break;
  3484. }
  3485. case COMMAND_ENABLE_ABILITY_QUE:{
  3486. EQ2Packet* app = client->GetPlayer()->GetSpellBookUpdatePacket(client->GetVersion());
  3487. if(app)
  3488. client->QueuePacket(app);
  3489. break;
  3490. }
  3491. case COMMAND_ITEMSEARCH:{
  3492. PacketStruct* packet = configReader.getStruct("WS_StartBroker", client->GetVersion());
  3493. if (packet) {
  3494. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  3495. //packet->setDataByName("unknown", 1);
  3496. packet->setDataByName("unknown2", 5, 0);
  3497. packet->setDataByName("unknown2", 20, 1);
  3498. packet->setDataByName("unknown2", 58, 3);
  3499. packet->setDataByName("unknown2", 40, 4);
  3500. client->QueuePacket(packet->serialize());
  3501. PacketStruct* packet2 = configReader.getStruct("WS_BrokerBags", client->GetVersion());
  3502. if (packet2) {
  3503. packet2->setDataByName("char_id", client->GetCharacterID());
  3504. client->QueuePacket(packet2->serialize()); //send this for now, needed to properly clear data
  3505. safe_delete(packet2);
  3506. }
  3507. safe_delete(packet);
  3508. }
  3509. break;
  3510. }
  3511. case COMMAND_ANIMTEST:{
  3512. PacketStruct* command_packet = configReader.getStruct("WS_CannedEmote", client->GetVersion());
  3513. if(command_packet){
  3514. int32 id = client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer());
  3515. if (cmdTarget)
  3516. id = client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget);
  3517. command_packet->setDataByName ( "spawn_id" , id);
  3518. int animID = 1;
  3519. if(sep && sep->arg[0] && sep->IsNumber(0))
  3520. animID = atoi(sep->arg[0]);
  3521. VisualState* vs = NULL;
  3522. if(animID == 0)
  3523. {
  3524. vs = visual_states.FindVisualState(sep->arg[0]);
  3525. }
  3526. char msg[128];
  3527. sprintf(msg,"Animation Test ID: %i",animID);
  3528. command_packet->setMediumStringByName ( "emote_msg" , msg );
  3529. if(vs != NULL)
  3530. command_packet->setDataByName ( "anim_type", vs->GetID ( ) );
  3531. else
  3532. command_packet->setDataByName ( "anim_type", animID );
  3533. command_packet->setDataByName ( "unknown0", 0 );
  3534. EQ2Packet* outapp = command_packet->serialize();
  3535. client->QueuePacket(outapp);
  3536. safe_delete(command_packet);
  3537. }
  3538. break;
  3539. }
  3540. case COMMAND_KICK:
  3541. {
  3542. if( sep == 0 || sep->arg[0] == 0)
  3543. {
  3544. client->SimpleMessage(CHANNEL_COLOR_RED, "/kick [name]");
  3545. }
  3546. else
  3547. {
  3548. Client* kickClient = zone_list.GetClientByCharName(string(sep->arg[0]));
  3549. if ( kickClient == client )
  3550. {
  3551. client->Message(CHANNEL_COLOR_RED, "You can't kick yourself!");
  3552. break;
  3553. }
  3554. else if(kickClient != NULL)
  3555. {
  3556. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  3557. if ( maxStatus >= client->GetAdminStatus( ) || kickClient->GetAdminStatus() >= client->GetAdminStatus() )
  3558. {
  3559. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  3560. break;
  3561. }
  3562. client->Message(CHANNEL_COLOR_RED, "Kicking %s...",sep->arg[0]);
  3563. kickClient->Disconnect();
  3564. }
  3565. else
  3566. {
  3567. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  3568. }
  3569. }
  3570. break;
  3571. }
  3572. case COMMAND_LOCK:
  3573. {
  3574. if( sep != NULL && sep->arg[0] != NULL && sep->IsNumber(0)){
  3575. int worldLocked = atoi(sep->arg[0]);
  3576. net.world_locked = worldLocked;
  3577. if ( worldLocked )
  3578. client->Message(CHANNEL_COLOR_YELLOW,"World server has been locked.");
  3579. else
  3580. client->Message(CHANNEL_COLOR_YELLOW,"World server has been unlocked.");
  3581. }
  3582. else
  3583. client->SimpleMessage(CHANNEL_COLOR_RED, "/lock [0/1]");
  3584. break;
  3585. }
  3586. case COMMAND_BAN:{
  3587. if( sep == 0 || sep->arg[0] == 0 || (sep->arg[1][0] != 0 && !sep->IsNumber(1) ) )
  3588. {
  3589. client->SimpleMessage(CHANNEL_COLOR_RED, "/ban [name] [permanent:0/1]");
  3590. }
  3591. else
  3592. {
  3593. Client* kickClient = zone_list.GetClientByCharName(sep->arg[0]);
  3594. if ( kickClient == client )
  3595. {
  3596. client->Message(CHANNEL_COLOR_RED, "You can't ban yourself!");
  3597. break;
  3598. }
  3599. else if(kickClient != NULL)
  3600. {
  3601. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  3602. if ( maxStatus > client->GetAdminStatus( ) ||
  3603. client->GetAdminStatus ( ) > kickClient->GetAdminStatus ( ) )
  3604. {
  3605. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  3606. break;
  3607. }
  3608. client->Message(CHANNEL_COLOR_RED, "Kicking & Banning %s...",sep->arg[0]);
  3609. int perm = atol(sep->arg[1]);
  3610. if ( perm == 1 )
  3611. database.UpdateAdminStatus(sep->arg[0],-2);
  3612. else
  3613. database.UpdateAdminStatus(sep->arg[0],-1);
  3614. kickClient->Disconnect();
  3615. }
  3616. else
  3617. {
  3618. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  3619. }
  3620. }
  3621. break;
  3622. }
  3623. case COMMAND_SET_COMBAT_VOICE:{
  3624. int32 value = 0;
  3625. if(sep && sep->arg[0] && sep->IsNumber(0))
  3626. value = atoi(sep->arg[0]);
  3627. client->GetPlayer()->SetCombatVoice(value);
  3628. break;
  3629. }
  3630. case COMMAND_SET_EMOTE_VOICE:{
  3631. int32 value = 0;
  3632. if(sep && sep->arg[0] && sep->IsNumber(0))
  3633. value = atoi(sep->arg[0]);
  3634. client->GetPlayer()->SetEmoteVoice(value);
  3635. break;
  3636. }
  3637. case COMMAND_GIVEITEM:{
  3638. if(sep && sep->arg[0][0] && sep->arg[0][1] && sep->IsNumber(1)){
  3639. Client* itemToClient = zone_list.GetClientByCharName(sep->arg[0]);
  3640. if ( itemToClient == NULL )
  3641. client->Message(CHANNEL_COLOR_YELLOW,"Could not find %s.",sep->arg[0]);
  3642. else
  3643. {
  3644. int32 item_id = atol(sep->arg[1]);
  3645. client->Message(CHANNEL_COLOR_YELLOW,"Gave %s item id %i.",sep->arg[0],item_id);
  3646. itemToClient->AddItem(item_id);
  3647. }
  3648. }
  3649. else
  3650. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /giveitem [name] [item_id]");
  3651. break;
  3652. }
  3653. case COMMAND_REPORT_BUG : { Command_ReportBug(client, sep); break; }
  3654. case COMMAND_INVENTORY : { Command_Inventory(client, sep, command); break; }
  3655. case COMMAND_WEAPONSTATS : { Command_WeaponStats(client); break; }
  3656. case COMMAND_SKILL :
  3657. case COMMAND_SKILL_ADD :
  3658. case COMMAND_SKILL_REMOVE :
  3659. case COMMAND_SKILL_LIST : { Command_Skills(client, sep, command->handler); break; }
  3660. case COMMAND_ZONE_SET : { Command_ZoneSet(client, sep); break; }
  3661. case COMMAND_ZONE_DETAILS : { Command_ZoneDetails(client, sep); break; }
  3662. case COMMAND_ENTITYCOMMAND :
  3663. case COMMAND_ENTITYCOMMAND_LIST : { Command_EntityCommand(client, sep, command->handler); break; }
  3664. case COMMAND_MERCHANT :
  3665. case COMMAND_MERCHANT_LIST : { Command_Merchant(client, sep, command->handler); break; }
  3666. case COMMAND_APPEARANCE :
  3667. case COMMAND_APPEARANCE_LIST : { Command_Appearance(client, sep, command->handler); break; }
  3668. case COMMAND_TRACK : { Command_Track(client); break; }
  3669. case COMMAND_DISTANCE : { Command_Distance(client); break; }
  3670. case COMMAND_INSPECT_PLAYER : { Command_InspectPlayer(client, sep); break; }
  3671. case COMMAND_ZONE_SAFE : { Command_ZoneSafeCoords(client, sep); break; }
  3672. case COMMAND_GUILDSAY : { Command_GuildSay(client, sep); break; }
  3673. case COMMAND_OFFICERSAY : { Command_OfficerSay(client, sep); break; }
  3674. case COMMAND_SET_GUILD_MEMBER_NOTE : { Command_SetGuildMemberNote(client, sep); break; }
  3675. case COMMAND_SET_GUILD_OFFICER_NOTE : { Command_SetGuildOfficerNote(client, sep); break; }
  3676. case COMMAND_GUILD : { Command_Guild(client, sep); break; }
  3677. case COMMAND_CREATE_GUILD : { Command_CreateGuild(client); break; }
  3678. case COMMAND_GUILDS : { Command_Guilds(client); break; }
  3679. case COMMAND_GUILDS_ADD : { Command_GuildsAdd(client, sep); break; }
  3680. case COMMAND_GUILDS_CREATE : { Command_GuildsCreate(client, sep); break; }
  3681. case COMMAND_GUILDS_DELETE : { Command_GuildsDelete(client, sep); break; }
  3682. case COMMAND_GUILDS_LIST : { Command_GuildsList(client); break; }
  3683. case COMMAND_GUILDS_REMOVE : { Command_GuildsRemove(client, sep); break; }
  3684. case COMMAND_CLAIM : { Command_Claim(client, sep); break; }
  3685. case COMMAND_CLEAR_ALL_QUEUED : { Command_ClearAllQueued(client); break; }
  3686. case COMMAND_LOCATION : { Command_Location(client); break; }
  3687. case COMMAND_LOCATION_ADD : { Command_LocationAdd(client, sep); break; }
  3688. case COMMAND_LOCATION_CREATE : { Command_LocationCreate(client, sep); break; }
  3689. case COMMAND_LOCATION_DELETE : { Command_LocationDelete(client, sep); break; }
  3690. case COMMAND_LOCATION_LIST : { Command_LocationList(client, sep); break; }
  3691. case COMMAND_LOCATION_REMOVE : { Command_LocationRemove(client, sep); break; }
  3692. case COMMAND_GRID : { Command_Grid(client); break; }
  3693. case COMMAND_TRY_ON : { Command_TryOn(client, sep); break; }
  3694. case COMMAND_IRC : { Command_IRC(client, sep); break; }
  3695. case COMMAND_RANDOMIZE : { Command_Randomize(client, sep); break; }
  3696. case COMMAND_AFK : { Command_AFK(client, sep); break; }
  3697. case COMMAND_SHOW_CLOAK : { Command_ShowCloak(client, sep); break; }
  3698. case COMMAND_SHOW_HELM : { Command_ShowHelm(client, sep); break; }
  3699. case COMMAND_SHOW_HOOD : { Command_ShowHood(client, sep); break; }
  3700. case COMMAND_SHOW_HOOD_OR_HELM : { Command_ShowHoodHelm(client, sep); break; }
  3701. case COMMAND_SHOW_RANGED : { Command_ShowRanged(client, sep); break; }
  3702. case COMMAND_STOP_DRINKING : { Command_StopDrinking(client); break; }
  3703. case COMMAND_STOP_EATING : { Command_StopEating(client); break; }
  3704. case COMMAND_TOGGLE_ANONYMOUS : { Command_Toggle_Anonymous(client); break; }
  3705. case COMMAND_TOGGLE_AUTOCONSUME : { Command_Toggle_AutoConsume(client, sep); break; }
  3706. case COMMAND_TOGGLE_BONUS_EXP : { Command_Toggle_BonusXP(client); break; }
  3707. case COMMAND_TOGGLE_COMBAT_EXP : { Command_Toggle_CombatXP(client); break; }
  3708. case COMMAND_TOGGLE_GM_HIDE : { Command_Toggle_GMHide(client); break; }
  3709. case COMMAND_TOGGLE_GM_VANISH : { Command_Toggle_GMVanish(client); break; }
  3710. case COMMAND_TOGGLE_ILLUSIONS : { Command_Toggle_Illusions(client, sep); break; }
  3711. case COMMAND_TOGGLE_LFG : { Command_Toggle_LFG(client); break; }
  3712. case COMMAND_TOGGLE_LFW : { Command_Toggle_LFW(client); break; }
  3713. case COMMAND_TOGGLE_QUEST_EXP : { Command_Toggle_QuestXP(client); break; }
  3714. case COMMAND_TOGGLE_ROLEPLAYING : { Command_Toggle_Roleplaying(client); break; }
  3715. case COMMAND_TOGGLE_DUELS : { Command_Toggle_Duels(client); break; }
  3716. case COMMAND_TOGGLE_TRADES : { Command_Toggle_Trades(client); break; }
  3717. case COMMAND_TOGGLE_GUILDS : { Command_Toggle_Guilds(client); break; }
  3718. case COMMAND_TOGGLE_GROUPS : { Command_Toggle_Groups(client); break; }
  3719. case COMMAND_TOGGLE_RAIDS : { Command_Toggle_Raids(client); break; }
  3720. case COMMAND_TOGGLE_LON : { Command_Toggle_LON(client); break; }
  3721. case COMMAND_TOGGLE_VCINVITE : { Command_Toggle_VoiceChat(client); break; }
  3722. case COMMAND_CANCEL_MAINTAINED : { Command_CancelMaintained(client, sep); break; }
  3723. case COMMAND_MOTD : { Command_MOTD(client); break; }
  3724. case COMMAND_RANDOM : { Command_Random(client, sep); break; }
  3725. case COMMAND_CREATE : { Command_Create(client, sep); break; }
  3726. case COMMAND_CREATEFROMRECIPE : { Command_CreateFromRecipe(client, sep); break; }
  3727. case COMMAND_TITLE : { Command_Title(client); break; }
  3728. case COMMAND_TITLE_LIST : { Command_TitleList(client); break; }
  3729. case COMMAND_TITLE_SETPREFIX : { Command_TitleSetPrefix(client, sep); break; }
  3730. case COMMAND_TITLE_SETSUFFIX : { Command_TitleSetSuffix(client, sep); break; }
  3731. case COMMAND_TITLE_FIX : { Command_TitleFix(client, sep); break; }
  3732. case COMMAND_LANGUAGES : { Command_Languages(client, sep); break; }
  3733. case COMMAND_SET_LANGUAGE : { Command_SetLanguage(client, sep); break; }
  3734. case COMMAND_FOLLOW : { Command_Follow(client, sep); break; }
  3735. case COMMAND_STOP_FOLLOW : { Command_StopFollow(client, sep); break; }
  3736. case COMMAND_LASTNAME : { Command_LastName(client, sep); break; }
  3737. case COMMAND_CONFIRMLASTNAME : { Command_ConfirmLastName(client, sep); break; }
  3738. case COMMAND_PET : { Command_Pet(client, sep); break; }
  3739. case COMMAND_PETNAME : { Command_PetName(client, sep); break; }
  3740. case COMMAND_NAME_PET : { Command_NamePet(client, sep); break; }
  3741. case COMMAND_RENAME : { Command_Rename(client, sep); break; }
  3742. case COMMAND_CONFIRMRENAME : { Command_ConfirmRename(client, sep); break; }
  3743. case COMMAND_PETOPTIONS : { Command_PetOptions(client, sep); break; }
  3744. case COMMAND_START_TRADE : { Command_TradeStart(client, sep); break; }
  3745. case COMMAND_ACCEPT_TRADE : { Command_TradeAccept(client, sep); break; }
  3746. case COMMAND_REJECT_TRADE : { Command_TradeReject(client, sep); break; }
  3747. case COMMAND_CANCEL_TRADE : { Command_TradeCancel(client, sep); break; }
  3748. case COMMAND_SET_TRADE_COIN : { Command_TradeSetCoin(client, sep); break; }
  3749. case COMMAND_ADD_TRADE_COPPER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_COPPER); break; }
  3750. case COMMAND_ADD_TRADE_SILVER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_SILVER); break; }
  3751. case COMMAND_ADD_TRADE_GOLD : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_GOLD); break; }
  3752. case COMMAND_ADD_TRADE_PLAT : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_PLAT); break; }
  3753. case COMMAND_REMOVE_TRADE_COPPER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_COPPER); break; }
  3754. case COMMAND_REMOVE_TRADE_SILVER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_SILVER); break; }
  3755. case COMMAND_REMOVE_TRADE_GOLD : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_GOLD); break; }
  3756. case COMMAND_REMOVE_TRADE_PLAT : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_PLAT); break; }
  3757. case COMMAND_ADD_TRADE_ITEM : { Command_TradeAddItem(client, sep); break; }
  3758. case COMMAND_REMOVE_TRADE_ITEM : { Command_TradeRemoveItem(client, sep); break; }
  3759. case COMMAND_ACCEPT_ADVANCEMENT : { Command_AcceptAdvancement(client, sep); break; }
  3760. case COMMAND_DUEL : { Command_Duel(client, sep); break; }
  3761. case COMMAND_DUELBET : { Command_DuelBet(client, sep); break; }
  3762. case COMMAND_DUEL_ACCEPT : { Command_DuelAccept(client, sep); break; }
  3763. case COMMAND_DUEL_DECLINE : { Command_DuelDecline(client, sep); break; }
  3764. case COMMAND_DUEL_SURRENDER : { Command_DuelSurrender(client, sep); break; }
  3765. case COMMAND_DUEL_TOGGLE : { Command_DuelToggle(client, sep); break; }
  3766. case COMMAND_SPAWN_TEMPLATE : { Command_SpawnTemplate(client, sep); break; }
  3767. case COMMAND_MODIFY : { Command_Modify(client); break; }
  3768. case COMMAND_MODIFY_CHARACTER : { Command_ModifyCharacter(client, sep); break; }
  3769. case COMMAND_MODIFY_QUEST : { Command_ModifyQuest(client, sep); break; }
  3770. case COMMAND_MODIFY_FACTION : { Command_ModifyFaction(client, sep); break; }
  3771. case COMMAND_MODIFY_GUILD : { Command_ModifyGuild(client, sep); break; }
  3772. case COMMAND_MODIFY_ITEM : { Command_ModifyItem(client, sep); break; }
  3773. case COMMAND_MODIFY_SKILL : { Command_ModifySkill(client, sep); break; }
  3774. case COMMAND_MODIFY_SPAWN : { Command_ModifySpawn(client, sep); break; }
  3775. case COMMAND_MODIFY_SPELL : { Command_ModifySpell(client, sep); break; }
  3776. case COMMAND_MODIFY_ZONE : { Command_ModifyZone(client, sep); break; }
  3777. case COMMAND_JOIN_CHANNEL : { Command_JoinChannel(client, sep); break;}
  3778. case COMMAND_JOIN_CHANNEL_FROM_LOAD: { Command_JoinChannelFromLoad(client, sep); break;}
  3779. case COMMAND_TELL_CHANNEL : { Command_TellChannel(client, sep); break;}
  3780. case COMMAND_LEAVE_CHANNEL : { Command_LeaveChannel(client, sep); break;}
  3781. case COMMAND_WHO_CHANNEL : { Command_WhoChannel(client, sep); break;}
  3782. case COMMAND_RAIN : { Command_Rain(client, sep); break; }
  3783. case COMMAND_WIND : { Command_Wind(client, sep); break; }
  3784. case COMMAND_WEATHER : { Command_Weather(client, sep); break; }
  3785. case COMMAND_FROM_MERCHANT : { Command_SendMerchantWindow(client, sep); break; }
  3786. case COMMAND_TO_MERCHANT : { Command_SendMerchantWindow(client, sep, true); break; }
  3787. case COMMAND_SELECT : { Command_Select(client, sep); break; }
  3788. case COMMAND_SMP : { Command_StationMarketPlace(client, sep); break; }
  3789. case COMMAND_CONSUME_FOOD : { Command_ConsumeFood(client, sep); break; }
  3790. case COMMAND_AQUAMAN : { Command_Aquaman(client, sep); break; }
  3791. case COMMAND_ATTUNE_INV : { Command_Attune_Inv(client, sep); break; }
  3792. case COMMAND_PLAYER : { Command_Player(client, sep); break; }
  3793. case COMMAND_PLAYER_COINS : { Command_Player_Coins(client, sep); break; }
  3794. case COMMAND_RESET_ZONE_TIMER : { Command_Reset_Zone_Timer(client, sep); break; }
  3795. case COMMAND_ACHIEVEMENT_ADD : { Command_AchievementAdd(client, sep); break; }
  3796. case COMMAND_EDITOR : { Command_Editor(client, sep); break; }
  3797. case COMMAND_ACCEPT_RESURRECTION: { Command_AcceptResurrection(client, sep); break; }
  3798. case COMMAND_DECLINE_RESURRECTION:{ Command_DeclineResurrection(client, sep); break; }
  3799. case COMMAND_TEST : { Command_Test(client, command_parms); break; }
  3800. case COMMAND_SPEED : { Command_Speed(client, sep); break; }
  3801. case COMMAND_BOT : { Command_Bot(client, sep); break; }
  3802. case COMMAND_BOT_CREATE : { Command_Bot_Create(client, sep); break; }
  3803. case COMMAND_BOT_CUSTOMIZE : { Command_Bot_Customize(client, sep); break; }
  3804. case COMMAND_BOT_SPAWN : { Command_Bot_Spawn(client, sep); break; }
  3805. case COMMAND_BOT_LIST : { Command_Bot_List(client, sep); break; }
  3806. case COMMAND_BOT_INV : { Command_Bot_Inv(client, sep); break; }
  3807. case COMMAND_BOT_SETTINGS : { Command_Bot_Settings(client, sep); break; }
  3808. case COMMAND_BOT_HELP : { Command_Bot_Help(client, sep); break; }
  3809. case GET_AA_XML : { Get_AA_Xml(client, sep); break; }
  3810. case ADD_AA : { Add_AA(client, sep); break; }
  3811. case COMMIT_AA_PROFILE : { Commit_AA_Profile(client, sep); break; }
  3812. case BEGIN_AA_PROFILE : { Begin_AA_Profile(client, sep); break; }
  3813. case BACK_AA : { Back_AA(client, sep); break; }
  3814. case REMOVE_AA : { Remove_AA(client, sep); break; }
  3815. case SWITCH_AA_PROFILE : { Switch_AA_Profile(client, sep); break; }
  3816. case CANCEL_AA_PROFILE : { Cancel_AA_Profile(client, sep); break; }
  3817. case SAVE_AA_PROFILE : { Save_AA_Profile(client, sep); break; }
  3818. case COMMAND_TARGETITEM : { Command_TargetItem(client, sep); break; }
  3819. default:
  3820. {
  3821. LogWrite(COMMAND__WARNING, 0, "Command", "Unhandled command: %s", command->command.data.c_str());
  3822. break;
  3823. }
  3824. }
  3825. safe_delete(sep);
  3826. }
  3827. /******************** New COMMAND Handler Functions ********************/
  3828. /*
  3829. Started breaking apart the huge switch() for commands into sepErate
  3830. functions so it is easier to locate the blocks of code by command
  3831. -- JA 2012.03.03
  3832. */
  3833. // sample function header
  3834. /*
  3835. Function:
  3836. Purpose :
  3837. Params :
  3838. Dev :
  3839. Example :
  3840. */
  3841. //void Commands::Command()
  3842. //{
  3843. //}
  3844. /*
  3845. Function: Command_AcceptAdvancement()
  3846. Purpose : Player accepts a new advancement option
  3847. Params : Spell ID
  3848. Dev : Jabantiz
  3849. */
  3850. void Commands::Command_AcceptAdvancement(Client* client, Seperator* sep)
  3851. {
  3852. Player *player = client->GetPlayer();
  3853. TraitData* trait = master_trait_list.GetTrait(atoul(sep->arg[0]));
  3854. // Check to see if this is a trait or grandmaster training (traits are always new spells, training is always upgrades)
  3855. if (!player->HasSpell(trait->spellID, 0, true))
  3856. {
  3857. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  3858. player->AddSpellBookEntry(trait->spellID, trait->tier, player->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  3859. }
  3860. else
  3861. {
  3862. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  3863. int8 old_slot = player->GetSpellSlot(spell->GetSpellID());
  3864. player->RemoveSpellBookEntry(spell->GetSpellID());
  3865. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  3866. player->UnlockSpell(spell);
  3867. client->SendSpellUpdate(spell);
  3868. }
  3869. // Spell book update
  3870. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  3871. client->QueuePacket(master_trait_list.GetTraitListPacket(client));
  3872. }
  3873. /*
  3874. Function:
  3875. Purpose :
  3876. Params :
  3877. Dev :
  3878. Example :
  3879. */
  3880. void Commands::Command_AFK(Client* client, Seperator* sep)
  3881. {
  3882. Player* player = client->GetPlayer();
  3883. player->toggle_character_flag(CF_AFK);
  3884. client->Message(CHANNEL_COLOR_YELLOW,"You are %s afk.", client->GetPlayer()->get_character_flag(CF_AFK)?"now":"no longer");
  3885. if (player->get_character_flag(CF_AFK))
  3886. {
  3887. LogWrite(MISC__TODO, 1, "TODO", "player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_AFK); <-- need to find this");
  3888. /*player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_AFK); <-- need to find this */
  3889. if (sep && sep->argplus[0])
  3890. player->SetAwayMessage("I am away from the keyboard, " + string(sep->argplus[0]));
  3891. else
  3892. player->SetAwayMessage("Sorry, I am A.F.K. (Away From Keyboard)");
  3893. string message = string(player->GetName()) + " is going afk.";
  3894. Spawn* target = player->GetTarget();
  3895. if (target && target != player)
  3896. {
  3897. message = string(player->GetName()) + " tells " + string(target->GetName()) + " that ";
  3898. player->GetGender() == 1 ? message += "he" : message += "she";
  3899. message += " is going afk.";
  3900. }
  3901. player->GetZone()->SimpleMessage(CHANNEL_COLOR_YELLOW, message.c_str(), player, 30);
  3902. }
  3903. /*else
  3904. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_AFK); <-- need to find this */
  3905. }
  3906. /*
  3907. Function: Command_Appearance()
  3908. Purpose : Handles /appearance commands
  3909. Params : list
  3910. Dev : Scatman
  3911. Example : /appearance list
  3912. */
  3913. void Commands::Command_Appearance(Client* client, Seperator* sep, int handler)
  3914. {
  3915. if( handler == COMMAND_APPEARANCE )
  3916. {
  3917. // /appearance command by itself shows help (to be extended)
  3918. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  3919. return;
  3920. }
  3921. else if( handler == COMMAND_APPEARANCE_LIST )
  3922. {
  3923. // /appearance list command expects "name" param
  3924. if (sep && sep->arg[0])
  3925. {
  3926. const char* appearance_name = sep->argplus[0];
  3927. client->Message(CHANNEL_COLOR_YELLOW, "Listing appearances like '%s':", appearance_name);
  3928. vector<int16>* appearances = database.GetAppearanceIDsLikeName(string(appearance_name));
  3929. if (appearances)
  3930. {
  3931. vector<int16>::iterator itr;
  3932. for (itr = appearances->begin(); itr != appearances->end(); itr++)
  3933. {
  3934. int16 id = *itr;
  3935. string name = database.GetAppearanceName(id);
  3936. if (ToLower(name).find(ToLower(string(appearance_name))) < 0xFFFFFFFF)
  3937. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", name.c_str(), id);
  3938. }
  3939. safe_delete(appearances);
  3940. }
  3941. }
  3942. else // no param
  3943. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  3944. }
  3945. }
  3946. /*
  3947. Function: Command_Claim()
  3948. Purpose :
  3949. Params :
  3950. Dev :
  3951. Example :
  3952. */
  3953. void Commands::Command_Claim(Client* client, Seperator* sep)
  3954. {
  3955. if (sep && sep->arg[0] && sep->IsNumber(0))
  3956. {
  3957. LogWrite(MISC__TODO, 1, "TODO", "On Scatman's TODO list!\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  3958. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "On Scatman's TODO :)");
  3959. }
  3960. else
  3961. client->ShowClaimWindow();
  3962. }
  3963. /*
  3964. Function: Command_ClearAllQueued()
  3965. Purpose :
  3966. Params :
  3967. Dev :
  3968. Example :
  3969. */
  3970. void Commands::Command_ClearAllQueued(Client* client)
  3971. {
  3972. ZoneServer* zone = client->GetPlayer()->GetZone();
  3973. if (zone && zone->GetSpellProcess())
  3974. zone->GetSpellProcess()->RemoveSpellFromQueue(client->GetPlayer());
  3975. }
  3976. /*
  3977. Function: Command_CancelMaintained()
  3978. Purpose : Cancels maintained spells
  3979. Params : Maintained Spell Index
  3980. Dev : Zcoretri
  3981. Example : /cancel_maintained 1 - would cancel the spell in slot 1 of Maintained Spells list
  3982. */
  3983. void Commands::Command_CancelMaintained(Client* client, Seperator* sep)
  3984. {
  3985. if (sep && sep->arg[0] && sep->IsNumber(0))
  3986. {
  3987. int32 spell_index = atoul(sep->arg[0]);
  3988. MaintainedEffects mEffects = client->GetPlayer()->GetInfoStruct()->maintained_effects[spell_index];
  3989. //Spell* spell = master_spell_list.GetSpell(mEffects.spell_id, mEffects.tier);
  3990. // if (spell && spell->GetSpellData()->friendly_spell) -- NOTE::You can cancel hostile maintained spells,
  3991. // just not spelleffects/dets - Foof
  3992. //{
  3993. if (!client->GetPlayer()->GetZone()->GetSpellProcess()->DeleteCasterSpell(mEffects.spell))
  3994. client->Message(CHANNEL_COLOR_RED, "The maintained spell could not be cancelled.");
  3995. // }
  3996. //else
  3997. //client->Message(CHANNEL_COLOR_RED, "You can only cancel friendly spells!");
  3998. }
  3999. }
  4000. /*
  4001. Function: Command_Create()
  4002. Purpose : Handler for starting Tradeskilling table
  4003. Params :
  4004. Dev : Zcoretri
  4005. Example :
  4006. */
  4007. void Commands::Command_Create(Client* client, Seperator* sep)
  4008. {
  4009. PrintSep(sep, "COMMAND_CREATE");
  4010. client->SendRecipeList();
  4011. client->ShowRecipeBook();
  4012. }
  4013. void Commands::Command_CreateFromRecipe(Client* client, Seperator* sep)
  4014. {
  4015. PrintSep(sep, "COMMAND_CREATEFROMRECIPE");
  4016. if (sep && sep->arg[0] && sep->IsNumber(0))
  4017. ClientPacketFunctions::SendCreateFromRecipe(client, atoul(sep->arg[0]));
  4018. }
  4019. /*
  4020. Function: Command_Distance()
  4021. Purpose : Displays distance from targeted spawn
  4022. Params :
  4023. Dev : Scatman
  4024. Example : /distance
  4025. */
  4026. void Commands::Command_Distance(Client* client)
  4027. {
  4028. Spawn* target = client->GetPlayer()->GetTarget();
  4029. if (target)
  4030. client->Message(CHANNEL_COLOR_YELLOW, "Your distance from %s is %f", target->GetName(), client->GetPlayer()->GetDistance(target));
  4031. else
  4032. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must have a spawn targeted to use /distance");
  4033. }
  4034. /*
  4035. Function: Command_Duel()
  4036. Purpose : Handle the /duel commands - not yet implemented
  4037. Params : unknown
  4038. Dev :
  4039. Example :
  4040. */
  4041. void Commands::Command_Duel(Client* client, Seperator* sep)
  4042. {
  4043. PrintSep(sep, "COMMAND_DUEL");
  4044. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Command");
  4045. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4046. }
  4047. /*
  4048. Function: Command_DuelBet()
  4049. Purpose : Handle the /duel commands - not yet implemented
  4050. Params : unknown
  4051. Dev :
  4052. Example :
  4053. */
  4054. void Commands::Command_DuelBet(Client* client, Seperator* sep)
  4055. {
  4056. PrintSep(sep, "COMMAND_DUELBET");
  4057. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Bet Command");
  4058. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4059. }
  4060. /*
  4061. Function: Command_DuelAccept()
  4062. Purpose : Handle the /duel commands - not yet implemented
  4063. Params : unknown
  4064. Dev :
  4065. Example :
  4066. */
  4067. void Commands::Command_DuelAccept(Client* client, Seperator* sep)
  4068. {
  4069. PrintSep(sep, "COMMAND_DUEL_ACCEPT");
  4070. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Accept Duel Command");
  4071. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4072. }
  4073. /*
  4074. Function: Command_DuelDecline()
  4075. Purpose : Handle the /duel commands - not yet implemented
  4076. Params : unknown
  4077. Dev :
  4078. Example :
  4079. */
  4080. void Commands::Command_DuelDecline(Client* client, Seperator* sep)
  4081. {
  4082. PrintSep(sep, "COMMAND_DUEL_DECLINE");
  4083. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Decline Duel Request Command");
  4084. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4085. }
  4086. /*
  4087. Function: Command_DuelSurrender()
  4088. Purpose : Handle the /duel commands - not yet implemented
  4089. Params : unknown
  4090. Dev :
  4091. Example :
  4092. */
  4093. void Commands::Command_DuelSurrender(Client* client, Seperator* sep)
  4094. {
  4095. PrintSep(sep, "COMMAND_DUEL_SURRENDER");
  4096. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Surrender Duel Command");
  4097. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4098. // JA, just messin around ;)
  4099. char surrender[64];
  4100. sprintf(surrender, "%s surrendered like a cowardly dog!", client->GetPlayer()->GetName());
  4101. zone_list.HandleGlobalAnnouncement(surrender);
  4102. }
  4103. /*
  4104. Function: Command_DuelToggle()
  4105. Purpose : Handle the /duel commands - not yet implemented
  4106. Params : unknown
  4107. Dev :
  4108. Example :
  4109. */
  4110. void Commands::Command_DuelToggle(Client* client, Seperator* sep)
  4111. {
  4112. PrintSep(sep, "COMMAND_DUEL");
  4113. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Commands");
  4114. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4115. }
  4116. /*
  4117. Function:
  4118. Purpose :
  4119. Params :
  4120. Dev :
  4121. Example :
  4122. */
  4123. void Commands::Command_EntityCommand(Client* client, Seperator* sep, int handler)
  4124. {
  4125. if( handler == COMMAND_ENTITYCOMMAND )
  4126. {
  4127. // /entitycommand command by itself shows help (to be extended)
  4128. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  4129. return;
  4130. }
  4131. else if( handler == COMMAND_ENTITYCOMMAND_LIST )
  4132. {
  4133. // /entitycommand list command expects "name" param
  4134. if (sep && sep->arg[0])
  4135. {
  4136. const char* entity_command_name = sep->argplus[0];
  4137. client->Message(CHANNEL_COLOR_YELLOW, "Listing entity commands like '%s':", entity_command_name);
  4138. map<int32, vector<EntityCommand*>*>* entity_command_list_all = client->GetCurrentZone()->GetEntityCommandListAll();
  4139. map<int32, vector<EntityCommand*>*>::iterator itr;
  4140. for (itr = entity_command_list_all->begin(); itr != entity_command_list_all->end(); itr++)
  4141. {
  4142. vector<EntityCommand*>* entity_command_list = itr->second;
  4143. vector<EntityCommand*>::iterator itr2;
  4144. for (itr2 = entity_command_list->begin(); itr2 != entity_command_list->end(); itr2++)
  4145. {
  4146. EntityCommand* entity_command = *itr2;
  4147. if (ToLower(entity_command->name).find(ToLower(string(entity_command_name))) < 0xFFFFFFFF)
  4148. client->Message(CHANNEL_COLOR_YELLOW, "Command Text: %s, Command List ID: %u, Distance: %f\n", entity_command->name.c_str(), itr->first, entity_command->distance);
  4149. }
  4150. }
  4151. }
  4152. else // no command name
  4153. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  4154. }
  4155. }
  4156. /*
  4157. Function: Command_Follow()
  4158. Purpose : Handle the /follow command - not yet implemented
  4159. Params :
  4160. Dev :
  4161. Example :
  4162. */
  4163. void Commands::Command_Follow(Client* client, Seperator* sep)
  4164. {
  4165. PrintSep(sep, "COMMAND_FOLLOW");
  4166. // flag to toggle if the players target is in the players group
  4167. bool targetInGroup = false;
  4168. // get a pointer to the players group
  4169. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  4170. // If the player has a group and has a target
  4171. if (gmi && client->GetPlayer()->GetTarget()) {
  4172. deque<GroupMemberInfo*>::iterator itr;
  4173. world.GetGroupManager()->GroupLock(__FUNCTION__, __LINE__);
  4174. deque<GroupMemberInfo*>* members = world.GetGroupManager()->GetGroupMembers(gmi->group_id);
  4175. // Loop through the group members
  4176. for (itr = members->begin(); itr != members->end(); itr++) {
  4177. // If a group member matches a target
  4178. if ((*itr)->member == client->GetPlayer()->GetTarget()) {
  4179. // toggle the flag and break the loop
  4180. targetInGroup = true;
  4181. break;
  4182. }
  4183. }
  4184. world.GetGroupManager()->ReleaseGroupLock(__FUNCTION__, __LINE__);
  4185. }
  4186. if (targetInGroup) {
  4187. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  4188. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You start to follow %s.", client->GetPlayer()->GetTarget()->GetName());
  4189. client->GetPlayer()->SetFollowTarget(client->GetPlayer()->GetTarget());
  4190. client->GetPlayer()->info_changed = true;
  4191. client->GetPlayer()->changed = true;
  4192. }
  4193. else
  4194. client->Message(CHANNEL_COLOR_WHITE, "You must first select a group member to follow.");
  4195. }
  4196. /*
  4197. Function: Command_StopFollow()
  4198. Purpose : Handle the /stop_follow command - not yet implemented
  4199. Params :
  4200. Dev :
  4201. Example :
  4202. */
  4203. void Commands::Command_StopFollow(Client* client, Seperator* sep)
  4204. {
  4205. PrintSep(sep, "COMMAND_STOP_FOLLOW");
  4206. if (client->GetPlayer()->GetFollowTarget()) {
  4207. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  4208. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You are no longer following %s", client->GetPlayer()->GetFollowTarget()->GetName());
  4209. client->GetPlayer()->SetFollowTarget(0);
  4210. client->GetPlayer()->info_changed = true;
  4211. client->GetPlayer()->changed = true;
  4212. }
  4213. }
  4214. #include "../Zone/SPGrid.h"
  4215. /*
  4216. Function: Command_Grid()
  4217. Purpose : Show player's current Grid ID
  4218. Params :
  4219. Dev : Scatman
  4220. Example : /grid
  4221. */
  4222. void Commands::Command_Grid(Client* client)
  4223. {
  4224. client->Message(CHANNEL_COLOR_YELLOW, "Your Grid ID is %u", client->GetPlayer()->appearance.pos.grid_id);
  4225. if (client->GetCurrentZone()->Grid != nullptr) {
  4226. int32 grid = client->GetCurrentZone()->Grid->GetGridID(client->GetPlayer());
  4227. client->Message(CHANNEL_COLOR_YELLOW, "SPGrid result is %u", grid);
  4228. }
  4229. }
  4230. /*
  4231. Function: Command_Guild()
  4232. Purpose : Handler for all UI-related guild commands
  4233. Dev : Scatman
  4234. */
  4235. void Commands::Command_Guild(Client* client, Seperator* sep)
  4236. {
  4237. Guild* guild = client->GetPlayer()->GetGuild();
  4238. if (sep && sep->arg[0])
  4239. {
  4240. const char* command = sep->arg[0];
  4241. int32 length = strlen(command);
  4242. LogWrite(COMMAND__DEBUG, 0, "Command", "Guild Command: %s", command);
  4243. if (strncmp(command, "rank_name", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && guild)
  4244. guild->SetRankName(atoi(sep->arg[1]), sep->argplus[2]);
  4245. else if (strncmp(command, "rank_permission", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  4246. guild->SetPermission(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  4247. else if (strncmp(command, "filter_event", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  4248. guild->SetEventFilter(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  4249. else if (strncmp(command, "kick", length) == 0 && sep->arg[1] && guild)
  4250. guild->KickGuildMember(client, sep->arg[1]);
  4251. else if (strncmp(command, "demote", length) == 0 && sep->arg[1] && guild)
  4252. guild->DemoteGuildMember(client, sep->arg[1]);
  4253. else if (strncmp(command, "promote", length) == 0 && sep->arg[1] && guild)
  4254. guild->PromoteGuildMember(client, sep->arg[1]);
  4255. else if (strncmp(command, "points", length) == 0 && guild)
  4256. {
  4257. if (sep->arg[1] && strncmp(sep->arg[1], "add", length) == 0)
  4258. {
  4259. if (sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  4260. {
  4261. float points = atof(sep->arg[2]);
  4262. const char* option = sep->arg[3];
  4263. const char* comment = sep->argplus[4];
  4264. if (strncmp(option, "all", strlen(option)) == 0)
  4265. guild->AddPointsToAll(client, points, comment);
  4266. else if (strncmp(option, "online", strlen(option)) == 0)
  4267. guild->AddPointsToAllOnline(client, points, comment);
  4268. else if (strncmp(option, "group", strlen(option)) == 0)
  4269. guild->AddPointsToGroup(client, points, comment);
  4270. else if (strncmp(option, "raid", strlen(option)) == 0)
  4271. guild->AddPointsToRaid(client, points, comment);
  4272. else
  4273. guild->AddPointsToGuildMember(client, points, option, comment);
  4274. }
  4275. }
  4276. else if (sep->arg[1] && strncmp(sep->arg[1], "view", strlen(sep->arg[1])) == 0 && sep->arg[2])
  4277. guild->ViewGuildMemberPoints(client, sep->arg[2]);
  4278. else
  4279. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild points command: %s", sep->argplus[0]);
  4280. }
  4281. else if (strncmp(command, "motd", length) == 0 && sep->arg[1] && guild)
  4282. guild->SetMOTD(sep->argplus[1]);
  4283. else if (strncmp(command, "recruiting", length) == 0 && guild)
  4284. {
  4285. if (sep->arg[1])
  4286. {
  4287. const char* option = sep->arg[1];
  4288. if (strncmp(option, "short_text", strlen(option)) == 0 && sep->arg[2])
  4289. guild->SetRecruitingShortDesc(sep->argplus[2]);
  4290. else if (strncmp(option, "long_text", strlen(option)) == 0 && sep->arg[2])
  4291. guild->SetRecruitingFullDesc(sep->argplus[2]);
  4292. else if (strncmp(option, "flag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  4293. guild->SetRecruitingFlag(atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  4294. else if (strncmp(option, "min_level", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  4295. guild->SetRecruitingMinLevel(atoi(sep->arg[2]));
  4296. else if (strncmp(option, "playstyle", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  4297. guild->SetRecruitingPlayStyle(atoi(sep->arg[2]));
  4298. else if (strncmp(option, "tag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && sep->IsNumber(3))
  4299. guild->SetRecruitingDescTag(atoi(sep->arg[2]), atoi(sep->arg[3]));
  4300. else if (strncmp(command, "recruiting", strlen(option)) == 0)
  4301. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_RECRUITING_FOR_GUILD, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  4302. else
  4303. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  4304. }
  4305. else
  4306. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  4307. }
  4308. else if (strncmp(command, "notify_online", length) == 0 && sep->arg[1] && guild)
  4309. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_NOTIFY_LOGINS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  4310. else if (strncmp(command, "event_privacy", length) == 0 && sep->arg[1] && guild)
  4311. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_DONT_GENERATE_EVENTS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  4312. else if (strncmp(command, "recruiter", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  4313. guild->SetGuildRecruiter(client, sep->arg[1], strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  4314. else if (strncmp(command, "recruiter_description", length) == 0 && sep->arg[1] && guild)
  4315. guild->SetGuildRecruiterDescription(client, sep->argplus[1]);
  4316. else if (strncmp(command, "lock_event", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  4317. guild->LockGuildEvent(atoul(sep->arg[1]), strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  4318. else if (strncmp(command, "delete_event", length) == 0 && sep->arg[1] && guild)
  4319. guild->DeleteGuildEvent(atoul(sep->arg[1]));
  4320. else if (strncmp(command, "invite", length) == 0 && guild)
  4321. {
  4322. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  4323. guild->InvitePlayer(client, sep->arg[1]);
  4324. else
  4325. {
  4326. Spawn* target = client->GetPlayer()->GetTarget();
  4327. if (target)
  4328. {
  4329. if (target->IsPlayer())
  4330. guild->InvitePlayer(client, target->GetName());
  4331. else
  4332. client->Message(CHANNEL_COLOR_WHITE, "%s is not a player.", target->GetName());
  4333. }
  4334. }
  4335. }
  4336. else if (strncmp(command, "accept", length) == 0)
  4337. {
  4338. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  4339. if (pgi && pgi->guild && pgi->invited_by)
  4340. pgi->guild->AddNewGuildMember(client, pgi->invited_by->GetName());
  4341. client->SetPendingGuildInvite(0);
  4342. }
  4343. else if (strncmp(command, "decline", length) == 0)
  4344. {
  4345. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  4346. if (pgi && pgi->guild && pgi->invited_by)
  4347. {
  4348. Client* client_inviter = pgi->invited_by->GetZone()->GetClientBySpawn(pgi->invited_by);
  4349. if (client_inviter)
  4350. client_inviter->Message(CHANNEL_COLOR_WHITE, "%s has declined your invitation to join %s.", client->GetPlayer()->GetName(), pgi->guild->GetName());
  4351. }
  4352. client->SetPendingGuildInvite(0);
  4353. }
  4354. else if (strncmp(command, "create", length) == 0 && sep->arg[1])
  4355. {
  4356. const char* guild_name = sep->argplus[0];
  4357. if (!guild_list.GetGuild(guild_name))
  4358. world.CreateGuild(guild_name, client, client->GetPlayer()->GetGroupMemberInfo()->group_id);
  4359. else
  4360. client->SimpleMessage(CHANNEL_COLOR_WHITE, "A guild with that name already exists.");
  4361. }
  4362. else if (strncmp(command, "search", length) == 0)
  4363. client->ShowGuildSearchWindow();
  4364. else if (strncmp(command, "recruiting_details", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  4365. {
  4366. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  4367. if (to_guild)
  4368. to_guild->SendGuildRecruitingDetails(client);
  4369. }
  4370. else if (strncmp(command, "recruiting_image", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  4371. {
  4372. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  4373. if (to_guild)
  4374. to_guild->SendGuildRecruitingImages(client);
  4375. }
  4376. else if (strncmp(command, "recruiter_adventure_class", length) == 0)
  4377. {
  4378. if (sep->arg[1])
  4379. {
  4380. const char* option = sep->arg[1];
  4381. if (strncmp(option, "toggle", strlen(option)) == 0)
  4382. guild->ToggleGuildRecruiterAdventureClass(client);
  4383. }
  4384. else
  4385. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiter_adventure_class command: '%s'", sep->argplus[0]);
  4386. }
  4387. else if (strncmp(command, "display_heraldry", length) == 0)
  4388. {
  4389. // JA: not sure this is right...
  4390. client->GetPlayer()->toggle_character_flag(CF_SHOW_GUILD_HERALDRY);
  4391. client->GetPlayer()->SetCharSheetChanged(true);
  4392. }
  4393. else
  4394. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild command: '%s'", sep->argplus[0]);
  4395. }
  4396. }
  4397. /*
  4398. Function: Command_GuildCreate()
  4399. Purpose : Display's in-game Guild Creation window
  4400. Dev : Scatman
  4401. */
  4402. void Commands::Command_CreateGuild(Client* client)
  4403. {
  4404. client->SendGuildCreateWindow();
  4405. }
  4406. /*
  4407. Function: Command_SetGuildOfficerNote()
  4408. Purpose :
  4409. Dev : Scatman
  4410. */
  4411. void Commands::Command_SetGuildOfficerNote(Client* client, Seperator* sep)
  4412. {
  4413. if (sep && sep->arg[0] && sep->arg[1])
  4414. {
  4415. Guild* guild = client->GetPlayer()->GetGuild();
  4416. if (guild)
  4417. guild->SetGuildOfficerNote(sep->arg[0], sep->argplus[1]);
  4418. }
  4419. }
  4420. /*
  4421. Function: Command_SetGuildMemberNote()
  4422. Purpose :
  4423. Dev : Scatman
  4424. */
  4425. void Commands::Command_SetGuildMemberNote(Client* client, Seperator* sep)
  4426. {
  4427. if (sep && sep->arg[0] && sep->arg[1])
  4428. {
  4429. Guild* guild = client->GetPlayer()->GetGuild();
  4430. if (guild)
  4431. guild->SetGuildMemberNote(sep->arg[0], sep->argplus[1]);
  4432. }
  4433. }
  4434. /*
  4435. Function: Command_GuildSay()
  4436. Purpose :
  4437. Dev : Scatman
  4438. */
  4439. void Commands::Command_GuildSay(Client* client, Seperator* sep)
  4440. {
  4441. Guild* guild = client->GetPlayer()->GetGuild();
  4442. if (guild)
  4443. {
  4444. if (sep && sep->arg[0])
  4445. guild->HandleGuildSay(client, sep->argplus[0]);
  4446. }
  4447. else
  4448. client->SimpleMessage(CHANNEL_COLOR_WHITE, "You are not a member of a guild");
  4449. }
  4450. /*
  4451. Function: Command_OfficerSay()
  4452. Purpose :
  4453. Dev : Scatman
  4454. */
  4455. void Commands::Command_OfficerSay(Client* client, Seperator* sep)
  4456. {
  4457. Guild* guild = client->GetPlayer()->GetGuild();
  4458. if (guild)
  4459. {
  4460. if (sep && sep->arg[0])
  4461. guild->HandleOfficerSay(client, sep->argplus[0]);
  4462. }
  4463. else
  4464. client->SimpleMessage(CHANNEL_COLOR_WHITE, "You are not a member of a guild");
  4465. }
  4466. /*
  4467. Function: Command_Guilds()
  4468. Purpose : Shows help for /guild command
  4469. Params :
  4470. Dev : Scatman
  4471. Example :
  4472. */
  4473. void Commands::Command_Guilds(Client* client)
  4474. {
  4475. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds [create|delete|add|remove|list]");
  4476. }
  4477. /*
  4478. Function: Command_GuildsAdd()
  4479. Purpose : Add's players to a guild
  4480. Params : guild_name|guild_id, player name
  4481. Dev : Scatman
  4482. Example : /guilds add 1 Admin = adds player Admin to guild_id 1
  4483. */
  4484. void Commands::Command_GuildsAdd(Client* client, Seperator* sep)
  4485. {
  4486. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  4487. {
  4488. Guild* guild = 0;
  4489. bool found = true;
  4490. if (sep->IsNumber(0))
  4491. {
  4492. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  4493. if (!guild)
  4494. {
  4495. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  4496. found = false;
  4497. }
  4498. }
  4499. else
  4500. {
  4501. guild = guild_list.GetGuild(sep->arg[0]);
  4502. if (!guild)
  4503. {
  4504. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  4505. found = false;
  4506. }
  4507. }
  4508. if (found)
  4509. {
  4510. Client* to_client = 0;
  4511. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  4512. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  4513. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  4514. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  4515. if (to_client)
  4516. guild->InvitePlayer(client, to_client->GetPlayer()->GetName());
  4517. else
  4518. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  4519. }
  4520. }
  4521. else
  4522. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds add [guild name|guild id] (player name).");
  4523. }
  4524. /*
  4525. Function: Command_GuildsCreate()
  4526. Purpose : Creates a guild
  4527. Params : guild_name, player_name (optional)
  4528. Dev : Scatman
  4529. Example : /guilds create [guild name] (player name)
  4530. */
  4531. void Commands::Command_GuildsCreate(Client* client, Seperator* sep)
  4532. {
  4533. if (sep && sep->arg[0])
  4534. {
  4535. const char* guild_name = sep->arg[0];
  4536. if (!guild_list.GetGuild(guild_name))
  4537. {
  4538. bool ret = false;
  4539. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  4540. {
  4541. Client* to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  4542. if (to_client)
  4543. {
  4544. world.CreateGuild(guild_name, to_client);
  4545. ret = true;
  4546. }
  4547. else
  4548. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player with name '%s'", sep->arg[1]);
  4549. }
  4550. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  4551. {
  4552. Client* to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  4553. if (to_client)
  4554. {
  4555. world.CreateGuild(guild_name, to_client);
  4556. ret = true;
  4557. }
  4558. }
  4559. else
  4560. {
  4561. world.CreateGuild(guild_name);
  4562. ret = true;
  4563. }
  4564. if (ret)
  4565. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully created.", guild_name);
  4566. else
  4567. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the guild.");
  4568. }
  4569. else
  4570. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' already exists.", guild_name);
  4571. }
  4572. else
  4573. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds create [guild name] (player name). If no player is specified, the player's target will be used. If the player has no target, a guild with no members will be created.");
  4574. }
  4575. /*
  4576. Function: Command_GuildsDelete()
  4577. Purpose : Delete's a guild
  4578. Params : guild name
  4579. Dev : Scatman
  4580. Example : /guilds delete Test
  4581. */
  4582. void Commands::Command_GuildsDelete(Client* client, Seperator* sep)
  4583. {
  4584. if (sep && sep->arg[0])
  4585. {
  4586. Guild* guild = 0;
  4587. bool found = true;
  4588. if (sep->IsNumber(0))
  4589. {
  4590. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  4591. if (!guild)
  4592. {
  4593. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  4594. found = false;
  4595. }
  4596. }
  4597. else
  4598. {
  4599. guild = guild_list.GetGuild(sep->arg[0]);
  4600. if (!guild)
  4601. {
  4602. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  4603. found = false;
  4604. }
  4605. }
  4606. if (found)
  4607. {
  4608. guild->RemoveAllGuildMembers();
  4609. database.DeleteGuild(guild);
  4610. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully deleted.", guild->GetName());
  4611. guild_list.RemoveGuild(guild, true);
  4612. }
  4613. }
  4614. else
  4615. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds delete [guild name].");
  4616. }
  4617. /*
  4618. Function: Command_GuildsList()
  4619. Purpose : Lists current guilds on server
  4620. Params :
  4621. Dev : Scatman
  4622. Example : /guilds list
  4623. */
  4624. void Commands::Command_GuildsList(Client* client)
  4625. {
  4626. MutexMap<int32, Guild*>* guilds = guild_list.GetGuilds();
  4627. MutexMap<int32, Guild*>::iterator itr = guilds->begin();
  4628. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Guild List:");
  4629. if (guilds->size() == 0)
  4630. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "None.");
  4631. else {
  4632. while (itr.Next()) {
  4633. Guild* guild = itr.second;
  4634. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", guild->GetID(), guild->GetName());
  4635. }
  4636. }
  4637. }
  4638. /*
  4639. Function: Command_GuildsRemove()
  4640. Purpose : Removes a player from a guild
  4641. Params : guild name|guild id, player name
  4642. Dev : Scatman
  4643. Example : /guilds remove 1 Admin = removes Admin from guild 1
  4644. */
  4645. void Commands::Command_GuildsRemove(Client* client, Seperator* sep)
  4646. {
  4647. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  4648. {
  4649. Guild* guild = 0;
  4650. bool found = true;
  4651. if (sep->IsNumber(0))
  4652. {
  4653. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  4654. if (!guild)
  4655. {
  4656. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  4657. found = false;
  4658. }
  4659. }
  4660. else
  4661. {
  4662. guild = guild_list.GetGuild(sep->arg[0]);
  4663. if (!guild)
  4664. {
  4665. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  4666. found = false;
  4667. }
  4668. }
  4669. if (found)
  4670. {
  4671. Client* to_client = 0;
  4672. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  4673. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  4674. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  4675. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  4676. if (to_client)
  4677. {
  4678. Player* to_player = to_client->GetPlayer();
  4679. if (to_player->GetGuild())
  4680. {
  4681. if (to_player->GetGuild() == guild)
  4682. {
  4683. guild->KickGuildMember(client, to_player->GetName());
  4684. }
  4685. else
  4686. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in the guild '%s'.", to_player->GetName(), guild->GetName());
  4687. }
  4688. else
  4689. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in a guild.", to_player->GetName());
  4690. }
  4691. else
  4692. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  4693. }
  4694. }
  4695. else
  4696. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds remove [guild name|guild id] (player name).");
  4697. }
  4698. /*
  4699. Function: Command_InspectPlayer()
  4700. Purpose : Handle the Inspect functions
  4701. Params : Client to inspect
  4702. Dev : Scatman
  4703. Example : /inspect Scatman
  4704. */
  4705. void Commands::Command_InspectPlayer(Client* client, Seperator* sep)
  4706. {
  4707. if (sep && sep->arg[0])
  4708. {
  4709. Client* inspect_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  4710. if (inspect_client)
  4711. client->InspectPlayer(inspect_client->GetPlayer());
  4712. }
  4713. else
  4714. {
  4715. Spawn* target = client->GetPlayer()->GetTarget();
  4716. if (target && target->IsPlayer())
  4717. client->InspectPlayer((Player*)target);
  4718. }
  4719. }
  4720. /*
  4721. Function: Command_Inventory()
  4722. Purpose : Handle changes in player inventory
  4723. Params : <TBD>
  4724. Dev : All
  4725. Example : /inventory delete item_id
  4726. */
  4727. void Commands::Command_Inventory(Client* client, Seperator* sep, EQ2_RemoteCommandString* command)
  4728. {
  4729. PrintSep(sep, "Command_Inventory"); // temp to figure out the params
  4730. Player* player = client->GetPlayer();
  4731. if(sep && sep->arg[0][0])
  4732. {
  4733. LogWrite(COMMAND__INFO, 0, "Command", "command: %s", command->command.data.c_str());
  4734. if(client->GetPlayer()->GetHP() == 0)
  4735. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  4736. else if(sep->arg[1][0] && strncasecmp("destroy", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  4737. {
  4738. int16 index = atoi(sep->arg[1]);
  4739. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  4740. if(item)
  4741. {
  4742. if(item->GetItemScript() && lua_interface)
  4743. lua_interface->RunItemScript(item->GetItemScript(), "destroyed", item, client->GetPlayer());
  4744. int32 bag_id = item->details.inv_slot_id;
  4745. database.DeleteItem(client->GetCharacterID(), item, 0);
  4746. client->GetPlayer()->item_list.DestroyItem(index);
  4747. EQ2Packet* outapp = client->GetPlayer()->SendInventoryUpdate(client->GetVersion());
  4748. client->QueuePacket(outapp);
  4749. outapp = client->GetPlayer()->SendBagUpdate(bag_id, client->GetVersion());
  4750. if (outapp)
  4751. client->QueuePacket(outapp);
  4752. }
  4753. }
  4754. else if(sep->arg[4][0] && strncasecmp("move", sep->arg[0], 4) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3) && sep->IsNumber(4))
  4755. {
  4756. int16 from_index = atoi(sep->arg[1]);
  4757. sint16 to_slot = atoi(sep->arg[2]);
  4758. sint32 bag_id = atol(sep->arg[3]);
  4759. int8 charges = atoi(sep->arg[4]);
  4760. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(from_index);
  4761. if(bag_id == -4 && !client->GetPlayer()->item_list.SharedBankAddAllowed(item))
  4762. {
  4763. client->SimpleMessage(CHANNEL_COLOR_RED, "That item (or an item inside) cannot be shared.");
  4764. return;
  4765. }
  4766. sint32 old_inventory_id = 0;
  4767. if(item)
  4768. old_inventory_id = item->details.inv_slot_id;
  4769. //autobank
  4770. if (bag_id == -3 && to_slot == -1)
  4771. {
  4772. if (player->HasFreeBankSlot())
  4773. to_slot = player->FindFreeBankSlot();
  4774. else
  4775. {
  4776. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free bank slots.");
  4777. return;
  4778. }
  4779. }
  4780. //auto inventory
  4781. if (bag_id == 0 && to_slot == -1)
  4782. {
  4783. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  4784. {
  4785. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free slots.");
  4786. return;
  4787. }
  4788. }
  4789. EQ2Packet* outapp = client->GetPlayer()->MoveInventoryItem(bag_id, from_index, (int8)to_slot, charges, client->GetVersion());
  4790. client->QueuePacket(outapp);
  4791. //removed from bag send update
  4792. if(old_inventory_id > 0 && item && item->details.inv_slot_id != old_inventory_id)
  4793. {
  4794. outapp = client->GetPlayer()->SendBagUpdate(old_inventory_id, client->GetVersion());
  4795. if(outapp)
  4796. client->QueuePacket(outapp);
  4797. }
  4798. if(item && item->details.inv_slot_id > 0 && item->details.inv_slot_id != old_inventory_id)
  4799. {
  4800. outapp = client->GetPlayer()->SendBagUpdate(item->details.inv_slot_id, client->GetVersion());
  4801. if(outapp)
  4802. client->QueuePacket(outapp);
  4803. }
  4804. }
  4805. else if(sep->arg[1][0] && strncasecmp("equip", sep->arg[0], 5) == 0 && sep->IsNumber(1))
  4806. {
  4807. if(client->GetPlayer()->EngagedInCombat())
  4808. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not equip items while in combat.");
  4809. else
  4810. {
  4811. int16 index = atoi(sep->arg[1]);
  4812. int8 slot_id = 255;
  4813. if(sep->arg[2][0] && sep->IsNumber(2))
  4814. slot_id = atoi(sep->arg[2]);
  4815. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), slot_id);
  4816. EQ2Packet* outapp = 0;
  4817. for(int32 i=0;i<packets.size();i++)
  4818. {
  4819. outapp = packets[i];
  4820. if(outapp)
  4821. client->QueuePacket(outapp);
  4822. }
  4823. client->GetPlayer()->ChangePrimaryWeapon();
  4824. client->GetPlayer()->ChangeSecondaryWeapon();
  4825. client->GetPlayer()->ChangeRangedWeapon();
  4826. EQ2Packet* characterSheetPackets = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion());
  4827. client->QueuePacket(characterSheetPackets);
  4828. }
  4829. }
  4830. else if (sep->arg[1][0] && strncasecmp("unpack", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  4831. {
  4832. if (client->GetPlayer()->EngagedInCombat())
  4833. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unpack items while in combat.");
  4834. else {
  4835. int16 index = atoi(sep->arg[1]);
  4836. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  4837. if (item) {
  4838. // client->GetPlayer()->item_list.DestroyItem(index);
  4839. if (item->item_sets.size() > 0) {
  4840. for (int32 i = 0; i < item->item_sets.size(); i++) {
  4841. ItemSet* set = item->item_sets[i];
  4842. if (set->item_stack_size == 0)
  4843. set->item_stack_size += 1;
  4844. client->AddItem(set->item_id, set->item_stack_size);
  4845. }
  4846. }
  4847. }
  4848. client->RemoveItem(item, 1);
  4849. }
  4850. }
  4851. else if(sep->arg[1][0] && strncasecmp("unequip", sep->arg[0], 7) == 0 && sep->IsNumber(1))
  4852. {
  4853. if(client->GetPlayer()->EngagedInCombat())
  4854. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unequip items while in combat.");
  4855. else
  4856. {
  4857. int16 index = atoi(sep->arg[1]);
  4858. sint32 bag_id = -999;
  4859. int8 to_slot = 255;
  4860. if(sep->arg[3][0])
  4861. {
  4862. if(sep->IsNumber(2))
  4863. bag_id = atol(sep->arg[2]);
  4864. if(sep->IsNumber(3))
  4865. to_slot = atoi(sep->arg[3]);
  4866. }
  4867. vector<EQ2Packet*> packets = client->GetPlayer()->UnequipItem(index, bag_id, to_slot, client->GetVersion());
  4868. EQ2Packet* outapp = 0;
  4869. for(int32 i=0;i<packets.size();i++)
  4870. {
  4871. outapp = packets[i];
  4872. if(outapp)
  4873. client->QueuePacket(outapp);
  4874. }
  4875. client->GetPlayer()->ChangePrimaryWeapon();
  4876. client->GetPlayer()->ChangeSecondaryWeapon();
  4877. client->GetPlayer()->ChangeRangedWeapon();
  4878. EQ2Packet* characterSheetPackets = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion());
  4879. client->QueuePacket(characterSheetPackets);
  4880. }
  4881. }
  4882. else if(sep->arg[2][0] && strncasecmp("swap_equip", sep->arg[0], 10) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  4883. {
  4884. LogWrite(MISC__TODO, 1, "TODO", " fix this, need to get how live does it\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  4885. int16 index1 = atoi(sep->arg[1]);
  4886. int16 index2 = atoi(sep->arg[2]);
  4887. EQ2Packet* outapp = client->GetPlayer()->SwapEquippedItems(index1, index2, client->GetVersion());
  4888. if(outapp)
  4889. client->QueuePacket(outapp);
  4890. else
  4891. {
  4892. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to swap items");
  4893. return;
  4894. }
  4895. }
  4896. else if (sep->arg[2][0] && strncasecmp("pop", sep->arg[0], 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  4897. {
  4898. sint16 to_slot = atoi(sep->arg[1]);
  4899. sint32 bag_id = atoi(sep->arg[2]);
  4900. Item* item = client->GetPlayer()->item_list.GetOverflowItem();
  4901. if (item) {
  4902. //auto inventory
  4903. if (bag_id == 0 && to_slot == -1)
  4904. {
  4905. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  4906. {
  4907. client->SimpleMessage(CHANNEL_ERROR, "You do not have any free slots.");
  4908. return;
  4909. }
  4910. // Set the slot for the item
  4911. item->details.inv_slot_id = bag_id;
  4912. item->details.slot_id = to_slot;
  4913. // Flag the item so it gets saved in its new location
  4914. item->save_needed = true;
  4915. // Add the item to its new location
  4916. player->item_list.AddItem(item);
  4917. // Remove the item from the overflow list
  4918. player->item_list.RemoveOverflowItem(item);
  4919. // Send the inventory update packet
  4920. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  4921. return;
  4922. }
  4923. else if (bag_id == -3 && to_slot == -1) {
  4924. // Auto Bank
  4925. if (!player->item_list.GetFirstFreeBankSlot(&bag_id, &to_slot)) {
  4926. client->SimpleMessage(CHANNEL_STATUS, "You do not have any free bank slots.");
  4927. return;
  4928. }
  4929. item->details.inv_slot_id = bag_id;
  4930. item->details.slot_id = to_slot;
  4931. item->save_needed = true;
  4932. player->item_list.AddItem(item);
  4933. player->item_list.RemoveOverflowItem(item);
  4934. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  4935. }
  4936. else if (bag_id == -4) {
  4937. // Shared Bank
  4938. if (!player->item_list.SharedBankAddAllowed(item)) {
  4939. client->SimpleMessage(CHANNEL_STATUS, "That item (or an item inside) cannot be shared.");
  4940. return;
  4941. }
  4942. Item* tmp_item = player->item_list.GetItem(-4, to_slot);
  4943. if (tmp_item) {
  4944. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  4945. return;
  4946. }
  4947. else {
  4948. item->details.inv_slot_id = bag_id;
  4949. item->details.slot_id = to_slot;
  4950. item->save_needed = true;
  4951. player->item_list.AddItem(item);
  4952. player->item_list.RemoveOverflowItem(item);
  4953. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  4954. return;
  4955. }
  4956. }
  4957. else {
  4958. // Try to get an item from the given bag id and slot id
  4959. Item* tmp_item = player->item_list.GetItem(bag_id, to_slot);
  4960. // Check to see if we got an item, if we do send an error,
  4961. // if we don't put the overflow item into this slot
  4962. if (tmp_item) {
  4963. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  4964. }
  4965. else {
  4966. item->details.inv_slot_id = bag_id;
  4967. item->details.slot_id = to_slot;
  4968. item->save_needed = true;
  4969. player->item_list.AddItem(item);
  4970. player->item_list.RemoveOverflowItem(item);
  4971. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  4972. return;
  4973. }
  4974. }
  4975. }
  4976. }
  4977. }
  4978. else
  4979. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /inventory {destroy|move|equip|unequip|swap_equip|pop} {item_id} [to_slot] [bag_id]");
  4980. }
  4981. /*
  4982. Function: Command_IRC()
  4983. Purpose : Handle the IRC functions
  4984. Params : IRC Commands
  4985. Dev : Scatman
  4986. Example : /irc say #Channel Hello World!
  4987. */
  4988. void Commands::Command_IRC(Client* client, Seperator* sep)
  4989. {
  4990. if (!rule_manager.GetGlobalRule(R_World, IRCEnabled)->GetBool()) {
  4991. client->SimpleMessage(CHANNEL_STATUS, "IRC is currently disabled on this server");
  4992. return;
  4993. }
  4994. if (sep && sep->arg[0][0]) {
  4995. if (strcasecmp(sep->arg[0], "say") == 0) {
  4996. if (sep->arg[1][0] && sep->arg[2][0]) {
  4997. if (sep->IsNumber(sep->arg[1]))
  4998. irc.Say(client, atoul(sep->arg[1]), sep->argplus[2]);
  4999. else
  5000. irc.Say(client, sep->arg[1], sep->argplus[2]);
  5001. }
  5002. else
  5003. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc say <channel name | channel index> <message>");
  5004. }
  5005. else if (strcasecmp(sep->arg[0], "join") == 0) {
  5006. if (sep->arg[1][0])
  5007. irc.JoinChannel(client, sep->arg[1]);
  5008. else
  5009. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc join <channel name>");
  5010. }
  5011. else if (strcasecmp(sep->arg[0], "leave") == 0) {
  5012. if (sep->arg[1][0])
  5013. irc.LeaveChannel(client, sep->arg[1]);
  5014. else
  5015. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc leave <channel name>");
  5016. }
  5017. else if (strcasecmp(sep->arg[0], "list") == 0)
  5018. irc.ListChannels(client);
  5019. else if (strcasecmp(sep->arg[0], "connect") == 0) {
  5020. if (sep->arg[1][0] && sep->arg[2][0] && sep->IsNumber(2))
  5021. irc.ConnectToServer(client, sep->arg[1], atoi(sep->arg[2]), sep->arg[3]);
  5022. else
  5023. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc connect <host> <port> (nick)");
  5024. }
  5025. else if (strcasecmp(sep->arg[0], "disconnect") == 0)
  5026. irc.DisconnectFromServer(client);
  5027. else
  5028. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown IRC command.");
  5029. }
  5030. else
  5031. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown IRC command.");
  5032. }
  5033. /*
  5034. Function: Command_Languages()
  5035. Purpose : Show's languages the player knows
  5036. Params :
  5037. Dev : Zcoretri
  5038. Example :
  5039. */
  5040. void Commands::Command_Languages(Client* client, Seperator* sep)
  5041. {
  5042. list<Language*>* languages = client->GetPlayer()->GetPlayerLanguages()->GetAllLanguages();
  5043. list<Language*>::iterator itr;
  5044. Language* language;
  5045. client->Message(CHANNEL_COLOR_WHITE, "You know the following languages:");
  5046. for(itr = languages->begin(); itr != languages->end(); itr++)
  5047. {
  5048. language = *itr;
  5049. client->Message(CHANNEL_COLOR_WHITE, "%s", language->GetName());
  5050. }
  5051. }
  5052. /*
  5053. Function: Command_SetLanguage()
  5054. Purpose : Handles language commands
  5055. Params : Language ID
  5056. Dev : Zcoretri
  5057. Example :
  5058. */
  5059. void Commands::Command_SetLanguage(Client* client, Seperator* sep)
  5060. {
  5061. Player* player = client->GetPlayer();
  5062. if (sep && sep->arg[0])
  5063. {
  5064. if(!sep->IsNumber(0))
  5065. {
  5066. //String passed in
  5067. const char* value = sep->arg[0];
  5068. if(strncasecmp(value, "Common", strlen(value)) == 0)
  5069. {
  5070. database.SaveCharacterCurrentLang(0, client->GetCharacterID(), client);
  5071. client->SendLanguagesUpdate(0);
  5072. client->Message(CHANNEL_COLOR_WHITE, "You are now speaking %s", value);
  5073. }
  5074. else
  5075. {
  5076. if(player->HasLanguage(value))
  5077. {
  5078. Language* language = player->GetPlayerLanguages()->GetLanguageByName(value);
  5079. database.SaveCharacterCurrentLang(language->GetID(), client->GetCharacterID(), client);
  5080. client->SendLanguagesUpdate(language->GetID());
  5081. client->Message(CHANNEL_COLOR_WHITE, "You are now speaking %s", language->GetName());
  5082. }
  5083. else
  5084. client->Message(CHANNEL_COLOR_WHITE, "You do not know how to speak %s", value);
  5085. }
  5086. }
  5087. else
  5088. {
  5089. //Number passed in
  5090. int32 id = atoul(sep->arg[0]);
  5091. if(player->HasLanguage(id))
  5092. {
  5093. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  5094. database.SaveCharacterCurrentLang(id, client->GetCharacterID(), client);
  5095. client->SendLanguagesUpdate(id);
  5096. client->Message(CHANNEL_COLOR_WHITE, "You are now speaking %s", language->GetName());
  5097. }
  5098. else
  5099. {
  5100. Language* language = master_languages_list.GetLanguage(id);
  5101. client->Message(CHANNEL_COLOR_WHITE, "You do not know how to speak %s", language->GetName());
  5102. }
  5103. }
  5104. }
  5105. else
  5106. {
  5107. //No value was passed in
  5108. int32 id = database.GetCharacterCurrentLang(client->GetCharacterID(), player);
  5109. if(id > 0)
  5110. {
  5111. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  5112. client->Message(CHANNEL_COLOR_WHITE, "You are currently speaking %s ", language->GetName());
  5113. }
  5114. else
  5115. client->Message(CHANNEL_COLOR_WHITE, "You are currently speaking Common");
  5116. }
  5117. }
  5118. /*
  5119. Function: Command_LastName()
  5120. Purpose : Sets player surname
  5121. Params : Name text
  5122. Dev : theFoof
  5123. Example :
  5124. */
  5125. void Commands::Command_LastName(Client* client, Seperator* sep)
  5126. {
  5127. if (!client)
  5128. return;
  5129. if (sep && sep->arg[0])
  5130. {
  5131. if (!client->GetPlayer()->get_character_flag(CF_ENABLE_CHANGE_LASTNAME)){
  5132. client->Message(CHANNEL_COLOR_YELLOW, "You must be atleast level %i to change your last name.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  5133. return;
  5134. }
  5135. client->RemovePendingLastName();
  5136. uchar* checkname = (uchar*)sep->arg[0];
  5137. bool valid_name = true;
  5138. for (int32 i = 0; i < strlen(sep->arg[0]); i++) {
  5139. if (!alpha_check(checkname[i])) {
  5140. valid_name = false;
  5141. break;
  5142. }
  5143. }
  5144. if (!valid_name) {
  5145. client->Message(CHANNEL_COLOR_YELLOW, "Your last name can only contain letters.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  5146. return;
  5147. }
  5148. string last_name = (string)sep->arg[0];
  5149. int8 max_length = rule_manager.GetGlobalRule(R_Player, MaxLastNameLength)->GetInt8();
  5150. int8 min_length = rule_manager.GetGlobalRule(R_Player, MinLastNameLength)->GetInt8();
  5151. if (last_name.length() <= max_length && last_name.length() >= min_length){
  5152. client->SetPendingLastName(last_name);
  5153. client->SendLastNameConfirmation();
  5154. }
  5155. else
  5156. client->Message(CHANNEL_COLOR_YELLOW, "Your last name must be between %i and %i characters long.", min_length, max_length);
  5157. }
  5158. }
  5159. /*
  5160. Function: Command_ConfirmLastName()
  5161. Purpose : Confirms setting of player surname
  5162. Params : Name text
  5163. Dev : theFoof
  5164. Example :
  5165. */
  5166. void Commands::Command_ConfirmLastName(Client* client, Seperator* sep)
  5167. {
  5168. if (!client)
  5169. return;
  5170. string* name = client->GetPendingLastName();
  5171. if (name){
  5172. Player* player = client->GetPlayer();
  5173. player->SetLastName(name->c_str(), false);
  5174. client->SendTitleUpdate();
  5175. player->SetCharSheetChanged(true);
  5176. client->RemovePendingLastName();
  5177. }
  5178. }
  5179. /*
  5180. Function: Command_Location()
  5181. Purpose : Display's Help for /location commands
  5182. Params :
  5183. Dev : Scatman
  5184. Example : /location = show's help for command
  5185. */
  5186. void Commands::Command_Location(Client* client)
  5187. {
  5188. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Valid /location commands are:");
  5189. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location create [name] (include y). Include y defaults to false");
  5190. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location add [location id]");
  5191. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location remove [location point id]");
  5192. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location delete [location id]");
  5193. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location list [locations|points] [location id if points used]");
  5194. }
  5195. /*
  5196. Function: Command_LocationAdd()
  5197. Purpose : Add's a location to an existing location config
  5198. Params : location_id
  5199. Dev : Scatman
  5200. Example : /location add {location_id}
  5201. */
  5202. void Commands::Command_LocationAdd(Client* client, Seperator* sep)
  5203. {
  5204. if (sep && sep->arg[0] && sep->IsNumber(0))
  5205. {
  5206. int32 location_id = atoul(sep->arg[0]);
  5207. float x = client->GetPlayer()->GetX();
  5208. float y = client->GetPlayer()->GetY();
  5209. float z = client->GetPlayer()->GetZ();
  5210. if (database.AddLocationPoint(location_id, x, y, z))
  5211. client->Message(CHANNEL_COLOR_YELLOW, "Point (%f, %f, %f) was successfully added to location %u", x, y, z, location_id);
  5212. else
  5213. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist. Use /location create to create one", location_id);
  5214. }
  5215. else
  5216. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location add [location id]");
  5217. }
  5218. /*
  5219. Function: Command_LocationCreate()
  5220. Purpose : Creates a new location config
  5221. Params : location name, 0/1 for include_y (optional)
  5222. Dev : Scatman
  5223. Example : /location create Test 1 = creates a new location named Test with include_y True
  5224. */
  5225. void Commands::Command_LocationCreate(Client* client, Seperator* sep)
  5226. {
  5227. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  5228. {
  5229. const char* name = sep->arg[0];
  5230. bool include_y = false;
  5231. if (sep->arg[1] && sep->IsNumber(1) && atoi(sep->arg[1]) > 0)
  5232. include_y = true;
  5233. int32 location_id = database.CreateLocation(client->GetPlayer()->GetZone()->GetZoneID(), client->GetPlayer()->appearance.pos.grid_id, name, include_y);
  5234. if (location_id > 0)
  5235. client->Message(CHANNEL_COLOR_YELLOW, "Location '%s' was successfully created with location id %u", name, location_id);
  5236. else
  5237. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the requested location");
  5238. }
  5239. else
  5240. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location create [name] (include_y). Include y defaults to false");
  5241. }
  5242. /*
  5243. Function: Command_LocationDelete()
  5244. Purpose : Delete's a location config and all it's location points
  5245. Params : location_id
  5246. Dev : Scatman
  5247. Example : /location delete {location_id}
  5248. */
  5249. void Commands::Command_LocationDelete(Client* client, Seperator* sep)
  5250. {
  5251. if (sep && sep->arg[0] && sep->IsNumber(0))
  5252. {
  5253. int32 location_id = atoul(sep->arg[0]);
  5254. if (database.DeleteLocation(location_id))
  5255. client->Message(CHANNEL_COLOR_YELLOW, "Location id %u and all its points were successfully deleted", location_id);
  5256. else
  5257. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist", location_id);
  5258. }
  5259. else
  5260. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location delete [location id]");
  5261. }
  5262. /*
  5263. Function: Command_LocationList()
  5264. Purpose : Display's a list of location points
  5265. Params : location_id
  5266. Dev : Scatman
  5267. Example : /location list {location_id}
  5268. */
  5269. void Commands::Command_LocationList(Client* client, Seperator* sep)
  5270. {
  5271. if (sep && sep->arg[0])
  5272. {
  5273. const char* option = sep->arg[0];
  5274. if (strncmp(option, "locations", strlen(option)) == 0)
  5275. database.ListLocations(client);
  5276. else if (strncmp(option, "points", strlen(option)) == 0 && sep->arg[1] && sep->IsNumber(1))
  5277. {
  5278. int32 location_id = atoul(sep->arg[1]);
  5279. database.ListLocationPoints(client, location_id);
  5280. }
  5281. else
  5282. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  5283. }
  5284. else
  5285. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  5286. }
  5287. /*
  5288. Function: Command_LocationRemove()
  5289. Purpose : Removes a single location point from a location config
  5290. Params : location_point_id (gotten from /location list {id})
  5291. Dev : Scatman
  5292. Example : /location remove 1 = will remove location_point_id 1
  5293. */
  5294. void Commands::Command_LocationRemove(Client* client, Seperator* sep)
  5295. {
  5296. if (sep && sep->arg[0] && sep->IsNumber(0))
  5297. {
  5298. int32 location_point_id = atoul(sep->arg[0]);
  5299. if (database.DeleteLocationPoint(location_point_id))
  5300. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Location point was successfully deleted");
  5301. else
  5302. client->Message(CHANNEL_COLOR_YELLOW, "Location point with ID %u does not exist", location_point_id);
  5303. }
  5304. else
  5305. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location remove [location point id]");
  5306. }
  5307. /*
  5308. Function: Command_Merchant()
  5309. Purpose : Handles Merchant commands
  5310. Params : list
  5311. Dev : Scatman
  5312. Example : /merchant list
  5313. */
  5314. void Commands::Command_Merchant(Client* client, Seperator* sep, int handler)
  5315. {
  5316. if( handler == COMMAND_MERCHANT )
  5317. {
  5318. // /merchant command by itself shows help (to be extended)
  5319. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  5320. return;
  5321. }
  5322. else if( handler == COMMAND_MERCHANT_LIST )
  5323. {
  5324. // /merchant list command expects "description" param
  5325. if (sep && sep->arg[0])
  5326. {
  5327. const char* merchant_description = sep->argplus[0];
  5328. client->Message(CHANNEL_COLOR_YELLOW, "Listing merchants like '%s':", merchant_description);
  5329. map<int32, MerchantInfo*>* merchant_info = world.GetMerchantInfo();
  5330. map<int32, MerchantInfo*>::iterator itr;
  5331. for (itr = merchant_info->begin(); itr != merchant_info->end(); itr++)
  5332. {
  5333. string description = database.GetMerchantDescription(itr->first);
  5334. if (ToLower(description).find(ToLower(string(merchant_description))) < 0xFFFFFFFF)
  5335. client->Message(CHANNEL_COLOR_YELLOW, "Merchant ID: %u, Description: %s", itr->first, description.c_str());
  5336. }
  5337. }
  5338. else // no description
  5339. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  5340. }
  5341. }
  5342. /*
  5343. Function: Command_Modify()
  5344. Purpose : to replace our other "set" commands
  5345. Params : System = the system to modify, Action = the action to perform, Target = what to change (target, or index)
  5346. Dev : John Adams
  5347. Example : /modify spell set name "Aegolism III"
  5348. */
  5349. void Commands::Command_Modify(Client* client)
  5350. {
  5351. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /modify [system] [action] [field] [value] {target|id}");
  5352. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Systems: character, faction, guild, item, skill, spawn, spell, zone");
  5353. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Actions: set, create, delete, add, remove");
  5354. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Value : field name in the table being modified");
  5355. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target : modify current target, or specified {system} ID");
  5356. }
  5357. /*
  5358. Function: Command_ModifySpawn()
  5359. Purpose : replace "spawn set" commands
  5360. Params : Action : the action to perform (or special handler)
  5361. : Field : the DB field to change
  5362. : Value : what to set the value to
  5363. : Target : what object to change (my target, or spawn_id)
  5364. Dev : John Adams
  5365. Example : /modify spawn set name "Lady Vox"
  5366. :
  5367. Note : Special Handlers, like "zoneto" for Signs
  5368. : /modify spawn zoneto
  5369. : Will set a sign's zone x/y/z to my current coords
  5370. */
  5371. void Commands::Command_ModifySpawn(Client* client, Seperator* sep)
  5372. {
  5373. PrintSep(sep, "COMMAND_MODIFY");
  5374. // need at least 2 args for a valid command
  5375. if( sep && sep->arg[1] )
  5376. {
  5377. // JA: just a quick implementation because I need it :)
  5378. if (strcmp(sep->arg[0], "zoneto") == 0)
  5379. {
  5380. if( sep->IsNumber(1) )
  5381. {
  5382. int32 spawn_id = atoul(sep->arg[1]);
  5383. float x_coord = client->GetPlayer()->GetX();
  5384. float y_coord = client->GetPlayer()->GetY();
  5385. float z_coord = client->GetPlayer()->GetZ();
  5386. float h_coord = client->GetPlayer()->GetHeading();
  5387. database.SaveSignZoneToCoords(spawn_id, x_coord, y_coord, z_coord, h_coord);
  5388. }
  5389. else
  5390. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify spawn zoneto spawn_id - sets spawn_id to your coords");
  5391. }
  5392. }
  5393. else
  5394. Command_Modify(client);
  5395. }
  5396. /*
  5397. Function: Command_ModifyCharacter()
  5398. Purpose : to replace our other "set" commands
  5399. Params : Action : Add, Remove
  5400. : Field : copper, silver, gold, plat
  5401. : Value : min 1, max unlimited
  5402. : Target : Self, Player
  5403. Dev : Cynnar
  5404. Example : /modify character add gold 50
  5405. : /modify character remove silver 25
  5406. */
  5407. void Commands::Command_ModifyCharacter(Client* client, Seperator* sep)
  5408. {
  5409. PrintSep(sep, "COMMAND_MODIFY");
  5410. int64 value = 0;
  5411. Player* player = client->GetPlayer();
  5412. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  5413. player = (Player*)player->GetTarget();
  5414. // need at least 2 args for a valid command
  5415. if( sep && sep->arg[1] )
  5416. {
  5417. if (strcmp(sep->arg[0], "add") == 0)
  5418. {
  5419. if (strcmp(sep->arg[1], "copper") == 0)
  5420. {
  5421. value = atoi64(sep->arg[2]);
  5422. player->AddCoins(value);
  5423. if (client->GetPlayer() == player)
  5424. {
  5425. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu copper coin%s", value, (value > 1 ? "s" : ""));
  5426. }
  5427. else {
  5428. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu copper coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  5429. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu copper coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  5430. }
  5431. }
  5432. else if (strcmp(sep->arg[1], "silver") == 0)
  5433. {
  5434. value = atoi64(sep->arg[2]) * 100;
  5435. player->AddCoins(value);
  5436. if (client->GetPlayer() == player)
  5437. {
  5438. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu silver coin%s", value / 100, (value > 1 ? "s" : ""));
  5439. }
  5440. else {
  5441. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu silver coin%s", player->GetName(), value / 100, (value > 1 ? "s" : ""));
  5442. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu silver coin%s", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  5443. }
  5444. }
  5445. else if (strcmp(sep->arg[1], "gold") == 0)
  5446. {
  5447. value = atoi64(sep->arg[2]) * 10000;
  5448. player->AddCoins(value);
  5449. if (client->GetPlayer() == player)
  5450. {
  5451. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu gold coin%s", value / 10000, (value > 1 ? "s" : ""));
  5452. }
  5453. else {
  5454. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu gold coin%s", player->GetName(), value / 10000, (value > 1 ? "s" : ""));
  5455. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu gold coin%s", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  5456. }
  5457. }
  5458. else if (strcmp(sep->arg[1], "plat") == 0)
  5459. {
  5460. value = atoi64(sep->arg[2]) * 1000000;
  5461. player->AddCoins(value);
  5462. if (client->GetPlayer() == player)
  5463. {
  5464. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu platinum coin%s", value / 1000000, (value > 1 ? "s" : ""));
  5465. }
  5466. else {
  5467. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu platinum coin%s", player->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  5468. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu platinum coin%s", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  5469. }
  5470. }
  5471. else
  5472. {
  5473. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  5474. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  5475. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  5476. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character add copper 20");
  5477. }
  5478. }
  5479. else if (strcmp(sep->arg[0], "remove") == 0)
  5480. {
  5481. if (strcmp(sep->arg[1], "copper") == 0)
  5482. {
  5483. value = atoi64(sep->arg[2]);
  5484. player->RemoveCoins(value);
  5485. if (client->GetPlayer() == player)
  5486. {
  5487. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from yourself", value, (value > 1 ? "s" : ""));
  5488. }
  5489. else {
  5490. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from %s", value, (value > 1 ? "s" : ""), player->GetName());
  5491. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu copper coin%s from you", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  5492. }
  5493. }
  5494. else if (strcmp(sep->arg[1], "silver") == 0)
  5495. {
  5496. value = atoi64(sep->arg[2]) * 100;
  5497. player->RemoveCoins(value);
  5498. if (client->GetPlayer() == player)
  5499. {
  5500. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from yourself", value / 100, (value > 1 ? "s" : ""));
  5501. }
  5502. else {
  5503. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from %s", value / 100, (value > 1 ? "s" : ""), player->GetName());
  5504. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu silver coin%s from you", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  5505. }
  5506. }
  5507. else if (strcmp(sep->arg[1], "gold") == 0)
  5508. {
  5509. value = atoi64(sep->arg[2]) * 10000;
  5510. player->RemoveCoins(value);
  5511. if (client->GetPlayer() == player)
  5512. {
  5513. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from yourself", value / 10000, (value > 1 ? "s" : ""));
  5514. }
  5515. else {
  5516. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from %s", value / 10000, (value > 1 ? "s" : ""), player->GetName());
  5517. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu gold coin%s from you", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  5518. }
  5519. }
  5520. else if (strcmp(sep->arg[1], "plat") == 0)
  5521. {
  5522. value = atoi64(sep->arg[2]) * 1000000;
  5523. player->RemoveCoins(value);
  5524. if (client->GetPlayer() == player)
  5525. {
  5526. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from yourself", value / 1000000, (value > 1 ? "s" : ""));
  5527. }
  5528. else {
  5529. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from %s", value / 1000000, (value > 1 ? "s" : ""), player->GetName());
  5530. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu platinum coin%s from you", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  5531. }
  5532. }
  5533. else
  5534. {
  5535. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  5536. }
  5537. }
  5538. else if (strcmp(sep->arg[0], "set") == 0) {
  5539. if (strcmp(sep->arg[1], "tslevel") == 0) {
  5540. int8 level = atoi(sep->arg[2]);
  5541. if (level > 0 && level < 256) {
  5542. if (player) {
  5543. if (client->GetPlayer() == player)
  5544. client->ChangeTSLevel(player->GetTSLevel(), level);
  5545. else
  5546. player->GetZone()->GetClientBySpawn(player)->ChangeTSLevel(player->GetTSLevel(), level);
  5547. }
  5548. }
  5549. else
  5550. client->SimpleMessage(CHANNEL_ERROR, "Level must be between 1 - 255");
  5551. }
  5552. else if (strcmp(sep->arg[1], "tsclass") == 0) {
  5553. int8 tsclass = atoi(sep->arg[2]);
  5554. player->SetTradeskillClass(tsclass);
  5555. player->GetInfoStruct()->tradeskill_class1 = classes.GetTSBaseClass(player->GetTradeskillClass());
  5556. player->GetInfoStruct()->tradeskill_class2 = classes.GetSecondaryTSBaseClass(player->GetTradeskillClass());
  5557. player->GetInfoStruct()->tradeskill_class3 = player->GetTradeskillClass();
  5558. player->SetCharSheetChanged(true);
  5559. }
  5560. }
  5561. }
  5562. else
  5563. {
  5564. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  5565. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  5566. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  5567. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  5568. }
  5569. }
  5570. void Commands::Command_ModifyFaction(Client* client, Seperator* sep)
  5571. {
  5572. PrintSep(sep, "COMMAND_MODIFY");
  5573. // need at least 2 args for a valid command
  5574. if( sep && sep->arg[1] )
  5575. {
  5576. }
  5577. else
  5578. Command_Modify(client);
  5579. }
  5580. void Commands::Command_ModifyGuild(Client* client, Seperator* sep)
  5581. {
  5582. PrintSep(sep, "COMMAND_MODIFY");
  5583. // need at least 2 args for a valid command
  5584. if( sep && sep->arg[1] )
  5585. {
  5586. }
  5587. else
  5588. Command_Modify(client);
  5589. }
  5590. void Commands::Command_ModifyItem(Client* client, Seperator* sep)
  5591. {
  5592. PrintSep(sep, "COMMAND_MODIFY");
  5593. // need at least 2 args for a valid command
  5594. if( sep && sep->arg[1] )
  5595. {
  5596. }
  5597. else
  5598. Command_Modify(client);
  5599. }
  5600. /*
  5601. Function: Command_ModifyQuest()
  5602. Purpose : to list players quest and completed quests
  5603. Params : Action : list, completed
  5604. : Target : Self, Player
  5605. Dev : Cynnar
  5606. Example : /modify quest list
  5607. : /modify quest completed
  5608. */
  5609. void Commands::Command_ModifyQuest(Client* client, Seperator* sep)
  5610. {
  5611. PrintSep(sep, "COMMAND_MODIFY");
  5612. int64 value = 0;
  5613. Player* player = client->GetPlayer();
  5614. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  5615. player = (Player*)player->GetTarget();
  5616. // need at least 2 args for a valid command
  5617. if (sep && sep->arg[1])
  5618. {
  5619. if (strcmp(sep->arg[0], "list") == 0)
  5620. {
  5621. map<int32, Quest*>* quests = player->GetPlayerQuests();
  5622. map<int32, Quest*>::iterator itr;
  5623. client->Message(CHANNEL_COLOR_YELLOW, "%s's Quest List:.", client->GetPlayer()->GetName());
  5624. if (quests->size() == 0)
  5625. client->Message(CHANNEL_COLOR_YELLOW, "%s has no quests.", client->GetPlayer()->GetName());
  5626. else
  5627. {
  5628. for (itr = quests->begin(); itr != quests->end(); itr++)
  5629. {
  5630. Quest* quest = itr->second;
  5631. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  5632. }
  5633. }
  5634. }
  5635. else if (strcmp(sep->arg[0], "completed") == 0)
  5636. {
  5637. map<int32, Quest*>* quests = player->GetCompletedPlayerQuests();
  5638. map<int32, Quest*>::iterator itr;
  5639. client->Message(CHANNEL_COLOR_YELLOW, "%s's Completed Quest List:.", client->GetPlayer()->GetName());
  5640. if (quests->size() == 0)
  5641. client->Message(CHANNEL_COLOR_YELLOW, "%s has no completed quests.", client->GetPlayer()->GetName());
  5642. else
  5643. {
  5644. for (itr = quests->begin(); itr != quests->end(); itr++)
  5645. {
  5646. Quest* quest = itr->second;
  5647. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  5648. }
  5649. }
  5650. }
  5651. // Add in a progress step, and a LogWrite() for tracking GM Commands.
  5652. // LogWrite(LUA__DEBUG, 0, "LUA", "Quest: %s, function: %s", quest->GetName(), function);
  5653. else if (strcmp(sep->arg[0], "remove") == 0)
  5654. {
  5655. int32 quest_id = 0;
  5656. if (sep && sep->arg[1] && sep->IsNumber(1))
  5657. quest_id = atoul(sep->arg[1]);
  5658. if (quest_id > 0)
  5659. {
  5660. if (lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0)
  5661. {
  5662. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  5663. if (quest)
  5664. if (client->GetPlayer() == player)
  5665. {
  5666. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been removed from your journal", quest->GetName());
  5667. }
  5668. else
  5669. {
  5670. client->Message(CHANNEL_COLOR_YELLOW, "You have removed the quest %s from %s's journal", quest->GetName(), player->GetName());
  5671. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s has removed the quest %s from your journal", client->GetPlayer()->GetName(), quest->GetName());
  5672. }
  5673. LogWrite(COMMAND__INFO, 0, "GM Command", "%s removed the quest %s from %s", client->GetPlayer()->GetName(), quest->GetName(), player->GetName());
  5674. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  5675. }
  5676. client->RemovePlayerQuest(quest_id);
  5677. client->GetCurrentZone()->SendQuestUpdates(client);
  5678. }
  5679. }
  5680. else if (strcmp(sep->arg[0], "advance") == 0)
  5681. {
  5682. int32 quest_id = 0;
  5683. int32 step = 0;
  5684. if (sep && sep->arg[1] && sep->IsNumber(1))
  5685. {
  5686. quest_id = atoul(sep->arg[1]);
  5687. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  5688. if (sep && sep->arg[2] && sep->IsNumber(1))
  5689. {
  5690. step = atoul(sep->arg[2]);
  5691. if (quest_id > 0 && step > 0)
  5692. {
  5693. if (player && player->IsPlayer() && quest_id > 0 && step > 0 && (player->player_quests.count(quest_id) > 0))
  5694. {
  5695. if (client)
  5696. {
  5697. client->AddPendingQuestUpdate(quest_id, step);
  5698. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been advanced one step.", quest->GetName());
  5699. LogWrite(COMMAND__INFO, 0, "GM Command", "%s advanced the quest %s one step", client->GetPlayer()->GetName(), quest->GetName());
  5700. }
  5701. }
  5702. }
  5703. else
  5704. {
  5705. client->Message(CHANNEL_COLOR_RED, "Quest ID and Step Number must be greater than 0!");
  5706. }
  5707. }
  5708. else
  5709. {
  5710. client->Message(CHANNEL_COLOR_RED, "Step Number must be a number!");
  5711. }
  5712. }
  5713. else
  5714. {
  5715. client->Message(CHANNEL_COLOR_RED, "Quest ID must be a number!");
  5716. }
  5717. }
  5718. else
  5719. {
  5720. Command_Modify(client);
  5721. }
  5722. }
  5723. else
  5724. {
  5725. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify quest [action] [quest id] [step number]");
  5726. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: list, completed, remove, advance");
  5727. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest list");
  5728. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest remove 156");
  5729. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest advance 50 1");
  5730. }
  5731. }
  5732. void Commands::Command_ModifySkill(Client* client, Seperator* sep)
  5733. {
  5734. PrintSep(sep, "COMMAND_MODIFY");
  5735. // need at least 2 args for a valid command
  5736. if( sep && sep->arg[1] )
  5737. {
  5738. if (strcmp(sep->arg[0], "add") == 0) {
  5739. const char* skill_name = sep->argplus[1];
  5740. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  5741. if (skill) {
  5742. Player* player = 0;
  5743. Client* to_client = 0;
  5744. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  5745. player = (Player*)client->GetPlayer()->GetTarget();
  5746. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  5747. }
  5748. else {
  5749. player = client->GetPlayer();
  5750. to_client = client;
  5751. }
  5752. if (player)
  5753. {
  5754. if (!player->GetSkills()->HasSkill(skill->skill_id))
  5755. {
  5756. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  5757. if (to_client == client) {
  5758. client->Message(CHANNEL_STATUS, "Added skill '%s'.", skill_name);
  5759. }
  5760. else {
  5761. client->Message(CHANNEL_STATUS, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  5762. to_client->Message(CHANNEL_STATUS, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  5763. }
  5764. }
  5765. else
  5766. client->Message(CHANNEL_STATUS, "%s already has the skill '%s'.", to_client == client ? "You" : player->GetName(), skill_name);
  5767. }
  5768. }
  5769. else
  5770. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  5771. }
  5772. else if (strcmp(sep->arg[0], "remove") == 0) {
  5773. const char* skill_name = sep->argplus[1];
  5774. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  5775. if (skill) {
  5776. Player* player = 0;
  5777. Client* to_client = 0;
  5778. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  5779. player = (Player*)client->GetPlayer()->GetTarget();
  5780. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  5781. }
  5782. else {
  5783. player = client->GetPlayer();
  5784. to_client = client;
  5785. }
  5786. if (player)
  5787. {
  5788. if (player->GetSkills()->HasSkill(skill->skill_id))
  5789. {
  5790. player->RemoveSkillFromDB(skill, true);
  5791. if (client == to_client) {
  5792. client->Message(CHANNEL_STATUS, "Removed skill '%s'.", skill_name);
  5793. }
  5794. else {
  5795. client->Message(CHANNEL_STATUS, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  5796. to_client->Message(CHANNEL_STATUS, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  5797. }
  5798. }
  5799. else {
  5800. if (client == to_client)
  5801. client->Message(CHANNEL_STATUS, "You do not have the skill '%s'.", skill_name);
  5802. else
  5803. client->Message(CHANNEL_STATUS, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  5804. }
  5805. }
  5806. }
  5807. else
  5808. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  5809. }
  5810. else if (strcmp(sep->arg[0], "set") == 0) {
  5811. if (!sep->IsNumber(2)) {
  5812. client->Message(CHANNEL_STATUS, "The last parameter must be a number.");
  5813. return;
  5814. }
  5815. const char* skill_name = sep->arg[1];
  5816. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  5817. if (skill) {
  5818. int16 val = atoi(sep->arg[2]);
  5819. Player* player = 0;
  5820. Client* to_client = 0;
  5821. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  5822. player = (Player*)client->GetPlayer()->GetTarget();
  5823. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  5824. }
  5825. else {
  5826. player = client->GetPlayer();
  5827. to_client = client;
  5828. }
  5829. if (player)
  5830. {
  5831. if (player->GetSkills()->HasSkill(skill->skill_id)) {
  5832. player->GetSkills()->SetSkill(skill->skill_id, val);
  5833. if (client != to_client)
  5834. client->Message(CHANNEL_STATUS, "You set %s's '%s' skill to %i.", player->GetName(), skill_name, val);
  5835. to_client->Message(CHANNEL_STATUS, "Your '%s' skill has been set to %i.", skill_name, val);
  5836. }
  5837. else {
  5838. client->Message(CHANNEL_STATUS, "Target does not have the skill '%s'.", skill_name);
  5839. }
  5840. }
  5841. }
  5842. else {
  5843. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  5844. }
  5845. }
  5846. else {
  5847. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  5848. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  5849. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  5850. }
  5851. }
  5852. else {
  5853. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  5854. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  5855. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  5856. }
  5857. }
  5858. void Commands::Command_ModifySpell(Client* client, Seperator* sep)
  5859. {
  5860. PrintSep(sep, "COMMAND_MODIFY");
  5861. // need at least 2 args for a valid command
  5862. if( sep && sep->arg[1] )
  5863. {
  5864. }
  5865. else
  5866. Command_Modify(client);
  5867. }
  5868. void Commands::Command_ModifyZone(Client* client, Seperator* sep)
  5869. {
  5870. PrintSep(sep, "COMMAND_MODIFY");
  5871. // need at least 2 args for a valid command
  5872. if( sep && sep->arg[1] )
  5873. {
  5874. }
  5875. else
  5876. Command_Modify(client);
  5877. }
  5878. /*
  5879. Function: Command_MOTD()
  5880. Purpose : Displays server MOTD
  5881. Params :
  5882. Dev : LethalEncounter
  5883. Example : /motd
  5884. */
  5885. void Commands::Command_MOTD(Client* client)
  5886. {
  5887. if (client)
  5888. ClientPacketFunctions::SendMOTD(client);
  5889. }
  5890. /*
  5891. Function: Command_Pet()
  5892. Purpose : Handle Pet {Command} commands
  5893. Params : attack, backoff, preserve_master, preserve_self, follow, stay, getlost
  5894. Dev :
  5895. Example : /pet preserve_master
  5896. */
  5897. void Commands::Command_Pet(Client* client, Seperator* sep)
  5898. {
  5899. PrintSep(sep, "COMMAND_PET");
  5900. //LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Pet Commands");
  5901. //client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  5902. if (strcmp(sep->arg[0], "hide") == 0) {
  5903. // doing /pet hide will toggle the hide status on all the pets that can be hidden
  5904. Entity* pet = client->GetPlayer()->GetDeityPet();
  5905. if (pet) {
  5906. if (pet->IsPrivateSpawn())
  5907. client->GetPlayer()->HideDeityPet(false);
  5908. else
  5909. client->GetPlayer()->HideDeityPet(true);
  5910. }
  5911. pet = client->GetPlayer()->GetCosmeticPet();
  5912. if (pet) {
  5913. if (pet->IsPrivateSpawn())
  5914. client->GetPlayer()->HideCosmeticPet(false);
  5915. else
  5916. client->GetPlayer()->HideCosmeticPet(true);
  5917. }
  5918. return;
  5919. }
  5920. // below is for all combat pets
  5921. if (!client->GetPlayer()->HasPet()) {
  5922. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a pet.");
  5923. return;
  5924. }
  5925. if (strcmp(sep->arg[0], "stay") == 0) {
  5926. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to stay.");
  5927. client->GetPlayer()->GetInfoStruct()->pet_movement = 1;
  5928. client->GetPlayer()->SetCharSheetChanged(true);
  5929. if (client->GetPlayer()->GetPet())
  5930. client->GetPlayer()->GetPet()->following = false;
  5931. if (client->GetPlayer()->GetCharmedPet())
  5932. client->GetPlayer()->GetCharmedPet()->following = false;
  5933. }
  5934. else if (strcmp(sep->arg[0], "follow") == 0) {
  5935. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to follow.");
  5936. client->GetPlayer()->GetInfoStruct()->pet_movement = 2;
  5937. client->GetPlayer()->SetCharSheetChanged(true);
  5938. }
  5939. else if (strcmp(sep->arg[0], "preserve_master") == 0) {
  5940. if (client->GetPlayer()->GetInfoStruct()->pet_behavior & 1) {
  5941. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect you.");
  5942. client->GetPlayer()->GetInfoStruct()->pet_behavior -= 1;
  5943. }
  5944. else {
  5945. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect you.");
  5946. client->GetPlayer()->GetInfoStruct()->pet_behavior += 1;
  5947. }
  5948. client->GetPlayer()->SetCharSheetChanged(true);
  5949. }
  5950. else if (strcmp(sep->arg[0], "preserve_self") == 0) {
  5951. if (client->GetPlayer()->GetInfoStruct()->pet_behavior & 2) {
  5952. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect itself.");
  5953. client->GetPlayer()->GetInfoStruct()->pet_behavior -= 2;
  5954. }
  5955. else {
  5956. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect itself.");
  5957. client->GetPlayer()->GetInfoStruct()->pet_behavior += 2;
  5958. }
  5959. client->GetPlayer()->SetCharSheetChanged(true);
  5960. }
  5961. else if (strcmp(sep->arg[0], "backoff") == 0) {
  5962. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to back down.");
  5963. if (client->GetPlayer()->GetPet())
  5964. ((NPC*)client->GetPlayer()->GetPet())->Brain()->ClearHate();
  5965. if (client->GetPlayer()->GetCharmedPet())
  5966. ((NPC*)client->GetPlayer()->GetCharmedPet())->Brain()->ClearHate();
  5967. client->GetPlayer()->GetInfoStruct()->pet_behavior = 0;
  5968. client->GetPlayer()->SetCharSheetChanged(true);
  5969. }
  5970. else if (strcmp(sep->arg[0], "attack") == 0) {
  5971. if (client->GetPlayer()->HasTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  5972. if (client->GetPlayer()->AttackAllowed((Entity*)client->GetPlayer()->GetTarget())){
  5973. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to attack your target.");
  5974. if (client->GetPlayer()->GetPet())
  5975. client->GetPlayer()->GetPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  5976. if (client->GetPlayer()->GetCharmedPet())
  5977. client->GetPlayer()->GetCharmedPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  5978. }
  5979. else
  5980. client->Message(CHANNEL_COLOR_YELLOW, "You can not attack that.");
  5981. }
  5982. else
  5983. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a target.");
  5984. }
  5985. else if (strcmp(sep->arg[0], "getlost") == 0) {
  5986. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetPet());
  5987. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetCharmedPet());
  5988. client->Message(CHANNEL_COLOR_YELLOW, "You tell your pet to get lost.");
  5989. }
  5990. else
  5991. client->Message(CHANNEL_COLOR_YELLOW, "Unknown pet command.");
  5992. }
  5993. /*
  5994. Function: Command_PetName()
  5995. Purpose : Pet your name (???)
  5996. Params :
  5997. Dev :
  5998. Example :
  5999. */
  6000. void Commands::Command_PetName(Client* client, Seperator* sep)
  6001. {
  6002. PrintSep(sep, "COMMAND_PETNAME");
  6003. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Pet Name Command");
  6004. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6005. }
  6006. /*
  6007. Function: Command_NamePet()
  6008. Purpose : Name your pet
  6009. Params :
  6010. Dev :
  6011. Example :
  6012. */
  6013. void Commands::Command_NamePet(Client* client, Seperator* sep)
  6014. {
  6015. PrintSep(sep, "COMMAND_NAME_PET");
  6016. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Name Pet Command");
  6017. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6018. }
  6019. /*
  6020. Function: Command_Rename()
  6021. Purpose : Renames existing pet
  6022. Params :
  6023. Dev :
  6024. Example :
  6025. */
  6026. void Commands::Command_Rename(Client* client, Seperator* sep)
  6027. {
  6028. PrintSep(sep, "COMMAND_RENAME");
  6029. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Rename Pet Command");
  6030. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6031. }
  6032. /*
  6033. Function: Command_ConfirmRename()
  6034. Purpose : Confirms renaming your pet
  6035. Params :
  6036. Dev :
  6037. Example :
  6038. */
  6039. void Commands::Command_ConfirmRename(Client* client, Seperator* sep)
  6040. {
  6041. PrintSep(sep, "COMMAND_CONFIRMRENAME");
  6042. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Confirm Rename Pet Command");
  6043. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6044. }
  6045. /*
  6046. Function: Command_PetOptions()
  6047. Purpose : Sets various pet options
  6048. Params :
  6049. Dev :
  6050. Example :
  6051. */
  6052. void Commands::Command_PetOptions(Client* client, Seperator* sep)
  6053. {
  6054. PrintSep(sep, "COMMAND_PETOPTIONS");
  6055. Player* player = client->GetPlayer();
  6056. Spawn* target = player->GetTarget();
  6057. if (!target)
  6058. return;
  6059. if (target == player->GetPet())
  6060. client->SendPetOptionsWindow(player->GetPet()->GetName());
  6061. else if (target == player->GetCharmedPet())
  6062. client->SendPetOptionsWindow(player->GetCharmedPet()->GetName());
  6063. else if (target == player->GetCosmeticPet())
  6064. client->SendPetOptionsWindow(player->GetCosmeticPet()->GetName(), 0);
  6065. else if (target == player->GetDeityPet())
  6066. client->SendPetOptionsWindow(player->GetDeityPet()->GetName(), 0);
  6067. }
  6068. /*
  6069. Function: Command_Random()
  6070. Purpose : Handles /random dice roll in-game
  6071. Params : 1-100
  6072. Dev : Scatman
  6073. Example : /randon 1 100
  6074. */
  6075. void Commands::Command_Random(Client* client, Seperator* sep)
  6076. {
  6077. char message[256] = {0};
  6078. if (sep)
  6079. {
  6080. if (sep->GetArgNumber() == 0 && sep->IsNumber(0))
  6081. sprintf(message, "Random: %s rolls 1 to %i on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), atoi(sep->arg[0]), MakeRandomInt(1, atoi(sep->arg[0])));
  6082. else if (sep->GetArgNumber() > 0 && sep->IsNumber(0) && sep->IsNumber(1))
  6083. sprintf(message, "Random: %s rolls from %i to %i on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), atoi(sep->arg[0]), atoi(sep->arg[1]), MakeRandomInt(atoi(sep->arg[0]), atoi(sep->arg[1])));
  6084. else
  6085. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  6086. }
  6087. else
  6088. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  6089. client->GetPlayer()->GetZone()->HandleChatMessage(0, 0, CHANNEL_EMOTE, message);
  6090. }
  6091. /*
  6092. Function: Command_Randomize()
  6093. Purpose : Sets randomize (appearance) values for NPCs
  6094. Params : Attrib Name
  6095. Dev : Scatman
  6096. Example : /randomize gender 1 -- will randomize the NPCs gender (male/female)
  6097. */
  6098. void Commands::Command_Randomize(Client* client, Seperator* sep)
  6099. {
  6100. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  6101. if (target)
  6102. {
  6103. if (target->IsNPC())
  6104. {
  6105. if (sep && sep->arg[0] && !sep->IsNumber(0))
  6106. {
  6107. const char* value = sep->arg[0];
  6108. if (strncasecmp(value, "show", strlen(value)) == 0)
  6109. {
  6110. client->DisplayRandomizeFeatures(target->GetRandomize());
  6111. }
  6112. else
  6113. {
  6114. if (sep->arg[1] && sep->IsNumber(1))
  6115. {
  6116. int8 option = atoi(sep->arg[1]);
  6117. if (option == 0 || option == 1)
  6118. {
  6119. int32 feature = 0;
  6120. char feature_text[32] = {0};
  6121. if (strncasecmp(value, "gender", strlen(value)) == 0) {
  6122. feature = RANDOMIZE_GENDER;
  6123. strncpy(feature_text, "gender", sizeof(feature_text) - 1);
  6124. }
  6125. else if (strncasecmp(value, "race", strlen(value)) == 0) {
  6126. feature = RANDOMIZE_RACE;
  6127. strncpy(feature_text, "race", sizeof(feature_text) - 1);
  6128. }
  6129. else if (strncasecmp(value, "model", strlen(value)) == 0) {
  6130. feature = RANDOMIZE_MODEL_TYPE;
  6131. strncpy(feature_text, "model", sizeof(feature_text) - 1);
  6132. }
  6133. else if (strncasecmp(value, "facial_hair", strlen(value)) == 0) {
  6134. feature = RANDOMIZE_FACIAL_HAIR_TYPE;
  6135. strncpy(feature_text, "facial hair", sizeof(feature_text) - 1);
  6136. }
  6137. else if (strncasecmp(value, "hair", strlen(value)) == 0) {
  6138. feature = RANDOMIZE_HAIR_TYPE;
  6139. strncpy(feature_text, "hair", sizeof(feature_text) - 1);
  6140. }
  6141. else if (strncasecmp(value, "wing", strlen(value)) == 0) {
  6142. feature = RANDOMIZE_WING_TYPE;
  6143. strncpy(feature_text, "wings", sizeof(feature_text) - 1);
  6144. }
  6145. else if (strncasecmp(value, "cheek", strlen(value)) == 0) {
  6146. feature = RANDOMIZE_CHEEK_TYPE;
  6147. strncpy(feature_text, "cheeks", sizeof(feature_text) - 1);
  6148. }
  6149. else if (strncasecmp(value, "chin", strlen(value)) == 0) {
  6150. feature = RANDOMIZE_CHIN_TYPE;
  6151. strncpy(feature_text, "chin", sizeof(feature_text) - 1);
  6152. }
  6153. else if (strncasecmp(value, "ear", strlen(value)) == 0) {
  6154. feature = RANDOMIZE_EAR_TYPE;
  6155. strncpy(feature_text, "ears", sizeof(feature_text) - 1);
  6156. }
  6157. else if (strncasecmp(value, "eye_brow", strlen(value)) == 0) {
  6158. feature = RANDOMIZE_EYE_BROW_TYPE;
  6159. strncpy(feature_text, "eye brows", sizeof(feature_text) - 1);
  6160. }
  6161. else if (strncasecmp(value, "eye", strlen(value)) == 0) {
  6162. feature = RANDOMIZE_EYE_TYPE;
  6163. strncpy(feature_text, "eyes", sizeof(feature_text) - 1);
  6164. }
  6165. else if (strncasecmp(value, "lip", strlen(value)) == 0) {
  6166. feature = RANDOMIZE_LIP_TYPE;
  6167. strncpy(feature_text, "lips", sizeof(feature_text) - 1);
  6168. }
  6169. else if (strncasecmp(value, "nose", strlen(value)) == 0) {
  6170. feature = RANDOMIZE_NOSE_TYPE;
  6171. strncpy(feature_text, "nose", sizeof(feature_text) - 1);
  6172. }
  6173. else if (strncasecmp(value, "eye_color", strlen(value)) == 0) {
  6174. feature = RANDOMIZE_EYE_COLOR;
  6175. strncpy(feature_text, "eye color", sizeof(feature_text) - 1);
  6176. }
  6177. else if (strncasecmp(value, "hair_color", strlen(value)) == 0) {
  6178. feature = RANDOMIZE_HAIR_TYPE_COLOR;
  6179. strncpy(feature_text, "hair color", sizeof(feature_text) - 1);
  6180. }
  6181. else if (strncasecmp(value, "hair_color1", strlen(value)) == 0) {
  6182. feature = RANDOMIZE_HAIR_COLOR1;
  6183. strncpy(feature_text, "hair color1", sizeof(feature_text) - 1);
  6184. }
  6185. else if (strncasecmp(value, "hair_color2", strlen(value)) == 0) {
  6186. feature = RANDOMIZE_HAIR_COLOR2;
  6187. strncpy(feature_text, "hair color2", sizeof(feature_text) - 1);
  6188. }
  6189. else if (strncasecmp(value, "hair_highlight", strlen(value)) == 0) {
  6190. feature = RANDOMIZE_HAIR_HIGHLIGHT;
  6191. strncpy(feature_text, "hair highlights", sizeof(feature_text) - 1);
  6192. }
  6193. else if (strncasecmp(value, "facial_hair_color", strlen(value)) == 0) {
  6194. feature = RANDOMIZE_HAIR_FACE_COLOR;
  6195. strncpy(feature_text, "facial hair color", sizeof(feature_text) - 1);
  6196. }
  6197. else if (strncasecmp(value, "facial_hair_color_highlight", strlen(value)) == 0) {
  6198. feature = RANDOMIZE_HAIR_FACE_HIGHLIGHT_COLOR;
  6199. strncpy(feature_text, "facial hair color highlights", sizeof(feature_text) - 1);
  6200. }
  6201. else if (strncasecmp(value, "hair_color_highlight", strlen(value)) == 0) {
  6202. feature = RANDOMIZE_HAIR_TYPE_HIGHLIGHT_COLOR;
  6203. strncpy(feature_text, "hair color highlights", sizeof(feature_text) - 1);
  6204. }
  6205. else if (strncasecmp(value, "skin_color", strlen(value)) == 0) {
  6206. feature = RANDOMIZE_SKIN_COLOR;
  6207. strncpy(feature_text, "skin color", sizeof(feature_text) - 1);
  6208. }
  6209. else if (strncasecmp(value, "wing_color1", strlen(value)) == 0) {
  6210. feature = RANDOMIZE_WING_COLOR1;
  6211. strncpy(feature_text, "wing color1", sizeof(feature_text) - 1);
  6212. }
  6213. else if (strncasecmp(value, "wing_color2", strlen(value)) == 0) {
  6214. feature = RANDOMIZE_WING_COLOR2;
  6215. strncpy(feature_text, "wing color2", sizeof(feature_text) - 1);
  6216. }
  6217. else {
  6218. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is not a valid feature to randomize.", value);
  6219. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Valid features are: 'gender', 'race', 'model', 'hair', 'facial_hair', 'legs', 'wings', 'cheek', 'chin', 'ear', 'eye', 'eye_brow', 'lip', 'nose', 'eye_color', 'hair_color1', 'hair_color2', 'hair_highlight', 'facial_hair_color', 'facial_hair_color_highlight', 'hair_color', 'hair_color_highlight', 'skin_color', 'wing_color1', 'wing_color2'.");
  6220. }
  6221. if (feature > 0) {
  6222. if (option == 1) {
  6223. if (target->GetRandomize() & feature)
  6224. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is already set to randomly generate their %s.", target->GetName(), feature_text);
  6225. else {
  6226. target->AddRandomize(feature);
  6227. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(feature);
  6228. database.UpdateRandomize(target->GetDatabaseID(), feature);
  6229. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will now generate their %s randomly.", target->GetName(), feature_text);
  6230. }
  6231. }
  6232. else {
  6233. if (target->GetRandomize() & feature) {
  6234. target->AddRandomize(-feature);
  6235. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(-feature);
  6236. database.UpdateRandomize(target->GetDatabaseID(), -feature);
  6237. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will no longer generate their %s randomly.", target->GetName(), feature_text);
  6238. }
  6239. else
  6240. client->Message(CHANNEL_COLOR_YELLOW, "'%s' already does not randomly generate their %s.", target->GetName(), feature_text);
  6241. }
  6242. }
  6243. }
  6244. else
  6245. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  6246. }
  6247. else
  6248. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  6249. }
  6250. }
  6251. else {
  6252. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /randomize [show | [feature [1|0]]");
  6253. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "'show' will display current configured features");
  6254. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Valid features are: 'gender', 'race', 'model', 'hair', 'facial_hair', 'legs', 'wings', 'cheek', 'chin', 'ear', 'eye', 'eye_brow', 'lip', 'nose', 'eye_color', 'hair_color1', 'hair_color2', 'hair_highlight', 'facial_hair_color', 'facial_hair_color_highlight', 'hair_color', 'hair_color_highlight', 'skin_color', 'wing_color1', 'wing_color2'.");
  6255. }
  6256. }
  6257. else
  6258. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "The target you wish to randomize must be an NPC.");
  6259. }
  6260. else
  6261. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select the target you wish to randomize.");
  6262. }
  6263. /*
  6264. Function: Command_ShowCloak()
  6265. Purpose : Character Settings combo box for Show Cloak
  6266. Params : true/false
  6267. Dev : John Adams
  6268. Example :
  6269. */
  6270. void Commands::Command_ShowCloak(Client* client, Seperator* sep)
  6271. {
  6272. Player* player = client->GetPlayer();
  6273. if (sep && sep->arg[0])
  6274. {
  6275. const char* value = sep->arg[0];
  6276. if (strncasecmp(value, "true", strlen(value)) == 0)
  6277. {
  6278. player->set_character_flag(CF_SHOW_CLOAK);
  6279. player->reset_character_flag(CF2_SHOW_RANGED);
  6280. }
  6281. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6282. player->reset_character_flag(CF_SHOW_CLOAK);
  6283. else
  6284. {
  6285. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6286. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6287. }
  6288. }
  6289. }
  6290. /*
  6291. Function: Command_ShowHelm()
  6292. Purpose : Character Settings combo box for Show Helm
  6293. Params : true/false
  6294. Dev : John Adams
  6295. Example :
  6296. */
  6297. void Commands::Command_ShowHelm(Client* client, Seperator* sep)
  6298. {
  6299. Player* player = client->GetPlayer();
  6300. if (sep && sep->arg[0])
  6301. {
  6302. const char* value = sep->arg[0];
  6303. if (strncasecmp(value, "true", strlen(value)) == 0)
  6304. {
  6305. player->reset_character_flag(CF_HIDE_HELM);
  6306. player->set_character_flag(CF_HIDE_HOOD);
  6307. }
  6308. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6309. player->set_character_flag(CF_HIDE_HELM);
  6310. else
  6311. {
  6312. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6313. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6314. }
  6315. }
  6316. }
  6317. /*
  6318. Function: Command_ShowHood()
  6319. Purpose : Character Settings combo box for Show Hood
  6320. Params : true/false
  6321. Dev : John Adams
  6322. Example :
  6323. */
  6324. void Commands::Command_ShowHood(Client* client, Seperator* sep)
  6325. {
  6326. Player* player = client->GetPlayer();
  6327. if (sep && sep->arg[0])
  6328. {
  6329. const char* value = sep->arg[0];
  6330. if (strncasecmp(value, "true", strlen(value)) == 0)
  6331. {
  6332. player->reset_character_flag(CF_HIDE_HOOD);
  6333. player->set_character_flag(CF_HIDE_HELM);
  6334. }
  6335. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6336. player->set_character_flag(CF_HIDE_HOOD);
  6337. else
  6338. {
  6339. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6340. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6341. }
  6342. }
  6343. }
  6344. /*
  6345. Function: Command_ShowHoodHelm()
  6346. Purpose : Character Settings combo box for Show Helm or Hood
  6347. Params : true/false
  6348. Dev : John Adams
  6349. Example :
  6350. */
  6351. void Commands::Command_ShowHoodHelm(Client* client, Seperator* sep)
  6352. {
  6353. Player* player = client->GetPlayer();
  6354. if (sep && sep->arg[0])
  6355. {
  6356. const char* value = sep->arg[0];
  6357. if (strncasecmp(value, "true", strlen(value)) == 0)
  6358. {
  6359. player->reset_character_flag(CF_HIDE_HOOD);
  6360. player->reset_character_flag(CF_HIDE_HELM);
  6361. }
  6362. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6363. {
  6364. // don't think we ever wind up in here...
  6365. player->set_character_flag(CF_HIDE_HOOD);
  6366. player->set_character_flag(CF_HIDE_HELM);
  6367. }
  6368. else
  6369. {
  6370. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6371. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6372. }
  6373. }
  6374. }
  6375. /*
  6376. Function: Command_ShowRanged()
  6377. Purpose : Character Settings combo box for Show Ranged weapon
  6378. Params : true/false
  6379. Dev : John Adams
  6380. Example :
  6381. */
  6382. void Commands::Command_ShowRanged(Client* client, Seperator* sep)
  6383. {
  6384. Player* player = client->GetPlayer();
  6385. if (sep && sep->arg[0])
  6386. {
  6387. const char* value = sep->arg[0];
  6388. if (strncasecmp(value, "true", strlen(value)) == 0)
  6389. {
  6390. player->set_character_flag(CF2_SHOW_RANGED);
  6391. player->reset_character_flag(CF_SHOW_CLOAK);
  6392. }
  6393. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6394. player->reset_character_flag(CF2_SHOW_RANGED);
  6395. else
  6396. {
  6397. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6398. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6399. }
  6400. }
  6401. }
  6402. /*
  6403. Function:
  6404. Purpose :
  6405. Params :
  6406. Dev :
  6407. Example :
  6408. */
  6409. void Commands::Command_Skills(Client* client, Seperator* sep, int handler)
  6410. {
  6411. Player* player = 0;
  6412. Client* to_client = 0;
  6413. if(client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  6414. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  6415. switch(handler)
  6416. {
  6417. case COMMAND_SKILL:
  6418. {
  6419. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill [add|remove|list] [skill name]");
  6420. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to add/remove skills for that player.");
  6421. break;
  6422. }
  6423. case COMMAND_SKILL_ADD:
  6424. {
  6425. if (sep && sep->arg[0])
  6426. {
  6427. const char* skill_name = sep->argplus[0];
  6428. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6429. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // add skill to your target, if target is not you
  6430. {
  6431. player = to_client->GetPlayer();
  6432. if (player)
  6433. {
  6434. if (!player->GetSkills()->HasSkill(skill->skill_id))
  6435. {
  6436. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  6437. client->Message(CHANNEL_COLOR_YELLOW, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  6438. to_client->Message(CHANNEL_COLOR_YELLOW, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  6439. }
  6440. else
  6441. client->Message(CHANNEL_COLOR_YELLOW, "%s already has the skill '%s'.", player->GetName(), skill_name);
  6442. }
  6443. }
  6444. else if (skill) // add skill to yourself
  6445. {
  6446. player = client->GetPlayer();
  6447. if (player)
  6448. {
  6449. if (!player->GetSkills()->HasSkill(skill->skill_id))
  6450. {
  6451. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  6452. client->Message(CHANNEL_COLOR_YELLOW, "Added skill '%s'.", skill_name);
  6453. }
  6454. else
  6455. client->Message(CHANNEL_COLOR_YELLOW, "You already have the skill '%s'.", skill_name);
  6456. }
  6457. }
  6458. else
  6459. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  6460. }
  6461. else
  6462. {
  6463. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill add [skill name]");
  6464. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  6465. }
  6466. break;
  6467. }
  6468. case COMMAND_SKILL_REMOVE:
  6469. {
  6470. if (sep && sep->arg[0])
  6471. {
  6472. const char* skill_name = sep->argplus[0];
  6473. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6474. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // remove skill from your target, if target is not you
  6475. {
  6476. player = to_client->GetPlayer();
  6477. if (player)
  6478. {
  6479. if (player->GetSkills()->HasSkill(skill->skill_id))
  6480. {
  6481. player->RemoveSkillFromDB(skill, true);
  6482. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  6483. to_client->Message(CHANNEL_COLOR_YELLOW, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  6484. }
  6485. else
  6486. client->Message(CHANNEL_COLOR_YELLOW, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  6487. }
  6488. }
  6489. else if(skill) // remove skill from yourself
  6490. {
  6491. Player* player = client->GetPlayer();
  6492. if (player)
  6493. {
  6494. if (player->GetSkills()->HasSkill(skill->skill_id))
  6495. {
  6496. player->RemoveSkillFromDB(skill, true);
  6497. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s'.", skill_name);
  6498. }
  6499. else
  6500. client->Message(CHANNEL_COLOR_YELLOW, "You do not have the skill '%s'.", skill_name);
  6501. }
  6502. }
  6503. else
  6504. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  6505. }
  6506. else
  6507. {
  6508. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill remove [skill name]");
  6509. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  6510. }
  6511. break;
  6512. }
  6513. case COMMAND_SKILL_LIST:
  6514. {
  6515. if (sep && sep->arg[0])
  6516. {
  6517. const char* skill_name = sep->argplus[0];
  6518. client->Message(CHANNEL_COLOR_YELLOW, "Listing skills like '%s':", skill_name);
  6519. map<int32, Skill*>* skills = master_skill_list.GetAllSkills();
  6520. map<int32, Skill*>::iterator itr;
  6521. if (skills && skills->size() > 0)
  6522. {
  6523. for (itr = skills->begin(); itr != skills->end(); itr++)
  6524. {
  6525. Skill* skill = itr->second;
  6526. string current_skill_name = ::ToLower(string(skill->name.data.c_str()));
  6527. if (current_skill_name.find(::ToLower(string(skill_name))) < 0xFFFFFFFF)
  6528. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", skill->name.data.c_str(), skill->skill_id);
  6529. }
  6530. }
  6531. }
  6532. else
  6533. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill list [skill name]");
  6534. break;
  6535. }
  6536. }
  6537. }
  6538. /*
  6539. Function: Command_SpawnTemplate()
  6540. Purpose : Create or Use defined Spawn Templates
  6541. Params : create, save, rempve, list
  6542. Dev : John Adams
  6543. Example : /spawn template create "Test"
  6544. */
  6545. void Commands::Command_SpawnTemplate(Client* client, Seperator* sep)
  6546. {
  6547. if (sep == NULL || sep->arg[0] == NULL)
  6548. {
  6549. client->Message(CHANNEL_COLOR_YELLOW, "Examples:\n/spawn template save Test - saves a template of the targetted spawn as the name Test\n/spawn template list - shows a list of current templates\n/spawn template spawn [id|name] creates a new spawn based on template [id|name] at your current location.");
  6550. return;
  6551. }
  6552. // got params, continue
  6553. const char * template_cmd = sep->arg[0];
  6554. if (strncasecmp(template_cmd, "list", strlen(template_cmd)) == 0)
  6555. {
  6556. if (!sep->IsSet(1))
  6557. {
  6558. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /spawn template list [name|location_id]");
  6559. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Examples:\n/spawn template list [name] - will show all templates containing [name].\n/spawn template list [location_id] - will show all templates that [location_id] is assigned to.");
  6560. return;
  6561. }
  6562. map<int32, string>* template_names = 0;
  6563. if (sep->IsNumber(1))
  6564. {
  6565. int32 location_id = 0;
  6566. location_id = atoi(sep->arg[1]);
  6567. template_names = database.GetSpawnTemplateListByID(location_id);
  6568. }
  6569. else
  6570. {
  6571. const char* name = 0;
  6572. name = sep->argplus[1];
  6573. template_names = database.GetSpawnTemplateListByName(name);
  6574. }
  6575. if(!template_names)
  6576. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No templates found.");
  6577. else
  6578. {
  6579. map<int32, string>::iterator itr;
  6580. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  6581. for(itr = template_names->begin(); itr != template_names->end(); itr++)
  6582. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  6583. safe_delete(template_names);
  6584. }
  6585. }
  6586. else if (strncasecmp(template_cmd, "save", strlen(template_cmd)) == 0)
  6587. {
  6588. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  6589. if ( target && (target->IsNPC() || target->IsObject() || target->IsSign() || target->IsWidget() || target->IsGroundSpawn()) )
  6590. {
  6591. if (sep && sep->arg[1][0] && !sep->IsNumber(1))
  6592. {
  6593. // first, lookup to see if template name already exists
  6594. const char* name = 0;
  6595. name = sep->argplus[1];
  6596. map<int32, string>* template_names = database.GetSpawnTemplateListByName(name);
  6597. if(!template_names)
  6598. {
  6599. int32 new_template_id = database.SaveSpawnTemplate(target->GetSpawnLocationID(), name);
  6600. if( new_template_id > 0 )
  6601. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template '%s' added for spawn '%s' (%u) as TemplateID: %u", name, target->GetName(), target->GetSpawnLocationID(), new_template_id);
  6602. else
  6603. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' for spawn '%s' (%u).", name, target->GetName(), target->GetSpawnLocationID());
  6604. }
  6605. else
  6606. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' - Already exists!", name);
  6607. }
  6608. else
  6609. client->Message(CHANNEL_COLOR_RED, "ERROR: Saving a new spawn template requires a valid template name!");
  6610. }
  6611. else
  6612. client->Message(CHANNEL_COLOR_RED, "ERROR: You must target the spawn you wish to save as a template!");
  6613. }
  6614. else if (strncasecmp(template_cmd, "remove", strlen(template_cmd)) == 0)
  6615. {
  6616. if (sep && sep->arg[1][0] && sep->IsNumber(1))
  6617. {
  6618. int32 template_id = 0;
  6619. template_id = atoi(sep->arg[1]);
  6620. if (database.RemoveSpawnTemplate(template_id))
  6621. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template ID: %u successfully removed.", template_id);
  6622. else
  6623. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to remove spawn template ID: %u", template_id);
  6624. }
  6625. else
  6626. client->Message(CHANNEL_COLOR_RED, "ERROR: Removing a spawn template requires a valid template ID!");
  6627. }
  6628. // Renamed create to spawn
  6629. else if (strncasecmp(template_cmd, "spawn", strlen(template_cmd)) == 0)
  6630. {
  6631. if (sep && sep->arg[1][0])
  6632. {
  6633. int32 new_location = 0;
  6634. if (sep->IsNumber(1))
  6635. {
  6636. int32 template_id = 0;
  6637. template_id = atoi(sep->arg[1]);
  6638. new_location = database.CreateSpawnFromTemplateByID(client, template_id);
  6639. if( new_location > 0 )
  6640. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template ID: %u", new_location, template_id);
  6641. else
  6642. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template ID: %u", template_id);
  6643. }
  6644. else
  6645. {
  6646. const char* name = 0;
  6647. name = sep->argplus[1];
  6648. new_location = database.CreateSpawnFromTemplateByName(client, name);
  6649. if( new_location > 0 )
  6650. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template: '%s'", new_location, name);
  6651. else
  6652. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template: '%s'", name);
  6653. }
  6654. }
  6655. else
  6656. client->Message(CHANNEL_COLOR_RED, "ERROR: Spawning a new spawn location requires a valid template name or ID!");
  6657. }
  6658. else
  6659. client->Message(CHANNEL_COLOR_RED, "ERROR: Unknown /spawn template command.");
  6660. }
  6661. void Commands::Command_Speed(Client* client, Seperator* sep) {
  6662. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  6663. float new_speed = atof(sep->arg[0]);
  6664. if (new_speed > 0.0f)
  6665. {
  6666. client->GetPlayer()->SetSpeed(new_speed);
  6667. client->GetPlayer()->SetCharSheetChanged(true);
  6668. database.insertCharacterProperty(client, CHAR_PROPERTY_SPEED, sep->arg[0]);
  6669. client->Message(CHANNEL_STATUS, "Setting speed to %.2f.", new_speed);
  6670. }
  6671. else
  6672. client->Message(CHANNEL_STATUS, "Invalid speed provided %s.", sep->arg[0]);
  6673. }
  6674. else{
  6675. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /speed {new speed value}");
  6676. }
  6677. }
  6678. /*
  6679. Function: Command_StationMarketPlace()
  6680. Purpose : just trying to eat the console spam for now
  6681. Params :
  6682. Dev : John
  6683. */
  6684. void Commands::Command_StationMarketPlace(Client* client, Seperator* sep)
  6685. {
  6686. PrintSep(sep, "COMMAND_SMP");
  6687. // This will reduce the spam from once every 10 sec to once every 30 sec,
  6688. // can't seem to reduce it any more get rid of it completely...
  6689. if (sep && strcmp(sep->arg[0], "gkw") == 0) {
  6690. PacketStruct* packet = configReader.getStruct("WS_MarketFundsUpdate", client->GetVersion());
  6691. if (packet) {
  6692. packet->setDataByName("account_id", client->GetAccountID());
  6693. packet->setDataByName("character_id", client->GetCharacterID());
  6694. packet->setDataByName("unknown1", 1, 5);
  6695. packet->setDataByName("unknown1", 26, 6);
  6696. packet->setDataByName("unknown2", 0xFFFFFFFF);
  6697. packet->setDataByName("unknown3", 248, 1);
  6698. client->QueuePacket(packet->serialize());
  6699. }
  6700. safe_delete(packet);
  6701. }
  6702. }
  6703. /*
  6704. Function: Command_StopDrinking()
  6705. Purpose : Stops player from auto-consuming drink
  6706. Params :
  6707. Dev : Zcoretri
  6708. Example : /stopdrinking
  6709. */
  6710. void Commands::Command_StopDrinking(Client* client)
  6711. {
  6712. client->GetPlayer()->reset_character_flag(CF_DRINK_AUTO_CONSUME);
  6713. client->Message(CHANNEL_COLOR_YELLOW,"You stop drinking your current drink.");
  6714. }
  6715. /*
  6716. Function: Command_StopEating()
  6717. Purpose : Stops player from auto-consuming food
  6718. Params :
  6719. Dev : Zcoretri
  6720. Example : /stopeating
  6721. */
  6722. void Commands::Command_StopEating(Client* client)
  6723. {
  6724. client->GetPlayer()->reset_character_flag(CF_FOOD_AUTO_CONSUME);
  6725. client->Message(CHANNEL_COLOR_YELLOW,"You stop eating your current food.");
  6726. }
  6727. /*
  6728. Function: Command_Title()
  6729. Purpose : Help for /title command
  6730. Params : n/a
  6731. Dev : Zcoretri
  6732. Example : /title
  6733. */
  6734. void Commands::Command_Title(Client* client)
  6735. {
  6736. client->Message(CHANNEL_COLOR_YELLOW, "Available subcommands: list, setprefix <index>, setsuffix <index>, fix");
  6737. }
  6738. /*
  6739. Function: Command_TitleList()
  6740. Purpose : List available titles for player
  6741. Params : n/a
  6742. Dev : Zcoretri
  6743. Example : /title list
  6744. */
  6745. void Commands::Command_TitleList(Client* client)
  6746. {
  6747. list<Title*>* titles = client->GetPlayer()->GetPlayerTitles()->GetAllTitles();
  6748. list<Title*>::iterator itr;
  6749. Title* title;
  6750. int16 i = 0;
  6751. client->Message(CHANNEL_COLOR_WHITE, "Listing available titles:");
  6752. for(itr = titles->begin(); itr != titles->end(); itr++)
  6753. {
  6754. title = *itr;
  6755. client->Message(CHANNEL_COLOR_WHITE, "%i: type=[%s] title=[%s]", i, title->GetPrefix() ? "Prefix":"Suffix", title->GetName());
  6756. i++;
  6757. }
  6758. }
  6759. /*
  6760. Function: Command_TitleSetPrefix()
  6761. Purpose : Set Prefix title for player
  6762. Params : Title ID
  6763. Dev : Zcoretri
  6764. Example : /title setprefix 1
  6765. */
  6766. void Commands::Command_TitleSetPrefix(Client* client, Seperator* sep)
  6767. {
  6768. if (sep && sep->arg[0] && sep->IsNumber(0))
  6769. {
  6770. int32 index = atoul(sep->arg[0]);
  6771. database.SaveCharPrefixIndex(index, client->GetCharacterID(), client);
  6772. client->SendTitleUpdate();
  6773. }
  6774. }
  6775. /*
  6776. Function: Command_TitleSetSuffix()
  6777. Purpose : Set Suffix title for player
  6778. Params : Title ID
  6779. Dev : Zcoretri
  6780. Example : /title setsuffix 1
  6781. */
  6782. void Commands::Command_TitleSetSuffix(Client* client, Seperator* sep)
  6783. {
  6784. if (sep && sep->arg[0] && sep->IsNumber(0))
  6785. {
  6786. int32 index = atoul(sep->arg[0]);
  6787. database.SaveCharSuffixIndex(index, client->GetCharacterID(), client);
  6788. client->SendTitleUpdate();
  6789. }
  6790. }
  6791. /*
  6792. Function: Command_TitleFix()
  6793. Purpose : Fix title for player (???)
  6794. Params :
  6795. Dev : Zcoretri
  6796. Example :
  6797. */
  6798. void Commands::Command_TitleFix(Client* client, Seperator* sep)
  6799. {
  6800. PrintSep(sep, "COMMAND_TITLE_FIX");
  6801. LogWrite(MISC__TODO, 1, "Titles", "TODO-Command: TITLE_FIX");
  6802. }
  6803. /*
  6804. Function: Command_Toggle_Anonymous()
  6805. Purpose : Toggles player Anonymous
  6806. Params :
  6807. Dev : paulgh
  6808. Example : /anon
  6809. */
  6810. void Commands::Command_Toggle_Anonymous(Client* client)
  6811. {
  6812. Player* player = client->GetPlayer();
  6813. player->toggle_character_flag(CF_ANONYMOUS);
  6814. client->Message(CHANNEL_COLOR_YELLOW,"You are %s anonymous.", player->get_character_flag(CF_ANONYMOUS)?"now":"no longer");
  6815. if (player->get_character_flag(CF_ANONYMOUS))
  6816. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ANONYMOUS);
  6817. else
  6818. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ANONYMOUS);
  6819. }
  6820. /*
  6821. Function: Command_Toggle_AutoConsume()
  6822. Purpose : Toggles player food/drink auto consume
  6823. Params : unknown
  6824. Dev : paulgh
  6825. Example : /set_auto_consume
  6826. */
  6827. void Commands::Command_Toggle_AutoConsume(Client* client, Seperator* sep)
  6828. {
  6829. Player* player = client->GetPlayer();
  6830. if (sep && sep->arg[0])
  6831. PrintSep(sep, "COMMAND_SET_AUTO_CONSUME");
  6832. if (sep && sep->arg[0] && sep->IsNumber(0))
  6833. {
  6834. int8 slot = atoi(sep->arg[0]);
  6835. int8 flag = atoi(sep->arg[1]);
  6836. if (slot == EQ2_FOOD_SLOT)
  6837. {
  6838. player->toggle_character_flag(CF_FOOD_AUTO_CONSUME);
  6839. player->SetCharSheetChanged(true);
  6840. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  6841. if (flag == 1)
  6842. client->Message(CHANNEL_COLOR_WHITE, "You decide to eat immediately whenever you become hungry.");
  6843. else
  6844. client->Message(CHANNEL_COLOR_WHITE, "You decide to ignore the hunger.");
  6845. }
  6846. else
  6847. {
  6848. player->toggle_character_flag(CF_DRINK_AUTO_CONSUME);
  6849. player->SetCharSheetChanged(true);
  6850. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  6851. if (flag == 1)
  6852. client->Message(CHANNEL_COLOR_WHITE, "You decide to drink immediately whenever you become thirsty.");
  6853. else
  6854. client->Message(CHANNEL_COLOR_WHITE, "You decide to ignore the thirst.");
  6855. }
  6856. }
  6857. }
  6858. /*
  6859. Function: Command_Toggle_BonusXP()
  6860. Purpose : Toggles player Bonus XP
  6861. Params :
  6862. Dev : John Adams
  6863. Example : /disable_char_bonus_exp
  6864. */
  6865. void Commands::Command_Toggle_BonusXP(Client* client)
  6866. {
  6867. Player* player = client->GetPlayer();
  6868. player->toggle_character_flag(CF2_CHARACTER_BONUS_EXPERIENCE_ENABLED);
  6869. player->SetCharSheetChanged(true);
  6870. }
  6871. /*
  6872. Function: Command_Toggle_CombatXP()
  6873. Purpose : Toggles player Adventure XP
  6874. Params :
  6875. Dev : John Adams
  6876. Example : /disable_combat_exp
  6877. */
  6878. void Commands::Command_Toggle_CombatXP(Client* client)
  6879. {
  6880. Player* player = client->GetPlayer();
  6881. player->toggle_character_flag(CF_COMBAT_EXPERIENCE_ENABLED);
  6882. player->SetCharSheetChanged(true);
  6883. }
  6884. /*
  6885. Function: Command_Toggle_GMHide()
  6886. Purpose : Toggles hiding player GM status
  6887. Params :
  6888. Dev : Scatman
  6889. Example : /gm_hide
  6890. */
  6891. void Commands::Command_Toggle_GMHide(Client* client)
  6892. {
  6893. Player* player = client->GetPlayer();
  6894. player->toggle_character_flag(CF_HIDE_STATUS);
  6895. client->Message(CHANNEL_COLOR_YELLOW,"You are %s hiding your GM status.", player->get_character_flag(CF_HIDE_STATUS)?"now":"no longer");
  6896. }
  6897. /*
  6898. Function: Command_Toggle_GMVanish()
  6899. Purpose : Toggles hiding GM players from /who searches
  6900. Params :
  6901. Dev : Scatman
  6902. Example : /gm_vanish
  6903. */
  6904. void Commands::Command_Toggle_GMVanish(Client* client)
  6905. {
  6906. Player* player = client->GetPlayer();
  6907. player->toggle_character_flag(CF_GM_HIDDEN);
  6908. client->Message(CHANNEL_COLOR_YELLOW,"You are %s invisible to who queries.", player->get_character_flag(CF_GM_HIDDEN)?"now":"no longer");
  6909. }
  6910. /*
  6911. Function: Command_Toggle_Illusions()
  6912. Purpose : Toggles player illusion form
  6913. Params : not sure sep is needed, testing
  6914. Dev : paulgh
  6915. Example : /hide_illusions
  6916. */
  6917. void Commands::Command_Toggle_Illusions(Client* client, Seperator* sep)
  6918. {
  6919. if (sep && sep->arg[0])
  6920. PrintSep(sep, "COMMAND_TOGGLE_ILLUSIONS");
  6921. client->GetPlayer()->toggle_character_flag(CF_SHOW_ILLUSION);
  6922. }
  6923. /*
  6924. Function: Command_Toggle_LFG()
  6925. Purpose : Toggles player LFG Flag
  6926. Params :
  6927. Dev : paulgh
  6928. Example : /lfg
  6929. */
  6930. void Commands::Command_Toggle_LFG(Client* client)
  6931. {
  6932. Player* player = client->GetPlayer();
  6933. player->toggle_character_flag(CF_LFG);
  6934. client->Message(CHANNEL_COLOR_YELLOW,"You are %s LFG.", player->get_character_flag(CF_LFG)?"now":"no longer");
  6935. if (player->get_character_flag(CF_LFG))
  6936. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFG);
  6937. else
  6938. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFG);
  6939. }
  6940. /*
  6941. Function: Command_Toggle_LFW()
  6942. Purpose : Toggles player LFW Flag
  6943. Params :
  6944. Dev : paulgh
  6945. Example : /lfw
  6946. */
  6947. void Commands::Command_Toggle_LFW(Client* client)
  6948. {
  6949. Player* player = client->GetPlayer();
  6950. player->toggle_character_flag(CF_LFW);
  6951. client->Message(CHANNEL_COLOR_YELLOW,"You %s looking for work.", player->get_character_flag(CF_LFW)?"let others know you are":"stop");
  6952. if (player->get_character_flag(CF_LFW))
  6953. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFW);
  6954. else
  6955. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFW);
  6956. }
  6957. /*
  6958. Function: Command_Toggle_QuestXP()
  6959. Purpose : Toggles player Quest XP
  6960. Params :
  6961. Dev : John Adams
  6962. Example : /disable_quest_exp
  6963. */
  6964. void Commands::Command_Toggle_QuestXP(Client* client)
  6965. {
  6966. Player* player = client->GetPlayer();
  6967. player->toggle_character_flag(CF_QUEST_EXPERIENCE_ENABLED);
  6968. player->SetCharSheetChanged(true);
  6969. }
  6970. /*
  6971. Function: Command_Toggle_Roleplaying()
  6972. Purpose : Toggles player Roleplaying flag
  6973. Params :
  6974. Dev : paulgh
  6975. Example : /role
  6976. */
  6977. void Commands::Command_Toggle_Roleplaying(Client* client)
  6978. {
  6979. Player* player = client->GetPlayer();
  6980. player->toggle_character_flag(CF_ROLEPLAYING);
  6981. client->Message(CHANNEL_COLOR_YELLOW,"You are %s roleplaying.", player->get_character_flag(CF_ROLEPLAYING)?"now":"no longer");
  6982. if (player->get_character_flag(CF_ROLEPLAYING))
  6983. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ROLEPLAYING);
  6984. else
  6985. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ROLEPLAYING);
  6986. }
  6987. void Commands::Command_Toggle_Duels(Client* client)
  6988. {
  6989. Player* player = client->GetPlayer();
  6990. player->toggle_character_flag(CF_ALLOW_DUEL_INVITES);
  6991. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting duel invites.", player->get_character_flag(CF_ALLOW_DUEL_INVITES)?"now":"no longer");
  6992. }
  6993. void Commands::Command_Toggle_Trades(Client* client)
  6994. {
  6995. Player* player = client->GetPlayer();
  6996. player->toggle_character_flag(CF_ALLOW_TRADE_INVITES);
  6997. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting trade invites.", player->get_character_flag(CF_ALLOW_TRADE_INVITES)?"now":"no longer");
  6998. }
  6999. void Commands::Command_Toggle_Guilds(Client* client)
  7000. {
  7001. Player* player = client->GetPlayer();
  7002. player->toggle_character_flag(CF_ALLOW_GUILD_INVITES);
  7003. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting guild invites.", player->get_character_flag(CF_ALLOW_GUILD_INVITES)?"now":"no longer");
  7004. }
  7005. void Commands::Command_Toggle_Groups(Client* client)
  7006. {
  7007. Player* player = client->GetPlayer();
  7008. player->toggle_character_flag(CF_ALLOW_GROUP_INVITES);
  7009. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting group invites.", player->get_character_flag(CF_ALLOW_GROUP_INVITES)?"now":"no longer");
  7010. }
  7011. void Commands::Command_Toggle_Raids(Client* client)
  7012. {
  7013. Player* player = client->GetPlayer();
  7014. player->toggle_character_flag(CF_ALLOW_RAID_INVITES);
  7015. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting raid invites.", player->get_character_flag(CF_ALLOW_RAID_INVITES)?"now":"no longer");
  7016. }
  7017. void Commands::Command_Toggle_LON(Client* client)
  7018. {
  7019. Player* player = client->GetPlayer();
  7020. player->toggle_character_flag(CF2_ALLOW_LON_INVITES);
  7021. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting LoN invites.", player->get_character_flag(CF2_ALLOW_LON_INVITES)?"now":"no longer");
  7022. }
  7023. void Commands::Command_Toggle_VoiceChat(Client* client)
  7024. {
  7025. Player* player = client->GetPlayer();
  7026. player->toggle_character_flag(CF2_ALLOW_VOICE_INVITES);
  7027. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting voice chat invites.", player->get_character_flag(CF2_ALLOW_VOICE_INVITES)?"now":"no longer");
  7028. }
  7029. /*
  7030. Function: Command_TradeStart()
  7031. Purpose : Starts item/coin trade between players
  7032. Params :
  7033. Dev :
  7034. Example :
  7035. */
  7036. #include "../Trade.h"
  7037. void Commands::Command_TradeStart(Client* client, Seperator* sep)
  7038. {
  7039. PrintSep(sep, "COMMAND_START_TRADE");
  7040. Entity* trader = client->GetPlayer();
  7041. Entity* trader2 = 0;
  7042. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7043. Spawn* spawn = client->GetPlayer()->GetSpawnWithPlayerID(atoi(sep->arg[0]));
  7044. if (spawn) {
  7045. if (spawn->IsEntity())
  7046. trader2 = (Entity*)spawn;
  7047. }
  7048. }
  7049. else if (client->GetPlayer()->GetTarget()) {
  7050. if (client->GetPlayer()->GetTarget()->IsEntity())
  7051. trader2 = (Entity*)client->GetPlayer()->GetTarget();
  7052. }
  7053. // can only trade with player or bots
  7054. if (trader && trader2) {
  7055. if (trader == trader2) {
  7056. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade with yourself.");
  7057. }
  7058. else if (trader2->IsPlayer() || trader2->IsBot()) {
  7059. LogWrite(PLAYER__ERROR, 0, "Trade", "creating trade");
  7060. if (trader->trade)
  7061. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are already trading.");
  7062. else if (trader2->trade)
  7063. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is already trading.");
  7064. else {
  7065. Trade* trade = new Trade(trader, trader2);
  7066. trader->trade = trade;
  7067. trader2->trade = trade;
  7068. }
  7069. }
  7070. else {
  7071. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can only trade with another player or a bot.");
  7072. }
  7073. }
  7074. else
  7075. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to find target");
  7076. }
  7077. /*
  7078. Function: Command_Track()
  7079. Purpose : Starts/Stops Tracking for a player
  7080. Params :
  7081. Dev : Scatman
  7082. Example : /track
  7083. */
  7084. void Commands::Command_Track(Client* client)
  7085. {
  7086. if (!client->GetPlayer()->GetIsTracking())
  7087. client->GetPlayer()->GetZone()->AddPlayerTracking(client->GetPlayer());
  7088. else
  7089. client->GetPlayer()->GetZone()->RemovePlayerTracking(client->GetPlayer(), TRACKING_STOP);
  7090. }
  7091. /*
  7092. Function: Command_TradeAccept()
  7093. Purpose : Accepts item/coin trade between players
  7094. Params :
  7095. Dev :
  7096. Example :
  7097. */
  7098. void Commands::Command_TradeAccept(Client* client, Seperator* sep)
  7099. {
  7100. PrintSep(sep, "COMMAND_ACCEPT_TRADE");
  7101. Trade* trade = client->GetPlayer()->trade;
  7102. if (trade) {
  7103. bool trade_complete = trade->SetTradeAccepted(client->GetPlayer());
  7104. if (trade_complete)
  7105. safe_delete(trade);
  7106. }
  7107. else
  7108. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7109. }
  7110. /*
  7111. Function: Command_TradeReject()
  7112. Purpose : Rejects item/coin trade between players
  7113. Params :
  7114. Dev :
  7115. Example :
  7116. */
  7117. void Commands::Command_TradeReject(Client* client, Seperator* sep)
  7118. {
  7119. PrintSep(sep, "COMMAND_REJECT_TRADE");
  7120. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Reject Player Trading");
  7121. client->Message(CHANNEL_COLOR_YELLOW, "You cannot trade with other players (Not Implemented)");
  7122. }
  7123. /*
  7124. Function: Command_TradeCancel()
  7125. Purpose : Cancels item/coin trade between players
  7126. Params :
  7127. Dev :
  7128. Example :
  7129. */
  7130. void Commands::Command_TradeCancel(Client* client, Seperator* sep)
  7131. {
  7132. PrintSep(sep, "COMMAND_CANCEL_TRADE");
  7133. Trade* trade = client->GetPlayer()->trade;
  7134. if (trade) {
  7135. trade->CancelTrade(client->GetPlayer());
  7136. safe_delete(trade);
  7137. }
  7138. else
  7139. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7140. }
  7141. /*
  7142. Function: Command_TradeSetCoin()
  7143. Purpose : Sets coin trade between players
  7144. Params :
  7145. Dev :
  7146. Example :
  7147. */
  7148. void Commands::Command_TradeSetCoin(Client* client, Seperator* sep)
  7149. {
  7150. PrintSep(sep, "COMMAND_SET_TRADE_COIN");
  7151. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Set Trade Coin");
  7152. client->Message(CHANNEL_COLOR_YELLOW, "You cannot trade with other players (Not Implemented)");
  7153. }
  7154. /*
  7155. Function: Command_TradeAddCoin()
  7156. Purpose : Adds coin to trade between players
  7157. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  7158. Dev :
  7159. Example :
  7160. */
  7161. void Commands::Command_TradeAddCoin(Client* client, Seperator* sep, int handler)
  7162. {
  7163. PrintSep(sep, "COMMAND_ADD_TRADE_{coin type}");
  7164. Trade* trade = client->GetPlayer()->trade;
  7165. if (trade) {
  7166. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7167. int32 amount = atoi(sep->arg[0]);
  7168. int64 val = 0;
  7169. switch (handler) {
  7170. case COMMAND_ADD_TRADE_COPPER:
  7171. {
  7172. val = amount;
  7173. trade->AddCoinToTrade(client->GetPlayer(), val);
  7174. break;
  7175. }
  7176. case COMMAND_ADD_TRADE_SILVER:
  7177. {
  7178. val = amount * 100;
  7179. trade->AddCoinToTrade(client->GetPlayer(), val);
  7180. break;
  7181. }
  7182. case COMMAND_ADD_TRADE_GOLD:
  7183. {
  7184. val = amount * 10000;
  7185. trade->AddCoinToTrade(client->GetPlayer(), val);
  7186. break;
  7187. }
  7188. case COMMAND_ADD_TRADE_PLAT:
  7189. {
  7190. val = amount * 1000000;
  7191. trade->AddCoinToTrade(client->GetPlayer(), val);
  7192. break;
  7193. }
  7194. default:
  7195. {
  7196. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  7197. break;
  7198. }
  7199. }
  7200. }
  7201. else
  7202. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount.");
  7203. }
  7204. else
  7205. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7206. }
  7207. /*
  7208. Function: Command_TradeRemoveCoin()
  7209. Purpose : Removes coin from trade between players
  7210. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  7211. Dev :
  7212. Example :
  7213. */
  7214. void Commands::Command_TradeRemoveCoin(Client* client, Seperator* sep, int handler)
  7215. {
  7216. PrintSep(sep, "COMMAND_REMOVE_TRADE_{coin type}");
  7217. Trade* trade = client->GetPlayer()->trade;
  7218. if (trade) {
  7219. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7220. int32 amount = atoi(sep->arg[0]);
  7221. int64 val = 0;
  7222. switch (handler) {
  7223. case COMMAND_REMOVE_TRADE_COPPER:
  7224. {
  7225. val = amount;
  7226. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7227. break;
  7228. }
  7229. case COMMAND_REMOVE_TRADE_SILVER:
  7230. {
  7231. val = amount * 100;
  7232. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7233. break;
  7234. }
  7235. case COMMAND_REMOVE_TRADE_GOLD:
  7236. {
  7237. val = amount * 10000;
  7238. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7239. break;
  7240. }
  7241. case COMMAND_REMOVE_TRADE_PLAT:
  7242. {
  7243. val = amount * 1000000;
  7244. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7245. break;
  7246. }
  7247. default:
  7248. {
  7249. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  7250. break;
  7251. }
  7252. }
  7253. }
  7254. else
  7255. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount");
  7256. }
  7257. else
  7258. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7259. }
  7260. /*
  7261. Function: Command_TradeAddItem()
  7262. Purpose : Adds item to trade between players
  7263. Params :
  7264. Dev :
  7265. Example :
  7266. */
  7267. void Commands::Command_TradeAddItem(Client* client, Seperator* sep)
  7268. {
  7269. PrintSep(sep, "COMMAND_ADD_TRADE_ITEM");
  7270. /*
  7271. arg[0] = item index
  7272. arg[1] = slot
  7273. arg[2] = quantity
  7274. */
  7275. if (!client->GetPlayer()->trade) {
  7276. LogWrite(PLAYER__ERROR, 0, "Trade", "Player is not currently trading.");
  7277. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7278. return;
  7279. }
  7280. if (sep && sep->IsSet(0) && sep->IsNumber(0) && sep->IsSet(1) && sep->IsNumber(1) && sep->IsSet(2) && sep->IsNumber(2)) {
  7281. Item* item = 0;
  7282. int32 index = atoi(sep->arg[0]);
  7283. item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(index);
  7284. if (item) {
  7285. int8 result = client->GetPlayer()->trade->AddItemToTrade(client->GetPlayer(), item, atoi(sep->arg[2]), atoi(sep->arg[1]));
  7286. if (result == 1)
  7287. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Item is already being traded.");
  7288. else if (result == 2)
  7289. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade NO-TRADE items.");
  7290. else if (result == 3)
  7291. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade HEIRLOOM items.");
  7292. else if (result == 255)
  7293. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown error trying to add the item to the trade...");
  7294. }
  7295. else {
  7296. LogWrite(PLAYER__ERROR, 0, "Trade", "Unable to get an item for the player (%s) from the index (%u)", client->GetPlayer()->GetName(), index);
  7297. client->Message(CHANNEL_ERROR, "Unable to find item at index %u", index);
  7298. }
  7299. }
  7300. else
  7301. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  7302. }
  7303. /*
  7304. Function: Command_TradeRemoveItem()
  7305. Purpose : Removes item from trade between players
  7306. Params :
  7307. Dev :
  7308. Example :
  7309. */
  7310. void Commands::Command_TradeRemoveItem(Client* client, Seperator* sep)
  7311. {
  7312. PrintSep(sep, "COMMAND_REMOVE_TRADE_ITEM");
  7313. /*
  7314. arg[0] = trade window slot
  7315. */
  7316. Trade* trade = client->GetPlayer()->trade;
  7317. if (trade) {
  7318. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7319. trade->RemoveItemFromTrade(client->GetPlayer(), atoi(sep->arg[0]));
  7320. }
  7321. else
  7322. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  7323. }
  7324. else
  7325. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7326. }
  7327. void Commands::Command_TryOn(Client* client, Seperator* sep)
  7328. {
  7329. Item *item = 0;
  7330. sint32 crc;
  7331. if (sep) {
  7332. // 1096+ sends more info so need to do a version check so older clients (SF) still work
  7333. if (client->GetVersion() < 1096) {
  7334. if (sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2))
  7335. {
  7336. item = master_item_list.GetItem(atoul(sep->arg[1]));
  7337. crc = atol(sep->arg[2]);
  7338. }
  7339. }
  7340. else {
  7341. // From the broker and links in chat
  7342. if (strcmp(sep->arg[0], "crc") == 0) {
  7343. if (sep->IsNumber(2) && sep->IsNumber(3)) {
  7344. item = master_item_list.GetItem(atoul(sep->arg[2]));
  7345. crc = atol(sep->arg[3]);
  7346. }
  7347. }
  7348. // From inventory
  7349. if (strcmp(sep->arg[0], "dbid") == 0) {
  7350. if (sep->IsNumber(2) && sep->IsNumber(4)) {
  7351. item = master_item_list.GetItem(atoul(sep->arg[2]));
  7352. crc = atol(sep->arg[4]);
  7353. }
  7354. }
  7355. }
  7356. if (item)
  7357. client->ShowDressingRoom(item, crc);
  7358. }
  7359. }
  7360. void Commands::Command_JoinChannel(Client * client, Seperator *sep) {
  7361. const char *channel_name, *password = NULL;
  7362. if (sep == NULL || !sep->IsSet(0)) {
  7363. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /joinchannel <channel name> [password]");
  7364. return;
  7365. }
  7366. channel_name = sep->arg[0];
  7367. if (sep->IsSet(1))
  7368. password = sep->arg[1];
  7369. if (!chat.ChannelExists(channel_name) && !chat.CreateChannel(channel_name, password)) {
  7370. client->Message(CHANNEL_COLOR_RED, "Unable to create channel '%s'.", channel_name);
  7371. return;
  7372. }
  7373. if (chat.IsInChannel(client, channel_name)) {
  7374. client->Message(CHANNEL_COLOR_WHITE, "You are already in '%s'.", channel_name);
  7375. return;
  7376. }
  7377. if (chat.HasPassword(channel_name)) {
  7378. if (password == NULL) {
  7379. client->Message(CHANNEL_COLOR_WHITE, "Unable to join '%s': That channel is password protected.", channel_name);
  7380. return;
  7381. }
  7382. if (!chat.PasswordMatches(channel_name, password)) {
  7383. client->Message(CHANNEL_COLOR_WHITE, "Unable to join '%s': The password is not correc.t", channel_name);
  7384. return;
  7385. }
  7386. }
  7387. if (!chat.JoinChannel(client, channel_name))
  7388. client->Message(CHANNEL_COLOR_RED, "There was an internal error preventing you from joining '%s'.", channel_name);
  7389. }
  7390. void Commands::Command_JoinChannelFromLoad(Client * client, Seperator *sep) {
  7391. printf("ScatDebug: Received 'joinfromchannel', using the same function as 'joinchannel' (not sure what the difference is)\n");
  7392. Command_JoinChannel(client, sep);
  7393. }
  7394. void Commands::Command_TellChannel(Client *client, Seperator *sep) {
  7395. if (sep == NULL || !sep->IsSet(0) || !sep->IsSet(1)) {
  7396. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /tellchannel <channel name> <message>");
  7397. PrintSep(sep, "tellchannel");
  7398. return;
  7399. }
  7400. chat.TellChannel(client, sep->arg[0], sep->argplus[1]);
  7401. }
  7402. void Commands::Command_Test(Client* client, EQ2_16BitString* command_parms) {
  7403. PacketStruct* p = configReader.getStruct("WS_EqTargetItemCmd", client->GetVersion());
  7404. if (!p) return;
  7405. //Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  7406. //client->GetCurrentZone()->SendSpellFailedPacket(client, atoi(sep2->arg[0]));
  7407. //}
  7408. /*Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  7409. if (sep2 && sep2->arg[0] && sep2->IsNumber(0)) {
  7410. client->SetPendingFlightPath(atoi(sep2->arg[0]));
  7411. PacketStruct* packet = configReader.getStruct("WS_ReadyForTakeOff", client->GetVersion());
  7412. if (packet) {
  7413. client->QueuePacket(packet->serialize());
  7414. safe_delete(packet);
  7415. }
  7416. }*/
  7417. /*if (client->GetCurrentZone()->Grid != nullptr) {
  7418. int32 numFaces = 0;
  7419. int32 numGrids = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.size();
  7420. client->Message(CHANNEL_COLOR_YELLOW, "Num grids in cell: %u", numGrids);
  7421. map<int32, vector<Face*> >::iterator itr;
  7422. for (itr = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.begin(); itr != client->GetPlayer()->Cell_Info.CurrentCell->FaceList.end(); itr++)
  7423. numFaces += (*itr).second.size();
  7424. client->Message(CHANNEL_COLOR_YELLOW, "Num faces in cell: %u", numFaces);
  7425. }*/
  7426. //uchar blah[] = {
  7427. // 1208 - OP_EQUpdateStoreCmd
  7428. // /*0x00,0x3A,*/0x2B,0x00,0x00,0x00,0xFF,0x78,0x02,0x53,0x2C,0x33,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
  7429. // /*0x58,*/0x47,0x35,0xD3,0x45,0x42,0x42,0x51,0x00,0x40,0xD1,0xE7,0x57,0xB1,0x51,0xB1,0xBB,0xBB,0xB1,0x3B,0xB0,0xBB,0xB0,0x3B,0x59,0x85,0x5B,0x47,0x1D,0x9C,0x3B,0x3A,0x1B,0xB8,0xD9,0x64,0x14,0x85,0x9F,0x4C,0xC8,0x09,0x21,0xA4,0xB3,0x7F,0x45,0x90,0x0B,0x79,0x90,0x0F,0x31,0x28,0x80,0x42,0x28,0x82,0x62,0x28,0x81,0x52,0x28,0x83,0x38,0x94,0x43,0x05,0x54,0x42,0x02,0xAA,0xA0,0x1A,0x6A,0xA0,0x16,0xEA,0xA0,0x1E,0x1A,0xA0,0x11,0x9A,0xA0,0x19,0x5A,0xA0,0x15,0xDA,0xA0,0x1D,0x3A,0xA0,0x13,0xBA,0xA0,0x1B,0x7A,0xA0,0x17,0xFA,0xA0,0x1F,0x06,0x60,0x10,0x86,0x60,0x18,0x46,0x60,0x14,0xC6,0x60,0x1C,0x26,0x20,0x09,0x93,0x30,0x05,0xD3,0x30,0x03,0xB3,0x30,0x07,0xF3,0xB0,0x00,0x8B,0xB0,0x04,0xCB,0xB0,0x02,0xAB,0xB0,0x06,0xEB,0xB0,0x01,0x29,0xD8,0x84,0x2D,0xD8,0x86,0x1D,0xD8,0x85,0x3D,0xD8,0x87,0x03,0x38,0x84,0x23,0x38,0x86,0x13,0x38,0x85,0x33,0x38,0x87,0x0B,0xB8,0x84,0x34,0x5C,0xC1,0x35,0xDC,0xC0,0x2D,0xDC,0xC1,0x3D,0x3C,0xC0,0x23,0x3C,0xC1,0x33,0xBC,0xC0,0x2B,0xBC,0xC1,0x3B,0x7C,0xC0,0x27,0x7C,0xC1,0x37,0x64,0xE0,0xFF,0xD3,0xF0,0x0B,0x29,0x4A,0xD8,0x68
  7430. // 1193 - -- OP_ClientCmdMsg::OP_EqUpdateMerchantCmd --
  7431. // /*0x00,0x3A,*/0x38,0x00,0x00,0x00,0xFF,0x77,0x02,0xA6,0xAA,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x3F,0x00,0x00,0x00,0x00,0xA8,0x55,0xEC,0x8F,0x7F,0x70,0x31,0x08,0x40,0x71,0x3A,0x8B,0xB4,0x55,0xEC,0x8F,0x00
  7432. /*};
  7433. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  7434. int8 val = 0;
  7435. int16 pos = 0;
  7436. int idx = 0;
  7437. while(sep2 && sep2->arg[idx+1] && sep2->IsNumber(idx) && sep2->IsNumber(idx+1)){
  7438. pos = atoi(sep2->arg[idx]);
  7439. val = atoi(sep2->arg[idx+1]);
  7440. memset(blah+pos, val, 1);
  7441. idx+=2;
  7442. }
  7443. DumpPacket(blah, sizeof(blah));
  7444. client->QueuePacket(new EQ2Packet(OP_GroupCreatedMsg , blah, sizeof(blah)));*/
  7445. if (client->GetPlayer()->GetTarget()) {
  7446. PacketStruct* packet = configReader.getStruct("WS_SetControlGhost", client->GetVersion());
  7447. if (packet) {
  7448. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  7449. packet->setDataByName("size", 0);
  7450. packet->setDataByName("unknown2", 0);
  7451. EQ2Packet* app = packet->serialize();
  7452. client->QueuePacket(app);
  7453. safe_delete(packet);
  7454. }
  7455. PacketStruct* set_pov = configReader.getStruct("WS_SetPOVGhostCmd", client->GetVersion());
  7456. if (set_pov) {
  7457. set_pov->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  7458. EQ2Packet* app_pov = set_pov->serialize();
  7459. client->QueuePacket(app_pov);
  7460. safe_delete(set_pov);
  7461. }
  7462. }
  7463. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  7464. PacketStruct* packet = configReader.getStruct("WS_OpenCharCust", client->GetVersion());
  7465. if (packet) {
  7466. if (sep2 && sep2->arg[0] && sep2->IsNumber(0))
  7467. packet->setDataByName("Type", atoi(sep2->arg[0]));
  7468. else
  7469. packet->setDataByName("Type", 2);
  7470. if (sep2 && sep2->arg[1] && sep2->IsNumber(1))
  7471. packet->setDataByName("race_id", atoi(sep2->arg[1]));
  7472. else
  7473. packet->setDataByName("race_id", 0);
  7474. if (sep2 && sep2->arg[2] && sep2->IsNumber(2))
  7475. packet->setDataByName("gender", atoi(sep2->arg[2]));
  7476. else
  7477. packet->setDataByName("gender", 2);
  7478. if (sep2 && sep2->arg[3] && sep2->IsNumber(3))
  7479. packet->setDataByName("unknown", atoi(sep2->arg[3]), 0);
  7480. else
  7481. packet->setDataByName("unknown", 0, 0);
  7482. if (sep2 && sep2->arg[4] && sep2->IsNumber(4))
  7483. packet->setDataByName("unknown", atoi(sep2->arg[4]), 1);
  7484. else
  7485. packet->setDataByName("unknown", 0, 1);
  7486. if (sep2 && sep2->arg[5] && sep2->IsNumber(5))
  7487. packet->setDataByName("unknown", atoi(sep2->arg[5]), 2);
  7488. else
  7489. packet->setDataByName("unknown", 0, 2);
  7490. client->QueuePacket(packet->serialize());
  7491. }
  7492. safe_delete(packet);
  7493. safe_delete(sep2);
  7494. }
  7495. void Commands::Command_LeaveChannel(Client *client, Seperator *sep) {
  7496. const char *channel_name;
  7497. if (sep == NULL || !sep->IsSet(0)) {
  7498. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /leavechat <channel name>");
  7499. PrintSep(sep);
  7500. return;
  7501. }
  7502. channel_name = sep->arg[0];
  7503. if (!chat.IsInChannel(client, channel_name))
  7504. client->Message(CHANNEL_COLOR_WHITE, "Unable to leave '%s': You are not in the channel.", channel_name);
  7505. else if (!chat.LeaveChannel(client, channel_name))
  7506. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an internal error preventing you from leaving that channel MUAHAHA");
  7507. }
  7508. /*
  7509. Function:
  7510. Purpose :
  7511. Params :
  7512. Dev :
  7513. Example :
  7514. */
  7515. void Commands::Command_WeaponStats(Client* client)
  7516. {
  7517. Player* player = client->GetPlayer();
  7518. Item* primary = player->GetEquipmentList()->GetItem(EQ2_PRIMARY_SLOT);
  7519. Item* secondary = player->GetEquipmentList()->GetItem(EQ2_SECONDARY_SLOT);
  7520. Item* ranged = player->GetEquipmentList()->GetItem(EQ2_RANGE_SLOT);
  7521. client->SimpleMessage(0, "Primary:");
  7522. if (primary) {
  7523. client->Message(0, "Name: %s", primary->name.c_str());
  7524. client->Message(0, "Base Damage: %u - %u", primary->weapon_info->damage_low3, primary->weapon_info->damage_high3);
  7525. client->Message(0, "Actual Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  7526. client->Message(0, "Actual Delay: %u", player->GetPrimaryWeaponDelay());
  7527. client->Message(0, "Proc Percent: %d%%", 0);
  7528. client->Message(0, "Procs Per Minute: %d", 0);
  7529. }
  7530. else {
  7531. client->SimpleMessage(0, "Name: fist");
  7532. client->Message(0, "Base Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  7533. client->Message(0, "Actual Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  7534. client->Message(0, "Actual Delay: %d", player->GetPrimaryWeaponDelay() * 0.1);
  7535. client->Message(0, "Proc Percent: %d%%", 0);
  7536. client->Message(0, "Procs Per Minute: %d", 0);
  7537. }
  7538. client->SimpleMessage(0, " ");
  7539. client->SimpleMessage(0, " ");
  7540. if (secondary) {
  7541. client->SimpleMessage(0, "Secondary:");
  7542. client->Message(0, "Name: %s", secondary->name.c_str());
  7543. client->Message(0, "Base Damage: %u - %u", secondary->weapon_info->damage_low3, secondary->weapon_info->damage_high3);
  7544. client->Message(0, "Actual Damage: %u - %u", player->GetSecondaryWeaponMinDamage(), player->GetSecondaryWeaponMaxDamage());
  7545. client->Message(0, "Actual Delay: %d", player->GetSecondaryWeaponDelay() * 0.1);
  7546. client->Message(0, "Proc Percent: %d%%", 0);
  7547. client->Message(0, "Procs Per Minute: %d", 0);
  7548. client->SimpleMessage(0, " ");
  7549. client->SimpleMessage(0, " ");
  7550. }
  7551. client->SimpleMessage(0, "Ranged:");
  7552. if (ranged) {
  7553. client->Message(0, "Name: %s", ranged->name.c_str());
  7554. client->Message(0, "Base Damage: %u - %u", ranged->ranged_info->weapon_info.damage_low3, ranged->ranged_info->weapon_info.damage_high3);
  7555. client->Message(0, "Actual Damage: %u - %u", player->GetRangedWeaponMinDamage(), player->GetRangedWeaponMaxDamage());
  7556. client->Message(0, "Actual Delay: %d", player->GetRangeWeaponDelay() * 0.1);
  7557. client->Message(0, "Proc Percent: %d%%", 0);
  7558. client->Message(0, "Procs Per Minute: %d", 0);
  7559. }
  7560. else
  7561. client->SimpleMessage(0, "None");
  7562. }
  7563. void Commands::Command_WhoChannel(Client *client, Seperator *sep) {
  7564. const char *channel_name;
  7565. if (sep == NULL || !sep->IsSet(0)) {
  7566. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /chatwho <channel name>");
  7567. return;
  7568. }
  7569. channel_name = sep->arg[0];
  7570. if (!chat.ChannelExists(channel_name))
  7571. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That channel does not exist!");
  7572. else
  7573. chat.SendChannelUserList(client, channel_name);
  7574. }
  7575. void Commands::Command_ZoneSafeCoords(Client *client, Seperator *sep)
  7576. {
  7577. ZoneServer* zone = 0;
  7578. int32 zone_id = client->GetPlayer()->GetZone()->GetZoneID();
  7579. if (zone_id > 0)
  7580. {
  7581. zone = zone_list.Get(zone_id, false);
  7582. if (zone)
  7583. {
  7584. zone->SetSafeX(client->GetPlayer()->GetX());
  7585. zone->SetSafeY(client->GetPlayer()->GetY());
  7586. zone->SetSafeZ(client->GetPlayer()->GetZ());
  7587. zone->SetSafeHeading(client->GetPlayer()->GetHeading());
  7588. if( database.SaveZoneSafeCoords(zone_id, zone->GetSafeX(), zone->GetSafeY(), zone->GetSafeZ(), zone->GetSafeHeading()) )
  7589. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Zone safe coordinates updated!");
  7590. else
  7591. client->SimpleMessage(CHANNEL_COLOR_RED, "FAILED to update zone safe coordinates!");
  7592. }
  7593. }
  7594. }
  7595. /*
  7596. Function:
  7597. Purpose :
  7598. Params :
  7599. Dev :
  7600. Example :
  7601. */
  7602. void Commands::Command_ZoneDetails(Client* client, Seperator* sep)
  7603. {
  7604. ZoneInfo* zone_info = new ZoneInfo;
  7605. if (sep && sep->arg[0])
  7606. {
  7607. if (sep->IsNumber(0))
  7608. zone_info->id = atoi(sep->arg[0]);
  7609. else
  7610. zone_info->id = database.GetZoneID(sep->arg[0]);
  7611. if (zone_info->id > 0)
  7612. {
  7613. database.LoadZoneInfo(zone_info);
  7614. client->Message(CHANNEL_COLOR_YELLOW, "id: %u, name: %s, file: %s, description: %s", zone_info->id, zone_info->name, zone_info->file, zone_info->description);
  7615. client->Message(CHANNEL_COLOR_YELLOW, "safe_x: %f, safe_y: %f, safe_z: %f, underworld: %f", zone_info->safe_x, zone_info->safe_y, zone_info->safe_z, zone_info->underworld);
  7616. client->Message(CHANNEL_COLOR_YELLOW, "min_status: %u, min_level: %u, max_level: %u, xp_modifier: %u", zone_info->min_status, zone_info->min_level, zone_info->max_level, zone_info->xp_modifier);
  7617. client->Message(CHANNEL_COLOR_YELLOW, "instance_type: %u, shutdown_timer: %u, ruleset_id: %u", zone_info->instance_type, zone_info->shutdown_timer, zone_info->ruleset_id);
  7618. client->Message(CHANNEL_COLOR_YELLOW, "default_reenter_time: %u, default_reset_time: %u, default_lockout_time: %u", zone_info->default_reenter_time, zone_info->default_reenter_time, zone_info->default_lockout_time);
  7619. client->Message(CHANNEL_COLOR_YELLOW, "force_group_to_zone: %u, expansion_id: %u, min_version: %u", zone_info->force_group_to_zone, zone_info->expansion_id, zone_info->min_version);
  7620. client->Message(CHANNEL_COLOR_YELLOW, "always_loaded: %u, city_zone: %u, start_zone: %u, weather_allowed: %u", zone_info->always_loaded, zone_info->city_zone, zone_info->start_zone, zone_info->weather_allowed);
  7621. client->Message(CHANNEL_COLOR_YELLOW, "zone_type: %s", zone_info->zone_type);
  7622. client->Message(CHANNEL_COLOR_YELLOW, "lua_script: %s", zone_info->lua_script);
  7623. client->Message(CHANNEL_COLOR_YELLOW, "zone_motd: %s", zone_info->zone_motd);
  7624. }
  7625. else
  7626. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  7627. }
  7628. else
  7629. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone details [zone id|zone name]");
  7630. safe_delete(zone_info);
  7631. }
  7632. /*
  7633. Function:
  7634. Purpose :
  7635. Params :
  7636. Dev :
  7637. Example :
  7638. */
  7639. void Commands::Command_ZoneSet(Client* client, Seperator* sep)
  7640. {
  7641. if (sep && sep->arg[0] && sep->arg[1] && sep->arg[2])
  7642. {
  7643. ZoneServer* zone = 0;
  7644. int32 zone_id = 0;
  7645. if (sep->IsNumber(0) && atoi(sep->arg[0]) > 0)
  7646. {
  7647. zone_id = atoi(sep->arg[0]);
  7648. zone = zone_list.Get(atoi(sep->arg[0]), false);
  7649. }
  7650. else
  7651. {
  7652. zone_id = database.GetZoneID(sep->arg[0]);
  7653. if (zone_id > 0)
  7654. zone = zone_list.Get(sep->arg[0], false);
  7655. }
  7656. if (zone_id > 0)
  7657. {
  7658. if (zone_set_values.count(string(sep->arg[1])) > 0)
  7659. SetZoneCommand(client, zone_id, zone, zone_set_values[sep->arg[1]], sep->arg[2]);
  7660. else
  7661. client->Message(CHANNEL_COLOR_YELLOW, "The attribute '%s' is not valid.", sep->arg[1]);
  7662. }
  7663. else
  7664. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  7665. }
  7666. else
  7667. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone set [zone id|zone name] [attribute] [value]");
  7668. }
  7669. void Commands::Command_Rain(Client* client, Seperator* sep) {
  7670. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  7671. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /rain <float>");
  7672. return;
  7673. }
  7674. client->Message(CHANNEL_COLOR_YELLOW,"Setting rain to %.2f", atof(sep->arg[0]));
  7675. client->GetCurrentZone()->SetRain(atof(sep->arg[0]));
  7676. client->GetCurrentZone()->SetCurrentWeather(atof(sep->arg[0]));
  7677. }
  7678. void Commands::Command_Wind(Client* client, Seperator* sep) {
  7679. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  7680. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /wind <float>");
  7681. return;
  7682. }
  7683. client->Message(CHANNEL_COLOR_YELLOW, "Setting wind to %.2f", atof(sep->arg[0]));
  7684. client->GetCurrentZone()->SetWind(atof(sep->arg[0]));
  7685. }
  7686. void Commands::Command_SendMerchantWindow(Client* client, Seperator* sep, bool sell) {
  7687. Spawn* spawn = client->GetPlayer()->GetTarget();
  7688. if(spawn) {
  7689. client->SetMerchantTransaction(spawn);
  7690. if (spawn->GetMerchantID() > 0){
  7691. //MerchantFactionMultiplier* multiplier = world.GetMerchantMultiplier(spawn->GetMerchantID());
  7692. //if(!multiplier || (multiplier && client->GetPlayer()->GetFactions()->GetFactionValue(multiplier->faction_id) >= multiplier->faction_min)){
  7693. client->SendBuyMerchantList(sell);
  7694. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY))
  7695. client->SendSellMerchantList(sell);
  7696. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY_BACK))
  7697. client->SendBuyBackList(sell);
  7698. PacketStruct* packet = configReader.getStruct("WS_UpdateMerchant", client->GetVersion());
  7699. if (packet) {
  7700. packet->setDataByName("spawn_id", 0xFFFFFFFF);
  7701. packet->setDataByName("type", 16);
  7702. EQ2Packet* outapp = packet->serialize();
  7703. if (outapp)
  7704. client->QueuePacket(outapp);
  7705. safe_delete(packet);
  7706. }
  7707. }
  7708. if (spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR)
  7709. client->SendRepairList();
  7710. }
  7711. // client->SimpleMessage(CHANNEL_COLOR_RED, "Your faction is too low to use this merchant.");
  7712. }
  7713. void Commands::Command_Weather(Client* client, Seperator* sep)
  7714. {
  7715. //PrintSep(sep, "Weather");
  7716. if( sep && sep->arg[0] )
  7717. {
  7718. ZoneServer* zsZone = client->GetCurrentZone();
  7719. const char* value = sep->arg[0];
  7720. // process single-param commands first
  7721. if( strncasecmp(value, "details", strlen(value)) == 0 )
  7722. {
  7723. client->Message(CHANNEL_COLOR_YELLOW, "Weather Details for zone %s: ", zsZone->GetZoneName());
  7724. client->Message(CHANNEL_COLOR_YELLOW, "enabled: %i, allowed: %i, type: %i, frequency: %u", zsZone->isWeatherEnabled(), zsZone->isWeatherAllowed(), zsZone->GetWeatherType(), zsZone->GetWeatherFrequency());
  7725. client->Message(CHANNEL_COLOR_YELLOW, "severity: %.2f = %.2f, current: %.2f", zsZone->GetWeatherMinSeverity(), zsZone->GetWeatherMaxSeverity(), zsZone->GetCurrentWeather());
  7726. client->Message(CHANNEL_COLOR_YELLOW, "pattern: %i, chance: %i, amount: %.2f, offset: %.2f", zsZone->GetWeatherPattern(), zsZone->GetWeatherChance(), zsZone->GetWeatherChangeAmount(), zsZone->GetWeatherDynamicOffset());
  7727. }
  7728. else if( strncasecmp(value, "process", strlen(value)) == 0 )
  7729. {
  7730. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  7731. zsZone->ProcessWeather();
  7732. }
  7733. else if( strncasecmp(value, "reset", strlen(value)) == 0 )
  7734. {
  7735. zsZone->SetWeatherType(rule_manager.GetGlobalRule(R_Zone, WeatherType)->GetInt8());
  7736. zsZone->SetWeatherFrequency(rule_manager.GetGlobalRule(R_Zone, WeatherChangeFrequency)->GetInt32());
  7737. zsZone->SetWeatherMinSeverity(rule_manager.GetGlobalRule(R_Zone, MinWeatherSeverity)->GetFloat());
  7738. zsZone->SetWeatherMaxSeverity(rule_manager.GetGlobalRule(R_Zone, MaxWeatherSeverity)->GetFloat());
  7739. zsZone->SetCurrentWeather(zsZone->GetWeatherMinSeverity());
  7740. zsZone->SetWeatherPattern(1);
  7741. zsZone->SetWeatherChance(rule_manager.GetGlobalRule(R_Zone, WeatherChangeChance)->GetInt8());
  7742. zsZone->SetWeatherChangeAmount(rule_manager.GetGlobalRule(R_Zone, WeatherChangePerInterval)->GetFloat());
  7743. zsZone->SetWeatherDynamicOffset(rule_manager.GetGlobalRule(R_Zone, WeatherDynamicMaxOffset)->GetFloat());
  7744. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  7745. zsZone->ProcessWeather();
  7746. }
  7747. // process commands with params
  7748. if( sep->arg[1] )
  7749. {
  7750. if( strncasecmp(value, "enable", strlen(value)) == 0 && sep->IsNumber(1) )
  7751. zsZone->SetWeatherEnabled( ( atoi(sep->arg[1]) == 1 ) ? true : false );
  7752. else if( strncasecmp(value, "type", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 3) )
  7753. zsZone->SetWeatherType(atoi(sep->arg[1]));
  7754. else if( strncasecmp(value, "frequency", strlen(value)) == 0 && sep->IsNumber(1))
  7755. zsZone->SetWeatherFrequency( atoul(sep->arg[1]) );
  7756. else if( strncasecmp(value, "range", strlen(value)) == 0 && sep->IsNumber(1) && sep->IsNumber(2) ) {
  7757. zsZone->SetWeatherMinSeverity(atof(sep->arg[1]));
  7758. zsZone->SetWeatherMaxSeverity(atof(sep->arg[2]));
  7759. zsZone->SetRain(zsZone->GetWeatherMinSeverity());
  7760. }
  7761. else if( strncasecmp(value, "current", strlen(value)) == 0 && sep->IsNumber(1) ) {
  7762. zsZone->SetCurrentWeather(atof(sep->arg[1]));
  7763. zsZone->SetRain(zsZone->GetCurrentWeather());
  7764. }
  7765. else if( strncasecmp(value, "pattern", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 2) )
  7766. zsZone->SetWeatherPattern( atoi(sep->arg[1]) );
  7767. else if( strncasecmp(value, "chance", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 100) )
  7768. zsZone->SetWeatherChance( atoi(sep->arg[1]) );
  7769. else if( strncasecmp(value, "amount", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  7770. zsZone->SetWeatherChangeAmount( atof(sep->arg[1]) );
  7771. else if( strncasecmp(value, "offset", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  7772. zsZone->SetWeatherDynamicOffset( atof(sep->arg[1]) );
  7773. }
  7774. }
  7775. else
  7776. {
  7777. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /weather [command] [param]");
  7778. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: enable (0|1), type (0-3), frequency (sec), range|current (0.0 - 1.0)");
  7779. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: details, process, pattern (0|1), chance (%), amount (float), offset (float)");
  7780. return;
  7781. }
  7782. }
  7783. void Commands::Command_Select(Client* client, Seperator* sep) {
  7784. if (sep && sep->arg[1]) {
  7785. Spawn* spawn = client->GetPlayer()->GetTarget();
  7786. if (spawn && strlen(sep->arg[1]) > 0)
  7787. client->GetCurrentZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_CUSTOM, client->GetPlayer(), sep->arg[1]);
  7788. }
  7789. }
  7790. /*
  7791. Function: Command_ConsumeFood()
  7792. Purpose : Consume Food/Drink and apply mods
  7793. Params : Slot ID - EQ2_FOOD_SLOT 22, EQ2_DRINK_SLOT 23
  7794. Dev : Zcoretri
  7795. Example : /consume_food 22
  7796. */
  7797. void Commands::Command_ConsumeFood(Client* client, Seperator* sep) {
  7798. if (sep && sep->arg[0] && sep->IsNumber(0))
  7799. {
  7800. Player* player = client->GetPlayer();
  7801. int8 slot = atoi(sep->arg[0]);
  7802. Item* item = player->GetEquipmentList()->GetItem(slot);
  7803. if(item) {
  7804. LogWrite(MISC__INFO, 1, "Command", "ItemID: %u, ItemName: %s ItemCount: %i ", item->details.item_id, item->name.c_str(), item->details.count);
  7805. if(item->GetItemScript() && lua_interface){
  7806. lua_interface->RunItemScript(item->GetItemScript(), "cast", item, client->GetPlayer());
  7807. if (slot == 22)
  7808. client->Message(CHANNEL_COLOR_WHITE, "You eat a %s.", item->name.c_str());
  7809. else
  7810. client->Message(CHANNEL_COLOR_WHITE, "You drink a %s.", item->name.c_str());
  7811. }
  7812. }
  7813. if (item->details.count > 1) {
  7814. item->details.count -= 1;
  7815. item->save_needed = true;
  7816. }
  7817. else {
  7818. player->GetEquipmentList()->RemoveItem(slot, true);
  7819. database.DeleteItem(player->GetCharacterID(), item, "EQUIPPED");
  7820. }
  7821. client->GetPlayer()->SetCharSheetChanged(true);
  7822. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  7823. }
  7824. }
  7825. void Commands::Command_Aquaman(Client* client, Seperator* sep) {
  7826. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  7827. if (atoi(sep->arg[0]) == 1) {
  7828. client->GetPlayer()->GetInfoStruct()->vision = 4;
  7829. client->GetPlayer()->GetInfoStruct()->breathe_underwater = 1;
  7830. client->GetPlayer()->SetCharSheetChanged(true);
  7831. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Maybe you ought to stick to the shallow end until you know how to swim.");
  7832. }
  7833. else {
  7834. client->GetPlayer()->GetInfoStruct()->vision = 0;
  7835. client->GetPlayer()->GetInfoStruct()->breathe_underwater = 0;
  7836. client->GetPlayer()->SetCharSheetChanged(true);
  7837. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Aquaman mode turned off.");
  7838. }
  7839. }
  7840. else
  7841. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /aquaman [0|1]");
  7842. }
  7843. void Commands::Command_ReportBug(Client* client, Seperator* sep)
  7844. {
  7845. if(sep)
  7846. {
  7847. string data;
  7848. if(sep->arg[0]){
  7849. data = string(sep->arg[0]);
  7850. }
  7851. for(int i=1;i<sep->GetMaxArgNum();i++){
  7852. if(sep->arg[i])
  7853. data.append(" ").append(sep->arg[i]);
  7854. }
  7855. const char* target_name = 0;
  7856. int32 spawn_id = 0;
  7857. if(client->GetPlayer()->GetTarget())
  7858. {
  7859. target_name = client->GetPlayer()->GetTarget()->GetName();
  7860. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  7861. }
  7862. else
  7863. target_name = "N/A";
  7864. LogWrite(COMMAND__DEBUG, 1, "Command", "%s", data.c_str());
  7865. if(world.ReportBug(data, client->GetPlayer()->GetName(), client->GetAccountID(), target_name, spawn_id, client->GetCurrentZone()->GetZoneID()))
  7866. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully submitted bug.");
  7867. else
  7868. client->SimpleMessage(CHANNEL_COLOR_RED, "Error submitting bug.");
  7869. }
  7870. }
  7871. void Commands::Command_Attune_Inv(Client* client, Seperator* sep) {
  7872. PrintSep(sep, "Command_Attune_Inv");
  7873. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  7874. // Get the item index from the first parameter
  7875. int16 index = atoi(sep->arg[0]);
  7876. // Check to see if this is a valid item index for the player, if not exit out of the function
  7877. if (client->GetPlayer()->item_list.indexed_items.count(index) == 0) {
  7878. LogWrite(ITEM__DEBUG, 0, "Items", "%s has no item with an index of %i", client->GetPlayer()->GetName(), index);
  7879. return;
  7880. }
  7881. // Get the item
  7882. Item* item = client->GetPlayer()->item_list.indexed_items[index];
  7883. if(item) {
  7884. // Valid item lets check to make sure this item is attunable, if not return out
  7885. if (!item->CheckFlag(ATTUNEABLE)) {
  7886. LogWrite(ITEM__DEBUG, 0, "Items", "attune_inv called for an item that is not attunable (%s)", item->name.c_str());
  7887. return;
  7888. }
  7889. // Remove the attunable flag
  7890. item->generic_info.item_flags -= ATTUNEABLE;
  7891. // Set the attuned flag
  7892. item->generic_info.item_flags += ATTUNED;
  7893. // Flag this item for saving
  7894. item->save_needed = true;
  7895. client->QueuePacket(item->serialize(client->GetVersion(), false, client->GetPlayer()));
  7896. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), -1);
  7897. EQ2Packet* outapp = 0;
  7898. for (int32 i=0;i<packets.size();i++) {
  7899. outapp = packets[i];
  7900. if(outapp)
  7901. client->QueuePacket(outapp);
  7902. }
  7903. }
  7904. }
  7905. }
  7906. void Commands::Command_Reset_Zone_Timer(Client* client, Seperator* sep) {
  7907. PrintSep(sep, "Command_Reset_Zone_Timer");
  7908. /*if (sep && sep->arg[0] && sep->IsNumber(0)) {
  7909. int32 db_id = atoul(sep->arg[0]);
  7910. InstanceData* data = client->GetPlayer()->GetCharacterInstances().FindInstanceByDBID(db_id);
  7911. if (data) {
  7912. // TODO: add a check to timers to ensure it can be reset
  7913. // Delete the character from the instance
  7914. database.DeleteCharacterFromInstance(client->GetPlayer()->GetCharacterID(), data->instance_id);
  7915. data->instance_id = 0;
  7916. // Update the success time and set to 0 so the player can enter it again
  7917. database.UpdateCharacterInstance(client->GetPlayer()->GetCharacterID(), data->zone_name, 0, 1, 0);
  7918. data->last_success_timestamp = 0;
  7919. }
  7920. }*/
  7921. }
  7922. void Commands::Command_Player(Client* client, Seperator* sep) {
  7923. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player syntax --");
  7924. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins");
  7925. }
  7926. void Commands::Command_Player_Coins(Client* client, Seperator* sep) {
  7927. // /player coins add 10
  7928. // /player coins add plat 10
  7929. Player* player = client->GetPlayer();
  7930. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  7931. player = (Player*)player->GetTarget();
  7932. if (sep && sep->arg[0] && sep->arg[1]) {
  7933. const char* action = sep->arg[0];
  7934. int64 value = 0;
  7935. if (strncasecmp(action, "add", strlen(action)) == 0) {
  7936. if (sep->IsNumber(1)) {
  7937. value = atoi64(sep->arg[1]);
  7938. player->AddCoins(value);
  7939. if (client->GetPlayer() == player)
  7940. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  7941. else {
  7942. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  7943. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  7944. }
  7945. return;
  7946. }
  7947. else if (sep->arg[2] && sep->IsNumber(2)) {
  7948. const char* type = sep->arg[1];
  7949. if (strncasecmp(type, "copper", strlen(type)) == 0) {
  7950. value = atoi64(sep->arg[2]);
  7951. }
  7952. else if (strncasecmp(type, "silver", strlen(type)) == 0) {
  7953. value = atoi64(sep->arg[2]) * 100;
  7954. }
  7955. else if (strncasecmp(type, "gold", strlen(type)) == 0) {
  7956. value = atoi64(sep->arg[2]) * 10000;
  7957. }
  7958. else if (strncasecmp(type, "plat", strlen(type)) == 0) {
  7959. value = atoi64(sep->arg[2]) * 1000000;
  7960. }
  7961. player->AddCoins(value);
  7962. if (client->GetPlayer() == player)
  7963. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  7964. else {
  7965. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  7966. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  7967. }
  7968. return;
  7969. }
  7970. }
  7971. }
  7972. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player coins syntax --");
  7973. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add [value] - adds the given number of coins to the player");
  7974. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add copper [value] - adds the given amount of copper to the player");
  7975. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add silver [value] - adds the given amount of silver to the player");
  7976. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add gold [value] - adds the given amount of gold to the player");
  7977. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add plat [value] - adds the given amount of platinum to the player");
  7978. }
  7979. void Commands::Command_AchievementAdd(Client* client, Seperator* sep) {
  7980. PrintSep(sep, "ACHIEVEMENT_ADD");
  7981. if (sep && sep->IsSet(0)) {
  7982. int32 spell_id = atoul(sep->arg[1]);
  7983. int8 spell_tier = 0;
  7984. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  7985. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  7986. // addspellbookentry here
  7987. if (spell_tier >= data->maxRank) {
  7988. return;
  7989. }
  7990. if (!spell_tier) {
  7991. spell_tier = 1;
  7992. }
  7993. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  7994. {
  7995. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  7996. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  7997. client->GetPlayer()->UnlockSpell(spell);
  7998. client->SendSpellUpdate(spell);
  7999. }
  8000. else
  8001. {
  8002. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1);
  8003. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  8004. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  8005. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  8006. client->GetPlayer()->UnlockSpell(spell);
  8007. client->SendSpellUpdate(spell);
  8008. }
  8009. // cast spell here
  8010. if (!spell_tier)
  8011. spell_tier = 1;
  8012. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  8013. if (spell) {
  8014. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  8015. }
  8016. }
  8017. else {
  8018. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  8019. }
  8020. master_aa_list.DisplayAA(client, 0, 0);
  8021. }
  8022. void Commands::Command_Editor(Client* client, Seperator* sep) {
  8023. PacketStruct* packet = configReader.getStruct("WS_ChoiceWindow", client->GetVersion());
  8024. if (packet) {
  8025. string url = string(rule_manager.GetGlobalRule(R_World, EditorURL)->GetString());
  8026. if (rule_manager.GetGlobalRule(R_World, EditorOfficialServer)->GetBool()) {
  8027. char command[255];
  8028. url = "browser " + url;
  8029. int32 spawn_id = 0;
  8030. int32 zone_id = 0;
  8031. string type;
  8032. if (client->GetCurrentZone())
  8033. zone_id = client->GetCurrentZone()->GetZoneID();
  8034. if (client->GetPlayer()->GetTarget()) {
  8035. Spawn* target = client->GetPlayer()->GetTarget();
  8036. if (target->IsWidget())
  8037. type = "widgets";
  8038. else if (target->IsSign())
  8039. type = "signs";
  8040. else if (target->IsObject())
  8041. type = "objects";
  8042. else if (target->IsNPC())
  8043. type = "npcs";
  8044. else if (target->IsGroundSpawn())
  8045. type = "ground";
  8046. else
  8047. type = "spawn";
  8048. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  8049. }
  8050. sprintf(command, url.c_str(), zone_id, type.c_str(), spawn_id);
  8051. packet->setDataByName("accept_command", command);
  8052. }
  8053. else if (rule_manager.GetGlobalRule(R_World, EditorIncludeID)->GetBool()) {
  8054. char command[255];
  8055. url = "browser " + url;
  8056. if (client->GetPlayer()->GetTarget())
  8057. sprintf(command, url.c_str(), client->GetPlayer()->GetTarget()->GetDatabaseID());
  8058. packet->setDataByName("accept_command", command);
  8059. }
  8060. else {
  8061. string command = "browser " + url;
  8062. packet->setDataByName("accept_command", command.c_str());
  8063. }
  8064. packet->setDataByName("text", "Open the web editor?");
  8065. packet->setDataByName("accept_text", "Open");
  8066. packet->setDataByName("cancel_text", "Cancel");
  8067. // No clue if we even need the following 2 unknowns, just added them so the packet matches what live sends
  8068. packet->setDataByName("unknown2", 50);
  8069. packet->setDataByName("unknown4", 1);
  8070. client->QueuePacket(packet->serialize());
  8071. safe_delete(packet);
  8072. }
  8073. }
  8074. void Commands::Command_AcceptResurrection(Client* client, Seperator* sep) {
  8075. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  8076. return;
  8077. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  8078. if(client->GetCurrentRez()->active)
  8079. client->AcceptResurrection();
  8080. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  8081. }
  8082. void Commands::Command_DeclineResurrection(Client* client, Seperator* sep) {
  8083. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  8084. return;
  8085. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  8086. if(client->GetCurrentRez()->active)
  8087. client->GetCurrentRez()->should_delete = true;
  8088. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  8089. }
  8090. void Commands::Switch_AA_Profile(Client* client, Seperator* sep) {
  8091. PrintSep(sep, "Switch_AA_Profile");
  8092. if (sep && sep->IsSet(0)) {
  8093. string type = sep->arg[0];
  8094. int8 newtemplate = atoul(sep->arg[1]);
  8095. master_aa_list.DisplayAA(client, newtemplate, 1);
  8096. }
  8097. }
  8098. void Commands::Get_AA_Xml(Client* client, Seperator* sep) {
  8099. PrintSep(sep, "Get_AA_Xml");
  8100. if (sep && sep->IsSet(0)) {
  8101. string tabnum = sep->arg[0];
  8102. string spellid = sep->arg[1];
  8103. }
  8104. }
  8105. void Commands::Add_AA(Client* client, Seperator* sep) {
  8106. PrintSep(sep, "Add_AA");
  8107. if (sep && sep->IsSet(0)) {
  8108. int32 spell_id = atoul(sep->arg[1]);
  8109. int8 spell_tier = 0;
  8110. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  8111. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  8112. // addspellbookentry here
  8113. if (spell_tier >= data->maxRank) {
  8114. return;
  8115. }
  8116. if (!spell_tier) {
  8117. spell_tier = 1;
  8118. }
  8119. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  8120. {
  8121. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  8122. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  8123. client->GetPlayer()->UnlockSpell(spell);
  8124. client->SendSpellUpdate(spell);
  8125. }
  8126. else
  8127. {
  8128. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1 );
  8129. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  8130. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  8131. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  8132. client->GetPlayer()->UnlockSpell(spell);
  8133. client->SendSpellUpdate(spell);
  8134. }
  8135. // cast spell here
  8136. if (!spell_tier)
  8137. spell_tier = 1;
  8138. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  8139. if (spell) {
  8140. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  8141. }
  8142. }
  8143. else {
  8144. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  8145. }
  8146. master_aa_list.DisplayAA(client, 0, 0);
  8147. }
  8148. void Commands::Commit_AA_Profile(Client* client, Seperator* sep) {
  8149. PrintSep(sep, "Commit_AA_Profile");
  8150. if (sep && sep->IsSet(0)) {
  8151. }
  8152. }
  8153. void Commands::Begin_AA_Profile(Client* client, Seperator* sep) {
  8154. PrintSep(sep, "Begin_AA_Profile");
  8155. if (sep && sep->IsSet(0)) {
  8156. master_aa_list.DisplayAA(client, 100, 2);
  8157. }
  8158. }
  8159. void Commands::Back_AA(Client* client, Seperator* sep) {
  8160. if (sep && sep->IsSet(0)) {
  8161. PrintSep(sep, "Back_AA");
  8162. }
  8163. }
  8164. void Commands::Remove_AA(Client* client, Seperator* sep) {
  8165. if (sep && sep->IsSet(0)) {
  8166. PrintSep(sep, "Remove_AA");
  8167. }
  8168. }
  8169. void Commands::Cancel_AA_Profile(Client* client, Seperator* sep) {
  8170. MasterAAList master_aa_list;
  8171. PrintSep(sep, "Cancel_AA_Profile");
  8172. master_aa_list.DisplayAA(client, 0, 0);
  8173. }
  8174. void Commands::Save_AA_Profile(Client* client, Seperator* sep) {
  8175. if (sep && sep->IsSet(0)) {
  8176. PrintSep(sep, "Save_AA_Profile");
  8177. }
  8178. }
  8179. void Commands::Command_TargetItem(Client* client, Seperator* sep) {
  8180. if (!sep || sep->GetArgNumber() < 1 || !client->GetPlayer()) return;
  8181. if (!sep->IsNumber(0)) return;
  8182. int32 request_id = atoul(sep->arg[0]);
  8183. if (!sep->IsNumber(1)) return;
  8184. sint32 item_id = atoi(sep->arg[1]);
  8185. if (client->IsCurrentTransmuteID(request_id)) {
  8186. Transmute::HandleItemResponse(client, client->GetPlayer(), request_id, reinterpret_cast<int32&>(item_id));
  8187. }
  8188. else if (client->IsCurrentTransmuteID(item_id)) {
  8189. if (!sep->IsSet(2)) return;
  8190. if (sep->IsNumber(2) && atoi(sep->arg[2]) == 1) {
  8191. Transmute::HandleConfirmResponse(client, client->GetPlayer(), reinterpret_cast<int32&>(item_id));
  8192. }
  8193. }
  8194. }