Commands.cpp 467 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769
  1. /*
  2. EQ2Emulator: Everquest II Server Emulator
  3. Copyright (C) 2007 EQ2EMulator Development Team (http://www.eq2emulator.net)
  4. This file is part of EQ2Emulator.
  5. EQ2Emulator is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. EQ2Emulator is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with EQ2Emulator. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #include <sys/types.h>
  17. #include <boost/algorithm/string/predicate.hpp>
  18. #include <boost/algorithm/string.hpp>
  19. #include "Commands.h"
  20. #include "../ClientPacketFunctions.h"
  21. #include "../../common/version.h"
  22. #include "../../common/seperator.h"
  23. #include "../../common/servertalk.h"
  24. #include "../WorldDatabase.h"
  25. #include "../World.h"
  26. #include "../../common/ConfigReader.h"
  27. #include "../VisualStates.h"
  28. #include "../../common/debug.h"
  29. #include "../LuaInterface.h"
  30. #include "../Quests.h"
  31. #include "../client.h"
  32. #include "../NPC.h"
  33. #include "../Guilds/Guild.h"
  34. #include "../SpellProcess.h"
  35. #include "../Tradeskills/Tradeskills.h"
  36. #include "../../common/Log.h"
  37. #include "../../common/MiscFunctions.h"
  38. #include "../Languages.h"
  39. #include "../Traits/Traits.h"
  40. #include "../Chat/Chat.h"
  41. #include "../Rules/Rules.h"
  42. #include "../AltAdvancement/AltAdvancement.h"
  43. #include "../RaceTypes/RaceTypes.h"
  44. #include "../classes.h"
  45. #include "../Transmute.h"
  46. #include "../Bots/Bot.h"
  47. #include "../Web/PeerManager.h"
  48. extern WorldDatabase database;
  49. extern MasterSpellList master_spell_list;
  50. extern MasterTraitList master_trait_list;
  51. extern MasterRecipeList master_recipe_list;
  52. extern MasterRecipeBookList master_recipebook_list;
  53. extern World world;
  54. extern ClientList client_list;
  55. extern ConfigReader configReader;
  56. extern VisualStates visual_states;
  57. extern ZoneList zone_list;
  58. extern LuaInterface* lua_interface;
  59. extern MasterQuestList master_quest_list;
  60. extern MasterCollectionList master_collection_list;
  61. extern MasterSkillList master_skill_list;
  62. extern MasterFactionList master_faction_list;
  63. extern GuildList guild_list;
  64. extern MasterLanguagesList master_languages_list;
  65. extern Chat chat;
  66. extern RuleManager rule_manager;
  67. extern MasterAAList master_aa_list;
  68. extern MasterRaceTypeList race_types_list;
  69. extern Classes classes;
  70. extern PeerManager peer_manager;
  71. //devn00b: Fix for linux builds since we dont use stricmp we use strcasecmp
  72. #if defined(__GNUC__)
  73. #define stricmp strcasecmp
  74. #define strnicmp strncasecmp
  75. #endif
  76. EQ2Packet* RemoteCommands::serialize(int16 version){
  77. buffer.clear();
  78. vector<EQ2_RemoteCommandString>::iterator command_list;
  79. buffer.append((char*)&num_commands, sizeof(int16));
  80. for( command_list = commands.begin(); command_list != commands.end(); command_list++ ) {
  81. AddDataCommand(&(*command_list));
  82. }
  83. EQ2Packet* app = new EQ2Packet(OP_SetRemoteCmdsMsg, (uchar*)buffer.c_str(), buffer.length() + 1);
  84. return app;
  85. }
  86. Commands::Commands(){
  87. remote_commands = new RemoteCommands();
  88. spawn_set_values["list"] = SPAWN_SET_VALUE_LIST;
  89. spawn_set_values["name"] = SPAWN_SET_VALUE_NAME;
  90. spawn_set_values["level"] = SPAWN_SET_VALUE_LEVEL; // TODO: Fix this, min_level, max_level
  91. spawn_set_values["difficulty"] = SPAWN_SET_VALUE_DIFFICULTY;
  92. spawn_set_values["model_type"] = SPAWN_SET_VALUE_MODEL_TYPE;
  93. spawn_set_values["class"] = SPAWN_SET_VALUE_CLASS;
  94. spawn_set_values["gender"] = SPAWN_SET_VALUE_GENDER;
  95. spawn_set_values["show_name"] = SPAWN_SET_VALUE_SHOW_NAME;
  96. spawn_set_values["attackable"] = SPAWN_SET_VALUE_ATTACKABLE;
  97. spawn_set_values["show_level"] = SPAWN_SET_VALUE_SHOW_LEVEL;
  98. spawn_set_values["targetable"] = SPAWN_SET_VALUE_TARGETABLE;
  99. spawn_set_values["show_command_icon"] = SPAWN_SET_VALUE_SHOW_COMMAND_ICON;
  100. spawn_set_values["display_hand_icon"] = SPAWN_SET_VALUE_HAND_ICON;
  101. spawn_set_values["hair_type"] = SPAWN_SET_VALUE_HAIR_TYPE;
  102. spawn_set_values["facial_hair_type"] = SPAWN_SET_VALUE_FACIAL_HAIR_TYPE;
  103. spawn_set_values["wing_type"] = SPAWN_SET_VALUE_WING_TYPE;
  104. spawn_set_values["chest_type"] = SPAWN_SET_VALUE_CHEST_TYPE;
  105. spawn_set_values["legs_type"] = SPAWN_SET_VALUE_LEGS_TYPE;
  106. spawn_set_values["soga_hair_type"] = SPAWN_SET_VALUE_SOGA_HAIR_TYPE;
  107. spawn_set_values["soga_facial_hair_type"] = SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE;
  108. spawn_set_values["soga_model_type"] = SPAWN_SET_VALUE_SOGA_MODEL_TYPE;
  109. spawn_set_values["size"] = SPAWN_SET_VALUE_SIZE;
  110. spawn_set_values["hp"] = SPAWN_SET_VALUE_HP;
  111. spawn_set_values["power"] = SPAWN_SET_VALUE_POWER;
  112. spawn_set_values["heroic"] = SPAWN_SET_VALUE_HEROIC;
  113. spawn_set_values["respawn"] = SPAWN_SET_VALUE_RESPAWN;
  114. spawn_set_values["x"] = SPAWN_SET_VALUE_X;
  115. spawn_set_values["y"] = SPAWN_SET_VALUE_Y;
  116. spawn_set_values["z"] = SPAWN_SET_VALUE_Z;
  117. spawn_set_values["heading"] = SPAWN_SET_VALUE_HEADING;
  118. spawn_set_values["location"] = SPAWN_SET_VALUE_LOCATION;
  119. spawn_set_values["command_primary"] = SPAWN_SET_VALUE_COMMAND_PRIMARY;
  120. spawn_set_values["command_secondary"] = SPAWN_SET_VALUE_COMMAND_SECONDARY;
  121. spawn_set_values["visual_state"] = SPAWN_SET_VALUE_VISUAL_STATE;
  122. spawn_set_values["action_state"] = SPAWN_SET_VALUE_ACTION_STATE;
  123. spawn_set_values["mood_state"] = SPAWN_SET_VALUE_MOOD_STATE;
  124. spawn_set_values["initial_state"] = SPAWN_SET_VALUE_INITIAL_STATE;
  125. spawn_set_values["activity_state"] = SPAWN_SET_VALUE_ACTIVITY_STATE;
  126. spawn_set_values["collision_radius"] = SPAWN_SET_VALUE_COLLISION_RADIUS;
  127. spawn_set_values["faction"] = SPAWN_SET_VALUE_FACTION;
  128. spawn_set_values["spawn_script"] = SPAWN_SET_VALUE_SPAWN_SCRIPT;
  129. spawn_set_values["spawnentry_script"] = SPAWN_SET_VALUE_SPAWNENTRY_SCRIPT;
  130. spawn_set_values["spawnlocation_script"] = SPAWN_SET_VALUE_SPAWNLOCATION_SCRIPT;
  131. spawn_set_values["sub_title"] = SPAWN_SET_VALUE_SUB_TITLE;
  132. spawn_set_values["expire"] = SPAWN_SET_VALUE_EXPIRE;
  133. spawn_set_values["expire_offset"] = SPAWN_SET_VALUE_EXPIRE_OFFSET;
  134. spawn_set_values["x_offset"] = SPAWN_SET_VALUE_X_OFFSET;
  135. spawn_set_values["y_offset"] = SPAWN_SET_VALUE_Y_OFFSET;
  136. spawn_set_values["z_offset"] = SPAWN_SET_VALUE_Z_OFFSET;
  137. spawn_set_values["device_id"] = SPAWN_SET_VALUE_DEVICE_ID;
  138. spawn_set_values["pitch"] = SPAWN_SET_VALUE_PITCH;
  139. spawn_set_values["roll"] = SPAWN_SET_VALUE_ROLL;
  140. spawn_set_values["hide_hood"] = SPAWN_SET_VALUE_HIDE_HOOD;
  141. spawn_set_values["emote_state"] = SPAWN_SET_VALUE_EMOTE_STATE;
  142. spawn_set_values["icon"] = SPAWN_SET_VALUE_ICON;
  143. spawn_set_values["prefix"] = SPAWN_SET_VALUE_PREFIX;
  144. spawn_set_values["suffix"] = SPAWN_SET_VALUE_SUFFIX;
  145. spawn_set_values["lastname"] = SPAWN_SET_VALUE_LASTNAME;
  146. spawn_set_values["expansion_flag"] = SPAWN_SET_VALUE_EXPANSION_FLAG;
  147. spawn_set_values["holiday_flag"] = SPAWN_SET_VALUE_HOLIDAY_FLAG;
  148. spawn_set_values["merchant_min_level"] = SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL;
  149. spawn_set_values["merchant_max_level"] = SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL;
  150. spawn_set_values["skin_color"] = SPAWN_SET_SKIN_COLOR;
  151. spawn_set_values["aaxp_rewards"] = SPAWN_SET_AAXP_REWARDS;
  152. spawn_set_values["hair_color1"] = SPAWN_SET_HAIR_COLOR1;
  153. spawn_set_values["hair_color2"] = SPAWN_SET_HAIR_COLOR2;
  154. spawn_set_values["hair_type_color"] = SPAWN_SET_HAIR_TYPE_COLOR;
  155. spawn_set_values["hair_face_color"] = SPAWN_SET_HAIR_FACE_COLOR;
  156. spawn_set_values["hair_type_highlight_color"] = SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR;
  157. spawn_set_values["face_hairlight_color"] = SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR;
  158. spawn_set_values["hair_highlight"] = SPAWN_SET_HAIR_HIGHLIGHT;
  159. spawn_set_values["model_color"] = SPAWN_SET_MODEL_COLOR;
  160. spawn_set_values["eye_color"] = SPAWN_SET_EYE_COLOR;
  161. spawn_set_values["soga_skin_color"] = SPAWN_SET_SOGA_SKIN_COLOR;
  162. spawn_set_values["soga_hair_color1"] = SPAWN_SET_SOGA_HAIR_COLOR1;
  163. spawn_set_values["soga_hair_color2"] = SPAWN_SET_SOGA_HAIR_COLOR2;
  164. spawn_set_values["soga_hair_type_color"] = SPAWN_SET_SOGA_HAIR_TYPE_COLOR;
  165. spawn_set_values["soga_hair_face_color"] = SPAWN_SET_SOGA_HAIR_FACE_COLOR;
  166. spawn_set_values["soga_hair_type_highlight_color"] = SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR;
  167. spawn_set_values["soga_face_hairlight_color"] = SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR;
  168. spawn_set_values["soga_hair_highlight"] = SPAWN_SET_SOGA_HAIR_HIGHLIGHT;
  169. spawn_set_values["soga_model_color"] = SPAWN_SET_SOGA_MODEL_COLOR;
  170. spawn_set_values["soga_eye_color"] = SPAWN_SET_SOGA_EYE_COLOR;
  171. spawn_set_values["cheek_type"] = SPAWN_SET_CHEEK_TYPE;
  172. spawn_set_values["chin_type"] = SPAWN_SET_CHIN_TYPE;
  173. spawn_set_values["ear_type"] = SPAWN_SET_EAR_TYPE;
  174. spawn_set_values["eye_brow_type"] = SPAWN_SET_EYE_BROW_TYPE;
  175. spawn_set_values["eye_type"] = SPAWN_SET_EYE_TYPE;
  176. spawn_set_values["lip_type"] = SPAWN_SET_LIP_TYPE;
  177. spawn_set_values["nose_type"] = SPAWN_SET_NOSE_TYPE;
  178. spawn_set_values["body_size"] = SPAWN_SET_BODY_SIZE;
  179. spawn_set_values["body_age"] = SPAWN_SET_BODY_AGE;
  180. spawn_set_values["soga_cheek_type"] = SPAWN_SET_SOGA_CHEEK_TYPE;
  181. spawn_set_values["soga_chin_type"] = SPAWN_SET_SOGA_CHIN_TYPE;
  182. spawn_set_values["soga_ear_type"] = SPAWN_SET_SOGA_EAR_TYPE;
  183. spawn_set_values["soga_eye_brow_type"] = SPAWN_SET_SOGA_EYE_BROW_TYPE;
  184. spawn_set_values["soga_eye_type"] = SPAWN_SET_SOGA_EYE_TYPE;
  185. spawn_set_values["soga_lip_type"] = SPAWN_SET_SOGA_LIP_TYPE;
  186. spawn_set_values["soga_nose_type"] = SPAWN_SET_SOGA_NOSE_TYPE;
  187. spawn_set_values["soga_body_size"] = SPAWN_SET_SOGA_BODY_SIZE;
  188. spawn_set_values["soga_body_age"] = SPAWN_SET_SOGA_BODY_AGE;
  189. spawn_set_values["attack_type"] = SPAWN_SET_ATTACK_TYPE;
  190. spawn_set_values["race_type"] = SPAWN_SET_RACE_TYPE;
  191. spawn_set_values["loot_tier"] = SPAWN_SET_LOOT_TIER;
  192. spawn_set_values["loot_drop_type"] = SPAWN_SET_LOOT_DROP_TYPE;
  193. spawn_set_values["scared_strong_players"] = SPAWN_SET_SCARED_STRONG_PLAYERS;
  194. zone_set_values["expansion_id"] = ZONE_SET_VALUE_EXPANSION_ID;
  195. zone_set_values["name"] = ZONE_SET_VALUE_NAME;
  196. zone_set_values["file"] = ZONE_SET_VALUE_FILE ;
  197. zone_set_values["description"] = ZONE_SET_VALUE_DESCRIPTION;
  198. zone_set_values["safe_x"] = ZONE_SET_VALUE_SAFE_X;
  199. zone_set_values["safe_y"] = ZONE_SET_VALUE_SAFE_Y;
  200. zone_set_values["safe_z"] = ZONE_SET_VALUE_SAFE_Z;
  201. zone_set_values["underworld"] = ZONE_SET_VALUE_UNDERWORLD;
  202. zone_set_values["min_recommended"] = ZONE_SET_VALUE_MIN_RECOMMENDED;
  203. zone_set_values["max_recommended"] = ZONE_SET_VALUE_MAX_RECOMMENDED;
  204. zone_set_values["zone_type"] = ZONE_SET_VALUE_ZONE_TYPE;
  205. zone_set_values["always_loaded"] = ZONE_SET_VALUE_ALWAYS_LOADED;
  206. zone_set_values["city_zone"] = ZONE_SET_VALUE_CITY_ZONE;
  207. zone_set_values["weather_allowed"] = ZONE_SET_VALUE_WEATHER_ALLOWED;
  208. zone_set_values["min_status"] = ZONE_SET_VALUE_MIN_STATUS;
  209. zone_set_values["min_level"] = ZONE_SET_VALUE_MIN_LEVEL;
  210. zone_set_values["start_zone"] = ZONE_SET_VALUE_START_ZONE;
  211. zone_set_values["instance_type"] = ZONE_SET_VALUE_INSTANCE_TYPE;
  212. zone_set_values["default_reenter_time"] = ZONE_SET_VALUE_DEFAULT_REENTER_TIME;
  213. zone_set_values["default_reset_time"] = ZONE_SET_VALUE_DEFAULT_RESET_TIME;
  214. zone_set_values["default_lockout_time"] = ZONE_SET_VALUE_DEFAULT_LOCKOUT_TIME;
  215. zone_set_values["force_group_to_zone"] = ZONE_SET_VALUE_FORCE_GROUP_TO_ZONE;
  216. zone_set_values["lua_script"] = ZONE_SET_VALUE_LUA_SCRIPT;
  217. zone_set_values["shutdown_timer"] = ZONE_SET_VALUE_SHUTDOWN_TIMER;
  218. zone_set_values["zone_motd"] = ZONE_SET_VALUE_ZONE_MOTD;
  219. }
  220. Commands::~Commands() {
  221. safe_delete(remote_commands);
  222. }
  223. int32 Commands::GetSpawnSetType(string val){
  224. if(spawn_set_values.count(val) > 0)
  225. return spawn_set_values[val];
  226. return 0xFFFFFFFF;
  227. }
  228. bool Commands::SetSpawnCommand(Client* client, Spawn* target, int8 type, const char* value, bool send_update, bool temporary, string* temp_value, int8 index){
  229. if(!target)
  230. return false;
  231. int32 val = 0;
  232. try{
  233. if(type != SPAWN_SET_VALUE_NAME &&
  234. !(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))
  235. {
  236. switch(type)
  237. {
  238. case SPAWN_SET_SKIN_COLOR:
  239. case SPAWN_SET_HAIR_COLOR1:
  240. case SPAWN_SET_HAIR_COLOR2:
  241. case SPAWN_SET_HAIR_TYPE_COLOR:
  242. case SPAWN_SET_HAIR_FACE_COLOR:
  243. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  244. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  245. case SPAWN_SET_HAIR_HIGHLIGHT:
  246. case SPAWN_SET_EYE_COLOR:
  247. case SPAWN_SET_SOGA_SKIN_COLOR:
  248. case SPAWN_SET_SOGA_HAIR_COLOR1:
  249. case SPAWN_SET_SOGA_HAIR_COLOR2:
  250. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  251. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  252. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  253. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  254. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  255. case SPAWN_SET_SOGA_EYE_COLOR:
  256. case SPAWN_SET_RACE_TYPE:
  257. // ignore these are colors can't pass as a integer value
  258. break;
  259. default:
  260. val = atoul(value);
  261. }
  262. }
  263. }
  264. catch(...){
  265. if(client)
  266. client->Message(CHANNEL_COLOR_RED, "Invalid numeric spawn value: %s", value);
  267. return false;
  268. }
  269. if(temporary){
  270. char tmp[128] = {0};
  271. switch(type){
  272. case SPAWN_SET_VALUE_NAME:{
  273. sprintf(tmp, "%s", target->GetName());
  274. target->SetName(value);
  275. if(target->GetZone())
  276. target->GetZone()->SendUpdateTitles(target);
  277. break;
  278. }
  279. case SPAWN_SET_VALUE_X_OFFSET:
  280. {
  281. sprintf(tmp, "%f", target->GetXOffset());
  282. target->SetXOffset(float(val));
  283. break;
  284. }
  285. case SPAWN_SET_VALUE_Y_OFFSET:
  286. {
  287. sprintf(tmp, "%f", target->GetYOffset());
  288. target->SetYOffset(float(val));
  289. break;
  290. }
  291. case SPAWN_SET_VALUE_Z_OFFSET:
  292. {
  293. sprintf(tmp, "%f", target->GetZOffset());
  294. target->SetZOffset(float(val));
  295. break;
  296. }
  297. case SPAWN_SET_VALUE_EXPIRE: {
  298. sprintf(tmp, "%u", target->GetExpireTime());
  299. target->SetExpireTime(val);
  300. break;
  301. }
  302. case SPAWN_SET_VALUE_EXPIRE_OFFSET: {
  303. sprintf(tmp, "%u", target->GetExpireOffsetTime());
  304. target->SetExpireOffsetTime(val);
  305. break;
  306. }
  307. case SPAWN_SET_VALUE_SUB_TITLE: {
  308. sprintf(tmp, "%s", target->GetSubTitle());
  309. target->SetSubTitle(value);
  310. if(target->GetZone())
  311. target->GetZone()->SendUpdateTitles(target);
  312. break;
  313. }
  314. case SPAWN_SET_VALUE_LEVEL:{
  315. sprintf(tmp, "%i", target->GetLevel());
  316. target->SetLevel(val, send_update);
  317. break;
  318. }
  319. case SPAWN_SET_VALUE_DIFFICULTY:{
  320. sprintf(tmp, "%i", target->GetDifficulty());
  321. target->SetDifficulty(val, send_update);
  322. break;
  323. }
  324. case SPAWN_SET_VALUE_MODEL_TYPE:{
  325. sprintf(tmp, "%i", target->GetModelType());
  326. target->SetModelType(val, send_update);
  327. break;
  328. }
  329. case SPAWN_SET_VALUE_CLASS:{
  330. sprintf(tmp, "%i", target->GetAdventureClass());
  331. target->SetAdventureClass(val, send_update);
  332. break;
  333. }
  334. case SPAWN_SET_VALUE_GENDER:{
  335. sprintf(tmp, "%i", target->GetGender());
  336. target->SetGender(val, send_update);
  337. break;
  338. }
  339. case SPAWN_SET_VALUE_SHOW_NAME:{
  340. sprintf(tmp, "%i", target->GetShowName());
  341. target->SetShowName(val, send_update);
  342. break;
  343. }
  344. case SPAWN_SET_VALUE_ATTACKABLE:{
  345. sprintf(tmp, "%i", target->GetAttackable());
  346. target->SetAttackable(val, send_update);
  347. break;
  348. }
  349. case SPAWN_SET_VALUE_SHOW_LEVEL:{
  350. sprintf(tmp, "%i", target->GetShowLevel());
  351. target->SetShowLevel(val, send_update);
  352. break;
  353. }
  354. case SPAWN_SET_VALUE_TARGETABLE:{
  355. sprintf(tmp, "%i", target->GetTargetable());
  356. target->SetTargetable(val, send_update);
  357. break;
  358. }
  359. case SPAWN_SET_VALUE_SHOW_COMMAND_ICON:{
  360. sprintf(tmp, "%i", target->GetShowCommandIcon());
  361. target->SetShowCommandIcon(val, send_update);
  362. break;
  363. }
  364. case SPAWN_SET_VALUE_HAND_ICON:{
  365. sprintf(tmp, "%i", target->GetShowHandIcon());
  366. target->SetShowHandIcon(val, send_update);
  367. break;
  368. }
  369. case SPAWN_SET_VALUE_HAIR_TYPE:{
  370. if(target->IsEntity()){
  371. sprintf(tmp, "%i", ((Entity*)target)->GetHairType());
  372. ((Entity*)target)->SetHairType(val, send_update);
  373. }
  374. break;
  375. }
  376. case SPAWN_SET_VALUE_FACIAL_HAIR_TYPE:{
  377. if(target->IsEntity()){
  378. sprintf(tmp, "%i", ((Entity*)target)->GetFacialHairType());
  379. ((Entity*)target)->SetFacialHairType(val, send_update);
  380. }
  381. break;
  382. }
  383. case SPAWN_SET_VALUE_WING_TYPE:{
  384. if(target->IsEntity()){
  385. sprintf(tmp, "%i", ((Entity*)target)->GetWingType());
  386. ((Entity*)target)->SetWingType(val, send_update);
  387. }
  388. break;
  389. }
  390. case SPAWN_SET_VALUE_CHEST_TYPE:{
  391. if(target->IsEntity()){
  392. sprintf(tmp, "%i", ((Entity*)target)->GetChestType());
  393. ((Entity*)target)->SetChestType(val, send_update);
  394. }
  395. break;
  396. }
  397. case SPAWN_SET_VALUE_LEGS_TYPE:{
  398. if(target->IsEntity()){
  399. sprintf(tmp, "%i", ((Entity*)target)->GetLegsType());
  400. ((Entity*)target)->SetLegsType(val, send_update);
  401. }
  402. break;
  403. }
  404. case SPAWN_SET_VALUE_SOGA_HAIR_TYPE:{
  405. if(target->IsEntity()){
  406. sprintf(tmp, "%i", ((Entity*)target)->GetSogaHairType());
  407. ((Entity*)target)->SetSogaHairType(val, send_update);
  408. }
  409. break;
  410. }
  411. case SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE:{
  412. if(target->IsEntity()){
  413. sprintf(tmp, "%i", ((Entity*)target)->GetSogaFacialHairType());
  414. ((Entity*)target)->SetSogaFacialHairType(val, send_update);
  415. }
  416. break;
  417. }
  418. case SPAWN_SET_VALUE_SOGA_MODEL_TYPE:{
  419. sprintf(tmp, "%i", target->GetSogaModelType());
  420. target->SetSogaModelType(val, send_update);
  421. break;
  422. }
  423. case SPAWN_SET_VALUE_SIZE:{
  424. sprintf(tmp, "%i", target->GetSize());
  425. target->SetSize(val, send_update);
  426. break;
  427. }
  428. case SPAWN_SET_VALUE_HP:{
  429. sprintf(tmp, "%i", target->GetHP());
  430. target->SetTotalHPBase(val);
  431. target->SetHP(val, send_update);
  432. break;
  433. }
  434. case SPAWN_SET_VALUE_POWER:{
  435. sprintf(tmp, "%i", target->GetPower());
  436. target->SetTotalPowerBase(val);
  437. target->SetPower(val, send_update);
  438. break;
  439. }
  440. case SPAWN_SET_VALUE_HEROIC:{
  441. sprintf(tmp, "%i", target->GetHeroic());
  442. target->SetHeroic(val, send_update);
  443. break;
  444. }
  445. case SPAWN_SET_VALUE_RESPAWN:{
  446. sprintf(tmp, "%u", target->GetRespawnTime());
  447. target->SetRespawnTime(val);
  448. break;
  449. }
  450. case SPAWN_SET_VALUE_X:{
  451. sprintf(tmp, "%f", target->GetX());
  452. target->SetX(atof(value), send_update);
  453. break;
  454. }
  455. case SPAWN_SET_VALUE_Y:{
  456. sprintf(tmp, "%f", target->GetY());
  457. target->SetY(atof(value), send_update);
  458. break;
  459. }
  460. case SPAWN_SET_VALUE_Z:{
  461. sprintf(tmp, "%f", target->GetZ());
  462. target->SetZ(atof(value), send_update);
  463. break;
  464. }
  465. case SPAWN_SET_VALUE_HEADING:{
  466. sprintf(tmp, "%f", target->GetHeading());
  467. target->SetHeading(atof(value) + 360, send_update);
  468. break;
  469. }
  470. case SPAWN_SET_VALUE_VISUAL_STATE:{
  471. sprintf(tmp, "%i", target->GetVisualState());
  472. target->SetVisualState(val, send_update);
  473. break;
  474. }
  475. case SPAWN_SET_VALUE_ACTION_STATE:{
  476. sprintf(tmp, "%i", target->GetActionState());
  477. target->SetActionState(val, send_update);
  478. break;
  479. }
  480. case SPAWN_SET_VALUE_MOOD_STATE:{
  481. sprintf(tmp, "%i", target->GetMoodState());
  482. target->SetMoodState(val, send_update);
  483. break;
  484. }
  485. case SPAWN_SET_VALUE_INITIAL_STATE:{
  486. sprintf(tmp, "%i", target->GetInitialState());
  487. target->SetInitialState(val, send_update);
  488. break;
  489. }
  490. case SPAWN_SET_VALUE_ACTIVITY_STATE:{
  491. sprintf(tmp, "%i", target->GetActivityStatus());
  492. target->SetActivityStatus(val, send_update);
  493. break;
  494. }
  495. case SPAWN_SET_VALUE_COLLISION_RADIUS:{
  496. sprintf(tmp, "%i", target->GetCollisionRadius());
  497. target->SetCollisionRadius(val, send_update);
  498. break;
  499. }
  500. case SPAWN_SET_VALUE_DEVICE_ID: {
  501. if (target->IsObject()) {
  502. sprintf(tmp, "%i", ((Object*)target)->GetDeviceID());
  503. ((Object*)target)->SetDeviceID(val);
  504. }
  505. break;
  506. }
  507. case SPAWN_SET_VALUE_PITCH: {
  508. sprintf(tmp, "%f", target->GetPitch());
  509. target->SetPitch(atof(value), send_update);
  510. break;
  511. }
  512. case SPAWN_SET_VALUE_ROLL: {
  513. sprintf(tmp, "%f", target->GetRoll());
  514. target->SetRoll(atof(value), send_update);
  515. break;
  516. }
  517. case SPAWN_SET_VALUE_HIDE_HOOD: {
  518. sprintf(tmp, "%i", target->appearance.hide_hood);
  519. target->SetHideHood(val);
  520. break;
  521. }
  522. case SPAWN_SET_VALUE_EMOTE_STATE: {
  523. sprintf(tmp, "%i", target->appearance.emote_state);
  524. target->SetEmoteState(val);
  525. break;
  526. }
  527. case SPAWN_SET_VALUE_ICON: {
  528. sprintf(tmp, "%i", target->GetIconValue());
  529. target->SetIcon(val);
  530. break;
  531. }
  532. case SPAWN_SET_VALUE_PREFIX: {
  533. sprintf(tmp, "%s", target->GetPrefixTitle());
  534. target->SetPrefixTitle(value);
  535. if(target->GetZone())
  536. target->GetZone()->SendUpdateTitles(target);
  537. break;
  538. }
  539. case SPAWN_SET_VALUE_SUFFIX: {
  540. sprintf(tmp, "%s", target->GetSuffixTitle());
  541. target->SetSuffixTitle(value);
  542. if(target->GetZone())
  543. target->GetZone()->SendUpdateTitles(target);
  544. break;
  545. }
  546. case SPAWN_SET_VALUE_LASTNAME: {
  547. sprintf(tmp, "%s", target->GetLastName());
  548. target->SetLastName(value);
  549. if(target->GetZone())
  550. target->GetZone()->SendUpdateTitles(target);
  551. break;
  552. }
  553. case SPAWN_SET_VALUE_EXPANSION_FLAG:
  554. case SPAWN_SET_VALUE_HOLIDAY_FLAG: {
  555. // nothing to do must reload spawns
  556. break;
  557. }
  558. case SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL: {
  559. sprintf(tmp, "%i", target->GetMerchantMinLevel());
  560. target->SetMerchantLevelRange(atoul(value), target->GetMerchantMaxLevel());
  561. break;
  562. }
  563. case SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL: {
  564. sprintf(tmp, "%i", target->GetMerchantMaxLevel());
  565. target->SetMerchantLevelRange(target->GetMerchantMinLevel(), atoul(value));
  566. break;
  567. }
  568. case SPAWN_SET_VALUE_FACTION:{
  569. sprintf(tmp, "%i", target->faction_id);
  570. ZoneServer* zone = target->GetZone();
  571. if (!zone && client)
  572. zone = client->GetCurrentZone();
  573. target->faction_id = atoul(value);
  574. if(zone)
  575. {
  576. zone->RemoveDeadEnemyList(target);
  577. if(target->IsNPC())
  578. zone->AddEnemyList((NPC*)target);
  579. }
  580. break;
  581. }
  582. case SPAWN_SET_SKIN_COLOR:
  583. case SPAWN_SET_HAIR_COLOR1:
  584. case SPAWN_SET_HAIR_COLOR2:
  585. case SPAWN_SET_HAIR_TYPE_COLOR:
  586. case SPAWN_SET_HAIR_FACE_COLOR:
  587. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  588. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  589. case SPAWN_SET_HAIR_HIGHLIGHT:
  590. case SPAWN_SET_MODEL_COLOR:
  591. case SPAWN_SET_EYE_COLOR:
  592. case SPAWN_SET_SOGA_SKIN_COLOR:
  593. case SPAWN_SET_SOGA_HAIR_COLOR1:
  594. case SPAWN_SET_SOGA_HAIR_COLOR2:
  595. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  596. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  597. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  598. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  599. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  600. case SPAWN_SET_SOGA_MODEL_COLOR:
  601. case SPAWN_SET_SOGA_EYE_COLOR:
  602. {
  603. if (target->IsEntity())
  604. {
  605. Seperator* skinsep = new Seperator(value, ' ', 3, 500, true);
  606. if (skinsep->IsNumber(0) && skinsep->IsNumber(1) && skinsep->IsNumber(2))
  607. {
  608. EQ2_Color clr;
  609. clr.red = atoul(skinsep->arg[0]);
  610. clr.green = atoul(skinsep->arg[1]);
  611. clr.blue = atoul(skinsep->arg[2]);
  612. switch(type)
  613. {
  614. case SPAWN_SET_SKIN_COLOR:
  615. ((Entity*)target)->SetSkinColor(clr);
  616. break;
  617. case SPAWN_SET_HAIR_COLOR1:
  618. ((Entity*)target)->SetHairColor1(clr);
  619. break;
  620. case SPAWN_SET_HAIR_COLOR2:
  621. ((Entity*)target)->SetHairColor2(clr);
  622. break;
  623. case SPAWN_SET_HAIR_TYPE_COLOR:
  624. ((Entity*)target)->SetHairColor(clr);
  625. break;
  626. case SPAWN_SET_HAIR_FACE_COLOR:
  627. ((Entity*)target)->SetFacialHairColor(clr);
  628. break;
  629. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  630. ((Entity*)target)->SetHairTypeHighlightColor(clr);
  631. break;
  632. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  633. ((Entity*)target)->SetFacialHairHighlightColor(clr);
  634. break;
  635. case SPAWN_SET_HAIR_HIGHLIGHT:
  636. ((Entity*)target)->SetHairHighlightColor(clr);
  637. break;
  638. case SPAWN_SET_MODEL_COLOR:
  639. ((Entity*)target)->SetModelColor(clr);
  640. break;
  641. case SPAWN_SET_EYE_COLOR:
  642. ((Entity*)target)->SetEyeColor(clr);
  643. break;
  644. case SPAWN_SET_SOGA_SKIN_COLOR:
  645. ((Entity*)target)->SetSogaSkinColor(clr);
  646. break;
  647. case SPAWN_SET_SOGA_HAIR_COLOR1:
  648. ((Entity*)target)->SetSogaHairColor1(clr);
  649. break;
  650. case SPAWN_SET_SOGA_HAIR_COLOR2:
  651. ((Entity*)target)->SetSogaHairColor2(clr);
  652. break;
  653. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  654. ((Entity*)target)->SetSogaHairColor(clr);
  655. break;
  656. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  657. ((Entity*)target)->SetSogaFacialHairColor(clr);
  658. break;
  659. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  660. ((Entity*)target)->SetSogaHairTypeHighlightColor(clr);
  661. break;
  662. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  663. ((Entity*)target)->SetSogaFacialHairHighlightColor(clr);
  664. break;
  665. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  666. ((Entity*)target)->SetSogaHairHighlightColor(clr);
  667. break;
  668. case SPAWN_SET_SOGA_MODEL_COLOR:
  669. ((Entity*)target)->SetSogaModelColor(clr);
  670. break;
  671. case SPAWN_SET_SOGA_EYE_COLOR:
  672. ((Entity*)target)->SetSogaEyeColor(clr);
  673. break;
  674. }
  675. }
  676. safe_delete(skinsep);
  677. }
  678. break;
  679. }
  680. case SPAWN_SET_AAXP_REWARDS: {
  681. target->SetAAXPRewards(atoul(value));
  682. break;
  683. }
  684. case SPAWN_SET_CHEEK_TYPE:{
  685. if(target->IsEntity() && index < 3){
  686. sprintf(tmp, "%i", ((Entity*)target)->features.cheek_type[index]);
  687. sint8 new_value = atoi(value);
  688. ((Entity*)target)->features.cheek_type[index] = new_value;
  689. ((Entity*)target)->info_changed = true;
  690. }
  691. break;
  692. }
  693. case SPAWN_SET_CHIN_TYPE:{
  694. if(target->IsEntity() && index < 3){
  695. sprintf(tmp, "%i", ((Entity*)target)->features.chin_type[index]);
  696. sint8 new_value = atoi(value);
  697. ((Entity*)target)->features.chin_type[index] = new_value;
  698. ((Entity*)target)->info_changed = true;
  699. }
  700. break;
  701. }
  702. case SPAWN_SET_EAR_TYPE:{
  703. if(target->IsEntity() && index < 3){
  704. sprintf(tmp, "%i", ((Entity*)target)->features.ear_type[index]);
  705. sint8 new_value = atoi(value);
  706. ((Entity*)target)->features.ear_type[index] = new_value;
  707. ((Entity*)target)->info_changed = true;
  708. }
  709. break;
  710. }
  711. case SPAWN_SET_EYE_BROW_TYPE:{
  712. if(target->IsEntity() && index < 3){
  713. sprintf(tmp, "%i", ((Entity*)target)->features.eye_brow_type[index]);
  714. sint8 new_value = atoi(value);
  715. ((Entity*)target)->features.eye_brow_type[index] = new_value;
  716. ((Entity*)target)->info_changed = true;
  717. }
  718. break;
  719. }
  720. case SPAWN_SET_EYE_TYPE:{
  721. if(target->IsEntity() && index < 3){
  722. sprintf(tmp, "%i", ((Entity*)target)->features.eye_type[index]);
  723. sint8 new_value = atoi(value);
  724. ((Entity*)target)->features.eye_type[index] = new_value;
  725. ((Entity*)target)->info_changed = true;
  726. }
  727. break;
  728. }
  729. case SPAWN_SET_LIP_TYPE:{
  730. if(target->IsEntity() && index < 3){
  731. sprintf(tmp, "%i", ((Entity*)target)->features.lip_type[index]);
  732. sint8 new_value = atoi(value);
  733. ((Entity*)target)->features.lip_type[index] = new_value;
  734. ((Entity*)target)->info_changed = true;
  735. }
  736. break;
  737. }
  738. case SPAWN_SET_NOSE_TYPE:{
  739. if(target->IsEntity() && index < 3){
  740. sprintf(tmp, "%i", ((Entity*)target)->features.nose_type[index]);
  741. sint8 new_value = atoi(value);
  742. ((Entity*)target)->features.nose_type[index] = new_value;
  743. ((Entity*)target)->info_changed = true;
  744. }
  745. break;
  746. }
  747. case SPAWN_SET_BODY_SIZE:{
  748. if(target->IsEntity()){
  749. sprintf(tmp, "%i", ((Entity*)target)->features.body_size);
  750. int8 new_value = atoul(value);
  751. ((Entity*)target)->features.body_size = new_value;
  752. ((Entity*)target)->info_changed = true;
  753. }
  754. break;
  755. }
  756. case SPAWN_SET_BODY_AGE:{
  757. if(target->IsEntity()){
  758. sprintf(tmp, "%i", ((Entity*)target)->features.body_age);
  759. int8 new_value = atoul(value);
  760. ((Entity*)target)->features.body_age = new_value;
  761. ((Entity*)target)->info_changed = true;
  762. }
  763. break;
  764. }
  765. case SPAWN_SET_SOGA_CHEEK_TYPE:{
  766. if(target->IsEntity() && index < 3){
  767. sprintf(tmp, "%i", ((Entity*)target)->features.soga_cheek_type[index]);
  768. sint8 new_value = atoi(value);
  769. ((Entity*)target)->features.soga_cheek_type[index] = new_value;
  770. ((Entity*)target)->info_changed = true;
  771. }
  772. break;
  773. }
  774. case SPAWN_SET_SOGA_CHIN_TYPE:{
  775. if(target->IsEntity() && index < 3){
  776. sprintf(tmp, "%i", ((Entity*)target)->features.soga_chin_type[index]);
  777. sint8 new_value = atoi(value);
  778. ((Entity*)target)->features.soga_chin_type[index] = new_value;
  779. ((Entity*)target)->info_changed = true;
  780. }
  781. break;
  782. }
  783. case SPAWN_SET_SOGA_EAR_TYPE:{
  784. if(target->IsEntity() && index < 3){
  785. sprintf(tmp, "%i", ((Entity*)target)->features.soga_ear_type[index]);
  786. sint8 new_value = atoi(value);
  787. ((Entity*)target)->features.soga_ear_type[index] = new_value;
  788. ((Entity*)target)->info_changed = true;
  789. }
  790. break;
  791. }
  792. case SPAWN_SET_SOGA_EYE_BROW_TYPE:{
  793. if(target->IsEntity() && index < 3){
  794. sprintf(tmp, "%i", ((Entity*)target)->features.soga_eye_brow_type[index]);
  795. sint8 new_value = atoi(value);
  796. ((Entity*)target)->features.soga_eye_brow_type[index] = new_value;
  797. ((Entity*)target)->info_changed = true;
  798. }
  799. break;
  800. }
  801. case SPAWN_SET_SOGA_EYE_TYPE:{
  802. if(target->IsEntity() && index < 3){
  803. sprintf(tmp, "%i", ((Entity*)target)->features.soga_eye_type[index]);
  804. sint8 new_value = atoi(value);
  805. ((Entity*)target)->features.soga_eye_type[index] = new_value;
  806. ((Entity*)target)->info_changed = true;
  807. }
  808. break;
  809. }
  810. case SPAWN_SET_SOGA_LIP_TYPE:{
  811. if(target->IsEntity() && index < 3){
  812. sprintf(tmp, "%i", ((Entity*)target)->features.soga_lip_type[index]);
  813. sint8 new_value = atoi(value);
  814. ((Entity*)target)->features.soga_lip_type[index] = new_value;
  815. ((Entity*)target)->info_changed = true;
  816. }
  817. break;
  818. }
  819. case SPAWN_SET_SOGA_BODY_SIZE:{
  820. if(target->IsEntity()){
  821. sprintf(tmp, "%i", ((Entity*)target)->features.soga_body_size);
  822. int8 new_value = atoul(value);
  823. ((Entity*)target)->features.soga_body_size = new_value;
  824. ((Entity*)target)->info_changed = true;
  825. }
  826. break;
  827. }
  828. case SPAWN_SET_SOGA_BODY_AGE:{
  829. if(target->IsEntity()){
  830. sprintf(tmp, "%i", ((Entity*)target)->features.soga_body_age);
  831. int8 new_value = atoul(value);
  832. ((Entity*)target)->features.soga_body_age = new_value;
  833. ((Entity*)target)->info_changed = true;
  834. }
  835. break;
  836. }
  837. case SPAWN_SET_ATTACK_TYPE:{
  838. if(target->IsEntity()){
  839. sprintf(tmp, "%u", ((Entity*)target)->GetInfoStruct()->get_attack_type());
  840. int8 new_value = atoul(value);
  841. ((Entity*)target)->GetInfoStruct()->set_attack_type(new_value);
  842. }
  843. break;
  844. }
  845. case SPAWN_SET_RACE_TYPE:{
  846. if(target->GetModelType() > 0){
  847. Seperator* tmpsep = new Seperator(value, ' ', 3, 500, true);
  848. if (tmpsep->IsNumber(0))
  849. {
  850. int16 race_type = atoul(value);
  851. const char* category = tmpsep->IsSet(1) ? tmpsep->arg[1] : "NULL";
  852. const char* subcategory = tmpsep->IsSet(2) ? tmpsep->arg[2] : "NULL";
  853. const char* model_name = tmpsep->IsSet(3) ? tmpsep->arg[3] : "NULL";
  854. if(race_types_list.AddRaceType(target->GetModelType(), race_type, category, subcategory, model_name)) {
  855. if(client) {
  856. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Race type added to memory, however not saved to database.");
  857. }
  858. }
  859. else if(client) {
  860. client->SimpleMessage(CHANNEL_COLOR_RED, "Model type already on the race_types_list, use spawn set database to override and update database.");
  861. }
  862. }
  863. safe_delete(tmpsep);
  864. }
  865. break;
  866. }
  867. case SPAWN_SET_LOOT_TIER:{
  868. if(target->IsEntity()){
  869. sprintf(tmp, "%u", target->GetLootTier());
  870. int32 new_value = atoul(value);
  871. target->SetLootTier(new_value);
  872. }
  873. break;
  874. }
  875. case SPAWN_SET_LOOT_DROP_TYPE:{
  876. if(target->IsEntity()){
  877. sprintf(tmp, "%u", target->GetLootDropType());
  878. int32 new_value = atoul(value);
  879. target->SetLootDropType(new_value);
  880. }
  881. break;
  882. }
  883. case SPAWN_SET_SCARED_STRONG_PLAYERS:{
  884. if(target->IsNPC()){
  885. sprintf(tmp, "%u", target->IsScaredByStrongPlayers());
  886. int32 new_value = atoul(value);
  887. target->SetScaredByStrongPlayers(new_value);
  888. }
  889. break;
  890. }
  891. if(temp_value)
  892. *temp_value = string(tmp);
  893. }
  894. }
  895. else{
  896. /**** NOT TEMPORARY ELSE STATEMENT ****/
  897. /**** MUST RE-DEFINE WHAT IS ALREADY IN THE IF TEMPORARY BLOCK HERE ****/
  898. switch(type){
  899. case SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL: {
  900. target->SetMerchantLevelRange(atoul(value), target->GetMerchantMaxLevel());
  901. break;
  902. }
  903. case SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL: {
  904. target->SetMerchantLevelRange(target->GetMerchantMinLevel(), atoul(value));
  905. break;
  906. }
  907. case SPAWN_SET_VALUE_EXPANSION_FLAG: {
  908. if (target->GetDatabaseID() > 0)
  909. {
  910. char query[256];
  911. snprintf(query, 256, "update spawn set expansion_flag=%u where id=%u", atoul(value), target->GetDatabaseID());
  912. if (database.RunQuery(query, strnlen(query, 256)))
  913. {
  914. if(client)
  915. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  916. }
  917. }
  918. break;
  919. }
  920. case SPAWN_SET_VALUE_HOLIDAY_FLAG: {
  921. if (target->GetDatabaseID() > 0)
  922. {
  923. char query[256];
  924. snprintf(query, 256, "update spawn set holiday_flag=%u where id=%u", atoul(value), target->GetDatabaseID());
  925. if (database.RunQuery(query, strnlen(query, 256)))
  926. {
  927. if(client)
  928. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  929. }
  930. }
  931. break;
  932. }
  933. case SPAWN_SET_AAXP_REWARDS: {
  934. if (target->GetDatabaseID() > 0)
  935. {
  936. char query[256];
  937. snprintf(query, 256, "update spawn set aaxp_rewards=%u where id=%u", atoul(value), target->GetDatabaseID());
  938. if (database.RunQuery(query, strnlen(query, 256)))
  939. {
  940. if(client)
  941. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  942. }
  943. }
  944. break;
  945. }
  946. case SPAWN_SET_VALUE_NAME:{
  947. target->SetName(value);
  948. if(target->GetZone())
  949. target->GetZone()->SendUpdateTitles(target);
  950. break;
  951. }
  952. case SPAWN_SET_VALUE_SUB_TITLE: {
  953. target->SetSubTitle(value);
  954. if(target->GetZone())
  955. target->GetZone()->SendUpdateTitles(target);
  956. break;
  957. }
  958. case SPAWN_SET_VALUE_X_OFFSET:
  959. {
  960. target->SetXOffset(atof(value));
  961. break;
  962. }
  963. case SPAWN_SET_VALUE_Y_OFFSET:
  964. {
  965. target->SetYOffset(atof(value));
  966. break;
  967. }
  968. case SPAWN_SET_VALUE_Z_OFFSET:
  969. {
  970. target->SetZOffset(atof(value));
  971. break;
  972. }
  973. case SPAWN_SET_VALUE_EXPIRE: {
  974. target->SetExpireTime(val);
  975. break;
  976. }
  977. case SPAWN_SET_VALUE_EXPIRE_OFFSET: {
  978. target->SetExpireOffsetTime(val);
  979. break;
  980. }
  981. case SPAWN_SET_VALUE_LEVEL:{
  982. target->SetLevel(val, send_update);
  983. break;
  984. }
  985. case SPAWN_SET_VALUE_DIFFICULTY:{
  986. target->SetDifficulty(val, send_update);
  987. break;
  988. }
  989. case SPAWN_SET_VALUE_MODEL_TYPE:{
  990. target->SetModelType(val, send_update);
  991. break;
  992. }
  993. case SPAWN_SET_VALUE_CLASS:{
  994. target->SetAdventureClass(val, send_update);
  995. break;
  996. }
  997. case SPAWN_SET_VALUE_GENDER:{
  998. target->SetGender(val, send_update);
  999. break;
  1000. }
  1001. case SPAWN_SET_VALUE_SHOW_NAME:{
  1002. target->SetShowName(val, send_update);
  1003. break;
  1004. }
  1005. case SPAWN_SET_VALUE_ATTACKABLE:{
  1006. target->SetAttackable(val, send_update);
  1007. break;
  1008. }
  1009. case SPAWN_SET_VALUE_SHOW_LEVEL:{
  1010. target->SetShowLevel(val, send_update);
  1011. break;
  1012. }
  1013. case SPAWN_SET_VALUE_TARGETABLE:{
  1014. target->SetTargetable(val, send_update);
  1015. break;
  1016. }
  1017. case SPAWN_SET_VALUE_SHOW_COMMAND_ICON:{
  1018. target->SetShowCommandIcon(val, send_update);
  1019. break;
  1020. }
  1021. case SPAWN_SET_VALUE_HAND_ICON:{
  1022. target->SetShowHandIcon(val, send_update);
  1023. break;
  1024. }
  1025. case SPAWN_SET_VALUE_HAIR_TYPE:{
  1026. if(target->IsEntity())
  1027. ((Entity*)target)->SetHairType(val, send_update);
  1028. break;
  1029. }
  1030. case SPAWN_SET_VALUE_FACIAL_HAIR_TYPE:{
  1031. if(target->IsEntity())
  1032. ((Entity*)target)->SetFacialHairType(val, send_update);
  1033. break;
  1034. }
  1035. case SPAWN_SET_VALUE_WING_TYPE:{
  1036. if(target->IsEntity())
  1037. ((Entity*)target)->SetWingType(val, send_update);
  1038. break;
  1039. }
  1040. case SPAWN_SET_VALUE_CHEST_TYPE:{
  1041. if(target->IsEntity())
  1042. ((Entity*)target)->SetChestType(val, send_update);
  1043. break;
  1044. }
  1045. case SPAWN_SET_VALUE_LEGS_TYPE:{
  1046. if(target->IsEntity())
  1047. ((Entity*)target)->SetLegsType(val, send_update);
  1048. break;
  1049. }
  1050. case SPAWN_SET_VALUE_SOGA_HAIR_TYPE:{
  1051. if(target->IsEntity())
  1052. ((Entity*)target)->SetSogaHairType(val, send_update);
  1053. break;
  1054. }
  1055. case SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE:{
  1056. if(target->IsEntity())
  1057. ((Entity*)target)->SetSogaFacialHairType(val, send_update);
  1058. break;
  1059. }
  1060. case SPAWN_SET_VALUE_SOGA_MODEL_TYPE:{
  1061. target->SetSogaModelType(val, send_update);
  1062. break;
  1063. }
  1064. case SPAWN_SET_VALUE_SIZE:{
  1065. target->SetSize(val, send_update);
  1066. break;
  1067. }
  1068. case SPAWN_SET_VALUE_HP:{
  1069. target->SetTotalHPBase(val);
  1070. target->SetHP(val, send_update);
  1071. break;
  1072. }
  1073. case SPAWN_SET_VALUE_POWER:{
  1074. target->SetTotalPowerBase(val);
  1075. target->SetPower(val, send_update);
  1076. break;
  1077. }
  1078. case SPAWN_SET_VALUE_HEROIC:{
  1079. target->SetHeroic(val, send_update);
  1080. break;
  1081. }
  1082. case SPAWN_SET_VALUE_RESPAWN:{
  1083. target->SetRespawnTime(val);
  1084. break;
  1085. }
  1086. case SPAWN_SET_VALUE_X:{
  1087. target->SetX(atof(value), send_update);
  1088. target->SetSpawnOrigX(target->GetX());
  1089. break;
  1090. }
  1091. case SPAWN_SET_VALUE_Y:{
  1092. target->SetY(atof(value), send_update);
  1093. target->SetSpawnOrigY(target->GetY());
  1094. break;
  1095. }
  1096. case SPAWN_SET_VALUE_Z:{
  1097. target->SetZ(atof(value), send_update);
  1098. target->SetSpawnOrigZ(target->GetZ());
  1099. break;
  1100. }
  1101. case SPAWN_SET_VALUE_HEADING:{
  1102. target->SetHeading(atof(value), send_update);
  1103. target->SetSpawnOrigHeading(target->GetHeading());
  1104. break;
  1105. }
  1106. case SPAWN_SET_VALUE_COMMAND_PRIMARY:{
  1107. ZoneServer* zone = target->GetZone();
  1108. if (!zone && client)
  1109. zone = client->GetCurrentZone();
  1110. if(zone && zone->GetEntityCommandList(val))
  1111. target->SetPrimaryCommands(zone->GetEntityCommandList(val));
  1112. target->primary_command_list_id = val;
  1113. break;
  1114. }
  1115. case SPAWN_SET_VALUE_COMMAND_SECONDARY:{
  1116. ZoneServer* zone = target->GetZone();
  1117. if (!zone && client)
  1118. zone = client->GetCurrentZone();
  1119. if (zone && zone->GetEntityCommandList(val))
  1120. target->SetSecondaryCommands(zone->GetEntityCommandList(val));
  1121. target->secondary_command_list_id = val;
  1122. break;
  1123. }
  1124. case SPAWN_SET_VALUE_VISUAL_STATE:{
  1125. target->SetVisualState(val, send_update);
  1126. break;
  1127. }
  1128. case SPAWN_SET_VALUE_ACTION_STATE:{
  1129. target->SetActionState(val, send_update);
  1130. break;
  1131. }
  1132. case SPAWN_SET_VALUE_MOOD_STATE:{
  1133. target->SetMoodState(val, send_update);
  1134. break;
  1135. }
  1136. case SPAWN_SET_VALUE_INITIAL_STATE:{
  1137. target->SetInitialState(val, send_update);
  1138. break;
  1139. }
  1140. case SPAWN_SET_VALUE_ACTIVITY_STATE:{
  1141. target->SetActivityStatus(val, send_update);
  1142. break;
  1143. }
  1144. case SPAWN_SET_VALUE_COLLISION_RADIUS:{
  1145. target->SetCollisionRadius(val, send_update);
  1146. break;
  1147. }
  1148. case SPAWN_SET_VALUE_FACTION:{
  1149. ZoneServer* zone = target->GetZone();
  1150. if (!zone && client)
  1151. zone = client->GetCurrentZone();
  1152. target->faction_id = val;
  1153. if(zone)
  1154. {
  1155. zone->RemoveDeadEnemyList(target);
  1156. if(target->IsNPC())
  1157. zone->AddEnemyList((NPC*)target);
  1158. }
  1159. break;
  1160. }
  1161. case SPAWN_SET_VALUE_DEVICE_ID:{
  1162. if (target->IsObject())
  1163. ((Object*)target)->SetDeviceID(val);
  1164. break;
  1165. }
  1166. case SPAWN_SET_VALUE_PITCH: {
  1167. target->SetPitch(atof(value), send_update);
  1168. target->SetSpawnOrigPitch(atof(value));
  1169. break;
  1170. }
  1171. case SPAWN_SET_VALUE_ROLL: {
  1172. target->SetRoll(atof(value), send_update);
  1173. target->SetSpawnOrigRoll(atof(value));
  1174. break;
  1175. }
  1176. case SPAWN_SET_VALUE_HIDE_HOOD: {
  1177. target->SetHideHood(val);
  1178. break;
  1179. }
  1180. case SPAWN_SET_VALUE_EMOTE_STATE: {
  1181. target->SetEmoteState(val);
  1182. break;
  1183. }
  1184. case SPAWN_SET_VALUE_ICON: {
  1185. target->SetIcon(val);
  1186. break;
  1187. }
  1188. case SPAWN_SET_VALUE_PREFIX: {
  1189. target->SetPrefixTitle(value);
  1190. if(target->GetZone())
  1191. target->GetZone()->SendUpdateTitles(target);
  1192. break;
  1193. }
  1194. case SPAWN_SET_VALUE_SUFFIX: {
  1195. target->SetSuffixTitle(value);
  1196. if(target->GetZone())
  1197. target->GetZone()->SendUpdateTitles(target);
  1198. break;
  1199. }
  1200. case SPAWN_SET_VALUE_LASTNAME: {
  1201. target->SetLastName(value);
  1202. if(target->GetZone())
  1203. target->GetZone()->SendUpdateTitles(target);
  1204. break;
  1205. }
  1206. case SPAWN_SET_VALUE_SPAWN_SCRIPT:{
  1207. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  1208. if(client){
  1209. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  1210. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawn_script 'SpawnScripts/example.lua'");
  1211. }
  1212. return false;
  1213. }
  1214. else if(!database.UpdateSpawnScriptData(target->GetDatabaseID(), 0, 0, value))
  1215. return false;
  1216. else{
  1217. if(!world.GetSpawnLocationScript(target->GetSpawnLocationID()))
  1218. target->SetSpawnScript(value);
  1219. }
  1220. break;
  1221. }
  1222. case SPAWN_SET_VALUE_SPAWNLOCATION_SCRIPT:{
  1223. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  1224. if(client){
  1225. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  1226. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawnlocation_script 'SpawnScripts/example.lua'");
  1227. }
  1228. return false;
  1229. }
  1230. else if(!database.UpdateSpawnScriptData(0, target->GetSpawnLocationID(), 0, value))
  1231. return false;
  1232. else{
  1233. if(!world.GetSpawnEntryScript(target->GetSpawnEntryID()))
  1234. target->SetSpawnScript(value);
  1235. }
  1236. break;
  1237. }
  1238. case SPAWN_SET_VALUE_SPAWNENTRY_SCRIPT:{
  1239. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  1240. if(client){
  1241. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  1242. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawnentry_script 'SpawnScripts/example.lua'");
  1243. }
  1244. return false;
  1245. }
  1246. else if(!database.UpdateSpawnScriptData(0, 0, target->GetSpawnEntryID(), value))
  1247. return false;
  1248. else
  1249. target->SetSpawnScript(value);
  1250. break;
  1251. }
  1252. case SPAWN_SET_SKIN_COLOR:
  1253. case SPAWN_SET_HAIR_COLOR1:
  1254. case SPAWN_SET_HAIR_COLOR2:
  1255. case SPAWN_SET_HAIR_TYPE_COLOR:
  1256. case SPAWN_SET_HAIR_FACE_COLOR:
  1257. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  1258. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  1259. case SPAWN_SET_HAIR_HIGHLIGHT:
  1260. case SPAWN_SET_MODEL_COLOR:
  1261. case SPAWN_SET_EYE_COLOR:
  1262. case SPAWN_SET_SOGA_SKIN_COLOR:
  1263. case SPAWN_SET_SOGA_HAIR_COLOR1:
  1264. case SPAWN_SET_SOGA_HAIR_COLOR2:
  1265. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  1266. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  1267. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  1268. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  1269. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  1270. case SPAWN_SET_SOGA_MODEL_COLOR:
  1271. case SPAWN_SET_SOGA_EYE_COLOR: {
  1272. if (target->IsNPC())
  1273. {
  1274. Seperator* skinsep = new Seperator(value, ' ', 3, 500, true);
  1275. if (skinsep->IsNumber(0) && skinsep->IsNumber(1) && skinsep->IsNumber(2))
  1276. {
  1277. EQ2_Color clr;
  1278. clr.red = atoul(skinsep->arg[0]);
  1279. clr.green = atoul(skinsep->arg[1]);
  1280. clr.blue = atoul(skinsep->arg[2]);
  1281. Query replaceSkinQuery;
  1282. string fieldName("");
  1283. switch(type)
  1284. {
  1285. case SPAWN_SET_SKIN_COLOR:
  1286. ((Entity*)target)->SetSkinColor(clr);
  1287. fieldName.append("skin_color");
  1288. break;
  1289. case SPAWN_SET_HAIR_COLOR1:
  1290. ((Entity*)target)->SetHairColor1(clr);
  1291. fieldName.append("hair_color1");
  1292. break;
  1293. case SPAWN_SET_HAIR_COLOR2:
  1294. ((Entity*)target)->SetHairColor2(clr);
  1295. fieldName.append("hair_color2");
  1296. break;
  1297. case SPAWN_SET_HAIR_TYPE_COLOR:
  1298. ((Entity*)target)->SetHairColor(clr);
  1299. fieldName.append("hair_type_color");
  1300. break;
  1301. case SPAWN_SET_HAIR_FACE_COLOR:
  1302. ((Entity*)target)->SetFacialHairColor(clr);
  1303. fieldName.append("hair_face_color");
  1304. break;
  1305. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  1306. ((Entity*)target)->SetHairTypeHighlightColor(clr);
  1307. fieldName.append("hair_type_highlight_color");
  1308. break;
  1309. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  1310. ((Entity*)target)->SetFacialHairHighlightColor(clr);
  1311. fieldName.append("hair_face_highlight_color");
  1312. break;
  1313. case SPAWN_SET_HAIR_HIGHLIGHT:
  1314. ((Entity*)target)->SetHairHighlightColor(clr);
  1315. fieldName.append("hair_highlight");
  1316. break;
  1317. case SPAWN_SET_MODEL_COLOR:
  1318. ((Entity*)target)->SetModelColor(clr);
  1319. fieldName.append("model_color");
  1320. break;
  1321. case SPAWN_SET_EYE_COLOR:
  1322. ((Entity*)target)->SetEyeColor(clr);
  1323. fieldName.append("eye_color");
  1324. break;
  1325. case SPAWN_SET_SOGA_SKIN_COLOR:
  1326. ((Entity*)target)->SetSogaSkinColor(clr);
  1327. fieldName.append("soga_skin_color");
  1328. break;
  1329. case SPAWN_SET_SOGA_HAIR_COLOR1:
  1330. ((Entity*)target)->SetSogaHairColor1(clr);
  1331. fieldName.append("soga_hair_color1");
  1332. break;
  1333. case SPAWN_SET_SOGA_HAIR_COLOR2:
  1334. ((Entity*)target)->SetSogaHairColor2(clr);
  1335. fieldName.append("soga_hair_color2");
  1336. break;
  1337. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  1338. ((Entity*)target)->SetSogaHairColor(clr);
  1339. fieldName.append("soga_hair_type_color");
  1340. break;
  1341. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  1342. ((Entity*)target)->SetSogaFacialHairColor(clr);
  1343. fieldName.append("soga_hair_face_color");
  1344. break;
  1345. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  1346. ((Entity*)target)->SetSogaHairTypeHighlightColor(clr);
  1347. fieldName.append("soga_hair_type_highlight_color");
  1348. break;
  1349. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  1350. ((Entity*)target)->SetSogaFacialHairHighlightColor(clr);
  1351. fieldName.append("soga_hair_face_highlight_color");
  1352. break;
  1353. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  1354. ((Entity*)target)->SetSogaHairHighlightColor(clr);
  1355. fieldName.append("soga_hair_highlight");
  1356. break;
  1357. case SPAWN_SET_SOGA_MODEL_COLOR:
  1358. ((Entity*)target)->SetSogaModelColor(clr);
  1359. fieldName.append("soga_model_color");
  1360. break;
  1361. case SPAWN_SET_SOGA_EYE_COLOR:
  1362. ((Entity*)target)->SetSogaEyeColor(clr);
  1363. fieldName.append("soga_eye_color");
  1364. break;
  1365. }
  1366. replaceSkinQuery.AddQueryAsync(0, &database, Q_DELETE, "delete from npc_appearance where spawn_id=%u and type='%s'", target->GetDatabaseID(), fieldName.c_str());
  1367. 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);
  1368. }
  1369. safe_delete(skinsep);
  1370. }
  1371. break;
  1372. }
  1373. case SPAWN_SET_CHEEK_TYPE:{
  1374. if(target->IsEntity() && index < 3){
  1375. sint8 new_value = atoi(value);
  1376. ((Entity*)target)->features.cheek_type[index] = new_value;
  1377. UpdateDatabaseAppearance(client, target, "cheek_type", ((Entity*)target)->features.cheek_type[0], ((Entity*)target)->features.cheek_type[1], ((Entity*)target)->features.cheek_type[2]);
  1378. }
  1379. break;
  1380. }
  1381. case SPAWN_SET_CHIN_TYPE:{
  1382. if(target->IsEntity() && index < 3){
  1383. sint8 new_value = atoi(value);
  1384. ((Entity*)target)->features.chin_type[index] = new_value;
  1385. UpdateDatabaseAppearance(client, target, "chin_type", ((Entity*)target)->features.chin_type[0], ((Entity*)target)->features.chin_type[1], ((Entity*)target)->features.chin_type[2]);
  1386. }
  1387. break;
  1388. }
  1389. case SPAWN_SET_EAR_TYPE:{
  1390. if(target->IsEntity() && index < 3){
  1391. sint8 new_value = atoi(value);
  1392. ((Entity*)target)->features.ear_type[index] = new_value;
  1393. UpdateDatabaseAppearance(client, target, "ear_type", ((Entity*)target)->features.ear_type[0], ((Entity*)target)->features.ear_type[1], ((Entity*)target)->features.ear_type[2]);
  1394. }
  1395. break;
  1396. }
  1397. case SPAWN_SET_EYE_BROW_TYPE:{
  1398. if(target->IsEntity() && index < 3){
  1399. sint8 new_value = atoi(value);
  1400. ((Entity*)target)->features.eye_brow_type[index] = new_value;
  1401. UpdateDatabaseAppearance(client, target, "eye_brow_type", ((Entity*)target)->features.eye_brow_type[0], ((Entity*)target)->features.eye_brow_type[1], ((Entity*)target)->features.eye_brow_type[2]);
  1402. }
  1403. break;
  1404. }
  1405. case SPAWN_SET_EYE_TYPE:{
  1406. if(target->IsEntity() && index < 3){
  1407. sint8 new_value = atoi(value);
  1408. ((Entity*)target)->features.eye_type[index] = new_value;
  1409. UpdateDatabaseAppearance(client, target, "eye_type", ((Entity*)target)->features.eye_type[0], ((Entity*)target)->features.eye_type[1], ((Entity*)target)->features.eye_type[2]);
  1410. }
  1411. break;
  1412. }
  1413. case SPAWN_SET_LIP_TYPE:{
  1414. if(target->IsEntity() && index < 3){
  1415. sint8 new_value = atoi(value);
  1416. ((Entity*)target)->features.lip_type[index] = new_value;
  1417. UpdateDatabaseAppearance(client, target, "lip_type", ((Entity*)target)->features.lip_type[0], ((Entity*)target)->features.lip_type[1], ((Entity*)target)->features.lip_type[2]);
  1418. }
  1419. break;
  1420. }
  1421. case SPAWN_SET_NOSE_TYPE:{
  1422. if(target->IsEntity() && index < 3){
  1423. sint8 new_value = atoi(value);
  1424. ((Entity*)target)->features.nose_type[index] = new_value;
  1425. UpdateDatabaseAppearance(client, target, "nose_type", ((Entity*)target)->features.nose_type[0], ((Entity*)target)->features.nose_type[1], ((Entity*)target)->features.nose_type[2]);
  1426. }
  1427. break;
  1428. }
  1429. case SPAWN_SET_BODY_SIZE:{
  1430. if(target->IsEntity()){
  1431. int8 new_value = atoul(value);
  1432. ((Entity*)target)->features.body_size = new_value;
  1433. UpdateDatabaseAppearance(client, target, "body_size", ((Entity*)target)->features.body_size, 0, 0);
  1434. }
  1435. break;
  1436. }
  1437. case SPAWN_SET_BODY_AGE:{
  1438. if(target->IsEntity()){
  1439. int8 new_value = atoul(value);
  1440. ((Entity*)target)->features.body_age = new_value;
  1441. UpdateDatabaseAppearance(client, target, "body_age", ((Entity*)target)->features.body_age, 0, 0);
  1442. }
  1443. break;
  1444. }
  1445. case SPAWN_SET_SOGA_CHEEK_TYPE:{
  1446. if(target->IsEntity() && index < 3){
  1447. sint8 new_value = atoi(value);
  1448. ((Entity*)target)->features.soga_cheek_type[index] = new_value;
  1449. UpdateDatabaseAppearance(client, target, "soga_cheek_type", ((Entity*)target)->features.soga_cheek_type[0], ((Entity*)target)->features.soga_cheek_type[1], ((Entity*)target)->features.soga_cheek_type[2]);
  1450. }
  1451. break;
  1452. }
  1453. case SPAWN_SET_SOGA_CHIN_TYPE:{
  1454. if(target->IsEntity() && index < 3){
  1455. sint8 new_value = atoi(value);
  1456. ((Entity*)target)->features.soga_chin_type[index] = new_value;
  1457. UpdateDatabaseAppearance(client, target, "soga_chin_type", ((Entity*)target)->features.soga_chin_type[0], ((Entity*)target)->features.soga_chin_type[1], ((Entity*)target)->features.soga_chin_type[2]);
  1458. }
  1459. break;
  1460. }
  1461. case SPAWN_SET_SOGA_EAR_TYPE:{
  1462. if(target->IsEntity() && index < 3){
  1463. sint8 new_value = atoi(value);
  1464. ((Entity*)target)->features.soga_ear_type[index] = new_value;
  1465. UpdateDatabaseAppearance(client, target, "soga_ear_type", ((Entity*)target)->features.soga_ear_type[0], ((Entity*)target)->features.soga_ear_type[1], ((Entity*)target)->features.soga_ear_type[2]);
  1466. }
  1467. break;
  1468. }
  1469. case SPAWN_SET_SOGA_EYE_BROW_TYPE:{
  1470. if(target->IsEntity() && index < 3){
  1471. sint8 new_value = atoi(value);
  1472. ((Entity*)target)->features.soga_eye_brow_type[index] = new_value;
  1473. UpdateDatabaseAppearance(client, target, "soga_eye_brow_type", ((Entity*)target)->features.soga_eye_brow_type[0], ((Entity*)target)->features.soga_eye_brow_type[1], ((Entity*)target)->features.soga_eye_brow_type[2]);
  1474. }
  1475. break;
  1476. }
  1477. case SPAWN_SET_SOGA_EYE_TYPE:{
  1478. if(target->IsEntity() && index < 3){
  1479. sint8 new_value = atoi(value);
  1480. ((Entity*)target)->features.soga_eye_type[index] = new_value;
  1481. UpdateDatabaseAppearance(client, target, "soga_eye_type", ((Entity*)target)->features.soga_eye_type[0], ((Entity*)target)->features.soga_eye_type[1], ((Entity*)target)->features.soga_eye_type[2]);
  1482. }
  1483. break;
  1484. }
  1485. case SPAWN_SET_SOGA_LIP_TYPE:{
  1486. if(target->IsEntity() && index < 3){
  1487. sint8 new_value = atoi(value);
  1488. ((Entity*)target)->features.soga_lip_type[index] = new_value;
  1489. UpdateDatabaseAppearance(client, target, "soga_lip_type", ((Entity*)target)->features.soga_lip_type[0], ((Entity*)target)->features.soga_lip_type[1], ((Entity*)target)->features.soga_lip_type[2]);
  1490. }
  1491. break;
  1492. }
  1493. case SPAWN_SET_SOGA_NOSE_TYPE:{
  1494. if(target->IsEntity() && index < 3){
  1495. sint8 new_value = atoi(value);
  1496. ((Entity*)target)->features.soga_nose_type[index] = new_value;
  1497. UpdateDatabaseAppearance(client, target, "soga_nose_type", ((Entity*)target)->features.soga_nose_type[0], ((Entity*)target)->features.soga_nose_type[1], ((Entity*)target)->features.soga_nose_type[2]);
  1498. }
  1499. break;
  1500. }
  1501. case SPAWN_SET_SOGA_BODY_SIZE:{
  1502. if(target->IsEntity()){
  1503. int8 new_value = atoul(value);
  1504. ((Entity*)target)->features.body_size = new_value;
  1505. UpdateDatabaseAppearance(client, target, "body_size", ((Entity*)target)->features.body_size, 0, 0);
  1506. }
  1507. break;
  1508. }
  1509. case SPAWN_SET_SOGA_BODY_AGE:{
  1510. if(target->IsEntity()){
  1511. int8 new_value = atoul(value);
  1512. ((Entity*)target)->features.body_age = new_value;
  1513. UpdateDatabaseAppearance(client, target, "body_age", ((Entity*)target)->features.body_age, 0, 0);
  1514. }
  1515. break;
  1516. }
  1517. case SPAWN_SET_ATTACK_TYPE:{
  1518. if(target->IsEntity()){
  1519. int8 new_value = atoul(value);
  1520. ((Entity*)target)->GetInfoStruct()->set_attack_type(new_value);
  1521. if(target->IsNPC()) {
  1522. if(target->GetDatabaseID()) {
  1523. Query spawnNPCQuery;
  1524. spawnNPCQuery.AddQueryAsync(0, &database, Q_INSERT, "update spawn_npcs set attack_type=%u where id=%u", new_value, target->GetDatabaseID());
  1525. } else if(client) {
  1526. client->Message(CHANNEL_COLOR_RED, "Invalid spawn to update the database (NPC only) or no database id for the NPC present.");
  1527. }
  1528. }
  1529. }
  1530. break;
  1531. }
  1532. case SPAWN_SET_RACE_TYPE:{
  1533. if(target->GetModelType() > 0){
  1534. Seperator* tmpsep = new Seperator(value, ' ', 3, 500, true);
  1535. if (tmpsep->IsNumber(0))
  1536. {
  1537. Query typequery;
  1538. int16 race_type = atoul(value);
  1539. const char* category = tmpsep->IsSet(1) ? tmpsep->arg[1] : "NULL";
  1540. const char* subcategory = tmpsep->IsSet(2) ? tmpsep->arg[2] : "NULL";
  1541. const char* model_name = tmpsep->IsSet(3) ? tmpsep->arg[3] : "NULL";
  1542. if(race_types_list.AddRaceType(target->GetModelType(), race_type, category, subcategory, model_name)) {
  1543. if(client)
  1544. client->Message(CHANNEL_COLOR_YELLOW, "Model Type %u Race type %u inserted into memory + replaced into database, Model Type: %u set to Race Type: %u, Category: %s, SubCategory: %s, Model Name: %s.", race_type, target->GetModelType(), race_type, category, subcategory, model_name);
  1545. typequery.AddQueryAsync(0, &database, Q_INSERT, "insert into race_types (model_type, race_id, category, subcategory, model_name) values(%u, %u, '%s', '%s', '%s')", target->GetModelType(), race_type, category, subcategory, model_name);
  1546. }
  1547. else {
  1548. if(client)
  1549. client->Message(CHANNEL_COLOR_RED, "Model Type: %u Race type %u overrided in memory + replaced into database, Model Type: %u set to Race Type: %u, Category: %s, SubCategory: %s, Model Name: %s.", race_type, target->GetModelType(), race_type, category, subcategory, model_name);
  1550. race_types_list.AddRaceType(target->GetModelType(), race_type, category, subcategory, model_name, true);
  1551. typequery.AddQueryAsync(0, &database, Q_INSERT, "update race_types set race_id=%u, category='%s', subcategory='%s', model_name='%s' where model_type=%u", race_type, category, subcategory, model_name, target->GetModelType());
  1552. }
  1553. }
  1554. safe_delete(tmpsep);
  1555. }
  1556. break;
  1557. }
  1558. case SPAWN_SET_LOOT_TIER:{
  1559. int32 new_value = atoul(value);
  1560. target->SetLootTier(new_value);
  1561. if (target->GetDatabaseID() > 0)
  1562. {
  1563. char query[256];
  1564. snprintf(query, 256, "update spawn set loot_tier=%u where id=%u", atoul(value), target->GetDatabaseID());
  1565. if (database.RunQuery(query, strnlen(query, 256)))
  1566. {
  1567. if(client)
  1568. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  1569. }
  1570. }
  1571. break;
  1572. }
  1573. case SPAWN_SET_LOOT_DROP_TYPE:{
  1574. int32 new_value = atoul(value);
  1575. target->SetLootDropType(new_value);
  1576. if (target->GetDatabaseID() > 0)
  1577. {
  1578. char query[256];
  1579. snprintf(query, 256, "update spawn set loot_drop_type=%u where id=%u", atoul(value), target->GetDatabaseID());
  1580. if (database.RunQuery(query, strnlen(query, 256)))
  1581. {
  1582. if(client)
  1583. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  1584. }
  1585. }
  1586. break;
  1587. }
  1588. case SPAWN_SET_SCARED_STRONG_PLAYERS:{
  1589. int32 new_value = atoul(value);
  1590. target->SetScaredByStrongPlayers(new_value);
  1591. if (target->GetDatabaseID() > 0)
  1592. {
  1593. char query[256];
  1594. snprintf(query, 256, "update spawn_npcs set scared_by_strong_players=%u where id=%u", atoul(value), target->GetDatabaseID());
  1595. if (database.RunQuery(query, strnlen(query, 256)))
  1596. {
  1597. if(client)
  1598. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  1599. }
  1600. }
  1601. break;
  1602. }
  1603. }
  1604. }
  1605. return true;
  1606. }
  1607. void Commands::UpdateDatabaseAppearance(Client* client, Spawn* target, string fieldName, sint8 r, sint8 g, sint8 b)
  1608. {
  1609. Query replaceQuery;
  1610. if(target->IsBot())
  1611. {
  1612. Bot* bot = (Bot*)target;
  1613. if(bot->BotID)
  1614. database.SaveBotFloats(bot->BotID, fieldName.c_str(), r, g, b);
  1615. }
  1616. else if(target->IsPlayer())
  1617. {
  1618. replaceQuery.AddQueryAsync(0, &database, Q_DELETE, "delete from char_colors where char_id=%u and type='%s'", ((Player*)target)->GetCharacterID(), fieldName.c_str());
  1619. replaceQuery.AddQueryAsync(0, &database, Q_INSERT, "insert into char_colors set char_id=%u, type='%s', red=%i, green=%i, blue=%i", ((Player*)target)->GetCharacterID(), fieldName.c_str(), r, g, b);
  1620. }
  1621. else
  1622. {
  1623. replaceQuery.AddQueryAsync(0, &database, Q_DELETE, "delete from npc_appearance where spawn_id=%u and type='%s'", target->GetDatabaseID(), fieldName.c_str());
  1624. replaceQuery.AddQueryAsync(0, &database, Q_INSERT, "insert into npc_appearance set spawn_id=%u, type='%s', red=%i, green=%i, blue=%i", target->GetDatabaseID(), fieldName.c_str(), r, g, b);
  1625. }
  1626. ((Entity*)target)->changed = true;
  1627. ((Entity*)target)->info_changed = true;
  1628. if(target->GetZone())
  1629. target->GetZone()->AddChangedSpawn(target);
  1630. }
  1631. /* The zone object will be NULL if the zone is not currently running. We pass both of these in so we can update
  1632. the database fields always and also update the zone in memory if it's running. */
  1633. bool Commands::SetZoneCommand(Client* client, int32 zone_id, ZoneServer* zone, int8 type, const char* value) {
  1634. if (client && zone_id > 0 && type > 0 && value) {
  1635. sint32 int_value = 0;
  1636. float float_value = 0;
  1637. if (type == ZONE_SET_VALUE_SAFE_X || type == ZONE_SET_VALUE_SAFE_Y || type == ZONE_SET_VALUE_SAFE_Z || type == ZONE_SET_VALUE_UNDERWORLD) {
  1638. try {
  1639. float_value = atof(value);
  1640. }
  1641. catch (...) {
  1642. client->Message(CHANNEL_COLOR_RED, "Error converting '%s' to a float value", value);
  1643. return false;
  1644. }
  1645. }
  1646. 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) {
  1647. try {
  1648. int_value = atoi(value);
  1649. }
  1650. catch (...) {
  1651. client->Message(CHANNEL_COLOR_RED, "Error converting '%s' to an integer value", value);
  1652. return false;
  1653. }
  1654. }
  1655. switch (type) {
  1656. case ZONE_SET_VALUE_EXPANSION_ID: {
  1657. break;
  1658. }
  1659. case ZONE_SET_VALUE_NAME: {
  1660. if (zone)
  1661. zone->SetZoneName(const_cast<char*>(value));
  1662. database.SaveZoneInfo(zone_id, "name", value);
  1663. break;
  1664. }
  1665. case ZONE_SET_VALUE_FILE: {
  1666. if (zone)
  1667. zone->SetZoneFile(const_cast<char*>(value));
  1668. database.SaveZoneInfo(zone_id, "file", value);
  1669. break;
  1670. }
  1671. case ZONE_SET_VALUE_DESCRIPTION: {
  1672. if (zone)
  1673. zone->SetZoneDescription(const_cast<char*>(value));
  1674. database.SaveZoneInfo(zone_id, "description", value);
  1675. break;
  1676. }
  1677. case ZONE_SET_VALUE_SAFE_X: {
  1678. if (zone)
  1679. zone->SetSafeX(float_value);
  1680. database.SaveZoneInfo(zone_id, "safe_x", float_value);
  1681. break;
  1682. }
  1683. case ZONE_SET_VALUE_SAFE_Y: {
  1684. if (zone)
  1685. zone->SetSafeY(float_value);
  1686. database.SaveZoneInfo(zone_id, "safe_y", float_value);
  1687. break;
  1688. }
  1689. case ZONE_SET_VALUE_SAFE_Z: {
  1690. if (zone)
  1691. zone->SetSafeZ(float_value);
  1692. database.SaveZoneInfo(zone_id, "safe_z", float_value);
  1693. break;
  1694. }
  1695. case ZONE_SET_VALUE_UNDERWORLD: {
  1696. if (zone)
  1697. zone->SetUnderWorld(float_value);
  1698. database.SaveZoneInfo(zone_id, "underworld", float_value);
  1699. break;
  1700. }
  1701. case ZONE_SET_VALUE_MIN_RECOMMENDED: {
  1702. break;
  1703. }
  1704. case ZONE_SET_VALUE_MAX_RECOMMENDED: {
  1705. break;
  1706. }
  1707. case ZONE_SET_VALUE_ZONE_TYPE: {
  1708. break;
  1709. }
  1710. case ZONE_SET_VALUE_ALWAYS_LOADED: {
  1711. if (zone)
  1712. zone->SetAlwaysLoaded(int_value == 1);
  1713. database.SaveZoneInfo(zone_id, "always_loaded", int_value);
  1714. break;
  1715. }
  1716. case ZONE_SET_VALUE_CITY_ZONE: {
  1717. if (zone)
  1718. zone->SetCityZone(int_value == 1);
  1719. database.SaveZoneInfo(zone_id, "city_zone", int_value);
  1720. break;
  1721. }
  1722. case ZONE_SET_VALUE_WEATHER_ALLOWED: {
  1723. if (zone)
  1724. zone->SetWeatherAllowed(int_value == 1);
  1725. database.SaveZoneInfo(zone_id, "weather_allowed", int_value);
  1726. break;
  1727. }
  1728. case ZONE_SET_VALUE_MIN_STATUS: {
  1729. if (zone)
  1730. zone->SetMinimumStatus(int_value);
  1731. database.SaveZoneInfo(zone_id, "min_status", int_value);
  1732. break;
  1733. }
  1734. case ZONE_SET_VALUE_MIN_LEVEL: {
  1735. if (zone)
  1736. zone->SetMinimumLevel(int_value);
  1737. database.SaveZoneInfo(zone_id, "min_level", int_value);
  1738. break;
  1739. }
  1740. case ZONE_SET_VALUE_MAX_LEVEL: {
  1741. if (zone)
  1742. zone->SetMaximumLevel(int_value);
  1743. database.SaveZoneInfo(zone_id, "max_level", int_value);
  1744. break;
  1745. }
  1746. case ZONE_SET_VALUE_START_ZONE: {
  1747. database.SaveZoneInfo(zone_id, "start_zone", int_value);
  1748. break;
  1749. }
  1750. case ZONE_SET_VALUE_INSTANCE_TYPE: {
  1751. if (zone)
  1752. zone->SetInstanceType(int_value);
  1753. database.SaveZoneInfo(zone_id, "instance_type", int_value);
  1754. break;
  1755. }
  1756. case ZONE_SET_VALUE_DEFAULT_REENTER_TIME: {
  1757. if (zone)
  1758. zone->SetDefaultReenterTime(int_value);
  1759. database.SaveZoneInfo(zone_id, "default_reenter_time", int_value);
  1760. break;
  1761. }
  1762. case ZONE_SET_VALUE_DEFAULT_RESET_TIME: {
  1763. if (zone)
  1764. zone->SetDefaultResetTime(int_value);
  1765. database.SaveZoneInfo(zone_id, "default_reset_time", int_value);
  1766. break;
  1767. }
  1768. case ZONE_SET_VALUE_DEFAULT_LOCKOUT_TIME: {
  1769. if (zone)
  1770. zone->SetDefaultLockoutTime(int_value);
  1771. database.SaveZoneInfo(zone_id, "default_lockout_time", int_value);
  1772. break;
  1773. }
  1774. case ZONE_SET_VALUE_FORCE_GROUP_TO_ZONE: {
  1775. if (zone)
  1776. zone->SetForceGroupZoneOption(int_value);
  1777. database.SaveZoneInfo(zone_id, "force_group_to_zone", int_value);
  1778. break;
  1779. }
  1780. case ZONE_SET_VALUE_LUA_SCRIPT: {
  1781. if (lua_interface && lua_interface->GetZoneScript(value) == 0) {
  1782. client->Message(CHANNEL_COLOR_RED, "Invalid Zone Script file. Be sure you give the absolute path.");
  1783. client->Message(CHANNEL_COLOR_RED, "Example: /zone set lua_script 'ZoneScripts/QueensColony.lua'");
  1784. return false;
  1785. }
  1786. else {
  1787. world.AddZoneScript(zone_id, const_cast<char*>(value));
  1788. database.SaveZoneInfo(zone_id, "lua_script", value);
  1789. }
  1790. break;
  1791. }
  1792. case ZONE_SET_VALUE_SHUTDOWN_TIMER: {
  1793. if (zone)
  1794. zone->SetShutdownTimer(int_value);
  1795. database.SaveZoneInfo(zone_id, "shutdown_timer", int_value);
  1796. break;
  1797. }
  1798. case ZONE_SET_VALUE_ZONE_MOTD: {
  1799. if (zone)
  1800. zone->SetZoneMOTD(string(value));
  1801. database.SaveZoneInfo(zone_id, "zone_motd", value);
  1802. break;
  1803. }
  1804. default: {
  1805. client->Message(CHANNEL_COLOR_RED, "Invalid zone attribute %i", type);
  1806. return false;
  1807. }
  1808. }
  1809. }
  1810. else {
  1811. if (client)
  1812. client->SimpleMessage(CHANNEL_COLOR_RED, "An error occured saving new zone data.");
  1813. return false;
  1814. }
  1815. return true;
  1816. }
  1817. void Commands::Process(int32 index, EQ2_16BitString* command_parms, Client* client, Spawn* targetOverride) {
  1818. if (index >= remote_commands->commands.size()) {
  1819. LogWrite(COMMAND__ERROR, 0, "Command", "Error, command handler of %u was requested, but max handler is %u", index, remote_commands->commands.size());
  1820. return;
  1821. }
  1822. Spawn* cmdTarget = targetOverride ? targetOverride : client->GetPlayer()->GetTarget();
  1823. EQ2_RemoteCommandString* parent_command = 0;
  1824. EQ2_RemoteCommandString* command = &remote_commands->commands[index];
  1825. Seperator* sep = 0;
  1826. if (command_parms->size > 0) {
  1827. sep = new Seperator(command_parms->data.c_str(), ' ', 10, 500, true);
  1828. if (sep && sep->arg[0] && remote_commands->validSubCommand(command->command.data, string(sep->arg[0]))) {
  1829. parent_command = command;
  1830. command = &(remote_commands->subcommands[command->command.data][string(sep->arg[0])]);
  1831. safe_delete(sep);
  1832. if (command_parms->data.length() > (command->command.data.length() + 1))
  1833. sep = new Seperator(command_parms->data.c_str() + (command->command.data.length() + 1), ' ', 10, 500, true);
  1834. LogWrite(COMMAND__DEBUG, 1, "Command", "Handler: %u, COMMAND: '%s', SUBCOMMAND: '%s'", index, parent_command->command.data.c_str(), command->command.data.c_str());
  1835. }
  1836. else
  1837. LogWrite(COMMAND__DEBUG, 1, "Command", "Handler: %u, COMMAND: '%s'", index, command->command.data.c_str());
  1838. }
  1839. int ndx = 0;
  1840. if (command->required_status > client->GetAdminStatus())
  1841. {
  1842. 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());
  1843. safe_delete(sep);
  1844. client->SimpleMessage(3, "Error: Your status is insufficient for this command.");
  1845. return;
  1846. }
  1847. Player* player = client->GetPlayer();
  1848. LogWrite(COMMAND__DEBUG, 0, "Command", "Player '%s' (%u), Command: %s", player->GetName(), client->GetAccountID(), command->command.data.c_str());
  1849. switch (command->handler) {
  1850. case COMMAND_RELOAD: {
  1851. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reload commands:");
  1852. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload structs");
  1853. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload items");
  1854. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload luasystem");
  1855. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spawnscripts");
  1856. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spells");
  1857. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spells npc");
  1858. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload quests");
  1859. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spawns");
  1860. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload groundspawns");
  1861. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload zonescripts");
  1862. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload entity_commands");
  1863. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload factions");
  1864. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload mail");
  1865. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload guilds");
  1866. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload locations");
  1867. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload rules");
  1868. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload transporters");
  1869. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload startabilities");
  1870. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload voiceovers");
  1871. break;
  1872. }
  1873. case COMMAND_RELOADSTRUCTS: {
  1874. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Structs...");
  1875. world.SetReloadingSubsystem("Structs");
  1876. configReader.ReloadStructs();
  1877. world.RemoveReloadingSubSystem("Structs");
  1878. peer_manager.sendPeersMessage("/reloadcommand", command->handler);
  1879. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1880. break;
  1881. }
  1882. case COMMAND_RELOAD_QUESTS: {
  1883. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Quests...");
  1884. world.SetReloadingSubsystem("Quests");
  1885. master_quest_list.Reload();
  1886. client_list.ReloadQuests();
  1887. zone_list.ReloadClientQuests();
  1888. world.RemoveReloadingSubSystem("Quests");
  1889. peer_manager.sendPeersMessage("/reloadcommand", command->handler);
  1890. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1891. break;
  1892. }
  1893. case COMMAND_RELOAD_SPAWNS: {
  1894. client->GetCurrentZone()->ReloadSpawns();
  1895. break;
  1896. }
  1897. case COMMAND_RELOAD_SPELLS: {
  1898. if (sep && sep->arg[0] && strcmp(sep->arg[0], "npc") == 0) {
  1899. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading NPC Spells Lists (Note: Must Reload Spawns/Repop to reset npc spells)...");
  1900. world.PurgeNPCSpells();
  1901. database.LoadNPCSpells();
  1902. peer_manager.sendPeersMessage("/reloadcommand", command->handler, 1);
  1903. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1904. }
  1905. else {
  1906. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spells & NPC Spell Lists (Note: Must Reload Spawns/Repop to reset npc spells)...");
  1907. world.SetReloadingSubsystem("Spells");
  1908. zone_list.DeleteSpellProcess();
  1909. if (lua_interface)
  1910. lua_interface->DestroySpells();
  1911. master_spell_list.Reload();
  1912. zone_list.LoadSpellProcess();
  1913. world.RemoveReloadingSubSystem("Spells");
  1914. world.PurgeNPCSpells();
  1915. database.LoadNPCSpells();
  1916. peer_manager.sendPeersMessage("/reloadcommand", command->handler);
  1917. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1918. }
  1919. break;
  1920. }
  1921. case COMMAND_RELOAD_GROUNDSPAWNS: {
  1922. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Groundspawn Entries...");
  1923. world.SetReloadingSubsystem("GroundSpawns");
  1924. client->GetCurrentZone()->DeleteGroundSpawnItems();
  1925. client->GetCurrentZone()->LoadGroundSpawnEntries();
  1926. world.RemoveReloadingSubSystem("GroundSpawns");
  1927. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1928. break;
  1929. }
  1930. case COMMAND_RELOAD_ZONESCRIPTS: {
  1931. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Zone Scripts...");
  1932. world.SetReloadingSubsystem("ZoneScripts");
  1933. world.ResetZoneScripts();
  1934. database.LoadZoneScriptData();
  1935. if (lua_interface)
  1936. lua_interface->DestroyZoneScripts();
  1937. world.RemoveReloadingSubSystem("ZoneScripts");
  1938. peer_manager.sendPeersMessage("/reloadcommand", command->handler);
  1939. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1940. break;
  1941. }
  1942. case COMMAND_RELOAD_ENTITYCOMMANDS: {
  1943. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Entity Commands...");
  1944. world.SetReloadingSubsystem("EntityCommands");
  1945. client->GetCurrentZone()->ClearEntityCommands();
  1946. database.LoadEntityCommands(client->GetCurrentZone());
  1947. world.RemoveReloadingSubSystem("EntityCommands");
  1948. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1949. break;
  1950. }
  1951. case COMMAND_RELOAD_FACTIONS: {
  1952. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Factions...");
  1953. world.SetReloadingSubsystem("Factions");
  1954. master_faction_list.Clear();
  1955. database.LoadFactionList();
  1956. world.RemoveReloadingSubSystem("Factions");
  1957. peer_manager.sendPeersMessage("/reloadcommand", command->handler);
  1958. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1959. break;
  1960. }
  1961. case COMMAND_RELOAD_MAIL: {
  1962. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Mail...");
  1963. zone_list.ReloadMail();
  1964. peer_manager.sendPeersMessage("/reloadcommand", command->handler);
  1965. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1966. break;
  1967. }
  1968. case COMMAND_RELOAD_GUILDS: {
  1969. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Guilds...");
  1970. world.ReloadGuilds();
  1971. peer_manager.sendPeersMessage("/reloadcommand", command->handler);
  1972. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1973. break;
  1974. }
  1975. case COMMAND_RELOAD_LOCATIONS: {
  1976. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Locations...");
  1977. client->GetPlayer()->GetZone()->RemoveLocationGrids();
  1978. database.LoadLocationGrids(client->GetPlayer()->GetZone());
  1979. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1980. break;
  1981. }
  1982. case COMMAND_RELOAD_RULES: {
  1983. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Rules...");
  1984. database.LoadRuleSets(true);
  1985. peer_manager.sendPeersMessage("/reloadcommand", command->handler);
  1986. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1987. break;
  1988. }
  1989. case COMMAND_RELOAD_TRANSPORTERS: {
  1990. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Transporters in your current zone...");
  1991. database.LoadTransporters(client->GetCurrentZone());
  1992. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1993. break;
  1994. }
  1995. case COMMAND_RELOAD_STARTABILITIES: {
  1996. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Starting Skills/Spells...");
  1997. world.PurgeStartingLists();
  1998. world.LoadStartingLists();
  1999. peer_manager.sendPeersMessage("/reloadcommand", command->handler);
  2000. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  2001. break;
  2002. }
  2003. case COMMAND_RELOAD_VOICEOVERS: {
  2004. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Voiceovers...");
  2005. world.PurgeVoiceOvers();
  2006. world.LoadVoiceOvers();
  2007. peer_manager.sendPeersMessage("/reloadcommand", command->handler);
  2008. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  2009. break;
  2010. }
  2011. case COMMAND_READ: {
  2012. if (sep && sep->arg[1][0] && sep->IsNumber(1)) {
  2013. if (strcmp(sep->arg[0], "read") == 0) {
  2014. int32 item_index = atol(sep->arg[1]);
  2015. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  2016. if (item) {
  2017. Spawn* spawn = cmdTarget;
  2018. client->SendShowBook(client->GetPlayer(), item->name, item->book_language, item->book_pages);
  2019. break;
  2020. }
  2021. }
  2022. }
  2023. break;
  2024. }
  2025. case COMMAND_USEABILITY:{
  2026. if (sep && sep->arg[0][0] && sep->IsNumber(0)) {
  2027. if (!client->GetPlayer()->Alive()) {
  2028. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot do that right now.");
  2029. }
  2030. else {
  2031. int32 spell_id = atoul(sep->arg[0]);
  2032. int8 spell_tier = 0;
  2033. if (sep->arg[1][0] && sep->IsNumber(1))
  2034. spell_tier = atoi(sep->arg[1]);
  2035. else
  2036. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  2037. if (!spell_tier)
  2038. spell_tier = 1;
  2039. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  2040. if (spell) {
  2041. 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)
  2042. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), cmdTarget, true, true);
  2043. else
  2044. {
  2045. if (cmdTarget)
  2046. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), cmdTarget);
  2047. else
  2048. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  2049. }
  2050. }
  2051. }
  2052. }
  2053. else if (cmdTarget && cmdTarget->IsWidget())
  2054. {
  2055. Widget* widget = (Widget*)cmdTarget;
  2056. widget->HandleUse(client, "use", WIDGET_TYPE_DOOR);
  2057. }
  2058. else
  2059. {
  2060. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /useability {spell_id} [spell_tier]");
  2061. }
  2062. break;
  2063. }
  2064. case COMMAND_INFO:{
  2065. bool check_self_trade = true;
  2066. if(sep && sep->arg[1][0] && sep->IsNumber(1)){
  2067. if(strcmp(sep->arg[0], "inventory") == 0){
  2068. int32 item_index = atol(sep->arg[1]);
  2069. LogWrite(COMMAND__DEBUG, 5, "Command", "/info inventory item original index %u", item_index);
  2070. if(client->GetVersion() <= 561) {
  2071. if(item_index <= 255) {
  2072. item_index = 255 - item_index;
  2073. }
  2074. else {
  2075. if(item_index == 256) { // first "new" item to inventory is assigned index 256 by client
  2076. item_index = client->GetPlayer()->item_list.GetFirstNewItem();
  2077. }
  2078. else {
  2079. // otherwise the slot has to be mapped out depending on the amount of new items + index sent in
  2080. item_index = client->GetPlayer()->item_list.GetNewItemByIndex((int16)item_index - 255);
  2081. }
  2082. }
  2083. }
  2084. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  2085. if(item){
  2086. if (item->IsCollectable() && client->SendCollectionsForItem(item))
  2087. break;
  2088. EQ2Packet* app = 0;
  2089. if(client->GetVersion() <= 561) {
  2090. app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  2091. }
  2092. else {
  2093. app = item->serialize(client->GetVersion(), (!item->GetItemScript() || !lua_interface), client->GetPlayer());
  2094. }
  2095. //DumpPacket(app);
  2096. client->QueuePacket(app);
  2097. if(item->GetItemScript() && lua_interface)
  2098. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  2099. else if(item->generic_info.offers_quest_id > 0){ //leave the current functionality in place if it doesnt have an item script
  2100. Quest* quest = master_quest_list.GetQuest(item->generic_info.offers_quest_id, false);
  2101. if(quest && client->GetPlayer()->HasQuestBeenCompleted(item->generic_info.offers_quest_id) == 0 && client->GetPlayer()->HasActiveQuest(item->generic_info.offers_quest_id) == 0)
  2102. client->AddPendingQuest(new Quest(quest)); // copy quest since we pulled the master quest to see if it existed or not
  2103. }
  2104. }
  2105. else
  2106. LogWrite(COMMAND__ERROR, 0, "Command", "/info inventory: Unknown Index: %u", item_index);
  2107. }
  2108. else if(strcmp(sep->arg[0], "equipment") == 0){
  2109. int32 item_index = client->GetPlayer()->ConvertSlotFromClient(atol(sep->arg[1]), client->GetVersion());
  2110. Item* item = client->GetPlayer()->GetEquipmentList()->GetItem(item_index);
  2111. if(item){
  2112. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  2113. client->QueuePacket(app);
  2114. if(item->GetItemScript() && lua_interface)
  2115. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  2116. }
  2117. else
  2118. LogWrite(COMMAND__ERROR, 0, "Command", "/info equipment: Unknown Index: %u", item_index);
  2119. }
  2120. else if(strcmp(sep->arg[0], "appearance") == 0){
  2121. int32 item_index = client->GetPlayer()->ConvertSlotFromClient(atol(sep->arg[1]), client->GetVersion());
  2122. Item* item = client->GetPlayer()->GetAppearanceEquipmentList()->GetItem(item_index);
  2123. if(item){
  2124. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  2125. client->QueuePacket(app);
  2126. if(item->GetItemScript() && lua_interface)
  2127. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  2128. }
  2129. else
  2130. LogWrite(COMMAND__ERROR, 0, "Command", "/info appearance: Unknown Index: %u", item_index);
  2131. }
  2132. 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){
  2133. int32 item_id = atoul(sep->arg[1]);
  2134. Item* item = master_item_list.GetItem(item_id);
  2135. if(item){
  2136. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  2137. client->QueuePacket(app);
  2138. }
  2139. else
  2140. LogWrite(COMMAND__ERROR, 0, "Command", "/info item|merchant|store|buyback|consignment: Unknown Item ID: %u", item_id);
  2141. }
  2142. else if (strcmp(sep->arg[0], "spell") == 0) {
  2143. sint32 spell_id = atol(sep->arg[1]);
  2144. int8 tier = atoi(sep->arg[3]);
  2145. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, tier, client, true, 0x2A);
  2146. if (outapp)
  2147. client->QueuePacket(outapp);
  2148. else
  2149. LogWrite(COMMAND__ERROR, 0, "Command", "/info spell: Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  2150. }
  2151. else if (strcmp(sep->arg[0], "achievement") == 0) {
  2152. sint32 spell_id = atol(sep->arg[2]);
  2153. int8 group = atoi(sep->arg[1]);
  2154. AltAdvanceData* data = 0;
  2155. SpellBookEntry* spellentry = 0;
  2156. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  2157. LogWrite(COMMAND__ERROR, 0, "Command", "/info achievement: AA Spell ID and/or Tier, ID: %u, Group: %i", spell_id, group);
  2158. EQ2Packet* outapp = master_spell_list.GetAASpellPacket(spell_id, tier, client, true, 0x45);
  2159. if (outapp)
  2160. client->QueuePacket(outapp);
  2161. else
  2162. LogWrite(COMMAND__ERROR, 0, "Command", "/info achievement: Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, group);
  2163. }
  2164. else if (strcmp(sep->arg[0], "spellbook") == 0) {
  2165. sint32 spell_id = atol(sep->arg[1]);
  2166. int32 tier = atoi(sep->arg[2]);
  2167. if (tier > 255) {
  2168. SpellBookEntry* ent = client->GetPlayer()->GetSpellBookSpell(spell_id);
  2169. if (ent)
  2170. tier = ent->tier;
  2171. }
  2172. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, (int8)tier, client, true, 0x2A);
  2173. if (outapp)
  2174. client->QueuePacket(outapp);
  2175. else
  2176. LogWrite(COMMAND__ERROR, 0, "Command", "/info spellbook: Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  2177. }
  2178. else if (strcmp(sep->arg[0], "recipe") == 0) {
  2179. sint32 recipe_id = atol(sep->arg[1]);
  2180. EQ2Packet* outapp = master_recipe_list.GetRecipePacket(recipe_id, client, true, 0x2C);
  2181. if(outapp)
  2182. client->QueuePacket(outapp);
  2183. else
  2184. LogWrite(COMMAND__ERROR, 0, "Command", "/info recipe: Unknown Recipe ID: %u", recipe_id);
  2185. }
  2186. else if (strcmp(sep->arg[0], "recipe_product") == 0) {
  2187. sint32 recipe_id = atol(sep->arg[1]);
  2188. PlayerRecipeList* prl = client->GetPlayer()->GetRecipeList();
  2189. Recipe* recipe = nullptr;
  2190. if ((recipe = prl->GetRecipe(recipe_id)) && recipe->GetProductID()) {
  2191. RecipeProducts* rp = recipe->products[1];
  2192. if (recipe->GetProductID() > 0) {
  2193. Item* item = master_item_list.GetItem(recipe->GetProductID());
  2194. if(item){
  2195. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  2196. client->QueuePacket(app);
  2197. }
  2198. else
  2199. LogWrite(COMMAND__ERROR, 0, "Command", "/info recipe_product: Unknown Item ID: %u", recipe->GetProductID());
  2200. }
  2201. else {
  2202. LogWrite(COMMAND__ERROR, 0, "Command", "/info recipe_product: recipe->GetProductID() has value 0 for recipe id %u.", recipe_id);
  2203. }
  2204. }
  2205. else {
  2206. LogWrite(COMMAND__ERROR, 0, "Command", "/info recipe_product: with recipe id %u not found (recipe missing or no product in stage 1 assigned).", recipe_id);
  2207. }
  2208. }
  2209. else if (strcmp(sep->arg[0], "maintained") ==0) {
  2210. int32 slot = atol(sep->arg[1]);
  2211. int32 spell_id = atol(sep->arg[2]);
  2212. LogWrite(COMMAND__DEBUG, 5, "Command", "/info maintained: Spell ID - Slot: %u unknown: %u", slot, spell_id);
  2213. //int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  2214. MaintainedEffects* info = client->GetPlayer()->GetMaintainedSpellBySlot(slot);
  2215. EQ2Packet* outapp = master_spell_list.GetSpellPacket(info->spell_id, info->tier, client, true, 0x00);
  2216. if(outapp)
  2217. client->QueuePacket(outapp);
  2218. else
  2219. LogWrite(COMMAND__ERROR, 0, "Command", "/info maintained: Unknown Spell ID: %u", spell_id);
  2220. }
  2221. else if (strcmp(sep->arg[0], "effect") == 0) {
  2222. int32 spell_id = atol(sep->arg[1]);
  2223. LogWrite(COMMAND__DEBUG, 5, "Command", "/info effect: Spell ID: %u", spell_id);
  2224. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  2225. int8 type = 0;
  2226. if (client->GetVersion() <= 561)
  2227. type = 1;
  2228. EQ2Packet* outapp = master_spell_list.GetSpecialSpellPacket(spell_id, tier, client, true, type);
  2229. if (outapp){
  2230. client->QueuePacket(outapp);
  2231. }
  2232. else
  2233. LogWrite(COMMAND__ERROR, 0, "Command", "/info effect: Unknown Spell ID: %u", spell_id);
  2234. }
  2235. else if(sep->IsNumber(1) && ((strncasecmp("your_trade", sep->arg[0], 10) == 0) ||
  2236. (strncasecmp("their_trade", sep->arg[0], 11) == 0)))
  2237. {
  2238. if(strncasecmp("t", sep->arg[0], 1) == 0) { // their_trade not self trade
  2239. check_self_trade = false;
  2240. }
  2241. int8 slot_id = atoul(sep->arg[1]);
  2242. if(client->GetPlayer()->trade) {
  2243. Entity* traderToCheck = client->GetPlayer();
  2244. if(!check_self_trade) {
  2245. traderToCheck = client->GetPlayer()->trade->GetTradee(client->GetPlayer());
  2246. }
  2247. Item* tradeItem = client->GetPlayer()->trade->GetTraderSlot(traderToCheck, slot_id);
  2248. if(tradeItem != nullptr) {
  2249. EQ2Packet* app = tradeItem->serialize(client->GetVersion(), true, client->GetPlayer(), true, 0, 0, client->GetVersion() > 561 ? true : false);
  2250. client->QueuePacket(app);
  2251. }
  2252. }
  2253. }
  2254. }
  2255. else if (sep && strcmp(sep->arg[0], "overflow") == 0) {
  2256. Item* item = player->item_list.GetOverflowItem();
  2257. if(item) {
  2258. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  2259. client->QueuePacket(app);
  2260. }
  2261. else
  2262. LogWrite(COMMAND__ERROR, 0,"Command", "/info overflow: Unable to retrieve an overflow item.");
  2263. }
  2264. else
  2265. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /info {inventory|equipment|spell} {id}");
  2266. break;
  2267. }
  2268. case COMMAND_USE_EQUIPPED_ITEM:{
  2269. if (sep && sep->arg[0] && sep->IsNumber(0)){
  2270. int32 slot_id = atoul(sep->arg[0]);
  2271. Item* item = player->GetEquipmentList()->GetItem(slot_id);
  2272. if (item && item->generic_info.usable && item->GetItemScript()) {
  2273. if(!item->CheckFlag2(INDESTRUCTABLE) && item->generic_info.condition == 0) {
  2274. client->SimpleMessage(CHANNEL_COLOR_RED, "This item is broken and must be repaired at a mender before it can be used");
  2275. }
  2276. else if (item->CheckFlag(EVIL_ONLY) && client->GetPlayer()->GetAlignment() != ALIGNMENT_EVIL) {
  2277. client->Message(0, "%s requires an evil race.", item->name.c_str());
  2278. }
  2279. else if (item->CheckFlag(GOOD_ONLY) && client->GetPlayer()->GetAlignment() != ALIGNMENT_GOOD) {
  2280. client->Message(0, "%s requires a good race.", item->name.c_str());
  2281. }
  2282. else {
  2283. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player, player->GetTarget());
  2284. }
  2285. }
  2286. }
  2287. break;
  2288. }
  2289. case COMMAND_USE_ITEM: {
  2290. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  2291. int32 item_index = atoul(sep->arg[0]);
  2292. Item* item = player->item_list.GetItemFromIndex(item_index);
  2293. client->UseItem(item, client->GetPlayer()->GetTarget() ? client->GetPlayer()->GetTarget() : client->GetPlayer());
  2294. }
  2295. break;
  2296. }
  2297. case COMMAND_SCRIBE_SCROLL_ITEM: {
  2298. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  2299. Item* item = player->item_list.GetItemFromUniqueID(atoul(sep->arg[0]));
  2300. if (item) {
  2301. LogWrite(ITEM__DEBUG, 0, "Items", "ITEM ID: %u", item->details.item_id);
  2302. if(item->generic_info.item_type == 6) {
  2303. Spell* spell = master_spell_list.GetSpell(item->skill_info->spell_id, item->skill_info->spell_tier);
  2304. int8 old_slot = 0;
  2305. if (spell) {
  2306. if(!spell->ScribeAllowed(client->GetPlayer())) {
  2307. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not meet one of the requirements to scribe, due to class or level.");
  2308. break;
  2309. }
  2310. int16 tier_up = player->GetTierUp(spell->GetSpellTier());
  2311. if (rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Spells, RequirePreviousTierScribe)->GetInt8() && !player->HasSpell(spell->GetSpellID(), tier_up, false, true))
  2312. client->SimpleMessage(CHANNEL_COLOR_RED, "You have not scribed the required previous version of this ability.");
  2313. else if (!player->HasSpell(spell->GetSpellID(), spell->GetSpellTier(), true)) {
  2314. old_slot = player->GetSpellSlot(spell->GetSpellID());
  2315. player->RemoveSpellBookEntry(spell->GetSpellID());
  2316. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  2317. player->UnlockSpell(spell);
  2318. client->SendSpellUpdate(spell);
  2319. database.DeleteItem(client->GetCharacterID(), item, 0);
  2320. player->item_list.RemoveItem(item, true);
  2321. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  2322. client->QueuePacket(player->SendInventoryUpdate(client->GetVersion()));
  2323. // force purge client cache and display updated spell for hover over
  2324. EQ2Packet* app = spell->SerializeSpell(client, false, false);
  2325. client->QueuePacket(app);
  2326. }
  2327. }
  2328. else
  2329. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown spell ID: %u and tier: %u", item->skill_info->spell_id, item->skill_info->spell_tier);
  2330. }
  2331. else if(item->generic_info.item_type == 7){
  2332. if(item->recipebook_info) {
  2333. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Scribing recipe book %s (%u) for player %s.", item->name.c_str(), item->recipebook_info->recipe_id, player->GetName());
  2334. client->AddRecipeBookToPlayer(item->recipebook_info->recipe_id, item);
  2335. }
  2336. else {
  2337. client->Message(CHANNEL_NARRATIVE, "Recipe book is unavailable! Report to admin recipe id %u could not be retrieved.", item->recipebook_info ? item->recipebook_info->recipe_id : 0);
  2338. LogWrite(COMMAND__ERROR, 0, "Command", "Recipe Book %u could not be retrieved for item %s.", item->recipebook_info ? item->recipebook_info->recipe_id : 0, item->name.c_str());
  2339. }
  2340. }
  2341. else {
  2342. LogWrite(COMMAND__ERROR, 0, "Command", "Recipe Book Info is not set for item %s.", item->name.c_str());
  2343. }
  2344. }
  2345. else
  2346. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown unique item ID: %s", sep->arg[0]);
  2347. }
  2348. break;
  2349. }
  2350. case COMMAND_SUMMONITEM: {
  2351. if (sep && sep->IsNumber(0)) {
  2352. int32 item_id = atol(sep->arg[0]);
  2353. int32 quantity = 1;
  2354. if (sep->arg[1] && sep->IsNumber(1))
  2355. quantity = atoi(sep->arg[1]);
  2356. if (sep->arg[2] && strncasecmp(sep->arg[2], "bank", 4) == 0) {
  2357. client->AddItemToBank(item_id,quantity);
  2358. }
  2359. else {
  2360. client->AddItem(item_id, quantity);
  2361. }
  2362. }
  2363. else {
  2364. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} [quantity] or");
  2365. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} {quantity} [location] where location = bank");
  2366. }
  2367. break;
  2368. }
  2369. case COMMAND_COLLECTION_ADDITEM: {
  2370. // takes 2 params: collection_id, slot
  2371. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  2372. Item *item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(atoul(sep->arg[1]));
  2373. if (item)
  2374. client->HandleCollectionAddItem(atoul(sep->arg[0]), item);
  2375. else
  2376. 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]));
  2377. }
  2378. else
  2379. LogWrite(COLLECTION__ERROR, 0, "Collect", "Received command 'COMMAND_COLLECTION_ADDITEM' with unhandeled argument types");
  2380. break;
  2381. }
  2382. case COMMAND_COLLECTION_FILTER_MATCHITEM: {
  2383. // takes 1 param: slot
  2384. printf("COMMAND_COLLECTION_FILTER_MATCHITEM:\n");
  2385. int i = 0;
  2386. while (sep->arg[i] && strlen(sep->arg[i]) > 0) {
  2387. printf("\t%u: %s\n", i, sep->arg[i]);
  2388. i++;
  2389. }
  2390. break;
  2391. }
  2392. case COMMAND_WAYPOINT: {
  2393. bool success = false;
  2394. client->ClearWaypoint();
  2395. if (sep && sep->IsNumber(0) && sep->IsNumber(1) && sep->IsNumber(2)) {
  2396. if (!client->ShowPathToTarget(atof(sep->arg[0]), atof(sep->arg[1]), atof(sep->arg[2]), 0))
  2397. client->Message(CHANNEL_COLOR_RED, "Invalid coordinates given");
  2398. }
  2399. else if ( client->GetAdminStatus() > 100 && cmdTarget ) {
  2400. if (!client->ShowPathToTarget(cmdTarget->GetX(), cmdTarget->GetY(), cmdTarget->GetZ(), 0))
  2401. client->Message(CHANNEL_COLOR_RED, "Invalid coordinates given");
  2402. }
  2403. else {
  2404. client->Message(CHANNEL_COLOR_YELLOW, "Usage: /waypoint x y z");
  2405. }
  2406. break;
  2407. }
  2408. case COMMAND_WHO:{
  2409. const char* who = 0;
  2410. if(sep && sep->arg[0]){
  2411. //cout << "Who query: \n";
  2412. who = sep->argplus[0];
  2413. //cout << who << endl;
  2414. }
  2415. zone_list.ProcessWhoQuery(who, client);
  2416. break;
  2417. }
  2418. case COMMAND_SELECT_JUNCTION:{
  2419. // transporters (bells birds) use OP_SelectZoneTeleporterDestinatio / ProcessTeleportLocation(app)
  2420. // this is only used for revive it seems
  2421. int32 choice = 0;
  2422. if(sep && sep->arg[0] && sep->IsNumber(0))
  2423. choice = atoul(sep->arg[0]);
  2424. if(!client->GetPlayer()->Alive()){ //dead and this is a revive request
  2425. client->HandlePlayerRevive(choice);
  2426. }
  2427. break;
  2428. }
  2429. case COMMAND_SPAWN_MOVE: {
  2430. if (cmdTarget && cmdTarget->IsPlayer() == false) {
  2431. PacketStruct* packet = configReader.getStruct("WS_MoveObjectMode", client->GetVersion());
  2432. if (packet) {
  2433. float unknown2_3 = 0;
  2434. int8 placement_mode = 0;
  2435. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::DEFAULT);
  2436. if (sep && sep->arg[0][0]) {
  2437. if (strcmp(sep->arg[0], "wall") == 0) {
  2438. placement_mode = 2;
  2439. unknown2_3 = 150;
  2440. }
  2441. else if (strcmp(sep->arg[0], "ceiling") == 0)
  2442. placement_mode = 1;
  2443. else if (strcmp(sep->arg[0], "openheading") == 0 && cmdTarget->IsWidget())
  2444. {
  2445. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "[PlacementMode] WIDGET OPEN HEADING MODE");
  2446. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::OPEN_HEADING);
  2447. }
  2448. else if (strcmp(sep->arg[0], "closeheading") == 0 && cmdTarget->IsWidget())
  2449. {
  2450. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "[PlacementMode] WIDGET CLOSE HEADING MODE");
  2451. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::CLOSE_HEADING);
  2452. }
  2453. else if (strcmp(sep->arg[0], "myloc") == 0)
  2454. {
  2455. if (cmdTarget->GetSpawnLocationPlacementID() < 1) {
  2456. client->Message(CHANNEL_COLOR_YELLOW, "[PlacementMode] Spawn %s cannot be moved it is not assigned a spawn location placement id.", cmdTarget->GetName());
  2457. safe_delete(packet);
  2458. break;
  2459. }
  2460. cmdTarget->SetX(client->GetPlayer()->GetX(), true);
  2461. cmdTarget->SetY(client->GetPlayer()->GetY(), true);
  2462. cmdTarget->SetZ(client->GetPlayer()->GetZ(), true);
  2463. cmdTarget->SetHeading(client->GetPlayer()->GetHeading(), true);
  2464. if (database.UpdateSpawnLocationSpawns(cmdTarget))
  2465. client->Message(CHANNEL_COLOR_YELLOW, "[PlacementMode] Spawn %s placed at your location. Updated spawn_location_placement for spawn.", cmdTarget->GetName());
  2466. safe_delete(packet);
  2467. break;
  2468. }
  2469. }
  2470. packet->setDataByName("placement_mode", placement_mode);
  2471. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget));
  2472. packet->setDataByName("model_type", cmdTarget->GetModelType());
  2473. packet->setDataByName("unknown", 1); //size
  2474. packet->setDataByName("unknown2", 1); //size 2
  2475. packet->setDataByName("unknown2", .5, 1); //size 3
  2476. packet->setDataByName("unknown2", 3, 2);
  2477. packet->setDataByName("unknown2", unknown2_3, 3);
  2478. packet->setDataByName("max_distance", 500);
  2479. packet->setDataByName("CoEunknown", 0xFFFFFFFF);
  2480. client->QueuePacket(packet->serialize());
  2481. safe_delete(packet);
  2482. }
  2483. }
  2484. else {
  2485. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /spawn move (wall OR ceiling)");
  2486. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Moves a spawn anywhere you like. Optionally wall/ceiling can be provided to place wall/ceiling items.");
  2487. }
  2488. break;
  2489. }
  2490. case COMMAND_HAIL:{
  2491. Spawn* spawn = cmdTarget;
  2492. if(spawn && spawn->GetTargetable())
  2493. {
  2494. char tmp[75] = {0};
  2495. sprintf(tmp, "Hail, %s", spawn->GetName());
  2496. bool show_bubble = true;
  2497. if (spawn->IsNPC())
  2498. show_bubble = false;
  2499. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp, HEAR_SPAWN_DISTANCE, 0, show_bubble, client->GetPlayer()->GetCurrentLanguage());
  2500. if(spawn->IsPlayer() == false && spawn->Alive() && spawn->GetDistance(client->GetPlayer()) < rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Spawn, HailDistance)->GetInt32()){
  2501. if(spawn->IsNPC() && ((NPC*)spawn)->EngagedInCombat())
  2502. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED_BUSY, client->GetPlayer());
  2503. else
  2504. {
  2505. bool pauseRunback = false;
  2506. // prime runback as the heading or anything can be altered when hailing succeeds
  2507. if(spawn->IsNPC() && (spawn->HasMovementLoop() || spawn->HasMovementLocations()))
  2508. {
  2509. ((NPC*)spawn)->StartRunback();
  2510. pauseRunback = true;
  2511. }
  2512. if(spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED, client->GetPlayer()) && pauseRunback)
  2513. spawn->PauseMovement(rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Spawn, HailMovementPause)->GetInt32());
  2514. else if(spawn->IsNPC() && pauseRunback)
  2515. ((NPC*)spawn)->ClearRunback();
  2516. }
  2517. }
  2518. }
  2519. else {
  2520. string tmp = "Hail";
  2521. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp.c_str(), HEAR_SPAWN_DISTANCE, 0, true, client->GetPlayer()->GetCurrentLanguage());
  2522. }
  2523. break;
  2524. }
  2525. case COMMAND_SAY:{
  2526. if (sep && sep->arg[0][0]) {
  2527. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, sep->argplus[0], HEAR_SPAWN_DISTANCE, 0, true, client->GetPlayer()->GetCurrentLanguage());
  2528. if (cmdTarget && !(cmdTarget->IsPlayer()))
  2529. client->GetCurrentZone()->CallSpawnScript(cmdTarget, SPAWN_SCRIPT_HEAR_SAY, client->GetPlayer(), sep->argplus[0]);
  2530. }
  2531. else
  2532. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /say {message}");
  2533. break;
  2534. }
  2535. case COMMAND_TELL:{
  2536. if(sep && sep->arg[0] && sep->argplus[1]){
  2537. if(!zone_list.HandleGlobalChatMessage(client, sep->arg[0], CHANNEL_PRIVATE_TELL, sep->argplus[1], 0, client->GetPlayer()->GetCurrentLanguage()))
  2538. client->Message(CHANNEL_COLOR_RED,"Unable to find client %s",sep->arg[0]);
  2539. }else
  2540. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /tell {character_name} {message}");
  2541. break;
  2542. }
  2543. case COMMAND_SHOUT:{
  2544. if(sep && sep->arg[0][0])
  2545. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SHOUT, sep->argplus[0], 0, 0, true, client->GetPlayer()->GetCurrentLanguage());
  2546. else
  2547. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /shout {message}");
  2548. break;
  2549. }
  2550. case COMMAND_AUCTION:{
  2551. if(sep && sep->arg[0][0])
  2552. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_AUCTION, sep->argplus[0], 0, 0, true, client->GetPlayer()->GetCurrentLanguage());
  2553. else
  2554. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /auction {message}");
  2555. break;
  2556. }
  2557. case COMMAND_OOC:{
  2558. //For now ooc will be the global chat channel, eventually when we create more channels we will create a global chat channel
  2559. if(sep && sep->arg[0][0])
  2560. zone_list.HandleGlobalChatMessage(client, 0, CHANNEL_OUT_OF_CHARACTER, sep->argplus[0], 0, client->GetPlayer()->GetCurrentLanguage());
  2561. else
  2562. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /ooc {message}");
  2563. break;
  2564. }
  2565. case COMMAND_EMOTE:{
  2566. if(sep && sep->arg[0][0])
  2567. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_EMOTE, sep->argplus[0]);
  2568. else
  2569. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /emote {action}");
  2570. break;
  2571. }
  2572. case COMMAND_RACE:{
  2573. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  2574. if(sep->arg[1][0] && sep->IsNumber(1)){
  2575. client->GetPlayer()->GetInfoStruct()->set_race(atoi(sep->arg[1]));
  2576. client->GetPlayer()->SetRace(atoi(sep->arg[1]));
  2577. client->UpdateTimeStampFlag ( RACE_UPDATE_FLAG );
  2578. client->GetPlayer()->SetCharSheetChanged(true);
  2579. }
  2580. client->GetPlayer()->SetModelType(atoi(sep->arg[0]));
  2581. //EQ2Packet* outapp = client->GetPlayer()->spawn_update_packet(client->GetPlayer(), client->GetVersion(), client->GetPlayer()->GetFeatures());
  2582. //client->QueuePacket(outapp);
  2583. }
  2584. else{
  2585. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /race {race type id} {race id}");
  2586. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "{race id} is optional");
  2587. }
  2588. break;
  2589. }
  2590. case COMMAND_BANK_DEPOSIT:{
  2591. if(client->GetBanker() && sep && sep->arg[0]){
  2592. int64 amount = 0;
  2593. string deposit = string(sep->arg[0]);
  2594. amount = atoi64(deposit.c_str());
  2595. client->BankDeposit(amount);
  2596. }
  2597. break;
  2598. }
  2599. case COMMAND_BANK_WITHDRAWAL:{
  2600. if(client->GetBanker() && sep && sep->arg[0] && sep->IsNumber(0)){
  2601. int64 amount = 0;
  2602. string deposit = string(sep->arg[0]);
  2603. amount = atoi64(deposit.c_str());
  2604. client->BankWithdrawal(amount);
  2605. }
  2606. break;
  2607. }
  2608. case COMMAND_BANK_CANCEL:{
  2609. Spawn* banker = cmdTarget;
  2610. client->Bank(banker, true);
  2611. break;
  2612. }
  2613. case COMMAND_BANK:{
  2614. LogWrite(PLAYER__DEBUG, 0, "Players", "Open Player Personal Bank...");
  2615. Spawn* banker = cmdTarget;
  2616. client->Bank(banker);
  2617. break;
  2618. }
  2619. case COMMAND_GUILD_BANK:{
  2620. LogWrite(GUILD__DEBUG, 0, "Guilds", "Open Guild Bank...");
  2621. //Spawn* banker = client->GetPlayer()->GetTarget();
  2622. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will eventually open the guild bank!");
  2623. break;
  2624. }
  2625. case COMMAND_START_MAIL: {
  2626. client->SetMailTransaction(cmdTarget);
  2627. client->SendMailList();
  2628. break;
  2629. }
  2630. case COMMAND_CANCEL_MAIL: {
  2631. client->SetMailTransaction(0);
  2632. break;
  2633. }
  2634. case COMMAND_GET_MAIL_MESSAGE: {
  2635. if (sep && sep->arg[0] && sep->IsNumber(0))
  2636. client->DisplayMailMessage(atoul(sep->arg[0]));
  2637. break;
  2638. }
  2639. case COMMAND_ADD_MAIL_PLAT: {
  2640. if (sep && sep->arg[0] && sep->IsNumber(0))
  2641. client->AddMailCoin(0, 0, 0, atoul(sep->arg[0]));
  2642. break;
  2643. }
  2644. case COMMAND_ADD_MAIL_GOLD: {
  2645. if (sep && sep->arg[0] && sep->IsNumber(0))
  2646. client->AddMailCoin(0, 0, atoul(sep->arg[0]));
  2647. break;
  2648. }
  2649. case COMMAND_ADD_MAIL_SILVER: {
  2650. if (sep && sep->arg[0] && sep->IsNumber(0))
  2651. client->AddMailCoin(0, atoul(sep->arg[0]));
  2652. break;
  2653. }
  2654. case COMMAND_ADD_MAIL_COPPER: {
  2655. if (sep && sep->arg[0] && sep->IsNumber(0))
  2656. client->AddMailCoin(atoul(sep->arg[0]));
  2657. break;
  2658. }
  2659. case COMMAND_SET_MAIL_ITEM: {
  2660. if(sep && sep->IsNumber(0) && sep->IsNumber(1))
  2661. {
  2662. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(atoul(sep->arg[0]));
  2663. if(item)
  2664. {
  2665. int16 quantity = atoul(sep->arg[1]);
  2666. if(item->CheckFlag(NO_TRADE) || item->CheckFlag(ATTUNED) || item->CheckFlag(ARTIFACT) || item->CheckFlag2(HEIRLOOM))
  2667. {
  2668. return;
  2669. }
  2670. if(item->IsBag())
  2671. {
  2672. vector<Item*>* bag_items = player->GetPlayerItemList()->GetItemsInBag(item);
  2673. if(bag_items && bag_items->size() > 0)
  2674. {
  2675. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot mail a bag with items inside it.");
  2676. safe_delete(bag_items);
  2677. return;
  2678. }
  2679. safe_delete(bag_items);
  2680. }
  2681. Item* itemtoadd = item;
  2682. if(quantity > 0)
  2683. {
  2684. if(quantity > item->details.count)
  2685. return;
  2686. Item* tmpItem = new Item(item);
  2687. tmpItem->details.count = quantity;
  2688. itemtoadd = tmpItem;
  2689. }
  2690. if(client->AddMailItem(itemtoadd))
  2691. {
  2692. client->RemoveItem(item, quantity, true);
  2693. }
  2694. }
  2695. }
  2696. break;
  2697. }
  2698. case COMMAND_REMOVE_MAIL_PLAT: {
  2699. if (sep && sep->arg[0] && sep->IsNumber(0))
  2700. client->RemoveMailCoin(0, 0, 0, atoul(sep->arg[0]));
  2701. break;
  2702. }
  2703. case COMMAND_REMOVE_MAIL_GOLD: {
  2704. if (sep && sep->arg[0] && sep->IsNumber(0))
  2705. client->RemoveMailCoin(0, 0, atoul(sep->arg[0]));
  2706. break;
  2707. }
  2708. case COMMAND_REMOVE_MAIL_SILVER: {
  2709. if (sep && sep->arg[0] && sep->IsNumber(0))
  2710. client->RemoveMailCoin(0, atoul(sep->arg[0]));
  2711. break;
  2712. }
  2713. case COMMAND_REMOVE_MAIL_COPPER: {
  2714. if (sep && sep->arg[0] && sep->IsNumber(0))
  2715. client->RemoveMailCoin(atoul(sep->arg[0]));
  2716. break;
  2717. }
  2718. case COMMAND_TAKE_MAIL_ATTACHMENTS: {
  2719. if (sep && sep->arg[0] && sep->IsNumber(0))
  2720. client->TakeMailAttachments(atoul(sep->arg[0]));
  2721. break;
  2722. }
  2723. case COMMAND_CANCEL_SEND_MAIL: {
  2724. client->ResetSendMail();
  2725. break;
  2726. }
  2727. case COMMAND_DELETE_MAIL_MESSAGE: {
  2728. if (sep && sep->arg[0] && sep->IsNumber(0))
  2729. client->DeleteMail(atoul(sep->arg[0]), true);
  2730. break;
  2731. }
  2732. case COMMAND_REPORT_SPAM: {
  2733. LogWrite(MISC__TODO, 1, "TODO", " received reportspam\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  2734. if (sep && sep->arg[0]) LogWrite(COMMAND__DEBUG, 0, "Command", "%s\n", sep->argplus[0]);
  2735. break;
  2736. }
  2737. case COMMAND_KILL:{
  2738. Spawn* dead = 0;
  2739. if (sep && sep->arg[0] && strncasecmp(sep->arg[0],"self",4)==0){
  2740. dead=client->GetPlayer();
  2741. client->GetPlayer()->SetHP(0);
  2742. client->GetPlayer()->KillSpawn(dead);
  2743. }else{
  2744. dead= cmdTarget;
  2745. if(dead && dead->IsPlayer() == false){
  2746. if(dead->IsNPC() && ((NPC*)dead)->Brain()) {
  2747. client->GetPlayer()->CheckEncounterState((Entity*)dead);
  2748. ((NPC*)dead)->Brain()->AddToEncounter(client->GetPlayer());
  2749. ((NPC*)dead)->AddTargetToEncounter(client->GetPlayer());
  2750. ((NPC*)dead)->Brain()->AddHate(client->GetPlayer(), 1);
  2751. }
  2752. dead->SetHP(0);
  2753. if(sep && sep->arg[0] && sep->IsNumber(0) && atoi(sep->arg[0]) == 1)
  2754. client->GetCurrentZone()->RemoveSpawn(dead, true, true, true, true, true);
  2755. else
  2756. client->GetPlayer()->KillSpawn(dead);
  2757. }else{
  2758. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /kill (self)");
  2759. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Kills currently selected non-player target.");
  2760. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Optionally, self may be used to kill yourself");
  2761. }
  2762. }
  2763. break;
  2764. }
  2765. case COMMAND_LEVEL:{
  2766. if(sep && sep->arg[ndx][0] && sep->IsNumber(0)){
  2767. int16 new_level = atoi(sep->arg[ndx]);
  2768. if (!client->GetPlayer()->CheckLevelStatus(new_level))
  2769. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have the required status to level up anymore!");
  2770. else {
  2771. if (new_level < 1)
  2772. new_level = 1;
  2773. if (new_level > 255)
  2774. new_level = 255;
  2775. client->ChangeLevel(client->GetPlayer()->GetLevel(), new_level);
  2776. }
  2777. }else
  2778. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /level {new_level}");
  2779. break;
  2780. }
  2781. case COMMAND_SIT: {
  2782. if(client->GetPlayer()->GetHP() > 0){
  2783. client->QueuePacket(new EQ2Packet(OP_SitMsg, 0, 0));
  2784. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You sit down.");
  2785. client->GetPlayer()->set_character_flag(CF_IS_SITTING);
  2786. }
  2787. break;
  2788. }
  2789. case COMMAND_STAND: {
  2790. if(client->GetPlayer()->GetHP() > 0){
  2791. client->QueuePacket(new EQ2Packet(OP_StandMsg, 0, 0));
  2792. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You stand up.");
  2793. client->GetPlayer()->reset_character_flag(CF_IS_SITTING);
  2794. }
  2795. break;
  2796. }
  2797. case COMMAND_CLASS:{
  2798. if(sep && sep->arg[ndx][0]){
  2799. client->GetPlayer()->SetPlayerAdventureClass(atoi(sep->arg[ndx]));
  2800. client->UpdateTimeStampFlag ( CLASS_UPDATE_FLAG );
  2801. }else
  2802. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /class {class_id}");
  2803. break;
  2804. }
  2805. case COMMAND_FLYMODE:{
  2806. if(sep && sep->arg[0] && sep->IsNumber(0)){
  2807. PrintSep(sep, "COMMAND_FLYMODE");
  2808. int8 val = atoul(sep->arg[0]);
  2809. ClientPacketFunctions::SendFlyMode(client, val);
  2810. }
  2811. else{
  2812. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage ON: /flymode [1|2] 1 = fly, 2 = no clip");
  2813. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage OFF: /flymode 0");
  2814. }
  2815. break;
  2816. }
  2817. case COMMAND_LOOT_LIST:{
  2818. Spawn* spawn = cmdTarget;
  2819. if(spawn && spawn->IsEntity()){
  2820. if (sep && sep->arg[0]) {
  2821. if (!spawn->GetDatabaseID())
  2822. {
  2823. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "NOTE: Spawn has no database id to assign to loottables.");
  2824. }
  2825. if (!spawn->IsNPC())
  2826. {
  2827. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "these /loot list [add/remove/clearall] sub-commands are only designed for an NPC.");
  2828. break;
  2829. }
  2830. bool reloadLoot = false;
  2831. if (!stricmp(sep->arg[0], "remove") && sep->arg[1] && sep->IsNumber(1))
  2832. {
  2833. int32 loottable_id = atoul(sep->arg[1]);
  2834. if (loottable_id > 0 && database.RemoveSpawnLootTable(spawn, loottable_id))
  2835. {
  2836. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u loot table %u removed.", spawn->GetDatabaseID(), loottable_id);
  2837. reloadLoot = true;
  2838. }
  2839. else
  2840. client->Message(CHANNEL_COLOR_YELLOW, "/loot list remove [loottableid] - could not match any spawn_id entries against loottable_id %u.", loottable_id);
  2841. }
  2842. else if (!stricmp(sep->arg[0], "add") && sep->arg[1] && sep->IsNumber(1))
  2843. {
  2844. int32 loottable_id = atoul(sep->arg[1]);
  2845. if (loottable_id > 0)
  2846. {
  2847. database.AddLootTableToSpawn(spawn, loottable_id);
  2848. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u loot table %u added.", spawn->GetDatabaseID(), loottable_id);
  2849. reloadLoot = true;
  2850. }
  2851. else
  2852. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list add [loottableid] - cannot add a loottable id of 0.");
  2853. }
  2854. else if (!stricmp(sep->arg[0], "clearall"))
  2855. {
  2856. if (database.RemoveSpawnLootTable(spawn, 0))
  2857. {
  2858. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn loot tables removed.");
  2859. reloadLoot = true;
  2860. }
  2861. else
  2862. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list clearall - could not match any spawn_id entries in loottable_id.");
  2863. }
  2864. else if (!stricmp(sep->arg[0], "details"))
  2865. {
  2866. spawn->LockLoot();
  2867. client->SimpleMessage(CHANNEL_COMMANDS, "Loot Window List:");
  2868. if (spawn->GetLootWindowList()->size() > 0) {
  2869. std::map<int32, bool>::iterator itr;
  2870. for (itr = spawn->GetLootWindowList()->begin(); itr != spawn->GetLootWindowList()->end(); itr++) {
  2871. Spawn* looter = client->GetPlayer()->GetZone()->GetSpawnByID(itr->first);
  2872. if (looter) {
  2873. client->Message(CHANNEL_COLOR_YELLOW, "Looter: %s IsLootWindowOpen: %s, HasCompletedLootWindow: %s.", looter->GetName(), itr->second ? "NO" : "YES", spawn->HasSpawnLootWindowCompleted(itr->first) ? "YES" : "NO");
  2874. }
  2875. }
  2876. }
  2877. spawn->UnlockLoot();
  2878. }
  2879. else
  2880. {
  2881. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list argument not supported.");
  2882. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list add [loottableid] - add new loottable to spawn");
  2883. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list remove [loottableid] - remove existing loottable from spawn");
  2884. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list clearall - remove all loottables from spawn");
  2885. break;
  2886. }
  2887. if (reloadLoot)
  2888. {
  2889. database.LoadSpawnLoot(spawn->GetZone(), spawn);
  2890. if (spawn->IsNPC())
  2891. {
  2892. Entity* ent = (Entity*)spawn;
  2893. ent->SetLootCoins(0);
  2894. ent->ClearLoot();
  2895. spawn->GetZone()->AddLoot((NPC*)spawn);
  2896. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u active loot purged and reloaded.", spawn->GetDatabaseID());
  2897. }
  2898. }
  2899. break; // nothing further this is the end of these sub commands
  2900. }
  2901. else
  2902. {
  2903. vector<int32> loot_list = client->GetCurrentZone()->GetSpawnLootList(spawn->GetDatabaseID(), spawn->GetZone()->GetZoneID(), spawn->GetLevel(), race_types_list.GetRaceType(spawn->GetModelType()), spawn);
  2904. if (loot_list.size() > 0) {
  2905. client->Message(CHANNEL_COLOR_YELLOW, "%s belongs to the following loot lists: ", spawn->GetName());
  2906. vector<int32>::iterator list_itr;
  2907. LootTable* table = 0;
  2908. for (list_itr = loot_list.begin(); list_itr != loot_list.end(); list_itr++) {
  2909. table = client->GetCurrentZone()->GetLootTable(*list_itr);
  2910. if (table)
  2911. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", *list_itr, table->name.c_str());
  2912. }
  2913. }
  2914. client->Message(CHANNEL_COLOR_YELLOW, "Coins being carried: %u", spawn->GetLootCoins());
  2915. vector<Item*>* items = spawn->GetLootItems();
  2916. if (items) {
  2917. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is carrying the following items: ");
  2918. vector<Item*>::iterator itr;
  2919. Item* item = 0;
  2920. for (itr = items->begin(); itr != items->end(); itr++) {
  2921. item = *itr;
  2922. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", item->details.item_id, item->name.c_str());
  2923. }
  2924. }
  2925. else
  2926. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is not carrying any items.");
  2927. }
  2928. }
  2929. break;
  2930. }
  2931. case COMMAND_LOOT_SETCOIN:{
  2932. Spawn* spawn = cmdTarget;
  2933. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2934. spawn->SetLootCoins(atoul(sep->arg[0]));
  2935. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully set coins.");
  2936. }
  2937. else
  2938. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot setcoin {amount}");
  2939. break;
  2940. }
  2941. case COMMAND_LOOT_ADDITEM:{
  2942. Spawn* spawn = cmdTarget;
  2943. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2944. int16 charges = 1;
  2945. if(sep->arg[1] && sep->IsNumber(1))
  2946. charges = atoi(sep->arg[1]);
  2947. spawn->AddLootItem(atoul(sep->arg[0]), charges);
  2948. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully added item.");
  2949. }
  2950. else
  2951. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot additem {item_id}");
  2952. break;
  2953. }
  2954. case COMMAND_LOOT_REMOVEITEM:{
  2955. Spawn* spawn = cmdTarget;
  2956. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2957. Item* item = spawn->LootItem(atoul(sep->arg[0]));
  2958. lua_interface->SetLuaUserDataStale(item);
  2959. safe_delete(item);
  2960. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully removed item.");
  2961. }
  2962. else
  2963. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot removeitem {item_id}");
  2964. break;
  2965. }
  2966. case COMMAND_LOOT_CORPSE:
  2967. case COMMAND_DISARM:
  2968. case COMMAND_LOOT:{
  2969. if (cmdTarget && ((Entity*)cmdTarget)->IsNPC() && cmdTarget->Alive())
  2970. {
  2971. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is not dead.");
  2972. break;
  2973. }
  2974. if(cmdTarget && cmdTarget->IsEntity()){
  2975. if (cmdTarget->GetDistance(client->GetPlayer()) <= rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Loot, LootRadius)->GetFloat()){
  2976. if (!rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Loot, AutoDisarmChest)->GetBool() && command->handler == COMMAND_DISARM )
  2977. client->OpenChest(cmdTarget, true);
  2978. else
  2979. client->LootSpawnRequest(cmdTarget, rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Loot, AutoDisarmChest)->GetBool());
  2980. if (!(cmdTarget)->HasLoot()){
  2981. if (((Entity*)cmdTarget)->IsNPC())
  2982. client->GetCurrentZone()->RemoveDeadSpawn(cmdTarget);
  2983. }
  2984. }
  2985. else
  2986. client->Message(CHANNEL_COLOR_YELLOW, "You are too far away to interact with that");
  2987. }
  2988. else if(!cmdTarget || cmdTarget->GetHP() > 0)
  2989. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid target.");
  2990. break;
  2991. }
  2992. case COMMAND_RELOADSPAWNSCRIPTS:{
  2993. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spawn Scripts....");
  2994. if (lua_interface)
  2995. lua_interface->SetLuaSystemReloading(true);
  2996. world.ResetSpawnScripts();
  2997. database.LoadSpawnScriptData();
  2998. if(lua_interface) {
  2999. lua_interface->DestroySpawnScripts();
  3000. lua_interface->SetLuaSystemReloading(false);
  3001. }
  3002. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Success!");
  3003. break;
  3004. }
  3005. case COMMAND_RELOADREGIONSCRIPTS:{
  3006. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Region Scripts....");
  3007. if(lua_interface) {
  3008. lua_interface->DestroyRegionScripts();
  3009. }
  3010. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Success!");
  3011. break;
  3012. }
  3013. case COMMAND_RELOADLUASYSTEM:{
  3014. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Attempting to reload entire LUA system....");
  3015. world.SetReloadingSubsystem("LuaSystem");
  3016. if(lua_interface) {
  3017. lua_interface->SetLuaSystemReloading(true);
  3018. }
  3019. zone_list.DeleteSpellProcess();
  3020. if (lua_interface)
  3021. lua_interface->DestroySpells();
  3022. master_spell_list.Reload();
  3023. zone_list.LoadSpellProcess();
  3024. if(lua_interface){
  3025. map<Client*, int32> debug_clients = lua_interface->GetDebugClients();
  3026. map<Client*, int32>::iterator itr;
  3027. for(itr = debug_clients.begin(); itr != debug_clients.end(); itr++){
  3028. if(lua_interface)
  3029. lua_interface->UpdateDebugClients(itr->first);
  3030. }
  3031. }
  3032. world.ResetSpawnScripts();
  3033. database.LoadSpawnScriptData();
  3034. world.ResetZoneScripts();
  3035. database.LoadZoneScriptData();
  3036. if(lua_interface) {
  3037. lua_interface->DestroySpawnScripts();
  3038. lua_interface->DestroyRegionScripts();
  3039. lua_interface->DestroyQuests();
  3040. lua_interface->DestroyItemScripts();
  3041. lua_interface->DestroyZoneScripts();
  3042. }
  3043. int32 quest_count = database.LoadQuests();
  3044. int32 spell_count = 0;
  3045. if(lua_interface) {
  3046. spell_count = database.LoadSpellScriptData();
  3047. lua_interface->SetLuaSystemReloading(false);
  3048. }
  3049. world.RemoveReloadingSubSystem("LuaSystem");
  3050. client->Message(CHANNEL_COLOR_YELLOW, "Successfully loaded %u spell(s), %u quest(s).", spell_count, quest_count);
  3051. break;
  3052. }
  3053. case COMMAND_DECLINE_QUEST:{
  3054. int32 quest_id = 0;
  3055. if(sep && sep->arg[0] && sep->IsNumber(0))
  3056. quest_id = atoul(sep->arg[0]);
  3057. if(quest_id > 0){
  3058. client->RemovePendingQuest(quest_id);
  3059. }
  3060. break;
  3061. }
  3062. case COMMAND_DELETE_QUEST:{
  3063. int32 quest_id = 0;
  3064. if(sep && sep->arg[0] && sep->IsNumber(0))
  3065. quest_id = atoul(sep->arg[0]);
  3066. if(quest_id > 0){
  3067. client->GetPlayer()->MPlayerQuests.readlock(__FUNCTION__, __LINE__);
  3068. if(lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0) {
  3069. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  3070. client->GetPlayer()->MPlayerQuests.releasereadlock(__FUNCTION__, __LINE__);
  3071. if (quest && quest->CanDeleteQuest()) {
  3072. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  3073. client->RemovePlayerQuest(quest_id);
  3074. client->GetCurrentZone()->SendQuestUpdates(client);
  3075. }
  3076. }
  3077. else {
  3078. client->GetPlayer()->MPlayerQuests.releasereadlock(__FUNCTION__, __LINE__);
  3079. }
  3080. }
  3081. break;
  3082. }
  3083. case COMMAND_ACCEPT_QUEST:{
  3084. int32 quest_id = 0;
  3085. if(sep && sep->arg[0] && sep->IsNumber(0))
  3086. quest_id = atoul(sep->arg[0]);
  3087. if(quest_id > 0){
  3088. client->AcceptQuest(quest_id);
  3089. }
  3090. break;
  3091. }
  3092. case COMMAND_NAME:{
  3093. if(sep && sep->arg[ndx][0]){
  3094. client->GetPlayer()->GetInfoStruct()->set_name(std::string(sep->arg[ndx]).substr(0,39));
  3095. client->GetPlayer()->SetCharSheetChanged(true);
  3096. }else
  3097. client->Message(CHANNEL_COLOR_YELLOW,"Usage: /name {new_name}");
  3098. break;
  3099. }
  3100. case COMMAND_GROUP: {
  3101. if(sep && sep->arg[0])
  3102. printf("Group: %s\n",sep->argplus[0]);
  3103. break;
  3104. }
  3105. case COMMAND_GROUPSAY:{
  3106. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  3107. if(sep && sep->arg[0] && gmi) {
  3108. world.GetGroupManager()->GroupChatMessage(gmi->group_id, client->GetPlayer(), client->GetPlayer()->GetCurrentLanguage(), sep->argplus[0]);
  3109. peer_manager.SendPeersChannelMessage(gmi->group_id, std::string(client->GetPlayer()->GetName()), std::string(sep->argplus[0]), CHANNEL_GROUP_SAY, client->GetPlayer()->GetCurrentLanguage());
  3110. }
  3111. break;
  3112. }
  3113. case COMMAND_GROUPINVITE: {
  3114. Entity* target = 0;
  3115. Client* target_client = 0;
  3116. if (client->GetPlayer()->GetGroupMemberInfo() && !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  3117. client->SimpleMessage(CHANNEL_COMMANDS, "You must be the group leader to invite.");
  3118. return;
  3119. }
  3120. // name provided with command so it has to be a player, npc not supported here
  3121. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0){
  3122. target_client = zone_list.GetClientByCharName(sep->arg[0]);
  3123. if (target_client) {
  3124. if (!target_client->IsConnected() || !target_client->IsReadyForSpawns())
  3125. target = 0;
  3126. else
  3127. target = target_client->GetPlayer();
  3128. }
  3129. }
  3130. // if name was not provided use the players target, npc or player supported here
  3131. if (!target && client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  3132. target = (Entity*)client->GetPlayer()->GetTarget();
  3133. if (target->IsPlayer()) {
  3134. target_client = ((Player*)target)->GetClient();
  3135. }
  3136. }
  3137. int8 result = world.GetGroupManager()->Invite(client->GetPlayer(), target);
  3138. if (target && result == 0) {
  3139. client->Message(CHANNEL_COMMANDS, "You invite %s to group with you.", target->GetName());
  3140. if (target_client) {
  3141. client->SendReceiveOffer(target_client, 1, std::string(client->GetPlayer()->GetName()), 1);
  3142. }
  3143. }
  3144. else if (result == 1)
  3145. client->SimpleMessage(CHANNEL_COMMANDS, "That player is already in a group.");
  3146. else if (result == 2)
  3147. client->SimpleMessage(CHANNEL_COMMANDS, "That player has been invited to another group.");
  3148. else if (result == 3)
  3149. client->SimpleMessage(CHANNEL_COMMANDS, "Your group is already full.");
  3150. else if (result == 4)
  3151. client->SimpleMessage(CHANNEL_COMMANDS, "You have a pending invitation, cancel it first.");
  3152. else if (result == 5)
  3153. client->SimpleMessage(CHANNEL_COMMANDS, "You cannot invite yourself!");
  3154. else if (result == 6)
  3155. client->SimpleMessage(CHANNEL_COMMANDS, "Could not locate the player.");
  3156. else
  3157. client->SimpleMessage(CHANNEL_COMMANDS, "Group invite failed, unknown error!");
  3158. break;
  3159. }
  3160. case COMMAND_GROUPDISBAND: {
  3161. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  3162. if (gmi && gmi->leader) { // TODO: Leader check..DONE! :X
  3163. // world.GetGroupManager()->SimpleGroupMessage(gmi->group_id, "Your group has been disbanded.");
  3164. world.GetGroupManager()->RemoveGroup(gmi->group_id);
  3165. peer_manager.sendPeersDisbandGroup(gmi->group_id);
  3166. }
  3167. break;
  3168. }
  3169. case COMMAND_GROUP_LEAVE: {
  3170. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  3171. if (gmi) {
  3172. int32 group_id = gmi->group_id;
  3173. world.GetGroupManager()->RemoveGroupMember(group_id, client->GetPlayer());
  3174. if (!world.GetGroupManager()->IsGroupIDValid(group_id)) {
  3175. // leader->Message(CHANNEL_COLOR_GROUP, "%s has left the group.", client->GetPlayer()->GetName());
  3176. }
  3177. else {
  3178. world.GetGroupManager()->GroupMessage(group_id, "%s has left the group.", client->GetPlayer()->GetName());
  3179. }
  3180. client->SimpleMessage(CHANNEL_GROUP_CHAT, "You have left the group");
  3181. }
  3182. break;
  3183. }
  3184. case COMMAND_FRIEND_ADD:{
  3185. string name = "";
  3186. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  3187. name = database.GetPlayerName(sep->arg[0]);
  3188. else if(cmdTarget && cmdTarget->IsPlayer())
  3189. name = string(cmdTarget->GetName());
  3190. if(name.length() > 0){
  3191. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  3192. if(client->GetPlayer()->IsIgnored(name.c_str())){
  3193. client->GetPlayer()->RemoveIgnore(name.c_str());
  3194. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  3195. client->SendChatRelationship(3, name.c_str());
  3196. }
  3197. client->GetPlayer()->AddFriend(name.c_str(), true);
  3198. client->SendChatRelationship(0, name.c_str());
  3199. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added friend: %s", name.c_str());
  3200. if(zone_list.GetClientByCharName(name))
  3201. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Friend: %s has logged in.", name.c_str());
  3202. }
  3203. else
  3204. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot be more friendly towards yourself!");
  3205. }
  3206. else
  3207. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  3208. break;
  3209. }
  3210. case COMMAND_FRIEND_REMOVE:{
  3211. string name = "";
  3212. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  3213. name = database.GetPlayerName(sep->arg[0]);
  3214. else if(cmdTarget && cmdTarget->IsPlayer())
  3215. name = string(cmdTarget->GetName());
  3216. if(name.length() > 0){
  3217. client->GetPlayer()->RemoveFriend(name.c_str());
  3218. client->SendChatRelationship(1, name.c_str());
  3219. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  3220. }
  3221. else
  3222. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  3223. break;
  3224. }
  3225. case COMMAND_FRIENDS:{
  3226. break;
  3227. }
  3228. case COMMAND_IGNORE_ADD:{
  3229. string name = "";
  3230. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  3231. name = database.GetPlayerName(sep->arg[0]);
  3232. else if(cmdTarget && cmdTarget->IsPlayer())
  3233. name = string(cmdTarget->GetName());
  3234. if(name.length() > 0){
  3235. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  3236. if(client->GetPlayer()->IsFriend(name.c_str())){
  3237. client->GetPlayer()->RemoveFriend(name.c_str());
  3238. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  3239. client->SendChatRelationship(1, name.c_str());
  3240. }
  3241. client->GetPlayer()->AddIgnore(name.c_str(), true);
  3242. client->SendChatRelationship(2, name.c_str());
  3243. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added ignore: %s", name.c_str());
  3244. }
  3245. else
  3246. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot ignore yourself!");
  3247. }
  3248. else
  3249. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  3250. break;
  3251. }
  3252. case COMMAND_IGNORE_REMOVE:{
  3253. string name = "";
  3254. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  3255. name = database.GetPlayerName(sep->arg[0]);
  3256. else if(cmdTarget && cmdTarget->IsPlayer())
  3257. name = string(cmdTarget->GetName());
  3258. if(name.length() > 0){
  3259. client->GetPlayer()->RemoveIgnore(name.c_str());
  3260. client->SendChatRelationship(3, name.c_str());
  3261. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  3262. }
  3263. break;
  3264. }
  3265. case COMMAND_IGNORES:{
  3266. break;
  3267. }
  3268. case COMMAND_GROUP_KICK:{
  3269. Entity* kicked = 0;
  3270. Client* kicked_client = 0;
  3271. int32 group_id = 0;
  3272. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader)
  3273. return;
  3274. if (sep && sep->arg[0]) {
  3275. kicked_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  3276. if (kicked_client)
  3277. kicked = kicked_client->GetPlayer();
  3278. }
  3279. else if (cmdTarget && cmdTarget->IsEntity()) {
  3280. kicked = (Entity*)cmdTarget;
  3281. }
  3282. group_id = client->GetPlayer()->GetGroupMemberInfo()->group_id;
  3283. bool send_kicked_message = world.GetGroupManager()->GetGroupSize(group_id) > 2;
  3284. if (kicked)
  3285. world.GetGroupManager()->RemoveGroupMember(group_id, kicked);
  3286. if(send_kicked_message)
  3287. world.GetGroupManager()->GroupMessage(group_id, "%s was kicked from the group.", kicked->GetName());
  3288. else
  3289. client->Message(CHANNEL_GROUP_CHAT, "You kicked %s from the group", kicked->GetName());
  3290. if (kicked_client)
  3291. kicked_client->SimpleMessage(CHANNEL_GROUP_CHAT, "You were kicked from the group");
  3292. break;
  3293. }
  3294. case COMMAND_GROUP_MAKE_LEADER:{
  3295. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  3296. client->SimpleMessage(CHANNEL_COMMANDS, "You are not a group leader.");
  3297. return;
  3298. }
  3299. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 1) {
  3300. Client* new_leader = zone_list.GetClientByCharName(sep->arg[0]);
  3301. if (new_leader && new_leader->GetPlayer()->GetGroupMemberInfo() && new_leader->GetPlayer()->GetGroupMemberInfo()->group_id == client->GetPlayer()->GetGroupMemberInfo()->group_id) {
  3302. if (client->GetPlayer()->IsGroupMember(new_leader->GetPlayer())) {
  3303. if(world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, new_leader->GetPlayer())) {
  3304. world.GetGroupManager()->GroupMessage(client->GetPlayer()->GetGroupMemberInfo()->group_id, "%s is now leader of the group.", new_leader->GetPlayer()->GetName());
  3305. }
  3306. }
  3307. }
  3308. else
  3309. client->SimpleMessage(CHANNEL_COMMANDS, "Unable to find the given player.");
  3310. }
  3311. else if (cmdTarget && cmdTarget->IsPlayer() && ((Player*)cmdTarget)->GetGroupMemberInfo() && ((Player*)cmdTarget)->GetGroupMemberInfo()->group_id == client->GetPlayer()->GetGroupMemberInfo()->group_id) {
  3312. if(client->GetPlayer()->IsGroupMember((Player*)cmdTarget) && world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, (Entity*)cmdTarget)) {
  3313. world.GetGroupManager()->GroupMessage(client->GetPlayer()->GetGroupMemberInfo()->group_id, "%s is now leader of the group.", cmdTarget->GetName());
  3314. }
  3315. }
  3316. else
  3317. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to change group leader.");
  3318. break;
  3319. }
  3320. case COMMAND_GROUP_ACCEPT_INVITE: {
  3321. int8 result = 3;
  3322. std::string leader = world.GetGroupManager()->HasPendingInvite(client->GetPlayer());
  3323. std::string playerName(client->GetPlayer()->GetName());
  3324. Client* leader_client = client->GetCurrentZone()->GetClientByName((char*)leader.c_str());
  3325. bool group_existed = false;
  3326. if(leader_client && leader_client->GetPlayer()->GetGroupMemberInfo()) {
  3327. group_existed = true;
  3328. }
  3329. if(client->GetPlayer()->GetGroupMemberInfo() && client->GetPlayer()->GetGroupMemberInfo()->leader) {
  3330. int8 raid_result = world.GetGroupManager()->AcceptRaidInvite(std::string(client->GetPlayer()->GetName()), client->GetPlayer()->GetGroupMemberInfo()->group_id);
  3331. if(raid_result == 1) {
  3332. GroupOptions options;
  3333. if(world.GetGroupManager()->GetDefaultGroupOptions(client->GetPlayer()->GetGroupMemberInfo()->group_id, &options)) {
  3334. std::vector<int32> raidGroups;
  3335. world.GetGroupManager()->GetRaidGroups(client->GetPlayer()->GetGroupMemberInfo()->group_id, &raidGroups);
  3336. peer_manager.sendPeersNewGroupRequest("", 0, client->GetPlayer()->GetGroupMemberInfo()->group_id, "", "", &options, "", &raidGroups, true);
  3337. }
  3338. world.GetGroupManager()->ClearGroupRaidLooterFlag(client->GetPlayer()->GetGroupMemberInfo()->group_id);
  3339. world.GetGroupManager()->SendGroupUpdate(client->GetPlayer()->GetGroupMemberInfo()->group_id);
  3340. break;
  3341. }
  3342. }
  3343. if(net.is_primary) {
  3344. int32 group_id = 0;
  3345. result = world.GetGroupManager()->AcceptInvite(client->GetPlayer(), &group_id, false);
  3346. client->HandleGroupAcceptResponse(result);
  3347. if(result == 0) {
  3348. GroupOptions options;
  3349. if(leader_client) {
  3350. if(!group_existed) {
  3351. leader_client->SetGroupOptionsReference(&options);
  3352. peer_manager.sendPeersNewGroupRequest("", 0, group_id, leader, playerName, &options);
  3353. }
  3354. world.GetGroupManager()->AddGroupMember(group_id, leader_client->GetPlayer(), true);
  3355. world.GetGroupManager()->GroupMessage(leader_client->GetPlayer()->GetGroupMemberInfo()->group_id, "%s has joined the group.", playerName.c_str());
  3356. world.GetGroupManager()->AddGroupMember(leader_client->GetPlayer()->GetGroupMemberInfo()->group_id, client->GetPlayer());
  3357. }
  3358. }
  3359. }
  3360. else {
  3361. if(leader.size() < 1) {
  3362. client->HandleGroupAcceptResponse(1);
  3363. }
  3364. else {
  3365. Client* leader_client = client->GetCurrentZone()->GetClientByName((char*)leader.c_str());
  3366. GroupOptions options;
  3367. if(leader_client) {
  3368. leader_client->SetGroupOptionsReference(&options);
  3369. world.GetGroupManager()->AddInvite(leader_client->GetPlayer(), client->GetPlayer());
  3370. peer_manager.sendPrimaryNewGroupRequest(leader, playerName, client->GetPlayer()->GetID(), &options);
  3371. }
  3372. else {
  3373. client->HandleGroupAcceptResponse(2);
  3374. }
  3375. }
  3376. }
  3377. break;
  3378. }
  3379. case COMMAND_GROUP_DECLINE_INVITE: {
  3380. world.GetGroupManager()->DeclineInvite(client->GetPlayer()); // TODO: Add message to leader
  3381. break;
  3382. }
  3383. case COMMAND_SUMMON:{
  3384. char* search_name = 0;
  3385. if(sep && sep->arg[0][0])
  3386. search_name = sep->arg[0];
  3387. if(!search_name && !cmdTarget){
  3388. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /summon [name]");
  3389. 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.");
  3390. }
  3391. else{
  3392. if(!client->Summon(search_name))
  3393. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  3394. }
  3395. break;
  3396. }
  3397. case COMMAND_GOTO:{
  3398. const char* search_name = 0;
  3399. if(sep && sep->arg[0][0])
  3400. search_name = sep->argplus[0];
  3401. if(!search_name && !cmdTarget){
  3402. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /goto [name]");
  3403. 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.");
  3404. }
  3405. else{
  3406. if(!client->GotoSpawn(search_name))
  3407. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  3408. }
  3409. break;
  3410. }
  3411. case COMMAND_MOVE:{
  3412. bool success = false;
  3413. try{
  3414. if(sep && sep->arg[2][0] && sep->IsNumber(0) && sep->IsNumber(1) && sep->IsNumber(2)){
  3415. EQ2Packet* app = client->GetPlayer()->Move(atof(sep->arg[0]), atof(sep->arg[1]), atof(sep->arg[2]), client->GetVersion());
  3416. if(app){
  3417. client->QueuePacket(app);
  3418. success = true;
  3419. }
  3420. }
  3421. }
  3422. catch(...){}
  3423. if(!success){
  3424. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /move x y z");
  3425. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Moves the client to the given coordinates.");
  3426. }
  3427. break;
  3428. }
  3429. case COMMAND_SETTIME:{
  3430. if(sep && sep->arg[0]){
  3431. world.MWorldTime.writelock(__FUNCTION__, __LINE__);
  3432. sscanf (sep->arg[0], "%d:%d", &world.GetWorldTimeStruct()->hour, &world.GetWorldTimeStruct()->minute);
  3433. if(sep->arg[1] && sep->IsNumber(1))
  3434. world.GetWorldTimeStruct()->month = atoi(sep->arg[1]) - 1; //zero based indexes
  3435. if(sep->arg[2] && sep->IsNumber(2))
  3436. world.GetWorldTimeStruct()->day = atoi(sep->arg[2]) - 1; //zero based indexes
  3437. if(sep->arg[3] && sep->IsNumber(3))
  3438. world.GetWorldTimeStruct()->year = atoi(sep->arg[3]);
  3439. world.MWorldTime.releasewritelock(__FUNCTION__, __LINE__);
  3440. client->GetCurrentZone()->SendTimeUpdateToAllClients();
  3441. }
  3442. else{
  3443. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /settime [hour:minute] (month) (day) (year)");
  3444. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Example: /settime 8:30");
  3445. }
  3446. break;
  3447. }
  3448. case COMMAND_VERSION:{
  3449. client->Message(CHANNEL_COLOR_YELLOW,"%s %s", EQ2EMU_MODULE, CURRENT_VERSION);
  3450. client->Message(CHANNEL_COLOR_YELLOW,"Last Compiled on %s %s", COMPILE_DATE, COMPILE_TIME);
  3451. auto [days, hours, minutes, seconds] = convertTimestampDuration((getCurrentTimestamp() - world.world_uptime));
  3452. client->Message(CHANNEL_COLOR_YELLOW,"Uptime %u day(s), %u hour(s), %u minute(s), %u second(s).", days, hours, minutes, seconds);
  3453. break;
  3454. }
  3455. case COMMAND_ZONE:{
  3456. int32 instanceID = 0;
  3457. string zone;
  3458. int32 zone_id = 0;
  3459. bool listSearch = false;
  3460. bool isInstance = false;
  3461. bool notZoningCommand = false;
  3462. ZoneServer* zsZone = 0;
  3463. ZoneChangeDetails zone_details;
  3464. if(sep && sep->arg[0][0])
  3465. {
  3466. if(strncasecmp(sep->arg[0], "list", 4) == 0)
  3467. listSearch = true;
  3468. else if(strncasecmp(sep->arg[0], "active", 6) == 0)
  3469. {
  3470. zone_list.SendZoneList(client);
  3471. notZoningCommand = true;
  3472. break;
  3473. }
  3474. else if(strncasecmp(sep->arg[0], "instance", 6) == 0)
  3475. {
  3476. if(sep->IsNumber(1))
  3477. instanceID = atol(sep->arg[1]);
  3478. }
  3479. else if(strncasecmp(sep->arg[0], "lock", 4) == 0)
  3480. {
  3481. PrintSep(sep, "ZONE LOCK");
  3482. if(sep->IsNumber(1)) {
  3483. if(zone_list.GetZone(&zone_details, atoul(sep->arg[1]), "", false, false, false, false)) {
  3484. zsZone = (ZoneServer*)zone_details.zonePtr;
  3485. }
  3486. }
  3487. else {
  3488. if(zone_list.GetZone(&zone_details, 0, std::string(sep->arg[1]), false, false, false, false)) {
  3489. zsZone = (ZoneServer*)zone_details.zonePtr;
  3490. }
  3491. }
  3492. if( zsZone )
  3493. {
  3494. zsZone->SetZoneLockState(true);
  3495. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now locked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  3496. }
  3497. else
  3498. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be locked.", sep->arg[1]);
  3499. notZoningCommand = true;
  3500. break;
  3501. }
  3502. else if(strncasecmp(sep->arg[0], "unlock", 6) == 0)
  3503. {
  3504. PrintSep(sep, "ZONE UNLOCK");
  3505. if(sep->IsNumber(1)) {
  3506. if(zone_list.GetZone(&zone_details, atoul(sep->arg[1]), "", false, false, false, false)) {
  3507. zsZone = (ZoneServer*)zone_details.zonePtr;
  3508. }
  3509. }
  3510. else {
  3511. if(zone_list.GetZone(&zone_details, 0, std::string(sep->arg[1]), false, false, false, false)) {
  3512. zsZone = (ZoneServer*)zone_details.zonePtr;
  3513. }
  3514. }
  3515. if( zsZone )
  3516. {
  3517. zsZone->SetZoneLockState(false);
  3518. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now unlocked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  3519. }
  3520. else
  3521. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be unlocked.", sep->arg[1]);
  3522. notZoningCommand = true;
  3523. break;
  3524. }
  3525. else
  3526. {
  3527. if(sep->IsNumber(0))
  3528. {
  3529. zone_id = atoul(sep->arg[0]);
  3530. string zonename = database.GetZoneName(zone_id);
  3531. if(zonename.length() > 0)
  3532. zone = zonename;
  3533. }
  3534. else
  3535. zone = sep->arg[0];
  3536. }
  3537. if(instanceID > 0)
  3538. {
  3539. if(zone_list.GetZoneByInstance(&zone_details, instanceID, 0, true)) {
  3540. instanceID = zone_details.instanceId;
  3541. zone = zone_details.zoneName;
  3542. zone_id = zone_details.zoneId;
  3543. }
  3544. isInstance = true;
  3545. }
  3546. }
  3547. if(!listSearch)
  3548. {
  3549. if(zone.length() == 0)
  3550. client->Message(CHANNEL_COLOR_RED, "Error: Invalid Zone");
  3551. else if(instanceID != client->GetCurrentZone()->GetInstanceID() ||
  3552. zone_id != client->GetCurrentZone()->GetZoneID())
  3553. {
  3554. const char* zonestr = zone.c_str();
  3555. if(database.VerifyZone(zonestr))
  3556. {
  3557. if(client->CheckZoneAccess(zonestr))
  3558. {
  3559. client->Message(CHANNEL_COLOR_YELLOW,"Zoning to %s...", zonestr);
  3560. if(isInstance)
  3561. client->Zone(&zone_details,(ZoneServer*)zone_details.zonePtr,true,false);
  3562. else
  3563. client->Zone(zonestr);
  3564. }
  3565. }
  3566. else
  3567. client->Message(CHANNEL_COLOR_RED, "Error: Zone '%s' not found. To get a list type /zone list", zonestr);
  3568. }
  3569. else
  3570. client->Message(CHANNEL_COLOR_RED, "Error: You are already in that zone!");
  3571. }
  3572. else
  3573. {
  3574. const char* name = 0;
  3575. if(sep && sep->arg[1][0])
  3576. {
  3577. map<int32, string>* zone_names;
  3578. name = sep->argplus[1];
  3579. sint16 status = client->GetAdminStatus();
  3580. if( status > 0 )
  3581. {
  3582. client->SimpleMessage(CHANNEL_COLOR_RED, "ADMIN MODE");
  3583. zone_names = database.GetZoneList(name, true);
  3584. }
  3585. else
  3586. zone_names = database.GetZoneList(name);
  3587. if(!zone_names)
  3588. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No zones found.");
  3589. else
  3590. {
  3591. map<int32, string>::iterator itr;
  3592. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  3593. for(itr = zone_names->begin(); itr != zone_names->end(); itr++)
  3594. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  3595. safe_delete(zone_names);
  3596. }
  3597. }
  3598. else
  3599. {
  3600. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone [zone name]");
  3601. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone list [partial zone name]");
  3602. }
  3603. }
  3604. break;
  3605. }
  3606. case COMMAND_USE: {
  3607. Spawn* target = cmdTarget;
  3608. if (target && target->IsWidget())
  3609. ((Widget*)target)->HandleUse(client, "use");
  3610. break;
  3611. }
  3612. case COMMAND_OPEN: {
  3613. Spawn* target = cmdTarget;
  3614. if (target && target->IsWidget())
  3615. ((Widget*)target)->HandleUse(client, "Open", WIDGET_TYPE_DOOR);
  3616. break;
  3617. }
  3618. case COMMAND_CASTSPELL: {
  3619. if (sep && sep->arg[0] && sep->IsNumber(0))
  3620. {
  3621. int8 tier = 1;
  3622. if (sep->arg[1] && sep->IsNumber(1))
  3623. tier = atoul(sep->arg[1]);
  3624. int8 self = 1;
  3625. if (sep->arg[1] && sep->IsNumber(2))
  3626. {
  3627. self = atoul(sep->arg[2]);
  3628. if(self != 1 && !cmdTarget->IsEntity())
  3629. {
  3630. client->Message(CHANNEL_COLOR_RED, "Target is not an entity required to cast non-self spell.");
  3631. self = 1;
  3632. }
  3633. }
  3634. int32 spellid = atoul(sep->arg[0]);
  3635. Spell* spell = master_spell_list.GetSpell(spellid, tier);
  3636. if (spell)
  3637. {
  3638. client->Message(CHANNEL_COLOR_RED, "Casting spell %u.", spellid);
  3639. SpellProcess* spellProcess = 0;
  3640. // Get the current zones spell process
  3641. spellProcess = client->GetCurrentZone()->GetSpellProcess();
  3642. spellProcess->CastInstant(spell, (!cmdTarget || self == 1) ? (Entity*)client->GetPlayer() : (Entity*)cmdTarget, (cmdTarget && cmdTarget->IsEntity()) ? (Entity*)cmdTarget : (Entity*)client->GetPlayer());
  3643. }
  3644. else
  3645. {
  3646. client->Message(CHANNEL_COLOR_RED, "Could not find spell %u.",spellid);
  3647. }
  3648. }
  3649. else if (sep && sep->arg[0])
  3650. {
  3651. database.FindSpell(client, (char*)sep->argplus[0]);
  3652. }
  3653. else
  3654. {
  3655. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellid] (tier=1) - Cast Spell with specified spell id, tier is optional, default of 1.");
  3656. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellname] - Find spells wildcard match with a partial spell name");
  3657. }
  3658. break;
  3659. }
  3660. case COMMAND_KNOWLEDGEWINDOWSORT: {
  3661. if (sep && (client->GetVersion() <= 561 && sep->GetArgNumber() == 3) || sep->GetArgNumber() == 4)
  3662. {
  3663. int32 book = atoul(sep->arg[0]); // 0 - spells, 1 - combat, 2 - abilities, 3 - tradeskill
  3664. // cannot sort the ability book in this client it is greyed out
  3665. if (client->GetVersion() <= 561 && book == SPELL_BOOK_TYPE_ABILITY)
  3666. break;
  3667. int32 sort_by = atoul(sep->arg[1]); // 0 - alpha, 1 - level, 2 - category
  3668. int32 order = atoul(sep->arg[2]); // 0 - ascending, 1 - descending
  3669. int32 pattern = atoul(sep->arg[3]); // 0 - zigzag, 1 - down, 2 - across
  3670. int32 maxlvlonly = 0;
  3671. if(client->GetVersion() > 561 && sep->arg[4][0]) {
  3672. maxlvlonly = atoul(sep->arg[4]); // checkbox for newer clients
  3673. }
  3674. client->GetPlayer()->ResortSpellBook(sort_by, order, pattern, maxlvlonly, book);
  3675. ClientPacketFunctions::SendSkillSlotMappings(client);
  3676. }
  3677. else
  3678. {
  3679. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /knowledgewindow_sort [book] [sort_by] [order] [pattern]");
  3680. }
  3681. break;
  3682. }
  3683. case COMMAND_MOVE_ITEM:
  3684. {
  3685. int32 id = 0;
  3686. if (sep && sep->IsNumber(0))
  3687. id = atoul(sep->arg[0]);
  3688. Spawn* spawn = 0;
  3689. if (id == 0)
  3690. {
  3691. spawn = cmdTarget;
  3692. }
  3693. else
  3694. spawn = client->GetCurrentZone()->GetSpawnFromUniqueItemID(id);
  3695. if (!spawn || !client->HasOwnerOrEditAccess() || !spawn->GetPickupItemID())
  3696. break;
  3697. Item* item = master_item_list.GetItem(spawn->GetPickupItemID());
  3698. client->SendMoveObjectMode(spawn, (item && item->houseitem_info) ? item->houseitem_info->house_location : 0);
  3699. break;
  3700. }
  3701. case COMMAND_PICKUP:
  3702. {
  3703. int32 id = 0;
  3704. if (sep && sep->IsNumber(0))
  3705. id = atoul(sep->arg[0]);
  3706. Spawn* spawn = 0;
  3707. if (id == 0)
  3708. {
  3709. spawn = cmdTarget;
  3710. }
  3711. else
  3712. spawn = client->GetCurrentZone()->GetSpawnFromUniqueItemID(id);
  3713. if (!spawn || !client->HasOwnerOrEditAccess() || !spawn->GetPickupItemID())
  3714. break;
  3715. if(client->AddItem(spawn->GetPickupItemID(), 1)) {
  3716. Query query;
  3717. 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());
  3718. if (database.RemoveSpawnFromSpawnLocation(spawn)) {
  3719. client->GetCurrentZone()->RemoveSpawn(spawn, true, true, true, true, true);
  3720. }
  3721. // we had a UI Window displayed, update the house items
  3722. if ( id > 0 )
  3723. client->GetCurrentZone()->SendHouseItems(client);
  3724. }
  3725. break;
  3726. }
  3727. case COMMAND_HOUSE_DEPOSIT:
  3728. {
  3729. PrintSep(sep, "COMMAND_HOUSE_DEPOSIT");
  3730. // arg0 = spawn_id for DoF, could also be house_id for newer clients
  3731. // arg1 = coin (in copper)
  3732. // arg2 = status? (not implemented yet)
  3733. PlayerHouse* ph = nullptr;
  3734. int32 spawn_id = 0;
  3735. if(sep && sep->arg[0]) {
  3736. spawn_id = atoul(sep->arg[0]);
  3737. ph = world.GetPlayerHouse(client, spawn_id, client->GetVersion() > 561 ? spawn_id : 0, nullptr);
  3738. }
  3739. if(!ph) {
  3740. ph = world.GetPlayerHouseByInstanceID(client->GetCurrentZone()->GetInstanceID());
  3741. }
  3742. if (ph && sep && sep->IsNumber(1))
  3743. {
  3744. int64 outValCoin = strtoull(sep->arg[1], NULL, 0);
  3745. int32 outValStatus = 0;
  3746. if(sep->IsNumber(2))
  3747. {
  3748. outValStatus = strtoull(sep->arg[2], NULL, 0);
  3749. if(outValStatus > client->GetPlayer()->GetInfoStruct()->get_status_points())
  3750. outValStatus = 0; // cheat check
  3751. }
  3752. if ((!outValCoin && outValStatus) || client->GetPlayer()->RemoveCoins(outValCoin))
  3753. {
  3754. if(outValStatus)
  3755. client->GetPlayer()->GetInfoStruct()->subtract_status_points(outValStatus);
  3756. char query[256];
  3757. map<string,Deposit>::iterator itr = ph->depositsMap.find(string(client->GetPlayer()->GetName()));
  3758. if (itr != ph->depositsMap.end())
  3759. {
  3760. snprintf(query, 256, "update character_house_deposits set timestamp = %u, amount = amount + %llu, last_amount = %llu, status = status + %u, last_status = %u where house_id = %u and instance_id = %u and name='%s'", Timer::GetUnixTimeStamp(), outValCoin, outValCoin, outValStatus, outValStatus, ph->house_id, ph->instance_id, client->GetPlayer()->GetName());
  3761. }
  3762. else
  3763. snprintf(query, 256, "insert into character_house_deposits set timestamp = %u, house_id = %u, instance_id = %u, name='%s', amount = %llu, status = %u", Timer::GetUnixTimeStamp(), ph->house_id, ph->instance_id, client->GetPlayer()->GetName(), outValCoin, outValStatus);
  3764. if (database.RunQuery(query, strnlen(query, 256)))
  3765. {
  3766. ph->escrow_coins += outValCoin;
  3767. ph->escrow_status += outValStatus;
  3768. database.UpdateHouseEscrow(ph->house_id, ph->instance_id, ph->escrow_coins, ph->escrow_status);
  3769. database.LoadDeposits(ph);
  3770. client->PlaySound("coin_cha_ching");
  3771. HouseZone* hz = world.GetHouseZone(ph->house_id);
  3772. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetVersion() <= 561 ? spawn_id : client->GetPlayer()->GetID());
  3773. }
  3774. else
  3775. {
  3776. if(outValCoin)
  3777. client->GetPlayer()->AddCoins(outValCoin);
  3778. if(outValStatus)
  3779. client->GetPlayer()->GetInfoStruct()->add_status_points(outValStatus);
  3780. client->SimpleMessage(CHANNEL_COLOR_RED, "Deposit failed!");
  3781. }
  3782. }
  3783. }
  3784. break;
  3785. }
  3786. case COMMAND_HOUSE:
  3787. {
  3788. int32 spawn_id = 0;
  3789. if (sep && sep->IsNumber(0))
  3790. {
  3791. PlayerHouse* ph = nullptr;
  3792. if(!ph && sep && sep->arg[0]) {
  3793. spawn_id = atoul(sep->arg[0]);
  3794. ph = world.GetPlayerHouse(client, spawn_id, spawn_id, nullptr);
  3795. }
  3796. HouseZone* hz = 0;
  3797. if (ph)
  3798. hz = world.GetHouseZone(ph->house_id);
  3799. // there is a arg[1] that is true/false, but not sure what it is for investigate more later
  3800. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetVersion() <= 561 ? spawn_id : client->GetPlayer()->GetID());
  3801. }
  3802. else if (client->GetCurrentZone()->GetInstanceType() != 0)
  3803. {
  3804. // inside a house or something? Send the access window
  3805. PlayerHouse* ph = world.GetPlayerHouseByInstanceID(client->GetCurrentZone()->GetInstanceID());
  3806. HouseZone* hz = 0;
  3807. if ( ph )
  3808. hz = world.GetHouseZone(ph->house_id);
  3809. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetVersion() <= 561 ? spawn_id : client->GetPlayer()->GetID());
  3810. client->GetCurrentZone()->SendHouseItems(client);
  3811. }
  3812. break;
  3813. }
  3814. case COMMAND_HOUSE_UI:
  3815. {
  3816. if (sep && sep->IsNumber(0) && client->GetCurrentZone()->GetInstanceType() == Instance_Type::NONE)
  3817. {
  3818. int32 unique_id = atoi(sep->arg[0]);
  3819. PlayerHouse* ph = world.GetPlayerHouseByUniqueID(unique_id);
  3820. HouseZone* hz = 0;
  3821. if ( ph )
  3822. hz = world.GetHouseZone(ph->house_id);
  3823. // there is a arg[1] that is true/false, but not sure what it is for investigate more later
  3824. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  3825. }
  3826. break;
  3827. }
  3828. case COMMAND_PLACE_HOUSE_ITEM: {
  3829. if (sep && sep->IsNumber(0))
  3830. {
  3831. int32 uniqueid = atoi(sep->arg[0]);
  3832. Item* item = client->GetPlayer()->item_list.GetItemFromUniqueID(uniqueid);
  3833. //Item* item = player->GetEquipmentList()->GetItem(slot);
  3834. if (item && item->IsHouseItem())
  3835. {
  3836. if (!client->HasOwnerOrEditAccess())
  3837. {
  3838. client->SimpleMessage(CHANNEL_COLOR_RED, "This is not your home!");
  3839. break;
  3840. }
  3841. else if (!item->generic_info.appearance_id)
  3842. {
  3843. 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);
  3844. break;
  3845. }
  3846. else if(item->CheckFlag2(HOUSE_LORE) && client->GetCurrentZone()->HouseItemSpawnExists(item->details.item_id)) {
  3847. client->Message(CHANNEL_COLOR_RED, "Item %s is house lore and you cannot place another.", item->name.c_str());
  3848. break;
  3849. }
  3850. if (client->GetTempPlacementSpawn())
  3851. {
  3852. Spawn* tmp = client->GetTempPlacementSpawn();
  3853. client->GetCurrentZone()->RemoveSpawn(tmp, true, true, true, true, true);
  3854. client->SetTempPlacementSpawn(nullptr);
  3855. }
  3856. Object* obj = new Object();
  3857. Spawn* spawn = (Spawn*)obj;
  3858. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3859. strcpy(spawn->appearance.name, "temp");
  3860. spawn->SetX(client->GetPlayer()->GetX());
  3861. spawn->SetY(client->GetPlayer()->GetY());
  3862. spawn->SetZ(client->GetPlayer()->GetZ());
  3863. spawn->appearance.pos.collision_radius = 32;
  3864. spawn->SetHeading(client->GetPlayer()->GetHeading());
  3865. spawn->SetSpawnOrigX(spawn->GetX());
  3866. spawn->SetSpawnOrigY(spawn->GetY());
  3867. spawn->SetSpawnOrigZ(spawn->GetZ());
  3868. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  3869. spawn->appearance.targetable = 1;
  3870. spawn->appearance.activity_status = ACTIVITY_STATUS_SOLID;
  3871. spawn->appearance.race = item && item->generic_info.appearance_id ? item->generic_info.appearance_id : 1472;
  3872. spawn->SetModelType(item && item->generic_info.appearance_id ? item->generic_info.appearance_id : 1472);
  3873. spawn->SetLocation(client->GetPlayer()->GetLocation());
  3874. spawn->SetZone(client->GetCurrentZone());
  3875. client->SetTempPlacementSpawn(spawn);
  3876. client->SetPlacementUniqueItemID(uniqueid);
  3877. client->GetCurrentZone()->AddSpawn(spawn);
  3878. }
  3879. }
  3880. break;
  3881. }
  3882. case COMMAND_GM:
  3883. {
  3884. if (sep && sep->arg[0] && sep->arg[1])
  3885. {
  3886. bool onOff = (strcmp(sep->arg[1], "on") == 0);
  3887. if (strcmp(sep->arg[0], "vision") == 0)
  3888. {
  3889. client->GetPlayer()->SetGMVision(onOff);
  3890. #if defined(__GNUC__)
  3891. database.insertCharacterProperty(client, CHAR_PROPERTY_GMVISION, (onOff) ? (char*)"1" : (char*)"0");
  3892. #else
  3893. database.insertCharacterProperty(client, CHAR_PROPERTY_GMVISION, (onOff) ? "1" : "0");
  3894. #endif
  3895. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3896. if (onOff)
  3897. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Vision Enabled!");
  3898. else
  3899. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Vision Disabled!");
  3900. }
  3901. else if (strcmp(sep->arg[0], "tag") == 0)
  3902. {
  3903. int32 value = 0;
  3904. int16 tag_icon = 0;
  3905. // groundspawn has special exception -1 argument so it needs to be handled here
  3906. if(sep->arg[2] && sep->arg[3] && ((tag_icon = atoul(sep->arg[3])) > 0) || (strncasecmp(sep->arg[1], "groundspawn", 11) == 0)) {
  3907. value = atoul(sep->arg[2]);
  3908. if(strncasecmp(sep->arg[1], "faction", 7) == 0){
  3909. if(!value) {
  3910. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid faction id.");
  3911. break;
  3912. }
  3913. if(!tag_icon) {
  3914. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid tag icon id.");
  3915. break;
  3916. }
  3917. client->GetPlayer()->AddGMVisualFilter(GMTagFilterType::GMFILTERTYPE_FACTION, value, "", tag_icon);
  3918. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3919. client->Message(CHANNEL_COLOR_RED, "Adding faction id %u with tag icon %u.", value, tag_icon);
  3920. }
  3921. else if(strncasecmp(sep->arg[1], "spawngroup", 10) == 0){
  3922. if(value>0) {
  3923. value = 1;
  3924. }
  3925. if(!tag_icon) {
  3926. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid tag icon id.");
  3927. break;
  3928. }
  3929. client->GetPlayer()->AddGMVisualFilter(GMTagFilterType::GMFILTERTYPE_SPAWNGROUP, value, "", tag_icon);
  3930. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3931. client->Message(CHANNEL_COLOR_RED, "Adding spawn group tag \"%s\" with tag icon %u.", (value == 1) ? "on" : "off", tag_icon);
  3932. }
  3933. else if(strncasecmp(sep->arg[1], "race", 4 == 0)){
  3934. if(!value) {
  3935. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid race id.");
  3936. break;
  3937. }
  3938. if(!tag_icon) {
  3939. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid tag icon id.");
  3940. break;
  3941. }
  3942. client->GetPlayer()->AddGMVisualFilter(GMTagFilterType::GMFILTERTYPE_RACE, value, "", tag_icon);
  3943. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3944. client->Message(CHANNEL_COLOR_RED, "Adding race id %u with tag icon %u.", value, tag_icon);
  3945. }
  3946. else if(strncasecmp(sep->arg[1], "groundspawn", 11) == 0){
  3947. // one less argument value field not tag_icon for this one
  3948. if(!value) {
  3949. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid tag icon id.");
  3950. break;
  3951. }
  3952. client->GetPlayer()->AddGMVisualFilter(GMTagFilterType::GMFILTERTYPE_GROUNDSPAWN, 1, "", value);
  3953. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3954. client->Message(CHANNEL_COLOR_RED, "Adding groundspawns with tag icon %u.", value);
  3955. }
  3956. }
  3957. else {
  3958. if(strncasecmp(sep->arg[1], "clear", 5) == 0){
  3959. client->GetPlayer()->ClearGMVisualFilters();
  3960. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Tags Cleared!");
  3961. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3962. }
  3963. else {
  3964. client->SimpleMessage(CHANNEL_COLOR_RED, "GM Tagging Missing Arguments:");
  3965. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/gm tag [type] [value] [visual_icon_display]");
  3966. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/gm tag clear - Clears all GM visual tags");
  3967. client->SimpleMessage(CHANNEL_COLOR_RED, "Visual Type Options:");
  3968. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "type: faction, value: faction id of spawn(s)");
  3969. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "type: spawngroup, value: 1 to show grouped, 0 to show not grouped");
  3970. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "type: race, value: race id (either against base race or race id in spawn details)");
  3971. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "type: groundspawn, value: (not used)");
  3972. client->SimpleMessage(CHANNEL_COLOR_RED, "Visual Icon Options:");
  3973. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3974. "1 = skull, 2 = shield half dark blue / half light blue, 3 = purple? star, 4 = yellow sword, 5 = red X, 6 = green flame");
  3975. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3976. "7 = Number \"1\", 8 = Number \"2\", 9 = Number \"3\", 10 = Number \"4\", 11 = Number \"5\", 12 = Number \"6\"");
  3977. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3978. "25 = shield, 26 = green plus, 27 = crossed swords, 28 = bow with arrow in it, 29 = light blue lightning bolt");
  3979. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3980. "30 = bard instrument (hard to see), 31 = writ with shield, 32 = writ with green +, 33 = writ with crossed sword");
  3981. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3982. "34 = writ with bow, 35 = writ with light blue lightning bolt, 36 = same as 30, 37 = party with crossed sword, shield and lightning bolt");
  3983. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3984. "38 = shaking hands green background, 39 = shaking hands dark green background, unlocked keylock");
  3985. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3986. "40 = red aura icon with black shadow of person and big red aura, 41 = green aura icon with black shadow of person big green aura");
  3987. }
  3988. }
  3989. }
  3990. else if (strcmp(sep->arg[0], "regiondebug") == 0)
  3991. {
  3992. client->SetRegionDebug(onOff);
  3993. #if defined(__GNUC__)
  3994. database.insertCharacterProperty(client, CHAR_PROPERTY_REGIONDEBUG, (onOff) ? (char*)"1" : (char*)"0");
  3995. #else
  3996. database.insertCharacterProperty(client, CHAR_PROPERTY_REGIONDEBUG, (onOff) ? "1" : "0");
  3997. #endif
  3998. if (onOff)
  3999. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Region Debug Enabled!");
  4000. else
  4001. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Region Debug Disabled!");
  4002. }
  4003. else if (strcmp(sep->arg[0], "sight") == 0)
  4004. {
  4005. if(onOff && cmdTarget) {
  4006. client->SetPlayerPOVGhost(cmdTarget);
  4007. }
  4008. else
  4009. client->SetPlayerPOVGhost(nullptr);
  4010. }
  4011. else if (strcmp(sep->arg[0], "controleffects") == 0)
  4012. {
  4013. if(cmdTarget && cmdTarget->IsEntity()) {
  4014. ((Entity*)cmdTarget)->SendControlEffectDetailsToClient(client);
  4015. }
  4016. else {
  4017. client->GetPlayer()->SendControlEffectDetailsToClient(client);
  4018. }
  4019. }
  4020. else if (strcmp(sep->arg[0], "luadebug") == 0)
  4021. {
  4022. client->SetLuaDebugClient(onOff);
  4023. #if defined(__GNUC__)
  4024. database.insertCharacterProperty(client, CHAR_PROPERTY_LUADEBUG, (onOff) ? (char*)"1" : (char*)"0");
  4025. #else
  4026. database.insertCharacterProperty(client, CHAR_PROPERTY_LUADEBUG, (onOff) ? "1" : "0");
  4027. #endif
  4028. if (onOff)
  4029. {
  4030. if (lua_interface)
  4031. lua_interface->UpdateDebugClients(client);
  4032. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will now receive LUA error messages.");
  4033. }
  4034. else
  4035. {
  4036. if (lua_interface)
  4037. lua_interface->RemoveDebugClients(client);
  4038. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will no longer receive LUA error messages.");
  4039. }
  4040. }
  4041. }
  4042. break;
  4043. }
  4044. case COMMAND_ATTACK:
  4045. case COMMAND_AUTO_ATTACK:{
  4046. Command_AutoAttack(client, sep);
  4047. break;
  4048. }
  4049. case COMMAND_DEPOP:{
  4050. bool allow_respawns = false;
  4051. if(sep && sep->arg[0] && sep->IsNumber(0)){
  4052. if(atoi(sep->arg[0]) == 1)
  4053. allow_respawns = true;
  4054. }
  4055. client->GetCurrentZone()->Depop(allow_respawns);
  4056. break;
  4057. }
  4058. case COMMAND_REPOP:{
  4059. client->GetCurrentZone()->Depop(false, true);
  4060. break;
  4061. }
  4062. case COMMAND_BUYBACK:{
  4063. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  4064. // 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
  4065. int64 id = atoi64(sep->arg[0]);
  4066. // get the first int32, the item id
  4067. //int32 item_id = (int32)id;
  4068. // get the second int32, the unique id
  4069. int32 unique_id = (int32)(id>>32);
  4070. int8 quantity = atoi(sep->arg[1]);
  4071. if(quantity == 255)
  4072. quantity = 1;
  4073. client->BuyBack(unique_id, quantity);
  4074. }
  4075. break;
  4076. }
  4077. case COMMAND_MERCHANT_BUY:{
  4078. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  4079. int32 item_id = atoul(sep->arg[0]);
  4080. int8 quantity = atoi(sep->arg[1]);
  4081. client->BuyItem(item_id, quantity);
  4082. }
  4083. else
  4084. Command_SendMerchantWindow(client, sep);
  4085. break;
  4086. }
  4087. case COMMAND_MERCHANT_SELL:{
  4088. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  4089. // 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
  4090. int64 id = atoi64(sep->arg[0]);
  4091. // get the first int32, the item id
  4092. int32 item_id = (int32)id;
  4093. // get the second int32, the unique id
  4094. int32 unique_id = (int32)(id>>32);
  4095. int8 quantity = atoi(sep->arg[1]);
  4096. LogWrite(MERCHANT__DEBUG, 0, "Merchant", "Selling Item: Item Id = %ul, unique id = %ul, Quantity = %i", item_id, unique_id, quantity);
  4097. client->SellItem(item_id, quantity, unique_id);
  4098. }
  4099. break;
  4100. }
  4101. case COMMAND_MENDER_REPAIR: {
  4102. if (sep && sep->arg[0] && sep->IsNumber(0))
  4103. client->RepairItem(atoul(sep->arg[0]));
  4104. break;
  4105. }
  4106. case COMMAND_MENDER_REPAIR_ALL: {
  4107. client->RepairAllItems();
  4108. break;
  4109. }
  4110. case COMMAND_CANCEL_MERCHANT:{
  4111. client->SetMerchantTransaction(0);
  4112. break;
  4113. }
  4114. case COMMAND_START_MERCHANT:{
  4115. break;
  4116. }
  4117. case COMMAND_INVULNERABLE:{
  4118. sint8 val = -1;
  4119. if(sep && sep->arg[0] && sep->IsNumber(0)){
  4120. val = atoi(sep->arg[0]);
  4121. //devn00b: Fix for linux builds
  4122. #if defined(__GNUC__)
  4123. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? (char*) "1" : (char*) "0");
  4124. #else
  4125. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  4126. #endif
  4127. // database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  4128. client->GetPlayer()->SetInvulnerable(val==1);
  4129. if(client->GetPlayer()->GetInvulnerable())
  4130. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are now invulnerable!");
  4131. else
  4132. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are no longer invulnerable!");
  4133. }
  4134. if(val == -1)
  4135. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /invulnerable [0/1]");
  4136. break;
  4137. }
  4138. case COMMAND_REPAIR: {
  4139. Spawn* spawn = cmdTarget;
  4140. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR) {
  4141. client->SendHailCommand(spawn);
  4142. client->SetMerchantTransaction(spawn);
  4143. client->SendRepairList();
  4144. }
  4145. break;
  4146. }
  4147. case COMMAND_LOTTO: {
  4148. Spawn* spawn = cmdTarget;
  4149. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_LOTTO) {
  4150. client->SetMerchantTransaction(spawn);
  4151. client->ShowLottoWindow();
  4152. }
  4153. break;
  4154. }
  4155. case COMMAND_ACCEPT_REWARD:{
  4156. int32 unknown = 0;
  4157. int32 selectable_item_id = 0;
  4158. //Quest *quest = 0;
  4159. /* no idea what the first argument is for (faction maybe?)
  4160. if the reward has a selectable item reward, it's sent as the second argument
  4161. if neither of these are included in the reward, there is no sep
  4162. 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
  4163. only 1 quest or collection reward may be displayed at a time */
  4164. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  4165. unknown = atoul(sep->arg[0]);
  4166. selectable_item_id = atoul(sep->arg[1]);
  4167. }
  4168. /* this logic here may seem unexpected, but the quest queue response for GetPendingQuestAcceptance is only populated if it is the current reward displayed to the client based on a quest
  4169. ** Otherwise it will likely be a DoF client scenario (pending item rewards, selectable item rewards) which is specifying an item id
  4170. ** lastly it will be a collection which also supplies an item id and you can only have one pending collection turn in at a time (they queue against Client::HandInCollections
  4171. */
  4172. int32 item_id = 0;
  4173. if(sep && sep->arg[0][0] && sep->IsNumber(0))
  4174. item_id = atoul(sep->arg[0]);
  4175. bool collectedItems = client->GetPlayer()->AcceptQuestReward(item_id, selectable_item_id);
  4176. if (collectedItems) {
  4177. EQ2Packet* outapp = client->GetPlayer()->SendInventoryUpdate(client->GetVersion());
  4178. if (outapp)
  4179. client->QueuePacket(outapp);
  4180. }
  4181. else
  4182. LogWrite(COMMAND__ERROR, 0, "Command", "Error in COMMAND_ACCEPT_REWARD. No pending quest or collection reward was found (unknown=%u).", unknown);
  4183. break;
  4184. }
  4185. case COMMAND_BUY_FROM_BROKER:{
  4186. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  4187. int32 item_id = atoul(sep->arg[0]);
  4188. int16 quantity = atoul(sep->arg[1]);
  4189. Item* item = master_item_list.GetItem(item_id);
  4190. if(item && item->generic_info.max_charges > 1)
  4191. quantity = item->generic_info.max_charges;
  4192. client->AddItem(item_id, quantity, AddItemType::BUY_FROM_BROKER);
  4193. }
  4194. break;
  4195. }
  4196. case COMMAND_SEARCH_STORES_PAGE:{
  4197. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  4198. int32 page = atoul(sep->arg[0]);
  4199. client->SearchStore(page);
  4200. }
  4201. break;
  4202. }
  4203. case COMMAND_SEARCH_STORES:{
  4204. if(sep && sep->arg[0][0]){
  4205. const char* values = sep->argplus[0];
  4206. if(values){
  4207. LogWrite(ITEM__WARNING, 0, "Item", "SearchStores: %s", values);
  4208. map<string, string> str_values = TranslateBrokerRequest(values);
  4209. vector<Item*>* items = master_item_list.GetItems(str_values, client);
  4210. if(items){
  4211. client->SetItemSearch(items);
  4212. client->SearchStore(0);
  4213. }
  4214. }
  4215. }
  4216. break;
  4217. }
  4218. case COMMAND_LUADEBUG:{
  4219. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "start") == 0){
  4220. client->SetLuaDebugClient(true);
  4221. if(lua_interface)
  4222. lua_interface->UpdateDebugClients(client);
  4223. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will now receive LUA error messages.");
  4224. }
  4225. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "stop") == 0){
  4226. client->SetLuaDebugClient(false);
  4227. if(lua_interface)
  4228. lua_interface->RemoveDebugClients(client);
  4229. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will no longer receive LUA error messages.");
  4230. }
  4231. else{
  4232. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /luadebug {start | stop}");
  4233. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will allow you to receive lua debug messages normally seen only in the console.");
  4234. }
  4235. break;
  4236. }
  4237. case COMMAND_SPAWN_GROUP:
  4238. {
  4239. Spawn* target = cmdTarget;
  4240. if(target && target->IsPlayer() == false)
  4241. {
  4242. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "create") == 0)
  4243. {
  4244. if(target->GetSpawnLocationPlacementID() > 0)
  4245. {
  4246. if(sep->arg[1] && !sep->IsNumber(1) && strlen(sep->arg[1]) > 0)
  4247. {
  4248. int32 id = database.CreateSpawnGroup(target, sep->arg[1]);
  4249. if(id > 0)
  4250. client->Message(CHANNEL_COLOR_YELLOW, "Successfully created new spawn group with id: %u", id);
  4251. else
  4252. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error creating group, check console for details.");
  4253. target->SetSpawnGroupID(id);
  4254. target->AddSpawnToGroup(target);
  4255. }
  4256. else
  4257. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group create [name]");
  4258. }
  4259. else
  4260. 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.");
  4261. }
  4262. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "add") == 0)
  4263. {
  4264. if(sep->arg[1] && sep->IsNumber(1))
  4265. {
  4266. int32 group_id = atoul(sep->arg[1]);
  4267. Spawn* leader = client->GetCurrentZone()->GetSpawnGroup(group_id);
  4268. if(leader)
  4269. {
  4270. leader->AddSpawnToGroup(target);
  4271. target->SetSpawnGroupID(group_id);
  4272. if(database.SpawnGroupAddSpawn(target, group_id))
  4273. client->Message(CHANNEL_COLOR_YELLOW, "Successfully added '%s' to group id: %u", target->GetName(), group_id);
  4274. else
  4275. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error adding spawn to group, check console for details.");
  4276. }
  4277. else
  4278. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No spawns found in the current zone for that spawn group, be sure to use '/spawn group create' first!");
  4279. }
  4280. else
  4281. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group add [group id]");
  4282. }
  4283. else if(target->GetSpawnGroupID() == 0)
  4284. {
  4285. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That spawn is not in a group!");
  4286. }
  4287. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "remove") == 0)
  4288. {
  4289. int32 group_id = target->GetSpawnGroupID();
  4290. target->RemoveSpawnFromGroup();
  4291. if(database.SpawnGroupRemoveSpawn(target, group_id))
  4292. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed '%s' from group id: %u", target->GetName(), group_id);
  4293. else
  4294. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing spawn from group, check console for details.");
  4295. }
  4296. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "associate") == 0)
  4297. {
  4298. int32 group_id = target->GetSpawnGroupID();
  4299. if(sep->arg[1] && sep->IsNumber(1))
  4300. {
  4301. if(database.SpawnGroupAddAssociation(group_id, atoul(sep->arg[1])))
  4302. client->Message(CHANNEL_COLOR_YELLOW, "Successfully associated group id %u with group id %u", group_id, atoul(sep->arg[1]));
  4303. else
  4304. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error associating groups, check console for details.");
  4305. }
  4306. else
  4307. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Allows you to spawn only one associated group at once. Syntax: /spawn group associate [other group id]");
  4308. }
  4309. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "deassociate") == 0)
  4310. {
  4311. int32 group_id = target->GetSpawnGroupID();
  4312. if(sep->arg[1] && sep->IsNumber(1))
  4313. {
  4314. if(database.SpawnGroupRemoveAssociation(group_id, atoul(sep->arg[1])))
  4315. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed association between group id %u and group id %u", group_id, atoul(sep->arg[1]));
  4316. else
  4317. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing group associations, check console for details.");
  4318. }
  4319. else
  4320. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Removes previous group associations. Syntax: /spawn group deassociate [other group id]");
  4321. }
  4322. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "chance") == 0)
  4323. {
  4324. if(sep->arg[1] && sep->IsNumber(1))
  4325. {
  4326. if(database.SetGroupSpawnChance(target->GetSpawnGroupID(), atof(sep->arg[1])))
  4327. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set group spawn chance to %f for group id: %u", atof(sep->arg[1]), target->GetSpawnGroupID());
  4328. else
  4329. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error setting group spawn chance, check console for details.");
  4330. }
  4331. else
  4332. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group chance [group's spawn chance percentage]");
  4333. }
  4334. else
  4335. {
  4336. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command allows you to modify spawn groups.");
  4337. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group [create/add/remove/chance/associate/deassociate]");
  4338. }
  4339. }
  4340. else
  4341. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select a valid spawn to use this command.");
  4342. break;
  4343. }
  4344. case COMMAND_SPAWN_COMBINE:{
  4345. Spawn* spawn = cmdTarget;
  4346. float radius = 0;
  4347. bool failed = true;
  4348. if(spawn && !spawn->IsPlayer() && sep && sep->arg[0] && sep->arg[0][0]){
  4349. failed = false;
  4350. if(spawn->GetSpawnGroupID() > 0){
  4351. 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.");
  4352. }
  4353. else if(sep->IsNumber(0)){
  4354. radius = atof(sep->arg[0]);
  4355. client->CombineSpawns(radius, spawn);
  4356. }
  4357. else{
  4358. if(strncasecmp(sep->arg[0], "add", 3) == 0){
  4359. client->AddCombineSpawn(spawn);
  4360. }
  4361. else if(strncasecmp(sep->arg[0], "remove", 6) == 0){
  4362. client->RemoveCombineSpawn(spawn);
  4363. }
  4364. else if(strncasecmp(sep->arg[0], "save", 4) == 0){
  4365. const char* name = 0;
  4366. if(sep->arg[1] && sep->arg[1][0])
  4367. name = sep->argplus[1];
  4368. client->SaveCombineSpawns(name);
  4369. }
  4370. else
  4371. failed = true;
  4372. }
  4373. }
  4374. if(failed){
  4375. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command combines several spawns into a single spawn group.");
  4376. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn combine [radius/add/remove/save]");
  4377. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Ex: /spawn combine 1, /spawn combine save (spawn group name)");
  4378. }
  4379. break;
  4380. }
  4381. case COMMAND_SPAWN_CREATE:{
  4382. Spawn* spawn = 0;
  4383. if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "object", 6) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  4384. spawn = new Object();
  4385. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  4386. }
  4387. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "groundspawn", 11) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  4388. spawn = new GroundSpawn();
  4389. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  4390. }
  4391. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "sign", 4) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  4392. spawn = new Sign();
  4393. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  4394. }
  4395. else if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "npc", 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  4396. spawn = new NPC();
  4397. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  4398. spawn->appearance.pos.collision_radius = 32;
  4399. spawn->secondary_command_list_id = 0;
  4400. spawn->primary_command_list_id = 0;
  4401. spawn->appearance.display_name = 1;
  4402. spawn->appearance.show_level = 1;
  4403. spawn->appearance.attackable = 1;
  4404. }
  4405. else{
  4406. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn create [spawn type] [race type] [class type] [level] [name] (difficulty) (size)");
  4407. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are required except difficulty and size. Valid types are Object, NPC, Sign, or GroundSpawn");
  4408. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn create npc 203 1 50 'Lady Vox' 1 32");
  4409. break;
  4410. }
  4411. spawn->SetID(Spawn::NextID());
  4412. spawn->SetX(client->GetPlayer()->GetX());
  4413. spawn->SetY(client->GetPlayer()->GetY());
  4414. spawn->SetZ(client->GetPlayer()->GetZ());
  4415. spawn->SetHeading(client->GetPlayer()->GetHeading());
  4416. spawn->SetSpawnOrigX(spawn->GetX());
  4417. spawn->SetSpawnOrigY(spawn->GetY());
  4418. spawn->SetSpawnOrigZ(spawn->GetZ());
  4419. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  4420. if(spawn->IsSign())
  4421. {
  4422. ((Sign*)spawn)->SetSignType(SIGN_TYPE_GENERIC);
  4423. ((Sign*)spawn)->SetSignDistance(20.0f);
  4424. ((Sign*)spawn)->SetIncludeLocation(1);
  4425. ((Sign*)spawn)->SetIncludeHeading(1);
  4426. ((Sign*)spawn)->SetInitialState(1);
  4427. ((Sign*)spawn)->SetSignTitle(sep->arg[4]);
  4428. ((Sign*)spawn)->SetActivityStatus(64);
  4429. spawn->appearance.race = 0;
  4430. spawn->SetLevel(0);
  4431. spawn->SetHP(0);
  4432. spawn->SetTotalHP(0);
  4433. spawn->SetPower(0);
  4434. spawn->SetTotalPower(0);
  4435. spawn->SetDifficulty(0);
  4436. spawn->SetTargetable(0);
  4437. spawn->SetSogaModelType(0);
  4438. spawn->SetCollisionRadius(19);
  4439. ((Sign*)spawn)->SetWidgetX(client->GetPlayer()->GetX());
  4440. ((Sign*)spawn)->SetWidgetY(client->GetPlayer()->GetY());
  4441. ((Sign*)spawn)->SetWidgetZ(client->GetPlayer()->GetZ());
  4442. spawn->SetLocation(client->GetPlayer()->GetLocation());
  4443. spawn->appearance.model_type = atoul(sep->arg[1]);
  4444. }
  4445. else
  4446. {
  4447. spawn->appearance.targetable = 1;
  4448. spawn->appearance.race = 255;
  4449. spawn->SetLocation(client->GetPlayer()->GetLocation());
  4450. spawn->SetModelType(atoi(sep->arg[1]));
  4451. spawn->SetAdventureClass(atoi(sep->arg[2]));
  4452. spawn->SetLevel(atoi(sep->arg[3]));
  4453. spawn->SetName(sep->arg[4]);
  4454. if(sep->arg[5][0] && sep->IsNumber(5))
  4455. spawn->SetDifficulty(atoi(sep->arg[5]));
  4456. if(sep->arg[6][0] && sep->IsNumber(6))
  4457. spawn->size = atoi(sep->arg[6]);
  4458. if(spawn->GetTotalHP() == 0){
  4459. spawn->SetTotalHP(25*spawn->GetLevel() + 1);
  4460. spawn->SetHP(25*spawn->GetLevel() + 1);
  4461. }
  4462. if(spawn->GetTotalPower() == 0){
  4463. spawn->SetTotalPower(25*spawn->GetLevel() + 1);
  4464. spawn->SetPower(25*spawn->GetLevel() + 1);
  4465. }
  4466. }
  4467. client->GetCurrentZone()->AddSpawn(spawn);
  4468. break;
  4469. }
  4470. case COMMAND_SPAWN_EQUIPMENT:{
  4471. Spawn* spawn = cmdTarget;
  4472. if(spawn && sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1) && spawn->IsEntity()){
  4473. int8 slot = atoi(sep->arg[0]);
  4474. int16 type = atoi(sep->arg[1]);
  4475. int8 red = 0;
  4476. int8 green = 0;
  4477. int8 blue = 0;
  4478. int8 h_red = 0;
  4479. int8 h_green = 0;
  4480. int8 h_blue = 0;
  4481. if(sep->arg[2])
  4482. red = atoi(sep->arg[2]);
  4483. if(sep->arg[3])
  4484. green = atoi(sep->arg[3]);
  4485. if(sep->arg[4])
  4486. blue = atoi(sep->arg[4]);
  4487. if(sep->arg[5])
  4488. h_red = atoi(sep->arg[5]);
  4489. if(sep->arg[6])
  4490. h_green = atoi(sep->arg[6]);
  4491. if(sep->arg[7])
  4492. h_blue = atoi(sep->arg[7]);
  4493. ((Entity*)spawn)->SetEquipment(slot, type, red, green, blue, h_red, h_green, h_blue);
  4494. database.SaveNPCAppearanceEquipment(spawn->GetDatabaseID() , slot, type, red, green, blue, h_red, h_green, h_blue);
  4495. }
  4496. else{
  4497. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn equipment [slot] [appearance id] (red) (green) (blue) (highlight red) (hgreen) (hblue)");
  4498. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn's equipment. ");
  4499. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Slot is 0-24, Appearance ID from appearances table, Colors are 0-255");
  4500. }
  4501. break;
  4502. }
  4503. case COMMAND_SPAWN_DETAILS: {
  4504. Spawn* spawn = cmdTarget;
  4505. if (sep && sep->arg[0][0]) {
  4506. if (cmdTarget)
  4507. {
  4508. if (ToLower(string(sep->arg[0])) == "los")
  4509. {
  4510. bool hasLOS = client->GetPlayer()->CheckLoS(cmdTarget);
  4511. if (hasLOS)
  4512. client->Message(CHANNEL_COLOR_YELLOW, "You have line of sight with %s", spawn->GetName());
  4513. else
  4514. client->Message(CHANNEL_COLOR_RED, "You DO NOT have line of sight with %s", spawn->GetName());
  4515. break;
  4516. }
  4517. else if (ToLower(string(sep->arg[0])) == "bestz")
  4518. {
  4519. glm::vec3 targPos(cmdTarget->GetX(), cmdTarget->GetZ(), cmdTarget->GetY());
  4520. float bestZ = client->GetPlayer()->FindDestGroundZ(targPos, cmdTarget->GetYOffset());
  4521. client->Message(CHANNEL_COLOR_YELLOW, "Best Z for %s is %f", spawn->GetName(), bestZ);
  4522. break;
  4523. }
  4524. else if (ToLower(string(sep->arg[0])) == "inwater")
  4525. {
  4526. if (cmdTarget->GetRegionMap() == nullptr)
  4527. client->SimpleMessage(CHANNEL_COLOR_RED, "No water map for zone.");
  4528. else
  4529. {
  4530. bool inWater = cmdTarget->InWater();
  4531. client->Message(CHANNEL_COLOR_YELLOW, "%s is %s.", cmdTarget->GetName(), inWater ? "in water" : "out of water");
  4532. }
  4533. break;
  4534. }
  4535. else if (ToLower(string(sep->arg[0])) == "inlava")
  4536. {
  4537. if (cmdTarget->GetRegionMap() == nullptr)
  4538. client->SimpleMessage(CHANNEL_COLOR_RED, "No region map for zone.");
  4539. else
  4540. {
  4541. bool inLava = cmdTarget->InLava();
  4542. client->Message(CHANNEL_COLOR_YELLOW, "%s is %s.", cmdTarget->GetName(), inLava ? "in lava" : "out of lava");
  4543. }
  4544. break;
  4545. }
  4546. else if (ToLower(string(sep->arg[0])) == "regions")
  4547. {
  4548. glm::vec3 targPos(cmdTarget->GetX(), cmdTarget->GetY(), cmdTarget->GetZ());
  4549. if (cmdTarget->GetRegionMap() == nullptr)
  4550. client->SimpleMessage(CHANNEL_COLOR_RED, "No region map for zone.");
  4551. else
  4552. {
  4553. cmdTarget->GetRegionMap()->IdentifyRegionsInGrid(client, targPos);
  4554. }
  4555. break;
  4556. }
  4557. else if (ToLower(string(sep->arg[0])) == "behind")
  4558. {
  4559. bool isBehind = client->GetPlayer()->BehindTarget(cmdTarget);
  4560. client->Message(CHANNEL_COLOR_YELLOW, "%s %s.", isBehind ? "YOU are behind" : "YOU are NOT behind", cmdTarget->GetName());
  4561. break;
  4562. }
  4563. else if (ToLower(string(sep->arg[0])) == "infront")
  4564. {
  4565. bool isBehind = client->GetPlayer()->InFrontSpawn(cmdTarget, client->GetPlayer()->GetX(), client->GetPlayer()->GetZ());
  4566. client->Message(CHANNEL_COLOR_YELLOW, "%s %s.", isBehind ? "YOU are infront of" : "YOU are NOT infront of", cmdTarget->GetName());
  4567. break;
  4568. }
  4569. else if (ToLower(string(sep->arg[0])) == "flank")
  4570. {
  4571. bool isFlanking = client->GetPlayer()->FlankingTarget(cmdTarget);
  4572. client->Message(CHANNEL_COLOR_YELLOW, "%s is %s.", isFlanking ? "YOU are flanking" : "YOU are NOT flanking", cmdTarget->GetName());
  4573. break;
  4574. }
  4575. else if (ToLower(string(sep->arg[0])) == "aggro")
  4576. {
  4577. if(cmdTarget->IsNPC() && ((NPC*)cmdTarget)->Brain()) {
  4578. ((NPC*)cmdTarget)->Brain()->SendEncounterList(client);
  4579. ((NPC*)cmdTarget)->Brain()->SendHateList(client);
  4580. }
  4581. else {
  4582. client->SimpleMessage(CHANNEL_COLOR_RED, "/spawn details aggro is for NPCs only!");
  4583. }
  4584. break;
  4585. }
  4586. else if (ToLower(string(sep->arg[0])) == "angle")
  4587. {
  4588. float spawnAngle = client->GetPlayer()->GetFaceTarget(cmdTarget->GetX(), cmdTarget->GetZ());
  4589. client->Message(CHANNEL_COLOR_YELLOW, "Angle %f between player %s and target %s", spawnAngle, client->GetPlayer()->GetTarget() ? client->GetPlayer()->GetTarget()->GetName() : client->GetPlayer()->GetName(), client->GetPlayer()->GetName());
  4590. break;
  4591. }
  4592. }
  4593. if (sep->IsNumber(0))
  4594. {
  4595. float radius = atof(sep->arg[0]);
  4596. if (!client->GetCurrentZone()->SendRadiusSpawnInfo(client, radius))
  4597. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No results in the radius were found.");
  4598. break;
  4599. }
  4600. }
  4601. if (spawn) {
  4602. const char* type = "NPC";
  4603. if (spawn->IsObject())
  4604. type = "Object";
  4605. else if (spawn->IsSign())
  4606. type = "Sign";
  4607. else if (spawn->IsWidget())
  4608. type = "Widget";
  4609. else if (spawn->IsGroundSpawn())
  4610. type = "GroundSpawn";
  4611. int16 race_type = race_types_list.GetRaceType(spawn->GetModelType());
  4612. int16 race_base_type = race_types_list.GetRaceBaseType(spawn->GetModelType());
  4613. char* category = race_types_list.GetRaceTypeCategory(spawn->GetModelType());
  4614. char* subcategory = race_types_list.GetRaceTypeSubCategory(spawn->GetModelType());
  4615. char* modelname = race_types_list.GetRaceTypeModelName(spawn->GetModelType());
  4616. client->Message(CHANNEL_COLOR_YELLOW, "Name: %s, %s ID: %u", spawn->GetName(), type, spawn->GetDatabaseID());
  4617. client->Message(CHANNEL_COLOR_YELLOW, "Last Name: %s, Sub-Title: %s, Prefix: %s, Suffix: %s", spawn->GetLastName(), spawn->GetSubTitle(), spawn->GetPrefixTitle(), spawn->GetSuffixTitle());
  4618. client->Message(CHANNEL_COLOR_YELLOW, "Spawn Location ID: %u, Spawn Group ID: %u", spawn->GetSpawnLocationID(), spawn->GetSpawnGroupID());
  4619. client->Message(CHANNEL_COLOR_YELLOW, "Faction ID: %u, Merchant ID: %u, Transporter ID: %u", spawn->GetFactionID(), spawn->GetMerchantID(), spawn->GetTransporterID());
  4620. client->Message(CHANNEL_COLOR_YELLOW, "Grid ID: %u", spawn->GetLocation());
  4621. client->Message(CHANNEL_COLOR_YELLOW, "Race: %i, Class: %i, Gender: %i", spawn->GetRace(), spawn->GetAdventureClass(), spawn->GetGender());
  4622. client->Message(CHANNEL_COLOR_YELLOW, "Level: %i, HP: %u / %u, Power: %u / %u", spawn->GetLevel(), spawn->GetHP(), spawn->GetTotalHP(), spawn->GetPower(), spawn->GetTotalPower());
  4623. 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());
  4624. client->Message(CHANNEL_COLOR_YELLOW, "Collision Radius: %i, Size: %i, Difficulty: %i, Heroic: %i", spawn->GetCollisionRadius(), spawn->GetSize(), spawn->GetDifficulty(), spawn->GetHeroic());
  4625. client->Message(CHANNEL_COLOR_YELLOW, "Targetable: %i, Show Name: %i, Attackable: %i, Show Level: %i", spawn->GetTargetable(), spawn->GetShowName(), spawn->GetAttackable(), spawn->GetShowLevel());
  4626. client->Message(CHANNEL_COLOR_YELLOW, "Show Command Icon: %i, Display Hand Icon: %i", spawn->GetShowCommandIcon(), spawn->GetShowHandIcon());
  4627. if (spawn->IsEntity()) {
  4628. 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());
  4629. 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());
  4630. }
  4631. client->Message(CHANNEL_COLOR_YELLOW, "Model Type: %i, Soga Race Type: %i, Race Type: %u, Race Base Type: %u, Race Category: %s (subcategory: %s), Model Name: %s.", spawn->GetModelType(), spawn->GetSogaModelType(), race_type, race_base_type, category, subcategory, modelname);
  4632. client->Message(CHANNEL_COLOR_YELLOW, "Primary Command Type: %u, Secondary Command Type: %u", spawn->GetPrimaryCommandListID(), spawn->GetSecondaryCommandListID());
  4633. 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());
  4634. 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);
  4635. if (spawn->IsNPC())
  4636. client->Message(CHANNEL_COLOR_YELLOW, "Randomize: %u", ((NPC*)spawn)->GetRandomize());
  4637. if (spawn->IsNPC()){
  4638. client->Message(CHANNEL_COLOR_YELLOW, "Heat Resist/Base: %u/%u",((NPC*)spawn)->GetHeatResistance(), ((NPC*)spawn)->GetHeatResistanceBase());
  4639. client->Message(CHANNEL_COLOR_YELLOW, "Cold Resist/Base: %u/%u",((NPC*)spawn)->GetColdResistance(), ((NPC*)spawn)->GetColdResistanceBase());
  4640. client->Message(CHANNEL_COLOR_YELLOW, "Magic Resist/Base: %u/%u",((NPC*)spawn)->GetMagicResistance(), ((NPC*)spawn)->GetMagicResistanceBase());
  4641. client->Message(CHANNEL_COLOR_YELLOW, "Mental Resist/Base: %u/%u",((NPC*)spawn)->GetMentalResistance(), ((NPC*)spawn)->GetMentalResistanceBase());
  4642. client->Message(CHANNEL_COLOR_YELLOW, "Divine Resist/Base: %u/%u",((NPC*)spawn)->GetDivineResistance(), ((NPC*)spawn)->GetDivineResistanceBase());
  4643. client->Message(CHANNEL_COLOR_YELLOW, "Disease Resist/Base: %u/%u",((NPC*)spawn)->GetDiseaseResistance(), ((NPC*)spawn)->GetDiseaseResistanceBase());
  4644. client->Message(CHANNEL_COLOR_YELLOW, "Poison Resist/Base: %u/%u",((NPC*)spawn)->GetPoisonResistance(), ((NPC*)spawn)->GetPoisonResistanceBase());
  4645. }
  4646. string details;
  4647. details += "\\#0000FFName: " + string(spawn->GetName()) + "\n";
  4648. details += "Type: " + string(type) + "\n";
  4649. details += "ID: " + to_string(spawn->GetDatabaseID()) + "\n";
  4650. details += "Last Name: " + string(spawn->GetLastName()) + "\n";
  4651. details += "Sub-Title: " + string(spawn->GetSubTitle()) + "\n";
  4652. details += "Prefix: " + string(spawn->GetPrefixTitle()) + "\n";
  4653. details += "Suffix: " + string(spawn->GetSuffixTitle()) + "\n";
  4654. details += "Race: " + to_string(spawn->GetRace()) + "\n";
  4655. details += "Class: " + to_string(spawn->GetAdventureClass()) + "\n";
  4656. details += "Gender: " + to_string(spawn->GetGender()) + "\n";
  4657. details += "Level: " + to_string(spawn->GetLevel()) + "\n";
  4658. details += "HP: " + to_string(spawn->GetHP()) + " / " + to_string(spawn->GetTotalHP()) + "(" + to_string(spawn->GetIntHPRatio()) + "%)\n";
  4659. details += "Power: " + to_string(spawn->GetPower()) + + " / " + to_string(spawn->GetTotalPower()) + "\n";
  4660. details += "Difficulty: " + to_string(spawn->GetDifficulty()) + "\n";
  4661. details += "Heroic: " + to_string(spawn->GetHeroic()) + "\n";
  4662. details += "Group ID: " + to_string(spawn->GetSpawnGroupID()) + "\n";
  4663. details += "Faction ID: " + to_string(spawn->GetFactionID()) + "\n";
  4664. details += "Merchant ID: " + to_string(spawn->GetMerchantID()) + "\n";
  4665. details += "Transport ID: " + to_string(spawn->GetTransporterID()) + "\n";
  4666. details += "Location ID: " + to_string(spawn->GetSpawnLocationID()) + "\n";
  4667. char x[16];
  4668. sprintf(x, "%.2f", spawn->GetX());
  4669. char y[16];
  4670. sprintf(y, "%.2f", spawn->GetY());
  4671. char z[16];
  4672. sprintf(z, "%.2f", spawn->GetZ());
  4673. details += "Location: " + string(x) + ", " + string(y) + ", " + string(z) + "\n";
  4674. string details2;
  4675. details2 += "Heading: " + to_string(spawn->GetHeading()) + "\n";
  4676. details2 += "Grid ID: " + to_string(spawn->GetLocation()) + "\n";
  4677. details2 += "Size: " + to_string(spawn->GetSize()) + "\n";
  4678. details2 += "Collision Radius: " + to_string(spawn->GetCollisionRadius()) + "\n";
  4679. details2 += "Respawn Time: " + to_string(spawn->GetRespawnTime()) + "\n";
  4680. details2 += "Targetable: " + to_string(spawn->GetTargetable()) + "\n";
  4681. details2 += "Show Name: " + to_string(spawn->GetShowName()) + "\n";
  4682. details2 += "Attackable: " + to_string(spawn->GetAttackable()) + "\n";
  4683. details2 += "Show Level: " + to_string(spawn->GetShowLevel()) + "\n";
  4684. details2 += "Show Command Icon: " + to_string(spawn->GetShowCommandIcon()) + "\n";
  4685. details2 += "Display Hand Icon: " + to_string(spawn->GetShowHandIcon()) + "\n";
  4686. details2 += "Model Type: " + to_string(spawn->GetModelType()) + "\n";
  4687. details2 += "Soga Race Type: " + to_string(spawn->GetSogaModelType()) + "\n";
  4688. details2 += "Race Type: " + to_string(race_type) + "\n";
  4689. details2 += "Race Base Type: " + to_string(race_base_type) + "\n";
  4690. details2 += "Race Category (Sub Category): " + std::string(category) + " (" + std::string(subcategory) + ")\n";
  4691. details2 += "Model Name: " + std::string(modelname) + "\n";
  4692. details2 += "Primary Command ID: " + to_string(spawn->GetPrimaryCommandListID()) + "\n";
  4693. details2 += "Secondary Cmd ID: " + to_string(spawn->GetSecondaryCommandListID()) + "\n";
  4694. details2 += "Visual State: " + to_string(spawn->GetVisualState()) + "\n";
  4695. details2 += "Action State: " + to_string(spawn->GetActionState()) + "\n";
  4696. details2 += "Mood State: " + to_string(spawn->GetMoodState()) + "\n";
  4697. details2 += "Initial State: " + to_string(spawn->GetInitialState()) + "\n";
  4698. details2 += "Activity Status: " + to_string(spawn->GetActivityStatus()) + "\n";
  4699. details2 += "Emote State: " + to_string(spawn->GetEmoteState()) + "\n";
  4700. string details3;
  4701. details3 += "Pitch: " + to_string(spawn->GetPitch()) + "\n";
  4702. details3 += "Roll: " + to_string(spawn->GetRoll()) + "\n";
  4703. details3 += "Hide Hood: " + to_string(spawn->appearance.hide_hood) + "\n";
  4704. details3 += "Speed: " + to_string(spawn->GetSpeed()) + "\n";
  4705. details3 += "BaseSpeed: " + to_string(spawn->GetBaseSpeed()) + "\n";
  4706. if(spawn->IsSign()) {
  4707. details3 += "Sign Language: " + to_string(((Sign*)spawn)->GetLanguage()) + "\n";
  4708. }
  4709. if(spawn->IsEntity())
  4710. {
  4711. Entity* ent = (Entity*)spawn;
  4712. details3 += "STR / STRBase: " + to_string(ent->GetInfoStruct()->get_str()) + " / " + to_string(ent->GetInfoStruct()->get_str_base()) + "\n";
  4713. details3 += "AGI / AGIBase: " + to_string(ent->GetInfoStruct()->get_agi()) + " / " + to_string(ent->GetInfoStruct()->get_agi_base()) + "\n";
  4714. details3 += "STA / STABase: " + to_string(ent->GetInfoStruct()->get_sta()) + " / " + to_string(ent->GetInfoStruct()->get_sta_base()) + "\n";
  4715. details3 += "INT / INTBase: " + to_string(ent->GetInfoStruct()->get_intel()) + " / " + to_string(ent->GetInfoStruct()->get_intel_base()) + "\n";
  4716. details3 += "WIS / WISBase: " + to_string(ent->GetInfoStruct()->get_wis()) + " / " + to_string(ent->GetInfoStruct()->get_wis_base()) + "\n";
  4717. }
  4718. string details4;
  4719. if (spawn->IsEntity()) {
  4720. details4 += "Facial Hair Type: " + to_string(((Entity*)spawn)->GetFacialHairType()) + "\n";
  4721. details4 += "Hair Type: " + to_string(((Entity*)spawn)->GetHairType()) + "\n";
  4722. details4 += "Chest Type: " + to_string(((Entity*)spawn)->GetChestType()) + "\n";
  4723. details4 += "Legs Type: " + to_string(((Entity*)spawn)->GetLegsType()) + "\n";
  4724. details4 += "Soga Facial Hair Type: " + to_string(((Entity*)spawn)->GetSogaFacialHairType()) + "\n";
  4725. details4 += "Soga Hair Type: " + to_string(((Entity*)spawn)->GetSogaHairType()) + "\n";
  4726. details4 += "Wing Type: " + to_string(((Entity*)spawn)->GetWingType()) + "\n";
  4727. if (spawn->IsNPC()) {
  4728. details4 += "\nRandomize: " + to_string(((NPC*)spawn)->GetRandomize()) + "\n";
  4729. }
  4730. }
  4731. const char* spawnScriptMsg = (spawn->GetSpawnScript() && strlen(spawn->GetSpawnScript())>0) ? spawn->GetSpawnScript() : "Not Set";
  4732. details4 += "\nSpawnScript: " + std::string(spawnScriptMsg) + "\n";
  4733. string title = string(spawn->GetName()) + "(" + to_string(spawn->GetDatabaseID()) + ")";
  4734. client->SendShowBook(client->GetPlayer(), title, 0, 4, details, details2, details3, details4);
  4735. }
  4736. else {
  4737. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn details (radius)");
  4738. 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.");
  4739. }
  4740. break;
  4741. }
  4742. case COMMAND_SPAWN_TARGET:{
  4743. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  4744. int32 spawn_id = atoul(sep->arg[0]);
  4745. int16 response = client->GetCurrentZone()->SetSpawnTargetable(spawn_id);
  4746. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  4747. }
  4748. else if(sep && sep->arg[0][0] && sep->arg[1][0] && sep->IsNumber(1) && ToLower(string(sep->arg[0])) == "radius"){
  4749. float distance = atof(sep->arg[1]);
  4750. int16 response = client->GetCurrentZone()->SetSpawnTargetable(client->GetPlayer(), distance);
  4751. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  4752. }
  4753. else{
  4754. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn target [spawn id]");
  4755. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn as targetable. Used to change a spawn if it was set to untargetable.");
  4756. }
  4757. break;
  4758. }
  4759. case COMMAND_SPAWN_SET:
  4760. {
  4761. Spawn* spawn = cmdTarget;
  4762. sint16 set_type = -1;
  4763. string type_str;
  4764. if (spawn)
  4765. {
  4766. // check if parameters are (location or list or not player and not a 2nd param), and that there is at least 1 value
  4767. 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)
  4768. {
  4769. // set the type, which will be 0 if location or list or invalid
  4770. set_type = spawn_set_values[ToLower(string(sep->arg[0]))];
  4771. }
  4772. if(set_type > 0)
  4773. {
  4774. // check if spawn set is NOT a char update, or not location, or isn't a number
  4775. 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)
  4776. {
  4777. client->SimpleMessage(CHANNEL_COLOR_RED, "Invalid value for set command.");
  4778. }
  4779. else
  4780. {
  4781. string name = string(spawn->GetName());
  4782. bool customSetSpawn = false;
  4783. if(set_type >= SPAWN_SET_CHEEK_TYPE && set_type <= SPAWN_SET_SOGA_NOSE_TYPE)
  4784. {
  4785. int8 index = sep->IsNumber(2) ? atoul(sep->arg[2]) : 0;
  4786. // override the standard setspawncommand, we pass arguments different!
  4787. if(SetSpawnCommand(client, spawn, set_type, sep->arg[1], true, false, nullptr, index))
  4788. customSetSpawn = true;
  4789. }
  4790. if(customSetSpawn || SetSpawnCommand(client, spawn, set_type, sep->argplus[1]))
  4791. {
  4792. if (set_type == SPAWN_SET_VALUE_EXPANSION_FLAG || set_type == SPAWN_SET_VALUE_HOLIDAY_FLAG)
  4793. {
  4794. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "A /reload spawns is required to properly update the spawns with the xpack/holiday flag.");
  4795. }
  4796. else if (set_type == SPAWN_SET_VALUE_NAME)
  4797. {
  4798. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "New name will not be effective until zone reload.");
  4799. }
  4800. else if (set_type == SPAWN_SET_SKIN_COLOR || (set_type >= SPAWN_SET_HAIR_COLOR1 && set_type <= SPAWN_SET_SOGA_EYE_COLOR))
  4801. {
  4802. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set color field to R G B: %s.", sep->argplus[1]);
  4803. }
  4804. else if(set_type == SPAWN_SET_VALUE_LOCATION)
  4805. {
  4806. spawn->SetLocation(client->GetPlayer()->GetLocation());
  4807. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set '%s' to '%u' for spawn '%s' (DBID: %u)", sep->arg[0], client->GetPlayer()->GetLocation(), name.c_str(), spawn->GetDatabaseID());
  4808. }
  4809. else
  4810. {
  4811. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set '%s' to '%s' for spawn '%s' (DBID: %u)", sep->arg[0], sep->arg[1], name.c_str(), spawn->GetDatabaseID());
  4812. }
  4813. switch (set_type)
  4814. {
  4815. case SPAWN_SET_VALUE_EXPANSION_FLAG:
  4816. case SPAWN_SET_VALUE_HOLIDAY_FLAG:
  4817. case SPAWN_SET_VALUE_FACTION:
  4818. case SPAWN_SET_AAXP_REWARDS:
  4819. case SPAWN_SET_CHEEK_TYPE:
  4820. case SPAWN_SET_CHIN_TYPE:
  4821. case SPAWN_SET_EAR_TYPE:
  4822. case SPAWN_SET_EYE_BROW_TYPE:
  4823. case SPAWN_SET_EYE_TYPE:
  4824. case SPAWN_SET_LIP_TYPE:
  4825. case SPAWN_SET_NOSE_TYPE:
  4826. case SPAWN_SET_BODY_SIZE:
  4827. case SPAWN_SET_BODY_AGE:
  4828. case SPAWN_SET_SOGA_CHEEK_TYPE:
  4829. case SPAWN_SET_SOGA_CHIN_TYPE:
  4830. case SPAWN_SET_SOGA_EAR_TYPE:
  4831. case SPAWN_SET_SOGA_EYE_BROW_TYPE:
  4832. case SPAWN_SET_SOGA_EYE_TYPE:
  4833. case SPAWN_SET_SOGA_LIP_TYPE:
  4834. case SPAWN_SET_SOGA_NOSE_TYPE:
  4835. case SPAWN_SET_SOGA_BODY_SIZE:
  4836. case SPAWN_SET_SOGA_BODY_AGE:
  4837. case SPAWN_SET_ATTACK_TYPE:
  4838. case SPAWN_SET_RACE_TYPE:
  4839. case SPAWN_SET_LOOT_TIER:
  4840. case SPAWN_SET_LOOT_DROP_TYPE:
  4841. case SPAWN_SET_SCARED_STRONG_PLAYERS:
  4842. {
  4843. // not applicable already ran db command
  4844. break;
  4845. }
  4846. default:
  4847. {
  4848. client->GetCurrentZone()->ApplySetSpawnCommand(client, spawn, set_type, sep->argplus[1]);
  4849. break;
  4850. }
  4851. }
  4852. 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))
  4853. {
  4854. if(spawn->GetSpawnLocationID() > 0 && database.UpdateSpawnLocationSpawns(spawn))
  4855. {
  4856. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information for spawn '%s' (DBID: %u)", name.c_str(), spawn->GetDatabaseID());
  4857. }
  4858. else if(spawn->GetSpawnLocationID() > 0)
  4859. {
  4860. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn information, see console window for details.");
  4861. }
  4862. }
  4863. else
  4864. {
  4865. if(spawn->GetDatabaseID() > 0 && database.SaveSpawnInfo(spawn))
  4866. {
  4867. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn for spawn '%s' (DBID: %u)", name.c_str(), spawn->GetDatabaseID());
  4868. }
  4869. else if(spawn->GetDatabaseID() > 0)
  4870. {
  4871. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn, see console window for details.");
  4872. }
  4873. }
  4874. }
  4875. }
  4876. }
  4877. else if(set_type == 0)
  4878. {
  4879. // /spawn set list - lists all possible attributes that can be changed with this command, 10 per line.
  4880. map<string, int8>::iterator itr;
  4881. int i=0;
  4882. string list;
  4883. for(itr = spawn_set_values.begin(); itr != spawn_set_values.end(); itr++, i++)
  4884. {
  4885. if(i==10)
  4886. {
  4887. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  4888. i = 0;
  4889. }
  4890. if(i>0)
  4891. {
  4892. list.append(", ").append(itr->first);
  4893. }
  4894. else
  4895. {
  4896. list = itr->first;
  4897. }
  4898. }
  4899. if(list.length() > 0)
  4900. {
  4901. // if 1 or more, display in client.
  4902. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  4903. }
  4904. }
  4905. else
  4906. {
  4907. // syntax fail
  4908. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn set [type] [value]");
  4909. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used to change various settings for the targeted NPC or Object.");
  4910. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "For a list of changeable settings use /spawn set list");
  4911. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Note: /spawn set location does not require a value. The client's current location is used.");
  4912. }
  4913. }
  4914. break;
  4915. }
  4916. case COMMAND_SPAWN_REMOVE:{
  4917. Spawn* spawn = cmdTarget;
  4918. if(spawn && !spawn->IsPlayer()){
  4919. if(spawn->GetSpawnLocationID() > 0){
  4920. string name = string(spawn->GetName());
  4921. int32 dbid = spawn->GetDatabaseID();
  4922. if(database.RemoveSpawnFromSpawnLocation(spawn)){
  4923. client->GetCurrentZone()->RemoveSpawn(spawn, true, false, true, true, true);
  4924. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed spawn from zone for spawn '%s' (DBID: %u)", name.c_str(), dbid);
  4925. }
  4926. else
  4927. client->SimpleMessage(CHANNEL_COLOR_RED, "Error removing spawn, see console window for details.");
  4928. }
  4929. else
  4930. client->SimpleMessage(CHANNEL_COLOR_RED, "This spawn does not have a spawn group associated with it");
  4931. }
  4932. else{
  4933. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn remove");
  4934. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for removing the targeted NPC or Object from the zone.");
  4935. }
  4936. break;
  4937. }
  4938. case COMMAND_SPAWN_LIST:{
  4939. if(sep && sep->arg[0][0]){
  4940. vector<string>* results = database.GetSpawnNameList(sep->argplus[0]);
  4941. vector<string>::iterator itr;
  4942. if(results){
  4943. for(itr=results->begin();itr!=results->end();itr++){
  4944. client->SimpleMessage(CHANNEL_COLOR_YELLOW, (*itr).c_str());
  4945. }
  4946. safe_delete(results);
  4947. }
  4948. else
  4949. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found. ");
  4950. }
  4951. else{
  4952. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn list [name]");
  4953. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Name can be a partial match.");
  4954. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn list Qeynos Guard");
  4955. }
  4956. break;
  4957. }
  4958. case COMMAND_SPAWN_ADD:{
  4959. Spawn* spawn = cmdTarget;
  4960. if(spawn && sep && ((sep->arg[1][0] && sep->IsNumber(0)) || (sep->arg[0][0] && strncasecmp(sep->arg[0], "new", 3) == 0))){
  4961. if(spawn->GetSpawnLocationID() > 0){
  4962. client->Message(CHANNEL_COLOR_RED, "This spawn already has a spawn group id of %u, use /spawn remove to reassign it", spawn->GetSpawnLocationID());
  4963. break;
  4964. }
  4965. if(spawn->GetDatabaseID() == 0){
  4966. if(database.SaveSpawnInfo(spawn)) {
  4967. char spawn_type[32];
  4968. memset(spawn_type, 0, sizeof(spawn_type));
  4969. if (spawn->IsNPC())
  4970. strncpy(spawn_type, "NPC", sizeof(spawn_type) - 1);
  4971. else if (spawn->IsObject())
  4972. strncpy(spawn_type, "Object", sizeof(spawn_type) - 1);
  4973. else if (spawn->IsSign())
  4974. strncpy(spawn_type, "Sign", sizeof(spawn_type) - 1);
  4975. else if (spawn->IsGroundSpawn())
  4976. strncpy(spawn_type, "GroundSpawn", sizeof(spawn_type) - 1);
  4977. else
  4978. strncpy(spawn_type, "Unknown", sizeof(spawn_type) - 1);
  4979. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information with a %s id of %u", spawn_type, spawn->GetDatabaseID());
  4980. }
  4981. else
  4982. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn information, see console window for details.");
  4983. }
  4984. int32 spawn_group_id = 0;
  4985. if(strncasecmp(sep->arg[0], "new", 3) == 0)
  4986. spawn_group_id = database.GetNextSpawnLocation();
  4987. else
  4988. spawn_group_id = atol(sep->arg[0]);
  4989. int8 percent = 100;
  4990. if(sep->arg[2] && sep->IsNumber(2))
  4991. percent = atoi(sep->arg[2]);
  4992. spawn->SetSpawnLocationID(spawn_group_id);
  4993. float x_offset = database.GetSpawnLocationPlacementOffsetX(spawn->GetSpawnLocationID());
  4994. float y_offset = database.GetSpawnLocationPlacementOffsetY(spawn->GetSpawnLocationID());
  4995. float z_offset = database.GetSpawnLocationPlacementOffsetZ(spawn->GetSpawnLocationID());
  4996. if(database.SaveSpawnEntry(spawn, sep->arg[1], percent, x_offset, y_offset, z_offset))
  4997. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn location with a spawn group of %u", spawn->GetSpawnLocationID());
  4998. else
  4999. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn location, see console window for details.");
  5000. }
  5001. else{
  5002. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn add [spawn group id] [spawn group name] (percentage)");
  5003. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for adding the targeted NPC or Object to the database.");
  5004. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can substitute new for [spawn group id] to create a new one.");
  5005. }
  5006. break;
  5007. }
  5008. case COMMAND_SPAWN:{
  5009. int32 id = 0;
  5010. Spawn* spawn = 0;
  5011. if(sep && sep->arg[0] && sep->IsNumber(0)){
  5012. id = atol(sep->arg[0]);
  5013. spawn = client->GetCurrentZone()->GetSpawn(id);
  5014. }
  5015. if(id > 0 && spawn && spawn->appearance.name[0] == 0)
  5016. id = 0;
  5017. if(!id || !spawn){
  5018. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn [spawn id] (x) (y) (z) (heading) (location)");
  5019. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are optional except the id. The spawn id must be in the database.");
  5020. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn 1 0 0 0 0");
  5021. safe_delete(sep);
  5022. return;
  5023. }
  5024. if(sep && sep->arg[1][0]){
  5025. float x = atof(sep->arg[1]);
  5026. spawn->appearance.pos.X = x;
  5027. }
  5028. else
  5029. spawn->SetX(client->GetPlayer()->GetX(), false);
  5030. if(sep && sep->arg[2][0]){
  5031. float y = atof(sep->arg[2]);
  5032. spawn->appearance.pos.Y = y;
  5033. }
  5034. else
  5035. spawn->SetY(client->GetPlayer()->GetY(), false);
  5036. if(sep && sep->arg[3][0]){
  5037. float z = atof(sep->arg[3]);
  5038. spawn->appearance.pos.Z = z;
  5039. }
  5040. else
  5041. spawn->SetZ(client->GetPlayer()->GetZ(), false);
  5042. if(sep && sep->arg[4][0]){
  5043. float heading = atof(sep->arg[4]);
  5044. spawn->SetHeading(heading);
  5045. }
  5046. else
  5047. spawn->SetHeading(client->GetPlayer()->GetHeading(), false);
  5048. spawn->SetSpawnOrigX(spawn->GetX());
  5049. spawn->SetSpawnOrigY(spawn->GetY());
  5050. spawn->SetSpawnOrigZ(spawn->GetZ());
  5051. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  5052. if(sep && sep->arg[5][0])
  5053. spawn->SetLocation(atoul(sep->arg[5]));
  5054. else
  5055. spawn->SetLocation(client->GetPlayer()->GetLocation());
  5056. if(spawn->IsNPC() && spawn->GetTotalHP() == 0){
  5057. spawn->SetTotalHP(spawn->GetLevel() * 15);
  5058. spawn->SetHP(spawn->GetTotalHP());
  5059. }
  5060. if(spawn->GetTotalPower() == 0){
  5061. spawn->SetTotalPower(spawn->GetLevel() * 15);
  5062. spawn->SetPower(spawn->GetTotalPower());
  5063. }
  5064. const char* script = world.GetSpawnScript(id);
  5065. if(script && lua_interface && lua_interface->GetSpawnScript(script) != 0)
  5066. spawn->SetSpawnScript(string(script));
  5067. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_PRESPAWN);
  5068. client->GetCurrentZone()->AddSpawn(spawn);
  5069. if(spawn->IsNPC())
  5070. spawn->GetZone()->AddLoot((NPC*)spawn);
  5071. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_SPAWN);
  5072. LogWrite(COMMAND__INFO, 0, "Command", "Received spawn command - Parms: %s", command_parms->data.c_str());
  5073. break;
  5074. }
  5075. case COMMAND_ADMINFLAG:
  5076. {
  5077. if(sep && sep->arg[0]){
  5078. sint16 tmp_status = database.GetCharacterAdminStatus(sep->arg[0]);
  5079. sint16 new_status = atoi(sep->arg[1]);
  5080. if(tmp_status == -10)
  5081. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character does not exist.");
  5082. else if(tmp_status >= client->GetAdminStatus())
  5083. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character has same or higher level status.");
  5084. else if (new_status > client->GetAdminStatus())
  5085. client->SimpleMessage(CHANNEL_ERROR, "Unable to flag character. Reason: New status is higher then your status.");
  5086. else{
  5087. Client* client2 = client->GetCurrentZone()->GetClientByName(sep->arg[0]);
  5088. if (!client2)
  5089. client2 = zone_list.GetClientByCharName(sep->arg[0]);
  5090. if(database.UpdateAdminStatus(sep->arg[0],new_status)) {
  5091. client->Message(CHANNEL_COLOR_YELLOW,"Character status updated to %i for %s.",new_status,sep->arg[0]);
  5092. if (client2) {
  5093. client2->SetAdminStatus(new_status);
  5094. client2->Message(CHANNEL_COLOR_YELLOW, "%s has set your admin status to %i.", client->GetPlayer()->GetName(), new_status);
  5095. }
  5096. }
  5097. else
  5098. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Unknown reason.");
  5099. }
  5100. }else{
  5101. sint16 status = database.GetCharacterAdminStatus(client->GetPlayer()->GetName());
  5102. if(status != client->GetAdminStatus())
  5103. {
  5104. client->Message(CHANNEL_COLOR_YELLOW,"Flag status was changed from %i to %i.",status,client->GetAdminStatus());
  5105. client->SetAdminStatus(status);
  5106. }
  5107. else
  5108. {
  5109. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /flag {name} {new_status}");
  5110. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Standard User: 0");
  5111. client->Message(CHANNEL_COLOR_YELLOW," Admin User: %i", status);
  5112. }
  5113. }
  5114. break;
  5115. }
  5116. case COMMAND_CANNEDEMOTE:{
  5117. client->GetCurrentZone()->HandleEmote(client->GetPlayer(), command_parms->data);
  5118. break;
  5119. }
  5120. case COMMAND_BROADCAST: {
  5121. if (sep && sep->arg[0])
  5122. zone_list.HandleGlobalBroadcast(sep->argplus[0]);
  5123. else
  5124. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /broadcast {message}");
  5125. break;
  5126. }
  5127. case COMMAND_ANNOUNCE: {
  5128. if (sep && sep->arg[0])
  5129. zone_list.HandleGlobalAnnouncement(sep->argplus[0]);
  5130. else
  5131. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /announce {message}");
  5132. break;
  5133. }
  5134. case COMMAND_RELOAD_ITEMS:{
  5135. LogWrite(COMMAND__INFO, 0, "Command", "Reloading items..");
  5136. int32 item_id = (sep && sep->arg[0]) ? atoul(sep->arg[0]) : 0;
  5137. if(item_id > 0) {
  5138. client->Message(CHANNEL_COLOR_YELLOW, "Reloading item %u based on /reload items [item_id].", item_id);
  5139. }
  5140. else {
  5141. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Started Reloading items (this might take a few minutes...)");
  5142. }
  5143. database.ReloadItemList(item_id);
  5144. if(!item_id) {
  5145. database.LoadMerchantInformation(); // we skip if there is only a reload of single item not all items
  5146. }
  5147. if(item_id > 0) {
  5148. client->Message(CHANNEL_COLOR_YELLOW, "Reloaded item %u.", item_id);
  5149. }
  5150. else {
  5151. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Finished Reloading items.");
  5152. }
  5153. break;
  5154. }
  5155. case COMMAND_ENABLE_ABILITY_QUE:{
  5156. EQ2Packet* app = client->GetPlayer()->GetSpellBookUpdatePacket(client->GetVersion());
  5157. if(app)
  5158. client->QueuePacket(app);
  5159. break;
  5160. }
  5161. case COMMAND_ITEMSEARCH:
  5162. case COMMAND_FROMBROKER:{
  5163. PacketStruct* packet = configReader.getStruct("WS_StartBroker", client->GetVersion());
  5164. if (packet) {
  5165. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  5166. //packet->setDataByName("unknown", 1);
  5167. packet->setDataByName("unknown2", 5, 0);
  5168. packet->setDataByName("unknown2", 20, 1);
  5169. packet->setDataByName("unknown2", 58, 3);
  5170. packet->setDataByName("unknown2", 40, 4);
  5171. client->QueuePacket(packet->serialize());
  5172. PacketStruct* packet2 = configReader.getStruct("WS_BrokerBags", client->GetVersion());
  5173. if (packet2) {
  5174. packet2->setDataByName("char_id", client->GetCharacterID());
  5175. client->QueuePacket(packet2->serialize()); //send this for now, needed to properly clear data
  5176. safe_delete(packet2);
  5177. }
  5178. safe_delete(packet);
  5179. }
  5180. break;
  5181. }
  5182. case COMMAND_ANIMTEST:{
  5183. PacketStruct* command_packet = configReader.getStruct("WS_CannedEmote", client->GetVersion());
  5184. if(command_packet){
  5185. int32 id = client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer());
  5186. if (cmdTarget)
  5187. id = client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget);
  5188. command_packet->setDataByName ( "spawn_id" , id);
  5189. int animID = 1;
  5190. if(sep && sep->arg[0] && sep->IsNumber(0))
  5191. animID = atoi(sep->arg[0]);
  5192. VisualState* vs = NULL;
  5193. if(animID == 0)
  5194. {
  5195. vs = visual_states.FindVisualState(sep->arg[0]);
  5196. }
  5197. char msg[128];
  5198. sprintf(msg,"Animation Test ID: %i",animID);
  5199. command_packet->setMediumStringByName ( "emote_msg" , msg );
  5200. if(vs != NULL)
  5201. command_packet->setDataByName ( "anim_type", vs->GetID ( ) );
  5202. else
  5203. command_packet->setDataByName ( "anim_type", animID );
  5204. command_packet->setDataByName ( "unknown0", 0 );
  5205. EQ2Packet* outapp = command_packet->serialize();
  5206. client->QueuePacket(outapp);
  5207. safe_delete(command_packet);
  5208. }
  5209. break;
  5210. }
  5211. case COMMAND_KICK:
  5212. {
  5213. if( sep == 0 || sep->arg[0] == 0)
  5214. {
  5215. client->SimpleMessage(CHANNEL_COLOR_RED, "/kick [name]");
  5216. }
  5217. else
  5218. {
  5219. Client* kickClient = zone_list.GetClientByCharName(string(sep->arg[0]));
  5220. if ( kickClient == client )
  5221. {
  5222. client->Message(CHANNEL_COLOR_RED, "You can't kick yourself!");
  5223. break;
  5224. }
  5225. else if(kickClient != NULL)
  5226. {
  5227. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  5228. if ( maxStatus >= client->GetAdminStatus( ) || kickClient->GetAdminStatus() >= client->GetAdminStatus() )
  5229. {
  5230. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  5231. break;
  5232. }
  5233. client->Message(CHANNEL_COLOR_RED, "Kicking %s...",sep->arg[0]);
  5234. kickClient->Disconnect();
  5235. }
  5236. else
  5237. {
  5238. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  5239. }
  5240. }
  5241. break;
  5242. }
  5243. case COMMAND_LOCK:
  5244. {
  5245. if( sep != NULL && sep->arg[0] != NULL && sep->IsNumber(0)){
  5246. int worldLocked = atoi(sep->arg[0]);
  5247. net.world_locked = worldLocked;
  5248. if ( worldLocked )
  5249. client->Message(CHANNEL_COLOR_YELLOW,"World server has been locked.");
  5250. else
  5251. client->Message(CHANNEL_COLOR_YELLOW,"World server has been unlocked.");
  5252. }
  5253. else
  5254. client->SimpleMessage(CHANNEL_COLOR_RED, "/lock [0/1]");
  5255. break;
  5256. }
  5257. case COMMAND_BAN:{
  5258. if( sep == 0 || sep->arg[0] == 0 || (sep->arg[1][0] != 0 && !sep->IsNumber(1) ) )
  5259. {
  5260. client->SimpleMessage(CHANNEL_COLOR_RED, "/ban [name] [permanent:0/1]");
  5261. }
  5262. else
  5263. {
  5264. Client* kickClient = zone_list.GetClientByCharName(sep->arg[0]);
  5265. if ( kickClient == client )
  5266. {
  5267. client->Message(CHANNEL_COLOR_RED, "You can't ban yourself!");
  5268. break;
  5269. }
  5270. else if(kickClient != NULL)
  5271. {
  5272. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  5273. if ( maxStatus > client->GetAdminStatus( ) ||
  5274. client->GetAdminStatus ( ) > kickClient->GetAdminStatus ( ) )
  5275. {
  5276. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  5277. break;
  5278. }
  5279. client->Message(CHANNEL_COLOR_RED, "Kicking & Banning %s...",sep->arg[0]);
  5280. int perm = atol(sep->arg[1]);
  5281. if ( perm == 1 )
  5282. database.UpdateAdminStatus(sep->arg[0],-2);
  5283. else
  5284. database.UpdateAdminStatus(sep->arg[0],-1);
  5285. kickClient->Disconnect();
  5286. }
  5287. else
  5288. {
  5289. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  5290. }
  5291. }
  5292. break;
  5293. }
  5294. case COMMAND_SET_COMBAT_VOICE:{
  5295. int32 value = 0;
  5296. if(sep && sep->arg[0] && sep->IsNumber(0))
  5297. value = atoi(sep->arg[0]);
  5298. client->GetPlayer()->SetCombatVoice(value);
  5299. break;
  5300. }
  5301. case COMMAND_SET_EMOTE_VOICE:{
  5302. int32 value = 0;
  5303. if(sep && sep->arg[0] && sep->IsNumber(0))
  5304. value = atoi(sep->arg[0]);
  5305. client->GetPlayer()->SetEmoteVoice(value);
  5306. break;
  5307. }
  5308. case COMMAND_GIVEITEM:{
  5309. if(sep && sep->arg[0][0] && sep->arg[0][1] && sep->IsNumber(1)){
  5310. Client* itemToClient = zone_list.GetClientByCharName(sep->arg[0]);
  5311. if ( itemToClient == NULL )
  5312. client->Message(CHANNEL_COLOR_YELLOW,"Could not find %s.",sep->arg[0]);
  5313. else
  5314. {
  5315. int32 item_id = atol(sep->arg[1]);
  5316. client->Message(CHANNEL_COLOR_YELLOW,"Gave %s item id %i.",sep->arg[0],item_id);
  5317. itemToClient->AddItem(item_id);
  5318. }
  5319. }
  5320. else
  5321. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /giveitem [name] [item_id]");
  5322. break;
  5323. }
  5324. case COMMAND_REPORT_BUG : { Command_ReportBug(client, sep); break; }
  5325. case COMMAND_INVENTORY : { Command_Inventory(client, sep, command); break; }
  5326. case COMMAND_WEAPONSTATS : { Command_WeaponStats(client); break; }
  5327. case COMMAND_SKILL :
  5328. case COMMAND_SKILL_ADD :
  5329. case COMMAND_SKILL_REMOVE :
  5330. case COMMAND_SKILL_LIST : { Command_Skills(client, sep, command->handler); break; }
  5331. case COMMAND_ZONE_SET : { Command_ZoneSet(client, sep); break; }
  5332. case COMMAND_ZONE_DETAILS : { Command_ZoneDetails(client, sep); break; }
  5333. case COMMAND_ENTITYCOMMAND :
  5334. case COMMAND_ENTITYCOMMAND_LIST : { Command_EntityCommand(client, sep, command->handler); break; }
  5335. case COMMAND_MERCHANT :
  5336. case COMMAND_MERCHANT_LIST : { Command_Merchant(client, sep, command->handler); break; }
  5337. case COMMAND_APPEARANCE :
  5338. case COMMAND_APPEARANCE_LIST : { Command_Appearance(client, sep, command->handler); break; }
  5339. case COMMAND_TRACK : { Command_Track(client); break; }
  5340. case COMMAND_DISTANCE : { Command_Distance(client); break; }
  5341. case COMMAND_INSPECT_PLAYER : { Command_InspectPlayer(client, sep); break; }
  5342. case COMMAND_ZONE_SAFE : { Command_ZoneSafeCoords(client, sep); break; }
  5343. case COMMAND_GUILDSAY : { Command_GuildSay(client, sep); break; }
  5344. case COMMAND_OFFICERSAY : { Command_OfficerSay(client, sep); break; }
  5345. case COMMAND_SET_GUILD_MEMBER_NOTE : { Command_SetGuildMemberNote(client, sep); break; }
  5346. case COMMAND_SET_GUILD_OFFICER_NOTE : { Command_SetGuildOfficerNote(client, sep); break; }
  5347. case COMMAND_GUILD : { Command_Guild(client, sep); break; }
  5348. case COMMAND_CREATE_GUILD : { Command_CreateGuild(client); break; }
  5349. case COMMAND_GUILDS : { Command_Guilds(client); break; }
  5350. case COMMAND_GUILDS_ADD : { Command_GuildsAdd(client, sep); break; }
  5351. case COMMAND_GUILDS_CREATE : { Command_GuildsCreate(client, sep); break; }
  5352. case COMMAND_GUILDS_DELETE : { Command_GuildsDelete(client, sep); break; }
  5353. case COMMAND_GUILDS_LIST : { Command_GuildsList(client); break; }
  5354. case COMMAND_GUILDS_REMOVE : { Command_GuildsRemove(client, sep); break; }
  5355. case COMMAND_CLAIM : { Command_Claim(client, sep); break; }
  5356. case COMMAND_CLEAR_ALL_QUEUED : { Command_ClearAllQueued(client); break; }
  5357. case COMMAND_LOCATION : { Command_Location(client); break; }
  5358. case COMMAND_LOCATION_ADD : { Command_LocationAdd(client, sep); break; }
  5359. case COMMAND_LOCATION_CREATE : { Command_LocationCreate(client, sep); break; }
  5360. case COMMAND_LOCATION_DELETE : { Command_LocationDelete(client, sep); break; }
  5361. case COMMAND_LOCATION_LIST : { Command_LocationList(client, sep); break; }
  5362. case COMMAND_LOCATION_REMOVE : { Command_LocationRemove(client, sep); break; }
  5363. case COMMAND_GRID : { Command_Grid(client, sep); break; }
  5364. case COMMAND_TRY_ON : { Command_TryOn(client, sep); break; }
  5365. case COMMAND_RANDOMIZE : { Command_Randomize(client, sep); break; }
  5366. case COMMAND_AFK : { Command_AFK(client, sep); break; }
  5367. case COMMAND_SHOW_CLOAK : { Command_ShowCloak(client, sep); break; }
  5368. case COMMAND_SHOW_HELM : { Command_ShowHelm(client, sep); break; }
  5369. case COMMAND_SHOW_HOOD : { Command_ShowHood(client, sep); break; }
  5370. case COMMAND_SHOW_HOOD_OR_HELM : { Command_ShowHoodHelm(client, sep); break; }
  5371. case COMMAND_SHOW_RANGED : { Command_ShowRanged(client, sep); break; }
  5372. case COMMAND_STOP_DRINKING : { Command_StopDrinking(client); break; }
  5373. case COMMAND_STOP_EATING : { Command_StopEating(client); break; }
  5374. case COMMAND_TOGGLE_ANONYMOUS : { Command_Toggle_Anonymous(client); break; }
  5375. case COMMAND_TOGGLE_AUTOCONSUME : { Command_Toggle_AutoConsume(client, sep); break; }
  5376. case COMMAND_TOGGLE_BONUS_EXP : { Command_Toggle_BonusXP(client); break; }
  5377. case COMMAND_TOGGLE_COMBAT_EXP : { Command_Toggle_CombatXP(client); break; }
  5378. case COMMAND_TOGGLE_GM_HIDE : { Command_Toggle_GMHide(client); break; }
  5379. case COMMAND_TOGGLE_GM_VANISH : { Command_Toggle_GMVanish(client); break; }
  5380. case COMMAND_TOGGLE_ILLUSIONS : { Command_Toggle_Illusions(client, sep); break; }
  5381. case COMMAND_TOGGLE_LFG : { Command_Toggle_LFG(client); break; }
  5382. case COMMAND_TOGGLE_LFW : { Command_Toggle_LFW(client); break; }
  5383. case COMMAND_TOGGLE_QUEST_EXP : { Command_Toggle_QuestXP(client); break; }
  5384. case COMMAND_TOGGLE_ROLEPLAYING : { Command_Toggle_Roleplaying(client); break; }
  5385. case COMMAND_TOGGLE_DUELS : { Command_Toggle_Duels(client); break; }
  5386. case COMMAND_TOGGLE_TRADES : { Command_Toggle_Trades(client); break; }
  5387. case COMMAND_TOGGLE_GUILDS : { Command_Toggle_Guilds(client); break; }
  5388. case COMMAND_TOGGLE_GROUPS : { Command_Toggle_Groups(client); break; }
  5389. case COMMAND_TOGGLE_RAIDS : { Command_Toggle_Raids(client); break; }
  5390. case COMMAND_TOGGLE_LON : { Command_Toggle_LON(client); break; }
  5391. case COMMAND_TOGGLE_VCINVITE : { Command_Toggle_VoiceChat(client); break; }
  5392. case COMMAND_CANCEL_MAINTAINED : { Command_CancelMaintained(client, sep); break; }
  5393. case COMMAND_MOTD : { Command_MOTD(client); break; }
  5394. case COMMAND_RANDOM : { Command_Random(client, sep); break; }
  5395. case COMMAND_CREATE : { Command_Create(client, sep); break; }
  5396. case COMMAND_CREATEFROMRECIPE : { Command_CreateFromRecipe(client, sep); break; }
  5397. case COMMAND_TITLE : { Command_Title(client); break; }
  5398. case COMMAND_TITLE_LIST : { Command_TitleList(client); break; }
  5399. case COMMAND_TITLE_SETPREFIX : { Command_TitleSetPrefix(client, sep); break; }
  5400. case COMMAND_TITLE_SETSUFFIX : { Command_TitleSetSuffix(client, sep); break; }
  5401. case COMMAND_TITLE_FIX : { Command_TitleFix(client, sep); break; }
  5402. case COMMAND_LANGUAGES : { Command_Languages(client, sep); break; }
  5403. case COMMAND_SET_LANGUAGE : { Command_SetLanguage(client, sep); break; }
  5404. case COMMAND_FOLLOW : { Command_Follow(client, sep); break; }
  5405. case COMMAND_STOP_FOLLOW : { Command_StopFollow(client, sep); break; }
  5406. case COMMAND_LASTNAME : { Command_LastName(client, sep); break; }
  5407. case COMMAND_CONFIRMLASTNAME : { Command_ConfirmLastName(client, sep); break; }
  5408. case COMMAND_PET : { Command_Pet(client, sep); break; }
  5409. case COMMAND_PETNAME : { Command_PetName(client, sep); break; }
  5410. case COMMAND_NAME_PET : { Command_NamePet(client, sep); break; }
  5411. case COMMAND_RENAME : { Command_Rename(client, sep); break; }
  5412. case COMMAND_CONFIRMRENAME : { Command_ConfirmRename(client, sep); break; }
  5413. case COMMAND_PETOPTIONS : { Command_PetOptions(client, sep); break; }
  5414. case COMMAND_START_TRADE : { Command_TradeStart(client, sep); break; }
  5415. case COMMAND_ACCEPT_TRADE : { Command_TradeAccept(client, sep); break; }
  5416. case COMMAND_REJECT_TRADE : { Command_TradeReject(client, sep); break; }
  5417. case COMMAND_CANCEL_TRADE : { Command_TradeCancel(client, sep); break; }
  5418. case COMMAND_SET_TRADE_COIN : { Command_TradeSetCoin(client, sep); break; }
  5419. case COMMAND_ADD_TRADE_COPPER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_COPPER); break; }
  5420. case COMMAND_ADD_TRADE_SILVER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_SILVER); break; }
  5421. case COMMAND_ADD_TRADE_GOLD : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_GOLD); break; }
  5422. case COMMAND_ADD_TRADE_PLAT : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_PLAT); break; }
  5423. case COMMAND_REMOVE_TRADE_COPPER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_COPPER); break; }
  5424. case COMMAND_REMOVE_TRADE_SILVER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_SILVER); break; }
  5425. case COMMAND_REMOVE_TRADE_GOLD : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_GOLD); break; }
  5426. case COMMAND_REMOVE_TRADE_PLAT : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_PLAT); break; }
  5427. case COMMAND_ADD_TRADE_ITEM : { Command_TradeAddItem(client, sep); break; }
  5428. case COMMAND_REMOVE_TRADE_ITEM : { Command_TradeRemoveItem(client, sep); break; }
  5429. case COMMAND_ACCEPT_ADVANCEMENT : { Command_AcceptAdvancement(client, sep); break; }
  5430. case COMMAND_DUEL : { Command_Duel(client, sep); break; }
  5431. case COMMAND_DUELBET : { Command_DuelBet(client, sep); break; }
  5432. case COMMAND_DUEL_ACCEPT : { Command_DuelAccept(client, sep); break; }
  5433. case COMMAND_DUEL_DECLINE : { Command_DuelDecline(client, sep); break; }
  5434. case COMMAND_DUEL_SURRENDER : { Command_DuelSurrender(client, sep); break; }
  5435. case COMMAND_DUEL_TOGGLE : { Command_DuelToggle(client, sep); break; }
  5436. case COMMAND_SPAWN_TEMPLATE : { Command_SpawnTemplate(client, sep); break; }
  5437. //devn00b
  5438. case COMMAND_MOOD : { Command_Mood(client, sep); break;}
  5439. case COMMAND_MODIFY : { Command_Modify(client); break; }
  5440. case COMMAND_MODIFY_CHARACTER : { Command_ModifyCharacter(client, sep); break; }
  5441. case COMMAND_MODIFY_QUEST : { Command_ModifyQuest(client, sep); break; }
  5442. case COMMAND_MODIFY_FACTION : { Command_ModifyFaction(client, sep); break; }
  5443. case COMMAND_MODIFY_GUILD : { Command_ModifyGuild(client, sep); break; }
  5444. case COMMAND_MODIFY_ITEM : { Command_ModifyItem(client, sep); break; }
  5445. case COMMAND_MODIFY_SKILL : { Command_ModifySkill(client, sep); break; }
  5446. case COMMAND_MODIFY_SPAWN : { Command_ModifySpawn(client, sep); break; }
  5447. case COMMAND_MODIFY_SPELL : { Command_ModifySpell(client, sep); break; }
  5448. case COMMAND_MODIFY_ZONE : { Command_ModifyZone(client, sep); break; }
  5449. case COMMAND_JOIN_CHANNEL : { Command_JoinChannel(client, sep); break;}
  5450. case COMMAND_JOIN_CHANNEL_FROM_LOAD: { Command_JoinChannelFromLoad(client, sep); break;}
  5451. case COMMAND_TELL_CHANNEL : { Command_TellChannel(client, sep); break;}
  5452. case COMMAND_LEAVE_CHANNEL : { Command_LeaveChannel(client, sep); break;}
  5453. case COMMAND_WHO_CHANNEL : { Command_WhoChannel(client, sep); break;}
  5454. case COMMAND_RAIN : { Command_Rain(client, sep); break; }
  5455. case COMMAND_WIND : { Command_Wind(client, sep); break; }
  5456. case COMMAND_WEATHER : { Command_Weather(client, sep); break; }
  5457. case COMMAND_FROM_MERCHANT : { Command_SendMerchantWindow(client, sep); break; }
  5458. case COMMAND_TO_MERCHANT : { Command_SendMerchantWindow(client, sep, true); break; }
  5459. case COMMAND_SELECT : { Command_Select(client, sep); break; }
  5460. case COMMAND_SMP : { Command_StationMarketPlace(client, sep); break; }
  5461. case COMMAND_CONSUME_FOOD : { Command_ConsumeFood(client, sep); break; }
  5462. case COMMAND_SET_CONSUME_FOOD : { Command_ConsumeFood(client, sep); break; }
  5463. case COMMAND_AQUAMAN : { Command_Aquaman(client, sep); break; }
  5464. case COMMAND_ATTUNE_INV : { Command_Attune_Inv(client, sep); break; }
  5465. case COMMAND_PLAYER : { Command_Player(client, sep); break; }
  5466. case COMMAND_PLAYER_COINS : { Command_Player_Coins(client, sep); break; }
  5467. case COMMAND_RESET_ZONE_TIMER : { Command_Reset_Zone_Timer(client, sep); break; }
  5468. case COMMAND_ACHIEVEMENT_ADD : { Command_AchievementAdd(client, sep); break; }
  5469. case COMMAND_EDITOR : { Command_Editor(client, sep); break; }
  5470. case COMMAND_ACCEPT_RESURRECTION: { Command_AcceptResurrection(client, sep); break; }
  5471. case COMMAND_DECLINE_RESURRECTION:{ Command_DeclineResurrection(client, sep); break; }
  5472. case COMMAND_TEST : { Command_Test(client, command_parms); break; }
  5473. case COMMAND_SPEED : { Command_Speed(client, sep); break; }
  5474. case COMMAND_BOT : { Command_Bot(client, sep); break; }
  5475. case COMMAND_BOT_CREATE : { Command_Bot_Create(client, sep); break; }
  5476. case COMMAND_BOT_CUSTOMIZE : { Command_Bot_Customize(client, sep); break; }
  5477. case COMMAND_BOT_SPAWN : { Command_Bot_Spawn(client, sep); break; }
  5478. case COMMAND_BOT_LIST : { Command_Bot_List(client, sep); break; }
  5479. case COMMAND_BOT_INV : { Command_Bot_Inv(client, sep); break; }
  5480. case COMMAND_BOT_SETTINGS : { Command_Bot_Settings(client, sep); break; }
  5481. case COMMAND_BOT_HELP : { Command_Bot_Help(client, sep); break; }
  5482. case GET_AA_XML : { Get_AA_Xml(client, sep); break; }
  5483. case ADD_AA : { Add_AA(client, sep); break; }
  5484. case COMMIT_AA_PROFILE : { Commit_AA_Profile(client, sep); break; }
  5485. case BEGIN_AA_PROFILE : { Begin_AA_Profile(client, sep); break; }
  5486. case BACK_AA : { Back_AA(client, sep); break; }
  5487. case REMOVE_AA : { Remove_AA(client, sep); break; }
  5488. case SWITCH_AA_PROFILE : { Switch_AA_Profile(client, sep); break; }
  5489. case CANCEL_AA_PROFILE : { Cancel_AA_Profile(client, sep); break; }
  5490. case SAVE_AA_PROFILE : { Save_AA_Profile(client, sep); break; }
  5491. case COMMAND_TARGETITEM : { Command_TargetItem(client, sep); break; }
  5492. case COMMAND_FINDSPAWN: { Command_FindSpawn(client, sep); break; }
  5493. case COMMAND_MOVECHARACTER: { Command_MoveCharacter(client, sep); break; }
  5494. case COMMAND_CRAFTITEM: {
  5495. Item* item = 0;
  5496. if (sep && sep->IsNumber(0)) {
  5497. int32 item_id = atol(sep->arg[0]);
  5498. int32 quantity = 1;
  5499. if (sep->arg[1] && sep->IsNumber(1))
  5500. quantity = atoi(sep->arg[1]);
  5501. item = new Item(master_item_list.GetItem(item_id));
  5502. if (!item) {
  5503. LogWrite(TRADESKILL__ERROR, 0, "CraftItem", "Item (%u) not found.", item_id);
  5504. }
  5505. else {
  5506. item->details.count = quantity;
  5507. // use CHANNEL_COLOR_CHAT_RELATIONSHIP as that is the same value (4) as it is in a log for this message
  5508. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You created %s.", item->CreateItemLink(client->GetVersion()).c_str());
  5509. bool itemDeleted = false;
  5510. client->AddItem(item, &itemDeleted);
  5511. //Check for crafting quest updates
  5512. int8 update_amt = 0;
  5513. if (!itemDeleted && item->stack_count > 1)
  5514. update_amt = 1;
  5515. else
  5516. update_amt = quantity;
  5517. if(!itemDeleted)
  5518. client->GetPlayer()->CheckQuestsCraftUpdate(item, update_amt);
  5519. }
  5520. }
  5521. else {
  5522. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /craftitem {item_id} [quantity] ");
  5523. }
  5524. break;
  5525. }
  5526. case COMMAND_UNMENTOR:
  5527. case COMMAND_MENTOR: {
  5528. client->GetPlayer()->MentorTarget();
  5529. break;
  5530. }
  5531. case COMMAND_CANCEL_EFFECT: { Command_CancelEffect(client, sep); break; }
  5532. case COMMAND_CUREPLAYER: { Command_CurePlayer(client, sep); break; }
  5533. case COMMAND_SHARE_QUEST: { Command_ShareQuest(client, sep); break; }
  5534. case COMMAND_YELL: { Command_Yell(client, sep); break; }
  5535. case COMMAND_SETAUTOLOOTMODE: { Command_SetAutoLootMode(client, sep); break; }
  5536. case COMMAND_ASSIST: { Command_Assist(client, sep); break; }
  5537. case COMMAND_TARGET: { Command_Target(client, sep); break; }
  5538. case COMMAND_TARGET_PET: { Command_Target_Pet(client, sep); break; }
  5539. case COMMAND_WHOGROUP: { Command_WhoGroup(client, sep); break; }
  5540. case COMMAND_WHORAID: { Command_WhoRaid(client, sep); break; }
  5541. case COMMAND_RAIDINVITE: { Command_RaidInvite(client, sep); break; }
  5542. case COMMAND_RAID_LOOTER: { Command_Raid_Looter(client, sep); break; }
  5543. case COMMAND_KICKFROMGROUP: { Command_KickFromGroup(client, sep); break; }
  5544. case COMMAND_KICKFROMRAID: { Command_KickFromRaid(client, sep); break; }
  5545. case COMMAND_LEAVERAID: { Command_LeaveRaid(client, sep); break; }
  5546. case COMMAND_SPLIT: { Command_Split(client, sep); break; }
  5547. case COMMAND_RAIDSAY: { Command_RaidSay(client, sep); break; }
  5548. default:
  5549. {
  5550. LogWrite(COMMAND__WARNING, 0, "Command", "Unhandled command: %s", command->command.data.c_str());
  5551. break;
  5552. }
  5553. }
  5554. safe_delete(sep);
  5555. }
  5556. /******************** New COMMAND Handler Functions ********************/
  5557. /*
  5558. Started breaking apart the huge switch() for commands into sepErate
  5559. functions so it is easier to locate the blocks of code by command
  5560. -- JA 2012.03.03
  5561. */
  5562. // sample function header
  5563. /*
  5564. Function:
  5565. Purpose :
  5566. Params :
  5567. Dev :
  5568. Example :
  5569. */
  5570. //void Commands::Command()
  5571. //{
  5572. //}
  5573. /*
  5574. Function: Command_AcceptAdvancement()
  5575. Purpose : Player accepts a new advancement option
  5576. Params : Spell ID
  5577. Dev : Jabantiz
  5578. */
  5579. void Commands::Command_AcceptAdvancement(Client* client, Seperator* sep)
  5580. {
  5581. Player *player = client->GetPlayer();
  5582. if (sep && sep->IsSet(0)) {
  5583. int32 trait_id = atoul(sep->arg[0]);
  5584. TraitData* trait = nullptr;
  5585. if(client->GetVersion() <= 561) {
  5586. trait = master_trait_list.GetTraitByItemID(trait_id);
  5587. }
  5588. else {
  5589. trait = master_trait_list.GetTrait(trait_id);
  5590. }
  5591. if(!trait) {
  5592. LogWrite(COMMAND__ERROR, 0, "Command", "Invalid accept advancement of trait %u, no trait found.", trait_id);
  5593. return; // not valid lets not crash!
  5594. }
  5595. if(!master_trait_list.IsPlayerAllowedTrait(client, trait)) {
  5596. client->SimpleMessage(CHANNEL_COLOR_RED, "Not enough trait points to accept trait.");
  5597. return;
  5598. }
  5599. // Check to see if this is a trait or grandmaster training (traits are always new spells, training is always upgrades)
  5600. if (!player->HasSpell(trait->spellID, 0, true))
  5601. {
  5602. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  5603. if(spell) {
  5604. player->AddSpellBookEntry(trait->spellID, trait->tier, player->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  5605. }
  5606. else {
  5607. client->Message(CHANNEL_COLOR_RED, "ERROR! Trait is not a valid spell id %u may be disabled.", trait->spellID);
  5608. }
  5609. }
  5610. else
  5611. {
  5612. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  5613. if(spell) {
  5614. int8 old_slot = player->GetSpellSlot(spell->GetSpellID());
  5615. player->RemoveSpellBookEntry(spell->GetSpellID());
  5616. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  5617. player->UnlockSpell(spell);
  5618. client->SendSpellUpdate(spell);
  5619. }
  5620. else {
  5621. client->Message(CHANNEL_COLOR_RED, "ERROR! Trait is not a valid spell id %u may be disabled.", trait->spellID);
  5622. }
  5623. }
  5624. // Spell book update
  5625. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  5626. client->QueuePacket(master_trait_list.GetTraitListPacket(client));
  5627. if(client->GetVersion() <= 561) {
  5628. master_trait_list.ChooseNextTrait(client);
  5629. }
  5630. }
  5631. }
  5632. /*
  5633. Function:
  5634. Purpose :
  5635. Params :
  5636. Dev :
  5637. Example :
  5638. */
  5639. void Commands::Command_AFK(Client* client, Seperator* sep)
  5640. {
  5641. Player* player = client->GetPlayer();
  5642. player->toggle_character_flag(CF_AFK);
  5643. client->Message(CHANNEL_COLOR_YELLOW,"You are %s afk.", client->GetPlayer()->get_character_flag(CF_AFK)?"now":"no longer");
  5644. if (player->get_character_flag(CF_AFK))
  5645. {
  5646. if (sep && sep->argplus[0])
  5647. player->SetAwayMessage("I am away from the keyboard, " + string(sep->argplus[0]));
  5648. else
  5649. player->SetAwayMessage("Sorry, I am A.F.K. (Away From Keyboard)");
  5650. string message = string(player->GetName()) + " is going afk.";
  5651. Spawn* target = player->GetTarget();
  5652. if (target && target != player)
  5653. {
  5654. message = string(player->GetName()) + " tells " + string(target->GetName()) + " that ";
  5655. player->GetGender() == 1 ? message += "he" : message += "she";
  5656. message += " is going afk.";
  5657. }
  5658. player->GetZone()->SimpleMessage(CHANNEL_COLOR_YELLOW, message.c_str(), player, 30);
  5659. }
  5660. if (player->get_character_flag(CF_AFK))
  5661. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_AFK);
  5662. else
  5663. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_AFK);
  5664. }
  5665. /*
  5666. Function: Command_Appearance()
  5667. Purpose : Handles /appearance commands
  5668. Params : list
  5669. Dev : Scatman
  5670. Example : /appearance list
  5671. */
  5672. void Commands::Command_Appearance(Client* client, Seperator* sep, int handler)
  5673. {
  5674. if( handler == COMMAND_APPEARANCE )
  5675. {
  5676. // /appearance command by itself shows help (to be extended)
  5677. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  5678. return;
  5679. }
  5680. else if( handler == COMMAND_APPEARANCE_LIST )
  5681. {
  5682. // /appearance list command expects "name" param
  5683. if (sep && sep->arg[0])
  5684. {
  5685. const char* appearance_name = sep->argplus[0];
  5686. client->Message(CHANNEL_COLOR_YELLOW, "Listing appearances like '%s':", appearance_name);
  5687. vector<int16>* appearances = database.GetAppearanceIDsLikeName(string(appearance_name));
  5688. if (appearances)
  5689. {
  5690. vector<int16>::iterator itr;
  5691. for (itr = appearances->begin(); itr != appearances->end(); itr++)
  5692. {
  5693. int16 id = *itr;
  5694. string name = database.GetAppearanceName(id);
  5695. if (ToLower(name).find(ToLower(string(appearance_name))) < 0xFFFFFFFF)
  5696. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", name.c_str(), id);
  5697. }
  5698. safe_delete(appearances);
  5699. }
  5700. }
  5701. else // no param
  5702. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  5703. }
  5704. }
  5705. /*
  5706. Function: Command_Claim()
  5707. Purpose : Summon veteran rewards
  5708. Params : nothing = show claim window, any number claims that item.
  5709. Dev : devn00b
  5710. Example : /claim 0 (claims the 1st item added to the list claim[0])
  5711. */
  5712. void Commands::Command_Claim(Client* client, Seperator* sep)
  5713. {
  5714. //if we were passed a claim id
  5715. if (sep && sep->argplus[0] && sep->IsNumber(0))
  5716. {
  5717. int32 char_id = client->GetCharacterID();
  5718. int8 my_claim_id = atoi(sep->argplus[0]);
  5719. vector<ClaimItems> claim = database.LoadCharacterClaimItems(char_id);
  5720. Item* item = master_item_list.GetItem(claim[my_claim_id].item_id);
  5721. database.ClaimItem(char_id, item->details.item_id, client);
  5722. return;
  5723. }
  5724. else {
  5725. //if no arg just send the window.
  5726. client->ShowClaimWindow();
  5727. return;
  5728. }
  5729. return;
  5730. }
  5731. /*
  5732. Function: Command_ClearAllQueued()
  5733. Purpose :
  5734. Params :
  5735. Dev :
  5736. Example :
  5737. */
  5738. void Commands::Command_ClearAllQueued(Client* client)
  5739. {
  5740. ZoneServer* zone = client->GetPlayer()->GetZone();
  5741. if (zone && zone->GetSpellProcess())
  5742. zone->GetSpellProcess()->RemoveSpellFromQueue(client->GetPlayer());
  5743. }
  5744. /*
  5745. Function: Command_CancelMaintained()
  5746. Purpose : Cancels maintained spells
  5747. Params : Maintained Spell Index
  5748. Dev : Zcoretri
  5749. Example : /cancel_maintained 1 - would cancel the spell in slot 1 of Maintained Spells list
  5750. */
  5751. void Commands::Command_CancelMaintained(Client* client, Seperator* sep)
  5752. {
  5753. if (sep && sep->arg[0] && sep->IsNumber(0))
  5754. {
  5755. int32 spell_index = atoul(sep->arg[0]);
  5756. if(spell_index > 29)
  5757. return;
  5758. client->GetPlayer()->MMaintainedSpells.readlock(__FUNCTION__, __LINE__);
  5759. MaintainedEffects mEffects = client->GetPlayer()->GetInfoStruct()->maintained_effects[spell_index];
  5760. client->GetPlayer()->MMaintainedSpells.releasereadlock(__FUNCTION__, __LINE__);
  5761. if (!client->GetPlayer()->GetZone()->GetSpellProcess()->DeleteCasterSpell(mEffects.spell, "canceled", false))
  5762. client->Message(CHANNEL_COLOR_RED, "The maintained spell could not be cancelled.");
  5763. }
  5764. }
  5765. /*
  5766. Function: Command_Create()
  5767. Purpose : Handler for starting Tradeskilling table
  5768. Params :
  5769. Dev : Zcoretri
  5770. Example :
  5771. */
  5772. void Commands::Command_Create(Client* client, Seperator* sep)
  5773. {
  5774. PrintSep(sep, "COMMAND_CREATE");
  5775. client->ShowRecipeBook();
  5776. }
  5777. void Commands::Command_CreateFromRecipe(Client* client, Seperator* sep)
  5778. {
  5779. PrintSep(sep, "COMMAND_CREATEFROMRECIPE");
  5780. if (sep && sep->arg[0] && sep->IsNumber(0))
  5781. ClientPacketFunctions::SendCreateFromRecipe(client, atoul(sep->arg[0]));
  5782. }
  5783. /*
  5784. Function: Command_Distance()
  5785. Purpose : Displays distance from targeted spawn
  5786. Params :
  5787. Dev : Scatman
  5788. Example : /distance
  5789. */
  5790. void Commands::Command_Distance(Client* client)
  5791. {
  5792. Spawn* target = client->GetPlayer()->GetTarget();
  5793. if (target)
  5794. client->Message(CHANNEL_COLOR_YELLOW, "Your distance from %s is %f", target->GetName(), client->GetPlayer()->GetDistance(target));
  5795. else
  5796. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must have a spawn targeted to use /distance");
  5797. }
  5798. /*
  5799. Function: Command_Duel()
  5800. Purpose : Handle the /duel commands - not yet implemented
  5801. Params : unknown
  5802. Dev :
  5803. Example :
  5804. */
  5805. void Commands::Command_Duel(Client* client, Seperator* sep)
  5806. {
  5807. PrintSep(sep, "COMMAND_DUEL");
  5808. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Command");
  5809. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5810. }
  5811. /*
  5812. Function: Command_DuelBet()
  5813. Purpose : Handle the /duel commands - not yet implemented
  5814. Params : unknown
  5815. Dev :
  5816. Example :
  5817. */
  5818. void Commands::Command_DuelBet(Client* client, Seperator* sep)
  5819. {
  5820. PrintSep(sep, "COMMAND_DUELBET");
  5821. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Bet Command");
  5822. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5823. }
  5824. /*
  5825. Function: Command_DuelAccept()
  5826. Purpose : Handle the /duel commands - not yet implemented
  5827. Params : unknown
  5828. Dev :
  5829. Example :
  5830. */
  5831. void Commands::Command_DuelAccept(Client* client, Seperator* sep)
  5832. {
  5833. PrintSep(sep, "COMMAND_DUEL_ACCEPT");
  5834. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Accept Duel Command");
  5835. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5836. }
  5837. /*
  5838. Function: Command_DuelDecline()
  5839. Purpose : Handle the /duel commands - not yet implemented
  5840. Params : unknown
  5841. Dev :
  5842. Example :
  5843. */
  5844. void Commands::Command_DuelDecline(Client* client, Seperator* sep)
  5845. {
  5846. PrintSep(sep, "COMMAND_DUEL_DECLINE");
  5847. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Decline Duel Request Command");
  5848. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5849. }
  5850. /*
  5851. Function: Command_DuelSurrender()
  5852. Purpose : Handle the /duel commands - not yet implemented
  5853. Params : unknown
  5854. Dev :
  5855. Example :
  5856. */
  5857. void Commands::Command_DuelSurrender(Client* client, Seperator* sep)
  5858. {
  5859. PrintSep(sep, "COMMAND_DUEL_SURRENDER");
  5860. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Surrender Duel Command");
  5861. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5862. // JA, just messin around ;)
  5863. char surrender[64];
  5864. sprintf(surrender, "%s surrendered like a cowardly dog!", client->GetPlayer()->GetName());
  5865. zone_list.HandleGlobalAnnouncement(surrender);
  5866. }
  5867. /*
  5868. Function: Command_DuelToggle()
  5869. Purpose : Handle the /duel commands - not yet implemented
  5870. Params : unknown
  5871. Dev :
  5872. Example :
  5873. */
  5874. void Commands::Command_DuelToggle(Client* client, Seperator* sep)
  5875. {
  5876. PrintSep(sep, "COMMAND_DUEL");
  5877. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Commands");
  5878. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5879. }
  5880. /*
  5881. Function:
  5882. Purpose :
  5883. Params :
  5884. Dev :
  5885. Example :
  5886. */
  5887. void Commands::Command_EntityCommand(Client* client, Seperator* sep, int handler)
  5888. {
  5889. if( handler == COMMAND_ENTITYCOMMAND )
  5890. {
  5891. // /entitycommand command by itself shows help (to be extended)
  5892. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  5893. return;
  5894. }
  5895. else if( handler == COMMAND_ENTITYCOMMAND_LIST )
  5896. {
  5897. // /entitycommand list command expects "name" param
  5898. if (sep && sep->arg[0])
  5899. {
  5900. const char* entity_command_name = sep->argplus[0];
  5901. client->Message(CHANNEL_COLOR_YELLOW, "Listing entity commands like '%s':", entity_command_name);
  5902. map<int32, vector<EntityCommand*>*>* entity_command_list_all = client->GetCurrentZone()->GetEntityCommandListAll();
  5903. map<int32, vector<EntityCommand*>*>::iterator itr;
  5904. for (itr = entity_command_list_all->begin(); itr != entity_command_list_all->end(); itr++)
  5905. {
  5906. vector<EntityCommand*>* entity_command_list = itr->second;
  5907. vector<EntityCommand*>::iterator itr2;
  5908. for (itr2 = entity_command_list->begin(); itr2 != entity_command_list->end(); itr2++)
  5909. {
  5910. EntityCommand* entity_command = *itr2;
  5911. if (ToLower(entity_command->name).find(ToLower(string(entity_command_name))) < 0xFFFFFFFF)
  5912. 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);
  5913. }
  5914. }
  5915. }
  5916. else // no command name
  5917. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  5918. }
  5919. }
  5920. /*
  5921. Function: Command_Follow()
  5922. Purpose : Handle the /follow command - not yet implemented
  5923. Params :
  5924. Dev :
  5925. Example :
  5926. */
  5927. void Commands::Command_Follow(Client* client, Seperator* sep)
  5928. {
  5929. PrintSep(sep, "COMMAND_FOLLOW");
  5930. // flag to toggle if the players target is in the players group
  5931. bool targetInGroup = false;
  5932. // get a pointer to the players group
  5933. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  5934. // If the player has a group and has a target
  5935. if (gmi && client->GetPlayer()->GetTarget()) {
  5936. deque<GroupMemberInfo*>::iterator itr;
  5937. world.GetGroupManager()->GroupLock(__FUNCTION__, __LINE__);
  5938. PlayerGroup* group = world.GetGroupManager()->GetGroup(gmi->group_id);
  5939. if (group)
  5940. {
  5941. group->MGroupMembers.readlock(__FUNCTION__, __LINE__);
  5942. deque<GroupMemberInfo*>* members = group->GetMembers();
  5943. // Loop through the group members
  5944. for (itr = members->begin(); itr != members->end(); itr++) {
  5945. // If a group member matches a target
  5946. if ((*itr)->member && (*itr)->member == client->GetPlayer()->GetTarget()) {
  5947. // toggle the flag and break the loop
  5948. targetInGroup = true;
  5949. break;
  5950. }
  5951. }
  5952. group->MGroupMembers.releasereadlock(__FUNCTION__, __LINE__);
  5953. }
  5954. world.GetGroupManager()->ReleaseGroupLock(__FUNCTION__, __LINE__);
  5955. }
  5956. if (targetInGroup) {
  5957. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  5958. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You start to follow %s.", client->GetPlayer()->GetTarget()->GetName());
  5959. client->GetPlayer()->SetFollowTarget(client->GetPlayer()->GetTarget());
  5960. client->GetPlayer()->info_changed = true;
  5961. client->GetPlayer()->changed = true;
  5962. }
  5963. else
  5964. client->Message(CHANNEL_NARRATIVE, "You must first select a group member to follow.");
  5965. }
  5966. /*
  5967. Function: Command_StopFollow()
  5968. Purpose : Handle the /stop_follow command - not yet implemented
  5969. Params :
  5970. Dev :
  5971. Example :
  5972. */
  5973. void Commands::Command_StopFollow(Client* client, Seperator* sep)
  5974. {
  5975. PrintSep(sep, "COMMAND_STOP_FOLLOW");
  5976. if (client->GetPlayer()->GetFollowTarget()) {
  5977. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  5978. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You are no longer following %s", client->GetPlayer()->GetFollowTarget()->GetName());
  5979. client->GetPlayer()->SetFollowTarget(0);
  5980. client->GetPlayer()->info_changed = true;
  5981. client->GetPlayer()->changed = true;
  5982. }
  5983. }
  5984. /*
  5985. Function: Command_Grid()
  5986. Purpose : Show player's current Grid ID
  5987. Params :
  5988. Dev : Scatman
  5989. Example : /grid
  5990. */
  5991. void Commands::Command_Grid(Client* client, Seperator* sep)
  5992. {
  5993. if (client->GetPlayer()->GetMap() != nullptr) {
  5994. if(sep && sep->arg[0][0] && strncasecmp("spawns", sep->arg[0], 6) == 0) {
  5995. int32 grid = client->GetPlayer()->GetLocation();
  5996. if(sep->IsNumber(1))
  5997. grid = atoul(sep->arg[1]);
  5998. client->GetCurrentZone()->SendClientSpawnListInGrid(client, grid);
  5999. }
  6000. if(sep && sep->arg[0][0] && strncasecmp("boundary", sep->arg[0], 8) == 0) {
  6001. int32 grid = client->GetPlayer()->GetLocation();
  6002. if(sep->IsNumber(1))
  6003. grid = atoul(sep->arg[1]);
  6004. if(!client->GetPlayer()->GetMap()) {
  6005. client->Message(CHANNEL_COLOR_RED, "No map to check grid!");
  6006. return;
  6007. }
  6008. GridMapBorder* gmb = client->GetPlayer()->GetMap()->GetMapGridBorder(grid, false);
  6009. if(gmb) {
  6010. client->Message(CHANNEL_COLOR_YELLOW, "Grid %u border MinX %f MaxX %f, MinY %f MaxY %f, MinZ %f MaxZ %f", grid, gmb->m_MinX, gmb->m_MaxX, gmb->m_MinY, gmb->m_MaxY, gmb->m_MinZ, gmb->m_MaxZ);
  6011. }
  6012. else {
  6013. client->Message(CHANNEL_COLOR_RED, "Grid %u has no grid map border", grid);
  6014. }
  6015. }
  6016. else {
  6017. client->Message(CHANNEL_COLOR_YELLOW, "Your Grid ID is %u", client->GetPlayer()->GetLocation());
  6018. auto loc = glm::vec3(client->GetPlayer()->GetX(), client->GetPlayer()->GetZ(), client->GetPlayer()->GetY());
  6019. uint32 GridID = 0;
  6020. uint32 WidgetID = 0;
  6021. float new_z = client->GetPlayer()->FindBestZ(loc, nullptr, &GridID, &WidgetID);
  6022. float minY = client->GetPlayer()->GetMap()->GetMinY();
  6023. float maxY = client->GetPlayer()->GetMap()->GetMaxY();
  6024. float minZ = client->GetPlayer()->GetMap()->GetMinZ();
  6025. float maxZ = client->GetPlayer()->GetMap()->GetMaxZ();
  6026. int32 grid_spawn_count = client->GetPlayer()->GetZone()->GetSpawnCountInGrid(GridID);
  6027. client->Message(CHANNEL_COLOR_YELLOW, "Grid result is %u, at EQ2 Y coordinate %f. Spawns on grid: %u. Min/Max Y %f/%f Z %f/%f. Widget ID: %u", GridID, new_z, grid_spawn_count, minY, maxY, minZ, maxZ, WidgetID);
  6028. }
  6029. }
  6030. }
  6031. /*
  6032. Function: Command_Guild()
  6033. Purpose : Handler for all UI-related guild commands
  6034. Dev : Scatman
  6035. */
  6036. void Commands::Command_Guild(Client* client, Seperator* sep)
  6037. {
  6038. Guild* guild = client->GetPlayer()->GetGuild();
  6039. if (sep && sep->GetMaxArgNum() > 0 && sep->arg[0])
  6040. {
  6041. const char* command = sep->arg[0];
  6042. int32 length = strlen(command);
  6043. LogWrite(COMMAND__DEBUG, 0, "Command", "Guild Command: %s", command);
  6044. if (strncmp(command, "rank_name", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && guild)
  6045. guild->SetRankName(atoi(sep->arg[1]), sep->argplus[2]);
  6046. else if (strncmp(command, "rank_permission", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild) {
  6047. guild->SetPermission(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  6048. peer_manager.sendPeersGuildPermission(guild->GetID(), atoul(sep->arg[1]), atoul(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  6049. }
  6050. else if (strncmp(command, "filter_event", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild) {
  6051. guild->SetEventFilter(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  6052. peer_manager.sendPeersGuildEventFilter(guild->GetID(), atoul(sep->arg[1]), atoul(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  6053. }
  6054. else if (strncmp(command, "kick", length) == 0 && sep->arg[1] && guild) {
  6055. int32 character_id = guild->KickGuildMember(client, sep->arg[1]);
  6056. if(character_id > 0) {
  6057. peer_manager.sendPeersRemoveGuildMember(character_id, guild->GetID(), std::string(client->GetPlayer()->GetName()));
  6058. }
  6059. }
  6060. else if (strncmp(command, "demote", length) == 0 && sep->arg[1] && guild)
  6061. guild->DemoteGuildMember(client, sep->arg[1]);
  6062. else if (strncmp(command, "promote", length) == 0 && sep->arg[1] && guild)
  6063. guild->PromoteGuildMember(client, sep->arg[1]);
  6064. else if (strncmp(command, "points", length) == 0 && guild)
  6065. {
  6066. if (sep->arg[1] && strncmp(sep->arg[1], "add", length) == 0)
  6067. {
  6068. if (sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  6069. {
  6070. float points = atof(sep->arg[2]);
  6071. const char* option = sep->arg[3];
  6072. const char* comment = sep->argplus[4];
  6073. if (strncmp(option, "all", strlen(option)) == 0)
  6074. guild->AddPointsToAll(client, points, comment);
  6075. else if (strncmp(option, "online", strlen(option)) == 0)
  6076. guild->AddPointsToAllOnline(client, points, comment);
  6077. else if (strncmp(option, "group", strlen(option)) == 0)
  6078. guild->AddPointsToGroup(client, points, comment);
  6079. else if (strncmp(option, "raid", strlen(option)) == 0)
  6080. guild->AddPointsToRaid(client, points, comment);
  6081. else
  6082. guild->AddPointsToGuildMember(client, points, option, comment);
  6083. }
  6084. }
  6085. else if (sep->arg[1] && strncmp(sep->arg[1], "view", strlen(sep->arg[1])) == 0 && sep->arg[2])
  6086. guild->ViewGuildMemberPoints(client, sep->arg[2]);
  6087. else
  6088. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild points command: %s", sep->argplus[0]);
  6089. }
  6090. else if (strncmp(command, "motd", length) == 0 && sep->arg[1] && guild)
  6091. guild->SetMOTD(sep->argplus[1]);
  6092. else if (strncmp(command, "recruiting", length) == 0 && guild)
  6093. {
  6094. if (sep->arg[1])
  6095. {
  6096. const char* option = sep->arg[1];
  6097. if (strncmp(option, "short_text", strlen(option)) == 0 && sep->arg[2])
  6098. guild->SetRecruitingShortDesc(sep->argplus[2]);
  6099. else if (strncmp(option, "long_text", strlen(option)) == 0 && sep->arg[2])
  6100. guild->SetRecruitingFullDesc(sep->argplus[2]);
  6101. else if (strncmp(option, "flag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  6102. guild->SetRecruitingFlag(atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  6103. else if (strncmp(option, "min_level", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  6104. guild->SetRecruitingMinLevel(atoi(sep->arg[2]));
  6105. else if (strncmp(option, "playstyle", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  6106. guild->SetRecruitingPlayStyle(atoi(sep->arg[2]));
  6107. else if (strncmp(option, "tag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && sep->IsNumber(3))
  6108. guild->SetRecruitingDescTag(atoi(sep->arg[2]), atoi(sep->arg[3]));
  6109. else if (strncmp(command, "recruiting", strlen(option)) == 0)
  6110. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_RECRUITING_FOR_GUILD, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  6111. else
  6112. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  6113. }
  6114. else
  6115. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  6116. }
  6117. else if (strncmp(command, "notify_online", length) == 0 && sep->arg[1] && guild)
  6118. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_NOTIFY_LOGINS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  6119. else if (strncmp(command, "event_privacy", length) == 0 && sep->arg[1] && guild)
  6120. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_DONT_GENERATE_EVENTS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  6121. else if (strncmp(command, "recruiter", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  6122. guild->SetGuildRecruiter(client, sep->arg[1], strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  6123. else if (strncmp(command, "recruiter_description", length) == 0 && sep->arg[1] && guild)
  6124. guild->SetGuildRecruiterDescription(client, sep->argplus[1]);
  6125. else if (strncmp(command, "lock_event", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  6126. guild->LockGuildEvent(atoul(sep->arg[1]), strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  6127. else if (strncmp(command, "delete_event", length) == 0 && sep->arg[1] && guild)
  6128. guild->DeleteGuildEvent(atoul(sep->arg[1]));
  6129. else if (strncmp(command, "invite", length) == 0 && guild)
  6130. {
  6131. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  6132. guild->InvitePlayer(client, sep->arg[1]);
  6133. else
  6134. {
  6135. Spawn* target = client->GetPlayer()->GetTarget();
  6136. if (target)
  6137. {
  6138. if (target->IsPlayer())
  6139. guild->InvitePlayer(client, target->GetName());
  6140. else
  6141. client->Message(CHANNEL_NARRATIVE, "%s is not a player.", target->GetName());
  6142. }
  6143. }
  6144. }
  6145. else if (strncmp(command, "accept", length) == 0)
  6146. {
  6147. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  6148. if (pgi && pgi->guild && pgi->invited_by)
  6149. pgi->guild->AddNewGuildMember(client, pgi->invited_by->GetName());
  6150. client->SetPendingGuildInvite(0);
  6151. }
  6152. else if (strncmp(command, "decline", length) == 0)
  6153. {
  6154. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  6155. if (pgi && pgi->guild && pgi->invited_by && pgi->invited_by->IsPlayer())
  6156. {
  6157. Client* client_inviter = ((Player*)pgi->invited_by)->GetClient();
  6158. if (client_inviter) {
  6159. client_inviter->Message(CHANNEL_NARRATIVE, "%s has declined your invitation to join %s.", client->GetPlayer()->GetName(), pgi->guild->GetName());
  6160. }
  6161. }
  6162. client->SetPendingGuildInvite(0);
  6163. }
  6164. else if (strncmp(command, "create", length) == 0 && sep->arg[1])
  6165. {
  6166. const char* guild_name = sep->argplus[1];
  6167. if(!guild_name || strlen(guild_name) < 4) {
  6168. client->SimpleMessage(CHANNEL_NARRATIVE, "Guild name is too short.");
  6169. }
  6170. else if (!guild_list.GetGuild(guild_name)) {
  6171. if(net.is_primary) {
  6172. int32 guildID = world.CreateGuild(guild_name, client, client->GetPlayer()->GetGroupMemberInfo() ? client->GetPlayer()->GetGroupMemberInfo()->group_id : 0);
  6173. if(guildID > 0)
  6174. peer_manager.sendPeersCreateGuild(guildID);
  6175. }
  6176. else {
  6177. peer_manager.sendPrimaryCreateGuildRequest(std::string(guild_name), std::string(client->GetPlayer()->GetName()));
  6178. }
  6179. }
  6180. else
  6181. client->SimpleMessage(CHANNEL_NARRATIVE, "A guild with that name already exists.");
  6182. }
  6183. else if (strncmp(command, "search", length) == 0)
  6184. client->ShowGuildSearchWindow();
  6185. else if (strncmp(command, "recruiting_details", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  6186. {
  6187. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  6188. if (to_guild)
  6189. to_guild->SendGuildRecruitingDetails(client);
  6190. }
  6191. else if (strncmp(command, "recruiting_image", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  6192. {
  6193. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  6194. if (to_guild)
  6195. to_guild->SendGuildRecruitingImages(client);
  6196. }
  6197. else if (strncmp(command, "recruiter_adventure_class", length) == 0)
  6198. {
  6199. if (sep->arg[1])
  6200. {
  6201. const char* option = sep->arg[1];
  6202. if (strncmp(option, "toggle", strlen(option)) == 0)
  6203. guild->ToggleGuildRecruiterAdventureClass(client);
  6204. }
  6205. else
  6206. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiter_adventure_class command: '%s'", sep->argplus[0]);
  6207. }
  6208. else if (strncmp(command, "display_heraldry", length) == 0)
  6209. {
  6210. // JA: not sure this is right...
  6211. client->GetPlayer()->toggle_character_flag(CF_SHOW_GUILD_HERALDRY);
  6212. client->GetPlayer()->SetCharSheetChanged(true);
  6213. }
  6214. else
  6215. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild command: '%s'", sep->argplus[0]);
  6216. }
  6217. }
  6218. /*
  6219. Function: Command_GuildCreate()
  6220. Purpose : Display's in-game Guild Creation window
  6221. Dev : Scatman
  6222. */
  6223. void Commands::Command_CreateGuild(Client* client)
  6224. {
  6225. client->SendGuildCreateWindow();
  6226. }
  6227. /*
  6228. Function: Command_SetGuildOfficerNote()
  6229. Purpose :
  6230. Dev : Scatman
  6231. */
  6232. void Commands::Command_SetGuildOfficerNote(Client* client, Seperator* sep)
  6233. {
  6234. if (sep && sep->arg[0] && sep->arg[1])
  6235. {
  6236. Guild* guild = client->GetPlayer()->GetGuild();
  6237. if (guild)
  6238. guild->SetGuildOfficerNote(sep->arg[0], sep->argplus[1]);
  6239. }
  6240. }
  6241. /*
  6242. Function: Command_SetGuildMemberNote()
  6243. Purpose :
  6244. Dev : Scatman
  6245. */
  6246. void Commands::Command_SetGuildMemberNote(Client* client, Seperator* sep)
  6247. {
  6248. if (sep && sep->arg[0] && sep->arg[1])
  6249. {
  6250. Guild* guild = client->GetPlayer()->GetGuild();
  6251. if (guild)
  6252. guild->SetGuildMemberNote(sep->arg[0], sep->argplus[1]);
  6253. }
  6254. }
  6255. /*
  6256. Function: Command_GuildSay()
  6257. Purpose :
  6258. Dev : Scatman
  6259. */
  6260. void Commands::Command_GuildSay(Client* client, Seperator* sep)
  6261. {
  6262. Guild* guild = client->GetPlayer()->GetGuild();
  6263. if (guild)
  6264. {
  6265. if (sep && sep->arg[0]) {
  6266. bool success = guild->HandleGuildSay(client, sep->argplus[0]);
  6267. if(success)
  6268. peer_manager.SendPeersGuildChannelMessage(guild->GetID(), std::string(client->GetPlayer()->GetName()), std::string(sep->argplus[0]), CHANNEL_GUILD_SAY, client->GetPlayer()->GetCurrentLanguage());
  6269. }
  6270. }
  6271. else
  6272. client->SimpleMessage(CHANNEL_NARRATIVE, "You are not a member of a guild");
  6273. }
  6274. /*
  6275. Function: Command_OfficerSay()
  6276. Purpose :
  6277. Dev : Scatman
  6278. */
  6279. void Commands::Command_OfficerSay(Client* client, Seperator* sep)
  6280. {
  6281. Guild* guild = client->GetPlayer()->GetGuild();
  6282. if (guild)
  6283. {
  6284. if (sep && sep->arg[0]) {
  6285. bool success = guild->HandleOfficerSay(client, sep->argplus[0]);
  6286. if(success)
  6287. peer_manager.SendPeersGuildChannelMessage(guild->GetID(), std::string(client->GetPlayer()->GetName()), std::string(sep->argplus[0]), CHANNEL_OFFICER_SAY, client->GetPlayer()->GetCurrentLanguage());
  6288. }
  6289. }
  6290. else
  6291. client->SimpleMessage(CHANNEL_NARRATIVE, "You are not a member of a guild");
  6292. }
  6293. /*
  6294. Function: Command_Guilds()
  6295. Purpose : Shows help for /guild command
  6296. Params :
  6297. Dev : Scatman
  6298. Example :
  6299. */
  6300. void Commands::Command_Guilds(Client* client)
  6301. {
  6302. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds [create|delete|add|remove|list]");
  6303. }
  6304. /*
  6305. Function: Command_GuildsAdd()
  6306. Purpose : Add's players to a guild
  6307. Params : guild_name|guild_id, player name
  6308. Dev : Scatman
  6309. Example : /guilds add 1 Admin = adds player Admin to guild_id 1
  6310. */
  6311. void Commands::Command_GuildsAdd(Client* client, Seperator* sep)
  6312. {
  6313. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  6314. {
  6315. Guild* guild = 0;
  6316. bool found = true;
  6317. if (sep->IsNumber(0))
  6318. {
  6319. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  6320. if (!guild)
  6321. {
  6322. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  6323. found = false;
  6324. }
  6325. }
  6326. else
  6327. {
  6328. guild = guild_list.GetGuild(sep->arg[0]);
  6329. if (!guild)
  6330. {
  6331. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  6332. found = false;
  6333. }
  6334. }
  6335. if (found)
  6336. {
  6337. Client* to_client = 0;
  6338. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  6339. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  6340. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  6341. to_client = ((Player*)client->GetPlayer()->GetTarget())->GetClient();
  6342. if (to_client)
  6343. guild->InvitePlayer(client, to_client->GetPlayer()->GetName());
  6344. else
  6345. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  6346. }
  6347. }
  6348. else
  6349. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds add [guild name|guild id] (player name).");
  6350. }
  6351. /*
  6352. Function: Command_GuildsCreate()
  6353. Purpose : Creates a guild
  6354. Params : guild_name, player_name (optional)
  6355. Dev : Scatman
  6356. Example : /guilds create [guild name] (player name)
  6357. */
  6358. void Commands::Command_GuildsCreate(Client* client, Seperator* sep)
  6359. {
  6360. if (sep && sep->arg[0])
  6361. {
  6362. const char* guild_name = sep->arg[0];
  6363. if(!guild_name || strlen(guild_name) < 4) {
  6364. client->Message(CHANNEL_COLOR_YELLOW, "Guild name is too short.");
  6365. }
  6366. else if (!guild_list.GetGuild(guild_name))
  6367. {
  6368. bool ret = false;
  6369. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  6370. {
  6371. Client* to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  6372. if (to_client)
  6373. {
  6374. if(net.is_primary) {
  6375. int32 guildID = world.CreateGuild(guild_name, to_client, to_client->GetPlayer()->GetGroupMemberInfo() ? to_client->GetPlayer()->GetGroupMemberInfo()->group_id : 0);
  6376. if(guildID > 0)
  6377. peer_manager.sendPeersCreateGuild(guildID);
  6378. }
  6379. else {
  6380. peer_manager.sendPrimaryCreateGuildRequest(std::string(guild_name), std::string(to_client->GetPlayer()->GetName()));
  6381. }
  6382. ret = true;
  6383. }
  6384. else
  6385. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player with name '%s'", sep->arg[1]);
  6386. }
  6387. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  6388. {
  6389. Client* to_client = ((Player*)client->GetPlayer()->GetTarget())->GetClient();
  6390. if (to_client)
  6391. {
  6392. if(net.is_primary) {
  6393. int32 guildID = world.CreateGuild(guild_name, to_client, to_client->GetPlayer()->GetGroupMemberInfo() ? to_client->GetPlayer()->GetGroupMemberInfo()->group_id : 0);
  6394. if(guildID > 0)
  6395. peer_manager.sendPeersCreateGuild(guildID);
  6396. }
  6397. else {
  6398. peer_manager.sendPrimaryCreateGuildRequest(std::string(guild_name), std::string(to_client->GetPlayer()->GetName()));
  6399. }
  6400. ret = true;
  6401. }
  6402. }
  6403. else
  6404. {
  6405. if(net.is_primary) {
  6406. int32 guildID = world.CreateGuild(guild_name);
  6407. if(guildID > 0)
  6408. peer_manager.sendPeersCreateGuild(guildID);
  6409. }
  6410. else {
  6411. peer_manager.sendPrimaryCreateGuildRequest(std::string(guild_name), "");
  6412. }
  6413. ret = true;
  6414. }
  6415. if (ret)
  6416. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully created.", guild_name);
  6417. else
  6418. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the guild.");
  6419. }
  6420. else
  6421. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' already exists.", guild_name);
  6422. }
  6423. else
  6424. 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.");
  6425. }
  6426. /*
  6427. Function: Command_GuildsDelete()
  6428. Purpose : Delete's a guild
  6429. Params : guild name
  6430. Dev : Scatman
  6431. Example : /guilds delete Test
  6432. */
  6433. void Commands::Command_GuildsDelete(Client* client, Seperator* sep)
  6434. {
  6435. if (sep && sep->arg[0])
  6436. {
  6437. Guild* guild = 0;
  6438. bool found = true;
  6439. if (sep->IsNumber(0))
  6440. {
  6441. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  6442. if (!guild)
  6443. {
  6444. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  6445. found = false;
  6446. }
  6447. }
  6448. else
  6449. {
  6450. guild = guild_list.GetGuild(sep->arg[0]);
  6451. if (!guild)
  6452. {
  6453. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  6454. found = false;
  6455. }
  6456. }
  6457. if (found)
  6458. {
  6459. guild->RemoveAllGuildMembers();
  6460. database.DeleteGuild(guild);
  6461. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully deleted.", guild->GetName());
  6462. guild_list.RemoveGuild(guild, true);
  6463. }
  6464. }
  6465. else
  6466. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds delete [guild name].");
  6467. }
  6468. /*
  6469. Function: Command_GuildsList()
  6470. Purpose : Lists current guilds on server
  6471. Params :
  6472. Dev : Scatman
  6473. Example : /guilds list
  6474. */
  6475. void Commands::Command_GuildsList(Client* client)
  6476. {
  6477. MutexMap<int32, Guild*>* guilds = guild_list.GetGuilds();
  6478. MutexMap<int32, Guild*>::iterator itr = guilds->begin();
  6479. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Guild List:");
  6480. if (guilds->size() == 0)
  6481. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "None.");
  6482. else {
  6483. while (itr.Next()) {
  6484. Guild* guild = itr.second;
  6485. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", guild->GetID(), guild->GetName());
  6486. }
  6487. }
  6488. }
  6489. /*
  6490. Function: Command_GuildsRemove()
  6491. Purpose : Removes a player from a guild
  6492. Params : guild name|guild id, player name
  6493. Dev : Scatman
  6494. Example : /guilds remove 1 Admin = removes Admin from guild 1
  6495. */
  6496. void Commands::Command_GuildsRemove(Client* client, Seperator* sep)
  6497. {
  6498. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  6499. {
  6500. Guild* guild = 0;
  6501. bool found = true;
  6502. if (sep->IsNumber(0))
  6503. {
  6504. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  6505. if (!guild)
  6506. {
  6507. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  6508. found = false;
  6509. }
  6510. }
  6511. else
  6512. {
  6513. guild = guild_list.GetGuild(sep->arg[0]);
  6514. if (!guild)
  6515. {
  6516. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  6517. found = false;
  6518. }
  6519. }
  6520. if (found)
  6521. {
  6522. Client* to_client = 0;
  6523. char* charName = nullptr;
  6524. if(sep->arg[1][0])
  6525. charName = sep->arg[1];
  6526. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  6527. charName = ((Player*)client->GetPlayer()->GetTarget())->GetName();
  6528. else
  6529. {
  6530. client->Message(CHANNEL_COLOR_YELLOW, "Missing player name or not a valid target to remove from the guild.");
  6531. return;
  6532. }
  6533. int32 character_id = guild->KickGuildMember(client, charName);
  6534. if(character_id > 0)
  6535. peer_manager.sendPeersRemoveGuildMember(character_id, guild->GetID(), std::string(client->GetPlayer()->GetName()));
  6536. else
  6537. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to remove from the guild.", charName);
  6538. }
  6539. }
  6540. else
  6541. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds remove [guild name|guild id] (player name).");
  6542. }
  6543. /*
  6544. Function: Command_InspectPlayer()
  6545. Purpose : Handle the Inspect functions
  6546. Params : Client to inspect
  6547. Dev : Scatman
  6548. Example : /inspect Scatman
  6549. */
  6550. void Commands::Command_InspectPlayer(Client* client, Seperator* sep)
  6551. {
  6552. if (sep && sep->arg[0])
  6553. {
  6554. Client* inspect_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  6555. if (inspect_client)
  6556. client->InspectPlayer(inspect_client->GetPlayer());
  6557. }
  6558. else
  6559. {
  6560. Spawn* target = client->GetPlayer()->GetTarget();
  6561. if (target && target->IsPlayer())
  6562. client->InspectPlayer((Player*)target);
  6563. }
  6564. }
  6565. /*
  6566. Function: Command_Inventory()
  6567. Purpose : Handle changes in player inventory
  6568. Params : <TBD>
  6569. Dev : All
  6570. Example : /inventory delete item_id
  6571. */
  6572. void Commands::Command_Inventory(Client* client, Seperator* sep, EQ2_RemoteCommandString* command)
  6573. {
  6574. PrintSep(sep, "Command_Inventory"); // temp to figure out the params
  6575. Player* player = client->GetPlayer();
  6576. if(sep && sep->arg[0][0])
  6577. {
  6578. LogWrite(COMMAND__INFO, 0, "Command", "command: %s", sep->argplus[0]);
  6579. if(!client->GetPlayer()->Alive())
  6580. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  6581. else if(sep->arg[1][0] && strncasecmp("destroy", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  6582. {
  6583. int16 index = atoi(sep->arg[1]);
  6584. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  6585. if(item)
  6586. {
  6587. if(item->details.item_locked) {
  6588. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot destroy the item in use.");
  6589. return;
  6590. }
  6591. else if(item->IsBag() && item->details.equip_slot_id) {
  6592. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot destroy the item, it is being used as quiver.");
  6593. return;
  6594. }
  6595. else if(item->CheckFlag(NO_DESTROY)) {
  6596. client->SimpleMessage(CHANNEL_COLOR_RED, "You can't destroy this item.");
  6597. return;
  6598. }
  6599. if(item->GetItemScript() && lua_interface)
  6600. lua_interface->RunItemScript(item->GetItemScript(), "destroyed", item, client->GetPlayer());
  6601. //reobtain item make sure it wasn't removed
  6602. item = player->item_list.GetItemFromIndex(index);
  6603. int32 bag_id = 0;
  6604. if(item){
  6605. bag_id = item->details.inv_slot_id;
  6606. database.DeleteItem(client->GetCharacterID(), item, 0);
  6607. }
  6608. client->GetPlayer()->item_list.DestroyItem(index);
  6609. client->GetPlayer()->UpdateInventory(bag_id);
  6610. client->GetPlayer()->CalculateApplyWeight();
  6611. }
  6612. }
  6613. 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))
  6614. {
  6615. int16 from_index = atoi(sep->arg[1]);
  6616. sint16 to_slot = atoi(sep->arg[2]); // don't convert slot since this is inventory not equipment
  6617. sint32 bag_id = atol(sep->arg[3]);
  6618. int8 charges = atoi(sep->arg[4]);
  6619. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(from_index);
  6620. if(!item) {
  6621. client->SimpleMessage(CHANNEL_COLOR_RED, "You have no item.");
  6622. return;
  6623. }
  6624. if(to_slot == item->details.slot_id && (bag_id < 0 || bag_id == item->details.inv_slot_id)) {
  6625. return;
  6626. }
  6627. if(item->details.item_locked)
  6628. {
  6629. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot move the item in use.");
  6630. return;
  6631. }
  6632. if(bag_id == -4 && !client->GetPlayer()->item_list.SharedBankAddAllowed(item))
  6633. {
  6634. client->SimpleMessage(CHANNEL_COLOR_RED, "That item (or an item inside) cannot be shared.");
  6635. return;
  6636. }
  6637. sint32 old_inventory_id = 0;
  6638. if(item)
  6639. old_inventory_id = item->details.inv_slot_id;
  6640. //autobank
  6641. if (bag_id == -3 && to_slot == -1)
  6642. {
  6643. if (player->HasFreeBankSlot())
  6644. to_slot = player->FindFreeBankSlot();
  6645. else
  6646. {
  6647. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free bank slots.");
  6648. return;
  6649. }
  6650. }
  6651. //auto inventory
  6652. if (bag_id == 0 && to_slot == -1)
  6653. {
  6654. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  6655. {
  6656. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free slots.");
  6657. return;
  6658. }
  6659. }
  6660. bool item_deleted = false;
  6661. EQ2Packet* outapp = client->GetPlayer()->MoveInventoryItem(bag_id, from_index, (int8)to_slot, charges, 0, &item_deleted, client->GetVersion());
  6662. client->QueuePacket(outapp);
  6663. if(item_deleted)
  6664. item = nullptr;
  6665. //removed from bag send update
  6666. if(old_inventory_id > 0 && item && item->details.inv_slot_id != old_inventory_id)
  6667. {
  6668. outapp = client->GetPlayer()->SendBagUpdate(old_inventory_id, client->GetVersion());
  6669. if(outapp)
  6670. client->QueuePacket(outapp);
  6671. }
  6672. if(item && item->details.inv_slot_id > 0 && item->details.inv_slot_id != old_inventory_id)
  6673. {
  6674. outapp = client->GetPlayer()->SendBagUpdate(item->details.inv_slot_id, client->GetVersion());
  6675. if(outapp)
  6676. client->QueuePacket(outapp);
  6677. }
  6678. }
  6679. else if(sep->arg[1][0] && strncasecmp("equip", sep->arg[0], 5) == 0 && sep->IsNumber(1))
  6680. {
  6681. int16 index = atoi(sep->arg[1]);
  6682. int8 slot_id = 255;
  6683. int8 unk3 = 0;
  6684. int8 appearance_equip = 0;
  6685. if(sep->arg[2][0] && sep->IsNumber(2))
  6686. slot_id = player->ConvertSlotFromClient(atoi(sep->arg[2]), client->GetVersion());
  6687. if(sep->arg[3][0] && sep->IsNumber(3))
  6688. unk3 = atoul(sep->arg[3]);
  6689. if(sep->arg[4][0] && sep->IsNumber(4))
  6690. appearance_equip = atoul(sep->arg[4]);
  6691. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), appearance_equip, slot_id);
  6692. EQ2Packet* outapp = 0;
  6693. for(int32 i=0;i<packets.size();i++)
  6694. {
  6695. outapp = packets[i];
  6696. if(outapp)
  6697. client->QueuePacket(outapp);
  6698. }
  6699. client->GetPlayer()->UpdateWeapons();
  6700. EQ2Packet* characterSheetPackets = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion());
  6701. client->QueuePacket(characterSheetPackets);
  6702. }
  6703. else if (sep->arg[1][0] && strncasecmp("unpack", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  6704. {
  6705. if (client->GetPlayer()->EngagedInCombat())
  6706. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unpack items while in combat.");
  6707. else {
  6708. int16 index = atoi(sep->arg[1]);
  6709. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  6710. if (item) {
  6711. if(item->details.item_locked)
  6712. {
  6713. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot unpack the item in use.");
  6714. return;
  6715. }
  6716. // client->GetPlayer()->item_list.DestroyItem(index);
  6717. if (item->item_sets.size() > 0) {
  6718. for (int32 i = 0; i < item->item_sets.size(); i++) {
  6719. ItemSet* set = item->item_sets[i];
  6720. if (set->item_stack_size == 0)
  6721. set->item_stack_size += 1;
  6722. client->AddItem(set->item_id, set->item_stack_size);
  6723. }
  6724. }
  6725. }
  6726. client->RemoveItem(item, 1);
  6727. }
  6728. }
  6729. else if(sep->arg[1][0] && strncasecmp("unequip", sep->arg[0], 7) == 0 && sep->IsNumber(1))
  6730. {
  6731. int16 index = player->ConvertSlotFromClient(atoi(sep->arg[1]), client->GetVersion());
  6732. sint32 bag_id = -999;
  6733. int8 to_slot = 255;
  6734. if(sep->arg[3][0])
  6735. {
  6736. if(sep->IsNumber(2))
  6737. bag_id = atol(sep->arg[2]);
  6738. if(sep->IsNumber(3))
  6739. to_slot = atoi(sep->arg[3]);
  6740. }
  6741. sint8 unk4 = 0;
  6742. int8 appearance_equip = 0;
  6743. if(sep->arg[4][0] && sep->IsNumber(4))
  6744. unk4 = atoi(sep->arg[4]);
  6745. if(sep->arg[5][0] && sep->IsNumber(5))
  6746. appearance_equip = atoul(sep->arg[5]);
  6747. vector<EQ2Packet*> packets = client->GetPlayer()->UnequipItem(index, bag_id, to_slot, client->GetVersion(), appearance_equip);
  6748. EQ2Packet* outapp = 0;
  6749. for(int32 i=0;i<packets.size();i++)
  6750. {
  6751. outapp = packets[i];
  6752. if(outapp)
  6753. client->QueuePacket(outapp);
  6754. }
  6755. client->UnequipItem(index, bag_id, to_slot, appearance_equip);
  6756. }
  6757. else if(sep->arg[2][0] && strncasecmp("swap_equip", sep->arg[0], 10) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  6758. {
  6759. if(client->GetPlayer()->EngagedInCombat() && rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Player, AllowPlayerEquipCombat)->GetInt8() == 0) {
  6760. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not swap items while in combat.");
  6761. }
  6762. else {
  6763. int16 index1 = client->GetPlayer()->ConvertSlotFromClient(atoi(sep->arg[1]), client->GetVersion());
  6764. int16 index2 = client->GetPlayer()->ConvertSlotFromClient(atoi(sep->arg[2]), client->GetVersion());
  6765. int8 type = 0;
  6766. if(sep->IsNumber(3))
  6767. type = atoul(sep->arg[3]); // type 0 is combat, 3 = appearance
  6768. EQ2Packet* outapp = client->GetPlayer()->SwapEquippedItems(index1, index2, client->GetVersion(), type);
  6769. if(outapp)
  6770. client->QueuePacket(outapp);
  6771. else
  6772. {
  6773. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to swap items");
  6774. return;
  6775. }
  6776. }
  6777. }
  6778. else if (sep->arg[2][0] && strncasecmp("pop", sep->arg[0], 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  6779. {
  6780. sint16 to_slot = atoi(sep->arg[1]);
  6781. sint32 bag_id = atoi(sep->arg[2]);
  6782. Item* item = client->GetPlayer()->item_list.GetOverflowItem();
  6783. if (item) {
  6784. //auto inventory
  6785. if (bag_id == 0 && to_slot == -1)
  6786. {
  6787. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  6788. {
  6789. client->SimpleMessage(CHANNEL_ERROR, "You do not have any free slots.");
  6790. return;
  6791. }
  6792. // Set the slot for the item
  6793. item->details.inv_slot_id = bag_id;
  6794. item->details.slot_id = to_slot;
  6795. // Flag the item so it gets saved in its new location
  6796. item->save_needed = true;
  6797. // Add the item to its new location
  6798. if(player->item_list.AddItem(item)) {
  6799. // Remove the item from the overflow list
  6800. player->item_list.RemoveOverflowItem(item);
  6801. }
  6802. // Send the inventory update packet
  6803. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  6804. return;
  6805. }
  6806. else if (bag_id == -3 && to_slot == -1) {
  6807. // Auto Bank
  6808. if (!player->item_list.GetFirstFreeBankSlot(&bag_id, &to_slot)) {
  6809. client->SimpleMessage(CHANNEL_STATUS, "You do not have any free bank slots.");
  6810. return;
  6811. }
  6812. item->details.inv_slot_id = bag_id;
  6813. item->details.slot_id = to_slot;
  6814. item->save_needed = true;
  6815. if(player->item_list.AddItem(item)) {
  6816. player->item_list.RemoveOverflowItem(item);
  6817. }
  6818. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  6819. }
  6820. else if (bag_id == -4) {
  6821. // Shared Bank
  6822. if (!player->item_list.SharedBankAddAllowed(item)) {
  6823. client->SimpleMessage(CHANNEL_STATUS, "That item (or an item inside) cannot be shared.");
  6824. return;
  6825. }
  6826. Item* tmp_item = player->item_list.GetItem(-4, to_slot);
  6827. if (tmp_item) {
  6828. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  6829. return;
  6830. }
  6831. else {
  6832. item->details.inv_slot_id = bag_id;
  6833. item->details.slot_id = to_slot;
  6834. item->save_needed = true;
  6835. if(player->item_list.AddItem(item)) {
  6836. player->item_list.RemoveOverflowItem(item);
  6837. }
  6838. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  6839. return;
  6840. }
  6841. }
  6842. else {
  6843. // Try to get an item from the given bag id and slot id
  6844. Item* tmp_item = player->item_list.GetItem(bag_id, to_slot);
  6845. // Check to see if we got an item, if we do send an error,
  6846. // if we don't put the overflow item into this slot
  6847. if (tmp_item) {
  6848. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  6849. }
  6850. else {
  6851. item->details.inv_slot_id = bag_id;
  6852. item->details.slot_id = to_slot;
  6853. item->save_needed = true;
  6854. if(player->item_list.AddItem(item)) {
  6855. player->item_list.RemoveOverflowItem(item);
  6856. }
  6857. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  6858. return;
  6859. }
  6860. }
  6861. }
  6862. }
  6863. else if(sep->arg[2][0] && strncasecmp("nosale", sep->arg[0], 6) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  6864. {
  6865. sint64 data = strtoull(sep->arg[1], NULL, 0);
  6866. int32 character_item_id = (int32) (data >> 32);
  6867. int32 item_id = (int32) (data & 0xffffffffL);
  6868. int8 sale_setting = atoi(sep->arg[2]);
  6869. Item* item = client->GetPlayer()->item_list.GetItemFromUniqueID(character_item_id);
  6870. if(item)
  6871. {
  6872. item->no_sale = sale_setting;
  6873. item->save_needed = true;
  6874. client->SendSellMerchantList();
  6875. }
  6876. }
  6877. }
  6878. else
  6879. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /inventory {destroy|move|equip|unequip|swap_equip|pop} {item_id} [to_slot] [bag_id]");
  6880. }
  6881. /*
  6882. Function: Command_Languages()
  6883. Purpose : Show's languages the player knows
  6884. Params :
  6885. Dev : Zcoretri
  6886. Example :
  6887. */
  6888. void Commands::Command_Languages(Client* client, Seperator* sep)
  6889. {
  6890. list<Language*>* languages = client->GetPlayer()->GetPlayerLanguages()->GetAllLanguages();
  6891. list<Language*>::iterator itr;
  6892. Language* language;
  6893. client->Message(CHANNEL_NARRATIVE, "You know the following languages:");
  6894. for(itr = languages->begin(); itr != languages->end(); itr++)
  6895. {
  6896. language = *itr;
  6897. client->Message(CHANNEL_NARRATIVE, "%s", language->GetName());
  6898. }
  6899. }
  6900. /*
  6901. Function: Command_SetLanguage()
  6902. Purpose : Handles language commands
  6903. Params : Language ID
  6904. Dev : Zcoretri
  6905. Example :
  6906. */
  6907. void Commands::Command_SetLanguage(Client* client, Seperator* sep)
  6908. {
  6909. Player* player = client->GetPlayer();
  6910. if (sep && sep->arg[0])
  6911. {
  6912. if(!sep->IsNumber(0))
  6913. {
  6914. //String passed in
  6915. const char* value = sep->arg[0];
  6916. if(strncasecmp(value, "Common", strlen(value)) == 0)
  6917. {
  6918. database.SaveCharacterCurrentLang(0, client->GetCharacterID(), client);
  6919. client->SendLanguagesUpdate(0);
  6920. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", value);
  6921. }
  6922. else
  6923. {
  6924. if(player->HasLanguage(value))
  6925. {
  6926. Language* language = player->GetPlayerLanguages()->GetLanguageByName(value);
  6927. database.SaveCharacterCurrentLang(language->GetID(), client->GetCharacterID(), client);
  6928. client->SendLanguagesUpdate(language->GetID());
  6929. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", language->GetName());
  6930. }
  6931. else
  6932. client->Message(CHANNEL_NARRATIVE, "You do not know how to speak %s", value);
  6933. }
  6934. }
  6935. else
  6936. {
  6937. //Number passed in
  6938. int32 id = atoul(sep->arg[0]);
  6939. if(player->HasLanguage(id))
  6940. {
  6941. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  6942. database.SaveCharacterCurrentLang(id, client->GetCharacterID(), client);
  6943. client->SendLanguagesUpdate(id);
  6944. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", language->GetName());
  6945. }
  6946. else
  6947. {
  6948. Language* language = master_languages_list.GetLanguage(id);
  6949. if(language)
  6950. client->Message(CHANNEL_NARRATIVE, "You do not know how to speak %s", language->GetName());
  6951. }
  6952. }
  6953. }
  6954. else
  6955. {
  6956. //No value was passed in
  6957. int32 id = database.GetCharacterCurrentLang(client->GetCharacterID(), player);
  6958. if(id > 0)
  6959. {
  6960. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  6961. client->Message(CHANNEL_NARRATIVE, "You are currently speaking %s ", language->GetName());
  6962. }
  6963. else
  6964. client->Message(CHANNEL_NARRATIVE, "You are currently speaking Common");
  6965. }
  6966. }
  6967. /*
  6968. Function: Command_LastName()
  6969. Purpose : Sets player surname
  6970. Params : Name text
  6971. Dev : theFoof
  6972. Example :
  6973. */
  6974. void Commands::Command_LastName(Client* client, Seperator* sep)
  6975. {
  6976. if (!client)
  6977. return;
  6978. if (sep && sep->arg[0])
  6979. {
  6980. if (!client->GetPlayer()->get_character_flag(CF_ENABLE_CHANGE_LASTNAME)){
  6981. client->Message(CHANNEL_COLOR_YELLOW, "You must be atleast level %i to change your last name.", rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Player, MinLastNameLevel)->GetInt8());
  6982. return;
  6983. }
  6984. client->RemovePendingLastName();
  6985. uchar* checkname = (uchar*)sep->arg[0];
  6986. bool valid_name = true;
  6987. for (int32 i = 0; i < strlen(sep->arg[0]); i++) {
  6988. if (!alpha_check(checkname[i])) {
  6989. valid_name = false;
  6990. break;
  6991. }
  6992. }
  6993. if (!valid_name) {
  6994. client->Message(CHANNEL_COLOR_YELLOW, "Your last name can only contain letters.", rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Player, MinLastNameLevel)->GetInt8());
  6995. return;
  6996. }
  6997. string last_name = (string)sep->arg[0];
  6998. int8 max_length = rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Player, MaxLastNameLength)->GetInt8();
  6999. int8 min_length = rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Player, MinLastNameLength)->GetInt8();
  7000. if (last_name.length() <= max_length && last_name.length() >= min_length){
  7001. client->SetPendingLastName(last_name);
  7002. client->SendLastNameConfirmation();
  7003. }
  7004. else
  7005. client->Message(CHANNEL_COLOR_YELLOW, "Your last name must be between %i and %i characters long.", min_length, max_length);
  7006. }
  7007. }
  7008. /*
  7009. Function: Command_ConfirmLastName()
  7010. Purpose : Confirms setting of player surname
  7011. Params : Name text
  7012. Dev : theFoof
  7013. Example :
  7014. */
  7015. void Commands::Command_ConfirmLastName(Client* client, Seperator* sep)
  7016. {
  7017. if (!client)
  7018. return;
  7019. string* name = client->GetPendingLastName();
  7020. if (name){
  7021. Player* player = client->GetPlayer();
  7022. player->SetLastName(name->c_str(), false);
  7023. client->SendTitleUpdate();
  7024. player->SetCharSheetChanged(true);
  7025. client->RemovePendingLastName();
  7026. }
  7027. }
  7028. /*
  7029. Function: Command_Location()
  7030. Purpose : Display's Help for /location commands
  7031. Params :
  7032. Dev : Scatman
  7033. Example : /location = show's help for command
  7034. */
  7035. void Commands::Command_Location(Client* client)
  7036. {
  7037. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Valid /location commands are:");
  7038. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location create [name] (include y). Include y defaults to false");
  7039. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location add [location id]");
  7040. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location remove [location point id]");
  7041. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location delete [location id]");
  7042. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location list [locations|points] [location id if points used]");
  7043. }
  7044. /*
  7045. Function: Command_LocationAdd()
  7046. Purpose : Add's a location to an existing location config
  7047. Params : location_id
  7048. Dev : Scatman
  7049. Example : /location add {location_id}
  7050. */
  7051. void Commands::Command_LocationAdd(Client* client, Seperator* sep)
  7052. {
  7053. if (sep && sep->arg[0] && sep->IsNumber(0))
  7054. {
  7055. int32 location_id = atoul(sep->arg[0]);
  7056. float x = client->GetPlayer()->GetX();
  7057. float y = client->GetPlayer()->GetY();
  7058. float z = client->GetPlayer()->GetZ();
  7059. if (database.AddLocationPoint(location_id, x, y, z))
  7060. client->Message(CHANNEL_COLOR_YELLOW, "Point (%f, %f, %f) was successfully added to location %u", x, y, z, location_id);
  7061. else
  7062. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist. Use /location create to create one", location_id);
  7063. }
  7064. else
  7065. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location add [location id]");
  7066. }
  7067. /*
  7068. Function: Command_LocationCreate()
  7069. Purpose : Creates a new location config
  7070. Params : location name, 0/1 for include_y (optional)
  7071. Dev : Scatman
  7072. Example : /location create Test 1 = creates a new location named Test with include_y True
  7073. */
  7074. void Commands::Command_LocationCreate(Client* client, Seperator* sep)
  7075. {
  7076. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  7077. {
  7078. const char* name = sep->arg[0];
  7079. bool include_y = false;
  7080. if (sep->arg[1] && sep->IsNumber(1) && atoi(sep->arg[1]) > 0)
  7081. include_y = true;
  7082. int32 location_id = database.CreateLocation(client->GetPlayer()->GetZone()->GetZoneID(), client->GetPlayer()->GetLocation(), name, include_y);
  7083. if (location_id > 0)
  7084. client->Message(CHANNEL_COLOR_YELLOW, "Location '%s' was successfully created with location id %u", name, location_id);
  7085. else
  7086. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the requested location");
  7087. }
  7088. else
  7089. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location create [name] (include_y). Include y defaults to false");
  7090. }
  7091. /*
  7092. Function: Command_LocationDelete()
  7093. Purpose : Delete's a location config and all it's location points
  7094. Params : location_id
  7095. Dev : Scatman
  7096. Example : /location delete {location_id}
  7097. */
  7098. void Commands::Command_LocationDelete(Client* client, Seperator* sep)
  7099. {
  7100. if (sep && sep->arg[0] && sep->IsNumber(0))
  7101. {
  7102. int32 location_id = atoul(sep->arg[0]);
  7103. if (database.DeleteLocation(location_id))
  7104. client->Message(CHANNEL_COLOR_YELLOW, "Location id %u and all its points were successfully deleted", location_id);
  7105. else
  7106. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist", location_id);
  7107. }
  7108. else
  7109. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location delete [location id]");
  7110. }
  7111. /*
  7112. Function: Command_LocationList()
  7113. Purpose : Display's a list of location points
  7114. Params : location_id
  7115. Dev : Scatman
  7116. Example : /location list {location_id}
  7117. */
  7118. void Commands::Command_LocationList(Client* client, Seperator* sep)
  7119. {
  7120. if (sep && sep->arg[0])
  7121. {
  7122. const char* option = sep->arg[0];
  7123. if (strncmp(option, "locations", strlen(option)) == 0)
  7124. database.ListLocations(client);
  7125. else if (strncmp(option, "points", strlen(option)) == 0 && sep->arg[1] && sep->IsNumber(1))
  7126. {
  7127. int32 location_id = atoul(sep->arg[1]);
  7128. database.ListLocationPoints(client, location_id);
  7129. }
  7130. else
  7131. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  7132. }
  7133. else
  7134. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  7135. }
  7136. /*
  7137. Function: Command_LocationRemove()
  7138. Purpose : Removes a single location point from a location config
  7139. Params : location_point_id (gotten from /location list {id})
  7140. Dev : Scatman
  7141. Example : /location remove 1 = will remove location_point_id 1
  7142. */
  7143. void Commands::Command_LocationRemove(Client* client, Seperator* sep)
  7144. {
  7145. if (sep && sep->arg[0] && sep->IsNumber(0))
  7146. {
  7147. int32 location_point_id = atoul(sep->arg[0]);
  7148. if (database.DeleteLocationPoint(location_point_id))
  7149. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Location point was successfully deleted");
  7150. else
  7151. client->Message(CHANNEL_COLOR_YELLOW, "Location point with ID %u does not exist", location_point_id);
  7152. }
  7153. else
  7154. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location remove [location point id]");
  7155. }
  7156. /*
  7157. Function: Command_Merchant()
  7158. Purpose : Handles Merchant commands
  7159. Params : list
  7160. Dev : Scatman
  7161. Example : /merchant list
  7162. */
  7163. void Commands::Command_Merchant(Client* client, Seperator* sep, int handler)
  7164. {
  7165. if( handler == COMMAND_MERCHANT )
  7166. {
  7167. // /merchant command by itself shows help (to be extended)
  7168. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  7169. return;
  7170. }
  7171. else if( handler == COMMAND_MERCHANT_LIST )
  7172. {
  7173. // /merchant list command expects "description" param
  7174. if (sep && sep->arg[0])
  7175. {
  7176. const char* merchant_description = sep->argplus[0];
  7177. client->Message(CHANNEL_COLOR_YELLOW, "Listing merchants like '%s':", merchant_description);
  7178. map<int32, MerchantInfo*>* merchant_info = world.GetMerchantInfo();
  7179. map<int32, MerchantInfo*>::iterator itr;
  7180. for (itr = merchant_info->begin(); itr != merchant_info->end(); itr++)
  7181. {
  7182. string description = database.GetMerchantDescription(itr->first);
  7183. if (ToLower(description).find(ToLower(string(merchant_description))) < 0xFFFFFFFF)
  7184. client->Message(CHANNEL_COLOR_YELLOW, "Merchant ID: %u, Description: %s", itr->first, description.c_str());
  7185. }
  7186. }
  7187. else // no description
  7188. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  7189. }
  7190. }
  7191. /*
  7192. Function: Command_Modify()
  7193. Purpose : to replace our other "set" commands
  7194. Params : System = the system to modify, Action = the action to perform, Target = what to change (target, or index)
  7195. Dev : John Adams
  7196. Example : /modify spell set name "Aegolism III"
  7197. */
  7198. void Commands::Command_Modify(Client* client)
  7199. {
  7200. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /modify [system] [action] [field] [value] {target|id}");
  7201. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Systems: character, faction, guild, item, skill, spawn, spell, zone");
  7202. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Actions: set, create, delete, add, remove");
  7203. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Value : field name in the table being modified");
  7204. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target : modify current target, or specified {system} ID");
  7205. }
  7206. /*
  7207. Function: Command_ModifySpawn()
  7208. Purpose : replace "spawn set" commands
  7209. Params : Action : the action to perform (or special handler)
  7210. : Field : the DB field to change
  7211. : Value : what to set the value to
  7212. : Target : what object to change (my target, or spawn_id)
  7213. Dev : John Adams
  7214. Example : /modify spawn set name "Lady Vox"
  7215. :
  7216. Note : Special Handlers, like "zoneto" for Signs
  7217. : /modify spawn zoneto
  7218. : Will set a sign's zone x/y/z to my current coords
  7219. */
  7220. void Commands::Command_ModifySpawn(Client* client, Seperator* sep)
  7221. {
  7222. PrintSep(sep, "COMMAND_MODIFY");
  7223. // need at least 2 args for a valid command
  7224. if( sep && sep->arg[1] )
  7225. {
  7226. // JA: just a quick implementation because I need it :)
  7227. if (strcmp(sep->arg[0], "zoneto") == 0)
  7228. {
  7229. if( sep->IsNumber(1) )
  7230. {
  7231. int32 spawn_id = atoul(sep->arg[1]);
  7232. float x_coord = client->GetPlayer()->GetX();
  7233. float y_coord = client->GetPlayer()->GetY();
  7234. float z_coord = client->GetPlayer()->GetZ();
  7235. float h_coord = client->GetPlayer()->GetHeading();
  7236. database.SaveSignZoneToCoords(spawn_id, x_coord, y_coord, z_coord, h_coord);
  7237. }
  7238. else
  7239. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify spawn zoneto spawn_id - sets spawn_id to your coords");
  7240. }
  7241. }
  7242. else
  7243. Command_Modify(client);
  7244. }
  7245. /*
  7246. Function: Command_ModifyCharacter()
  7247. Purpose : to replace our other "set" commands
  7248. Params : Action : Add, Remove
  7249. : Field : copper, silver, gold, plat
  7250. : Value : min 1, max unlimited
  7251. : Target : Self, Player
  7252. Dev : Cynnar
  7253. Example : /modify character add gold 50
  7254. : /modify character remove silver 25
  7255. */
  7256. void Commands::Command_ModifyCharacter(Client* client, Seperator* sep)
  7257. {
  7258. PrintSep(sep, "COMMAND_MODIFY");
  7259. int64 value = 0;
  7260. Player* player = client->GetPlayer();
  7261. Client* targetClient = client;
  7262. if (player->HasTarget() && player->GetTarget()->IsPlayer()) {
  7263. player = (Player*)player->GetTarget();
  7264. targetClient = player->GetClient();
  7265. }
  7266. // need at least 2 args for a valid command
  7267. if( sep && sep->arg[1] )
  7268. {
  7269. if (strcmp(sep->arg[0], "add") == 0)
  7270. {
  7271. if (strcmp(sep->arg[1], "copper") == 0)
  7272. {
  7273. value = atoi64(sep->arg[2]);
  7274. player->AddCoins(value);
  7275. if (client->GetPlayer() == player)
  7276. {
  7277. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu copper coin%s", value, (value > 1 ? "s" : ""));
  7278. }
  7279. else {
  7280. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu copper coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  7281. if(targetClient) {
  7282. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu copper coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  7283. }
  7284. }
  7285. }
  7286. else if (strcmp(sep->arg[1], "silver") == 0)
  7287. {
  7288. value = atoi64(sep->arg[2]) * 100;
  7289. player->AddCoins(value);
  7290. if (client->GetPlayer() == player)
  7291. {
  7292. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu silver coin%s", value / 100, (value > 1 ? "s" : ""));
  7293. }
  7294. else {
  7295. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu silver coin%s", player->GetName(), value / 100, (value > 1 ? "s" : ""));
  7296. if(targetClient) {
  7297. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu silver coin%s", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  7298. }
  7299. }
  7300. }
  7301. else if (strcmp(sep->arg[1], "gold") == 0)
  7302. {
  7303. value = atoi64(sep->arg[2]) * 10000;
  7304. player->AddCoins(value);
  7305. if (client->GetPlayer() == player)
  7306. {
  7307. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu gold coin%s", value / 10000, (value > 1 ? "s" : ""));
  7308. }
  7309. else {
  7310. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu gold coin%s", player->GetName(), value / 10000, (value > 1 ? "s" : ""));
  7311. if(targetClient) {
  7312. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu gold coin%s", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  7313. }
  7314. }
  7315. }
  7316. else if (strcmp(sep->arg[1], "plat") == 0)
  7317. {
  7318. value = atoi64(sep->arg[2]) * 1000000;
  7319. player->AddCoins(value);
  7320. if (client->GetPlayer() == player)
  7321. {
  7322. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu platinum coin%s", value / 1000000, (value > 1 ? "s" : ""));
  7323. }
  7324. else {
  7325. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu platinum coin%s", player->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  7326. if(targetClient) {
  7327. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu platinum coin%s", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  7328. }
  7329. }
  7330. }
  7331. else
  7332. {
  7333. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  7334. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  7335. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  7336. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character add copper 20");
  7337. }
  7338. }
  7339. else if (strcmp(sep->arg[0], "remove") == 0)
  7340. {
  7341. if (strcmp(sep->arg[1], "copper") == 0)
  7342. {
  7343. value = atoi64(sep->arg[2]);
  7344. player->RemoveCoins(value);
  7345. if (client->GetPlayer() == player)
  7346. {
  7347. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from yourself", value, (value > 1 ? "s" : ""));
  7348. }
  7349. else {
  7350. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from %s", value, (value > 1 ? "s" : ""), player->GetName());
  7351. if(targetClient) {
  7352. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu copper coin%s from you", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  7353. }
  7354. }
  7355. }
  7356. else if (strcmp(sep->arg[1], "silver") == 0)
  7357. {
  7358. value = atoi64(sep->arg[2]) * 100;
  7359. player->RemoveCoins(value);
  7360. if (client->GetPlayer() == player)
  7361. {
  7362. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from yourself", value / 100, (value > 1 ? "s" : ""));
  7363. }
  7364. else {
  7365. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from %s", value / 100, (value > 1 ? "s" : ""), player->GetName());
  7366. if(targetClient) {
  7367. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu silver coin%s from you", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  7368. }
  7369. }
  7370. }
  7371. else if (strcmp(sep->arg[1], "gold") == 0)
  7372. {
  7373. value = atoi64(sep->arg[2]) * 10000;
  7374. player->RemoveCoins(value);
  7375. if (client->GetPlayer() == player)
  7376. {
  7377. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from yourself", value / 10000, (value > 1 ? "s" : ""));
  7378. }
  7379. else {
  7380. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from %s", value / 10000, (value > 1 ? "s" : ""), player->GetName());
  7381. if(targetClient) {
  7382. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu gold coin%s from you", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  7383. }
  7384. }
  7385. }
  7386. else if (strcmp(sep->arg[1], "plat") == 0)
  7387. {
  7388. value = atoi64(sep->arg[2]) * 1000000;
  7389. player->RemoveCoins(value);
  7390. if (client->GetPlayer() == player)
  7391. {
  7392. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from yourself", value / 1000000, (value > 1 ? "s" : ""));
  7393. }
  7394. else {
  7395. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from %s", value / 1000000, (value > 1 ? "s" : ""), player->GetName());
  7396. if(targetClient) {
  7397. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu platinum coin%s from you", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  7398. }
  7399. }
  7400. }
  7401. else
  7402. {
  7403. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  7404. }
  7405. }
  7406. else if (strcmp(sep->arg[0], "set") == 0) {
  7407. if (strcmp(sep->arg[1], "tslevel") == 0) {
  7408. int8 level = atoi(sep->arg[2]);
  7409. if (level > 0 && level < 256) {
  7410. if (player) {
  7411. if (client->GetPlayer() == player)
  7412. client->ChangeTSLevel(player->GetTSLevel(), level);
  7413. else if(targetClient)
  7414. targetClient->ChangeTSLevel(player->GetTSLevel(), level);
  7415. }
  7416. }
  7417. else
  7418. client->SimpleMessage(CHANNEL_ERROR, "Level must be between 1 - 255");
  7419. }
  7420. else if (strcmp(sep->arg[1], "tsclass") == 0) {
  7421. int8 tsclass = atoi(sep->arg[2]);
  7422. player->SetTradeskillClass(tsclass);
  7423. player->GetInfoStruct()->set_tradeskill_class1(classes.GetTSBaseClass(player->GetTradeskillClass()));
  7424. player->GetInfoStruct()->set_tradeskill_class2(classes.GetSecondaryTSBaseClass(player->GetTradeskillClass()));
  7425. player->GetInfoStruct()->set_tradeskill_class3(player->GetTradeskillClass());
  7426. player->SetCharSheetChanged(true);
  7427. }
  7428. else if (strcmp(sep->arg[1], "gender") == 0) {
  7429. int8 gender = atoi(sep->arg[2]);
  7430. client->GetPlayer()->GetInfoStruct()->set_gender(gender);
  7431. client->GetPlayer()->SetCharSheetChanged(true);
  7432. client->UpdateTimeStampFlag ( GENDER_UPDATE_FLAG );
  7433. }
  7434. }
  7435. }
  7436. else
  7437. {
  7438. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  7439. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  7440. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  7441. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  7442. }
  7443. }
  7444. void Commands::Command_ModifyFaction(Client* client, Seperator* sep)
  7445. {
  7446. PrintSep(sep, "COMMAND_MODIFY");
  7447. // need at least 2 args for a valid command
  7448. if( sep && sep->arg[1] )
  7449. {
  7450. }
  7451. else
  7452. Command_Modify(client);
  7453. }
  7454. void Commands::Command_ModifyGuild(Client* client, Seperator* sep)
  7455. {
  7456. PrintSep(sep, "COMMAND_MODIFY");
  7457. // need at least 2 args for a valid command
  7458. if( sep && sep->arg[1] )
  7459. {
  7460. }
  7461. else
  7462. Command_Modify(client);
  7463. }
  7464. void Commands::Command_ModifyItem(Client* client, Seperator* sep)
  7465. {
  7466. PrintSep(sep, "COMMAND_MODIFY");
  7467. // need at least 2 args for a valid command
  7468. if( sep && sep->arg[1] )
  7469. {
  7470. }
  7471. else
  7472. Command_Modify(client);
  7473. }
  7474. /*
  7475. Function: Command_ModifyQuest()
  7476. Purpose : to list players quest and completed quests
  7477. Params : Action : list, completed
  7478. : Target : Self, Player
  7479. Dev : Cynnar
  7480. Example : /modify quest list
  7481. : /modify quest completed
  7482. */
  7483. void Commands::Command_ModifyQuest(Client* client, Seperator* sep)
  7484. {
  7485. PrintSep(sep, "COMMAND_MODIFY");
  7486. int64 value = 0;
  7487. Player* player = client->GetPlayer();
  7488. Client* targetClient = client;
  7489. if (player->HasTarget() && player->GetTarget()->IsPlayer()) {
  7490. player = (Player*)player->GetTarget();
  7491. targetClient = player->GetClient();
  7492. }
  7493. // need at least 2 args for a valid command
  7494. if (sep && sep->arg[1])
  7495. {
  7496. if (strcmp(sep->arg[0], "list") == 0)
  7497. {
  7498. map<int32, Quest*>* quests = player->GetPlayerQuests();
  7499. map<int32, Quest*>::iterator itr;
  7500. client->Message(CHANNEL_COLOR_YELLOW, "%s's Quest List:.", client->GetPlayer()->GetName());
  7501. if (quests->size() == 0)
  7502. client->Message(CHANNEL_COLOR_YELLOW, "%s has no quests.", client->GetPlayer()->GetName());
  7503. else
  7504. {
  7505. for (itr = quests->begin(); itr != quests->end(); itr++)
  7506. {
  7507. Quest* quest = itr->second;
  7508. if(quest) {
  7509. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  7510. }
  7511. }
  7512. }
  7513. }
  7514. else if (strcmp(sep->arg[0], "completed") == 0)
  7515. {
  7516. map<int32, Quest*>* quests = player->GetCompletedPlayerQuests();
  7517. map<int32, Quest*>::iterator itr;
  7518. client->Message(CHANNEL_COLOR_YELLOW, "%s's Completed Quest List:.", client->GetPlayer()->GetName());
  7519. if (quests->size() == 0)
  7520. client->Message(CHANNEL_COLOR_YELLOW, "%s has no completed quests.", client->GetPlayer()->GetName());
  7521. else
  7522. {
  7523. for (itr = quests->begin(); itr != quests->end(); itr++)
  7524. {
  7525. Quest* quest = itr->second;
  7526. if(quest) {
  7527. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  7528. }
  7529. }
  7530. }
  7531. }
  7532. // Add in a progress step, and a LogWrite() for tracking GM Commands.
  7533. // LogWrite(LUA__DEBUG, 0, "LUA", "Quest: %s, function: %s", quest->GetName(), function);
  7534. else if (strcmp(sep->arg[0], "remove") == 0)
  7535. {
  7536. int32 quest_id = 0;
  7537. if (sep && sep->arg[1] && sep->IsNumber(1))
  7538. quest_id = atoul(sep->arg[1]);
  7539. if (quest_id > 0)
  7540. {
  7541. if (lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0)
  7542. {
  7543. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  7544. if (quest)
  7545. if (client->GetPlayer() == player)
  7546. {
  7547. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been removed from your journal", quest->GetName());
  7548. }
  7549. else
  7550. {
  7551. client->Message(CHANNEL_COLOR_YELLOW, "You have removed the quest %s from %s's journal", quest->GetName(), player->GetName());
  7552. if(targetClient) {
  7553. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s has removed the quest %s from your journal", client->GetPlayer()->GetName(), quest->GetName());
  7554. }
  7555. }
  7556. LogWrite(COMMAND__INFO, 0, "GM Command", "%s removed the quest %s from %s", client->GetPlayer()->GetName(), quest->GetName(), player->GetName());
  7557. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  7558. }
  7559. client->RemovePlayerQuest(quest_id);
  7560. client->GetCurrentZone()->SendQuestUpdates(client);
  7561. }
  7562. }
  7563. else if (strcmp(sep->arg[0], "advance") == 0)
  7564. {
  7565. int32 quest_id = 0;
  7566. int32 step = 0;
  7567. if (sep && sep->arg[1] && sep->IsNumber(1))
  7568. {
  7569. quest_id = atoul(sep->arg[1]);
  7570. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  7571. if(!quest) {
  7572. client->Message(CHANNEL_COLOR_RED, "Quest not found!");
  7573. return;
  7574. }
  7575. if (sep && sep->arg[2] && sep->IsNumber(1))
  7576. {
  7577. step = atoul(sep->arg[2]);
  7578. if (quest_id > 0 && step > 0)
  7579. {
  7580. if (player && player->IsPlayer() && quest_id > 0 && step > 0 && (player->player_quests.count(quest_id) > 0))
  7581. {
  7582. if (client)
  7583. {
  7584. client->AddPendingQuestUpdate(quest_id, step);
  7585. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been advanced one step.", quest->GetName());
  7586. LogWrite(COMMAND__INFO, 0, "GM Command", "%s advanced the quest %s one step", client->GetPlayer()->GetName(), quest->GetName());
  7587. }
  7588. }
  7589. }
  7590. else
  7591. {
  7592. client->Message(CHANNEL_COLOR_RED, "Quest ID and Step Number must be greater than 0!");
  7593. }
  7594. }
  7595. else
  7596. {
  7597. client->Message(CHANNEL_COLOR_RED, "Step Number must be a number!");
  7598. }
  7599. }
  7600. else
  7601. {
  7602. client->Message(CHANNEL_COLOR_RED, "Quest ID must be a number!");
  7603. }
  7604. }
  7605. else
  7606. {
  7607. Command_Modify(client);
  7608. }
  7609. }
  7610. else
  7611. {
  7612. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify quest [action] [quest id] [step number]");
  7613. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: list, completed, remove, advance");
  7614. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest list");
  7615. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest remove 156");
  7616. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest advance 50 1");
  7617. }
  7618. }
  7619. void Commands::Command_ModifySkill(Client* client, Seperator* sep)
  7620. {
  7621. PrintSep(sep, "COMMAND_MODIFY");
  7622. // need at least 2 args for a valid command
  7623. if( sep && sep->arg[1] )
  7624. {
  7625. if (strcmp(sep->arg[0], "add") == 0) {
  7626. const char* skill_name = sep->argplus[1];
  7627. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  7628. if (skill) {
  7629. Player* player = 0;
  7630. Client* to_client = 0;
  7631. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  7632. player = (Player*)client->GetPlayer()->GetTarget();
  7633. to_client = player->GetClient();
  7634. }
  7635. else {
  7636. player = client->GetPlayer();
  7637. to_client = client;
  7638. }
  7639. if (player)
  7640. {
  7641. if (!player->GetSkills()->HasSkill(skill->skill_id))
  7642. {
  7643. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  7644. if (to_client == client) {
  7645. client->Message(CHANNEL_STATUS, "Added skill '%s'.", skill_name);
  7646. }
  7647. else {
  7648. client->Message(CHANNEL_STATUS, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  7649. to_client->Message(CHANNEL_STATUS, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  7650. }
  7651. }
  7652. else
  7653. client->Message(CHANNEL_STATUS, "%s already has the skill '%s'.", to_client == client ? "You" : player->GetName(), skill_name);
  7654. }
  7655. }
  7656. else
  7657. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  7658. }
  7659. else if (strcmp(sep->arg[0], "remove") == 0) {
  7660. const char* skill_name = sep->argplus[1];
  7661. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  7662. if (skill) {
  7663. Player* player = 0;
  7664. Client* to_client = 0;
  7665. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  7666. player = (Player*)client->GetPlayer()->GetTarget();
  7667. to_client = player->GetClient();
  7668. }
  7669. else {
  7670. player = client->GetPlayer();
  7671. to_client = client;
  7672. }
  7673. if (player)
  7674. {
  7675. if (player->GetSkills()->HasSkill(skill->skill_id))
  7676. {
  7677. player->RemoveSkillFromDB(skill, true);
  7678. if (client == to_client) {
  7679. client->Message(CHANNEL_STATUS, "Removed skill '%s'.", skill_name);
  7680. }
  7681. else {
  7682. client->Message(CHANNEL_STATUS, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  7683. if(to_client) {
  7684. to_client->Message(CHANNEL_STATUS, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  7685. }
  7686. }
  7687. }
  7688. else {
  7689. if (client == to_client)
  7690. client->Message(CHANNEL_STATUS, "You do not have the skill '%s'.", skill_name);
  7691. else
  7692. client->Message(CHANNEL_STATUS, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  7693. }
  7694. }
  7695. }
  7696. else
  7697. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  7698. }
  7699. else if (strcmp(sep->arg[0], "set") == 0) {
  7700. if (!sep->IsNumber(2)) {
  7701. client->Message(CHANNEL_STATUS, "The last parameter must be a number.");
  7702. return;
  7703. }
  7704. const char* skill_name = sep->arg[1];
  7705. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  7706. if (skill) {
  7707. int16 val = atoi(sep->arg[2]);
  7708. Player* player = 0;
  7709. Client* to_client = 0;
  7710. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  7711. player = (Player*)client->GetPlayer()->GetTarget();
  7712. to_client = player->GetClient();
  7713. }
  7714. else {
  7715. player = client->GetPlayer();
  7716. to_client = client;
  7717. }
  7718. if (player)
  7719. {
  7720. if (player->GetSkills()->HasSkill(skill->skill_id)) {
  7721. player->GetSkills()->SetSkill(skill->skill_id, val);
  7722. if (client != to_client)
  7723. client->Message(CHANNEL_STATUS, "You set %s's '%s' skill to %i.", player->GetName(), skill_name, val);
  7724. if(to_client) {
  7725. to_client->Message(CHANNEL_STATUS, "Your '%s' skill has been set to %i.", skill_name, val);
  7726. }
  7727. }
  7728. else {
  7729. client->Message(CHANNEL_STATUS, "Target does not have the skill '%s'.", skill_name);
  7730. }
  7731. }
  7732. }
  7733. else {
  7734. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  7735. }
  7736. }
  7737. else {
  7738. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  7739. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  7740. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  7741. }
  7742. }
  7743. else {
  7744. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  7745. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  7746. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  7747. }
  7748. }
  7749. void Commands::Command_ModifySpell(Client* client, Seperator* sep)
  7750. {
  7751. PrintSep(sep, "COMMAND_MODIFY");
  7752. // need at least 2 args for a valid command
  7753. if( sep && sep->arg[1] )
  7754. {
  7755. }
  7756. else
  7757. Command_Modify(client);
  7758. }
  7759. void Commands::Command_ModifyZone(Client* client, Seperator* sep)
  7760. {
  7761. PrintSep(sep, "COMMAND_MODIFY");
  7762. // need at least 2 args for a valid command
  7763. if( sep && sep->arg[1] )
  7764. {
  7765. }
  7766. else
  7767. Command_Modify(client);
  7768. }
  7769. /*
  7770. Function: Command_MOTD()
  7771. Purpose : Displays server MOTD
  7772. Params :
  7773. Dev : LethalEncounter
  7774. Example : /motd
  7775. */
  7776. void Commands::Command_MOTD(Client* client)
  7777. {
  7778. if (client)
  7779. ClientPacketFunctions::SendMOTD(client);
  7780. }
  7781. /*
  7782. Function: Command_Pet()
  7783. Purpose : Handle Pet {Command} commands
  7784. Params : attack, backoff, preserve_master, preserve_self, follow, stay, getlost
  7785. Dev :
  7786. Example : /pet preserve_master
  7787. */
  7788. void Commands::Command_Pet(Client* client, Seperator* sep)
  7789. {
  7790. PrintSep(sep, "COMMAND_PET");
  7791. //LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Pet Commands");
  7792. //client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7793. if (!sep || !sep->arg[0])
  7794. return; // should have sep->arg[0] filled
  7795. if (strcmp(sep->arg[0], "hide") == 0) {
  7796. // doing /pet hide will toggle the hide status on all the pets that can be hidden
  7797. Entity* pet = client->GetPlayer()->GetDeityPet();
  7798. if (pet) {
  7799. if (pet->IsPrivateSpawn())
  7800. client->GetPlayer()->HideDeityPet(false);
  7801. else
  7802. client->GetPlayer()->HideDeityPet(true);
  7803. }
  7804. pet = client->GetPlayer()->GetCosmeticPet();
  7805. if (pet) {
  7806. if (pet->IsPrivateSpawn())
  7807. client->GetPlayer()->HideCosmeticPet(false);
  7808. else
  7809. client->GetPlayer()->HideCosmeticPet(true);
  7810. }
  7811. return;
  7812. }
  7813. // below is for all combat pets
  7814. if (!client->GetPlayer()->HasPet()) {
  7815. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a pet.");
  7816. return;
  7817. }
  7818. if (strcmp(sep->arg[0], "stay") == 0 || strcmp(sep->arg[0], "stayhere") == 0) {
  7819. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to stay.");
  7820. client->GetPlayer()->GetInfoStruct()->set_pet_movement(1);
  7821. client->GetPlayer()->SetCharSheetChanged(true);
  7822. if (client->GetPlayer()->GetPet())
  7823. client->GetPlayer()->GetPet()->following = false;
  7824. if (client->GetPlayer()->GetCharmedPet())
  7825. client->GetPlayer()->GetCharmedPet()->following = false;
  7826. }
  7827. else if (strcmp(sep->arg[0], "follow") == 0 || strcmp(sep->arg[0], "followme") == 0) {
  7828. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to follow.");
  7829. client->GetPlayer()->GetInfoStruct()->set_pet_movement(2);
  7830. client->GetPlayer()->SetCharSheetChanged(true);
  7831. }
  7832. else if (strcmp(sep->arg[0], "preserve_master") == 0 || strcmp(sep->arg[0], "guardme") == 0) {
  7833. if (client->GetPlayer()->GetInfoStruct()->get_pet_behavior() & 1) {
  7834. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect you.");
  7835. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()-1);
  7836. }
  7837. else {
  7838. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect you.");
  7839. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()+1);
  7840. }
  7841. client->GetPlayer()->SetCharSheetChanged(true);
  7842. }
  7843. else if (strcmp(sep->arg[0], "preserve_self") == 0 || strcmp(sep->arg[0], "guardhere") == 0) { // guardhere might be accurate, diff logic
  7844. if (client->GetPlayer()->GetInfoStruct()->get_pet_behavior() & 2) {
  7845. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect itself.");
  7846. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()-2);
  7847. }
  7848. else {
  7849. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect itself.");
  7850. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()+2);
  7851. }
  7852. client->GetPlayer()->SetCharSheetChanged(true);
  7853. }
  7854. else if (strcmp(sep->arg[0], "backoff") == 0) {
  7855. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to back down.");
  7856. if (client->GetPlayer()->GetPet())
  7857. ((NPC*)client->GetPlayer()->GetPet())->Brain()->ClearHate();
  7858. if (client->GetPlayer()->GetCharmedPet())
  7859. ((NPC*)client->GetPlayer()->GetCharmedPet())->Brain()->ClearHate();
  7860. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(0);
  7861. client->GetPlayer()->SetCharSheetChanged(true);
  7862. }
  7863. else if (strcmp(sep->arg[0], "attack") == 0) {
  7864. if (client->GetPlayer()->HasTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  7865. if (client->GetPlayer()->AttackAllowed((Entity*)client->GetPlayer()->GetTarget())){
  7866. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to attack your target.");
  7867. if (client->GetPlayer()->GetPet())
  7868. client->GetPlayer()->GetPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  7869. if (client->GetPlayer()->GetCharmedPet())
  7870. client->GetPlayer()->GetCharmedPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  7871. }
  7872. else
  7873. client->Message(CHANNEL_COLOR_YELLOW, "You can not attack that.");
  7874. }
  7875. else
  7876. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a target.");
  7877. }
  7878. else if (strcmp(sep->arg[0], "getlost") == 0) {
  7879. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetPet());
  7880. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetCharmedPet());
  7881. client->Message(CHANNEL_COLOR_YELLOW, "You tell your pet to get lost.");
  7882. }
  7883. else
  7884. client->Message(CHANNEL_COLOR_YELLOW, "Unknown pet command %s.", sep->arg[0]);
  7885. }
  7886. /*
  7887. Function: Command_PetName()
  7888. Purpose : Pet your name (???)
  7889. Params :
  7890. Dev :
  7891. Example :
  7892. */
  7893. void Commands::Command_PetName(Client* client, Seperator* sep)
  7894. {
  7895. if (sep && sep->arg[0]) {
  7896. const char* pet_name = sep->argplus[0];
  7897. client->SetPetName(pet_name);
  7898. }
  7899. else {
  7900. client->GetPlayer()->GetInfoStruct()->set_pet_name("");
  7901. }
  7902. }
  7903. /*
  7904. Function: Command_NamePet()
  7905. Purpose : Name your pet
  7906. Params :
  7907. Dev :
  7908. Example :
  7909. */
  7910. void Commands::Command_NamePet(Client* client, Seperator* sep)
  7911. {
  7912. PrintSep(sep, "COMMAND_NAME_PET");
  7913. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Name Pet Command");
  7914. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7915. }
  7916. /*
  7917. Function: Command_Rename()
  7918. Purpose : Renames existing pet
  7919. Params :
  7920. Dev :
  7921. Example :
  7922. */
  7923. void Commands::Command_Rename(Client* client, Seperator* sep)
  7924. {
  7925. PrintSep(sep, "COMMAND_RENAME");
  7926. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Rename Pet Command");
  7927. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7928. }
  7929. /*
  7930. Function: Command_ConfirmRename()
  7931. Purpose : Confirms renaming your pet
  7932. Params :
  7933. Dev :
  7934. Example :
  7935. */
  7936. void Commands::Command_ConfirmRename(Client* client, Seperator* sep)
  7937. {
  7938. PrintSep(sep, "COMMAND_CONFIRMRENAME");
  7939. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Confirm Rename Pet Command");
  7940. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7941. }
  7942. /*
  7943. Function: Command_PetOptions()
  7944. Purpose : Sets various pet options
  7945. Params :
  7946. Dev :
  7947. Example :
  7948. */
  7949. void Commands::Command_PetOptions(Client* client, Seperator* sep)
  7950. {
  7951. PrintSep(sep, "COMMAND_PETOPTIONS");
  7952. Player* player = client->GetPlayer();
  7953. Spawn* target = player->GetTarget();
  7954. if (!target)
  7955. return;
  7956. if (target == player->GetPet())
  7957. client->SendPetOptionsWindow(player->GetPet()->GetName());
  7958. else if (target == player->GetCharmedPet())
  7959. client->SendPetOptionsWindow(player->GetCharmedPet()->GetName());
  7960. else if (target == player->GetCosmeticPet())
  7961. client->SendPetOptionsWindow(player->GetCosmeticPet()->GetName(), 0);
  7962. else if (target == player->GetDeityPet())
  7963. client->SendPetOptionsWindow(player->GetDeityPet()->GetName(), 0);
  7964. }
  7965. /*
  7966. Function: Command_Random()
  7967. Purpose : Handles /random dice roll in-game
  7968. Params : 1-100
  7969. Dev : Scatman
  7970. Example : /randon 1 100
  7971. */
  7972. void Commands::Command_Random(Client* client, Seperator* sep)
  7973. {
  7974. char message[256] = {0};
  7975. if (sep)
  7976. {
  7977. if (sep->GetArgNumber() == 0 && sep->IsNumber(0))
  7978. 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])));
  7979. else if (sep->GetArgNumber() > 0 && sep->IsNumber(0) && sep->IsNumber(1))
  7980. 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])));
  7981. else
  7982. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  7983. }
  7984. else
  7985. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  7986. client->GetPlayer()->GetZone()->HandleChatMessage(0, 0, CHANNEL_EMOTE, message);
  7987. }
  7988. /*
  7989. Function: Command_Randomize()
  7990. Purpose : Sets randomize (appearance) values for NPCs
  7991. Params : Attrib Name
  7992. Dev : Scatman
  7993. Example : /randomize gender 1 -- will randomize the NPCs gender (male/female)
  7994. */
  7995. void Commands::Command_Randomize(Client* client, Seperator* sep)
  7996. {
  7997. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  7998. if (target)
  7999. {
  8000. if (target->IsNPC())
  8001. {
  8002. if (sep && sep->arg[0] && !sep->IsNumber(0))
  8003. {
  8004. const char* value = sep->arg[0];
  8005. if (strncasecmp(value, "show", strlen(value)) == 0)
  8006. {
  8007. client->DisplayRandomizeFeatures(target->GetRandomize());
  8008. }
  8009. else
  8010. {
  8011. if (sep->arg[1] && sep->IsNumber(1))
  8012. {
  8013. int8 option = atoi(sep->arg[1]);
  8014. if (option == 0 || option == 1)
  8015. {
  8016. int32 feature = 0;
  8017. char feature_text[32] = {0};
  8018. if (strncasecmp(value, "gender", strlen(value)) == 0) {
  8019. feature = RANDOMIZE_GENDER;
  8020. strncpy(feature_text, "gender", sizeof(feature_text) - 1);
  8021. }
  8022. else if (strncasecmp(value, "race", strlen(value)) == 0) {
  8023. feature = RANDOMIZE_RACE;
  8024. strncpy(feature_text, "race", sizeof(feature_text) - 1);
  8025. }
  8026. else if (strncasecmp(value, "model", strlen(value)) == 0) {
  8027. feature = RANDOMIZE_MODEL_TYPE;
  8028. strncpy(feature_text, "model", sizeof(feature_text) - 1);
  8029. }
  8030. else if (strncasecmp(value, "facial_hair", strlen(value)) == 0) {
  8031. feature = RANDOMIZE_FACIAL_HAIR_TYPE;
  8032. strncpy(feature_text, "facial hair", sizeof(feature_text) - 1);
  8033. }
  8034. else if (strncasecmp(value, "hair", strlen(value)) == 0) {
  8035. feature = RANDOMIZE_HAIR_TYPE;
  8036. strncpy(feature_text, "hair", sizeof(feature_text) - 1);
  8037. }
  8038. else if (strncasecmp(value, "wing", strlen(value)) == 0) {
  8039. feature = RANDOMIZE_WING_TYPE;
  8040. strncpy(feature_text, "wings", sizeof(feature_text) - 1);
  8041. }
  8042. else if (strncasecmp(value, "cheek", strlen(value)) == 0) {
  8043. feature = RANDOMIZE_CHEEK_TYPE;
  8044. strncpy(feature_text, "cheeks", sizeof(feature_text) - 1);
  8045. }
  8046. else if (strncasecmp(value, "chin", strlen(value)) == 0) {
  8047. feature = RANDOMIZE_CHIN_TYPE;
  8048. strncpy(feature_text, "chin", sizeof(feature_text) - 1);
  8049. }
  8050. else if (strncasecmp(value, "ear", strlen(value)) == 0) {
  8051. feature = RANDOMIZE_EAR_TYPE;
  8052. strncpy(feature_text, "ears", sizeof(feature_text) - 1);
  8053. }
  8054. else if (strncasecmp(value, "eye_brow", strlen(value)) == 0) {
  8055. feature = RANDOMIZE_EYE_BROW_TYPE;
  8056. strncpy(feature_text, "eye brows", sizeof(feature_text) - 1);
  8057. }
  8058. else if (strncasecmp(value, "eye", strlen(value)) == 0) {
  8059. feature = RANDOMIZE_EYE_TYPE;
  8060. strncpy(feature_text, "eyes", sizeof(feature_text) - 1);
  8061. }
  8062. else if (strncasecmp(value, "lip", strlen(value)) == 0) {
  8063. feature = RANDOMIZE_LIP_TYPE;
  8064. strncpy(feature_text, "lips", sizeof(feature_text) - 1);
  8065. }
  8066. else if (strncasecmp(value, "nose", strlen(value)) == 0) {
  8067. feature = RANDOMIZE_NOSE_TYPE;
  8068. strncpy(feature_text, "nose", sizeof(feature_text) - 1);
  8069. }
  8070. else if (strncasecmp(value, "eye_color", strlen(value)) == 0) {
  8071. feature = RANDOMIZE_EYE_COLOR;
  8072. strncpy(feature_text, "eye color", sizeof(feature_text) - 1);
  8073. }
  8074. else if (strncasecmp(value, "hair_color", strlen(value)) == 0) {
  8075. feature = RANDOMIZE_HAIR_TYPE_COLOR;
  8076. strncpy(feature_text, "hair color", sizeof(feature_text) - 1);
  8077. }
  8078. else if (strncasecmp(value, "hair_color1", strlen(value)) == 0) {
  8079. feature = RANDOMIZE_HAIR_COLOR1;
  8080. strncpy(feature_text, "hair color1", sizeof(feature_text) - 1);
  8081. }
  8082. else if (strncasecmp(value, "hair_color2", strlen(value)) == 0) {
  8083. feature = RANDOMIZE_HAIR_COLOR2;
  8084. strncpy(feature_text, "hair color2", sizeof(feature_text) - 1);
  8085. }
  8086. else if (strncasecmp(value, "hair_highlight", strlen(value)) == 0) {
  8087. feature = RANDOMIZE_HAIR_HIGHLIGHT;
  8088. strncpy(feature_text, "hair highlights", sizeof(feature_text) - 1);
  8089. }
  8090. else if (strncasecmp(value, "facial_hair_color", strlen(value)) == 0) {
  8091. feature = RANDOMIZE_HAIR_FACE_COLOR;
  8092. strncpy(feature_text, "facial hair color", sizeof(feature_text) - 1);
  8093. }
  8094. else if (strncasecmp(value, "facial_hair_color_highlight", strlen(value)) == 0) {
  8095. feature = RANDOMIZE_HAIR_FACE_HIGHLIGHT_COLOR;
  8096. strncpy(feature_text, "facial hair color highlights", sizeof(feature_text) - 1);
  8097. }
  8098. else if (strncasecmp(value, "hair_color_highlight", strlen(value)) == 0) {
  8099. feature = RANDOMIZE_HAIR_TYPE_HIGHLIGHT_COLOR;
  8100. strncpy(feature_text, "hair color highlights", sizeof(feature_text) - 1);
  8101. }
  8102. else if (strncasecmp(value, "skin_color", strlen(value)) == 0) {
  8103. feature = RANDOMIZE_SKIN_COLOR;
  8104. strncpy(feature_text, "skin color", sizeof(feature_text) - 1);
  8105. }
  8106. else if (strncasecmp(value, "wing_color1", strlen(value)) == 0) {
  8107. feature = RANDOMIZE_WING_COLOR1;
  8108. strncpy(feature_text, "wing color1", sizeof(feature_text) - 1);
  8109. }
  8110. else if (strncasecmp(value, "wing_color2", strlen(value)) == 0) {
  8111. feature = RANDOMIZE_WING_COLOR2;
  8112. strncpy(feature_text, "wing color2", sizeof(feature_text) - 1);
  8113. }
  8114. else {
  8115. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is not a valid feature to randomize.", value);
  8116. 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'.");
  8117. }
  8118. if (feature > 0) {
  8119. if (option == 1) {
  8120. if (target->GetRandomize() & feature)
  8121. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is already set to randomly generate their %s.", target->GetName(), feature_text);
  8122. else {
  8123. target->AddRandomize(feature);
  8124. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(feature);
  8125. database.UpdateRandomize(target->GetDatabaseID(), feature);
  8126. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will now generate their %s randomly.", target->GetName(), feature_text);
  8127. }
  8128. }
  8129. else {
  8130. if (target->GetRandomize() & feature) {
  8131. target->AddRandomize(-feature);
  8132. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(-feature);
  8133. database.UpdateRandomize(target->GetDatabaseID(), -feature);
  8134. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will no longer generate their %s randomly.", target->GetName(), feature_text);
  8135. }
  8136. else
  8137. client->Message(CHANNEL_COLOR_YELLOW, "'%s' already does not randomly generate their %s.", target->GetName(), feature_text);
  8138. }
  8139. }
  8140. }
  8141. else
  8142. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  8143. }
  8144. else
  8145. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  8146. }
  8147. }
  8148. else {
  8149. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /randomize [show | [feature [1|0]]");
  8150. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "'show' will display current configured features");
  8151. 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'.");
  8152. }
  8153. }
  8154. else
  8155. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "The target you wish to randomize must be an NPC.");
  8156. }
  8157. else
  8158. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select the target you wish to randomize.");
  8159. }
  8160. /*
  8161. Function: Command_ShowCloak()
  8162. Purpose : Character Settings combo box for Show Cloak
  8163. Params : true/false
  8164. Dev : John Adams
  8165. Example :
  8166. */
  8167. void Commands::Command_ShowCloak(Client* client, Seperator* sep)
  8168. {
  8169. Player* player = client->GetPlayer();
  8170. if (sep && sep->arg[0])
  8171. {
  8172. const char* value = sep->arg[0];
  8173. if (strncasecmp(value, "true", strlen(value)) == 0)
  8174. {
  8175. player->set_character_flag(CF_SHOW_CLOAK);
  8176. player->reset_character_flag(CF2_SHOW_RANGED);
  8177. }
  8178. else if (strncasecmp(value, "false", strlen(value)) == 0)
  8179. player->reset_character_flag(CF_SHOW_CLOAK);
  8180. else
  8181. {
  8182. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8183. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8184. }
  8185. }
  8186. }
  8187. /*
  8188. Function: Command_ShowHelm()
  8189. Purpose : Character Settings combo box for Show Helm
  8190. Params : true/false
  8191. Dev : John Adams
  8192. Example :
  8193. */
  8194. void Commands::Command_ShowHelm(Client* client, Seperator* sep)
  8195. {
  8196. Player* player = client->GetPlayer();
  8197. if(client->GetVersion() <= 561) {
  8198. return; // not allowed/supported
  8199. }
  8200. if (sep && sep->arg[0])
  8201. {
  8202. PrintSep(sep, "Command_ShowHelm");
  8203. const char* value = sep->arg[0];
  8204. if (strncasecmp(value, "true", strlen(value)) == 0)
  8205. {
  8206. player->toggle_character_flag(CF_HIDE_HELM);
  8207. player->toggle_character_flag(CF_HIDE_HOOD);
  8208. }
  8209. else if (strncasecmp(value, "false", strlen(value)) == 0)
  8210. player->toggle_character_flag(CF_HIDE_HELM);
  8211. else
  8212. {
  8213. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8214. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8215. }
  8216. }
  8217. }
  8218. /*
  8219. Function: Command_ShowHood()
  8220. Purpose : Character Settings combo box for Show Hood
  8221. Params : true/false
  8222. Dev : John Adams
  8223. Example :
  8224. */
  8225. void Commands::Command_ShowHood(Client* client, Seperator* sep)
  8226. {
  8227. Player* player = client->GetPlayer();
  8228. if (sep && sep->arg[0])
  8229. {
  8230. PrintSep(sep, "Command_ShowHood");
  8231. const char* value = sep->arg[0];
  8232. if (strncasecmp(value, "true", strlen(value)) == 0)
  8233. {
  8234. player->toggle_character_flag(CF_HIDE_HOOD);
  8235. if(client->GetVersion() > 561) { // no hide helm support in DoF
  8236. player->toggle_character_flag(CF_HIDE_HELM);
  8237. }
  8238. }
  8239. else if (strncasecmp(value, "false", strlen(value)) == 0) {
  8240. player->toggle_character_flag(CF_HIDE_HOOD);
  8241. }
  8242. else
  8243. {
  8244. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8245. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8246. }
  8247. }
  8248. }
  8249. /*
  8250. Function: Command_ShowHoodHelm()
  8251. Purpose : Character Settings combo box for Show Helm or Hood
  8252. Params : true/false
  8253. Dev : John Adams
  8254. Example :
  8255. */
  8256. void Commands::Command_ShowHoodHelm(Client* client, Seperator* sep)
  8257. {
  8258. Player* player = client->GetPlayer();
  8259. if(client->GetVersion() <= 561) {
  8260. return; // not allowed/supported
  8261. }
  8262. if (sep && sep->arg[0])
  8263. {
  8264. PrintSep(sep, "Command_ShowHoodHelm");
  8265. const char* value = sep->arg[0];
  8266. if (strncasecmp(value, "true", strlen(value)) == 0)
  8267. {
  8268. player->toggle_character_flag(CF_HIDE_HOOD);
  8269. player->toggle_character_flag(CF_HIDE_HELM);
  8270. }
  8271. else if (strncasecmp(value, "false", strlen(value)) == 0)
  8272. {
  8273. // don't think we ever wind up in here...
  8274. player->toggle_character_flag(CF_HIDE_HOOD);
  8275. player->toggle_character_flag(CF_HIDE_HELM);
  8276. }
  8277. else
  8278. {
  8279. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8280. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8281. }
  8282. }
  8283. }
  8284. /*
  8285. Function: Command_ShowRanged()
  8286. Purpose : Character Settings combo box for Show Ranged weapon
  8287. Params : true/false
  8288. Dev : John Adams
  8289. Example :
  8290. */
  8291. void Commands::Command_ShowRanged(Client* client, Seperator* sep)
  8292. {
  8293. Player* player = client->GetPlayer();
  8294. if (sep && sep->arg[0])
  8295. {
  8296. const char* value = sep->arg[0];
  8297. if (strncasecmp(value, "true", strlen(value)) == 0)
  8298. {
  8299. player->set_character_flag(CF2_SHOW_RANGED);
  8300. player->reset_character_flag(CF_SHOW_CLOAK);
  8301. }
  8302. else if (strncasecmp(value, "false", strlen(value)) == 0)
  8303. player->reset_character_flag(CF2_SHOW_RANGED);
  8304. else
  8305. {
  8306. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8307. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8308. }
  8309. }
  8310. }
  8311. /*
  8312. Function:
  8313. Purpose :
  8314. Params :
  8315. Dev :
  8316. Example :
  8317. */
  8318. void Commands::Command_Skills(Client* client, Seperator* sep, int handler)
  8319. {
  8320. Player* player = 0;
  8321. Client* to_client = 0;
  8322. if(client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  8323. to_client = ((Player*)client->GetPlayer()->GetTarget())->GetClient();
  8324. switch(handler)
  8325. {
  8326. case COMMAND_SKILL:
  8327. {
  8328. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill [add|remove|list] [skill name]");
  8329. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to add/remove skills for that player.");
  8330. break;
  8331. }
  8332. case COMMAND_SKILL_ADD:
  8333. {
  8334. if (sep && sep->arg[0])
  8335. {
  8336. const char* skill_name = sep->argplus[0];
  8337. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  8338. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // add skill to your target, if target is not you
  8339. {
  8340. player = to_client->GetPlayer();
  8341. if (player)
  8342. {
  8343. if (!player->GetSkills()->HasSkill(skill->skill_id))
  8344. {
  8345. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  8346. client->Message(CHANNEL_COLOR_YELLOW, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  8347. to_client->Message(CHANNEL_COLOR_YELLOW, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  8348. }
  8349. else
  8350. client->Message(CHANNEL_COLOR_YELLOW, "%s already has the skill '%s'.", player->GetName(), skill_name);
  8351. }
  8352. }
  8353. else if (skill) // add skill to yourself
  8354. {
  8355. player = client->GetPlayer();
  8356. if (player)
  8357. {
  8358. if (!player->GetSkills()->HasSkill(skill->skill_id))
  8359. {
  8360. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  8361. client->Message(CHANNEL_COLOR_YELLOW, "Added skill '%s'.", skill_name);
  8362. }
  8363. else
  8364. client->Message(CHANNEL_COLOR_YELLOW, "You already have the skill '%s'.", skill_name);
  8365. }
  8366. }
  8367. else
  8368. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  8369. }
  8370. else
  8371. {
  8372. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill add [skill name]");
  8373. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  8374. }
  8375. break;
  8376. }
  8377. case COMMAND_SKILL_REMOVE:
  8378. {
  8379. if (sep && sep->arg[0])
  8380. {
  8381. const char* skill_name = sep->argplus[0];
  8382. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  8383. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // remove skill from your target, if target is not you
  8384. {
  8385. player = to_client->GetPlayer();
  8386. if (player)
  8387. {
  8388. if (player->GetSkills()->HasSkill(skill->skill_id))
  8389. {
  8390. player->RemoveSkillFromDB(skill, true);
  8391. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  8392. to_client->Message(CHANNEL_COLOR_YELLOW, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  8393. }
  8394. else
  8395. client->Message(CHANNEL_COLOR_YELLOW, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  8396. }
  8397. }
  8398. else if(skill) // remove skill from yourself
  8399. {
  8400. Player* player = client->GetPlayer();
  8401. if (player)
  8402. {
  8403. if (player->GetSkills()->HasSkill(skill->skill_id))
  8404. {
  8405. player->RemoveSkillFromDB(skill, true);
  8406. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s'.", skill_name);
  8407. }
  8408. else
  8409. client->Message(CHANNEL_COLOR_YELLOW, "You do not have the skill '%s'.", skill_name);
  8410. }
  8411. }
  8412. else
  8413. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  8414. }
  8415. else
  8416. {
  8417. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill remove [skill name]");
  8418. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  8419. }
  8420. break;
  8421. }
  8422. case COMMAND_SKILL_LIST:
  8423. {
  8424. if (sep && sep->arg[0])
  8425. {
  8426. const char* skill_name = sep->argplus[0];
  8427. client->Message(CHANNEL_COLOR_YELLOW, "Listing skills like '%s':", skill_name);
  8428. map<int32, Skill*>* skills = master_skill_list.GetAllSkills();
  8429. map<int32, Skill*>::iterator itr;
  8430. if (skills && skills->size() > 0)
  8431. {
  8432. for (itr = skills->begin(); itr != skills->end(); itr++)
  8433. {
  8434. Skill* skill = itr->second;
  8435. string current_skill_name = ::ToLower(string(skill->name.data.c_str()));
  8436. if (current_skill_name.find(::ToLower(string(skill_name))) < 0xFFFFFFFF)
  8437. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", skill->name.data.c_str(), skill->skill_id);
  8438. }
  8439. }
  8440. }
  8441. else
  8442. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill list [skill name]");
  8443. break;
  8444. }
  8445. }
  8446. }
  8447. /*
  8448. Function: Command_SpawnTemplate()
  8449. Purpose : Create or Use defined Spawn Templates
  8450. Params : create, save, rempve, list
  8451. Dev : John Adams
  8452. Example : /spawn template create "Test"
  8453. */
  8454. void Commands::Command_SpawnTemplate(Client* client, Seperator* sep)
  8455. {
  8456. if (sep == NULL || sep->arg[0] == NULL)
  8457. {
  8458. 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.");
  8459. return;
  8460. }
  8461. // got params, continue
  8462. const char * template_cmd = sep->arg[0];
  8463. if (strncasecmp(template_cmd, "list", strlen(template_cmd)) == 0)
  8464. {
  8465. if (!sep->IsSet(1))
  8466. {
  8467. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /spawn template list [name|location_id]");
  8468. 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.");
  8469. return;
  8470. }
  8471. map<int32, string>* template_names = 0;
  8472. if (sep->IsNumber(1))
  8473. {
  8474. int32 location_id = 0;
  8475. location_id = atoi(sep->arg[1]);
  8476. template_names = database.GetSpawnTemplateListByID(location_id);
  8477. }
  8478. else
  8479. {
  8480. const char* name = 0;
  8481. name = sep->argplus[1];
  8482. template_names = database.GetSpawnTemplateListByName(name);
  8483. }
  8484. if(!template_names)
  8485. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No templates found.");
  8486. else
  8487. {
  8488. map<int32, string>::iterator itr;
  8489. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  8490. for(itr = template_names->begin(); itr != template_names->end(); itr++)
  8491. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  8492. safe_delete(template_names);
  8493. }
  8494. }
  8495. else if (strncasecmp(template_cmd, "save", strlen(template_cmd)) == 0)
  8496. {
  8497. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  8498. if ( target && (target->IsNPC() || target->IsObject() || target->IsSign() || target->IsWidget() || target->IsGroundSpawn()) )
  8499. {
  8500. if (sep && sep->arg[1][0] && !sep->IsNumber(1))
  8501. {
  8502. // first, lookup to see if template name already exists
  8503. const char* name = 0;
  8504. name = sep->argplus[1];
  8505. map<int32, string>* template_names = database.GetSpawnTemplateListByName(name);
  8506. if(!template_names)
  8507. {
  8508. int32 new_template_id = database.SaveSpawnTemplate(target->GetSpawnLocationID(), name);
  8509. if( new_template_id > 0 )
  8510. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template '%s' added for spawn '%s' (%u) as TemplateID: %u", name, target->GetName(), target->GetSpawnLocationID(), new_template_id);
  8511. else
  8512. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' for spawn '%s' (%u).", name, target->GetName(), target->GetSpawnLocationID());
  8513. }
  8514. else
  8515. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' - Already exists!", name);
  8516. }
  8517. else
  8518. client->Message(CHANNEL_COLOR_RED, "ERROR: Saving a new spawn template requires a valid template name!");
  8519. }
  8520. else
  8521. client->Message(CHANNEL_COLOR_RED, "ERROR: You must target the spawn you wish to save as a template!");
  8522. }
  8523. else if (strncasecmp(template_cmd, "remove", strlen(template_cmd)) == 0)
  8524. {
  8525. if (sep && sep->arg[1][0] && sep->IsNumber(1))
  8526. {
  8527. int32 template_id = 0;
  8528. template_id = atoi(sep->arg[1]);
  8529. if (database.RemoveSpawnTemplate(template_id))
  8530. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template ID: %u successfully removed.", template_id);
  8531. else
  8532. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to remove spawn template ID: %u", template_id);
  8533. }
  8534. else
  8535. client->Message(CHANNEL_COLOR_RED, "ERROR: Removing a spawn template requires a valid template ID!");
  8536. }
  8537. // Renamed create to spawn
  8538. else if (strncasecmp(template_cmd, "spawn", strlen(template_cmd)) == 0)
  8539. {
  8540. if (sep && sep->arg[1][0])
  8541. {
  8542. int32 new_location = 0;
  8543. if (sep->IsNumber(1))
  8544. {
  8545. int32 template_id = 0;
  8546. template_id = atoi(sep->arg[1]);
  8547. new_location = database.CreateSpawnFromTemplateByID(client, template_id);
  8548. if( new_location > 0 )
  8549. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template ID: %u", new_location, template_id);
  8550. else
  8551. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template ID: %u", template_id);
  8552. }
  8553. else
  8554. {
  8555. const char* name = 0;
  8556. name = sep->argplus[1];
  8557. new_location = database.CreateSpawnFromTemplateByName(client, name);
  8558. if( new_location > 0 )
  8559. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template: '%s'", new_location, name);
  8560. else
  8561. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template: '%s'", name);
  8562. }
  8563. }
  8564. else
  8565. client->Message(CHANNEL_COLOR_RED, "ERROR: Spawning a new spawn location requires a valid template name or ID!");
  8566. }
  8567. else
  8568. client->Message(CHANNEL_COLOR_RED, "ERROR: Unknown /spawn template command.");
  8569. }
  8570. void Commands::Command_Speed(Client* client, Seperator* sep) {
  8571. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  8572. float new_speed = atof(sep->arg[0]);
  8573. if (new_speed > 0.0f)
  8574. {
  8575. client->GetPlayer()->SetSpeed(new_speed, true);
  8576. client->GetPlayer()->SetCharSheetChanged(true);
  8577. database.insertCharacterProperty(client, CHAR_PROPERTY_SPEED, sep->arg[0]);
  8578. client->Message(CHANNEL_STATUS, "Setting speed to %.2f.", new_speed);
  8579. }
  8580. else
  8581. client->Message(CHANNEL_STATUS, "Invalid speed provided %s.", sep->arg[0]);
  8582. }
  8583. else{
  8584. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /speed {new speed value}");
  8585. }
  8586. }
  8587. /*
  8588. Function: Command_StationMarketPlace()
  8589. Purpose : just trying to eat the console spam for now
  8590. Params :
  8591. Dev : John
  8592. */
  8593. void Commands::Command_StationMarketPlace(Client* client, Seperator* sep)
  8594. {
  8595. PrintSep(sep, "COMMAND_SMP");
  8596. // This will reduce the spam from once every 10 sec to once every 30 sec,
  8597. // can't seem to reduce it any more get rid of it completely...
  8598. if (sep && strcmp(sep->arg[0], "gkw") == 0) {
  8599. PacketStruct* packet = configReader.getStruct("WS_MarketFundsUpdate", client->GetVersion());
  8600. if (packet) {
  8601. packet->setDataByName("account_id", client->GetAccountID());
  8602. packet->setDataByName("character_id", client->GetCharacterID());
  8603. packet->setDataByName("unknown1", 1, 5);
  8604. packet->setDataByName("unknown1", 26, 6);
  8605. packet->setDataByName("unknown2", 0xFFFFFFFF);
  8606. packet->setDataByName("unknown3", 248, 1);
  8607. client->QueuePacket(packet->serialize());
  8608. }
  8609. safe_delete(packet);
  8610. }
  8611. }
  8612. /*
  8613. Function: Command_StopDrinking()
  8614. Purpose : Stops player from auto-consuming drink
  8615. Params :
  8616. Dev : Zcoretri
  8617. Example : /stopdrinking
  8618. */
  8619. void Commands::Command_StopDrinking(Client* client)
  8620. {
  8621. client->GetPlayer()->reset_character_flag(CF_DRINK_AUTO_CONSUME);
  8622. client->GetPlayer()->SetActiveDrinkUniqueID(0);
  8623. client->Message(CHANNEL_COLOR_YELLOW,"You stop drinking your current drink.");
  8624. }
  8625. /*
  8626. Function: Command_StopEating()
  8627. Purpose : Stops player from auto-consuming food
  8628. Params :
  8629. Dev : Zcoretri
  8630. Example : /stopeating
  8631. */
  8632. void Commands::Command_StopEating(Client* client)
  8633. {
  8634. client->GetPlayer()->reset_character_flag(CF_FOOD_AUTO_CONSUME);
  8635. client->GetPlayer()->SetActiveFoodUniqueID(0);
  8636. client->Message(CHANNEL_COLOR_YELLOW,"You stop eating your current food.");
  8637. }
  8638. /*
  8639. Function: Command_Title()
  8640. Purpose : Help for /title command
  8641. Params : n/a
  8642. Dev : Zcoretri
  8643. Example : /title
  8644. */
  8645. void Commands::Command_Title(Client* client)
  8646. {
  8647. client->Message(CHANNEL_COLOR_YELLOW, "Available subcommands: list, setprefix <index>, setsuffix <index>, fix");
  8648. }
  8649. /*
  8650. Function: Command_TitleList()
  8651. Purpose : List available titles for player
  8652. Params : n/a
  8653. Dev : Zcoretri
  8654. Example : /title list
  8655. */
  8656. void Commands::Command_TitleList(Client* client)
  8657. {
  8658. // must call release read lock before leaving function on GetPlayerTitles
  8659. vector<Title*>* titles = client->GetPlayer()->GetPlayerTitles()->GetAllTitles();
  8660. vector<Title*>::iterator itr;
  8661. Title* title;
  8662. sint32 i = 0;
  8663. client->Message(CHANNEL_NARRATIVE, "Listing available titles:");
  8664. for(itr = titles->begin(); itr != titles->end(); itr++)
  8665. {
  8666. title = *itr;
  8667. client->Message(CHANNEL_NARRATIVE, "%i: type=[%s] title=[%s]", i, title->GetPrefix() ? "Prefix":"Suffix", title->GetName());
  8668. i++;
  8669. }
  8670. client->GetPlayer()->GetPlayerTitles()->ReleaseReadLock();
  8671. }
  8672. /*
  8673. Function: Command_TitleSetPrefix()
  8674. Purpose : Set Prefix title for player
  8675. Params : Title ID
  8676. Dev : Zcoretri
  8677. Example : /title setprefix 1
  8678. */
  8679. void Commands::Command_TitleSetPrefix(Client* client, Seperator* sep)
  8680. {
  8681. if (sep && sep->arg[0] && sep->IsNumber(0))
  8682. {
  8683. sint32 index = atoul(sep->arg[0]);
  8684. if(index > -1)
  8685. {
  8686. Title* title = client->GetPlayer()->GetPlayerTitles()->GetTitle(index);
  8687. if(!title)
  8688. {
  8689. client->Message(CHANNEL_COLOR_RED, "Missing index %i to set title", index);
  8690. return;
  8691. }
  8692. else if(!title->GetPrefix())
  8693. {
  8694. client->Message(CHANNEL_COLOR_RED, "%s is not a prefix.", title->GetName());
  8695. return;
  8696. }
  8697. }
  8698. else // make sure client doesn't pass some bogus negative index
  8699. index = -1;
  8700. database.SaveCharPrefixIndex(index, client->GetCharacterID());
  8701. client->SendTitleUpdate();
  8702. }
  8703. }
  8704. /*
  8705. Function: Command_TitleSetSuffix()
  8706. Purpose : Set Suffix title for player
  8707. Params : Title ID
  8708. Dev : Zcoretri
  8709. Example : /title setsuffix 1
  8710. */
  8711. void Commands::Command_TitleSetSuffix(Client* client, Seperator* sep)
  8712. {
  8713. if (sep && sep->arg[0] && sep->IsNumber(0))
  8714. {
  8715. sint32 index = atoul(sep->arg[0]);
  8716. if(index > -1)
  8717. {
  8718. Title* title = client->GetPlayer()->GetPlayerTitles()->GetTitle(index);
  8719. if(!title)
  8720. {
  8721. client->Message(CHANNEL_COLOR_RED, "Missing index %i to set title", index);
  8722. return;
  8723. }
  8724. else if(title->GetPrefix())
  8725. {
  8726. client->Message(CHANNEL_COLOR_RED, "%s is not a suffix.", title->GetName());
  8727. return;
  8728. }
  8729. }
  8730. else // make sure client doesn't pass some bogus negative index
  8731. index = -1;
  8732. database.SaveCharSuffixIndex(index, client->GetCharacterID());
  8733. client->SendTitleUpdate();
  8734. }
  8735. }
  8736. /*
  8737. Function: Command_TitleFix()
  8738. Purpose : Fix title for player (???)
  8739. Params :
  8740. Dev : Zcoretri
  8741. Example :
  8742. */
  8743. void Commands::Command_TitleFix(Client* client, Seperator* sep)
  8744. {
  8745. PrintSep(sep, "COMMAND_TITLE_FIX");
  8746. LogWrite(MISC__TODO, 1, "Titles", "TODO-Command: TITLE_FIX");
  8747. }
  8748. /*
  8749. Function: Command_Toggle_Anonymous()
  8750. Purpose : Toggles player Anonymous
  8751. Params :
  8752. Dev : paulgh
  8753. Example : /anon
  8754. */
  8755. void Commands::Command_Toggle_Anonymous(Client* client)
  8756. {
  8757. Player* player = client->GetPlayer();
  8758. player->toggle_character_flag(CF_ANONYMOUS);
  8759. client->Message(CHANNEL_COLOR_YELLOW,"You are %s anonymous.", player->get_character_flag(CF_ANONYMOUS)?"now":"no longer");
  8760. if (player->get_character_flag(CF_ANONYMOUS))
  8761. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ANONYMOUS);
  8762. else
  8763. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ANONYMOUS);
  8764. }
  8765. /*
  8766. Function: Command_Toggle_AutoConsume()
  8767. Purpose : Toggles player food/drink auto consume
  8768. Params : unknown
  8769. Dev : paulgh
  8770. Example : /set_auto_consume
  8771. */
  8772. void Commands::Command_Toggle_AutoConsume(Client* client, Seperator* sep)
  8773. {
  8774. Player* player = client->GetPlayer();
  8775. if (sep && sep->arg[0])
  8776. PrintSep(sep, "COMMAND_SET_AUTO_CONSUME");
  8777. if (sep && sep->arg[0] && sep->IsNumber(0))
  8778. {
  8779. int8 slot = atoi(sep->arg[0]);
  8780. int8 flag = atoi(sep->arg[1]);
  8781. if (client->GetVersion() <= 373) {
  8782. slot += 4;
  8783. }
  8784. else if (client->GetVersion() <= 561) {
  8785. slot += 2;
  8786. }
  8787. if (slot == EQ2_FOOD_SLOT)
  8788. {
  8789. player->toggle_character_flag(CF_FOOD_AUTO_CONSUME);
  8790. player->SetCharSheetChanged(true);
  8791. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  8792. if (flag == 1)
  8793. client->Message(CHANNEL_NARRATIVE, "You decide to eat immediately whenever you become hungry.");
  8794. else
  8795. {
  8796. client->Message(CHANNEL_NARRATIVE, "You decide to ignore the hunger.");
  8797. return;
  8798. }
  8799. }
  8800. else
  8801. {
  8802. player->toggle_character_flag(CF_DRINK_AUTO_CONSUME);
  8803. player->SetCharSheetChanged(true);
  8804. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  8805. if (flag == 1)
  8806. client->Message(CHANNEL_NARRATIVE, "You decide to drink immediately whenever you become thirsty.");
  8807. else
  8808. {
  8809. client->Message(CHANNEL_NARRATIVE, "You decide to ignore the thirst.");
  8810. return;
  8811. }
  8812. }
  8813. if(!client->CheckConsumptionAllowed(slot, false))
  8814. return;
  8815. Item* item = player->GetEquipmentList()->GetItem(slot);
  8816. if(item)
  8817. client->ConsumeFoodDrink(item, slot);
  8818. }
  8819. }
  8820. /*
  8821. Function: Command_Toggle_BonusXP()
  8822. Purpose : Toggles player Bonus XP
  8823. Params :
  8824. Dev : John Adams
  8825. Example : /disable_char_bonus_exp
  8826. */
  8827. void Commands::Command_Toggle_BonusXP(Client* client)
  8828. {
  8829. Player* player = client->GetPlayer();
  8830. player->toggle_character_flag(CF2_CHARACTER_BONUS_EXPERIENCE_ENABLED);
  8831. player->SetCharSheetChanged(true);
  8832. }
  8833. /*
  8834. Function: Command_Toggle_CombatXP()
  8835. Purpose : Toggles player Adventure XP
  8836. Params :
  8837. Dev : John Adams
  8838. Example : /disable_combat_exp
  8839. */
  8840. void Commands::Command_Toggle_CombatXP(Client* client)
  8841. {
  8842. Player* player = client->GetPlayer();
  8843. player->toggle_character_flag(CF_COMBAT_EXPERIENCE_ENABLED);
  8844. player->SetCharSheetChanged(true);
  8845. }
  8846. /*
  8847. Function: Command_Toggle_GMHide()
  8848. Purpose : Toggles hiding player GM status
  8849. Params :
  8850. Dev : Scatman
  8851. Example : /gm_hide
  8852. */
  8853. void Commands::Command_Toggle_GMHide(Client* client)
  8854. {
  8855. Player* player = client->GetPlayer();
  8856. player->toggle_character_flag(CF_HIDE_STATUS);
  8857. client->Message(CHANNEL_COLOR_YELLOW,"You are %s hiding your GM status.", player->get_character_flag(CF_HIDE_STATUS)?"now":"no longer");
  8858. }
  8859. /*
  8860. Function: Command_Toggle_GMVanish()
  8861. Purpose : Toggles hiding GM players from /who searches
  8862. Params :
  8863. Dev : Scatman
  8864. Example : /gm_vanish
  8865. */
  8866. void Commands::Command_Toggle_GMVanish(Client* client)
  8867. {
  8868. Player* player = client->GetPlayer();
  8869. player->toggle_character_flag(CF_GM_HIDDEN);
  8870. client->Message(CHANNEL_COLOR_YELLOW,"You are %s invisible to who queries.", player->get_character_flag(CF_GM_HIDDEN)?"now":"no longer");
  8871. }
  8872. /*
  8873. Function: Command_Toggle_Illusions()
  8874. Purpose : Toggles player illusion form
  8875. Params : not sure sep is needed, testing
  8876. Dev : paulgh
  8877. Example : /hide_illusions
  8878. */
  8879. void Commands::Command_Toggle_Illusions(Client* client, Seperator* sep)
  8880. {
  8881. if (sep && sep->arg[0])
  8882. PrintSep(sep, "COMMAND_TOGGLE_ILLUSIONS");
  8883. client->GetPlayer()->toggle_character_flag(CF_SHOW_ILLUSION);
  8884. }
  8885. /*
  8886. Function: Command_Toggle_LFG()
  8887. Purpose : Toggles player LFG Flag
  8888. Params :
  8889. Dev : paulgh
  8890. Example : /lfg
  8891. */
  8892. void Commands::Command_Toggle_LFG(Client* client)
  8893. {
  8894. Player* player = client->GetPlayer();
  8895. player->toggle_character_flag(CF_LFG);
  8896. client->Message(CHANNEL_COLOR_YELLOW,"You are %s LFG.", player->get_character_flag(CF_LFG)?"now":"no longer");
  8897. if (player->get_character_flag(CF_LFG))
  8898. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFG);
  8899. else
  8900. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFG);
  8901. }
  8902. /*
  8903. Function: Command_Toggle_LFW()
  8904. Purpose : Toggles player LFW Flag
  8905. Params :
  8906. Dev : paulgh
  8907. Example : /lfw
  8908. */
  8909. void Commands::Command_Toggle_LFW(Client* client)
  8910. {
  8911. Player* player = client->GetPlayer();
  8912. player->toggle_character_flag(CF_LFW);
  8913. client->Message(CHANNEL_COLOR_YELLOW,"You %s looking for work.", player->get_character_flag(CF_LFW)?"let others know you are":"stop");
  8914. if (player->get_character_flag(CF_LFW))
  8915. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFW);
  8916. else
  8917. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFW);
  8918. }
  8919. /*
  8920. Function: Command_Toggle_QuestXP()
  8921. Purpose : Toggles player Quest XP
  8922. Params :
  8923. Dev : John Adams
  8924. Example : /disable_quest_exp
  8925. */
  8926. void Commands::Command_Toggle_QuestXP(Client* client)
  8927. {
  8928. Player* player = client->GetPlayer();
  8929. player->toggle_character_flag(CF_QUEST_EXPERIENCE_ENABLED);
  8930. player->SetCharSheetChanged(true);
  8931. }
  8932. /*
  8933. Function: Command_Toggle_Roleplaying()
  8934. Purpose : Toggles player Roleplaying flag
  8935. Params :
  8936. Dev : paulgh
  8937. Example : /role
  8938. */
  8939. void Commands::Command_Toggle_Roleplaying(Client* client)
  8940. {
  8941. Player* player = client->GetPlayer();
  8942. player->toggle_character_flag(CF_ROLEPLAYING);
  8943. client->Message(CHANNEL_COLOR_YELLOW,"You are %s roleplaying.", player->get_character_flag(CF_ROLEPLAYING)?"now":"no longer");
  8944. if (player->get_character_flag(CF_ROLEPLAYING))
  8945. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ROLEPLAYING);
  8946. else
  8947. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ROLEPLAYING);
  8948. }
  8949. void Commands::Command_Toggle_Duels(Client* client)
  8950. {
  8951. Player* player = client->GetPlayer();
  8952. player->toggle_character_flag(CF_ALLOW_DUEL_INVITES);
  8953. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting duel invites.", player->get_character_flag(CF_ALLOW_DUEL_INVITES)?"now":"no longer");
  8954. }
  8955. void Commands::Command_Toggle_Trades(Client* client)
  8956. {
  8957. Player* player = client->GetPlayer();
  8958. player->toggle_character_flag(CF_ALLOW_TRADE_INVITES);
  8959. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting trade invites.", player->get_character_flag(CF_ALLOW_TRADE_INVITES)?"now":"no longer");
  8960. }
  8961. void Commands::Command_Toggle_Guilds(Client* client)
  8962. {
  8963. Player* player = client->GetPlayer();
  8964. player->toggle_character_flag(CF_ALLOW_GUILD_INVITES);
  8965. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting guild invites.", player->get_character_flag(CF_ALLOW_GUILD_INVITES)?"now":"no longer");
  8966. }
  8967. void Commands::Command_Toggle_Groups(Client* client)
  8968. {
  8969. Player* player = client->GetPlayer();
  8970. player->toggle_character_flag(CF_ALLOW_GROUP_INVITES);
  8971. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting group invites.", player->get_character_flag(CF_ALLOW_GROUP_INVITES)?"now":"no longer");
  8972. }
  8973. void Commands::Command_Toggle_Raids(Client* client)
  8974. {
  8975. Player* player = client->GetPlayer();
  8976. player->toggle_character_flag(CF_ALLOW_RAID_INVITES);
  8977. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting raid invites.", player->get_character_flag(CF_ALLOW_RAID_INVITES)?"now":"no longer");
  8978. }
  8979. void Commands::Command_Toggle_LON(Client* client)
  8980. {
  8981. Player* player = client->GetPlayer();
  8982. player->toggle_character_flag(CF2_ALLOW_LON_INVITES);
  8983. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting LoN invites.", player->get_character_flag(CF2_ALLOW_LON_INVITES)?"now":"no longer");
  8984. }
  8985. void Commands::Command_Toggle_VoiceChat(Client* client)
  8986. {
  8987. Player* player = client->GetPlayer();
  8988. player->toggle_character_flag(CF2_ALLOW_VOICE_INVITES);
  8989. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting voice chat invites.", player->get_character_flag(CF2_ALLOW_VOICE_INVITES)?"now":"no longer");
  8990. }
  8991. /*
  8992. Function: Command_TradeStart()
  8993. Purpose : Starts item/coin trade between players
  8994. Params :
  8995. Dev :
  8996. Example :
  8997. */
  8998. #include "../Trade.h"
  8999. void Commands::Command_TradeStart(Client* client, Seperator* sep)
  9000. {
  9001. PrintSep(sep, "COMMAND_START_TRADE");
  9002. Entity* trader = client->GetPlayer();
  9003. Entity* trader2 = 0;
  9004. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  9005. Spawn* spawn = client->GetPlayer()->GetSpawnWithPlayerID(atoi(sep->arg[0]));
  9006. if (spawn) {
  9007. if (spawn->IsEntity())
  9008. trader2 = (Entity*)spawn;
  9009. }
  9010. }
  9011. else if (client->GetPlayer()->GetTarget()) {
  9012. if (client->GetPlayer()->GetTarget()->IsEntity())
  9013. trader2 = (Entity*)client->GetPlayer()->GetTarget();
  9014. }
  9015. // can only trade with player or bots
  9016. if (trader && trader2) {
  9017. if (trader == trader2) {
  9018. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade with yourself.");
  9019. }
  9020. else if (trader2->IsPlayer() || trader2->IsBot()) {
  9021. LogWrite(PLAYER__ERROR, 0, "Trade", "creating trade");
  9022. if (trader->trade)
  9023. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are already trading.");
  9024. else if (trader2->trade)
  9025. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is already trading.");
  9026. else {
  9027. Trade* trade = new Trade(trader, trader2);
  9028. trader->trade = trade;
  9029. trader2->trade = trade;
  9030. }
  9031. }
  9032. else {
  9033. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can only trade with another player or a bot.");
  9034. }
  9035. }
  9036. else
  9037. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to find target");
  9038. }
  9039. /*
  9040. Function: Command_Track()
  9041. Purpose : Starts/Stops Tracking for a player
  9042. Params :
  9043. Dev : Scatman
  9044. Example : /track
  9045. */
  9046. void Commands::Command_Track(Client* client)
  9047. {
  9048. if (!client->GetPlayer()->GetIsTracking())
  9049. client->GetPlayer()->GetZone()->AddPlayerTracking(client->GetPlayer());
  9050. else
  9051. client->GetPlayer()->GetZone()->RemovePlayerTracking(client->GetPlayer(), TRACKING_STOP);
  9052. }
  9053. /*
  9054. Function: Command_TradeAccept()
  9055. Purpose : Accepts item/coin trade between players
  9056. Params :
  9057. Dev :
  9058. Example :
  9059. */
  9060. void Commands::Command_TradeAccept(Client* client, Seperator* sep)
  9061. {
  9062. PrintSep(sep, "COMMAND_ACCEPT_TRADE");
  9063. Trade* trade = client->GetPlayer()->trade;
  9064. if (trade) {
  9065. bool trade_complete = trade->SetTradeAccepted(client->GetPlayer());
  9066. if (trade_complete)
  9067. safe_delete(trade);
  9068. }
  9069. else
  9070. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  9071. }
  9072. /*
  9073. Function: Command_TradeReject()
  9074. Purpose : Rejects item/coin trade between players
  9075. Params :
  9076. Dev :
  9077. Example :
  9078. */
  9079. void Commands::Command_TradeReject(Client* client, Seperator* sep)
  9080. {
  9081. PrintSep(sep, "COMMAND_REJECT_TRADE");
  9082. Command_TradeCancel(client, sep);
  9083. }
  9084. /*
  9085. Function: Command_TradeCancel()
  9086. Purpose : Cancels item/coin trade between players
  9087. Params :
  9088. Dev :
  9089. Example :
  9090. */
  9091. void Commands::Command_TradeCancel(Client* client, Seperator* sep)
  9092. {
  9093. PrintSep(sep, "COMMAND_CANCEL_TRADE");
  9094. Trade* trade = client->GetPlayer()->trade;
  9095. if (trade) {
  9096. trade->CancelTrade(client->GetPlayer());
  9097. safe_delete(trade);
  9098. }
  9099. else
  9100. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  9101. }
  9102. /*
  9103. Function: Command_TradeSetCoin()
  9104. Purpose : Sets coin trade between players
  9105. Params :
  9106. Dev :
  9107. Example :
  9108. */
  9109. void Commands::Command_TradeSetCoin(Client* client, Seperator* sep)
  9110. {
  9111. PrintSep(sep, "COMMAND_SET_TRADE_COIN");
  9112. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Set Trade Coin");
  9113. client->Message(CHANNEL_COLOR_YELLOW, "You cannot trade with other players (Not Implemented)");
  9114. }
  9115. /*
  9116. Function: Command_TradeAddCoin()
  9117. Purpose : Adds coin to trade between players
  9118. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  9119. Dev :
  9120. Example :
  9121. */
  9122. void Commands::Command_TradeAddCoin(Client* client, Seperator* sep, int handler)
  9123. {
  9124. PrintSep(sep, "COMMAND_ADD_TRADE_{coin type}");
  9125. Trade* trade = client->GetPlayer()->trade;
  9126. if (trade) {
  9127. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  9128. int32 amount = atoi(sep->arg[0]);
  9129. int64 val = 0;
  9130. switch (handler) {
  9131. case COMMAND_ADD_TRADE_COPPER:
  9132. {
  9133. val = amount;
  9134. trade->AddCoinToTrade(client->GetPlayer(), val);
  9135. break;
  9136. }
  9137. case COMMAND_ADD_TRADE_SILVER:
  9138. {
  9139. val = amount * 100;
  9140. trade->AddCoinToTrade(client->GetPlayer(), val);
  9141. break;
  9142. }
  9143. case COMMAND_ADD_TRADE_GOLD:
  9144. {
  9145. val = amount * 10000;
  9146. trade->AddCoinToTrade(client->GetPlayer(), val);
  9147. break;
  9148. }
  9149. case COMMAND_ADD_TRADE_PLAT:
  9150. {
  9151. val = amount * 1000000;
  9152. trade->AddCoinToTrade(client->GetPlayer(), val);
  9153. break;
  9154. }
  9155. default:
  9156. {
  9157. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  9158. break;
  9159. }
  9160. }
  9161. }
  9162. else
  9163. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount.");
  9164. }
  9165. else
  9166. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  9167. }
  9168. /*
  9169. Function: Command_TradeRemoveCoin()
  9170. Purpose : Removes coin from trade between players
  9171. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  9172. Dev :
  9173. Example :
  9174. */
  9175. void Commands::Command_TradeRemoveCoin(Client* client, Seperator* sep, int handler)
  9176. {
  9177. PrintSep(sep, "COMMAND_REMOVE_TRADE_{coin type}");
  9178. Trade* trade = client->GetPlayer()->trade;
  9179. if (trade) {
  9180. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  9181. int32 amount = atoi(sep->arg[0]);
  9182. int64 val = 0;
  9183. switch (handler) {
  9184. case COMMAND_REMOVE_TRADE_COPPER:
  9185. {
  9186. val = amount;
  9187. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  9188. break;
  9189. }
  9190. case COMMAND_REMOVE_TRADE_SILVER:
  9191. {
  9192. val = amount * 100;
  9193. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  9194. break;
  9195. }
  9196. case COMMAND_REMOVE_TRADE_GOLD:
  9197. {
  9198. val = amount * 10000;
  9199. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  9200. break;
  9201. }
  9202. case COMMAND_REMOVE_TRADE_PLAT:
  9203. {
  9204. val = amount * 1000000;
  9205. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  9206. break;
  9207. }
  9208. default:
  9209. {
  9210. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  9211. break;
  9212. }
  9213. }
  9214. }
  9215. else
  9216. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount");
  9217. }
  9218. else
  9219. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  9220. }
  9221. /*
  9222. Function: Command_TradeAddItem()
  9223. Purpose : Adds item to trade between players
  9224. Params :
  9225. Dev :
  9226. Example :
  9227. */
  9228. void Commands::Command_TradeAddItem(Client* client, Seperator* sep)
  9229. {
  9230. PrintSep(sep, "COMMAND_ADD_TRADE_ITEM");
  9231. /*
  9232. arg[0] = item index
  9233. arg[1] = slot
  9234. arg[2] = quantity
  9235. */
  9236. if (!client->GetPlayer()->trade) {
  9237. LogWrite(PLAYER__ERROR, 0, "Trade", "Player is not currently trading.");
  9238. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  9239. return;
  9240. }
  9241. if (sep && sep->IsSet(0) && sep->IsNumber(0) && sep->IsSet(1) && sep->IsNumber(1) && sep->IsSet(2) && sep->IsNumber(2)) {
  9242. Item* item = 0;
  9243. int32 index = atoi(sep->arg[0]);
  9244. item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(index);
  9245. if (item) {
  9246. int8 result = client->GetPlayer()->trade->AddItemToTrade(client->GetPlayer(), item, atoi(sep->arg[2]), atoi(sep->arg[1]));
  9247. if (result == 1)
  9248. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Item is already being traded.");
  9249. else if (result == 2)
  9250. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade NO-TRADE items.");
  9251. else if (result == 3)
  9252. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade HEIRLOOM items.");
  9253. else if (result == 254)
  9254. client->Message(CHANNEL_COLOR_YELLOW, "You are trading with an older client with a %u trade slot restriction...", client->GetPlayer()->trade->MaxSlots());
  9255. else if (result == 255)
  9256. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown error trying to add the item to the trade...");
  9257. }
  9258. else {
  9259. LogWrite(PLAYER__ERROR, 0, "Trade", "Unable to get an item for the player (%s) from the index (%u)", client->GetPlayer()->GetName(), index);
  9260. client->Message(CHANNEL_ERROR, "Unable to find item at index %u", index);
  9261. }
  9262. }
  9263. else
  9264. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  9265. }
  9266. /*
  9267. Function: Command_TradeRemoveItem()
  9268. Purpose : Removes item from trade between players
  9269. Params :
  9270. Dev :
  9271. Example :
  9272. */
  9273. void Commands::Command_TradeRemoveItem(Client* client, Seperator* sep)
  9274. {
  9275. PrintSep(sep, "COMMAND_REMOVE_TRADE_ITEM");
  9276. /*
  9277. arg[0] = trade window slot
  9278. */
  9279. Trade* trade = client->GetPlayer()->trade;
  9280. if (trade) {
  9281. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  9282. trade->RemoveItemFromTrade(client->GetPlayer(), atoi(sep->arg[0]));
  9283. }
  9284. else
  9285. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  9286. }
  9287. else
  9288. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  9289. }
  9290. void Commands::Command_TryOn(Client* client, Seperator* sep)
  9291. {
  9292. Item *item = 0;
  9293. sint32 crc;
  9294. if (sep) {
  9295. // 1096+ sends more info so need to do a version check so older clients (SF) still work
  9296. if (client->GetVersion() < 1096) {
  9297. if (sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2))
  9298. {
  9299. item = master_item_list.GetItem(atoul(sep->arg[1]));
  9300. crc = atol(sep->arg[2]);
  9301. }
  9302. }
  9303. else {
  9304. // From the broker and links in chat
  9305. if (strcmp(sep->arg[0], "crc") == 0) {
  9306. if (sep->IsNumber(2) && sep->IsNumber(3)) {
  9307. item = master_item_list.GetItem(atoul(sep->arg[2]));
  9308. crc = atol(sep->arg[3]);
  9309. }
  9310. }
  9311. // From inventory
  9312. if (strcmp(sep->arg[0], "dbid") == 0) {
  9313. if (sep->IsNumber(2) && sep->IsNumber(4)) {
  9314. item = master_item_list.GetItem(atoul(sep->arg[2]));
  9315. crc = atol(sep->arg[4]);
  9316. }
  9317. }
  9318. }
  9319. if (item)
  9320. client->ShowDressingRoom(item, crc);
  9321. }
  9322. }
  9323. void Commands::Command_JoinChannel(Client * client, Seperator *sep) {
  9324. const char *channel_name, *password = NULL;
  9325. if (sep == NULL || !sep->IsSet(0)) {
  9326. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /joinchannel <channel name> [password]");
  9327. return;
  9328. }
  9329. channel_name = sep->arg[0];
  9330. if (sep->IsSet(1))
  9331. password = sep->arg[1];
  9332. if (!chat.ChannelExists(channel_name) && !chat.CreateChannel(channel_name, password)) {
  9333. client->Message(CHANNEL_COLOR_RED, "Unable to create channel '%s'.", channel_name);
  9334. return;
  9335. }
  9336. if (chat.IsInChannel(client, channel_name)) {
  9337. client->Message(CHANNEL_NARRATIVE, "You are already in '%s'.", channel_name);
  9338. return;
  9339. }
  9340. if (chat.HasPassword(channel_name)) {
  9341. if (password == NULL) {
  9342. client->Message(CHANNEL_NARRATIVE, "Unable to join '%s': That channel is password protected.", channel_name);
  9343. return;
  9344. }
  9345. if (!chat.PasswordMatches(channel_name, password)) {
  9346. client->Message(CHANNEL_NARRATIVE, "Unable to join '%s': The password is not correc.t", channel_name);
  9347. return;
  9348. }
  9349. }
  9350. if (!chat.JoinChannel(client, channel_name))
  9351. client->Message(CHANNEL_COLOR_RED, "There was an internal error preventing you from joining '%s'.", channel_name);
  9352. }
  9353. void Commands::Command_JoinChannelFromLoad(Client * client, Seperator *sep) {
  9354. printf("ScatDebug: Received 'joinfromchannel', using the same function as 'joinchannel' (not sure what the difference is)\n");
  9355. Command_JoinChannel(client, sep);
  9356. }
  9357. void Commands::Command_TellChannel(Client *client, Seperator *sep) {
  9358. if (sep == NULL || !sep->IsSet(0) || !sep->IsSet(1)) {
  9359. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /tellchannel <channel name> <message>");
  9360. PrintSep(sep, "tellchannel");
  9361. return;
  9362. }
  9363. chat.TellChannel(client, sep->arg[0], sep->argplus[1]);
  9364. }
  9365. void Commands::Command_Test(Client* client, EQ2_16BitString* command_parms) {
  9366. Seperator* sep = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  9367. if (sep->IsSet(0)) {
  9368. if (atoi(sep->arg[0]) == 1) {
  9369. PacketStruct* packet2 = configReader.getStruct("WS_SpellGainedMsg", client->GetVersion());
  9370. if (packet2) {
  9371. packet2->setDataByName("spell_type", 2);
  9372. packet2->setDataByName("spell_id", 8308);
  9373. packet2->setDataByName("spell_name", "Sprint");
  9374. packet2->setDataByName("add_silently", 0);
  9375. packet2->setDataByName("tier", 1);
  9376. packet2->setDataByName("blah1", 1);
  9377. packet2->setDataByName("blah2", 1);
  9378. EQ2Packet* outapp = packet2->serialize();
  9379. DumpPacket(outapp);
  9380. client->QueuePacket(outapp);
  9381. safe_delete(packet2);
  9382. }
  9383. }
  9384. else if (atoi(sep->arg[0]) == 2) {
  9385. PacketStruct* packet2 = configReader.getStruct("WS_GuildUpdate", client->GetVersion());
  9386. if (packet2) {
  9387. packet2->setDataByName("guild_name", "Test");
  9388. packet2->setDataByName("guild_motd", "Test MOTD");
  9389. packet2->setDataByName("guild_id", 1234);
  9390. packet2->setDataByName("guild_level", 1);
  9391. packet2->setDataByName("unknown", 2);
  9392. packet2->setDataByName("unknown2", 3);
  9393. packet2->setDataByName("exp_current", 1);
  9394. packet2->setDataByName("exp_to_next_level", 4);
  9395. EQ2Packet* outapp = packet2->serialize();
  9396. DumpPacket(outapp);
  9397. client->QueuePacket(outapp);
  9398. safe_delete(packet2);
  9399. }
  9400. }
  9401. else if (atoi(sep->arg[0]) == 3) {
  9402. PacketStruct* packet2 = configReader.getStruct("WS_JoinGuildNotify", client->GetVersion());
  9403. if (packet2) {
  9404. packet2->setDataByName("guild_id", 1234);
  9405. packet2->setDataByName("character_id", 1);
  9406. packet2->setDataByName("account_id", 2);
  9407. packet2->setDataByName("guild_level", 1);
  9408. packet2->setDataByName("name", "Test");
  9409. packet2->setDataByName("unknown2", 0);
  9410. packet2->setDataByName("unknown3", 1);
  9411. packet2->setDataByName("adventure_class", 6);
  9412. packet2->setDataByName("adventure_level", 7);
  9413. packet2->setDataByName("tradeskill_class", 4);
  9414. packet2->setDataByName("tradeskill_level", 5);
  9415. packet2->setDataByName("rank", 0);
  9416. packet2->setDataByName("member_flags", 2);
  9417. packet2->setDataByName("join_date", 1591112273);
  9418. packet2->setDataByName("guild_status", 2);
  9419. packet2->setDataByName("last_login", 1591132273);
  9420. packet2->setDataByName("recruiter_id", 1);
  9421. packet2->setDataByName("points", 2345);
  9422. packet2->setDataByName("note", "note");
  9423. packet2->setMediumStringByName("officer_note", "O note");
  9424. packet2->setMediumStringByName("zone", "Blah");
  9425. EQ2Packet* outapp = packet2->serialize();
  9426. DumpPacket(outapp);
  9427. client->QueuePacket(outapp);
  9428. safe_delete(packet2);
  9429. }
  9430. }
  9431. else if (atoi(sep->arg[0]) == 5) {
  9432. int16 offset = atoi(sep->arg[1]);
  9433. int32 value1 = atol(sep->arg[2]);
  9434. EQ2Packet* outapp = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion(), offset, value1);
  9435. client->QueuePacket(outapp);
  9436. }
  9437. else if (atoi(sep->arg[0]) == 6) {
  9438. Spawn* spawn = client->GetPlayer()->GetTarget();
  9439. if (!spawn)
  9440. spawn = client->GetPlayer();
  9441. else if (spawn->IsEntity())
  9442. ((Entity*)spawn)->SetSpeed(atof(sep->arg[4]));
  9443. spawn->RunToLocation(atof(sep->arg[1]), atof(sep->arg[2]), atof(sep->arg[3]));
  9444. }
  9445. else if (atoi(sep->arg[0]) == 7) {
  9446. int32 id = 0;
  9447. Spawn* spawn = client->GetCurrentZone()->GetSpawn(7720001);
  9448. if (spawn) {
  9449. spawn->SetX(client->GetPlayer()->GetX() + .5, false);
  9450. spawn->SetY(client->GetPlayer()->GetY(), false);
  9451. spawn->SetZ(client->GetPlayer()->GetZ() + .5, false);
  9452. float heading = client->GetPlayer()->GetHeading() + 180;
  9453. if (heading > 360)
  9454. heading -= 360;
  9455. spawn->SetLevel(5);
  9456. spawn->SetAdventureClass(4);
  9457. spawn->SetHeading(heading, false);
  9458. spawn->SetSpawnOrigX(spawn->GetX());
  9459. spawn->SetSpawnOrigY(spawn->GetY());
  9460. spawn->SetSpawnOrigZ(spawn->GetZ());
  9461. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  9462. spawn->SetLocation(client->GetPlayer()->GetLocation());
  9463. spawn->appearance.targetable = 1;
  9464. if (spawn->IsNPC() && spawn->GetTotalHP() == 0) {
  9465. spawn->SetTotalHP(spawn->GetLevel() * 15);
  9466. spawn->SetHP(spawn->GetTotalHP());
  9467. }
  9468. if (spawn->GetTotalPower() == 0) {
  9469. spawn->SetTotalPower(spawn->GetLevel() * 15);
  9470. spawn->SetPower(spawn->GetTotalPower());
  9471. }
  9472. int16 offset = atoi(sep->arg[1]);
  9473. int32 value1 = atol(sep->arg[2]);
  9474. sprintf(spawn->appearance.name, "Offset %i", offset);
  9475. EQ2Packet* ret = spawn->spawn_serialize(client->GetPlayer(), client->GetVersion(), offset, value1);
  9476. DumpPacket(ret);
  9477. client->QueuePacket(ret);
  9478. }
  9479. }
  9480. else if (atoi(sep->arg[0]) == 8) {
  9481. int32 id = atoi(sep->arg[1]);
  9482. Spawn* spawn = client->GetCurrentZone()->GetSpawn(id);
  9483. if (spawn) {
  9484. spawn->SetX(client->GetPlayer()->GetX() + .5, false);
  9485. spawn->SetY(client->GetPlayer()->GetY(), false);
  9486. spawn->SetZ(client->GetPlayer()->GetZ() + .5, false);
  9487. float heading = client->GetPlayer()->GetHeading() + 180;
  9488. if (heading > 360)
  9489. heading -= 360;
  9490. spawn->SetLevel(5);
  9491. spawn->SetAdventureClass(4);
  9492. spawn->SetHeading(heading, false);
  9493. spawn->SetSpawnOrigX(spawn->GetX());
  9494. spawn->SetSpawnOrigY(spawn->GetY());
  9495. spawn->SetSpawnOrigZ(spawn->GetZ());
  9496. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  9497. spawn->SetLocation(client->GetPlayer()->GetLocation());
  9498. spawn->appearance.targetable = 1;
  9499. if (spawn->IsNPC() && spawn->GetTotalHP() == 0) {
  9500. spawn->SetTotalHP(spawn->GetLevel() * 15);
  9501. spawn->SetHP(spawn->GetTotalHP());
  9502. }
  9503. if (spawn->GetTotalPower() == 0) {
  9504. spawn->SetTotalPower(spawn->GetLevel() * 15);
  9505. spawn->SetPower(spawn->GetTotalPower());
  9506. }
  9507. int16 offset = atoi(sep->arg[2]);
  9508. int16 offset2 = atoi(sep->arg[3]);
  9509. int32 value1 = atol(sep->arg[4]);
  9510. int16 offset3 = 0;
  9511. int16 offset4 = 0;
  9512. int32 value2 = 0;
  9513. if (sep->IsSet(7)) {
  9514. offset3 = atoi(sep->arg[5]);
  9515. offset4 = atoi(sep->arg[6]);
  9516. value2 = atol(sep->arg[7]);
  9517. }
  9518. sprintf(spawn->appearance.name, "Offset %i to %i", offset, offset2);
  9519. spawn->AddPrimaryEntityCommand("attack", 10000, "attack","", 0, 0);
  9520. EQ2Packet* ret = spawn->spawn_serialize(client->GetPlayer(), client->GetVersion(), offset, value1, offset2, offset3, offset4, value2);
  9521. DumpPacket(ret);
  9522. client->QueuePacket(ret);
  9523. }
  9524. }
  9525. else if (atoi(sep->arg[0]) == 9) {
  9526. PacketStruct* packet2 = configReader.getStruct("WS_DeathWindow", client->GetVersion());
  9527. if (packet2) {
  9528. packet2->setArrayLengthByName("location_count", 1);
  9529. packet2->setArrayDataByName("location_ida", 1234);
  9530. packet2->setArrayDataByName("unknown2a", 3);
  9531. packet2->setArrayDataByName("zone_name", "Queen's Colony");
  9532. packet2->setArrayDataByName("location_name", "Myrrin's Tower");
  9533. packet2->setArrayDataByName("distance", 134);
  9534. EQ2Packet* app = packet2->serialize();
  9535. if (sep->IsSet(2)) {
  9536. int8 offset = atoi(sep->arg[1]);
  9537. uchar* ptr2 = app->pBuffer;
  9538. ptr2 += offset;
  9539. if (sep->IsNumber(2)) {
  9540. int32 value1 = atol(sep->arg[2]);
  9541. if (value1 > 0xFFFF)
  9542. memcpy(ptr2, (uchar*)&value1, 4);
  9543. else if (value1 > 0xFF)
  9544. memcpy(ptr2, (uchar*)&value1, 2);
  9545. else
  9546. memcpy(ptr2, (uchar*)&value1, 1);
  9547. }
  9548. else {
  9549. int8 len = strlen(sep->arg[2]);
  9550. memcpy(ptr2, (uchar*)&len, 1);
  9551. ptr2 += 1;
  9552. memcpy(ptr2, sep->arg[2], len);
  9553. }
  9554. }
  9555. DumpPacket(app);
  9556. client->QueuePacket(app);
  9557. safe_delete(packet2);
  9558. }
  9559. }
  9560. else if (atoi(sep->arg[0]) == 10) {
  9561. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalUpdate", client->GetVersion());
  9562. if (packet2) {
  9563. packet2->setArrayLengthByName("num_quests", 1);
  9564. packet2->setArrayDataByName("active", 1);
  9565. packet2->setArrayDataByName("name", "Tasks aboard the Far Journey");
  9566. packet2->setArrayDataByName("quest_type", "Hallmark");
  9567. packet2->setArrayDataByName("quest_zone", "Hallmark");
  9568. packet2->setArrayDataByName("journal_updated", 1);
  9569. packet2->setArrayDataByName("quest_id", 524);
  9570. packet2->setArrayDataByName("day", 19);
  9571. packet2->setArrayDataByName("month", 6);
  9572. packet2->setArrayDataByName("year", 20);
  9573. packet2->setArrayDataByName("level", 2);
  9574. packet2->setArrayDataByName("encounter_level", 4);
  9575. packet2->setArrayDataByName("difficulty", 3);
  9576. packet2->setArrayDataByName("visible", 1);
  9577. packet2->setDataByName("visible_quest_id", 524);
  9578. packet2->setDataByName("player_crc", 2900677088);
  9579. packet2->setDataByName("player_name", "LethalEncounter");
  9580. EQ2Packet* app = packet2->serialize();
  9581. if (sep->IsSet(2)) {
  9582. int8 offset = atoi(sep->arg[1]);
  9583. uchar* ptr2 = app->pBuffer;
  9584. ptr2 += offset;
  9585. if (sep->IsNumber(2)) {
  9586. int32 value1 = atol(sep->arg[2]);
  9587. if (value1 > 0xFFFF)
  9588. memcpy(ptr2, (uchar*)&value1, 4);
  9589. else if (value1 > 0xFF)
  9590. memcpy(ptr2, (uchar*)&value1, 2);
  9591. else
  9592. memcpy(ptr2, (uchar*)&value1, 1);
  9593. }
  9594. else {
  9595. int8 len = strlen(sep->arg[2]);
  9596. memcpy(ptr2, (uchar*)&len, 1);
  9597. ptr2 += 1;
  9598. memcpy(ptr2, sep->arg[2], len);
  9599. }
  9600. }
  9601. DumpPacket(app);
  9602. client->QueuePacket(app);
  9603. safe_delete(packet2);
  9604. }
  9605. }
  9606. else if (atoi(sep->arg[0]) == 11) {
  9607. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalReply", client->GetVersion());
  9608. if (packet2) {
  9609. packet2->setDataByName("quest_id", 524);
  9610. packet2->setDataByName("player_crc", 2900677088);
  9611. packet2->setDataByName("name", "Tasks aboard the Far Journey");
  9612. packet2->setDataByName("description", "I completed all the tasks assigned to me by Captain Varlos aboard the Far Journey");
  9613. packet2->setDataByName("type", "Hallmark");
  9614. packet2->setDataByName("complete_header", "To complete this quest, I must do the following tasks:");
  9615. packet2->setDataByName("day", 19);
  9616. packet2->setDataByName("month", 6);
  9617. packet2->setDataByName("year", 20);
  9618. packet2->setDataByName("level", 1);
  9619. packet2->setDataByName("encounter_level", 1);
  9620. packet2->setDataByName("difficulty", 1);
  9621. packet2->setDataByName("time_obtained", Timer::GetUnixTimeStamp());
  9622. //packet2->setDataByName("timer_start", Timer::GetUnixTimeStamp());
  9623. //packet2->setDataByName("timer_duration", 300);
  9624. //packet2->setDataByName("timer_running", 1);
  9625. packet2->setArrayLengthByName("task_groups_completed", 9);
  9626. packet2->setArrayLengthByName("num_task_groups", 10);
  9627. packet2->setArrayDataByName("task_group", "I spoke to Waulon as Captain Varlos had asked of me.");
  9628. packet2->setArrayDataByName("task_group", "I found Waulon's hat in one of the boxes.", 1);
  9629. packet2->setArrayDataByName("task_group", "I returned Waulon's hat.", 2);
  9630. packet2->setArrayDataByName("task_group", "I have spoken to Ingrid.", 3);
  9631. packet2->setArrayDataByName("task_group", "I purchased a Shard of Luclin.", 4);
  9632. packet2->setArrayDataByName("task_group", "I gave the Shard of Luclin to Ingrid.", 5);
  9633. packet2->setArrayDataByName("task_group", "I have spoken to Captain Varlos.", 6);
  9634. packet2->setArrayDataByName("task_group", "I killed the rats that Captain Varlos requested.", 7);
  9635. packet2->setArrayDataByName("task_group", "Captain Varlos has ordered you to kill the escaped goblin.", 8);
  9636. packet2->setArrayDataByName("task_group", "I killed the escaped goblin.", 9);
  9637. /*packet2->setSubArrayLengthByName("num_tasks", 1);
  9638. packet2->setSubArrayDataByName("task", "I need to talk to Garven Tralk");
  9639. packet2->setSubArrayLengthByName("num_updates", 1);
  9640. packet2->setSubArrayDataByName("update_currentval", 0);
  9641. packet2->setSubArrayDataByName("update_maxval", 1);
  9642. packet2->setSubArrayDataByName("icon", 11);
  9643. */
  9644. packet2->setArrayDataByName("waypoint", 0xFFFFFFFF);
  9645. packet2->setDataByName("journal_updated", 1);
  9646. packet2->setDataByName("bullets", 1);
  9647. EQ2Packet* app = packet2->serialize();
  9648. if (sep->IsSet(2)) {
  9649. int16 offset = atoi(sep->arg[1]);
  9650. uchar* ptr2 = app->pBuffer;
  9651. ptr2 += offset;
  9652. if (sep->IsNumber(2)) {
  9653. int32 value1 = atol(sep->arg[2]);
  9654. if (value1 > 0xFFFF)
  9655. memcpy(ptr2, (uchar*)&value1, 4);
  9656. else if (value1 > 0xFF)
  9657. memcpy(ptr2, (uchar*)&value1, 2);
  9658. else
  9659. memcpy(ptr2, (uchar*)&value1, 1);
  9660. }
  9661. else {
  9662. int16 len = strlen(sep->arg[2]);
  9663. memcpy(ptr2, (uchar*)&len, 2);
  9664. ptr2 += 2;
  9665. memcpy(ptr2, sep->arg[2], len);
  9666. }
  9667. }
  9668. DumpPacket(app);
  9669. client->QueuePacket(app);
  9670. safe_delete(packet2);
  9671. }
  9672. }
  9673. else if (atoi(sep->arg[0]) == 12) {
  9674. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalReply", client->GetVersion());
  9675. if (packet2) {
  9676. packet2->setDataByName("quest_id", 5725);
  9677. packet2->setDataByName("player_crc", 2900677088);
  9678. packet2->setDataByName("name", "Archetype Selection");
  9679. packet2->setDataByName("description", "I have reported my profession to Garven Tralk.");
  9680. packet2->setDataByName("type", "Hallmark");
  9681. packet2->setDataByName("complete_header", "To complete this quest, I must do the following tasks:");
  9682. packet2->setDataByName("day", 19);
  9683. packet2->setDataByName("month", 6);
  9684. packet2->setDataByName("year", 20);
  9685. packet2->setDataByName("level", 2);
  9686. packet2->setDataByName("encounter_level", 4);
  9687. packet2->setDataByName("difficulty", 3);
  9688. packet2->setDataByName("time_obtained", Timer::GetUnixTimeStamp());
  9689. packet2->setDataByName("timer_start", Timer::GetUnixTimeStamp());
  9690. packet2->setDataByName("timer_duration", 300);
  9691. packet2->setDataByName("timer_running", 1);
  9692. packet2->setArrayLengthByName("task_groups_completed", 0);
  9693. packet2->setArrayLengthByName("num_task_groups", 1);
  9694. packet2->setArrayDataByName("task_group", "I need to talk to Garven Tralk");
  9695. packet2->setSubArrayLengthByName("num_tasks", 1);
  9696. packet2->setSubArrayDataByName("task", "I need to talk to Garven Tralk");
  9697. packet2->setSubArrayLengthByName("num_updates", 1);
  9698. packet2->setSubArrayDataByName("update_currentval", 0);
  9699. packet2->setSubArrayDataByName("update_maxval", 1);
  9700. packet2->setSubArrayDataByName("icon", 11);
  9701. packet2->setArrayDataByName("waypoint", 0xFFFFFFFF);
  9702. packet2->setDataByName("journal_updated", 1);
  9703. packet2->setSubstructDataByName("reward_data", "unknown1", 255);
  9704. packet2->setSubstructDataByName("reward_data", "reward", "Quest Reward!");
  9705. packet2->setSubstructDataByName("reward_data", "unknown2", 0x3f);
  9706. packet2->setSubstructDataByName("reward_data", "coin", 150);
  9707. packet2->setSubstructDataByName("reward_data", "status_points", 5);
  9708. packet2->setSubstructDataByName("reward_data", "exp_bonus", 10);
  9709. packet2->setSubstructArrayLengthByName("reward_data", "num_rewards", 1);
  9710. packet2->setSubstructArrayDataByName("reward_data", "reward_id", 123);
  9711. Item* item = master_item_list.GetItem(152755);
  9712. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9713. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, client->GetClientItemPacketOffset());
  9714. /*packet2->setSubstructDataByName("item", "unique_id", 567);
  9715. packet2->setSubstructDataByName("item", "broker_item_id", 0xFFFFFFFFFFFFFFFF);
  9716. packet2->setSubstructDataByName("item", "icon", 0xe7);
  9717. packet2->setSubstructDataByName("item", "tier", 4);
  9718. packet2->setSubstructDataByName("item", "flags", 0x60);
  9719. packet2->setSubstructArrayLengthByName("item", "stat_count", 1);
  9720. packet2->setSubstructDataByName("item", "stat_type", 1);
  9721. packet2->setSubstructDataByName("item", "stat_subtype", 2);
  9722. packet2->setSubstructDataByName("item", "value", 3);
  9723. packet2->setSubstructDataByName("item", "condition", 100);
  9724. packet2->setSubstructDataByName("item", "weight", 1);
  9725. packet2->setSubstructDataByName("item", "skill_req1", 0xacafa99e);
  9726. packet2->setSubstructDataByName("item", "skill_req2", 0xacafa99e);
  9727. packet2->setSubstructDataByName("item", "skill_min", 1);
  9728. packet2->setSubstructArrayLengthByName("item", "class_count", 3);
  9729. packet2->setSubstructDataByName("item", "adventure_class", 1);
  9730. packet2->setSubstructDataByName("item", "adventure_class", 11, 0, 1);
  9731. packet2->setSubstructDataByName("item", "adventure_class", 0x1f, 0, 2);
  9732. packet2->setSubstructDataByName("item", "tradeskill_class", 255);
  9733. packet2->setSubstructDataByName("item", "tradeskill_class", 255, 0, 1);
  9734. packet2->setSubstructDataByName("item", "tradeskill_class", 255, 0, 2);
  9735. packet2->setSubstructDataByName("item", "level", 0x1e);
  9736. packet2->setSubstructDataByName("item", "level", 100, 0, 1);
  9737. packet2->setSubstructDataByName("item", "level", 100, 0, 2);
  9738. packet2->setSubstructDataByName("item_footer", "name", "Footman Gloves");*/
  9739. //packet2->PrintPacket();
  9740. EQ2Packet* app = packet2->serialize();
  9741. if (sep->IsSet(2)) {
  9742. int16 offset = atoi(sep->arg[1]);
  9743. uchar* ptr2 = app->pBuffer;
  9744. ptr2 += offset;
  9745. if (sep->IsNumber(2)) {
  9746. int32 value1 = atol(sep->arg[2]);
  9747. if (value1 > 0xFFFF)
  9748. memcpy(ptr2, (uchar*)&value1, 4);
  9749. else if (value1 > 0xFF)
  9750. memcpy(ptr2, (uchar*)&value1, 2);
  9751. else
  9752. memcpy(ptr2, (uchar*)&value1, 1);
  9753. }
  9754. else {
  9755. int16 len = strlen(sep->arg[2]);
  9756. memcpy(ptr2, (uchar*)&len, 2);
  9757. ptr2 += 2;
  9758. memcpy(ptr2, sep->arg[2], len);
  9759. }
  9760. }
  9761. DumpPacket(app);
  9762. client->QueuePacket(app);
  9763. safe_delete(packet2);
  9764. }
  9765. }
  9766. else if (atoi(sep->arg[0]) == 13) {
  9767. PacketStruct* packet2 = configReader.getStruct("WS_OnScreenMsg", client->GetVersion());
  9768. if (packet2 && sep->IsSet(7)) {
  9769. packet2->setDataByName("unknown", atoi(sep->arg[1]));
  9770. char blah[128];
  9771. sprintf(blah, "\\#6EFF6EYou get better at \12\\#C8FFC8%s\\#6EFF6E! (7/15)", sep->arg[2]);
  9772. packet2->setDataByName("text", blah);
  9773. packet2->setDataByName("message_type", sep->arg[3]);
  9774. packet2->setDataByName("size", atof(sep->arg[4]));
  9775. packet2->setDataByName("red", atoi(sep->arg[5]));
  9776. packet2->setDataByName("green", atoi(sep->arg[6]));
  9777. packet2->setDataByName("blue", atoi(sep->arg[7]));
  9778. EQ2Packet* app = packet2->serialize();
  9779. DumpPacket(app);
  9780. client->QueuePacket(app);
  9781. safe_delete(packet2);
  9782. }
  9783. }
  9784. else if (atoi(sep->arg[0]) == 14) {
  9785. PacketStruct* packet2 = configReader.getStruct("WS_InstructionWindow", client->GetVersion());
  9786. if (packet2 && sep->IsSet(3)) {
  9787. packet2->setDataByName("open_seconds_min", atof(sep->arg[1]));
  9788. packet2->setDataByName("open_seconds_max", atof(sep->arg[2]));
  9789. packet2->setDataByName("voice_sync", atoi(sep->arg[3]));
  9790. 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.");
  9791. packet2->setDataByName("voice", "voiceover/english/narrator/boat_06p_tutorial02/narrator_001_63779ca0.mp3");
  9792. packet2->setArrayLengthByName("num_goals", 1);
  9793. //packet2->setArrayDataByName("goal_text", )
  9794. packet2->setSubArrayLengthByName("num_tasks", 1);
  9795. packet2->setSubArrayDataByName("task_text", "continue");
  9796. packet2->setDataByName("complete_sound", "click");
  9797. packet2->setDataByName("signal", "introduction");
  9798. packet2->setDataByName("voice_key1", 0xcda65173);
  9799. packet2->setDataByName("voice_key2", 0x984bfc6d);
  9800. EQ2Packet* app = packet2->serialize();
  9801. DumpPacket(app);
  9802. client->QueuePacket(app);
  9803. safe_delete(packet2);
  9804. packet2 = configReader.getStruct("WS_ShowWindow", client->GetVersion());
  9805. packet2->setDataByName("window", "MainHUD.StartMenu");
  9806. packet2->setDataByName("show", 1);
  9807. app = packet2->serialize();
  9808. DumpPacket(app);
  9809. client->QueuePacket(app);
  9810. safe_delete(packet2);
  9811. packet2 = configReader.getStruct("WS_FlashWindow", client->GetVersion());
  9812. packet2->setDataByName("window", "MainHUD.StartMenu.help");
  9813. packet2->setDataByName("flash_seconds", 10);
  9814. app = packet2->serialize();
  9815. DumpPacket(app);
  9816. client->QueuePacket(app);
  9817. safe_delete(packet2);
  9818. }
  9819. }
  9820. else if (atoi(sep->arg[0]) == 15) {
  9821. PacketStruct* packet2 = configReader.getStruct("WS_UpdateLoot", client->GetVersion());
  9822. if (packet2) {
  9823. packet2->setArrayLengthByName("loot_count", 1);
  9824. packet2->setArrayDataByName("name", "Test");
  9825. packet2->setArrayDataByName("item_id", 1234);
  9826. packet2->setArrayDataByName("count", 1);
  9827. packet2->setArrayDataByName("icon", 258);
  9828. packet2->setArrayDataByName("ability_id", 0xFFFFFFFF);
  9829. Spawn* spawn = client->GetPlayer()->GetTarget();
  9830. if (spawn)
  9831. packet2->setDataByName("object_id", client->GetPlayer()->GetIDWithPlayerSpawn(spawn));
  9832. packet2->setDataByName("display", 1);
  9833. packet2->setDataByName("loot_type", 1);
  9834. packet2->setDataByName("lotto_timeout", 60);
  9835. EQ2Packet* app = packet2->serialize();
  9836. DumpPacket(app);
  9837. client->QueuePacket(app);
  9838. safe_delete(packet2);
  9839. }
  9840. }
  9841. else if (atoi(sep->arg[0]) == 16 && sep->IsNumber(1)) {
  9842. char blah[32];
  9843. sprintf(blah, "Testing: %i", atoi(sep->arg[1]));
  9844. client->SimpleMessage(atoi(sep->arg[1]), blah);
  9845. }
  9846. else if (atoi(sep->arg[0]) == 17 && sep->IsNumber(2)) {
  9847. if (sep->IsSet(2)) {
  9848. int16 offset = atoi(sep->arg[1]);
  9849. if (sep->IsNumber(2)) {
  9850. int32 value1 = atol(sep->arg[2]);
  9851. client->QueuePacket(client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion(), offset, value1));
  9852. cout << "Sent" << endl;
  9853. }
  9854. }
  9855. }
  9856. else if (atoi(sep->arg[0]) == 18) {
  9857. PacketStruct* packet2 = configReader.getStruct("WS_QuestRewardPackMsg", client->GetVersion());
  9858. if (packet2) {
  9859. packet2->setSubstructDataByName("reward_data", "unknown1", 255);
  9860. packet2->setSubstructDataByName("reward_data", "reward", "Quest Reward!");
  9861. packet2->setSubstructDataByName("reward_data", "max_coin", 0);
  9862. packet2->setSubstructDataByName("reward_data", "text", "Some custom text to mess things up?");
  9863. packet2->setSubstructDataByName("reward_data", "status_points", 5);
  9864. //packet2->setSubstructDataByName("reward_data", "exp_bonus", 10);
  9865. packet2->setSubstructArrayLengthByName("reward_data", "num_rewards", 1);
  9866. Item* item = new Item(master_item_list.GetItem(9357));
  9867. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9868. //item->stack_count = 20;
  9869. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, client->GetClientItemPacketOffset());
  9870. safe_delete(item);
  9871. /*item = new Item(master_item_list.GetItem(36685));
  9872. item->stack_count = 20;
  9873. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9874. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 1, 0, -1);
  9875. safe_delete(item);
  9876. item = master_item_list.GetItem(1414);
  9877. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9878. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 2, 0, -1);
  9879. item = master_item_list.GetItem(75057);
  9880. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9881. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 3, 0, -1);*/
  9882. EQ2Packet* app = packet2->serialize();
  9883. if (sep->IsSet(2)) {
  9884. int16 offset = atoi(sep->arg[1]);
  9885. uchar* ptr2 = app->pBuffer;
  9886. ptr2 += offset;
  9887. if (sep->IsNumber(2)) {
  9888. int32 value1 = atol(sep->arg[2]);
  9889. if (value1 > 0xFFFF)
  9890. memcpy(ptr2, (uchar*)&value1, 4);
  9891. else if (value1 > 0xFF)
  9892. memcpy(ptr2, (uchar*)&value1, 2);
  9893. else
  9894. memcpy(ptr2, (uchar*)&value1, 1);
  9895. }
  9896. else {
  9897. int16 len = strlen(sep->arg[2]);
  9898. memcpy(ptr2, (uchar*)&len, 2);
  9899. ptr2 += 2;
  9900. memcpy(ptr2, sep->arg[2], len);
  9901. }
  9902. }
  9903. DumpPacket(app);
  9904. client->QueuePacket(app);
  9905. safe_delete(packet2);
  9906. }
  9907. }
  9908. else if (atoi(sep->arg[0]) == 19) {
  9909. PacketStruct* packet2 = configReader.getStruct("WS_UpdateLoot", client->GetVersion());
  9910. Spawn* spawn = client->GetPlayer()->GetTarget();
  9911. if (packet2 && spawn) {
  9912. Item* item = master_item_list.GetItem(130053);
  9913. packet2->setArrayLengthByName("loot_count", 1);
  9914. packet2->setArrayDataByName("loot_id", item->details.item_id);
  9915. packet2->setArrayDataByName("unknown2", 1);
  9916. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, 2, true);
  9917. packet2->setDataByName("display", 1);
  9918. packet2->setDataByName("unknown2b", 1);
  9919. packet2->setDataByName("unknown3", 0x3c);
  9920. packet2->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(spawn));
  9921. packet2->PrintPacket();
  9922. EQ2Packet* app = packet2->serialize();
  9923. if (sep->IsSet(2)) {
  9924. int16 offset = atoi(sep->arg[1]);
  9925. int16 offset2 = 0;
  9926. int32 value1 = 0;
  9927. if (sep->IsSet(3)) {
  9928. offset2 = atoi(sep->arg[2]);
  9929. value1 = atol(sep->arg[3]);
  9930. }
  9931. else
  9932. value1 = atol(sep->arg[2]);
  9933. int16 offset3 = 0;
  9934. int16 offset4 = 0;
  9935. int32 value2 = 0;
  9936. if (sep->IsSet(6)) {
  9937. offset3 = atoi(sep->arg[4]);
  9938. offset4 = atoi(sep->arg[5]);
  9939. value2 = atol(sep->arg[6]);
  9940. }
  9941. offset--;
  9942. if (offset2 > 0 && offset2 >= offset) {
  9943. offset2--;
  9944. uchar* ptr2 = app->pBuffer;
  9945. ptr2 += offset;
  9946. for (int i = offset; i <= offset2; i++) {
  9947. if (value1 > 0xFFFF) {
  9948. memcpy(ptr2, (uchar*)&value1, 4);
  9949. i += 3;
  9950. ptr2 += 3;
  9951. }
  9952. else if (value1 > 0xFF) {
  9953. memcpy(ptr2, (uchar*)&value1, 2);
  9954. i++;
  9955. ptr2++;
  9956. }
  9957. else
  9958. memcpy(ptr2, (uchar*)&value1, 1);
  9959. ptr2++;
  9960. }
  9961. }
  9962. if (offset4 > 0 && offset4 >= offset3) {
  9963. offset3--;
  9964. offset4--;
  9965. uchar* ptr2 = app->pBuffer;
  9966. ptr2 += offset3;
  9967. for (int i = offset3; i <= offset4; i++) {
  9968. if (value2 > 0xFFFF) {
  9969. memcpy(ptr2, (uchar*)&value2, 4);
  9970. i += 3;
  9971. ptr2 += 3;
  9972. }
  9973. else if (value2 > 0xFF) {
  9974. memcpy(ptr2, (uchar*)&value2, 2);
  9975. i++;
  9976. ptr2++;
  9977. }
  9978. else
  9979. memcpy(ptr2, (uchar*)&value2, 1);
  9980. ptr2++;
  9981. }
  9982. }
  9983. }
  9984. DumpPacket(app);
  9985. client->QueuePacket(app);
  9986. safe_delete(packet2);
  9987. }
  9988. }
  9989. else if (atoi(sep->arg[0]) == 21) {
  9990. PacketStruct* packet2 = configReader.getStruct("WS_OfferQuest", client->GetVersion());
  9991. if (packet2) {
  9992. packet2->setDataByName("unknown0", 255);
  9993. packet2->setDataByName("reward", "New Quest");
  9994. packet2->setDataByName("title", "Title");
  9995. packet2->setDataByName("description", "description");
  9996. packet2->setDataByName("quest_difficulty", 3);
  9997. packet2->setDataByName("unknown1", 5);
  9998. packet2->setDataByName("level", 3);
  9999. packet2->setDataByName("coin", 150);
  10000. packet2->setDataByName("status_points", 5);
  10001. packet2->setDataByName("exp_bonus", 10);
  10002. packet2->setArrayLengthByName("num_rewards", 1);
  10003. Item* item = new Item(master_item_list.GetItem(36212));
  10004. packet2->setArrayDataByName("reward_id", item->details.item_id);
  10005. item->stack_count = 20;
  10006. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, client->GetClientItemPacketOffset());
  10007. safe_delete(item);
  10008. char accept[35] = { 0 };
  10009. char decline[35] = { 0 };
  10010. sprintf(accept, "q_accept_pending_quest %u", 0);
  10011. sprintf(decline, "q_deny_pending_quest %u", 0);
  10012. packet2->setDataByName("accept_command", accept);
  10013. packet2->setDataByName("decline_command", decline);
  10014. EQ2Packet* app = packet2->serialize();
  10015. if (sep->IsSet(2)) {
  10016. int16 offset = atoi(sep->arg[1]);
  10017. uchar* ptr2 = app->pBuffer;
  10018. ptr2 += offset;
  10019. if (sep->IsNumber(2)) {
  10020. int32 value1 = atol(sep->arg[2]);
  10021. if (value1 > 0xFFFF)
  10022. memcpy(ptr2, (uchar*)&value1, 4);
  10023. else if (value1 > 0xFF)
  10024. memcpy(ptr2, (uchar*)&value1, 2);
  10025. else
  10026. memcpy(ptr2, (uchar*)&value1, 1);
  10027. }
  10028. DumpPacket(app);
  10029. client->QueuePacket(app);
  10030. safe_delete(packet2);
  10031. }
  10032. }
  10033. }
  10034. else if (atoi(sep->arg[0]) == 22) { //same as 21, but 8bit string
  10035. PacketStruct* packet2 = configReader.getStruct("WS_OfferQuest", client->GetVersion());
  10036. if (packet2) {
  10037. packet2->setDataByName("unknown0", 255);
  10038. packet2->setDataByName("reward", "New Quest");
  10039. packet2->setDataByName("title", "Title");
  10040. packet2->setDataByName("description", "description");
  10041. packet2->setDataByName("quest_difficulty", 3);
  10042. packet2->setDataByName("unknown1", 5);
  10043. packet2->setDataByName("level", 3);
  10044. packet2->setDataByName("coin", 150);
  10045. packet2->setDataByName("status_points", 5);
  10046. packet2->setDataByName("exp_bonus", 10);
  10047. packet2->setArrayLengthByName("num_rewards", 1);
  10048. Item* item = new Item(master_item_list.GetItem(36212));
  10049. packet2->setArrayDataByName("reward_id", item->details.item_id);
  10050. item->stack_count = 20;
  10051. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, client->GetClientItemPacketOffset());
  10052. safe_delete(item);
  10053. char accept[35] = { 0 };
  10054. char decline[35] = { 0 };
  10055. sprintf(accept, "q_accept_pending_quest %u", 0);
  10056. sprintf(decline, "q_deny_pending_quest %u", 0);
  10057. packet2->setDataByName("accept_command", accept);
  10058. packet2->setDataByName("decline_command", decline);
  10059. EQ2Packet* app = packet2->serialize();
  10060. if (sep->IsSet(2)) {
  10061. int16 offset = atoi(sep->arg[1]);
  10062. uchar* ptr2 = app->pBuffer;
  10063. ptr2 += offset;
  10064. if (sep->IsNumber(2)) {
  10065. int32 value1 = atol(sep->arg[2]);
  10066. if (value1 > 0xFFFF)
  10067. memcpy(ptr2, (uchar*)&value1, 4);
  10068. else if (value1 > 0xFF)
  10069. memcpy(ptr2, (uchar*)&value1, 2);
  10070. else
  10071. memcpy(ptr2, (uchar*)&value1, 1);
  10072. }
  10073. else {
  10074. int8 len = strlen(sep->arg[2]);
  10075. memcpy(ptr2, (uchar*)&len, 1);
  10076. ptr2 += 1;
  10077. memcpy(ptr2, sep->arg[2], len);
  10078. }
  10079. }
  10080. DumpPacket(app);
  10081. client->QueuePacket(app);
  10082. safe_delete(packet2);
  10083. }
  10084. }
  10085. else if (atoi(sep->arg[0]) == 23) {
  10086. if (client->GetPlayer()->GetTarget()) {
  10087. PacketStruct* packet2 = configReader.getStruct("WS_UpdateMerchant", client->GetVersion());
  10088. if (packet2) {
  10089. Spawn* target = client->GetPlayer()->GetTarget();
  10090. packet2->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(target));
  10091. Item* item = new Item(master_item_list.GetItem(12565));
  10092. int8 i = 0;
  10093. packet2->setArrayLengthByName("num_items", 1);
  10094. packet2->setArrayDataByName("item_name", item->name.c_str(), i);
  10095. packet2->setArrayDataByName("item_id", item->details.item_id, i);
  10096. packet2->setArrayDataByName("stack_size", item->stack_count, i);
  10097. packet2->setArrayDataByName("icon", item->GetIcon(client->GetVersion()), i);
  10098. int8 tmp_level = 0;
  10099. if (item->generic_info.adventure_default_level > 0)
  10100. tmp_level = item->generic_info.adventure_default_level;
  10101. else
  10102. tmp_level = item->generic_info.tradeskill_default_level;
  10103. packet2->setArrayDataByName("level", tmp_level, i);
  10104. packet2->setArrayDataByName("tier", item->details.tier, i);
  10105. packet2->setArrayDataByName("item_id2", item->details.item_id, i);
  10106. int8 item_difficulty = client->GetPlayer()->GetArrowColor(tmp_level);
  10107. if (item_difficulty != ARROW_COLOR_WHITE && item_difficulty != ARROW_COLOR_RED && item_difficulty != ARROW_COLOR_GRAY)
  10108. item_difficulty = ARROW_COLOR_WHITE;
  10109. item_difficulty -= 6;
  10110. if (item_difficulty < 0)
  10111. item_difficulty *= -1;
  10112. packet2->setArrayDataByName("item_difficulty", item_difficulty, i);
  10113. packet2->setArrayDataByName("quantity", 2, i);
  10114. packet2->setArrayDataByName("unknown5", 255, i);
  10115. packet2->setArrayDataByName("stack_size2", item->stack_count, i);
  10116. packet2->setArrayDataByName("description", item->description.c_str(), i);
  10117. packet2->setDataByName("type", 2);
  10118. EQ2Packet* app = packet2->serialize();
  10119. if (sep->IsSet(2)) {
  10120. int16 offset = atoi(sep->arg[1]);
  10121. uchar* ptr2 = app->pBuffer;
  10122. ptr2 += offset;
  10123. if (sep->IsNumber(2)) {
  10124. int32 value1 = atol(sep->arg[2]);
  10125. if (value1 > 0xFFFF)
  10126. memcpy(ptr2, (uchar*)&value1, 4);
  10127. else if (value1 > 0xFF)
  10128. memcpy(ptr2, (uchar*)&value1, 2);
  10129. else
  10130. memcpy(ptr2, (uchar*)&value1, 1);
  10131. }
  10132. else {
  10133. int8 len = strlen(sep->arg[2]);
  10134. memcpy(ptr2, (uchar*)&len, 1);
  10135. ptr2 += 1;
  10136. memcpy(ptr2, sep->arg[2], len);
  10137. }
  10138. }
  10139. DumpPacket(app);
  10140. client->QueuePacket(app);
  10141. safe_delete(packet2);
  10142. }
  10143. }
  10144. }
  10145. else if (atoi(sep->arg[0]) == 24) {
  10146. PacketStruct* packet2 = configReader.getStruct("WS_EnableGameEvent", client->GetVersion());
  10147. if (packet2) {
  10148. if (sep->IsSet(2)) {
  10149. packet2->setDataByName("event_name", sep->arg[1]);
  10150. packet2->setDataByName("enabled", atoi(sep->arg[2]));
  10151. EQ2Packet* app = packet2->serialize();
  10152. DumpPacket(app);
  10153. client->QueuePacket(app);
  10154. safe_delete(packet2);
  10155. }
  10156. }
  10157. }
  10158. else if (atoi(sep->arg[0]) == 25) {
  10159. if (sep->IsSet(1)) {
  10160. Widget* new_spawn = new Widget();
  10161. int32 id = atoul(sep->arg[1]);
  10162. new_spawn->SetWidgetID(id);
  10163. EQ2Packet* ret = new_spawn->serialize(client->GetPlayer(), client->GetVersion());
  10164. client->QueuePacket(ret);
  10165. int8 index = client->GetPlayer()->GetIndexForSpawn(new_spawn);
  10166. PacketStruct* packet2 = configReader.getStruct("WS_DestroyGhostCmd", client->GetVersion());
  10167. if (packet2) {
  10168. packet2->setDataByName("spawn_index", index);
  10169. packet2->setDataByName("delete", 1);
  10170. EQ2Packet* app = packet2->serialize();
  10171. client->QueuePacket(app);
  10172. safe_delete(packet2);
  10173. }
  10174. }
  10175. }
  10176. else if (atoi(sep->arg[0]) == 26) {
  10177. if (sep->IsSet(4)) {
  10178. Widget* new_spawn = new Widget();
  10179. int32 id = atoul(sep->arg[1]);
  10180. new_spawn->SetWidgetID(id);
  10181. float x = atof(sep->arg[2]);
  10182. float y = atof(sep->arg[3]);
  10183. float z = atof(sep->arg[4]);
  10184. new_spawn->SetLocation(client->GetPlayer()->GetLocation());
  10185. new_spawn->SetWidgetX(x);
  10186. new_spawn->SetWidgetY(y);
  10187. new_spawn->SetWidgetZ(z);
  10188. new_spawn->SetX(x);
  10189. new_spawn->SetY(y);
  10190. new_spawn->SetZ(z);
  10191. EQ2Packet* ret = new_spawn->serialize(client->GetPlayer(), client->GetVersion());
  10192. client->QueuePacket(ret);
  10193. }
  10194. }
  10195. else if (atoi(sep->arg[0]) == 27) {
  10196. Spawn* target = client->GetPlayer()->GetTarget();
  10197. PacketStruct* packet2 = configReader.getStruct("WS_HearSimpleDamage", client->GetVersion());
  10198. if (packet2 && target && sep->IsSet(4)) {
  10199. client->GetPlayer()->GetZone()->SendDamagePacket(client->GetPlayer(), target, atoul(sep->arg[1]), atoul(sep->arg[2]), atoul(sep->arg[3]), atoul(sep->arg[4]), sep->arg[5] != nullptr ? sep->arg[5] : "");
  10200. }
  10201. }
  10202. else if (atoi(sep->arg[0]) == 28 && sep->IsNumber(1)) {
  10203. World::newValue = strtoull(sep->arg[1], NULL, 0);
  10204. }
  10205. else if (atoi(sep->arg[0]) == 29 && sep->IsNumber(1)) {
  10206. client->SendHearCast(client->GetPlayer(), client->GetPlayer()->GetTarget() ? client->GetPlayer()->GetTarget() : client->GetPlayer(),
  10207. strtoull(sep->arg[1], NULL, 0), atoul(sep->arg[2]));
  10208. }
  10209. else if (atoi(sep->arg[0]) == 30) {
  10210. PacketStruct* packet = configReader.getStruct("WS_UpdateSkillBook", client->GetVersion());
  10211. if (packet) {
  10212. packet->setDataByName("unknown", World::newValue);
  10213. EQ2Packet* outapp = packet->serialize();
  10214. DumpPacket(outapp);
  10215. client->QueuePacket(outapp);
  10216. safe_delete(packet);
  10217. }
  10218. }
  10219. else if (atoi(sep->arg[0]) == 31) {
  10220. client->SendRecipeList();
  10221. }
  10222. else if (atoi(sep->arg[0]) == 32 && sep->IsNumber(1) && sep->IsNumber(2)) {
  10223. if(client->GetVersion() <= 561) {
  10224. int32 param = atoul(sep->arg[1]);
  10225. int32 paramvalue = atoul(sep->arg[2]);
  10226. client->Message(CHANNEL_COLOR_YELLOW, "Send control flag param %u param value %u", param, paramvalue);
  10227. ClientPacketFunctions::SendServerControlFlagsClassic(client, param, paramvalue);
  10228. }
  10229. else if(sep->IsNumber(3)) {
  10230. int8 param1 = atoul(sep->arg[1]);
  10231. int8 param2 = atoul(sep->arg[2]);
  10232. int8 paramval = atoul(sep->arg[3]);
  10233. client->Message(CHANNEL_COLOR_YELLOW, "Send control flag param1 %u param2 %u param value %u", param1, param2, paramval);
  10234. ClientPacketFunctions::SendServerControlFlags(client, param1, param2, paramval);
  10235. }
  10236. }
  10237. else if (atoi(sep->arg[0]) == 33 && sep->IsNumber(1) && sep->IsNumber(2)) {
  10238. client->GetCurrentZone()->SendHealPacket(client->GetPlayer(), client->GetPlayer()->GetTarget() ? client->GetPlayer()->GetTarget() : client->GetPlayer(),
  10239. atoul(sep->arg[1]), atoul(sep->arg[2]), "TestSpell");
  10240. }
  10241. else if(atoi(sep->arg[0]) == 34 && sep->IsNumber(1) && sep->IsNumber(2)) {
  10242. PacketStruct* packet = configReader.getStruct("WS_QuestRewardPackMsg", client->GetVersion());
  10243. packet->setSubstructDataByName("reward_data", "unknown1", atoi(sep->arg[1]));
  10244. Item* item = master_item_list.GetItem(atoul(sep->arg[2]));
  10245. if(item) {
  10246. packet->setSubstructArrayLengthByName("reward_data", "num_select_rewards", 1);
  10247. packet->setArrayDataByName("select_reward_id", item->details.item_id, 0);
  10248. packet->setItemArrayDataByName("select_item", item, client->GetPlayer(), 0, 0, World::newValue - 2);
  10249. }
  10250. client->QueuePacket(packet->serialize());
  10251. safe_delete(packet);
  10252. }
  10253. else if(atoi(sep->arg[0]) == 35) {
  10254. if(client->GetPlayer()->GetGroupMemberInfo() && client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  10255. Entity* target = (Entity*)client->GetPlayer()->GetTarget();
  10256. if(target->GetGroupMemberInfo()) {
  10257. PlayerGroup* group = world.GetGroupManager()->GetGroup(client->GetPlayer()->GetGroupMemberInfo()->group_id);
  10258. PlayerGroup* group2 = world.GetGroupManager()->GetGroup(target->GetGroupMemberInfo()->group_id);
  10259. if(group && group2) {
  10260. group->AddGroupToRaid(group2->GetID());
  10261. group2->AddGroupToRaid(group->GetID());
  10262. }
  10263. }
  10264. }
  10265. }
  10266. else if(atoi(sep->arg[0]) == 36) {
  10267. EQ2Packet* packet = client->GetPlayer()->GetRaidUpdatePacket(client->GetVersion());
  10268. if(packet) {
  10269. client->QueuePacket(packet);
  10270. }
  10271. }
  10272. else if(atoi(sep->arg[0]) == 37) {
  10273. Guild* guild = client->GetPlayer()->GetGuild();
  10274. if(guild)
  10275. guild->SendGuildMemberList();
  10276. }
  10277. }
  10278. else {
  10279. PacketStruct* packet2 = configReader.getStruct("WS_ExaminePartialSpellInfo", client->GetVersion());
  10280. if (packet2) {
  10281. packet2->setSubstructDataByName("info_header", "show_name", 1);
  10282. packet2->setSubstructDataByName("info_header", "unknown", 7);
  10283. packet2->setSubstructDataByName("info_header", "unknown2", 1);
  10284. packet2->setSubstructDataByName("info_header", "unknown3", 1);
  10285. packet2->setSubstructDataByName("info_header", "unknown4", 1);
  10286. packet2->setSubstructDataByName("info_header", "unknown5", 1);
  10287. packet2->setSubstructDataByName("info_header", "unknown6", "Testing");
  10288. packet2->setSubstructDataByName("info_header", "unknown7", "Testing");
  10289. packet2->setSubstructDataByName("info_header", "unknown8", 66);
  10290. packet2->setSubstructDataByName("info_header", "title", "Blah Title Blah");
  10291. packet2->setSubstructDataByName("info_header", "title_text", "Blah Blah");
  10292. packet2->setSubstructDataByName("info_header", "title_text2", "Blah Blah2");
  10293. packet2->setSubstructDataByName("info_header", "show_popup", 1);
  10294. packet2->setSubstructDataByName("info_header", "packettype", 3);
  10295. packet2->setSubstructDataByName("spell_info", "skill_name", "Testing");
  10296. packet2->setSubstructDataByName("spell_info", "level", 19);
  10297. packet2->setSubstructDataByName("spell_info", "tier", 1);
  10298. packet2->setSubstructDataByName("spell_info", "health_cost", 5);
  10299. packet2->setSubstructDataByName("spell_info", "min_class_skill_req", 3);
  10300. packet2->setSubstructDataByName("spell_info", "mana_cost", 6);
  10301. packet2->setSubstructDataByName("spell_info", "req_concentration", 7);
  10302. packet2->setSubstructDataByName("spell_info", "cast_time", 200);
  10303. packet2->setSubstructDataByName("spell_info", "recovery", 220);
  10304. packet2->setSubstructDataByName("spell_info", "recast", 280);
  10305. packet2->setSubstructDataByName("spell_info", "beneficial", 1);
  10306. packet2->setSubstructDataByName("spell_info", "maintained", 1);
  10307. packet2->setSubstructDataByName("spell_info", "spell_book_type", 1);
  10308. packet2->setSubstructDataByName("spell_info", "quality", 3);
  10309. packet2->setSubstructDataByName("spell_info", "test_1a", 1);
  10310. packet2->setSubstructDataByName("spell_info", "test_1b", 1);
  10311. packet2->setSubstructDataByName("spell_info", "test_1c", 1);
  10312. packet2->setSubstructDataByName("spell_info", "test_1d", 1);
  10313. packet2->setSubstructDataByName("spell_info", "test_2a", 2);
  10314. packet2->setSubstructDataByName("spell_info", "test_2b", 2);
  10315. packet2->setSubstructDataByName("spell_info", "test_2c", 2);
  10316. packet2->setSubstructDataByName("spell_info", "test_2d", 2);
  10317. packet2->setSubstructDataByName("spell_info", "test_3", 3);
  10318. packet2->setSubstructDataByName("spell_info", "test_4", 4);
  10319. packet2->setSubstructDataByName("spell_info", "test_5", 5);
  10320. packet2->setSubstructDataByName("spell_info", "test_6", 6);
  10321. packet2->setSubstructDataByName("spell_info", "min_class_skill_req", 1);
  10322. packet2->setSubstructDataByName("spell_info", "min_class_skill_rec", 30123);
  10323. packet2->setSubstructDataByName("spell_info", "num_reagents", 1);
  10324. packet2->setSubstructArrayLengthByName("spell_info", "num_reagents", 1);
  10325. packet2->setArrayDataByName("reagent", "Alcohol");
  10326. packet2->setArrayDataByName("consumed", "123");
  10327. packet2->setSubstructDataByName("spell_info", "class_skill", 52);
  10328. packet2->setSubstructDataByName("spell_info", "id", 8308);
  10329. packet2->setSubstructDataByName("spell_info", "icon", 303);
  10330. packet2->setSubstructDataByName("spell_info", "icon2", 0xFFFF);
  10331. packet2->setSubstructDataByName("spell_info", "icontype", 317);
  10332. packet2->setSubstructDataByName("spell_info", "type", 2);
  10333. packet2->setSubstructDataByName("spell_info", "spell_text_color", 255);
  10334. packet2->setSubstructDataByName("spell_info", "duration1", 600);
  10335. packet2->setSubstructDataByName("spell_info", "duration2", 600);
  10336. packet2->setSubstructDataByName("spell_info", "name", "Sprint");
  10337. packet2->setSubstructDataByName("spell_info", "description", "Test description");
  10338. EQ2Packet* outapp = packet2->serialize();
  10339. DumpPacket(outapp);
  10340. client->QueuePacket(outapp);
  10341. safe_delete(packet2);
  10342. }
  10343. }
  10344. return;
  10345. PacketStruct* p = configReader.getStruct("WS_EqTargetItemCmd", client->GetVersion());
  10346. if (!p) return;
  10347. //Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  10348. //client->GetCurrentZone()->SendSpellFailedPacket(client, atoi(sep2->arg[0]));
  10349. //}
  10350. /*Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  10351. if (sep2 && sep2->arg[0] && sep2->IsNumber(0)) {
  10352. client->SetPendingFlightPath(atoi(sep2->arg[0]));
  10353. PacketStruct* packet = configReader.getStruct("WS_ReadyForTakeOff", client->GetVersion());
  10354. if (packet) {
  10355. client->QueuePacket(packet->serialize());
  10356. safe_delete(packet);
  10357. }
  10358. }*/
  10359. /*if (client->GetCurrentZone()->Grid != nullptr) {
  10360. int32 numFaces = 0;
  10361. int32 numGrids = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.size();
  10362. client->Message(CHANNEL_COLOR_YELLOW, "Num grids in cell: %u", numGrids);
  10363. map<int32, vector<Face*> >::iterator itr;
  10364. for (itr = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.begin(); itr != client->GetPlayer()->Cell_Info.CurrentCell->FaceList.end(); itr++)
  10365. numFaces += (*itr).second.size();
  10366. client->Message(CHANNEL_COLOR_YELLOW, "Num faces in cell: %u", numFaces);
  10367. }*/
  10368. //uchar blah[] = {
  10369. // 1208 - OP_EQUpdateStoreCmd
  10370. // /*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
  10371. // /*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
  10372. // 1193 - -- OP_ClientCmdMsg::OP_EqUpdateMerchantCmd --
  10373. // /*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
  10374. /*};
  10375. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  10376. int8 val = 0;
  10377. int16 pos = 0;
  10378. int idx = 0;
  10379. while(sep2 && sep2->arg[idx+1] && sep2->IsNumber(idx) && sep2->IsNumber(idx+1)){
  10380. pos = atoi(sep2->arg[idx]);
  10381. val = atoi(sep2->arg[idx+1]);
  10382. memset(blah+pos, val, 1);
  10383. idx+=2;
  10384. }
  10385. DumpPacket(blah, sizeof(blah));
  10386. client->QueuePacket(new EQ2Packet(OP_GroupCreatedMsg , blah, sizeof(blah)));*/
  10387. if (client->GetPlayer()->GetTarget()) {
  10388. PacketStruct* packet = configReader.getStruct("WS_SetControlGhost", client->GetVersion());
  10389. if (packet) {
  10390. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  10391. packet->setDataByName("size", 0);
  10392. packet->setDataByName("unknown2", 0);
  10393. EQ2Packet* app = packet->serialize();
  10394. client->QueuePacket(app);
  10395. safe_delete(packet);
  10396. }
  10397. PacketStruct* set_pov = configReader.getStruct("WS_SetPOVGhostCmd", client->GetVersion());
  10398. if (set_pov) {
  10399. set_pov->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  10400. EQ2Packet* app_pov = set_pov->serialize();
  10401. client->QueuePacket(app_pov);
  10402. safe_delete(set_pov);
  10403. }
  10404. }
  10405. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  10406. PacketStruct* packet = configReader.getStruct("WS_OpenCharCust", client->GetVersion());
  10407. if (packet) {
  10408. if (sep2 && sep2->arg[0] && sep2->IsNumber(0))
  10409. packet->setDataByName("Type", atoi(sep2->arg[0]));
  10410. else
  10411. packet->setDataByName("Type", 2);
  10412. if (sep2 && sep2->arg[1] && sep2->IsNumber(1))
  10413. packet->setDataByName("race_id", atoi(sep2->arg[1]));
  10414. else
  10415. packet->setDataByName("race_id", 0);
  10416. if (sep2 && sep2->arg[2] && sep2->IsNumber(2))
  10417. packet->setDataByName("gender", atoi(sep2->arg[2]));
  10418. else
  10419. packet->setDataByName("gender", 2);
  10420. if (sep2 && sep2->arg[3] && sep2->IsNumber(3))
  10421. packet->setDataByName("unknown", atoi(sep2->arg[3]), 0);
  10422. else
  10423. packet->setDataByName("unknown", 0, 0);
  10424. if (sep2 && sep2->arg[4] && sep2->IsNumber(4))
  10425. packet->setDataByName("unknown", atoi(sep2->arg[4]), 1);
  10426. else
  10427. packet->setDataByName("unknown", 0, 1);
  10428. if (sep2 && sep2->arg[5] && sep2->IsNumber(5))
  10429. packet->setDataByName("unknown", atoi(sep2->arg[5]), 2);
  10430. else
  10431. packet->setDataByName("unknown", 0, 2);
  10432. client->QueuePacket(packet->serialize());
  10433. }
  10434. safe_delete(packet);
  10435. safe_delete(sep2);
  10436. }
  10437. void Commands::Command_LeaveChannel(Client *client, Seperator *sep) {
  10438. const char *channel_name;
  10439. if (sep == NULL || !sep->IsSet(0)) {
  10440. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /leavechat <channel name>");
  10441. PrintSep(sep);
  10442. return;
  10443. }
  10444. channel_name = sep->arg[0];
  10445. if (!chat.IsInChannel(client, channel_name))
  10446. client->Message(CHANNEL_NARRATIVE, "Unable to leave '%s': You are not in the channel.", channel_name);
  10447. else if (!chat.LeaveChannel(client, channel_name))
  10448. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an internal error preventing you from leaving that channel MUAHAHA");
  10449. }
  10450. /*
  10451. Function:
  10452. Purpose :
  10453. Params :
  10454. Dev :
  10455. Example :
  10456. */
  10457. void Commands::Command_WeaponStats(Client* client)
  10458. {
  10459. Player* player = client->GetPlayer();
  10460. Spawn* target = player->GetTarget();
  10461. Item* primary = player->GetEquipmentList()->GetItem(EQ2_PRIMARY_SLOT);
  10462. Item* secondary = player->GetEquipmentList()->GetItem(EQ2_SECONDARY_SLOT);
  10463. Item* ranged = player->GetEquipmentList()->GetItem(EQ2_RANGE_SLOT);
  10464. const char* charName = player->GetName();
  10465. if(target && target->IsEntity()) {
  10466. primary = ((Entity*)target)->GetEquipmentList()->GetItem(EQ2_PRIMARY_SLOT);
  10467. secondary = ((Entity*)target)->GetEquipmentList()->GetItem(EQ2_SECONDARY_SLOT);
  10468. ranged = ((Entity*)target)->GetEquipmentList()->GetItem(EQ2_RANGE_SLOT);
  10469. charName = target->GetName();
  10470. }
  10471. else {
  10472. target = nullptr;
  10473. }
  10474. client->Message(0, "WeaponStats for %s", charName);
  10475. client->SimpleMessage(0, "Primary:");
  10476. if (primary) {
  10477. client->Message(0, "Name: %s", primary->name.c_str());
  10478. client->Message(0, "Base Damage: %u - %u", primary->weapon_info->damage_low3, primary->weapon_info->damage_high3);
  10479. client->Message(0, "Mastery Damage: %u - %u", primary->weapon_info->damage_low2, primary->weapon_info->damage_high2);
  10480. client->Message(0, "Damage: %u - %u", primary->weapon_info->damage_low1, primary->weapon_info->damage_high1);
  10481. client->Message(0, "Actual Damage: %u - %u", target ? ((Entity*)target)->GetPrimaryWeaponMinDamage() : player->GetPrimaryWeaponMinDamage(),
  10482. target ? ((Entity*)target)->GetPrimaryWeaponMaxDamage() : player->GetPrimaryWeaponMaxDamage());
  10483. client->Message(0, "Actual Delay: %u", target ? ((Entity*)target)->GetPrimaryWeaponDelay() : player->GetPrimaryWeaponDelay());
  10484. client->Message(0, "Proc Percent: %d%%", 0);
  10485. client->Message(0, "Procs Per Minute: %d", 0);
  10486. }
  10487. else {
  10488. client->SimpleMessage(0, "Name: fist");
  10489. client->Message(0, "Base Damage: %u - %u", target ? ((Entity*)target)->GetPrimaryWeaponMinDamage() : player->GetPrimaryWeaponMinDamage(),
  10490. target ? ((Entity*)target)->GetPrimaryWeaponMaxDamage() : player->GetPrimaryWeaponMaxDamage());
  10491. client->Message(0, "Actual Damage: %u - %u", target ? ((Entity*)target)->GetPrimaryWeaponMinDamage() : player->GetPrimaryWeaponMinDamage(),
  10492. target ? ((Entity*)target)->GetPrimaryWeaponMaxDamage() : player->GetPrimaryWeaponMaxDamage());
  10493. client->Message(0, "Actual Delay: %d", target ? ((Entity*)target)->GetPrimaryWeaponDelay() : player->GetPrimaryWeaponDelay() * 0.1);
  10494. client->Message(0, "Proc Percent: %d%%", 0);
  10495. client->Message(0, "Procs Per Minute: %d", 0);
  10496. }
  10497. client->SimpleMessage(0, " ");
  10498. client->SimpleMessage(0, " ");
  10499. if (secondary) {
  10500. client->SimpleMessage(0, "Secondary:");
  10501. client->Message(0, "Name: %s", secondary->name.c_str());
  10502. client->Message(0, "Base Damage: %u - %u", secondary->weapon_info->damage_low3, secondary->weapon_info->damage_high3);
  10503. client->Message(0, "Mastery Damage: %u - %u", secondary->weapon_info->damage_low2, secondary->weapon_info->damage_high2);
  10504. client->Message(0, "Damage: %u - %u", secondary->weapon_info->damage_low1, secondary->weapon_info->damage_high1);
  10505. client->Message(0, "Actual Damage: %u - %u", target ? ((Entity*)target)->GetSecondaryWeaponMinDamage() : player->GetSecondaryWeaponMinDamage(),
  10506. target ? ((Entity*)target)->GetSecondaryWeaponMaxDamage() : player->GetSecondaryWeaponMaxDamage());
  10507. client->Message(0, "Actual Delay: %d", target ? ((Entity*)target)->GetSecondaryWeaponDelay() : player->GetSecondaryWeaponDelay() * 0.1);
  10508. client->Message(0, "Proc Percent: %d%%", 0);
  10509. client->Message(0, "Procs Per Minute: %d", 0);
  10510. client->SimpleMessage(0, " ");
  10511. client->SimpleMessage(0, " ");
  10512. }
  10513. client->SimpleMessage(0, "Ranged:");
  10514. if (ranged) {
  10515. client->Message(0, "Name: %s", ranged->name.c_str());
  10516. client->Message(0, "Base Damage: %u - %u", ranged->ranged_info->weapon_info.damage_low3, ranged->ranged_info->weapon_info.damage_high3);
  10517. client->Message(0, "Mastery Damage: %u - %u", ranged->ranged_info->weapon_info.damage_low2, ranged->ranged_info->weapon_info.damage_high2);
  10518. client->Message(0, "Damage: %u - %u", ranged->ranged_info->weapon_info.damage_low1, ranged->ranged_info->weapon_info.damage_high1);
  10519. client->Message(0, "Actual Damage: %u - %u", target ? ((Entity*)target)->GetRangedWeaponMinDamage() : player->GetRangedWeaponMinDamage(),
  10520. target ? ((Entity*)target)->GetRangedWeaponMaxDamage() : player->GetRangedWeaponMaxDamage());
  10521. client->Message(0, "Actual Delay: %d", target ? ((Entity*)target)->GetRangeWeaponDelay() : player->GetRangeWeaponDelay() * 0.1);
  10522. client->Message(0, "Proc Percent: %d%%", 0);
  10523. client->Message(0, "Procs Per Minute: %d", 0);
  10524. }
  10525. else
  10526. client->SimpleMessage(0, "None");
  10527. }
  10528. void Commands::Command_WhoChannel(Client *client, Seperator *sep) {
  10529. const char *channel_name;
  10530. if (sep == NULL || !sep->IsSet(0)) {
  10531. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /chatwho <channel name>");
  10532. return;
  10533. }
  10534. channel_name = sep->arg[0];
  10535. if (!chat.ChannelExists(channel_name))
  10536. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That channel does not exist!");
  10537. else
  10538. chat.SendChannelUserList(client, channel_name);
  10539. }
  10540. void Commands::Command_ZoneSafeCoords(Client *client, Seperator *sep)
  10541. {
  10542. ZoneServer* zone = 0;
  10543. int32 zone_id = client->GetPlayer()->GetZone()->GetZoneID();
  10544. if (zone_id > 0)
  10545. {
  10546. ZoneChangeDetails zone_details;
  10547. if(zone_list.GetZone(&zone_details, zone_id, "", false, false, false)) {
  10548. zone = (ZoneServer*)zone_details.zonePtr;
  10549. }
  10550. if (zone)
  10551. {
  10552. zone->SetSafeX(client->GetPlayer()->GetX());
  10553. zone->SetSafeY(client->GetPlayer()->GetY());
  10554. zone->SetSafeZ(client->GetPlayer()->GetZ());
  10555. zone->SetSafeHeading(client->GetPlayer()->GetHeading());
  10556. if( database.SaveZoneSafeCoords(zone_id, zone->GetSafeX(), zone->GetSafeY(), zone->GetSafeZ(), zone->GetSafeHeading()) )
  10557. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Zone safe coordinates updated!");
  10558. else
  10559. client->SimpleMessage(CHANNEL_COLOR_RED, "FAILED to update zone safe coordinates!");
  10560. }
  10561. }
  10562. }
  10563. /*
  10564. Function:
  10565. Purpose :
  10566. Params :
  10567. Dev :
  10568. Example :
  10569. */
  10570. void Commands::Command_ZoneDetails(Client* client, Seperator* sep)
  10571. {
  10572. ZoneInfo* zone_info = new ZoneInfo;
  10573. if (sep && sep->arg[0])
  10574. {
  10575. if (sep->IsNumber(0))
  10576. zone_info->id = atoi(sep->arg[0]);
  10577. else
  10578. zone_info->id = database.GetZoneID(sep->arg[0]);
  10579. if (zone_info->id > 0)
  10580. {
  10581. database.LoadZoneInfo(zone_info);
  10582. 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);
  10583. 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);
  10584. 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);
  10585. 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);
  10586. 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);
  10587. 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);
  10588. 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);
  10589. client->Message(CHANNEL_COLOR_YELLOW, "zone_type: %s, sky_file: %s", zone_info->zone_type, zone_info->sky_file);
  10590. client->Message(CHANNEL_COLOR_YELLOW, "lua_script: %s", zone_info->lua_script);
  10591. client->Message(CHANNEL_COLOR_YELLOW, "zone_motd: %s", zone_info->zone_motd);
  10592. }
  10593. else
  10594. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  10595. }
  10596. else
  10597. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone details [zone id|zone name]");
  10598. safe_delete(zone_info);
  10599. }
  10600. /*
  10601. Function:
  10602. Purpose :
  10603. Params :
  10604. Dev :
  10605. Example :
  10606. */
  10607. void Commands::Command_ZoneSet(Client* client, Seperator* sep)
  10608. {
  10609. if (sep && sep->arg[0] && sep->arg[1] && sep->arg[2])
  10610. {
  10611. ZoneServer* zone = 0;
  10612. int32 zone_id = 0;
  10613. ZoneChangeDetails zone_details;
  10614. if (sep->IsNumber(0) && atoi(sep->arg[0]) > 0)
  10615. {
  10616. zone_id = atoul(sep->arg[0]);
  10617. if(zone_list.GetZone(&zone_details, zone_id, "", false, false, false, false)) {
  10618. zone = (ZoneServer*)zone_details.zonePtr;
  10619. }
  10620. }
  10621. else
  10622. {
  10623. zone_id = database.GetZoneID(sep->arg[0]);
  10624. if(zone_list.GetZone(&zone_details, zone_id, "", false, false, false, false)) {
  10625. zone = (ZoneServer*)zone_details.zonePtr;
  10626. }
  10627. }
  10628. if (zone_id > 0)
  10629. {
  10630. if (zone_set_values.count(string(sep->arg[1])) > 0)
  10631. SetZoneCommand(client, zone_id, zone, zone_set_values[sep->arg[1]], sep->arg[2]);
  10632. else
  10633. client->Message(CHANNEL_COLOR_YELLOW, "The attribute '%s' is not valid.", sep->arg[1]);
  10634. }
  10635. else
  10636. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  10637. }
  10638. else
  10639. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone set [zone id|zone name] [attribute] [value]");
  10640. }
  10641. void Commands::Command_Rain(Client* client, Seperator* sep) {
  10642. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  10643. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /rain <float>");
  10644. return;
  10645. }
  10646. client->Message(CHANNEL_COLOR_YELLOW,"Setting rain to %.2f", atof(sep->arg[0]));
  10647. client->GetCurrentZone()->SetRain(atof(sep->arg[0]));
  10648. client->GetCurrentZone()->SetCurrentWeather(atof(sep->arg[0]));
  10649. }
  10650. void Commands::Command_Wind(Client* client, Seperator* sep) {
  10651. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  10652. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /wind <float>");
  10653. return;
  10654. }
  10655. client->Message(CHANNEL_COLOR_YELLOW, "Setting wind to %.2f", atof(sep->arg[0]));
  10656. client->GetCurrentZone()->SetWind(atof(sep->arg[0]));
  10657. }
  10658. void Commands::Command_SendMerchantWindow(Client* client, Seperator* sep, bool sell) {
  10659. Spawn* spawn = client->GetPlayer()->GetTarget();
  10660. if(client->GetVersion() < 561) {
  10661. sell = false; // doesn't support in the same way as AoM just open the normal buy/sell window
  10662. }
  10663. if(spawn) {
  10664. client->SetMerchantTransaction(spawn);
  10665. if (spawn->GetMerchantID() > 0 && spawn->IsClientInMerchantLevelRange(client)){
  10666. client->SendHailCommand(spawn);
  10667. //MerchantFactionMultiplier* multiplier = world.GetMerchantMultiplier(spawn->GetMerchantID());
  10668. //if(!multiplier || (multiplier && client->GetPlayer()->GetFactions()->GetFactionValue(multiplier->faction_id) >= multiplier->faction_min)){
  10669. client->SendBuyMerchantList(sell);
  10670. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY))
  10671. client->SendSellMerchantList(sell);
  10672. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY_BACK))
  10673. client->SendBuyBackList(sell);
  10674. if(client->GetVersion() > 561) {
  10675. PacketStruct* packet = configReader.getStruct("WS_UpdateMerchant", client->GetVersion());
  10676. if (packet) {
  10677. packet->setDataByName("spawn_id", 0xFFFFFFFF);
  10678. packet->setDataByName("type", 16);
  10679. EQ2Packet* outapp = packet->serialize();
  10680. if (outapp)
  10681. client->QueuePacket(outapp);
  10682. safe_delete(packet);
  10683. }
  10684. }
  10685. }
  10686. if (spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR)
  10687. client->SendRepairList();
  10688. }
  10689. // client->SimpleMessage(CHANNEL_COLOR_RED, "Your faction is too low to use this merchant.");
  10690. }
  10691. void Commands::Command_Weather(Client* client, Seperator* sep)
  10692. {
  10693. //PrintSep(sep, "Weather");
  10694. if( sep && sep->arg[0] )
  10695. {
  10696. ZoneServer* zsZone = client->GetCurrentZone();
  10697. const char* value = sep->arg[0];
  10698. // process single-param commands first
  10699. if( strncasecmp(value, "details", strlen(value)) == 0 )
  10700. {
  10701. client->Message(CHANNEL_COLOR_YELLOW, "Weather Details for zone %s: ", zsZone->GetZoneName());
  10702. client->Message(CHANNEL_COLOR_YELLOW, "enabled: %i, allowed: %i, type: %i, frequency: %u", zsZone->isWeatherEnabled(), zsZone->isWeatherAllowed(), zsZone->GetWeatherType(), zsZone->GetWeatherFrequency());
  10703. client->Message(CHANNEL_COLOR_YELLOW, "severity: %.2f = %.2f, current: %.2f", zsZone->GetWeatherMinSeverity(), zsZone->GetWeatherMaxSeverity(), zsZone->GetCurrentWeather());
  10704. client->Message(CHANNEL_COLOR_YELLOW, "pattern: %i, chance: %i, amount: %.2f, offset: %.2f", zsZone->GetWeatherPattern(), zsZone->GetWeatherChance(), zsZone->GetWeatherChangeAmount(), zsZone->GetWeatherDynamicOffset());
  10705. }
  10706. else if( strncasecmp(value, "process", strlen(value)) == 0 )
  10707. {
  10708. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  10709. zsZone->ProcessWeather();
  10710. }
  10711. else if( strncasecmp(value, "reset", strlen(value)) == 0 )
  10712. {
  10713. zsZone->SetWeatherType(rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Zone, WeatherType)->GetInt8());
  10714. zsZone->SetWeatherFrequency(rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Zone, WeatherChangeFrequency)->GetInt32());
  10715. zsZone->SetWeatherMinSeverity(rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Zone, MinWeatherSeverity)->GetFloat());
  10716. zsZone->SetWeatherMaxSeverity(rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Zone, MaxWeatherSeverity)->GetFloat());
  10717. zsZone->SetCurrentWeather(zsZone->GetWeatherMinSeverity());
  10718. zsZone->SetWeatherPattern(1);
  10719. zsZone->SetWeatherChance(rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Zone, WeatherChangeChance)->GetInt8());
  10720. zsZone->SetWeatherChangeAmount(rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Zone, WeatherChangePerInterval)->GetFloat());
  10721. zsZone->SetWeatherDynamicOffset(rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Zone, WeatherDynamicMaxOffset)->GetFloat());
  10722. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  10723. zsZone->ProcessWeather();
  10724. }
  10725. // process commands with params
  10726. if( sep->arg[1] )
  10727. {
  10728. if( strncasecmp(value, "enable", strlen(value)) == 0 && sep->IsNumber(1) )
  10729. zsZone->SetWeatherEnabled( ( atoi(sep->arg[1]) == 1 ) ? true : false );
  10730. else if( strncasecmp(value, "type", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 3) )
  10731. zsZone->SetWeatherType(atoi(sep->arg[1]));
  10732. else if( strncasecmp(value, "frequency", strlen(value)) == 0 && sep->IsNumber(1))
  10733. zsZone->SetWeatherFrequency( atoul(sep->arg[1]) );
  10734. else if( strncasecmp(value, "range", strlen(value)) == 0 && sep->IsNumber(1) && sep->IsNumber(2) ) {
  10735. zsZone->SetWeatherMinSeverity(atof(sep->arg[1]));
  10736. zsZone->SetWeatherMaxSeverity(atof(sep->arg[2]));
  10737. zsZone->SetRain(zsZone->GetWeatherMinSeverity());
  10738. }
  10739. else if( strncasecmp(value, "current", strlen(value)) == 0 && sep->IsNumber(1) ) {
  10740. zsZone->SetCurrentWeather(atof(sep->arg[1]));
  10741. zsZone->SetRain(zsZone->GetCurrentWeather());
  10742. }
  10743. else if( strncasecmp(value, "pattern", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 2) )
  10744. zsZone->SetWeatherPattern( atoi(sep->arg[1]) );
  10745. else if( strncasecmp(value, "chance", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 100) )
  10746. zsZone->SetWeatherChance( atoi(sep->arg[1]) );
  10747. else if( strncasecmp(value, "amount", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  10748. zsZone->SetWeatherChangeAmount( atof(sep->arg[1]) );
  10749. else if( strncasecmp(value, "offset", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  10750. zsZone->SetWeatherDynamicOffset( atof(sep->arg[1]) );
  10751. }
  10752. }
  10753. else
  10754. {
  10755. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /weather [command] [param]");
  10756. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: enable (0|1), type (0-3), frequency (sec), range|current (0.0 - 1.0)");
  10757. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: details, process, pattern (0|1), chance (%), amount (float), offset (float)");
  10758. return;
  10759. }
  10760. }
  10761. void Commands::Command_Select(Client* client, Seperator* sep) {
  10762. if (sep && sep->arg[1]) {
  10763. Spawn* spawn = client->GetPlayer()->GetTarget();
  10764. if (spawn && strlen(sep->arg[1]) > 0)
  10765. client->GetCurrentZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_CUSTOM, client->GetPlayer(), sep->arg[1]);
  10766. }
  10767. }
  10768. /*
  10769. Function: Command_ConsumeFood()
  10770. Purpose : Consume Food/Drink and apply mods
  10771. Params : Slot ID - EQ2_FOOD_SLOT 22, EQ2_DRINK_SLOT 23
  10772. Dev : Zcoretri
  10773. Example : /consume_food 22
  10774. */
  10775. void Commands::Command_ConsumeFood(Client* client, Seperator* sep) {
  10776. if (sep && sep->arg[0] && sep->IsNumber(0))
  10777. {
  10778. Player* player = client->GetPlayer();
  10779. int32 slot = atoul(sep->arg[0]);
  10780. if (client->GetVersion() <= 373) {
  10781. if(client->GetVersion() <= 561) {
  10782. if(slot <= 255) {
  10783. slot = 255 - slot;
  10784. }
  10785. else {
  10786. if(slot == 256) { // first "new" item to inventory is assigned index 256 by client
  10787. slot = client->GetPlayer()->item_list.GetFirstNewItem();
  10788. }
  10789. else {
  10790. // otherwise the slot has to be mapped out depending on the amount of new items + index sent in
  10791. slot = client->GetPlayer()->item_list.GetNewItemByIndex((int16)slot - 255);
  10792. }
  10793. }
  10794. }
  10795. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(slot);
  10796. if(item && item->IsFood()) {
  10797. if(client->CheckConsumptionAllowed(slot)) {
  10798. if(item->IsFoodFood())
  10799. slot = EQ2_FOOD_SLOT;
  10800. else if(item->IsFoodDrink())
  10801. slot = EQ2_DRINK_SLOT;
  10802. else
  10803. return; // not valid item
  10804. client->ConsumeFoodDrink(item, slot);
  10805. }
  10806. }
  10807. }
  10808. else {
  10809. if (client->GetVersion() > 373 && client->GetVersion() <= 561) {
  10810. slot += 2;
  10811. }
  10812. Item* item = player->GetEquipmentList()->GetItem(slot);
  10813. if(client->CheckConsumptionAllowed(slot)) {
  10814. client->ConsumeFoodDrink(item, slot);
  10815. }
  10816. }
  10817. }
  10818. }
  10819. void Commands::Command_Aquaman(Client* client, Seperator* sep) {
  10820. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  10821. if (atoi(sep->arg[0]) == 1) {
  10822. client->GetPlayer()->GetInfoStruct()->set_vision(4);
  10823. client->GetPlayer()->GetInfoStruct()->set_breathe_underwater(1);
  10824. client->GetPlayer()->SetCharSheetChanged(true);
  10825. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Maybe you ought to stick to the shallow end until you know how to swim.");
  10826. }
  10827. else {
  10828. client->GetPlayer()->GetInfoStruct()->set_vision(0);
  10829. client->GetPlayer()->GetInfoStruct()->set_breathe_underwater(0);
  10830. client->GetPlayer()->SetCharSheetChanged(true);
  10831. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Aquaman mode turned off.");
  10832. }
  10833. }
  10834. else
  10835. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /aquaman [0|1]");
  10836. }
  10837. void Commands::Command_ReportBug(Client* client, Seperator* sep)
  10838. {
  10839. if(sep)
  10840. {
  10841. string data;
  10842. if(sep->arg[0]){
  10843. data = string(sep->arg[0]);
  10844. }
  10845. for(int i=1;i<sep->GetMaxArgNum();i++){
  10846. if(sep->arg[i])
  10847. data.append(" ").append(sep->arg[i]);
  10848. }
  10849. if(!sep->IsSet(7)){
  10850. data.append(" ").append(std::to_string(client->GetVersion())).append("\a");
  10851. }
  10852. const char* target_name = 0;
  10853. int32 spawn_id = 0;
  10854. if(client->GetPlayer()->GetTarget())
  10855. {
  10856. target_name = client->GetPlayer()->GetTarget()->GetName();
  10857. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  10858. }
  10859. else
  10860. target_name = "N/A";
  10861. LogWrite(COMMAND__DEBUG, 1, "Command", "%s", data.c_str());
  10862. if(world.ReportBug(data, client->GetPlayer()->GetName(), client->GetAccountID(), target_name, spawn_id, client->GetCurrentZone()->GetZoneID()))
  10863. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully submitted bug.");
  10864. else
  10865. client->SimpleMessage(CHANNEL_COLOR_RED, "Error submitting bug.");
  10866. }
  10867. }
  10868. void Commands::Command_Attune_Inv(Client* client, Seperator* sep) {
  10869. PrintSep(sep, "Command_Attune_Inv");
  10870. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  10871. // Get the item index from the first parameter
  10872. int16 index = atoi(sep->arg[0]);
  10873. // Check to see if this is a valid item index for the player, if not exit out of the function
  10874. if (client->GetPlayer()->item_list.indexed_items.count(index) == 0) {
  10875. LogWrite(ITEM__DEBUG, 0, "Items", "%s has no item with an index of %i", client->GetPlayer()->GetName(), index);
  10876. return;
  10877. }
  10878. // Get the item
  10879. Item* item = client->GetPlayer()->item_list.indexed_items[index];
  10880. if(item) {
  10881. // Valid item lets check to make sure this item is attunable, if not return out
  10882. if (!item->CheckFlag(ATTUNEABLE)) {
  10883. LogWrite(ITEM__DEBUG, 0, "Items", "attune_inv called for an item that is not attunable (%s)", item->name.c_str());
  10884. return;
  10885. }
  10886. // Remove the attunable flag
  10887. item->generic_info.item_flags -= ATTUNEABLE;
  10888. // Set the attuned flag
  10889. item->generic_info.item_flags += ATTUNED;
  10890. // Flag this item for saving
  10891. item->save_needed = true;
  10892. client->QueuePacket(item->serialize(client->GetVersion(), false, client->GetPlayer()));
  10893. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), 0, -1); // appearance type??
  10894. EQ2Packet* outapp = 0;
  10895. for (int32 i=0;i<packets.size();i++) {
  10896. outapp = packets[i];
  10897. if(outapp)
  10898. client->QueuePacket(outapp);
  10899. }
  10900. }
  10901. }
  10902. }
  10903. void Commands::Command_Reset_Zone_Timer(Client* client, Seperator* sep) {
  10904. PrintSep(sep, "Command_Reset_Zone_Timer");
  10905. /*if (sep && sep->arg[0] && sep->IsNumber(0)) {
  10906. int32 db_id = atoul(sep->arg[0]);
  10907. InstanceData* data = client->GetPlayer()->GetCharacterInstances().FindInstanceByDBID(db_id);
  10908. if (data) {
  10909. // TODO: add a check to timers to ensure it can be reset
  10910. // Delete the character from the instance
  10911. database.DeleteCharacterFromInstance(client->GetPlayer()->GetCharacterID(), data->instance_id);
  10912. data->instance_id = 0;
  10913. // Update the success time and set to 0 so the player can enter it again
  10914. database.UpdateCharacterInstance(client->GetPlayer()->GetCharacterID(), data->zone_name, 0, 1, 0);
  10915. data->last_success_timestamp = 0;
  10916. }
  10917. }*/
  10918. }
  10919. void Commands::Command_Player(Client* client, Seperator* sep) {
  10920. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player syntax --");
  10921. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins");
  10922. }
  10923. void Commands::Command_Player_Coins(Client* client, Seperator* sep) {
  10924. // /player coins add 10
  10925. // /player coins add plat 10
  10926. Player* player = client->GetPlayer();
  10927. Client* targetClient = client;
  10928. if (player->HasTarget() && player->GetTarget()->IsPlayer()) {
  10929. player = (Player*)player->GetTarget();
  10930. targetClient = player->GetClient();
  10931. }
  10932. if (sep && sep->arg[0] && sep->arg[1]) {
  10933. const char* action = sep->arg[0];
  10934. int64 value = 0;
  10935. if (strncasecmp(action, "add", strlen(action)) == 0) {
  10936. if (sep->IsNumber(1)) {
  10937. value = atoi64(sep->arg[1]);
  10938. player->AddCoins(value);
  10939. if (client->GetPlayer() == player)
  10940. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  10941. else {
  10942. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  10943. if(targetClient) {
  10944. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  10945. }
  10946. }
  10947. return;
  10948. }
  10949. else if (sep->arg[2] && sep->IsNumber(2)) {
  10950. const char* type = sep->arg[1];
  10951. if (strncasecmp(type, "copper", strlen(type)) == 0) {
  10952. value = atoi64(sep->arg[2]);
  10953. }
  10954. else if (strncasecmp(type, "silver", strlen(type)) == 0) {
  10955. value = atoi64(sep->arg[2]) * 100;
  10956. }
  10957. else if (strncasecmp(type, "gold", strlen(type)) == 0) {
  10958. value = atoi64(sep->arg[2]) * 10000;
  10959. }
  10960. else if (strncasecmp(type, "plat", strlen(type)) == 0) {
  10961. value = atoi64(sep->arg[2]) * 1000000;
  10962. }
  10963. player->AddCoins(value);
  10964. if (client->GetPlayer() == player)
  10965. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  10966. else {
  10967. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  10968. if(targetClient) {
  10969. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  10970. }
  10971. }
  10972. return;
  10973. }
  10974. }
  10975. }
  10976. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player coins syntax --");
  10977. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add [value] - adds the given number of coins to the player");
  10978. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add copper [value] - adds the given amount of copper to the player");
  10979. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add silver [value] - adds the given amount of silver to the player");
  10980. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add gold [value] - adds the given amount of gold to the player");
  10981. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add plat [value] - adds the given amount of platinum to the player");
  10982. }
  10983. void Commands::Command_AchievementAdd(Client* client, Seperator* sep) {
  10984. PrintSep(sep, "ACHIEVEMENT_ADD");
  10985. if (sep && sep->IsSet(0)) {
  10986. int32 spell_id = atoul(sep->arg[1]);
  10987. int8 spell_tier = 0;
  10988. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  10989. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  10990. // addspellbookentry here
  10991. if (spell_tier >= data->maxRank) {
  10992. return;
  10993. }
  10994. if (!spell_tier) {
  10995. spell_tier = 1;
  10996. }
  10997. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  10998. {
  10999. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  11000. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  11001. client->GetPlayer()->UnlockSpell(spell);
  11002. client->SendSpellUpdate(spell);
  11003. }
  11004. else
  11005. {
  11006. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1);
  11007. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  11008. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  11009. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  11010. client->GetPlayer()->UnlockSpell(spell);
  11011. client->SendSpellUpdate(spell);
  11012. }
  11013. // cast spell here
  11014. if (!spell_tier)
  11015. spell_tier = 1;
  11016. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  11017. if (spell) {
  11018. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  11019. }
  11020. }
  11021. else {
  11022. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  11023. }
  11024. if(client->GetVersion() > 561)
  11025. master_aa_list.DisplayAA(client, 0, 0);
  11026. }
  11027. void Commands::Command_Editor(Client* client, Seperator* sep) {
  11028. PacketStruct* packet = configReader.getStruct("WS_ChoiceWindow", client->GetVersion());
  11029. if (packet) {
  11030. string url = string(rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_World, EditorURL)->GetString());
  11031. if (rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_World, EditorOfficialServer)->GetBool()) {
  11032. char command[255];
  11033. url = "browser " + url;
  11034. int32 spawn_id = 0;
  11035. int32 zone_id = 0;
  11036. string type;
  11037. if (client->GetCurrentZone())
  11038. zone_id = client->GetCurrentZone()->GetZoneID();
  11039. if (client->GetPlayer()->GetTarget()) {
  11040. Spawn* target = client->GetPlayer()->GetTarget();
  11041. if (target->IsWidget())
  11042. type = "widgets";
  11043. else if (target->IsSign())
  11044. type = "signs";
  11045. else if (target->IsObject())
  11046. type = "objects";
  11047. else if (target->IsNPC())
  11048. type = "npcs";
  11049. else if (target->IsGroundSpawn())
  11050. type = "ground";
  11051. else
  11052. type = "spawn";
  11053. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  11054. }
  11055. sprintf(command, url.c_str(), zone_id, type.c_str(), spawn_id);
  11056. packet->setDataByName("accept_command", command);
  11057. }
  11058. else if (rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_World, EditorIncludeID)->GetBool()) {
  11059. char command[255];
  11060. url = "browser " + url;
  11061. if (client->GetPlayer()->GetTarget())
  11062. sprintf(command, url.c_str(), client->GetPlayer()->GetTarget()->GetDatabaseID());
  11063. packet->setDataByName("accept_command", command);
  11064. }
  11065. else {
  11066. string command = "browser " + url;
  11067. packet->setDataByName("accept_command", command.c_str());
  11068. }
  11069. packet->setDataByName("text", "Open the web editor?");
  11070. packet->setDataByName("accept_text", "Open");
  11071. packet->setDataByName("cancel_text", "Cancel");
  11072. // No clue if we even need the following 2 unknowns, just added them so the packet matches what live sends
  11073. packet->setDataByName("unknown2", 50);
  11074. packet->setDataByName("unknown4", 1);
  11075. client->QueuePacket(packet->serialize());
  11076. safe_delete(packet);
  11077. }
  11078. }
  11079. void Commands::Command_AcceptResurrection(Client* client, Seperator* sep) {
  11080. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  11081. return;
  11082. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  11083. if(client->GetCurrentRez()->active)
  11084. client->AcceptResurrection();
  11085. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  11086. }
  11087. void Commands::Command_DeclineResurrection(Client* client, Seperator* sep) {
  11088. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  11089. return;
  11090. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  11091. if(client->GetCurrentRez()->active)
  11092. client->GetCurrentRez()->should_delete = true;
  11093. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  11094. }
  11095. void Commands::Switch_AA_Profile(Client* client, Seperator* sep) {
  11096. PrintSep(sep, "Switch_AA_Profile");
  11097. if (sep && sep->IsSet(0)) {
  11098. string type = sep->arg[0];
  11099. int8 newtemplate = atoul(sep->arg[1]);
  11100. if(client->GetVersion() > 561)
  11101. master_aa_list.DisplayAA(client, newtemplate, 1);
  11102. }
  11103. }
  11104. void Commands::Get_AA_Xml(Client* client, Seperator* sep) {
  11105. PrintSep(sep, "Get_AA_Xml");
  11106. if (sep && sep->IsSet(0)) {
  11107. string tabnum = sep->arg[0];
  11108. string spellid = sep->arg[1];
  11109. }
  11110. }
  11111. void Commands::Add_AA(Client* client, Seperator* sep) {
  11112. PrintSep(sep, "Add_AA");
  11113. if (sep && sep->IsSet(0)) {
  11114. int32 spell_id = atoul(sep->arg[1]);
  11115. int8 spell_tier = 0;
  11116. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  11117. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  11118. // addspellbookentry here
  11119. if(!data) {
  11120. LogWrite(COMMAND__ERROR, 0, "Command", "Error in Add_AA no data for spell_id %u spell_tier %u", spell_id, spell_tier);
  11121. return;
  11122. }
  11123. if (spell_tier >= data->maxRank) {
  11124. LogWrite(COMMAND__ERROR, 0, "Command", "Error in Add_AA spell_tier %u >= maxRank %u", spell_tier, data->maxRank);
  11125. return;
  11126. }
  11127. if (!spell_tier) {
  11128. spell_tier = 1;
  11129. }
  11130. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  11131. {
  11132. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  11133. if(spell)
  11134. {
  11135. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  11136. client->GetPlayer()->UnlockSpell(spell);
  11137. client->SendSpellUpdate(spell);
  11138. }
  11139. }
  11140. else
  11141. {
  11142. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1 );
  11143. if(spell)
  11144. {
  11145. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  11146. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  11147. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  11148. client->GetPlayer()->UnlockSpell(spell);
  11149. client->SendSpellUpdate(spell);
  11150. }
  11151. }
  11152. // cast spell here
  11153. if (!spell_tier)
  11154. spell_tier = 1;
  11155. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  11156. if (spell) {
  11157. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  11158. }
  11159. }
  11160. else {
  11161. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  11162. }
  11163. if(client->GetVersion() > 561)
  11164. master_aa_list.DisplayAA(client, 0, 0);
  11165. }
  11166. void Commands::Commit_AA_Profile(Client* client, Seperator* sep) {
  11167. PrintSep(sep, "Commit_AA_Profile");
  11168. if (sep && sep->IsSet(0)) {
  11169. }
  11170. }
  11171. void Commands::Begin_AA_Profile(Client* client, Seperator* sep) {
  11172. PrintSep(sep, "Begin_AA_Profile");
  11173. if (sep && sep->IsSet(0)) {
  11174. if(client->GetVersion() > 561)
  11175. master_aa_list.DisplayAA(client, 100, 2);
  11176. }
  11177. }
  11178. void Commands::Back_AA(Client* client, Seperator* sep) {
  11179. if (sep && sep->IsSet(0)) {
  11180. PrintSep(sep, "Back_AA");
  11181. }
  11182. }
  11183. void Commands::Remove_AA(Client* client, Seperator* sep) {
  11184. if (sep && sep->IsSet(0)) {
  11185. PrintSep(sep, "Remove_AA");
  11186. }
  11187. }
  11188. void Commands::Cancel_AA_Profile(Client* client, Seperator* sep) {
  11189. MasterAAList master_aa_list;
  11190. PrintSep(sep, "Cancel_AA_Profile");
  11191. if(client->GetVersion() > 561)
  11192. master_aa_list.DisplayAA(client, 0, 0);
  11193. }
  11194. void Commands::Save_AA_Profile(Client* client, Seperator* sep) {
  11195. if (sep && sep->IsSet(0)) {
  11196. PrintSep(sep, "Save_AA_Profile");
  11197. }
  11198. }
  11199. void Commands::Command_TargetItem(Client* client, Seperator* sep) {
  11200. if (!sep || sep->GetArgNumber() < 1 || !client->GetPlayer()) return;
  11201. if (!sep->IsNumber(0)) return;
  11202. int32 request_id = atoul(sep->arg[0]);
  11203. if (!sep->IsNumber(1)) return;
  11204. sint32 item_id = atoi(sep->arg[1]);
  11205. if (client->IsCurrentTransmuteID(request_id)) {
  11206. Transmute::HandleItemResponse(client, client->GetPlayer(), request_id, reinterpret_cast<int32&>(item_id));
  11207. }
  11208. else if (client->IsCurrentTransmuteID(item_id)) {
  11209. if (!sep->IsSet(2)) return;
  11210. if (sep->IsNumber(2) && atoi(sep->arg[2]) == 1) {
  11211. Transmute::HandleConfirmResponse(client, client->GetPlayer(), reinterpret_cast<int32&>(item_id));
  11212. }
  11213. }
  11214. }
  11215. void Commands::Command_FindSpawn(Client* client, Seperator* sep) {
  11216. if(sep)
  11217. client->GetCurrentZone()->FindSpawn(client, (char*)sep->argplus[0]);
  11218. }
  11219. void Commands::Command_MoveCharacter(Client* client, Seperator* sep) {
  11220. if(sep && sep->arg[0][0] && sep->arg[1][0])
  11221. {
  11222. char* name = sep->arg[0];
  11223. char* zoneName = sep->arg[1];
  11224. char query[256];
  11225. 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);
  11226. if (database.RunQuery(query, strnlen(query, 256)))
  11227. {
  11228. client->Message(CHANNEL_COLOR_YELLOW, "Ran query:%s", query);
  11229. }
  11230. else
  11231. client->Message(CHANNEL_COLOR_RED, "Query FAILED to run: %s", query);
  11232. }
  11233. }
  11234. void Commands::Command_Mood(Client* client, Seperator* sep) {
  11235. Player* player = client->GetPlayer();
  11236. if( sep && sep->arg[0] )
  11237. {
  11238. const char* value = sep->arg[0];
  11239. InfoStruct* info = player->GetInfoStruct();
  11240. int32 cid = client->GetCharacterID();
  11241. char* characterName = database.GetCharacterName(cid);
  11242. char tmp[1024]; // our emote string "xyz appears zyx"
  11243. //char properties vals
  11244. char* pname = "mood";
  11245. char* pval; // mood value
  11246. bool pt; //used to verify return from DB.
  11247. //This should never be seen.
  11248. sprintf(tmp, " ");
  11249. if( strncasecmp(value, "angry", strlen(value)) == 0 )
  11250. {
  11251. sprintf(tmp, "%s appears angry", characterName);
  11252. pval = "11852";
  11253. player->SetMoodState(11852, 1);
  11254. info->set_mood(11852);
  11255. pt = database.insertCharacterProperty(client, pname, pval);
  11256. }
  11257. else if( strncasecmp(value, "afraid", strlen(value)) == 0 )
  11258. {
  11259. sprintf(tmp, "%s appears afraid", characterName);
  11260. pval = "11851";
  11261. player->SetMoodState(11851, 1);
  11262. info->set_mood(11851);
  11263. pt = database.insertCharacterProperty(client, pname, pval);
  11264. }
  11265. else if( strncasecmp(value, "happy", strlen(value)) == 0 )
  11266. {
  11267. sprintf(tmp, "%s appears happy", characterName);
  11268. pval = "11854";
  11269. player->SetMoodState(11854, 1);
  11270. info->set_mood(11854);
  11271. pt = database.insertCharacterProperty(client, pname, pval);
  11272. }
  11273. else if( strncasecmp(value, "sad", strlen(value)) == 0 ) {
  11274. sprintf(tmp, "%s appears sad", characterName);
  11275. pval = "11856";
  11276. player->SetMoodState(11856, 1);
  11277. info->set_mood(11856);
  11278. pt = database.insertCharacterProperty(client, pname, pval);
  11279. }
  11280. else if( strncasecmp(value, "tired", strlen(value)) == 0 )
  11281. {
  11282. sprintf(tmp, "%s appears tired", characterName);
  11283. pval = "11857";
  11284. player->SetMoodState(11857, 1);
  11285. info->set_mood(11857);
  11286. pt = database.insertCharacterProperty(client, pname, pval);
  11287. }
  11288. else if( strncasecmp(value, "none", strlen(value)) == 0 )
  11289. {
  11290. //using 11855 mood_idle for none, I assume thats what its for?
  11291. pval = "11855";
  11292. player->SetMoodState(11855, 1);
  11293. info->set_mood(11855);
  11294. pt = database.insertCharacterProperty(client, pname, pval);
  11295. //return since we have nothing left to do. No emote for none.
  11296. return;
  11297. }else{
  11298. client->SimpleMessage(CHANNEL_NARRATIVE, "Listing Available Moods:");
  11299. client->SimpleMessage(CHANNEL_NARRATIVE, "none");
  11300. client->SimpleMessage(CHANNEL_NARRATIVE, "afraid");
  11301. client->SimpleMessage(CHANNEL_NARRATIVE, "angry");
  11302. client->SimpleMessage(CHANNEL_NARRATIVE, "happy");
  11303. client->SimpleMessage(CHANNEL_NARRATIVE, "sad");
  11304. client->SimpleMessage(CHANNEL_NARRATIVE, "tired");
  11305. return;
  11306. }
  11307. client->GetPlayer()->GetZone()->HandleChatMessage(0, 0, CHANNEL_EMOTE, tmp);
  11308. return;
  11309. }
  11310. client->SimpleMessage(CHANNEL_NARRATIVE, "Listing Available Moods:");
  11311. client->SimpleMessage(CHANNEL_NARRATIVE, "none");
  11312. client->SimpleMessage(CHANNEL_NARRATIVE, "afraid");
  11313. client->SimpleMessage(CHANNEL_NARRATIVE, "angry");
  11314. client->SimpleMessage(CHANNEL_NARRATIVE, "happy");
  11315. client->SimpleMessage(CHANNEL_NARRATIVE, "sad");
  11316. client->SimpleMessage(CHANNEL_NARRATIVE, "tired");
  11317. return;
  11318. }
  11319. /*
  11320. Function: Command_CancelEffect()
  11321. Purpose : Cancels (good) effect spells
  11322. Example : /cancel_effect spell_id - would cancel the spell with the <spell_id> value in spell effects list
  11323. */
  11324. void Commands::Command_CancelEffect(Client* client, Seperator* sep)
  11325. {
  11326. if (sep && sep->arg[0] && sep->IsNumber(0))
  11327. {
  11328. int32 spell_id = atoul(sep->arg[0]);
  11329. SpellEffects* effect = client->GetPlayer()->GetSpellEffect(spell_id);
  11330. if(!effect || effect->spell->spell->GetSpellData()->det_type) {
  11331. return;
  11332. }
  11333. MaintainedEffects* meffect = effect->caster->GetMaintainedSpell(spell_id);
  11334. if (!meffect || !meffect->spell || !meffect->spell->caster || !meffect->spell->caster->GetZone() ||
  11335. !meffect->spell->caster->GetZone()->GetSpellProcess()->DeleteCasterSpell(meffect->spell, "canceled", false, client->GetPlayer()))
  11336. client->Message(CHANNEL_COLOR_RED, "The spell effect could not be cancelled.");
  11337. }
  11338. }
  11339. /*
  11340. Function: Command_CurePlayer()
  11341. Purpose : Identifies spell to cast for cure based on type
  11342. Example : /cureplayer ??
  11343. https://eq2.fandom.com/wiki/Update:58
  11344. New command /cureplayer [playername|group or raid position][trauma|arcane|noxious|elemental|curse] optional [spell|potion]
  11345. Example: /cureplayer g0 noxious spell
  11346. Will attempt to cure yourself of a noxious detriment with only spells and without using potions (even if you have them).
  11347. Example: /cureplayer r4 noxious
  11348. Will attempt to cure the character in raid slot 4 of a noxious detriment using a spell or potion (whichever is available).
  11349. */
  11350. void Commands::Command_CurePlayer(Client* client, Seperator* sep)
  11351. {
  11352. Entity* target = nullptr;
  11353. bool use_spells = true;
  11354. bool use_potions = true;
  11355. if (sep && sep->arg[0] && sep->arg[1]) {
  11356. if(sep->arg[2]) {
  11357. std::string type(sep->arg[2]);
  11358. boost::algorithm::to_lower(type);
  11359. if(type == "potion")
  11360. use_spells = false;
  11361. else if(type == "spell")
  11362. use_potions = false;
  11363. }
  11364. if(strlen(sep->arg[0]) > 1 && isdigit(sep->arg[0][1])) {
  11365. int32 mapped_position = (int32)(sep->arg[0][1]) - 48;
  11366. // TODO: RAID Support ('r' argument)
  11367. if(sep->arg[0][0] == 'g' && !mapped_position) {
  11368. target = (Entity*)client->GetPlayer();
  11369. }
  11370. else {
  11371. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  11372. if (gmi && gmi->group_id) {
  11373. PlayerGroup* group = world.GetGroupManager()->GetGroup(gmi->group_id);
  11374. if(group) {
  11375. target = group->GetGroupMemberByPosition(client->GetPlayer(), mapped_position);
  11376. }
  11377. }
  11378. }
  11379. }
  11380. else {
  11381. Client* target_client = zone_list.GetClientByCharName(sep->arg[0]);
  11382. if(target_client && target_client->GetPlayer() && target_client->GetPlayer()->GetZone() == client->GetPlayer()->GetZone()) {
  11383. target = (Entity*)target_client->GetPlayer();
  11384. }
  11385. }
  11386. ItemEffectType type = EFFECT_CURE_TYPE_ALL;
  11387. bool successful_spell = false;
  11388. bool successful_potion = false;
  11389. if(target) {
  11390. SpellBookEntry* entry = nullptr;
  11391. std::string str(sep->arg[1]);
  11392. boost::algorithm::to_lower(str);
  11393. if(str == "arcane") {
  11394. type = EFFECT_CURE_TYPE_ARCANE;
  11395. // cure arcane spell missing in DB?
  11396. if(use_spells && rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Spells, CureArcaneSpellID)->GetInt32()) {
  11397. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Spells, CureArcaneSpellID)->GetInt32()); // cure noxious
  11398. }
  11399. }
  11400. else if(str == "trauma") {
  11401. type = EFFECT_CURE_TYPE_TRAUMA;
  11402. // cure trauma spell missing in DB?
  11403. if(use_spells && rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Spells, CureTraumaSpellID)->GetInt32()) {
  11404. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Spells, CureTraumaSpellID)->GetInt32()); // cure noxious
  11405. }
  11406. }
  11407. else if(str == "noxious") {
  11408. type = EFFECT_CURE_TYPE_NOXIOUS;
  11409. if(use_spells && rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Spells, CureNoxiousSpellID)->GetInt32()) {
  11410. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Spells, CureNoxiousSpellID)->GetInt32()); // cure noxious
  11411. }
  11412. }
  11413. else if(str == "curse") {
  11414. type = EFFECT_CURE_TYPE_CURSE;
  11415. if(use_spells && rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Spells, CureCurseSpellID)->GetInt32()) {
  11416. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Spells, CureCurseSpellID)->GetInt32()); // cure curse
  11417. }
  11418. }
  11419. else if(str == "magic") {
  11420. type = EFFECT_CURE_TYPE_MAGIC;
  11421. if(use_spells && rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Spells, CureMagicSpellID)->GetInt32()) {
  11422. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Spells, CureMagicSpellID)->GetInt32()); // cure magic
  11423. }
  11424. }
  11425. if(use_spells) {
  11426. // check if any of the specific cure types are available, if not then check the base cures
  11427. if(!entry && rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Spells, CureSpellID)->GetInt32()) {
  11428. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Spells, CureSpellID)->GetInt32()); // cure
  11429. }
  11430. if(entry && entry->spell_id) {
  11431. Spell* spell = master_spell_list.GetSpell(entry->spell_id, entry->tier);
  11432. target->GetZone()->ProcessSpell(spell, (Entity*)client->GetPlayer(), target, true, false);
  11433. successful_spell = true;
  11434. }
  11435. }
  11436. }
  11437. if(!successful_spell && use_potions && target && type != NO_EFFECT_TYPE) {
  11438. vector<Item*>* potential_items = client->GetItemsByEffectType(type, EFFECT_CURE_TYPE_ALL);
  11439. if (potential_items && potential_items->size() > 0) {
  11440. vector<Item*>::iterator itr;
  11441. for (itr = potential_items->begin(); itr != potential_items->end(); itr++)
  11442. {
  11443. Item* item = *itr;
  11444. if(client->UseItem(item, target)) {
  11445. successful_potion = true;
  11446. break;
  11447. }
  11448. }
  11449. }
  11450. safe_delete(potential_items);
  11451. }
  11452. }
  11453. }
  11454. /*
  11455. Function: Command_ShareQuest()
  11456. Purpose : Share quest with the group
  11457. Example : /share_quest [quest_id]
  11458. */
  11459. void Commands::Command_ShareQuest(Client* client, Seperator* sep)
  11460. {
  11461. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  11462. int32 quest_id = atoul(sep->arg[0]);
  11463. bool hasQuest = client->GetPlayer()->HasAnyQuest(quest_id);
  11464. if(hasQuest) {
  11465. Quest* quest = master_quest_list.GetQuest(quest_id, false);
  11466. if(quest) {
  11467. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  11468. if (gmi && gmi->group_id) {
  11469. PlayerGroup* group = world.GetGroupManager()->GetGroup(gmi->group_id);
  11470. if (group) {
  11471. group->ShareQuestWithGroup(client, quest);
  11472. }
  11473. }
  11474. }
  11475. }
  11476. else {
  11477. client->SimpleMessage(CHANNEL_COLOR_RED, "Cannot find quest.");
  11478. }
  11479. }
  11480. }
  11481. /*
  11482. Function: Command_Yell()
  11483. Purpose : Yell to break an encounter
  11484. Example : /yell
  11485. * Uses self target, encounter target or no target
  11486. */
  11487. void Commands::Command_Yell(Client* client, Seperator* sep) {
  11488. Entity* player = (Entity*)client->GetPlayer();
  11489. Spawn* res = nullptr;
  11490. Spawn* prev = nullptr;
  11491. bool cycleAll = false;
  11492. if (player->GetTarget() == player) {
  11493. cycleAll = true; // self target breaks all encounters
  11494. }
  11495. else if (player->GetTarget()) {
  11496. res = player->GetTarget(); // selected target other than self only dis-engages that encounter
  11497. }
  11498. if (res && !client->GetPlayer()->IsEngagedBySpawnID(res->GetID()))
  11499. return;
  11500. bool groupPermissionYell = true;
  11501. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  11502. // If the player has a group and has a target
  11503. if (gmi) {
  11504. deque<GroupMemberInfo*>::iterator itr;
  11505. world.GetGroupManager()->GroupLock(__FUNCTION__, __LINE__);
  11506. PlayerGroup* group = world.GetGroupManager()->GetGroup(gmi->group_id);
  11507. if (group && !group->GetGroupOptions()->default_yell && !gmi->leader) { // default_yell_method = 0 means leader only
  11508. groupPermissionYell = false;
  11509. }
  11510. world.GetGroupManager()->ReleaseGroupLock(__FUNCTION__, __LINE__);
  11511. }
  11512. if (!groupPermissionYell) {
  11513. LogWrite(COMMAND__ERROR, 0, "Command", "%s permission to yell denied due to group yell method set to leader only", client->GetPlayer()->GetName());
  11514. return;
  11515. }
  11516. bool alreadyYelled = false;
  11517. do {
  11518. if (!res && player->IsEngagedInEncounter(&res)) { // no target is set, dis-engage top of hated by list
  11519. }
  11520. if (!res || prev == res) {
  11521. return;
  11522. }
  11523. if (res->IsNPC() && ((NPC*)res)->Brain()) {
  11524. if (!alreadyYelled) {
  11525. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You yell for help!");
  11526. string yellMsg = std::string(client->GetPlayer()->GetName()) + " yelled for help!";
  11527. client->GetPlayer()->GetZone()->SimpleMessage(CHANNEL_COLOR_RED, yellMsg.c_str(), client->GetPlayer(), 35.0f, false);
  11528. client->GetPlayer()->GetZone()->SendYellPacket(client->GetPlayer());
  11529. }
  11530. alreadyYelled = true;
  11531. NPC* npc = (NPC*)res;
  11532. npc->Brain()->ClearEncounter();
  11533. npc->SetLockedNoLoot(ENCOUNTER_STATE_BROKEN);
  11534. npc->UpdateEncounterState(ENCOUNTER_STATE_BROKEN);
  11535. }
  11536. prev = res;
  11537. res = nullptr;
  11538. } while (cycleAll);
  11539. if (!player->IsEngagedInEncounter()) {
  11540. if (player->GetInfoStruct()->get_engaged_encounter()) {
  11541. player->GetInfoStruct()->set_engaged_encounter(0);
  11542. player->SetRegenValues((player->GetInfoStruct()->get_effective_level() > 0) ? player->GetInfoStruct()->get_effective_level() : player->GetLevel());
  11543. client->GetPlayer()->SetCharSheetChanged(true);
  11544. player->info_changed = true;
  11545. }
  11546. }
  11547. }
  11548. /*
  11549. Function: Command_SetAutoLootMode()
  11550. Purpose : Set player auto loot mode (0 = disabled, 1 = need/lotto, 2 = decline).
  11551. Example : /setautolootmode [mode]
  11552. */
  11553. void Commands::Command_SetAutoLootMode(Client* client, Seperator* sep) {
  11554. if (sep && sep->IsNumber(0)) {
  11555. int8 mode = atoul(sep->arg[0]);
  11556. switch (mode) {
  11557. case AutoLootMode::METHOD_DISABLED: {
  11558. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Disabled auto loot mode");
  11559. break;
  11560. }
  11561. case AutoLootMode::METHOD_ACCEPT: {
  11562. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Enabled auto loot mode for need and lotto.");
  11563. break;
  11564. }
  11565. default: {
  11566. mode = AutoLootMode::METHOD_DECLINE;
  11567. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Enabled auto loot mode to decline need and lotto.");
  11568. break;
  11569. }
  11570. }
  11571. client->GetPlayer()->GetInfoStruct()->set_group_auto_loot_method(mode);
  11572. database.insertCharacterProperty(client, CHAR_PROPERTY_AUTOLOOTMETHOD, (char*)std::to_string(mode).c_str());
  11573. client->SendDefaultGroupOptions();
  11574. }
  11575. }
  11576. /*
  11577. Function: Command_AutoAttack()
  11578. Purpose : Attack / Auto Attack
  11579. Example : /attack, /autoattack type
  11580. */
  11581. void Commands::Command_AutoAttack(Client* client, Seperator* sep) {
  11582. int8 type = 1;
  11583. bool update = false;
  11584. Player* player = client->GetPlayer();
  11585. if(!player)
  11586. return;
  11587. bool incombat = player->EngagedInCombat();
  11588. if(sep && sep->arg[0] && sep->IsNumber(0))
  11589. type = atoi(sep->arg[0]);
  11590. if(!client->GetPlayer()->Alive()){
  11591. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  11592. return;
  11593. }
  11594. if(type == 0){
  11595. if(incombat)
  11596. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You stop fighting.");
  11597. player->StopCombat(type);
  11598. update = true;
  11599. }
  11600. else {
  11601. if(type == 2){
  11602. player->InCombat(false);
  11603. if(incombat && player->GetRangeAttack()){
  11604. player->StopCombat(type);
  11605. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You stop fighting.");
  11606. update = true;
  11607. }
  11608. else{
  11609. player->SetRangeAttack(true);
  11610. player->InCombat(true, true);
  11611. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You start fighting.");
  11612. update = true;
  11613. }
  11614. }
  11615. else {
  11616. player->InCombat(false, true);
  11617. player->SetRangeAttack(false);
  11618. player->InCombat(true);
  11619. if(!incombat) {
  11620. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You start fighting.");
  11621. update = true;
  11622. }
  11623. }
  11624. /*else
  11625. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You cannot attack that!");*/
  11626. }
  11627. if(update) {
  11628. player->SetCharSheetChanged(true);
  11629. }
  11630. }
  11631. /*
  11632. Function: Command_Assist()
  11633. Purpose : Assist target
  11634. Example : /assist [name]
  11635. * Uses target or character name
  11636. */
  11637. void Commands::Command_Assist(Client* client, Seperator* sep) {
  11638. Entity* player = (Entity*)client->GetPlayer();
  11639. Spawn* res = nullptr;
  11640. if(sep && sep->arg[0]) {
  11641. if(!stricmp(sep->arg[0], "on")) {
  11642. database.insertCharacterProperty(client, CHAR_PROPERTY_ASSISTAUTOATTACK, "1");
  11643. return;
  11644. }
  11645. else if(!stricmp(sep->arg[0], "off")) {
  11646. database.insertCharacterProperty(client, CHAR_PROPERTY_ASSISTAUTOATTACK, "0");
  11647. return;
  11648. }
  11649. Client* otherClient = client->GetPlayer()->GetZone()->GetClientByName(sep->arg[0]);
  11650. if(otherClient) {
  11651. res = otherClient->GetPlayer();
  11652. }
  11653. }
  11654. if (player->GetTarget()) {
  11655. res = player->GetTarget(); // selected target other than self only dis-engages that encounter
  11656. }
  11657. if(res && res->GetTarget()) {
  11658. res = res->GetTarget();
  11659. }
  11660. if(res) {
  11661. client->TargetSpawn(res);
  11662. if(client->GetPlayer()->GetInfoStruct()->get_assist_auto_attack() && !player->EngagedInCombat()) {
  11663. Command_AutoAttack(client, nullptr);
  11664. }
  11665. }
  11666. }
  11667. /*
  11668. Function: Command_Target()
  11669. Purpose : Target spawn/player
  11670. Example : /target [name]
  11671. * Uses target or character name
  11672. */
  11673. void Commands::Command_Target(Client* client, Seperator* sep) {
  11674. Entity* player = (Entity*)client->GetPlayer();
  11675. Spawn* res = nullptr;
  11676. if(sep && sep->arg[0] && player->GetZone()) {
  11677. float max_distance = rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Player, MaxTargetCommandDistance)->GetFloat();
  11678. if(max_distance < 1.0f) {
  11679. max_distance = 10.0f;
  11680. }
  11681. player->GetZone()->SetPlayerTargetByName(client, (char*)sep->argplus[0], max_distance);
  11682. }
  11683. }
  11684. /*
  11685. Function: Command_Target_Pet()
  11686. Purpose : Target pet
  11687. Example : /target_pet
  11688. * Use to target pet
  11689. */
  11690. void Commands::Command_Target_Pet(Client* client, Seperator* sep) {
  11691. Entity* player = (Entity*)client->GetPlayer();
  11692. Spawn* res = client->GetPlayer()->GetPet();
  11693. if(res) {
  11694. client->TargetSpawn(res);
  11695. }
  11696. }
  11697. /*
  11698. Function: Command_WhoGroup()
  11699. Purpose : Lists all members of current group
  11700. Example : /whogroup
  11701. */
  11702. void Commands::Command_WhoGroup(Client* client, Seperator* sep) {
  11703. Entity* player = (Entity*)client->GetPlayer();
  11704. if(player->GetGroupMemberInfo()) {
  11705. world.GetGroupManager()->SendWhoGroupMembers(client, player->GetGroupMemberInfo()->group_id);
  11706. }
  11707. else {
  11708. client->SimpleMessage(CHANNEL_COLOR_RED, "You are not currently in a group.");
  11709. }
  11710. }
  11711. /*
  11712. Function: Command_WhoRaid()
  11713. Purpose : Lists all members of raid
  11714. Example : /whoraid
  11715. */
  11716. void Commands::Command_WhoRaid(Client* client, Seperator* sep) {
  11717. Entity* player = (Entity*)client->GetPlayer();
  11718. if(player->GetGroupMemberInfo()) {
  11719. world.GetGroupManager()->SendWhoRaidMembers(client, player->GetGroupMemberInfo()->group_id);
  11720. }
  11721. else {
  11722. client->SimpleMessage(CHANNEL_COLOR_RED, "You are not currently in a group or raid.");
  11723. }
  11724. }
  11725. /*
  11726. Function: Command_RaidInvite()
  11727. Purpose : Invites a group to the raid
  11728. Example : /raidinvite
  11729. */
  11730. void Commands::Command_RaidInvite(Client* client, Seperator* sep) {
  11731. Entity* target = nullptr;
  11732. if( sep && sep->arg[0] ) {
  11733. Client* target_client = zone_list.GetClientByCharName(sep->arg[0]);
  11734. if(target_client)
  11735. target = (Entity*)target_client->GetPlayer();
  11736. }
  11737. if(!target) {
  11738. if(client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsEntity())
  11739. target = (Entity*)client->GetPlayer()->GetTarget();
  11740. }
  11741. world.GetGroupManager()->SendRaidInvite(client, target);
  11742. }
  11743. /*
  11744. Function: Command_Raid_Looter()
  11745. Purpose : Adds a looter to the raid loot list
  11746. Example : /raid_looter <name>
  11747. */
  11748. void Commands::Command_Raid_Looter(Client* client, Seperator* sep) {
  11749. if(!client->GetPlayer()->GetGroupMemberInfo() || client->GetPlayer()->GetGroupMemberInfo()->leader)
  11750. return;
  11751. Entity* target = nullptr;
  11752. if( sep && sep->arg[0] ) {
  11753. Client* target_client = zone_list.GetClientByCharName(sep->arg[0]);
  11754. if(target_client)
  11755. target = (Entity*)target_client->GetPlayer();
  11756. }
  11757. if(!target) {
  11758. if(client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsEntity())
  11759. target = (Entity*)client->GetPlayer()->GetTarget();
  11760. }
  11761. bool isLeaderRaid = world.GetGroupManager()->IsInRaidGroup(client->GetPlayer()->GetGroupMemberInfo()->group_id, client->GetPlayer()->GetGroupMemberInfo()->group_id, true);
  11762. if(isLeaderRaid && target && target->IsEntity()) {
  11763. if(((Entity*)target)->GetGroupMemberInfo() && world.GetGroupManager()->IsInRaidGroup(client->GetPlayer()->GetGroupMemberInfo()->group_id, ((Entity*)target)->GetGroupMemberInfo()->group_id, false)) {
  11764. if(((Entity*)target)->GetGroupMemberInfo()->is_raid_looter) {
  11765. client->Message(CHANNEL_COLOR_YELLOW, "%s removed as a raid looter.", target->GetName());
  11766. ((Entity*)target)->GetGroupMemberInfo()->is_raid_looter = false;
  11767. }
  11768. else {
  11769. client->Message(CHANNEL_COLOR_YELLOW, "%s added as a raid looter.", target->GetName());
  11770. ((Entity*)target)->GetGroupMemberInfo()->is_raid_looter = true;
  11771. }
  11772. }
  11773. }
  11774. }
  11775. /*
  11776. Function: Command_KickFromGroup()
  11777. Purpose : Kick a player from a group
  11778. Example : /kickfromgroup <name>
  11779. */
  11780. void Commands::Command_KickFromGroup(Client* client, Seperator* sep) {
  11781. Entity* target = nullptr;
  11782. Client* target_client = nullptr;
  11783. if( sep && sep->arg[0] ) {
  11784. target_client = zone_list.GetClientByCharName(sep->arg[0]);
  11785. if(target_client) {
  11786. target = target_client->GetPlayer();
  11787. }
  11788. }
  11789. if(!target) {
  11790. if(client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsEntity())
  11791. target = (Entity*)client->GetPlayer()->GetTarget();
  11792. if(target && target->IsPlayer())
  11793. target_client = ((Player*)target)->GetClient();
  11794. }
  11795. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  11796. if (gmi && gmi->leader && target && target->GetGroupMemberInfo() && gmi->group_id == target->GetGroupMemberInfo()->group_id) {
  11797. int32 group_id = gmi->group_id;
  11798. world.GetGroupManager()->RemoveGroupMember(group_id, target);
  11799. if (!world.GetGroupManager()->IsGroupIDValid(group_id)) {
  11800. // leader->Message(CHANNEL_COLOR_GROUP, "%s has left the group.", client->GetPlayer()->GetName());
  11801. }
  11802. else {
  11803. world.GetGroupManager()->GroupMessage(group_id, "%s has been removed from the group.", target->GetName());
  11804. }
  11805. if(target_client)
  11806. target_client->SimpleMessage(CHANNEL_GROUP_CHAT, "You have been kicked from the group");
  11807. }
  11808. }
  11809. /*
  11810. Function: Command_KickFromRaid()
  11811. Purpose : Kick a group from a raid
  11812. Example : /kickfromraid <name>
  11813. */
  11814. void Commands::Command_KickFromRaid(Client* client, Seperator* sep) {
  11815. Entity* target = nullptr;
  11816. Client* target_client = nullptr;
  11817. if( sep && sep->arg[0] ) {
  11818. target_client = zone_list.GetClientByCharName(sep->arg[0]);
  11819. if(target_client) {
  11820. target = target_client->GetPlayer();
  11821. }
  11822. }
  11823. if(!target) {
  11824. if(client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsEntity())
  11825. target = (Entity*)client->GetPlayer()->GetTarget();
  11826. if(target && target->IsPlayer())
  11827. target_client = ((Player*)target)->GetClient();
  11828. }
  11829. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  11830. if(gmi && gmi->leader && target && target->GetGroupMemberInfo() && world.GetGroupManager()->IsInRaidGroup(gmi->group_id, target->GetGroupMemberInfo()->group_id, false) &&
  11831. world.GetGroupManager()->IsInRaidGroup(gmi->group_id, gmi->group_id, true)) {
  11832. GroupOptions goptions;
  11833. world.GetGroupManager()->GetDefaultGroupOptions(gmi->group_id, &goptions);
  11834. world.GetGroupManager()->RemoveGroupFromRaid(gmi->group_id, target->GetGroupMemberInfo()->group_id);
  11835. std::vector<int32> raidGroups;
  11836. world.GetGroupManager()->GetRaidGroups(gmi->group_id, &raidGroups);
  11837. peer_manager.sendPeersNewGroupRequest("", 0, gmi->group_id, "", "", &goptions, "", &raidGroups, true);
  11838. std::vector<int32> emptyRaid;
  11839. peer_manager.sendPeersNewGroupRequest("", 0, target->GetGroupMemberInfo()->group_id, "", "", &goptions, "", &emptyRaid, true);
  11840. }
  11841. }
  11842. /*
  11843. Function: Command_LeaveRaid()
  11844. Purpose : Leave a raid
  11845. Example : /leaveraid
  11846. */
  11847. void Commands::Command_LeaveRaid(Client* client, Seperator* sep) {
  11848. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  11849. int32 orig_group_id = 0;
  11850. if(gmi && gmi->leader && world.GetGroupManager()->IsInRaidGroup(gmi->group_id, gmi->group_id, false)) {
  11851. orig_group_id = gmi->group_id;
  11852. GroupOptions goptions;
  11853. world.GetGroupManager()->GetDefaultGroupOptions(gmi->group_id, &goptions);
  11854. std::vector<int32> raidGroups;
  11855. world.GetGroupManager()->GetRaidGroups(gmi->group_id, &raidGroups);
  11856. std::vector<int32>::iterator cur_group_itr = std::find(raidGroups.begin(), raidGroups.end(), gmi->group_id);
  11857. if(cur_group_itr != raidGroups.end())
  11858. raidGroups.erase(cur_group_itr);
  11859. bool sendEmpty = false;
  11860. std::vector<int32> emptyRaid;
  11861. if(raidGroups.size() < 2) {
  11862. sendEmpty = true;
  11863. }
  11864. for(cur_group_itr = raidGroups.begin(); cur_group_itr != raidGroups.end(); cur_group_itr++) {
  11865. if(sendEmpty) {
  11866. world.GetGroupManager()->ClearGroupRaid((*cur_group_itr));
  11867. peer_manager.sendPeersNewGroupRequest("", 0, (*cur_group_itr), "", "", &goptions, "", &emptyRaid, true);
  11868. world.GetGroupManager()->SendGroupUpdate((*cur_group_itr), nullptr, true);
  11869. }
  11870. else {
  11871. world.GetGroupManager()->ReplaceRaidGroups((*cur_group_itr), &raidGroups);
  11872. }
  11873. }
  11874. if(!sendEmpty) {
  11875. peer_manager.sendPeersNewGroupRequest("", 0, orig_group_id, "", "", &goptions, "", &raidGroups, true);
  11876. }
  11877. world.GetGroupManager()->ClearGroupRaid(orig_group_id);
  11878. world.GetGroupManager()->SendGroupUpdate(orig_group_id, nullptr, true);
  11879. peer_manager.sendPeersNewGroupRequest("", 0, orig_group_id, "", "", &goptions, "", &emptyRaid, true);
  11880. }
  11881. }
  11882. /*
  11883. Function: Command_Split()
  11884. Purpose : split coin to group
  11885. Example : /split {plat} {gold} {silver} {copper}
  11886. */
  11887. void Commands::Command_Split(Client* client, Seperator* sep) {
  11888. // int32 item_id = atoul(sep->arg[0,1,2,3]);
  11889. int32 plat = 0, gold = 0, silver = 0, copper = 0;
  11890. if(sep->IsNumber(0))
  11891. plat = atoul(sep->arg[0]);
  11892. if(sep->IsNumber(1))
  11893. gold = atoul(sep->arg[1]);
  11894. if(sep->IsNumber(2))
  11895. silver = atoul(sep->arg[2]);
  11896. if(sep->IsNumber(3))
  11897. copper = atoul(sep->arg[3]);
  11898. world.GetGroupManager()->SplitWithGroupOrRaid(client, plat, gold, silver, copper);
  11899. }
  11900. /*
  11901. Function: Command_RaidSay()
  11902. Purpose : Speak to raid members
  11903. Example : /raidsay {message}, /rsay {message}
  11904. */
  11905. void Commands::Command_RaidSay(Client* client, Seperator* sep) {
  11906. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  11907. if(sep && sep->arg[0] && gmi) {
  11908. world.GetGroupManager()->GroupLock(__FUNCTION__, __LINE__);
  11909. int32 spawn_group_id = gmi->group_id;
  11910. PlayerGroup* spawn_group = world.GetGroupManager()->GetGroup(spawn_group_id);
  11911. bool israidgroup = (spawn_group && spawn_group->IsGroupRaid());
  11912. world.GetGroupManager()->ReleaseGroupLock(__FUNCTION__, __LINE__);
  11913. if(israidgroup) {
  11914. world.GetGroupManager()->GroupChatMessage(gmi->group_id, client->GetPlayer(), client->GetPlayer()->GetCurrentLanguage(), sep->argplus[0], CHANNEL_RAID_SAY);
  11915. peer_manager.SendPeersChannelMessage(gmi->group_id, std::string(client->GetPlayer()->GetName()), std::string(sep->argplus[0]), CHANNEL_RAID_SAY, client->GetPlayer()->GetCurrentLanguage());
  11916. }
  11917. }
  11918. }