Commands.cpp 438 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046
  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. if(client->GetVersion() <= 546) {
  2050. item_index = (uint32)-(sint32)item_index & 0xFFFFFFFF;
  2051. item_index -= 1;
  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", "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", "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", "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", "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", "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", "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", "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", "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", "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", "Unknown Item ID: %u", recipe->GetProductID());
  2163. }
  2164. else {
  2165. LogWrite(COMMAND__ERROR, 0, "Command", "recipe_product recipe->GetProductID() has value 0 for recipe id %u.", recipe_id);
  2166. }
  2167. }
  2168. else {
  2169. LogWrite(COMMAND__ERROR, 0, "Command", "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", "Unknown 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", "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", "Unknown 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", "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", "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 = client->GetCurrentZone()->GetClientBySpawn(target);
  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)
  6006. {
  6007. Client* client_inviter = pgi->invited_by->GetZone()->GetClientBySpawn(pgi->invited_by);
  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. client->SetPendingGuildInvite(0);
  6012. }
  6013. else if (strncmp(command, "create", length) == 0 && sep->arg[1])
  6014. {
  6015. const char* guild_name = sep->argplus[1];
  6016. if (!guild_list.GetGuild(guild_name))
  6017. world.CreateGuild(guild_name, client, client->GetPlayer()->GetGroupMemberInfo() ? client->GetPlayer()->GetGroupMemberInfo()->group_id : 0);
  6018. else
  6019. client->SimpleMessage(CHANNEL_NARRATIVE, "A guild with that name already exists.");
  6020. }
  6021. else if (strncmp(command, "search", length) == 0)
  6022. client->ShowGuildSearchWindow();
  6023. else if (strncmp(command, "recruiting_details", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  6024. {
  6025. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  6026. if (to_guild)
  6027. to_guild->SendGuildRecruitingDetails(client);
  6028. }
  6029. else if (strncmp(command, "recruiting_image", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  6030. {
  6031. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  6032. if (to_guild)
  6033. to_guild->SendGuildRecruitingImages(client);
  6034. }
  6035. else if (strncmp(command, "recruiter_adventure_class", length) == 0)
  6036. {
  6037. if (sep->arg[1])
  6038. {
  6039. const char* option = sep->arg[1];
  6040. if (strncmp(option, "toggle", strlen(option)) == 0)
  6041. guild->ToggleGuildRecruiterAdventureClass(client);
  6042. }
  6043. else
  6044. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiter_adventure_class command: '%s'", sep->argplus[0]);
  6045. }
  6046. else if (strncmp(command, "display_heraldry", length) == 0)
  6047. {
  6048. // JA: not sure this is right...
  6049. client->GetPlayer()->toggle_character_flag(CF_SHOW_GUILD_HERALDRY);
  6050. client->GetPlayer()->SetCharSheetChanged(true);
  6051. }
  6052. else
  6053. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild command: '%s'", sep->argplus[0]);
  6054. }
  6055. }
  6056. /*
  6057. Function: Command_GuildCreate()
  6058. Purpose : Display's in-game Guild Creation window
  6059. Dev : Scatman
  6060. */
  6061. void Commands::Command_CreateGuild(Client* client)
  6062. {
  6063. client->SendGuildCreateWindow();
  6064. }
  6065. /*
  6066. Function: Command_SetGuildOfficerNote()
  6067. Purpose :
  6068. Dev : Scatman
  6069. */
  6070. void Commands::Command_SetGuildOfficerNote(Client* client, Seperator* sep)
  6071. {
  6072. if (sep && sep->arg[0] && sep->arg[1])
  6073. {
  6074. Guild* guild = client->GetPlayer()->GetGuild();
  6075. if (guild)
  6076. guild->SetGuildOfficerNote(sep->arg[0], sep->argplus[1]);
  6077. }
  6078. }
  6079. /*
  6080. Function: Command_SetGuildMemberNote()
  6081. Purpose :
  6082. Dev : Scatman
  6083. */
  6084. void Commands::Command_SetGuildMemberNote(Client* client, Seperator* sep)
  6085. {
  6086. if (sep && sep->arg[0] && sep->arg[1])
  6087. {
  6088. Guild* guild = client->GetPlayer()->GetGuild();
  6089. if (guild)
  6090. guild->SetGuildMemberNote(sep->arg[0], sep->argplus[1]);
  6091. }
  6092. }
  6093. /*
  6094. Function: Command_GuildSay()
  6095. Purpose :
  6096. Dev : Scatman
  6097. */
  6098. void Commands::Command_GuildSay(Client* client, Seperator* sep)
  6099. {
  6100. Guild* guild = client->GetPlayer()->GetGuild();
  6101. if (guild)
  6102. {
  6103. if (sep && sep->arg[0])
  6104. guild->HandleGuildSay(client, sep->argplus[0]);
  6105. }
  6106. else
  6107. client->SimpleMessage(CHANNEL_NARRATIVE, "You are not a member of a guild");
  6108. }
  6109. /*
  6110. Function: Command_OfficerSay()
  6111. Purpose :
  6112. Dev : Scatman
  6113. */
  6114. void Commands::Command_OfficerSay(Client* client, Seperator* sep)
  6115. {
  6116. Guild* guild = client->GetPlayer()->GetGuild();
  6117. if (guild)
  6118. {
  6119. if (sep && sep->arg[0])
  6120. guild->HandleOfficerSay(client, sep->argplus[0]);
  6121. }
  6122. else
  6123. client->SimpleMessage(CHANNEL_NARRATIVE, "You are not a member of a guild");
  6124. }
  6125. /*
  6126. Function: Command_Guilds()
  6127. Purpose : Shows help for /guild command
  6128. Params :
  6129. Dev : Scatman
  6130. Example :
  6131. */
  6132. void Commands::Command_Guilds(Client* client)
  6133. {
  6134. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds [create|delete|add|remove|list]");
  6135. }
  6136. /*
  6137. Function: Command_GuildsAdd()
  6138. Purpose : Add's players to a guild
  6139. Params : guild_name|guild_id, player name
  6140. Dev : Scatman
  6141. Example : /guilds add 1 Admin = adds player Admin to guild_id 1
  6142. */
  6143. void Commands::Command_GuildsAdd(Client* client, Seperator* sep)
  6144. {
  6145. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  6146. {
  6147. Guild* guild = 0;
  6148. bool found = true;
  6149. if (sep->IsNumber(0))
  6150. {
  6151. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  6152. if (!guild)
  6153. {
  6154. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  6155. found = false;
  6156. }
  6157. }
  6158. else
  6159. {
  6160. guild = guild_list.GetGuild(sep->arg[0]);
  6161. if (!guild)
  6162. {
  6163. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  6164. found = false;
  6165. }
  6166. }
  6167. if (found)
  6168. {
  6169. Client* to_client = 0;
  6170. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  6171. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  6172. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  6173. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  6174. if (to_client)
  6175. guild->InvitePlayer(client, to_client->GetPlayer()->GetName());
  6176. else
  6177. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  6178. }
  6179. }
  6180. else
  6181. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds add [guild name|guild id] (player name).");
  6182. }
  6183. /*
  6184. Function: Command_GuildsCreate()
  6185. Purpose : Creates a guild
  6186. Params : guild_name, player_name (optional)
  6187. Dev : Scatman
  6188. Example : /guilds create [guild name] (player name)
  6189. */
  6190. void Commands::Command_GuildsCreate(Client* client, Seperator* sep)
  6191. {
  6192. if (sep && sep->arg[0])
  6193. {
  6194. const char* guild_name = sep->arg[0];
  6195. if (!guild_list.GetGuild(guild_name))
  6196. {
  6197. bool ret = false;
  6198. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  6199. {
  6200. Client* to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  6201. if (to_client)
  6202. {
  6203. world.CreateGuild(guild_name, to_client);
  6204. ret = true;
  6205. }
  6206. else
  6207. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player with name '%s'", sep->arg[1]);
  6208. }
  6209. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  6210. {
  6211. Client* to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  6212. if (to_client)
  6213. {
  6214. world.CreateGuild(guild_name, to_client);
  6215. ret = true;
  6216. }
  6217. }
  6218. else
  6219. {
  6220. world.CreateGuild(guild_name);
  6221. ret = true;
  6222. }
  6223. if (ret)
  6224. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully created.", guild_name);
  6225. else
  6226. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the guild.");
  6227. }
  6228. else
  6229. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' already exists.", guild_name);
  6230. }
  6231. else
  6232. 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.");
  6233. }
  6234. /*
  6235. Function: Command_GuildsDelete()
  6236. Purpose : Delete's a guild
  6237. Params : guild name
  6238. Dev : Scatman
  6239. Example : /guilds delete Test
  6240. */
  6241. void Commands::Command_GuildsDelete(Client* client, Seperator* sep)
  6242. {
  6243. if (sep && sep->arg[0])
  6244. {
  6245. Guild* guild = 0;
  6246. bool found = true;
  6247. if (sep->IsNumber(0))
  6248. {
  6249. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  6250. if (!guild)
  6251. {
  6252. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  6253. found = false;
  6254. }
  6255. }
  6256. else
  6257. {
  6258. guild = guild_list.GetGuild(sep->arg[0]);
  6259. if (!guild)
  6260. {
  6261. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  6262. found = false;
  6263. }
  6264. }
  6265. if (found)
  6266. {
  6267. guild->RemoveAllGuildMembers();
  6268. database.DeleteGuild(guild);
  6269. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully deleted.", guild->GetName());
  6270. guild_list.RemoveGuild(guild, true);
  6271. }
  6272. }
  6273. else
  6274. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds delete [guild name].");
  6275. }
  6276. /*
  6277. Function: Command_GuildsList()
  6278. Purpose : Lists current guilds on server
  6279. Params :
  6280. Dev : Scatman
  6281. Example : /guilds list
  6282. */
  6283. void Commands::Command_GuildsList(Client* client)
  6284. {
  6285. MutexMap<int32, Guild*>* guilds = guild_list.GetGuilds();
  6286. MutexMap<int32, Guild*>::iterator itr = guilds->begin();
  6287. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Guild List:");
  6288. if (guilds->size() == 0)
  6289. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "None.");
  6290. else {
  6291. while (itr.Next()) {
  6292. Guild* guild = itr.second;
  6293. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", guild->GetID(), guild->GetName());
  6294. }
  6295. }
  6296. }
  6297. /*
  6298. Function: Command_GuildsRemove()
  6299. Purpose : Removes a player from a guild
  6300. Params : guild name|guild id, player name
  6301. Dev : Scatman
  6302. Example : /guilds remove 1 Admin = removes Admin from guild 1
  6303. */
  6304. void Commands::Command_GuildsRemove(Client* client, Seperator* sep)
  6305. {
  6306. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  6307. {
  6308. Guild* guild = 0;
  6309. bool found = true;
  6310. if (sep->IsNumber(0))
  6311. {
  6312. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  6313. if (!guild)
  6314. {
  6315. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  6316. found = false;
  6317. }
  6318. }
  6319. else
  6320. {
  6321. guild = guild_list.GetGuild(sep->arg[0]);
  6322. if (!guild)
  6323. {
  6324. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  6325. found = false;
  6326. }
  6327. }
  6328. if (found)
  6329. {
  6330. Client* to_client = 0;
  6331. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  6332. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  6333. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  6334. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  6335. if (to_client)
  6336. {
  6337. Player* to_player = to_client->GetPlayer();
  6338. if (to_player->GetGuild())
  6339. {
  6340. if (to_player->GetGuild() == guild)
  6341. {
  6342. guild->KickGuildMember(client, to_player->GetName());
  6343. }
  6344. else
  6345. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in the guild '%s'.", to_player->GetName(), guild->GetName());
  6346. }
  6347. else
  6348. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in a guild.", to_player->GetName());
  6349. }
  6350. else
  6351. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  6352. }
  6353. }
  6354. else
  6355. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds remove [guild name|guild id] (player name).");
  6356. }
  6357. /*
  6358. Function: Command_InspectPlayer()
  6359. Purpose : Handle the Inspect functions
  6360. Params : Client to inspect
  6361. Dev : Scatman
  6362. Example : /inspect Scatman
  6363. */
  6364. void Commands::Command_InspectPlayer(Client* client, Seperator* sep)
  6365. {
  6366. if (sep && sep->arg[0])
  6367. {
  6368. Client* inspect_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  6369. if (inspect_client)
  6370. client->InspectPlayer(inspect_client->GetPlayer());
  6371. }
  6372. else
  6373. {
  6374. Spawn* target = client->GetPlayer()->GetTarget();
  6375. if (target && target->IsPlayer())
  6376. client->InspectPlayer((Player*)target);
  6377. }
  6378. }
  6379. /*
  6380. Function: Command_Inventory()
  6381. Purpose : Handle changes in player inventory
  6382. Params : <TBD>
  6383. Dev : All
  6384. Example : /inventory delete item_id
  6385. */
  6386. void Commands::Command_Inventory(Client* client, Seperator* sep, EQ2_RemoteCommandString* command)
  6387. {
  6388. PrintSep(sep, "Command_Inventory"); // temp to figure out the params
  6389. Player* player = client->GetPlayer();
  6390. if(sep && sep->arg[0][0])
  6391. {
  6392. LogWrite(COMMAND__INFO, 0, "Command", "command: %s", sep->argplus[0]);
  6393. if(!client->GetPlayer()->Alive())
  6394. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  6395. else if(sep->arg[1][0] && strncasecmp("destroy", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  6396. {
  6397. int16 index = atoi(sep->arg[1]);
  6398. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  6399. if(item)
  6400. {
  6401. if(item->details.item_locked) {
  6402. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot destroy the item in use.");
  6403. return;
  6404. }
  6405. else if(item->CheckFlag(NO_DESTROY)) {
  6406. client->SimpleMessage(CHANNEL_COLOR_RED, "You can't destroy this item.");
  6407. return;
  6408. }
  6409. if(item->GetItemScript() && lua_interface)
  6410. lua_interface->RunItemScript(item->GetItemScript(), "destroyed", item, client->GetPlayer());
  6411. //reobtain item make sure it wasn't removed
  6412. item = player->item_list.GetItemFromIndex(index);
  6413. int32 bag_id = 0;
  6414. if(item){
  6415. bag_id = item->details.inv_slot_id;
  6416. database.DeleteItem(client->GetCharacterID(), item, 0);
  6417. }
  6418. client->GetPlayer()->item_list.DestroyItem(index);
  6419. client->GetPlayer()->UpdateInventory(bag_id);
  6420. }
  6421. }
  6422. 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))
  6423. {
  6424. int16 from_index = atoi(sep->arg[1]);
  6425. sint16 to_slot = atoi(sep->arg[2]); // don't convert slot since this is inventory not equipment
  6426. sint32 bag_id = atol(sep->arg[3]);
  6427. int8 charges = atoi(sep->arg[4]);
  6428. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(from_index);
  6429. if(!item) {
  6430. client->SimpleMessage(CHANNEL_COLOR_RED, "You have no item.");
  6431. return;
  6432. }
  6433. if(to_slot == item->details.slot_id && (bag_id < 0 || bag_id == item->details.inv_slot_id)) {
  6434. return;
  6435. }
  6436. if(item->details.item_locked)
  6437. {
  6438. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot move the item in use.");
  6439. return;
  6440. }
  6441. if(bag_id == -4 && !client->GetPlayer()->item_list.SharedBankAddAllowed(item))
  6442. {
  6443. client->SimpleMessage(CHANNEL_COLOR_RED, "That item (or an item inside) cannot be shared.");
  6444. return;
  6445. }
  6446. sint32 old_inventory_id = 0;
  6447. if(item)
  6448. old_inventory_id = item->details.inv_slot_id;
  6449. //autobank
  6450. if (bag_id == -3 && to_slot == -1)
  6451. {
  6452. if (player->HasFreeBankSlot())
  6453. to_slot = player->FindFreeBankSlot();
  6454. else
  6455. {
  6456. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free bank slots.");
  6457. return;
  6458. }
  6459. }
  6460. //auto inventory
  6461. if (bag_id == 0 && to_slot == -1)
  6462. {
  6463. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  6464. {
  6465. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free slots.");
  6466. return;
  6467. }
  6468. }
  6469. bool item_deleted = false;
  6470. EQ2Packet* outapp = client->GetPlayer()->MoveInventoryItem(bag_id, from_index, (int8)to_slot, charges, 0, &item_deleted, client->GetVersion());
  6471. client->QueuePacket(outapp);
  6472. if(item_deleted)
  6473. item = nullptr;
  6474. //removed from bag send update
  6475. if(old_inventory_id > 0 && item && item->details.inv_slot_id != old_inventory_id)
  6476. {
  6477. outapp = client->GetPlayer()->SendBagUpdate(old_inventory_id, client->GetVersion());
  6478. if(outapp)
  6479. client->QueuePacket(outapp);
  6480. }
  6481. if(item && item->details.inv_slot_id > 0 && item->details.inv_slot_id != old_inventory_id)
  6482. {
  6483. outapp = client->GetPlayer()->SendBagUpdate(item->details.inv_slot_id, client->GetVersion());
  6484. if(outapp)
  6485. client->QueuePacket(outapp);
  6486. }
  6487. }
  6488. else if(sep->arg[1][0] && strncasecmp("equip", sep->arg[0], 5) == 0 && sep->IsNumber(1))
  6489. {
  6490. if(client->GetPlayer()->EngagedInCombat())
  6491. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not equip items while in combat.");
  6492. else
  6493. {
  6494. int16 index = atoi(sep->arg[1]);
  6495. int8 slot_id = 255;
  6496. int8 unk3 = 0;
  6497. int8 appearance_equip = 0;
  6498. if(sep->arg[2][0] && sep->IsNumber(2))
  6499. slot_id = player->ConvertSlotFromClient(atoi(sep->arg[2]), client->GetVersion());
  6500. if(sep->arg[3][0] && sep->IsNumber(3))
  6501. unk3 = atoul(sep->arg[3]);
  6502. if(sep->arg[4][0] && sep->IsNumber(4))
  6503. appearance_equip = atoul(sep->arg[4]);
  6504. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), appearance_equip, slot_id);
  6505. EQ2Packet* outapp = 0;
  6506. for(int32 i=0;i<packets.size();i++)
  6507. {
  6508. outapp = packets[i];
  6509. if(outapp)
  6510. client->QueuePacket(outapp);
  6511. }
  6512. client->GetPlayer()->UpdateWeapons();
  6513. EQ2Packet* characterSheetPackets = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion());
  6514. client->QueuePacket(characterSheetPackets);
  6515. }
  6516. }
  6517. else if (sep->arg[1][0] && strncasecmp("unpack", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  6518. {
  6519. if (client->GetPlayer()->EngagedInCombat())
  6520. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unpack items while in combat.");
  6521. else {
  6522. int16 index = atoi(sep->arg[1]);
  6523. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  6524. if (item) {
  6525. if(item->details.item_locked)
  6526. {
  6527. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot unpack the item in use.");
  6528. return;
  6529. }
  6530. // client->GetPlayer()->item_list.DestroyItem(index);
  6531. if (item->item_sets.size() > 0) {
  6532. for (int32 i = 0; i < item->item_sets.size(); i++) {
  6533. ItemSet* set = item->item_sets[i];
  6534. if (set->item_stack_size == 0)
  6535. set->item_stack_size += 1;
  6536. client->AddItem(set->item_id, set->item_stack_size);
  6537. }
  6538. }
  6539. }
  6540. client->RemoveItem(item, 1);
  6541. }
  6542. }
  6543. else if(sep->arg[1][0] && strncasecmp("unequip", sep->arg[0], 7) == 0 && sep->IsNumber(1))
  6544. {
  6545. if(client->GetPlayer()->EngagedInCombat())
  6546. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unequip items while in combat.");
  6547. else
  6548. {
  6549. int16 index = player->ConvertSlotFromClient(atoi(sep->arg[1]), client->GetVersion());
  6550. sint32 bag_id = -999;
  6551. int8 to_slot = 255;
  6552. if(sep->arg[3][0])
  6553. {
  6554. if(sep->IsNumber(2))
  6555. bag_id = atol(sep->arg[2]);
  6556. if(sep->IsNumber(3))
  6557. to_slot = atoi(sep->arg[3]);
  6558. }
  6559. sint8 unk4 = 0;
  6560. int8 appearance_equip = 0;
  6561. if(sep->arg[4][0] && sep->IsNumber(4))
  6562. unk4 = atoi(sep->arg[4]);
  6563. if(sep->arg[5][0] && sep->IsNumber(5))
  6564. appearance_equip = atoul(sep->arg[5]);
  6565. vector<EQ2Packet*> packets = client->GetPlayer()->UnequipItem(index, bag_id, to_slot, client->GetVersion(), appearance_equip);
  6566. EQ2Packet* outapp = 0;
  6567. for(int32 i=0;i<packets.size();i++)
  6568. {
  6569. outapp = packets[i];
  6570. if(outapp)
  6571. client->QueuePacket(outapp);
  6572. }
  6573. client->UnequipItem(index, bag_id, to_slot, appearance_equip);
  6574. }
  6575. }
  6576. else if(sep->arg[2][0] && strncasecmp("swap_equip", sep->arg[0], 10) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  6577. {
  6578. if(client->GetPlayer()->EngagedInCombat()) {
  6579. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not swap items while in combat.");
  6580. }
  6581. else {
  6582. int16 index1 = client->GetPlayer()->ConvertSlotFromClient(atoi(sep->arg[1]), client->GetVersion());
  6583. int16 index2 = client->GetPlayer()->ConvertSlotFromClient(atoi(sep->arg[2]), client->GetVersion());
  6584. int8 type = 0;
  6585. if(sep->IsNumber(3))
  6586. type = atoul(sep->arg[3]); // type 0 is combat, 3 = appearance
  6587. EQ2Packet* outapp = client->GetPlayer()->SwapEquippedItems(index1, index2, client->GetVersion(), type);
  6588. if(outapp)
  6589. client->QueuePacket(outapp);
  6590. else
  6591. {
  6592. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to swap items");
  6593. return;
  6594. }
  6595. }
  6596. }
  6597. else if (sep->arg[2][0] && strncasecmp("pop", sep->arg[0], 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  6598. {
  6599. sint16 to_slot = atoi(sep->arg[1]);
  6600. sint32 bag_id = atoi(sep->arg[2]);
  6601. Item* item = client->GetPlayer()->item_list.GetOverflowItem();
  6602. if (item) {
  6603. //auto inventory
  6604. if (bag_id == 0 && to_slot == -1)
  6605. {
  6606. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  6607. {
  6608. client->SimpleMessage(CHANNEL_ERROR, "You do not have any free slots.");
  6609. return;
  6610. }
  6611. // Set the slot for the item
  6612. item->details.inv_slot_id = bag_id;
  6613. item->details.slot_id = to_slot;
  6614. // Flag the item so it gets saved in its new location
  6615. item->save_needed = true;
  6616. // Add the item to its new location
  6617. if(player->item_list.AddItem(item)) {
  6618. // Remove the item from the overflow list
  6619. player->item_list.RemoveOverflowItem(item);
  6620. }
  6621. // Send the inventory update packet
  6622. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  6623. return;
  6624. }
  6625. else if (bag_id == -3 && to_slot == -1) {
  6626. // Auto Bank
  6627. if (!player->item_list.GetFirstFreeBankSlot(&bag_id, &to_slot)) {
  6628. client->SimpleMessage(CHANNEL_STATUS, "You do not have any free bank slots.");
  6629. return;
  6630. }
  6631. item->details.inv_slot_id = bag_id;
  6632. item->details.slot_id = to_slot;
  6633. item->save_needed = true;
  6634. if(player->item_list.AddItem(item)) {
  6635. player->item_list.RemoveOverflowItem(item);
  6636. }
  6637. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  6638. }
  6639. else if (bag_id == -4) {
  6640. // Shared Bank
  6641. if (!player->item_list.SharedBankAddAllowed(item)) {
  6642. client->SimpleMessage(CHANNEL_STATUS, "That item (or an item inside) cannot be shared.");
  6643. return;
  6644. }
  6645. Item* tmp_item = player->item_list.GetItem(-4, to_slot);
  6646. if (tmp_item) {
  6647. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  6648. return;
  6649. }
  6650. else {
  6651. item->details.inv_slot_id = bag_id;
  6652. item->details.slot_id = to_slot;
  6653. item->save_needed = true;
  6654. if(player->item_list.AddItem(item)) {
  6655. player->item_list.RemoveOverflowItem(item);
  6656. }
  6657. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  6658. return;
  6659. }
  6660. }
  6661. else {
  6662. // Try to get an item from the given bag id and slot id
  6663. Item* tmp_item = player->item_list.GetItem(bag_id, to_slot);
  6664. // Check to see if we got an item, if we do send an error,
  6665. // if we don't put the overflow item into this slot
  6666. if (tmp_item) {
  6667. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  6668. }
  6669. else {
  6670. item->details.inv_slot_id = bag_id;
  6671. item->details.slot_id = to_slot;
  6672. item->save_needed = true;
  6673. if(player->item_list.AddItem(item)) {
  6674. player->item_list.RemoveOverflowItem(item);
  6675. }
  6676. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  6677. return;
  6678. }
  6679. }
  6680. }
  6681. }
  6682. else if(sep->arg[2][0] && strncasecmp("nosale", sep->arg[0], 6) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  6683. {
  6684. sint64 data = strtoull(sep->arg[1], NULL, 0);
  6685. int32 character_item_id = (int32) (data >> 32);
  6686. int32 item_id = (int32) (data & 0xffffffffL);
  6687. int8 sale_setting = atoi(sep->arg[2]);
  6688. Item* item = client->GetPlayer()->item_list.GetItemFromUniqueID(character_item_id);
  6689. if(item)
  6690. {
  6691. item->no_sale = sale_setting;
  6692. item->save_needed = true;
  6693. client->SendSellMerchantList();
  6694. }
  6695. }
  6696. }
  6697. else
  6698. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /inventory {destroy|move|equip|unequip|swap_equip|pop} {item_id} [to_slot] [bag_id]");
  6699. }
  6700. /*
  6701. Function: Command_Languages()
  6702. Purpose : Show's languages the player knows
  6703. Params :
  6704. Dev : Zcoretri
  6705. Example :
  6706. */
  6707. void Commands::Command_Languages(Client* client, Seperator* sep)
  6708. {
  6709. list<Language*>* languages = client->GetPlayer()->GetPlayerLanguages()->GetAllLanguages();
  6710. list<Language*>::iterator itr;
  6711. Language* language;
  6712. client->Message(CHANNEL_NARRATIVE, "You know the following languages:");
  6713. for(itr = languages->begin(); itr != languages->end(); itr++)
  6714. {
  6715. language = *itr;
  6716. client->Message(CHANNEL_NARRATIVE, "%s", language->GetName());
  6717. }
  6718. }
  6719. /*
  6720. Function: Command_SetLanguage()
  6721. Purpose : Handles language commands
  6722. Params : Language ID
  6723. Dev : Zcoretri
  6724. Example :
  6725. */
  6726. void Commands::Command_SetLanguage(Client* client, Seperator* sep)
  6727. {
  6728. Player* player = client->GetPlayer();
  6729. if (sep && sep->arg[0])
  6730. {
  6731. if(!sep->IsNumber(0))
  6732. {
  6733. //String passed in
  6734. const char* value = sep->arg[0];
  6735. if(strncasecmp(value, "Common", strlen(value)) == 0)
  6736. {
  6737. database.SaveCharacterCurrentLang(0, client->GetCharacterID(), client);
  6738. client->SendLanguagesUpdate(0);
  6739. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", value);
  6740. }
  6741. else
  6742. {
  6743. if(player->HasLanguage(value))
  6744. {
  6745. Language* language = player->GetPlayerLanguages()->GetLanguageByName(value);
  6746. database.SaveCharacterCurrentLang(language->GetID(), client->GetCharacterID(), client);
  6747. client->SendLanguagesUpdate(language->GetID());
  6748. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", language->GetName());
  6749. }
  6750. else
  6751. client->Message(CHANNEL_NARRATIVE, "You do not know how to speak %s", value);
  6752. }
  6753. }
  6754. else
  6755. {
  6756. //Number passed in
  6757. int32 id = atoul(sep->arg[0]);
  6758. if(player->HasLanguage(id))
  6759. {
  6760. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  6761. database.SaveCharacterCurrentLang(id, client->GetCharacterID(), client);
  6762. client->SendLanguagesUpdate(id);
  6763. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", language->GetName());
  6764. }
  6765. else
  6766. {
  6767. Language* language = master_languages_list.GetLanguage(id);
  6768. if(language)
  6769. client->Message(CHANNEL_NARRATIVE, "You do not know how to speak %s", language->GetName());
  6770. }
  6771. }
  6772. }
  6773. else
  6774. {
  6775. //No value was passed in
  6776. int32 id = database.GetCharacterCurrentLang(client->GetCharacterID(), player);
  6777. if(id > 0)
  6778. {
  6779. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  6780. client->Message(CHANNEL_NARRATIVE, "You are currently speaking %s ", language->GetName());
  6781. }
  6782. else
  6783. client->Message(CHANNEL_NARRATIVE, "You are currently speaking Common");
  6784. }
  6785. }
  6786. /*
  6787. Function: Command_LastName()
  6788. Purpose : Sets player surname
  6789. Params : Name text
  6790. Dev : theFoof
  6791. Example :
  6792. */
  6793. void Commands::Command_LastName(Client* client, Seperator* sep)
  6794. {
  6795. if (!client)
  6796. return;
  6797. if (sep && sep->arg[0])
  6798. {
  6799. if (!client->GetPlayer()->get_character_flag(CF_ENABLE_CHANGE_LASTNAME)){
  6800. client->Message(CHANNEL_COLOR_YELLOW, "You must be atleast level %i to change your last name.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  6801. return;
  6802. }
  6803. client->RemovePendingLastName();
  6804. uchar* checkname = (uchar*)sep->arg[0];
  6805. bool valid_name = true;
  6806. for (int32 i = 0; i < strlen(sep->arg[0]); i++) {
  6807. if (!alpha_check(checkname[i])) {
  6808. valid_name = false;
  6809. break;
  6810. }
  6811. }
  6812. if (!valid_name) {
  6813. client->Message(CHANNEL_COLOR_YELLOW, "Your last name can only contain letters.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  6814. return;
  6815. }
  6816. string last_name = (string)sep->arg[0];
  6817. int8 max_length = rule_manager.GetGlobalRule(R_Player, MaxLastNameLength)->GetInt8();
  6818. int8 min_length = rule_manager.GetGlobalRule(R_Player, MinLastNameLength)->GetInt8();
  6819. if (last_name.length() <= max_length && last_name.length() >= min_length){
  6820. client->SetPendingLastName(last_name);
  6821. client->SendLastNameConfirmation();
  6822. }
  6823. else
  6824. client->Message(CHANNEL_COLOR_YELLOW, "Your last name must be between %i and %i characters long.", min_length, max_length);
  6825. }
  6826. }
  6827. /*
  6828. Function: Command_ConfirmLastName()
  6829. Purpose : Confirms setting of player surname
  6830. Params : Name text
  6831. Dev : theFoof
  6832. Example :
  6833. */
  6834. void Commands::Command_ConfirmLastName(Client* client, Seperator* sep)
  6835. {
  6836. if (!client)
  6837. return;
  6838. string* name = client->GetPendingLastName();
  6839. if (name){
  6840. Player* player = client->GetPlayer();
  6841. player->SetLastName(name->c_str(), false);
  6842. client->SendTitleUpdate();
  6843. player->SetCharSheetChanged(true);
  6844. client->RemovePendingLastName();
  6845. }
  6846. }
  6847. /*
  6848. Function: Command_Location()
  6849. Purpose : Display's Help for /location commands
  6850. Params :
  6851. Dev : Scatman
  6852. Example : /location = show's help for command
  6853. */
  6854. void Commands::Command_Location(Client* client)
  6855. {
  6856. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Valid /location commands are:");
  6857. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location create [name] (include y). Include y defaults to false");
  6858. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location add [location id]");
  6859. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location remove [location point id]");
  6860. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location delete [location id]");
  6861. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location list [locations|points] [location id if points used]");
  6862. }
  6863. /*
  6864. Function: Command_LocationAdd()
  6865. Purpose : Add's a location to an existing location config
  6866. Params : location_id
  6867. Dev : Scatman
  6868. Example : /location add {location_id}
  6869. */
  6870. void Commands::Command_LocationAdd(Client* client, Seperator* sep)
  6871. {
  6872. if (sep && sep->arg[0] && sep->IsNumber(0))
  6873. {
  6874. int32 location_id = atoul(sep->arg[0]);
  6875. float x = client->GetPlayer()->GetX();
  6876. float y = client->GetPlayer()->GetY();
  6877. float z = client->GetPlayer()->GetZ();
  6878. if (database.AddLocationPoint(location_id, x, y, z))
  6879. client->Message(CHANNEL_COLOR_YELLOW, "Point (%f, %f, %f) was successfully added to location %u", x, y, z, location_id);
  6880. else
  6881. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist. Use /location create to create one", location_id);
  6882. }
  6883. else
  6884. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location add [location id]");
  6885. }
  6886. /*
  6887. Function: Command_LocationCreate()
  6888. Purpose : Creates a new location config
  6889. Params : location name, 0/1 for include_y (optional)
  6890. Dev : Scatman
  6891. Example : /location create Test 1 = creates a new location named Test with include_y True
  6892. */
  6893. void Commands::Command_LocationCreate(Client* client, Seperator* sep)
  6894. {
  6895. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  6896. {
  6897. const char* name = sep->arg[0];
  6898. bool include_y = false;
  6899. if (sep->arg[1] && sep->IsNumber(1) && atoi(sep->arg[1]) > 0)
  6900. include_y = true;
  6901. int32 location_id = database.CreateLocation(client->GetPlayer()->GetZone()->GetZoneID(), client->GetPlayer()->GetLocation(), name, include_y);
  6902. if (location_id > 0)
  6903. client->Message(CHANNEL_COLOR_YELLOW, "Location '%s' was successfully created with location id %u", name, location_id);
  6904. else
  6905. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the requested location");
  6906. }
  6907. else
  6908. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location create [name] (include_y). Include y defaults to false");
  6909. }
  6910. /*
  6911. Function: Command_LocationDelete()
  6912. Purpose : Delete's a location config and all it's location points
  6913. Params : location_id
  6914. Dev : Scatman
  6915. Example : /location delete {location_id}
  6916. */
  6917. void Commands::Command_LocationDelete(Client* client, Seperator* sep)
  6918. {
  6919. if (sep && sep->arg[0] && sep->IsNumber(0))
  6920. {
  6921. int32 location_id = atoul(sep->arg[0]);
  6922. if (database.DeleteLocation(location_id))
  6923. client->Message(CHANNEL_COLOR_YELLOW, "Location id %u and all its points were successfully deleted", location_id);
  6924. else
  6925. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist", location_id);
  6926. }
  6927. else
  6928. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location delete [location id]");
  6929. }
  6930. /*
  6931. Function: Command_LocationList()
  6932. Purpose : Display's a list of location points
  6933. Params : location_id
  6934. Dev : Scatman
  6935. Example : /location list {location_id}
  6936. */
  6937. void Commands::Command_LocationList(Client* client, Seperator* sep)
  6938. {
  6939. if (sep && sep->arg[0])
  6940. {
  6941. const char* option = sep->arg[0];
  6942. if (strncmp(option, "locations", strlen(option)) == 0)
  6943. database.ListLocations(client);
  6944. else if (strncmp(option, "points", strlen(option)) == 0 && sep->arg[1] && sep->IsNumber(1))
  6945. {
  6946. int32 location_id = atoul(sep->arg[1]);
  6947. database.ListLocationPoints(client, location_id);
  6948. }
  6949. else
  6950. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  6951. }
  6952. else
  6953. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  6954. }
  6955. /*
  6956. Function: Command_LocationRemove()
  6957. Purpose : Removes a single location point from a location config
  6958. Params : location_point_id (gotten from /location list {id})
  6959. Dev : Scatman
  6960. Example : /location remove 1 = will remove location_point_id 1
  6961. */
  6962. void Commands::Command_LocationRemove(Client* client, Seperator* sep)
  6963. {
  6964. if (sep && sep->arg[0] && sep->IsNumber(0))
  6965. {
  6966. int32 location_point_id = atoul(sep->arg[0]);
  6967. if (database.DeleteLocationPoint(location_point_id))
  6968. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Location point was successfully deleted");
  6969. else
  6970. client->Message(CHANNEL_COLOR_YELLOW, "Location point with ID %u does not exist", location_point_id);
  6971. }
  6972. else
  6973. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location remove [location point id]");
  6974. }
  6975. /*
  6976. Function: Command_Merchant()
  6977. Purpose : Handles Merchant commands
  6978. Params : list
  6979. Dev : Scatman
  6980. Example : /merchant list
  6981. */
  6982. void Commands::Command_Merchant(Client* client, Seperator* sep, int handler)
  6983. {
  6984. if( handler == COMMAND_MERCHANT )
  6985. {
  6986. // /merchant command by itself shows help (to be extended)
  6987. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  6988. return;
  6989. }
  6990. else if( handler == COMMAND_MERCHANT_LIST )
  6991. {
  6992. // /merchant list command expects "description" param
  6993. if (sep && sep->arg[0])
  6994. {
  6995. const char* merchant_description = sep->argplus[0];
  6996. client->Message(CHANNEL_COLOR_YELLOW, "Listing merchants like '%s':", merchant_description);
  6997. map<int32, MerchantInfo*>* merchant_info = world.GetMerchantInfo();
  6998. map<int32, MerchantInfo*>::iterator itr;
  6999. for (itr = merchant_info->begin(); itr != merchant_info->end(); itr++)
  7000. {
  7001. string description = database.GetMerchantDescription(itr->first);
  7002. if (ToLower(description).find(ToLower(string(merchant_description))) < 0xFFFFFFFF)
  7003. client->Message(CHANNEL_COLOR_YELLOW, "Merchant ID: %u, Description: %s", itr->first, description.c_str());
  7004. }
  7005. }
  7006. else // no description
  7007. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  7008. }
  7009. }
  7010. /*
  7011. Function: Command_Modify()
  7012. Purpose : to replace our other "set" commands
  7013. Params : System = the system to modify, Action = the action to perform, Target = what to change (target, or index)
  7014. Dev : John Adams
  7015. Example : /modify spell set name "Aegolism III"
  7016. */
  7017. void Commands::Command_Modify(Client* client)
  7018. {
  7019. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /modify [system] [action] [field] [value] {target|id}");
  7020. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Systems: character, faction, guild, item, skill, spawn, spell, zone");
  7021. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Actions: set, create, delete, add, remove");
  7022. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Value : field name in the table being modified");
  7023. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target : modify current target, or specified {system} ID");
  7024. }
  7025. /*
  7026. Function: Command_ModifySpawn()
  7027. Purpose : replace "spawn set" commands
  7028. Params : Action : the action to perform (or special handler)
  7029. : Field : the DB field to change
  7030. : Value : what to set the value to
  7031. : Target : what object to change (my target, or spawn_id)
  7032. Dev : John Adams
  7033. Example : /modify spawn set name "Lady Vox"
  7034. :
  7035. Note : Special Handlers, like "zoneto" for Signs
  7036. : /modify spawn zoneto
  7037. : Will set a sign's zone x/y/z to my current coords
  7038. */
  7039. void Commands::Command_ModifySpawn(Client* client, Seperator* sep)
  7040. {
  7041. PrintSep(sep, "COMMAND_MODIFY");
  7042. // need at least 2 args for a valid command
  7043. if( sep && sep->arg[1] )
  7044. {
  7045. // JA: just a quick implementation because I need it :)
  7046. if (strcmp(sep->arg[0], "zoneto") == 0)
  7047. {
  7048. if( sep->IsNumber(1) )
  7049. {
  7050. int32 spawn_id = atoul(sep->arg[1]);
  7051. float x_coord = client->GetPlayer()->GetX();
  7052. float y_coord = client->GetPlayer()->GetY();
  7053. float z_coord = client->GetPlayer()->GetZ();
  7054. float h_coord = client->GetPlayer()->GetHeading();
  7055. database.SaveSignZoneToCoords(spawn_id, x_coord, y_coord, z_coord, h_coord);
  7056. }
  7057. else
  7058. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify spawn zoneto spawn_id - sets spawn_id to your coords");
  7059. }
  7060. }
  7061. else
  7062. Command_Modify(client);
  7063. }
  7064. /*
  7065. Function: Command_ModifyCharacter()
  7066. Purpose : to replace our other "set" commands
  7067. Params : Action : Add, Remove
  7068. : Field : copper, silver, gold, plat
  7069. : Value : min 1, max unlimited
  7070. : Target : Self, Player
  7071. Dev : Cynnar
  7072. Example : /modify character add gold 50
  7073. : /modify character remove silver 25
  7074. */
  7075. void Commands::Command_ModifyCharacter(Client* client, Seperator* sep)
  7076. {
  7077. PrintSep(sep, "COMMAND_MODIFY");
  7078. int64 value = 0;
  7079. Player* player = client->GetPlayer();
  7080. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  7081. player = (Player*)player->GetTarget();
  7082. // need at least 2 args for a valid command
  7083. if( sep && sep->arg[1] )
  7084. {
  7085. if (strcmp(sep->arg[0], "add") == 0)
  7086. {
  7087. if (strcmp(sep->arg[1], "copper") == 0)
  7088. {
  7089. value = atoi64(sep->arg[2]);
  7090. player->AddCoins(value);
  7091. if (client->GetPlayer() == player)
  7092. {
  7093. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu copper coin%s", value, (value > 1 ? "s" : ""));
  7094. }
  7095. else {
  7096. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu copper coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  7097. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu copper coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  7098. }
  7099. }
  7100. else if (strcmp(sep->arg[1], "silver") == 0)
  7101. {
  7102. value = atoi64(sep->arg[2]) * 100;
  7103. player->AddCoins(value);
  7104. if (client->GetPlayer() == player)
  7105. {
  7106. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu silver coin%s", value / 100, (value > 1 ? "s" : ""));
  7107. }
  7108. else {
  7109. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu silver coin%s", player->GetName(), value / 100, (value > 1 ? "s" : ""));
  7110. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu silver coin%s", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  7111. }
  7112. }
  7113. else if (strcmp(sep->arg[1], "gold") == 0)
  7114. {
  7115. value = atoi64(sep->arg[2]) * 10000;
  7116. player->AddCoins(value);
  7117. if (client->GetPlayer() == player)
  7118. {
  7119. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu gold coin%s", value / 10000, (value > 1 ? "s" : ""));
  7120. }
  7121. else {
  7122. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu gold coin%s", player->GetName(), value / 10000, (value > 1 ? "s" : ""));
  7123. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu gold coin%s", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  7124. }
  7125. }
  7126. else if (strcmp(sep->arg[1], "plat") == 0)
  7127. {
  7128. value = atoi64(sep->arg[2]) * 1000000;
  7129. player->AddCoins(value);
  7130. if (client->GetPlayer() == player)
  7131. {
  7132. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu platinum coin%s", value / 1000000, (value > 1 ? "s" : ""));
  7133. }
  7134. else {
  7135. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu platinum coin%s", player->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  7136. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu platinum coin%s", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  7137. }
  7138. }
  7139. else
  7140. {
  7141. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  7142. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  7143. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  7144. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character add copper 20");
  7145. }
  7146. }
  7147. else if (strcmp(sep->arg[0], "remove") == 0)
  7148. {
  7149. if (strcmp(sep->arg[1], "copper") == 0)
  7150. {
  7151. value = atoi64(sep->arg[2]);
  7152. player->RemoveCoins(value);
  7153. if (client->GetPlayer() == player)
  7154. {
  7155. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from yourself", value, (value > 1 ? "s" : ""));
  7156. }
  7157. else {
  7158. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from %s", value, (value > 1 ? "s" : ""), player->GetName());
  7159. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu copper coin%s from you", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  7160. }
  7161. }
  7162. else if (strcmp(sep->arg[1], "silver") == 0)
  7163. {
  7164. value = atoi64(sep->arg[2]) * 100;
  7165. player->RemoveCoins(value);
  7166. if (client->GetPlayer() == player)
  7167. {
  7168. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from yourself", value / 100, (value > 1 ? "s" : ""));
  7169. }
  7170. else {
  7171. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from %s", value / 100, (value > 1 ? "s" : ""), player->GetName());
  7172. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu silver coin%s from you", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  7173. }
  7174. }
  7175. else if (strcmp(sep->arg[1], "gold") == 0)
  7176. {
  7177. value = atoi64(sep->arg[2]) * 10000;
  7178. player->RemoveCoins(value);
  7179. if (client->GetPlayer() == player)
  7180. {
  7181. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from yourself", value / 10000, (value > 1 ? "s" : ""));
  7182. }
  7183. else {
  7184. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from %s", value / 10000, (value > 1 ? "s" : ""), player->GetName());
  7185. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu gold coin%s from you", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  7186. }
  7187. }
  7188. else if (strcmp(sep->arg[1], "plat") == 0)
  7189. {
  7190. value = atoi64(sep->arg[2]) * 1000000;
  7191. player->RemoveCoins(value);
  7192. if (client->GetPlayer() == player)
  7193. {
  7194. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from yourself", value / 1000000, (value > 1 ? "s" : ""));
  7195. }
  7196. else {
  7197. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from %s", value / 1000000, (value > 1 ? "s" : ""), player->GetName());
  7198. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu platinum coin%s from you", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  7199. }
  7200. }
  7201. else
  7202. {
  7203. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  7204. }
  7205. }
  7206. else if (strcmp(sep->arg[0], "set") == 0) {
  7207. if (strcmp(sep->arg[1], "tslevel") == 0) {
  7208. int8 level = atoi(sep->arg[2]);
  7209. if (level > 0 && level < 256) {
  7210. if (player) {
  7211. if (client->GetPlayer() == player)
  7212. client->ChangeTSLevel(player->GetTSLevel(), level);
  7213. else
  7214. player->GetZone()->GetClientBySpawn(player)->ChangeTSLevel(player->GetTSLevel(), level);
  7215. }
  7216. }
  7217. else
  7218. client->SimpleMessage(CHANNEL_ERROR, "Level must be between 1 - 255");
  7219. }
  7220. else if (strcmp(sep->arg[1], "tsclass") == 0) {
  7221. int8 tsclass = atoi(sep->arg[2]);
  7222. player->SetTradeskillClass(tsclass);
  7223. player->GetInfoStruct()->set_tradeskill_class1(classes.GetTSBaseClass(player->GetTradeskillClass()));
  7224. player->GetInfoStruct()->set_tradeskill_class2(classes.GetSecondaryTSBaseClass(player->GetTradeskillClass()));
  7225. player->GetInfoStruct()->set_tradeskill_class3(player->GetTradeskillClass());
  7226. player->SetCharSheetChanged(true);
  7227. }
  7228. else if (strcmp(sep->arg[1], "gender") == 0) {
  7229. int8 gender = atoi(sep->arg[2]);
  7230. client->GetPlayer()->GetInfoStruct()->set_gender(gender);
  7231. client->GetPlayer()->SetCharSheetChanged(true);
  7232. client->UpdateTimeStampFlag ( GENDER_UPDATE_FLAG );
  7233. }
  7234. }
  7235. }
  7236. else
  7237. {
  7238. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  7239. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  7240. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  7241. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  7242. }
  7243. }
  7244. void Commands::Command_ModifyFaction(Client* client, Seperator* sep)
  7245. {
  7246. PrintSep(sep, "COMMAND_MODIFY");
  7247. // need at least 2 args for a valid command
  7248. if( sep && sep->arg[1] )
  7249. {
  7250. }
  7251. else
  7252. Command_Modify(client);
  7253. }
  7254. void Commands::Command_ModifyGuild(Client* client, Seperator* sep)
  7255. {
  7256. PrintSep(sep, "COMMAND_MODIFY");
  7257. // need at least 2 args for a valid command
  7258. if( sep && sep->arg[1] )
  7259. {
  7260. }
  7261. else
  7262. Command_Modify(client);
  7263. }
  7264. void Commands::Command_ModifyItem(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. /*
  7275. Function: Command_ModifyQuest()
  7276. Purpose : to list players quest and completed quests
  7277. Params : Action : list, completed
  7278. : Target : Self, Player
  7279. Dev : Cynnar
  7280. Example : /modify quest list
  7281. : /modify quest completed
  7282. */
  7283. void Commands::Command_ModifyQuest(Client* client, Seperator* sep)
  7284. {
  7285. PrintSep(sep, "COMMAND_MODIFY");
  7286. int64 value = 0;
  7287. Player* player = client->GetPlayer();
  7288. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  7289. player = (Player*)player->GetTarget();
  7290. // need at least 2 args for a valid command
  7291. if (sep && sep->arg[1])
  7292. {
  7293. if (strcmp(sep->arg[0], "list") == 0)
  7294. {
  7295. map<int32, Quest*>* quests = player->GetPlayerQuests();
  7296. map<int32, Quest*>::iterator itr;
  7297. client->Message(CHANNEL_COLOR_YELLOW, "%s's Quest List:.", client->GetPlayer()->GetName());
  7298. if (quests->size() == 0)
  7299. client->Message(CHANNEL_COLOR_YELLOW, "%s has no quests.", client->GetPlayer()->GetName());
  7300. else
  7301. {
  7302. for (itr = quests->begin(); itr != quests->end(); itr++)
  7303. {
  7304. Quest* quest = itr->second;
  7305. if(quest) {
  7306. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  7307. }
  7308. }
  7309. }
  7310. }
  7311. else if (strcmp(sep->arg[0], "completed") == 0)
  7312. {
  7313. map<int32, Quest*>* quests = player->GetCompletedPlayerQuests();
  7314. map<int32, Quest*>::iterator itr;
  7315. client->Message(CHANNEL_COLOR_YELLOW, "%s's Completed Quest List:.", client->GetPlayer()->GetName());
  7316. if (quests->size() == 0)
  7317. client->Message(CHANNEL_COLOR_YELLOW, "%s has no completed quests.", client->GetPlayer()->GetName());
  7318. else
  7319. {
  7320. for (itr = quests->begin(); itr != quests->end(); itr++)
  7321. {
  7322. Quest* quest = itr->second;
  7323. if(quest) {
  7324. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  7325. }
  7326. }
  7327. }
  7328. }
  7329. // Add in a progress step, and a LogWrite() for tracking GM Commands.
  7330. // LogWrite(LUA__DEBUG, 0, "LUA", "Quest: %s, function: %s", quest->GetName(), function);
  7331. else if (strcmp(sep->arg[0], "remove") == 0)
  7332. {
  7333. int32 quest_id = 0;
  7334. if (sep && sep->arg[1] && sep->IsNumber(1))
  7335. quest_id = atoul(sep->arg[1]);
  7336. if (quest_id > 0)
  7337. {
  7338. if (lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0)
  7339. {
  7340. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  7341. if (quest)
  7342. if (client->GetPlayer() == player)
  7343. {
  7344. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been removed from your journal", quest->GetName());
  7345. }
  7346. else
  7347. {
  7348. client->Message(CHANNEL_COLOR_YELLOW, "You have removed the quest %s from %s's journal", quest->GetName(), player->GetName());
  7349. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s has removed the quest %s from your journal", client->GetPlayer()->GetName(), quest->GetName());
  7350. }
  7351. LogWrite(COMMAND__INFO, 0, "GM Command", "%s removed the quest %s from %s", client->GetPlayer()->GetName(), quest->GetName(), player->GetName());
  7352. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  7353. }
  7354. client->RemovePlayerQuest(quest_id);
  7355. client->GetCurrentZone()->SendQuestUpdates(client);
  7356. }
  7357. }
  7358. else if (strcmp(sep->arg[0], "advance") == 0)
  7359. {
  7360. int32 quest_id = 0;
  7361. int32 step = 0;
  7362. if (sep && sep->arg[1] && sep->IsNumber(1))
  7363. {
  7364. quest_id = atoul(sep->arg[1]);
  7365. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  7366. if(!quest) {
  7367. client->Message(CHANNEL_COLOR_RED, "Quest not found!");
  7368. return;
  7369. }
  7370. if (sep && sep->arg[2] && sep->IsNumber(1))
  7371. {
  7372. step = atoul(sep->arg[2]);
  7373. if (quest_id > 0 && step > 0)
  7374. {
  7375. if (player && player->IsPlayer() && quest_id > 0 && step > 0 && (player->player_quests.count(quest_id) > 0))
  7376. {
  7377. if (client)
  7378. {
  7379. client->AddPendingQuestUpdate(quest_id, step);
  7380. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been advanced one step.", quest->GetName());
  7381. LogWrite(COMMAND__INFO, 0, "GM Command", "%s advanced the quest %s one step", client->GetPlayer()->GetName(), quest->GetName());
  7382. }
  7383. }
  7384. }
  7385. else
  7386. {
  7387. client->Message(CHANNEL_COLOR_RED, "Quest ID and Step Number must be greater than 0!");
  7388. }
  7389. }
  7390. else
  7391. {
  7392. client->Message(CHANNEL_COLOR_RED, "Step Number must be a number!");
  7393. }
  7394. }
  7395. else
  7396. {
  7397. client->Message(CHANNEL_COLOR_RED, "Quest ID must be a number!");
  7398. }
  7399. }
  7400. else
  7401. {
  7402. Command_Modify(client);
  7403. }
  7404. }
  7405. else
  7406. {
  7407. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify quest [action] [quest id] [step number]");
  7408. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: list, completed, remove, advance");
  7409. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest list");
  7410. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest remove 156");
  7411. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest advance 50 1");
  7412. }
  7413. }
  7414. void Commands::Command_ModifySkill(Client* client, Seperator* sep)
  7415. {
  7416. PrintSep(sep, "COMMAND_MODIFY");
  7417. // need at least 2 args for a valid command
  7418. if( sep && sep->arg[1] )
  7419. {
  7420. if (strcmp(sep->arg[0], "add") == 0) {
  7421. const char* skill_name = sep->argplus[1];
  7422. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  7423. if (skill) {
  7424. Player* player = 0;
  7425. Client* to_client = 0;
  7426. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  7427. player = (Player*)client->GetPlayer()->GetTarget();
  7428. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  7429. }
  7430. else {
  7431. player = client->GetPlayer();
  7432. to_client = client;
  7433. }
  7434. if (player)
  7435. {
  7436. if (!player->GetSkills()->HasSkill(skill->skill_id))
  7437. {
  7438. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  7439. if (to_client == client) {
  7440. client->Message(CHANNEL_STATUS, "Added skill '%s'.", skill_name);
  7441. }
  7442. else {
  7443. client->Message(CHANNEL_STATUS, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  7444. to_client->Message(CHANNEL_STATUS, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  7445. }
  7446. }
  7447. else
  7448. client->Message(CHANNEL_STATUS, "%s already has the skill '%s'.", to_client == client ? "You" : player->GetName(), skill_name);
  7449. }
  7450. }
  7451. else
  7452. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  7453. }
  7454. else if (strcmp(sep->arg[0], "remove") == 0) {
  7455. const char* skill_name = sep->argplus[1];
  7456. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  7457. if (skill) {
  7458. Player* player = 0;
  7459. Client* to_client = 0;
  7460. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  7461. player = (Player*)client->GetPlayer()->GetTarget();
  7462. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  7463. }
  7464. else {
  7465. player = client->GetPlayer();
  7466. to_client = client;
  7467. }
  7468. if (player)
  7469. {
  7470. if (player->GetSkills()->HasSkill(skill->skill_id))
  7471. {
  7472. player->RemoveSkillFromDB(skill, true);
  7473. if (client == to_client) {
  7474. client->Message(CHANNEL_STATUS, "Removed skill '%s'.", skill_name);
  7475. }
  7476. else {
  7477. client->Message(CHANNEL_STATUS, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  7478. to_client->Message(CHANNEL_STATUS, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  7479. }
  7480. }
  7481. else {
  7482. if (client == to_client)
  7483. client->Message(CHANNEL_STATUS, "You do not have the skill '%s'.", skill_name);
  7484. else
  7485. client->Message(CHANNEL_STATUS, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  7486. }
  7487. }
  7488. }
  7489. else
  7490. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  7491. }
  7492. else if (strcmp(sep->arg[0], "set") == 0) {
  7493. if (!sep->IsNumber(2)) {
  7494. client->Message(CHANNEL_STATUS, "The last parameter must be a number.");
  7495. return;
  7496. }
  7497. const char* skill_name = sep->arg[1];
  7498. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  7499. if (skill) {
  7500. int16 val = atoi(sep->arg[2]);
  7501. Player* player = 0;
  7502. Client* to_client = 0;
  7503. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  7504. player = (Player*)client->GetPlayer()->GetTarget();
  7505. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  7506. }
  7507. else {
  7508. player = client->GetPlayer();
  7509. to_client = client;
  7510. }
  7511. if (player)
  7512. {
  7513. if (player->GetSkills()->HasSkill(skill->skill_id)) {
  7514. player->GetSkills()->SetSkill(skill->skill_id, val);
  7515. if (client != to_client)
  7516. client->Message(CHANNEL_STATUS, "You set %s's '%s' skill to %i.", player->GetName(), skill_name, val);
  7517. to_client->Message(CHANNEL_STATUS, "Your '%s' skill has been set to %i.", skill_name, val);
  7518. }
  7519. else {
  7520. client->Message(CHANNEL_STATUS, "Target does not have the skill '%s'.", skill_name);
  7521. }
  7522. }
  7523. }
  7524. else {
  7525. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  7526. }
  7527. }
  7528. else {
  7529. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  7530. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  7531. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  7532. }
  7533. }
  7534. else {
  7535. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  7536. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  7537. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  7538. }
  7539. }
  7540. void Commands::Command_ModifySpell(Client* client, Seperator* sep)
  7541. {
  7542. PrintSep(sep, "COMMAND_MODIFY");
  7543. // need at least 2 args for a valid command
  7544. if( sep && sep->arg[1] )
  7545. {
  7546. }
  7547. else
  7548. Command_Modify(client);
  7549. }
  7550. void Commands::Command_ModifyZone(Client* client, Seperator* sep)
  7551. {
  7552. PrintSep(sep, "COMMAND_MODIFY");
  7553. // need at least 2 args for a valid command
  7554. if( sep && sep->arg[1] )
  7555. {
  7556. }
  7557. else
  7558. Command_Modify(client);
  7559. }
  7560. /*
  7561. Function: Command_MOTD()
  7562. Purpose : Displays server MOTD
  7563. Params :
  7564. Dev : LethalEncounter
  7565. Example : /motd
  7566. */
  7567. void Commands::Command_MOTD(Client* client)
  7568. {
  7569. if (client)
  7570. ClientPacketFunctions::SendMOTD(client);
  7571. }
  7572. /*
  7573. Function: Command_Pet()
  7574. Purpose : Handle Pet {Command} commands
  7575. Params : attack, backoff, preserve_master, preserve_self, follow, stay, getlost
  7576. Dev :
  7577. Example : /pet preserve_master
  7578. */
  7579. void Commands::Command_Pet(Client* client, Seperator* sep)
  7580. {
  7581. PrintSep(sep, "COMMAND_PET");
  7582. //LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Pet Commands");
  7583. //client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7584. if (!sep || !sep->arg[0])
  7585. return; // should have sep->arg[0] filled
  7586. if (strcmp(sep->arg[0], "hide") == 0) {
  7587. // doing /pet hide will toggle the hide status on all the pets that can be hidden
  7588. Entity* pet = client->GetPlayer()->GetDeityPet();
  7589. if (pet) {
  7590. if (pet->IsPrivateSpawn())
  7591. client->GetPlayer()->HideDeityPet(false);
  7592. else
  7593. client->GetPlayer()->HideDeityPet(true);
  7594. }
  7595. pet = client->GetPlayer()->GetCosmeticPet();
  7596. if (pet) {
  7597. if (pet->IsPrivateSpawn())
  7598. client->GetPlayer()->HideCosmeticPet(false);
  7599. else
  7600. client->GetPlayer()->HideCosmeticPet(true);
  7601. }
  7602. return;
  7603. }
  7604. // below is for all combat pets
  7605. if (!client->GetPlayer()->HasPet()) {
  7606. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a pet.");
  7607. return;
  7608. }
  7609. if (strcmp(sep->arg[0], "stay") == 0) {
  7610. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to stay.");
  7611. client->GetPlayer()->GetInfoStruct()->set_pet_movement(1);
  7612. client->GetPlayer()->SetCharSheetChanged(true);
  7613. if (client->GetPlayer()->GetPet())
  7614. client->GetPlayer()->GetPet()->following = false;
  7615. if (client->GetPlayer()->GetCharmedPet())
  7616. client->GetPlayer()->GetCharmedPet()->following = false;
  7617. }
  7618. else if (strcmp(sep->arg[0], "follow") == 0) {
  7619. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to follow.");
  7620. client->GetPlayer()->GetInfoStruct()->set_pet_movement(2);
  7621. client->GetPlayer()->SetCharSheetChanged(true);
  7622. }
  7623. else if (strcmp(sep->arg[0], "preserve_master") == 0) {
  7624. if (client->GetPlayer()->GetInfoStruct()->get_pet_behavior() & 1) {
  7625. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect you.");
  7626. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()-1);
  7627. }
  7628. else {
  7629. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect you.");
  7630. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()+1);
  7631. }
  7632. client->GetPlayer()->SetCharSheetChanged(true);
  7633. }
  7634. else if (strcmp(sep->arg[0], "preserve_self") == 0) {
  7635. if (client->GetPlayer()->GetInfoStruct()->get_pet_behavior() & 2) {
  7636. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect itself.");
  7637. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()-2);
  7638. }
  7639. else {
  7640. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect itself.");
  7641. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()+2);
  7642. }
  7643. client->GetPlayer()->SetCharSheetChanged(true);
  7644. }
  7645. else if (strcmp(sep->arg[0], "backoff") == 0) {
  7646. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to back down.");
  7647. if (client->GetPlayer()->GetPet())
  7648. ((NPC*)client->GetPlayer()->GetPet())->Brain()->ClearHate();
  7649. if (client->GetPlayer()->GetCharmedPet())
  7650. ((NPC*)client->GetPlayer()->GetCharmedPet())->Brain()->ClearHate();
  7651. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(0);
  7652. client->GetPlayer()->SetCharSheetChanged(true);
  7653. }
  7654. else if (strcmp(sep->arg[0], "attack") == 0) {
  7655. if (client->GetPlayer()->HasTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  7656. if (client->GetPlayer()->AttackAllowed((Entity*)client->GetPlayer()->GetTarget())){
  7657. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to attack your target.");
  7658. if (client->GetPlayer()->GetPet())
  7659. client->GetPlayer()->GetPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  7660. if (client->GetPlayer()->GetCharmedPet())
  7661. client->GetPlayer()->GetCharmedPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  7662. }
  7663. else
  7664. client->Message(CHANNEL_COLOR_YELLOW, "You can not attack that.");
  7665. }
  7666. else
  7667. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a target.");
  7668. }
  7669. else if (strcmp(sep->arg[0], "getlost") == 0) {
  7670. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetPet());
  7671. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetCharmedPet());
  7672. client->Message(CHANNEL_COLOR_YELLOW, "You tell your pet to get lost.");
  7673. }
  7674. else
  7675. client->Message(CHANNEL_COLOR_YELLOW, "Unknown pet command.");
  7676. }
  7677. /*
  7678. Function: Command_PetName()
  7679. Purpose : Pet your name (???)
  7680. Params :
  7681. Dev :
  7682. Example :
  7683. */
  7684. void Commands::Command_PetName(Client* client, Seperator* sep)
  7685. {
  7686. if (sep && sep->arg[0]) {
  7687. const char* pet_name = sep->argplus[0];
  7688. client->SetPetName(pet_name);
  7689. }
  7690. else {
  7691. client->GetPlayer()->GetInfoStruct()->set_pet_name("");
  7692. }
  7693. }
  7694. /*
  7695. Function: Command_NamePet()
  7696. Purpose : Name your pet
  7697. Params :
  7698. Dev :
  7699. Example :
  7700. */
  7701. void Commands::Command_NamePet(Client* client, Seperator* sep)
  7702. {
  7703. PrintSep(sep, "COMMAND_NAME_PET");
  7704. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Name Pet Command");
  7705. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7706. }
  7707. /*
  7708. Function: Command_Rename()
  7709. Purpose : Renames existing pet
  7710. Params :
  7711. Dev :
  7712. Example :
  7713. */
  7714. void Commands::Command_Rename(Client* client, Seperator* sep)
  7715. {
  7716. PrintSep(sep, "COMMAND_RENAME");
  7717. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Rename Pet Command");
  7718. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7719. }
  7720. /*
  7721. Function: Command_ConfirmRename()
  7722. Purpose : Confirms renaming your pet
  7723. Params :
  7724. Dev :
  7725. Example :
  7726. */
  7727. void Commands::Command_ConfirmRename(Client* client, Seperator* sep)
  7728. {
  7729. PrintSep(sep, "COMMAND_CONFIRMRENAME");
  7730. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Confirm Rename Pet Command");
  7731. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7732. }
  7733. /*
  7734. Function: Command_PetOptions()
  7735. Purpose : Sets various pet options
  7736. Params :
  7737. Dev :
  7738. Example :
  7739. */
  7740. void Commands::Command_PetOptions(Client* client, Seperator* sep)
  7741. {
  7742. PrintSep(sep, "COMMAND_PETOPTIONS");
  7743. Player* player = client->GetPlayer();
  7744. Spawn* target = player->GetTarget();
  7745. if (!target)
  7746. return;
  7747. if (target == player->GetPet())
  7748. client->SendPetOptionsWindow(player->GetPet()->GetName());
  7749. else if (target == player->GetCharmedPet())
  7750. client->SendPetOptionsWindow(player->GetCharmedPet()->GetName());
  7751. else if (target == player->GetCosmeticPet())
  7752. client->SendPetOptionsWindow(player->GetCosmeticPet()->GetName(), 0);
  7753. else if (target == player->GetDeityPet())
  7754. client->SendPetOptionsWindow(player->GetDeityPet()->GetName(), 0);
  7755. }
  7756. /*
  7757. Function: Command_Random()
  7758. Purpose : Handles /random dice roll in-game
  7759. Params : 1-100
  7760. Dev : Scatman
  7761. Example : /randon 1 100
  7762. */
  7763. void Commands::Command_Random(Client* client, Seperator* sep)
  7764. {
  7765. char message[256] = {0};
  7766. if (sep)
  7767. {
  7768. if (sep->GetArgNumber() == 0 && sep->IsNumber(0))
  7769. 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])));
  7770. else if (sep->GetArgNumber() > 0 && sep->IsNumber(0) && sep->IsNumber(1))
  7771. 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])));
  7772. else
  7773. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  7774. }
  7775. else
  7776. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  7777. client->GetPlayer()->GetZone()->HandleChatMessage(0, 0, CHANNEL_EMOTE, message);
  7778. }
  7779. /*
  7780. Function: Command_Randomize()
  7781. Purpose : Sets randomize (appearance) values for NPCs
  7782. Params : Attrib Name
  7783. Dev : Scatman
  7784. Example : /randomize gender 1 -- will randomize the NPCs gender (male/female)
  7785. */
  7786. void Commands::Command_Randomize(Client* client, Seperator* sep)
  7787. {
  7788. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  7789. if (target)
  7790. {
  7791. if (target->IsNPC())
  7792. {
  7793. if (sep && sep->arg[0] && !sep->IsNumber(0))
  7794. {
  7795. const char* value = sep->arg[0];
  7796. if (strncasecmp(value, "show", strlen(value)) == 0)
  7797. {
  7798. client->DisplayRandomizeFeatures(target->GetRandomize());
  7799. }
  7800. else
  7801. {
  7802. if (sep->arg[1] && sep->IsNumber(1))
  7803. {
  7804. int8 option = atoi(sep->arg[1]);
  7805. if (option == 0 || option == 1)
  7806. {
  7807. int32 feature = 0;
  7808. char feature_text[32] = {0};
  7809. if (strncasecmp(value, "gender", strlen(value)) == 0) {
  7810. feature = RANDOMIZE_GENDER;
  7811. strncpy(feature_text, "gender", sizeof(feature_text) - 1);
  7812. }
  7813. else if (strncasecmp(value, "race", strlen(value)) == 0) {
  7814. feature = RANDOMIZE_RACE;
  7815. strncpy(feature_text, "race", sizeof(feature_text) - 1);
  7816. }
  7817. else if (strncasecmp(value, "model", strlen(value)) == 0) {
  7818. feature = RANDOMIZE_MODEL_TYPE;
  7819. strncpy(feature_text, "model", sizeof(feature_text) - 1);
  7820. }
  7821. else if (strncasecmp(value, "facial_hair", strlen(value)) == 0) {
  7822. feature = RANDOMIZE_FACIAL_HAIR_TYPE;
  7823. strncpy(feature_text, "facial hair", sizeof(feature_text) - 1);
  7824. }
  7825. else if (strncasecmp(value, "hair", strlen(value)) == 0) {
  7826. feature = RANDOMIZE_HAIR_TYPE;
  7827. strncpy(feature_text, "hair", sizeof(feature_text) - 1);
  7828. }
  7829. else if (strncasecmp(value, "wing", strlen(value)) == 0) {
  7830. feature = RANDOMIZE_WING_TYPE;
  7831. strncpy(feature_text, "wings", sizeof(feature_text) - 1);
  7832. }
  7833. else if (strncasecmp(value, "cheek", strlen(value)) == 0) {
  7834. feature = RANDOMIZE_CHEEK_TYPE;
  7835. strncpy(feature_text, "cheeks", sizeof(feature_text) - 1);
  7836. }
  7837. else if (strncasecmp(value, "chin", strlen(value)) == 0) {
  7838. feature = RANDOMIZE_CHIN_TYPE;
  7839. strncpy(feature_text, "chin", sizeof(feature_text) - 1);
  7840. }
  7841. else if (strncasecmp(value, "ear", strlen(value)) == 0) {
  7842. feature = RANDOMIZE_EAR_TYPE;
  7843. strncpy(feature_text, "ears", sizeof(feature_text) - 1);
  7844. }
  7845. else if (strncasecmp(value, "eye_brow", strlen(value)) == 0) {
  7846. feature = RANDOMIZE_EYE_BROW_TYPE;
  7847. strncpy(feature_text, "eye brows", sizeof(feature_text) - 1);
  7848. }
  7849. else if (strncasecmp(value, "eye", strlen(value)) == 0) {
  7850. feature = RANDOMIZE_EYE_TYPE;
  7851. strncpy(feature_text, "eyes", sizeof(feature_text) - 1);
  7852. }
  7853. else if (strncasecmp(value, "lip", strlen(value)) == 0) {
  7854. feature = RANDOMIZE_LIP_TYPE;
  7855. strncpy(feature_text, "lips", sizeof(feature_text) - 1);
  7856. }
  7857. else if (strncasecmp(value, "nose", strlen(value)) == 0) {
  7858. feature = RANDOMIZE_NOSE_TYPE;
  7859. strncpy(feature_text, "nose", sizeof(feature_text) - 1);
  7860. }
  7861. else if (strncasecmp(value, "eye_color", strlen(value)) == 0) {
  7862. feature = RANDOMIZE_EYE_COLOR;
  7863. strncpy(feature_text, "eye color", sizeof(feature_text) - 1);
  7864. }
  7865. else if (strncasecmp(value, "hair_color", strlen(value)) == 0) {
  7866. feature = RANDOMIZE_HAIR_TYPE_COLOR;
  7867. strncpy(feature_text, "hair color", sizeof(feature_text) - 1);
  7868. }
  7869. else if (strncasecmp(value, "hair_color1", strlen(value)) == 0) {
  7870. feature = RANDOMIZE_HAIR_COLOR1;
  7871. strncpy(feature_text, "hair color1", sizeof(feature_text) - 1);
  7872. }
  7873. else if (strncasecmp(value, "hair_color2", strlen(value)) == 0) {
  7874. feature = RANDOMIZE_HAIR_COLOR2;
  7875. strncpy(feature_text, "hair color2", sizeof(feature_text) - 1);
  7876. }
  7877. else if (strncasecmp(value, "hair_highlight", strlen(value)) == 0) {
  7878. feature = RANDOMIZE_HAIR_HIGHLIGHT;
  7879. strncpy(feature_text, "hair highlights", sizeof(feature_text) - 1);
  7880. }
  7881. else if (strncasecmp(value, "facial_hair_color", strlen(value)) == 0) {
  7882. feature = RANDOMIZE_HAIR_FACE_COLOR;
  7883. strncpy(feature_text, "facial hair color", sizeof(feature_text) - 1);
  7884. }
  7885. else if (strncasecmp(value, "facial_hair_color_highlight", strlen(value)) == 0) {
  7886. feature = RANDOMIZE_HAIR_FACE_HIGHLIGHT_COLOR;
  7887. strncpy(feature_text, "facial hair color highlights", sizeof(feature_text) - 1);
  7888. }
  7889. else if (strncasecmp(value, "hair_color_highlight", strlen(value)) == 0) {
  7890. feature = RANDOMIZE_HAIR_TYPE_HIGHLIGHT_COLOR;
  7891. strncpy(feature_text, "hair color highlights", sizeof(feature_text) - 1);
  7892. }
  7893. else if (strncasecmp(value, "skin_color", strlen(value)) == 0) {
  7894. feature = RANDOMIZE_SKIN_COLOR;
  7895. strncpy(feature_text, "skin color", sizeof(feature_text) - 1);
  7896. }
  7897. else if (strncasecmp(value, "wing_color1", strlen(value)) == 0) {
  7898. feature = RANDOMIZE_WING_COLOR1;
  7899. strncpy(feature_text, "wing color1", sizeof(feature_text) - 1);
  7900. }
  7901. else if (strncasecmp(value, "wing_color2", strlen(value)) == 0) {
  7902. feature = RANDOMIZE_WING_COLOR2;
  7903. strncpy(feature_text, "wing color2", sizeof(feature_text) - 1);
  7904. }
  7905. else {
  7906. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is not a valid feature to randomize.", value);
  7907. 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'.");
  7908. }
  7909. if (feature > 0) {
  7910. if (option == 1) {
  7911. if (target->GetRandomize() & feature)
  7912. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is already set to randomly generate their %s.", target->GetName(), feature_text);
  7913. else {
  7914. target->AddRandomize(feature);
  7915. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(feature);
  7916. database.UpdateRandomize(target->GetDatabaseID(), feature);
  7917. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will now generate their %s randomly.", target->GetName(), feature_text);
  7918. }
  7919. }
  7920. else {
  7921. if (target->GetRandomize() & feature) {
  7922. target->AddRandomize(-feature);
  7923. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(-feature);
  7924. database.UpdateRandomize(target->GetDatabaseID(), -feature);
  7925. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will no longer generate their %s randomly.", target->GetName(), feature_text);
  7926. }
  7927. else
  7928. client->Message(CHANNEL_COLOR_YELLOW, "'%s' already does not randomly generate their %s.", target->GetName(), feature_text);
  7929. }
  7930. }
  7931. }
  7932. else
  7933. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  7934. }
  7935. else
  7936. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  7937. }
  7938. }
  7939. else {
  7940. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /randomize [show | [feature [1|0]]");
  7941. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "'show' will display current configured features");
  7942. 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'.");
  7943. }
  7944. }
  7945. else
  7946. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "The target you wish to randomize must be an NPC.");
  7947. }
  7948. else
  7949. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select the target you wish to randomize.");
  7950. }
  7951. /*
  7952. Function: Command_ShowCloak()
  7953. Purpose : Character Settings combo box for Show Cloak
  7954. Params : true/false
  7955. Dev : John Adams
  7956. Example :
  7957. */
  7958. void Commands::Command_ShowCloak(Client* client, Seperator* sep)
  7959. {
  7960. Player* player = client->GetPlayer();
  7961. if (sep && sep->arg[0])
  7962. {
  7963. const char* value = sep->arg[0];
  7964. if (strncasecmp(value, "true", strlen(value)) == 0)
  7965. {
  7966. player->set_character_flag(CF_SHOW_CLOAK);
  7967. player->reset_character_flag(CF2_SHOW_RANGED);
  7968. }
  7969. else if (strncasecmp(value, "false", strlen(value)) == 0)
  7970. player->reset_character_flag(CF_SHOW_CLOAK);
  7971. else
  7972. {
  7973. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7974. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7975. }
  7976. }
  7977. }
  7978. /*
  7979. Function: Command_ShowHelm()
  7980. Purpose : Character Settings combo box for Show Helm
  7981. Params : true/false
  7982. Dev : John Adams
  7983. Example :
  7984. */
  7985. void Commands::Command_ShowHelm(Client* client, Seperator* sep)
  7986. {
  7987. Player* player = client->GetPlayer();
  7988. if(client->GetVersion() <= 546) {
  7989. return; // not allowed/supported
  7990. }
  7991. if (sep && sep->arg[0])
  7992. {
  7993. PrintSep(sep, "Command_ShowHelm");
  7994. const char* value = sep->arg[0];
  7995. if (strncasecmp(value, "true", strlen(value)) == 0)
  7996. {
  7997. player->toggle_character_flag(CF_HIDE_HELM);
  7998. player->toggle_character_flag(CF_HIDE_HOOD);
  7999. }
  8000. else if (strncasecmp(value, "false", strlen(value)) == 0)
  8001. player->toggle_character_flag(CF_HIDE_HELM);
  8002. else
  8003. {
  8004. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8005. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8006. }
  8007. }
  8008. }
  8009. /*
  8010. Function: Command_ShowHood()
  8011. Purpose : Character Settings combo box for Show Hood
  8012. Params : true/false
  8013. Dev : John Adams
  8014. Example :
  8015. */
  8016. void Commands::Command_ShowHood(Client* client, Seperator* sep)
  8017. {
  8018. Player* player = client->GetPlayer();
  8019. if (sep && sep->arg[0])
  8020. {
  8021. PrintSep(sep, "Command_ShowHood");
  8022. const char* value = sep->arg[0];
  8023. if (strncasecmp(value, "true", strlen(value)) == 0)
  8024. {
  8025. player->toggle_character_flag(CF_HIDE_HOOD);
  8026. if(client->GetVersion() > 546) { // no hide helm support in DoF
  8027. player->toggle_character_flag(CF_HIDE_HELM);
  8028. }
  8029. }
  8030. else if (strncasecmp(value, "false", strlen(value)) == 0) {
  8031. player->toggle_character_flag(CF_HIDE_HOOD);
  8032. }
  8033. else
  8034. {
  8035. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8036. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8037. }
  8038. }
  8039. }
  8040. /*
  8041. Function: Command_ShowHoodHelm()
  8042. Purpose : Character Settings combo box for Show Helm or Hood
  8043. Params : true/false
  8044. Dev : John Adams
  8045. Example :
  8046. */
  8047. void Commands::Command_ShowHoodHelm(Client* client, Seperator* sep)
  8048. {
  8049. Player* player = client->GetPlayer();
  8050. if(client->GetVersion() <= 546) {
  8051. return; // not allowed/supported
  8052. }
  8053. if (sep && sep->arg[0])
  8054. {
  8055. PrintSep(sep, "Command_ShowHoodHelm");
  8056. const char* value = sep->arg[0];
  8057. if (strncasecmp(value, "true", strlen(value)) == 0)
  8058. {
  8059. player->toggle_character_flag(CF_HIDE_HOOD);
  8060. player->toggle_character_flag(CF_HIDE_HELM);
  8061. }
  8062. else if (strncasecmp(value, "false", strlen(value)) == 0)
  8063. {
  8064. // don't think we ever wind up in here...
  8065. player->toggle_character_flag(CF_HIDE_HOOD);
  8066. player->toggle_character_flag(CF_HIDE_HELM);
  8067. }
  8068. else
  8069. {
  8070. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8071. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8072. }
  8073. }
  8074. }
  8075. /*
  8076. Function: Command_ShowRanged()
  8077. Purpose : Character Settings combo box for Show Ranged weapon
  8078. Params : true/false
  8079. Dev : John Adams
  8080. Example :
  8081. */
  8082. void Commands::Command_ShowRanged(Client* client, Seperator* sep)
  8083. {
  8084. Player* player = client->GetPlayer();
  8085. if (sep && sep->arg[0])
  8086. {
  8087. const char* value = sep->arg[0];
  8088. if (strncasecmp(value, "true", strlen(value)) == 0)
  8089. {
  8090. player->set_character_flag(CF2_SHOW_RANGED);
  8091. player->reset_character_flag(CF_SHOW_CLOAK);
  8092. }
  8093. else if (strncasecmp(value, "false", strlen(value)) == 0)
  8094. player->reset_character_flag(CF2_SHOW_RANGED);
  8095. else
  8096. {
  8097. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8098. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8099. }
  8100. }
  8101. }
  8102. /*
  8103. Function:
  8104. Purpose :
  8105. Params :
  8106. Dev :
  8107. Example :
  8108. */
  8109. void Commands::Command_Skills(Client* client, Seperator* sep, int handler)
  8110. {
  8111. Player* player = 0;
  8112. Client* to_client = 0;
  8113. if(client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  8114. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  8115. switch(handler)
  8116. {
  8117. case COMMAND_SKILL:
  8118. {
  8119. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill [add|remove|list] [skill name]");
  8120. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to add/remove skills for that player.");
  8121. break;
  8122. }
  8123. case COMMAND_SKILL_ADD:
  8124. {
  8125. if (sep && sep->arg[0])
  8126. {
  8127. const char* skill_name = sep->argplus[0];
  8128. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  8129. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // add skill to your target, if target is not you
  8130. {
  8131. player = to_client->GetPlayer();
  8132. if (player)
  8133. {
  8134. if (!player->GetSkills()->HasSkill(skill->skill_id))
  8135. {
  8136. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  8137. client->Message(CHANNEL_COLOR_YELLOW, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  8138. to_client->Message(CHANNEL_COLOR_YELLOW, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  8139. }
  8140. else
  8141. client->Message(CHANNEL_COLOR_YELLOW, "%s already has the skill '%s'.", player->GetName(), skill_name);
  8142. }
  8143. }
  8144. else if (skill) // add skill to yourself
  8145. {
  8146. player = client->GetPlayer();
  8147. if (player)
  8148. {
  8149. if (!player->GetSkills()->HasSkill(skill->skill_id))
  8150. {
  8151. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  8152. client->Message(CHANNEL_COLOR_YELLOW, "Added skill '%s'.", skill_name);
  8153. }
  8154. else
  8155. client->Message(CHANNEL_COLOR_YELLOW, "You already have the skill '%s'.", skill_name);
  8156. }
  8157. }
  8158. else
  8159. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  8160. }
  8161. else
  8162. {
  8163. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill add [skill name]");
  8164. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  8165. }
  8166. break;
  8167. }
  8168. case COMMAND_SKILL_REMOVE:
  8169. {
  8170. if (sep && sep->arg[0])
  8171. {
  8172. const char* skill_name = sep->argplus[0];
  8173. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  8174. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // remove skill from your target, if target is not you
  8175. {
  8176. player = to_client->GetPlayer();
  8177. if (player)
  8178. {
  8179. if (player->GetSkills()->HasSkill(skill->skill_id))
  8180. {
  8181. player->RemoveSkillFromDB(skill, true);
  8182. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  8183. to_client->Message(CHANNEL_COLOR_YELLOW, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  8184. }
  8185. else
  8186. client->Message(CHANNEL_COLOR_YELLOW, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  8187. }
  8188. }
  8189. else if(skill) // remove skill from yourself
  8190. {
  8191. Player* player = client->GetPlayer();
  8192. if (player)
  8193. {
  8194. if (player->GetSkills()->HasSkill(skill->skill_id))
  8195. {
  8196. player->RemoveSkillFromDB(skill, true);
  8197. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s'.", skill_name);
  8198. }
  8199. else
  8200. client->Message(CHANNEL_COLOR_YELLOW, "You do not have the skill '%s'.", skill_name);
  8201. }
  8202. }
  8203. else
  8204. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  8205. }
  8206. else
  8207. {
  8208. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill remove [skill name]");
  8209. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  8210. }
  8211. break;
  8212. }
  8213. case COMMAND_SKILL_LIST:
  8214. {
  8215. if (sep && sep->arg[0])
  8216. {
  8217. const char* skill_name = sep->argplus[0];
  8218. client->Message(CHANNEL_COLOR_YELLOW, "Listing skills like '%s':", skill_name);
  8219. map<int32, Skill*>* skills = master_skill_list.GetAllSkills();
  8220. map<int32, Skill*>::iterator itr;
  8221. if (skills && skills->size() > 0)
  8222. {
  8223. for (itr = skills->begin(); itr != skills->end(); itr++)
  8224. {
  8225. Skill* skill = itr->second;
  8226. string current_skill_name = ::ToLower(string(skill->name.data.c_str()));
  8227. if (current_skill_name.find(::ToLower(string(skill_name))) < 0xFFFFFFFF)
  8228. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", skill->name.data.c_str(), skill->skill_id);
  8229. }
  8230. }
  8231. }
  8232. else
  8233. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill list [skill name]");
  8234. break;
  8235. }
  8236. }
  8237. }
  8238. /*
  8239. Function: Command_SpawnTemplate()
  8240. Purpose : Create or Use defined Spawn Templates
  8241. Params : create, save, rempve, list
  8242. Dev : John Adams
  8243. Example : /spawn template create "Test"
  8244. */
  8245. void Commands::Command_SpawnTemplate(Client* client, Seperator* sep)
  8246. {
  8247. if (sep == NULL || sep->arg[0] == NULL)
  8248. {
  8249. 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.");
  8250. return;
  8251. }
  8252. // got params, continue
  8253. const char * template_cmd = sep->arg[0];
  8254. if (strncasecmp(template_cmd, "list", strlen(template_cmd)) == 0)
  8255. {
  8256. if (!sep->IsSet(1))
  8257. {
  8258. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /spawn template list [name|location_id]");
  8259. 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.");
  8260. return;
  8261. }
  8262. map<int32, string>* template_names = 0;
  8263. if (sep->IsNumber(1))
  8264. {
  8265. int32 location_id = 0;
  8266. location_id = atoi(sep->arg[1]);
  8267. template_names = database.GetSpawnTemplateListByID(location_id);
  8268. }
  8269. else
  8270. {
  8271. const char* name = 0;
  8272. name = sep->argplus[1];
  8273. template_names = database.GetSpawnTemplateListByName(name);
  8274. }
  8275. if(!template_names)
  8276. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No templates found.");
  8277. else
  8278. {
  8279. map<int32, string>::iterator itr;
  8280. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  8281. for(itr = template_names->begin(); itr != template_names->end(); itr++)
  8282. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  8283. safe_delete(template_names);
  8284. }
  8285. }
  8286. else if (strncasecmp(template_cmd, "save", strlen(template_cmd)) == 0)
  8287. {
  8288. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  8289. if ( target && (target->IsNPC() || target->IsObject() || target->IsSign() || target->IsWidget() || target->IsGroundSpawn()) )
  8290. {
  8291. if (sep && sep->arg[1][0] && !sep->IsNumber(1))
  8292. {
  8293. // first, lookup to see if template name already exists
  8294. const char* name = 0;
  8295. name = sep->argplus[1];
  8296. map<int32, string>* template_names = database.GetSpawnTemplateListByName(name);
  8297. if(!template_names)
  8298. {
  8299. int32 new_template_id = database.SaveSpawnTemplate(target->GetSpawnLocationID(), name);
  8300. if( new_template_id > 0 )
  8301. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template '%s' added for spawn '%s' (%u) as TemplateID: %u", name, target->GetName(), target->GetSpawnLocationID(), new_template_id);
  8302. else
  8303. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' for spawn '%s' (%u).", name, target->GetName(), target->GetSpawnLocationID());
  8304. }
  8305. else
  8306. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' - Already exists!", name);
  8307. }
  8308. else
  8309. client->Message(CHANNEL_COLOR_RED, "ERROR: Saving a new spawn template requires a valid template name!");
  8310. }
  8311. else
  8312. client->Message(CHANNEL_COLOR_RED, "ERROR: You must target the spawn you wish to save as a template!");
  8313. }
  8314. else if (strncasecmp(template_cmd, "remove", strlen(template_cmd)) == 0)
  8315. {
  8316. if (sep && sep->arg[1][0] && sep->IsNumber(1))
  8317. {
  8318. int32 template_id = 0;
  8319. template_id = atoi(sep->arg[1]);
  8320. if (database.RemoveSpawnTemplate(template_id))
  8321. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template ID: %u successfully removed.", template_id);
  8322. else
  8323. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to remove spawn template ID: %u", template_id);
  8324. }
  8325. else
  8326. client->Message(CHANNEL_COLOR_RED, "ERROR: Removing a spawn template requires a valid template ID!");
  8327. }
  8328. // Renamed create to spawn
  8329. else if (strncasecmp(template_cmd, "spawn", strlen(template_cmd)) == 0)
  8330. {
  8331. if (sep && sep->arg[1][0])
  8332. {
  8333. int32 new_location = 0;
  8334. if (sep->IsNumber(1))
  8335. {
  8336. int32 template_id = 0;
  8337. template_id = atoi(sep->arg[1]);
  8338. new_location = database.CreateSpawnFromTemplateByID(client, template_id);
  8339. if( new_location > 0 )
  8340. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template ID: %u", new_location, template_id);
  8341. else
  8342. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template ID: %u", template_id);
  8343. }
  8344. else
  8345. {
  8346. const char* name = 0;
  8347. name = sep->argplus[1];
  8348. new_location = database.CreateSpawnFromTemplateByName(client, name);
  8349. if( new_location > 0 )
  8350. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template: '%s'", new_location, name);
  8351. else
  8352. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template: '%s'", name);
  8353. }
  8354. }
  8355. else
  8356. client->Message(CHANNEL_COLOR_RED, "ERROR: Spawning a new spawn location requires a valid template name or ID!");
  8357. }
  8358. else
  8359. client->Message(CHANNEL_COLOR_RED, "ERROR: Unknown /spawn template command.");
  8360. }
  8361. void Commands::Command_Speed(Client* client, Seperator* sep) {
  8362. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  8363. float new_speed = atof(sep->arg[0]);
  8364. if (new_speed > 0.0f)
  8365. {
  8366. client->GetPlayer()->SetSpeed(new_speed, true);
  8367. client->GetPlayer()->SetCharSheetChanged(true);
  8368. database.insertCharacterProperty(client, CHAR_PROPERTY_SPEED, sep->arg[0]);
  8369. client->Message(CHANNEL_STATUS, "Setting speed to %.2f.", new_speed);
  8370. }
  8371. else
  8372. client->Message(CHANNEL_STATUS, "Invalid speed provided %s.", sep->arg[0]);
  8373. }
  8374. else{
  8375. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /speed {new speed value}");
  8376. }
  8377. }
  8378. /*
  8379. Function: Command_StationMarketPlace()
  8380. Purpose : just trying to eat the console spam for now
  8381. Params :
  8382. Dev : John
  8383. */
  8384. void Commands::Command_StationMarketPlace(Client* client, Seperator* sep)
  8385. {
  8386. PrintSep(sep, "COMMAND_SMP");
  8387. // This will reduce the spam from once every 10 sec to once every 30 sec,
  8388. // can't seem to reduce it any more get rid of it completely...
  8389. if (sep && strcmp(sep->arg[0], "gkw") == 0) {
  8390. PacketStruct* packet = configReader.getStruct("WS_MarketFundsUpdate", client->GetVersion());
  8391. if (packet) {
  8392. packet->setDataByName("account_id", client->GetAccountID());
  8393. packet->setDataByName("character_id", client->GetCharacterID());
  8394. packet->setDataByName("unknown1", 1, 5);
  8395. packet->setDataByName("unknown1", 26, 6);
  8396. packet->setDataByName("unknown2", 0xFFFFFFFF);
  8397. packet->setDataByName("unknown3", 248, 1);
  8398. client->QueuePacket(packet->serialize());
  8399. }
  8400. safe_delete(packet);
  8401. }
  8402. }
  8403. /*
  8404. Function: Command_StopDrinking()
  8405. Purpose : Stops player from auto-consuming drink
  8406. Params :
  8407. Dev : Zcoretri
  8408. Example : /stopdrinking
  8409. */
  8410. void Commands::Command_StopDrinking(Client* client)
  8411. {
  8412. client->GetPlayer()->reset_character_flag(CF_DRINK_AUTO_CONSUME);
  8413. client->Message(CHANNEL_COLOR_YELLOW,"You stop drinking your current drink.");
  8414. }
  8415. /*
  8416. Function: Command_StopEating()
  8417. Purpose : Stops player from auto-consuming food
  8418. Params :
  8419. Dev : Zcoretri
  8420. Example : /stopeating
  8421. */
  8422. void Commands::Command_StopEating(Client* client)
  8423. {
  8424. client->GetPlayer()->reset_character_flag(CF_FOOD_AUTO_CONSUME);
  8425. client->Message(CHANNEL_COLOR_YELLOW,"You stop eating your current food.");
  8426. }
  8427. /*
  8428. Function: Command_Title()
  8429. Purpose : Help for /title command
  8430. Params : n/a
  8431. Dev : Zcoretri
  8432. Example : /title
  8433. */
  8434. void Commands::Command_Title(Client* client)
  8435. {
  8436. client->Message(CHANNEL_COLOR_YELLOW, "Available subcommands: list, setprefix <index>, setsuffix <index>, fix");
  8437. }
  8438. /*
  8439. Function: Command_TitleList()
  8440. Purpose : List available titles for player
  8441. Params : n/a
  8442. Dev : Zcoretri
  8443. Example : /title list
  8444. */
  8445. void Commands::Command_TitleList(Client* client)
  8446. {
  8447. // must call release read lock before leaving function on GetPlayerTitles
  8448. vector<Title*>* titles = client->GetPlayer()->GetPlayerTitles()->GetAllTitles();
  8449. vector<Title*>::iterator itr;
  8450. Title* title;
  8451. sint32 i = 0;
  8452. client->Message(CHANNEL_NARRATIVE, "Listing available titles:");
  8453. for(itr = titles->begin(); itr != titles->end(); itr++)
  8454. {
  8455. title = *itr;
  8456. client->Message(CHANNEL_NARRATIVE, "%i: type=[%s] title=[%s]", i, title->GetPrefix() ? "Prefix":"Suffix", title->GetName());
  8457. i++;
  8458. }
  8459. client->GetPlayer()->GetPlayerTitles()->ReleaseReadLock();
  8460. }
  8461. /*
  8462. Function: Command_TitleSetPrefix()
  8463. Purpose : Set Prefix title for player
  8464. Params : Title ID
  8465. Dev : Zcoretri
  8466. Example : /title setprefix 1
  8467. */
  8468. void Commands::Command_TitleSetPrefix(Client* client, Seperator* sep)
  8469. {
  8470. if (sep && sep->arg[0] && sep->IsNumber(0))
  8471. {
  8472. sint32 index = atoul(sep->arg[0]);
  8473. if(index > -1)
  8474. {
  8475. Title* title = client->GetPlayer()->GetPlayerTitles()->GetTitle(index);
  8476. if(!title)
  8477. {
  8478. client->Message(CHANNEL_COLOR_RED, "Missing index %i to set title", index);
  8479. return;
  8480. }
  8481. else if(!title->GetPrefix())
  8482. {
  8483. client->Message(CHANNEL_COLOR_RED, "%s is not a prefix.", title->GetName());
  8484. return;
  8485. }
  8486. }
  8487. else // make sure client doesn't pass some bogus negative index
  8488. index = -1;
  8489. database.SaveCharPrefixIndex(index, client->GetCharacterID());
  8490. client->SendTitleUpdate();
  8491. }
  8492. }
  8493. /*
  8494. Function: Command_TitleSetSuffix()
  8495. Purpose : Set Suffix title for player
  8496. Params : Title ID
  8497. Dev : Zcoretri
  8498. Example : /title setsuffix 1
  8499. */
  8500. void Commands::Command_TitleSetSuffix(Client* client, Seperator* sep)
  8501. {
  8502. if (sep && sep->arg[0] && sep->IsNumber(0))
  8503. {
  8504. sint32 index = atoul(sep->arg[0]);
  8505. if(index > -1)
  8506. {
  8507. Title* title = client->GetPlayer()->GetPlayerTitles()->GetTitle(index);
  8508. if(!title)
  8509. {
  8510. client->Message(CHANNEL_COLOR_RED, "Missing index %i to set title", index);
  8511. return;
  8512. }
  8513. else if(title->GetPrefix())
  8514. {
  8515. client->Message(CHANNEL_COLOR_RED, "%s is not a suffix.", title->GetName());
  8516. return;
  8517. }
  8518. }
  8519. else // make sure client doesn't pass some bogus negative index
  8520. index = -1;
  8521. database.SaveCharSuffixIndex(index, client->GetCharacterID());
  8522. client->SendTitleUpdate();
  8523. }
  8524. }
  8525. /*
  8526. Function: Command_TitleFix()
  8527. Purpose : Fix title for player (???)
  8528. Params :
  8529. Dev : Zcoretri
  8530. Example :
  8531. */
  8532. void Commands::Command_TitleFix(Client* client, Seperator* sep)
  8533. {
  8534. PrintSep(sep, "COMMAND_TITLE_FIX");
  8535. LogWrite(MISC__TODO, 1, "Titles", "TODO-Command: TITLE_FIX");
  8536. }
  8537. /*
  8538. Function: Command_Toggle_Anonymous()
  8539. Purpose : Toggles player Anonymous
  8540. Params :
  8541. Dev : paulgh
  8542. Example : /anon
  8543. */
  8544. void Commands::Command_Toggle_Anonymous(Client* client)
  8545. {
  8546. Player* player = client->GetPlayer();
  8547. player->toggle_character_flag(CF_ANONYMOUS);
  8548. client->Message(CHANNEL_COLOR_YELLOW,"You are %s anonymous.", player->get_character_flag(CF_ANONYMOUS)?"now":"no longer");
  8549. if (player->get_character_flag(CF_ANONYMOUS))
  8550. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ANONYMOUS);
  8551. else
  8552. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ANONYMOUS);
  8553. }
  8554. /*
  8555. Function: Command_Toggle_AutoConsume()
  8556. Purpose : Toggles player food/drink auto consume
  8557. Params : unknown
  8558. Dev : paulgh
  8559. Example : /set_auto_consume
  8560. */
  8561. void Commands::Command_Toggle_AutoConsume(Client* client, Seperator* sep)
  8562. {
  8563. Player* player = client->GetPlayer();
  8564. if (sep && sep->arg[0])
  8565. PrintSep(sep, "COMMAND_SET_AUTO_CONSUME");
  8566. if (sep && sep->arg[0] && sep->IsNumber(0))
  8567. {
  8568. int8 slot = atoi(sep->arg[0]);
  8569. int8 flag = atoi(sep->arg[1]);
  8570. if (client->GetVersion() <= 283) {
  8571. slot += 4;
  8572. }
  8573. else if (client->GetVersion() <= 546) {
  8574. slot += 2;
  8575. }
  8576. if (slot == EQ2_FOOD_SLOT)
  8577. {
  8578. player->toggle_character_flag(CF_FOOD_AUTO_CONSUME);
  8579. player->SetCharSheetChanged(true);
  8580. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  8581. if (flag == 1)
  8582. client->Message(CHANNEL_NARRATIVE, "You decide to eat immediately whenever you become hungry.");
  8583. else
  8584. {
  8585. client->Message(CHANNEL_NARRATIVE, "You decide to ignore the hunger.");
  8586. return;
  8587. }
  8588. }
  8589. else
  8590. {
  8591. player->toggle_character_flag(CF_DRINK_AUTO_CONSUME);
  8592. player->SetCharSheetChanged(true);
  8593. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  8594. if (flag == 1)
  8595. client->Message(CHANNEL_NARRATIVE, "You decide to drink immediately whenever you become thirsty.");
  8596. else
  8597. {
  8598. client->Message(CHANNEL_NARRATIVE, "You decide to ignore the thirst.");
  8599. return;
  8600. }
  8601. }
  8602. if(!client->CheckConsumptionAllowed(slot, false))
  8603. return;
  8604. Item* item = player->GetEquipmentList()->GetItem(slot);
  8605. if(item)
  8606. client->ConsumeFoodDrink(item, slot);
  8607. }
  8608. }
  8609. /*
  8610. Function: Command_Toggle_BonusXP()
  8611. Purpose : Toggles player Bonus XP
  8612. Params :
  8613. Dev : John Adams
  8614. Example : /disable_char_bonus_exp
  8615. */
  8616. void Commands::Command_Toggle_BonusXP(Client* client)
  8617. {
  8618. Player* player = client->GetPlayer();
  8619. player->toggle_character_flag(CF2_CHARACTER_BONUS_EXPERIENCE_ENABLED);
  8620. player->SetCharSheetChanged(true);
  8621. }
  8622. /*
  8623. Function: Command_Toggle_CombatXP()
  8624. Purpose : Toggles player Adventure XP
  8625. Params :
  8626. Dev : John Adams
  8627. Example : /disable_combat_exp
  8628. */
  8629. void Commands::Command_Toggle_CombatXP(Client* client)
  8630. {
  8631. Player* player = client->GetPlayer();
  8632. player->toggle_character_flag(CF_COMBAT_EXPERIENCE_ENABLED);
  8633. player->SetCharSheetChanged(true);
  8634. }
  8635. /*
  8636. Function: Command_Toggle_GMHide()
  8637. Purpose : Toggles hiding player GM status
  8638. Params :
  8639. Dev : Scatman
  8640. Example : /gm_hide
  8641. */
  8642. void Commands::Command_Toggle_GMHide(Client* client)
  8643. {
  8644. Player* player = client->GetPlayer();
  8645. player->toggle_character_flag(CF_HIDE_STATUS);
  8646. client->Message(CHANNEL_COLOR_YELLOW,"You are %s hiding your GM status.", player->get_character_flag(CF_HIDE_STATUS)?"now":"no longer");
  8647. }
  8648. /*
  8649. Function: Command_Toggle_GMVanish()
  8650. Purpose : Toggles hiding GM players from /who searches
  8651. Params :
  8652. Dev : Scatman
  8653. Example : /gm_vanish
  8654. */
  8655. void Commands::Command_Toggle_GMVanish(Client* client)
  8656. {
  8657. Player* player = client->GetPlayer();
  8658. player->toggle_character_flag(CF_GM_HIDDEN);
  8659. client->Message(CHANNEL_COLOR_YELLOW,"You are %s invisible to who queries.", player->get_character_flag(CF_GM_HIDDEN)?"now":"no longer");
  8660. }
  8661. /*
  8662. Function: Command_Toggle_Illusions()
  8663. Purpose : Toggles player illusion form
  8664. Params : not sure sep is needed, testing
  8665. Dev : paulgh
  8666. Example : /hide_illusions
  8667. */
  8668. void Commands::Command_Toggle_Illusions(Client* client, Seperator* sep)
  8669. {
  8670. if (sep && sep->arg[0])
  8671. PrintSep(sep, "COMMAND_TOGGLE_ILLUSIONS");
  8672. client->GetPlayer()->toggle_character_flag(CF_SHOW_ILLUSION);
  8673. }
  8674. /*
  8675. Function: Command_Toggle_LFG()
  8676. Purpose : Toggles player LFG Flag
  8677. Params :
  8678. Dev : paulgh
  8679. Example : /lfg
  8680. */
  8681. void Commands::Command_Toggle_LFG(Client* client)
  8682. {
  8683. Player* player = client->GetPlayer();
  8684. player->toggle_character_flag(CF_LFG);
  8685. client->Message(CHANNEL_COLOR_YELLOW,"You are %s LFG.", player->get_character_flag(CF_LFG)?"now":"no longer");
  8686. if (player->get_character_flag(CF_LFG))
  8687. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFG);
  8688. else
  8689. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFG);
  8690. }
  8691. /*
  8692. Function: Command_Toggle_LFW()
  8693. Purpose : Toggles player LFW Flag
  8694. Params :
  8695. Dev : paulgh
  8696. Example : /lfw
  8697. */
  8698. void Commands::Command_Toggle_LFW(Client* client)
  8699. {
  8700. Player* player = client->GetPlayer();
  8701. player->toggle_character_flag(CF_LFW);
  8702. client->Message(CHANNEL_COLOR_YELLOW,"You %s looking for work.", player->get_character_flag(CF_LFW)?"let others know you are":"stop");
  8703. if (player->get_character_flag(CF_LFW))
  8704. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFW);
  8705. else
  8706. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFW);
  8707. }
  8708. /*
  8709. Function: Command_Toggle_QuestXP()
  8710. Purpose : Toggles player Quest XP
  8711. Params :
  8712. Dev : John Adams
  8713. Example : /disable_quest_exp
  8714. */
  8715. void Commands::Command_Toggle_QuestXP(Client* client)
  8716. {
  8717. Player* player = client->GetPlayer();
  8718. player->toggle_character_flag(CF_QUEST_EXPERIENCE_ENABLED);
  8719. player->SetCharSheetChanged(true);
  8720. }
  8721. /*
  8722. Function: Command_Toggle_Roleplaying()
  8723. Purpose : Toggles player Roleplaying flag
  8724. Params :
  8725. Dev : paulgh
  8726. Example : /role
  8727. */
  8728. void Commands::Command_Toggle_Roleplaying(Client* client)
  8729. {
  8730. Player* player = client->GetPlayer();
  8731. player->toggle_character_flag(CF_ROLEPLAYING);
  8732. client->Message(CHANNEL_COLOR_YELLOW,"You are %s roleplaying.", player->get_character_flag(CF_ROLEPLAYING)?"now":"no longer");
  8733. if (player->get_character_flag(CF_ROLEPLAYING))
  8734. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ROLEPLAYING);
  8735. else
  8736. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ROLEPLAYING);
  8737. }
  8738. void Commands::Command_Toggle_Duels(Client* client)
  8739. {
  8740. Player* player = client->GetPlayer();
  8741. player->toggle_character_flag(CF_ALLOW_DUEL_INVITES);
  8742. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting duel invites.", player->get_character_flag(CF_ALLOW_DUEL_INVITES)?"now":"no longer");
  8743. }
  8744. void Commands::Command_Toggle_Trades(Client* client)
  8745. {
  8746. Player* player = client->GetPlayer();
  8747. player->toggle_character_flag(CF_ALLOW_TRADE_INVITES);
  8748. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting trade invites.", player->get_character_flag(CF_ALLOW_TRADE_INVITES)?"now":"no longer");
  8749. }
  8750. void Commands::Command_Toggle_Guilds(Client* client)
  8751. {
  8752. Player* player = client->GetPlayer();
  8753. player->toggle_character_flag(CF_ALLOW_GUILD_INVITES);
  8754. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting guild invites.", player->get_character_flag(CF_ALLOW_GUILD_INVITES)?"now":"no longer");
  8755. }
  8756. void Commands::Command_Toggle_Groups(Client* client)
  8757. {
  8758. Player* player = client->GetPlayer();
  8759. player->toggle_character_flag(CF_ALLOW_GROUP_INVITES);
  8760. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting group invites.", player->get_character_flag(CF_ALLOW_GROUP_INVITES)?"now":"no longer");
  8761. }
  8762. void Commands::Command_Toggle_Raids(Client* client)
  8763. {
  8764. Player* player = client->GetPlayer();
  8765. player->toggle_character_flag(CF_ALLOW_RAID_INVITES);
  8766. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting raid invites.", player->get_character_flag(CF_ALLOW_RAID_INVITES)?"now":"no longer");
  8767. }
  8768. void Commands::Command_Toggle_LON(Client* client)
  8769. {
  8770. Player* player = client->GetPlayer();
  8771. player->toggle_character_flag(CF2_ALLOW_LON_INVITES);
  8772. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting LoN invites.", player->get_character_flag(CF2_ALLOW_LON_INVITES)?"now":"no longer");
  8773. }
  8774. void Commands::Command_Toggle_VoiceChat(Client* client)
  8775. {
  8776. Player* player = client->GetPlayer();
  8777. player->toggle_character_flag(CF2_ALLOW_VOICE_INVITES);
  8778. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting voice chat invites.", player->get_character_flag(CF2_ALLOW_VOICE_INVITES)?"now":"no longer");
  8779. }
  8780. /*
  8781. Function: Command_TradeStart()
  8782. Purpose : Starts item/coin trade between players
  8783. Params :
  8784. Dev :
  8785. Example :
  8786. */
  8787. #include "../Trade.h"
  8788. void Commands::Command_TradeStart(Client* client, Seperator* sep)
  8789. {
  8790. PrintSep(sep, "COMMAND_START_TRADE");
  8791. Entity* trader = client->GetPlayer();
  8792. Entity* trader2 = 0;
  8793. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  8794. Spawn* spawn = client->GetPlayer()->GetSpawnWithPlayerID(atoi(sep->arg[0]));
  8795. if (spawn) {
  8796. if (spawn->IsEntity())
  8797. trader2 = (Entity*)spawn;
  8798. }
  8799. }
  8800. else if (client->GetPlayer()->GetTarget()) {
  8801. if (client->GetPlayer()->GetTarget()->IsEntity())
  8802. trader2 = (Entity*)client->GetPlayer()->GetTarget();
  8803. }
  8804. // can only trade with player or bots
  8805. if (trader && trader2) {
  8806. if (trader == trader2) {
  8807. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade with yourself.");
  8808. }
  8809. else if (trader2->IsPlayer() || trader2->IsBot()) {
  8810. LogWrite(PLAYER__ERROR, 0, "Trade", "creating trade");
  8811. if (trader->trade)
  8812. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are already trading.");
  8813. else if (trader2->trade)
  8814. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is already trading.");
  8815. else {
  8816. Trade* trade = new Trade(trader, trader2);
  8817. trader->trade = trade;
  8818. trader2->trade = trade;
  8819. }
  8820. }
  8821. else {
  8822. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can only trade with another player or a bot.");
  8823. }
  8824. }
  8825. else
  8826. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to find target");
  8827. }
  8828. /*
  8829. Function: Command_Track()
  8830. Purpose : Starts/Stops Tracking for a player
  8831. Params :
  8832. Dev : Scatman
  8833. Example : /track
  8834. */
  8835. void Commands::Command_Track(Client* client)
  8836. {
  8837. if (!client->GetPlayer()->GetIsTracking())
  8838. client->GetPlayer()->GetZone()->AddPlayerTracking(client->GetPlayer());
  8839. else
  8840. client->GetPlayer()->GetZone()->RemovePlayerTracking(client->GetPlayer(), TRACKING_STOP);
  8841. }
  8842. /*
  8843. Function: Command_TradeAccept()
  8844. Purpose : Accepts item/coin trade between players
  8845. Params :
  8846. Dev :
  8847. Example :
  8848. */
  8849. void Commands::Command_TradeAccept(Client* client, Seperator* sep)
  8850. {
  8851. PrintSep(sep, "COMMAND_ACCEPT_TRADE");
  8852. Trade* trade = client->GetPlayer()->trade;
  8853. if (trade) {
  8854. bool trade_complete = trade->SetTradeAccepted(client->GetPlayer());
  8855. if (trade_complete)
  8856. safe_delete(trade);
  8857. }
  8858. else
  8859. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8860. }
  8861. /*
  8862. Function: Command_TradeReject()
  8863. Purpose : Rejects item/coin trade between players
  8864. Params :
  8865. Dev :
  8866. Example :
  8867. */
  8868. void Commands::Command_TradeReject(Client* client, Seperator* sep)
  8869. {
  8870. PrintSep(sep, "COMMAND_REJECT_TRADE");
  8871. Command_TradeCancel(client, sep);
  8872. }
  8873. /*
  8874. Function: Command_TradeCancel()
  8875. Purpose : Cancels item/coin trade between players
  8876. Params :
  8877. Dev :
  8878. Example :
  8879. */
  8880. void Commands::Command_TradeCancel(Client* client, Seperator* sep)
  8881. {
  8882. PrintSep(sep, "COMMAND_CANCEL_TRADE");
  8883. Trade* trade = client->GetPlayer()->trade;
  8884. if (trade) {
  8885. trade->CancelTrade(client->GetPlayer());
  8886. safe_delete(trade);
  8887. }
  8888. else
  8889. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8890. }
  8891. /*
  8892. Function: Command_TradeSetCoin()
  8893. Purpose : Sets coin trade between players
  8894. Params :
  8895. Dev :
  8896. Example :
  8897. */
  8898. void Commands::Command_TradeSetCoin(Client* client, Seperator* sep)
  8899. {
  8900. PrintSep(sep, "COMMAND_SET_TRADE_COIN");
  8901. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Set Trade Coin");
  8902. client->Message(CHANNEL_COLOR_YELLOW, "You cannot trade with other players (Not Implemented)");
  8903. }
  8904. /*
  8905. Function: Command_TradeAddCoin()
  8906. Purpose : Adds coin to trade between players
  8907. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  8908. Dev :
  8909. Example :
  8910. */
  8911. void Commands::Command_TradeAddCoin(Client* client, Seperator* sep, int handler)
  8912. {
  8913. PrintSep(sep, "COMMAND_ADD_TRADE_{coin type}");
  8914. Trade* trade = client->GetPlayer()->trade;
  8915. if (trade) {
  8916. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  8917. int32 amount = atoi(sep->arg[0]);
  8918. int64 val = 0;
  8919. switch (handler) {
  8920. case COMMAND_ADD_TRADE_COPPER:
  8921. {
  8922. val = amount;
  8923. trade->AddCoinToTrade(client->GetPlayer(), val);
  8924. break;
  8925. }
  8926. case COMMAND_ADD_TRADE_SILVER:
  8927. {
  8928. val = amount * 100;
  8929. trade->AddCoinToTrade(client->GetPlayer(), val);
  8930. break;
  8931. }
  8932. case COMMAND_ADD_TRADE_GOLD:
  8933. {
  8934. val = amount * 10000;
  8935. trade->AddCoinToTrade(client->GetPlayer(), val);
  8936. break;
  8937. }
  8938. case COMMAND_ADD_TRADE_PLAT:
  8939. {
  8940. val = amount * 1000000;
  8941. trade->AddCoinToTrade(client->GetPlayer(), val);
  8942. break;
  8943. }
  8944. default:
  8945. {
  8946. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  8947. break;
  8948. }
  8949. }
  8950. }
  8951. else
  8952. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount.");
  8953. }
  8954. else
  8955. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8956. }
  8957. /*
  8958. Function: Command_TradeRemoveCoin()
  8959. Purpose : Removes coin from trade between players
  8960. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  8961. Dev :
  8962. Example :
  8963. */
  8964. void Commands::Command_TradeRemoveCoin(Client* client, Seperator* sep, int handler)
  8965. {
  8966. PrintSep(sep, "COMMAND_REMOVE_TRADE_{coin type}");
  8967. Trade* trade = client->GetPlayer()->trade;
  8968. if (trade) {
  8969. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  8970. int32 amount = atoi(sep->arg[0]);
  8971. int64 val = 0;
  8972. switch (handler) {
  8973. case COMMAND_REMOVE_TRADE_COPPER:
  8974. {
  8975. val = amount;
  8976. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  8977. break;
  8978. }
  8979. case COMMAND_REMOVE_TRADE_SILVER:
  8980. {
  8981. val = amount * 100;
  8982. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  8983. break;
  8984. }
  8985. case COMMAND_REMOVE_TRADE_GOLD:
  8986. {
  8987. val = amount * 10000;
  8988. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  8989. break;
  8990. }
  8991. case COMMAND_REMOVE_TRADE_PLAT:
  8992. {
  8993. val = amount * 1000000;
  8994. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  8995. break;
  8996. }
  8997. default:
  8998. {
  8999. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  9000. break;
  9001. }
  9002. }
  9003. }
  9004. else
  9005. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount");
  9006. }
  9007. else
  9008. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  9009. }
  9010. /*
  9011. Function: Command_TradeAddItem()
  9012. Purpose : Adds item to trade between players
  9013. Params :
  9014. Dev :
  9015. Example :
  9016. */
  9017. void Commands::Command_TradeAddItem(Client* client, Seperator* sep)
  9018. {
  9019. PrintSep(sep, "COMMAND_ADD_TRADE_ITEM");
  9020. /*
  9021. arg[0] = item index
  9022. arg[1] = slot
  9023. arg[2] = quantity
  9024. */
  9025. if (!client->GetPlayer()->trade) {
  9026. LogWrite(PLAYER__ERROR, 0, "Trade", "Player is not currently trading.");
  9027. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  9028. return;
  9029. }
  9030. if (sep && sep->IsSet(0) && sep->IsNumber(0) && sep->IsSet(1) && sep->IsNumber(1) && sep->IsSet(2) && sep->IsNumber(2)) {
  9031. Item* item = 0;
  9032. int32 index = atoi(sep->arg[0]);
  9033. item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(index);
  9034. if (item) {
  9035. int8 result = client->GetPlayer()->trade->AddItemToTrade(client->GetPlayer(), item, atoi(sep->arg[2]), atoi(sep->arg[1]));
  9036. if (result == 1)
  9037. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Item is already being traded.");
  9038. else if (result == 2)
  9039. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade NO-TRADE items.");
  9040. else if (result == 3)
  9041. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade HEIRLOOM items.");
  9042. else if (result == 255)
  9043. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown error trying to add the item to the trade...");
  9044. }
  9045. else {
  9046. LogWrite(PLAYER__ERROR, 0, "Trade", "Unable to get an item for the player (%s) from the index (%u)", client->GetPlayer()->GetName(), index);
  9047. client->Message(CHANNEL_ERROR, "Unable to find item at index %u", index);
  9048. }
  9049. }
  9050. else
  9051. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  9052. }
  9053. /*
  9054. Function: Command_TradeRemoveItem()
  9055. Purpose : Removes item from trade between players
  9056. Params :
  9057. Dev :
  9058. Example :
  9059. */
  9060. void Commands::Command_TradeRemoveItem(Client* client, Seperator* sep)
  9061. {
  9062. PrintSep(sep, "COMMAND_REMOVE_TRADE_ITEM");
  9063. /*
  9064. arg[0] = trade window slot
  9065. */
  9066. Trade* trade = client->GetPlayer()->trade;
  9067. if (trade) {
  9068. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  9069. trade->RemoveItemFromTrade(client->GetPlayer(), atoi(sep->arg[0]));
  9070. }
  9071. else
  9072. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  9073. }
  9074. else
  9075. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  9076. }
  9077. void Commands::Command_TryOn(Client* client, Seperator* sep)
  9078. {
  9079. Item *item = 0;
  9080. sint32 crc;
  9081. if (sep) {
  9082. // 1096+ sends more info so need to do a version check so older clients (SF) still work
  9083. if (client->GetVersion() < 1096) {
  9084. if (sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2))
  9085. {
  9086. item = master_item_list.GetItem(atoul(sep->arg[1]));
  9087. crc = atol(sep->arg[2]);
  9088. }
  9089. }
  9090. else {
  9091. // From the broker and links in chat
  9092. if (strcmp(sep->arg[0], "crc") == 0) {
  9093. if (sep->IsNumber(2) && sep->IsNumber(3)) {
  9094. item = master_item_list.GetItem(atoul(sep->arg[2]));
  9095. crc = atol(sep->arg[3]);
  9096. }
  9097. }
  9098. // From inventory
  9099. if (strcmp(sep->arg[0], "dbid") == 0) {
  9100. if (sep->IsNumber(2) && sep->IsNumber(4)) {
  9101. item = master_item_list.GetItem(atoul(sep->arg[2]));
  9102. crc = atol(sep->arg[4]);
  9103. }
  9104. }
  9105. }
  9106. if (item)
  9107. client->ShowDressingRoom(item, crc);
  9108. }
  9109. }
  9110. void Commands::Command_JoinChannel(Client * client, Seperator *sep) {
  9111. const char *channel_name, *password = NULL;
  9112. if (sep == NULL || !sep->IsSet(0)) {
  9113. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /joinchannel <channel name> [password]");
  9114. return;
  9115. }
  9116. channel_name = sep->arg[0];
  9117. if (sep->IsSet(1))
  9118. password = sep->arg[1];
  9119. if (!chat.ChannelExists(channel_name) && !chat.CreateChannel(channel_name, password)) {
  9120. client->Message(CHANNEL_COLOR_RED, "Unable to create channel '%s'.", channel_name);
  9121. return;
  9122. }
  9123. if (chat.IsInChannel(client, channel_name)) {
  9124. client->Message(CHANNEL_NARRATIVE, "You are already in '%s'.", channel_name);
  9125. return;
  9126. }
  9127. if (chat.HasPassword(channel_name)) {
  9128. if (password == NULL) {
  9129. client->Message(CHANNEL_NARRATIVE, "Unable to join '%s': That channel is password protected.", channel_name);
  9130. return;
  9131. }
  9132. if (!chat.PasswordMatches(channel_name, password)) {
  9133. client->Message(CHANNEL_NARRATIVE, "Unable to join '%s': The password is not correc.t", channel_name);
  9134. return;
  9135. }
  9136. }
  9137. if (!chat.JoinChannel(client, channel_name))
  9138. client->Message(CHANNEL_COLOR_RED, "There was an internal error preventing you from joining '%s'.", channel_name);
  9139. }
  9140. void Commands::Command_JoinChannelFromLoad(Client * client, Seperator *sep) {
  9141. printf("ScatDebug: Received 'joinfromchannel', using the same function as 'joinchannel' (not sure what the difference is)\n");
  9142. Command_JoinChannel(client, sep);
  9143. }
  9144. void Commands::Command_TellChannel(Client *client, Seperator *sep) {
  9145. if (sep == NULL || !sep->IsSet(0) || !sep->IsSet(1)) {
  9146. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /tellchannel <channel name> <message>");
  9147. PrintSep(sep, "tellchannel");
  9148. return;
  9149. }
  9150. chat.TellChannel(client, sep->arg[0], sep->argplus[1]);
  9151. }
  9152. void Commands::Command_Test(Client* client, EQ2_16BitString* command_parms) {
  9153. Seperator* sep = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  9154. if (sep->IsSet(0)) {
  9155. if (atoi(sep->arg[0]) == 1) {
  9156. PacketStruct* packet2 = configReader.getStruct("WS_SpellGainedMsg", client->GetVersion());
  9157. if (packet2) {
  9158. packet2->setDataByName("spell_type", 2);
  9159. packet2->setDataByName("spell_id", 8308);
  9160. packet2->setDataByName("spell_name", "Sprint");
  9161. packet2->setDataByName("add_silently", 0);
  9162. packet2->setDataByName("tier", 1);
  9163. packet2->setDataByName("blah1", 1);
  9164. packet2->setDataByName("blah2", 1);
  9165. EQ2Packet* outapp = packet2->serialize();
  9166. DumpPacket(outapp);
  9167. client->QueuePacket(outapp);
  9168. safe_delete(packet2);
  9169. }
  9170. }
  9171. else if (atoi(sep->arg[0]) == 2) {
  9172. PacketStruct* packet2 = configReader.getStruct("WS_GuildUpdate", client->GetVersion());
  9173. if (packet2) {
  9174. packet2->setDataByName("guild_name", "Test");
  9175. packet2->setDataByName("guild_motd", "Test MOTD");
  9176. packet2->setDataByName("guild_id", 1234);
  9177. packet2->setDataByName("guild_level", 1);
  9178. packet2->setDataByName("unknown", 2);
  9179. packet2->setDataByName("unknown2", 3);
  9180. packet2->setDataByName("exp_current", 1);
  9181. packet2->setDataByName("exp_to_next_level", 4);
  9182. EQ2Packet* outapp = packet2->serialize();
  9183. DumpPacket(outapp);
  9184. client->QueuePacket(outapp);
  9185. safe_delete(packet2);
  9186. }
  9187. }
  9188. else if (atoi(sep->arg[0]) == 3) {
  9189. PacketStruct* packet2 = configReader.getStruct("WS_JoinGuildNotify", client->GetVersion());
  9190. if (packet2) {
  9191. packet2->setDataByName("guild_id", 1234);
  9192. packet2->setDataByName("character_id", 1);
  9193. packet2->setDataByName("account_id", 2);
  9194. packet2->setDataByName("guild_level", 1);
  9195. packet2->setDataByName("name", "Test");
  9196. packet2->setDataByName("unknown2", 0);
  9197. packet2->setDataByName("unknown3", 1);
  9198. packet2->setDataByName("adventure_class", 6);
  9199. packet2->setDataByName("adventure_level", 7);
  9200. packet2->setDataByName("tradeskill_class", 4);
  9201. packet2->setDataByName("tradeskill_level", 5);
  9202. packet2->setDataByName("rank", 0);
  9203. packet2->setDataByName("member_flags", 2);
  9204. packet2->setDataByName("join_date", 1591112273);
  9205. packet2->setDataByName("guild_status", 2);
  9206. packet2->setDataByName("last_login", 1591132273);
  9207. packet2->setDataByName("recruiter_id", 1);
  9208. packet2->setDataByName("points", 2345);
  9209. packet2->setDataByName("note", "note");
  9210. packet2->setMediumStringByName("officer_note", "O note");
  9211. packet2->setMediumStringByName("zone", "Blah");
  9212. EQ2Packet* outapp = packet2->serialize();
  9213. DumpPacket(outapp);
  9214. client->QueuePacket(outapp);
  9215. safe_delete(packet2);
  9216. }
  9217. }
  9218. else if (atoi(sep->arg[0]) == 5) {
  9219. int16 offset = atoi(sep->arg[1]);
  9220. int32 value1 = atol(sep->arg[2]);
  9221. EQ2Packet* outapp = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion(), offset, value1);
  9222. client->QueuePacket(outapp);
  9223. }
  9224. else if (atoi(sep->arg[0]) == 6) {
  9225. Spawn* spawn = client->GetPlayer()->GetTarget();
  9226. if (!spawn)
  9227. spawn = client->GetPlayer();
  9228. else if (spawn->IsEntity())
  9229. ((Entity*)spawn)->SetSpeed(atof(sep->arg[4]));
  9230. spawn->RunToLocation(atof(sep->arg[1]), atof(sep->arg[2]), atof(sep->arg[3]));
  9231. }
  9232. else if (atoi(sep->arg[0]) == 7) {
  9233. int32 id = 0;
  9234. Spawn* spawn = client->GetCurrentZone()->GetSpawn(7720001);
  9235. if (spawn) {
  9236. spawn->SetX(client->GetPlayer()->GetX() + .5, false);
  9237. spawn->SetY(client->GetPlayer()->GetY(), false);
  9238. spawn->SetZ(client->GetPlayer()->GetZ() + .5, false);
  9239. float heading = client->GetPlayer()->GetHeading() + 180;
  9240. if (heading > 360)
  9241. heading -= 360;
  9242. spawn->SetLevel(5);
  9243. spawn->SetAdventureClass(4);
  9244. spawn->SetHeading(heading, false);
  9245. spawn->SetSpawnOrigX(spawn->GetX());
  9246. spawn->SetSpawnOrigY(spawn->GetY());
  9247. spawn->SetSpawnOrigZ(spawn->GetZ());
  9248. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  9249. spawn->SetLocation(client->GetPlayer()->GetLocation());
  9250. spawn->appearance.targetable = 1;
  9251. if (spawn->IsNPC() && spawn->GetTotalHP() == 0) {
  9252. spawn->SetTotalHP(spawn->GetLevel() * 15);
  9253. spawn->SetHP(spawn->GetTotalHP());
  9254. }
  9255. if (spawn->GetTotalPower() == 0) {
  9256. spawn->SetTotalPower(spawn->GetLevel() * 15);
  9257. spawn->SetPower(spawn->GetTotalPower());
  9258. }
  9259. int16 offset = atoi(sep->arg[1]);
  9260. int32 value1 = atol(sep->arg[2]);
  9261. sprintf(spawn->appearance.name, "Offset %i", offset);
  9262. EQ2Packet* ret = spawn->spawn_serialize(client->GetPlayer(), client->GetVersion(), offset, value1);
  9263. DumpPacket(ret);
  9264. client->QueuePacket(ret);
  9265. }
  9266. }
  9267. else if (atoi(sep->arg[0]) == 8) {
  9268. int32 id = atoi(sep->arg[1]);
  9269. Spawn* spawn = client->GetCurrentZone()->GetSpawn(id);
  9270. if (spawn) {
  9271. spawn->SetX(client->GetPlayer()->GetX() + .5, false);
  9272. spawn->SetY(client->GetPlayer()->GetY(), false);
  9273. spawn->SetZ(client->GetPlayer()->GetZ() + .5, false);
  9274. float heading = client->GetPlayer()->GetHeading() + 180;
  9275. if (heading > 360)
  9276. heading -= 360;
  9277. spawn->SetLevel(5);
  9278. spawn->SetAdventureClass(4);
  9279. spawn->SetHeading(heading, false);
  9280. spawn->SetSpawnOrigX(spawn->GetX());
  9281. spawn->SetSpawnOrigY(spawn->GetY());
  9282. spawn->SetSpawnOrigZ(spawn->GetZ());
  9283. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  9284. spawn->SetLocation(client->GetPlayer()->GetLocation());
  9285. spawn->appearance.targetable = 1;
  9286. if (spawn->IsNPC() && spawn->GetTotalHP() == 0) {
  9287. spawn->SetTotalHP(spawn->GetLevel() * 15);
  9288. spawn->SetHP(spawn->GetTotalHP());
  9289. }
  9290. if (spawn->GetTotalPower() == 0) {
  9291. spawn->SetTotalPower(spawn->GetLevel() * 15);
  9292. spawn->SetPower(spawn->GetTotalPower());
  9293. }
  9294. int16 offset = atoi(sep->arg[2]);
  9295. int16 offset2 = atoi(sep->arg[3]);
  9296. int32 value1 = atol(sep->arg[4]);
  9297. int16 offset3 = 0;
  9298. int16 offset4 = 0;
  9299. int32 value2 = 0;
  9300. if (sep->IsSet(7)) {
  9301. offset3 = atoi(sep->arg[5]);
  9302. offset4 = atoi(sep->arg[6]);
  9303. value2 = atol(sep->arg[7]);
  9304. }
  9305. sprintf(spawn->appearance.name, "Offset %i to %i", offset, offset2);
  9306. spawn->AddPrimaryEntityCommand("attack", 10000, "attack","", 0, 0);
  9307. EQ2Packet* ret = spawn->spawn_serialize(client->GetPlayer(), client->GetVersion(), offset, value1, offset2, offset3, offset4, value2);
  9308. DumpPacket(ret);
  9309. client->QueuePacket(ret);
  9310. }
  9311. }
  9312. else if (atoi(sep->arg[0]) == 9) {
  9313. PacketStruct* packet2 = configReader.getStruct("WS_DeathWindow", client->GetVersion());
  9314. if (packet2) {
  9315. packet2->setArrayLengthByName("location_count", 1);
  9316. packet2->setArrayDataByName("location_ida", 1234);
  9317. packet2->setArrayDataByName("unknown2a", 3);
  9318. packet2->setArrayDataByName("zone_name", "Queen's Colony");
  9319. packet2->setArrayDataByName("location_name", "Myrrin's Tower");
  9320. packet2->setArrayDataByName("distance", 134);
  9321. EQ2Packet* app = packet2->serialize();
  9322. if (sep->IsSet(2)) {
  9323. int8 offset = atoi(sep->arg[1]);
  9324. uchar* ptr2 = app->pBuffer;
  9325. ptr2 += offset;
  9326. if (sep->IsNumber(2)) {
  9327. int32 value1 = atol(sep->arg[2]);
  9328. if (value1 > 0xFFFF)
  9329. memcpy(ptr2, (uchar*)&value1, 4);
  9330. else if (value1 > 0xFF)
  9331. memcpy(ptr2, (uchar*)&value1, 2);
  9332. else
  9333. memcpy(ptr2, (uchar*)&value1, 1);
  9334. }
  9335. else {
  9336. int8 len = strlen(sep->arg[2]);
  9337. memcpy(ptr2, (uchar*)&len, 1);
  9338. ptr2 += 1;
  9339. memcpy(ptr2, sep->arg[2], len);
  9340. }
  9341. }
  9342. DumpPacket(app);
  9343. client->QueuePacket(app);
  9344. safe_delete(packet2);
  9345. }
  9346. }
  9347. else if (atoi(sep->arg[0]) == 10) {
  9348. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalUpdate", client->GetVersion());
  9349. if (packet2) {
  9350. packet2->setArrayLengthByName("num_quests", 1);
  9351. packet2->setArrayDataByName("active", 1);
  9352. packet2->setArrayDataByName("name", "Tasks aboard the Far Journey");
  9353. packet2->setArrayDataByName("quest_type", "Hallmark");
  9354. packet2->setArrayDataByName("quest_zone", "Hallmark");
  9355. packet2->setArrayDataByName("journal_updated", 1);
  9356. packet2->setArrayDataByName("quest_id", 524);
  9357. packet2->setArrayDataByName("day", 19);
  9358. packet2->setArrayDataByName("month", 6);
  9359. packet2->setArrayDataByName("year", 20);
  9360. packet2->setArrayDataByName("level", 2);
  9361. packet2->setArrayDataByName("encounter_level", 4);
  9362. packet2->setArrayDataByName("difficulty", 3);
  9363. packet2->setArrayDataByName("visible", 1);
  9364. packet2->setDataByName("visible_quest_id", 524);
  9365. packet2->setDataByName("player_crc", 2900677088);
  9366. packet2->setDataByName("player_name", "LethalEncounter");
  9367. EQ2Packet* app = packet2->serialize();
  9368. if (sep->IsSet(2)) {
  9369. int8 offset = atoi(sep->arg[1]);
  9370. uchar* ptr2 = app->pBuffer;
  9371. ptr2 += offset;
  9372. if (sep->IsNumber(2)) {
  9373. int32 value1 = atol(sep->arg[2]);
  9374. if (value1 > 0xFFFF)
  9375. memcpy(ptr2, (uchar*)&value1, 4);
  9376. else if (value1 > 0xFF)
  9377. memcpy(ptr2, (uchar*)&value1, 2);
  9378. else
  9379. memcpy(ptr2, (uchar*)&value1, 1);
  9380. }
  9381. else {
  9382. int8 len = strlen(sep->arg[2]);
  9383. memcpy(ptr2, (uchar*)&len, 1);
  9384. ptr2 += 1;
  9385. memcpy(ptr2, sep->arg[2], len);
  9386. }
  9387. }
  9388. DumpPacket(app);
  9389. client->QueuePacket(app);
  9390. safe_delete(packet2);
  9391. }
  9392. }
  9393. else if (atoi(sep->arg[0]) == 11) {
  9394. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalReply", client->GetVersion());
  9395. if (packet2) {
  9396. packet2->setDataByName("quest_id", 524);
  9397. packet2->setDataByName("player_crc", 2900677088);
  9398. packet2->setDataByName("name", "Tasks aboard the Far Journey");
  9399. packet2->setDataByName("description", "I completed all the tasks assigned to me by Captain Varlos aboard the Far Journey");
  9400. packet2->setDataByName("type", "Hallmark");
  9401. packet2->setDataByName("complete_header", "To complete this quest, I must do the following tasks:");
  9402. packet2->setDataByName("day", 19);
  9403. packet2->setDataByName("month", 6);
  9404. packet2->setDataByName("year", 20);
  9405. packet2->setDataByName("level", 1);
  9406. packet2->setDataByName("encounter_level", 1);
  9407. packet2->setDataByName("difficulty", 1);
  9408. packet2->setDataByName("time_obtained", Timer::GetUnixTimeStamp());
  9409. //packet2->setDataByName("timer_start", Timer::GetUnixTimeStamp());
  9410. //packet2->setDataByName("timer_duration", 300);
  9411. //packet2->setDataByName("timer_running", 1);
  9412. packet2->setArrayLengthByName("task_groups_completed", 9);
  9413. packet2->setArrayLengthByName("num_task_groups", 10);
  9414. packet2->setArrayDataByName("task_group", "I spoke to Waulon as Captain Varlos had asked of me.");
  9415. packet2->setArrayDataByName("task_group", "I found Waulon's hat in one of the boxes.", 1);
  9416. packet2->setArrayDataByName("task_group", "I returned Waulon's hat.", 2);
  9417. packet2->setArrayDataByName("task_group", "I have spoken to Ingrid.", 3);
  9418. packet2->setArrayDataByName("task_group", "I purchased a Shard of Luclin.", 4);
  9419. packet2->setArrayDataByName("task_group", "I gave the Shard of Luclin to Ingrid.", 5);
  9420. packet2->setArrayDataByName("task_group", "I have spoken to Captain Varlos.", 6);
  9421. packet2->setArrayDataByName("task_group", "I killed the rats that Captain Varlos requested.", 7);
  9422. packet2->setArrayDataByName("task_group", "Captain Varlos has ordered you to kill the escaped goblin.", 8);
  9423. packet2->setArrayDataByName("task_group", "I killed the escaped goblin.", 9);
  9424. /*packet2->setSubArrayLengthByName("num_tasks", 1);
  9425. packet2->setSubArrayDataByName("task", "I need to talk to Garven Tralk");
  9426. packet2->setSubArrayLengthByName("num_updates", 1);
  9427. packet2->setSubArrayDataByName("update_currentval", 0);
  9428. packet2->setSubArrayDataByName("update_maxval", 1);
  9429. packet2->setSubArrayDataByName("icon", 11);
  9430. */
  9431. packet2->setArrayDataByName("waypoint", 0xFFFFFFFF);
  9432. packet2->setDataByName("journal_updated", 1);
  9433. packet2->setDataByName("bullets", 1);
  9434. EQ2Packet* app = packet2->serialize();
  9435. if (sep->IsSet(2)) {
  9436. int16 offset = atoi(sep->arg[1]);
  9437. uchar* ptr2 = app->pBuffer;
  9438. ptr2 += offset;
  9439. if (sep->IsNumber(2)) {
  9440. int32 value1 = atol(sep->arg[2]);
  9441. if (value1 > 0xFFFF)
  9442. memcpy(ptr2, (uchar*)&value1, 4);
  9443. else if (value1 > 0xFF)
  9444. memcpy(ptr2, (uchar*)&value1, 2);
  9445. else
  9446. memcpy(ptr2, (uchar*)&value1, 1);
  9447. }
  9448. else {
  9449. int16 len = strlen(sep->arg[2]);
  9450. memcpy(ptr2, (uchar*)&len, 2);
  9451. ptr2 += 2;
  9452. memcpy(ptr2, sep->arg[2], len);
  9453. }
  9454. }
  9455. DumpPacket(app);
  9456. client->QueuePacket(app);
  9457. safe_delete(packet2);
  9458. }
  9459. }
  9460. else if (atoi(sep->arg[0]) == 12) {
  9461. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalReply", client->GetVersion());
  9462. if (packet2) {
  9463. packet2->setDataByName("quest_id", 524);
  9464. packet2->setDataByName("player_crc", 2900677088);
  9465. packet2->setDataByName("name", "Archetype Selection");
  9466. packet2->setDataByName("description", "I have reported my profession to Garven Tralk.");
  9467. packet2->setDataByName("type", "Hallmark");
  9468. packet2->setDataByName("complete_header", "To complete this quest, I must do the following tasks:");
  9469. packet2->setDataByName("day", 19);
  9470. packet2->setDataByName("month", 6);
  9471. packet2->setDataByName("year", 20);
  9472. packet2->setDataByName("level", 2);
  9473. packet2->setDataByName("encounter_level", 4);
  9474. packet2->setDataByName("difficulty", 3);
  9475. packet2->setDataByName("time_obtained", Timer::GetUnixTimeStamp());
  9476. packet2->setDataByName("timer_start", Timer::GetUnixTimeStamp());
  9477. packet2->setDataByName("timer_duration", 300);
  9478. packet2->setDataByName("timer_running", 1);
  9479. packet2->setArrayLengthByName("task_groups_completed", 0);
  9480. packet2->setArrayLengthByName("num_task_groups", 1);
  9481. packet2->setArrayDataByName("task_group", "I need to talk to Garven Tralk");
  9482. packet2->setSubArrayLengthByName("num_tasks", 1);
  9483. packet2->setSubArrayDataByName("task", "I need to talk to Garven Tralk");
  9484. packet2->setSubArrayLengthByName("num_updates", 1);
  9485. packet2->setSubArrayDataByName("update_currentval", 0);
  9486. packet2->setSubArrayDataByName("update_maxval", 1);
  9487. packet2->setSubArrayDataByName("icon", 11);
  9488. packet2->setArrayDataByName("waypoint", 0xFFFFFFFF);
  9489. packet2->setDataByName("journal_updated", 1);
  9490. packet2->setSubstructDataByName("reward_data", "unknown1", 255);
  9491. packet2->setSubstructDataByName("reward_data", "reward", "Quest Reward!");
  9492. packet2->setSubstructDataByName("reward_data", "unknown2", 0x3f);
  9493. packet2->setSubstructDataByName("reward_data", "coin", 150);
  9494. packet2->setSubstructDataByName("reward_data", "status_points", 5);
  9495. packet2->setSubstructDataByName("reward_data", "exp_bonus", 10);
  9496. packet2->setSubstructArrayLengthByName("reward_data", "num_rewards", 1);
  9497. packet2->setSubstructArrayDataByName("reward_data", "reward_id", 123);
  9498. Item* item = master_item_list.GetItem(152755);
  9499. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9500. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  9501. /*packet2->setSubstructDataByName("item", "unique_id", 567);
  9502. packet2->setSubstructDataByName("item", "broker_item_id", 0xFFFFFFFFFFFFFFFF);
  9503. packet2->setSubstructDataByName("item", "icon", 0xe7);
  9504. packet2->setSubstructDataByName("item", "tier", 4);
  9505. packet2->setSubstructDataByName("item", "flags", 0x60);
  9506. packet2->setSubstructArrayLengthByName("item", "stat_count", 1);
  9507. packet2->setSubstructDataByName("item", "stat_type", 1);
  9508. packet2->setSubstructDataByName("item", "stat_subtype", 2);
  9509. packet2->setSubstructDataByName("item", "value", 3);
  9510. packet2->setSubstructDataByName("item", "condition", 100);
  9511. packet2->setSubstructDataByName("item", "weight", 1);
  9512. packet2->setSubstructDataByName("item", "skill_req1", 0xacafa99e);
  9513. packet2->setSubstructDataByName("item", "skill_req2", 0xacafa99e);
  9514. packet2->setSubstructDataByName("item", "skill_min", 1);
  9515. packet2->setSubstructArrayLengthByName("item", "class_count", 3);
  9516. packet2->setSubstructDataByName("item", "adventure_class", 1);
  9517. packet2->setSubstructDataByName("item", "adventure_class", 11, 0, 1);
  9518. packet2->setSubstructDataByName("item", "adventure_class", 0x1f, 0, 2);
  9519. packet2->setSubstructDataByName("item", "tradeskill_class", 255);
  9520. packet2->setSubstructDataByName("item", "tradeskill_class", 255, 0, 1);
  9521. packet2->setSubstructDataByName("item", "tradeskill_class", 255, 0, 2);
  9522. packet2->setSubstructDataByName("item", "level", 0x1e);
  9523. packet2->setSubstructDataByName("item", "level", 100, 0, 1);
  9524. packet2->setSubstructDataByName("item", "level", 100, 0, 2);
  9525. packet2->setSubstructDataByName("item_footer", "name", "Footman Gloves");*/
  9526. //packet2->PrintPacket();
  9527. EQ2Packet* app = packet2->serialize();
  9528. if (sep->IsSet(2)) {
  9529. int16 offset = atoi(sep->arg[1]);
  9530. uchar* ptr2 = app->pBuffer;
  9531. ptr2 += offset;
  9532. if (sep->IsNumber(2)) {
  9533. int32 value1 = atol(sep->arg[2]);
  9534. if (value1 > 0xFFFF)
  9535. memcpy(ptr2, (uchar*)&value1, 4);
  9536. else if (value1 > 0xFF)
  9537. memcpy(ptr2, (uchar*)&value1, 2);
  9538. else
  9539. memcpy(ptr2, (uchar*)&value1, 1);
  9540. }
  9541. else {
  9542. int16 len = strlen(sep->arg[2]);
  9543. memcpy(ptr2, (uchar*)&len, 2);
  9544. ptr2 += 2;
  9545. memcpy(ptr2, sep->arg[2], len);
  9546. }
  9547. }
  9548. DumpPacket(app);
  9549. client->QueuePacket(app);
  9550. safe_delete(packet2);
  9551. }
  9552. }
  9553. else if (atoi(sep->arg[0]) == 13) {
  9554. PacketStruct* packet2 = configReader.getStruct("WS_OnScreenMsg", client->GetVersion());
  9555. if (packet2 && sep->IsSet(7)) {
  9556. packet2->setDataByName("unknown", atoi(sep->arg[1]));
  9557. char blah[128];
  9558. sprintf(blah, "\\#6EFF6EYou get better at \12\\#C8FFC8%s\\#6EFF6E! (7/15)", sep->arg[2]);
  9559. packet2->setDataByName("text", blah);
  9560. packet2->setDataByName("message_type", sep->arg[3]);
  9561. packet2->setDataByName("size", atof(sep->arg[4]));
  9562. packet2->setDataByName("red", atoi(sep->arg[5]));
  9563. packet2->setDataByName("green", atoi(sep->arg[6]));
  9564. packet2->setDataByName("blue", atoi(sep->arg[7]));
  9565. EQ2Packet* app = packet2->serialize();
  9566. DumpPacket(app);
  9567. client->QueuePacket(app);
  9568. safe_delete(packet2);
  9569. }
  9570. }
  9571. else if (atoi(sep->arg[0]) == 14) {
  9572. PacketStruct* packet2 = configReader.getStruct("WS_InstructionWindow", client->GetVersion());
  9573. if (packet2 && sep->IsSet(3)) {
  9574. packet2->setDataByName("open_seconds_min", atof(sep->arg[1]));
  9575. packet2->setDataByName("open_seconds_max", atof(sep->arg[2]));
  9576. packet2->setDataByName("voice_sync", atoi(sep->arg[3]));
  9577. 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.");
  9578. packet2->setDataByName("voice", "voiceover/english/narrator/boat_06p_tutorial02/narrator_001_63779ca0.mp3");
  9579. packet2->setArrayLengthByName("num_goals", 1);
  9580. //packet2->setArrayDataByName("goal_text", )
  9581. packet2->setSubArrayLengthByName("num_tasks", 1);
  9582. packet2->setSubArrayDataByName("task_text", "continue");
  9583. packet2->setDataByName("complete_sound", "click");
  9584. packet2->setDataByName("signal", "introduction");
  9585. packet2->setDataByName("voice_key1", 0xcda65173);
  9586. packet2->setDataByName("voice_key2", 0x984bfc6d);
  9587. EQ2Packet* app = packet2->serialize();
  9588. DumpPacket(app);
  9589. client->QueuePacket(app);
  9590. safe_delete(packet2);
  9591. packet2 = configReader.getStruct("WS_ShowWindow", client->GetVersion());
  9592. packet2->setDataByName("window", "MainHUD.StartMenu");
  9593. packet2->setDataByName("show", 1);
  9594. app = packet2->serialize();
  9595. DumpPacket(app);
  9596. client->QueuePacket(app);
  9597. safe_delete(packet2);
  9598. packet2 = configReader.getStruct("WS_FlashWindow", client->GetVersion());
  9599. packet2->setDataByName("window", "MainHUD.StartMenu.help");
  9600. packet2->setDataByName("flash_seconds", 10);
  9601. app = packet2->serialize();
  9602. DumpPacket(app);
  9603. client->QueuePacket(app);
  9604. safe_delete(packet2);
  9605. }
  9606. }
  9607. else if (atoi(sep->arg[0]) == 15) {
  9608. PacketStruct* packet2 = configReader.getStruct("WS_UpdateLoot", client->GetVersion());
  9609. if (packet2) {
  9610. packet2->setArrayLengthByName("loot_count", 1);
  9611. packet2->setArrayDataByName("name", "Test");
  9612. packet2->setArrayDataByName("item_id", 1234);
  9613. packet2->setArrayDataByName("count", 1);
  9614. packet2->setArrayDataByName("icon", 258);
  9615. packet2->setArrayDataByName("ability_id", 0xFFFFFFFF);
  9616. Spawn* spawn = client->GetPlayer()->GetTarget();
  9617. if (spawn)
  9618. packet2->setDataByName("object_id", client->GetPlayer()->GetIDWithPlayerSpawn(spawn));
  9619. packet2->setDataByName("unknown3", 1);
  9620. packet2->setDataByName("unknown4", 1);
  9621. packet2->setDataByName("unknown5", 60);
  9622. EQ2Packet* app = packet2->serialize();
  9623. DumpPacket(app);
  9624. client->QueuePacket(app);
  9625. safe_delete(packet2);
  9626. }
  9627. }
  9628. else if (atoi(sep->arg[0]) == 16 && sep->IsNumber(1)) {
  9629. char blah[32];
  9630. sprintf(blah, "Testing: %i", atoi(sep->arg[1]));
  9631. client->SimpleMessage(atoi(sep->arg[1]), blah);
  9632. }
  9633. else if (atoi(sep->arg[0]) == 17 && sep->IsNumber(2)) {
  9634. if (sep->IsSet(2)) {
  9635. int16 offset = atoi(sep->arg[1]);
  9636. if (sep->IsNumber(2)) {
  9637. int32 value1 = atol(sep->arg[2]);
  9638. client->QueuePacket(client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion(), offset, value1));
  9639. cout << "Sent" << endl;
  9640. }
  9641. }
  9642. }
  9643. else if (atoi(sep->arg[0]) == 18) {
  9644. PacketStruct* packet2 = configReader.getStruct("WS_QuestRewardPackMsg", client->GetVersion());
  9645. if (packet2) {
  9646. packet2->setSubstructDataByName("reward_data", "unknown1", 255);
  9647. packet2->setSubstructDataByName("reward_data", "reward", "Quest Reward!");
  9648. packet2->setSubstructDataByName("reward_data", "max_coin", 0);
  9649. packet2->setSubstructDataByName("reward_data", "text", "Some custom text to mess things up?");
  9650. //packet2->setSubstructDataByName("reward_data", "status_points", 5);
  9651. //packet2->setSubstructDataByName("reward_data", "exp_bonus", 10);
  9652. packet2->setSubstructArrayLengthByName("reward_data", "num_rewards", 1);
  9653. Item* item = new Item(master_item_list.GetItem(9357));
  9654. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9655. //item->stack_count = 20;
  9656. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  9657. safe_delete(item);
  9658. /*item = new Item(master_item_list.GetItem(36685));
  9659. item->stack_count = 20;
  9660. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9661. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 1, 0, -1);
  9662. safe_delete(item);
  9663. item = master_item_list.GetItem(1414);
  9664. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9665. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 2, 0, -1);
  9666. item = master_item_list.GetItem(75057);
  9667. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9668. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 3, 0, -1);*/
  9669. EQ2Packet* app = packet2->serialize();
  9670. if (sep->IsSet(2)) {
  9671. int16 offset = atoi(sep->arg[1]);
  9672. uchar* ptr2 = app->pBuffer;
  9673. ptr2 += offset;
  9674. if (sep->IsNumber(2)) {
  9675. int32 value1 = atol(sep->arg[2]);
  9676. if (value1 > 0xFFFF)
  9677. memcpy(ptr2, (uchar*)&value1, 4);
  9678. else if (value1 > 0xFF)
  9679. memcpy(ptr2, (uchar*)&value1, 2);
  9680. else
  9681. memcpy(ptr2, (uchar*)&value1, 1);
  9682. }
  9683. else {
  9684. int16 len = strlen(sep->arg[2]);
  9685. memcpy(ptr2, (uchar*)&len, 2);
  9686. ptr2 += 2;
  9687. memcpy(ptr2, sep->arg[2], len);
  9688. }
  9689. }
  9690. DumpPacket(app);
  9691. client->QueuePacket(app);
  9692. safe_delete(packet2);
  9693. }
  9694. }
  9695. else if (atoi(sep->arg[0]) == 19) {
  9696. PacketStruct* packet2 = configReader.getStruct("WS_UpdateLoot", client->GetVersion());
  9697. Spawn* spawn = client->GetPlayer()->GetTarget();
  9698. if (packet2 && spawn) {
  9699. Item* item = master_item_list.GetItem(130053);
  9700. packet2->setArrayLengthByName("loot_count", 1);
  9701. packet2->setArrayDataByName("loot_id", item->details.item_id);
  9702. packet2->setArrayDataByName("unknown2", 1);
  9703. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, 2, true);
  9704. packet2->setDataByName("display", 1);
  9705. packet2->setDataByName("unknown2b", 1);
  9706. packet2->setDataByName("unknown3", 0x3c);
  9707. packet2->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(spawn));
  9708. packet2->PrintPacket();
  9709. EQ2Packet* app = packet2->serialize();
  9710. if (sep->IsSet(2)) {
  9711. int16 offset = atoi(sep->arg[1]);
  9712. int16 offset2 = 0;
  9713. int32 value1 = 0;
  9714. if (sep->IsSet(3)) {
  9715. offset2 = atoi(sep->arg[2]);
  9716. value1 = atol(sep->arg[3]);
  9717. }
  9718. else
  9719. value1 = atol(sep->arg[2]);
  9720. int16 offset3 = 0;
  9721. int16 offset4 = 0;
  9722. int32 value2 = 0;
  9723. if (sep->IsSet(6)) {
  9724. offset3 = atoi(sep->arg[4]);
  9725. offset4 = atoi(sep->arg[5]);
  9726. value2 = atol(sep->arg[6]);
  9727. }
  9728. offset--;
  9729. if (offset2 > 0 && offset2 >= offset) {
  9730. offset2--;
  9731. uchar* ptr2 = app->pBuffer;
  9732. ptr2 += offset;
  9733. for (int i = offset; i <= offset2; i++) {
  9734. if (value1 > 0xFFFF) {
  9735. memcpy(ptr2, (uchar*)&value1, 4);
  9736. i += 3;
  9737. ptr2 += 3;
  9738. }
  9739. else if (value1 > 0xFF) {
  9740. memcpy(ptr2, (uchar*)&value1, 2);
  9741. i++;
  9742. ptr2++;
  9743. }
  9744. else
  9745. memcpy(ptr2, (uchar*)&value1, 1);
  9746. ptr2++;
  9747. }
  9748. }
  9749. if (offset4 > 0 && offset4 >= offset3) {
  9750. offset3--;
  9751. offset4--;
  9752. uchar* ptr2 = app->pBuffer;
  9753. ptr2 += offset3;
  9754. for (int i = offset3; i <= offset4; i++) {
  9755. if (value2 > 0xFFFF) {
  9756. memcpy(ptr2, (uchar*)&value2, 4);
  9757. i += 3;
  9758. ptr2 += 3;
  9759. }
  9760. else if (value2 > 0xFF) {
  9761. memcpy(ptr2, (uchar*)&value2, 2);
  9762. i++;
  9763. ptr2++;
  9764. }
  9765. else
  9766. memcpy(ptr2, (uchar*)&value2, 1);
  9767. ptr2++;
  9768. }
  9769. }
  9770. }
  9771. DumpPacket(app);
  9772. client->QueuePacket(app);
  9773. safe_delete(packet2);
  9774. }
  9775. }
  9776. else if (atoi(sep->arg[0]) == 21) {
  9777. PacketStruct* packet2 = configReader.getStruct("WS_OfferQuest", client->GetVersion());
  9778. if (packet2) {
  9779. packet2->setDataByName("unknown0", 255);
  9780. packet2->setDataByName("reward", "New Quest");
  9781. packet2->setDataByName("title", "Title");
  9782. packet2->setDataByName("description", "description");
  9783. packet2->setDataByName("quest_difficulty", 3);
  9784. packet2->setDataByName("unknown1", 5);
  9785. packet2->setDataByName("level", 3);
  9786. packet2->setDataByName("coin", 150);
  9787. packet2->setDataByName("status_points", 5);
  9788. packet2->setDataByName("exp_bonus", 10);
  9789. packet2->setArrayLengthByName("num_rewards", 1);
  9790. Item* item = new Item(master_item_list.GetItem(36212));
  9791. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9792. item->stack_count = 20;
  9793. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  9794. safe_delete(item);
  9795. char accept[35] = { 0 };
  9796. char decline[35] = { 0 };
  9797. sprintf(accept, "q_accept_pending_quest %u", 0);
  9798. sprintf(decline, "q_deny_pending_quest %u", 0);
  9799. packet2->setDataByName("accept_command", accept);
  9800. packet2->setDataByName("decline_command", decline);
  9801. EQ2Packet* app = packet2->serialize();
  9802. if (sep->IsSet(2)) {
  9803. int16 offset = atoi(sep->arg[1]);
  9804. uchar* ptr2 = app->pBuffer;
  9805. ptr2 += offset;
  9806. if (sep->IsNumber(2)) {
  9807. int32 value1 = atol(sep->arg[2]);
  9808. if (value1 > 0xFFFF)
  9809. memcpy(ptr2, (uchar*)&value1, 4);
  9810. else if (value1 > 0xFF)
  9811. memcpy(ptr2, (uchar*)&value1, 2);
  9812. else
  9813. memcpy(ptr2, (uchar*)&value1, 1);
  9814. }
  9815. DumpPacket(app);
  9816. client->QueuePacket(app);
  9817. safe_delete(packet2);
  9818. }
  9819. }
  9820. }
  9821. else if (atoi(sep->arg[0]) == 22) { //same as 21, but 8bit string
  9822. PacketStruct* packet2 = configReader.getStruct("WS_OfferQuest", client->GetVersion());
  9823. if (packet2) {
  9824. packet2->setDataByName("unknown0", 255);
  9825. packet2->setDataByName("reward", "New Quest");
  9826. packet2->setDataByName("title", "Title");
  9827. packet2->setDataByName("description", "description");
  9828. packet2->setDataByName("quest_difficulty", 3);
  9829. packet2->setDataByName("unknown1", 5);
  9830. packet2->setDataByName("level", 3);
  9831. packet2->setDataByName("coin", 150);
  9832. packet2->setDataByName("status_points", 5);
  9833. packet2->setDataByName("exp_bonus", 10);
  9834. packet2->setArrayLengthByName("num_rewards", 1);
  9835. Item* item = new Item(master_item_list.GetItem(36212));
  9836. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9837. item->stack_count = 20;
  9838. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  9839. safe_delete(item);
  9840. char accept[35] = { 0 };
  9841. char decline[35] = { 0 };
  9842. sprintf(accept, "q_accept_pending_quest %u", 0);
  9843. sprintf(decline, "q_deny_pending_quest %u", 0);
  9844. packet2->setDataByName("accept_command", accept);
  9845. packet2->setDataByName("decline_command", decline);
  9846. EQ2Packet* app = packet2->serialize();
  9847. if (sep->IsSet(2)) {
  9848. int16 offset = atoi(sep->arg[1]);
  9849. uchar* ptr2 = app->pBuffer;
  9850. ptr2 += offset;
  9851. if (sep->IsNumber(2)) {
  9852. int32 value1 = atol(sep->arg[2]);
  9853. if (value1 > 0xFFFF)
  9854. memcpy(ptr2, (uchar*)&value1, 4);
  9855. else if (value1 > 0xFF)
  9856. memcpy(ptr2, (uchar*)&value1, 2);
  9857. else
  9858. memcpy(ptr2, (uchar*)&value1, 1);
  9859. }
  9860. else {
  9861. int8 len = strlen(sep->arg[2]);
  9862. memcpy(ptr2, (uchar*)&len, 1);
  9863. ptr2 += 1;
  9864. memcpy(ptr2, sep->arg[2], len);
  9865. }
  9866. }
  9867. DumpPacket(app);
  9868. client->QueuePacket(app);
  9869. safe_delete(packet2);
  9870. }
  9871. }
  9872. else if (atoi(sep->arg[0]) == 23) {
  9873. if (client->GetPlayer()->GetTarget()) {
  9874. PacketStruct* packet2 = configReader.getStruct("WS_UpdateMerchant", client->GetVersion());
  9875. if (packet2) {
  9876. Spawn* target = client->GetPlayer()->GetTarget();
  9877. packet2->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(target));
  9878. Item* item = new Item(master_item_list.GetItem(12565));
  9879. int8 i = 0;
  9880. packet2->setArrayLengthByName("num_items", 1);
  9881. packet2->setArrayDataByName("item_name", item->name.c_str(), i);
  9882. packet2->setArrayDataByName("item_id", item->details.item_id, i);
  9883. packet2->setArrayDataByName("stack_size", item->stack_count, i);
  9884. packet2->setArrayDataByName("icon", item->details.icon, i);
  9885. int8 tmp_level = 0;
  9886. if (item->generic_info.adventure_default_level > 0)
  9887. tmp_level = item->generic_info.adventure_default_level;
  9888. else
  9889. tmp_level = item->generic_info.tradeskill_default_level;
  9890. packet2->setArrayDataByName("level", tmp_level, i);
  9891. packet2->setArrayDataByName("tier", item->details.tier, i);
  9892. packet2->setArrayDataByName("item_id2", item->details.item_id, i);
  9893. int8 item_difficulty = client->GetPlayer()->GetArrowColor(tmp_level);
  9894. if (item_difficulty != ARROW_COLOR_WHITE && item_difficulty != ARROW_COLOR_RED && item_difficulty != ARROW_COLOR_GRAY)
  9895. item_difficulty = ARROW_COLOR_WHITE;
  9896. item_difficulty -= 6;
  9897. if (item_difficulty < 0)
  9898. item_difficulty *= -1;
  9899. packet2->setArrayDataByName("item_difficulty", item_difficulty, i);
  9900. packet2->setArrayDataByName("quantity", 2, i);
  9901. packet2->setArrayDataByName("unknown5", 255, i);
  9902. packet2->setArrayDataByName("stack_size2", item->stack_count, i);
  9903. packet2->setArrayDataByName("description", item->description.c_str(), i);
  9904. packet2->setDataByName("type", 2);
  9905. EQ2Packet* app = packet2->serialize();
  9906. if (sep->IsSet(2)) {
  9907. int16 offset = atoi(sep->arg[1]);
  9908. uchar* ptr2 = app->pBuffer;
  9909. ptr2 += offset;
  9910. if (sep->IsNumber(2)) {
  9911. int32 value1 = atol(sep->arg[2]);
  9912. if (value1 > 0xFFFF)
  9913. memcpy(ptr2, (uchar*)&value1, 4);
  9914. else if (value1 > 0xFF)
  9915. memcpy(ptr2, (uchar*)&value1, 2);
  9916. else
  9917. memcpy(ptr2, (uchar*)&value1, 1);
  9918. }
  9919. else {
  9920. int8 len = strlen(sep->arg[2]);
  9921. memcpy(ptr2, (uchar*)&len, 1);
  9922. ptr2 += 1;
  9923. memcpy(ptr2, sep->arg[2], len);
  9924. }
  9925. }
  9926. DumpPacket(app);
  9927. client->QueuePacket(app);
  9928. safe_delete(packet2);
  9929. }
  9930. }
  9931. }
  9932. else if (atoi(sep->arg[0]) == 24) {
  9933. PacketStruct* packet2 = configReader.getStruct("WS_EnableGameEvent", client->GetVersion());
  9934. if (packet2) {
  9935. if (sep->IsSet(2)) {
  9936. packet2->setDataByName("event_name", sep->arg[1]);
  9937. packet2->setDataByName("enabled", atoi(sep->arg[2]));
  9938. EQ2Packet* app = packet2->serialize();
  9939. DumpPacket(app);
  9940. client->QueuePacket(app);
  9941. safe_delete(packet2);
  9942. }
  9943. }
  9944. }
  9945. else if (atoi(sep->arg[0]) == 25) {
  9946. if (sep->IsSet(1)) {
  9947. Widget* new_spawn = new Widget();
  9948. int32 id = atoul(sep->arg[1]);
  9949. new_spawn->SetWidgetID(id);
  9950. EQ2Packet* ret = new_spawn->serialize(client->GetPlayer(), client->GetVersion());
  9951. client->QueuePacket(ret);
  9952. int8 index = client->GetPlayer()->GetIndexForSpawn(new_spawn);
  9953. PacketStruct* packet2 = configReader.getStruct("WS_DestroyGhostCmd", client->GetVersion());
  9954. if (packet2) {
  9955. packet2->setDataByName("spawn_index", index);
  9956. packet2->setDataByName("delete", 1);
  9957. EQ2Packet* app = packet2->serialize();
  9958. client->QueuePacket(app);
  9959. safe_delete(packet2);
  9960. }
  9961. }
  9962. }
  9963. else if (atoi(sep->arg[0]) == 26) {
  9964. if (sep->IsSet(4)) {
  9965. Widget* new_spawn = new Widget();
  9966. int32 id = atoul(sep->arg[1]);
  9967. new_spawn->SetWidgetID(id);
  9968. float x = atof(sep->arg[2]);
  9969. float y = atof(sep->arg[3]);
  9970. float z = atof(sep->arg[4]);
  9971. new_spawn->SetLocation(client->GetPlayer()->GetLocation());
  9972. new_spawn->SetWidgetX(x);
  9973. new_spawn->SetWidgetY(y);
  9974. new_spawn->SetWidgetZ(z);
  9975. new_spawn->SetX(x);
  9976. new_spawn->SetY(y);
  9977. new_spawn->SetZ(z);
  9978. EQ2Packet* ret = new_spawn->serialize(client->GetPlayer(), client->GetVersion());
  9979. client->QueuePacket(ret);
  9980. }
  9981. }
  9982. else if (atoi(sep->arg[0]) == 27) {
  9983. Spawn* target = client->GetPlayer()->GetTarget();
  9984. PacketStruct* packet2 = configReader.getStruct("WS_HearSimpleDamage", client->GetVersion());
  9985. if (packet2 && target && sep->IsSet(4)) {
  9986. 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] : "");
  9987. }
  9988. }
  9989. else if (atoi(sep->arg[0]) == 28 && sep->IsNumber(1)) {
  9990. World::newValue = strtoull(sep->arg[1], NULL, 0);
  9991. }
  9992. else if (atoi(sep->arg[0]) == 29 && sep->IsNumber(1)) {
  9993. PacketStruct* packet = configReader.getStruct("WS_HearCastSpell", client->GetVersion());
  9994. if (packet) {
  9995. int32 caster_id = client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer());
  9996. int32 target_id = client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer());
  9997. packet->setDataByName("spawn_id", caster_id);
  9998. packet->setArrayLengthByName("num_targets", 1);
  9999. packet->setArrayDataByName("target", target_id);
  10000. packet->setDataByName("num_targets", 1);
  10001. packet->setDataByName("spell_visual", strtoull(sep->arg[1], NULL, 0)); //result
  10002. packet->setDataByName("cast_time", sep->IsNumber(2) ? strtof(sep->arg[2], NULL)*.01f : 2500); //delay
  10003. packet->setDataByName("spell_id", 1);
  10004. packet->setDataByName("spell_level", 1);
  10005. packet->setDataByName("spell_tier", 1);
  10006. EQ2Packet* outapp = packet->serialize();
  10007. DumpPacket(outapp);
  10008. client->QueuePacket(outapp);
  10009. safe_delete(packet);
  10010. }
  10011. }
  10012. else if (atoi(sep->arg[0]) == 30) {
  10013. PacketStruct* packet = configReader.getStruct("WS_UpdateSkillBook", client->GetVersion());
  10014. if (packet) {
  10015. packet->setDataByName("unknown", World::newValue);
  10016. EQ2Packet* outapp = packet->serialize();
  10017. DumpPacket(outapp);
  10018. client->QueuePacket(outapp);
  10019. safe_delete(packet);
  10020. }
  10021. }
  10022. else if (atoi(sep->arg[0]) == 31) {
  10023. client->SendRecipeList();
  10024. }
  10025. else if (atoi(sep->arg[0]) == 32 && sep->IsNumber(1) && sep->IsNumber(2)) {
  10026. if(client->GetVersion() <= 546) {
  10027. int32 param = atoul(sep->arg[1]);
  10028. int32 paramvalue = atoul(sep->arg[2]);
  10029. client->Message(CHANNEL_COLOR_YELLOW, "Send control flag param %u param value %u", param, paramvalue);
  10030. ClientPacketFunctions::SendServerControlFlagsClassic(client, param, paramvalue);
  10031. }
  10032. else if(sep->IsNumber(3)) {
  10033. int8 param1 = atoul(sep->arg[1]);
  10034. int8 param2 = atoul(sep->arg[2]);
  10035. int8 paramval = atoul(sep->arg[3]);
  10036. client->Message(CHANNEL_COLOR_YELLOW, "Send control flag param1 %u param2 %u param value %u", param1, param2, paramval);
  10037. ClientPacketFunctions::SendServerControlFlags(client, param1, param2, paramval);
  10038. }
  10039. }
  10040. }
  10041. else {
  10042. PacketStruct* packet2 = configReader.getStruct("WS_ExamineSpellInfo", client->GetVersion());
  10043. if (packet2) {
  10044. packet2->setSubstructDataByName("info_header", "show_name", 1);
  10045. packet2->setSubstructDataByName("info_header", "unknown", 7);
  10046. packet2->setSubstructDataByName("info_header", "unknown2", 1);
  10047. packet2->setSubstructDataByName("info_header", "unknown3", 1);
  10048. packet2->setSubstructDataByName("info_header", "unknown4", 1);
  10049. packet2->setSubstructDataByName("info_header", "unknown5", 1);
  10050. packet2->setSubstructDataByName("info_header", "unknown6", "Testing");
  10051. packet2->setSubstructDataByName("info_header", "unknown7", "Testing");
  10052. packet2->setSubstructDataByName("info_header", "unknown8", 66);
  10053. packet2->setSubstructDataByName("info_header", "title", "Blah Title Blah");
  10054. packet2->setSubstructDataByName("info_header", "title_text", "Blah Blah");
  10055. packet2->setSubstructDataByName("info_header", "title_text2", "Blah Blah2");
  10056. packet2->setSubstructDataByName("info_header", "show_popup", 1);
  10057. packet2->setSubstructDataByName("info_header", "packettype", 3);
  10058. packet2->setSubstructDataByName("spell_info", "skill_name", "Testing");
  10059. packet2->setSubstructDataByName("spell_info", "level", 19);
  10060. packet2->setSubstructDataByName("spell_info", "tier", 1);
  10061. packet2->setSubstructDataByName("spell_info", "health_cost", 5);
  10062. packet2->setSubstructDataByName("spell_info", "min_class_skill_req", 3);
  10063. packet2->setSubstructDataByName("spell_info", "mana_cost", 6);
  10064. packet2->setSubstructDataByName("spell_info", "req_concentration", 7);
  10065. packet2->setSubstructDataByName("spell_info", "cast_time", 200);
  10066. packet2->setSubstructDataByName("spell_info", "recovery", 220);
  10067. packet2->setSubstructDataByName("spell_info", "recast", 280);
  10068. packet2->setSubstructDataByName("spell_info", "beneficial", 1);
  10069. packet2->setSubstructDataByName("spell_info", "maintained", 1);
  10070. packet2->setSubstructDataByName("spell_info", "spell_book_type", 1);
  10071. packet2->setSubstructDataByName("spell_info", "quality", 3);
  10072. packet2->setSubstructDataByName("spell_info", "test_1a", 1);
  10073. packet2->setSubstructDataByName("spell_info", "test_1b", 1);
  10074. packet2->setSubstructDataByName("spell_info", "test_1c", 1);
  10075. packet2->setSubstructDataByName("spell_info", "test_1d", 1);
  10076. packet2->setSubstructDataByName("spell_info", "test_2a", 2);
  10077. packet2->setSubstructDataByName("spell_info", "test_2b", 2);
  10078. packet2->setSubstructDataByName("spell_info", "test_2c", 2);
  10079. packet2->setSubstructDataByName("spell_info", "test_2d", 2);
  10080. packet2->setSubstructDataByName("spell_info", "test_3", 3);
  10081. packet2->setSubstructDataByName("spell_info", "test_4", 4);
  10082. packet2->setSubstructDataByName("spell_info", "test_5", 5);
  10083. packet2->setSubstructDataByName("spell_info", "test_6", 6);
  10084. packet2->setSubstructDataByName("spell_info", "min_class_skill_req", 1);
  10085. packet2->setSubstructDataByName("spell_info", "min_class_skill_rec", 30123);
  10086. packet2->setSubstructDataByName("spell_info", "num_reagents", 1);
  10087. packet2->setSubstructArrayLengthByName("spell_info", "num_reagents", 1);
  10088. packet2->setArrayDataByName("reagent", "Alcohol");
  10089. packet2->setArrayDataByName("consumed", "123");
  10090. packet2->setSubstructDataByName("spell_info", "class_skill", 52);
  10091. packet2->setSubstructDataByName("spell_info", "id", 8308);
  10092. packet2->setSubstructDataByName("spell_info", "icon", 303);
  10093. packet2->setSubstructDataByName("spell_info", "icon2", 0xFFFF);
  10094. packet2->setSubstructDataByName("spell_info", "icontype", 317);
  10095. packet2->setSubstructDataByName("spell_info", "type", 2);
  10096. packet2->setSubstructDataByName("spell_info", "spell_text_color", 255);
  10097. packet2->setSubstructDataByName("spell_info", "duration1", 600);
  10098. packet2->setSubstructDataByName("spell_info", "duration2", 600);
  10099. packet2->setSubstructDataByName("spell_info", "name", "Sprint");
  10100. packet2->setSubstructDataByName("spell_info", "description", "Test description");
  10101. EQ2Packet* outapp = packet2->serialize();
  10102. DumpPacket(outapp);
  10103. client->QueuePacket(outapp);
  10104. safe_delete(packet2);
  10105. }
  10106. }
  10107. return;
  10108. PacketStruct* p = configReader.getStruct("WS_EqTargetItemCmd", client->GetVersion());
  10109. if (!p) return;
  10110. //Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  10111. //client->GetCurrentZone()->SendSpellFailedPacket(client, atoi(sep2->arg[0]));
  10112. //}
  10113. /*Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  10114. if (sep2 && sep2->arg[0] && sep2->IsNumber(0)) {
  10115. client->SetPendingFlightPath(atoi(sep2->arg[0]));
  10116. PacketStruct* packet = configReader.getStruct("WS_ReadyForTakeOff", client->GetVersion());
  10117. if (packet) {
  10118. client->QueuePacket(packet->serialize());
  10119. safe_delete(packet);
  10120. }
  10121. }*/
  10122. /*if (client->GetCurrentZone()->Grid != nullptr) {
  10123. int32 numFaces = 0;
  10124. int32 numGrids = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.size();
  10125. client->Message(CHANNEL_COLOR_YELLOW, "Num grids in cell: %u", numGrids);
  10126. map<int32, vector<Face*> >::iterator itr;
  10127. for (itr = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.begin(); itr != client->GetPlayer()->Cell_Info.CurrentCell->FaceList.end(); itr++)
  10128. numFaces += (*itr).second.size();
  10129. client->Message(CHANNEL_COLOR_YELLOW, "Num faces in cell: %u", numFaces);
  10130. }*/
  10131. //uchar blah[] = {
  10132. // 1208 - OP_EQUpdateStoreCmd
  10133. // /*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
  10134. // /*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
  10135. // 1193 - -- OP_ClientCmdMsg::OP_EqUpdateMerchantCmd --
  10136. // /*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
  10137. /*};
  10138. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  10139. int8 val = 0;
  10140. int16 pos = 0;
  10141. int idx = 0;
  10142. while(sep2 && sep2->arg[idx+1] && sep2->IsNumber(idx) && sep2->IsNumber(idx+1)){
  10143. pos = atoi(sep2->arg[idx]);
  10144. val = atoi(sep2->arg[idx+1]);
  10145. memset(blah+pos, val, 1);
  10146. idx+=2;
  10147. }
  10148. DumpPacket(blah, sizeof(blah));
  10149. client->QueuePacket(new EQ2Packet(OP_GroupCreatedMsg , blah, sizeof(blah)));*/
  10150. if (client->GetPlayer()->GetTarget()) {
  10151. PacketStruct* packet = configReader.getStruct("WS_SetControlGhost", client->GetVersion());
  10152. if (packet) {
  10153. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  10154. packet->setDataByName("size", 0);
  10155. packet->setDataByName("unknown2", 0);
  10156. EQ2Packet* app = packet->serialize();
  10157. client->QueuePacket(app);
  10158. safe_delete(packet);
  10159. }
  10160. PacketStruct* set_pov = configReader.getStruct("WS_SetPOVGhostCmd", client->GetVersion());
  10161. if (set_pov) {
  10162. set_pov->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  10163. EQ2Packet* app_pov = set_pov->serialize();
  10164. client->QueuePacket(app_pov);
  10165. safe_delete(set_pov);
  10166. }
  10167. }
  10168. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  10169. PacketStruct* packet = configReader.getStruct("WS_OpenCharCust", client->GetVersion());
  10170. if (packet) {
  10171. if (sep2 && sep2->arg[0] && sep2->IsNumber(0))
  10172. packet->setDataByName("Type", atoi(sep2->arg[0]));
  10173. else
  10174. packet->setDataByName("Type", 2);
  10175. if (sep2 && sep2->arg[1] && sep2->IsNumber(1))
  10176. packet->setDataByName("race_id", atoi(sep2->arg[1]));
  10177. else
  10178. packet->setDataByName("race_id", 0);
  10179. if (sep2 && sep2->arg[2] && sep2->IsNumber(2))
  10180. packet->setDataByName("gender", atoi(sep2->arg[2]));
  10181. else
  10182. packet->setDataByName("gender", 2);
  10183. if (sep2 && sep2->arg[3] && sep2->IsNumber(3))
  10184. packet->setDataByName("unknown", atoi(sep2->arg[3]), 0);
  10185. else
  10186. packet->setDataByName("unknown", 0, 0);
  10187. if (sep2 && sep2->arg[4] && sep2->IsNumber(4))
  10188. packet->setDataByName("unknown", atoi(sep2->arg[4]), 1);
  10189. else
  10190. packet->setDataByName("unknown", 0, 1);
  10191. if (sep2 && sep2->arg[5] && sep2->IsNumber(5))
  10192. packet->setDataByName("unknown", atoi(sep2->arg[5]), 2);
  10193. else
  10194. packet->setDataByName("unknown", 0, 2);
  10195. client->QueuePacket(packet->serialize());
  10196. }
  10197. safe_delete(packet);
  10198. safe_delete(sep2);
  10199. }
  10200. void Commands::Command_LeaveChannel(Client *client, Seperator *sep) {
  10201. const char *channel_name;
  10202. if (sep == NULL || !sep->IsSet(0)) {
  10203. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /leavechat <channel name>");
  10204. PrintSep(sep);
  10205. return;
  10206. }
  10207. channel_name = sep->arg[0];
  10208. if (!chat.IsInChannel(client, channel_name))
  10209. client->Message(CHANNEL_NARRATIVE, "Unable to leave '%s': You are not in the channel.", channel_name);
  10210. else if (!chat.LeaveChannel(client, channel_name))
  10211. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an internal error preventing you from leaving that channel MUAHAHA");
  10212. }
  10213. /*
  10214. Function:
  10215. Purpose :
  10216. Params :
  10217. Dev :
  10218. Example :
  10219. */
  10220. void Commands::Command_WeaponStats(Client* client)
  10221. {
  10222. Player* player = client->GetPlayer();
  10223. Spawn* target = player->GetTarget();
  10224. Item* primary = player->GetEquipmentList()->GetItem(EQ2_PRIMARY_SLOT);
  10225. Item* secondary = player->GetEquipmentList()->GetItem(EQ2_SECONDARY_SLOT);
  10226. Item* ranged = player->GetEquipmentList()->GetItem(EQ2_RANGE_SLOT);
  10227. const char* charName = player->GetName();
  10228. if(target && target->IsEntity()) {
  10229. primary = ((Entity*)target)->GetEquipmentList()->GetItem(EQ2_PRIMARY_SLOT);
  10230. secondary = ((Entity*)target)->GetEquipmentList()->GetItem(EQ2_SECONDARY_SLOT);
  10231. ranged = ((Entity*)target)->GetEquipmentList()->GetItem(EQ2_RANGE_SLOT);
  10232. charName = target->GetName();
  10233. }
  10234. else {
  10235. target = nullptr;
  10236. }
  10237. client->Message(0, "WeaponStats for %s", charName);
  10238. client->SimpleMessage(0, "Primary:");
  10239. if (primary) {
  10240. client->Message(0, "Name: %s", primary->name.c_str());
  10241. client->Message(0, "Base Damage: %u - %u", primary->weapon_info->damage_low3, primary->weapon_info->damage_high3);
  10242. client->Message(0, "Actual Damage: %u - %u", target ? ((Entity*)target)->GetPrimaryWeaponMinDamage() : player->GetPrimaryWeaponMinDamage(),
  10243. target ? ((Entity*)target)->GetPrimaryWeaponMaxDamage() : player->GetPrimaryWeaponMaxDamage());
  10244. client->Message(0, "Actual Delay: %u", target ? ((Entity*)target)->GetPrimaryWeaponDelay() : player->GetPrimaryWeaponDelay());
  10245. client->Message(0, "Proc Percent: %d%%", 0);
  10246. client->Message(0, "Procs Per Minute: %d", 0);
  10247. }
  10248. else {
  10249. client->SimpleMessage(0, "Name: fist");
  10250. client->Message(0, "Base Damage: %u - %u", target ? ((Entity*)target)->GetPrimaryWeaponMinDamage() : player->GetPrimaryWeaponMinDamage(),
  10251. target ? ((Entity*)target)->GetPrimaryWeaponMaxDamage() : player->GetPrimaryWeaponMaxDamage());
  10252. client->Message(0, "Actual Damage: %u - %u", target ? ((Entity*)target)->GetPrimaryWeaponMinDamage() : player->GetPrimaryWeaponMinDamage(),
  10253. target ? ((Entity*)target)->GetPrimaryWeaponMaxDamage() : player->GetPrimaryWeaponMaxDamage());
  10254. client->Message(0, "Actual Delay: %d", target ? ((Entity*)target)->GetPrimaryWeaponDelay() : player->GetPrimaryWeaponDelay() * 0.1);
  10255. client->Message(0, "Proc Percent: %d%%", 0);
  10256. client->Message(0, "Procs Per Minute: %d", 0);
  10257. }
  10258. client->SimpleMessage(0, " ");
  10259. client->SimpleMessage(0, " ");
  10260. if (secondary) {
  10261. client->SimpleMessage(0, "Secondary:");
  10262. client->Message(0, "Name: %s", secondary->name.c_str());
  10263. client->Message(0, "Base Damage: %u - %u", secondary->weapon_info->damage_low3, secondary->weapon_info->damage_high3);
  10264. client->Message(0, "Actual Damage: %u - %u", target ? ((Entity*)target)->GetSecondaryWeaponMinDamage() : player->GetSecondaryWeaponMinDamage(),
  10265. target ? ((Entity*)target)->GetSecondaryWeaponMaxDamage() : player->GetSecondaryWeaponMaxDamage());
  10266. client->Message(0, "Actual Delay: %d", target ? ((Entity*)target)->GetSecondaryWeaponDelay() : player->GetSecondaryWeaponDelay() * 0.1);
  10267. client->Message(0, "Proc Percent: %d%%", 0);
  10268. client->Message(0, "Procs Per Minute: %d", 0);
  10269. client->SimpleMessage(0, " ");
  10270. client->SimpleMessage(0, " ");
  10271. }
  10272. client->SimpleMessage(0, "Ranged:");
  10273. if (ranged) {
  10274. client->Message(0, "Name: %s", ranged->name.c_str());
  10275. client->Message(0, "Base Damage: %u - %u", ranged->ranged_info->weapon_info.damage_low3, ranged->ranged_info->weapon_info.damage_high3);
  10276. client->Message(0, "Actual Damage: %u - %u", target ? ((Entity*)target)->GetRangedWeaponMinDamage() : player->GetRangedWeaponMinDamage(),
  10277. target ? ((Entity*)target)->GetRangedWeaponMaxDamage() : player->GetRangedWeaponMaxDamage());
  10278. client->Message(0, "Actual Delay: %d", target ? ((Entity*)target)->GetRangeWeaponDelay() : player->GetRangeWeaponDelay() * 0.1);
  10279. client->Message(0, "Proc Percent: %d%%", 0);
  10280. client->Message(0, "Procs Per Minute: %d", 0);
  10281. }
  10282. else
  10283. client->SimpleMessage(0, "None");
  10284. }
  10285. void Commands::Command_WhoChannel(Client *client, Seperator *sep) {
  10286. const char *channel_name;
  10287. if (sep == NULL || !sep->IsSet(0)) {
  10288. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /chatwho <channel name>");
  10289. return;
  10290. }
  10291. channel_name = sep->arg[0];
  10292. if (!chat.ChannelExists(channel_name))
  10293. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That channel does not exist!");
  10294. else
  10295. chat.SendChannelUserList(client, channel_name);
  10296. }
  10297. void Commands::Command_ZoneSafeCoords(Client *client, Seperator *sep)
  10298. {
  10299. ZoneServer* zone = 0;
  10300. int32 zone_id = client->GetPlayer()->GetZone()->GetZoneID();
  10301. if (zone_id > 0)
  10302. {
  10303. zone = zone_list.Get(zone_id, false, false, false);
  10304. if (zone)
  10305. {
  10306. zone->SetSafeX(client->GetPlayer()->GetX());
  10307. zone->SetSafeY(client->GetPlayer()->GetY());
  10308. zone->SetSafeZ(client->GetPlayer()->GetZ());
  10309. zone->SetSafeHeading(client->GetPlayer()->GetHeading());
  10310. if( database.SaveZoneSafeCoords(zone_id, zone->GetSafeX(), zone->GetSafeY(), zone->GetSafeZ(), zone->GetSafeHeading()) )
  10311. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Zone safe coordinates updated!");
  10312. else
  10313. client->SimpleMessage(CHANNEL_COLOR_RED, "FAILED to update zone safe coordinates!");
  10314. }
  10315. }
  10316. }
  10317. /*
  10318. Function:
  10319. Purpose :
  10320. Params :
  10321. Dev :
  10322. Example :
  10323. */
  10324. void Commands::Command_ZoneDetails(Client* client, Seperator* sep)
  10325. {
  10326. ZoneInfo* zone_info = new ZoneInfo;
  10327. if (sep && sep->arg[0])
  10328. {
  10329. if (sep->IsNumber(0))
  10330. zone_info->id = atoi(sep->arg[0]);
  10331. else
  10332. zone_info->id = database.GetZoneID(sep->arg[0]);
  10333. if (zone_info->id > 0)
  10334. {
  10335. database.LoadZoneInfo(zone_info);
  10336. 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);
  10337. 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);
  10338. 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);
  10339. 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);
  10340. 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);
  10341. 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);
  10342. 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);
  10343. client->Message(CHANNEL_COLOR_YELLOW, "zone_type: %s, sky_file: %s", zone_info->zone_type, zone_info->sky_file);
  10344. client->Message(CHANNEL_COLOR_YELLOW, "lua_script: %s", zone_info->lua_script);
  10345. client->Message(CHANNEL_COLOR_YELLOW, "zone_motd: %s", zone_info->zone_motd);
  10346. }
  10347. else
  10348. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  10349. }
  10350. else
  10351. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone details [zone id|zone name]");
  10352. safe_delete(zone_info);
  10353. }
  10354. /*
  10355. Function:
  10356. Purpose :
  10357. Params :
  10358. Dev :
  10359. Example :
  10360. */
  10361. void Commands::Command_ZoneSet(Client* client, Seperator* sep)
  10362. {
  10363. if (sep && sep->arg[0] && sep->arg[1] && sep->arg[2])
  10364. {
  10365. ZoneServer* zone = 0;
  10366. int32 zone_id = 0;
  10367. if (sep->IsNumber(0) && atoi(sep->arg[0]) > 0)
  10368. {
  10369. zone_id = atoi(sep->arg[0]);
  10370. zone = zone_list.Get(atoi(sep->arg[0]), false, false, false);
  10371. }
  10372. else
  10373. {
  10374. zone_id = database.GetZoneID(sep->arg[0]);
  10375. if (zone_id > 0)
  10376. zone = zone_list.Get(sep->arg[0], false, false, false);
  10377. }
  10378. if (zone_id > 0)
  10379. {
  10380. if (zone_set_values.count(string(sep->arg[1])) > 0)
  10381. SetZoneCommand(client, zone_id, zone, zone_set_values[sep->arg[1]], sep->arg[2]);
  10382. else
  10383. client->Message(CHANNEL_COLOR_YELLOW, "The attribute '%s' is not valid.", sep->arg[1]);
  10384. }
  10385. else
  10386. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  10387. }
  10388. else
  10389. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone set [zone id|zone name] [attribute] [value]");
  10390. }
  10391. void Commands::Command_Rain(Client* client, Seperator* sep) {
  10392. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  10393. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /rain <float>");
  10394. return;
  10395. }
  10396. client->Message(CHANNEL_COLOR_YELLOW,"Setting rain to %.2f", atof(sep->arg[0]));
  10397. client->GetCurrentZone()->SetRain(atof(sep->arg[0]));
  10398. client->GetCurrentZone()->SetCurrentWeather(atof(sep->arg[0]));
  10399. }
  10400. void Commands::Command_Wind(Client* client, Seperator* sep) {
  10401. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  10402. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /wind <float>");
  10403. return;
  10404. }
  10405. client->Message(CHANNEL_COLOR_YELLOW, "Setting wind to %.2f", atof(sep->arg[0]));
  10406. client->GetCurrentZone()->SetWind(atof(sep->arg[0]));
  10407. }
  10408. void Commands::Command_SendMerchantWindow(Client* client, Seperator* sep, bool sell) {
  10409. Spawn* spawn = client->GetPlayer()->GetTarget();
  10410. if(client->GetVersion() <= 546) {
  10411. sell = false; // doesn't support in the same way as AoM just open the normal buy/sell window
  10412. }
  10413. if(spawn) {
  10414. client->SetMerchantTransaction(spawn);
  10415. if (spawn->GetMerchantID() > 0 && spawn->IsClientInMerchantLevelRange(client)){
  10416. client->SendHailCommand(spawn);
  10417. //MerchantFactionMultiplier* multiplier = world.GetMerchantMultiplier(spawn->GetMerchantID());
  10418. //if(!multiplier || (multiplier && client->GetPlayer()->GetFactions()->GetFactionValue(multiplier->faction_id) >= multiplier->faction_min)){
  10419. client->SendBuyMerchantList(sell);
  10420. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY))
  10421. client->SendSellMerchantList(sell);
  10422. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY_BACK))
  10423. client->SendBuyBackList(sell);
  10424. PacketStruct* packet = configReader.getStruct("WS_UpdateMerchant", client->GetVersion());
  10425. if (packet) {
  10426. packet->setDataByName("spawn_id", 0xFFFFFFFF);
  10427. packet->setDataByName("type", 16);
  10428. EQ2Packet* outapp = packet->serialize();
  10429. if (outapp)
  10430. client->QueuePacket(outapp);
  10431. safe_delete(packet);
  10432. }
  10433. }
  10434. if (spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR)
  10435. client->SendRepairList();
  10436. }
  10437. // client->SimpleMessage(CHANNEL_COLOR_RED, "Your faction is too low to use this merchant.");
  10438. }
  10439. void Commands::Command_Weather(Client* client, Seperator* sep)
  10440. {
  10441. //PrintSep(sep, "Weather");
  10442. if( sep && sep->arg[0] )
  10443. {
  10444. ZoneServer* zsZone = client->GetCurrentZone();
  10445. const char* value = sep->arg[0];
  10446. // process single-param commands first
  10447. if( strncasecmp(value, "details", strlen(value)) == 0 )
  10448. {
  10449. client->Message(CHANNEL_COLOR_YELLOW, "Weather Details for zone %s: ", zsZone->GetZoneName());
  10450. client->Message(CHANNEL_COLOR_YELLOW, "enabled: %i, allowed: %i, type: %i, frequency: %u", zsZone->isWeatherEnabled(), zsZone->isWeatherAllowed(), zsZone->GetWeatherType(), zsZone->GetWeatherFrequency());
  10451. client->Message(CHANNEL_COLOR_YELLOW, "severity: %.2f = %.2f, current: %.2f", zsZone->GetWeatherMinSeverity(), zsZone->GetWeatherMaxSeverity(), zsZone->GetCurrentWeather());
  10452. client->Message(CHANNEL_COLOR_YELLOW, "pattern: %i, chance: %i, amount: %.2f, offset: %.2f", zsZone->GetWeatherPattern(), zsZone->GetWeatherChance(), zsZone->GetWeatherChangeAmount(), zsZone->GetWeatherDynamicOffset());
  10453. }
  10454. else if( strncasecmp(value, "process", strlen(value)) == 0 )
  10455. {
  10456. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  10457. zsZone->ProcessWeather();
  10458. }
  10459. else if( strncasecmp(value, "reset", strlen(value)) == 0 )
  10460. {
  10461. zsZone->SetWeatherType(rule_manager.GetGlobalRule(R_Zone, WeatherType)->GetInt8());
  10462. zsZone->SetWeatherFrequency(rule_manager.GetGlobalRule(R_Zone, WeatherChangeFrequency)->GetInt32());
  10463. zsZone->SetWeatherMinSeverity(rule_manager.GetGlobalRule(R_Zone, MinWeatherSeverity)->GetFloat());
  10464. zsZone->SetWeatherMaxSeverity(rule_manager.GetGlobalRule(R_Zone, MaxWeatherSeverity)->GetFloat());
  10465. zsZone->SetCurrentWeather(zsZone->GetWeatherMinSeverity());
  10466. zsZone->SetWeatherPattern(1);
  10467. zsZone->SetWeatherChance(rule_manager.GetGlobalRule(R_Zone, WeatherChangeChance)->GetInt8());
  10468. zsZone->SetWeatherChangeAmount(rule_manager.GetGlobalRule(R_Zone, WeatherChangePerInterval)->GetFloat());
  10469. zsZone->SetWeatherDynamicOffset(rule_manager.GetGlobalRule(R_Zone, WeatherDynamicMaxOffset)->GetFloat());
  10470. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  10471. zsZone->ProcessWeather();
  10472. }
  10473. // process commands with params
  10474. if( sep->arg[1] )
  10475. {
  10476. if( strncasecmp(value, "enable", strlen(value)) == 0 && sep->IsNumber(1) )
  10477. zsZone->SetWeatherEnabled( ( atoi(sep->arg[1]) == 1 ) ? true : false );
  10478. else if( strncasecmp(value, "type", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 3) )
  10479. zsZone->SetWeatherType(atoi(sep->arg[1]));
  10480. else if( strncasecmp(value, "frequency", strlen(value)) == 0 && sep->IsNumber(1))
  10481. zsZone->SetWeatherFrequency( atoul(sep->arg[1]) );
  10482. else if( strncasecmp(value, "range", strlen(value)) == 0 && sep->IsNumber(1) && sep->IsNumber(2) ) {
  10483. zsZone->SetWeatherMinSeverity(atof(sep->arg[1]));
  10484. zsZone->SetWeatherMaxSeverity(atof(sep->arg[2]));
  10485. zsZone->SetRain(zsZone->GetWeatherMinSeverity());
  10486. }
  10487. else if( strncasecmp(value, "current", strlen(value)) == 0 && sep->IsNumber(1) ) {
  10488. zsZone->SetCurrentWeather(atof(sep->arg[1]));
  10489. zsZone->SetRain(zsZone->GetCurrentWeather());
  10490. }
  10491. else if( strncasecmp(value, "pattern", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 2) )
  10492. zsZone->SetWeatherPattern( atoi(sep->arg[1]) );
  10493. else if( strncasecmp(value, "chance", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 100) )
  10494. zsZone->SetWeatherChance( atoi(sep->arg[1]) );
  10495. else if( strncasecmp(value, "amount", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  10496. zsZone->SetWeatherChangeAmount( atof(sep->arg[1]) );
  10497. else if( strncasecmp(value, "offset", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  10498. zsZone->SetWeatherDynamicOffset( atof(sep->arg[1]) );
  10499. }
  10500. }
  10501. else
  10502. {
  10503. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /weather [command] [param]");
  10504. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: enable (0|1), type (0-3), frequency (sec), range|current (0.0 - 1.0)");
  10505. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: details, process, pattern (0|1), chance (%), amount (float), offset (float)");
  10506. return;
  10507. }
  10508. }
  10509. void Commands::Command_Select(Client* client, Seperator* sep) {
  10510. if (sep && sep->arg[1]) {
  10511. Spawn* spawn = client->GetPlayer()->GetTarget();
  10512. if (spawn && strlen(sep->arg[1]) > 0)
  10513. client->GetCurrentZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_CUSTOM, client->GetPlayer(), sep->arg[1]);
  10514. }
  10515. }
  10516. /*
  10517. Function: Command_ConsumeFood()
  10518. Purpose : Consume Food/Drink and apply mods
  10519. Params : Slot ID - EQ2_FOOD_SLOT 22, EQ2_DRINK_SLOT 23
  10520. Dev : Zcoretri
  10521. Example : /consume_food 22
  10522. */
  10523. void Commands::Command_ConsumeFood(Client* client, Seperator* sep) {
  10524. if (sep && sep->arg[0] && sep->IsNumber(0))
  10525. {
  10526. Player* player = client->GetPlayer();
  10527. int8 slot = atoi(sep->arg[0]);
  10528. if (client->GetVersion() <= 283) {
  10529. slot += 4;
  10530. }
  10531. else if (client->GetVersion() <= 546) {
  10532. slot += 2;
  10533. }
  10534. Item* item = player->GetEquipmentList()->GetItem(slot);
  10535. if(client->CheckConsumptionAllowed(slot)) {
  10536. client->ConsumeFoodDrink(item, slot);
  10537. }
  10538. }
  10539. }
  10540. void Commands::Command_Aquaman(Client* client, Seperator* sep) {
  10541. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  10542. if (atoi(sep->arg[0]) == 1) {
  10543. client->GetPlayer()->GetInfoStruct()->set_vision(4);
  10544. client->GetPlayer()->GetInfoStruct()->set_breathe_underwater(1);
  10545. client->GetPlayer()->SetCharSheetChanged(true);
  10546. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Maybe you ought to stick to the shallow end until you know how to swim.");
  10547. }
  10548. else {
  10549. client->GetPlayer()->GetInfoStruct()->set_vision(0);
  10550. client->GetPlayer()->GetInfoStruct()->set_breathe_underwater(0);
  10551. client->GetPlayer()->SetCharSheetChanged(true);
  10552. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Aquaman mode turned off.");
  10553. }
  10554. }
  10555. else
  10556. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /aquaman [0|1]");
  10557. }
  10558. void Commands::Command_ReportBug(Client* client, Seperator* sep)
  10559. {
  10560. if(sep)
  10561. {
  10562. string data;
  10563. if(sep->arg[0]){
  10564. data = string(sep->arg[0]);
  10565. }
  10566. for(int i=1;i<sep->GetMaxArgNum();i++){
  10567. if(sep->arg[i])
  10568. data.append(" ").append(sep->arg[i]);
  10569. }
  10570. const char* target_name = 0;
  10571. int32 spawn_id = 0;
  10572. if(client->GetPlayer()->GetTarget())
  10573. {
  10574. target_name = client->GetPlayer()->GetTarget()->GetName();
  10575. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  10576. }
  10577. else
  10578. target_name = "N/A";
  10579. LogWrite(COMMAND__DEBUG, 1, "Command", "%s", data.c_str());
  10580. if(world.ReportBug(data, client->GetPlayer()->GetName(), client->GetAccountID(), target_name, spawn_id, client->GetCurrentZone()->GetZoneID()))
  10581. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully submitted bug.");
  10582. else
  10583. client->SimpleMessage(CHANNEL_COLOR_RED, "Error submitting bug.");
  10584. }
  10585. }
  10586. void Commands::Command_Attune_Inv(Client* client, Seperator* sep) {
  10587. PrintSep(sep, "Command_Attune_Inv");
  10588. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  10589. // Get the item index from the first parameter
  10590. int16 index = atoi(sep->arg[0]);
  10591. // Check to see if this is a valid item index for the player, if not exit out of the function
  10592. if (client->GetPlayer()->item_list.indexed_items.count(index) == 0) {
  10593. LogWrite(ITEM__DEBUG, 0, "Items", "%s has no item with an index of %i", client->GetPlayer()->GetName(), index);
  10594. return;
  10595. }
  10596. // Get the item
  10597. Item* item = client->GetPlayer()->item_list.indexed_items[index];
  10598. if(item) {
  10599. // Valid item lets check to make sure this item is attunable, if not return out
  10600. if (!item->CheckFlag(ATTUNEABLE)) {
  10601. LogWrite(ITEM__DEBUG, 0, "Items", "attune_inv called for an item that is not attunable (%s)", item->name.c_str());
  10602. return;
  10603. }
  10604. // Remove the attunable flag
  10605. item->generic_info.item_flags -= ATTUNEABLE;
  10606. // Set the attuned flag
  10607. item->generic_info.item_flags += ATTUNED;
  10608. // Flag this item for saving
  10609. item->save_needed = true;
  10610. client->QueuePacket(item->serialize(client->GetVersion(), false, client->GetPlayer()));
  10611. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), 0, -1); // appearance type??
  10612. EQ2Packet* outapp = 0;
  10613. for (int32 i=0;i<packets.size();i++) {
  10614. outapp = packets[i];
  10615. if(outapp)
  10616. client->QueuePacket(outapp);
  10617. }
  10618. }
  10619. }
  10620. }
  10621. void Commands::Command_Reset_Zone_Timer(Client* client, Seperator* sep) {
  10622. PrintSep(sep, "Command_Reset_Zone_Timer");
  10623. /*if (sep && sep->arg[0] && sep->IsNumber(0)) {
  10624. int32 db_id = atoul(sep->arg[0]);
  10625. InstanceData* data = client->GetPlayer()->GetCharacterInstances().FindInstanceByDBID(db_id);
  10626. if (data) {
  10627. // TODO: add a check to timers to ensure it can be reset
  10628. // Delete the character from the instance
  10629. database.DeleteCharacterFromInstance(client->GetPlayer()->GetCharacterID(), data->instance_id);
  10630. data->instance_id = 0;
  10631. // Update the success time and set to 0 so the player can enter it again
  10632. database.UpdateCharacterInstance(client->GetPlayer()->GetCharacterID(), data->zone_name, 0, 1, 0);
  10633. data->last_success_timestamp = 0;
  10634. }
  10635. }*/
  10636. }
  10637. void Commands::Command_Player(Client* client, Seperator* sep) {
  10638. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player syntax --");
  10639. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins");
  10640. }
  10641. void Commands::Command_Player_Coins(Client* client, Seperator* sep) {
  10642. // /player coins add 10
  10643. // /player coins add plat 10
  10644. Player* player = client->GetPlayer();
  10645. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  10646. player = (Player*)player->GetTarget();
  10647. if (sep && sep->arg[0] && sep->arg[1]) {
  10648. const char* action = sep->arg[0];
  10649. int64 value = 0;
  10650. if (strncasecmp(action, "add", strlen(action)) == 0) {
  10651. if (sep->IsNumber(1)) {
  10652. value = atoi64(sep->arg[1]);
  10653. player->AddCoins(value);
  10654. if (client->GetPlayer() == player)
  10655. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  10656. else {
  10657. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  10658. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  10659. }
  10660. return;
  10661. }
  10662. else if (sep->arg[2] && sep->IsNumber(2)) {
  10663. const char* type = sep->arg[1];
  10664. if (strncasecmp(type, "copper", strlen(type)) == 0) {
  10665. value = atoi64(sep->arg[2]);
  10666. }
  10667. else if (strncasecmp(type, "silver", strlen(type)) == 0) {
  10668. value = atoi64(sep->arg[2]) * 100;
  10669. }
  10670. else if (strncasecmp(type, "gold", strlen(type)) == 0) {
  10671. value = atoi64(sep->arg[2]) * 10000;
  10672. }
  10673. else if (strncasecmp(type, "plat", strlen(type)) == 0) {
  10674. value = atoi64(sep->arg[2]) * 1000000;
  10675. }
  10676. player->AddCoins(value);
  10677. if (client->GetPlayer() == player)
  10678. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  10679. else {
  10680. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  10681. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  10682. }
  10683. return;
  10684. }
  10685. }
  10686. }
  10687. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player coins syntax --");
  10688. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add [value] - adds the given number of coins to the player");
  10689. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add copper [value] - adds the given amount of copper to the player");
  10690. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add silver [value] - adds the given amount of silver to the player");
  10691. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add gold [value] - adds the given amount of gold to the player");
  10692. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add plat [value] - adds the given amount of platinum to the player");
  10693. }
  10694. void Commands::Command_AchievementAdd(Client* client, Seperator* sep) {
  10695. PrintSep(sep, "ACHIEVEMENT_ADD");
  10696. if (sep && sep->IsSet(0)) {
  10697. int32 spell_id = atoul(sep->arg[1]);
  10698. int8 spell_tier = 0;
  10699. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  10700. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  10701. // addspellbookentry here
  10702. if (spell_tier >= data->maxRank) {
  10703. return;
  10704. }
  10705. if (!spell_tier) {
  10706. spell_tier = 1;
  10707. }
  10708. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  10709. {
  10710. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  10711. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  10712. client->GetPlayer()->UnlockSpell(spell);
  10713. client->SendSpellUpdate(spell);
  10714. }
  10715. else
  10716. {
  10717. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1);
  10718. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  10719. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  10720. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  10721. client->GetPlayer()->UnlockSpell(spell);
  10722. client->SendSpellUpdate(spell);
  10723. }
  10724. // cast spell here
  10725. if (!spell_tier)
  10726. spell_tier = 1;
  10727. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  10728. if (spell) {
  10729. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  10730. }
  10731. }
  10732. else {
  10733. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  10734. }
  10735. master_aa_list.DisplayAA(client, 0, 0);
  10736. }
  10737. void Commands::Command_Editor(Client* client, Seperator* sep) {
  10738. PacketStruct* packet = configReader.getStruct("WS_ChoiceWindow", client->GetVersion());
  10739. if (packet) {
  10740. string url = string(rule_manager.GetGlobalRule(R_World, EditorURL)->GetString());
  10741. if (rule_manager.GetGlobalRule(R_World, EditorOfficialServer)->GetBool()) {
  10742. char command[255];
  10743. url = "browser " + url;
  10744. int32 spawn_id = 0;
  10745. int32 zone_id = 0;
  10746. string type;
  10747. if (client->GetCurrentZone())
  10748. zone_id = client->GetCurrentZone()->GetZoneID();
  10749. if (client->GetPlayer()->GetTarget()) {
  10750. Spawn* target = client->GetPlayer()->GetTarget();
  10751. if (target->IsWidget())
  10752. type = "widgets";
  10753. else if (target->IsSign())
  10754. type = "signs";
  10755. else if (target->IsObject())
  10756. type = "objects";
  10757. else if (target->IsNPC())
  10758. type = "npcs";
  10759. else if (target->IsGroundSpawn())
  10760. type = "ground";
  10761. else
  10762. type = "spawn";
  10763. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  10764. }
  10765. sprintf(command, url.c_str(), zone_id, type.c_str(), spawn_id);
  10766. packet->setDataByName("accept_command", command);
  10767. }
  10768. else if (rule_manager.GetGlobalRule(R_World, EditorIncludeID)->GetBool()) {
  10769. char command[255];
  10770. url = "browser " + url;
  10771. if (client->GetPlayer()->GetTarget())
  10772. sprintf(command, url.c_str(), client->GetPlayer()->GetTarget()->GetDatabaseID());
  10773. packet->setDataByName("accept_command", command);
  10774. }
  10775. else {
  10776. string command = "browser " + url;
  10777. packet->setDataByName("accept_command", command.c_str());
  10778. }
  10779. packet->setDataByName("text", "Open the web editor?");
  10780. packet->setDataByName("accept_text", "Open");
  10781. packet->setDataByName("cancel_text", "Cancel");
  10782. // No clue if we even need the following 2 unknowns, just added them so the packet matches what live sends
  10783. packet->setDataByName("unknown2", 50);
  10784. packet->setDataByName("unknown4", 1);
  10785. client->QueuePacket(packet->serialize());
  10786. safe_delete(packet);
  10787. }
  10788. }
  10789. void Commands::Command_AcceptResurrection(Client* client, Seperator* sep) {
  10790. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  10791. return;
  10792. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  10793. if(client->GetCurrentRez()->active)
  10794. client->AcceptResurrection();
  10795. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  10796. }
  10797. void Commands::Command_DeclineResurrection(Client* client, Seperator* sep) {
  10798. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  10799. return;
  10800. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  10801. if(client->GetCurrentRez()->active)
  10802. client->GetCurrentRez()->should_delete = true;
  10803. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  10804. }
  10805. void Commands::Switch_AA_Profile(Client* client, Seperator* sep) {
  10806. PrintSep(sep, "Switch_AA_Profile");
  10807. if (sep && sep->IsSet(0)) {
  10808. string type = sep->arg[0];
  10809. int8 newtemplate = atoul(sep->arg[1]);
  10810. master_aa_list.DisplayAA(client, newtemplate, 1);
  10811. }
  10812. }
  10813. void Commands::Get_AA_Xml(Client* client, Seperator* sep) {
  10814. PrintSep(sep, "Get_AA_Xml");
  10815. if (sep && sep->IsSet(0)) {
  10816. string tabnum = sep->arg[0];
  10817. string spellid = sep->arg[1];
  10818. }
  10819. }
  10820. void Commands::Add_AA(Client* client, Seperator* sep) {
  10821. PrintSep(sep, "Add_AA");
  10822. if (sep && sep->IsSet(0)) {
  10823. int32 spell_id = atoul(sep->arg[1]);
  10824. int8 spell_tier = 0;
  10825. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  10826. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  10827. // addspellbookentry here
  10828. if(!data) {
  10829. LogWrite(COMMAND__ERROR, 0, "Command", "Error in Add_AA no data for spell_id %u spell_tier %u", spell_id, spell_tier);
  10830. return;
  10831. }
  10832. if (spell_tier >= data->maxRank) {
  10833. LogWrite(COMMAND__ERROR, 0, "Command", "Error in Add_AA spell_tier %u >= maxRank %u", spell_tier, data->maxRank);
  10834. return;
  10835. }
  10836. if (!spell_tier) {
  10837. spell_tier = 1;
  10838. }
  10839. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  10840. {
  10841. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  10842. if(spell)
  10843. {
  10844. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  10845. client->GetPlayer()->UnlockSpell(spell);
  10846. client->SendSpellUpdate(spell);
  10847. }
  10848. }
  10849. else
  10850. {
  10851. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1 );
  10852. if(spell)
  10853. {
  10854. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  10855. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  10856. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  10857. client->GetPlayer()->UnlockSpell(spell);
  10858. client->SendSpellUpdate(spell);
  10859. }
  10860. }
  10861. // cast spell here
  10862. if (!spell_tier)
  10863. spell_tier = 1;
  10864. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  10865. if (spell) {
  10866. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  10867. }
  10868. }
  10869. else {
  10870. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  10871. }
  10872. master_aa_list.DisplayAA(client, 0, 0);
  10873. }
  10874. void Commands::Commit_AA_Profile(Client* client, Seperator* sep) {
  10875. PrintSep(sep, "Commit_AA_Profile");
  10876. if (sep && sep->IsSet(0)) {
  10877. }
  10878. }
  10879. void Commands::Begin_AA_Profile(Client* client, Seperator* sep) {
  10880. PrintSep(sep, "Begin_AA_Profile");
  10881. if (sep && sep->IsSet(0)) {
  10882. master_aa_list.DisplayAA(client, 100, 2);
  10883. }
  10884. }
  10885. void Commands::Back_AA(Client* client, Seperator* sep) {
  10886. if (sep && sep->IsSet(0)) {
  10887. PrintSep(sep, "Back_AA");
  10888. }
  10889. }
  10890. void Commands::Remove_AA(Client* client, Seperator* sep) {
  10891. if (sep && sep->IsSet(0)) {
  10892. PrintSep(sep, "Remove_AA");
  10893. }
  10894. }
  10895. void Commands::Cancel_AA_Profile(Client* client, Seperator* sep) {
  10896. MasterAAList master_aa_list;
  10897. PrintSep(sep, "Cancel_AA_Profile");
  10898. master_aa_list.DisplayAA(client, 0, 0);
  10899. }
  10900. void Commands::Save_AA_Profile(Client* client, Seperator* sep) {
  10901. if (sep && sep->IsSet(0)) {
  10902. PrintSep(sep, "Save_AA_Profile");
  10903. }
  10904. }
  10905. void Commands::Command_TargetItem(Client* client, Seperator* sep) {
  10906. if (!sep || sep->GetArgNumber() < 1 || !client->GetPlayer()) return;
  10907. if (!sep->IsNumber(0)) return;
  10908. int32 request_id = atoul(sep->arg[0]);
  10909. if (!sep->IsNumber(1)) return;
  10910. sint32 item_id = atoi(sep->arg[1]);
  10911. if (client->IsCurrentTransmuteID(request_id)) {
  10912. Transmute::HandleItemResponse(client, client->GetPlayer(), request_id, reinterpret_cast<int32&>(item_id));
  10913. }
  10914. else if (client->IsCurrentTransmuteID(item_id)) {
  10915. if (!sep->IsSet(2)) return;
  10916. if (sep->IsNumber(2) && atoi(sep->arg[2]) == 1) {
  10917. Transmute::HandleConfirmResponse(client, client->GetPlayer(), reinterpret_cast<int32&>(item_id));
  10918. }
  10919. }
  10920. }
  10921. void Commands::Command_FindSpawn(Client* client, Seperator* sep) {
  10922. if(sep)
  10923. client->GetCurrentZone()->FindSpawn(client, (char*)sep->argplus[0]);
  10924. }
  10925. void Commands::Command_MoveCharacter(Client* client, Seperator* sep) {
  10926. if(sep && sep->arg[0][0] && sep->arg[1][0])
  10927. {
  10928. char* name = sep->arg[0];
  10929. char* zoneName = sep->arg[1];
  10930. char query[256];
  10931. 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);
  10932. if (database.RunQuery(query, strnlen(query, 256)))
  10933. {
  10934. client->Message(CHANNEL_COLOR_YELLOW, "Ran query:%s", query);
  10935. }
  10936. else
  10937. client->Message(CHANNEL_COLOR_RED, "Query FAILED to run: %s", query);
  10938. }
  10939. }
  10940. void Commands::Command_Mood(Client* client, Seperator* sep) {
  10941. Player* player = client->GetPlayer();
  10942. if( sep && sep->arg[0] )
  10943. {
  10944. const char* value = sep->arg[0];
  10945. InfoStruct* info = player->GetInfoStruct();
  10946. int32 cid = client->GetCharacterID();
  10947. char* characterName = database.GetCharacterName(cid);
  10948. char tmp[1024]; // our emote string "xyz appears zyx"
  10949. //char properties vals
  10950. char* pname = "mood";
  10951. char* pval; // mood value
  10952. bool pt; //used to verify return from DB.
  10953. //This should never be seen.
  10954. sprintf(tmp, " ");
  10955. if( strncasecmp(value, "angry", strlen(value)) == 0 )
  10956. {
  10957. sprintf(tmp, "%s appears angry", characterName);
  10958. pval = "11852";
  10959. player->SetMoodState(11852, 1);
  10960. info->set_mood(11852);
  10961. pt = database.insertCharacterProperty(client, pname, pval);
  10962. }
  10963. else if( strncasecmp(value, "afraid", strlen(value)) == 0 )
  10964. {
  10965. sprintf(tmp, "%s appears afraid", characterName);
  10966. pval = "11851";
  10967. player->SetMoodState(11851, 1);
  10968. info->set_mood(11851);
  10969. pt = database.insertCharacterProperty(client, pname, pval);
  10970. }
  10971. else if( strncasecmp(value, "happy", strlen(value)) == 0 )
  10972. {
  10973. sprintf(tmp, "%s appears happy", characterName);
  10974. pval = "11854";
  10975. player->SetMoodState(11854, 1);
  10976. info->set_mood(11854);
  10977. pt = database.insertCharacterProperty(client, pname, pval);
  10978. }
  10979. else if( strncasecmp(value, "sad", strlen(value)) == 0 ) {
  10980. sprintf(tmp, "%s appears sad", characterName);
  10981. pval = "11856";
  10982. player->SetMoodState(11856, 1);
  10983. info->set_mood(11856);
  10984. pt = database.insertCharacterProperty(client, pname, pval);
  10985. }
  10986. else if( strncasecmp(value, "tired", strlen(value)) == 0 )
  10987. {
  10988. sprintf(tmp, "%s appears tired", characterName);
  10989. pval = "11857";
  10990. player->SetMoodState(11857, 1);
  10991. info->set_mood(11857);
  10992. pt = database.insertCharacterProperty(client, pname, pval);
  10993. }
  10994. else if( strncasecmp(value, "none", strlen(value)) == 0 )
  10995. {
  10996. //using 11855 mood_idle for none, I assume thats what its for?
  10997. pval = "11855";
  10998. player->SetMoodState(11855, 1);
  10999. info->set_mood(11855);
  11000. pt = database.insertCharacterProperty(client, pname, pval);
  11001. //return since we have nothing left to do. No emote for none.
  11002. return;
  11003. }else{
  11004. client->SimpleMessage(CHANNEL_NARRATIVE, "Listing Available Moods:");
  11005. client->SimpleMessage(CHANNEL_NARRATIVE, "none");
  11006. client->SimpleMessage(CHANNEL_NARRATIVE, "afraid");
  11007. client->SimpleMessage(CHANNEL_NARRATIVE, "angry");
  11008. client->SimpleMessage(CHANNEL_NARRATIVE, "happy");
  11009. client->SimpleMessage(CHANNEL_NARRATIVE, "sad");
  11010. client->SimpleMessage(CHANNEL_NARRATIVE, "tired");
  11011. return;
  11012. }
  11013. client->GetPlayer()->GetZone()->HandleChatMessage(0, 0, CHANNEL_EMOTE, tmp);
  11014. return;
  11015. }
  11016. client->SimpleMessage(CHANNEL_NARRATIVE, "Listing Available Moods:");
  11017. client->SimpleMessage(CHANNEL_NARRATIVE, "none");
  11018. client->SimpleMessage(CHANNEL_NARRATIVE, "afraid");
  11019. client->SimpleMessage(CHANNEL_NARRATIVE, "angry");
  11020. client->SimpleMessage(CHANNEL_NARRATIVE, "happy");
  11021. client->SimpleMessage(CHANNEL_NARRATIVE, "sad");
  11022. client->SimpleMessage(CHANNEL_NARRATIVE, "tired");
  11023. return;
  11024. }
  11025. /*
  11026. Function: Command_CancelEffect()
  11027. Purpose : Cancels (good) effect spells
  11028. Example : /cancel_effect spell_id - would cancel the spell with the <spell_id> value in spell effects list
  11029. */
  11030. void Commands::Command_CancelEffect(Client* client, Seperator* sep)
  11031. {
  11032. if (sep && sep->arg[0] && sep->IsNumber(0))
  11033. {
  11034. int32 spell_id = atoul(sep->arg[0]);
  11035. SpellEffects* effect = client->GetPlayer()->GetSpellEffect(spell_id);
  11036. if(!effect || effect->spell->spell->GetSpellData()->det_type) {
  11037. return;
  11038. }
  11039. MaintainedEffects* meffect = effect->caster->GetMaintainedSpell(spell_id);
  11040. if (!meffect || !meffect->spell || !meffect->spell->caster || !meffect->spell->caster->GetZone() ||
  11041. !meffect->spell->caster->GetZone()->GetSpellProcess()->DeleteCasterSpell(meffect->spell, "canceled", false, client->GetPlayer()))
  11042. client->Message(CHANNEL_COLOR_RED, "The spell effect could not be cancelled.");
  11043. }
  11044. }
  11045. /*
  11046. Function: Command_CurePlayer()
  11047. Purpose : Identifies spell to cast for cure based on type
  11048. Example : /cureplayer ??
  11049. https://eq2.fandom.com/wiki/Update:58
  11050. New command /cureplayer [playername|group or raid position][trauma|arcane|noxious|elemental|curse] optional [spell|potion]
  11051. Example: /cureplayer g0 noxious spell
  11052. Will attempt to cure yourself of a noxious detriment with only spells and without using potions (even if you have them).
  11053. Example: /cureplayer r4 noxious
  11054. Will attempt to cure the character in raid slot 4 of a noxious detriment using a spell or potion (whichever is available).
  11055. */
  11056. void Commands::Command_CurePlayer(Client* client, Seperator* sep)
  11057. {
  11058. Entity* target = nullptr;
  11059. bool use_spells = true;
  11060. bool use_potions = true;
  11061. if (sep && sep->arg[0] && sep->arg[1]) {
  11062. if(sep->arg[2]) {
  11063. std::string type(sep->arg[2]);
  11064. boost::algorithm::to_lower(type);
  11065. if(type == "potion")
  11066. use_spells = false;
  11067. else if(type == "spell")
  11068. use_potions = false;
  11069. }
  11070. if(strlen(sep->arg[0]) > 1 && isdigit(sep->arg[0][1])) {
  11071. int32 mapped_position = (int32)(sep->arg[0][1]) - 48;
  11072. // TODO: RAID Support ('r' argument)
  11073. if(sep->arg[0][0] == 'g' && !mapped_position) {
  11074. target = (Entity*)client->GetPlayer();
  11075. }
  11076. else {
  11077. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  11078. if (gmi && gmi->group_id) {
  11079. PlayerGroup* group = world.GetGroupManager()->GetGroup(gmi->group_id);
  11080. if(group) {
  11081. target = group->GetGroupMemberByPosition(client->GetPlayer(), mapped_position);
  11082. }
  11083. }
  11084. }
  11085. }
  11086. else {
  11087. Client* target_client = zone_list.GetClientByCharName(sep->arg[0]);
  11088. if(target_client && target_client->GetPlayer() && target_client->GetPlayer()->GetZone() == client->GetPlayer()->GetZone()) {
  11089. target = (Entity*)target_client->GetPlayer();
  11090. }
  11091. }
  11092. ItemEffectType type = EFFECT_CURE_TYPE_ALL;
  11093. bool successful_spell = false;
  11094. bool successful_potion = false;
  11095. if(target) {
  11096. SpellBookEntry* entry = nullptr;
  11097. std::string str(sep->arg[1]);
  11098. boost::algorithm::to_lower(str);
  11099. if(str == "arcane") {
  11100. type = EFFECT_CURE_TYPE_ARCANE;
  11101. // cure arcane spell missing in DB?
  11102. if(use_spells && rule_manager.GetGlobalRule(R_Spells, CureArcaneSpellID)->GetInt32()) {
  11103. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureArcaneSpellID)->GetInt32()); // cure noxious
  11104. }
  11105. }
  11106. else if(str == "trauma") {
  11107. type = EFFECT_CURE_TYPE_TRAUMA;
  11108. // cure trauma spell missing in DB?
  11109. if(use_spells && rule_manager.GetGlobalRule(R_Spells, CureTraumaSpellID)->GetInt32()) {
  11110. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureTraumaSpellID)->GetInt32()); // cure noxious
  11111. }
  11112. }
  11113. else if(str == "noxious") {
  11114. type = EFFECT_CURE_TYPE_NOXIOUS;
  11115. if(use_spells && rule_manager.GetGlobalRule(R_Spells, CureNoxiousSpellID)->GetInt32()) {
  11116. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureNoxiousSpellID)->GetInt32()); // cure noxious
  11117. }
  11118. }
  11119. else if(str == "curse") {
  11120. type = EFFECT_CURE_TYPE_CURSE;
  11121. if(use_spells && rule_manager.GetGlobalRule(R_Spells, CureCurseSpellID)->GetInt32()) {
  11122. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureCurseSpellID)->GetInt32()); // cure curse
  11123. }
  11124. }
  11125. else if(str == "magic") {
  11126. type = EFFECT_CURE_TYPE_MAGIC;
  11127. if(use_spells && rule_manager.GetGlobalRule(R_Spells, CureMagicSpellID)->GetInt32()) {
  11128. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureMagicSpellID)->GetInt32()); // cure magic
  11129. }
  11130. }
  11131. if(use_spells) {
  11132. // check if any of the specific cure types are available, if not then check the base cures
  11133. if(!entry && rule_manager.GetGlobalRule(R_Spells, CureSpellID)->GetInt32()) {
  11134. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureSpellID)->GetInt32()); // cure
  11135. }
  11136. if(entry && entry->spell_id) {
  11137. Spell* spell = master_spell_list.GetSpell(entry->spell_id, entry->tier);
  11138. target->GetZone()->ProcessSpell(spell, (Entity*)client->GetPlayer(), target, true, false);
  11139. successful_spell = true;
  11140. }
  11141. }
  11142. }
  11143. if(!successful_spell && use_potions && target && type != NO_EFFECT_TYPE) {
  11144. vector<Item*>* potential_items = client->GetItemsByEffectType(type, EFFECT_CURE_TYPE_ALL);
  11145. if (potential_items && potential_items->size() > 0) {
  11146. vector<Item*>::iterator itr;
  11147. for (itr = potential_items->begin(); itr != potential_items->end(); itr++)
  11148. {
  11149. Item* item = *itr;
  11150. if(client->UseItem(item, target)) {
  11151. successful_potion = true;
  11152. break;
  11153. }
  11154. }
  11155. }
  11156. safe_delete(potential_items);
  11157. }
  11158. }
  11159. }
  11160. /*
  11161. Function: Command_ShareQuest()
  11162. Purpose : Share quest with the group
  11163. Example : /share_quest [quest_id]
  11164. */
  11165. void Commands::Command_ShareQuest(Client* client, Seperator* sep)
  11166. {
  11167. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  11168. int32 quest_id = atoul(sep->arg[0]);
  11169. bool hasQuest = client->GetPlayer()->HasAnyQuest(quest_id);
  11170. if(hasQuest) {
  11171. Quest* quest = master_quest_list.GetQuest(quest_id, false);
  11172. if(quest) {
  11173. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  11174. if (gmi && gmi->group_id) {
  11175. PlayerGroup* group = world.GetGroupManager()->GetGroup(gmi->group_id);
  11176. if (group) {
  11177. group->ShareQuestWithGroup(client, quest);
  11178. }
  11179. }
  11180. }
  11181. }
  11182. else {
  11183. client->SimpleMessage(CHANNEL_COLOR_RED, "Cannot find quest.");
  11184. }
  11185. }
  11186. }
  11187. /*
  11188. Function: Command_Yell()
  11189. Purpose : Yell to break an encounter
  11190. Example : /yell
  11191. * Uses self target, encounter target or no target
  11192. */
  11193. void Commands::Command_Yell(Client* client, Seperator* sep) {
  11194. Entity* player = (Entity*)client->GetPlayer();
  11195. Spawn* res = nullptr;
  11196. Spawn* prev = nullptr;
  11197. bool cycleAll = false;
  11198. if(player->GetTarget() == player) {
  11199. cycleAll = true; // self target breaks all encounters
  11200. }
  11201. else if(player->GetTarget()) {
  11202. res = player->GetTarget(); // selected target other than self only dis-engages that encounter
  11203. }
  11204. if(res && !client->GetPlayer()->IsEngagedBySpawnID(res->GetID()))
  11205. return;
  11206. bool alreadyYelled = false;
  11207. do {
  11208. if(!res && player->IsEngagedInEncounter(&res)) { // no target is set, dis-engage top of hated by list
  11209. }
  11210. if(!res || prev == res) {
  11211. return;
  11212. }
  11213. if(res->IsNPC() && ((NPC*)res)->Brain()) {
  11214. if(!alreadyYelled) {
  11215. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You yell for help!");
  11216. string yellMsg = std::string(client->GetPlayer()->GetName()) + " yelled for help!";
  11217. client->GetPlayer()->GetZone()->SimpleMessage(CHANNEL_COLOR_RED, yellMsg.c_str(), client->GetPlayer(), 35.0f, false);
  11218. client->GetPlayer()->GetZone()->SendYellPacket(client->GetPlayer());
  11219. }
  11220. alreadyYelled = true;
  11221. NPC* npc = (NPC*)res;
  11222. npc->Brain()->ClearEncounter();
  11223. npc->SetLockedNoLoot(ENCOUNTER_STATE_BROKEN);
  11224. npc->UpdateEncounterState(ENCOUNTER_STATE_BROKEN);
  11225. }
  11226. prev = res;
  11227. res = nullptr;
  11228. }while(cycleAll);
  11229. if(!player->IsEngagedInEncounter()) {
  11230. if(player->GetInfoStruct()->get_engaged_encounter()) {
  11231. player->GetInfoStruct()->set_engaged_encounter(0);
  11232. player->SetRegenValues((player->GetInfoStruct()->get_effective_level() > 0) ? player->GetInfoStruct()->get_effective_level() : player->GetLevel());
  11233. client->GetPlayer()->SetCharSheetChanged(true);
  11234. player->info_changed = true;
  11235. }
  11236. }
  11237. }