Commands.cpp 433 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899
  1. /*
  2. EQ2Emulator: Everquest II Server Emulator
  3. Copyright (C) 2007 EQ2EMulator Development Team (http://www.eq2emulator.net)
  4. This file is part of EQ2Emulator.
  5. EQ2Emulator is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. EQ2Emulator is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with EQ2Emulator. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #include <sys/types.h>
  17. #include <boost/algorithm/string/predicate.hpp>
  18. #include <boost/algorithm/string.hpp>
  19. #include "Commands.h"
  20. #include "../ClientPacketFunctions.h"
  21. #include "../../common/version.h"
  22. #include "../../common/seperator.h"
  23. #include "../../common/servertalk.h"
  24. #include "../WorldDatabase.h"
  25. #include "../World.h"
  26. #include "../../common/ConfigReader.h"
  27. #include "../VisualStates.h"
  28. #include "../../common/debug.h"
  29. #include "../LuaInterface.h"
  30. #include "../Quests.h"
  31. #include "../client.h"
  32. #include "../NPC.h"
  33. #include "../Guilds/Guild.h"
  34. #include "../SpellProcess.h"
  35. #include "../Tradeskills/Tradeskills.h"
  36. #include "../../common/Log.h"
  37. #include "../../common/MiscFunctions.h"
  38. #include "../Languages.h"
  39. #include "../Traits/Traits.h"
  40. #include "../Chat/Chat.h"
  41. #include "../Rules/Rules.h"
  42. #include "../AltAdvancement/AltAdvancement.h"
  43. #include "../RaceTypes/RaceTypes.h"
  44. #include "../classes.h"
  45. #include "../Transmute.h"
  46. #include "../Bots/Bot.h"
  47. extern WorldDatabase database;
  48. extern MasterSpellList master_spell_list;
  49. extern MasterTraitList master_trait_list;
  50. extern MasterRecipeList master_recipe_list;
  51. extern MasterRecipeBookList master_recipebook_list;
  52. extern World world;
  53. extern ClientList client_list;
  54. extern ConfigReader configReader;
  55. extern VisualStates visual_states;
  56. extern ZoneList zone_list;
  57. extern LuaInterface* lua_interface;
  58. extern MasterQuestList master_quest_list;
  59. extern MasterCollectionList master_collection_list;
  60. extern MasterSkillList master_skill_list;
  61. extern MasterFactionList master_faction_list;
  62. extern GuildList guild_list;
  63. extern MasterLanguagesList master_languages_list;
  64. extern Chat chat;
  65. extern RuleManager rule_manager;
  66. extern MasterAAList master_aa_list;
  67. extern MasterRaceTypeList race_types_list;
  68. extern Classes classes;
  69. //devn00b: Fix for linux builds since we dont use stricmp we use strcasecmp
  70. #if defined(__GNUC__)
  71. #define stricmp strcasecmp
  72. #define strnicmp strncasecmp
  73. #endif
  74. EQ2Packet* RemoteCommands::serialize(){
  75. buffer.clear();
  76. vector<EQ2_RemoteCommandString>::iterator command_list;
  77. buffer.append((char*)&num_commands, sizeof(int16));
  78. for( command_list = commands.begin(); command_list != commands.end(); command_list++ ) {
  79. AddDataCommand(&(*command_list));
  80. }
  81. EQ2Packet* app = new EQ2Packet(OP_SetRemoteCmdsMsg, (uchar*)buffer.c_str(), buffer.length() + 1);
  82. return app;
  83. }
  84. Commands::Commands(){
  85. remote_commands = new RemoteCommands();
  86. spawn_set_values["list"] = SPAWN_SET_VALUE_LIST;
  87. spawn_set_values["name"] = SPAWN_SET_VALUE_NAME;
  88. spawn_set_values["level"] = SPAWN_SET_VALUE_LEVEL; // TODO: Fix this, min_level, max_level
  89. spawn_set_values["difficulty"] = SPAWN_SET_VALUE_DIFFICULTY;
  90. spawn_set_values["model_type"] = SPAWN_SET_VALUE_MODEL_TYPE;
  91. spawn_set_values["class"] = SPAWN_SET_VALUE_CLASS;
  92. spawn_set_values["gender"] = SPAWN_SET_VALUE_GENDER;
  93. spawn_set_values["show_name"] = SPAWN_SET_VALUE_SHOW_NAME;
  94. spawn_set_values["attackable"] = SPAWN_SET_VALUE_ATTACKABLE;
  95. spawn_set_values["show_level"] = SPAWN_SET_VALUE_SHOW_LEVEL;
  96. spawn_set_values["targetable"] = SPAWN_SET_VALUE_TARGETABLE;
  97. spawn_set_values["show_command_icon"] = SPAWN_SET_VALUE_SHOW_COMMAND_ICON;
  98. spawn_set_values["display_hand_icon"] = SPAWN_SET_VALUE_HAND_ICON;
  99. spawn_set_values["hair_type"] = SPAWN_SET_VALUE_HAIR_TYPE;
  100. spawn_set_values["facial_hair_type"] = SPAWN_SET_VALUE_FACIAL_HAIR_TYPE;
  101. spawn_set_values["wing_type"] = SPAWN_SET_VALUE_WING_TYPE;
  102. spawn_set_values["chest_type"] = SPAWN_SET_VALUE_CHEST_TYPE;
  103. spawn_set_values["legs_type"] = SPAWN_SET_VALUE_LEGS_TYPE;
  104. spawn_set_values["soga_hair_type"] = SPAWN_SET_VALUE_SOGA_HAIR_TYPE;
  105. spawn_set_values["soga_facial_hair_type"] = SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE;
  106. spawn_set_values["soga_model_type"] = SPAWN_SET_VALUE_SOGA_MODEL_TYPE;
  107. spawn_set_values["size"] = SPAWN_SET_VALUE_SIZE;
  108. spawn_set_values["hp"] = SPAWN_SET_VALUE_HP;
  109. spawn_set_values["power"] = SPAWN_SET_VALUE_POWER;
  110. spawn_set_values["heroic"] = SPAWN_SET_VALUE_HEROIC;
  111. spawn_set_values["respawn"] = SPAWN_SET_VALUE_RESPAWN;
  112. spawn_set_values["x"] = SPAWN_SET_VALUE_X;
  113. spawn_set_values["y"] = SPAWN_SET_VALUE_Y;
  114. spawn_set_values["z"] = SPAWN_SET_VALUE_Z;
  115. spawn_set_values["heading"] = SPAWN_SET_VALUE_HEADING;
  116. spawn_set_values["location"] = SPAWN_SET_VALUE_LOCATION;
  117. spawn_set_values["command_primary"] = SPAWN_SET_VALUE_COMMAND_PRIMARY;
  118. spawn_set_values["command_secondary"] = SPAWN_SET_VALUE_COMMAND_SECONDARY;
  119. spawn_set_values["visual_state"] = SPAWN_SET_VALUE_VISUAL_STATE;
  120. spawn_set_values["action_state"] = SPAWN_SET_VALUE_ACTION_STATE;
  121. spawn_set_values["mood_state"] = SPAWN_SET_VALUE_MOOD_STATE;
  122. spawn_set_values["initial_state"] = SPAWN_SET_VALUE_INITIAL_STATE;
  123. spawn_set_values["activity_state"] = SPAWN_SET_VALUE_ACTIVITY_STATE;
  124. spawn_set_values["collision_radius"] = SPAWN_SET_VALUE_COLLISION_RADIUS;
  125. spawn_set_values["faction"] = SPAWN_SET_VALUE_FACTION;
  126. spawn_set_values["spawn_script"] = SPAWN_SET_VALUE_SPAWN_SCRIPT;
  127. spawn_set_values["spawnentry_script"] = SPAWN_SET_VALUE_SPAWNENTRY_SCRIPT;
  128. spawn_set_values["spawnlocation_script"] = SPAWN_SET_VALUE_SPAWNLOCATION_SCRIPT;
  129. spawn_set_values["sub_title"] = SPAWN_SET_VALUE_SUB_TITLE;
  130. spawn_set_values["expire"] = SPAWN_SET_VALUE_EXPIRE;
  131. spawn_set_values["expire_offset"] = SPAWN_SET_VALUE_EXPIRE_OFFSET;
  132. spawn_set_values["x_offset"] = SPAWN_SET_VALUE_X_OFFSET;
  133. spawn_set_values["y_offset"] = SPAWN_SET_VALUE_Y_OFFSET;
  134. spawn_set_values["z_offset"] = SPAWN_SET_VALUE_Z_OFFSET;
  135. spawn_set_values["device_id"] = SPAWN_SET_VALUE_DEVICE_ID;
  136. spawn_set_values["pitch"] = SPAWN_SET_VALUE_PITCH;
  137. spawn_set_values["roll"] = SPAWN_SET_VALUE_ROLL;
  138. spawn_set_values["hide_hood"] = SPAWN_SET_VALUE_HIDE_HOOD;
  139. spawn_set_values["emote_state"] = SPAWN_SET_VALUE_EMOTE_STATE;
  140. spawn_set_values["icon"] = SPAWN_SET_VALUE_ICON;
  141. spawn_set_values["prefix"] = SPAWN_SET_VALUE_PREFIX;
  142. spawn_set_values["suffix"] = SPAWN_SET_VALUE_SUFFIX;
  143. spawn_set_values["lastname"] = SPAWN_SET_VALUE_LASTNAME;
  144. spawn_set_values["expansion_flag"] = SPAWN_SET_VALUE_EXPANSION_FLAG;
  145. spawn_set_values["holiday_flag"] = SPAWN_SET_VALUE_HOLIDAY_FLAG;
  146. spawn_set_values["merchant_min_level"] = SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL;
  147. spawn_set_values["merchant_max_level"] = SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL;
  148. spawn_set_values["skin_color"] = SPAWN_SET_SKIN_COLOR;
  149. spawn_set_values["aaxp_rewards"] = SPAWN_SET_AAXP_REWARDS;
  150. spawn_set_values["hair_color1"] = SPAWN_SET_HAIR_COLOR1;
  151. spawn_set_values["hair_color2"] = SPAWN_SET_HAIR_COLOR2;
  152. spawn_set_values["hair_type_color"] = SPAWN_SET_HAIR_TYPE_COLOR;
  153. spawn_set_values["hair_face_color"] = SPAWN_SET_HAIR_FACE_COLOR;
  154. spawn_set_values["hair_type_highlight_color"] = SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR;
  155. spawn_set_values["face_hairlight_color"] = SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR;
  156. spawn_set_values["hair_highlight"] = SPAWN_SET_HAIR_HIGHLIGHT;
  157. spawn_set_values["model_color"] = SPAWN_SET_MODEL_COLOR;
  158. spawn_set_values["eye_color"] = SPAWN_SET_EYE_COLOR;
  159. spawn_set_values["soga_skin_color"] = SPAWN_SET_SOGA_SKIN_COLOR;
  160. spawn_set_values["soga_hair_color1"] = SPAWN_SET_SOGA_HAIR_COLOR1;
  161. spawn_set_values["soga_hair_color2"] = SPAWN_SET_SOGA_HAIR_COLOR2;
  162. spawn_set_values["soga_hair_type_color"] = SPAWN_SET_SOGA_HAIR_TYPE_COLOR;
  163. spawn_set_values["soga_hair_face_color"] = SPAWN_SET_SOGA_HAIR_FACE_COLOR;
  164. spawn_set_values["soga_hair_type_highlight_color"] = SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR;
  165. spawn_set_values["soga_face_hairlight_color"] = SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR;
  166. spawn_set_values["soga_hair_highlight"] = SPAWN_SET_SOGA_HAIR_HIGHLIGHT;
  167. spawn_set_values["soga_model_color"] = SPAWN_SET_SOGA_MODEL_COLOR;
  168. spawn_set_values["soga_eye_color"] = SPAWN_SET_SOGA_EYE_COLOR;
  169. spawn_set_values["cheek_type"] = SPAWN_SET_CHEEK_TYPE;
  170. spawn_set_values["chin_type"] = SPAWN_SET_CHIN_TYPE;
  171. spawn_set_values["ear_type"] = SPAWN_SET_EAR_TYPE;
  172. spawn_set_values["eye_brow_type"] = SPAWN_SET_EYE_BROW_TYPE;
  173. spawn_set_values["eye_type"] = SPAWN_SET_EYE_TYPE;
  174. spawn_set_values["lip_type"] = SPAWN_SET_LIP_TYPE;
  175. spawn_set_values["nose_type"] = SPAWN_SET_NOSE_TYPE;
  176. spawn_set_values["body_size"] = SPAWN_SET_BODY_SIZE;
  177. spawn_set_values["body_age"] = SPAWN_SET_BODY_AGE;
  178. spawn_set_values["soga_cheek_type"] = SPAWN_SET_SOGA_CHEEK_TYPE;
  179. spawn_set_values["soga_chin_type"] = SPAWN_SET_SOGA_CHIN_TYPE;
  180. spawn_set_values["soga_ear_type"] = SPAWN_SET_SOGA_EAR_TYPE;
  181. spawn_set_values["soga_eye_brow_type"] = SPAWN_SET_SOGA_EYE_BROW_TYPE;
  182. spawn_set_values["soga_eye_type"] = SPAWN_SET_SOGA_EYE_TYPE;
  183. spawn_set_values["soga_lip_type"] = SPAWN_SET_SOGA_LIP_TYPE;
  184. spawn_set_values["soga_nose_type"] = SPAWN_SET_SOGA_NOSE_TYPE;
  185. spawn_set_values["soga_body_size"] = SPAWN_SET_SOGA_BODY_SIZE;
  186. spawn_set_values["soga_body_age"] = SPAWN_SET_SOGA_BODY_AGE;
  187. spawn_set_values["attack_type"] = SPAWN_SET_ATTACK_TYPE;
  188. spawn_set_values["race_type"] = SPAWN_SET_RACE_TYPE;
  189. spawn_set_values["loot_tier"] = SPAWN_SET_LOOT_TIER;
  190. spawn_set_values["loot_drop_type"] = SPAWN_SET_LOOT_DROP_TYPE;
  191. zone_set_values["expansion_id"] = ZONE_SET_VALUE_EXPANSION_ID;
  192. zone_set_values["name"] = ZONE_SET_VALUE_NAME;
  193. zone_set_values["file"] = ZONE_SET_VALUE_FILE ;
  194. zone_set_values["description"] = ZONE_SET_VALUE_DESCRIPTION;
  195. zone_set_values["safe_x"] = ZONE_SET_VALUE_SAFE_X;
  196. zone_set_values["safe_y"] = ZONE_SET_VALUE_SAFE_Y;
  197. zone_set_values["safe_z"] = ZONE_SET_VALUE_SAFE_Z;
  198. zone_set_values["underworld"] = ZONE_SET_VALUE_UNDERWORLD;
  199. zone_set_values["min_recommended"] = ZONE_SET_VALUE_MIN_RECOMMENDED;
  200. zone_set_values["max_recommended"] = ZONE_SET_VALUE_MAX_RECOMMENDED;
  201. zone_set_values["zone_type"] = ZONE_SET_VALUE_ZONE_TYPE;
  202. zone_set_values["always_loaded"] = ZONE_SET_VALUE_ALWAYS_LOADED;
  203. zone_set_values["city_zone"] = ZONE_SET_VALUE_CITY_ZONE;
  204. zone_set_values["weather_allowed"] = ZONE_SET_VALUE_WEATHER_ALLOWED;
  205. zone_set_values["min_status"] = ZONE_SET_VALUE_MIN_STATUS;
  206. zone_set_values["min_level"] = ZONE_SET_VALUE_MIN_LEVEL;
  207. zone_set_values["start_zone"] = ZONE_SET_VALUE_START_ZONE;
  208. zone_set_values["instance_type"] = ZONE_SET_VALUE_INSTANCE_TYPE;
  209. zone_set_values["default_reenter_time"] = ZONE_SET_VALUE_DEFAULT_REENTER_TIME;
  210. zone_set_values["default_reset_time"] = ZONE_SET_VALUE_DEFAULT_RESET_TIME;
  211. zone_set_values["default_lockout_time"] = ZONE_SET_VALUE_DEFAULT_LOCKOUT_TIME;
  212. zone_set_values["force_group_to_zone"] = ZONE_SET_VALUE_FORCE_GROUP_TO_ZONE;
  213. zone_set_values["lua_script"] = ZONE_SET_VALUE_LUA_SCRIPT;
  214. zone_set_values["shutdown_timer"] = ZONE_SET_VALUE_SHUTDOWN_TIMER;
  215. zone_set_values["zone_motd"] = ZONE_SET_VALUE_ZONE_MOTD;
  216. }
  217. Commands::~Commands() {
  218. safe_delete(remote_commands);
  219. }
  220. int32 Commands::GetSpawnSetType(string val){
  221. if(spawn_set_values.count(val) > 0)
  222. return spawn_set_values[val];
  223. return 0xFFFFFFFF;
  224. }
  225. bool Commands::SetSpawnCommand(Client* client, Spawn* target, int8 type, const char* value, bool send_update, bool temporary, string* temp_value, int8 index){
  226. if(!target)
  227. return false;
  228. int32 val = 0;
  229. try{
  230. if(type != SPAWN_SET_VALUE_NAME &&
  231. !(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))
  232. {
  233. switch(type)
  234. {
  235. case SPAWN_SET_SKIN_COLOR:
  236. case SPAWN_SET_HAIR_COLOR1:
  237. case SPAWN_SET_HAIR_COLOR2:
  238. case SPAWN_SET_HAIR_TYPE_COLOR:
  239. case SPAWN_SET_HAIR_FACE_COLOR:
  240. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  241. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  242. case SPAWN_SET_HAIR_HIGHLIGHT:
  243. case SPAWN_SET_EYE_COLOR:
  244. case SPAWN_SET_SOGA_SKIN_COLOR:
  245. case SPAWN_SET_SOGA_HAIR_COLOR1:
  246. case SPAWN_SET_SOGA_HAIR_COLOR2:
  247. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  248. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  249. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  250. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  251. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  252. case SPAWN_SET_SOGA_EYE_COLOR:
  253. case SPAWN_SET_RACE_TYPE:
  254. // ignore these are colors can't pass as a integer value
  255. break;
  256. default:
  257. val = atoul(value);
  258. }
  259. }
  260. }
  261. catch(...){
  262. if(client)
  263. client->Message(CHANNEL_COLOR_RED, "Invalid numeric spawn value: %s", value);
  264. return false;
  265. }
  266. if(temporary){
  267. char tmp[128] = {0};
  268. switch(type){
  269. case SPAWN_SET_VALUE_NAME:{
  270. sprintf(tmp, "%s", target->GetName());
  271. target->SetName(value);
  272. if(target->GetZone())
  273. target->GetZone()->SendUpdateTitles(target);
  274. break;
  275. }
  276. case SPAWN_SET_VALUE_X_OFFSET:
  277. {
  278. sprintf(tmp, "%f", target->GetXOffset());
  279. target->SetXOffset(float(val));
  280. break;
  281. }
  282. case SPAWN_SET_VALUE_Y_OFFSET:
  283. {
  284. sprintf(tmp, "%f", target->GetYOffset());
  285. target->SetYOffset(float(val));
  286. break;
  287. }
  288. case SPAWN_SET_VALUE_Z_OFFSET:
  289. {
  290. sprintf(tmp, "%f", target->GetZOffset());
  291. target->SetZOffset(float(val));
  292. break;
  293. }
  294. case SPAWN_SET_VALUE_EXPIRE: {
  295. sprintf(tmp, "%u", target->GetExpireTime());
  296. target->SetExpireTime(val);
  297. break;
  298. }
  299. case SPAWN_SET_VALUE_EXPIRE_OFFSET: {
  300. sprintf(tmp, "%u", target->GetExpireOffsetTime());
  301. target->SetExpireOffsetTime(val);
  302. break;
  303. }
  304. case SPAWN_SET_VALUE_SUB_TITLE: {
  305. sprintf(tmp, "%s", target->GetSubTitle());
  306. target->SetSubTitle(value);
  307. if(target->GetZone())
  308. target->GetZone()->SendUpdateTitles(target);
  309. break;
  310. }
  311. case SPAWN_SET_VALUE_LEVEL:{
  312. sprintf(tmp, "%i", target->GetLevel());
  313. target->SetLevel(val, send_update);
  314. break;
  315. }
  316. case SPAWN_SET_VALUE_DIFFICULTY:{
  317. sprintf(tmp, "%i", target->GetEncounterLevel());
  318. target->SetEncounterLevel(val, send_update);
  319. break;
  320. }
  321. case SPAWN_SET_VALUE_MODEL_TYPE:{
  322. sprintf(tmp, "%i", target->GetModelType());
  323. target->SetModelType(val, send_update);
  324. break;
  325. }
  326. case SPAWN_SET_VALUE_CLASS:{
  327. sprintf(tmp, "%i", target->GetAdventureClass());
  328. target->SetAdventureClass(val, send_update);
  329. break;
  330. }
  331. case SPAWN_SET_VALUE_GENDER:{
  332. sprintf(tmp, "%i", target->GetGender());
  333. target->SetGender(val, send_update);
  334. break;
  335. }
  336. case SPAWN_SET_VALUE_SHOW_NAME:{
  337. sprintf(tmp, "%i", target->GetShowName());
  338. target->SetShowName(val, send_update);
  339. break;
  340. }
  341. case SPAWN_SET_VALUE_ATTACKABLE:{
  342. sprintf(tmp, "%i", target->GetAttackable());
  343. target->SetAttackable(val, send_update);
  344. break;
  345. }
  346. case SPAWN_SET_VALUE_SHOW_LEVEL:{
  347. sprintf(tmp, "%i", target->GetShowLevel());
  348. target->SetShowLevel(val, send_update);
  349. break;
  350. }
  351. case SPAWN_SET_VALUE_TARGETABLE:{
  352. sprintf(tmp, "%i", target->GetTargetable());
  353. target->SetTargetable(val, send_update);
  354. break;
  355. }
  356. case SPAWN_SET_VALUE_SHOW_COMMAND_ICON:{
  357. sprintf(tmp, "%i", target->GetShowCommandIcon());
  358. target->SetShowCommandIcon(val, send_update);
  359. break;
  360. }
  361. case SPAWN_SET_VALUE_HAND_ICON:{
  362. sprintf(tmp, "%i", target->GetShowHandIcon());
  363. target->SetShowHandIcon(val, send_update);
  364. break;
  365. }
  366. case SPAWN_SET_VALUE_HAIR_TYPE:{
  367. if(target->IsEntity()){
  368. sprintf(tmp, "%i", ((Entity*)target)->GetHairType());
  369. ((Entity*)target)->SetHairType(val, send_update);
  370. }
  371. break;
  372. }
  373. case SPAWN_SET_VALUE_FACIAL_HAIR_TYPE:{
  374. if(target->IsEntity()){
  375. sprintf(tmp, "%i", ((Entity*)target)->GetFacialHairType());
  376. ((Entity*)target)->SetFacialHairType(val, send_update);
  377. }
  378. break;
  379. }
  380. case SPAWN_SET_VALUE_WING_TYPE:{
  381. if(target->IsEntity()){
  382. sprintf(tmp, "%i", ((Entity*)target)->GetWingType());
  383. ((Entity*)target)->SetWingType(val, send_update);
  384. }
  385. break;
  386. }
  387. case SPAWN_SET_VALUE_CHEST_TYPE:{
  388. if(target->IsEntity()){
  389. sprintf(tmp, "%i", ((Entity*)target)->GetChestType());
  390. ((Entity*)target)->SetChestType(val, send_update);
  391. }
  392. break;
  393. }
  394. case SPAWN_SET_VALUE_LEGS_TYPE:{
  395. if(target->IsEntity()){
  396. sprintf(tmp, "%i", ((Entity*)target)->GetLegsType());
  397. ((Entity*)target)->SetLegsType(val, send_update);
  398. }
  399. break;
  400. }
  401. case SPAWN_SET_VALUE_SOGA_HAIR_TYPE:{
  402. if(target->IsEntity()){
  403. sprintf(tmp, "%i", ((Entity*)target)->GetSogaHairType());
  404. ((Entity*)target)->SetSogaHairType(val, send_update);
  405. }
  406. break;
  407. }
  408. case SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE:{
  409. if(target->IsEntity()){
  410. sprintf(tmp, "%i", ((Entity*)target)->GetSogaFacialHairType());
  411. ((Entity*)target)->SetSogaFacialHairType(val, send_update);
  412. }
  413. break;
  414. }
  415. case SPAWN_SET_VALUE_SOGA_MODEL_TYPE:{
  416. sprintf(tmp, "%i", target->GetSogaModelType());
  417. target->SetSogaModelType(val, send_update);
  418. break;
  419. }
  420. case SPAWN_SET_VALUE_SIZE:{
  421. sprintf(tmp, "%i", target->GetSize());
  422. target->SetSize(val, send_update);
  423. break;
  424. }
  425. case SPAWN_SET_VALUE_HP:{
  426. sprintf(tmp, "%i", target->GetHP());
  427. target->SetHP(val, send_update);
  428. break;
  429. }
  430. case SPAWN_SET_VALUE_POWER:{
  431. sprintf(tmp, "%i", target->GetPower());
  432. target->SetPower(val, send_update);
  433. break;
  434. }
  435. case SPAWN_SET_VALUE_HEROIC:{
  436. sprintf(tmp, "%i", target->GetHeroic());
  437. target->SetHeroic(val, send_update);
  438. break;
  439. }
  440. case SPAWN_SET_VALUE_RESPAWN:{
  441. sprintf(tmp, "%u", target->GetRespawnTime());
  442. target->SetRespawnTime(val);
  443. break;
  444. }
  445. case SPAWN_SET_VALUE_X:{
  446. sprintf(tmp, "%f", target->GetX());
  447. target->SetX(atof(value), send_update);
  448. break;
  449. }
  450. case SPAWN_SET_VALUE_Y:{
  451. sprintf(tmp, "%f", target->GetY());
  452. target->SetY(atof(value), send_update);
  453. break;
  454. }
  455. case SPAWN_SET_VALUE_Z:{
  456. sprintf(tmp, "%f", target->GetZ());
  457. target->SetZ(atof(value), send_update);
  458. break;
  459. }
  460. case SPAWN_SET_VALUE_HEADING:{
  461. sprintf(tmp, "%f", target->GetHeading());
  462. target->SetHeading(atof(value) + 360, send_update);
  463. break;
  464. }
  465. case SPAWN_SET_VALUE_VISUAL_STATE:{
  466. sprintf(tmp, "%i", target->GetVisualState());
  467. target->SetVisualState(val, send_update);
  468. break;
  469. }
  470. case SPAWN_SET_VALUE_ACTION_STATE:{
  471. sprintf(tmp, "%i", target->GetActionState());
  472. target->SetActionState(val, send_update);
  473. break;
  474. }
  475. case SPAWN_SET_VALUE_MOOD_STATE:{
  476. sprintf(tmp, "%i", target->GetMoodState());
  477. target->SetMoodState(val, send_update);
  478. break;
  479. }
  480. case SPAWN_SET_VALUE_INITIAL_STATE:{
  481. sprintf(tmp, "%i", target->GetInitialState());
  482. target->SetInitialState(val, send_update);
  483. break;
  484. }
  485. case SPAWN_SET_VALUE_ACTIVITY_STATE:{
  486. sprintf(tmp, "%i", target->GetActivityStatus());
  487. target->SetActivityStatus(val, send_update);
  488. break;
  489. }
  490. case SPAWN_SET_VALUE_COLLISION_RADIUS:{
  491. sprintf(tmp, "%i", target->GetCollisionRadius());
  492. target->SetCollisionRadius(val, send_update);
  493. break;
  494. }
  495. case SPAWN_SET_VALUE_DEVICE_ID: {
  496. if (target->IsObject()) {
  497. sprintf(tmp, "%i", ((Object*)target)->GetDeviceID());
  498. ((Object*)target)->SetDeviceID(val);
  499. }
  500. break;
  501. }
  502. case SPAWN_SET_VALUE_PITCH: {
  503. sprintf(tmp, "%f", target->GetPitch());
  504. target->SetPitch(atof(value), send_update);
  505. break;
  506. }
  507. case SPAWN_SET_VALUE_ROLL: {
  508. sprintf(tmp, "%f", target->GetRoll());
  509. target->SetRoll(atof(value), send_update);
  510. break;
  511. }
  512. case SPAWN_SET_VALUE_HIDE_HOOD: {
  513. sprintf(tmp, "%i", target->appearance.hide_hood);
  514. target->SetHideHood(val);
  515. break;
  516. }
  517. case SPAWN_SET_VALUE_EMOTE_STATE: {
  518. sprintf(tmp, "%i", target->appearance.emote_state);
  519. target->SetEmoteState(val);
  520. break;
  521. }
  522. case SPAWN_SET_VALUE_ICON: {
  523. sprintf(tmp, "%i", target->GetIconValue());
  524. target->SetIcon(val);
  525. break;
  526. }
  527. case SPAWN_SET_VALUE_PREFIX: {
  528. sprintf(tmp, "%s", target->GetPrefixTitle());
  529. target->SetPrefixTitle(value);
  530. if(target->GetZone())
  531. target->GetZone()->SendUpdateTitles(target);
  532. break;
  533. }
  534. case SPAWN_SET_VALUE_SUFFIX: {
  535. sprintf(tmp, "%s", target->GetSuffixTitle());
  536. target->SetSuffixTitle(value);
  537. if(target->GetZone())
  538. target->GetZone()->SendUpdateTitles(target);
  539. break;
  540. }
  541. case SPAWN_SET_VALUE_LASTNAME: {
  542. sprintf(tmp, "%s", target->GetLastName());
  543. target->SetLastName(value);
  544. if(target->GetZone())
  545. target->GetZone()->SendUpdateTitles(target);
  546. break;
  547. }
  548. case SPAWN_SET_VALUE_EXPANSION_FLAG:
  549. case SPAWN_SET_VALUE_HOLIDAY_FLAG: {
  550. // nothing to do must reload spawns
  551. break;
  552. }
  553. case SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL: {
  554. sprintf(tmp, "%i", target->GetMerchantMinLevel());
  555. target->SetMerchantLevelRange(atoul(value), target->GetMerchantMaxLevel());
  556. break;
  557. }
  558. case SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL: {
  559. sprintf(tmp, "%i", target->GetMerchantMaxLevel());
  560. target->SetMerchantLevelRange(target->GetMerchantMinLevel(), atoul(value));
  561. break;
  562. }
  563. case SPAWN_SET_VALUE_FACTION:{
  564. sprintf(tmp, "%i", target->faction_id);
  565. ZoneServer* zone = target->GetZone();
  566. if (!zone && client)
  567. zone = client->GetCurrentZone();
  568. target->faction_id = atoul(value);
  569. if(zone)
  570. {
  571. zone->RemoveDeadEnemyList(target);
  572. if(target->IsNPC())
  573. zone->AddEnemyList((NPC*)target);
  574. }
  575. break;
  576. }
  577. case SPAWN_SET_SKIN_COLOR:
  578. case SPAWN_SET_HAIR_COLOR1:
  579. case SPAWN_SET_HAIR_COLOR2:
  580. case SPAWN_SET_HAIR_TYPE_COLOR:
  581. case SPAWN_SET_HAIR_FACE_COLOR:
  582. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  583. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  584. case SPAWN_SET_HAIR_HIGHLIGHT:
  585. case SPAWN_SET_MODEL_COLOR:
  586. case SPAWN_SET_EYE_COLOR:
  587. case SPAWN_SET_SOGA_SKIN_COLOR:
  588. case SPAWN_SET_SOGA_HAIR_COLOR1:
  589. case SPAWN_SET_SOGA_HAIR_COLOR2:
  590. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  591. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  592. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  593. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  594. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  595. case SPAWN_SET_SOGA_MODEL_COLOR:
  596. case SPAWN_SET_SOGA_EYE_COLOR:
  597. {
  598. if (target->IsEntity())
  599. {
  600. Seperator* skinsep = new Seperator(value, ' ', 3, 500, true);
  601. if (skinsep->IsNumber(0) && skinsep->IsNumber(1) && skinsep->IsNumber(2))
  602. {
  603. EQ2_Color clr;
  604. clr.red = atoul(skinsep->arg[0]);
  605. clr.green = atoul(skinsep->arg[1]);
  606. clr.blue = atoul(skinsep->arg[2]);
  607. switch(type)
  608. {
  609. case SPAWN_SET_SKIN_COLOR:
  610. ((Entity*)target)->SetSkinColor(clr);
  611. break;
  612. case SPAWN_SET_HAIR_COLOR1:
  613. ((Entity*)target)->SetHairColor1(clr);
  614. break;
  615. case SPAWN_SET_HAIR_COLOR2:
  616. ((Entity*)target)->SetHairColor2(clr);
  617. break;
  618. case SPAWN_SET_HAIR_TYPE_COLOR:
  619. ((Entity*)target)->SetHairColor(clr);
  620. break;
  621. case SPAWN_SET_HAIR_FACE_COLOR:
  622. ((Entity*)target)->SetFacialHairColor(clr);
  623. break;
  624. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  625. ((Entity*)target)->SetHairTypeHighlightColor(clr);
  626. break;
  627. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  628. ((Entity*)target)->SetFacialHairHighlightColor(clr);
  629. break;
  630. case SPAWN_SET_HAIR_HIGHLIGHT:
  631. ((Entity*)target)->SetHairHighlightColor(clr);
  632. break;
  633. case SPAWN_SET_MODEL_COLOR:
  634. ((Entity*)target)->SetModelColor(clr);
  635. break;
  636. case SPAWN_SET_EYE_COLOR:
  637. ((Entity*)target)->SetEyeColor(clr);
  638. break;
  639. case SPAWN_SET_SOGA_SKIN_COLOR:
  640. ((Entity*)target)->SetSogaSkinColor(clr);
  641. break;
  642. case SPAWN_SET_SOGA_HAIR_COLOR1:
  643. ((Entity*)target)->SetSogaHairColor1(clr);
  644. break;
  645. case SPAWN_SET_SOGA_HAIR_COLOR2:
  646. ((Entity*)target)->SetSogaHairColor2(clr);
  647. break;
  648. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  649. ((Entity*)target)->SetSogaHairColor(clr);
  650. break;
  651. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  652. ((Entity*)target)->SetSogaFacialHairColor(clr);
  653. break;
  654. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  655. ((Entity*)target)->SetSogaHairTypeHighlightColor(clr);
  656. break;
  657. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  658. ((Entity*)target)->SetSogaFacialHairHighlightColor(clr);
  659. break;
  660. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  661. ((Entity*)target)->SetSogaHairHighlightColor(clr);
  662. break;
  663. case SPAWN_SET_SOGA_MODEL_COLOR:
  664. ((Entity*)target)->SetSogaModelColor(clr);
  665. break;
  666. case SPAWN_SET_SOGA_EYE_COLOR:
  667. ((Entity*)target)->SetSogaEyeColor(clr);
  668. break;
  669. }
  670. }
  671. safe_delete(skinsep);
  672. }
  673. break;
  674. }
  675. case SPAWN_SET_AAXP_REWARDS: {
  676. target->SetAAXPRewards(atoul(value));
  677. break;
  678. }
  679. case SPAWN_SET_CHEEK_TYPE:{
  680. if(target->IsEntity() && index < 3){
  681. sprintf(tmp, "%i", ((Entity*)target)->features.cheek_type[index]);
  682. sint8 new_value = atoi(value);
  683. ((Entity*)target)->features.cheek_type[index] = new_value;
  684. ((Entity*)target)->info_changed = true;
  685. }
  686. break;
  687. }
  688. case SPAWN_SET_CHIN_TYPE:{
  689. if(target->IsEntity() && index < 3){
  690. sprintf(tmp, "%i", ((Entity*)target)->features.chin_type[index]);
  691. sint8 new_value = atoi(value);
  692. ((Entity*)target)->features.chin_type[index] = new_value;
  693. ((Entity*)target)->info_changed = true;
  694. }
  695. break;
  696. }
  697. case SPAWN_SET_EAR_TYPE:{
  698. if(target->IsEntity() && index < 3){
  699. sprintf(tmp, "%i", ((Entity*)target)->features.ear_type[index]);
  700. sint8 new_value = atoi(value);
  701. ((Entity*)target)->features.ear_type[index] = new_value;
  702. ((Entity*)target)->info_changed = true;
  703. }
  704. break;
  705. }
  706. case SPAWN_SET_EYE_BROW_TYPE:{
  707. if(target->IsEntity() && index < 3){
  708. sprintf(tmp, "%i", ((Entity*)target)->features.eye_brow_type[index]);
  709. sint8 new_value = atoi(value);
  710. ((Entity*)target)->features.eye_brow_type[index] = new_value;
  711. ((Entity*)target)->info_changed = true;
  712. }
  713. break;
  714. }
  715. case SPAWN_SET_EYE_TYPE:{
  716. if(target->IsEntity() && index < 3){
  717. sprintf(tmp, "%i", ((Entity*)target)->features.eye_type[index]);
  718. sint8 new_value = atoi(value);
  719. ((Entity*)target)->features.eye_type[index] = new_value;
  720. ((Entity*)target)->info_changed = true;
  721. }
  722. break;
  723. }
  724. case SPAWN_SET_LIP_TYPE:{
  725. if(target->IsEntity() && index < 3){
  726. sprintf(tmp, "%i", ((Entity*)target)->features.lip_type[index]);
  727. sint8 new_value = atoi(value);
  728. ((Entity*)target)->features.lip_type[index] = new_value;
  729. ((Entity*)target)->info_changed = true;
  730. }
  731. break;
  732. }
  733. case SPAWN_SET_NOSE_TYPE:{
  734. if(target->IsEntity() && index < 3){
  735. sprintf(tmp, "%i", ((Entity*)target)->features.nose_type[index]);
  736. sint8 new_value = atoi(value);
  737. ((Entity*)target)->features.nose_type[index] = new_value;
  738. ((Entity*)target)->info_changed = true;
  739. }
  740. break;
  741. }
  742. case SPAWN_SET_BODY_SIZE:{
  743. if(target->IsEntity()){
  744. sprintf(tmp, "%i", ((Entity*)target)->features.body_size);
  745. int8 new_value = atoul(value);
  746. ((Entity*)target)->features.body_size = new_value;
  747. ((Entity*)target)->info_changed = true;
  748. }
  749. break;
  750. }
  751. case SPAWN_SET_BODY_AGE:{
  752. if(target->IsEntity()){
  753. sprintf(tmp, "%i", ((Entity*)target)->features.body_age);
  754. int8 new_value = atoul(value);
  755. ((Entity*)target)->features.body_age = new_value;
  756. ((Entity*)target)->info_changed = true;
  757. }
  758. break;
  759. }
  760. case SPAWN_SET_SOGA_CHEEK_TYPE:{
  761. if(target->IsEntity() && index < 3){
  762. sprintf(tmp, "%i", ((Entity*)target)->features.soga_cheek_type[index]);
  763. sint8 new_value = atoi(value);
  764. ((Entity*)target)->features.soga_cheek_type[index] = new_value;
  765. ((Entity*)target)->info_changed = true;
  766. }
  767. break;
  768. }
  769. case SPAWN_SET_SOGA_CHIN_TYPE:{
  770. if(target->IsEntity() && index < 3){
  771. sprintf(tmp, "%i", ((Entity*)target)->features.soga_chin_type[index]);
  772. sint8 new_value = atoi(value);
  773. ((Entity*)target)->features.soga_chin_type[index] = new_value;
  774. ((Entity*)target)->info_changed = true;
  775. }
  776. break;
  777. }
  778. case SPAWN_SET_SOGA_EAR_TYPE:{
  779. if(target->IsEntity() && index < 3){
  780. sprintf(tmp, "%i", ((Entity*)target)->features.soga_ear_type[index]);
  781. sint8 new_value = atoi(value);
  782. ((Entity*)target)->features.soga_ear_type[index] = new_value;
  783. ((Entity*)target)->info_changed = true;
  784. }
  785. break;
  786. }
  787. case SPAWN_SET_SOGA_EYE_BROW_TYPE:{
  788. if(target->IsEntity() && index < 3){
  789. sprintf(tmp, "%i", ((Entity*)target)->features.soga_eye_brow_type[index]);
  790. sint8 new_value = atoi(value);
  791. ((Entity*)target)->features.soga_eye_brow_type[index] = new_value;
  792. ((Entity*)target)->info_changed = true;
  793. }
  794. break;
  795. }
  796. case SPAWN_SET_SOGA_EYE_TYPE:{
  797. if(target->IsEntity() && index < 3){
  798. sprintf(tmp, "%i", ((Entity*)target)->features.soga_eye_type[index]);
  799. sint8 new_value = atoi(value);
  800. ((Entity*)target)->features.soga_eye_type[index] = new_value;
  801. ((Entity*)target)->info_changed = true;
  802. }
  803. break;
  804. }
  805. case SPAWN_SET_SOGA_LIP_TYPE:{
  806. if(target->IsEntity() && index < 3){
  807. sprintf(tmp, "%i", ((Entity*)target)->features.soga_lip_type[index]);
  808. sint8 new_value = atoi(value);
  809. ((Entity*)target)->features.soga_lip_type[index] = new_value;
  810. ((Entity*)target)->info_changed = true;
  811. }
  812. break;
  813. }
  814. case SPAWN_SET_SOGA_BODY_SIZE:{
  815. if(target->IsEntity()){
  816. sprintf(tmp, "%i", ((Entity*)target)->features.soga_body_size);
  817. int8 new_value = atoul(value);
  818. ((Entity*)target)->features.soga_body_size = new_value;
  819. ((Entity*)target)->info_changed = true;
  820. }
  821. break;
  822. }
  823. case SPAWN_SET_SOGA_BODY_AGE:{
  824. if(target->IsEntity()){
  825. sprintf(tmp, "%i", ((Entity*)target)->features.soga_body_age);
  826. int8 new_value = atoul(value);
  827. ((Entity*)target)->features.soga_body_age = new_value;
  828. ((Entity*)target)->info_changed = true;
  829. }
  830. break;
  831. }
  832. case SPAWN_SET_ATTACK_TYPE:{
  833. if(target->IsEntity()){
  834. sprintf(tmp, "%u", ((Entity*)target)->GetInfoStruct()->get_attack_type());
  835. int8 new_value = atoul(value);
  836. ((Entity*)target)->GetInfoStruct()->set_attack_type(new_value);
  837. }
  838. break;
  839. }
  840. case SPAWN_SET_RACE_TYPE:{
  841. if(target->GetModelType() > 0){
  842. Seperator* tmpsep = new Seperator(value, ' ', 3, 500, true);
  843. if (tmpsep->IsNumber(0))
  844. {
  845. int16 race_type = atoul(value);
  846. const char* category = tmpsep->IsSet(1) ? tmpsep->arg[1] : "NULL";
  847. const char* subcategory = tmpsep->IsSet(2) ? tmpsep->arg[2] : "NULL";
  848. const char* model_name = tmpsep->IsSet(3) ? tmpsep->arg[3] : "NULL";
  849. if(race_types_list.AddRaceType(target->GetModelType(), race_type, category, subcategory, model_name)) {
  850. if(client) {
  851. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Race type added to memory, however not saved to database.");
  852. }
  853. }
  854. else {
  855. client->SimpleMessage(CHANNEL_COLOR_RED, "Model type already on the race_types_list, use spawn set database to override and update database.");
  856. }
  857. }
  858. safe_delete(tmpsep);
  859. }
  860. break;
  861. }
  862. case SPAWN_SET_LOOT_TIER:{
  863. if(target->IsEntity()){
  864. sprintf(tmp, "%u", target->GetLootTier());
  865. int32 new_value = atoul(value);
  866. target->SetLootTier(new_value);
  867. }
  868. break;
  869. }
  870. case SPAWN_SET_LOOT_DROP_TYPE:{
  871. if(target->IsEntity()){
  872. sprintf(tmp, "%u", target->GetLootDropType());
  873. int32 new_value = atoul(value);
  874. target->SetLootDropType(new_value);
  875. }
  876. break;
  877. }
  878. if(temp_value)
  879. *temp_value = string(tmp);
  880. }
  881. }
  882. else{
  883. /**** NOT TEMPORARY ELSE STATEMENT ****/
  884. /**** MUST RE-DEFINE WHAT IS ALREADY IN THE IF TEMPORARY BLOCK HERE ****/
  885. switch(type){
  886. case SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL: {
  887. target->SetMerchantLevelRange(atoul(value), target->GetMerchantMaxLevel());
  888. break;
  889. }
  890. case SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL: {
  891. target->SetMerchantLevelRange(target->GetMerchantMinLevel(), atoul(value));
  892. break;
  893. }
  894. case SPAWN_SET_VALUE_EXPANSION_FLAG: {
  895. if (target->GetDatabaseID() > 0)
  896. {
  897. char query[256];
  898. snprintf(query, 256, "update spawn set expansion_flag=%u where id=%u", atoul(value), target->GetDatabaseID());
  899. if (database.RunQuery(query, strnlen(query, 256)))
  900. {
  901. if(client)
  902. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  903. }
  904. }
  905. break;
  906. }
  907. case SPAWN_SET_VALUE_HOLIDAY_FLAG: {
  908. if (target->GetDatabaseID() > 0)
  909. {
  910. char query[256];
  911. snprintf(query, 256, "update spawn set holiday_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_AAXP_REWARDS: {
  921. if (target->GetDatabaseID() > 0)
  922. {
  923. char query[256];
  924. snprintf(query, 256, "update spawn set aaxp_rewards=%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_VALUE_NAME:{
  934. target->SetName(value);
  935. if(target->GetZone())
  936. target->GetZone()->SendUpdateTitles(target);
  937. break;
  938. }
  939. case SPAWN_SET_VALUE_SUB_TITLE: {
  940. target->SetSubTitle(value);
  941. if(target->GetZone())
  942. target->GetZone()->SendUpdateTitles(target);
  943. break;
  944. }
  945. case SPAWN_SET_VALUE_X_OFFSET:
  946. {
  947. target->SetXOffset(atof(value));
  948. break;
  949. }
  950. case SPAWN_SET_VALUE_Y_OFFSET:
  951. {
  952. target->SetYOffset(atof(value));
  953. break;
  954. }
  955. case SPAWN_SET_VALUE_Z_OFFSET:
  956. {
  957. target->SetZOffset(atof(value));
  958. break;
  959. }
  960. case SPAWN_SET_VALUE_EXPIRE: {
  961. target->SetExpireTime(val);
  962. break;
  963. }
  964. case SPAWN_SET_VALUE_EXPIRE_OFFSET: {
  965. target->SetExpireOffsetTime(val);
  966. break;
  967. }
  968. case SPAWN_SET_VALUE_LEVEL:{
  969. target->SetLevel(val, send_update);
  970. break;
  971. }
  972. case SPAWN_SET_VALUE_DIFFICULTY:{
  973. target->SetEncounterLevel(val, send_update);
  974. break;
  975. }
  976. case SPAWN_SET_VALUE_MODEL_TYPE:{
  977. target->SetModelType(val, send_update);
  978. break;
  979. }
  980. case SPAWN_SET_VALUE_CLASS:{
  981. target->SetAdventureClass(val, send_update);
  982. break;
  983. }
  984. case SPAWN_SET_VALUE_GENDER:{
  985. target->SetGender(val, send_update);
  986. break;
  987. }
  988. case SPAWN_SET_VALUE_SHOW_NAME:{
  989. target->SetShowName(val, send_update);
  990. break;
  991. }
  992. case SPAWN_SET_VALUE_ATTACKABLE:{
  993. target->SetAttackable(val, send_update);
  994. break;
  995. }
  996. case SPAWN_SET_VALUE_SHOW_LEVEL:{
  997. target->SetShowLevel(val, send_update);
  998. break;
  999. }
  1000. case SPAWN_SET_VALUE_TARGETABLE:{
  1001. target->SetTargetable(val, send_update);
  1002. break;
  1003. }
  1004. case SPAWN_SET_VALUE_SHOW_COMMAND_ICON:{
  1005. target->SetShowCommandIcon(val, send_update);
  1006. break;
  1007. }
  1008. case SPAWN_SET_VALUE_HAND_ICON:{
  1009. target->SetShowHandIcon(val, send_update);
  1010. break;
  1011. }
  1012. case SPAWN_SET_VALUE_HAIR_TYPE:{
  1013. if(target->IsEntity())
  1014. ((Entity*)target)->SetHairType(val, send_update);
  1015. break;
  1016. }
  1017. case SPAWN_SET_VALUE_FACIAL_HAIR_TYPE:{
  1018. if(target->IsEntity())
  1019. ((Entity*)target)->SetFacialHairType(val, send_update);
  1020. break;
  1021. }
  1022. case SPAWN_SET_VALUE_WING_TYPE:{
  1023. if(target->IsEntity())
  1024. ((Entity*)target)->SetWingType(val, send_update);
  1025. break;
  1026. }
  1027. case SPAWN_SET_VALUE_CHEST_TYPE:{
  1028. if(target->IsEntity())
  1029. ((Entity*)target)->SetChestType(val, send_update);
  1030. break;
  1031. }
  1032. case SPAWN_SET_VALUE_LEGS_TYPE:{
  1033. if(target->IsEntity())
  1034. ((Entity*)target)->SetLegsType(val, send_update);
  1035. break;
  1036. }
  1037. case SPAWN_SET_VALUE_SOGA_HAIR_TYPE:{
  1038. if(target->IsEntity())
  1039. ((Entity*)target)->SetSogaHairType(val, send_update);
  1040. break;
  1041. }
  1042. case SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE:{
  1043. if(target->IsEntity())
  1044. ((Entity*)target)->SetSogaFacialHairType(val, send_update);
  1045. break;
  1046. }
  1047. case SPAWN_SET_VALUE_SOGA_MODEL_TYPE:{
  1048. target->SetSogaModelType(val, send_update);
  1049. break;
  1050. }
  1051. case SPAWN_SET_VALUE_SIZE:{
  1052. target->SetSize(val, send_update);
  1053. break;
  1054. }
  1055. case SPAWN_SET_VALUE_HP:{
  1056. target->SetHP(val, send_update);
  1057. break;
  1058. }
  1059. case SPAWN_SET_VALUE_POWER:{
  1060. target->SetPower(val, send_update);
  1061. break;
  1062. }
  1063. case SPAWN_SET_VALUE_HEROIC:{
  1064. target->SetHeroic(val, send_update);
  1065. break;
  1066. }
  1067. case SPAWN_SET_VALUE_RESPAWN:{
  1068. target->SetRespawnTime(val);
  1069. break;
  1070. }
  1071. case SPAWN_SET_VALUE_X:{
  1072. target->SetX(atof(value), send_update);
  1073. target->SetSpawnOrigX(target->GetX());
  1074. break;
  1075. }
  1076. case SPAWN_SET_VALUE_Y:{
  1077. target->SetY(atof(value), send_update);
  1078. target->SetSpawnOrigY(target->GetY());
  1079. break;
  1080. }
  1081. case SPAWN_SET_VALUE_Z:{
  1082. target->SetZ(atof(value), send_update);
  1083. target->SetSpawnOrigZ(target->GetZ());
  1084. break;
  1085. }
  1086. case SPAWN_SET_VALUE_HEADING:{
  1087. target->SetHeading(atof(value), send_update);
  1088. target->SetSpawnOrigHeading(target->GetHeading());
  1089. break;
  1090. }
  1091. case SPAWN_SET_VALUE_COMMAND_PRIMARY:{
  1092. ZoneServer* zone = target->GetZone();
  1093. if (!zone && client)
  1094. zone = client->GetCurrentZone();
  1095. if(zone && zone->GetEntityCommandList(val))
  1096. target->SetPrimaryCommands(zone->GetEntityCommandList(val));
  1097. target->primary_command_list_id = val;
  1098. break;
  1099. }
  1100. case SPAWN_SET_VALUE_COMMAND_SECONDARY:{
  1101. ZoneServer* zone = target->GetZone();
  1102. if (!zone && client)
  1103. zone = client->GetCurrentZone();
  1104. if (zone && zone->GetEntityCommandList(val))
  1105. target->SetSecondaryCommands(zone->GetEntityCommandList(val));
  1106. target->secondary_command_list_id = val;
  1107. break;
  1108. }
  1109. case SPAWN_SET_VALUE_VISUAL_STATE:{
  1110. target->SetVisualState(val, send_update);
  1111. break;
  1112. }
  1113. case SPAWN_SET_VALUE_ACTION_STATE:{
  1114. target->SetActionState(val, send_update);
  1115. break;
  1116. }
  1117. case SPAWN_SET_VALUE_MOOD_STATE:{
  1118. target->SetMoodState(val, send_update);
  1119. break;
  1120. }
  1121. case SPAWN_SET_VALUE_INITIAL_STATE:{
  1122. target->SetInitialState(val, send_update);
  1123. break;
  1124. }
  1125. case SPAWN_SET_VALUE_ACTIVITY_STATE:{
  1126. target->SetActivityStatus(val, send_update);
  1127. break;
  1128. }
  1129. case SPAWN_SET_VALUE_COLLISION_RADIUS:{
  1130. target->SetCollisionRadius(val, send_update);
  1131. break;
  1132. }
  1133. case SPAWN_SET_VALUE_FACTION:{
  1134. ZoneServer* zone = target->GetZone();
  1135. if (!zone && client)
  1136. zone = client->GetCurrentZone();
  1137. target->faction_id = val;
  1138. if(zone)
  1139. {
  1140. zone->RemoveDeadEnemyList(target);
  1141. if(target->IsNPC())
  1142. zone->AddEnemyList((NPC*)target);
  1143. }
  1144. break;
  1145. }
  1146. case SPAWN_SET_VALUE_DEVICE_ID:{
  1147. if (target->IsObject())
  1148. ((Object*)target)->SetDeviceID(val);
  1149. break;
  1150. }
  1151. case SPAWN_SET_VALUE_PITCH: {
  1152. target->SetPitch(atof(value), send_update);
  1153. target->SetSpawnOrigPitch(atof(value));
  1154. break;
  1155. }
  1156. case SPAWN_SET_VALUE_ROLL: {
  1157. target->SetRoll(atof(value), send_update);
  1158. target->SetSpawnOrigRoll(atof(value));
  1159. break;
  1160. }
  1161. case SPAWN_SET_VALUE_HIDE_HOOD: {
  1162. target->SetHideHood(val);
  1163. break;
  1164. }
  1165. case SPAWN_SET_VALUE_EMOTE_STATE: {
  1166. target->SetEmoteState(val);
  1167. break;
  1168. }
  1169. case SPAWN_SET_VALUE_ICON: {
  1170. target->SetIcon(val);
  1171. break;
  1172. }
  1173. case SPAWN_SET_VALUE_PREFIX: {
  1174. target->SetPrefixTitle(value);
  1175. if(target->GetZone())
  1176. target->GetZone()->SendUpdateTitles(target);
  1177. break;
  1178. }
  1179. case SPAWN_SET_VALUE_SUFFIX: {
  1180. target->SetSuffixTitle(value);
  1181. if(target->GetZone())
  1182. target->GetZone()->SendUpdateTitles(target);
  1183. break;
  1184. }
  1185. case SPAWN_SET_VALUE_LASTNAME: {
  1186. target->SetLastName(value);
  1187. if(target->GetZone())
  1188. target->GetZone()->SendUpdateTitles(target);
  1189. break;
  1190. }
  1191. case SPAWN_SET_VALUE_SPAWN_SCRIPT:{
  1192. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  1193. if(client){
  1194. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  1195. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawn_script 'SpawnScripts/example.lua'");
  1196. }
  1197. return false;
  1198. }
  1199. else if(!database.UpdateSpawnScriptData(target->GetDatabaseID(), 0, 0, value))
  1200. return false;
  1201. else{
  1202. if(!world.GetSpawnLocationScript(target->GetSpawnLocationID()))
  1203. target->SetSpawnScript(value);
  1204. }
  1205. break;
  1206. }
  1207. case SPAWN_SET_VALUE_SPAWNLOCATION_SCRIPT:{
  1208. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  1209. if(client){
  1210. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  1211. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawnlocation_script 'SpawnScripts/example.lua'");
  1212. }
  1213. return false;
  1214. }
  1215. else if(!database.UpdateSpawnScriptData(0, target->GetSpawnLocationID(), 0, value))
  1216. return false;
  1217. else{
  1218. if(!world.GetSpawnEntryScript(target->GetSpawnEntryID()))
  1219. target->SetSpawnScript(value);
  1220. }
  1221. break;
  1222. }
  1223. case SPAWN_SET_VALUE_SPAWNENTRY_SCRIPT:{
  1224. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  1225. if(client){
  1226. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  1227. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawnentry_script 'SpawnScripts/example.lua'");
  1228. }
  1229. return false;
  1230. }
  1231. else if(!database.UpdateSpawnScriptData(0, 0, target->GetSpawnEntryID(), value))
  1232. return false;
  1233. else
  1234. target->SetSpawnScript(value);
  1235. break;
  1236. }
  1237. case SPAWN_SET_SKIN_COLOR:
  1238. case SPAWN_SET_HAIR_COLOR1:
  1239. case SPAWN_SET_HAIR_COLOR2:
  1240. case SPAWN_SET_HAIR_TYPE_COLOR:
  1241. case SPAWN_SET_HAIR_FACE_COLOR:
  1242. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  1243. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  1244. case SPAWN_SET_HAIR_HIGHLIGHT:
  1245. case SPAWN_SET_MODEL_COLOR:
  1246. case SPAWN_SET_EYE_COLOR:
  1247. case SPAWN_SET_SOGA_SKIN_COLOR:
  1248. case SPAWN_SET_SOGA_HAIR_COLOR1:
  1249. case SPAWN_SET_SOGA_HAIR_COLOR2:
  1250. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  1251. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  1252. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  1253. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  1254. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  1255. case SPAWN_SET_SOGA_MODEL_COLOR:
  1256. case SPAWN_SET_SOGA_EYE_COLOR: {
  1257. if (target->IsNPC())
  1258. {
  1259. Seperator* skinsep = new Seperator(value, ' ', 3, 500, true);
  1260. if (skinsep->IsNumber(0) && skinsep->IsNumber(1) && skinsep->IsNumber(2))
  1261. {
  1262. EQ2_Color clr;
  1263. clr.red = atoul(skinsep->arg[0]);
  1264. clr.green = atoul(skinsep->arg[1]);
  1265. clr.blue = atoul(skinsep->arg[2]);
  1266. Query replaceSkinQuery;
  1267. string fieldName("");
  1268. switch(type)
  1269. {
  1270. case SPAWN_SET_SKIN_COLOR:
  1271. ((Entity*)target)->SetSkinColor(clr);
  1272. fieldName.append("skin_color");
  1273. break;
  1274. case SPAWN_SET_HAIR_COLOR1:
  1275. ((Entity*)target)->SetHairColor1(clr);
  1276. fieldName.append("hair_color1");
  1277. break;
  1278. case SPAWN_SET_HAIR_COLOR2:
  1279. ((Entity*)target)->SetHairColor2(clr);
  1280. fieldName.append("hair_color2");
  1281. break;
  1282. case SPAWN_SET_HAIR_TYPE_COLOR:
  1283. ((Entity*)target)->SetHairColor(clr);
  1284. fieldName.append("hair_type_color");
  1285. break;
  1286. case SPAWN_SET_HAIR_FACE_COLOR:
  1287. ((Entity*)target)->SetFacialHairColor(clr);
  1288. fieldName.append("hair_face_color");
  1289. break;
  1290. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  1291. ((Entity*)target)->SetHairTypeHighlightColor(clr);
  1292. fieldName.append("hair_type_highlight_color");
  1293. break;
  1294. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  1295. ((Entity*)target)->SetFacialHairHighlightColor(clr);
  1296. fieldName.append("hair_face_highlight_color");
  1297. break;
  1298. case SPAWN_SET_HAIR_HIGHLIGHT:
  1299. ((Entity*)target)->SetHairHighlightColor(clr);
  1300. fieldName.append("hair_highlight");
  1301. break;
  1302. case SPAWN_SET_MODEL_COLOR:
  1303. ((Entity*)target)->SetModelColor(clr);
  1304. fieldName.append("model_color");
  1305. break;
  1306. case SPAWN_SET_EYE_COLOR:
  1307. ((Entity*)target)->SetEyeColor(clr);
  1308. fieldName.append("eye_color");
  1309. break;
  1310. case SPAWN_SET_SOGA_SKIN_COLOR:
  1311. ((Entity*)target)->SetSogaSkinColor(clr);
  1312. fieldName.append("soga_skin_color");
  1313. break;
  1314. case SPAWN_SET_SOGA_HAIR_COLOR1:
  1315. ((Entity*)target)->SetSogaHairColor1(clr);
  1316. fieldName.append("soga_hair_color1");
  1317. break;
  1318. case SPAWN_SET_SOGA_HAIR_COLOR2:
  1319. ((Entity*)target)->SetSogaHairColor2(clr);
  1320. fieldName.append("soga_hair_color2");
  1321. break;
  1322. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  1323. ((Entity*)target)->SetSogaHairColor(clr);
  1324. fieldName.append("soga_hair_type_color");
  1325. break;
  1326. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  1327. ((Entity*)target)->SetSogaFacialHairColor(clr);
  1328. fieldName.append("soga_hair_face_color");
  1329. break;
  1330. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  1331. ((Entity*)target)->SetSogaHairTypeHighlightColor(clr);
  1332. fieldName.append("soga_hair_type_highlight_color");
  1333. break;
  1334. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  1335. ((Entity*)target)->SetSogaFacialHairHighlightColor(clr);
  1336. fieldName.append("soga_hair_face_highlight_color");
  1337. break;
  1338. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  1339. ((Entity*)target)->SetSogaHairHighlightColor(clr);
  1340. fieldName.append("soga_hair_highlight");
  1341. break;
  1342. case SPAWN_SET_SOGA_MODEL_COLOR:
  1343. ((Entity*)target)->SetSogaModelColor(clr);
  1344. fieldName.append("soga_model_color");
  1345. break;
  1346. case SPAWN_SET_SOGA_EYE_COLOR:
  1347. ((Entity*)target)->SetSogaEyeColor(clr);
  1348. fieldName.append("soga_eye_color");
  1349. break;
  1350. }
  1351. replaceSkinQuery.AddQueryAsync(0, &database, Q_DELETE, "delete from npc_appearance where spawn_id=%u and type='%s'", target->GetDatabaseID(), fieldName.c_str());
  1352. 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);
  1353. }
  1354. safe_delete(skinsep);
  1355. }
  1356. break;
  1357. }
  1358. case SPAWN_SET_CHEEK_TYPE:{
  1359. if(target->IsEntity() && index < 3){
  1360. sint8 new_value = atoi(value);
  1361. ((Entity*)target)->features.cheek_type[index] = new_value;
  1362. UpdateDatabaseAppearance(client, target, "cheek_type", ((Entity*)target)->features.cheek_type[0], ((Entity*)target)->features.cheek_type[1], ((Entity*)target)->features.cheek_type[2]);
  1363. }
  1364. break;
  1365. }
  1366. case SPAWN_SET_CHIN_TYPE:{
  1367. if(target->IsEntity() && index < 3){
  1368. sint8 new_value = atoi(value);
  1369. ((Entity*)target)->features.chin_type[index] = new_value;
  1370. UpdateDatabaseAppearance(client, target, "chin_type", ((Entity*)target)->features.chin_type[0], ((Entity*)target)->features.chin_type[1], ((Entity*)target)->features.chin_type[2]);
  1371. }
  1372. break;
  1373. }
  1374. case SPAWN_SET_EAR_TYPE:{
  1375. if(target->IsEntity() && index < 3){
  1376. sint8 new_value = atoi(value);
  1377. ((Entity*)target)->features.ear_type[index] = new_value;
  1378. UpdateDatabaseAppearance(client, target, "ear_type", ((Entity*)target)->features.ear_type[0], ((Entity*)target)->features.ear_type[1], ((Entity*)target)->features.ear_type[2]);
  1379. }
  1380. break;
  1381. }
  1382. case SPAWN_SET_EYE_BROW_TYPE:{
  1383. if(target->IsEntity() && index < 3){
  1384. sint8 new_value = atoi(value);
  1385. ((Entity*)target)->features.eye_brow_type[index] = new_value;
  1386. 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]);
  1387. }
  1388. break;
  1389. }
  1390. case SPAWN_SET_EYE_TYPE:{
  1391. if(target->IsEntity() && index < 3){
  1392. sint8 new_value = atoi(value);
  1393. ((Entity*)target)->features.eye_type[index] = new_value;
  1394. UpdateDatabaseAppearance(client, target, "eye_type", ((Entity*)target)->features.eye_type[0], ((Entity*)target)->features.eye_type[1], ((Entity*)target)->features.eye_type[2]);
  1395. }
  1396. break;
  1397. }
  1398. case SPAWN_SET_LIP_TYPE:{
  1399. if(target->IsEntity() && index < 3){
  1400. sint8 new_value = atoi(value);
  1401. ((Entity*)target)->features.lip_type[index] = new_value;
  1402. UpdateDatabaseAppearance(client, target, "lip_type", ((Entity*)target)->features.lip_type[0], ((Entity*)target)->features.lip_type[1], ((Entity*)target)->features.lip_type[2]);
  1403. }
  1404. break;
  1405. }
  1406. case SPAWN_SET_NOSE_TYPE:{
  1407. if(target->IsEntity() && index < 3){
  1408. sint8 new_value = atoi(value);
  1409. ((Entity*)target)->features.nose_type[index] = new_value;
  1410. UpdateDatabaseAppearance(client, target, "nose_type", ((Entity*)target)->features.nose_type[0], ((Entity*)target)->features.nose_type[1], ((Entity*)target)->features.nose_type[2]);
  1411. }
  1412. break;
  1413. }
  1414. case SPAWN_SET_BODY_SIZE:{
  1415. if(target->IsEntity()){
  1416. int8 new_value = atoul(value);
  1417. ((Entity*)target)->features.body_size = new_value;
  1418. UpdateDatabaseAppearance(client, target, "body_size", ((Entity*)target)->features.body_size, 0, 0);
  1419. }
  1420. break;
  1421. }
  1422. case SPAWN_SET_BODY_AGE:{
  1423. if(target->IsEntity()){
  1424. int8 new_value = atoul(value);
  1425. ((Entity*)target)->features.body_age = new_value;
  1426. UpdateDatabaseAppearance(client, target, "body_age", ((Entity*)target)->features.body_age, 0, 0);
  1427. }
  1428. break;
  1429. }
  1430. case SPAWN_SET_SOGA_CHEEK_TYPE:{
  1431. if(target->IsEntity() && index < 3){
  1432. sint8 new_value = atoi(value);
  1433. ((Entity*)target)->features.soga_cheek_type[index] = new_value;
  1434. 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]);
  1435. }
  1436. break;
  1437. }
  1438. case SPAWN_SET_SOGA_CHIN_TYPE:{
  1439. if(target->IsEntity() && index < 3){
  1440. sint8 new_value = atoi(value);
  1441. ((Entity*)target)->features.soga_chin_type[index] = new_value;
  1442. 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]);
  1443. }
  1444. break;
  1445. }
  1446. case SPAWN_SET_SOGA_EAR_TYPE:{
  1447. if(target->IsEntity() && index < 3){
  1448. sint8 new_value = atoi(value);
  1449. ((Entity*)target)->features.soga_ear_type[index] = new_value;
  1450. 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]);
  1451. }
  1452. break;
  1453. }
  1454. case SPAWN_SET_SOGA_EYE_BROW_TYPE:{
  1455. if(target->IsEntity() && index < 3){
  1456. sint8 new_value = atoi(value);
  1457. ((Entity*)target)->features.soga_eye_brow_type[index] = new_value;
  1458. 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]);
  1459. }
  1460. break;
  1461. }
  1462. case SPAWN_SET_SOGA_EYE_TYPE:{
  1463. if(target->IsEntity() && index < 3){
  1464. sint8 new_value = atoi(value);
  1465. ((Entity*)target)->features.soga_eye_type[index] = new_value;
  1466. 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]);
  1467. }
  1468. break;
  1469. }
  1470. case SPAWN_SET_SOGA_LIP_TYPE:{
  1471. if(target->IsEntity() && index < 3){
  1472. sint8 new_value = atoi(value);
  1473. ((Entity*)target)->features.soga_lip_type[index] = new_value;
  1474. 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]);
  1475. }
  1476. break;
  1477. }
  1478. case SPAWN_SET_SOGA_NOSE_TYPE:{
  1479. if(target->IsEntity() && index < 3){
  1480. sint8 new_value = atoi(value);
  1481. ((Entity*)target)->features.soga_nose_type[index] = new_value;
  1482. 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]);
  1483. }
  1484. break;
  1485. }
  1486. case SPAWN_SET_SOGA_BODY_SIZE:{
  1487. if(target->IsEntity()){
  1488. int8 new_value = atoul(value);
  1489. ((Entity*)target)->features.body_size = new_value;
  1490. UpdateDatabaseAppearance(client, target, "body_size", ((Entity*)target)->features.body_size, 0, 0);
  1491. }
  1492. break;
  1493. }
  1494. case SPAWN_SET_SOGA_BODY_AGE:{
  1495. if(target->IsEntity()){
  1496. int8 new_value = atoul(value);
  1497. ((Entity*)target)->features.body_age = new_value;
  1498. UpdateDatabaseAppearance(client, target, "body_age", ((Entity*)target)->features.body_age, 0, 0);
  1499. }
  1500. break;
  1501. }
  1502. case SPAWN_SET_ATTACK_TYPE:{
  1503. if(target->IsEntity()){
  1504. int8 new_value = atoul(value);
  1505. ((Entity*)target)->GetInfoStruct()->set_attack_type(new_value);
  1506. if(target->IsNPC()) {
  1507. if(target->GetDatabaseID()) {
  1508. Query spawnNPCQuery;
  1509. spawnNPCQuery.AddQueryAsync(0, &database, Q_INSERT, "update spawn_npcs set attack_type=%u where id=%u", new_value, target->GetDatabaseID());
  1510. } else if(client) {
  1511. client->Message(CHANNEL_COLOR_RED, "Invalid spawn to update the database (NPC only) or no database id for the NPC present.");
  1512. }
  1513. }
  1514. }
  1515. break;
  1516. }
  1517. case SPAWN_SET_RACE_TYPE:{
  1518. if(target->GetModelType() > 0){
  1519. Seperator* tmpsep = new Seperator(value, ' ', 3, 500, true);
  1520. if (tmpsep->IsNumber(0))
  1521. {
  1522. Query typequery;
  1523. int16 race_type = atoul(value);
  1524. const char* category = tmpsep->IsSet(1) ? tmpsep->arg[1] : "NULL";
  1525. const char* subcategory = tmpsep->IsSet(2) ? tmpsep->arg[2] : "NULL";
  1526. const char* model_name = tmpsep->IsSet(3) ? tmpsep->arg[3] : "NULL";
  1527. if(race_types_list.AddRaceType(target->GetModelType(), race_type, category, subcategory, model_name)) {
  1528. 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);
  1529. 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);
  1530. }
  1531. else {
  1532. 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);
  1533. race_types_list.AddRaceType(target->GetModelType(), race_type, category, subcategory, model_name, true);
  1534. 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());
  1535. }
  1536. }
  1537. safe_delete(tmpsep);
  1538. }
  1539. break;
  1540. }
  1541. case SPAWN_SET_LOOT_TIER:{
  1542. int32 new_value = atoul(value);
  1543. target->SetLootTier(new_value);
  1544. if (target->GetDatabaseID() > 0)
  1545. {
  1546. char query[256];
  1547. snprintf(query, 256, "update spawn set loot_tier=%u where id=%u", atoul(value), target->GetDatabaseID());
  1548. if (database.RunQuery(query, strnlen(query, 256)))
  1549. {
  1550. if(client)
  1551. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  1552. }
  1553. }
  1554. break;
  1555. }
  1556. case SPAWN_SET_LOOT_DROP_TYPE:{
  1557. int32 new_value = atoul(value);
  1558. target->SetLootDropType(new_value);
  1559. if (target->GetDatabaseID() > 0)
  1560. {
  1561. char query[256];
  1562. snprintf(query, 256, "update spawn set loot_drop_type=%u where id=%u", atoul(value), target->GetDatabaseID());
  1563. if (database.RunQuery(query, strnlen(query, 256)))
  1564. {
  1565. if(client)
  1566. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  1567. }
  1568. }
  1569. break;
  1570. }
  1571. }
  1572. }
  1573. return true;
  1574. }
  1575. void Commands::UpdateDatabaseAppearance(Client* client, Spawn* target, string fieldName, sint8 r, sint8 g, sint8 b)
  1576. {
  1577. Query replaceQuery;
  1578. if(target->IsBot())
  1579. {
  1580. Bot* bot = (Bot*)target;
  1581. if(bot->BotID)
  1582. database.SaveBotFloats(bot->BotID, fieldName.c_str(), r, g, b);
  1583. }
  1584. else if(target->IsPlayer())
  1585. {
  1586. replaceQuery.AddQueryAsync(0, &database, Q_DELETE, "delete from char_colors where char_id=%u and type='%s'", ((Player*)target)->GetCharacterID(), fieldName.c_str());
  1587. 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);
  1588. }
  1589. else
  1590. {
  1591. replaceQuery.AddQueryAsync(0, &database, Q_DELETE, "delete from npc_appearance where spawn_id=%u and type='%s'", target->GetDatabaseID(), fieldName.c_str());
  1592. 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);
  1593. }
  1594. ((Entity*)target)->changed = true;
  1595. ((Entity*)target)->info_changed = true;
  1596. if(target->GetZone())
  1597. target->GetZone()->AddChangedSpawn(target);
  1598. }
  1599. /* The zone object will be NULL if the zone is not currently running. We pass both of these in so we can update
  1600. the database fields always and also update the zone in memory if it's running. */
  1601. bool Commands::SetZoneCommand(Client* client, int32 zone_id, ZoneServer* zone, int8 type, const char* value) {
  1602. if (client && zone_id > 0 && type > 0 && value) {
  1603. sint32 int_value = 0;
  1604. float float_value = 0;
  1605. if (type == ZONE_SET_VALUE_SAFE_X || type == ZONE_SET_VALUE_SAFE_Y || type == ZONE_SET_VALUE_SAFE_Z || type == ZONE_SET_VALUE_UNDERWORLD) {
  1606. try {
  1607. float_value = atof(value);
  1608. }
  1609. catch (...) {
  1610. client->Message(CHANNEL_COLOR_RED, "Error converting '%s' to a float value", value);
  1611. return false;
  1612. }
  1613. }
  1614. 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) {
  1615. try {
  1616. int_value = atoi(value);
  1617. }
  1618. catch (...) {
  1619. client->Message(CHANNEL_COLOR_RED, "Error converting '%s' to an integer value", value);
  1620. return false;
  1621. }
  1622. }
  1623. switch (type) {
  1624. case ZONE_SET_VALUE_EXPANSION_ID: {
  1625. break;
  1626. }
  1627. case ZONE_SET_VALUE_NAME: {
  1628. if (zone)
  1629. zone->SetZoneName(const_cast<char*>(value));
  1630. database.SaveZoneInfo(zone_id, "name", value);
  1631. break;
  1632. }
  1633. case ZONE_SET_VALUE_FILE: {
  1634. if (zone)
  1635. zone->SetZoneFile(const_cast<char*>(value));
  1636. database.SaveZoneInfo(zone_id, "file", value);
  1637. break;
  1638. }
  1639. case ZONE_SET_VALUE_DESCRIPTION: {
  1640. if (zone)
  1641. zone->SetZoneDescription(const_cast<char*>(value));
  1642. database.SaveZoneInfo(zone_id, "description", value);
  1643. break;
  1644. }
  1645. case ZONE_SET_VALUE_SAFE_X: {
  1646. if (zone)
  1647. zone->SetSafeX(float_value);
  1648. database.SaveZoneInfo(zone_id, "safe_x", float_value);
  1649. break;
  1650. }
  1651. case ZONE_SET_VALUE_SAFE_Y: {
  1652. if (zone)
  1653. zone->SetSafeY(float_value);
  1654. database.SaveZoneInfo(zone_id, "safe_y", float_value);
  1655. break;
  1656. }
  1657. case ZONE_SET_VALUE_SAFE_Z: {
  1658. if (zone)
  1659. zone->SetSafeZ(float_value);
  1660. database.SaveZoneInfo(zone_id, "safe_z", float_value);
  1661. break;
  1662. }
  1663. case ZONE_SET_VALUE_UNDERWORLD: {
  1664. if (zone)
  1665. zone->SetUnderWorld(float_value);
  1666. database.SaveZoneInfo(zone_id, "underworld", float_value);
  1667. break;
  1668. }
  1669. case ZONE_SET_VALUE_MIN_RECOMMENDED: {
  1670. break;
  1671. }
  1672. case ZONE_SET_VALUE_MAX_RECOMMENDED: {
  1673. break;
  1674. }
  1675. case ZONE_SET_VALUE_ZONE_TYPE: {
  1676. break;
  1677. }
  1678. case ZONE_SET_VALUE_ALWAYS_LOADED: {
  1679. if (zone)
  1680. zone->SetAlwaysLoaded(int_value == 1);
  1681. database.SaveZoneInfo(zone_id, "always_loaded", int_value);
  1682. break;
  1683. }
  1684. case ZONE_SET_VALUE_CITY_ZONE: {
  1685. if (zone)
  1686. zone->SetCityZone(int_value == 1);
  1687. database.SaveZoneInfo(zone_id, "city_zone", int_value);
  1688. break;
  1689. }
  1690. case ZONE_SET_VALUE_WEATHER_ALLOWED: {
  1691. if (zone)
  1692. zone->SetWeatherAllowed(int_value == 1);
  1693. database.SaveZoneInfo(zone_id, "weather_allowed", int_value);
  1694. break;
  1695. }
  1696. case ZONE_SET_VALUE_MIN_STATUS: {
  1697. if (zone)
  1698. zone->SetMinimumStatus(int_value);
  1699. database.SaveZoneInfo(zone_id, "min_status", int_value);
  1700. break;
  1701. }
  1702. case ZONE_SET_VALUE_MIN_LEVEL: {
  1703. if (zone)
  1704. zone->SetMinimumLevel(int_value);
  1705. database.SaveZoneInfo(zone_id, "min_level", int_value);
  1706. break;
  1707. }
  1708. case ZONE_SET_VALUE_MAX_LEVEL: {
  1709. if (zone)
  1710. zone->SetMaximumLevel(int_value);
  1711. database.SaveZoneInfo(zone_id, "max_level", int_value);
  1712. break;
  1713. }
  1714. case ZONE_SET_VALUE_START_ZONE: {
  1715. database.SaveZoneInfo(zone_id, "start_zone", int_value);
  1716. break;
  1717. }
  1718. case ZONE_SET_VALUE_INSTANCE_TYPE: {
  1719. if (zone)
  1720. zone->SetInstanceType(int_value);
  1721. database.SaveZoneInfo(zone_id, "instance_type", int_value);
  1722. break;
  1723. }
  1724. case ZONE_SET_VALUE_DEFAULT_REENTER_TIME: {
  1725. if (zone)
  1726. zone->SetDefaultReenterTime(int_value);
  1727. database.SaveZoneInfo(zone_id, "default_reenter_time", int_value);
  1728. break;
  1729. }
  1730. case ZONE_SET_VALUE_DEFAULT_RESET_TIME: {
  1731. if (zone)
  1732. zone->SetDefaultResetTime(int_value);
  1733. database.SaveZoneInfo(zone_id, "default_reset_time", int_value);
  1734. break;
  1735. }
  1736. case ZONE_SET_VALUE_DEFAULT_LOCKOUT_TIME: {
  1737. if (zone)
  1738. zone->SetDefaultLockoutTime(int_value);
  1739. database.SaveZoneInfo(zone_id, "default_lockout_time", int_value);
  1740. break;
  1741. }
  1742. case ZONE_SET_VALUE_FORCE_GROUP_TO_ZONE: {
  1743. if (zone)
  1744. zone->SetForceGroupZoneOption(int_value);
  1745. database.SaveZoneInfo(zone_id, "force_group_to_zone", int_value);
  1746. break;
  1747. }
  1748. case ZONE_SET_VALUE_LUA_SCRIPT: {
  1749. if (lua_interface && lua_interface->GetZoneScript(value) == 0) {
  1750. client->Message(CHANNEL_COLOR_RED, "Invalid Zone Script file. Be sure you give the absolute path.");
  1751. client->Message(CHANNEL_COLOR_RED, "Example: /zone set lua_script 'ZoneScripts/QueensColony.lua'");
  1752. return false;
  1753. }
  1754. else {
  1755. world.AddZoneScript(zone_id, const_cast<char*>(value));
  1756. database.SaveZoneInfo(zone_id, "lua_script", value);
  1757. }
  1758. break;
  1759. }
  1760. case ZONE_SET_VALUE_SHUTDOWN_TIMER: {
  1761. if (zone)
  1762. zone->SetShutdownTimer(int_value);
  1763. database.SaveZoneInfo(zone_id, "shutdown_timer", int_value);
  1764. break;
  1765. }
  1766. case ZONE_SET_VALUE_ZONE_MOTD: {
  1767. if (zone)
  1768. zone->SetZoneMOTD(string(value));
  1769. database.SaveZoneInfo(zone_id, "zone_motd", value);
  1770. break;
  1771. }
  1772. default: {
  1773. client->Message(CHANNEL_COLOR_RED, "Invalid zone attribute %i", type);
  1774. return false;
  1775. }
  1776. }
  1777. }
  1778. else {
  1779. if (client)
  1780. client->SimpleMessage(CHANNEL_COLOR_RED, "An error occured saving new zone data.");
  1781. return false;
  1782. }
  1783. return true;
  1784. }
  1785. void Commands::Process(int32 index, EQ2_16BitString* command_parms, Client* client, Spawn* targetOverride) {
  1786. if (index >= remote_commands->commands.size()) {
  1787. LogWrite(COMMAND__ERROR, 0, "Command", "Error, command handler of %u was requested, but max handler is %u", index, remote_commands->commands.size());
  1788. return;
  1789. }
  1790. Spawn* cmdTarget = targetOverride ? targetOverride : client->GetPlayer()->GetTarget();
  1791. EQ2_RemoteCommandString* parent_command = 0;
  1792. EQ2_RemoteCommandString* command = &remote_commands->commands[index];
  1793. Seperator* sep = 0;
  1794. if (command_parms->size > 0) {
  1795. sep = new Seperator(command_parms->data.c_str(), ' ', 10, 500, true);
  1796. if (sep && sep->arg[0] && remote_commands->validSubCommand(command->command.data, string(sep->arg[0]))) {
  1797. parent_command = command;
  1798. command = &(remote_commands->subcommands[command->command.data][string(sep->arg[0])]);
  1799. safe_delete(sep);
  1800. if (command_parms->data.length() > (command->command.data.length() + 1))
  1801. sep = new Seperator(command_parms->data.c_str() + (command->command.data.length() + 1), ' ', 10, 500, true);
  1802. LogWrite(COMMAND__DEBUG, 1, "Command", "Handler: %u, COMMAND: '%s', SUBCOMMAND: '%s'", index, parent_command->command.data.c_str(), command->command.data.c_str());
  1803. }
  1804. else
  1805. LogWrite(COMMAND__DEBUG, 1, "Command", "Handler: %u, COMMAND: '%s'", index, command->command.data.c_str());
  1806. }
  1807. int ndx = 0;
  1808. if (command->required_status > client->GetAdminStatus())
  1809. {
  1810. 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());
  1811. safe_delete(sep);
  1812. client->SimpleMessage(3, "Error: Your status is insufficient for this command.");
  1813. return;
  1814. }
  1815. Player* player = client->GetPlayer();
  1816. LogWrite(COMMAND__DEBUG, 0, "Command", "Player '%s' (%u), Command: %s", player->GetName(), client->GetAccountID(), command->command.data.c_str());
  1817. switch (command->handler) {
  1818. case COMMAND_RELOAD: {
  1819. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reload commands:");
  1820. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload structs");
  1821. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload items");
  1822. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload luasystem");
  1823. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spawnscripts");
  1824. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spells");
  1825. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spells npc");
  1826. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload quests");
  1827. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spawns");
  1828. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload groundspawns");
  1829. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload zonescripts");
  1830. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload entity_commands");
  1831. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload factions");
  1832. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload mail");
  1833. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload guilds");
  1834. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload locations");
  1835. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload rules");
  1836. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload transporters");
  1837. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload startabilities");
  1838. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload voiceovers");
  1839. break;
  1840. }
  1841. case COMMAND_RELOADSTRUCTS: {
  1842. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Structs...");
  1843. world.SetReloadingSubsystem("Structs");
  1844. configReader.ReloadStructs();
  1845. world.RemoveReloadingSubSystem("Structs");
  1846. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1847. break;
  1848. }
  1849. case COMMAND_RELOAD_QUESTS: {
  1850. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Quests...");
  1851. world.SetReloadingSubsystem("Quests");
  1852. master_quest_list.Reload();
  1853. client_list.ReloadQuests();
  1854. zone_list.ReloadClientQuests();
  1855. world.RemoveReloadingSubSystem("Quests");
  1856. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1857. break;
  1858. }
  1859. case COMMAND_RELOAD_SPAWNS: {
  1860. client->GetCurrentZone()->ReloadSpawns();
  1861. break;
  1862. }
  1863. case COMMAND_RELOAD_SPELLS: {
  1864. if (sep && sep->arg[0] && strcmp(sep->arg[0], "npc") == 0) {
  1865. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading NPC Spells Lists (Note: Must Reload Spawns/Repop to reset npc spells)...");
  1866. world.PurgeNPCSpells();
  1867. database.LoadNPCSpells();
  1868. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1869. }
  1870. else {
  1871. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spells & NPC Spell Lists (Note: Must Reload Spawns/Repop to reset npc spells)...");
  1872. world.SetReloadingSubsystem("Spells");
  1873. zone_list.DeleteSpellProcess();
  1874. master_spell_list.Reload();
  1875. if (lua_interface)
  1876. lua_interface->ReloadSpells();
  1877. zone_list.LoadSpellProcess();
  1878. world.RemoveReloadingSubSystem("Spells");
  1879. world.PurgeNPCSpells();
  1880. database.LoadNPCSpells();
  1881. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1882. }
  1883. break;
  1884. }
  1885. case COMMAND_RELOAD_GROUNDSPAWNS: {
  1886. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Groundspawn Entries...");
  1887. world.SetReloadingSubsystem("GroundSpawns");
  1888. client->GetCurrentZone()->DeleteGroundSpawnItems();
  1889. client->GetCurrentZone()->LoadGroundSpawnEntries();
  1890. world.RemoveReloadingSubSystem("GroundSpawns");
  1891. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1892. break;
  1893. }
  1894. case COMMAND_RELOAD_ZONESCRIPTS: {
  1895. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Zone Scripts...");
  1896. world.SetReloadingSubsystem("ZoneScripts");
  1897. world.ResetZoneScripts();
  1898. database.LoadZoneScriptData();
  1899. if (lua_interface)
  1900. lua_interface->DestroyZoneScripts();
  1901. world.RemoveReloadingSubSystem("ZoneScripts");
  1902. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1903. break;
  1904. }
  1905. case COMMAND_RELOAD_ENTITYCOMMANDS: {
  1906. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Entity Commands...");
  1907. world.SetReloadingSubsystem("EntityCommands");
  1908. client->GetCurrentZone()->ClearEntityCommands();
  1909. database.LoadEntityCommands(client->GetCurrentZone());
  1910. world.RemoveReloadingSubSystem("EntityCommands");
  1911. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1912. break;
  1913. }
  1914. case COMMAND_RELOAD_FACTIONS: {
  1915. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Factions...");
  1916. world.SetReloadingSubsystem("Factions");
  1917. master_faction_list.Clear();
  1918. database.LoadFactionList();
  1919. world.RemoveReloadingSubSystem("Factions");
  1920. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1921. break;
  1922. }
  1923. case COMMAND_RELOAD_MAIL: {
  1924. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Mail...");
  1925. zone_list.ReloadMail();
  1926. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1927. break;
  1928. }
  1929. case COMMAND_RELOAD_GUILDS: {
  1930. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Guilds...");
  1931. world.ReloadGuilds();
  1932. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1933. break;
  1934. }
  1935. case COMMAND_RELOAD_LOCATIONS: {
  1936. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Locations...");
  1937. client->GetPlayer()->GetZone()->RemoveLocationGrids();
  1938. database.LoadLocationGrids(client->GetPlayer()->GetZone());
  1939. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1940. break;
  1941. }
  1942. case COMMAND_RELOAD_RULES: {
  1943. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Rules...");
  1944. database.LoadRuleSets(true);
  1945. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1946. break;
  1947. }
  1948. case COMMAND_RELOAD_TRANSPORTERS: {
  1949. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Transporters in your current zone...");
  1950. database.LoadTransporters(client->GetCurrentZone());
  1951. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1952. break;
  1953. }
  1954. case COMMAND_RELOAD_STARTABILITIES: {
  1955. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Starting Skills/Spells...");
  1956. world.PurgeStartingLists();
  1957. world.LoadStartingLists();
  1958. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1959. break;
  1960. }
  1961. case COMMAND_RELOAD_VOICEOVERS: {
  1962. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Voiceovers...");
  1963. world.PurgeVoiceOvers();
  1964. world.LoadVoiceOvers();
  1965. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1966. break;
  1967. }
  1968. case COMMAND_READ: {
  1969. if (sep && sep->arg[1][0] && sep->IsNumber(1)) {
  1970. if (strcmp(sep->arg[0], "read") == 0) {
  1971. int32 item_index = atol(sep->arg[1]);
  1972. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  1973. if (item) {
  1974. Spawn* spawn = cmdTarget;
  1975. client->SendShowBook(client->GetPlayer(), item->name, item->book_language, item->book_pages);
  1976. break;
  1977. }
  1978. }
  1979. }
  1980. break;
  1981. }
  1982. case COMMAND_USEABILITY:{
  1983. if (sep && sep->arg[0][0] && sep->IsNumber(0)) {
  1984. if (client->GetPlayer()->GetHP() == 0) {
  1985. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot do that right now.");
  1986. }
  1987. else {
  1988. int32 spell_id = atoul(sep->arg[0]);
  1989. int8 spell_tier = 0;
  1990. if (sep->arg[1][0] && sep->IsNumber(1))
  1991. spell_tier = atoi(sep->arg[1]);
  1992. else
  1993. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  1994. if (!spell_tier)
  1995. spell_tier = 1;
  1996. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  1997. if (spell) {
  1998. 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)
  1999. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), cmdTarget, true, true);
  2000. else
  2001. {
  2002. if (cmdTarget)
  2003. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), cmdTarget);
  2004. else
  2005. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  2006. }
  2007. }
  2008. }
  2009. }
  2010. else if (cmdTarget && cmdTarget->IsWidget())
  2011. {
  2012. Widget* widget = (Widget*)cmdTarget;
  2013. widget->HandleUse(client, "use", WIDGET_TYPE_DOOR);
  2014. }
  2015. else
  2016. {
  2017. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /useability {spell_id} [spell_tier]");
  2018. }
  2019. break;
  2020. }
  2021. case COMMAND_INFO:{
  2022. if(sep && sep->arg[1][0] && sep->IsNumber(1)){
  2023. if(strcmp(sep->arg[0], "inventory") == 0){
  2024. int32 item_index = atol(sep->arg[1]);
  2025. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  2026. if(item){
  2027. if (item->IsCollectable() && client->SendCollectionsForItem(item))
  2028. break;
  2029. EQ2Packet* app = item->serialize(client->GetVersion(), (!item->GetItemScript() || !lua_interface), client->GetPlayer());
  2030. //DumpPacket(app);
  2031. client->QueuePacket(app);
  2032. if(item->GetItemScript() && lua_interface)
  2033. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  2034. else if(item->generic_info.offers_quest_id > 0){ //leave the current functionality in place if it doesnt have an item script
  2035. Quest* quest = master_quest_list.GetQuest(item->generic_info.offers_quest_id, false);
  2036. if(quest && client->GetPlayer()->GetCompletedQuest(item->generic_info.offers_quest_id) == 0 && client->GetPlayer()->GetQuest(item->generic_info.offers_quest_id) == 0)
  2037. client->AddPendingQuest(new Quest(quest)); // copy quest since we pulled the master quest to see if it existed or not
  2038. }
  2039. }
  2040. else
  2041. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Index: %u", item_index);
  2042. }
  2043. else if(strcmp(sep->arg[0], "equipment") == 0){
  2044. int32 item_index = atol(sep->arg[1]);
  2045. Item* item = client->GetPlayer()->GetEquipmentList()->GetItem(item_index);
  2046. if(item){
  2047. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  2048. client->QueuePacket(app);
  2049. if(item->GetItemScript() && lua_interface)
  2050. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  2051. }
  2052. else
  2053. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Index: %u", item_index);
  2054. }
  2055. else if(strcmp(sep->arg[0], "appearance") == 0){
  2056. int32 item_index = atol(sep->arg[1]);
  2057. Item* item = client->GetPlayer()->GetAppearanceEquipmentList()->GetItem(item_index);
  2058. if(item){
  2059. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  2060. client->QueuePacket(app);
  2061. if(item->GetItemScript() && lua_interface)
  2062. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  2063. }
  2064. else
  2065. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Index: %u", item_index);
  2066. }
  2067. 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){
  2068. int32 item_id = atoul(sep->arg[1]);
  2069. Item* item = master_item_list.GetItem(item_id);
  2070. if(item){
  2071. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  2072. client->QueuePacket(app);
  2073. }
  2074. else
  2075. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Item ID: %u", item_id);
  2076. }
  2077. else if (strcmp(sep->arg[0], "spell") == 0) {
  2078. sint32 spell_id = atol(sep->arg[1]);
  2079. int8 tier = atoi(sep->arg[3]);
  2080. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, tier, client, true, 0x2A);
  2081. if (outapp)
  2082. client->QueuePacket(outapp);
  2083. else
  2084. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  2085. }
  2086. else if (strcmp(sep->arg[0], "achievement") == 0) {
  2087. sint32 spell_id = atol(sep->arg[2]);
  2088. int8 group = atoi(sep->arg[1]);
  2089. AltAdvanceData* data = 0;
  2090. SpellBookEntry* spellentry = 0;
  2091. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  2092. LogWrite(COMMAND__ERROR, 0, "Command", "AA Spell ID and/or Tier, ID: %u, Group: %i", spell_id, group);
  2093. EQ2Packet* outapp = master_spell_list.GetAASpellPacket(spell_id, tier, client, true, 0x45);
  2094. if (outapp)
  2095. client->QueuePacket(outapp);
  2096. else
  2097. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, group);
  2098. }
  2099. else if (strcmp(sep->arg[0], "spellbook") == 0) {
  2100. sint32 spell_id = atol(sep->arg[1]);
  2101. int32 tier = atoi(sep->arg[2]);
  2102. if (tier > 255) {
  2103. SpellBookEntry* ent = client->GetPlayer()->GetSpellBookSpell(spell_id);
  2104. if (ent)
  2105. tier = ent->tier;
  2106. }
  2107. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, (int8)tier, client, true, 0x2A);
  2108. if (outapp)
  2109. client->QueuePacket(outapp);
  2110. else
  2111. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  2112. }
  2113. else if (strcmp(sep->arg[0], "recipe") == 0) {
  2114. sint32 recipe_id = atol(sep->arg[1]);
  2115. EQ2Packet* outapp = master_recipe_list.GetRecipePacket(recipe_id, client, true, 0x2C);
  2116. if(outapp)
  2117. client->QueuePacket(outapp);
  2118. else
  2119. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Recipe ID: %u", recipe_id);
  2120. }
  2121. else if (strcmp(sep->arg[0], "maintained") ==0) {
  2122. int32 slot = atol(sep->arg[1]);
  2123. int32 spell_id = atol(sep->arg[2]);
  2124. LogWrite(COMMAND__DEBUG, 5, "Command", "Unknown Spell ID - Slot: %u unknown: %u", slot, spell_id);
  2125. //int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  2126. MaintainedEffects* info = client->GetPlayer()->GetMaintainedSpellBySlot(slot);
  2127. EQ2Packet* outapp = master_spell_list.GetSpellPacket(info->spell_id, info->tier, client, true, 0x00);
  2128. if(outapp)
  2129. client->QueuePacket(outapp);
  2130. else
  2131. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID: %u", spell_id);
  2132. }
  2133. else if (strcmp(sep->arg[0], "effect") == 0) {
  2134. int32 spell_id = atol(sep->arg[1]);
  2135. LogWrite(COMMAND__DEBUG, 5, "Command", "Unknown Spell ID: %u", spell_id);
  2136. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  2137. int8 type = 0;
  2138. if (client->GetVersion() <= 546)
  2139. type = 1;
  2140. EQ2Packet* outapp = master_spell_list.GetSpecialSpellPacket(spell_id, tier, client, true, type);
  2141. if (outapp){
  2142. client->QueuePacket(outapp);
  2143. }
  2144. else
  2145. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID: %u", spell_id);
  2146. }
  2147. }
  2148. else if (sep && strcmp(sep->arg[0], "overflow") == 0) {
  2149. Item* item = player->item_list.GetOverflowItem();
  2150. if(item) {
  2151. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  2152. client->QueuePacket(app);
  2153. }
  2154. else
  2155. LogWrite(COMMAND__ERROR, 0,"Command", "Unable to retrieve an overflow item.");
  2156. }
  2157. else
  2158. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /info {inventory|equipment|spell} {id}");
  2159. break;
  2160. }
  2161. case COMMAND_USE_EQUIPPED_ITEM:{
  2162. if (sep && sep->arg[0] && sep->IsNumber(0)){
  2163. int32 slot_id = atoul(sep->arg[0]);
  2164. Item* item = player->GetEquipmentList()->GetItem(slot_id);
  2165. if (item && item->generic_info.usable && item->GetItemScript()) {
  2166. if(!item->CheckFlag2(INDESTRUCTABLE) && item->generic_info.condition == 0) {
  2167. client->SimpleMessage(CHANNEL_COLOR_RED, "This item is broken and must be repaired at a mender before it can be used");
  2168. }
  2169. else if (item->CheckFlag(EVIL_ONLY) && client->GetPlayer()->GetAlignment() != ALIGNMENT_EVIL) {
  2170. client->Message(0, "%s requires an evil race.", item->name.c_str());
  2171. }
  2172. else if (item->CheckFlag(GOOD_ONLY) && client->GetPlayer()->GetAlignment() != ALIGNMENT_GOOD) {
  2173. client->Message(0, "%s requires a good race.", item->name.c_str());
  2174. }
  2175. else {
  2176. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player, player->GetTarget());
  2177. }
  2178. }
  2179. }
  2180. break;
  2181. }
  2182. case COMMAND_USE_ITEM: {
  2183. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  2184. int32 item_index = atoul(sep->arg[0]);
  2185. Item* item = player->item_list.GetItemFromIndex(item_index);
  2186. client->UseItem(item, client->GetPlayer()->GetTarget() ? client->GetPlayer()->GetTarget() : client->GetPlayer());
  2187. }
  2188. break;
  2189. }
  2190. case COMMAND_SCRIBE_SCROLL_ITEM: {
  2191. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  2192. Item* item = player->item_list.GetItemFromUniqueID(atoul(sep->arg[0]));
  2193. if (item) {
  2194. LogWrite(ITEM__DEBUG, 0, "Items", "ITEM ID: %u", item->details.item_id);
  2195. if(item->generic_info.item_type == 6) {
  2196. Spell* spell = master_spell_list.GetSpell(item->skill_info->spell_id, item->skill_info->spell_tier);
  2197. int8 old_slot = 0;
  2198. if (spell) {
  2199. if(!spell->ScribeAllowed(client->GetPlayer())) {
  2200. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not meet one of the requirements to scribe, due to class or level.");
  2201. break;
  2202. }
  2203. int16 tier_up = player->GetTierUp(spell->GetSpellTier());
  2204. if (rule_manager.GetGlobalRule(R_Spells, RequirePreviousTierScribe)->GetInt8() && !player->HasSpell(spell->GetSpellID(), tier_up, false, true))
  2205. client->SimpleMessage(CHANNEL_COLOR_RED, "You have not scribed the required previous version of this ability.");
  2206. else if (!player->HasSpell(spell->GetSpellID(), spell->GetSpellTier(), true)) {
  2207. old_slot = player->GetSpellSlot(spell->GetSpellID());
  2208. player->RemoveSpellBookEntry(spell->GetSpellID());
  2209. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  2210. player->UnlockSpell(spell);
  2211. client->SendSpellUpdate(spell);
  2212. database.DeleteItem(client->GetCharacterID(), item, 0);
  2213. player->item_list.RemoveItem(item, true);
  2214. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  2215. client->QueuePacket(player->SendInventoryUpdate(client->GetVersion()));
  2216. // force purge client cache and display updated spell for hover over
  2217. EQ2Packet* app = spell->SerializeSpell(client, false, false);
  2218. client->QueuePacket(app);
  2219. }
  2220. }
  2221. else
  2222. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown spell ID: %u and tier: %u", item->skill_info->spell_id, item->skill_info->spell_tier);
  2223. }
  2224. else if(item->generic_info.item_type == 7){
  2225. if(item->recipebook_info) {
  2226. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Scribing recipe book %s (%u) for player %s.", item->name.c_str(), item->recipebook_info->recipe_id, player->GetName());
  2227. Recipe* master_recipe = master_recipebook_list.GetRecipeBooks(item->recipebook_info->recipe_id);
  2228. if(master_recipe) {
  2229. Recipe* recipe_book = new Recipe(master_recipe);//(item->details.item_id));
  2230. // if valid recipe book and the player doesn't have it
  2231. if (recipe_book && recipe_book->GetLevel() > client->GetPlayer()->GetTSLevel()) {
  2232. client->Message(CHANNEL_NARRATIVE, "Your tradeskill level is not high enough to scribe this book.");
  2233. safe_delete(recipe_book);
  2234. }
  2235. else if(recipe_book && !recipe_book->CanUseRecipeByClass(item, client->GetPlayer()->GetTradeskillClass())) {
  2236. client->Message(CHANNEL_NARRATIVE, "Your tradeskill class cannot use this recipe.");
  2237. safe_delete(recipe_book);
  2238. }
  2239. else if (recipe_book && !(client->GetPlayer()->GetRecipeBookList()->HasRecipeBook(item->recipebook_info->recipe_id))){// (item->details.item_id))) {
  2240. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Valid recipe book that the player doesn't have");
  2241. // Add recipe book to the players list
  2242. client->GetPlayer()->GetRecipeBookList()->AddRecipeBook(recipe_book);
  2243. // Get a list of all recipes this book contains
  2244. vector<Recipe*> recipes = master_recipe_list.GetRecipes(recipe_book->GetBookName());
  2245. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "%i recipes found for %s book", recipes.size(), recipe_book->GetBookName());
  2246. if (recipes.empty() && item->recipebook_info) {
  2247. //Backup I guess if the recipe book is empty for whatever reason?
  2248. for (auto& itr : item->recipebook_info->recipes) {
  2249. Recipe* r = master_recipe_list.GetRecipeByName(itr.c_str());
  2250. if (r) {
  2251. recipes.push_back(r);
  2252. }
  2253. }
  2254. }
  2255. //Filter out duplicate recipes the player already has
  2256. for (auto itr = recipes.begin(); itr != recipes.end();) {
  2257. Recipe* recipe = *itr;
  2258. if (client->GetPlayer()->GetRecipeList()->GetRecipe(recipe->GetID())) {
  2259. itr = recipes.erase(itr);
  2260. }
  2261. else itr++;
  2262. }
  2263. int16 i = 0;
  2264. // Create the packet to send to update the players recipe list
  2265. PacketStruct* packet = 0;
  2266. if (!recipes.empty() && client->GetRecipeListSent()) {
  2267. packet = configReader.getStruct("WS_RecipeList", client->GetVersion());
  2268. if (packet) {
  2269. packet->setArrayLengthByName("num_recipes", recipes.size());
  2270. }
  2271. }
  2272. for (int32 r = 0; r < recipes.size(); r++) {
  2273. Recipe* recipe = recipes[r];
  2274. if (recipe) {
  2275. Recipe* player_recipe = new Recipe(recipe);
  2276. client->AddRecipeToPlayer(player_recipe, packet, &i);
  2277. }
  2278. }
  2279. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Done adding recipes");
  2280. database.SavePlayerRecipeBook(client->GetPlayer(), recipe_book->GetBookID());
  2281. database.DeleteItem(client->GetCharacterID(), item, 0);
  2282. client->GetPlayer()->item_list.RemoveItem(item, true);
  2283. client->QueuePacket(client->GetPlayer()->SendInventoryUpdate(client->GetVersion()));
  2284. if (packet && client->GetRecipeListSent())
  2285. client->QueuePacket(packet->serialize());
  2286. safe_delete(packet);
  2287. }
  2288. else {
  2289. if (recipe_book)
  2290. client->Message(CHANNEL_NARRATIVE, "You have already learned all you can from this item.");
  2291. safe_delete(recipe_book);
  2292. }
  2293. }
  2294. else {
  2295. 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);
  2296. 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());
  2297. }
  2298. }
  2299. else {
  2300. LogWrite(COMMAND__ERROR, 0, "Command", "Recipe Book Info is not set for item %s.", item->name.c_str());
  2301. }
  2302. }
  2303. }
  2304. else
  2305. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown unique item ID: %s", sep->arg[0]);
  2306. }
  2307. break;
  2308. }
  2309. case COMMAND_SUMMONITEM: {
  2310. if (sep && sep->IsNumber(0)) {
  2311. int32 item_id = atol(sep->arg[0]);
  2312. int32 quantity = 1;
  2313. if (sep->arg[1] && sep->IsNumber(1))
  2314. quantity = atoi(sep->arg[1]);
  2315. if (sep->arg[2] && strncasecmp(sep->arg[2], "bank", 4) == 0) {
  2316. client->AddItemToBank(item_id,quantity);
  2317. }
  2318. else {
  2319. client->AddItem(item_id, quantity);
  2320. }
  2321. }
  2322. else {
  2323. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} [quantity] or");
  2324. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} {quantity} [location] where location = bank");
  2325. }
  2326. break;
  2327. }
  2328. case COMMAND_COLLECTION_ADDITEM: {
  2329. // takes 2 params: collection_id, slot
  2330. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  2331. Item *item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(atoul(sep->arg[1]));
  2332. if (item)
  2333. client->HandleCollectionAddItem(atoul(sep->arg[0]), item);
  2334. else
  2335. 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]));
  2336. }
  2337. else
  2338. LogWrite(COLLECTION__ERROR, 0, "Collect", "Received command 'COMMAND_COLLECTION_ADDITEM' with unhandeled argument types");
  2339. break;
  2340. }
  2341. case COMMAND_COLLECTION_FILTER_MATCHITEM: {
  2342. // takes 1 param: slot
  2343. printf("COMMAND_COLLECTION_FILTER_MATCHITEM:\n");
  2344. int i = 0;
  2345. while (sep->arg[i] && strlen(sep->arg[i]) > 0) {
  2346. printf("\t%u: %s\n", i, sep->arg[i]);
  2347. i++;
  2348. }
  2349. break;
  2350. }
  2351. case COMMAND_WAYPOINT: {
  2352. bool success = false;
  2353. client->ClearWaypoint();
  2354. if (sep && sep->IsNumber(0) && sep->IsNumber(1) && sep->IsNumber(2)) {
  2355. if (!client->ShowPathToTarget(atof(sep->arg[0]), atof(sep->arg[1]), atof(sep->arg[2]), 0))
  2356. client->Message(CHANNEL_COLOR_RED, "Invalid coordinates given");
  2357. }
  2358. else if ( client->GetAdminStatus() > 100 && cmdTarget ) {
  2359. if (!client->ShowPathToTarget(cmdTarget->GetX(), cmdTarget->GetY(), cmdTarget->GetZ(), 0))
  2360. client->Message(CHANNEL_COLOR_RED, "Invalid coordinates given");
  2361. }
  2362. else {
  2363. client->Message(CHANNEL_COLOR_YELLOW, "Usage: /waypoint x y z");
  2364. }
  2365. break;
  2366. }
  2367. case COMMAND_WHO:{
  2368. const char* who = 0;
  2369. if(sep && sep->arg[0]){
  2370. //cout << "Who query: \n";
  2371. who = sep->argplus[0];
  2372. //cout << who << endl;
  2373. }
  2374. zone_list.ProcessWhoQuery(who, client);
  2375. break;
  2376. }
  2377. case COMMAND_SELECT_JUNCTION:{
  2378. // transporters (bells birds) use OP_SelectZoneTeleporterDestinatio / ProcessTeleportLocation(app)
  2379. // this is only used for revive it seems
  2380. int32 choice = 0;
  2381. if(sep && sep->arg[0] && sep->IsNumber(0))
  2382. choice = atoul(sep->arg[0]);
  2383. if(client->GetPlayer()->GetHP() == 0){ //dead and this is a revive request
  2384. client->HandlePlayerRevive(choice);
  2385. }
  2386. break;
  2387. }
  2388. case COMMAND_SPAWN_MOVE: {
  2389. if (cmdTarget && cmdTarget->IsPlayer() == false) {
  2390. PacketStruct* packet = configReader.getStruct("WS_MoveObjectMode", client->GetVersion());
  2391. if (packet) {
  2392. float unknown2_3 = 0;
  2393. int8 placement_mode = 0;
  2394. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::DEFAULT);
  2395. if (sep && sep->arg[0][0]) {
  2396. if (strcmp(sep->arg[0], "wall") == 0) {
  2397. placement_mode = 2;
  2398. unknown2_3 = 150;
  2399. }
  2400. else if (strcmp(sep->arg[0], "ceiling") == 0)
  2401. placement_mode = 1;
  2402. else if (strcmp(sep->arg[0], "openheading") == 0 && cmdTarget->IsWidget())
  2403. {
  2404. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "[PlacementMode] WIDGET OPEN HEADING MODE");
  2405. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::OPEN_HEADING);
  2406. }
  2407. else if (strcmp(sep->arg[0], "closeheading") == 0 && cmdTarget->IsWidget())
  2408. {
  2409. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "[PlacementMode] WIDGET CLOSE HEADING MODE");
  2410. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::CLOSE_HEADING);
  2411. }
  2412. else if (strcmp(sep->arg[0], "myloc") == 0)
  2413. {
  2414. if (cmdTarget->GetSpawnLocationPlacementID() < 1) {
  2415. client->Message(CHANNEL_COLOR_YELLOW, "[PlacementMode] Spawn %s cannot be moved it is not assigned a spawn location placement id.", cmdTarget->GetName());
  2416. safe_delete(packet);
  2417. break;
  2418. }
  2419. cmdTarget->SetX(client->GetPlayer()->GetX(), true);
  2420. cmdTarget->SetY(client->GetPlayer()->GetY(), true);
  2421. cmdTarget->SetZ(client->GetPlayer()->GetZ(), true);
  2422. cmdTarget->SetHeading(client->GetPlayer()->GetHeading(), true);
  2423. if (database.UpdateSpawnLocationSpawns(cmdTarget))
  2424. client->Message(CHANNEL_COLOR_YELLOW, "[PlacementMode] Spawn %s placed at your location. Updated spawn_location_placement for spawn.", cmdTarget->GetName());
  2425. safe_delete(packet);
  2426. break;
  2427. }
  2428. }
  2429. packet->setDataByName("placement_mode", placement_mode);
  2430. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget));
  2431. packet->setDataByName("model_type", cmdTarget->GetModelType());
  2432. packet->setDataByName("unknown", 1); //size
  2433. packet->setDataByName("unknown2", 1); //size 2
  2434. packet->setDataByName("unknown2", .5, 1); //size 3
  2435. packet->setDataByName("unknown2", 3, 2);
  2436. packet->setDataByName("unknown2", unknown2_3, 3);
  2437. packet->setDataByName("max_distance", 500);
  2438. packet->setDataByName("CoEunknown", 0xFFFFFFFF);
  2439. client->QueuePacket(packet->serialize());
  2440. safe_delete(packet);
  2441. }
  2442. }
  2443. else {
  2444. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /spawn move (wall OR ceiling)");
  2445. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Moves a spawn anywhere you like. Optionally wall/ceiling can be provided to place wall/ceiling items.");
  2446. }
  2447. break;
  2448. }
  2449. case COMMAND_HAIL:{
  2450. Spawn* spawn = cmdTarget;
  2451. if(spawn && spawn->GetTargetable())
  2452. {
  2453. char tmp[75] = {0};
  2454. sprintf(tmp, "Hail, %s", spawn->GetName());
  2455. bool show_bubble = true;
  2456. if (spawn->IsNPC())
  2457. show_bubble = false;
  2458. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp, HEAR_SPAWN_DISTANCE, 0, show_bubble, client->GetPlayer()->GetCurrentLanguage());
  2459. if(spawn->IsPlayer() == false && spawn->Alive() && spawn->GetDistance(client->GetPlayer()) < rule_manager.GetGlobalRule(R_Spawn, HailDistance)->GetInt32()){
  2460. if(spawn->IsNPC() && ((NPC*)spawn)->EngagedInCombat())
  2461. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED_BUSY, client->GetPlayer());
  2462. else
  2463. {
  2464. bool pauseRunback = false;
  2465. // prime runback as the heading or anything can be altered when hailing succeeds
  2466. if(spawn->IsNPC() && (spawn->HasMovementLoop() || spawn->HasMovementLocations()))
  2467. {
  2468. ((NPC*)spawn)->StartRunback();
  2469. pauseRunback = true;
  2470. }
  2471. if(spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED, client->GetPlayer()) && pauseRunback)
  2472. spawn->PauseMovement(rule_manager.GetGlobalRule(R_Spawn, HailMovementPause)->GetInt32());
  2473. else if(spawn->IsNPC() && pauseRunback)
  2474. ((NPC*)spawn)->ClearRunback();
  2475. }
  2476. }
  2477. }
  2478. else {
  2479. string tmp = "Hail";
  2480. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp.c_str(), HEAR_SPAWN_DISTANCE, 0, true, client->GetPlayer()->GetCurrentLanguage());
  2481. }
  2482. break;
  2483. }
  2484. case COMMAND_SAY:{
  2485. if (sep && sep->arg[0][0]) {
  2486. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, sep->argplus[0], HEAR_SPAWN_DISTANCE, 0, true, client->GetPlayer()->GetCurrentLanguage());
  2487. if (cmdTarget && !(cmdTarget->IsPlayer()))
  2488. client->GetCurrentZone()->CallSpawnScript(cmdTarget, SPAWN_SCRIPT_HEAR_SAY, client->GetPlayer(), sep->argplus[0]);
  2489. }
  2490. else
  2491. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /say {message}");
  2492. break;
  2493. }
  2494. case COMMAND_TELL:{
  2495. if(sep && sep->arg[0] && sep->argplus[1]){
  2496. if(!zone_list.HandleGlobalChatMessage(client, sep->arg[0], CHANNEL_PRIVATE_TELL, sep->argplus[1], 0, client->GetPlayer()->GetCurrentLanguage()))
  2497. client->Message(CHANNEL_COLOR_RED,"Unable to find client %s",sep->arg[0]);
  2498. }else
  2499. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /tell {character_name} {message}");
  2500. break;
  2501. }
  2502. case COMMAND_SHOUT:{
  2503. if(sep && sep->arg[0][0])
  2504. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SHOUT, sep->argplus[0], 0, 0, true, client->GetPlayer()->GetCurrentLanguage());
  2505. else
  2506. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /shout {message}");
  2507. break;
  2508. }
  2509. case COMMAND_AUCTION:{
  2510. if(sep && sep->arg[0][0])
  2511. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_AUCTION, sep->argplus[0], 0, 0, true, client->GetPlayer()->GetCurrentLanguage());
  2512. else
  2513. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /auction {message}");
  2514. break;
  2515. }
  2516. case COMMAND_OOC:{
  2517. //For now ooc will be the global chat channel, eventually when we create more channels we will create a global chat channel
  2518. if(sep && sep->arg[0][0])
  2519. zone_list.HandleGlobalChatMessage(client, 0, CHANNEL_OUT_OF_CHARACTER, sep->argplus[0], 0, client->GetPlayer()->GetCurrentLanguage());
  2520. else
  2521. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /ooc {message}");
  2522. break;
  2523. }
  2524. case COMMAND_EMOTE:{
  2525. if(sep && sep->arg[0][0])
  2526. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_EMOTE, sep->argplus[0]);
  2527. else
  2528. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /emote {action}");
  2529. break;
  2530. }
  2531. case COMMAND_RACE:{
  2532. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  2533. if(sep->arg[1][0] && sep->IsNumber(1)){
  2534. client->GetPlayer()->GetInfoStruct()->set_race(atoi(sep->arg[1]));
  2535. client->GetPlayer()->SetRace(atoi(sep->arg[1]));
  2536. client->UpdateTimeStampFlag ( RACE_UPDATE_FLAG );
  2537. client->GetPlayer()->SetCharSheetChanged(true);
  2538. }
  2539. client->GetPlayer()->SetModelType(atoi(sep->arg[0]));
  2540. //EQ2Packet* outapp = client->GetPlayer()->spawn_update_packet(client->GetPlayer(), client->GetVersion(), client->GetPlayer()->GetFeatures());
  2541. //client->QueuePacket(outapp);
  2542. }
  2543. else{
  2544. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /race {race type id} {race id}");
  2545. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "{race id} is optional");
  2546. }
  2547. break;
  2548. }
  2549. case COMMAND_BANK_DEPOSIT:{
  2550. if(client->GetBanker() && sep && sep->arg[0]){
  2551. int64 amount = 0;
  2552. string deposit = string(sep->arg[0]);
  2553. amount = atoi64(deposit.c_str());
  2554. client->BankDeposit(amount);
  2555. }
  2556. break;
  2557. }
  2558. case COMMAND_BANK_WITHDRAWAL:{
  2559. if(client->GetBanker() && sep && sep->arg[0] && sep->IsNumber(0)){
  2560. int64 amount = 0;
  2561. string deposit = string(sep->arg[0]);
  2562. amount = atoi64(deposit.c_str());
  2563. client->BankWithdrawal(amount);
  2564. }
  2565. break;
  2566. }
  2567. case COMMAND_BANK_CANCEL:{
  2568. Spawn* banker = cmdTarget;
  2569. client->Bank(banker, true);
  2570. break;
  2571. }
  2572. case COMMAND_BANK:{
  2573. LogWrite(PLAYER__DEBUG, 0, "Players", "Open Player Personal Bank...");
  2574. Spawn* banker = cmdTarget;
  2575. client->Bank(banker);
  2576. break;
  2577. }
  2578. case COMMAND_GUILD_BANK:{
  2579. LogWrite(GUILD__DEBUG, 0, "Guilds", "Open Guild Bank...");
  2580. //Spawn* banker = client->GetPlayer()->GetTarget();
  2581. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will eventually open the guild bank!");
  2582. break;
  2583. }
  2584. case COMMAND_START_MAIL: {
  2585. client->SetMailTransaction(cmdTarget);
  2586. client->SendMailList();
  2587. break;
  2588. }
  2589. case COMMAND_CANCEL_MAIL: {
  2590. client->SetMailTransaction(0);
  2591. break;
  2592. }
  2593. case COMMAND_GET_MAIL_MESSAGE: {
  2594. if (sep && sep->arg[0] && sep->IsNumber(0))
  2595. client->DisplayMailMessage(atoul(sep->arg[0]));
  2596. break;
  2597. }
  2598. case COMMAND_ADD_MAIL_PLAT: {
  2599. if (sep && sep->arg[0] && sep->IsNumber(0))
  2600. client->AddMailCoin(0, 0, 0, atoul(sep->arg[0]));
  2601. break;
  2602. }
  2603. case COMMAND_ADD_MAIL_GOLD: {
  2604. if (sep && sep->arg[0] && sep->IsNumber(0))
  2605. client->AddMailCoin(0, 0, atoul(sep->arg[0]));
  2606. break;
  2607. }
  2608. case COMMAND_ADD_MAIL_SILVER: {
  2609. if (sep && sep->arg[0] && sep->IsNumber(0))
  2610. client->AddMailCoin(0, atoul(sep->arg[0]));
  2611. break;
  2612. }
  2613. case COMMAND_ADD_MAIL_COPPER: {
  2614. if (sep && sep->arg[0] && sep->IsNumber(0))
  2615. client->AddMailCoin(atoul(sep->arg[0]));
  2616. break;
  2617. }
  2618. case COMMAND_SET_MAIL_ITEM: {
  2619. if(sep && sep->IsNumber(0) && sep->IsNumber(1))
  2620. {
  2621. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(atoul(sep->arg[0]));
  2622. if(item)
  2623. {
  2624. int16 quantity = atoul(sep->arg[1]);
  2625. if(item->CheckFlag(NO_TRADE) || item->CheckFlag(ATTUNED) || item->CheckFlag(ARTIFACT) || item->CheckFlag2(HEIRLOOM))
  2626. {
  2627. return;
  2628. }
  2629. if(item->IsBag())
  2630. {
  2631. vector<Item*>* bag_items = player->GetPlayerItemList()->GetItemsInBag(item);
  2632. if(bag_items && bag_items->size() > 0)
  2633. {
  2634. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot mail a bag with items inside it.");
  2635. safe_delete(bag_items);
  2636. return;
  2637. }
  2638. safe_delete(bag_items);
  2639. }
  2640. Item* itemtoadd = item;
  2641. if(quantity > 0)
  2642. {
  2643. if(quantity > item->details.count)
  2644. return;
  2645. Item* tmpItem = new Item(item);
  2646. tmpItem->details.count = quantity;
  2647. itemtoadd = tmpItem;
  2648. }
  2649. if(client->AddMailItem(itemtoadd))
  2650. {
  2651. client->RemoveItem(item, quantity, true);
  2652. }
  2653. }
  2654. }
  2655. break;
  2656. }
  2657. case COMMAND_REMOVE_MAIL_PLAT: {
  2658. if (sep && sep->arg[0] && sep->IsNumber(0))
  2659. client->RemoveMailCoin(0, 0, 0, atoul(sep->arg[0]));
  2660. break;
  2661. }
  2662. case COMMAND_REMOVE_MAIL_GOLD: {
  2663. if (sep && sep->arg[0] && sep->IsNumber(0))
  2664. client->RemoveMailCoin(0, 0, atoul(sep->arg[0]));
  2665. break;
  2666. }
  2667. case COMMAND_REMOVE_MAIL_SILVER: {
  2668. if (sep && sep->arg[0] && sep->IsNumber(0))
  2669. client->RemoveMailCoin(0, atoul(sep->arg[0]));
  2670. break;
  2671. }
  2672. case COMMAND_REMOVE_MAIL_COPPER: {
  2673. if (sep && sep->arg[0] && sep->IsNumber(0))
  2674. client->RemoveMailCoin(atoul(sep->arg[0]));
  2675. break;
  2676. }
  2677. case COMMAND_TAKE_MAIL_ATTACHMENTS: {
  2678. if (sep && sep->arg[0] && sep->IsNumber(0))
  2679. client->TakeMailAttachments(atoul(sep->arg[0]));
  2680. break;
  2681. }
  2682. case COMMAND_CANCEL_SEND_MAIL: {
  2683. client->ResetSendMail();
  2684. break;
  2685. }
  2686. case COMMAND_DELETE_MAIL_MESSAGE: {
  2687. if (sep && sep->arg[0] && sep->IsNumber(0))
  2688. client->DeleteMail(atoul(sep->arg[0]), true);
  2689. break;
  2690. }
  2691. case COMMAND_REPORT_SPAM: {
  2692. LogWrite(MISC__TODO, 1, "TODO", " received reportspam\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  2693. if (sep && sep->arg[0]) LogWrite(COMMAND__DEBUG, 0, "Command", "%s\n", sep->argplus[0]);
  2694. break;
  2695. }
  2696. case COMMAND_KILL:{
  2697. Spawn* dead = 0;
  2698. if (sep && sep->arg[0] && strncasecmp(sep->arg[0],"self",4)==0){
  2699. dead=client->GetPlayer();
  2700. client->GetPlayer()->SetHP(0);
  2701. client->GetPlayer()->KillSpawn(dead);
  2702. }else{
  2703. dead= cmdTarget;
  2704. if(dead && dead->IsPlayer() == false){
  2705. dead->SetHP(0);
  2706. if(sep && sep->arg[0] && sep->IsNumber(0) && atoi(sep->arg[0]) == 1)
  2707. client->GetCurrentZone()->RemoveSpawn(dead, true, true, true, true, true);
  2708. else
  2709. client->GetPlayer()->KillSpawn(dead);
  2710. }else{
  2711. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /kill (self)");
  2712. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Kills currently selected non-player target.");
  2713. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Optionally, self may be used to kill yourself");
  2714. }
  2715. }
  2716. break;
  2717. }
  2718. case COMMAND_LEVEL:{
  2719. if(sep && sep->arg[ndx][0] && sep->IsNumber(0)){
  2720. int16 new_level = atoi(sep->arg[ndx]);
  2721. if (!client->GetPlayer()->CheckLevelStatus(new_level))
  2722. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have the required status to level up anymore!");
  2723. else {
  2724. if (new_level < 1)
  2725. new_level = 1;
  2726. if (new_level > 255)
  2727. new_level = 255;
  2728. client->ChangeLevel(client->GetPlayer()->GetLevel(), new_level);
  2729. }
  2730. }else
  2731. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /level {new_level}");
  2732. break;
  2733. }
  2734. case COMMAND_SIT: {
  2735. if(client->GetPlayer()->GetHP() > 0){
  2736. client->QueuePacket(new EQ2Packet(OP_SitMsg, 0, 0));
  2737. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You sit down.");
  2738. client->GetPlayer()->set_character_flag(CF_IS_SITTING);
  2739. }
  2740. break;
  2741. }
  2742. case COMMAND_STAND: {
  2743. if(client->GetPlayer()->GetHP() > 0){
  2744. client->QueuePacket(new EQ2Packet(OP_StandMsg, 0, 0));
  2745. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You stand up.");
  2746. client->GetPlayer()->reset_character_flag(CF_IS_SITTING);
  2747. }
  2748. break;
  2749. }
  2750. case COMMAND_CLASS:{
  2751. if(sep && sep->arg[ndx][0]){
  2752. client->GetPlayer()->SetPlayerAdventureClass(atoi(sep->arg[ndx]));
  2753. client->UpdateTimeStampFlag ( CLASS_UPDATE_FLAG );
  2754. }else
  2755. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /class {class_id}");
  2756. break;
  2757. }
  2758. case COMMAND_FLYMODE:{
  2759. if(sep && sep->arg[0] && sep->IsNumber(0)){
  2760. PrintSep(sep, "COMMAND_FLYMODE");
  2761. int8 val = atoi(sep->arg[0]);
  2762. ClientPacketFunctions::SendFlyMode(client, val);
  2763. }
  2764. else{
  2765. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage ON: /flymode 1");
  2766. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage OFF: /flymode 0");
  2767. }
  2768. break;
  2769. }
  2770. case COMMAND_LOOT_LIST:{
  2771. Spawn* spawn = cmdTarget;
  2772. if(spawn && spawn->IsEntity()){
  2773. if (sep && sep->arg[0]) {
  2774. if (!spawn->GetDatabaseID())
  2775. {
  2776. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn has no database id to assign to loottables.");
  2777. break;
  2778. }
  2779. else if (!spawn->IsNPC())
  2780. {
  2781. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "these /loot list [add/remove/clearall] sub-commands are only designed for an NPC.");
  2782. break;
  2783. }
  2784. bool reloadLoot = false;
  2785. if (!stricmp(sep->arg[0], "remove") && sep->arg[1] && sep->IsNumber(1))
  2786. {
  2787. int32 loottable_id = atoul(sep->arg[1]);
  2788. if (loottable_id > 0 && database.RemoveSpawnLootTable(spawn, loottable_id))
  2789. {
  2790. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u loot table %u removed.", spawn->GetDatabaseID(), loottable_id);
  2791. reloadLoot = true;
  2792. }
  2793. else
  2794. client->Message(CHANNEL_COLOR_YELLOW, "/loot list remove [loottableid] - could not match any spawn_id entries against loottable_id %u.", loottable_id);
  2795. }
  2796. else if (!stricmp(sep->arg[0], "add") && sep->arg[1] && sep->IsNumber(1))
  2797. {
  2798. int32 loottable_id = atoul(sep->arg[1]);
  2799. if (loottable_id > 0)
  2800. {
  2801. database.AddLootTableToSpawn(spawn, loottable_id);
  2802. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u loot table %u added.", spawn->GetDatabaseID(), loottable_id);
  2803. reloadLoot = true;
  2804. }
  2805. else
  2806. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list add [loottableid] - cannot add a loottable id of 0.");
  2807. }
  2808. else if (!stricmp(sep->arg[0], "clearall"))
  2809. {
  2810. if (database.RemoveSpawnLootTable(spawn, 0))
  2811. {
  2812. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn loot tables removed.");
  2813. reloadLoot = true;
  2814. }
  2815. else
  2816. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list clearall - could not match any spawn_id entries in loottable_id.");
  2817. }
  2818. else
  2819. {
  2820. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list argument not supported.");
  2821. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list add [loottableid] - add new loottable to spawn");
  2822. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list remove [loottableid] - remove existing loottable from spawn");
  2823. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list clearall - remove all loottables from spawn");
  2824. break;
  2825. }
  2826. if (reloadLoot)
  2827. {
  2828. database.LoadSpawnLoot(spawn->GetZone(), spawn);
  2829. if (spawn->IsNPC())
  2830. {
  2831. Entity* ent = (Entity*)spawn;
  2832. ent->SetLootCoins(0);
  2833. ent->ClearLoot();
  2834. spawn->GetZone()->AddLoot((NPC*)spawn);
  2835. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u active loot purged and reloaded.", spawn->GetDatabaseID());
  2836. }
  2837. }
  2838. break; // nothing further this is the end of these sub commands
  2839. }
  2840. else
  2841. {
  2842. vector<int32> loot_list = client->GetCurrentZone()->GetSpawnLootList(spawn->GetDatabaseID(), spawn->GetZone()->GetZoneID(), spawn->GetLevel(), race_types_list.GetRaceType(spawn->GetModelType()), spawn);
  2843. if (loot_list.size() > 0) {
  2844. client->Message(CHANNEL_COLOR_YELLOW, "%s belongs to the following loot lists: ", spawn->GetName());
  2845. vector<int32>::iterator list_itr;
  2846. LootTable* table = 0;
  2847. for (list_itr = loot_list.begin(); list_itr != loot_list.end(); list_itr++) {
  2848. table = client->GetCurrentZone()->GetLootTable(*list_itr);
  2849. if (table)
  2850. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", *list_itr, table->name.c_str());
  2851. }
  2852. }
  2853. client->Message(CHANNEL_COLOR_YELLOW, "Coins being carried: %u", spawn->GetLootCoins());
  2854. vector<Item*>* items = spawn->GetLootItems();
  2855. if (items) {
  2856. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is carrying the following items: ");
  2857. vector<Item*>::iterator itr;
  2858. Item* item = 0;
  2859. for (itr = items->begin(); itr != items->end(); itr++) {
  2860. item = *itr;
  2861. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", item->details.item_id, item->name.c_str());
  2862. }
  2863. }
  2864. else
  2865. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is not carrying any items.");
  2866. }
  2867. }
  2868. break;
  2869. }
  2870. case COMMAND_LOOT_SETCOIN:{
  2871. Spawn* spawn = cmdTarget;
  2872. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2873. spawn->SetLootCoins(atoul(sep->arg[0]));
  2874. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully set coins.");
  2875. }
  2876. else
  2877. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot setcoin {amount}");
  2878. break;
  2879. }
  2880. case COMMAND_LOOT_ADDITEM:{
  2881. Spawn* spawn = cmdTarget;
  2882. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2883. int16 charges = 1;
  2884. if(sep->arg[1] && sep->IsNumber(1))
  2885. charges = atoi(sep->arg[1]);
  2886. spawn->AddLootItem(atoul(sep->arg[0]), charges);
  2887. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully added item.");
  2888. }
  2889. else
  2890. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot additem {item_id}");
  2891. break;
  2892. }
  2893. case COMMAND_LOOT_REMOVEITEM:{
  2894. Spawn* spawn = cmdTarget;
  2895. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2896. Item* item = spawn->LootItem(atoul(sep->arg[0]));
  2897. lua_interface->SetLuaUserDataStale(item);
  2898. safe_delete(item);
  2899. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully removed item.");
  2900. }
  2901. else
  2902. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot removeitem {item_id}");
  2903. break;
  2904. }
  2905. case COMMAND_LOOT_CORPSE:
  2906. case COMMAND_DISARM:
  2907. case COMMAND_LOOT:{
  2908. if (cmdTarget && ((Entity*)cmdTarget)->IsNPC() && cmdTarget->Alive())
  2909. {
  2910. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is not dead.");
  2911. break;
  2912. }
  2913. if(cmdTarget && cmdTarget->IsEntity()){
  2914. if (cmdTarget->GetDistance(client->GetPlayer()) <= rule_manager.GetGlobalRule(R_Loot, LootRadius)->GetFloat()){
  2915. if (!rule_manager.GetGlobalRule(R_Loot, AutoDisarmChest)->GetBool() && command->handler == COMMAND_DISARM )
  2916. client->OpenChest(cmdTarget, true);
  2917. else
  2918. client->Loot(cmdTarget, rule_manager.GetGlobalRule(R_Loot, AutoDisarmChest)->GetBool());
  2919. if (!(cmdTarget)->HasLoot()){
  2920. if (((Entity*)cmdTarget)->IsNPC())
  2921. client->GetCurrentZone()->RemoveDeadSpawn(cmdTarget);
  2922. }
  2923. }
  2924. else
  2925. client->Message(CHANNEL_COLOR_YELLOW, "You are too far away to interact with that");
  2926. }
  2927. else if(!cmdTarget || cmdTarget->GetHP() > 0)
  2928. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid target.");
  2929. break;
  2930. }
  2931. case COMMAND_RELOADSPAWNSCRIPTS:{
  2932. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spawn Scripts....");
  2933. if (lua_interface)
  2934. lua_interface->SetLuaSystemReloading(true);
  2935. world.ResetSpawnScripts();
  2936. database.LoadSpawnScriptData();
  2937. if(lua_interface) {
  2938. lua_interface->DestroySpawnScripts();
  2939. lua_interface->SetLuaSystemReloading(false);
  2940. }
  2941. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Success!");
  2942. break;
  2943. }
  2944. case COMMAND_RELOADREGIONSCRIPTS:{
  2945. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Region Scripts....");
  2946. if(lua_interface) {
  2947. lua_interface->DestroyRegionScripts();
  2948. }
  2949. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Success!");
  2950. break;
  2951. }
  2952. case COMMAND_RELOADLUASYSTEM:{
  2953. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Attempting to reload entire LUA system....");
  2954. world.SetReloadingSubsystem("LuaSystem");
  2955. if(lua_interface) {
  2956. lua_interface->SetLuaSystemReloading(true);
  2957. }
  2958. zone_list.DeleteSpellProcess();
  2959. master_spell_list.Reload();
  2960. if (lua_interface)
  2961. lua_interface->ReloadSpells();
  2962. zone_list.LoadSpellProcess();
  2963. if(lua_interface){
  2964. map<Client*, int32> debug_clients = lua_interface->GetDebugClients();
  2965. map<Client*, int32>::iterator itr;
  2966. for(itr = debug_clients.begin(); itr != debug_clients.end(); itr++){
  2967. if(lua_interface)
  2968. lua_interface->UpdateDebugClients(itr->first);
  2969. }
  2970. }
  2971. world.ResetSpawnScripts();
  2972. database.LoadSpawnScriptData();
  2973. world.ResetZoneScripts();
  2974. database.LoadZoneScriptData();
  2975. if(lua_interface) {
  2976. lua_interface->DestroySpawnScripts();
  2977. lua_interface->DestroyRegionScripts();
  2978. lua_interface->DestroyQuests();
  2979. lua_interface->DestroyItemScripts();
  2980. lua_interface->DestroyZoneScripts();
  2981. }
  2982. int32 quest_count = database.LoadQuests();
  2983. int32 spell_count = 0;
  2984. if(lua_interface) {
  2985. spell_count = database.LoadSpellScriptData();
  2986. lua_interface->SetLuaSystemReloading(false);
  2987. }
  2988. world.RemoveReloadingSubSystem("LuaSystem");
  2989. client->Message(CHANNEL_COLOR_YELLOW, "Successfully loaded %u spell(s), %u quest(s).", spell_count, quest_count);
  2990. break;
  2991. }
  2992. case COMMAND_DECLINE_QUEST:{
  2993. int32 quest_id = 0;
  2994. if(sep && sep->arg[0] && sep->IsNumber(0))
  2995. quest_id = atoul(sep->arg[0]);
  2996. if(quest_id > 0){
  2997. Quest* quest = client->GetPendingQuest(quest_id);
  2998. if(quest){
  2999. client->RemovePendingQuest(quest);
  3000. if(lua_interface)
  3001. lua_interface->CallQuestFunction(quest, "Declined", client->GetPlayer());
  3002. lua_interface->SetLuaUserDataStale(quest);
  3003. safe_delete(quest);
  3004. client->GetCurrentZone()->SendQuestUpdates(client);
  3005. }
  3006. }
  3007. break;
  3008. }
  3009. case COMMAND_DELETE_QUEST:{
  3010. int32 quest_id = 0;
  3011. if(sep && sep->arg[0] && sep->IsNumber(0))
  3012. quest_id = atoul(sep->arg[0]);
  3013. if(quest_id > 0){
  3014. if(lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0) {
  3015. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  3016. if (quest)
  3017. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  3018. }
  3019. client->RemovePlayerQuest(quest_id);
  3020. client->GetCurrentZone()->SendQuestUpdates(client);
  3021. }
  3022. break;
  3023. }
  3024. case COMMAND_ACCEPT_QUEST:{
  3025. int32 quest_id = 0;
  3026. if(sep && sep->arg[0] && sep->IsNumber(0))
  3027. quest_id = atoul(sep->arg[0]);
  3028. if(quest_id > 0){
  3029. client->AcceptQuest(quest_id);
  3030. }
  3031. break;
  3032. }
  3033. case COMMAND_NAME:{
  3034. if(sep && sep->arg[ndx][0]){
  3035. client->GetPlayer()->GetInfoStruct()->set_name(std::string(sep->arg[ndx]).substr(0,39));
  3036. client->GetPlayer()->SetCharSheetChanged(true);
  3037. }else
  3038. client->Message(CHANNEL_COLOR_YELLOW,"Usage: /name {new_name}");
  3039. break;
  3040. }
  3041. case COMMAND_GROUPSAY:{
  3042. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  3043. if(sep && sep->arg[0] && gmi)
  3044. world.GetGroupManager()->GroupChatMessage(gmi->group_id, client->GetPlayer(), client->GetPlayer()->GetCurrentLanguage(), sep->argplus[0]);
  3045. break;
  3046. }
  3047. case COMMAND_GROUPINVITE: {
  3048. Entity* target = 0;
  3049. Client* target_client = 0;
  3050. if (client->GetPlayer()->GetGroupMemberInfo() && !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  3051. client->SimpleMessage(CHANNEL_COMMANDS, "You must be the group leader to invite.");
  3052. return;
  3053. }
  3054. // name provided with command so it has to be a player, npc not supported here
  3055. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0){
  3056. target_client = zone_list.GetClientByCharName(sep->arg[0]);
  3057. if (target_client) {
  3058. if (!target_client->IsConnected() || !target_client->IsReadyForSpawns())
  3059. target = 0;
  3060. else
  3061. target = target_client->GetPlayer();
  3062. }
  3063. }
  3064. // if name was not provided use the players target, npc or player supported here
  3065. if (!target && client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  3066. target = (Entity*)client->GetPlayer()->GetTarget();
  3067. if (target->IsPlayer()) {
  3068. target_client = client->GetCurrentZone()->GetClientBySpawn(target);
  3069. }
  3070. }
  3071. int8 result = world.GetGroupManager()->Invite(client->GetPlayer(), target);
  3072. if (result == 0) {
  3073. client->Message(CHANNEL_COMMANDS, "You invite %s to group with you.", target->GetName());
  3074. if (target_client) {
  3075. PacketStruct* packet = configReader.getStruct("WS_ReceiveOffer", target_client->GetVersion());
  3076. if (packet) {
  3077. packet->setDataByName("type", 1);
  3078. packet->setDataByName("name", client->GetPlayer()->GetName());
  3079. packet->setDataByName("unknown2", 1);
  3080. target_client->QueuePacket(packet->serialize());
  3081. safe_delete(packet);
  3082. }
  3083. }
  3084. }
  3085. else if (result == 1)
  3086. client->SimpleMessage(CHANNEL_COMMANDS, "That player is already in a group.");
  3087. else if (result == 2)
  3088. client->SimpleMessage(CHANNEL_COMMANDS, "That player has been invited to another group.");
  3089. else if (result == 3)
  3090. client->SimpleMessage(CHANNEL_COMMANDS, "Your group is already full.");
  3091. else if (result == 4)
  3092. client->SimpleMessage(CHANNEL_COMMANDS, "You have a pending invitation, cancel it first.");
  3093. else if (result == 5)
  3094. client->SimpleMessage(CHANNEL_COMMANDS, "You cannot invite yourself!");
  3095. else if (result == 6)
  3096. client->SimpleMessage(CHANNEL_COMMANDS, "Could not locate the player.");
  3097. else
  3098. client->SimpleMessage(CHANNEL_COMMANDS, "Group invite failed, unknown error!");
  3099. break;
  3100. }
  3101. case COMMAND_GROUPDISBAND: {
  3102. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  3103. if (gmi) { // TODO: Leader check
  3104. // world.GetGroupManager()->SimpleGroupMessage(gmi->group_id, "Your group has been disbanded.");
  3105. world.GetGroupManager()->RemoveGroup(gmi->group_id);
  3106. }
  3107. break;
  3108. }
  3109. case COMMAND_GROUP_LEAVE: {
  3110. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  3111. if (gmi) {
  3112. int32 group_id = gmi->group_id;
  3113. world.GetGroupManager()->RemoveGroupMember(group_id, client->GetPlayer());
  3114. if (!world.GetGroupManager()->IsGroupIDValid(group_id)) {
  3115. // leader->Message(CHANNEL_COLOR_GROUP, "%s has left the group.", client->GetPlayer()->GetName());
  3116. }
  3117. else {
  3118. world.GetGroupManager()->GroupMessage(group_id, "%s has left the group.", client->GetPlayer()->GetName());
  3119. }
  3120. client->SimpleMessage(CHANNEL_GROUP_CHAT, "You have left the group");
  3121. }
  3122. break;
  3123. }
  3124. case COMMAND_FRIEND_ADD:{
  3125. string name = "";
  3126. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  3127. name = database.GetPlayerName(sep->arg[0]);
  3128. else if(cmdTarget && cmdTarget->IsPlayer())
  3129. name = string(cmdTarget->GetName());
  3130. if(name.length() > 0){
  3131. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  3132. if(client->GetPlayer()->IsIgnored(name.c_str())){
  3133. client->GetPlayer()->RemoveIgnore(name.c_str());
  3134. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  3135. client->SendChatRelationship(3, name.c_str());
  3136. }
  3137. client->GetPlayer()->AddFriend(name.c_str(), true);
  3138. client->SendChatRelationship(0, name.c_str());
  3139. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added friend: %s", name.c_str());
  3140. if(zone_list.GetClientByCharName(name))
  3141. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Friend: %s has logged in.", name.c_str());
  3142. }
  3143. else
  3144. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot be more friendly towards yourself!");
  3145. }
  3146. else
  3147. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  3148. break;
  3149. }
  3150. case COMMAND_FRIEND_REMOVE:{
  3151. string name = "";
  3152. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  3153. name = database.GetPlayerName(sep->arg[0]);
  3154. else if(cmdTarget && cmdTarget->IsPlayer())
  3155. name = string(cmdTarget->GetName());
  3156. if(name.length() > 0){
  3157. client->GetPlayer()->RemoveFriend(name.c_str());
  3158. client->SendChatRelationship(1, name.c_str());
  3159. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  3160. }
  3161. else
  3162. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  3163. break;
  3164. }
  3165. case COMMAND_FRIENDS:{
  3166. break;
  3167. }
  3168. case COMMAND_IGNORE_ADD:{
  3169. string name = "";
  3170. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  3171. name = database.GetPlayerName(sep->arg[0]);
  3172. else if(cmdTarget && cmdTarget->IsPlayer())
  3173. name = string(cmdTarget->GetName());
  3174. if(name.length() > 0){
  3175. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  3176. if(client->GetPlayer()->IsFriend(name.c_str())){
  3177. client->GetPlayer()->RemoveFriend(name.c_str());
  3178. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  3179. client->SendChatRelationship(1, name.c_str());
  3180. }
  3181. client->GetPlayer()->AddIgnore(name.c_str(), true);
  3182. client->SendChatRelationship(2, name.c_str());
  3183. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added ignore: %s", name.c_str());
  3184. }
  3185. else
  3186. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot ignore yourself!");
  3187. }
  3188. else
  3189. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  3190. break;
  3191. }
  3192. case COMMAND_IGNORE_REMOVE:{
  3193. string name = "";
  3194. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  3195. name = database.GetPlayerName(sep->arg[0]);
  3196. else if(cmdTarget && cmdTarget->IsPlayer())
  3197. name = string(cmdTarget->GetName());
  3198. if(name.length() > 0){
  3199. client->GetPlayer()->RemoveIgnore(name.c_str());
  3200. client->SendChatRelationship(3, name.c_str());
  3201. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  3202. }
  3203. break;
  3204. }
  3205. case COMMAND_IGNORES:{
  3206. break;
  3207. }
  3208. case COMMAND_GROUP_KICK:{
  3209. Entity* kicked = 0;
  3210. Client* kicked_client = 0;
  3211. int32 group_id = 0;
  3212. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader)
  3213. return;
  3214. if (sep && sep->arg[0]) {
  3215. kicked_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  3216. if (kicked_client)
  3217. kicked = kicked_client->GetPlayer();
  3218. }
  3219. else if (cmdTarget && cmdTarget->IsEntity()) {
  3220. kicked = (Entity*)cmdTarget;
  3221. }
  3222. group_id = client->GetPlayer()->GetGroupMemberInfo()->group_id;
  3223. bool send_kicked_message = world.GetGroupManager()->GetGroupSize(group_id) > 2;
  3224. if (kicked)
  3225. world.GetGroupManager()->RemoveGroupMember(group_id, kicked);
  3226. if(send_kicked_message)
  3227. world.GetGroupManager()->GroupMessage(group_id, "%s was kicked from the group.", kicked->GetName());
  3228. else
  3229. client->Message(CHANNEL_GROUP_CHAT, "You kicked %s from the group", kicked->GetName());
  3230. if (kicked_client)
  3231. kicked_client->SimpleMessage(CHANNEL_GROUP_CHAT, "You were kicked from the group");
  3232. break;
  3233. }
  3234. case COMMAND_GROUP_MAKE_LEADER:{
  3235. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  3236. client->SimpleMessage(CHANNEL_COMMANDS, "You are not a group leader.");
  3237. return;
  3238. }
  3239. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 1) {
  3240. Client* new_leader = zone_list.GetClientByCharName(sep->arg[0]);
  3241. if (new_leader && new_leader->GetPlayer()->GetGroupMemberInfo() && new_leader->GetPlayer()->GetGroupMemberInfo()->group_id == client->GetPlayer()->GetGroupMemberInfo()->group_id) {
  3242. if (client->GetPlayer()->IsGroupMember(new_leader->GetPlayer())) {
  3243. if(world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, new_leader->GetPlayer())) {
  3244. world.GetGroupManager()->GroupMessage(client->GetPlayer()->GetGroupMemberInfo()->group_id, "%s is now leader of the group.", new_leader->GetPlayer()->GetName());
  3245. }
  3246. }
  3247. }
  3248. else
  3249. client->SimpleMessage(CHANNEL_COMMANDS, "Unable to find the given player.");
  3250. }
  3251. else if (cmdTarget && cmdTarget->IsPlayer() && ((Player*)cmdTarget)->GetGroupMemberInfo() && ((Player*)cmdTarget)->GetGroupMemberInfo()->group_id == client->GetPlayer()->GetGroupMemberInfo()->group_id) {
  3252. if(client->GetPlayer()->IsGroupMember((Player*)cmdTarget) && world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, (Entity*)cmdTarget)) {
  3253. world.GetGroupManager()->GroupMessage(client->GetPlayer()->GetGroupMemberInfo()->group_id, "%s is now leader of the group.", cmdTarget->GetName());
  3254. }
  3255. }
  3256. else
  3257. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to change group leader.");
  3258. break;
  3259. }
  3260. case COMMAND_GROUP_ACCEPT_INVITE: {
  3261. if(sep && sep->arg[0] && strcmp(sep->arg[0], "group") == 0) {
  3262. int8 result = world.GetGroupManager()->AcceptInvite(client->GetPlayer());
  3263. if (result == 0)
  3264. client->SimpleMessage(CHANNEL_GROUP_CHAT, "You have joined the group.");
  3265. else if (result == 1)
  3266. client->SimpleMessage(CHANNEL_GROUP_CHAT, "You do not have a pending invite.");
  3267. else if (result == 2)
  3268. client->SimpleMessage(CHANNEL_GROUP_CHAT, "Unable to join group - could not find leader.");
  3269. else
  3270. client->SimpleMessage(CHANNEL_GROUP_CHAT, "Unable to join group - unknown error.");
  3271. }
  3272. break;
  3273. }
  3274. case COMMAND_GROUP_DECLINE_INVITE: {
  3275. if(sep && sep->arg[0] && strcmp(sep->arg[0], "group") == 0) {
  3276. world.GetGroupManager()->DeclineInvite(client->GetPlayer()); // TODO: Add message to leader
  3277. }
  3278. break;
  3279. }
  3280. case COMMAND_SUMMON:{
  3281. char* search_name = 0;
  3282. if(sep && sep->arg[0][0])
  3283. search_name = sep->arg[0];
  3284. if(!search_name && !cmdTarget){
  3285. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /summon [name]");
  3286. 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.");
  3287. }
  3288. else{
  3289. if(!client->Summon(search_name))
  3290. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  3291. }
  3292. break;
  3293. }
  3294. case COMMAND_GOTO:{
  3295. const char* search_name = 0;
  3296. if(sep && sep->arg[0][0])
  3297. search_name = sep->argplus[0];
  3298. if(!search_name && !cmdTarget){
  3299. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /goto [name]");
  3300. 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.");
  3301. }
  3302. else{
  3303. if(!client->GotoSpawn(search_name))
  3304. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  3305. }
  3306. break;
  3307. }
  3308. case COMMAND_MOVE:{
  3309. bool success = false;
  3310. try{
  3311. if(sep && sep->arg[2][0] && sep->IsNumber(0) && sep->IsNumber(1) && sep->IsNumber(2)){
  3312. EQ2Packet* app = client->GetPlayer()->Move(atof(sep->arg[0]), atof(sep->arg[1]), atof(sep->arg[2]), client->GetVersion());
  3313. if(app){
  3314. client->QueuePacket(app);
  3315. success = true;
  3316. }
  3317. }
  3318. }
  3319. catch(...){}
  3320. if(!success){
  3321. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /move x y z");
  3322. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Moves the client to the given coordinates.");
  3323. }
  3324. break;
  3325. }
  3326. case COMMAND_SETTIME:{
  3327. if(sep && sep->arg[0]){
  3328. world.MWorldTime.writelock(__FUNCTION__, __LINE__);
  3329. sscanf (sep->arg[0], "%d:%d", &world.GetWorldTimeStruct()->hour, &world.GetWorldTimeStruct()->minute);
  3330. if(sep->arg[1] && sep->IsNumber(1))
  3331. world.GetWorldTimeStruct()->month = atoi(sep->arg[1]) - 1; //zero based indexes
  3332. if(sep->arg[2] && sep->IsNumber(2))
  3333. world.GetWorldTimeStruct()->day = atoi(sep->arg[2]) - 1; //zero based indexes
  3334. if(sep->arg[3] && sep->IsNumber(3))
  3335. world.GetWorldTimeStruct()->year = atoi(sep->arg[3]);
  3336. world.MWorldTime.releasewritelock(__FUNCTION__, __LINE__);
  3337. client->GetCurrentZone()->SendTimeUpdateToAllClients();
  3338. }
  3339. else{
  3340. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /settime [hour:minute] (month) (day) (year)");
  3341. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Example: /settime 8:30");
  3342. }
  3343. break;
  3344. }
  3345. case COMMAND_VERSION:{
  3346. client->Message(CHANNEL_COLOR_YELLOW,"%s %s", EQ2EMU_MODULE, CURRENT_VERSION);
  3347. client->Message(CHANNEL_COLOR_YELLOW,"Last Compiled on %s %s", COMPILE_DATE, COMPILE_TIME);
  3348. break;
  3349. }
  3350. case COMMAND_ZONE:{
  3351. int32 instanceID = 0;
  3352. string zone;
  3353. int32 zone_id = 0;
  3354. bool listSearch = false;
  3355. bool isInstance = false;
  3356. ZoneServer* zsZone = 0;
  3357. if(sep && sep->arg[0][0])
  3358. {
  3359. if(strncasecmp(sep->arg[0], "list", 4) == 0)
  3360. listSearch = true;
  3361. else if(strncasecmp(sep->arg[0], "active", 6) == 0)
  3362. {
  3363. zone_list.SendZoneList(client);
  3364. break;
  3365. }
  3366. else if(strncasecmp(sep->arg[0], "instance", 6) == 0)
  3367. {
  3368. if(sep->IsNumber(1))
  3369. instanceID = atol(sep->arg[1]);
  3370. }
  3371. else if(strncasecmp(sep->arg[0], "lock", 4) == 0)
  3372. {
  3373. PrintSep(sep, "ZONE LOCK");
  3374. if(sep->IsNumber(1))
  3375. zsZone = zone_list.Get(atoul(sep->arg[1]), false);
  3376. else
  3377. zsZone = zone_list.Get(sep->arg[1], false);
  3378. if( zsZone )
  3379. {
  3380. zsZone->SetZoneLockState(true);
  3381. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now locked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  3382. }
  3383. else
  3384. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be locked.", sep->arg[1]);
  3385. break;
  3386. }
  3387. else if(strncasecmp(sep->arg[0], "unlock", 6) == 0)
  3388. {
  3389. PrintSep(sep, "ZONE UNLOCK");
  3390. if(sep->IsNumber(1))
  3391. zsZone = zone_list.Get(atoul(sep->arg[1]), false);
  3392. else
  3393. zsZone = zone_list.Get(sep->arg[1], false);
  3394. if( zsZone )
  3395. {
  3396. zsZone->SetZoneLockState(false);
  3397. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now unlocked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  3398. }
  3399. else
  3400. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be unlocked.", sep->arg[1]);
  3401. break;
  3402. }
  3403. else
  3404. {
  3405. if(sep->IsNumber(0))
  3406. {
  3407. zone_id = atoul(sep->arg[0]);
  3408. string zonename = database.GetZoneName(zone_id);
  3409. if(zonename.length() > 0)
  3410. zone = zonename;
  3411. }
  3412. else
  3413. zone = sep->arg[0];
  3414. }
  3415. if(instanceID > 0)
  3416. {
  3417. ZoneServer* zsInstance = zone_list.GetByInstanceID(instanceID);
  3418. if(zsInstance != NULL)
  3419. {
  3420. instanceID = zsInstance->GetInstanceID();
  3421. zone = zsInstance->GetZoneName();
  3422. zone_id = zsInstance->GetZoneID();
  3423. isInstance = true;
  3424. }
  3425. }
  3426. }
  3427. if(!listSearch)
  3428. {
  3429. if(zone.length() == 0)
  3430. client->Message(CHANNEL_COLOR_RED, "Error: Invalid Zone");
  3431. else if(instanceID != client->GetCurrentZone()->GetInstanceID() ||
  3432. zone_id != client->GetCurrentZone()->GetZoneID())
  3433. {
  3434. const char* zonestr = zone.c_str();
  3435. if(database.VerifyZone(zonestr))
  3436. {
  3437. if(client->CheckZoneAccess(zonestr))
  3438. {
  3439. client->Message(CHANNEL_COLOR_YELLOW,"Zoning to %s...", zonestr);
  3440. if(isInstance)
  3441. client->Zone(instanceID,true,true,false);
  3442. else
  3443. client->Zone(zonestr);
  3444. }
  3445. }
  3446. else
  3447. client->Message(CHANNEL_COLOR_RED, "Error: Zone '%s' not found. To get a list type /zone list", zonestr);
  3448. }
  3449. else
  3450. client->Message(CHANNEL_COLOR_RED, "Error: You are already in that zone!");
  3451. }
  3452. else
  3453. {
  3454. const char* name = 0;
  3455. if(sep && sep->arg[1][0])
  3456. {
  3457. map<int32, string>* zone_names;
  3458. name = sep->argplus[1];
  3459. sint16 status = client->GetAdminStatus();
  3460. if( status > 0 )
  3461. {
  3462. client->SimpleMessage(CHANNEL_COLOR_RED, "ADMIN MODE");
  3463. zone_names = database.GetZoneList(name, true);
  3464. }
  3465. else
  3466. zone_names = database.GetZoneList(name);
  3467. if(!zone_names)
  3468. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No zones found.");
  3469. else
  3470. {
  3471. map<int32, string>::iterator itr;
  3472. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  3473. for(itr = zone_names->begin(); itr != zone_names->end(); itr++)
  3474. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  3475. safe_delete(zone_names);
  3476. }
  3477. }
  3478. else
  3479. {
  3480. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone [zone name]");
  3481. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone list [partial zone name]");
  3482. }
  3483. }
  3484. break;
  3485. }
  3486. case COMMAND_USE: {
  3487. Spawn* target = cmdTarget;
  3488. if (target && target->IsWidget())
  3489. ((Widget*)target)->HandleUse(client, "use");
  3490. break;
  3491. }
  3492. case COMMAND_OPEN: {
  3493. Spawn* target = cmdTarget;
  3494. if (target && target->IsWidget())
  3495. ((Widget*)target)->HandleUse(client, "Open", WIDGET_TYPE_DOOR);
  3496. break;
  3497. }
  3498. case COMMAND_CASTSPELL: {
  3499. if (sep && sep->arg[0] && sep->IsNumber(0))
  3500. {
  3501. int8 tier = 1;
  3502. if (sep->arg[1] && sep->IsNumber(1))
  3503. tier = atoul(sep->arg[1]);
  3504. int8 self = 1;
  3505. if (sep->arg[1] && sep->IsNumber(2))
  3506. {
  3507. self = atoul(sep->arg[2]);
  3508. if(self != 1 && !cmdTarget->IsEntity())
  3509. {
  3510. client->Message(CHANNEL_COLOR_RED, "Target is not an entity required to cast non-self spell.");
  3511. self = 1;
  3512. }
  3513. }
  3514. int32 spellid = atoul(sep->arg[0]);
  3515. Spell* spell = master_spell_list.GetSpell(spellid, tier);
  3516. if (spell)
  3517. {
  3518. client->Message(CHANNEL_COLOR_RED, "Casting spell %u.", spellid);
  3519. SpellProcess* spellProcess = 0;
  3520. // Get the current zones spell process
  3521. spellProcess = client->GetCurrentZone()->GetSpellProcess();
  3522. spellProcess->CastInstant(spell, (!cmdTarget || self == 1) ? (Entity*)client->GetPlayer() : (Entity*)cmdTarget, (cmdTarget && cmdTarget->IsEntity()) ? (Entity*)cmdTarget : (Entity*)client->GetPlayer());
  3523. }
  3524. else
  3525. {
  3526. client->Message(CHANNEL_COLOR_RED, "Could not find spell %u.",spellid);
  3527. }
  3528. }
  3529. else if (sep && sep->arg[0])
  3530. {
  3531. database.FindSpell(client, (char*)sep->argplus[0]);
  3532. }
  3533. else
  3534. {
  3535. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellid] (tier=1) - Cast Spell with specified spell id, tier is optional, default of 1.");
  3536. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellname] - Find spells wildcard match with a partial spell name");
  3537. }
  3538. break;
  3539. }
  3540. case COMMAND_KNOWLEDGEWINDOWSORT: {
  3541. if (client->GetVersion() <= 546)
  3542. break;
  3543. if (sep && sep->GetArgNumber() == 4)
  3544. {
  3545. int32 book = atoul(sep->arg[0]); // 0 - spells, 1 - combat, 2 - abilities, 3 - tradeskill
  3546. int32 sort_by = atoul(sep->arg[1]); // 0 - alpha, 1 - level, 2 - category
  3547. int32 order = atoul(sep->arg[2]); // 0 - ascending, 1 - descending
  3548. int32 pattern = atoul(sep->arg[3]); // 0 - zigzag, 1 - down, 2 - across
  3549. int32 maxlvlonly = atoul(sep->arg[4]); // 0 - zigzag, 1 - down, 2 - across
  3550. client->GetPlayer()->ResortSpellBook(sort_by, order, pattern, maxlvlonly, book);
  3551. ClientPacketFunctions::SendSkillSlotMappings(client);
  3552. }
  3553. else
  3554. {
  3555. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /knowledgewindow_sort [book] [sort_by] [order] [pattern]");
  3556. }
  3557. break;
  3558. }
  3559. case COMMAND_MOVE_ITEM:
  3560. {
  3561. int32 id = 0;
  3562. if (sep && sep->IsNumber(0))
  3563. id = atoul(sep->arg[0]);
  3564. Spawn* spawn = 0;
  3565. if (id == 0)
  3566. {
  3567. spawn = cmdTarget;
  3568. }
  3569. else
  3570. spawn = client->GetCurrentZone()->GetSpawnFromUniqueItemID(id);
  3571. if (!spawn || !client->HasOwnerOrEditAccess() || !spawn->GetPickupItemID())
  3572. break;
  3573. client->SendMoveObjectMode(spawn, 0);
  3574. break;
  3575. }
  3576. case COMMAND_PICKUP:
  3577. {
  3578. int32 id = 0;
  3579. if (sep && sep->IsNumber(0))
  3580. id = atoul(sep->arg[0]);
  3581. Spawn* spawn = 0;
  3582. if (id == 0)
  3583. {
  3584. spawn = cmdTarget;
  3585. }
  3586. else
  3587. spawn = client->GetCurrentZone()->GetSpawnFromUniqueItemID(id);
  3588. if (!spawn || !client->HasOwnerOrEditAccess() || !spawn->GetPickupItemID())
  3589. break;
  3590. if(client->AddItem(spawn->GetPickupItemID(), 1)) {
  3591. Query query;
  3592. 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());
  3593. if (database.RemoveSpawnFromSpawnLocation(spawn)) {
  3594. client->GetCurrentZone()->RemoveSpawn(spawn, true, true, true, true, true);
  3595. }
  3596. // we had a UI Window displayed, update the house items
  3597. if ( id > 0 )
  3598. client->GetCurrentZone()->SendHouseItems(client);
  3599. }
  3600. break;
  3601. }
  3602. case COMMAND_HOUSE_DEPOSIT:
  3603. {
  3604. PrintSep(sep, "COMMAND_HOUSE_DEPOSIT");
  3605. // arg0 = ??? (set to 3)
  3606. // arg1 = coin (in copper)
  3607. // arg2 = status? (not implemented yet)
  3608. PlayerHouse* ph = world.GetPlayerHouseByInstanceID(client->GetCurrentZone()->GetInstanceID());
  3609. if (ph && sep && sep->IsNumber(1))
  3610. {
  3611. int64 outValCoin = strtoull(sep->arg[1], NULL, 0);
  3612. int32 outValStatus = 0;
  3613. if(sep->IsNumber(2))
  3614. {
  3615. outValStatus = strtoull(sep->arg[2], NULL, 0);
  3616. if(outValStatus > client->GetPlayer()->GetInfoStruct()->get_status_points())
  3617. outValStatus = 0; // cheat check
  3618. }
  3619. if ((!outValCoin && outValStatus) || client->GetPlayer()->RemoveCoins(outValCoin))
  3620. {
  3621. if(outValStatus)
  3622. client->GetPlayer()->GetInfoStruct()->subtract_status_points(outValStatus);
  3623. char query[256];
  3624. map<string,Deposit>::iterator itr = ph->depositsMap.find(string(client->GetPlayer()->GetName()));
  3625. if (itr != ph->depositsMap.end())
  3626. {
  3627. 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());
  3628. }
  3629. else
  3630. 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);
  3631. if (database.RunQuery(query, strnlen(query, 256)))
  3632. {
  3633. ph->escrow_coins += outValCoin;
  3634. ph->escrow_status += outValStatus;
  3635. database.UpdateHouseEscrow(ph->house_id, ph->instance_id, ph->escrow_coins, ph->escrow_status);
  3636. database.LoadDeposits(ph);
  3637. client->PlaySound("coin_cha_ching");
  3638. HouseZone* hz = world.GetHouseZone(ph->house_id);
  3639. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  3640. }
  3641. else
  3642. {
  3643. if(outValCoin)
  3644. client->GetPlayer()->AddCoins(outValCoin);
  3645. if(outValStatus)
  3646. client->GetPlayer()->GetInfoStruct()->add_status_points(outValStatus);
  3647. client->SimpleMessage(CHANNEL_COLOR_RED, "Deposit failed!");
  3648. }
  3649. }
  3650. }
  3651. break;
  3652. }
  3653. case COMMAND_HOUSE:
  3654. {
  3655. if (sep && sep->IsNumber(0))
  3656. {
  3657. int32 unique_id = atoi(sep->arg[0]);
  3658. PlayerHouse* ph = world.GetPlayerHouseByUniqueID(unique_id);
  3659. HouseZone* hz = 0;
  3660. if (ph)
  3661. hz = world.GetHouseZone(ph->house_id);
  3662. // there is a arg[1] that is true/false, but not sure what it is for investigate more later
  3663. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  3664. }
  3665. else if (client->GetCurrentZone()->GetInstanceType() != 0)
  3666. {
  3667. // inside a house or something? Send the access window
  3668. PlayerHouse* ph = world.GetPlayerHouseByInstanceID(client->GetCurrentZone()->GetInstanceID());
  3669. HouseZone* hz = 0;
  3670. if ( ph )
  3671. hz = world.GetHouseZone(ph->house_id);
  3672. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  3673. client->GetCurrentZone()->SendHouseItems(client);
  3674. }
  3675. break;
  3676. }
  3677. case COMMAND_HOUSE_UI:
  3678. {
  3679. if (sep && sep->IsNumber(0) && client->GetCurrentZone()->GetInstanceType() == Instance_Type::NONE)
  3680. {
  3681. int32 unique_id = atoi(sep->arg[0]);
  3682. PlayerHouse* ph = world.GetPlayerHouseByUniqueID(unique_id);
  3683. HouseZone* hz = 0;
  3684. if ( ph )
  3685. hz = world.GetHouseZone(ph->house_id);
  3686. // there is a arg[1] that is true/false, but not sure what it is for investigate more later
  3687. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, 0);
  3688. }
  3689. break;
  3690. }
  3691. case COMMAND_PLACE_HOUSE_ITEM: {
  3692. if (sep && sep->IsNumber(0))
  3693. {
  3694. int32 uniqueid = atoi(sep->arg[0]);
  3695. Item* item = client->GetPlayer()->item_list.GetItemFromUniqueID(uniqueid);
  3696. //Item* item = player->GetEquipmentList()->GetItem(slot);
  3697. if (item && item->IsHouseItem())
  3698. {
  3699. if (!client->HasOwnerOrEditAccess())
  3700. {
  3701. client->SimpleMessage(CHANNEL_COLOR_RED, "This is not your home!");
  3702. break;
  3703. }
  3704. else if (!item->generic_info.appearance_id)
  3705. {
  3706. 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);
  3707. break;
  3708. }
  3709. else if(item->CheckFlag2(HOUSE_LORE) && client->GetCurrentZone()->HouseItemSpawnExists(item->details.item_id)) {
  3710. client->Message(CHANNEL_COLOR_RED, "Item %s is house lore and you cannot place another.", item->name.c_str());
  3711. break;
  3712. }
  3713. if (client->GetTempPlacementSpawn())
  3714. {
  3715. Spawn* tmp = client->GetTempPlacementSpawn();
  3716. client->GetCurrentZone()->RemoveSpawn(tmp, true, true, true, true, true);
  3717. client->SetTempPlacementSpawn(nullptr);
  3718. }
  3719. Object* obj = new Object();
  3720. Spawn* spawn = (Spawn*)obj;
  3721. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3722. strcpy(spawn->appearance.name, "temp");
  3723. spawn->SetX(client->GetPlayer()->GetX());
  3724. spawn->SetY(client->GetPlayer()->GetY());
  3725. spawn->SetZ(client->GetPlayer()->GetZ());
  3726. spawn->appearance.pos.collision_radius = 32;
  3727. spawn->SetHeading(client->GetPlayer()->GetHeading());
  3728. spawn->SetSpawnOrigX(spawn->GetX());
  3729. spawn->SetSpawnOrigY(spawn->GetY());
  3730. spawn->SetSpawnOrigZ(spawn->GetZ());
  3731. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  3732. spawn->appearance.targetable = 1;
  3733. spawn->appearance.activity_status = ACTIVITY_STATUS_SOLID;
  3734. spawn->appearance.race = item && item->generic_info.appearance_id ? item->generic_info.appearance_id : 1472;
  3735. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  3736. spawn->SetModelType(item && item->generic_info.appearance_id ? item->generic_info.appearance_id : 1472);
  3737. spawn->SetZone(client->GetCurrentZone());
  3738. client->SetTempPlacementSpawn(spawn);
  3739. client->SetPlacementUniqueItemID(uniqueid);
  3740. client->GetCurrentZone()->AddSpawn(spawn);
  3741. }
  3742. }
  3743. break;
  3744. }
  3745. case COMMAND_GM:
  3746. {
  3747. if (sep && sep->arg[0] && sep->arg[1])
  3748. {
  3749. bool onOff = (strcmp(sep->arg[1], "on") == 0);
  3750. if (strcmp(sep->arg[0], "vision") == 0)
  3751. {
  3752. client->GetPlayer()->SetGMVision(onOff);
  3753. #if defined(__GNUC__)
  3754. database.insertCharacterProperty(client, CHAR_PROPERTY_GMVISION, (onOff) ? (char*)"1" : (char*)"0");
  3755. #else
  3756. database.insertCharacterProperty(client, CHAR_PROPERTY_GMVISION, (onOff) ? "1" : "0");
  3757. #endif
  3758. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3759. if (onOff)
  3760. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Vision Enabled!");
  3761. else
  3762. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Vision Disabled!");
  3763. }
  3764. else if (strcmp(sep->arg[0], "tag") == 0)
  3765. {
  3766. int32 value = 0;
  3767. int16 tag_icon = 0;
  3768. // groundspawn has special exception -1 argument so it needs to be handled here
  3769. if(sep->arg[2] && sep->arg[3] && ((tag_icon = atoul(sep->arg[3])) > 0) || (strncasecmp(sep->arg[1], "groundspawn", 11) == 0)) {
  3770. value = atoul(sep->arg[2]);
  3771. if(strncasecmp(sep->arg[1], "faction", 7) == 0){
  3772. if(!value) {
  3773. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid faction id.");
  3774. break;
  3775. }
  3776. if(!tag_icon) {
  3777. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid tag icon id.");
  3778. break;
  3779. }
  3780. client->GetPlayer()->AddGMVisualFilter(GMTagFilterType::GMFILTERTYPE_FACTION, value, "", tag_icon);
  3781. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3782. client->Message(CHANNEL_COLOR_RED, "Adding faction id %u with tag icon %u.", value, tag_icon);
  3783. }
  3784. else if(strncasecmp(sep->arg[1], "spawngroup", 10) == 0){
  3785. if(value>0) {
  3786. value = 1;
  3787. }
  3788. if(!tag_icon) {
  3789. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid tag icon id.");
  3790. break;
  3791. }
  3792. client->GetPlayer()->AddGMVisualFilter(GMTagFilterType::GMFILTERTYPE_SPAWNGROUP, value, "", tag_icon);
  3793. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3794. client->Message(CHANNEL_COLOR_RED, "Adding spawn group tag \"%s\" with tag icon %u.", (value == 1) ? "on" : "off", tag_icon);
  3795. }
  3796. else if(strncasecmp(sep->arg[1], "race", 4 == 0)){
  3797. if(!value) {
  3798. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid race id.");
  3799. break;
  3800. }
  3801. if(!tag_icon) {
  3802. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid tag icon id.");
  3803. break;
  3804. }
  3805. client->GetPlayer()->AddGMVisualFilter(GMTagFilterType::GMFILTERTYPE_RACE, value, "", tag_icon);
  3806. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3807. client->Message(CHANNEL_COLOR_RED, "Adding race id %u with tag icon %u.", value, tag_icon);
  3808. }
  3809. else if(strncasecmp(sep->arg[1], "groundspawn", 11) == 0){
  3810. // one less argument value field not tag_icon for this one
  3811. if(!value) {
  3812. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid tag icon id.");
  3813. break;
  3814. }
  3815. client->GetPlayer()->AddGMVisualFilter(GMTagFilterType::GMFILTERTYPE_GROUNDSPAWN, 1, "", value);
  3816. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3817. client->Message(CHANNEL_COLOR_RED, "Adding groundspawns with tag icon %u.", value);
  3818. }
  3819. }
  3820. else {
  3821. if(strncasecmp(sep->arg[1], "clear", 5) == 0){
  3822. client->GetPlayer()->ClearGMVisualFilters();
  3823. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Tags Cleared!");
  3824. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3825. }
  3826. else {
  3827. client->SimpleMessage(CHANNEL_COLOR_RED, "GM Tagging Missing Arguments:");
  3828. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/gm tag [type] [value] [visual_icon_display]");
  3829. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/gm tag clear - Clears all GM visual tags");
  3830. client->SimpleMessage(CHANNEL_COLOR_RED, "Visual Type Options:");
  3831. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "type: faction, value: faction id of spawn(s)");
  3832. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "type: spawngroup, value: 1 to show grouped, 0 to show not grouped");
  3833. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "type: race, value: race id (either against base race or race id in spawn details)");
  3834. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "type: groundspawn, value: (not used)");
  3835. client->SimpleMessage(CHANNEL_COLOR_RED, "Visual Icon Options:");
  3836. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3837. "1 = skull, 2 = shield half dark blue / half light blue, 3 = purple? star, 4 = yellow sword, 5 = red X, 6 = green flame");
  3838. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3839. "7 = Number \"1\", 8 = Number \"2\", 9 = Number \"3\", 10 = Number \"4\", 11 = Number \"5\", 12 = Number \"6\"");
  3840. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3841. "25 = shield, 26 = green plus, 27 = crossed swords, 28 = bow with arrow in it, 29 = light blue lightning bolt");
  3842. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3843. "30 = bard instrument (hard to see), 31 = writ with shield, 32 = writ with green +, 33 = writ with crossed sword");
  3844. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3845. "34 = writ with bow, 35 = writ with light blue lightning bolt, 36 = same as 30, 37 = party with crossed sword, shield and lightning bolt");
  3846. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3847. "38 = shaking hands green background, 39 = shaking hands dark green background, unlocked keylock");
  3848. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3849. "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");
  3850. }
  3851. }
  3852. }
  3853. else if (strcmp(sep->arg[0], "regiondebug") == 0)
  3854. {
  3855. client->SetRegionDebug(onOff);
  3856. #if defined(__GNUC__)
  3857. database.insertCharacterProperty(client, CHAR_PROPERTY_REGIONDEBUG, (onOff) ? (char*)"1" : (char*)"0");
  3858. #else
  3859. database.insertCharacterProperty(client, CHAR_PROPERTY_REGIONDEBUG, (onOff) ? "1" : "0");
  3860. #endif
  3861. if (onOff)
  3862. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Region Debug Enabled!");
  3863. else
  3864. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Region Debug Disabled!");
  3865. }
  3866. else if (strcmp(sep->arg[0], "sight") == 0)
  3867. {
  3868. if(onOff && cmdTarget) {
  3869. client->SetPlayerPOVGhost(cmdTarget);
  3870. }
  3871. else
  3872. client->SetPlayerPOVGhost(nullptr);
  3873. }
  3874. else if (strcmp(sep->arg[0], "luadebug") == 0)
  3875. {
  3876. client->SetLuaDebugClient(onOff);
  3877. #if defined(__GNUC__)
  3878. database.insertCharacterProperty(client, CHAR_PROPERTY_LUADEBUG, (onOff) ? (char*)"1" : (char*)"0");
  3879. #else
  3880. database.insertCharacterProperty(client, CHAR_PROPERTY_LUADEBUG, (onOff) ? "1" : "0");
  3881. #endif
  3882. if (onOff)
  3883. {
  3884. if (lua_interface)
  3885. lua_interface->UpdateDebugClients(client);
  3886. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will now receive LUA error messages.");
  3887. }
  3888. else
  3889. {
  3890. if (lua_interface)
  3891. lua_interface->RemoveDebugClients(client);
  3892. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will no longer receive LUA error messages.");
  3893. }
  3894. }
  3895. }
  3896. break;
  3897. }
  3898. case COMMAND_ATTACK:
  3899. case COMMAND_AUTO_ATTACK:{
  3900. int8 type = 1;
  3901. Player* player = client->GetPlayer();
  3902. if(!player)
  3903. break;
  3904. bool incombat = player->EngagedInCombat();
  3905. if(sep && sep->arg[0] && sep->IsNumber(0))
  3906. type = atoi(sep->arg[0]);
  3907. if(client->GetPlayer()->GetHP() == 0){
  3908. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  3909. break;
  3910. }
  3911. if(type == 0){
  3912. if(incombat)
  3913. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You stop fighting.");
  3914. player->StopCombat(type);
  3915. }
  3916. else {
  3917. if(type == 2){
  3918. player->InCombat(false);
  3919. if(incombat && player->GetRangeAttack()){
  3920. player->StopCombat(type);
  3921. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You stop fighting.");
  3922. }
  3923. else{
  3924. player->SetRangeAttack(true);
  3925. player->InCombat(true, true);
  3926. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You start fighting.");
  3927. }
  3928. }
  3929. else {
  3930. player->InCombat(false, true);
  3931. player->SetRangeAttack(false);
  3932. player->InCombat(true);
  3933. if(!incombat)
  3934. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You start fighting.");
  3935. }
  3936. /*else
  3937. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You cannot attack that!");*/
  3938. }
  3939. player->SetCharSheetChanged(true);
  3940. break;
  3941. }
  3942. case COMMAND_DEPOP:{
  3943. bool allow_respawns = false;
  3944. if(sep && sep->arg[0] && sep->IsNumber(0)){
  3945. if(atoi(sep->arg[0]) == 1)
  3946. allow_respawns = true;
  3947. }
  3948. client->GetCurrentZone()->Depop(allow_respawns);
  3949. break;
  3950. }
  3951. case COMMAND_REPOP:{
  3952. client->GetCurrentZone()->Depop(false, true);
  3953. break;
  3954. }
  3955. case COMMAND_BUYBACK:{
  3956. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  3957. // 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
  3958. int64 id = atoi64(sep->arg[0]);
  3959. // get the first int32, the item id
  3960. //int32 item_id = (int32)id;
  3961. // get the second int32, the unique id
  3962. int32 unique_id = (int32)(id>>32);
  3963. int8 quantity = atoi(sep->arg[1]);
  3964. if(quantity == 255)
  3965. quantity = 1;
  3966. client->BuyBack(unique_id, quantity);
  3967. }
  3968. break;
  3969. }
  3970. case COMMAND_MERCHANT_BUY:{
  3971. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  3972. int32 item_id = atoul(sep->arg[0]);
  3973. int8 quantity = atoi(sep->arg[1]);
  3974. client->BuyItem(item_id, quantity);
  3975. }
  3976. else
  3977. Command_SendMerchantWindow(client, sep);
  3978. break;
  3979. }
  3980. case COMMAND_MERCHANT_SELL:{
  3981. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  3982. // 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
  3983. int64 id = atoi64(sep->arg[0]);
  3984. // get the first int32, the item id
  3985. int32 item_id = (int32)id;
  3986. // get the second int32, the unique id
  3987. int32 unique_id = (int32)(id>>32);
  3988. int8 quantity = atoi(sep->arg[1]);
  3989. LogWrite(MERCHANT__DEBUG, 0, "Merchant", "Selling Item: Item Id = %ul, unique id = %ul, Quantity = %i", item_id, unique_id, quantity);
  3990. client->SellItem(item_id, quantity, unique_id);
  3991. }
  3992. break;
  3993. }
  3994. case COMMAND_MENDER_REPAIR: {
  3995. if (sep && sep->arg[0] && sep->IsNumber(0))
  3996. client->RepairItem(atoul(sep->arg[0]));
  3997. break;
  3998. }
  3999. case COMMAND_MENDER_REPAIR_ALL: {
  4000. client->RepairAllItems();
  4001. break;
  4002. }
  4003. case COMMAND_CANCEL_MERCHANT:{
  4004. client->SetMerchantTransaction(0);
  4005. break;
  4006. }
  4007. case COMMAND_START_MERCHANT:{
  4008. break;
  4009. }
  4010. case COMMAND_INVULNERABLE:{
  4011. sint8 val = -1;
  4012. if(sep && sep->arg[0] && sep->IsNumber(0)){
  4013. val = atoi(sep->arg[0]);
  4014. //devn00b: Fix for linux builds
  4015. #if defined(__GNUC__)
  4016. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? (char*) "1" : (char*) "0");
  4017. #else
  4018. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  4019. #endif
  4020. // database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  4021. client->GetPlayer()->SetInvulnerable(val==1);
  4022. if(client->GetPlayer()->GetInvulnerable())
  4023. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are now invulnerable!");
  4024. else
  4025. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are no longer invulnerable!");
  4026. }
  4027. if(val == -1)
  4028. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /invulnerable [0/1]");
  4029. break;
  4030. }
  4031. case COMMAND_REPAIR: {
  4032. Spawn* spawn = cmdTarget;
  4033. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR) {
  4034. client->SendHailCommand(spawn);
  4035. client->SetMerchantTransaction(spawn);
  4036. client->SendRepairList();
  4037. }
  4038. break;
  4039. }
  4040. case COMMAND_LOTTO: {
  4041. Spawn* spawn = cmdTarget;
  4042. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_LOTTO) {
  4043. client->SetMerchantTransaction(spawn);
  4044. client->ShowLottoWindow();
  4045. }
  4046. break;
  4047. }
  4048. case COMMAND_ACCEPT_REWARD:{
  4049. int32 unknown = 0;
  4050. int32 selectable_item_id = 0;
  4051. //Quest *quest = 0;
  4052. Collection *collection = 0;
  4053. /* no idea what the first argument is for (faction maybe?)
  4054. if the reward has a selectable item reward, it's sent as the second argument
  4055. if neither of these are included in the reward, there is no sep
  4056. 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
  4057. only 1 quest or collection reward may be displayed at a time */
  4058. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  4059. unknown = atoul(sep->arg[0]);
  4060. selectable_item_id = atoul(sep->arg[1]);
  4061. }
  4062. /* 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
  4063. ** Otherwise it will likely be a DoF client scenario (pending item rewards, selectable item rewards) which is specifying an item id
  4064. ** 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
  4065. */
  4066. int32 item_id = 0;
  4067. if(sep && sep->arg[0][0] && sep->IsNumber(0))
  4068. item_id = atoul(sep->arg[0]);
  4069. Quest* quest = client->GetPendingQuestAcceptance(item_id);
  4070. if(quest){
  4071. client->AcceptQuestReward(quest, item_id);
  4072. break;
  4073. }
  4074. bool collectedItems = false;
  4075. if (client->GetPlayer()->HasPendingItemRewards()) {
  4076. vector<Item*> items = client->GetPlayer()->GetPendingItemRewards();
  4077. if (items.size() > 0) {
  4078. collectedItems = true;
  4079. for (int i = 0; i < items.size(); i++) {
  4080. client->GetPlayer()->AddItem(new Item(items[i]));
  4081. }
  4082. client->GetPlayer()->ClearPendingItemRewards();
  4083. client->GetPlayer()->SetActiveReward(false);
  4084. }
  4085. map<int32, Item*> selectable_item = client->GetPlayer()->GetPendingSelectableItemReward(item_id);
  4086. if (selectable_item.size() > 0) {
  4087. collectedItems = true;
  4088. map<int32, Item*>::iterator itr;
  4089. for (itr = selectable_item.begin(); itr != selectable_item.end(); itr++) {
  4090. client->GetPlayer()->AddItem(new Item(itr->second));
  4091. client->GetPlayer()->ClearPendingSelectableItemRewards(itr->first);
  4092. }
  4093. client->GetPlayer()->SetActiveReward(false);
  4094. }
  4095. }
  4096. else if (collection = player->GetPendingCollectionReward())
  4097. {
  4098. client->AcceptCollectionRewards(collection, (selectable_item_id > 0) ? selectable_item_id : item_id);
  4099. collectedItems = true;
  4100. }
  4101. if (collectedItems) {
  4102. EQ2Packet* outapp = client->GetPlayer()->SendInventoryUpdate(client->GetVersion());
  4103. if (outapp)
  4104. client->QueuePacket(outapp);
  4105. }
  4106. else
  4107. LogWrite(COMMAND__ERROR, 0, "Command", "Error in COMMAND_ACCEPT_REWARD. No pending quest or collection reward was found (unknown=%u).", unknown);
  4108. break;
  4109. }
  4110. case COMMAND_BUY_FROM_BROKER:{
  4111. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  4112. int32 item_id = atoul(sep->arg[0]);
  4113. int16 quantity = atoul(sep->arg[1]);
  4114. Item* item = master_item_list.GetItem(item_id);
  4115. if(item && item->generic_info.max_charges > 1)
  4116. quantity = item->generic_info.max_charges;
  4117. client->AddItem(item_id, quantity, AddItemType::BUY_FROM_BROKER);
  4118. }
  4119. break;
  4120. }
  4121. case COMMAND_SEARCH_STORES_PAGE:{
  4122. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  4123. int32 page = atoul(sep->arg[0]);
  4124. client->SearchStore(page);
  4125. }
  4126. break;
  4127. }
  4128. case COMMAND_SEARCH_STORES:{
  4129. if(sep && sep->arg[0][0]){
  4130. const char* values = sep->argplus[0];
  4131. if(values){
  4132. LogWrite(ITEM__WARNING, 0, "Item", "SearchStores: %s", values);
  4133. map<string, string> str_values = TranslateBrokerRequest(values);
  4134. vector<Item*>* items = master_item_list.GetItems(str_values, client);
  4135. if(items){
  4136. client->SetItemSearch(items);
  4137. client->SearchStore(0);
  4138. }
  4139. }
  4140. }
  4141. break;
  4142. }
  4143. case COMMAND_LUADEBUG:{
  4144. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "start") == 0){
  4145. client->SetLuaDebugClient(true);
  4146. if(lua_interface)
  4147. lua_interface->UpdateDebugClients(client);
  4148. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will now receive LUA error messages.");
  4149. }
  4150. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "stop") == 0){
  4151. client->SetLuaDebugClient(false);
  4152. if(lua_interface)
  4153. lua_interface->RemoveDebugClients(client);
  4154. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will no longer receive LUA error messages.");
  4155. }
  4156. else{
  4157. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /luadebug {start | stop}");
  4158. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will allow you to receive lua debug messages normally seen only in the console.");
  4159. }
  4160. break;
  4161. }
  4162. case COMMAND_SPAWN_GROUP:
  4163. {
  4164. Spawn* target = cmdTarget;
  4165. if(target && target->IsPlayer() == false)
  4166. {
  4167. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "create") == 0)
  4168. {
  4169. if(target->GetSpawnLocationPlacementID() > 0)
  4170. {
  4171. if(sep->arg[1] && !sep->IsNumber(1) && strlen(sep->arg[1]) > 0)
  4172. {
  4173. int32 id = database.CreateSpawnGroup(target, sep->arg[1]);
  4174. if(id > 0)
  4175. client->Message(CHANNEL_COLOR_YELLOW, "Successfully created new spawn group with id: %u", id);
  4176. else
  4177. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error creating group, check console for details.");
  4178. target->SetSpawnGroupID(id);
  4179. target->AddSpawnToGroup(target);
  4180. }
  4181. else
  4182. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group create [name]");
  4183. }
  4184. else
  4185. 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.");
  4186. }
  4187. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "add") == 0)
  4188. {
  4189. if(sep->arg[1] && sep->IsNumber(1))
  4190. {
  4191. int32 group_id = atoul(sep->arg[1]);
  4192. Spawn* leader = client->GetCurrentZone()->GetSpawnGroup(group_id);
  4193. if(leader)
  4194. {
  4195. leader->AddSpawnToGroup(target);
  4196. target->SetSpawnGroupID(group_id);
  4197. if(database.SpawnGroupAddSpawn(target, group_id))
  4198. client->Message(CHANNEL_COLOR_YELLOW, "Successfully added '%s' to group id: %u", target->GetName(), group_id);
  4199. else
  4200. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error adding spawn to group, check console for details.");
  4201. }
  4202. else
  4203. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No spawns found in the current zone for that spawn group, be sure to use '/spawn group create' first!");
  4204. }
  4205. else
  4206. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group add [group id]");
  4207. }
  4208. else if(target->GetSpawnGroupID() == 0)
  4209. {
  4210. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That spawn is not in a group!");
  4211. }
  4212. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "remove") == 0)
  4213. {
  4214. int32 group_id = target->GetSpawnGroupID();
  4215. target->RemoveSpawnFromGroup();
  4216. if(database.SpawnGroupRemoveSpawn(target, group_id))
  4217. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed '%s' from group id: %u", target->GetName(), group_id);
  4218. else
  4219. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing spawn from group, check console for details.");
  4220. }
  4221. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "associate") == 0)
  4222. {
  4223. int32 group_id = target->GetSpawnGroupID();
  4224. if(sep->arg[1] && sep->IsNumber(1))
  4225. {
  4226. if(database.SpawnGroupAddAssociation(group_id, atoul(sep->arg[1])))
  4227. client->Message(CHANNEL_COLOR_YELLOW, "Successfully associated group id %u with group id %u", group_id, atoul(sep->arg[1]));
  4228. else
  4229. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error associating groups, check console for details.");
  4230. }
  4231. else
  4232. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Allows you to spawn only one associated group at once. Syntax: /spawn group associate [other group id]");
  4233. }
  4234. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "deassociate") == 0)
  4235. {
  4236. int32 group_id = target->GetSpawnGroupID();
  4237. if(sep->arg[1] && sep->IsNumber(1))
  4238. {
  4239. if(database.SpawnGroupRemoveAssociation(group_id, atoul(sep->arg[1])))
  4240. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed association between group id %u and group id %u", group_id, atoul(sep->arg[1]));
  4241. else
  4242. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing group associations, check console for details.");
  4243. }
  4244. else
  4245. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Removes previous group associations. Syntax: /spawn group deassociate [other group id]");
  4246. }
  4247. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "chance") == 0)
  4248. {
  4249. if(sep->arg[1] && sep->IsNumber(1))
  4250. {
  4251. if(database.SetGroupSpawnChance(target->GetSpawnGroupID(), atof(sep->arg[1])))
  4252. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set group spawn chance to %f for group id: %u", atof(sep->arg[1]), target->GetSpawnGroupID());
  4253. else
  4254. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error setting group spawn chance, check console for details.");
  4255. }
  4256. else
  4257. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group chance [group's spawn chance percentage]");
  4258. }
  4259. else
  4260. {
  4261. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command allows you to modify spawn groups.");
  4262. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group [create/add/remove/chance/associate/deassociate]");
  4263. }
  4264. }
  4265. else
  4266. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select a valid spawn to use this command.");
  4267. break;
  4268. }
  4269. case COMMAND_SPAWN_COMBINE:{
  4270. Spawn* spawn = cmdTarget;
  4271. float radius = 0;
  4272. bool failed = true;
  4273. if(spawn && !spawn->IsPlayer() && sep && sep->arg[0] && sep->arg[0][0]){
  4274. failed = false;
  4275. if(spawn->GetSpawnGroupID() > 0){
  4276. 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.");
  4277. }
  4278. else if(sep->IsNumber(0)){
  4279. radius = atof(sep->arg[0]);
  4280. client->CombineSpawns(radius, spawn);
  4281. }
  4282. else{
  4283. if(strncasecmp(sep->arg[0], "add", 3) == 0){
  4284. client->AddCombineSpawn(spawn);
  4285. }
  4286. else if(strncasecmp(sep->arg[0], "remove", 6) == 0){
  4287. client->RemoveCombineSpawn(spawn);
  4288. }
  4289. else if(strncasecmp(sep->arg[0], "save", 4) == 0){
  4290. const char* name = 0;
  4291. if(sep->arg[1] && sep->arg[1][0])
  4292. name = sep->argplus[1];
  4293. client->SaveCombineSpawns(name);
  4294. }
  4295. else
  4296. failed = true;
  4297. }
  4298. }
  4299. if(failed){
  4300. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command combines several spawns into a single spawn group.");
  4301. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn combine [radius/add/remove/save]");
  4302. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Ex: /spawn combine 1, /spawn combine save (spawn group name)");
  4303. }
  4304. break;
  4305. }
  4306. case COMMAND_SPAWN_CREATE:{
  4307. Spawn* spawn = 0;
  4308. if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "object", 6) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  4309. spawn = new Object();
  4310. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  4311. }
  4312. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "groundspawn", 11) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  4313. spawn = new GroundSpawn();
  4314. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  4315. }
  4316. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "sign", 4) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  4317. spawn = new Sign();
  4318. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  4319. }
  4320. else if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "npc", 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  4321. spawn = new NPC();
  4322. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  4323. spawn->appearance.pos.collision_radius = 32;
  4324. spawn->secondary_command_list_id = 0;
  4325. spawn->primary_command_list_id = 0;
  4326. spawn->appearance.display_name = 1;
  4327. spawn->appearance.show_level = 1;
  4328. spawn->appearance.attackable = 1;
  4329. }
  4330. else{
  4331. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn create [spawn type] [race type] [class type] [level] [name] (difficulty) (size)");
  4332. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are required except difficulty and size. Valid types are Object, NPC, Sign, or GroundSpawn");
  4333. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn create npc 203 1 50 'Lady Vox' 1 32");
  4334. break;
  4335. }
  4336. spawn->SetID(Spawn::NextID());
  4337. spawn->SetX(client->GetPlayer()->GetX());
  4338. spawn->SetY(client->GetPlayer()->GetY());
  4339. spawn->SetZ(client->GetPlayer()->GetZ());
  4340. spawn->SetHeading(client->GetPlayer()->GetHeading());
  4341. spawn->SetSpawnOrigX(spawn->GetX());
  4342. spawn->SetSpawnOrigY(spawn->GetY());
  4343. spawn->SetSpawnOrigZ(spawn->GetZ());
  4344. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  4345. if(spawn->IsSign())
  4346. {
  4347. ((Sign*)spawn)->SetSignType(SIGN_TYPE_GENERIC);
  4348. ((Sign*)spawn)->SetSignDistance(20.0f);
  4349. ((Sign*)spawn)->SetIncludeLocation(1);
  4350. ((Sign*)spawn)->SetIncludeHeading(1);
  4351. ((Sign*)spawn)->SetInitialState(1);
  4352. ((Sign*)spawn)->SetSignTitle(sep->arg[4]);
  4353. ((Sign*)spawn)->SetActivityStatus(64);
  4354. spawn->appearance.race = 0;
  4355. spawn->SetLevel(0);
  4356. spawn->SetHP(0);
  4357. spawn->SetTotalHP(0);
  4358. spawn->SetPower(0);
  4359. spawn->SetTotalPower(0);
  4360. spawn->SetEncounterLevel(0);
  4361. spawn->SetTargetable(0);
  4362. spawn->SetSogaModelType(0);
  4363. spawn->SetCollisionRadius(19);
  4364. ((Sign*)spawn)->SetWidgetX(client->GetPlayer()->GetX());
  4365. ((Sign*)spawn)->SetWidgetY(client->GetPlayer()->GetY());
  4366. ((Sign*)spawn)->SetWidgetZ(client->GetPlayer()->GetZ());
  4367. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  4368. spawn->appearance.model_type = atoul(sep->arg[1]);
  4369. }
  4370. else
  4371. {
  4372. spawn->appearance.targetable = 1;
  4373. spawn->appearance.race = 255;
  4374. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  4375. spawn->SetModelType(atoi(sep->arg[1]));
  4376. spawn->SetAdventureClass(atoi(sep->arg[2]));
  4377. spawn->SetLevel(atoi(sep->arg[3]));
  4378. spawn->SetName(sep->arg[4]);
  4379. if(sep->arg[5][0] && sep->IsNumber(5))
  4380. spawn->SetEncounterLevel(atoi(sep->arg[5]));
  4381. if(sep->arg[6][0] && sep->IsNumber(6))
  4382. spawn->size = atoi(sep->arg[6]);
  4383. if(spawn->GetTotalHP() == 0){
  4384. spawn->SetTotalHP(25*spawn->GetLevel() + 1);
  4385. spawn->SetHP(25*spawn->GetLevel() + 1);
  4386. }
  4387. if(spawn->GetTotalPower() == 0){
  4388. spawn->SetTotalPower(25*spawn->GetLevel() + 1);
  4389. spawn->SetPower(25*spawn->GetLevel() + 1);
  4390. }
  4391. }
  4392. client->GetCurrentZone()->AddSpawn(spawn);
  4393. break;
  4394. }
  4395. case COMMAND_SPAWN_EQUIPMENT:{
  4396. Spawn* spawn = cmdTarget;
  4397. if(spawn && sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1) && spawn->IsEntity()){
  4398. int8 slot = atoi(sep->arg[0]);
  4399. int16 type = atoi(sep->arg[1]);
  4400. int8 red = 0;
  4401. int8 green = 0;
  4402. int8 blue = 0;
  4403. int8 h_red = 0;
  4404. int8 h_green = 0;
  4405. int8 h_blue = 0;
  4406. if(sep->arg[2])
  4407. red = atoi(sep->arg[2]);
  4408. if(sep->arg[3])
  4409. green = atoi(sep->arg[3]);
  4410. if(sep->arg[4])
  4411. blue = atoi(sep->arg[4]);
  4412. if(sep->arg[5])
  4413. h_red = atoi(sep->arg[5]);
  4414. if(sep->arg[6])
  4415. h_green = atoi(sep->arg[6]);
  4416. if(sep->arg[7])
  4417. h_blue = atoi(sep->arg[7]);
  4418. ((Entity*)spawn)->SetEquipment(slot, type, red, green, blue, h_red, h_green, h_blue);
  4419. database.SaveNPCAppearanceEquipment(spawn->GetDatabaseID() , slot, type, red, green, blue, h_red, h_green, h_blue);
  4420. }
  4421. else{
  4422. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn equipment [slot] [appearance id] (red) (green) (blue) (highlight red) (hgreen) (hblue)");
  4423. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn's equipment. ");
  4424. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Slot is 0-24, Appearance ID from appearances table, Colors are 0-255");
  4425. }
  4426. break;
  4427. }
  4428. case COMMAND_SPAWN_DETAILS: {
  4429. Spawn* spawn = cmdTarget;
  4430. if (sep && sep->arg[0][0]) {
  4431. if (cmdTarget)
  4432. {
  4433. if (ToLower(string(sep->arg[0])) == "los")
  4434. {
  4435. bool hasLOS = client->GetPlayer()->CheckLoS(cmdTarget);
  4436. if (hasLOS)
  4437. client->Message(CHANNEL_COLOR_YELLOW, "You have line of sight with %s", spawn->GetName());
  4438. else
  4439. client->Message(CHANNEL_COLOR_RED, "You DO NOT have line of sight with %s", spawn->GetName());
  4440. break;
  4441. }
  4442. else if (ToLower(string(sep->arg[0])) == "bestz")
  4443. {
  4444. glm::vec3 targPos(cmdTarget->GetX(), cmdTarget->GetZ(), cmdTarget->GetY());
  4445. float bestZ = client->GetPlayer()->FindDestGroundZ(targPos, cmdTarget->GetYOffset());
  4446. client->Message(CHANNEL_COLOR_YELLOW, "Best Z for %s is %f", spawn->GetName(), bestZ);
  4447. break;
  4448. }
  4449. else if (ToLower(string(sep->arg[0])) == "inwater")
  4450. {
  4451. if (cmdTarget->GetRegionMap() == nullptr)
  4452. client->SimpleMessage(CHANNEL_COLOR_RED, "No water map for zone.");
  4453. else
  4454. {
  4455. bool inWater = cmdTarget->InWater();
  4456. client->Message(CHANNEL_COLOR_YELLOW, "%s is %s.", cmdTarget->GetName(), inWater ? "in water" : "out of water");
  4457. }
  4458. break;
  4459. }
  4460. else if (ToLower(string(sep->arg[0])) == "inlava")
  4461. {
  4462. if (cmdTarget->GetRegionMap() == nullptr)
  4463. client->SimpleMessage(CHANNEL_COLOR_RED, "No region map for zone.");
  4464. else
  4465. {
  4466. bool inLava = cmdTarget->InLava();
  4467. client->Message(CHANNEL_COLOR_YELLOW, "%s is %s.", cmdTarget->GetName(), inLava ? "in lava" : "out of lava");
  4468. }
  4469. break;
  4470. }
  4471. else if (ToLower(string(sep->arg[0])) == "regions")
  4472. {
  4473. glm::vec3 targPos(cmdTarget->GetX(), cmdTarget->GetY(), cmdTarget->GetZ());
  4474. if (cmdTarget->GetRegionMap() == nullptr)
  4475. client->SimpleMessage(CHANNEL_COLOR_RED, "No region map for zone.");
  4476. else
  4477. {
  4478. cmdTarget->GetRegionMap()->IdentifyRegionsInGrid(client, targPos);
  4479. }
  4480. break;
  4481. }
  4482. else if (ToLower(string(sep->arg[0])) == "behind")
  4483. {
  4484. bool isBehind = client->GetPlayer()->BehindTarget(cmdTarget);
  4485. client->Message(CHANNEL_COLOR_YELLOW, "%s %s.", isBehind ? "YOU are behind" : "YOU are NOT behind", cmdTarget->GetName());
  4486. break;
  4487. }
  4488. else if (ToLower(string(sep->arg[0])) == "infront")
  4489. {
  4490. bool isBehind = client->GetPlayer()->InFrontSpawn(cmdTarget, client->GetPlayer()->GetX(), client->GetPlayer()->GetZ());
  4491. client->Message(CHANNEL_COLOR_YELLOW, "%s %s.", isBehind ? "YOU are infront of" : "YOU are NOT infront of", cmdTarget->GetName());
  4492. break;
  4493. }
  4494. else if (ToLower(string(sep->arg[0])) == "flank")
  4495. {
  4496. bool isFlanking = client->GetPlayer()->FlankingTarget(cmdTarget);
  4497. client->Message(CHANNEL_COLOR_YELLOW, "%s is %s.", isFlanking ? "YOU are flanking" : "YOU are NOT flanking", cmdTarget->GetName());
  4498. break;
  4499. }
  4500. }
  4501. if (sep->IsNumber(0))
  4502. {
  4503. float radius = atof(sep->arg[0]);
  4504. if (!client->GetCurrentZone()->SendRadiusSpawnInfo(client, radius))
  4505. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No results in the radius were found.");
  4506. break;
  4507. }
  4508. }
  4509. if (spawn) {
  4510. const char* type = "NPC";
  4511. if (spawn->IsObject())
  4512. type = "Object";
  4513. else if (spawn->IsSign())
  4514. type = "Sign";
  4515. else if (spawn->IsWidget())
  4516. type = "Widget";
  4517. else if (spawn->IsGroundSpawn())
  4518. type = "GroundSpawn";
  4519. int16 race_type = race_types_list.GetRaceType(spawn->GetModelType());
  4520. int16 race_base_type = race_types_list.GetRaceBaseType(spawn->GetModelType());
  4521. char* category = race_types_list.GetRaceTypeCategory(spawn->GetModelType());
  4522. char* subcategory = race_types_list.GetRaceTypeSubCategory(spawn->GetModelType());
  4523. char* modelname = race_types_list.GetRaceTypeModelName(spawn->GetModelType());
  4524. client->Message(CHANNEL_COLOR_YELLOW, "Name: %s, %s ID: %u", spawn->GetName(), type, spawn->GetDatabaseID());
  4525. client->Message(CHANNEL_COLOR_YELLOW, "Last Name: %s, Sub-Title: %s, Prefix: %s, Suffix: %s", spawn->GetLastName(), spawn->GetSubTitle(), spawn->GetPrefixTitle(), spawn->GetSuffixTitle());
  4526. client->Message(CHANNEL_COLOR_YELLOW, "Spawn Location ID: %u, Spawn Group ID: %u", spawn->GetSpawnLocationID(), spawn->GetSpawnGroupID());
  4527. client->Message(CHANNEL_COLOR_YELLOW, "Faction ID: %u, Merchant ID: %u, Transporter ID: %u", spawn->GetFactionID(), spawn->GetMerchantID(), spawn->GetTransporterID());
  4528. client->Message(CHANNEL_COLOR_YELLOW, "Grid ID: %u", spawn->GetLocation());
  4529. client->Message(CHANNEL_COLOR_YELLOW, "Race: %i, Class: %i, Gender: %i", spawn->GetRace(), spawn->GetAdventureClass(), spawn->GetGender());
  4530. client->Message(CHANNEL_COLOR_YELLOW, "Level: %i, HP: %u, Power: %u", spawn->GetLevel(), spawn->GetHP(), spawn->GetPower());
  4531. 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());
  4532. client->Message(CHANNEL_COLOR_YELLOW, "Collision Radius: %i, Size: %i, Difficulty: %i, Heroic: %i", spawn->GetCollisionRadius(), spawn->GetSize(), spawn->GetEncounterLevel(), spawn->GetHeroic());
  4533. client->Message(CHANNEL_COLOR_YELLOW, "Targetable: %i, Show Name: %i, Attackable: %i, Show Level: %i", spawn->GetTargetable(), spawn->GetShowName(), spawn->GetAttackable(), spawn->GetShowLevel());
  4534. client->Message(CHANNEL_COLOR_YELLOW, "Show Command Icon: %i, Display Hand Icon: %i", spawn->GetShowCommandIcon(), spawn->GetShowHandIcon());
  4535. if (spawn->IsEntity()) {
  4536. 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());
  4537. 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());
  4538. }
  4539. 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);
  4540. client->Message(CHANNEL_COLOR_YELLOW, "Primary Command Type: %u, Secondary Command Type: %u", spawn->GetPrimaryCommandListID(), spawn->GetSecondaryCommandListID());
  4541. 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());
  4542. 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);
  4543. if (spawn->IsNPC())
  4544. client->Message(CHANNEL_COLOR_YELLOW, "Randomize: %u", ((NPC*)spawn)->GetRandomize());
  4545. if (spawn->IsNPC()){
  4546. client->Message(CHANNEL_COLOR_YELLOW, "Heat Resist/Base: %u/%u",((NPC*)spawn)->GetHeatResistance(), ((NPC*)spawn)->GetHeatResistanceBase());
  4547. client->Message(CHANNEL_COLOR_YELLOW, "Cold Resist/Base: %u/%u",((NPC*)spawn)->GetColdResistance(), ((NPC*)spawn)->GetColdResistanceBase());
  4548. client->Message(CHANNEL_COLOR_YELLOW, "Magic Resist/Base: %u/%u",((NPC*)spawn)->GetMagicResistance(), ((NPC*)spawn)->GetMagicResistanceBase());
  4549. client->Message(CHANNEL_COLOR_YELLOW, "Mental Resist/Base: %u/%u",((NPC*)spawn)->GetMentalResistance(), ((NPC*)spawn)->GetMentalResistanceBase());
  4550. client->Message(CHANNEL_COLOR_YELLOW, "Divine Resist/Base: %u/%u",((NPC*)spawn)->GetDivineResistance(), ((NPC*)spawn)->GetDivineResistanceBase());
  4551. client->Message(CHANNEL_COLOR_YELLOW, "Disease Resist/Base: %u/%u",((NPC*)spawn)->GetDiseaseResistance(), ((NPC*)spawn)->GetDiseaseResistanceBase());
  4552. client->Message(CHANNEL_COLOR_YELLOW, "Poison Resist/Base: %u/%u",((NPC*)spawn)->GetPoisonResistance(), ((NPC*)spawn)->GetPoisonResistanceBase());
  4553. }
  4554. string details;
  4555. details += "\\#0000FFName: " + string(spawn->GetName()) + "\n";
  4556. details += "Type: " + string(type) + "\n";
  4557. details += "ID: " + to_string(spawn->GetDatabaseID()) + "\n";
  4558. details += "Last Name: " + string(spawn->GetLastName()) + "\n";
  4559. details += "Sub-Title: " + string(spawn->GetSubTitle()) + "\n";
  4560. details += "Prefix: " + string(spawn->GetPrefixTitle()) + "\n";
  4561. details += "Suffix: " + string(spawn->GetSuffixTitle()) + "\n";
  4562. details += "Race: " + to_string(spawn->GetRace()) + "\n";
  4563. details += "Class: " + to_string(spawn->GetAdventureClass()) + "\n";
  4564. details += "Gender: " + to_string(spawn->GetGender()) + "\n";
  4565. details += "Level: " + to_string(spawn->GetLevel()) + "\n";
  4566. details += "HP: " + to_string(spawn->GetHP()) + "\n";
  4567. details += "Power: " + to_string(spawn->GetPower()) + "\n";
  4568. details += "Difficulty: " + to_string(spawn->GetEncounterLevel()) + "\n";
  4569. details += "Heroic: " + to_string(spawn->GetHeroic()) + "\n";
  4570. details += "Group ID: " + to_string(spawn->GetSpawnGroupID()) + "\n";
  4571. details += "Faction ID: " + to_string(spawn->GetFactionID()) + "\n";
  4572. details += "Merchant ID: " + to_string(spawn->GetMerchantID()) + "\n";
  4573. details += "Transport ID: " + to_string(spawn->GetTransporterID()) + "\n";
  4574. details += "Location ID: " + to_string(spawn->GetSpawnLocationID()) + "\n";
  4575. char x[16];
  4576. sprintf(x, "%.2f", spawn->GetX());
  4577. char y[16];
  4578. sprintf(y, "%.2f", spawn->GetY());
  4579. char z[16];
  4580. sprintf(z, "%.2f", spawn->GetZ());
  4581. details += "Location: " + string(x) + ", " + string(y) + ", " + string(z) + "\n";
  4582. string details2;
  4583. details2 += "Heading: " + to_string(spawn->GetHeading()) + "\n";
  4584. details2 += "Grid ID: " + to_string(spawn->GetLocation()) + "\n";
  4585. details2 += "Size: " + to_string(spawn->GetSize()) + "\n";
  4586. details2 += "Collision Radius: " + to_string(spawn->GetCollisionRadius()) + "\n";
  4587. details2 += "Respawn Time: " + to_string(spawn->GetRespawnTime()) + "\n";
  4588. details2 += "Targetable: " + to_string(spawn->GetTargetable()) + "\n";
  4589. details2 += "Show Name: " + to_string(spawn->GetShowName()) + "\n";
  4590. details2 += "Attackable: " + to_string(spawn->GetAttackable()) + "\n";
  4591. details2 += "Show Level: " + to_string(spawn->GetShowLevel()) + "\n";
  4592. details2 += "Show Command Icon: " + to_string(spawn->GetShowCommandIcon()) + "\n";
  4593. details2 += "Display Hand Icon: " + to_string(spawn->GetShowHandIcon()) + "\n";
  4594. details2 += "Model Type: " + to_string(spawn->GetModelType()) + "\n";
  4595. details2 += "Soga Race Type: " + to_string(spawn->GetSogaModelType()) + "\n";
  4596. details2 += "Race Type: " + to_string(race_type) + "\n";
  4597. details2 += "Race Base Type: " + to_string(race_base_type) + "\n";
  4598. details2 += "Race Category (Sub Category): " + std::string(category) + " (" + std::string(subcategory) + ")\n";
  4599. details2 += "Model Name: " + std::string(modelname) + "\n";
  4600. details2 += "Primary Command ID: " + to_string(spawn->GetPrimaryCommandListID()) + "\n";
  4601. details2 += "Secondary Cmd ID: " + to_string(spawn->GetSecondaryCommandListID()) + "\n";
  4602. details2 += "Visual State: " + to_string(spawn->GetVisualState()) + "\n";
  4603. details2 += "Action State: " + to_string(spawn->GetActionState()) + "\n";
  4604. details2 += "Mood State: " + to_string(spawn->GetMoodState()) + "\n";
  4605. details2 += "Initial State: " + to_string(spawn->GetInitialState()) + "\n";
  4606. details2 += "Activity Status: " + to_string(spawn->GetActivityStatus()) + "\n";
  4607. details2 += "Emote State: " + to_string(spawn->GetEmoteState()) + "\n";
  4608. string details3;
  4609. details3 += "Pitch: " + to_string(spawn->GetPitch()) + "\n";
  4610. details3 += "Roll: " + to_string(spawn->GetRoll()) + "\n";
  4611. details3 += "Hide Hood: " + to_string(spawn->appearance.hide_hood) + "\n";
  4612. details3 += "Speed: " + to_string(spawn->GetSpeed()) + "\n";
  4613. details3 += "BaseSpeed: " + to_string(spawn->GetBaseSpeed()) + "\n";
  4614. if(spawn->IsSign()) {
  4615. details3 += "Sign Language: " + to_string(((Sign*)spawn)->GetLanguage()) + "\n";
  4616. }
  4617. if(spawn->IsEntity())
  4618. {
  4619. Entity* ent = (Entity*)spawn;
  4620. details3 += "STR / STRBase: " + to_string(ent->GetInfoStruct()->get_str()) + " / " + to_string(ent->GetInfoStruct()->get_str_base()) + "\n";
  4621. details3 += "AGI / AGIBase: " + to_string(ent->GetInfoStruct()->get_agi()) + " / " + to_string(ent->GetInfoStruct()->get_agi_base()) + "\n";
  4622. details3 += "STA / STABase: " + to_string(ent->GetInfoStruct()->get_sta()) + " / " + to_string(ent->GetInfoStruct()->get_sta_base()) + "\n";
  4623. details3 += "INT / INTBase: " + to_string(ent->GetInfoStruct()->get_intel()) + " / " + to_string(ent->GetInfoStruct()->get_intel_base()) + "\n";
  4624. details3 += "WIS / WISBase: " + to_string(ent->GetInfoStruct()->get_wis()) + " / " + to_string(ent->GetInfoStruct()->get_wis_base()) + "\n";
  4625. }
  4626. string details4;
  4627. if (spawn->IsEntity()) {
  4628. details4 += "Facial Hair Type: " + to_string(((Entity*)spawn)->GetFacialHairType()) + "\n";
  4629. details4 += "Hair Type: " + to_string(((Entity*)spawn)->GetHairType()) + "\n";
  4630. details4 += "Chest Type: " + to_string(((Entity*)spawn)->GetChestType()) + "\n";
  4631. details4 += "Legs Type: " + to_string(((Entity*)spawn)->GetLegsType()) + "\n";
  4632. details4 += "Soga Facial Hair Type: " + to_string(((Entity*)spawn)->GetSogaFacialHairType()) + "\n";
  4633. details4 += "Soga Hair Type: " + to_string(((Entity*)spawn)->GetSogaHairType()) + "\n";
  4634. details4 += "Wing Type: " + to_string(((Entity*)spawn)->GetWingType()) + "\n";
  4635. if (spawn->IsNPC()) {
  4636. details4 += "\nRandomize: " + to_string(((NPC*)spawn)->GetRandomize()) + "\n";
  4637. }
  4638. }
  4639. const char* spawnScriptMsg = (spawn->GetSpawnScript() && strlen(spawn->GetSpawnScript())>0) ? spawn->GetSpawnScript() : "Not Set";
  4640. details4 += "\nSpawnScript: " + std::string(spawnScriptMsg) + "\n";
  4641. string title = string(spawn->GetName()) + "(" + to_string(spawn->GetDatabaseID()) + ")";
  4642. client->SendShowBook(client->GetPlayer(), title, 0, 4, details, details2, details3, details4);
  4643. }
  4644. else {
  4645. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn details (radius)");
  4646. 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.");
  4647. }
  4648. break;
  4649. }
  4650. case COMMAND_SPAWN_TARGET:{
  4651. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  4652. int32 spawn_id = atoul(sep->arg[0]);
  4653. int16 response = client->GetCurrentZone()->SetSpawnTargetable(spawn_id);
  4654. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  4655. }
  4656. else if(sep && sep->arg[0][0] && sep->arg[1][0] && sep->IsNumber(1) && ToLower(string(sep->arg[0])) == "radius"){
  4657. float distance = atof(sep->arg[1]);
  4658. int16 response = client->GetCurrentZone()->SetSpawnTargetable(client->GetPlayer(), distance);
  4659. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  4660. }
  4661. else{
  4662. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn target [spawn id]");
  4663. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn as targetable. Used to change a spawn if it was set to untargetable.");
  4664. }
  4665. break;
  4666. }
  4667. case COMMAND_SPAWN_SET:
  4668. {
  4669. Spawn* spawn = cmdTarget;
  4670. sint16 set_type = -1;
  4671. string type_str;
  4672. if (spawn)
  4673. {
  4674. // check if parameters are (location or list or not player and not a 2nd param), and that there is at least 1 value
  4675. 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)
  4676. {
  4677. // set the type, which will be 0 if location or list or invalid
  4678. set_type = spawn_set_values[ToLower(string(sep->arg[0]))];
  4679. }
  4680. if(set_type > 0)
  4681. {
  4682. // check if spawn set is NOT a char update, or not location, or isn't a number
  4683. 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)
  4684. {
  4685. client->SimpleMessage(CHANNEL_COLOR_RED, "Invalid value for set command.");
  4686. }
  4687. else
  4688. {
  4689. string name = string(spawn->GetName());
  4690. bool customSetSpawn = false;
  4691. if(set_type >= SPAWN_SET_CHEEK_TYPE && set_type <= SPAWN_SET_SOGA_NOSE_TYPE)
  4692. {
  4693. int8 index = sep->IsNumber(2) ? atoul(sep->arg[2]) : 0;
  4694. // override the standard setspawncommand, we pass arguments different!
  4695. if(SetSpawnCommand(client, spawn, set_type, sep->arg[1], true, false, nullptr, index))
  4696. customSetSpawn = true;
  4697. }
  4698. if(customSetSpawn || SetSpawnCommand(client, spawn, set_type, sep->argplus[1]))
  4699. {
  4700. if (set_type == SPAWN_SET_VALUE_EXPANSION_FLAG || set_type == SPAWN_SET_VALUE_HOLIDAY_FLAG)
  4701. {
  4702. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "A /reload spawns is required to properly update the spawns with the xpack/holiday flag.");
  4703. }
  4704. else if (set_type == SPAWN_SET_VALUE_NAME)
  4705. {
  4706. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "New name will not be effective until zone reload.");
  4707. }
  4708. else if (set_type == SPAWN_SET_SKIN_COLOR || (set_type >= SPAWN_SET_HAIR_COLOR1 && set_type <= SPAWN_SET_SOGA_EYE_COLOR))
  4709. {
  4710. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set color field to R G B: %s.", sep->argplus[1]);
  4711. }
  4712. else if(set_type == SPAWN_SET_VALUE_LOCATION)
  4713. {
  4714. spawn->SetLocation(client->GetPlayer()->GetLocation());
  4715. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set '%s' to '%u' for spawn '%s'", sep->arg[0], client->GetPlayer()->GetLocation(), name.c_str());
  4716. }
  4717. else
  4718. {
  4719. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set '%s' to '%s' for spawn '%s'", sep->arg[0], sep->arg[1], name.c_str());
  4720. }
  4721. switch (set_type)
  4722. {
  4723. case SPAWN_SET_VALUE_EXPANSION_FLAG:
  4724. case SPAWN_SET_VALUE_HOLIDAY_FLAG:
  4725. case SPAWN_SET_VALUE_FACTION:
  4726. case SPAWN_SET_AAXP_REWARDS:
  4727. case SPAWN_SET_CHEEK_TYPE:
  4728. case SPAWN_SET_CHIN_TYPE:
  4729. case SPAWN_SET_EAR_TYPE:
  4730. case SPAWN_SET_EYE_BROW_TYPE:
  4731. case SPAWN_SET_EYE_TYPE:
  4732. case SPAWN_SET_LIP_TYPE:
  4733. case SPAWN_SET_NOSE_TYPE:
  4734. case SPAWN_SET_BODY_SIZE:
  4735. case SPAWN_SET_BODY_AGE:
  4736. case SPAWN_SET_SOGA_CHEEK_TYPE:
  4737. case SPAWN_SET_SOGA_CHIN_TYPE:
  4738. case SPAWN_SET_SOGA_EAR_TYPE:
  4739. case SPAWN_SET_SOGA_EYE_BROW_TYPE:
  4740. case SPAWN_SET_SOGA_EYE_TYPE:
  4741. case SPAWN_SET_SOGA_LIP_TYPE:
  4742. case SPAWN_SET_SOGA_NOSE_TYPE:
  4743. case SPAWN_SET_SOGA_BODY_SIZE:
  4744. case SPAWN_SET_SOGA_BODY_AGE:
  4745. case SPAWN_SET_ATTACK_TYPE:
  4746. case SPAWN_SET_RACE_TYPE:
  4747. case SPAWN_SET_LOOT_TIER:
  4748. case SPAWN_SET_LOOT_DROP_TYPE:
  4749. {
  4750. // not applicable already ran db command
  4751. break;
  4752. }
  4753. default:
  4754. {
  4755. client->GetCurrentZone()->ApplySetSpawnCommand(client, spawn, set_type, sep->argplus[1]);
  4756. break;
  4757. }
  4758. }
  4759. 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))
  4760. {
  4761. if(spawn->GetSpawnLocationID() > 0 && database.UpdateSpawnLocationSpawns(spawn))
  4762. {
  4763. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information.");
  4764. }
  4765. else if(spawn->GetSpawnLocationID() > 0)
  4766. {
  4767. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn information, see console window for details.");
  4768. }
  4769. }
  4770. else
  4771. {
  4772. if(spawn->GetDatabaseID() > 0 && database.SaveSpawnInfo(spawn))
  4773. {
  4774. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully saved spawn.");
  4775. }
  4776. else if(spawn->GetDatabaseID() > 0)
  4777. {
  4778. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn, see console window for details.");
  4779. }
  4780. }
  4781. }
  4782. }
  4783. }
  4784. else if(set_type == 0)
  4785. {
  4786. // /spawn set list - lists all possible attributes that can be changed with this command, 10 per line.
  4787. map<string, int8>::iterator itr;
  4788. int i=0;
  4789. string list;
  4790. for(itr = spawn_set_values.begin(); itr != spawn_set_values.end(); itr++, i++)
  4791. {
  4792. if(i==10)
  4793. {
  4794. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  4795. i = 0;
  4796. }
  4797. if(i>0)
  4798. {
  4799. list.append(", ").append(itr->first);
  4800. }
  4801. else
  4802. {
  4803. list = itr->first;
  4804. }
  4805. }
  4806. if(list.length() > 0)
  4807. {
  4808. // if 1 or more, display in client.
  4809. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  4810. }
  4811. }
  4812. else
  4813. {
  4814. // syntax fail
  4815. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn set [type] [value]");
  4816. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used to change various settings for the targeted NPC or Object.");
  4817. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "For a list of changeable settings use /spawn set list");
  4818. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Note: /spawn set location does not require a value. The client's current location is used.");
  4819. }
  4820. }
  4821. break;
  4822. }
  4823. case COMMAND_SPAWN_REMOVE:{
  4824. Spawn* spawn = cmdTarget;
  4825. if(spawn && !spawn->IsPlayer()){
  4826. if(spawn->GetSpawnLocationID() > 0){
  4827. if(database.RemoveSpawnFromSpawnLocation(spawn)){
  4828. client->GetCurrentZone()->RemoveSpawn(spawn, true, false, true, true, true);
  4829. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully removed spawn from zone");
  4830. }
  4831. else
  4832. client->SimpleMessage(CHANNEL_COLOR_RED, "Error removing spawn, see console window for details.");
  4833. }
  4834. else
  4835. client->SimpleMessage(CHANNEL_COLOR_RED, "This spawn does not have a spawn group associated with it");
  4836. }
  4837. else{
  4838. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn remove");
  4839. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for removing the targeted NPC or Object from the zone.");
  4840. }
  4841. break;
  4842. }
  4843. case COMMAND_SPAWN_LIST:{
  4844. if(sep && sep->arg[0][0]){
  4845. vector<string>* results = database.GetSpawnNameList(sep->argplus[0]);
  4846. vector<string>::iterator itr;
  4847. if(results){
  4848. for(itr=results->begin();itr!=results->end();itr++){
  4849. client->SimpleMessage(CHANNEL_COLOR_YELLOW, (*itr).c_str());
  4850. }
  4851. safe_delete(results);
  4852. }
  4853. else
  4854. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found. ");
  4855. }
  4856. else{
  4857. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn list [name]");
  4858. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Name can be a partial match.");
  4859. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn list Qeynos Guard");
  4860. }
  4861. break;
  4862. }
  4863. case COMMAND_SPAWN_ADD:{
  4864. Spawn* spawn = cmdTarget;
  4865. if(spawn && sep && sep->arg[1][0] && (sep->IsNumber(0) || strncasecmp(sep->arg[0], "new", 3) == 0)){
  4866. if(spawn->GetSpawnLocationID() > 0){
  4867. client->Message(CHANNEL_COLOR_RED, "This spawn already has a spawn group id of %u, use /spawn remove to reassign it", spawn->GetSpawnLocationID());
  4868. break;
  4869. }
  4870. if(spawn->GetDatabaseID() == 0){
  4871. if(database.SaveSpawnInfo(spawn)) {
  4872. char spawn_type[32];
  4873. memset(spawn_type, 0, sizeof(spawn_type));
  4874. if (spawn->IsNPC())
  4875. strncpy(spawn_type, "NPC", sizeof(spawn_type) - 1);
  4876. else if (spawn->IsObject())
  4877. strncpy(spawn_type, "Object", sizeof(spawn_type) - 1);
  4878. else if (spawn->IsSign())
  4879. strncpy(spawn_type, "Sign", sizeof(spawn_type) - 1);
  4880. else if (spawn->IsGroundSpawn())
  4881. strncpy(spawn_type, "GroundSpawn", sizeof(spawn_type) - 1);
  4882. else
  4883. strncpy(spawn_type, "Unknown", sizeof(spawn_type) - 1);
  4884. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information with a %s id of %u", spawn_type, spawn->GetDatabaseID());
  4885. }
  4886. else
  4887. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn information, see console window for details.");
  4888. }
  4889. int32 spawn_group_id = 0;
  4890. if(strncasecmp(sep->arg[0], "new", 3) == 0)
  4891. spawn_group_id = database.GetNextSpawnLocation();
  4892. else
  4893. spawn_group_id = atol(sep->arg[0]);
  4894. int8 percent = 100;
  4895. if(sep->arg[2] && sep->IsNumber(2))
  4896. percent = atoi(sep->arg[2]);
  4897. spawn->SetSpawnLocationID(spawn_group_id);
  4898. float x_offset = database.GetSpawnLocationPlacementOffsetX(spawn->GetSpawnLocationID());
  4899. float y_offset = database.GetSpawnLocationPlacementOffsetY(spawn->GetSpawnLocationID());
  4900. float z_offset = database.GetSpawnLocationPlacementOffsetZ(spawn->GetSpawnLocationID());
  4901. if(database.SaveSpawnEntry(spawn, sep->arg[1], percent, x_offset, y_offset, z_offset))
  4902. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn location with a spawn group of %u", spawn->GetSpawnLocationID());
  4903. else
  4904. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn location, see console window for details.");
  4905. }
  4906. else{
  4907. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn add [spawn group id] [spawn group name] (percentage)");
  4908. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for adding the targeted NPC or Object to the database.");
  4909. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can substitute new for [spawn group id] to create a new one.");
  4910. }
  4911. break;
  4912. }
  4913. case COMMAND_SPAWN:{
  4914. int32 id = 0;
  4915. Spawn* spawn = 0;
  4916. if(sep && sep->arg[0] && sep->IsNumber(0)){
  4917. id = atol(sep->arg[0]);
  4918. spawn = client->GetCurrentZone()->GetSpawn(id);
  4919. }
  4920. if(id > 0 && spawn && spawn->appearance.name[0] == 0)
  4921. id = 0;
  4922. if(!id || !spawn){
  4923. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn [spawn id] (x) (y) (z) (heading) (location)");
  4924. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are optional except the id. The spawn id must be in the database.");
  4925. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn 1 0 0 0 0");
  4926. safe_delete(sep);
  4927. return;
  4928. }
  4929. if(sep && sep->arg[1][0]){
  4930. float x = atof(sep->arg[1]);
  4931. spawn->appearance.pos.X = x;
  4932. }
  4933. else
  4934. spawn->SetX(client->GetPlayer()->GetX(), false);
  4935. if(sep && sep->arg[2][0]){
  4936. float y = atof(sep->arg[2]);
  4937. spawn->appearance.pos.Y = y;
  4938. }
  4939. else
  4940. spawn->SetY(client->GetPlayer()->GetY(), false);
  4941. if(sep && sep->arg[3][0]){
  4942. float z = atof(sep->arg[3]);
  4943. spawn->appearance.pos.Z = z;
  4944. }
  4945. else
  4946. spawn->SetZ(client->GetPlayer()->GetZ(), false);
  4947. if(sep && sep->arg[4][0]){
  4948. float heading = atof(sep->arg[4]);
  4949. spawn->SetHeading(heading);
  4950. }
  4951. else
  4952. spawn->SetHeading(client->GetPlayer()->GetHeading(), false);
  4953. spawn->SetSpawnOrigX(spawn->GetX());
  4954. spawn->SetSpawnOrigY(spawn->GetY());
  4955. spawn->SetSpawnOrigZ(spawn->GetZ());
  4956. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  4957. if(sep && sep->arg[5][0])
  4958. spawn->appearance.pos.grid_id = atol(sep->arg[5]);
  4959. else
  4960. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  4961. if(spawn->IsNPC() && spawn->GetTotalHP() == 0){
  4962. spawn->SetTotalHP(spawn->GetLevel() * 15);
  4963. spawn->SetHP(spawn->GetTotalHP());
  4964. }
  4965. if(spawn->GetTotalPower() == 0){
  4966. spawn->SetTotalPower(spawn->GetLevel() * 15);
  4967. spawn->SetPower(spawn->GetTotalPower());
  4968. }
  4969. const char* script = world.GetSpawnScript(id);
  4970. if(script && lua_interface && lua_interface->GetSpawnScript(script) != 0)
  4971. spawn->SetSpawnScript(string(script));
  4972. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_PRESPAWN);
  4973. client->GetCurrentZone()->AddSpawn(spawn);
  4974. if(spawn->IsNPC())
  4975. spawn->GetZone()->AddLoot((NPC*)spawn);
  4976. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_SPAWN);
  4977. LogWrite(COMMAND__INFO, 0, "Command", "Received spawn command - Parms: %s", command_parms->data.c_str());
  4978. break;
  4979. }
  4980. case COMMAND_ADMINFLAG:
  4981. {
  4982. if(sep && sep->arg[0]){
  4983. sint16 tmp_status = database.GetCharacterAdminStatus(sep->arg[0]);
  4984. sint16 new_status = atoi(sep->arg[1]);
  4985. if(tmp_status == -10)
  4986. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character does not exist.");
  4987. else if(tmp_status >= client->GetAdminStatus())
  4988. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character has same or higher level status.");
  4989. else if (new_status > client->GetAdminStatus())
  4990. client->SimpleMessage(CHANNEL_ERROR, "Unable to flag character. Reason: New status is higher then your status.");
  4991. else{
  4992. Client* client2 = client->GetCurrentZone()->GetClientByName(sep->arg[0]);
  4993. if (!client2)
  4994. client2 = zone_list.GetClientByCharName(sep->arg[0]);
  4995. if(database.UpdateAdminStatus(sep->arg[0],new_status)) {
  4996. client->Message(CHANNEL_COLOR_YELLOW,"Character status updated to %i for %s.",new_status,sep->arg[0]);
  4997. if (client2) {
  4998. client2->SetAdminStatus(new_status);
  4999. client2->Message(CHANNEL_COLOR_YELLOW, "%s has set your admin status to %i.", client->GetPlayer()->GetName(), new_status);
  5000. }
  5001. }
  5002. else
  5003. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Unknown reason.");
  5004. }
  5005. }else{
  5006. sint16 status = database.GetCharacterAdminStatus(client->GetPlayer()->GetName());
  5007. if(status != client->GetAdminStatus())
  5008. {
  5009. client->Message(CHANNEL_COLOR_YELLOW,"Flag status was changed from %i to %i.",status,client->GetAdminStatus());
  5010. client->SetAdminStatus(status);
  5011. }
  5012. else
  5013. {
  5014. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /flag {name} {new_status}");
  5015. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Standard User: 0");
  5016. client->Message(CHANNEL_COLOR_YELLOW," Admin User: %i", status);
  5017. }
  5018. }
  5019. break;
  5020. }
  5021. case COMMAND_CANNEDEMOTE:{
  5022. client->GetCurrentZone()->HandleEmote(client, command_parms->data);
  5023. break;
  5024. }
  5025. case COMMAND_BROADCAST: {
  5026. if (sep && sep->arg[0])
  5027. zone_list.HandleGlobalBroadcast(sep->argplus[0]);
  5028. else
  5029. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /broadcast {message}");
  5030. break;
  5031. }
  5032. case COMMAND_ANNOUNCE: {
  5033. if (sep && sep->arg[0])
  5034. zone_list.HandleGlobalAnnouncement(sep->argplus[0]);
  5035. else
  5036. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /announce {message}");
  5037. break;
  5038. }
  5039. case COMMAND_RELOAD_ITEMS:{
  5040. LogWrite(COMMAND__INFO, 0, "Command", "Reloading items..");
  5041. int32 item_id = (sep && sep->arg[0]) ? atoul(sep->arg[0]) : 0;
  5042. if(item_id > 0) {
  5043. client->Message(CHANNEL_COLOR_YELLOW, "Reloading item %u based on /reload items [item_id].", item_id);
  5044. }
  5045. else {
  5046. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Started Reloading items (this might take a few minutes...)");
  5047. }
  5048. database.ReloadItemList(item_id);
  5049. if(!item_id) {
  5050. database.LoadMerchantInformation(); // we skip if there is only a reload of single item not all items
  5051. }
  5052. if(item_id > 0) {
  5053. client->Message(CHANNEL_COLOR_YELLOW, "Reloaded item %u.", item_id);
  5054. }
  5055. else {
  5056. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Finished Reloading items.");
  5057. }
  5058. break;
  5059. }
  5060. case COMMAND_ENABLE_ABILITY_QUE:{
  5061. EQ2Packet* app = client->GetPlayer()->GetSpellBookUpdatePacket(client->GetVersion());
  5062. if(app)
  5063. client->QueuePacket(app);
  5064. break;
  5065. }
  5066. case COMMAND_ITEMSEARCH:
  5067. case COMMAND_FROMBROKER:{
  5068. PacketStruct* packet = configReader.getStruct("WS_StartBroker", client->GetVersion());
  5069. if (packet) {
  5070. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  5071. //packet->setDataByName("unknown", 1);
  5072. packet->setDataByName("unknown2", 5, 0);
  5073. packet->setDataByName("unknown2", 20, 1);
  5074. packet->setDataByName("unknown2", 58, 3);
  5075. packet->setDataByName("unknown2", 40, 4);
  5076. client->QueuePacket(packet->serialize());
  5077. PacketStruct* packet2 = configReader.getStruct("WS_BrokerBags", client->GetVersion());
  5078. if (packet2) {
  5079. packet2->setDataByName("char_id", client->GetCharacterID());
  5080. client->QueuePacket(packet2->serialize()); //send this for now, needed to properly clear data
  5081. safe_delete(packet2);
  5082. }
  5083. safe_delete(packet);
  5084. }
  5085. break;
  5086. }
  5087. case COMMAND_ANIMTEST:{
  5088. PacketStruct* command_packet = configReader.getStruct("WS_CannedEmote", client->GetVersion());
  5089. if(command_packet){
  5090. int32 id = client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer());
  5091. if (cmdTarget)
  5092. id = client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget);
  5093. command_packet->setDataByName ( "spawn_id" , id);
  5094. int animID = 1;
  5095. if(sep && sep->arg[0] && sep->IsNumber(0))
  5096. animID = atoi(sep->arg[0]);
  5097. VisualState* vs = NULL;
  5098. if(animID == 0)
  5099. {
  5100. vs = visual_states.FindVisualState(sep->arg[0]);
  5101. }
  5102. char msg[128];
  5103. sprintf(msg,"Animation Test ID: %i",animID);
  5104. command_packet->setMediumStringByName ( "emote_msg" , msg );
  5105. if(vs != NULL)
  5106. command_packet->setDataByName ( "anim_type", vs->GetID ( ) );
  5107. else
  5108. command_packet->setDataByName ( "anim_type", animID );
  5109. command_packet->setDataByName ( "unknown0", 0 );
  5110. EQ2Packet* outapp = command_packet->serialize();
  5111. client->QueuePacket(outapp);
  5112. safe_delete(command_packet);
  5113. }
  5114. break;
  5115. }
  5116. case COMMAND_KICK:
  5117. {
  5118. if( sep == 0 || sep->arg[0] == 0)
  5119. {
  5120. client->SimpleMessage(CHANNEL_COLOR_RED, "/kick [name]");
  5121. }
  5122. else
  5123. {
  5124. Client* kickClient = zone_list.GetClientByCharName(string(sep->arg[0]));
  5125. if ( kickClient == client )
  5126. {
  5127. client->Message(CHANNEL_COLOR_RED, "You can't kick yourself!");
  5128. break;
  5129. }
  5130. else if(kickClient != NULL)
  5131. {
  5132. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  5133. if ( maxStatus >= client->GetAdminStatus( ) || kickClient->GetAdminStatus() >= client->GetAdminStatus() )
  5134. {
  5135. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  5136. break;
  5137. }
  5138. client->Message(CHANNEL_COLOR_RED, "Kicking %s...",sep->arg[0]);
  5139. kickClient->Disconnect();
  5140. }
  5141. else
  5142. {
  5143. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  5144. }
  5145. }
  5146. break;
  5147. }
  5148. case COMMAND_LOCK:
  5149. {
  5150. if( sep != NULL && sep->arg[0] != NULL && sep->IsNumber(0)){
  5151. int worldLocked = atoi(sep->arg[0]);
  5152. net.world_locked = worldLocked;
  5153. if ( worldLocked )
  5154. client->Message(CHANNEL_COLOR_YELLOW,"World server has been locked.");
  5155. else
  5156. client->Message(CHANNEL_COLOR_YELLOW,"World server has been unlocked.");
  5157. }
  5158. else
  5159. client->SimpleMessage(CHANNEL_COLOR_RED, "/lock [0/1]");
  5160. break;
  5161. }
  5162. case COMMAND_BAN:{
  5163. if( sep == 0 || sep->arg[0] == 0 || (sep->arg[1][0] != 0 && !sep->IsNumber(1) ) )
  5164. {
  5165. client->SimpleMessage(CHANNEL_COLOR_RED, "/ban [name] [permanent:0/1]");
  5166. }
  5167. else
  5168. {
  5169. Client* kickClient = zone_list.GetClientByCharName(sep->arg[0]);
  5170. if ( kickClient == client )
  5171. {
  5172. client->Message(CHANNEL_COLOR_RED, "You can't ban yourself!");
  5173. break;
  5174. }
  5175. else if(kickClient != NULL)
  5176. {
  5177. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  5178. if ( maxStatus > client->GetAdminStatus( ) ||
  5179. client->GetAdminStatus ( ) > kickClient->GetAdminStatus ( ) )
  5180. {
  5181. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  5182. break;
  5183. }
  5184. client->Message(CHANNEL_COLOR_RED, "Kicking & Banning %s...",sep->arg[0]);
  5185. int perm = atol(sep->arg[1]);
  5186. if ( perm == 1 )
  5187. database.UpdateAdminStatus(sep->arg[0],-2);
  5188. else
  5189. database.UpdateAdminStatus(sep->arg[0],-1);
  5190. kickClient->Disconnect();
  5191. }
  5192. else
  5193. {
  5194. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  5195. }
  5196. }
  5197. break;
  5198. }
  5199. case COMMAND_SET_COMBAT_VOICE:{
  5200. int32 value = 0;
  5201. if(sep && sep->arg[0] && sep->IsNumber(0))
  5202. value = atoi(sep->arg[0]);
  5203. client->GetPlayer()->SetCombatVoice(value);
  5204. break;
  5205. }
  5206. case COMMAND_SET_EMOTE_VOICE:{
  5207. int32 value = 0;
  5208. if(sep && sep->arg[0] && sep->IsNumber(0))
  5209. value = atoi(sep->arg[0]);
  5210. client->GetPlayer()->SetEmoteVoice(value);
  5211. break;
  5212. }
  5213. case COMMAND_GIVEITEM:{
  5214. if(sep && sep->arg[0][0] && sep->arg[0][1] && sep->IsNumber(1)){
  5215. Client* itemToClient = zone_list.GetClientByCharName(sep->arg[0]);
  5216. if ( itemToClient == NULL )
  5217. client->Message(CHANNEL_COLOR_YELLOW,"Could not find %s.",sep->arg[0]);
  5218. else
  5219. {
  5220. int32 item_id = atol(sep->arg[1]);
  5221. client->Message(CHANNEL_COLOR_YELLOW,"Gave %s item id %i.",sep->arg[0],item_id);
  5222. itemToClient->AddItem(item_id);
  5223. }
  5224. }
  5225. else
  5226. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /giveitem [name] [item_id]");
  5227. break;
  5228. }
  5229. case COMMAND_REPORT_BUG : { Command_ReportBug(client, sep); break; }
  5230. case COMMAND_INVENTORY : { Command_Inventory(client, sep, command); break; }
  5231. case COMMAND_WEAPONSTATS : { Command_WeaponStats(client); break; }
  5232. case COMMAND_SKILL :
  5233. case COMMAND_SKILL_ADD :
  5234. case COMMAND_SKILL_REMOVE :
  5235. case COMMAND_SKILL_LIST : { Command_Skills(client, sep, command->handler); break; }
  5236. case COMMAND_ZONE_SET : { Command_ZoneSet(client, sep); break; }
  5237. case COMMAND_ZONE_DETAILS : { Command_ZoneDetails(client, sep); break; }
  5238. case COMMAND_ENTITYCOMMAND :
  5239. case COMMAND_ENTITYCOMMAND_LIST : { Command_EntityCommand(client, sep, command->handler); break; }
  5240. case COMMAND_MERCHANT :
  5241. case COMMAND_MERCHANT_LIST : { Command_Merchant(client, sep, command->handler); break; }
  5242. case COMMAND_APPEARANCE :
  5243. case COMMAND_APPEARANCE_LIST : { Command_Appearance(client, sep, command->handler); break; }
  5244. case COMMAND_TRACK : { Command_Track(client); break; }
  5245. case COMMAND_DISTANCE : { Command_Distance(client); break; }
  5246. case COMMAND_INSPECT_PLAYER : { Command_InspectPlayer(client, sep); break; }
  5247. case COMMAND_ZONE_SAFE : { Command_ZoneSafeCoords(client, sep); break; }
  5248. case COMMAND_GUILDSAY : { Command_GuildSay(client, sep); break; }
  5249. case COMMAND_OFFICERSAY : { Command_OfficerSay(client, sep); break; }
  5250. case COMMAND_SET_GUILD_MEMBER_NOTE : { Command_SetGuildMemberNote(client, sep); break; }
  5251. case COMMAND_SET_GUILD_OFFICER_NOTE : { Command_SetGuildOfficerNote(client, sep); break; }
  5252. case COMMAND_GUILD : { Command_Guild(client, sep); break; }
  5253. case COMMAND_CREATE_GUILD : { Command_CreateGuild(client); break; }
  5254. case COMMAND_GUILDS : { Command_Guilds(client); break; }
  5255. case COMMAND_GUILDS_ADD : { Command_GuildsAdd(client, sep); break; }
  5256. case COMMAND_GUILDS_CREATE : { Command_GuildsCreate(client, sep); break; }
  5257. case COMMAND_GUILDS_DELETE : { Command_GuildsDelete(client, sep); break; }
  5258. case COMMAND_GUILDS_LIST : { Command_GuildsList(client); break; }
  5259. case COMMAND_GUILDS_REMOVE : { Command_GuildsRemove(client, sep); break; }
  5260. case COMMAND_CLAIM : { Command_Claim(client, sep); break; }
  5261. case COMMAND_CLEAR_ALL_QUEUED : { Command_ClearAllQueued(client); break; }
  5262. case COMMAND_LOCATION : { Command_Location(client); break; }
  5263. case COMMAND_LOCATION_ADD : { Command_LocationAdd(client, sep); break; }
  5264. case COMMAND_LOCATION_CREATE : { Command_LocationCreate(client, sep); break; }
  5265. case COMMAND_LOCATION_DELETE : { Command_LocationDelete(client, sep); break; }
  5266. case COMMAND_LOCATION_LIST : { Command_LocationList(client, sep); break; }
  5267. case COMMAND_LOCATION_REMOVE : { Command_LocationRemove(client, sep); break; }
  5268. case COMMAND_GRID : { Command_Grid(client, sep); break; }
  5269. case COMMAND_TRY_ON : { Command_TryOn(client, sep); break; }
  5270. case COMMAND_RANDOMIZE : { Command_Randomize(client, sep); break; }
  5271. case COMMAND_AFK : { Command_AFK(client, sep); break; }
  5272. case COMMAND_SHOW_CLOAK : { Command_ShowCloak(client, sep); break; }
  5273. case COMMAND_SHOW_HELM : { Command_ShowHelm(client, sep); break; }
  5274. case COMMAND_SHOW_HOOD : { Command_ShowHood(client, sep); break; }
  5275. case COMMAND_SHOW_HOOD_OR_HELM : { Command_ShowHoodHelm(client, sep); break; }
  5276. case COMMAND_SHOW_RANGED : { Command_ShowRanged(client, sep); break; }
  5277. case COMMAND_STOP_DRINKING : { Command_StopDrinking(client); break; }
  5278. case COMMAND_STOP_EATING : { Command_StopEating(client); break; }
  5279. case COMMAND_TOGGLE_ANONYMOUS : { Command_Toggle_Anonymous(client); break; }
  5280. case COMMAND_TOGGLE_AUTOCONSUME : { Command_Toggle_AutoConsume(client, sep); break; }
  5281. case COMMAND_TOGGLE_BONUS_EXP : { Command_Toggle_BonusXP(client); break; }
  5282. case COMMAND_TOGGLE_COMBAT_EXP : { Command_Toggle_CombatXP(client); break; }
  5283. case COMMAND_TOGGLE_GM_HIDE : { Command_Toggle_GMHide(client); break; }
  5284. case COMMAND_TOGGLE_GM_VANISH : { Command_Toggle_GMVanish(client); break; }
  5285. case COMMAND_TOGGLE_ILLUSIONS : { Command_Toggle_Illusions(client, sep); break; }
  5286. case COMMAND_TOGGLE_LFG : { Command_Toggle_LFG(client); break; }
  5287. case COMMAND_TOGGLE_LFW : { Command_Toggle_LFW(client); break; }
  5288. case COMMAND_TOGGLE_QUEST_EXP : { Command_Toggle_QuestXP(client); break; }
  5289. case COMMAND_TOGGLE_ROLEPLAYING : { Command_Toggle_Roleplaying(client); break; }
  5290. case COMMAND_TOGGLE_DUELS : { Command_Toggle_Duels(client); break; }
  5291. case COMMAND_TOGGLE_TRADES : { Command_Toggle_Trades(client); break; }
  5292. case COMMAND_TOGGLE_GUILDS : { Command_Toggle_Guilds(client); break; }
  5293. case COMMAND_TOGGLE_GROUPS : { Command_Toggle_Groups(client); break; }
  5294. case COMMAND_TOGGLE_RAIDS : { Command_Toggle_Raids(client); break; }
  5295. case COMMAND_TOGGLE_LON : { Command_Toggle_LON(client); break; }
  5296. case COMMAND_TOGGLE_VCINVITE : { Command_Toggle_VoiceChat(client); break; }
  5297. case COMMAND_CANCEL_MAINTAINED : { Command_CancelMaintained(client, sep); break; }
  5298. case COMMAND_MOTD : { Command_MOTD(client); break; }
  5299. case COMMAND_RANDOM : { Command_Random(client, sep); break; }
  5300. case COMMAND_CREATE : { Command_Create(client, sep); break; }
  5301. case COMMAND_CREATEFROMRECIPE : { Command_CreateFromRecipe(client, sep); break; }
  5302. case COMMAND_TITLE : { Command_Title(client); break; }
  5303. case COMMAND_TITLE_LIST : { Command_TitleList(client); break; }
  5304. case COMMAND_TITLE_SETPREFIX : { Command_TitleSetPrefix(client, sep); break; }
  5305. case COMMAND_TITLE_SETSUFFIX : { Command_TitleSetSuffix(client, sep); break; }
  5306. case COMMAND_TITLE_FIX : { Command_TitleFix(client, sep); break; }
  5307. case COMMAND_LANGUAGES : { Command_Languages(client, sep); break; }
  5308. case COMMAND_SET_LANGUAGE : { Command_SetLanguage(client, sep); break; }
  5309. case COMMAND_FOLLOW : { Command_Follow(client, sep); break; }
  5310. case COMMAND_STOP_FOLLOW : { Command_StopFollow(client, sep); break; }
  5311. case COMMAND_LASTNAME : { Command_LastName(client, sep); break; }
  5312. case COMMAND_CONFIRMLASTNAME : { Command_ConfirmLastName(client, sep); break; }
  5313. case COMMAND_PET : { Command_Pet(client, sep); break; }
  5314. case COMMAND_PETNAME : { Command_PetName(client, sep); break; }
  5315. case COMMAND_NAME_PET : { Command_NamePet(client, sep); break; }
  5316. case COMMAND_RENAME : { Command_Rename(client, sep); break; }
  5317. case COMMAND_CONFIRMRENAME : { Command_ConfirmRename(client, sep); break; }
  5318. case COMMAND_PETOPTIONS : { Command_PetOptions(client, sep); break; }
  5319. case COMMAND_START_TRADE : { Command_TradeStart(client, sep); break; }
  5320. case COMMAND_ACCEPT_TRADE : { Command_TradeAccept(client, sep); break; }
  5321. case COMMAND_REJECT_TRADE : { Command_TradeReject(client, sep); break; }
  5322. case COMMAND_CANCEL_TRADE : { Command_TradeCancel(client, sep); break; }
  5323. case COMMAND_SET_TRADE_COIN : { Command_TradeSetCoin(client, sep); break; }
  5324. case COMMAND_ADD_TRADE_COPPER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_COPPER); break; }
  5325. case COMMAND_ADD_TRADE_SILVER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_SILVER); break; }
  5326. case COMMAND_ADD_TRADE_GOLD : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_GOLD); break; }
  5327. case COMMAND_ADD_TRADE_PLAT : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_PLAT); break; }
  5328. case COMMAND_REMOVE_TRADE_COPPER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_COPPER); break; }
  5329. case COMMAND_REMOVE_TRADE_SILVER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_SILVER); break; }
  5330. case COMMAND_REMOVE_TRADE_GOLD : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_GOLD); break; }
  5331. case COMMAND_REMOVE_TRADE_PLAT : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_PLAT); break; }
  5332. case COMMAND_ADD_TRADE_ITEM : { Command_TradeAddItem(client, sep); break; }
  5333. case COMMAND_REMOVE_TRADE_ITEM : { Command_TradeRemoveItem(client, sep); break; }
  5334. case COMMAND_ACCEPT_ADVANCEMENT : { Command_AcceptAdvancement(client, sep); break; }
  5335. case COMMAND_DUEL : { Command_Duel(client, sep); break; }
  5336. case COMMAND_DUELBET : { Command_DuelBet(client, sep); break; }
  5337. case COMMAND_DUEL_ACCEPT : { Command_DuelAccept(client, sep); break; }
  5338. case COMMAND_DUEL_DECLINE : { Command_DuelDecline(client, sep); break; }
  5339. case COMMAND_DUEL_SURRENDER : { Command_DuelSurrender(client, sep); break; }
  5340. case COMMAND_DUEL_TOGGLE : { Command_DuelToggle(client, sep); break; }
  5341. case COMMAND_SPAWN_TEMPLATE : { Command_SpawnTemplate(client, sep); break; }
  5342. //devn00b
  5343. case COMMAND_MOOD : { Command_Mood(client, sep); break;}
  5344. case COMMAND_MODIFY : { Command_Modify(client); break; }
  5345. case COMMAND_MODIFY_CHARACTER : { Command_ModifyCharacter(client, sep); break; }
  5346. case COMMAND_MODIFY_QUEST : { Command_ModifyQuest(client, sep); break; }
  5347. case COMMAND_MODIFY_FACTION : { Command_ModifyFaction(client, sep); break; }
  5348. case COMMAND_MODIFY_GUILD : { Command_ModifyGuild(client, sep); break; }
  5349. case COMMAND_MODIFY_ITEM : { Command_ModifyItem(client, sep); break; }
  5350. case COMMAND_MODIFY_SKILL : { Command_ModifySkill(client, sep); break; }
  5351. case COMMAND_MODIFY_SPAWN : { Command_ModifySpawn(client, sep); break; }
  5352. case COMMAND_MODIFY_SPELL : { Command_ModifySpell(client, sep); break; }
  5353. case COMMAND_MODIFY_ZONE : { Command_ModifyZone(client, sep); break; }
  5354. case COMMAND_JOIN_CHANNEL : { Command_JoinChannel(client, sep); break;}
  5355. case COMMAND_JOIN_CHANNEL_FROM_LOAD: { Command_JoinChannelFromLoad(client, sep); break;}
  5356. case COMMAND_TELL_CHANNEL : { Command_TellChannel(client, sep); break;}
  5357. case COMMAND_LEAVE_CHANNEL : { Command_LeaveChannel(client, sep); break;}
  5358. case COMMAND_WHO_CHANNEL : { Command_WhoChannel(client, sep); break;}
  5359. case COMMAND_RAIN : { Command_Rain(client, sep); break; }
  5360. case COMMAND_WIND : { Command_Wind(client, sep); break; }
  5361. case COMMAND_WEATHER : { Command_Weather(client, sep); break; }
  5362. case COMMAND_FROM_MERCHANT : { Command_SendMerchantWindow(client, sep); break; }
  5363. case COMMAND_TO_MERCHANT : { Command_SendMerchantWindow(client, sep, true); break; }
  5364. case COMMAND_SELECT : { Command_Select(client, sep); break; }
  5365. case COMMAND_SMP : { Command_StationMarketPlace(client, sep); break; }
  5366. case COMMAND_CONSUME_FOOD : { Command_ConsumeFood(client, sep); break; }
  5367. case COMMAND_AQUAMAN : { Command_Aquaman(client, sep); break; }
  5368. case COMMAND_ATTUNE_INV : { Command_Attune_Inv(client, sep); break; }
  5369. case COMMAND_PLAYER : { Command_Player(client, sep); break; }
  5370. case COMMAND_PLAYER_COINS : { Command_Player_Coins(client, sep); break; }
  5371. case COMMAND_RESET_ZONE_TIMER : { Command_Reset_Zone_Timer(client, sep); break; }
  5372. case COMMAND_ACHIEVEMENT_ADD : { Command_AchievementAdd(client, sep); break; }
  5373. case COMMAND_EDITOR : { Command_Editor(client, sep); break; }
  5374. case COMMAND_ACCEPT_RESURRECTION: { Command_AcceptResurrection(client, sep); break; }
  5375. case COMMAND_DECLINE_RESURRECTION:{ Command_DeclineResurrection(client, sep); break; }
  5376. case COMMAND_TEST : { Command_Test(client, command_parms); break; }
  5377. case COMMAND_SPEED : { Command_Speed(client, sep); break; }
  5378. case COMMAND_BOT : { Command_Bot(client, sep); break; }
  5379. case COMMAND_BOT_CREATE : { Command_Bot_Create(client, sep); break; }
  5380. case COMMAND_BOT_CUSTOMIZE : { Command_Bot_Customize(client, sep); break; }
  5381. case COMMAND_BOT_SPAWN : { Command_Bot_Spawn(client, sep); break; }
  5382. case COMMAND_BOT_LIST : { Command_Bot_List(client, sep); break; }
  5383. case COMMAND_BOT_INV : { Command_Bot_Inv(client, sep); break; }
  5384. case COMMAND_BOT_SETTINGS : { Command_Bot_Settings(client, sep); break; }
  5385. case COMMAND_BOT_HELP : { Command_Bot_Help(client, sep); break; }
  5386. case GET_AA_XML : { Get_AA_Xml(client, sep); break; }
  5387. case ADD_AA : { Add_AA(client, sep); break; }
  5388. case COMMIT_AA_PROFILE : { Commit_AA_Profile(client, sep); break; }
  5389. case BEGIN_AA_PROFILE : { Begin_AA_Profile(client, sep); break; }
  5390. case BACK_AA : { Back_AA(client, sep); break; }
  5391. case REMOVE_AA : { Remove_AA(client, sep); break; }
  5392. case SWITCH_AA_PROFILE : { Switch_AA_Profile(client, sep); break; }
  5393. case CANCEL_AA_PROFILE : { Cancel_AA_Profile(client, sep); break; }
  5394. case SAVE_AA_PROFILE : { Save_AA_Profile(client, sep); break; }
  5395. case COMMAND_TARGETITEM : { Command_TargetItem(client, sep); break; }
  5396. case COMMAND_FINDSPAWN: { Command_FindSpawn(client, sep); break; }
  5397. case COMMAND_MOVECHARACTER: { Command_MoveCharacter(client, sep); break; }
  5398. case COMMAND_CRAFTITEM: {
  5399. Item* item = 0;
  5400. if (sep && sep->IsNumber(0)) {
  5401. int32 item_id = atol(sep->arg[0]);
  5402. int32 quantity = 1;
  5403. if (sep->arg[1] && sep->IsNumber(1))
  5404. quantity = atoi(sep->arg[1]);
  5405. item = new Item(master_item_list.GetItem(item_id));
  5406. if (!item) {
  5407. LogWrite(TRADESKILL__ERROR, 0, "CraftItem", "Item (%u) not found.", item_id);
  5408. }
  5409. else {
  5410. item->details.count = quantity;
  5411. // use CHANNEL_COLOR_CHAT_RELATIONSHIP as that is the same value (4) as it is in a log for this message
  5412. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You created %s.", item->CreateItemLink(client->GetVersion()).c_str());
  5413. bool itemDeleted = false;
  5414. client->AddItem(item, &itemDeleted);
  5415. //Check for crafting quest updates
  5416. int8 update_amt = 0;
  5417. if (!itemDeleted && item->stack_count > 1)
  5418. update_amt = 1;
  5419. else
  5420. update_amt = quantity;
  5421. if(!itemDeleted)
  5422. client->GetPlayer()->CheckQuestsCraftUpdate(item, update_amt);
  5423. }
  5424. }
  5425. else {
  5426. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /craftitem {item_id} [quantity] ");
  5427. }
  5428. break;
  5429. }
  5430. case COMMAND_UNMENTOR:
  5431. case COMMAND_MENTOR: {
  5432. client->GetPlayer()->MentorTarget();
  5433. break;
  5434. }
  5435. case COMMAND_CANCEL_EFFECT: { Command_CancelEffect(client, sep); break; }
  5436. case COMMAND_CUREPLAYER: { Command_CurePlayer(client, sep); break; }
  5437. default:
  5438. {
  5439. LogWrite(COMMAND__WARNING, 0, "Command", "Unhandled command: %s", command->command.data.c_str());
  5440. break;
  5441. }
  5442. }
  5443. safe_delete(sep);
  5444. }
  5445. /******************** New COMMAND Handler Functions ********************/
  5446. /*
  5447. Started breaking apart the huge switch() for commands into sepErate
  5448. functions so it is easier to locate the blocks of code by command
  5449. -- JA 2012.03.03
  5450. */
  5451. // sample function header
  5452. /*
  5453. Function:
  5454. Purpose :
  5455. Params :
  5456. Dev :
  5457. Example :
  5458. */
  5459. //void Commands::Command()
  5460. //{
  5461. //}
  5462. /*
  5463. Function: Command_AcceptAdvancement()
  5464. Purpose : Player accepts a new advancement option
  5465. Params : Spell ID
  5466. Dev : Jabantiz
  5467. */
  5468. void Commands::Command_AcceptAdvancement(Client* client, Seperator* sep)
  5469. {
  5470. Player *player = client->GetPlayer();
  5471. if (sep && sep->IsSet(0)) {
  5472. TraitData* trait = master_trait_list.GetTrait(atoul(sep->arg[0]));
  5473. // Check to see if this is a trait or grandmaster training (traits are always new spells, training is always upgrades)
  5474. if (!player->HasSpell(trait->spellID, 0, true))
  5475. {
  5476. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  5477. player->AddSpellBookEntry(trait->spellID, trait->tier, player->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  5478. }
  5479. else
  5480. {
  5481. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  5482. int8 old_slot = player->GetSpellSlot(spell->GetSpellID());
  5483. player->RemoveSpellBookEntry(spell->GetSpellID());
  5484. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  5485. player->UnlockSpell(spell);
  5486. client->SendSpellUpdate(spell);
  5487. }
  5488. // Spell book update
  5489. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  5490. client->QueuePacket(master_trait_list.GetTraitListPacket(client));
  5491. }
  5492. }
  5493. /*
  5494. Function:
  5495. Purpose :
  5496. Params :
  5497. Dev :
  5498. Example :
  5499. */
  5500. void Commands::Command_AFK(Client* client, Seperator* sep)
  5501. {
  5502. Player* player = client->GetPlayer();
  5503. player->toggle_character_flag(CF_AFK);
  5504. client->Message(CHANNEL_COLOR_YELLOW,"You are %s afk.", client->GetPlayer()->get_character_flag(CF_AFK)?"now":"no longer");
  5505. if (player->get_character_flag(CF_AFK))
  5506. {
  5507. if (sep && sep->argplus[0])
  5508. player->SetAwayMessage("I am away from the keyboard, " + string(sep->argplus[0]));
  5509. else
  5510. player->SetAwayMessage("Sorry, I am A.F.K. (Away From Keyboard)");
  5511. string message = string(player->GetName()) + " is going afk.";
  5512. Spawn* target = player->GetTarget();
  5513. if (target && target != player)
  5514. {
  5515. message = string(player->GetName()) + " tells " + string(target->GetName()) + " that ";
  5516. player->GetGender() == 1 ? message += "he" : message += "she";
  5517. message += " is going afk.";
  5518. }
  5519. player->GetZone()->SimpleMessage(CHANNEL_COLOR_YELLOW, message.c_str(), player, 30);
  5520. }
  5521. }
  5522. /*
  5523. Function: Command_Appearance()
  5524. Purpose : Handles /appearance commands
  5525. Params : list
  5526. Dev : Scatman
  5527. Example : /appearance list
  5528. */
  5529. void Commands::Command_Appearance(Client* client, Seperator* sep, int handler)
  5530. {
  5531. if( handler == COMMAND_APPEARANCE )
  5532. {
  5533. // /appearance command by itself shows help (to be extended)
  5534. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  5535. return;
  5536. }
  5537. else if( handler == COMMAND_APPEARANCE_LIST )
  5538. {
  5539. // /appearance list command expects "name" param
  5540. if (sep && sep->arg[0])
  5541. {
  5542. const char* appearance_name = sep->argplus[0];
  5543. client->Message(CHANNEL_COLOR_YELLOW, "Listing appearances like '%s':", appearance_name);
  5544. vector<int16>* appearances = database.GetAppearanceIDsLikeName(string(appearance_name));
  5545. if (appearances)
  5546. {
  5547. vector<int16>::iterator itr;
  5548. for (itr = appearances->begin(); itr != appearances->end(); itr++)
  5549. {
  5550. int16 id = *itr;
  5551. string name = database.GetAppearanceName(id);
  5552. if (ToLower(name).find(ToLower(string(appearance_name))) < 0xFFFFFFFF)
  5553. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", name.c_str(), id);
  5554. }
  5555. safe_delete(appearances);
  5556. }
  5557. }
  5558. else // no param
  5559. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  5560. }
  5561. }
  5562. /*
  5563. Function: Command_Claim()
  5564. Purpose :
  5565. Params :
  5566. Dev :
  5567. Example :
  5568. */
  5569. void Commands::Command_Claim(Client* client, Seperator* sep)
  5570. {
  5571. if (sep && sep->arg[0] && sep->IsNumber(0))
  5572. {
  5573. LogWrite(MISC__TODO, 1, "TODO", "TODO: Command_Claim to be completed\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  5574. }
  5575. else
  5576. client->ShowClaimWindow();
  5577. }
  5578. /*
  5579. Function: Command_ClearAllQueued()
  5580. Purpose :
  5581. Params :
  5582. Dev :
  5583. Example :
  5584. */
  5585. void Commands::Command_ClearAllQueued(Client* client)
  5586. {
  5587. ZoneServer* zone = client->GetPlayer()->GetZone();
  5588. if (zone && zone->GetSpellProcess())
  5589. zone->GetSpellProcess()->RemoveSpellFromQueue(client->GetPlayer());
  5590. }
  5591. /*
  5592. Function: Command_CancelMaintained()
  5593. Purpose : Cancels maintained spells
  5594. Params : Maintained Spell Index
  5595. Dev : Zcoretri
  5596. Example : /cancel_maintained 1 - would cancel the spell in slot 1 of Maintained Spells list
  5597. */
  5598. void Commands::Command_CancelMaintained(Client* client, Seperator* sep)
  5599. {
  5600. if (sep && sep->arg[0] && sep->IsNumber(0))
  5601. {
  5602. int32 spell_index = atoul(sep->arg[0]);
  5603. if(spell_index > 29)
  5604. return;
  5605. client->GetPlayer()->MMaintainedSpells.readlock(__FUNCTION__, __LINE__);
  5606. MaintainedEffects mEffects = client->GetPlayer()->GetInfoStruct()->maintained_effects[spell_index];
  5607. client->GetPlayer()->MMaintainedSpells.releasereadlock(__FUNCTION__, __LINE__);
  5608. if (!client->GetPlayer()->GetZone()->GetSpellProcess()->DeleteCasterSpell(mEffects.spell, "canceled", false))
  5609. client->Message(CHANNEL_COLOR_RED, "The maintained spell could not be cancelled.");
  5610. }
  5611. }
  5612. /*
  5613. Function: Command_Create()
  5614. Purpose : Handler for starting Tradeskilling table
  5615. Params :
  5616. Dev : Zcoretri
  5617. Example :
  5618. */
  5619. void Commands::Command_Create(Client* client, Seperator* sep)
  5620. {
  5621. PrintSep(sep, "COMMAND_CREATE");
  5622. client->SendRecipeList();
  5623. client->ShowRecipeBook();
  5624. }
  5625. void Commands::Command_CreateFromRecipe(Client* client, Seperator* sep)
  5626. {
  5627. PrintSep(sep, "COMMAND_CREATEFROMRECIPE");
  5628. if (sep && sep->arg[0] && sep->IsNumber(0))
  5629. ClientPacketFunctions::SendCreateFromRecipe(client, atoul(sep->arg[0]));
  5630. }
  5631. /*
  5632. Function: Command_Distance()
  5633. Purpose : Displays distance from targeted spawn
  5634. Params :
  5635. Dev : Scatman
  5636. Example : /distance
  5637. */
  5638. void Commands::Command_Distance(Client* client)
  5639. {
  5640. Spawn* target = client->GetPlayer()->GetTarget();
  5641. if (target)
  5642. client->Message(CHANNEL_COLOR_YELLOW, "Your distance from %s is %f", target->GetName(), client->GetPlayer()->GetDistance(target));
  5643. else
  5644. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must have a spawn targeted to use /distance");
  5645. }
  5646. /*
  5647. Function: Command_Duel()
  5648. Purpose : Handle the /duel commands - not yet implemented
  5649. Params : unknown
  5650. Dev :
  5651. Example :
  5652. */
  5653. void Commands::Command_Duel(Client* client, Seperator* sep)
  5654. {
  5655. PrintSep(sep, "COMMAND_DUEL");
  5656. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Command");
  5657. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5658. }
  5659. /*
  5660. Function: Command_DuelBet()
  5661. Purpose : Handle the /duel commands - not yet implemented
  5662. Params : unknown
  5663. Dev :
  5664. Example :
  5665. */
  5666. void Commands::Command_DuelBet(Client* client, Seperator* sep)
  5667. {
  5668. PrintSep(sep, "COMMAND_DUELBET");
  5669. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Bet Command");
  5670. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5671. }
  5672. /*
  5673. Function: Command_DuelAccept()
  5674. Purpose : Handle the /duel commands - not yet implemented
  5675. Params : unknown
  5676. Dev :
  5677. Example :
  5678. */
  5679. void Commands::Command_DuelAccept(Client* client, Seperator* sep)
  5680. {
  5681. PrintSep(sep, "COMMAND_DUEL_ACCEPT");
  5682. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Accept Duel Command");
  5683. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5684. }
  5685. /*
  5686. Function: Command_DuelDecline()
  5687. Purpose : Handle the /duel commands - not yet implemented
  5688. Params : unknown
  5689. Dev :
  5690. Example :
  5691. */
  5692. void Commands::Command_DuelDecline(Client* client, Seperator* sep)
  5693. {
  5694. PrintSep(sep, "COMMAND_DUEL_DECLINE");
  5695. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Decline Duel Request Command");
  5696. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5697. }
  5698. /*
  5699. Function: Command_DuelSurrender()
  5700. Purpose : Handle the /duel commands - not yet implemented
  5701. Params : unknown
  5702. Dev :
  5703. Example :
  5704. */
  5705. void Commands::Command_DuelSurrender(Client* client, Seperator* sep)
  5706. {
  5707. PrintSep(sep, "COMMAND_DUEL_SURRENDER");
  5708. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Surrender Duel Command");
  5709. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5710. // JA, just messin around ;)
  5711. char surrender[64];
  5712. sprintf(surrender, "%s surrendered like a cowardly dog!", client->GetPlayer()->GetName());
  5713. zone_list.HandleGlobalAnnouncement(surrender);
  5714. }
  5715. /*
  5716. Function: Command_DuelToggle()
  5717. Purpose : Handle the /duel commands - not yet implemented
  5718. Params : unknown
  5719. Dev :
  5720. Example :
  5721. */
  5722. void Commands::Command_DuelToggle(Client* client, Seperator* sep)
  5723. {
  5724. PrintSep(sep, "COMMAND_DUEL");
  5725. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Commands");
  5726. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5727. }
  5728. /*
  5729. Function:
  5730. Purpose :
  5731. Params :
  5732. Dev :
  5733. Example :
  5734. */
  5735. void Commands::Command_EntityCommand(Client* client, Seperator* sep, int handler)
  5736. {
  5737. if( handler == COMMAND_ENTITYCOMMAND )
  5738. {
  5739. // /entitycommand command by itself shows help (to be extended)
  5740. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  5741. return;
  5742. }
  5743. else if( handler == COMMAND_ENTITYCOMMAND_LIST )
  5744. {
  5745. // /entitycommand list command expects "name" param
  5746. if (sep && sep->arg[0])
  5747. {
  5748. const char* entity_command_name = sep->argplus[0];
  5749. client->Message(CHANNEL_COLOR_YELLOW, "Listing entity commands like '%s':", entity_command_name);
  5750. map<int32, vector<EntityCommand*>*>* entity_command_list_all = client->GetCurrentZone()->GetEntityCommandListAll();
  5751. map<int32, vector<EntityCommand*>*>::iterator itr;
  5752. for (itr = entity_command_list_all->begin(); itr != entity_command_list_all->end(); itr++)
  5753. {
  5754. vector<EntityCommand*>* entity_command_list = itr->second;
  5755. vector<EntityCommand*>::iterator itr2;
  5756. for (itr2 = entity_command_list->begin(); itr2 != entity_command_list->end(); itr2++)
  5757. {
  5758. EntityCommand* entity_command = *itr2;
  5759. if (ToLower(entity_command->name).find(ToLower(string(entity_command_name))) < 0xFFFFFFFF)
  5760. 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);
  5761. }
  5762. }
  5763. }
  5764. else // no command name
  5765. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  5766. }
  5767. }
  5768. /*
  5769. Function: Command_Follow()
  5770. Purpose : Handle the /follow command - not yet implemented
  5771. Params :
  5772. Dev :
  5773. Example :
  5774. */
  5775. void Commands::Command_Follow(Client* client, Seperator* sep)
  5776. {
  5777. PrintSep(sep, "COMMAND_FOLLOW");
  5778. // flag to toggle if the players target is in the players group
  5779. bool targetInGroup = false;
  5780. // get a pointer to the players group
  5781. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  5782. // If the player has a group and has a target
  5783. if (gmi && client->GetPlayer()->GetTarget()) {
  5784. deque<GroupMemberInfo*>::iterator itr;
  5785. world.GetGroupManager()->GroupLock(__FUNCTION__, __LINE__);
  5786. PlayerGroup* group = world.GetGroupManager()->GetGroup(gmi->group_id);
  5787. if (group)
  5788. {
  5789. group->MGroupMembers.readlock(__FUNCTION__, __LINE__);
  5790. deque<GroupMemberInfo*>* members = group->GetMembers();
  5791. // Loop through the group members
  5792. for (itr = members->begin(); itr != members->end(); itr++) {
  5793. // If a group member matches a target
  5794. if ((*itr)->member && (*itr)->member == client->GetPlayer()->GetTarget()) {
  5795. // toggle the flag and break the loop
  5796. targetInGroup = true;
  5797. break;
  5798. }
  5799. }
  5800. group->MGroupMembers.releasereadlock(__FUNCTION__, __LINE__);
  5801. }
  5802. world.GetGroupManager()->ReleaseGroupLock(__FUNCTION__, __LINE__);
  5803. }
  5804. if (targetInGroup) {
  5805. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  5806. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You start to follow %s.", client->GetPlayer()->GetTarget()->GetName());
  5807. client->GetPlayer()->SetFollowTarget(client->GetPlayer()->GetTarget());
  5808. client->GetPlayer()->info_changed = true;
  5809. client->GetPlayer()->changed = true;
  5810. }
  5811. else
  5812. client->Message(CHANNEL_NARRATIVE, "You must first select a group member to follow.");
  5813. }
  5814. /*
  5815. Function: Command_StopFollow()
  5816. Purpose : Handle the /stop_follow command - not yet implemented
  5817. Params :
  5818. Dev :
  5819. Example :
  5820. */
  5821. void Commands::Command_StopFollow(Client* client, Seperator* sep)
  5822. {
  5823. PrintSep(sep, "COMMAND_STOP_FOLLOW");
  5824. if (client->GetPlayer()->GetFollowTarget()) {
  5825. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  5826. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You are no longer following %s", client->GetPlayer()->GetFollowTarget()->GetName());
  5827. client->GetPlayer()->SetFollowTarget(0);
  5828. client->GetPlayer()->info_changed = true;
  5829. client->GetPlayer()->changed = true;
  5830. }
  5831. }
  5832. /*
  5833. Function: Command_Grid()
  5834. Purpose : Show player's current Grid ID
  5835. Params :
  5836. Dev : Scatman
  5837. Example : /grid
  5838. */
  5839. void Commands::Command_Grid(Client* client, Seperator* sep)
  5840. {
  5841. if (client->GetPlayer()->GetMap() != nullptr) {
  5842. if(sep && sep->arg[0][0] && strncasecmp("spawns", sep->arg[0], 6) == 0) {
  5843. int32 grid = client->GetPlayer()->GetLocation();
  5844. if(sep->IsNumber(1))
  5845. grid = atoul(sep->arg[1]);
  5846. std::vector<Spawn*> spawns = client->GetPlayer()->GetZone()->GetSpawnsInGrid(grid);
  5847. client->Message(CHANNEL_COLOR_RED, "Grid ID %u has %u spawns.", grid, spawns.size());
  5848. for(int i=0;i<spawns.size();i++) {
  5849. Spawn* spawn = spawns.at(i);
  5850. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %s (%u), Loc X/Y/Z: %f/%f/%f.", spawn->GetName(), spawn->GetID(), spawn->GetX(), spawn->GetY(), spawn->GetZ());
  5851. }
  5852. }
  5853. else {
  5854. client->Message(CHANNEL_COLOR_YELLOW, "Your Grid ID is %u", client->GetPlayer()->appearance.pos.grid_id);
  5855. auto loc = glm::vec3(client->GetPlayer()->GetX(), client->GetPlayer()->GetZ(), client->GetPlayer()->GetY());
  5856. uint32 GridID = 0;
  5857. uint32 WidgetID = 0;
  5858. float new_z = client->GetPlayer()->GetMap()->FindBestZ(loc, nullptr, &GridID, &WidgetID);
  5859. float minY = client->GetPlayer()->GetMap()->GetMinY();
  5860. float maxY = client->GetPlayer()->GetMap()->GetMaxY();
  5861. float minZ = client->GetPlayer()->GetMap()->GetMinZ();
  5862. float maxZ = client->GetPlayer()->GetMap()->GetMaxZ();
  5863. int32 grid_spawn_count = client->GetPlayer()->GetZone()->GetSpawnCountInGrid(GridID);
  5864. 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);
  5865. }
  5866. }
  5867. }
  5868. /*
  5869. Function: Command_Guild()
  5870. Purpose : Handler for all UI-related guild commands
  5871. Dev : Scatman
  5872. */
  5873. void Commands::Command_Guild(Client* client, Seperator* sep)
  5874. {
  5875. Guild* guild = client->GetPlayer()->GetGuild();
  5876. if (sep && sep->GetMaxArgNum() > 0 && sep->arg[0])
  5877. {
  5878. const char* command = sep->arg[0];
  5879. int32 length = strlen(command);
  5880. LogWrite(COMMAND__DEBUG, 0, "Command", "Guild Command: %s", command);
  5881. if (strncmp(command, "rank_name", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && guild)
  5882. guild->SetRankName(atoi(sep->arg[1]), sep->argplus[2]);
  5883. else if (strncmp(command, "rank_permission", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  5884. guild->SetPermission(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  5885. else if (strncmp(command, "filter_event", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  5886. guild->SetEventFilter(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  5887. else if (strncmp(command, "kick", length) == 0 && sep->arg[1] && guild)
  5888. guild->KickGuildMember(client, sep->arg[1]);
  5889. else if (strncmp(command, "demote", length) == 0 && sep->arg[1] && guild)
  5890. guild->DemoteGuildMember(client, sep->arg[1]);
  5891. else if (strncmp(command, "promote", length) == 0 && sep->arg[1] && guild)
  5892. guild->PromoteGuildMember(client, sep->arg[1]);
  5893. else if (strncmp(command, "points", length) == 0 && guild)
  5894. {
  5895. if (sep->arg[1] && strncmp(sep->arg[1], "add", length) == 0)
  5896. {
  5897. if (sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  5898. {
  5899. float points = atof(sep->arg[2]);
  5900. const char* option = sep->arg[3];
  5901. const char* comment = sep->argplus[4];
  5902. if (strncmp(option, "all", strlen(option)) == 0)
  5903. guild->AddPointsToAll(client, points, comment);
  5904. else if (strncmp(option, "online", strlen(option)) == 0)
  5905. guild->AddPointsToAllOnline(client, points, comment);
  5906. else if (strncmp(option, "group", strlen(option)) == 0)
  5907. guild->AddPointsToGroup(client, points, comment);
  5908. else if (strncmp(option, "raid", strlen(option)) == 0)
  5909. guild->AddPointsToRaid(client, points, comment);
  5910. else
  5911. guild->AddPointsToGuildMember(client, points, option, comment);
  5912. }
  5913. }
  5914. else if (sep->arg[1] && strncmp(sep->arg[1], "view", strlen(sep->arg[1])) == 0 && sep->arg[2])
  5915. guild->ViewGuildMemberPoints(client, sep->arg[2]);
  5916. else
  5917. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild points command: %s", sep->argplus[0]);
  5918. }
  5919. else if (strncmp(command, "motd", length) == 0 && sep->arg[1] && guild)
  5920. guild->SetMOTD(sep->argplus[1]);
  5921. else if (strncmp(command, "recruiting", length) == 0 && guild)
  5922. {
  5923. if (sep->arg[1])
  5924. {
  5925. const char* option = sep->arg[1];
  5926. if (strncmp(option, "short_text", strlen(option)) == 0 && sep->arg[2])
  5927. guild->SetRecruitingShortDesc(sep->argplus[2]);
  5928. else if (strncmp(option, "long_text", strlen(option)) == 0 && sep->arg[2])
  5929. guild->SetRecruitingFullDesc(sep->argplus[2]);
  5930. else if (strncmp(option, "flag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  5931. guild->SetRecruitingFlag(atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  5932. else if (strncmp(option, "min_level", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  5933. guild->SetRecruitingMinLevel(atoi(sep->arg[2]));
  5934. else if (strncmp(option, "playstyle", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  5935. guild->SetRecruitingPlayStyle(atoi(sep->arg[2]));
  5936. else if (strncmp(option, "tag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && sep->IsNumber(3))
  5937. guild->SetRecruitingDescTag(atoi(sep->arg[2]), atoi(sep->arg[3]));
  5938. else if (strncmp(command, "recruiting", strlen(option)) == 0)
  5939. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_RECRUITING_FOR_GUILD, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  5940. else
  5941. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  5942. }
  5943. else
  5944. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  5945. }
  5946. else if (strncmp(command, "notify_online", length) == 0 && sep->arg[1] && guild)
  5947. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_NOTIFY_LOGINS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  5948. else if (strncmp(command, "event_privacy", length) == 0 && sep->arg[1] && guild)
  5949. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_DONT_GENERATE_EVENTS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  5950. else if (strncmp(command, "recruiter", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  5951. guild->SetGuildRecruiter(client, sep->arg[1], strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  5952. else if (strncmp(command, "recruiter_description", length) == 0 && sep->arg[1] && guild)
  5953. guild->SetGuildRecruiterDescription(client, sep->argplus[1]);
  5954. else if (strncmp(command, "lock_event", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  5955. guild->LockGuildEvent(atoul(sep->arg[1]), strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  5956. else if (strncmp(command, "delete_event", length) == 0 && sep->arg[1] && guild)
  5957. guild->DeleteGuildEvent(atoul(sep->arg[1]));
  5958. else if (strncmp(command, "invite", length) == 0 && guild)
  5959. {
  5960. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  5961. guild->InvitePlayer(client, sep->arg[1]);
  5962. else
  5963. {
  5964. Spawn* target = client->GetPlayer()->GetTarget();
  5965. if (target)
  5966. {
  5967. if (target->IsPlayer())
  5968. guild->InvitePlayer(client, target->GetName());
  5969. else
  5970. client->Message(CHANNEL_NARRATIVE, "%s is not a player.", target->GetName());
  5971. }
  5972. }
  5973. }
  5974. else if (strncmp(command, "accept", length) == 0)
  5975. {
  5976. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  5977. if (pgi && pgi->guild && pgi->invited_by)
  5978. pgi->guild->AddNewGuildMember(client, pgi->invited_by->GetName());
  5979. client->SetPendingGuildInvite(0);
  5980. }
  5981. else if (strncmp(command, "decline", length) == 0)
  5982. {
  5983. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  5984. if (pgi && pgi->guild && pgi->invited_by)
  5985. {
  5986. Client* client_inviter = pgi->invited_by->GetZone()->GetClientBySpawn(pgi->invited_by);
  5987. if (client_inviter)
  5988. client_inviter->Message(CHANNEL_NARRATIVE, "%s has declined your invitation to join %s.", client->GetPlayer()->GetName(), pgi->guild->GetName());
  5989. }
  5990. client->SetPendingGuildInvite(0);
  5991. }
  5992. else if (strncmp(command, "create", length) == 0 && sep->arg[1])
  5993. {
  5994. const char* guild_name = sep->argplus[1];
  5995. if (!guild_list.GetGuild(guild_name))
  5996. world.CreateGuild(guild_name, client, client->GetPlayer()->GetGroupMemberInfo() ? client->GetPlayer()->GetGroupMemberInfo()->group_id : 0);
  5997. else
  5998. client->SimpleMessage(CHANNEL_NARRATIVE, "A guild with that name already exists.");
  5999. }
  6000. else if (strncmp(command, "search", length) == 0)
  6001. client->ShowGuildSearchWindow();
  6002. else if (strncmp(command, "recruiting_details", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  6003. {
  6004. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  6005. if (to_guild)
  6006. to_guild->SendGuildRecruitingDetails(client);
  6007. }
  6008. else if (strncmp(command, "recruiting_image", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  6009. {
  6010. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  6011. if (to_guild)
  6012. to_guild->SendGuildRecruitingImages(client);
  6013. }
  6014. else if (strncmp(command, "recruiter_adventure_class", length) == 0)
  6015. {
  6016. if (sep->arg[1])
  6017. {
  6018. const char* option = sep->arg[1];
  6019. if (strncmp(option, "toggle", strlen(option)) == 0)
  6020. guild->ToggleGuildRecruiterAdventureClass(client);
  6021. }
  6022. else
  6023. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiter_adventure_class command: '%s'", sep->argplus[0]);
  6024. }
  6025. else if (strncmp(command, "display_heraldry", length) == 0)
  6026. {
  6027. // JA: not sure this is right...
  6028. client->GetPlayer()->toggle_character_flag(CF_SHOW_GUILD_HERALDRY);
  6029. client->GetPlayer()->SetCharSheetChanged(true);
  6030. }
  6031. else
  6032. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild command: '%s'", sep->argplus[0]);
  6033. }
  6034. }
  6035. /*
  6036. Function: Command_GuildCreate()
  6037. Purpose : Display's in-game Guild Creation window
  6038. Dev : Scatman
  6039. */
  6040. void Commands::Command_CreateGuild(Client* client)
  6041. {
  6042. client->SendGuildCreateWindow();
  6043. }
  6044. /*
  6045. Function: Command_SetGuildOfficerNote()
  6046. Purpose :
  6047. Dev : Scatman
  6048. */
  6049. void Commands::Command_SetGuildOfficerNote(Client* client, Seperator* sep)
  6050. {
  6051. if (sep && sep->arg[0] && sep->arg[1])
  6052. {
  6053. Guild* guild = client->GetPlayer()->GetGuild();
  6054. if (guild)
  6055. guild->SetGuildOfficerNote(sep->arg[0], sep->argplus[1]);
  6056. }
  6057. }
  6058. /*
  6059. Function: Command_SetGuildMemberNote()
  6060. Purpose :
  6061. Dev : Scatman
  6062. */
  6063. void Commands::Command_SetGuildMemberNote(Client* client, Seperator* sep)
  6064. {
  6065. if (sep && sep->arg[0] && sep->arg[1])
  6066. {
  6067. Guild* guild = client->GetPlayer()->GetGuild();
  6068. if (guild)
  6069. guild->SetGuildMemberNote(sep->arg[0], sep->argplus[1]);
  6070. }
  6071. }
  6072. /*
  6073. Function: Command_GuildSay()
  6074. Purpose :
  6075. Dev : Scatman
  6076. */
  6077. void Commands::Command_GuildSay(Client* client, Seperator* sep)
  6078. {
  6079. Guild* guild = client->GetPlayer()->GetGuild();
  6080. if (guild)
  6081. {
  6082. if (sep && sep->arg[0])
  6083. guild->HandleGuildSay(client, sep->argplus[0]);
  6084. }
  6085. else
  6086. client->SimpleMessage(CHANNEL_NARRATIVE, "You are not a member of a guild");
  6087. }
  6088. /*
  6089. Function: Command_OfficerSay()
  6090. Purpose :
  6091. Dev : Scatman
  6092. */
  6093. void Commands::Command_OfficerSay(Client* client, Seperator* sep)
  6094. {
  6095. Guild* guild = client->GetPlayer()->GetGuild();
  6096. if (guild)
  6097. {
  6098. if (sep && sep->arg[0])
  6099. guild->HandleOfficerSay(client, sep->argplus[0]);
  6100. }
  6101. else
  6102. client->SimpleMessage(CHANNEL_NARRATIVE, "You are not a member of a guild");
  6103. }
  6104. /*
  6105. Function: Command_Guilds()
  6106. Purpose : Shows help for /guild command
  6107. Params :
  6108. Dev : Scatman
  6109. Example :
  6110. */
  6111. void Commands::Command_Guilds(Client* client)
  6112. {
  6113. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds [create|delete|add|remove|list]");
  6114. }
  6115. /*
  6116. Function: Command_GuildsAdd()
  6117. Purpose : Add's players to a guild
  6118. Params : guild_name|guild_id, player name
  6119. Dev : Scatman
  6120. Example : /guilds add 1 Admin = adds player Admin to guild_id 1
  6121. */
  6122. void Commands::Command_GuildsAdd(Client* client, Seperator* sep)
  6123. {
  6124. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  6125. {
  6126. Guild* guild = 0;
  6127. bool found = true;
  6128. if (sep->IsNumber(0))
  6129. {
  6130. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  6131. if (!guild)
  6132. {
  6133. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  6134. found = false;
  6135. }
  6136. }
  6137. else
  6138. {
  6139. guild = guild_list.GetGuild(sep->arg[0]);
  6140. if (!guild)
  6141. {
  6142. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  6143. found = false;
  6144. }
  6145. }
  6146. if (found)
  6147. {
  6148. Client* to_client = 0;
  6149. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  6150. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  6151. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  6152. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  6153. if (to_client)
  6154. guild->InvitePlayer(client, to_client->GetPlayer()->GetName());
  6155. else
  6156. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  6157. }
  6158. }
  6159. else
  6160. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds add [guild name|guild id] (player name).");
  6161. }
  6162. /*
  6163. Function: Command_GuildsCreate()
  6164. Purpose : Creates a guild
  6165. Params : guild_name, player_name (optional)
  6166. Dev : Scatman
  6167. Example : /guilds create [guild name] (player name)
  6168. */
  6169. void Commands::Command_GuildsCreate(Client* client, Seperator* sep)
  6170. {
  6171. if (sep && sep->arg[0])
  6172. {
  6173. const char* guild_name = sep->arg[0];
  6174. if (!guild_list.GetGuild(guild_name))
  6175. {
  6176. bool ret = false;
  6177. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  6178. {
  6179. Client* to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  6180. if (to_client)
  6181. {
  6182. world.CreateGuild(guild_name, to_client);
  6183. ret = true;
  6184. }
  6185. else
  6186. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player with name '%s'", sep->arg[1]);
  6187. }
  6188. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  6189. {
  6190. Client* to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  6191. if (to_client)
  6192. {
  6193. world.CreateGuild(guild_name, to_client);
  6194. ret = true;
  6195. }
  6196. }
  6197. else
  6198. {
  6199. world.CreateGuild(guild_name);
  6200. ret = true;
  6201. }
  6202. if (ret)
  6203. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully created.", guild_name);
  6204. else
  6205. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the guild.");
  6206. }
  6207. else
  6208. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' already exists.", guild_name);
  6209. }
  6210. else
  6211. 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.");
  6212. }
  6213. /*
  6214. Function: Command_GuildsDelete()
  6215. Purpose : Delete's a guild
  6216. Params : guild name
  6217. Dev : Scatman
  6218. Example : /guilds delete Test
  6219. */
  6220. void Commands::Command_GuildsDelete(Client* client, Seperator* sep)
  6221. {
  6222. if (sep && sep->arg[0])
  6223. {
  6224. Guild* guild = 0;
  6225. bool found = true;
  6226. if (sep->IsNumber(0))
  6227. {
  6228. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  6229. if (!guild)
  6230. {
  6231. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  6232. found = false;
  6233. }
  6234. }
  6235. else
  6236. {
  6237. guild = guild_list.GetGuild(sep->arg[0]);
  6238. if (!guild)
  6239. {
  6240. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  6241. found = false;
  6242. }
  6243. }
  6244. if (found)
  6245. {
  6246. guild->RemoveAllGuildMembers();
  6247. database.DeleteGuild(guild);
  6248. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully deleted.", guild->GetName());
  6249. guild_list.RemoveGuild(guild, true);
  6250. }
  6251. }
  6252. else
  6253. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds delete [guild name].");
  6254. }
  6255. /*
  6256. Function: Command_GuildsList()
  6257. Purpose : Lists current guilds on server
  6258. Params :
  6259. Dev : Scatman
  6260. Example : /guilds list
  6261. */
  6262. void Commands::Command_GuildsList(Client* client)
  6263. {
  6264. MutexMap<int32, Guild*>* guilds = guild_list.GetGuilds();
  6265. MutexMap<int32, Guild*>::iterator itr = guilds->begin();
  6266. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Guild List:");
  6267. if (guilds->size() == 0)
  6268. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "None.");
  6269. else {
  6270. while (itr.Next()) {
  6271. Guild* guild = itr.second;
  6272. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", guild->GetID(), guild->GetName());
  6273. }
  6274. }
  6275. }
  6276. /*
  6277. Function: Command_GuildsRemove()
  6278. Purpose : Removes a player from a guild
  6279. Params : guild name|guild id, player name
  6280. Dev : Scatman
  6281. Example : /guilds remove 1 Admin = removes Admin from guild 1
  6282. */
  6283. void Commands::Command_GuildsRemove(Client* client, Seperator* sep)
  6284. {
  6285. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  6286. {
  6287. Guild* guild = 0;
  6288. bool found = true;
  6289. if (sep->IsNumber(0))
  6290. {
  6291. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  6292. if (!guild)
  6293. {
  6294. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  6295. found = false;
  6296. }
  6297. }
  6298. else
  6299. {
  6300. guild = guild_list.GetGuild(sep->arg[0]);
  6301. if (!guild)
  6302. {
  6303. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  6304. found = false;
  6305. }
  6306. }
  6307. if (found)
  6308. {
  6309. Client* to_client = 0;
  6310. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  6311. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  6312. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  6313. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  6314. if (to_client)
  6315. {
  6316. Player* to_player = to_client->GetPlayer();
  6317. if (to_player->GetGuild())
  6318. {
  6319. if (to_player->GetGuild() == guild)
  6320. {
  6321. guild->KickGuildMember(client, to_player->GetName());
  6322. }
  6323. else
  6324. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in the guild '%s'.", to_player->GetName(), guild->GetName());
  6325. }
  6326. else
  6327. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in a guild.", to_player->GetName());
  6328. }
  6329. else
  6330. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  6331. }
  6332. }
  6333. else
  6334. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds remove [guild name|guild id] (player name).");
  6335. }
  6336. /*
  6337. Function: Command_InspectPlayer()
  6338. Purpose : Handle the Inspect functions
  6339. Params : Client to inspect
  6340. Dev : Scatman
  6341. Example : /inspect Scatman
  6342. */
  6343. void Commands::Command_InspectPlayer(Client* client, Seperator* sep)
  6344. {
  6345. if (sep && sep->arg[0])
  6346. {
  6347. Client* inspect_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  6348. if (inspect_client)
  6349. client->InspectPlayer(inspect_client->GetPlayer());
  6350. }
  6351. else
  6352. {
  6353. Spawn* target = client->GetPlayer()->GetTarget();
  6354. if (target && target->IsPlayer())
  6355. client->InspectPlayer((Player*)target);
  6356. }
  6357. }
  6358. /*
  6359. Function: Command_Inventory()
  6360. Purpose : Handle changes in player inventory
  6361. Params : <TBD>
  6362. Dev : All
  6363. Example : /inventory delete item_id
  6364. */
  6365. void Commands::Command_Inventory(Client* client, Seperator* sep, EQ2_RemoteCommandString* command)
  6366. {
  6367. PrintSep(sep, "Command_Inventory"); // temp to figure out the params
  6368. Player* player = client->GetPlayer();
  6369. if(sep && sep->arg[0][0])
  6370. {
  6371. LogWrite(COMMAND__INFO, 0, "Command", "command: %s", sep->argplus[0]);
  6372. if(client->GetPlayer()->GetHP() == 0)
  6373. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  6374. else if(sep->arg[1][0] && strncasecmp("destroy", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  6375. {
  6376. int16 index = atoi(sep->arg[1]);
  6377. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  6378. if(item)
  6379. {
  6380. if(item->details.item_locked) {
  6381. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot destroy the item in use.");
  6382. return;
  6383. }
  6384. else if(item->CheckFlag(NO_DESTROY)) {
  6385. client->SimpleMessage(CHANNEL_COLOR_RED, "You can't destroy this item.");
  6386. return;
  6387. }
  6388. if(item->GetItemScript() && lua_interface)
  6389. lua_interface->RunItemScript(item->GetItemScript(), "destroyed", item, client->GetPlayer());
  6390. //reobtain item make sure it wasn't removed
  6391. item = player->item_list.GetItemFromIndex(index);
  6392. int32 bag_id = 0;
  6393. if(item){
  6394. bag_id = item->details.inv_slot_id;
  6395. database.DeleteItem(client->GetCharacterID(), item, 0);
  6396. }
  6397. client->GetPlayer()->item_list.DestroyItem(index);
  6398. client->GetPlayer()->UpdateInventory(bag_id);
  6399. }
  6400. }
  6401. 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))
  6402. {
  6403. int16 from_index = atoi(sep->arg[1]);
  6404. sint16 to_slot = atoi(sep->arg[2]);
  6405. sint32 bag_id = atol(sep->arg[3]);
  6406. int8 charges = atoi(sep->arg[4]);
  6407. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(from_index);
  6408. if(!item) {
  6409. client->SimpleMessage(CHANNEL_COLOR_RED, "You have no item.");
  6410. return;
  6411. }
  6412. if(to_slot == item->details.slot_id && (bag_id < 0 || bag_id == item->details.inv_slot_id)) {
  6413. return;
  6414. }
  6415. if(item->details.item_locked)
  6416. {
  6417. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot move the item in use.");
  6418. return;
  6419. }
  6420. if(bag_id == -4 && !client->GetPlayer()->item_list.SharedBankAddAllowed(item))
  6421. {
  6422. client->SimpleMessage(CHANNEL_COLOR_RED, "That item (or an item inside) cannot be shared.");
  6423. return;
  6424. }
  6425. sint32 old_inventory_id = 0;
  6426. if(item)
  6427. old_inventory_id = item->details.inv_slot_id;
  6428. //autobank
  6429. if (bag_id == -3 && to_slot == -1)
  6430. {
  6431. if (player->HasFreeBankSlot())
  6432. to_slot = player->FindFreeBankSlot();
  6433. else
  6434. {
  6435. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free bank slots.");
  6436. return;
  6437. }
  6438. }
  6439. //auto inventory
  6440. if (bag_id == 0 && to_slot == -1)
  6441. {
  6442. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  6443. {
  6444. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free slots.");
  6445. return;
  6446. }
  6447. }
  6448. bool item_deleted = false;
  6449. EQ2Packet* outapp = client->GetPlayer()->MoveInventoryItem(bag_id, from_index, (int8)to_slot, charges, 0, &item_deleted, client->GetVersion());
  6450. client->QueuePacket(outapp);
  6451. if(item_deleted)
  6452. item = nullptr;
  6453. //removed from bag send update
  6454. if(old_inventory_id > 0 && item && item->details.inv_slot_id != old_inventory_id)
  6455. {
  6456. outapp = client->GetPlayer()->SendBagUpdate(old_inventory_id, client->GetVersion());
  6457. if(outapp)
  6458. client->QueuePacket(outapp);
  6459. }
  6460. if(item && item->details.inv_slot_id > 0 && item->details.inv_slot_id != old_inventory_id)
  6461. {
  6462. outapp = client->GetPlayer()->SendBagUpdate(item->details.inv_slot_id, client->GetVersion());
  6463. if(outapp)
  6464. client->QueuePacket(outapp);
  6465. }
  6466. }
  6467. else if(sep->arg[1][0] && strncasecmp("equip", sep->arg[0], 5) == 0 && sep->IsNumber(1))
  6468. {
  6469. if(client->GetPlayer()->EngagedInCombat())
  6470. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not equip items while in combat.");
  6471. else
  6472. {
  6473. int16 index = atoi(sep->arg[1]);
  6474. int8 slot_id = 255;
  6475. int8 unk3 = 0;
  6476. int8 appearance_equip = 0;
  6477. if(sep->arg[2][0] && sep->IsNumber(2))
  6478. slot_id = atoi(sep->arg[2]);
  6479. if(sep->arg[3][0] && sep->IsNumber(3))
  6480. unk3 = atoul(sep->arg[3]);
  6481. if(sep->arg[4][0] && sep->IsNumber(4))
  6482. appearance_equip = atoul(sep->arg[4]);
  6483. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), appearance_equip, slot_id);
  6484. EQ2Packet* outapp = 0;
  6485. for(int32 i=0;i<packets.size();i++)
  6486. {
  6487. outapp = packets[i];
  6488. if(outapp)
  6489. client->QueuePacket(outapp);
  6490. }
  6491. client->GetPlayer()->ChangePrimaryWeapon();
  6492. client->GetPlayer()->ChangeSecondaryWeapon();
  6493. client->GetPlayer()->ChangeRangedWeapon();
  6494. EQ2Packet* characterSheetPackets = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion());
  6495. client->QueuePacket(characterSheetPackets);
  6496. }
  6497. }
  6498. else if (sep->arg[1][0] && strncasecmp("unpack", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  6499. {
  6500. if (client->GetPlayer()->EngagedInCombat())
  6501. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unpack items while in combat.");
  6502. else {
  6503. int16 index = atoi(sep->arg[1]);
  6504. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  6505. if (item) {
  6506. if(item->details.item_locked)
  6507. {
  6508. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot unpack the item in use.");
  6509. return;
  6510. }
  6511. // client->GetPlayer()->item_list.DestroyItem(index);
  6512. if (item->item_sets.size() > 0) {
  6513. for (int32 i = 0; i < item->item_sets.size(); i++) {
  6514. ItemSet* set = item->item_sets[i];
  6515. if (set->item_stack_size == 0)
  6516. set->item_stack_size += 1;
  6517. client->AddItem(set->item_id, set->item_stack_size);
  6518. }
  6519. }
  6520. }
  6521. client->RemoveItem(item, 1);
  6522. }
  6523. }
  6524. else if(sep->arg[1][0] && strncasecmp("unequip", sep->arg[0], 7) == 0 && sep->IsNumber(1))
  6525. {
  6526. if(client->GetPlayer()->EngagedInCombat())
  6527. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unequip items while in combat.");
  6528. else
  6529. {
  6530. int16 index = atoi(sep->arg[1]);
  6531. sint32 bag_id = -999;
  6532. int8 to_slot = 255;
  6533. if(sep->arg[3][0])
  6534. {
  6535. if(sep->IsNumber(2))
  6536. bag_id = atol(sep->arg[2]);
  6537. if(sep->IsNumber(3))
  6538. to_slot = atoi(sep->arg[3]);
  6539. }
  6540. sint8 unk4 = 0;
  6541. int8 appearance_equip = 0;
  6542. if(sep->arg[4][0] && sep->IsNumber(4))
  6543. unk4 = atoi(sep->arg[4]);
  6544. if(sep->arg[5][0] && sep->IsNumber(5))
  6545. appearance_equip = atoul(sep->arg[5]);
  6546. vector<EQ2Packet*> packets = client->GetPlayer()->UnequipItem(index, bag_id, to_slot, client->GetVersion(), appearance_equip);
  6547. EQ2Packet* outapp = 0;
  6548. for(int32 i=0;i<packets.size();i++)
  6549. {
  6550. outapp = packets[i];
  6551. if(outapp)
  6552. client->QueuePacket(outapp);
  6553. }
  6554. client->UnequipItem(index, bag_id, to_slot, appearance_equip);
  6555. }
  6556. }
  6557. else if(sep->arg[2][0] && strncasecmp("swap_equip", sep->arg[0], 10) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  6558. {
  6559. if(client->GetPlayer()->EngagedInCombat()) {
  6560. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not swap items while in combat.");
  6561. }
  6562. else {
  6563. int16 index1 = atoi(sep->arg[1]);
  6564. int16 index2 = atoi(sep->arg[2]);
  6565. int8 type = 0;
  6566. if(sep->IsNumber(3))
  6567. type = atoul(sep->arg[3]); // type 0 is combat, 3 = appearance
  6568. EQ2Packet* outapp = client->GetPlayer()->SwapEquippedItems(index1, index2, client->GetVersion(), type);
  6569. if(outapp)
  6570. client->QueuePacket(outapp);
  6571. else
  6572. {
  6573. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to swap items");
  6574. return;
  6575. }
  6576. }
  6577. }
  6578. else if (sep->arg[2][0] && strncasecmp("pop", sep->arg[0], 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  6579. {
  6580. sint16 to_slot = atoi(sep->arg[1]);
  6581. sint32 bag_id = atoi(sep->arg[2]);
  6582. Item* item = client->GetPlayer()->item_list.GetOverflowItem();
  6583. if (item) {
  6584. //auto inventory
  6585. if (bag_id == 0 && to_slot == -1)
  6586. {
  6587. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  6588. {
  6589. client->SimpleMessage(CHANNEL_ERROR, "You do not have any free slots.");
  6590. return;
  6591. }
  6592. // Set the slot for the item
  6593. item->details.inv_slot_id = bag_id;
  6594. item->details.slot_id = to_slot;
  6595. // Flag the item so it gets saved in its new location
  6596. item->save_needed = true;
  6597. // Add the item to its new location
  6598. if(player->item_list.AddItem(item)) {
  6599. // Remove the item from the overflow list
  6600. player->item_list.RemoveOverflowItem(item);
  6601. }
  6602. // Send the inventory update packet
  6603. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  6604. return;
  6605. }
  6606. else if (bag_id == -3 && to_slot == -1) {
  6607. // Auto Bank
  6608. if (!player->item_list.GetFirstFreeBankSlot(&bag_id, &to_slot)) {
  6609. client->SimpleMessage(CHANNEL_STATUS, "You do not have any free bank slots.");
  6610. return;
  6611. }
  6612. item->details.inv_slot_id = bag_id;
  6613. item->details.slot_id = to_slot;
  6614. item->save_needed = true;
  6615. if(player->item_list.AddItem(item)) {
  6616. player->item_list.RemoveOverflowItem(item);
  6617. }
  6618. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  6619. }
  6620. else if (bag_id == -4) {
  6621. // Shared Bank
  6622. if (!player->item_list.SharedBankAddAllowed(item)) {
  6623. client->SimpleMessage(CHANNEL_STATUS, "That item (or an item inside) cannot be shared.");
  6624. return;
  6625. }
  6626. Item* tmp_item = player->item_list.GetItem(-4, to_slot);
  6627. if (tmp_item) {
  6628. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  6629. return;
  6630. }
  6631. else {
  6632. item->details.inv_slot_id = bag_id;
  6633. item->details.slot_id = to_slot;
  6634. item->save_needed = true;
  6635. if(player->item_list.AddItem(item)) {
  6636. player->item_list.RemoveOverflowItem(item);
  6637. }
  6638. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  6639. return;
  6640. }
  6641. }
  6642. else {
  6643. // Try to get an item from the given bag id and slot id
  6644. Item* tmp_item = player->item_list.GetItem(bag_id, to_slot);
  6645. // Check to see if we got an item, if we do send an error,
  6646. // if we don't put the overflow item into this slot
  6647. if (tmp_item) {
  6648. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  6649. }
  6650. else {
  6651. item->details.inv_slot_id = bag_id;
  6652. item->details.slot_id = to_slot;
  6653. item->save_needed = true;
  6654. if(player->item_list.AddItem(item)) {
  6655. player->item_list.RemoveOverflowItem(item);
  6656. }
  6657. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  6658. return;
  6659. }
  6660. }
  6661. }
  6662. }
  6663. else if(sep->arg[2][0] && strncasecmp("nosale", sep->arg[0], 6) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  6664. {
  6665. sint64 data = strtoull(sep->arg[1], NULL, 0);
  6666. int32 character_item_id = (int32) (data >> 32);
  6667. int32 item_id = (int32) (data & 0xffffffffL);
  6668. int8 sale_setting = atoi(sep->arg[2]);
  6669. Item* item = client->GetPlayer()->item_list.GetItemFromUniqueID(character_item_id);
  6670. if(item)
  6671. {
  6672. item->no_sale = sale_setting;
  6673. item->save_needed = true;
  6674. client->SendSellMerchantList();
  6675. }
  6676. }
  6677. }
  6678. else
  6679. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /inventory {destroy|move|equip|unequip|swap_equip|pop} {item_id} [to_slot] [bag_id]");
  6680. }
  6681. /*
  6682. Function: Command_Languages()
  6683. Purpose : Show's languages the player knows
  6684. Params :
  6685. Dev : Zcoretri
  6686. Example :
  6687. */
  6688. void Commands::Command_Languages(Client* client, Seperator* sep)
  6689. {
  6690. list<Language*>* languages = client->GetPlayer()->GetPlayerLanguages()->GetAllLanguages();
  6691. list<Language*>::iterator itr;
  6692. Language* language;
  6693. client->Message(CHANNEL_NARRATIVE, "You know the following languages:");
  6694. for(itr = languages->begin(); itr != languages->end(); itr++)
  6695. {
  6696. language = *itr;
  6697. client->Message(CHANNEL_NARRATIVE, "%s", language->GetName());
  6698. }
  6699. }
  6700. /*
  6701. Function: Command_SetLanguage()
  6702. Purpose : Handles language commands
  6703. Params : Language ID
  6704. Dev : Zcoretri
  6705. Example :
  6706. */
  6707. void Commands::Command_SetLanguage(Client* client, Seperator* sep)
  6708. {
  6709. Player* player = client->GetPlayer();
  6710. if (sep && sep->arg[0])
  6711. {
  6712. if(!sep->IsNumber(0))
  6713. {
  6714. //String passed in
  6715. const char* value = sep->arg[0];
  6716. if(strncasecmp(value, "Common", strlen(value)) == 0)
  6717. {
  6718. database.SaveCharacterCurrentLang(0, client->GetCharacterID(), client);
  6719. client->SendLanguagesUpdate(0);
  6720. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", value);
  6721. }
  6722. else
  6723. {
  6724. if(player->HasLanguage(value))
  6725. {
  6726. Language* language = player->GetPlayerLanguages()->GetLanguageByName(value);
  6727. database.SaveCharacterCurrentLang(language->GetID(), client->GetCharacterID(), client);
  6728. client->SendLanguagesUpdate(language->GetID());
  6729. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", language->GetName());
  6730. }
  6731. else
  6732. client->Message(CHANNEL_NARRATIVE, "You do not know how to speak %s", value);
  6733. }
  6734. }
  6735. else
  6736. {
  6737. //Number passed in
  6738. int32 id = atoul(sep->arg[0]);
  6739. if(player->HasLanguage(id))
  6740. {
  6741. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  6742. database.SaveCharacterCurrentLang(id, client->GetCharacterID(), client);
  6743. client->SendLanguagesUpdate(id);
  6744. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", language->GetName());
  6745. }
  6746. else
  6747. {
  6748. Language* language = master_languages_list.GetLanguage(id);
  6749. if(language)
  6750. client->Message(CHANNEL_NARRATIVE, "You do not know how to speak %s", language->GetName());
  6751. }
  6752. }
  6753. }
  6754. else
  6755. {
  6756. //No value was passed in
  6757. int32 id = database.GetCharacterCurrentLang(client->GetCharacterID(), player);
  6758. if(id > 0)
  6759. {
  6760. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  6761. client->Message(CHANNEL_NARRATIVE, "You are currently speaking %s ", language->GetName());
  6762. }
  6763. else
  6764. client->Message(CHANNEL_NARRATIVE, "You are currently speaking Common");
  6765. }
  6766. }
  6767. /*
  6768. Function: Command_LastName()
  6769. Purpose : Sets player surname
  6770. Params : Name text
  6771. Dev : theFoof
  6772. Example :
  6773. */
  6774. void Commands::Command_LastName(Client* client, Seperator* sep)
  6775. {
  6776. if (!client)
  6777. return;
  6778. if (sep && sep->arg[0])
  6779. {
  6780. if (!client->GetPlayer()->get_character_flag(CF_ENABLE_CHANGE_LASTNAME)){
  6781. client->Message(CHANNEL_COLOR_YELLOW, "You must be atleast level %i to change your last name.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  6782. return;
  6783. }
  6784. client->RemovePendingLastName();
  6785. uchar* checkname = (uchar*)sep->arg[0];
  6786. bool valid_name = true;
  6787. for (int32 i = 0; i < strlen(sep->arg[0]); i++) {
  6788. if (!alpha_check(checkname[i])) {
  6789. valid_name = false;
  6790. break;
  6791. }
  6792. }
  6793. if (!valid_name) {
  6794. client->Message(CHANNEL_COLOR_YELLOW, "Your last name can only contain letters.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  6795. return;
  6796. }
  6797. string last_name = (string)sep->arg[0];
  6798. int8 max_length = rule_manager.GetGlobalRule(R_Player, MaxLastNameLength)->GetInt8();
  6799. int8 min_length = rule_manager.GetGlobalRule(R_Player, MinLastNameLength)->GetInt8();
  6800. if (last_name.length() <= max_length && last_name.length() >= min_length){
  6801. client->SetPendingLastName(last_name);
  6802. client->SendLastNameConfirmation();
  6803. }
  6804. else
  6805. client->Message(CHANNEL_COLOR_YELLOW, "Your last name must be between %i and %i characters long.", min_length, max_length);
  6806. }
  6807. }
  6808. /*
  6809. Function: Command_ConfirmLastName()
  6810. Purpose : Confirms setting of player surname
  6811. Params : Name text
  6812. Dev : theFoof
  6813. Example :
  6814. */
  6815. void Commands::Command_ConfirmLastName(Client* client, Seperator* sep)
  6816. {
  6817. if (!client)
  6818. return;
  6819. string* name = client->GetPendingLastName();
  6820. if (name){
  6821. Player* player = client->GetPlayer();
  6822. player->SetLastName(name->c_str(), false);
  6823. client->SendTitleUpdate();
  6824. player->SetCharSheetChanged(true);
  6825. client->RemovePendingLastName();
  6826. }
  6827. }
  6828. /*
  6829. Function: Command_Location()
  6830. Purpose : Display's Help for /location commands
  6831. Params :
  6832. Dev : Scatman
  6833. Example : /location = show's help for command
  6834. */
  6835. void Commands::Command_Location(Client* client)
  6836. {
  6837. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Valid /location commands are:");
  6838. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location create [name] (include y). Include y defaults to false");
  6839. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location add [location id]");
  6840. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location remove [location point id]");
  6841. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location delete [location id]");
  6842. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location list [locations|points] [location id if points used]");
  6843. }
  6844. /*
  6845. Function: Command_LocationAdd()
  6846. Purpose : Add's a location to an existing location config
  6847. Params : location_id
  6848. Dev : Scatman
  6849. Example : /location add {location_id}
  6850. */
  6851. void Commands::Command_LocationAdd(Client* client, Seperator* sep)
  6852. {
  6853. if (sep && sep->arg[0] && sep->IsNumber(0))
  6854. {
  6855. int32 location_id = atoul(sep->arg[0]);
  6856. float x = client->GetPlayer()->GetX();
  6857. float y = client->GetPlayer()->GetY();
  6858. float z = client->GetPlayer()->GetZ();
  6859. if (database.AddLocationPoint(location_id, x, y, z))
  6860. client->Message(CHANNEL_COLOR_YELLOW, "Point (%f, %f, %f) was successfully added to location %u", x, y, z, location_id);
  6861. else
  6862. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist. Use /location create to create one", location_id);
  6863. }
  6864. else
  6865. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location add [location id]");
  6866. }
  6867. /*
  6868. Function: Command_LocationCreate()
  6869. Purpose : Creates a new location config
  6870. Params : location name, 0/1 for include_y (optional)
  6871. Dev : Scatman
  6872. Example : /location create Test 1 = creates a new location named Test with include_y True
  6873. */
  6874. void Commands::Command_LocationCreate(Client* client, Seperator* sep)
  6875. {
  6876. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  6877. {
  6878. const char* name = sep->arg[0];
  6879. bool include_y = false;
  6880. if (sep->arg[1] && sep->IsNumber(1) && atoi(sep->arg[1]) > 0)
  6881. include_y = true;
  6882. int32 location_id = database.CreateLocation(client->GetPlayer()->GetZone()->GetZoneID(), client->GetPlayer()->appearance.pos.grid_id, name, include_y);
  6883. if (location_id > 0)
  6884. client->Message(CHANNEL_COLOR_YELLOW, "Location '%s' was successfully created with location id %u", name, location_id);
  6885. else
  6886. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the requested location");
  6887. }
  6888. else
  6889. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location create [name] (include_y). Include y defaults to false");
  6890. }
  6891. /*
  6892. Function: Command_LocationDelete()
  6893. Purpose : Delete's a location config and all it's location points
  6894. Params : location_id
  6895. Dev : Scatman
  6896. Example : /location delete {location_id}
  6897. */
  6898. void Commands::Command_LocationDelete(Client* client, Seperator* sep)
  6899. {
  6900. if (sep && sep->arg[0] && sep->IsNumber(0))
  6901. {
  6902. int32 location_id = atoul(sep->arg[0]);
  6903. if (database.DeleteLocation(location_id))
  6904. client->Message(CHANNEL_COLOR_YELLOW, "Location id %u and all its points were successfully deleted", location_id);
  6905. else
  6906. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist", location_id);
  6907. }
  6908. else
  6909. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location delete [location id]");
  6910. }
  6911. /*
  6912. Function: Command_LocationList()
  6913. Purpose : Display's a list of location points
  6914. Params : location_id
  6915. Dev : Scatman
  6916. Example : /location list {location_id}
  6917. */
  6918. void Commands::Command_LocationList(Client* client, Seperator* sep)
  6919. {
  6920. if (sep && sep->arg[0])
  6921. {
  6922. const char* option = sep->arg[0];
  6923. if (strncmp(option, "locations", strlen(option)) == 0)
  6924. database.ListLocations(client);
  6925. else if (strncmp(option, "points", strlen(option)) == 0 && sep->arg[1] && sep->IsNumber(1))
  6926. {
  6927. int32 location_id = atoul(sep->arg[1]);
  6928. database.ListLocationPoints(client, location_id);
  6929. }
  6930. else
  6931. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  6932. }
  6933. else
  6934. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  6935. }
  6936. /*
  6937. Function: Command_LocationRemove()
  6938. Purpose : Removes a single location point from a location config
  6939. Params : location_point_id (gotten from /location list {id})
  6940. Dev : Scatman
  6941. Example : /location remove 1 = will remove location_point_id 1
  6942. */
  6943. void Commands::Command_LocationRemove(Client* client, Seperator* sep)
  6944. {
  6945. if (sep && sep->arg[0] && sep->IsNumber(0))
  6946. {
  6947. int32 location_point_id = atoul(sep->arg[0]);
  6948. if (database.DeleteLocationPoint(location_point_id))
  6949. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Location point was successfully deleted");
  6950. else
  6951. client->Message(CHANNEL_COLOR_YELLOW, "Location point with ID %u does not exist", location_point_id);
  6952. }
  6953. else
  6954. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location remove [location point id]");
  6955. }
  6956. /*
  6957. Function: Command_Merchant()
  6958. Purpose : Handles Merchant commands
  6959. Params : list
  6960. Dev : Scatman
  6961. Example : /merchant list
  6962. */
  6963. void Commands::Command_Merchant(Client* client, Seperator* sep, int handler)
  6964. {
  6965. if( handler == COMMAND_MERCHANT )
  6966. {
  6967. // /merchant command by itself shows help (to be extended)
  6968. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  6969. return;
  6970. }
  6971. else if( handler == COMMAND_MERCHANT_LIST )
  6972. {
  6973. // /merchant list command expects "description" param
  6974. if (sep && sep->arg[0])
  6975. {
  6976. const char* merchant_description = sep->argplus[0];
  6977. client->Message(CHANNEL_COLOR_YELLOW, "Listing merchants like '%s':", merchant_description);
  6978. map<int32, MerchantInfo*>* merchant_info = world.GetMerchantInfo();
  6979. map<int32, MerchantInfo*>::iterator itr;
  6980. for (itr = merchant_info->begin(); itr != merchant_info->end(); itr++)
  6981. {
  6982. string description = database.GetMerchantDescription(itr->first);
  6983. if (ToLower(description).find(ToLower(string(merchant_description))) < 0xFFFFFFFF)
  6984. client->Message(CHANNEL_COLOR_YELLOW, "Merchant ID: %u, Description: %s", itr->first, description.c_str());
  6985. }
  6986. }
  6987. else // no description
  6988. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  6989. }
  6990. }
  6991. /*
  6992. Function: Command_Modify()
  6993. Purpose : to replace our other "set" commands
  6994. Params : System = the system to modify, Action = the action to perform, Target = what to change (target, or index)
  6995. Dev : John Adams
  6996. Example : /modify spell set name "Aegolism III"
  6997. */
  6998. void Commands::Command_Modify(Client* client)
  6999. {
  7000. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /modify [system] [action] [field] [value] {target|id}");
  7001. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Systems: character, faction, guild, item, skill, spawn, spell, zone");
  7002. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Actions: set, create, delete, add, remove");
  7003. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Value : field name in the table being modified");
  7004. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target : modify current target, or specified {system} ID");
  7005. }
  7006. /*
  7007. Function: Command_ModifySpawn()
  7008. Purpose : replace "spawn set" commands
  7009. Params : Action : the action to perform (or special handler)
  7010. : Field : the DB field to change
  7011. : Value : what to set the value to
  7012. : Target : what object to change (my target, or spawn_id)
  7013. Dev : John Adams
  7014. Example : /modify spawn set name "Lady Vox"
  7015. :
  7016. Note : Special Handlers, like "zoneto" for Signs
  7017. : /modify spawn zoneto
  7018. : Will set a sign's zone x/y/z to my current coords
  7019. */
  7020. void Commands::Command_ModifySpawn(Client* client, Seperator* sep)
  7021. {
  7022. PrintSep(sep, "COMMAND_MODIFY");
  7023. // need at least 2 args for a valid command
  7024. if( sep && sep->arg[1] )
  7025. {
  7026. // JA: just a quick implementation because I need it :)
  7027. if (strcmp(sep->arg[0], "zoneto") == 0)
  7028. {
  7029. if( sep->IsNumber(1) )
  7030. {
  7031. int32 spawn_id = atoul(sep->arg[1]);
  7032. float x_coord = client->GetPlayer()->GetX();
  7033. float y_coord = client->GetPlayer()->GetY();
  7034. float z_coord = client->GetPlayer()->GetZ();
  7035. float h_coord = client->GetPlayer()->GetHeading();
  7036. database.SaveSignZoneToCoords(spawn_id, x_coord, y_coord, z_coord, h_coord);
  7037. }
  7038. else
  7039. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify spawn zoneto spawn_id - sets spawn_id to your coords");
  7040. }
  7041. }
  7042. else
  7043. Command_Modify(client);
  7044. }
  7045. /*
  7046. Function: Command_ModifyCharacter()
  7047. Purpose : to replace our other "set" commands
  7048. Params : Action : Add, Remove
  7049. : Field : copper, silver, gold, plat
  7050. : Value : min 1, max unlimited
  7051. : Target : Self, Player
  7052. Dev : Cynnar
  7053. Example : /modify character add gold 50
  7054. : /modify character remove silver 25
  7055. */
  7056. void Commands::Command_ModifyCharacter(Client* client, Seperator* sep)
  7057. {
  7058. PrintSep(sep, "COMMAND_MODIFY");
  7059. int64 value = 0;
  7060. Player* player = client->GetPlayer();
  7061. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  7062. player = (Player*)player->GetTarget();
  7063. // need at least 2 args for a valid command
  7064. if( sep && sep->arg[1] )
  7065. {
  7066. if (strcmp(sep->arg[0], "add") == 0)
  7067. {
  7068. if (strcmp(sep->arg[1], "copper") == 0)
  7069. {
  7070. value = atoi64(sep->arg[2]);
  7071. player->AddCoins(value);
  7072. if (client->GetPlayer() == player)
  7073. {
  7074. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu copper coin%s", value, (value > 1 ? "s" : ""));
  7075. }
  7076. else {
  7077. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu copper coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  7078. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu copper coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  7079. }
  7080. }
  7081. else if (strcmp(sep->arg[1], "silver") == 0)
  7082. {
  7083. value = atoi64(sep->arg[2]) * 100;
  7084. player->AddCoins(value);
  7085. if (client->GetPlayer() == player)
  7086. {
  7087. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu silver coin%s", value / 100, (value > 1 ? "s" : ""));
  7088. }
  7089. else {
  7090. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu silver coin%s", player->GetName(), value / 100, (value > 1 ? "s" : ""));
  7091. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu silver coin%s", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  7092. }
  7093. }
  7094. else if (strcmp(sep->arg[1], "gold") == 0)
  7095. {
  7096. value = atoi64(sep->arg[2]) * 10000;
  7097. player->AddCoins(value);
  7098. if (client->GetPlayer() == player)
  7099. {
  7100. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu gold coin%s", value / 10000, (value > 1 ? "s" : ""));
  7101. }
  7102. else {
  7103. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu gold coin%s", player->GetName(), value / 10000, (value > 1 ? "s" : ""));
  7104. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu gold coin%s", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  7105. }
  7106. }
  7107. else if (strcmp(sep->arg[1], "plat") == 0)
  7108. {
  7109. value = atoi64(sep->arg[2]) * 1000000;
  7110. player->AddCoins(value);
  7111. if (client->GetPlayer() == player)
  7112. {
  7113. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu platinum coin%s", value / 1000000, (value > 1 ? "s" : ""));
  7114. }
  7115. else {
  7116. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu platinum coin%s", player->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  7117. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu platinum coin%s", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  7118. }
  7119. }
  7120. else
  7121. {
  7122. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  7123. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  7124. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  7125. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character add copper 20");
  7126. }
  7127. }
  7128. else if (strcmp(sep->arg[0], "remove") == 0)
  7129. {
  7130. if (strcmp(sep->arg[1], "copper") == 0)
  7131. {
  7132. value = atoi64(sep->arg[2]);
  7133. player->RemoveCoins(value);
  7134. if (client->GetPlayer() == player)
  7135. {
  7136. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from yourself", value, (value > 1 ? "s" : ""));
  7137. }
  7138. else {
  7139. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from %s", value, (value > 1 ? "s" : ""), player->GetName());
  7140. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu copper coin%s from you", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  7141. }
  7142. }
  7143. else if (strcmp(sep->arg[1], "silver") == 0)
  7144. {
  7145. value = atoi64(sep->arg[2]) * 100;
  7146. player->RemoveCoins(value);
  7147. if (client->GetPlayer() == player)
  7148. {
  7149. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from yourself", value / 100, (value > 1 ? "s" : ""));
  7150. }
  7151. else {
  7152. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from %s", value / 100, (value > 1 ? "s" : ""), player->GetName());
  7153. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu silver coin%s from you", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  7154. }
  7155. }
  7156. else if (strcmp(sep->arg[1], "gold") == 0)
  7157. {
  7158. value = atoi64(sep->arg[2]) * 10000;
  7159. player->RemoveCoins(value);
  7160. if (client->GetPlayer() == player)
  7161. {
  7162. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from yourself", value / 10000, (value > 1 ? "s" : ""));
  7163. }
  7164. else {
  7165. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from %s", value / 10000, (value > 1 ? "s" : ""), player->GetName());
  7166. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu gold coin%s from you", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  7167. }
  7168. }
  7169. else if (strcmp(sep->arg[1], "plat") == 0)
  7170. {
  7171. value = atoi64(sep->arg[2]) * 1000000;
  7172. player->RemoveCoins(value);
  7173. if (client->GetPlayer() == player)
  7174. {
  7175. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from yourself", value / 1000000, (value > 1 ? "s" : ""));
  7176. }
  7177. else {
  7178. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from %s", value / 1000000, (value > 1 ? "s" : ""), player->GetName());
  7179. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu platinum coin%s from you", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  7180. }
  7181. }
  7182. else
  7183. {
  7184. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  7185. }
  7186. }
  7187. else if (strcmp(sep->arg[0], "set") == 0) {
  7188. if (strcmp(sep->arg[1], "tslevel") == 0) {
  7189. int8 level = atoi(sep->arg[2]);
  7190. if (level > 0 && level < 256) {
  7191. if (player) {
  7192. if (client->GetPlayer() == player)
  7193. client->ChangeTSLevel(player->GetTSLevel(), level);
  7194. else
  7195. player->GetZone()->GetClientBySpawn(player)->ChangeTSLevel(player->GetTSLevel(), level);
  7196. }
  7197. }
  7198. else
  7199. client->SimpleMessage(CHANNEL_ERROR, "Level must be between 1 - 255");
  7200. }
  7201. else if (strcmp(sep->arg[1], "tsclass") == 0) {
  7202. int8 tsclass = atoi(sep->arg[2]);
  7203. player->SetTradeskillClass(tsclass);
  7204. player->GetInfoStruct()->set_tradeskill_class1(classes.GetTSBaseClass(player->GetTradeskillClass()));
  7205. player->GetInfoStruct()->set_tradeskill_class2(classes.GetSecondaryTSBaseClass(player->GetTradeskillClass()));
  7206. player->GetInfoStruct()->set_tradeskill_class3(player->GetTradeskillClass());
  7207. player->SetCharSheetChanged(true);
  7208. }
  7209. else if (strcmp(sep->arg[1], "gender") == 0) {
  7210. int8 gender = atoi(sep->arg[2]);
  7211. client->GetPlayer()->GetInfoStruct()->set_gender(gender);
  7212. client->GetPlayer()->SetCharSheetChanged(true);
  7213. client->UpdateTimeStampFlag ( GENDER_UPDATE_FLAG );
  7214. }
  7215. }
  7216. }
  7217. else
  7218. {
  7219. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  7220. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  7221. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  7222. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  7223. }
  7224. }
  7225. void Commands::Command_ModifyFaction(Client* client, Seperator* sep)
  7226. {
  7227. PrintSep(sep, "COMMAND_MODIFY");
  7228. // need at least 2 args for a valid command
  7229. if( sep && sep->arg[1] )
  7230. {
  7231. }
  7232. else
  7233. Command_Modify(client);
  7234. }
  7235. void Commands::Command_ModifyGuild(Client* client, Seperator* sep)
  7236. {
  7237. PrintSep(sep, "COMMAND_MODIFY");
  7238. // need at least 2 args for a valid command
  7239. if( sep && sep->arg[1] )
  7240. {
  7241. }
  7242. else
  7243. Command_Modify(client);
  7244. }
  7245. void Commands::Command_ModifyItem(Client* client, Seperator* sep)
  7246. {
  7247. PrintSep(sep, "COMMAND_MODIFY");
  7248. // need at least 2 args for a valid command
  7249. if( sep && sep->arg[1] )
  7250. {
  7251. }
  7252. else
  7253. Command_Modify(client);
  7254. }
  7255. /*
  7256. Function: Command_ModifyQuest()
  7257. Purpose : to list players quest and completed quests
  7258. Params : Action : list, completed
  7259. : Target : Self, Player
  7260. Dev : Cynnar
  7261. Example : /modify quest list
  7262. : /modify quest completed
  7263. */
  7264. void Commands::Command_ModifyQuest(Client* client, Seperator* sep)
  7265. {
  7266. PrintSep(sep, "COMMAND_MODIFY");
  7267. int64 value = 0;
  7268. Player* player = client->GetPlayer();
  7269. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  7270. player = (Player*)player->GetTarget();
  7271. // need at least 2 args for a valid command
  7272. if (sep && sep->arg[1])
  7273. {
  7274. if (strcmp(sep->arg[0], "list") == 0)
  7275. {
  7276. map<int32, Quest*>* quests = player->GetPlayerQuests();
  7277. map<int32, Quest*>::iterator itr;
  7278. client->Message(CHANNEL_COLOR_YELLOW, "%s's Quest List:.", client->GetPlayer()->GetName());
  7279. if (quests->size() == 0)
  7280. client->Message(CHANNEL_COLOR_YELLOW, "%s has no quests.", client->GetPlayer()->GetName());
  7281. else
  7282. {
  7283. for (itr = quests->begin(); itr != quests->end(); itr++)
  7284. {
  7285. Quest* quest = itr->second;
  7286. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  7287. }
  7288. }
  7289. }
  7290. else if (strcmp(sep->arg[0], "completed") == 0)
  7291. {
  7292. map<int32, Quest*>* quests = player->GetCompletedPlayerQuests();
  7293. map<int32, Quest*>::iterator itr;
  7294. client->Message(CHANNEL_COLOR_YELLOW, "%s's Completed Quest List:.", client->GetPlayer()->GetName());
  7295. if (quests->size() == 0)
  7296. client->Message(CHANNEL_COLOR_YELLOW, "%s has no completed quests.", client->GetPlayer()->GetName());
  7297. else
  7298. {
  7299. for (itr = quests->begin(); itr != quests->end(); itr++)
  7300. {
  7301. Quest* quest = itr->second;
  7302. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  7303. }
  7304. }
  7305. }
  7306. // Add in a progress step, and a LogWrite() for tracking GM Commands.
  7307. // LogWrite(LUA__DEBUG, 0, "LUA", "Quest: %s, function: %s", quest->GetName(), function);
  7308. else if (strcmp(sep->arg[0], "remove") == 0)
  7309. {
  7310. int32 quest_id = 0;
  7311. if (sep && sep->arg[1] && sep->IsNumber(1))
  7312. quest_id = atoul(sep->arg[1]);
  7313. if (quest_id > 0)
  7314. {
  7315. if (lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0)
  7316. {
  7317. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  7318. if (quest)
  7319. if (client->GetPlayer() == player)
  7320. {
  7321. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been removed from your journal", quest->GetName());
  7322. }
  7323. else
  7324. {
  7325. client->Message(CHANNEL_COLOR_YELLOW, "You have removed the quest %s from %s's journal", quest->GetName(), player->GetName());
  7326. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s has removed the quest %s from your journal", client->GetPlayer()->GetName(), quest->GetName());
  7327. }
  7328. LogWrite(COMMAND__INFO, 0, "GM Command", "%s removed the quest %s from %s", client->GetPlayer()->GetName(), quest->GetName(), player->GetName());
  7329. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  7330. }
  7331. client->RemovePlayerQuest(quest_id);
  7332. client->GetCurrentZone()->SendQuestUpdates(client);
  7333. }
  7334. }
  7335. else if (strcmp(sep->arg[0], "advance") == 0)
  7336. {
  7337. int32 quest_id = 0;
  7338. int32 step = 0;
  7339. if (sep && sep->arg[1] && sep->IsNumber(1))
  7340. {
  7341. quest_id = atoul(sep->arg[1]);
  7342. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  7343. if(!quest) {
  7344. client->Message(CHANNEL_COLOR_RED, "Quest not found!");
  7345. return;
  7346. }
  7347. if (sep && sep->arg[2] && sep->IsNumber(1))
  7348. {
  7349. step = atoul(sep->arg[2]);
  7350. if (quest_id > 0 && step > 0)
  7351. {
  7352. if (player && player->IsPlayer() && quest_id > 0 && step > 0 && (player->player_quests.count(quest_id) > 0))
  7353. {
  7354. if (client)
  7355. {
  7356. client->AddPendingQuestUpdate(quest_id, step);
  7357. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been advanced one step.", quest->GetName());
  7358. LogWrite(COMMAND__INFO, 0, "GM Command", "%s advanced the quest %s one step", client->GetPlayer()->GetName(), quest->GetName());
  7359. }
  7360. }
  7361. }
  7362. else
  7363. {
  7364. client->Message(CHANNEL_COLOR_RED, "Quest ID and Step Number must be greater than 0!");
  7365. }
  7366. }
  7367. else
  7368. {
  7369. client->Message(CHANNEL_COLOR_RED, "Step Number must be a number!");
  7370. }
  7371. }
  7372. else
  7373. {
  7374. client->Message(CHANNEL_COLOR_RED, "Quest ID must be a number!");
  7375. }
  7376. }
  7377. else
  7378. {
  7379. Command_Modify(client);
  7380. }
  7381. }
  7382. else
  7383. {
  7384. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify quest [action] [quest id] [step number]");
  7385. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: list, completed, remove, advance");
  7386. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest list");
  7387. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest remove 156");
  7388. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest advance 50 1");
  7389. }
  7390. }
  7391. void Commands::Command_ModifySkill(Client* client, Seperator* sep)
  7392. {
  7393. PrintSep(sep, "COMMAND_MODIFY");
  7394. // need at least 2 args for a valid command
  7395. if( sep && sep->arg[1] )
  7396. {
  7397. if (strcmp(sep->arg[0], "add") == 0) {
  7398. const char* skill_name = sep->argplus[1];
  7399. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  7400. if (skill) {
  7401. Player* player = 0;
  7402. Client* to_client = 0;
  7403. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  7404. player = (Player*)client->GetPlayer()->GetTarget();
  7405. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  7406. }
  7407. else {
  7408. player = client->GetPlayer();
  7409. to_client = client;
  7410. }
  7411. if (player)
  7412. {
  7413. if (!player->GetSkills()->HasSkill(skill->skill_id))
  7414. {
  7415. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  7416. if (to_client == client) {
  7417. client->Message(CHANNEL_STATUS, "Added skill '%s'.", skill_name);
  7418. }
  7419. else {
  7420. client->Message(CHANNEL_STATUS, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  7421. to_client->Message(CHANNEL_STATUS, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  7422. }
  7423. }
  7424. else
  7425. client->Message(CHANNEL_STATUS, "%s already has the skill '%s'.", to_client == client ? "You" : player->GetName(), skill_name);
  7426. }
  7427. }
  7428. else
  7429. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  7430. }
  7431. else if (strcmp(sep->arg[0], "remove") == 0) {
  7432. const char* skill_name = sep->argplus[1];
  7433. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  7434. if (skill) {
  7435. Player* player = 0;
  7436. Client* to_client = 0;
  7437. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  7438. player = (Player*)client->GetPlayer()->GetTarget();
  7439. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  7440. }
  7441. else {
  7442. player = client->GetPlayer();
  7443. to_client = client;
  7444. }
  7445. if (player)
  7446. {
  7447. if (player->GetSkills()->HasSkill(skill->skill_id))
  7448. {
  7449. player->RemoveSkillFromDB(skill, true);
  7450. if (client == to_client) {
  7451. client->Message(CHANNEL_STATUS, "Removed skill '%s'.", skill_name);
  7452. }
  7453. else {
  7454. client->Message(CHANNEL_STATUS, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  7455. to_client->Message(CHANNEL_STATUS, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  7456. }
  7457. }
  7458. else {
  7459. if (client == to_client)
  7460. client->Message(CHANNEL_STATUS, "You do not have the skill '%s'.", skill_name);
  7461. else
  7462. client->Message(CHANNEL_STATUS, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  7463. }
  7464. }
  7465. }
  7466. else
  7467. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  7468. }
  7469. else if (strcmp(sep->arg[0], "set") == 0) {
  7470. if (!sep->IsNumber(2)) {
  7471. client->Message(CHANNEL_STATUS, "The last parameter must be a number.");
  7472. return;
  7473. }
  7474. const char* skill_name = sep->arg[1];
  7475. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  7476. if (skill) {
  7477. int16 val = atoi(sep->arg[2]);
  7478. Player* player = 0;
  7479. Client* to_client = 0;
  7480. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  7481. player = (Player*)client->GetPlayer()->GetTarget();
  7482. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  7483. }
  7484. else {
  7485. player = client->GetPlayer();
  7486. to_client = client;
  7487. }
  7488. if (player)
  7489. {
  7490. if (player->GetSkills()->HasSkill(skill->skill_id)) {
  7491. player->GetSkills()->SetSkill(skill->skill_id, val);
  7492. if (client != to_client)
  7493. client->Message(CHANNEL_STATUS, "You set %s's '%s' skill to %i.", player->GetName(), skill_name, val);
  7494. to_client->Message(CHANNEL_STATUS, "Your '%s' skill has been set to %i.", skill_name, val);
  7495. }
  7496. else {
  7497. client->Message(CHANNEL_STATUS, "Target does not have the skill '%s'.", skill_name);
  7498. }
  7499. }
  7500. }
  7501. else {
  7502. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  7503. }
  7504. }
  7505. else {
  7506. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  7507. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  7508. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  7509. }
  7510. }
  7511. else {
  7512. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  7513. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  7514. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  7515. }
  7516. }
  7517. void Commands::Command_ModifySpell(Client* client, Seperator* sep)
  7518. {
  7519. PrintSep(sep, "COMMAND_MODIFY");
  7520. // need at least 2 args for a valid command
  7521. if( sep && sep->arg[1] )
  7522. {
  7523. }
  7524. else
  7525. Command_Modify(client);
  7526. }
  7527. void Commands::Command_ModifyZone(Client* client, Seperator* sep)
  7528. {
  7529. PrintSep(sep, "COMMAND_MODIFY");
  7530. // need at least 2 args for a valid command
  7531. if( sep && sep->arg[1] )
  7532. {
  7533. }
  7534. else
  7535. Command_Modify(client);
  7536. }
  7537. /*
  7538. Function: Command_MOTD()
  7539. Purpose : Displays server MOTD
  7540. Params :
  7541. Dev : LethalEncounter
  7542. Example : /motd
  7543. */
  7544. void Commands::Command_MOTD(Client* client)
  7545. {
  7546. if (client)
  7547. ClientPacketFunctions::SendMOTD(client);
  7548. }
  7549. /*
  7550. Function: Command_Pet()
  7551. Purpose : Handle Pet {Command} commands
  7552. Params : attack, backoff, preserve_master, preserve_self, follow, stay, getlost
  7553. Dev :
  7554. Example : /pet preserve_master
  7555. */
  7556. void Commands::Command_Pet(Client* client, Seperator* sep)
  7557. {
  7558. PrintSep(sep, "COMMAND_PET");
  7559. //LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Pet Commands");
  7560. //client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7561. if (!sep || !sep->arg[0])
  7562. return; // should have sep->arg[0] filled
  7563. if (strcmp(sep->arg[0], "hide") == 0) {
  7564. // doing /pet hide will toggle the hide status on all the pets that can be hidden
  7565. Entity* pet = client->GetPlayer()->GetDeityPet();
  7566. if (pet) {
  7567. if (pet->IsPrivateSpawn())
  7568. client->GetPlayer()->HideDeityPet(false);
  7569. else
  7570. client->GetPlayer()->HideDeityPet(true);
  7571. }
  7572. pet = client->GetPlayer()->GetCosmeticPet();
  7573. if (pet) {
  7574. if (pet->IsPrivateSpawn())
  7575. client->GetPlayer()->HideCosmeticPet(false);
  7576. else
  7577. client->GetPlayer()->HideCosmeticPet(true);
  7578. }
  7579. return;
  7580. }
  7581. // below is for all combat pets
  7582. if (!client->GetPlayer()->HasPet()) {
  7583. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a pet.");
  7584. return;
  7585. }
  7586. if (strcmp(sep->arg[0], "stay") == 0) {
  7587. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to stay.");
  7588. client->GetPlayer()->GetInfoStruct()->set_pet_movement(1);
  7589. client->GetPlayer()->SetCharSheetChanged(true);
  7590. if (client->GetPlayer()->GetPet())
  7591. client->GetPlayer()->GetPet()->following = false;
  7592. if (client->GetPlayer()->GetCharmedPet())
  7593. client->GetPlayer()->GetCharmedPet()->following = false;
  7594. }
  7595. else if (strcmp(sep->arg[0], "follow") == 0) {
  7596. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to follow.");
  7597. client->GetPlayer()->GetInfoStruct()->set_pet_movement(2);
  7598. client->GetPlayer()->SetCharSheetChanged(true);
  7599. }
  7600. else if (strcmp(sep->arg[0], "preserve_master") == 0) {
  7601. if (client->GetPlayer()->GetInfoStruct()->get_pet_behavior() & 1) {
  7602. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect you.");
  7603. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()-1);
  7604. }
  7605. else {
  7606. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect you.");
  7607. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()+1);
  7608. }
  7609. client->GetPlayer()->SetCharSheetChanged(true);
  7610. }
  7611. else if (strcmp(sep->arg[0], "preserve_self") == 0) {
  7612. if (client->GetPlayer()->GetInfoStruct()->get_pet_behavior() & 2) {
  7613. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect itself.");
  7614. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()-2);
  7615. }
  7616. else {
  7617. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect itself.");
  7618. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()+2);
  7619. }
  7620. client->GetPlayer()->SetCharSheetChanged(true);
  7621. }
  7622. else if (strcmp(sep->arg[0], "backoff") == 0) {
  7623. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to back down.");
  7624. if (client->GetPlayer()->GetPet())
  7625. ((NPC*)client->GetPlayer()->GetPet())->Brain()->ClearHate();
  7626. if (client->GetPlayer()->GetCharmedPet())
  7627. ((NPC*)client->GetPlayer()->GetCharmedPet())->Brain()->ClearHate();
  7628. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(0);
  7629. client->GetPlayer()->SetCharSheetChanged(true);
  7630. }
  7631. else if (strcmp(sep->arg[0], "attack") == 0) {
  7632. if (client->GetPlayer()->HasTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  7633. if (client->GetPlayer()->AttackAllowed((Entity*)client->GetPlayer()->GetTarget())){
  7634. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to attack your target.");
  7635. if (client->GetPlayer()->GetPet())
  7636. client->GetPlayer()->GetPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  7637. if (client->GetPlayer()->GetCharmedPet())
  7638. client->GetPlayer()->GetCharmedPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  7639. }
  7640. else
  7641. client->Message(CHANNEL_COLOR_YELLOW, "You can not attack that.");
  7642. }
  7643. else
  7644. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a target.");
  7645. }
  7646. else if (strcmp(sep->arg[0], "getlost") == 0) {
  7647. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetPet());
  7648. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetCharmedPet());
  7649. client->Message(CHANNEL_COLOR_YELLOW, "You tell your pet to get lost.");
  7650. }
  7651. else
  7652. client->Message(CHANNEL_COLOR_YELLOW, "Unknown pet command.");
  7653. }
  7654. /*
  7655. Function: Command_PetName()
  7656. Purpose : Pet your name (???)
  7657. Params :
  7658. Dev :
  7659. Example :
  7660. */
  7661. void Commands::Command_PetName(Client* client, Seperator* sep)
  7662. {
  7663. if (sep && sep->arg[0]) {
  7664. const char* pet_name = sep->argplus[0];
  7665. client->SetPetName(pet_name);
  7666. }
  7667. else {
  7668. client->GetPlayer()->GetInfoStruct()->set_pet_name("");
  7669. }
  7670. }
  7671. /*
  7672. Function: Command_NamePet()
  7673. Purpose : Name your pet
  7674. Params :
  7675. Dev :
  7676. Example :
  7677. */
  7678. void Commands::Command_NamePet(Client* client, Seperator* sep)
  7679. {
  7680. PrintSep(sep, "COMMAND_NAME_PET");
  7681. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Name Pet Command");
  7682. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7683. }
  7684. /*
  7685. Function: Command_Rename()
  7686. Purpose : Renames existing pet
  7687. Params :
  7688. Dev :
  7689. Example :
  7690. */
  7691. void Commands::Command_Rename(Client* client, Seperator* sep)
  7692. {
  7693. PrintSep(sep, "COMMAND_RENAME");
  7694. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Rename Pet Command");
  7695. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7696. }
  7697. /*
  7698. Function: Command_ConfirmRename()
  7699. Purpose : Confirms renaming your pet
  7700. Params :
  7701. Dev :
  7702. Example :
  7703. */
  7704. void Commands::Command_ConfirmRename(Client* client, Seperator* sep)
  7705. {
  7706. PrintSep(sep, "COMMAND_CONFIRMRENAME");
  7707. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Confirm Rename Pet Command");
  7708. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7709. }
  7710. /*
  7711. Function: Command_PetOptions()
  7712. Purpose : Sets various pet options
  7713. Params :
  7714. Dev :
  7715. Example :
  7716. */
  7717. void Commands::Command_PetOptions(Client* client, Seperator* sep)
  7718. {
  7719. PrintSep(sep, "COMMAND_PETOPTIONS");
  7720. Player* player = client->GetPlayer();
  7721. Spawn* target = player->GetTarget();
  7722. if (!target)
  7723. return;
  7724. if (target == player->GetPet())
  7725. client->SendPetOptionsWindow(player->GetPet()->GetName());
  7726. else if (target == player->GetCharmedPet())
  7727. client->SendPetOptionsWindow(player->GetCharmedPet()->GetName());
  7728. else if (target == player->GetCosmeticPet())
  7729. client->SendPetOptionsWindow(player->GetCosmeticPet()->GetName(), 0);
  7730. else if (target == player->GetDeityPet())
  7731. client->SendPetOptionsWindow(player->GetDeityPet()->GetName(), 0);
  7732. }
  7733. /*
  7734. Function: Command_Random()
  7735. Purpose : Handles /random dice roll in-game
  7736. Params : 1-100
  7737. Dev : Scatman
  7738. Example : /randon 1 100
  7739. */
  7740. void Commands::Command_Random(Client* client, Seperator* sep)
  7741. {
  7742. char message[256] = {0};
  7743. if (sep)
  7744. {
  7745. if (sep->GetArgNumber() == 0 && sep->IsNumber(0))
  7746. 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])));
  7747. else if (sep->GetArgNumber() > 0 && sep->IsNumber(0) && sep->IsNumber(1))
  7748. 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])));
  7749. else
  7750. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  7751. }
  7752. else
  7753. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  7754. client->GetPlayer()->GetZone()->HandleChatMessage(0, 0, CHANNEL_EMOTE, message);
  7755. }
  7756. /*
  7757. Function: Command_Randomize()
  7758. Purpose : Sets randomize (appearance) values for NPCs
  7759. Params : Attrib Name
  7760. Dev : Scatman
  7761. Example : /randomize gender 1 -- will randomize the NPCs gender (male/female)
  7762. */
  7763. void Commands::Command_Randomize(Client* client, Seperator* sep)
  7764. {
  7765. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  7766. if (target)
  7767. {
  7768. if (target->IsNPC())
  7769. {
  7770. if (sep && sep->arg[0] && !sep->IsNumber(0))
  7771. {
  7772. const char* value = sep->arg[0];
  7773. if (strncasecmp(value, "show", strlen(value)) == 0)
  7774. {
  7775. client->DisplayRandomizeFeatures(target->GetRandomize());
  7776. }
  7777. else
  7778. {
  7779. if (sep->arg[1] && sep->IsNumber(1))
  7780. {
  7781. int8 option = atoi(sep->arg[1]);
  7782. if (option == 0 || option == 1)
  7783. {
  7784. int32 feature = 0;
  7785. char feature_text[32] = {0};
  7786. if (strncasecmp(value, "gender", strlen(value)) == 0) {
  7787. feature = RANDOMIZE_GENDER;
  7788. strncpy(feature_text, "gender", sizeof(feature_text) - 1);
  7789. }
  7790. else if (strncasecmp(value, "race", strlen(value)) == 0) {
  7791. feature = RANDOMIZE_RACE;
  7792. strncpy(feature_text, "race", sizeof(feature_text) - 1);
  7793. }
  7794. else if (strncasecmp(value, "model", strlen(value)) == 0) {
  7795. feature = RANDOMIZE_MODEL_TYPE;
  7796. strncpy(feature_text, "model", sizeof(feature_text) - 1);
  7797. }
  7798. else if (strncasecmp(value, "facial_hair", strlen(value)) == 0) {
  7799. feature = RANDOMIZE_FACIAL_HAIR_TYPE;
  7800. strncpy(feature_text, "facial hair", sizeof(feature_text) - 1);
  7801. }
  7802. else if (strncasecmp(value, "hair", strlen(value)) == 0) {
  7803. feature = RANDOMIZE_HAIR_TYPE;
  7804. strncpy(feature_text, "hair", sizeof(feature_text) - 1);
  7805. }
  7806. else if (strncasecmp(value, "wing", strlen(value)) == 0) {
  7807. feature = RANDOMIZE_WING_TYPE;
  7808. strncpy(feature_text, "wings", sizeof(feature_text) - 1);
  7809. }
  7810. else if (strncasecmp(value, "cheek", strlen(value)) == 0) {
  7811. feature = RANDOMIZE_CHEEK_TYPE;
  7812. strncpy(feature_text, "cheeks", sizeof(feature_text) - 1);
  7813. }
  7814. else if (strncasecmp(value, "chin", strlen(value)) == 0) {
  7815. feature = RANDOMIZE_CHIN_TYPE;
  7816. strncpy(feature_text, "chin", sizeof(feature_text) - 1);
  7817. }
  7818. else if (strncasecmp(value, "ear", strlen(value)) == 0) {
  7819. feature = RANDOMIZE_EAR_TYPE;
  7820. strncpy(feature_text, "ears", sizeof(feature_text) - 1);
  7821. }
  7822. else if (strncasecmp(value, "eye_brow", strlen(value)) == 0) {
  7823. feature = RANDOMIZE_EYE_BROW_TYPE;
  7824. strncpy(feature_text, "eye brows", sizeof(feature_text) - 1);
  7825. }
  7826. else if (strncasecmp(value, "eye", strlen(value)) == 0) {
  7827. feature = RANDOMIZE_EYE_TYPE;
  7828. strncpy(feature_text, "eyes", sizeof(feature_text) - 1);
  7829. }
  7830. else if (strncasecmp(value, "lip", strlen(value)) == 0) {
  7831. feature = RANDOMIZE_LIP_TYPE;
  7832. strncpy(feature_text, "lips", sizeof(feature_text) - 1);
  7833. }
  7834. else if (strncasecmp(value, "nose", strlen(value)) == 0) {
  7835. feature = RANDOMIZE_NOSE_TYPE;
  7836. strncpy(feature_text, "nose", sizeof(feature_text) - 1);
  7837. }
  7838. else if (strncasecmp(value, "eye_color", strlen(value)) == 0) {
  7839. feature = RANDOMIZE_EYE_COLOR;
  7840. strncpy(feature_text, "eye color", sizeof(feature_text) - 1);
  7841. }
  7842. else if (strncasecmp(value, "hair_color", strlen(value)) == 0) {
  7843. feature = RANDOMIZE_HAIR_TYPE_COLOR;
  7844. strncpy(feature_text, "hair color", sizeof(feature_text) - 1);
  7845. }
  7846. else if (strncasecmp(value, "hair_color1", strlen(value)) == 0) {
  7847. feature = RANDOMIZE_HAIR_COLOR1;
  7848. strncpy(feature_text, "hair color1", sizeof(feature_text) - 1);
  7849. }
  7850. else if (strncasecmp(value, "hair_color2", strlen(value)) == 0) {
  7851. feature = RANDOMIZE_HAIR_COLOR2;
  7852. strncpy(feature_text, "hair color2", sizeof(feature_text) - 1);
  7853. }
  7854. else if (strncasecmp(value, "hair_highlight", strlen(value)) == 0) {
  7855. feature = RANDOMIZE_HAIR_HIGHLIGHT;
  7856. strncpy(feature_text, "hair highlights", sizeof(feature_text) - 1);
  7857. }
  7858. else if (strncasecmp(value, "facial_hair_color", strlen(value)) == 0) {
  7859. feature = RANDOMIZE_HAIR_FACE_COLOR;
  7860. strncpy(feature_text, "facial hair color", sizeof(feature_text) - 1);
  7861. }
  7862. else if (strncasecmp(value, "facial_hair_color_highlight", strlen(value)) == 0) {
  7863. feature = RANDOMIZE_HAIR_FACE_HIGHLIGHT_COLOR;
  7864. strncpy(feature_text, "facial hair color highlights", sizeof(feature_text) - 1);
  7865. }
  7866. else if (strncasecmp(value, "hair_color_highlight", strlen(value)) == 0) {
  7867. feature = RANDOMIZE_HAIR_TYPE_HIGHLIGHT_COLOR;
  7868. strncpy(feature_text, "hair color highlights", sizeof(feature_text) - 1);
  7869. }
  7870. else if (strncasecmp(value, "skin_color", strlen(value)) == 0) {
  7871. feature = RANDOMIZE_SKIN_COLOR;
  7872. strncpy(feature_text, "skin color", sizeof(feature_text) - 1);
  7873. }
  7874. else if (strncasecmp(value, "wing_color1", strlen(value)) == 0) {
  7875. feature = RANDOMIZE_WING_COLOR1;
  7876. strncpy(feature_text, "wing color1", sizeof(feature_text) - 1);
  7877. }
  7878. else if (strncasecmp(value, "wing_color2", strlen(value)) == 0) {
  7879. feature = RANDOMIZE_WING_COLOR2;
  7880. strncpy(feature_text, "wing color2", sizeof(feature_text) - 1);
  7881. }
  7882. else {
  7883. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is not a valid feature to randomize.", value);
  7884. 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'.");
  7885. }
  7886. if (feature > 0) {
  7887. if (option == 1) {
  7888. if (target->GetRandomize() & feature)
  7889. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is already set to randomly generate their %s.", target->GetName(), feature_text);
  7890. else {
  7891. target->AddRandomize(feature);
  7892. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(feature);
  7893. database.UpdateRandomize(target->GetDatabaseID(), feature);
  7894. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will now generate their %s randomly.", target->GetName(), feature_text);
  7895. }
  7896. }
  7897. else {
  7898. if (target->GetRandomize() & feature) {
  7899. target->AddRandomize(-feature);
  7900. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(-feature);
  7901. database.UpdateRandomize(target->GetDatabaseID(), -feature);
  7902. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will no longer generate their %s randomly.", target->GetName(), feature_text);
  7903. }
  7904. else
  7905. client->Message(CHANNEL_COLOR_YELLOW, "'%s' already does not randomly generate their %s.", target->GetName(), feature_text);
  7906. }
  7907. }
  7908. }
  7909. else
  7910. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  7911. }
  7912. else
  7913. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  7914. }
  7915. }
  7916. else {
  7917. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /randomize [show | [feature [1|0]]");
  7918. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "'show' will display current configured features");
  7919. 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'.");
  7920. }
  7921. }
  7922. else
  7923. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "The target you wish to randomize must be an NPC.");
  7924. }
  7925. else
  7926. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select the target you wish to randomize.");
  7927. }
  7928. /*
  7929. Function: Command_ShowCloak()
  7930. Purpose : Character Settings combo box for Show Cloak
  7931. Params : true/false
  7932. Dev : John Adams
  7933. Example :
  7934. */
  7935. void Commands::Command_ShowCloak(Client* client, Seperator* sep)
  7936. {
  7937. Player* player = client->GetPlayer();
  7938. if (sep && sep->arg[0])
  7939. {
  7940. const char* value = sep->arg[0];
  7941. if (strncasecmp(value, "true", strlen(value)) == 0)
  7942. {
  7943. player->set_character_flag(CF_SHOW_CLOAK);
  7944. player->reset_character_flag(CF2_SHOW_RANGED);
  7945. }
  7946. else if (strncasecmp(value, "false", strlen(value)) == 0)
  7947. player->reset_character_flag(CF_SHOW_CLOAK);
  7948. else
  7949. {
  7950. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7951. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7952. }
  7953. }
  7954. }
  7955. /*
  7956. Function: Command_ShowHelm()
  7957. Purpose : Character Settings combo box for Show Helm
  7958. Params : true/false
  7959. Dev : John Adams
  7960. Example :
  7961. */
  7962. void Commands::Command_ShowHelm(Client* client, Seperator* sep)
  7963. {
  7964. Player* player = client->GetPlayer();
  7965. if (sep && sep->arg[0])
  7966. {
  7967. const char* value = sep->arg[0];
  7968. if (strncasecmp(value, "true", strlen(value)) == 0)
  7969. {
  7970. player->reset_character_flag(CF_HIDE_HELM);
  7971. player->set_character_flag(CF_HIDE_HOOD);
  7972. }
  7973. else if (strncasecmp(value, "false", strlen(value)) == 0)
  7974. player->set_character_flag(CF_HIDE_HELM);
  7975. else
  7976. {
  7977. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7978. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7979. }
  7980. }
  7981. }
  7982. /*
  7983. Function: Command_ShowHood()
  7984. Purpose : Character Settings combo box for Show Hood
  7985. Params : true/false
  7986. Dev : John Adams
  7987. Example :
  7988. */
  7989. void Commands::Command_ShowHood(Client* client, Seperator* sep)
  7990. {
  7991. Player* player = client->GetPlayer();
  7992. if (sep && sep->arg[0])
  7993. {
  7994. const char* value = sep->arg[0];
  7995. if (strncasecmp(value, "true", strlen(value)) == 0)
  7996. {
  7997. player->reset_character_flag(CF_HIDE_HOOD);
  7998. player->set_character_flag(CF_HIDE_HELM);
  7999. }
  8000. else if (strncasecmp(value, "false", strlen(value)) == 0)
  8001. player->set_character_flag(CF_HIDE_HOOD);
  8002. else
  8003. {
  8004. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8005. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8006. }
  8007. }
  8008. }
  8009. /*
  8010. Function: Command_ShowHoodHelm()
  8011. Purpose : Character Settings combo box for Show Helm or Hood
  8012. Params : true/false
  8013. Dev : John Adams
  8014. Example :
  8015. */
  8016. void Commands::Command_ShowHoodHelm(Client* client, Seperator* sep)
  8017. {
  8018. Player* player = client->GetPlayer();
  8019. if (sep && sep->arg[0])
  8020. {
  8021. const char* value = sep->arg[0];
  8022. if (strncasecmp(value, "true", strlen(value)) == 0)
  8023. {
  8024. player->reset_character_flag(CF_HIDE_HOOD);
  8025. player->reset_character_flag(CF_HIDE_HELM);
  8026. }
  8027. else if (strncasecmp(value, "false", strlen(value)) == 0)
  8028. {
  8029. // don't think we ever wind up in here...
  8030. player->set_character_flag(CF_HIDE_HOOD);
  8031. player->set_character_flag(CF_HIDE_HELM);
  8032. }
  8033. else
  8034. {
  8035. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8036. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8037. }
  8038. }
  8039. }
  8040. /*
  8041. Function: Command_ShowRanged()
  8042. Purpose : Character Settings combo box for Show Ranged weapon
  8043. Params : true/false
  8044. Dev : John Adams
  8045. Example :
  8046. */
  8047. void Commands::Command_ShowRanged(Client* client, Seperator* sep)
  8048. {
  8049. Player* player = client->GetPlayer();
  8050. if (sep && sep->arg[0])
  8051. {
  8052. const char* value = sep->arg[0];
  8053. if (strncasecmp(value, "true", strlen(value)) == 0)
  8054. {
  8055. player->set_character_flag(CF2_SHOW_RANGED);
  8056. player->reset_character_flag(CF_SHOW_CLOAK);
  8057. }
  8058. else if (strncasecmp(value, "false", strlen(value)) == 0)
  8059. player->reset_character_flag(CF2_SHOW_RANGED);
  8060. else
  8061. {
  8062. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8063. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8064. }
  8065. }
  8066. }
  8067. /*
  8068. Function:
  8069. Purpose :
  8070. Params :
  8071. Dev :
  8072. Example :
  8073. */
  8074. void Commands::Command_Skills(Client* client, Seperator* sep, int handler)
  8075. {
  8076. Player* player = 0;
  8077. Client* to_client = 0;
  8078. if(client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  8079. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  8080. switch(handler)
  8081. {
  8082. case COMMAND_SKILL:
  8083. {
  8084. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill [add|remove|list] [skill name]");
  8085. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to add/remove skills for that player.");
  8086. break;
  8087. }
  8088. case COMMAND_SKILL_ADD:
  8089. {
  8090. if (sep && sep->arg[0])
  8091. {
  8092. const char* skill_name = sep->argplus[0];
  8093. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  8094. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // add skill to your target, if target is not you
  8095. {
  8096. player = to_client->GetPlayer();
  8097. if (player)
  8098. {
  8099. if (!player->GetSkills()->HasSkill(skill->skill_id))
  8100. {
  8101. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  8102. client->Message(CHANNEL_COLOR_YELLOW, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  8103. to_client->Message(CHANNEL_COLOR_YELLOW, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  8104. }
  8105. else
  8106. client->Message(CHANNEL_COLOR_YELLOW, "%s already has the skill '%s'.", player->GetName(), skill_name);
  8107. }
  8108. }
  8109. else if (skill) // add skill to yourself
  8110. {
  8111. player = client->GetPlayer();
  8112. if (player)
  8113. {
  8114. if (!player->GetSkills()->HasSkill(skill->skill_id))
  8115. {
  8116. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  8117. client->Message(CHANNEL_COLOR_YELLOW, "Added skill '%s'.", skill_name);
  8118. }
  8119. else
  8120. client->Message(CHANNEL_COLOR_YELLOW, "You already have the skill '%s'.", skill_name);
  8121. }
  8122. }
  8123. else
  8124. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  8125. }
  8126. else
  8127. {
  8128. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill add [skill name]");
  8129. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  8130. }
  8131. break;
  8132. }
  8133. case COMMAND_SKILL_REMOVE:
  8134. {
  8135. if (sep && sep->arg[0])
  8136. {
  8137. const char* skill_name = sep->argplus[0];
  8138. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  8139. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // remove skill from your target, if target is not you
  8140. {
  8141. player = to_client->GetPlayer();
  8142. if (player)
  8143. {
  8144. if (player->GetSkills()->HasSkill(skill->skill_id))
  8145. {
  8146. player->RemoveSkillFromDB(skill, true);
  8147. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  8148. to_client->Message(CHANNEL_COLOR_YELLOW, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  8149. }
  8150. else
  8151. client->Message(CHANNEL_COLOR_YELLOW, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  8152. }
  8153. }
  8154. else if(skill) // remove skill from yourself
  8155. {
  8156. Player* player = client->GetPlayer();
  8157. if (player)
  8158. {
  8159. if (player->GetSkills()->HasSkill(skill->skill_id))
  8160. {
  8161. player->RemoveSkillFromDB(skill, true);
  8162. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s'.", skill_name);
  8163. }
  8164. else
  8165. client->Message(CHANNEL_COLOR_YELLOW, "You do not have the skill '%s'.", skill_name);
  8166. }
  8167. }
  8168. else
  8169. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  8170. }
  8171. else
  8172. {
  8173. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill remove [skill name]");
  8174. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  8175. }
  8176. break;
  8177. }
  8178. case COMMAND_SKILL_LIST:
  8179. {
  8180. if (sep && sep->arg[0])
  8181. {
  8182. const char* skill_name = sep->argplus[0];
  8183. client->Message(CHANNEL_COLOR_YELLOW, "Listing skills like '%s':", skill_name);
  8184. map<int32, Skill*>* skills = master_skill_list.GetAllSkills();
  8185. map<int32, Skill*>::iterator itr;
  8186. if (skills && skills->size() > 0)
  8187. {
  8188. for (itr = skills->begin(); itr != skills->end(); itr++)
  8189. {
  8190. Skill* skill = itr->second;
  8191. string current_skill_name = ::ToLower(string(skill->name.data.c_str()));
  8192. if (current_skill_name.find(::ToLower(string(skill_name))) < 0xFFFFFFFF)
  8193. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", skill->name.data.c_str(), skill->skill_id);
  8194. }
  8195. }
  8196. }
  8197. else
  8198. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill list [skill name]");
  8199. break;
  8200. }
  8201. }
  8202. }
  8203. /*
  8204. Function: Command_SpawnTemplate()
  8205. Purpose : Create or Use defined Spawn Templates
  8206. Params : create, save, rempve, list
  8207. Dev : John Adams
  8208. Example : /spawn template create "Test"
  8209. */
  8210. void Commands::Command_SpawnTemplate(Client* client, Seperator* sep)
  8211. {
  8212. if (sep == NULL || sep->arg[0] == NULL)
  8213. {
  8214. 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.");
  8215. return;
  8216. }
  8217. // got params, continue
  8218. const char * template_cmd = sep->arg[0];
  8219. if (strncasecmp(template_cmd, "list", strlen(template_cmd)) == 0)
  8220. {
  8221. if (!sep->IsSet(1))
  8222. {
  8223. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /spawn template list [name|location_id]");
  8224. 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.");
  8225. return;
  8226. }
  8227. map<int32, string>* template_names = 0;
  8228. if (sep->IsNumber(1))
  8229. {
  8230. int32 location_id = 0;
  8231. location_id = atoi(sep->arg[1]);
  8232. template_names = database.GetSpawnTemplateListByID(location_id);
  8233. }
  8234. else
  8235. {
  8236. const char* name = 0;
  8237. name = sep->argplus[1];
  8238. template_names = database.GetSpawnTemplateListByName(name);
  8239. }
  8240. if(!template_names)
  8241. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No templates found.");
  8242. else
  8243. {
  8244. map<int32, string>::iterator itr;
  8245. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  8246. for(itr = template_names->begin(); itr != template_names->end(); itr++)
  8247. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  8248. safe_delete(template_names);
  8249. }
  8250. }
  8251. else if (strncasecmp(template_cmd, "save", strlen(template_cmd)) == 0)
  8252. {
  8253. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  8254. if ( target && (target->IsNPC() || target->IsObject() || target->IsSign() || target->IsWidget() || target->IsGroundSpawn()) )
  8255. {
  8256. if (sep && sep->arg[1][0] && !sep->IsNumber(1))
  8257. {
  8258. // first, lookup to see if template name already exists
  8259. const char* name = 0;
  8260. name = sep->argplus[1];
  8261. map<int32, string>* template_names = database.GetSpawnTemplateListByName(name);
  8262. if(!template_names)
  8263. {
  8264. int32 new_template_id = database.SaveSpawnTemplate(target->GetSpawnLocationID(), name);
  8265. if( new_template_id > 0 )
  8266. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template '%s' added for spawn '%s' (%u) as TemplateID: %u", name, target->GetName(), target->GetSpawnLocationID(), new_template_id);
  8267. else
  8268. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' for spawn '%s' (%u).", name, target->GetName(), target->GetSpawnLocationID());
  8269. }
  8270. else
  8271. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' - Already exists!", name);
  8272. }
  8273. else
  8274. client->Message(CHANNEL_COLOR_RED, "ERROR: Saving a new spawn template requires a valid template name!");
  8275. }
  8276. else
  8277. client->Message(CHANNEL_COLOR_RED, "ERROR: You must target the spawn you wish to save as a template!");
  8278. }
  8279. else if (strncasecmp(template_cmd, "remove", strlen(template_cmd)) == 0)
  8280. {
  8281. if (sep && sep->arg[1][0] && sep->IsNumber(1))
  8282. {
  8283. int32 template_id = 0;
  8284. template_id = atoi(sep->arg[1]);
  8285. if (database.RemoveSpawnTemplate(template_id))
  8286. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template ID: %u successfully removed.", template_id);
  8287. else
  8288. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to remove spawn template ID: %u", template_id);
  8289. }
  8290. else
  8291. client->Message(CHANNEL_COLOR_RED, "ERROR: Removing a spawn template requires a valid template ID!");
  8292. }
  8293. // Renamed create to spawn
  8294. else if (strncasecmp(template_cmd, "spawn", strlen(template_cmd)) == 0)
  8295. {
  8296. if (sep && sep->arg[1][0])
  8297. {
  8298. int32 new_location = 0;
  8299. if (sep->IsNumber(1))
  8300. {
  8301. int32 template_id = 0;
  8302. template_id = atoi(sep->arg[1]);
  8303. new_location = database.CreateSpawnFromTemplateByID(client, template_id);
  8304. if( new_location > 0 )
  8305. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template ID: %u", new_location, template_id);
  8306. else
  8307. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template ID: %u", template_id);
  8308. }
  8309. else
  8310. {
  8311. const char* name = 0;
  8312. name = sep->argplus[1];
  8313. new_location = database.CreateSpawnFromTemplateByName(client, name);
  8314. if( new_location > 0 )
  8315. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template: '%s'", new_location, name);
  8316. else
  8317. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template: '%s'", name);
  8318. }
  8319. }
  8320. else
  8321. client->Message(CHANNEL_COLOR_RED, "ERROR: Spawning a new spawn location requires a valid template name or ID!");
  8322. }
  8323. else
  8324. client->Message(CHANNEL_COLOR_RED, "ERROR: Unknown /spawn template command.");
  8325. }
  8326. void Commands::Command_Speed(Client* client, Seperator* sep) {
  8327. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  8328. float new_speed = atof(sep->arg[0]);
  8329. if (new_speed > 0.0f)
  8330. {
  8331. client->GetPlayer()->SetSpeed(new_speed, true);
  8332. client->GetPlayer()->SetCharSheetChanged(true);
  8333. database.insertCharacterProperty(client, CHAR_PROPERTY_SPEED, sep->arg[0]);
  8334. client->Message(CHANNEL_STATUS, "Setting speed to %.2f.", new_speed);
  8335. }
  8336. else
  8337. client->Message(CHANNEL_STATUS, "Invalid speed provided %s.", sep->arg[0]);
  8338. }
  8339. else{
  8340. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /speed {new speed value}");
  8341. }
  8342. }
  8343. /*
  8344. Function: Command_StationMarketPlace()
  8345. Purpose : just trying to eat the console spam for now
  8346. Params :
  8347. Dev : John
  8348. */
  8349. void Commands::Command_StationMarketPlace(Client* client, Seperator* sep)
  8350. {
  8351. PrintSep(sep, "COMMAND_SMP");
  8352. // This will reduce the spam from once every 10 sec to once every 30 sec,
  8353. // can't seem to reduce it any more get rid of it completely...
  8354. if (sep && strcmp(sep->arg[0], "gkw") == 0) {
  8355. PacketStruct* packet = configReader.getStruct("WS_MarketFundsUpdate", client->GetVersion());
  8356. if (packet) {
  8357. packet->setDataByName("account_id", client->GetAccountID());
  8358. packet->setDataByName("character_id", client->GetCharacterID());
  8359. packet->setDataByName("unknown1", 1, 5);
  8360. packet->setDataByName("unknown1", 26, 6);
  8361. packet->setDataByName("unknown2", 0xFFFFFFFF);
  8362. packet->setDataByName("unknown3", 248, 1);
  8363. client->QueuePacket(packet->serialize());
  8364. }
  8365. safe_delete(packet);
  8366. }
  8367. }
  8368. /*
  8369. Function: Command_StopDrinking()
  8370. Purpose : Stops player from auto-consuming drink
  8371. Params :
  8372. Dev : Zcoretri
  8373. Example : /stopdrinking
  8374. */
  8375. void Commands::Command_StopDrinking(Client* client)
  8376. {
  8377. client->GetPlayer()->reset_character_flag(CF_DRINK_AUTO_CONSUME);
  8378. client->Message(CHANNEL_COLOR_YELLOW,"You stop drinking your current drink.");
  8379. }
  8380. /*
  8381. Function: Command_StopEating()
  8382. Purpose : Stops player from auto-consuming food
  8383. Params :
  8384. Dev : Zcoretri
  8385. Example : /stopeating
  8386. */
  8387. void Commands::Command_StopEating(Client* client)
  8388. {
  8389. client->GetPlayer()->reset_character_flag(CF_FOOD_AUTO_CONSUME);
  8390. client->Message(CHANNEL_COLOR_YELLOW,"You stop eating your current food.");
  8391. }
  8392. /*
  8393. Function: Command_Title()
  8394. Purpose : Help for /title command
  8395. Params : n/a
  8396. Dev : Zcoretri
  8397. Example : /title
  8398. */
  8399. void Commands::Command_Title(Client* client)
  8400. {
  8401. client->Message(CHANNEL_COLOR_YELLOW, "Available subcommands: list, setprefix <index>, setsuffix <index>, fix");
  8402. }
  8403. /*
  8404. Function: Command_TitleList()
  8405. Purpose : List available titles for player
  8406. Params : n/a
  8407. Dev : Zcoretri
  8408. Example : /title list
  8409. */
  8410. void Commands::Command_TitleList(Client* client)
  8411. {
  8412. // must call release read lock before leaving function on GetPlayerTitles
  8413. vector<Title*>* titles = client->GetPlayer()->GetPlayerTitles()->GetAllTitles();
  8414. vector<Title*>::iterator itr;
  8415. Title* title;
  8416. sint32 i = 0;
  8417. client->Message(CHANNEL_NARRATIVE, "Listing available titles:");
  8418. for(itr = titles->begin(); itr != titles->end(); itr++)
  8419. {
  8420. title = *itr;
  8421. client->Message(CHANNEL_NARRATIVE, "%i: type=[%s] title=[%s]", i, title->GetPrefix() ? "Prefix":"Suffix", title->GetName());
  8422. i++;
  8423. }
  8424. client->GetPlayer()->GetPlayerTitles()->ReleaseReadLock();
  8425. }
  8426. /*
  8427. Function: Command_TitleSetPrefix()
  8428. Purpose : Set Prefix title for player
  8429. Params : Title ID
  8430. Dev : Zcoretri
  8431. Example : /title setprefix 1
  8432. */
  8433. void Commands::Command_TitleSetPrefix(Client* client, Seperator* sep)
  8434. {
  8435. if (sep && sep->arg[0] && sep->IsNumber(0))
  8436. {
  8437. sint32 index = atoul(sep->arg[0]);
  8438. if(index > -1)
  8439. {
  8440. Title* title = client->GetPlayer()->GetPlayerTitles()->GetTitle(index);
  8441. if(!title)
  8442. {
  8443. client->Message(CHANNEL_COLOR_RED, "Missing index %i to set title", index);
  8444. return;
  8445. }
  8446. else if(!title->GetPrefix())
  8447. {
  8448. client->Message(CHANNEL_COLOR_RED, "%s is not a prefix.", title->GetName());
  8449. return;
  8450. }
  8451. }
  8452. else // make sure client doesn't pass some bogus negative index
  8453. index = -1;
  8454. database.SaveCharPrefixIndex(index, client->GetCharacterID());
  8455. client->SendTitleUpdate();
  8456. }
  8457. }
  8458. /*
  8459. Function: Command_TitleSetSuffix()
  8460. Purpose : Set Suffix title for player
  8461. Params : Title ID
  8462. Dev : Zcoretri
  8463. Example : /title setsuffix 1
  8464. */
  8465. void Commands::Command_TitleSetSuffix(Client* client, Seperator* sep)
  8466. {
  8467. if (sep && sep->arg[0] && sep->IsNumber(0))
  8468. {
  8469. sint32 index = atoul(sep->arg[0]);
  8470. if(index > -1)
  8471. {
  8472. Title* title = client->GetPlayer()->GetPlayerTitles()->GetTitle(index);
  8473. if(!title)
  8474. {
  8475. client->Message(CHANNEL_COLOR_RED, "Missing index %i to set title", index);
  8476. return;
  8477. }
  8478. else if(title->GetPrefix())
  8479. {
  8480. client->Message(CHANNEL_COLOR_RED, "%s is not a suffix.", title->GetName());
  8481. return;
  8482. }
  8483. }
  8484. else // make sure client doesn't pass some bogus negative index
  8485. index = -1;
  8486. database.SaveCharSuffixIndex(index, client->GetCharacterID());
  8487. client->SendTitleUpdate();
  8488. }
  8489. }
  8490. /*
  8491. Function: Command_TitleFix()
  8492. Purpose : Fix title for player (???)
  8493. Params :
  8494. Dev : Zcoretri
  8495. Example :
  8496. */
  8497. void Commands::Command_TitleFix(Client* client, Seperator* sep)
  8498. {
  8499. PrintSep(sep, "COMMAND_TITLE_FIX");
  8500. LogWrite(MISC__TODO, 1, "Titles", "TODO-Command: TITLE_FIX");
  8501. }
  8502. /*
  8503. Function: Command_Toggle_Anonymous()
  8504. Purpose : Toggles player Anonymous
  8505. Params :
  8506. Dev : paulgh
  8507. Example : /anon
  8508. */
  8509. void Commands::Command_Toggle_Anonymous(Client* client)
  8510. {
  8511. Player* player = client->GetPlayer();
  8512. player->toggle_character_flag(CF_ANONYMOUS);
  8513. client->Message(CHANNEL_COLOR_YELLOW,"You are %s anonymous.", player->get_character_flag(CF_ANONYMOUS)?"now":"no longer");
  8514. if (player->get_character_flag(CF_ANONYMOUS))
  8515. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ANONYMOUS);
  8516. else
  8517. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ANONYMOUS);
  8518. }
  8519. /*
  8520. Function: Command_Toggle_AutoConsume()
  8521. Purpose : Toggles player food/drink auto consume
  8522. Params : unknown
  8523. Dev : paulgh
  8524. Example : /set_auto_consume
  8525. */
  8526. void Commands::Command_Toggle_AutoConsume(Client* client, Seperator* sep)
  8527. {
  8528. Player* player = client->GetPlayer();
  8529. if (sep && sep->arg[0])
  8530. PrintSep(sep, "COMMAND_SET_AUTO_CONSUME");
  8531. if (sep && sep->arg[0] && sep->IsNumber(0))
  8532. {
  8533. int8 slot = atoi(sep->arg[0]);
  8534. int8 flag = atoi(sep->arg[1]);
  8535. if (client->GetVersion() <= 283) {
  8536. slot += 4;
  8537. }
  8538. else if (client->GetVersion() <= 546) {
  8539. slot += 2;
  8540. }
  8541. if (slot == EQ2_FOOD_SLOT)
  8542. {
  8543. player->toggle_character_flag(CF_FOOD_AUTO_CONSUME);
  8544. player->SetCharSheetChanged(true);
  8545. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  8546. if (flag == 1)
  8547. client->Message(CHANNEL_NARRATIVE, "You decide to eat immediately whenever you become hungry.");
  8548. else
  8549. {
  8550. client->Message(CHANNEL_NARRATIVE, "You decide to ignore the hunger.");
  8551. return;
  8552. }
  8553. }
  8554. else
  8555. {
  8556. player->toggle_character_flag(CF_DRINK_AUTO_CONSUME);
  8557. player->SetCharSheetChanged(true);
  8558. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  8559. if (flag == 1)
  8560. client->Message(CHANNEL_NARRATIVE, "You decide to drink immediately whenever you become thirsty.");
  8561. else
  8562. {
  8563. client->Message(CHANNEL_NARRATIVE, "You decide to ignore the thirst.");
  8564. return;
  8565. }
  8566. }
  8567. if(slot == 22 && player->GetSpellEffectBySpellType(SPELL_TYPE_FOOD))
  8568. return;
  8569. else if (player->GetSpellEffectBySpellType(SPELL_TYPE_DRINK))
  8570. return;
  8571. Item* item = player->GetEquipmentList()->GetItem(slot);
  8572. if(item)
  8573. client->ConsumeFoodDrink(item, slot);
  8574. }
  8575. }
  8576. /*
  8577. Function: Command_Toggle_BonusXP()
  8578. Purpose : Toggles player Bonus XP
  8579. Params :
  8580. Dev : John Adams
  8581. Example : /disable_char_bonus_exp
  8582. */
  8583. void Commands::Command_Toggle_BonusXP(Client* client)
  8584. {
  8585. Player* player = client->GetPlayer();
  8586. player->toggle_character_flag(CF2_CHARACTER_BONUS_EXPERIENCE_ENABLED);
  8587. player->SetCharSheetChanged(true);
  8588. }
  8589. /*
  8590. Function: Command_Toggle_CombatXP()
  8591. Purpose : Toggles player Adventure XP
  8592. Params :
  8593. Dev : John Adams
  8594. Example : /disable_combat_exp
  8595. */
  8596. void Commands::Command_Toggle_CombatXP(Client* client)
  8597. {
  8598. Player* player = client->GetPlayer();
  8599. player->toggle_character_flag(CF_COMBAT_EXPERIENCE_ENABLED);
  8600. player->SetCharSheetChanged(true);
  8601. }
  8602. /*
  8603. Function: Command_Toggle_GMHide()
  8604. Purpose : Toggles hiding player GM status
  8605. Params :
  8606. Dev : Scatman
  8607. Example : /gm_hide
  8608. */
  8609. void Commands::Command_Toggle_GMHide(Client* client)
  8610. {
  8611. Player* player = client->GetPlayer();
  8612. player->toggle_character_flag(CF_HIDE_STATUS);
  8613. client->Message(CHANNEL_COLOR_YELLOW,"You are %s hiding your GM status.", player->get_character_flag(CF_HIDE_STATUS)?"now":"no longer");
  8614. }
  8615. /*
  8616. Function: Command_Toggle_GMVanish()
  8617. Purpose : Toggles hiding GM players from /who searches
  8618. Params :
  8619. Dev : Scatman
  8620. Example : /gm_vanish
  8621. */
  8622. void Commands::Command_Toggle_GMVanish(Client* client)
  8623. {
  8624. Player* player = client->GetPlayer();
  8625. player->toggle_character_flag(CF_GM_HIDDEN);
  8626. client->Message(CHANNEL_COLOR_YELLOW,"You are %s invisible to who queries.", player->get_character_flag(CF_GM_HIDDEN)?"now":"no longer");
  8627. }
  8628. /*
  8629. Function: Command_Toggle_Illusions()
  8630. Purpose : Toggles player illusion form
  8631. Params : not sure sep is needed, testing
  8632. Dev : paulgh
  8633. Example : /hide_illusions
  8634. */
  8635. void Commands::Command_Toggle_Illusions(Client* client, Seperator* sep)
  8636. {
  8637. if (sep && sep->arg[0])
  8638. PrintSep(sep, "COMMAND_TOGGLE_ILLUSIONS");
  8639. client->GetPlayer()->toggle_character_flag(CF_SHOW_ILLUSION);
  8640. }
  8641. /*
  8642. Function: Command_Toggle_LFG()
  8643. Purpose : Toggles player LFG Flag
  8644. Params :
  8645. Dev : paulgh
  8646. Example : /lfg
  8647. */
  8648. void Commands::Command_Toggle_LFG(Client* client)
  8649. {
  8650. Player* player = client->GetPlayer();
  8651. player->toggle_character_flag(CF_LFG);
  8652. client->Message(CHANNEL_COLOR_YELLOW,"You are %s LFG.", player->get_character_flag(CF_LFG)?"now":"no longer");
  8653. if (player->get_character_flag(CF_LFG))
  8654. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFG);
  8655. else
  8656. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFG);
  8657. }
  8658. /*
  8659. Function: Command_Toggle_LFW()
  8660. Purpose : Toggles player LFW Flag
  8661. Params :
  8662. Dev : paulgh
  8663. Example : /lfw
  8664. */
  8665. void Commands::Command_Toggle_LFW(Client* client)
  8666. {
  8667. Player* player = client->GetPlayer();
  8668. player->toggle_character_flag(CF_LFW);
  8669. client->Message(CHANNEL_COLOR_YELLOW,"You %s looking for work.", player->get_character_flag(CF_LFW)?"let others know you are":"stop");
  8670. if (player->get_character_flag(CF_LFW))
  8671. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFW);
  8672. else
  8673. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFW);
  8674. }
  8675. /*
  8676. Function: Command_Toggle_QuestXP()
  8677. Purpose : Toggles player Quest XP
  8678. Params :
  8679. Dev : John Adams
  8680. Example : /disable_quest_exp
  8681. */
  8682. void Commands::Command_Toggle_QuestXP(Client* client)
  8683. {
  8684. Player* player = client->GetPlayer();
  8685. player->toggle_character_flag(CF_QUEST_EXPERIENCE_ENABLED);
  8686. player->SetCharSheetChanged(true);
  8687. }
  8688. /*
  8689. Function: Command_Toggle_Roleplaying()
  8690. Purpose : Toggles player Roleplaying flag
  8691. Params :
  8692. Dev : paulgh
  8693. Example : /role
  8694. */
  8695. void Commands::Command_Toggle_Roleplaying(Client* client)
  8696. {
  8697. Player* player = client->GetPlayer();
  8698. player->toggle_character_flag(CF_ROLEPLAYING);
  8699. client->Message(CHANNEL_COLOR_YELLOW,"You are %s roleplaying.", player->get_character_flag(CF_ROLEPLAYING)?"now":"no longer");
  8700. if (player->get_character_flag(CF_ROLEPLAYING))
  8701. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ROLEPLAYING);
  8702. else
  8703. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ROLEPLAYING);
  8704. }
  8705. void Commands::Command_Toggle_Duels(Client* client)
  8706. {
  8707. Player* player = client->GetPlayer();
  8708. player->toggle_character_flag(CF_ALLOW_DUEL_INVITES);
  8709. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting duel invites.", player->get_character_flag(CF_ALLOW_DUEL_INVITES)?"now":"no longer");
  8710. }
  8711. void Commands::Command_Toggle_Trades(Client* client)
  8712. {
  8713. Player* player = client->GetPlayer();
  8714. player->toggle_character_flag(CF_ALLOW_TRADE_INVITES);
  8715. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting trade invites.", player->get_character_flag(CF_ALLOW_TRADE_INVITES)?"now":"no longer");
  8716. }
  8717. void Commands::Command_Toggle_Guilds(Client* client)
  8718. {
  8719. Player* player = client->GetPlayer();
  8720. player->toggle_character_flag(CF_ALLOW_GUILD_INVITES);
  8721. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting guild invites.", player->get_character_flag(CF_ALLOW_GUILD_INVITES)?"now":"no longer");
  8722. }
  8723. void Commands::Command_Toggle_Groups(Client* client)
  8724. {
  8725. Player* player = client->GetPlayer();
  8726. player->toggle_character_flag(CF_ALLOW_GROUP_INVITES);
  8727. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting group invites.", player->get_character_flag(CF_ALLOW_GROUP_INVITES)?"now":"no longer");
  8728. }
  8729. void Commands::Command_Toggle_Raids(Client* client)
  8730. {
  8731. Player* player = client->GetPlayer();
  8732. player->toggle_character_flag(CF_ALLOW_RAID_INVITES);
  8733. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting raid invites.", player->get_character_flag(CF_ALLOW_RAID_INVITES)?"now":"no longer");
  8734. }
  8735. void Commands::Command_Toggle_LON(Client* client)
  8736. {
  8737. Player* player = client->GetPlayer();
  8738. player->toggle_character_flag(CF2_ALLOW_LON_INVITES);
  8739. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting LoN invites.", player->get_character_flag(CF2_ALLOW_LON_INVITES)?"now":"no longer");
  8740. }
  8741. void Commands::Command_Toggle_VoiceChat(Client* client)
  8742. {
  8743. Player* player = client->GetPlayer();
  8744. player->toggle_character_flag(CF2_ALLOW_VOICE_INVITES);
  8745. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting voice chat invites.", player->get_character_flag(CF2_ALLOW_VOICE_INVITES)?"now":"no longer");
  8746. }
  8747. /*
  8748. Function: Command_TradeStart()
  8749. Purpose : Starts item/coin trade between players
  8750. Params :
  8751. Dev :
  8752. Example :
  8753. */
  8754. #include "../Trade.h"
  8755. void Commands::Command_TradeStart(Client* client, Seperator* sep)
  8756. {
  8757. PrintSep(sep, "COMMAND_START_TRADE");
  8758. Entity* trader = client->GetPlayer();
  8759. Entity* trader2 = 0;
  8760. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  8761. Spawn* spawn = client->GetPlayer()->GetSpawnWithPlayerID(atoi(sep->arg[0]));
  8762. if (spawn) {
  8763. if (spawn->IsEntity())
  8764. trader2 = (Entity*)spawn;
  8765. }
  8766. }
  8767. else if (client->GetPlayer()->GetTarget()) {
  8768. if (client->GetPlayer()->GetTarget()->IsEntity())
  8769. trader2 = (Entity*)client->GetPlayer()->GetTarget();
  8770. }
  8771. // can only trade with player or bots
  8772. if (trader && trader2) {
  8773. if (trader == trader2) {
  8774. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade with yourself.");
  8775. }
  8776. else if (trader2->IsPlayer() || trader2->IsBot()) {
  8777. LogWrite(PLAYER__ERROR, 0, "Trade", "creating trade");
  8778. if (trader->trade)
  8779. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are already trading.");
  8780. else if (trader2->trade)
  8781. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is already trading.");
  8782. else {
  8783. Trade* trade = new Trade(trader, trader2);
  8784. trader->trade = trade;
  8785. trader2->trade = trade;
  8786. }
  8787. }
  8788. else {
  8789. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can only trade with another player or a bot.");
  8790. }
  8791. }
  8792. else
  8793. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to find target");
  8794. }
  8795. /*
  8796. Function: Command_Track()
  8797. Purpose : Starts/Stops Tracking for a player
  8798. Params :
  8799. Dev : Scatman
  8800. Example : /track
  8801. */
  8802. void Commands::Command_Track(Client* client)
  8803. {
  8804. if (!client->GetPlayer()->GetIsTracking())
  8805. client->GetPlayer()->GetZone()->AddPlayerTracking(client->GetPlayer());
  8806. else
  8807. client->GetPlayer()->GetZone()->RemovePlayerTracking(client->GetPlayer(), TRACKING_STOP);
  8808. }
  8809. /*
  8810. Function: Command_TradeAccept()
  8811. Purpose : Accepts item/coin trade between players
  8812. Params :
  8813. Dev :
  8814. Example :
  8815. */
  8816. void Commands::Command_TradeAccept(Client* client, Seperator* sep)
  8817. {
  8818. PrintSep(sep, "COMMAND_ACCEPT_TRADE");
  8819. Trade* trade = client->GetPlayer()->trade;
  8820. if (trade) {
  8821. bool trade_complete = trade->SetTradeAccepted(client->GetPlayer());
  8822. if (trade_complete)
  8823. safe_delete(trade);
  8824. }
  8825. else
  8826. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8827. }
  8828. /*
  8829. Function: Command_TradeReject()
  8830. Purpose : Rejects item/coin trade between players
  8831. Params :
  8832. Dev :
  8833. Example :
  8834. */
  8835. void Commands::Command_TradeReject(Client* client, Seperator* sep)
  8836. {
  8837. PrintSep(sep, "COMMAND_REJECT_TRADE");
  8838. Command_TradeCancel(client, sep);
  8839. }
  8840. /*
  8841. Function: Command_TradeCancel()
  8842. Purpose : Cancels item/coin trade between players
  8843. Params :
  8844. Dev :
  8845. Example :
  8846. */
  8847. void Commands::Command_TradeCancel(Client* client, Seperator* sep)
  8848. {
  8849. PrintSep(sep, "COMMAND_CANCEL_TRADE");
  8850. Trade* trade = client->GetPlayer()->trade;
  8851. if (trade) {
  8852. trade->CancelTrade(client->GetPlayer());
  8853. safe_delete(trade);
  8854. }
  8855. else
  8856. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8857. }
  8858. /*
  8859. Function: Command_TradeSetCoin()
  8860. Purpose : Sets coin trade between players
  8861. Params :
  8862. Dev :
  8863. Example :
  8864. */
  8865. void Commands::Command_TradeSetCoin(Client* client, Seperator* sep)
  8866. {
  8867. PrintSep(sep, "COMMAND_SET_TRADE_COIN");
  8868. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Set Trade Coin");
  8869. client->Message(CHANNEL_COLOR_YELLOW, "You cannot trade with other players (Not Implemented)");
  8870. }
  8871. /*
  8872. Function: Command_TradeAddCoin()
  8873. Purpose : Adds coin to trade between players
  8874. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  8875. Dev :
  8876. Example :
  8877. */
  8878. void Commands::Command_TradeAddCoin(Client* client, Seperator* sep, int handler)
  8879. {
  8880. PrintSep(sep, "COMMAND_ADD_TRADE_{coin type}");
  8881. Trade* trade = client->GetPlayer()->trade;
  8882. if (trade) {
  8883. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  8884. int32 amount = atoi(sep->arg[0]);
  8885. int64 val = 0;
  8886. switch (handler) {
  8887. case COMMAND_ADD_TRADE_COPPER:
  8888. {
  8889. val = amount;
  8890. trade->AddCoinToTrade(client->GetPlayer(), val);
  8891. break;
  8892. }
  8893. case COMMAND_ADD_TRADE_SILVER:
  8894. {
  8895. val = amount * 100;
  8896. trade->AddCoinToTrade(client->GetPlayer(), val);
  8897. break;
  8898. }
  8899. case COMMAND_ADD_TRADE_GOLD:
  8900. {
  8901. val = amount * 10000;
  8902. trade->AddCoinToTrade(client->GetPlayer(), val);
  8903. break;
  8904. }
  8905. case COMMAND_ADD_TRADE_PLAT:
  8906. {
  8907. val = amount * 1000000;
  8908. trade->AddCoinToTrade(client->GetPlayer(), val);
  8909. break;
  8910. }
  8911. default:
  8912. {
  8913. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  8914. break;
  8915. }
  8916. }
  8917. }
  8918. else
  8919. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount.");
  8920. }
  8921. else
  8922. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8923. }
  8924. /*
  8925. Function: Command_TradeRemoveCoin()
  8926. Purpose : Removes coin from trade between players
  8927. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  8928. Dev :
  8929. Example :
  8930. */
  8931. void Commands::Command_TradeRemoveCoin(Client* client, Seperator* sep, int handler)
  8932. {
  8933. PrintSep(sep, "COMMAND_REMOVE_TRADE_{coin type}");
  8934. Trade* trade = client->GetPlayer()->trade;
  8935. if (trade) {
  8936. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  8937. int32 amount = atoi(sep->arg[0]);
  8938. int64 val = 0;
  8939. switch (handler) {
  8940. case COMMAND_REMOVE_TRADE_COPPER:
  8941. {
  8942. val = amount;
  8943. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  8944. break;
  8945. }
  8946. case COMMAND_REMOVE_TRADE_SILVER:
  8947. {
  8948. val = amount * 100;
  8949. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  8950. break;
  8951. }
  8952. case COMMAND_REMOVE_TRADE_GOLD:
  8953. {
  8954. val = amount * 10000;
  8955. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  8956. break;
  8957. }
  8958. case COMMAND_REMOVE_TRADE_PLAT:
  8959. {
  8960. val = amount * 1000000;
  8961. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  8962. break;
  8963. }
  8964. default:
  8965. {
  8966. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  8967. break;
  8968. }
  8969. }
  8970. }
  8971. else
  8972. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount");
  8973. }
  8974. else
  8975. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8976. }
  8977. /*
  8978. Function: Command_TradeAddItem()
  8979. Purpose : Adds item to trade between players
  8980. Params :
  8981. Dev :
  8982. Example :
  8983. */
  8984. void Commands::Command_TradeAddItem(Client* client, Seperator* sep)
  8985. {
  8986. PrintSep(sep, "COMMAND_ADD_TRADE_ITEM");
  8987. /*
  8988. arg[0] = item index
  8989. arg[1] = slot
  8990. arg[2] = quantity
  8991. */
  8992. if (!client->GetPlayer()->trade) {
  8993. LogWrite(PLAYER__ERROR, 0, "Trade", "Player is not currently trading.");
  8994. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8995. return;
  8996. }
  8997. if (sep && sep->IsSet(0) && sep->IsNumber(0) && sep->IsSet(1) && sep->IsNumber(1) && sep->IsSet(2) && sep->IsNumber(2)) {
  8998. Item* item = 0;
  8999. int32 index = atoi(sep->arg[0]);
  9000. item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(index);
  9001. if (item) {
  9002. int8 result = client->GetPlayer()->trade->AddItemToTrade(client->GetPlayer(), item, atoi(sep->arg[2]), atoi(sep->arg[1]));
  9003. if (result == 1)
  9004. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Item is already being traded.");
  9005. else if (result == 2)
  9006. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade NO-TRADE items.");
  9007. else if (result == 3)
  9008. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade HEIRLOOM items.");
  9009. else if (result == 255)
  9010. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown error trying to add the item to the trade...");
  9011. }
  9012. else {
  9013. LogWrite(PLAYER__ERROR, 0, "Trade", "Unable to get an item for the player (%s) from the index (%u)", client->GetPlayer()->GetName(), index);
  9014. client->Message(CHANNEL_ERROR, "Unable to find item at index %u", index);
  9015. }
  9016. }
  9017. else
  9018. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  9019. }
  9020. /*
  9021. Function: Command_TradeRemoveItem()
  9022. Purpose : Removes item from trade between players
  9023. Params :
  9024. Dev :
  9025. Example :
  9026. */
  9027. void Commands::Command_TradeRemoveItem(Client* client, Seperator* sep)
  9028. {
  9029. PrintSep(sep, "COMMAND_REMOVE_TRADE_ITEM");
  9030. /*
  9031. arg[0] = trade window slot
  9032. */
  9033. Trade* trade = client->GetPlayer()->trade;
  9034. if (trade) {
  9035. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  9036. trade->RemoveItemFromTrade(client->GetPlayer(), atoi(sep->arg[0]));
  9037. }
  9038. else
  9039. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  9040. }
  9041. else
  9042. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  9043. }
  9044. void Commands::Command_TryOn(Client* client, Seperator* sep)
  9045. {
  9046. Item *item = 0;
  9047. sint32 crc;
  9048. if (sep) {
  9049. // 1096+ sends more info so need to do a version check so older clients (SF) still work
  9050. if (client->GetVersion() < 1096) {
  9051. if (sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2))
  9052. {
  9053. item = master_item_list.GetItem(atoul(sep->arg[1]));
  9054. crc = atol(sep->arg[2]);
  9055. }
  9056. }
  9057. else {
  9058. // From the broker and links in chat
  9059. if (strcmp(sep->arg[0], "crc") == 0) {
  9060. if (sep->IsNumber(2) && sep->IsNumber(3)) {
  9061. item = master_item_list.GetItem(atoul(sep->arg[2]));
  9062. crc = atol(sep->arg[3]);
  9063. }
  9064. }
  9065. // From inventory
  9066. if (strcmp(sep->arg[0], "dbid") == 0) {
  9067. if (sep->IsNumber(2) && sep->IsNumber(4)) {
  9068. item = master_item_list.GetItem(atoul(sep->arg[2]));
  9069. crc = atol(sep->arg[4]);
  9070. }
  9071. }
  9072. }
  9073. if (item)
  9074. client->ShowDressingRoom(item, crc);
  9075. }
  9076. }
  9077. void Commands::Command_JoinChannel(Client * client, Seperator *sep) {
  9078. const char *channel_name, *password = NULL;
  9079. if (sep == NULL || !sep->IsSet(0)) {
  9080. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /joinchannel <channel name> [password]");
  9081. return;
  9082. }
  9083. channel_name = sep->arg[0];
  9084. if (sep->IsSet(1))
  9085. password = sep->arg[1];
  9086. if (!chat.ChannelExists(channel_name) && !chat.CreateChannel(channel_name, password)) {
  9087. client->Message(CHANNEL_COLOR_RED, "Unable to create channel '%s'.", channel_name);
  9088. return;
  9089. }
  9090. if (chat.IsInChannel(client, channel_name)) {
  9091. client->Message(CHANNEL_NARRATIVE, "You are already in '%s'.", channel_name);
  9092. return;
  9093. }
  9094. if (chat.HasPassword(channel_name)) {
  9095. if (password == NULL) {
  9096. client->Message(CHANNEL_NARRATIVE, "Unable to join '%s': That channel is password protected.", channel_name);
  9097. return;
  9098. }
  9099. if (!chat.PasswordMatches(channel_name, password)) {
  9100. client->Message(CHANNEL_NARRATIVE, "Unable to join '%s': The password is not correc.t", channel_name);
  9101. return;
  9102. }
  9103. }
  9104. if (!chat.JoinChannel(client, channel_name))
  9105. client->Message(CHANNEL_COLOR_RED, "There was an internal error preventing you from joining '%s'.", channel_name);
  9106. }
  9107. void Commands::Command_JoinChannelFromLoad(Client * client, Seperator *sep) {
  9108. printf("ScatDebug: Received 'joinfromchannel', using the same function as 'joinchannel' (not sure what the difference is)\n");
  9109. Command_JoinChannel(client, sep);
  9110. }
  9111. void Commands::Command_TellChannel(Client *client, Seperator *sep) {
  9112. if (sep == NULL || !sep->IsSet(0) || !sep->IsSet(1)) {
  9113. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /tellchannel <channel name> <message>");
  9114. PrintSep(sep, "tellchannel");
  9115. return;
  9116. }
  9117. chat.TellChannel(client, sep->arg[0], sep->argplus[1]);
  9118. }
  9119. void Commands::Command_Test(Client* client, EQ2_16BitString* command_parms) {
  9120. Seperator* sep = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  9121. if (sep->IsSet(0)) {
  9122. if (atoi(sep->arg[0]) == 1) {
  9123. PacketStruct* packet2 = configReader.getStruct("WS_SpellGainedMsg", client->GetVersion());
  9124. if (packet2) {
  9125. packet2->setDataByName("spell_type", 2);
  9126. packet2->setDataByName("spell_id", 8308);
  9127. packet2->setDataByName("spell_name", "Sprint");
  9128. packet2->setDataByName("add_silently", 0);
  9129. packet2->setDataByName("tier", 1);
  9130. packet2->setDataByName("blah1", 1);
  9131. packet2->setDataByName("blah2", 1);
  9132. EQ2Packet* outapp = packet2->serialize();
  9133. DumpPacket(outapp);
  9134. client->QueuePacket(outapp);
  9135. safe_delete(packet2);
  9136. }
  9137. }
  9138. else if (atoi(sep->arg[0]) == 2) {
  9139. PacketStruct* packet2 = configReader.getStruct("WS_GuildUpdate", client->GetVersion());
  9140. if (packet2) {
  9141. packet2->setDataByName("guild_name", "Test");
  9142. packet2->setDataByName("guild_motd", "Test MOTD");
  9143. packet2->setDataByName("guild_id", 1234);
  9144. packet2->setDataByName("guild_level", 1);
  9145. packet2->setDataByName("unknown", 2);
  9146. packet2->setDataByName("unknown2", 3);
  9147. packet2->setDataByName("exp_current", 1);
  9148. packet2->setDataByName("exp_to_next_level", 4);
  9149. EQ2Packet* outapp = packet2->serialize();
  9150. DumpPacket(outapp);
  9151. client->QueuePacket(outapp);
  9152. safe_delete(packet2);
  9153. }
  9154. }
  9155. else if (atoi(sep->arg[0]) == 3) {
  9156. PacketStruct* packet2 = configReader.getStruct("WS_JoinGuildNotify", client->GetVersion());
  9157. if (packet2) {
  9158. packet2->setDataByName("guild_id", 1234);
  9159. packet2->setDataByName("character_id", 1);
  9160. packet2->setDataByName("account_id", 2);
  9161. packet2->setDataByName("guild_level", 1);
  9162. packet2->setDataByName("name", "Test");
  9163. packet2->setDataByName("unknown2", 0);
  9164. packet2->setDataByName("unknown3", 1);
  9165. packet2->setDataByName("adventure_class", 6);
  9166. packet2->setDataByName("adventure_level", 7);
  9167. packet2->setDataByName("tradeskill_class", 4);
  9168. packet2->setDataByName("tradeskill_level", 5);
  9169. packet2->setDataByName("rank", 0);
  9170. packet2->setDataByName("member_flags", 2);
  9171. packet2->setDataByName("join_date", 1591112273);
  9172. packet2->setDataByName("guild_status", 2);
  9173. packet2->setDataByName("last_login", 1591132273);
  9174. packet2->setDataByName("recruiter_id", 1);
  9175. packet2->setDataByName("points", 2345);
  9176. packet2->setDataByName("note", "note");
  9177. packet2->setMediumStringByName("officer_note", "O note");
  9178. packet2->setMediumStringByName("zone", "Blah");
  9179. EQ2Packet* outapp = packet2->serialize();
  9180. DumpPacket(outapp);
  9181. client->QueuePacket(outapp);
  9182. safe_delete(packet2);
  9183. }
  9184. }
  9185. else if (atoi(sep->arg[0]) == 5) {
  9186. int16 offset = atoi(sep->arg[1]);
  9187. int32 value1 = atol(sep->arg[2]);
  9188. EQ2Packet* outapp = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion(), offset, value1);
  9189. client->QueuePacket(outapp);
  9190. }
  9191. else if (atoi(sep->arg[0]) == 6) {
  9192. Spawn* spawn = client->GetPlayer()->GetTarget();
  9193. if (!spawn)
  9194. spawn = client->GetPlayer();
  9195. else if (spawn->IsEntity())
  9196. ((Entity*)spawn)->SetSpeed(atof(sep->arg[4]));
  9197. spawn->RunToLocation(atof(sep->arg[1]), atof(sep->arg[2]), atof(sep->arg[3]));
  9198. }
  9199. else if (atoi(sep->arg[0]) == 7) {
  9200. int32 id = 0;
  9201. Spawn* spawn = client->GetCurrentZone()->GetSpawn(7720001);
  9202. if (spawn) {
  9203. spawn->SetX(client->GetPlayer()->GetX() + .5, false);
  9204. spawn->SetY(client->GetPlayer()->GetY(), false);
  9205. spawn->SetZ(client->GetPlayer()->GetZ() + .5, false);
  9206. float heading = client->GetPlayer()->GetHeading() + 180;
  9207. if (heading > 360)
  9208. heading -= 360;
  9209. spawn->SetLevel(5);
  9210. spawn->SetAdventureClass(4);
  9211. spawn->SetHeading(heading, false);
  9212. spawn->SetSpawnOrigX(spawn->GetX());
  9213. spawn->SetSpawnOrigY(spawn->GetY());
  9214. spawn->SetSpawnOrigZ(spawn->GetZ());
  9215. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  9216. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  9217. spawn->appearance.targetable = 1;
  9218. if (spawn->IsNPC() && spawn->GetTotalHP() == 0) {
  9219. spawn->SetTotalHP(spawn->GetLevel() * 15);
  9220. spawn->SetHP(spawn->GetTotalHP());
  9221. }
  9222. if (spawn->GetTotalPower() == 0) {
  9223. spawn->SetTotalPower(spawn->GetLevel() * 15);
  9224. spawn->SetPower(spawn->GetTotalPower());
  9225. }
  9226. int16 offset = atoi(sep->arg[1]);
  9227. int32 value1 = atol(sep->arg[2]);
  9228. sprintf(spawn->appearance.name, "Offset %i", offset);
  9229. EQ2Packet* ret = spawn->spawn_serialize(client->GetPlayer(), client->GetVersion(), offset, value1);
  9230. DumpPacket(ret);
  9231. client->QueuePacket(ret);
  9232. }
  9233. }
  9234. else if (atoi(sep->arg[0]) == 8) {
  9235. int32 id = atoi(sep->arg[1]);
  9236. Spawn* spawn = client->GetCurrentZone()->GetSpawn(id);
  9237. if (spawn) {
  9238. spawn->SetX(client->GetPlayer()->GetX() + .5, false);
  9239. spawn->SetY(client->GetPlayer()->GetY(), false);
  9240. spawn->SetZ(client->GetPlayer()->GetZ() + .5, false);
  9241. float heading = client->GetPlayer()->GetHeading() + 180;
  9242. if (heading > 360)
  9243. heading -= 360;
  9244. spawn->SetLevel(5);
  9245. spawn->SetAdventureClass(4);
  9246. spawn->SetHeading(heading, false);
  9247. spawn->SetSpawnOrigX(spawn->GetX());
  9248. spawn->SetSpawnOrigY(spawn->GetY());
  9249. spawn->SetSpawnOrigZ(spawn->GetZ());
  9250. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  9251. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  9252. spawn->appearance.targetable = 1;
  9253. if (spawn->IsNPC() && spawn->GetTotalHP() == 0) {
  9254. spawn->SetTotalHP(spawn->GetLevel() * 15);
  9255. spawn->SetHP(spawn->GetTotalHP());
  9256. }
  9257. if (spawn->GetTotalPower() == 0) {
  9258. spawn->SetTotalPower(spawn->GetLevel() * 15);
  9259. spawn->SetPower(spawn->GetTotalPower());
  9260. }
  9261. int16 offset = atoi(sep->arg[2]);
  9262. int16 offset2 = atoi(sep->arg[3]);
  9263. int32 value1 = atol(sep->arg[4]);
  9264. int16 offset3 = 0;
  9265. int16 offset4 = 0;
  9266. int32 value2 = 0;
  9267. if (sep->IsSet(7)) {
  9268. offset3 = atoi(sep->arg[5]);
  9269. offset4 = atoi(sep->arg[6]);
  9270. value2 = atol(sep->arg[7]);
  9271. }
  9272. sprintf(spawn->appearance.name, "Offset %i to %i", offset, offset2);
  9273. spawn->AddPrimaryEntityCommand("attack", 10000, "attack","", 0, 0);
  9274. EQ2Packet* ret = spawn->spawn_serialize(client->GetPlayer(), client->GetVersion(), offset, value1, offset2, offset3, offset4, value2);
  9275. DumpPacket(ret);
  9276. client->QueuePacket(ret);
  9277. }
  9278. }
  9279. else if (atoi(sep->arg[0]) == 9) {
  9280. PacketStruct* packet2 = configReader.getStruct("WS_DeathWindow", client->GetVersion());
  9281. if (packet2) {
  9282. packet2->setArrayLengthByName("location_count", 1);
  9283. packet2->setArrayDataByName("location_ida", 1234);
  9284. packet2->setArrayDataByName("unknown2a", 3);
  9285. packet2->setArrayDataByName("zone_name", "Queen's Colony");
  9286. packet2->setArrayDataByName("location_name", "Myrrin's Tower");
  9287. packet2->setArrayDataByName("distance", 134);
  9288. EQ2Packet* app = packet2->serialize();
  9289. if (sep->IsSet(2)) {
  9290. int8 offset = atoi(sep->arg[1]);
  9291. uchar* ptr2 = app->pBuffer;
  9292. ptr2 += offset;
  9293. if (sep->IsNumber(2)) {
  9294. int32 value1 = atol(sep->arg[2]);
  9295. if (value1 > 0xFFFF)
  9296. memcpy(ptr2, (uchar*)&value1, 4);
  9297. else if (value1 > 0xFF)
  9298. memcpy(ptr2, (uchar*)&value1, 2);
  9299. else
  9300. memcpy(ptr2, (uchar*)&value1, 1);
  9301. }
  9302. else {
  9303. int8 len = strlen(sep->arg[2]);
  9304. memcpy(ptr2, (uchar*)&len, 1);
  9305. ptr2 += 1;
  9306. memcpy(ptr2, sep->arg[2], len);
  9307. }
  9308. }
  9309. DumpPacket(app);
  9310. client->QueuePacket(app);
  9311. safe_delete(packet2);
  9312. }
  9313. }
  9314. else if (atoi(sep->arg[0]) == 10) {
  9315. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalUpdate", client->GetVersion());
  9316. if (packet2) {
  9317. packet2->setArrayLengthByName("num_quests", 1);
  9318. packet2->setArrayDataByName("active", 1);
  9319. packet2->setArrayDataByName("name", "Tasks aboard the Far Journey");
  9320. packet2->setArrayDataByName("quest_type", "Hallmark");
  9321. packet2->setArrayDataByName("quest_zone", "Hallmark");
  9322. packet2->setArrayDataByName("journal_updated", 1);
  9323. packet2->setArrayDataByName("quest_id", 524);
  9324. packet2->setArrayDataByName("day", 19);
  9325. packet2->setArrayDataByName("month", 6);
  9326. packet2->setArrayDataByName("year", 20);
  9327. packet2->setArrayDataByName("level", 2);
  9328. packet2->setArrayDataByName("encounter_level", 4);
  9329. packet2->setArrayDataByName("difficulty", 3);
  9330. packet2->setArrayDataByName("visible", 1);
  9331. packet2->setDataByName("visible_quest_id", 524);
  9332. packet2->setDataByName("player_crc", 2900677088);
  9333. packet2->setDataByName("player_name", "LethalEncounter");
  9334. EQ2Packet* app = packet2->serialize();
  9335. if (sep->IsSet(2)) {
  9336. int8 offset = atoi(sep->arg[1]);
  9337. uchar* ptr2 = app->pBuffer;
  9338. ptr2 += offset;
  9339. if (sep->IsNumber(2)) {
  9340. int32 value1 = atol(sep->arg[2]);
  9341. if (value1 > 0xFFFF)
  9342. memcpy(ptr2, (uchar*)&value1, 4);
  9343. else if (value1 > 0xFF)
  9344. memcpy(ptr2, (uchar*)&value1, 2);
  9345. else
  9346. memcpy(ptr2, (uchar*)&value1, 1);
  9347. }
  9348. else {
  9349. int8 len = strlen(sep->arg[2]);
  9350. memcpy(ptr2, (uchar*)&len, 1);
  9351. ptr2 += 1;
  9352. memcpy(ptr2, sep->arg[2], len);
  9353. }
  9354. }
  9355. DumpPacket(app);
  9356. client->QueuePacket(app);
  9357. safe_delete(packet2);
  9358. }
  9359. }
  9360. else if (atoi(sep->arg[0]) == 11) {
  9361. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalReply", client->GetVersion());
  9362. if (packet2) {
  9363. packet2->setDataByName("quest_id", 524);
  9364. packet2->setDataByName("player_crc", 2900677088);
  9365. packet2->setDataByName("name", "Tasks aboard the Far Journey");
  9366. packet2->setDataByName("description", "I completed all the tasks assigned to me by Captain Varlos aboard the Far Journey");
  9367. packet2->setDataByName("type", "Hallmark");
  9368. packet2->setDataByName("complete_header", "To complete this quest, I must do the following tasks:");
  9369. packet2->setDataByName("day", 19);
  9370. packet2->setDataByName("month", 6);
  9371. packet2->setDataByName("year", 20);
  9372. packet2->setDataByName("level", 1);
  9373. packet2->setDataByName("encounter_level", 1);
  9374. packet2->setDataByName("difficulty", 1);
  9375. packet2->setDataByName("time_obtained", Timer::GetUnixTimeStamp());
  9376. //packet2->setDataByName("timer_start", Timer::GetUnixTimeStamp());
  9377. //packet2->setDataByName("timer_duration", 300);
  9378. //packet2->setDataByName("timer_running", 1);
  9379. packet2->setArrayLengthByName("task_groups_completed", 9);
  9380. packet2->setArrayLengthByName("num_task_groups", 10);
  9381. packet2->setArrayDataByName("task_group", "I spoke to Waulon as Captain Varlos had asked of me.");
  9382. packet2->setArrayDataByName("task_group", "I found Waulon's hat in one of the boxes.", 1);
  9383. packet2->setArrayDataByName("task_group", "I returned Waulon's hat.", 2);
  9384. packet2->setArrayDataByName("task_group", "I have spoken to Ingrid.", 3);
  9385. packet2->setArrayDataByName("task_group", "I purchased a Shard of Luclin.", 4);
  9386. packet2->setArrayDataByName("task_group", "I gave the Shard of Luclin to Ingrid.", 5);
  9387. packet2->setArrayDataByName("task_group", "I have spoken to Captain Varlos.", 6);
  9388. packet2->setArrayDataByName("task_group", "I killed the rats that Captain Varlos requested.", 7);
  9389. packet2->setArrayDataByName("task_group", "Captain Varlos has ordered you to kill the escaped goblin.", 8);
  9390. packet2->setArrayDataByName("task_group", "I killed the escaped goblin.", 9);
  9391. /*packet2->setSubArrayLengthByName("num_tasks", 1);
  9392. packet2->setSubArrayDataByName("task", "I need to talk to Garven Tralk");
  9393. packet2->setSubArrayLengthByName("num_updates", 1);
  9394. packet2->setSubArrayDataByName("update_currentval", 0);
  9395. packet2->setSubArrayDataByName("update_maxval", 1);
  9396. packet2->setSubArrayDataByName("icon", 11);
  9397. */
  9398. packet2->setArrayDataByName("waypoint", 0xFFFFFFFF);
  9399. packet2->setDataByName("journal_updated", 1);
  9400. packet2->setDataByName("bullets", 1);
  9401. EQ2Packet* app = packet2->serialize();
  9402. if (sep->IsSet(2)) {
  9403. int16 offset = atoi(sep->arg[1]);
  9404. uchar* ptr2 = app->pBuffer;
  9405. ptr2 += offset;
  9406. if (sep->IsNumber(2)) {
  9407. int32 value1 = atol(sep->arg[2]);
  9408. if (value1 > 0xFFFF)
  9409. memcpy(ptr2, (uchar*)&value1, 4);
  9410. else if (value1 > 0xFF)
  9411. memcpy(ptr2, (uchar*)&value1, 2);
  9412. else
  9413. memcpy(ptr2, (uchar*)&value1, 1);
  9414. }
  9415. else {
  9416. int16 len = strlen(sep->arg[2]);
  9417. memcpy(ptr2, (uchar*)&len, 2);
  9418. ptr2 += 2;
  9419. memcpy(ptr2, sep->arg[2], len);
  9420. }
  9421. }
  9422. DumpPacket(app);
  9423. client->QueuePacket(app);
  9424. safe_delete(packet2);
  9425. }
  9426. }
  9427. else if (atoi(sep->arg[0]) == 12) {
  9428. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalReply", client->GetVersion());
  9429. if (packet2) {
  9430. packet2->setDataByName("quest_id", 524);
  9431. packet2->setDataByName("player_crc", 2900677088);
  9432. packet2->setDataByName("name", "Archetype Selection");
  9433. packet2->setDataByName("description", "I have reported my profession to Garven Tralk.");
  9434. packet2->setDataByName("type", "Hallmark");
  9435. packet2->setDataByName("complete_header", "To complete this quest, I must do the following tasks:");
  9436. packet2->setDataByName("day", 19);
  9437. packet2->setDataByName("month", 6);
  9438. packet2->setDataByName("year", 20);
  9439. packet2->setDataByName("level", 2);
  9440. packet2->setDataByName("encounter_level", 4);
  9441. packet2->setDataByName("difficulty", 3);
  9442. packet2->setDataByName("time_obtained", Timer::GetUnixTimeStamp());
  9443. packet2->setDataByName("timer_start", Timer::GetUnixTimeStamp());
  9444. packet2->setDataByName("timer_duration", 300);
  9445. packet2->setDataByName("timer_running", 1);
  9446. packet2->setArrayLengthByName("task_groups_completed", 0);
  9447. packet2->setArrayLengthByName("num_task_groups", 1);
  9448. packet2->setArrayDataByName("task_group", "I need to talk to Garven Tralk");
  9449. packet2->setSubArrayLengthByName("num_tasks", 1);
  9450. packet2->setSubArrayDataByName("task", "I need to talk to Garven Tralk");
  9451. packet2->setSubArrayLengthByName("num_updates", 1);
  9452. packet2->setSubArrayDataByName("update_currentval", 0);
  9453. packet2->setSubArrayDataByName("update_maxval", 1);
  9454. packet2->setSubArrayDataByName("icon", 11);
  9455. packet2->setArrayDataByName("waypoint", 0xFFFFFFFF);
  9456. packet2->setDataByName("journal_updated", 1);
  9457. packet2->setSubstructDataByName("reward_data", "unknown1", 255);
  9458. packet2->setSubstructDataByName("reward_data", "reward", "Quest Reward!");
  9459. packet2->setSubstructDataByName("reward_data", "unknown2", 0x3f);
  9460. packet2->setSubstructDataByName("reward_data", "coin", 150);
  9461. packet2->setSubstructDataByName("reward_data", "status_points", 5);
  9462. packet2->setSubstructDataByName("reward_data", "exp_bonus", 10);
  9463. packet2->setSubstructArrayLengthByName("reward_data", "num_rewards", 1);
  9464. packet2->setSubstructArrayDataByName("reward_data", "reward_id", 123);
  9465. Item* item = master_item_list.GetItem(152755);
  9466. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9467. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  9468. /*packet2->setSubstructDataByName("item", "unique_id", 567);
  9469. packet2->setSubstructDataByName("item", "broker_item_id", 0xFFFFFFFFFFFFFFFF);
  9470. packet2->setSubstructDataByName("item", "icon", 0xe7);
  9471. packet2->setSubstructDataByName("item", "tier", 4);
  9472. packet2->setSubstructDataByName("item", "flags", 0x60);
  9473. packet2->setSubstructArrayLengthByName("item", "stat_count", 1);
  9474. packet2->setSubstructDataByName("item", "stat_type", 1);
  9475. packet2->setSubstructDataByName("item", "stat_subtype", 2);
  9476. packet2->setSubstructDataByName("item", "value", 3);
  9477. packet2->setSubstructDataByName("item", "condition", 100);
  9478. packet2->setSubstructDataByName("item", "weight", 1);
  9479. packet2->setSubstructDataByName("item", "skill_req1", 0xacafa99e);
  9480. packet2->setSubstructDataByName("item", "skill_req2", 0xacafa99e);
  9481. packet2->setSubstructDataByName("item", "skill_min", 1);
  9482. packet2->setSubstructArrayLengthByName("item", "class_count", 3);
  9483. packet2->setSubstructDataByName("item", "adventure_class", 1);
  9484. packet2->setSubstructDataByName("item", "adventure_class", 11, 0, 1);
  9485. packet2->setSubstructDataByName("item", "adventure_class", 0x1f, 0, 2);
  9486. packet2->setSubstructDataByName("item", "tradeskill_class", 255);
  9487. packet2->setSubstructDataByName("item", "tradeskill_class", 255, 0, 1);
  9488. packet2->setSubstructDataByName("item", "tradeskill_class", 255, 0, 2);
  9489. packet2->setSubstructDataByName("item", "level", 0x1e);
  9490. packet2->setSubstructDataByName("item", "level", 100, 0, 1);
  9491. packet2->setSubstructDataByName("item", "level", 100, 0, 2);
  9492. packet2->setSubstructDataByName("item_footer", "name", "Footman Gloves");*/
  9493. //packet2->PrintPacket();
  9494. EQ2Packet* app = packet2->serialize();
  9495. if (sep->IsSet(2)) {
  9496. int16 offset = atoi(sep->arg[1]);
  9497. uchar* ptr2 = app->pBuffer;
  9498. ptr2 += offset;
  9499. if (sep->IsNumber(2)) {
  9500. int32 value1 = atol(sep->arg[2]);
  9501. if (value1 > 0xFFFF)
  9502. memcpy(ptr2, (uchar*)&value1, 4);
  9503. else if (value1 > 0xFF)
  9504. memcpy(ptr2, (uchar*)&value1, 2);
  9505. else
  9506. memcpy(ptr2, (uchar*)&value1, 1);
  9507. }
  9508. else {
  9509. int16 len = strlen(sep->arg[2]);
  9510. memcpy(ptr2, (uchar*)&len, 2);
  9511. ptr2 += 2;
  9512. memcpy(ptr2, sep->arg[2], len);
  9513. }
  9514. }
  9515. DumpPacket(app);
  9516. client->QueuePacket(app);
  9517. safe_delete(packet2);
  9518. }
  9519. }
  9520. else if (atoi(sep->arg[0]) == 13) {
  9521. PacketStruct* packet2 = configReader.getStruct("WS_OnScreenMsg", client->GetVersion());
  9522. if (packet2 && sep->IsSet(7)) {
  9523. packet2->setDataByName("unknown", atoi(sep->arg[1]));
  9524. char blah[128];
  9525. sprintf(blah, "\\#6EFF6EYou get better at \12\\#C8FFC8%s\\#6EFF6E! (7/15)", sep->arg[2]);
  9526. packet2->setDataByName("text", blah);
  9527. packet2->setDataByName("message_type", sep->arg[3]);
  9528. packet2->setDataByName("size", atof(sep->arg[4]));
  9529. packet2->setDataByName("red", atoi(sep->arg[5]));
  9530. packet2->setDataByName("green", atoi(sep->arg[6]));
  9531. packet2->setDataByName("blue", atoi(sep->arg[7]));
  9532. EQ2Packet* app = packet2->serialize();
  9533. DumpPacket(app);
  9534. client->QueuePacket(app);
  9535. safe_delete(packet2);
  9536. }
  9537. }
  9538. else if (atoi(sep->arg[0]) == 14) {
  9539. PacketStruct* packet2 = configReader.getStruct("WS_InstructionWindow", client->GetVersion());
  9540. if (packet2 && sep->IsSet(3)) {
  9541. packet2->setDataByName("open_seconds_min", atof(sep->arg[1]));
  9542. packet2->setDataByName("open_seconds_max", atof(sep->arg[2]));
  9543. packet2->setDataByName("voice_sync", atoi(sep->arg[3]));
  9544. 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.");
  9545. packet2->setDataByName("voice", "voiceover/english/narrator/boat_06p_tutorial02/narrator_001_63779ca0.mp3");
  9546. packet2->setArrayLengthByName("num_goals", 1);
  9547. //packet2->setArrayDataByName("goal_text", )
  9548. packet2->setSubArrayLengthByName("num_tasks", 1);
  9549. packet2->setSubArrayDataByName("task_text", "continue");
  9550. packet2->setDataByName("complete_sound", "click");
  9551. packet2->setDataByName("signal", "introduction");
  9552. packet2->setDataByName("voice_key1", 0xcda65173);
  9553. packet2->setDataByName("voice_key2", 0x984bfc6d);
  9554. EQ2Packet* app = packet2->serialize();
  9555. DumpPacket(app);
  9556. client->QueuePacket(app);
  9557. safe_delete(packet2);
  9558. packet2 = configReader.getStruct("WS_ShowWindow", client->GetVersion());
  9559. packet2->setDataByName("window", "MainHUD.StartMenu");
  9560. packet2->setDataByName("show", 1);
  9561. app = packet2->serialize();
  9562. DumpPacket(app);
  9563. client->QueuePacket(app);
  9564. safe_delete(packet2);
  9565. packet2 = configReader.getStruct("WS_FlashWindow", client->GetVersion());
  9566. packet2->setDataByName("window", "MainHUD.StartMenu.help");
  9567. packet2->setDataByName("flash_seconds", 10);
  9568. app = packet2->serialize();
  9569. DumpPacket(app);
  9570. client->QueuePacket(app);
  9571. safe_delete(packet2);
  9572. }
  9573. }
  9574. else if (atoi(sep->arg[0]) == 15) {
  9575. PacketStruct* packet2 = configReader.getStruct("WS_UpdateLoot", client->GetVersion());
  9576. if (packet2) {
  9577. packet2->setArrayLengthByName("loot_count", 1);
  9578. packet2->setArrayDataByName("name", "Test");
  9579. packet2->setArrayDataByName("item_id", 1234);
  9580. packet2->setArrayDataByName("count", 1);
  9581. packet2->setArrayDataByName("icon", 258);
  9582. packet2->setArrayDataByName("ability_id", 0xFFFFFFFF);
  9583. Spawn* spawn = client->GetPlayer()->GetTarget();
  9584. if (spawn)
  9585. packet2->setDataByName("object_id", client->GetPlayer()->GetIDWithPlayerSpawn(spawn));
  9586. packet2->setDataByName("unknown3", 1);
  9587. packet2->setDataByName("unknown4", 1);
  9588. packet2->setDataByName("unknown5", 60);
  9589. EQ2Packet* app = packet2->serialize();
  9590. DumpPacket(app);
  9591. client->QueuePacket(app);
  9592. safe_delete(packet2);
  9593. }
  9594. }
  9595. else if (atoi(sep->arg[0]) == 16 && sep->IsNumber(1)) {
  9596. char blah[32];
  9597. sprintf(blah, "Testing: %i", atoi(sep->arg[1]));
  9598. client->SimpleMessage(atoi(sep->arg[1]), blah);
  9599. }
  9600. else if (atoi(sep->arg[0]) == 17 && sep->IsNumber(2)) {
  9601. if (sep->IsSet(2)) {
  9602. int16 offset = atoi(sep->arg[1]);
  9603. if (sep->IsNumber(2)) {
  9604. int32 value1 = atol(sep->arg[2]);
  9605. client->QueuePacket(client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion(), offset, value1));
  9606. cout << "Sent" << endl;
  9607. }
  9608. }
  9609. }
  9610. else if (atoi(sep->arg[0]) == 18) {
  9611. PacketStruct* packet2 = configReader.getStruct("WS_QuestRewardPackMsg", client->GetVersion());
  9612. if (packet2) {
  9613. packet2->setSubstructDataByName("reward_data", "unknown1", 255);
  9614. packet2->setSubstructDataByName("reward_data", "reward", "Quest Reward!");
  9615. packet2->setSubstructDataByName("reward_data", "coin", 150);
  9616. packet2->setSubstructDataByName("reward_data", "status_points", 5);
  9617. packet2->setSubstructDataByName("reward_data", "exp_bonus", 10);
  9618. packet2->setSubstructArrayLengthByName("reward_data", "num_rewards", 4);
  9619. Item* item = new Item(master_item_list.GetItem(36212));
  9620. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9621. item->stack_count = 20;
  9622. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  9623. safe_delete(item);
  9624. item = new Item(master_item_list.GetItem(36685));
  9625. item->stack_count = 20;
  9626. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9627. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 1, 0, -1);
  9628. safe_delete(item);
  9629. item = master_item_list.GetItem(1414);
  9630. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9631. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 2, 0, -1);
  9632. item = master_item_list.GetItem(75057);
  9633. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9634. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 3, 0, -1);
  9635. EQ2Packet* app = packet2->serialize();
  9636. if (sep->IsSet(2)) {
  9637. int16 offset = atoi(sep->arg[1]);
  9638. uchar* ptr2 = app->pBuffer;
  9639. ptr2 += offset;
  9640. if (sep->IsNumber(2)) {
  9641. int32 value1 = atol(sep->arg[2]);
  9642. if (value1 > 0xFFFF)
  9643. memcpy(ptr2, (uchar*)&value1, 4);
  9644. else if (value1 > 0xFF)
  9645. memcpy(ptr2, (uchar*)&value1, 2);
  9646. else
  9647. memcpy(ptr2, (uchar*)&value1, 1);
  9648. }
  9649. else {
  9650. int16 len = strlen(sep->arg[2]);
  9651. memcpy(ptr2, (uchar*)&len, 2);
  9652. ptr2 += 2;
  9653. memcpy(ptr2, sep->arg[2], len);
  9654. }
  9655. }
  9656. DumpPacket(app);
  9657. client->QueuePacket(app);
  9658. safe_delete(packet2);
  9659. }
  9660. }
  9661. else if (atoi(sep->arg[0]) == 19) {
  9662. PacketStruct* packet2 = configReader.getStruct("WS_UpdateLoot", client->GetVersion());
  9663. Spawn* spawn = client->GetPlayer()->GetTarget();
  9664. if (packet2 && spawn) {
  9665. Item* item = master_item_list.GetItem(130053);
  9666. packet2->setArrayLengthByName("loot_count", 1);
  9667. packet2->setArrayDataByName("loot_id", item->details.item_id);
  9668. packet2->setArrayDataByName("unknown2", 1);
  9669. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, 2, true);
  9670. packet2->setDataByName("display", 1);
  9671. packet2->setDataByName("unknown2b", 1);
  9672. packet2->setDataByName("unknown3", 0x3c);
  9673. packet2->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(spawn));
  9674. packet2->PrintPacket();
  9675. EQ2Packet* app = packet2->serialize();
  9676. if (sep->IsSet(2)) {
  9677. int16 offset = atoi(sep->arg[1]);
  9678. int16 offset2 = 0;
  9679. int32 value1 = 0;
  9680. if (sep->IsSet(3)) {
  9681. offset2 = atoi(sep->arg[2]);
  9682. value1 = atol(sep->arg[3]);
  9683. }
  9684. else
  9685. value1 = atol(sep->arg[2]);
  9686. int16 offset3 = 0;
  9687. int16 offset4 = 0;
  9688. int32 value2 = 0;
  9689. if (sep->IsSet(6)) {
  9690. offset3 = atoi(sep->arg[4]);
  9691. offset4 = atoi(sep->arg[5]);
  9692. value2 = atol(sep->arg[6]);
  9693. }
  9694. offset--;
  9695. if (offset2 > 0 && offset2 >= offset) {
  9696. offset2--;
  9697. uchar* ptr2 = app->pBuffer;
  9698. ptr2 += offset;
  9699. for (int i = offset; i <= offset2; i++) {
  9700. if (value1 > 0xFFFF) {
  9701. memcpy(ptr2, (uchar*)&value1, 4);
  9702. i += 3;
  9703. ptr2 += 3;
  9704. }
  9705. else if (value1 > 0xFF) {
  9706. memcpy(ptr2, (uchar*)&value1, 2);
  9707. i++;
  9708. ptr2++;
  9709. }
  9710. else
  9711. memcpy(ptr2, (uchar*)&value1, 1);
  9712. ptr2++;
  9713. }
  9714. }
  9715. if (offset4 > 0 && offset4 >= offset3) {
  9716. offset3--;
  9717. offset4--;
  9718. uchar* ptr2 = app->pBuffer;
  9719. ptr2 += offset3;
  9720. for (int i = offset3; i <= offset4; i++) {
  9721. if (value2 > 0xFFFF) {
  9722. memcpy(ptr2, (uchar*)&value2, 4);
  9723. i += 3;
  9724. ptr2 += 3;
  9725. }
  9726. else if (value2 > 0xFF) {
  9727. memcpy(ptr2, (uchar*)&value2, 2);
  9728. i++;
  9729. ptr2++;
  9730. }
  9731. else
  9732. memcpy(ptr2, (uchar*)&value2, 1);
  9733. ptr2++;
  9734. }
  9735. }
  9736. }
  9737. DumpPacket(app);
  9738. client->QueuePacket(app);
  9739. safe_delete(packet2);
  9740. }
  9741. }
  9742. else if (atoi(sep->arg[0]) == 21) {
  9743. PacketStruct* packet2 = configReader.getStruct("WS_OfferQuest", client->GetVersion());
  9744. if (packet2) {
  9745. packet2->setDataByName("unknown0", 255);
  9746. packet2->setDataByName("reward", "New Quest");
  9747. packet2->setDataByName("title", "Title");
  9748. packet2->setDataByName("description", "description");
  9749. packet2->setDataByName("quest_difficulty", 3);
  9750. packet2->setDataByName("unknown1", 5);
  9751. packet2->setDataByName("level", 3);
  9752. packet2->setDataByName("coin", 150);
  9753. packet2->setDataByName("status_points", 5);
  9754. packet2->setDataByName("exp_bonus", 10);
  9755. packet2->setArrayLengthByName("num_rewards", 1);
  9756. Item* item = new Item(master_item_list.GetItem(36212));
  9757. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9758. item->stack_count = 20;
  9759. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  9760. safe_delete(item);
  9761. char accept[35] = { 0 };
  9762. char decline[35] = { 0 };
  9763. sprintf(accept, "q_accept_pending_quest %u", 0);
  9764. sprintf(decline, "q_deny_pending_quest %u", 0);
  9765. packet2->setDataByName("accept_command", accept);
  9766. packet2->setDataByName("decline_command", decline);
  9767. EQ2Packet* app = packet2->serialize();
  9768. if (sep->IsSet(2)) {
  9769. int16 offset = atoi(sep->arg[1]);
  9770. uchar* ptr2 = app->pBuffer;
  9771. ptr2 += offset;
  9772. if (sep->IsNumber(2)) {
  9773. int32 value1 = atol(sep->arg[2]);
  9774. if (value1 > 0xFFFF)
  9775. memcpy(ptr2, (uchar*)&value1, 4);
  9776. else if (value1 > 0xFF)
  9777. memcpy(ptr2, (uchar*)&value1, 2);
  9778. else
  9779. memcpy(ptr2, (uchar*)&value1, 1);
  9780. }
  9781. DumpPacket(app);
  9782. client->QueuePacket(app);
  9783. safe_delete(packet2);
  9784. }
  9785. }
  9786. }
  9787. else if (atoi(sep->arg[0]) == 22) { //same as 21, but 8bit string
  9788. PacketStruct* packet2 = configReader.getStruct("WS_OfferQuest", client->GetVersion());
  9789. if (packet2) {
  9790. packet2->setDataByName("unknown0", 255);
  9791. packet2->setDataByName("reward", "New Quest");
  9792. packet2->setDataByName("title", "Title");
  9793. packet2->setDataByName("description", "description");
  9794. packet2->setDataByName("quest_difficulty", 3);
  9795. packet2->setDataByName("unknown1", 5);
  9796. packet2->setDataByName("level", 3);
  9797. packet2->setDataByName("coin", 150);
  9798. packet2->setDataByName("status_points", 5);
  9799. packet2->setDataByName("exp_bonus", 10);
  9800. packet2->setArrayLengthByName("num_rewards", 1);
  9801. Item* item = new Item(master_item_list.GetItem(36212));
  9802. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9803. item->stack_count = 20;
  9804. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  9805. safe_delete(item);
  9806. char accept[35] = { 0 };
  9807. char decline[35] = { 0 };
  9808. sprintf(accept, "q_accept_pending_quest %u", 0);
  9809. sprintf(decline, "q_deny_pending_quest %u", 0);
  9810. packet2->setDataByName("accept_command", accept);
  9811. packet2->setDataByName("decline_command", decline);
  9812. EQ2Packet* app = packet2->serialize();
  9813. if (sep->IsSet(2)) {
  9814. int16 offset = atoi(sep->arg[1]);
  9815. uchar* ptr2 = app->pBuffer;
  9816. ptr2 += offset;
  9817. if (sep->IsNumber(2)) {
  9818. int32 value1 = atol(sep->arg[2]);
  9819. if (value1 > 0xFFFF)
  9820. memcpy(ptr2, (uchar*)&value1, 4);
  9821. else if (value1 > 0xFF)
  9822. memcpy(ptr2, (uchar*)&value1, 2);
  9823. else
  9824. memcpy(ptr2, (uchar*)&value1, 1);
  9825. }
  9826. else {
  9827. int8 len = strlen(sep->arg[2]);
  9828. memcpy(ptr2, (uchar*)&len, 1);
  9829. ptr2 += 1;
  9830. memcpy(ptr2, sep->arg[2], len);
  9831. }
  9832. }
  9833. DumpPacket(app);
  9834. client->QueuePacket(app);
  9835. safe_delete(packet2);
  9836. }
  9837. }
  9838. else if (atoi(sep->arg[0]) == 23) {
  9839. if (client->GetPlayer()->GetTarget()) {
  9840. PacketStruct* packet2 = configReader.getStruct("WS_UpdateMerchant", client->GetVersion());
  9841. if (packet2) {
  9842. Spawn* target = client->GetPlayer()->GetTarget();
  9843. packet2->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(target));
  9844. Item* item = new Item(master_item_list.GetItem(12565));
  9845. int8 i = 0;
  9846. packet2->setArrayLengthByName("num_items", 1);
  9847. packet2->setArrayDataByName("item_name", item->name.c_str(), i);
  9848. packet2->setArrayDataByName("item_id", item->details.item_id, i);
  9849. packet2->setArrayDataByName("stack_size", item->stack_count, i);
  9850. packet2->setArrayDataByName("icon", item->details.icon, i);
  9851. int8 tmp_level = 0;
  9852. if (item->generic_info.adventure_default_level > 0)
  9853. tmp_level = item->generic_info.adventure_default_level;
  9854. else
  9855. tmp_level = item->generic_info.tradeskill_default_level;
  9856. packet2->setArrayDataByName("level", tmp_level, i);
  9857. packet2->setArrayDataByName("tier", item->details.tier, i);
  9858. packet2->setArrayDataByName("item_id2", item->details.item_id, i);
  9859. int8 item_difficulty = client->GetPlayer()->GetArrowColor(tmp_level);
  9860. if (item_difficulty != ARROW_COLOR_WHITE && item_difficulty != ARROW_COLOR_RED && item_difficulty != ARROW_COLOR_GRAY)
  9861. item_difficulty = ARROW_COLOR_WHITE;
  9862. item_difficulty -= 6;
  9863. if (item_difficulty < 0)
  9864. item_difficulty *= -1;
  9865. packet2->setArrayDataByName("item_difficulty", item_difficulty, i);
  9866. packet2->setArrayDataByName("quantity", 2, i);
  9867. packet2->setArrayDataByName("unknown5", 255, i);
  9868. packet2->setArrayDataByName("stack_size2", item->stack_count, i);
  9869. packet2->setArrayDataByName("description", item->description.c_str(), i);
  9870. packet2->setDataByName("type", 2);
  9871. EQ2Packet* app = packet2->serialize();
  9872. if (sep->IsSet(2)) {
  9873. int16 offset = atoi(sep->arg[1]);
  9874. uchar* ptr2 = app->pBuffer;
  9875. ptr2 += offset;
  9876. if (sep->IsNumber(2)) {
  9877. int32 value1 = atol(sep->arg[2]);
  9878. if (value1 > 0xFFFF)
  9879. memcpy(ptr2, (uchar*)&value1, 4);
  9880. else if (value1 > 0xFF)
  9881. memcpy(ptr2, (uchar*)&value1, 2);
  9882. else
  9883. memcpy(ptr2, (uchar*)&value1, 1);
  9884. }
  9885. else {
  9886. int8 len = strlen(sep->arg[2]);
  9887. memcpy(ptr2, (uchar*)&len, 1);
  9888. ptr2 += 1;
  9889. memcpy(ptr2, sep->arg[2], len);
  9890. }
  9891. }
  9892. DumpPacket(app);
  9893. client->QueuePacket(app);
  9894. safe_delete(packet2);
  9895. }
  9896. }
  9897. }
  9898. else if (atoi(sep->arg[0]) == 24) {
  9899. PacketStruct* packet2 = configReader.getStruct("WS_EnableGameEvent", client->GetVersion());
  9900. if (packet2) {
  9901. if (sep->IsSet(2)) {
  9902. packet2->setDataByName("event_name", sep->arg[1]);
  9903. packet2->setDataByName("enabled", atoi(sep->arg[2]));
  9904. EQ2Packet* app = packet2->serialize();
  9905. DumpPacket(app);
  9906. client->QueuePacket(app);
  9907. safe_delete(packet2);
  9908. }
  9909. }
  9910. }
  9911. else if (atoi(sep->arg[0]) == 25) {
  9912. if (sep->IsSet(1)) {
  9913. Widget* new_spawn = new Widget();
  9914. int32 id = atoul(sep->arg[1]);
  9915. new_spawn->SetWidgetID(id);
  9916. EQ2Packet* ret = new_spawn->serialize(client->GetPlayer(), client->GetVersion());
  9917. client->QueuePacket(ret);
  9918. int8 index = client->GetPlayer()->GetIndexForSpawn(new_spawn);
  9919. PacketStruct* packet2 = configReader.getStruct("WS_DestroyGhostCmd", client->GetVersion());
  9920. if (packet2) {
  9921. packet2->setDataByName("spawn_index", index);
  9922. packet2->setDataByName("delete", 1);
  9923. EQ2Packet* app = packet2->serialize();
  9924. client->QueuePacket(app);
  9925. safe_delete(packet2);
  9926. }
  9927. }
  9928. }
  9929. else if (atoi(sep->arg[0]) == 26) {
  9930. if (sep->IsSet(4)) {
  9931. Widget* new_spawn = new Widget();
  9932. int32 id = atoul(sep->arg[1]);
  9933. new_spawn->SetWidgetID(id);
  9934. float x = atof(sep->arg[2]);
  9935. float y = atof(sep->arg[3]);
  9936. float z = atof(sep->arg[4]);
  9937. new_spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  9938. new_spawn->SetWidgetX(x);
  9939. new_spawn->SetWidgetY(y);
  9940. new_spawn->SetWidgetZ(z);
  9941. new_spawn->SetX(x);
  9942. new_spawn->SetY(y);
  9943. new_spawn->SetZ(z);
  9944. EQ2Packet* ret = new_spawn->serialize(client->GetPlayer(), client->GetVersion());
  9945. client->QueuePacket(ret);
  9946. }
  9947. }
  9948. else if (atoi(sep->arg[0]) == 27) {
  9949. Spawn* target = client->GetPlayer()->GetTarget();
  9950. PacketStruct* packet2 = configReader.getStruct("WS_HearSimpleDamage", client->GetVersion());
  9951. if (packet2 && target && sep->IsSet(2)) {
  9952. packet2->setSubstructDataByName("header", "defender", client->GetPlayer()->GetIDWithPlayerSpawn(target));
  9953. packet2->setSubstructDataByName("header", "defender_proxy", client->GetPlayer()->GetIDWithPlayerSpawn(target));
  9954. packet2->setSubstructDataByName("header", "attacker", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  9955. packet2->setArrayLengthByName("num_dmg", 1);
  9956. packet2->setArrayDataByName("damage_type", atoi(sep->arg[1]));
  9957. packet2->setArrayDataByName("damage", atoi(sep->arg[2]));
  9958. packet2->setDataByName("spell", 1);
  9959. packet2->setDataByName("spell_name", "Testing");
  9960. EQ2Packet* app = packet2->serialize();
  9961. if (sep->IsSet(4)) {
  9962. int16 offset = atoi(sep->arg[3]);
  9963. uchar* ptr2 = app->pBuffer;
  9964. ptr2 += offset;
  9965. if (sep->IsNumber(4)) {
  9966. int32 value1 = atol(sep->arg[4]);
  9967. if (value1 > 0xFFFF)
  9968. memcpy(ptr2, (uchar*)&value1, 4);
  9969. else if (value1 > 0xFF)
  9970. memcpy(ptr2, (uchar*)&value1, 2);
  9971. else
  9972. memcpy(ptr2, (uchar*)&value1, 1);
  9973. }
  9974. else {
  9975. int8 len = strlen(sep->arg[4]);
  9976. memcpy(ptr2, (uchar*)&len, 1);
  9977. ptr2 += 1;
  9978. memcpy(ptr2, sep->arg[4], len);
  9979. }
  9980. }
  9981. if (sep->IsSet(6)) {
  9982. int16 offset = atoi(sep->arg[5]);
  9983. uchar* ptr2 = app->pBuffer;
  9984. ptr2 += offset;
  9985. if (sep->IsNumber(6)) {
  9986. int32 value1 = atol(sep->arg[6]);
  9987. if (value1 > 0xFFFF)
  9988. memcpy(ptr2, (uchar*)&value1, 4);
  9989. else if (value1 > 0xFF)
  9990. memcpy(ptr2, (uchar*)&value1, 2);
  9991. else
  9992. memcpy(ptr2, (uchar*)&value1, 1);
  9993. }
  9994. else {
  9995. int8 len = strlen(sep->arg[6]);
  9996. memcpy(ptr2, (uchar*)&len, 1);
  9997. ptr2 += 1;
  9998. memcpy(ptr2, sep->arg[6], len);
  9999. }
  10000. }
  10001. DumpPacket(app);
  10002. client->QueuePacket(app);
  10003. safe_delete(packet2);
  10004. }
  10005. }
  10006. else if (atoi(sep->arg[0]) == 28 && sep->IsNumber(1)) {
  10007. World::newValue = strtoull(sep->arg[1], NULL, 0);
  10008. }
  10009. }
  10010. else {
  10011. PacketStruct* packet2 = configReader.getStruct("WS_ExamineSpellInfo", client->GetVersion());
  10012. if (packet2) {
  10013. packet2->setSubstructDataByName("info_header", "show_name", 1);
  10014. packet2->setSubstructDataByName("info_header", "unknown", 7);
  10015. packet2->setSubstructDataByName("info_header", "unknown2", 1);
  10016. packet2->setSubstructDataByName("info_header", "unknown3", 1);
  10017. packet2->setSubstructDataByName("info_header", "unknown4", 1);
  10018. packet2->setSubstructDataByName("info_header", "unknown5", 1);
  10019. packet2->setSubstructDataByName("info_header", "unknown6", "Testing");
  10020. packet2->setSubstructDataByName("info_header", "unknown7", "Testing");
  10021. packet2->setSubstructDataByName("info_header", "unknown8", 66);
  10022. packet2->setSubstructDataByName("info_header", "title", "Blah Title Blah");
  10023. packet2->setSubstructDataByName("info_header", "title_text", "Blah Blah");
  10024. packet2->setSubstructDataByName("info_header", "title_text2", "Blah Blah2");
  10025. packet2->setSubstructDataByName("info_header", "show_popup", 1);
  10026. packet2->setSubstructDataByName("info_header", "packettype", 3);
  10027. packet2->setSubstructDataByName("spell_info", "skill_name", "Testing");
  10028. packet2->setSubstructDataByName("spell_info", "level", 19);
  10029. packet2->setSubstructDataByName("spell_info", "tier", 1);
  10030. packet2->setSubstructDataByName("spell_info", "health_cost", 5);
  10031. packet2->setSubstructDataByName("spell_info", "min_class_skill_req", 3);
  10032. packet2->setSubstructDataByName("spell_info", "mana_cost", 6);
  10033. packet2->setSubstructDataByName("spell_info", "req_concentration", 7);
  10034. packet2->setSubstructDataByName("spell_info", "cast_time", 200);
  10035. packet2->setSubstructDataByName("spell_info", "recovery", 220);
  10036. packet2->setSubstructDataByName("spell_info", "recast", 280);
  10037. packet2->setSubstructDataByName("spell_info", "beneficial", 1);
  10038. packet2->setSubstructDataByName("spell_info", "maintained", 1);
  10039. packet2->setSubstructDataByName("spell_info", "spell_book_type", 1);
  10040. packet2->setSubstructDataByName("spell_info", "quality", 3);
  10041. packet2->setSubstructDataByName("spell_info", "test_1a", 1);
  10042. packet2->setSubstructDataByName("spell_info", "test_1b", 1);
  10043. packet2->setSubstructDataByName("spell_info", "test_1c", 1);
  10044. packet2->setSubstructDataByName("spell_info", "test_1d", 1);
  10045. packet2->setSubstructDataByName("spell_info", "test_2a", 2);
  10046. packet2->setSubstructDataByName("spell_info", "test_2b", 2);
  10047. packet2->setSubstructDataByName("spell_info", "test_2c", 2);
  10048. packet2->setSubstructDataByName("spell_info", "test_2d", 2);
  10049. packet2->setSubstructDataByName("spell_info", "test_3", 3);
  10050. packet2->setSubstructDataByName("spell_info", "test_4", 4);
  10051. packet2->setSubstructDataByName("spell_info", "test_5", 5);
  10052. packet2->setSubstructDataByName("spell_info", "test_6", 6);
  10053. packet2->setSubstructDataByName("spell_info", "min_class_skill_req", 1);
  10054. packet2->setSubstructDataByName("spell_info", "min_class_skill_rec", 30123);
  10055. packet2->setSubstructDataByName("spell_info", "num_reagents", 1);
  10056. packet2->setSubstructArrayLengthByName("spell_info", "num_reagents", 1);
  10057. packet2->setArrayDataByName("reagent", "Alcohol");
  10058. packet2->setArrayDataByName("consumed", "123");
  10059. packet2->setSubstructDataByName("spell_info", "class_skill", 52);
  10060. packet2->setSubstructDataByName("spell_info", "id", 8308);
  10061. packet2->setSubstructDataByName("spell_info", "icon", 303);
  10062. packet2->setSubstructDataByName("spell_info", "icon2", 0xFFFF);
  10063. packet2->setSubstructDataByName("spell_info", "icontype", 317);
  10064. packet2->setSubstructDataByName("spell_info", "type", 2);
  10065. packet2->setSubstructDataByName("spell_info", "spell_text_color", 255);
  10066. packet2->setSubstructDataByName("spell_info", "duration1", 600);
  10067. packet2->setSubstructDataByName("spell_info", "duration2", 600);
  10068. packet2->setSubstructDataByName("spell_info", "name", "Sprint");
  10069. packet2->setSubstructDataByName("spell_info", "description", "Test description");
  10070. EQ2Packet* outapp = packet2->serialize();
  10071. DumpPacket(outapp);
  10072. client->QueuePacket(outapp);
  10073. safe_delete(packet2);
  10074. }
  10075. }
  10076. return;
  10077. PacketStruct* p = configReader.getStruct("WS_EqTargetItemCmd", client->GetVersion());
  10078. if (!p) return;
  10079. //Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  10080. //client->GetCurrentZone()->SendSpellFailedPacket(client, atoi(sep2->arg[0]));
  10081. //}
  10082. /*Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  10083. if (sep2 && sep2->arg[0] && sep2->IsNumber(0)) {
  10084. client->SetPendingFlightPath(atoi(sep2->arg[0]));
  10085. PacketStruct* packet = configReader.getStruct("WS_ReadyForTakeOff", client->GetVersion());
  10086. if (packet) {
  10087. client->QueuePacket(packet->serialize());
  10088. safe_delete(packet);
  10089. }
  10090. }*/
  10091. /*if (client->GetCurrentZone()->Grid != nullptr) {
  10092. int32 numFaces = 0;
  10093. int32 numGrids = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.size();
  10094. client->Message(CHANNEL_COLOR_YELLOW, "Num grids in cell: %u", numGrids);
  10095. map<int32, vector<Face*> >::iterator itr;
  10096. for (itr = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.begin(); itr != client->GetPlayer()->Cell_Info.CurrentCell->FaceList.end(); itr++)
  10097. numFaces += (*itr).second.size();
  10098. client->Message(CHANNEL_COLOR_YELLOW, "Num faces in cell: %u", numFaces);
  10099. }*/
  10100. //uchar blah[] = {
  10101. // 1208 - OP_EQUpdateStoreCmd
  10102. // /*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
  10103. // /*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
  10104. // 1193 - -- OP_ClientCmdMsg::OP_EqUpdateMerchantCmd --
  10105. // /*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
  10106. /*};
  10107. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  10108. int8 val = 0;
  10109. int16 pos = 0;
  10110. int idx = 0;
  10111. while(sep2 && sep2->arg[idx+1] && sep2->IsNumber(idx) && sep2->IsNumber(idx+1)){
  10112. pos = atoi(sep2->arg[idx]);
  10113. val = atoi(sep2->arg[idx+1]);
  10114. memset(blah+pos, val, 1);
  10115. idx+=2;
  10116. }
  10117. DumpPacket(blah, sizeof(blah));
  10118. client->QueuePacket(new EQ2Packet(OP_GroupCreatedMsg , blah, sizeof(blah)));*/
  10119. if (client->GetPlayer()->GetTarget()) {
  10120. PacketStruct* packet = configReader.getStruct("WS_SetControlGhost", client->GetVersion());
  10121. if (packet) {
  10122. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  10123. packet->setDataByName("size", 0);
  10124. packet->setDataByName("unknown2", 0);
  10125. EQ2Packet* app = packet->serialize();
  10126. client->QueuePacket(app);
  10127. safe_delete(packet);
  10128. }
  10129. PacketStruct* set_pov = configReader.getStruct("WS_SetPOVGhostCmd", client->GetVersion());
  10130. if (set_pov) {
  10131. set_pov->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  10132. EQ2Packet* app_pov = set_pov->serialize();
  10133. client->QueuePacket(app_pov);
  10134. safe_delete(set_pov);
  10135. }
  10136. }
  10137. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  10138. PacketStruct* packet = configReader.getStruct("WS_OpenCharCust", client->GetVersion());
  10139. if (packet) {
  10140. if (sep2 && sep2->arg[0] && sep2->IsNumber(0))
  10141. packet->setDataByName("Type", atoi(sep2->arg[0]));
  10142. else
  10143. packet->setDataByName("Type", 2);
  10144. if (sep2 && sep2->arg[1] && sep2->IsNumber(1))
  10145. packet->setDataByName("race_id", atoi(sep2->arg[1]));
  10146. else
  10147. packet->setDataByName("race_id", 0);
  10148. if (sep2 && sep2->arg[2] && sep2->IsNumber(2))
  10149. packet->setDataByName("gender", atoi(sep2->arg[2]));
  10150. else
  10151. packet->setDataByName("gender", 2);
  10152. if (sep2 && sep2->arg[3] && sep2->IsNumber(3))
  10153. packet->setDataByName("unknown", atoi(sep2->arg[3]), 0);
  10154. else
  10155. packet->setDataByName("unknown", 0, 0);
  10156. if (sep2 && sep2->arg[4] && sep2->IsNumber(4))
  10157. packet->setDataByName("unknown", atoi(sep2->arg[4]), 1);
  10158. else
  10159. packet->setDataByName("unknown", 0, 1);
  10160. if (sep2 && sep2->arg[5] && sep2->IsNumber(5))
  10161. packet->setDataByName("unknown", atoi(sep2->arg[5]), 2);
  10162. else
  10163. packet->setDataByName("unknown", 0, 2);
  10164. client->QueuePacket(packet->serialize());
  10165. }
  10166. safe_delete(packet);
  10167. safe_delete(sep2);
  10168. }
  10169. void Commands::Command_LeaveChannel(Client *client, Seperator *sep) {
  10170. const char *channel_name;
  10171. if (sep == NULL || !sep->IsSet(0)) {
  10172. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /leavechat <channel name>");
  10173. PrintSep(sep);
  10174. return;
  10175. }
  10176. channel_name = sep->arg[0];
  10177. if (!chat.IsInChannel(client, channel_name))
  10178. client->Message(CHANNEL_NARRATIVE, "Unable to leave '%s': You are not in the channel.", channel_name);
  10179. else if (!chat.LeaveChannel(client, channel_name))
  10180. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an internal error preventing you from leaving that channel MUAHAHA");
  10181. }
  10182. /*
  10183. Function:
  10184. Purpose :
  10185. Params :
  10186. Dev :
  10187. Example :
  10188. */
  10189. void Commands::Command_WeaponStats(Client* client)
  10190. {
  10191. Player* player = client->GetPlayer();
  10192. Item* primary = player->GetEquipmentList()->GetItem(EQ2_PRIMARY_SLOT);
  10193. Item* secondary = player->GetEquipmentList()->GetItem(EQ2_SECONDARY_SLOT);
  10194. Item* ranged = player->GetEquipmentList()->GetItem(EQ2_RANGE_SLOT);
  10195. client->SimpleMessage(0, "Primary:");
  10196. if (primary) {
  10197. client->Message(0, "Name: %s", primary->name.c_str());
  10198. client->Message(0, "Base Damage: %u - %u", primary->weapon_info->damage_low3, primary->weapon_info->damage_high3);
  10199. client->Message(0, "Actual Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  10200. client->Message(0, "Actual Delay: %u", player->GetPrimaryWeaponDelay());
  10201. client->Message(0, "Proc Percent: %d%%", 0);
  10202. client->Message(0, "Procs Per Minute: %d", 0);
  10203. }
  10204. else {
  10205. client->SimpleMessage(0, "Name: fist");
  10206. client->Message(0, "Base Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  10207. client->Message(0, "Actual Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  10208. client->Message(0, "Actual Delay: %d", player->GetPrimaryWeaponDelay() * 0.1);
  10209. client->Message(0, "Proc Percent: %d%%", 0);
  10210. client->Message(0, "Procs Per Minute: %d", 0);
  10211. }
  10212. client->SimpleMessage(0, " ");
  10213. client->SimpleMessage(0, " ");
  10214. if (secondary) {
  10215. client->SimpleMessage(0, "Secondary:");
  10216. client->Message(0, "Name: %s", secondary->name.c_str());
  10217. client->Message(0, "Base Damage: %u - %u", secondary->weapon_info->damage_low3, secondary->weapon_info->damage_high3);
  10218. client->Message(0, "Actual Damage: %u - %u", player->GetSecondaryWeaponMinDamage(), player->GetSecondaryWeaponMaxDamage());
  10219. client->Message(0, "Actual Delay: %d", player->GetSecondaryWeaponDelay() * 0.1);
  10220. client->Message(0, "Proc Percent: %d%%", 0);
  10221. client->Message(0, "Procs Per Minute: %d", 0);
  10222. client->SimpleMessage(0, " ");
  10223. client->SimpleMessage(0, " ");
  10224. }
  10225. client->SimpleMessage(0, "Ranged:");
  10226. if (ranged) {
  10227. client->Message(0, "Name: %s", ranged->name.c_str());
  10228. client->Message(0, "Base Damage: %u - %u", ranged->ranged_info->weapon_info.damage_low3, ranged->ranged_info->weapon_info.damage_high3);
  10229. client->Message(0, "Actual Damage: %u - %u", player->GetRangedWeaponMinDamage(), player->GetRangedWeaponMaxDamage());
  10230. client->Message(0, "Actual Delay: %d", player->GetRangeWeaponDelay() * 0.1);
  10231. client->Message(0, "Proc Percent: %d%%", 0);
  10232. client->Message(0, "Procs Per Minute: %d", 0);
  10233. }
  10234. else
  10235. client->SimpleMessage(0, "None");
  10236. }
  10237. void Commands::Command_WhoChannel(Client *client, Seperator *sep) {
  10238. const char *channel_name;
  10239. if (sep == NULL || !sep->IsSet(0)) {
  10240. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /chatwho <channel name>");
  10241. return;
  10242. }
  10243. channel_name = sep->arg[0];
  10244. if (!chat.ChannelExists(channel_name))
  10245. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That channel does not exist!");
  10246. else
  10247. chat.SendChannelUserList(client, channel_name);
  10248. }
  10249. void Commands::Command_ZoneSafeCoords(Client *client, Seperator *sep)
  10250. {
  10251. ZoneServer* zone = 0;
  10252. int32 zone_id = client->GetPlayer()->GetZone()->GetZoneID();
  10253. if (zone_id > 0)
  10254. {
  10255. zone = zone_list.Get(zone_id, false);
  10256. if (zone)
  10257. {
  10258. zone->SetSafeX(client->GetPlayer()->GetX());
  10259. zone->SetSafeY(client->GetPlayer()->GetY());
  10260. zone->SetSafeZ(client->GetPlayer()->GetZ());
  10261. zone->SetSafeHeading(client->GetPlayer()->GetHeading());
  10262. if( database.SaveZoneSafeCoords(zone_id, zone->GetSafeX(), zone->GetSafeY(), zone->GetSafeZ(), zone->GetSafeHeading()) )
  10263. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Zone safe coordinates updated!");
  10264. else
  10265. client->SimpleMessage(CHANNEL_COLOR_RED, "FAILED to update zone safe coordinates!");
  10266. }
  10267. }
  10268. }
  10269. /*
  10270. Function:
  10271. Purpose :
  10272. Params :
  10273. Dev :
  10274. Example :
  10275. */
  10276. void Commands::Command_ZoneDetails(Client* client, Seperator* sep)
  10277. {
  10278. ZoneInfo* zone_info = new ZoneInfo;
  10279. if (sep && sep->arg[0])
  10280. {
  10281. if (sep->IsNumber(0))
  10282. zone_info->id = atoi(sep->arg[0]);
  10283. else
  10284. zone_info->id = database.GetZoneID(sep->arg[0]);
  10285. if (zone_info->id > 0)
  10286. {
  10287. database.LoadZoneInfo(zone_info);
  10288. 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);
  10289. 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);
  10290. 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);
  10291. 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);
  10292. 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);
  10293. 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);
  10294. 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);
  10295. client->Message(CHANNEL_COLOR_YELLOW, "zone_type: %s, sky_file: %s", zone_info->zone_type, zone_info->sky_file);
  10296. client->Message(CHANNEL_COLOR_YELLOW, "lua_script: %s", zone_info->lua_script);
  10297. client->Message(CHANNEL_COLOR_YELLOW, "zone_motd: %s", zone_info->zone_motd);
  10298. }
  10299. else
  10300. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  10301. }
  10302. else
  10303. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone details [zone id|zone name]");
  10304. safe_delete(zone_info);
  10305. }
  10306. /*
  10307. Function:
  10308. Purpose :
  10309. Params :
  10310. Dev :
  10311. Example :
  10312. */
  10313. void Commands::Command_ZoneSet(Client* client, Seperator* sep)
  10314. {
  10315. if (sep && sep->arg[0] && sep->arg[1] && sep->arg[2])
  10316. {
  10317. ZoneServer* zone = 0;
  10318. int32 zone_id = 0;
  10319. if (sep->IsNumber(0) && atoi(sep->arg[0]) > 0)
  10320. {
  10321. zone_id = atoi(sep->arg[0]);
  10322. zone = zone_list.Get(atoi(sep->arg[0]), false);
  10323. }
  10324. else
  10325. {
  10326. zone_id = database.GetZoneID(sep->arg[0]);
  10327. if (zone_id > 0)
  10328. zone = zone_list.Get(sep->arg[0], false);
  10329. }
  10330. if (zone_id > 0)
  10331. {
  10332. if (zone_set_values.count(string(sep->arg[1])) > 0)
  10333. SetZoneCommand(client, zone_id, zone, zone_set_values[sep->arg[1]], sep->arg[2]);
  10334. else
  10335. client->Message(CHANNEL_COLOR_YELLOW, "The attribute '%s' is not valid.", sep->arg[1]);
  10336. }
  10337. else
  10338. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  10339. }
  10340. else
  10341. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone set [zone id|zone name] [attribute] [value]");
  10342. }
  10343. void Commands::Command_Rain(Client* client, Seperator* sep) {
  10344. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  10345. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /rain <float>");
  10346. return;
  10347. }
  10348. client->Message(CHANNEL_COLOR_YELLOW,"Setting rain to %.2f", atof(sep->arg[0]));
  10349. client->GetCurrentZone()->SetRain(atof(sep->arg[0]));
  10350. client->GetCurrentZone()->SetCurrentWeather(atof(sep->arg[0]));
  10351. }
  10352. void Commands::Command_Wind(Client* client, Seperator* sep) {
  10353. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  10354. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /wind <float>");
  10355. return;
  10356. }
  10357. client->Message(CHANNEL_COLOR_YELLOW, "Setting wind to %.2f", atof(sep->arg[0]));
  10358. client->GetCurrentZone()->SetWind(atof(sep->arg[0]));
  10359. }
  10360. void Commands::Command_SendMerchantWindow(Client* client, Seperator* sep, bool sell) {
  10361. Spawn* spawn = client->GetPlayer()->GetTarget();
  10362. if(spawn) {
  10363. client->SetMerchantTransaction(spawn);
  10364. if (spawn->GetMerchantID() > 0 && spawn->IsClientInMerchantLevelRange(client)){
  10365. client->SendHailCommand(spawn);
  10366. //MerchantFactionMultiplier* multiplier = world.GetMerchantMultiplier(spawn->GetMerchantID());
  10367. //if(!multiplier || (multiplier && client->GetPlayer()->GetFactions()->GetFactionValue(multiplier->faction_id) >= multiplier->faction_min)){
  10368. client->SendBuyMerchantList(sell);
  10369. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY))
  10370. client->SendSellMerchantList(sell);
  10371. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY_BACK))
  10372. client->SendBuyBackList(sell);
  10373. PacketStruct* packet = configReader.getStruct("WS_UpdateMerchant", client->GetVersion());
  10374. if (packet) {
  10375. packet->setDataByName("spawn_id", 0xFFFFFFFF);
  10376. packet->setDataByName("type", 16);
  10377. EQ2Packet* outapp = packet->serialize();
  10378. if (outapp)
  10379. client->QueuePacket(outapp);
  10380. safe_delete(packet);
  10381. }
  10382. }
  10383. if (spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR)
  10384. client->SendRepairList();
  10385. }
  10386. // client->SimpleMessage(CHANNEL_COLOR_RED, "Your faction is too low to use this merchant.");
  10387. }
  10388. void Commands::Command_Weather(Client* client, Seperator* sep)
  10389. {
  10390. //PrintSep(sep, "Weather");
  10391. if( sep && sep->arg[0] )
  10392. {
  10393. ZoneServer* zsZone = client->GetCurrentZone();
  10394. const char* value = sep->arg[0];
  10395. // process single-param commands first
  10396. if( strncasecmp(value, "details", strlen(value)) == 0 )
  10397. {
  10398. client->Message(CHANNEL_COLOR_YELLOW, "Weather Details for zone %s: ", zsZone->GetZoneName());
  10399. client->Message(CHANNEL_COLOR_YELLOW, "enabled: %i, allowed: %i, type: %i, frequency: %u", zsZone->isWeatherEnabled(), zsZone->isWeatherAllowed(), zsZone->GetWeatherType(), zsZone->GetWeatherFrequency());
  10400. client->Message(CHANNEL_COLOR_YELLOW, "severity: %.2f = %.2f, current: %.2f", zsZone->GetWeatherMinSeverity(), zsZone->GetWeatherMaxSeverity(), zsZone->GetCurrentWeather());
  10401. client->Message(CHANNEL_COLOR_YELLOW, "pattern: %i, chance: %i, amount: %.2f, offset: %.2f", zsZone->GetWeatherPattern(), zsZone->GetWeatherChance(), zsZone->GetWeatherChangeAmount(), zsZone->GetWeatherDynamicOffset());
  10402. }
  10403. else if( strncasecmp(value, "process", strlen(value)) == 0 )
  10404. {
  10405. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  10406. zsZone->ProcessWeather();
  10407. }
  10408. else if( strncasecmp(value, "reset", strlen(value)) == 0 )
  10409. {
  10410. zsZone->SetWeatherType(rule_manager.GetGlobalRule(R_Zone, WeatherType)->GetInt8());
  10411. zsZone->SetWeatherFrequency(rule_manager.GetGlobalRule(R_Zone, WeatherChangeFrequency)->GetInt32());
  10412. zsZone->SetWeatherMinSeverity(rule_manager.GetGlobalRule(R_Zone, MinWeatherSeverity)->GetFloat());
  10413. zsZone->SetWeatherMaxSeverity(rule_manager.GetGlobalRule(R_Zone, MaxWeatherSeverity)->GetFloat());
  10414. zsZone->SetCurrentWeather(zsZone->GetWeatherMinSeverity());
  10415. zsZone->SetWeatherPattern(1);
  10416. zsZone->SetWeatherChance(rule_manager.GetGlobalRule(R_Zone, WeatherChangeChance)->GetInt8());
  10417. zsZone->SetWeatherChangeAmount(rule_manager.GetGlobalRule(R_Zone, WeatherChangePerInterval)->GetFloat());
  10418. zsZone->SetWeatherDynamicOffset(rule_manager.GetGlobalRule(R_Zone, WeatherDynamicMaxOffset)->GetFloat());
  10419. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  10420. zsZone->ProcessWeather();
  10421. }
  10422. // process commands with params
  10423. if( sep->arg[1] )
  10424. {
  10425. if( strncasecmp(value, "enable", strlen(value)) == 0 && sep->IsNumber(1) )
  10426. zsZone->SetWeatherEnabled( ( atoi(sep->arg[1]) == 1 ) ? true : false );
  10427. else if( strncasecmp(value, "type", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 3) )
  10428. zsZone->SetWeatherType(atoi(sep->arg[1]));
  10429. else if( strncasecmp(value, "frequency", strlen(value)) == 0 && sep->IsNumber(1))
  10430. zsZone->SetWeatherFrequency( atoul(sep->arg[1]) );
  10431. else if( strncasecmp(value, "range", strlen(value)) == 0 && sep->IsNumber(1) && sep->IsNumber(2) ) {
  10432. zsZone->SetWeatherMinSeverity(atof(sep->arg[1]));
  10433. zsZone->SetWeatherMaxSeverity(atof(sep->arg[2]));
  10434. zsZone->SetRain(zsZone->GetWeatherMinSeverity());
  10435. }
  10436. else if( strncasecmp(value, "current", strlen(value)) == 0 && sep->IsNumber(1) ) {
  10437. zsZone->SetCurrentWeather(atof(sep->arg[1]));
  10438. zsZone->SetRain(zsZone->GetCurrentWeather());
  10439. }
  10440. else if( strncasecmp(value, "pattern", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 2) )
  10441. zsZone->SetWeatherPattern( atoi(sep->arg[1]) );
  10442. else if( strncasecmp(value, "chance", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 100) )
  10443. zsZone->SetWeatherChance( atoi(sep->arg[1]) );
  10444. else if( strncasecmp(value, "amount", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  10445. zsZone->SetWeatherChangeAmount( atof(sep->arg[1]) );
  10446. else if( strncasecmp(value, "offset", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  10447. zsZone->SetWeatherDynamicOffset( atof(sep->arg[1]) );
  10448. }
  10449. }
  10450. else
  10451. {
  10452. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /weather [command] [param]");
  10453. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: enable (0|1), type (0-3), frequency (sec), range|current (0.0 - 1.0)");
  10454. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: details, process, pattern (0|1), chance (%), amount (float), offset (float)");
  10455. return;
  10456. }
  10457. }
  10458. void Commands::Command_Select(Client* client, Seperator* sep) {
  10459. if (sep && sep->arg[1]) {
  10460. Spawn* spawn = client->GetPlayer()->GetTarget();
  10461. if (spawn && strlen(sep->arg[1]) > 0)
  10462. client->GetCurrentZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_CUSTOM, client->GetPlayer(), sep->arg[1]);
  10463. }
  10464. }
  10465. /*
  10466. Function: Command_ConsumeFood()
  10467. Purpose : Consume Food/Drink and apply mods
  10468. Params : Slot ID - EQ2_FOOD_SLOT 22, EQ2_DRINK_SLOT 23
  10469. Dev : Zcoretri
  10470. Example : /consume_food 22
  10471. */
  10472. void Commands::Command_ConsumeFood(Client* client, Seperator* sep) {
  10473. if (sep && sep->arg[0] && sep->IsNumber(0))
  10474. {
  10475. Player* player = client->GetPlayer();
  10476. int8 slot = atoi(sep->arg[0]);
  10477. Item* item = player->GetEquipmentList()->GetItem(slot);
  10478. if(slot == 22 && player->GetSpellEffectBySpellType(SPELL_TYPE_FOOD))
  10479. {
  10480. client->Message(CHANNEL_NARRATIVE, "If you ate anymore you would explode!");
  10481. return;
  10482. }
  10483. else if (player->GetSpellEffectBySpellType(SPELL_TYPE_DRINK))
  10484. {
  10485. client->Message(CHANNEL_NARRATIVE, "If you drank anymore you would explode!");
  10486. return;
  10487. }
  10488. client->ConsumeFoodDrink(item, slot);
  10489. }
  10490. }
  10491. void Commands::Command_Aquaman(Client* client, Seperator* sep) {
  10492. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  10493. if (atoi(sep->arg[0]) == 1) {
  10494. client->GetPlayer()->GetInfoStruct()->set_vision(4);
  10495. client->GetPlayer()->GetInfoStruct()->set_breathe_underwater(1);
  10496. client->GetPlayer()->SetCharSheetChanged(true);
  10497. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Maybe you ought to stick to the shallow end until you know how to swim.");
  10498. }
  10499. else {
  10500. client->GetPlayer()->GetInfoStruct()->set_vision(0);
  10501. client->GetPlayer()->GetInfoStruct()->set_breathe_underwater(0);
  10502. client->GetPlayer()->SetCharSheetChanged(true);
  10503. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Aquaman mode turned off.");
  10504. }
  10505. }
  10506. else
  10507. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /aquaman [0|1]");
  10508. }
  10509. void Commands::Command_ReportBug(Client* client, Seperator* sep)
  10510. {
  10511. if(sep)
  10512. {
  10513. string data;
  10514. if(sep->arg[0]){
  10515. data = string(sep->arg[0]);
  10516. }
  10517. for(int i=1;i<sep->GetMaxArgNum();i++){
  10518. if(sep->arg[i])
  10519. data.append(" ").append(sep->arg[i]);
  10520. }
  10521. const char* target_name = 0;
  10522. int32 spawn_id = 0;
  10523. if(client->GetPlayer()->GetTarget())
  10524. {
  10525. target_name = client->GetPlayer()->GetTarget()->GetName();
  10526. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  10527. }
  10528. else
  10529. target_name = "N/A";
  10530. LogWrite(COMMAND__DEBUG, 1, "Command", "%s", data.c_str());
  10531. if(world.ReportBug(data, client->GetPlayer()->GetName(), client->GetAccountID(), target_name, spawn_id, client->GetCurrentZone()->GetZoneID()))
  10532. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully submitted bug.");
  10533. else
  10534. client->SimpleMessage(CHANNEL_COLOR_RED, "Error submitting bug.");
  10535. }
  10536. }
  10537. void Commands::Command_Attune_Inv(Client* client, Seperator* sep) {
  10538. PrintSep(sep, "Command_Attune_Inv");
  10539. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  10540. // Get the item index from the first parameter
  10541. int16 index = atoi(sep->arg[0]);
  10542. // Check to see if this is a valid item index for the player, if not exit out of the function
  10543. if (client->GetPlayer()->item_list.indexed_items.count(index) == 0) {
  10544. LogWrite(ITEM__DEBUG, 0, "Items", "%s has no item with an index of %i", client->GetPlayer()->GetName(), index);
  10545. return;
  10546. }
  10547. // Get the item
  10548. Item* item = client->GetPlayer()->item_list.indexed_items[index];
  10549. if(item) {
  10550. // Valid item lets check to make sure this item is attunable, if not return out
  10551. if (!item->CheckFlag(ATTUNEABLE)) {
  10552. LogWrite(ITEM__DEBUG, 0, "Items", "attune_inv called for an item that is not attunable (%s)", item->name.c_str());
  10553. return;
  10554. }
  10555. // Remove the attunable flag
  10556. item->generic_info.item_flags -= ATTUNEABLE;
  10557. // Set the attuned flag
  10558. item->generic_info.item_flags += ATTUNED;
  10559. // Flag this item for saving
  10560. item->save_needed = true;
  10561. client->QueuePacket(item->serialize(client->GetVersion(), false, client->GetPlayer()));
  10562. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), 0, -1); // appearance type??
  10563. EQ2Packet* outapp = 0;
  10564. for (int32 i=0;i<packets.size();i++) {
  10565. outapp = packets[i];
  10566. if(outapp)
  10567. client->QueuePacket(outapp);
  10568. }
  10569. }
  10570. }
  10571. }
  10572. void Commands::Command_Reset_Zone_Timer(Client* client, Seperator* sep) {
  10573. PrintSep(sep, "Command_Reset_Zone_Timer");
  10574. /*if (sep && sep->arg[0] && sep->IsNumber(0)) {
  10575. int32 db_id = atoul(sep->arg[0]);
  10576. InstanceData* data = client->GetPlayer()->GetCharacterInstances().FindInstanceByDBID(db_id);
  10577. if (data) {
  10578. // TODO: add a check to timers to ensure it can be reset
  10579. // Delete the character from the instance
  10580. database.DeleteCharacterFromInstance(client->GetPlayer()->GetCharacterID(), data->instance_id);
  10581. data->instance_id = 0;
  10582. // Update the success time and set to 0 so the player can enter it again
  10583. database.UpdateCharacterInstance(client->GetPlayer()->GetCharacterID(), data->zone_name, 0, 1, 0);
  10584. data->last_success_timestamp = 0;
  10585. }
  10586. }*/
  10587. }
  10588. void Commands::Command_Player(Client* client, Seperator* sep) {
  10589. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player syntax --");
  10590. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins");
  10591. }
  10592. void Commands::Command_Player_Coins(Client* client, Seperator* sep) {
  10593. // /player coins add 10
  10594. // /player coins add plat 10
  10595. Player* player = client->GetPlayer();
  10596. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  10597. player = (Player*)player->GetTarget();
  10598. if (sep && sep->arg[0] && sep->arg[1]) {
  10599. const char* action = sep->arg[0];
  10600. int64 value = 0;
  10601. if (strncasecmp(action, "add", strlen(action)) == 0) {
  10602. if (sep->IsNumber(1)) {
  10603. value = atoi64(sep->arg[1]);
  10604. player->AddCoins(value);
  10605. if (client->GetPlayer() == player)
  10606. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  10607. else {
  10608. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  10609. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  10610. }
  10611. return;
  10612. }
  10613. else if (sep->arg[2] && sep->IsNumber(2)) {
  10614. const char* type = sep->arg[1];
  10615. if (strncasecmp(type, "copper", strlen(type)) == 0) {
  10616. value = atoi64(sep->arg[2]);
  10617. }
  10618. else if (strncasecmp(type, "silver", strlen(type)) == 0) {
  10619. value = atoi64(sep->arg[2]) * 100;
  10620. }
  10621. else if (strncasecmp(type, "gold", strlen(type)) == 0) {
  10622. value = atoi64(sep->arg[2]) * 10000;
  10623. }
  10624. else if (strncasecmp(type, "plat", strlen(type)) == 0) {
  10625. value = atoi64(sep->arg[2]) * 1000000;
  10626. }
  10627. player->AddCoins(value);
  10628. if (client->GetPlayer() == player)
  10629. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  10630. else {
  10631. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  10632. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  10633. }
  10634. return;
  10635. }
  10636. }
  10637. }
  10638. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player coins syntax --");
  10639. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add [value] - adds the given number of coins to the player");
  10640. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add copper [value] - adds the given amount of copper to the player");
  10641. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add silver [value] - adds the given amount of silver to the player");
  10642. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add gold [value] - adds the given amount of gold to the player");
  10643. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add plat [value] - adds the given amount of platinum to the player");
  10644. }
  10645. void Commands::Command_AchievementAdd(Client* client, Seperator* sep) {
  10646. PrintSep(sep, "ACHIEVEMENT_ADD");
  10647. if (sep && sep->IsSet(0)) {
  10648. int32 spell_id = atoul(sep->arg[1]);
  10649. int8 spell_tier = 0;
  10650. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  10651. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  10652. // addspellbookentry here
  10653. if (spell_tier >= data->maxRank) {
  10654. return;
  10655. }
  10656. if (!spell_tier) {
  10657. spell_tier = 1;
  10658. }
  10659. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  10660. {
  10661. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  10662. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  10663. client->GetPlayer()->UnlockSpell(spell);
  10664. client->SendSpellUpdate(spell);
  10665. }
  10666. else
  10667. {
  10668. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1);
  10669. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  10670. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  10671. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  10672. client->GetPlayer()->UnlockSpell(spell);
  10673. client->SendSpellUpdate(spell);
  10674. }
  10675. // cast spell here
  10676. if (!spell_tier)
  10677. spell_tier = 1;
  10678. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  10679. if (spell) {
  10680. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  10681. }
  10682. }
  10683. else {
  10684. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  10685. }
  10686. master_aa_list.DisplayAA(client, 0, 0);
  10687. }
  10688. void Commands::Command_Editor(Client* client, Seperator* sep) {
  10689. PacketStruct* packet = configReader.getStruct("WS_ChoiceWindow", client->GetVersion());
  10690. if (packet) {
  10691. string url = string(rule_manager.GetGlobalRule(R_World, EditorURL)->GetString());
  10692. if (rule_manager.GetGlobalRule(R_World, EditorOfficialServer)->GetBool()) {
  10693. char command[255];
  10694. url = "browser " + url;
  10695. int32 spawn_id = 0;
  10696. int32 zone_id = 0;
  10697. string type;
  10698. if (client->GetCurrentZone())
  10699. zone_id = client->GetCurrentZone()->GetZoneID();
  10700. if (client->GetPlayer()->GetTarget()) {
  10701. Spawn* target = client->GetPlayer()->GetTarget();
  10702. if (target->IsWidget())
  10703. type = "widgets";
  10704. else if (target->IsSign())
  10705. type = "signs";
  10706. else if (target->IsObject())
  10707. type = "objects";
  10708. else if (target->IsNPC())
  10709. type = "npcs";
  10710. else if (target->IsGroundSpawn())
  10711. type = "ground";
  10712. else
  10713. type = "spawn";
  10714. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  10715. }
  10716. sprintf(command, url.c_str(), zone_id, type.c_str(), spawn_id);
  10717. packet->setDataByName("accept_command", command);
  10718. }
  10719. else if (rule_manager.GetGlobalRule(R_World, EditorIncludeID)->GetBool()) {
  10720. char command[255];
  10721. url = "browser " + url;
  10722. if (client->GetPlayer()->GetTarget())
  10723. sprintf(command, url.c_str(), client->GetPlayer()->GetTarget()->GetDatabaseID());
  10724. packet->setDataByName("accept_command", command);
  10725. }
  10726. else {
  10727. string command = "browser " + url;
  10728. packet->setDataByName("accept_command", command.c_str());
  10729. }
  10730. packet->setDataByName("text", "Open the web editor?");
  10731. packet->setDataByName("accept_text", "Open");
  10732. packet->setDataByName("cancel_text", "Cancel");
  10733. // No clue if we even need the following 2 unknowns, just added them so the packet matches what live sends
  10734. packet->setDataByName("unknown2", 50);
  10735. packet->setDataByName("unknown4", 1);
  10736. client->QueuePacket(packet->serialize());
  10737. safe_delete(packet);
  10738. }
  10739. }
  10740. void Commands::Command_AcceptResurrection(Client* client, Seperator* sep) {
  10741. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  10742. return;
  10743. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  10744. if(client->GetCurrentRez()->active)
  10745. client->AcceptResurrection();
  10746. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  10747. }
  10748. void Commands::Command_DeclineResurrection(Client* client, Seperator* sep) {
  10749. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  10750. return;
  10751. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  10752. if(client->GetCurrentRez()->active)
  10753. client->GetCurrentRez()->should_delete = true;
  10754. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  10755. }
  10756. void Commands::Switch_AA_Profile(Client* client, Seperator* sep) {
  10757. PrintSep(sep, "Switch_AA_Profile");
  10758. if (sep && sep->IsSet(0)) {
  10759. string type = sep->arg[0];
  10760. int8 newtemplate = atoul(sep->arg[1]);
  10761. master_aa_list.DisplayAA(client, newtemplate, 1);
  10762. }
  10763. }
  10764. void Commands::Get_AA_Xml(Client* client, Seperator* sep) {
  10765. PrintSep(sep, "Get_AA_Xml");
  10766. if (sep && sep->IsSet(0)) {
  10767. string tabnum = sep->arg[0];
  10768. string spellid = sep->arg[1];
  10769. }
  10770. }
  10771. void Commands::Add_AA(Client* client, Seperator* sep) {
  10772. PrintSep(sep, "Add_AA");
  10773. if (sep && sep->IsSet(0)) {
  10774. int32 spell_id = atoul(sep->arg[1]);
  10775. int8 spell_tier = 0;
  10776. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  10777. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  10778. // addspellbookentry here
  10779. if(!data) {
  10780. LogWrite(COMMAND__ERROR, 0, "Command", "Error in Add_AA no data for spell_id %u spell_tier %u", spell_id, spell_tier);
  10781. return;
  10782. }
  10783. if (spell_tier >= data->maxRank) {
  10784. LogWrite(COMMAND__ERROR, 0, "Command", "Error in Add_AA spell_tier %u >= maxRank %u", spell_tier, data->maxRank);
  10785. return;
  10786. }
  10787. if (!spell_tier) {
  10788. spell_tier = 1;
  10789. }
  10790. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  10791. {
  10792. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  10793. if(spell)
  10794. {
  10795. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  10796. client->GetPlayer()->UnlockSpell(spell);
  10797. client->SendSpellUpdate(spell);
  10798. }
  10799. }
  10800. else
  10801. {
  10802. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1 );
  10803. if(spell)
  10804. {
  10805. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  10806. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  10807. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  10808. client->GetPlayer()->UnlockSpell(spell);
  10809. client->SendSpellUpdate(spell);
  10810. }
  10811. }
  10812. // cast spell here
  10813. if (!spell_tier)
  10814. spell_tier = 1;
  10815. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  10816. if (spell) {
  10817. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  10818. }
  10819. }
  10820. else {
  10821. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  10822. }
  10823. master_aa_list.DisplayAA(client, 0, 0);
  10824. }
  10825. void Commands::Commit_AA_Profile(Client* client, Seperator* sep) {
  10826. PrintSep(sep, "Commit_AA_Profile");
  10827. if (sep && sep->IsSet(0)) {
  10828. }
  10829. }
  10830. void Commands::Begin_AA_Profile(Client* client, Seperator* sep) {
  10831. PrintSep(sep, "Begin_AA_Profile");
  10832. if (sep && sep->IsSet(0)) {
  10833. master_aa_list.DisplayAA(client, 100, 2);
  10834. }
  10835. }
  10836. void Commands::Back_AA(Client* client, Seperator* sep) {
  10837. if (sep && sep->IsSet(0)) {
  10838. PrintSep(sep, "Back_AA");
  10839. }
  10840. }
  10841. void Commands::Remove_AA(Client* client, Seperator* sep) {
  10842. if (sep && sep->IsSet(0)) {
  10843. PrintSep(sep, "Remove_AA");
  10844. }
  10845. }
  10846. void Commands::Cancel_AA_Profile(Client* client, Seperator* sep) {
  10847. MasterAAList master_aa_list;
  10848. PrintSep(sep, "Cancel_AA_Profile");
  10849. master_aa_list.DisplayAA(client, 0, 0);
  10850. }
  10851. void Commands::Save_AA_Profile(Client* client, Seperator* sep) {
  10852. if (sep && sep->IsSet(0)) {
  10853. PrintSep(sep, "Save_AA_Profile");
  10854. }
  10855. }
  10856. void Commands::Command_TargetItem(Client* client, Seperator* sep) {
  10857. if (!sep || sep->GetArgNumber() < 1 || !client->GetPlayer()) return;
  10858. if (!sep->IsNumber(0)) return;
  10859. int32 request_id = atoul(sep->arg[0]);
  10860. if (!sep->IsNumber(1)) return;
  10861. sint32 item_id = atoi(sep->arg[1]);
  10862. if (client->IsCurrentTransmuteID(request_id)) {
  10863. Transmute::HandleItemResponse(client, client->GetPlayer(), request_id, reinterpret_cast<int32&>(item_id));
  10864. }
  10865. else if (client->IsCurrentTransmuteID(item_id)) {
  10866. if (!sep->IsSet(2)) return;
  10867. if (sep->IsNumber(2) && atoi(sep->arg[2]) == 1) {
  10868. Transmute::HandleConfirmResponse(client, client->GetPlayer(), reinterpret_cast<int32&>(item_id));
  10869. }
  10870. }
  10871. }
  10872. void Commands::Command_FindSpawn(Client* client, Seperator* sep) {
  10873. if(sep)
  10874. client->GetCurrentZone()->FindSpawn(client, (char*)sep->argplus[0]);
  10875. }
  10876. void Commands::Command_MoveCharacter(Client* client, Seperator* sep) {
  10877. if(sep && sep->arg[0][0] && sep->arg[1][0])
  10878. {
  10879. char* name = sep->arg[0];
  10880. char* zoneName = sep->arg[1];
  10881. char query[256];
  10882. 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);
  10883. if (database.RunQuery(query, strnlen(query, 256)))
  10884. {
  10885. client->Message(CHANNEL_COLOR_YELLOW, "Ran query:%s", query);
  10886. }
  10887. else
  10888. client->Message(CHANNEL_COLOR_RED, "Query FAILED to run: %s", query);
  10889. }
  10890. }
  10891. void Commands::Command_Mood(Client* client, Seperator* sep) {
  10892. Player* player = client->GetPlayer();
  10893. if( sep && sep->arg[0] )
  10894. {
  10895. const char* value = sep->arg[0];
  10896. InfoStruct* info = player->GetInfoStruct();
  10897. int32 cid = client->GetCharacterID();
  10898. char* characterName = database.GetCharacterName(cid);
  10899. char tmp[1024]; // our emote string "xyz appears zyx"
  10900. //char properties vals
  10901. char* pname = "mood";
  10902. char* pval; // mood value
  10903. bool pt; //used to verify return from DB.
  10904. //This should never be seen.
  10905. sprintf(tmp, " ");
  10906. if( strncasecmp(value, "angry", strlen(value)) == 0 )
  10907. {
  10908. sprintf(tmp, "%s appears angry", characterName);
  10909. pval = "11852";
  10910. player->SetMoodState(11852, 1);
  10911. info->set_mood(11852);
  10912. pt = database.insertCharacterProperty(client, pname, pval);
  10913. }
  10914. else if( strncasecmp(value, "afraid", strlen(value)) == 0 )
  10915. {
  10916. sprintf(tmp, "%s appears afraid", characterName);
  10917. pval = "11851";
  10918. player->SetMoodState(11851, 1);
  10919. info->set_mood(11851);
  10920. pt = database.insertCharacterProperty(client, pname, pval);
  10921. }
  10922. else if( strncasecmp(value, "happy", strlen(value)) == 0 )
  10923. {
  10924. sprintf(tmp, "%s appears happy", characterName);
  10925. pval = "11854";
  10926. player->SetMoodState(11854, 1);
  10927. info->set_mood(11854);
  10928. pt = database.insertCharacterProperty(client, pname, pval);
  10929. }
  10930. else if( strncasecmp(value, "sad", strlen(value)) == 0 ) {
  10931. sprintf(tmp, "%s appears sad", characterName);
  10932. pval = "11856";
  10933. player->SetMoodState(11856, 1);
  10934. info->set_mood(11856);
  10935. pt = database.insertCharacterProperty(client, pname, pval);
  10936. }
  10937. else if( strncasecmp(value, "tired", strlen(value)) == 0 )
  10938. {
  10939. sprintf(tmp, "%s appears tired", characterName);
  10940. pval = "11857";
  10941. player->SetMoodState(11857, 1);
  10942. info->set_mood(11857);
  10943. pt = database.insertCharacterProperty(client, pname, pval);
  10944. }
  10945. else if( strncasecmp(value, "none", strlen(value)) == 0 )
  10946. {
  10947. //using 11855 mood_idle for none, I assume thats what its for?
  10948. pval = "11855";
  10949. player->SetMoodState(11855, 1);
  10950. info->set_mood(11855);
  10951. pt = database.insertCharacterProperty(client, pname, pval);
  10952. //return since we have nothing left to do. No emote for none.
  10953. return;
  10954. }else{
  10955. client->SimpleMessage(CHANNEL_NARRATIVE, "Listing Available Moods:");
  10956. client->SimpleMessage(CHANNEL_NARRATIVE, "none");
  10957. client->SimpleMessage(CHANNEL_NARRATIVE, "afraid");
  10958. client->SimpleMessage(CHANNEL_NARRATIVE, "angry");
  10959. client->SimpleMessage(CHANNEL_NARRATIVE, "happy");
  10960. client->SimpleMessage(CHANNEL_NARRATIVE, "sad");
  10961. client->SimpleMessage(CHANNEL_NARRATIVE, "tired");
  10962. return;
  10963. }
  10964. client->GetPlayer()->GetZone()->HandleChatMessage(0, 0, CHANNEL_EMOTE, tmp);
  10965. return;
  10966. }
  10967. client->SimpleMessage(CHANNEL_NARRATIVE, "Listing Available Moods:");
  10968. client->SimpleMessage(CHANNEL_NARRATIVE, "none");
  10969. client->SimpleMessage(CHANNEL_NARRATIVE, "afraid");
  10970. client->SimpleMessage(CHANNEL_NARRATIVE, "angry");
  10971. client->SimpleMessage(CHANNEL_NARRATIVE, "happy");
  10972. client->SimpleMessage(CHANNEL_NARRATIVE, "sad");
  10973. client->SimpleMessage(CHANNEL_NARRATIVE, "tired");
  10974. return;
  10975. }
  10976. /*
  10977. Function: Command_CancelEffect()
  10978. Purpose : Cancels (good) effect spells
  10979. Example : /cancel_effect spell_id - would cancel the spell with the <spell_id> value in spell effects list
  10980. */
  10981. void Commands::Command_CancelEffect(Client* client, Seperator* sep)
  10982. {
  10983. if (sep && sep->arg[0] && sep->IsNumber(0))
  10984. {
  10985. int32 spell_id = atoul(sep->arg[0]);
  10986. SpellEffects* effect = client->GetPlayer()->GetSpellEffect(spell_id);
  10987. if(!effect || effect->spell->spell->GetSpellData()->det_type) {
  10988. return;
  10989. }
  10990. MaintainedEffects* meffect = effect->caster->GetMaintainedSpell(spell_id);
  10991. if (!meffect || !meffect->spell || !meffect->spell->caster ||
  10992. !meffect->spell->caster->GetZone()->GetSpellProcess()->DeleteCasterSpell(meffect->spell, "canceled", false, client->GetPlayer()))
  10993. client->Message(CHANNEL_COLOR_RED, "The spell effect could not be cancelled.");
  10994. }
  10995. }
  10996. /*
  10997. Function: Command_CurePlayer()
  10998. Purpose : Identifies spell to cast for cure based on type
  10999. Example : /cureplayer ??
  11000. https://eq2.fandom.com/wiki/Update:58
  11001. New command /cureplayer [playername|group or raid position][trauma|arcane|noxious|elemental|curse] optional [spell|potion]
  11002. Example: /cureplayer g0 noxious spell
  11003. Will attempt to cure yourself of a noxious detriment with only spells and without using potions (even if you have them).
  11004. Example: /cureplayer r4 noxious
  11005. Will attempt to cure the character in raid slot 4 of a noxious detriment using a spell or potion (whichever is available).
  11006. */
  11007. void Commands::Command_CurePlayer(Client* client, Seperator* sep)
  11008. {
  11009. Entity* target = nullptr;
  11010. bool use_spells = true;
  11011. bool use_potions = true;
  11012. if (sep && sep->arg[0] && sep->arg[1]) {
  11013. if(sep->arg[2]) {
  11014. std::string type(sep->arg[2]);
  11015. boost::algorithm::to_lower(type);
  11016. if(type == "potion")
  11017. use_spells = false;
  11018. else if(type == "spell")
  11019. use_potions = false;
  11020. }
  11021. if(strlen(sep->arg[0]) > 1 && isdigit(sep->arg[0][1])) {
  11022. int32 mapped_position = (int32)(sep->arg[0][1]) - 48;
  11023. // TODO: RAID Support ('r' argument)
  11024. if(sep->arg[0][0] == 'g' && !mapped_position) {
  11025. target = (Entity*)client->GetPlayer();
  11026. }
  11027. else {
  11028. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  11029. if (gmi && gmi->group_id) {
  11030. PlayerGroup* group = world.GetGroupManager()->GetGroup(gmi->group_id);
  11031. if(group) {
  11032. target = group->GetGroupMemberByPosition(client->GetPlayer(), mapped_position);
  11033. }
  11034. }
  11035. }
  11036. }
  11037. else {
  11038. Client* target_client = zone_list.GetClientByCharName(sep->arg[0]);
  11039. if(target_client && target_client->GetPlayer() && target_client->GetPlayer()->GetZone() == client->GetPlayer()->GetZone()) {
  11040. target = (Entity*)target_client->GetPlayer();
  11041. }
  11042. }
  11043. ItemEffectType type = EFFECT_CURE_TYPE_ALL;
  11044. bool successful_spell = false;
  11045. bool successful_potion = false;
  11046. if(target) {
  11047. SpellBookEntry* entry = nullptr;
  11048. std::string str(sep->arg[1]);
  11049. boost::algorithm::to_lower(str);
  11050. if(str == "arcane") {
  11051. type = EFFECT_CURE_TYPE_ARCANE;
  11052. // cure arcane spell missing in DB?
  11053. if(use_spells && rule_manager.GetGlobalRule(R_Spells, CureArcaneSpellID)->GetInt32()) {
  11054. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureArcaneSpellID)->GetInt32()); // cure noxious
  11055. }
  11056. }
  11057. else if(str == "trauma") {
  11058. type = EFFECT_CURE_TYPE_TRAUMA;
  11059. // cure trauma spell missing in DB?
  11060. if(use_spells && rule_manager.GetGlobalRule(R_Spells, CureTraumaSpellID)->GetInt32()) {
  11061. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureTraumaSpellID)->GetInt32()); // cure noxious
  11062. }
  11063. }
  11064. else if(str == "noxious") {
  11065. type = EFFECT_CURE_TYPE_NOXIOUS;
  11066. if(use_spells && rule_manager.GetGlobalRule(R_Spells, CureNoxiousSpellID)->GetInt32()) {
  11067. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureNoxiousSpellID)->GetInt32()); // cure noxious
  11068. }
  11069. }
  11070. else if(str == "curse") {
  11071. type = EFFECT_CURE_TYPE_CURSE;
  11072. if(use_spells && rule_manager.GetGlobalRule(R_Spells, CureCurseSpellID)->GetInt32()) {
  11073. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureCurseSpellID)->GetInt32()); // cure curse
  11074. }
  11075. }
  11076. else if(str == "magic") {
  11077. type = EFFECT_CURE_TYPE_MAGIC;
  11078. if(use_spells && rule_manager.GetGlobalRule(R_Spells, CureMagicSpellID)->GetInt32()) {
  11079. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureMagicSpellID)->GetInt32()); // cure magic
  11080. }
  11081. }
  11082. if(use_spells) {
  11083. // check if any of the specific cure types are available, if not then check the base cures
  11084. if(!entry && rule_manager.GetGlobalRule(R_Spells, CureSpellID)->GetInt32()) {
  11085. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureSpellID)->GetInt32()); // cure
  11086. }
  11087. if(entry) {
  11088. Spell* spell = master_spell_list.GetSpell(entry->spell_id, entry->tier);
  11089. target->GetZone()->ProcessSpell(spell, (Entity*)client->GetPlayer(), target, true, false);
  11090. successful_spell = true;
  11091. }
  11092. }
  11093. }
  11094. if(!successful_spell && use_potions && target && type != NO_EFFECT_TYPE) {
  11095. vector<Item*>* potential_items = client->GetItemsByEffectType(type, EFFECT_CURE_TYPE_ALL);
  11096. if (potential_items && potential_items->size() > 0) {
  11097. vector<Item*>::iterator itr;
  11098. for (itr = potential_items->begin(); itr != potential_items->end(); itr++)
  11099. {
  11100. Item* item = *itr;
  11101. if(client->UseItem(item, target)) {
  11102. successful_potion = true;
  11103. break;
  11104. }
  11105. }
  11106. }
  11107. safe_delete(potential_items);
  11108. }
  11109. }
  11110. }