Commands.cpp 394 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972
  1. /*
  2. EQ2Emulator: Everquest II Server Emulator
  3. Copyright (C) 2007 EQ2EMulator Development Team (http://www.eq2emulator.net)
  4. This file is part of EQ2Emulator.
  5. EQ2Emulator is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. EQ2Emulator is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with EQ2Emulator. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #include <sys/types.h>
  17. #include "Commands.h"
  18. #include "../ClientPacketFunctions.h"
  19. #include "../../common/version.h"
  20. #include "../../common/seperator.h"
  21. #include "../../common/servertalk.h"
  22. #include "../WorldDatabase.h"
  23. #include "../World.h"
  24. #include "../../common/ConfigReader.h"
  25. #include "../VisualStates.h"
  26. #include "../../common/debug.h"
  27. #include "../LuaInterface.h"
  28. #include "../Quests.h"
  29. #include "../client.h"
  30. #include "../NPC.h"
  31. #include "../Guilds/Guild.h"
  32. #include "../SpellProcess.h"
  33. #include "../Tradeskills/Tradeskills.h"
  34. #include "../../common/Log.h"
  35. #include "../../common/MiscFunctions.h"
  36. #include "../Languages.h"
  37. #include "../IRC/IRC.h"
  38. #include "../Traits/Traits.h"
  39. #include "../Chat/Chat.h"
  40. #include "../Rules/Rules.h"
  41. #include "../AltAdvancement/AltAdvancement.h"
  42. #include "../RaceTypes/RaceTypes.h"
  43. #include "../classes.h"
  44. #include "../Transmute.h"
  45. #include "../Zone/SPGrid.h"
  46. extern WorldDatabase database;
  47. extern MasterSpellList master_spell_list;
  48. extern MasterTraitList master_trait_list;
  49. extern MasterRecipeList master_recipe_list;
  50. extern MasterRecipeBookList master_recipebook_list;
  51. extern World world;
  52. extern ClientList client_list;
  53. extern ConfigReader configReader;
  54. extern VisualStates visual_states;
  55. extern ZoneList zone_list;
  56. extern LuaInterface* lua_interface;
  57. extern MasterQuestList master_quest_list;
  58. extern MasterCollectionList master_collection_list;
  59. extern MasterSkillList master_skill_list;
  60. extern MasterFactionList master_faction_list;
  61. extern GuildList guild_list;
  62. extern MasterLanguagesList master_languages_list;
  63. extern IRC irc;
  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. zone_set_values["expansion_id"] = ZONE_SET_VALUE_EXPANSION_ID;
  170. zone_set_values["name"] = ZONE_SET_VALUE_NAME;
  171. zone_set_values["file"] = ZONE_SET_VALUE_FILE ;
  172. zone_set_values["description"] = ZONE_SET_VALUE_DESCRIPTION;
  173. zone_set_values["safe_x"] = ZONE_SET_VALUE_SAFE_X;
  174. zone_set_values["safe_y"] = ZONE_SET_VALUE_SAFE_Y;
  175. zone_set_values["safe_z"] = ZONE_SET_VALUE_SAFE_Z;
  176. zone_set_values["underworld"] = ZONE_SET_VALUE_UNDERWORLD;
  177. zone_set_values["min_recommended"] = ZONE_SET_VALUE_MIN_RECOMMENDED;
  178. zone_set_values["max_recommended"] = ZONE_SET_VALUE_MAX_RECOMMENDED;
  179. zone_set_values["zone_type"] = ZONE_SET_VALUE_ZONE_TYPE;
  180. zone_set_values["always_loaded"] = ZONE_SET_VALUE_ALWAYS_LOADED;
  181. zone_set_values["city_zone"] = ZONE_SET_VALUE_CITY_ZONE;
  182. zone_set_values["weather_allowed"] = ZONE_SET_VALUE_WEATHER_ALLOWED;
  183. zone_set_values["min_status"] = ZONE_SET_VALUE_MIN_STATUS;
  184. zone_set_values["min_level"] = ZONE_SET_VALUE_MIN_LEVEL;
  185. zone_set_values["start_zone"] = ZONE_SET_VALUE_START_ZONE;
  186. zone_set_values["instance_type"] = ZONE_SET_VALUE_INSTANCE_TYPE;
  187. zone_set_values["default_reenter_time"] = ZONE_SET_VALUE_DEFAULT_REENTER_TIME;
  188. zone_set_values["default_reset_time"] = ZONE_SET_VALUE_DEFAULT_RESET_TIME;
  189. zone_set_values["default_lockout_time"] = ZONE_SET_VALUE_DEFAULT_LOCKOUT_TIME;
  190. zone_set_values["force_group_to_zone"] = ZONE_SET_VALUE_FORCE_GROUP_TO_ZONE;
  191. zone_set_values["lua_script"] = ZONE_SET_VALUE_LUA_SCRIPT;
  192. zone_set_values["shutdown_timer"] = ZONE_SET_VALUE_SHUTDOWN_TIMER;
  193. zone_set_values["zone_motd"] = ZONE_SET_VALUE_ZONE_MOTD;
  194. }
  195. Commands::~Commands() {
  196. safe_delete(remote_commands);
  197. }
  198. int32 Commands::GetSpawnSetType(string val){
  199. if(spawn_set_values.count(val) > 0)
  200. return spawn_set_values[val];
  201. return 0xFFFFFFFF;
  202. }
  203. bool Commands::SetSpawnCommand(Client* client, Spawn* target, int8 type, const char* value, bool send_update, bool temporary, string* temp_value){
  204. if(!target)
  205. return false;
  206. int32 val = 0;
  207. try{
  208. if(type != SPAWN_SET_VALUE_NAME &&
  209. !(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))
  210. {
  211. switch(type)
  212. {
  213. case SPAWN_SET_SKIN_COLOR:
  214. case SPAWN_SET_HAIR_COLOR1:
  215. case SPAWN_SET_HAIR_COLOR2:
  216. case SPAWN_SET_HAIR_TYPE_COLOR:
  217. case SPAWN_SET_HAIR_FACE_COLOR:
  218. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  219. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  220. case SPAWN_SET_HAIR_HIGHLIGHT:
  221. case SPAWN_SET_EYE_COLOR:
  222. case SPAWN_SET_SOGA_SKIN_COLOR:
  223. case SPAWN_SET_SOGA_HAIR_COLOR1:
  224. case SPAWN_SET_SOGA_HAIR_COLOR2:
  225. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  226. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  227. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  228. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  229. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  230. case SPAWN_SET_SOGA_EYE_COLOR:
  231. // ignore these are colors can't pass as a integer value
  232. break;
  233. default:
  234. val = atoul(value);
  235. }
  236. }
  237. }
  238. catch(...){
  239. if(client)
  240. client->Message(CHANNEL_COLOR_RED, "Invalid numeric spawn value: %s", value);
  241. return false;
  242. }
  243. if(temporary){
  244. char tmp[128] = {0};
  245. switch(type){
  246. case SPAWN_SET_VALUE_NAME:{
  247. sprintf(tmp, "%s", target->GetName());
  248. target->SetName(value);
  249. if(target->GetZone())
  250. target->GetZone()->SendUpdateTitles(target);
  251. break;
  252. }
  253. case SPAWN_SET_VALUE_X_OFFSET:
  254. {
  255. sprintf(tmp, "%f", target->GetXOffset());
  256. target->SetXOffset(float(val));
  257. break;
  258. }
  259. case SPAWN_SET_VALUE_Y_OFFSET:
  260. {
  261. sprintf(tmp, "%f", target->GetYOffset());
  262. target->SetYOffset(float(val));
  263. break;
  264. }
  265. case SPAWN_SET_VALUE_Z_OFFSET:
  266. {
  267. sprintf(tmp, "%f", target->GetZOffset());
  268. target->SetZOffset(float(val));
  269. break;
  270. }
  271. case SPAWN_SET_VALUE_EXPIRE: {
  272. sprintf(tmp, "%u", target->GetExpireTime());
  273. target->SetExpireTime(val);
  274. break;
  275. }
  276. case SPAWN_SET_VALUE_EXPIRE_OFFSET: {
  277. sprintf(tmp, "%u", target->GetExpireOffsetTime());
  278. target->SetExpireOffsetTime(val);
  279. break;
  280. }
  281. case SPAWN_SET_VALUE_SUB_TITLE: {
  282. sprintf(tmp, "%s", target->GetSubTitle());
  283. target->SetSubTitle(value);
  284. if(target->GetZone())
  285. target->GetZone()->SendUpdateTitles(target);
  286. break;
  287. }
  288. case SPAWN_SET_VALUE_LEVEL:{
  289. sprintf(tmp, "%i", target->GetLevel());
  290. target->SetLevel(val, send_update);
  291. break;
  292. }
  293. case SPAWN_SET_VALUE_DIFFICULTY:{
  294. sprintf(tmp, "%i", target->GetEncounterLevel());
  295. target->SetEncounterLevel(val, send_update);
  296. break;
  297. }
  298. case SPAWN_SET_VALUE_MODEL_TYPE:{
  299. sprintf(tmp, "%i", target->GetModelType());
  300. target->SetModelType(val, send_update);
  301. break;
  302. }
  303. case SPAWN_SET_VALUE_CLASS:{
  304. sprintf(tmp, "%i", target->GetAdventureClass());
  305. target->SetAdventureClass(val, send_update);
  306. break;
  307. }
  308. case SPAWN_SET_VALUE_GENDER:{
  309. sprintf(tmp, "%i", target->GetGender());
  310. target->SetGender(val, send_update);
  311. break;
  312. }
  313. case SPAWN_SET_VALUE_SHOW_NAME:{
  314. sprintf(tmp, "%i", target->GetShowName());
  315. target->SetShowName(val, send_update);
  316. break;
  317. }
  318. case SPAWN_SET_VALUE_ATTACKABLE:{
  319. sprintf(tmp, "%i", target->GetAttackable());
  320. target->SetAttackable(val, send_update);
  321. break;
  322. }
  323. case SPAWN_SET_VALUE_SHOW_LEVEL:{
  324. sprintf(tmp, "%i", target->GetShowLevel());
  325. target->SetShowLevel(val, send_update);
  326. break;
  327. }
  328. case SPAWN_SET_VALUE_TARGETABLE:{
  329. sprintf(tmp, "%i", target->GetTargetable());
  330. target->SetTargetable(val, send_update);
  331. break;
  332. }
  333. case SPAWN_SET_VALUE_SHOW_COMMAND_ICON:{
  334. sprintf(tmp, "%i", target->GetShowCommandIcon());
  335. target->SetShowCommandIcon(val, send_update);
  336. break;
  337. }
  338. case SPAWN_SET_VALUE_HAND_ICON:{
  339. sprintf(tmp, "%i", target->GetShowHandIcon());
  340. target->SetShowHandIcon(val, send_update);
  341. break;
  342. }
  343. case SPAWN_SET_VALUE_HAIR_TYPE:{
  344. if(target->IsEntity()){
  345. sprintf(tmp, "%i", ((Entity*)target)->GetHairType());
  346. ((Entity*)target)->SetHairType(val, send_update);
  347. }
  348. break;
  349. }
  350. case SPAWN_SET_VALUE_FACIAL_HAIR_TYPE:{
  351. if(target->IsEntity()){
  352. sprintf(tmp, "%i", ((Entity*)target)->GetFacialHairType());
  353. ((Entity*)target)->SetFacialHairType(val, send_update);
  354. }
  355. break;
  356. }
  357. case SPAWN_SET_VALUE_WING_TYPE:{
  358. if(target->IsEntity()){
  359. sprintf(tmp, "%i", ((Entity*)target)->GetWingType());
  360. ((Entity*)target)->SetWingType(val, send_update);
  361. }
  362. break;
  363. }
  364. case SPAWN_SET_VALUE_CHEST_TYPE:{
  365. if(target->IsEntity()){
  366. sprintf(tmp, "%i", ((Entity*)target)->GetChestType());
  367. ((Entity*)target)->SetChestType(val, send_update);
  368. }
  369. break;
  370. }
  371. case SPAWN_SET_VALUE_LEGS_TYPE:{
  372. if(target->IsEntity()){
  373. sprintf(tmp, "%i", ((Entity*)target)->GetLegsType());
  374. ((Entity*)target)->SetLegsType(val, send_update);
  375. }
  376. break;
  377. }
  378. case SPAWN_SET_VALUE_SOGA_HAIR_TYPE:{
  379. if(target->IsEntity()){
  380. sprintf(tmp, "%i", ((Entity*)target)->GetSogaHairType());
  381. ((Entity*)target)->SetSogaHairType(val, send_update);
  382. }
  383. break;
  384. }
  385. case SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE:{
  386. if(target->IsEntity()){
  387. sprintf(tmp, "%i", ((Entity*)target)->GetSogaFacialHairType());
  388. ((Entity*)target)->SetSogaFacialHairType(val, send_update);
  389. }
  390. break;
  391. }
  392. case SPAWN_SET_VALUE_SOGA_MODEL_TYPE:{
  393. sprintf(tmp, "%i", target->GetSogaModelType());
  394. target->SetSogaModelType(val, send_update);
  395. break;
  396. }
  397. case SPAWN_SET_VALUE_SIZE:{
  398. sprintf(tmp, "%i", target->GetSize());
  399. target->SetSize(val, send_update);
  400. break;
  401. }
  402. case SPAWN_SET_VALUE_HP:{
  403. sprintf(tmp, "%i", target->GetHP());
  404. target->SetHP(val, send_update);
  405. break;
  406. }
  407. case SPAWN_SET_VALUE_POWER:{
  408. sprintf(tmp, "%i", target->GetPower());
  409. target->SetPower(val, send_update);
  410. break;
  411. }
  412. case SPAWN_SET_VALUE_HEROIC:{
  413. sprintf(tmp, "%i", target->GetHeroic());
  414. target->SetHeroic(val, send_update);
  415. break;
  416. }
  417. case SPAWN_SET_VALUE_RESPAWN:{
  418. sprintf(tmp, "%u", target->GetRespawnTime());
  419. target->SetRespawnTime(val);
  420. break;
  421. }
  422. case SPAWN_SET_VALUE_X:{
  423. sprintf(tmp, "%f", target->GetX());
  424. target->SetX(atof(value), send_update);
  425. break;
  426. }
  427. case SPAWN_SET_VALUE_Y:{
  428. sprintf(tmp, "%f", target->GetY());
  429. target->SetY(atof(value), send_update);
  430. break;
  431. }
  432. case SPAWN_SET_VALUE_Z:{
  433. sprintf(tmp, "%f", target->GetZ());
  434. target->SetZ(atof(value), send_update);
  435. break;
  436. }
  437. case SPAWN_SET_VALUE_HEADING:{
  438. sprintf(tmp, "%f", target->GetHeading());
  439. target->SetHeading(atof(value) + 360, send_update);
  440. break;
  441. }
  442. case SPAWN_SET_VALUE_VISUAL_STATE:{
  443. sprintf(tmp, "%i", target->GetVisualState());
  444. target->SetVisualState(val, send_update);
  445. break;
  446. }
  447. case SPAWN_SET_VALUE_ACTION_STATE:{
  448. sprintf(tmp, "%i", target->GetActionState());
  449. target->SetActionState(val, send_update);
  450. break;
  451. }
  452. case SPAWN_SET_VALUE_MOOD_STATE:{
  453. sprintf(tmp, "%i", target->GetMoodState());
  454. target->SetMoodState(val, send_update);
  455. break;
  456. }
  457. case SPAWN_SET_VALUE_INITIAL_STATE:{
  458. sprintf(tmp, "%i", target->GetInitialState());
  459. target->SetInitialState(val, send_update);
  460. break;
  461. }
  462. case SPAWN_SET_VALUE_ACTIVITY_STATE:{
  463. sprintf(tmp, "%i", target->GetActivityStatus());
  464. target->SetActivityStatus(val, send_update);
  465. break;
  466. }
  467. case SPAWN_SET_VALUE_COLLISION_RADIUS:{
  468. sprintf(tmp, "%i", target->GetCollisionRadius());
  469. target->SetCollisionRadius(val, send_update);
  470. break;
  471. }
  472. case SPAWN_SET_VALUE_DEVICE_ID: {
  473. if (target->IsObject()) {
  474. sprintf(tmp, "%i", ((Object*)target)->GetDeviceID());
  475. ((Object*)target)->SetDeviceID(val);
  476. }
  477. break;
  478. }
  479. case SPAWN_SET_VALUE_PITCH: {
  480. sprintf(tmp, "%f", target->GetPitch());
  481. target->SetPitch(atof(value), send_update);
  482. break;
  483. }
  484. case SPAWN_SET_VALUE_ROLL: {
  485. sprintf(tmp, "%f", target->GetRoll());
  486. target->SetRoll(atof(value), send_update);
  487. break;
  488. }
  489. case SPAWN_SET_VALUE_HIDE_HOOD: {
  490. sprintf(tmp, "%i", target->appearance.hide_hood);
  491. target->SetHideHood(val);
  492. break;
  493. }
  494. case SPAWN_SET_VALUE_EMOTE_STATE: {
  495. sprintf(tmp, "%i", target->appearance.emote_state);
  496. target->SetEmoteState(val);
  497. break;
  498. }
  499. case SPAWN_SET_VALUE_ICON: {
  500. sprintf(tmp, "%i", target->GetIconValue());
  501. target->SetIcon(val);
  502. break;
  503. }
  504. case SPAWN_SET_VALUE_PREFIX: {
  505. sprintf(tmp, "%s", target->GetPrefixTitle());
  506. target->SetPrefixTitle(value);
  507. if(target->GetZone())
  508. target->GetZone()->SendUpdateTitles(target);
  509. break;
  510. }
  511. case SPAWN_SET_VALUE_SUFFIX: {
  512. sprintf(tmp, "%s", target->GetSuffixTitle());
  513. target->SetSuffixTitle(value);
  514. if(target->GetZone())
  515. target->GetZone()->SendUpdateTitles(target);
  516. break;
  517. }
  518. case SPAWN_SET_VALUE_LASTNAME: {
  519. sprintf(tmp, "%s", target->GetLastName());
  520. target->SetLastName(value);
  521. if(target->GetZone())
  522. target->GetZone()->SendUpdateTitles(target);
  523. break;
  524. }
  525. case SPAWN_SET_VALUE_EXPANSION_FLAG:
  526. case SPAWN_SET_VALUE_HOLIDAY_FLAG: {
  527. // nothing to do must reload spawns
  528. break;
  529. }
  530. case SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL: {
  531. sprintf(tmp, "%i", target->GetMerchantMinLevel());
  532. target->SetMerchantLevelRange(atoul(value), target->GetMerchantMaxLevel());
  533. break;
  534. }
  535. case SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL: {
  536. sprintf(tmp, "%i", target->GetMerchantMaxLevel());
  537. target->SetMerchantLevelRange(target->GetMerchantMinLevel(), atoul(value));
  538. break;
  539. }
  540. case SPAWN_SET_VALUE_FACTION:{
  541. sprintf(tmp, "%i", target->faction_id);
  542. ZoneServer* zone = target->GetZone();
  543. if (!zone && client)
  544. zone = client->GetCurrentZone();
  545. target->faction_id = atoul(value);
  546. if(zone)
  547. {
  548. zone->RemoveDeadEnemyList(target);
  549. if(target->IsNPC())
  550. zone->AddEnemyList((NPC*)target);
  551. }
  552. break;
  553. }
  554. case SPAWN_SET_SKIN_COLOR:
  555. case SPAWN_SET_HAIR_COLOR1:
  556. case SPAWN_SET_HAIR_COLOR2:
  557. case SPAWN_SET_HAIR_TYPE_COLOR:
  558. case SPAWN_SET_HAIR_FACE_COLOR:
  559. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  560. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  561. case SPAWN_SET_HAIR_HIGHLIGHT:
  562. case SPAWN_SET_MODEL_COLOR:
  563. case SPAWN_SET_EYE_COLOR:
  564. case SPAWN_SET_SOGA_SKIN_COLOR:
  565. case SPAWN_SET_SOGA_HAIR_COLOR1:
  566. case SPAWN_SET_SOGA_HAIR_COLOR2:
  567. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  568. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  569. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  570. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  571. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  572. case SPAWN_SET_SOGA_MODEL_COLOR:
  573. case SPAWN_SET_SOGA_EYE_COLOR:
  574. {
  575. if (target->IsEntity())
  576. {
  577. Seperator* skinsep = new Seperator(value, ' ', 3, 500, true);
  578. if (skinsep->IsNumber(0) && skinsep->IsNumber(1) && skinsep->IsNumber(2))
  579. {
  580. EQ2_Color clr;
  581. clr.red = atoul(skinsep->arg[0]);
  582. clr.green = atoul(skinsep->arg[1]);
  583. clr.blue = atoul(skinsep->arg[2]);
  584. switch(type)
  585. {
  586. case SPAWN_SET_SKIN_COLOR:
  587. ((Entity*)target)->SetSkinColor(clr);
  588. break;
  589. case SPAWN_SET_HAIR_COLOR1:
  590. ((Entity*)target)->SetHairColor1(clr);
  591. break;
  592. case SPAWN_SET_HAIR_COLOR2:
  593. ((Entity*)target)->SetHairColor2(clr);
  594. break;
  595. case SPAWN_SET_HAIR_TYPE_COLOR:
  596. ((Entity*)target)->SetHairColor(clr);
  597. break;
  598. case SPAWN_SET_HAIR_FACE_COLOR:
  599. ((Entity*)target)->SetFacialHairColor(clr);
  600. break;
  601. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  602. ((Entity*)target)->SetHairTypeHighlightColor(clr);
  603. break;
  604. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  605. ((Entity*)target)->SetFacialHairHighlightColor(clr);
  606. break;
  607. case SPAWN_SET_HAIR_HIGHLIGHT:
  608. ((Entity*)target)->SetHairHighlightColor(clr);
  609. break;
  610. case SPAWN_SET_MODEL_COLOR:
  611. ((Entity*)target)->SetModelColor(clr);
  612. break;
  613. case SPAWN_SET_EYE_COLOR:
  614. ((Entity*)target)->SetEyeColor(clr);
  615. break;
  616. case SPAWN_SET_SOGA_SKIN_COLOR:
  617. ((Entity*)target)->SetSogaSkinColor(clr);
  618. break;
  619. case SPAWN_SET_SOGA_HAIR_COLOR1:
  620. ((Entity*)target)->SetSogaHairColor1(clr);
  621. break;
  622. case SPAWN_SET_SOGA_HAIR_COLOR2:
  623. ((Entity*)target)->SetSogaHairColor2(clr);
  624. break;
  625. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  626. ((Entity*)target)->SetSogaHairColor(clr);
  627. break;
  628. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  629. ((Entity*)target)->SetSogaFacialHairColor(clr);
  630. break;
  631. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  632. ((Entity*)target)->SetSogaHairTypeHighlightColor(clr);
  633. break;
  634. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  635. ((Entity*)target)->SetSogaFacialHairHighlightColor(clr);
  636. break;
  637. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  638. ((Entity*)target)->SetSogaHairHighlightColor(clr);
  639. break;
  640. case SPAWN_SET_SOGA_MODEL_COLOR:
  641. ((Entity*)target)->SetSogaModelColor(clr);
  642. break;
  643. case SPAWN_SET_SOGA_EYE_COLOR:
  644. ((Entity*)target)->SetSogaEyeColor(clr);
  645. break;
  646. }
  647. }
  648. safe_delete(skinsep);
  649. }
  650. break;
  651. }
  652. case SPAWN_SET_AAXP_REWARDS: {
  653. target->SetAAXPRewards(atoul(value));
  654. break;
  655. }
  656. if(temp_value)
  657. *temp_value = string(tmp);
  658. }
  659. }
  660. else{
  661. switch(type){
  662. case SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL: {
  663. target->SetMerchantLevelRange(atoul(value), target->GetMerchantMaxLevel());
  664. break;
  665. }
  666. case SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL: {
  667. target->SetMerchantLevelRange(target->GetMerchantMinLevel(), atoul(value));
  668. break;
  669. }
  670. case SPAWN_SET_VALUE_EXPANSION_FLAG: {
  671. if (target->GetDatabaseID() > 0)
  672. {
  673. char query[256];
  674. snprintf(query, 256, "update spawn set expansion_flag=%u where id=%i", atoul(value), target->GetDatabaseID());
  675. if (database.RunQuery(query, strnlen(query, 256)))
  676. {
  677. if(client)
  678. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  679. }
  680. }
  681. break;
  682. }
  683. case SPAWN_SET_VALUE_HOLIDAY_FLAG: {
  684. if (target->GetDatabaseID() > 0)
  685. {
  686. char query[256];
  687. snprintf(query, 256, "update spawn set holiday_flag=%u where id=%i", atoul(value), target->GetDatabaseID());
  688. if (database.RunQuery(query, strnlen(query, 256)))
  689. {
  690. if(client)
  691. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  692. }
  693. }
  694. break;
  695. }
  696. case SPAWN_SET_AAXP_REWARDS: {
  697. if (target->GetDatabaseID() > 0)
  698. {
  699. char query[256];
  700. snprintf(query, 256, "update spawn set aaxp_rewards=%u where id=%i", atoul(value), target->GetDatabaseID());
  701. if (database.RunQuery(query, strnlen(query, 256)))
  702. {
  703. if(client)
  704. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  705. }
  706. }
  707. break;
  708. }
  709. case SPAWN_SET_VALUE_NAME:{
  710. target->SetName(value);
  711. if(target->GetZone())
  712. target->GetZone()->SendUpdateTitles(target);
  713. break;
  714. }
  715. case SPAWN_SET_VALUE_SUB_TITLE: {
  716. target->SetSubTitle(value);
  717. if(target->GetZone())
  718. target->GetZone()->SendUpdateTitles(target);
  719. break;
  720. }
  721. case SPAWN_SET_VALUE_X_OFFSET:
  722. {
  723. target->SetXOffset(atof(value));
  724. break;
  725. }
  726. case SPAWN_SET_VALUE_Y_OFFSET:
  727. {
  728. target->SetYOffset(atof(value));
  729. break;
  730. }
  731. case SPAWN_SET_VALUE_Z_OFFSET:
  732. {
  733. target->SetZOffset(atof(value));
  734. break;
  735. }
  736. case SPAWN_SET_VALUE_EXPIRE: {
  737. target->SetExpireTime(val);
  738. break;
  739. }
  740. case SPAWN_SET_VALUE_EXPIRE_OFFSET: {
  741. target->SetExpireOffsetTime(val);
  742. break;
  743. }
  744. case SPAWN_SET_VALUE_LEVEL:{
  745. target->SetLevel(val, send_update);
  746. break;
  747. }
  748. case SPAWN_SET_VALUE_DIFFICULTY:{
  749. target->SetEncounterLevel(val, send_update);
  750. break;
  751. }
  752. case SPAWN_SET_VALUE_MODEL_TYPE:{
  753. target->SetModelType(val, send_update);
  754. break;
  755. }
  756. case SPAWN_SET_VALUE_CLASS:{
  757. target->SetAdventureClass(val, send_update);
  758. break;
  759. }
  760. case SPAWN_SET_VALUE_GENDER:{
  761. target->SetGender(val, send_update);
  762. break;
  763. }
  764. case SPAWN_SET_VALUE_SHOW_NAME:{
  765. target->SetShowName(val, send_update);
  766. break;
  767. }
  768. case SPAWN_SET_VALUE_ATTACKABLE:{
  769. target->SetAttackable(val, send_update);
  770. break;
  771. }
  772. case SPAWN_SET_VALUE_SHOW_LEVEL:{
  773. target->SetShowLevel(val, send_update);
  774. break;
  775. }
  776. case SPAWN_SET_VALUE_TARGETABLE:{
  777. target->SetTargetable(val, send_update);
  778. break;
  779. }
  780. case SPAWN_SET_VALUE_SHOW_COMMAND_ICON:{
  781. target->SetShowCommandIcon(val, send_update);
  782. break;
  783. }
  784. case SPAWN_SET_VALUE_HAND_ICON:{
  785. target->SetShowHandIcon(val, send_update);
  786. break;
  787. }
  788. case SPAWN_SET_VALUE_HAIR_TYPE:{
  789. if(target->IsEntity())
  790. ((Entity*)target)->SetHairType(val, send_update);
  791. break;
  792. }
  793. case SPAWN_SET_VALUE_FACIAL_HAIR_TYPE:{
  794. if(target->IsEntity())
  795. ((Entity*)target)->SetFacialHairType(val, send_update);
  796. break;
  797. }
  798. case SPAWN_SET_VALUE_WING_TYPE:{
  799. if(target->IsEntity())
  800. ((Entity*)target)->SetWingType(val, send_update);
  801. break;
  802. }
  803. case SPAWN_SET_VALUE_CHEST_TYPE:{
  804. if(target->IsEntity())
  805. ((Entity*)target)->SetChestType(val, send_update);
  806. break;
  807. }
  808. case SPAWN_SET_VALUE_LEGS_TYPE:{
  809. if(target->IsEntity())
  810. ((Entity*)target)->SetLegsType(val, send_update);
  811. break;
  812. }
  813. case SPAWN_SET_VALUE_SOGA_HAIR_TYPE:{
  814. if(target->IsEntity())
  815. ((Entity*)target)->SetSogaHairType(val, send_update);
  816. break;
  817. }
  818. case SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE:{
  819. if(target->IsEntity())
  820. ((Entity*)target)->SetSogaFacialHairType(val, send_update);
  821. break;
  822. }
  823. case SPAWN_SET_VALUE_SOGA_MODEL_TYPE:{
  824. target->SetSogaModelType(val, send_update);
  825. break;
  826. }
  827. case SPAWN_SET_VALUE_SIZE:{
  828. target->SetSize(val, send_update);
  829. break;
  830. }
  831. case SPAWN_SET_VALUE_HP:{
  832. target->SetHP(val, send_update);
  833. break;
  834. }
  835. case SPAWN_SET_VALUE_POWER:{
  836. target->SetPower(val, send_update);
  837. break;
  838. }
  839. case SPAWN_SET_VALUE_HEROIC:{
  840. target->SetHeroic(val, send_update);
  841. break;
  842. }
  843. case SPAWN_SET_VALUE_RESPAWN:{
  844. target->SetRespawnTime(val);
  845. break;
  846. }
  847. case SPAWN_SET_VALUE_X:{
  848. target->SetX(atof(value), send_update);
  849. target->SetSpawnOrigX(target->GetX());
  850. break;
  851. }
  852. case SPAWN_SET_VALUE_Y:{
  853. target->SetY(atof(value), send_update);
  854. target->SetSpawnOrigY(target->GetY());
  855. break;
  856. }
  857. case SPAWN_SET_VALUE_Z:{
  858. target->SetZ(atof(value), send_update);
  859. target->SetSpawnOrigZ(target->GetZ());
  860. break;
  861. }
  862. case SPAWN_SET_VALUE_HEADING:{
  863. target->SetHeading(atof(value), send_update);
  864. target->SetSpawnOrigHeading(target->GetHeading());
  865. break;
  866. }
  867. case SPAWN_SET_VALUE_COMMAND_PRIMARY:{
  868. ZoneServer* zone = target->GetZone();
  869. if (!zone && client)
  870. zone = client->GetCurrentZone();
  871. if(zone && zone->GetEntityCommandList(val))
  872. target->SetPrimaryCommands(zone->GetEntityCommandList(val));
  873. target->primary_command_list_id = val;
  874. break;
  875. }
  876. case SPAWN_SET_VALUE_COMMAND_SECONDARY:{
  877. ZoneServer* zone = target->GetZone();
  878. if (!zone && client)
  879. zone = client->GetCurrentZone();
  880. if (zone && zone->GetEntityCommandList(val))
  881. target->SetSecondaryCommands(zone->GetEntityCommandList(val));
  882. target->secondary_command_list_id = val;
  883. break;
  884. }
  885. case SPAWN_SET_VALUE_VISUAL_STATE:{
  886. target->SetVisualState(val, send_update);
  887. break;
  888. }
  889. case SPAWN_SET_VALUE_ACTION_STATE:{
  890. target->SetActionState(val, send_update);
  891. break;
  892. }
  893. case SPAWN_SET_VALUE_MOOD_STATE:{
  894. target->SetMoodState(val, send_update);
  895. break;
  896. }
  897. case SPAWN_SET_VALUE_INITIAL_STATE:{
  898. target->SetInitialState(val, send_update);
  899. break;
  900. }
  901. case SPAWN_SET_VALUE_ACTIVITY_STATE:{
  902. target->SetActivityStatus(val, send_update);
  903. break;
  904. }
  905. case SPAWN_SET_VALUE_COLLISION_RADIUS:{
  906. target->SetCollisionRadius(val, send_update);
  907. break;
  908. }
  909. case SPAWN_SET_VALUE_FACTION:{
  910. ZoneServer* zone = target->GetZone();
  911. if (!zone && client)
  912. zone = client->GetCurrentZone();
  913. target->faction_id = val;
  914. if(zone)
  915. {
  916. zone->RemoveDeadEnemyList(target);
  917. if(target->IsNPC())
  918. zone->AddEnemyList((NPC*)target);
  919. }
  920. break;
  921. }
  922. case SPAWN_SET_VALUE_DEVICE_ID:{
  923. if (target->IsObject())
  924. ((Object*)target)->SetDeviceID(val);
  925. break;
  926. }
  927. case SPAWN_SET_VALUE_PITCH: {
  928. target->SetPitch(atof(value), send_update);
  929. target->SetSpawnOrigPitch(atof(value));
  930. break;
  931. }
  932. case SPAWN_SET_VALUE_ROLL: {
  933. target->SetRoll(atof(value), send_update);
  934. target->SetSpawnOrigRoll(atof(value));
  935. break;
  936. }
  937. case SPAWN_SET_VALUE_HIDE_HOOD: {
  938. target->SetHideHood(val);
  939. break;
  940. }
  941. case SPAWN_SET_VALUE_EMOTE_STATE: {
  942. target->SetEmoteState(val);
  943. break;
  944. }
  945. case SPAWN_SET_VALUE_ICON: {
  946. target->SetIcon(val);
  947. break;
  948. }
  949. case SPAWN_SET_VALUE_PREFIX: {
  950. target->SetPrefixTitle(value);
  951. if(target->GetZone())
  952. target->GetZone()->SendUpdateTitles(target);
  953. break;
  954. }
  955. case SPAWN_SET_VALUE_SUFFIX: {
  956. target->SetSuffixTitle(value);
  957. if(target->GetZone())
  958. target->GetZone()->SendUpdateTitles(target);
  959. break;
  960. }
  961. case SPAWN_SET_VALUE_LASTNAME: {
  962. target->SetLastName(value);
  963. if(target->GetZone())
  964. target->GetZone()->SendUpdateTitles(target);
  965. break;
  966. }
  967. case SPAWN_SET_VALUE_SPAWN_SCRIPT:{
  968. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  969. if(client){
  970. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  971. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawn_script 'SpawnScripts/example.lua'");
  972. }
  973. return false;
  974. }
  975. else if(!database.UpdateSpawnScriptData(target->GetDatabaseID(), 0, 0, value))
  976. return false;
  977. else{
  978. if(!world.GetSpawnLocationScript(target->GetSpawnLocationID()))
  979. target->SetSpawnScript(value);
  980. }
  981. break;
  982. }
  983. case SPAWN_SET_VALUE_SPAWNLOCATION_SCRIPT:{
  984. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  985. if(client){
  986. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  987. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawnlocation_script 'SpawnScripts/example.lua'");
  988. }
  989. return false;
  990. }
  991. else if(!database.UpdateSpawnScriptData(0, target->GetSpawnLocationID(), 0, value))
  992. return false;
  993. else{
  994. if(!world.GetSpawnEntryScript(target->GetSpawnEntryID()))
  995. target->SetSpawnScript(value);
  996. }
  997. break;
  998. }
  999. case SPAWN_SET_VALUE_SPAWNENTRY_SCRIPT:{
  1000. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  1001. if(client){
  1002. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  1003. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawnentry_script 'SpawnScripts/example.lua'");
  1004. }
  1005. return false;
  1006. }
  1007. else if(!database.UpdateSpawnScriptData(0, 0, target->GetSpawnEntryID(), value))
  1008. return false;
  1009. else
  1010. target->SetSpawnScript(value);
  1011. break;
  1012. }
  1013. case SPAWN_SET_SKIN_COLOR:
  1014. case SPAWN_SET_HAIR_COLOR1:
  1015. case SPAWN_SET_HAIR_COLOR2:
  1016. case SPAWN_SET_HAIR_TYPE_COLOR:
  1017. case SPAWN_SET_HAIR_FACE_COLOR:
  1018. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  1019. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  1020. case SPAWN_SET_HAIR_HIGHLIGHT:
  1021. case SPAWN_SET_MODEL_COLOR:
  1022. case SPAWN_SET_EYE_COLOR:
  1023. case SPAWN_SET_SOGA_SKIN_COLOR:
  1024. case SPAWN_SET_SOGA_HAIR_COLOR1:
  1025. case SPAWN_SET_SOGA_HAIR_COLOR2:
  1026. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  1027. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  1028. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  1029. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  1030. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  1031. case SPAWN_SET_SOGA_MODEL_COLOR:
  1032. case SPAWN_SET_SOGA_EYE_COLOR: {
  1033. if (target->IsNPC())
  1034. {
  1035. Seperator* skinsep = new Seperator(value, ' ', 3, 500, true);
  1036. if (skinsep->IsNumber(0) && skinsep->IsNumber(1) && skinsep->IsNumber(2))
  1037. {
  1038. EQ2_Color clr;
  1039. clr.red = atoul(skinsep->arg[0]);
  1040. clr.green = atoul(skinsep->arg[1]);
  1041. clr.blue = atoul(skinsep->arg[2]);
  1042. Query replaceSkinQuery;
  1043. string fieldName("");
  1044. switch(type)
  1045. {
  1046. case SPAWN_SET_SKIN_COLOR:
  1047. ((Entity*)target)->SetSkinColor(clr);
  1048. fieldName.append("skin_color");
  1049. break;
  1050. case SPAWN_SET_HAIR_COLOR1:
  1051. ((Entity*)target)->SetHairColor1(clr);
  1052. fieldName.append("hair_color1");
  1053. break;
  1054. case SPAWN_SET_HAIR_COLOR2:
  1055. ((Entity*)target)->SetHairColor2(clr);
  1056. fieldName.append("hair_color2");
  1057. break;
  1058. case SPAWN_SET_HAIR_TYPE_COLOR:
  1059. ((Entity*)target)->SetHairColor(clr);
  1060. fieldName.append("hair_type_color");
  1061. break;
  1062. case SPAWN_SET_HAIR_FACE_COLOR:
  1063. ((Entity*)target)->SetFacialHairColor(clr);
  1064. fieldName.append("hair_face_color");
  1065. break;
  1066. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  1067. ((Entity*)target)->SetHairTypeHighlightColor(clr);
  1068. fieldName.append("hair_type_highlight_color");
  1069. break;
  1070. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  1071. ((Entity*)target)->SetFacialHairHighlightColor(clr);
  1072. fieldName.append("hair_face_highlight_color");
  1073. break;
  1074. case SPAWN_SET_HAIR_HIGHLIGHT:
  1075. ((Entity*)target)->SetHairHighlightColor(clr);
  1076. fieldName.append("hair_highlight");
  1077. break;
  1078. case SPAWN_SET_MODEL_COLOR:
  1079. ((Entity*)target)->SetModelColor(clr);
  1080. fieldName.append("model_color");
  1081. break;
  1082. case SPAWN_SET_EYE_COLOR:
  1083. ((Entity*)target)->SetEyeColor(clr);
  1084. fieldName.append("eye_color");
  1085. break;
  1086. case SPAWN_SET_SOGA_SKIN_COLOR:
  1087. ((Entity*)target)->SetSogaSkinColor(clr);
  1088. fieldName.append("soga_skin_color");
  1089. break;
  1090. case SPAWN_SET_SOGA_HAIR_COLOR1:
  1091. ((Entity*)target)->SetSogaHairColor1(clr);
  1092. fieldName.append("soga_hair_color1");
  1093. break;
  1094. case SPAWN_SET_SOGA_HAIR_COLOR2:
  1095. ((Entity*)target)->SetSogaHairColor2(clr);
  1096. fieldName.append("soga_hair_color2");
  1097. break;
  1098. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  1099. ((Entity*)target)->SetSogaHairColor(clr);
  1100. fieldName.append("soga_hair_type_color");
  1101. break;
  1102. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  1103. ((Entity*)target)->SetSogaFacialHairColor(clr);
  1104. fieldName.append("soga_hair_face_color");
  1105. break;
  1106. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  1107. ((Entity*)target)->SetSogaHairTypeHighlightColor(clr);
  1108. fieldName.append("soga_hair_type_highlight_color");
  1109. break;
  1110. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  1111. ((Entity*)target)->SetSogaFacialHairHighlightColor(clr);
  1112. fieldName.append("soga_hair_face_highlight_color");
  1113. break;
  1114. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  1115. ((Entity*)target)->SetSogaHairHighlightColor(clr);
  1116. fieldName.append("soga_hair_highlight");
  1117. break;
  1118. case SPAWN_SET_SOGA_MODEL_COLOR:
  1119. ((Entity*)target)->SetSogaModelColor(clr);
  1120. fieldName.append("soga_model_color");
  1121. break;
  1122. case SPAWN_SET_SOGA_EYE_COLOR:
  1123. ((Entity*)target)->SetSogaEyeColor(clr);
  1124. fieldName.append("soga_eye_color");
  1125. break;
  1126. }
  1127. replaceSkinQuery.AddQueryAsync(0, &database, Q_DELETE, "delete from npc_appearance where spawn_id=%u and type='%s'", target->GetDatabaseID(), fieldName.c_str());
  1128. 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);
  1129. }
  1130. safe_delete(skinsep);
  1131. }
  1132. break;
  1133. }
  1134. }
  1135. }
  1136. return true;
  1137. }
  1138. /* The zone object will be NULL if the zone is not currently running. We pass both of these in so we can update
  1139. the database fields always and also update the zone in memory if it's running. */
  1140. bool Commands::SetZoneCommand(Client* client, int32 zone_id, ZoneServer* zone, int8 type, const char* value) {
  1141. if (client && zone_id > 0 && type > 0 && value) {
  1142. sint32 int_value = 0;
  1143. float float_value = 0;
  1144. if (type == ZONE_SET_VALUE_SAFE_X || type == ZONE_SET_VALUE_SAFE_Y || type == ZONE_SET_VALUE_SAFE_Z || type == ZONE_SET_VALUE_UNDERWORLD) {
  1145. try {
  1146. float_value = atof(value);
  1147. }
  1148. catch (...) {
  1149. client->Message(CHANNEL_COLOR_RED, "Error converting '%s' to a float value", value);
  1150. return false;
  1151. }
  1152. }
  1153. 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) {
  1154. try {
  1155. int_value = atoi(value);
  1156. }
  1157. catch (...) {
  1158. client->Message(CHANNEL_COLOR_RED, "Error converting '%s' to an integer value", value);
  1159. return false;
  1160. }
  1161. }
  1162. switch (type) {
  1163. case ZONE_SET_VALUE_EXPANSION_ID: {
  1164. break;
  1165. }
  1166. case ZONE_SET_VALUE_NAME: {
  1167. if (zone)
  1168. zone->SetZoneName(const_cast<char*>(value));
  1169. database.SaveZoneInfo(zone_id, "name", value);
  1170. break;
  1171. }
  1172. case ZONE_SET_VALUE_FILE: {
  1173. if (zone)
  1174. zone->SetZoneFile(const_cast<char*>(value));
  1175. database.SaveZoneInfo(zone_id, "file", value);
  1176. break;
  1177. }
  1178. case ZONE_SET_VALUE_DESCRIPTION: {
  1179. if (zone)
  1180. zone->SetZoneDescription(const_cast<char*>(value));
  1181. database.SaveZoneInfo(zone_id, "description", value);
  1182. break;
  1183. }
  1184. case ZONE_SET_VALUE_SAFE_X: {
  1185. if (zone)
  1186. zone->SetSafeX(float_value);
  1187. database.SaveZoneInfo(zone_id, "safe_x", float_value);
  1188. break;
  1189. }
  1190. case ZONE_SET_VALUE_SAFE_Y: {
  1191. if (zone)
  1192. zone->SetSafeY(float_value);
  1193. database.SaveZoneInfo(zone_id, "safe_y", float_value);
  1194. break;
  1195. }
  1196. case ZONE_SET_VALUE_SAFE_Z: {
  1197. if (zone)
  1198. zone->SetSafeZ(float_value);
  1199. database.SaveZoneInfo(zone_id, "safe_z", float_value);
  1200. break;
  1201. }
  1202. case ZONE_SET_VALUE_UNDERWORLD: {
  1203. if (zone)
  1204. zone->SetUnderWorld(float_value);
  1205. database.SaveZoneInfo(zone_id, "underworld", float_value);
  1206. break;
  1207. }
  1208. case ZONE_SET_VALUE_MIN_RECOMMENDED: {
  1209. break;
  1210. }
  1211. case ZONE_SET_VALUE_MAX_RECOMMENDED: {
  1212. break;
  1213. }
  1214. case ZONE_SET_VALUE_ZONE_TYPE: {
  1215. break;
  1216. }
  1217. case ZONE_SET_VALUE_ALWAYS_LOADED: {
  1218. if (zone)
  1219. zone->SetAlwaysLoaded(int_value == 1);
  1220. database.SaveZoneInfo(zone_id, "always_loaded", int_value);
  1221. break;
  1222. }
  1223. case ZONE_SET_VALUE_CITY_ZONE: {
  1224. if (zone)
  1225. zone->SetCityZone(int_value == 1);
  1226. database.SaveZoneInfo(zone_id, "city_zone", int_value);
  1227. break;
  1228. }
  1229. case ZONE_SET_VALUE_WEATHER_ALLOWED: {
  1230. if (zone)
  1231. zone->SetWeatherAllowed(int_value == 1);
  1232. database.SaveZoneInfo(zone_id, "weather_allowed", int_value);
  1233. break;
  1234. }
  1235. case ZONE_SET_VALUE_MIN_STATUS: {
  1236. if (zone)
  1237. zone->SetMinimumStatus(int_value);
  1238. database.SaveZoneInfo(zone_id, "min_status", int_value);
  1239. break;
  1240. }
  1241. case ZONE_SET_VALUE_MIN_LEVEL: {
  1242. if (zone)
  1243. zone->SetMinimumLevel(int_value);
  1244. database.SaveZoneInfo(zone_id, "min_level", int_value);
  1245. break;
  1246. }
  1247. case ZONE_SET_VALUE_MAX_LEVEL: {
  1248. if (zone)
  1249. zone->SetMaximumLevel(int_value);
  1250. database.SaveZoneInfo(zone_id, "max_level", int_value);
  1251. break;
  1252. }
  1253. case ZONE_SET_VALUE_START_ZONE: {
  1254. database.SaveZoneInfo(zone_id, "start_zone", int_value);
  1255. break;
  1256. }
  1257. case ZONE_SET_VALUE_INSTANCE_TYPE: {
  1258. if (zone)
  1259. zone->SetInstanceType(int_value);
  1260. database.SaveZoneInfo(zone_id, "instance_type", int_value);
  1261. break;
  1262. }
  1263. case ZONE_SET_VALUE_DEFAULT_REENTER_TIME: {
  1264. if (zone)
  1265. zone->SetDefaultReenterTime(int_value);
  1266. database.SaveZoneInfo(zone_id, "default_reenter_time", int_value);
  1267. break;
  1268. }
  1269. case ZONE_SET_VALUE_DEFAULT_RESET_TIME: {
  1270. if (zone)
  1271. zone->SetDefaultResetTime(int_value);
  1272. database.SaveZoneInfo(zone_id, "default_reset_time", int_value);
  1273. break;
  1274. }
  1275. case ZONE_SET_VALUE_DEFAULT_LOCKOUT_TIME: {
  1276. if (zone)
  1277. zone->SetDefaultLockoutTime(int_value);
  1278. database.SaveZoneInfo(zone_id, "default_lockout_time", int_value);
  1279. break;
  1280. }
  1281. case ZONE_SET_VALUE_FORCE_GROUP_TO_ZONE: {
  1282. if (zone)
  1283. zone->SetForceGroupZoneOption(int_value);
  1284. database.SaveZoneInfo(zone_id, "force_group_to_zone", int_value);
  1285. break;
  1286. }
  1287. case ZONE_SET_VALUE_LUA_SCRIPT: {
  1288. if (lua_interface && lua_interface->GetZoneScript(value) == 0) {
  1289. client->Message(CHANNEL_COLOR_RED, "Invalid Zone Script file. Be sure you give the absolute path.");
  1290. client->Message(CHANNEL_COLOR_RED, "Example: /zone set lua_script 'ZoneScripts/QueensColony.lua'");
  1291. return false;
  1292. }
  1293. else {
  1294. world.AddZoneScript(zone_id, const_cast<char*>(value));
  1295. database.SaveZoneInfo(zone_id, "lua_script", value);
  1296. }
  1297. break;
  1298. }
  1299. case ZONE_SET_VALUE_SHUTDOWN_TIMER: {
  1300. if (zone)
  1301. zone->SetShutdownTimer(int_value);
  1302. database.SaveZoneInfo(zone_id, "shutdown_timer", int_value);
  1303. break;
  1304. }
  1305. case ZONE_SET_VALUE_ZONE_MOTD: {
  1306. if (zone)
  1307. zone->SetZoneMOTD(string(value));
  1308. database.SaveZoneInfo(zone_id, "zone_motd", value);
  1309. break;
  1310. }
  1311. default: {
  1312. client->Message(CHANNEL_COLOR_RED, "Invalid zone attribute %i", type);
  1313. return false;
  1314. }
  1315. }
  1316. }
  1317. else {
  1318. if (client)
  1319. client->SimpleMessage(CHANNEL_COLOR_RED, "An error occured saving new zone data.");
  1320. return false;
  1321. }
  1322. return true;
  1323. }
  1324. void Commands::Process(int32 index, EQ2_16BitString* command_parms, Client* client, Spawn* targetOverride) {
  1325. if (index >= remote_commands->commands.size()) {
  1326. LogWrite(COMMAND__ERROR, 0, "Command", "Error, command handler of %u was requested, but max handler is %u", index, remote_commands->commands.size());
  1327. return;
  1328. }
  1329. Spawn* cmdTarget = targetOverride ? targetOverride : client->GetPlayer()->GetTarget();
  1330. EQ2_RemoteCommandString* parent_command = 0;
  1331. EQ2_RemoteCommandString* command = &remote_commands->commands[index];
  1332. Seperator* sep = 0;
  1333. if (command_parms->size > 0) {
  1334. sep = new Seperator(command_parms->data.c_str(), ' ', 10, 500, true);
  1335. if (sep && sep->arg[0] && remote_commands->validSubCommand(command->command.data, string(sep->arg[0]))) {
  1336. parent_command = command;
  1337. command = &(remote_commands->subcommands[command->command.data][string(sep->arg[0])]);
  1338. safe_delete(sep);
  1339. if (command_parms->data.length() > (command->command.data.length() + 1))
  1340. sep = new Seperator(command_parms->data.c_str() + (command->command.data.length() + 1), ' ', 10, 500, true);
  1341. LogWrite(COMMAND__DEBUG, 1, "Command", "Handler: %u, COMMAND: '%s', SUBCOMMAND: '%s'", index, parent_command->command.data.c_str(), command->command.data.c_str());
  1342. }
  1343. else
  1344. LogWrite(COMMAND__DEBUG, 1, "Command", "Handler: %u, COMMAND: '%s'", index, command->command.data.c_str());
  1345. }
  1346. int ndx = 0;
  1347. if (command->required_status > client->GetAdminStatus())
  1348. {
  1349. 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());
  1350. safe_delete(sep);
  1351. client->SimpleMessage(3, "Error: Your status is insufficient for this command.");
  1352. return;
  1353. }
  1354. Player* player = client->GetPlayer();
  1355. LogWrite(COMMAND__DEBUG, 0, "Command", "Player '%s' (%u), Command: %s", player->GetName(), client->GetAccountID(), command->command.data.c_str());
  1356. switch (command->handler) {
  1357. case COMMAND_RELOAD: {
  1358. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reload commands:");
  1359. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload structs");
  1360. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload items");
  1361. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload luasystem");
  1362. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spawnscripts");
  1363. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spells");
  1364. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload quests");
  1365. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spawns");
  1366. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload groundspawns");
  1367. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload zonescripts");
  1368. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload entity_commands");
  1369. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload factions");
  1370. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload mail");
  1371. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload guilds");
  1372. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload locations");
  1373. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload rules");
  1374. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload transporters");
  1375. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload startabilities");
  1376. break;
  1377. }
  1378. case COMMAND_RELOADSTRUCTS: {
  1379. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Structs...");
  1380. world.SetReloadingSubsystem("Structs");
  1381. configReader.ReloadStructs();
  1382. world.RemoveReloadingSubSystem("Structs");
  1383. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1384. break;
  1385. }
  1386. case COMMAND_RELOAD_QUESTS: {
  1387. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Quests...");
  1388. world.SetReloadingSubsystem("Quests");
  1389. master_quest_list.Reload();
  1390. client_list.ReloadQuests();
  1391. zone_list.ReloadClientQuests();
  1392. world.RemoveReloadingSubSystem("Quests");
  1393. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1394. break;
  1395. }
  1396. case COMMAND_RELOAD_SPAWNS: {
  1397. client->GetCurrentZone()->ReloadSpawns();
  1398. break;
  1399. }
  1400. case COMMAND_RELOAD_SPELLS: {
  1401. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spells...");
  1402. world.SetReloadingSubsystem("Spells");
  1403. zone_list.DeleteSpellProcess();
  1404. master_spell_list.Reload();
  1405. if (lua_interface)
  1406. lua_interface->ReloadSpells();
  1407. zone_list.LoadSpellProcess();
  1408. world.RemoveReloadingSubSystem("Spells");
  1409. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1410. break;
  1411. }
  1412. case COMMAND_RELOAD_GROUNDSPAWNS: {
  1413. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Groundspawn Entries...");
  1414. world.SetReloadingSubsystem("GroundSpawns");
  1415. client->GetCurrentZone()->DeleteGroundSpawnItems();
  1416. client->GetCurrentZone()->LoadGroundSpawnEntries();
  1417. world.RemoveReloadingSubSystem("GroundSpawns");
  1418. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1419. break;
  1420. }
  1421. case COMMAND_RELOAD_ZONESCRIPTS: {
  1422. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Zone Scripts...");
  1423. world.SetReloadingSubsystem("ZoneScripts");
  1424. world.ResetZoneScripts();
  1425. database.LoadZoneScriptData();
  1426. if (lua_interface)
  1427. lua_interface->DestroyZoneScripts();
  1428. world.RemoveReloadingSubSystem("ZoneScripts");
  1429. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1430. break;
  1431. }
  1432. case COMMAND_RELOAD_ENTITYCOMMANDS: {
  1433. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Entity Commands...");
  1434. world.SetReloadingSubsystem("EntityCommands");
  1435. client->GetCurrentZone()->ClearEntityCommands();
  1436. database.LoadEntityCommands(client->GetCurrentZone());
  1437. world.RemoveReloadingSubSystem("EntityCommands");
  1438. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1439. break;
  1440. }
  1441. case COMMAND_RELOAD_FACTIONS: {
  1442. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Factions...");
  1443. world.SetReloadingSubsystem("Factions");
  1444. master_faction_list.Clear();
  1445. database.LoadFactionList();
  1446. world.RemoveReloadingSubSystem("Factions");
  1447. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1448. break;
  1449. }
  1450. case COMMAND_RELOAD_MAIL: {
  1451. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Mail...");
  1452. zone_list.ReloadMail();
  1453. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1454. break;
  1455. }
  1456. case COMMAND_RELOAD_GUILDS: {
  1457. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Guilds...");
  1458. world.ReloadGuilds();
  1459. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1460. break;
  1461. }
  1462. case COMMAND_RELOAD_LOCATIONS: {
  1463. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Locations...");
  1464. client->GetPlayer()->GetZone()->RemoveLocationGrids();
  1465. database.LoadLocationGrids(client->GetPlayer()->GetZone());
  1466. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1467. break;
  1468. }
  1469. case COMMAND_RELOAD_RULES: {
  1470. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Rules...");
  1471. database.LoadRuleSets(true);
  1472. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1473. break;
  1474. }
  1475. case COMMAND_RELOAD_TRANSPORTERS: {
  1476. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Transporters in your current zone...");
  1477. database.LoadTransporters(client->GetCurrentZone());
  1478. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1479. break;
  1480. }
  1481. case COMMAND_RELOAD_STARTABILITIES: {
  1482. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Starting Skills/Spells...");
  1483. world.PurgeStartingLists();
  1484. world.LoadStartingLists();
  1485. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1486. break;
  1487. }
  1488. case COMMAND_READ: {
  1489. if (sep && sep->arg[1][0] && sep->IsNumber(1)) {
  1490. if (strcmp(sep->arg[0], "read") == 0) {
  1491. int32 item_index = atol(sep->arg[1]);
  1492. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  1493. if (item) {
  1494. Spawn* spawn = cmdTarget;
  1495. client->SendShowBook(client->GetPlayer(), item->name, item->book_pages);
  1496. break;
  1497. }
  1498. }
  1499. }
  1500. break;
  1501. }
  1502. case COMMAND_USEABILITY:{
  1503. if (sep && sep->arg[0][0] && sep->IsNumber(0)) {
  1504. if (client->GetPlayer()->GetHP() == 0) {
  1505. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot do that right now.");
  1506. }
  1507. else {
  1508. int32 spell_id = atoul(sep->arg[0]);
  1509. int8 spell_tier = 0;
  1510. if (sep->arg[1][0] && sep->IsNumber(1))
  1511. spell_tier = atoi(sep->arg[1]);
  1512. else
  1513. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  1514. if (!spell_tier)
  1515. spell_tier = 1;
  1516. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  1517. if (spell) {
  1518. 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)
  1519. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), cmdTarget, true, true);
  1520. else
  1521. {
  1522. if (cmdTarget)
  1523. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), cmdTarget);
  1524. else
  1525. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  1526. }
  1527. }
  1528. }
  1529. }
  1530. else if (cmdTarget && cmdTarget->IsWidget())
  1531. {
  1532. Widget* widget = (Widget*)cmdTarget;
  1533. widget->HandleUse(client, "use", WIDGET_TYPE_DOOR);
  1534. }
  1535. else
  1536. {
  1537. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /useability {spell_id} [spell_tier]");
  1538. }
  1539. break;
  1540. }
  1541. case COMMAND_INFO:{
  1542. if(sep && sep->arg[1][0] && sep->IsNumber(1)){
  1543. if(strcmp(sep->arg[0], "inventory") == 0){
  1544. int32 item_index = atol(sep->arg[1]);
  1545. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  1546. if(item){
  1547. if (item->IsCollectable() && client->SendCollectionsForItem(item))
  1548. break;
  1549. EQ2Packet* app = item->serialize(client->GetVersion(), (!item->GetItemScript() || !lua_interface), client->GetPlayer());
  1550. //DumpPacket(app);
  1551. client->QueuePacket(app);
  1552. if(item->GetItemScript() && lua_interface)
  1553. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  1554. else if(item->generic_info.offers_quest_id > 0){ //leave the current functionality in place if it doesnt have an item script
  1555. Quest* quest = master_quest_list.GetQuest(item->generic_info.offers_quest_id, false);
  1556. if(quest && client->GetPlayer()->GetCompletedQuest(item->generic_info.offers_quest_id) == 0 && client->GetPlayer()->GetQuest(item->generic_info.offers_quest_id) == 0)
  1557. client->AddPendingQuest(new Quest(quest)); // copy quest since we pulled the master quest to see if it existed or not
  1558. }
  1559. }
  1560. else
  1561. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Index: %u", item_index);
  1562. }
  1563. else if(strcmp(sep->arg[0], "equipment") == 0){
  1564. int32 item_index = atol(sep->arg[1]);
  1565. Item* item = client->GetPlayer()->GetEquipmentList()->GetItem(item_index);
  1566. if(item){
  1567. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1568. client->QueuePacket(app);
  1569. if(item->GetItemScript() && lua_interface)
  1570. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  1571. }
  1572. else
  1573. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Index: %u", item_index);
  1574. }
  1575. else if(strcmp(sep->arg[0], "appearance") == 0){
  1576. int32 item_index = atol(sep->arg[1]);
  1577. Item* item = client->GetPlayer()->GetAppearanceEquipmentList()->GetItem(item_index);
  1578. if(item){
  1579. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1580. client->QueuePacket(app);
  1581. if(item->GetItemScript() && lua_interface)
  1582. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  1583. }
  1584. else
  1585. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Index: %u", item_index);
  1586. }
  1587. 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){
  1588. int32 item_id = atoul(sep->arg[1]);
  1589. Item* item = master_item_list.GetItem(item_id);
  1590. if(item){
  1591. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1592. client->QueuePacket(app);
  1593. }
  1594. else
  1595. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Item ID: %u", item_id);
  1596. }
  1597. else if (strcmp(sep->arg[0], "spell") == 0) {
  1598. sint32 spell_id = atol(sep->arg[1]);
  1599. int8 tier = atoi(sep->arg[3]);
  1600. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, tier, client, true, 0x2A);
  1601. if (outapp)
  1602. client->QueuePacket(outapp);
  1603. else
  1604. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  1605. }
  1606. else if (strcmp(sep->arg[0], "achievement") == 0) {
  1607. sint32 spell_id = atol(sep->arg[2]);
  1608. int8 group = atoi(sep->arg[1]);
  1609. AltAdvanceData* data = 0;
  1610. SpellBookEntry* spellentry = 0;
  1611. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  1612. LogWrite(COMMAND__ERROR, 0, "Command", "AA Spell ID and/or Tier, ID: %u, Group: %i", spell_id, group);
  1613. EQ2Packet* outapp = master_spell_list.GetAASpellPacket(spell_id, tier, client, true, 0x45);
  1614. if (outapp)
  1615. client->QueuePacket(outapp);
  1616. else
  1617. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, group);
  1618. }
  1619. else if (strcmp(sep->arg[0], "spellbook") == 0) {
  1620. sint32 spell_id = atol(sep->arg[1]);
  1621. int32 tier = atoi(sep->arg[2]);
  1622. if (tier > 255) {
  1623. SpellBookEntry* ent = client->GetPlayer()->GetSpellBookSpell(spell_id);
  1624. if (ent)
  1625. tier = ent->tier;
  1626. }
  1627. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, (int8)tier, client, true, 0x2A);
  1628. if (outapp)
  1629. client->QueuePacket(outapp);
  1630. else
  1631. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  1632. }
  1633. else if (strcmp(sep->arg[0], "recipe") == 0) {
  1634. sint32 recipe_id = atol(sep->arg[1]);
  1635. EQ2Packet* outapp = master_recipe_list.GetRecipePacket(recipe_id, client, true, 0x2C);
  1636. if(outapp)
  1637. client->QueuePacket(outapp);
  1638. else
  1639. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Recipe ID: %u", recipe_id);
  1640. }
  1641. else if (strcmp(sep->arg[0], "maintained") ==0) {
  1642. int32 slot = atol(sep->arg[1]);
  1643. int32 spell_id = atol(sep->arg[2]);
  1644. LogWrite(COMMAND__DEBUG, 5, "Command", "Unknown Spell ID - Slot: %u unknown: %u", slot, spell_id);
  1645. //int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  1646. MaintainedEffects* info = client->GetPlayer()->GetMaintainedSpellBySlot(slot);
  1647. EQ2Packet* outapp = master_spell_list.GetSpellPacket(info->spell_id, info->tier, client, true, 0x00);
  1648. if(outapp)
  1649. client->QueuePacket(outapp);
  1650. else
  1651. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID: %u", spell_id);
  1652. }
  1653. else if (strcmp(sep->arg[0], "effect") == 0) {
  1654. int32 spell_id = atol(sep->arg[1]);
  1655. LogWrite(COMMAND__DEBUG, 5, "Command", "Unknown Spell ID: %u", spell_id);
  1656. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  1657. int8 type = 0;
  1658. if (client->GetVersion() <= 546)
  1659. type = 1;
  1660. EQ2Packet* outapp = master_spell_list.GetSpecialSpellPacket(spell_id, tier, client, true, type);
  1661. if (outapp){
  1662. client->QueuePacket(outapp);
  1663. }
  1664. else
  1665. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID: %u", spell_id);
  1666. }
  1667. }
  1668. else if (sep && strcmp(sep->arg[0], "overflow") == 0) {
  1669. Item* item = player->item_list.GetOverflowItem();
  1670. if(item) {
  1671. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1672. client->QueuePacket(app);
  1673. }
  1674. else
  1675. LogWrite(COMMAND__ERROR, 0,"Command", "Unable to retrieve an overflow item.");
  1676. }
  1677. else
  1678. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /info {inventory|equipment|spell} {id}");
  1679. break;
  1680. }
  1681. case COMMAND_USE_EQUIPPED_ITEM:{
  1682. if (sep && sep->arg[0] && sep->IsNumber(0)){
  1683. int32 slot_id = atoul(sep->arg[0]);
  1684. Item* item = player->GetEquipmentList()->GetItem(slot_id);
  1685. if (item && item->generic_info.usable && item->GetItemScript())
  1686. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player);
  1687. }
  1688. break;
  1689. }
  1690. case COMMAND_USE_ITEM: {
  1691. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  1692. int32 item_index = atoul(sep->arg[0]);
  1693. Item* item = player->item_list.GetItemFromIndex(item_index);
  1694. if (item && item->GetItemScript()) {
  1695. if (item->generic_info.max_charges == 0 || item->generic_info.max_charges == 0xFFFF)
  1696. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player);
  1697. else {
  1698. if (item->details.count > 0) {
  1699. std::string itemName = string(item->name);
  1700. int32 item_id = item->details.item_id;
  1701. sint64 flags = 0;
  1702. if(lua_interface->RunItemScript(item->GetItemScript(), "used", item, player, &flags) && flags >= 0)
  1703. {
  1704. //reobtain item make sure it wasn't removed
  1705. Item* item = player->item_list.GetItemFromIndex(item_index);
  1706. if(!item)
  1707. LogWrite(PLAYER__WARNING, 0, "Command", "%s: Item %s (%i) was used, however after the item looks to be removed.", client->GetPlayer()->GetName(), itemName.c_str(), item_id);
  1708. else if(!item->generic_info.display_charges && item->generic_info.max_charges == 1)
  1709. client->RemoveItem(item, 1); // end of a set of charges OR an item that uses a stack count of actual item quantity
  1710. else
  1711. {
  1712. item->details.count--; // charges
  1713. item->save_needed = true;
  1714. client->QueuePacket(item->serialize(client->GetVersion(), false, client->GetPlayer()));
  1715. }
  1716. }
  1717. else
  1718. LogWrite(PLAYER__WARNING, 0, "Command", "%s: Item %s (%i) was used, after it returned %i, bypassing any removal/update of items.", client->GetPlayer()->GetName(), itemName.c_str(), item_id, flags);
  1719. }
  1720. else
  1721. {
  1722. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Item is out of charges.");
  1723. LogWrite(PLAYER__ERROR, 0, "Command", "%s: Item %s (%i) attempted to be used, however details.count is 0.", client->GetPlayer()->GetName(), item->name.c_str(), item->details.item_id);
  1724. }
  1725. }
  1726. }
  1727. }
  1728. break;
  1729. }
  1730. case COMMAND_SCRIBE_SCROLL_ITEM: {
  1731. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  1732. Item* item = player->item_list.GetItemFromUniqueID(atoul(sep->arg[0]));
  1733. if (item) {
  1734. LogWrite(ITEM__DEBUG, 0, "Items", "ITEM ID: %u", item->details.item_id);
  1735. if(item->generic_info.item_type == 6) {
  1736. Spell* spell = master_spell_list.GetSpell(item->skill_info->spell_id, item->skill_info->spell_tier);
  1737. int8 old_slot = 0;
  1738. if (spell) {
  1739. int16 tier_up = player->GetTierUp(spell->GetSpellTier());
  1740. if (rule_manager.GetGlobalRule(R_Spells, RequirePreviousTierScribe)->GetInt8() && !player->HasSpell(spell->GetSpellID(), tier_up, false, true))
  1741. client->SimpleMessage(CHANNEL_COLOR_RED, "You have not scribed the required previous version of this ability.");
  1742. else if (!player->HasSpell(spell->GetSpellID(), spell->GetSpellTier(), true)) {
  1743. old_slot = player->GetSpellSlot(spell->GetSpellID());
  1744. player->RemoveSpellBookEntry(spell->GetSpellID());
  1745. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  1746. player->UnlockSpell(spell);
  1747. client->SendSpellUpdate(spell);
  1748. database.DeleteItem(client->GetCharacterID(), item, 0);
  1749. player->item_list.RemoveItem(item, true);
  1750. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  1751. client->QueuePacket(player->SendInventoryUpdate(client->GetVersion()));
  1752. // force purge client cache and display updated spell for hover over
  1753. EQ2Packet* app = spell->SerializeSpell(client, false, false);
  1754. client->QueuePacket(app);
  1755. }
  1756. }
  1757. else
  1758. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown spell ID: %u and tier: %u", item->skill_info->spell_id, item->skill_info->spell_tier);
  1759. }
  1760. else if(item->generic_info.item_type == 7){
  1761. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Scribing recipe book %s (%u) for player %s.", item->name.c_str(), item->details.item_id, player->GetName());
  1762. Recipe* recipe_book = new Recipe(master_recipebook_list.GetRecipeBooks(item->details.item_id));
  1763. // if valid recipe book and the player doesn't have it
  1764. if (recipe_book && recipe_book->GetLevel() > client->GetPlayer()->GetTSLevel()) {
  1765. client->Message(CHANNEL_NARRATIVE, "Your tradeskill level is not high enough to scribe this book.");
  1766. safe_delete(recipe_book);
  1767. }
  1768. else if (recipe_book && !(client->GetPlayer()->GetRecipeBookList()->HasRecipeBook(item->details.item_id))) {
  1769. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Valid recipe book that the player doesn't have");
  1770. // Add recipe book to the players list
  1771. client->GetPlayer()->GetRecipeBookList()->AddRecipeBook(recipe_book);
  1772. // Get a list of all recipes this book contains
  1773. vector<Recipe*>* book_recipes = master_recipe_list.GetRecipes(recipe_book->GetBookName());
  1774. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "%i recipes found for %s book", book_recipes->size(), recipe_book->GetBookName());
  1775. // Create the packet to send to update the players recipe list
  1776. PacketStruct* packet = 0;
  1777. if (client->GetRecipeListSent()) {
  1778. packet = configReader.getStruct("WS_RecipeList", client->GetVersion());
  1779. if (packet)
  1780. packet->setArrayLengthByName("num_recipes", book_recipes->size());
  1781. }
  1782. // loop through the list
  1783. vector<Recipe*>::iterator itr;
  1784. int16 i = 0;
  1785. for (itr = book_recipes->begin(); itr != book_recipes->end(); itr++) {
  1786. // check to see if the player already has this recipe some how
  1787. if (!client->GetPlayer()->GetRecipeList()->GetRecipe((*itr)->GetID())) {
  1788. // Player doesn't already have this recipe so lets add it
  1789. Recipe* recipe = new Recipe(master_recipe_list.GetRecipe((*itr)->GetID()));
  1790. client->GetPlayer()->GetRecipeList()->AddRecipe(recipe);
  1791. database.SavePlayerRecipe(client->GetPlayer(), recipe->GetID());
  1792. client->Message(CHANNEL_NARRATIVE, "Recipe: \"%s\" put in recipe book.", recipe->GetName());
  1793. if (packet && client->GetRecipeListSent()) {
  1794. packet->setArrayDataByName("id", recipe->GetID(), i);
  1795. packet->setArrayDataByName("tier", recipe->GetTier(), i);
  1796. packet->setArrayDataByName("level", recipe->GetLevel(), i);
  1797. packet->setArrayDataByName("icon", recipe->GetIcon(), i);
  1798. packet->setArrayDataByName("classes", recipe->GetClasses(), i);
  1799. packet->setArrayDataByName("skill", recipe->GetSkill(), i);
  1800. packet->setArrayDataByName("technique", recipe->GetTechnique(), i);
  1801. packet->setArrayDataByName("knowledge", recipe->GetKnowledge(), i);
  1802. packet->setArrayDataByName("unknown2", recipe->GetUnknown2(), i);
  1803. packet->setArrayDataByName("recipe_name", recipe->GetName(), i);
  1804. packet->setArrayDataByName("recipe_book", recipe->GetBook(), i);
  1805. packet->setArrayDataByName("unknown3", recipe->GetUnknown3(), i);
  1806. i++;
  1807. }
  1808. }
  1809. }
  1810. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Done adding recipes");
  1811. database.SavePlayerRecipeBook(client->GetPlayer(), recipe_book->GetBookID());
  1812. database.DeleteItem(client->GetCharacterID(), item, 0);
  1813. client->GetPlayer()->item_list.RemoveItem(item, true);
  1814. client->QueuePacket(client->GetPlayer()->SendInventoryUpdate(client->GetVersion()));
  1815. if (packet && client->GetRecipeListSent())
  1816. client->QueuePacket(packet->serialize());
  1817. safe_delete(packet);
  1818. }
  1819. else {
  1820. if (recipe_book)
  1821. client->Message(CHANNEL_NARRATIVE, "You have already learned all you can from this item.");
  1822. safe_delete(recipe_book);
  1823. }
  1824. }
  1825. }
  1826. else
  1827. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown unique item ID: %s", sep->arg[0]);
  1828. }
  1829. break;
  1830. }
  1831. case COMMAND_SUMMONITEM: {
  1832. if (sep && sep->IsNumber(0)) {
  1833. int32 item_id = atol(sep->arg[0]);
  1834. int32 quantity = 1;
  1835. if (sep->arg[1] && sep->IsNumber(1))
  1836. quantity = atoi(sep->arg[1]);
  1837. if (sep->arg[2] && strncasecmp(sep->arg[2], "bank", 4) == 0) {
  1838. client->AddItemToBank(item_id,quantity);
  1839. }
  1840. else {
  1841. client->AddItem(item_id, quantity);
  1842. }
  1843. }
  1844. else {
  1845. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} [quantity] or");
  1846. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} {quantity} [location] where location = bank");
  1847. }
  1848. break;
  1849. }
  1850. case COMMAND_COLLECTION_ADDITEM: {
  1851. // takes 2 params: collection_id, slot
  1852. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  1853. Item *item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(atoul(sep->arg[1]));
  1854. if (item)
  1855. client->HandleCollectionAddItem(atoul(sep->arg[0]), item);
  1856. else
  1857. 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]));
  1858. }
  1859. else
  1860. LogWrite(COLLECTION__ERROR, 0, "Collect", "Received command 'COMMAND_COLLECTION_ADDITEM' with unhandeled argument types");
  1861. break;
  1862. }
  1863. case COMMAND_COLLECTION_FILTER_MATCHITEM: {
  1864. // takes 1 param: slot
  1865. printf("COMMAND_COLLECTION_FILTER_MATCHITEM:\n");
  1866. int i = 0;
  1867. while (sep->arg[i] && strlen(sep->arg[i]) > 0) {
  1868. printf("\t%u: %s\n", i, sep->arg[i]);
  1869. i++;
  1870. }
  1871. break;
  1872. }
  1873. case COMMAND_WAYPOINT: {
  1874. bool success = false;
  1875. client->ClearWaypoint();
  1876. if (sep && sep->IsNumber(0) && sep->IsNumber(1) && sep->IsNumber(2)) {
  1877. if (!client->ShowPathToTarget(atof(sep->arg[0]), atof(sep->arg[1]), atof(sep->arg[2]), 0))
  1878. client->Message(CHANNEL_COLOR_RED, "Invalid coordinates given");
  1879. }
  1880. else if ( client->GetAdminStatus() > 100 && cmdTarget ) {
  1881. if (!client->ShowPathToTarget(cmdTarget->GetX(), cmdTarget->GetY(), cmdTarget->GetZ(), 0))
  1882. client->Message(CHANNEL_COLOR_RED, "Invalid coordinates given");
  1883. }
  1884. else {
  1885. client->Message(CHANNEL_COLOR_YELLOW, "Usage: /waypoint x y z");
  1886. }
  1887. break;
  1888. }
  1889. case COMMAND_WHO:{
  1890. const char* who = 0;
  1891. if(sep && sep->arg[0]){
  1892. //cout << "Who query: \n";
  1893. who = sep->argplus[0];
  1894. //cout << who << endl;
  1895. }
  1896. zone_list.ProcessWhoQuery(who, client);
  1897. break;
  1898. }
  1899. case COMMAND_SELECT_JUNCTION:{
  1900. LogWrite(MISC__TODO, 1, "TODO", "For access/travel selections (i.e. Mariner Bells, Player Death Window, etc.)\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1901. int32 choice = 0;
  1902. if(sep && sep->arg[0] && sep->IsNumber(0))
  1903. choice = atoul(sep->arg[0]);
  1904. if(client->GetPlayer()->GetHP() == 0){ //dead and this is a revive request
  1905. client->HandlePlayerRevive(choice);
  1906. }
  1907. break;
  1908. }
  1909. case COMMAND_SPAWN_MOVE: {
  1910. if (cmdTarget && cmdTarget->IsPlayer() == false) {
  1911. PacketStruct* packet = configReader.getStruct("WS_MoveObjectMode", client->GetVersion());
  1912. if (packet) {
  1913. float unknown2_3 = 0;
  1914. int8 placement_mode = 0;
  1915. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::DEFAULT);
  1916. if (sep && sep->arg[0][0]) {
  1917. if (strcmp(sep->arg[0], "wall") == 0) {
  1918. placement_mode = 2;
  1919. unknown2_3 = 150;
  1920. }
  1921. else if (strcmp(sep->arg[0], "ceiling") == 0)
  1922. placement_mode = 1;
  1923. else if (strcmp(sep->arg[0], "openheading") == 0 && cmdTarget->IsWidget())
  1924. {
  1925. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "[PlacementMode] WIDGET OPEN HEADING MODE");
  1926. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::OPEN_HEADING);
  1927. }
  1928. else if (strcmp(sep->arg[0], "closeheading") == 0 && cmdTarget->IsWidget())
  1929. {
  1930. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "[PlacementMode] WIDGET CLOSE HEADING MODE");
  1931. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::CLOSE_HEADING);
  1932. }
  1933. else if (strcmp(sep->arg[0], "myloc") == 0)
  1934. {
  1935. if (cmdTarget->GetSpawnLocationPlacementID() < 1) {
  1936. client->Message(CHANNEL_COLOR_YELLOW, "[PlacementMode] Spawn %s cannot be moved it is not assigned a spawn location placement id.", cmdTarget->GetName());
  1937. safe_delete(packet);
  1938. break;
  1939. }
  1940. cmdTarget->SetX(client->GetPlayer()->GetX(), true);
  1941. cmdTarget->SetY(client->GetPlayer()->GetY(), true);
  1942. cmdTarget->SetZ(client->GetPlayer()->GetZ(), true);
  1943. cmdTarget->SetHeading(client->GetPlayer()->GetHeading(), true);
  1944. if (database.UpdateSpawnLocationSpawns(cmdTarget))
  1945. client->Message(CHANNEL_COLOR_YELLOW, "[PlacementMode] Spawn %s placed at your location. Updated spawn_location_placement for spawn.", cmdTarget->GetName());
  1946. safe_delete(packet);
  1947. break;
  1948. }
  1949. }
  1950. packet->setDataByName("placement_mode", placement_mode);
  1951. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget));
  1952. packet->setDataByName("model_type", cmdTarget->GetModelType());
  1953. packet->setDataByName("unknown", 1); //size
  1954. packet->setDataByName("unknown2", 1); //size 2
  1955. packet->setDataByName("unknown2", .5, 1); //size 3
  1956. packet->setDataByName("unknown2", 3, 2);
  1957. packet->setDataByName("unknown2", unknown2_3, 3);
  1958. packet->setDataByName("max_distance", 500);
  1959. packet->setDataByName("CoEunknown", 0xFFFFFFFF);
  1960. client->QueuePacket(packet->serialize());
  1961. safe_delete(packet);
  1962. }
  1963. }
  1964. else {
  1965. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /spawn move (wall OR ceiling)");
  1966. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Moves a spawn anywhere you like. Optionally wall/ceiling can be provided to place wall/ceiling items.");
  1967. }
  1968. break;
  1969. }
  1970. case COMMAND_HAIL:{
  1971. Spawn* spawn = cmdTarget;
  1972. if(spawn && spawn->GetTargetable())
  1973. {
  1974. char tmp[75] = {0};
  1975. sprintf(tmp, "Hail, %s", spawn->GetName());
  1976. bool show_bubble = true;
  1977. if (spawn->IsNPC())
  1978. show_bubble = false;
  1979. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp, HEAR_SPAWN_DISTANCE, 0, show_bubble);
  1980. if(spawn->IsPlayer() == false && spawn->GetDistance(client->GetPlayer()) < rule_manager.GetGlobalRule(R_Spawn, HailDistance)->GetInt32()){
  1981. if(spawn->IsNPC() && ((NPC*)spawn)->EngagedInCombat())
  1982. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED_BUSY, client->GetPlayer());
  1983. else
  1984. {
  1985. bool pauseRunback = false;
  1986. // prime runback as the heading or anything can be altered when hailing succeeds
  1987. if(spawn->IsNPC() && (spawn->HasMovementLoop() || spawn->HasMovementLocations()))
  1988. {
  1989. ((NPC*)spawn)->StartRunback();
  1990. pauseRunback = true;
  1991. }
  1992. if(spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED, client->GetPlayer()) && pauseRunback)
  1993. spawn->PauseMovement(rule_manager.GetGlobalRule(R_Spawn, HailMovementPause)->GetInt32());
  1994. else if(spawn->IsNPC() && pauseRunback)
  1995. ((NPC*)spawn)->ClearRunback();
  1996. }
  1997. }
  1998. }
  1999. else {
  2000. string tmp = "Hail";
  2001. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp.c_str(), HEAR_SPAWN_DISTANCE, 0, true);
  2002. }
  2003. break;
  2004. }
  2005. case COMMAND_SAY:{
  2006. if (sep && sep->arg[0][0]) {
  2007. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, sep->argplus[0], HEAR_SPAWN_DISTANCE);
  2008. if (cmdTarget && !(cmdTarget->IsPlayer()))
  2009. client->GetCurrentZone()->CallSpawnScript(cmdTarget, SPAWN_SCRIPT_HEAR_SAY, client->GetPlayer(), sep->argplus[0]);
  2010. }
  2011. else
  2012. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /say {message}");
  2013. break;
  2014. }
  2015. case COMMAND_TELL:{
  2016. if(sep && sep->arg[0] && sep->argplus[1]){
  2017. if(!zone_list.HandleGlobalChatMessage(client, sep->arg[0], CHANNEL_PRIVATE_TELL, sep->argplus[1]))
  2018. client->Message(CHANNEL_COLOR_RED,"Unable to find client %s",sep->arg[0]);
  2019. }else
  2020. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /tell {character_name} {message}");
  2021. break;
  2022. }
  2023. case COMMAND_SHOUT:{
  2024. if(sep && sep->arg[0][0])
  2025. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SHOUT, sep->argplus[0]);
  2026. else
  2027. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /shout {message}");
  2028. break;
  2029. }
  2030. case COMMAND_AUCTION:{
  2031. if(sep && sep->arg[0][0])
  2032. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_AUCTION, sep->argplus[0]);
  2033. else
  2034. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /auction {message}");
  2035. break;
  2036. }
  2037. case COMMAND_OOC:{
  2038. //For now ooc will be the global chat channel, eventually when we create more channels we will create a global chat channel
  2039. if(sep && sep->arg[0][0])
  2040. zone_list.HandleGlobalChatMessage(client, 0, CHANNEL_OUT_OF_CHARACTER, sep->argplus[0]);
  2041. else
  2042. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /ooc {message}");
  2043. break;
  2044. }
  2045. case COMMAND_EMOTE:{
  2046. if(sep && sep->arg[0][0])
  2047. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_EMOTE, sep->argplus[0]);
  2048. else
  2049. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /emote {action}");
  2050. break;
  2051. }
  2052. case COMMAND_RACE:{
  2053. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  2054. if(sep->arg[1][0] && sep->IsNumber(1)){
  2055. client->GetPlayer()->GetInfoStruct()->set_race(atoi(sep->arg[1]));
  2056. client->GetPlayer()->SetRace(atoi(sep->arg[1]));
  2057. client->UpdateTimeStampFlag ( RACE_UPDATE_FLAG );
  2058. client->GetPlayer()->SetCharSheetChanged(true);
  2059. }
  2060. client->GetPlayer()->SetModelType(atoi(sep->arg[0]));
  2061. //EQ2Packet* outapp = client->GetPlayer()->spawn_update_packet(client->GetPlayer(), client->GetVersion(), client->GetPlayer()->GetFeatures());
  2062. //client->QueuePacket(outapp);
  2063. }
  2064. else{
  2065. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /race {race type id} {race id}");
  2066. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "{race id} is optional");
  2067. }
  2068. break;
  2069. }
  2070. case COMMAND_BANK_DEPOSIT:{
  2071. if(client->GetBanker() && sep && sep->arg[0]){
  2072. int64 amount = 0;
  2073. string deposit = string(sep->arg[0]);
  2074. amount = atoi64(deposit.c_str());
  2075. client->BankDeposit(amount);
  2076. }
  2077. break;
  2078. }
  2079. case COMMAND_BANK_WITHDRAWAL:{
  2080. if(client->GetBanker() && sep && sep->arg[0] && sep->IsNumber(0)){
  2081. int64 amount = 0;
  2082. string deposit = string(sep->arg[0]);
  2083. amount = atoi64(deposit.c_str());
  2084. client->BankWithdrawal(amount);
  2085. }
  2086. break;
  2087. }
  2088. case COMMAND_BANK_CANCEL:{
  2089. Spawn* banker = cmdTarget;
  2090. client->Bank(banker, true);
  2091. break;
  2092. }
  2093. case COMMAND_BANK:{
  2094. LogWrite(PLAYER__DEBUG, 0, "Players", "Open Player Personal Bank...");
  2095. Spawn* banker = cmdTarget;
  2096. client->Bank(banker);
  2097. break;
  2098. }
  2099. case COMMAND_GUILD_BANK:{
  2100. LogWrite(GUILD__DEBUG, 0, "Guilds", "Open Guild Bank...");
  2101. //Spawn* banker = client->GetPlayer()->GetTarget();
  2102. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will eventually open the guild bank!");
  2103. break;
  2104. }
  2105. case COMMAND_START_MAIL: {
  2106. client->SetMailTransaction(cmdTarget);
  2107. client->SendMailList();
  2108. break;
  2109. }
  2110. case COMMAND_CANCEL_MAIL: {
  2111. client->SetMailTransaction(0);
  2112. break;
  2113. }
  2114. case COMMAND_GET_MAIL_MESSAGE: {
  2115. if (sep && sep->arg[0] && sep->IsNumber(0))
  2116. client->DisplayMailMessage(atoul(sep->arg[0]));
  2117. break;
  2118. }
  2119. case COMMAND_ADD_MAIL_PLAT: {
  2120. if (sep && sep->arg[0] && sep->IsNumber(0))
  2121. client->AddMailCoin(0, 0, 0, atoul(sep->arg[0]));
  2122. break;
  2123. }
  2124. case COMMAND_ADD_MAIL_GOLD: {
  2125. if (sep && sep->arg[0] && sep->IsNumber(0))
  2126. client->AddMailCoin(0, 0, atoul(sep->arg[0]));
  2127. break;
  2128. }
  2129. case COMMAND_ADD_MAIL_SILVER: {
  2130. if (sep && sep->arg[0] && sep->IsNumber(0))
  2131. client->AddMailCoin(0, atoul(sep->arg[0]));
  2132. break;
  2133. }
  2134. case COMMAND_ADD_MAIL_COPPER: {
  2135. if (sep && sep->arg[0] && sep->IsNumber(0))
  2136. client->AddMailCoin(atoul(sep->arg[0]));
  2137. break;
  2138. }
  2139. case COMMAND_SET_MAIL_ITEM: {
  2140. if(sep && sep->IsNumber(0) && sep->IsNumber(2))
  2141. {
  2142. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(atoul(sep->arg[0]));
  2143. if(item)
  2144. {
  2145. int16 quantity = atoul(sep->arg[1]);
  2146. if(item->CheckFlag(NO_TRADE) || item->CheckFlag(ATTUNED) || item->CheckFlag(ARTIFACT) || item->CheckFlag2(HEIRLOOM))
  2147. {
  2148. return;
  2149. }
  2150. if(item->IsBag())
  2151. {
  2152. vector<Item*>* bag_items = player->GetPlayerItemList()->GetItemsInBag(item);
  2153. if(bag_items && bag_items->size() > 0)
  2154. {
  2155. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot mail a bag with items inside it.");
  2156. safe_delete(bag_items);
  2157. return;
  2158. }
  2159. safe_delete(bag_items);
  2160. }
  2161. Item* itemtoadd = item;
  2162. if(quantity > 0)
  2163. {
  2164. if(quantity > item->details.count)
  2165. return;
  2166. Item* tmpItem = new Item(item);
  2167. tmpItem->details.count = quantity;
  2168. itemtoadd = tmpItem;
  2169. }
  2170. if(client->AddMailItem(itemtoadd))
  2171. {
  2172. client->RemoveItem(item, quantity, true);
  2173. }
  2174. }
  2175. }
  2176. break;
  2177. }
  2178. case COMMAND_REMOVE_MAIL_PLAT: {
  2179. if (sep && sep->arg[0] && sep->IsNumber(0))
  2180. client->RemoveMailCoin(0, 0, 0, atoul(sep->arg[0]));
  2181. break;
  2182. }
  2183. case COMMAND_REMOVE_MAIL_GOLD: {
  2184. if (sep && sep->arg[0] && sep->IsNumber(0))
  2185. client->RemoveMailCoin(0, 0, atoul(sep->arg[0]));
  2186. break;
  2187. }
  2188. case COMMAND_REMOVE_MAIL_SILVER: {
  2189. if (sep && sep->arg[0] && sep->IsNumber(0))
  2190. client->RemoveMailCoin(0, atoul(sep->arg[0]));
  2191. break;
  2192. }
  2193. case COMMAND_REMOVE_MAIL_COPPER: {
  2194. if (sep && sep->arg[0] && sep->IsNumber(0))
  2195. client->RemoveMailCoin(atoul(sep->arg[0]));
  2196. break;
  2197. }
  2198. case COMMAND_TAKE_MAIL_ATTACHMENTS: {
  2199. if (sep && sep->arg[0] && sep->IsNumber(0))
  2200. client->TakeMailAttachments(atoul(sep->arg[0]));
  2201. break;
  2202. }
  2203. case COMMAND_CANCEL_SEND_MAIL: {
  2204. client->ResetSendMail();
  2205. break;
  2206. }
  2207. case COMMAND_DELETE_MAIL_MESSAGE: {
  2208. if (sep && sep->arg[0] && sep->IsNumber(0))
  2209. client->DeleteMail(atoul(sep->arg[0]), true);
  2210. break;
  2211. }
  2212. case COMMAND_REPORT_SPAM: {
  2213. LogWrite(MISC__TODO, 1, "TODO", " received reportspam\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  2214. if (sep && sep->arg[0]) LogWrite(COMMAND__DEBUG, 0, "Command", "%s\n", sep->argplus[0]);
  2215. break;
  2216. }
  2217. case COMMAND_KILL:{
  2218. Spawn* dead = 0;
  2219. if (sep && sep->arg[0] && strncasecmp(sep->arg[0],"self",4)==0){
  2220. dead=client->GetPlayer();
  2221. client->GetPlayer()->SetHP(0);
  2222. client->GetPlayer()->KillSpawn(dead);
  2223. }else{
  2224. dead= cmdTarget;
  2225. if(dead && dead->IsPlayer() == false){
  2226. dead->SetHP(0);
  2227. if(sep && sep->arg[0] && sep->IsNumber(0) && atoi(sep->arg[0]) == 1)
  2228. client->GetCurrentZone()->RemoveSpawn(dead, true);
  2229. else
  2230. client->GetPlayer()->KillSpawn(dead);
  2231. }else{
  2232. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /kill (self)");
  2233. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Kills currently selected non-player target.");
  2234. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Optionally, self may be used to kill yourself");
  2235. }
  2236. }
  2237. break;
  2238. }
  2239. case COMMAND_LEVEL:{
  2240. if(sep && sep->arg[ndx][0] && sep->IsNumber(0)){
  2241. int16 new_level = atoi(sep->arg[ndx]);
  2242. if (!client->GetPlayer()->CheckLevelStatus(new_level))
  2243. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have the required status to level up anymore!");
  2244. else {
  2245. if (new_level < 1)
  2246. new_level = 1;
  2247. if (new_level > 255)
  2248. new_level = 255;
  2249. client->ChangeLevel(client->GetPlayer()->GetLevel(), new_level);
  2250. }
  2251. }else
  2252. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /level {new_level}");
  2253. break;
  2254. }
  2255. case COMMAND_SIT: {
  2256. LogWrite(MISC__TODO, 1, "TODO", " Send update packet to all clients\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  2257. if(client->GetPlayer()->GetHP() > 0){
  2258. client->QueuePacket(new EQ2Packet(OP_SitMsg, 0, 0));
  2259. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You sit down.");
  2260. client->GetPlayer()->set_character_flag(CF_IS_SITTING);
  2261. }
  2262. break;
  2263. }
  2264. case COMMAND_STAND: {
  2265. LogWrite(MISC__TODO, 1, "TODO", " Send update packet to all clients\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  2266. if(client->GetPlayer()->GetHP() > 0){
  2267. client->QueuePacket(new EQ2Packet(OP_StandMsg, 0, 0));
  2268. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You stand up.");
  2269. client->GetPlayer()->reset_character_flag(CF_IS_SITTING);
  2270. }
  2271. break;
  2272. }
  2273. case COMMAND_CLASS:{
  2274. if(sep && sep->arg[ndx][0]){
  2275. client->GetPlayer()->SetPlayerAdventureClass(atoi(sep->arg[ndx]));
  2276. client->UpdateTimeStampFlag ( CLASS_UPDATE_FLAG );
  2277. }else
  2278. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /class {class_id}");
  2279. break;
  2280. }
  2281. case COMMAND_GENDER:{
  2282. if(sep && sep->arg[ndx][0]){
  2283. client->GetPlayer()->GetInfoStruct()->set_gender(atoi(sep->arg[ndx]));
  2284. client->GetPlayer()->SetCharSheetChanged(true);
  2285. client->UpdateTimeStampFlag ( GENDER_UPDATE_FLAG );
  2286. }else{
  2287. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /gender {new_gender_id}");
  2288. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Male: 1");
  2289. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Female: 2");
  2290. }
  2291. break;
  2292. }
  2293. case COMMAND_FLYMODE:{
  2294. if(sep && sep->arg[0] && sep->IsNumber(0)){
  2295. PrintSep(sep, "COMMAND_FLYMODE");
  2296. int8 val = atoi(sep->arg[0]);
  2297. ClientPacketFunctions::SendFlyMode(client, val);
  2298. }
  2299. else{
  2300. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage ON: /flymode 1");
  2301. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage OFF: /flymode 0");
  2302. }
  2303. break;
  2304. }
  2305. case COMMAND_LOOT_LIST:{
  2306. Spawn* spawn = cmdTarget;
  2307. if(spawn && spawn->IsEntity()){
  2308. if (sep && sep->arg[0]) {
  2309. if (!spawn->GetDatabaseID())
  2310. {
  2311. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn has no database id to assign to loottables.");
  2312. break;
  2313. }
  2314. else if (!spawn->IsNPC())
  2315. {
  2316. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "these /loot list [add/remove/clearall] sub-commands are only designed for an NPC.");
  2317. break;
  2318. }
  2319. bool reloadLoot = false;
  2320. if (!stricmp(sep->arg[0], "remove") && sep->arg[1] && sep->IsNumber(1))
  2321. {
  2322. int32 loottable_id = atoul(sep->arg[1]);
  2323. if (loottable_id > 0 && database.RemoveSpawnLootTable(spawn, loottable_id))
  2324. {
  2325. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u loot table %u removed.", spawn->GetDatabaseID(), loottable_id);
  2326. reloadLoot = true;
  2327. }
  2328. else
  2329. client->Message(CHANNEL_COLOR_YELLOW, "/loot list remove [loottableid] - could not match any spawn_id entries against loottable_id %u.", loottable_id);
  2330. }
  2331. else if (!stricmp(sep->arg[0], "add") && sep->arg[1] && sep->IsNumber(1))
  2332. {
  2333. int32 loottable_id = atoul(sep->arg[1]);
  2334. if (loottable_id > 0)
  2335. {
  2336. database.AddLootTableToSpawn(spawn, loottable_id);
  2337. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u loot table %u added.", spawn->GetDatabaseID(), loottable_id);
  2338. reloadLoot = true;
  2339. }
  2340. else
  2341. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list add [loottableid] - cannot add a loottable id of 0.");
  2342. }
  2343. else if (!stricmp(sep->arg[0], "clearall"))
  2344. {
  2345. if (database.RemoveSpawnLootTable(spawn, 0))
  2346. {
  2347. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn loot tables removed.");
  2348. reloadLoot = true;
  2349. }
  2350. else
  2351. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list clearall - could not match any spawn_id entries in loottable_id.");
  2352. }
  2353. else
  2354. {
  2355. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list argument not supported.");
  2356. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list add [loottableid] - add new loottable to spawn");
  2357. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list remove [loottableid] - remove existing loottable from spawn");
  2358. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list clearall - remove all loottables from spawn");
  2359. break;
  2360. }
  2361. if (reloadLoot)
  2362. {
  2363. database.LoadSpawnLoot(spawn->GetZone(), spawn);
  2364. if (spawn->IsNPC())
  2365. {
  2366. Entity* ent = (Entity*)spawn;
  2367. ent->SetLootCoins(0);
  2368. ent->ClearLootList();
  2369. spawn->GetZone()->AddLoot((NPC*)spawn);
  2370. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u active loot purged and reloaded.", spawn->GetDatabaseID());
  2371. }
  2372. }
  2373. break; // nothing further this is the end of these sub commands
  2374. }
  2375. else
  2376. {
  2377. vector<int32> loot_list = client->GetCurrentZone()->GetSpawnLootList(spawn->GetDatabaseID(), spawn->GetZone()->GetZoneID(), spawn->GetLevel(), race_types_list.GetRaceType(spawn->GetModelType()), spawn);
  2378. if (loot_list.size() > 0) {
  2379. client->Message(CHANNEL_COLOR_YELLOW, "%s belongs to the following loot lists: ", spawn->GetName());
  2380. vector<int32>::iterator list_itr;
  2381. LootTable* table = 0;
  2382. for (list_itr = loot_list.begin(); list_itr != loot_list.end(); list_itr++) {
  2383. table = client->GetCurrentZone()->GetLootTable(*list_itr);
  2384. if (table)
  2385. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", *list_itr, table->name.c_str());
  2386. }
  2387. }
  2388. client->Message(CHANNEL_COLOR_YELLOW, "Coins being carried: %u", spawn->GetLootCoins());
  2389. vector<Item*>* items = spawn->GetLootItems();
  2390. if (items) {
  2391. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is carrying the following items: ");
  2392. vector<Item*>::iterator itr;
  2393. Item* item = 0;
  2394. for (itr = items->begin(); itr != items->end(); itr++) {
  2395. item = *itr;
  2396. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", item->details.item_id, item->name.c_str());
  2397. }
  2398. }
  2399. else
  2400. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is not carrying any items.");
  2401. }
  2402. }
  2403. break;
  2404. }
  2405. case COMMAND_LOOT_SETCOIN:{
  2406. Spawn* spawn = cmdTarget;
  2407. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2408. spawn->SetLootCoins(atoul(sep->arg[0]));
  2409. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully set coins.");
  2410. }
  2411. else
  2412. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot setcoin {amount}");
  2413. break;
  2414. }
  2415. case COMMAND_LOOT_ADDITEM:{
  2416. Spawn* spawn = cmdTarget;
  2417. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2418. int16 charges = 1;
  2419. if(sep->arg[1] && sep->IsNumber(1))
  2420. charges = atoi(sep->arg[1]);
  2421. spawn->AddLootItem(atoul(sep->arg[0]), charges);
  2422. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully added item.");
  2423. }
  2424. else
  2425. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot additem {item_id}");
  2426. break;
  2427. }
  2428. case COMMAND_LOOT_REMOVEITEM:{
  2429. Spawn* spawn = cmdTarget;
  2430. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2431. Item* item = spawn->LootItem(atoul(sep->arg[0]));
  2432. safe_delete(item);
  2433. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully removed item.");
  2434. }
  2435. else
  2436. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot removeitem {item_id}");
  2437. break;
  2438. }
  2439. case COMMAND_LOOT_CORPSE:
  2440. case COMMAND_DISARM:
  2441. case COMMAND_LOOT:{
  2442. if (cmdTarget && ((Entity*)cmdTarget)->IsNPC() && cmdTarget->Alive())
  2443. {
  2444. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is not dead.");
  2445. break;
  2446. }
  2447. if(cmdTarget && cmdTarget->IsEntity()){
  2448. if (cmdTarget->GetDistance(client->GetPlayer()) <= rule_manager.GetGlobalRule(R_Loot, LootRadius)->GetFloat()){
  2449. if (!rule_manager.GetGlobalRule(R_Loot, AutoDisarmChest)->GetBool() && command->handler == COMMAND_DISARM )
  2450. client->OpenChest(cmdTarget, true);
  2451. else
  2452. client->Loot(cmdTarget, rule_manager.GetGlobalRule(R_Loot, AutoDisarmChest)->GetBool());
  2453. if (!(cmdTarget)->HasLoot()){
  2454. if (((Entity*)cmdTarget)->IsNPC())
  2455. client->GetCurrentZone()->RemoveDeadSpawn(cmdTarget);
  2456. }
  2457. }
  2458. else
  2459. client->Message(CHANNEL_COLOR_YELLOW, "You are too far away to interact with that");
  2460. }
  2461. else if(!cmdTarget || cmdTarget->GetHP() > 0)
  2462. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid target.");
  2463. break;
  2464. }
  2465. case COMMAND_RELOADSPAWNSCRIPTS:{
  2466. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spawn Scripts....");
  2467. if (lua_interface)
  2468. lua_interface->SetSpawnScriptsReloading(true);
  2469. world.ResetSpawnScripts();
  2470. database.LoadSpawnScriptData();
  2471. if(lua_interface) {
  2472. lua_interface->DestroySpawnScripts();
  2473. lua_interface->SetSpawnScriptsReloading(false);
  2474. }
  2475. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Success!");
  2476. break;
  2477. }
  2478. case COMMAND_RELOADREGIONSCRIPTS:{
  2479. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Region Scripts....");
  2480. if(lua_interface) {
  2481. lua_interface->DestroyRegionScripts();
  2482. }
  2483. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Success!");
  2484. break;
  2485. }
  2486. case COMMAND_RELOADLUASYSTEM:{
  2487. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Attempting to reload entire LUA system....");
  2488. map<Client*, int32> debug_clients = lua_interface->GetDebugClients();
  2489. safe_delete(lua_interface);
  2490. lua_interface = new LuaInterface();
  2491. if(lua_interface)
  2492. lua_interface->SetSpawnScriptsReloading(true);
  2493. if(lua_interface && debug_clients.size() > 0){
  2494. map<Client*, int32>::iterator itr;
  2495. for(itr = debug_clients.begin(); itr != debug_clients .end(); itr++){
  2496. if(lua_interface)
  2497. lua_interface->UpdateDebugClients(itr->first);
  2498. }
  2499. }
  2500. world.ResetSpawnScripts();
  2501. database.LoadSpawnScriptData();
  2502. world.ResetZoneScripts();
  2503. database.LoadZoneScriptData();
  2504. int32 quest_count = database.LoadQuests();
  2505. zone_list.DeleteSpellProcess();
  2506. master_spell_list.Reload();
  2507. int32 spell_count = 0;
  2508. if(lua_interface) {
  2509. lua_interface->DestroySpawnScripts();
  2510. lua_interface->DestroySpells();
  2511. spell_count = database.LoadSpellScriptData();
  2512. lua_interface->SetSpawnScriptsReloading(false);
  2513. }
  2514. zone_list.LoadSpellProcess();
  2515. client->Message(CHANNEL_COLOR_YELLOW, "Successfully loaded %u spell(s), %u quest(s).", spell_count, quest_count);
  2516. break;
  2517. }
  2518. case COMMAND_DECLINE_QUEST:{
  2519. int32 quest_id = 0;
  2520. if(sep && sep->arg[0] && sep->IsNumber(0))
  2521. quest_id = atoul(sep->arg[0]);
  2522. if(quest_id > 0){
  2523. Quest* quest = client->GetPendingQuest(quest_id);
  2524. if(quest){
  2525. client->RemovePendingQuest(quest);
  2526. if(lua_interface)
  2527. lua_interface->CallQuestFunction(quest, "Declined", client->GetPlayer());
  2528. safe_delete(quest);
  2529. client->GetCurrentZone()->SendQuestUpdates(client);
  2530. }
  2531. }
  2532. break;
  2533. }
  2534. case COMMAND_DELETE_QUEST:{
  2535. int32 quest_id = 0;
  2536. if(sep && sep->arg[0] && sep->IsNumber(0))
  2537. quest_id = atoul(sep->arg[0]);
  2538. if(quest_id > 0){
  2539. if(lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0) {
  2540. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  2541. if (quest)
  2542. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  2543. }
  2544. client->RemovePlayerQuest(quest_id);
  2545. client->GetCurrentZone()->SendQuestUpdates(client);
  2546. }
  2547. break;
  2548. }
  2549. case COMMAND_ACCEPT_QUEST:{
  2550. int32 quest_id = 0;
  2551. if(sep && sep->arg[0] && sep->IsNumber(0))
  2552. quest_id = atoul(sep->arg[0]);
  2553. if(quest_id > 0){
  2554. client->AcceptQuest(quest_id);
  2555. }
  2556. break;
  2557. }
  2558. case COMMAND_NAME:{
  2559. if(sep && sep->arg[ndx][0]){
  2560. client->GetPlayer()->GetInfoStruct()->set_name(std::string(sep->arg[ndx]).substr(0,39));
  2561. client->GetPlayer()->SetCharSheetChanged(true);
  2562. }else
  2563. client->Message(CHANNEL_COLOR_YELLOW,"Usage: /name {new_name}");
  2564. break;
  2565. }
  2566. case COMMAND_GROUPSAY:{
  2567. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  2568. if(sep && sep->arg[0] && gmi)
  2569. world.GetGroupManager()->GroupChatMessage(gmi->group_id, client->GetPlayer(), sep->argplus[0]);
  2570. break;
  2571. }
  2572. case COMMAND_GROUPINVITE: {
  2573. Entity* target = 0;
  2574. Client* target_client = 0;
  2575. if (client->GetPlayer()->GetGroupMemberInfo() && !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  2576. client->SimpleMessage(CHANNEL_COMMANDS, "You must be the group leader to invite.");
  2577. return;
  2578. }
  2579. // name provided with command so it has to be a player, npc not supported here
  2580. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0){
  2581. target_client = zone_list.GetClientByCharName(sep->arg[0]);
  2582. if (target_client) {
  2583. if (!target_client->IsConnected() || !target_client->IsReadyForSpawns())
  2584. target = 0;
  2585. else
  2586. target = target_client->GetPlayer();
  2587. }
  2588. }
  2589. // if name was not provided use the players target, npc or player supported here
  2590. if (!target && client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  2591. target = (Entity*)client->GetPlayer()->GetTarget();
  2592. if (target->IsPlayer()) {
  2593. target_client = client->GetCurrentZone()->GetClientBySpawn(target);
  2594. }
  2595. }
  2596. int8 result = world.GetGroupManager()->Invite(client->GetPlayer(), target);
  2597. if (result == 0) {
  2598. client->Message(CHANNEL_COMMANDS, "You invite %s to group with you.", target->GetName());
  2599. if (target_client) {
  2600. PacketStruct* packet = configReader.getStruct("WS_ReceiveOffer", target_client->GetVersion());
  2601. if (packet) {
  2602. packet->setDataByName("type", 1);
  2603. packet->setDataByName("name", client->GetPlayer()->GetName());
  2604. packet->setDataByName("unknown2", 1);
  2605. target_client->QueuePacket(packet->serialize());
  2606. safe_delete(packet);
  2607. }
  2608. }
  2609. }
  2610. else if (result == 1)
  2611. client->SimpleMessage(CHANNEL_COMMANDS, "That player is already in a group.");
  2612. else if (result == 2)
  2613. client->SimpleMessage(CHANNEL_COMMANDS, "That player has been invited to another group.");
  2614. else if (result == 3)
  2615. client->SimpleMessage(CHANNEL_COMMANDS, "Your group is already full.");
  2616. else if (result == 4)
  2617. client->SimpleMessage(CHANNEL_COMMANDS, "You have a pending invitation, cancel it first.");
  2618. else if (result == 5)
  2619. client->SimpleMessage(CHANNEL_COMMANDS, "You cannot invite yourself!");
  2620. else if (result == 6)
  2621. client->SimpleMessage(CHANNEL_COMMANDS, "Could not locate the player.");
  2622. else
  2623. client->SimpleMessage(CHANNEL_COMMANDS, "Group invite failed, unknown error!");
  2624. break;
  2625. }
  2626. case COMMAND_GROUPDISBAND: {
  2627. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  2628. if (gmi) { // TODO: Leader check
  2629. // world.GetGroupManager()->SimpleGroupMessage(gmi->group_id, "Your group has been disbanded.");
  2630. world.GetGroupManager()->RemoveGroup(gmi->group_id);
  2631. }
  2632. break;
  2633. }
  2634. case COMMAND_GROUP_LEAVE: {
  2635. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  2636. if (gmi) {
  2637. int32 group_id = gmi->group_id;
  2638. world.GetGroupManager()->RemoveGroupMember(group_id, client->GetPlayer());
  2639. if (!world.GetGroupManager()->IsGroupIDValid(group_id)) {
  2640. // leader->Message(CHANNEL_COLOR_GROUP, "%s has left the group.", client->GetPlayer()->GetName());
  2641. }
  2642. else {
  2643. world.GetGroupManager()->GroupMessage(group_id, "%s has left the group.", client->GetPlayer()->GetName());
  2644. }
  2645. client->SimpleMessage(CHANNEL_GROUP_CHAT, "You have left the group");
  2646. }
  2647. break;
  2648. }
  2649. case COMMAND_FRIEND_ADD:{
  2650. string name = "";
  2651. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2652. name = database.GetPlayerName(sep->arg[0]);
  2653. else if(cmdTarget && cmdTarget->IsPlayer())
  2654. name = string(cmdTarget->GetName());
  2655. if(name.length() > 0){
  2656. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  2657. if(client->GetPlayer()->IsIgnored(name.c_str())){
  2658. client->GetPlayer()->RemoveIgnore(name.c_str());
  2659. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  2660. client->SendChatRelationship(3, name.c_str());
  2661. }
  2662. client->GetPlayer()->AddFriend(name.c_str(), true);
  2663. client->SendChatRelationship(0, name.c_str());
  2664. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added friend: %s", name.c_str());
  2665. if(zone_list.GetClientByCharName(name))
  2666. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Friend: %s has logged in.", name.c_str());
  2667. }
  2668. else
  2669. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot be more friendly towards yourself!");
  2670. }
  2671. else
  2672. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  2673. break;
  2674. }
  2675. case COMMAND_FRIEND_REMOVE:{
  2676. string name = "";
  2677. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2678. name = database.GetPlayerName(sep->arg[0]);
  2679. else if(cmdTarget && cmdTarget->IsPlayer())
  2680. name = string(cmdTarget->GetName());
  2681. if(name.length() > 0){
  2682. client->GetPlayer()->RemoveFriend(name.c_str());
  2683. client->SendChatRelationship(1, name.c_str());
  2684. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  2685. }
  2686. else
  2687. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  2688. break;
  2689. }
  2690. case COMMAND_FRIENDS:{
  2691. break;
  2692. }
  2693. case COMMAND_IGNORE_ADD:{
  2694. string name = "";
  2695. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2696. name = database.GetPlayerName(sep->arg[0]);
  2697. else if(cmdTarget && cmdTarget->IsPlayer())
  2698. name = string(cmdTarget->GetName());
  2699. if(name.length() > 0){
  2700. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  2701. if(client->GetPlayer()->IsFriend(name.c_str())){
  2702. client->GetPlayer()->RemoveFriend(name.c_str());
  2703. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  2704. client->SendChatRelationship(1, name.c_str());
  2705. }
  2706. client->GetPlayer()->AddIgnore(name.c_str(), true);
  2707. client->SendChatRelationship(2, name.c_str());
  2708. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added ignore: %s", name.c_str());
  2709. }
  2710. else
  2711. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot ignore yourself!");
  2712. }
  2713. else
  2714. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  2715. break;
  2716. }
  2717. case COMMAND_IGNORE_REMOVE:{
  2718. string name = "";
  2719. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2720. name = database.GetPlayerName(sep->arg[0]);
  2721. else if(cmdTarget && cmdTarget->IsPlayer())
  2722. name = string(cmdTarget->GetName());
  2723. if(name.length() > 0){
  2724. client->GetPlayer()->RemoveIgnore(name.c_str());
  2725. client->SendChatRelationship(3, name.c_str());
  2726. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  2727. }
  2728. break;
  2729. }
  2730. case COMMAND_IGNORES:{
  2731. break;
  2732. }
  2733. case COMMAND_GROUP_KICK:{
  2734. Entity* kicked = 0;
  2735. Client* kicked_client = 0;
  2736. int32 group_id = 0;
  2737. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader)
  2738. return;
  2739. LogWrite(MISC__TODO, 0, "TODO", "Add a check to see if the client using the command (COMMAND_GROUP_KICK) is the group leader");
  2740. if (sep && sep->arg[0]) {
  2741. kicked_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  2742. if (kicked_client)
  2743. kicked = kicked_client->GetPlayer();
  2744. }
  2745. else if (cmdTarget && cmdTarget->IsEntity()) {
  2746. kicked = (Entity*)cmdTarget;
  2747. }
  2748. group_id = client->GetPlayer()->GetGroupMemberInfo()->group_id;
  2749. bool send_kicked_message = world.GetGroupManager()->GetGroupSize(group_id) > 2;
  2750. if (kicked)
  2751. world.GetGroupManager()->RemoveGroupMember(group_id, kicked);
  2752. if(send_kicked_message)
  2753. world.GetGroupManager()->GroupMessage(group_id, "%s was kicked from the group.", kicked->GetName());
  2754. else
  2755. client->Message(CHANNEL_GROUP_CHAT, "You kicked %s from the group", kicked->GetName());
  2756. if (kicked_client)
  2757. kicked_client->SimpleMessage(CHANNEL_GROUP_CHAT, "You were kicked from the group");
  2758. break;
  2759. }
  2760. case COMMAND_GROUP_MAKE_LEADER:{
  2761. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  2762. client->SimpleMessage(CHANNEL_COMMANDS, "You are not a group leader.");
  2763. return;
  2764. }
  2765. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 1) {
  2766. Client* new_leader = zone_list.GetClientByCharName(sep->arg[0]);
  2767. if (new_leader) {
  2768. if (client->GetPlayer()->IsGroupMember(new_leader->GetPlayer())) {
  2769. world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, new_leader->GetPlayer());
  2770. }
  2771. }
  2772. else
  2773. client->SimpleMessage(CHANNEL_COMMANDS, "Unable to find the given player.");
  2774. }
  2775. else if (cmdTarget && cmdTarget->IsPlayer())
  2776. world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, (Entity*)cmdTarget);
  2777. else
  2778. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to change group leader.");
  2779. break;
  2780. }
  2781. case COMMAND_GROUP_ACCEPT_INVITE: {
  2782. if(sep && sep->arg[0] && strcmp(sep->arg[0], "group") == 0) {
  2783. int8 result = world.GetGroupManager()->AcceptInvite(client->GetPlayer());
  2784. if (result == 0)
  2785. client->SimpleMessage(CHANNEL_GROUP_CHAT, "You have joined the group.");
  2786. else if (result == 1)
  2787. client->SimpleMessage(CHANNEL_GROUP_CHAT, "You do not have a pending invite.");
  2788. else if (result == 2)
  2789. client->SimpleMessage(CHANNEL_GROUP_CHAT, "Unable to join group - could not find leader.");
  2790. else
  2791. client->SimpleMessage(CHANNEL_GROUP_CHAT, "Unable to join group - unknown error.");
  2792. }
  2793. break;
  2794. }
  2795. case COMMAND_GROUP_DECLINE_INVITE: {
  2796. if(sep && sep->arg[0] && strcmp(sep->arg[0], "group") == 0) {
  2797. world.GetGroupManager()->DeclineInvite(client->GetPlayer()); // TODO: Add message to leader
  2798. }
  2799. break;
  2800. }
  2801. case COMMAND_SUMMON:{
  2802. char* search_name = 0;
  2803. if(sep && sep->arg[0][0])
  2804. search_name = sep->arg[0];
  2805. if(!search_name && !cmdTarget){
  2806. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /summon [name]");
  2807. 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.");
  2808. }
  2809. else{
  2810. if(!client->Summon(search_name))
  2811. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  2812. }
  2813. break;
  2814. }
  2815. case COMMAND_GOTO:{
  2816. const char* search_name = 0;
  2817. if(sep && sep->arg[0][0])
  2818. search_name = sep->argplus[0];
  2819. if(!search_name && !cmdTarget){
  2820. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /goto [name]");
  2821. 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.");
  2822. }
  2823. else{
  2824. if(!client->GotoSpawn(search_name))
  2825. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  2826. }
  2827. break;
  2828. }
  2829. case COMMAND_MOVE:{
  2830. bool success = false;
  2831. try{
  2832. if(sep && sep->arg[2][0] && sep->IsNumber(0) && sep->IsNumber(1) && sep->IsNumber(2)){
  2833. EQ2Packet* app = client->GetPlayer()->Move(atof(sep->arg[0]), atof(sep->arg[1]), atof(sep->arg[2]), client->GetVersion());
  2834. if(app){
  2835. client->QueuePacket(app);
  2836. success = true;
  2837. }
  2838. }
  2839. }
  2840. catch(...){}
  2841. if(!success){
  2842. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /move x y z");
  2843. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Moves the client to the given coordinates.");
  2844. }
  2845. break;
  2846. }
  2847. case COMMAND_SETTIME:{
  2848. if(sep && sep->arg[0]){
  2849. sscanf (sep->arg[0], "%d:%d", &world.GetWorldTimeStruct()->hour, &world.GetWorldTimeStruct()->minute);
  2850. if(sep->arg[1] && sep->IsNumber(1))
  2851. world.GetWorldTimeStruct()->month = atoi(sep->arg[1]) - 1; //zero based indexes
  2852. if(sep->arg[2] && sep->IsNumber(2))
  2853. world.GetWorldTimeStruct()->day = atoi(sep->arg[2]) - 1; //zero based indexes
  2854. if(sep->arg[3] && sep->IsNumber(3))
  2855. world.GetWorldTimeStruct()->year = atoi(sep->arg[3]);
  2856. client->GetCurrentZone()->SendTimeUpdateToAllClients();
  2857. }
  2858. else{
  2859. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /settime [hour:minute] (month) (day) (year)");
  2860. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Example: /settime 8:30");
  2861. }
  2862. break;
  2863. }
  2864. case COMMAND_VERSION:{
  2865. client->Message(CHANNEL_COLOR_YELLOW,"%s %s", EQ2EMU_MODULE, CURRENT_VERSION);
  2866. client->Message(CHANNEL_COLOR_YELLOW,"Last Compiled on %s %s", COMPILE_DATE, COMPILE_TIME);
  2867. break;
  2868. }
  2869. case COMMAND_ZONE:{
  2870. int32 instanceID = 0;
  2871. string zone;
  2872. int32 zone_id = 0;
  2873. bool listSearch = false;
  2874. bool isInstance = false;
  2875. ZoneServer* zsZone = 0;
  2876. if(sep && sep->arg[0][0])
  2877. {
  2878. if(strncasecmp(sep->arg[0], "list", 4) == 0)
  2879. listSearch = true;
  2880. else if(strncasecmp(sep->arg[0], "active", 6) == 0)
  2881. {
  2882. zone_list.SendZoneList(client);
  2883. break;
  2884. }
  2885. else if(strncasecmp(sep->arg[0], "instance", 6) == 0)
  2886. {
  2887. if(sep->IsNumber(1))
  2888. instanceID = atol(sep->arg[1]);
  2889. }
  2890. else if(strncasecmp(sep->arg[0], "lock", 4) == 0)
  2891. {
  2892. PrintSep(sep, "ZONE LOCK");
  2893. if(sep->IsNumber(1))
  2894. zsZone = zone_list.Get(atoul(sep->arg[1]), false);
  2895. else
  2896. zsZone = zone_list.Get(sep->arg[1], false);
  2897. if( zsZone )
  2898. {
  2899. zsZone->SetZoneLockState(true);
  2900. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now locked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  2901. }
  2902. else
  2903. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be locked.", sep->arg[1]);
  2904. break;
  2905. }
  2906. else if(strncasecmp(sep->arg[0], "unlock", 6) == 0)
  2907. {
  2908. PrintSep(sep, "ZONE UNLOCK");
  2909. if(sep->IsNumber(1))
  2910. zsZone = zone_list.Get(atoul(sep->arg[1]), false);
  2911. else
  2912. zsZone = zone_list.Get(sep->arg[1], false);
  2913. if( zsZone )
  2914. {
  2915. zsZone->SetZoneLockState(false);
  2916. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now unlocked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  2917. }
  2918. else
  2919. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be unlocked.", sep->arg[1]);
  2920. break;
  2921. }
  2922. else
  2923. {
  2924. if(sep->IsNumber(0))
  2925. {
  2926. zone_id = atoul(sep->arg[0]);
  2927. string zonename = database.GetZoneName(zone_id);
  2928. if(zonename.length() > 0)
  2929. zone = zonename;
  2930. }
  2931. else
  2932. zone = sep->arg[0];
  2933. }
  2934. if(instanceID > 0)
  2935. {
  2936. ZoneServer* zsInstance = zone_list.GetByInstanceID(instanceID);
  2937. if(zsInstance != NULL)
  2938. {
  2939. instanceID = zsInstance->GetInstanceID();
  2940. zone = zsInstance->GetZoneName();
  2941. zone_id = zsInstance->GetZoneID();
  2942. isInstance = true;
  2943. }
  2944. }
  2945. }
  2946. if(!listSearch)
  2947. {
  2948. if(zone.length() == 0)
  2949. client->Message(CHANNEL_COLOR_RED, "Error: Invalid Zone");
  2950. else if(instanceID != client->GetCurrentZone()->GetInstanceID() ||
  2951. zone_id != client->GetCurrentZone()->GetZoneID())
  2952. {
  2953. const char* zonestr = zone.c_str();
  2954. if(database.VerifyZone(zonestr))
  2955. {
  2956. if(client->CheckZoneAccess(zonestr))
  2957. {
  2958. client->Message(CHANNEL_COLOR_YELLOW,"Zoning to %s...", zonestr);
  2959. if(isInstance)
  2960. client->Zone(instanceID,true,true);
  2961. else
  2962. client->Zone(zonestr);
  2963. }
  2964. }
  2965. else
  2966. client->Message(CHANNEL_COLOR_RED, "Error: Zone '%s' not found. To get a list type /zone list", zonestr);
  2967. }
  2968. else
  2969. client->Message(CHANNEL_COLOR_RED, "Error: You are already in that zone!");
  2970. }
  2971. else
  2972. {
  2973. const char* name = 0;
  2974. if(sep && sep->arg[1][0])
  2975. {
  2976. map<int32, string>* zone_names;
  2977. name = sep->argplus[1];
  2978. sint16 status = client->GetAdminStatus();
  2979. if( status > 0 )
  2980. {
  2981. client->SimpleMessage(CHANNEL_COLOR_RED, "ADMIN MODE");
  2982. zone_names = database.GetZoneList(name, true);
  2983. }
  2984. else
  2985. zone_names = database.GetZoneList(name);
  2986. if(!zone_names)
  2987. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No zones found.");
  2988. else
  2989. {
  2990. map<int32, string>::iterator itr;
  2991. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  2992. for(itr = zone_names->begin(); itr != zone_names->end(); itr++)
  2993. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  2994. safe_delete(zone_names);
  2995. }
  2996. }
  2997. else
  2998. {
  2999. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone [zone name]");
  3000. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone list [partial zone name]");
  3001. }
  3002. }
  3003. break;
  3004. }
  3005. case COMMAND_USE: {
  3006. Spawn* target = cmdTarget;
  3007. if (target && target->IsWidget())
  3008. ((Widget*)target)->HandleUse(client, "use");
  3009. break;
  3010. }
  3011. case COMMAND_OPEN: {
  3012. Spawn* target = cmdTarget;
  3013. if (target && target->IsWidget())
  3014. ((Widget*)target)->HandleUse(client, "Open", WIDGET_TYPE_DOOR);
  3015. break;
  3016. }
  3017. case COMMAND_CASTSPELL: {
  3018. if (sep && sep->arg[0] && sep->IsNumber(0))
  3019. {
  3020. int8 tier = 1;
  3021. if (sep->arg[1] && sep->IsNumber(1))
  3022. tier = atoul(sep->arg[1]);
  3023. int8 self = 1;
  3024. if (sep->arg[1] && sep->IsNumber(2))
  3025. {
  3026. self = atoul(sep->arg[2]);
  3027. if(self != 1 && !cmdTarget->IsEntity())
  3028. {
  3029. client->Message(CHANNEL_COLOR_RED, "Target is not an entity required to cast non-self spell.");
  3030. self = 1;
  3031. }
  3032. }
  3033. int32 spellid = atoul(sep->arg[0]);
  3034. Spell* spell = master_spell_list.GetSpell(spellid, tier);
  3035. if (spell)
  3036. {
  3037. client->Message(CHANNEL_COLOR_RED, "Casting spell %u.", spellid);
  3038. SpellProcess* spellProcess = 0;
  3039. // Get the current zones spell process
  3040. spellProcess = client->GetCurrentZone()->GetSpellProcess();
  3041. spellProcess->CastInstant(spell, (!cmdTarget || self == 1) ? (Entity*)client->GetPlayer() : (Entity*)cmdTarget, (cmdTarget && cmdTarget->IsEntity()) ? (Entity*)cmdTarget : (Entity*)client->GetPlayer());
  3042. }
  3043. else
  3044. {
  3045. client->Message(CHANNEL_COLOR_RED, "Could not find spell %u.",spellid);
  3046. }
  3047. }
  3048. else if (sep && sep->arg[0])
  3049. {
  3050. database.FindSpell(client, (char*)sep->argplus[0]);
  3051. }
  3052. else
  3053. {
  3054. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellid] (tier=1) - Cast Spell with specified spell id, tier is optional, default of 1.");
  3055. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellname] - Find spells wildcard match with a partial spell name");
  3056. }
  3057. break;
  3058. }
  3059. case COMMAND_KNOWLEDGEWINDOWSORT: {
  3060. if (client->GetVersion() <= 546)
  3061. break;
  3062. if (sep && sep->GetArgNumber() == 4)
  3063. {
  3064. int32 book = atoul(sep->arg[0]); // 0 - spells, 1 - combat, 2 - abilities, 3 - tradeskill
  3065. int32 sort_by = atoul(sep->arg[1]); // 0 - alpha, 1 - level, 2 - category
  3066. int32 order = atoul(sep->arg[2]); // 0 - ascending, 1 - descending
  3067. int32 pattern = atoul(sep->arg[3]); // 0 - zigzag, 1 - down, 2 - across
  3068. int32 maxlvlonly = atoul(sep->arg[4]); // 0 - zigzag, 1 - down, 2 - across
  3069. client->GetPlayer()->ResortSpellBook(sort_by, order, pattern, maxlvlonly, book);
  3070. ClientPacketFunctions::SendSkillSlotMappings(client);
  3071. }
  3072. else
  3073. {
  3074. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /knowledgewindow_sort [book] [sort_by] [order] [pattern]");
  3075. }
  3076. break;
  3077. }
  3078. case COMMAND_MOVE_ITEM:
  3079. {
  3080. int32 id = 0;
  3081. if (sep->IsNumber(0))
  3082. id = atoul(sep->arg[0]);
  3083. Spawn* spawn = 0;
  3084. if (id == 0)
  3085. {
  3086. spawn = cmdTarget;
  3087. }
  3088. else
  3089. spawn = client->GetCurrentZone()->GetSpawnFromUniqueItemID(id);
  3090. if (!spawn || !client->HasOwnerOrEditAccess() || !spawn->GetPickupItemID())
  3091. break;
  3092. client->SendMoveObjectMode(spawn, 0);
  3093. break;
  3094. }
  3095. case COMMAND_PICKUP:
  3096. {
  3097. int32 id = 0;
  3098. if (sep->IsNumber(0))
  3099. id = atoul(sep->arg[0]);
  3100. Spawn* spawn = 0;
  3101. if (id == 0)
  3102. {
  3103. spawn = cmdTarget;
  3104. }
  3105. else
  3106. spawn = client->GetCurrentZone()->GetSpawnFromUniqueItemID(id);
  3107. if (!spawn || !client->HasOwnerOrEditAccess() || !spawn->GetPickupItemID())
  3108. break;
  3109. client->AddItem(spawn->GetPickupItemID(), 1);
  3110. Query query;
  3111. 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());
  3112. if (database.RemoveSpawnFromSpawnLocation(spawn)) {
  3113. client->GetCurrentZone()->RemoveSpawn(spawn, true, true);
  3114. }
  3115. // we had a UI Window displayed, update the house items
  3116. if ( id > 0 )
  3117. client->GetCurrentZone()->SendHouseItems(client);
  3118. break;
  3119. }
  3120. case COMMAND_HOUSE_DEPOSIT:
  3121. {
  3122. PrintSep(sep, "COMMAND_HOUSE_DEPOSIT");
  3123. // arg0 = ??? (set to 3)
  3124. // arg1 = coin (in copper)
  3125. // arg2 = status? (not implemented yet)
  3126. PlayerHouse* ph = world.GetPlayerHouseByInstanceID(client->GetCurrentZone()->GetInstanceID());
  3127. if (ph && sep && sep->IsNumber(1))
  3128. {
  3129. int64 outValCoin = strtoull(sep->arg[1], NULL, 0);
  3130. int32 outValStatus = 0;
  3131. if(sep->IsNumber(2))
  3132. {
  3133. outValStatus = strtoull(sep->arg[2], NULL, 0);
  3134. if(outValStatus > client->GetPlayer()->GetInfoStruct()->get_status_points())
  3135. outValStatus = 0; // cheat check
  3136. }
  3137. if ((!outValCoin && outValStatus) || client->GetPlayer()->RemoveCoins(outValCoin))
  3138. {
  3139. if(outValStatus)
  3140. client->GetPlayer()->GetInfoStruct()->subtract_status_points(outValStatus);
  3141. char query[256];
  3142. map<string,Deposit>::iterator itr = ph->depositsMap.find(string(client->GetPlayer()->GetName()));
  3143. if (itr != ph->depositsMap.end())
  3144. {
  3145. snprintf(query, 256, "update character_house_deposits set timestamp = %u, amount = amount + %I64u, last_amount = %I64u, 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());
  3146. }
  3147. else
  3148. snprintf(query, 256, "insert into character_house_deposits set timestamp = %u, house_id = %u, instance_id = %u, name='%s', amount = %I64u, status = %u", Timer::GetUnixTimeStamp(), ph->house_id, ph->instance_id, client->GetPlayer()->GetName(), outValCoin, outValStatus);
  3149. if (database.RunQuery(query, strnlen(query, 256)))
  3150. {
  3151. ph->escrow_coins += outValCoin;
  3152. ph->escrow_status += outValStatus;
  3153. database.UpdateHouseEscrow(ph->house_id, ph->instance_id, ph->escrow_coins, ph->escrow_status);
  3154. database.LoadDeposits(ph);
  3155. client->PlaySound("coin_cha_ching");
  3156. HouseZone* hz = world.GetHouseZone(ph->house_id);
  3157. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  3158. }
  3159. else
  3160. {
  3161. if(outValCoin)
  3162. client->GetPlayer()->AddCoins(outValCoin);
  3163. if(outValStatus)
  3164. client->GetPlayer()->GetInfoStruct()->add_status_points(outValStatus);
  3165. client->SimpleMessage(CHANNEL_COLOR_RED, "Deposit failed!");
  3166. }
  3167. }
  3168. }
  3169. break;
  3170. }
  3171. case COMMAND_HOUSE:
  3172. {
  3173. if (sep && sep->IsNumber(0))
  3174. {
  3175. int32 unique_id = atoi(sep->arg[0]);
  3176. PlayerHouse* ph = world.GetPlayerHouseByUniqueID(unique_id);
  3177. HouseZone* hz = 0;
  3178. if (ph)
  3179. hz = world.GetHouseZone(ph->house_id);
  3180. // there is a arg[1] that is true/false, but not sure what it is for investigate more later
  3181. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  3182. }
  3183. else if (client->GetCurrentZone()->GetInstanceType() != 0)
  3184. {
  3185. // inside a house or something? Send the access window
  3186. PlayerHouse* ph = world.GetPlayerHouseByInstanceID(client->GetCurrentZone()->GetInstanceID());
  3187. HouseZone* hz = 0;
  3188. if ( ph )
  3189. hz = world.GetHouseZone(ph->house_id);
  3190. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  3191. client->GetCurrentZone()->SendHouseItems(client);
  3192. }
  3193. break;
  3194. }
  3195. case COMMAND_HOUSE_UI:
  3196. {
  3197. if (sep && sep->IsNumber(0) && client->GetCurrentZone()->GetInstanceType() == Instance_Type::NONE)
  3198. {
  3199. int32 unique_id = atoi(sep->arg[0]);
  3200. PlayerHouse* ph = world.GetPlayerHouseByUniqueID(unique_id);
  3201. HouseZone* hz = 0;
  3202. if ( ph )
  3203. hz = world.GetHouseZone(ph->house_id);
  3204. // there is a arg[1] that is true/false, but not sure what it is for investigate more later
  3205. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, 0);
  3206. }
  3207. break;
  3208. }
  3209. case COMMAND_PLACE_HOUSE_ITEM: {
  3210. if (sep && sep->IsNumber(0))
  3211. {
  3212. int32 uniqueid = atoi(sep->arg[0]);
  3213. Item* item = client->GetPlayer()->item_list.GetItemFromUniqueID(uniqueid);
  3214. //Item* item = player->GetEquipmentList()->GetItem(slot);
  3215. if (item && item->IsHouseItem())
  3216. {
  3217. if (!client->HasOwnerOrEditAccess())
  3218. {
  3219. client->SimpleMessage(CHANNEL_COLOR_RED, "This is not your home!");
  3220. break;
  3221. }
  3222. else if (!item->generic_info.appearance_id)
  3223. {
  3224. 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);
  3225. break;
  3226. }
  3227. if (client->GetTempPlacementSpawn())
  3228. {
  3229. Spawn* tmp = client->GetTempPlacementSpawn();
  3230. client->GetCurrentZone()->RemoveSpawn(tmp);
  3231. client->SetTempPlacementSpawn(nullptr);
  3232. }
  3233. Spawn* spawn = new Object();
  3234. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3235. spawn->SetID(Spawn::NextID());
  3236. spawn->SetX(client->GetPlayer()->GetX());
  3237. spawn->SetY(client->GetPlayer()->GetY());
  3238. spawn->SetZ(client->GetPlayer()->GetZ());
  3239. spawn->SetHeading(client->GetPlayer()->GetHeading());
  3240. spawn->SetSpawnOrigX(spawn->GetX());
  3241. spawn->SetSpawnOrigY(spawn->GetY());
  3242. spawn->SetSpawnOrigZ(spawn->GetZ());
  3243. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  3244. spawn->appearance.targetable = 1;
  3245. spawn->appearance.activity_status = ACTIVITY_STATUS_SOLID;
  3246. spawn->appearance.race = item && item->generic_info.appearance_id ? item->generic_info.appearance_id : 1472;
  3247. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  3248. spawn->SetModelType(item && item->generic_info.appearance_id ? item->generic_info.appearance_id : 1472);
  3249. spawn->SetZone(client->GetCurrentZone());
  3250. client->GetCurrentZone()->SendSpawn(spawn, client);
  3251. client->SetTempPlacementSpawn(spawn);
  3252. client->SetPlacementUniqueItemID(uniqueid);
  3253. client->SendMoveObjectMode(spawn, 0);
  3254. }
  3255. }
  3256. break;
  3257. }
  3258. case COMMAND_GM:
  3259. {
  3260. if (sep && sep->arg[0] && sep->arg[1])
  3261. {
  3262. bool onOff = (strcmp(sep->arg[1], "on") == 0);
  3263. if (strcmp(sep->arg[0], "vision") == 0)
  3264. {
  3265. client->GetPlayer()->SetGMVision(onOff);
  3266. #if defined(__GNUC__)
  3267. database.insertCharacterProperty(client, CHAR_PROPERTY_GMVISION, (onOff) ? (char*)"1" : (char*)"0");
  3268. #else
  3269. database.insertCharacterProperty(client, CHAR_PROPERTY_GMVISION, (onOff) ? "1" : "0");
  3270. #endif
  3271. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3272. if (onOff)
  3273. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Vision Enabled!");
  3274. else
  3275. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Vision Disabled!");
  3276. }
  3277. else if (strcmp(sep->arg[0], "regiondebug") == 0)
  3278. {
  3279. client->SetRegionDebug(onOff);
  3280. #if defined(__GNUC__)
  3281. database.insertCharacterProperty(client, CHAR_PROPERTY_REGIONDEBUG, (onOff) ? (char*)"1" : (char*)"0");
  3282. #else
  3283. database.insertCharacterProperty(client, CHAR_PROPERTY_REGIONDEBUG, (onOff) ? "1" : "0");
  3284. #endif
  3285. if (onOff)
  3286. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Region Debug Enabled!");
  3287. else
  3288. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Region Debug Disabled!");
  3289. }
  3290. else if (strcmp(sep->arg[0], "luadebug") == 0)
  3291. {
  3292. client->SetLuaDebugClient(onOff);
  3293. #if defined(__GNUC__)
  3294. database.insertCharacterProperty(client, CHAR_PROPERTY_LUADEBUG, (onOff) ? (char*)"1" : (char*)"0");
  3295. #else
  3296. database.insertCharacterProperty(client, CHAR_PROPERTY_LUADEBUG, (onOff) ? "1" : "0");
  3297. #endif
  3298. if (onOff)
  3299. {
  3300. if (lua_interface)
  3301. lua_interface->UpdateDebugClients(client);
  3302. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will now receive LUA error messages.");
  3303. }
  3304. else
  3305. {
  3306. if (lua_interface)
  3307. lua_interface->RemoveDebugClients(client);
  3308. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will no longer receive LUA error messages.");
  3309. }
  3310. }
  3311. }
  3312. break;
  3313. }
  3314. case COMMAND_ATTACK:
  3315. case COMMAND_AUTO_ATTACK:{
  3316. int8 type = 1;
  3317. Player* player = client->GetPlayer();
  3318. if(!player)
  3319. break;
  3320. bool incombat = player->EngagedInCombat();
  3321. if(sep && sep->arg[0] && sep->IsNumber(0))
  3322. type = atoi(sep->arg[0]);
  3323. if(client->GetPlayer()->GetHP() == 0){
  3324. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  3325. break;
  3326. }
  3327. if(type == 0){
  3328. if(incombat)
  3329. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You stop fighting.");
  3330. player->StopCombat(type);
  3331. }
  3332. else {
  3333. if(type == 2){
  3334. player->InCombat(false);
  3335. if(incombat && player->GetRangeAttack()){
  3336. player->StopCombat(type);
  3337. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You stop fighting.");
  3338. }
  3339. else{
  3340. player->SetRangeAttack(true);
  3341. player->InCombat(true, true);
  3342. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You start fighting.");
  3343. }
  3344. }
  3345. else {
  3346. player->InCombat(false, true);
  3347. player->SetRangeAttack(false);
  3348. player->InCombat(true);
  3349. if(!incombat)
  3350. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You start fighting.");
  3351. }
  3352. /*else
  3353. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You cannot attack that!");*/
  3354. }
  3355. player->SetCharSheetChanged(true);
  3356. break;
  3357. }
  3358. case COMMAND_DEPOP:{
  3359. bool allow_respawns = false;
  3360. if(sep && sep->arg[0] && sep->IsNumber(0)){
  3361. if(atoi(sep->arg[0]) == 1)
  3362. allow_respawns = true;
  3363. }
  3364. client->GetCurrentZone()->Depop(allow_respawns);
  3365. break;
  3366. }
  3367. case COMMAND_REPOP:{
  3368. client->GetCurrentZone()->Depop(false, true);
  3369. break;
  3370. }
  3371. case COMMAND_BUYBACK:{
  3372. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  3373. // 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
  3374. int64 id = atoi64(sep->arg[0]);
  3375. // get the first int32, the item id
  3376. //int32 item_id = (int32)id;
  3377. // get the second int32, the unique id
  3378. int32 unique_id = (int32)(id>>32);
  3379. int8 quantity = atoi(sep->arg[1]);
  3380. if(quantity == 255)
  3381. quantity = 1;
  3382. client->BuyBack(unique_id, quantity);
  3383. }
  3384. break;
  3385. }
  3386. case COMMAND_MERCHANT_BUY:{
  3387. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  3388. int32 item_id = atoul(sep->arg[0]);
  3389. int8 quantity = atoi(sep->arg[1]);
  3390. client->BuyItem(item_id, quantity);
  3391. }
  3392. else
  3393. Command_SendMerchantWindow(client, sep);
  3394. break;
  3395. }
  3396. case COMMAND_MERCHANT_SELL:{
  3397. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  3398. // 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
  3399. int64 id = atoi64(sep->arg[0]);
  3400. // get the first int32, the item id
  3401. int32 item_id = (int32)id;
  3402. // get the second int32, the unique id
  3403. int32 unique_id = (int32)(id>>32);
  3404. int8 quantity = atoi(sep->arg[1]);
  3405. LogWrite(MERCHANT__DEBUG, 0, "Merchant", "Selling Item: Item Id = %ul, unique id = %ul, Quantity = %i", item_id, unique_id, quantity);
  3406. client->SellItem(item_id, quantity, unique_id);
  3407. }
  3408. break;
  3409. }
  3410. case COMMAND_MENDER_REPAIR: {
  3411. if (sep && sep->arg[0] && sep->IsNumber(0))
  3412. client->RepairItem(atoul(sep->arg[0]));
  3413. break;
  3414. }
  3415. case COMMAND_MENDER_REPAIR_ALL: {
  3416. client->RepairAllItems();
  3417. break;
  3418. }
  3419. case COMMAND_CANCEL_MERCHANT:{
  3420. client->SetMerchantTransaction(0);
  3421. break;
  3422. }
  3423. case COMMAND_START_MERCHANT:{
  3424. break;
  3425. }
  3426. case COMMAND_INVULNERABLE:{
  3427. sint8 val = -1;
  3428. if(sep && sep->arg[0] && sep->IsNumber(0)){
  3429. val = atoi(sep->arg[0]);
  3430. //devn00b: Fix for linux builds
  3431. #if defined(__GNUC__)
  3432. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? (char*) "1" : (char*) "0");
  3433. #else
  3434. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  3435. #endif
  3436. // database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  3437. client->GetPlayer()->SetInvulnerable(val==1);
  3438. if(client->GetPlayer()->GetInvulnerable())
  3439. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are now invulnerable!");
  3440. else
  3441. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are no longer invulnerable!");
  3442. }
  3443. if(val == -1)
  3444. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /invulnerable [0/1]");
  3445. break;
  3446. }
  3447. case COMMAND_REPAIR: {
  3448. Spawn* spawn = cmdTarget;
  3449. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR) {
  3450. client->SendHailCommand(spawn);
  3451. client->SetMerchantTransaction(spawn);
  3452. client->SendRepairList();
  3453. }
  3454. break;
  3455. }
  3456. case COMMAND_LOTTO: {
  3457. Spawn* spawn = cmdTarget;
  3458. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_LOTTO) {
  3459. client->SetMerchantTransaction(spawn);
  3460. client->ShowLottoWindow();
  3461. }
  3462. break;
  3463. }
  3464. case COMMAND_ACCEPT_REWARD:{
  3465. int32 unknown = 0;
  3466. int32 selectable_item_id = 0;
  3467. //Quest *quest = 0;
  3468. Collection *collection = 0;
  3469. /* no idea what the first argument is for (faction maybe?)
  3470. if the reward has a selectable item reward, it's sent as the second argument
  3471. if neither of these are included in the reward, there is no sep
  3472. 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
  3473. only 1 quest or collection reward may be displayed at a time */
  3474. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  3475. unknown = atoul(sep->arg[0]);
  3476. selectable_item_id = atoul(sep->arg[1]);
  3477. }
  3478. //if ((quest = player->GetPendingQuestReward()))
  3479. // client->AcceptQuestRewards(quest, selectable_item_id);
  3480. /* the below needs to go away eventually and be redone */
  3481. int32 item_id = 0;
  3482. if(sep && sep->arg[0][0] && sep->IsNumber(0))
  3483. item_id = atoul(sep->arg[0]);
  3484. Quest* quest = client->GetPendingQuestAcceptance(item_id);
  3485. if(quest){
  3486. client->AcceptQuestReward(quest, item_id);
  3487. break;
  3488. }
  3489. bool collectedItems = false;
  3490. if (collection = player->GetPendingCollectionReward())
  3491. {
  3492. client->AcceptCollectionRewards(collection, selectable_item_id);
  3493. collectedItems = true;
  3494. }
  3495. else if (client->GetPlayer()->HasPendingItemRewards()) {
  3496. vector<Item*> items = client->GetPlayer()->GetPendingItemRewards();
  3497. if (items.size() > 0) {
  3498. collectedItems = true;
  3499. for (int i = 0; i < items.size(); i++) {
  3500. client->GetPlayer()->AddItem(new Item(items[i]));
  3501. }
  3502. client->GetPlayer()->ClearPendingItemRewards();
  3503. }
  3504. map<int32, Item*> selectable_item = client->GetPlayer()->GetPendingSelectableItemReward(item_id);
  3505. if (selectable_item.size() > 0) {
  3506. collectedItems = true;
  3507. map<int32, Item*>::iterator itr;
  3508. for (itr = selectable_item.begin(); itr != selectable_item.end(); itr++) {
  3509. client->GetPlayer()->AddItem(new Item(itr->second));
  3510. client->GetPlayer()->ClearPendingSelectableItemRewards(itr->first);
  3511. }
  3512. }
  3513. }
  3514. if (collectedItems) {
  3515. EQ2Packet* outapp = client->GetPlayer()->SendInventoryUpdate(client->GetVersion());
  3516. if (outapp)
  3517. client->QueuePacket(outapp);
  3518. }
  3519. else
  3520. LogWrite(COMMAND__ERROR, 0, "Command", "Error in COMMAND_ACCEPT_REWARD. No pending quest or collection reward was found (unknown=%u).", unknown);
  3521. break;
  3522. }
  3523. case COMMAND_BUY_FROM_BROKER:{
  3524. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  3525. int32 item_id = atoul(sep->arg[0]);
  3526. int16 quantity = atoul(sep->arg[1]);
  3527. Item* item = master_item_list.GetItem(item_id);
  3528. if(item && item->generic_info.max_charges > 1)
  3529. quantity = item->generic_info.max_charges;
  3530. client->AddItem(item_id, quantity);
  3531. }
  3532. break;
  3533. }
  3534. case COMMAND_SEARCH_STORES_PAGE:{
  3535. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  3536. int32 page = atoul(sep->arg[0]);
  3537. client->SearchStore(page);
  3538. }
  3539. break;
  3540. }
  3541. case COMMAND_SEARCH_STORES:{
  3542. if(sep && sep->arg[0][0]){
  3543. const char* values = sep->argplus[0];
  3544. if(values){
  3545. LogWrite(ITEM__WARNING, 0, "Item", "SearchStores: %s", values);
  3546. map<string, string> str_values = TranslateBrokerRequest(values);
  3547. vector<Item*>* items = master_item_list.GetItems(str_values);
  3548. if(items){
  3549. client->SetItemSearch(items);
  3550. client->SearchStore(0);
  3551. }
  3552. }
  3553. }
  3554. break;
  3555. }
  3556. case COMMAND_LUADEBUG:{
  3557. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "start") == 0){
  3558. client->SetLuaDebugClient(true);
  3559. if(lua_interface)
  3560. lua_interface->UpdateDebugClients(client);
  3561. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will now receive LUA error messages.");
  3562. }
  3563. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "stop") == 0){
  3564. client->SetLuaDebugClient(false);
  3565. if(lua_interface)
  3566. lua_interface->RemoveDebugClients(client);
  3567. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will no longer receive LUA error messages.");
  3568. }
  3569. else{
  3570. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /luadebug {start | stop}");
  3571. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will allow you to receive lua debug messages normally seen only in the console.");
  3572. }
  3573. break;
  3574. }
  3575. case COMMAND_SPAWN_GROUP:
  3576. {
  3577. Spawn* target = cmdTarget;
  3578. if(target && target->IsPlayer() == false)
  3579. {
  3580. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "create") == 0)
  3581. {
  3582. if(target->GetSpawnLocationPlacementID() > 0)
  3583. {
  3584. if(sep->arg[1] && !sep->IsNumber(1) && strlen(sep->arg[1]) > 0)
  3585. {
  3586. int32 id = database.CreateSpawnGroup(target, sep->arg[1]);
  3587. if(id > 0)
  3588. client->Message(CHANNEL_COLOR_YELLOW, "Successfully created new spawn group with id: %u", id);
  3589. else
  3590. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error creating group, check console for details.");
  3591. target->SetSpawnGroupID(id);
  3592. target->AddSpawnToGroup(target);
  3593. }
  3594. else
  3595. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group create [name]");
  3596. }
  3597. else
  3598. 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.");
  3599. }
  3600. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "add") == 0)
  3601. {
  3602. if(sep->arg[1] && sep->IsNumber(1))
  3603. {
  3604. int32 group_id = atoul(sep->arg[1]);
  3605. Spawn* leader = client->GetCurrentZone()->GetSpawnGroup(group_id);
  3606. if(leader)
  3607. {
  3608. leader->AddSpawnToGroup(target);
  3609. target->SetSpawnGroupID(group_id);
  3610. if(database.SpawnGroupAddSpawn(target, group_id))
  3611. client->Message(CHANNEL_COLOR_YELLOW, "Successfully added '%s' to group id: %u", target->GetName(), group_id);
  3612. else
  3613. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error adding spawn to group, check console for details.");
  3614. }
  3615. else
  3616. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No spawns found in the current zone for that spawn group, be sure to use '/spawn group create' first!");
  3617. }
  3618. else
  3619. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group add [group id]");
  3620. }
  3621. else if(target->GetSpawnGroupID() == 0)
  3622. {
  3623. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That spawn is not in a group!");
  3624. }
  3625. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "remove") == 0)
  3626. {
  3627. int32 group_id = target->GetSpawnGroupID();
  3628. target->RemoveSpawnFromGroup();
  3629. if(database.SpawnGroupRemoveSpawn(target, group_id))
  3630. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed '%s' from group id: %u", target->GetName(), group_id);
  3631. else
  3632. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing spawn from group, check console for details.");
  3633. }
  3634. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "associate") == 0)
  3635. {
  3636. int32 group_id = target->GetSpawnGroupID();
  3637. if(sep->arg[1] && sep->IsNumber(1))
  3638. {
  3639. if(database.SpawnGroupAddAssociation(group_id, atoul(sep->arg[1])))
  3640. client->Message(CHANNEL_COLOR_YELLOW, "Successfully associated group id %u with group id %u", group_id, atoul(sep->arg[1]));
  3641. else
  3642. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error associating groups, check console for details.");
  3643. }
  3644. else
  3645. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Allows you to spawn only one associated group at once. Syntax: /spawn group associate [other group id]");
  3646. }
  3647. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "deassociate") == 0)
  3648. {
  3649. int32 group_id = target->GetSpawnGroupID();
  3650. if(sep->arg[1] && sep->IsNumber(1))
  3651. {
  3652. if(database.SpawnGroupRemoveAssociation(group_id, atoul(sep->arg[1])))
  3653. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed association between group id %u and group id %u", group_id, atoul(sep->arg[1]));
  3654. else
  3655. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing group associations, check console for details.");
  3656. }
  3657. else
  3658. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Removes previous group associations. Syntax: /spawn group deassociate [other group id]");
  3659. }
  3660. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "chance") == 0)
  3661. {
  3662. if(sep->arg[1] && sep->IsNumber(1))
  3663. {
  3664. if(database.SetGroupSpawnChance(target->GetSpawnGroupID(), atof(sep->arg[1])))
  3665. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set group spawn chance to %f for group id: %u", atof(sep->arg[1]), target->GetSpawnGroupID());
  3666. else
  3667. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error setting group spawn chance, check console for details.");
  3668. }
  3669. else
  3670. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group chance [group's spawn chance percentage]");
  3671. }
  3672. else
  3673. {
  3674. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command allows you to modify spawn groups.");
  3675. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group [create/add/remove/chance/associate/deassociate]");
  3676. }
  3677. }
  3678. else
  3679. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select a valid spawn to use this command.");
  3680. break;
  3681. }
  3682. case COMMAND_SPAWN_COMBINE:{
  3683. Spawn* spawn = cmdTarget;
  3684. float radius = 0;
  3685. bool failed = true;
  3686. if(spawn && !spawn->IsPlayer() && sep && sep->arg[0] && sep->arg[0][0]){
  3687. failed = false;
  3688. if(spawn->GetSpawnGroupID() > 0){
  3689. 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.");
  3690. }
  3691. else if(sep->IsNumber(0)){
  3692. radius = atof(sep->arg[0]);
  3693. client->CombineSpawns(radius, spawn);
  3694. }
  3695. else{
  3696. if(strncasecmp(sep->arg[0], "add", 3) == 0){
  3697. client->AddCombineSpawn(spawn);
  3698. }
  3699. else if(strncasecmp(sep->arg[0], "remove", 6) == 0){
  3700. client->RemoveCombineSpawn(spawn);
  3701. }
  3702. else if(strncasecmp(sep->arg[0], "save", 4) == 0){
  3703. const char* name = 0;
  3704. if(sep->arg[1] && sep->arg[1][0])
  3705. name = sep->argplus[1];
  3706. client->SaveCombineSpawns(name);
  3707. }
  3708. else
  3709. failed = true;
  3710. }
  3711. }
  3712. if(failed){
  3713. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command combines several spawns into a single spawn group.");
  3714. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn combine [radius/add/remove/save]");
  3715. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Ex: /spawn combine 1, /spawn combine save (spawn group name)");
  3716. }
  3717. break;
  3718. }
  3719. case COMMAND_SPAWN_CREATE:{
  3720. Spawn* spawn = 0;
  3721. if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "object", 6) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  3722. spawn = new Object();
  3723. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3724. }
  3725. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "groundspawn", 11) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  3726. spawn = new GroundSpawn();
  3727. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3728. }
  3729. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "sign", 4) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  3730. spawn = new Sign();
  3731. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3732. }
  3733. else if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "npc", 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  3734. spawn = new NPC();
  3735. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3736. spawn->appearance.pos.collision_radius = 32;
  3737. spawn->secondary_command_list_id = 0;
  3738. spawn->primary_command_list_id = 0;
  3739. spawn->appearance.display_name = 1;
  3740. spawn->appearance.show_level = 1;
  3741. spawn->appearance.attackable = 1;
  3742. }
  3743. else{
  3744. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn create [spawn type] [race type] [class type] [level] [name] (difficulty) (size)");
  3745. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are required except difficulty and size. Valid types are Object, NPC, Sign, or GroundSpawn");
  3746. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn create npc 203 1 50 'Lady Vox' 1 32");
  3747. break;
  3748. }
  3749. spawn->SetID(Spawn::NextID());
  3750. spawn->SetX(client->GetPlayer()->GetX());
  3751. spawn->SetY(client->GetPlayer()->GetY());
  3752. spawn->SetZ(client->GetPlayer()->GetZ());
  3753. spawn->SetHeading(client->GetPlayer()->GetHeading());
  3754. spawn->SetSpawnOrigX(spawn->GetX());
  3755. spawn->SetSpawnOrigY(spawn->GetY());
  3756. spawn->SetSpawnOrigZ(spawn->GetZ());
  3757. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  3758. if(spawn->IsSign())
  3759. {
  3760. ((Sign*)spawn)->SetSignType(SIGN_TYPE_GENERIC);
  3761. ((Sign*)spawn)->SetSignDistance(20.0f);
  3762. ((Sign*)spawn)->SetIncludeLocation(1);
  3763. ((Sign*)spawn)->SetIncludeHeading(1);
  3764. ((Sign*)spawn)->SetInitialState(1);
  3765. ((Sign*)spawn)->SetSignTitle(sep->arg[4]);
  3766. ((Sign*)spawn)->SetActivityStatus(64);
  3767. spawn->appearance.race = 0;
  3768. spawn->SetLevel(0);
  3769. spawn->SetHP(0);
  3770. spawn->SetTotalHP(0);
  3771. spawn->SetPower(0);
  3772. spawn->SetTotalPower(0);
  3773. spawn->SetEncounterLevel(0);
  3774. spawn->SetTargetable(0);
  3775. spawn->SetSogaModelType(0);
  3776. spawn->SetCollisionRadius(19);
  3777. ((Sign*)spawn)->SetWidgetX(client->GetPlayer()->GetX());
  3778. ((Sign*)spawn)->SetWidgetY(client->GetPlayer()->GetY());
  3779. ((Sign*)spawn)->SetWidgetZ(client->GetPlayer()->GetZ());
  3780. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  3781. spawn->appearance.model_type = atoul(sep->arg[1]);
  3782. }
  3783. else
  3784. {
  3785. spawn->appearance.targetable = 1;
  3786. spawn->appearance.race = 255;
  3787. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  3788. spawn->SetModelType(atoi(sep->arg[1]));
  3789. spawn->SetAdventureClass(atoi(sep->arg[2]));
  3790. spawn->SetLevel(atoi(sep->arg[3]));
  3791. spawn->SetName(sep->arg[4]);
  3792. if(sep->arg[5][0] && sep->IsNumber(5))
  3793. spawn->SetEncounterLevel(atoi(sep->arg[5]));
  3794. if(sep->arg[6][0] && sep->IsNumber(6))
  3795. spawn->size = atoi(sep->arg[6]);
  3796. if(spawn->GetTotalHP() == 0){
  3797. spawn->SetTotalHP(25*spawn->GetLevel() + 1);
  3798. spawn->SetHP(25*spawn->GetLevel() + 1);
  3799. }
  3800. if(spawn->GetTotalPower() == 0){
  3801. spawn->SetTotalPower(25*spawn->GetLevel() + 1);
  3802. spawn->SetPower(25*spawn->GetLevel() + 1);
  3803. }
  3804. }
  3805. client->GetCurrentZone()->AddSpawn(spawn);
  3806. break;
  3807. }
  3808. case COMMAND_SPAWN_EQUIPMENT:{
  3809. Spawn* spawn = cmdTarget;
  3810. if(spawn && sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1) && spawn->IsEntity()){
  3811. int8 slot = atoi(sep->arg[0]);
  3812. int16 type = atoi(sep->arg[1]);
  3813. int8 red = 0;
  3814. int8 green = 0;
  3815. int8 blue = 0;
  3816. int8 h_red = 0;
  3817. int8 h_green = 0;
  3818. int8 h_blue = 0;
  3819. if(sep->arg[2])
  3820. red = atoi(sep->arg[2]);
  3821. if(sep->arg[3])
  3822. green = atoi(sep->arg[3]);
  3823. if(sep->arg[4])
  3824. blue = atoi(sep->arg[4]);
  3825. if(sep->arg[5])
  3826. h_red = atoi(sep->arg[5]);
  3827. if(sep->arg[6])
  3828. h_green = atoi(sep->arg[6]);
  3829. if(sep->arg[7])
  3830. h_blue = atoi(sep->arg[7]);
  3831. ((Entity*)spawn)->SetEquipment(slot, type, red, green, blue, h_red, h_green, h_blue);
  3832. database.SaveNPCAppearanceEquipment(spawn->GetDatabaseID() , slot, type, red, green, blue, h_red, h_green, h_blue);
  3833. }
  3834. else{
  3835. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn equipment [slot] [appearance id] (red) (green) (blue) (highlight red) (hgreen) (hblue)");
  3836. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn's equipment. ");
  3837. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Slot is 0-24, Appearance ID from appearances table, Colors are 0-255");
  3838. }
  3839. break;
  3840. }
  3841. case COMMAND_SPAWN_DETAILS: {
  3842. Spawn* spawn = cmdTarget;
  3843. if (sep && sep->arg[0][0]) {
  3844. if (cmdTarget)
  3845. {
  3846. if (ToLower(string(sep->arg[0])) == "los")
  3847. {
  3848. bool hasLOS = client->GetPlayer()->CheckLoS(cmdTarget);
  3849. if (hasLOS)
  3850. client->Message(CHANNEL_COLOR_YELLOW, "You have line of sight with %s", spawn->GetName());
  3851. else
  3852. client->Message(CHANNEL_COLOR_RED, "You DO NOT have line of sight with %s", spawn->GetName());
  3853. break;
  3854. }
  3855. else if (ToLower(string(sep->arg[0])) == "bestz")
  3856. {
  3857. glm::vec3 targPos(cmdTarget->GetX(), cmdTarget->GetZ(), cmdTarget->GetY());
  3858. float bestZ = client->GetPlayer()->FindDestGroundZ(targPos, cmdTarget->GetYOffset());
  3859. client->Message(CHANNEL_COLOR_YELLOW, "Best Z for %s is %f", spawn->GetName(), bestZ);
  3860. break;
  3861. }
  3862. else if (ToLower(string(sep->arg[0])) == "inwater")
  3863. {
  3864. if (cmdTarget->GetRegionMap() == nullptr)
  3865. client->SimpleMessage(CHANNEL_COLOR_RED, "No water map for zone.");
  3866. else
  3867. {
  3868. bool inWater = cmdTarget->InWater();
  3869. client->Message(CHANNEL_COLOR_YELLOW, "%s is %s.", cmdTarget->GetName(), inWater ? "in water" : "out of water");
  3870. }
  3871. break;
  3872. }
  3873. else if (ToLower(string(sep->arg[0])) == "inlava")
  3874. {
  3875. if (cmdTarget->GetRegionMap() == nullptr)
  3876. client->SimpleMessage(CHANNEL_COLOR_RED, "No region map for zone.");
  3877. else
  3878. {
  3879. bool inLava = cmdTarget->InLava();
  3880. client->Message(CHANNEL_COLOR_YELLOW, "%s is %s.", cmdTarget->GetName(), inLava ? "in lava" : "out of lava");
  3881. }
  3882. break;
  3883. }
  3884. else if (ToLower(string(sep->arg[0])) == "regions")
  3885. {
  3886. glm::vec3 targPos(cmdTarget->GetX(), cmdTarget->GetY(), cmdTarget->GetZ());
  3887. if (cmdTarget->GetRegionMap() == nullptr)
  3888. client->SimpleMessage(CHANNEL_COLOR_RED, "No region map for zone.");
  3889. else
  3890. {
  3891. cmdTarget->GetRegionMap()->IdentifyRegionsInGrid(client, targPos);
  3892. }
  3893. break;
  3894. }
  3895. else if (ToLower(string(sep->arg[0])) == "behind")
  3896. {
  3897. bool isBehind = client->GetPlayer()->BehindTarget(cmdTarget);
  3898. client->Message(CHANNEL_COLOR_YELLOW, "%s %s.", isBehind ? "YOU are behind" : "YOU are NOT behind", cmdTarget->GetName());
  3899. break;
  3900. }
  3901. else if (ToLower(string(sep->arg[0])) == "infront")
  3902. {
  3903. bool isBehind = client->GetPlayer()->InFrontSpawn(cmdTarget, client->GetPlayer()->GetX(), client->GetPlayer()->GetZ());
  3904. client->Message(CHANNEL_COLOR_YELLOW, "%s %s.", isBehind ? "YOU are infront of" : "YOU are NOT infront of", cmdTarget->GetName());
  3905. break;
  3906. }
  3907. else if (ToLower(string(sep->arg[0])) == "flank")
  3908. {
  3909. bool isFlanking = client->GetPlayer()->FlankingTarget(cmdTarget);
  3910. client->Message(CHANNEL_COLOR_YELLOW, "%s is %s.", isFlanking ? "YOU are flanking" : "YOU are NOT flanking", cmdTarget->GetName());
  3911. break;
  3912. }
  3913. }
  3914. if (sep->IsNumber(0))
  3915. {
  3916. float radius = atof(sep->arg[0]);
  3917. if (!client->GetCurrentZone()->SendRadiusSpawnInfo(client, radius))
  3918. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No results in the radius were found.");
  3919. break;
  3920. }
  3921. }
  3922. if (spawn) {
  3923. const char* type = "NPC";
  3924. if (spawn->IsObject())
  3925. type = "Object";
  3926. else if (spawn->IsSign())
  3927. type = "Sign";
  3928. else if (spawn->IsWidget())
  3929. type = "Widget";
  3930. else if (spawn->IsGroundSpawn())
  3931. type = "GroundSpawn";
  3932. client->Message(CHANNEL_COLOR_YELLOW, "Name: %s, %s ID: %u", spawn->GetName(), type, spawn->GetDatabaseID());
  3933. client->Message(CHANNEL_COLOR_YELLOW, "Last Name: %s, Sub-Title: %s, Prefix: %s, Suffix: %s", spawn->GetLastName(), spawn->GetSubTitle(), spawn->GetPrefixTitle(), spawn->GetSuffixTitle());
  3934. client->Message(CHANNEL_COLOR_YELLOW, "Spawn Location ID: %u, Spawn Group ID: %u", spawn->GetSpawnLocationID(), spawn->GetSpawnGroupID());
  3935. client->Message(CHANNEL_COLOR_YELLOW, "Faction ID: %u, Merchant ID: %u, Transporter ID: %u", spawn->GetFactionID(), spawn->GetMerchantID(), spawn->GetTransporterID());
  3936. client->Message(CHANNEL_COLOR_YELLOW, "Grid ID: %u", spawn->GetLocation());
  3937. client->Message(CHANNEL_COLOR_YELLOW, "Race: %i, Class: %i, Gender: %i", spawn->GetRace(), spawn->GetAdventureClass(), spawn->GetGender());
  3938. client->Message(CHANNEL_COLOR_YELLOW, "Level: %i, HP: %u, Power: %u", spawn->GetLevel(), spawn->GetHP(), spawn->GetPower());
  3939. 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());
  3940. client->Message(CHANNEL_COLOR_YELLOW, "Collision Radius: %i, Size: %i, Difficulty: %i, Heroic: %i", spawn->GetCollisionRadius(), spawn->GetSize(), spawn->GetEncounterLevel(), spawn->GetHeroic());
  3941. client->Message(CHANNEL_COLOR_YELLOW, "Targetable: %i, Show Name: %i, Attackable: %i, Show Level: %i", spawn->GetTargetable(), spawn->GetShowName(), spawn->GetAttackable(), spawn->GetShowLevel());
  3942. client->Message(CHANNEL_COLOR_YELLOW, "Show Command Icon: %i, Display Hand Icon: %i", spawn->GetShowCommandIcon(), spawn->GetShowHandIcon());
  3943. if (spawn->IsEntity()) {
  3944. 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());
  3945. 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());
  3946. }
  3947. client->Message(CHANNEL_COLOR_YELLOW, "Model Type: %i, Soga Race Type: %i", spawn->GetModelType(), spawn->GetSogaModelType());
  3948. client->Message(CHANNEL_COLOR_YELLOW, "Primary Command Type: %u, Secondary Command Type: %u", spawn->GetPrimaryCommandListID(), spawn->GetSecondaryCommandListID());
  3949. 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());
  3950. 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);
  3951. if (spawn->IsNPC())
  3952. client->Message(CHANNEL_COLOR_YELLOW, "Randomize: %u", ((NPC*)spawn)->GetRandomize());
  3953. string details;
  3954. details += "\\#0000FFName: " + string(spawn->GetName()) + "\n";
  3955. details += "Type: " + string(type) + "\n";
  3956. details += "ID: " + to_string(spawn->GetDatabaseID()) + "\n";
  3957. details += "Last Name: " + string(spawn->GetLastName()) + "\n";
  3958. details += "Sub-Title: " + string(spawn->GetSubTitle()) + "\n";
  3959. details += "Prefix: " + string(spawn->GetPrefixTitle()) + "\n";
  3960. details += "Suffix: " + string(spawn->GetSuffixTitle()) + "\n";
  3961. details += "Race: " + to_string(spawn->GetRace()) + "\n";
  3962. details += "Class: " + to_string(spawn->GetAdventureClass()) + "\n";
  3963. details += "Gender: " + to_string(spawn->GetGender()) + "\n";
  3964. details += "Level: " + to_string(spawn->GetLevel()) + "\n";
  3965. details += "HP: " + to_string(spawn->GetHP()) + "\n";
  3966. details += "Power: " + to_string(spawn->GetPower()) + "\n";
  3967. details += "Difficulty: " + to_string(spawn->GetEncounterLevel()) + "\n";
  3968. details += "Heroic: " + to_string(spawn->GetHeroic()) + "\n";
  3969. details += "Group ID: " + to_string(spawn->GetSpawnGroupID()) + "\n";
  3970. details += "Faction ID: " + to_string(spawn->GetFactionID()) + "\n";
  3971. details += "Merchant ID: " + to_string(spawn->GetMerchantID()) + "\n";
  3972. details += "Transport ID: " + to_string(spawn->GetTransporterID()) + "\n";
  3973. details += "Location ID: " + to_string(spawn->GetSpawnLocationID()) + "\n";
  3974. char x[16];
  3975. sprintf(x, "%.2f", spawn->GetX());
  3976. char y[16];
  3977. sprintf(y, "%.2f", spawn->GetY());
  3978. char z[16];
  3979. sprintf(z, "%.2f", spawn->GetZ());
  3980. details += "Location: " + string(x) + ", " + string(y) + ", " + string(z) + "\n";
  3981. string details2;
  3982. details2 += "Heading: " + to_string(spawn->GetHeading()) + "\n";
  3983. details2 += "Grid ID: " + to_string(spawn->GetLocation()) + "\n";
  3984. details2 += "Size: " + to_string(spawn->GetSize()) + "\n";
  3985. details2 += "Collision Radius: " + to_string(spawn->GetCollisionRadius()) + "\n";
  3986. details2 += "Respawn Time: " + to_string(spawn->GetRespawnTime()) + "\n";
  3987. details2 += "Targetable: " + to_string(spawn->GetTargetable()) + "\n";
  3988. details2 += "Show Name: " + to_string(spawn->GetShowName()) + "\n";
  3989. details2 += "Attackable: " + to_string(spawn->GetAttackable()) + "\n";
  3990. details2 += "Show Level: " + to_string(spawn->GetShowLevel()) + "\n";
  3991. details2 += "Show Command Icon: " + to_string(spawn->GetShowCommandIcon()) + "\n";
  3992. details2 += "Display Hand Icon: " + to_string(spawn->GetShowHandIcon()) + "\n";
  3993. details2 += "Model Type: " + to_string(spawn->GetModelType()) + "\n";
  3994. details2 += "Soga Race Type: " + to_string(spawn->GetSogaModelType()) + "\n";
  3995. details2 += "Primary Command ID: " + to_string(spawn->GetPrimaryCommandListID()) + "\n";
  3996. details2 += "Secondary Cmd ID: " + to_string(spawn->GetSecondaryCommandListID()) + "\n";
  3997. details2 += "Visual State: " + to_string(spawn->GetVisualState()) + "\n";
  3998. details2 += "Action State: " + to_string(spawn->GetActionState()) + "\n";
  3999. details2 += "Mood State: " + to_string(spawn->GetMoodState()) + "\n";
  4000. details2 += "Initial State: " + to_string(spawn->GetInitialState()) + "\n";
  4001. details2 += "Activity Status: " + to_string(spawn->GetActivityStatus()) + "\n";
  4002. details2 += "Emote State: " + to_string(spawn->GetEmoteState()) + "\n";
  4003. string details3;
  4004. details3 += "Pitch: " + to_string(spawn->GetPitch()) + "\n";
  4005. details3 += "Roll: " + to_string(spawn->GetRoll()) + "\n";
  4006. details3 += "Hide Hood: " + to_string(spawn->appearance.hide_hood) + "\n";
  4007. details3 += "Speed: " + to_string(spawn->GetSpeed()) + "\n";
  4008. details3 += "BaseSpeed: " + to_string(spawn->GetBaseSpeed()) + "\n";
  4009. if(spawn->IsEntity())
  4010. {
  4011. Entity* ent = (Entity*)spawn;
  4012. details3 += "STR / STRBase: " + to_string(ent->GetInfoStruct()->get_str()) + " / " + to_string(ent->GetInfoStruct()->get_str_base()) + "\n";
  4013. details3 += "AGI / AGIBase: " + to_string(ent->GetInfoStruct()->get_agi()) + " / " + to_string(ent->GetInfoStruct()->get_agi_base()) + "\n";
  4014. details3 += "STA / STABase: " + to_string(ent->GetInfoStruct()->get_sta()) + " / " + to_string(ent->GetInfoStruct()->get_sta_base()) + "\n";
  4015. details3 += "INT / INTBase: " + to_string(ent->GetInfoStruct()->get_intel()) + " / " + to_string(ent->GetInfoStruct()->get_intel_base()) + "\n";
  4016. details3 += "WIS / WISBase: " + to_string(ent->GetInfoStruct()->get_wis()) + " / " + to_string(ent->GetInfoStruct()->get_wis_base()) + "\n";
  4017. }
  4018. string details4;
  4019. if (spawn->IsEntity()) {
  4020. details4 += "Facial Hair Type: " + to_string(((Entity*)spawn)->GetFacialHairType()) + "\n";
  4021. details4 += "Hair Type: " + to_string(((Entity*)spawn)->GetHairType()) + "\n";
  4022. details4 += "Chest Type: " + to_string(((Entity*)spawn)->GetChestType()) + "\n";
  4023. details4 += "Legs Type: " + to_string(((Entity*)spawn)->GetLegsType()) + "\n";
  4024. details4 += "Soga Facial Hair Type: " + to_string(((Entity*)spawn)->GetSogaFacialHairType()) + "\n";
  4025. details4 += "Soga Hair Type: " + to_string(((Entity*)spawn)->GetSogaHairType()) + "\n";
  4026. details4 += "Wing Type: " + to_string(((Entity*)spawn)->GetWingType()) + "\n";
  4027. if (spawn->IsNPC()) {
  4028. details4 += "\nRandomize: " + to_string(((NPC*)spawn)->GetRandomize()) + "\n";
  4029. }
  4030. const char* spawnScriptMsg = (spawn->GetSpawnScript() && strlen(spawn->GetSpawnScript())>0) ? spawn->GetSpawnScript() : "Not Set";
  4031. details4 += "\nSpawnScript: " + std::string(spawnScriptMsg) + "\n";
  4032. }
  4033. string title = string(spawn->GetName()) + "(" + to_string(spawn->GetDatabaseID()) + ")";
  4034. client->SendShowBook(client->GetPlayer(), title, 4, details, details2, details3, details4);
  4035. }
  4036. else {
  4037. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn details (radius)");
  4038. 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.");
  4039. }
  4040. break;
  4041. }
  4042. case COMMAND_SPAWN_TARGET:{
  4043. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  4044. int32 spawn_id = atoul(sep->arg[0]);
  4045. int16 response = client->GetCurrentZone()->SetSpawnTargetable(spawn_id);
  4046. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  4047. }
  4048. else if(sep && sep->arg[0][0] && sep->arg[1][0] && sep->IsNumber(1) && ToLower(string(sep->arg[0])) == "radius"){
  4049. float distance = atof(sep->arg[1]);
  4050. int16 response = client->GetCurrentZone()->SetSpawnTargetable(client->GetPlayer(), distance);
  4051. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  4052. }
  4053. else{
  4054. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn target [spawn id]");
  4055. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn as targetable. Used to change a spawn if it was set to untargetable.");
  4056. }
  4057. break;
  4058. }
  4059. case COMMAND_SPAWN_SET:
  4060. {
  4061. Spawn* spawn = cmdTarget;
  4062. sint16 set_type = -1;
  4063. string type_str;
  4064. if (spawn)
  4065. {
  4066. // check if parameters are (location or list or not player and not a 2nd param), and that there is at least 1 value
  4067. 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)
  4068. {
  4069. // set the type, which will be 0 if location or list or invalid
  4070. set_type = spawn_set_values[ToLower(string(sep->arg[0]))];
  4071. }
  4072. if(set_type > 0)
  4073. {
  4074. // check if spawn set is NOT a char update, or not location, or isn't a number
  4075. 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)
  4076. {
  4077. client->SimpleMessage(CHANNEL_COLOR_RED, "Invalid value for set command.");
  4078. }
  4079. else
  4080. {
  4081. string name = string(spawn->GetName());
  4082. if(SetSpawnCommand(client, spawn, set_type, sep->argplus[1]))
  4083. {
  4084. if (set_type == SPAWN_SET_VALUE_EXPANSION_FLAG || set_type == SPAWN_SET_VALUE_HOLIDAY_FLAG)
  4085. {
  4086. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "A /reload spawns is required to properly update the spawns with the xpack/holiday flag.");
  4087. }
  4088. else if (set_type == SPAWN_SET_VALUE_NAME)
  4089. {
  4090. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "New name will not be effective until zone reload.");
  4091. }
  4092. else if (set_type == SPAWN_SET_SKIN_COLOR || (set_type >= SPAWN_SET_HAIR_COLOR1 && set_type <= SPAWN_SET_SOGA_EYE_COLOR))
  4093. {
  4094. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set color field to R G B: %s.", sep->argplus[1]);
  4095. }
  4096. else if(set_type == SPAWN_SET_VALUE_LOCATION)
  4097. {
  4098. spawn->SetLocation(client->GetPlayer()->GetLocation());
  4099. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set '%s' to '%u' for spawn '%s'", sep->arg[0], client->GetPlayer()->GetLocation(), name.c_str());
  4100. }
  4101. else
  4102. {
  4103. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set '%s' to '%s' for spawn '%s'", sep->arg[0], sep->arg[1], name.c_str());
  4104. }
  4105. switch (set_type)
  4106. {
  4107. case SPAWN_SET_VALUE_EXPANSION_FLAG:
  4108. case SPAWN_SET_VALUE_HOLIDAY_FLAG:
  4109. case SPAWN_SET_VALUE_FACTION:
  4110. case SPAWN_SET_AAXP_REWARDS:
  4111. {
  4112. // not applicable already ran db command
  4113. break;
  4114. }
  4115. default:
  4116. {
  4117. client->GetCurrentZone()->ApplySetSpawnCommand(client, spawn, set_type, sep->argplus[1]);
  4118. break;
  4119. }
  4120. }
  4121. 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))
  4122. {
  4123. if(spawn->GetSpawnLocationID() > 0 && database.UpdateSpawnLocationSpawns(spawn))
  4124. {
  4125. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information.");
  4126. }
  4127. else if(spawn->GetSpawnLocationID() > 0)
  4128. {
  4129. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn information, see console window for details.");
  4130. }
  4131. }
  4132. else
  4133. {
  4134. if(spawn->GetDatabaseID() > 0 && database.SaveSpawnInfo(spawn))
  4135. {
  4136. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully saved spawn.");
  4137. }
  4138. else if(spawn->GetDatabaseID() > 0)
  4139. {
  4140. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn, see console window for details.");
  4141. }
  4142. }
  4143. }
  4144. }
  4145. }
  4146. else if(set_type == 0)
  4147. {
  4148. // /spawn set list - lists all possible attributes that can be changed with this command, 10 per line.
  4149. map<string, int8>::iterator itr;
  4150. int i=0;
  4151. string list;
  4152. for(itr = spawn_set_values.begin(); itr != spawn_set_values.end(); itr++, i++)
  4153. {
  4154. if(i==10)
  4155. {
  4156. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  4157. i = 0;
  4158. }
  4159. if(i>0)
  4160. {
  4161. list.append(", ").append(itr->first);
  4162. }
  4163. else
  4164. {
  4165. list = itr->first;
  4166. }
  4167. }
  4168. if(list.length() > 0)
  4169. {
  4170. // if 1 or more, display in client.
  4171. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  4172. }
  4173. }
  4174. else
  4175. {
  4176. // syntax fail
  4177. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn set [type] [value]");
  4178. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used to change various settings for the targeted NPC or Object.");
  4179. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "For a list of changeable settings use /spawn set list");
  4180. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Note: /spawn set location does not require a value. The client's current location is used.");
  4181. }
  4182. }
  4183. break;
  4184. }
  4185. case COMMAND_SPAWN_REMOVE:{
  4186. Spawn* spawn = cmdTarget;
  4187. if(spawn && !spawn->IsPlayer()){
  4188. if(spawn->GetSpawnLocationID() > 0){
  4189. if(database.RemoveSpawnFromSpawnLocation(spawn)){
  4190. client->GetCurrentZone()->RemoveSpawn(spawn, true, false);
  4191. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully removed spawn from zone");
  4192. }
  4193. else
  4194. client->SimpleMessage(CHANNEL_COLOR_RED, "Error removing spawn, see console window for details.");
  4195. }
  4196. else
  4197. client->SimpleMessage(CHANNEL_COLOR_RED, "This spawn does not have a spawn group associated with it");
  4198. }
  4199. else{
  4200. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn remove");
  4201. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for removing the targeted NPC or Object from the zone.");
  4202. }
  4203. break;
  4204. }
  4205. case COMMAND_SPAWN_LIST:{
  4206. if(sep && sep->arg[0][0]){
  4207. vector<string>* results = database.GetSpawnNameList(sep->argplus[0]);
  4208. vector<string>::iterator itr;
  4209. if(results){
  4210. for(itr=results->begin();itr!=results->end();itr++){
  4211. client->SimpleMessage(CHANNEL_COLOR_YELLOW, (*itr).c_str());
  4212. }
  4213. safe_delete(results);
  4214. }
  4215. else
  4216. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found. ");
  4217. }
  4218. else{
  4219. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn list [name]");
  4220. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Name can be a partial match.");
  4221. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn list Qeynos Guard");
  4222. }
  4223. break;
  4224. }
  4225. case COMMAND_SPAWN_ADD:{
  4226. Spawn* spawn = cmdTarget;
  4227. if(spawn && sep && sep->arg[1][0] && (sep->IsNumber(0) || strncasecmp(sep->arg[0], "new", 3) == 0)){
  4228. if(spawn->GetSpawnLocationID() > 0){
  4229. client->Message(CHANNEL_COLOR_RED, "This spawn already has a spawn group id of %u, use /spawn remove to reassign it", spawn->GetSpawnLocationID());
  4230. break;
  4231. }
  4232. if(spawn->GetDatabaseID() == 0){
  4233. if(database.SaveSpawnInfo(spawn)) {
  4234. char spawn_type[32];
  4235. memset(spawn_type, 0, sizeof(spawn_type));
  4236. if (spawn->IsNPC())
  4237. strncpy(spawn_type, "NPC", sizeof(spawn_type) - 1);
  4238. else if (spawn->IsObject())
  4239. strncpy(spawn_type, "Object", sizeof(spawn_type) - 1);
  4240. else if (spawn->IsSign())
  4241. strncpy(spawn_type, "Sign", sizeof(spawn_type) - 1);
  4242. else if (spawn->IsGroundSpawn())
  4243. strncpy(spawn_type, "GroundSpawn", sizeof(spawn_type) - 1);
  4244. else
  4245. strncpy(spawn_type, "Unknown", sizeof(spawn_type) - 1);
  4246. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information with a %s id of %u", spawn_type, spawn->GetDatabaseID());
  4247. }
  4248. else
  4249. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn information, see console window for details.");
  4250. }
  4251. int32 spawn_group_id = 0;
  4252. if(strncasecmp(sep->arg[0], "new", 3) == 0)
  4253. spawn_group_id = database.GetNextSpawnLocation();
  4254. else
  4255. spawn_group_id = atol(sep->arg[0]);
  4256. int8 percent = 100;
  4257. if(sep->arg[2] && sep->IsNumber(2))
  4258. percent = atoi(sep->arg[2]);
  4259. spawn->SetSpawnLocationID(spawn_group_id);
  4260. float x_offset = database.GetSpawnLocationPlacementOffsetX(spawn->GetSpawnLocationID());
  4261. float y_offset = database.GetSpawnLocationPlacementOffsetY(spawn->GetSpawnLocationID());
  4262. float z_offset = database.GetSpawnLocationPlacementOffsetZ(spawn->GetSpawnLocationID());
  4263. if(database.SaveSpawnEntry(spawn, sep->arg[1], percent, x_offset, y_offset, z_offset))
  4264. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn location with a spawn group of %u", spawn->GetSpawnLocationID());
  4265. else
  4266. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn location, see console window for details.");
  4267. }
  4268. else{
  4269. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn add [spawn group id] [spawn group name] (percentage)");
  4270. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for adding the targeted NPC or Object to the database.");
  4271. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can substitute new for [spawn group id] to create a new one.");
  4272. }
  4273. break;
  4274. }
  4275. case COMMAND_SPAWN:{
  4276. int32 id = 0;
  4277. Spawn* spawn = 0;
  4278. if(sep && sep->arg[0] && sep->IsNumber(0)){
  4279. id = atol(sep->arg[0]);
  4280. spawn = client->GetCurrentZone()->GetSpawn(id);
  4281. }
  4282. if(id > 0 && spawn && spawn->appearance.name[0] == 0)
  4283. id = 0;
  4284. if(!id || !spawn){
  4285. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn [spawn id] (x) (y) (z) (heading) (location)");
  4286. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are optional except the id. The spawn id must be in the database.");
  4287. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn 1 0 0 0 0");
  4288. safe_delete(sep);
  4289. return;
  4290. }
  4291. if(sep && sep->arg[1][0]){
  4292. float x = atof(sep->arg[1]);
  4293. spawn->appearance.pos.X = x;
  4294. }
  4295. else
  4296. spawn->SetX(client->GetPlayer()->GetX(), false);
  4297. if(sep && sep->arg[2][0]){
  4298. float y = atof(sep->arg[2]);
  4299. spawn->appearance.pos.Y = y;
  4300. }
  4301. else
  4302. spawn->SetY(client->GetPlayer()->GetY(), false);
  4303. if(sep && sep->arg[3][0]){
  4304. float z = atof(sep->arg[3]);
  4305. spawn->appearance.pos.Z = z;
  4306. }
  4307. else
  4308. spawn->SetZ(client->GetPlayer()->GetZ(), false);
  4309. if(sep && sep->arg[4][0]){
  4310. float heading = atof(sep->arg[4]);
  4311. spawn->SetHeading(heading);
  4312. }
  4313. else
  4314. spawn->SetHeading(client->GetPlayer()->GetHeading(), false);
  4315. spawn->SetSpawnOrigX(spawn->GetX());
  4316. spawn->SetSpawnOrigY(spawn->GetY());
  4317. spawn->SetSpawnOrigZ(spawn->GetZ());
  4318. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  4319. if(sep && sep->arg[5][0])
  4320. spawn->appearance.pos.grid_id = atol(sep->arg[5]);
  4321. else
  4322. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  4323. if(spawn->IsNPC() && spawn->GetTotalHP() == 0){
  4324. spawn->SetTotalHP(spawn->GetLevel() * 15);
  4325. spawn->SetHP(spawn->GetTotalHP());
  4326. }
  4327. if(spawn->GetTotalPower() == 0){
  4328. spawn->SetTotalPower(spawn->GetLevel() * 15);
  4329. spawn->SetPower(spawn->GetTotalPower());
  4330. }
  4331. const char* script = world.GetSpawnScript(id);
  4332. if(script && lua_interface && lua_interface->GetSpawnScript(script) != 0)
  4333. spawn->SetSpawnScript(string(script));
  4334. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_PRESPAWN);
  4335. client->GetCurrentZone()->AddSpawn(spawn);
  4336. if(spawn->IsNPC())
  4337. spawn->GetZone()->AddLoot((NPC*)spawn);
  4338. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_SPAWN);
  4339. LogWrite(COMMAND__INFO, 0, "Command", "Received spawn command - Parms: %s", command_parms->data.c_str());
  4340. break;
  4341. }
  4342. case COMMAND_ADMINFLAG:
  4343. {
  4344. if(sep && sep->arg[0]){
  4345. sint16 tmp_status = database.GetCharacterAdminStatus(sep->arg[0]);
  4346. sint16 new_status = atoi(sep->arg[1]);
  4347. if(tmp_status == -10)
  4348. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character does not exist.");
  4349. else if(tmp_status >= client->GetAdminStatus())
  4350. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character has same or higher level status.");
  4351. else if (new_status > client->GetAdminStatus())
  4352. client->SimpleMessage(CHANNEL_ERROR, "Unable to flag character. Reason: New status is higher then your status.");
  4353. else{
  4354. Client* client2 = client->GetCurrentZone()->GetClientByName(sep->arg[0]);
  4355. if (!client2)
  4356. client2 = zone_list.GetClientByCharName(sep->arg[0]);
  4357. if(database.UpdateAdminStatus(sep->arg[0],new_status)) {
  4358. client->Message(CHANNEL_COLOR_YELLOW,"Character status updated to %i for %s.",new_status,sep->arg[0]);
  4359. if (client2) {
  4360. client2->SetAdminStatus(new_status);
  4361. client2->Message(CHANNEL_COLOR_YELLOW, "%s has set your admin status to %i.", client->GetPlayer()->GetName(), new_status);
  4362. }
  4363. }
  4364. else
  4365. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Unknown reason.");
  4366. }
  4367. }else{
  4368. sint16 status = database.GetCharacterAdminStatus(client->GetPlayer()->GetName());
  4369. if(status != client->GetAdminStatus())
  4370. {
  4371. client->Message(CHANNEL_COLOR_YELLOW,"Flag status was changed from %i to %i.",status,client->GetAdminStatus());
  4372. client->SetAdminStatus(status);
  4373. }
  4374. else
  4375. {
  4376. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /flag {name} {new_status}");
  4377. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Standard User: 0");
  4378. client->Message(CHANNEL_COLOR_YELLOW," Admin User: %i", status);
  4379. }
  4380. }
  4381. break;
  4382. }
  4383. case COMMAND_CANNEDEMOTE:{
  4384. client->GetCurrentZone()->HandleEmote(client, command_parms->data);
  4385. break;
  4386. }
  4387. case COMMAND_BROADCAST: {
  4388. if (sep && sep->arg[0])
  4389. zone_list.HandleGlobalBroadcast(sep->argplus[0]);
  4390. else
  4391. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /broadcast {message}");
  4392. break;
  4393. }
  4394. case COMMAND_ANNOUNCE: {
  4395. if (sep && sep->arg[0])
  4396. zone_list.HandleGlobalAnnouncement(sep->argplus[0]);
  4397. else
  4398. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /announce {message}");
  4399. break;
  4400. }
  4401. case COMMAND_RELOAD_ITEMS:{
  4402. LogWrite(COMMAND__INFO, 0, "Command", "Reloading items..");
  4403. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Started Reloading items (this might take a few minutes...)");
  4404. database.ReloadItemList();
  4405. database.LoadMerchantInformation();
  4406. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Finished Reloading items.");
  4407. break;
  4408. }
  4409. case COMMAND_ENABLE_ABILITY_QUE:{
  4410. EQ2Packet* app = client->GetPlayer()->GetSpellBookUpdatePacket(client->GetVersion());
  4411. if(app)
  4412. client->QueuePacket(app);
  4413. break;
  4414. }
  4415. case COMMAND_ITEMSEARCH:
  4416. case COMMAND_FROMBROKER:{
  4417. PacketStruct* packet = configReader.getStruct("WS_StartBroker", client->GetVersion());
  4418. if (packet) {
  4419. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  4420. //packet->setDataByName("unknown", 1);
  4421. packet->setDataByName("unknown2", 5, 0);
  4422. packet->setDataByName("unknown2", 20, 1);
  4423. packet->setDataByName("unknown2", 58, 3);
  4424. packet->setDataByName("unknown2", 40, 4);
  4425. client->QueuePacket(packet->serialize());
  4426. PacketStruct* packet2 = configReader.getStruct("WS_BrokerBags", client->GetVersion());
  4427. if (packet2) {
  4428. packet2->setDataByName("char_id", client->GetCharacterID());
  4429. client->QueuePacket(packet2->serialize()); //send this for now, needed to properly clear data
  4430. safe_delete(packet2);
  4431. }
  4432. safe_delete(packet);
  4433. }
  4434. break;
  4435. }
  4436. case COMMAND_ANIMTEST:{
  4437. PacketStruct* command_packet = configReader.getStruct("WS_CannedEmote", client->GetVersion());
  4438. if(command_packet){
  4439. int32 id = client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer());
  4440. if (cmdTarget)
  4441. id = client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget);
  4442. command_packet->setDataByName ( "spawn_id" , id);
  4443. int animID = 1;
  4444. if(sep && sep->arg[0] && sep->IsNumber(0))
  4445. animID = atoi(sep->arg[0]);
  4446. VisualState* vs = NULL;
  4447. if(animID == 0)
  4448. {
  4449. vs = visual_states.FindVisualState(sep->arg[0]);
  4450. }
  4451. char msg[128];
  4452. sprintf(msg,"Animation Test ID: %i",animID);
  4453. command_packet->setMediumStringByName ( "emote_msg" , msg );
  4454. if(vs != NULL)
  4455. command_packet->setDataByName ( "anim_type", vs->GetID ( ) );
  4456. else
  4457. command_packet->setDataByName ( "anim_type", animID );
  4458. command_packet->setDataByName ( "unknown0", 0 );
  4459. EQ2Packet* outapp = command_packet->serialize();
  4460. client->QueuePacket(outapp);
  4461. safe_delete(command_packet);
  4462. }
  4463. break;
  4464. }
  4465. case COMMAND_KICK:
  4466. {
  4467. if( sep == 0 || sep->arg[0] == 0)
  4468. {
  4469. client->SimpleMessage(CHANNEL_COLOR_RED, "/kick [name]");
  4470. }
  4471. else
  4472. {
  4473. Client* kickClient = zone_list.GetClientByCharName(string(sep->arg[0]));
  4474. if ( kickClient == client )
  4475. {
  4476. client->Message(CHANNEL_COLOR_RED, "You can't kick yourself!");
  4477. break;
  4478. }
  4479. else if(kickClient != NULL)
  4480. {
  4481. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  4482. if ( maxStatus >= client->GetAdminStatus( ) || kickClient->GetAdminStatus() >= client->GetAdminStatus() )
  4483. {
  4484. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  4485. break;
  4486. }
  4487. client->Message(CHANNEL_COLOR_RED, "Kicking %s...",sep->arg[0]);
  4488. kickClient->Disconnect();
  4489. }
  4490. else
  4491. {
  4492. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  4493. }
  4494. }
  4495. break;
  4496. }
  4497. case COMMAND_LOCK:
  4498. {
  4499. if( sep != NULL && sep->arg[0] != NULL && sep->IsNumber(0)){
  4500. int worldLocked = atoi(sep->arg[0]);
  4501. net.world_locked = worldLocked;
  4502. if ( worldLocked )
  4503. client->Message(CHANNEL_COLOR_YELLOW,"World server has been locked.");
  4504. else
  4505. client->Message(CHANNEL_COLOR_YELLOW,"World server has been unlocked.");
  4506. }
  4507. else
  4508. client->SimpleMessage(CHANNEL_COLOR_RED, "/lock [0/1]");
  4509. break;
  4510. }
  4511. case COMMAND_BAN:{
  4512. if( sep == 0 || sep->arg[0] == 0 || (sep->arg[1][0] != 0 && !sep->IsNumber(1) ) )
  4513. {
  4514. client->SimpleMessage(CHANNEL_COLOR_RED, "/ban [name] [permanent:0/1]");
  4515. }
  4516. else
  4517. {
  4518. Client* kickClient = zone_list.GetClientByCharName(sep->arg[0]);
  4519. if ( kickClient == client )
  4520. {
  4521. client->Message(CHANNEL_COLOR_RED, "You can't ban yourself!");
  4522. break;
  4523. }
  4524. else if(kickClient != NULL)
  4525. {
  4526. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  4527. if ( maxStatus > client->GetAdminStatus( ) ||
  4528. client->GetAdminStatus ( ) > kickClient->GetAdminStatus ( ) )
  4529. {
  4530. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  4531. break;
  4532. }
  4533. client->Message(CHANNEL_COLOR_RED, "Kicking & Banning %s...",sep->arg[0]);
  4534. int perm = atol(sep->arg[1]);
  4535. if ( perm == 1 )
  4536. database.UpdateAdminStatus(sep->arg[0],-2);
  4537. else
  4538. database.UpdateAdminStatus(sep->arg[0],-1);
  4539. kickClient->Disconnect();
  4540. }
  4541. else
  4542. {
  4543. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  4544. }
  4545. }
  4546. break;
  4547. }
  4548. case COMMAND_SET_COMBAT_VOICE:{
  4549. int32 value = 0;
  4550. if(sep && sep->arg[0] && sep->IsNumber(0))
  4551. value = atoi(sep->arg[0]);
  4552. client->GetPlayer()->SetCombatVoice(value);
  4553. break;
  4554. }
  4555. case COMMAND_SET_EMOTE_VOICE:{
  4556. int32 value = 0;
  4557. if(sep && sep->arg[0] && sep->IsNumber(0))
  4558. value = atoi(sep->arg[0]);
  4559. client->GetPlayer()->SetEmoteVoice(value);
  4560. break;
  4561. }
  4562. case COMMAND_GIVEITEM:{
  4563. if(sep && sep->arg[0][0] && sep->arg[0][1] && sep->IsNumber(1)){
  4564. Client* itemToClient = zone_list.GetClientByCharName(sep->arg[0]);
  4565. if ( itemToClient == NULL )
  4566. client->Message(CHANNEL_COLOR_YELLOW,"Could not find %s.",sep->arg[0]);
  4567. else
  4568. {
  4569. int32 item_id = atol(sep->arg[1]);
  4570. client->Message(CHANNEL_COLOR_YELLOW,"Gave %s item id %i.",sep->arg[0],item_id);
  4571. itemToClient->AddItem(item_id);
  4572. }
  4573. }
  4574. else
  4575. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /giveitem [name] [item_id]");
  4576. break;
  4577. }
  4578. case COMMAND_REPORT_BUG : { Command_ReportBug(client, sep); break; }
  4579. case COMMAND_INVENTORY : { Command_Inventory(client, sep, command); break; }
  4580. case COMMAND_WEAPONSTATS : { Command_WeaponStats(client); break; }
  4581. case COMMAND_SKILL :
  4582. case COMMAND_SKILL_ADD :
  4583. case COMMAND_SKILL_REMOVE :
  4584. case COMMAND_SKILL_LIST : { Command_Skills(client, sep, command->handler); break; }
  4585. case COMMAND_ZONE_SET : { Command_ZoneSet(client, sep); break; }
  4586. case COMMAND_ZONE_DETAILS : { Command_ZoneDetails(client, sep); break; }
  4587. case COMMAND_ENTITYCOMMAND :
  4588. case COMMAND_ENTITYCOMMAND_LIST : { Command_EntityCommand(client, sep, command->handler); break; }
  4589. case COMMAND_MERCHANT :
  4590. case COMMAND_MERCHANT_LIST : { Command_Merchant(client, sep, command->handler); break; }
  4591. case COMMAND_APPEARANCE :
  4592. case COMMAND_APPEARANCE_LIST : { Command_Appearance(client, sep, command->handler); break; }
  4593. case COMMAND_TRACK : { Command_Track(client); break; }
  4594. case COMMAND_DISTANCE : { Command_Distance(client); break; }
  4595. case COMMAND_INSPECT_PLAYER : { Command_InspectPlayer(client, sep); break; }
  4596. case COMMAND_ZONE_SAFE : { Command_ZoneSafeCoords(client, sep); break; }
  4597. case COMMAND_GUILDSAY : { Command_GuildSay(client, sep); break; }
  4598. case COMMAND_OFFICERSAY : { Command_OfficerSay(client, sep); break; }
  4599. case COMMAND_SET_GUILD_MEMBER_NOTE : { Command_SetGuildMemberNote(client, sep); break; }
  4600. case COMMAND_SET_GUILD_OFFICER_NOTE : { Command_SetGuildOfficerNote(client, sep); break; }
  4601. case COMMAND_GUILD : { Command_Guild(client, sep); break; }
  4602. case COMMAND_CREATE_GUILD : { Command_CreateGuild(client); break; }
  4603. case COMMAND_GUILDS : { Command_Guilds(client); break; }
  4604. case COMMAND_GUILDS_ADD : { Command_GuildsAdd(client, sep); break; }
  4605. case COMMAND_GUILDS_CREATE : { Command_GuildsCreate(client, sep); break; }
  4606. case COMMAND_GUILDS_DELETE : { Command_GuildsDelete(client, sep); break; }
  4607. case COMMAND_GUILDS_LIST : { Command_GuildsList(client); break; }
  4608. case COMMAND_GUILDS_REMOVE : { Command_GuildsRemove(client, sep); break; }
  4609. case COMMAND_CLAIM : { Command_Claim(client, sep); break; }
  4610. case COMMAND_CLEAR_ALL_QUEUED : { Command_ClearAllQueued(client); break; }
  4611. case COMMAND_LOCATION : { Command_Location(client); break; }
  4612. case COMMAND_LOCATION_ADD : { Command_LocationAdd(client, sep); break; }
  4613. case COMMAND_LOCATION_CREATE : { Command_LocationCreate(client, sep); break; }
  4614. case COMMAND_LOCATION_DELETE : { Command_LocationDelete(client, sep); break; }
  4615. case COMMAND_LOCATION_LIST : { Command_LocationList(client, sep); break; }
  4616. case COMMAND_LOCATION_REMOVE : { Command_LocationRemove(client, sep); break; }
  4617. case COMMAND_GRID : { Command_Grid(client); break; }
  4618. case COMMAND_TRY_ON : { Command_TryOn(client, sep); break; }
  4619. case COMMAND_IRC : { Command_IRC(client, sep); break; }
  4620. case COMMAND_RANDOMIZE : { Command_Randomize(client, sep); break; }
  4621. case COMMAND_AFK : { Command_AFK(client, sep); break; }
  4622. case COMMAND_SHOW_CLOAK : { Command_ShowCloak(client, sep); break; }
  4623. case COMMAND_SHOW_HELM : { Command_ShowHelm(client, sep); break; }
  4624. case COMMAND_SHOW_HOOD : { Command_ShowHood(client, sep); break; }
  4625. case COMMAND_SHOW_HOOD_OR_HELM : { Command_ShowHoodHelm(client, sep); break; }
  4626. case COMMAND_SHOW_RANGED : { Command_ShowRanged(client, sep); break; }
  4627. case COMMAND_STOP_DRINKING : { Command_StopDrinking(client); break; }
  4628. case COMMAND_STOP_EATING : { Command_StopEating(client); break; }
  4629. case COMMAND_TOGGLE_ANONYMOUS : { Command_Toggle_Anonymous(client); break; }
  4630. case COMMAND_TOGGLE_AUTOCONSUME : { Command_Toggle_AutoConsume(client, sep); break; }
  4631. case COMMAND_TOGGLE_BONUS_EXP : { Command_Toggle_BonusXP(client); break; }
  4632. case COMMAND_TOGGLE_COMBAT_EXP : { Command_Toggle_CombatXP(client); break; }
  4633. case COMMAND_TOGGLE_GM_HIDE : { Command_Toggle_GMHide(client); break; }
  4634. case COMMAND_TOGGLE_GM_VANISH : { Command_Toggle_GMVanish(client); break; }
  4635. case COMMAND_TOGGLE_ILLUSIONS : { Command_Toggle_Illusions(client, sep); break; }
  4636. case COMMAND_TOGGLE_LFG : { Command_Toggle_LFG(client); break; }
  4637. case COMMAND_TOGGLE_LFW : { Command_Toggle_LFW(client); break; }
  4638. case COMMAND_TOGGLE_QUEST_EXP : { Command_Toggle_QuestXP(client); break; }
  4639. case COMMAND_TOGGLE_ROLEPLAYING : { Command_Toggle_Roleplaying(client); break; }
  4640. case COMMAND_TOGGLE_DUELS : { Command_Toggle_Duels(client); break; }
  4641. case COMMAND_TOGGLE_TRADES : { Command_Toggle_Trades(client); break; }
  4642. case COMMAND_TOGGLE_GUILDS : { Command_Toggle_Guilds(client); break; }
  4643. case COMMAND_TOGGLE_GROUPS : { Command_Toggle_Groups(client); break; }
  4644. case COMMAND_TOGGLE_RAIDS : { Command_Toggle_Raids(client); break; }
  4645. case COMMAND_TOGGLE_LON : { Command_Toggle_LON(client); break; }
  4646. case COMMAND_TOGGLE_VCINVITE : { Command_Toggle_VoiceChat(client); break; }
  4647. case COMMAND_CANCEL_MAINTAINED : { Command_CancelMaintained(client, sep); break; }
  4648. case COMMAND_MOTD : { Command_MOTD(client); break; }
  4649. case COMMAND_RANDOM : { Command_Random(client, sep); break; }
  4650. case COMMAND_CREATE : { Command_Create(client, sep); break; }
  4651. case COMMAND_CREATEFROMRECIPE : { Command_CreateFromRecipe(client, sep); break; }
  4652. case COMMAND_TITLE : { Command_Title(client); break; }
  4653. case COMMAND_TITLE_LIST : { Command_TitleList(client); break; }
  4654. case COMMAND_TITLE_SETPREFIX : { Command_TitleSetPrefix(client, sep); break; }
  4655. case COMMAND_TITLE_SETSUFFIX : { Command_TitleSetSuffix(client, sep); break; }
  4656. case COMMAND_TITLE_FIX : { Command_TitleFix(client, sep); break; }
  4657. case COMMAND_LANGUAGES : { Command_Languages(client, sep); break; }
  4658. case COMMAND_SET_LANGUAGE : { Command_SetLanguage(client, sep); break; }
  4659. case COMMAND_FOLLOW : { Command_Follow(client, sep); break; }
  4660. case COMMAND_STOP_FOLLOW : { Command_StopFollow(client, sep); break; }
  4661. case COMMAND_LASTNAME : { Command_LastName(client, sep); break; }
  4662. case COMMAND_CONFIRMLASTNAME : { Command_ConfirmLastName(client, sep); break; }
  4663. case COMMAND_PET : { Command_Pet(client, sep); break; }
  4664. case COMMAND_PETNAME : { Command_PetName(client, sep); break; }
  4665. case COMMAND_NAME_PET : { Command_NamePet(client, sep); break; }
  4666. case COMMAND_RENAME : { Command_Rename(client, sep); break; }
  4667. case COMMAND_CONFIRMRENAME : { Command_ConfirmRename(client, sep); break; }
  4668. case COMMAND_PETOPTIONS : { Command_PetOptions(client, sep); break; }
  4669. case COMMAND_START_TRADE : { Command_TradeStart(client, sep); break; }
  4670. case COMMAND_ACCEPT_TRADE : { Command_TradeAccept(client, sep); break; }
  4671. case COMMAND_REJECT_TRADE : { Command_TradeReject(client, sep); break; }
  4672. case COMMAND_CANCEL_TRADE : { Command_TradeCancel(client, sep); break; }
  4673. case COMMAND_SET_TRADE_COIN : { Command_TradeSetCoin(client, sep); break; }
  4674. case COMMAND_ADD_TRADE_COPPER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_COPPER); break; }
  4675. case COMMAND_ADD_TRADE_SILVER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_SILVER); break; }
  4676. case COMMAND_ADD_TRADE_GOLD : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_GOLD); break; }
  4677. case COMMAND_ADD_TRADE_PLAT : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_PLAT); break; }
  4678. case COMMAND_REMOVE_TRADE_COPPER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_COPPER); break; }
  4679. case COMMAND_REMOVE_TRADE_SILVER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_SILVER); break; }
  4680. case COMMAND_REMOVE_TRADE_GOLD : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_GOLD); break; }
  4681. case COMMAND_REMOVE_TRADE_PLAT : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_PLAT); break; }
  4682. case COMMAND_ADD_TRADE_ITEM : { Command_TradeAddItem(client, sep); break; }
  4683. case COMMAND_REMOVE_TRADE_ITEM : { Command_TradeRemoveItem(client, sep); break; }
  4684. case COMMAND_ACCEPT_ADVANCEMENT : { Command_AcceptAdvancement(client, sep); break; }
  4685. case COMMAND_DUEL : { Command_Duel(client, sep); break; }
  4686. case COMMAND_DUELBET : { Command_DuelBet(client, sep); break; }
  4687. case COMMAND_DUEL_ACCEPT : { Command_DuelAccept(client, sep); break; }
  4688. case COMMAND_DUEL_DECLINE : { Command_DuelDecline(client, sep); break; }
  4689. case COMMAND_DUEL_SURRENDER : { Command_DuelSurrender(client, sep); break; }
  4690. case COMMAND_DUEL_TOGGLE : { Command_DuelToggle(client, sep); break; }
  4691. case COMMAND_SPAWN_TEMPLATE : { Command_SpawnTemplate(client, sep); break; }
  4692. case COMMAND_MODIFY : { Command_Modify(client); break; }
  4693. case COMMAND_MODIFY_CHARACTER : { Command_ModifyCharacter(client, sep); break; }
  4694. case COMMAND_MODIFY_QUEST : { Command_ModifyQuest(client, sep); break; }
  4695. case COMMAND_MODIFY_FACTION : { Command_ModifyFaction(client, sep); break; }
  4696. case COMMAND_MODIFY_GUILD : { Command_ModifyGuild(client, sep); break; }
  4697. case COMMAND_MODIFY_ITEM : { Command_ModifyItem(client, sep); break; }
  4698. case COMMAND_MODIFY_SKILL : { Command_ModifySkill(client, sep); break; }
  4699. case COMMAND_MODIFY_SPAWN : { Command_ModifySpawn(client, sep); break; }
  4700. case COMMAND_MODIFY_SPELL : { Command_ModifySpell(client, sep); break; }
  4701. case COMMAND_MODIFY_ZONE : { Command_ModifyZone(client, sep); break; }
  4702. case COMMAND_JOIN_CHANNEL : { Command_JoinChannel(client, sep); break;}
  4703. case COMMAND_JOIN_CHANNEL_FROM_LOAD: { Command_JoinChannelFromLoad(client, sep); break;}
  4704. case COMMAND_TELL_CHANNEL : { Command_TellChannel(client, sep); break;}
  4705. case COMMAND_LEAVE_CHANNEL : { Command_LeaveChannel(client, sep); break;}
  4706. case COMMAND_WHO_CHANNEL : { Command_WhoChannel(client, sep); break;}
  4707. case COMMAND_RAIN : { Command_Rain(client, sep); break; }
  4708. case COMMAND_WIND : { Command_Wind(client, sep); break; }
  4709. case COMMAND_WEATHER : { Command_Weather(client, sep); break; }
  4710. case COMMAND_FROM_MERCHANT : { Command_SendMerchantWindow(client, sep); break; }
  4711. case COMMAND_TO_MERCHANT : { Command_SendMerchantWindow(client, sep, true); break; }
  4712. case COMMAND_SELECT : { Command_Select(client, sep); break; }
  4713. case COMMAND_SMP : { Command_StationMarketPlace(client, sep); break; }
  4714. case COMMAND_CONSUME_FOOD : { Command_ConsumeFood(client, sep); break; }
  4715. case COMMAND_AQUAMAN : { Command_Aquaman(client, sep); break; }
  4716. case COMMAND_ATTUNE_INV : { Command_Attune_Inv(client, sep); break; }
  4717. case COMMAND_PLAYER : { Command_Player(client, sep); break; }
  4718. case COMMAND_PLAYER_COINS : { Command_Player_Coins(client, sep); break; }
  4719. case COMMAND_RESET_ZONE_TIMER : { Command_Reset_Zone_Timer(client, sep); break; }
  4720. case COMMAND_ACHIEVEMENT_ADD : { Command_AchievementAdd(client, sep); break; }
  4721. case COMMAND_EDITOR : { Command_Editor(client, sep); break; }
  4722. case COMMAND_ACCEPT_RESURRECTION: { Command_AcceptResurrection(client, sep); break; }
  4723. case COMMAND_DECLINE_RESURRECTION:{ Command_DeclineResurrection(client, sep); break; }
  4724. case COMMAND_TEST : { Command_Test(client, command_parms); break; }
  4725. case COMMAND_SPEED : { Command_Speed(client, sep); break; }
  4726. case COMMAND_BOT : { Command_Bot(client, sep); break; }
  4727. case COMMAND_BOT_CREATE : { Command_Bot_Create(client, sep); break; }
  4728. case COMMAND_BOT_CUSTOMIZE : { Command_Bot_Customize(client, sep); break; }
  4729. case COMMAND_BOT_SPAWN : { Command_Bot_Spawn(client, sep); break; }
  4730. case COMMAND_BOT_LIST : { Command_Bot_List(client, sep); break; }
  4731. case COMMAND_BOT_INV : { Command_Bot_Inv(client, sep); break; }
  4732. case COMMAND_BOT_SETTINGS : { Command_Bot_Settings(client, sep); break; }
  4733. case COMMAND_BOT_HELP : { Command_Bot_Help(client, sep); break; }
  4734. case GET_AA_XML : { Get_AA_Xml(client, sep); break; }
  4735. case ADD_AA : { Add_AA(client, sep); break; }
  4736. case COMMIT_AA_PROFILE : { Commit_AA_Profile(client, sep); break; }
  4737. case BEGIN_AA_PROFILE : { Begin_AA_Profile(client, sep); break; }
  4738. case BACK_AA : { Back_AA(client, sep); break; }
  4739. case REMOVE_AA : { Remove_AA(client, sep); break; }
  4740. case SWITCH_AA_PROFILE : { Switch_AA_Profile(client, sep); break; }
  4741. case CANCEL_AA_PROFILE : { Cancel_AA_Profile(client, sep); break; }
  4742. case SAVE_AA_PROFILE : { Save_AA_Profile(client, sep); break; }
  4743. case COMMAND_TARGETITEM : { Command_TargetItem(client, sep); break; }
  4744. case COMMAND_FINDSPAWN: { Command_FindSpawn(client, sep); break; }
  4745. case COMMAND_MOVECHARACTER: { Command_MoveCharacter(client, sep); break; }
  4746. case COMMAND_CRAFTITEM: {
  4747. Item* item = 0;
  4748. if (sep && sep->IsNumber(0)) {
  4749. int32 item_id = atol(sep->arg[0]);
  4750. int32 quantity = 1;
  4751. if (sep->arg[1] && sep->IsNumber(1))
  4752. quantity = atoi(sep->arg[1]);
  4753. item = new Item(master_item_list.GetItem(item_id));
  4754. if (!item) {
  4755. LogWrite(TRADESKILL__ERROR, 0, "CraftItem", "Item (%u) not found.", item_id);
  4756. }
  4757. else {
  4758. item->details.count = quantity;
  4759. // use CHANNEL_COLOR_CHAT_RELATIONSHIP as that is the same value (4) as it is in a log for this message
  4760. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You created %s.", item->CreateItemLink(client->GetVersion()).c_str());
  4761. client->AddItem(item);
  4762. //Check for crafting quest updates
  4763. int8 update_amt = 0;
  4764. if (item->stack_count > 1)
  4765. update_amt = 1;
  4766. else
  4767. update_amt = quantity;
  4768. client->GetPlayer()->CheckQuestsCraftUpdate(item, update_amt);
  4769. }
  4770. }
  4771. else {
  4772. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /craftitem {item_id} [quantity] ");
  4773. }
  4774. break;
  4775. }
  4776. case COMMAND_UNMENTOR:
  4777. case COMMAND_MENTOR: {
  4778. client->GetPlayer()->MentorTarget();
  4779. break;
  4780. }
  4781. default:
  4782. {
  4783. LogWrite(COMMAND__WARNING, 0, "Command", "Unhandled command: %s", command->command.data.c_str());
  4784. break;
  4785. }
  4786. }
  4787. safe_delete(sep);
  4788. }
  4789. /******************** New COMMAND Handler Functions ********************/
  4790. /*
  4791. Started breaking apart the huge switch() for commands into sepErate
  4792. functions so it is easier to locate the blocks of code by command
  4793. -- JA 2012.03.03
  4794. */
  4795. // sample function header
  4796. /*
  4797. Function:
  4798. Purpose :
  4799. Params :
  4800. Dev :
  4801. Example :
  4802. */
  4803. //void Commands::Command()
  4804. //{
  4805. //}
  4806. /*
  4807. Function: Command_AcceptAdvancement()
  4808. Purpose : Player accepts a new advancement option
  4809. Params : Spell ID
  4810. Dev : Jabantiz
  4811. */
  4812. void Commands::Command_AcceptAdvancement(Client* client, Seperator* sep)
  4813. {
  4814. Player *player = client->GetPlayer();
  4815. if (sep && sep->IsSet(0)) {
  4816. TraitData* trait = master_trait_list.GetTrait(atoul(sep->arg[0]));
  4817. // Check to see if this is a trait or grandmaster training (traits are always new spells, training is always upgrades)
  4818. if (!player->HasSpell(trait->spellID, 0, true))
  4819. {
  4820. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  4821. player->AddSpellBookEntry(trait->spellID, trait->tier, player->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  4822. }
  4823. else
  4824. {
  4825. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  4826. int8 old_slot = player->GetSpellSlot(spell->GetSpellID());
  4827. player->RemoveSpellBookEntry(spell->GetSpellID());
  4828. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  4829. player->UnlockSpell(spell);
  4830. client->SendSpellUpdate(spell);
  4831. }
  4832. // Spell book update
  4833. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  4834. client->QueuePacket(master_trait_list.GetTraitListPacket(client));
  4835. }
  4836. }
  4837. /*
  4838. Function:
  4839. Purpose :
  4840. Params :
  4841. Dev :
  4842. Example :
  4843. */
  4844. void Commands::Command_AFK(Client* client, Seperator* sep)
  4845. {
  4846. Player* player = client->GetPlayer();
  4847. player->toggle_character_flag(CF_AFK);
  4848. client->Message(CHANNEL_COLOR_YELLOW,"You are %s afk.", client->GetPlayer()->get_character_flag(CF_AFK)?"now":"no longer");
  4849. if (player->get_character_flag(CF_AFK))
  4850. {
  4851. LogWrite(MISC__TODO, 1, "TODO", "player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_AFK); <-- need to find this");
  4852. /*player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_AFK); <-- need to find this */
  4853. if (sep && sep->argplus[0])
  4854. player->SetAwayMessage("I am away from the keyboard, " + string(sep->argplus[0]));
  4855. else
  4856. player->SetAwayMessage("Sorry, I am A.F.K. (Away From Keyboard)");
  4857. string message = string(player->GetName()) + " is going afk.";
  4858. Spawn* target = player->GetTarget();
  4859. if (target && target != player)
  4860. {
  4861. message = string(player->GetName()) + " tells " + string(target->GetName()) + " that ";
  4862. player->GetGender() == 1 ? message += "he" : message += "she";
  4863. message += " is going afk.";
  4864. }
  4865. player->GetZone()->SimpleMessage(CHANNEL_COLOR_YELLOW, message.c_str(), player, 30);
  4866. }
  4867. /*else
  4868. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_AFK); <-- need to find this */
  4869. }
  4870. /*
  4871. Function: Command_Appearance()
  4872. Purpose : Handles /appearance commands
  4873. Params : list
  4874. Dev : Scatman
  4875. Example : /appearance list
  4876. */
  4877. void Commands::Command_Appearance(Client* client, Seperator* sep, int handler)
  4878. {
  4879. if( handler == COMMAND_APPEARANCE )
  4880. {
  4881. // /appearance command by itself shows help (to be extended)
  4882. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  4883. return;
  4884. }
  4885. else if( handler == COMMAND_APPEARANCE_LIST )
  4886. {
  4887. // /appearance list command expects "name" param
  4888. if (sep && sep->arg[0])
  4889. {
  4890. const char* appearance_name = sep->argplus[0];
  4891. client->Message(CHANNEL_COLOR_YELLOW, "Listing appearances like '%s':", appearance_name);
  4892. vector<int16>* appearances = database.GetAppearanceIDsLikeName(string(appearance_name));
  4893. if (appearances)
  4894. {
  4895. vector<int16>::iterator itr;
  4896. for (itr = appearances->begin(); itr != appearances->end(); itr++)
  4897. {
  4898. int16 id = *itr;
  4899. string name = database.GetAppearanceName(id);
  4900. if (ToLower(name).find(ToLower(string(appearance_name))) < 0xFFFFFFFF)
  4901. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", name.c_str(), id);
  4902. }
  4903. safe_delete(appearances);
  4904. }
  4905. }
  4906. else // no param
  4907. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  4908. }
  4909. }
  4910. /*
  4911. Function: Command_Claim()
  4912. Purpose :
  4913. Params :
  4914. Dev :
  4915. Example :
  4916. */
  4917. void Commands::Command_Claim(Client* client, Seperator* sep)
  4918. {
  4919. if (sep && sep->arg[0] && sep->IsNumber(0))
  4920. {
  4921. LogWrite(MISC__TODO, 1, "TODO", "On Scatman's TODO list!\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  4922. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "On Scatman's TODO :)");
  4923. }
  4924. else
  4925. client->ShowClaimWindow();
  4926. }
  4927. /*
  4928. Function: Command_ClearAllQueued()
  4929. Purpose :
  4930. Params :
  4931. Dev :
  4932. Example :
  4933. */
  4934. void Commands::Command_ClearAllQueued(Client* client)
  4935. {
  4936. ZoneServer* zone = client->GetPlayer()->GetZone();
  4937. if (zone && zone->GetSpellProcess())
  4938. zone->GetSpellProcess()->RemoveSpellFromQueue(client->GetPlayer());
  4939. }
  4940. /*
  4941. Function: Command_CancelMaintained()
  4942. Purpose : Cancels maintained spells
  4943. Params : Maintained Spell Index
  4944. Dev : Zcoretri
  4945. Example : /cancel_maintained 1 - would cancel the spell in slot 1 of Maintained Spells list
  4946. */
  4947. void Commands::Command_CancelMaintained(Client* client, Seperator* sep)
  4948. {
  4949. if (sep && sep->arg[0] && sep->IsNumber(0))
  4950. {
  4951. int32 spell_index = atoul(sep->arg[0]);
  4952. MaintainedEffects mEffects = client->GetPlayer()->GetInfoStruct()->maintained_effects[spell_index];
  4953. //Spell* spell = master_spell_list.GetSpell(mEffects.spell_id, mEffects.tier);
  4954. // if (spell && spell->GetSpellData()->friendly_spell) -- NOTE::You can cancel hostile maintained spells,
  4955. // just not spelleffects/dets - Foof
  4956. //{
  4957. if (!client->GetPlayer()->GetZone()->GetSpellProcess()->DeleteCasterSpell(mEffects.spell, "canceled"))
  4958. client->Message(CHANNEL_COLOR_RED, "The maintained spell could not be cancelled.");
  4959. // }
  4960. //else
  4961. //client->Message(CHANNEL_COLOR_RED, "You can only cancel friendly spells!");
  4962. }
  4963. }
  4964. /*
  4965. Function: Command_Create()
  4966. Purpose : Handler for starting Tradeskilling table
  4967. Params :
  4968. Dev : Zcoretri
  4969. Example :
  4970. */
  4971. void Commands::Command_Create(Client* client, Seperator* sep)
  4972. {
  4973. PrintSep(sep, "COMMAND_CREATE");
  4974. client->SendRecipeList();
  4975. client->ShowRecipeBook();
  4976. }
  4977. void Commands::Command_CreateFromRecipe(Client* client, Seperator* sep)
  4978. {
  4979. PrintSep(sep, "COMMAND_CREATEFROMRECIPE");
  4980. if (sep && sep->arg[0] && sep->IsNumber(0))
  4981. ClientPacketFunctions::SendCreateFromRecipe(client, atoul(sep->arg[0]));
  4982. }
  4983. /*
  4984. Function: Command_Distance()
  4985. Purpose : Displays distance from targeted spawn
  4986. Params :
  4987. Dev : Scatman
  4988. Example : /distance
  4989. */
  4990. void Commands::Command_Distance(Client* client)
  4991. {
  4992. Spawn* target = client->GetPlayer()->GetTarget();
  4993. if (target)
  4994. client->Message(CHANNEL_COLOR_YELLOW, "Your distance from %s is %f", target->GetName(), client->GetPlayer()->GetDistance(target));
  4995. else
  4996. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must have a spawn targeted to use /distance");
  4997. }
  4998. /*
  4999. Function: Command_Duel()
  5000. Purpose : Handle the /duel commands - not yet implemented
  5001. Params : unknown
  5002. Dev :
  5003. Example :
  5004. */
  5005. void Commands::Command_Duel(Client* client, Seperator* sep)
  5006. {
  5007. PrintSep(sep, "COMMAND_DUEL");
  5008. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Command");
  5009. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5010. }
  5011. /*
  5012. Function: Command_DuelBet()
  5013. Purpose : Handle the /duel commands - not yet implemented
  5014. Params : unknown
  5015. Dev :
  5016. Example :
  5017. */
  5018. void Commands::Command_DuelBet(Client* client, Seperator* sep)
  5019. {
  5020. PrintSep(sep, "COMMAND_DUELBET");
  5021. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Bet Command");
  5022. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5023. }
  5024. /*
  5025. Function: Command_DuelAccept()
  5026. Purpose : Handle the /duel commands - not yet implemented
  5027. Params : unknown
  5028. Dev :
  5029. Example :
  5030. */
  5031. void Commands::Command_DuelAccept(Client* client, Seperator* sep)
  5032. {
  5033. PrintSep(sep, "COMMAND_DUEL_ACCEPT");
  5034. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Accept Duel Command");
  5035. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5036. }
  5037. /*
  5038. Function: Command_DuelDecline()
  5039. Purpose : Handle the /duel commands - not yet implemented
  5040. Params : unknown
  5041. Dev :
  5042. Example :
  5043. */
  5044. void Commands::Command_DuelDecline(Client* client, Seperator* sep)
  5045. {
  5046. PrintSep(sep, "COMMAND_DUEL_DECLINE");
  5047. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Decline Duel Request Command");
  5048. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5049. }
  5050. /*
  5051. Function: Command_DuelSurrender()
  5052. Purpose : Handle the /duel commands - not yet implemented
  5053. Params : unknown
  5054. Dev :
  5055. Example :
  5056. */
  5057. void Commands::Command_DuelSurrender(Client* client, Seperator* sep)
  5058. {
  5059. PrintSep(sep, "COMMAND_DUEL_SURRENDER");
  5060. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Surrender Duel Command");
  5061. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5062. // JA, just messin around ;)
  5063. char surrender[64];
  5064. sprintf(surrender, "%s surrendered like a cowardly dog!", client->GetPlayer()->GetName());
  5065. zone_list.HandleGlobalAnnouncement(surrender);
  5066. }
  5067. /*
  5068. Function: Command_DuelToggle()
  5069. Purpose : Handle the /duel commands - not yet implemented
  5070. Params : unknown
  5071. Dev :
  5072. Example :
  5073. */
  5074. void Commands::Command_DuelToggle(Client* client, Seperator* sep)
  5075. {
  5076. PrintSep(sep, "COMMAND_DUEL");
  5077. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Commands");
  5078. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5079. }
  5080. /*
  5081. Function:
  5082. Purpose :
  5083. Params :
  5084. Dev :
  5085. Example :
  5086. */
  5087. void Commands::Command_EntityCommand(Client* client, Seperator* sep, int handler)
  5088. {
  5089. if( handler == COMMAND_ENTITYCOMMAND )
  5090. {
  5091. // /entitycommand command by itself shows help (to be extended)
  5092. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  5093. return;
  5094. }
  5095. else if( handler == COMMAND_ENTITYCOMMAND_LIST )
  5096. {
  5097. // /entitycommand list command expects "name" param
  5098. if (sep && sep->arg[0])
  5099. {
  5100. const char* entity_command_name = sep->argplus[0];
  5101. client->Message(CHANNEL_COLOR_YELLOW, "Listing entity commands like '%s':", entity_command_name);
  5102. map<int32, vector<EntityCommand*>*>* entity_command_list_all = client->GetCurrentZone()->GetEntityCommandListAll();
  5103. map<int32, vector<EntityCommand*>*>::iterator itr;
  5104. for (itr = entity_command_list_all->begin(); itr != entity_command_list_all->end(); itr++)
  5105. {
  5106. vector<EntityCommand*>* entity_command_list = itr->second;
  5107. vector<EntityCommand*>::iterator itr2;
  5108. for (itr2 = entity_command_list->begin(); itr2 != entity_command_list->end(); itr2++)
  5109. {
  5110. EntityCommand* entity_command = *itr2;
  5111. if (ToLower(entity_command->name).find(ToLower(string(entity_command_name))) < 0xFFFFFFFF)
  5112. 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);
  5113. }
  5114. }
  5115. }
  5116. else // no command name
  5117. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  5118. }
  5119. }
  5120. /*
  5121. Function: Command_Follow()
  5122. Purpose : Handle the /follow command - not yet implemented
  5123. Params :
  5124. Dev :
  5125. Example :
  5126. */
  5127. void Commands::Command_Follow(Client* client, Seperator* sep)
  5128. {
  5129. PrintSep(sep, "COMMAND_FOLLOW");
  5130. // flag to toggle if the players target is in the players group
  5131. bool targetInGroup = false;
  5132. // get a pointer to the players group
  5133. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  5134. // If the player has a group and has a target
  5135. if (gmi && client->GetPlayer()->GetTarget()) {
  5136. deque<GroupMemberInfo*>::iterator itr;
  5137. world.GetGroupManager()->GroupLock(__FUNCTION__, __LINE__);
  5138. PlayerGroup* group = world.GetGroupManager()->GetGroup(gmi->group_id);
  5139. if (group)
  5140. {
  5141. group->MGroupMembers.readlock(__FUNCTION__, __LINE__);
  5142. deque<GroupMemberInfo*>* members = group->GetMembers();
  5143. // Loop through the group members
  5144. for (itr = members->begin(); itr != members->end(); itr++) {
  5145. // If a group member matches a target
  5146. if ((*itr)->member == client->GetPlayer()->GetTarget()) {
  5147. // toggle the flag and break the loop
  5148. targetInGroup = true;
  5149. break;
  5150. }
  5151. }
  5152. group->MGroupMembers.releasereadlock(__FUNCTION__, __LINE__);
  5153. }
  5154. world.GetGroupManager()->ReleaseGroupLock(__FUNCTION__, __LINE__);
  5155. }
  5156. if (targetInGroup) {
  5157. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  5158. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You start to follow %s.", client->GetPlayer()->GetTarget()->GetName());
  5159. client->GetPlayer()->SetFollowTarget(client->GetPlayer()->GetTarget());
  5160. client->GetPlayer()->info_changed = true;
  5161. client->GetPlayer()->changed = true;
  5162. }
  5163. else
  5164. client->Message(CHANNEL_NARRATIVE, "You must first select a group member to follow.");
  5165. }
  5166. /*
  5167. Function: Command_StopFollow()
  5168. Purpose : Handle the /stop_follow command - not yet implemented
  5169. Params :
  5170. Dev :
  5171. Example :
  5172. */
  5173. void Commands::Command_StopFollow(Client* client, Seperator* sep)
  5174. {
  5175. PrintSep(sep, "COMMAND_STOP_FOLLOW");
  5176. if (client->GetPlayer()->GetFollowTarget()) {
  5177. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  5178. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You are no longer following %s", client->GetPlayer()->GetFollowTarget()->GetName());
  5179. client->GetPlayer()->SetFollowTarget(0);
  5180. client->GetPlayer()->info_changed = true;
  5181. client->GetPlayer()->changed = true;
  5182. }
  5183. }
  5184. #include "../Zone/SPGrid.h"
  5185. /*
  5186. Function: Command_Grid()
  5187. Purpose : Show player's current Grid ID
  5188. Params :
  5189. Dev : Scatman
  5190. Example : /grid
  5191. */
  5192. void Commands::Command_Grid(Client* client)
  5193. {
  5194. client->Message(CHANNEL_COLOR_YELLOW, "Your Grid ID is %u", client->GetPlayer()->appearance.pos.grid_id);
  5195. if (client->GetPlayer()->GetMap() != nullptr) {
  5196. int32 grid = client->GetPlayer()->GetMap()->GetGrid()->GetGridID(client->GetPlayer());
  5197. client->Message(CHANNEL_COLOR_YELLOW, "SPGrid result is %u", grid);
  5198. }
  5199. }
  5200. /*
  5201. Function: Command_Guild()
  5202. Purpose : Handler for all UI-related guild commands
  5203. Dev : Scatman
  5204. */
  5205. void Commands::Command_Guild(Client* client, Seperator* sep)
  5206. {
  5207. Guild* guild = client->GetPlayer()->GetGuild();
  5208. if (sep && sep->GetMaxArgNum() > 0 && sep->arg[0])
  5209. {
  5210. const char* command = sep->arg[0];
  5211. int32 length = strlen(command);
  5212. LogWrite(COMMAND__DEBUG, 0, "Command", "Guild Command: %s", command);
  5213. if (strncmp(command, "rank_name", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && guild)
  5214. guild->SetRankName(atoi(sep->arg[1]), sep->argplus[2]);
  5215. else if (strncmp(command, "rank_permission", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  5216. guild->SetPermission(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  5217. else if (strncmp(command, "filter_event", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  5218. guild->SetEventFilter(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  5219. else if (strncmp(command, "kick", length) == 0 && sep->arg[1] && guild)
  5220. guild->KickGuildMember(client, sep->arg[1]);
  5221. else if (strncmp(command, "demote", length) == 0 && sep->arg[1] && guild)
  5222. guild->DemoteGuildMember(client, sep->arg[1]);
  5223. else if (strncmp(command, "promote", length) == 0 && sep->arg[1] && guild)
  5224. guild->PromoteGuildMember(client, sep->arg[1]);
  5225. else if (strncmp(command, "points", length) == 0 && guild)
  5226. {
  5227. if (sep->arg[1] && strncmp(sep->arg[1], "add", length) == 0)
  5228. {
  5229. if (sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  5230. {
  5231. float points = atof(sep->arg[2]);
  5232. const char* option = sep->arg[3];
  5233. const char* comment = sep->argplus[4];
  5234. if (strncmp(option, "all", strlen(option)) == 0)
  5235. guild->AddPointsToAll(client, points, comment);
  5236. else if (strncmp(option, "online", strlen(option)) == 0)
  5237. guild->AddPointsToAllOnline(client, points, comment);
  5238. else if (strncmp(option, "group", strlen(option)) == 0)
  5239. guild->AddPointsToGroup(client, points, comment);
  5240. else if (strncmp(option, "raid", strlen(option)) == 0)
  5241. guild->AddPointsToRaid(client, points, comment);
  5242. else
  5243. guild->AddPointsToGuildMember(client, points, option, comment);
  5244. }
  5245. }
  5246. else if (sep->arg[1] && strncmp(sep->arg[1], "view", strlen(sep->arg[1])) == 0 && sep->arg[2])
  5247. guild->ViewGuildMemberPoints(client, sep->arg[2]);
  5248. else
  5249. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild points command: %s", sep->argplus[0]);
  5250. }
  5251. else if (strncmp(command, "motd", length) == 0 && sep->arg[1] && guild)
  5252. guild->SetMOTD(sep->argplus[1]);
  5253. else if (strncmp(command, "recruiting", length) == 0 && guild)
  5254. {
  5255. if (sep->arg[1])
  5256. {
  5257. const char* option = sep->arg[1];
  5258. if (strncmp(option, "short_text", strlen(option)) == 0 && sep->arg[2])
  5259. guild->SetRecruitingShortDesc(sep->argplus[2]);
  5260. else if (strncmp(option, "long_text", strlen(option)) == 0 && sep->arg[2])
  5261. guild->SetRecruitingFullDesc(sep->argplus[2]);
  5262. else if (strncmp(option, "flag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  5263. guild->SetRecruitingFlag(atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  5264. else if (strncmp(option, "min_level", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  5265. guild->SetRecruitingMinLevel(atoi(sep->arg[2]));
  5266. else if (strncmp(option, "playstyle", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  5267. guild->SetRecruitingPlayStyle(atoi(sep->arg[2]));
  5268. else if (strncmp(option, "tag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && sep->IsNumber(3))
  5269. guild->SetRecruitingDescTag(atoi(sep->arg[2]), atoi(sep->arg[3]));
  5270. else if (strncmp(command, "recruiting", strlen(option)) == 0)
  5271. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_RECRUITING_FOR_GUILD, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  5272. else
  5273. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  5274. }
  5275. else
  5276. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  5277. }
  5278. else if (strncmp(command, "notify_online", length) == 0 && sep->arg[1] && guild)
  5279. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_NOTIFY_LOGINS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  5280. else if (strncmp(command, "event_privacy", length) == 0 && sep->arg[1] && guild)
  5281. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_DONT_GENERATE_EVENTS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  5282. else if (strncmp(command, "recruiter", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  5283. guild->SetGuildRecruiter(client, sep->arg[1], strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  5284. else if (strncmp(command, "recruiter_description", length) == 0 && sep->arg[1] && guild)
  5285. guild->SetGuildRecruiterDescription(client, sep->argplus[1]);
  5286. else if (strncmp(command, "lock_event", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  5287. guild->LockGuildEvent(atoul(sep->arg[1]), strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  5288. else if (strncmp(command, "delete_event", length) == 0 && sep->arg[1] && guild)
  5289. guild->DeleteGuildEvent(atoul(sep->arg[1]));
  5290. else if (strncmp(command, "invite", length) == 0 && guild)
  5291. {
  5292. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  5293. guild->InvitePlayer(client, sep->arg[1]);
  5294. else
  5295. {
  5296. Spawn* target = client->GetPlayer()->GetTarget();
  5297. if (target)
  5298. {
  5299. if (target->IsPlayer())
  5300. guild->InvitePlayer(client, target->GetName());
  5301. else
  5302. client->Message(CHANNEL_NARRATIVE, "%s is not a player.", target->GetName());
  5303. }
  5304. }
  5305. }
  5306. else if (strncmp(command, "accept", length) == 0)
  5307. {
  5308. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  5309. if (pgi && pgi->guild && pgi->invited_by)
  5310. pgi->guild->AddNewGuildMember(client, pgi->invited_by->GetName());
  5311. client->SetPendingGuildInvite(0);
  5312. }
  5313. else if (strncmp(command, "decline", length) == 0)
  5314. {
  5315. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  5316. if (pgi && pgi->guild && pgi->invited_by)
  5317. {
  5318. Client* client_inviter = pgi->invited_by->GetZone()->GetClientBySpawn(pgi->invited_by);
  5319. if (client_inviter)
  5320. client_inviter->Message(CHANNEL_NARRATIVE, "%s has declined your invitation to join %s.", client->GetPlayer()->GetName(), pgi->guild->GetName());
  5321. }
  5322. client->SetPendingGuildInvite(0);
  5323. }
  5324. else if (strncmp(command, "create", length) == 0 && sep->arg[1])
  5325. {
  5326. const char* guild_name = sep->argplus[1];
  5327. if (!guild_list.GetGuild(guild_name))
  5328. world.CreateGuild(guild_name, client, client->GetPlayer()->GetGroupMemberInfo() ? client->GetPlayer()->GetGroupMemberInfo()->group_id : 0);
  5329. else
  5330. client->SimpleMessage(CHANNEL_NARRATIVE, "A guild with that name already exists.");
  5331. }
  5332. else if (strncmp(command, "search", length) == 0)
  5333. client->ShowGuildSearchWindow();
  5334. else if (strncmp(command, "recruiting_details", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  5335. {
  5336. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  5337. if (to_guild)
  5338. to_guild->SendGuildRecruitingDetails(client);
  5339. }
  5340. else if (strncmp(command, "recruiting_image", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  5341. {
  5342. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  5343. if (to_guild)
  5344. to_guild->SendGuildRecruitingImages(client);
  5345. }
  5346. else if (strncmp(command, "recruiter_adventure_class", length) == 0)
  5347. {
  5348. if (sep->arg[1])
  5349. {
  5350. const char* option = sep->arg[1];
  5351. if (strncmp(option, "toggle", strlen(option)) == 0)
  5352. guild->ToggleGuildRecruiterAdventureClass(client);
  5353. }
  5354. else
  5355. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiter_adventure_class command: '%s'", sep->argplus[0]);
  5356. }
  5357. else if (strncmp(command, "display_heraldry", length) == 0)
  5358. {
  5359. // JA: not sure this is right...
  5360. client->GetPlayer()->toggle_character_flag(CF_SHOW_GUILD_HERALDRY);
  5361. client->GetPlayer()->SetCharSheetChanged(true);
  5362. }
  5363. else
  5364. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild command: '%s'", sep->argplus[0]);
  5365. }
  5366. }
  5367. /*
  5368. Function: Command_GuildCreate()
  5369. Purpose : Display's in-game Guild Creation window
  5370. Dev : Scatman
  5371. */
  5372. void Commands::Command_CreateGuild(Client* client)
  5373. {
  5374. client->SendGuildCreateWindow();
  5375. }
  5376. /*
  5377. Function: Command_SetGuildOfficerNote()
  5378. Purpose :
  5379. Dev : Scatman
  5380. */
  5381. void Commands::Command_SetGuildOfficerNote(Client* client, Seperator* sep)
  5382. {
  5383. if (sep && sep->arg[0] && sep->arg[1])
  5384. {
  5385. Guild* guild = client->GetPlayer()->GetGuild();
  5386. if (guild)
  5387. guild->SetGuildOfficerNote(sep->arg[0], sep->argplus[1]);
  5388. }
  5389. }
  5390. /*
  5391. Function: Command_SetGuildMemberNote()
  5392. Purpose :
  5393. Dev : Scatman
  5394. */
  5395. void Commands::Command_SetGuildMemberNote(Client* client, Seperator* sep)
  5396. {
  5397. if (sep && sep->arg[0] && sep->arg[1])
  5398. {
  5399. Guild* guild = client->GetPlayer()->GetGuild();
  5400. if (guild)
  5401. guild->SetGuildMemberNote(sep->arg[0], sep->argplus[1]);
  5402. }
  5403. }
  5404. /*
  5405. Function: Command_GuildSay()
  5406. Purpose :
  5407. Dev : Scatman
  5408. */
  5409. void Commands::Command_GuildSay(Client* client, Seperator* sep)
  5410. {
  5411. Guild* guild = client->GetPlayer()->GetGuild();
  5412. if (guild)
  5413. {
  5414. if (sep && sep->arg[0])
  5415. guild->HandleGuildSay(client, sep->argplus[0]);
  5416. }
  5417. else
  5418. client->SimpleMessage(CHANNEL_NARRATIVE, "You are not a member of a guild");
  5419. }
  5420. /*
  5421. Function: Command_OfficerSay()
  5422. Purpose :
  5423. Dev : Scatman
  5424. */
  5425. void Commands::Command_OfficerSay(Client* client, Seperator* sep)
  5426. {
  5427. Guild* guild = client->GetPlayer()->GetGuild();
  5428. if (guild)
  5429. {
  5430. if (sep && sep->arg[0])
  5431. guild->HandleOfficerSay(client, sep->argplus[0]);
  5432. }
  5433. else
  5434. client->SimpleMessage(CHANNEL_NARRATIVE, "You are not a member of a guild");
  5435. }
  5436. /*
  5437. Function: Command_Guilds()
  5438. Purpose : Shows help for /guild command
  5439. Params :
  5440. Dev : Scatman
  5441. Example :
  5442. */
  5443. void Commands::Command_Guilds(Client* client)
  5444. {
  5445. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds [create|delete|add|remove|list]");
  5446. }
  5447. /*
  5448. Function: Command_GuildsAdd()
  5449. Purpose : Add's players to a guild
  5450. Params : guild_name|guild_id, player name
  5451. Dev : Scatman
  5452. Example : /guilds add 1 Admin = adds player Admin to guild_id 1
  5453. */
  5454. void Commands::Command_GuildsAdd(Client* client, Seperator* sep)
  5455. {
  5456. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  5457. {
  5458. Guild* guild = 0;
  5459. bool found = true;
  5460. if (sep->IsNumber(0))
  5461. {
  5462. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  5463. if (!guild)
  5464. {
  5465. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  5466. found = false;
  5467. }
  5468. }
  5469. else
  5470. {
  5471. guild = guild_list.GetGuild(sep->arg[0]);
  5472. if (!guild)
  5473. {
  5474. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  5475. found = false;
  5476. }
  5477. }
  5478. if (found)
  5479. {
  5480. Client* to_client = 0;
  5481. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  5482. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  5483. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  5484. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  5485. if (to_client)
  5486. guild->InvitePlayer(client, to_client->GetPlayer()->GetName());
  5487. else
  5488. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  5489. }
  5490. }
  5491. else
  5492. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds add [guild name|guild id] (player name).");
  5493. }
  5494. /*
  5495. Function: Command_GuildsCreate()
  5496. Purpose : Creates a guild
  5497. Params : guild_name, player_name (optional)
  5498. Dev : Scatman
  5499. Example : /guilds create [guild name] (player name)
  5500. */
  5501. void Commands::Command_GuildsCreate(Client* client, Seperator* sep)
  5502. {
  5503. if (sep && sep->arg[0])
  5504. {
  5505. const char* guild_name = sep->arg[0];
  5506. if (!guild_list.GetGuild(guild_name))
  5507. {
  5508. bool ret = false;
  5509. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  5510. {
  5511. Client* to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  5512. if (to_client)
  5513. {
  5514. world.CreateGuild(guild_name, to_client);
  5515. ret = true;
  5516. }
  5517. else
  5518. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player with name '%s'", sep->arg[1]);
  5519. }
  5520. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  5521. {
  5522. Client* to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  5523. if (to_client)
  5524. {
  5525. world.CreateGuild(guild_name, to_client);
  5526. ret = true;
  5527. }
  5528. }
  5529. else
  5530. {
  5531. world.CreateGuild(guild_name);
  5532. ret = true;
  5533. }
  5534. if (ret)
  5535. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully created.", guild_name);
  5536. else
  5537. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the guild.");
  5538. }
  5539. else
  5540. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' already exists.", guild_name);
  5541. }
  5542. else
  5543. 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.");
  5544. }
  5545. /*
  5546. Function: Command_GuildsDelete()
  5547. Purpose : Delete's a guild
  5548. Params : guild name
  5549. Dev : Scatman
  5550. Example : /guilds delete Test
  5551. */
  5552. void Commands::Command_GuildsDelete(Client* client, Seperator* sep)
  5553. {
  5554. if (sep && sep->arg[0])
  5555. {
  5556. Guild* guild = 0;
  5557. bool found = true;
  5558. if (sep->IsNumber(0))
  5559. {
  5560. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  5561. if (!guild)
  5562. {
  5563. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  5564. found = false;
  5565. }
  5566. }
  5567. else
  5568. {
  5569. guild = guild_list.GetGuild(sep->arg[0]);
  5570. if (!guild)
  5571. {
  5572. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  5573. found = false;
  5574. }
  5575. }
  5576. if (found)
  5577. {
  5578. guild->RemoveAllGuildMembers();
  5579. database.DeleteGuild(guild);
  5580. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully deleted.", guild->GetName());
  5581. guild_list.RemoveGuild(guild, true);
  5582. }
  5583. }
  5584. else
  5585. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds delete [guild name].");
  5586. }
  5587. /*
  5588. Function: Command_GuildsList()
  5589. Purpose : Lists current guilds on server
  5590. Params :
  5591. Dev : Scatman
  5592. Example : /guilds list
  5593. */
  5594. void Commands::Command_GuildsList(Client* client)
  5595. {
  5596. MutexMap<int32, Guild*>* guilds = guild_list.GetGuilds();
  5597. MutexMap<int32, Guild*>::iterator itr = guilds->begin();
  5598. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Guild List:");
  5599. if (guilds->size() == 0)
  5600. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "None.");
  5601. else {
  5602. while (itr.Next()) {
  5603. Guild* guild = itr.second;
  5604. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", guild->GetID(), guild->GetName());
  5605. }
  5606. }
  5607. }
  5608. /*
  5609. Function: Command_GuildsRemove()
  5610. Purpose : Removes a player from a guild
  5611. Params : guild name|guild id, player name
  5612. Dev : Scatman
  5613. Example : /guilds remove 1 Admin = removes Admin from guild 1
  5614. */
  5615. void Commands::Command_GuildsRemove(Client* client, Seperator* sep)
  5616. {
  5617. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  5618. {
  5619. Guild* guild = 0;
  5620. bool found = true;
  5621. if (sep->IsNumber(0))
  5622. {
  5623. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  5624. if (!guild)
  5625. {
  5626. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  5627. found = false;
  5628. }
  5629. }
  5630. else
  5631. {
  5632. guild = guild_list.GetGuild(sep->arg[0]);
  5633. if (!guild)
  5634. {
  5635. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  5636. found = false;
  5637. }
  5638. }
  5639. if (found)
  5640. {
  5641. Client* to_client = 0;
  5642. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  5643. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  5644. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  5645. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  5646. if (to_client)
  5647. {
  5648. Player* to_player = to_client->GetPlayer();
  5649. if (to_player->GetGuild())
  5650. {
  5651. if (to_player->GetGuild() == guild)
  5652. {
  5653. guild->KickGuildMember(client, to_player->GetName());
  5654. }
  5655. else
  5656. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in the guild '%s'.", to_player->GetName(), guild->GetName());
  5657. }
  5658. else
  5659. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in a guild.", to_player->GetName());
  5660. }
  5661. else
  5662. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  5663. }
  5664. }
  5665. else
  5666. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds remove [guild name|guild id] (player name).");
  5667. }
  5668. /*
  5669. Function: Command_InspectPlayer()
  5670. Purpose : Handle the Inspect functions
  5671. Params : Client to inspect
  5672. Dev : Scatman
  5673. Example : /inspect Scatman
  5674. */
  5675. void Commands::Command_InspectPlayer(Client* client, Seperator* sep)
  5676. {
  5677. if (sep && sep->arg[0])
  5678. {
  5679. Client* inspect_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  5680. if (inspect_client)
  5681. client->InspectPlayer(inspect_client->GetPlayer());
  5682. }
  5683. else
  5684. {
  5685. Spawn* target = client->GetPlayer()->GetTarget();
  5686. if (target && target->IsPlayer())
  5687. client->InspectPlayer((Player*)target);
  5688. }
  5689. }
  5690. /*
  5691. Function: Command_Inventory()
  5692. Purpose : Handle changes in player inventory
  5693. Params : <TBD>
  5694. Dev : All
  5695. Example : /inventory delete item_id
  5696. */
  5697. void Commands::Command_Inventory(Client* client, Seperator* sep, EQ2_RemoteCommandString* command)
  5698. {
  5699. PrintSep(sep, "Command_Inventory"); // temp to figure out the params
  5700. Player* player = client->GetPlayer();
  5701. if(sep && sep->arg[0][0])
  5702. {
  5703. LogWrite(COMMAND__INFO, 0, "Command", "command: %s", sep->argplus[0]);
  5704. if(client->GetPlayer()->GetHP() == 0)
  5705. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  5706. else if(sep->arg[1][0] && strncasecmp("destroy", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  5707. {
  5708. int16 index = atoi(sep->arg[1]);
  5709. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  5710. if(item)
  5711. {
  5712. if(item->GetItemScript() && lua_interface)
  5713. lua_interface->RunItemScript(item->GetItemScript(), "destroyed", item, client->GetPlayer());
  5714. int32 bag_id = item->details.inv_slot_id;
  5715. database.DeleteItem(client->GetCharacterID(), item, 0);
  5716. client->GetPlayer()->item_list.DestroyItem(index);
  5717. EQ2Packet* outapp = client->GetPlayer()->SendInventoryUpdate(client->GetVersion());
  5718. client->QueuePacket(outapp);
  5719. outapp = client->GetPlayer()->SendBagUpdate(bag_id, client->GetVersion());
  5720. if (outapp)
  5721. client->QueuePacket(outapp);
  5722. }
  5723. }
  5724. 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))
  5725. {
  5726. int16 from_index = atoi(sep->arg[1]);
  5727. sint16 to_slot = atoi(sep->arg[2]);
  5728. sint32 bag_id = atol(sep->arg[3]);
  5729. int8 charges = atoi(sep->arg[4]);
  5730. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(from_index);
  5731. if(bag_id == -4 && !client->GetPlayer()->item_list.SharedBankAddAllowed(item))
  5732. {
  5733. client->SimpleMessage(CHANNEL_COLOR_RED, "That item (or an item inside) cannot be shared.");
  5734. return;
  5735. }
  5736. sint32 old_inventory_id = 0;
  5737. if(item)
  5738. old_inventory_id = item->details.inv_slot_id;
  5739. //autobank
  5740. if (bag_id == -3 && to_slot == -1)
  5741. {
  5742. if (player->HasFreeBankSlot())
  5743. to_slot = player->FindFreeBankSlot();
  5744. else
  5745. {
  5746. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free bank slots.");
  5747. return;
  5748. }
  5749. }
  5750. //auto inventory
  5751. if (bag_id == 0 && to_slot == -1)
  5752. {
  5753. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  5754. {
  5755. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free slots.");
  5756. return;
  5757. }
  5758. }
  5759. EQ2Packet* outapp = client->GetPlayer()->MoveInventoryItem(bag_id, from_index, (int8)to_slot, charges, 0, client->GetVersion());
  5760. client->QueuePacket(outapp);
  5761. //removed from bag send update
  5762. if(old_inventory_id > 0 && item && item->details.inv_slot_id != old_inventory_id)
  5763. {
  5764. outapp = client->GetPlayer()->SendBagUpdate(old_inventory_id, client->GetVersion());
  5765. if(outapp)
  5766. client->QueuePacket(outapp);
  5767. }
  5768. if(item && item->details.inv_slot_id > 0 && item->details.inv_slot_id != old_inventory_id)
  5769. {
  5770. outapp = client->GetPlayer()->SendBagUpdate(item->details.inv_slot_id, client->GetVersion());
  5771. if(outapp)
  5772. client->QueuePacket(outapp);
  5773. }
  5774. }
  5775. else if(sep->arg[1][0] && strncasecmp("equip", sep->arg[0], 5) == 0 && sep->IsNumber(1))
  5776. {
  5777. if(client->GetPlayer()->EngagedInCombat())
  5778. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not equip items while in combat.");
  5779. else
  5780. {
  5781. int16 index = atoi(sep->arg[1]);
  5782. int8 slot_id = 255;
  5783. int8 unk3 = 0;
  5784. int8 appearance_equip = 0;
  5785. if(sep->arg[2][0] && sep->IsNumber(2))
  5786. slot_id = atoi(sep->arg[2]);
  5787. if(sep->arg[3][0] && sep->IsNumber(3))
  5788. unk3 = atoul(sep->arg[3]);
  5789. if(sep->arg[4][0] && sep->IsNumber(4))
  5790. appearance_equip = atoul(sep->arg[4]);
  5791. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), appearance_equip, slot_id);
  5792. EQ2Packet* outapp = 0;
  5793. for(int32 i=0;i<packets.size();i++)
  5794. {
  5795. outapp = packets[i];
  5796. if(outapp)
  5797. client->QueuePacket(outapp);
  5798. }
  5799. client->GetPlayer()->ChangePrimaryWeapon();
  5800. client->GetPlayer()->ChangeSecondaryWeapon();
  5801. client->GetPlayer()->ChangeRangedWeapon();
  5802. EQ2Packet* characterSheetPackets = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion());
  5803. client->QueuePacket(characterSheetPackets);
  5804. }
  5805. }
  5806. else if (sep->arg[1][0] && strncasecmp("unpack", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  5807. {
  5808. if (client->GetPlayer()->EngagedInCombat())
  5809. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unpack items while in combat.");
  5810. else {
  5811. int16 index = atoi(sep->arg[1]);
  5812. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  5813. if (item) {
  5814. // client->GetPlayer()->item_list.DestroyItem(index);
  5815. if (item->item_sets.size() > 0) {
  5816. for (int32 i = 0; i < item->item_sets.size(); i++) {
  5817. ItemSet* set = item->item_sets[i];
  5818. if (set->item_stack_size == 0)
  5819. set->item_stack_size += 1;
  5820. client->AddItem(set->item_id, set->item_stack_size);
  5821. }
  5822. }
  5823. }
  5824. client->RemoveItem(item, 1);
  5825. }
  5826. }
  5827. else if(sep->arg[1][0] && strncasecmp("unequip", sep->arg[0], 7) == 0 && sep->IsNumber(1))
  5828. {
  5829. if(client->GetPlayer()->EngagedInCombat())
  5830. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unequip items while in combat.");
  5831. else
  5832. {
  5833. int16 index = atoi(sep->arg[1]);
  5834. sint32 bag_id = -999;
  5835. int8 to_slot = 255;
  5836. if(sep->arg[3][0])
  5837. {
  5838. if(sep->IsNumber(2))
  5839. bag_id = atol(sep->arg[2]);
  5840. if(sep->IsNumber(3))
  5841. to_slot = atoi(sep->arg[3]);
  5842. }
  5843. sint8 unk4 = 0;
  5844. int8 appearance_equip = 0;
  5845. if(sep->arg[4][0] && sep->IsNumber(4))
  5846. unk4 = atoi(sep->arg[4]);
  5847. if(sep->arg[5][0] && sep->IsNumber(5))
  5848. appearance_equip = atoul(sep->arg[5]);
  5849. vector<EQ2Packet*> packets = client->GetPlayer()->UnequipItem(index, bag_id, to_slot, client->GetVersion(), appearance_equip);
  5850. EQ2Packet* outapp = 0;
  5851. for(int32 i=0;i<packets.size();i++)
  5852. {
  5853. outapp = packets[i];
  5854. if(outapp)
  5855. client->QueuePacket(outapp);
  5856. }
  5857. client->GetPlayer()->ChangePrimaryWeapon();
  5858. client->GetPlayer()->ChangeSecondaryWeapon();
  5859. client->GetPlayer()->ChangeRangedWeapon();
  5860. EQ2Packet* characterSheetPackets = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion());
  5861. client->QueuePacket(characterSheetPackets);
  5862. }
  5863. }
  5864. else if(sep->arg[2][0] && strncasecmp("swap_equip", sep->arg[0], 10) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  5865. {
  5866. LogWrite(MISC__TODO, 1, "TODO", " fix this, need to get how live does it\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  5867. int16 index1 = atoi(sep->arg[1]);
  5868. int16 index2 = atoi(sep->arg[2]);
  5869. int8 type = 0;
  5870. if(sep->IsNumber(3))
  5871. type = atoul(sep->arg[3]); // type 0 is combat, 3 = appearance
  5872. EQ2Packet* outapp = client->GetPlayer()->SwapEquippedItems(index1, index2, client->GetVersion(), type);
  5873. if(outapp)
  5874. client->QueuePacket(outapp);
  5875. else
  5876. {
  5877. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to swap items");
  5878. return;
  5879. }
  5880. }
  5881. else if (sep->arg[2][0] && strncasecmp("pop", sep->arg[0], 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  5882. {
  5883. sint16 to_slot = atoi(sep->arg[1]);
  5884. sint32 bag_id = atoi(sep->arg[2]);
  5885. Item* item = client->GetPlayer()->item_list.GetOverflowItem();
  5886. if (item) {
  5887. //auto inventory
  5888. if (bag_id == 0 && to_slot == -1)
  5889. {
  5890. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  5891. {
  5892. client->SimpleMessage(CHANNEL_ERROR, "You do not have any free slots.");
  5893. return;
  5894. }
  5895. // Set the slot for the item
  5896. item->details.inv_slot_id = bag_id;
  5897. item->details.slot_id = to_slot;
  5898. // Flag the item so it gets saved in its new location
  5899. item->save_needed = true;
  5900. // Add the item to its new location
  5901. player->item_list.AddItem(item);
  5902. // Remove the item from the overflow list
  5903. player->item_list.RemoveOverflowItem(item);
  5904. // Send the inventory update packet
  5905. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5906. return;
  5907. }
  5908. else if (bag_id == -3 && to_slot == -1) {
  5909. // Auto Bank
  5910. if (!player->item_list.GetFirstFreeBankSlot(&bag_id, &to_slot)) {
  5911. client->SimpleMessage(CHANNEL_STATUS, "You do not have any free bank slots.");
  5912. return;
  5913. }
  5914. item->details.inv_slot_id = bag_id;
  5915. item->details.slot_id = to_slot;
  5916. item->save_needed = true;
  5917. player->item_list.AddItem(item);
  5918. player->item_list.RemoveOverflowItem(item);
  5919. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5920. }
  5921. else if (bag_id == -4) {
  5922. // Shared Bank
  5923. if (!player->item_list.SharedBankAddAllowed(item)) {
  5924. client->SimpleMessage(CHANNEL_STATUS, "That item (or an item inside) cannot be shared.");
  5925. return;
  5926. }
  5927. Item* tmp_item = player->item_list.GetItem(-4, to_slot);
  5928. if (tmp_item) {
  5929. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  5930. return;
  5931. }
  5932. else {
  5933. item->details.inv_slot_id = bag_id;
  5934. item->details.slot_id = to_slot;
  5935. item->save_needed = true;
  5936. player->item_list.AddItem(item);
  5937. player->item_list.RemoveOverflowItem(item);
  5938. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5939. return;
  5940. }
  5941. }
  5942. else {
  5943. // Try to get an item from the given bag id and slot id
  5944. Item* tmp_item = player->item_list.GetItem(bag_id, to_slot);
  5945. // Check to see if we got an item, if we do send an error,
  5946. // if we don't put the overflow item into this slot
  5947. if (tmp_item) {
  5948. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  5949. }
  5950. else {
  5951. item->details.inv_slot_id = bag_id;
  5952. item->details.slot_id = to_slot;
  5953. item->save_needed = true;
  5954. player->item_list.AddItem(item);
  5955. player->item_list.RemoveOverflowItem(item);
  5956. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5957. return;
  5958. }
  5959. }
  5960. }
  5961. }
  5962. else if(sep->arg[2][0] && strncasecmp("nosale", sep->arg[0], 6) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  5963. {
  5964. sint64 data = strtoull(sep->arg[1], NULL, 0);
  5965. int32 character_item_id = (int32) (data >> 32);
  5966. int32 item_id = (int32) (data & 0xffffffffL);
  5967. int8 sale_setting = atoi(sep->arg[2]);
  5968. Item* item = client->GetPlayer()->item_list.GetItemFromUniqueID(character_item_id);
  5969. if(item)
  5970. {
  5971. item->no_sale = sale_setting;
  5972. item->save_needed = true;
  5973. client->SendSellMerchantList();
  5974. }
  5975. }
  5976. }
  5977. else
  5978. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /inventory {destroy|move|equip|unequip|swap_equip|pop} {item_id} [to_slot] [bag_id]");
  5979. }
  5980. /*
  5981. Function: Command_IRC()
  5982. Purpose : Handle the IRC functions
  5983. Params : IRC Commands
  5984. Dev : Scatman
  5985. Example : /irc say #Channel Hello World!
  5986. */
  5987. void Commands::Command_IRC(Client* client, Seperator* sep)
  5988. {
  5989. if (!rule_manager.GetGlobalRule(R_World, IRCEnabled)->GetBool()) {
  5990. client->SimpleMessage(CHANNEL_STATUS, "IRC is currently disabled on this server");
  5991. return;
  5992. }
  5993. if (sep && sep->arg[0][0]) {
  5994. if (strcasecmp(sep->arg[0], "say") == 0) {
  5995. if (sep->arg[1][0] && sep->arg[2][0]) {
  5996. if (sep->IsNumber(sep->arg[1]))
  5997. irc.Say(client, atoul(sep->arg[1]), sep->argplus[2]);
  5998. else
  5999. irc.Say(client, sep->arg[1], sep->argplus[2]);
  6000. }
  6001. else
  6002. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc say <channel name | channel index> <message>");
  6003. }
  6004. else if (strcasecmp(sep->arg[0], "join") == 0) {
  6005. if (sep->arg[1][0])
  6006. irc.JoinChannel(client, sep->arg[1]);
  6007. else
  6008. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc join <channel name>");
  6009. }
  6010. else if (strcasecmp(sep->arg[0], "leave") == 0) {
  6011. if (sep->arg[1][0])
  6012. irc.LeaveChannel(client, sep->arg[1]);
  6013. else
  6014. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc leave <channel name>");
  6015. }
  6016. else if (strcasecmp(sep->arg[0], "list") == 0)
  6017. irc.ListChannels(client);
  6018. else if (strcasecmp(sep->arg[0], "connect") == 0) {
  6019. if (sep->arg[1][0] && sep->arg[2][0] && sep->IsNumber(2))
  6020. irc.ConnectToServer(client, sep->arg[1], atoi(sep->arg[2]), sep->arg[3]);
  6021. else
  6022. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc connect <host> <port> (nick)");
  6023. }
  6024. else if (strcasecmp(sep->arg[0], "disconnect") == 0)
  6025. irc.DisconnectFromServer(client);
  6026. else
  6027. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown IRC command.");
  6028. }
  6029. else
  6030. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown IRC command.");
  6031. }
  6032. /*
  6033. Function: Command_Languages()
  6034. Purpose : Show's languages the player knows
  6035. Params :
  6036. Dev : Zcoretri
  6037. Example :
  6038. */
  6039. void Commands::Command_Languages(Client* client, Seperator* sep)
  6040. {
  6041. list<Language*>* languages = client->GetPlayer()->GetPlayerLanguages()->GetAllLanguages();
  6042. list<Language*>::iterator itr;
  6043. Language* language;
  6044. client->Message(CHANNEL_NARRATIVE, "You know the following languages:");
  6045. for(itr = languages->begin(); itr != languages->end(); itr++)
  6046. {
  6047. language = *itr;
  6048. client->Message(CHANNEL_NARRATIVE, "%s", language->GetName());
  6049. }
  6050. }
  6051. /*
  6052. Function: Command_SetLanguage()
  6053. Purpose : Handles language commands
  6054. Params : Language ID
  6055. Dev : Zcoretri
  6056. Example :
  6057. */
  6058. void Commands::Command_SetLanguage(Client* client, Seperator* sep)
  6059. {
  6060. Player* player = client->GetPlayer();
  6061. if (sep && sep->arg[0])
  6062. {
  6063. if(!sep->IsNumber(0))
  6064. {
  6065. //String passed in
  6066. const char* value = sep->arg[0];
  6067. if(strncasecmp(value, "Common", strlen(value)) == 0)
  6068. {
  6069. database.SaveCharacterCurrentLang(0, client->GetCharacterID(), client);
  6070. client->SendLanguagesUpdate(0);
  6071. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", value);
  6072. }
  6073. else
  6074. {
  6075. if(player->HasLanguage(value))
  6076. {
  6077. Language* language = player->GetPlayerLanguages()->GetLanguageByName(value);
  6078. database.SaveCharacterCurrentLang(language->GetID(), client->GetCharacterID(), client);
  6079. client->SendLanguagesUpdate(language->GetID());
  6080. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", language->GetName());
  6081. }
  6082. else
  6083. client->Message(CHANNEL_NARRATIVE, "You do not know how to speak %s", value);
  6084. }
  6085. }
  6086. else
  6087. {
  6088. //Number passed in
  6089. int32 id = atoul(sep->arg[0]);
  6090. if(player->HasLanguage(id))
  6091. {
  6092. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  6093. database.SaveCharacterCurrentLang(id, client->GetCharacterID(), client);
  6094. client->SendLanguagesUpdate(id);
  6095. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", language->GetName());
  6096. }
  6097. else
  6098. {
  6099. Language* language = master_languages_list.GetLanguage(id);
  6100. client->Message(CHANNEL_NARRATIVE, "You do not know how to speak %s", language->GetName());
  6101. }
  6102. }
  6103. }
  6104. else
  6105. {
  6106. //No value was passed in
  6107. int32 id = database.GetCharacterCurrentLang(client->GetCharacterID(), player);
  6108. if(id > 0)
  6109. {
  6110. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  6111. client->Message(CHANNEL_NARRATIVE, "You are currently speaking %s ", language->GetName());
  6112. }
  6113. else
  6114. client->Message(CHANNEL_NARRATIVE, "You are currently speaking Common");
  6115. }
  6116. }
  6117. /*
  6118. Function: Command_LastName()
  6119. Purpose : Sets player surname
  6120. Params : Name text
  6121. Dev : theFoof
  6122. Example :
  6123. */
  6124. void Commands::Command_LastName(Client* client, Seperator* sep)
  6125. {
  6126. if (!client)
  6127. return;
  6128. if (sep && sep->arg[0])
  6129. {
  6130. if (!client->GetPlayer()->get_character_flag(CF_ENABLE_CHANGE_LASTNAME)){
  6131. client->Message(CHANNEL_COLOR_YELLOW, "You must be atleast level %i to change your last name.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  6132. return;
  6133. }
  6134. client->RemovePendingLastName();
  6135. uchar* checkname = (uchar*)sep->arg[0];
  6136. bool valid_name = true;
  6137. for (int32 i = 0; i < strlen(sep->arg[0]); i++) {
  6138. if (!alpha_check(checkname[i])) {
  6139. valid_name = false;
  6140. break;
  6141. }
  6142. }
  6143. if (!valid_name) {
  6144. client->Message(CHANNEL_COLOR_YELLOW, "Your last name can only contain letters.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  6145. return;
  6146. }
  6147. string last_name = (string)sep->arg[0];
  6148. int8 max_length = rule_manager.GetGlobalRule(R_Player, MaxLastNameLength)->GetInt8();
  6149. int8 min_length = rule_manager.GetGlobalRule(R_Player, MinLastNameLength)->GetInt8();
  6150. if (last_name.length() <= max_length && last_name.length() >= min_length){
  6151. client->SetPendingLastName(last_name);
  6152. client->SendLastNameConfirmation();
  6153. }
  6154. else
  6155. client->Message(CHANNEL_COLOR_YELLOW, "Your last name must be between %i and %i characters long.", min_length, max_length);
  6156. }
  6157. }
  6158. /*
  6159. Function: Command_ConfirmLastName()
  6160. Purpose : Confirms setting of player surname
  6161. Params : Name text
  6162. Dev : theFoof
  6163. Example :
  6164. */
  6165. void Commands::Command_ConfirmLastName(Client* client, Seperator* sep)
  6166. {
  6167. if (!client)
  6168. return;
  6169. string* name = client->GetPendingLastName();
  6170. if (name){
  6171. Player* player = client->GetPlayer();
  6172. player->SetLastName(name->c_str(), false);
  6173. client->SendTitleUpdate();
  6174. player->SetCharSheetChanged(true);
  6175. client->RemovePendingLastName();
  6176. }
  6177. }
  6178. /*
  6179. Function: Command_Location()
  6180. Purpose : Display's Help for /location commands
  6181. Params :
  6182. Dev : Scatman
  6183. Example : /location = show's help for command
  6184. */
  6185. void Commands::Command_Location(Client* client)
  6186. {
  6187. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Valid /location commands are:");
  6188. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location create [name] (include y). Include y defaults to false");
  6189. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location add [location id]");
  6190. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location remove [location point id]");
  6191. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location delete [location id]");
  6192. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location list [locations|points] [location id if points used]");
  6193. }
  6194. /*
  6195. Function: Command_LocationAdd()
  6196. Purpose : Add's a location to an existing location config
  6197. Params : location_id
  6198. Dev : Scatman
  6199. Example : /location add {location_id}
  6200. */
  6201. void Commands::Command_LocationAdd(Client* client, Seperator* sep)
  6202. {
  6203. if (sep && sep->arg[0] && sep->IsNumber(0))
  6204. {
  6205. int32 location_id = atoul(sep->arg[0]);
  6206. float x = client->GetPlayer()->GetX();
  6207. float y = client->GetPlayer()->GetY();
  6208. float z = client->GetPlayer()->GetZ();
  6209. if (database.AddLocationPoint(location_id, x, y, z))
  6210. client->Message(CHANNEL_COLOR_YELLOW, "Point (%f, %f, %f) was successfully added to location %u", x, y, z, location_id);
  6211. else
  6212. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist. Use /location create to create one", location_id);
  6213. }
  6214. else
  6215. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location add [location id]");
  6216. }
  6217. /*
  6218. Function: Command_LocationCreate()
  6219. Purpose : Creates a new location config
  6220. Params : location name, 0/1 for include_y (optional)
  6221. Dev : Scatman
  6222. Example : /location create Test 1 = creates a new location named Test with include_y True
  6223. */
  6224. void Commands::Command_LocationCreate(Client* client, Seperator* sep)
  6225. {
  6226. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  6227. {
  6228. const char* name = sep->arg[0];
  6229. bool include_y = false;
  6230. if (sep->arg[1] && sep->IsNumber(1) && atoi(sep->arg[1]) > 0)
  6231. include_y = true;
  6232. int32 location_id = database.CreateLocation(client->GetPlayer()->GetZone()->GetZoneID(), client->GetPlayer()->appearance.pos.grid_id, name, include_y);
  6233. if (location_id > 0)
  6234. client->Message(CHANNEL_COLOR_YELLOW, "Location '%s' was successfully created with location id %u", name, location_id);
  6235. else
  6236. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the requested location");
  6237. }
  6238. else
  6239. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location create [name] (include_y). Include y defaults to false");
  6240. }
  6241. /*
  6242. Function: Command_LocationDelete()
  6243. Purpose : Delete's a location config and all it's location points
  6244. Params : location_id
  6245. Dev : Scatman
  6246. Example : /location delete {location_id}
  6247. */
  6248. void Commands::Command_LocationDelete(Client* client, Seperator* sep)
  6249. {
  6250. if (sep && sep->arg[0] && sep->IsNumber(0))
  6251. {
  6252. int32 location_id = atoul(sep->arg[0]);
  6253. if (database.DeleteLocation(location_id))
  6254. client->Message(CHANNEL_COLOR_YELLOW, "Location id %u and all its points were successfully deleted", location_id);
  6255. else
  6256. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist", location_id);
  6257. }
  6258. else
  6259. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location delete [location id]");
  6260. }
  6261. /*
  6262. Function: Command_LocationList()
  6263. Purpose : Display's a list of location points
  6264. Params : location_id
  6265. Dev : Scatman
  6266. Example : /location list {location_id}
  6267. */
  6268. void Commands::Command_LocationList(Client* client, Seperator* sep)
  6269. {
  6270. if (sep && sep->arg[0])
  6271. {
  6272. const char* option = sep->arg[0];
  6273. if (strncmp(option, "locations", strlen(option)) == 0)
  6274. database.ListLocations(client);
  6275. else if (strncmp(option, "points", strlen(option)) == 0 && sep->arg[1] && sep->IsNumber(1))
  6276. {
  6277. int32 location_id = atoul(sep->arg[1]);
  6278. database.ListLocationPoints(client, location_id);
  6279. }
  6280. else
  6281. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  6282. }
  6283. else
  6284. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  6285. }
  6286. /*
  6287. Function: Command_LocationRemove()
  6288. Purpose : Removes a single location point from a location config
  6289. Params : location_point_id (gotten from /location list {id})
  6290. Dev : Scatman
  6291. Example : /location remove 1 = will remove location_point_id 1
  6292. */
  6293. void Commands::Command_LocationRemove(Client* client, Seperator* sep)
  6294. {
  6295. if (sep && sep->arg[0] && sep->IsNumber(0))
  6296. {
  6297. int32 location_point_id = atoul(sep->arg[0]);
  6298. if (database.DeleteLocationPoint(location_point_id))
  6299. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Location point was successfully deleted");
  6300. else
  6301. client->Message(CHANNEL_COLOR_YELLOW, "Location point with ID %u does not exist", location_point_id);
  6302. }
  6303. else
  6304. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location remove [location point id]");
  6305. }
  6306. /*
  6307. Function: Command_Merchant()
  6308. Purpose : Handles Merchant commands
  6309. Params : list
  6310. Dev : Scatman
  6311. Example : /merchant list
  6312. */
  6313. void Commands::Command_Merchant(Client* client, Seperator* sep, int handler)
  6314. {
  6315. if( handler == COMMAND_MERCHANT )
  6316. {
  6317. // /merchant command by itself shows help (to be extended)
  6318. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  6319. return;
  6320. }
  6321. else if( handler == COMMAND_MERCHANT_LIST )
  6322. {
  6323. // /merchant list command expects "description" param
  6324. if (sep && sep->arg[0])
  6325. {
  6326. const char* merchant_description = sep->argplus[0];
  6327. client->Message(CHANNEL_COLOR_YELLOW, "Listing merchants like '%s':", merchant_description);
  6328. map<int32, MerchantInfo*>* merchant_info = world.GetMerchantInfo();
  6329. map<int32, MerchantInfo*>::iterator itr;
  6330. for (itr = merchant_info->begin(); itr != merchant_info->end(); itr++)
  6331. {
  6332. string description = database.GetMerchantDescription(itr->first);
  6333. if (ToLower(description).find(ToLower(string(merchant_description))) < 0xFFFFFFFF)
  6334. client->Message(CHANNEL_COLOR_YELLOW, "Merchant ID: %u, Description: %s", itr->first, description.c_str());
  6335. }
  6336. }
  6337. else // no description
  6338. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  6339. }
  6340. }
  6341. /*
  6342. Function: Command_Modify()
  6343. Purpose : to replace our other "set" commands
  6344. Params : System = the system to modify, Action = the action to perform, Target = what to change (target, or index)
  6345. Dev : John Adams
  6346. Example : /modify spell set name "Aegolism III"
  6347. */
  6348. void Commands::Command_Modify(Client* client)
  6349. {
  6350. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /modify [system] [action] [field] [value] {target|id}");
  6351. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Systems: character, faction, guild, item, skill, spawn, spell, zone");
  6352. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Actions: set, create, delete, add, remove");
  6353. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Value : field name in the table being modified");
  6354. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target : modify current target, or specified {system} ID");
  6355. }
  6356. /*
  6357. Function: Command_ModifySpawn()
  6358. Purpose : replace "spawn set" commands
  6359. Params : Action : the action to perform (or special handler)
  6360. : Field : the DB field to change
  6361. : Value : what to set the value to
  6362. : Target : what object to change (my target, or spawn_id)
  6363. Dev : John Adams
  6364. Example : /modify spawn set name "Lady Vox"
  6365. :
  6366. Note : Special Handlers, like "zoneto" for Signs
  6367. : /modify spawn zoneto
  6368. : Will set a sign's zone x/y/z to my current coords
  6369. */
  6370. void Commands::Command_ModifySpawn(Client* client, Seperator* sep)
  6371. {
  6372. PrintSep(sep, "COMMAND_MODIFY");
  6373. // need at least 2 args for a valid command
  6374. if( sep && sep->arg[1] )
  6375. {
  6376. // JA: just a quick implementation because I need it :)
  6377. if (strcmp(sep->arg[0], "zoneto") == 0)
  6378. {
  6379. if( sep->IsNumber(1) )
  6380. {
  6381. int32 spawn_id = atoul(sep->arg[1]);
  6382. float x_coord = client->GetPlayer()->GetX();
  6383. float y_coord = client->GetPlayer()->GetY();
  6384. float z_coord = client->GetPlayer()->GetZ();
  6385. float h_coord = client->GetPlayer()->GetHeading();
  6386. database.SaveSignZoneToCoords(spawn_id, x_coord, y_coord, z_coord, h_coord);
  6387. }
  6388. else
  6389. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify spawn zoneto spawn_id - sets spawn_id to your coords");
  6390. }
  6391. }
  6392. else
  6393. Command_Modify(client);
  6394. }
  6395. /*
  6396. Function: Command_ModifyCharacter()
  6397. Purpose : to replace our other "set" commands
  6398. Params : Action : Add, Remove
  6399. : Field : copper, silver, gold, plat
  6400. : Value : min 1, max unlimited
  6401. : Target : Self, Player
  6402. Dev : Cynnar
  6403. Example : /modify character add gold 50
  6404. : /modify character remove silver 25
  6405. */
  6406. void Commands::Command_ModifyCharacter(Client* client, Seperator* sep)
  6407. {
  6408. PrintSep(sep, "COMMAND_MODIFY");
  6409. int64 value = 0;
  6410. Player* player = client->GetPlayer();
  6411. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  6412. player = (Player*)player->GetTarget();
  6413. // need at least 2 args for a valid command
  6414. if( sep && sep->arg[1] )
  6415. {
  6416. if (strcmp(sep->arg[0], "add") == 0)
  6417. {
  6418. if (strcmp(sep->arg[1], "copper") == 0)
  6419. {
  6420. value = atoi64(sep->arg[2]);
  6421. player->AddCoins(value);
  6422. if (client->GetPlayer() == player)
  6423. {
  6424. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu copper coin%s", value, (value > 1 ? "s" : ""));
  6425. }
  6426. else {
  6427. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu copper coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  6428. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu copper coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  6429. }
  6430. }
  6431. else if (strcmp(sep->arg[1], "silver") == 0)
  6432. {
  6433. value = atoi64(sep->arg[2]) * 100;
  6434. player->AddCoins(value);
  6435. if (client->GetPlayer() == player)
  6436. {
  6437. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu silver coin%s", value / 100, (value > 1 ? "s" : ""));
  6438. }
  6439. else {
  6440. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu silver coin%s", player->GetName(), value / 100, (value > 1 ? "s" : ""));
  6441. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu silver coin%s", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  6442. }
  6443. }
  6444. else if (strcmp(sep->arg[1], "gold") == 0)
  6445. {
  6446. value = atoi64(sep->arg[2]) * 10000;
  6447. player->AddCoins(value);
  6448. if (client->GetPlayer() == player)
  6449. {
  6450. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu gold coin%s", value / 10000, (value > 1 ? "s" : ""));
  6451. }
  6452. else {
  6453. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu gold coin%s", player->GetName(), value / 10000, (value > 1 ? "s" : ""));
  6454. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu gold coin%s", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  6455. }
  6456. }
  6457. else if (strcmp(sep->arg[1], "plat") == 0)
  6458. {
  6459. value = atoi64(sep->arg[2]) * 1000000;
  6460. player->AddCoins(value);
  6461. if (client->GetPlayer() == player)
  6462. {
  6463. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu platinum coin%s", value / 1000000, (value > 1 ? "s" : ""));
  6464. }
  6465. else {
  6466. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu platinum coin%s", player->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  6467. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu platinum coin%s", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  6468. }
  6469. }
  6470. else
  6471. {
  6472. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  6473. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  6474. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  6475. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character add copper 20");
  6476. }
  6477. }
  6478. else if (strcmp(sep->arg[0], "remove") == 0)
  6479. {
  6480. if (strcmp(sep->arg[1], "copper") == 0)
  6481. {
  6482. value = atoi64(sep->arg[2]);
  6483. player->RemoveCoins(value);
  6484. if (client->GetPlayer() == player)
  6485. {
  6486. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from yourself", value, (value > 1 ? "s" : ""));
  6487. }
  6488. else {
  6489. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from %s", value, (value > 1 ? "s" : ""), player->GetName());
  6490. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu copper coin%s from you", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  6491. }
  6492. }
  6493. else if (strcmp(sep->arg[1], "silver") == 0)
  6494. {
  6495. value = atoi64(sep->arg[2]) * 100;
  6496. player->RemoveCoins(value);
  6497. if (client->GetPlayer() == player)
  6498. {
  6499. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from yourself", value / 100, (value > 1 ? "s" : ""));
  6500. }
  6501. else {
  6502. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from %s", value / 100, (value > 1 ? "s" : ""), player->GetName());
  6503. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu silver coin%s from you", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  6504. }
  6505. }
  6506. else if (strcmp(sep->arg[1], "gold") == 0)
  6507. {
  6508. value = atoi64(sep->arg[2]) * 10000;
  6509. player->RemoveCoins(value);
  6510. if (client->GetPlayer() == player)
  6511. {
  6512. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from yourself", value / 10000, (value > 1 ? "s" : ""));
  6513. }
  6514. else {
  6515. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from %s", value / 10000, (value > 1 ? "s" : ""), player->GetName());
  6516. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu gold coin%s from you", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  6517. }
  6518. }
  6519. else if (strcmp(sep->arg[1], "plat") == 0)
  6520. {
  6521. value = atoi64(sep->arg[2]) * 1000000;
  6522. player->RemoveCoins(value);
  6523. if (client->GetPlayer() == player)
  6524. {
  6525. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from yourself", value / 1000000, (value > 1 ? "s" : ""));
  6526. }
  6527. else {
  6528. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from %s", value / 1000000, (value > 1 ? "s" : ""), player->GetName());
  6529. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu platinum coin%s from you", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  6530. }
  6531. }
  6532. else
  6533. {
  6534. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  6535. }
  6536. }
  6537. else if (strcmp(sep->arg[0], "set") == 0) {
  6538. if (strcmp(sep->arg[1], "tslevel") == 0) {
  6539. int8 level = atoi(sep->arg[2]);
  6540. if (level > 0 && level < 256) {
  6541. if (player) {
  6542. if (client->GetPlayer() == player)
  6543. client->ChangeTSLevel(player->GetTSLevel(), level);
  6544. else
  6545. player->GetZone()->GetClientBySpawn(player)->ChangeTSLevel(player->GetTSLevel(), level);
  6546. }
  6547. }
  6548. else
  6549. client->SimpleMessage(CHANNEL_ERROR, "Level must be between 1 - 255");
  6550. }
  6551. else if (strcmp(sep->arg[1], "tsclass") == 0) {
  6552. int8 tsclass = atoi(sep->arg[2]);
  6553. player->SetTradeskillClass(tsclass);
  6554. player->GetInfoStruct()->set_tradeskill_class1(classes.GetTSBaseClass(player->GetTradeskillClass()));
  6555. player->GetInfoStruct()->set_tradeskill_class2(classes.GetSecondaryTSBaseClass(player->GetTradeskillClass()));
  6556. player->GetInfoStruct()->set_tradeskill_class3(player->GetTradeskillClass());
  6557. player->SetCharSheetChanged(true);
  6558. }
  6559. }
  6560. }
  6561. else
  6562. {
  6563. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  6564. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  6565. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  6566. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  6567. }
  6568. }
  6569. void Commands::Command_ModifyFaction(Client* client, Seperator* sep)
  6570. {
  6571. PrintSep(sep, "COMMAND_MODIFY");
  6572. // need at least 2 args for a valid command
  6573. if( sep && sep->arg[1] )
  6574. {
  6575. }
  6576. else
  6577. Command_Modify(client);
  6578. }
  6579. void Commands::Command_ModifyGuild(Client* client, Seperator* sep)
  6580. {
  6581. PrintSep(sep, "COMMAND_MODIFY");
  6582. // need at least 2 args for a valid command
  6583. if( sep && sep->arg[1] )
  6584. {
  6585. }
  6586. else
  6587. Command_Modify(client);
  6588. }
  6589. void Commands::Command_ModifyItem(Client* client, Seperator* sep)
  6590. {
  6591. PrintSep(sep, "COMMAND_MODIFY");
  6592. // need at least 2 args for a valid command
  6593. if( sep && sep->arg[1] )
  6594. {
  6595. }
  6596. else
  6597. Command_Modify(client);
  6598. }
  6599. /*
  6600. Function: Command_ModifyQuest()
  6601. Purpose : to list players quest and completed quests
  6602. Params : Action : list, completed
  6603. : Target : Self, Player
  6604. Dev : Cynnar
  6605. Example : /modify quest list
  6606. : /modify quest completed
  6607. */
  6608. void Commands::Command_ModifyQuest(Client* client, Seperator* sep)
  6609. {
  6610. PrintSep(sep, "COMMAND_MODIFY");
  6611. int64 value = 0;
  6612. Player* player = client->GetPlayer();
  6613. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  6614. player = (Player*)player->GetTarget();
  6615. // need at least 2 args for a valid command
  6616. if (sep && sep->arg[1])
  6617. {
  6618. if (strcmp(sep->arg[0], "list") == 0)
  6619. {
  6620. map<int32, Quest*>* quests = player->GetPlayerQuests();
  6621. map<int32, Quest*>::iterator itr;
  6622. client->Message(CHANNEL_COLOR_YELLOW, "%s's Quest List:.", client->GetPlayer()->GetName());
  6623. if (quests->size() == 0)
  6624. client->Message(CHANNEL_COLOR_YELLOW, "%s has no quests.", client->GetPlayer()->GetName());
  6625. else
  6626. {
  6627. for (itr = quests->begin(); itr != quests->end(); itr++)
  6628. {
  6629. Quest* quest = itr->second;
  6630. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  6631. }
  6632. }
  6633. }
  6634. else if (strcmp(sep->arg[0], "completed") == 0)
  6635. {
  6636. map<int32, Quest*>* quests = player->GetCompletedPlayerQuests();
  6637. map<int32, Quest*>::iterator itr;
  6638. client->Message(CHANNEL_COLOR_YELLOW, "%s's Completed Quest List:.", client->GetPlayer()->GetName());
  6639. if (quests->size() == 0)
  6640. client->Message(CHANNEL_COLOR_YELLOW, "%s has no completed quests.", client->GetPlayer()->GetName());
  6641. else
  6642. {
  6643. for (itr = quests->begin(); itr != quests->end(); itr++)
  6644. {
  6645. Quest* quest = itr->second;
  6646. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  6647. }
  6648. }
  6649. }
  6650. // Add in a progress step, and a LogWrite() for tracking GM Commands.
  6651. // LogWrite(LUA__DEBUG, 0, "LUA", "Quest: %s, function: %s", quest->GetName(), function);
  6652. else if (strcmp(sep->arg[0], "remove") == 0)
  6653. {
  6654. int32 quest_id = 0;
  6655. if (sep && sep->arg[1] && sep->IsNumber(1))
  6656. quest_id = atoul(sep->arg[1]);
  6657. if (quest_id > 0)
  6658. {
  6659. if (lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0)
  6660. {
  6661. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  6662. if (quest)
  6663. if (client->GetPlayer() == player)
  6664. {
  6665. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been removed from your journal", quest->GetName());
  6666. }
  6667. else
  6668. {
  6669. client->Message(CHANNEL_COLOR_YELLOW, "You have removed the quest %s from %s's journal", quest->GetName(), player->GetName());
  6670. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s has removed the quest %s from your journal", client->GetPlayer()->GetName(), quest->GetName());
  6671. }
  6672. LogWrite(COMMAND__INFO, 0, "GM Command", "%s removed the quest %s from %s", client->GetPlayer()->GetName(), quest->GetName(), player->GetName());
  6673. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  6674. }
  6675. client->RemovePlayerQuest(quest_id);
  6676. client->GetCurrentZone()->SendQuestUpdates(client);
  6677. }
  6678. }
  6679. else if (strcmp(sep->arg[0], "advance") == 0)
  6680. {
  6681. int32 quest_id = 0;
  6682. int32 step = 0;
  6683. if (sep && sep->arg[1] && sep->IsNumber(1))
  6684. {
  6685. quest_id = atoul(sep->arg[1]);
  6686. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  6687. if (sep && sep->arg[2] && sep->IsNumber(1))
  6688. {
  6689. step = atoul(sep->arg[2]);
  6690. if (quest_id > 0 && step > 0)
  6691. {
  6692. if (player && player->IsPlayer() && quest_id > 0 && step > 0 && (player->player_quests.count(quest_id) > 0))
  6693. {
  6694. if (client)
  6695. {
  6696. client->AddPendingQuestUpdate(quest_id, step);
  6697. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been advanced one step.", quest->GetName());
  6698. LogWrite(COMMAND__INFO, 0, "GM Command", "%s advanced the quest %s one step", client->GetPlayer()->GetName(), quest->GetName());
  6699. }
  6700. }
  6701. }
  6702. else
  6703. {
  6704. client->Message(CHANNEL_COLOR_RED, "Quest ID and Step Number must be greater than 0!");
  6705. }
  6706. }
  6707. else
  6708. {
  6709. client->Message(CHANNEL_COLOR_RED, "Step Number must be a number!");
  6710. }
  6711. }
  6712. else
  6713. {
  6714. client->Message(CHANNEL_COLOR_RED, "Quest ID must be a number!");
  6715. }
  6716. }
  6717. else
  6718. {
  6719. Command_Modify(client);
  6720. }
  6721. }
  6722. else
  6723. {
  6724. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify quest [action] [quest id] [step number]");
  6725. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: list, completed, remove, advance");
  6726. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest list");
  6727. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest remove 156");
  6728. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest advance 50 1");
  6729. }
  6730. }
  6731. void Commands::Command_ModifySkill(Client* client, Seperator* sep)
  6732. {
  6733. PrintSep(sep, "COMMAND_MODIFY");
  6734. // need at least 2 args for a valid command
  6735. if( sep && sep->arg[1] )
  6736. {
  6737. if (strcmp(sep->arg[0], "add") == 0) {
  6738. const char* skill_name = sep->argplus[1];
  6739. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6740. if (skill) {
  6741. Player* player = 0;
  6742. Client* to_client = 0;
  6743. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  6744. player = (Player*)client->GetPlayer()->GetTarget();
  6745. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  6746. }
  6747. else {
  6748. player = client->GetPlayer();
  6749. to_client = client;
  6750. }
  6751. if (player)
  6752. {
  6753. if (!player->GetSkills()->HasSkill(skill->skill_id))
  6754. {
  6755. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  6756. if (to_client == client) {
  6757. client->Message(CHANNEL_STATUS, "Added skill '%s'.", skill_name);
  6758. }
  6759. else {
  6760. client->Message(CHANNEL_STATUS, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  6761. to_client->Message(CHANNEL_STATUS, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  6762. }
  6763. }
  6764. else
  6765. client->Message(CHANNEL_STATUS, "%s already has the skill '%s'.", to_client == client ? "You" : player->GetName(), skill_name);
  6766. }
  6767. }
  6768. else
  6769. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  6770. }
  6771. else if (strcmp(sep->arg[0], "remove") == 0) {
  6772. const char* skill_name = sep->argplus[1];
  6773. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6774. if (skill) {
  6775. Player* player = 0;
  6776. Client* to_client = 0;
  6777. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  6778. player = (Player*)client->GetPlayer()->GetTarget();
  6779. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  6780. }
  6781. else {
  6782. player = client->GetPlayer();
  6783. to_client = client;
  6784. }
  6785. if (player)
  6786. {
  6787. if (player->GetSkills()->HasSkill(skill->skill_id))
  6788. {
  6789. player->RemoveSkillFromDB(skill, true);
  6790. if (client == to_client) {
  6791. client->Message(CHANNEL_STATUS, "Removed skill '%s'.", skill_name);
  6792. }
  6793. else {
  6794. client->Message(CHANNEL_STATUS, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  6795. to_client->Message(CHANNEL_STATUS, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  6796. }
  6797. }
  6798. else {
  6799. if (client == to_client)
  6800. client->Message(CHANNEL_STATUS, "You do not have the skill '%s'.", skill_name);
  6801. else
  6802. client->Message(CHANNEL_STATUS, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  6803. }
  6804. }
  6805. }
  6806. else
  6807. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  6808. }
  6809. else if (strcmp(sep->arg[0], "set") == 0) {
  6810. if (!sep->IsNumber(2)) {
  6811. client->Message(CHANNEL_STATUS, "The last parameter must be a number.");
  6812. return;
  6813. }
  6814. const char* skill_name = sep->arg[1];
  6815. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6816. if (skill) {
  6817. int16 val = atoi(sep->arg[2]);
  6818. Player* player = 0;
  6819. Client* to_client = 0;
  6820. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  6821. player = (Player*)client->GetPlayer()->GetTarget();
  6822. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  6823. }
  6824. else {
  6825. player = client->GetPlayer();
  6826. to_client = client;
  6827. }
  6828. if (player)
  6829. {
  6830. if (player->GetSkills()->HasSkill(skill->skill_id)) {
  6831. player->GetSkills()->SetSkill(skill->skill_id, val);
  6832. if (client != to_client)
  6833. client->Message(CHANNEL_STATUS, "You set %s's '%s' skill to %i.", player->GetName(), skill_name, val);
  6834. to_client->Message(CHANNEL_STATUS, "Your '%s' skill has been set to %i.", skill_name, val);
  6835. }
  6836. else {
  6837. client->Message(CHANNEL_STATUS, "Target does not have the skill '%s'.", skill_name);
  6838. }
  6839. }
  6840. }
  6841. else {
  6842. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  6843. }
  6844. }
  6845. else {
  6846. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  6847. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  6848. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  6849. }
  6850. }
  6851. else {
  6852. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  6853. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  6854. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  6855. }
  6856. }
  6857. void Commands::Command_ModifySpell(Client* client, Seperator* sep)
  6858. {
  6859. PrintSep(sep, "COMMAND_MODIFY");
  6860. // need at least 2 args for a valid command
  6861. if( sep && sep->arg[1] )
  6862. {
  6863. }
  6864. else
  6865. Command_Modify(client);
  6866. }
  6867. void Commands::Command_ModifyZone(Client* client, Seperator* sep)
  6868. {
  6869. PrintSep(sep, "COMMAND_MODIFY");
  6870. // need at least 2 args for a valid command
  6871. if( sep && sep->arg[1] )
  6872. {
  6873. }
  6874. else
  6875. Command_Modify(client);
  6876. }
  6877. /*
  6878. Function: Command_MOTD()
  6879. Purpose : Displays server MOTD
  6880. Params :
  6881. Dev : LethalEncounter
  6882. Example : /motd
  6883. */
  6884. void Commands::Command_MOTD(Client* client)
  6885. {
  6886. if (client)
  6887. ClientPacketFunctions::SendMOTD(client);
  6888. }
  6889. /*
  6890. Function: Command_Pet()
  6891. Purpose : Handle Pet {Command} commands
  6892. Params : attack, backoff, preserve_master, preserve_self, follow, stay, getlost
  6893. Dev :
  6894. Example : /pet preserve_master
  6895. */
  6896. void Commands::Command_Pet(Client* client, Seperator* sep)
  6897. {
  6898. PrintSep(sep, "COMMAND_PET");
  6899. //LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Pet Commands");
  6900. //client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6901. if (!sep || !sep->arg[0])
  6902. return; // should have sep->arg[0] filled
  6903. if (strcmp(sep->arg[0], "hide") == 0) {
  6904. // doing /pet hide will toggle the hide status on all the pets that can be hidden
  6905. Entity* pet = client->GetPlayer()->GetDeityPet();
  6906. if (pet) {
  6907. if (pet->IsPrivateSpawn())
  6908. client->GetPlayer()->HideDeityPet(false);
  6909. else
  6910. client->GetPlayer()->HideDeityPet(true);
  6911. }
  6912. pet = client->GetPlayer()->GetCosmeticPet();
  6913. if (pet) {
  6914. if (pet->IsPrivateSpawn())
  6915. client->GetPlayer()->HideCosmeticPet(false);
  6916. else
  6917. client->GetPlayer()->HideCosmeticPet(true);
  6918. }
  6919. return;
  6920. }
  6921. // below is for all combat pets
  6922. if (!client->GetPlayer()->HasPet()) {
  6923. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a pet.");
  6924. return;
  6925. }
  6926. if (strcmp(sep->arg[0], "stay") == 0) {
  6927. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to stay.");
  6928. client->GetPlayer()->GetInfoStruct()->set_pet_movement(1);
  6929. client->GetPlayer()->SetCharSheetChanged(true);
  6930. if (client->GetPlayer()->GetPet())
  6931. client->GetPlayer()->GetPet()->following = false;
  6932. if (client->GetPlayer()->GetCharmedPet())
  6933. client->GetPlayer()->GetCharmedPet()->following = false;
  6934. }
  6935. else if (strcmp(sep->arg[0], "follow") == 0) {
  6936. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to follow.");
  6937. client->GetPlayer()->GetInfoStruct()->set_pet_movement(2);
  6938. client->GetPlayer()->SetCharSheetChanged(true);
  6939. }
  6940. else if (strcmp(sep->arg[0], "preserve_master") == 0) {
  6941. if (client->GetPlayer()->GetInfoStruct()->get_pet_behavior() & 1) {
  6942. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect you.");
  6943. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()-1);
  6944. }
  6945. else {
  6946. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect you.");
  6947. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()+1);
  6948. }
  6949. client->GetPlayer()->SetCharSheetChanged(true);
  6950. }
  6951. else if (strcmp(sep->arg[0], "preserve_self") == 0) {
  6952. if (client->GetPlayer()->GetInfoStruct()->get_pet_behavior() & 2) {
  6953. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect itself.");
  6954. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()-2);
  6955. }
  6956. else {
  6957. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect itself.");
  6958. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()+2);
  6959. }
  6960. client->GetPlayer()->SetCharSheetChanged(true);
  6961. }
  6962. else if (strcmp(sep->arg[0], "backoff") == 0) {
  6963. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to back down.");
  6964. if (client->GetPlayer()->GetPet())
  6965. ((NPC*)client->GetPlayer()->GetPet())->Brain()->ClearHate();
  6966. if (client->GetPlayer()->GetCharmedPet())
  6967. ((NPC*)client->GetPlayer()->GetCharmedPet())->Brain()->ClearHate();
  6968. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(0);
  6969. client->GetPlayer()->SetCharSheetChanged(true);
  6970. }
  6971. else if (strcmp(sep->arg[0], "attack") == 0) {
  6972. if (client->GetPlayer()->HasTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  6973. if (client->GetPlayer()->AttackAllowed((Entity*)client->GetPlayer()->GetTarget())){
  6974. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to attack your target.");
  6975. if (client->GetPlayer()->GetPet())
  6976. client->GetPlayer()->GetPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  6977. if (client->GetPlayer()->GetCharmedPet())
  6978. client->GetPlayer()->GetCharmedPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  6979. }
  6980. else
  6981. client->Message(CHANNEL_COLOR_YELLOW, "You can not attack that.");
  6982. }
  6983. else
  6984. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a target.");
  6985. }
  6986. else if (strcmp(sep->arg[0], "getlost") == 0) {
  6987. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetPet());
  6988. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetCharmedPet());
  6989. client->Message(CHANNEL_COLOR_YELLOW, "You tell your pet to get lost.");
  6990. }
  6991. else
  6992. client->Message(CHANNEL_COLOR_YELLOW, "Unknown pet command.");
  6993. }
  6994. /*
  6995. Function: Command_PetName()
  6996. Purpose : Pet your name (???)
  6997. Params :
  6998. Dev :
  6999. Example :
  7000. */
  7001. void Commands::Command_PetName(Client* client, Seperator* sep)
  7002. {
  7003. PrintSep(sep, "COMMAND_PETNAME");
  7004. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Pet Name Command");
  7005. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7006. }
  7007. /*
  7008. Function: Command_NamePet()
  7009. Purpose : Name your pet
  7010. Params :
  7011. Dev :
  7012. Example :
  7013. */
  7014. void Commands::Command_NamePet(Client* client, Seperator* sep)
  7015. {
  7016. PrintSep(sep, "COMMAND_NAME_PET");
  7017. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Name Pet Command");
  7018. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7019. }
  7020. /*
  7021. Function: Command_Rename()
  7022. Purpose : Renames existing pet
  7023. Params :
  7024. Dev :
  7025. Example :
  7026. */
  7027. void Commands::Command_Rename(Client* client, Seperator* sep)
  7028. {
  7029. PrintSep(sep, "COMMAND_RENAME");
  7030. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Rename Pet Command");
  7031. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7032. }
  7033. /*
  7034. Function: Command_ConfirmRename()
  7035. Purpose : Confirms renaming your pet
  7036. Params :
  7037. Dev :
  7038. Example :
  7039. */
  7040. void Commands::Command_ConfirmRename(Client* client, Seperator* sep)
  7041. {
  7042. PrintSep(sep, "COMMAND_CONFIRMRENAME");
  7043. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Confirm Rename Pet Command");
  7044. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7045. }
  7046. /*
  7047. Function: Command_PetOptions()
  7048. Purpose : Sets various pet options
  7049. Params :
  7050. Dev :
  7051. Example :
  7052. */
  7053. void Commands::Command_PetOptions(Client* client, Seperator* sep)
  7054. {
  7055. PrintSep(sep, "COMMAND_PETOPTIONS");
  7056. Player* player = client->GetPlayer();
  7057. Spawn* target = player->GetTarget();
  7058. if (!target)
  7059. return;
  7060. if (target == player->GetPet())
  7061. client->SendPetOptionsWindow(player->GetPet()->GetName());
  7062. else if (target == player->GetCharmedPet())
  7063. client->SendPetOptionsWindow(player->GetCharmedPet()->GetName());
  7064. else if (target == player->GetCosmeticPet())
  7065. client->SendPetOptionsWindow(player->GetCosmeticPet()->GetName(), 0);
  7066. else if (target == player->GetDeityPet())
  7067. client->SendPetOptionsWindow(player->GetDeityPet()->GetName(), 0);
  7068. }
  7069. /*
  7070. Function: Command_Random()
  7071. Purpose : Handles /random dice roll in-game
  7072. Params : 1-100
  7073. Dev : Scatman
  7074. Example : /randon 1 100
  7075. */
  7076. void Commands::Command_Random(Client* client, Seperator* sep)
  7077. {
  7078. char message[256] = {0};
  7079. if (sep)
  7080. {
  7081. if (sep->GetArgNumber() == 0 && sep->IsNumber(0))
  7082. 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])));
  7083. else if (sep->GetArgNumber() > 0 && sep->IsNumber(0) && sep->IsNumber(1))
  7084. 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])));
  7085. else
  7086. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  7087. }
  7088. else
  7089. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  7090. client->GetPlayer()->GetZone()->HandleChatMessage(0, 0, CHANNEL_EMOTE, message);
  7091. }
  7092. /*
  7093. Function: Command_Randomize()
  7094. Purpose : Sets randomize (appearance) values for NPCs
  7095. Params : Attrib Name
  7096. Dev : Scatman
  7097. Example : /randomize gender 1 -- will randomize the NPCs gender (male/female)
  7098. */
  7099. void Commands::Command_Randomize(Client* client, Seperator* sep)
  7100. {
  7101. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  7102. if (target)
  7103. {
  7104. if (target->IsNPC())
  7105. {
  7106. if (sep && sep->arg[0] && !sep->IsNumber(0))
  7107. {
  7108. const char* value = sep->arg[0];
  7109. if (strncasecmp(value, "show", strlen(value)) == 0)
  7110. {
  7111. client->DisplayRandomizeFeatures(target->GetRandomize());
  7112. }
  7113. else
  7114. {
  7115. if (sep->arg[1] && sep->IsNumber(1))
  7116. {
  7117. int8 option = atoi(sep->arg[1]);
  7118. if (option == 0 || option == 1)
  7119. {
  7120. int32 feature = 0;
  7121. char feature_text[32] = {0};
  7122. if (strncasecmp(value, "gender", strlen(value)) == 0) {
  7123. feature = RANDOMIZE_GENDER;
  7124. strncpy(feature_text, "gender", sizeof(feature_text) - 1);
  7125. }
  7126. else if (strncasecmp(value, "race", strlen(value)) == 0) {
  7127. feature = RANDOMIZE_RACE;
  7128. strncpy(feature_text, "race", sizeof(feature_text) - 1);
  7129. }
  7130. else if (strncasecmp(value, "model", strlen(value)) == 0) {
  7131. feature = RANDOMIZE_MODEL_TYPE;
  7132. strncpy(feature_text, "model", sizeof(feature_text) - 1);
  7133. }
  7134. else if (strncasecmp(value, "facial_hair", strlen(value)) == 0) {
  7135. feature = RANDOMIZE_FACIAL_HAIR_TYPE;
  7136. strncpy(feature_text, "facial hair", sizeof(feature_text) - 1);
  7137. }
  7138. else if (strncasecmp(value, "hair", strlen(value)) == 0) {
  7139. feature = RANDOMIZE_HAIR_TYPE;
  7140. strncpy(feature_text, "hair", sizeof(feature_text) - 1);
  7141. }
  7142. else if (strncasecmp(value, "wing", strlen(value)) == 0) {
  7143. feature = RANDOMIZE_WING_TYPE;
  7144. strncpy(feature_text, "wings", sizeof(feature_text) - 1);
  7145. }
  7146. else if (strncasecmp(value, "cheek", strlen(value)) == 0) {
  7147. feature = RANDOMIZE_CHEEK_TYPE;
  7148. strncpy(feature_text, "cheeks", sizeof(feature_text) - 1);
  7149. }
  7150. else if (strncasecmp(value, "chin", strlen(value)) == 0) {
  7151. feature = RANDOMIZE_CHIN_TYPE;
  7152. strncpy(feature_text, "chin", sizeof(feature_text) - 1);
  7153. }
  7154. else if (strncasecmp(value, "ear", strlen(value)) == 0) {
  7155. feature = RANDOMIZE_EAR_TYPE;
  7156. strncpy(feature_text, "ears", sizeof(feature_text) - 1);
  7157. }
  7158. else if (strncasecmp(value, "eye_brow", strlen(value)) == 0) {
  7159. feature = RANDOMIZE_EYE_BROW_TYPE;
  7160. strncpy(feature_text, "eye brows", sizeof(feature_text) - 1);
  7161. }
  7162. else if (strncasecmp(value, "eye", strlen(value)) == 0) {
  7163. feature = RANDOMIZE_EYE_TYPE;
  7164. strncpy(feature_text, "eyes", sizeof(feature_text) - 1);
  7165. }
  7166. else if (strncasecmp(value, "lip", strlen(value)) == 0) {
  7167. feature = RANDOMIZE_LIP_TYPE;
  7168. strncpy(feature_text, "lips", sizeof(feature_text) - 1);
  7169. }
  7170. else if (strncasecmp(value, "nose", strlen(value)) == 0) {
  7171. feature = RANDOMIZE_NOSE_TYPE;
  7172. strncpy(feature_text, "nose", sizeof(feature_text) - 1);
  7173. }
  7174. else if (strncasecmp(value, "eye_color", strlen(value)) == 0) {
  7175. feature = RANDOMIZE_EYE_COLOR;
  7176. strncpy(feature_text, "eye color", sizeof(feature_text) - 1);
  7177. }
  7178. else if (strncasecmp(value, "hair_color", strlen(value)) == 0) {
  7179. feature = RANDOMIZE_HAIR_TYPE_COLOR;
  7180. strncpy(feature_text, "hair color", sizeof(feature_text) - 1);
  7181. }
  7182. else if (strncasecmp(value, "hair_color1", strlen(value)) == 0) {
  7183. feature = RANDOMIZE_HAIR_COLOR1;
  7184. strncpy(feature_text, "hair color1", sizeof(feature_text) - 1);
  7185. }
  7186. else if (strncasecmp(value, "hair_color2", strlen(value)) == 0) {
  7187. feature = RANDOMIZE_HAIR_COLOR2;
  7188. strncpy(feature_text, "hair color2", sizeof(feature_text) - 1);
  7189. }
  7190. else if (strncasecmp(value, "hair_highlight", strlen(value)) == 0) {
  7191. feature = RANDOMIZE_HAIR_HIGHLIGHT;
  7192. strncpy(feature_text, "hair highlights", sizeof(feature_text) - 1);
  7193. }
  7194. else if (strncasecmp(value, "facial_hair_color", strlen(value)) == 0) {
  7195. feature = RANDOMIZE_HAIR_FACE_COLOR;
  7196. strncpy(feature_text, "facial hair color", sizeof(feature_text) - 1);
  7197. }
  7198. else if (strncasecmp(value, "facial_hair_color_highlight", strlen(value)) == 0) {
  7199. feature = RANDOMIZE_HAIR_FACE_HIGHLIGHT_COLOR;
  7200. strncpy(feature_text, "facial hair color highlights", sizeof(feature_text) - 1);
  7201. }
  7202. else if (strncasecmp(value, "hair_color_highlight", strlen(value)) == 0) {
  7203. feature = RANDOMIZE_HAIR_TYPE_HIGHLIGHT_COLOR;
  7204. strncpy(feature_text, "hair color highlights", sizeof(feature_text) - 1);
  7205. }
  7206. else if (strncasecmp(value, "skin_color", strlen(value)) == 0) {
  7207. feature = RANDOMIZE_SKIN_COLOR;
  7208. strncpy(feature_text, "skin color", sizeof(feature_text) - 1);
  7209. }
  7210. else if (strncasecmp(value, "wing_color1", strlen(value)) == 0) {
  7211. feature = RANDOMIZE_WING_COLOR1;
  7212. strncpy(feature_text, "wing color1", sizeof(feature_text) - 1);
  7213. }
  7214. else if (strncasecmp(value, "wing_color2", strlen(value)) == 0) {
  7215. feature = RANDOMIZE_WING_COLOR2;
  7216. strncpy(feature_text, "wing color2", sizeof(feature_text) - 1);
  7217. }
  7218. else {
  7219. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is not a valid feature to randomize.", value);
  7220. 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'.");
  7221. }
  7222. if (feature > 0) {
  7223. if (option == 1) {
  7224. if (target->GetRandomize() & feature)
  7225. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is already set to randomly generate their %s.", target->GetName(), feature_text);
  7226. else {
  7227. target->AddRandomize(feature);
  7228. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(feature);
  7229. database.UpdateRandomize(target->GetDatabaseID(), feature);
  7230. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will now generate their %s randomly.", target->GetName(), feature_text);
  7231. }
  7232. }
  7233. else {
  7234. if (target->GetRandomize() & feature) {
  7235. target->AddRandomize(-feature);
  7236. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(-feature);
  7237. database.UpdateRandomize(target->GetDatabaseID(), -feature);
  7238. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will no longer generate their %s randomly.", target->GetName(), feature_text);
  7239. }
  7240. else
  7241. client->Message(CHANNEL_COLOR_YELLOW, "'%s' already does not randomly generate their %s.", target->GetName(), feature_text);
  7242. }
  7243. }
  7244. }
  7245. else
  7246. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  7247. }
  7248. else
  7249. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  7250. }
  7251. }
  7252. else {
  7253. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /randomize [show | [feature [1|0]]");
  7254. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "'show' will display current configured features");
  7255. 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'.");
  7256. }
  7257. }
  7258. else
  7259. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "The target you wish to randomize must be an NPC.");
  7260. }
  7261. else
  7262. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select the target you wish to randomize.");
  7263. }
  7264. /*
  7265. Function: Command_ShowCloak()
  7266. Purpose : Character Settings combo box for Show Cloak
  7267. Params : true/false
  7268. Dev : John Adams
  7269. Example :
  7270. */
  7271. void Commands::Command_ShowCloak(Client* client, Seperator* sep)
  7272. {
  7273. Player* player = client->GetPlayer();
  7274. if (sep && sep->arg[0])
  7275. {
  7276. const char* value = sep->arg[0];
  7277. if (strncasecmp(value, "true", strlen(value)) == 0)
  7278. {
  7279. player->set_character_flag(CF_SHOW_CLOAK);
  7280. player->reset_character_flag(CF2_SHOW_RANGED);
  7281. }
  7282. else if (strncasecmp(value, "false", strlen(value)) == 0)
  7283. player->reset_character_flag(CF_SHOW_CLOAK);
  7284. else
  7285. {
  7286. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7287. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7288. }
  7289. }
  7290. }
  7291. /*
  7292. Function: Command_ShowHelm()
  7293. Purpose : Character Settings combo box for Show Helm
  7294. Params : true/false
  7295. Dev : John Adams
  7296. Example :
  7297. */
  7298. void Commands::Command_ShowHelm(Client* client, Seperator* sep)
  7299. {
  7300. Player* player = client->GetPlayer();
  7301. if (sep && sep->arg[0])
  7302. {
  7303. const char* value = sep->arg[0];
  7304. if (strncasecmp(value, "true", strlen(value)) == 0)
  7305. {
  7306. player->reset_character_flag(CF_HIDE_HELM);
  7307. player->set_character_flag(CF_HIDE_HOOD);
  7308. }
  7309. else if (strncasecmp(value, "false", strlen(value)) == 0)
  7310. player->set_character_flag(CF_HIDE_HELM);
  7311. else
  7312. {
  7313. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7314. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7315. }
  7316. }
  7317. }
  7318. /*
  7319. Function: Command_ShowHood()
  7320. Purpose : Character Settings combo box for Show Hood
  7321. Params : true/false
  7322. Dev : John Adams
  7323. Example :
  7324. */
  7325. void Commands::Command_ShowHood(Client* client, Seperator* sep)
  7326. {
  7327. Player* player = client->GetPlayer();
  7328. if (sep && sep->arg[0])
  7329. {
  7330. const char* value = sep->arg[0];
  7331. if (strncasecmp(value, "true", strlen(value)) == 0)
  7332. {
  7333. player->reset_character_flag(CF_HIDE_HOOD);
  7334. player->set_character_flag(CF_HIDE_HELM);
  7335. }
  7336. else if (strncasecmp(value, "false", strlen(value)) == 0)
  7337. player->set_character_flag(CF_HIDE_HOOD);
  7338. else
  7339. {
  7340. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7341. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7342. }
  7343. }
  7344. }
  7345. /*
  7346. Function: Command_ShowHoodHelm()
  7347. Purpose : Character Settings combo box for Show Helm or Hood
  7348. Params : true/false
  7349. Dev : John Adams
  7350. Example :
  7351. */
  7352. void Commands::Command_ShowHoodHelm(Client* client, Seperator* sep)
  7353. {
  7354. Player* player = client->GetPlayer();
  7355. if (sep && sep->arg[0])
  7356. {
  7357. const char* value = sep->arg[0];
  7358. if (strncasecmp(value, "true", strlen(value)) == 0)
  7359. {
  7360. player->reset_character_flag(CF_HIDE_HOOD);
  7361. player->reset_character_flag(CF_HIDE_HELM);
  7362. }
  7363. else if (strncasecmp(value, "false", strlen(value)) == 0)
  7364. {
  7365. // don't think we ever wind up in here...
  7366. player->set_character_flag(CF_HIDE_HOOD);
  7367. player->set_character_flag(CF_HIDE_HELM);
  7368. }
  7369. else
  7370. {
  7371. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7372. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7373. }
  7374. }
  7375. }
  7376. /*
  7377. Function: Command_ShowRanged()
  7378. Purpose : Character Settings combo box for Show Ranged weapon
  7379. Params : true/false
  7380. Dev : John Adams
  7381. Example :
  7382. */
  7383. void Commands::Command_ShowRanged(Client* client, Seperator* sep)
  7384. {
  7385. Player* player = client->GetPlayer();
  7386. if (sep && sep->arg[0])
  7387. {
  7388. const char* value = sep->arg[0];
  7389. if (strncasecmp(value, "true", strlen(value)) == 0)
  7390. {
  7391. player->set_character_flag(CF2_SHOW_RANGED);
  7392. player->reset_character_flag(CF_SHOW_CLOAK);
  7393. }
  7394. else if (strncasecmp(value, "false", strlen(value)) == 0)
  7395. player->reset_character_flag(CF2_SHOW_RANGED);
  7396. else
  7397. {
  7398. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7399. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7400. }
  7401. }
  7402. }
  7403. /*
  7404. Function:
  7405. Purpose :
  7406. Params :
  7407. Dev :
  7408. Example :
  7409. */
  7410. void Commands::Command_Skills(Client* client, Seperator* sep, int handler)
  7411. {
  7412. Player* player = 0;
  7413. Client* to_client = 0;
  7414. if(client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  7415. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  7416. switch(handler)
  7417. {
  7418. case COMMAND_SKILL:
  7419. {
  7420. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill [add|remove|list] [skill name]");
  7421. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to add/remove skills for that player.");
  7422. break;
  7423. }
  7424. case COMMAND_SKILL_ADD:
  7425. {
  7426. if (sep && sep->arg[0])
  7427. {
  7428. const char* skill_name = sep->argplus[0];
  7429. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  7430. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // add skill to your target, if target is not you
  7431. {
  7432. player = to_client->GetPlayer();
  7433. if (player)
  7434. {
  7435. if (!player->GetSkills()->HasSkill(skill->skill_id))
  7436. {
  7437. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  7438. client->Message(CHANNEL_COLOR_YELLOW, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  7439. to_client->Message(CHANNEL_COLOR_YELLOW, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  7440. }
  7441. else
  7442. client->Message(CHANNEL_COLOR_YELLOW, "%s already has the skill '%s'.", player->GetName(), skill_name);
  7443. }
  7444. }
  7445. else if (skill) // add skill to yourself
  7446. {
  7447. player = client->GetPlayer();
  7448. if (player)
  7449. {
  7450. if (!player->GetSkills()->HasSkill(skill->skill_id))
  7451. {
  7452. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  7453. client->Message(CHANNEL_COLOR_YELLOW, "Added skill '%s'.", skill_name);
  7454. }
  7455. else
  7456. client->Message(CHANNEL_COLOR_YELLOW, "You already have the skill '%s'.", skill_name);
  7457. }
  7458. }
  7459. else
  7460. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  7461. }
  7462. else
  7463. {
  7464. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill add [skill name]");
  7465. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  7466. }
  7467. break;
  7468. }
  7469. case COMMAND_SKILL_REMOVE:
  7470. {
  7471. if (sep && sep->arg[0])
  7472. {
  7473. const char* skill_name = sep->argplus[0];
  7474. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  7475. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // remove skill from your target, if target is not you
  7476. {
  7477. player = to_client->GetPlayer();
  7478. if (player)
  7479. {
  7480. if (player->GetSkills()->HasSkill(skill->skill_id))
  7481. {
  7482. player->RemoveSkillFromDB(skill, true);
  7483. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  7484. to_client->Message(CHANNEL_COLOR_YELLOW, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  7485. }
  7486. else
  7487. client->Message(CHANNEL_COLOR_YELLOW, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  7488. }
  7489. }
  7490. else if(skill) // remove skill from yourself
  7491. {
  7492. Player* player = client->GetPlayer();
  7493. if (player)
  7494. {
  7495. if (player->GetSkills()->HasSkill(skill->skill_id))
  7496. {
  7497. player->RemoveSkillFromDB(skill, true);
  7498. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s'.", skill_name);
  7499. }
  7500. else
  7501. client->Message(CHANNEL_COLOR_YELLOW, "You do not have the skill '%s'.", skill_name);
  7502. }
  7503. }
  7504. else
  7505. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  7506. }
  7507. else
  7508. {
  7509. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill remove [skill name]");
  7510. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  7511. }
  7512. break;
  7513. }
  7514. case COMMAND_SKILL_LIST:
  7515. {
  7516. if (sep && sep->arg[0])
  7517. {
  7518. const char* skill_name = sep->argplus[0];
  7519. client->Message(CHANNEL_COLOR_YELLOW, "Listing skills like '%s':", skill_name);
  7520. map<int32, Skill*>* skills = master_skill_list.GetAllSkills();
  7521. map<int32, Skill*>::iterator itr;
  7522. if (skills && skills->size() > 0)
  7523. {
  7524. for (itr = skills->begin(); itr != skills->end(); itr++)
  7525. {
  7526. Skill* skill = itr->second;
  7527. string current_skill_name = ::ToLower(string(skill->name.data.c_str()));
  7528. if (current_skill_name.find(::ToLower(string(skill_name))) < 0xFFFFFFFF)
  7529. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", skill->name.data.c_str(), skill->skill_id);
  7530. }
  7531. }
  7532. }
  7533. else
  7534. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill list [skill name]");
  7535. break;
  7536. }
  7537. }
  7538. }
  7539. /*
  7540. Function: Command_SpawnTemplate()
  7541. Purpose : Create or Use defined Spawn Templates
  7542. Params : create, save, rempve, list
  7543. Dev : John Adams
  7544. Example : /spawn template create "Test"
  7545. */
  7546. void Commands::Command_SpawnTemplate(Client* client, Seperator* sep)
  7547. {
  7548. if (sep == NULL || sep->arg[0] == NULL)
  7549. {
  7550. 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.");
  7551. return;
  7552. }
  7553. // got params, continue
  7554. const char * template_cmd = sep->arg[0];
  7555. if (strncasecmp(template_cmd, "list", strlen(template_cmd)) == 0)
  7556. {
  7557. if (!sep->IsSet(1))
  7558. {
  7559. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /spawn template list [name|location_id]");
  7560. 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.");
  7561. return;
  7562. }
  7563. map<int32, string>* template_names = 0;
  7564. if (sep->IsNumber(1))
  7565. {
  7566. int32 location_id = 0;
  7567. location_id = atoi(sep->arg[1]);
  7568. template_names = database.GetSpawnTemplateListByID(location_id);
  7569. }
  7570. else
  7571. {
  7572. const char* name = 0;
  7573. name = sep->argplus[1];
  7574. template_names = database.GetSpawnTemplateListByName(name);
  7575. }
  7576. if(!template_names)
  7577. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No templates found.");
  7578. else
  7579. {
  7580. map<int32, string>::iterator itr;
  7581. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  7582. for(itr = template_names->begin(); itr != template_names->end(); itr++)
  7583. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  7584. safe_delete(template_names);
  7585. }
  7586. }
  7587. else if (strncasecmp(template_cmd, "save", strlen(template_cmd)) == 0)
  7588. {
  7589. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  7590. if ( target && (target->IsNPC() || target->IsObject() || target->IsSign() || target->IsWidget() || target->IsGroundSpawn()) )
  7591. {
  7592. if (sep && sep->arg[1][0] && !sep->IsNumber(1))
  7593. {
  7594. // first, lookup to see if template name already exists
  7595. const char* name = 0;
  7596. name = sep->argplus[1];
  7597. map<int32, string>* template_names = database.GetSpawnTemplateListByName(name);
  7598. if(!template_names)
  7599. {
  7600. int32 new_template_id = database.SaveSpawnTemplate(target->GetSpawnLocationID(), name);
  7601. if( new_template_id > 0 )
  7602. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template '%s' added for spawn '%s' (%u) as TemplateID: %u", name, target->GetName(), target->GetSpawnLocationID(), new_template_id);
  7603. else
  7604. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' for spawn '%s' (%u).", name, target->GetName(), target->GetSpawnLocationID());
  7605. }
  7606. else
  7607. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' - Already exists!", name);
  7608. }
  7609. else
  7610. client->Message(CHANNEL_COLOR_RED, "ERROR: Saving a new spawn template requires a valid template name!");
  7611. }
  7612. else
  7613. client->Message(CHANNEL_COLOR_RED, "ERROR: You must target the spawn you wish to save as a template!");
  7614. }
  7615. else if (strncasecmp(template_cmd, "remove", strlen(template_cmd)) == 0)
  7616. {
  7617. if (sep && sep->arg[1][0] && sep->IsNumber(1))
  7618. {
  7619. int32 template_id = 0;
  7620. template_id = atoi(sep->arg[1]);
  7621. if (database.RemoveSpawnTemplate(template_id))
  7622. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template ID: %u successfully removed.", template_id);
  7623. else
  7624. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to remove spawn template ID: %u", template_id);
  7625. }
  7626. else
  7627. client->Message(CHANNEL_COLOR_RED, "ERROR: Removing a spawn template requires a valid template ID!");
  7628. }
  7629. // Renamed create to spawn
  7630. else if (strncasecmp(template_cmd, "spawn", strlen(template_cmd)) == 0)
  7631. {
  7632. if (sep && sep->arg[1][0])
  7633. {
  7634. int32 new_location = 0;
  7635. if (sep->IsNumber(1))
  7636. {
  7637. int32 template_id = 0;
  7638. template_id = atoi(sep->arg[1]);
  7639. new_location = database.CreateSpawnFromTemplateByID(client, template_id);
  7640. if( new_location > 0 )
  7641. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template ID: %u", new_location, template_id);
  7642. else
  7643. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template ID: %u", template_id);
  7644. }
  7645. else
  7646. {
  7647. const char* name = 0;
  7648. name = sep->argplus[1];
  7649. new_location = database.CreateSpawnFromTemplateByName(client, name);
  7650. if( new_location > 0 )
  7651. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template: '%s'", new_location, name);
  7652. else
  7653. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template: '%s'", name);
  7654. }
  7655. }
  7656. else
  7657. client->Message(CHANNEL_COLOR_RED, "ERROR: Spawning a new spawn location requires a valid template name or ID!");
  7658. }
  7659. else
  7660. client->Message(CHANNEL_COLOR_RED, "ERROR: Unknown /spawn template command.");
  7661. }
  7662. void Commands::Command_Speed(Client* client, Seperator* sep) {
  7663. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  7664. float new_speed = atof(sep->arg[0]);
  7665. if (new_speed > 0.0f)
  7666. {
  7667. client->GetPlayer()->SetSpeed(new_speed, true);
  7668. client->GetPlayer()->SetCharSheetChanged(true);
  7669. database.insertCharacterProperty(client, CHAR_PROPERTY_SPEED, sep->arg[0]);
  7670. client->Message(CHANNEL_STATUS, "Setting speed to %.2f.", new_speed);
  7671. }
  7672. else
  7673. client->Message(CHANNEL_STATUS, "Invalid speed provided %s.", sep->arg[0]);
  7674. }
  7675. else{
  7676. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /speed {new speed value}");
  7677. }
  7678. }
  7679. /*
  7680. Function: Command_StationMarketPlace()
  7681. Purpose : just trying to eat the console spam for now
  7682. Params :
  7683. Dev : John
  7684. */
  7685. void Commands::Command_StationMarketPlace(Client* client, Seperator* sep)
  7686. {
  7687. PrintSep(sep, "COMMAND_SMP");
  7688. // This will reduce the spam from once every 10 sec to once every 30 sec,
  7689. // can't seem to reduce it any more get rid of it completely...
  7690. if (sep && strcmp(sep->arg[0], "gkw") == 0) {
  7691. PacketStruct* packet = configReader.getStruct("WS_MarketFundsUpdate", client->GetVersion());
  7692. if (packet) {
  7693. packet->setDataByName("account_id", client->GetAccountID());
  7694. packet->setDataByName("character_id", client->GetCharacterID());
  7695. packet->setDataByName("unknown1", 1, 5);
  7696. packet->setDataByName("unknown1", 26, 6);
  7697. packet->setDataByName("unknown2", 0xFFFFFFFF);
  7698. packet->setDataByName("unknown3", 248, 1);
  7699. client->QueuePacket(packet->serialize());
  7700. }
  7701. safe_delete(packet);
  7702. }
  7703. }
  7704. /*
  7705. Function: Command_StopDrinking()
  7706. Purpose : Stops player from auto-consuming drink
  7707. Params :
  7708. Dev : Zcoretri
  7709. Example : /stopdrinking
  7710. */
  7711. void Commands::Command_StopDrinking(Client* client)
  7712. {
  7713. client->GetPlayer()->reset_character_flag(CF_DRINK_AUTO_CONSUME);
  7714. client->Message(CHANNEL_COLOR_YELLOW,"You stop drinking your current drink.");
  7715. }
  7716. /*
  7717. Function: Command_StopEating()
  7718. Purpose : Stops player from auto-consuming food
  7719. Params :
  7720. Dev : Zcoretri
  7721. Example : /stopeating
  7722. */
  7723. void Commands::Command_StopEating(Client* client)
  7724. {
  7725. client->GetPlayer()->reset_character_flag(CF_FOOD_AUTO_CONSUME);
  7726. client->Message(CHANNEL_COLOR_YELLOW,"You stop eating your current food.");
  7727. }
  7728. /*
  7729. Function: Command_Title()
  7730. Purpose : Help for /title command
  7731. Params : n/a
  7732. Dev : Zcoretri
  7733. Example : /title
  7734. */
  7735. void Commands::Command_Title(Client* client)
  7736. {
  7737. client->Message(CHANNEL_COLOR_YELLOW, "Available subcommands: list, setprefix <index>, setsuffix <index>, fix");
  7738. }
  7739. /*
  7740. Function: Command_TitleList()
  7741. Purpose : List available titles for player
  7742. Params : n/a
  7743. Dev : Zcoretri
  7744. Example : /title list
  7745. */
  7746. void Commands::Command_TitleList(Client* client)
  7747. {
  7748. // must call release read lock before leaving function on GetPlayerTitles
  7749. vector<Title*>* titles = client->GetPlayer()->GetPlayerTitles()->GetAllTitles();
  7750. vector<Title*>::iterator itr;
  7751. Title* title;
  7752. sint32 i = 0;
  7753. client->Message(CHANNEL_NARRATIVE, "Listing available titles:");
  7754. for(itr = titles->begin(); itr != titles->end(); itr++)
  7755. {
  7756. title = *itr;
  7757. client->Message(CHANNEL_NARRATIVE, "%i: type=[%s] title=[%s]", i, title->GetPrefix() ? "Prefix":"Suffix", title->GetName());
  7758. i++;
  7759. }
  7760. client->GetPlayer()->GetPlayerTitles()->ReleaseReadLock();
  7761. }
  7762. /*
  7763. Function: Command_TitleSetPrefix()
  7764. Purpose : Set Prefix title for player
  7765. Params : Title ID
  7766. Dev : Zcoretri
  7767. Example : /title setprefix 1
  7768. */
  7769. void Commands::Command_TitleSetPrefix(Client* client, Seperator* sep)
  7770. {
  7771. if (sep && sep->arg[0] && sep->IsNumber(0))
  7772. {
  7773. sint32 index = atoul(sep->arg[0]);
  7774. if(index > -1)
  7775. {
  7776. Title* title = client->GetPlayer()->GetPlayerTitles()->GetTitle(index);
  7777. if(!title)
  7778. {
  7779. client->Message(CHANNEL_COLOR_RED, "Missing index %i to set title", index);
  7780. return;
  7781. }
  7782. else if(!title->GetPrefix())
  7783. {
  7784. client->Message(CHANNEL_COLOR_RED, "%s is not a prefix.", title->GetName());
  7785. return;
  7786. }
  7787. }
  7788. else // make sure client doesn't pass some bogus negative index
  7789. index = -1;
  7790. database.SaveCharPrefixIndex(index, client->GetCharacterID());
  7791. client->SendTitleUpdate();
  7792. }
  7793. }
  7794. /*
  7795. Function: Command_TitleSetSuffix()
  7796. Purpose : Set Suffix title for player
  7797. Params : Title ID
  7798. Dev : Zcoretri
  7799. Example : /title setsuffix 1
  7800. */
  7801. void Commands::Command_TitleSetSuffix(Client* client, Seperator* sep)
  7802. {
  7803. if (sep && sep->arg[0] && sep->IsNumber(0))
  7804. {
  7805. sint32 index = atoul(sep->arg[0]);
  7806. if(index > -1)
  7807. {
  7808. Title* title = client->GetPlayer()->GetPlayerTitles()->GetTitle(index);
  7809. if(!title)
  7810. {
  7811. client->Message(CHANNEL_COLOR_RED, "Missing index %i to set title", index);
  7812. return;
  7813. }
  7814. else if(title->GetPrefix())
  7815. {
  7816. client->Message(CHANNEL_COLOR_RED, "%s is not a suffix.", title->GetName());
  7817. return;
  7818. }
  7819. }
  7820. else // make sure client doesn't pass some bogus negative index
  7821. index = -1;
  7822. database.SaveCharSuffixIndex(index, client->GetCharacterID());
  7823. client->SendTitleUpdate();
  7824. }
  7825. }
  7826. /*
  7827. Function: Command_TitleFix()
  7828. Purpose : Fix title for player (???)
  7829. Params :
  7830. Dev : Zcoretri
  7831. Example :
  7832. */
  7833. void Commands::Command_TitleFix(Client* client, Seperator* sep)
  7834. {
  7835. PrintSep(sep, "COMMAND_TITLE_FIX");
  7836. LogWrite(MISC__TODO, 1, "Titles", "TODO-Command: TITLE_FIX");
  7837. }
  7838. /*
  7839. Function: Command_Toggle_Anonymous()
  7840. Purpose : Toggles player Anonymous
  7841. Params :
  7842. Dev : paulgh
  7843. Example : /anon
  7844. */
  7845. void Commands::Command_Toggle_Anonymous(Client* client)
  7846. {
  7847. Player* player = client->GetPlayer();
  7848. player->toggle_character_flag(CF_ANONYMOUS);
  7849. client->Message(CHANNEL_COLOR_YELLOW,"You are %s anonymous.", player->get_character_flag(CF_ANONYMOUS)?"now":"no longer");
  7850. if (player->get_character_flag(CF_ANONYMOUS))
  7851. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ANONYMOUS);
  7852. else
  7853. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ANONYMOUS);
  7854. }
  7855. /*
  7856. Function: Command_Toggle_AutoConsume()
  7857. Purpose : Toggles player food/drink auto consume
  7858. Params : unknown
  7859. Dev : paulgh
  7860. Example : /set_auto_consume
  7861. */
  7862. void Commands::Command_Toggle_AutoConsume(Client* client, Seperator* sep)
  7863. {
  7864. Player* player = client->GetPlayer();
  7865. if (sep && sep->arg[0])
  7866. PrintSep(sep, "COMMAND_SET_AUTO_CONSUME");
  7867. if (sep && sep->arg[0] && sep->IsNumber(0))
  7868. {
  7869. int8 slot = atoi(sep->arg[0]);
  7870. int8 flag = atoi(sep->arg[1]);
  7871. if (client->GetVersion() <= 283) {
  7872. slot += 4;
  7873. }
  7874. else if (client->GetVersion() <= 546) {
  7875. slot += 2;
  7876. }
  7877. if (slot == EQ2_FOOD_SLOT)
  7878. {
  7879. player->toggle_character_flag(CF_FOOD_AUTO_CONSUME);
  7880. player->SetCharSheetChanged(true);
  7881. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  7882. if (flag == 1)
  7883. client->Message(CHANNEL_NARRATIVE, "You decide to eat immediately whenever you become hungry.");
  7884. else
  7885. {
  7886. client->Message(CHANNEL_NARRATIVE, "You decide to ignore the hunger.");
  7887. return;
  7888. }
  7889. }
  7890. else
  7891. {
  7892. player->toggle_character_flag(CF_DRINK_AUTO_CONSUME);
  7893. player->SetCharSheetChanged(true);
  7894. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  7895. if (flag == 1)
  7896. client->Message(CHANNEL_NARRATIVE, "You decide to drink immediately whenever you become thirsty.");
  7897. else
  7898. {
  7899. client->Message(CHANNEL_NARRATIVE, "You decide to ignore the thirst.");
  7900. return;
  7901. }
  7902. }
  7903. if(slot == 22 && player->GetSpellEffectBySpellType(SPELL_TYPE_FOOD))
  7904. return;
  7905. else if (player->GetSpellEffectBySpellType(SPELL_TYPE_DRINK))
  7906. return;
  7907. Item* item = player->GetEquipmentList()->GetItem(slot);
  7908. if(item)
  7909. client->ConsumeFoodDrink(item, slot);
  7910. }
  7911. }
  7912. /*
  7913. Function: Command_Toggle_BonusXP()
  7914. Purpose : Toggles player Bonus XP
  7915. Params :
  7916. Dev : John Adams
  7917. Example : /disable_char_bonus_exp
  7918. */
  7919. void Commands::Command_Toggle_BonusXP(Client* client)
  7920. {
  7921. Player* player = client->GetPlayer();
  7922. player->toggle_character_flag(CF2_CHARACTER_BONUS_EXPERIENCE_ENABLED);
  7923. player->SetCharSheetChanged(true);
  7924. }
  7925. /*
  7926. Function: Command_Toggle_CombatXP()
  7927. Purpose : Toggles player Adventure XP
  7928. Params :
  7929. Dev : John Adams
  7930. Example : /disable_combat_exp
  7931. */
  7932. void Commands::Command_Toggle_CombatXP(Client* client)
  7933. {
  7934. Player* player = client->GetPlayer();
  7935. player->toggle_character_flag(CF_COMBAT_EXPERIENCE_ENABLED);
  7936. player->SetCharSheetChanged(true);
  7937. }
  7938. /*
  7939. Function: Command_Toggle_GMHide()
  7940. Purpose : Toggles hiding player GM status
  7941. Params :
  7942. Dev : Scatman
  7943. Example : /gm_hide
  7944. */
  7945. void Commands::Command_Toggle_GMHide(Client* client)
  7946. {
  7947. Player* player = client->GetPlayer();
  7948. player->toggle_character_flag(CF_HIDE_STATUS);
  7949. client->Message(CHANNEL_COLOR_YELLOW,"You are %s hiding your GM status.", player->get_character_flag(CF_HIDE_STATUS)?"now":"no longer");
  7950. }
  7951. /*
  7952. Function: Command_Toggle_GMVanish()
  7953. Purpose : Toggles hiding GM players from /who searches
  7954. Params :
  7955. Dev : Scatman
  7956. Example : /gm_vanish
  7957. */
  7958. void Commands::Command_Toggle_GMVanish(Client* client)
  7959. {
  7960. Player* player = client->GetPlayer();
  7961. player->toggle_character_flag(CF_GM_HIDDEN);
  7962. client->Message(CHANNEL_COLOR_YELLOW,"You are %s invisible to who queries.", player->get_character_flag(CF_GM_HIDDEN)?"now":"no longer");
  7963. }
  7964. /*
  7965. Function: Command_Toggle_Illusions()
  7966. Purpose : Toggles player illusion form
  7967. Params : not sure sep is needed, testing
  7968. Dev : paulgh
  7969. Example : /hide_illusions
  7970. */
  7971. void Commands::Command_Toggle_Illusions(Client* client, Seperator* sep)
  7972. {
  7973. if (sep && sep->arg[0])
  7974. PrintSep(sep, "COMMAND_TOGGLE_ILLUSIONS");
  7975. client->GetPlayer()->toggle_character_flag(CF_SHOW_ILLUSION);
  7976. }
  7977. /*
  7978. Function: Command_Toggle_LFG()
  7979. Purpose : Toggles player LFG Flag
  7980. Params :
  7981. Dev : paulgh
  7982. Example : /lfg
  7983. */
  7984. void Commands::Command_Toggle_LFG(Client* client)
  7985. {
  7986. Player* player = client->GetPlayer();
  7987. player->toggle_character_flag(CF_LFG);
  7988. client->Message(CHANNEL_COLOR_YELLOW,"You are %s LFG.", player->get_character_flag(CF_LFG)?"now":"no longer");
  7989. if (player->get_character_flag(CF_LFG))
  7990. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFG);
  7991. else
  7992. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFG);
  7993. }
  7994. /*
  7995. Function: Command_Toggle_LFW()
  7996. Purpose : Toggles player LFW Flag
  7997. Params :
  7998. Dev : paulgh
  7999. Example : /lfw
  8000. */
  8001. void Commands::Command_Toggle_LFW(Client* client)
  8002. {
  8003. Player* player = client->GetPlayer();
  8004. player->toggle_character_flag(CF_LFW);
  8005. client->Message(CHANNEL_COLOR_YELLOW,"You %s looking for work.", player->get_character_flag(CF_LFW)?"let others know you are":"stop");
  8006. if (player->get_character_flag(CF_LFW))
  8007. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFW);
  8008. else
  8009. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFW);
  8010. }
  8011. /*
  8012. Function: Command_Toggle_QuestXP()
  8013. Purpose : Toggles player Quest XP
  8014. Params :
  8015. Dev : John Adams
  8016. Example : /disable_quest_exp
  8017. */
  8018. void Commands::Command_Toggle_QuestXP(Client* client)
  8019. {
  8020. Player* player = client->GetPlayer();
  8021. player->toggle_character_flag(CF_QUEST_EXPERIENCE_ENABLED);
  8022. player->SetCharSheetChanged(true);
  8023. }
  8024. /*
  8025. Function: Command_Toggle_Roleplaying()
  8026. Purpose : Toggles player Roleplaying flag
  8027. Params :
  8028. Dev : paulgh
  8029. Example : /role
  8030. */
  8031. void Commands::Command_Toggle_Roleplaying(Client* client)
  8032. {
  8033. Player* player = client->GetPlayer();
  8034. player->toggle_character_flag(CF_ROLEPLAYING);
  8035. client->Message(CHANNEL_COLOR_YELLOW,"You are %s roleplaying.", player->get_character_flag(CF_ROLEPLAYING)?"now":"no longer");
  8036. if (player->get_character_flag(CF_ROLEPLAYING))
  8037. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ROLEPLAYING);
  8038. else
  8039. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ROLEPLAYING);
  8040. }
  8041. void Commands::Command_Toggle_Duels(Client* client)
  8042. {
  8043. Player* player = client->GetPlayer();
  8044. player->toggle_character_flag(CF_ALLOW_DUEL_INVITES);
  8045. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting duel invites.", player->get_character_flag(CF_ALLOW_DUEL_INVITES)?"now":"no longer");
  8046. }
  8047. void Commands::Command_Toggle_Trades(Client* client)
  8048. {
  8049. Player* player = client->GetPlayer();
  8050. player->toggle_character_flag(CF_ALLOW_TRADE_INVITES);
  8051. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting trade invites.", player->get_character_flag(CF_ALLOW_TRADE_INVITES)?"now":"no longer");
  8052. }
  8053. void Commands::Command_Toggle_Guilds(Client* client)
  8054. {
  8055. Player* player = client->GetPlayer();
  8056. player->toggle_character_flag(CF_ALLOW_GUILD_INVITES);
  8057. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting guild invites.", player->get_character_flag(CF_ALLOW_GUILD_INVITES)?"now":"no longer");
  8058. }
  8059. void Commands::Command_Toggle_Groups(Client* client)
  8060. {
  8061. Player* player = client->GetPlayer();
  8062. player->toggle_character_flag(CF_ALLOW_GROUP_INVITES);
  8063. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting group invites.", player->get_character_flag(CF_ALLOW_GROUP_INVITES)?"now":"no longer");
  8064. }
  8065. void Commands::Command_Toggle_Raids(Client* client)
  8066. {
  8067. Player* player = client->GetPlayer();
  8068. player->toggle_character_flag(CF_ALLOW_RAID_INVITES);
  8069. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting raid invites.", player->get_character_flag(CF_ALLOW_RAID_INVITES)?"now":"no longer");
  8070. }
  8071. void Commands::Command_Toggle_LON(Client* client)
  8072. {
  8073. Player* player = client->GetPlayer();
  8074. player->toggle_character_flag(CF2_ALLOW_LON_INVITES);
  8075. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting LoN invites.", player->get_character_flag(CF2_ALLOW_LON_INVITES)?"now":"no longer");
  8076. }
  8077. void Commands::Command_Toggle_VoiceChat(Client* client)
  8078. {
  8079. Player* player = client->GetPlayer();
  8080. player->toggle_character_flag(CF2_ALLOW_VOICE_INVITES);
  8081. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting voice chat invites.", player->get_character_flag(CF2_ALLOW_VOICE_INVITES)?"now":"no longer");
  8082. }
  8083. /*
  8084. Function: Command_TradeStart()
  8085. Purpose : Starts item/coin trade between players
  8086. Params :
  8087. Dev :
  8088. Example :
  8089. */
  8090. #include "../Trade.h"
  8091. void Commands::Command_TradeStart(Client* client, Seperator* sep)
  8092. {
  8093. PrintSep(sep, "COMMAND_START_TRADE");
  8094. Entity* trader = client->GetPlayer();
  8095. Entity* trader2 = 0;
  8096. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  8097. Spawn* spawn = client->GetPlayer()->GetSpawnWithPlayerID(atoi(sep->arg[0]));
  8098. if (spawn) {
  8099. if (spawn->IsEntity())
  8100. trader2 = (Entity*)spawn;
  8101. }
  8102. }
  8103. else if (client->GetPlayer()->GetTarget()) {
  8104. if (client->GetPlayer()->GetTarget()->IsEntity())
  8105. trader2 = (Entity*)client->GetPlayer()->GetTarget();
  8106. }
  8107. // can only trade with player or bots
  8108. if (trader && trader2) {
  8109. if (trader == trader2) {
  8110. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade with yourself.");
  8111. }
  8112. else if (trader2->IsPlayer() || trader2->IsBot()) {
  8113. LogWrite(PLAYER__ERROR, 0, "Trade", "creating trade");
  8114. if (trader->trade)
  8115. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are already trading.");
  8116. else if (trader2->trade)
  8117. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is already trading.");
  8118. else {
  8119. Trade* trade = new Trade(trader, trader2);
  8120. trader->trade = trade;
  8121. trader2->trade = trade;
  8122. }
  8123. }
  8124. else {
  8125. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can only trade with another player or a bot.");
  8126. }
  8127. }
  8128. else
  8129. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to find target");
  8130. }
  8131. /*
  8132. Function: Command_Track()
  8133. Purpose : Starts/Stops Tracking for a player
  8134. Params :
  8135. Dev : Scatman
  8136. Example : /track
  8137. */
  8138. void Commands::Command_Track(Client* client)
  8139. {
  8140. if (!client->GetPlayer()->GetIsTracking())
  8141. client->GetPlayer()->GetZone()->AddPlayerTracking(client->GetPlayer());
  8142. else
  8143. client->GetPlayer()->GetZone()->RemovePlayerTracking(client->GetPlayer(), TRACKING_STOP);
  8144. }
  8145. /*
  8146. Function: Command_TradeAccept()
  8147. Purpose : Accepts item/coin trade between players
  8148. Params :
  8149. Dev :
  8150. Example :
  8151. */
  8152. void Commands::Command_TradeAccept(Client* client, Seperator* sep)
  8153. {
  8154. PrintSep(sep, "COMMAND_ACCEPT_TRADE");
  8155. Trade* trade = client->GetPlayer()->trade;
  8156. if (trade) {
  8157. bool trade_complete = trade->SetTradeAccepted(client->GetPlayer());
  8158. if (trade_complete)
  8159. safe_delete(trade);
  8160. }
  8161. else
  8162. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8163. }
  8164. /*
  8165. Function: Command_TradeReject()
  8166. Purpose : Rejects item/coin trade between players
  8167. Params :
  8168. Dev :
  8169. Example :
  8170. */
  8171. void Commands::Command_TradeReject(Client* client, Seperator* sep)
  8172. {
  8173. PrintSep(sep, "COMMAND_REJECT_TRADE");
  8174. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Reject Player Trading");
  8175. client->Message(CHANNEL_COLOR_YELLOW, "You cannot trade with other players (Not Implemented)");
  8176. }
  8177. /*
  8178. Function: Command_TradeCancel()
  8179. Purpose : Cancels item/coin trade between players
  8180. Params :
  8181. Dev :
  8182. Example :
  8183. */
  8184. void Commands::Command_TradeCancel(Client* client, Seperator* sep)
  8185. {
  8186. PrintSep(sep, "COMMAND_CANCEL_TRADE");
  8187. Trade* trade = client->GetPlayer()->trade;
  8188. if (trade) {
  8189. trade->CancelTrade(client->GetPlayer());
  8190. safe_delete(trade);
  8191. }
  8192. else
  8193. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8194. }
  8195. /*
  8196. Function: Command_TradeSetCoin()
  8197. Purpose : Sets coin trade between players
  8198. Params :
  8199. Dev :
  8200. Example :
  8201. */
  8202. void Commands::Command_TradeSetCoin(Client* client, Seperator* sep)
  8203. {
  8204. PrintSep(sep, "COMMAND_SET_TRADE_COIN");
  8205. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Set Trade Coin");
  8206. client->Message(CHANNEL_COLOR_YELLOW, "You cannot trade with other players (Not Implemented)");
  8207. }
  8208. /*
  8209. Function: Command_TradeAddCoin()
  8210. Purpose : Adds coin to trade between players
  8211. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  8212. Dev :
  8213. Example :
  8214. */
  8215. void Commands::Command_TradeAddCoin(Client* client, Seperator* sep, int handler)
  8216. {
  8217. PrintSep(sep, "COMMAND_ADD_TRADE_{coin type}");
  8218. Trade* trade = client->GetPlayer()->trade;
  8219. if (trade) {
  8220. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  8221. int32 amount = atoi(sep->arg[0]);
  8222. int64 val = 0;
  8223. switch (handler) {
  8224. case COMMAND_ADD_TRADE_COPPER:
  8225. {
  8226. val = amount;
  8227. trade->AddCoinToTrade(client->GetPlayer(), val);
  8228. break;
  8229. }
  8230. case COMMAND_ADD_TRADE_SILVER:
  8231. {
  8232. val = amount * 100;
  8233. trade->AddCoinToTrade(client->GetPlayer(), val);
  8234. break;
  8235. }
  8236. case COMMAND_ADD_TRADE_GOLD:
  8237. {
  8238. val = amount * 10000;
  8239. trade->AddCoinToTrade(client->GetPlayer(), val);
  8240. break;
  8241. }
  8242. case COMMAND_ADD_TRADE_PLAT:
  8243. {
  8244. val = amount * 1000000;
  8245. trade->AddCoinToTrade(client->GetPlayer(), val);
  8246. break;
  8247. }
  8248. default:
  8249. {
  8250. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  8251. break;
  8252. }
  8253. }
  8254. }
  8255. else
  8256. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount.");
  8257. }
  8258. else
  8259. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8260. }
  8261. /*
  8262. Function: Command_TradeRemoveCoin()
  8263. Purpose : Removes coin from trade between players
  8264. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  8265. Dev :
  8266. Example :
  8267. */
  8268. void Commands::Command_TradeRemoveCoin(Client* client, Seperator* sep, int handler)
  8269. {
  8270. PrintSep(sep, "COMMAND_REMOVE_TRADE_{coin type}");
  8271. Trade* trade = client->GetPlayer()->trade;
  8272. if (trade) {
  8273. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  8274. int32 amount = atoi(sep->arg[0]);
  8275. int64 val = 0;
  8276. switch (handler) {
  8277. case COMMAND_REMOVE_TRADE_COPPER:
  8278. {
  8279. val = amount;
  8280. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  8281. break;
  8282. }
  8283. case COMMAND_REMOVE_TRADE_SILVER:
  8284. {
  8285. val = amount * 100;
  8286. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  8287. break;
  8288. }
  8289. case COMMAND_REMOVE_TRADE_GOLD:
  8290. {
  8291. val = amount * 10000;
  8292. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  8293. break;
  8294. }
  8295. case COMMAND_REMOVE_TRADE_PLAT:
  8296. {
  8297. val = amount * 1000000;
  8298. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  8299. break;
  8300. }
  8301. default:
  8302. {
  8303. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  8304. break;
  8305. }
  8306. }
  8307. }
  8308. else
  8309. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount");
  8310. }
  8311. else
  8312. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8313. }
  8314. /*
  8315. Function: Command_TradeAddItem()
  8316. Purpose : Adds item to trade between players
  8317. Params :
  8318. Dev :
  8319. Example :
  8320. */
  8321. void Commands::Command_TradeAddItem(Client* client, Seperator* sep)
  8322. {
  8323. PrintSep(sep, "COMMAND_ADD_TRADE_ITEM");
  8324. /*
  8325. arg[0] = item index
  8326. arg[1] = slot
  8327. arg[2] = quantity
  8328. */
  8329. if (!client->GetPlayer()->trade) {
  8330. LogWrite(PLAYER__ERROR, 0, "Trade", "Player is not currently trading.");
  8331. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8332. return;
  8333. }
  8334. if (sep && sep->IsSet(0) && sep->IsNumber(0) && sep->IsSet(1) && sep->IsNumber(1) && sep->IsSet(2) && sep->IsNumber(2)) {
  8335. Item* item = 0;
  8336. int32 index = atoi(sep->arg[0]);
  8337. item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(index);
  8338. if (item) {
  8339. int8 result = client->GetPlayer()->trade->AddItemToTrade(client->GetPlayer(), item, atoi(sep->arg[2]), atoi(sep->arg[1]));
  8340. if (result == 1)
  8341. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Item is already being traded.");
  8342. else if (result == 2)
  8343. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade NO-TRADE items.");
  8344. else if (result == 3)
  8345. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade HEIRLOOM items.");
  8346. else if (result == 255)
  8347. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown error trying to add the item to the trade...");
  8348. }
  8349. else {
  8350. LogWrite(PLAYER__ERROR, 0, "Trade", "Unable to get an item for the player (%s) from the index (%u)", client->GetPlayer()->GetName(), index);
  8351. client->Message(CHANNEL_ERROR, "Unable to find item at index %u", index);
  8352. }
  8353. }
  8354. else
  8355. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  8356. }
  8357. /*
  8358. Function: Command_TradeRemoveItem()
  8359. Purpose : Removes item from trade between players
  8360. Params :
  8361. Dev :
  8362. Example :
  8363. */
  8364. void Commands::Command_TradeRemoveItem(Client* client, Seperator* sep)
  8365. {
  8366. PrintSep(sep, "COMMAND_REMOVE_TRADE_ITEM");
  8367. /*
  8368. arg[0] = trade window slot
  8369. */
  8370. Trade* trade = client->GetPlayer()->trade;
  8371. if (trade) {
  8372. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  8373. trade->RemoveItemFromTrade(client->GetPlayer(), atoi(sep->arg[0]));
  8374. }
  8375. else
  8376. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  8377. }
  8378. else
  8379. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8380. }
  8381. void Commands::Command_TryOn(Client* client, Seperator* sep)
  8382. {
  8383. Item *item = 0;
  8384. sint32 crc;
  8385. if (sep) {
  8386. // 1096+ sends more info so need to do a version check so older clients (SF) still work
  8387. if (client->GetVersion() < 1096) {
  8388. if (sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2))
  8389. {
  8390. item = master_item_list.GetItem(atoul(sep->arg[1]));
  8391. crc = atol(sep->arg[2]);
  8392. }
  8393. }
  8394. else {
  8395. // From the broker and links in chat
  8396. if (strcmp(sep->arg[0], "crc") == 0) {
  8397. if (sep->IsNumber(2) && sep->IsNumber(3)) {
  8398. item = master_item_list.GetItem(atoul(sep->arg[2]));
  8399. crc = atol(sep->arg[3]);
  8400. }
  8401. }
  8402. // From inventory
  8403. if (strcmp(sep->arg[0], "dbid") == 0) {
  8404. if (sep->IsNumber(2) && sep->IsNumber(4)) {
  8405. item = master_item_list.GetItem(atoul(sep->arg[2]));
  8406. crc = atol(sep->arg[4]);
  8407. }
  8408. }
  8409. }
  8410. if (item)
  8411. client->ShowDressingRoom(item, crc);
  8412. }
  8413. }
  8414. void Commands::Command_JoinChannel(Client * client, Seperator *sep) {
  8415. const char *channel_name, *password = NULL;
  8416. if (sep == NULL || !sep->IsSet(0)) {
  8417. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /joinchannel <channel name> [password]");
  8418. return;
  8419. }
  8420. channel_name = sep->arg[0];
  8421. if (sep->IsSet(1))
  8422. password = sep->arg[1];
  8423. if (!chat.ChannelExists(channel_name) && !chat.CreateChannel(channel_name, password)) {
  8424. client->Message(CHANNEL_COLOR_RED, "Unable to create channel '%s'.", channel_name);
  8425. return;
  8426. }
  8427. if (chat.IsInChannel(client, channel_name)) {
  8428. client->Message(CHANNEL_NARRATIVE, "You are already in '%s'.", channel_name);
  8429. return;
  8430. }
  8431. if (chat.HasPassword(channel_name)) {
  8432. if (password == NULL) {
  8433. client->Message(CHANNEL_NARRATIVE, "Unable to join '%s': That channel is password protected.", channel_name);
  8434. return;
  8435. }
  8436. if (!chat.PasswordMatches(channel_name, password)) {
  8437. client->Message(CHANNEL_NARRATIVE, "Unable to join '%s': The password is not correc.t", channel_name);
  8438. return;
  8439. }
  8440. }
  8441. if (!chat.JoinChannel(client, channel_name))
  8442. client->Message(CHANNEL_COLOR_RED, "There was an internal error preventing you from joining '%s'.", channel_name);
  8443. }
  8444. void Commands::Command_JoinChannelFromLoad(Client * client, Seperator *sep) {
  8445. printf("ScatDebug: Received 'joinfromchannel', using the same function as 'joinchannel' (not sure what the difference is)\n");
  8446. Command_JoinChannel(client, sep);
  8447. }
  8448. void Commands::Command_TellChannel(Client *client, Seperator *sep) {
  8449. if (sep == NULL || !sep->IsSet(0) || !sep->IsSet(1)) {
  8450. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /tellchannel <channel name> <message>");
  8451. PrintSep(sep, "tellchannel");
  8452. return;
  8453. }
  8454. chat.TellChannel(client, sep->arg[0], sep->argplus[1]);
  8455. }
  8456. void Commands::Command_Test(Client* client, EQ2_16BitString* command_parms) {
  8457. Seperator* sep = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  8458. if (sep->IsSet(0)) {
  8459. if (atoi(sep->arg[0]) == 1) {
  8460. PacketStruct* packet2 = configReader.getStruct("WS_SpellGainedMsg", client->GetVersion());
  8461. if (packet2) {
  8462. packet2->setDataByName("spell_type", 2);
  8463. packet2->setDataByName("spell_id", 8308);
  8464. packet2->setDataByName("spell_name", "Sprint");
  8465. packet2->setDataByName("add_silently", 0);
  8466. packet2->setDataByName("tier", 1);
  8467. packet2->setDataByName("blah1", 1);
  8468. packet2->setDataByName("blah2", 1);
  8469. EQ2Packet* outapp = packet2->serialize();
  8470. DumpPacket(outapp);
  8471. client->QueuePacket(outapp);
  8472. safe_delete(packet2);
  8473. }
  8474. }
  8475. else if (atoi(sep->arg[0]) == 2) {
  8476. PacketStruct* packet2 = configReader.getStruct("WS_GuildUpdate", client->GetVersion());
  8477. if (packet2) {
  8478. packet2->setDataByName("guild_name", "Test");
  8479. packet2->setDataByName("guild_motd", "Test MOTD");
  8480. packet2->setDataByName("guild_id", 1234);
  8481. packet2->setDataByName("guild_level", 1);
  8482. packet2->setDataByName("unknown", 2);
  8483. packet2->setDataByName("unknown2", 3);
  8484. packet2->setDataByName("exp_current", 1);
  8485. packet2->setDataByName("exp_to_next_level", 4);
  8486. EQ2Packet* outapp = packet2->serialize();
  8487. DumpPacket(outapp);
  8488. client->QueuePacket(outapp);
  8489. safe_delete(packet2);
  8490. }
  8491. }
  8492. else if (atoi(sep->arg[0]) == 3) {
  8493. PacketStruct* packet2 = configReader.getStruct("WS_JoinGuildNotify", client->GetVersion());
  8494. if (packet2) {
  8495. packet2->setDataByName("guild_id", 1234);
  8496. packet2->setDataByName("character_id", 1);
  8497. packet2->setDataByName("account_id", 2);
  8498. packet2->setDataByName("guild_level", 1);
  8499. packet2->setDataByName("name", "Test");
  8500. packet2->setDataByName("unknown2", 0);
  8501. packet2->setDataByName("unknown3", 1);
  8502. packet2->setDataByName("adventure_class", 6);
  8503. packet2->setDataByName("adventure_level", 7);
  8504. packet2->setDataByName("tradeskill_class", 4);
  8505. packet2->setDataByName("tradeskill_level", 5);
  8506. packet2->setDataByName("rank", 0);
  8507. packet2->setDataByName("member_flags", 2);
  8508. packet2->setDataByName("join_date", 1591112273);
  8509. packet2->setDataByName("guild_status", 2);
  8510. packet2->setDataByName("last_login", 1591132273);
  8511. packet2->setDataByName("recruiter_id", 1);
  8512. packet2->setDataByName("points", 2345);
  8513. packet2->setDataByName("note", "note");
  8514. packet2->setMediumStringByName("officer_note", "O note");
  8515. packet2->setMediumStringByName("zone", "Blah");
  8516. EQ2Packet* outapp = packet2->serialize();
  8517. DumpPacket(outapp);
  8518. client->QueuePacket(outapp);
  8519. safe_delete(packet2);
  8520. }
  8521. }
  8522. else if (atoi(sep->arg[0]) == 5) {
  8523. int16 offset = atoi(sep->arg[1]);
  8524. int32 value1 = atol(sep->arg[2]);
  8525. EQ2Packet* outapp = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion(), offset, value1);
  8526. client->QueuePacket(outapp);
  8527. }
  8528. else if (atoi(sep->arg[0]) == 6) {
  8529. Spawn* spawn = client->GetPlayer()->GetTarget();
  8530. if (!spawn)
  8531. spawn = client->GetPlayer();
  8532. else if (spawn->IsEntity())
  8533. ((Entity*)spawn)->SetSpeed(atof(sep->arg[4]));
  8534. spawn->RunToLocation(atof(sep->arg[1]), atof(sep->arg[2]), atof(sep->arg[3]));
  8535. }
  8536. else if (atoi(sep->arg[0]) == 7) {
  8537. int32 id = 0;
  8538. Spawn* spawn = client->GetCurrentZone()->GetSpawn(7720001);
  8539. if (spawn) {
  8540. spawn->SetX(client->GetPlayer()->GetX() + .5, false);
  8541. spawn->SetY(client->GetPlayer()->GetY(), false);
  8542. spawn->SetZ(client->GetPlayer()->GetZ() + .5, false);
  8543. float heading = client->GetPlayer()->GetHeading() + 180;
  8544. if (heading > 360)
  8545. heading -= 360;
  8546. spawn->SetLevel(5);
  8547. spawn->SetAdventureClass(4);
  8548. spawn->SetHeading(heading, false);
  8549. spawn->SetSpawnOrigX(spawn->GetX());
  8550. spawn->SetSpawnOrigY(spawn->GetY());
  8551. spawn->SetSpawnOrigZ(spawn->GetZ());
  8552. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  8553. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  8554. spawn->appearance.targetable = 1;
  8555. if (spawn->IsNPC() && spawn->GetTotalHP() == 0) {
  8556. spawn->SetTotalHP(spawn->GetLevel() * 15);
  8557. spawn->SetHP(spawn->GetTotalHP());
  8558. }
  8559. if (spawn->GetTotalPower() == 0) {
  8560. spawn->SetTotalPower(spawn->GetLevel() * 15);
  8561. spawn->SetPower(spawn->GetTotalPower());
  8562. }
  8563. int16 offset = atoi(sep->arg[1]);
  8564. int32 value1 = atol(sep->arg[2]);
  8565. sprintf(spawn->appearance.name, "Offset %i", offset);
  8566. EQ2Packet* ret = spawn->spawn_serialize(client->GetPlayer(), client->GetVersion(), offset, value1);
  8567. DumpPacket(ret);
  8568. client->QueuePacket(ret);
  8569. }
  8570. }
  8571. else if (atoi(sep->arg[0]) == 8) {
  8572. int32 id = atoi(sep->arg[1]);
  8573. Spawn* spawn = client->GetCurrentZone()->GetSpawn(id);
  8574. if (spawn) {
  8575. spawn->SetX(client->GetPlayer()->GetX() + .5, false);
  8576. spawn->SetY(client->GetPlayer()->GetY(), false);
  8577. spawn->SetZ(client->GetPlayer()->GetZ() + .5, false);
  8578. float heading = client->GetPlayer()->GetHeading() + 180;
  8579. if (heading > 360)
  8580. heading -= 360;
  8581. spawn->SetLevel(5);
  8582. spawn->SetAdventureClass(4);
  8583. spawn->SetHeading(heading, false);
  8584. spawn->SetSpawnOrigX(spawn->GetX());
  8585. spawn->SetSpawnOrigY(spawn->GetY());
  8586. spawn->SetSpawnOrigZ(spawn->GetZ());
  8587. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  8588. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  8589. spawn->appearance.targetable = 1;
  8590. if (spawn->IsNPC() && spawn->GetTotalHP() == 0) {
  8591. spawn->SetTotalHP(spawn->GetLevel() * 15);
  8592. spawn->SetHP(spawn->GetTotalHP());
  8593. }
  8594. if (spawn->GetTotalPower() == 0) {
  8595. spawn->SetTotalPower(spawn->GetLevel() * 15);
  8596. spawn->SetPower(spawn->GetTotalPower());
  8597. }
  8598. int16 offset = atoi(sep->arg[2]);
  8599. int16 offset2 = atoi(sep->arg[3]);
  8600. int32 value1 = atol(sep->arg[4]);
  8601. int16 offset3 = 0;
  8602. int16 offset4 = 0;
  8603. int32 value2 = 0;
  8604. if (sep->IsSet(7)) {
  8605. offset3 = atoi(sep->arg[5]);
  8606. offset4 = atoi(sep->arg[6]);
  8607. value2 = atol(sep->arg[7]);
  8608. }
  8609. sprintf(spawn->appearance.name, "Offset %i to %i", offset, offset2);
  8610. spawn->AddPrimaryEntityCommand("attack", 10000, "attack","", 0, 0);
  8611. EQ2Packet* ret = spawn->spawn_serialize(client->GetPlayer(), client->GetVersion(), offset, value1, offset2, offset3, offset4, value2);
  8612. DumpPacket(ret);
  8613. client->QueuePacket(ret);
  8614. }
  8615. }
  8616. else if (atoi(sep->arg[0]) == 9) {
  8617. PacketStruct* packet2 = configReader.getStruct("WS_DeathWindow", client->GetVersion());
  8618. if (packet2) {
  8619. packet2->setArrayLengthByName("location_count", 1);
  8620. packet2->setArrayDataByName("location_ida", 1234);
  8621. packet2->setArrayDataByName("unknown2a", 3);
  8622. packet2->setArrayDataByName("zone_name", "Queen's Colony");
  8623. packet2->setArrayDataByName("location_name", "Myrrin's Tower");
  8624. packet2->setArrayDataByName("distance", 134);
  8625. EQ2Packet* app = packet2->serialize();
  8626. if (sep->IsSet(2)) {
  8627. int8 offset = atoi(sep->arg[1]);
  8628. uchar* ptr2 = app->pBuffer;
  8629. ptr2 += offset;
  8630. if (sep->IsNumber(2)) {
  8631. int32 value1 = atol(sep->arg[2]);
  8632. if (value1 > 0xFFFF)
  8633. memcpy(ptr2, (uchar*)&value1, 4);
  8634. else if (value1 > 0xFF)
  8635. memcpy(ptr2, (uchar*)&value1, 2);
  8636. else
  8637. memcpy(ptr2, (uchar*)&value1, 1);
  8638. }
  8639. else {
  8640. int8 len = strlen(sep->arg[2]);
  8641. memcpy(ptr2, (uchar*)&len, 1);
  8642. ptr2 += 1;
  8643. memcpy(ptr2, sep->arg[2], len);
  8644. }
  8645. }
  8646. DumpPacket(app);
  8647. client->QueuePacket(app);
  8648. safe_delete(packet2);
  8649. }
  8650. }
  8651. else if (atoi(sep->arg[0]) == 10) {
  8652. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalUpdate", client->GetVersion());
  8653. if (packet2) {
  8654. packet2->setArrayLengthByName("num_quests", 1);
  8655. packet2->setArrayDataByName("active", 1);
  8656. packet2->setArrayDataByName("name", "Tasks aboard the Far Journey");
  8657. packet2->setArrayDataByName("quest_type", "Hallmark");
  8658. packet2->setArrayDataByName("quest_zone", "Hallmark");
  8659. packet2->setArrayDataByName("journal_updated", 1);
  8660. packet2->setArrayDataByName("quest_id", 524);
  8661. packet2->setArrayDataByName("day", 19);
  8662. packet2->setArrayDataByName("month", 6);
  8663. packet2->setArrayDataByName("year", 20);
  8664. packet2->setArrayDataByName("level", 2);
  8665. packet2->setArrayDataByName("encounter_level", 4);
  8666. packet2->setArrayDataByName("difficulty", 3);
  8667. packet2->setArrayDataByName("visible", 1);
  8668. packet2->setDataByName("visible_quest_id", 524);
  8669. packet2->setDataByName("player_crc", 2900677088);
  8670. packet2->setDataByName("player_name", "LethalEncounter");
  8671. EQ2Packet* app = packet2->serialize();
  8672. if (sep->IsSet(2)) {
  8673. int8 offset = atoi(sep->arg[1]);
  8674. uchar* ptr2 = app->pBuffer;
  8675. ptr2 += offset;
  8676. if (sep->IsNumber(2)) {
  8677. int32 value1 = atol(sep->arg[2]);
  8678. if (value1 > 0xFFFF)
  8679. memcpy(ptr2, (uchar*)&value1, 4);
  8680. else if (value1 > 0xFF)
  8681. memcpy(ptr2, (uchar*)&value1, 2);
  8682. else
  8683. memcpy(ptr2, (uchar*)&value1, 1);
  8684. }
  8685. else {
  8686. int8 len = strlen(sep->arg[2]);
  8687. memcpy(ptr2, (uchar*)&len, 1);
  8688. ptr2 += 1;
  8689. memcpy(ptr2, sep->arg[2], len);
  8690. }
  8691. }
  8692. DumpPacket(app);
  8693. client->QueuePacket(app);
  8694. safe_delete(packet2);
  8695. }
  8696. }
  8697. else if (atoi(sep->arg[0]) == 11) {
  8698. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalReply", client->GetVersion());
  8699. if (packet2) {
  8700. packet2->setDataByName("quest_id", 524);
  8701. packet2->setDataByName("player_crc", 2900677088);
  8702. packet2->setDataByName("name", "Tasks aboard the Far Journey");
  8703. packet2->setDataByName("description", "I completed all the tasks assigned to me by Captain Varlos aboard the Far Journey");
  8704. packet2->setDataByName("type", "Hallmark");
  8705. packet2->setDataByName("complete_header", "To complete this quest, I must do the following tasks:");
  8706. packet2->setDataByName("day", 19);
  8707. packet2->setDataByName("month", 6);
  8708. packet2->setDataByName("year", 20);
  8709. packet2->setDataByName("level", 1);
  8710. packet2->setDataByName("encounter_level", 1);
  8711. packet2->setDataByName("difficulty", 1);
  8712. packet2->setDataByName("time_obtained", Timer::GetUnixTimeStamp());
  8713. //packet2->setDataByName("timer_start", Timer::GetUnixTimeStamp());
  8714. //packet2->setDataByName("timer_duration", 300);
  8715. //packet2->setDataByName("timer_running", 1);
  8716. packet2->setArrayLengthByName("task_groups_completed", 9);
  8717. packet2->setArrayLengthByName("num_task_groups", 10);
  8718. packet2->setArrayDataByName("task_group", "I spoke to Waulon as Captain Varlos had asked of me.");
  8719. packet2->setArrayDataByName("task_group", "I found Waulon's hat in one of the boxes.", 1);
  8720. packet2->setArrayDataByName("task_group", "I returned Waulon's hat.", 2);
  8721. packet2->setArrayDataByName("task_group", "I have spoken to Ingrid.", 3);
  8722. packet2->setArrayDataByName("task_group", "I purchased a Shard of Luclin.", 4);
  8723. packet2->setArrayDataByName("task_group", "I gave the Shard of Luclin to Ingrid.", 5);
  8724. packet2->setArrayDataByName("task_group", "I have spoken to Captain Varlos.", 6);
  8725. packet2->setArrayDataByName("task_group", "I killed the rats that Captain Varlos requested.", 7);
  8726. packet2->setArrayDataByName("task_group", "Captain Varlos has ordered you to kill the escaped goblin.", 8);
  8727. packet2->setArrayDataByName("task_group", "I killed the escaped goblin.", 9);
  8728. /*packet2->setSubArrayLengthByName("num_tasks", 1);
  8729. packet2->setSubArrayDataByName("task", "I need to talk to Garven Tralk");
  8730. packet2->setSubArrayLengthByName("num_updates", 1);
  8731. packet2->setSubArrayDataByName("update_currentval", 0);
  8732. packet2->setSubArrayDataByName("update_maxval", 1);
  8733. packet2->setSubArrayDataByName("icon", 11);
  8734. */
  8735. packet2->setArrayDataByName("waypoint", 0xFFFFFFFF);
  8736. packet2->setDataByName("journal_updated", 1);
  8737. packet2->setDataByName("bullets", 1);
  8738. EQ2Packet* app = packet2->serialize();
  8739. if (sep->IsSet(2)) {
  8740. int16 offset = atoi(sep->arg[1]);
  8741. uchar* ptr2 = app->pBuffer;
  8742. ptr2 += offset;
  8743. if (sep->IsNumber(2)) {
  8744. int32 value1 = atol(sep->arg[2]);
  8745. if (value1 > 0xFFFF)
  8746. memcpy(ptr2, (uchar*)&value1, 4);
  8747. else if (value1 > 0xFF)
  8748. memcpy(ptr2, (uchar*)&value1, 2);
  8749. else
  8750. memcpy(ptr2, (uchar*)&value1, 1);
  8751. }
  8752. else {
  8753. int16 len = strlen(sep->arg[2]);
  8754. memcpy(ptr2, (uchar*)&len, 2);
  8755. ptr2 += 2;
  8756. memcpy(ptr2, sep->arg[2], len);
  8757. }
  8758. }
  8759. DumpPacket(app);
  8760. client->QueuePacket(app);
  8761. safe_delete(packet2);
  8762. }
  8763. }
  8764. else if (atoi(sep->arg[0]) == 12) {
  8765. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalReply", client->GetVersion());
  8766. if (packet2) {
  8767. packet2->setDataByName("quest_id", 524);
  8768. packet2->setDataByName("player_crc", 2900677088);
  8769. packet2->setDataByName("name", "Archetype Selection");
  8770. packet2->setDataByName("description", "I have reported my profession to Garven Tralk.");
  8771. packet2->setDataByName("type", "Hallmark");
  8772. packet2->setDataByName("complete_header", "To complete this quest, I must do the following tasks:");
  8773. packet2->setDataByName("day", 19);
  8774. packet2->setDataByName("month", 6);
  8775. packet2->setDataByName("year", 20);
  8776. packet2->setDataByName("level", 2);
  8777. packet2->setDataByName("encounter_level", 4);
  8778. packet2->setDataByName("difficulty", 3);
  8779. packet2->setDataByName("time_obtained", Timer::GetUnixTimeStamp());
  8780. packet2->setDataByName("timer_start", Timer::GetUnixTimeStamp());
  8781. packet2->setDataByName("timer_duration", 300);
  8782. packet2->setDataByName("timer_running", 1);
  8783. packet2->setArrayLengthByName("task_groups_completed", 0);
  8784. packet2->setArrayLengthByName("num_task_groups", 1);
  8785. packet2->setArrayDataByName("task_group", "I need to talk to Garven Tralk");
  8786. packet2->setSubArrayLengthByName("num_tasks", 1);
  8787. packet2->setSubArrayDataByName("task", "I need to talk to Garven Tralk");
  8788. packet2->setSubArrayLengthByName("num_updates", 1);
  8789. packet2->setSubArrayDataByName("update_currentval", 0);
  8790. packet2->setSubArrayDataByName("update_maxval", 1);
  8791. packet2->setSubArrayDataByName("icon", 11);
  8792. packet2->setArrayDataByName("waypoint", 0xFFFFFFFF);
  8793. packet2->setDataByName("journal_updated", 1);
  8794. packet2->setSubstructDataByName("reward_data", "unknown1", 255);
  8795. packet2->setSubstructDataByName("reward_data", "reward", "Quest Reward!");
  8796. packet2->setSubstructDataByName("reward_data", "unknown2", 0x3f);
  8797. packet2->setSubstructDataByName("reward_data", "coin", 150);
  8798. packet2->setSubstructDataByName("reward_data", "status_points", 5);
  8799. packet2->setSubstructDataByName("reward_data", "exp_bonus", 10);
  8800. packet2->setSubstructArrayLengthByName("reward_data", "num_rewards", 1);
  8801. packet2->setSubstructArrayDataByName("reward_data", "reward_id", 123);
  8802. Item* item = master_item_list.GetItem(152755);
  8803. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8804. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  8805. /*packet2->setSubstructDataByName("item", "unique_id", 567);
  8806. packet2->setSubstructDataByName("item", "broker_item_id", 0xFFFFFFFFFFFFFFFF);
  8807. packet2->setSubstructDataByName("item", "icon", 0xe7);
  8808. packet2->setSubstructDataByName("item", "tier", 4);
  8809. packet2->setSubstructDataByName("item", "flags", 0x60);
  8810. packet2->setSubstructArrayLengthByName("item", "stat_count", 1);
  8811. packet2->setSubstructDataByName("item", "stat_type", 1);
  8812. packet2->setSubstructDataByName("item", "stat_subtype", 2);
  8813. packet2->setSubstructDataByName("item", "value", 3);
  8814. packet2->setSubstructDataByName("item", "condition", 100);
  8815. packet2->setSubstructDataByName("item", "weight", 1);
  8816. packet2->setSubstructDataByName("item", "skill_req1", 0xacafa99e);
  8817. packet2->setSubstructDataByName("item", "skill_req2", 0xacafa99e);
  8818. packet2->setSubstructDataByName("item", "skill_min", 1);
  8819. packet2->setSubstructArrayLengthByName("item", "class_count", 3);
  8820. packet2->setSubstructDataByName("item", "adventure_class", 1);
  8821. packet2->setSubstructDataByName("item", "adventure_class", 11, 0, 1);
  8822. packet2->setSubstructDataByName("item", "adventure_class", 0x1f, 0, 2);
  8823. packet2->setSubstructDataByName("item", "tradeskill_class", 255);
  8824. packet2->setSubstructDataByName("item", "tradeskill_class", 255, 0, 1);
  8825. packet2->setSubstructDataByName("item", "tradeskill_class", 255, 0, 2);
  8826. packet2->setSubstructDataByName("item", "level", 0x1e);
  8827. packet2->setSubstructDataByName("item", "level", 100, 0, 1);
  8828. packet2->setSubstructDataByName("item", "level", 100, 0, 2);
  8829. packet2->setSubstructDataByName("item_footer", "name", "Footman Gloves");*/
  8830. //packet2->PrintPacket();
  8831. EQ2Packet* app = packet2->serialize();
  8832. if (sep->IsSet(2)) {
  8833. int16 offset = atoi(sep->arg[1]);
  8834. uchar* ptr2 = app->pBuffer;
  8835. ptr2 += offset;
  8836. if (sep->IsNumber(2)) {
  8837. int32 value1 = atol(sep->arg[2]);
  8838. if (value1 > 0xFFFF)
  8839. memcpy(ptr2, (uchar*)&value1, 4);
  8840. else if (value1 > 0xFF)
  8841. memcpy(ptr2, (uchar*)&value1, 2);
  8842. else
  8843. memcpy(ptr2, (uchar*)&value1, 1);
  8844. }
  8845. else {
  8846. int16 len = strlen(sep->arg[2]);
  8847. memcpy(ptr2, (uchar*)&len, 2);
  8848. ptr2 += 2;
  8849. memcpy(ptr2, sep->arg[2], len);
  8850. }
  8851. }
  8852. DumpPacket(app);
  8853. client->QueuePacket(app);
  8854. safe_delete(packet2);
  8855. }
  8856. }
  8857. else if (atoi(sep->arg[0]) == 13) {
  8858. PacketStruct* packet2 = configReader.getStruct("WS_OnScreenMsg", client->GetVersion());
  8859. if (packet2 && sep->IsSet(7)) {
  8860. packet2->setDataByName("unknown", atoi(sep->arg[1]));
  8861. char blah[128];
  8862. sprintf(blah, "\\#6EFF6EYou get better at \12\\#C8FFC8%s\\#6EFF6E! (7/15)", sep->arg[2]);
  8863. packet2->setDataByName("text", blah);
  8864. packet2->setDataByName("message_type", sep->arg[3]);
  8865. packet2->setDataByName("size", atof(sep->arg[4]));
  8866. packet2->setDataByName("red", atoi(sep->arg[5]));
  8867. packet2->setDataByName("green", atoi(sep->arg[6]));
  8868. packet2->setDataByName("blue", atoi(sep->arg[7]));
  8869. EQ2Packet* app = packet2->serialize();
  8870. DumpPacket(app);
  8871. client->QueuePacket(app);
  8872. safe_delete(packet2);
  8873. }
  8874. }
  8875. else if (atoi(sep->arg[0]) == 14) {
  8876. PacketStruct* packet2 = configReader.getStruct("WS_InstructionWindow", client->GetVersion());
  8877. if (packet2 && sep->IsSet(3)) {
  8878. packet2->setDataByName("open_seconds_min", atof(sep->arg[1]));
  8879. packet2->setDataByName("open_seconds_max", atof(sep->arg[2]));
  8880. packet2->setDataByName("voice_sync", atoi(sep->arg[3]));
  8881. 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.");
  8882. packet2->setDataByName("voice", "voiceover/english/narrator/boat_06p_tutorial02/narrator_001_63779ca0.mp3");
  8883. packet2->setArrayLengthByName("num_goals", 1);
  8884. //packet2->setArrayDataByName("goal_text", )
  8885. packet2->setSubArrayLengthByName("num_tasks", 1);
  8886. packet2->setSubArrayDataByName("task_text", "continue");
  8887. packet2->setDataByName("complete_sound", "click");
  8888. packet2->setDataByName("signal", "introduction");
  8889. packet2->setDataByName("voice_key1", 0xcda65173);
  8890. packet2->setDataByName("voice_key2", 0x984bfc6d);
  8891. EQ2Packet* app = packet2->serialize();
  8892. DumpPacket(app);
  8893. client->QueuePacket(app);
  8894. safe_delete(packet2);
  8895. packet2 = configReader.getStruct("WS_ShowWindow", client->GetVersion());
  8896. packet2->setDataByName("window", "MainHUD.StartMenu");
  8897. packet2->setDataByName("show", 1);
  8898. app = packet2->serialize();
  8899. DumpPacket(app);
  8900. client->QueuePacket(app);
  8901. safe_delete(packet2);
  8902. packet2 = configReader.getStruct("WS_FlashWindow", client->GetVersion());
  8903. packet2->setDataByName("window", "MainHUD.StartMenu.help");
  8904. packet2->setDataByName("flash_seconds", 10);
  8905. app = packet2->serialize();
  8906. DumpPacket(app);
  8907. client->QueuePacket(app);
  8908. safe_delete(packet2);
  8909. }
  8910. }
  8911. else if (atoi(sep->arg[0]) == 15) {
  8912. PacketStruct* packet2 = configReader.getStruct("WS_UpdateLoot", client->GetVersion());
  8913. if (packet2) {
  8914. packet2->setArrayLengthByName("loot_count", 1);
  8915. packet2->setArrayDataByName("name", "Test");
  8916. packet2->setArrayDataByName("item_id", 1234);
  8917. packet2->setArrayDataByName("count", 1);
  8918. packet2->setArrayDataByName("icon", 258);
  8919. packet2->setArrayDataByName("ability_id", 0xFFFFFFFF);
  8920. Spawn* spawn = client->GetPlayer()->GetTarget();
  8921. if (spawn)
  8922. packet2->setDataByName("object_id", client->GetPlayer()->GetIDWithPlayerSpawn(spawn));
  8923. packet2->setDataByName("unknown3", 1);
  8924. packet2->setDataByName("unknown4", 1);
  8925. packet2->setDataByName("unknown5", 60);
  8926. EQ2Packet* app = packet2->serialize();
  8927. DumpPacket(app);
  8928. client->QueuePacket(app);
  8929. safe_delete(packet2);
  8930. }
  8931. }
  8932. else if (atoi(sep->arg[0]) == 16 && sep->IsNumber(1)) {
  8933. char blah[32];
  8934. sprintf(blah, "Testing: %i", atoi(sep->arg[1]));
  8935. client->SimpleMessage(atoi(sep->arg[1]), blah);
  8936. }
  8937. else if (atoi(sep->arg[0]) == 17 && sep->IsNumber(2)) {
  8938. if (sep->IsSet(2)) {
  8939. int16 offset = atoi(sep->arg[1]);
  8940. if (sep->IsNumber(2)) {
  8941. int32 value1 = atol(sep->arg[2]);
  8942. client->QueuePacket(client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion(), offset, value1));
  8943. cout << "Sent" << endl;
  8944. }
  8945. }
  8946. }
  8947. else if (atoi(sep->arg[0]) == 18) {
  8948. PacketStruct* packet2 = configReader.getStruct("WS_QuestRewardPackMsg", client->GetVersion());
  8949. if (packet2) {
  8950. packet2->setSubstructDataByName("reward_data", "unknown1", 255);
  8951. packet2->setSubstructDataByName("reward_data", "reward", "Quest Reward!");
  8952. packet2->setSubstructDataByName("reward_data", "coin", 150);
  8953. packet2->setSubstructDataByName("reward_data", "status_points", 5);
  8954. packet2->setSubstructDataByName("reward_data", "exp_bonus", 10);
  8955. packet2->setSubstructArrayLengthByName("reward_data", "num_rewards", 4);
  8956. Item* item = new Item(master_item_list.GetItem(36212));
  8957. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8958. item->stack_count = 20;
  8959. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  8960. safe_delete(item);
  8961. item = new Item(master_item_list.GetItem(36685));
  8962. item->stack_count = 20;
  8963. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8964. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 1, 0, -1);
  8965. safe_delete(item);
  8966. item = master_item_list.GetItem(1414);
  8967. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8968. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 2, 0, -1);
  8969. item = master_item_list.GetItem(75057);
  8970. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8971. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 3, 0, -1);
  8972. EQ2Packet* app = packet2->serialize();
  8973. if (sep->IsSet(2)) {
  8974. int16 offset = atoi(sep->arg[1]);
  8975. uchar* ptr2 = app->pBuffer;
  8976. ptr2 += offset;
  8977. if (sep->IsNumber(2)) {
  8978. int32 value1 = atol(sep->arg[2]);
  8979. if (value1 > 0xFFFF)
  8980. memcpy(ptr2, (uchar*)&value1, 4);
  8981. else if (value1 > 0xFF)
  8982. memcpy(ptr2, (uchar*)&value1, 2);
  8983. else
  8984. memcpy(ptr2, (uchar*)&value1, 1);
  8985. }
  8986. else {
  8987. int16 len = strlen(sep->arg[2]);
  8988. memcpy(ptr2, (uchar*)&len, 2);
  8989. ptr2 += 2;
  8990. memcpy(ptr2, sep->arg[2], len);
  8991. }
  8992. }
  8993. DumpPacket(app);
  8994. client->QueuePacket(app);
  8995. safe_delete(packet2);
  8996. }
  8997. }
  8998. else if (atoi(sep->arg[0]) == 19) {
  8999. PacketStruct* packet2 = configReader.getStruct("WS_UpdateLoot", client->GetVersion());
  9000. Spawn* spawn = client->GetPlayer()->GetTarget();
  9001. if (packet2 && spawn) {
  9002. Item* item = master_item_list.GetItem(130053);
  9003. packet2->setArrayLengthByName("loot_count", 1);
  9004. packet2->setArrayDataByName("loot_id", item->details.item_id);
  9005. packet2->setArrayDataByName("unknown2", 1);
  9006. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, 2, true);
  9007. packet2->setDataByName("display", 1);
  9008. packet2->setDataByName("unknown2b", 1);
  9009. packet2->setDataByName("unknown3", 0x3c);
  9010. packet2->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(spawn));
  9011. packet2->PrintPacket();
  9012. EQ2Packet* app = packet2->serialize();
  9013. if (sep->IsSet(2)) {
  9014. int16 offset = atoi(sep->arg[1]);
  9015. int16 offset2 = 0;
  9016. int32 value1 = 0;
  9017. if (sep->IsSet(3)) {
  9018. offset2 = atoi(sep->arg[2]);
  9019. value1 = atol(sep->arg[3]);
  9020. }
  9021. else
  9022. value1 = atol(sep->arg[2]);
  9023. int16 offset3 = 0;
  9024. int16 offset4 = 0;
  9025. int32 value2 = 0;
  9026. if (sep->IsSet(6)) {
  9027. offset3 = atoi(sep->arg[4]);
  9028. offset4 = atoi(sep->arg[5]);
  9029. value2 = atol(sep->arg[6]);
  9030. }
  9031. offset--;
  9032. if (offset2 > 0 && offset2 >= offset) {
  9033. offset2--;
  9034. uchar* ptr2 = app->pBuffer;
  9035. ptr2 += offset;
  9036. for (int i = offset; i <= offset2; i++) {
  9037. if (value1 > 0xFFFF) {
  9038. memcpy(ptr2, (uchar*)&value1, 4);
  9039. i += 3;
  9040. ptr2 += 3;
  9041. }
  9042. else if (value1 > 0xFF) {
  9043. memcpy(ptr2, (uchar*)&value1, 2);
  9044. i++;
  9045. ptr2++;
  9046. }
  9047. else
  9048. memcpy(ptr2, (uchar*)&value1, 1);
  9049. ptr2++;
  9050. }
  9051. }
  9052. if (offset4 > 0 && offset4 >= offset3) {
  9053. offset3--;
  9054. offset4--;
  9055. uchar* ptr2 = app->pBuffer;
  9056. ptr2 += offset3;
  9057. for (int i = offset3; i <= offset4; i++) {
  9058. if (value2 > 0xFFFF) {
  9059. memcpy(ptr2, (uchar*)&value2, 4);
  9060. i += 3;
  9061. ptr2 += 3;
  9062. }
  9063. else if (value2 > 0xFF) {
  9064. memcpy(ptr2, (uchar*)&value2, 2);
  9065. i++;
  9066. ptr2++;
  9067. }
  9068. else
  9069. memcpy(ptr2, (uchar*)&value2, 1);
  9070. ptr2++;
  9071. }
  9072. }
  9073. }
  9074. DumpPacket(app);
  9075. client->QueuePacket(app);
  9076. safe_delete(packet2);
  9077. }
  9078. }
  9079. else if (atoi(sep->arg[0]) == 21) {
  9080. PacketStruct* packet2 = configReader.getStruct("WS_OfferQuest", client->GetVersion());
  9081. if (packet2) {
  9082. packet2->setDataByName("unknown0", 255);
  9083. packet2->setDataByName("reward", "New Quest");
  9084. packet2->setDataByName("title", "Title");
  9085. packet2->setDataByName("description", "description");
  9086. packet2->setDataByName("quest_difficulty", 3);
  9087. packet2->setDataByName("unknown1", 5);
  9088. packet2->setDataByName("level", 3);
  9089. packet2->setDataByName("coin", 150);
  9090. packet2->setDataByName("status_points", 5);
  9091. packet2->setDataByName("exp_bonus", 10);
  9092. packet2->setArrayLengthByName("num_rewards", 1);
  9093. Item* item = new Item(master_item_list.GetItem(36212));
  9094. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9095. item->stack_count = 20;
  9096. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  9097. safe_delete(item);
  9098. char accept[35] = { 0 };
  9099. char decline[35] = { 0 };
  9100. sprintf(accept, "q_accept_pending_quest %u", 0);
  9101. sprintf(decline, "q_deny_pending_quest %u", 0);
  9102. packet2->setDataByName("accept_command", accept);
  9103. packet2->setDataByName("decline_command", decline);
  9104. EQ2Packet* app = packet2->serialize();
  9105. if (sep->IsSet(2)) {
  9106. int16 offset = atoi(sep->arg[1]);
  9107. uchar* ptr2 = app->pBuffer;
  9108. ptr2 += offset;
  9109. if (sep->IsNumber(2)) {
  9110. int32 value1 = atol(sep->arg[2]);
  9111. if (value1 > 0xFFFF)
  9112. memcpy(ptr2, (uchar*)&value1, 4);
  9113. else if (value1 > 0xFF)
  9114. memcpy(ptr2, (uchar*)&value1, 2);
  9115. else
  9116. memcpy(ptr2, (uchar*)&value1, 1);
  9117. }
  9118. DumpPacket(app);
  9119. client->QueuePacket(app);
  9120. safe_delete(packet2);
  9121. }
  9122. }
  9123. }
  9124. else if (atoi(sep->arg[0]) == 22) { //same as 21, but 8bit string
  9125. PacketStruct* packet2 = configReader.getStruct("WS_OfferQuest", client->GetVersion());
  9126. if (packet2) {
  9127. packet2->setDataByName("unknown0", 255);
  9128. packet2->setDataByName("reward", "New Quest");
  9129. packet2->setDataByName("title", "Title");
  9130. packet2->setDataByName("description", "description");
  9131. packet2->setDataByName("quest_difficulty", 3);
  9132. packet2->setDataByName("unknown1", 5);
  9133. packet2->setDataByName("level", 3);
  9134. packet2->setDataByName("coin", 150);
  9135. packet2->setDataByName("status_points", 5);
  9136. packet2->setDataByName("exp_bonus", 10);
  9137. packet2->setArrayLengthByName("num_rewards", 1);
  9138. Item* item = new Item(master_item_list.GetItem(36212));
  9139. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9140. item->stack_count = 20;
  9141. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  9142. safe_delete(item);
  9143. char accept[35] = { 0 };
  9144. char decline[35] = { 0 };
  9145. sprintf(accept, "q_accept_pending_quest %u", 0);
  9146. sprintf(decline, "q_deny_pending_quest %u", 0);
  9147. packet2->setDataByName("accept_command", accept);
  9148. packet2->setDataByName("decline_command", decline);
  9149. EQ2Packet* app = packet2->serialize();
  9150. if (sep->IsSet(2)) {
  9151. int16 offset = atoi(sep->arg[1]);
  9152. uchar* ptr2 = app->pBuffer;
  9153. ptr2 += offset;
  9154. if (sep->IsNumber(2)) {
  9155. int32 value1 = atol(sep->arg[2]);
  9156. if (value1 > 0xFFFF)
  9157. memcpy(ptr2, (uchar*)&value1, 4);
  9158. else if (value1 > 0xFF)
  9159. memcpy(ptr2, (uchar*)&value1, 2);
  9160. else
  9161. memcpy(ptr2, (uchar*)&value1, 1);
  9162. }
  9163. else {
  9164. int8 len = strlen(sep->arg[2]);
  9165. memcpy(ptr2, (uchar*)&len, 1);
  9166. ptr2 += 1;
  9167. memcpy(ptr2, sep->arg[2], len);
  9168. }
  9169. }
  9170. DumpPacket(app);
  9171. client->QueuePacket(app);
  9172. safe_delete(packet2);
  9173. }
  9174. }
  9175. else if (atoi(sep->arg[0]) == 23) {
  9176. if (client->GetPlayer()->GetTarget()) {
  9177. PacketStruct* packet2 = configReader.getStruct("WS_UpdateMerchant", client->GetVersion());
  9178. if (packet2) {
  9179. Spawn* target = client->GetPlayer()->GetTarget();
  9180. packet2->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(target));
  9181. Item* item = new Item(master_item_list.GetItem(12565));
  9182. int8 i = 0;
  9183. packet2->setArrayLengthByName("num_items", 1);
  9184. packet2->setArrayDataByName("item_name", item->name.c_str(), i);
  9185. packet2->setArrayDataByName("item_id", item->details.item_id, i);
  9186. packet2->setArrayDataByName("stack_size", item->stack_count, i);
  9187. packet2->setArrayDataByName("icon", item->details.icon, i);
  9188. int8 tmp_level = 0;
  9189. if (item->generic_info.adventure_default_level > 0)
  9190. tmp_level = item->generic_info.adventure_default_level;
  9191. else
  9192. tmp_level = item->generic_info.tradeskill_default_level;
  9193. packet2->setArrayDataByName("level", tmp_level, i);
  9194. packet2->setArrayDataByName("tier", item->details.tier, i);
  9195. packet2->setArrayDataByName("item_id2", item->details.item_id, i);
  9196. int8 item_difficulty = client->GetPlayer()->GetArrowColor(tmp_level);
  9197. if (item_difficulty != ARROW_COLOR_WHITE && item_difficulty != ARROW_COLOR_RED && item_difficulty != ARROW_COLOR_GRAY)
  9198. item_difficulty = ARROW_COLOR_WHITE;
  9199. item_difficulty -= 6;
  9200. if (item_difficulty < 0)
  9201. item_difficulty *= -1;
  9202. packet2->setArrayDataByName("item_difficulty", item_difficulty, i);
  9203. packet2->setArrayDataByName("quantity", 2, i);
  9204. packet2->setArrayDataByName("unknown5", 255, i);
  9205. packet2->setArrayDataByName("stack_size2", item->stack_count, i);
  9206. packet2->setArrayDataByName("description", item->description.c_str(), i);
  9207. packet2->setDataByName("type", 2);
  9208. EQ2Packet* app = packet2->serialize();
  9209. if (sep->IsSet(2)) {
  9210. int16 offset = atoi(sep->arg[1]);
  9211. uchar* ptr2 = app->pBuffer;
  9212. ptr2 += offset;
  9213. if (sep->IsNumber(2)) {
  9214. int32 value1 = atol(sep->arg[2]);
  9215. if (value1 > 0xFFFF)
  9216. memcpy(ptr2, (uchar*)&value1, 4);
  9217. else if (value1 > 0xFF)
  9218. memcpy(ptr2, (uchar*)&value1, 2);
  9219. else
  9220. memcpy(ptr2, (uchar*)&value1, 1);
  9221. }
  9222. else {
  9223. int8 len = strlen(sep->arg[2]);
  9224. memcpy(ptr2, (uchar*)&len, 1);
  9225. ptr2 += 1;
  9226. memcpy(ptr2, sep->arg[2], len);
  9227. }
  9228. }
  9229. DumpPacket(app);
  9230. client->QueuePacket(app);
  9231. safe_delete(packet2);
  9232. }
  9233. }
  9234. }
  9235. else if (atoi(sep->arg[0]) == 24) {
  9236. PacketStruct* packet2 = configReader.getStruct("WS_EnableGameEvent", client->GetVersion());
  9237. if (packet2) {
  9238. if (sep->IsSet(2)) {
  9239. packet2->setDataByName("event_name", sep->arg[1]);
  9240. packet2->setDataByName("enabled", atoi(sep->arg[2]));
  9241. EQ2Packet* app = packet2->serialize();
  9242. DumpPacket(app);
  9243. client->QueuePacket(app);
  9244. safe_delete(packet2);
  9245. }
  9246. }
  9247. }
  9248. else if (atoi(sep->arg[0]) == 25) {
  9249. if (sep->IsSet(1)) {
  9250. Widget* new_spawn = new Widget();
  9251. int32 id = atoul(sep->arg[1]);
  9252. new_spawn->SetWidgetID(id);
  9253. EQ2Packet* ret = new_spawn->serialize(client->GetPlayer(), client->GetVersion());
  9254. client->QueuePacket(ret);
  9255. int8 index = client->GetPlayer()->GetIndexForSpawn(new_spawn);
  9256. PacketStruct* packet2 = configReader.getStruct("WS_DestroyGhostCmd", client->GetVersion());
  9257. if (packet2) {
  9258. packet2->setDataByName("spawn_index", index);
  9259. packet2->setDataByName("delete", 1);
  9260. EQ2Packet* app = packet2->serialize();
  9261. client->QueuePacket(app);
  9262. safe_delete(packet2);
  9263. }
  9264. }
  9265. }
  9266. else if (atoi(sep->arg[0]) == 26) {
  9267. if (sep->IsSet(4)) {
  9268. Widget* new_spawn = new Widget();
  9269. int32 id = atoul(sep->arg[1]);
  9270. new_spawn->SetWidgetID(id);
  9271. float x = atof(sep->arg[2]);
  9272. float y = atof(sep->arg[3]);
  9273. float z = atof(sep->arg[4]);
  9274. new_spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  9275. new_spawn->SetWidgetX(x);
  9276. new_spawn->SetWidgetY(y);
  9277. new_spawn->SetWidgetZ(z);
  9278. new_spawn->SetX(x);
  9279. new_spawn->SetY(y);
  9280. new_spawn->SetZ(z);
  9281. EQ2Packet* ret = new_spawn->serialize(client->GetPlayer(), client->GetVersion());
  9282. client->QueuePacket(ret);
  9283. }
  9284. }
  9285. else if (atoi(sep->arg[0]) == 27) {
  9286. Spawn* target = client->GetPlayer()->GetTarget();
  9287. PacketStruct* packet2 = configReader.getStruct("WS_HearSimpleDamage", client->GetVersion());
  9288. if (packet2 && target && sep->IsSet(2)) {
  9289. packet2->setSubstructDataByName("header", "defender", client->GetPlayer()->GetIDWithPlayerSpawn(target));
  9290. packet2->setSubstructDataByName("header", "defender_proxy", client->GetPlayer()->GetIDWithPlayerSpawn(target));
  9291. packet2->setSubstructDataByName("header", "attacker", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  9292. packet2->setArrayLengthByName("num_dmg", 1);
  9293. packet2->setArrayDataByName("damage_type", atoi(sep->arg[1]));
  9294. packet2->setArrayDataByName("damage", atoi(sep->arg[2]));
  9295. packet2->setDataByName("spell", 1);
  9296. packet2->setDataByName("spell_name", "Testing");
  9297. EQ2Packet* app = packet2->serialize();
  9298. if (sep->IsSet(4)) {
  9299. int16 offset = atoi(sep->arg[3]);
  9300. uchar* ptr2 = app->pBuffer;
  9301. ptr2 += offset;
  9302. if (sep->IsNumber(4)) {
  9303. int32 value1 = atol(sep->arg[4]);
  9304. if (value1 > 0xFFFF)
  9305. memcpy(ptr2, (uchar*)&value1, 4);
  9306. else if (value1 > 0xFF)
  9307. memcpy(ptr2, (uchar*)&value1, 2);
  9308. else
  9309. memcpy(ptr2, (uchar*)&value1, 1);
  9310. }
  9311. else {
  9312. int8 len = strlen(sep->arg[4]);
  9313. memcpy(ptr2, (uchar*)&len, 1);
  9314. ptr2 += 1;
  9315. memcpy(ptr2, sep->arg[4], len);
  9316. }
  9317. }
  9318. if (sep->IsSet(6)) {
  9319. int16 offset = atoi(sep->arg[5]);
  9320. uchar* ptr2 = app->pBuffer;
  9321. ptr2 += offset;
  9322. if (sep->IsNumber(6)) {
  9323. int32 value1 = atol(sep->arg[6]);
  9324. if (value1 > 0xFFFF)
  9325. memcpy(ptr2, (uchar*)&value1, 4);
  9326. else if (value1 > 0xFF)
  9327. memcpy(ptr2, (uchar*)&value1, 2);
  9328. else
  9329. memcpy(ptr2, (uchar*)&value1, 1);
  9330. }
  9331. else {
  9332. int8 len = strlen(sep->arg[6]);
  9333. memcpy(ptr2, (uchar*)&len, 1);
  9334. ptr2 += 1;
  9335. memcpy(ptr2, sep->arg[6], len);
  9336. }
  9337. }
  9338. DumpPacket(app);
  9339. client->QueuePacket(app);
  9340. safe_delete(packet2);
  9341. }
  9342. }
  9343. else if (atoi(sep->arg[0]) == 28 && sep->IsNumber(1)) {
  9344. World::newValue = strtoull(sep->arg[1], NULL, 0);
  9345. }
  9346. }
  9347. else {
  9348. PacketStruct* packet2 = configReader.getStruct("WS_ExamineSpellInfo", client->GetVersion());
  9349. if (packet2) {
  9350. packet2->setSubstructDataByName("info_header", "show_name", 1);
  9351. packet2->setSubstructDataByName("info_header", "unknown", 7);
  9352. packet2->setSubstructDataByName("info_header", "unknown2", 1);
  9353. packet2->setSubstructDataByName("info_header", "unknown3", 1);
  9354. packet2->setSubstructDataByName("info_header", "unknown4", 1);
  9355. packet2->setSubstructDataByName("info_header", "unknown5", 1);
  9356. packet2->setSubstructDataByName("info_header", "unknown6", "Testing");
  9357. packet2->setSubstructDataByName("info_header", "unknown7", "Testing");
  9358. packet2->setSubstructDataByName("info_header", "unknown8", 66);
  9359. packet2->setSubstructDataByName("info_header", "title", "Blah Title Blah");
  9360. packet2->setSubstructDataByName("info_header", "title_text", "Blah Blah");
  9361. packet2->setSubstructDataByName("info_header", "title_text2", "Blah Blah2");
  9362. packet2->setSubstructDataByName("info_header", "show_popup", 1);
  9363. packet2->setSubstructDataByName("info_header", "packettype", 3);
  9364. packet2->setSubstructDataByName("spell_info", "skill_name", "Testing");
  9365. packet2->setSubstructDataByName("spell_info", "level", 19);
  9366. packet2->setSubstructDataByName("spell_info", "tier", 1);
  9367. packet2->setSubstructDataByName("spell_info", "health_cost", 5);
  9368. packet2->setSubstructDataByName("spell_info", "min_class_skill_req", 3);
  9369. packet2->setSubstructDataByName("spell_info", "mana_cost", 6);
  9370. packet2->setSubstructDataByName("spell_info", "req_concentration", 7);
  9371. packet2->setSubstructDataByName("spell_info", "cast_time", 200);
  9372. packet2->setSubstructDataByName("spell_info", "recovery", 220);
  9373. packet2->setSubstructDataByName("spell_info", "recast", 280);
  9374. packet2->setSubstructDataByName("spell_info", "beneficial", 1);
  9375. packet2->setSubstructDataByName("spell_info", "maintained", 1);
  9376. packet2->setSubstructDataByName("spell_info", "spell_book_type", 1);
  9377. packet2->setSubstructDataByName("spell_info", "quality", 3);
  9378. packet2->setSubstructDataByName("spell_info", "test_1a", 1);
  9379. packet2->setSubstructDataByName("spell_info", "test_1b", 1);
  9380. packet2->setSubstructDataByName("spell_info", "test_1c", 1);
  9381. packet2->setSubstructDataByName("spell_info", "test_1d", 1);
  9382. packet2->setSubstructDataByName("spell_info", "test_2a", 2);
  9383. packet2->setSubstructDataByName("spell_info", "test_2b", 2);
  9384. packet2->setSubstructDataByName("spell_info", "test_2c", 2);
  9385. packet2->setSubstructDataByName("spell_info", "test_2d", 2);
  9386. packet2->setSubstructDataByName("spell_info", "test_3", 3);
  9387. packet2->setSubstructDataByName("spell_info", "test_4", 4);
  9388. packet2->setSubstructDataByName("spell_info", "test_5", 5);
  9389. packet2->setSubstructDataByName("spell_info", "test_6", 6);
  9390. packet2->setSubstructDataByName("spell_info", "min_class_skill_req", 1);
  9391. packet2->setSubstructDataByName("spell_info", "min_class_skill_rec", 30123);
  9392. packet2->setSubstructDataByName("spell_info", "num_reagents", 1);
  9393. packet2->setSubstructArrayLengthByName("spell_info", "num_reagents", 1);
  9394. packet2->setArrayDataByName("reagent", "Alcohol");
  9395. packet2->setArrayDataByName("consumed", "123");
  9396. packet2->setSubstructDataByName("spell_info", "class_skill", 52);
  9397. packet2->setSubstructDataByName("spell_info", "id", 8308);
  9398. packet2->setSubstructDataByName("spell_info", "icon", 303);
  9399. packet2->setSubstructDataByName("spell_info", "icon2", 0xFFFF);
  9400. packet2->setSubstructDataByName("spell_info", "icontype", 317);
  9401. packet2->setSubstructDataByName("spell_info", "type", 2);
  9402. packet2->setSubstructDataByName("spell_info", "spell_text_color", 255);
  9403. packet2->setSubstructDataByName("spell_info", "duration1", 600);
  9404. packet2->setSubstructDataByName("spell_info", "duration2", 600);
  9405. packet2->setSubstructDataByName("spell_info", "name", "Sprint");
  9406. packet2->setSubstructDataByName("spell_info", "description", "Test description");
  9407. EQ2Packet* outapp = packet2->serialize();
  9408. DumpPacket(outapp);
  9409. client->QueuePacket(outapp);
  9410. safe_delete(packet2);
  9411. }
  9412. }
  9413. return;
  9414. PacketStruct* p = configReader.getStruct("WS_EqTargetItemCmd", client->GetVersion());
  9415. if (!p) return;
  9416. //Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  9417. //client->GetCurrentZone()->SendSpellFailedPacket(client, atoi(sep2->arg[0]));
  9418. //}
  9419. /*Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  9420. if (sep2 && sep2->arg[0] && sep2->IsNumber(0)) {
  9421. client->SetPendingFlightPath(atoi(sep2->arg[0]));
  9422. PacketStruct* packet = configReader.getStruct("WS_ReadyForTakeOff", client->GetVersion());
  9423. if (packet) {
  9424. client->QueuePacket(packet->serialize());
  9425. safe_delete(packet);
  9426. }
  9427. }*/
  9428. /*if (client->GetCurrentZone()->Grid != nullptr) {
  9429. int32 numFaces = 0;
  9430. int32 numGrids = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.size();
  9431. client->Message(CHANNEL_COLOR_YELLOW, "Num grids in cell: %u", numGrids);
  9432. map<int32, vector<Face*> >::iterator itr;
  9433. for (itr = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.begin(); itr != client->GetPlayer()->Cell_Info.CurrentCell->FaceList.end(); itr++)
  9434. numFaces += (*itr).second.size();
  9435. client->Message(CHANNEL_COLOR_YELLOW, "Num faces in cell: %u", numFaces);
  9436. }*/
  9437. //uchar blah[] = {
  9438. // 1208 - OP_EQUpdateStoreCmd
  9439. // /*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
  9440. // /*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
  9441. // 1193 - -- OP_ClientCmdMsg::OP_EqUpdateMerchantCmd --
  9442. // /*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
  9443. /*};
  9444. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  9445. int8 val = 0;
  9446. int16 pos = 0;
  9447. int idx = 0;
  9448. while(sep2 && sep2->arg[idx+1] && sep2->IsNumber(idx) && sep2->IsNumber(idx+1)){
  9449. pos = atoi(sep2->arg[idx]);
  9450. val = atoi(sep2->arg[idx+1]);
  9451. memset(blah+pos, val, 1);
  9452. idx+=2;
  9453. }
  9454. DumpPacket(blah, sizeof(blah));
  9455. client->QueuePacket(new EQ2Packet(OP_GroupCreatedMsg , blah, sizeof(blah)));*/
  9456. if (client->GetPlayer()->GetTarget()) {
  9457. PacketStruct* packet = configReader.getStruct("WS_SetControlGhost", client->GetVersion());
  9458. if (packet) {
  9459. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  9460. packet->setDataByName("size", 0);
  9461. packet->setDataByName("unknown2", 0);
  9462. EQ2Packet* app = packet->serialize();
  9463. client->QueuePacket(app);
  9464. safe_delete(packet);
  9465. }
  9466. PacketStruct* set_pov = configReader.getStruct("WS_SetPOVGhostCmd", client->GetVersion());
  9467. if (set_pov) {
  9468. set_pov->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  9469. EQ2Packet* app_pov = set_pov->serialize();
  9470. client->QueuePacket(app_pov);
  9471. safe_delete(set_pov);
  9472. }
  9473. }
  9474. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  9475. PacketStruct* packet = configReader.getStruct("WS_OpenCharCust", client->GetVersion());
  9476. if (packet) {
  9477. if (sep2 && sep2->arg[0] && sep2->IsNumber(0))
  9478. packet->setDataByName("Type", atoi(sep2->arg[0]));
  9479. else
  9480. packet->setDataByName("Type", 2);
  9481. if (sep2 && sep2->arg[1] && sep2->IsNumber(1))
  9482. packet->setDataByName("race_id", atoi(sep2->arg[1]));
  9483. else
  9484. packet->setDataByName("race_id", 0);
  9485. if (sep2 && sep2->arg[2] && sep2->IsNumber(2))
  9486. packet->setDataByName("gender", atoi(sep2->arg[2]));
  9487. else
  9488. packet->setDataByName("gender", 2);
  9489. if (sep2 && sep2->arg[3] && sep2->IsNumber(3))
  9490. packet->setDataByName("unknown", atoi(sep2->arg[3]), 0);
  9491. else
  9492. packet->setDataByName("unknown", 0, 0);
  9493. if (sep2 && sep2->arg[4] && sep2->IsNumber(4))
  9494. packet->setDataByName("unknown", atoi(sep2->arg[4]), 1);
  9495. else
  9496. packet->setDataByName("unknown", 0, 1);
  9497. if (sep2 && sep2->arg[5] && sep2->IsNumber(5))
  9498. packet->setDataByName("unknown", atoi(sep2->arg[5]), 2);
  9499. else
  9500. packet->setDataByName("unknown", 0, 2);
  9501. client->QueuePacket(packet->serialize());
  9502. }
  9503. safe_delete(packet);
  9504. safe_delete(sep2);
  9505. }
  9506. void Commands::Command_LeaveChannel(Client *client, Seperator *sep) {
  9507. const char *channel_name;
  9508. if (sep == NULL || !sep->IsSet(0)) {
  9509. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /leavechat <channel name>");
  9510. PrintSep(sep);
  9511. return;
  9512. }
  9513. channel_name = sep->arg[0];
  9514. if (!chat.IsInChannel(client, channel_name))
  9515. client->Message(CHANNEL_NARRATIVE, "Unable to leave '%s': You are not in the channel.", channel_name);
  9516. else if (!chat.LeaveChannel(client, channel_name))
  9517. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an internal error preventing you from leaving that channel MUAHAHA");
  9518. }
  9519. /*
  9520. Function:
  9521. Purpose :
  9522. Params :
  9523. Dev :
  9524. Example :
  9525. */
  9526. void Commands::Command_WeaponStats(Client* client)
  9527. {
  9528. Player* player = client->GetPlayer();
  9529. Item* primary = player->GetEquipmentList()->GetItem(EQ2_PRIMARY_SLOT);
  9530. Item* secondary = player->GetEquipmentList()->GetItem(EQ2_SECONDARY_SLOT);
  9531. Item* ranged = player->GetEquipmentList()->GetItem(EQ2_RANGE_SLOT);
  9532. client->SimpleMessage(0, "Primary:");
  9533. if (primary) {
  9534. client->Message(0, "Name: %s", primary->name.c_str());
  9535. client->Message(0, "Base Damage: %u - %u", primary->weapon_info->damage_low3, primary->weapon_info->damage_high3);
  9536. client->Message(0, "Actual Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  9537. client->Message(0, "Actual Delay: %u", player->GetPrimaryWeaponDelay());
  9538. client->Message(0, "Proc Percent: %d%%", 0);
  9539. client->Message(0, "Procs Per Minute: %d", 0);
  9540. }
  9541. else {
  9542. client->SimpleMessage(0, "Name: fist");
  9543. client->Message(0, "Base Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  9544. client->Message(0, "Actual Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  9545. client->Message(0, "Actual Delay: %d", player->GetPrimaryWeaponDelay() * 0.1);
  9546. client->Message(0, "Proc Percent: %d%%", 0);
  9547. client->Message(0, "Procs Per Minute: %d", 0);
  9548. }
  9549. client->SimpleMessage(0, " ");
  9550. client->SimpleMessage(0, " ");
  9551. if (secondary) {
  9552. client->SimpleMessage(0, "Secondary:");
  9553. client->Message(0, "Name: %s", secondary->name.c_str());
  9554. client->Message(0, "Base Damage: %u - %u", secondary->weapon_info->damage_low3, secondary->weapon_info->damage_high3);
  9555. client->Message(0, "Actual Damage: %u - %u", player->GetSecondaryWeaponMinDamage(), player->GetSecondaryWeaponMaxDamage());
  9556. client->Message(0, "Actual Delay: %d", player->GetSecondaryWeaponDelay() * 0.1);
  9557. client->Message(0, "Proc Percent: %d%%", 0);
  9558. client->Message(0, "Procs Per Minute: %d", 0);
  9559. client->SimpleMessage(0, " ");
  9560. client->SimpleMessage(0, " ");
  9561. }
  9562. client->SimpleMessage(0, "Ranged:");
  9563. if (ranged) {
  9564. client->Message(0, "Name: %s", ranged->name.c_str());
  9565. client->Message(0, "Base Damage: %u - %u", ranged->ranged_info->weapon_info.damage_low3, ranged->ranged_info->weapon_info.damage_high3);
  9566. client->Message(0, "Actual Damage: %u - %u", player->GetRangedWeaponMinDamage(), player->GetRangedWeaponMaxDamage());
  9567. client->Message(0, "Actual Delay: %d", player->GetRangeWeaponDelay() * 0.1);
  9568. client->Message(0, "Proc Percent: %d%%", 0);
  9569. client->Message(0, "Procs Per Minute: %d", 0);
  9570. }
  9571. else
  9572. client->SimpleMessage(0, "None");
  9573. }
  9574. void Commands::Command_WhoChannel(Client *client, Seperator *sep) {
  9575. const char *channel_name;
  9576. if (sep == NULL || !sep->IsSet(0)) {
  9577. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /chatwho <channel name>");
  9578. return;
  9579. }
  9580. channel_name = sep->arg[0];
  9581. if (!chat.ChannelExists(channel_name))
  9582. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That channel does not exist!");
  9583. else
  9584. chat.SendChannelUserList(client, channel_name);
  9585. }
  9586. void Commands::Command_ZoneSafeCoords(Client *client, Seperator *sep)
  9587. {
  9588. ZoneServer* zone = 0;
  9589. int32 zone_id = client->GetPlayer()->GetZone()->GetZoneID();
  9590. if (zone_id > 0)
  9591. {
  9592. zone = zone_list.Get(zone_id, false);
  9593. if (zone)
  9594. {
  9595. zone->SetSafeX(client->GetPlayer()->GetX());
  9596. zone->SetSafeY(client->GetPlayer()->GetY());
  9597. zone->SetSafeZ(client->GetPlayer()->GetZ());
  9598. zone->SetSafeHeading(client->GetPlayer()->GetHeading());
  9599. if( database.SaveZoneSafeCoords(zone_id, zone->GetSafeX(), zone->GetSafeY(), zone->GetSafeZ(), zone->GetSafeHeading()) )
  9600. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Zone safe coordinates updated!");
  9601. else
  9602. client->SimpleMessage(CHANNEL_COLOR_RED, "FAILED to update zone safe coordinates!");
  9603. }
  9604. }
  9605. }
  9606. /*
  9607. Function:
  9608. Purpose :
  9609. Params :
  9610. Dev :
  9611. Example :
  9612. */
  9613. void Commands::Command_ZoneDetails(Client* client, Seperator* sep)
  9614. {
  9615. ZoneInfo* zone_info = new ZoneInfo;
  9616. if (sep && sep->arg[0])
  9617. {
  9618. if (sep->IsNumber(0))
  9619. zone_info->id = atoi(sep->arg[0]);
  9620. else
  9621. zone_info->id = database.GetZoneID(sep->arg[0]);
  9622. if (zone_info->id > 0)
  9623. {
  9624. database.LoadZoneInfo(zone_info);
  9625. 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);
  9626. 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);
  9627. 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);
  9628. 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);
  9629. 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);
  9630. 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);
  9631. 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);
  9632. client->Message(CHANNEL_COLOR_YELLOW, "zone_type: %s, sky_file: %s", zone_info->zone_type, zone_info->sky_file);
  9633. client->Message(CHANNEL_COLOR_YELLOW, "lua_script: %s", zone_info->lua_script);
  9634. client->Message(CHANNEL_COLOR_YELLOW, "zone_motd: %s", zone_info->zone_motd);
  9635. }
  9636. else
  9637. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  9638. }
  9639. else
  9640. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone details [zone id|zone name]");
  9641. safe_delete(zone_info);
  9642. }
  9643. /*
  9644. Function:
  9645. Purpose :
  9646. Params :
  9647. Dev :
  9648. Example :
  9649. */
  9650. void Commands::Command_ZoneSet(Client* client, Seperator* sep)
  9651. {
  9652. if (sep && sep->arg[0] && sep->arg[1] && sep->arg[2])
  9653. {
  9654. ZoneServer* zone = 0;
  9655. int32 zone_id = 0;
  9656. if (sep->IsNumber(0) && atoi(sep->arg[0]) > 0)
  9657. {
  9658. zone_id = atoi(sep->arg[0]);
  9659. zone = zone_list.Get(atoi(sep->arg[0]), false);
  9660. }
  9661. else
  9662. {
  9663. zone_id = database.GetZoneID(sep->arg[0]);
  9664. if (zone_id > 0)
  9665. zone = zone_list.Get(sep->arg[0], false);
  9666. }
  9667. if (zone_id > 0)
  9668. {
  9669. if (zone_set_values.count(string(sep->arg[1])) > 0)
  9670. SetZoneCommand(client, zone_id, zone, zone_set_values[sep->arg[1]], sep->arg[2]);
  9671. else
  9672. client->Message(CHANNEL_COLOR_YELLOW, "The attribute '%s' is not valid.", sep->arg[1]);
  9673. }
  9674. else
  9675. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  9676. }
  9677. else
  9678. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone set [zone id|zone name] [attribute] [value]");
  9679. }
  9680. void Commands::Command_Rain(Client* client, Seperator* sep) {
  9681. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  9682. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /rain <float>");
  9683. return;
  9684. }
  9685. client->Message(CHANNEL_COLOR_YELLOW,"Setting rain to %.2f", atof(sep->arg[0]));
  9686. client->GetCurrentZone()->SetRain(atof(sep->arg[0]));
  9687. client->GetCurrentZone()->SetCurrentWeather(atof(sep->arg[0]));
  9688. }
  9689. void Commands::Command_Wind(Client* client, Seperator* sep) {
  9690. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  9691. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /wind <float>");
  9692. return;
  9693. }
  9694. client->Message(CHANNEL_COLOR_YELLOW, "Setting wind to %.2f", atof(sep->arg[0]));
  9695. client->GetCurrentZone()->SetWind(atof(sep->arg[0]));
  9696. }
  9697. void Commands::Command_SendMerchantWindow(Client* client, Seperator* sep, bool sell) {
  9698. Spawn* spawn = client->GetPlayer()->GetTarget();
  9699. if(spawn) {
  9700. client->SetMerchantTransaction(spawn);
  9701. if (spawn->GetMerchantID() > 0 && spawn->IsClientInMerchantLevelRange(client)){
  9702. client->SendHailCommand(spawn);
  9703. //MerchantFactionMultiplier* multiplier = world.GetMerchantMultiplier(spawn->GetMerchantID());
  9704. //if(!multiplier || (multiplier && client->GetPlayer()->GetFactions()->GetFactionValue(multiplier->faction_id) >= multiplier->faction_min)){
  9705. client->SendBuyMerchantList(sell);
  9706. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY))
  9707. client->SendSellMerchantList(sell);
  9708. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY_BACK))
  9709. client->SendBuyBackList(sell);
  9710. PacketStruct* packet = configReader.getStruct("WS_UpdateMerchant", client->GetVersion());
  9711. if (packet) {
  9712. packet->setDataByName("spawn_id", 0xFFFFFFFF);
  9713. packet->setDataByName("type", 16);
  9714. EQ2Packet* outapp = packet->serialize();
  9715. if (outapp)
  9716. client->QueuePacket(outapp);
  9717. safe_delete(packet);
  9718. }
  9719. }
  9720. if (spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR)
  9721. client->SendRepairList();
  9722. }
  9723. // client->SimpleMessage(CHANNEL_COLOR_RED, "Your faction is too low to use this merchant.");
  9724. }
  9725. void Commands::Command_Weather(Client* client, Seperator* sep)
  9726. {
  9727. //PrintSep(sep, "Weather");
  9728. if( sep && sep->arg[0] )
  9729. {
  9730. ZoneServer* zsZone = client->GetCurrentZone();
  9731. const char* value = sep->arg[0];
  9732. // process single-param commands first
  9733. if( strncasecmp(value, "details", strlen(value)) == 0 )
  9734. {
  9735. client->Message(CHANNEL_COLOR_YELLOW, "Weather Details for zone %s: ", zsZone->GetZoneName());
  9736. client->Message(CHANNEL_COLOR_YELLOW, "enabled: %i, allowed: %i, type: %i, frequency: %u", zsZone->isWeatherEnabled(), zsZone->isWeatherAllowed(), zsZone->GetWeatherType(), zsZone->GetWeatherFrequency());
  9737. client->Message(CHANNEL_COLOR_YELLOW, "severity: %.2f = %.2f, current: %.2f", zsZone->GetWeatherMinSeverity(), zsZone->GetWeatherMaxSeverity(), zsZone->GetCurrentWeather());
  9738. client->Message(CHANNEL_COLOR_YELLOW, "pattern: %i, chance: %i, amount: %.2f, offset: %.2f", zsZone->GetWeatherPattern(), zsZone->GetWeatherChance(), zsZone->GetWeatherChangeAmount(), zsZone->GetWeatherDynamicOffset());
  9739. }
  9740. else if( strncasecmp(value, "process", strlen(value)) == 0 )
  9741. {
  9742. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  9743. zsZone->ProcessWeather();
  9744. }
  9745. else if( strncasecmp(value, "reset", strlen(value)) == 0 )
  9746. {
  9747. zsZone->SetWeatherType(rule_manager.GetGlobalRule(R_Zone, WeatherType)->GetInt8());
  9748. zsZone->SetWeatherFrequency(rule_manager.GetGlobalRule(R_Zone, WeatherChangeFrequency)->GetInt32());
  9749. zsZone->SetWeatherMinSeverity(rule_manager.GetGlobalRule(R_Zone, MinWeatherSeverity)->GetFloat());
  9750. zsZone->SetWeatherMaxSeverity(rule_manager.GetGlobalRule(R_Zone, MaxWeatherSeverity)->GetFloat());
  9751. zsZone->SetCurrentWeather(zsZone->GetWeatherMinSeverity());
  9752. zsZone->SetWeatherPattern(1);
  9753. zsZone->SetWeatherChance(rule_manager.GetGlobalRule(R_Zone, WeatherChangeChance)->GetInt8());
  9754. zsZone->SetWeatherChangeAmount(rule_manager.GetGlobalRule(R_Zone, WeatherChangePerInterval)->GetFloat());
  9755. zsZone->SetWeatherDynamicOffset(rule_manager.GetGlobalRule(R_Zone, WeatherDynamicMaxOffset)->GetFloat());
  9756. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  9757. zsZone->ProcessWeather();
  9758. }
  9759. // process commands with params
  9760. if( sep->arg[1] )
  9761. {
  9762. if( strncasecmp(value, "enable", strlen(value)) == 0 && sep->IsNumber(1) )
  9763. zsZone->SetWeatherEnabled( ( atoi(sep->arg[1]) == 1 ) ? true : false );
  9764. else if( strncasecmp(value, "type", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 3) )
  9765. zsZone->SetWeatherType(atoi(sep->arg[1]));
  9766. else if( strncasecmp(value, "frequency", strlen(value)) == 0 && sep->IsNumber(1))
  9767. zsZone->SetWeatherFrequency( atoul(sep->arg[1]) );
  9768. else if( strncasecmp(value, "range", strlen(value)) == 0 && sep->IsNumber(1) && sep->IsNumber(2) ) {
  9769. zsZone->SetWeatherMinSeverity(atof(sep->arg[1]));
  9770. zsZone->SetWeatherMaxSeverity(atof(sep->arg[2]));
  9771. zsZone->SetRain(zsZone->GetWeatherMinSeverity());
  9772. }
  9773. else if( strncasecmp(value, "current", strlen(value)) == 0 && sep->IsNumber(1) ) {
  9774. zsZone->SetCurrentWeather(atof(sep->arg[1]));
  9775. zsZone->SetRain(zsZone->GetCurrentWeather());
  9776. }
  9777. else if( strncasecmp(value, "pattern", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 2) )
  9778. zsZone->SetWeatherPattern( atoi(sep->arg[1]) );
  9779. else if( strncasecmp(value, "chance", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 100) )
  9780. zsZone->SetWeatherChance( atoi(sep->arg[1]) );
  9781. else if( strncasecmp(value, "amount", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  9782. zsZone->SetWeatherChangeAmount( atof(sep->arg[1]) );
  9783. else if( strncasecmp(value, "offset", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  9784. zsZone->SetWeatherDynamicOffset( atof(sep->arg[1]) );
  9785. }
  9786. }
  9787. else
  9788. {
  9789. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /weather [command] [param]");
  9790. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: enable (0|1), type (0-3), frequency (sec), range|current (0.0 - 1.0)");
  9791. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: details, process, pattern (0|1), chance (%), amount (float), offset (float)");
  9792. return;
  9793. }
  9794. }
  9795. void Commands::Command_Select(Client* client, Seperator* sep) {
  9796. if (sep && sep->arg[1]) {
  9797. Spawn* spawn = client->GetPlayer()->GetTarget();
  9798. if (spawn && strlen(sep->arg[1]) > 0)
  9799. client->GetCurrentZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_CUSTOM, client->GetPlayer(), sep->arg[1]);
  9800. }
  9801. }
  9802. /*
  9803. Function: Command_ConsumeFood()
  9804. Purpose : Consume Food/Drink and apply mods
  9805. Params : Slot ID - EQ2_FOOD_SLOT 22, EQ2_DRINK_SLOT 23
  9806. Dev : Zcoretri
  9807. Example : /consume_food 22
  9808. */
  9809. void Commands::Command_ConsumeFood(Client* client, Seperator* sep) {
  9810. if (sep && sep->arg[0] && sep->IsNumber(0))
  9811. {
  9812. Player* player = client->GetPlayer();
  9813. int8 slot = atoi(sep->arg[0]);
  9814. Item* item = player->GetEquipmentList()->GetItem(slot);
  9815. if(slot == 22 && player->GetSpellEffectBySpellType(SPELL_TYPE_FOOD))
  9816. {
  9817. client->Message(CHANNEL_NARRATIVE, "If you ate anymore you would explode!");
  9818. return;
  9819. }
  9820. else if (player->GetSpellEffectBySpellType(SPELL_TYPE_DRINK))
  9821. {
  9822. client->Message(CHANNEL_NARRATIVE, "If you drank anymore you would explode!");
  9823. return;
  9824. }
  9825. client->ConsumeFoodDrink(item, slot);
  9826. }
  9827. }
  9828. void Commands::Command_Aquaman(Client* client, Seperator* sep) {
  9829. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  9830. if (atoi(sep->arg[0]) == 1) {
  9831. client->GetPlayer()->GetInfoStruct()->set_vision(4);
  9832. client->GetPlayer()->GetInfoStruct()->set_breathe_underwater(1);
  9833. client->GetPlayer()->SetCharSheetChanged(true);
  9834. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Maybe you ought to stick to the shallow end until you know how to swim.");
  9835. }
  9836. else {
  9837. client->GetPlayer()->GetInfoStruct()->set_vision(0);
  9838. client->GetPlayer()->GetInfoStruct()->set_breathe_underwater(0);
  9839. client->GetPlayer()->SetCharSheetChanged(true);
  9840. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Aquaman mode turned off.");
  9841. }
  9842. }
  9843. else
  9844. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /aquaman [0|1]");
  9845. }
  9846. void Commands::Command_ReportBug(Client* client, Seperator* sep)
  9847. {
  9848. if(sep)
  9849. {
  9850. string data;
  9851. if(sep->arg[0]){
  9852. data = string(sep->arg[0]);
  9853. }
  9854. for(int i=1;i<sep->GetMaxArgNum();i++){
  9855. if(sep->arg[i])
  9856. data.append(" ").append(sep->arg[i]);
  9857. }
  9858. const char* target_name = 0;
  9859. int32 spawn_id = 0;
  9860. if(client->GetPlayer()->GetTarget())
  9861. {
  9862. target_name = client->GetPlayer()->GetTarget()->GetName();
  9863. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  9864. }
  9865. else
  9866. target_name = "N/A";
  9867. LogWrite(COMMAND__DEBUG, 1, "Command", "%s", data.c_str());
  9868. if(world.ReportBug(data, client->GetPlayer()->GetName(), client->GetAccountID(), target_name, spawn_id, client->GetCurrentZone()->GetZoneID()))
  9869. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully submitted bug.");
  9870. else
  9871. client->SimpleMessage(CHANNEL_COLOR_RED, "Error submitting bug.");
  9872. }
  9873. }
  9874. void Commands::Command_Attune_Inv(Client* client, Seperator* sep) {
  9875. PrintSep(sep, "Command_Attune_Inv");
  9876. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  9877. // Get the item index from the first parameter
  9878. int16 index = atoi(sep->arg[0]);
  9879. // Check to see if this is a valid item index for the player, if not exit out of the function
  9880. if (client->GetPlayer()->item_list.indexed_items.count(index) == 0) {
  9881. LogWrite(ITEM__DEBUG, 0, "Items", "%s has no item with an index of %i", client->GetPlayer()->GetName(), index);
  9882. return;
  9883. }
  9884. // Get the item
  9885. Item* item = client->GetPlayer()->item_list.indexed_items[index];
  9886. if(item) {
  9887. // Valid item lets check to make sure this item is attunable, if not return out
  9888. if (!item->CheckFlag(ATTUNEABLE)) {
  9889. LogWrite(ITEM__DEBUG, 0, "Items", "attune_inv called for an item that is not attunable (%s)", item->name.c_str());
  9890. return;
  9891. }
  9892. // Remove the attunable flag
  9893. item->generic_info.item_flags -= ATTUNEABLE;
  9894. // Set the attuned flag
  9895. item->generic_info.item_flags += ATTUNED;
  9896. // Flag this item for saving
  9897. item->save_needed = true;
  9898. client->QueuePacket(item->serialize(client->GetVersion(), false, client->GetPlayer()));
  9899. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), 0, -1); // appearance type??
  9900. EQ2Packet* outapp = 0;
  9901. for (int32 i=0;i<packets.size();i++) {
  9902. outapp = packets[i];
  9903. if(outapp)
  9904. client->QueuePacket(outapp);
  9905. }
  9906. }
  9907. }
  9908. }
  9909. void Commands::Command_Reset_Zone_Timer(Client* client, Seperator* sep) {
  9910. PrintSep(sep, "Command_Reset_Zone_Timer");
  9911. /*if (sep && sep->arg[0] && sep->IsNumber(0)) {
  9912. int32 db_id = atoul(sep->arg[0]);
  9913. InstanceData* data = client->GetPlayer()->GetCharacterInstances().FindInstanceByDBID(db_id);
  9914. if (data) {
  9915. // TODO: add a check to timers to ensure it can be reset
  9916. // Delete the character from the instance
  9917. database.DeleteCharacterFromInstance(client->GetPlayer()->GetCharacterID(), data->instance_id);
  9918. data->instance_id = 0;
  9919. // Update the success time and set to 0 so the player can enter it again
  9920. database.UpdateCharacterInstance(client->GetPlayer()->GetCharacterID(), data->zone_name, 0, 1, 0);
  9921. data->last_success_timestamp = 0;
  9922. }
  9923. }*/
  9924. }
  9925. void Commands::Command_Player(Client* client, Seperator* sep) {
  9926. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player syntax --");
  9927. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins");
  9928. }
  9929. void Commands::Command_Player_Coins(Client* client, Seperator* sep) {
  9930. // /player coins add 10
  9931. // /player coins add plat 10
  9932. Player* player = client->GetPlayer();
  9933. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  9934. player = (Player*)player->GetTarget();
  9935. if (sep && sep->arg[0] && sep->arg[1]) {
  9936. const char* action = sep->arg[0];
  9937. int64 value = 0;
  9938. if (strncasecmp(action, "add", strlen(action)) == 0) {
  9939. if (sep->IsNumber(1)) {
  9940. value = atoi64(sep->arg[1]);
  9941. player->AddCoins(value);
  9942. if (client->GetPlayer() == player)
  9943. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  9944. else {
  9945. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  9946. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  9947. }
  9948. return;
  9949. }
  9950. else if (sep->arg[2] && sep->IsNumber(2)) {
  9951. const char* type = sep->arg[1];
  9952. if (strncasecmp(type, "copper", strlen(type)) == 0) {
  9953. value = atoi64(sep->arg[2]);
  9954. }
  9955. else if (strncasecmp(type, "silver", strlen(type)) == 0) {
  9956. value = atoi64(sep->arg[2]) * 100;
  9957. }
  9958. else if (strncasecmp(type, "gold", strlen(type)) == 0) {
  9959. value = atoi64(sep->arg[2]) * 10000;
  9960. }
  9961. else if (strncasecmp(type, "plat", strlen(type)) == 0) {
  9962. value = atoi64(sep->arg[2]) * 1000000;
  9963. }
  9964. player->AddCoins(value);
  9965. if (client->GetPlayer() == player)
  9966. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  9967. else {
  9968. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  9969. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  9970. }
  9971. return;
  9972. }
  9973. }
  9974. }
  9975. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player coins syntax --");
  9976. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add [value] - adds the given number of coins to the player");
  9977. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add copper [value] - adds the given amount of copper to the player");
  9978. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add silver [value] - adds the given amount of silver to the player");
  9979. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add gold [value] - adds the given amount of gold to the player");
  9980. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add plat [value] - adds the given amount of platinum to the player");
  9981. }
  9982. void Commands::Command_AchievementAdd(Client* client, Seperator* sep) {
  9983. PrintSep(sep, "ACHIEVEMENT_ADD");
  9984. if (sep && sep->IsSet(0)) {
  9985. int32 spell_id = atoul(sep->arg[1]);
  9986. int8 spell_tier = 0;
  9987. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  9988. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  9989. // addspellbookentry here
  9990. if (spell_tier >= data->maxRank) {
  9991. return;
  9992. }
  9993. if (!spell_tier) {
  9994. spell_tier = 1;
  9995. }
  9996. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  9997. {
  9998. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  9999. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  10000. client->GetPlayer()->UnlockSpell(spell);
  10001. client->SendSpellUpdate(spell);
  10002. }
  10003. else
  10004. {
  10005. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1);
  10006. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  10007. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  10008. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  10009. client->GetPlayer()->UnlockSpell(spell);
  10010. client->SendSpellUpdate(spell);
  10011. }
  10012. // cast spell here
  10013. if (!spell_tier)
  10014. spell_tier = 1;
  10015. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  10016. if (spell) {
  10017. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  10018. }
  10019. }
  10020. else {
  10021. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  10022. }
  10023. master_aa_list.DisplayAA(client, 0, 0);
  10024. }
  10025. void Commands::Command_Editor(Client* client, Seperator* sep) {
  10026. PacketStruct* packet = configReader.getStruct("WS_ChoiceWindow", client->GetVersion());
  10027. if (packet) {
  10028. string url = string(rule_manager.GetGlobalRule(R_World, EditorURL)->GetString());
  10029. if (rule_manager.GetGlobalRule(R_World, EditorOfficialServer)->GetBool()) {
  10030. char command[255];
  10031. url = "browser " + url;
  10032. int32 spawn_id = 0;
  10033. int32 zone_id = 0;
  10034. string type;
  10035. if (client->GetCurrentZone())
  10036. zone_id = client->GetCurrentZone()->GetZoneID();
  10037. if (client->GetPlayer()->GetTarget()) {
  10038. Spawn* target = client->GetPlayer()->GetTarget();
  10039. if (target->IsWidget())
  10040. type = "widgets";
  10041. else if (target->IsSign())
  10042. type = "signs";
  10043. else if (target->IsObject())
  10044. type = "objects";
  10045. else if (target->IsNPC())
  10046. type = "npcs";
  10047. else if (target->IsGroundSpawn())
  10048. type = "ground";
  10049. else
  10050. type = "spawn";
  10051. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  10052. }
  10053. sprintf(command, url.c_str(), zone_id, type.c_str(), spawn_id);
  10054. packet->setDataByName("accept_command", command);
  10055. }
  10056. else if (rule_manager.GetGlobalRule(R_World, EditorIncludeID)->GetBool()) {
  10057. char command[255];
  10058. url = "browser " + url;
  10059. if (client->GetPlayer()->GetTarget())
  10060. sprintf(command, url.c_str(), client->GetPlayer()->GetTarget()->GetDatabaseID());
  10061. packet->setDataByName("accept_command", command);
  10062. }
  10063. else {
  10064. string command = "browser " + url;
  10065. packet->setDataByName("accept_command", command.c_str());
  10066. }
  10067. packet->setDataByName("text", "Open the web editor?");
  10068. packet->setDataByName("accept_text", "Open");
  10069. packet->setDataByName("cancel_text", "Cancel");
  10070. // No clue if we even need the following 2 unknowns, just added them so the packet matches what live sends
  10071. packet->setDataByName("unknown2", 50);
  10072. packet->setDataByName("unknown4", 1);
  10073. client->QueuePacket(packet->serialize());
  10074. safe_delete(packet);
  10075. }
  10076. }
  10077. void Commands::Command_AcceptResurrection(Client* client, Seperator* sep) {
  10078. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  10079. return;
  10080. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  10081. if(client->GetCurrentRez()->active)
  10082. client->AcceptResurrection();
  10083. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  10084. }
  10085. void Commands::Command_DeclineResurrection(Client* client, Seperator* sep) {
  10086. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  10087. return;
  10088. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  10089. if(client->GetCurrentRez()->active)
  10090. client->GetCurrentRez()->should_delete = true;
  10091. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  10092. }
  10093. void Commands::Switch_AA_Profile(Client* client, Seperator* sep) {
  10094. PrintSep(sep, "Switch_AA_Profile");
  10095. if (sep && sep->IsSet(0)) {
  10096. string type = sep->arg[0];
  10097. int8 newtemplate = atoul(sep->arg[1]);
  10098. master_aa_list.DisplayAA(client, newtemplate, 1);
  10099. }
  10100. }
  10101. void Commands::Get_AA_Xml(Client* client, Seperator* sep) {
  10102. PrintSep(sep, "Get_AA_Xml");
  10103. if (sep && sep->IsSet(0)) {
  10104. string tabnum = sep->arg[0];
  10105. string spellid = sep->arg[1];
  10106. }
  10107. }
  10108. void Commands::Add_AA(Client* client, Seperator* sep) {
  10109. PrintSep(sep, "Add_AA");
  10110. if (sep && sep->IsSet(0)) {
  10111. int32 spell_id = atoul(sep->arg[1]);
  10112. int8 spell_tier = 0;
  10113. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  10114. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  10115. // addspellbookentry here
  10116. if(!data) {
  10117. LogWrite(COMMAND__ERROR, 0, "Command", "Error in Add_AA no data for spell_id %u spell_tier %u", spell_id, spell_tier);
  10118. return;
  10119. }
  10120. if (spell_tier >= data->maxRank) {
  10121. LogWrite(COMMAND__ERROR, 0, "Command", "Error in Add_AA spell_tier %u >= maxRank %u", spell_tier, data->maxRank);
  10122. return;
  10123. }
  10124. if (!spell_tier) {
  10125. spell_tier = 1;
  10126. }
  10127. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  10128. {
  10129. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  10130. if(spell)
  10131. {
  10132. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  10133. client->GetPlayer()->UnlockSpell(spell);
  10134. client->SendSpellUpdate(spell);
  10135. }
  10136. }
  10137. else
  10138. {
  10139. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1 );
  10140. if(spell)
  10141. {
  10142. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  10143. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  10144. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  10145. client->GetPlayer()->UnlockSpell(spell);
  10146. client->SendSpellUpdate(spell);
  10147. }
  10148. }
  10149. // cast spell here
  10150. if (!spell_tier)
  10151. spell_tier = 1;
  10152. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  10153. if (spell) {
  10154. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  10155. }
  10156. }
  10157. else {
  10158. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  10159. }
  10160. master_aa_list.DisplayAA(client, 0, 0);
  10161. }
  10162. void Commands::Commit_AA_Profile(Client* client, Seperator* sep) {
  10163. PrintSep(sep, "Commit_AA_Profile");
  10164. if (sep && sep->IsSet(0)) {
  10165. }
  10166. }
  10167. void Commands::Begin_AA_Profile(Client* client, Seperator* sep) {
  10168. PrintSep(sep, "Begin_AA_Profile");
  10169. if (sep && sep->IsSet(0)) {
  10170. master_aa_list.DisplayAA(client, 100, 2);
  10171. }
  10172. }
  10173. void Commands::Back_AA(Client* client, Seperator* sep) {
  10174. if (sep && sep->IsSet(0)) {
  10175. PrintSep(sep, "Back_AA");
  10176. }
  10177. }
  10178. void Commands::Remove_AA(Client* client, Seperator* sep) {
  10179. if (sep && sep->IsSet(0)) {
  10180. PrintSep(sep, "Remove_AA");
  10181. }
  10182. }
  10183. void Commands::Cancel_AA_Profile(Client* client, Seperator* sep) {
  10184. MasterAAList master_aa_list;
  10185. PrintSep(sep, "Cancel_AA_Profile");
  10186. master_aa_list.DisplayAA(client, 0, 0);
  10187. }
  10188. void Commands::Save_AA_Profile(Client* client, Seperator* sep) {
  10189. if (sep && sep->IsSet(0)) {
  10190. PrintSep(sep, "Save_AA_Profile");
  10191. }
  10192. }
  10193. void Commands::Command_TargetItem(Client* client, Seperator* sep) {
  10194. if (!sep || sep->GetArgNumber() < 1 || !client->GetPlayer()) return;
  10195. if (!sep->IsNumber(0)) return;
  10196. int32 request_id = atoul(sep->arg[0]);
  10197. if (!sep->IsNumber(1)) return;
  10198. sint32 item_id = atoi(sep->arg[1]);
  10199. if (client->IsCurrentTransmuteID(request_id)) {
  10200. Transmute::HandleItemResponse(client, client->GetPlayer(), request_id, reinterpret_cast<int32&>(item_id));
  10201. }
  10202. else if (client->IsCurrentTransmuteID(item_id)) {
  10203. if (!sep->IsSet(2)) return;
  10204. if (sep->IsNumber(2) && atoi(sep->arg[2]) == 1) {
  10205. Transmute::HandleConfirmResponse(client, client->GetPlayer(), reinterpret_cast<int32&>(item_id));
  10206. }
  10207. }
  10208. }
  10209. void Commands::Command_FindSpawn(Client* client, Seperator* sep) {
  10210. if(sep)
  10211. client->GetCurrentZone()->FindSpawn(client, (char*)sep->argplus[0]);
  10212. }
  10213. void Commands::Command_MoveCharacter(Client* client, Seperator* sep) {
  10214. if(sep && sep->arg[0][0] && sep->arg[1][0])
  10215. {
  10216. char* name = sep->arg[0];
  10217. char* zoneName = sep->arg[1];
  10218. char query[256];
  10219. 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);
  10220. if (database.RunQuery(query, strnlen(query, 256)))
  10221. {
  10222. client->Message(CHANNEL_COLOR_YELLOW, "Ran query:%s", query);
  10223. }
  10224. else
  10225. client->Message(CHANNEL_COLOR_RED, "Query FAILED to run: %s", query);
  10226. }
  10227. }