Commands.cpp 438 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067
  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 <boost/algorithm/string/predicate.hpp>
  18. #include <boost/algorithm/string.hpp>
  19. #include "Commands.h"
  20. #include "../ClientPacketFunctions.h"
  21. #include "../../common/version.h"
  22. #include "../../common/seperator.h"
  23. #include "../../common/servertalk.h"
  24. #include "../WorldDatabase.h"
  25. #include "../World.h"
  26. #include "../../common/ConfigReader.h"
  27. #include "../VisualStates.h"
  28. #include "../../common/debug.h"
  29. #include "../LuaInterface.h"
  30. #include "../Quests.h"
  31. #include "../client.h"
  32. #include "../NPC.h"
  33. #include "../Guilds/Guild.h"
  34. #include "../SpellProcess.h"
  35. #include "../Tradeskills/Tradeskills.h"
  36. #include "../../common/Log.h"
  37. #include "../../common/MiscFunctions.h"
  38. #include "../Languages.h"
  39. #include "../Traits/Traits.h"
  40. #include "../Chat/Chat.h"
  41. #include "../Rules/Rules.h"
  42. #include "../AltAdvancement/AltAdvancement.h"
  43. #include "../RaceTypes/RaceTypes.h"
  44. #include "../classes.h"
  45. #include "../Transmute.h"
  46. #include "../Bots/Bot.h"
  47. extern WorldDatabase database;
  48. extern MasterSpellList master_spell_list;
  49. extern MasterTraitList master_trait_list;
  50. extern MasterRecipeList master_recipe_list;
  51. extern MasterRecipeBookList master_recipebook_list;
  52. extern World world;
  53. extern ClientList client_list;
  54. extern ConfigReader configReader;
  55. extern VisualStates visual_states;
  56. extern ZoneList zone_list;
  57. extern LuaInterface* lua_interface;
  58. extern MasterQuestList master_quest_list;
  59. extern MasterCollectionList master_collection_list;
  60. extern MasterSkillList master_skill_list;
  61. extern MasterFactionList master_faction_list;
  62. extern GuildList guild_list;
  63. extern MasterLanguagesList master_languages_list;
  64. extern Chat chat;
  65. extern RuleManager rule_manager;
  66. extern MasterAAList master_aa_list;
  67. extern MasterRaceTypeList race_types_list;
  68. extern Classes classes;
  69. //devn00b: Fix for linux builds since we dont use stricmp we use strcasecmp
  70. #if defined(__GNUC__)
  71. #define stricmp strcasecmp
  72. #define strnicmp strncasecmp
  73. #endif
  74. EQ2Packet* RemoteCommands::serialize(){
  75. buffer.clear();
  76. vector<EQ2_RemoteCommandString>::iterator command_list;
  77. buffer.append((char*)&num_commands, sizeof(int16));
  78. for( command_list = commands.begin(); command_list != commands.end(); command_list++ ) {
  79. AddDataCommand(&(*command_list));
  80. }
  81. EQ2Packet* app = new EQ2Packet(OP_SetRemoteCmdsMsg, (uchar*)buffer.c_str(), buffer.length() + 1);
  82. return app;
  83. }
  84. Commands::Commands(){
  85. remote_commands = new RemoteCommands();
  86. spawn_set_values["list"] = SPAWN_SET_VALUE_LIST;
  87. spawn_set_values["name"] = SPAWN_SET_VALUE_NAME;
  88. spawn_set_values["level"] = SPAWN_SET_VALUE_LEVEL; // TODO: Fix this, min_level, max_level
  89. spawn_set_values["difficulty"] = SPAWN_SET_VALUE_DIFFICULTY;
  90. spawn_set_values["model_type"] = SPAWN_SET_VALUE_MODEL_TYPE;
  91. spawn_set_values["class"] = SPAWN_SET_VALUE_CLASS;
  92. spawn_set_values["gender"] = SPAWN_SET_VALUE_GENDER;
  93. spawn_set_values["show_name"] = SPAWN_SET_VALUE_SHOW_NAME;
  94. spawn_set_values["attackable"] = SPAWN_SET_VALUE_ATTACKABLE;
  95. spawn_set_values["show_level"] = SPAWN_SET_VALUE_SHOW_LEVEL;
  96. spawn_set_values["targetable"] = SPAWN_SET_VALUE_TARGETABLE;
  97. spawn_set_values["show_command_icon"] = SPAWN_SET_VALUE_SHOW_COMMAND_ICON;
  98. spawn_set_values["display_hand_icon"] = SPAWN_SET_VALUE_HAND_ICON;
  99. spawn_set_values["hair_type"] = SPAWN_SET_VALUE_HAIR_TYPE;
  100. spawn_set_values["facial_hair_type"] = SPAWN_SET_VALUE_FACIAL_HAIR_TYPE;
  101. spawn_set_values["wing_type"] = SPAWN_SET_VALUE_WING_TYPE;
  102. spawn_set_values["chest_type"] = SPAWN_SET_VALUE_CHEST_TYPE;
  103. spawn_set_values["legs_type"] = SPAWN_SET_VALUE_LEGS_TYPE;
  104. spawn_set_values["soga_hair_type"] = SPAWN_SET_VALUE_SOGA_HAIR_TYPE;
  105. spawn_set_values["soga_facial_hair_type"] = SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE;
  106. spawn_set_values["soga_model_type"] = SPAWN_SET_VALUE_SOGA_MODEL_TYPE;
  107. spawn_set_values["size"] = SPAWN_SET_VALUE_SIZE;
  108. spawn_set_values["hp"] = SPAWN_SET_VALUE_HP;
  109. spawn_set_values["power"] = SPAWN_SET_VALUE_POWER;
  110. spawn_set_values["heroic"] = SPAWN_SET_VALUE_HEROIC;
  111. spawn_set_values["respawn"] = SPAWN_SET_VALUE_RESPAWN;
  112. spawn_set_values["x"] = SPAWN_SET_VALUE_X;
  113. spawn_set_values["y"] = SPAWN_SET_VALUE_Y;
  114. spawn_set_values["z"] = SPAWN_SET_VALUE_Z;
  115. spawn_set_values["heading"] = SPAWN_SET_VALUE_HEADING;
  116. spawn_set_values["location"] = SPAWN_SET_VALUE_LOCATION;
  117. spawn_set_values["command_primary"] = SPAWN_SET_VALUE_COMMAND_PRIMARY;
  118. spawn_set_values["command_secondary"] = SPAWN_SET_VALUE_COMMAND_SECONDARY;
  119. spawn_set_values["visual_state"] = SPAWN_SET_VALUE_VISUAL_STATE;
  120. spawn_set_values["action_state"] = SPAWN_SET_VALUE_ACTION_STATE;
  121. spawn_set_values["mood_state"] = SPAWN_SET_VALUE_MOOD_STATE;
  122. spawn_set_values["initial_state"] = SPAWN_SET_VALUE_INITIAL_STATE;
  123. spawn_set_values["activity_state"] = SPAWN_SET_VALUE_ACTIVITY_STATE;
  124. spawn_set_values["collision_radius"] = SPAWN_SET_VALUE_COLLISION_RADIUS;
  125. spawn_set_values["faction"] = SPAWN_SET_VALUE_FACTION;
  126. spawn_set_values["spawn_script"] = SPAWN_SET_VALUE_SPAWN_SCRIPT;
  127. spawn_set_values["spawnentry_script"] = SPAWN_SET_VALUE_SPAWNENTRY_SCRIPT;
  128. spawn_set_values["spawnlocation_script"] = SPAWN_SET_VALUE_SPAWNLOCATION_SCRIPT;
  129. spawn_set_values["sub_title"] = SPAWN_SET_VALUE_SUB_TITLE;
  130. spawn_set_values["expire"] = SPAWN_SET_VALUE_EXPIRE;
  131. spawn_set_values["expire_offset"] = SPAWN_SET_VALUE_EXPIRE_OFFSET;
  132. spawn_set_values["x_offset"] = SPAWN_SET_VALUE_X_OFFSET;
  133. spawn_set_values["y_offset"] = SPAWN_SET_VALUE_Y_OFFSET;
  134. spawn_set_values["z_offset"] = SPAWN_SET_VALUE_Z_OFFSET;
  135. spawn_set_values["device_id"] = SPAWN_SET_VALUE_DEVICE_ID;
  136. spawn_set_values["pitch"] = SPAWN_SET_VALUE_PITCH;
  137. spawn_set_values["roll"] = SPAWN_SET_VALUE_ROLL;
  138. spawn_set_values["hide_hood"] = SPAWN_SET_VALUE_HIDE_HOOD;
  139. spawn_set_values["emote_state"] = SPAWN_SET_VALUE_EMOTE_STATE;
  140. spawn_set_values["icon"] = SPAWN_SET_VALUE_ICON;
  141. spawn_set_values["prefix"] = SPAWN_SET_VALUE_PREFIX;
  142. spawn_set_values["suffix"] = SPAWN_SET_VALUE_SUFFIX;
  143. spawn_set_values["lastname"] = SPAWN_SET_VALUE_LASTNAME;
  144. spawn_set_values["expansion_flag"] = SPAWN_SET_VALUE_EXPANSION_FLAG;
  145. spawn_set_values["holiday_flag"] = SPAWN_SET_VALUE_HOLIDAY_FLAG;
  146. spawn_set_values["merchant_min_level"] = SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL;
  147. spawn_set_values["merchant_max_level"] = SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL;
  148. spawn_set_values["skin_color"] = SPAWN_SET_SKIN_COLOR;
  149. spawn_set_values["aaxp_rewards"] = SPAWN_SET_AAXP_REWARDS;
  150. spawn_set_values["hair_color1"] = SPAWN_SET_HAIR_COLOR1;
  151. spawn_set_values["hair_color2"] = SPAWN_SET_HAIR_COLOR2;
  152. spawn_set_values["hair_type_color"] = SPAWN_SET_HAIR_TYPE_COLOR;
  153. spawn_set_values["hair_face_color"] = SPAWN_SET_HAIR_FACE_COLOR;
  154. spawn_set_values["hair_type_highlight_color"] = SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR;
  155. spawn_set_values["face_hairlight_color"] = SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR;
  156. spawn_set_values["hair_highlight"] = SPAWN_SET_HAIR_HIGHLIGHT;
  157. spawn_set_values["model_color"] = SPAWN_SET_MODEL_COLOR;
  158. spawn_set_values["eye_color"] = SPAWN_SET_EYE_COLOR;
  159. spawn_set_values["soga_skin_color"] = SPAWN_SET_SOGA_SKIN_COLOR;
  160. spawn_set_values["soga_hair_color1"] = SPAWN_SET_SOGA_HAIR_COLOR1;
  161. spawn_set_values["soga_hair_color2"] = SPAWN_SET_SOGA_HAIR_COLOR2;
  162. spawn_set_values["soga_hair_type_color"] = SPAWN_SET_SOGA_HAIR_TYPE_COLOR;
  163. spawn_set_values["soga_hair_face_color"] = SPAWN_SET_SOGA_HAIR_FACE_COLOR;
  164. spawn_set_values["soga_hair_type_highlight_color"] = SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR;
  165. spawn_set_values["soga_face_hairlight_color"] = SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR;
  166. spawn_set_values["soga_hair_highlight"] = SPAWN_SET_SOGA_HAIR_HIGHLIGHT;
  167. spawn_set_values["soga_model_color"] = SPAWN_SET_SOGA_MODEL_COLOR;
  168. spawn_set_values["soga_eye_color"] = SPAWN_SET_SOGA_EYE_COLOR;
  169. spawn_set_values["cheek_type"] = SPAWN_SET_CHEEK_TYPE;
  170. spawn_set_values["chin_type"] = SPAWN_SET_CHIN_TYPE;
  171. spawn_set_values["ear_type"] = SPAWN_SET_EAR_TYPE;
  172. spawn_set_values["eye_brow_type"] = SPAWN_SET_EYE_BROW_TYPE;
  173. spawn_set_values["eye_type"] = SPAWN_SET_EYE_TYPE;
  174. spawn_set_values["lip_type"] = SPAWN_SET_LIP_TYPE;
  175. spawn_set_values["nose_type"] = SPAWN_SET_NOSE_TYPE;
  176. spawn_set_values["body_size"] = SPAWN_SET_BODY_SIZE;
  177. spawn_set_values["body_age"] = SPAWN_SET_BODY_AGE;
  178. spawn_set_values["soga_cheek_type"] = SPAWN_SET_SOGA_CHEEK_TYPE;
  179. spawn_set_values["soga_chin_type"] = SPAWN_SET_SOGA_CHIN_TYPE;
  180. spawn_set_values["soga_ear_type"] = SPAWN_SET_SOGA_EAR_TYPE;
  181. spawn_set_values["soga_eye_brow_type"] = SPAWN_SET_SOGA_EYE_BROW_TYPE;
  182. spawn_set_values["soga_eye_type"] = SPAWN_SET_SOGA_EYE_TYPE;
  183. spawn_set_values["soga_lip_type"] = SPAWN_SET_SOGA_LIP_TYPE;
  184. spawn_set_values["soga_nose_type"] = SPAWN_SET_SOGA_NOSE_TYPE;
  185. spawn_set_values["soga_body_size"] = SPAWN_SET_SOGA_BODY_SIZE;
  186. spawn_set_values["soga_body_age"] = SPAWN_SET_SOGA_BODY_AGE;
  187. spawn_set_values["attack_type"] = SPAWN_SET_ATTACK_TYPE;
  188. spawn_set_values["race_type"] = SPAWN_SET_RACE_TYPE;
  189. spawn_set_values["loot_tier"] = SPAWN_SET_LOOT_TIER;
  190. spawn_set_values["loot_drop_type"] = SPAWN_SET_LOOT_DROP_TYPE;
  191. spawn_set_values["scared_strong_players"] = SPAWN_SET_SCARED_STRONG_PLAYERS;
  192. zone_set_values["expansion_id"] = ZONE_SET_VALUE_EXPANSION_ID;
  193. zone_set_values["name"] = ZONE_SET_VALUE_NAME;
  194. zone_set_values["file"] = ZONE_SET_VALUE_FILE ;
  195. zone_set_values["description"] = ZONE_SET_VALUE_DESCRIPTION;
  196. zone_set_values["safe_x"] = ZONE_SET_VALUE_SAFE_X;
  197. zone_set_values["safe_y"] = ZONE_SET_VALUE_SAFE_Y;
  198. zone_set_values["safe_z"] = ZONE_SET_VALUE_SAFE_Z;
  199. zone_set_values["underworld"] = ZONE_SET_VALUE_UNDERWORLD;
  200. zone_set_values["min_recommended"] = ZONE_SET_VALUE_MIN_RECOMMENDED;
  201. zone_set_values["max_recommended"] = ZONE_SET_VALUE_MAX_RECOMMENDED;
  202. zone_set_values["zone_type"] = ZONE_SET_VALUE_ZONE_TYPE;
  203. zone_set_values["always_loaded"] = ZONE_SET_VALUE_ALWAYS_LOADED;
  204. zone_set_values["city_zone"] = ZONE_SET_VALUE_CITY_ZONE;
  205. zone_set_values["weather_allowed"] = ZONE_SET_VALUE_WEATHER_ALLOWED;
  206. zone_set_values["min_status"] = ZONE_SET_VALUE_MIN_STATUS;
  207. zone_set_values["min_level"] = ZONE_SET_VALUE_MIN_LEVEL;
  208. zone_set_values["start_zone"] = ZONE_SET_VALUE_START_ZONE;
  209. zone_set_values["instance_type"] = ZONE_SET_VALUE_INSTANCE_TYPE;
  210. zone_set_values["default_reenter_time"] = ZONE_SET_VALUE_DEFAULT_REENTER_TIME;
  211. zone_set_values["default_reset_time"] = ZONE_SET_VALUE_DEFAULT_RESET_TIME;
  212. zone_set_values["default_lockout_time"] = ZONE_SET_VALUE_DEFAULT_LOCKOUT_TIME;
  213. zone_set_values["force_group_to_zone"] = ZONE_SET_VALUE_FORCE_GROUP_TO_ZONE;
  214. zone_set_values["lua_script"] = ZONE_SET_VALUE_LUA_SCRIPT;
  215. zone_set_values["shutdown_timer"] = ZONE_SET_VALUE_SHUTDOWN_TIMER;
  216. zone_set_values["zone_motd"] = ZONE_SET_VALUE_ZONE_MOTD;
  217. }
  218. Commands::~Commands() {
  219. safe_delete(remote_commands);
  220. }
  221. int32 Commands::GetSpawnSetType(string val){
  222. if(spawn_set_values.count(val) > 0)
  223. return spawn_set_values[val];
  224. return 0xFFFFFFFF;
  225. }
  226. bool Commands::SetSpawnCommand(Client* client, Spawn* target, int8 type, const char* value, bool send_update, bool temporary, string* temp_value, int8 index){
  227. if(!target)
  228. return false;
  229. int32 val = 0;
  230. try{
  231. if(type != SPAWN_SET_VALUE_NAME &&
  232. !(type >= SPAWN_SET_VALUE_SPAWN_SCRIPT && type <= SPAWN_SET_VALUE_SUB_TITLE) && !(type >= SPAWN_SET_VALUE_PREFIX && type <= SPAWN_SET_VALUE_EXPANSION_FLAG || type == SPAWN_SET_VALUE_HOLIDAY_FLAG))
  233. {
  234. switch(type)
  235. {
  236. case SPAWN_SET_SKIN_COLOR:
  237. case SPAWN_SET_HAIR_COLOR1:
  238. case SPAWN_SET_HAIR_COLOR2:
  239. case SPAWN_SET_HAIR_TYPE_COLOR:
  240. case SPAWN_SET_HAIR_FACE_COLOR:
  241. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  242. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  243. case SPAWN_SET_HAIR_HIGHLIGHT:
  244. case SPAWN_SET_EYE_COLOR:
  245. case SPAWN_SET_SOGA_SKIN_COLOR:
  246. case SPAWN_SET_SOGA_HAIR_COLOR1:
  247. case SPAWN_SET_SOGA_HAIR_COLOR2:
  248. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  249. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  250. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  251. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  252. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  253. case SPAWN_SET_SOGA_EYE_COLOR:
  254. case SPAWN_SET_RACE_TYPE:
  255. // ignore these are colors can't pass as a integer value
  256. break;
  257. default:
  258. val = atoul(value);
  259. }
  260. }
  261. }
  262. catch(...){
  263. if(client)
  264. client->Message(CHANNEL_COLOR_RED, "Invalid numeric spawn value: %s", value);
  265. return false;
  266. }
  267. if(temporary){
  268. char tmp[128] = {0};
  269. switch(type){
  270. case SPAWN_SET_VALUE_NAME:{
  271. sprintf(tmp, "%s", target->GetName());
  272. target->SetName(value);
  273. if(target->GetZone())
  274. target->GetZone()->SendUpdateTitles(target);
  275. break;
  276. }
  277. case SPAWN_SET_VALUE_X_OFFSET:
  278. {
  279. sprintf(tmp, "%f", target->GetXOffset());
  280. target->SetXOffset(float(val));
  281. break;
  282. }
  283. case SPAWN_SET_VALUE_Y_OFFSET:
  284. {
  285. sprintf(tmp, "%f", target->GetYOffset());
  286. target->SetYOffset(float(val));
  287. break;
  288. }
  289. case SPAWN_SET_VALUE_Z_OFFSET:
  290. {
  291. sprintf(tmp, "%f", target->GetZOffset());
  292. target->SetZOffset(float(val));
  293. break;
  294. }
  295. case SPAWN_SET_VALUE_EXPIRE: {
  296. sprintf(tmp, "%u", target->GetExpireTime());
  297. target->SetExpireTime(val);
  298. break;
  299. }
  300. case SPAWN_SET_VALUE_EXPIRE_OFFSET: {
  301. sprintf(tmp, "%u", target->GetExpireOffsetTime());
  302. target->SetExpireOffsetTime(val);
  303. break;
  304. }
  305. case SPAWN_SET_VALUE_SUB_TITLE: {
  306. sprintf(tmp, "%s", target->GetSubTitle());
  307. target->SetSubTitle(value);
  308. if(target->GetZone())
  309. target->GetZone()->SendUpdateTitles(target);
  310. break;
  311. }
  312. case SPAWN_SET_VALUE_LEVEL:{
  313. sprintf(tmp, "%i", target->GetLevel());
  314. target->SetLevel(val, send_update);
  315. break;
  316. }
  317. case SPAWN_SET_VALUE_DIFFICULTY:{
  318. sprintf(tmp, "%i", target->GetDifficulty());
  319. target->SetDifficulty(val, send_update);
  320. break;
  321. }
  322. case SPAWN_SET_VALUE_MODEL_TYPE:{
  323. sprintf(tmp, "%i", target->GetModelType());
  324. target->SetModelType(val, send_update);
  325. break;
  326. }
  327. case SPAWN_SET_VALUE_CLASS:{
  328. sprintf(tmp, "%i", target->GetAdventureClass());
  329. target->SetAdventureClass(val, send_update);
  330. break;
  331. }
  332. case SPAWN_SET_VALUE_GENDER:{
  333. sprintf(tmp, "%i", target->GetGender());
  334. target->SetGender(val, send_update);
  335. break;
  336. }
  337. case SPAWN_SET_VALUE_SHOW_NAME:{
  338. sprintf(tmp, "%i", target->GetShowName());
  339. target->SetShowName(val, send_update);
  340. break;
  341. }
  342. case SPAWN_SET_VALUE_ATTACKABLE:{
  343. sprintf(tmp, "%i", target->GetAttackable());
  344. target->SetAttackable(val, send_update);
  345. break;
  346. }
  347. case SPAWN_SET_VALUE_SHOW_LEVEL:{
  348. sprintf(tmp, "%i", target->GetShowLevel());
  349. target->SetShowLevel(val, send_update);
  350. break;
  351. }
  352. case SPAWN_SET_VALUE_TARGETABLE:{
  353. sprintf(tmp, "%i", target->GetTargetable());
  354. target->SetTargetable(val, send_update);
  355. break;
  356. }
  357. case SPAWN_SET_VALUE_SHOW_COMMAND_ICON:{
  358. sprintf(tmp, "%i", target->GetShowCommandIcon());
  359. target->SetShowCommandIcon(val, send_update);
  360. break;
  361. }
  362. case SPAWN_SET_VALUE_HAND_ICON:{
  363. sprintf(tmp, "%i", target->GetShowHandIcon());
  364. target->SetShowHandIcon(val, send_update);
  365. break;
  366. }
  367. case SPAWN_SET_VALUE_HAIR_TYPE:{
  368. if(target->IsEntity()){
  369. sprintf(tmp, "%i", ((Entity*)target)->GetHairType());
  370. ((Entity*)target)->SetHairType(val, send_update);
  371. }
  372. break;
  373. }
  374. case SPAWN_SET_VALUE_FACIAL_HAIR_TYPE:{
  375. if(target->IsEntity()){
  376. sprintf(tmp, "%i", ((Entity*)target)->GetFacialHairType());
  377. ((Entity*)target)->SetFacialHairType(val, send_update);
  378. }
  379. break;
  380. }
  381. case SPAWN_SET_VALUE_WING_TYPE:{
  382. if(target->IsEntity()){
  383. sprintf(tmp, "%i", ((Entity*)target)->GetWingType());
  384. ((Entity*)target)->SetWingType(val, send_update);
  385. }
  386. break;
  387. }
  388. case SPAWN_SET_VALUE_CHEST_TYPE:{
  389. if(target->IsEntity()){
  390. sprintf(tmp, "%i", ((Entity*)target)->GetChestType());
  391. ((Entity*)target)->SetChestType(val, send_update);
  392. }
  393. break;
  394. }
  395. case SPAWN_SET_VALUE_LEGS_TYPE:{
  396. if(target->IsEntity()){
  397. sprintf(tmp, "%i", ((Entity*)target)->GetLegsType());
  398. ((Entity*)target)->SetLegsType(val, send_update);
  399. }
  400. break;
  401. }
  402. case SPAWN_SET_VALUE_SOGA_HAIR_TYPE:{
  403. if(target->IsEntity()){
  404. sprintf(tmp, "%i", ((Entity*)target)->GetSogaHairType());
  405. ((Entity*)target)->SetSogaHairType(val, send_update);
  406. }
  407. break;
  408. }
  409. case SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE:{
  410. if(target->IsEntity()){
  411. sprintf(tmp, "%i", ((Entity*)target)->GetSogaFacialHairType());
  412. ((Entity*)target)->SetSogaFacialHairType(val, send_update);
  413. }
  414. break;
  415. }
  416. case SPAWN_SET_VALUE_SOGA_MODEL_TYPE:{
  417. sprintf(tmp, "%i", target->GetSogaModelType());
  418. target->SetSogaModelType(val, send_update);
  419. break;
  420. }
  421. case SPAWN_SET_VALUE_SIZE:{
  422. sprintf(tmp, "%i", target->GetSize());
  423. target->SetSize(val, send_update);
  424. break;
  425. }
  426. case SPAWN_SET_VALUE_HP:{
  427. sprintf(tmp, "%i", target->GetHP());
  428. target->SetHP(val, send_update);
  429. break;
  430. }
  431. case SPAWN_SET_VALUE_POWER:{
  432. sprintf(tmp, "%i", target->GetPower());
  433. target->SetPower(val, send_update);
  434. break;
  435. }
  436. case SPAWN_SET_VALUE_HEROIC:{
  437. sprintf(tmp, "%i", target->GetHeroic());
  438. target->SetHeroic(val, send_update);
  439. break;
  440. }
  441. case SPAWN_SET_VALUE_RESPAWN:{
  442. sprintf(tmp, "%u", target->GetRespawnTime());
  443. target->SetRespawnTime(val);
  444. break;
  445. }
  446. case SPAWN_SET_VALUE_X:{
  447. sprintf(tmp, "%f", target->GetX());
  448. target->SetX(atof(value), send_update);
  449. break;
  450. }
  451. case SPAWN_SET_VALUE_Y:{
  452. sprintf(tmp, "%f", target->GetY());
  453. target->SetY(atof(value), send_update);
  454. break;
  455. }
  456. case SPAWN_SET_VALUE_Z:{
  457. sprintf(tmp, "%f", target->GetZ());
  458. target->SetZ(atof(value), send_update);
  459. break;
  460. }
  461. case SPAWN_SET_VALUE_HEADING:{
  462. sprintf(tmp, "%f", target->GetHeading());
  463. target->SetHeading(atof(value) + 360, send_update);
  464. break;
  465. }
  466. case SPAWN_SET_VALUE_VISUAL_STATE:{
  467. sprintf(tmp, "%i", target->GetVisualState());
  468. target->SetVisualState(val, send_update);
  469. break;
  470. }
  471. case SPAWN_SET_VALUE_ACTION_STATE:{
  472. sprintf(tmp, "%i", target->GetActionState());
  473. target->SetActionState(val, send_update);
  474. break;
  475. }
  476. case SPAWN_SET_VALUE_MOOD_STATE:{
  477. sprintf(tmp, "%i", target->GetMoodState());
  478. target->SetMoodState(val, send_update);
  479. break;
  480. }
  481. case SPAWN_SET_VALUE_INITIAL_STATE:{
  482. sprintf(tmp, "%i", target->GetInitialState());
  483. target->SetInitialState(val, send_update);
  484. break;
  485. }
  486. case SPAWN_SET_VALUE_ACTIVITY_STATE:{
  487. sprintf(tmp, "%i", target->GetActivityStatus());
  488. target->SetActivityStatus(val, send_update);
  489. break;
  490. }
  491. case SPAWN_SET_VALUE_COLLISION_RADIUS:{
  492. sprintf(tmp, "%i", target->GetCollisionRadius());
  493. target->SetCollisionRadius(val, send_update);
  494. break;
  495. }
  496. case SPAWN_SET_VALUE_DEVICE_ID: {
  497. if (target->IsObject()) {
  498. sprintf(tmp, "%i", ((Object*)target)->GetDeviceID());
  499. ((Object*)target)->SetDeviceID(val);
  500. }
  501. break;
  502. }
  503. case SPAWN_SET_VALUE_PITCH: {
  504. sprintf(tmp, "%f", target->GetPitch());
  505. target->SetPitch(atof(value), send_update);
  506. break;
  507. }
  508. case SPAWN_SET_VALUE_ROLL: {
  509. sprintf(tmp, "%f", target->GetRoll());
  510. target->SetRoll(atof(value), send_update);
  511. break;
  512. }
  513. case SPAWN_SET_VALUE_HIDE_HOOD: {
  514. sprintf(tmp, "%i", target->appearance.hide_hood);
  515. target->SetHideHood(val);
  516. break;
  517. }
  518. case SPAWN_SET_VALUE_EMOTE_STATE: {
  519. sprintf(tmp, "%i", target->appearance.emote_state);
  520. target->SetEmoteState(val);
  521. break;
  522. }
  523. case SPAWN_SET_VALUE_ICON: {
  524. sprintf(tmp, "%i", target->GetIconValue());
  525. target->SetIcon(val);
  526. break;
  527. }
  528. case SPAWN_SET_VALUE_PREFIX: {
  529. sprintf(tmp, "%s", target->GetPrefixTitle());
  530. target->SetPrefixTitle(value);
  531. if(target->GetZone())
  532. target->GetZone()->SendUpdateTitles(target);
  533. break;
  534. }
  535. case SPAWN_SET_VALUE_SUFFIX: {
  536. sprintf(tmp, "%s", target->GetSuffixTitle());
  537. target->SetSuffixTitle(value);
  538. if(target->GetZone())
  539. target->GetZone()->SendUpdateTitles(target);
  540. break;
  541. }
  542. case SPAWN_SET_VALUE_LASTNAME: {
  543. sprintf(tmp, "%s", target->GetLastName());
  544. target->SetLastName(value);
  545. if(target->GetZone())
  546. target->GetZone()->SendUpdateTitles(target);
  547. break;
  548. }
  549. case SPAWN_SET_VALUE_EXPANSION_FLAG:
  550. case SPAWN_SET_VALUE_HOLIDAY_FLAG: {
  551. // nothing to do must reload spawns
  552. break;
  553. }
  554. case SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL: {
  555. sprintf(tmp, "%i", target->GetMerchantMinLevel());
  556. target->SetMerchantLevelRange(atoul(value), target->GetMerchantMaxLevel());
  557. break;
  558. }
  559. case SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL: {
  560. sprintf(tmp, "%i", target->GetMerchantMaxLevel());
  561. target->SetMerchantLevelRange(target->GetMerchantMinLevel(), atoul(value));
  562. break;
  563. }
  564. case SPAWN_SET_VALUE_FACTION:{
  565. sprintf(tmp, "%i", target->faction_id);
  566. ZoneServer* zone = target->GetZone();
  567. if (!zone && client)
  568. zone = client->GetCurrentZone();
  569. target->faction_id = atoul(value);
  570. if(zone)
  571. {
  572. zone->RemoveDeadEnemyList(target);
  573. if(target->IsNPC())
  574. zone->AddEnemyList((NPC*)target);
  575. }
  576. break;
  577. }
  578. case SPAWN_SET_SKIN_COLOR:
  579. case SPAWN_SET_HAIR_COLOR1:
  580. case SPAWN_SET_HAIR_COLOR2:
  581. case SPAWN_SET_HAIR_TYPE_COLOR:
  582. case SPAWN_SET_HAIR_FACE_COLOR:
  583. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  584. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  585. case SPAWN_SET_HAIR_HIGHLIGHT:
  586. case SPAWN_SET_MODEL_COLOR:
  587. case SPAWN_SET_EYE_COLOR:
  588. case SPAWN_SET_SOGA_SKIN_COLOR:
  589. case SPAWN_SET_SOGA_HAIR_COLOR1:
  590. case SPAWN_SET_SOGA_HAIR_COLOR2:
  591. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  592. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  593. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  594. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  595. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  596. case SPAWN_SET_SOGA_MODEL_COLOR:
  597. case SPAWN_SET_SOGA_EYE_COLOR:
  598. {
  599. if (target->IsEntity())
  600. {
  601. Seperator* skinsep = new Seperator(value, ' ', 3, 500, true);
  602. if (skinsep->IsNumber(0) && skinsep->IsNumber(1) && skinsep->IsNumber(2))
  603. {
  604. EQ2_Color clr;
  605. clr.red = atoul(skinsep->arg[0]);
  606. clr.green = atoul(skinsep->arg[1]);
  607. clr.blue = atoul(skinsep->arg[2]);
  608. switch(type)
  609. {
  610. case SPAWN_SET_SKIN_COLOR:
  611. ((Entity*)target)->SetSkinColor(clr);
  612. break;
  613. case SPAWN_SET_HAIR_COLOR1:
  614. ((Entity*)target)->SetHairColor1(clr);
  615. break;
  616. case SPAWN_SET_HAIR_COLOR2:
  617. ((Entity*)target)->SetHairColor2(clr);
  618. break;
  619. case SPAWN_SET_HAIR_TYPE_COLOR:
  620. ((Entity*)target)->SetHairColor(clr);
  621. break;
  622. case SPAWN_SET_HAIR_FACE_COLOR:
  623. ((Entity*)target)->SetFacialHairColor(clr);
  624. break;
  625. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  626. ((Entity*)target)->SetHairTypeHighlightColor(clr);
  627. break;
  628. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  629. ((Entity*)target)->SetFacialHairHighlightColor(clr);
  630. break;
  631. case SPAWN_SET_HAIR_HIGHLIGHT:
  632. ((Entity*)target)->SetHairHighlightColor(clr);
  633. break;
  634. case SPAWN_SET_MODEL_COLOR:
  635. ((Entity*)target)->SetModelColor(clr);
  636. break;
  637. case SPAWN_SET_EYE_COLOR:
  638. ((Entity*)target)->SetEyeColor(clr);
  639. break;
  640. case SPAWN_SET_SOGA_SKIN_COLOR:
  641. ((Entity*)target)->SetSogaSkinColor(clr);
  642. break;
  643. case SPAWN_SET_SOGA_HAIR_COLOR1:
  644. ((Entity*)target)->SetSogaHairColor1(clr);
  645. break;
  646. case SPAWN_SET_SOGA_HAIR_COLOR2:
  647. ((Entity*)target)->SetSogaHairColor2(clr);
  648. break;
  649. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  650. ((Entity*)target)->SetSogaHairColor(clr);
  651. break;
  652. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  653. ((Entity*)target)->SetSogaFacialHairColor(clr);
  654. break;
  655. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  656. ((Entity*)target)->SetSogaHairTypeHighlightColor(clr);
  657. break;
  658. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  659. ((Entity*)target)->SetSogaFacialHairHighlightColor(clr);
  660. break;
  661. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  662. ((Entity*)target)->SetSogaHairHighlightColor(clr);
  663. break;
  664. case SPAWN_SET_SOGA_MODEL_COLOR:
  665. ((Entity*)target)->SetSogaModelColor(clr);
  666. break;
  667. case SPAWN_SET_SOGA_EYE_COLOR:
  668. ((Entity*)target)->SetSogaEyeColor(clr);
  669. break;
  670. }
  671. }
  672. safe_delete(skinsep);
  673. }
  674. break;
  675. }
  676. case SPAWN_SET_AAXP_REWARDS: {
  677. target->SetAAXPRewards(atoul(value));
  678. break;
  679. }
  680. case SPAWN_SET_CHEEK_TYPE:{
  681. if(target->IsEntity() && index < 3){
  682. sprintf(tmp, "%i", ((Entity*)target)->features.cheek_type[index]);
  683. sint8 new_value = atoi(value);
  684. ((Entity*)target)->features.cheek_type[index] = new_value;
  685. ((Entity*)target)->info_changed = true;
  686. }
  687. break;
  688. }
  689. case SPAWN_SET_CHIN_TYPE:{
  690. if(target->IsEntity() && index < 3){
  691. sprintf(tmp, "%i", ((Entity*)target)->features.chin_type[index]);
  692. sint8 new_value = atoi(value);
  693. ((Entity*)target)->features.chin_type[index] = new_value;
  694. ((Entity*)target)->info_changed = true;
  695. }
  696. break;
  697. }
  698. case SPAWN_SET_EAR_TYPE:{
  699. if(target->IsEntity() && index < 3){
  700. sprintf(tmp, "%i", ((Entity*)target)->features.ear_type[index]);
  701. sint8 new_value = atoi(value);
  702. ((Entity*)target)->features.ear_type[index] = new_value;
  703. ((Entity*)target)->info_changed = true;
  704. }
  705. break;
  706. }
  707. case SPAWN_SET_EYE_BROW_TYPE:{
  708. if(target->IsEntity() && index < 3){
  709. sprintf(tmp, "%i", ((Entity*)target)->features.eye_brow_type[index]);
  710. sint8 new_value = atoi(value);
  711. ((Entity*)target)->features.eye_brow_type[index] = new_value;
  712. ((Entity*)target)->info_changed = true;
  713. }
  714. break;
  715. }
  716. case SPAWN_SET_EYE_TYPE:{
  717. if(target->IsEntity() && index < 3){
  718. sprintf(tmp, "%i", ((Entity*)target)->features.eye_type[index]);
  719. sint8 new_value = atoi(value);
  720. ((Entity*)target)->features.eye_type[index] = new_value;
  721. ((Entity*)target)->info_changed = true;
  722. }
  723. break;
  724. }
  725. case SPAWN_SET_LIP_TYPE:{
  726. if(target->IsEntity() && index < 3){
  727. sprintf(tmp, "%i", ((Entity*)target)->features.lip_type[index]);
  728. sint8 new_value = atoi(value);
  729. ((Entity*)target)->features.lip_type[index] = new_value;
  730. ((Entity*)target)->info_changed = true;
  731. }
  732. break;
  733. }
  734. case SPAWN_SET_NOSE_TYPE:{
  735. if(target->IsEntity() && index < 3){
  736. sprintf(tmp, "%i", ((Entity*)target)->features.nose_type[index]);
  737. sint8 new_value = atoi(value);
  738. ((Entity*)target)->features.nose_type[index] = new_value;
  739. ((Entity*)target)->info_changed = true;
  740. }
  741. break;
  742. }
  743. case SPAWN_SET_BODY_SIZE:{
  744. if(target->IsEntity()){
  745. sprintf(tmp, "%i", ((Entity*)target)->features.body_size);
  746. int8 new_value = atoul(value);
  747. ((Entity*)target)->features.body_size = new_value;
  748. ((Entity*)target)->info_changed = true;
  749. }
  750. break;
  751. }
  752. case SPAWN_SET_BODY_AGE:{
  753. if(target->IsEntity()){
  754. sprintf(tmp, "%i", ((Entity*)target)->features.body_age);
  755. int8 new_value = atoul(value);
  756. ((Entity*)target)->features.body_age = new_value;
  757. ((Entity*)target)->info_changed = true;
  758. }
  759. break;
  760. }
  761. case SPAWN_SET_SOGA_CHEEK_TYPE:{
  762. if(target->IsEntity() && index < 3){
  763. sprintf(tmp, "%i", ((Entity*)target)->features.soga_cheek_type[index]);
  764. sint8 new_value = atoi(value);
  765. ((Entity*)target)->features.soga_cheek_type[index] = new_value;
  766. ((Entity*)target)->info_changed = true;
  767. }
  768. break;
  769. }
  770. case SPAWN_SET_SOGA_CHIN_TYPE:{
  771. if(target->IsEntity() && index < 3){
  772. sprintf(tmp, "%i", ((Entity*)target)->features.soga_chin_type[index]);
  773. sint8 new_value = atoi(value);
  774. ((Entity*)target)->features.soga_chin_type[index] = new_value;
  775. ((Entity*)target)->info_changed = true;
  776. }
  777. break;
  778. }
  779. case SPAWN_SET_SOGA_EAR_TYPE:{
  780. if(target->IsEntity() && index < 3){
  781. sprintf(tmp, "%i", ((Entity*)target)->features.soga_ear_type[index]);
  782. sint8 new_value = atoi(value);
  783. ((Entity*)target)->features.soga_ear_type[index] = new_value;
  784. ((Entity*)target)->info_changed = true;
  785. }
  786. break;
  787. }
  788. case SPAWN_SET_SOGA_EYE_BROW_TYPE:{
  789. if(target->IsEntity() && index < 3){
  790. sprintf(tmp, "%i", ((Entity*)target)->features.soga_eye_brow_type[index]);
  791. sint8 new_value = atoi(value);
  792. ((Entity*)target)->features.soga_eye_brow_type[index] = new_value;
  793. ((Entity*)target)->info_changed = true;
  794. }
  795. break;
  796. }
  797. case SPAWN_SET_SOGA_EYE_TYPE:{
  798. if(target->IsEntity() && index < 3){
  799. sprintf(tmp, "%i", ((Entity*)target)->features.soga_eye_type[index]);
  800. sint8 new_value = atoi(value);
  801. ((Entity*)target)->features.soga_eye_type[index] = new_value;
  802. ((Entity*)target)->info_changed = true;
  803. }
  804. break;
  805. }
  806. case SPAWN_SET_SOGA_LIP_TYPE:{
  807. if(target->IsEntity() && index < 3){
  808. sprintf(tmp, "%i", ((Entity*)target)->features.soga_lip_type[index]);
  809. sint8 new_value = atoi(value);
  810. ((Entity*)target)->features.soga_lip_type[index] = new_value;
  811. ((Entity*)target)->info_changed = true;
  812. }
  813. break;
  814. }
  815. case SPAWN_SET_SOGA_BODY_SIZE:{
  816. if(target->IsEntity()){
  817. sprintf(tmp, "%i", ((Entity*)target)->features.soga_body_size);
  818. int8 new_value = atoul(value);
  819. ((Entity*)target)->features.soga_body_size = new_value;
  820. ((Entity*)target)->info_changed = true;
  821. }
  822. break;
  823. }
  824. case SPAWN_SET_SOGA_BODY_AGE:{
  825. if(target->IsEntity()){
  826. sprintf(tmp, "%i", ((Entity*)target)->features.soga_body_age);
  827. int8 new_value = atoul(value);
  828. ((Entity*)target)->features.soga_body_age = new_value;
  829. ((Entity*)target)->info_changed = true;
  830. }
  831. break;
  832. }
  833. case SPAWN_SET_ATTACK_TYPE:{
  834. if(target->IsEntity()){
  835. sprintf(tmp, "%u", ((Entity*)target)->GetInfoStruct()->get_attack_type());
  836. int8 new_value = atoul(value);
  837. ((Entity*)target)->GetInfoStruct()->set_attack_type(new_value);
  838. }
  839. break;
  840. }
  841. case SPAWN_SET_RACE_TYPE:{
  842. if(target->GetModelType() > 0){
  843. Seperator* tmpsep = new Seperator(value, ' ', 3, 500, true);
  844. if (tmpsep->IsNumber(0))
  845. {
  846. int16 race_type = atoul(value);
  847. const char* category = tmpsep->IsSet(1) ? tmpsep->arg[1] : "NULL";
  848. const char* subcategory = tmpsep->IsSet(2) ? tmpsep->arg[2] : "NULL";
  849. const char* model_name = tmpsep->IsSet(3) ? tmpsep->arg[3] : "NULL";
  850. if(race_types_list.AddRaceType(target->GetModelType(), race_type, category, subcategory, model_name)) {
  851. if(client) {
  852. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Race type added to memory, however not saved to database.");
  853. }
  854. }
  855. else {
  856. client->SimpleMessage(CHANNEL_COLOR_RED, "Model type already on the race_types_list, use spawn set database to override and update database.");
  857. }
  858. }
  859. safe_delete(tmpsep);
  860. }
  861. break;
  862. }
  863. case SPAWN_SET_LOOT_TIER:{
  864. if(target->IsEntity()){
  865. sprintf(tmp, "%u", target->GetLootTier());
  866. int32 new_value = atoul(value);
  867. target->SetLootTier(new_value);
  868. }
  869. break;
  870. }
  871. case SPAWN_SET_LOOT_DROP_TYPE:{
  872. if(target->IsEntity()){
  873. sprintf(tmp, "%u", target->GetLootDropType());
  874. int32 new_value = atoul(value);
  875. target->SetLootDropType(new_value);
  876. }
  877. break;
  878. }
  879. case SPAWN_SET_SCARED_STRONG_PLAYERS:{
  880. if(target->IsNPC()){
  881. sprintf(tmp, "%u", target->IsScaredByStrongPlayers());
  882. int32 new_value = atoul(value);
  883. target->SetScaredByStrongPlayers(new_value);
  884. }
  885. break;
  886. }
  887. if(temp_value)
  888. *temp_value = string(tmp);
  889. }
  890. }
  891. else{
  892. /**** NOT TEMPORARY ELSE STATEMENT ****/
  893. /**** MUST RE-DEFINE WHAT IS ALREADY IN THE IF TEMPORARY BLOCK HERE ****/
  894. switch(type){
  895. case SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL: {
  896. target->SetMerchantLevelRange(atoul(value), target->GetMerchantMaxLevel());
  897. break;
  898. }
  899. case SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL: {
  900. target->SetMerchantLevelRange(target->GetMerchantMinLevel(), atoul(value));
  901. break;
  902. }
  903. case SPAWN_SET_VALUE_EXPANSION_FLAG: {
  904. if (target->GetDatabaseID() > 0)
  905. {
  906. char query[256];
  907. snprintf(query, 256, "update spawn set expansion_flag=%u where id=%u", atoul(value), target->GetDatabaseID());
  908. if (database.RunQuery(query, strnlen(query, 256)))
  909. {
  910. if(client)
  911. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  912. }
  913. }
  914. break;
  915. }
  916. case SPAWN_SET_VALUE_HOLIDAY_FLAG: {
  917. if (target->GetDatabaseID() > 0)
  918. {
  919. char query[256];
  920. snprintf(query, 256, "update spawn set holiday_flag=%u where id=%u", atoul(value), target->GetDatabaseID());
  921. if (database.RunQuery(query, strnlen(query, 256)))
  922. {
  923. if(client)
  924. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  925. }
  926. }
  927. break;
  928. }
  929. case SPAWN_SET_AAXP_REWARDS: {
  930. if (target->GetDatabaseID() > 0)
  931. {
  932. char query[256];
  933. snprintf(query, 256, "update spawn set aaxp_rewards=%u where id=%u", atoul(value), target->GetDatabaseID());
  934. if (database.RunQuery(query, strnlen(query, 256)))
  935. {
  936. if(client)
  937. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  938. }
  939. }
  940. break;
  941. }
  942. case SPAWN_SET_VALUE_NAME:{
  943. target->SetName(value);
  944. if(target->GetZone())
  945. target->GetZone()->SendUpdateTitles(target);
  946. break;
  947. }
  948. case SPAWN_SET_VALUE_SUB_TITLE: {
  949. target->SetSubTitle(value);
  950. if(target->GetZone())
  951. target->GetZone()->SendUpdateTitles(target);
  952. break;
  953. }
  954. case SPAWN_SET_VALUE_X_OFFSET:
  955. {
  956. target->SetXOffset(atof(value));
  957. break;
  958. }
  959. case SPAWN_SET_VALUE_Y_OFFSET:
  960. {
  961. target->SetYOffset(atof(value));
  962. break;
  963. }
  964. case SPAWN_SET_VALUE_Z_OFFSET:
  965. {
  966. target->SetZOffset(atof(value));
  967. break;
  968. }
  969. case SPAWN_SET_VALUE_EXPIRE: {
  970. target->SetExpireTime(val);
  971. break;
  972. }
  973. case SPAWN_SET_VALUE_EXPIRE_OFFSET: {
  974. target->SetExpireOffsetTime(val);
  975. break;
  976. }
  977. case SPAWN_SET_VALUE_LEVEL:{
  978. target->SetLevel(val, send_update);
  979. break;
  980. }
  981. case SPAWN_SET_VALUE_DIFFICULTY:{
  982. target->SetDifficulty(val, send_update);
  983. break;
  984. }
  985. case SPAWN_SET_VALUE_MODEL_TYPE:{
  986. target->SetModelType(val, send_update);
  987. break;
  988. }
  989. case SPAWN_SET_VALUE_CLASS:{
  990. target->SetAdventureClass(val, send_update);
  991. break;
  992. }
  993. case SPAWN_SET_VALUE_GENDER:{
  994. target->SetGender(val, send_update);
  995. break;
  996. }
  997. case SPAWN_SET_VALUE_SHOW_NAME:{
  998. target->SetShowName(val, send_update);
  999. break;
  1000. }
  1001. case SPAWN_SET_VALUE_ATTACKABLE:{
  1002. target->SetAttackable(val, send_update);
  1003. break;
  1004. }
  1005. case SPAWN_SET_VALUE_SHOW_LEVEL:{
  1006. target->SetShowLevel(val, send_update);
  1007. break;
  1008. }
  1009. case SPAWN_SET_VALUE_TARGETABLE:{
  1010. target->SetTargetable(val, send_update);
  1011. break;
  1012. }
  1013. case SPAWN_SET_VALUE_SHOW_COMMAND_ICON:{
  1014. target->SetShowCommandIcon(val, send_update);
  1015. break;
  1016. }
  1017. case SPAWN_SET_VALUE_HAND_ICON:{
  1018. target->SetShowHandIcon(val, send_update);
  1019. break;
  1020. }
  1021. case SPAWN_SET_VALUE_HAIR_TYPE:{
  1022. if(target->IsEntity())
  1023. ((Entity*)target)->SetHairType(val, send_update);
  1024. break;
  1025. }
  1026. case SPAWN_SET_VALUE_FACIAL_HAIR_TYPE:{
  1027. if(target->IsEntity())
  1028. ((Entity*)target)->SetFacialHairType(val, send_update);
  1029. break;
  1030. }
  1031. case SPAWN_SET_VALUE_WING_TYPE:{
  1032. if(target->IsEntity())
  1033. ((Entity*)target)->SetWingType(val, send_update);
  1034. break;
  1035. }
  1036. case SPAWN_SET_VALUE_CHEST_TYPE:{
  1037. if(target->IsEntity())
  1038. ((Entity*)target)->SetChestType(val, send_update);
  1039. break;
  1040. }
  1041. case SPAWN_SET_VALUE_LEGS_TYPE:{
  1042. if(target->IsEntity())
  1043. ((Entity*)target)->SetLegsType(val, send_update);
  1044. break;
  1045. }
  1046. case SPAWN_SET_VALUE_SOGA_HAIR_TYPE:{
  1047. if(target->IsEntity())
  1048. ((Entity*)target)->SetSogaHairType(val, send_update);
  1049. break;
  1050. }
  1051. case SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE:{
  1052. if(target->IsEntity())
  1053. ((Entity*)target)->SetSogaFacialHairType(val, send_update);
  1054. break;
  1055. }
  1056. case SPAWN_SET_VALUE_SOGA_MODEL_TYPE:{
  1057. target->SetSogaModelType(val, send_update);
  1058. break;
  1059. }
  1060. case SPAWN_SET_VALUE_SIZE:{
  1061. target->SetSize(val, send_update);
  1062. break;
  1063. }
  1064. case SPAWN_SET_VALUE_HP:{
  1065. target->SetHP(val, send_update);
  1066. break;
  1067. }
  1068. case SPAWN_SET_VALUE_POWER:{
  1069. target->SetPower(val, send_update);
  1070. break;
  1071. }
  1072. case SPAWN_SET_VALUE_HEROIC:{
  1073. target->SetHeroic(val, send_update);
  1074. break;
  1075. }
  1076. case SPAWN_SET_VALUE_RESPAWN:{
  1077. target->SetRespawnTime(val);
  1078. break;
  1079. }
  1080. case SPAWN_SET_VALUE_X:{
  1081. target->SetX(atof(value), send_update);
  1082. target->SetSpawnOrigX(target->GetX());
  1083. break;
  1084. }
  1085. case SPAWN_SET_VALUE_Y:{
  1086. target->SetY(atof(value), send_update);
  1087. target->SetSpawnOrigY(target->GetY());
  1088. break;
  1089. }
  1090. case SPAWN_SET_VALUE_Z:{
  1091. target->SetZ(atof(value), send_update);
  1092. target->SetSpawnOrigZ(target->GetZ());
  1093. break;
  1094. }
  1095. case SPAWN_SET_VALUE_HEADING:{
  1096. target->SetHeading(atof(value), send_update);
  1097. target->SetSpawnOrigHeading(target->GetHeading());
  1098. break;
  1099. }
  1100. case SPAWN_SET_VALUE_COMMAND_PRIMARY:{
  1101. ZoneServer* zone = target->GetZone();
  1102. if (!zone && client)
  1103. zone = client->GetCurrentZone();
  1104. if(zone && zone->GetEntityCommandList(val))
  1105. target->SetPrimaryCommands(zone->GetEntityCommandList(val));
  1106. target->primary_command_list_id = val;
  1107. break;
  1108. }
  1109. case SPAWN_SET_VALUE_COMMAND_SECONDARY:{
  1110. ZoneServer* zone = target->GetZone();
  1111. if (!zone && client)
  1112. zone = client->GetCurrentZone();
  1113. if (zone && zone->GetEntityCommandList(val))
  1114. target->SetSecondaryCommands(zone->GetEntityCommandList(val));
  1115. target->secondary_command_list_id = val;
  1116. break;
  1117. }
  1118. case SPAWN_SET_VALUE_VISUAL_STATE:{
  1119. target->SetVisualState(val, send_update);
  1120. break;
  1121. }
  1122. case SPAWN_SET_VALUE_ACTION_STATE:{
  1123. target->SetActionState(val, send_update);
  1124. break;
  1125. }
  1126. case SPAWN_SET_VALUE_MOOD_STATE:{
  1127. target->SetMoodState(val, send_update);
  1128. break;
  1129. }
  1130. case SPAWN_SET_VALUE_INITIAL_STATE:{
  1131. target->SetInitialState(val, send_update);
  1132. break;
  1133. }
  1134. case SPAWN_SET_VALUE_ACTIVITY_STATE:{
  1135. target->SetActivityStatus(val, send_update);
  1136. break;
  1137. }
  1138. case SPAWN_SET_VALUE_COLLISION_RADIUS:{
  1139. target->SetCollisionRadius(val, send_update);
  1140. break;
  1141. }
  1142. case SPAWN_SET_VALUE_FACTION:{
  1143. ZoneServer* zone = target->GetZone();
  1144. if (!zone && client)
  1145. zone = client->GetCurrentZone();
  1146. target->faction_id = val;
  1147. if(zone)
  1148. {
  1149. zone->RemoveDeadEnemyList(target);
  1150. if(target->IsNPC())
  1151. zone->AddEnemyList((NPC*)target);
  1152. }
  1153. break;
  1154. }
  1155. case SPAWN_SET_VALUE_DEVICE_ID:{
  1156. if (target->IsObject())
  1157. ((Object*)target)->SetDeviceID(val);
  1158. break;
  1159. }
  1160. case SPAWN_SET_VALUE_PITCH: {
  1161. target->SetPitch(atof(value), send_update);
  1162. target->SetSpawnOrigPitch(atof(value));
  1163. break;
  1164. }
  1165. case SPAWN_SET_VALUE_ROLL: {
  1166. target->SetRoll(atof(value), send_update);
  1167. target->SetSpawnOrigRoll(atof(value));
  1168. break;
  1169. }
  1170. case SPAWN_SET_VALUE_HIDE_HOOD: {
  1171. target->SetHideHood(val);
  1172. break;
  1173. }
  1174. case SPAWN_SET_VALUE_EMOTE_STATE: {
  1175. target->SetEmoteState(val);
  1176. break;
  1177. }
  1178. case SPAWN_SET_VALUE_ICON: {
  1179. target->SetIcon(val);
  1180. break;
  1181. }
  1182. case SPAWN_SET_VALUE_PREFIX: {
  1183. target->SetPrefixTitle(value);
  1184. if(target->GetZone())
  1185. target->GetZone()->SendUpdateTitles(target);
  1186. break;
  1187. }
  1188. case SPAWN_SET_VALUE_SUFFIX: {
  1189. target->SetSuffixTitle(value);
  1190. if(target->GetZone())
  1191. target->GetZone()->SendUpdateTitles(target);
  1192. break;
  1193. }
  1194. case SPAWN_SET_VALUE_LASTNAME: {
  1195. target->SetLastName(value);
  1196. if(target->GetZone())
  1197. target->GetZone()->SendUpdateTitles(target);
  1198. break;
  1199. }
  1200. case SPAWN_SET_VALUE_SPAWN_SCRIPT:{
  1201. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  1202. if(client){
  1203. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  1204. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawn_script 'SpawnScripts/example.lua'");
  1205. }
  1206. return false;
  1207. }
  1208. else if(!database.UpdateSpawnScriptData(target->GetDatabaseID(), 0, 0, value))
  1209. return false;
  1210. else{
  1211. if(!world.GetSpawnLocationScript(target->GetSpawnLocationID()))
  1212. target->SetSpawnScript(value);
  1213. }
  1214. break;
  1215. }
  1216. case SPAWN_SET_VALUE_SPAWNLOCATION_SCRIPT:{
  1217. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  1218. if(client){
  1219. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  1220. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawnlocation_script 'SpawnScripts/example.lua'");
  1221. }
  1222. return false;
  1223. }
  1224. else if(!database.UpdateSpawnScriptData(0, target->GetSpawnLocationID(), 0, value))
  1225. return false;
  1226. else{
  1227. if(!world.GetSpawnEntryScript(target->GetSpawnEntryID()))
  1228. target->SetSpawnScript(value);
  1229. }
  1230. break;
  1231. }
  1232. case SPAWN_SET_VALUE_SPAWNENTRY_SCRIPT:{
  1233. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  1234. if(client){
  1235. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  1236. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawnentry_script 'SpawnScripts/example.lua'");
  1237. }
  1238. return false;
  1239. }
  1240. else if(!database.UpdateSpawnScriptData(0, 0, target->GetSpawnEntryID(), value))
  1241. return false;
  1242. else
  1243. target->SetSpawnScript(value);
  1244. break;
  1245. }
  1246. case SPAWN_SET_SKIN_COLOR:
  1247. case SPAWN_SET_HAIR_COLOR1:
  1248. case SPAWN_SET_HAIR_COLOR2:
  1249. case SPAWN_SET_HAIR_TYPE_COLOR:
  1250. case SPAWN_SET_HAIR_FACE_COLOR:
  1251. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  1252. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  1253. case SPAWN_SET_HAIR_HIGHLIGHT:
  1254. case SPAWN_SET_MODEL_COLOR:
  1255. case SPAWN_SET_EYE_COLOR:
  1256. case SPAWN_SET_SOGA_SKIN_COLOR:
  1257. case SPAWN_SET_SOGA_HAIR_COLOR1:
  1258. case SPAWN_SET_SOGA_HAIR_COLOR2:
  1259. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  1260. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  1261. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  1262. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  1263. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  1264. case SPAWN_SET_SOGA_MODEL_COLOR:
  1265. case SPAWN_SET_SOGA_EYE_COLOR: {
  1266. if (target->IsNPC())
  1267. {
  1268. Seperator* skinsep = new Seperator(value, ' ', 3, 500, true);
  1269. if (skinsep->IsNumber(0) && skinsep->IsNumber(1) && skinsep->IsNumber(2))
  1270. {
  1271. EQ2_Color clr;
  1272. clr.red = atoul(skinsep->arg[0]);
  1273. clr.green = atoul(skinsep->arg[1]);
  1274. clr.blue = atoul(skinsep->arg[2]);
  1275. Query replaceSkinQuery;
  1276. string fieldName("");
  1277. switch(type)
  1278. {
  1279. case SPAWN_SET_SKIN_COLOR:
  1280. ((Entity*)target)->SetSkinColor(clr);
  1281. fieldName.append("skin_color");
  1282. break;
  1283. case SPAWN_SET_HAIR_COLOR1:
  1284. ((Entity*)target)->SetHairColor1(clr);
  1285. fieldName.append("hair_color1");
  1286. break;
  1287. case SPAWN_SET_HAIR_COLOR2:
  1288. ((Entity*)target)->SetHairColor2(clr);
  1289. fieldName.append("hair_color2");
  1290. break;
  1291. case SPAWN_SET_HAIR_TYPE_COLOR:
  1292. ((Entity*)target)->SetHairColor(clr);
  1293. fieldName.append("hair_type_color");
  1294. break;
  1295. case SPAWN_SET_HAIR_FACE_COLOR:
  1296. ((Entity*)target)->SetFacialHairColor(clr);
  1297. fieldName.append("hair_face_color");
  1298. break;
  1299. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  1300. ((Entity*)target)->SetHairTypeHighlightColor(clr);
  1301. fieldName.append("hair_type_highlight_color");
  1302. break;
  1303. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  1304. ((Entity*)target)->SetFacialHairHighlightColor(clr);
  1305. fieldName.append("hair_face_highlight_color");
  1306. break;
  1307. case SPAWN_SET_HAIR_HIGHLIGHT:
  1308. ((Entity*)target)->SetHairHighlightColor(clr);
  1309. fieldName.append("hair_highlight");
  1310. break;
  1311. case SPAWN_SET_MODEL_COLOR:
  1312. ((Entity*)target)->SetModelColor(clr);
  1313. fieldName.append("model_color");
  1314. break;
  1315. case SPAWN_SET_EYE_COLOR:
  1316. ((Entity*)target)->SetEyeColor(clr);
  1317. fieldName.append("eye_color");
  1318. break;
  1319. case SPAWN_SET_SOGA_SKIN_COLOR:
  1320. ((Entity*)target)->SetSogaSkinColor(clr);
  1321. fieldName.append("soga_skin_color");
  1322. break;
  1323. case SPAWN_SET_SOGA_HAIR_COLOR1:
  1324. ((Entity*)target)->SetSogaHairColor1(clr);
  1325. fieldName.append("soga_hair_color1");
  1326. break;
  1327. case SPAWN_SET_SOGA_HAIR_COLOR2:
  1328. ((Entity*)target)->SetSogaHairColor2(clr);
  1329. fieldName.append("soga_hair_color2");
  1330. break;
  1331. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  1332. ((Entity*)target)->SetSogaHairColor(clr);
  1333. fieldName.append("soga_hair_type_color");
  1334. break;
  1335. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  1336. ((Entity*)target)->SetSogaFacialHairColor(clr);
  1337. fieldName.append("soga_hair_face_color");
  1338. break;
  1339. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  1340. ((Entity*)target)->SetSogaHairTypeHighlightColor(clr);
  1341. fieldName.append("soga_hair_type_highlight_color");
  1342. break;
  1343. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  1344. ((Entity*)target)->SetSogaFacialHairHighlightColor(clr);
  1345. fieldName.append("soga_hair_face_highlight_color");
  1346. break;
  1347. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  1348. ((Entity*)target)->SetSogaHairHighlightColor(clr);
  1349. fieldName.append("soga_hair_highlight");
  1350. break;
  1351. case SPAWN_SET_SOGA_MODEL_COLOR:
  1352. ((Entity*)target)->SetSogaModelColor(clr);
  1353. fieldName.append("soga_model_color");
  1354. break;
  1355. case SPAWN_SET_SOGA_EYE_COLOR:
  1356. ((Entity*)target)->SetSogaEyeColor(clr);
  1357. fieldName.append("soga_eye_color");
  1358. break;
  1359. }
  1360. replaceSkinQuery.AddQueryAsync(0, &database, Q_DELETE, "delete from npc_appearance where spawn_id=%u and type='%s'", target->GetDatabaseID(), fieldName.c_str());
  1361. replaceSkinQuery.AddQueryAsync(0, &database, Q_INSERT, "insert into npc_appearance set spawn_id=%u, type='%s', red=%u, green=%u, blue=%u", target->GetDatabaseID(), fieldName.c_str(), clr.red, clr.green, clr.blue);
  1362. }
  1363. safe_delete(skinsep);
  1364. }
  1365. break;
  1366. }
  1367. case SPAWN_SET_CHEEK_TYPE:{
  1368. if(target->IsEntity() && index < 3){
  1369. sint8 new_value = atoi(value);
  1370. ((Entity*)target)->features.cheek_type[index] = new_value;
  1371. UpdateDatabaseAppearance(client, target, "cheek_type", ((Entity*)target)->features.cheek_type[0], ((Entity*)target)->features.cheek_type[1], ((Entity*)target)->features.cheek_type[2]);
  1372. }
  1373. break;
  1374. }
  1375. case SPAWN_SET_CHIN_TYPE:{
  1376. if(target->IsEntity() && index < 3){
  1377. sint8 new_value = atoi(value);
  1378. ((Entity*)target)->features.chin_type[index] = new_value;
  1379. UpdateDatabaseAppearance(client, target, "chin_type", ((Entity*)target)->features.chin_type[0], ((Entity*)target)->features.chin_type[1], ((Entity*)target)->features.chin_type[2]);
  1380. }
  1381. break;
  1382. }
  1383. case SPAWN_SET_EAR_TYPE:{
  1384. if(target->IsEntity() && index < 3){
  1385. sint8 new_value = atoi(value);
  1386. ((Entity*)target)->features.ear_type[index] = new_value;
  1387. UpdateDatabaseAppearance(client, target, "ear_type", ((Entity*)target)->features.ear_type[0], ((Entity*)target)->features.ear_type[1], ((Entity*)target)->features.ear_type[2]);
  1388. }
  1389. break;
  1390. }
  1391. case SPAWN_SET_EYE_BROW_TYPE:{
  1392. if(target->IsEntity() && index < 3){
  1393. sint8 new_value = atoi(value);
  1394. ((Entity*)target)->features.eye_brow_type[index] = new_value;
  1395. UpdateDatabaseAppearance(client, target, "eye_brow_type", ((Entity*)target)->features.eye_brow_type[0], ((Entity*)target)->features.eye_brow_type[1], ((Entity*)target)->features.eye_brow_type[2]);
  1396. }
  1397. break;
  1398. }
  1399. case SPAWN_SET_EYE_TYPE:{
  1400. if(target->IsEntity() && index < 3){
  1401. sint8 new_value = atoi(value);
  1402. ((Entity*)target)->features.eye_type[index] = new_value;
  1403. UpdateDatabaseAppearance(client, target, "eye_type", ((Entity*)target)->features.eye_type[0], ((Entity*)target)->features.eye_type[1], ((Entity*)target)->features.eye_type[2]);
  1404. }
  1405. break;
  1406. }
  1407. case SPAWN_SET_LIP_TYPE:{
  1408. if(target->IsEntity() && index < 3){
  1409. sint8 new_value = atoi(value);
  1410. ((Entity*)target)->features.lip_type[index] = new_value;
  1411. UpdateDatabaseAppearance(client, target, "lip_type", ((Entity*)target)->features.lip_type[0], ((Entity*)target)->features.lip_type[1], ((Entity*)target)->features.lip_type[2]);
  1412. }
  1413. break;
  1414. }
  1415. case SPAWN_SET_NOSE_TYPE:{
  1416. if(target->IsEntity() && index < 3){
  1417. sint8 new_value = atoi(value);
  1418. ((Entity*)target)->features.nose_type[index] = new_value;
  1419. UpdateDatabaseAppearance(client, target, "nose_type", ((Entity*)target)->features.nose_type[0], ((Entity*)target)->features.nose_type[1], ((Entity*)target)->features.nose_type[2]);
  1420. }
  1421. break;
  1422. }
  1423. case SPAWN_SET_BODY_SIZE:{
  1424. if(target->IsEntity()){
  1425. int8 new_value = atoul(value);
  1426. ((Entity*)target)->features.body_size = new_value;
  1427. UpdateDatabaseAppearance(client, target, "body_size", ((Entity*)target)->features.body_size, 0, 0);
  1428. }
  1429. break;
  1430. }
  1431. case SPAWN_SET_BODY_AGE:{
  1432. if(target->IsEntity()){
  1433. int8 new_value = atoul(value);
  1434. ((Entity*)target)->features.body_age = new_value;
  1435. UpdateDatabaseAppearance(client, target, "body_age", ((Entity*)target)->features.body_age, 0, 0);
  1436. }
  1437. break;
  1438. }
  1439. case SPAWN_SET_SOGA_CHEEK_TYPE:{
  1440. if(target->IsEntity() && index < 3){
  1441. sint8 new_value = atoi(value);
  1442. ((Entity*)target)->features.soga_cheek_type[index] = new_value;
  1443. UpdateDatabaseAppearance(client, target, "soga_cheek_type", ((Entity*)target)->features.soga_cheek_type[0], ((Entity*)target)->features.soga_cheek_type[1], ((Entity*)target)->features.soga_cheek_type[2]);
  1444. }
  1445. break;
  1446. }
  1447. case SPAWN_SET_SOGA_CHIN_TYPE:{
  1448. if(target->IsEntity() && index < 3){
  1449. sint8 new_value = atoi(value);
  1450. ((Entity*)target)->features.soga_chin_type[index] = new_value;
  1451. UpdateDatabaseAppearance(client, target, "soga_chin_type", ((Entity*)target)->features.soga_chin_type[0], ((Entity*)target)->features.soga_chin_type[1], ((Entity*)target)->features.soga_chin_type[2]);
  1452. }
  1453. break;
  1454. }
  1455. case SPAWN_SET_SOGA_EAR_TYPE:{
  1456. if(target->IsEntity() && index < 3){
  1457. sint8 new_value = atoi(value);
  1458. ((Entity*)target)->features.soga_ear_type[index] = new_value;
  1459. UpdateDatabaseAppearance(client, target, "soga_ear_type", ((Entity*)target)->features.soga_ear_type[0], ((Entity*)target)->features.soga_ear_type[1], ((Entity*)target)->features.soga_ear_type[2]);
  1460. }
  1461. break;
  1462. }
  1463. case SPAWN_SET_SOGA_EYE_BROW_TYPE:{
  1464. if(target->IsEntity() && index < 3){
  1465. sint8 new_value = atoi(value);
  1466. ((Entity*)target)->features.soga_eye_brow_type[index] = new_value;
  1467. UpdateDatabaseAppearance(client, target, "soga_eye_brow_type", ((Entity*)target)->features.soga_eye_brow_type[0], ((Entity*)target)->features.soga_eye_brow_type[1], ((Entity*)target)->features.soga_eye_brow_type[2]);
  1468. }
  1469. break;
  1470. }
  1471. case SPAWN_SET_SOGA_EYE_TYPE:{
  1472. if(target->IsEntity() && index < 3){
  1473. sint8 new_value = atoi(value);
  1474. ((Entity*)target)->features.soga_eye_type[index] = new_value;
  1475. UpdateDatabaseAppearance(client, target, "soga_eye_type", ((Entity*)target)->features.soga_eye_type[0], ((Entity*)target)->features.soga_eye_type[1], ((Entity*)target)->features.soga_eye_type[2]);
  1476. }
  1477. break;
  1478. }
  1479. case SPAWN_SET_SOGA_LIP_TYPE:{
  1480. if(target->IsEntity() && index < 3){
  1481. sint8 new_value = atoi(value);
  1482. ((Entity*)target)->features.soga_lip_type[index] = new_value;
  1483. UpdateDatabaseAppearance(client, target, "soga_lip_type", ((Entity*)target)->features.soga_lip_type[0], ((Entity*)target)->features.soga_lip_type[1], ((Entity*)target)->features.soga_lip_type[2]);
  1484. }
  1485. break;
  1486. }
  1487. case SPAWN_SET_SOGA_NOSE_TYPE:{
  1488. if(target->IsEntity() && index < 3){
  1489. sint8 new_value = atoi(value);
  1490. ((Entity*)target)->features.soga_nose_type[index] = new_value;
  1491. UpdateDatabaseAppearance(client, target, "soga_nose_type", ((Entity*)target)->features.soga_nose_type[0], ((Entity*)target)->features.soga_nose_type[1], ((Entity*)target)->features.soga_nose_type[2]);
  1492. }
  1493. break;
  1494. }
  1495. case SPAWN_SET_SOGA_BODY_SIZE:{
  1496. if(target->IsEntity()){
  1497. int8 new_value = atoul(value);
  1498. ((Entity*)target)->features.body_size = new_value;
  1499. UpdateDatabaseAppearance(client, target, "body_size", ((Entity*)target)->features.body_size, 0, 0);
  1500. }
  1501. break;
  1502. }
  1503. case SPAWN_SET_SOGA_BODY_AGE:{
  1504. if(target->IsEntity()){
  1505. int8 new_value = atoul(value);
  1506. ((Entity*)target)->features.body_age = new_value;
  1507. UpdateDatabaseAppearance(client, target, "body_age", ((Entity*)target)->features.body_age, 0, 0);
  1508. }
  1509. break;
  1510. }
  1511. case SPAWN_SET_ATTACK_TYPE:{
  1512. if(target->IsEntity()){
  1513. int8 new_value = atoul(value);
  1514. ((Entity*)target)->GetInfoStruct()->set_attack_type(new_value);
  1515. if(target->IsNPC()) {
  1516. if(target->GetDatabaseID()) {
  1517. Query spawnNPCQuery;
  1518. spawnNPCQuery.AddQueryAsync(0, &database, Q_INSERT, "update spawn_npcs set attack_type=%u where id=%u", new_value, target->GetDatabaseID());
  1519. } else if(client) {
  1520. client->Message(CHANNEL_COLOR_RED, "Invalid spawn to update the database (NPC only) or no database id for the NPC present.");
  1521. }
  1522. }
  1523. }
  1524. break;
  1525. }
  1526. case SPAWN_SET_RACE_TYPE:{
  1527. if(target->GetModelType() > 0){
  1528. Seperator* tmpsep = new Seperator(value, ' ', 3, 500, true);
  1529. if (tmpsep->IsNumber(0))
  1530. {
  1531. Query typequery;
  1532. int16 race_type = atoul(value);
  1533. const char* category = tmpsep->IsSet(1) ? tmpsep->arg[1] : "NULL";
  1534. const char* subcategory = tmpsep->IsSet(2) ? tmpsep->arg[2] : "NULL";
  1535. const char* model_name = tmpsep->IsSet(3) ? tmpsep->arg[3] : "NULL";
  1536. if(race_types_list.AddRaceType(target->GetModelType(), race_type, category, subcategory, model_name)) {
  1537. client->Message(CHANNEL_COLOR_YELLOW, "Model Type %u Race type %u inserted into memory + replaced into database, Model Type: %u set to Race Type: %u, Category: %s, SubCategory: %s, Model Name: %s.", race_type, target->GetModelType(), race_type, category, subcategory, model_name);
  1538. typequery.AddQueryAsync(0, &database, Q_INSERT, "insert into race_types (model_type, race_id, category, subcategory, model_name) values(%u, %u, '%s', '%s', '%s')", target->GetModelType(), race_type, category, subcategory, model_name);
  1539. }
  1540. else {
  1541. client->Message(CHANNEL_COLOR_RED, "Model Type: %u Race type %u overrided in memory + replaced into database, Model Type: %u set to Race Type: %u, Category: %s, SubCategory: %s, Model Name: %s.", race_type, target->GetModelType(), race_type, category, subcategory, model_name);
  1542. race_types_list.AddRaceType(target->GetModelType(), race_type, category, subcategory, model_name, true);
  1543. typequery.AddQueryAsync(0, &database, Q_INSERT, "update race_types set race_id=%u, category='%s', subcategory='%s', model_name='%s' where model_type=%u", race_type, category, subcategory, model_name, target->GetModelType());
  1544. }
  1545. }
  1546. safe_delete(tmpsep);
  1547. }
  1548. break;
  1549. }
  1550. case SPAWN_SET_LOOT_TIER:{
  1551. int32 new_value = atoul(value);
  1552. target->SetLootTier(new_value);
  1553. if (target->GetDatabaseID() > 0)
  1554. {
  1555. char query[256];
  1556. snprintf(query, 256, "update spawn set loot_tier=%u where id=%u", atoul(value), target->GetDatabaseID());
  1557. if (database.RunQuery(query, strnlen(query, 256)))
  1558. {
  1559. if(client)
  1560. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  1561. }
  1562. }
  1563. break;
  1564. }
  1565. case SPAWN_SET_LOOT_DROP_TYPE:{
  1566. int32 new_value = atoul(value);
  1567. target->SetLootDropType(new_value);
  1568. if (target->GetDatabaseID() > 0)
  1569. {
  1570. char query[256];
  1571. snprintf(query, 256, "update spawn set loot_drop_type=%u where id=%u", atoul(value), target->GetDatabaseID());
  1572. if (database.RunQuery(query, strnlen(query, 256)))
  1573. {
  1574. if(client)
  1575. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  1576. }
  1577. }
  1578. break;
  1579. }
  1580. case SPAWN_SET_SCARED_STRONG_PLAYERS:{
  1581. int32 new_value = atoul(value);
  1582. target->SetScaredByStrongPlayers(new_value);
  1583. if (target->GetDatabaseID() > 0)
  1584. {
  1585. char query[256];
  1586. snprintf(query, 256, "update spawn_npcs set scared_by_strong_players=%u where id=%u", atoul(value), target->GetDatabaseID());
  1587. if (database.RunQuery(query, strnlen(query, 256)))
  1588. {
  1589. if(client)
  1590. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  1591. }
  1592. }
  1593. break;
  1594. }
  1595. }
  1596. }
  1597. return true;
  1598. }
  1599. void Commands::UpdateDatabaseAppearance(Client* client, Spawn* target, string fieldName, sint8 r, sint8 g, sint8 b)
  1600. {
  1601. Query replaceQuery;
  1602. if(target->IsBot())
  1603. {
  1604. Bot* bot = (Bot*)target;
  1605. if(bot->BotID)
  1606. database.SaveBotFloats(bot->BotID, fieldName.c_str(), r, g, b);
  1607. }
  1608. else if(target->IsPlayer())
  1609. {
  1610. replaceQuery.AddQueryAsync(0, &database, Q_DELETE, "delete from char_colors where char_id=%u and type='%s'", ((Player*)target)->GetCharacterID(), fieldName.c_str());
  1611. replaceQuery.AddQueryAsync(0, &database, Q_INSERT, "insert into char_colors set char_id=%u, type='%s', red=%i, green=%i, blue=%i", ((Player*)target)->GetCharacterID(), fieldName.c_str(), r, g, b);
  1612. }
  1613. else
  1614. {
  1615. replaceQuery.AddQueryAsync(0, &database, Q_DELETE, "delete from npc_appearance where spawn_id=%u and type='%s'", target->GetDatabaseID(), fieldName.c_str());
  1616. replaceQuery.AddQueryAsync(0, &database, Q_INSERT, "insert into npc_appearance set spawn_id=%u, type='%s', red=%i, green=%i, blue=%i", target->GetDatabaseID(), fieldName.c_str(), r, g, b);
  1617. }
  1618. ((Entity*)target)->changed = true;
  1619. ((Entity*)target)->info_changed = true;
  1620. if(target->GetZone())
  1621. target->GetZone()->AddChangedSpawn(target);
  1622. }
  1623. /* The zone object will be NULL if the zone is not currently running. We pass both of these in so we can update
  1624. the database fields always and also update the zone in memory if it's running. */
  1625. bool Commands::SetZoneCommand(Client* client, int32 zone_id, ZoneServer* zone, int8 type, const char* value) {
  1626. if (client && zone_id > 0 && type > 0 && value) {
  1627. sint32 int_value = 0;
  1628. float float_value = 0;
  1629. if (type == ZONE_SET_VALUE_SAFE_X || type == ZONE_SET_VALUE_SAFE_Y || type == ZONE_SET_VALUE_SAFE_Z || type == ZONE_SET_VALUE_UNDERWORLD) {
  1630. try {
  1631. float_value = atof(value);
  1632. }
  1633. catch (...) {
  1634. client->Message(CHANNEL_COLOR_RED, "Error converting '%s' to a float value", value);
  1635. return false;
  1636. }
  1637. }
  1638. 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) {
  1639. try {
  1640. int_value = atoi(value);
  1641. }
  1642. catch (...) {
  1643. client->Message(CHANNEL_COLOR_RED, "Error converting '%s' to an integer value", value);
  1644. return false;
  1645. }
  1646. }
  1647. switch (type) {
  1648. case ZONE_SET_VALUE_EXPANSION_ID: {
  1649. break;
  1650. }
  1651. case ZONE_SET_VALUE_NAME: {
  1652. if (zone)
  1653. zone->SetZoneName(const_cast<char*>(value));
  1654. database.SaveZoneInfo(zone_id, "name", value);
  1655. break;
  1656. }
  1657. case ZONE_SET_VALUE_FILE: {
  1658. if (zone)
  1659. zone->SetZoneFile(const_cast<char*>(value));
  1660. database.SaveZoneInfo(zone_id, "file", value);
  1661. break;
  1662. }
  1663. case ZONE_SET_VALUE_DESCRIPTION: {
  1664. if (zone)
  1665. zone->SetZoneDescription(const_cast<char*>(value));
  1666. database.SaveZoneInfo(zone_id, "description", value);
  1667. break;
  1668. }
  1669. case ZONE_SET_VALUE_SAFE_X: {
  1670. if (zone)
  1671. zone->SetSafeX(float_value);
  1672. database.SaveZoneInfo(zone_id, "safe_x", float_value);
  1673. break;
  1674. }
  1675. case ZONE_SET_VALUE_SAFE_Y: {
  1676. if (zone)
  1677. zone->SetSafeY(float_value);
  1678. database.SaveZoneInfo(zone_id, "safe_y", float_value);
  1679. break;
  1680. }
  1681. case ZONE_SET_VALUE_SAFE_Z: {
  1682. if (zone)
  1683. zone->SetSafeZ(float_value);
  1684. database.SaveZoneInfo(zone_id, "safe_z", float_value);
  1685. break;
  1686. }
  1687. case ZONE_SET_VALUE_UNDERWORLD: {
  1688. if (zone)
  1689. zone->SetUnderWorld(float_value);
  1690. database.SaveZoneInfo(zone_id, "underworld", float_value);
  1691. break;
  1692. }
  1693. case ZONE_SET_VALUE_MIN_RECOMMENDED: {
  1694. break;
  1695. }
  1696. case ZONE_SET_VALUE_MAX_RECOMMENDED: {
  1697. break;
  1698. }
  1699. case ZONE_SET_VALUE_ZONE_TYPE: {
  1700. break;
  1701. }
  1702. case ZONE_SET_VALUE_ALWAYS_LOADED: {
  1703. if (zone)
  1704. zone->SetAlwaysLoaded(int_value == 1);
  1705. database.SaveZoneInfo(zone_id, "always_loaded", int_value);
  1706. break;
  1707. }
  1708. case ZONE_SET_VALUE_CITY_ZONE: {
  1709. if (zone)
  1710. zone->SetCityZone(int_value == 1);
  1711. database.SaveZoneInfo(zone_id, "city_zone", int_value);
  1712. break;
  1713. }
  1714. case ZONE_SET_VALUE_WEATHER_ALLOWED: {
  1715. if (zone)
  1716. zone->SetWeatherAllowed(int_value == 1);
  1717. database.SaveZoneInfo(zone_id, "weather_allowed", int_value);
  1718. break;
  1719. }
  1720. case ZONE_SET_VALUE_MIN_STATUS: {
  1721. if (zone)
  1722. zone->SetMinimumStatus(int_value);
  1723. database.SaveZoneInfo(zone_id, "min_status", int_value);
  1724. break;
  1725. }
  1726. case ZONE_SET_VALUE_MIN_LEVEL: {
  1727. if (zone)
  1728. zone->SetMinimumLevel(int_value);
  1729. database.SaveZoneInfo(zone_id, "min_level", int_value);
  1730. break;
  1731. }
  1732. case ZONE_SET_VALUE_MAX_LEVEL: {
  1733. if (zone)
  1734. zone->SetMaximumLevel(int_value);
  1735. database.SaveZoneInfo(zone_id, "max_level", int_value);
  1736. break;
  1737. }
  1738. case ZONE_SET_VALUE_START_ZONE: {
  1739. database.SaveZoneInfo(zone_id, "start_zone", int_value);
  1740. break;
  1741. }
  1742. case ZONE_SET_VALUE_INSTANCE_TYPE: {
  1743. if (zone)
  1744. zone->SetInstanceType(int_value);
  1745. database.SaveZoneInfo(zone_id, "instance_type", int_value);
  1746. break;
  1747. }
  1748. case ZONE_SET_VALUE_DEFAULT_REENTER_TIME: {
  1749. if (zone)
  1750. zone->SetDefaultReenterTime(int_value);
  1751. database.SaveZoneInfo(zone_id, "default_reenter_time", int_value);
  1752. break;
  1753. }
  1754. case ZONE_SET_VALUE_DEFAULT_RESET_TIME: {
  1755. if (zone)
  1756. zone->SetDefaultResetTime(int_value);
  1757. database.SaveZoneInfo(zone_id, "default_reset_time", int_value);
  1758. break;
  1759. }
  1760. case ZONE_SET_VALUE_DEFAULT_LOCKOUT_TIME: {
  1761. if (zone)
  1762. zone->SetDefaultLockoutTime(int_value);
  1763. database.SaveZoneInfo(zone_id, "default_lockout_time", int_value);
  1764. break;
  1765. }
  1766. case ZONE_SET_VALUE_FORCE_GROUP_TO_ZONE: {
  1767. if (zone)
  1768. zone->SetForceGroupZoneOption(int_value);
  1769. database.SaveZoneInfo(zone_id, "force_group_to_zone", int_value);
  1770. break;
  1771. }
  1772. case ZONE_SET_VALUE_LUA_SCRIPT: {
  1773. if (lua_interface && lua_interface->GetZoneScript(value) == 0) {
  1774. client->Message(CHANNEL_COLOR_RED, "Invalid Zone Script file. Be sure you give the absolute path.");
  1775. client->Message(CHANNEL_COLOR_RED, "Example: /zone set lua_script 'ZoneScripts/QueensColony.lua'");
  1776. return false;
  1777. }
  1778. else {
  1779. world.AddZoneScript(zone_id, const_cast<char*>(value));
  1780. database.SaveZoneInfo(zone_id, "lua_script", value);
  1781. }
  1782. break;
  1783. }
  1784. case ZONE_SET_VALUE_SHUTDOWN_TIMER: {
  1785. if (zone)
  1786. zone->SetShutdownTimer(int_value);
  1787. database.SaveZoneInfo(zone_id, "shutdown_timer", int_value);
  1788. break;
  1789. }
  1790. case ZONE_SET_VALUE_ZONE_MOTD: {
  1791. if (zone)
  1792. zone->SetZoneMOTD(string(value));
  1793. database.SaveZoneInfo(zone_id, "zone_motd", value);
  1794. break;
  1795. }
  1796. default: {
  1797. client->Message(CHANNEL_COLOR_RED, "Invalid zone attribute %i", type);
  1798. return false;
  1799. }
  1800. }
  1801. }
  1802. else {
  1803. if (client)
  1804. client->SimpleMessage(CHANNEL_COLOR_RED, "An error occured saving new zone data.");
  1805. return false;
  1806. }
  1807. return true;
  1808. }
  1809. void Commands::Process(int32 index, EQ2_16BitString* command_parms, Client* client, Spawn* targetOverride) {
  1810. if (index >= remote_commands->commands.size()) {
  1811. LogWrite(COMMAND__ERROR, 0, "Command", "Error, command handler of %u was requested, but max handler is %u", index, remote_commands->commands.size());
  1812. return;
  1813. }
  1814. Spawn* cmdTarget = targetOverride ? targetOverride : client->GetPlayer()->GetTarget();
  1815. EQ2_RemoteCommandString* parent_command = 0;
  1816. EQ2_RemoteCommandString* command = &remote_commands->commands[index];
  1817. Seperator* sep = 0;
  1818. if (command_parms->size > 0) {
  1819. sep = new Seperator(command_parms->data.c_str(), ' ', 10, 500, true);
  1820. if (sep && sep->arg[0] && remote_commands->validSubCommand(command->command.data, string(sep->arg[0]))) {
  1821. parent_command = command;
  1822. command = &(remote_commands->subcommands[command->command.data][string(sep->arg[0])]);
  1823. safe_delete(sep);
  1824. if (command_parms->data.length() > (command->command.data.length() + 1))
  1825. sep = new Seperator(command_parms->data.c_str() + (command->command.data.length() + 1), ' ', 10, 500, true);
  1826. LogWrite(COMMAND__DEBUG, 1, "Command", "Handler: %u, COMMAND: '%s', SUBCOMMAND: '%s'", index, parent_command->command.data.c_str(), command->command.data.c_str());
  1827. }
  1828. else
  1829. LogWrite(COMMAND__DEBUG, 1, "Command", "Handler: %u, COMMAND: '%s'", index, command->command.data.c_str());
  1830. }
  1831. int ndx = 0;
  1832. if (command->required_status > client->GetAdminStatus())
  1833. {
  1834. 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());
  1835. safe_delete(sep);
  1836. client->SimpleMessage(3, "Error: Your status is insufficient for this command.");
  1837. return;
  1838. }
  1839. Player* player = client->GetPlayer();
  1840. LogWrite(COMMAND__DEBUG, 0, "Command", "Player '%s' (%u), Command: %s", player->GetName(), client->GetAccountID(), command->command.data.c_str());
  1841. switch (command->handler) {
  1842. case COMMAND_RELOAD: {
  1843. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reload commands:");
  1844. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload structs");
  1845. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload items");
  1846. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload luasystem");
  1847. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spawnscripts");
  1848. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spells");
  1849. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spells npc");
  1850. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload quests");
  1851. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spawns");
  1852. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload groundspawns");
  1853. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload zonescripts");
  1854. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload entity_commands");
  1855. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload factions");
  1856. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload mail");
  1857. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload guilds");
  1858. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload locations");
  1859. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload rules");
  1860. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload transporters");
  1861. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload startabilities");
  1862. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload voiceovers");
  1863. break;
  1864. }
  1865. case COMMAND_RELOADSTRUCTS: {
  1866. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Structs...");
  1867. world.SetReloadingSubsystem("Structs");
  1868. configReader.ReloadStructs();
  1869. world.RemoveReloadingSubSystem("Structs");
  1870. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1871. break;
  1872. }
  1873. case COMMAND_RELOAD_QUESTS: {
  1874. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Quests...");
  1875. world.SetReloadingSubsystem("Quests");
  1876. master_quest_list.Reload();
  1877. client_list.ReloadQuests();
  1878. zone_list.ReloadClientQuests();
  1879. world.RemoveReloadingSubSystem("Quests");
  1880. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1881. break;
  1882. }
  1883. case COMMAND_RELOAD_SPAWNS: {
  1884. client->GetCurrentZone()->ReloadSpawns();
  1885. break;
  1886. }
  1887. case COMMAND_RELOAD_SPELLS: {
  1888. if (sep && sep->arg[0] && strcmp(sep->arg[0], "npc") == 0) {
  1889. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading NPC Spells Lists (Note: Must Reload Spawns/Repop to reset npc spells)...");
  1890. world.PurgeNPCSpells();
  1891. database.LoadNPCSpells();
  1892. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1893. }
  1894. else {
  1895. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spells & NPC Spell Lists (Note: Must Reload Spawns/Repop to reset npc spells)...");
  1896. world.SetReloadingSubsystem("Spells");
  1897. zone_list.DeleteSpellProcess();
  1898. master_spell_list.Reload();
  1899. if (lua_interface)
  1900. lua_interface->ReloadSpells();
  1901. zone_list.LoadSpellProcess();
  1902. world.RemoveReloadingSubSystem("Spells");
  1903. world.PurgeNPCSpells();
  1904. database.LoadNPCSpells();
  1905. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1906. }
  1907. break;
  1908. }
  1909. case COMMAND_RELOAD_GROUNDSPAWNS: {
  1910. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Groundspawn Entries...");
  1911. world.SetReloadingSubsystem("GroundSpawns");
  1912. client->GetCurrentZone()->DeleteGroundSpawnItems();
  1913. client->GetCurrentZone()->LoadGroundSpawnEntries();
  1914. world.RemoveReloadingSubSystem("GroundSpawns");
  1915. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1916. break;
  1917. }
  1918. case COMMAND_RELOAD_ZONESCRIPTS: {
  1919. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Zone Scripts...");
  1920. world.SetReloadingSubsystem("ZoneScripts");
  1921. world.ResetZoneScripts();
  1922. database.LoadZoneScriptData();
  1923. if (lua_interface)
  1924. lua_interface->DestroyZoneScripts();
  1925. world.RemoveReloadingSubSystem("ZoneScripts");
  1926. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1927. break;
  1928. }
  1929. case COMMAND_RELOAD_ENTITYCOMMANDS: {
  1930. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Entity Commands...");
  1931. world.SetReloadingSubsystem("EntityCommands");
  1932. client->GetCurrentZone()->ClearEntityCommands();
  1933. database.LoadEntityCommands(client->GetCurrentZone());
  1934. world.RemoveReloadingSubSystem("EntityCommands");
  1935. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1936. break;
  1937. }
  1938. case COMMAND_RELOAD_FACTIONS: {
  1939. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Factions...");
  1940. world.SetReloadingSubsystem("Factions");
  1941. master_faction_list.Clear();
  1942. database.LoadFactionList();
  1943. world.RemoveReloadingSubSystem("Factions");
  1944. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1945. break;
  1946. }
  1947. case COMMAND_RELOAD_MAIL: {
  1948. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Mail...");
  1949. zone_list.ReloadMail();
  1950. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1951. break;
  1952. }
  1953. case COMMAND_RELOAD_GUILDS: {
  1954. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Guilds...");
  1955. world.ReloadGuilds();
  1956. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1957. break;
  1958. }
  1959. case COMMAND_RELOAD_LOCATIONS: {
  1960. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Locations...");
  1961. client->GetPlayer()->GetZone()->RemoveLocationGrids();
  1962. database.LoadLocationGrids(client->GetPlayer()->GetZone());
  1963. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1964. break;
  1965. }
  1966. case COMMAND_RELOAD_RULES: {
  1967. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Rules...");
  1968. database.LoadRuleSets(true);
  1969. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1970. break;
  1971. }
  1972. case COMMAND_RELOAD_TRANSPORTERS: {
  1973. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Transporters in your current zone...");
  1974. database.LoadTransporters(client->GetCurrentZone());
  1975. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1976. break;
  1977. }
  1978. case COMMAND_RELOAD_STARTABILITIES: {
  1979. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Starting Skills/Spells...");
  1980. world.PurgeStartingLists();
  1981. world.LoadStartingLists();
  1982. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1983. break;
  1984. }
  1985. case COMMAND_RELOAD_VOICEOVERS: {
  1986. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Voiceovers...");
  1987. world.PurgeVoiceOvers();
  1988. world.LoadVoiceOvers();
  1989. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1990. break;
  1991. }
  1992. case COMMAND_READ: {
  1993. if (sep && sep->arg[1][0] && sep->IsNumber(1)) {
  1994. if (strcmp(sep->arg[0], "read") == 0) {
  1995. int32 item_index = atol(sep->arg[1]);
  1996. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  1997. if (item) {
  1998. Spawn* spawn = cmdTarget;
  1999. client->SendShowBook(client->GetPlayer(), item->name, item->book_language, item->book_pages);
  2000. break;
  2001. }
  2002. }
  2003. }
  2004. break;
  2005. }
  2006. case COMMAND_USEABILITY:{
  2007. if (sep && sep->arg[0][0] && sep->IsNumber(0)) {
  2008. if (!client->GetPlayer()->Alive()) {
  2009. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot do that right now.");
  2010. }
  2011. else {
  2012. int32 spell_id = atoul(sep->arg[0]);
  2013. int8 spell_tier = 0;
  2014. if (sep->arg[1][0] && sep->IsNumber(1))
  2015. spell_tier = atoi(sep->arg[1]);
  2016. else
  2017. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  2018. if (!spell_tier)
  2019. spell_tier = 1;
  2020. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  2021. if (spell) {
  2022. 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)
  2023. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), cmdTarget, true, true);
  2024. else
  2025. {
  2026. if (cmdTarget)
  2027. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), cmdTarget);
  2028. else
  2029. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  2030. }
  2031. }
  2032. }
  2033. }
  2034. else if (cmdTarget && cmdTarget->IsWidget())
  2035. {
  2036. Widget* widget = (Widget*)cmdTarget;
  2037. widget->HandleUse(client, "use", WIDGET_TYPE_DOOR);
  2038. }
  2039. else
  2040. {
  2041. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /useability {spell_id} [spell_tier]");
  2042. }
  2043. break;
  2044. }
  2045. case COMMAND_INFO:{
  2046. if(sep && sep->arg[1][0] && sep->IsNumber(1)){
  2047. if(strcmp(sep->arg[0], "inventory") == 0){
  2048. int32 item_index = atol(sep->arg[1]);
  2049. //printf("Index provided: %u\n",item_index);
  2050. if(client->GetVersion() <= 546 && item_index <= 255) {
  2051. item_index = 255 - item_index;
  2052. }
  2053. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  2054. if(item){
  2055. if (item->IsCollectable() && client->SendCollectionsForItem(item))
  2056. break;
  2057. EQ2Packet* app = item->serialize(client->GetVersion(), (!item->GetItemScript() || !lua_interface), client->GetPlayer());
  2058. //DumpPacket(app);
  2059. client->QueuePacket(app);
  2060. if(item->GetItemScript() && lua_interface)
  2061. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  2062. else if(item->generic_info.offers_quest_id > 0){ //leave the current functionality in place if it doesnt have an item script
  2063. Quest* quest = master_quest_list.GetQuest(item->generic_info.offers_quest_id, false);
  2064. if(quest && client->GetPlayer()->HasQuestBeenCompleted(item->generic_info.offers_quest_id) == 0 && client->GetPlayer()->HasActiveQuest(item->generic_info.offers_quest_id) == 0)
  2065. client->AddPendingQuest(new Quest(quest)); // copy quest since we pulled the master quest to see if it existed or not
  2066. }
  2067. }
  2068. else
  2069. LogWrite(COMMAND__ERROR, 0, "Command", "/info inventory: Unknown Index: %u", item_index);
  2070. }
  2071. else if(strcmp(sep->arg[0], "equipment") == 0){
  2072. int32 item_index = client->GetPlayer()->ConvertSlotFromClient(atol(sep->arg[1]), client->GetVersion());
  2073. Item* item = client->GetPlayer()->GetEquipmentList()->GetItem(item_index);
  2074. if(item){
  2075. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  2076. client->QueuePacket(app);
  2077. if(item->GetItemScript() && lua_interface)
  2078. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  2079. }
  2080. else
  2081. LogWrite(COMMAND__ERROR, 0, "Command", "/info equipment: Unknown Index: %u", item_index);
  2082. }
  2083. else if(strcmp(sep->arg[0], "appearance") == 0){
  2084. int32 item_index = client->GetPlayer()->ConvertSlotFromClient(atol(sep->arg[1]), client->GetVersion());
  2085. Item* item = client->GetPlayer()->GetAppearanceEquipmentList()->GetItem(item_index);
  2086. if(item){
  2087. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  2088. client->QueuePacket(app);
  2089. if(item->GetItemScript() && lua_interface)
  2090. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  2091. }
  2092. else
  2093. LogWrite(COMMAND__ERROR, 0, "Command", "/info appearance: Unknown Index: %u", item_index);
  2094. }
  2095. 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){
  2096. int32 item_id = atoul(sep->arg[1]);
  2097. Item* item = master_item_list.GetItem(item_id);
  2098. if(item){
  2099. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  2100. client->QueuePacket(app);
  2101. }
  2102. else
  2103. LogWrite(COMMAND__ERROR, 0, "Command", "/info item|merchant|store|buyback|consignment: Unknown Item ID: %u", item_id);
  2104. }
  2105. else if (strcmp(sep->arg[0], "spell") == 0) {
  2106. sint32 spell_id = atol(sep->arg[1]);
  2107. int8 tier = atoi(sep->arg[3]);
  2108. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, tier, client, true, 0x2A);
  2109. if (outapp)
  2110. client->QueuePacket(outapp);
  2111. else
  2112. LogWrite(COMMAND__ERROR, 0, "Command", "/info spell: Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  2113. }
  2114. else if (strcmp(sep->arg[0], "achievement") == 0) {
  2115. sint32 spell_id = atol(sep->arg[2]);
  2116. int8 group = atoi(sep->arg[1]);
  2117. AltAdvanceData* data = 0;
  2118. SpellBookEntry* spellentry = 0;
  2119. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  2120. LogWrite(COMMAND__ERROR, 0, "Command", "/info achievement: AA Spell ID and/or Tier, ID: %u, Group: %i", spell_id, group);
  2121. EQ2Packet* outapp = master_spell_list.GetAASpellPacket(spell_id, tier, client, true, 0x45);
  2122. if (outapp)
  2123. client->QueuePacket(outapp);
  2124. else
  2125. LogWrite(COMMAND__ERROR, 0, "Command", "/info achievement: Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, group);
  2126. }
  2127. else if (strcmp(sep->arg[0], "spellbook") == 0) {
  2128. sint32 spell_id = atol(sep->arg[1]);
  2129. int32 tier = atoi(sep->arg[2]);
  2130. if (tier > 255) {
  2131. SpellBookEntry* ent = client->GetPlayer()->GetSpellBookSpell(spell_id);
  2132. if (ent)
  2133. tier = ent->tier;
  2134. }
  2135. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, (int8)tier, client, true, 0x2A);
  2136. if (outapp)
  2137. client->QueuePacket(outapp);
  2138. else
  2139. LogWrite(COMMAND__ERROR, 0, "Command", "/info spellbook: Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  2140. }
  2141. else if (strcmp(sep->arg[0], "recipe") == 0) {
  2142. sint32 recipe_id = atol(sep->arg[1]);
  2143. EQ2Packet* outapp = master_recipe_list.GetRecipePacket(recipe_id, client, true, 0x2C);
  2144. if(outapp)
  2145. client->QueuePacket(outapp);
  2146. else
  2147. LogWrite(COMMAND__ERROR, 0, "Command", "/info recipe: Unknown Recipe ID: %u", recipe_id);
  2148. }
  2149. else if (strcmp(sep->arg[0], "recipe_product") == 0) {
  2150. sint32 recipe_id = atol(sep->arg[1]);
  2151. PlayerRecipeList* prl = client->GetPlayer()->GetRecipeList();
  2152. Recipe* recipe = nullptr;
  2153. if ((recipe = prl->GetRecipe(recipe_id)) && recipe->GetProductID()) {
  2154. RecipeProducts* rp = recipe->products[1];
  2155. if (recipe->GetProductID() > 0) {
  2156. Item* item = master_item_list.GetItem(recipe->GetProductID());
  2157. if(item){
  2158. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  2159. client->QueuePacket(app);
  2160. }
  2161. else
  2162. LogWrite(COMMAND__ERROR, 0, "Command", "/info recipe_product: Unknown Item ID: %u", recipe->GetProductID());
  2163. }
  2164. else {
  2165. LogWrite(COMMAND__ERROR, 0, "Command", "/info recipe_product: recipe->GetProductID() has value 0 for recipe id %u.", recipe_id);
  2166. }
  2167. }
  2168. else {
  2169. LogWrite(COMMAND__ERROR, 0, "Command", "/info recipe_product: with recipe id %u not found (recipe missing or no product in stage 1 assigned).", recipe_id);
  2170. }
  2171. }
  2172. else if (strcmp(sep->arg[0], "maintained") ==0) {
  2173. int32 slot = atol(sep->arg[1]);
  2174. int32 spell_id = atol(sep->arg[2]);
  2175. LogWrite(COMMAND__DEBUG, 5, "Command", "/info maintained: Spell ID - Slot: %u unknown: %u", slot, spell_id);
  2176. //int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  2177. MaintainedEffects* info = client->GetPlayer()->GetMaintainedSpellBySlot(slot);
  2178. EQ2Packet* outapp = master_spell_list.GetSpellPacket(info->spell_id, info->tier, client, true, 0x00);
  2179. if(outapp)
  2180. client->QueuePacket(outapp);
  2181. else
  2182. LogWrite(COMMAND__ERROR, 0, "Command", "/info maintained: Unknown Spell ID: %u", spell_id);
  2183. }
  2184. else if (strcmp(sep->arg[0], "effect") == 0) {
  2185. int32 spell_id = atol(sep->arg[1]);
  2186. LogWrite(COMMAND__DEBUG, 5, "Command", "/info effect: Spell ID: %u", spell_id);
  2187. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  2188. int8 type = 0;
  2189. if (client->GetVersion() <= 546)
  2190. type = 1;
  2191. EQ2Packet* outapp = master_spell_list.GetSpecialSpellPacket(spell_id, tier, client, true, type);
  2192. if (outapp){
  2193. client->QueuePacket(outapp);
  2194. }
  2195. else
  2196. LogWrite(COMMAND__ERROR, 0, "Command", "/info effect: Unknown Spell ID: %u", spell_id);
  2197. }
  2198. }
  2199. else if (sep && strcmp(sep->arg[0], "overflow") == 0) {
  2200. Item* item = player->item_list.GetOverflowItem();
  2201. if(item) {
  2202. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  2203. client->QueuePacket(app);
  2204. }
  2205. else
  2206. LogWrite(COMMAND__ERROR, 0,"Command", "/info overflow: Unable to retrieve an overflow item.");
  2207. }
  2208. else
  2209. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /info {inventory|equipment|spell} {id}");
  2210. break;
  2211. }
  2212. case COMMAND_USE_EQUIPPED_ITEM:{
  2213. if (sep && sep->arg[0] && sep->IsNumber(0)){
  2214. int32 slot_id = atoul(sep->arg[0]);
  2215. Item* item = player->GetEquipmentList()->GetItem(slot_id);
  2216. if (item && item->generic_info.usable && item->GetItemScript()) {
  2217. if(!item->CheckFlag2(INDESTRUCTABLE) && item->generic_info.condition == 0) {
  2218. client->SimpleMessage(CHANNEL_COLOR_RED, "This item is broken and must be repaired at a mender before it can be used");
  2219. }
  2220. else if (item->CheckFlag(EVIL_ONLY) && client->GetPlayer()->GetAlignment() != ALIGNMENT_EVIL) {
  2221. client->Message(0, "%s requires an evil race.", item->name.c_str());
  2222. }
  2223. else if (item->CheckFlag(GOOD_ONLY) && client->GetPlayer()->GetAlignment() != ALIGNMENT_GOOD) {
  2224. client->Message(0, "%s requires a good race.", item->name.c_str());
  2225. }
  2226. else {
  2227. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player, player->GetTarget());
  2228. }
  2229. }
  2230. }
  2231. break;
  2232. }
  2233. case COMMAND_USE_ITEM: {
  2234. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  2235. int32 item_index = atoul(sep->arg[0]);
  2236. Item* item = player->item_list.GetItemFromIndex(item_index);
  2237. client->UseItem(item, client->GetPlayer()->GetTarget() ? client->GetPlayer()->GetTarget() : client->GetPlayer());
  2238. }
  2239. break;
  2240. }
  2241. case COMMAND_SCRIBE_SCROLL_ITEM: {
  2242. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  2243. Item* item = player->item_list.GetItemFromUniqueID(atoul(sep->arg[0]));
  2244. if (item) {
  2245. LogWrite(ITEM__DEBUG, 0, "Items", "ITEM ID: %u", item->details.item_id);
  2246. if(item->generic_info.item_type == 6) {
  2247. Spell* spell = master_spell_list.GetSpell(item->skill_info->spell_id, item->skill_info->spell_tier);
  2248. int8 old_slot = 0;
  2249. if (spell) {
  2250. if(!spell->ScribeAllowed(client->GetPlayer())) {
  2251. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not meet one of the requirements to scribe, due to class or level.");
  2252. break;
  2253. }
  2254. int16 tier_up = player->GetTierUp(spell->GetSpellTier());
  2255. if (rule_manager.GetGlobalRule(R_Spells, RequirePreviousTierScribe)->GetInt8() && !player->HasSpell(spell->GetSpellID(), tier_up, false, true))
  2256. client->SimpleMessage(CHANNEL_COLOR_RED, "You have not scribed the required previous version of this ability.");
  2257. else if (!player->HasSpell(spell->GetSpellID(), spell->GetSpellTier(), true)) {
  2258. old_slot = player->GetSpellSlot(spell->GetSpellID());
  2259. player->RemoveSpellBookEntry(spell->GetSpellID());
  2260. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  2261. player->UnlockSpell(spell);
  2262. client->SendSpellUpdate(spell);
  2263. database.DeleteItem(client->GetCharacterID(), item, 0);
  2264. player->item_list.RemoveItem(item, true);
  2265. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  2266. client->QueuePacket(player->SendInventoryUpdate(client->GetVersion()));
  2267. // force purge client cache and display updated spell for hover over
  2268. EQ2Packet* app = spell->SerializeSpell(client, false, false);
  2269. client->QueuePacket(app);
  2270. }
  2271. }
  2272. else
  2273. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown spell ID: %u and tier: %u", item->skill_info->spell_id, item->skill_info->spell_tier);
  2274. }
  2275. else if(item->generic_info.item_type == 7){
  2276. if(item->recipebook_info) {
  2277. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Scribing recipe book %s (%u) for player %s.", item->name.c_str(), item->recipebook_info->recipe_id, player->GetName());
  2278. client->AddRecipeBookToPlayer(item->recipebook_info->recipe_id, item);
  2279. }
  2280. else {
  2281. client->Message(CHANNEL_NARRATIVE, "Recipe book is unavailable! Report to admin recipe id %u could not be retrieved.", item->recipebook_info ? item->recipebook_info->recipe_id : 0);
  2282. LogWrite(COMMAND__ERROR, 0, "Command", "Recipe Book %u could not be retrieved for item %s.", item->recipebook_info ? item->recipebook_info->recipe_id : 0, item->name.c_str());
  2283. }
  2284. }
  2285. else {
  2286. LogWrite(COMMAND__ERROR, 0, "Command", "Recipe Book Info is not set for item %s.", item->name.c_str());
  2287. }
  2288. }
  2289. else
  2290. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown unique item ID: %s", sep->arg[0]);
  2291. }
  2292. break;
  2293. }
  2294. case COMMAND_SUMMONITEM: {
  2295. if (sep && sep->IsNumber(0)) {
  2296. int32 item_id = atol(sep->arg[0]);
  2297. int32 quantity = 1;
  2298. if (sep->arg[1] && sep->IsNumber(1))
  2299. quantity = atoi(sep->arg[1]);
  2300. if (sep->arg[2] && strncasecmp(sep->arg[2], "bank", 4) == 0) {
  2301. client->AddItemToBank(item_id,quantity);
  2302. }
  2303. else {
  2304. client->AddItem(item_id, quantity);
  2305. }
  2306. }
  2307. else {
  2308. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} [quantity] or");
  2309. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} {quantity} [location] where location = bank");
  2310. }
  2311. break;
  2312. }
  2313. case COMMAND_COLLECTION_ADDITEM: {
  2314. // takes 2 params: collection_id, slot
  2315. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  2316. Item *item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(atoul(sep->arg[1]));
  2317. if (item)
  2318. client->HandleCollectionAddItem(atoul(sep->arg[0]), item);
  2319. else
  2320. 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]));
  2321. }
  2322. else
  2323. LogWrite(COLLECTION__ERROR, 0, "Collect", "Received command 'COMMAND_COLLECTION_ADDITEM' with unhandeled argument types");
  2324. break;
  2325. }
  2326. case COMMAND_COLLECTION_FILTER_MATCHITEM: {
  2327. // takes 1 param: slot
  2328. printf("COMMAND_COLLECTION_FILTER_MATCHITEM:\n");
  2329. int i = 0;
  2330. while (sep->arg[i] && strlen(sep->arg[i]) > 0) {
  2331. printf("\t%u: %s\n", i, sep->arg[i]);
  2332. i++;
  2333. }
  2334. break;
  2335. }
  2336. case COMMAND_WAYPOINT: {
  2337. bool success = false;
  2338. client->ClearWaypoint();
  2339. if (sep && sep->IsNumber(0) && sep->IsNumber(1) && sep->IsNumber(2)) {
  2340. if (!client->ShowPathToTarget(atof(sep->arg[0]), atof(sep->arg[1]), atof(sep->arg[2]), 0))
  2341. client->Message(CHANNEL_COLOR_RED, "Invalid coordinates given");
  2342. }
  2343. else if ( client->GetAdminStatus() > 100 && cmdTarget ) {
  2344. if (!client->ShowPathToTarget(cmdTarget->GetX(), cmdTarget->GetY(), cmdTarget->GetZ(), 0))
  2345. client->Message(CHANNEL_COLOR_RED, "Invalid coordinates given");
  2346. }
  2347. else {
  2348. client->Message(CHANNEL_COLOR_YELLOW, "Usage: /waypoint x y z");
  2349. }
  2350. break;
  2351. }
  2352. case COMMAND_WHO:{
  2353. const char* who = 0;
  2354. if(sep && sep->arg[0]){
  2355. //cout << "Who query: \n";
  2356. who = sep->argplus[0];
  2357. //cout << who << endl;
  2358. }
  2359. zone_list.ProcessWhoQuery(who, client);
  2360. break;
  2361. }
  2362. case COMMAND_SELECT_JUNCTION:{
  2363. // transporters (bells birds) use OP_SelectZoneTeleporterDestinatio / ProcessTeleportLocation(app)
  2364. // this is only used for revive it seems
  2365. int32 choice = 0;
  2366. if(sep && sep->arg[0] && sep->IsNumber(0))
  2367. choice = atoul(sep->arg[0]);
  2368. if(!client->GetPlayer()->Alive()){ //dead and this is a revive request
  2369. client->HandlePlayerRevive(choice);
  2370. }
  2371. break;
  2372. }
  2373. case COMMAND_SPAWN_MOVE: {
  2374. if (cmdTarget && cmdTarget->IsPlayer() == false) {
  2375. PacketStruct* packet = configReader.getStruct("WS_MoveObjectMode", client->GetVersion());
  2376. if (packet) {
  2377. float unknown2_3 = 0;
  2378. int8 placement_mode = 0;
  2379. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::DEFAULT);
  2380. if (sep && sep->arg[0][0]) {
  2381. if (strcmp(sep->arg[0], "wall") == 0) {
  2382. placement_mode = 2;
  2383. unknown2_3 = 150;
  2384. }
  2385. else if (strcmp(sep->arg[0], "ceiling") == 0)
  2386. placement_mode = 1;
  2387. else if (strcmp(sep->arg[0], "openheading") == 0 && cmdTarget->IsWidget())
  2388. {
  2389. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "[PlacementMode] WIDGET OPEN HEADING MODE");
  2390. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::OPEN_HEADING);
  2391. }
  2392. else if (strcmp(sep->arg[0], "closeheading") == 0 && cmdTarget->IsWidget())
  2393. {
  2394. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "[PlacementMode] WIDGET CLOSE HEADING MODE");
  2395. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::CLOSE_HEADING);
  2396. }
  2397. else if (strcmp(sep->arg[0], "myloc") == 0)
  2398. {
  2399. if (cmdTarget->GetSpawnLocationPlacementID() < 1) {
  2400. client->Message(CHANNEL_COLOR_YELLOW, "[PlacementMode] Spawn %s cannot be moved it is not assigned a spawn location placement id.", cmdTarget->GetName());
  2401. safe_delete(packet);
  2402. break;
  2403. }
  2404. cmdTarget->SetX(client->GetPlayer()->GetX(), true);
  2405. cmdTarget->SetY(client->GetPlayer()->GetY(), true);
  2406. cmdTarget->SetZ(client->GetPlayer()->GetZ(), true);
  2407. cmdTarget->SetHeading(client->GetPlayer()->GetHeading(), true);
  2408. if (database.UpdateSpawnLocationSpawns(cmdTarget))
  2409. client->Message(CHANNEL_COLOR_YELLOW, "[PlacementMode] Spawn %s placed at your location. Updated spawn_location_placement for spawn.", cmdTarget->GetName());
  2410. safe_delete(packet);
  2411. break;
  2412. }
  2413. }
  2414. packet->setDataByName("placement_mode", placement_mode);
  2415. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget));
  2416. packet->setDataByName("model_type", cmdTarget->GetModelType());
  2417. packet->setDataByName("unknown", 1); //size
  2418. packet->setDataByName("unknown2", 1); //size 2
  2419. packet->setDataByName("unknown2", .5, 1); //size 3
  2420. packet->setDataByName("unknown2", 3, 2);
  2421. packet->setDataByName("unknown2", unknown2_3, 3);
  2422. packet->setDataByName("max_distance", 500);
  2423. packet->setDataByName("CoEunknown", 0xFFFFFFFF);
  2424. client->QueuePacket(packet->serialize());
  2425. safe_delete(packet);
  2426. }
  2427. }
  2428. else {
  2429. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /spawn move (wall OR ceiling)");
  2430. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Moves a spawn anywhere you like. Optionally wall/ceiling can be provided to place wall/ceiling items.");
  2431. }
  2432. break;
  2433. }
  2434. case COMMAND_HAIL:{
  2435. Spawn* spawn = cmdTarget;
  2436. if(spawn && spawn->GetTargetable())
  2437. {
  2438. char tmp[75] = {0};
  2439. sprintf(tmp, "Hail, %s", spawn->GetName());
  2440. bool show_bubble = true;
  2441. if (spawn->IsNPC())
  2442. show_bubble = false;
  2443. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp, HEAR_SPAWN_DISTANCE, 0, show_bubble, client->GetPlayer()->GetCurrentLanguage());
  2444. if(spawn->IsPlayer() == false && spawn->Alive() && spawn->GetDistance(client->GetPlayer()) < rule_manager.GetGlobalRule(R_Spawn, HailDistance)->GetInt32()){
  2445. if(spawn->IsNPC() && ((NPC*)spawn)->EngagedInCombat())
  2446. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED_BUSY, client->GetPlayer());
  2447. else
  2448. {
  2449. bool pauseRunback = false;
  2450. // prime runback as the heading or anything can be altered when hailing succeeds
  2451. if(spawn->IsNPC() && (spawn->HasMovementLoop() || spawn->HasMovementLocations()))
  2452. {
  2453. ((NPC*)spawn)->StartRunback();
  2454. pauseRunback = true;
  2455. }
  2456. if(spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED, client->GetPlayer()) && pauseRunback)
  2457. spawn->PauseMovement(rule_manager.GetGlobalRule(R_Spawn, HailMovementPause)->GetInt32());
  2458. else if(spawn->IsNPC() && pauseRunback)
  2459. ((NPC*)spawn)->ClearRunback();
  2460. }
  2461. }
  2462. }
  2463. else {
  2464. string tmp = "Hail";
  2465. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp.c_str(), HEAR_SPAWN_DISTANCE, 0, true, client->GetPlayer()->GetCurrentLanguage());
  2466. }
  2467. break;
  2468. }
  2469. case COMMAND_SAY:{
  2470. if (sep && sep->arg[0][0]) {
  2471. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, sep->argplus[0], HEAR_SPAWN_DISTANCE, 0, true, client->GetPlayer()->GetCurrentLanguage());
  2472. if (cmdTarget && !(cmdTarget->IsPlayer()))
  2473. client->GetCurrentZone()->CallSpawnScript(cmdTarget, SPAWN_SCRIPT_HEAR_SAY, client->GetPlayer(), sep->argplus[0]);
  2474. }
  2475. else
  2476. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /say {message}");
  2477. break;
  2478. }
  2479. case COMMAND_TELL:{
  2480. if(sep && sep->arg[0] && sep->argplus[1]){
  2481. if(!zone_list.HandleGlobalChatMessage(client, sep->arg[0], CHANNEL_PRIVATE_TELL, sep->argplus[1], 0, client->GetPlayer()->GetCurrentLanguage()))
  2482. client->Message(CHANNEL_COLOR_RED,"Unable to find client %s",sep->arg[0]);
  2483. }else
  2484. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /tell {character_name} {message}");
  2485. break;
  2486. }
  2487. case COMMAND_SHOUT:{
  2488. if(sep && sep->arg[0][0])
  2489. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SHOUT, sep->argplus[0], 0, 0, true, client->GetPlayer()->GetCurrentLanguage());
  2490. else
  2491. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /shout {message}");
  2492. break;
  2493. }
  2494. case COMMAND_AUCTION:{
  2495. if(sep && sep->arg[0][0])
  2496. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_AUCTION, sep->argplus[0], 0, 0, true, client->GetPlayer()->GetCurrentLanguage());
  2497. else
  2498. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /auction {message}");
  2499. break;
  2500. }
  2501. case COMMAND_OOC:{
  2502. //For now ooc will be the global chat channel, eventually when we create more channels we will create a global chat channel
  2503. if(sep && sep->arg[0][0])
  2504. zone_list.HandleGlobalChatMessage(client, 0, CHANNEL_OUT_OF_CHARACTER, sep->argplus[0], 0, client->GetPlayer()->GetCurrentLanguage());
  2505. else
  2506. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /ooc {message}");
  2507. break;
  2508. }
  2509. case COMMAND_EMOTE:{
  2510. if(sep && sep->arg[0][0])
  2511. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_EMOTE, sep->argplus[0]);
  2512. else
  2513. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /emote {action}");
  2514. break;
  2515. }
  2516. case COMMAND_RACE:{
  2517. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  2518. if(sep->arg[1][0] && sep->IsNumber(1)){
  2519. client->GetPlayer()->GetInfoStruct()->set_race(atoi(sep->arg[1]));
  2520. client->GetPlayer()->SetRace(atoi(sep->arg[1]));
  2521. client->UpdateTimeStampFlag ( RACE_UPDATE_FLAG );
  2522. client->GetPlayer()->SetCharSheetChanged(true);
  2523. }
  2524. client->GetPlayer()->SetModelType(atoi(sep->arg[0]));
  2525. //EQ2Packet* outapp = client->GetPlayer()->spawn_update_packet(client->GetPlayer(), client->GetVersion(), client->GetPlayer()->GetFeatures());
  2526. //client->QueuePacket(outapp);
  2527. }
  2528. else{
  2529. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /race {race type id} {race id}");
  2530. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "{race id} is optional");
  2531. }
  2532. break;
  2533. }
  2534. case COMMAND_BANK_DEPOSIT:{
  2535. if(client->GetBanker() && sep && sep->arg[0]){
  2536. int64 amount = 0;
  2537. string deposit = string(sep->arg[0]);
  2538. amount = atoi64(deposit.c_str());
  2539. client->BankDeposit(amount);
  2540. }
  2541. break;
  2542. }
  2543. case COMMAND_BANK_WITHDRAWAL:{
  2544. if(client->GetBanker() && sep && sep->arg[0] && sep->IsNumber(0)){
  2545. int64 amount = 0;
  2546. string deposit = string(sep->arg[0]);
  2547. amount = atoi64(deposit.c_str());
  2548. client->BankWithdrawal(amount);
  2549. }
  2550. break;
  2551. }
  2552. case COMMAND_BANK_CANCEL:{
  2553. Spawn* banker = cmdTarget;
  2554. client->Bank(banker, true);
  2555. break;
  2556. }
  2557. case COMMAND_BANK:{
  2558. LogWrite(PLAYER__DEBUG, 0, "Players", "Open Player Personal Bank...");
  2559. Spawn* banker = cmdTarget;
  2560. client->Bank(banker);
  2561. break;
  2562. }
  2563. case COMMAND_GUILD_BANK:{
  2564. LogWrite(GUILD__DEBUG, 0, "Guilds", "Open Guild Bank...");
  2565. //Spawn* banker = client->GetPlayer()->GetTarget();
  2566. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will eventually open the guild bank!");
  2567. break;
  2568. }
  2569. case COMMAND_START_MAIL: {
  2570. client->SetMailTransaction(cmdTarget);
  2571. client->SendMailList();
  2572. break;
  2573. }
  2574. case COMMAND_CANCEL_MAIL: {
  2575. client->SetMailTransaction(0);
  2576. break;
  2577. }
  2578. case COMMAND_GET_MAIL_MESSAGE: {
  2579. if (sep && sep->arg[0] && sep->IsNumber(0))
  2580. client->DisplayMailMessage(atoul(sep->arg[0]));
  2581. break;
  2582. }
  2583. case COMMAND_ADD_MAIL_PLAT: {
  2584. if (sep && sep->arg[0] && sep->IsNumber(0))
  2585. client->AddMailCoin(0, 0, 0, atoul(sep->arg[0]));
  2586. break;
  2587. }
  2588. case COMMAND_ADD_MAIL_GOLD: {
  2589. if (sep && sep->arg[0] && sep->IsNumber(0))
  2590. client->AddMailCoin(0, 0, atoul(sep->arg[0]));
  2591. break;
  2592. }
  2593. case COMMAND_ADD_MAIL_SILVER: {
  2594. if (sep && sep->arg[0] && sep->IsNumber(0))
  2595. client->AddMailCoin(0, atoul(sep->arg[0]));
  2596. break;
  2597. }
  2598. case COMMAND_ADD_MAIL_COPPER: {
  2599. if (sep && sep->arg[0] && sep->IsNumber(0))
  2600. client->AddMailCoin(atoul(sep->arg[0]));
  2601. break;
  2602. }
  2603. case COMMAND_SET_MAIL_ITEM: {
  2604. if(sep && sep->IsNumber(0) && sep->IsNumber(1))
  2605. {
  2606. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(atoul(sep->arg[0]));
  2607. if(item)
  2608. {
  2609. int16 quantity = atoul(sep->arg[1]);
  2610. if(item->CheckFlag(NO_TRADE) || item->CheckFlag(ATTUNED) || item->CheckFlag(ARTIFACT) || item->CheckFlag2(HEIRLOOM))
  2611. {
  2612. return;
  2613. }
  2614. if(item->IsBag())
  2615. {
  2616. vector<Item*>* bag_items = player->GetPlayerItemList()->GetItemsInBag(item);
  2617. if(bag_items && bag_items->size() > 0)
  2618. {
  2619. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot mail a bag with items inside it.");
  2620. safe_delete(bag_items);
  2621. return;
  2622. }
  2623. safe_delete(bag_items);
  2624. }
  2625. Item* itemtoadd = item;
  2626. if(quantity > 0)
  2627. {
  2628. if(quantity > item->details.count)
  2629. return;
  2630. Item* tmpItem = new Item(item);
  2631. tmpItem->details.count = quantity;
  2632. itemtoadd = tmpItem;
  2633. }
  2634. if(client->AddMailItem(itemtoadd))
  2635. {
  2636. client->RemoveItem(item, quantity, true);
  2637. }
  2638. }
  2639. }
  2640. break;
  2641. }
  2642. case COMMAND_REMOVE_MAIL_PLAT: {
  2643. if (sep && sep->arg[0] && sep->IsNumber(0))
  2644. client->RemoveMailCoin(0, 0, 0, atoul(sep->arg[0]));
  2645. break;
  2646. }
  2647. case COMMAND_REMOVE_MAIL_GOLD: {
  2648. if (sep && sep->arg[0] && sep->IsNumber(0))
  2649. client->RemoveMailCoin(0, 0, atoul(sep->arg[0]));
  2650. break;
  2651. }
  2652. case COMMAND_REMOVE_MAIL_SILVER: {
  2653. if (sep && sep->arg[0] && sep->IsNumber(0))
  2654. client->RemoveMailCoin(0, atoul(sep->arg[0]));
  2655. break;
  2656. }
  2657. case COMMAND_REMOVE_MAIL_COPPER: {
  2658. if (sep && sep->arg[0] && sep->IsNumber(0))
  2659. client->RemoveMailCoin(atoul(sep->arg[0]));
  2660. break;
  2661. }
  2662. case COMMAND_TAKE_MAIL_ATTACHMENTS: {
  2663. if (sep && sep->arg[0] && sep->IsNumber(0))
  2664. client->TakeMailAttachments(atoul(sep->arg[0]));
  2665. break;
  2666. }
  2667. case COMMAND_CANCEL_SEND_MAIL: {
  2668. client->ResetSendMail();
  2669. break;
  2670. }
  2671. case COMMAND_DELETE_MAIL_MESSAGE: {
  2672. if (sep && sep->arg[0] && sep->IsNumber(0))
  2673. client->DeleteMail(atoul(sep->arg[0]), true);
  2674. break;
  2675. }
  2676. case COMMAND_REPORT_SPAM: {
  2677. LogWrite(MISC__TODO, 1, "TODO", " received reportspam\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  2678. if (sep && sep->arg[0]) LogWrite(COMMAND__DEBUG, 0, "Command", "%s\n", sep->argplus[0]);
  2679. break;
  2680. }
  2681. case COMMAND_KILL:{
  2682. Spawn* dead = 0;
  2683. if (sep && sep->arg[0] && strncasecmp(sep->arg[0],"self",4)==0){
  2684. dead=client->GetPlayer();
  2685. client->GetPlayer()->SetHP(0);
  2686. client->GetPlayer()->KillSpawn(dead);
  2687. }else{
  2688. dead= cmdTarget;
  2689. if(dead && dead->IsPlayer() == false){
  2690. if(dead->IsNPC() && ((NPC*)dead)->Brain()) {
  2691. client->GetPlayer()->CheckEncounterState((Entity*)dead);
  2692. ((NPC*)dead)->Brain()->AddToEncounter(client->GetPlayer());
  2693. ((NPC*)dead)->AddTargetToEncounter(client->GetPlayer());
  2694. ((NPC*)dead)->Brain()->AddHate(client->GetPlayer(), 1);
  2695. }
  2696. dead->SetHP(0);
  2697. if(sep && sep->arg[0] && sep->IsNumber(0) && atoi(sep->arg[0]) == 1)
  2698. client->GetCurrentZone()->RemoveSpawn(dead, true, true, true, true, true);
  2699. else
  2700. client->GetPlayer()->KillSpawn(dead);
  2701. }else{
  2702. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /kill (self)");
  2703. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Kills currently selected non-player target.");
  2704. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Optionally, self may be used to kill yourself");
  2705. }
  2706. }
  2707. break;
  2708. }
  2709. case COMMAND_LEVEL:{
  2710. if(sep && sep->arg[ndx][0] && sep->IsNumber(0)){
  2711. int16 new_level = atoi(sep->arg[ndx]);
  2712. if (!client->GetPlayer()->CheckLevelStatus(new_level))
  2713. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have the required status to level up anymore!");
  2714. else {
  2715. if (new_level < 1)
  2716. new_level = 1;
  2717. if (new_level > 255)
  2718. new_level = 255;
  2719. client->ChangeLevel(client->GetPlayer()->GetLevel(), new_level);
  2720. }
  2721. }else
  2722. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /level {new_level}");
  2723. break;
  2724. }
  2725. case COMMAND_SIT: {
  2726. if(client->GetPlayer()->GetHP() > 0){
  2727. client->QueuePacket(new EQ2Packet(OP_SitMsg, 0, 0));
  2728. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You sit down.");
  2729. client->GetPlayer()->set_character_flag(CF_IS_SITTING);
  2730. }
  2731. break;
  2732. }
  2733. case COMMAND_STAND: {
  2734. if(client->GetPlayer()->GetHP() > 0){
  2735. client->QueuePacket(new EQ2Packet(OP_StandMsg, 0, 0));
  2736. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You stand up.");
  2737. client->GetPlayer()->reset_character_flag(CF_IS_SITTING);
  2738. }
  2739. break;
  2740. }
  2741. case COMMAND_CLASS:{
  2742. if(sep && sep->arg[ndx][0]){
  2743. client->GetPlayer()->SetPlayerAdventureClass(atoi(sep->arg[ndx]));
  2744. client->UpdateTimeStampFlag ( CLASS_UPDATE_FLAG );
  2745. }else
  2746. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /class {class_id}");
  2747. break;
  2748. }
  2749. case COMMAND_FLYMODE:{
  2750. if(sep && sep->arg[0] && sep->IsNumber(0)){
  2751. PrintSep(sep, "COMMAND_FLYMODE");
  2752. int8 val = atoul(sep->arg[0]);
  2753. ClientPacketFunctions::SendFlyMode(client, val);
  2754. }
  2755. else{
  2756. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage ON: /flymode [1|2] 1 = fly, 2 = no clip");
  2757. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage OFF: /flymode 0");
  2758. }
  2759. break;
  2760. }
  2761. case COMMAND_LOOT_LIST:{
  2762. Spawn* spawn = cmdTarget;
  2763. if(spawn && spawn->IsEntity()){
  2764. if (sep && sep->arg[0]) {
  2765. if (!spawn->GetDatabaseID())
  2766. {
  2767. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn has no database id to assign to loottables.");
  2768. break;
  2769. }
  2770. else if (!spawn->IsNPC())
  2771. {
  2772. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "these /loot list [add/remove/clearall] sub-commands are only designed for an NPC.");
  2773. break;
  2774. }
  2775. bool reloadLoot = false;
  2776. if (!stricmp(sep->arg[0], "remove") && sep->arg[1] && sep->IsNumber(1))
  2777. {
  2778. int32 loottable_id = atoul(sep->arg[1]);
  2779. if (loottable_id > 0 && database.RemoveSpawnLootTable(spawn, loottable_id))
  2780. {
  2781. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u loot table %u removed.", spawn->GetDatabaseID(), loottable_id);
  2782. reloadLoot = true;
  2783. }
  2784. else
  2785. client->Message(CHANNEL_COLOR_YELLOW, "/loot list remove [loottableid] - could not match any spawn_id entries against loottable_id %u.", loottable_id);
  2786. }
  2787. else if (!stricmp(sep->arg[0], "add") && sep->arg[1] && sep->IsNumber(1))
  2788. {
  2789. int32 loottable_id = atoul(sep->arg[1]);
  2790. if (loottable_id > 0)
  2791. {
  2792. database.AddLootTableToSpawn(spawn, loottable_id);
  2793. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u loot table %u added.", spawn->GetDatabaseID(), loottable_id);
  2794. reloadLoot = true;
  2795. }
  2796. else
  2797. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list add [loottableid] - cannot add a loottable id of 0.");
  2798. }
  2799. else if (!stricmp(sep->arg[0], "clearall"))
  2800. {
  2801. if (database.RemoveSpawnLootTable(spawn, 0))
  2802. {
  2803. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn loot tables removed.");
  2804. reloadLoot = true;
  2805. }
  2806. else
  2807. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list clearall - could not match any spawn_id entries in loottable_id.");
  2808. }
  2809. else
  2810. {
  2811. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list argument not supported.");
  2812. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list add [loottableid] - add new loottable to spawn");
  2813. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list remove [loottableid] - remove existing loottable from spawn");
  2814. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list clearall - remove all loottables from spawn");
  2815. break;
  2816. }
  2817. if (reloadLoot)
  2818. {
  2819. database.LoadSpawnLoot(spawn->GetZone(), spawn);
  2820. if (spawn->IsNPC())
  2821. {
  2822. Entity* ent = (Entity*)spawn;
  2823. ent->SetLootCoins(0);
  2824. ent->ClearLoot();
  2825. spawn->GetZone()->AddLoot((NPC*)spawn);
  2826. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u active loot purged and reloaded.", spawn->GetDatabaseID());
  2827. }
  2828. }
  2829. break; // nothing further this is the end of these sub commands
  2830. }
  2831. else
  2832. {
  2833. vector<int32> loot_list = client->GetCurrentZone()->GetSpawnLootList(spawn->GetDatabaseID(), spawn->GetZone()->GetZoneID(), spawn->GetLevel(), race_types_list.GetRaceType(spawn->GetModelType()), spawn);
  2834. if (loot_list.size() > 0) {
  2835. client->Message(CHANNEL_COLOR_YELLOW, "%s belongs to the following loot lists: ", spawn->GetName());
  2836. vector<int32>::iterator list_itr;
  2837. LootTable* table = 0;
  2838. for (list_itr = loot_list.begin(); list_itr != loot_list.end(); list_itr++) {
  2839. table = client->GetCurrentZone()->GetLootTable(*list_itr);
  2840. if (table)
  2841. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", *list_itr, table->name.c_str());
  2842. }
  2843. }
  2844. client->Message(CHANNEL_COLOR_YELLOW, "Coins being carried: %u", spawn->GetLootCoins());
  2845. vector<Item*>* items = spawn->GetLootItems();
  2846. if (items) {
  2847. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is carrying the following items: ");
  2848. vector<Item*>::iterator itr;
  2849. Item* item = 0;
  2850. for (itr = items->begin(); itr != items->end(); itr++) {
  2851. item = *itr;
  2852. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", item->details.item_id, item->name.c_str());
  2853. }
  2854. }
  2855. else
  2856. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is not carrying any items.");
  2857. }
  2858. }
  2859. break;
  2860. }
  2861. case COMMAND_LOOT_SETCOIN:{
  2862. Spawn* spawn = cmdTarget;
  2863. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2864. spawn->SetLootCoins(atoul(sep->arg[0]));
  2865. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully set coins.");
  2866. }
  2867. else
  2868. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot setcoin {amount}");
  2869. break;
  2870. }
  2871. case COMMAND_LOOT_ADDITEM:{
  2872. Spawn* spawn = cmdTarget;
  2873. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2874. int16 charges = 1;
  2875. if(sep->arg[1] && sep->IsNumber(1))
  2876. charges = atoi(sep->arg[1]);
  2877. spawn->AddLootItem(atoul(sep->arg[0]), charges);
  2878. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully added item.");
  2879. }
  2880. else
  2881. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot additem {item_id}");
  2882. break;
  2883. }
  2884. case COMMAND_LOOT_REMOVEITEM:{
  2885. Spawn* spawn = cmdTarget;
  2886. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2887. Item* item = spawn->LootItem(atoul(sep->arg[0]));
  2888. lua_interface->SetLuaUserDataStale(item);
  2889. safe_delete(item);
  2890. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully removed item.");
  2891. }
  2892. else
  2893. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot removeitem {item_id}");
  2894. break;
  2895. }
  2896. case COMMAND_LOOT_CORPSE:
  2897. case COMMAND_DISARM:
  2898. case COMMAND_LOOT:{
  2899. if (cmdTarget && ((Entity*)cmdTarget)->IsNPC() && cmdTarget->Alive())
  2900. {
  2901. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is not dead.");
  2902. break;
  2903. }
  2904. if(cmdTarget && cmdTarget->IsEntity()){
  2905. if (cmdTarget->GetDistance(client->GetPlayer()) <= rule_manager.GetGlobalRule(R_Loot, LootRadius)->GetFloat()){
  2906. if (!rule_manager.GetGlobalRule(R_Loot, AutoDisarmChest)->GetBool() && command->handler == COMMAND_DISARM )
  2907. client->OpenChest(cmdTarget, true);
  2908. else
  2909. client->Loot(cmdTarget, rule_manager.GetGlobalRule(R_Loot, AutoDisarmChest)->GetBool());
  2910. if (!(cmdTarget)->HasLoot()){
  2911. if (((Entity*)cmdTarget)->IsNPC())
  2912. client->GetCurrentZone()->RemoveDeadSpawn(cmdTarget);
  2913. }
  2914. }
  2915. else
  2916. client->Message(CHANNEL_COLOR_YELLOW, "You are too far away to interact with that");
  2917. }
  2918. else if(!cmdTarget || cmdTarget->GetHP() > 0)
  2919. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid target.");
  2920. break;
  2921. }
  2922. case COMMAND_RELOADSPAWNSCRIPTS:{
  2923. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spawn Scripts....");
  2924. if (lua_interface)
  2925. lua_interface->SetLuaSystemReloading(true);
  2926. world.ResetSpawnScripts();
  2927. database.LoadSpawnScriptData();
  2928. if(lua_interface) {
  2929. lua_interface->DestroySpawnScripts();
  2930. lua_interface->SetLuaSystemReloading(false);
  2931. }
  2932. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Success!");
  2933. break;
  2934. }
  2935. case COMMAND_RELOADREGIONSCRIPTS:{
  2936. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Region Scripts....");
  2937. if(lua_interface) {
  2938. lua_interface->DestroyRegionScripts();
  2939. }
  2940. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Success!");
  2941. break;
  2942. }
  2943. case COMMAND_RELOADLUASYSTEM:{
  2944. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Attempting to reload entire LUA system....");
  2945. world.SetReloadingSubsystem("LuaSystem");
  2946. if(lua_interface) {
  2947. lua_interface->SetLuaSystemReloading(true);
  2948. }
  2949. zone_list.DeleteSpellProcess();
  2950. master_spell_list.Reload();
  2951. if (lua_interface)
  2952. lua_interface->ReloadSpells();
  2953. zone_list.LoadSpellProcess();
  2954. if(lua_interface){
  2955. map<Client*, int32> debug_clients = lua_interface->GetDebugClients();
  2956. map<Client*, int32>::iterator itr;
  2957. for(itr = debug_clients.begin(); itr != debug_clients.end(); itr++){
  2958. if(lua_interface)
  2959. lua_interface->UpdateDebugClients(itr->first);
  2960. }
  2961. }
  2962. world.ResetSpawnScripts();
  2963. database.LoadSpawnScriptData();
  2964. world.ResetZoneScripts();
  2965. database.LoadZoneScriptData();
  2966. if(lua_interface) {
  2967. lua_interface->DestroySpawnScripts();
  2968. lua_interface->DestroyRegionScripts();
  2969. lua_interface->DestroyQuests();
  2970. lua_interface->DestroyItemScripts();
  2971. lua_interface->DestroyZoneScripts();
  2972. }
  2973. int32 quest_count = database.LoadQuests();
  2974. int32 spell_count = 0;
  2975. if(lua_interface) {
  2976. spell_count = database.LoadSpellScriptData();
  2977. lua_interface->SetLuaSystemReloading(false);
  2978. }
  2979. world.RemoveReloadingSubSystem("LuaSystem");
  2980. client->Message(CHANNEL_COLOR_YELLOW, "Successfully loaded %u spell(s), %u quest(s).", spell_count, quest_count);
  2981. break;
  2982. }
  2983. case COMMAND_DECLINE_QUEST:{
  2984. int32 quest_id = 0;
  2985. if(sep && sep->arg[0] && sep->IsNumber(0))
  2986. quest_id = atoul(sep->arg[0]);
  2987. if(quest_id > 0){
  2988. client->RemovePendingQuest(quest_id);
  2989. }
  2990. break;
  2991. }
  2992. case COMMAND_DELETE_QUEST:{
  2993. int32 quest_id = 0;
  2994. if(sep && sep->arg[0] && sep->IsNumber(0))
  2995. quest_id = atoul(sep->arg[0]);
  2996. if(quest_id > 0){
  2997. client->GetPlayer()->MPlayerQuests.readlock(__FUNCTION__, __LINE__);
  2998. if(lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0) {
  2999. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  3000. client->GetPlayer()->MPlayerQuests.releasereadlock(__FUNCTION__, __LINE__);
  3001. if (quest && quest->CanDeleteQuest()) {
  3002. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  3003. client->RemovePlayerQuest(quest_id);
  3004. client->GetCurrentZone()->SendQuestUpdates(client);
  3005. }
  3006. }
  3007. else {
  3008. client->GetPlayer()->MPlayerQuests.releasereadlock(__FUNCTION__, __LINE__);
  3009. }
  3010. }
  3011. break;
  3012. }
  3013. case COMMAND_ACCEPT_QUEST:{
  3014. int32 quest_id = 0;
  3015. if(sep && sep->arg[0] && sep->IsNumber(0))
  3016. quest_id = atoul(sep->arg[0]);
  3017. if(quest_id > 0){
  3018. client->AcceptQuest(quest_id);
  3019. }
  3020. break;
  3021. }
  3022. case COMMAND_NAME:{
  3023. if(sep && sep->arg[ndx][0]){
  3024. client->GetPlayer()->GetInfoStruct()->set_name(std::string(sep->arg[ndx]).substr(0,39));
  3025. client->GetPlayer()->SetCharSheetChanged(true);
  3026. }else
  3027. client->Message(CHANNEL_COLOR_YELLOW,"Usage: /name {new_name}");
  3028. break;
  3029. }
  3030. case COMMAND_GROUP: {
  3031. if(sep && sep->arg[0])
  3032. printf("Group: %s\n",sep->argplus[0]);
  3033. break;
  3034. }
  3035. case COMMAND_GROUPSAY:{
  3036. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  3037. if(sep && sep->arg[0] && gmi)
  3038. world.GetGroupManager()->GroupChatMessage(gmi->group_id, client->GetPlayer(), client->GetPlayer()->GetCurrentLanguage(), sep->argplus[0]);
  3039. break;
  3040. }
  3041. case COMMAND_GROUPINVITE: {
  3042. Entity* target = 0;
  3043. Client* target_client = 0;
  3044. if (client->GetPlayer()->GetGroupMemberInfo() && !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  3045. client->SimpleMessage(CHANNEL_COMMANDS, "You must be the group leader to invite.");
  3046. return;
  3047. }
  3048. // name provided with command so it has to be a player, npc not supported here
  3049. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0){
  3050. target_client = zone_list.GetClientByCharName(sep->arg[0]);
  3051. if (target_client) {
  3052. if (!target_client->IsConnected() || !target_client->IsReadyForSpawns())
  3053. target = 0;
  3054. else
  3055. target = target_client->GetPlayer();
  3056. }
  3057. }
  3058. // if name was not provided use the players target, npc or player supported here
  3059. if (!target && client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  3060. target = (Entity*)client->GetPlayer()->GetTarget();
  3061. if (target->IsPlayer()) {
  3062. target_client = ((Player*)target)->GetClient();
  3063. }
  3064. }
  3065. int8 result = world.GetGroupManager()->Invite(client->GetPlayer(), target);
  3066. if (result == 0) {
  3067. client->Message(CHANNEL_COMMANDS, "You invite %s to group with you.", target->GetName());
  3068. if (target_client) {
  3069. PacketStruct* packet = configReader.getStruct("WS_ReceiveOffer", target_client->GetVersion());
  3070. if (packet) {
  3071. packet->setDataByName("type", 1);
  3072. packet->setDataByName("name", client->GetPlayer()->GetName());
  3073. packet->setDataByName("unknown2", 1);
  3074. target_client->QueuePacket(packet->serialize());
  3075. safe_delete(packet);
  3076. }
  3077. }
  3078. }
  3079. else if (result == 1)
  3080. client->SimpleMessage(CHANNEL_COMMANDS, "That player is already in a group.");
  3081. else if (result == 2)
  3082. client->SimpleMessage(CHANNEL_COMMANDS, "That player has been invited to another group.");
  3083. else if (result == 3)
  3084. client->SimpleMessage(CHANNEL_COMMANDS, "Your group is already full.");
  3085. else if (result == 4)
  3086. client->SimpleMessage(CHANNEL_COMMANDS, "You have a pending invitation, cancel it first.");
  3087. else if (result == 5)
  3088. client->SimpleMessage(CHANNEL_COMMANDS, "You cannot invite yourself!");
  3089. else if (result == 6)
  3090. client->SimpleMessage(CHANNEL_COMMANDS, "Could not locate the player.");
  3091. else
  3092. client->SimpleMessage(CHANNEL_COMMANDS, "Group invite failed, unknown error!");
  3093. break;
  3094. }
  3095. case COMMAND_GROUPDISBAND: {
  3096. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  3097. if (gmi) { // TODO: Leader check
  3098. // world.GetGroupManager()->SimpleGroupMessage(gmi->group_id, "Your group has been disbanded.");
  3099. world.GetGroupManager()->RemoveGroup(gmi->group_id);
  3100. }
  3101. break;
  3102. }
  3103. case COMMAND_GROUP_LEAVE: {
  3104. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  3105. if (gmi) {
  3106. int32 group_id = gmi->group_id;
  3107. world.GetGroupManager()->RemoveGroupMember(group_id, client->GetPlayer());
  3108. if (!world.GetGroupManager()->IsGroupIDValid(group_id)) {
  3109. // leader->Message(CHANNEL_COLOR_GROUP, "%s has left the group.", client->GetPlayer()->GetName());
  3110. }
  3111. else {
  3112. world.GetGroupManager()->GroupMessage(group_id, "%s has left the group.", client->GetPlayer()->GetName());
  3113. }
  3114. client->SimpleMessage(CHANNEL_GROUP_CHAT, "You have left the group");
  3115. }
  3116. break;
  3117. }
  3118. case COMMAND_FRIEND_ADD:{
  3119. string name = "";
  3120. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  3121. name = database.GetPlayerName(sep->arg[0]);
  3122. else if(cmdTarget && cmdTarget->IsPlayer())
  3123. name = string(cmdTarget->GetName());
  3124. if(name.length() > 0){
  3125. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  3126. if(client->GetPlayer()->IsIgnored(name.c_str())){
  3127. client->GetPlayer()->RemoveIgnore(name.c_str());
  3128. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  3129. client->SendChatRelationship(3, name.c_str());
  3130. }
  3131. client->GetPlayer()->AddFriend(name.c_str(), true);
  3132. client->SendChatRelationship(0, name.c_str());
  3133. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added friend: %s", name.c_str());
  3134. if(zone_list.GetClientByCharName(name))
  3135. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Friend: %s has logged in.", name.c_str());
  3136. }
  3137. else
  3138. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot be more friendly towards yourself!");
  3139. }
  3140. else
  3141. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  3142. break;
  3143. }
  3144. case COMMAND_FRIEND_REMOVE:{
  3145. string name = "";
  3146. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  3147. name = database.GetPlayerName(sep->arg[0]);
  3148. else if(cmdTarget && cmdTarget->IsPlayer())
  3149. name = string(cmdTarget->GetName());
  3150. if(name.length() > 0){
  3151. client->GetPlayer()->RemoveFriend(name.c_str());
  3152. client->SendChatRelationship(1, name.c_str());
  3153. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  3154. }
  3155. else
  3156. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  3157. break;
  3158. }
  3159. case COMMAND_FRIENDS:{
  3160. break;
  3161. }
  3162. case COMMAND_IGNORE_ADD:{
  3163. string name = "";
  3164. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  3165. name = database.GetPlayerName(sep->arg[0]);
  3166. else if(cmdTarget && cmdTarget->IsPlayer())
  3167. name = string(cmdTarget->GetName());
  3168. if(name.length() > 0){
  3169. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  3170. if(client->GetPlayer()->IsFriend(name.c_str())){
  3171. client->GetPlayer()->RemoveFriend(name.c_str());
  3172. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  3173. client->SendChatRelationship(1, name.c_str());
  3174. }
  3175. client->GetPlayer()->AddIgnore(name.c_str(), true);
  3176. client->SendChatRelationship(2, name.c_str());
  3177. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added ignore: %s", name.c_str());
  3178. }
  3179. else
  3180. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot ignore yourself!");
  3181. }
  3182. else
  3183. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  3184. break;
  3185. }
  3186. case COMMAND_IGNORE_REMOVE:{
  3187. string name = "";
  3188. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  3189. name = database.GetPlayerName(sep->arg[0]);
  3190. else if(cmdTarget && cmdTarget->IsPlayer())
  3191. name = string(cmdTarget->GetName());
  3192. if(name.length() > 0){
  3193. client->GetPlayer()->RemoveIgnore(name.c_str());
  3194. client->SendChatRelationship(3, name.c_str());
  3195. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  3196. }
  3197. break;
  3198. }
  3199. case COMMAND_IGNORES:{
  3200. break;
  3201. }
  3202. case COMMAND_GROUP_KICK:{
  3203. Entity* kicked = 0;
  3204. Client* kicked_client = 0;
  3205. int32 group_id = 0;
  3206. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader)
  3207. return;
  3208. if (sep && sep->arg[0]) {
  3209. kicked_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  3210. if (kicked_client)
  3211. kicked = kicked_client->GetPlayer();
  3212. }
  3213. else if (cmdTarget && cmdTarget->IsEntity()) {
  3214. kicked = (Entity*)cmdTarget;
  3215. }
  3216. group_id = client->GetPlayer()->GetGroupMemberInfo()->group_id;
  3217. bool send_kicked_message = world.GetGroupManager()->GetGroupSize(group_id) > 2;
  3218. if (kicked)
  3219. world.GetGroupManager()->RemoveGroupMember(group_id, kicked);
  3220. if(send_kicked_message)
  3221. world.GetGroupManager()->GroupMessage(group_id, "%s was kicked from the group.", kicked->GetName());
  3222. else
  3223. client->Message(CHANNEL_GROUP_CHAT, "You kicked %s from the group", kicked->GetName());
  3224. if (kicked_client)
  3225. kicked_client->SimpleMessage(CHANNEL_GROUP_CHAT, "You were kicked from the group");
  3226. break;
  3227. }
  3228. case COMMAND_GROUP_MAKE_LEADER:{
  3229. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  3230. client->SimpleMessage(CHANNEL_COMMANDS, "You are not a group leader.");
  3231. return;
  3232. }
  3233. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 1) {
  3234. Client* new_leader = zone_list.GetClientByCharName(sep->arg[0]);
  3235. if (new_leader && new_leader->GetPlayer()->GetGroupMemberInfo() && new_leader->GetPlayer()->GetGroupMemberInfo()->group_id == client->GetPlayer()->GetGroupMemberInfo()->group_id) {
  3236. if (client->GetPlayer()->IsGroupMember(new_leader->GetPlayer())) {
  3237. if(world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, new_leader->GetPlayer())) {
  3238. world.GetGroupManager()->GroupMessage(client->GetPlayer()->GetGroupMemberInfo()->group_id, "%s is now leader of the group.", new_leader->GetPlayer()->GetName());
  3239. }
  3240. }
  3241. }
  3242. else
  3243. client->SimpleMessage(CHANNEL_COMMANDS, "Unable to find the given player.");
  3244. }
  3245. else if (cmdTarget && cmdTarget->IsPlayer() && ((Player*)cmdTarget)->GetGroupMemberInfo() && ((Player*)cmdTarget)->GetGroupMemberInfo()->group_id == client->GetPlayer()->GetGroupMemberInfo()->group_id) {
  3246. if(client->GetPlayer()->IsGroupMember((Player*)cmdTarget) && world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, (Entity*)cmdTarget)) {
  3247. world.GetGroupManager()->GroupMessage(client->GetPlayer()->GetGroupMemberInfo()->group_id, "%s is now leader of the group.", cmdTarget->GetName());
  3248. }
  3249. }
  3250. else
  3251. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to change group leader.");
  3252. break;
  3253. }
  3254. case COMMAND_GROUP_ACCEPT_INVITE: {
  3255. if((sep && sep->arg[0] && strcmp(sep->arg[0], "group") == 0) || (!sep && client->GetVersion() <= 546)) {
  3256. int8 result = world.GetGroupManager()->AcceptInvite(client->GetPlayer());
  3257. if (result == 0)
  3258. client->SimpleMessage(CHANNEL_GROUP_CHAT, "You have joined the group.");
  3259. else if (result == 1)
  3260. client->SimpleMessage(CHANNEL_GROUP_CHAT, "You do not have a pending invite.");
  3261. else if (result == 2)
  3262. client->SimpleMessage(CHANNEL_GROUP_CHAT, "Unable to join group - could not find leader.");
  3263. else
  3264. client->SimpleMessage(CHANNEL_GROUP_CHAT, "Unable to join group - unknown error.");
  3265. }
  3266. break;
  3267. }
  3268. case COMMAND_GROUP_DECLINE_INVITE: {
  3269. if(sep && sep->arg[0] && strcmp(sep->arg[0], "group") == 0) {
  3270. world.GetGroupManager()->DeclineInvite(client->GetPlayer()); // TODO: Add message to leader
  3271. }
  3272. break;
  3273. }
  3274. case COMMAND_SUMMON:{
  3275. char* search_name = 0;
  3276. if(sep && sep->arg[0][0])
  3277. search_name = sep->arg[0];
  3278. if(!search_name && !cmdTarget){
  3279. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /summon [name]");
  3280. 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.");
  3281. }
  3282. else{
  3283. if(!client->Summon(search_name))
  3284. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  3285. }
  3286. break;
  3287. }
  3288. case COMMAND_GOTO:{
  3289. const char* search_name = 0;
  3290. if(sep && sep->arg[0][0])
  3291. search_name = sep->argplus[0];
  3292. if(!search_name && !cmdTarget){
  3293. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /goto [name]");
  3294. 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.");
  3295. }
  3296. else{
  3297. if(!client->GotoSpawn(search_name))
  3298. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  3299. }
  3300. break;
  3301. }
  3302. case COMMAND_MOVE:{
  3303. bool success = false;
  3304. try{
  3305. if(sep && sep->arg[2][0] && sep->IsNumber(0) && sep->IsNumber(1) && sep->IsNumber(2)){
  3306. EQ2Packet* app = client->GetPlayer()->Move(atof(sep->arg[0]), atof(sep->arg[1]), atof(sep->arg[2]), client->GetVersion());
  3307. if(app){
  3308. client->QueuePacket(app);
  3309. success = true;
  3310. }
  3311. }
  3312. }
  3313. catch(...){}
  3314. if(!success){
  3315. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /move x y z");
  3316. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Moves the client to the given coordinates.");
  3317. }
  3318. break;
  3319. }
  3320. case COMMAND_SETTIME:{
  3321. if(sep && sep->arg[0]){
  3322. world.MWorldTime.writelock(__FUNCTION__, __LINE__);
  3323. sscanf (sep->arg[0], "%d:%d", &world.GetWorldTimeStruct()->hour, &world.GetWorldTimeStruct()->minute);
  3324. if(sep->arg[1] && sep->IsNumber(1))
  3325. world.GetWorldTimeStruct()->month = atoi(sep->arg[1]) - 1; //zero based indexes
  3326. if(sep->arg[2] && sep->IsNumber(2))
  3327. world.GetWorldTimeStruct()->day = atoi(sep->arg[2]) - 1; //zero based indexes
  3328. if(sep->arg[3] && sep->IsNumber(3))
  3329. world.GetWorldTimeStruct()->year = atoi(sep->arg[3]);
  3330. world.MWorldTime.releasewritelock(__FUNCTION__, __LINE__);
  3331. client->GetCurrentZone()->SendTimeUpdateToAllClients();
  3332. }
  3333. else{
  3334. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /settime [hour:minute] (month) (day) (year)");
  3335. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Example: /settime 8:30");
  3336. }
  3337. break;
  3338. }
  3339. case COMMAND_VERSION:{
  3340. client->Message(CHANNEL_COLOR_YELLOW,"%s %s", EQ2EMU_MODULE, CURRENT_VERSION);
  3341. client->Message(CHANNEL_COLOR_YELLOW,"Last Compiled on %s %s", COMPILE_DATE, COMPILE_TIME);
  3342. break;
  3343. }
  3344. case COMMAND_ZONE:{
  3345. int32 instanceID = 0;
  3346. string zone;
  3347. int32 zone_id = 0;
  3348. bool listSearch = false;
  3349. bool isInstance = false;
  3350. ZoneServer* zsZone = 0;
  3351. if(sep && sep->arg[0][0])
  3352. {
  3353. if(strncasecmp(sep->arg[0], "list", 4) == 0)
  3354. listSearch = true;
  3355. else if(strncasecmp(sep->arg[0], "active", 6) == 0)
  3356. {
  3357. zone_list.SendZoneList(client);
  3358. break;
  3359. }
  3360. else if(strncasecmp(sep->arg[0], "instance", 6) == 0)
  3361. {
  3362. if(sep->IsNumber(1))
  3363. instanceID = atol(sep->arg[1]);
  3364. }
  3365. else if(strncasecmp(sep->arg[0], "lock", 4) == 0)
  3366. {
  3367. PrintSep(sep, "ZONE LOCK");
  3368. if(sep->IsNumber(1))
  3369. zsZone = zone_list.Get(atoul(sep->arg[1]), false, false, false);
  3370. else
  3371. zsZone = zone_list.Get(sep->arg[1], false, false, false);
  3372. if( zsZone )
  3373. {
  3374. zsZone->SetZoneLockState(true);
  3375. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now locked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  3376. }
  3377. else
  3378. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be locked.", sep->arg[1]);
  3379. break;
  3380. }
  3381. else if(strncasecmp(sep->arg[0], "unlock", 6) == 0)
  3382. {
  3383. PrintSep(sep, "ZONE UNLOCK");
  3384. if(sep->IsNumber(1))
  3385. zsZone = zone_list.Get(atoul(sep->arg[1]), false, false, false);
  3386. else
  3387. zsZone = zone_list.Get(sep->arg[1], false, false, false);
  3388. if( zsZone )
  3389. {
  3390. zsZone->SetZoneLockState(false);
  3391. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now unlocked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  3392. }
  3393. else
  3394. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be unlocked.", sep->arg[1]);
  3395. break;
  3396. }
  3397. else
  3398. {
  3399. if(sep->IsNumber(0))
  3400. {
  3401. zone_id = atoul(sep->arg[0]);
  3402. string zonename = database.GetZoneName(zone_id);
  3403. if(zonename.length() > 0)
  3404. zone = zonename;
  3405. }
  3406. else
  3407. zone = sep->arg[0];
  3408. }
  3409. if(instanceID > 0)
  3410. {
  3411. ZoneServer* zsInstance = zone_list.GetByInstanceID(instanceID);
  3412. if(zsInstance != NULL)
  3413. {
  3414. instanceID = zsInstance->GetInstanceID();
  3415. zone = zsInstance->GetZoneName();
  3416. zone_id = zsInstance->GetZoneID();
  3417. isInstance = true;
  3418. }
  3419. }
  3420. }
  3421. if(!listSearch)
  3422. {
  3423. if(zone.length() == 0)
  3424. client->Message(CHANNEL_COLOR_RED, "Error: Invalid Zone");
  3425. else if(instanceID != client->GetCurrentZone()->GetInstanceID() ||
  3426. zone_id != client->GetCurrentZone()->GetZoneID())
  3427. {
  3428. const char* zonestr = zone.c_str();
  3429. if(database.VerifyZone(zonestr))
  3430. {
  3431. if(client->CheckZoneAccess(zonestr))
  3432. {
  3433. client->Message(CHANNEL_COLOR_YELLOW,"Zoning to %s...", zonestr);
  3434. if(isInstance)
  3435. client->Zone(instanceID,true,true,false);
  3436. else
  3437. client->Zone(zonestr);
  3438. }
  3439. }
  3440. else
  3441. client->Message(CHANNEL_COLOR_RED, "Error: Zone '%s' not found. To get a list type /zone list", zonestr);
  3442. }
  3443. else
  3444. client->Message(CHANNEL_COLOR_RED, "Error: You are already in that zone!");
  3445. }
  3446. else
  3447. {
  3448. const char* name = 0;
  3449. if(sep && sep->arg[1][0])
  3450. {
  3451. map<int32, string>* zone_names;
  3452. name = sep->argplus[1];
  3453. sint16 status = client->GetAdminStatus();
  3454. if( status > 0 )
  3455. {
  3456. client->SimpleMessage(CHANNEL_COLOR_RED, "ADMIN MODE");
  3457. zone_names = database.GetZoneList(name, true);
  3458. }
  3459. else
  3460. zone_names = database.GetZoneList(name);
  3461. if(!zone_names)
  3462. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No zones found.");
  3463. else
  3464. {
  3465. map<int32, string>::iterator itr;
  3466. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  3467. for(itr = zone_names->begin(); itr != zone_names->end(); itr++)
  3468. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  3469. safe_delete(zone_names);
  3470. }
  3471. }
  3472. else
  3473. {
  3474. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone [zone name]");
  3475. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone list [partial zone name]");
  3476. }
  3477. }
  3478. break;
  3479. }
  3480. case COMMAND_USE: {
  3481. Spawn* target = cmdTarget;
  3482. if (target && target->IsWidget())
  3483. ((Widget*)target)->HandleUse(client, "use");
  3484. break;
  3485. }
  3486. case COMMAND_OPEN: {
  3487. Spawn* target = cmdTarget;
  3488. if (target && target->IsWidget())
  3489. ((Widget*)target)->HandleUse(client, "Open", WIDGET_TYPE_DOOR);
  3490. break;
  3491. }
  3492. case COMMAND_CASTSPELL: {
  3493. if (sep && sep->arg[0] && sep->IsNumber(0))
  3494. {
  3495. int8 tier = 1;
  3496. if (sep->arg[1] && sep->IsNumber(1))
  3497. tier = atoul(sep->arg[1]);
  3498. int8 self = 1;
  3499. if (sep->arg[1] && sep->IsNumber(2))
  3500. {
  3501. self = atoul(sep->arg[2]);
  3502. if(self != 1 && !cmdTarget->IsEntity())
  3503. {
  3504. client->Message(CHANNEL_COLOR_RED, "Target is not an entity required to cast non-self spell.");
  3505. self = 1;
  3506. }
  3507. }
  3508. int32 spellid = atoul(sep->arg[0]);
  3509. Spell* spell = master_spell_list.GetSpell(spellid, tier);
  3510. if (spell)
  3511. {
  3512. client->Message(CHANNEL_COLOR_RED, "Casting spell %u.", spellid);
  3513. SpellProcess* spellProcess = 0;
  3514. // Get the current zones spell process
  3515. spellProcess = client->GetCurrentZone()->GetSpellProcess();
  3516. spellProcess->CastInstant(spell, (!cmdTarget || self == 1) ? (Entity*)client->GetPlayer() : (Entity*)cmdTarget, (cmdTarget && cmdTarget->IsEntity()) ? (Entity*)cmdTarget : (Entity*)client->GetPlayer());
  3517. }
  3518. else
  3519. {
  3520. client->Message(CHANNEL_COLOR_RED, "Could not find spell %u.",spellid);
  3521. }
  3522. }
  3523. else if (sep && sep->arg[0])
  3524. {
  3525. database.FindSpell(client, (char*)sep->argplus[0]);
  3526. }
  3527. else
  3528. {
  3529. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellid] (tier=1) - Cast Spell with specified spell id, tier is optional, default of 1.");
  3530. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellname] - Find spells wildcard match with a partial spell name");
  3531. }
  3532. break;
  3533. }
  3534. case COMMAND_KNOWLEDGEWINDOWSORT: {
  3535. if (sep && (client->GetVersion() <= 546 && sep->GetArgNumber() == 3) || sep->GetArgNumber() == 4)
  3536. {
  3537. int32 book = atoul(sep->arg[0]); // 0 - spells, 1 - combat, 2 - abilities, 3 - tradeskill
  3538. // cannot sort the ability book in this client it is greyed out
  3539. if (client->GetVersion() <= 546 && book == SPELL_BOOK_TYPE_ABILITY)
  3540. break;
  3541. int32 sort_by = atoul(sep->arg[1]); // 0 - alpha, 1 - level, 2 - category
  3542. int32 order = atoul(sep->arg[2]); // 0 - ascending, 1 - descending
  3543. int32 pattern = atoul(sep->arg[3]); // 0 - zigzag, 1 - down, 2 - across
  3544. int32 maxlvlonly = 0;
  3545. if(client->GetVersion() > 546 && sep->arg[4][0]) {
  3546. maxlvlonly = atoul(sep->arg[4]); // checkbox for newer clients
  3547. }
  3548. client->GetPlayer()->ResortSpellBook(sort_by, order, pattern, maxlvlonly, book);
  3549. ClientPacketFunctions::SendSkillSlotMappings(client);
  3550. }
  3551. else
  3552. {
  3553. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /knowledgewindow_sort [book] [sort_by] [order] [pattern]");
  3554. }
  3555. break;
  3556. }
  3557. case COMMAND_MOVE_ITEM:
  3558. {
  3559. int32 id = 0;
  3560. if (sep && sep->IsNumber(0))
  3561. id = atoul(sep->arg[0]);
  3562. Spawn* spawn = 0;
  3563. if (id == 0)
  3564. {
  3565. spawn = cmdTarget;
  3566. }
  3567. else
  3568. spawn = client->GetCurrentZone()->GetSpawnFromUniqueItemID(id);
  3569. if (!spawn || !client->HasOwnerOrEditAccess() || !spawn->GetPickupItemID())
  3570. break;
  3571. client->SendMoveObjectMode(spawn, 0);
  3572. break;
  3573. }
  3574. case COMMAND_PICKUP:
  3575. {
  3576. int32 id = 0;
  3577. if (sep && sep->IsNumber(0))
  3578. id = atoul(sep->arg[0]);
  3579. Spawn* spawn = 0;
  3580. if (id == 0)
  3581. {
  3582. spawn = cmdTarget;
  3583. }
  3584. else
  3585. spawn = client->GetCurrentZone()->GetSpawnFromUniqueItemID(id);
  3586. if (!spawn || !client->HasOwnerOrEditAccess() || !spawn->GetPickupItemID())
  3587. break;
  3588. if(client->AddItem(spawn->GetPickupItemID(), 1)) {
  3589. Query query;
  3590. query.RunQuery2(Q_INSERT, "delete from spawn_instance_data where spawn_id = %u and spawn_location_id = %u and pickup_item_id = %u", spawn->GetDatabaseID(), spawn->GetSpawnLocationID(), spawn->GetPickupItemID());
  3591. if (database.RemoveSpawnFromSpawnLocation(spawn)) {
  3592. client->GetCurrentZone()->RemoveSpawn(spawn, true, true, true, true, true);
  3593. }
  3594. // we had a UI Window displayed, update the house items
  3595. if ( id > 0 )
  3596. client->GetCurrentZone()->SendHouseItems(client);
  3597. }
  3598. break;
  3599. }
  3600. case COMMAND_HOUSE_DEPOSIT:
  3601. {
  3602. PrintSep(sep, "COMMAND_HOUSE_DEPOSIT");
  3603. // arg0 = spawn_id for DoF, could also be house_id for newer clients
  3604. // arg1 = coin (in copper)
  3605. // arg2 = status? (not implemented yet)
  3606. PlayerHouse* ph = nullptr;
  3607. int32 spawn_id = 0;
  3608. if(sep && sep->arg[0]) {
  3609. spawn_id = atoul(sep->arg[0]);
  3610. ph = world.GetPlayerHouse(client, spawn_id, client->GetVersion() > 546 ? spawn_id : 0, nullptr);
  3611. }
  3612. if(!ph) {
  3613. ph = world.GetPlayerHouseByInstanceID(client->GetCurrentZone()->GetInstanceID());
  3614. }
  3615. if (ph && sep && sep->IsNumber(1))
  3616. {
  3617. int64 outValCoin = strtoull(sep->arg[1], NULL, 0);
  3618. int32 outValStatus = 0;
  3619. if(sep->IsNumber(2))
  3620. {
  3621. outValStatus = strtoull(sep->arg[2], NULL, 0);
  3622. if(outValStatus > client->GetPlayer()->GetInfoStruct()->get_status_points())
  3623. outValStatus = 0; // cheat check
  3624. }
  3625. if ((!outValCoin && outValStatus) || client->GetPlayer()->RemoveCoins(outValCoin))
  3626. {
  3627. if(outValStatus)
  3628. client->GetPlayer()->GetInfoStruct()->subtract_status_points(outValStatus);
  3629. char query[256];
  3630. map<string,Deposit>::iterator itr = ph->depositsMap.find(string(client->GetPlayer()->GetName()));
  3631. if (itr != ph->depositsMap.end())
  3632. {
  3633. snprintf(query, 256, "update character_house_deposits set timestamp = %u, amount = amount + %llu, last_amount = %llu, status = status + %u, last_status = %u where house_id = %u and instance_id = %u and name='%s'", Timer::GetUnixTimeStamp(), outValCoin, outValCoin, outValStatus, outValStatus, ph->house_id, ph->instance_id, client->GetPlayer()->GetName());
  3634. }
  3635. else
  3636. snprintf(query, 256, "insert into character_house_deposits set timestamp = %u, house_id = %u, instance_id = %u, name='%s', amount = %llu, status = %u", Timer::GetUnixTimeStamp(), ph->house_id, ph->instance_id, client->GetPlayer()->GetName(), outValCoin, outValStatus);
  3637. if (database.RunQuery(query, strnlen(query, 256)))
  3638. {
  3639. ph->escrow_coins += outValCoin;
  3640. ph->escrow_status += outValStatus;
  3641. database.UpdateHouseEscrow(ph->house_id, ph->instance_id, ph->escrow_coins, ph->escrow_status);
  3642. database.LoadDeposits(ph);
  3643. client->PlaySound("coin_cha_ching");
  3644. HouseZone* hz = world.GetHouseZone(ph->house_id);
  3645. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetVersion() <= 546 ? spawn_id : client->GetPlayer()->GetID());
  3646. }
  3647. else
  3648. {
  3649. if(outValCoin)
  3650. client->GetPlayer()->AddCoins(outValCoin);
  3651. if(outValStatus)
  3652. client->GetPlayer()->GetInfoStruct()->add_status_points(outValStatus);
  3653. client->SimpleMessage(CHANNEL_COLOR_RED, "Deposit failed!");
  3654. }
  3655. }
  3656. }
  3657. break;
  3658. }
  3659. case COMMAND_HOUSE:
  3660. {
  3661. int32 spawn_id = 0;
  3662. if (sep && sep->IsNumber(0))
  3663. {
  3664. PlayerHouse* ph = nullptr;
  3665. if(!ph && sep && sep->arg[0]) {
  3666. spawn_id = atoul(sep->arg[0]);
  3667. ph = world.GetPlayerHouse(client, spawn_id, spawn_id, nullptr);
  3668. }
  3669. HouseZone* hz = 0;
  3670. if (ph)
  3671. hz = world.GetHouseZone(ph->house_id);
  3672. // there is a arg[1] that is true/false, but not sure what it is for investigate more later
  3673. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetVersion() <= 546 ? spawn_id : client->GetPlayer()->GetID());
  3674. }
  3675. else if (client->GetCurrentZone()->GetInstanceType() != 0)
  3676. {
  3677. // inside a house or something? Send the access window
  3678. PlayerHouse* ph = world.GetPlayerHouseByInstanceID(client->GetCurrentZone()->GetInstanceID());
  3679. HouseZone* hz = 0;
  3680. if ( ph )
  3681. hz = world.GetHouseZone(ph->house_id);
  3682. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetVersion() <= 546 ? spawn_id : client->GetPlayer()->GetID());
  3683. client->GetCurrentZone()->SendHouseItems(client);
  3684. }
  3685. break;
  3686. }
  3687. case COMMAND_HOUSE_UI:
  3688. {
  3689. if (sep && sep->IsNumber(0) && client->GetCurrentZone()->GetInstanceType() == Instance_Type::NONE)
  3690. {
  3691. int32 unique_id = atoi(sep->arg[0]);
  3692. PlayerHouse* ph = world.GetPlayerHouseByUniqueID(unique_id);
  3693. HouseZone* hz = 0;
  3694. if ( ph )
  3695. hz = world.GetHouseZone(ph->house_id);
  3696. // there is a arg[1] that is true/false, but not sure what it is for investigate more later
  3697. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  3698. }
  3699. break;
  3700. }
  3701. case COMMAND_PLACE_HOUSE_ITEM: {
  3702. if (sep && sep->IsNumber(0))
  3703. {
  3704. int32 uniqueid = atoi(sep->arg[0]);
  3705. Item* item = client->GetPlayer()->item_list.GetItemFromUniqueID(uniqueid);
  3706. //Item* item = player->GetEquipmentList()->GetItem(slot);
  3707. if (item && item->IsHouseItem())
  3708. {
  3709. if (!client->HasOwnerOrEditAccess())
  3710. {
  3711. client->SimpleMessage(CHANNEL_COLOR_RED, "This is not your home!");
  3712. break;
  3713. }
  3714. else if (!item->generic_info.appearance_id)
  3715. {
  3716. client->Message(CHANNEL_COLOR_RED, "This item has not been configured in the database, %s (%u) needs an entry where ?? has the model type id, eg. insert into item_appearances set item_id=%u,equip_type=??;", item->name.c_str(), item->details.item_id, item->details.item_id);
  3717. break;
  3718. }
  3719. else if(item->CheckFlag2(HOUSE_LORE) && client->GetCurrentZone()->HouseItemSpawnExists(item->details.item_id)) {
  3720. client->Message(CHANNEL_COLOR_RED, "Item %s is house lore and you cannot place another.", item->name.c_str());
  3721. break;
  3722. }
  3723. if (client->GetTempPlacementSpawn())
  3724. {
  3725. Spawn* tmp = client->GetTempPlacementSpawn();
  3726. client->GetCurrentZone()->RemoveSpawn(tmp, true, true, true, true, true);
  3727. client->SetTempPlacementSpawn(nullptr);
  3728. }
  3729. Object* obj = new Object();
  3730. Spawn* spawn = (Spawn*)obj;
  3731. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3732. strcpy(spawn->appearance.name, "temp");
  3733. spawn->SetX(client->GetPlayer()->GetX());
  3734. spawn->SetY(client->GetPlayer()->GetY());
  3735. spawn->SetZ(client->GetPlayer()->GetZ());
  3736. spawn->appearance.pos.collision_radius = 32;
  3737. spawn->SetHeading(client->GetPlayer()->GetHeading());
  3738. spawn->SetSpawnOrigX(spawn->GetX());
  3739. spawn->SetSpawnOrigY(spawn->GetY());
  3740. spawn->SetSpawnOrigZ(spawn->GetZ());
  3741. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  3742. spawn->appearance.targetable = 1;
  3743. spawn->appearance.activity_status = ACTIVITY_STATUS_SOLID;
  3744. spawn->appearance.race = item && item->generic_info.appearance_id ? item->generic_info.appearance_id : 1472;
  3745. spawn->SetModelType(item && item->generic_info.appearance_id ? item->generic_info.appearance_id : 1472);
  3746. spawn->SetLocation(client->GetPlayer()->GetLocation());
  3747. spawn->SetZone(client->GetCurrentZone());
  3748. client->SetTempPlacementSpawn(spawn);
  3749. client->SetPlacementUniqueItemID(uniqueid);
  3750. client->GetCurrentZone()->AddSpawn(spawn);
  3751. }
  3752. }
  3753. break;
  3754. }
  3755. case COMMAND_GM:
  3756. {
  3757. if (sep && sep->arg[0] && sep->arg[1])
  3758. {
  3759. bool onOff = (strcmp(sep->arg[1], "on") == 0);
  3760. if (strcmp(sep->arg[0], "vision") == 0)
  3761. {
  3762. client->GetPlayer()->SetGMVision(onOff);
  3763. #if defined(__GNUC__)
  3764. database.insertCharacterProperty(client, CHAR_PROPERTY_GMVISION, (onOff) ? (char*)"1" : (char*)"0");
  3765. #else
  3766. database.insertCharacterProperty(client, CHAR_PROPERTY_GMVISION, (onOff) ? "1" : "0");
  3767. #endif
  3768. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3769. if (onOff)
  3770. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Vision Enabled!");
  3771. else
  3772. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Vision Disabled!");
  3773. }
  3774. else if (strcmp(sep->arg[0], "tag") == 0)
  3775. {
  3776. int32 value = 0;
  3777. int16 tag_icon = 0;
  3778. // groundspawn has special exception -1 argument so it needs to be handled here
  3779. if(sep->arg[2] && sep->arg[3] && ((tag_icon = atoul(sep->arg[3])) > 0) || (strncasecmp(sep->arg[1], "groundspawn", 11) == 0)) {
  3780. value = atoul(sep->arg[2]);
  3781. if(strncasecmp(sep->arg[1], "faction", 7) == 0){
  3782. if(!value) {
  3783. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid faction id.");
  3784. break;
  3785. }
  3786. if(!tag_icon) {
  3787. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid tag icon id.");
  3788. break;
  3789. }
  3790. client->GetPlayer()->AddGMVisualFilter(GMTagFilterType::GMFILTERTYPE_FACTION, value, "", tag_icon);
  3791. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3792. client->Message(CHANNEL_COLOR_RED, "Adding faction id %u with tag icon %u.", value, tag_icon);
  3793. }
  3794. else if(strncasecmp(sep->arg[1], "spawngroup", 10) == 0){
  3795. if(value>0) {
  3796. value = 1;
  3797. }
  3798. if(!tag_icon) {
  3799. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid tag icon id.");
  3800. break;
  3801. }
  3802. client->GetPlayer()->AddGMVisualFilter(GMTagFilterType::GMFILTERTYPE_SPAWNGROUP, value, "", tag_icon);
  3803. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3804. client->Message(CHANNEL_COLOR_RED, "Adding spawn group tag \"%s\" with tag icon %u.", (value == 1) ? "on" : "off", tag_icon);
  3805. }
  3806. else if(strncasecmp(sep->arg[1], "race", 4 == 0)){
  3807. if(!value) {
  3808. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid race id.");
  3809. break;
  3810. }
  3811. if(!tag_icon) {
  3812. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid tag icon id.");
  3813. break;
  3814. }
  3815. client->GetPlayer()->AddGMVisualFilter(GMTagFilterType::GMFILTERTYPE_RACE, value, "", tag_icon);
  3816. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3817. client->Message(CHANNEL_COLOR_RED, "Adding race id %u with tag icon %u.", value, tag_icon);
  3818. }
  3819. else if(strncasecmp(sep->arg[1], "groundspawn", 11) == 0){
  3820. // one less argument value field not tag_icon for this one
  3821. if(!value) {
  3822. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid tag icon id.");
  3823. break;
  3824. }
  3825. client->GetPlayer()->AddGMVisualFilter(GMTagFilterType::GMFILTERTYPE_GROUNDSPAWN, 1, "", value);
  3826. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3827. client->Message(CHANNEL_COLOR_RED, "Adding groundspawns with tag icon %u.", value);
  3828. }
  3829. }
  3830. else {
  3831. if(strncasecmp(sep->arg[1], "clear", 5) == 0){
  3832. client->GetPlayer()->ClearGMVisualFilters();
  3833. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Tags Cleared!");
  3834. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3835. }
  3836. else {
  3837. client->SimpleMessage(CHANNEL_COLOR_RED, "GM Tagging Missing Arguments:");
  3838. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/gm tag [type] [value] [visual_icon_display]");
  3839. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/gm tag clear - Clears all GM visual tags");
  3840. client->SimpleMessage(CHANNEL_COLOR_RED, "Visual Type Options:");
  3841. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "type: faction, value: faction id of spawn(s)");
  3842. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "type: spawngroup, value: 1 to show grouped, 0 to show not grouped");
  3843. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "type: race, value: race id (either against base race or race id in spawn details)");
  3844. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "type: groundspawn, value: (not used)");
  3845. client->SimpleMessage(CHANNEL_COLOR_RED, "Visual Icon Options:");
  3846. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3847. "1 = skull, 2 = shield half dark blue / half light blue, 3 = purple? star, 4 = yellow sword, 5 = red X, 6 = green flame");
  3848. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3849. "7 = Number \"1\", 8 = Number \"2\", 9 = Number \"3\", 10 = Number \"4\", 11 = Number \"5\", 12 = Number \"6\"");
  3850. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3851. "25 = shield, 26 = green plus, 27 = crossed swords, 28 = bow with arrow in it, 29 = light blue lightning bolt");
  3852. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3853. "30 = bard instrument (hard to see), 31 = writ with shield, 32 = writ with green +, 33 = writ with crossed sword");
  3854. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3855. "34 = writ with bow, 35 = writ with light blue lightning bolt, 36 = same as 30, 37 = party with crossed sword, shield and lightning bolt");
  3856. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3857. "38 = shaking hands green background, 39 = shaking hands dark green background, unlocked keylock");
  3858. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3859. "40 = red aura icon with black shadow of person and big red aura, 41 = green aura icon with black shadow of person big green aura");
  3860. }
  3861. }
  3862. }
  3863. else if (strcmp(sep->arg[0], "regiondebug") == 0)
  3864. {
  3865. client->SetRegionDebug(onOff);
  3866. #if defined(__GNUC__)
  3867. database.insertCharacterProperty(client, CHAR_PROPERTY_REGIONDEBUG, (onOff) ? (char*)"1" : (char*)"0");
  3868. #else
  3869. database.insertCharacterProperty(client, CHAR_PROPERTY_REGIONDEBUG, (onOff) ? "1" : "0");
  3870. #endif
  3871. if (onOff)
  3872. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Region Debug Enabled!");
  3873. else
  3874. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Region Debug Disabled!");
  3875. }
  3876. else if (strcmp(sep->arg[0], "sight") == 0)
  3877. {
  3878. if(onOff && cmdTarget) {
  3879. client->SetPlayerPOVGhost(cmdTarget);
  3880. }
  3881. else
  3882. client->SetPlayerPOVGhost(nullptr);
  3883. }
  3884. else if (strcmp(sep->arg[0], "controleffects") == 0)
  3885. {
  3886. if(cmdTarget && cmdTarget->IsEntity()) {
  3887. ((Entity*)cmdTarget)->SendControlEffectDetailsToClient(client);
  3888. }
  3889. else {
  3890. client->GetPlayer()->SendControlEffectDetailsToClient(client);
  3891. }
  3892. }
  3893. else if (strcmp(sep->arg[0], "luadebug") == 0)
  3894. {
  3895. client->SetLuaDebugClient(onOff);
  3896. #if defined(__GNUC__)
  3897. database.insertCharacterProperty(client, CHAR_PROPERTY_LUADEBUG, (onOff) ? (char*)"1" : (char*)"0");
  3898. #else
  3899. database.insertCharacterProperty(client, CHAR_PROPERTY_LUADEBUG, (onOff) ? "1" : "0");
  3900. #endif
  3901. if (onOff)
  3902. {
  3903. if (lua_interface)
  3904. lua_interface->UpdateDebugClients(client);
  3905. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will now receive LUA error messages.");
  3906. }
  3907. else
  3908. {
  3909. if (lua_interface)
  3910. lua_interface->RemoveDebugClients(client);
  3911. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will no longer receive LUA error messages.");
  3912. }
  3913. }
  3914. }
  3915. break;
  3916. }
  3917. case COMMAND_ATTACK:
  3918. case COMMAND_AUTO_ATTACK:{
  3919. int8 type = 1;
  3920. bool update = false;
  3921. Player* player = client->GetPlayer();
  3922. if(!player)
  3923. break;
  3924. bool incombat = player->EngagedInCombat();
  3925. if(sep && sep->arg[0] && sep->IsNumber(0))
  3926. type = atoi(sep->arg[0]);
  3927. if(!client->GetPlayer()->Alive()){
  3928. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  3929. break;
  3930. }
  3931. if(type == 0){
  3932. if(incombat)
  3933. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You stop fighting.");
  3934. player->StopCombat(type);
  3935. update = true;
  3936. }
  3937. else {
  3938. if(type == 2){
  3939. player->InCombat(false);
  3940. if(incombat && player->GetRangeAttack()){
  3941. player->StopCombat(type);
  3942. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You stop fighting.");
  3943. update = true;
  3944. }
  3945. else{
  3946. player->SetRangeAttack(true);
  3947. player->InCombat(true, true);
  3948. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You start fighting.");
  3949. update = true;
  3950. }
  3951. }
  3952. else {
  3953. player->InCombat(false, true);
  3954. player->SetRangeAttack(false);
  3955. player->InCombat(true);
  3956. if(!incombat) {
  3957. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You start fighting.");
  3958. update = true;
  3959. }
  3960. }
  3961. /*else
  3962. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You cannot attack that!");*/
  3963. }
  3964. if(update) {
  3965. player->SetCharSheetChanged(true);
  3966. }
  3967. break;
  3968. }
  3969. case COMMAND_DEPOP:{
  3970. bool allow_respawns = false;
  3971. if(sep && sep->arg[0] && sep->IsNumber(0)){
  3972. if(atoi(sep->arg[0]) == 1)
  3973. allow_respawns = true;
  3974. }
  3975. client->GetCurrentZone()->Depop(allow_respawns);
  3976. break;
  3977. }
  3978. case COMMAND_REPOP:{
  3979. client->GetCurrentZone()->Depop(false, true);
  3980. break;
  3981. }
  3982. case COMMAND_BUYBACK:{
  3983. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  3984. // 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
  3985. int64 id = atoi64(sep->arg[0]);
  3986. // get the first int32, the item id
  3987. //int32 item_id = (int32)id;
  3988. // get the second int32, the unique id
  3989. int32 unique_id = (int32)(id>>32);
  3990. int8 quantity = atoi(sep->arg[1]);
  3991. if(quantity == 255)
  3992. quantity = 1;
  3993. client->BuyBack(unique_id, quantity);
  3994. }
  3995. break;
  3996. }
  3997. case COMMAND_MERCHANT_BUY:{
  3998. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  3999. int32 item_id = atoul(sep->arg[0]);
  4000. int8 quantity = atoi(sep->arg[1]);
  4001. client->BuyItem(item_id, quantity);
  4002. }
  4003. else
  4004. Command_SendMerchantWindow(client, sep);
  4005. break;
  4006. }
  4007. case COMMAND_MERCHANT_SELL:{
  4008. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  4009. // 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
  4010. int64 id = atoi64(sep->arg[0]);
  4011. // get the first int32, the item id
  4012. int32 item_id = (int32)id;
  4013. // get the second int32, the unique id
  4014. int32 unique_id = (int32)(id>>32);
  4015. int8 quantity = atoi(sep->arg[1]);
  4016. LogWrite(MERCHANT__DEBUG, 0, "Merchant", "Selling Item: Item Id = %ul, unique id = %ul, Quantity = %i", item_id, unique_id, quantity);
  4017. client->SellItem(item_id, quantity, unique_id);
  4018. }
  4019. break;
  4020. }
  4021. case COMMAND_MENDER_REPAIR: {
  4022. if (sep && sep->arg[0] && sep->IsNumber(0))
  4023. client->RepairItem(atoul(sep->arg[0]));
  4024. break;
  4025. }
  4026. case COMMAND_MENDER_REPAIR_ALL: {
  4027. client->RepairAllItems();
  4028. break;
  4029. }
  4030. case COMMAND_CANCEL_MERCHANT:{
  4031. client->SetMerchantTransaction(0);
  4032. break;
  4033. }
  4034. case COMMAND_START_MERCHANT:{
  4035. break;
  4036. }
  4037. case COMMAND_INVULNERABLE:{
  4038. sint8 val = -1;
  4039. if(sep && sep->arg[0] && sep->IsNumber(0)){
  4040. val = atoi(sep->arg[0]);
  4041. //devn00b: Fix for linux builds
  4042. #if defined(__GNUC__)
  4043. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? (char*) "1" : (char*) "0");
  4044. #else
  4045. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  4046. #endif
  4047. // database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  4048. client->GetPlayer()->SetInvulnerable(val==1);
  4049. if(client->GetPlayer()->GetInvulnerable())
  4050. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are now invulnerable!");
  4051. else
  4052. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are no longer invulnerable!");
  4053. }
  4054. if(val == -1)
  4055. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /invulnerable [0/1]");
  4056. break;
  4057. }
  4058. case COMMAND_REPAIR: {
  4059. Spawn* spawn = cmdTarget;
  4060. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR) {
  4061. client->SendHailCommand(spawn);
  4062. client->SetMerchantTransaction(spawn);
  4063. client->SendRepairList();
  4064. }
  4065. break;
  4066. }
  4067. case COMMAND_LOTTO: {
  4068. Spawn* spawn = cmdTarget;
  4069. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_LOTTO) {
  4070. client->SetMerchantTransaction(spawn);
  4071. client->ShowLottoWindow();
  4072. }
  4073. break;
  4074. }
  4075. case COMMAND_ACCEPT_REWARD:{
  4076. int32 unknown = 0;
  4077. int32 selectable_item_id = 0;
  4078. //Quest *quest = 0;
  4079. /* no idea what the first argument is for (faction maybe?)
  4080. if the reward has a selectable item reward, it's sent as the second argument
  4081. if neither of these are included in the reward, there is no sep
  4082. 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
  4083. only 1 quest or collection reward may be displayed at a time */
  4084. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  4085. unknown = atoul(sep->arg[0]);
  4086. selectable_item_id = atoul(sep->arg[1]);
  4087. }
  4088. /* this logic here may seem unexpected, but the quest queue response for GetPendingQuestAcceptance is only populated if it is the current reward displayed to the client based on a quest
  4089. ** Otherwise it will likely be a DoF client scenario (pending item rewards, selectable item rewards) which is specifying an item id
  4090. ** lastly it will be a collection which also supplies an item id and you can only have one pending collection turn in at a time (they queue against Client::HandInCollections
  4091. */
  4092. int32 item_id = 0;
  4093. if(sep && sep->arg[0][0] && sep->IsNumber(0))
  4094. item_id = atoul(sep->arg[0]);
  4095. bool collectedItems = client->GetPlayer()->AcceptQuestReward(item_id, selectable_item_id);
  4096. if (collectedItems) {
  4097. EQ2Packet* outapp = client->GetPlayer()->SendInventoryUpdate(client->GetVersion());
  4098. if (outapp)
  4099. client->QueuePacket(outapp);
  4100. }
  4101. else
  4102. LogWrite(COMMAND__ERROR, 0, "Command", "Error in COMMAND_ACCEPT_REWARD. No pending quest or collection reward was found (unknown=%u).", unknown);
  4103. break;
  4104. }
  4105. case COMMAND_BUY_FROM_BROKER:{
  4106. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  4107. int32 item_id = atoul(sep->arg[0]);
  4108. int16 quantity = atoul(sep->arg[1]);
  4109. Item* item = master_item_list.GetItem(item_id);
  4110. if(item && item->generic_info.max_charges > 1)
  4111. quantity = item->generic_info.max_charges;
  4112. client->AddItem(item_id, quantity, AddItemType::BUY_FROM_BROKER);
  4113. }
  4114. break;
  4115. }
  4116. case COMMAND_SEARCH_STORES_PAGE:{
  4117. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  4118. int32 page = atoul(sep->arg[0]);
  4119. client->SearchStore(page);
  4120. }
  4121. break;
  4122. }
  4123. case COMMAND_SEARCH_STORES:{
  4124. if(sep && sep->arg[0][0]){
  4125. const char* values = sep->argplus[0];
  4126. if(values){
  4127. LogWrite(ITEM__WARNING, 0, "Item", "SearchStores: %s", values);
  4128. map<string, string> str_values = TranslateBrokerRequest(values);
  4129. vector<Item*>* items = master_item_list.GetItems(str_values, client);
  4130. if(items){
  4131. client->SetItemSearch(items);
  4132. client->SearchStore(0);
  4133. }
  4134. }
  4135. }
  4136. break;
  4137. }
  4138. case COMMAND_LUADEBUG:{
  4139. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "start") == 0){
  4140. client->SetLuaDebugClient(true);
  4141. if(lua_interface)
  4142. lua_interface->UpdateDebugClients(client);
  4143. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will now receive LUA error messages.");
  4144. }
  4145. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "stop") == 0){
  4146. client->SetLuaDebugClient(false);
  4147. if(lua_interface)
  4148. lua_interface->RemoveDebugClients(client);
  4149. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will no longer receive LUA error messages.");
  4150. }
  4151. else{
  4152. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /luadebug {start | stop}");
  4153. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will allow you to receive lua debug messages normally seen only in the console.");
  4154. }
  4155. break;
  4156. }
  4157. case COMMAND_SPAWN_GROUP:
  4158. {
  4159. Spawn* target = cmdTarget;
  4160. if(target && target->IsPlayer() == false)
  4161. {
  4162. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "create") == 0)
  4163. {
  4164. if(target->GetSpawnLocationPlacementID() > 0)
  4165. {
  4166. if(sep->arg[1] && !sep->IsNumber(1) && strlen(sep->arg[1]) > 0)
  4167. {
  4168. int32 id = database.CreateSpawnGroup(target, sep->arg[1]);
  4169. if(id > 0)
  4170. client->Message(CHANNEL_COLOR_YELLOW, "Successfully created new spawn group with id: %u", id);
  4171. else
  4172. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error creating group, check console for details.");
  4173. target->SetSpawnGroupID(id);
  4174. target->AddSpawnToGroup(target);
  4175. }
  4176. else
  4177. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group create [name]");
  4178. }
  4179. else
  4180. 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.");
  4181. }
  4182. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "add") == 0)
  4183. {
  4184. if(sep->arg[1] && sep->IsNumber(1))
  4185. {
  4186. int32 group_id = atoul(sep->arg[1]);
  4187. Spawn* leader = client->GetCurrentZone()->GetSpawnGroup(group_id);
  4188. if(leader)
  4189. {
  4190. leader->AddSpawnToGroup(target);
  4191. target->SetSpawnGroupID(group_id);
  4192. if(database.SpawnGroupAddSpawn(target, group_id))
  4193. client->Message(CHANNEL_COLOR_YELLOW, "Successfully added '%s' to group id: %u", target->GetName(), group_id);
  4194. else
  4195. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error adding spawn to group, check console for details.");
  4196. }
  4197. else
  4198. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No spawns found in the current zone for that spawn group, be sure to use '/spawn group create' first!");
  4199. }
  4200. else
  4201. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group add [group id]");
  4202. }
  4203. else if(target->GetSpawnGroupID() == 0)
  4204. {
  4205. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That spawn is not in a group!");
  4206. }
  4207. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "remove") == 0)
  4208. {
  4209. int32 group_id = target->GetSpawnGroupID();
  4210. target->RemoveSpawnFromGroup();
  4211. if(database.SpawnGroupRemoveSpawn(target, group_id))
  4212. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed '%s' from group id: %u", target->GetName(), group_id);
  4213. else
  4214. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing spawn from group, check console for details.");
  4215. }
  4216. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "associate") == 0)
  4217. {
  4218. int32 group_id = target->GetSpawnGroupID();
  4219. if(sep->arg[1] && sep->IsNumber(1))
  4220. {
  4221. if(database.SpawnGroupAddAssociation(group_id, atoul(sep->arg[1])))
  4222. client->Message(CHANNEL_COLOR_YELLOW, "Successfully associated group id %u with group id %u", group_id, atoul(sep->arg[1]));
  4223. else
  4224. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error associating groups, check console for details.");
  4225. }
  4226. else
  4227. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Allows you to spawn only one associated group at once. Syntax: /spawn group associate [other group id]");
  4228. }
  4229. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "deassociate") == 0)
  4230. {
  4231. int32 group_id = target->GetSpawnGroupID();
  4232. if(sep->arg[1] && sep->IsNumber(1))
  4233. {
  4234. if(database.SpawnGroupRemoveAssociation(group_id, atoul(sep->arg[1])))
  4235. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed association between group id %u and group id %u", group_id, atoul(sep->arg[1]));
  4236. else
  4237. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing group associations, check console for details.");
  4238. }
  4239. else
  4240. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Removes previous group associations. Syntax: /spawn group deassociate [other group id]");
  4241. }
  4242. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "chance") == 0)
  4243. {
  4244. if(sep->arg[1] && sep->IsNumber(1))
  4245. {
  4246. if(database.SetGroupSpawnChance(target->GetSpawnGroupID(), atof(sep->arg[1])))
  4247. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set group spawn chance to %f for group id: %u", atof(sep->arg[1]), target->GetSpawnGroupID());
  4248. else
  4249. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error setting group spawn chance, check console for details.");
  4250. }
  4251. else
  4252. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group chance [group's spawn chance percentage]");
  4253. }
  4254. else
  4255. {
  4256. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command allows you to modify spawn groups.");
  4257. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group [create/add/remove/chance/associate/deassociate]");
  4258. }
  4259. }
  4260. else
  4261. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select a valid spawn to use this command.");
  4262. break;
  4263. }
  4264. case COMMAND_SPAWN_COMBINE:{
  4265. Spawn* spawn = cmdTarget;
  4266. float radius = 0;
  4267. bool failed = true;
  4268. if(spawn && !spawn->IsPlayer() && sep && sep->arg[0] && sep->arg[0][0]){
  4269. failed = false;
  4270. if(spawn->GetSpawnGroupID() > 0){
  4271. 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.");
  4272. }
  4273. else if(sep->IsNumber(0)){
  4274. radius = atof(sep->arg[0]);
  4275. client->CombineSpawns(radius, spawn);
  4276. }
  4277. else{
  4278. if(strncasecmp(sep->arg[0], "add", 3) == 0){
  4279. client->AddCombineSpawn(spawn);
  4280. }
  4281. else if(strncasecmp(sep->arg[0], "remove", 6) == 0){
  4282. client->RemoveCombineSpawn(spawn);
  4283. }
  4284. else if(strncasecmp(sep->arg[0], "save", 4) == 0){
  4285. const char* name = 0;
  4286. if(sep->arg[1] && sep->arg[1][0])
  4287. name = sep->argplus[1];
  4288. client->SaveCombineSpawns(name);
  4289. }
  4290. else
  4291. failed = true;
  4292. }
  4293. }
  4294. if(failed){
  4295. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command combines several spawns into a single spawn group.");
  4296. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn combine [radius/add/remove/save]");
  4297. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Ex: /spawn combine 1, /spawn combine save (spawn group name)");
  4298. }
  4299. break;
  4300. }
  4301. case COMMAND_SPAWN_CREATE:{
  4302. Spawn* spawn = 0;
  4303. if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "object", 6) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  4304. spawn = new Object();
  4305. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  4306. }
  4307. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "groundspawn", 11) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  4308. spawn = new GroundSpawn();
  4309. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  4310. }
  4311. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "sign", 4) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  4312. spawn = new Sign();
  4313. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  4314. }
  4315. else if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "npc", 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  4316. spawn = new NPC();
  4317. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  4318. spawn->appearance.pos.collision_radius = 32;
  4319. spawn->secondary_command_list_id = 0;
  4320. spawn->primary_command_list_id = 0;
  4321. spawn->appearance.display_name = 1;
  4322. spawn->appearance.show_level = 1;
  4323. spawn->appearance.attackable = 1;
  4324. }
  4325. else{
  4326. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn create [spawn type] [race type] [class type] [level] [name] (difficulty) (size)");
  4327. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are required except difficulty and size. Valid types are Object, NPC, Sign, or GroundSpawn");
  4328. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn create npc 203 1 50 'Lady Vox' 1 32");
  4329. break;
  4330. }
  4331. spawn->SetID(Spawn::NextID());
  4332. spawn->SetX(client->GetPlayer()->GetX());
  4333. spawn->SetY(client->GetPlayer()->GetY());
  4334. spawn->SetZ(client->GetPlayer()->GetZ());
  4335. spawn->SetHeading(client->GetPlayer()->GetHeading());
  4336. spawn->SetSpawnOrigX(spawn->GetX());
  4337. spawn->SetSpawnOrigY(spawn->GetY());
  4338. spawn->SetSpawnOrigZ(spawn->GetZ());
  4339. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  4340. if(spawn->IsSign())
  4341. {
  4342. ((Sign*)spawn)->SetSignType(SIGN_TYPE_GENERIC);
  4343. ((Sign*)spawn)->SetSignDistance(20.0f);
  4344. ((Sign*)spawn)->SetIncludeLocation(1);
  4345. ((Sign*)spawn)->SetIncludeHeading(1);
  4346. ((Sign*)spawn)->SetInitialState(1);
  4347. ((Sign*)spawn)->SetSignTitle(sep->arg[4]);
  4348. ((Sign*)spawn)->SetActivityStatus(64);
  4349. spawn->appearance.race = 0;
  4350. spawn->SetLevel(0);
  4351. spawn->SetHP(0);
  4352. spawn->SetTotalHP(0);
  4353. spawn->SetPower(0);
  4354. spawn->SetTotalPower(0);
  4355. spawn->SetDifficulty(0);
  4356. spawn->SetTargetable(0);
  4357. spawn->SetSogaModelType(0);
  4358. spawn->SetCollisionRadius(19);
  4359. ((Sign*)spawn)->SetWidgetX(client->GetPlayer()->GetX());
  4360. ((Sign*)spawn)->SetWidgetY(client->GetPlayer()->GetY());
  4361. ((Sign*)spawn)->SetWidgetZ(client->GetPlayer()->GetZ());
  4362. spawn->SetLocation(client->GetPlayer()->GetLocation());
  4363. spawn->appearance.model_type = atoul(sep->arg[1]);
  4364. }
  4365. else
  4366. {
  4367. spawn->appearance.targetable = 1;
  4368. spawn->appearance.race = 255;
  4369. spawn->SetLocation(client->GetPlayer()->GetLocation());
  4370. spawn->SetModelType(atoi(sep->arg[1]));
  4371. spawn->SetAdventureClass(atoi(sep->arg[2]));
  4372. spawn->SetLevel(atoi(sep->arg[3]));
  4373. spawn->SetName(sep->arg[4]);
  4374. if(sep->arg[5][0] && sep->IsNumber(5))
  4375. spawn->SetDifficulty(atoi(sep->arg[5]));
  4376. if(sep->arg[6][0] && sep->IsNumber(6))
  4377. spawn->size = atoi(sep->arg[6]);
  4378. if(spawn->GetTotalHP() == 0){
  4379. spawn->SetTotalHP(25*spawn->GetLevel() + 1);
  4380. spawn->SetHP(25*spawn->GetLevel() + 1);
  4381. }
  4382. if(spawn->GetTotalPower() == 0){
  4383. spawn->SetTotalPower(25*spawn->GetLevel() + 1);
  4384. spawn->SetPower(25*spawn->GetLevel() + 1);
  4385. }
  4386. }
  4387. client->GetCurrentZone()->AddSpawn(spawn);
  4388. break;
  4389. }
  4390. case COMMAND_SPAWN_EQUIPMENT:{
  4391. Spawn* spawn = cmdTarget;
  4392. if(spawn && sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1) && spawn->IsEntity()){
  4393. int8 slot = atoi(sep->arg[0]);
  4394. int16 type = atoi(sep->arg[1]);
  4395. int8 red = 0;
  4396. int8 green = 0;
  4397. int8 blue = 0;
  4398. int8 h_red = 0;
  4399. int8 h_green = 0;
  4400. int8 h_blue = 0;
  4401. if(sep->arg[2])
  4402. red = atoi(sep->arg[2]);
  4403. if(sep->arg[3])
  4404. green = atoi(sep->arg[3]);
  4405. if(sep->arg[4])
  4406. blue = atoi(sep->arg[4]);
  4407. if(sep->arg[5])
  4408. h_red = atoi(sep->arg[5]);
  4409. if(sep->arg[6])
  4410. h_green = atoi(sep->arg[6]);
  4411. if(sep->arg[7])
  4412. h_blue = atoi(sep->arg[7]);
  4413. ((Entity*)spawn)->SetEquipment(slot, type, red, green, blue, h_red, h_green, h_blue);
  4414. database.SaveNPCAppearanceEquipment(spawn->GetDatabaseID() , slot, type, red, green, blue, h_red, h_green, h_blue);
  4415. }
  4416. else{
  4417. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn equipment [slot] [appearance id] (red) (green) (blue) (highlight red) (hgreen) (hblue)");
  4418. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn's equipment. ");
  4419. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Slot is 0-24, Appearance ID from appearances table, Colors are 0-255");
  4420. }
  4421. break;
  4422. }
  4423. case COMMAND_SPAWN_DETAILS: {
  4424. Spawn* spawn = cmdTarget;
  4425. if (sep && sep->arg[0][0]) {
  4426. if (cmdTarget)
  4427. {
  4428. if (ToLower(string(sep->arg[0])) == "los")
  4429. {
  4430. bool hasLOS = client->GetPlayer()->CheckLoS(cmdTarget);
  4431. if (hasLOS)
  4432. client->Message(CHANNEL_COLOR_YELLOW, "You have line of sight with %s", spawn->GetName());
  4433. else
  4434. client->Message(CHANNEL_COLOR_RED, "You DO NOT have line of sight with %s", spawn->GetName());
  4435. break;
  4436. }
  4437. else if (ToLower(string(sep->arg[0])) == "bestz")
  4438. {
  4439. glm::vec3 targPos(cmdTarget->GetX(), cmdTarget->GetZ(), cmdTarget->GetY());
  4440. float bestZ = client->GetPlayer()->FindDestGroundZ(targPos, cmdTarget->GetYOffset());
  4441. client->Message(CHANNEL_COLOR_YELLOW, "Best Z for %s is %f", spawn->GetName(), bestZ);
  4442. break;
  4443. }
  4444. else if (ToLower(string(sep->arg[0])) == "inwater")
  4445. {
  4446. if (cmdTarget->GetRegionMap() == nullptr)
  4447. client->SimpleMessage(CHANNEL_COLOR_RED, "No water map for zone.");
  4448. else
  4449. {
  4450. bool inWater = cmdTarget->InWater();
  4451. client->Message(CHANNEL_COLOR_YELLOW, "%s is %s.", cmdTarget->GetName(), inWater ? "in water" : "out of water");
  4452. }
  4453. break;
  4454. }
  4455. else if (ToLower(string(sep->arg[0])) == "inlava")
  4456. {
  4457. if (cmdTarget->GetRegionMap() == nullptr)
  4458. client->SimpleMessage(CHANNEL_COLOR_RED, "No region map for zone.");
  4459. else
  4460. {
  4461. bool inLava = cmdTarget->InLava();
  4462. client->Message(CHANNEL_COLOR_YELLOW, "%s is %s.", cmdTarget->GetName(), inLava ? "in lava" : "out of lava");
  4463. }
  4464. break;
  4465. }
  4466. else if (ToLower(string(sep->arg[0])) == "regions")
  4467. {
  4468. glm::vec3 targPos(cmdTarget->GetX(), cmdTarget->GetY(), cmdTarget->GetZ());
  4469. if (cmdTarget->GetRegionMap() == nullptr)
  4470. client->SimpleMessage(CHANNEL_COLOR_RED, "No region map for zone.");
  4471. else
  4472. {
  4473. cmdTarget->GetRegionMap()->IdentifyRegionsInGrid(client, targPos);
  4474. }
  4475. break;
  4476. }
  4477. else if (ToLower(string(sep->arg[0])) == "behind")
  4478. {
  4479. bool isBehind = client->GetPlayer()->BehindTarget(cmdTarget);
  4480. client->Message(CHANNEL_COLOR_YELLOW, "%s %s.", isBehind ? "YOU are behind" : "YOU are NOT behind", cmdTarget->GetName());
  4481. break;
  4482. }
  4483. else if (ToLower(string(sep->arg[0])) == "infront")
  4484. {
  4485. bool isBehind = client->GetPlayer()->InFrontSpawn(cmdTarget, client->GetPlayer()->GetX(), client->GetPlayer()->GetZ());
  4486. client->Message(CHANNEL_COLOR_YELLOW, "%s %s.", isBehind ? "YOU are infront of" : "YOU are NOT infront of", cmdTarget->GetName());
  4487. break;
  4488. }
  4489. else if (ToLower(string(sep->arg[0])) == "flank")
  4490. {
  4491. bool isFlanking = client->GetPlayer()->FlankingTarget(cmdTarget);
  4492. client->Message(CHANNEL_COLOR_YELLOW, "%s is %s.", isFlanking ? "YOU are flanking" : "YOU are NOT flanking", cmdTarget->GetName());
  4493. break;
  4494. }
  4495. else if (ToLower(string(sep->arg[0])) == "aggro")
  4496. {
  4497. if(cmdTarget->IsNPC() && ((NPC*)cmdTarget)->Brain()) {
  4498. ((NPC*)cmdTarget)->Brain()->SendEncounterList(client);
  4499. ((NPC*)cmdTarget)->Brain()->SendHateList(client);
  4500. }
  4501. else {
  4502. client->SimpleMessage(CHANNEL_COLOR_RED, "/spawn details aggro is for NPCs only!");
  4503. }
  4504. break;
  4505. }
  4506. else if (ToLower(string(sep->arg[0])) == "angle")
  4507. {
  4508. float spawnAngle = client->GetPlayer()->GetFaceTarget(cmdTarget->GetX(), cmdTarget->GetZ());
  4509. client->Message(CHANNEL_COLOR_YELLOW, "Angle %f between player %s and target %s", spawnAngle, client->GetPlayer()->GetTarget() ? client->GetPlayer()->GetTarget()->GetName() : client->GetPlayer()->GetName(), client->GetPlayer()->GetName());
  4510. break;
  4511. }
  4512. }
  4513. if (sep->IsNumber(0))
  4514. {
  4515. float radius = atof(sep->arg[0]);
  4516. if (!client->GetCurrentZone()->SendRadiusSpawnInfo(client, radius))
  4517. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No results in the radius were found.");
  4518. break;
  4519. }
  4520. }
  4521. if (spawn) {
  4522. const char* type = "NPC";
  4523. if (spawn->IsObject())
  4524. type = "Object";
  4525. else if (spawn->IsSign())
  4526. type = "Sign";
  4527. else if (spawn->IsWidget())
  4528. type = "Widget";
  4529. else if (spawn->IsGroundSpawn())
  4530. type = "GroundSpawn";
  4531. int16 race_type = race_types_list.GetRaceType(spawn->GetModelType());
  4532. int16 race_base_type = race_types_list.GetRaceBaseType(spawn->GetModelType());
  4533. char* category = race_types_list.GetRaceTypeCategory(spawn->GetModelType());
  4534. char* subcategory = race_types_list.GetRaceTypeSubCategory(spawn->GetModelType());
  4535. char* modelname = race_types_list.GetRaceTypeModelName(spawn->GetModelType());
  4536. client->Message(CHANNEL_COLOR_YELLOW, "Name: %s, %s ID: %u", spawn->GetName(), type, spawn->GetDatabaseID());
  4537. client->Message(CHANNEL_COLOR_YELLOW, "Last Name: %s, Sub-Title: %s, Prefix: %s, Suffix: %s", spawn->GetLastName(), spawn->GetSubTitle(), spawn->GetPrefixTitle(), spawn->GetSuffixTitle());
  4538. client->Message(CHANNEL_COLOR_YELLOW, "Spawn Location ID: %u, Spawn Group ID: %u", spawn->GetSpawnLocationID(), spawn->GetSpawnGroupID());
  4539. client->Message(CHANNEL_COLOR_YELLOW, "Faction ID: %u, Merchant ID: %u, Transporter ID: %u", spawn->GetFactionID(), spawn->GetMerchantID(), spawn->GetTransporterID());
  4540. client->Message(CHANNEL_COLOR_YELLOW, "Grid ID: %u", spawn->GetLocation());
  4541. client->Message(CHANNEL_COLOR_YELLOW, "Race: %i, Class: %i, Gender: %i", spawn->GetRace(), spawn->GetAdventureClass(), spawn->GetGender());
  4542. client->Message(CHANNEL_COLOR_YELLOW, "Level: %i, HP: %u / %u, Power: %u / %u", spawn->GetLevel(), spawn->GetHP(), spawn->GetTotalHP(), spawn->GetPower(), spawn->GetTotalPower());
  4543. 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());
  4544. client->Message(CHANNEL_COLOR_YELLOW, "Collision Radius: %i, Size: %i, Difficulty: %i, Heroic: %i", spawn->GetCollisionRadius(), spawn->GetSize(), spawn->GetDifficulty(), spawn->GetHeroic());
  4545. client->Message(CHANNEL_COLOR_YELLOW, "Targetable: %i, Show Name: %i, Attackable: %i, Show Level: %i", spawn->GetTargetable(), spawn->GetShowName(), spawn->GetAttackable(), spawn->GetShowLevel());
  4546. client->Message(CHANNEL_COLOR_YELLOW, "Show Command Icon: %i, Display Hand Icon: %i", spawn->GetShowCommandIcon(), spawn->GetShowHandIcon());
  4547. if (spawn->IsEntity()) {
  4548. 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());
  4549. 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());
  4550. }
  4551. client->Message(CHANNEL_COLOR_YELLOW, "Model Type: %i, Soga Race Type: %i, Race Type: %u, Race Base Type: %u, Race Category: %s (subcategory: %s), Model Name: %s.", spawn->GetModelType(), spawn->GetSogaModelType(), race_type, race_base_type, category, subcategory, modelname);
  4552. client->Message(CHANNEL_COLOR_YELLOW, "Primary Command Type: %u, Secondary Command Type: %u", spawn->GetPrimaryCommandListID(), spawn->GetSecondaryCommandListID());
  4553. 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());
  4554. 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);
  4555. if (spawn->IsNPC())
  4556. client->Message(CHANNEL_COLOR_YELLOW, "Randomize: %u", ((NPC*)spawn)->GetRandomize());
  4557. if (spawn->IsNPC()){
  4558. client->Message(CHANNEL_COLOR_YELLOW, "Heat Resist/Base: %u/%u",((NPC*)spawn)->GetHeatResistance(), ((NPC*)spawn)->GetHeatResistanceBase());
  4559. client->Message(CHANNEL_COLOR_YELLOW, "Cold Resist/Base: %u/%u",((NPC*)spawn)->GetColdResistance(), ((NPC*)spawn)->GetColdResistanceBase());
  4560. client->Message(CHANNEL_COLOR_YELLOW, "Magic Resist/Base: %u/%u",((NPC*)spawn)->GetMagicResistance(), ((NPC*)spawn)->GetMagicResistanceBase());
  4561. client->Message(CHANNEL_COLOR_YELLOW, "Mental Resist/Base: %u/%u",((NPC*)spawn)->GetMentalResistance(), ((NPC*)spawn)->GetMentalResistanceBase());
  4562. client->Message(CHANNEL_COLOR_YELLOW, "Divine Resist/Base: %u/%u",((NPC*)spawn)->GetDivineResistance(), ((NPC*)spawn)->GetDivineResistanceBase());
  4563. client->Message(CHANNEL_COLOR_YELLOW, "Disease Resist/Base: %u/%u",((NPC*)spawn)->GetDiseaseResistance(), ((NPC*)spawn)->GetDiseaseResistanceBase());
  4564. client->Message(CHANNEL_COLOR_YELLOW, "Poison Resist/Base: %u/%u",((NPC*)spawn)->GetPoisonResistance(), ((NPC*)spawn)->GetPoisonResistanceBase());
  4565. }
  4566. string details;
  4567. details += "\\#0000FFName: " + string(spawn->GetName()) + "\n";
  4568. details += "Type: " + string(type) + "\n";
  4569. details += "ID: " + to_string(spawn->GetDatabaseID()) + "\n";
  4570. details += "Last Name: " + string(spawn->GetLastName()) + "\n";
  4571. details += "Sub-Title: " + string(spawn->GetSubTitle()) + "\n";
  4572. details += "Prefix: " + string(spawn->GetPrefixTitle()) + "\n";
  4573. details += "Suffix: " + string(spawn->GetSuffixTitle()) + "\n";
  4574. details += "Race: " + to_string(spawn->GetRace()) + "\n";
  4575. details += "Class: " + to_string(spawn->GetAdventureClass()) + "\n";
  4576. details += "Gender: " + to_string(spawn->GetGender()) + "\n";
  4577. details += "Level: " + to_string(spawn->GetLevel()) + "\n";
  4578. details += "HP: " + to_string(spawn->GetHP()) + " / " + to_string(spawn->GetTotalHP()) + "(" + to_string(spawn->GetIntHPRatio()) + "%)\n";
  4579. details += "Power: " + to_string(spawn->GetPower()) + + " / " + to_string(spawn->GetTotalPower()) + "\n";
  4580. details += "Difficulty: " + to_string(spawn->GetDifficulty()) + "\n";
  4581. details += "Heroic: " + to_string(spawn->GetHeroic()) + "\n";
  4582. details += "Group ID: " + to_string(spawn->GetSpawnGroupID()) + "\n";
  4583. details += "Faction ID: " + to_string(spawn->GetFactionID()) + "\n";
  4584. details += "Merchant ID: " + to_string(spawn->GetMerchantID()) + "\n";
  4585. details += "Transport ID: " + to_string(spawn->GetTransporterID()) + "\n";
  4586. details += "Location ID: " + to_string(spawn->GetSpawnLocationID()) + "\n";
  4587. char x[16];
  4588. sprintf(x, "%.2f", spawn->GetX());
  4589. char y[16];
  4590. sprintf(y, "%.2f", spawn->GetY());
  4591. char z[16];
  4592. sprintf(z, "%.2f", spawn->GetZ());
  4593. details += "Location: " + string(x) + ", " + string(y) + ", " + string(z) + "\n";
  4594. string details2;
  4595. details2 += "Heading: " + to_string(spawn->GetHeading()) + "\n";
  4596. details2 += "Grid ID: " + to_string(spawn->GetLocation()) + "\n";
  4597. details2 += "Size: " + to_string(spawn->GetSize()) + "\n";
  4598. details2 += "Collision Radius: " + to_string(spawn->GetCollisionRadius()) + "\n";
  4599. details2 += "Respawn Time: " + to_string(spawn->GetRespawnTime()) + "\n";
  4600. details2 += "Targetable: " + to_string(spawn->GetTargetable()) + "\n";
  4601. details2 += "Show Name: " + to_string(spawn->GetShowName()) + "\n";
  4602. details2 += "Attackable: " + to_string(spawn->GetAttackable()) + "\n";
  4603. details2 += "Show Level: " + to_string(spawn->GetShowLevel()) + "\n";
  4604. details2 += "Show Command Icon: " + to_string(spawn->GetShowCommandIcon()) + "\n";
  4605. details2 += "Display Hand Icon: " + to_string(spawn->GetShowHandIcon()) + "\n";
  4606. details2 += "Model Type: " + to_string(spawn->GetModelType()) + "\n";
  4607. details2 += "Soga Race Type: " + to_string(spawn->GetSogaModelType()) + "\n";
  4608. details2 += "Race Type: " + to_string(race_type) + "\n";
  4609. details2 += "Race Base Type: " + to_string(race_base_type) + "\n";
  4610. details2 += "Race Category (Sub Category): " + std::string(category) + " (" + std::string(subcategory) + ")\n";
  4611. details2 += "Model Name: " + std::string(modelname) + "\n";
  4612. details2 += "Primary Command ID: " + to_string(spawn->GetPrimaryCommandListID()) + "\n";
  4613. details2 += "Secondary Cmd ID: " + to_string(spawn->GetSecondaryCommandListID()) + "\n";
  4614. details2 += "Visual State: " + to_string(spawn->GetVisualState()) + "\n";
  4615. details2 += "Action State: " + to_string(spawn->GetActionState()) + "\n";
  4616. details2 += "Mood State: " + to_string(spawn->GetMoodState()) + "\n";
  4617. details2 += "Initial State: " + to_string(spawn->GetInitialState()) + "\n";
  4618. details2 += "Activity Status: " + to_string(spawn->GetActivityStatus()) + "\n";
  4619. details2 += "Emote State: " + to_string(spawn->GetEmoteState()) + "\n";
  4620. string details3;
  4621. details3 += "Pitch: " + to_string(spawn->GetPitch()) + "\n";
  4622. details3 += "Roll: " + to_string(spawn->GetRoll()) + "\n";
  4623. details3 += "Hide Hood: " + to_string(spawn->appearance.hide_hood) + "\n";
  4624. details3 += "Speed: " + to_string(spawn->GetSpeed()) + "\n";
  4625. details3 += "BaseSpeed: " + to_string(spawn->GetBaseSpeed()) + "\n";
  4626. if(spawn->IsSign()) {
  4627. details3 += "Sign Language: " + to_string(((Sign*)spawn)->GetLanguage()) + "\n";
  4628. }
  4629. if(spawn->IsEntity())
  4630. {
  4631. Entity* ent = (Entity*)spawn;
  4632. details3 += "STR / STRBase: " + to_string(ent->GetInfoStruct()->get_str()) + " / " + to_string(ent->GetInfoStruct()->get_str_base()) + "\n";
  4633. details3 += "AGI / AGIBase: " + to_string(ent->GetInfoStruct()->get_agi()) + " / " + to_string(ent->GetInfoStruct()->get_agi_base()) + "\n";
  4634. details3 += "STA / STABase: " + to_string(ent->GetInfoStruct()->get_sta()) + " / " + to_string(ent->GetInfoStruct()->get_sta_base()) + "\n";
  4635. details3 += "INT / INTBase: " + to_string(ent->GetInfoStruct()->get_intel()) + " / " + to_string(ent->GetInfoStruct()->get_intel_base()) + "\n";
  4636. details3 += "WIS / WISBase: " + to_string(ent->GetInfoStruct()->get_wis()) + " / " + to_string(ent->GetInfoStruct()->get_wis_base()) + "\n";
  4637. }
  4638. string details4;
  4639. if (spawn->IsEntity()) {
  4640. details4 += "Facial Hair Type: " + to_string(((Entity*)spawn)->GetFacialHairType()) + "\n";
  4641. details4 += "Hair Type: " + to_string(((Entity*)spawn)->GetHairType()) + "\n";
  4642. details4 += "Chest Type: " + to_string(((Entity*)spawn)->GetChestType()) + "\n";
  4643. details4 += "Legs Type: " + to_string(((Entity*)spawn)->GetLegsType()) + "\n";
  4644. details4 += "Soga Facial Hair Type: " + to_string(((Entity*)spawn)->GetSogaFacialHairType()) + "\n";
  4645. details4 += "Soga Hair Type: " + to_string(((Entity*)spawn)->GetSogaHairType()) + "\n";
  4646. details4 += "Wing Type: " + to_string(((Entity*)spawn)->GetWingType()) + "\n";
  4647. if (spawn->IsNPC()) {
  4648. details4 += "\nRandomize: " + to_string(((NPC*)spawn)->GetRandomize()) + "\n";
  4649. }
  4650. }
  4651. const char* spawnScriptMsg = (spawn->GetSpawnScript() && strlen(spawn->GetSpawnScript())>0) ? spawn->GetSpawnScript() : "Not Set";
  4652. details4 += "\nSpawnScript: " + std::string(spawnScriptMsg) + "\n";
  4653. string title = string(spawn->GetName()) + "(" + to_string(spawn->GetDatabaseID()) + ")";
  4654. client->SendShowBook(client->GetPlayer(), title, 0, 4, details, details2, details3, details4);
  4655. }
  4656. else {
  4657. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn details (radius)");
  4658. 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.");
  4659. }
  4660. break;
  4661. }
  4662. case COMMAND_SPAWN_TARGET:{
  4663. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  4664. int32 spawn_id = atoul(sep->arg[0]);
  4665. int16 response = client->GetCurrentZone()->SetSpawnTargetable(spawn_id);
  4666. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  4667. }
  4668. else if(sep && sep->arg[0][0] && sep->arg[1][0] && sep->IsNumber(1) && ToLower(string(sep->arg[0])) == "radius"){
  4669. float distance = atof(sep->arg[1]);
  4670. int16 response = client->GetCurrentZone()->SetSpawnTargetable(client->GetPlayer(), distance);
  4671. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  4672. }
  4673. else{
  4674. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn target [spawn id]");
  4675. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn as targetable. Used to change a spawn if it was set to untargetable.");
  4676. }
  4677. break;
  4678. }
  4679. case COMMAND_SPAWN_SET:
  4680. {
  4681. Spawn* spawn = cmdTarget;
  4682. sint16 set_type = -1;
  4683. string type_str;
  4684. if (spawn)
  4685. {
  4686. // check if parameters are (location or list or not player and not a 2nd param), and that there is at least 1 value
  4687. 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)
  4688. {
  4689. // set the type, which will be 0 if location or list or invalid
  4690. set_type = spawn_set_values[ToLower(string(sep->arg[0]))];
  4691. }
  4692. if(set_type > 0)
  4693. {
  4694. // check if spawn set is NOT a char update, or not location, or isn't a number
  4695. if(!(set_type >= SPAWN_SET_VALUE_PREFIX) && !(set_type <= SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL) && 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)
  4696. {
  4697. client->SimpleMessage(CHANNEL_COLOR_RED, "Invalid value for set command.");
  4698. }
  4699. else
  4700. {
  4701. string name = string(spawn->GetName());
  4702. bool customSetSpawn = false;
  4703. if(set_type >= SPAWN_SET_CHEEK_TYPE && set_type <= SPAWN_SET_SOGA_NOSE_TYPE)
  4704. {
  4705. int8 index = sep->IsNumber(2) ? atoul(sep->arg[2]) : 0;
  4706. // override the standard setspawncommand, we pass arguments different!
  4707. if(SetSpawnCommand(client, spawn, set_type, sep->arg[1], true, false, nullptr, index))
  4708. customSetSpawn = true;
  4709. }
  4710. if(customSetSpawn || SetSpawnCommand(client, spawn, set_type, sep->argplus[1]))
  4711. {
  4712. if (set_type == SPAWN_SET_VALUE_EXPANSION_FLAG || set_type == SPAWN_SET_VALUE_HOLIDAY_FLAG)
  4713. {
  4714. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "A /reload spawns is required to properly update the spawns with the xpack/holiday flag.");
  4715. }
  4716. else if (set_type == SPAWN_SET_VALUE_NAME)
  4717. {
  4718. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "New name will not be effective until zone reload.");
  4719. }
  4720. else if (set_type == SPAWN_SET_SKIN_COLOR || (set_type >= SPAWN_SET_HAIR_COLOR1 && set_type <= SPAWN_SET_SOGA_EYE_COLOR))
  4721. {
  4722. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set color field to R G B: %s.", sep->argplus[1]);
  4723. }
  4724. else if(set_type == SPAWN_SET_VALUE_LOCATION)
  4725. {
  4726. spawn->SetLocation(client->GetPlayer()->GetLocation());
  4727. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set '%s' to '%u' for spawn '%s' (DBID: %u)", sep->arg[0], client->GetPlayer()->GetLocation(), name.c_str(), spawn->GetDatabaseID());
  4728. }
  4729. else
  4730. {
  4731. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set '%s' to '%s' for spawn '%s' (DBID: %u)", sep->arg[0], sep->arg[1], name.c_str(), spawn->GetDatabaseID());
  4732. }
  4733. switch (set_type)
  4734. {
  4735. case SPAWN_SET_VALUE_EXPANSION_FLAG:
  4736. case SPAWN_SET_VALUE_HOLIDAY_FLAG:
  4737. case SPAWN_SET_VALUE_FACTION:
  4738. case SPAWN_SET_AAXP_REWARDS:
  4739. case SPAWN_SET_CHEEK_TYPE:
  4740. case SPAWN_SET_CHIN_TYPE:
  4741. case SPAWN_SET_EAR_TYPE:
  4742. case SPAWN_SET_EYE_BROW_TYPE:
  4743. case SPAWN_SET_EYE_TYPE:
  4744. case SPAWN_SET_LIP_TYPE:
  4745. case SPAWN_SET_NOSE_TYPE:
  4746. case SPAWN_SET_BODY_SIZE:
  4747. case SPAWN_SET_BODY_AGE:
  4748. case SPAWN_SET_SOGA_CHEEK_TYPE:
  4749. case SPAWN_SET_SOGA_CHIN_TYPE:
  4750. case SPAWN_SET_SOGA_EAR_TYPE:
  4751. case SPAWN_SET_SOGA_EYE_BROW_TYPE:
  4752. case SPAWN_SET_SOGA_EYE_TYPE:
  4753. case SPAWN_SET_SOGA_LIP_TYPE:
  4754. case SPAWN_SET_SOGA_NOSE_TYPE:
  4755. case SPAWN_SET_SOGA_BODY_SIZE:
  4756. case SPAWN_SET_SOGA_BODY_AGE:
  4757. case SPAWN_SET_ATTACK_TYPE:
  4758. case SPAWN_SET_RACE_TYPE:
  4759. case SPAWN_SET_LOOT_TIER:
  4760. case SPAWN_SET_LOOT_DROP_TYPE:
  4761. case SPAWN_SET_SCARED_STRONG_PLAYERS:
  4762. {
  4763. // not applicable already ran db command
  4764. break;
  4765. }
  4766. default:
  4767. {
  4768. client->GetCurrentZone()->ApplySetSpawnCommand(client, spawn, set_type, sep->argplus[1]);
  4769. break;
  4770. }
  4771. }
  4772. 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))
  4773. {
  4774. if(spawn->GetSpawnLocationID() > 0 && database.UpdateSpawnLocationSpawns(spawn))
  4775. {
  4776. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information for spawn '%s' (DBID: %u)", name.c_str(), spawn->GetDatabaseID());
  4777. }
  4778. else if(spawn->GetSpawnLocationID() > 0)
  4779. {
  4780. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn information, see console window for details.");
  4781. }
  4782. }
  4783. else
  4784. {
  4785. if(spawn->GetDatabaseID() > 0 && database.SaveSpawnInfo(spawn))
  4786. {
  4787. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn for spawn '%s' (DBID: %u)", name.c_str(), spawn->GetDatabaseID());
  4788. }
  4789. else if(spawn->GetDatabaseID() > 0)
  4790. {
  4791. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn, see console window for details.");
  4792. }
  4793. }
  4794. }
  4795. }
  4796. }
  4797. else if(set_type == 0)
  4798. {
  4799. // /spawn set list - lists all possible attributes that can be changed with this command, 10 per line.
  4800. map<string, int8>::iterator itr;
  4801. int i=0;
  4802. string list;
  4803. for(itr = spawn_set_values.begin(); itr != spawn_set_values.end(); itr++, i++)
  4804. {
  4805. if(i==10)
  4806. {
  4807. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  4808. i = 0;
  4809. }
  4810. if(i>0)
  4811. {
  4812. list.append(", ").append(itr->first);
  4813. }
  4814. else
  4815. {
  4816. list = itr->first;
  4817. }
  4818. }
  4819. if(list.length() > 0)
  4820. {
  4821. // if 1 or more, display in client.
  4822. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  4823. }
  4824. }
  4825. else
  4826. {
  4827. // syntax fail
  4828. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn set [type] [value]");
  4829. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used to change various settings for the targeted NPC or Object.");
  4830. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "For a list of changeable settings use /spawn set list");
  4831. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Note: /spawn set location does not require a value. The client's current location is used.");
  4832. }
  4833. }
  4834. break;
  4835. }
  4836. case COMMAND_SPAWN_REMOVE:{
  4837. Spawn* spawn = cmdTarget;
  4838. if(spawn && !spawn->IsPlayer()){
  4839. if(spawn->GetSpawnLocationID() > 0){
  4840. string name = string(spawn->GetName());
  4841. int32 dbid = spawn->GetDatabaseID();
  4842. if(database.RemoveSpawnFromSpawnLocation(spawn)){
  4843. client->GetCurrentZone()->RemoveSpawn(spawn, true, false, true, true, true);
  4844. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed spawn from zone for spawn '%s' (DBID: %u)", name.c_str(), dbid);
  4845. }
  4846. else
  4847. client->SimpleMessage(CHANNEL_COLOR_RED, "Error removing spawn, see console window for details.");
  4848. }
  4849. else
  4850. client->SimpleMessage(CHANNEL_COLOR_RED, "This spawn does not have a spawn group associated with it");
  4851. }
  4852. else{
  4853. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn remove");
  4854. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for removing the targeted NPC or Object from the zone.");
  4855. }
  4856. break;
  4857. }
  4858. case COMMAND_SPAWN_LIST:{
  4859. if(sep && sep->arg[0][0]){
  4860. vector<string>* results = database.GetSpawnNameList(sep->argplus[0]);
  4861. vector<string>::iterator itr;
  4862. if(results){
  4863. for(itr=results->begin();itr!=results->end();itr++){
  4864. client->SimpleMessage(CHANNEL_COLOR_YELLOW, (*itr).c_str());
  4865. }
  4866. safe_delete(results);
  4867. }
  4868. else
  4869. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found. ");
  4870. }
  4871. else{
  4872. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn list [name]");
  4873. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Name can be a partial match.");
  4874. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn list Qeynos Guard");
  4875. }
  4876. break;
  4877. }
  4878. case COMMAND_SPAWN_ADD:{
  4879. Spawn* spawn = cmdTarget;
  4880. if(spawn && sep && sep->arg[1][0] && (sep->IsNumber(0) || strncasecmp(sep->arg[0], "new", 3) == 0)){
  4881. if(spawn->GetSpawnLocationID() > 0){
  4882. client->Message(CHANNEL_COLOR_RED, "This spawn already has a spawn group id of %u, use /spawn remove to reassign it", spawn->GetSpawnLocationID());
  4883. break;
  4884. }
  4885. if(spawn->GetDatabaseID() == 0){
  4886. if(database.SaveSpawnInfo(spawn)) {
  4887. char spawn_type[32];
  4888. memset(spawn_type, 0, sizeof(spawn_type));
  4889. if (spawn->IsNPC())
  4890. strncpy(spawn_type, "NPC", sizeof(spawn_type) - 1);
  4891. else if (spawn->IsObject())
  4892. strncpy(spawn_type, "Object", sizeof(spawn_type) - 1);
  4893. else if (spawn->IsSign())
  4894. strncpy(spawn_type, "Sign", sizeof(spawn_type) - 1);
  4895. else if (spawn->IsGroundSpawn())
  4896. strncpy(spawn_type, "GroundSpawn", sizeof(spawn_type) - 1);
  4897. else
  4898. strncpy(spawn_type, "Unknown", sizeof(spawn_type) - 1);
  4899. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information with a %s id of %u", spawn_type, spawn->GetDatabaseID());
  4900. }
  4901. else
  4902. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn information, see console window for details.");
  4903. }
  4904. int32 spawn_group_id = 0;
  4905. if(strncasecmp(sep->arg[0], "new", 3) == 0)
  4906. spawn_group_id = database.GetNextSpawnLocation();
  4907. else
  4908. spawn_group_id = atol(sep->arg[0]);
  4909. int8 percent = 100;
  4910. if(sep->arg[2] && sep->IsNumber(2))
  4911. percent = atoi(sep->arg[2]);
  4912. spawn->SetSpawnLocationID(spawn_group_id);
  4913. float x_offset = database.GetSpawnLocationPlacementOffsetX(spawn->GetSpawnLocationID());
  4914. float y_offset = database.GetSpawnLocationPlacementOffsetY(spawn->GetSpawnLocationID());
  4915. float z_offset = database.GetSpawnLocationPlacementOffsetZ(spawn->GetSpawnLocationID());
  4916. if(database.SaveSpawnEntry(spawn, sep->arg[1], percent, x_offset, y_offset, z_offset))
  4917. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn location with a spawn group of %u", spawn->GetSpawnLocationID());
  4918. else
  4919. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn location, see console window for details.");
  4920. }
  4921. else{
  4922. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn add [spawn group id] [spawn group name] (percentage)");
  4923. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for adding the targeted NPC or Object to the database.");
  4924. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can substitute new for [spawn group id] to create a new one.");
  4925. }
  4926. break;
  4927. }
  4928. case COMMAND_SPAWN:{
  4929. int32 id = 0;
  4930. Spawn* spawn = 0;
  4931. if(sep && sep->arg[0] && sep->IsNumber(0)){
  4932. id = atol(sep->arg[0]);
  4933. spawn = client->GetCurrentZone()->GetSpawn(id);
  4934. }
  4935. if(id > 0 && spawn && spawn->appearance.name[0] == 0)
  4936. id = 0;
  4937. if(!id || !spawn){
  4938. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn [spawn id] (x) (y) (z) (heading) (location)");
  4939. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are optional except the id. The spawn id must be in the database.");
  4940. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn 1 0 0 0 0");
  4941. safe_delete(sep);
  4942. return;
  4943. }
  4944. if(sep && sep->arg[1][0]){
  4945. float x = atof(sep->arg[1]);
  4946. spawn->appearance.pos.X = x;
  4947. }
  4948. else
  4949. spawn->SetX(client->GetPlayer()->GetX(), false);
  4950. if(sep && sep->arg[2][0]){
  4951. float y = atof(sep->arg[2]);
  4952. spawn->appearance.pos.Y = y;
  4953. }
  4954. else
  4955. spawn->SetY(client->GetPlayer()->GetY(), false);
  4956. if(sep && sep->arg[3][0]){
  4957. float z = atof(sep->arg[3]);
  4958. spawn->appearance.pos.Z = z;
  4959. }
  4960. else
  4961. spawn->SetZ(client->GetPlayer()->GetZ(), false);
  4962. if(sep && sep->arg[4][0]){
  4963. float heading = atof(sep->arg[4]);
  4964. spawn->SetHeading(heading);
  4965. }
  4966. else
  4967. spawn->SetHeading(client->GetPlayer()->GetHeading(), false);
  4968. spawn->SetSpawnOrigX(spawn->GetX());
  4969. spawn->SetSpawnOrigY(spawn->GetY());
  4970. spawn->SetSpawnOrigZ(spawn->GetZ());
  4971. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  4972. if(sep && sep->arg[5][0])
  4973. spawn->SetLocation(atoul(sep->arg[5]));
  4974. else
  4975. spawn->SetLocation(client->GetPlayer()->GetLocation());
  4976. if(spawn->IsNPC() && spawn->GetTotalHP() == 0){
  4977. spawn->SetTotalHP(spawn->GetLevel() * 15);
  4978. spawn->SetHP(spawn->GetTotalHP());
  4979. }
  4980. if(spawn->GetTotalPower() == 0){
  4981. spawn->SetTotalPower(spawn->GetLevel() * 15);
  4982. spawn->SetPower(spawn->GetTotalPower());
  4983. }
  4984. const char* script = world.GetSpawnScript(id);
  4985. if(script && lua_interface && lua_interface->GetSpawnScript(script) != 0)
  4986. spawn->SetSpawnScript(string(script));
  4987. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_PRESPAWN);
  4988. client->GetCurrentZone()->AddSpawn(spawn);
  4989. if(spawn->IsNPC())
  4990. spawn->GetZone()->AddLoot((NPC*)spawn);
  4991. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_SPAWN);
  4992. LogWrite(COMMAND__INFO, 0, "Command", "Received spawn command - Parms: %s", command_parms->data.c_str());
  4993. break;
  4994. }
  4995. case COMMAND_ADMINFLAG:
  4996. {
  4997. if(sep && sep->arg[0]){
  4998. sint16 tmp_status = database.GetCharacterAdminStatus(sep->arg[0]);
  4999. sint16 new_status = atoi(sep->arg[1]);
  5000. if(tmp_status == -10)
  5001. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character does not exist.");
  5002. else if(tmp_status >= client->GetAdminStatus())
  5003. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character has same or higher level status.");
  5004. else if (new_status > client->GetAdminStatus())
  5005. client->SimpleMessage(CHANNEL_ERROR, "Unable to flag character. Reason: New status is higher then your status.");
  5006. else{
  5007. Client* client2 = client->GetCurrentZone()->GetClientByName(sep->arg[0]);
  5008. if (!client2)
  5009. client2 = zone_list.GetClientByCharName(sep->arg[0]);
  5010. if(database.UpdateAdminStatus(sep->arg[0],new_status)) {
  5011. client->Message(CHANNEL_COLOR_YELLOW,"Character status updated to %i for %s.",new_status,sep->arg[0]);
  5012. if (client2) {
  5013. client2->SetAdminStatus(new_status);
  5014. client2->Message(CHANNEL_COLOR_YELLOW, "%s has set your admin status to %i.", client->GetPlayer()->GetName(), new_status);
  5015. }
  5016. }
  5017. else
  5018. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Unknown reason.");
  5019. }
  5020. }else{
  5021. sint16 status = database.GetCharacterAdminStatus(client->GetPlayer()->GetName());
  5022. if(status != client->GetAdminStatus())
  5023. {
  5024. client->Message(CHANNEL_COLOR_YELLOW,"Flag status was changed from %i to %i.",status,client->GetAdminStatus());
  5025. client->SetAdminStatus(status);
  5026. }
  5027. else
  5028. {
  5029. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /flag {name} {new_status}");
  5030. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Standard User: 0");
  5031. client->Message(CHANNEL_COLOR_YELLOW," Admin User: %i", status);
  5032. }
  5033. }
  5034. break;
  5035. }
  5036. case COMMAND_CANNEDEMOTE:{
  5037. client->GetCurrentZone()->HandleEmote(client->GetPlayer(), command_parms->data);
  5038. break;
  5039. }
  5040. case COMMAND_BROADCAST: {
  5041. if (sep && sep->arg[0])
  5042. zone_list.HandleGlobalBroadcast(sep->argplus[0]);
  5043. else
  5044. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /broadcast {message}");
  5045. break;
  5046. }
  5047. case COMMAND_ANNOUNCE: {
  5048. if (sep && sep->arg[0])
  5049. zone_list.HandleGlobalAnnouncement(sep->argplus[0]);
  5050. else
  5051. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /announce {message}");
  5052. break;
  5053. }
  5054. case COMMAND_RELOAD_ITEMS:{
  5055. LogWrite(COMMAND__INFO, 0, "Command", "Reloading items..");
  5056. int32 item_id = (sep && sep->arg[0]) ? atoul(sep->arg[0]) : 0;
  5057. if(item_id > 0) {
  5058. client->Message(CHANNEL_COLOR_YELLOW, "Reloading item %u based on /reload items [item_id].", item_id);
  5059. }
  5060. else {
  5061. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Started Reloading items (this might take a few minutes...)");
  5062. }
  5063. database.ReloadItemList(item_id);
  5064. if(!item_id) {
  5065. database.LoadMerchantInformation(); // we skip if there is only a reload of single item not all items
  5066. }
  5067. if(item_id > 0) {
  5068. client->Message(CHANNEL_COLOR_YELLOW, "Reloaded item %u.", item_id);
  5069. }
  5070. else {
  5071. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Finished Reloading items.");
  5072. }
  5073. break;
  5074. }
  5075. case COMMAND_ENABLE_ABILITY_QUE:{
  5076. EQ2Packet* app = client->GetPlayer()->GetSpellBookUpdatePacket(client->GetVersion());
  5077. if(app)
  5078. client->QueuePacket(app);
  5079. break;
  5080. }
  5081. case COMMAND_ITEMSEARCH:
  5082. case COMMAND_FROMBROKER:{
  5083. PacketStruct* packet = configReader.getStruct("WS_StartBroker", client->GetVersion());
  5084. if (packet) {
  5085. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  5086. //packet->setDataByName("unknown", 1);
  5087. packet->setDataByName("unknown2", 5, 0);
  5088. packet->setDataByName("unknown2", 20, 1);
  5089. packet->setDataByName("unknown2", 58, 3);
  5090. packet->setDataByName("unknown2", 40, 4);
  5091. client->QueuePacket(packet->serialize());
  5092. PacketStruct* packet2 = configReader.getStruct("WS_BrokerBags", client->GetVersion());
  5093. if (packet2) {
  5094. packet2->setDataByName("char_id", client->GetCharacterID());
  5095. client->QueuePacket(packet2->serialize()); //send this for now, needed to properly clear data
  5096. safe_delete(packet2);
  5097. }
  5098. safe_delete(packet);
  5099. }
  5100. break;
  5101. }
  5102. case COMMAND_ANIMTEST:{
  5103. PacketStruct* command_packet = configReader.getStruct("WS_CannedEmote", client->GetVersion());
  5104. if(command_packet){
  5105. int32 id = client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer());
  5106. if (cmdTarget)
  5107. id = client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget);
  5108. command_packet->setDataByName ( "spawn_id" , id);
  5109. int animID = 1;
  5110. if(sep && sep->arg[0] && sep->IsNumber(0))
  5111. animID = atoi(sep->arg[0]);
  5112. VisualState* vs = NULL;
  5113. if(animID == 0)
  5114. {
  5115. vs = visual_states.FindVisualState(sep->arg[0]);
  5116. }
  5117. char msg[128];
  5118. sprintf(msg,"Animation Test ID: %i",animID);
  5119. command_packet->setMediumStringByName ( "emote_msg" , msg );
  5120. if(vs != NULL)
  5121. command_packet->setDataByName ( "anim_type", vs->GetID ( ) );
  5122. else
  5123. command_packet->setDataByName ( "anim_type", animID );
  5124. command_packet->setDataByName ( "unknown0", 0 );
  5125. EQ2Packet* outapp = command_packet->serialize();
  5126. client->QueuePacket(outapp);
  5127. safe_delete(command_packet);
  5128. }
  5129. break;
  5130. }
  5131. case COMMAND_KICK:
  5132. {
  5133. if( sep == 0 || sep->arg[0] == 0)
  5134. {
  5135. client->SimpleMessage(CHANNEL_COLOR_RED, "/kick [name]");
  5136. }
  5137. else
  5138. {
  5139. Client* kickClient = zone_list.GetClientByCharName(string(sep->arg[0]));
  5140. if ( kickClient == client )
  5141. {
  5142. client->Message(CHANNEL_COLOR_RED, "You can't kick yourself!");
  5143. break;
  5144. }
  5145. else if(kickClient != NULL)
  5146. {
  5147. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  5148. if ( maxStatus >= client->GetAdminStatus( ) || kickClient->GetAdminStatus() >= client->GetAdminStatus() )
  5149. {
  5150. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  5151. break;
  5152. }
  5153. client->Message(CHANNEL_COLOR_RED, "Kicking %s...",sep->arg[0]);
  5154. kickClient->Disconnect();
  5155. }
  5156. else
  5157. {
  5158. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  5159. }
  5160. }
  5161. break;
  5162. }
  5163. case COMMAND_LOCK:
  5164. {
  5165. if( sep != NULL && sep->arg[0] != NULL && sep->IsNumber(0)){
  5166. int worldLocked = atoi(sep->arg[0]);
  5167. net.world_locked = worldLocked;
  5168. if ( worldLocked )
  5169. client->Message(CHANNEL_COLOR_YELLOW,"World server has been locked.");
  5170. else
  5171. client->Message(CHANNEL_COLOR_YELLOW,"World server has been unlocked.");
  5172. }
  5173. else
  5174. client->SimpleMessage(CHANNEL_COLOR_RED, "/lock [0/1]");
  5175. break;
  5176. }
  5177. case COMMAND_BAN:{
  5178. if( sep == 0 || sep->arg[0] == 0 || (sep->arg[1][0] != 0 && !sep->IsNumber(1) ) )
  5179. {
  5180. client->SimpleMessage(CHANNEL_COLOR_RED, "/ban [name] [permanent:0/1]");
  5181. }
  5182. else
  5183. {
  5184. Client* kickClient = zone_list.GetClientByCharName(sep->arg[0]);
  5185. if ( kickClient == client )
  5186. {
  5187. client->Message(CHANNEL_COLOR_RED, "You can't ban yourself!");
  5188. break;
  5189. }
  5190. else if(kickClient != NULL)
  5191. {
  5192. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  5193. if ( maxStatus > client->GetAdminStatus( ) ||
  5194. client->GetAdminStatus ( ) > kickClient->GetAdminStatus ( ) )
  5195. {
  5196. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  5197. break;
  5198. }
  5199. client->Message(CHANNEL_COLOR_RED, "Kicking & Banning %s...",sep->arg[0]);
  5200. int perm = atol(sep->arg[1]);
  5201. if ( perm == 1 )
  5202. database.UpdateAdminStatus(sep->arg[0],-2);
  5203. else
  5204. database.UpdateAdminStatus(sep->arg[0],-1);
  5205. kickClient->Disconnect();
  5206. }
  5207. else
  5208. {
  5209. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  5210. }
  5211. }
  5212. break;
  5213. }
  5214. case COMMAND_SET_COMBAT_VOICE:{
  5215. int32 value = 0;
  5216. if(sep && sep->arg[0] && sep->IsNumber(0))
  5217. value = atoi(sep->arg[0]);
  5218. client->GetPlayer()->SetCombatVoice(value);
  5219. break;
  5220. }
  5221. case COMMAND_SET_EMOTE_VOICE:{
  5222. int32 value = 0;
  5223. if(sep && sep->arg[0] && sep->IsNumber(0))
  5224. value = atoi(sep->arg[0]);
  5225. client->GetPlayer()->SetEmoteVoice(value);
  5226. break;
  5227. }
  5228. case COMMAND_GIVEITEM:{
  5229. if(sep && sep->arg[0][0] && sep->arg[0][1] && sep->IsNumber(1)){
  5230. Client* itemToClient = zone_list.GetClientByCharName(sep->arg[0]);
  5231. if ( itemToClient == NULL )
  5232. client->Message(CHANNEL_COLOR_YELLOW,"Could not find %s.",sep->arg[0]);
  5233. else
  5234. {
  5235. int32 item_id = atol(sep->arg[1]);
  5236. client->Message(CHANNEL_COLOR_YELLOW,"Gave %s item id %i.",sep->arg[0],item_id);
  5237. itemToClient->AddItem(item_id);
  5238. }
  5239. }
  5240. else
  5241. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /giveitem [name] [item_id]");
  5242. break;
  5243. }
  5244. case COMMAND_REPORT_BUG : { Command_ReportBug(client, sep); break; }
  5245. case COMMAND_INVENTORY : { Command_Inventory(client, sep, command); break; }
  5246. case COMMAND_WEAPONSTATS : { Command_WeaponStats(client); break; }
  5247. case COMMAND_SKILL :
  5248. case COMMAND_SKILL_ADD :
  5249. case COMMAND_SKILL_REMOVE :
  5250. case COMMAND_SKILL_LIST : { Command_Skills(client, sep, command->handler); break; }
  5251. case COMMAND_ZONE_SET : { Command_ZoneSet(client, sep); break; }
  5252. case COMMAND_ZONE_DETAILS : { Command_ZoneDetails(client, sep); break; }
  5253. case COMMAND_ENTITYCOMMAND :
  5254. case COMMAND_ENTITYCOMMAND_LIST : { Command_EntityCommand(client, sep, command->handler); break; }
  5255. case COMMAND_MERCHANT :
  5256. case COMMAND_MERCHANT_LIST : { Command_Merchant(client, sep, command->handler); break; }
  5257. case COMMAND_APPEARANCE :
  5258. case COMMAND_APPEARANCE_LIST : { Command_Appearance(client, sep, command->handler); break; }
  5259. case COMMAND_TRACK : { Command_Track(client); break; }
  5260. case COMMAND_DISTANCE : { Command_Distance(client); break; }
  5261. case COMMAND_INSPECT_PLAYER : { Command_InspectPlayer(client, sep); break; }
  5262. case COMMAND_ZONE_SAFE : { Command_ZoneSafeCoords(client, sep); break; }
  5263. case COMMAND_GUILDSAY : { Command_GuildSay(client, sep); break; }
  5264. case COMMAND_OFFICERSAY : { Command_OfficerSay(client, sep); break; }
  5265. case COMMAND_SET_GUILD_MEMBER_NOTE : { Command_SetGuildMemberNote(client, sep); break; }
  5266. case COMMAND_SET_GUILD_OFFICER_NOTE : { Command_SetGuildOfficerNote(client, sep); break; }
  5267. case COMMAND_GUILD : { Command_Guild(client, sep); break; }
  5268. case COMMAND_CREATE_GUILD : { Command_CreateGuild(client); break; }
  5269. case COMMAND_GUILDS : { Command_Guilds(client); break; }
  5270. case COMMAND_GUILDS_ADD : { Command_GuildsAdd(client, sep); break; }
  5271. case COMMAND_GUILDS_CREATE : { Command_GuildsCreate(client, sep); break; }
  5272. case COMMAND_GUILDS_DELETE : { Command_GuildsDelete(client, sep); break; }
  5273. case COMMAND_GUILDS_LIST : { Command_GuildsList(client); break; }
  5274. case COMMAND_GUILDS_REMOVE : { Command_GuildsRemove(client, sep); break; }
  5275. case COMMAND_CLAIM : { Command_Claim(client, sep); break; }
  5276. case COMMAND_CLEAR_ALL_QUEUED : { Command_ClearAllQueued(client); break; }
  5277. case COMMAND_LOCATION : { Command_Location(client); break; }
  5278. case COMMAND_LOCATION_ADD : { Command_LocationAdd(client, sep); break; }
  5279. case COMMAND_LOCATION_CREATE : { Command_LocationCreate(client, sep); break; }
  5280. case COMMAND_LOCATION_DELETE : { Command_LocationDelete(client, sep); break; }
  5281. case COMMAND_LOCATION_LIST : { Command_LocationList(client, sep); break; }
  5282. case COMMAND_LOCATION_REMOVE : { Command_LocationRemove(client, sep); break; }
  5283. case COMMAND_GRID : { Command_Grid(client, sep); break; }
  5284. case COMMAND_TRY_ON : { Command_TryOn(client, sep); break; }
  5285. case COMMAND_RANDOMIZE : { Command_Randomize(client, sep); break; }
  5286. case COMMAND_AFK : { Command_AFK(client, sep); break; }
  5287. case COMMAND_SHOW_CLOAK : { Command_ShowCloak(client, sep); break; }
  5288. case COMMAND_SHOW_HELM : { Command_ShowHelm(client, sep); break; }
  5289. case COMMAND_SHOW_HOOD : { Command_ShowHood(client, sep); break; }
  5290. case COMMAND_SHOW_HOOD_OR_HELM : { Command_ShowHoodHelm(client, sep); break; }
  5291. case COMMAND_SHOW_RANGED : { Command_ShowRanged(client, sep); break; }
  5292. case COMMAND_STOP_DRINKING : { Command_StopDrinking(client); break; }
  5293. case COMMAND_STOP_EATING : { Command_StopEating(client); break; }
  5294. case COMMAND_TOGGLE_ANONYMOUS : { Command_Toggle_Anonymous(client); break; }
  5295. case COMMAND_TOGGLE_AUTOCONSUME : { Command_Toggle_AutoConsume(client, sep); break; }
  5296. case COMMAND_TOGGLE_BONUS_EXP : { Command_Toggle_BonusXP(client); break; }
  5297. case COMMAND_TOGGLE_COMBAT_EXP : { Command_Toggle_CombatXP(client); break; }
  5298. case COMMAND_TOGGLE_GM_HIDE : { Command_Toggle_GMHide(client); break; }
  5299. case COMMAND_TOGGLE_GM_VANISH : { Command_Toggle_GMVanish(client); break; }
  5300. case COMMAND_TOGGLE_ILLUSIONS : { Command_Toggle_Illusions(client, sep); break; }
  5301. case COMMAND_TOGGLE_LFG : { Command_Toggle_LFG(client); break; }
  5302. case COMMAND_TOGGLE_LFW : { Command_Toggle_LFW(client); break; }
  5303. case COMMAND_TOGGLE_QUEST_EXP : { Command_Toggle_QuestXP(client); break; }
  5304. case COMMAND_TOGGLE_ROLEPLAYING : { Command_Toggle_Roleplaying(client); break; }
  5305. case COMMAND_TOGGLE_DUELS : { Command_Toggle_Duels(client); break; }
  5306. case COMMAND_TOGGLE_TRADES : { Command_Toggle_Trades(client); break; }
  5307. case COMMAND_TOGGLE_GUILDS : { Command_Toggle_Guilds(client); break; }
  5308. case COMMAND_TOGGLE_GROUPS : { Command_Toggle_Groups(client); break; }
  5309. case COMMAND_TOGGLE_RAIDS : { Command_Toggle_Raids(client); break; }
  5310. case COMMAND_TOGGLE_LON : { Command_Toggle_LON(client); break; }
  5311. case COMMAND_TOGGLE_VCINVITE : { Command_Toggle_VoiceChat(client); break; }
  5312. case COMMAND_CANCEL_MAINTAINED : { Command_CancelMaintained(client, sep); break; }
  5313. case COMMAND_MOTD : { Command_MOTD(client); break; }
  5314. case COMMAND_RANDOM : { Command_Random(client, sep); break; }
  5315. case COMMAND_CREATE : { Command_Create(client, sep); break; }
  5316. case COMMAND_CREATEFROMRECIPE : { Command_CreateFromRecipe(client, sep); break; }
  5317. case COMMAND_TITLE : { Command_Title(client); break; }
  5318. case COMMAND_TITLE_LIST : { Command_TitleList(client); break; }
  5319. case COMMAND_TITLE_SETPREFIX : { Command_TitleSetPrefix(client, sep); break; }
  5320. case COMMAND_TITLE_SETSUFFIX : { Command_TitleSetSuffix(client, sep); break; }
  5321. case COMMAND_TITLE_FIX : { Command_TitleFix(client, sep); break; }
  5322. case COMMAND_LANGUAGES : { Command_Languages(client, sep); break; }
  5323. case COMMAND_SET_LANGUAGE : { Command_SetLanguage(client, sep); break; }
  5324. case COMMAND_FOLLOW : { Command_Follow(client, sep); break; }
  5325. case COMMAND_STOP_FOLLOW : { Command_StopFollow(client, sep); break; }
  5326. case COMMAND_LASTNAME : { Command_LastName(client, sep); break; }
  5327. case COMMAND_CONFIRMLASTNAME : { Command_ConfirmLastName(client, sep); break; }
  5328. case COMMAND_PET : { Command_Pet(client, sep); break; }
  5329. case COMMAND_PETNAME : { Command_PetName(client, sep); break; }
  5330. case COMMAND_NAME_PET : { Command_NamePet(client, sep); break; }
  5331. case COMMAND_RENAME : { Command_Rename(client, sep); break; }
  5332. case COMMAND_CONFIRMRENAME : { Command_ConfirmRename(client, sep); break; }
  5333. case COMMAND_PETOPTIONS : { Command_PetOptions(client, sep); break; }
  5334. case COMMAND_START_TRADE : { Command_TradeStart(client, sep); break; }
  5335. case COMMAND_ACCEPT_TRADE : { Command_TradeAccept(client, sep); break; }
  5336. case COMMAND_REJECT_TRADE : { Command_TradeReject(client, sep); break; }
  5337. case COMMAND_CANCEL_TRADE : { Command_TradeCancel(client, sep); break; }
  5338. case COMMAND_SET_TRADE_COIN : { Command_TradeSetCoin(client, sep); break; }
  5339. case COMMAND_ADD_TRADE_COPPER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_COPPER); break; }
  5340. case COMMAND_ADD_TRADE_SILVER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_SILVER); break; }
  5341. case COMMAND_ADD_TRADE_GOLD : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_GOLD); break; }
  5342. case COMMAND_ADD_TRADE_PLAT : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_PLAT); break; }
  5343. case COMMAND_REMOVE_TRADE_COPPER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_COPPER); break; }
  5344. case COMMAND_REMOVE_TRADE_SILVER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_SILVER); break; }
  5345. case COMMAND_REMOVE_TRADE_GOLD : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_GOLD); break; }
  5346. case COMMAND_REMOVE_TRADE_PLAT : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_PLAT); break; }
  5347. case COMMAND_ADD_TRADE_ITEM : { Command_TradeAddItem(client, sep); break; }
  5348. case COMMAND_REMOVE_TRADE_ITEM : { Command_TradeRemoveItem(client, sep); break; }
  5349. case COMMAND_ACCEPT_ADVANCEMENT : { Command_AcceptAdvancement(client, sep); break; }
  5350. case COMMAND_DUEL : { Command_Duel(client, sep); break; }
  5351. case COMMAND_DUELBET : { Command_DuelBet(client, sep); break; }
  5352. case COMMAND_DUEL_ACCEPT : { Command_DuelAccept(client, sep); break; }
  5353. case COMMAND_DUEL_DECLINE : { Command_DuelDecline(client, sep); break; }
  5354. case COMMAND_DUEL_SURRENDER : { Command_DuelSurrender(client, sep); break; }
  5355. case COMMAND_DUEL_TOGGLE : { Command_DuelToggle(client, sep); break; }
  5356. case COMMAND_SPAWN_TEMPLATE : { Command_SpawnTemplate(client, sep); break; }
  5357. //devn00b
  5358. case COMMAND_MOOD : { Command_Mood(client, sep); break;}
  5359. case COMMAND_MODIFY : { Command_Modify(client); break; }
  5360. case COMMAND_MODIFY_CHARACTER : { Command_ModifyCharacter(client, sep); break; }
  5361. case COMMAND_MODIFY_QUEST : { Command_ModifyQuest(client, sep); break; }
  5362. case COMMAND_MODIFY_FACTION : { Command_ModifyFaction(client, sep); break; }
  5363. case COMMAND_MODIFY_GUILD : { Command_ModifyGuild(client, sep); break; }
  5364. case COMMAND_MODIFY_ITEM : { Command_ModifyItem(client, sep); break; }
  5365. case COMMAND_MODIFY_SKILL : { Command_ModifySkill(client, sep); break; }
  5366. case COMMAND_MODIFY_SPAWN : { Command_ModifySpawn(client, sep); break; }
  5367. case COMMAND_MODIFY_SPELL : { Command_ModifySpell(client, sep); break; }
  5368. case COMMAND_MODIFY_ZONE : { Command_ModifyZone(client, sep); break; }
  5369. case COMMAND_JOIN_CHANNEL : { Command_JoinChannel(client, sep); break;}
  5370. case COMMAND_JOIN_CHANNEL_FROM_LOAD: { Command_JoinChannelFromLoad(client, sep); break;}
  5371. case COMMAND_TELL_CHANNEL : { Command_TellChannel(client, sep); break;}
  5372. case COMMAND_LEAVE_CHANNEL : { Command_LeaveChannel(client, sep); break;}
  5373. case COMMAND_WHO_CHANNEL : { Command_WhoChannel(client, sep); break;}
  5374. case COMMAND_RAIN : { Command_Rain(client, sep); break; }
  5375. case COMMAND_WIND : { Command_Wind(client, sep); break; }
  5376. case COMMAND_WEATHER : { Command_Weather(client, sep); break; }
  5377. case COMMAND_FROM_MERCHANT : { Command_SendMerchantWindow(client, sep); break; }
  5378. case COMMAND_TO_MERCHANT : { Command_SendMerchantWindow(client, sep, true); break; }
  5379. case COMMAND_SELECT : { Command_Select(client, sep); break; }
  5380. case COMMAND_SMP : { Command_StationMarketPlace(client, sep); break; }
  5381. case COMMAND_CONSUME_FOOD : { Command_ConsumeFood(client, sep); break; }
  5382. case COMMAND_AQUAMAN : { Command_Aquaman(client, sep); break; }
  5383. case COMMAND_ATTUNE_INV : { Command_Attune_Inv(client, sep); break; }
  5384. case COMMAND_PLAYER : { Command_Player(client, sep); break; }
  5385. case COMMAND_PLAYER_COINS : { Command_Player_Coins(client, sep); break; }
  5386. case COMMAND_RESET_ZONE_TIMER : { Command_Reset_Zone_Timer(client, sep); break; }
  5387. case COMMAND_ACHIEVEMENT_ADD : { Command_AchievementAdd(client, sep); break; }
  5388. case COMMAND_EDITOR : { Command_Editor(client, sep); break; }
  5389. case COMMAND_ACCEPT_RESURRECTION: { Command_AcceptResurrection(client, sep); break; }
  5390. case COMMAND_DECLINE_RESURRECTION:{ Command_DeclineResurrection(client, sep); break; }
  5391. case COMMAND_TEST : { Command_Test(client, command_parms); break; }
  5392. case COMMAND_SPEED : { Command_Speed(client, sep); break; }
  5393. case COMMAND_BOT : { Command_Bot(client, sep); break; }
  5394. case COMMAND_BOT_CREATE : { Command_Bot_Create(client, sep); break; }
  5395. case COMMAND_BOT_CUSTOMIZE : { Command_Bot_Customize(client, sep); break; }
  5396. case COMMAND_BOT_SPAWN : { Command_Bot_Spawn(client, sep); break; }
  5397. case COMMAND_BOT_LIST : { Command_Bot_List(client, sep); break; }
  5398. case COMMAND_BOT_INV : { Command_Bot_Inv(client, sep); break; }
  5399. case COMMAND_BOT_SETTINGS : { Command_Bot_Settings(client, sep); break; }
  5400. case COMMAND_BOT_HELP : { Command_Bot_Help(client, sep); break; }
  5401. case GET_AA_XML : { Get_AA_Xml(client, sep); break; }
  5402. case ADD_AA : { Add_AA(client, sep); break; }
  5403. case COMMIT_AA_PROFILE : { Commit_AA_Profile(client, sep); break; }
  5404. case BEGIN_AA_PROFILE : { Begin_AA_Profile(client, sep); break; }
  5405. case BACK_AA : { Back_AA(client, sep); break; }
  5406. case REMOVE_AA : { Remove_AA(client, sep); break; }
  5407. case SWITCH_AA_PROFILE : { Switch_AA_Profile(client, sep); break; }
  5408. case CANCEL_AA_PROFILE : { Cancel_AA_Profile(client, sep); break; }
  5409. case SAVE_AA_PROFILE : { Save_AA_Profile(client, sep); break; }
  5410. case COMMAND_TARGETITEM : { Command_TargetItem(client, sep); break; }
  5411. case COMMAND_FINDSPAWN: { Command_FindSpawn(client, sep); break; }
  5412. case COMMAND_MOVECHARACTER: { Command_MoveCharacter(client, sep); break; }
  5413. case COMMAND_CRAFTITEM: {
  5414. Item* item = 0;
  5415. if (sep && sep->IsNumber(0)) {
  5416. int32 item_id = atol(sep->arg[0]);
  5417. int32 quantity = 1;
  5418. if (sep->arg[1] && sep->IsNumber(1))
  5419. quantity = atoi(sep->arg[1]);
  5420. item = new Item(master_item_list.GetItem(item_id));
  5421. if (!item) {
  5422. LogWrite(TRADESKILL__ERROR, 0, "CraftItem", "Item (%u) not found.", item_id);
  5423. }
  5424. else {
  5425. item->details.count = quantity;
  5426. // use CHANNEL_COLOR_CHAT_RELATIONSHIP as that is the same value (4) as it is in a log for this message
  5427. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You created %s.", item->CreateItemLink(client->GetVersion()).c_str());
  5428. bool itemDeleted = false;
  5429. client->AddItem(item, &itemDeleted);
  5430. //Check for crafting quest updates
  5431. int8 update_amt = 0;
  5432. if (!itemDeleted && item->stack_count > 1)
  5433. update_amt = 1;
  5434. else
  5435. update_amt = quantity;
  5436. if(!itemDeleted)
  5437. client->GetPlayer()->CheckQuestsCraftUpdate(item, update_amt);
  5438. }
  5439. }
  5440. else {
  5441. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /craftitem {item_id} [quantity] ");
  5442. }
  5443. break;
  5444. }
  5445. case COMMAND_UNMENTOR:
  5446. case COMMAND_MENTOR: {
  5447. client->GetPlayer()->MentorTarget();
  5448. break;
  5449. }
  5450. case COMMAND_CANCEL_EFFECT: { Command_CancelEffect(client, sep); break; }
  5451. case COMMAND_CUREPLAYER: { Command_CurePlayer(client, sep); break; }
  5452. case COMMAND_SHARE_QUEST: { Command_ShareQuest(client, sep); break; }
  5453. case COMMAND_YELL: { Command_Yell(client, sep); break; }
  5454. default:
  5455. {
  5456. LogWrite(COMMAND__WARNING, 0, "Command", "Unhandled command: %s", command->command.data.c_str());
  5457. break;
  5458. }
  5459. }
  5460. safe_delete(sep);
  5461. }
  5462. /******************** New COMMAND Handler Functions ********************/
  5463. /*
  5464. Started breaking apart the huge switch() for commands into sepErate
  5465. functions so it is easier to locate the blocks of code by command
  5466. -- JA 2012.03.03
  5467. */
  5468. // sample function header
  5469. /*
  5470. Function:
  5471. Purpose :
  5472. Params :
  5473. Dev :
  5474. Example :
  5475. */
  5476. //void Commands::Command()
  5477. //{
  5478. //}
  5479. /*
  5480. Function: Command_AcceptAdvancement()
  5481. Purpose : Player accepts a new advancement option
  5482. Params : Spell ID
  5483. Dev : Jabantiz
  5484. */
  5485. void Commands::Command_AcceptAdvancement(Client* client, Seperator* sep)
  5486. {
  5487. Player *player = client->GetPlayer();
  5488. if (sep && sep->IsSet(0)) {
  5489. TraitData* trait = master_trait_list.GetTrait(atoul(sep->arg[0]));
  5490. // Check to see if this is a trait or grandmaster training (traits are always new spells, training is always upgrades)
  5491. if (!player->HasSpell(trait->spellID, 0, true))
  5492. {
  5493. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  5494. player->AddSpellBookEntry(trait->spellID, trait->tier, player->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  5495. }
  5496. else
  5497. {
  5498. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  5499. int8 old_slot = player->GetSpellSlot(spell->GetSpellID());
  5500. player->RemoveSpellBookEntry(spell->GetSpellID());
  5501. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  5502. player->UnlockSpell(spell);
  5503. client->SendSpellUpdate(spell);
  5504. }
  5505. // Spell book update
  5506. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  5507. client->QueuePacket(master_trait_list.GetTraitListPacket(client));
  5508. }
  5509. }
  5510. /*
  5511. Function:
  5512. Purpose :
  5513. Params :
  5514. Dev :
  5515. Example :
  5516. */
  5517. void Commands::Command_AFK(Client* client, Seperator* sep)
  5518. {
  5519. Player* player = client->GetPlayer();
  5520. player->toggle_character_flag(CF_AFK);
  5521. client->Message(CHANNEL_COLOR_YELLOW,"You are %s afk.", client->GetPlayer()->get_character_flag(CF_AFK)?"now":"no longer");
  5522. if (player->get_character_flag(CF_AFK))
  5523. {
  5524. if (sep && sep->argplus[0])
  5525. player->SetAwayMessage("I am away from the keyboard, " + string(sep->argplus[0]));
  5526. else
  5527. player->SetAwayMessage("Sorry, I am A.F.K. (Away From Keyboard)");
  5528. string message = string(player->GetName()) + " is going afk.";
  5529. Spawn* target = player->GetTarget();
  5530. if (target && target != player)
  5531. {
  5532. message = string(player->GetName()) + " tells " + string(target->GetName()) + " that ";
  5533. player->GetGender() == 1 ? message += "he" : message += "she";
  5534. message += " is going afk.";
  5535. }
  5536. player->GetZone()->SimpleMessage(CHANNEL_COLOR_YELLOW, message.c_str(), player, 30);
  5537. }
  5538. }
  5539. /*
  5540. Function: Command_Appearance()
  5541. Purpose : Handles /appearance commands
  5542. Params : list
  5543. Dev : Scatman
  5544. Example : /appearance list
  5545. */
  5546. void Commands::Command_Appearance(Client* client, Seperator* sep, int handler)
  5547. {
  5548. if( handler == COMMAND_APPEARANCE )
  5549. {
  5550. // /appearance command by itself shows help (to be extended)
  5551. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  5552. return;
  5553. }
  5554. else if( handler == COMMAND_APPEARANCE_LIST )
  5555. {
  5556. // /appearance list command expects "name" param
  5557. if (sep && sep->arg[0])
  5558. {
  5559. const char* appearance_name = sep->argplus[0];
  5560. client->Message(CHANNEL_COLOR_YELLOW, "Listing appearances like '%s':", appearance_name);
  5561. vector<int16>* appearances = database.GetAppearanceIDsLikeName(string(appearance_name));
  5562. if (appearances)
  5563. {
  5564. vector<int16>::iterator itr;
  5565. for (itr = appearances->begin(); itr != appearances->end(); itr++)
  5566. {
  5567. int16 id = *itr;
  5568. string name = database.GetAppearanceName(id);
  5569. if (ToLower(name).find(ToLower(string(appearance_name))) < 0xFFFFFFFF)
  5570. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", name.c_str(), id);
  5571. }
  5572. safe_delete(appearances);
  5573. }
  5574. }
  5575. else // no param
  5576. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  5577. }
  5578. }
  5579. /*
  5580. Function: Command_Claim()
  5581. Purpose : Summon veteran rewards
  5582. Params : nothing = show claim window, any number claims that item.
  5583. Dev : devn00b
  5584. Example : /claim 0 (claims the 1st item added to the list claim[0])
  5585. */
  5586. void Commands::Command_Claim(Client* client, Seperator* sep)
  5587. {
  5588. //if we were passed a claim id
  5589. if (sep && sep->argplus[0] && sep->IsNumber(0))
  5590. {
  5591. int32 char_id = client->GetCharacterID();
  5592. int8 my_claim_id = atoi(sep->argplus[0]);
  5593. vector<ClaimItems> claim = database.LoadCharacterClaimItems(char_id);
  5594. Item* item = master_item_list.GetItem(claim[my_claim_id].item_id);
  5595. database.ClaimItem(char_id, item->details.item_id, client);
  5596. return;
  5597. }
  5598. else {
  5599. //if no arg just send the window.
  5600. client->ShowClaimWindow();
  5601. return;
  5602. }
  5603. return;
  5604. }
  5605. /*
  5606. Function: Command_ClearAllQueued()
  5607. Purpose :
  5608. Params :
  5609. Dev :
  5610. Example :
  5611. */
  5612. void Commands::Command_ClearAllQueued(Client* client)
  5613. {
  5614. ZoneServer* zone = client->GetPlayer()->GetZone();
  5615. if (zone && zone->GetSpellProcess())
  5616. zone->GetSpellProcess()->RemoveSpellFromQueue(client->GetPlayer());
  5617. }
  5618. /*
  5619. Function: Command_CancelMaintained()
  5620. Purpose : Cancels maintained spells
  5621. Params : Maintained Spell Index
  5622. Dev : Zcoretri
  5623. Example : /cancel_maintained 1 - would cancel the spell in slot 1 of Maintained Spells list
  5624. */
  5625. void Commands::Command_CancelMaintained(Client* client, Seperator* sep)
  5626. {
  5627. if (sep && sep->arg[0] && sep->IsNumber(0))
  5628. {
  5629. int32 spell_index = atoul(sep->arg[0]);
  5630. if(spell_index > 29)
  5631. return;
  5632. client->GetPlayer()->MMaintainedSpells.readlock(__FUNCTION__, __LINE__);
  5633. MaintainedEffects mEffects = client->GetPlayer()->GetInfoStruct()->maintained_effects[spell_index];
  5634. client->GetPlayer()->MMaintainedSpells.releasereadlock(__FUNCTION__, __LINE__);
  5635. if (!client->GetPlayer()->GetZone()->GetSpellProcess()->DeleteCasterSpell(mEffects.spell, "canceled", false))
  5636. client->Message(CHANNEL_COLOR_RED, "The maintained spell could not be cancelled.");
  5637. }
  5638. }
  5639. /*
  5640. Function: Command_Create()
  5641. Purpose : Handler for starting Tradeskilling table
  5642. Params :
  5643. Dev : Zcoretri
  5644. Example :
  5645. */
  5646. void Commands::Command_Create(Client* client, Seperator* sep)
  5647. {
  5648. PrintSep(sep, "COMMAND_CREATE");
  5649. client->ShowRecipeBook();
  5650. }
  5651. void Commands::Command_CreateFromRecipe(Client* client, Seperator* sep)
  5652. {
  5653. PrintSep(sep, "COMMAND_CREATEFROMRECIPE");
  5654. if (sep && sep->arg[0] && sep->IsNumber(0))
  5655. ClientPacketFunctions::SendCreateFromRecipe(client, atoul(sep->arg[0]));
  5656. }
  5657. /*
  5658. Function: Command_Distance()
  5659. Purpose : Displays distance from targeted spawn
  5660. Params :
  5661. Dev : Scatman
  5662. Example : /distance
  5663. */
  5664. void Commands::Command_Distance(Client* client)
  5665. {
  5666. Spawn* target = client->GetPlayer()->GetTarget();
  5667. if (target)
  5668. client->Message(CHANNEL_COLOR_YELLOW, "Your distance from %s is %f", target->GetName(), client->GetPlayer()->GetDistance(target));
  5669. else
  5670. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must have a spawn targeted to use /distance");
  5671. }
  5672. /*
  5673. Function: Command_Duel()
  5674. Purpose : Handle the /duel commands - not yet implemented
  5675. Params : unknown
  5676. Dev :
  5677. Example :
  5678. */
  5679. void Commands::Command_Duel(Client* client, Seperator* sep)
  5680. {
  5681. PrintSep(sep, "COMMAND_DUEL");
  5682. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Command");
  5683. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5684. }
  5685. /*
  5686. Function: Command_DuelBet()
  5687. Purpose : Handle the /duel commands - not yet implemented
  5688. Params : unknown
  5689. Dev :
  5690. Example :
  5691. */
  5692. void Commands::Command_DuelBet(Client* client, Seperator* sep)
  5693. {
  5694. PrintSep(sep, "COMMAND_DUELBET");
  5695. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Bet Command");
  5696. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5697. }
  5698. /*
  5699. Function: Command_DuelAccept()
  5700. Purpose : Handle the /duel commands - not yet implemented
  5701. Params : unknown
  5702. Dev :
  5703. Example :
  5704. */
  5705. void Commands::Command_DuelAccept(Client* client, Seperator* sep)
  5706. {
  5707. PrintSep(sep, "COMMAND_DUEL_ACCEPT");
  5708. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Accept Duel Command");
  5709. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5710. }
  5711. /*
  5712. Function: Command_DuelDecline()
  5713. Purpose : Handle the /duel commands - not yet implemented
  5714. Params : unknown
  5715. Dev :
  5716. Example :
  5717. */
  5718. void Commands::Command_DuelDecline(Client* client, Seperator* sep)
  5719. {
  5720. PrintSep(sep, "COMMAND_DUEL_DECLINE");
  5721. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Decline Duel Request Command");
  5722. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5723. }
  5724. /*
  5725. Function: Command_DuelSurrender()
  5726. Purpose : Handle the /duel commands - not yet implemented
  5727. Params : unknown
  5728. Dev :
  5729. Example :
  5730. */
  5731. void Commands::Command_DuelSurrender(Client* client, Seperator* sep)
  5732. {
  5733. PrintSep(sep, "COMMAND_DUEL_SURRENDER");
  5734. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Surrender Duel Command");
  5735. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5736. // JA, just messin around ;)
  5737. char surrender[64];
  5738. sprintf(surrender, "%s surrendered like a cowardly dog!", client->GetPlayer()->GetName());
  5739. zone_list.HandleGlobalAnnouncement(surrender);
  5740. }
  5741. /*
  5742. Function: Command_DuelToggle()
  5743. Purpose : Handle the /duel commands - not yet implemented
  5744. Params : unknown
  5745. Dev :
  5746. Example :
  5747. */
  5748. void Commands::Command_DuelToggle(Client* client, Seperator* sep)
  5749. {
  5750. PrintSep(sep, "COMMAND_DUEL");
  5751. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Commands");
  5752. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5753. }
  5754. /*
  5755. Function:
  5756. Purpose :
  5757. Params :
  5758. Dev :
  5759. Example :
  5760. */
  5761. void Commands::Command_EntityCommand(Client* client, Seperator* sep, int handler)
  5762. {
  5763. if( handler == COMMAND_ENTITYCOMMAND )
  5764. {
  5765. // /entitycommand command by itself shows help (to be extended)
  5766. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  5767. return;
  5768. }
  5769. else if( handler == COMMAND_ENTITYCOMMAND_LIST )
  5770. {
  5771. // /entitycommand list command expects "name" param
  5772. if (sep && sep->arg[0])
  5773. {
  5774. const char* entity_command_name = sep->argplus[0];
  5775. client->Message(CHANNEL_COLOR_YELLOW, "Listing entity commands like '%s':", entity_command_name);
  5776. map<int32, vector<EntityCommand*>*>* entity_command_list_all = client->GetCurrentZone()->GetEntityCommandListAll();
  5777. map<int32, vector<EntityCommand*>*>::iterator itr;
  5778. for (itr = entity_command_list_all->begin(); itr != entity_command_list_all->end(); itr++)
  5779. {
  5780. vector<EntityCommand*>* entity_command_list = itr->second;
  5781. vector<EntityCommand*>::iterator itr2;
  5782. for (itr2 = entity_command_list->begin(); itr2 != entity_command_list->end(); itr2++)
  5783. {
  5784. EntityCommand* entity_command = *itr2;
  5785. if (ToLower(entity_command->name).find(ToLower(string(entity_command_name))) < 0xFFFFFFFF)
  5786. 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);
  5787. }
  5788. }
  5789. }
  5790. else // no command name
  5791. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  5792. }
  5793. }
  5794. /*
  5795. Function: Command_Follow()
  5796. Purpose : Handle the /follow command - not yet implemented
  5797. Params :
  5798. Dev :
  5799. Example :
  5800. */
  5801. void Commands::Command_Follow(Client* client, Seperator* sep)
  5802. {
  5803. PrintSep(sep, "COMMAND_FOLLOW");
  5804. // flag to toggle if the players target is in the players group
  5805. bool targetInGroup = false;
  5806. // get a pointer to the players group
  5807. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  5808. // If the player has a group and has a target
  5809. if (gmi && client->GetPlayer()->GetTarget()) {
  5810. deque<GroupMemberInfo*>::iterator itr;
  5811. world.GetGroupManager()->GroupLock(__FUNCTION__, __LINE__);
  5812. PlayerGroup* group = world.GetGroupManager()->GetGroup(gmi->group_id);
  5813. if (group)
  5814. {
  5815. group->MGroupMembers.readlock(__FUNCTION__, __LINE__);
  5816. deque<GroupMemberInfo*>* members = group->GetMembers();
  5817. // Loop through the group members
  5818. for (itr = members->begin(); itr != members->end(); itr++) {
  5819. // If a group member matches a target
  5820. if ((*itr)->member && (*itr)->member == client->GetPlayer()->GetTarget()) {
  5821. // toggle the flag and break the loop
  5822. targetInGroup = true;
  5823. break;
  5824. }
  5825. }
  5826. group->MGroupMembers.releasereadlock(__FUNCTION__, __LINE__);
  5827. }
  5828. world.GetGroupManager()->ReleaseGroupLock(__FUNCTION__, __LINE__);
  5829. }
  5830. if (targetInGroup) {
  5831. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  5832. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You start to follow %s.", client->GetPlayer()->GetTarget()->GetName());
  5833. client->GetPlayer()->SetFollowTarget(client->GetPlayer()->GetTarget());
  5834. client->GetPlayer()->info_changed = true;
  5835. client->GetPlayer()->changed = true;
  5836. }
  5837. else
  5838. client->Message(CHANNEL_NARRATIVE, "You must first select a group member to follow.");
  5839. }
  5840. /*
  5841. Function: Command_StopFollow()
  5842. Purpose : Handle the /stop_follow command - not yet implemented
  5843. Params :
  5844. Dev :
  5845. Example :
  5846. */
  5847. void Commands::Command_StopFollow(Client* client, Seperator* sep)
  5848. {
  5849. PrintSep(sep, "COMMAND_STOP_FOLLOW");
  5850. if (client->GetPlayer()->GetFollowTarget()) {
  5851. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  5852. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You are no longer following %s", client->GetPlayer()->GetFollowTarget()->GetName());
  5853. client->GetPlayer()->SetFollowTarget(0);
  5854. client->GetPlayer()->info_changed = true;
  5855. client->GetPlayer()->changed = true;
  5856. }
  5857. }
  5858. /*
  5859. Function: Command_Grid()
  5860. Purpose : Show player's current Grid ID
  5861. Params :
  5862. Dev : Scatman
  5863. Example : /grid
  5864. */
  5865. void Commands::Command_Grid(Client* client, Seperator* sep)
  5866. {
  5867. if (client->GetPlayer()->GetMap() != nullptr) {
  5868. if(sep && sep->arg[0][0] && strncasecmp("spawns", sep->arg[0], 6) == 0) {
  5869. int32 grid = client->GetPlayer()->GetLocation();
  5870. if(sep->IsNumber(1))
  5871. grid = atoul(sep->arg[1]);
  5872. client->GetCurrentZone()->SendClientSpawnListInGrid(client, grid);
  5873. }
  5874. else {
  5875. client->Message(CHANNEL_COLOR_YELLOW, "Your Grid ID is %u", client->GetPlayer()->GetLocation());
  5876. auto loc = glm::vec3(client->GetPlayer()->GetX(), client->GetPlayer()->GetZ(), client->GetPlayer()->GetY());
  5877. uint32 GridID = 0;
  5878. uint32 WidgetID = 0;
  5879. float new_z = client->GetPlayer()->FindBestZ(loc, nullptr, &GridID, &WidgetID);
  5880. float minY = client->GetPlayer()->GetMap()->GetMinY();
  5881. float maxY = client->GetPlayer()->GetMap()->GetMaxY();
  5882. float minZ = client->GetPlayer()->GetMap()->GetMinZ();
  5883. float maxZ = client->GetPlayer()->GetMap()->GetMaxZ();
  5884. int32 grid_spawn_count = client->GetPlayer()->GetZone()->GetSpawnCountInGrid(GridID);
  5885. client->Message(CHANNEL_COLOR_YELLOW, "Grid result is %u, at EQ2 Y coordinate %f. Spawns on grid: %u. Min/Max Y %f/%f Z %f/%f. Widget ID: %u", GridID, new_z, grid_spawn_count, minY, maxY, minZ, maxZ, WidgetID);
  5886. }
  5887. }
  5888. }
  5889. /*
  5890. Function: Command_Guild()
  5891. Purpose : Handler for all UI-related guild commands
  5892. Dev : Scatman
  5893. */
  5894. void Commands::Command_Guild(Client* client, Seperator* sep)
  5895. {
  5896. Guild* guild = client->GetPlayer()->GetGuild();
  5897. if (sep && sep->GetMaxArgNum() > 0 && sep->arg[0])
  5898. {
  5899. const char* command = sep->arg[0];
  5900. int32 length = strlen(command);
  5901. LogWrite(COMMAND__DEBUG, 0, "Command", "Guild Command: %s", command);
  5902. if (strncmp(command, "rank_name", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && guild)
  5903. guild->SetRankName(atoi(sep->arg[1]), sep->argplus[2]);
  5904. else if (strncmp(command, "rank_permission", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  5905. guild->SetPermission(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  5906. else if (strncmp(command, "filter_event", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  5907. guild->SetEventFilter(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  5908. else if (strncmp(command, "kick", length) == 0 && sep->arg[1] && guild)
  5909. guild->KickGuildMember(client, sep->arg[1]);
  5910. else if (strncmp(command, "demote", length) == 0 && sep->arg[1] && guild)
  5911. guild->DemoteGuildMember(client, sep->arg[1]);
  5912. else if (strncmp(command, "promote", length) == 0 && sep->arg[1] && guild)
  5913. guild->PromoteGuildMember(client, sep->arg[1]);
  5914. else if (strncmp(command, "points", length) == 0 && guild)
  5915. {
  5916. if (sep->arg[1] && strncmp(sep->arg[1], "add", length) == 0)
  5917. {
  5918. if (sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  5919. {
  5920. float points = atof(sep->arg[2]);
  5921. const char* option = sep->arg[3];
  5922. const char* comment = sep->argplus[4];
  5923. if (strncmp(option, "all", strlen(option)) == 0)
  5924. guild->AddPointsToAll(client, points, comment);
  5925. else if (strncmp(option, "online", strlen(option)) == 0)
  5926. guild->AddPointsToAllOnline(client, points, comment);
  5927. else if (strncmp(option, "group", strlen(option)) == 0)
  5928. guild->AddPointsToGroup(client, points, comment);
  5929. else if (strncmp(option, "raid", strlen(option)) == 0)
  5930. guild->AddPointsToRaid(client, points, comment);
  5931. else
  5932. guild->AddPointsToGuildMember(client, points, option, comment);
  5933. }
  5934. }
  5935. else if (sep->arg[1] && strncmp(sep->arg[1], "view", strlen(sep->arg[1])) == 0 && sep->arg[2])
  5936. guild->ViewGuildMemberPoints(client, sep->arg[2]);
  5937. else
  5938. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild points command: %s", sep->argplus[0]);
  5939. }
  5940. else if (strncmp(command, "motd", length) == 0 && sep->arg[1] && guild)
  5941. guild->SetMOTD(sep->argplus[1]);
  5942. else if (strncmp(command, "recruiting", length) == 0 && guild)
  5943. {
  5944. if (sep->arg[1])
  5945. {
  5946. const char* option = sep->arg[1];
  5947. if (strncmp(option, "short_text", strlen(option)) == 0 && sep->arg[2])
  5948. guild->SetRecruitingShortDesc(sep->argplus[2]);
  5949. else if (strncmp(option, "long_text", strlen(option)) == 0 && sep->arg[2])
  5950. guild->SetRecruitingFullDesc(sep->argplus[2]);
  5951. else if (strncmp(option, "flag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  5952. guild->SetRecruitingFlag(atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  5953. else if (strncmp(option, "min_level", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  5954. guild->SetRecruitingMinLevel(atoi(sep->arg[2]));
  5955. else if (strncmp(option, "playstyle", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  5956. guild->SetRecruitingPlayStyle(atoi(sep->arg[2]));
  5957. else if (strncmp(option, "tag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && sep->IsNumber(3))
  5958. guild->SetRecruitingDescTag(atoi(sep->arg[2]), atoi(sep->arg[3]));
  5959. else if (strncmp(command, "recruiting", strlen(option)) == 0)
  5960. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_RECRUITING_FOR_GUILD, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  5961. else
  5962. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  5963. }
  5964. else
  5965. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  5966. }
  5967. else if (strncmp(command, "notify_online", length) == 0 && sep->arg[1] && guild)
  5968. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_NOTIFY_LOGINS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  5969. else if (strncmp(command, "event_privacy", length) == 0 && sep->arg[1] && guild)
  5970. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_DONT_GENERATE_EVENTS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  5971. else if (strncmp(command, "recruiter", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  5972. guild->SetGuildRecruiter(client, sep->arg[1], strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  5973. else if (strncmp(command, "recruiter_description", length) == 0 && sep->arg[1] && guild)
  5974. guild->SetGuildRecruiterDescription(client, sep->argplus[1]);
  5975. else if (strncmp(command, "lock_event", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  5976. guild->LockGuildEvent(atoul(sep->arg[1]), strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  5977. else if (strncmp(command, "delete_event", length) == 0 && sep->arg[1] && guild)
  5978. guild->DeleteGuildEvent(atoul(sep->arg[1]));
  5979. else if (strncmp(command, "invite", length) == 0 && guild)
  5980. {
  5981. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  5982. guild->InvitePlayer(client, sep->arg[1]);
  5983. else
  5984. {
  5985. Spawn* target = client->GetPlayer()->GetTarget();
  5986. if (target)
  5987. {
  5988. if (target->IsPlayer())
  5989. guild->InvitePlayer(client, target->GetName());
  5990. else
  5991. client->Message(CHANNEL_NARRATIVE, "%s is not a player.", target->GetName());
  5992. }
  5993. }
  5994. }
  5995. else if (strncmp(command, "accept", length) == 0)
  5996. {
  5997. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  5998. if (pgi && pgi->guild && pgi->invited_by)
  5999. pgi->guild->AddNewGuildMember(client, pgi->invited_by->GetName());
  6000. client->SetPendingGuildInvite(0);
  6001. }
  6002. else if (strncmp(command, "decline", length) == 0)
  6003. {
  6004. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  6005. if (pgi && pgi->guild && pgi->invited_by && pgi->invited_by->IsPlayer())
  6006. {
  6007. Client* client_inviter = ((Player*)pgi->invited_by)->GetClient();
  6008. if (client_inviter) {
  6009. client_inviter->Message(CHANNEL_NARRATIVE, "%s has declined your invitation to join %s.", client->GetPlayer()->GetName(), pgi->guild->GetName());
  6010. }
  6011. }
  6012. client->SetPendingGuildInvite(0);
  6013. }
  6014. else if (strncmp(command, "create", length) == 0 && sep->arg[1])
  6015. {
  6016. const char* guild_name = sep->argplus[1];
  6017. if (!guild_list.GetGuild(guild_name))
  6018. world.CreateGuild(guild_name, client, client->GetPlayer()->GetGroupMemberInfo() ? client->GetPlayer()->GetGroupMemberInfo()->group_id : 0);
  6019. else
  6020. client->SimpleMessage(CHANNEL_NARRATIVE, "A guild with that name already exists.");
  6021. }
  6022. else if (strncmp(command, "search", length) == 0)
  6023. client->ShowGuildSearchWindow();
  6024. else if (strncmp(command, "recruiting_details", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  6025. {
  6026. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  6027. if (to_guild)
  6028. to_guild->SendGuildRecruitingDetails(client);
  6029. }
  6030. else if (strncmp(command, "recruiting_image", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  6031. {
  6032. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  6033. if (to_guild)
  6034. to_guild->SendGuildRecruitingImages(client);
  6035. }
  6036. else if (strncmp(command, "recruiter_adventure_class", length) == 0)
  6037. {
  6038. if (sep->arg[1])
  6039. {
  6040. const char* option = sep->arg[1];
  6041. if (strncmp(option, "toggle", strlen(option)) == 0)
  6042. guild->ToggleGuildRecruiterAdventureClass(client);
  6043. }
  6044. else
  6045. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiter_adventure_class command: '%s'", sep->argplus[0]);
  6046. }
  6047. else if (strncmp(command, "display_heraldry", length) == 0)
  6048. {
  6049. // JA: not sure this is right...
  6050. client->GetPlayer()->toggle_character_flag(CF_SHOW_GUILD_HERALDRY);
  6051. client->GetPlayer()->SetCharSheetChanged(true);
  6052. }
  6053. else
  6054. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild command: '%s'", sep->argplus[0]);
  6055. }
  6056. }
  6057. /*
  6058. Function: Command_GuildCreate()
  6059. Purpose : Display's in-game Guild Creation window
  6060. Dev : Scatman
  6061. */
  6062. void Commands::Command_CreateGuild(Client* client)
  6063. {
  6064. client->SendGuildCreateWindow();
  6065. }
  6066. /*
  6067. Function: Command_SetGuildOfficerNote()
  6068. Purpose :
  6069. Dev : Scatman
  6070. */
  6071. void Commands::Command_SetGuildOfficerNote(Client* client, Seperator* sep)
  6072. {
  6073. if (sep && sep->arg[0] && sep->arg[1])
  6074. {
  6075. Guild* guild = client->GetPlayer()->GetGuild();
  6076. if (guild)
  6077. guild->SetGuildOfficerNote(sep->arg[0], sep->argplus[1]);
  6078. }
  6079. }
  6080. /*
  6081. Function: Command_SetGuildMemberNote()
  6082. Purpose :
  6083. Dev : Scatman
  6084. */
  6085. void Commands::Command_SetGuildMemberNote(Client* client, Seperator* sep)
  6086. {
  6087. if (sep && sep->arg[0] && sep->arg[1])
  6088. {
  6089. Guild* guild = client->GetPlayer()->GetGuild();
  6090. if (guild)
  6091. guild->SetGuildMemberNote(sep->arg[0], sep->argplus[1]);
  6092. }
  6093. }
  6094. /*
  6095. Function: Command_GuildSay()
  6096. Purpose :
  6097. Dev : Scatman
  6098. */
  6099. void Commands::Command_GuildSay(Client* client, Seperator* sep)
  6100. {
  6101. Guild* guild = client->GetPlayer()->GetGuild();
  6102. if (guild)
  6103. {
  6104. if (sep && sep->arg[0])
  6105. guild->HandleGuildSay(client, sep->argplus[0]);
  6106. }
  6107. else
  6108. client->SimpleMessage(CHANNEL_NARRATIVE, "You are not a member of a guild");
  6109. }
  6110. /*
  6111. Function: Command_OfficerSay()
  6112. Purpose :
  6113. Dev : Scatman
  6114. */
  6115. void Commands::Command_OfficerSay(Client* client, Seperator* sep)
  6116. {
  6117. Guild* guild = client->GetPlayer()->GetGuild();
  6118. if (guild)
  6119. {
  6120. if (sep && sep->arg[0])
  6121. guild->HandleOfficerSay(client, sep->argplus[0]);
  6122. }
  6123. else
  6124. client->SimpleMessage(CHANNEL_NARRATIVE, "You are not a member of a guild");
  6125. }
  6126. /*
  6127. Function: Command_Guilds()
  6128. Purpose : Shows help for /guild command
  6129. Params :
  6130. Dev : Scatman
  6131. Example :
  6132. */
  6133. void Commands::Command_Guilds(Client* client)
  6134. {
  6135. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds [create|delete|add|remove|list]");
  6136. }
  6137. /*
  6138. Function: Command_GuildsAdd()
  6139. Purpose : Add's players to a guild
  6140. Params : guild_name|guild_id, player name
  6141. Dev : Scatman
  6142. Example : /guilds add 1 Admin = adds player Admin to guild_id 1
  6143. */
  6144. void Commands::Command_GuildsAdd(Client* client, Seperator* sep)
  6145. {
  6146. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  6147. {
  6148. Guild* guild = 0;
  6149. bool found = true;
  6150. if (sep->IsNumber(0))
  6151. {
  6152. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  6153. if (!guild)
  6154. {
  6155. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  6156. found = false;
  6157. }
  6158. }
  6159. else
  6160. {
  6161. guild = guild_list.GetGuild(sep->arg[0]);
  6162. if (!guild)
  6163. {
  6164. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  6165. found = false;
  6166. }
  6167. }
  6168. if (found)
  6169. {
  6170. Client* to_client = 0;
  6171. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  6172. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  6173. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  6174. to_client = ((Player*)client->GetPlayer()->GetTarget())->GetClient();
  6175. if (to_client)
  6176. guild->InvitePlayer(client, to_client->GetPlayer()->GetName());
  6177. else
  6178. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  6179. }
  6180. }
  6181. else
  6182. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds add [guild name|guild id] (player name).");
  6183. }
  6184. /*
  6185. Function: Command_GuildsCreate()
  6186. Purpose : Creates a guild
  6187. Params : guild_name, player_name (optional)
  6188. Dev : Scatman
  6189. Example : /guilds create [guild name] (player name)
  6190. */
  6191. void Commands::Command_GuildsCreate(Client* client, Seperator* sep)
  6192. {
  6193. if (sep && sep->arg[0])
  6194. {
  6195. const char* guild_name = sep->arg[0];
  6196. if (!guild_list.GetGuild(guild_name))
  6197. {
  6198. bool ret = false;
  6199. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  6200. {
  6201. Client* to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  6202. if (to_client)
  6203. {
  6204. world.CreateGuild(guild_name, to_client);
  6205. ret = true;
  6206. }
  6207. else
  6208. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player with name '%s'", sep->arg[1]);
  6209. }
  6210. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  6211. {
  6212. Client* to_client = ((Player*)client->GetPlayer()->GetTarget())->GetClient();
  6213. if (to_client)
  6214. {
  6215. world.CreateGuild(guild_name, to_client);
  6216. ret = true;
  6217. }
  6218. }
  6219. else
  6220. {
  6221. world.CreateGuild(guild_name);
  6222. ret = true;
  6223. }
  6224. if (ret)
  6225. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully created.", guild_name);
  6226. else
  6227. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the guild.");
  6228. }
  6229. else
  6230. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' already exists.", guild_name);
  6231. }
  6232. else
  6233. 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.");
  6234. }
  6235. /*
  6236. Function: Command_GuildsDelete()
  6237. Purpose : Delete's a guild
  6238. Params : guild name
  6239. Dev : Scatman
  6240. Example : /guilds delete Test
  6241. */
  6242. void Commands::Command_GuildsDelete(Client* client, Seperator* sep)
  6243. {
  6244. if (sep && sep->arg[0])
  6245. {
  6246. Guild* guild = 0;
  6247. bool found = true;
  6248. if (sep->IsNumber(0))
  6249. {
  6250. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  6251. if (!guild)
  6252. {
  6253. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  6254. found = false;
  6255. }
  6256. }
  6257. else
  6258. {
  6259. guild = guild_list.GetGuild(sep->arg[0]);
  6260. if (!guild)
  6261. {
  6262. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  6263. found = false;
  6264. }
  6265. }
  6266. if (found)
  6267. {
  6268. guild->RemoveAllGuildMembers();
  6269. database.DeleteGuild(guild);
  6270. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully deleted.", guild->GetName());
  6271. guild_list.RemoveGuild(guild, true);
  6272. }
  6273. }
  6274. else
  6275. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds delete [guild name].");
  6276. }
  6277. /*
  6278. Function: Command_GuildsList()
  6279. Purpose : Lists current guilds on server
  6280. Params :
  6281. Dev : Scatman
  6282. Example : /guilds list
  6283. */
  6284. void Commands::Command_GuildsList(Client* client)
  6285. {
  6286. MutexMap<int32, Guild*>* guilds = guild_list.GetGuilds();
  6287. MutexMap<int32, Guild*>::iterator itr = guilds->begin();
  6288. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Guild List:");
  6289. if (guilds->size() == 0)
  6290. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "None.");
  6291. else {
  6292. while (itr.Next()) {
  6293. Guild* guild = itr.second;
  6294. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", guild->GetID(), guild->GetName());
  6295. }
  6296. }
  6297. }
  6298. /*
  6299. Function: Command_GuildsRemove()
  6300. Purpose : Removes a player from a guild
  6301. Params : guild name|guild id, player name
  6302. Dev : Scatman
  6303. Example : /guilds remove 1 Admin = removes Admin from guild 1
  6304. */
  6305. void Commands::Command_GuildsRemove(Client* client, Seperator* sep)
  6306. {
  6307. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  6308. {
  6309. Guild* guild = 0;
  6310. bool found = true;
  6311. if (sep->IsNumber(0))
  6312. {
  6313. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  6314. if (!guild)
  6315. {
  6316. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  6317. found = false;
  6318. }
  6319. }
  6320. else
  6321. {
  6322. guild = guild_list.GetGuild(sep->arg[0]);
  6323. if (!guild)
  6324. {
  6325. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  6326. found = false;
  6327. }
  6328. }
  6329. if (found)
  6330. {
  6331. Client* to_client = 0;
  6332. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  6333. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  6334. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  6335. to_client = ((Player*)client->GetPlayer()->GetTarget())->GetClient();
  6336. if (to_client)
  6337. {
  6338. Player* to_player = to_client->GetPlayer();
  6339. if (to_player->GetGuild())
  6340. {
  6341. if (to_player->GetGuild() == guild)
  6342. {
  6343. guild->KickGuildMember(client, to_player->GetName());
  6344. }
  6345. else
  6346. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in the guild '%s'.", to_player->GetName(), guild->GetName());
  6347. }
  6348. else
  6349. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in a guild.", to_player->GetName());
  6350. }
  6351. else
  6352. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  6353. }
  6354. }
  6355. else
  6356. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds remove [guild name|guild id] (player name).");
  6357. }
  6358. /*
  6359. Function: Command_InspectPlayer()
  6360. Purpose : Handle the Inspect functions
  6361. Params : Client to inspect
  6362. Dev : Scatman
  6363. Example : /inspect Scatman
  6364. */
  6365. void Commands::Command_InspectPlayer(Client* client, Seperator* sep)
  6366. {
  6367. if (sep && sep->arg[0])
  6368. {
  6369. Client* inspect_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  6370. if (inspect_client)
  6371. client->InspectPlayer(inspect_client->GetPlayer());
  6372. }
  6373. else
  6374. {
  6375. Spawn* target = client->GetPlayer()->GetTarget();
  6376. if (target && target->IsPlayer())
  6377. client->InspectPlayer((Player*)target);
  6378. }
  6379. }
  6380. /*
  6381. Function: Command_Inventory()
  6382. Purpose : Handle changes in player inventory
  6383. Params : <TBD>
  6384. Dev : All
  6385. Example : /inventory delete item_id
  6386. */
  6387. void Commands::Command_Inventory(Client* client, Seperator* sep, EQ2_RemoteCommandString* command)
  6388. {
  6389. PrintSep(sep, "Command_Inventory"); // temp to figure out the params
  6390. Player* player = client->GetPlayer();
  6391. if(sep && sep->arg[0][0])
  6392. {
  6393. LogWrite(COMMAND__INFO, 0, "Command", "command: %s", sep->argplus[0]);
  6394. if(!client->GetPlayer()->Alive())
  6395. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  6396. else if(sep->arg[1][0] && strncasecmp("destroy", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  6397. {
  6398. int16 index = atoi(sep->arg[1]);
  6399. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  6400. if(item)
  6401. {
  6402. if(item->details.item_locked) {
  6403. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot destroy the item in use.");
  6404. return;
  6405. }
  6406. else if(item->CheckFlag(NO_DESTROY)) {
  6407. client->SimpleMessage(CHANNEL_COLOR_RED, "You can't destroy this item.");
  6408. return;
  6409. }
  6410. if(item->GetItemScript() && lua_interface)
  6411. lua_interface->RunItemScript(item->GetItemScript(), "destroyed", item, client->GetPlayer());
  6412. //reobtain item make sure it wasn't removed
  6413. item = player->item_list.GetItemFromIndex(index);
  6414. int32 bag_id = 0;
  6415. if(item){
  6416. bag_id = item->details.inv_slot_id;
  6417. database.DeleteItem(client->GetCharacterID(), item, 0);
  6418. }
  6419. client->GetPlayer()->item_list.DestroyItem(index);
  6420. client->GetPlayer()->UpdateInventory(bag_id);
  6421. }
  6422. }
  6423. 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))
  6424. {
  6425. int16 from_index = atoi(sep->arg[1]);
  6426. sint16 to_slot = atoi(sep->arg[2]); // don't convert slot since this is inventory not equipment
  6427. sint32 bag_id = atol(sep->arg[3]);
  6428. int8 charges = atoi(sep->arg[4]);
  6429. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(from_index);
  6430. if(!item) {
  6431. client->SimpleMessage(CHANNEL_COLOR_RED, "You have no item.");
  6432. return;
  6433. }
  6434. if(to_slot == item->details.slot_id && (bag_id < 0 || bag_id == item->details.inv_slot_id)) {
  6435. return;
  6436. }
  6437. if(item->details.item_locked)
  6438. {
  6439. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot move the item in use.");
  6440. return;
  6441. }
  6442. if(bag_id == -4 && !client->GetPlayer()->item_list.SharedBankAddAllowed(item))
  6443. {
  6444. client->SimpleMessage(CHANNEL_COLOR_RED, "That item (or an item inside) cannot be shared.");
  6445. return;
  6446. }
  6447. sint32 old_inventory_id = 0;
  6448. if(item)
  6449. old_inventory_id = item->details.inv_slot_id;
  6450. //autobank
  6451. if (bag_id == -3 && to_slot == -1)
  6452. {
  6453. if (player->HasFreeBankSlot())
  6454. to_slot = player->FindFreeBankSlot();
  6455. else
  6456. {
  6457. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free bank slots.");
  6458. return;
  6459. }
  6460. }
  6461. //auto inventory
  6462. if (bag_id == 0 && to_slot == -1)
  6463. {
  6464. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  6465. {
  6466. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free slots.");
  6467. return;
  6468. }
  6469. }
  6470. bool item_deleted = false;
  6471. EQ2Packet* outapp = client->GetPlayer()->MoveInventoryItem(bag_id, from_index, (int8)to_slot, charges, 0, &item_deleted, client->GetVersion());
  6472. client->QueuePacket(outapp);
  6473. if(item_deleted)
  6474. item = nullptr;
  6475. //removed from bag send update
  6476. if(old_inventory_id > 0 && item && item->details.inv_slot_id != old_inventory_id)
  6477. {
  6478. outapp = client->GetPlayer()->SendBagUpdate(old_inventory_id, client->GetVersion());
  6479. if(outapp)
  6480. client->QueuePacket(outapp);
  6481. }
  6482. if(item && item->details.inv_slot_id > 0 && item->details.inv_slot_id != old_inventory_id)
  6483. {
  6484. outapp = client->GetPlayer()->SendBagUpdate(item->details.inv_slot_id, client->GetVersion());
  6485. if(outapp)
  6486. client->QueuePacket(outapp);
  6487. }
  6488. }
  6489. else if(sep->arg[1][0] && strncasecmp("equip", sep->arg[0], 5) == 0 && sep->IsNumber(1))
  6490. {
  6491. if(client->GetPlayer()->EngagedInCombat())
  6492. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not equip items while in combat.");
  6493. else
  6494. {
  6495. int16 index = atoi(sep->arg[1]);
  6496. int8 slot_id = 255;
  6497. int8 unk3 = 0;
  6498. int8 appearance_equip = 0;
  6499. if(sep->arg[2][0] && sep->IsNumber(2))
  6500. slot_id = player->ConvertSlotFromClient(atoi(sep->arg[2]), client->GetVersion());
  6501. if(sep->arg[3][0] && sep->IsNumber(3))
  6502. unk3 = atoul(sep->arg[3]);
  6503. if(sep->arg[4][0] && sep->IsNumber(4))
  6504. appearance_equip = atoul(sep->arg[4]);
  6505. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), appearance_equip, slot_id);
  6506. EQ2Packet* outapp = 0;
  6507. for(int32 i=0;i<packets.size();i++)
  6508. {
  6509. outapp = packets[i];
  6510. if(outapp)
  6511. client->QueuePacket(outapp);
  6512. }
  6513. client->GetPlayer()->UpdateWeapons();
  6514. EQ2Packet* characterSheetPackets = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion());
  6515. client->QueuePacket(characterSheetPackets);
  6516. }
  6517. }
  6518. else if (sep->arg[1][0] && strncasecmp("unpack", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  6519. {
  6520. if (client->GetPlayer()->EngagedInCombat())
  6521. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unpack items while in combat.");
  6522. else {
  6523. int16 index = atoi(sep->arg[1]);
  6524. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  6525. if (item) {
  6526. if(item->details.item_locked)
  6527. {
  6528. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot unpack the item in use.");
  6529. return;
  6530. }
  6531. // client->GetPlayer()->item_list.DestroyItem(index);
  6532. if (item->item_sets.size() > 0) {
  6533. for (int32 i = 0; i < item->item_sets.size(); i++) {
  6534. ItemSet* set = item->item_sets[i];
  6535. if (set->item_stack_size == 0)
  6536. set->item_stack_size += 1;
  6537. client->AddItem(set->item_id, set->item_stack_size);
  6538. }
  6539. }
  6540. }
  6541. client->RemoveItem(item, 1);
  6542. }
  6543. }
  6544. else if(sep->arg[1][0] && strncasecmp("unequip", sep->arg[0], 7) == 0 && sep->IsNumber(1))
  6545. {
  6546. if(client->GetPlayer()->EngagedInCombat())
  6547. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unequip items while in combat.");
  6548. else
  6549. {
  6550. int16 index = player->ConvertSlotFromClient(atoi(sep->arg[1]), client->GetVersion());
  6551. sint32 bag_id = -999;
  6552. int8 to_slot = 255;
  6553. if(sep->arg[3][0])
  6554. {
  6555. if(sep->IsNumber(2))
  6556. bag_id = atol(sep->arg[2]);
  6557. if(sep->IsNumber(3))
  6558. to_slot = atoi(sep->arg[3]);
  6559. }
  6560. sint8 unk4 = 0;
  6561. int8 appearance_equip = 0;
  6562. if(sep->arg[4][0] && sep->IsNumber(4))
  6563. unk4 = atoi(sep->arg[4]);
  6564. if(sep->arg[5][0] && sep->IsNumber(5))
  6565. appearance_equip = atoul(sep->arg[5]);
  6566. vector<EQ2Packet*> packets = client->GetPlayer()->UnequipItem(index, bag_id, to_slot, client->GetVersion(), appearance_equip);
  6567. EQ2Packet* outapp = 0;
  6568. for(int32 i=0;i<packets.size();i++)
  6569. {
  6570. outapp = packets[i];
  6571. if(outapp)
  6572. client->QueuePacket(outapp);
  6573. }
  6574. client->UnequipItem(index, bag_id, to_slot, appearance_equip);
  6575. }
  6576. }
  6577. else if(sep->arg[2][0] && strncasecmp("swap_equip", sep->arg[0], 10) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  6578. {
  6579. if(client->GetPlayer()->EngagedInCombat()) {
  6580. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not swap items while in combat.");
  6581. }
  6582. else {
  6583. int16 index1 = client->GetPlayer()->ConvertSlotFromClient(atoi(sep->arg[1]), client->GetVersion());
  6584. int16 index2 = client->GetPlayer()->ConvertSlotFromClient(atoi(sep->arg[2]), client->GetVersion());
  6585. int8 type = 0;
  6586. if(sep->IsNumber(3))
  6587. type = atoul(sep->arg[3]); // type 0 is combat, 3 = appearance
  6588. EQ2Packet* outapp = client->GetPlayer()->SwapEquippedItems(index1, index2, client->GetVersion(), type);
  6589. if(outapp)
  6590. client->QueuePacket(outapp);
  6591. else
  6592. {
  6593. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to swap items");
  6594. return;
  6595. }
  6596. }
  6597. }
  6598. else if (sep->arg[2][0] && strncasecmp("pop", sep->arg[0], 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  6599. {
  6600. sint16 to_slot = atoi(sep->arg[1]);
  6601. sint32 bag_id = atoi(sep->arg[2]);
  6602. Item* item = client->GetPlayer()->item_list.GetOverflowItem();
  6603. if (item) {
  6604. //auto inventory
  6605. if (bag_id == 0 && to_slot == -1)
  6606. {
  6607. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  6608. {
  6609. client->SimpleMessage(CHANNEL_ERROR, "You do not have any free slots.");
  6610. return;
  6611. }
  6612. // Set the slot for the item
  6613. item->details.inv_slot_id = bag_id;
  6614. item->details.slot_id = to_slot;
  6615. // Flag the item so it gets saved in its new location
  6616. item->save_needed = true;
  6617. // Add the item to its new location
  6618. if(player->item_list.AddItem(item)) {
  6619. // Remove the item from the overflow list
  6620. player->item_list.RemoveOverflowItem(item);
  6621. }
  6622. // Send the inventory update packet
  6623. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  6624. return;
  6625. }
  6626. else if (bag_id == -3 && to_slot == -1) {
  6627. // Auto Bank
  6628. if (!player->item_list.GetFirstFreeBankSlot(&bag_id, &to_slot)) {
  6629. client->SimpleMessage(CHANNEL_STATUS, "You do not have any free bank slots.");
  6630. return;
  6631. }
  6632. item->details.inv_slot_id = bag_id;
  6633. item->details.slot_id = to_slot;
  6634. item->save_needed = true;
  6635. if(player->item_list.AddItem(item)) {
  6636. player->item_list.RemoveOverflowItem(item);
  6637. }
  6638. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  6639. }
  6640. else if (bag_id == -4) {
  6641. // Shared Bank
  6642. if (!player->item_list.SharedBankAddAllowed(item)) {
  6643. client->SimpleMessage(CHANNEL_STATUS, "That item (or an item inside) cannot be shared.");
  6644. return;
  6645. }
  6646. Item* tmp_item = player->item_list.GetItem(-4, to_slot);
  6647. if (tmp_item) {
  6648. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  6649. return;
  6650. }
  6651. else {
  6652. item->details.inv_slot_id = bag_id;
  6653. item->details.slot_id = to_slot;
  6654. item->save_needed = true;
  6655. if(player->item_list.AddItem(item)) {
  6656. player->item_list.RemoveOverflowItem(item);
  6657. }
  6658. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  6659. return;
  6660. }
  6661. }
  6662. else {
  6663. // Try to get an item from the given bag id and slot id
  6664. Item* tmp_item = player->item_list.GetItem(bag_id, to_slot);
  6665. // Check to see if we got an item, if we do send an error,
  6666. // if we don't put the overflow item into this slot
  6667. if (tmp_item) {
  6668. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  6669. }
  6670. else {
  6671. item->details.inv_slot_id = bag_id;
  6672. item->details.slot_id = to_slot;
  6673. item->save_needed = true;
  6674. if(player->item_list.AddItem(item)) {
  6675. player->item_list.RemoveOverflowItem(item);
  6676. }
  6677. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  6678. return;
  6679. }
  6680. }
  6681. }
  6682. }
  6683. else if(sep->arg[2][0] && strncasecmp("nosale", sep->arg[0], 6) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  6684. {
  6685. sint64 data = strtoull(sep->arg[1], NULL, 0);
  6686. int32 character_item_id = (int32) (data >> 32);
  6687. int32 item_id = (int32) (data & 0xffffffffL);
  6688. int8 sale_setting = atoi(sep->arg[2]);
  6689. Item* item = client->GetPlayer()->item_list.GetItemFromUniqueID(character_item_id);
  6690. if(item)
  6691. {
  6692. item->no_sale = sale_setting;
  6693. item->save_needed = true;
  6694. client->SendSellMerchantList();
  6695. }
  6696. }
  6697. }
  6698. else
  6699. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /inventory {destroy|move|equip|unequip|swap_equip|pop} {item_id} [to_slot] [bag_id]");
  6700. }
  6701. /*
  6702. Function: Command_Languages()
  6703. Purpose : Show's languages the player knows
  6704. Params :
  6705. Dev : Zcoretri
  6706. Example :
  6707. */
  6708. void Commands::Command_Languages(Client* client, Seperator* sep)
  6709. {
  6710. list<Language*>* languages = client->GetPlayer()->GetPlayerLanguages()->GetAllLanguages();
  6711. list<Language*>::iterator itr;
  6712. Language* language;
  6713. client->Message(CHANNEL_NARRATIVE, "You know the following languages:");
  6714. for(itr = languages->begin(); itr != languages->end(); itr++)
  6715. {
  6716. language = *itr;
  6717. client->Message(CHANNEL_NARRATIVE, "%s", language->GetName());
  6718. }
  6719. }
  6720. /*
  6721. Function: Command_SetLanguage()
  6722. Purpose : Handles language commands
  6723. Params : Language ID
  6724. Dev : Zcoretri
  6725. Example :
  6726. */
  6727. void Commands::Command_SetLanguage(Client* client, Seperator* sep)
  6728. {
  6729. Player* player = client->GetPlayer();
  6730. if (sep && sep->arg[0])
  6731. {
  6732. if(!sep->IsNumber(0))
  6733. {
  6734. //String passed in
  6735. const char* value = sep->arg[0];
  6736. if(strncasecmp(value, "Common", strlen(value)) == 0)
  6737. {
  6738. database.SaveCharacterCurrentLang(0, client->GetCharacterID(), client);
  6739. client->SendLanguagesUpdate(0);
  6740. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", value);
  6741. }
  6742. else
  6743. {
  6744. if(player->HasLanguage(value))
  6745. {
  6746. Language* language = player->GetPlayerLanguages()->GetLanguageByName(value);
  6747. database.SaveCharacterCurrentLang(language->GetID(), client->GetCharacterID(), client);
  6748. client->SendLanguagesUpdate(language->GetID());
  6749. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", language->GetName());
  6750. }
  6751. else
  6752. client->Message(CHANNEL_NARRATIVE, "You do not know how to speak %s", value);
  6753. }
  6754. }
  6755. else
  6756. {
  6757. //Number passed in
  6758. int32 id = atoul(sep->arg[0]);
  6759. if(player->HasLanguage(id))
  6760. {
  6761. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  6762. database.SaveCharacterCurrentLang(id, client->GetCharacterID(), client);
  6763. client->SendLanguagesUpdate(id);
  6764. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", language->GetName());
  6765. }
  6766. else
  6767. {
  6768. Language* language = master_languages_list.GetLanguage(id);
  6769. if(language)
  6770. client->Message(CHANNEL_NARRATIVE, "You do not know how to speak %s", language->GetName());
  6771. }
  6772. }
  6773. }
  6774. else
  6775. {
  6776. //No value was passed in
  6777. int32 id = database.GetCharacterCurrentLang(client->GetCharacterID(), player);
  6778. if(id > 0)
  6779. {
  6780. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  6781. client->Message(CHANNEL_NARRATIVE, "You are currently speaking %s ", language->GetName());
  6782. }
  6783. else
  6784. client->Message(CHANNEL_NARRATIVE, "You are currently speaking Common");
  6785. }
  6786. }
  6787. /*
  6788. Function: Command_LastName()
  6789. Purpose : Sets player surname
  6790. Params : Name text
  6791. Dev : theFoof
  6792. Example :
  6793. */
  6794. void Commands::Command_LastName(Client* client, Seperator* sep)
  6795. {
  6796. if (!client)
  6797. return;
  6798. if (sep && sep->arg[0])
  6799. {
  6800. if (!client->GetPlayer()->get_character_flag(CF_ENABLE_CHANGE_LASTNAME)){
  6801. client->Message(CHANNEL_COLOR_YELLOW, "You must be atleast level %i to change your last name.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  6802. return;
  6803. }
  6804. client->RemovePendingLastName();
  6805. uchar* checkname = (uchar*)sep->arg[0];
  6806. bool valid_name = true;
  6807. for (int32 i = 0; i < strlen(sep->arg[0]); i++) {
  6808. if (!alpha_check(checkname[i])) {
  6809. valid_name = false;
  6810. break;
  6811. }
  6812. }
  6813. if (!valid_name) {
  6814. client->Message(CHANNEL_COLOR_YELLOW, "Your last name can only contain letters.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  6815. return;
  6816. }
  6817. string last_name = (string)sep->arg[0];
  6818. int8 max_length = rule_manager.GetGlobalRule(R_Player, MaxLastNameLength)->GetInt8();
  6819. int8 min_length = rule_manager.GetGlobalRule(R_Player, MinLastNameLength)->GetInt8();
  6820. if (last_name.length() <= max_length && last_name.length() >= min_length){
  6821. client->SetPendingLastName(last_name);
  6822. client->SendLastNameConfirmation();
  6823. }
  6824. else
  6825. client->Message(CHANNEL_COLOR_YELLOW, "Your last name must be between %i and %i characters long.", min_length, max_length);
  6826. }
  6827. }
  6828. /*
  6829. Function: Command_ConfirmLastName()
  6830. Purpose : Confirms setting of player surname
  6831. Params : Name text
  6832. Dev : theFoof
  6833. Example :
  6834. */
  6835. void Commands::Command_ConfirmLastName(Client* client, Seperator* sep)
  6836. {
  6837. if (!client)
  6838. return;
  6839. string* name = client->GetPendingLastName();
  6840. if (name){
  6841. Player* player = client->GetPlayer();
  6842. player->SetLastName(name->c_str(), false);
  6843. client->SendTitleUpdate();
  6844. player->SetCharSheetChanged(true);
  6845. client->RemovePendingLastName();
  6846. }
  6847. }
  6848. /*
  6849. Function: Command_Location()
  6850. Purpose : Display's Help for /location commands
  6851. Params :
  6852. Dev : Scatman
  6853. Example : /location = show's help for command
  6854. */
  6855. void Commands::Command_Location(Client* client)
  6856. {
  6857. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Valid /location commands are:");
  6858. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location create [name] (include y). Include y defaults to false");
  6859. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location add [location id]");
  6860. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location remove [location point id]");
  6861. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location delete [location id]");
  6862. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location list [locations|points] [location id if points used]");
  6863. }
  6864. /*
  6865. Function: Command_LocationAdd()
  6866. Purpose : Add's a location to an existing location config
  6867. Params : location_id
  6868. Dev : Scatman
  6869. Example : /location add {location_id}
  6870. */
  6871. void Commands::Command_LocationAdd(Client* client, Seperator* sep)
  6872. {
  6873. if (sep && sep->arg[0] && sep->IsNumber(0))
  6874. {
  6875. int32 location_id = atoul(sep->arg[0]);
  6876. float x = client->GetPlayer()->GetX();
  6877. float y = client->GetPlayer()->GetY();
  6878. float z = client->GetPlayer()->GetZ();
  6879. if (database.AddLocationPoint(location_id, x, y, z))
  6880. client->Message(CHANNEL_COLOR_YELLOW, "Point (%f, %f, %f) was successfully added to location %u", x, y, z, location_id);
  6881. else
  6882. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist. Use /location create to create one", location_id);
  6883. }
  6884. else
  6885. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location add [location id]");
  6886. }
  6887. /*
  6888. Function: Command_LocationCreate()
  6889. Purpose : Creates a new location config
  6890. Params : location name, 0/1 for include_y (optional)
  6891. Dev : Scatman
  6892. Example : /location create Test 1 = creates a new location named Test with include_y True
  6893. */
  6894. void Commands::Command_LocationCreate(Client* client, Seperator* sep)
  6895. {
  6896. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  6897. {
  6898. const char* name = sep->arg[0];
  6899. bool include_y = false;
  6900. if (sep->arg[1] && sep->IsNumber(1) && atoi(sep->arg[1]) > 0)
  6901. include_y = true;
  6902. int32 location_id = database.CreateLocation(client->GetPlayer()->GetZone()->GetZoneID(), client->GetPlayer()->GetLocation(), name, include_y);
  6903. if (location_id > 0)
  6904. client->Message(CHANNEL_COLOR_YELLOW, "Location '%s' was successfully created with location id %u", name, location_id);
  6905. else
  6906. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the requested location");
  6907. }
  6908. else
  6909. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location create [name] (include_y). Include y defaults to false");
  6910. }
  6911. /*
  6912. Function: Command_LocationDelete()
  6913. Purpose : Delete's a location config and all it's location points
  6914. Params : location_id
  6915. Dev : Scatman
  6916. Example : /location delete {location_id}
  6917. */
  6918. void Commands::Command_LocationDelete(Client* client, Seperator* sep)
  6919. {
  6920. if (sep && sep->arg[0] && sep->IsNumber(0))
  6921. {
  6922. int32 location_id = atoul(sep->arg[0]);
  6923. if (database.DeleteLocation(location_id))
  6924. client->Message(CHANNEL_COLOR_YELLOW, "Location id %u and all its points were successfully deleted", location_id);
  6925. else
  6926. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist", location_id);
  6927. }
  6928. else
  6929. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location delete [location id]");
  6930. }
  6931. /*
  6932. Function: Command_LocationList()
  6933. Purpose : Display's a list of location points
  6934. Params : location_id
  6935. Dev : Scatman
  6936. Example : /location list {location_id}
  6937. */
  6938. void Commands::Command_LocationList(Client* client, Seperator* sep)
  6939. {
  6940. if (sep && sep->arg[0])
  6941. {
  6942. const char* option = sep->arg[0];
  6943. if (strncmp(option, "locations", strlen(option)) == 0)
  6944. database.ListLocations(client);
  6945. else if (strncmp(option, "points", strlen(option)) == 0 && sep->arg[1] && sep->IsNumber(1))
  6946. {
  6947. int32 location_id = atoul(sep->arg[1]);
  6948. database.ListLocationPoints(client, location_id);
  6949. }
  6950. else
  6951. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  6952. }
  6953. else
  6954. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  6955. }
  6956. /*
  6957. Function: Command_LocationRemove()
  6958. Purpose : Removes a single location point from a location config
  6959. Params : location_point_id (gotten from /location list {id})
  6960. Dev : Scatman
  6961. Example : /location remove 1 = will remove location_point_id 1
  6962. */
  6963. void Commands::Command_LocationRemove(Client* client, Seperator* sep)
  6964. {
  6965. if (sep && sep->arg[0] && sep->IsNumber(0))
  6966. {
  6967. int32 location_point_id = atoul(sep->arg[0]);
  6968. if (database.DeleteLocationPoint(location_point_id))
  6969. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Location point was successfully deleted");
  6970. else
  6971. client->Message(CHANNEL_COLOR_YELLOW, "Location point with ID %u does not exist", location_point_id);
  6972. }
  6973. else
  6974. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location remove [location point id]");
  6975. }
  6976. /*
  6977. Function: Command_Merchant()
  6978. Purpose : Handles Merchant commands
  6979. Params : list
  6980. Dev : Scatman
  6981. Example : /merchant list
  6982. */
  6983. void Commands::Command_Merchant(Client* client, Seperator* sep, int handler)
  6984. {
  6985. if( handler == COMMAND_MERCHANT )
  6986. {
  6987. // /merchant command by itself shows help (to be extended)
  6988. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  6989. return;
  6990. }
  6991. else if( handler == COMMAND_MERCHANT_LIST )
  6992. {
  6993. // /merchant list command expects "description" param
  6994. if (sep && sep->arg[0])
  6995. {
  6996. const char* merchant_description = sep->argplus[0];
  6997. client->Message(CHANNEL_COLOR_YELLOW, "Listing merchants like '%s':", merchant_description);
  6998. map<int32, MerchantInfo*>* merchant_info = world.GetMerchantInfo();
  6999. map<int32, MerchantInfo*>::iterator itr;
  7000. for (itr = merchant_info->begin(); itr != merchant_info->end(); itr++)
  7001. {
  7002. string description = database.GetMerchantDescription(itr->first);
  7003. if (ToLower(description).find(ToLower(string(merchant_description))) < 0xFFFFFFFF)
  7004. client->Message(CHANNEL_COLOR_YELLOW, "Merchant ID: %u, Description: %s", itr->first, description.c_str());
  7005. }
  7006. }
  7007. else // no description
  7008. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  7009. }
  7010. }
  7011. /*
  7012. Function: Command_Modify()
  7013. Purpose : to replace our other "set" commands
  7014. Params : System = the system to modify, Action = the action to perform, Target = what to change (target, or index)
  7015. Dev : John Adams
  7016. Example : /modify spell set name "Aegolism III"
  7017. */
  7018. void Commands::Command_Modify(Client* client)
  7019. {
  7020. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /modify [system] [action] [field] [value] {target|id}");
  7021. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Systems: character, faction, guild, item, skill, spawn, spell, zone");
  7022. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Actions: set, create, delete, add, remove");
  7023. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Value : field name in the table being modified");
  7024. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target : modify current target, or specified {system} ID");
  7025. }
  7026. /*
  7027. Function: Command_ModifySpawn()
  7028. Purpose : replace "spawn set" commands
  7029. Params : Action : the action to perform (or special handler)
  7030. : Field : the DB field to change
  7031. : Value : what to set the value to
  7032. : Target : what object to change (my target, or spawn_id)
  7033. Dev : John Adams
  7034. Example : /modify spawn set name "Lady Vox"
  7035. :
  7036. Note : Special Handlers, like "zoneto" for Signs
  7037. : /modify spawn zoneto
  7038. : Will set a sign's zone x/y/z to my current coords
  7039. */
  7040. void Commands::Command_ModifySpawn(Client* client, Seperator* sep)
  7041. {
  7042. PrintSep(sep, "COMMAND_MODIFY");
  7043. // need at least 2 args for a valid command
  7044. if( sep && sep->arg[1] )
  7045. {
  7046. // JA: just a quick implementation because I need it :)
  7047. if (strcmp(sep->arg[0], "zoneto") == 0)
  7048. {
  7049. if( sep->IsNumber(1) )
  7050. {
  7051. int32 spawn_id = atoul(sep->arg[1]);
  7052. float x_coord = client->GetPlayer()->GetX();
  7053. float y_coord = client->GetPlayer()->GetY();
  7054. float z_coord = client->GetPlayer()->GetZ();
  7055. float h_coord = client->GetPlayer()->GetHeading();
  7056. database.SaveSignZoneToCoords(spawn_id, x_coord, y_coord, z_coord, h_coord);
  7057. }
  7058. else
  7059. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify spawn zoneto spawn_id - sets spawn_id to your coords");
  7060. }
  7061. }
  7062. else
  7063. Command_Modify(client);
  7064. }
  7065. /*
  7066. Function: Command_ModifyCharacter()
  7067. Purpose : to replace our other "set" commands
  7068. Params : Action : Add, Remove
  7069. : Field : copper, silver, gold, plat
  7070. : Value : min 1, max unlimited
  7071. : Target : Self, Player
  7072. Dev : Cynnar
  7073. Example : /modify character add gold 50
  7074. : /modify character remove silver 25
  7075. */
  7076. void Commands::Command_ModifyCharacter(Client* client, Seperator* sep)
  7077. {
  7078. PrintSep(sep, "COMMAND_MODIFY");
  7079. int64 value = 0;
  7080. Player* player = client->GetPlayer();
  7081. Client* targetClient = client;
  7082. if (player->HasTarget() && player->GetTarget()->IsPlayer()) {
  7083. player = (Player*)player->GetTarget();
  7084. targetClient = player->GetClient();
  7085. }
  7086. // need at least 2 args for a valid command
  7087. if( sep && sep->arg[1] )
  7088. {
  7089. if (strcmp(sep->arg[0], "add") == 0)
  7090. {
  7091. if (strcmp(sep->arg[1], "copper") == 0)
  7092. {
  7093. value = atoi64(sep->arg[2]);
  7094. player->AddCoins(value);
  7095. if (client->GetPlayer() == player)
  7096. {
  7097. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu copper coin%s", value, (value > 1 ? "s" : ""));
  7098. }
  7099. else {
  7100. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu copper coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  7101. if(targetClient) {
  7102. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu copper coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  7103. }
  7104. }
  7105. }
  7106. else if (strcmp(sep->arg[1], "silver") == 0)
  7107. {
  7108. value = atoi64(sep->arg[2]) * 100;
  7109. player->AddCoins(value);
  7110. if (client->GetPlayer() == player)
  7111. {
  7112. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu silver coin%s", value / 100, (value > 1 ? "s" : ""));
  7113. }
  7114. else {
  7115. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu silver coin%s", player->GetName(), value / 100, (value > 1 ? "s" : ""));
  7116. if(targetClient) {
  7117. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu silver coin%s", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  7118. }
  7119. }
  7120. }
  7121. else if (strcmp(sep->arg[1], "gold") == 0)
  7122. {
  7123. value = atoi64(sep->arg[2]) * 10000;
  7124. player->AddCoins(value);
  7125. if (client->GetPlayer() == player)
  7126. {
  7127. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu gold coin%s", value / 10000, (value > 1 ? "s" : ""));
  7128. }
  7129. else {
  7130. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu gold coin%s", player->GetName(), value / 10000, (value > 1 ? "s" : ""));
  7131. if(targetClient) {
  7132. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu gold coin%s", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  7133. }
  7134. }
  7135. }
  7136. else if (strcmp(sep->arg[1], "plat") == 0)
  7137. {
  7138. value = atoi64(sep->arg[2]) * 1000000;
  7139. player->AddCoins(value);
  7140. if (client->GetPlayer() == player)
  7141. {
  7142. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu platinum coin%s", value / 1000000, (value > 1 ? "s" : ""));
  7143. }
  7144. else {
  7145. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu platinum coin%s", player->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  7146. if(targetClient) {
  7147. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu platinum coin%s", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  7148. }
  7149. }
  7150. }
  7151. else
  7152. {
  7153. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  7154. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  7155. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  7156. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character add copper 20");
  7157. }
  7158. }
  7159. else if (strcmp(sep->arg[0], "remove") == 0)
  7160. {
  7161. if (strcmp(sep->arg[1], "copper") == 0)
  7162. {
  7163. value = atoi64(sep->arg[2]);
  7164. player->RemoveCoins(value);
  7165. if (client->GetPlayer() == player)
  7166. {
  7167. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from yourself", value, (value > 1 ? "s" : ""));
  7168. }
  7169. else {
  7170. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from %s", value, (value > 1 ? "s" : ""), player->GetName());
  7171. if(targetClient) {
  7172. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu copper coin%s from you", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  7173. }
  7174. }
  7175. }
  7176. else if (strcmp(sep->arg[1], "silver") == 0)
  7177. {
  7178. value = atoi64(sep->arg[2]) * 100;
  7179. player->RemoveCoins(value);
  7180. if (client->GetPlayer() == player)
  7181. {
  7182. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from yourself", value / 100, (value > 1 ? "s" : ""));
  7183. }
  7184. else {
  7185. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from %s", value / 100, (value > 1 ? "s" : ""), player->GetName());
  7186. if(targetClient) {
  7187. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu silver coin%s from you", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  7188. }
  7189. }
  7190. }
  7191. else if (strcmp(sep->arg[1], "gold") == 0)
  7192. {
  7193. value = atoi64(sep->arg[2]) * 10000;
  7194. player->RemoveCoins(value);
  7195. if (client->GetPlayer() == player)
  7196. {
  7197. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from yourself", value / 10000, (value > 1 ? "s" : ""));
  7198. }
  7199. else {
  7200. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from %s", value / 10000, (value > 1 ? "s" : ""), player->GetName());
  7201. if(targetClient) {
  7202. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu gold coin%s from you", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  7203. }
  7204. }
  7205. }
  7206. else if (strcmp(sep->arg[1], "plat") == 0)
  7207. {
  7208. value = atoi64(sep->arg[2]) * 1000000;
  7209. player->RemoveCoins(value);
  7210. if (client->GetPlayer() == player)
  7211. {
  7212. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from yourself", value / 1000000, (value > 1 ? "s" : ""));
  7213. }
  7214. else {
  7215. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from %s", value / 1000000, (value > 1 ? "s" : ""), player->GetName());
  7216. if(targetClient) {
  7217. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu platinum coin%s from you", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  7218. }
  7219. }
  7220. }
  7221. else
  7222. {
  7223. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  7224. }
  7225. }
  7226. else if (strcmp(sep->arg[0], "set") == 0) {
  7227. if (strcmp(sep->arg[1], "tslevel") == 0) {
  7228. int8 level = atoi(sep->arg[2]);
  7229. if (level > 0 && level < 256) {
  7230. if (player) {
  7231. if (client->GetPlayer() == player)
  7232. client->ChangeTSLevel(player->GetTSLevel(), level);
  7233. else if(targetClient)
  7234. targetClient->ChangeTSLevel(player->GetTSLevel(), level);
  7235. }
  7236. }
  7237. else
  7238. client->SimpleMessage(CHANNEL_ERROR, "Level must be between 1 - 255");
  7239. }
  7240. else if (strcmp(sep->arg[1], "tsclass") == 0) {
  7241. int8 tsclass = atoi(sep->arg[2]);
  7242. player->SetTradeskillClass(tsclass);
  7243. player->GetInfoStruct()->set_tradeskill_class1(classes.GetTSBaseClass(player->GetTradeskillClass()));
  7244. player->GetInfoStruct()->set_tradeskill_class2(classes.GetSecondaryTSBaseClass(player->GetTradeskillClass()));
  7245. player->GetInfoStruct()->set_tradeskill_class3(player->GetTradeskillClass());
  7246. player->SetCharSheetChanged(true);
  7247. }
  7248. else if (strcmp(sep->arg[1], "gender") == 0) {
  7249. int8 gender = atoi(sep->arg[2]);
  7250. client->GetPlayer()->GetInfoStruct()->set_gender(gender);
  7251. client->GetPlayer()->SetCharSheetChanged(true);
  7252. client->UpdateTimeStampFlag ( GENDER_UPDATE_FLAG );
  7253. }
  7254. }
  7255. }
  7256. else
  7257. {
  7258. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  7259. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  7260. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  7261. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  7262. }
  7263. }
  7264. void Commands::Command_ModifyFaction(Client* client, Seperator* sep)
  7265. {
  7266. PrintSep(sep, "COMMAND_MODIFY");
  7267. // need at least 2 args for a valid command
  7268. if( sep && sep->arg[1] )
  7269. {
  7270. }
  7271. else
  7272. Command_Modify(client);
  7273. }
  7274. void Commands::Command_ModifyGuild(Client* client, Seperator* sep)
  7275. {
  7276. PrintSep(sep, "COMMAND_MODIFY");
  7277. // need at least 2 args for a valid command
  7278. if( sep && sep->arg[1] )
  7279. {
  7280. }
  7281. else
  7282. Command_Modify(client);
  7283. }
  7284. void Commands::Command_ModifyItem(Client* client, Seperator* sep)
  7285. {
  7286. PrintSep(sep, "COMMAND_MODIFY");
  7287. // need at least 2 args for a valid command
  7288. if( sep && sep->arg[1] )
  7289. {
  7290. }
  7291. else
  7292. Command_Modify(client);
  7293. }
  7294. /*
  7295. Function: Command_ModifyQuest()
  7296. Purpose : to list players quest and completed quests
  7297. Params : Action : list, completed
  7298. : Target : Self, Player
  7299. Dev : Cynnar
  7300. Example : /modify quest list
  7301. : /modify quest completed
  7302. */
  7303. void Commands::Command_ModifyQuest(Client* client, Seperator* sep)
  7304. {
  7305. PrintSep(sep, "COMMAND_MODIFY");
  7306. int64 value = 0;
  7307. Player* player = client->GetPlayer();
  7308. Client* targetClient = client;
  7309. if (player->HasTarget() && player->GetTarget()->IsPlayer()) {
  7310. player = (Player*)player->GetTarget();
  7311. targetClient = player->GetClient();
  7312. }
  7313. // need at least 2 args for a valid command
  7314. if (sep && sep->arg[1])
  7315. {
  7316. if (strcmp(sep->arg[0], "list") == 0)
  7317. {
  7318. map<int32, Quest*>* quests = player->GetPlayerQuests();
  7319. map<int32, Quest*>::iterator itr;
  7320. client->Message(CHANNEL_COLOR_YELLOW, "%s's Quest List:.", client->GetPlayer()->GetName());
  7321. if (quests->size() == 0)
  7322. client->Message(CHANNEL_COLOR_YELLOW, "%s has no quests.", client->GetPlayer()->GetName());
  7323. else
  7324. {
  7325. for (itr = quests->begin(); itr != quests->end(); itr++)
  7326. {
  7327. Quest* quest = itr->second;
  7328. if(quest) {
  7329. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  7330. }
  7331. }
  7332. }
  7333. }
  7334. else if (strcmp(sep->arg[0], "completed") == 0)
  7335. {
  7336. map<int32, Quest*>* quests = player->GetCompletedPlayerQuests();
  7337. map<int32, Quest*>::iterator itr;
  7338. client->Message(CHANNEL_COLOR_YELLOW, "%s's Completed Quest List:.", client->GetPlayer()->GetName());
  7339. if (quests->size() == 0)
  7340. client->Message(CHANNEL_COLOR_YELLOW, "%s has no completed quests.", client->GetPlayer()->GetName());
  7341. else
  7342. {
  7343. for (itr = quests->begin(); itr != quests->end(); itr++)
  7344. {
  7345. Quest* quest = itr->second;
  7346. if(quest) {
  7347. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  7348. }
  7349. }
  7350. }
  7351. }
  7352. // Add in a progress step, and a LogWrite() for tracking GM Commands.
  7353. // LogWrite(LUA__DEBUG, 0, "LUA", "Quest: %s, function: %s", quest->GetName(), function);
  7354. else if (strcmp(sep->arg[0], "remove") == 0)
  7355. {
  7356. int32 quest_id = 0;
  7357. if (sep && sep->arg[1] && sep->IsNumber(1))
  7358. quest_id = atoul(sep->arg[1]);
  7359. if (quest_id > 0)
  7360. {
  7361. if (lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0)
  7362. {
  7363. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  7364. if (quest)
  7365. if (client->GetPlayer() == player)
  7366. {
  7367. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been removed from your journal", quest->GetName());
  7368. }
  7369. else
  7370. {
  7371. client->Message(CHANNEL_COLOR_YELLOW, "You have removed the quest %s from %s's journal", quest->GetName(), player->GetName());
  7372. if(targetClient) {
  7373. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s has removed the quest %s from your journal", client->GetPlayer()->GetName(), quest->GetName());
  7374. }
  7375. }
  7376. LogWrite(COMMAND__INFO, 0, "GM Command", "%s removed the quest %s from %s", client->GetPlayer()->GetName(), quest->GetName(), player->GetName());
  7377. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  7378. }
  7379. client->RemovePlayerQuest(quest_id);
  7380. client->GetCurrentZone()->SendQuestUpdates(client);
  7381. }
  7382. }
  7383. else if (strcmp(sep->arg[0], "advance") == 0)
  7384. {
  7385. int32 quest_id = 0;
  7386. int32 step = 0;
  7387. if (sep && sep->arg[1] && sep->IsNumber(1))
  7388. {
  7389. quest_id = atoul(sep->arg[1]);
  7390. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  7391. if(!quest) {
  7392. client->Message(CHANNEL_COLOR_RED, "Quest not found!");
  7393. return;
  7394. }
  7395. if (sep && sep->arg[2] && sep->IsNumber(1))
  7396. {
  7397. step = atoul(sep->arg[2]);
  7398. if (quest_id > 0 && step > 0)
  7399. {
  7400. if (player && player->IsPlayer() && quest_id > 0 && step > 0 && (player->player_quests.count(quest_id) > 0))
  7401. {
  7402. if (client)
  7403. {
  7404. client->AddPendingQuestUpdate(quest_id, step);
  7405. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been advanced one step.", quest->GetName());
  7406. LogWrite(COMMAND__INFO, 0, "GM Command", "%s advanced the quest %s one step", client->GetPlayer()->GetName(), quest->GetName());
  7407. }
  7408. }
  7409. }
  7410. else
  7411. {
  7412. client->Message(CHANNEL_COLOR_RED, "Quest ID and Step Number must be greater than 0!");
  7413. }
  7414. }
  7415. else
  7416. {
  7417. client->Message(CHANNEL_COLOR_RED, "Step Number must be a number!");
  7418. }
  7419. }
  7420. else
  7421. {
  7422. client->Message(CHANNEL_COLOR_RED, "Quest ID must be a number!");
  7423. }
  7424. }
  7425. else
  7426. {
  7427. Command_Modify(client);
  7428. }
  7429. }
  7430. else
  7431. {
  7432. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify quest [action] [quest id] [step number]");
  7433. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: list, completed, remove, advance");
  7434. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest list");
  7435. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest remove 156");
  7436. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest advance 50 1");
  7437. }
  7438. }
  7439. void Commands::Command_ModifySkill(Client* client, Seperator* sep)
  7440. {
  7441. PrintSep(sep, "COMMAND_MODIFY");
  7442. // need at least 2 args for a valid command
  7443. if( sep && sep->arg[1] )
  7444. {
  7445. if (strcmp(sep->arg[0], "add") == 0) {
  7446. const char* skill_name = sep->argplus[1];
  7447. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  7448. if (skill) {
  7449. Player* player = 0;
  7450. Client* to_client = 0;
  7451. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  7452. player = (Player*)client->GetPlayer()->GetTarget();
  7453. to_client = player->GetClient();
  7454. }
  7455. else {
  7456. player = client->GetPlayer();
  7457. to_client = client;
  7458. }
  7459. if (player)
  7460. {
  7461. if (!player->GetSkills()->HasSkill(skill->skill_id))
  7462. {
  7463. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  7464. if (to_client == client) {
  7465. client->Message(CHANNEL_STATUS, "Added skill '%s'.", skill_name);
  7466. }
  7467. else {
  7468. client->Message(CHANNEL_STATUS, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  7469. to_client->Message(CHANNEL_STATUS, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  7470. }
  7471. }
  7472. else
  7473. client->Message(CHANNEL_STATUS, "%s already has the skill '%s'.", to_client == client ? "You" : player->GetName(), skill_name);
  7474. }
  7475. }
  7476. else
  7477. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  7478. }
  7479. else if (strcmp(sep->arg[0], "remove") == 0) {
  7480. const char* skill_name = sep->argplus[1];
  7481. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  7482. if (skill) {
  7483. Player* player = 0;
  7484. Client* to_client = 0;
  7485. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  7486. player = (Player*)client->GetPlayer()->GetTarget();
  7487. to_client = player->GetClient();
  7488. }
  7489. else {
  7490. player = client->GetPlayer();
  7491. to_client = client;
  7492. }
  7493. if (player)
  7494. {
  7495. if (player->GetSkills()->HasSkill(skill->skill_id))
  7496. {
  7497. player->RemoveSkillFromDB(skill, true);
  7498. if (client == to_client) {
  7499. client->Message(CHANNEL_STATUS, "Removed skill '%s'.", skill_name);
  7500. }
  7501. else {
  7502. client->Message(CHANNEL_STATUS, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  7503. if(to_client) {
  7504. to_client->Message(CHANNEL_STATUS, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  7505. }
  7506. }
  7507. }
  7508. else {
  7509. if (client == to_client)
  7510. client->Message(CHANNEL_STATUS, "You do not have the skill '%s'.", skill_name);
  7511. else
  7512. client->Message(CHANNEL_STATUS, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  7513. }
  7514. }
  7515. }
  7516. else
  7517. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  7518. }
  7519. else if (strcmp(sep->arg[0], "set") == 0) {
  7520. if (!sep->IsNumber(2)) {
  7521. client->Message(CHANNEL_STATUS, "The last parameter must be a number.");
  7522. return;
  7523. }
  7524. const char* skill_name = sep->arg[1];
  7525. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  7526. if (skill) {
  7527. int16 val = atoi(sep->arg[2]);
  7528. Player* player = 0;
  7529. Client* to_client = 0;
  7530. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  7531. player = (Player*)client->GetPlayer()->GetTarget();
  7532. to_client = player->GetClient();
  7533. }
  7534. else {
  7535. player = client->GetPlayer();
  7536. to_client = client;
  7537. }
  7538. if (player)
  7539. {
  7540. if (player->GetSkills()->HasSkill(skill->skill_id)) {
  7541. player->GetSkills()->SetSkill(skill->skill_id, val);
  7542. if (client != to_client)
  7543. client->Message(CHANNEL_STATUS, "You set %s's '%s' skill to %i.", player->GetName(), skill_name, val);
  7544. if(to_client) {
  7545. to_client->Message(CHANNEL_STATUS, "Your '%s' skill has been set to %i.", skill_name, val);
  7546. }
  7547. }
  7548. else {
  7549. client->Message(CHANNEL_STATUS, "Target does not have the skill '%s'.", skill_name);
  7550. }
  7551. }
  7552. }
  7553. else {
  7554. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  7555. }
  7556. }
  7557. else {
  7558. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  7559. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  7560. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  7561. }
  7562. }
  7563. else {
  7564. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  7565. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  7566. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  7567. }
  7568. }
  7569. void Commands::Command_ModifySpell(Client* client, Seperator* sep)
  7570. {
  7571. PrintSep(sep, "COMMAND_MODIFY");
  7572. // need at least 2 args for a valid command
  7573. if( sep && sep->arg[1] )
  7574. {
  7575. }
  7576. else
  7577. Command_Modify(client);
  7578. }
  7579. void Commands::Command_ModifyZone(Client* client, Seperator* sep)
  7580. {
  7581. PrintSep(sep, "COMMAND_MODIFY");
  7582. // need at least 2 args for a valid command
  7583. if( sep && sep->arg[1] )
  7584. {
  7585. }
  7586. else
  7587. Command_Modify(client);
  7588. }
  7589. /*
  7590. Function: Command_MOTD()
  7591. Purpose : Displays server MOTD
  7592. Params :
  7593. Dev : LethalEncounter
  7594. Example : /motd
  7595. */
  7596. void Commands::Command_MOTD(Client* client)
  7597. {
  7598. if (client)
  7599. ClientPacketFunctions::SendMOTD(client);
  7600. }
  7601. /*
  7602. Function: Command_Pet()
  7603. Purpose : Handle Pet {Command} commands
  7604. Params : attack, backoff, preserve_master, preserve_self, follow, stay, getlost
  7605. Dev :
  7606. Example : /pet preserve_master
  7607. */
  7608. void Commands::Command_Pet(Client* client, Seperator* sep)
  7609. {
  7610. PrintSep(sep, "COMMAND_PET");
  7611. //LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Pet Commands");
  7612. //client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7613. if (!sep || !sep->arg[0])
  7614. return; // should have sep->arg[0] filled
  7615. if (strcmp(sep->arg[0], "hide") == 0) {
  7616. // doing /pet hide will toggle the hide status on all the pets that can be hidden
  7617. Entity* pet = client->GetPlayer()->GetDeityPet();
  7618. if (pet) {
  7619. if (pet->IsPrivateSpawn())
  7620. client->GetPlayer()->HideDeityPet(false);
  7621. else
  7622. client->GetPlayer()->HideDeityPet(true);
  7623. }
  7624. pet = client->GetPlayer()->GetCosmeticPet();
  7625. if (pet) {
  7626. if (pet->IsPrivateSpawn())
  7627. client->GetPlayer()->HideCosmeticPet(false);
  7628. else
  7629. client->GetPlayer()->HideCosmeticPet(true);
  7630. }
  7631. return;
  7632. }
  7633. // below is for all combat pets
  7634. if (!client->GetPlayer()->HasPet()) {
  7635. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a pet.");
  7636. return;
  7637. }
  7638. if (strcmp(sep->arg[0], "stay") == 0) {
  7639. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to stay.");
  7640. client->GetPlayer()->GetInfoStruct()->set_pet_movement(1);
  7641. client->GetPlayer()->SetCharSheetChanged(true);
  7642. if (client->GetPlayer()->GetPet())
  7643. client->GetPlayer()->GetPet()->following = false;
  7644. if (client->GetPlayer()->GetCharmedPet())
  7645. client->GetPlayer()->GetCharmedPet()->following = false;
  7646. }
  7647. else if (strcmp(sep->arg[0], "follow") == 0) {
  7648. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to follow.");
  7649. client->GetPlayer()->GetInfoStruct()->set_pet_movement(2);
  7650. client->GetPlayer()->SetCharSheetChanged(true);
  7651. }
  7652. else if (strcmp(sep->arg[0], "preserve_master") == 0) {
  7653. if (client->GetPlayer()->GetInfoStruct()->get_pet_behavior() & 1) {
  7654. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect you.");
  7655. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()-1);
  7656. }
  7657. else {
  7658. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect you.");
  7659. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()+1);
  7660. }
  7661. client->GetPlayer()->SetCharSheetChanged(true);
  7662. }
  7663. else if (strcmp(sep->arg[0], "preserve_self") == 0) {
  7664. if (client->GetPlayer()->GetInfoStruct()->get_pet_behavior() & 2) {
  7665. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect itself.");
  7666. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()-2);
  7667. }
  7668. else {
  7669. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect itself.");
  7670. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()+2);
  7671. }
  7672. client->GetPlayer()->SetCharSheetChanged(true);
  7673. }
  7674. else if (strcmp(sep->arg[0], "backoff") == 0) {
  7675. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to back down.");
  7676. if (client->GetPlayer()->GetPet())
  7677. ((NPC*)client->GetPlayer()->GetPet())->Brain()->ClearHate();
  7678. if (client->GetPlayer()->GetCharmedPet())
  7679. ((NPC*)client->GetPlayer()->GetCharmedPet())->Brain()->ClearHate();
  7680. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(0);
  7681. client->GetPlayer()->SetCharSheetChanged(true);
  7682. }
  7683. else if (strcmp(sep->arg[0], "attack") == 0) {
  7684. if (client->GetPlayer()->HasTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  7685. if (client->GetPlayer()->AttackAllowed((Entity*)client->GetPlayer()->GetTarget())){
  7686. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to attack your target.");
  7687. if (client->GetPlayer()->GetPet())
  7688. client->GetPlayer()->GetPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  7689. if (client->GetPlayer()->GetCharmedPet())
  7690. client->GetPlayer()->GetCharmedPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  7691. }
  7692. else
  7693. client->Message(CHANNEL_COLOR_YELLOW, "You can not attack that.");
  7694. }
  7695. else
  7696. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a target.");
  7697. }
  7698. else if (strcmp(sep->arg[0], "getlost") == 0) {
  7699. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetPet());
  7700. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetCharmedPet());
  7701. client->Message(CHANNEL_COLOR_YELLOW, "You tell your pet to get lost.");
  7702. }
  7703. else
  7704. client->Message(CHANNEL_COLOR_YELLOW, "Unknown pet command.");
  7705. }
  7706. /*
  7707. Function: Command_PetName()
  7708. Purpose : Pet your name (???)
  7709. Params :
  7710. Dev :
  7711. Example :
  7712. */
  7713. void Commands::Command_PetName(Client* client, Seperator* sep)
  7714. {
  7715. if (sep && sep->arg[0]) {
  7716. const char* pet_name = sep->argplus[0];
  7717. client->SetPetName(pet_name);
  7718. }
  7719. else {
  7720. client->GetPlayer()->GetInfoStruct()->set_pet_name("");
  7721. }
  7722. }
  7723. /*
  7724. Function: Command_NamePet()
  7725. Purpose : Name your pet
  7726. Params :
  7727. Dev :
  7728. Example :
  7729. */
  7730. void Commands::Command_NamePet(Client* client, Seperator* sep)
  7731. {
  7732. PrintSep(sep, "COMMAND_NAME_PET");
  7733. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Name Pet Command");
  7734. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7735. }
  7736. /*
  7737. Function: Command_Rename()
  7738. Purpose : Renames existing pet
  7739. Params :
  7740. Dev :
  7741. Example :
  7742. */
  7743. void Commands::Command_Rename(Client* client, Seperator* sep)
  7744. {
  7745. PrintSep(sep, "COMMAND_RENAME");
  7746. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Rename Pet Command");
  7747. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7748. }
  7749. /*
  7750. Function: Command_ConfirmRename()
  7751. Purpose : Confirms renaming your pet
  7752. Params :
  7753. Dev :
  7754. Example :
  7755. */
  7756. void Commands::Command_ConfirmRename(Client* client, Seperator* sep)
  7757. {
  7758. PrintSep(sep, "COMMAND_CONFIRMRENAME");
  7759. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Confirm Rename Pet Command");
  7760. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7761. }
  7762. /*
  7763. Function: Command_PetOptions()
  7764. Purpose : Sets various pet options
  7765. Params :
  7766. Dev :
  7767. Example :
  7768. */
  7769. void Commands::Command_PetOptions(Client* client, Seperator* sep)
  7770. {
  7771. PrintSep(sep, "COMMAND_PETOPTIONS");
  7772. Player* player = client->GetPlayer();
  7773. Spawn* target = player->GetTarget();
  7774. if (!target)
  7775. return;
  7776. if (target == player->GetPet())
  7777. client->SendPetOptionsWindow(player->GetPet()->GetName());
  7778. else if (target == player->GetCharmedPet())
  7779. client->SendPetOptionsWindow(player->GetCharmedPet()->GetName());
  7780. else if (target == player->GetCosmeticPet())
  7781. client->SendPetOptionsWindow(player->GetCosmeticPet()->GetName(), 0);
  7782. else if (target == player->GetDeityPet())
  7783. client->SendPetOptionsWindow(player->GetDeityPet()->GetName(), 0);
  7784. }
  7785. /*
  7786. Function: Command_Random()
  7787. Purpose : Handles /random dice roll in-game
  7788. Params : 1-100
  7789. Dev : Scatman
  7790. Example : /randon 1 100
  7791. */
  7792. void Commands::Command_Random(Client* client, Seperator* sep)
  7793. {
  7794. char message[256] = {0};
  7795. if (sep)
  7796. {
  7797. if (sep->GetArgNumber() == 0 && sep->IsNumber(0))
  7798. 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])));
  7799. else if (sep->GetArgNumber() > 0 && sep->IsNumber(0) && sep->IsNumber(1))
  7800. 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])));
  7801. else
  7802. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  7803. }
  7804. else
  7805. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  7806. client->GetPlayer()->GetZone()->HandleChatMessage(0, 0, CHANNEL_EMOTE, message);
  7807. }
  7808. /*
  7809. Function: Command_Randomize()
  7810. Purpose : Sets randomize (appearance) values for NPCs
  7811. Params : Attrib Name
  7812. Dev : Scatman
  7813. Example : /randomize gender 1 -- will randomize the NPCs gender (male/female)
  7814. */
  7815. void Commands::Command_Randomize(Client* client, Seperator* sep)
  7816. {
  7817. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  7818. if (target)
  7819. {
  7820. if (target->IsNPC())
  7821. {
  7822. if (sep && sep->arg[0] && !sep->IsNumber(0))
  7823. {
  7824. const char* value = sep->arg[0];
  7825. if (strncasecmp(value, "show", strlen(value)) == 0)
  7826. {
  7827. client->DisplayRandomizeFeatures(target->GetRandomize());
  7828. }
  7829. else
  7830. {
  7831. if (sep->arg[1] && sep->IsNumber(1))
  7832. {
  7833. int8 option = atoi(sep->arg[1]);
  7834. if (option == 0 || option == 1)
  7835. {
  7836. int32 feature = 0;
  7837. char feature_text[32] = {0};
  7838. if (strncasecmp(value, "gender", strlen(value)) == 0) {
  7839. feature = RANDOMIZE_GENDER;
  7840. strncpy(feature_text, "gender", sizeof(feature_text) - 1);
  7841. }
  7842. else if (strncasecmp(value, "race", strlen(value)) == 0) {
  7843. feature = RANDOMIZE_RACE;
  7844. strncpy(feature_text, "race", sizeof(feature_text) - 1);
  7845. }
  7846. else if (strncasecmp(value, "model", strlen(value)) == 0) {
  7847. feature = RANDOMIZE_MODEL_TYPE;
  7848. strncpy(feature_text, "model", sizeof(feature_text) - 1);
  7849. }
  7850. else if (strncasecmp(value, "facial_hair", strlen(value)) == 0) {
  7851. feature = RANDOMIZE_FACIAL_HAIR_TYPE;
  7852. strncpy(feature_text, "facial hair", sizeof(feature_text) - 1);
  7853. }
  7854. else if (strncasecmp(value, "hair", strlen(value)) == 0) {
  7855. feature = RANDOMIZE_HAIR_TYPE;
  7856. strncpy(feature_text, "hair", sizeof(feature_text) - 1);
  7857. }
  7858. else if (strncasecmp(value, "wing", strlen(value)) == 0) {
  7859. feature = RANDOMIZE_WING_TYPE;
  7860. strncpy(feature_text, "wings", sizeof(feature_text) - 1);
  7861. }
  7862. else if (strncasecmp(value, "cheek", strlen(value)) == 0) {
  7863. feature = RANDOMIZE_CHEEK_TYPE;
  7864. strncpy(feature_text, "cheeks", sizeof(feature_text) - 1);
  7865. }
  7866. else if (strncasecmp(value, "chin", strlen(value)) == 0) {
  7867. feature = RANDOMIZE_CHIN_TYPE;
  7868. strncpy(feature_text, "chin", sizeof(feature_text) - 1);
  7869. }
  7870. else if (strncasecmp(value, "ear", strlen(value)) == 0) {
  7871. feature = RANDOMIZE_EAR_TYPE;
  7872. strncpy(feature_text, "ears", sizeof(feature_text) - 1);
  7873. }
  7874. else if (strncasecmp(value, "eye_brow", strlen(value)) == 0) {
  7875. feature = RANDOMIZE_EYE_BROW_TYPE;
  7876. strncpy(feature_text, "eye brows", sizeof(feature_text) - 1);
  7877. }
  7878. else if (strncasecmp(value, "eye", strlen(value)) == 0) {
  7879. feature = RANDOMIZE_EYE_TYPE;
  7880. strncpy(feature_text, "eyes", sizeof(feature_text) - 1);
  7881. }
  7882. else if (strncasecmp(value, "lip", strlen(value)) == 0) {
  7883. feature = RANDOMIZE_LIP_TYPE;
  7884. strncpy(feature_text, "lips", sizeof(feature_text) - 1);
  7885. }
  7886. else if (strncasecmp(value, "nose", strlen(value)) == 0) {
  7887. feature = RANDOMIZE_NOSE_TYPE;
  7888. strncpy(feature_text, "nose", sizeof(feature_text) - 1);
  7889. }
  7890. else if (strncasecmp(value, "eye_color", strlen(value)) == 0) {
  7891. feature = RANDOMIZE_EYE_COLOR;
  7892. strncpy(feature_text, "eye color", sizeof(feature_text) - 1);
  7893. }
  7894. else if (strncasecmp(value, "hair_color", strlen(value)) == 0) {
  7895. feature = RANDOMIZE_HAIR_TYPE_COLOR;
  7896. strncpy(feature_text, "hair color", sizeof(feature_text) - 1);
  7897. }
  7898. else if (strncasecmp(value, "hair_color1", strlen(value)) == 0) {
  7899. feature = RANDOMIZE_HAIR_COLOR1;
  7900. strncpy(feature_text, "hair color1", sizeof(feature_text) - 1);
  7901. }
  7902. else if (strncasecmp(value, "hair_color2", strlen(value)) == 0) {
  7903. feature = RANDOMIZE_HAIR_COLOR2;
  7904. strncpy(feature_text, "hair color2", sizeof(feature_text) - 1);
  7905. }
  7906. else if (strncasecmp(value, "hair_highlight", strlen(value)) == 0) {
  7907. feature = RANDOMIZE_HAIR_HIGHLIGHT;
  7908. strncpy(feature_text, "hair highlights", sizeof(feature_text) - 1);
  7909. }
  7910. else if (strncasecmp(value, "facial_hair_color", strlen(value)) == 0) {
  7911. feature = RANDOMIZE_HAIR_FACE_COLOR;
  7912. strncpy(feature_text, "facial hair color", sizeof(feature_text) - 1);
  7913. }
  7914. else if (strncasecmp(value, "facial_hair_color_highlight", strlen(value)) == 0) {
  7915. feature = RANDOMIZE_HAIR_FACE_HIGHLIGHT_COLOR;
  7916. strncpy(feature_text, "facial hair color highlights", sizeof(feature_text) - 1);
  7917. }
  7918. else if (strncasecmp(value, "hair_color_highlight", strlen(value)) == 0) {
  7919. feature = RANDOMIZE_HAIR_TYPE_HIGHLIGHT_COLOR;
  7920. strncpy(feature_text, "hair color highlights", sizeof(feature_text) - 1);
  7921. }
  7922. else if (strncasecmp(value, "skin_color", strlen(value)) == 0) {
  7923. feature = RANDOMIZE_SKIN_COLOR;
  7924. strncpy(feature_text, "skin color", sizeof(feature_text) - 1);
  7925. }
  7926. else if (strncasecmp(value, "wing_color1", strlen(value)) == 0) {
  7927. feature = RANDOMIZE_WING_COLOR1;
  7928. strncpy(feature_text, "wing color1", sizeof(feature_text) - 1);
  7929. }
  7930. else if (strncasecmp(value, "wing_color2", strlen(value)) == 0) {
  7931. feature = RANDOMIZE_WING_COLOR2;
  7932. strncpy(feature_text, "wing color2", sizeof(feature_text) - 1);
  7933. }
  7934. else {
  7935. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is not a valid feature to randomize.", value);
  7936. 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'.");
  7937. }
  7938. if (feature > 0) {
  7939. if (option == 1) {
  7940. if (target->GetRandomize() & feature)
  7941. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is already set to randomly generate their %s.", target->GetName(), feature_text);
  7942. else {
  7943. target->AddRandomize(feature);
  7944. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(feature);
  7945. database.UpdateRandomize(target->GetDatabaseID(), feature);
  7946. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will now generate their %s randomly.", target->GetName(), feature_text);
  7947. }
  7948. }
  7949. else {
  7950. if (target->GetRandomize() & feature) {
  7951. target->AddRandomize(-feature);
  7952. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(-feature);
  7953. database.UpdateRandomize(target->GetDatabaseID(), -feature);
  7954. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will no longer generate their %s randomly.", target->GetName(), feature_text);
  7955. }
  7956. else
  7957. client->Message(CHANNEL_COLOR_YELLOW, "'%s' already does not randomly generate their %s.", target->GetName(), feature_text);
  7958. }
  7959. }
  7960. }
  7961. else
  7962. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  7963. }
  7964. else
  7965. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  7966. }
  7967. }
  7968. else {
  7969. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /randomize [show | [feature [1|0]]");
  7970. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "'show' will display current configured features");
  7971. 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'.");
  7972. }
  7973. }
  7974. else
  7975. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "The target you wish to randomize must be an NPC.");
  7976. }
  7977. else
  7978. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select the target you wish to randomize.");
  7979. }
  7980. /*
  7981. Function: Command_ShowCloak()
  7982. Purpose : Character Settings combo box for Show Cloak
  7983. Params : true/false
  7984. Dev : John Adams
  7985. Example :
  7986. */
  7987. void Commands::Command_ShowCloak(Client* client, Seperator* sep)
  7988. {
  7989. Player* player = client->GetPlayer();
  7990. if (sep && sep->arg[0])
  7991. {
  7992. const char* value = sep->arg[0];
  7993. if (strncasecmp(value, "true", strlen(value)) == 0)
  7994. {
  7995. player->set_character_flag(CF_SHOW_CLOAK);
  7996. player->reset_character_flag(CF2_SHOW_RANGED);
  7997. }
  7998. else if (strncasecmp(value, "false", strlen(value)) == 0)
  7999. player->reset_character_flag(CF_SHOW_CLOAK);
  8000. else
  8001. {
  8002. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8003. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8004. }
  8005. }
  8006. }
  8007. /*
  8008. Function: Command_ShowHelm()
  8009. Purpose : Character Settings combo box for Show Helm
  8010. Params : true/false
  8011. Dev : John Adams
  8012. Example :
  8013. */
  8014. void Commands::Command_ShowHelm(Client* client, Seperator* sep)
  8015. {
  8016. Player* player = client->GetPlayer();
  8017. if(client->GetVersion() <= 546) {
  8018. return; // not allowed/supported
  8019. }
  8020. if (sep && sep->arg[0])
  8021. {
  8022. PrintSep(sep, "Command_ShowHelm");
  8023. const char* value = sep->arg[0];
  8024. if (strncasecmp(value, "true", strlen(value)) == 0)
  8025. {
  8026. player->toggle_character_flag(CF_HIDE_HELM);
  8027. player->toggle_character_flag(CF_HIDE_HOOD);
  8028. }
  8029. else if (strncasecmp(value, "false", strlen(value)) == 0)
  8030. player->toggle_character_flag(CF_HIDE_HELM);
  8031. else
  8032. {
  8033. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8034. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8035. }
  8036. }
  8037. }
  8038. /*
  8039. Function: Command_ShowHood()
  8040. Purpose : Character Settings combo box for Show Hood
  8041. Params : true/false
  8042. Dev : John Adams
  8043. Example :
  8044. */
  8045. void Commands::Command_ShowHood(Client* client, Seperator* sep)
  8046. {
  8047. Player* player = client->GetPlayer();
  8048. if (sep && sep->arg[0])
  8049. {
  8050. PrintSep(sep, "Command_ShowHood");
  8051. const char* value = sep->arg[0];
  8052. if (strncasecmp(value, "true", strlen(value)) == 0)
  8053. {
  8054. player->toggle_character_flag(CF_HIDE_HOOD);
  8055. if(client->GetVersion() > 546) { // no hide helm support in DoF
  8056. player->toggle_character_flag(CF_HIDE_HELM);
  8057. }
  8058. }
  8059. else if (strncasecmp(value, "false", strlen(value)) == 0) {
  8060. player->toggle_character_flag(CF_HIDE_HOOD);
  8061. }
  8062. else
  8063. {
  8064. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8065. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8066. }
  8067. }
  8068. }
  8069. /*
  8070. Function: Command_ShowHoodHelm()
  8071. Purpose : Character Settings combo box for Show Helm or Hood
  8072. Params : true/false
  8073. Dev : John Adams
  8074. Example :
  8075. */
  8076. void Commands::Command_ShowHoodHelm(Client* client, Seperator* sep)
  8077. {
  8078. Player* player = client->GetPlayer();
  8079. if(client->GetVersion() <= 546) {
  8080. return; // not allowed/supported
  8081. }
  8082. if (sep && sep->arg[0])
  8083. {
  8084. PrintSep(sep, "Command_ShowHoodHelm");
  8085. const char* value = sep->arg[0];
  8086. if (strncasecmp(value, "true", strlen(value)) == 0)
  8087. {
  8088. player->toggle_character_flag(CF_HIDE_HOOD);
  8089. player->toggle_character_flag(CF_HIDE_HELM);
  8090. }
  8091. else if (strncasecmp(value, "false", strlen(value)) == 0)
  8092. {
  8093. // don't think we ever wind up in here...
  8094. player->toggle_character_flag(CF_HIDE_HOOD);
  8095. player->toggle_character_flag(CF_HIDE_HELM);
  8096. }
  8097. else
  8098. {
  8099. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8100. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8101. }
  8102. }
  8103. }
  8104. /*
  8105. Function: Command_ShowRanged()
  8106. Purpose : Character Settings combo box for Show Ranged weapon
  8107. Params : true/false
  8108. Dev : John Adams
  8109. Example :
  8110. */
  8111. void Commands::Command_ShowRanged(Client* client, Seperator* sep)
  8112. {
  8113. Player* player = client->GetPlayer();
  8114. if (sep && sep->arg[0])
  8115. {
  8116. const char* value = sep->arg[0];
  8117. if (strncasecmp(value, "true", strlen(value)) == 0)
  8118. {
  8119. player->set_character_flag(CF2_SHOW_RANGED);
  8120. player->reset_character_flag(CF_SHOW_CLOAK);
  8121. }
  8122. else if (strncasecmp(value, "false", strlen(value)) == 0)
  8123. player->reset_character_flag(CF2_SHOW_RANGED);
  8124. else
  8125. {
  8126. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8127. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8128. }
  8129. }
  8130. }
  8131. /*
  8132. Function:
  8133. Purpose :
  8134. Params :
  8135. Dev :
  8136. Example :
  8137. */
  8138. void Commands::Command_Skills(Client* client, Seperator* sep, int handler)
  8139. {
  8140. Player* player = 0;
  8141. Client* to_client = 0;
  8142. if(client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  8143. to_client = ((Player*)client->GetPlayer()->GetTarget())->GetClient();
  8144. switch(handler)
  8145. {
  8146. case COMMAND_SKILL:
  8147. {
  8148. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill [add|remove|list] [skill name]");
  8149. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to add/remove skills for that player.");
  8150. break;
  8151. }
  8152. case COMMAND_SKILL_ADD:
  8153. {
  8154. if (sep && sep->arg[0])
  8155. {
  8156. const char* skill_name = sep->argplus[0];
  8157. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  8158. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // add skill to your target, if target is not you
  8159. {
  8160. player = to_client->GetPlayer();
  8161. if (player)
  8162. {
  8163. if (!player->GetSkills()->HasSkill(skill->skill_id))
  8164. {
  8165. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  8166. client->Message(CHANNEL_COLOR_YELLOW, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  8167. to_client->Message(CHANNEL_COLOR_YELLOW, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  8168. }
  8169. else
  8170. client->Message(CHANNEL_COLOR_YELLOW, "%s already has the skill '%s'.", player->GetName(), skill_name);
  8171. }
  8172. }
  8173. else if (skill) // add skill to yourself
  8174. {
  8175. player = client->GetPlayer();
  8176. if (player)
  8177. {
  8178. if (!player->GetSkills()->HasSkill(skill->skill_id))
  8179. {
  8180. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  8181. client->Message(CHANNEL_COLOR_YELLOW, "Added skill '%s'.", skill_name);
  8182. }
  8183. else
  8184. client->Message(CHANNEL_COLOR_YELLOW, "You already have the skill '%s'.", skill_name);
  8185. }
  8186. }
  8187. else
  8188. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  8189. }
  8190. else
  8191. {
  8192. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill add [skill name]");
  8193. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  8194. }
  8195. break;
  8196. }
  8197. case COMMAND_SKILL_REMOVE:
  8198. {
  8199. if (sep && sep->arg[0])
  8200. {
  8201. const char* skill_name = sep->argplus[0];
  8202. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  8203. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // remove skill from your target, if target is not you
  8204. {
  8205. player = to_client->GetPlayer();
  8206. if (player)
  8207. {
  8208. if (player->GetSkills()->HasSkill(skill->skill_id))
  8209. {
  8210. player->RemoveSkillFromDB(skill, true);
  8211. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  8212. to_client->Message(CHANNEL_COLOR_YELLOW, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  8213. }
  8214. else
  8215. client->Message(CHANNEL_COLOR_YELLOW, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  8216. }
  8217. }
  8218. else if(skill) // remove skill from yourself
  8219. {
  8220. Player* player = client->GetPlayer();
  8221. if (player)
  8222. {
  8223. if (player->GetSkills()->HasSkill(skill->skill_id))
  8224. {
  8225. player->RemoveSkillFromDB(skill, true);
  8226. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s'.", skill_name);
  8227. }
  8228. else
  8229. client->Message(CHANNEL_COLOR_YELLOW, "You do not have the skill '%s'.", skill_name);
  8230. }
  8231. }
  8232. else
  8233. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  8234. }
  8235. else
  8236. {
  8237. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill remove [skill name]");
  8238. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  8239. }
  8240. break;
  8241. }
  8242. case COMMAND_SKILL_LIST:
  8243. {
  8244. if (sep && sep->arg[0])
  8245. {
  8246. const char* skill_name = sep->argplus[0];
  8247. client->Message(CHANNEL_COLOR_YELLOW, "Listing skills like '%s':", skill_name);
  8248. map<int32, Skill*>* skills = master_skill_list.GetAllSkills();
  8249. map<int32, Skill*>::iterator itr;
  8250. if (skills && skills->size() > 0)
  8251. {
  8252. for (itr = skills->begin(); itr != skills->end(); itr++)
  8253. {
  8254. Skill* skill = itr->second;
  8255. string current_skill_name = ::ToLower(string(skill->name.data.c_str()));
  8256. if (current_skill_name.find(::ToLower(string(skill_name))) < 0xFFFFFFFF)
  8257. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", skill->name.data.c_str(), skill->skill_id);
  8258. }
  8259. }
  8260. }
  8261. else
  8262. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill list [skill name]");
  8263. break;
  8264. }
  8265. }
  8266. }
  8267. /*
  8268. Function: Command_SpawnTemplate()
  8269. Purpose : Create or Use defined Spawn Templates
  8270. Params : create, save, rempve, list
  8271. Dev : John Adams
  8272. Example : /spawn template create "Test"
  8273. */
  8274. void Commands::Command_SpawnTemplate(Client* client, Seperator* sep)
  8275. {
  8276. if (sep == NULL || sep->arg[0] == NULL)
  8277. {
  8278. 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.");
  8279. return;
  8280. }
  8281. // got params, continue
  8282. const char * template_cmd = sep->arg[0];
  8283. if (strncasecmp(template_cmd, "list", strlen(template_cmd)) == 0)
  8284. {
  8285. if (!sep->IsSet(1))
  8286. {
  8287. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /spawn template list [name|location_id]");
  8288. 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.");
  8289. return;
  8290. }
  8291. map<int32, string>* template_names = 0;
  8292. if (sep->IsNumber(1))
  8293. {
  8294. int32 location_id = 0;
  8295. location_id = atoi(sep->arg[1]);
  8296. template_names = database.GetSpawnTemplateListByID(location_id);
  8297. }
  8298. else
  8299. {
  8300. const char* name = 0;
  8301. name = sep->argplus[1];
  8302. template_names = database.GetSpawnTemplateListByName(name);
  8303. }
  8304. if(!template_names)
  8305. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No templates found.");
  8306. else
  8307. {
  8308. map<int32, string>::iterator itr;
  8309. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  8310. for(itr = template_names->begin(); itr != template_names->end(); itr++)
  8311. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  8312. safe_delete(template_names);
  8313. }
  8314. }
  8315. else if (strncasecmp(template_cmd, "save", strlen(template_cmd)) == 0)
  8316. {
  8317. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  8318. if ( target && (target->IsNPC() || target->IsObject() || target->IsSign() || target->IsWidget() || target->IsGroundSpawn()) )
  8319. {
  8320. if (sep && sep->arg[1][0] && !sep->IsNumber(1))
  8321. {
  8322. // first, lookup to see if template name already exists
  8323. const char* name = 0;
  8324. name = sep->argplus[1];
  8325. map<int32, string>* template_names = database.GetSpawnTemplateListByName(name);
  8326. if(!template_names)
  8327. {
  8328. int32 new_template_id = database.SaveSpawnTemplate(target->GetSpawnLocationID(), name);
  8329. if( new_template_id > 0 )
  8330. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template '%s' added for spawn '%s' (%u) as TemplateID: %u", name, target->GetName(), target->GetSpawnLocationID(), new_template_id);
  8331. else
  8332. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' for spawn '%s' (%u).", name, target->GetName(), target->GetSpawnLocationID());
  8333. }
  8334. else
  8335. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' - Already exists!", name);
  8336. }
  8337. else
  8338. client->Message(CHANNEL_COLOR_RED, "ERROR: Saving a new spawn template requires a valid template name!");
  8339. }
  8340. else
  8341. client->Message(CHANNEL_COLOR_RED, "ERROR: You must target the spawn you wish to save as a template!");
  8342. }
  8343. else if (strncasecmp(template_cmd, "remove", strlen(template_cmd)) == 0)
  8344. {
  8345. if (sep && sep->arg[1][0] && sep->IsNumber(1))
  8346. {
  8347. int32 template_id = 0;
  8348. template_id = atoi(sep->arg[1]);
  8349. if (database.RemoveSpawnTemplate(template_id))
  8350. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template ID: %u successfully removed.", template_id);
  8351. else
  8352. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to remove spawn template ID: %u", template_id);
  8353. }
  8354. else
  8355. client->Message(CHANNEL_COLOR_RED, "ERROR: Removing a spawn template requires a valid template ID!");
  8356. }
  8357. // Renamed create to spawn
  8358. else if (strncasecmp(template_cmd, "spawn", strlen(template_cmd)) == 0)
  8359. {
  8360. if (sep && sep->arg[1][0])
  8361. {
  8362. int32 new_location = 0;
  8363. if (sep->IsNumber(1))
  8364. {
  8365. int32 template_id = 0;
  8366. template_id = atoi(sep->arg[1]);
  8367. new_location = database.CreateSpawnFromTemplateByID(client, template_id);
  8368. if( new_location > 0 )
  8369. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template ID: %u", new_location, template_id);
  8370. else
  8371. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template ID: %u", template_id);
  8372. }
  8373. else
  8374. {
  8375. const char* name = 0;
  8376. name = sep->argplus[1];
  8377. new_location = database.CreateSpawnFromTemplateByName(client, name);
  8378. if( new_location > 0 )
  8379. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template: '%s'", new_location, name);
  8380. else
  8381. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template: '%s'", name);
  8382. }
  8383. }
  8384. else
  8385. client->Message(CHANNEL_COLOR_RED, "ERROR: Spawning a new spawn location requires a valid template name or ID!");
  8386. }
  8387. else
  8388. client->Message(CHANNEL_COLOR_RED, "ERROR: Unknown /spawn template command.");
  8389. }
  8390. void Commands::Command_Speed(Client* client, Seperator* sep) {
  8391. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  8392. float new_speed = atof(sep->arg[0]);
  8393. if (new_speed > 0.0f)
  8394. {
  8395. client->GetPlayer()->SetSpeed(new_speed, true);
  8396. client->GetPlayer()->SetCharSheetChanged(true);
  8397. database.insertCharacterProperty(client, CHAR_PROPERTY_SPEED, sep->arg[0]);
  8398. client->Message(CHANNEL_STATUS, "Setting speed to %.2f.", new_speed);
  8399. }
  8400. else
  8401. client->Message(CHANNEL_STATUS, "Invalid speed provided %s.", sep->arg[0]);
  8402. }
  8403. else{
  8404. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /speed {new speed value}");
  8405. }
  8406. }
  8407. /*
  8408. Function: Command_StationMarketPlace()
  8409. Purpose : just trying to eat the console spam for now
  8410. Params :
  8411. Dev : John
  8412. */
  8413. void Commands::Command_StationMarketPlace(Client* client, Seperator* sep)
  8414. {
  8415. PrintSep(sep, "COMMAND_SMP");
  8416. // This will reduce the spam from once every 10 sec to once every 30 sec,
  8417. // can't seem to reduce it any more get rid of it completely...
  8418. if (sep && strcmp(sep->arg[0], "gkw") == 0) {
  8419. PacketStruct* packet = configReader.getStruct("WS_MarketFundsUpdate", client->GetVersion());
  8420. if (packet) {
  8421. packet->setDataByName("account_id", client->GetAccountID());
  8422. packet->setDataByName("character_id", client->GetCharacterID());
  8423. packet->setDataByName("unknown1", 1, 5);
  8424. packet->setDataByName("unknown1", 26, 6);
  8425. packet->setDataByName("unknown2", 0xFFFFFFFF);
  8426. packet->setDataByName("unknown3", 248, 1);
  8427. client->QueuePacket(packet->serialize());
  8428. }
  8429. safe_delete(packet);
  8430. }
  8431. }
  8432. /*
  8433. Function: Command_StopDrinking()
  8434. Purpose : Stops player from auto-consuming drink
  8435. Params :
  8436. Dev : Zcoretri
  8437. Example : /stopdrinking
  8438. */
  8439. void Commands::Command_StopDrinking(Client* client)
  8440. {
  8441. client->GetPlayer()->reset_character_flag(CF_DRINK_AUTO_CONSUME);
  8442. client->Message(CHANNEL_COLOR_YELLOW,"You stop drinking your current drink.");
  8443. }
  8444. /*
  8445. Function: Command_StopEating()
  8446. Purpose : Stops player from auto-consuming food
  8447. Params :
  8448. Dev : Zcoretri
  8449. Example : /stopeating
  8450. */
  8451. void Commands::Command_StopEating(Client* client)
  8452. {
  8453. client->GetPlayer()->reset_character_flag(CF_FOOD_AUTO_CONSUME);
  8454. client->Message(CHANNEL_COLOR_YELLOW,"You stop eating your current food.");
  8455. }
  8456. /*
  8457. Function: Command_Title()
  8458. Purpose : Help for /title command
  8459. Params : n/a
  8460. Dev : Zcoretri
  8461. Example : /title
  8462. */
  8463. void Commands::Command_Title(Client* client)
  8464. {
  8465. client->Message(CHANNEL_COLOR_YELLOW, "Available subcommands: list, setprefix <index>, setsuffix <index>, fix");
  8466. }
  8467. /*
  8468. Function: Command_TitleList()
  8469. Purpose : List available titles for player
  8470. Params : n/a
  8471. Dev : Zcoretri
  8472. Example : /title list
  8473. */
  8474. void Commands::Command_TitleList(Client* client)
  8475. {
  8476. // must call release read lock before leaving function on GetPlayerTitles
  8477. vector<Title*>* titles = client->GetPlayer()->GetPlayerTitles()->GetAllTitles();
  8478. vector<Title*>::iterator itr;
  8479. Title* title;
  8480. sint32 i = 0;
  8481. client->Message(CHANNEL_NARRATIVE, "Listing available titles:");
  8482. for(itr = titles->begin(); itr != titles->end(); itr++)
  8483. {
  8484. title = *itr;
  8485. client->Message(CHANNEL_NARRATIVE, "%i: type=[%s] title=[%s]", i, title->GetPrefix() ? "Prefix":"Suffix", title->GetName());
  8486. i++;
  8487. }
  8488. client->GetPlayer()->GetPlayerTitles()->ReleaseReadLock();
  8489. }
  8490. /*
  8491. Function: Command_TitleSetPrefix()
  8492. Purpose : Set Prefix title for player
  8493. Params : Title ID
  8494. Dev : Zcoretri
  8495. Example : /title setprefix 1
  8496. */
  8497. void Commands::Command_TitleSetPrefix(Client* client, Seperator* sep)
  8498. {
  8499. if (sep && sep->arg[0] && sep->IsNumber(0))
  8500. {
  8501. sint32 index = atoul(sep->arg[0]);
  8502. if(index > -1)
  8503. {
  8504. Title* title = client->GetPlayer()->GetPlayerTitles()->GetTitle(index);
  8505. if(!title)
  8506. {
  8507. client->Message(CHANNEL_COLOR_RED, "Missing index %i to set title", index);
  8508. return;
  8509. }
  8510. else if(!title->GetPrefix())
  8511. {
  8512. client->Message(CHANNEL_COLOR_RED, "%s is not a prefix.", title->GetName());
  8513. return;
  8514. }
  8515. }
  8516. else // make sure client doesn't pass some bogus negative index
  8517. index = -1;
  8518. database.SaveCharPrefixIndex(index, client->GetCharacterID());
  8519. client->SendTitleUpdate();
  8520. }
  8521. }
  8522. /*
  8523. Function: Command_TitleSetSuffix()
  8524. Purpose : Set Suffix title for player
  8525. Params : Title ID
  8526. Dev : Zcoretri
  8527. Example : /title setsuffix 1
  8528. */
  8529. void Commands::Command_TitleSetSuffix(Client* client, Seperator* sep)
  8530. {
  8531. if (sep && sep->arg[0] && sep->IsNumber(0))
  8532. {
  8533. sint32 index = atoul(sep->arg[0]);
  8534. if(index > -1)
  8535. {
  8536. Title* title = client->GetPlayer()->GetPlayerTitles()->GetTitle(index);
  8537. if(!title)
  8538. {
  8539. client->Message(CHANNEL_COLOR_RED, "Missing index %i to set title", index);
  8540. return;
  8541. }
  8542. else if(title->GetPrefix())
  8543. {
  8544. client->Message(CHANNEL_COLOR_RED, "%s is not a suffix.", title->GetName());
  8545. return;
  8546. }
  8547. }
  8548. else // make sure client doesn't pass some bogus negative index
  8549. index = -1;
  8550. database.SaveCharSuffixIndex(index, client->GetCharacterID());
  8551. client->SendTitleUpdate();
  8552. }
  8553. }
  8554. /*
  8555. Function: Command_TitleFix()
  8556. Purpose : Fix title for player (???)
  8557. Params :
  8558. Dev : Zcoretri
  8559. Example :
  8560. */
  8561. void Commands::Command_TitleFix(Client* client, Seperator* sep)
  8562. {
  8563. PrintSep(sep, "COMMAND_TITLE_FIX");
  8564. LogWrite(MISC__TODO, 1, "Titles", "TODO-Command: TITLE_FIX");
  8565. }
  8566. /*
  8567. Function: Command_Toggle_Anonymous()
  8568. Purpose : Toggles player Anonymous
  8569. Params :
  8570. Dev : paulgh
  8571. Example : /anon
  8572. */
  8573. void Commands::Command_Toggle_Anonymous(Client* client)
  8574. {
  8575. Player* player = client->GetPlayer();
  8576. player->toggle_character_flag(CF_ANONYMOUS);
  8577. client->Message(CHANNEL_COLOR_YELLOW,"You are %s anonymous.", player->get_character_flag(CF_ANONYMOUS)?"now":"no longer");
  8578. if (player->get_character_flag(CF_ANONYMOUS))
  8579. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ANONYMOUS);
  8580. else
  8581. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ANONYMOUS);
  8582. }
  8583. /*
  8584. Function: Command_Toggle_AutoConsume()
  8585. Purpose : Toggles player food/drink auto consume
  8586. Params : unknown
  8587. Dev : paulgh
  8588. Example : /set_auto_consume
  8589. */
  8590. void Commands::Command_Toggle_AutoConsume(Client* client, Seperator* sep)
  8591. {
  8592. Player* player = client->GetPlayer();
  8593. if (sep && sep->arg[0])
  8594. PrintSep(sep, "COMMAND_SET_AUTO_CONSUME");
  8595. if (sep && sep->arg[0] && sep->IsNumber(0))
  8596. {
  8597. int8 slot = atoi(sep->arg[0]);
  8598. int8 flag = atoi(sep->arg[1]);
  8599. if (client->GetVersion() <= 283) {
  8600. slot += 4;
  8601. }
  8602. else if (client->GetVersion() <= 546) {
  8603. slot += 2;
  8604. }
  8605. if (slot == EQ2_FOOD_SLOT)
  8606. {
  8607. player->toggle_character_flag(CF_FOOD_AUTO_CONSUME);
  8608. player->SetCharSheetChanged(true);
  8609. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  8610. if (flag == 1)
  8611. client->Message(CHANNEL_NARRATIVE, "You decide to eat immediately whenever you become hungry.");
  8612. else
  8613. {
  8614. client->Message(CHANNEL_NARRATIVE, "You decide to ignore the hunger.");
  8615. return;
  8616. }
  8617. }
  8618. else
  8619. {
  8620. player->toggle_character_flag(CF_DRINK_AUTO_CONSUME);
  8621. player->SetCharSheetChanged(true);
  8622. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  8623. if (flag == 1)
  8624. client->Message(CHANNEL_NARRATIVE, "You decide to drink immediately whenever you become thirsty.");
  8625. else
  8626. {
  8627. client->Message(CHANNEL_NARRATIVE, "You decide to ignore the thirst.");
  8628. return;
  8629. }
  8630. }
  8631. if(!client->CheckConsumptionAllowed(slot, false))
  8632. return;
  8633. Item* item = player->GetEquipmentList()->GetItem(slot);
  8634. if(item)
  8635. client->ConsumeFoodDrink(item, slot);
  8636. }
  8637. }
  8638. /*
  8639. Function: Command_Toggle_BonusXP()
  8640. Purpose : Toggles player Bonus XP
  8641. Params :
  8642. Dev : John Adams
  8643. Example : /disable_char_bonus_exp
  8644. */
  8645. void Commands::Command_Toggle_BonusXP(Client* client)
  8646. {
  8647. Player* player = client->GetPlayer();
  8648. player->toggle_character_flag(CF2_CHARACTER_BONUS_EXPERIENCE_ENABLED);
  8649. player->SetCharSheetChanged(true);
  8650. }
  8651. /*
  8652. Function: Command_Toggle_CombatXP()
  8653. Purpose : Toggles player Adventure XP
  8654. Params :
  8655. Dev : John Adams
  8656. Example : /disable_combat_exp
  8657. */
  8658. void Commands::Command_Toggle_CombatXP(Client* client)
  8659. {
  8660. Player* player = client->GetPlayer();
  8661. player->toggle_character_flag(CF_COMBAT_EXPERIENCE_ENABLED);
  8662. player->SetCharSheetChanged(true);
  8663. }
  8664. /*
  8665. Function: Command_Toggle_GMHide()
  8666. Purpose : Toggles hiding player GM status
  8667. Params :
  8668. Dev : Scatman
  8669. Example : /gm_hide
  8670. */
  8671. void Commands::Command_Toggle_GMHide(Client* client)
  8672. {
  8673. Player* player = client->GetPlayer();
  8674. player->toggle_character_flag(CF_HIDE_STATUS);
  8675. client->Message(CHANNEL_COLOR_YELLOW,"You are %s hiding your GM status.", player->get_character_flag(CF_HIDE_STATUS)?"now":"no longer");
  8676. }
  8677. /*
  8678. Function: Command_Toggle_GMVanish()
  8679. Purpose : Toggles hiding GM players from /who searches
  8680. Params :
  8681. Dev : Scatman
  8682. Example : /gm_vanish
  8683. */
  8684. void Commands::Command_Toggle_GMVanish(Client* client)
  8685. {
  8686. Player* player = client->GetPlayer();
  8687. player->toggle_character_flag(CF_GM_HIDDEN);
  8688. client->Message(CHANNEL_COLOR_YELLOW,"You are %s invisible to who queries.", player->get_character_flag(CF_GM_HIDDEN)?"now":"no longer");
  8689. }
  8690. /*
  8691. Function: Command_Toggle_Illusions()
  8692. Purpose : Toggles player illusion form
  8693. Params : not sure sep is needed, testing
  8694. Dev : paulgh
  8695. Example : /hide_illusions
  8696. */
  8697. void Commands::Command_Toggle_Illusions(Client* client, Seperator* sep)
  8698. {
  8699. if (sep && sep->arg[0])
  8700. PrintSep(sep, "COMMAND_TOGGLE_ILLUSIONS");
  8701. client->GetPlayer()->toggle_character_flag(CF_SHOW_ILLUSION);
  8702. }
  8703. /*
  8704. Function: Command_Toggle_LFG()
  8705. Purpose : Toggles player LFG Flag
  8706. Params :
  8707. Dev : paulgh
  8708. Example : /lfg
  8709. */
  8710. void Commands::Command_Toggle_LFG(Client* client)
  8711. {
  8712. Player* player = client->GetPlayer();
  8713. player->toggle_character_flag(CF_LFG);
  8714. client->Message(CHANNEL_COLOR_YELLOW,"You are %s LFG.", player->get_character_flag(CF_LFG)?"now":"no longer");
  8715. if (player->get_character_flag(CF_LFG))
  8716. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFG);
  8717. else
  8718. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFG);
  8719. }
  8720. /*
  8721. Function: Command_Toggle_LFW()
  8722. Purpose : Toggles player LFW Flag
  8723. Params :
  8724. Dev : paulgh
  8725. Example : /lfw
  8726. */
  8727. void Commands::Command_Toggle_LFW(Client* client)
  8728. {
  8729. Player* player = client->GetPlayer();
  8730. player->toggle_character_flag(CF_LFW);
  8731. client->Message(CHANNEL_COLOR_YELLOW,"You %s looking for work.", player->get_character_flag(CF_LFW)?"let others know you are":"stop");
  8732. if (player->get_character_flag(CF_LFW))
  8733. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFW);
  8734. else
  8735. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFW);
  8736. }
  8737. /*
  8738. Function: Command_Toggle_QuestXP()
  8739. Purpose : Toggles player Quest XP
  8740. Params :
  8741. Dev : John Adams
  8742. Example : /disable_quest_exp
  8743. */
  8744. void Commands::Command_Toggle_QuestXP(Client* client)
  8745. {
  8746. Player* player = client->GetPlayer();
  8747. player->toggle_character_flag(CF_QUEST_EXPERIENCE_ENABLED);
  8748. player->SetCharSheetChanged(true);
  8749. }
  8750. /*
  8751. Function: Command_Toggle_Roleplaying()
  8752. Purpose : Toggles player Roleplaying flag
  8753. Params :
  8754. Dev : paulgh
  8755. Example : /role
  8756. */
  8757. void Commands::Command_Toggle_Roleplaying(Client* client)
  8758. {
  8759. Player* player = client->GetPlayer();
  8760. player->toggle_character_flag(CF_ROLEPLAYING);
  8761. client->Message(CHANNEL_COLOR_YELLOW,"You are %s roleplaying.", player->get_character_flag(CF_ROLEPLAYING)?"now":"no longer");
  8762. if (player->get_character_flag(CF_ROLEPLAYING))
  8763. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ROLEPLAYING);
  8764. else
  8765. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ROLEPLAYING);
  8766. }
  8767. void Commands::Command_Toggle_Duels(Client* client)
  8768. {
  8769. Player* player = client->GetPlayer();
  8770. player->toggle_character_flag(CF_ALLOW_DUEL_INVITES);
  8771. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting duel invites.", player->get_character_flag(CF_ALLOW_DUEL_INVITES)?"now":"no longer");
  8772. }
  8773. void Commands::Command_Toggle_Trades(Client* client)
  8774. {
  8775. Player* player = client->GetPlayer();
  8776. player->toggle_character_flag(CF_ALLOW_TRADE_INVITES);
  8777. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting trade invites.", player->get_character_flag(CF_ALLOW_TRADE_INVITES)?"now":"no longer");
  8778. }
  8779. void Commands::Command_Toggle_Guilds(Client* client)
  8780. {
  8781. Player* player = client->GetPlayer();
  8782. player->toggle_character_flag(CF_ALLOW_GUILD_INVITES);
  8783. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting guild invites.", player->get_character_flag(CF_ALLOW_GUILD_INVITES)?"now":"no longer");
  8784. }
  8785. void Commands::Command_Toggle_Groups(Client* client)
  8786. {
  8787. Player* player = client->GetPlayer();
  8788. player->toggle_character_flag(CF_ALLOW_GROUP_INVITES);
  8789. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting group invites.", player->get_character_flag(CF_ALLOW_GROUP_INVITES)?"now":"no longer");
  8790. }
  8791. void Commands::Command_Toggle_Raids(Client* client)
  8792. {
  8793. Player* player = client->GetPlayer();
  8794. player->toggle_character_flag(CF_ALLOW_RAID_INVITES);
  8795. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting raid invites.", player->get_character_flag(CF_ALLOW_RAID_INVITES)?"now":"no longer");
  8796. }
  8797. void Commands::Command_Toggle_LON(Client* client)
  8798. {
  8799. Player* player = client->GetPlayer();
  8800. player->toggle_character_flag(CF2_ALLOW_LON_INVITES);
  8801. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting LoN invites.", player->get_character_flag(CF2_ALLOW_LON_INVITES)?"now":"no longer");
  8802. }
  8803. void Commands::Command_Toggle_VoiceChat(Client* client)
  8804. {
  8805. Player* player = client->GetPlayer();
  8806. player->toggle_character_flag(CF2_ALLOW_VOICE_INVITES);
  8807. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting voice chat invites.", player->get_character_flag(CF2_ALLOW_VOICE_INVITES)?"now":"no longer");
  8808. }
  8809. /*
  8810. Function: Command_TradeStart()
  8811. Purpose : Starts item/coin trade between players
  8812. Params :
  8813. Dev :
  8814. Example :
  8815. */
  8816. #include "../Trade.h"
  8817. void Commands::Command_TradeStart(Client* client, Seperator* sep)
  8818. {
  8819. PrintSep(sep, "COMMAND_START_TRADE");
  8820. Entity* trader = client->GetPlayer();
  8821. Entity* trader2 = 0;
  8822. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  8823. Spawn* spawn = client->GetPlayer()->GetSpawnWithPlayerID(atoi(sep->arg[0]));
  8824. if (spawn) {
  8825. if (spawn->IsEntity())
  8826. trader2 = (Entity*)spawn;
  8827. }
  8828. }
  8829. else if (client->GetPlayer()->GetTarget()) {
  8830. if (client->GetPlayer()->GetTarget()->IsEntity())
  8831. trader2 = (Entity*)client->GetPlayer()->GetTarget();
  8832. }
  8833. // can only trade with player or bots
  8834. if (trader && trader2) {
  8835. if (trader == trader2) {
  8836. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade with yourself.");
  8837. }
  8838. else if (trader2->IsPlayer() || trader2->IsBot()) {
  8839. LogWrite(PLAYER__ERROR, 0, "Trade", "creating trade");
  8840. if (trader->trade)
  8841. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are already trading.");
  8842. else if (trader2->trade)
  8843. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is already trading.");
  8844. else {
  8845. Trade* trade = new Trade(trader, trader2);
  8846. trader->trade = trade;
  8847. trader2->trade = trade;
  8848. }
  8849. }
  8850. else {
  8851. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can only trade with another player or a bot.");
  8852. }
  8853. }
  8854. else
  8855. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to find target");
  8856. }
  8857. /*
  8858. Function: Command_Track()
  8859. Purpose : Starts/Stops Tracking for a player
  8860. Params :
  8861. Dev : Scatman
  8862. Example : /track
  8863. */
  8864. void Commands::Command_Track(Client* client)
  8865. {
  8866. if (!client->GetPlayer()->GetIsTracking())
  8867. client->GetPlayer()->GetZone()->AddPlayerTracking(client->GetPlayer());
  8868. else
  8869. client->GetPlayer()->GetZone()->RemovePlayerTracking(client->GetPlayer(), TRACKING_STOP);
  8870. }
  8871. /*
  8872. Function: Command_TradeAccept()
  8873. Purpose : Accepts item/coin trade between players
  8874. Params :
  8875. Dev :
  8876. Example :
  8877. */
  8878. void Commands::Command_TradeAccept(Client* client, Seperator* sep)
  8879. {
  8880. PrintSep(sep, "COMMAND_ACCEPT_TRADE");
  8881. Trade* trade = client->GetPlayer()->trade;
  8882. if (trade) {
  8883. bool trade_complete = trade->SetTradeAccepted(client->GetPlayer());
  8884. if (trade_complete)
  8885. safe_delete(trade);
  8886. }
  8887. else
  8888. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8889. }
  8890. /*
  8891. Function: Command_TradeReject()
  8892. Purpose : Rejects item/coin trade between players
  8893. Params :
  8894. Dev :
  8895. Example :
  8896. */
  8897. void Commands::Command_TradeReject(Client* client, Seperator* sep)
  8898. {
  8899. PrintSep(sep, "COMMAND_REJECT_TRADE");
  8900. Command_TradeCancel(client, sep);
  8901. }
  8902. /*
  8903. Function: Command_TradeCancel()
  8904. Purpose : Cancels item/coin trade between players
  8905. Params :
  8906. Dev :
  8907. Example :
  8908. */
  8909. void Commands::Command_TradeCancel(Client* client, Seperator* sep)
  8910. {
  8911. PrintSep(sep, "COMMAND_CANCEL_TRADE");
  8912. Trade* trade = client->GetPlayer()->trade;
  8913. if (trade) {
  8914. trade->CancelTrade(client->GetPlayer());
  8915. safe_delete(trade);
  8916. }
  8917. else
  8918. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8919. }
  8920. /*
  8921. Function: Command_TradeSetCoin()
  8922. Purpose : Sets coin trade between players
  8923. Params :
  8924. Dev :
  8925. Example :
  8926. */
  8927. void Commands::Command_TradeSetCoin(Client* client, Seperator* sep)
  8928. {
  8929. PrintSep(sep, "COMMAND_SET_TRADE_COIN");
  8930. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Set Trade Coin");
  8931. client->Message(CHANNEL_COLOR_YELLOW, "You cannot trade with other players (Not Implemented)");
  8932. }
  8933. /*
  8934. Function: Command_TradeAddCoin()
  8935. Purpose : Adds coin to trade between players
  8936. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  8937. Dev :
  8938. Example :
  8939. */
  8940. void Commands::Command_TradeAddCoin(Client* client, Seperator* sep, int handler)
  8941. {
  8942. PrintSep(sep, "COMMAND_ADD_TRADE_{coin type}");
  8943. Trade* trade = client->GetPlayer()->trade;
  8944. if (trade) {
  8945. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  8946. int32 amount = atoi(sep->arg[0]);
  8947. int64 val = 0;
  8948. switch (handler) {
  8949. case COMMAND_ADD_TRADE_COPPER:
  8950. {
  8951. val = amount;
  8952. trade->AddCoinToTrade(client->GetPlayer(), val);
  8953. break;
  8954. }
  8955. case COMMAND_ADD_TRADE_SILVER:
  8956. {
  8957. val = amount * 100;
  8958. trade->AddCoinToTrade(client->GetPlayer(), val);
  8959. break;
  8960. }
  8961. case COMMAND_ADD_TRADE_GOLD:
  8962. {
  8963. val = amount * 10000;
  8964. trade->AddCoinToTrade(client->GetPlayer(), val);
  8965. break;
  8966. }
  8967. case COMMAND_ADD_TRADE_PLAT:
  8968. {
  8969. val = amount * 1000000;
  8970. trade->AddCoinToTrade(client->GetPlayer(), val);
  8971. break;
  8972. }
  8973. default:
  8974. {
  8975. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  8976. break;
  8977. }
  8978. }
  8979. }
  8980. else
  8981. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount.");
  8982. }
  8983. else
  8984. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8985. }
  8986. /*
  8987. Function: Command_TradeRemoveCoin()
  8988. Purpose : Removes coin from trade between players
  8989. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  8990. Dev :
  8991. Example :
  8992. */
  8993. void Commands::Command_TradeRemoveCoin(Client* client, Seperator* sep, int handler)
  8994. {
  8995. PrintSep(sep, "COMMAND_REMOVE_TRADE_{coin type}");
  8996. Trade* trade = client->GetPlayer()->trade;
  8997. if (trade) {
  8998. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  8999. int32 amount = atoi(sep->arg[0]);
  9000. int64 val = 0;
  9001. switch (handler) {
  9002. case COMMAND_REMOVE_TRADE_COPPER:
  9003. {
  9004. val = amount;
  9005. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  9006. break;
  9007. }
  9008. case COMMAND_REMOVE_TRADE_SILVER:
  9009. {
  9010. val = amount * 100;
  9011. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  9012. break;
  9013. }
  9014. case COMMAND_REMOVE_TRADE_GOLD:
  9015. {
  9016. val = amount * 10000;
  9017. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  9018. break;
  9019. }
  9020. case COMMAND_REMOVE_TRADE_PLAT:
  9021. {
  9022. val = amount * 1000000;
  9023. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  9024. break;
  9025. }
  9026. default:
  9027. {
  9028. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  9029. break;
  9030. }
  9031. }
  9032. }
  9033. else
  9034. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount");
  9035. }
  9036. else
  9037. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  9038. }
  9039. /*
  9040. Function: Command_TradeAddItem()
  9041. Purpose : Adds item to trade between players
  9042. Params :
  9043. Dev :
  9044. Example :
  9045. */
  9046. void Commands::Command_TradeAddItem(Client* client, Seperator* sep)
  9047. {
  9048. PrintSep(sep, "COMMAND_ADD_TRADE_ITEM");
  9049. /*
  9050. arg[0] = item index
  9051. arg[1] = slot
  9052. arg[2] = quantity
  9053. */
  9054. if (!client->GetPlayer()->trade) {
  9055. LogWrite(PLAYER__ERROR, 0, "Trade", "Player is not currently trading.");
  9056. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  9057. return;
  9058. }
  9059. if (sep && sep->IsSet(0) && sep->IsNumber(0) && sep->IsSet(1) && sep->IsNumber(1) && sep->IsSet(2) && sep->IsNumber(2)) {
  9060. Item* item = 0;
  9061. int32 index = atoi(sep->arg[0]);
  9062. item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(index);
  9063. if (item) {
  9064. int8 result = client->GetPlayer()->trade->AddItemToTrade(client->GetPlayer(), item, atoi(sep->arg[2]), atoi(sep->arg[1]));
  9065. if (result == 1)
  9066. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Item is already being traded.");
  9067. else if (result == 2)
  9068. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade NO-TRADE items.");
  9069. else if (result == 3)
  9070. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade HEIRLOOM items.");
  9071. else if (result == 255)
  9072. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown error trying to add the item to the trade...");
  9073. }
  9074. else {
  9075. LogWrite(PLAYER__ERROR, 0, "Trade", "Unable to get an item for the player (%s) from the index (%u)", client->GetPlayer()->GetName(), index);
  9076. client->Message(CHANNEL_ERROR, "Unable to find item at index %u", index);
  9077. }
  9078. }
  9079. else
  9080. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  9081. }
  9082. /*
  9083. Function: Command_TradeRemoveItem()
  9084. Purpose : Removes item from trade between players
  9085. Params :
  9086. Dev :
  9087. Example :
  9088. */
  9089. void Commands::Command_TradeRemoveItem(Client* client, Seperator* sep)
  9090. {
  9091. PrintSep(sep, "COMMAND_REMOVE_TRADE_ITEM");
  9092. /*
  9093. arg[0] = trade window slot
  9094. */
  9095. Trade* trade = client->GetPlayer()->trade;
  9096. if (trade) {
  9097. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  9098. trade->RemoveItemFromTrade(client->GetPlayer(), atoi(sep->arg[0]));
  9099. }
  9100. else
  9101. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  9102. }
  9103. else
  9104. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  9105. }
  9106. void Commands::Command_TryOn(Client* client, Seperator* sep)
  9107. {
  9108. Item *item = 0;
  9109. sint32 crc;
  9110. if (sep) {
  9111. // 1096+ sends more info so need to do a version check so older clients (SF) still work
  9112. if (client->GetVersion() < 1096) {
  9113. if (sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2))
  9114. {
  9115. item = master_item_list.GetItem(atoul(sep->arg[1]));
  9116. crc = atol(sep->arg[2]);
  9117. }
  9118. }
  9119. else {
  9120. // From the broker and links in chat
  9121. if (strcmp(sep->arg[0], "crc") == 0) {
  9122. if (sep->IsNumber(2) && sep->IsNumber(3)) {
  9123. item = master_item_list.GetItem(atoul(sep->arg[2]));
  9124. crc = atol(sep->arg[3]);
  9125. }
  9126. }
  9127. // From inventory
  9128. if (strcmp(sep->arg[0], "dbid") == 0) {
  9129. if (sep->IsNumber(2) && sep->IsNumber(4)) {
  9130. item = master_item_list.GetItem(atoul(sep->arg[2]));
  9131. crc = atol(sep->arg[4]);
  9132. }
  9133. }
  9134. }
  9135. if (item)
  9136. client->ShowDressingRoom(item, crc);
  9137. }
  9138. }
  9139. void Commands::Command_JoinChannel(Client * client, Seperator *sep) {
  9140. const char *channel_name, *password = NULL;
  9141. if (sep == NULL || !sep->IsSet(0)) {
  9142. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /joinchannel <channel name> [password]");
  9143. return;
  9144. }
  9145. channel_name = sep->arg[0];
  9146. if (sep->IsSet(1))
  9147. password = sep->arg[1];
  9148. if (!chat.ChannelExists(channel_name) && !chat.CreateChannel(channel_name, password)) {
  9149. client->Message(CHANNEL_COLOR_RED, "Unable to create channel '%s'.", channel_name);
  9150. return;
  9151. }
  9152. if (chat.IsInChannel(client, channel_name)) {
  9153. client->Message(CHANNEL_NARRATIVE, "You are already in '%s'.", channel_name);
  9154. return;
  9155. }
  9156. if (chat.HasPassword(channel_name)) {
  9157. if (password == NULL) {
  9158. client->Message(CHANNEL_NARRATIVE, "Unable to join '%s': That channel is password protected.", channel_name);
  9159. return;
  9160. }
  9161. if (!chat.PasswordMatches(channel_name, password)) {
  9162. client->Message(CHANNEL_NARRATIVE, "Unable to join '%s': The password is not correc.t", channel_name);
  9163. return;
  9164. }
  9165. }
  9166. if (!chat.JoinChannel(client, channel_name))
  9167. client->Message(CHANNEL_COLOR_RED, "There was an internal error preventing you from joining '%s'.", channel_name);
  9168. }
  9169. void Commands::Command_JoinChannelFromLoad(Client * client, Seperator *sep) {
  9170. printf("ScatDebug: Received 'joinfromchannel', using the same function as 'joinchannel' (not sure what the difference is)\n");
  9171. Command_JoinChannel(client, sep);
  9172. }
  9173. void Commands::Command_TellChannel(Client *client, Seperator *sep) {
  9174. if (sep == NULL || !sep->IsSet(0) || !sep->IsSet(1)) {
  9175. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /tellchannel <channel name> <message>");
  9176. PrintSep(sep, "tellchannel");
  9177. return;
  9178. }
  9179. chat.TellChannel(client, sep->arg[0], sep->argplus[1]);
  9180. }
  9181. void Commands::Command_Test(Client* client, EQ2_16BitString* command_parms) {
  9182. Seperator* sep = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  9183. if (sep->IsSet(0)) {
  9184. if (atoi(sep->arg[0]) == 1) {
  9185. PacketStruct* packet2 = configReader.getStruct("WS_SpellGainedMsg", client->GetVersion());
  9186. if (packet2) {
  9187. packet2->setDataByName("spell_type", 2);
  9188. packet2->setDataByName("spell_id", 8308);
  9189. packet2->setDataByName("spell_name", "Sprint");
  9190. packet2->setDataByName("add_silently", 0);
  9191. packet2->setDataByName("tier", 1);
  9192. packet2->setDataByName("blah1", 1);
  9193. packet2->setDataByName("blah2", 1);
  9194. EQ2Packet* outapp = packet2->serialize();
  9195. DumpPacket(outapp);
  9196. client->QueuePacket(outapp);
  9197. safe_delete(packet2);
  9198. }
  9199. }
  9200. else if (atoi(sep->arg[0]) == 2) {
  9201. PacketStruct* packet2 = configReader.getStruct("WS_GuildUpdate", client->GetVersion());
  9202. if (packet2) {
  9203. packet2->setDataByName("guild_name", "Test");
  9204. packet2->setDataByName("guild_motd", "Test MOTD");
  9205. packet2->setDataByName("guild_id", 1234);
  9206. packet2->setDataByName("guild_level", 1);
  9207. packet2->setDataByName("unknown", 2);
  9208. packet2->setDataByName("unknown2", 3);
  9209. packet2->setDataByName("exp_current", 1);
  9210. packet2->setDataByName("exp_to_next_level", 4);
  9211. EQ2Packet* outapp = packet2->serialize();
  9212. DumpPacket(outapp);
  9213. client->QueuePacket(outapp);
  9214. safe_delete(packet2);
  9215. }
  9216. }
  9217. else if (atoi(sep->arg[0]) == 3) {
  9218. PacketStruct* packet2 = configReader.getStruct("WS_JoinGuildNotify", client->GetVersion());
  9219. if (packet2) {
  9220. packet2->setDataByName("guild_id", 1234);
  9221. packet2->setDataByName("character_id", 1);
  9222. packet2->setDataByName("account_id", 2);
  9223. packet2->setDataByName("guild_level", 1);
  9224. packet2->setDataByName("name", "Test");
  9225. packet2->setDataByName("unknown2", 0);
  9226. packet2->setDataByName("unknown3", 1);
  9227. packet2->setDataByName("adventure_class", 6);
  9228. packet2->setDataByName("adventure_level", 7);
  9229. packet2->setDataByName("tradeskill_class", 4);
  9230. packet2->setDataByName("tradeskill_level", 5);
  9231. packet2->setDataByName("rank", 0);
  9232. packet2->setDataByName("member_flags", 2);
  9233. packet2->setDataByName("join_date", 1591112273);
  9234. packet2->setDataByName("guild_status", 2);
  9235. packet2->setDataByName("last_login", 1591132273);
  9236. packet2->setDataByName("recruiter_id", 1);
  9237. packet2->setDataByName("points", 2345);
  9238. packet2->setDataByName("note", "note");
  9239. packet2->setMediumStringByName("officer_note", "O note");
  9240. packet2->setMediumStringByName("zone", "Blah");
  9241. EQ2Packet* outapp = packet2->serialize();
  9242. DumpPacket(outapp);
  9243. client->QueuePacket(outapp);
  9244. safe_delete(packet2);
  9245. }
  9246. }
  9247. else if (atoi(sep->arg[0]) == 5) {
  9248. int16 offset = atoi(sep->arg[1]);
  9249. int32 value1 = atol(sep->arg[2]);
  9250. EQ2Packet* outapp = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion(), offset, value1);
  9251. client->QueuePacket(outapp);
  9252. }
  9253. else if (atoi(sep->arg[0]) == 6) {
  9254. Spawn* spawn = client->GetPlayer()->GetTarget();
  9255. if (!spawn)
  9256. spawn = client->GetPlayer();
  9257. else if (spawn->IsEntity())
  9258. ((Entity*)spawn)->SetSpeed(atof(sep->arg[4]));
  9259. spawn->RunToLocation(atof(sep->arg[1]), atof(sep->arg[2]), atof(sep->arg[3]));
  9260. }
  9261. else if (atoi(sep->arg[0]) == 7) {
  9262. int32 id = 0;
  9263. Spawn* spawn = client->GetCurrentZone()->GetSpawn(7720001);
  9264. if (spawn) {
  9265. spawn->SetX(client->GetPlayer()->GetX() + .5, false);
  9266. spawn->SetY(client->GetPlayer()->GetY(), false);
  9267. spawn->SetZ(client->GetPlayer()->GetZ() + .5, false);
  9268. float heading = client->GetPlayer()->GetHeading() + 180;
  9269. if (heading > 360)
  9270. heading -= 360;
  9271. spawn->SetLevel(5);
  9272. spawn->SetAdventureClass(4);
  9273. spawn->SetHeading(heading, false);
  9274. spawn->SetSpawnOrigX(spawn->GetX());
  9275. spawn->SetSpawnOrigY(spawn->GetY());
  9276. spawn->SetSpawnOrigZ(spawn->GetZ());
  9277. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  9278. spawn->SetLocation(client->GetPlayer()->GetLocation());
  9279. spawn->appearance.targetable = 1;
  9280. if (spawn->IsNPC() && spawn->GetTotalHP() == 0) {
  9281. spawn->SetTotalHP(spawn->GetLevel() * 15);
  9282. spawn->SetHP(spawn->GetTotalHP());
  9283. }
  9284. if (spawn->GetTotalPower() == 0) {
  9285. spawn->SetTotalPower(spawn->GetLevel() * 15);
  9286. spawn->SetPower(spawn->GetTotalPower());
  9287. }
  9288. int16 offset = atoi(sep->arg[1]);
  9289. int32 value1 = atol(sep->arg[2]);
  9290. sprintf(spawn->appearance.name, "Offset %i", offset);
  9291. EQ2Packet* ret = spawn->spawn_serialize(client->GetPlayer(), client->GetVersion(), offset, value1);
  9292. DumpPacket(ret);
  9293. client->QueuePacket(ret);
  9294. }
  9295. }
  9296. else if (atoi(sep->arg[0]) == 8) {
  9297. int32 id = atoi(sep->arg[1]);
  9298. Spawn* spawn = client->GetCurrentZone()->GetSpawn(id);
  9299. if (spawn) {
  9300. spawn->SetX(client->GetPlayer()->GetX() + .5, false);
  9301. spawn->SetY(client->GetPlayer()->GetY(), false);
  9302. spawn->SetZ(client->GetPlayer()->GetZ() + .5, false);
  9303. float heading = client->GetPlayer()->GetHeading() + 180;
  9304. if (heading > 360)
  9305. heading -= 360;
  9306. spawn->SetLevel(5);
  9307. spawn->SetAdventureClass(4);
  9308. spawn->SetHeading(heading, false);
  9309. spawn->SetSpawnOrigX(spawn->GetX());
  9310. spawn->SetSpawnOrigY(spawn->GetY());
  9311. spawn->SetSpawnOrigZ(spawn->GetZ());
  9312. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  9313. spawn->SetLocation(client->GetPlayer()->GetLocation());
  9314. spawn->appearance.targetable = 1;
  9315. if (spawn->IsNPC() && spawn->GetTotalHP() == 0) {
  9316. spawn->SetTotalHP(spawn->GetLevel() * 15);
  9317. spawn->SetHP(spawn->GetTotalHP());
  9318. }
  9319. if (spawn->GetTotalPower() == 0) {
  9320. spawn->SetTotalPower(spawn->GetLevel() * 15);
  9321. spawn->SetPower(spawn->GetTotalPower());
  9322. }
  9323. int16 offset = atoi(sep->arg[2]);
  9324. int16 offset2 = atoi(sep->arg[3]);
  9325. int32 value1 = atol(sep->arg[4]);
  9326. int16 offset3 = 0;
  9327. int16 offset4 = 0;
  9328. int32 value2 = 0;
  9329. if (sep->IsSet(7)) {
  9330. offset3 = atoi(sep->arg[5]);
  9331. offset4 = atoi(sep->arg[6]);
  9332. value2 = atol(sep->arg[7]);
  9333. }
  9334. sprintf(spawn->appearance.name, "Offset %i to %i", offset, offset2);
  9335. spawn->AddPrimaryEntityCommand("attack", 10000, "attack","", 0, 0);
  9336. EQ2Packet* ret = spawn->spawn_serialize(client->GetPlayer(), client->GetVersion(), offset, value1, offset2, offset3, offset4, value2);
  9337. DumpPacket(ret);
  9338. client->QueuePacket(ret);
  9339. }
  9340. }
  9341. else if (atoi(sep->arg[0]) == 9) {
  9342. PacketStruct* packet2 = configReader.getStruct("WS_DeathWindow", client->GetVersion());
  9343. if (packet2) {
  9344. packet2->setArrayLengthByName("location_count", 1);
  9345. packet2->setArrayDataByName("location_ida", 1234);
  9346. packet2->setArrayDataByName("unknown2a", 3);
  9347. packet2->setArrayDataByName("zone_name", "Queen's Colony");
  9348. packet2->setArrayDataByName("location_name", "Myrrin's Tower");
  9349. packet2->setArrayDataByName("distance", 134);
  9350. EQ2Packet* app = packet2->serialize();
  9351. if (sep->IsSet(2)) {
  9352. int8 offset = atoi(sep->arg[1]);
  9353. uchar* ptr2 = app->pBuffer;
  9354. ptr2 += offset;
  9355. if (sep->IsNumber(2)) {
  9356. int32 value1 = atol(sep->arg[2]);
  9357. if (value1 > 0xFFFF)
  9358. memcpy(ptr2, (uchar*)&value1, 4);
  9359. else if (value1 > 0xFF)
  9360. memcpy(ptr2, (uchar*)&value1, 2);
  9361. else
  9362. memcpy(ptr2, (uchar*)&value1, 1);
  9363. }
  9364. else {
  9365. int8 len = strlen(sep->arg[2]);
  9366. memcpy(ptr2, (uchar*)&len, 1);
  9367. ptr2 += 1;
  9368. memcpy(ptr2, sep->arg[2], len);
  9369. }
  9370. }
  9371. DumpPacket(app);
  9372. client->QueuePacket(app);
  9373. safe_delete(packet2);
  9374. }
  9375. }
  9376. else if (atoi(sep->arg[0]) == 10) {
  9377. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalUpdate", client->GetVersion());
  9378. if (packet2) {
  9379. packet2->setArrayLengthByName("num_quests", 1);
  9380. packet2->setArrayDataByName("active", 1);
  9381. packet2->setArrayDataByName("name", "Tasks aboard the Far Journey");
  9382. packet2->setArrayDataByName("quest_type", "Hallmark");
  9383. packet2->setArrayDataByName("quest_zone", "Hallmark");
  9384. packet2->setArrayDataByName("journal_updated", 1);
  9385. packet2->setArrayDataByName("quest_id", 524);
  9386. packet2->setArrayDataByName("day", 19);
  9387. packet2->setArrayDataByName("month", 6);
  9388. packet2->setArrayDataByName("year", 20);
  9389. packet2->setArrayDataByName("level", 2);
  9390. packet2->setArrayDataByName("encounter_level", 4);
  9391. packet2->setArrayDataByName("difficulty", 3);
  9392. packet2->setArrayDataByName("visible", 1);
  9393. packet2->setDataByName("visible_quest_id", 524);
  9394. packet2->setDataByName("player_crc", 2900677088);
  9395. packet2->setDataByName("player_name", "LethalEncounter");
  9396. EQ2Packet* app = packet2->serialize();
  9397. if (sep->IsSet(2)) {
  9398. int8 offset = atoi(sep->arg[1]);
  9399. uchar* ptr2 = app->pBuffer;
  9400. ptr2 += offset;
  9401. if (sep->IsNumber(2)) {
  9402. int32 value1 = atol(sep->arg[2]);
  9403. if (value1 > 0xFFFF)
  9404. memcpy(ptr2, (uchar*)&value1, 4);
  9405. else if (value1 > 0xFF)
  9406. memcpy(ptr2, (uchar*)&value1, 2);
  9407. else
  9408. memcpy(ptr2, (uchar*)&value1, 1);
  9409. }
  9410. else {
  9411. int8 len = strlen(sep->arg[2]);
  9412. memcpy(ptr2, (uchar*)&len, 1);
  9413. ptr2 += 1;
  9414. memcpy(ptr2, sep->arg[2], len);
  9415. }
  9416. }
  9417. DumpPacket(app);
  9418. client->QueuePacket(app);
  9419. safe_delete(packet2);
  9420. }
  9421. }
  9422. else if (atoi(sep->arg[0]) == 11) {
  9423. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalReply", client->GetVersion());
  9424. if (packet2) {
  9425. packet2->setDataByName("quest_id", 524);
  9426. packet2->setDataByName("player_crc", 2900677088);
  9427. packet2->setDataByName("name", "Tasks aboard the Far Journey");
  9428. packet2->setDataByName("description", "I completed all the tasks assigned to me by Captain Varlos aboard the Far Journey");
  9429. packet2->setDataByName("type", "Hallmark");
  9430. packet2->setDataByName("complete_header", "To complete this quest, I must do the following tasks:");
  9431. packet2->setDataByName("day", 19);
  9432. packet2->setDataByName("month", 6);
  9433. packet2->setDataByName("year", 20);
  9434. packet2->setDataByName("level", 1);
  9435. packet2->setDataByName("encounter_level", 1);
  9436. packet2->setDataByName("difficulty", 1);
  9437. packet2->setDataByName("time_obtained", Timer::GetUnixTimeStamp());
  9438. //packet2->setDataByName("timer_start", Timer::GetUnixTimeStamp());
  9439. //packet2->setDataByName("timer_duration", 300);
  9440. //packet2->setDataByName("timer_running", 1);
  9441. packet2->setArrayLengthByName("task_groups_completed", 9);
  9442. packet2->setArrayLengthByName("num_task_groups", 10);
  9443. packet2->setArrayDataByName("task_group", "I spoke to Waulon as Captain Varlos had asked of me.");
  9444. packet2->setArrayDataByName("task_group", "I found Waulon's hat in one of the boxes.", 1);
  9445. packet2->setArrayDataByName("task_group", "I returned Waulon's hat.", 2);
  9446. packet2->setArrayDataByName("task_group", "I have spoken to Ingrid.", 3);
  9447. packet2->setArrayDataByName("task_group", "I purchased a Shard of Luclin.", 4);
  9448. packet2->setArrayDataByName("task_group", "I gave the Shard of Luclin to Ingrid.", 5);
  9449. packet2->setArrayDataByName("task_group", "I have spoken to Captain Varlos.", 6);
  9450. packet2->setArrayDataByName("task_group", "I killed the rats that Captain Varlos requested.", 7);
  9451. packet2->setArrayDataByName("task_group", "Captain Varlos has ordered you to kill the escaped goblin.", 8);
  9452. packet2->setArrayDataByName("task_group", "I killed the escaped goblin.", 9);
  9453. /*packet2->setSubArrayLengthByName("num_tasks", 1);
  9454. packet2->setSubArrayDataByName("task", "I need to talk to Garven Tralk");
  9455. packet2->setSubArrayLengthByName("num_updates", 1);
  9456. packet2->setSubArrayDataByName("update_currentval", 0);
  9457. packet2->setSubArrayDataByName("update_maxval", 1);
  9458. packet2->setSubArrayDataByName("icon", 11);
  9459. */
  9460. packet2->setArrayDataByName("waypoint", 0xFFFFFFFF);
  9461. packet2->setDataByName("journal_updated", 1);
  9462. packet2->setDataByName("bullets", 1);
  9463. EQ2Packet* app = packet2->serialize();
  9464. if (sep->IsSet(2)) {
  9465. int16 offset = atoi(sep->arg[1]);
  9466. uchar* ptr2 = app->pBuffer;
  9467. ptr2 += offset;
  9468. if (sep->IsNumber(2)) {
  9469. int32 value1 = atol(sep->arg[2]);
  9470. if (value1 > 0xFFFF)
  9471. memcpy(ptr2, (uchar*)&value1, 4);
  9472. else if (value1 > 0xFF)
  9473. memcpy(ptr2, (uchar*)&value1, 2);
  9474. else
  9475. memcpy(ptr2, (uchar*)&value1, 1);
  9476. }
  9477. else {
  9478. int16 len = strlen(sep->arg[2]);
  9479. memcpy(ptr2, (uchar*)&len, 2);
  9480. ptr2 += 2;
  9481. memcpy(ptr2, sep->arg[2], len);
  9482. }
  9483. }
  9484. DumpPacket(app);
  9485. client->QueuePacket(app);
  9486. safe_delete(packet2);
  9487. }
  9488. }
  9489. else if (atoi(sep->arg[0]) == 12) {
  9490. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalReply", client->GetVersion());
  9491. if (packet2) {
  9492. packet2->setDataByName("quest_id", 524);
  9493. packet2->setDataByName("player_crc", 2900677088);
  9494. packet2->setDataByName("name", "Archetype Selection");
  9495. packet2->setDataByName("description", "I have reported my profession to Garven Tralk.");
  9496. packet2->setDataByName("type", "Hallmark");
  9497. packet2->setDataByName("complete_header", "To complete this quest, I must do the following tasks:");
  9498. packet2->setDataByName("day", 19);
  9499. packet2->setDataByName("month", 6);
  9500. packet2->setDataByName("year", 20);
  9501. packet2->setDataByName("level", 2);
  9502. packet2->setDataByName("encounter_level", 4);
  9503. packet2->setDataByName("difficulty", 3);
  9504. packet2->setDataByName("time_obtained", Timer::GetUnixTimeStamp());
  9505. packet2->setDataByName("timer_start", Timer::GetUnixTimeStamp());
  9506. packet2->setDataByName("timer_duration", 300);
  9507. packet2->setDataByName("timer_running", 1);
  9508. packet2->setArrayLengthByName("task_groups_completed", 0);
  9509. packet2->setArrayLengthByName("num_task_groups", 1);
  9510. packet2->setArrayDataByName("task_group", "I need to talk to Garven Tralk");
  9511. packet2->setSubArrayLengthByName("num_tasks", 1);
  9512. packet2->setSubArrayDataByName("task", "I need to talk to Garven Tralk");
  9513. packet2->setSubArrayLengthByName("num_updates", 1);
  9514. packet2->setSubArrayDataByName("update_currentval", 0);
  9515. packet2->setSubArrayDataByName("update_maxval", 1);
  9516. packet2->setSubArrayDataByName("icon", 11);
  9517. packet2->setArrayDataByName("waypoint", 0xFFFFFFFF);
  9518. packet2->setDataByName("journal_updated", 1);
  9519. packet2->setSubstructDataByName("reward_data", "unknown1", 255);
  9520. packet2->setSubstructDataByName("reward_data", "reward", "Quest Reward!");
  9521. packet2->setSubstructDataByName("reward_data", "unknown2", 0x3f);
  9522. packet2->setSubstructDataByName("reward_data", "coin", 150);
  9523. packet2->setSubstructDataByName("reward_data", "status_points", 5);
  9524. packet2->setSubstructDataByName("reward_data", "exp_bonus", 10);
  9525. packet2->setSubstructArrayLengthByName("reward_data", "num_rewards", 1);
  9526. packet2->setSubstructArrayDataByName("reward_data", "reward_id", 123);
  9527. Item* item = master_item_list.GetItem(152755);
  9528. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9529. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  9530. /*packet2->setSubstructDataByName("item", "unique_id", 567);
  9531. packet2->setSubstructDataByName("item", "broker_item_id", 0xFFFFFFFFFFFFFFFF);
  9532. packet2->setSubstructDataByName("item", "icon", 0xe7);
  9533. packet2->setSubstructDataByName("item", "tier", 4);
  9534. packet2->setSubstructDataByName("item", "flags", 0x60);
  9535. packet2->setSubstructArrayLengthByName("item", "stat_count", 1);
  9536. packet2->setSubstructDataByName("item", "stat_type", 1);
  9537. packet2->setSubstructDataByName("item", "stat_subtype", 2);
  9538. packet2->setSubstructDataByName("item", "value", 3);
  9539. packet2->setSubstructDataByName("item", "condition", 100);
  9540. packet2->setSubstructDataByName("item", "weight", 1);
  9541. packet2->setSubstructDataByName("item", "skill_req1", 0xacafa99e);
  9542. packet2->setSubstructDataByName("item", "skill_req2", 0xacafa99e);
  9543. packet2->setSubstructDataByName("item", "skill_min", 1);
  9544. packet2->setSubstructArrayLengthByName("item", "class_count", 3);
  9545. packet2->setSubstructDataByName("item", "adventure_class", 1);
  9546. packet2->setSubstructDataByName("item", "adventure_class", 11, 0, 1);
  9547. packet2->setSubstructDataByName("item", "adventure_class", 0x1f, 0, 2);
  9548. packet2->setSubstructDataByName("item", "tradeskill_class", 255);
  9549. packet2->setSubstructDataByName("item", "tradeskill_class", 255, 0, 1);
  9550. packet2->setSubstructDataByName("item", "tradeskill_class", 255, 0, 2);
  9551. packet2->setSubstructDataByName("item", "level", 0x1e);
  9552. packet2->setSubstructDataByName("item", "level", 100, 0, 1);
  9553. packet2->setSubstructDataByName("item", "level", 100, 0, 2);
  9554. packet2->setSubstructDataByName("item_footer", "name", "Footman Gloves");*/
  9555. //packet2->PrintPacket();
  9556. EQ2Packet* app = packet2->serialize();
  9557. if (sep->IsSet(2)) {
  9558. int16 offset = atoi(sep->arg[1]);
  9559. uchar* ptr2 = app->pBuffer;
  9560. ptr2 += offset;
  9561. if (sep->IsNumber(2)) {
  9562. int32 value1 = atol(sep->arg[2]);
  9563. if (value1 > 0xFFFF)
  9564. memcpy(ptr2, (uchar*)&value1, 4);
  9565. else if (value1 > 0xFF)
  9566. memcpy(ptr2, (uchar*)&value1, 2);
  9567. else
  9568. memcpy(ptr2, (uchar*)&value1, 1);
  9569. }
  9570. else {
  9571. int16 len = strlen(sep->arg[2]);
  9572. memcpy(ptr2, (uchar*)&len, 2);
  9573. ptr2 += 2;
  9574. memcpy(ptr2, sep->arg[2], len);
  9575. }
  9576. }
  9577. DumpPacket(app);
  9578. client->QueuePacket(app);
  9579. safe_delete(packet2);
  9580. }
  9581. }
  9582. else if (atoi(sep->arg[0]) == 13) {
  9583. PacketStruct* packet2 = configReader.getStruct("WS_OnScreenMsg", client->GetVersion());
  9584. if (packet2 && sep->IsSet(7)) {
  9585. packet2->setDataByName("unknown", atoi(sep->arg[1]));
  9586. char blah[128];
  9587. sprintf(blah, "\\#6EFF6EYou get better at \12\\#C8FFC8%s\\#6EFF6E! (7/15)", sep->arg[2]);
  9588. packet2->setDataByName("text", blah);
  9589. packet2->setDataByName("message_type", sep->arg[3]);
  9590. packet2->setDataByName("size", atof(sep->arg[4]));
  9591. packet2->setDataByName("red", atoi(sep->arg[5]));
  9592. packet2->setDataByName("green", atoi(sep->arg[6]));
  9593. packet2->setDataByName("blue", atoi(sep->arg[7]));
  9594. EQ2Packet* app = packet2->serialize();
  9595. DumpPacket(app);
  9596. client->QueuePacket(app);
  9597. safe_delete(packet2);
  9598. }
  9599. }
  9600. else if (atoi(sep->arg[0]) == 14) {
  9601. PacketStruct* packet2 = configReader.getStruct("WS_InstructionWindow", client->GetVersion());
  9602. if (packet2 && sep->IsSet(3)) {
  9603. packet2->setDataByName("open_seconds_min", atof(sep->arg[1]));
  9604. packet2->setDataByName("open_seconds_max", atof(sep->arg[2]));
  9605. packet2->setDataByName("voice_sync", atoi(sep->arg[3]));
  9606. packet2->setDataByName("text", "Welcome to Norrath, the world of EverQuest II. Left click on the help button at any time for more detailed help and information.");
  9607. packet2->setDataByName("voice", "voiceover/english/narrator/boat_06p_tutorial02/narrator_001_63779ca0.mp3");
  9608. packet2->setArrayLengthByName("num_goals", 1);
  9609. //packet2->setArrayDataByName("goal_text", )
  9610. packet2->setSubArrayLengthByName("num_tasks", 1);
  9611. packet2->setSubArrayDataByName("task_text", "continue");
  9612. packet2->setDataByName("complete_sound", "click");
  9613. packet2->setDataByName("signal", "introduction");
  9614. packet2->setDataByName("voice_key1", 0xcda65173);
  9615. packet2->setDataByName("voice_key2", 0x984bfc6d);
  9616. EQ2Packet* app = packet2->serialize();
  9617. DumpPacket(app);
  9618. client->QueuePacket(app);
  9619. safe_delete(packet2);
  9620. packet2 = configReader.getStruct("WS_ShowWindow", client->GetVersion());
  9621. packet2->setDataByName("window", "MainHUD.StartMenu");
  9622. packet2->setDataByName("show", 1);
  9623. app = packet2->serialize();
  9624. DumpPacket(app);
  9625. client->QueuePacket(app);
  9626. safe_delete(packet2);
  9627. packet2 = configReader.getStruct("WS_FlashWindow", client->GetVersion());
  9628. packet2->setDataByName("window", "MainHUD.StartMenu.help");
  9629. packet2->setDataByName("flash_seconds", 10);
  9630. app = packet2->serialize();
  9631. DumpPacket(app);
  9632. client->QueuePacket(app);
  9633. safe_delete(packet2);
  9634. }
  9635. }
  9636. else if (atoi(sep->arg[0]) == 15) {
  9637. PacketStruct* packet2 = configReader.getStruct("WS_UpdateLoot", client->GetVersion());
  9638. if (packet2) {
  9639. packet2->setArrayLengthByName("loot_count", 1);
  9640. packet2->setArrayDataByName("name", "Test");
  9641. packet2->setArrayDataByName("item_id", 1234);
  9642. packet2->setArrayDataByName("count", 1);
  9643. packet2->setArrayDataByName("icon", 258);
  9644. packet2->setArrayDataByName("ability_id", 0xFFFFFFFF);
  9645. Spawn* spawn = client->GetPlayer()->GetTarget();
  9646. if (spawn)
  9647. packet2->setDataByName("object_id", client->GetPlayer()->GetIDWithPlayerSpawn(spawn));
  9648. packet2->setDataByName("unknown3", 1);
  9649. packet2->setDataByName("unknown4", 1);
  9650. packet2->setDataByName("unknown5", 60);
  9651. EQ2Packet* app = packet2->serialize();
  9652. DumpPacket(app);
  9653. client->QueuePacket(app);
  9654. safe_delete(packet2);
  9655. }
  9656. }
  9657. else if (atoi(sep->arg[0]) == 16 && sep->IsNumber(1)) {
  9658. char blah[32];
  9659. sprintf(blah, "Testing: %i", atoi(sep->arg[1]));
  9660. client->SimpleMessage(atoi(sep->arg[1]), blah);
  9661. }
  9662. else if (atoi(sep->arg[0]) == 17 && sep->IsNumber(2)) {
  9663. if (sep->IsSet(2)) {
  9664. int16 offset = atoi(sep->arg[1]);
  9665. if (sep->IsNumber(2)) {
  9666. int32 value1 = atol(sep->arg[2]);
  9667. client->QueuePacket(client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion(), offset, value1));
  9668. cout << "Sent" << endl;
  9669. }
  9670. }
  9671. }
  9672. else if (atoi(sep->arg[0]) == 18) {
  9673. PacketStruct* packet2 = configReader.getStruct("WS_QuestRewardPackMsg", client->GetVersion());
  9674. if (packet2) {
  9675. packet2->setSubstructDataByName("reward_data", "unknown1", 255);
  9676. packet2->setSubstructDataByName("reward_data", "reward", "Quest Reward!");
  9677. packet2->setSubstructDataByName("reward_data", "max_coin", 0);
  9678. packet2->setSubstructDataByName("reward_data", "text", "Some custom text to mess things up?");
  9679. //packet2->setSubstructDataByName("reward_data", "status_points", 5);
  9680. //packet2->setSubstructDataByName("reward_data", "exp_bonus", 10);
  9681. packet2->setSubstructArrayLengthByName("reward_data", "num_rewards", 1);
  9682. Item* item = new Item(master_item_list.GetItem(9357));
  9683. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9684. //item->stack_count = 20;
  9685. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  9686. safe_delete(item);
  9687. /*item = new Item(master_item_list.GetItem(36685));
  9688. item->stack_count = 20;
  9689. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9690. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 1, 0, -1);
  9691. safe_delete(item);
  9692. item = master_item_list.GetItem(1414);
  9693. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9694. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 2, 0, -1);
  9695. item = master_item_list.GetItem(75057);
  9696. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9697. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 3, 0, -1);*/
  9698. EQ2Packet* app = packet2->serialize();
  9699. if (sep->IsSet(2)) {
  9700. int16 offset = atoi(sep->arg[1]);
  9701. uchar* ptr2 = app->pBuffer;
  9702. ptr2 += offset;
  9703. if (sep->IsNumber(2)) {
  9704. int32 value1 = atol(sep->arg[2]);
  9705. if (value1 > 0xFFFF)
  9706. memcpy(ptr2, (uchar*)&value1, 4);
  9707. else if (value1 > 0xFF)
  9708. memcpy(ptr2, (uchar*)&value1, 2);
  9709. else
  9710. memcpy(ptr2, (uchar*)&value1, 1);
  9711. }
  9712. else {
  9713. int16 len = strlen(sep->arg[2]);
  9714. memcpy(ptr2, (uchar*)&len, 2);
  9715. ptr2 += 2;
  9716. memcpy(ptr2, sep->arg[2], len);
  9717. }
  9718. }
  9719. DumpPacket(app);
  9720. client->QueuePacket(app);
  9721. safe_delete(packet2);
  9722. }
  9723. }
  9724. else if (atoi(sep->arg[0]) == 19) {
  9725. PacketStruct* packet2 = configReader.getStruct("WS_UpdateLoot", client->GetVersion());
  9726. Spawn* spawn = client->GetPlayer()->GetTarget();
  9727. if (packet2 && spawn) {
  9728. Item* item = master_item_list.GetItem(130053);
  9729. packet2->setArrayLengthByName("loot_count", 1);
  9730. packet2->setArrayDataByName("loot_id", item->details.item_id);
  9731. packet2->setArrayDataByName("unknown2", 1);
  9732. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, 2, true);
  9733. packet2->setDataByName("display", 1);
  9734. packet2->setDataByName("unknown2b", 1);
  9735. packet2->setDataByName("unknown3", 0x3c);
  9736. packet2->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(spawn));
  9737. packet2->PrintPacket();
  9738. EQ2Packet* app = packet2->serialize();
  9739. if (sep->IsSet(2)) {
  9740. int16 offset = atoi(sep->arg[1]);
  9741. int16 offset2 = 0;
  9742. int32 value1 = 0;
  9743. if (sep->IsSet(3)) {
  9744. offset2 = atoi(sep->arg[2]);
  9745. value1 = atol(sep->arg[3]);
  9746. }
  9747. else
  9748. value1 = atol(sep->arg[2]);
  9749. int16 offset3 = 0;
  9750. int16 offset4 = 0;
  9751. int32 value2 = 0;
  9752. if (sep->IsSet(6)) {
  9753. offset3 = atoi(sep->arg[4]);
  9754. offset4 = atoi(sep->arg[5]);
  9755. value2 = atol(sep->arg[6]);
  9756. }
  9757. offset--;
  9758. if (offset2 > 0 && offset2 >= offset) {
  9759. offset2--;
  9760. uchar* ptr2 = app->pBuffer;
  9761. ptr2 += offset;
  9762. for (int i = offset; i <= offset2; i++) {
  9763. if (value1 > 0xFFFF) {
  9764. memcpy(ptr2, (uchar*)&value1, 4);
  9765. i += 3;
  9766. ptr2 += 3;
  9767. }
  9768. else if (value1 > 0xFF) {
  9769. memcpy(ptr2, (uchar*)&value1, 2);
  9770. i++;
  9771. ptr2++;
  9772. }
  9773. else
  9774. memcpy(ptr2, (uchar*)&value1, 1);
  9775. ptr2++;
  9776. }
  9777. }
  9778. if (offset4 > 0 && offset4 >= offset3) {
  9779. offset3--;
  9780. offset4--;
  9781. uchar* ptr2 = app->pBuffer;
  9782. ptr2 += offset3;
  9783. for (int i = offset3; i <= offset4; i++) {
  9784. if (value2 > 0xFFFF) {
  9785. memcpy(ptr2, (uchar*)&value2, 4);
  9786. i += 3;
  9787. ptr2 += 3;
  9788. }
  9789. else if (value2 > 0xFF) {
  9790. memcpy(ptr2, (uchar*)&value2, 2);
  9791. i++;
  9792. ptr2++;
  9793. }
  9794. else
  9795. memcpy(ptr2, (uchar*)&value2, 1);
  9796. ptr2++;
  9797. }
  9798. }
  9799. }
  9800. DumpPacket(app);
  9801. client->QueuePacket(app);
  9802. safe_delete(packet2);
  9803. }
  9804. }
  9805. else if (atoi(sep->arg[0]) == 21) {
  9806. PacketStruct* packet2 = configReader.getStruct("WS_OfferQuest", client->GetVersion());
  9807. if (packet2) {
  9808. packet2->setDataByName("unknown0", 255);
  9809. packet2->setDataByName("reward", "New Quest");
  9810. packet2->setDataByName("title", "Title");
  9811. packet2->setDataByName("description", "description");
  9812. packet2->setDataByName("quest_difficulty", 3);
  9813. packet2->setDataByName("unknown1", 5);
  9814. packet2->setDataByName("level", 3);
  9815. packet2->setDataByName("coin", 150);
  9816. packet2->setDataByName("status_points", 5);
  9817. packet2->setDataByName("exp_bonus", 10);
  9818. packet2->setArrayLengthByName("num_rewards", 1);
  9819. Item* item = new Item(master_item_list.GetItem(36212));
  9820. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9821. item->stack_count = 20;
  9822. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  9823. safe_delete(item);
  9824. char accept[35] = { 0 };
  9825. char decline[35] = { 0 };
  9826. sprintf(accept, "q_accept_pending_quest %u", 0);
  9827. sprintf(decline, "q_deny_pending_quest %u", 0);
  9828. packet2->setDataByName("accept_command", accept);
  9829. packet2->setDataByName("decline_command", decline);
  9830. EQ2Packet* app = packet2->serialize();
  9831. if (sep->IsSet(2)) {
  9832. int16 offset = atoi(sep->arg[1]);
  9833. uchar* ptr2 = app->pBuffer;
  9834. ptr2 += offset;
  9835. if (sep->IsNumber(2)) {
  9836. int32 value1 = atol(sep->arg[2]);
  9837. if (value1 > 0xFFFF)
  9838. memcpy(ptr2, (uchar*)&value1, 4);
  9839. else if (value1 > 0xFF)
  9840. memcpy(ptr2, (uchar*)&value1, 2);
  9841. else
  9842. memcpy(ptr2, (uchar*)&value1, 1);
  9843. }
  9844. DumpPacket(app);
  9845. client->QueuePacket(app);
  9846. safe_delete(packet2);
  9847. }
  9848. }
  9849. }
  9850. else if (atoi(sep->arg[0]) == 22) { //same as 21, but 8bit string
  9851. PacketStruct* packet2 = configReader.getStruct("WS_OfferQuest", client->GetVersion());
  9852. if (packet2) {
  9853. packet2->setDataByName("unknown0", 255);
  9854. packet2->setDataByName("reward", "New Quest");
  9855. packet2->setDataByName("title", "Title");
  9856. packet2->setDataByName("description", "description");
  9857. packet2->setDataByName("quest_difficulty", 3);
  9858. packet2->setDataByName("unknown1", 5);
  9859. packet2->setDataByName("level", 3);
  9860. packet2->setDataByName("coin", 150);
  9861. packet2->setDataByName("status_points", 5);
  9862. packet2->setDataByName("exp_bonus", 10);
  9863. packet2->setArrayLengthByName("num_rewards", 1);
  9864. Item* item = new Item(master_item_list.GetItem(36212));
  9865. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9866. item->stack_count = 20;
  9867. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  9868. safe_delete(item);
  9869. char accept[35] = { 0 };
  9870. char decline[35] = { 0 };
  9871. sprintf(accept, "q_accept_pending_quest %u", 0);
  9872. sprintf(decline, "q_deny_pending_quest %u", 0);
  9873. packet2->setDataByName("accept_command", accept);
  9874. packet2->setDataByName("decline_command", decline);
  9875. EQ2Packet* app = packet2->serialize();
  9876. if (sep->IsSet(2)) {
  9877. int16 offset = atoi(sep->arg[1]);
  9878. uchar* ptr2 = app->pBuffer;
  9879. ptr2 += offset;
  9880. if (sep->IsNumber(2)) {
  9881. int32 value1 = atol(sep->arg[2]);
  9882. if (value1 > 0xFFFF)
  9883. memcpy(ptr2, (uchar*)&value1, 4);
  9884. else if (value1 > 0xFF)
  9885. memcpy(ptr2, (uchar*)&value1, 2);
  9886. else
  9887. memcpy(ptr2, (uchar*)&value1, 1);
  9888. }
  9889. else {
  9890. int8 len = strlen(sep->arg[2]);
  9891. memcpy(ptr2, (uchar*)&len, 1);
  9892. ptr2 += 1;
  9893. memcpy(ptr2, sep->arg[2], len);
  9894. }
  9895. }
  9896. DumpPacket(app);
  9897. client->QueuePacket(app);
  9898. safe_delete(packet2);
  9899. }
  9900. }
  9901. else if (atoi(sep->arg[0]) == 23) {
  9902. if (client->GetPlayer()->GetTarget()) {
  9903. PacketStruct* packet2 = configReader.getStruct("WS_UpdateMerchant", client->GetVersion());
  9904. if (packet2) {
  9905. Spawn* target = client->GetPlayer()->GetTarget();
  9906. packet2->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(target));
  9907. Item* item = new Item(master_item_list.GetItem(12565));
  9908. int8 i = 0;
  9909. packet2->setArrayLengthByName("num_items", 1);
  9910. packet2->setArrayDataByName("item_name", item->name.c_str(), i);
  9911. packet2->setArrayDataByName("item_id", item->details.item_id, i);
  9912. packet2->setArrayDataByName("stack_size", item->stack_count, i);
  9913. packet2->setArrayDataByName("icon", item->details.icon, i);
  9914. int8 tmp_level = 0;
  9915. if (item->generic_info.adventure_default_level > 0)
  9916. tmp_level = item->generic_info.adventure_default_level;
  9917. else
  9918. tmp_level = item->generic_info.tradeskill_default_level;
  9919. packet2->setArrayDataByName("level", tmp_level, i);
  9920. packet2->setArrayDataByName("tier", item->details.tier, i);
  9921. packet2->setArrayDataByName("item_id2", item->details.item_id, i);
  9922. int8 item_difficulty = client->GetPlayer()->GetArrowColor(tmp_level);
  9923. if (item_difficulty != ARROW_COLOR_WHITE && item_difficulty != ARROW_COLOR_RED && item_difficulty != ARROW_COLOR_GRAY)
  9924. item_difficulty = ARROW_COLOR_WHITE;
  9925. item_difficulty -= 6;
  9926. if (item_difficulty < 0)
  9927. item_difficulty *= -1;
  9928. packet2->setArrayDataByName("item_difficulty", item_difficulty, i);
  9929. packet2->setArrayDataByName("quantity", 2, i);
  9930. packet2->setArrayDataByName("unknown5", 255, i);
  9931. packet2->setArrayDataByName("stack_size2", item->stack_count, i);
  9932. packet2->setArrayDataByName("description", item->description.c_str(), i);
  9933. packet2->setDataByName("type", 2);
  9934. EQ2Packet* app = packet2->serialize();
  9935. if (sep->IsSet(2)) {
  9936. int16 offset = atoi(sep->arg[1]);
  9937. uchar* ptr2 = app->pBuffer;
  9938. ptr2 += offset;
  9939. if (sep->IsNumber(2)) {
  9940. int32 value1 = atol(sep->arg[2]);
  9941. if (value1 > 0xFFFF)
  9942. memcpy(ptr2, (uchar*)&value1, 4);
  9943. else if (value1 > 0xFF)
  9944. memcpy(ptr2, (uchar*)&value1, 2);
  9945. else
  9946. memcpy(ptr2, (uchar*)&value1, 1);
  9947. }
  9948. else {
  9949. int8 len = strlen(sep->arg[2]);
  9950. memcpy(ptr2, (uchar*)&len, 1);
  9951. ptr2 += 1;
  9952. memcpy(ptr2, sep->arg[2], len);
  9953. }
  9954. }
  9955. DumpPacket(app);
  9956. client->QueuePacket(app);
  9957. safe_delete(packet2);
  9958. }
  9959. }
  9960. }
  9961. else if (atoi(sep->arg[0]) == 24) {
  9962. PacketStruct* packet2 = configReader.getStruct("WS_EnableGameEvent", client->GetVersion());
  9963. if (packet2) {
  9964. if (sep->IsSet(2)) {
  9965. packet2->setDataByName("event_name", sep->arg[1]);
  9966. packet2->setDataByName("enabled", atoi(sep->arg[2]));
  9967. EQ2Packet* app = packet2->serialize();
  9968. DumpPacket(app);
  9969. client->QueuePacket(app);
  9970. safe_delete(packet2);
  9971. }
  9972. }
  9973. }
  9974. else if (atoi(sep->arg[0]) == 25) {
  9975. if (sep->IsSet(1)) {
  9976. Widget* new_spawn = new Widget();
  9977. int32 id = atoul(sep->arg[1]);
  9978. new_spawn->SetWidgetID(id);
  9979. EQ2Packet* ret = new_spawn->serialize(client->GetPlayer(), client->GetVersion());
  9980. client->QueuePacket(ret);
  9981. int8 index = client->GetPlayer()->GetIndexForSpawn(new_spawn);
  9982. PacketStruct* packet2 = configReader.getStruct("WS_DestroyGhostCmd", client->GetVersion());
  9983. if (packet2) {
  9984. packet2->setDataByName("spawn_index", index);
  9985. packet2->setDataByName("delete", 1);
  9986. EQ2Packet* app = packet2->serialize();
  9987. client->QueuePacket(app);
  9988. safe_delete(packet2);
  9989. }
  9990. }
  9991. }
  9992. else if (atoi(sep->arg[0]) == 26) {
  9993. if (sep->IsSet(4)) {
  9994. Widget* new_spawn = new Widget();
  9995. int32 id = atoul(sep->arg[1]);
  9996. new_spawn->SetWidgetID(id);
  9997. float x = atof(sep->arg[2]);
  9998. float y = atof(sep->arg[3]);
  9999. float z = atof(sep->arg[4]);
  10000. new_spawn->SetLocation(client->GetPlayer()->GetLocation());
  10001. new_spawn->SetWidgetX(x);
  10002. new_spawn->SetWidgetY(y);
  10003. new_spawn->SetWidgetZ(z);
  10004. new_spawn->SetX(x);
  10005. new_spawn->SetY(y);
  10006. new_spawn->SetZ(z);
  10007. EQ2Packet* ret = new_spawn->serialize(client->GetPlayer(), client->GetVersion());
  10008. client->QueuePacket(ret);
  10009. }
  10010. }
  10011. else if (atoi(sep->arg[0]) == 27) {
  10012. Spawn* target = client->GetPlayer()->GetTarget();
  10013. PacketStruct* packet2 = configReader.getStruct("WS_HearSimpleDamage", client->GetVersion());
  10014. if (packet2 && target && sep->IsSet(4)) {
  10015. client->GetPlayer()->GetZone()->SendDamagePacket(client->GetPlayer(), target, atoul(sep->arg[1]), atoul(sep->arg[2]), atoul(sep->arg[3]), atoul(sep->arg[4]), sep->arg[5] != nullptr ? sep->arg[5] : "");
  10016. }
  10017. }
  10018. else if (atoi(sep->arg[0]) == 28 && sep->IsNumber(1)) {
  10019. World::newValue = strtoull(sep->arg[1], NULL, 0);
  10020. }
  10021. else if (atoi(sep->arg[0]) == 29 && sep->IsNumber(1)) {
  10022. client->SendHearCast(client->GetPlayer(), client->GetPlayer()->GetTarget() ? client->GetPlayer()->GetTarget() : client->GetPlayer(),
  10023. strtoull(sep->arg[1], NULL, 0), atoul(sep->arg[2]));
  10024. }
  10025. else if (atoi(sep->arg[0]) == 30) {
  10026. PacketStruct* packet = configReader.getStruct("WS_UpdateSkillBook", client->GetVersion());
  10027. if (packet) {
  10028. packet->setDataByName("unknown", World::newValue);
  10029. EQ2Packet* outapp = packet->serialize();
  10030. DumpPacket(outapp);
  10031. client->QueuePacket(outapp);
  10032. safe_delete(packet);
  10033. }
  10034. }
  10035. else if (atoi(sep->arg[0]) == 31) {
  10036. client->SendRecipeList();
  10037. }
  10038. else if (atoi(sep->arg[0]) == 32 && sep->IsNumber(1) && sep->IsNumber(2)) {
  10039. if(client->GetVersion() <= 546) {
  10040. int32 param = atoul(sep->arg[1]);
  10041. int32 paramvalue = atoul(sep->arg[2]);
  10042. client->Message(CHANNEL_COLOR_YELLOW, "Send control flag param %u param value %u", param, paramvalue);
  10043. ClientPacketFunctions::SendServerControlFlagsClassic(client, param, paramvalue);
  10044. }
  10045. else if(sep->IsNumber(3)) {
  10046. int8 param1 = atoul(sep->arg[1]);
  10047. int8 param2 = atoul(sep->arg[2]);
  10048. int8 paramval = atoul(sep->arg[3]);
  10049. client->Message(CHANNEL_COLOR_YELLOW, "Send control flag param1 %u param2 %u param value %u", param1, param2, paramval);
  10050. ClientPacketFunctions::SendServerControlFlags(client, param1, param2, paramval);
  10051. }
  10052. }
  10053. else if (atoi(sep->arg[0]) == 33 && sep->IsNumber(1) && sep->IsNumber(2)) {
  10054. client->GetCurrentZone()->SendHealPacket(client->GetPlayer(), client->GetPlayer()->GetTarget() ? client->GetPlayer()->GetTarget() : client->GetPlayer(),
  10055. atoul(sep->arg[1]), atoul(sep->arg[2]), "TestSpell");
  10056. }
  10057. }
  10058. else {
  10059. PacketStruct* packet2 = configReader.getStruct("WS_ExamineSpellInfo", client->GetVersion());
  10060. if (packet2) {
  10061. packet2->setSubstructDataByName("info_header", "show_name", 1);
  10062. packet2->setSubstructDataByName("info_header", "unknown", 7);
  10063. packet2->setSubstructDataByName("info_header", "unknown2", 1);
  10064. packet2->setSubstructDataByName("info_header", "unknown3", 1);
  10065. packet2->setSubstructDataByName("info_header", "unknown4", 1);
  10066. packet2->setSubstructDataByName("info_header", "unknown5", 1);
  10067. packet2->setSubstructDataByName("info_header", "unknown6", "Testing");
  10068. packet2->setSubstructDataByName("info_header", "unknown7", "Testing");
  10069. packet2->setSubstructDataByName("info_header", "unknown8", 66);
  10070. packet2->setSubstructDataByName("info_header", "title", "Blah Title Blah");
  10071. packet2->setSubstructDataByName("info_header", "title_text", "Blah Blah");
  10072. packet2->setSubstructDataByName("info_header", "title_text2", "Blah Blah2");
  10073. packet2->setSubstructDataByName("info_header", "show_popup", 1);
  10074. packet2->setSubstructDataByName("info_header", "packettype", 3);
  10075. packet2->setSubstructDataByName("spell_info", "skill_name", "Testing");
  10076. packet2->setSubstructDataByName("spell_info", "level", 19);
  10077. packet2->setSubstructDataByName("spell_info", "tier", 1);
  10078. packet2->setSubstructDataByName("spell_info", "health_cost", 5);
  10079. packet2->setSubstructDataByName("spell_info", "min_class_skill_req", 3);
  10080. packet2->setSubstructDataByName("spell_info", "mana_cost", 6);
  10081. packet2->setSubstructDataByName("spell_info", "req_concentration", 7);
  10082. packet2->setSubstructDataByName("spell_info", "cast_time", 200);
  10083. packet2->setSubstructDataByName("spell_info", "recovery", 220);
  10084. packet2->setSubstructDataByName("spell_info", "recast", 280);
  10085. packet2->setSubstructDataByName("spell_info", "beneficial", 1);
  10086. packet2->setSubstructDataByName("spell_info", "maintained", 1);
  10087. packet2->setSubstructDataByName("spell_info", "spell_book_type", 1);
  10088. packet2->setSubstructDataByName("spell_info", "quality", 3);
  10089. packet2->setSubstructDataByName("spell_info", "test_1a", 1);
  10090. packet2->setSubstructDataByName("spell_info", "test_1b", 1);
  10091. packet2->setSubstructDataByName("spell_info", "test_1c", 1);
  10092. packet2->setSubstructDataByName("spell_info", "test_1d", 1);
  10093. packet2->setSubstructDataByName("spell_info", "test_2a", 2);
  10094. packet2->setSubstructDataByName("spell_info", "test_2b", 2);
  10095. packet2->setSubstructDataByName("spell_info", "test_2c", 2);
  10096. packet2->setSubstructDataByName("spell_info", "test_2d", 2);
  10097. packet2->setSubstructDataByName("spell_info", "test_3", 3);
  10098. packet2->setSubstructDataByName("spell_info", "test_4", 4);
  10099. packet2->setSubstructDataByName("spell_info", "test_5", 5);
  10100. packet2->setSubstructDataByName("spell_info", "test_6", 6);
  10101. packet2->setSubstructDataByName("spell_info", "min_class_skill_req", 1);
  10102. packet2->setSubstructDataByName("spell_info", "min_class_skill_rec", 30123);
  10103. packet2->setSubstructDataByName("spell_info", "num_reagents", 1);
  10104. packet2->setSubstructArrayLengthByName("spell_info", "num_reagents", 1);
  10105. packet2->setArrayDataByName("reagent", "Alcohol");
  10106. packet2->setArrayDataByName("consumed", "123");
  10107. packet2->setSubstructDataByName("spell_info", "class_skill", 52);
  10108. packet2->setSubstructDataByName("spell_info", "id", 8308);
  10109. packet2->setSubstructDataByName("spell_info", "icon", 303);
  10110. packet2->setSubstructDataByName("spell_info", "icon2", 0xFFFF);
  10111. packet2->setSubstructDataByName("spell_info", "icontype", 317);
  10112. packet2->setSubstructDataByName("spell_info", "type", 2);
  10113. packet2->setSubstructDataByName("spell_info", "spell_text_color", 255);
  10114. packet2->setSubstructDataByName("spell_info", "duration1", 600);
  10115. packet2->setSubstructDataByName("spell_info", "duration2", 600);
  10116. packet2->setSubstructDataByName("spell_info", "name", "Sprint");
  10117. packet2->setSubstructDataByName("spell_info", "description", "Test description");
  10118. EQ2Packet* outapp = packet2->serialize();
  10119. DumpPacket(outapp);
  10120. client->QueuePacket(outapp);
  10121. safe_delete(packet2);
  10122. }
  10123. }
  10124. return;
  10125. PacketStruct* p = configReader.getStruct("WS_EqTargetItemCmd", client->GetVersion());
  10126. if (!p) return;
  10127. //Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  10128. //client->GetCurrentZone()->SendSpellFailedPacket(client, atoi(sep2->arg[0]));
  10129. //}
  10130. /*Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  10131. if (sep2 && sep2->arg[0] && sep2->IsNumber(0)) {
  10132. client->SetPendingFlightPath(atoi(sep2->arg[0]));
  10133. PacketStruct* packet = configReader.getStruct("WS_ReadyForTakeOff", client->GetVersion());
  10134. if (packet) {
  10135. client->QueuePacket(packet->serialize());
  10136. safe_delete(packet);
  10137. }
  10138. }*/
  10139. /*if (client->GetCurrentZone()->Grid != nullptr) {
  10140. int32 numFaces = 0;
  10141. int32 numGrids = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.size();
  10142. client->Message(CHANNEL_COLOR_YELLOW, "Num grids in cell: %u", numGrids);
  10143. map<int32, vector<Face*> >::iterator itr;
  10144. for (itr = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.begin(); itr != client->GetPlayer()->Cell_Info.CurrentCell->FaceList.end(); itr++)
  10145. numFaces += (*itr).second.size();
  10146. client->Message(CHANNEL_COLOR_YELLOW, "Num faces in cell: %u", numFaces);
  10147. }*/
  10148. //uchar blah[] = {
  10149. // 1208 - OP_EQUpdateStoreCmd
  10150. // /*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
  10151. // /*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
  10152. // 1193 - -- OP_ClientCmdMsg::OP_EqUpdateMerchantCmd --
  10153. // /*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
  10154. /*};
  10155. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  10156. int8 val = 0;
  10157. int16 pos = 0;
  10158. int idx = 0;
  10159. while(sep2 && sep2->arg[idx+1] && sep2->IsNumber(idx) && sep2->IsNumber(idx+1)){
  10160. pos = atoi(sep2->arg[idx]);
  10161. val = atoi(sep2->arg[idx+1]);
  10162. memset(blah+pos, val, 1);
  10163. idx+=2;
  10164. }
  10165. DumpPacket(blah, sizeof(blah));
  10166. client->QueuePacket(new EQ2Packet(OP_GroupCreatedMsg , blah, sizeof(blah)));*/
  10167. if (client->GetPlayer()->GetTarget()) {
  10168. PacketStruct* packet = configReader.getStruct("WS_SetControlGhost", client->GetVersion());
  10169. if (packet) {
  10170. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  10171. packet->setDataByName("size", 0);
  10172. packet->setDataByName("unknown2", 0);
  10173. EQ2Packet* app = packet->serialize();
  10174. client->QueuePacket(app);
  10175. safe_delete(packet);
  10176. }
  10177. PacketStruct* set_pov = configReader.getStruct("WS_SetPOVGhostCmd", client->GetVersion());
  10178. if (set_pov) {
  10179. set_pov->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  10180. EQ2Packet* app_pov = set_pov->serialize();
  10181. client->QueuePacket(app_pov);
  10182. safe_delete(set_pov);
  10183. }
  10184. }
  10185. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  10186. PacketStruct* packet = configReader.getStruct("WS_OpenCharCust", client->GetVersion());
  10187. if (packet) {
  10188. if (sep2 && sep2->arg[0] && sep2->IsNumber(0))
  10189. packet->setDataByName("Type", atoi(sep2->arg[0]));
  10190. else
  10191. packet->setDataByName("Type", 2);
  10192. if (sep2 && sep2->arg[1] && sep2->IsNumber(1))
  10193. packet->setDataByName("race_id", atoi(sep2->arg[1]));
  10194. else
  10195. packet->setDataByName("race_id", 0);
  10196. if (sep2 && sep2->arg[2] && sep2->IsNumber(2))
  10197. packet->setDataByName("gender", atoi(sep2->arg[2]));
  10198. else
  10199. packet->setDataByName("gender", 2);
  10200. if (sep2 && sep2->arg[3] && sep2->IsNumber(3))
  10201. packet->setDataByName("unknown", atoi(sep2->arg[3]), 0);
  10202. else
  10203. packet->setDataByName("unknown", 0, 0);
  10204. if (sep2 && sep2->arg[4] && sep2->IsNumber(4))
  10205. packet->setDataByName("unknown", atoi(sep2->arg[4]), 1);
  10206. else
  10207. packet->setDataByName("unknown", 0, 1);
  10208. if (sep2 && sep2->arg[5] && sep2->IsNumber(5))
  10209. packet->setDataByName("unknown", atoi(sep2->arg[5]), 2);
  10210. else
  10211. packet->setDataByName("unknown", 0, 2);
  10212. client->QueuePacket(packet->serialize());
  10213. }
  10214. safe_delete(packet);
  10215. safe_delete(sep2);
  10216. }
  10217. void Commands::Command_LeaveChannel(Client *client, Seperator *sep) {
  10218. const char *channel_name;
  10219. if (sep == NULL || !sep->IsSet(0)) {
  10220. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /leavechat <channel name>");
  10221. PrintSep(sep);
  10222. return;
  10223. }
  10224. channel_name = sep->arg[0];
  10225. if (!chat.IsInChannel(client, channel_name))
  10226. client->Message(CHANNEL_NARRATIVE, "Unable to leave '%s': You are not in the channel.", channel_name);
  10227. else if (!chat.LeaveChannel(client, channel_name))
  10228. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an internal error preventing you from leaving that channel MUAHAHA");
  10229. }
  10230. /*
  10231. Function:
  10232. Purpose :
  10233. Params :
  10234. Dev :
  10235. Example :
  10236. */
  10237. void Commands::Command_WeaponStats(Client* client)
  10238. {
  10239. Player* player = client->GetPlayer();
  10240. Spawn* target = player->GetTarget();
  10241. Item* primary = player->GetEquipmentList()->GetItem(EQ2_PRIMARY_SLOT);
  10242. Item* secondary = player->GetEquipmentList()->GetItem(EQ2_SECONDARY_SLOT);
  10243. Item* ranged = player->GetEquipmentList()->GetItem(EQ2_RANGE_SLOT);
  10244. const char* charName = player->GetName();
  10245. if(target && target->IsEntity()) {
  10246. primary = ((Entity*)target)->GetEquipmentList()->GetItem(EQ2_PRIMARY_SLOT);
  10247. secondary = ((Entity*)target)->GetEquipmentList()->GetItem(EQ2_SECONDARY_SLOT);
  10248. ranged = ((Entity*)target)->GetEquipmentList()->GetItem(EQ2_RANGE_SLOT);
  10249. charName = target->GetName();
  10250. }
  10251. else {
  10252. target = nullptr;
  10253. }
  10254. client->Message(0, "WeaponStats for %s", charName);
  10255. client->SimpleMessage(0, "Primary:");
  10256. if (primary) {
  10257. client->Message(0, "Name: %s", primary->name.c_str());
  10258. client->Message(0, "Base Damage: %u - %u", primary->weapon_info->damage_low3, primary->weapon_info->damage_high3);
  10259. client->Message(0, "Actual Damage: %u - %u", target ? ((Entity*)target)->GetPrimaryWeaponMinDamage() : player->GetPrimaryWeaponMinDamage(),
  10260. target ? ((Entity*)target)->GetPrimaryWeaponMaxDamage() : player->GetPrimaryWeaponMaxDamage());
  10261. client->Message(0, "Actual Delay: %u", target ? ((Entity*)target)->GetPrimaryWeaponDelay() : player->GetPrimaryWeaponDelay());
  10262. client->Message(0, "Proc Percent: %d%%", 0);
  10263. client->Message(0, "Procs Per Minute: %d", 0);
  10264. }
  10265. else {
  10266. client->SimpleMessage(0, "Name: fist");
  10267. client->Message(0, "Base Damage: %u - %u", target ? ((Entity*)target)->GetPrimaryWeaponMinDamage() : player->GetPrimaryWeaponMinDamage(),
  10268. target ? ((Entity*)target)->GetPrimaryWeaponMaxDamage() : player->GetPrimaryWeaponMaxDamage());
  10269. client->Message(0, "Actual Damage: %u - %u", target ? ((Entity*)target)->GetPrimaryWeaponMinDamage() : player->GetPrimaryWeaponMinDamage(),
  10270. target ? ((Entity*)target)->GetPrimaryWeaponMaxDamage() : player->GetPrimaryWeaponMaxDamage());
  10271. client->Message(0, "Actual Delay: %d", target ? ((Entity*)target)->GetPrimaryWeaponDelay() : player->GetPrimaryWeaponDelay() * 0.1);
  10272. client->Message(0, "Proc Percent: %d%%", 0);
  10273. client->Message(0, "Procs Per Minute: %d", 0);
  10274. }
  10275. client->SimpleMessage(0, " ");
  10276. client->SimpleMessage(0, " ");
  10277. if (secondary) {
  10278. client->SimpleMessage(0, "Secondary:");
  10279. client->Message(0, "Name: %s", secondary->name.c_str());
  10280. client->Message(0, "Base Damage: %u - %u", secondary->weapon_info->damage_low3, secondary->weapon_info->damage_high3);
  10281. client->Message(0, "Actual Damage: %u - %u", target ? ((Entity*)target)->GetSecondaryWeaponMinDamage() : player->GetSecondaryWeaponMinDamage(),
  10282. target ? ((Entity*)target)->GetSecondaryWeaponMaxDamage() : player->GetSecondaryWeaponMaxDamage());
  10283. client->Message(0, "Actual Delay: %d", target ? ((Entity*)target)->GetSecondaryWeaponDelay() : player->GetSecondaryWeaponDelay() * 0.1);
  10284. client->Message(0, "Proc Percent: %d%%", 0);
  10285. client->Message(0, "Procs Per Minute: %d", 0);
  10286. client->SimpleMessage(0, " ");
  10287. client->SimpleMessage(0, " ");
  10288. }
  10289. client->SimpleMessage(0, "Ranged:");
  10290. if (ranged) {
  10291. client->Message(0, "Name: %s", ranged->name.c_str());
  10292. client->Message(0, "Base Damage: %u - %u", ranged->ranged_info->weapon_info.damage_low3, ranged->ranged_info->weapon_info.damage_high3);
  10293. client->Message(0, "Actual Damage: %u - %u", target ? ((Entity*)target)->GetRangedWeaponMinDamage() : player->GetRangedWeaponMinDamage(),
  10294. target ? ((Entity*)target)->GetRangedWeaponMaxDamage() : player->GetRangedWeaponMaxDamage());
  10295. client->Message(0, "Actual Delay: %d", target ? ((Entity*)target)->GetRangeWeaponDelay() : player->GetRangeWeaponDelay() * 0.1);
  10296. client->Message(0, "Proc Percent: %d%%", 0);
  10297. client->Message(0, "Procs Per Minute: %d", 0);
  10298. }
  10299. else
  10300. client->SimpleMessage(0, "None");
  10301. }
  10302. void Commands::Command_WhoChannel(Client *client, Seperator *sep) {
  10303. const char *channel_name;
  10304. if (sep == NULL || !sep->IsSet(0)) {
  10305. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /chatwho <channel name>");
  10306. return;
  10307. }
  10308. channel_name = sep->arg[0];
  10309. if (!chat.ChannelExists(channel_name))
  10310. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That channel does not exist!");
  10311. else
  10312. chat.SendChannelUserList(client, channel_name);
  10313. }
  10314. void Commands::Command_ZoneSafeCoords(Client *client, Seperator *sep)
  10315. {
  10316. ZoneServer* zone = 0;
  10317. int32 zone_id = client->GetPlayer()->GetZone()->GetZoneID();
  10318. if (zone_id > 0)
  10319. {
  10320. zone = zone_list.Get(zone_id, false, false, false);
  10321. if (zone)
  10322. {
  10323. zone->SetSafeX(client->GetPlayer()->GetX());
  10324. zone->SetSafeY(client->GetPlayer()->GetY());
  10325. zone->SetSafeZ(client->GetPlayer()->GetZ());
  10326. zone->SetSafeHeading(client->GetPlayer()->GetHeading());
  10327. if( database.SaveZoneSafeCoords(zone_id, zone->GetSafeX(), zone->GetSafeY(), zone->GetSafeZ(), zone->GetSafeHeading()) )
  10328. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Zone safe coordinates updated!");
  10329. else
  10330. client->SimpleMessage(CHANNEL_COLOR_RED, "FAILED to update zone safe coordinates!");
  10331. }
  10332. }
  10333. }
  10334. /*
  10335. Function:
  10336. Purpose :
  10337. Params :
  10338. Dev :
  10339. Example :
  10340. */
  10341. void Commands::Command_ZoneDetails(Client* client, Seperator* sep)
  10342. {
  10343. ZoneInfo* zone_info = new ZoneInfo;
  10344. if (sep && sep->arg[0])
  10345. {
  10346. if (sep->IsNumber(0))
  10347. zone_info->id = atoi(sep->arg[0]);
  10348. else
  10349. zone_info->id = database.GetZoneID(sep->arg[0]);
  10350. if (zone_info->id > 0)
  10351. {
  10352. database.LoadZoneInfo(zone_info);
  10353. 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);
  10354. 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);
  10355. 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);
  10356. 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);
  10357. 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);
  10358. 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);
  10359. 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);
  10360. client->Message(CHANNEL_COLOR_YELLOW, "zone_type: %s, sky_file: %s", zone_info->zone_type, zone_info->sky_file);
  10361. client->Message(CHANNEL_COLOR_YELLOW, "lua_script: %s", zone_info->lua_script);
  10362. client->Message(CHANNEL_COLOR_YELLOW, "zone_motd: %s", zone_info->zone_motd);
  10363. }
  10364. else
  10365. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  10366. }
  10367. else
  10368. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone details [zone id|zone name]");
  10369. safe_delete(zone_info);
  10370. }
  10371. /*
  10372. Function:
  10373. Purpose :
  10374. Params :
  10375. Dev :
  10376. Example :
  10377. */
  10378. void Commands::Command_ZoneSet(Client* client, Seperator* sep)
  10379. {
  10380. if (sep && sep->arg[0] && sep->arg[1] && sep->arg[2])
  10381. {
  10382. ZoneServer* zone = 0;
  10383. int32 zone_id = 0;
  10384. if (sep->IsNumber(0) && atoi(sep->arg[0]) > 0)
  10385. {
  10386. zone_id = atoi(sep->arg[0]);
  10387. zone = zone_list.Get(atoi(sep->arg[0]), false, false, false);
  10388. }
  10389. else
  10390. {
  10391. zone_id = database.GetZoneID(sep->arg[0]);
  10392. if (zone_id > 0)
  10393. zone = zone_list.Get(sep->arg[0], false, false, false);
  10394. }
  10395. if (zone_id > 0)
  10396. {
  10397. if (zone_set_values.count(string(sep->arg[1])) > 0)
  10398. SetZoneCommand(client, zone_id, zone, zone_set_values[sep->arg[1]], sep->arg[2]);
  10399. else
  10400. client->Message(CHANNEL_COLOR_YELLOW, "The attribute '%s' is not valid.", sep->arg[1]);
  10401. }
  10402. else
  10403. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  10404. }
  10405. else
  10406. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone set [zone id|zone name] [attribute] [value]");
  10407. }
  10408. void Commands::Command_Rain(Client* client, Seperator* sep) {
  10409. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  10410. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /rain <float>");
  10411. return;
  10412. }
  10413. client->Message(CHANNEL_COLOR_YELLOW,"Setting rain to %.2f", atof(sep->arg[0]));
  10414. client->GetCurrentZone()->SetRain(atof(sep->arg[0]));
  10415. client->GetCurrentZone()->SetCurrentWeather(atof(sep->arg[0]));
  10416. }
  10417. void Commands::Command_Wind(Client* client, Seperator* sep) {
  10418. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  10419. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /wind <float>");
  10420. return;
  10421. }
  10422. client->Message(CHANNEL_COLOR_YELLOW, "Setting wind to %.2f", atof(sep->arg[0]));
  10423. client->GetCurrentZone()->SetWind(atof(sep->arg[0]));
  10424. }
  10425. void Commands::Command_SendMerchantWindow(Client* client, Seperator* sep, bool sell) {
  10426. Spawn* spawn = client->GetPlayer()->GetTarget();
  10427. if(client->GetVersion() <= 546) {
  10428. sell = false; // doesn't support in the same way as AoM just open the normal buy/sell window
  10429. }
  10430. if(spawn) {
  10431. client->SetMerchantTransaction(spawn);
  10432. if (spawn->GetMerchantID() > 0 && spawn->IsClientInMerchantLevelRange(client)){
  10433. client->SendHailCommand(spawn);
  10434. //MerchantFactionMultiplier* multiplier = world.GetMerchantMultiplier(spawn->GetMerchantID());
  10435. //if(!multiplier || (multiplier && client->GetPlayer()->GetFactions()->GetFactionValue(multiplier->faction_id) >= multiplier->faction_min)){
  10436. client->SendBuyMerchantList(sell);
  10437. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY))
  10438. client->SendSellMerchantList(sell);
  10439. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY_BACK))
  10440. client->SendBuyBackList(sell);
  10441. if(client->GetVersion() > 546) {
  10442. PacketStruct* packet = configReader.getStruct("WS_UpdateMerchant", client->GetVersion());
  10443. if (packet) {
  10444. packet->setDataByName("spawn_id", 0xFFFFFFFF);
  10445. packet->setDataByName("type", 16);
  10446. EQ2Packet* outapp = packet->serialize();
  10447. if (outapp)
  10448. client->QueuePacket(outapp);
  10449. safe_delete(packet);
  10450. }
  10451. }
  10452. }
  10453. if (spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR)
  10454. client->SendRepairList();
  10455. }
  10456. // client->SimpleMessage(CHANNEL_COLOR_RED, "Your faction is too low to use this merchant.");
  10457. }
  10458. void Commands::Command_Weather(Client* client, Seperator* sep)
  10459. {
  10460. //PrintSep(sep, "Weather");
  10461. if( sep && sep->arg[0] )
  10462. {
  10463. ZoneServer* zsZone = client->GetCurrentZone();
  10464. const char* value = sep->arg[0];
  10465. // process single-param commands first
  10466. if( strncasecmp(value, "details", strlen(value)) == 0 )
  10467. {
  10468. client->Message(CHANNEL_COLOR_YELLOW, "Weather Details for zone %s: ", zsZone->GetZoneName());
  10469. client->Message(CHANNEL_COLOR_YELLOW, "enabled: %i, allowed: %i, type: %i, frequency: %u", zsZone->isWeatherEnabled(), zsZone->isWeatherAllowed(), zsZone->GetWeatherType(), zsZone->GetWeatherFrequency());
  10470. client->Message(CHANNEL_COLOR_YELLOW, "severity: %.2f = %.2f, current: %.2f", zsZone->GetWeatherMinSeverity(), zsZone->GetWeatherMaxSeverity(), zsZone->GetCurrentWeather());
  10471. client->Message(CHANNEL_COLOR_YELLOW, "pattern: %i, chance: %i, amount: %.2f, offset: %.2f", zsZone->GetWeatherPattern(), zsZone->GetWeatherChance(), zsZone->GetWeatherChangeAmount(), zsZone->GetWeatherDynamicOffset());
  10472. }
  10473. else if( strncasecmp(value, "process", strlen(value)) == 0 )
  10474. {
  10475. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  10476. zsZone->ProcessWeather();
  10477. }
  10478. else if( strncasecmp(value, "reset", strlen(value)) == 0 )
  10479. {
  10480. zsZone->SetWeatherType(rule_manager.GetGlobalRule(R_Zone, WeatherType)->GetInt8());
  10481. zsZone->SetWeatherFrequency(rule_manager.GetGlobalRule(R_Zone, WeatherChangeFrequency)->GetInt32());
  10482. zsZone->SetWeatherMinSeverity(rule_manager.GetGlobalRule(R_Zone, MinWeatherSeverity)->GetFloat());
  10483. zsZone->SetWeatherMaxSeverity(rule_manager.GetGlobalRule(R_Zone, MaxWeatherSeverity)->GetFloat());
  10484. zsZone->SetCurrentWeather(zsZone->GetWeatherMinSeverity());
  10485. zsZone->SetWeatherPattern(1);
  10486. zsZone->SetWeatherChance(rule_manager.GetGlobalRule(R_Zone, WeatherChangeChance)->GetInt8());
  10487. zsZone->SetWeatherChangeAmount(rule_manager.GetGlobalRule(R_Zone, WeatherChangePerInterval)->GetFloat());
  10488. zsZone->SetWeatherDynamicOffset(rule_manager.GetGlobalRule(R_Zone, WeatherDynamicMaxOffset)->GetFloat());
  10489. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  10490. zsZone->ProcessWeather();
  10491. }
  10492. // process commands with params
  10493. if( sep->arg[1] )
  10494. {
  10495. if( strncasecmp(value, "enable", strlen(value)) == 0 && sep->IsNumber(1) )
  10496. zsZone->SetWeatherEnabled( ( atoi(sep->arg[1]) == 1 ) ? true : false );
  10497. else if( strncasecmp(value, "type", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 3) )
  10498. zsZone->SetWeatherType(atoi(sep->arg[1]));
  10499. else if( strncasecmp(value, "frequency", strlen(value)) == 0 && sep->IsNumber(1))
  10500. zsZone->SetWeatherFrequency( atoul(sep->arg[1]) );
  10501. else if( strncasecmp(value, "range", strlen(value)) == 0 && sep->IsNumber(1) && sep->IsNumber(2) ) {
  10502. zsZone->SetWeatherMinSeverity(atof(sep->arg[1]));
  10503. zsZone->SetWeatherMaxSeverity(atof(sep->arg[2]));
  10504. zsZone->SetRain(zsZone->GetWeatherMinSeverity());
  10505. }
  10506. else if( strncasecmp(value, "current", strlen(value)) == 0 && sep->IsNumber(1) ) {
  10507. zsZone->SetCurrentWeather(atof(sep->arg[1]));
  10508. zsZone->SetRain(zsZone->GetCurrentWeather());
  10509. }
  10510. else if( strncasecmp(value, "pattern", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 2) )
  10511. zsZone->SetWeatherPattern( atoi(sep->arg[1]) );
  10512. else if( strncasecmp(value, "chance", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 100) )
  10513. zsZone->SetWeatherChance( atoi(sep->arg[1]) );
  10514. else if( strncasecmp(value, "amount", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  10515. zsZone->SetWeatherChangeAmount( atof(sep->arg[1]) );
  10516. else if( strncasecmp(value, "offset", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  10517. zsZone->SetWeatherDynamicOffset( atof(sep->arg[1]) );
  10518. }
  10519. }
  10520. else
  10521. {
  10522. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /weather [command] [param]");
  10523. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: enable (0|1), type (0-3), frequency (sec), range|current (0.0 - 1.0)");
  10524. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: details, process, pattern (0|1), chance (%), amount (float), offset (float)");
  10525. return;
  10526. }
  10527. }
  10528. void Commands::Command_Select(Client* client, Seperator* sep) {
  10529. if (sep && sep->arg[1]) {
  10530. Spawn* spawn = client->GetPlayer()->GetTarget();
  10531. if (spawn && strlen(sep->arg[1]) > 0)
  10532. client->GetCurrentZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_CUSTOM, client->GetPlayer(), sep->arg[1]);
  10533. }
  10534. }
  10535. /*
  10536. Function: Command_ConsumeFood()
  10537. Purpose : Consume Food/Drink and apply mods
  10538. Params : Slot ID - EQ2_FOOD_SLOT 22, EQ2_DRINK_SLOT 23
  10539. Dev : Zcoretri
  10540. Example : /consume_food 22
  10541. */
  10542. void Commands::Command_ConsumeFood(Client* client, Seperator* sep) {
  10543. if (sep && sep->arg[0] && sep->IsNumber(0))
  10544. {
  10545. Player* player = client->GetPlayer();
  10546. int8 slot = atoi(sep->arg[0]);
  10547. if (client->GetVersion() <= 283) {
  10548. slot += 4;
  10549. }
  10550. else if (client->GetVersion() <= 546) {
  10551. slot += 2;
  10552. }
  10553. Item* item = player->GetEquipmentList()->GetItem(slot);
  10554. if(client->CheckConsumptionAllowed(slot)) {
  10555. client->ConsumeFoodDrink(item, slot);
  10556. }
  10557. }
  10558. }
  10559. void Commands::Command_Aquaman(Client* client, Seperator* sep) {
  10560. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  10561. if (atoi(sep->arg[0]) == 1) {
  10562. client->GetPlayer()->GetInfoStruct()->set_vision(4);
  10563. client->GetPlayer()->GetInfoStruct()->set_breathe_underwater(1);
  10564. client->GetPlayer()->SetCharSheetChanged(true);
  10565. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Maybe you ought to stick to the shallow end until you know how to swim.");
  10566. }
  10567. else {
  10568. client->GetPlayer()->GetInfoStruct()->set_vision(0);
  10569. client->GetPlayer()->GetInfoStruct()->set_breathe_underwater(0);
  10570. client->GetPlayer()->SetCharSheetChanged(true);
  10571. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Aquaman mode turned off.");
  10572. }
  10573. }
  10574. else
  10575. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /aquaman [0|1]");
  10576. }
  10577. void Commands::Command_ReportBug(Client* client, Seperator* sep)
  10578. {
  10579. if(sep)
  10580. {
  10581. string data;
  10582. if(sep->arg[0]){
  10583. data = string(sep->arg[0]);
  10584. }
  10585. for(int i=1;i<sep->GetMaxArgNum();i++){
  10586. if(sep->arg[i])
  10587. data.append(" ").append(sep->arg[i]);
  10588. }
  10589. const char* target_name = 0;
  10590. int32 spawn_id = 0;
  10591. if(client->GetPlayer()->GetTarget())
  10592. {
  10593. target_name = client->GetPlayer()->GetTarget()->GetName();
  10594. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  10595. }
  10596. else
  10597. target_name = "N/A";
  10598. LogWrite(COMMAND__DEBUG, 1, "Command", "%s", data.c_str());
  10599. if(world.ReportBug(data, client->GetPlayer()->GetName(), client->GetAccountID(), target_name, spawn_id, client->GetCurrentZone()->GetZoneID()))
  10600. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully submitted bug.");
  10601. else
  10602. client->SimpleMessage(CHANNEL_COLOR_RED, "Error submitting bug.");
  10603. }
  10604. }
  10605. void Commands::Command_Attune_Inv(Client* client, Seperator* sep) {
  10606. PrintSep(sep, "Command_Attune_Inv");
  10607. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  10608. // Get the item index from the first parameter
  10609. int16 index = atoi(sep->arg[0]);
  10610. // Check to see if this is a valid item index for the player, if not exit out of the function
  10611. if (client->GetPlayer()->item_list.indexed_items.count(index) == 0) {
  10612. LogWrite(ITEM__DEBUG, 0, "Items", "%s has no item with an index of %i", client->GetPlayer()->GetName(), index);
  10613. return;
  10614. }
  10615. // Get the item
  10616. Item* item = client->GetPlayer()->item_list.indexed_items[index];
  10617. if(item) {
  10618. // Valid item lets check to make sure this item is attunable, if not return out
  10619. if (!item->CheckFlag(ATTUNEABLE)) {
  10620. LogWrite(ITEM__DEBUG, 0, "Items", "attune_inv called for an item that is not attunable (%s)", item->name.c_str());
  10621. return;
  10622. }
  10623. // Remove the attunable flag
  10624. item->generic_info.item_flags -= ATTUNEABLE;
  10625. // Set the attuned flag
  10626. item->generic_info.item_flags += ATTUNED;
  10627. // Flag this item for saving
  10628. item->save_needed = true;
  10629. client->QueuePacket(item->serialize(client->GetVersion(), false, client->GetPlayer()));
  10630. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), 0, -1); // appearance type??
  10631. EQ2Packet* outapp = 0;
  10632. for (int32 i=0;i<packets.size();i++) {
  10633. outapp = packets[i];
  10634. if(outapp)
  10635. client->QueuePacket(outapp);
  10636. }
  10637. }
  10638. }
  10639. }
  10640. void Commands::Command_Reset_Zone_Timer(Client* client, Seperator* sep) {
  10641. PrintSep(sep, "Command_Reset_Zone_Timer");
  10642. /*if (sep && sep->arg[0] && sep->IsNumber(0)) {
  10643. int32 db_id = atoul(sep->arg[0]);
  10644. InstanceData* data = client->GetPlayer()->GetCharacterInstances().FindInstanceByDBID(db_id);
  10645. if (data) {
  10646. // TODO: add a check to timers to ensure it can be reset
  10647. // Delete the character from the instance
  10648. database.DeleteCharacterFromInstance(client->GetPlayer()->GetCharacterID(), data->instance_id);
  10649. data->instance_id = 0;
  10650. // Update the success time and set to 0 so the player can enter it again
  10651. database.UpdateCharacterInstance(client->GetPlayer()->GetCharacterID(), data->zone_name, 0, 1, 0);
  10652. data->last_success_timestamp = 0;
  10653. }
  10654. }*/
  10655. }
  10656. void Commands::Command_Player(Client* client, Seperator* sep) {
  10657. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player syntax --");
  10658. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins");
  10659. }
  10660. void Commands::Command_Player_Coins(Client* client, Seperator* sep) {
  10661. // /player coins add 10
  10662. // /player coins add plat 10
  10663. Player* player = client->GetPlayer();
  10664. Client* targetClient = client;
  10665. if (player->HasTarget() && player->GetTarget()->IsPlayer()) {
  10666. player = (Player*)player->GetTarget();
  10667. targetClient = player->GetClient();
  10668. }
  10669. if (sep && sep->arg[0] && sep->arg[1]) {
  10670. const char* action = sep->arg[0];
  10671. int64 value = 0;
  10672. if (strncasecmp(action, "add", strlen(action)) == 0) {
  10673. if (sep->IsNumber(1)) {
  10674. value = atoi64(sep->arg[1]);
  10675. player->AddCoins(value);
  10676. if (client->GetPlayer() == player)
  10677. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  10678. else {
  10679. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  10680. if(targetClient) {
  10681. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  10682. }
  10683. }
  10684. return;
  10685. }
  10686. else if (sep->arg[2] && sep->IsNumber(2)) {
  10687. const char* type = sep->arg[1];
  10688. if (strncasecmp(type, "copper", strlen(type)) == 0) {
  10689. value = atoi64(sep->arg[2]);
  10690. }
  10691. else if (strncasecmp(type, "silver", strlen(type)) == 0) {
  10692. value = atoi64(sep->arg[2]) * 100;
  10693. }
  10694. else if (strncasecmp(type, "gold", strlen(type)) == 0) {
  10695. value = atoi64(sep->arg[2]) * 10000;
  10696. }
  10697. else if (strncasecmp(type, "plat", strlen(type)) == 0) {
  10698. value = atoi64(sep->arg[2]) * 1000000;
  10699. }
  10700. player->AddCoins(value);
  10701. if (client->GetPlayer() == player)
  10702. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  10703. else {
  10704. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  10705. if(targetClient) {
  10706. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  10707. }
  10708. }
  10709. return;
  10710. }
  10711. }
  10712. }
  10713. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player coins syntax --");
  10714. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add [value] - adds the given number of coins to the player");
  10715. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add copper [value] - adds the given amount of copper to the player");
  10716. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add silver [value] - adds the given amount of silver to the player");
  10717. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add gold [value] - adds the given amount of gold to the player");
  10718. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add plat [value] - adds the given amount of platinum to the player");
  10719. }
  10720. void Commands::Command_AchievementAdd(Client* client, Seperator* sep) {
  10721. PrintSep(sep, "ACHIEVEMENT_ADD");
  10722. if (sep && sep->IsSet(0)) {
  10723. int32 spell_id = atoul(sep->arg[1]);
  10724. int8 spell_tier = 0;
  10725. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  10726. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  10727. // addspellbookentry here
  10728. if (spell_tier >= data->maxRank) {
  10729. return;
  10730. }
  10731. if (!spell_tier) {
  10732. spell_tier = 1;
  10733. }
  10734. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  10735. {
  10736. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  10737. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  10738. client->GetPlayer()->UnlockSpell(spell);
  10739. client->SendSpellUpdate(spell);
  10740. }
  10741. else
  10742. {
  10743. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1);
  10744. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  10745. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  10746. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  10747. client->GetPlayer()->UnlockSpell(spell);
  10748. client->SendSpellUpdate(spell);
  10749. }
  10750. // cast spell here
  10751. if (!spell_tier)
  10752. spell_tier = 1;
  10753. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  10754. if (spell) {
  10755. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  10756. }
  10757. }
  10758. else {
  10759. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  10760. }
  10761. master_aa_list.DisplayAA(client, 0, 0);
  10762. }
  10763. void Commands::Command_Editor(Client* client, Seperator* sep) {
  10764. PacketStruct* packet = configReader.getStruct("WS_ChoiceWindow", client->GetVersion());
  10765. if (packet) {
  10766. string url = string(rule_manager.GetGlobalRule(R_World, EditorURL)->GetString());
  10767. if (rule_manager.GetGlobalRule(R_World, EditorOfficialServer)->GetBool()) {
  10768. char command[255];
  10769. url = "browser " + url;
  10770. int32 spawn_id = 0;
  10771. int32 zone_id = 0;
  10772. string type;
  10773. if (client->GetCurrentZone())
  10774. zone_id = client->GetCurrentZone()->GetZoneID();
  10775. if (client->GetPlayer()->GetTarget()) {
  10776. Spawn* target = client->GetPlayer()->GetTarget();
  10777. if (target->IsWidget())
  10778. type = "widgets";
  10779. else if (target->IsSign())
  10780. type = "signs";
  10781. else if (target->IsObject())
  10782. type = "objects";
  10783. else if (target->IsNPC())
  10784. type = "npcs";
  10785. else if (target->IsGroundSpawn())
  10786. type = "ground";
  10787. else
  10788. type = "spawn";
  10789. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  10790. }
  10791. sprintf(command, url.c_str(), zone_id, type.c_str(), spawn_id);
  10792. packet->setDataByName("accept_command", command);
  10793. }
  10794. else if (rule_manager.GetGlobalRule(R_World, EditorIncludeID)->GetBool()) {
  10795. char command[255];
  10796. url = "browser " + url;
  10797. if (client->GetPlayer()->GetTarget())
  10798. sprintf(command, url.c_str(), client->GetPlayer()->GetTarget()->GetDatabaseID());
  10799. packet->setDataByName("accept_command", command);
  10800. }
  10801. else {
  10802. string command = "browser " + url;
  10803. packet->setDataByName("accept_command", command.c_str());
  10804. }
  10805. packet->setDataByName("text", "Open the web editor?");
  10806. packet->setDataByName("accept_text", "Open");
  10807. packet->setDataByName("cancel_text", "Cancel");
  10808. // No clue if we even need the following 2 unknowns, just added them so the packet matches what live sends
  10809. packet->setDataByName("unknown2", 50);
  10810. packet->setDataByName("unknown4", 1);
  10811. client->QueuePacket(packet->serialize());
  10812. safe_delete(packet);
  10813. }
  10814. }
  10815. void Commands::Command_AcceptResurrection(Client* client, Seperator* sep) {
  10816. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  10817. return;
  10818. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  10819. if(client->GetCurrentRez()->active)
  10820. client->AcceptResurrection();
  10821. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  10822. }
  10823. void Commands::Command_DeclineResurrection(Client* client, Seperator* sep) {
  10824. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  10825. return;
  10826. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  10827. if(client->GetCurrentRez()->active)
  10828. client->GetCurrentRez()->should_delete = true;
  10829. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  10830. }
  10831. void Commands::Switch_AA_Profile(Client* client, Seperator* sep) {
  10832. PrintSep(sep, "Switch_AA_Profile");
  10833. if (sep && sep->IsSet(0)) {
  10834. string type = sep->arg[0];
  10835. int8 newtemplate = atoul(sep->arg[1]);
  10836. master_aa_list.DisplayAA(client, newtemplate, 1);
  10837. }
  10838. }
  10839. void Commands::Get_AA_Xml(Client* client, Seperator* sep) {
  10840. PrintSep(sep, "Get_AA_Xml");
  10841. if (sep && sep->IsSet(0)) {
  10842. string tabnum = sep->arg[0];
  10843. string spellid = sep->arg[1];
  10844. }
  10845. }
  10846. void Commands::Add_AA(Client* client, Seperator* sep) {
  10847. PrintSep(sep, "Add_AA");
  10848. if (sep && sep->IsSet(0)) {
  10849. int32 spell_id = atoul(sep->arg[1]);
  10850. int8 spell_tier = 0;
  10851. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  10852. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  10853. // addspellbookentry here
  10854. if(!data) {
  10855. LogWrite(COMMAND__ERROR, 0, "Command", "Error in Add_AA no data for spell_id %u spell_tier %u", spell_id, spell_tier);
  10856. return;
  10857. }
  10858. if (spell_tier >= data->maxRank) {
  10859. LogWrite(COMMAND__ERROR, 0, "Command", "Error in Add_AA spell_tier %u >= maxRank %u", spell_tier, data->maxRank);
  10860. return;
  10861. }
  10862. if (!spell_tier) {
  10863. spell_tier = 1;
  10864. }
  10865. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  10866. {
  10867. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  10868. if(spell)
  10869. {
  10870. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  10871. client->GetPlayer()->UnlockSpell(spell);
  10872. client->SendSpellUpdate(spell);
  10873. }
  10874. }
  10875. else
  10876. {
  10877. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1 );
  10878. if(spell)
  10879. {
  10880. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  10881. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  10882. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  10883. client->GetPlayer()->UnlockSpell(spell);
  10884. client->SendSpellUpdate(spell);
  10885. }
  10886. }
  10887. // cast spell here
  10888. if (!spell_tier)
  10889. spell_tier = 1;
  10890. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  10891. if (spell) {
  10892. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  10893. }
  10894. }
  10895. else {
  10896. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  10897. }
  10898. master_aa_list.DisplayAA(client, 0, 0);
  10899. }
  10900. void Commands::Commit_AA_Profile(Client* client, Seperator* sep) {
  10901. PrintSep(sep, "Commit_AA_Profile");
  10902. if (sep && sep->IsSet(0)) {
  10903. }
  10904. }
  10905. void Commands::Begin_AA_Profile(Client* client, Seperator* sep) {
  10906. PrintSep(sep, "Begin_AA_Profile");
  10907. if (sep && sep->IsSet(0)) {
  10908. master_aa_list.DisplayAA(client, 100, 2);
  10909. }
  10910. }
  10911. void Commands::Back_AA(Client* client, Seperator* sep) {
  10912. if (sep && sep->IsSet(0)) {
  10913. PrintSep(sep, "Back_AA");
  10914. }
  10915. }
  10916. void Commands::Remove_AA(Client* client, Seperator* sep) {
  10917. if (sep && sep->IsSet(0)) {
  10918. PrintSep(sep, "Remove_AA");
  10919. }
  10920. }
  10921. void Commands::Cancel_AA_Profile(Client* client, Seperator* sep) {
  10922. MasterAAList master_aa_list;
  10923. PrintSep(sep, "Cancel_AA_Profile");
  10924. master_aa_list.DisplayAA(client, 0, 0);
  10925. }
  10926. void Commands::Save_AA_Profile(Client* client, Seperator* sep) {
  10927. if (sep && sep->IsSet(0)) {
  10928. PrintSep(sep, "Save_AA_Profile");
  10929. }
  10930. }
  10931. void Commands::Command_TargetItem(Client* client, Seperator* sep) {
  10932. if (!sep || sep->GetArgNumber() < 1 || !client->GetPlayer()) return;
  10933. if (!sep->IsNumber(0)) return;
  10934. int32 request_id = atoul(sep->arg[0]);
  10935. if (!sep->IsNumber(1)) return;
  10936. sint32 item_id = atoi(sep->arg[1]);
  10937. if (client->IsCurrentTransmuteID(request_id)) {
  10938. Transmute::HandleItemResponse(client, client->GetPlayer(), request_id, reinterpret_cast<int32&>(item_id));
  10939. }
  10940. else if (client->IsCurrentTransmuteID(item_id)) {
  10941. if (!sep->IsSet(2)) return;
  10942. if (sep->IsNumber(2) && atoi(sep->arg[2]) == 1) {
  10943. Transmute::HandleConfirmResponse(client, client->GetPlayer(), reinterpret_cast<int32&>(item_id));
  10944. }
  10945. }
  10946. }
  10947. void Commands::Command_FindSpawn(Client* client, Seperator* sep) {
  10948. if(sep)
  10949. client->GetCurrentZone()->FindSpawn(client, (char*)sep->argplus[0]);
  10950. }
  10951. void Commands::Command_MoveCharacter(Client* client, Seperator* sep) {
  10952. if(sep && sep->arg[0][0] && sep->arg[1][0])
  10953. {
  10954. char* name = sep->arg[0];
  10955. char* zoneName = sep->arg[1];
  10956. char query[256];
  10957. snprintf(query, 256, "UPDATE characters c, zones z set c.x = z.safe_x, c.y = z.safe_y, c.z = z.safe_z, c.heading = z.safe_heading, c.current_zone_id = z.id where c.name = '%s' and z.name='%s'", name, zoneName);
  10958. if (database.RunQuery(query, strnlen(query, 256)))
  10959. {
  10960. client->Message(CHANNEL_COLOR_YELLOW, "Ran query:%s", query);
  10961. }
  10962. else
  10963. client->Message(CHANNEL_COLOR_RED, "Query FAILED to run: %s", query);
  10964. }
  10965. }
  10966. void Commands::Command_Mood(Client* client, Seperator* sep) {
  10967. Player* player = client->GetPlayer();
  10968. if( sep && sep->arg[0] )
  10969. {
  10970. const char* value = sep->arg[0];
  10971. InfoStruct* info = player->GetInfoStruct();
  10972. int32 cid = client->GetCharacterID();
  10973. char* characterName = database.GetCharacterName(cid);
  10974. char tmp[1024]; // our emote string "xyz appears zyx"
  10975. //char properties vals
  10976. char* pname = "mood";
  10977. char* pval; // mood value
  10978. bool pt; //used to verify return from DB.
  10979. //This should never be seen.
  10980. sprintf(tmp, " ");
  10981. if( strncasecmp(value, "angry", strlen(value)) == 0 )
  10982. {
  10983. sprintf(tmp, "%s appears angry", characterName);
  10984. pval = "11852";
  10985. player->SetMoodState(11852, 1);
  10986. info->set_mood(11852);
  10987. pt = database.insertCharacterProperty(client, pname, pval);
  10988. }
  10989. else if( strncasecmp(value, "afraid", strlen(value)) == 0 )
  10990. {
  10991. sprintf(tmp, "%s appears afraid", characterName);
  10992. pval = "11851";
  10993. player->SetMoodState(11851, 1);
  10994. info->set_mood(11851);
  10995. pt = database.insertCharacterProperty(client, pname, pval);
  10996. }
  10997. else if( strncasecmp(value, "happy", strlen(value)) == 0 )
  10998. {
  10999. sprintf(tmp, "%s appears happy", characterName);
  11000. pval = "11854";
  11001. player->SetMoodState(11854, 1);
  11002. info->set_mood(11854);
  11003. pt = database.insertCharacterProperty(client, pname, pval);
  11004. }
  11005. else if( strncasecmp(value, "sad", strlen(value)) == 0 ) {
  11006. sprintf(tmp, "%s appears sad", characterName);
  11007. pval = "11856";
  11008. player->SetMoodState(11856, 1);
  11009. info->set_mood(11856);
  11010. pt = database.insertCharacterProperty(client, pname, pval);
  11011. }
  11012. else if( strncasecmp(value, "tired", strlen(value)) == 0 )
  11013. {
  11014. sprintf(tmp, "%s appears tired", characterName);
  11015. pval = "11857";
  11016. player->SetMoodState(11857, 1);
  11017. info->set_mood(11857);
  11018. pt = database.insertCharacterProperty(client, pname, pval);
  11019. }
  11020. else if( strncasecmp(value, "none", strlen(value)) == 0 )
  11021. {
  11022. //using 11855 mood_idle for none, I assume thats what its for?
  11023. pval = "11855";
  11024. player->SetMoodState(11855, 1);
  11025. info->set_mood(11855);
  11026. pt = database.insertCharacterProperty(client, pname, pval);
  11027. //return since we have nothing left to do. No emote for none.
  11028. return;
  11029. }else{
  11030. client->SimpleMessage(CHANNEL_NARRATIVE, "Listing Available Moods:");
  11031. client->SimpleMessage(CHANNEL_NARRATIVE, "none");
  11032. client->SimpleMessage(CHANNEL_NARRATIVE, "afraid");
  11033. client->SimpleMessage(CHANNEL_NARRATIVE, "angry");
  11034. client->SimpleMessage(CHANNEL_NARRATIVE, "happy");
  11035. client->SimpleMessage(CHANNEL_NARRATIVE, "sad");
  11036. client->SimpleMessage(CHANNEL_NARRATIVE, "tired");
  11037. return;
  11038. }
  11039. client->GetPlayer()->GetZone()->HandleChatMessage(0, 0, CHANNEL_EMOTE, tmp);
  11040. return;
  11041. }
  11042. client->SimpleMessage(CHANNEL_NARRATIVE, "Listing Available Moods:");
  11043. client->SimpleMessage(CHANNEL_NARRATIVE, "none");
  11044. client->SimpleMessage(CHANNEL_NARRATIVE, "afraid");
  11045. client->SimpleMessage(CHANNEL_NARRATIVE, "angry");
  11046. client->SimpleMessage(CHANNEL_NARRATIVE, "happy");
  11047. client->SimpleMessage(CHANNEL_NARRATIVE, "sad");
  11048. client->SimpleMessage(CHANNEL_NARRATIVE, "tired");
  11049. return;
  11050. }
  11051. /*
  11052. Function: Command_CancelEffect()
  11053. Purpose : Cancels (good) effect spells
  11054. Example : /cancel_effect spell_id - would cancel the spell with the <spell_id> value in spell effects list
  11055. */
  11056. void Commands::Command_CancelEffect(Client* client, Seperator* sep)
  11057. {
  11058. if (sep && sep->arg[0] && sep->IsNumber(0))
  11059. {
  11060. int32 spell_id = atoul(sep->arg[0]);
  11061. SpellEffects* effect = client->GetPlayer()->GetSpellEffect(spell_id);
  11062. if(!effect || effect->spell->spell->GetSpellData()->det_type) {
  11063. return;
  11064. }
  11065. MaintainedEffects* meffect = effect->caster->GetMaintainedSpell(spell_id);
  11066. if (!meffect || !meffect->spell || !meffect->spell->caster || !meffect->spell->caster->GetZone() ||
  11067. !meffect->spell->caster->GetZone()->GetSpellProcess()->DeleteCasterSpell(meffect->spell, "canceled", false, client->GetPlayer()))
  11068. client->Message(CHANNEL_COLOR_RED, "The spell effect could not be cancelled.");
  11069. }
  11070. }
  11071. /*
  11072. Function: Command_CurePlayer()
  11073. Purpose : Identifies spell to cast for cure based on type
  11074. Example : /cureplayer ??
  11075. https://eq2.fandom.com/wiki/Update:58
  11076. New command /cureplayer [playername|group or raid position][trauma|arcane|noxious|elemental|curse] optional [spell|potion]
  11077. Example: /cureplayer g0 noxious spell
  11078. Will attempt to cure yourself of a noxious detriment with only spells and without using potions (even if you have them).
  11079. Example: /cureplayer r4 noxious
  11080. Will attempt to cure the character in raid slot 4 of a noxious detriment using a spell or potion (whichever is available).
  11081. */
  11082. void Commands::Command_CurePlayer(Client* client, Seperator* sep)
  11083. {
  11084. Entity* target = nullptr;
  11085. bool use_spells = true;
  11086. bool use_potions = true;
  11087. if (sep && sep->arg[0] && sep->arg[1]) {
  11088. if(sep->arg[2]) {
  11089. std::string type(sep->arg[2]);
  11090. boost::algorithm::to_lower(type);
  11091. if(type == "potion")
  11092. use_spells = false;
  11093. else if(type == "spell")
  11094. use_potions = false;
  11095. }
  11096. if(strlen(sep->arg[0]) > 1 && isdigit(sep->arg[0][1])) {
  11097. int32 mapped_position = (int32)(sep->arg[0][1]) - 48;
  11098. // TODO: RAID Support ('r' argument)
  11099. if(sep->arg[0][0] == 'g' && !mapped_position) {
  11100. target = (Entity*)client->GetPlayer();
  11101. }
  11102. else {
  11103. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  11104. if (gmi && gmi->group_id) {
  11105. PlayerGroup* group = world.GetGroupManager()->GetGroup(gmi->group_id);
  11106. if(group) {
  11107. target = group->GetGroupMemberByPosition(client->GetPlayer(), mapped_position);
  11108. }
  11109. }
  11110. }
  11111. }
  11112. else {
  11113. Client* target_client = zone_list.GetClientByCharName(sep->arg[0]);
  11114. if(target_client && target_client->GetPlayer() && target_client->GetPlayer()->GetZone() == client->GetPlayer()->GetZone()) {
  11115. target = (Entity*)target_client->GetPlayer();
  11116. }
  11117. }
  11118. ItemEffectType type = EFFECT_CURE_TYPE_ALL;
  11119. bool successful_spell = false;
  11120. bool successful_potion = false;
  11121. if(target) {
  11122. SpellBookEntry* entry = nullptr;
  11123. std::string str(sep->arg[1]);
  11124. boost::algorithm::to_lower(str);
  11125. if(str == "arcane") {
  11126. type = EFFECT_CURE_TYPE_ARCANE;
  11127. // cure arcane spell missing in DB?
  11128. if(use_spells && rule_manager.GetGlobalRule(R_Spells, CureArcaneSpellID)->GetInt32()) {
  11129. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureArcaneSpellID)->GetInt32()); // cure noxious
  11130. }
  11131. }
  11132. else if(str == "trauma") {
  11133. type = EFFECT_CURE_TYPE_TRAUMA;
  11134. // cure trauma spell missing in DB?
  11135. if(use_spells && rule_manager.GetGlobalRule(R_Spells, CureTraumaSpellID)->GetInt32()) {
  11136. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureTraumaSpellID)->GetInt32()); // cure noxious
  11137. }
  11138. }
  11139. else if(str == "noxious") {
  11140. type = EFFECT_CURE_TYPE_NOXIOUS;
  11141. if(use_spells && rule_manager.GetGlobalRule(R_Spells, CureNoxiousSpellID)->GetInt32()) {
  11142. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureNoxiousSpellID)->GetInt32()); // cure noxious
  11143. }
  11144. }
  11145. else if(str == "curse") {
  11146. type = EFFECT_CURE_TYPE_CURSE;
  11147. if(use_spells && rule_manager.GetGlobalRule(R_Spells, CureCurseSpellID)->GetInt32()) {
  11148. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureCurseSpellID)->GetInt32()); // cure curse
  11149. }
  11150. }
  11151. else if(str == "magic") {
  11152. type = EFFECT_CURE_TYPE_MAGIC;
  11153. if(use_spells && rule_manager.GetGlobalRule(R_Spells, CureMagicSpellID)->GetInt32()) {
  11154. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureMagicSpellID)->GetInt32()); // cure magic
  11155. }
  11156. }
  11157. if(use_spells) {
  11158. // check if any of the specific cure types are available, if not then check the base cures
  11159. if(!entry && rule_manager.GetGlobalRule(R_Spells, CureSpellID)->GetInt32()) {
  11160. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureSpellID)->GetInt32()); // cure
  11161. }
  11162. if(entry && entry->spell_id) {
  11163. Spell* spell = master_spell_list.GetSpell(entry->spell_id, entry->tier);
  11164. target->GetZone()->ProcessSpell(spell, (Entity*)client->GetPlayer(), target, true, false);
  11165. successful_spell = true;
  11166. }
  11167. }
  11168. }
  11169. if(!successful_spell && use_potions && target && type != NO_EFFECT_TYPE) {
  11170. vector<Item*>* potential_items = client->GetItemsByEffectType(type, EFFECT_CURE_TYPE_ALL);
  11171. if (potential_items && potential_items->size() > 0) {
  11172. vector<Item*>::iterator itr;
  11173. for (itr = potential_items->begin(); itr != potential_items->end(); itr++)
  11174. {
  11175. Item* item = *itr;
  11176. if(client->UseItem(item, target)) {
  11177. successful_potion = true;
  11178. break;
  11179. }
  11180. }
  11181. }
  11182. safe_delete(potential_items);
  11183. }
  11184. }
  11185. }
  11186. /*
  11187. Function: Command_ShareQuest()
  11188. Purpose : Share quest with the group
  11189. Example : /share_quest [quest_id]
  11190. */
  11191. void Commands::Command_ShareQuest(Client* client, Seperator* sep)
  11192. {
  11193. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  11194. int32 quest_id = atoul(sep->arg[0]);
  11195. bool hasQuest = client->GetPlayer()->HasAnyQuest(quest_id);
  11196. if(hasQuest) {
  11197. Quest* quest = master_quest_list.GetQuest(quest_id, false);
  11198. if(quest) {
  11199. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  11200. if (gmi && gmi->group_id) {
  11201. PlayerGroup* group = world.GetGroupManager()->GetGroup(gmi->group_id);
  11202. if (group) {
  11203. group->ShareQuestWithGroup(client, quest);
  11204. }
  11205. }
  11206. }
  11207. }
  11208. else {
  11209. client->SimpleMessage(CHANNEL_COLOR_RED, "Cannot find quest.");
  11210. }
  11211. }
  11212. }
  11213. /*
  11214. Function: Command_Yell()
  11215. Purpose : Yell to break an encounter
  11216. Example : /yell
  11217. * Uses self target, encounter target or no target
  11218. */
  11219. void Commands::Command_Yell(Client* client, Seperator* sep) {
  11220. Entity* player = (Entity*)client->GetPlayer();
  11221. Spawn* res = nullptr;
  11222. Spawn* prev = nullptr;
  11223. bool cycleAll = false;
  11224. if(player->GetTarget() == player) {
  11225. cycleAll = true; // self target breaks all encounters
  11226. }
  11227. else if(player->GetTarget()) {
  11228. res = player->GetTarget(); // selected target other than self only dis-engages that encounter
  11229. }
  11230. if(res && !client->GetPlayer()->IsEngagedBySpawnID(res->GetID()))
  11231. return;
  11232. bool alreadyYelled = false;
  11233. do {
  11234. if(!res && player->IsEngagedInEncounter(&res)) { // no target is set, dis-engage top of hated by list
  11235. }
  11236. if(!res || prev == res) {
  11237. return;
  11238. }
  11239. if(res->IsNPC() && ((NPC*)res)->Brain()) {
  11240. if(!alreadyYelled) {
  11241. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You yell for help!");
  11242. string yellMsg = std::string(client->GetPlayer()->GetName()) + " yelled for help!";
  11243. client->GetPlayer()->GetZone()->SimpleMessage(CHANNEL_COLOR_RED, yellMsg.c_str(), client->GetPlayer(), 35.0f, false);
  11244. client->GetPlayer()->GetZone()->SendYellPacket(client->GetPlayer());
  11245. }
  11246. alreadyYelled = true;
  11247. NPC* npc = (NPC*)res;
  11248. npc->Brain()->ClearEncounter();
  11249. npc->SetLockedNoLoot(ENCOUNTER_STATE_BROKEN);
  11250. npc->UpdateEncounterState(ENCOUNTER_STATE_BROKEN);
  11251. }
  11252. prev = res;
  11253. res = nullptr;
  11254. }while(cycleAll);
  11255. if(!player->IsEngagedInEncounter()) {
  11256. if(player->GetInfoStruct()->get_engaged_encounter()) {
  11257. player->GetInfoStruct()->set_engaged_encounter(0);
  11258. player->SetRegenValues((player->GetInfoStruct()->get_effective_level() > 0) ? player->GetInfoStruct()->get_effective_level() : player->GetLevel());
  11259. client->GetPlayer()->SetCharSheetChanged(true);
  11260. player->info_changed = true;
  11261. }
  11262. }
  11263. }