Commands.cpp 468 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783
  1. /*
  2. EQ2Emulator: Everquest II Server Emulator
  3. Copyright (C) 2007 EQ2EMulator Development Team (http://www.eq2emulator.net)
  4. This file is part of EQ2Emulator.
  5. EQ2Emulator is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. EQ2Emulator is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with EQ2Emulator. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #include <sys/types.h>
  17. #include <boost/algorithm/string/predicate.hpp>
  18. #include <boost/algorithm/string.hpp>
  19. #include "Commands.h"
  20. #include "../ClientPacketFunctions.h"
  21. #include "../../common/version.h"
  22. #include "../../common/seperator.h"
  23. #include "../../common/servertalk.h"
  24. #include "../WorldDatabase.h"
  25. #include "../World.h"
  26. #include "../../common/ConfigReader.h"
  27. #include "../VisualStates.h"
  28. #include "../../common/debug.h"
  29. #include "../LuaInterface.h"
  30. #include "../Quests.h"
  31. #include "../client.h"
  32. #include "../NPC.h"
  33. #include "../Guilds/Guild.h"
  34. #include "../SpellProcess.h"
  35. #include "../Tradeskills/Tradeskills.h"
  36. #include "../../common/Log.h"
  37. #include "../../common/MiscFunctions.h"
  38. #include "../Languages.h"
  39. #include "../Traits/Traits.h"
  40. #include "../Chat/Chat.h"
  41. #include "../Rules/Rules.h"
  42. #include "../AltAdvancement/AltAdvancement.h"
  43. #include "../RaceTypes/RaceTypes.h"
  44. #include "../classes.h"
  45. #include "../Transmute.h"
  46. #include "../Bots/Bot.h"
  47. #include "../Web/PeerManager.h"
  48. #include "../../common/GlobalHeaders.h"
  49. extern WorldDatabase database;
  50. extern MasterSpellList master_spell_list;
  51. extern MasterTraitList master_trait_list;
  52. extern MasterRecipeList master_recipe_list;
  53. extern MasterRecipeBookList master_recipebook_list;
  54. extern World world;
  55. extern ClientList client_list;
  56. extern ConfigReader configReader;
  57. extern VisualStates visual_states;
  58. extern ZoneList zone_list;
  59. extern LuaInterface* lua_interface;
  60. extern MasterQuestList master_quest_list;
  61. extern MasterCollectionList master_collection_list;
  62. extern MasterSkillList master_skill_list;
  63. extern MasterFactionList master_faction_list;
  64. extern GuildList guild_list;
  65. extern MasterLanguagesList master_languages_list;
  66. extern Chat chat;
  67. extern RuleManager rule_manager;
  68. extern MasterAAList master_aa_list;
  69. extern MasterRaceTypeList race_types_list;
  70. extern Classes classes;
  71. extern PeerManager peer_manager;
  72. //devn00b: Fix for linux builds since we dont use stricmp we use strcasecmp
  73. #if defined(__GNUC__)
  74. #define stricmp strcasecmp
  75. #define strnicmp strncasecmp
  76. #endif
  77. EQ2Packet* RemoteCommands::serialize(int16 version){
  78. buffer.clear();
  79. vector<EQ2_RemoteCommandString>::iterator command_list;
  80. buffer.append((char*)&num_commands, sizeof(int16));
  81. for( command_list = commands.begin(); command_list != commands.end(); command_list++ ) {
  82. AddDataCommand(&(*command_list));
  83. }
  84. EQ2Packet* app = new EQ2Packet(OP_SetRemoteCmdsMsg, (uchar*)buffer.c_str(), buffer.length() + 1);
  85. return app;
  86. }
  87. Commands::Commands(){
  88. remote_commands = new RemoteCommands();
  89. spawn_set_values["list"] = SPAWN_SET_VALUE_LIST;
  90. spawn_set_values["name"] = SPAWN_SET_VALUE_NAME;
  91. spawn_set_values["level"] = SPAWN_SET_VALUE_LEVEL; // TODO: Fix this, min_level, max_level
  92. spawn_set_values["difficulty"] = SPAWN_SET_VALUE_DIFFICULTY;
  93. spawn_set_values["model_type"] = SPAWN_SET_VALUE_MODEL_TYPE;
  94. spawn_set_values["class"] = SPAWN_SET_VALUE_CLASS;
  95. spawn_set_values["gender"] = SPAWN_SET_VALUE_GENDER;
  96. spawn_set_values["show_name"] = SPAWN_SET_VALUE_SHOW_NAME;
  97. spawn_set_values["attackable"] = SPAWN_SET_VALUE_ATTACKABLE;
  98. spawn_set_values["show_level"] = SPAWN_SET_VALUE_SHOW_LEVEL;
  99. spawn_set_values["targetable"] = SPAWN_SET_VALUE_TARGETABLE;
  100. spawn_set_values["show_command_icon"] = SPAWN_SET_VALUE_SHOW_COMMAND_ICON;
  101. spawn_set_values["display_hand_icon"] = SPAWN_SET_VALUE_HAND_ICON;
  102. spawn_set_values["hair_type"] = SPAWN_SET_VALUE_HAIR_TYPE;
  103. spawn_set_values["facial_hair_type"] = SPAWN_SET_VALUE_FACIAL_HAIR_TYPE;
  104. spawn_set_values["wing_type"] = SPAWN_SET_VALUE_WING_TYPE;
  105. spawn_set_values["chest_type"] = SPAWN_SET_VALUE_CHEST_TYPE;
  106. spawn_set_values["legs_type"] = SPAWN_SET_VALUE_LEGS_TYPE;
  107. spawn_set_values["soga_hair_type"] = SPAWN_SET_VALUE_SOGA_HAIR_TYPE;
  108. spawn_set_values["soga_facial_hair_type"] = SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE;
  109. spawn_set_values["soga_model_type"] = SPAWN_SET_VALUE_SOGA_MODEL_TYPE;
  110. spawn_set_values["size"] = SPAWN_SET_VALUE_SIZE;
  111. spawn_set_values["hp"] = SPAWN_SET_VALUE_HP;
  112. spawn_set_values["power"] = SPAWN_SET_VALUE_POWER;
  113. spawn_set_values["heroic"] = SPAWN_SET_VALUE_HEROIC;
  114. spawn_set_values["respawn"] = SPAWN_SET_VALUE_RESPAWN;
  115. spawn_set_values["x"] = SPAWN_SET_VALUE_X;
  116. spawn_set_values["y"] = SPAWN_SET_VALUE_Y;
  117. spawn_set_values["z"] = SPAWN_SET_VALUE_Z;
  118. spawn_set_values["heading"] = SPAWN_SET_VALUE_HEADING;
  119. spawn_set_values["location"] = SPAWN_SET_VALUE_LOCATION;
  120. spawn_set_values["command_primary"] = SPAWN_SET_VALUE_COMMAND_PRIMARY;
  121. spawn_set_values["command_secondary"] = SPAWN_SET_VALUE_COMMAND_SECONDARY;
  122. spawn_set_values["visual_state"] = SPAWN_SET_VALUE_VISUAL_STATE;
  123. spawn_set_values["action_state"] = SPAWN_SET_VALUE_ACTION_STATE;
  124. spawn_set_values["mood_state"] = SPAWN_SET_VALUE_MOOD_STATE;
  125. spawn_set_values["initial_state"] = SPAWN_SET_VALUE_INITIAL_STATE;
  126. spawn_set_values["activity_state"] = SPAWN_SET_VALUE_ACTIVITY_STATE;
  127. spawn_set_values["collision_radius"] = SPAWN_SET_VALUE_COLLISION_RADIUS;
  128. spawn_set_values["faction"] = SPAWN_SET_VALUE_FACTION;
  129. spawn_set_values["spawn_script"] = SPAWN_SET_VALUE_SPAWN_SCRIPT;
  130. spawn_set_values["spawnentry_script"] = SPAWN_SET_VALUE_SPAWNENTRY_SCRIPT;
  131. spawn_set_values["spawnlocation_script"] = SPAWN_SET_VALUE_SPAWNLOCATION_SCRIPT;
  132. spawn_set_values["sub_title"] = SPAWN_SET_VALUE_SUB_TITLE;
  133. spawn_set_values["expire"] = SPAWN_SET_VALUE_EXPIRE;
  134. spawn_set_values["expire_offset"] = SPAWN_SET_VALUE_EXPIRE_OFFSET;
  135. spawn_set_values["x_offset"] = SPAWN_SET_VALUE_X_OFFSET;
  136. spawn_set_values["y_offset"] = SPAWN_SET_VALUE_Y_OFFSET;
  137. spawn_set_values["z_offset"] = SPAWN_SET_VALUE_Z_OFFSET;
  138. spawn_set_values["device_id"] = SPAWN_SET_VALUE_DEVICE_ID;
  139. spawn_set_values["pitch"] = SPAWN_SET_VALUE_PITCH;
  140. spawn_set_values["roll"] = SPAWN_SET_VALUE_ROLL;
  141. spawn_set_values["hide_hood"] = SPAWN_SET_VALUE_HIDE_HOOD;
  142. spawn_set_values["emote_state"] = SPAWN_SET_VALUE_EMOTE_STATE;
  143. spawn_set_values["icon"] = SPAWN_SET_VALUE_ICON;
  144. spawn_set_values["prefix"] = SPAWN_SET_VALUE_PREFIX;
  145. spawn_set_values["suffix"] = SPAWN_SET_VALUE_SUFFIX;
  146. spawn_set_values["lastname"] = SPAWN_SET_VALUE_LASTNAME;
  147. spawn_set_values["expansion_flag"] = SPAWN_SET_VALUE_EXPANSION_FLAG;
  148. spawn_set_values["holiday_flag"] = SPAWN_SET_VALUE_HOLIDAY_FLAG;
  149. spawn_set_values["merchant_min_level"] = SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL;
  150. spawn_set_values["merchant_max_level"] = SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL;
  151. spawn_set_values["skin_color"] = SPAWN_SET_SKIN_COLOR;
  152. spawn_set_values["aaxp_rewards"] = SPAWN_SET_AAXP_REWARDS;
  153. spawn_set_values["hair_color1"] = SPAWN_SET_HAIR_COLOR1;
  154. spawn_set_values["hair_color2"] = SPAWN_SET_HAIR_COLOR2;
  155. spawn_set_values["hair_type_color"] = SPAWN_SET_HAIR_TYPE_COLOR;
  156. spawn_set_values["hair_face_color"] = SPAWN_SET_HAIR_FACE_COLOR;
  157. spawn_set_values["hair_type_highlight_color"] = SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR;
  158. spawn_set_values["face_hairlight_color"] = SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR;
  159. spawn_set_values["hair_highlight"] = SPAWN_SET_HAIR_HIGHLIGHT;
  160. spawn_set_values["model_color"] = SPAWN_SET_MODEL_COLOR;
  161. spawn_set_values["eye_color"] = SPAWN_SET_EYE_COLOR;
  162. spawn_set_values["soga_skin_color"] = SPAWN_SET_SOGA_SKIN_COLOR;
  163. spawn_set_values["soga_hair_color1"] = SPAWN_SET_SOGA_HAIR_COLOR1;
  164. spawn_set_values["soga_hair_color2"] = SPAWN_SET_SOGA_HAIR_COLOR2;
  165. spawn_set_values["soga_hair_type_color"] = SPAWN_SET_SOGA_HAIR_TYPE_COLOR;
  166. spawn_set_values["soga_hair_face_color"] = SPAWN_SET_SOGA_HAIR_FACE_COLOR;
  167. spawn_set_values["soga_hair_type_highlight_color"] = SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR;
  168. spawn_set_values["soga_face_hairlight_color"] = SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR;
  169. spawn_set_values["soga_hair_highlight"] = SPAWN_SET_SOGA_HAIR_HIGHLIGHT;
  170. spawn_set_values["soga_model_color"] = SPAWN_SET_SOGA_MODEL_COLOR;
  171. spawn_set_values["soga_eye_color"] = SPAWN_SET_SOGA_EYE_COLOR;
  172. spawn_set_values["cheek_type"] = SPAWN_SET_CHEEK_TYPE;
  173. spawn_set_values["chin_type"] = SPAWN_SET_CHIN_TYPE;
  174. spawn_set_values["ear_type"] = SPAWN_SET_EAR_TYPE;
  175. spawn_set_values["eye_brow_type"] = SPAWN_SET_EYE_BROW_TYPE;
  176. spawn_set_values["eye_type"] = SPAWN_SET_EYE_TYPE;
  177. spawn_set_values["lip_type"] = SPAWN_SET_LIP_TYPE;
  178. spawn_set_values["nose_type"] = SPAWN_SET_NOSE_TYPE;
  179. spawn_set_values["body_size"] = SPAWN_SET_BODY_SIZE;
  180. spawn_set_values["body_age"] = SPAWN_SET_BODY_AGE;
  181. spawn_set_values["soga_cheek_type"] = SPAWN_SET_SOGA_CHEEK_TYPE;
  182. spawn_set_values["soga_chin_type"] = SPAWN_SET_SOGA_CHIN_TYPE;
  183. spawn_set_values["soga_ear_type"] = SPAWN_SET_SOGA_EAR_TYPE;
  184. spawn_set_values["soga_eye_brow_type"] = SPAWN_SET_SOGA_EYE_BROW_TYPE;
  185. spawn_set_values["soga_eye_type"] = SPAWN_SET_SOGA_EYE_TYPE;
  186. spawn_set_values["soga_lip_type"] = SPAWN_SET_SOGA_LIP_TYPE;
  187. spawn_set_values["soga_nose_type"] = SPAWN_SET_SOGA_NOSE_TYPE;
  188. spawn_set_values["soga_body_size"] = SPAWN_SET_SOGA_BODY_SIZE;
  189. spawn_set_values["soga_body_age"] = SPAWN_SET_SOGA_BODY_AGE;
  190. spawn_set_values["attack_type"] = SPAWN_SET_ATTACK_TYPE;
  191. spawn_set_values["race_type"] = SPAWN_SET_RACE_TYPE;
  192. spawn_set_values["loot_tier"] = SPAWN_SET_LOOT_TIER;
  193. spawn_set_values["loot_drop_type"] = SPAWN_SET_LOOT_DROP_TYPE;
  194. spawn_set_values["scared_strong_players"] = SPAWN_SET_SCARED_STRONG_PLAYERS;
  195. zone_set_values["expansion_id"] = ZONE_SET_VALUE_EXPANSION_ID;
  196. zone_set_values["name"] = ZONE_SET_VALUE_NAME;
  197. zone_set_values["file"] = ZONE_SET_VALUE_FILE ;
  198. zone_set_values["description"] = ZONE_SET_VALUE_DESCRIPTION;
  199. zone_set_values["safe_x"] = ZONE_SET_VALUE_SAFE_X;
  200. zone_set_values["safe_y"] = ZONE_SET_VALUE_SAFE_Y;
  201. zone_set_values["safe_z"] = ZONE_SET_VALUE_SAFE_Z;
  202. zone_set_values["underworld"] = ZONE_SET_VALUE_UNDERWORLD;
  203. zone_set_values["min_recommended"] = ZONE_SET_VALUE_MIN_RECOMMENDED;
  204. zone_set_values["max_recommended"] = ZONE_SET_VALUE_MAX_RECOMMENDED;
  205. zone_set_values["zone_type"] = ZONE_SET_VALUE_ZONE_TYPE;
  206. zone_set_values["always_loaded"] = ZONE_SET_VALUE_ALWAYS_LOADED;
  207. zone_set_values["city_zone"] = ZONE_SET_VALUE_CITY_ZONE;
  208. zone_set_values["weather_allowed"] = ZONE_SET_VALUE_WEATHER_ALLOWED;
  209. zone_set_values["min_status"] = ZONE_SET_VALUE_MIN_STATUS;
  210. zone_set_values["min_level"] = ZONE_SET_VALUE_MIN_LEVEL;
  211. zone_set_values["start_zone"] = ZONE_SET_VALUE_START_ZONE;
  212. zone_set_values["instance_type"] = ZONE_SET_VALUE_INSTANCE_TYPE;
  213. zone_set_values["default_reenter_time"] = ZONE_SET_VALUE_DEFAULT_REENTER_TIME;
  214. zone_set_values["default_reset_time"] = ZONE_SET_VALUE_DEFAULT_RESET_TIME;
  215. zone_set_values["default_lockout_time"] = ZONE_SET_VALUE_DEFAULT_LOCKOUT_TIME;
  216. zone_set_values["force_group_to_zone"] = ZONE_SET_VALUE_FORCE_GROUP_TO_ZONE;
  217. zone_set_values["lua_script"] = ZONE_SET_VALUE_LUA_SCRIPT;
  218. zone_set_values["shutdown_timer"] = ZONE_SET_VALUE_SHUTDOWN_TIMER;
  219. zone_set_values["zone_motd"] = ZONE_SET_VALUE_ZONE_MOTD;
  220. }
  221. Commands::~Commands() {
  222. safe_delete(remote_commands);
  223. }
  224. int32 Commands::GetSpawnSetType(string val){
  225. if(spawn_set_values.count(val) > 0)
  226. return spawn_set_values[val];
  227. return 0xFFFFFFFF;
  228. }
  229. bool Commands::SetSpawnCommand(Client* client, Spawn* target, int8 type, const char* value, bool send_update, bool temporary, string* temp_value, int8 index){
  230. if(!target)
  231. return false;
  232. int32 val = 0;
  233. try{
  234. if(type != SPAWN_SET_VALUE_NAME &&
  235. !(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))
  236. {
  237. switch(type)
  238. {
  239. case SPAWN_SET_SKIN_COLOR:
  240. case SPAWN_SET_HAIR_COLOR1:
  241. case SPAWN_SET_HAIR_COLOR2:
  242. case SPAWN_SET_HAIR_TYPE_COLOR:
  243. case SPAWN_SET_HAIR_FACE_COLOR:
  244. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  245. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  246. case SPAWN_SET_HAIR_HIGHLIGHT:
  247. case SPAWN_SET_EYE_COLOR:
  248. case SPAWN_SET_SOGA_SKIN_COLOR:
  249. case SPAWN_SET_SOGA_HAIR_COLOR1:
  250. case SPAWN_SET_SOGA_HAIR_COLOR2:
  251. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  252. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  253. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  254. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  255. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  256. case SPAWN_SET_SOGA_EYE_COLOR:
  257. case SPAWN_SET_RACE_TYPE:
  258. // ignore these are colors can't pass as a integer value
  259. break;
  260. default:
  261. val = atoul(value);
  262. }
  263. }
  264. }
  265. catch(...){
  266. if(client)
  267. client->Message(CHANNEL_COLOR_RED, "Invalid numeric spawn value: %s", value);
  268. return false;
  269. }
  270. if(temporary){
  271. char tmp[128] = {0};
  272. switch(type){
  273. case SPAWN_SET_VALUE_NAME:{
  274. sprintf(tmp, "%s", target->GetName());
  275. target->SetName(value);
  276. if(target->GetZone())
  277. target->GetZone()->SendUpdateTitles(target);
  278. break;
  279. }
  280. case SPAWN_SET_VALUE_X_OFFSET:
  281. {
  282. sprintf(tmp, "%f", target->GetXOffset());
  283. target->SetXOffset(float(val));
  284. break;
  285. }
  286. case SPAWN_SET_VALUE_Y_OFFSET:
  287. {
  288. sprintf(tmp, "%f", target->GetYOffset());
  289. target->SetYOffset(float(val));
  290. break;
  291. }
  292. case SPAWN_SET_VALUE_Z_OFFSET:
  293. {
  294. sprintf(tmp, "%f", target->GetZOffset());
  295. target->SetZOffset(float(val));
  296. break;
  297. }
  298. case SPAWN_SET_VALUE_EXPIRE: {
  299. sprintf(tmp, "%u", target->GetExpireTime());
  300. target->SetExpireTime(val);
  301. break;
  302. }
  303. case SPAWN_SET_VALUE_EXPIRE_OFFSET: {
  304. sprintf(tmp, "%u", target->GetExpireOffsetTime());
  305. target->SetExpireOffsetTime(val);
  306. break;
  307. }
  308. case SPAWN_SET_VALUE_SUB_TITLE: {
  309. sprintf(tmp, "%s", target->GetSubTitle());
  310. target->SetSubTitle(value);
  311. if(target->GetZone())
  312. target->GetZone()->SendUpdateTitles(target);
  313. break;
  314. }
  315. case SPAWN_SET_VALUE_LEVEL:{
  316. sprintf(tmp, "%i", target->GetLevel());
  317. target->SetLevel(val, send_update);
  318. break;
  319. }
  320. case SPAWN_SET_VALUE_DIFFICULTY:{
  321. sprintf(tmp, "%i", target->GetDifficulty());
  322. target->SetDifficulty(val, send_update);
  323. break;
  324. }
  325. case SPAWN_SET_VALUE_MODEL_TYPE:{
  326. sprintf(tmp, "%i", target->GetModelType());
  327. target->SetModelType(val, send_update);
  328. break;
  329. }
  330. case SPAWN_SET_VALUE_CLASS:{
  331. sprintf(tmp, "%i", target->GetAdventureClass());
  332. target->SetAdventureClass(val, send_update);
  333. break;
  334. }
  335. case SPAWN_SET_VALUE_GENDER:{
  336. sprintf(tmp, "%i", target->GetGender());
  337. target->SetGender(val, send_update);
  338. break;
  339. }
  340. case SPAWN_SET_VALUE_SHOW_NAME:{
  341. sprintf(tmp, "%i", target->GetShowName());
  342. target->SetShowName(val, send_update);
  343. break;
  344. }
  345. case SPAWN_SET_VALUE_ATTACKABLE:{
  346. sprintf(tmp, "%i", target->GetAttackable());
  347. target->SetAttackable(val, send_update);
  348. break;
  349. }
  350. case SPAWN_SET_VALUE_SHOW_LEVEL:{
  351. sprintf(tmp, "%i", target->GetShowLevel());
  352. target->SetShowLevel(val, send_update);
  353. break;
  354. }
  355. case SPAWN_SET_VALUE_TARGETABLE:{
  356. sprintf(tmp, "%i", target->GetTargetable());
  357. target->SetTargetable(val, send_update);
  358. break;
  359. }
  360. case SPAWN_SET_VALUE_SHOW_COMMAND_ICON:{
  361. sprintf(tmp, "%i", target->GetShowCommandIcon());
  362. target->SetShowCommandIcon(val, send_update);
  363. break;
  364. }
  365. case SPAWN_SET_VALUE_HAND_ICON:{
  366. sprintf(tmp, "%i", target->GetShowHandIcon());
  367. target->SetShowHandIcon(val, send_update);
  368. break;
  369. }
  370. case SPAWN_SET_VALUE_HAIR_TYPE:{
  371. if(target->IsEntity()){
  372. sprintf(tmp, "%i", ((Entity*)target)->GetHairType());
  373. ((Entity*)target)->SetHairType(val, send_update);
  374. }
  375. break;
  376. }
  377. case SPAWN_SET_VALUE_FACIAL_HAIR_TYPE:{
  378. if(target->IsEntity()){
  379. sprintf(tmp, "%i", ((Entity*)target)->GetFacialHairType());
  380. ((Entity*)target)->SetFacialHairType(val, send_update);
  381. }
  382. break;
  383. }
  384. case SPAWN_SET_VALUE_WING_TYPE:{
  385. if(target->IsEntity()){
  386. sprintf(tmp, "%i", ((Entity*)target)->GetWingType());
  387. ((Entity*)target)->SetWingType(val, send_update);
  388. }
  389. break;
  390. }
  391. case SPAWN_SET_VALUE_CHEST_TYPE:{
  392. if(target->IsEntity()){
  393. sprintf(tmp, "%i", ((Entity*)target)->GetChestType());
  394. ((Entity*)target)->SetChestType(val, send_update);
  395. }
  396. break;
  397. }
  398. case SPAWN_SET_VALUE_LEGS_TYPE:{
  399. if(target->IsEntity()){
  400. sprintf(tmp, "%i", ((Entity*)target)->GetLegsType());
  401. ((Entity*)target)->SetLegsType(val, send_update);
  402. }
  403. break;
  404. }
  405. case SPAWN_SET_VALUE_SOGA_HAIR_TYPE:{
  406. if(target->IsEntity()){
  407. sprintf(tmp, "%i", ((Entity*)target)->GetSogaHairType());
  408. ((Entity*)target)->SetSogaHairType(val, send_update);
  409. }
  410. break;
  411. }
  412. case SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE:{
  413. if(target->IsEntity()){
  414. sprintf(tmp, "%i", ((Entity*)target)->GetSogaFacialHairType());
  415. ((Entity*)target)->SetSogaFacialHairType(val, send_update);
  416. }
  417. break;
  418. }
  419. case SPAWN_SET_VALUE_SOGA_MODEL_TYPE:{
  420. sprintf(tmp, "%i", target->GetSogaModelType());
  421. target->SetSogaModelType(val, send_update);
  422. break;
  423. }
  424. case SPAWN_SET_VALUE_SIZE:{
  425. sprintf(tmp, "%i", target->GetSize());
  426. target->SetSize(val, send_update);
  427. break;
  428. }
  429. case SPAWN_SET_VALUE_HP:{
  430. sprintf(tmp, "%i", target->GetHP());
  431. target->SetTotalHPBase(val);
  432. target->SetHP(val, send_update);
  433. break;
  434. }
  435. case SPAWN_SET_VALUE_POWER:{
  436. sprintf(tmp, "%i", target->GetPower());
  437. target->SetTotalPowerBase(val);
  438. target->SetPower(val, send_update);
  439. break;
  440. }
  441. case SPAWN_SET_VALUE_HEROIC:{
  442. sprintf(tmp, "%i", target->GetHeroic());
  443. target->SetHeroic(val, send_update);
  444. break;
  445. }
  446. case SPAWN_SET_VALUE_RESPAWN:{
  447. sprintf(tmp, "%u", target->GetRespawnTime());
  448. target->SetRespawnTime(val);
  449. break;
  450. }
  451. case SPAWN_SET_VALUE_X:{
  452. sprintf(tmp, "%f", target->GetX());
  453. target->SetX(atof(value), send_update);
  454. break;
  455. }
  456. case SPAWN_SET_VALUE_Y:{
  457. sprintf(tmp, "%f", target->GetY());
  458. target->SetY(atof(value), send_update);
  459. break;
  460. }
  461. case SPAWN_SET_VALUE_Z:{
  462. sprintf(tmp, "%f", target->GetZ());
  463. target->SetZ(atof(value), send_update);
  464. break;
  465. }
  466. case SPAWN_SET_VALUE_HEADING:{
  467. sprintf(tmp, "%f", target->GetHeading());
  468. target->SetHeading(atof(value) + 360, send_update);
  469. break;
  470. }
  471. case SPAWN_SET_VALUE_VISUAL_STATE:{
  472. sprintf(tmp, "%i", target->GetVisualState());
  473. target->SetVisualState(val, send_update);
  474. break;
  475. }
  476. case SPAWN_SET_VALUE_ACTION_STATE:{
  477. sprintf(tmp, "%i", target->GetActionState());
  478. target->SetActionState(val, send_update);
  479. break;
  480. }
  481. case SPAWN_SET_VALUE_MOOD_STATE:{
  482. sprintf(tmp, "%i", target->GetMoodState());
  483. target->SetMoodState(val, send_update);
  484. break;
  485. }
  486. case SPAWN_SET_VALUE_INITIAL_STATE:{
  487. sprintf(tmp, "%i", target->GetInitialState());
  488. target->SetInitialState(val, send_update);
  489. break;
  490. }
  491. case SPAWN_SET_VALUE_ACTIVITY_STATE:{
  492. sprintf(tmp, "%i", target->GetActivityStatus());
  493. target->SetActivityStatus(val, send_update);
  494. break;
  495. }
  496. case SPAWN_SET_VALUE_COLLISION_RADIUS:{
  497. sprintf(tmp, "%i", target->GetCollisionRadius());
  498. target->SetCollisionRadius(val, send_update);
  499. break;
  500. }
  501. case SPAWN_SET_VALUE_DEVICE_ID: {
  502. if (target->IsObject()) {
  503. sprintf(tmp, "%i", ((Object*)target)->GetDeviceID());
  504. ((Object*)target)->SetDeviceID(val);
  505. }
  506. break;
  507. }
  508. case SPAWN_SET_VALUE_PITCH: {
  509. sprintf(tmp, "%f", target->GetPitch());
  510. target->SetPitch(atof(value), send_update);
  511. break;
  512. }
  513. case SPAWN_SET_VALUE_ROLL: {
  514. sprintf(tmp, "%f", target->GetRoll());
  515. target->SetRoll(atof(value), send_update);
  516. break;
  517. }
  518. case SPAWN_SET_VALUE_HIDE_HOOD: {
  519. sprintf(tmp, "%i", target->appearance.hide_hood);
  520. target->SetHideHood(val);
  521. break;
  522. }
  523. case SPAWN_SET_VALUE_EMOTE_STATE: {
  524. sprintf(tmp, "%i", target->appearance.emote_state);
  525. target->SetEmoteState(val);
  526. break;
  527. }
  528. case SPAWN_SET_VALUE_ICON: {
  529. sprintf(tmp, "%i", target->GetIconValue());
  530. target->SetIcon(val);
  531. break;
  532. }
  533. case SPAWN_SET_VALUE_PREFIX: {
  534. sprintf(tmp, "%s", target->GetPrefixTitle());
  535. target->SetPrefixTitle(value);
  536. if(target->GetZone())
  537. target->GetZone()->SendUpdateTitles(target);
  538. break;
  539. }
  540. case SPAWN_SET_VALUE_SUFFIX: {
  541. sprintf(tmp, "%s", target->GetSuffixTitle());
  542. target->SetSuffixTitle(value);
  543. if(target->GetZone())
  544. target->GetZone()->SendUpdateTitles(target);
  545. break;
  546. }
  547. case SPAWN_SET_VALUE_LASTNAME: {
  548. sprintf(tmp, "%s", target->GetLastName());
  549. target->SetLastName(value);
  550. if(target->GetZone())
  551. target->GetZone()->SendUpdateTitles(target);
  552. break;
  553. }
  554. case SPAWN_SET_VALUE_EXPANSION_FLAG:
  555. case SPAWN_SET_VALUE_HOLIDAY_FLAG: {
  556. // nothing to do must reload spawns
  557. break;
  558. }
  559. case SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL: {
  560. sprintf(tmp, "%i", target->GetMerchantMinLevel());
  561. target->SetMerchantLevelRange(atoul(value), target->GetMerchantMaxLevel());
  562. break;
  563. }
  564. case SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL: {
  565. sprintf(tmp, "%i", target->GetMerchantMaxLevel());
  566. target->SetMerchantLevelRange(target->GetMerchantMinLevel(), atoul(value));
  567. break;
  568. }
  569. case SPAWN_SET_VALUE_FACTION:{
  570. sprintf(tmp, "%i", target->faction_id);
  571. ZoneServer* zone = target->GetZone();
  572. if (!zone && client)
  573. zone = client->GetCurrentZone();
  574. target->faction_id = atoul(value);
  575. if(zone)
  576. {
  577. zone->RemoveDeadEnemyList(target);
  578. if(target->IsNPC())
  579. zone->AddEnemyList((NPC*)target);
  580. }
  581. break;
  582. }
  583. case SPAWN_SET_SKIN_COLOR:
  584. case SPAWN_SET_HAIR_COLOR1:
  585. case SPAWN_SET_HAIR_COLOR2:
  586. case SPAWN_SET_HAIR_TYPE_COLOR:
  587. case SPAWN_SET_HAIR_FACE_COLOR:
  588. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  589. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  590. case SPAWN_SET_HAIR_HIGHLIGHT:
  591. case SPAWN_SET_MODEL_COLOR:
  592. case SPAWN_SET_EYE_COLOR:
  593. case SPAWN_SET_SOGA_SKIN_COLOR:
  594. case SPAWN_SET_SOGA_HAIR_COLOR1:
  595. case SPAWN_SET_SOGA_HAIR_COLOR2:
  596. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  597. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  598. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  599. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  600. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  601. case SPAWN_SET_SOGA_MODEL_COLOR:
  602. case SPAWN_SET_SOGA_EYE_COLOR:
  603. {
  604. if (target->IsEntity())
  605. {
  606. Seperator* skinsep = new Seperator(value, ' ', 3, 500, true);
  607. if (skinsep->IsNumber(0) && skinsep->IsNumber(1) && skinsep->IsNumber(2))
  608. {
  609. EQ2_Color clr;
  610. clr.red = atoul(skinsep->arg[0]);
  611. clr.green = atoul(skinsep->arg[1]);
  612. clr.blue = atoul(skinsep->arg[2]);
  613. switch(type)
  614. {
  615. case SPAWN_SET_SKIN_COLOR:
  616. ((Entity*)target)->SetSkinColor(clr);
  617. break;
  618. case SPAWN_SET_HAIR_COLOR1:
  619. ((Entity*)target)->SetHairColor1(clr);
  620. break;
  621. case SPAWN_SET_HAIR_COLOR2:
  622. ((Entity*)target)->SetHairColor2(clr);
  623. break;
  624. case SPAWN_SET_HAIR_TYPE_COLOR:
  625. ((Entity*)target)->SetHairColor(clr);
  626. break;
  627. case SPAWN_SET_HAIR_FACE_COLOR:
  628. ((Entity*)target)->SetFacialHairColor(clr);
  629. break;
  630. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  631. ((Entity*)target)->SetHairTypeHighlightColor(clr);
  632. break;
  633. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  634. ((Entity*)target)->SetFacialHairHighlightColor(clr);
  635. break;
  636. case SPAWN_SET_HAIR_HIGHLIGHT:
  637. ((Entity*)target)->SetHairHighlightColor(clr);
  638. break;
  639. case SPAWN_SET_MODEL_COLOR:
  640. ((Entity*)target)->SetModelColor(clr);
  641. break;
  642. case SPAWN_SET_EYE_COLOR:
  643. ((Entity*)target)->SetEyeColor(clr);
  644. break;
  645. case SPAWN_SET_SOGA_SKIN_COLOR:
  646. ((Entity*)target)->SetSogaSkinColor(clr);
  647. break;
  648. case SPAWN_SET_SOGA_HAIR_COLOR1:
  649. ((Entity*)target)->SetSogaHairColor1(clr);
  650. break;
  651. case SPAWN_SET_SOGA_HAIR_COLOR2:
  652. ((Entity*)target)->SetSogaHairColor2(clr);
  653. break;
  654. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  655. ((Entity*)target)->SetSogaHairColor(clr);
  656. break;
  657. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  658. ((Entity*)target)->SetSogaFacialHairColor(clr);
  659. break;
  660. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  661. ((Entity*)target)->SetSogaHairTypeHighlightColor(clr);
  662. break;
  663. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  664. ((Entity*)target)->SetSogaFacialHairHighlightColor(clr);
  665. break;
  666. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  667. ((Entity*)target)->SetSogaHairHighlightColor(clr);
  668. break;
  669. case SPAWN_SET_SOGA_MODEL_COLOR:
  670. ((Entity*)target)->SetSogaModelColor(clr);
  671. break;
  672. case SPAWN_SET_SOGA_EYE_COLOR:
  673. ((Entity*)target)->SetSogaEyeColor(clr);
  674. break;
  675. }
  676. }
  677. safe_delete(skinsep);
  678. }
  679. break;
  680. }
  681. case SPAWN_SET_AAXP_REWARDS: {
  682. target->SetAAXPRewards(atoul(value));
  683. break;
  684. }
  685. case SPAWN_SET_CHEEK_TYPE:{
  686. if(target->IsEntity() && index < 3){
  687. sprintf(tmp, "%i", ((Entity*)target)->features.cheek_type[index]);
  688. sint8 new_value = atoi(value);
  689. ((Entity*)target)->features.cheek_type[index] = new_value;
  690. ((Entity*)target)->info_changed = true;
  691. }
  692. break;
  693. }
  694. case SPAWN_SET_CHIN_TYPE:{
  695. if(target->IsEntity() && index < 3){
  696. sprintf(tmp, "%i", ((Entity*)target)->features.chin_type[index]);
  697. sint8 new_value = atoi(value);
  698. ((Entity*)target)->features.chin_type[index] = new_value;
  699. ((Entity*)target)->info_changed = true;
  700. }
  701. break;
  702. }
  703. case SPAWN_SET_EAR_TYPE:{
  704. if(target->IsEntity() && index < 3){
  705. sprintf(tmp, "%i", ((Entity*)target)->features.ear_type[index]);
  706. sint8 new_value = atoi(value);
  707. ((Entity*)target)->features.ear_type[index] = new_value;
  708. ((Entity*)target)->info_changed = true;
  709. }
  710. break;
  711. }
  712. case SPAWN_SET_EYE_BROW_TYPE:{
  713. if(target->IsEntity() && index < 3){
  714. sprintf(tmp, "%i", ((Entity*)target)->features.eye_brow_type[index]);
  715. sint8 new_value = atoi(value);
  716. ((Entity*)target)->features.eye_brow_type[index] = new_value;
  717. ((Entity*)target)->info_changed = true;
  718. }
  719. break;
  720. }
  721. case SPAWN_SET_EYE_TYPE:{
  722. if(target->IsEntity() && index < 3){
  723. sprintf(tmp, "%i", ((Entity*)target)->features.eye_type[index]);
  724. sint8 new_value = atoi(value);
  725. ((Entity*)target)->features.eye_type[index] = new_value;
  726. ((Entity*)target)->info_changed = true;
  727. }
  728. break;
  729. }
  730. case SPAWN_SET_LIP_TYPE:{
  731. if(target->IsEntity() && index < 3){
  732. sprintf(tmp, "%i", ((Entity*)target)->features.lip_type[index]);
  733. sint8 new_value = atoi(value);
  734. ((Entity*)target)->features.lip_type[index] = new_value;
  735. ((Entity*)target)->info_changed = true;
  736. }
  737. break;
  738. }
  739. case SPAWN_SET_NOSE_TYPE:{
  740. if(target->IsEntity() && index < 3){
  741. sprintf(tmp, "%i", ((Entity*)target)->features.nose_type[index]);
  742. sint8 new_value = atoi(value);
  743. ((Entity*)target)->features.nose_type[index] = new_value;
  744. ((Entity*)target)->info_changed = true;
  745. }
  746. break;
  747. }
  748. case SPAWN_SET_BODY_SIZE:{
  749. if(target->IsEntity()){
  750. sprintf(tmp, "%i", ((Entity*)target)->features.body_size);
  751. int8 new_value = atoul(value);
  752. ((Entity*)target)->features.body_size = new_value;
  753. ((Entity*)target)->info_changed = true;
  754. }
  755. break;
  756. }
  757. case SPAWN_SET_BODY_AGE:{
  758. if(target->IsEntity()){
  759. sprintf(tmp, "%i", ((Entity*)target)->features.body_age);
  760. int8 new_value = atoul(value);
  761. ((Entity*)target)->features.body_age = new_value;
  762. ((Entity*)target)->info_changed = true;
  763. }
  764. break;
  765. }
  766. case SPAWN_SET_SOGA_CHEEK_TYPE:{
  767. if(target->IsEntity() && index < 3){
  768. sprintf(tmp, "%i", ((Entity*)target)->features.soga_cheek_type[index]);
  769. sint8 new_value = atoi(value);
  770. ((Entity*)target)->features.soga_cheek_type[index] = new_value;
  771. ((Entity*)target)->info_changed = true;
  772. }
  773. break;
  774. }
  775. case SPAWN_SET_SOGA_CHIN_TYPE:{
  776. if(target->IsEntity() && index < 3){
  777. sprintf(tmp, "%i", ((Entity*)target)->features.soga_chin_type[index]);
  778. sint8 new_value = atoi(value);
  779. ((Entity*)target)->features.soga_chin_type[index] = new_value;
  780. ((Entity*)target)->info_changed = true;
  781. }
  782. break;
  783. }
  784. case SPAWN_SET_SOGA_EAR_TYPE:{
  785. if(target->IsEntity() && index < 3){
  786. sprintf(tmp, "%i", ((Entity*)target)->features.soga_ear_type[index]);
  787. sint8 new_value = atoi(value);
  788. ((Entity*)target)->features.soga_ear_type[index] = new_value;
  789. ((Entity*)target)->info_changed = true;
  790. }
  791. break;
  792. }
  793. case SPAWN_SET_SOGA_EYE_BROW_TYPE:{
  794. if(target->IsEntity() && index < 3){
  795. sprintf(tmp, "%i", ((Entity*)target)->features.soga_eye_brow_type[index]);
  796. sint8 new_value = atoi(value);
  797. ((Entity*)target)->features.soga_eye_brow_type[index] = new_value;
  798. ((Entity*)target)->info_changed = true;
  799. }
  800. break;
  801. }
  802. case SPAWN_SET_SOGA_EYE_TYPE:{
  803. if(target->IsEntity() && index < 3){
  804. sprintf(tmp, "%i", ((Entity*)target)->features.soga_eye_type[index]);
  805. sint8 new_value = atoi(value);
  806. ((Entity*)target)->features.soga_eye_type[index] = new_value;
  807. ((Entity*)target)->info_changed = true;
  808. }
  809. break;
  810. }
  811. case SPAWN_SET_SOGA_LIP_TYPE:{
  812. if(target->IsEntity() && index < 3){
  813. sprintf(tmp, "%i", ((Entity*)target)->features.soga_lip_type[index]);
  814. sint8 new_value = atoi(value);
  815. ((Entity*)target)->features.soga_lip_type[index] = new_value;
  816. ((Entity*)target)->info_changed = true;
  817. }
  818. break;
  819. }
  820. case SPAWN_SET_SOGA_BODY_SIZE:{
  821. if(target->IsEntity()){
  822. sprintf(tmp, "%i", ((Entity*)target)->features.soga_body_size);
  823. int8 new_value = atoul(value);
  824. ((Entity*)target)->features.soga_body_size = new_value;
  825. ((Entity*)target)->info_changed = true;
  826. }
  827. break;
  828. }
  829. case SPAWN_SET_SOGA_BODY_AGE:{
  830. if(target->IsEntity()){
  831. sprintf(tmp, "%i", ((Entity*)target)->features.soga_body_age);
  832. int8 new_value = atoul(value);
  833. ((Entity*)target)->features.soga_body_age = new_value;
  834. ((Entity*)target)->info_changed = true;
  835. }
  836. break;
  837. }
  838. case SPAWN_SET_ATTACK_TYPE:{
  839. if(target->IsEntity()){
  840. sprintf(tmp, "%u", ((Entity*)target)->GetInfoStruct()->get_attack_type());
  841. int8 new_value = atoul(value);
  842. ((Entity*)target)->GetInfoStruct()->set_attack_type(new_value);
  843. }
  844. break;
  845. }
  846. case SPAWN_SET_RACE_TYPE:{
  847. if(target->GetModelType() > 0){
  848. Seperator* tmpsep = new Seperator(value, ' ', 3, 500, true);
  849. if (tmpsep->IsNumber(0))
  850. {
  851. int16 race_type = atoul(value);
  852. const char* category = tmpsep->IsSet(1) ? tmpsep->arg[1] : "NULL";
  853. const char* subcategory = tmpsep->IsSet(2) ? tmpsep->arg[2] : "NULL";
  854. const char* model_name = tmpsep->IsSet(3) ? tmpsep->arg[3] : "NULL";
  855. if(race_types_list.AddRaceType(target->GetModelType(), race_type, category, subcategory, model_name)) {
  856. if(client) {
  857. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Race type added to memory, however not saved to database.");
  858. }
  859. }
  860. else if(client) {
  861. client->SimpleMessage(CHANNEL_COLOR_RED, "Model type already on the race_types_list, use spawn set database to override and update database.");
  862. }
  863. }
  864. safe_delete(tmpsep);
  865. }
  866. break;
  867. }
  868. case SPAWN_SET_LOOT_TIER:{
  869. if(target->IsEntity()){
  870. sprintf(tmp, "%u", target->GetLootTier());
  871. int32 new_value = atoul(value);
  872. target->SetLootTier(new_value);
  873. }
  874. break;
  875. }
  876. case SPAWN_SET_LOOT_DROP_TYPE:{
  877. if(target->IsEntity()){
  878. sprintf(tmp, "%u", target->GetLootDropType());
  879. int32 new_value = atoul(value);
  880. target->SetLootDropType(new_value);
  881. }
  882. break;
  883. }
  884. case SPAWN_SET_SCARED_STRONG_PLAYERS:{
  885. if(target->IsNPC()){
  886. sprintf(tmp, "%u", target->IsScaredByStrongPlayers());
  887. int32 new_value = atoul(value);
  888. target->SetScaredByStrongPlayers(new_value);
  889. }
  890. break;
  891. }
  892. if(temp_value)
  893. *temp_value = string(tmp);
  894. }
  895. }
  896. else{
  897. /**** NOT TEMPORARY ELSE STATEMENT ****/
  898. /**** MUST RE-DEFINE WHAT IS ALREADY IN THE IF TEMPORARY BLOCK HERE ****/
  899. switch(type){
  900. case SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL: {
  901. target->SetMerchantLevelRange(atoul(value), target->GetMerchantMaxLevel());
  902. break;
  903. }
  904. case SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL: {
  905. target->SetMerchantLevelRange(target->GetMerchantMinLevel(), atoul(value));
  906. break;
  907. }
  908. case SPAWN_SET_VALUE_EXPANSION_FLAG: {
  909. if (target->GetDatabaseID() > 0)
  910. {
  911. char query[256];
  912. snprintf(query, 256, "update spawn set expansion_flag=%u where id=%u", atoul(value), target->GetDatabaseID());
  913. if (database.RunQuery(query, strnlen(query, 256)))
  914. {
  915. if(client)
  916. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  917. }
  918. }
  919. break;
  920. }
  921. case SPAWN_SET_VALUE_HOLIDAY_FLAG: {
  922. if (target->GetDatabaseID() > 0)
  923. {
  924. char query[256];
  925. snprintf(query, 256, "update spawn set holiday_flag=%u where id=%u", atoul(value), target->GetDatabaseID());
  926. if (database.RunQuery(query, strnlen(query, 256)))
  927. {
  928. if(client)
  929. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  930. }
  931. }
  932. break;
  933. }
  934. case SPAWN_SET_AAXP_REWARDS: {
  935. if (target->GetDatabaseID() > 0)
  936. {
  937. char query[256];
  938. snprintf(query, 256, "update spawn set aaxp_rewards=%u where id=%u", atoul(value), target->GetDatabaseID());
  939. if (database.RunQuery(query, strnlen(query, 256)))
  940. {
  941. if(client)
  942. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  943. }
  944. }
  945. break;
  946. }
  947. case SPAWN_SET_VALUE_NAME:{
  948. target->SetName(value);
  949. if(target->GetZone())
  950. target->GetZone()->SendUpdateTitles(target);
  951. break;
  952. }
  953. case SPAWN_SET_VALUE_SUB_TITLE: {
  954. target->SetSubTitle(value);
  955. if(target->GetZone())
  956. target->GetZone()->SendUpdateTitles(target);
  957. break;
  958. }
  959. case SPAWN_SET_VALUE_X_OFFSET:
  960. {
  961. target->SetXOffset(atof(value));
  962. break;
  963. }
  964. case SPAWN_SET_VALUE_Y_OFFSET:
  965. {
  966. target->SetYOffset(atof(value));
  967. break;
  968. }
  969. case SPAWN_SET_VALUE_Z_OFFSET:
  970. {
  971. target->SetZOffset(atof(value));
  972. break;
  973. }
  974. case SPAWN_SET_VALUE_EXPIRE: {
  975. target->SetExpireTime(val);
  976. break;
  977. }
  978. case SPAWN_SET_VALUE_EXPIRE_OFFSET: {
  979. target->SetExpireOffsetTime(val);
  980. break;
  981. }
  982. case SPAWN_SET_VALUE_LEVEL:{
  983. target->SetLevel(val, send_update);
  984. break;
  985. }
  986. case SPAWN_SET_VALUE_DIFFICULTY:{
  987. target->SetDifficulty(val, send_update);
  988. break;
  989. }
  990. case SPAWN_SET_VALUE_MODEL_TYPE:{
  991. target->SetModelType(val, send_update);
  992. break;
  993. }
  994. case SPAWN_SET_VALUE_CLASS:{
  995. target->SetAdventureClass(val, send_update);
  996. break;
  997. }
  998. case SPAWN_SET_VALUE_GENDER:{
  999. target->SetGender(val, send_update);
  1000. break;
  1001. }
  1002. case SPAWN_SET_VALUE_SHOW_NAME:{
  1003. target->SetShowName(val, send_update);
  1004. break;
  1005. }
  1006. case SPAWN_SET_VALUE_ATTACKABLE:{
  1007. target->SetAttackable(val, send_update);
  1008. break;
  1009. }
  1010. case SPAWN_SET_VALUE_SHOW_LEVEL:{
  1011. target->SetShowLevel(val, send_update);
  1012. break;
  1013. }
  1014. case SPAWN_SET_VALUE_TARGETABLE:{
  1015. target->SetTargetable(val, send_update);
  1016. break;
  1017. }
  1018. case SPAWN_SET_VALUE_SHOW_COMMAND_ICON:{
  1019. target->SetShowCommandIcon(val, send_update);
  1020. break;
  1021. }
  1022. case SPAWN_SET_VALUE_HAND_ICON:{
  1023. target->SetShowHandIcon(val, send_update);
  1024. break;
  1025. }
  1026. case SPAWN_SET_VALUE_HAIR_TYPE:{
  1027. if(target->IsEntity())
  1028. ((Entity*)target)->SetHairType(val, send_update);
  1029. break;
  1030. }
  1031. case SPAWN_SET_VALUE_FACIAL_HAIR_TYPE:{
  1032. if(target->IsEntity())
  1033. ((Entity*)target)->SetFacialHairType(val, send_update);
  1034. break;
  1035. }
  1036. case SPAWN_SET_VALUE_WING_TYPE:{
  1037. if(target->IsEntity())
  1038. ((Entity*)target)->SetWingType(val, send_update);
  1039. break;
  1040. }
  1041. case SPAWN_SET_VALUE_CHEST_TYPE:{
  1042. if(target->IsEntity())
  1043. ((Entity*)target)->SetChestType(val, send_update);
  1044. break;
  1045. }
  1046. case SPAWN_SET_VALUE_LEGS_TYPE:{
  1047. if(target->IsEntity())
  1048. ((Entity*)target)->SetLegsType(val, send_update);
  1049. break;
  1050. }
  1051. case SPAWN_SET_VALUE_SOGA_HAIR_TYPE:{
  1052. if(target->IsEntity())
  1053. ((Entity*)target)->SetSogaHairType(val, send_update);
  1054. break;
  1055. }
  1056. case SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE:{
  1057. if(target->IsEntity())
  1058. ((Entity*)target)->SetSogaFacialHairType(val, send_update);
  1059. break;
  1060. }
  1061. case SPAWN_SET_VALUE_SOGA_MODEL_TYPE:{
  1062. target->SetSogaModelType(val, send_update);
  1063. break;
  1064. }
  1065. case SPAWN_SET_VALUE_SIZE:{
  1066. target->SetSize(val, send_update);
  1067. break;
  1068. }
  1069. case SPAWN_SET_VALUE_HP:{
  1070. target->SetTotalHPBase(val);
  1071. target->SetHP(val, send_update);
  1072. break;
  1073. }
  1074. case SPAWN_SET_VALUE_POWER:{
  1075. target->SetTotalPowerBase(val);
  1076. target->SetPower(val, send_update);
  1077. break;
  1078. }
  1079. case SPAWN_SET_VALUE_HEROIC:{
  1080. target->SetHeroic(val, send_update);
  1081. break;
  1082. }
  1083. case SPAWN_SET_VALUE_RESPAWN:{
  1084. target->SetRespawnTime(val);
  1085. break;
  1086. }
  1087. case SPAWN_SET_VALUE_X:{
  1088. target->SetX(atof(value), send_update);
  1089. target->SetSpawnOrigX(target->GetX());
  1090. break;
  1091. }
  1092. case SPAWN_SET_VALUE_Y:{
  1093. target->SetY(atof(value), send_update);
  1094. target->SetSpawnOrigY(target->GetY());
  1095. break;
  1096. }
  1097. case SPAWN_SET_VALUE_Z:{
  1098. target->SetZ(atof(value), send_update);
  1099. target->SetSpawnOrigZ(target->GetZ());
  1100. break;
  1101. }
  1102. case SPAWN_SET_VALUE_HEADING:{
  1103. target->SetHeading(atof(value), send_update);
  1104. target->SetSpawnOrigHeading(target->GetHeading());
  1105. break;
  1106. }
  1107. case SPAWN_SET_VALUE_COMMAND_PRIMARY:{
  1108. ZoneServer* zone = target->GetZone();
  1109. if (!zone && client)
  1110. zone = client->GetCurrentZone();
  1111. if(zone && zone->GetEntityCommandList(val))
  1112. target->SetPrimaryCommands(zone->GetEntityCommandList(val));
  1113. target->primary_command_list_id = val;
  1114. break;
  1115. }
  1116. case SPAWN_SET_VALUE_COMMAND_SECONDARY:{
  1117. ZoneServer* zone = target->GetZone();
  1118. if (!zone && client)
  1119. zone = client->GetCurrentZone();
  1120. if (zone && zone->GetEntityCommandList(val))
  1121. target->SetSecondaryCommands(zone->GetEntityCommandList(val));
  1122. target->secondary_command_list_id = val;
  1123. break;
  1124. }
  1125. case SPAWN_SET_VALUE_VISUAL_STATE:{
  1126. target->SetVisualState(val, send_update);
  1127. break;
  1128. }
  1129. case SPAWN_SET_VALUE_ACTION_STATE:{
  1130. target->SetActionState(val, send_update);
  1131. break;
  1132. }
  1133. case SPAWN_SET_VALUE_MOOD_STATE:{
  1134. target->SetMoodState(val, send_update);
  1135. break;
  1136. }
  1137. case SPAWN_SET_VALUE_INITIAL_STATE:{
  1138. target->SetInitialState(val, send_update);
  1139. break;
  1140. }
  1141. case SPAWN_SET_VALUE_ACTIVITY_STATE:{
  1142. target->SetActivityStatus(val, send_update);
  1143. break;
  1144. }
  1145. case SPAWN_SET_VALUE_COLLISION_RADIUS:{
  1146. target->SetCollisionRadius(val, send_update);
  1147. break;
  1148. }
  1149. case SPAWN_SET_VALUE_FACTION:{
  1150. ZoneServer* zone = target->GetZone();
  1151. if (!zone && client)
  1152. zone = client->GetCurrentZone();
  1153. target->faction_id = val;
  1154. if(zone)
  1155. {
  1156. zone->RemoveDeadEnemyList(target);
  1157. if(target->IsNPC())
  1158. zone->AddEnemyList((NPC*)target);
  1159. }
  1160. break;
  1161. }
  1162. case SPAWN_SET_VALUE_DEVICE_ID:{
  1163. if (target->IsObject())
  1164. ((Object*)target)->SetDeviceID(val);
  1165. break;
  1166. }
  1167. case SPAWN_SET_VALUE_PITCH: {
  1168. target->SetPitch(atof(value), send_update);
  1169. target->SetSpawnOrigPitch(atof(value));
  1170. break;
  1171. }
  1172. case SPAWN_SET_VALUE_ROLL: {
  1173. target->SetRoll(atof(value), send_update);
  1174. target->SetSpawnOrigRoll(atof(value));
  1175. break;
  1176. }
  1177. case SPAWN_SET_VALUE_HIDE_HOOD: {
  1178. target->SetHideHood(val);
  1179. break;
  1180. }
  1181. case SPAWN_SET_VALUE_EMOTE_STATE: {
  1182. target->SetEmoteState(val);
  1183. break;
  1184. }
  1185. case SPAWN_SET_VALUE_ICON: {
  1186. target->SetIcon(val);
  1187. break;
  1188. }
  1189. case SPAWN_SET_VALUE_PREFIX: {
  1190. target->SetPrefixTitle(value);
  1191. if(target->GetZone())
  1192. target->GetZone()->SendUpdateTitles(target);
  1193. break;
  1194. }
  1195. case SPAWN_SET_VALUE_SUFFIX: {
  1196. target->SetSuffixTitle(value);
  1197. if(target->GetZone())
  1198. target->GetZone()->SendUpdateTitles(target);
  1199. break;
  1200. }
  1201. case SPAWN_SET_VALUE_LASTNAME: {
  1202. target->SetLastName(value);
  1203. if(target->GetZone())
  1204. target->GetZone()->SendUpdateTitles(target);
  1205. break;
  1206. }
  1207. case SPAWN_SET_VALUE_SPAWN_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 spawn_script 'SpawnScripts/example.lua'");
  1212. }
  1213. return false;
  1214. }
  1215. else if(!database.UpdateSpawnScriptData(target->GetDatabaseID(), 0, 0, value))
  1216. return false;
  1217. else{
  1218. if(!world.GetSpawnLocationScript(target->GetSpawnLocationID()))
  1219. target->SetSpawnScript(value);
  1220. }
  1221. break;
  1222. }
  1223. case SPAWN_SET_VALUE_SPAWNLOCATION_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 spawnlocation_script 'SpawnScripts/example.lua'");
  1228. }
  1229. return false;
  1230. }
  1231. else if(!database.UpdateSpawnScriptData(0, target->GetSpawnLocationID(), 0, value))
  1232. return false;
  1233. else{
  1234. if(!world.GetSpawnEntryScript(target->GetSpawnEntryID()))
  1235. target->SetSpawnScript(value);
  1236. }
  1237. break;
  1238. }
  1239. case SPAWN_SET_VALUE_SPAWNENTRY_SCRIPT:{
  1240. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  1241. if(client){
  1242. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  1243. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawnentry_script 'SpawnScripts/example.lua'");
  1244. }
  1245. return false;
  1246. }
  1247. else if(!database.UpdateSpawnScriptData(0, 0, target->GetSpawnEntryID(), value))
  1248. return false;
  1249. else
  1250. target->SetSpawnScript(value);
  1251. break;
  1252. }
  1253. case SPAWN_SET_SKIN_COLOR:
  1254. case SPAWN_SET_HAIR_COLOR1:
  1255. case SPAWN_SET_HAIR_COLOR2:
  1256. case SPAWN_SET_HAIR_TYPE_COLOR:
  1257. case SPAWN_SET_HAIR_FACE_COLOR:
  1258. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  1259. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  1260. case SPAWN_SET_HAIR_HIGHLIGHT:
  1261. case SPAWN_SET_MODEL_COLOR:
  1262. case SPAWN_SET_EYE_COLOR:
  1263. case SPAWN_SET_SOGA_SKIN_COLOR:
  1264. case SPAWN_SET_SOGA_HAIR_COLOR1:
  1265. case SPAWN_SET_SOGA_HAIR_COLOR2:
  1266. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  1267. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  1268. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  1269. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  1270. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  1271. case SPAWN_SET_SOGA_MODEL_COLOR:
  1272. case SPAWN_SET_SOGA_EYE_COLOR: {
  1273. if (target->IsNPC())
  1274. {
  1275. Seperator* skinsep = new Seperator(value, ' ', 3, 500, true);
  1276. if (skinsep->IsNumber(0) && skinsep->IsNumber(1) && skinsep->IsNumber(2))
  1277. {
  1278. EQ2_Color clr;
  1279. clr.red = atoul(skinsep->arg[0]);
  1280. clr.green = atoul(skinsep->arg[1]);
  1281. clr.blue = atoul(skinsep->arg[2]);
  1282. Query replaceSkinQuery;
  1283. string fieldName("");
  1284. switch(type)
  1285. {
  1286. case SPAWN_SET_SKIN_COLOR:
  1287. ((Entity*)target)->SetSkinColor(clr);
  1288. fieldName.append("skin_color");
  1289. break;
  1290. case SPAWN_SET_HAIR_COLOR1:
  1291. ((Entity*)target)->SetHairColor1(clr);
  1292. fieldName.append("hair_color1");
  1293. break;
  1294. case SPAWN_SET_HAIR_COLOR2:
  1295. ((Entity*)target)->SetHairColor2(clr);
  1296. fieldName.append("hair_color2");
  1297. break;
  1298. case SPAWN_SET_HAIR_TYPE_COLOR:
  1299. ((Entity*)target)->SetHairColor(clr);
  1300. fieldName.append("hair_type_color");
  1301. break;
  1302. case SPAWN_SET_HAIR_FACE_COLOR:
  1303. ((Entity*)target)->SetFacialHairColor(clr);
  1304. fieldName.append("hair_face_color");
  1305. break;
  1306. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  1307. ((Entity*)target)->SetHairTypeHighlightColor(clr);
  1308. fieldName.append("hair_type_highlight_color");
  1309. break;
  1310. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  1311. ((Entity*)target)->SetFacialHairHighlightColor(clr);
  1312. fieldName.append("hair_face_highlight_color");
  1313. break;
  1314. case SPAWN_SET_HAIR_HIGHLIGHT:
  1315. ((Entity*)target)->SetHairHighlightColor(clr);
  1316. fieldName.append("hair_highlight");
  1317. break;
  1318. case SPAWN_SET_MODEL_COLOR:
  1319. ((Entity*)target)->SetModelColor(clr);
  1320. fieldName.append("model_color");
  1321. break;
  1322. case SPAWN_SET_EYE_COLOR:
  1323. ((Entity*)target)->SetEyeColor(clr);
  1324. fieldName.append("eye_color");
  1325. break;
  1326. case SPAWN_SET_SOGA_SKIN_COLOR:
  1327. ((Entity*)target)->SetSogaSkinColor(clr);
  1328. fieldName.append("soga_skin_color");
  1329. break;
  1330. case SPAWN_SET_SOGA_HAIR_COLOR1:
  1331. ((Entity*)target)->SetSogaHairColor1(clr);
  1332. fieldName.append("soga_hair_color1");
  1333. break;
  1334. case SPAWN_SET_SOGA_HAIR_COLOR2:
  1335. ((Entity*)target)->SetSogaHairColor2(clr);
  1336. fieldName.append("soga_hair_color2");
  1337. break;
  1338. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  1339. ((Entity*)target)->SetSogaHairColor(clr);
  1340. fieldName.append("soga_hair_type_color");
  1341. break;
  1342. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  1343. ((Entity*)target)->SetSogaFacialHairColor(clr);
  1344. fieldName.append("soga_hair_face_color");
  1345. break;
  1346. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  1347. ((Entity*)target)->SetSogaHairTypeHighlightColor(clr);
  1348. fieldName.append("soga_hair_type_highlight_color");
  1349. break;
  1350. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  1351. ((Entity*)target)->SetSogaFacialHairHighlightColor(clr);
  1352. fieldName.append("soga_hair_face_highlight_color");
  1353. break;
  1354. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  1355. ((Entity*)target)->SetSogaHairHighlightColor(clr);
  1356. fieldName.append("soga_hair_highlight");
  1357. break;
  1358. case SPAWN_SET_SOGA_MODEL_COLOR:
  1359. ((Entity*)target)->SetSogaModelColor(clr);
  1360. fieldName.append("soga_model_color");
  1361. break;
  1362. case SPAWN_SET_SOGA_EYE_COLOR:
  1363. ((Entity*)target)->SetSogaEyeColor(clr);
  1364. fieldName.append("soga_eye_color");
  1365. break;
  1366. }
  1367. replaceSkinQuery.AddQueryAsync(0, &database, Q_DELETE, "delete from npc_appearance where spawn_id=%u and type='%s'", target->GetDatabaseID(), fieldName.c_str());
  1368. 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);
  1369. }
  1370. safe_delete(skinsep);
  1371. }
  1372. break;
  1373. }
  1374. case SPAWN_SET_CHEEK_TYPE:{
  1375. if(target->IsEntity() && index < 3){
  1376. sint8 new_value = atoi(value);
  1377. ((Entity*)target)->features.cheek_type[index] = new_value;
  1378. UpdateDatabaseAppearance(client, target, "cheek_type", ((Entity*)target)->features.cheek_type[0], ((Entity*)target)->features.cheek_type[1], ((Entity*)target)->features.cheek_type[2]);
  1379. }
  1380. break;
  1381. }
  1382. case SPAWN_SET_CHIN_TYPE:{
  1383. if(target->IsEntity() && index < 3){
  1384. sint8 new_value = atoi(value);
  1385. ((Entity*)target)->features.chin_type[index] = new_value;
  1386. UpdateDatabaseAppearance(client, target, "chin_type", ((Entity*)target)->features.chin_type[0], ((Entity*)target)->features.chin_type[1], ((Entity*)target)->features.chin_type[2]);
  1387. }
  1388. break;
  1389. }
  1390. case SPAWN_SET_EAR_TYPE:{
  1391. if(target->IsEntity() && index < 3){
  1392. sint8 new_value = atoi(value);
  1393. ((Entity*)target)->features.ear_type[index] = new_value;
  1394. UpdateDatabaseAppearance(client, target, "ear_type", ((Entity*)target)->features.ear_type[0], ((Entity*)target)->features.ear_type[1], ((Entity*)target)->features.ear_type[2]);
  1395. }
  1396. break;
  1397. }
  1398. case SPAWN_SET_EYE_BROW_TYPE:{
  1399. if(target->IsEntity() && index < 3){
  1400. sint8 new_value = atoi(value);
  1401. ((Entity*)target)->features.eye_brow_type[index] = new_value;
  1402. 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]);
  1403. }
  1404. break;
  1405. }
  1406. case SPAWN_SET_EYE_TYPE:{
  1407. if(target->IsEntity() && index < 3){
  1408. sint8 new_value = atoi(value);
  1409. ((Entity*)target)->features.eye_type[index] = new_value;
  1410. UpdateDatabaseAppearance(client, target, "eye_type", ((Entity*)target)->features.eye_type[0], ((Entity*)target)->features.eye_type[1], ((Entity*)target)->features.eye_type[2]);
  1411. }
  1412. break;
  1413. }
  1414. case SPAWN_SET_LIP_TYPE:{
  1415. if(target->IsEntity() && index < 3){
  1416. sint8 new_value = atoi(value);
  1417. ((Entity*)target)->features.lip_type[index] = new_value;
  1418. UpdateDatabaseAppearance(client, target, "lip_type", ((Entity*)target)->features.lip_type[0], ((Entity*)target)->features.lip_type[1], ((Entity*)target)->features.lip_type[2]);
  1419. }
  1420. break;
  1421. }
  1422. case SPAWN_SET_NOSE_TYPE:{
  1423. if(target->IsEntity() && index < 3){
  1424. sint8 new_value = atoi(value);
  1425. ((Entity*)target)->features.nose_type[index] = new_value;
  1426. UpdateDatabaseAppearance(client, target, "nose_type", ((Entity*)target)->features.nose_type[0], ((Entity*)target)->features.nose_type[1], ((Entity*)target)->features.nose_type[2]);
  1427. }
  1428. break;
  1429. }
  1430. case SPAWN_SET_BODY_SIZE:{
  1431. if(target->IsEntity()){
  1432. int8 new_value = atoul(value);
  1433. ((Entity*)target)->features.body_size = new_value;
  1434. UpdateDatabaseAppearance(client, target, "body_size", ((Entity*)target)->features.body_size, 0, 0);
  1435. }
  1436. break;
  1437. }
  1438. case SPAWN_SET_BODY_AGE:{
  1439. if(target->IsEntity()){
  1440. int8 new_value = atoul(value);
  1441. ((Entity*)target)->features.body_age = new_value;
  1442. UpdateDatabaseAppearance(client, target, "body_age", ((Entity*)target)->features.body_age, 0, 0);
  1443. }
  1444. break;
  1445. }
  1446. case SPAWN_SET_SOGA_CHEEK_TYPE:{
  1447. if(target->IsEntity() && index < 3){
  1448. sint8 new_value = atoi(value);
  1449. ((Entity*)target)->features.soga_cheek_type[index] = new_value;
  1450. 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]);
  1451. }
  1452. break;
  1453. }
  1454. case SPAWN_SET_SOGA_CHIN_TYPE:{
  1455. if(target->IsEntity() && index < 3){
  1456. sint8 new_value = atoi(value);
  1457. ((Entity*)target)->features.soga_chin_type[index] = new_value;
  1458. 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]);
  1459. }
  1460. break;
  1461. }
  1462. case SPAWN_SET_SOGA_EAR_TYPE:{
  1463. if(target->IsEntity() && index < 3){
  1464. sint8 new_value = atoi(value);
  1465. ((Entity*)target)->features.soga_ear_type[index] = new_value;
  1466. 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]);
  1467. }
  1468. break;
  1469. }
  1470. case SPAWN_SET_SOGA_EYE_BROW_TYPE:{
  1471. if(target->IsEntity() && index < 3){
  1472. sint8 new_value = atoi(value);
  1473. ((Entity*)target)->features.soga_eye_brow_type[index] = new_value;
  1474. 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]);
  1475. }
  1476. break;
  1477. }
  1478. case SPAWN_SET_SOGA_EYE_TYPE:{
  1479. if(target->IsEntity() && index < 3){
  1480. sint8 new_value = atoi(value);
  1481. ((Entity*)target)->features.soga_eye_type[index] = new_value;
  1482. 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]);
  1483. }
  1484. break;
  1485. }
  1486. case SPAWN_SET_SOGA_LIP_TYPE:{
  1487. if(target->IsEntity() && index < 3){
  1488. sint8 new_value = atoi(value);
  1489. ((Entity*)target)->features.soga_lip_type[index] = new_value;
  1490. 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]);
  1491. }
  1492. break;
  1493. }
  1494. case SPAWN_SET_SOGA_NOSE_TYPE:{
  1495. if(target->IsEntity() && index < 3){
  1496. sint8 new_value = atoi(value);
  1497. ((Entity*)target)->features.soga_nose_type[index] = new_value;
  1498. 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]);
  1499. }
  1500. break;
  1501. }
  1502. case SPAWN_SET_SOGA_BODY_SIZE:{
  1503. if(target->IsEntity()){
  1504. int8 new_value = atoul(value);
  1505. ((Entity*)target)->features.body_size = new_value;
  1506. UpdateDatabaseAppearance(client, target, "body_size", ((Entity*)target)->features.body_size, 0, 0);
  1507. }
  1508. break;
  1509. }
  1510. case SPAWN_SET_SOGA_BODY_AGE:{
  1511. if(target->IsEntity()){
  1512. int8 new_value = atoul(value);
  1513. ((Entity*)target)->features.body_age = new_value;
  1514. UpdateDatabaseAppearance(client, target, "body_age", ((Entity*)target)->features.body_age, 0, 0);
  1515. }
  1516. break;
  1517. }
  1518. case SPAWN_SET_ATTACK_TYPE:{
  1519. if(target->IsEntity()){
  1520. int8 new_value = atoul(value);
  1521. ((Entity*)target)->GetInfoStruct()->set_attack_type(new_value);
  1522. if(target->IsNPC()) {
  1523. if(target->GetDatabaseID()) {
  1524. Query spawnNPCQuery;
  1525. spawnNPCQuery.AddQueryAsync(0, &database, Q_INSERT, "update spawn_npcs set attack_type=%u where id=%u", new_value, target->GetDatabaseID());
  1526. } else if(client) {
  1527. client->Message(CHANNEL_COLOR_RED, "Invalid spawn to update the database (NPC only) or no database id for the NPC present.");
  1528. }
  1529. }
  1530. }
  1531. break;
  1532. }
  1533. case SPAWN_SET_RACE_TYPE:{
  1534. if(target->GetModelType() > 0){
  1535. Seperator* tmpsep = new Seperator(value, ' ', 3, 500, true);
  1536. if (tmpsep->IsNumber(0))
  1537. {
  1538. Query typequery;
  1539. int16 race_type = atoul(value);
  1540. const char* category = tmpsep->IsSet(1) ? tmpsep->arg[1] : "NULL";
  1541. const char* subcategory = tmpsep->IsSet(2) ? tmpsep->arg[2] : "NULL";
  1542. const char* model_name = tmpsep->IsSet(3) ? tmpsep->arg[3] : "NULL";
  1543. if(race_types_list.AddRaceType(target->GetModelType(), race_type, category, subcategory, model_name)) {
  1544. if(client)
  1545. 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);
  1546. 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);
  1547. }
  1548. else {
  1549. if(client)
  1550. 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);
  1551. race_types_list.AddRaceType(target->GetModelType(), race_type, category, subcategory, model_name, true);
  1552. 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());
  1553. }
  1554. }
  1555. safe_delete(tmpsep);
  1556. }
  1557. break;
  1558. }
  1559. case SPAWN_SET_LOOT_TIER:{
  1560. int32 new_value = atoul(value);
  1561. target->SetLootTier(new_value);
  1562. if (target->GetDatabaseID() > 0)
  1563. {
  1564. char query[256];
  1565. snprintf(query, 256, "update spawn set loot_tier=%u where id=%u", atoul(value), target->GetDatabaseID());
  1566. if (database.RunQuery(query, strnlen(query, 256)))
  1567. {
  1568. if(client)
  1569. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  1570. }
  1571. }
  1572. break;
  1573. }
  1574. case SPAWN_SET_LOOT_DROP_TYPE:{
  1575. int32 new_value = atoul(value);
  1576. target->SetLootDropType(new_value);
  1577. if (target->GetDatabaseID() > 0)
  1578. {
  1579. char query[256];
  1580. snprintf(query, 256, "update spawn set loot_drop_type=%u where id=%u", atoul(value), target->GetDatabaseID());
  1581. if (database.RunQuery(query, strnlen(query, 256)))
  1582. {
  1583. if(client)
  1584. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  1585. }
  1586. }
  1587. break;
  1588. }
  1589. case SPAWN_SET_SCARED_STRONG_PLAYERS:{
  1590. int32 new_value = atoul(value);
  1591. target->SetScaredByStrongPlayers(new_value);
  1592. if (target->GetDatabaseID() > 0)
  1593. {
  1594. char query[256];
  1595. snprintf(query, 256, "update spawn_npcs set scared_by_strong_players=%u where id=%u", atoul(value), target->GetDatabaseID());
  1596. if (database.RunQuery(query, strnlen(query, 256)))
  1597. {
  1598. if(client)
  1599. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  1600. }
  1601. }
  1602. break;
  1603. }
  1604. }
  1605. }
  1606. return true;
  1607. }
  1608. void Commands::UpdateDatabaseAppearance(Client* client, Spawn* target, string fieldName, sint8 r, sint8 g, sint8 b)
  1609. {
  1610. Query replaceQuery;
  1611. if(target->IsBot())
  1612. {
  1613. Bot* bot = (Bot*)target;
  1614. if(bot->BotID)
  1615. database.SaveBotFloats(bot->BotID, fieldName.c_str(), r, g, b);
  1616. }
  1617. else if(target->IsPlayer())
  1618. {
  1619. replaceQuery.AddQueryAsync(0, &database, Q_DELETE, "delete from char_colors where char_id=%u and type='%s'", ((Player*)target)->GetCharacterID(), fieldName.c_str());
  1620. 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);
  1621. }
  1622. else
  1623. {
  1624. replaceQuery.AddQueryAsync(0, &database, Q_DELETE, "delete from npc_appearance where spawn_id=%u and type='%s'", target->GetDatabaseID(), fieldName.c_str());
  1625. 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);
  1626. }
  1627. ((Entity*)target)->changed = true;
  1628. ((Entity*)target)->info_changed = true;
  1629. if(target->GetZone())
  1630. target->GetZone()->AddChangedSpawn(target);
  1631. }
  1632. /* The zone object will be NULL if the zone is not currently running. We pass both of these in so we can update
  1633. the database fields always and also update the zone in memory if it's running. */
  1634. bool Commands::SetZoneCommand(Client* client, int32 zone_id, ZoneServer* zone, int8 type, const char* value) {
  1635. if (client && zone_id > 0 && type > 0 && value) {
  1636. sint32 int_value = 0;
  1637. float float_value = 0;
  1638. if (type == ZONE_SET_VALUE_SAFE_X || type == ZONE_SET_VALUE_SAFE_Y || type == ZONE_SET_VALUE_SAFE_Z || type == ZONE_SET_VALUE_UNDERWORLD) {
  1639. try {
  1640. float_value = atof(value);
  1641. }
  1642. catch (...) {
  1643. client->Message(CHANNEL_COLOR_RED, "Error converting '%s' to a float value", value);
  1644. return false;
  1645. }
  1646. }
  1647. 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) {
  1648. try {
  1649. int_value = atoi(value);
  1650. }
  1651. catch (...) {
  1652. client->Message(CHANNEL_COLOR_RED, "Error converting '%s' to an integer value", value);
  1653. return false;
  1654. }
  1655. }
  1656. switch (type) {
  1657. case ZONE_SET_VALUE_EXPANSION_ID: {
  1658. break;
  1659. }
  1660. case ZONE_SET_VALUE_NAME: {
  1661. if (zone)
  1662. zone->SetZoneName(const_cast<char*>(value));
  1663. database.SaveZoneInfo(zone_id, "name", value);
  1664. break;
  1665. }
  1666. case ZONE_SET_VALUE_FILE: {
  1667. if (zone)
  1668. zone->SetZoneFile(const_cast<char*>(value));
  1669. database.SaveZoneInfo(zone_id, "file", value);
  1670. break;
  1671. }
  1672. case ZONE_SET_VALUE_DESCRIPTION: {
  1673. if (zone)
  1674. zone->SetZoneDescription(const_cast<char*>(value));
  1675. database.SaveZoneInfo(zone_id, "description", value);
  1676. break;
  1677. }
  1678. case ZONE_SET_VALUE_SAFE_X: {
  1679. if (zone)
  1680. zone->SetSafeX(float_value);
  1681. database.SaveZoneInfo(zone_id, "safe_x", float_value);
  1682. break;
  1683. }
  1684. case ZONE_SET_VALUE_SAFE_Y: {
  1685. if (zone)
  1686. zone->SetSafeY(float_value);
  1687. database.SaveZoneInfo(zone_id, "safe_y", float_value);
  1688. break;
  1689. }
  1690. case ZONE_SET_VALUE_SAFE_Z: {
  1691. if (zone)
  1692. zone->SetSafeZ(float_value);
  1693. database.SaveZoneInfo(zone_id, "safe_z", float_value);
  1694. break;
  1695. }
  1696. case ZONE_SET_VALUE_UNDERWORLD: {
  1697. if (zone)
  1698. zone->SetUnderWorld(float_value);
  1699. database.SaveZoneInfo(zone_id, "underworld", float_value);
  1700. break;
  1701. }
  1702. case ZONE_SET_VALUE_MIN_RECOMMENDED: {
  1703. break;
  1704. }
  1705. case ZONE_SET_VALUE_MAX_RECOMMENDED: {
  1706. break;
  1707. }
  1708. case ZONE_SET_VALUE_ZONE_TYPE: {
  1709. break;
  1710. }
  1711. case ZONE_SET_VALUE_ALWAYS_LOADED: {
  1712. if (zone)
  1713. zone->SetAlwaysLoaded(int_value == 1);
  1714. database.SaveZoneInfo(zone_id, "always_loaded", int_value);
  1715. break;
  1716. }
  1717. case ZONE_SET_VALUE_CITY_ZONE: {
  1718. if (zone)
  1719. zone->SetCityZone(int_value == 1);
  1720. database.SaveZoneInfo(zone_id, "city_zone", int_value);
  1721. break;
  1722. }
  1723. case ZONE_SET_VALUE_WEATHER_ALLOWED: {
  1724. if (zone)
  1725. zone->SetWeatherAllowed(int_value == 1);
  1726. database.SaveZoneInfo(zone_id, "weather_allowed", int_value);
  1727. break;
  1728. }
  1729. case ZONE_SET_VALUE_MIN_STATUS: {
  1730. if (zone)
  1731. zone->SetMinimumStatus(int_value);
  1732. database.SaveZoneInfo(zone_id, "min_status", int_value);
  1733. break;
  1734. }
  1735. case ZONE_SET_VALUE_MIN_LEVEL: {
  1736. if (zone)
  1737. zone->SetMinimumLevel(int_value);
  1738. database.SaveZoneInfo(zone_id, "min_level", int_value);
  1739. break;
  1740. }
  1741. case ZONE_SET_VALUE_MAX_LEVEL: {
  1742. if (zone)
  1743. zone->SetMaximumLevel(int_value);
  1744. database.SaveZoneInfo(zone_id, "max_level", int_value);
  1745. break;
  1746. }
  1747. case ZONE_SET_VALUE_START_ZONE: {
  1748. database.SaveZoneInfo(zone_id, "start_zone", int_value);
  1749. break;
  1750. }
  1751. case ZONE_SET_VALUE_INSTANCE_TYPE: {
  1752. if (zone)
  1753. zone->SetInstanceType(int_value);
  1754. database.SaveZoneInfo(zone_id, "instance_type", int_value);
  1755. break;
  1756. }
  1757. case ZONE_SET_VALUE_DEFAULT_REENTER_TIME: {
  1758. if (zone)
  1759. zone->SetDefaultReenterTime(int_value);
  1760. database.SaveZoneInfo(zone_id, "default_reenter_time", int_value);
  1761. break;
  1762. }
  1763. case ZONE_SET_VALUE_DEFAULT_RESET_TIME: {
  1764. if (zone)
  1765. zone->SetDefaultResetTime(int_value);
  1766. database.SaveZoneInfo(zone_id, "default_reset_time", int_value);
  1767. break;
  1768. }
  1769. case ZONE_SET_VALUE_DEFAULT_LOCKOUT_TIME: {
  1770. if (zone)
  1771. zone->SetDefaultLockoutTime(int_value);
  1772. database.SaveZoneInfo(zone_id, "default_lockout_time", int_value);
  1773. break;
  1774. }
  1775. case ZONE_SET_VALUE_FORCE_GROUP_TO_ZONE: {
  1776. if (zone)
  1777. zone->SetForceGroupZoneOption(int_value);
  1778. database.SaveZoneInfo(zone_id, "force_group_to_zone", int_value);
  1779. break;
  1780. }
  1781. case ZONE_SET_VALUE_LUA_SCRIPT: {
  1782. if (lua_interface && lua_interface->GetZoneScript(value) == 0) {
  1783. client->Message(CHANNEL_COLOR_RED, "Invalid Zone Script file. Be sure you give the absolute path.");
  1784. client->Message(CHANNEL_COLOR_RED, "Example: /zone set lua_script 'ZoneScripts/QueensColony.lua'");
  1785. return false;
  1786. }
  1787. else {
  1788. world.AddZoneScript(zone_id, const_cast<char*>(value));
  1789. database.SaveZoneInfo(zone_id, "lua_script", value);
  1790. }
  1791. break;
  1792. }
  1793. case ZONE_SET_VALUE_SHUTDOWN_TIMER: {
  1794. if (zone)
  1795. zone->SetShutdownTimer(int_value);
  1796. database.SaveZoneInfo(zone_id, "shutdown_timer", int_value);
  1797. break;
  1798. }
  1799. case ZONE_SET_VALUE_ZONE_MOTD: {
  1800. if (zone)
  1801. zone->SetZoneMOTD(string(value));
  1802. database.SaveZoneInfo(zone_id, "zone_motd", value);
  1803. break;
  1804. }
  1805. default: {
  1806. client->Message(CHANNEL_COLOR_RED, "Invalid zone attribute %i", type);
  1807. return false;
  1808. }
  1809. }
  1810. }
  1811. else {
  1812. if (client)
  1813. client->SimpleMessage(CHANNEL_COLOR_RED, "An error occured saving new zone data.");
  1814. return false;
  1815. }
  1816. return true;
  1817. }
  1818. void Commands::Process(int32 index, EQ2_16BitString* command_parms, Client* client, Spawn* targetOverride) {
  1819. if (index >= remote_commands->commands.size()) {
  1820. LogWrite(COMMAND__ERROR, 0, "Command", "Error, command handler of %u was requested, but max handler is %u", index, remote_commands->commands.size());
  1821. return;
  1822. }
  1823. Spawn* cmdTarget = targetOverride ? targetOverride : client->GetPlayer()->GetTarget();
  1824. EQ2_RemoteCommandString* parent_command = 0;
  1825. EQ2_RemoteCommandString* command = &remote_commands->commands[index];
  1826. Seperator* sep = 0;
  1827. if (command_parms->size > 0) {
  1828. sep = new Seperator(command_parms->data.c_str(), ' ', 10, 500, true);
  1829. if (sep && sep->arg[0] && remote_commands->validSubCommand(command->command.data, string(sep->arg[0]))) {
  1830. parent_command = command;
  1831. command = &(remote_commands->subcommands[command->command.data][string(sep->arg[0])]);
  1832. safe_delete(sep);
  1833. if (command_parms->data.length() > (command->command.data.length() + 1))
  1834. sep = new Seperator(command_parms->data.c_str() + (command->command.data.length() + 1), ' ', 10, 500, true);
  1835. LogWrite(COMMAND__DEBUG, 1, "Command", "Handler: %u, COMMAND: '%s', SUBCOMMAND: '%s'", index, parent_command->command.data.c_str(), command->command.data.c_str());
  1836. }
  1837. else
  1838. LogWrite(COMMAND__DEBUG, 1, "Command", "Handler: %u, COMMAND: '%s'", index, command->command.data.c_str());
  1839. }
  1840. int ndx = 0;
  1841. if (command->required_status > client->GetAdminStatus())
  1842. {
  1843. 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());
  1844. safe_delete(sep);
  1845. client->SimpleMessage(3, "Error: Your status is insufficient for this command.");
  1846. return;
  1847. }
  1848. Player* player = client->GetPlayer();
  1849. LogWrite(COMMAND__DEBUG, 0, "Command", "Player '%s' (%u), Command: %s", player->GetName(), client->GetAccountID(), command->command.data.c_str());
  1850. switch (command->handler) {
  1851. case COMMAND_RELOAD: {
  1852. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reload commands:");
  1853. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload structs");
  1854. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload items");
  1855. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload luasystem");
  1856. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spawnscripts");
  1857. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spells");
  1858. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spells npc");
  1859. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload quests");
  1860. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spawns");
  1861. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload groundspawns");
  1862. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload zonescripts");
  1863. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload entity_commands");
  1864. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload factions");
  1865. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload mail");
  1866. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload guilds");
  1867. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload locations");
  1868. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload rules");
  1869. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload transporters");
  1870. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload startabilities");
  1871. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload voiceovers");
  1872. break;
  1873. }
  1874. case COMMAND_RELOADSTRUCTS: {
  1875. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Structs...");
  1876. world.SetReloadingSubsystem("Structs");
  1877. configReader.ReloadStructs();
  1878. world.RemoveReloadingSubSystem("Structs");
  1879. peer_manager.sendPeersMessage("/reloadcommand", command->handler);
  1880. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1881. break;
  1882. }
  1883. case COMMAND_RELOAD_QUESTS: {
  1884. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Quests...");
  1885. world.SetReloadingSubsystem("Quests");
  1886. master_quest_list.Reload();
  1887. client_list.ReloadQuests();
  1888. zone_list.ReloadClientQuests();
  1889. world.RemoveReloadingSubSystem("Quests");
  1890. peer_manager.sendPeersMessage("/reloadcommand", command->handler);
  1891. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1892. break;
  1893. }
  1894. case COMMAND_RELOAD_SPAWNS: {
  1895. client->GetCurrentZone()->ReloadSpawns();
  1896. break;
  1897. }
  1898. case COMMAND_RELOAD_SPELLS: {
  1899. if (sep && sep->arg[0] && strcmp(sep->arg[0], "npc") == 0) {
  1900. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading NPC Spells Lists (Note: Must Reload Spawns/Repop to reset npc spells)...");
  1901. world.PurgeNPCSpells();
  1902. database.LoadNPCSpells();
  1903. peer_manager.sendPeersMessage("/reloadcommand", command->handler, 1);
  1904. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1905. }
  1906. else {
  1907. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spells & NPC Spell Lists (Note: Must Reload Spawns/Repop to reset npc spells)...");
  1908. world.SetReloadingSubsystem("Spells");
  1909. zone_list.DeleteSpellProcess();
  1910. if (lua_interface)
  1911. lua_interface->DestroySpells();
  1912. master_spell_list.Reload();
  1913. zone_list.LoadSpellProcess();
  1914. world.RemoveReloadingSubSystem("Spells");
  1915. world.PurgeNPCSpells();
  1916. database.LoadNPCSpells();
  1917. peer_manager.sendPeersMessage("/reloadcommand", command->handler);
  1918. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1919. }
  1920. break;
  1921. }
  1922. case COMMAND_RELOAD_GROUNDSPAWNS: {
  1923. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Groundspawn Entries...");
  1924. world.SetReloadingSubsystem("GroundSpawns");
  1925. client->GetCurrentZone()->DeleteGroundSpawnItems();
  1926. client->GetCurrentZone()->LoadGroundSpawnEntries();
  1927. world.RemoveReloadingSubSystem("GroundSpawns");
  1928. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1929. break;
  1930. }
  1931. case COMMAND_RELOAD_ZONESCRIPTS: {
  1932. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Zone Scripts...");
  1933. world.SetReloadingSubsystem("ZoneScripts");
  1934. world.ResetZoneScripts();
  1935. database.LoadZoneScriptData();
  1936. if (lua_interface)
  1937. lua_interface->DestroyZoneScripts();
  1938. world.RemoveReloadingSubSystem("ZoneScripts");
  1939. peer_manager.sendPeersMessage("/reloadcommand", command->handler);
  1940. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1941. break;
  1942. }
  1943. case COMMAND_RELOAD_ENTITYCOMMANDS: {
  1944. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Entity Commands...");
  1945. world.SetReloadingSubsystem("EntityCommands");
  1946. client->GetCurrentZone()->ClearEntityCommands();
  1947. database.LoadEntityCommands(client->GetCurrentZone());
  1948. world.RemoveReloadingSubSystem("EntityCommands");
  1949. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1950. break;
  1951. }
  1952. case COMMAND_RELOAD_FACTIONS: {
  1953. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Factions...");
  1954. world.SetReloadingSubsystem("Factions");
  1955. master_faction_list.Clear();
  1956. database.LoadFactionList();
  1957. world.RemoveReloadingSubSystem("Factions");
  1958. peer_manager.sendPeersMessage("/reloadcommand", command->handler);
  1959. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1960. break;
  1961. }
  1962. case COMMAND_RELOAD_MAIL: {
  1963. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Mail...");
  1964. zone_list.ReloadMail();
  1965. peer_manager.sendPeersMessage("/reloadcommand", command->handler);
  1966. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1967. break;
  1968. }
  1969. case COMMAND_RELOAD_GUILDS: {
  1970. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Guilds...");
  1971. world.ReloadGuilds();
  1972. peer_manager.sendPeersMessage("/reloadcommand", command->handler);
  1973. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1974. break;
  1975. }
  1976. case COMMAND_RELOAD_LOCATIONS: {
  1977. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Locations...");
  1978. client->GetPlayer()->GetZone()->RemoveLocationGrids();
  1979. database.LoadLocationGrids(client->GetPlayer()->GetZone());
  1980. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1981. break;
  1982. }
  1983. case COMMAND_RELOAD_RULES: {
  1984. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Rules...");
  1985. database.LoadRuleSets(true);
  1986. peer_manager.sendPeersMessage("/reloadcommand", command->handler);
  1987. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1988. break;
  1989. }
  1990. case COMMAND_RELOAD_TRANSPORTERS: {
  1991. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Transporters in your current zone...");
  1992. database.LoadTransporters(client->GetCurrentZone());
  1993. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1994. break;
  1995. }
  1996. case COMMAND_RELOAD_STARTABILITIES: {
  1997. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Starting Skills/Spells...");
  1998. world.PurgeStartingLists();
  1999. world.LoadStartingLists();
  2000. peer_manager.sendPeersMessage("/reloadcommand", command->handler);
  2001. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  2002. break;
  2003. }
  2004. case COMMAND_RELOAD_VOICEOVERS: {
  2005. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Voiceovers...");
  2006. world.PurgeVoiceOvers();
  2007. world.LoadVoiceOvers();
  2008. peer_manager.sendPeersMessage("/reloadcommand", command->handler);
  2009. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  2010. break;
  2011. }
  2012. case COMMAND_READ: {
  2013. if (sep && sep->arg[1][0] && sep->IsNumber(1)) {
  2014. if (strcmp(sep->arg[0], "read") == 0) {
  2015. int32 item_index = atol(sep->arg[1]);
  2016. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  2017. if (item) {
  2018. Spawn* spawn = cmdTarget;
  2019. client->SendShowBook(client->GetPlayer(), item->name, item->book_language, item->book_pages);
  2020. break;
  2021. }
  2022. }
  2023. }
  2024. break;
  2025. }
  2026. case COMMAND_USEABILITY:{
  2027. if (sep && sep->arg[0][0] && sep->IsNumber(0)) {
  2028. if (!client->GetPlayer()->Alive()) {
  2029. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot do that right now.");
  2030. }
  2031. else {
  2032. int32 spell_id = atoul(sep->arg[0]);
  2033. int8 spell_tier = 0;
  2034. if (sep->arg[1][0] && sep->IsNumber(1))
  2035. spell_tier = atoi(sep->arg[1]);
  2036. else
  2037. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  2038. if (!spell_tier)
  2039. spell_tier = 1;
  2040. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  2041. if (spell) {
  2042. 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)
  2043. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), cmdTarget, true, true);
  2044. else
  2045. {
  2046. if (cmdTarget)
  2047. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), cmdTarget);
  2048. else
  2049. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  2050. }
  2051. }
  2052. }
  2053. }
  2054. else if (cmdTarget && cmdTarget->IsWidget())
  2055. {
  2056. Widget* widget = (Widget*)cmdTarget;
  2057. widget->HandleUse(client, "use", WIDGET_TYPE_DOOR);
  2058. }
  2059. else
  2060. {
  2061. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /useability {spell_id} [spell_tier]");
  2062. }
  2063. break;
  2064. }
  2065. case COMMAND_INFO:{
  2066. bool check_self_trade = true;
  2067. if(sep && sep->arg[1][0] && sep->IsNumber(1)){
  2068. if(strcmp(sep->arg[0], "inventory") == 0){
  2069. int32 item_index = atol(sep->arg[1]);
  2070. LogWrite(COMMAND__DEBUG, 5, "Command", "/info inventory item original index %u", item_index);
  2071. if(client->GetVersion() <= 561) {
  2072. if(item_index <= 255) {
  2073. item_index = 255 - item_index;
  2074. }
  2075. else {
  2076. if(item_index == 256) { // first "new" item to inventory is assigned index 256 by client
  2077. item_index = client->GetPlayer()->item_list.GetFirstNewItem();
  2078. }
  2079. else {
  2080. // otherwise the slot has to be mapped out depending on the amount of new items + index sent in
  2081. item_index = client->GetPlayer()->item_list.GetNewItemByIndex((int16)item_index - 255);
  2082. }
  2083. }
  2084. }
  2085. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  2086. if(item){
  2087. if (item->IsCollectable() && client->SendCollectionsForItem(item))
  2088. break;
  2089. EQ2Packet* app = 0;
  2090. if(client->GetVersion() <= 561) {
  2091. app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  2092. }
  2093. else {
  2094. app = item->serialize(client->GetVersion(), (!item->GetItemScript() || !lua_interface), client->GetPlayer());
  2095. }
  2096. //DumpPacket(app);
  2097. client->QueuePacket(app);
  2098. if(item->GetItemScript() && lua_interface)
  2099. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  2100. else if(item->generic_info.offers_quest_id > 0){ //leave the current functionality in place if it doesnt have an item script
  2101. Quest* quest = master_quest_list.GetQuest(item->generic_info.offers_quest_id, false);
  2102. if(quest && client->GetPlayer()->HasQuestBeenCompleted(item->generic_info.offers_quest_id) == 0 && client->GetPlayer()->HasActiveQuest(item->generic_info.offers_quest_id) == 0)
  2103. client->AddPendingQuest(new Quest(quest)); // copy quest since we pulled the master quest to see if it existed or not
  2104. }
  2105. }
  2106. else
  2107. LogWrite(COMMAND__ERROR, 0, "Command", "/info inventory: Unknown Index: %u", item_index);
  2108. }
  2109. else if(strcmp(sep->arg[0], "equipment") == 0){
  2110. int32 item_index = client->GetPlayer()->ConvertSlotFromClient(atol(sep->arg[1]), client->GetVersion());
  2111. Item* item = client->GetPlayer()->GetEquipmentList()->GetItem(item_index);
  2112. if(item){
  2113. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  2114. client->QueuePacket(app);
  2115. if(item->GetItemScript() && lua_interface)
  2116. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  2117. }
  2118. else
  2119. LogWrite(COMMAND__ERROR, 0, "Command", "/info equipment: Unknown Index: %u", item_index);
  2120. }
  2121. else if(strcmp(sep->arg[0], "appearance") == 0){
  2122. int32 item_index = client->GetPlayer()->ConvertSlotFromClient(atol(sep->arg[1]), client->GetVersion());
  2123. Item* item = client->GetPlayer()->GetAppearanceEquipmentList()->GetItem(item_index);
  2124. if(item){
  2125. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  2126. client->QueuePacket(app);
  2127. if(item->GetItemScript() && lua_interface)
  2128. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  2129. }
  2130. else
  2131. LogWrite(COMMAND__ERROR, 0, "Command", "/info appearance: Unknown Index: %u", item_index);
  2132. }
  2133. 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){
  2134. int32 item_id = atoul(sep->arg[1]);
  2135. Item* item = master_item_list.GetItem(item_id);
  2136. if(item){
  2137. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  2138. client->QueuePacket(app);
  2139. }
  2140. else
  2141. LogWrite(COMMAND__ERROR, 0, "Command", "/info item|merchant|store|buyback|consignment: Unknown Item ID: %u", item_id);
  2142. }
  2143. else if (strcmp(sep->arg[0], "spell") == 0) {
  2144. sint32 spell_id = atol(sep->arg[1]);
  2145. int8 tier = atoi(sep->arg[3]);
  2146. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, tier, client, true, 0x2A);
  2147. if (outapp)
  2148. client->QueuePacket(outapp);
  2149. else
  2150. LogWrite(COMMAND__ERROR, 0, "Command", "/info spell: Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  2151. }
  2152. else if (strcmp(sep->arg[0], "achievement") == 0) {
  2153. sint32 spell_id = atol(sep->arg[2]);
  2154. int8 group = atoi(sep->arg[1]);
  2155. AltAdvanceData* data = 0;
  2156. SpellBookEntry* spellentry = 0;
  2157. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  2158. LogWrite(COMMAND__ERROR, 0, "Command", "/info achievement: AA Spell ID and/or Tier, ID: %u, Group: %i", spell_id, group);
  2159. EQ2Packet* outapp = master_spell_list.GetAASpellPacket(spell_id, tier, client, true, 0x45);
  2160. if (outapp)
  2161. client->QueuePacket(outapp);
  2162. else
  2163. LogWrite(COMMAND__ERROR, 0, "Command", "/info achievement: Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, group);
  2164. }
  2165. else if (strcmp(sep->arg[0], "spellbook") == 0) {
  2166. sint32 spell_id = atol(sep->arg[1]);
  2167. int32 tier = atoi(sep->arg[2]);
  2168. if (tier > 255) {
  2169. SpellBookEntry* ent = client->GetPlayer()->GetSpellBookSpell(spell_id);
  2170. if (ent)
  2171. tier = ent->tier;
  2172. }
  2173. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, (int8)tier, client, true, 0x2A);
  2174. if (outapp)
  2175. client->QueuePacket(outapp);
  2176. else
  2177. LogWrite(COMMAND__ERROR, 0, "Command", "/info spellbook: Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  2178. }
  2179. else if (strcmp(sep->arg[0], "recipe") == 0) {
  2180. sint32 recipe_id = atol(sep->arg[1]);
  2181. EQ2Packet* outapp = master_recipe_list.GetRecipePacket(recipe_id, client, true, 0x2C);
  2182. if(outapp)
  2183. client->QueuePacket(outapp);
  2184. else
  2185. LogWrite(COMMAND__ERROR, 0, "Command", "/info recipe: Unknown Recipe ID: %u", recipe_id);
  2186. }
  2187. else if (strcmp(sep->arg[0], "recipe_product") == 0) {
  2188. sint32 recipe_id = atol(sep->arg[1]);
  2189. PlayerRecipeList* prl = client->GetPlayer()->GetRecipeList();
  2190. Recipe* recipe = nullptr;
  2191. if ((recipe = prl->GetRecipe(recipe_id)) && recipe->GetProductID()) {
  2192. RecipeProducts* rp = recipe->products[1];
  2193. if (recipe->GetProductID() > 0) {
  2194. Item* item = master_item_list.GetItem(recipe->GetProductID());
  2195. if(item){
  2196. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  2197. client->QueuePacket(app);
  2198. }
  2199. else
  2200. LogWrite(COMMAND__ERROR, 0, "Command", "/info recipe_product: Unknown Item ID: %u", recipe->GetProductID());
  2201. }
  2202. else {
  2203. LogWrite(COMMAND__ERROR, 0, "Command", "/info recipe_product: recipe->GetProductID() has value 0 for recipe id %u.", recipe_id);
  2204. }
  2205. }
  2206. else {
  2207. LogWrite(COMMAND__ERROR, 0, "Command", "/info recipe_product: with recipe id %u not found (recipe missing or no product in stage 1 assigned).", recipe_id);
  2208. }
  2209. }
  2210. else if (strcmp(sep->arg[0], "maintained") ==0) {
  2211. int32 slot = atol(sep->arg[1]);
  2212. int32 spell_id = atol(sep->arg[2]);
  2213. LogWrite(COMMAND__DEBUG, 5, "Command", "/info maintained: Spell ID - Slot: %u unknown: %u", slot, spell_id);
  2214. //int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  2215. MaintainedEffects* info = client->GetPlayer()->GetMaintainedSpellBySlot(slot);
  2216. EQ2Packet* outapp = master_spell_list.GetSpellPacket(info->spell_id, info->tier, client, true, 0x00);
  2217. if(outapp)
  2218. client->QueuePacket(outapp);
  2219. else
  2220. LogWrite(COMMAND__ERROR, 0, "Command", "/info maintained: Unknown Spell ID: %u", spell_id);
  2221. }
  2222. else if (strcmp(sep->arg[0], "effect") == 0) {
  2223. int32 spell_id = atol(sep->arg[1]);
  2224. LogWrite(COMMAND__DEBUG, 5, "Command", "/info effect: Spell ID: %u", spell_id);
  2225. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  2226. int8 type = 0;
  2227. if (client->GetVersion() <= 561)
  2228. type = 1;
  2229. EQ2Packet* outapp = master_spell_list.GetSpecialSpellPacket(spell_id, tier, client, true, type);
  2230. if (outapp){
  2231. client->QueuePacket(outapp);
  2232. }
  2233. else
  2234. LogWrite(COMMAND__ERROR, 0, "Command", "/info effect: Unknown Spell ID: %u", spell_id);
  2235. }
  2236. else if(sep->IsNumber(1) && ((strncasecmp("your_trade", sep->arg[0], 10) == 0) ||
  2237. (strncasecmp("their_trade", sep->arg[0], 11) == 0)))
  2238. {
  2239. if(strncasecmp("t", sep->arg[0], 1) == 0) { // their_trade not self trade
  2240. check_self_trade = false;
  2241. }
  2242. int8 slot_id = atoul(sep->arg[1]);
  2243. if(client->GetPlayer()->trade) {
  2244. Entity* traderToCheck = client->GetPlayer();
  2245. if(!check_self_trade) {
  2246. traderToCheck = client->GetPlayer()->trade->GetTradee(client->GetPlayer());
  2247. }
  2248. Item* tradeItem = client->GetPlayer()->trade->GetTraderSlot(traderToCheck, slot_id);
  2249. if(tradeItem != nullptr) {
  2250. EQ2Packet* app = tradeItem->serialize(client->GetVersion(), true, client->GetPlayer(), true, 0, 0, client->GetVersion() > 561 ? true : false);
  2251. client->QueuePacket(app);
  2252. }
  2253. }
  2254. }
  2255. }
  2256. else if (sep && strcmp(sep->arg[0], "overflow") == 0) {
  2257. Item* item = player->item_list.GetOverflowItem();
  2258. if(item) {
  2259. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  2260. client->QueuePacket(app);
  2261. }
  2262. else
  2263. LogWrite(COMMAND__ERROR, 0,"Command", "/info overflow: Unable to retrieve an overflow item.");
  2264. }
  2265. else
  2266. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /info {inventory|equipment|spell} {id}");
  2267. break;
  2268. }
  2269. case COMMAND_USE_EQUIPPED_ITEM:{
  2270. if (sep && sep->arg[0] && sep->IsNumber(0)){
  2271. int32 slot_id = atoul(sep->arg[0]);
  2272. Item* item = player->GetEquipmentList()->GetItem(slot_id);
  2273. if (item && item->generic_info.usable && item->GetItemScript()) {
  2274. if(!item->CheckFlag2(INDESTRUCTABLE) && item->generic_info.condition == 0) {
  2275. client->SimpleMessage(CHANNEL_COLOR_RED, "This item is broken and must be repaired at a mender before it can be used");
  2276. }
  2277. else if (item->CheckFlag(EVIL_ONLY) && client->GetPlayer()->GetAlignment() != ALIGNMENT_EVIL) {
  2278. client->Message(0, "%s requires an evil race.", item->name.c_str());
  2279. }
  2280. else if (item->CheckFlag(GOOD_ONLY) && client->GetPlayer()->GetAlignment() != ALIGNMENT_GOOD) {
  2281. client->Message(0, "%s requires a good race.", item->name.c_str());
  2282. }
  2283. else {
  2284. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player, player->GetTarget());
  2285. }
  2286. }
  2287. }
  2288. break;
  2289. }
  2290. case COMMAND_USE_ITEM: {
  2291. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  2292. int32 item_index = atoul(sep->arg[0]);
  2293. Item* item = player->item_list.GetItemFromIndex(item_index);
  2294. client->UseItem(item, client->GetPlayer()->GetTarget() ? client->GetPlayer()->GetTarget() : client->GetPlayer());
  2295. }
  2296. break;
  2297. }
  2298. case COMMAND_SCRIBE_SCROLL_ITEM: {
  2299. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  2300. Item* item = player->item_list.GetItemFromUniqueID(atoul(sep->arg[0]));
  2301. if (item) {
  2302. LogWrite(ITEM__DEBUG, 0, "Items", "ITEM ID: %u", item->details.item_id);
  2303. if(item->generic_info.item_type == 6) {
  2304. Spell* spell = master_spell_list.GetSpell(item->skill_info->spell_id, item->skill_info->spell_tier);
  2305. int8 old_slot = 0;
  2306. if (spell) {
  2307. if(!spell->ScribeAllowed(client->GetPlayer())) {
  2308. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not meet one of the requirements to scribe, due to class or level.");
  2309. break;
  2310. }
  2311. int16 tier_up = player->GetTierUp(spell->GetSpellTier());
  2312. if (rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Spells, RequirePreviousTierScribe)->GetInt8() && !player->HasSpell(spell->GetSpellID(), tier_up, false, true))
  2313. client->SimpleMessage(CHANNEL_COLOR_RED, "You have not scribed the required previous version of this ability.");
  2314. else if (!player->HasSpell(spell->GetSpellID(), spell->GetSpellTier(), true)) {
  2315. old_slot = player->GetSpellSlot(spell->GetSpellID());
  2316. player->RemoveSpellBookEntry(spell->GetSpellID());
  2317. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  2318. player->UnlockSpell(spell);
  2319. client->SendSpellUpdate(spell);
  2320. database.DeleteItem(client->GetCharacterID(), item, 0);
  2321. player->item_list.RemoveItem(item, true);
  2322. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  2323. client->QueuePacket(player->SendInventoryUpdate(client->GetVersion()));
  2324. // force purge client cache and display updated spell for hover over
  2325. EQ2Packet* app = spell->SerializeSpell(client, false, false);
  2326. client->QueuePacket(app);
  2327. }
  2328. }
  2329. else
  2330. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown spell ID: %u and tier: %u", item->skill_info->spell_id, item->skill_info->spell_tier);
  2331. }
  2332. else if(item->generic_info.item_type == 7){
  2333. if(item->recipebook_info) {
  2334. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Scribing recipe book %s (%u) for player %s.", item->name.c_str(), item->recipebook_info->recipe_id, player->GetName());
  2335. client->AddRecipeBookToPlayer(item->recipebook_info->recipe_id, item);
  2336. }
  2337. else {
  2338. 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);
  2339. 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());
  2340. }
  2341. }
  2342. else {
  2343. LogWrite(COMMAND__ERROR, 0, "Command", "Recipe Book Info is not set for item %s.", item->name.c_str());
  2344. }
  2345. }
  2346. else
  2347. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown unique item ID: %s", sep->arg[0]);
  2348. }
  2349. break;
  2350. }
  2351. case COMMAND_SUMMONITEM: {
  2352. if (sep && sep->IsNumber(0)) {
  2353. int32 item_id = atol(sep->arg[0]);
  2354. int32 quantity = 1;
  2355. if (sep->arg[1] && sep->IsNumber(1))
  2356. quantity = atoi(sep->arg[1]);
  2357. if (sep->arg[2] && strncasecmp(sep->arg[2], "bank", 4) == 0) {
  2358. client->AddItemToBank(item_id,quantity);
  2359. }
  2360. else {
  2361. client->AddItem(item_id, quantity);
  2362. }
  2363. }
  2364. else {
  2365. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} [quantity] or");
  2366. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} {quantity} [location] where location = bank");
  2367. }
  2368. break;
  2369. }
  2370. case COMMAND_COLLECTION_ADDITEM: {
  2371. // takes 2 params: collection_id, slot
  2372. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  2373. Item *item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(atoul(sep->arg[1]));
  2374. if (item)
  2375. client->HandleCollectionAddItem(atoul(sep->arg[0]), item);
  2376. else
  2377. 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]));
  2378. }
  2379. else
  2380. LogWrite(COLLECTION__ERROR, 0, "Collect", "Received command 'COMMAND_COLLECTION_ADDITEM' with unhandeled argument types");
  2381. break;
  2382. }
  2383. case COMMAND_COLLECTION_FILTER_MATCHITEM: {
  2384. // takes 1 param: slot
  2385. printf("COMMAND_COLLECTION_FILTER_MATCHITEM:\n");
  2386. int i = 0;
  2387. while (sep->arg[i] && strlen(sep->arg[i]) > 0) {
  2388. printf("\t%u: %s\n", i, sep->arg[i]);
  2389. i++;
  2390. }
  2391. break;
  2392. }
  2393. case COMMAND_WAYPOINT: {
  2394. bool success = false;
  2395. client->ClearWaypoint();
  2396. if (sep && sep->IsNumber(0) && sep->IsNumber(1) && sep->IsNumber(2)) {
  2397. if (!client->ShowPathToTarget(atof(sep->arg[0]), atof(sep->arg[1]), atof(sep->arg[2]), 0))
  2398. client->Message(CHANNEL_COLOR_RED, "Invalid coordinates given");
  2399. }
  2400. else if ( client->GetAdminStatus() > 100 && cmdTarget ) {
  2401. if (!client->ShowPathToTarget(cmdTarget->GetX(), cmdTarget->GetY(), cmdTarget->GetZ(), 0))
  2402. client->Message(CHANNEL_COLOR_RED, "Invalid coordinates given");
  2403. }
  2404. else {
  2405. client->Message(CHANNEL_COLOR_YELLOW, "Usage: /waypoint x y z");
  2406. }
  2407. break;
  2408. }
  2409. case COMMAND_WHO:{
  2410. const char* who = 0;
  2411. if(sep && sep->arg[0]){
  2412. //cout << "Who query: \n";
  2413. who = sep->argplus[0];
  2414. //cout << who << endl;
  2415. }
  2416. zone_list.ProcessWhoQuery(who, client);
  2417. break;
  2418. }
  2419. case COMMAND_SELECT_JUNCTION:{
  2420. // transporters (bells birds) use OP_SelectZoneTeleporterDestinatio / ProcessTeleportLocation(app)
  2421. // this is only used for revive it seems
  2422. int32 choice = 0;
  2423. if(sep && sep->arg[0] && sep->IsNumber(0))
  2424. choice = atoul(sep->arg[0]);
  2425. if(!client->GetPlayer()->Alive()){ //dead and this is a revive request
  2426. client->HandlePlayerRevive(choice);
  2427. }
  2428. break;
  2429. }
  2430. case COMMAND_SPAWN_MOVE: {
  2431. if (cmdTarget && cmdTarget->IsPlayer() == false) {
  2432. PacketStruct* packet = configReader.getStruct("WS_MoveObjectMode", client->GetVersion());
  2433. if (packet) {
  2434. float unknown2_3 = 0;
  2435. int8 placement_mode = 0;
  2436. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::DEFAULT);
  2437. if (sep && sep->arg[0][0]) {
  2438. if (strcmp(sep->arg[0], "wall") == 0) {
  2439. placement_mode = 2;
  2440. unknown2_3 = 150;
  2441. }
  2442. else if (strcmp(sep->arg[0], "ceiling") == 0)
  2443. placement_mode = 1;
  2444. else if (strcmp(sep->arg[0], "openheading") == 0 && cmdTarget->IsWidget())
  2445. {
  2446. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "[PlacementMode] WIDGET OPEN HEADING MODE");
  2447. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::OPEN_HEADING);
  2448. }
  2449. else if (strcmp(sep->arg[0], "closeheading") == 0 && cmdTarget->IsWidget())
  2450. {
  2451. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "[PlacementMode] WIDGET CLOSE HEADING MODE");
  2452. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::CLOSE_HEADING);
  2453. }
  2454. else if (strcmp(sep->arg[0], "myloc") == 0)
  2455. {
  2456. if (cmdTarget->GetSpawnLocationPlacementID() < 1) {
  2457. client->Message(CHANNEL_COLOR_YELLOW, "[PlacementMode] Spawn %s cannot be moved it is not assigned a spawn location placement id.", cmdTarget->GetName());
  2458. safe_delete(packet);
  2459. break;
  2460. }
  2461. cmdTarget->SetX(client->GetPlayer()->GetX(), true);
  2462. cmdTarget->SetY(client->GetPlayer()->GetY(), true);
  2463. cmdTarget->SetZ(client->GetPlayer()->GetZ(), true);
  2464. cmdTarget->SetHeading(client->GetPlayer()->GetHeading(), true);
  2465. if (database.UpdateSpawnLocationSpawns(cmdTarget))
  2466. client->Message(CHANNEL_COLOR_YELLOW, "[PlacementMode] Spawn %s placed at your location. Updated spawn_location_placement for spawn.", cmdTarget->GetName());
  2467. safe_delete(packet);
  2468. break;
  2469. }
  2470. }
  2471. packet->setDataByName("placement_mode", placement_mode);
  2472. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget));
  2473. packet->setDataByName("model_type", cmdTarget->GetModelType());
  2474. packet->setDataByName("unknown", 1); //size
  2475. packet->setDataByName("unknown2", 1); //size 2
  2476. packet->setDataByName("unknown2", .5, 1); //size 3
  2477. packet->setDataByName("unknown2", 3, 2);
  2478. packet->setDataByName("unknown2", unknown2_3, 3);
  2479. packet->setDataByName("max_distance", 500);
  2480. packet->setDataByName("CoEunknown", 0xFFFFFFFF);
  2481. client->QueuePacket(packet->serialize());
  2482. safe_delete(packet);
  2483. }
  2484. }
  2485. else {
  2486. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /spawn move (wall OR ceiling)");
  2487. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Moves a spawn anywhere you like. Optionally wall/ceiling can be provided to place wall/ceiling items.");
  2488. }
  2489. break;
  2490. }
  2491. case COMMAND_HAIL:{
  2492. Spawn* spawn = cmdTarget;
  2493. if(spawn && spawn->GetTargetable())
  2494. {
  2495. char tmp[75] = {0};
  2496. sprintf(tmp, "Hail, %s", spawn->GetName());
  2497. bool show_bubble = true;
  2498. if (spawn->IsNPC())
  2499. show_bubble = false;
  2500. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp, HEAR_SPAWN_DISTANCE, 0, show_bubble, client->GetPlayer()->GetCurrentLanguage());
  2501. if(spawn->IsPlayer() == false && spawn->Alive() && spawn->GetDistance(client->GetPlayer()) < rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Spawn, HailDistance)->GetInt32()){
  2502. if(spawn->IsNPC() && ((NPC*)spawn)->EngagedInCombat())
  2503. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED_BUSY, client->GetPlayer());
  2504. else
  2505. {
  2506. bool pauseRunback = false;
  2507. // prime runback as the heading or anything can be altered when hailing succeeds
  2508. if(spawn->IsNPC() && (spawn->HasMovementLoop() || spawn->HasMovementLocations()))
  2509. {
  2510. ((NPC*)spawn)->StartRunback();
  2511. pauseRunback = true;
  2512. }
  2513. if(spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED, client->GetPlayer()) && pauseRunback)
  2514. spawn->PauseMovement(rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Spawn, HailMovementPause)->GetInt32());
  2515. else if(spawn->IsNPC() && pauseRunback)
  2516. ((NPC*)spawn)->ClearRunback();
  2517. }
  2518. }
  2519. }
  2520. else {
  2521. string tmp = "Hail";
  2522. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp.c_str(), HEAR_SPAWN_DISTANCE, 0, true, client->GetPlayer()->GetCurrentLanguage());
  2523. }
  2524. break;
  2525. }
  2526. case COMMAND_SAY:{
  2527. if (sep && sep->arg[0][0]) {
  2528. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, sep->argplus[0], HEAR_SPAWN_DISTANCE, 0, true, client->GetPlayer()->GetCurrentLanguage());
  2529. if (cmdTarget && !(cmdTarget->IsPlayer()))
  2530. client->GetCurrentZone()->CallSpawnScript(cmdTarget, SPAWN_SCRIPT_HEAR_SAY, client->GetPlayer(), sep->argplus[0]);
  2531. }
  2532. else
  2533. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /say {message}");
  2534. break;
  2535. }
  2536. case COMMAND_TELL:{
  2537. if(sep && sep->arg[0] && sep->argplus[1]){
  2538. if(!zone_list.HandleGlobalChatMessage(client, sep->arg[0], CHANNEL_PRIVATE_TELL, sep->argplus[1], 0, client->GetPlayer()->GetCurrentLanguage()))
  2539. client->Message(CHANNEL_COLOR_RED,"Unable to find client %s",sep->arg[0]);
  2540. }else
  2541. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /tell {character_name} {message}");
  2542. break;
  2543. }
  2544. case COMMAND_SHOUT:{
  2545. if(sep && sep->arg[0][0])
  2546. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SHOUT, sep->argplus[0], 0, 0, true, client->GetPlayer()->GetCurrentLanguage());
  2547. else
  2548. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /shout {message}");
  2549. break;
  2550. }
  2551. case COMMAND_AUCTION:{
  2552. if(sep && sep->arg[0][0])
  2553. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_AUCTION, sep->argplus[0], 0, 0, true, client->GetPlayer()->GetCurrentLanguage());
  2554. else
  2555. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /auction {message}");
  2556. break;
  2557. }
  2558. case COMMAND_OOC:{
  2559. //For now ooc will be the global chat channel, eventually when we create more channels we will create a global chat channel
  2560. if(sep && sep->arg[0][0])
  2561. zone_list.HandleGlobalChatMessage(client, 0, CHANNEL_OUT_OF_CHARACTER, sep->argplus[0], 0, client->GetPlayer()->GetCurrentLanguage());
  2562. else
  2563. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /ooc {message}");
  2564. break;
  2565. }
  2566. case COMMAND_EMOTE:{
  2567. if(sep && sep->arg[0][0])
  2568. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_EMOTE, sep->argplus[0]);
  2569. else
  2570. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /emote {action}");
  2571. break;
  2572. }
  2573. case COMMAND_RACE:{
  2574. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  2575. if(sep->arg[1][0] && sep->IsNumber(1)){
  2576. client->GetPlayer()->GetInfoStruct()->set_race(atoi(sep->arg[1]));
  2577. client->GetPlayer()->SetRace(atoi(sep->arg[1]));
  2578. client->UpdateTimeStampFlag ( RACE_UPDATE_FLAG );
  2579. client->GetPlayer()->SetCharSheetChanged(true);
  2580. }
  2581. client->GetPlayer()->SetModelType(atoi(sep->arg[0]));
  2582. //EQ2Packet* outapp = client->GetPlayer()->spawn_update_packet(client->GetPlayer(), client->GetVersion(), client->GetPlayer()->GetFeatures());
  2583. //client->QueuePacket(outapp);
  2584. }
  2585. else{
  2586. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /race {race type id} {race id}");
  2587. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "{race id} is optional");
  2588. }
  2589. break;
  2590. }
  2591. case COMMAND_BANK_DEPOSIT:{
  2592. if(client->GetBanker() && sep && sep->arg[0]){
  2593. int64 amount = 0;
  2594. string deposit = string(sep->arg[0]);
  2595. amount = atoi64(deposit.c_str());
  2596. client->BankDeposit(amount);
  2597. }
  2598. break;
  2599. }
  2600. case COMMAND_BANK_WITHDRAWAL:{
  2601. if(client->GetBanker() && sep && sep->arg[0] && sep->IsNumber(0)){
  2602. int64 amount = 0;
  2603. string deposit = string(sep->arg[0]);
  2604. amount = atoi64(deposit.c_str());
  2605. client->BankWithdrawal(amount);
  2606. }
  2607. break;
  2608. }
  2609. case COMMAND_BANK_CANCEL:{
  2610. Spawn* banker = cmdTarget;
  2611. client->Bank(banker, true);
  2612. break;
  2613. }
  2614. case COMMAND_BANK:{
  2615. LogWrite(PLAYER__DEBUG, 0, "Players", "Open Player Personal Bank...");
  2616. Spawn* banker = cmdTarget;
  2617. client->Bank(banker);
  2618. break;
  2619. }
  2620. case COMMAND_GUILD_BANK:{
  2621. LogWrite(GUILD__DEBUG, 0, "Guilds", "Open Guild Bank...");
  2622. //Spawn* banker = client->GetPlayer()->GetTarget();
  2623. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will eventually open the guild bank!");
  2624. break;
  2625. }
  2626. case COMMAND_START_MAIL: {
  2627. client->SetMailTransaction(cmdTarget);
  2628. client->SendMailList();
  2629. break;
  2630. }
  2631. case COMMAND_CANCEL_MAIL: {
  2632. client->SetMailTransaction(0);
  2633. break;
  2634. }
  2635. case COMMAND_GET_MAIL_MESSAGE: {
  2636. if (sep && sep->arg[0] && sep->IsNumber(0))
  2637. client->DisplayMailMessage(atoul(sep->arg[0]));
  2638. break;
  2639. }
  2640. case COMMAND_ADD_MAIL_PLAT: {
  2641. if (sep && sep->arg[0] && sep->IsNumber(0))
  2642. client->AddMailCoin(0, 0, 0, atoul(sep->arg[0]));
  2643. break;
  2644. }
  2645. case COMMAND_ADD_MAIL_GOLD: {
  2646. if (sep && sep->arg[0] && sep->IsNumber(0))
  2647. client->AddMailCoin(0, 0, atoul(sep->arg[0]));
  2648. break;
  2649. }
  2650. case COMMAND_ADD_MAIL_SILVER: {
  2651. if (sep && sep->arg[0] && sep->IsNumber(0))
  2652. client->AddMailCoin(0, atoul(sep->arg[0]));
  2653. break;
  2654. }
  2655. case COMMAND_ADD_MAIL_COPPER: {
  2656. if (sep && sep->arg[0] && sep->IsNumber(0))
  2657. client->AddMailCoin(atoul(sep->arg[0]));
  2658. break;
  2659. }
  2660. case COMMAND_SET_MAIL_ITEM: {
  2661. if(sep && sep->IsNumber(0) && sep->IsNumber(1))
  2662. {
  2663. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(atoul(sep->arg[0]));
  2664. if(item)
  2665. {
  2666. int16 quantity = atoul(sep->arg[1]);
  2667. if(item->CheckFlag(NO_TRADE) || item->CheckFlag(ATTUNED) || item->CheckFlag(ARTIFACT) || item->CheckFlag2(HEIRLOOM))
  2668. {
  2669. return;
  2670. }
  2671. if(item->IsBag())
  2672. {
  2673. vector<Item*>* bag_items = player->GetPlayerItemList()->GetItemsInBag(item);
  2674. if(bag_items && bag_items->size() > 0)
  2675. {
  2676. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot mail a bag with items inside it.");
  2677. safe_delete(bag_items);
  2678. return;
  2679. }
  2680. safe_delete(bag_items);
  2681. }
  2682. Item* itemtoadd = item;
  2683. if(quantity > 0)
  2684. {
  2685. if(quantity > item->details.count)
  2686. return;
  2687. Item* tmpItem = new Item(item);
  2688. tmpItem->details.count = quantity;
  2689. itemtoadd = tmpItem;
  2690. }
  2691. if(client->AddMailItem(itemtoadd))
  2692. {
  2693. client->RemoveItem(item, quantity, true);
  2694. }
  2695. }
  2696. }
  2697. break;
  2698. }
  2699. case COMMAND_REMOVE_MAIL_PLAT: {
  2700. if (sep && sep->arg[0] && sep->IsNumber(0))
  2701. client->RemoveMailCoin(0, 0, 0, atoul(sep->arg[0]));
  2702. break;
  2703. }
  2704. case COMMAND_REMOVE_MAIL_GOLD: {
  2705. if (sep && sep->arg[0] && sep->IsNumber(0))
  2706. client->RemoveMailCoin(0, 0, atoul(sep->arg[0]));
  2707. break;
  2708. }
  2709. case COMMAND_REMOVE_MAIL_SILVER: {
  2710. if (sep && sep->arg[0] && sep->IsNumber(0))
  2711. client->RemoveMailCoin(0, atoul(sep->arg[0]));
  2712. break;
  2713. }
  2714. case COMMAND_REMOVE_MAIL_COPPER: {
  2715. if (sep && sep->arg[0] && sep->IsNumber(0))
  2716. client->RemoveMailCoin(atoul(sep->arg[0]));
  2717. break;
  2718. }
  2719. case COMMAND_TAKE_MAIL_ATTACHMENTS: {
  2720. if (sep && sep->arg[0] && sep->IsNumber(0))
  2721. client->TakeMailAttachments(atoul(sep->arg[0]));
  2722. break;
  2723. }
  2724. case COMMAND_CANCEL_SEND_MAIL: {
  2725. client->ResetSendMail();
  2726. break;
  2727. }
  2728. case COMMAND_DELETE_MAIL_MESSAGE: {
  2729. if (sep && sep->arg[0] && sep->IsNumber(0))
  2730. client->DeleteMail(atoul(sep->arg[0]), true);
  2731. break;
  2732. }
  2733. case COMMAND_REPORT_SPAM: {
  2734. LogWrite(MISC__TODO, 1, "TODO", " received reportspam\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  2735. if (sep && sep->arg[0]) LogWrite(COMMAND__DEBUG, 0, "Command", "%s\n", sep->argplus[0]);
  2736. break;
  2737. }
  2738. case COMMAND_KILL:{
  2739. Spawn* dead = 0;
  2740. if (sep && sep->arg[0] && strncasecmp(sep->arg[0],"self",4)==0){
  2741. dead=client->GetPlayer();
  2742. client->GetPlayer()->SetHP(0);
  2743. client->GetPlayer()->KillSpawn(dead);
  2744. }else{
  2745. dead= cmdTarget;
  2746. if(dead && dead->IsPlayer() == false){
  2747. if(dead->IsNPC() && ((NPC*)dead)->Brain()) {
  2748. client->GetPlayer()->CheckEncounterState((Entity*)dead);
  2749. ((NPC*)dead)->Brain()->AddToEncounter(client->GetPlayer());
  2750. ((NPC*)dead)->AddTargetToEncounter(client->GetPlayer());
  2751. ((NPC*)dead)->Brain()->AddHate(client->GetPlayer(), 1);
  2752. }
  2753. dead->SetHP(0);
  2754. if(sep && sep->arg[0] && sep->IsNumber(0) && atoi(sep->arg[0]) == 1)
  2755. client->GetCurrentZone()->RemoveSpawn(dead, true, true, true, true, true);
  2756. else
  2757. client->GetPlayer()->KillSpawn(dead);
  2758. }else{
  2759. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /kill (self)");
  2760. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Kills currently selected non-player target.");
  2761. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Optionally, self may be used to kill yourself");
  2762. }
  2763. }
  2764. break;
  2765. }
  2766. case COMMAND_LEVEL:{
  2767. if(sep && sep->arg[ndx][0] && sep->IsNumber(0)){
  2768. int16 new_level = atoi(sep->arg[ndx]);
  2769. if (!client->GetPlayer()->CheckLevelStatus(new_level))
  2770. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have the required status to level up anymore!");
  2771. else {
  2772. if (new_level < 1)
  2773. new_level = 1;
  2774. if (new_level > 255)
  2775. new_level = 255;
  2776. client->ChangeLevel(client->GetPlayer()->GetLevel(), new_level);
  2777. }
  2778. }else
  2779. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /level {new_level}");
  2780. break;
  2781. }
  2782. case COMMAND_SIT: {
  2783. if(client->GetPlayer()->GetHP() > 0){
  2784. client->QueuePacket(new EQ2Packet(OP_SitMsg, 0, 0));
  2785. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You sit down.");
  2786. client->GetPlayer()->set_character_flag(CF_IS_SITTING);
  2787. }
  2788. break;
  2789. }
  2790. case COMMAND_STAND: {
  2791. if(client->GetPlayer()->GetHP() > 0){
  2792. client->QueuePacket(new EQ2Packet(OP_StandMsg, 0, 0));
  2793. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You stand up.");
  2794. client->GetPlayer()->reset_character_flag(CF_IS_SITTING);
  2795. }
  2796. break;
  2797. }
  2798. case COMMAND_CLASS:{
  2799. if(sep && sep->arg[ndx][0]){
  2800. client->GetPlayer()->SetPlayerAdventureClass(atoi(sep->arg[ndx]));
  2801. client->UpdateTimeStampFlag ( CLASS_UPDATE_FLAG );
  2802. }else
  2803. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /class {class_id}");
  2804. break;
  2805. }
  2806. case COMMAND_FLYMODE:{
  2807. if(sep && sep->arg[0] && sep->IsNumber(0)){
  2808. PrintSep(sep, "COMMAND_FLYMODE");
  2809. int8 val = atoul(sep->arg[0]);
  2810. ClientPacketFunctions::SendFlyMode(client, val);
  2811. }
  2812. else{
  2813. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage ON: /flymode [1|2] 1 = fly, 2 = no clip");
  2814. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage OFF: /flymode 0");
  2815. }
  2816. break;
  2817. }
  2818. case COMMAND_LOOT_LIST:{
  2819. Spawn* spawn = cmdTarget;
  2820. if(spawn && spawn->IsEntity()){
  2821. if (sep && sep->arg[0]) {
  2822. if (!spawn->GetDatabaseID())
  2823. {
  2824. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "NOTE: Spawn has no database id to assign to loottables.");
  2825. }
  2826. if (!spawn->IsNPC())
  2827. {
  2828. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "these /loot list [add/remove/clearall] sub-commands are only designed for an NPC.");
  2829. break;
  2830. }
  2831. bool reloadLoot = false;
  2832. if (!stricmp(sep->arg[0], "remove") && sep->arg[1] && sep->IsNumber(1))
  2833. {
  2834. int32 loottable_id = atoul(sep->arg[1]);
  2835. if (loottable_id > 0 && database.RemoveSpawnLootTable(spawn, loottable_id))
  2836. {
  2837. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u loot table %u removed.", spawn->GetDatabaseID(), loottable_id);
  2838. reloadLoot = true;
  2839. }
  2840. else
  2841. client->Message(CHANNEL_COLOR_YELLOW, "/loot list remove [loottableid] - could not match any spawn_id entries against loottable_id %u.", loottable_id);
  2842. }
  2843. else if (!stricmp(sep->arg[0], "add") && sep->arg[1] && sep->IsNumber(1))
  2844. {
  2845. int32 loottable_id = atoul(sep->arg[1]);
  2846. if (loottable_id > 0)
  2847. {
  2848. database.AddLootTableToSpawn(spawn, loottable_id);
  2849. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u loot table %u added.", spawn->GetDatabaseID(), loottable_id);
  2850. reloadLoot = true;
  2851. }
  2852. else
  2853. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list add [loottableid] - cannot add a loottable id of 0.");
  2854. }
  2855. else if (!stricmp(sep->arg[0], "clearall"))
  2856. {
  2857. if (database.RemoveSpawnLootTable(spawn, 0))
  2858. {
  2859. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn loot tables removed.");
  2860. reloadLoot = true;
  2861. }
  2862. else
  2863. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list clearall - could not match any spawn_id entries in loottable_id.");
  2864. }
  2865. else if (!stricmp(sep->arg[0], "details"))
  2866. {
  2867. spawn->LockLoot();
  2868. client->SimpleMessage(CHANNEL_COMMANDS, "Loot Window List:");
  2869. if (spawn->GetLootWindowList()->size() > 0) {
  2870. std::map<int32, bool>::iterator itr;
  2871. for (itr = spawn->GetLootWindowList()->begin(); itr != spawn->GetLootWindowList()->end(); itr++) {
  2872. Spawn* looter = client->GetPlayer()->GetZone()->GetSpawnByID(itr->first);
  2873. if (looter) {
  2874. client->Message(CHANNEL_COLOR_YELLOW, "Looter: %s IsLootWindowOpen: %s, HasCompletedLootWindow: %s.", looter->GetName(), itr->second ? "NO" : "YES", spawn->HasSpawnLootWindowCompleted(itr->first) ? "YES" : "NO");
  2875. }
  2876. }
  2877. }
  2878. spawn->UnlockLoot();
  2879. }
  2880. else
  2881. {
  2882. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list argument not supported.");
  2883. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list add [loottableid] - add new loottable to spawn");
  2884. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list remove [loottableid] - remove existing loottable from spawn");
  2885. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list clearall - remove all loottables from spawn");
  2886. break;
  2887. }
  2888. if (reloadLoot)
  2889. {
  2890. database.LoadSpawnLoot(spawn->GetZone(), spawn);
  2891. if (spawn->IsNPC())
  2892. {
  2893. Entity* ent = (Entity*)spawn;
  2894. ent->SetLootCoins(0);
  2895. ent->ClearLoot();
  2896. spawn->GetZone()->AddLoot((NPC*)spawn);
  2897. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u active loot purged and reloaded.", spawn->GetDatabaseID());
  2898. }
  2899. }
  2900. break; // nothing further this is the end of these sub commands
  2901. }
  2902. else
  2903. {
  2904. vector<int32> loot_list = client->GetCurrentZone()->GetSpawnLootList(spawn->GetDatabaseID(), spawn->GetZone()->GetZoneID(), spawn->GetLevel(), race_types_list.GetRaceType(spawn->GetModelType()), spawn);
  2905. if (loot_list.size() > 0) {
  2906. client->Message(CHANNEL_COLOR_YELLOW, "%s belongs to the following loot lists: ", spawn->GetName());
  2907. vector<int32>::iterator list_itr;
  2908. LootTable* table = 0;
  2909. for (list_itr = loot_list.begin(); list_itr != loot_list.end(); list_itr++) {
  2910. table = client->GetCurrentZone()->GetLootTable(*list_itr);
  2911. if (table)
  2912. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", *list_itr, table->name.c_str());
  2913. }
  2914. }
  2915. client->Message(CHANNEL_COLOR_YELLOW, "Coins being carried: %u", spawn->GetLootCoins());
  2916. vector<Item*>* items = spawn->GetLootItems();
  2917. if (items) {
  2918. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is carrying the following items: ");
  2919. vector<Item*>::iterator itr;
  2920. Item* item = 0;
  2921. for (itr = items->begin(); itr != items->end(); itr++) {
  2922. item = *itr;
  2923. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", item->details.item_id, item->name.c_str());
  2924. }
  2925. }
  2926. else
  2927. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is not carrying any items.");
  2928. }
  2929. }
  2930. break;
  2931. }
  2932. case COMMAND_LOOT_SETCOIN:{
  2933. Spawn* spawn = cmdTarget;
  2934. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2935. spawn->SetLootCoins(atoul(sep->arg[0]));
  2936. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully set coins.");
  2937. }
  2938. else
  2939. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot setcoin {amount}");
  2940. break;
  2941. }
  2942. case COMMAND_LOOT_ADDITEM:{
  2943. Spawn* spawn = cmdTarget;
  2944. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2945. int16 charges = 1;
  2946. if(sep->arg[1] && sep->IsNumber(1))
  2947. charges = atoi(sep->arg[1]);
  2948. spawn->AddLootItem(atoul(sep->arg[0]), charges);
  2949. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully added item.");
  2950. }
  2951. else
  2952. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot additem {item_id}");
  2953. break;
  2954. }
  2955. case COMMAND_LOOT_REMOVEITEM:{
  2956. Spawn* spawn = cmdTarget;
  2957. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2958. Item* item = spawn->LootItem(atoul(sep->arg[0]));
  2959. lua_interface->SetLuaUserDataStale(item);
  2960. safe_delete(item);
  2961. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully removed item.");
  2962. }
  2963. else
  2964. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot removeitem {item_id}");
  2965. break;
  2966. }
  2967. case COMMAND_LOOT_CORPSE:
  2968. case COMMAND_DISARM:
  2969. case COMMAND_LOOT:{
  2970. if (cmdTarget && ((Entity*)cmdTarget)->IsNPC() && cmdTarget->Alive())
  2971. {
  2972. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is not dead.");
  2973. break;
  2974. }
  2975. if(cmdTarget && cmdTarget->IsEntity()){
  2976. if (cmdTarget->GetDistance(client->GetPlayer()) <= rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Loot, LootRadius)->GetFloat()){
  2977. if (!rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Loot, AutoDisarmChest)->GetBool() && command->handler == COMMAND_DISARM )
  2978. client->OpenChest(cmdTarget, true);
  2979. else
  2980. client->LootSpawnRequest(cmdTarget, rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Loot, AutoDisarmChest)->GetBool());
  2981. if (!(cmdTarget)->HasLoot()){
  2982. if (((Entity*)cmdTarget)->IsNPC())
  2983. client->GetCurrentZone()->RemoveDeadSpawn(cmdTarget);
  2984. }
  2985. }
  2986. else
  2987. client->Message(CHANNEL_COLOR_YELLOW, "You are too far away to interact with that");
  2988. }
  2989. else if(!cmdTarget || cmdTarget->GetHP() > 0)
  2990. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid target.");
  2991. break;
  2992. }
  2993. case COMMAND_RELOADSPAWNSCRIPTS:{
  2994. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spawn Scripts....");
  2995. if (lua_interface)
  2996. lua_interface->SetLuaSystemReloading(true);
  2997. world.ResetSpawnScripts();
  2998. database.LoadSpawnScriptData();
  2999. if(lua_interface) {
  3000. lua_interface->DestroySpawnScripts();
  3001. lua_interface->SetLuaSystemReloading(false);
  3002. }
  3003. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Success!");
  3004. break;
  3005. }
  3006. case COMMAND_RELOADREGIONSCRIPTS:{
  3007. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Region Scripts....");
  3008. if(lua_interface) {
  3009. lua_interface->DestroyRegionScripts();
  3010. }
  3011. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Success!");
  3012. break;
  3013. }
  3014. case COMMAND_RELOADLUASYSTEM:{
  3015. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Attempting to reload entire LUA system....");
  3016. world.SetReloadingSubsystem("LuaSystem");
  3017. if(lua_interface) {
  3018. lua_interface->SetLuaSystemReloading(true);
  3019. }
  3020. zone_list.DeleteSpellProcess();
  3021. if (lua_interface)
  3022. lua_interface->DestroySpells();
  3023. master_spell_list.Reload();
  3024. zone_list.LoadSpellProcess();
  3025. if(lua_interface){
  3026. map<Client*, int32> debug_clients = lua_interface->GetDebugClients();
  3027. map<Client*, int32>::iterator itr;
  3028. for(itr = debug_clients.begin(); itr != debug_clients.end(); itr++){
  3029. if(lua_interface)
  3030. lua_interface->UpdateDebugClients(itr->first);
  3031. }
  3032. }
  3033. world.ResetSpawnScripts();
  3034. database.LoadSpawnScriptData();
  3035. world.ResetZoneScripts();
  3036. database.LoadZoneScriptData();
  3037. if(lua_interface) {
  3038. lua_interface->DestroySpawnScripts();
  3039. lua_interface->DestroyRegionScripts();
  3040. lua_interface->DestroyQuests();
  3041. lua_interface->DestroyItemScripts();
  3042. lua_interface->DestroyZoneScripts();
  3043. }
  3044. int32 quest_count = database.LoadQuests();
  3045. int32 spell_count = 0;
  3046. if(lua_interface) {
  3047. spell_count = database.LoadSpellScriptData();
  3048. lua_interface->SetLuaSystemReloading(false);
  3049. }
  3050. world.RemoveReloadingSubSystem("LuaSystem");
  3051. client->Message(CHANNEL_COLOR_YELLOW, "Successfully loaded %u spell(s), %u quest(s).", spell_count, quest_count);
  3052. break;
  3053. }
  3054. case COMMAND_DECLINE_QUEST:{
  3055. int32 quest_id = 0;
  3056. if(sep && sep->arg[0] && sep->IsNumber(0))
  3057. quest_id = atoul(sep->arg[0]);
  3058. if(quest_id > 0){
  3059. client->RemovePendingQuest(quest_id);
  3060. }
  3061. break;
  3062. }
  3063. case COMMAND_DELETE_QUEST:{
  3064. int32 quest_id = 0;
  3065. if(sep && sep->arg[0] && sep->IsNumber(0))
  3066. quest_id = atoul(sep->arg[0]);
  3067. if(quest_id > 0){
  3068. client->GetPlayer()->MPlayerQuests.readlock(__FUNCTION__, __LINE__);
  3069. if(lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0) {
  3070. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  3071. client->GetPlayer()->MPlayerQuests.releasereadlock(__FUNCTION__, __LINE__);
  3072. if (quest && quest->CanDeleteQuest()) {
  3073. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  3074. client->RemovePlayerQuest(quest_id);
  3075. client->GetCurrentZone()->SendQuestUpdates(client);
  3076. }
  3077. }
  3078. else {
  3079. client->GetPlayer()->MPlayerQuests.releasereadlock(__FUNCTION__, __LINE__);
  3080. }
  3081. }
  3082. break;
  3083. }
  3084. case COMMAND_ACCEPT_QUEST:{
  3085. int32 quest_id = 0;
  3086. if(sep && sep->arg[0] && sep->IsNumber(0))
  3087. quest_id = atoul(sep->arg[0]);
  3088. if(quest_id > 0){
  3089. client->AcceptQuest(quest_id);
  3090. }
  3091. break;
  3092. }
  3093. case COMMAND_NAME:{
  3094. if(sep && sep->arg[ndx][0]){
  3095. client->GetPlayer()->GetInfoStruct()->set_name(std::string(sep->arg[ndx]).substr(0,39));
  3096. client->GetPlayer()->SetCharSheetChanged(true);
  3097. }else
  3098. client->Message(CHANNEL_COLOR_YELLOW,"Usage: /name {new_name}");
  3099. break;
  3100. }
  3101. case COMMAND_GROUP: {
  3102. if(sep && sep->arg[0])
  3103. printf("Group: %s\n",sep->argplus[0]);
  3104. break;
  3105. }
  3106. case COMMAND_GROUPSAY:{
  3107. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  3108. if(sep && sep->arg[0] && gmi) {
  3109. world.GetGroupManager()->GroupChatMessage(gmi->group_id, client->GetPlayer(), client->GetPlayer()->GetCurrentLanguage(), sep->argplus[0]);
  3110. peer_manager.SendPeersChannelMessage(gmi->group_id, std::string(client->GetPlayer()->GetName()), std::string(sep->argplus[0]), CHANNEL_GROUP_SAY, client->GetPlayer()->GetCurrentLanguage());
  3111. }
  3112. break;
  3113. }
  3114. case COMMAND_GROUPINVITE: {
  3115. Entity* target = 0;
  3116. Client* target_client = 0;
  3117. if (client->GetPlayer()->GetGroupMemberInfo() && !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  3118. client->SimpleMessage(CHANNEL_COMMANDS, "You must be the group leader to invite.");
  3119. return;
  3120. }
  3121. // name provided with command so it has to be a player, npc not supported here
  3122. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0){
  3123. target_client = zone_list.GetClientByCharName(sep->arg[0]);
  3124. if (target_client) {
  3125. if (!target_client->IsConnected() || !target_client->IsReadyForSpawns())
  3126. target = 0;
  3127. else
  3128. target = target_client->GetPlayer();
  3129. }
  3130. }
  3131. // if name was not provided use the players target, npc or player supported here
  3132. if (!target && client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  3133. target = (Entity*)client->GetPlayer()->GetTarget();
  3134. if (target->IsPlayer()) {
  3135. target_client = ((Player*)target)->GetClient();
  3136. }
  3137. }
  3138. int8 result = world.GetGroupManager()->Invite(client->GetPlayer(), target);
  3139. if (target && result == 0) {
  3140. client->Message(CHANNEL_COMMANDS, "You invite %s to group with you.", target->GetName());
  3141. if (target_client) {
  3142. client->SendReceiveOffer(target_client, 1, std::string(client->GetPlayer()->GetName()), 1);
  3143. }
  3144. }
  3145. else if (result == 1)
  3146. client->SimpleMessage(CHANNEL_COMMANDS, "That player is already in a group.");
  3147. else if (result == 2)
  3148. client->SimpleMessage(CHANNEL_COMMANDS, "That player has been invited to another group.");
  3149. else if (result == 3)
  3150. client->SimpleMessage(CHANNEL_COMMANDS, "Your group is already full.");
  3151. else if (result == 4)
  3152. client->SimpleMessage(CHANNEL_COMMANDS, "You have a pending invitation, cancel it first.");
  3153. else if (result == 5)
  3154. client->SimpleMessage(CHANNEL_COMMANDS, "You cannot invite yourself!");
  3155. else if (result == 6)
  3156. client->SimpleMessage(CHANNEL_COMMANDS, "Could not locate the player.");
  3157. else
  3158. client->SimpleMessage(CHANNEL_COMMANDS, "Group invite failed, unknown error!");
  3159. break;
  3160. }
  3161. case COMMAND_GROUPDISBAND: {
  3162. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  3163. if (gmi && gmi->leader) { // TODO: Leader check..DONE! :X
  3164. // world.GetGroupManager()->SimpleGroupMessage(gmi->group_id, "Your group has been disbanded.");
  3165. world.GetGroupManager()->RemoveGroup(gmi->group_id);
  3166. peer_manager.sendPeersDisbandGroup(gmi->group_id);
  3167. }
  3168. break;
  3169. }
  3170. case COMMAND_GROUP_LEAVE: {
  3171. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  3172. if (gmi) {
  3173. int32 group_id = gmi->group_id;
  3174. world.GetGroupManager()->RemoveGroupMember(group_id, client->GetPlayer());
  3175. if (!world.GetGroupManager()->IsGroupIDValid(group_id)) {
  3176. // leader->Message(CHANNEL_COLOR_GROUP, "%s has left the group.", client->GetPlayer()->GetName());
  3177. }
  3178. else {
  3179. world.GetGroupManager()->GroupMessage(group_id, "%s has left the group.", client->GetPlayer()->GetName());
  3180. }
  3181. client->SimpleMessage(CHANNEL_GROUP_CHAT, "You have left the group");
  3182. }
  3183. break;
  3184. }
  3185. case COMMAND_FRIEND_ADD:{
  3186. string name = "";
  3187. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  3188. name = database.GetPlayerName(sep->arg[0]);
  3189. else if(cmdTarget && cmdTarget->IsPlayer())
  3190. name = string(cmdTarget->GetName());
  3191. if(name.length() > 0){
  3192. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  3193. if(client->GetPlayer()->IsIgnored(name.c_str())){
  3194. client->GetPlayer()->RemoveIgnore(name.c_str());
  3195. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  3196. client->SendChatRelationship(3, name.c_str());
  3197. }
  3198. client->GetPlayer()->AddFriend(name.c_str(), true);
  3199. client->SendChatRelationship(0, name.c_str());
  3200. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added friend: %s", name.c_str());
  3201. if(zone_list.GetClientByCharName(name))
  3202. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Friend: %s has logged in.", name.c_str());
  3203. }
  3204. else
  3205. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot be more friendly towards yourself!");
  3206. }
  3207. else
  3208. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  3209. break;
  3210. }
  3211. case COMMAND_FRIEND_REMOVE:{
  3212. string name = "";
  3213. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  3214. name = database.GetPlayerName(sep->arg[0]);
  3215. else if(cmdTarget && cmdTarget->IsPlayer())
  3216. name = string(cmdTarget->GetName());
  3217. if(name.length() > 0){
  3218. client->GetPlayer()->RemoveFriend(name.c_str());
  3219. client->SendChatRelationship(1, name.c_str());
  3220. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  3221. }
  3222. else
  3223. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  3224. break;
  3225. }
  3226. case COMMAND_FRIENDS:{
  3227. break;
  3228. }
  3229. case COMMAND_IGNORE_ADD:{
  3230. string name = "";
  3231. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  3232. name = database.GetPlayerName(sep->arg[0]);
  3233. else if(cmdTarget && cmdTarget->IsPlayer())
  3234. name = string(cmdTarget->GetName());
  3235. if(name.length() > 0){
  3236. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  3237. if(client->GetPlayer()->IsFriend(name.c_str())){
  3238. client->GetPlayer()->RemoveFriend(name.c_str());
  3239. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  3240. client->SendChatRelationship(1, name.c_str());
  3241. }
  3242. client->GetPlayer()->AddIgnore(name.c_str(), true);
  3243. client->SendChatRelationship(2, name.c_str());
  3244. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added ignore: %s", name.c_str());
  3245. }
  3246. else
  3247. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot ignore yourself!");
  3248. }
  3249. else
  3250. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  3251. break;
  3252. }
  3253. case COMMAND_IGNORE_REMOVE:{
  3254. string name = "";
  3255. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  3256. name = database.GetPlayerName(sep->arg[0]);
  3257. else if(cmdTarget && cmdTarget->IsPlayer())
  3258. name = string(cmdTarget->GetName());
  3259. if(name.length() > 0){
  3260. client->GetPlayer()->RemoveIgnore(name.c_str());
  3261. client->SendChatRelationship(3, name.c_str());
  3262. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  3263. }
  3264. break;
  3265. }
  3266. case COMMAND_IGNORES:{
  3267. break;
  3268. }
  3269. case COMMAND_GROUP_KICK:{
  3270. Entity* kicked = 0;
  3271. Client* kicked_client = 0;
  3272. int32 group_id = 0;
  3273. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader)
  3274. return;
  3275. if (sep && sep->arg[0]) {
  3276. kicked_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  3277. if (kicked_client)
  3278. kicked = kicked_client->GetPlayer();
  3279. }
  3280. else if (cmdTarget && cmdTarget->IsEntity()) {
  3281. kicked = (Entity*)cmdTarget;
  3282. }
  3283. group_id = client->GetPlayer()->GetGroupMemberInfo()->group_id;
  3284. bool send_kicked_message = world.GetGroupManager()->GetGroupSize(group_id) > 2;
  3285. if (kicked)
  3286. world.GetGroupManager()->RemoveGroupMember(group_id, kicked);
  3287. if(send_kicked_message)
  3288. world.GetGroupManager()->GroupMessage(group_id, "%s was kicked from the group.", kicked->GetName());
  3289. else
  3290. client->Message(CHANNEL_GROUP_CHAT, "You kicked %s from the group", kicked->GetName());
  3291. if (kicked_client)
  3292. kicked_client->SimpleMessage(CHANNEL_GROUP_CHAT, "You were kicked from the group");
  3293. break;
  3294. }
  3295. case COMMAND_GROUP_MAKE_LEADER:{
  3296. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  3297. client->SimpleMessage(CHANNEL_COMMANDS, "You are not a group leader.");
  3298. return;
  3299. }
  3300. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 1) {
  3301. Client* new_leader = zone_list.GetClientByCharName(sep->arg[0]);
  3302. if (new_leader && new_leader->GetPlayer()->GetGroupMemberInfo() && new_leader->GetPlayer()->GetGroupMemberInfo()->group_id == client->GetPlayer()->GetGroupMemberInfo()->group_id) {
  3303. if (client->GetPlayer()->IsGroupMember(new_leader->GetPlayer())) {
  3304. if(world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, new_leader->GetPlayer())) {
  3305. world.GetGroupManager()->GroupMessage(client->GetPlayer()->GetGroupMemberInfo()->group_id, "%s is now leader of the group.", new_leader->GetPlayer()->GetName());
  3306. }
  3307. }
  3308. }
  3309. else
  3310. client->SimpleMessage(CHANNEL_COMMANDS, "Unable to find the given player.");
  3311. }
  3312. else if (cmdTarget && cmdTarget->IsPlayer() && ((Player*)cmdTarget)->GetGroupMemberInfo() && ((Player*)cmdTarget)->GetGroupMemberInfo()->group_id == client->GetPlayer()->GetGroupMemberInfo()->group_id) {
  3313. if(client->GetPlayer()->IsGroupMember((Player*)cmdTarget) && world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, (Entity*)cmdTarget)) {
  3314. world.GetGroupManager()->GroupMessage(client->GetPlayer()->GetGroupMemberInfo()->group_id, "%s is now leader of the group.", cmdTarget->GetName());
  3315. }
  3316. }
  3317. else
  3318. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to change group leader.");
  3319. break;
  3320. }
  3321. case COMMAND_GROUP_ACCEPT_INVITE: {
  3322. int8 result = 3;
  3323. std::string leader = world.GetGroupManager()->HasPendingInvite(client->GetPlayer());
  3324. std::string playerName(client->GetPlayer()->GetName());
  3325. Client* leader_client = client->GetCurrentZone()->GetClientByName((char*)leader.c_str());
  3326. bool group_existed = false;
  3327. if(leader_client && leader_client->GetPlayer()->GetGroupMemberInfo()) {
  3328. group_existed = true;
  3329. }
  3330. if(client->GetPlayer()->GetGroupMemberInfo() && client->GetPlayer()->GetGroupMemberInfo()->leader) {
  3331. int8 raid_result = world.GetGroupManager()->AcceptRaidInvite(std::string(client->GetPlayer()->GetName()), client->GetPlayer()->GetGroupMemberInfo()->group_id);
  3332. if(raid_result == 1) {
  3333. GroupOptions options;
  3334. if(world.GetGroupManager()->GetDefaultGroupOptions(client->GetPlayer()->GetGroupMemberInfo()->group_id, &options)) {
  3335. std::vector<int32> raidGroups;
  3336. world.GetGroupManager()->GetRaidGroups(client->GetPlayer()->GetGroupMemberInfo()->group_id, &raidGroups);
  3337. peer_manager.sendPeersNewGroupRequest("", 0, client->GetPlayer()->GetGroupMemberInfo()->group_id, "", "", &options, "", &raidGroups, true);
  3338. }
  3339. world.GetGroupManager()->ClearGroupRaidLooterFlag(client->GetPlayer()->GetGroupMemberInfo()->group_id);
  3340. world.GetGroupManager()->SendGroupUpdate(client->GetPlayer()->GetGroupMemberInfo()->group_id);
  3341. break;
  3342. }
  3343. }
  3344. if(net.is_primary) {
  3345. int32 group_id = 0;
  3346. result = world.GetGroupManager()->AcceptInvite(client->GetPlayer(), &group_id, false);
  3347. client->HandleGroupAcceptResponse(result);
  3348. if(result == 0) {
  3349. GroupOptions options;
  3350. if(leader_client) {
  3351. if(!group_existed) {
  3352. leader_client->SetGroupOptionsReference(&options);
  3353. peer_manager.sendPeersNewGroupRequest("", 0, group_id, leader, playerName, &options);
  3354. }
  3355. world.GetGroupManager()->AddGroupMember(group_id, leader_client->GetPlayer(), true);
  3356. world.GetGroupManager()->GroupMessage(leader_client->GetPlayer()->GetGroupMemberInfo()->group_id, "%s has joined the group.", playerName.c_str());
  3357. world.GetGroupManager()->AddGroupMember(leader_client->GetPlayer()->GetGroupMemberInfo()->group_id, client->GetPlayer());
  3358. }
  3359. }
  3360. }
  3361. else {
  3362. if(leader.size() < 1) {
  3363. client->HandleGroupAcceptResponse(1);
  3364. }
  3365. else {
  3366. Client* leader_client = client->GetCurrentZone()->GetClientByName((char*)leader.c_str());
  3367. GroupOptions options;
  3368. if(leader_client) {
  3369. leader_client->SetGroupOptionsReference(&options);
  3370. world.GetGroupManager()->AddInvite(leader_client->GetPlayer(), client->GetPlayer());
  3371. peer_manager.sendPrimaryNewGroupRequest(leader, playerName, client->GetPlayer()->GetID(), &options);
  3372. }
  3373. else {
  3374. client->HandleGroupAcceptResponse(2);
  3375. }
  3376. }
  3377. }
  3378. break;
  3379. }
  3380. case COMMAND_GROUP_DECLINE_INVITE: {
  3381. world.GetGroupManager()->DeclineInvite(client->GetPlayer()); // TODO: Add message to leader
  3382. break;
  3383. }
  3384. case COMMAND_SUMMON:{
  3385. char* search_name = 0;
  3386. if(sep && sep->arg[0][0])
  3387. search_name = sep->arg[0];
  3388. if(!search_name && !cmdTarget){
  3389. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /summon [name]");
  3390. 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.");
  3391. }
  3392. else{
  3393. if(!client->Summon(search_name))
  3394. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  3395. }
  3396. break;
  3397. }
  3398. case COMMAND_GOTO:{
  3399. const char* search_name = 0;
  3400. if(sep && sep->arg[0][0])
  3401. search_name = sep->argplus[0];
  3402. if(!search_name && !cmdTarget){
  3403. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /goto [name]");
  3404. 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.");
  3405. }
  3406. else{
  3407. if(!client->GotoSpawn(search_name))
  3408. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  3409. }
  3410. break;
  3411. }
  3412. case COMMAND_MOVE:{
  3413. bool success = false;
  3414. try{
  3415. if(sep && sep->arg[2][0] && sep->IsNumber(0) && sep->IsNumber(1) && sep->IsNumber(2)){
  3416. EQ2Packet* app = client->GetPlayer()->Move(atof(sep->arg[0]), atof(sep->arg[1]), atof(sep->arg[2]), client->GetVersion());
  3417. if(app){
  3418. client->QueuePacket(app);
  3419. success = true;
  3420. }
  3421. }
  3422. }
  3423. catch(...){}
  3424. if(!success){
  3425. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /move x y z");
  3426. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Moves the client to the given coordinates.");
  3427. }
  3428. break;
  3429. }
  3430. case COMMAND_SETTIME:{
  3431. if(sep && sep->arg[0]){
  3432. world.MWorldTime.writelock(__FUNCTION__, __LINE__);
  3433. sscanf (sep->arg[0], "%d:%d", &world.GetWorldTimeStruct()->hour, &world.GetWorldTimeStruct()->minute);
  3434. if(sep->arg[1] && sep->IsNumber(1))
  3435. world.GetWorldTimeStruct()->month = atoi(sep->arg[1]) - 1; //zero based indexes
  3436. if(sep->arg[2] && sep->IsNumber(2))
  3437. world.GetWorldTimeStruct()->day = atoi(sep->arg[2]) - 1; //zero based indexes
  3438. if(sep->arg[3] && sep->IsNumber(3))
  3439. world.GetWorldTimeStruct()->year = atoi(sep->arg[3]);
  3440. world.MWorldTime.releasewritelock(__FUNCTION__, __LINE__);
  3441. client->GetCurrentZone()->SendTimeUpdateToAllClients();
  3442. }
  3443. else{
  3444. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /settime [hour:minute] (month) (day) (year)");
  3445. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Example: /settime 8:30");
  3446. }
  3447. break;
  3448. }
  3449. case COMMAND_VERSION:{
  3450. client->Message(CHANNEL_COLOR_YELLOW,"%s %s", EQ2EMU_MODULE, CURRENT_VERSION);
  3451. client->Message(CHANNEL_COLOR_YELLOW,"Last Compiled on %s %s", COMPILE_DATE, COMPILE_TIME);
  3452. auto [days, hours, minutes, seconds] = convertTimestampDuration((getCurrentTimestamp() - world.world_uptime));
  3453. client->Message(CHANNEL_COLOR_YELLOW,"Uptime %u day(s), %u hour(s), %u minute(s), %u second(s).", days, hours, minutes, seconds);
  3454. break;
  3455. }
  3456. case COMMAND_ZONE:{
  3457. int32 instanceID = 0;
  3458. string zone;
  3459. int32 zone_id = 0;
  3460. bool listSearch = false;
  3461. bool isInstance = false;
  3462. bool notZoningCommand = false;
  3463. ZoneServer* zsZone = 0;
  3464. ZoneChangeDetails zone_details;
  3465. if(sep && sep->arg[0][0])
  3466. {
  3467. if(strncasecmp(sep->arg[0], "list", 4) == 0)
  3468. listSearch = true;
  3469. else if(strncasecmp(sep->arg[0], "active", 6) == 0)
  3470. {
  3471. zone_list.SendZoneList(client);
  3472. notZoningCommand = true;
  3473. break;
  3474. }
  3475. else if(strncasecmp(sep->arg[0], "instance", 6) == 0)
  3476. {
  3477. if(sep->IsNumber(1))
  3478. instanceID = atol(sep->arg[1]);
  3479. }
  3480. else if(strncasecmp(sep->arg[0], "lock", 4) == 0)
  3481. {
  3482. PrintSep(sep, "ZONE LOCK");
  3483. if(sep->IsNumber(1)) {
  3484. if(zone_list.GetZone(&zone_details, atoul(sep->arg[1]), "", false, false, false, false)) {
  3485. zsZone = (ZoneServer*)zone_details.zonePtr;
  3486. }
  3487. }
  3488. else {
  3489. if(zone_list.GetZone(&zone_details, 0, std::string(sep->arg[1]), false, false, false, false)) {
  3490. zsZone = (ZoneServer*)zone_details.zonePtr;
  3491. }
  3492. }
  3493. if( zsZone )
  3494. {
  3495. zsZone->SetZoneLockState(true);
  3496. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now locked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  3497. }
  3498. else
  3499. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be locked.", sep->arg[1]);
  3500. notZoningCommand = true;
  3501. break;
  3502. }
  3503. else if(strncasecmp(sep->arg[0], "unlock", 6) == 0)
  3504. {
  3505. PrintSep(sep, "ZONE UNLOCK");
  3506. if(sep->IsNumber(1)) {
  3507. if(zone_list.GetZone(&zone_details, atoul(sep->arg[1]), "", false, false, false, false)) {
  3508. zsZone = (ZoneServer*)zone_details.zonePtr;
  3509. }
  3510. }
  3511. else {
  3512. if(zone_list.GetZone(&zone_details, 0, std::string(sep->arg[1]), false, false, false, false)) {
  3513. zsZone = (ZoneServer*)zone_details.zonePtr;
  3514. }
  3515. }
  3516. if( zsZone )
  3517. {
  3518. zsZone->SetZoneLockState(false);
  3519. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now unlocked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  3520. }
  3521. else
  3522. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be unlocked.", sep->arg[1]);
  3523. notZoningCommand = true;
  3524. break;
  3525. }
  3526. else
  3527. {
  3528. if(sep->IsNumber(0))
  3529. {
  3530. zone_id = atoul(sep->arg[0]);
  3531. string zonename = database.GetZoneName(zone_id);
  3532. if(zonename.length() > 0)
  3533. zone = zonename;
  3534. }
  3535. else
  3536. zone = sep->arg[0];
  3537. }
  3538. if(instanceID > 0)
  3539. {
  3540. if(zone_list.GetZoneByInstance(&zone_details, instanceID, 0, true)) {
  3541. instanceID = zone_details.instanceId;
  3542. zone = zone_details.zoneName;
  3543. zone_id = zone_details.zoneId;
  3544. }
  3545. isInstance = true;
  3546. }
  3547. }
  3548. if(!listSearch)
  3549. {
  3550. if(zone.length() == 0)
  3551. client->Message(CHANNEL_COLOR_RED, "Error: Invalid Zone");
  3552. else if(instanceID != client->GetCurrentZone()->GetInstanceID() ||
  3553. zone_id != client->GetCurrentZone()->GetZoneID())
  3554. {
  3555. const char* zonestr = zone.c_str();
  3556. if(database.VerifyZone(zonestr))
  3557. {
  3558. if(client->CheckZoneAccess(zonestr))
  3559. {
  3560. client->Message(CHANNEL_COLOR_YELLOW,"Zoning to %s...", zonestr);
  3561. if(isInstance)
  3562. client->Zone(&zone_details,(ZoneServer*)zone_details.zonePtr,true,false);
  3563. else
  3564. client->Zone(zonestr);
  3565. }
  3566. }
  3567. else
  3568. client->Message(CHANNEL_COLOR_RED, "Error: Zone '%s' not found. To get a list type /zone list", zonestr);
  3569. }
  3570. else
  3571. client->Message(CHANNEL_COLOR_RED, "Error: You are already in that zone!");
  3572. }
  3573. else
  3574. {
  3575. const char* name = 0;
  3576. if(sep && sep->arg[1][0])
  3577. {
  3578. map<int32, string>* zone_names;
  3579. name = sep->argplus[1];
  3580. sint16 status = client->GetAdminStatus();
  3581. if( status > 0 )
  3582. {
  3583. client->SimpleMessage(CHANNEL_COLOR_RED, "ADMIN MODE");
  3584. zone_names = database.GetZoneList(name, true);
  3585. }
  3586. else
  3587. zone_names = database.GetZoneList(name);
  3588. if(!zone_names)
  3589. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No zones found.");
  3590. else
  3591. {
  3592. map<int32, string>::iterator itr;
  3593. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  3594. for(itr = zone_names->begin(); itr != zone_names->end(); itr++)
  3595. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  3596. safe_delete(zone_names);
  3597. }
  3598. }
  3599. else
  3600. {
  3601. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone [zone name]");
  3602. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone list [partial zone name]");
  3603. }
  3604. }
  3605. break;
  3606. }
  3607. case COMMAND_USE: {
  3608. Spawn* target = cmdTarget;
  3609. if (target && target->IsWidget())
  3610. ((Widget*)target)->HandleUse(client, "use");
  3611. break;
  3612. }
  3613. case COMMAND_OPEN: {
  3614. Spawn* target = cmdTarget;
  3615. if (target && target->IsWidget())
  3616. ((Widget*)target)->HandleUse(client, "Open", WIDGET_TYPE_DOOR);
  3617. break;
  3618. }
  3619. case COMMAND_CASTSPELL: {
  3620. if (sep && sep->arg[0] && sep->IsNumber(0))
  3621. {
  3622. int8 tier = 1;
  3623. if (sep->arg[1] && sep->IsNumber(1))
  3624. tier = atoul(sep->arg[1]);
  3625. int8 self = 1;
  3626. if (sep->arg[1] && sep->IsNumber(2))
  3627. {
  3628. self = atoul(sep->arg[2]);
  3629. if(self != 1 && !cmdTarget->IsEntity())
  3630. {
  3631. client->Message(CHANNEL_COLOR_RED, "Target is not an entity required to cast non-self spell.");
  3632. self = 1;
  3633. }
  3634. }
  3635. int32 spellid = atoul(sep->arg[0]);
  3636. Spell* spell = master_spell_list.GetSpell(spellid, tier);
  3637. if (spell)
  3638. {
  3639. client->Message(CHANNEL_COLOR_RED, "Casting spell %u.", spellid);
  3640. SpellProcess* spellProcess = 0;
  3641. // Get the current zones spell process
  3642. spellProcess = client->GetCurrentZone()->GetSpellProcess();
  3643. spellProcess->CastInstant(spell, (!cmdTarget || self == 1) ? (Entity*)client->GetPlayer() : (Entity*)cmdTarget, (cmdTarget && cmdTarget->IsEntity()) ? (Entity*)cmdTarget : (Entity*)client->GetPlayer());
  3644. }
  3645. else
  3646. {
  3647. client->Message(CHANNEL_COLOR_RED, "Could not find spell %u.",spellid);
  3648. }
  3649. }
  3650. else if (sep && sep->arg[0])
  3651. {
  3652. database.FindSpell(client, (char*)sep->argplus[0]);
  3653. }
  3654. else
  3655. {
  3656. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellid] (tier=1) - Cast Spell with specified spell id, tier is optional, default of 1.");
  3657. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellname] - Find spells wildcard match with a partial spell name");
  3658. }
  3659. break;
  3660. }
  3661. case COMMAND_KNOWLEDGEWINDOWSORT: {
  3662. if (sep && (client->GetVersion() <= 561 && sep->GetArgNumber() == 3) || sep->GetArgNumber() == 4)
  3663. {
  3664. int32 book = atoul(sep->arg[0]); // 0 - spells, 1 - combat, 2 - abilities, 3 - tradeskill
  3665. // cannot sort the ability book in this client it is greyed out
  3666. if (client->GetVersion() <= 561 && book == SPELL_BOOK_TYPE_ABILITY)
  3667. break;
  3668. int32 sort_by = atoul(sep->arg[1]); // 0 - alpha, 1 - level, 2 - category
  3669. int32 order = atoul(sep->arg[2]); // 0 - ascending, 1 - descending
  3670. int32 pattern = atoul(sep->arg[3]); // 0 - zigzag, 1 - down, 2 - across
  3671. int32 maxlvlonly = 0;
  3672. if(client->GetVersion() > 561 && sep->arg[4][0]) {
  3673. maxlvlonly = atoul(sep->arg[4]); // checkbox for newer clients
  3674. }
  3675. client->GetPlayer()->ResortSpellBook(sort_by, order, pattern, maxlvlonly, book);
  3676. ClientPacketFunctions::SendSkillSlotMappings(client);
  3677. }
  3678. else
  3679. {
  3680. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /knowledgewindow_sort [book] [sort_by] [order] [pattern]");
  3681. }
  3682. break;
  3683. }
  3684. case COMMAND_MOVE_ITEM:
  3685. {
  3686. int32 id = 0;
  3687. if (sep && sep->IsNumber(0))
  3688. id = atoul(sep->arg[0]);
  3689. Spawn* spawn = 0;
  3690. if (id == 0)
  3691. {
  3692. spawn = cmdTarget;
  3693. }
  3694. else
  3695. spawn = client->GetCurrentZone()->GetSpawnFromUniqueItemID(id);
  3696. if (!spawn || !client->HasOwnerOrEditAccess() || !spawn->GetPickupItemID())
  3697. break;
  3698. Item* item = master_item_list.GetItem(spawn->GetPickupItemID());
  3699. client->SendMoveObjectMode(spawn, (item && item->houseitem_info) ? item->houseitem_info->house_location : 0);
  3700. break;
  3701. }
  3702. case COMMAND_PICKUP:
  3703. {
  3704. int32 id = 0;
  3705. if (sep && sep->IsNumber(0))
  3706. id = atoul(sep->arg[0]);
  3707. Spawn* spawn = 0;
  3708. if (id == 0)
  3709. {
  3710. spawn = cmdTarget;
  3711. }
  3712. else
  3713. spawn = client->GetCurrentZone()->GetSpawnFromUniqueItemID(id);
  3714. if (!spawn || !client->HasOwnerOrEditAccess() || !spawn->GetPickupItemID())
  3715. break;
  3716. if(client->AddItem(spawn->GetPickupItemID(), 1)) {
  3717. Query query;
  3718. 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());
  3719. if (database.RemoveSpawnFromSpawnLocation(spawn)) {
  3720. client->GetCurrentZone()->RemoveSpawn(spawn, true, true, true, true, true);
  3721. }
  3722. // we had a UI Window displayed, update the house items
  3723. if ( id > 0 )
  3724. client->GetCurrentZone()->SendHouseItems(client);
  3725. }
  3726. break;
  3727. }
  3728. case COMMAND_HOUSE_DEPOSIT:
  3729. {
  3730. PrintSep(sep, "COMMAND_HOUSE_DEPOSIT");
  3731. // arg0 = spawn_id for DoF, could also be house_id for newer clients
  3732. // arg1 = coin (in copper)
  3733. // arg2 = status? (not implemented yet)
  3734. PlayerHouse* ph = nullptr;
  3735. int32 spawn_id = 0;
  3736. if(sep && sep->arg[0]) {
  3737. spawn_id = atoul(sep->arg[0]);
  3738. ph = world.GetPlayerHouse(client, spawn_id, client->GetVersion() > 561 ? spawn_id : 0, nullptr);
  3739. }
  3740. if(!ph) {
  3741. ph = world.GetPlayerHouseByInstanceID(client->GetCurrentZone()->GetInstanceID());
  3742. }
  3743. if (ph && sep && sep->IsNumber(1))
  3744. {
  3745. int64 outValCoin = strtoull(sep->arg[1], NULL, 0);
  3746. int32 outValStatus = 0;
  3747. if(sep->IsNumber(2))
  3748. {
  3749. outValStatus = strtoull(sep->arg[2], NULL, 0);
  3750. if(outValStatus > client->GetPlayer()->GetInfoStruct()->get_status_points())
  3751. outValStatus = 0; // cheat check
  3752. }
  3753. if ((!outValCoin && outValStatus) || client->GetPlayer()->RemoveCoins(outValCoin))
  3754. {
  3755. if(outValStatus)
  3756. client->GetPlayer()->GetInfoStruct()->subtract_status_points(outValStatus);
  3757. char query[256];
  3758. map<string,Deposit>::iterator itr = ph->depositsMap.find(string(client->GetPlayer()->GetName()));
  3759. if (itr != ph->depositsMap.end())
  3760. {
  3761. 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());
  3762. }
  3763. else
  3764. 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);
  3765. if (database.RunQuery(query, strnlen(query, 256)))
  3766. {
  3767. ph->escrow_coins += outValCoin;
  3768. ph->escrow_status += outValStatus;
  3769. database.UpdateHouseEscrow(ph->house_id, ph->instance_id, ph->escrow_coins, ph->escrow_status);
  3770. database.LoadDeposits(ph);
  3771. client->PlaySound("coin_cha_ching");
  3772. HouseZone* hz = world.GetHouseZone(ph->house_id);
  3773. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetVersion() <= 561 ? spawn_id : client->GetPlayer()->GetID());
  3774. }
  3775. else
  3776. {
  3777. if(outValCoin)
  3778. client->GetPlayer()->AddCoins(outValCoin);
  3779. if(outValStatus)
  3780. client->GetPlayer()->GetInfoStruct()->add_status_points(outValStatus);
  3781. client->SimpleMessage(CHANNEL_COLOR_RED, "Deposit failed!");
  3782. }
  3783. }
  3784. }
  3785. break;
  3786. }
  3787. case COMMAND_HOUSE:
  3788. {
  3789. int32 spawn_id = 0;
  3790. if (sep && sep->IsNumber(0))
  3791. {
  3792. PlayerHouse* ph = nullptr;
  3793. if(!ph && sep && sep->arg[0]) {
  3794. spawn_id = atoul(sep->arg[0]);
  3795. ph = world.GetPlayerHouse(client, spawn_id, spawn_id, nullptr);
  3796. }
  3797. HouseZone* hz = 0;
  3798. if (ph)
  3799. hz = world.GetHouseZone(ph->house_id);
  3800. // there is a arg[1] that is true/false, but not sure what it is for investigate more later
  3801. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetVersion() <= 561 ? spawn_id : client->GetPlayer()->GetID());
  3802. }
  3803. else if (client->GetCurrentZone()->GetInstanceType() != 0)
  3804. {
  3805. // inside a house or something? Send the access window
  3806. PlayerHouse* ph = world.GetPlayerHouseByInstanceID(client->GetCurrentZone()->GetInstanceID());
  3807. HouseZone* hz = 0;
  3808. if ( ph )
  3809. hz = world.GetHouseZone(ph->house_id);
  3810. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetVersion() <= 561 ? spawn_id : client->GetPlayer()->GetID());
  3811. client->GetCurrentZone()->SendHouseItems(client);
  3812. }
  3813. break;
  3814. }
  3815. case COMMAND_HOUSE_UI:
  3816. {
  3817. if (sep && sep->IsNumber(0) && client->GetCurrentZone()->GetInstanceType() == Instance_Type::NONE)
  3818. {
  3819. int32 unique_id = atoi(sep->arg[0]);
  3820. PlayerHouse* ph = world.GetPlayerHouseByUniqueID(unique_id);
  3821. HouseZone* hz = 0;
  3822. if ( ph )
  3823. hz = world.GetHouseZone(ph->house_id);
  3824. // there is a arg[1] that is true/false, but not sure what it is for investigate more later
  3825. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  3826. }
  3827. break;
  3828. }
  3829. case COMMAND_PLACE_HOUSE_ITEM: {
  3830. if (sep && sep->IsNumber(0))
  3831. {
  3832. int32 uniqueid = atoi(sep->arg[0]);
  3833. Item* item = client->GetPlayer()->item_list.GetItemFromUniqueID(uniqueid);
  3834. //Item* item = player->GetEquipmentList()->GetItem(slot);
  3835. if (item && item->IsHouseItem())
  3836. {
  3837. if (!client->HasOwnerOrEditAccess())
  3838. {
  3839. client->SimpleMessage(CHANNEL_COLOR_RED, "This is not your home!");
  3840. break;
  3841. }
  3842. else if (!item->generic_info.appearance_id)
  3843. {
  3844. 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);
  3845. break;
  3846. }
  3847. else if(item->CheckFlag2(HOUSE_LORE) && client->GetCurrentZone()->HouseItemSpawnExists(item->details.item_id)) {
  3848. client->Message(CHANNEL_COLOR_RED, "Item %s is house lore and you cannot place another.", item->name.c_str());
  3849. break;
  3850. }
  3851. if (client->GetTempPlacementSpawn())
  3852. {
  3853. Spawn* tmp = client->GetTempPlacementSpawn();
  3854. client->GetCurrentZone()->RemoveSpawn(tmp, true, true, true, true, true);
  3855. client->SetTempPlacementSpawn(nullptr);
  3856. }
  3857. Object* obj = new Object();
  3858. Spawn* spawn = (Spawn*)obj;
  3859. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3860. strcpy(spawn->appearance.name, "temp");
  3861. spawn->SetX(client->GetPlayer()->GetX());
  3862. spawn->SetY(client->GetPlayer()->GetY());
  3863. spawn->SetZ(client->GetPlayer()->GetZ());
  3864. spawn->appearance.pos.collision_radius = 32;
  3865. spawn->SetHeading(client->GetPlayer()->GetHeading());
  3866. spawn->SetSpawnOrigX(spawn->GetX());
  3867. spawn->SetSpawnOrigY(spawn->GetY());
  3868. spawn->SetSpawnOrigZ(spawn->GetZ());
  3869. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  3870. spawn->appearance.targetable = 1;
  3871. spawn->appearance.activity_status = ACTIVITY_STATUS_SOLID;
  3872. spawn->appearance.race = item && item->generic_info.appearance_id ? item->generic_info.appearance_id : 1472;
  3873. spawn->SetModelType(item && item->generic_info.appearance_id ? item->generic_info.appearance_id : 1472);
  3874. spawn->SetLocation(client->GetPlayer()->GetLocation());
  3875. spawn->SetZone(client->GetCurrentZone());
  3876. client->SetTempPlacementSpawn(spawn);
  3877. client->SetPlacementUniqueItemID(uniqueid);
  3878. client->GetCurrentZone()->AddSpawn(spawn);
  3879. }
  3880. }
  3881. break;
  3882. }
  3883. case COMMAND_GM:
  3884. {
  3885. if (sep && sep->arg[0] && sep->arg[1])
  3886. {
  3887. bool onOff = (strcmp(sep->arg[1], "on") == 0);
  3888. if (strcmp(sep->arg[0], "vision") == 0)
  3889. {
  3890. client->GetPlayer()->SetGMVision(onOff);
  3891. #if defined(__GNUC__)
  3892. database.insertCharacterProperty(client, CHAR_PROPERTY_GMVISION, (onOff) ? (char*)"1" : (char*)"0");
  3893. #else
  3894. database.insertCharacterProperty(client, CHAR_PROPERTY_GMVISION, (onOff) ? "1" : "0");
  3895. #endif
  3896. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3897. if (onOff)
  3898. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Vision Enabled!");
  3899. else
  3900. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Vision Disabled!");
  3901. }
  3902. else if (strcmp(sep->arg[0], "tag") == 0)
  3903. {
  3904. int32 value = 0;
  3905. int16 tag_icon = 0;
  3906. // groundspawn has special exception -1 argument so it needs to be handled here
  3907. if(sep->arg[2] && sep->arg[3] && ((tag_icon = atoul(sep->arg[3])) > 0) || (strncasecmp(sep->arg[1], "groundspawn", 11) == 0)) {
  3908. value = atoul(sep->arg[2]);
  3909. if(strncasecmp(sep->arg[1], "faction", 7) == 0){
  3910. if(!value) {
  3911. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid faction id.");
  3912. break;
  3913. }
  3914. if(!tag_icon) {
  3915. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid tag icon id.");
  3916. break;
  3917. }
  3918. client->GetPlayer()->AddGMVisualFilter(GMTagFilterType::GMFILTERTYPE_FACTION, value, "", tag_icon);
  3919. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3920. client->Message(CHANNEL_COLOR_RED, "Adding faction id %u with tag icon %u.", value, tag_icon);
  3921. }
  3922. else if(strncasecmp(sep->arg[1], "spawngroup", 10) == 0){
  3923. if(value>0) {
  3924. value = 1;
  3925. }
  3926. if(!tag_icon) {
  3927. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid tag icon id.");
  3928. break;
  3929. }
  3930. client->GetPlayer()->AddGMVisualFilter(GMTagFilterType::GMFILTERTYPE_SPAWNGROUP, value, "", tag_icon);
  3931. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3932. client->Message(CHANNEL_COLOR_RED, "Adding spawn group tag \"%s\" with tag icon %u.", (value == 1) ? "on" : "off", tag_icon);
  3933. }
  3934. else if(strncasecmp(sep->arg[1], "race", 4 == 0)){
  3935. if(!value) {
  3936. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid race id.");
  3937. break;
  3938. }
  3939. if(!tag_icon) {
  3940. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid tag icon id.");
  3941. break;
  3942. }
  3943. client->GetPlayer()->AddGMVisualFilter(GMTagFilterType::GMFILTERTYPE_RACE, value, "", tag_icon);
  3944. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3945. client->Message(CHANNEL_COLOR_RED, "Adding race id %u with tag icon %u.", value, tag_icon);
  3946. }
  3947. else if(strncasecmp(sep->arg[1], "groundspawn", 11) == 0){
  3948. // one less argument value field not tag_icon for this one
  3949. if(!value) {
  3950. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid tag icon id.");
  3951. break;
  3952. }
  3953. client->GetPlayer()->AddGMVisualFilter(GMTagFilterType::GMFILTERTYPE_GROUNDSPAWN, 1, "", value);
  3954. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3955. client->Message(CHANNEL_COLOR_RED, "Adding groundspawns with tag icon %u.", value);
  3956. }
  3957. }
  3958. else {
  3959. if(strncasecmp(sep->arg[1], "clear", 5) == 0){
  3960. client->GetPlayer()->ClearGMVisualFilters();
  3961. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Tags Cleared!");
  3962. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3963. }
  3964. else {
  3965. client->SimpleMessage(CHANNEL_COLOR_RED, "GM Tagging Missing Arguments:");
  3966. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/gm tag [type] [value] [visual_icon_display]");
  3967. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/gm tag clear - Clears all GM visual tags");
  3968. client->SimpleMessage(CHANNEL_COLOR_RED, "Visual Type Options:");
  3969. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "type: faction, value: faction id of spawn(s)");
  3970. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "type: spawngroup, value: 1 to show grouped, 0 to show not grouped");
  3971. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "type: race, value: race id (either against base race or race id in spawn details)");
  3972. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "type: groundspawn, value: (not used)");
  3973. client->SimpleMessage(CHANNEL_COLOR_RED, "Visual Icon Options:");
  3974. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3975. "1 = skull, 2 = shield half dark blue / half light blue, 3 = purple? star, 4 = yellow sword, 5 = red X, 6 = green flame");
  3976. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3977. "7 = Number \"1\", 8 = Number \"2\", 9 = Number \"3\", 10 = Number \"4\", 11 = Number \"5\", 12 = Number \"6\"");
  3978. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3979. "25 = shield, 26 = green plus, 27 = crossed swords, 28 = bow with arrow in it, 29 = light blue lightning bolt");
  3980. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3981. "30 = bard instrument (hard to see), 31 = writ with shield, 32 = writ with green +, 33 = writ with crossed sword");
  3982. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3983. "34 = writ with bow, 35 = writ with light blue lightning bolt, 36 = same as 30, 37 = party with crossed sword, shield and lightning bolt");
  3984. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3985. "38 = shaking hands green background, 39 = shaking hands dark green background, unlocked keylock");
  3986. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3987. "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");
  3988. }
  3989. }
  3990. }
  3991. else if (strcmp(sep->arg[0], "regiondebug") == 0)
  3992. {
  3993. client->SetRegionDebug(onOff);
  3994. #if defined(__GNUC__)
  3995. database.insertCharacterProperty(client, CHAR_PROPERTY_REGIONDEBUG, (onOff) ? (char*)"1" : (char*)"0");
  3996. #else
  3997. database.insertCharacterProperty(client, CHAR_PROPERTY_REGIONDEBUG, (onOff) ? "1" : "0");
  3998. #endif
  3999. if (onOff)
  4000. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Region Debug Enabled!");
  4001. else
  4002. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Region Debug Disabled!");
  4003. }
  4004. else if (strcmp(sep->arg[0], "sight") == 0)
  4005. {
  4006. if(onOff && cmdTarget) {
  4007. client->SetPlayerPOVGhost(cmdTarget);
  4008. }
  4009. else
  4010. client->SetPlayerPOVGhost(nullptr);
  4011. }
  4012. else if (strcmp(sep->arg[0], "controleffects") == 0)
  4013. {
  4014. if(cmdTarget && cmdTarget->IsEntity()) {
  4015. ((Entity*)cmdTarget)->SendControlEffectDetailsToClient(client);
  4016. }
  4017. else {
  4018. client->GetPlayer()->SendControlEffectDetailsToClient(client);
  4019. }
  4020. }
  4021. else if (strcmp(sep->arg[0], "luadebug") == 0)
  4022. {
  4023. client->SetLuaDebugClient(onOff);
  4024. #if defined(__GNUC__)
  4025. database.insertCharacterProperty(client, CHAR_PROPERTY_LUADEBUG, (onOff) ? (char*)"1" : (char*)"0");
  4026. #else
  4027. database.insertCharacterProperty(client, CHAR_PROPERTY_LUADEBUG, (onOff) ? "1" : "0");
  4028. #endif
  4029. if (onOff)
  4030. {
  4031. if (lua_interface)
  4032. lua_interface->UpdateDebugClients(client);
  4033. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will now receive LUA error messages.");
  4034. }
  4035. else
  4036. {
  4037. if (lua_interface)
  4038. lua_interface->RemoveDebugClients(client);
  4039. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will no longer receive LUA error messages.");
  4040. }
  4041. }
  4042. }
  4043. break;
  4044. }
  4045. case COMMAND_ATTACK:
  4046. case COMMAND_AUTO_ATTACK:{
  4047. Command_AutoAttack(client, sep);
  4048. break;
  4049. }
  4050. case COMMAND_DEPOP:{
  4051. bool allow_respawns = false;
  4052. if(sep && sep->arg[0] && sep->IsNumber(0)){
  4053. if(atoi(sep->arg[0]) == 1)
  4054. allow_respawns = true;
  4055. }
  4056. client->GetCurrentZone()->Depop(allow_respawns);
  4057. break;
  4058. }
  4059. case COMMAND_REPOP:{
  4060. client->GetCurrentZone()->Depop(false, true);
  4061. break;
  4062. }
  4063. case COMMAND_BUYBACK:{
  4064. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  4065. // 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
  4066. int64 id = atoi64(sep->arg[0]);
  4067. // get the first int32, the item id
  4068. //int32 item_id = (int32)id;
  4069. // get the second int32, the unique id
  4070. int32 unique_id = (int32)(id>>32);
  4071. int8 quantity = atoi(sep->arg[1]);
  4072. if(quantity == 255)
  4073. quantity = 1;
  4074. client->BuyBack(unique_id, quantity);
  4075. }
  4076. break;
  4077. }
  4078. case COMMAND_MERCHANT_BUY:{
  4079. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  4080. int32 item_id = atoul(sep->arg[0]);
  4081. int8 quantity = atoi(sep->arg[1]);
  4082. client->BuyItem(item_id, quantity);
  4083. }
  4084. else
  4085. Command_SendMerchantWindow(client, sep);
  4086. break;
  4087. }
  4088. case COMMAND_MERCHANT_SELL:{
  4089. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  4090. // 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
  4091. int64 id = atoi64(sep->arg[0]);
  4092. // get the first int32, the item id
  4093. int32 item_id = (int32)id;
  4094. // get the second int32, the unique id
  4095. int32 unique_id = (int32)(id>>32);
  4096. int8 quantity = atoi(sep->arg[1]);
  4097. LogWrite(MERCHANT__DEBUG, 0, "Merchant", "Selling Item: Item Id = %ul, unique id = %ul, Quantity = %i", item_id, unique_id, quantity);
  4098. client->SellItem(item_id, quantity, unique_id);
  4099. }
  4100. break;
  4101. }
  4102. case COMMAND_MENDER_REPAIR: {
  4103. if (sep && sep->arg[0] && sep->IsNumber(0))
  4104. client->RepairItem(atoul(sep->arg[0]));
  4105. break;
  4106. }
  4107. case COMMAND_MENDER_REPAIR_ALL: {
  4108. client->RepairAllItems();
  4109. break;
  4110. }
  4111. case COMMAND_CANCEL_MERCHANT:{
  4112. client->SetMerchantTransaction(0);
  4113. break;
  4114. }
  4115. case COMMAND_START_MERCHANT:{
  4116. break;
  4117. }
  4118. case COMMAND_INVULNERABLE:{
  4119. sint8 val = -1;
  4120. if(sep && sep->arg[0] && sep->IsNumber(0)){
  4121. val = atoi(sep->arg[0]);
  4122. //devn00b: Fix for linux builds
  4123. #if defined(__GNUC__)
  4124. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? (char*) "1" : (char*) "0");
  4125. #else
  4126. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  4127. #endif
  4128. // database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  4129. client->GetPlayer()->SetInvulnerable(val==1);
  4130. if(client->GetPlayer()->GetInvulnerable())
  4131. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are now invulnerable!");
  4132. else
  4133. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are no longer invulnerable!");
  4134. }
  4135. if(val == -1)
  4136. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /invulnerable [0/1]");
  4137. break;
  4138. }
  4139. case COMMAND_REPAIR: {
  4140. Spawn* spawn = cmdTarget;
  4141. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR) {
  4142. client->SendHailCommand(spawn);
  4143. client->SetMerchantTransaction(spawn);
  4144. client->SendRepairList();
  4145. }
  4146. break;
  4147. }
  4148. case COMMAND_LOTTO: {
  4149. Spawn* spawn = cmdTarget;
  4150. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_LOTTO) {
  4151. client->SetMerchantTransaction(spawn);
  4152. client->ShowLottoWindow();
  4153. }
  4154. break;
  4155. }
  4156. case COMMAND_ACCEPT_REWARD:{
  4157. int32 unknown = 0;
  4158. int32 selectable_item_id = 0;
  4159. //Quest *quest = 0;
  4160. /* no idea what the first argument is for (faction maybe?)
  4161. if the reward has a selectable item reward, it's sent as the second argument
  4162. if neither of these are included in the reward, there is no sep
  4163. 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
  4164. only 1 quest or collection reward may be displayed at a time */
  4165. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  4166. unknown = atoul(sep->arg[0]);
  4167. selectable_item_id = atoul(sep->arg[1]);
  4168. }
  4169. /* 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
  4170. ** Otherwise it will likely be a DoF client scenario (pending item rewards, selectable item rewards) which is specifying an item id
  4171. ** 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
  4172. */
  4173. int32 item_id = 0;
  4174. if(sep && sep->arg[0][0] && sep->IsNumber(0))
  4175. item_id = atoul(sep->arg[0]);
  4176. bool collectedItems = client->GetPlayer()->AcceptQuestReward(item_id, selectable_item_id);
  4177. if (collectedItems) {
  4178. EQ2Packet* outapp = client->GetPlayer()->SendInventoryUpdate(client->GetVersion());
  4179. if (outapp)
  4180. client->QueuePacket(outapp);
  4181. }
  4182. else
  4183. LogWrite(COMMAND__ERROR, 0, "Command", "Error in COMMAND_ACCEPT_REWARD. No pending quest or collection reward was found (unknown=%u).", unknown);
  4184. break;
  4185. }
  4186. case COMMAND_BUY_FROM_BROKER:{
  4187. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  4188. int32 item_id = atoul(sep->arg[0]);
  4189. int16 quantity = atoul(sep->arg[1]);
  4190. Item* item = master_item_list.GetItem(item_id);
  4191. if(item && item->generic_info.max_charges > 1)
  4192. quantity = item->generic_info.max_charges;
  4193. client->AddItem(item_id, quantity, AddItemType::BUY_FROM_BROKER);
  4194. }
  4195. break;
  4196. }
  4197. case COMMAND_SEARCH_STORES_PAGE:{
  4198. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  4199. int32 page = atoul(sep->arg[0]);
  4200. client->SearchStore(page);
  4201. }
  4202. break;
  4203. }
  4204. case COMMAND_SEARCH_STORES:{
  4205. if(sep && sep->arg[0][0]){
  4206. const char* values = sep->argplus[0];
  4207. if(values){
  4208. LogWrite(ITEM__WARNING, 0, "Item", "SearchStores: %s", values);
  4209. map<string, string> str_values = TranslateBrokerRequest(values);
  4210. vector<Item*>* items = master_item_list.GetItems(str_values, client);
  4211. if(items){
  4212. client->SetItemSearch(items);
  4213. client->SearchStore(0);
  4214. }
  4215. }
  4216. }
  4217. break;
  4218. }
  4219. case COMMAND_LUADEBUG:{
  4220. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "start") == 0){
  4221. client->SetLuaDebugClient(true);
  4222. if(lua_interface)
  4223. lua_interface->UpdateDebugClients(client);
  4224. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will now receive LUA error messages.");
  4225. }
  4226. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "stop") == 0){
  4227. client->SetLuaDebugClient(false);
  4228. if(lua_interface)
  4229. lua_interface->RemoveDebugClients(client);
  4230. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will no longer receive LUA error messages.");
  4231. }
  4232. else{
  4233. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /luadebug {start | stop}");
  4234. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will allow you to receive lua debug messages normally seen only in the console.");
  4235. }
  4236. break;
  4237. }
  4238. case COMMAND_SPAWN_GROUP:
  4239. {
  4240. Spawn* target = cmdTarget;
  4241. if(target && target->IsPlayer() == false)
  4242. {
  4243. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "create") == 0)
  4244. {
  4245. if(target->GetSpawnLocationPlacementID() > 0)
  4246. {
  4247. if(sep->arg[1] && !sep->IsNumber(1) && strlen(sep->arg[1]) > 0)
  4248. {
  4249. int32 id = database.CreateSpawnGroup(target, sep->arg[1]);
  4250. if(id > 0)
  4251. client->Message(CHANNEL_COLOR_YELLOW, "Successfully created new spawn group with id: %u", id);
  4252. else
  4253. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error creating group, check console for details.");
  4254. target->SetSpawnGroupID(id);
  4255. target->AddSpawnToGroup(target);
  4256. }
  4257. else
  4258. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group create [name]");
  4259. }
  4260. else
  4261. 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.");
  4262. }
  4263. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "add") == 0)
  4264. {
  4265. if(sep->arg[1] && sep->IsNumber(1))
  4266. {
  4267. int32 group_id = atoul(sep->arg[1]);
  4268. Spawn* leader = client->GetCurrentZone()->GetSpawnGroup(group_id);
  4269. if(leader)
  4270. {
  4271. leader->AddSpawnToGroup(target);
  4272. target->SetSpawnGroupID(group_id);
  4273. if(database.SpawnGroupAddSpawn(target, group_id))
  4274. client->Message(CHANNEL_COLOR_YELLOW, "Successfully added '%s' to group id: %u", target->GetName(), group_id);
  4275. else
  4276. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error adding spawn to group, check console for details.");
  4277. }
  4278. else
  4279. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No spawns found in the current zone for that spawn group, be sure to use '/spawn group create' first!");
  4280. }
  4281. else
  4282. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group add [group id]");
  4283. }
  4284. else if(target->GetSpawnGroupID() == 0)
  4285. {
  4286. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That spawn is not in a group!");
  4287. }
  4288. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "remove") == 0)
  4289. {
  4290. int32 group_id = target->GetSpawnGroupID();
  4291. target->RemoveSpawnFromGroup();
  4292. if(database.SpawnGroupRemoveSpawn(target, group_id))
  4293. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed '%s' from group id: %u", target->GetName(), group_id);
  4294. else
  4295. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing spawn from group, check console for details.");
  4296. }
  4297. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "associate") == 0)
  4298. {
  4299. int32 group_id = target->GetSpawnGroupID();
  4300. if(sep->arg[1] && sep->IsNumber(1))
  4301. {
  4302. if(database.SpawnGroupAddAssociation(group_id, atoul(sep->arg[1])))
  4303. client->Message(CHANNEL_COLOR_YELLOW, "Successfully associated group id %u with group id %u", group_id, atoul(sep->arg[1]));
  4304. else
  4305. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error associating groups, check console for details.");
  4306. }
  4307. else
  4308. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Allows you to spawn only one associated group at once. Syntax: /spawn group associate [other group id]");
  4309. }
  4310. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "deassociate") == 0)
  4311. {
  4312. int32 group_id = target->GetSpawnGroupID();
  4313. if(sep->arg[1] && sep->IsNumber(1))
  4314. {
  4315. if(database.SpawnGroupRemoveAssociation(group_id, atoul(sep->arg[1])))
  4316. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed association between group id %u and group id %u", group_id, atoul(sep->arg[1]));
  4317. else
  4318. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing group associations, check console for details.");
  4319. }
  4320. else
  4321. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Removes previous group associations. Syntax: /spawn group deassociate [other group id]");
  4322. }
  4323. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "chance") == 0)
  4324. {
  4325. if(sep->arg[1] && sep->IsNumber(1))
  4326. {
  4327. if(database.SetGroupSpawnChance(target->GetSpawnGroupID(), atof(sep->arg[1])))
  4328. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set group spawn chance to %f for group id: %u", atof(sep->arg[1]), target->GetSpawnGroupID());
  4329. else
  4330. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error setting group spawn chance, check console for details.");
  4331. }
  4332. else
  4333. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group chance [group's spawn chance percentage]");
  4334. }
  4335. else
  4336. {
  4337. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command allows you to modify spawn groups.");
  4338. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group [create/add/remove/chance/associate/deassociate]");
  4339. }
  4340. }
  4341. else
  4342. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select a valid spawn to use this command.");
  4343. break;
  4344. }
  4345. case COMMAND_SPAWN_COMBINE:{
  4346. Spawn* spawn = cmdTarget;
  4347. float radius = 0;
  4348. bool failed = true;
  4349. if(spawn && !spawn->IsPlayer() && sep && sep->arg[0] && sep->arg[0][0]){
  4350. failed = false;
  4351. if(spawn->GetSpawnGroupID() > 0){
  4352. 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.");
  4353. }
  4354. else if(sep->IsNumber(0)){
  4355. radius = atof(sep->arg[0]);
  4356. client->CombineSpawns(radius, spawn);
  4357. }
  4358. else{
  4359. if(strncasecmp(sep->arg[0], "add", 3) == 0){
  4360. client->AddCombineSpawn(spawn);
  4361. }
  4362. else if(strncasecmp(sep->arg[0], "remove", 6) == 0){
  4363. client->RemoveCombineSpawn(spawn);
  4364. }
  4365. else if(strncasecmp(sep->arg[0], "save", 4) == 0){
  4366. const char* name = 0;
  4367. if(sep->arg[1] && sep->arg[1][0])
  4368. name = sep->argplus[1];
  4369. client->SaveCombineSpawns(name);
  4370. }
  4371. else
  4372. failed = true;
  4373. }
  4374. }
  4375. if(failed){
  4376. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command combines several spawns into a single spawn group.");
  4377. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn combine [radius/add/remove/save]");
  4378. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Ex: /spawn combine 1, /spawn combine save (spawn group name)");
  4379. }
  4380. break;
  4381. }
  4382. case COMMAND_SPAWN_CREATE:{
  4383. Spawn* spawn = 0;
  4384. if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "object", 6) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  4385. spawn = new Object();
  4386. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  4387. }
  4388. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "groundspawn", 11) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  4389. spawn = new GroundSpawn();
  4390. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  4391. }
  4392. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "sign", 4) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  4393. spawn = new Sign();
  4394. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  4395. }
  4396. else if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "npc", 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  4397. spawn = new NPC();
  4398. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  4399. spawn->appearance.pos.collision_radius = 32;
  4400. spawn->secondary_command_list_id = 0;
  4401. spawn->primary_command_list_id = 0;
  4402. spawn->appearance.display_name = 1;
  4403. spawn->appearance.show_level = 1;
  4404. spawn->appearance.attackable = 1;
  4405. }
  4406. else{
  4407. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn create [spawn type] [race type] [class type] [level] [name] (difficulty) (size)");
  4408. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are required except difficulty and size. Valid types are Object, NPC, Sign, or GroundSpawn");
  4409. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn create npc 203 1 50 'Lady Vox' 1 32");
  4410. break;
  4411. }
  4412. spawn->SetID(Spawn::NextID());
  4413. spawn->SetX(client->GetPlayer()->GetX());
  4414. spawn->SetY(client->GetPlayer()->GetY());
  4415. spawn->SetZ(client->GetPlayer()->GetZ());
  4416. spawn->SetHeading(client->GetPlayer()->GetHeading());
  4417. spawn->SetSpawnOrigX(spawn->GetX());
  4418. spawn->SetSpawnOrigY(spawn->GetY());
  4419. spawn->SetSpawnOrigZ(spawn->GetZ());
  4420. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  4421. if(spawn->IsSign())
  4422. {
  4423. ((Sign*)spawn)->SetSignType(SIGN_TYPE_GENERIC);
  4424. ((Sign*)spawn)->SetSignDistance(20.0f);
  4425. ((Sign*)spawn)->SetIncludeLocation(1);
  4426. ((Sign*)spawn)->SetIncludeHeading(1);
  4427. ((Sign*)spawn)->SetInitialState(1);
  4428. ((Sign*)spawn)->SetSignTitle(sep->arg[4]);
  4429. ((Sign*)spawn)->SetActivityStatus(64);
  4430. spawn->appearance.race = 0;
  4431. spawn->SetLevel(0);
  4432. spawn->SetHP(0);
  4433. spawn->SetTotalHP(0);
  4434. spawn->SetPower(0);
  4435. spawn->SetTotalPower(0);
  4436. spawn->SetDifficulty(0);
  4437. spawn->SetTargetable(0);
  4438. spawn->SetSogaModelType(0);
  4439. spawn->SetCollisionRadius(19);
  4440. ((Sign*)spawn)->SetWidgetX(client->GetPlayer()->GetX());
  4441. ((Sign*)spawn)->SetWidgetY(client->GetPlayer()->GetY());
  4442. ((Sign*)spawn)->SetWidgetZ(client->GetPlayer()->GetZ());
  4443. spawn->SetLocation(client->GetPlayer()->GetLocation());
  4444. spawn->appearance.model_type = atoul(sep->arg[1]);
  4445. }
  4446. else
  4447. {
  4448. spawn->appearance.targetable = 1;
  4449. spawn->appearance.race = 255;
  4450. spawn->SetLocation(client->GetPlayer()->GetLocation());
  4451. spawn->SetModelType(atoi(sep->arg[1]));
  4452. spawn->SetAdventureClass(atoi(sep->arg[2]));
  4453. spawn->SetLevel(atoi(sep->arg[3]));
  4454. spawn->SetName(sep->arg[4]);
  4455. if(sep->arg[5][0] && sep->IsNumber(5))
  4456. spawn->SetDifficulty(atoi(sep->arg[5]));
  4457. if(sep->arg[6][0] && sep->IsNumber(6))
  4458. spawn->size = atoi(sep->arg[6]);
  4459. if(spawn->GetTotalHP() == 0){
  4460. spawn->SetTotalHP(25*spawn->GetLevel() + 1);
  4461. spawn->SetHP(25*spawn->GetLevel() + 1);
  4462. }
  4463. if(spawn->GetTotalPower() == 0){
  4464. spawn->SetTotalPower(25*spawn->GetLevel() + 1);
  4465. spawn->SetPower(25*spawn->GetLevel() + 1);
  4466. }
  4467. }
  4468. client->GetCurrentZone()->AddSpawn(spawn);
  4469. break;
  4470. }
  4471. case COMMAND_SPAWN_EQUIPMENT:{
  4472. Spawn* spawn = cmdTarget;
  4473. if(spawn && sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1) && spawn->IsEntity()){
  4474. int8 slot = atoi(sep->arg[0]);
  4475. int16 type = atoi(sep->arg[1]);
  4476. int8 red = 0;
  4477. int8 green = 0;
  4478. int8 blue = 0;
  4479. int8 h_red = 0;
  4480. int8 h_green = 0;
  4481. int8 h_blue = 0;
  4482. if(sep->arg[2])
  4483. red = atoi(sep->arg[2]);
  4484. if(sep->arg[3])
  4485. green = atoi(sep->arg[3]);
  4486. if(sep->arg[4])
  4487. blue = atoi(sep->arg[4]);
  4488. if(sep->arg[5])
  4489. h_red = atoi(sep->arg[5]);
  4490. if(sep->arg[6])
  4491. h_green = atoi(sep->arg[6]);
  4492. if(sep->arg[7])
  4493. h_blue = atoi(sep->arg[7]);
  4494. ((Entity*)spawn)->SetEquipment(slot, type, red, green, blue, h_red, h_green, h_blue);
  4495. database.SaveNPCAppearanceEquipment(spawn->GetDatabaseID() , slot, type, red, green, blue, h_red, h_green, h_blue);
  4496. }
  4497. else{
  4498. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn equipment [slot] [appearance id] (red) (green) (blue) (highlight red) (hgreen) (hblue)");
  4499. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn's equipment. ");
  4500. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Slot is 0-24, Appearance ID from appearances table, Colors are 0-255");
  4501. }
  4502. break;
  4503. }
  4504. case COMMAND_SPAWN_DETAILS: {
  4505. Spawn* spawn = cmdTarget;
  4506. if (sep && sep->arg[0][0]) {
  4507. if (cmdTarget)
  4508. {
  4509. if (ToLower(string(sep->arg[0])) == "los")
  4510. {
  4511. bool hasLOS = client->GetPlayer()->CheckLoS(cmdTarget);
  4512. if (hasLOS)
  4513. client->Message(CHANNEL_COLOR_YELLOW, "You have line of sight with %s", spawn->GetName());
  4514. else
  4515. client->Message(CHANNEL_COLOR_RED, "You DO NOT have line of sight with %s", spawn->GetName());
  4516. break;
  4517. }
  4518. else if (ToLower(string(sep->arg[0])) == "bestz")
  4519. {
  4520. glm::vec3 targPos(cmdTarget->GetX(), cmdTarget->GetZ(), cmdTarget->GetY());
  4521. float bestZ = client->GetPlayer()->FindDestGroundZ(targPos, cmdTarget->GetYOffset());
  4522. client->Message(CHANNEL_COLOR_YELLOW, "Best Z for %s is %f", spawn->GetName(), bestZ);
  4523. break;
  4524. }
  4525. else if (ToLower(string(sep->arg[0])) == "inwater")
  4526. {
  4527. if (cmdTarget->GetRegionMap() == nullptr)
  4528. client->SimpleMessage(CHANNEL_COLOR_RED, "No water map for zone.");
  4529. else
  4530. {
  4531. bool inWater = cmdTarget->InWater();
  4532. client->Message(CHANNEL_COLOR_YELLOW, "%s is %s.", cmdTarget->GetName(), inWater ? "in water" : "out of water");
  4533. }
  4534. break;
  4535. }
  4536. else if (ToLower(string(sep->arg[0])) == "inlava")
  4537. {
  4538. if (cmdTarget->GetRegionMap() == nullptr)
  4539. client->SimpleMessage(CHANNEL_COLOR_RED, "No region map for zone.");
  4540. else
  4541. {
  4542. bool inLava = cmdTarget->InLava();
  4543. client->Message(CHANNEL_COLOR_YELLOW, "%s is %s.", cmdTarget->GetName(), inLava ? "in lava" : "out of lava");
  4544. }
  4545. break;
  4546. }
  4547. else if (ToLower(string(sep->arg[0])) == "regions")
  4548. {
  4549. glm::vec3 targPos(cmdTarget->GetX(), cmdTarget->GetY(), cmdTarget->GetZ());
  4550. if (cmdTarget->GetRegionMap() == nullptr)
  4551. client->SimpleMessage(CHANNEL_COLOR_RED, "No region map for zone.");
  4552. else
  4553. {
  4554. cmdTarget->GetRegionMap()->IdentifyRegionsInGrid(client, targPos);
  4555. }
  4556. break;
  4557. }
  4558. else if (ToLower(string(sep->arg[0])) == "behind")
  4559. {
  4560. bool isBehind = client->GetPlayer()->BehindTarget(cmdTarget);
  4561. client->Message(CHANNEL_COLOR_YELLOW, "%s %s.", isBehind ? "YOU are behind" : "YOU are NOT behind", cmdTarget->GetName());
  4562. break;
  4563. }
  4564. else if (ToLower(string(sep->arg[0])) == "infront")
  4565. {
  4566. bool isBehind = client->GetPlayer()->InFrontSpawn(cmdTarget, client->GetPlayer()->GetX(), client->GetPlayer()->GetZ());
  4567. client->Message(CHANNEL_COLOR_YELLOW, "%s %s.", isBehind ? "YOU are infront of" : "YOU are NOT infront of", cmdTarget->GetName());
  4568. break;
  4569. }
  4570. else if (ToLower(string(sep->arg[0])) == "flank")
  4571. {
  4572. bool isFlanking = client->GetPlayer()->FlankingTarget(cmdTarget);
  4573. client->Message(CHANNEL_COLOR_YELLOW, "%s is %s.", isFlanking ? "YOU are flanking" : "YOU are NOT flanking", cmdTarget->GetName());
  4574. break;
  4575. }
  4576. else if (ToLower(string(sep->arg[0])) == "aggro")
  4577. {
  4578. if(cmdTarget->IsNPC() && ((NPC*)cmdTarget)->Brain()) {
  4579. ((NPC*)cmdTarget)->Brain()->SendEncounterList(client);
  4580. ((NPC*)cmdTarget)->Brain()->SendHateList(client);
  4581. }
  4582. else {
  4583. client->SimpleMessage(CHANNEL_COLOR_RED, "/spawn details aggro is for NPCs only!");
  4584. }
  4585. break;
  4586. }
  4587. else if (ToLower(string(sep->arg[0])) == "angle")
  4588. {
  4589. float spawnAngle = client->GetPlayer()->GetFaceTarget(cmdTarget->GetX(), cmdTarget->GetZ());
  4590. client->Message(CHANNEL_COLOR_YELLOW, "Angle %f between player %s and target %s", spawnAngle, client->GetPlayer()->GetTarget() ? client->GetPlayer()->GetTarget()->GetName() : client->GetPlayer()->GetName(), client->GetPlayer()->GetName());
  4591. break;
  4592. }
  4593. }
  4594. if (sep->IsNumber(0))
  4595. {
  4596. float radius = atof(sep->arg[0]);
  4597. if (!client->GetCurrentZone()->SendRadiusSpawnInfo(client, radius))
  4598. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No results in the radius were found.");
  4599. break;
  4600. }
  4601. }
  4602. if (spawn) {
  4603. const char* type = "NPC";
  4604. if (spawn->IsObject())
  4605. type = "Object";
  4606. else if (spawn->IsSign())
  4607. type = "Sign";
  4608. else if (spawn->IsWidget())
  4609. type = "Widget";
  4610. else if (spawn->IsGroundSpawn())
  4611. type = "GroundSpawn";
  4612. int16 race_type = race_types_list.GetRaceType(spawn->GetModelType());
  4613. int16 race_base_type = race_types_list.GetRaceBaseType(spawn->GetModelType());
  4614. char* category = race_types_list.GetRaceTypeCategory(spawn->GetModelType());
  4615. char* subcategory = race_types_list.GetRaceTypeSubCategory(spawn->GetModelType());
  4616. char* modelname = race_types_list.GetRaceTypeModelName(spawn->GetModelType());
  4617. client->Message(CHANNEL_COLOR_YELLOW, "Name: %s, %s ID: %u", spawn->GetName(), type, spawn->GetDatabaseID());
  4618. client->Message(CHANNEL_COLOR_YELLOW, "Last Name: %s, Sub-Title: %s, Prefix: %s, Suffix: %s", spawn->GetLastName(), spawn->GetSubTitle(), spawn->GetPrefixTitle(), spawn->GetSuffixTitle());
  4619. client->Message(CHANNEL_COLOR_YELLOW, "Spawn Location ID: %u, Spawn Group ID: %u", spawn->GetSpawnLocationID(), spawn->GetSpawnGroupID());
  4620. client->Message(CHANNEL_COLOR_YELLOW, "Faction ID: %u, Merchant ID: %u, Transporter ID: %u", spawn->GetFactionID(), spawn->GetMerchantID(), spawn->GetTransporterID());
  4621. client->Message(CHANNEL_COLOR_YELLOW, "Grid ID: %u", spawn->GetLocation());
  4622. client->Message(CHANNEL_COLOR_YELLOW, "Race: %i, Class: %i, Gender: %i", spawn->GetRace(), spawn->GetAdventureClass(), spawn->GetGender());
  4623. client->Message(CHANNEL_COLOR_YELLOW, "Level: %i, HP: %u / %u, Power: %u / %u", spawn->GetLevel(), spawn->GetHP(), spawn->GetTotalHP(), spawn->GetPower(), spawn->GetTotalPower());
  4624. 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());
  4625. client->Message(CHANNEL_COLOR_YELLOW, "Collision Radius: %i, Size: %i, Difficulty: %i, Heroic: %i", spawn->GetCollisionRadius(), spawn->GetSize(), spawn->GetDifficulty(), spawn->GetHeroic());
  4626. client->Message(CHANNEL_COLOR_YELLOW, "Targetable: %i, Show Name: %i, Attackable: %i, Show Level: %i", spawn->GetTargetable(), spawn->GetShowName(), spawn->GetAttackable(), spawn->GetShowLevel());
  4627. client->Message(CHANNEL_COLOR_YELLOW, "Show Command Icon: %i, Display Hand Icon: %i", spawn->GetShowCommandIcon(), spawn->GetShowHandIcon());
  4628. if (spawn->IsEntity()) {
  4629. 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());
  4630. 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());
  4631. }
  4632. 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);
  4633. client->Message(CHANNEL_COLOR_YELLOW, "Primary Command Type: %u, Secondary Command Type: %u", spawn->GetPrimaryCommandListID(), spawn->GetSecondaryCommandListID());
  4634. 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());
  4635. 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);
  4636. if (spawn->IsNPC())
  4637. client->Message(CHANNEL_COLOR_YELLOW, "Randomize: %u", ((NPC*)spawn)->GetRandomize());
  4638. if (spawn->IsNPC()){
  4639. client->Message(CHANNEL_COLOR_YELLOW, "Heat Resist/Base: %u/%u",((NPC*)spawn)->GetHeatResistance(), ((NPC*)spawn)->GetHeatResistanceBase());
  4640. client->Message(CHANNEL_COLOR_YELLOW, "Cold Resist/Base: %u/%u",((NPC*)spawn)->GetColdResistance(), ((NPC*)spawn)->GetColdResistanceBase());
  4641. client->Message(CHANNEL_COLOR_YELLOW, "Magic Resist/Base: %u/%u",((NPC*)spawn)->GetMagicResistance(), ((NPC*)spawn)->GetMagicResistanceBase());
  4642. client->Message(CHANNEL_COLOR_YELLOW, "Mental Resist/Base: %u/%u",((NPC*)spawn)->GetMentalResistance(), ((NPC*)spawn)->GetMentalResistanceBase());
  4643. client->Message(CHANNEL_COLOR_YELLOW, "Divine Resist/Base: %u/%u",((NPC*)spawn)->GetDivineResistance(), ((NPC*)spawn)->GetDivineResistanceBase());
  4644. client->Message(CHANNEL_COLOR_YELLOW, "Disease Resist/Base: %u/%u",((NPC*)spawn)->GetDiseaseResistance(), ((NPC*)spawn)->GetDiseaseResistanceBase());
  4645. client->Message(CHANNEL_COLOR_YELLOW, "Poison Resist/Base: %u/%u",((NPC*)spawn)->GetPoisonResistance(), ((NPC*)spawn)->GetPoisonResistanceBase());
  4646. }
  4647. string details;
  4648. details += "\\#0000FFName: " + string(spawn->GetName()) + "\n";
  4649. details += "Type: " + string(type) + "\n";
  4650. details += "ID: " + to_string(spawn->GetDatabaseID()) + "\n";
  4651. details += "Last Name: " + string(spawn->GetLastName()) + "\n";
  4652. details += "Sub-Title: " + string(spawn->GetSubTitle()) + "\n";
  4653. details += "Prefix: " + string(spawn->GetPrefixTitle()) + "\n";
  4654. details += "Suffix: " + string(spawn->GetSuffixTitle()) + "\n";
  4655. details += "Race: " + to_string(spawn->GetRace()) + "\n";
  4656. details += "Class: " + to_string(spawn->GetAdventureClass()) + "\n";
  4657. details += "Gender: " + to_string(spawn->GetGender()) + "\n";
  4658. details += "Level: " + to_string(spawn->GetLevel()) + "\n";
  4659. details += "HP: " + to_string(spawn->GetHP()) + " / " + to_string(spawn->GetTotalHP()) + "(" + to_string(spawn->GetIntHPRatio()) + "%)\n";
  4660. details += "Power: " + to_string(spawn->GetPower()) + + " / " + to_string(spawn->GetTotalPower()) + "\n";
  4661. details += "Difficulty: " + to_string(spawn->GetDifficulty()) + "\n";
  4662. details += "Heroic: " + to_string(spawn->GetHeroic()) + "\n";
  4663. details += "Group ID: " + to_string(spawn->GetSpawnGroupID()) + "\n";
  4664. details += "Faction ID: " + to_string(spawn->GetFactionID()) + "\n";
  4665. details += "Merchant ID: " + to_string(spawn->GetMerchantID()) + "\n";
  4666. details += "Transport ID: " + to_string(spawn->GetTransporterID()) + "\n";
  4667. details += "Location ID: " + to_string(spawn->GetSpawnLocationID()) + "\n";
  4668. char x[16];
  4669. sprintf(x, "%.2f", spawn->GetX());
  4670. char y[16];
  4671. sprintf(y, "%.2f", spawn->GetY());
  4672. char z[16];
  4673. sprintf(z, "%.2f", spawn->GetZ());
  4674. details += "Location: " + string(x) + ", " + string(y) + ", " + string(z) + "\n";
  4675. string details2;
  4676. details2 += "Heading: " + to_string(spawn->GetHeading()) + "\n";
  4677. details2 += "Grid ID: " + to_string(spawn->GetLocation()) + "\n";
  4678. details2 += "Size: " + to_string(spawn->GetSize()) + "\n";
  4679. details2 += "Collision Radius: " + to_string(spawn->GetCollisionRadius()) + "\n";
  4680. details2 += "Respawn Time: " + to_string(spawn->GetRespawnTime()) + "\n";
  4681. details2 += "Targetable: " + to_string(spawn->GetTargetable()) + "\n";
  4682. details2 += "Show Name: " + to_string(spawn->GetShowName()) + "\n";
  4683. details2 += "Attackable: " + to_string(spawn->GetAttackable()) + "\n";
  4684. details2 += "Show Level: " + to_string(spawn->GetShowLevel()) + "\n";
  4685. details2 += "Show Command Icon: " + to_string(spawn->GetShowCommandIcon()) + "\n";
  4686. details2 += "Display Hand Icon: " + to_string(spawn->GetShowHandIcon()) + "\n";
  4687. details2 += "Model Type: " + to_string(spawn->GetModelType()) + "\n";
  4688. details2 += "Soga Race Type: " + to_string(spawn->GetSogaModelType()) + "\n";
  4689. details2 += "Race Type: " + to_string(race_type) + "\n";
  4690. details2 += "Race Base Type: " + to_string(race_base_type) + "\n";
  4691. details2 += "Race Category (Sub Category): " + std::string(category) + " (" + std::string(subcategory) + ")\n";
  4692. details2 += "Model Name: " + std::string(modelname) + "\n";
  4693. details2 += "Primary Command ID: " + to_string(spawn->GetPrimaryCommandListID()) + "\n";
  4694. details2 += "Secondary Cmd ID: " + to_string(spawn->GetSecondaryCommandListID()) + "\n";
  4695. details2 += "Visual State: " + to_string(spawn->GetVisualState()) + "\n";
  4696. details2 += "Action State: " + to_string(spawn->GetActionState()) + "\n";
  4697. details2 += "Mood State: " + to_string(spawn->GetMoodState()) + "\n";
  4698. details2 += "Initial State: " + to_string(spawn->GetInitialState()) + "\n";
  4699. details2 += "Activity Status: " + to_string(spawn->GetActivityStatus()) + "\n";
  4700. details2 += "Emote State: " + to_string(spawn->GetEmoteState()) + "\n";
  4701. string details3;
  4702. details3 += "Pitch: " + to_string(spawn->GetPitch()) + "\n";
  4703. details3 += "Roll: " + to_string(spawn->GetRoll()) + "\n";
  4704. details3 += "Hide Hood: " + to_string(spawn->appearance.hide_hood) + "\n";
  4705. details3 += "Speed: " + to_string(spawn->GetSpeed()) + "\n";
  4706. details3 += "BaseSpeed: " + to_string(spawn->GetBaseSpeed()) + "\n";
  4707. if(spawn->IsSign()) {
  4708. details3 += "Sign Language: " + to_string(((Sign*)spawn)->GetLanguage()) + "\n";
  4709. }
  4710. if(spawn->IsEntity())
  4711. {
  4712. Entity* ent = (Entity*)spawn;
  4713. details3 += "STR / STRBase: " + to_string(ent->GetInfoStruct()->get_str()) + " / " + to_string(ent->GetInfoStruct()->get_str_base()) + "\n";
  4714. details3 += "AGI / AGIBase: " + to_string(ent->GetInfoStruct()->get_agi()) + " / " + to_string(ent->GetInfoStruct()->get_agi_base()) + "\n";
  4715. details3 += "STA / STABase: " + to_string(ent->GetInfoStruct()->get_sta()) + " / " + to_string(ent->GetInfoStruct()->get_sta_base()) + "\n";
  4716. details3 += "INT / INTBase: " + to_string(ent->GetInfoStruct()->get_intel()) + " / " + to_string(ent->GetInfoStruct()->get_intel_base()) + "\n";
  4717. details3 += "WIS / WISBase: " + to_string(ent->GetInfoStruct()->get_wis()) + " / " + to_string(ent->GetInfoStruct()->get_wis_base()) + "\n";
  4718. }
  4719. string details4;
  4720. if (spawn->IsEntity()) {
  4721. details4 += "Facial Hair Type: " + to_string(((Entity*)spawn)->GetFacialHairType()) + "\n";
  4722. details4 += "Hair Type: " + to_string(((Entity*)spawn)->GetHairType()) + "\n";
  4723. details4 += "Chest Type: " + to_string(((Entity*)spawn)->GetChestType()) + "\n";
  4724. details4 += "Legs Type: " + to_string(((Entity*)spawn)->GetLegsType()) + "\n";
  4725. details4 += "Soga Facial Hair Type: " + to_string(((Entity*)spawn)->GetSogaFacialHairType()) + "\n";
  4726. details4 += "Soga Hair Type: " + to_string(((Entity*)spawn)->GetSogaHairType()) + "\n";
  4727. details4 += "Wing Type: " + to_string(((Entity*)spawn)->GetWingType()) + "\n";
  4728. if (spawn->IsNPC()) {
  4729. details4 += "\nRandomize: " + to_string(((NPC*)spawn)->GetRandomize()) + "\n";
  4730. }
  4731. }
  4732. const char* spawnScriptMsg = (spawn->GetSpawnScript() && strlen(spawn->GetSpawnScript())>0) ? spawn->GetSpawnScript() : "Not Set";
  4733. details4 += "\nSpawnScript: " + std::string(spawnScriptMsg) + "\n";
  4734. string title = string(spawn->GetName()) + "(" + to_string(spawn->GetDatabaseID()) + ")";
  4735. client->SendShowBook(client->GetPlayer(), title, 0, 4, details, details2, details3, details4);
  4736. }
  4737. else {
  4738. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn details (radius)");
  4739. 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.");
  4740. }
  4741. break;
  4742. }
  4743. case COMMAND_SPAWN_TARGET:{
  4744. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  4745. int32 spawn_id = atoul(sep->arg[0]);
  4746. int16 response = client->GetCurrentZone()->SetSpawnTargetable(spawn_id);
  4747. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  4748. }
  4749. else if(sep && sep->arg[0][0] && sep->arg[1][0] && sep->IsNumber(1) && ToLower(string(sep->arg[0])) == "radius"){
  4750. float distance = atof(sep->arg[1]);
  4751. int16 response = client->GetCurrentZone()->SetSpawnTargetable(client->GetPlayer(), distance);
  4752. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  4753. }
  4754. else{
  4755. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn target [spawn id]");
  4756. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn as targetable. Used to change a spawn if it was set to untargetable.");
  4757. }
  4758. break;
  4759. }
  4760. case COMMAND_SPAWN_SET:
  4761. {
  4762. Spawn* spawn = cmdTarget;
  4763. sint16 set_type = -1;
  4764. string type_str;
  4765. if (spawn)
  4766. {
  4767. // check if parameters are (location or list or not player and not a 2nd param), and that there is at least 1 value
  4768. 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)
  4769. {
  4770. // set the type, which will be 0 if location or list or invalid
  4771. set_type = spawn_set_values[ToLower(string(sep->arg[0]))];
  4772. }
  4773. if(set_type > 0)
  4774. {
  4775. // check if spawn set is NOT a char update, or not location, or isn't a number
  4776. 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)
  4777. {
  4778. client->SimpleMessage(CHANNEL_COLOR_RED, "Invalid value for set command.");
  4779. }
  4780. else
  4781. {
  4782. string name = string(spawn->GetName());
  4783. bool customSetSpawn = false;
  4784. if(set_type >= SPAWN_SET_CHEEK_TYPE && set_type <= SPAWN_SET_SOGA_NOSE_TYPE)
  4785. {
  4786. int8 index = sep->IsNumber(2) ? atoul(sep->arg[2]) : 0;
  4787. // override the standard setspawncommand, we pass arguments different!
  4788. if(SetSpawnCommand(client, spawn, set_type, sep->arg[1], true, false, nullptr, index))
  4789. customSetSpawn = true;
  4790. }
  4791. if(customSetSpawn || SetSpawnCommand(client, spawn, set_type, sep->argplus[1]))
  4792. {
  4793. if (set_type == SPAWN_SET_VALUE_EXPANSION_FLAG || set_type == SPAWN_SET_VALUE_HOLIDAY_FLAG)
  4794. {
  4795. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "A /reload spawns is required to properly update the spawns with the xpack/holiday flag.");
  4796. }
  4797. else if (set_type == SPAWN_SET_VALUE_NAME)
  4798. {
  4799. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "New name will not be effective until zone reload.");
  4800. }
  4801. else if (set_type == SPAWN_SET_SKIN_COLOR || (set_type >= SPAWN_SET_HAIR_COLOR1 && set_type <= SPAWN_SET_SOGA_EYE_COLOR))
  4802. {
  4803. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set color field to R G B: %s.", sep->argplus[1]);
  4804. }
  4805. else if(set_type == SPAWN_SET_VALUE_LOCATION)
  4806. {
  4807. spawn->SetLocation(client->GetPlayer()->GetLocation());
  4808. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set '%s' to '%u' for spawn '%s' (DBID: %u)", sep->arg[0], client->GetPlayer()->GetLocation(), name.c_str(), spawn->GetDatabaseID());
  4809. }
  4810. else
  4811. {
  4812. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set '%s' to '%s' for spawn '%s' (DBID: %u)", sep->arg[0], sep->arg[1], name.c_str(), spawn->GetDatabaseID());
  4813. }
  4814. switch (set_type)
  4815. {
  4816. case SPAWN_SET_VALUE_EXPANSION_FLAG:
  4817. case SPAWN_SET_VALUE_HOLIDAY_FLAG:
  4818. case SPAWN_SET_VALUE_FACTION:
  4819. case SPAWN_SET_AAXP_REWARDS:
  4820. case SPAWN_SET_CHEEK_TYPE:
  4821. case SPAWN_SET_CHIN_TYPE:
  4822. case SPAWN_SET_EAR_TYPE:
  4823. case SPAWN_SET_EYE_BROW_TYPE:
  4824. case SPAWN_SET_EYE_TYPE:
  4825. case SPAWN_SET_LIP_TYPE:
  4826. case SPAWN_SET_NOSE_TYPE:
  4827. case SPAWN_SET_BODY_SIZE:
  4828. case SPAWN_SET_BODY_AGE:
  4829. case SPAWN_SET_SOGA_CHEEK_TYPE:
  4830. case SPAWN_SET_SOGA_CHIN_TYPE:
  4831. case SPAWN_SET_SOGA_EAR_TYPE:
  4832. case SPAWN_SET_SOGA_EYE_BROW_TYPE:
  4833. case SPAWN_SET_SOGA_EYE_TYPE:
  4834. case SPAWN_SET_SOGA_LIP_TYPE:
  4835. case SPAWN_SET_SOGA_NOSE_TYPE:
  4836. case SPAWN_SET_SOGA_BODY_SIZE:
  4837. case SPAWN_SET_SOGA_BODY_AGE:
  4838. case SPAWN_SET_ATTACK_TYPE:
  4839. case SPAWN_SET_RACE_TYPE:
  4840. case SPAWN_SET_LOOT_TIER:
  4841. case SPAWN_SET_LOOT_DROP_TYPE:
  4842. case SPAWN_SET_SCARED_STRONG_PLAYERS:
  4843. {
  4844. // not applicable already ran db command
  4845. break;
  4846. }
  4847. default:
  4848. {
  4849. client->GetCurrentZone()->ApplySetSpawnCommand(client, spawn, set_type, sep->argplus[1]);
  4850. break;
  4851. }
  4852. }
  4853. 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))
  4854. {
  4855. if(spawn->GetSpawnLocationID() > 0 && database.UpdateSpawnLocationSpawns(spawn))
  4856. {
  4857. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information for spawn '%s' (DBID: %u)", name.c_str(), spawn->GetDatabaseID());
  4858. }
  4859. else if(spawn->GetSpawnLocationID() > 0)
  4860. {
  4861. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn information, see console window for details.");
  4862. }
  4863. }
  4864. else
  4865. {
  4866. if(spawn->GetDatabaseID() > 0 && database.SaveSpawnInfo(spawn))
  4867. {
  4868. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn for spawn '%s' (DBID: %u)", name.c_str(), spawn->GetDatabaseID());
  4869. }
  4870. else if(spawn->GetDatabaseID() > 0)
  4871. {
  4872. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn, see console window for details.");
  4873. }
  4874. }
  4875. }
  4876. }
  4877. }
  4878. else if(set_type == 0)
  4879. {
  4880. // /spawn set list - lists all possible attributes that can be changed with this command, 10 per line.
  4881. map<string, int8>::iterator itr;
  4882. int i=0;
  4883. string list;
  4884. for(itr = spawn_set_values.begin(); itr != spawn_set_values.end(); itr++, i++)
  4885. {
  4886. if(i==10)
  4887. {
  4888. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  4889. i = 0;
  4890. }
  4891. if(i>0)
  4892. {
  4893. list.append(", ").append(itr->first);
  4894. }
  4895. else
  4896. {
  4897. list = itr->first;
  4898. }
  4899. }
  4900. if(list.length() > 0)
  4901. {
  4902. // if 1 or more, display in client.
  4903. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  4904. }
  4905. }
  4906. else
  4907. {
  4908. // syntax fail
  4909. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn set [type] [value]");
  4910. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used to change various settings for the targeted NPC or Object.");
  4911. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "For a list of changeable settings use /spawn set list");
  4912. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Note: /spawn set location does not require a value. The client's current location is used.");
  4913. }
  4914. }
  4915. break;
  4916. }
  4917. case COMMAND_SPAWN_REMOVE:{
  4918. Spawn* spawn = cmdTarget;
  4919. if(spawn && !spawn->IsPlayer()){
  4920. if(spawn->GetSpawnLocationID() > 0){
  4921. string name = string(spawn->GetName());
  4922. int32 dbid = spawn->GetDatabaseID();
  4923. if(database.RemoveSpawnFromSpawnLocation(spawn)){
  4924. client->GetCurrentZone()->RemoveSpawn(spawn, true, false, true, true, true);
  4925. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed spawn from zone for spawn '%s' (DBID: %u)", name.c_str(), dbid);
  4926. }
  4927. else
  4928. client->SimpleMessage(CHANNEL_COLOR_RED, "Error removing spawn, see console window for details.");
  4929. }
  4930. else
  4931. client->SimpleMessage(CHANNEL_COLOR_RED, "This spawn does not have a spawn group associated with it");
  4932. }
  4933. else{
  4934. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn remove");
  4935. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for removing the targeted NPC or Object from the zone.");
  4936. }
  4937. break;
  4938. }
  4939. case COMMAND_SPAWN_LIST:{
  4940. if(sep && sep->arg[0][0]){
  4941. vector<string>* results = database.GetSpawnNameList(sep->argplus[0]);
  4942. vector<string>::iterator itr;
  4943. if(results){
  4944. for(itr=results->begin();itr!=results->end();itr++){
  4945. client->SimpleMessage(CHANNEL_COLOR_YELLOW, (*itr).c_str());
  4946. }
  4947. safe_delete(results);
  4948. }
  4949. else
  4950. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found. ");
  4951. }
  4952. else{
  4953. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn list [name]");
  4954. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Name can be a partial match.");
  4955. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn list Qeynos Guard");
  4956. }
  4957. break;
  4958. }
  4959. case COMMAND_SPAWN_ADD:{
  4960. Spawn* spawn = cmdTarget;
  4961. if(spawn && sep && ((sep->arg[1][0] && sep->IsNumber(0)) || (sep->arg[0][0] && strncasecmp(sep->arg[0], "new", 3) == 0))){
  4962. if(spawn->GetSpawnLocationID() > 0){
  4963. client->Message(CHANNEL_COLOR_RED, "This spawn already has a spawn group id of %u, use /spawn remove to reassign it", spawn->GetSpawnLocationID());
  4964. break;
  4965. }
  4966. if(spawn->GetDatabaseID() == 0){
  4967. if(database.SaveSpawnInfo(spawn)) {
  4968. char spawn_type[32];
  4969. memset(spawn_type, 0, sizeof(spawn_type));
  4970. if (spawn->IsNPC())
  4971. strncpy(spawn_type, "NPC", sizeof(spawn_type) - 1);
  4972. else if (spawn->IsObject())
  4973. strncpy(spawn_type, "Object", sizeof(spawn_type) - 1);
  4974. else if (spawn->IsSign())
  4975. strncpy(spawn_type, "Sign", sizeof(spawn_type) - 1);
  4976. else if (spawn->IsGroundSpawn())
  4977. strncpy(spawn_type, "GroundSpawn", sizeof(spawn_type) - 1);
  4978. else
  4979. strncpy(spawn_type, "Unknown", sizeof(spawn_type) - 1);
  4980. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information with a %s id of %u", spawn_type, spawn->GetDatabaseID());
  4981. }
  4982. else
  4983. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn information, see console window for details.");
  4984. }
  4985. int32 spawn_group_id = 0;
  4986. if(strncasecmp(sep->arg[0], "new", 3) == 0)
  4987. spawn_group_id = database.GetNextSpawnLocation();
  4988. else
  4989. spawn_group_id = atol(sep->arg[0]);
  4990. int8 percent = 100;
  4991. if(sep->arg[2] && sep->IsNumber(2))
  4992. percent = atoi(sep->arg[2]);
  4993. spawn->SetSpawnLocationID(spawn_group_id);
  4994. float x_offset = database.GetSpawnLocationPlacementOffsetX(spawn->GetSpawnLocationID());
  4995. float y_offset = database.GetSpawnLocationPlacementOffsetY(spawn->GetSpawnLocationID());
  4996. float z_offset = database.GetSpawnLocationPlacementOffsetZ(spawn->GetSpawnLocationID());
  4997. if(database.SaveSpawnEntry(spawn, sep->arg[1], percent, x_offset, y_offset, z_offset))
  4998. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn location with a spawn group of %u", spawn->GetSpawnLocationID());
  4999. else
  5000. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn location, see console window for details.");
  5001. }
  5002. else{
  5003. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn add [spawn group id] [spawn group name] (percentage)");
  5004. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for adding the targeted NPC or Object to the database.");
  5005. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can substitute new for [spawn group id] to create a new one.");
  5006. }
  5007. break;
  5008. }
  5009. case COMMAND_SPAWN:{
  5010. int32 id = 0;
  5011. Spawn* spawn = 0;
  5012. if(sep && sep->arg[0] && sep->IsNumber(0)){
  5013. id = atol(sep->arg[0]);
  5014. spawn = client->GetCurrentZone()->GetSpawn(id);
  5015. }
  5016. if(id > 0 && spawn && spawn->appearance.name[0] == 0)
  5017. id = 0;
  5018. if(!id || !spawn){
  5019. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn [spawn id] (x) (y) (z) (heading) (location)");
  5020. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are optional except the id. The spawn id must be in the database.");
  5021. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn 1 0 0 0 0");
  5022. safe_delete(sep);
  5023. return;
  5024. }
  5025. if(sep && sep->arg[1][0]){
  5026. float x = atof(sep->arg[1]);
  5027. spawn->appearance.pos.X = x;
  5028. }
  5029. else
  5030. spawn->SetX(client->GetPlayer()->GetX(), false);
  5031. if(sep && sep->arg[2][0]){
  5032. float y = atof(sep->arg[2]);
  5033. spawn->appearance.pos.Y = y;
  5034. }
  5035. else
  5036. spawn->SetY(client->GetPlayer()->GetY(), false);
  5037. if(sep && sep->arg[3][0]){
  5038. float z = atof(sep->arg[3]);
  5039. spawn->appearance.pos.Z = z;
  5040. }
  5041. else
  5042. spawn->SetZ(client->GetPlayer()->GetZ(), false);
  5043. if(sep && sep->arg[4][0]){
  5044. float heading = atof(sep->arg[4]);
  5045. spawn->SetHeading(heading);
  5046. }
  5047. else
  5048. spawn->SetHeading(client->GetPlayer()->GetHeading(), false);
  5049. spawn->SetSpawnOrigX(spawn->GetX());
  5050. spawn->SetSpawnOrigY(spawn->GetY());
  5051. spawn->SetSpawnOrigZ(spawn->GetZ());
  5052. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  5053. if(sep && sep->arg[5][0])
  5054. spawn->SetLocation(atoul(sep->arg[5]));
  5055. else
  5056. spawn->SetLocation(client->GetPlayer()->GetLocation());
  5057. if(spawn->IsNPC() && spawn->GetTotalHP() == 0){
  5058. spawn->SetTotalHP(spawn->GetLevel() * 15);
  5059. spawn->SetHP(spawn->GetTotalHP());
  5060. }
  5061. if(spawn->GetTotalPower() == 0){
  5062. spawn->SetTotalPower(spawn->GetLevel() * 15);
  5063. spawn->SetPower(spawn->GetTotalPower());
  5064. }
  5065. const char* script = world.GetSpawnScript(id);
  5066. if(script && lua_interface && lua_interface->GetSpawnScript(script) != 0)
  5067. spawn->SetSpawnScript(string(script));
  5068. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_PRESPAWN);
  5069. client->GetCurrentZone()->AddSpawn(spawn);
  5070. if(spawn->IsNPC())
  5071. spawn->GetZone()->AddLoot((NPC*)spawn);
  5072. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_SPAWN);
  5073. LogWrite(COMMAND__INFO, 0, "Command", "Received spawn command - Parms: %s", command_parms->data.c_str());
  5074. break;
  5075. }
  5076. case COMMAND_ADMINFLAG:
  5077. {
  5078. if(sep && sep->arg[0]){
  5079. sint16 tmp_status = database.GetCharacterAdminStatus(sep->arg[0]);
  5080. sint16 new_status = atoi(sep->arg[1]);
  5081. if(tmp_status == -10)
  5082. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character does not exist.");
  5083. else if(tmp_status >= client->GetAdminStatus())
  5084. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character has same or higher level status.");
  5085. else if (new_status > client->GetAdminStatus())
  5086. client->SimpleMessage(CHANNEL_ERROR, "Unable to flag character. Reason: New status is higher then your status.");
  5087. else{
  5088. Client* client2 = client->GetCurrentZone()->GetClientByName(sep->arg[0]);
  5089. if (!client2)
  5090. client2 = zone_list.GetClientByCharName(sep->arg[0]);
  5091. if(database.UpdateAdminStatus(sep->arg[0],new_status)) {
  5092. client->Message(CHANNEL_COLOR_YELLOW,"Character status updated to %i for %s.",new_status,sep->arg[0]);
  5093. if (client2) {
  5094. client2->SetAdminStatus(new_status);
  5095. client2->Message(CHANNEL_COLOR_YELLOW, "%s has set your admin status to %i.", client->GetPlayer()->GetName(), new_status);
  5096. }
  5097. }
  5098. else
  5099. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Unknown reason.");
  5100. }
  5101. }else{
  5102. sint16 status = database.GetCharacterAdminStatus(client->GetPlayer()->GetName());
  5103. if(status != client->GetAdminStatus())
  5104. {
  5105. client->Message(CHANNEL_COLOR_YELLOW,"Flag status was changed from %i to %i.",status,client->GetAdminStatus());
  5106. client->SetAdminStatus(status);
  5107. }
  5108. else
  5109. {
  5110. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /flag {name} {new_status}");
  5111. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Standard User: 0");
  5112. client->Message(CHANNEL_COLOR_YELLOW," Admin User: %i", status);
  5113. }
  5114. }
  5115. break;
  5116. }
  5117. case COMMAND_CANNEDEMOTE:{
  5118. client->GetCurrentZone()->HandleEmote(client->GetPlayer(), command_parms->data);
  5119. break;
  5120. }
  5121. case COMMAND_BROADCAST: {
  5122. if (sep && sep->arg[0])
  5123. zone_list.HandleGlobalBroadcast(sep->argplus[0]);
  5124. else
  5125. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /broadcast {message}");
  5126. break;
  5127. }
  5128. case COMMAND_ANNOUNCE: {
  5129. if (sep && sep->arg[0])
  5130. zone_list.HandleGlobalAnnouncement(sep->argplus[0]);
  5131. else
  5132. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /announce {message}");
  5133. break;
  5134. }
  5135. case COMMAND_RELOAD_ITEMS:{
  5136. LogWrite(COMMAND__INFO, 0, "Command", "Reloading items..");
  5137. int32 item_id = (sep && sep->arg[0]) ? atoul(sep->arg[0]) : 0;
  5138. if(item_id > 0) {
  5139. client->Message(CHANNEL_COLOR_YELLOW, "Reloading item %u based on /reload items [item_id].", item_id);
  5140. }
  5141. else {
  5142. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Started Reloading items (this might take a few minutes...)");
  5143. }
  5144. database.ReloadItemList(item_id);
  5145. if(!item_id) {
  5146. database.LoadMerchantInformation(); // we skip if there is only a reload of single item not all items
  5147. }
  5148. if(item_id > 0) {
  5149. client->Message(CHANNEL_COLOR_YELLOW, "Reloaded item %u.", item_id);
  5150. }
  5151. else {
  5152. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Finished Reloading items.");
  5153. }
  5154. break;
  5155. }
  5156. case COMMAND_ENABLE_ABILITY_QUE:{
  5157. EQ2Packet* app = client->GetPlayer()->GetSpellBookUpdatePacket(client->GetVersion());
  5158. if(app)
  5159. client->QueuePacket(app);
  5160. break;
  5161. }
  5162. case COMMAND_ITEMSEARCH:
  5163. case COMMAND_FROMBROKER:{
  5164. PacketStruct* packet = configReader.getStruct("WS_StartBroker", client->GetVersion());
  5165. if (packet) {
  5166. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  5167. //packet->setDataByName("unknown", 1);
  5168. packet->setDataByName("unknown2", 5, 0);
  5169. packet->setDataByName("unknown2", 20, 1);
  5170. packet->setDataByName("unknown2", 58, 3);
  5171. packet->setDataByName("unknown2", 40, 4);
  5172. client->QueuePacket(packet->serialize());
  5173. PacketStruct* packet2 = configReader.getStruct("WS_BrokerBags", client->GetVersion());
  5174. if (packet2) {
  5175. packet2->setDataByName("char_id", client->GetCharacterID());
  5176. client->QueuePacket(packet2->serialize()); //send this for now, needed to properly clear data
  5177. safe_delete(packet2);
  5178. }
  5179. safe_delete(packet);
  5180. }
  5181. break;
  5182. }
  5183. case COMMAND_ANIMTEST:{
  5184. PacketStruct* command_packet = configReader.getStruct("WS_CannedEmote", client->GetVersion());
  5185. if(command_packet){
  5186. int32 id = client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer());
  5187. if (cmdTarget)
  5188. id = client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget);
  5189. command_packet->setDataByName ( "spawn_id" , id);
  5190. int animID = 1;
  5191. if(sep && sep->arg[0] && sep->IsNumber(0))
  5192. animID = atoi(sep->arg[0]);
  5193. VisualState* vs = NULL;
  5194. if(animID == 0)
  5195. {
  5196. vs = visual_states.FindVisualState(sep->arg[0]);
  5197. }
  5198. char msg[128];
  5199. sprintf(msg,"Animation Test ID: %i",animID);
  5200. command_packet->setMediumStringByName ( "emote_msg" , msg );
  5201. if(vs != NULL)
  5202. command_packet->setDataByName ( "anim_type", vs->GetID ( ) );
  5203. else
  5204. command_packet->setDataByName ( "anim_type", animID );
  5205. command_packet->setDataByName ( "unknown0", 0 );
  5206. EQ2Packet* outapp = command_packet->serialize();
  5207. client->QueuePacket(outapp);
  5208. safe_delete(command_packet);
  5209. }
  5210. break;
  5211. }
  5212. case COMMAND_KICK:
  5213. {
  5214. if( sep == 0 || sep->arg[0] == 0)
  5215. {
  5216. client->SimpleMessage(CHANNEL_COLOR_RED, "/kick [name]");
  5217. }
  5218. else
  5219. {
  5220. Client* kickClient = zone_list.GetClientByCharName(string(sep->arg[0]));
  5221. if ( kickClient == client )
  5222. {
  5223. client->Message(CHANNEL_COLOR_RED, "You can't kick yourself!");
  5224. break;
  5225. }
  5226. else if(kickClient != NULL)
  5227. {
  5228. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  5229. if ( maxStatus >= client->GetAdminStatus( ) || kickClient->GetAdminStatus() >= client->GetAdminStatus() )
  5230. {
  5231. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  5232. break;
  5233. }
  5234. client->Message(CHANNEL_COLOR_RED, "Kicking %s...",sep->arg[0]);
  5235. kickClient->Disconnect();
  5236. }
  5237. else
  5238. {
  5239. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  5240. }
  5241. }
  5242. break;
  5243. }
  5244. case COMMAND_LOCK:
  5245. {
  5246. if( sep != NULL && sep->arg[0] != NULL && sep->IsNumber(0)){
  5247. int worldLocked = atoi(sep->arg[0]);
  5248. net.world_locked = worldLocked;
  5249. if ( worldLocked )
  5250. client->Message(CHANNEL_COLOR_YELLOW,"World server has been locked.");
  5251. else
  5252. client->Message(CHANNEL_COLOR_YELLOW,"World server has been unlocked.");
  5253. }
  5254. else
  5255. client->SimpleMessage(CHANNEL_COLOR_RED, "/lock [0/1]");
  5256. break;
  5257. }
  5258. case COMMAND_BAN:{
  5259. if( sep == 0 || sep->arg[0] == 0 || (sep->arg[1][0] != 0 && !sep->IsNumber(1) ) )
  5260. {
  5261. client->SimpleMessage(CHANNEL_COLOR_RED, "/ban [name] [permanent:0/1]");
  5262. }
  5263. else
  5264. {
  5265. Client* kickClient = zone_list.GetClientByCharName(sep->arg[0]);
  5266. if ( kickClient == client )
  5267. {
  5268. client->Message(CHANNEL_COLOR_RED, "You can't ban yourself!");
  5269. break;
  5270. }
  5271. else if(kickClient != NULL)
  5272. {
  5273. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  5274. if ( maxStatus > client->GetAdminStatus( ) ||
  5275. client->GetAdminStatus ( ) > kickClient->GetAdminStatus ( ) )
  5276. {
  5277. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  5278. break;
  5279. }
  5280. client->Message(CHANNEL_COLOR_RED, "Kicking & Banning %s...",sep->arg[0]);
  5281. int perm = atol(sep->arg[1]);
  5282. if ( perm == 1 )
  5283. database.UpdateAdminStatus(sep->arg[0],-2);
  5284. else
  5285. database.UpdateAdminStatus(sep->arg[0],-1);
  5286. kickClient->Disconnect();
  5287. }
  5288. else
  5289. {
  5290. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  5291. }
  5292. }
  5293. break;
  5294. }
  5295. case COMMAND_SET_COMBAT_VOICE:{
  5296. int32 value = 0;
  5297. if(sep && sep->arg[0] && sep->IsNumber(0))
  5298. value = atoi(sep->arg[0]);
  5299. client->GetPlayer()->SetCombatVoice(value);
  5300. break;
  5301. }
  5302. case COMMAND_SET_EMOTE_VOICE:{
  5303. int32 value = 0;
  5304. if(sep && sep->arg[0] && sep->IsNumber(0))
  5305. value = atoi(sep->arg[0]);
  5306. client->GetPlayer()->SetEmoteVoice(value);
  5307. break;
  5308. }
  5309. case COMMAND_GIVEITEM:{
  5310. if(sep && sep->arg[0][0] && sep->arg[0][1] && sep->IsNumber(1)){
  5311. Client* itemToClient = zone_list.GetClientByCharName(sep->arg[0]);
  5312. if ( itemToClient == NULL )
  5313. client->Message(CHANNEL_COLOR_YELLOW,"Could not find %s.",sep->arg[0]);
  5314. else
  5315. {
  5316. int32 item_id = atol(sep->arg[1]);
  5317. client->Message(CHANNEL_COLOR_YELLOW,"Gave %s item id %i.",sep->arg[0],item_id);
  5318. itemToClient->AddItem(item_id);
  5319. }
  5320. }
  5321. else
  5322. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /giveitem [name] [item_id]");
  5323. break;
  5324. }
  5325. case COMMAND_REPORT_BUG : { Command_ReportBug(client, sep); break; }
  5326. case COMMAND_INVENTORY : { Command_Inventory(client, sep, command); break; }
  5327. case COMMAND_WEAPONSTATS : { Command_WeaponStats(client); break; }
  5328. case COMMAND_SKILL :
  5329. case COMMAND_SKILL_ADD :
  5330. case COMMAND_SKILL_REMOVE :
  5331. case COMMAND_SKILL_LIST : { Command_Skills(client, sep, command->handler); break; }
  5332. case COMMAND_ZONE_SET : { Command_ZoneSet(client, sep); break; }
  5333. case COMMAND_ZONE_DETAILS : { Command_ZoneDetails(client, sep); break; }
  5334. case COMMAND_ENTITYCOMMAND :
  5335. case COMMAND_ENTITYCOMMAND_LIST : { Command_EntityCommand(client, sep, command->handler); break; }
  5336. case COMMAND_MERCHANT :
  5337. case COMMAND_MERCHANT_LIST : { Command_Merchant(client, sep, command->handler); break; }
  5338. case COMMAND_APPEARANCE :
  5339. case COMMAND_APPEARANCE_LIST : { Command_Appearance(client, sep, command->handler); break; }
  5340. case COMMAND_TRACK : { Command_Track(client); break; }
  5341. case COMMAND_DISTANCE : { Command_Distance(client); break; }
  5342. case COMMAND_INSPECT_PLAYER : { Command_InspectPlayer(client, sep); break; }
  5343. case COMMAND_ZONE_SAFE : { Command_ZoneSafeCoords(client, sep); break; }
  5344. case COMMAND_GUILDSAY : { Command_GuildSay(client, sep); break; }
  5345. case COMMAND_OFFICERSAY : { Command_OfficerSay(client, sep); break; }
  5346. case COMMAND_SET_GUILD_MEMBER_NOTE : { Command_SetGuildMemberNote(client, sep); break; }
  5347. case COMMAND_SET_GUILD_OFFICER_NOTE : { Command_SetGuildOfficerNote(client, sep); break; }
  5348. case COMMAND_GUILD : { Command_Guild(client, sep); break; }
  5349. case COMMAND_CREATE_GUILD : { Command_CreateGuild(client); break; }
  5350. case COMMAND_GUILDS : { Command_Guilds(client); break; }
  5351. case COMMAND_GUILDS_ADD : { Command_GuildsAdd(client, sep); break; }
  5352. case COMMAND_GUILDS_CREATE : { Command_GuildsCreate(client, sep); break; }
  5353. case COMMAND_GUILDS_DELETE : { Command_GuildsDelete(client, sep); break; }
  5354. case COMMAND_GUILDS_LIST : { Command_GuildsList(client); break; }
  5355. case COMMAND_GUILDS_REMOVE : { Command_GuildsRemove(client, sep); break; }
  5356. case COMMAND_CLAIM : { Command_Claim(client, sep); break; }
  5357. case COMMAND_CLEAR_ALL_QUEUED : { Command_ClearAllQueued(client); break; }
  5358. case COMMAND_LOCATION : { Command_Location(client); break; }
  5359. case COMMAND_LOCATION_ADD : { Command_LocationAdd(client, sep); break; }
  5360. case COMMAND_LOCATION_CREATE : { Command_LocationCreate(client, sep); break; }
  5361. case COMMAND_LOCATION_DELETE : { Command_LocationDelete(client, sep); break; }
  5362. case COMMAND_LOCATION_LIST : { Command_LocationList(client, sep); break; }
  5363. case COMMAND_LOCATION_REMOVE : { Command_LocationRemove(client, sep); break; }
  5364. case COMMAND_GRID : { Command_Grid(client, sep); break; }
  5365. case COMMAND_TRY_ON : { Command_TryOn(client, sep); break; }
  5366. case COMMAND_RANDOMIZE : { Command_Randomize(client, sep); break; }
  5367. case COMMAND_AFK : { Command_AFK(client, sep); break; }
  5368. case COMMAND_SHOW_CLOAK : { Command_ShowCloak(client, sep); break; }
  5369. case COMMAND_SHOW_HELM : { Command_ShowHelm(client, sep); break; }
  5370. case COMMAND_SHOW_HOOD : { Command_ShowHood(client, sep); break; }
  5371. case COMMAND_SHOW_HOOD_OR_HELM : { Command_ShowHoodHelm(client, sep); break; }
  5372. case COMMAND_SHOW_RANGED : { Command_ShowRanged(client, sep); break; }
  5373. case COMMAND_STOP_DRINKING : { Command_StopDrinking(client); break; }
  5374. case COMMAND_STOP_EATING : { Command_StopEating(client); break; }
  5375. case COMMAND_TOGGLE_ANONYMOUS : { Command_Toggle_Anonymous(client); break; }
  5376. case COMMAND_TOGGLE_AUTOCONSUME : { Command_Toggle_AutoConsume(client, sep); break; }
  5377. case COMMAND_TOGGLE_BONUS_EXP : { Command_Toggle_BonusXP(client); break; }
  5378. case COMMAND_TOGGLE_COMBAT_EXP : { Command_Toggle_CombatXP(client); break; }
  5379. case COMMAND_TOGGLE_GM_HIDE : { Command_Toggle_GMHide(client); break; }
  5380. case COMMAND_TOGGLE_GM_VANISH : { Command_Toggle_GMVanish(client); break; }
  5381. case COMMAND_TOGGLE_ILLUSIONS : { Command_Toggle_Illusions(client, sep); break; }
  5382. case COMMAND_TOGGLE_LFG : { Command_Toggle_LFG(client); break; }
  5383. case COMMAND_TOGGLE_LFW : { Command_Toggle_LFW(client); break; }
  5384. case COMMAND_TOGGLE_QUEST_EXP : { Command_Toggle_QuestXP(client); break; }
  5385. case COMMAND_TOGGLE_ROLEPLAYING : { Command_Toggle_Roleplaying(client); break; }
  5386. case COMMAND_TOGGLE_DUELS : { Command_Toggle_Duels(client); break; }
  5387. case COMMAND_TOGGLE_TRADES : { Command_Toggle_Trades(client); break; }
  5388. case COMMAND_TOGGLE_GUILDS : { Command_Toggle_Guilds(client); break; }
  5389. case COMMAND_TOGGLE_GROUPS : { Command_Toggle_Groups(client); break; }
  5390. case COMMAND_TOGGLE_RAIDS : { Command_Toggle_Raids(client); break; }
  5391. case COMMAND_TOGGLE_LON : { Command_Toggle_LON(client); break; }
  5392. case COMMAND_TOGGLE_VCINVITE : { Command_Toggle_VoiceChat(client); break; }
  5393. case COMMAND_CANCEL_MAINTAINED : { Command_CancelMaintained(client, sep); break; }
  5394. case COMMAND_MOTD : { Command_MOTD(client); break; }
  5395. case COMMAND_RANDOM : { Command_Random(client, sep); break; }
  5396. case COMMAND_CREATE : { Command_Create(client, sep); break; }
  5397. case COMMAND_CREATEFROMRECIPE : { Command_CreateFromRecipe(client, sep); break; }
  5398. case COMMAND_TITLE : { Command_Title(client); break; }
  5399. case COMMAND_TITLE_LIST : { Command_TitleList(client); break; }
  5400. case COMMAND_TITLE_SETPREFIX : { Command_TitleSetPrefix(client, sep); break; }
  5401. case COMMAND_TITLE_SETSUFFIX : { Command_TitleSetSuffix(client, sep); break; }
  5402. case COMMAND_TITLE_FIX : { Command_TitleFix(client, sep); break; }
  5403. case COMMAND_LANGUAGES : { Command_Languages(client, sep); break; }
  5404. case COMMAND_SET_LANGUAGE : { Command_SetLanguage(client, sep); break; }
  5405. case COMMAND_FOLLOW : { Command_Follow(client, sep); break; }
  5406. case COMMAND_STOP_FOLLOW : { Command_StopFollow(client, sep); break; }
  5407. case COMMAND_LASTNAME : { Command_LastName(client, sep); break; }
  5408. case COMMAND_CONFIRMLASTNAME : { Command_ConfirmLastName(client, sep); break; }
  5409. case COMMAND_PET : { Command_Pet(client, sep); break; }
  5410. case COMMAND_PETNAME : { Command_PetName(client, sep); break; }
  5411. case COMMAND_NAME_PET : { Command_NamePet(client, sep); break; }
  5412. case COMMAND_RENAME : { Command_Rename(client, sep); break; }
  5413. case COMMAND_CONFIRMRENAME : { Command_ConfirmRename(client, sep); break; }
  5414. case COMMAND_PETOPTIONS : { Command_PetOptions(client, sep); break; }
  5415. case COMMAND_START_TRADE : { Command_TradeStart(client, sep); break; }
  5416. case COMMAND_ACCEPT_TRADE : { Command_TradeAccept(client, sep); break; }
  5417. case COMMAND_REJECT_TRADE : { Command_TradeReject(client, sep); break; }
  5418. case COMMAND_CANCEL_TRADE : { Command_TradeCancel(client, sep); break; }
  5419. case COMMAND_SET_TRADE_COIN : { Command_TradeSetCoin(client, sep); break; }
  5420. case COMMAND_ADD_TRADE_COPPER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_COPPER); break; }
  5421. case COMMAND_ADD_TRADE_SILVER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_SILVER); break; }
  5422. case COMMAND_ADD_TRADE_GOLD : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_GOLD); break; }
  5423. case COMMAND_ADD_TRADE_PLAT : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_PLAT); break; }
  5424. case COMMAND_REMOVE_TRADE_COPPER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_COPPER); break; }
  5425. case COMMAND_REMOVE_TRADE_SILVER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_SILVER); break; }
  5426. case COMMAND_REMOVE_TRADE_GOLD : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_GOLD); break; }
  5427. case COMMAND_REMOVE_TRADE_PLAT : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_PLAT); break; }
  5428. case COMMAND_ADD_TRADE_ITEM : { Command_TradeAddItem(client, sep); break; }
  5429. case COMMAND_REMOVE_TRADE_ITEM : { Command_TradeRemoveItem(client, sep); break; }
  5430. case COMMAND_ACCEPT_ADVANCEMENT : { Command_AcceptAdvancement(client, sep); break; }
  5431. case COMMAND_DUEL : { Command_Duel(client, sep); break; }
  5432. case COMMAND_DUELBET : { Command_DuelBet(client, sep); break; }
  5433. case COMMAND_DUEL_ACCEPT : { Command_DuelAccept(client, sep); break; }
  5434. case COMMAND_DUEL_DECLINE : { Command_DuelDecline(client, sep); break; }
  5435. case COMMAND_DUEL_SURRENDER : { Command_DuelSurrender(client, sep); break; }
  5436. case COMMAND_DUEL_TOGGLE : { Command_DuelToggle(client, sep); break; }
  5437. case COMMAND_SPAWN_TEMPLATE : { Command_SpawnTemplate(client, sep); break; }
  5438. //devn00b
  5439. case COMMAND_MOOD : { Command_Mood(client, sep); break;}
  5440. case COMMAND_MODIFY : { Command_Modify(client); break; }
  5441. case COMMAND_MODIFY_CHARACTER : { Command_ModifyCharacter(client, sep); break; }
  5442. case COMMAND_MODIFY_QUEST : { Command_ModifyQuest(client, sep); break; }
  5443. case COMMAND_MODIFY_FACTION : { Command_ModifyFaction(client, sep); break; }
  5444. case COMMAND_MODIFY_GUILD : { Command_ModifyGuild(client, sep); break; }
  5445. case COMMAND_MODIFY_ITEM : { Command_ModifyItem(client, sep); break; }
  5446. case COMMAND_MODIFY_SKILL : { Command_ModifySkill(client, sep); break; }
  5447. case COMMAND_MODIFY_SPAWN : { Command_ModifySpawn(client, sep); break; }
  5448. case COMMAND_MODIFY_SPELL : { Command_ModifySpell(client, sep); break; }
  5449. case COMMAND_MODIFY_ZONE : { Command_ModifyZone(client, sep); break; }
  5450. case COMMAND_JOIN_CHANNEL : { Command_JoinChannel(client, sep); break;}
  5451. case COMMAND_JOIN_CHANNEL_FROM_LOAD: { Command_JoinChannelFromLoad(client, sep); break;}
  5452. case COMMAND_TELL_CHANNEL : { Command_TellChannel(client, sep); break;}
  5453. case COMMAND_LEAVE_CHANNEL : { Command_LeaveChannel(client, sep); break;}
  5454. case COMMAND_WHO_CHANNEL : { Command_WhoChannel(client, sep); break;}
  5455. case COMMAND_RAIN : { Command_Rain(client, sep); break; }
  5456. case COMMAND_WIND : { Command_Wind(client, sep); break; }
  5457. case COMMAND_WEATHER : { Command_Weather(client, sep); break; }
  5458. case COMMAND_FROM_MERCHANT : { Command_SendMerchantWindow(client, sep); break; }
  5459. case COMMAND_TO_MERCHANT : { Command_SendMerchantWindow(client, sep, true); break; }
  5460. case COMMAND_SELECT : { Command_Select(client, sep); break; }
  5461. case COMMAND_SMP : { Command_StationMarketPlace(client, sep); break; }
  5462. case COMMAND_CONSUME_FOOD : { Command_ConsumeFood(client, sep); break; }
  5463. case COMMAND_SET_CONSUME_FOOD : { Command_ConsumeFood(client, sep); break; }
  5464. case COMMAND_AQUAMAN : { Command_Aquaman(client, sep); break; }
  5465. case COMMAND_ATTUNE_INV : { Command_Attune_Inv(client, sep); break; }
  5466. case COMMAND_PLAYER : { Command_Player(client, sep); break; }
  5467. case COMMAND_PLAYER_COINS : { Command_Player_Coins(client, sep); break; }
  5468. case COMMAND_RESET_ZONE_TIMER : { Command_Reset_Zone_Timer(client, sep); break; }
  5469. case COMMAND_ACHIEVEMENT_ADD : { Command_AchievementAdd(client, sep); break; }
  5470. case COMMAND_EDITOR : { Command_Editor(client, sep); break; }
  5471. case COMMAND_ACCEPT_RESURRECTION: { Command_AcceptResurrection(client, sep); break; }
  5472. case COMMAND_DECLINE_RESURRECTION:{ Command_DeclineResurrection(client, sep); break; }
  5473. case COMMAND_TEST : { Command_Test(client, command_parms); break; }
  5474. case COMMAND_SPEED : { Command_Speed(client, sep); break; }
  5475. case COMMAND_BOT : { Command_Bot(client, sep); break; }
  5476. case COMMAND_BOT_CREATE : { Command_Bot_Create(client, sep); break; }
  5477. case COMMAND_BOT_CUSTOMIZE : { Command_Bot_Customize(client, sep); break; }
  5478. case COMMAND_BOT_SPAWN : { Command_Bot_Spawn(client, sep); break; }
  5479. case COMMAND_BOT_LIST : { Command_Bot_List(client, sep); break; }
  5480. case COMMAND_BOT_INV : { Command_Bot_Inv(client, sep); break; }
  5481. case COMMAND_BOT_SETTINGS : { Command_Bot_Settings(client, sep); break; }
  5482. case COMMAND_BOT_HELP : { Command_Bot_Help(client, sep); break; }
  5483. case GET_AA_XML : { Get_AA_Xml(client, sep); break; }
  5484. case ADD_AA : { Add_AA(client, sep); break; }
  5485. case COMMIT_AA_PROFILE : { Commit_AA_Profile(client, sep); break; }
  5486. case BEGIN_AA_PROFILE : { Begin_AA_Profile(client, sep); break; }
  5487. case BACK_AA : { Back_AA(client, sep); break; }
  5488. case REMOVE_AA : { Remove_AA(client, sep); break; }
  5489. case SWITCH_AA_PROFILE : { Switch_AA_Profile(client, sep); break; }
  5490. case CANCEL_AA_PROFILE : { Cancel_AA_Profile(client, sep); break; }
  5491. case SAVE_AA_PROFILE : { Save_AA_Profile(client, sep); break; }
  5492. case COMMAND_TARGETITEM : { Command_TargetItem(client, sep); break; }
  5493. case COMMAND_FINDSPAWN: { Command_FindSpawn(client, sep); break; }
  5494. case COMMAND_MOVECHARACTER: { Command_MoveCharacter(client, sep); break; }
  5495. case COMMAND_CRAFTITEM: {
  5496. Item* item = 0;
  5497. if (sep && sep->IsNumber(0)) {
  5498. int32 item_id = atol(sep->arg[0]);
  5499. int32 quantity = 1;
  5500. if (sep->arg[1] && sep->IsNumber(1))
  5501. quantity = atoi(sep->arg[1]);
  5502. item = new Item(master_item_list.GetItem(item_id));
  5503. if (!item) {
  5504. LogWrite(TRADESKILL__ERROR, 0, "CraftItem", "Item (%u) not found.", item_id);
  5505. }
  5506. else {
  5507. item->details.count = quantity;
  5508. // use CHANNEL_COLOR_CHAT_RELATIONSHIP as that is the same value (4) as it is in a log for this message
  5509. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You created %s.", item->CreateItemLink(client->GetVersion()).c_str());
  5510. bool itemDeleted = false;
  5511. client->AddItem(item, &itemDeleted);
  5512. //Check for crafting quest updates
  5513. int8 update_amt = 0;
  5514. if (!itemDeleted && item->stack_count > 1)
  5515. update_amt = 1;
  5516. else
  5517. update_amt = quantity;
  5518. if(!itemDeleted)
  5519. client->GetPlayer()->CheckQuestsCraftUpdate(item, update_amt);
  5520. }
  5521. }
  5522. else {
  5523. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /craftitem {item_id} [quantity] ");
  5524. }
  5525. break;
  5526. }
  5527. case COMMAND_UNMENTOR:
  5528. case COMMAND_MENTOR: {
  5529. client->GetPlayer()->MentorTarget();
  5530. break;
  5531. }
  5532. case COMMAND_CANCEL_EFFECT: { Command_CancelEffect(client, sep); break; }
  5533. case COMMAND_CUREPLAYER: { Command_CurePlayer(client, sep); break; }
  5534. case COMMAND_SHARE_QUEST: { Command_ShareQuest(client, sep); break; }
  5535. case COMMAND_YELL: { Command_Yell(client, sep); break; }
  5536. case COMMAND_SETAUTOLOOTMODE: { Command_SetAutoLootMode(client, sep); break; }
  5537. case COMMAND_ASSIST: { Command_Assist(client, sep); break; }
  5538. case COMMAND_TARGET: { Command_Target(client, sep); break; }
  5539. case COMMAND_TARGET_PET: { Command_Target_Pet(client, sep); break; }
  5540. case COMMAND_WHOGROUP: { Command_WhoGroup(client, sep); break; }
  5541. case COMMAND_WHORAID: { Command_WhoRaid(client, sep); break; }
  5542. case COMMAND_RAIDINVITE: { Command_RaidInvite(client, sep); break; }
  5543. case COMMAND_RAID_LOOTER: { Command_Raid_Looter(client, sep); break; }
  5544. case COMMAND_KICKFROMGROUP: { Command_KickFromGroup(client, sep); break; }
  5545. case COMMAND_KICKFROMRAID: { Command_KickFromRaid(client, sep); break; }
  5546. case COMMAND_LEAVERAID: { Command_LeaveRaid(client, sep); break; }
  5547. case COMMAND_SPLIT: { Command_Split(client, sep); break; }
  5548. case COMMAND_RAIDSAY: { Command_RaidSay(client, sep); break; }
  5549. default:
  5550. {
  5551. LogWrite(COMMAND__WARNING, 0, "Command", "Unhandled command: %s", command->command.data.c_str());
  5552. break;
  5553. }
  5554. }
  5555. safe_delete(sep);
  5556. }
  5557. /******************** New COMMAND Handler Functions ********************/
  5558. /*
  5559. Started breaking apart the huge switch() for commands into sepErate
  5560. functions so it is easier to locate the blocks of code by command
  5561. -- JA 2012.03.03
  5562. */
  5563. // sample function header
  5564. /*
  5565. Function:
  5566. Purpose :
  5567. Params :
  5568. Dev :
  5569. Example :
  5570. */
  5571. //void Commands::Command()
  5572. //{
  5573. //}
  5574. /*
  5575. Function: Command_AcceptAdvancement()
  5576. Purpose : Player accepts a new advancement option
  5577. Params : Spell ID
  5578. Dev : Jabantiz
  5579. */
  5580. void Commands::Command_AcceptAdvancement(Client* client, Seperator* sep)
  5581. {
  5582. Player *player = client->GetPlayer();
  5583. if (sep && sep->IsSet(0)) {
  5584. int32 trait_id = atoul(sep->arg[0]);
  5585. TraitData* trait = nullptr;
  5586. if(client->GetVersion() <= 561) {
  5587. trait = master_trait_list.GetTraitByItemID(trait_id);
  5588. }
  5589. else {
  5590. trait = master_trait_list.GetTrait(trait_id);
  5591. }
  5592. if(!trait) {
  5593. LogWrite(COMMAND__ERROR, 0, "Command", "Invalid accept advancement of trait %u, no trait found.", trait_id);
  5594. return; // not valid lets not crash!
  5595. }
  5596. if(!master_trait_list.IsPlayerAllowedTrait(client, trait)) {
  5597. client->SimpleMessage(CHANNEL_COLOR_RED, "Not enough trait points to accept trait.");
  5598. return;
  5599. }
  5600. // Check to see if this is a trait or grandmaster training (traits are always new spells, training is always upgrades)
  5601. if (!player->HasSpell(trait->spellID, 0, true))
  5602. {
  5603. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  5604. if(spell) {
  5605. player->AddSpellBookEntry(trait->spellID, trait->tier, player->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  5606. }
  5607. else {
  5608. client->Message(CHANNEL_COLOR_RED, "ERROR! Trait is not a valid spell id %u may be disabled.", trait->spellID);
  5609. }
  5610. }
  5611. else
  5612. {
  5613. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  5614. if(spell) {
  5615. int8 old_slot = player->GetSpellSlot(spell->GetSpellID());
  5616. player->RemoveSpellBookEntry(spell->GetSpellID());
  5617. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  5618. player->UnlockSpell(spell);
  5619. client->SendSpellUpdate(spell);
  5620. }
  5621. else {
  5622. client->Message(CHANNEL_COLOR_RED, "ERROR! Trait is not a valid spell id %u may be disabled.", trait->spellID);
  5623. }
  5624. }
  5625. // Spell book update
  5626. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  5627. client->QueuePacket(master_trait_list.GetTraitListPacket(client));
  5628. if(client->GetVersion() <= 561) {
  5629. master_trait_list.ChooseNextTrait(client);
  5630. }
  5631. }
  5632. }
  5633. /*
  5634. Function:
  5635. Purpose :
  5636. Params :
  5637. Dev :
  5638. Example :
  5639. */
  5640. void Commands::Command_AFK(Client* client, Seperator* sep)
  5641. {
  5642. Player* player = client->GetPlayer();
  5643. player->toggle_character_flag(CF_AFK);
  5644. client->Message(CHANNEL_COLOR_YELLOW,"You are %s afk.", client->GetPlayer()->get_character_flag(CF_AFK)?"now":"no longer");
  5645. if (player->get_character_flag(CF_AFK))
  5646. {
  5647. if (sep && sep->argplus[0])
  5648. player->SetAwayMessage("I am away from the keyboard, " + string(sep->argplus[0]));
  5649. else
  5650. player->SetAwayMessage("Sorry, I am A.F.K. (Away From Keyboard)");
  5651. string message = string(player->GetName()) + " is going afk.";
  5652. Spawn* target = player->GetTarget();
  5653. if (target && target != player)
  5654. {
  5655. message = string(player->GetName()) + " tells " + string(target->GetName()) + " that ";
  5656. player->GetGender() == 1 ? message += "he" : message += "she";
  5657. message += " is going afk.";
  5658. }
  5659. player->GetZone()->SimpleMessage(CHANNEL_COLOR_YELLOW, message.c_str(), player, 30);
  5660. }
  5661. if (player->get_character_flag(CF_AFK))
  5662. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_AFK);
  5663. else
  5664. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_AFK);
  5665. }
  5666. /*
  5667. Function: Command_Appearance()
  5668. Purpose : Handles /appearance commands
  5669. Params : list
  5670. Dev : Scatman
  5671. Example : /appearance list
  5672. */
  5673. void Commands::Command_Appearance(Client* client, Seperator* sep, int handler)
  5674. {
  5675. if( handler == COMMAND_APPEARANCE )
  5676. {
  5677. // /appearance command by itself shows help (to be extended)
  5678. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  5679. return;
  5680. }
  5681. else if( handler == COMMAND_APPEARANCE_LIST )
  5682. {
  5683. // /appearance list command expects "name" param
  5684. if (sep && sep->arg[0])
  5685. {
  5686. const char* appearance_name = sep->argplus[0];
  5687. client->Message(CHANNEL_COLOR_YELLOW, "Listing appearances like '%s':", appearance_name);
  5688. vector<int16>* appearances = database.GetAppearanceIDsLikeName(string(appearance_name));
  5689. if (appearances)
  5690. {
  5691. vector<int16>::iterator itr;
  5692. for (itr = appearances->begin(); itr != appearances->end(); itr++)
  5693. {
  5694. int16 id = *itr;
  5695. string name = database.GetAppearanceName(id);
  5696. if (ToLower(name).find(ToLower(string(appearance_name))) < 0xFFFFFFFF)
  5697. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", name.c_str(), id);
  5698. }
  5699. safe_delete(appearances);
  5700. }
  5701. }
  5702. else // no param
  5703. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  5704. }
  5705. }
  5706. /*
  5707. Function: Command_Claim()
  5708. Purpose : Summon veteran rewards
  5709. Params : nothing = show claim window, any number claims that item.
  5710. Dev : devn00b
  5711. Example : /claim 0 (claims the 1st item added to the list claim[0])
  5712. */
  5713. void Commands::Command_Claim(Client* client, Seperator* sep)
  5714. {
  5715. //if we were passed a claim id
  5716. if (sep && sep->argplus[0] && sep->IsNumber(0))
  5717. {
  5718. int32 char_id = client->GetCharacterID();
  5719. int8 my_claim_id = atoi(sep->argplus[0]);
  5720. vector<ClaimItems> claim = database.LoadCharacterClaimItems(char_id);
  5721. Item* item = master_item_list.GetItem(claim[my_claim_id].item_id);
  5722. database.ClaimItem(char_id, item->details.item_id, client);
  5723. return;
  5724. }
  5725. else {
  5726. //if no arg just send the window.
  5727. client->ShowClaimWindow();
  5728. return;
  5729. }
  5730. return;
  5731. }
  5732. /*
  5733. Function: Command_ClearAllQueued()
  5734. Purpose :
  5735. Params :
  5736. Dev :
  5737. Example :
  5738. */
  5739. void Commands::Command_ClearAllQueued(Client* client)
  5740. {
  5741. ZoneServer* zone = client->GetPlayer()->GetZone();
  5742. if (zone && zone->GetSpellProcess())
  5743. zone->GetSpellProcess()->RemoveSpellFromQueue(client->GetPlayer());
  5744. }
  5745. /*
  5746. Function: Command_CancelMaintained()
  5747. Purpose : Cancels maintained spells
  5748. Params : Maintained Spell Index
  5749. Dev : Zcoretri
  5750. Example : /cancel_maintained 1 - would cancel the spell in slot 1 of Maintained Spells list
  5751. */
  5752. void Commands::Command_CancelMaintained(Client* client, Seperator* sep)
  5753. {
  5754. if (sep && sep->arg[0] && sep->IsNumber(0))
  5755. {
  5756. int32 spell_index = atoul(sep->arg[0]);
  5757. if(spell_index > 29)
  5758. return;
  5759. client->GetPlayer()->MMaintainedSpells.readlock(__FUNCTION__, __LINE__);
  5760. MaintainedEffects mEffects = client->GetPlayer()->GetInfoStruct()->maintained_effects[spell_index];
  5761. client->GetPlayer()->MMaintainedSpells.releasereadlock(__FUNCTION__, __LINE__);
  5762. if (!client->GetPlayer()->GetZone()->GetSpellProcess()->DeleteCasterSpell(mEffects.spell, "canceled", false))
  5763. client->Message(CHANNEL_COLOR_RED, "The maintained spell could not be cancelled.");
  5764. }
  5765. }
  5766. /*
  5767. Function: Command_Create()
  5768. Purpose : Handler for starting Tradeskilling table
  5769. Params :
  5770. Dev : Zcoretri
  5771. Example :
  5772. */
  5773. void Commands::Command_Create(Client* client, Seperator* sep)
  5774. {
  5775. PrintSep(sep, "COMMAND_CREATE");
  5776. client->ShowRecipeBook();
  5777. }
  5778. void Commands::Command_CreateFromRecipe(Client* client, Seperator* sep)
  5779. {
  5780. PrintSep(sep, "COMMAND_CREATEFROMRECIPE");
  5781. if (sep && sep->arg[0] && sep->IsNumber(0))
  5782. ClientPacketFunctions::SendCreateFromRecipe(client, atoul(sep->arg[0]));
  5783. }
  5784. /*
  5785. Function: Command_Distance()
  5786. Purpose : Displays distance from targeted spawn
  5787. Params :
  5788. Dev : Scatman
  5789. Example : /distance
  5790. */
  5791. void Commands::Command_Distance(Client* client)
  5792. {
  5793. Spawn* target = client->GetPlayer()->GetTarget();
  5794. if (target)
  5795. client->Message(CHANNEL_COLOR_YELLOW, "Your distance from %s is %f", target->GetName(), client->GetPlayer()->GetDistance(target));
  5796. else
  5797. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must have a spawn targeted to use /distance");
  5798. }
  5799. /*
  5800. Function: Command_Duel()
  5801. Purpose : Handle the /duel commands - not yet implemented
  5802. Params : unknown
  5803. Dev :
  5804. Example :
  5805. */
  5806. void Commands::Command_Duel(Client* client, Seperator* sep)
  5807. {
  5808. PrintSep(sep, "COMMAND_DUEL");
  5809. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Command");
  5810. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5811. }
  5812. /*
  5813. Function: Command_DuelBet()
  5814. Purpose : Handle the /duel commands - not yet implemented
  5815. Params : unknown
  5816. Dev :
  5817. Example :
  5818. */
  5819. void Commands::Command_DuelBet(Client* client, Seperator* sep)
  5820. {
  5821. PrintSep(sep, "COMMAND_DUELBET");
  5822. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Bet Command");
  5823. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5824. }
  5825. /*
  5826. Function: Command_DuelAccept()
  5827. Purpose : Handle the /duel commands - not yet implemented
  5828. Params : unknown
  5829. Dev :
  5830. Example :
  5831. */
  5832. void Commands::Command_DuelAccept(Client* client, Seperator* sep)
  5833. {
  5834. PrintSep(sep, "COMMAND_DUEL_ACCEPT");
  5835. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Accept Duel Command");
  5836. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5837. }
  5838. /*
  5839. Function: Command_DuelDecline()
  5840. Purpose : Handle the /duel commands - not yet implemented
  5841. Params : unknown
  5842. Dev :
  5843. Example :
  5844. */
  5845. void Commands::Command_DuelDecline(Client* client, Seperator* sep)
  5846. {
  5847. PrintSep(sep, "COMMAND_DUEL_DECLINE");
  5848. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Decline Duel Request Command");
  5849. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5850. }
  5851. /*
  5852. Function: Command_DuelSurrender()
  5853. Purpose : Handle the /duel commands - not yet implemented
  5854. Params : unknown
  5855. Dev :
  5856. Example :
  5857. */
  5858. void Commands::Command_DuelSurrender(Client* client, Seperator* sep)
  5859. {
  5860. PrintSep(sep, "COMMAND_DUEL_SURRENDER");
  5861. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Surrender Duel Command");
  5862. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5863. // JA, just messin around ;)
  5864. char surrender[64];
  5865. sprintf(surrender, "%s surrendered like a cowardly dog!", client->GetPlayer()->GetName());
  5866. zone_list.HandleGlobalAnnouncement(surrender);
  5867. }
  5868. /*
  5869. Function: Command_DuelToggle()
  5870. Purpose : Handle the /duel commands - not yet implemented
  5871. Params : unknown
  5872. Dev :
  5873. Example :
  5874. */
  5875. void Commands::Command_DuelToggle(Client* client, Seperator* sep)
  5876. {
  5877. PrintSep(sep, "COMMAND_DUEL");
  5878. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Commands");
  5879. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5880. }
  5881. /*
  5882. Function:
  5883. Purpose :
  5884. Params :
  5885. Dev :
  5886. Example :
  5887. */
  5888. void Commands::Command_EntityCommand(Client* client, Seperator* sep, int handler)
  5889. {
  5890. if( handler == COMMAND_ENTITYCOMMAND )
  5891. {
  5892. // /entitycommand command by itself shows help (to be extended)
  5893. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  5894. return;
  5895. }
  5896. else if( handler == COMMAND_ENTITYCOMMAND_LIST )
  5897. {
  5898. // /entitycommand list command expects "name" param
  5899. if (sep && sep->arg[0])
  5900. {
  5901. const char* entity_command_name = sep->argplus[0];
  5902. client->Message(CHANNEL_COLOR_YELLOW, "Listing entity commands like '%s':", entity_command_name);
  5903. map<int32, vector<EntityCommand*>*>* entity_command_list_all = client->GetCurrentZone()->GetEntityCommandListAll();
  5904. map<int32, vector<EntityCommand*>*>::iterator itr;
  5905. for (itr = entity_command_list_all->begin(); itr != entity_command_list_all->end(); itr++)
  5906. {
  5907. vector<EntityCommand*>* entity_command_list = itr->second;
  5908. vector<EntityCommand*>::iterator itr2;
  5909. for (itr2 = entity_command_list->begin(); itr2 != entity_command_list->end(); itr2++)
  5910. {
  5911. EntityCommand* entity_command = *itr2;
  5912. if (ToLower(entity_command->name).find(ToLower(string(entity_command_name))) < 0xFFFFFFFF)
  5913. 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);
  5914. }
  5915. }
  5916. }
  5917. else // no command name
  5918. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  5919. }
  5920. }
  5921. /*
  5922. Function: Command_Follow()
  5923. Purpose : Handle the /follow command - not yet implemented
  5924. Params :
  5925. Dev :
  5926. Example :
  5927. */
  5928. void Commands::Command_Follow(Client* client, Seperator* sep)
  5929. {
  5930. PrintSep(sep, "COMMAND_FOLLOW");
  5931. // flag to toggle if the players target is in the players group
  5932. bool targetInGroup = false;
  5933. // get a pointer to the players group
  5934. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  5935. // If the player has a group and has a target
  5936. if (gmi && client->GetPlayer()->GetTarget()) {
  5937. deque<GroupMemberInfo*>::iterator itr;
  5938. world.GetGroupManager()->GroupLock(__FUNCTION__, __LINE__);
  5939. PlayerGroup* group = world.GetGroupManager()->GetGroup(gmi->group_id);
  5940. if (group)
  5941. {
  5942. group->MGroupMembers.readlock(__FUNCTION__, __LINE__);
  5943. deque<GroupMemberInfo*>* members = group->GetMembers();
  5944. // Loop through the group members
  5945. for (itr = members->begin(); itr != members->end(); itr++) {
  5946. // If a group member matches a target
  5947. if ((*itr)->member && (*itr)->member == client->GetPlayer()->GetTarget()) {
  5948. // toggle the flag and break the loop
  5949. targetInGroup = true;
  5950. break;
  5951. }
  5952. }
  5953. group->MGroupMembers.releasereadlock(__FUNCTION__, __LINE__);
  5954. }
  5955. world.GetGroupManager()->ReleaseGroupLock(__FUNCTION__, __LINE__);
  5956. }
  5957. if (targetInGroup) {
  5958. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  5959. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You start to follow %s.", client->GetPlayer()->GetTarget()->GetName());
  5960. client->GetPlayer()->SetFollowTarget(client->GetPlayer()->GetTarget());
  5961. client->GetPlayer()->info_changed = true;
  5962. client->GetPlayer()->changed = true;
  5963. }
  5964. else
  5965. client->Message(CHANNEL_NARRATIVE, "You must first select a group member to follow.");
  5966. }
  5967. /*
  5968. Function: Command_StopFollow()
  5969. Purpose : Handle the /stop_follow command - not yet implemented
  5970. Params :
  5971. Dev :
  5972. Example :
  5973. */
  5974. void Commands::Command_StopFollow(Client* client, Seperator* sep)
  5975. {
  5976. PrintSep(sep, "COMMAND_STOP_FOLLOW");
  5977. if (client->GetPlayer()->GetFollowTarget()) {
  5978. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  5979. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You are no longer following %s", client->GetPlayer()->GetFollowTarget()->GetName());
  5980. client->GetPlayer()->SetFollowTarget(0);
  5981. client->GetPlayer()->info_changed = true;
  5982. client->GetPlayer()->changed = true;
  5983. }
  5984. }
  5985. /*
  5986. Function: Command_Grid()
  5987. Purpose : Show player's current Grid ID
  5988. Params :
  5989. Dev : Scatman
  5990. Example : /grid
  5991. */
  5992. void Commands::Command_Grid(Client* client, Seperator* sep)
  5993. {
  5994. if (client->GetPlayer()->GetMap() != nullptr) {
  5995. if(sep && sep->arg[0][0] && strncasecmp("spawns", sep->arg[0], 6) == 0) {
  5996. int32 grid = client->GetPlayer()->GetLocation();
  5997. if(sep->IsNumber(1))
  5998. grid = atoul(sep->arg[1]);
  5999. client->GetCurrentZone()->SendClientSpawnListInGrid(client, grid);
  6000. }
  6001. if(sep && sep->arg[0][0] && strncasecmp("boundary", sep->arg[0], 8) == 0) {
  6002. int32 grid = client->GetPlayer()->GetLocation();
  6003. if(sep->IsNumber(1))
  6004. grid = atoul(sep->arg[1]);
  6005. if(!client->GetPlayer()->GetMap()) {
  6006. client->Message(CHANNEL_COLOR_RED, "No map to check grid!");
  6007. return;
  6008. }
  6009. GridMapBorder* gmb = client->GetPlayer()->GetMap()->GetMapGridBorder(grid, false);
  6010. if(gmb) {
  6011. client->Message(CHANNEL_COLOR_YELLOW, "Grid %u border MinX %f MaxX %f, MinY %f MaxY %f, MinZ %f MaxZ %f", grid, gmb->m_MinX, gmb->m_MaxX, gmb->m_MinY, gmb->m_MaxY, gmb->m_MinZ, gmb->m_MaxZ);
  6012. }
  6013. else {
  6014. client->Message(CHANNEL_COLOR_RED, "Grid %u has no grid map border", grid);
  6015. }
  6016. }
  6017. else {
  6018. client->Message(CHANNEL_COLOR_YELLOW, "Your Grid ID is %u", client->GetPlayer()->GetLocation());
  6019. auto loc = glm::vec3(client->GetPlayer()->GetX(), client->GetPlayer()->GetZ(), client->GetPlayer()->GetY());
  6020. uint32 GridID = 0;
  6021. uint32 WidgetID = 0;
  6022. float new_z = client->GetPlayer()->FindBestZ(loc, nullptr, &GridID, &WidgetID);
  6023. float minY = client->GetPlayer()->GetMap()->GetMinY();
  6024. float maxY = client->GetPlayer()->GetMap()->GetMaxY();
  6025. float minZ = client->GetPlayer()->GetMap()->GetMinZ();
  6026. float maxZ = client->GetPlayer()->GetMap()->GetMaxZ();
  6027. int32 grid_spawn_count = client->GetPlayer()->GetZone()->GetSpawnCountInGrid(GridID);
  6028. 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);
  6029. }
  6030. }
  6031. }
  6032. /*
  6033. Function: Command_Guild()
  6034. Purpose : Handler for all UI-related guild commands
  6035. Dev : Scatman
  6036. */
  6037. void Commands::Command_Guild(Client* client, Seperator* sep)
  6038. {
  6039. Guild* guild = client->GetPlayer()->GetGuild();
  6040. if (sep && sep->GetMaxArgNum() > 0 && sep->arg[0])
  6041. {
  6042. const char* command = sep->arg[0];
  6043. int32 length = strlen(command);
  6044. LogWrite(COMMAND__DEBUG, 0, "Command", "Guild Command: %s", command);
  6045. if (strncmp(command, "rank_name", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && guild)
  6046. guild->SetRankName(atoi(sep->arg[1]), sep->argplus[2]);
  6047. else if (strncmp(command, "rank_permission", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild) {
  6048. guild->SetPermission(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  6049. peer_manager.sendPeersGuildPermission(guild->GetID(), atoul(sep->arg[1]), atoul(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  6050. }
  6051. else if (strncmp(command, "filter_event", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild) {
  6052. guild->SetEventFilter(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  6053. peer_manager.sendPeersGuildEventFilter(guild->GetID(), atoul(sep->arg[1]), atoul(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  6054. }
  6055. else if (strncmp(command, "kick", length) == 0 && sep->arg[1] && guild) {
  6056. int32 character_id = guild->KickGuildMember(client, sep->arg[1]);
  6057. if(character_id > 0) {
  6058. peer_manager.sendPeersRemoveGuildMember(character_id, guild->GetID(), std::string(client->GetPlayer()->GetName()));
  6059. }
  6060. }
  6061. else if (strncmp(command, "demote", length) == 0 && sep->arg[1] && guild)
  6062. guild->DemoteGuildMember(client, sep->arg[1]);
  6063. else if (strncmp(command, "promote", length) == 0 && sep->arg[1] && guild)
  6064. guild->PromoteGuildMember(client, sep->arg[1]);
  6065. else if (strncmp(command, "points", length) == 0 && guild)
  6066. {
  6067. if (sep->arg[1] && strncmp(sep->arg[1], "add", length) == 0)
  6068. {
  6069. if (sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  6070. {
  6071. float points = atof(sep->arg[2]);
  6072. const char* option = sep->arg[3];
  6073. const char* comment = sep->argplus[4];
  6074. if (strncmp(option, "all", strlen(option)) == 0)
  6075. guild->AddPointsToAll(client, points, comment);
  6076. else if (strncmp(option, "online", strlen(option)) == 0)
  6077. guild->AddPointsToAllOnline(client, points, comment);
  6078. else if (strncmp(option, "group", strlen(option)) == 0)
  6079. guild->AddPointsToGroup(client, points, comment);
  6080. else if (strncmp(option, "raid", strlen(option)) == 0)
  6081. guild->AddPointsToRaid(client, points, comment);
  6082. else
  6083. guild->AddPointsToGuildMember(client, points, option, comment);
  6084. }
  6085. }
  6086. else if (sep->arg[1] && strncmp(sep->arg[1], "view", strlen(sep->arg[1])) == 0 && sep->arg[2])
  6087. guild->ViewGuildMemberPoints(client, sep->arg[2]);
  6088. else
  6089. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild points command: %s", sep->argplus[0]);
  6090. }
  6091. else if (strncmp(command, "motd", length) == 0 && sep->arg[1] && guild)
  6092. guild->SetMOTD(sep->argplus[1]);
  6093. else if (strncmp(command, "recruiting", length) == 0 && guild)
  6094. {
  6095. if (sep->arg[1])
  6096. {
  6097. const char* option = sep->arg[1];
  6098. if (strncmp(option, "short_text", strlen(option)) == 0 && sep->arg[2])
  6099. guild->SetRecruitingShortDesc(sep->argplus[2]);
  6100. else if (strncmp(option, "long_text", strlen(option)) == 0 && sep->arg[2])
  6101. guild->SetRecruitingFullDesc(sep->argplus[2]);
  6102. else if (strncmp(option, "flag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  6103. guild->SetRecruitingFlag(atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  6104. else if (strncmp(option, "min_level", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  6105. guild->SetRecruitingMinLevel(atoi(sep->arg[2]));
  6106. else if (strncmp(option, "playstyle", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  6107. guild->SetRecruitingPlayStyle(atoi(sep->arg[2]));
  6108. else if (strncmp(option, "tag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && sep->IsNumber(3))
  6109. guild->SetRecruitingDescTag(atoi(sep->arg[2]), atoi(sep->arg[3]));
  6110. else if (strncmp(command, "recruiting", strlen(option)) == 0)
  6111. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_RECRUITING_FOR_GUILD, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  6112. else
  6113. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  6114. }
  6115. else
  6116. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  6117. }
  6118. else if (strncmp(command, "notify_online", length) == 0 && sep->arg[1] && guild)
  6119. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_NOTIFY_LOGINS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  6120. else if (strncmp(command, "event_privacy", length) == 0 && sep->arg[1] && guild)
  6121. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_DONT_GENERATE_EVENTS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  6122. else if (strncmp(command, "recruiter", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  6123. guild->SetGuildRecruiter(client, sep->arg[1], strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  6124. else if (strncmp(command, "recruiter_description", length) == 0 && sep->arg[1] && guild)
  6125. guild->SetGuildRecruiterDescription(client, sep->argplus[1]);
  6126. else if (strncmp(command, "lock_event", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  6127. guild->LockGuildEvent(atoul(sep->arg[1]), strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  6128. else if (strncmp(command, "delete_event", length) == 0 && sep->arg[1] && guild)
  6129. guild->DeleteGuildEvent(atoul(sep->arg[1]));
  6130. else if (strncmp(command, "invite", length) == 0 && guild)
  6131. {
  6132. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  6133. guild->InvitePlayer(client, sep->arg[1]);
  6134. else
  6135. {
  6136. Spawn* target = client->GetPlayer()->GetTarget();
  6137. if (target)
  6138. {
  6139. if (target->IsPlayer())
  6140. guild->InvitePlayer(client, target->GetName());
  6141. else
  6142. client->Message(CHANNEL_NARRATIVE, "%s is not a player.", target->GetName());
  6143. }
  6144. }
  6145. }
  6146. else if (strncmp(command, "accept", length) == 0)
  6147. {
  6148. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  6149. if (pgi && pgi->guild && pgi->invited_by)
  6150. pgi->guild->AddNewGuildMember(client, pgi->invited_by->GetName());
  6151. client->SetPendingGuildInvite(0);
  6152. }
  6153. else if (strncmp(command, "decline", length) == 0)
  6154. {
  6155. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  6156. if (pgi && pgi->guild && pgi->invited_by && pgi->invited_by->IsPlayer())
  6157. {
  6158. Client* client_inviter = ((Player*)pgi->invited_by)->GetClient();
  6159. if (client_inviter) {
  6160. client_inviter->Message(CHANNEL_NARRATIVE, "%s has declined your invitation to join %s.", client->GetPlayer()->GetName(), pgi->guild->GetName());
  6161. }
  6162. }
  6163. client->SetPendingGuildInvite(0);
  6164. }
  6165. else if (strncmp(command, "create", length) == 0 && sep->arg[1])
  6166. {
  6167. const char* guild_name = sep->argplus[1];
  6168. if(!guild_name || strlen(guild_name) < 4) {
  6169. client->SimpleMessage(CHANNEL_NARRATIVE, "Guild name is too short.");
  6170. }
  6171. else if (!guild_list.GetGuild(guild_name)) {
  6172. if(net.is_primary) {
  6173. int32 guildID = world.CreateGuild(guild_name, client, client->GetPlayer()->GetGroupMemberInfo() ? client->GetPlayer()->GetGroupMemberInfo()->group_id : 0);
  6174. if(guildID > 0)
  6175. peer_manager.sendPeersCreateGuild(guildID);
  6176. }
  6177. else {
  6178. peer_manager.sendPrimaryCreateGuildRequest(std::string(guild_name), std::string(client->GetPlayer()->GetName()));
  6179. }
  6180. }
  6181. else
  6182. client->SimpleMessage(CHANNEL_NARRATIVE, "A guild with that name already exists.");
  6183. }
  6184. else if (strncmp(command, "search", length) == 0)
  6185. client->ShowGuildSearchWindow();
  6186. else if (strncmp(command, "recruiting_details", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  6187. {
  6188. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  6189. if (to_guild)
  6190. to_guild->SendGuildRecruitingDetails(client);
  6191. }
  6192. else if (strncmp(command, "recruiting_image", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  6193. {
  6194. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  6195. if (to_guild)
  6196. to_guild->SendGuildRecruitingImages(client);
  6197. }
  6198. else if (strncmp(command, "recruiter_adventure_class", length) == 0)
  6199. {
  6200. if (sep->arg[1])
  6201. {
  6202. const char* option = sep->arg[1];
  6203. if (strncmp(option, "toggle", strlen(option)) == 0)
  6204. guild->ToggleGuildRecruiterAdventureClass(client);
  6205. }
  6206. else
  6207. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiter_adventure_class command: '%s'", sep->argplus[0]);
  6208. }
  6209. else if (strncmp(command, "display_heraldry", length) == 0)
  6210. {
  6211. // JA: not sure this is right...
  6212. client->GetPlayer()->toggle_character_flag(CF_SHOW_GUILD_HERALDRY);
  6213. client->GetPlayer()->SetCharSheetChanged(true);
  6214. }
  6215. else
  6216. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild command: '%s'", sep->argplus[0]);
  6217. }
  6218. }
  6219. /*
  6220. Function: Command_GuildCreate()
  6221. Purpose : Display's in-game Guild Creation window
  6222. Dev : Scatman
  6223. */
  6224. void Commands::Command_CreateGuild(Client* client)
  6225. {
  6226. client->SendGuildCreateWindow();
  6227. }
  6228. /*
  6229. Function: Command_SetGuildOfficerNote()
  6230. Purpose :
  6231. Dev : Scatman
  6232. */
  6233. void Commands::Command_SetGuildOfficerNote(Client* client, Seperator* sep)
  6234. {
  6235. if (sep && sep->arg[0] && sep->arg[1])
  6236. {
  6237. Guild* guild = client->GetPlayer()->GetGuild();
  6238. if (guild)
  6239. guild->SetGuildOfficerNote(sep->arg[0], sep->argplus[1]);
  6240. }
  6241. }
  6242. /*
  6243. Function: Command_SetGuildMemberNote()
  6244. Purpose :
  6245. Dev : Scatman
  6246. */
  6247. void Commands::Command_SetGuildMemberNote(Client* client, Seperator* sep)
  6248. {
  6249. if (sep && sep->arg[0] && sep->arg[1])
  6250. {
  6251. Guild* guild = client->GetPlayer()->GetGuild();
  6252. if (guild)
  6253. guild->SetGuildMemberNote(sep->arg[0], sep->argplus[1]);
  6254. }
  6255. }
  6256. /*
  6257. Function: Command_GuildSay()
  6258. Purpose :
  6259. Dev : Scatman
  6260. */
  6261. void Commands::Command_GuildSay(Client* client, Seperator* sep)
  6262. {
  6263. Guild* guild = client->GetPlayer()->GetGuild();
  6264. if (guild)
  6265. {
  6266. if (sep && sep->arg[0]) {
  6267. bool success = guild->HandleGuildSay(client, sep->argplus[0]);
  6268. if(success)
  6269. peer_manager.SendPeersGuildChannelMessage(guild->GetID(), std::string(client->GetPlayer()->GetName()), std::string(sep->argplus[0]), CHANNEL_GUILD_SAY, client->GetPlayer()->GetCurrentLanguage());
  6270. }
  6271. }
  6272. else
  6273. client->SimpleMessage(CHANNEL_NARRATIVE, "You are not a member of a guild");
  6274. }
  6275. /*
  6276. Function: Command_OfficerSay()
  6277. Purpose :
  6278. Dev : Scatman
  6279. */
  6280. void Commands::Command_OfficerSay(Client* client, Seperator* sep)
  6281. {
  6282. Guild* guild = client->GetPlayer()->GetGuild();
  6283. if (guild)
  6284. {
  6285. if (sep && sep->arg[0]) {
  6286. bool success = guild->HandleOfficerSay(client, sep->argplus[0]);
  6287. if(success)
  6288. peer_manager.SendPeersGuildChannelMessage(guild->GetID(), std::string(client->GetPlayer()->GetName()), std::string(sep->argplus[0]), CHANNEL_OFFICER_SAY, client->GetPlayer()->GetCurrentLanguage());
  6289. }
  6290. }
  6291. else
  6292. client->SimpleMessage(CHANNEL_NARRATIVE, "You are not a member of a guild");
  6293. }
  6294. /*
  6295. Function: Command_Guilds()
  6296. Purpose : Shows help for /guild command
  6297. Params :
  6298. Dev : Scatman
  6299. Example :
  6300. */
  6301. void Commands::Command_Guilds(Client* client)
  6302. {
  6303. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds [create|delete|add|remove|list]");
  6304. }
  6305. /*
  6306. Function: Command_GuildsAdd()
  6307. Purpose : Add's players to a guild
  6308. Params : guild_name|guild_id, player name
  6309. Dev : Scatman
  6310. Example : /guilds add 1 Admin = adds player Admin to guild_id 1
  6311. */
  6312. void Commands::Command_GuildsAdd(Client* client, Seperator* sep)
  6313. {
  6314. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  6315. {
  6316. Guild* guild = 0;
  6317. bool found = true;
  6318. if (sep->IsNumber(0))
  6319. {
  6320. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  6321. if (!guild)
  6322. {
  6323. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  6324. found = false;
  6325. }
  6326. }
  6327. else
  6328. {
  6329. guild = guild_list.GetGuild(sep->arg[0]);
  6330. if (!guild)
  6331. {
  6332. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  6333. found = false;
  6334. }
  6335. }
  6336. if (found)
  6337. {
  6338. Client* to_client = 0;
  6339. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  6340. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  6341. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  6342. to_client = ((Player*)client->GetPlayer()->GetTarget())->GetClient();
  6343. if (to_client)
  6344. guild->InvitePlayer(client, to_client->GetPlayer()->GetName());
  6345. else
  6346. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  6347. }
  6348. }
  6349. else
  6350. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds add [guild name|guild id] (player name).");
  6351. }
  6352. /*
  6353. Function: Command_GuildsCreate()
  6354. Purpose : Creates a guild
  6355. Params : guild_name, player_name (optional)
  6356. Dev : Scatman
  6357. Example : /guilds create [guild name] (player name)
  6358. */
  6359. void Commands::Command_GuildsCreate(Client* client, Seperator* sep)
  6360. {
  6361. if (sep && sep->arg[0])
  6362. {
  6363. const char* guild_name = sep->arg[0];
  6364. int8 resp = database.CheckNameFilter(guild_name, 4, 41);
  6365. if(!guild_name || resp == BADNAMELENGTH_REPLY) {
  6366. client->Message(CHANNEL_COLOR_YELLOW, "Guild name is too short.");
  6367. }
  6368. else if(resp == NAMEINVALID_REPLY || resp == NAMEFILTER_REPLY) {
  6369. client->Message(CHANNEL_COLOR_YELLOW, "Guild name was rejected.");
  6370. }
  6371. else if (!guild_list.GetGuild(guild_name))
  6372. {
  6373. bool ret = false;
  6374. if (sep->arg[1] && strlen(sep->arg[1]) > 0 && client->GetAdminStatus() > 0)
  6375. {
  6376. Client* to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  6377. if (to_client && !to_client->GetPlayer()->GetGuild())
  6378. {
  6379. if(net.is_primary) {
  6380. int32 guildID = world.CreateGuild(guild_name, to_client, to_client->GetPlayer()->GetGroupMemberInfo() ? to_client->GetPlayer()->GetGroupMemberInfo()->group_id : 0);
  6381. if(guildID > 0)
  6382. peer_manager.sendPeersCreateGuild(guildID);
  6383. }
  6384. else {
  6385. peer_manager.sendPrimaryCreateGuildRequest(std::string(guild_name), std::string(to_client->GetPlayer()->GetName()));
  6386. }
  6387. ret = true;
  6388. }
  6389. else {
  6390. client->Message(CHANNEL_COLOR_YELLOW, "Could not find target %s or target is already in a guild.", sep->arg[1]);
  6391. }
  6392. }
  6393. else if (client->GetAdminStatus() > 0 && client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  6394. {
  6395. Client* to_client = ((Player*)client->GetPlayer()->GetTarget())->GetClient();
  6396. if (to_client && !to_client->GetPlayer()->GetGuild())
  6397. {
  6398. if(net.is_primary) {
  6399. int32 guildID = world.CreateGuild(guild_name, to_client, to_client->GetPlayer()->GetGroupMemberInfo() ? to_client->GetPlayer()->GetGroupMemberInfo()->group_id : 0);
  6400. if(guildID > 0)
  6401. peer_manager.sendPeersCreateGuild(guildID);
  6402. }
  6403. else {
  6404. peer_manager.sendPrimaryCreateGuildRequest(std::string(guild_name), std::string(to_client->GetPlayer()->GetName()));
  6405. }
  6406. ret = true;
  6407. }
  6408. else {
  6409. client->Message(CHANNEL_COLOR_YELLOW, "Could not find target %s or target is already in a guild.", (to_client != nullptr) ? to_client->GetPlayer()->GetName() : "NoTarget");
  6410. }
  6411. }
  6412. else
  6413. {
  6414. if(client->GetPlayer()->GetGuild()) {
  6415. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are already in a guild.");
  6416. }
  6417. else if(net.is_primary) {
  6418. int32 guildID = world.CreateGuild(guild_name);
  6419. if(guildID > 0)
  6420. peer_manager.sendPeersCreateGuild(guildID);
  6421. }
  6422. else {
  6423. peer_manager.sendPrimaryCreateGuildRequest(std::string(guild_name), "");
  6424. }
  6425. ret = true;
  6426. }
  6427. if (ret)
  6428. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully created.", guild_name);
  6429. else
  6430. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the guild.");
  6431. }
  6432. else
  6433. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' already exists.", guild_name);
  6434. }
  6435. else
  6436. 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.");
  6437. }
  6438. /*
  6439. Function: Command_GuildsDelete()
  6440. Purpose : Delete's a guild
  6441. Params : guild name
  6442. Dev : Scatman
  6443. Example : /guilds delete Test
  6444. */
  6445. void Commands::Command_GuildsDelete(Client* client, Seperator* sep)
  6446. {
  6447. if (sep && sep->arg[0])
  6448. {
  6449. Guild* guild = 0;
  6450. bool found = true;
  6451. if (sep->IsNumber(0))
  6452. {
  6453. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  6454. if (!guild)
  6455. {
  6456. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  6457. found = false;
  6458. }
  6459. }
  6460. else
  6461. {
  6462. guild = guild_list.GetGuild(sep->arg[0]);
  6463. if (!guild)
  6464. {
  6465. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  6466. found = false;
  6467. }
  6468. }
  6469. if (found)
  6470. {
  6471. guild->RemoveAllGuildMembers();
  6472. database.DeleteGuild(guild);
  6473. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully deleted.", guild->GetName());
  6474. guild_list.RemoveGuild(guild, true);
  6475. }
  6476. }
  6477. else
  6478. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds delete [guild name].");
  6479. }
  6480. /*
  6481. Function: Command_GuildsList()
  6482. Purpose : Lists current guilds on server
  6483. Params :
  6484. Dev : Scatman
  6485. Example : /guilds list
  6486. */
  6487. void Commands::Command_GuildsList(Client* client)
  6488. {
  6489. MutexMap<int32, Guild*>* guilds = guild_list.GetGuilds();
  6490. MutexMap<int32, Guild*>::iterator itr = guilds->begin();
  6491. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Guild List:");
  6492. if (guilds->size() == 0)
  6493. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "None.");
  6494. else {
  6495. while (itr.Next()) {
  6496. Guild* guild = itr.second;
  6497. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", guild->GetID(), guild->GetName());
  6498. }
  6499. }
  6500. }
  6501. /*
  6502. Function: Command_GuildsRemove()
  6503. Purpose : Removes a player from a guild
  6504. Params : guild name|guild id, player name
  6505. Dev : Scatman
  6506. Example : /guilds remove 1 Admin = removes Admin from guild 1
  6507. */
  6508. void Commands::Command_GuildsRemove(Client* client, Seperator* sep)
  6509. {
  6510. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  6511. {
  6512. Guild* guild = 0;
  6513. bool found = true;
  6514. if (sep->IsNumber(0))
  6515. {
  6516. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  6517. if (!guild)
  6518. {
  6519. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  6520. found = false;
  6521. }
  6522. }
  6523. else
  6524. {
  6525. guild = guild_list.GetGuild(sep->arg[0]);
  6526. if (!guild)
  6527. {
  6528. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  6529. found = false;
  6530. }
  6531. }
  6532. if (found)
  6533. {
  6534. Client* to_client = 0;
  6535. char* charName = nullptr;
  6536. if(sep->arg[1][0])
  6537. charName = sep->arg[1];
  6538. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  6539. charName = ((Player*)client->GetPlayer()->GetTarget())->GetName();
  6540. else
  6541. {
  6542. client->Message(CHANNEL_COLOR_YELLOW, "Missing player name or not a valid target to remove from the guild.");
  6543. return;
  6544. }
  6545. int32 character_id = guild->KickGuildMember(client, charName);
  6546. if(character_id > 0)
  6547. peer_manager.sendPeersRemoveGuildMember(character_id, guild->GetID(), std::string(client->GetPlayer()->GetName()));
  6548. else
  6549. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to remove from the guild.", charName);
  6550. }
  6551. }
  6552. else
  6553. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds remove [guild name|guild id] (player name).");
  6554. }
  6555. /*
  6556. Function: Command_InspectPlayer()
  6557. Purpose : Handle the Inspect functions
  6558. Params : Client to inspect
  6559. Dev : Scatman
  6560. Example : /inspect Scatman
  6561. */
  6562. void Commands::Command_InspectPlayer(Client* client, Seperator* sep)
  6563. {
  6564. if (sep && sep->arg[0])
  6565. {
  6566. Client* inspect_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  6567. if (inspect_client)
  6568. client->InspectPlayer(inspect_client->GetPlayer());
  6569. }
  6570. else
  6571. {
  6572. Spawn* target = client->GetPlayer()->GetTarget();
  6573. if (target && target->IsPlayer())
  6574. client->InspectPlayer((Player*)target);
  6575. }
  6576. }
  6577. /*
  6578. Function: Command_Inventory()
  6579. Purpose : Handle changes in player inventory
  6580. Params : <TBD>
  6581. Dev : All
  6582. Example : /inventory delete item_id
  6583. */
  6584. void Commands::Command_Inventory(Client* client, Seperator* sep, EQ2_RemoteCommandString* command)
  6585. {
  6586. PrintSep(sep, "Command_Inventory"); // temp to figure out the params
  6587. Player* player = client->GetPlayer();
  6588. if(sep && sep->arg[0][0])
  6589. {
  6590. LogWrite(COMMAND__INFO, 0, "Command", "command: %s", sep->argplus[0]);
  6591. if(!client->GetPlayer()->Alive())
  6592. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  6593. else if(sep->arg[1][0] && strncasecmp("destroy", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  6594. {
  6595. int16 index = atoi(sep->arg[1]);
  6596. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  6597. if(item)
  6598. {
  6599. if(item->details.item_locked) {
  6600. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot destroy the item in use.");
  6601. return;
  6602. }
  6603. else if(item->IsBag() && item->details.equip_slot_id) {
  6604. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot destroy the item, it is being used as quiver.");
  6605. return;
  6606. }
  6607. else if(item->CheckFlag(NO_DESTROY)) {
  6608. client->SimpleMessage(CHANNEL_COLOR_RED, "You can't destroy this item.");
  6609. return;
  6610. }
  6611. if(item->GetItemScript() && lua_interface)
  6612. lua_interface->RunItemScript(item->GetItemScript(), "destroyed", item, client->GetPlayer());
  6613. //reobtain item make sure it wasn't removed
  6614. item = player->item_list.GetItemFromIndex(index);
  6615. int32 bag_id = 0;
  6616. if(item){
  6617. bag_id = item->details.inv_slot_id;
  6618. database.DeleteItem(client->GetCharacterID(), item, 0);
  6619. }
  6620. client->GetPlayer()->item_list.DestroyItem(index);
  6621. client->GetPlayer()->UpdateInventory(bag_id);
  6622. client->GetPlayer()->CalculateApplyWeight();
  6623. }
  6624. }
  6625. 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))
  6626. {
  6627. int16 from_index = atoi(sep->arg[1]);
  6628. sint16 to_slot = atoi(sep->arg[2]); // don't convert slot since this is inventory not equipment
  6629. sint32 bag_id = atol(sep->arg[3]);
  6630. int8 charges = atoi(sep->arg[4]);
  6631. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(from_index);
  6632. if(!item) {
  6633. client->SimpleMessage(CHANNEL_COLOR_RED, "You have no item.");
  6634. return;
  6635. }
  6636. if(to_slot == item->details.slot_id && (bag_id < 0 || bag_id == item->details.inv_slot_id)) {
  6637. return;
  6638. }
  6639. if(item->details.item_locked)
  6640. {
  6641. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot move the item in use.");
  6642. return;
  6643. }
  6644. if(bag_id == -4 && !client->GetPlayer()->item_list.SharedBankAddAllowed(item))
  6645. {
  6646. client->SimpleMessage(CHANNEL_COLOR_RED, "That item (or an item inside) cannot be shared.");
  6647. return;
  6648. }
  6649. sint32 old_inventory_id = 0;
  6650. if(item)
  6651. old_inventory_id = item->details.inv_slot_id;
  6652. //autobank
  6653. if (bag_id == -3 && to_slot == -1)
  6654. {
  6655. if (player->HasFreeBankSlot())
  6656. to_slot = player->FindFreeBankSlot();
  6657. else
  6658. {
  6659. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free bank slots.");
  6660. return;
  6661. }
  6662. }
  6663. //auto inventory
  6664. if (bag_id == 0 && to_slot == -1)
  6665. {
  6666. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  6667. {
  6668. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free slots.");
  6669. return;
  6670. }
  6671. }
  6672. bool item_deleted = false;
  6673. EQ2Packet* outapp = client->GetPlayer()->MoveInventoryItem(bag_id, from_index, (int8)to_slot, charges, 0, &item_deleted, client->GetVersion());
  6674. client->QueuePacket(outapp);
  6675. if(item_deleted)
  6676. item = nullptr;
  6677. //removed from bag send update
  6678. if(old_inventory_id > 0 && item && item->details.inv_slot_id != old_inventory_id)
  6679. {
  6680. outapp = client->GetPlayer()->SendBagUpdate(old_inventory_id, client->GetVersion());
  6681. if(outapp)
  6682. client->QueuePacket(outapp);
  6683. }
  6684. if(item && item->details.inv_slot_id > 0 && item->details.inv_slot_id != old_inventory_id)
  6685. {
  6686. outapp = client->GetPlayer()->SendBagUpdate(item->details.inv_slot_id, client->GetVersion());
  6687. if(outapp)
  6688. client->QueuePacket(outapp);
  6689. }
  6690. client->GetPlayer()->CalculateApplyWeight();
  6691. }
  6692. else if(sep->arg[1][0] && strncasecmp("equip", sep->arg[0], 5) == 0 && sep->IsNumber(1))
  6693. {
  6694. int16 index = atoi(sep->arg[1]);
  6695. int8 slot_id = 255;
  6696. int8 unk3 = 0;
  6697. int8 appearance_equip = 0;
  6698. if(sep->arg[2][0] && sep->IsNumber(2))
  6699. slot_id = player->ConvertSlotFromClient(atoi(sep->arg[2]), client->GetVersion());
  6700. if(sep->arg[3][0] && sep->IsNumber(3))
  6701. unk3 = atoul(sep->arg[3]);
  6702. if(sep->arg[4][0] && sep->IsNumber(4))
  6703. appearance_equip = atoul(sep->arg[4]);
  6704. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), appearance_equip, slot_id);
  6705. EQ2Packet* outapp = 0;
  6706. for(int32 i=0;i<packets.size();i++)
  6707. {
  6708. outapp = packets[i];
  6709. if(outapp)
  6710. client->QueuePacket(outapp);
  6711. }
  6712. client->GetPlayer()->UpdateWeapons();
  6713. EQ2Packet* characterSheetPackets = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion());
  6714. client->QueuePacket(characterSheetPackets);
  6715. }
  6716. else if (sep->arg[1][0] && strncasecmp("unpack", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  6717. {
  6718. if (client->GetPlayer()->EngagedInCombat())
  6719. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unpack items while in combat.");
  6720. else {
  6721. int16 index = atoi(sep->arg[1]);
  6722. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  6723. if (item) {
  6724. if(item->details.item_locked)
  6725. {
  6726. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot unpack the item in use.");
  6727. return;
  6728. }
  6729. // client->GetPlayer()->item_list.DestroyItem(index);
  6730. if (item->item_sets.size() > 0) {
  6731. for (int32 i = 0; i < item->item_sets.size(); i++) {
  6732. ItemSet* set = item->item_sets[i];
  6733. if (set->item_stack_size == 0)
  6734. set->item_stack_size += 1;
  6735. client->AddItem(set->item_id, set->item_stack_size);
  6736. }
  6737. }
  6738. }
  6739. client->RemoveItem(item, 1);
  6740. }
  6741. }
  6742. else if(sep->arg[1][0] && strncasecmp("unequip", sep->arg[0], 7) == 0 && sep->IsNumber(1))
  6743. {
  6744. int16 index = player->ConvertSlotFromClient(atoi(sep->arg[1]), client->GetVersion());
  6745. sint32 bag_id = -999;
  6746. int8 to_slot = 255;
  6747. if(sep->arg[3][0])
  6748. {
  6749. if(sep->IsNumber(2))
  6750. bag_id = atol(sep->arg[2]);
  6751. if(sep->IsNumber(3))
  6752. to_slot = atoi(sep->arg[3]);
  6753. }
  6754. sint8 unk4 = 0;
  6755. int8 appearance_equip = 0;
  6756. if(sep->arg[4][0] && sep->IsNumber(4))
  6757. unk4 = atoi(sep->arg[4]);
  6758. if(sep->arg[5][0] && sep->IsNumber(5))
  6759. appearance_equip = atoul(sep->arg[5]);
  6760. vector<EQ2Packet*> packets = client->GetPlayer()->UnequipItem(index, bag_id, to_slot, client->GetVersion(), appearance_equip);
  6761. EQ2Packet* outapp = 0;
  6762. for(int32 i=0;i<packets.size();i++)
  6763. {
  6764. outapp = packets[i];
  6765. if(outapp)
  6766. client->QueuePacket(outapp);
  6767. }
  6768. client->UnequipItem(index, bag_id, to_slot, appearance_equip);
  6769. }
  6770. else if(sep->arg[2][0] && strncasecmp("swap_equip", sep->arg[0], 10) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  6771. {
  6772. if(client->GetPlayer()->EngagedInCombat() && rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Player, AllowPlayerEquipCombat)->GetInt8() == 0) {
  6773. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not swap items while in combat.");
  6774. }
  6775. else {
  6776. int16 index1 = client->GetPlayer()->ConvertSlotFromClient(atoi(sep->arg[1]), client->GetVersion());
  6777. int16 index2 = client->GetPlayer()->ConvertSlotFromClient(atoi(sep->arg[2]), client->GetVersion());
  6778. int8 type = 0;
  6779. if(sep->IsNumber(3))
  6780. type = atoul(sep->arg[3]); // type 0 is combat, 3 = appearance
  6781. EQ2Packet* outapp = client->GetPlayer()->SwapEquippedItems(index1, index2, client->GetVersion(), type);
  6782. if(outapp)
  6783. client->QueuePacket(outapp);
  6784. else
  6785. {
  6786. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to swap items");
  6787. return;
  6788. }
  6789. }
  6790. }
  6791. else if (sep->arg[2][0] && strncasecmp("pop", sep->arg[0], 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  6792. {
  6793. sint16 to_slot = atoi(sep->arg[1]);
  6794. sint32 bag_id = atoi(sep->arg[2]);
  6795. Item* item = client->GetPlayer()->item_list.GetOverflowItem();
  6796. if (item) {
  6797. //auto inventory
  6798. if (bag_id == 0 && to_slot == -1)
  6799. {
  6800. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  6801. {
  6802. client->SimpleMessage(CHANNEL_ERROR, "You do not have any free slots.");
  6803. return;
  6804. }
  6805. // Set the slot for the item
  6806. item->details.inv_slot_id = bag_id;
  6807. item->details.slot_id = to_slot;
  6808. // Flag the item so it gets saved in its new location
  6809. item->save_needed = true;
  6810. // Add the item to its new location
  6811. if(player->item_list.AddItem(item)) {
  6812. // Remove the item from the overflow list
  6813. player->item_list.RemoveOverflowItem(item);
  6814. }
  6815. // Send the inventory update packet
  6816. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  6817. return;
  6818. }
  6819. else if (bag_id == -3 && to_slot == -1) {
  6820. // Auto Bank
  6821. if (!player->item_list.GetFirstFreeBankSlot(&bag_id, &to_slot)) {
  6822. client->SimpleMessage(CHANNEL_STATUS, "You do not have any free bank slots.");
  6823. return;
  6824. }
  6825. item->details.inv_slot_id = bag_id;
  6826. item->details.slot_id = to_slot;
  6827. item->save_needed = true;
  6828. if(player->item_list.AddItem(item)) {
  6829. player->item_list.RemoveOverflowItem(item);
  6830. }
  6831. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  6832. }
  6833. else if (bag_id == -4) {
  6834. // Shared Bank
  6835. if (!player->item_list.SharedBankAddAllowed(item)) {
  6836. client->SimpleMessage(CHANNEL_STATUS, "That item (or an item inside) cannot be shared.");
  6837. return;
  6838. }
  6839. Item* tmp_item = player->item_list.GetItem(-4, to_slot);
  6840. if (tmp_item) {
  6841. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  6842. return;
  6843. }
  6844. else {
  6845. item->details.inv_slot_id = bag_id;
  6846. item->details.slot_id = to_slot;
  6847. item->save_needed = true;
  6848. if(player->item_list.AddItem(item)) {
  6849. player->item_list.RemoveOverflowItem(item);
  6850. }
  6851. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  6852. return;
  6853. }
  6854. }
  6855. else {
  6856. // Try to get an item from the given bag id and slot id
  6857. Item* tmp_item = player->item_list.GetItem(bag_id, to_slot);
  6858. // Check to see if we got an item, if we do send an error,
  6859. // if we don't put the overflow item into this slot
  6860. if (tmp_item) {
  6861. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  6862. }
  6863. else {
  6864. item->details.inv_slot_id = bag_id;
  6865. item->details.slot_id = to_slot;
  6866. item->save_needed = true;
  6867. if(player->item_list.AddItem(item)) {
  6868. player->item_list.RemoveOverflowItem(item);
  6869. }
  6870. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  6871. return;
  6872. }
  6873. }
  6874. }
  6875. }
  6876. else if(sep->arg[2][0] && strncasecmp("nosale", sep->arg[0], 6) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  6877. {
  6878. sint64 data = strtoull(sep->arg[1], NULL, 0);
  6879. int32 character_item_id = (int32) (data >> 32);
  6880. int32 item_id = (int32) (data & 0xffffffffL);
  6881. int8 sale_setting = atoi(sep->arg[2]);
  6882. Item* item = client->GetPlayer()->item_list.GetItemFromUniqueID(character_item_id);
  6883. if(item)
  6884. {
  6885. item->no_sale = sale_setting;
  6886. item->save_needed = true;
  6887. client->SendSellMerchantList();
  6888. }
  6889. }
  6890. }
  6891. else
  6892. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /inventory {destroy|move|equip|unequip|swap_equip|pop} {item_id} [to_slot] [bag_id]");
  6893. }
  6894. /*
  6895. Function: Command_Languages()
  6896. Purpose : Show's languages the player knows
  6897. Params :
  6898. Dev : Zcoretri
  6899. Example :
  6900. */
  6901. void Commands::Command_Languages(Client* client, Seperator* sep)
  6902. {
  6903. list<Language*>* languages = client->GetPlayer()->GetPlayerLanguages()->GetAllLanguages();
  6904. list<Language*>::iterator itr;
  6905. Language* language;
  6906. client->Message(CHANNEL_NARRATIVE, "You know the following languages:");
  6907. for(itr = languages->begin(); itr != languages->end(); itr++)
  6908. {
  6909. language = *itr;
  6910. client->Message(CHANNEL_NARRATIVE, "%s", language->GetName());
  6911. }
  6912. }
  6913. /*
  6914. Function: Command_SetLanguage()
  6915. Purpose : Handles language commands
  6916. Params : Language ID
  6917. Dev : Zcoretri
  6918. Example :
  6919. */
  6920. void Commands::Command_SetLanguage(Client* client, Seperator* sep)
  6921. {
  6922. Player* player = client->GetPlayer();
  6923. if (sep && sep->arg[0])
  6924. {
  6925. if(!sep->IsNumber(0))
  6926. {
  6927. //String passed in
  6928. const char* value = sep->arg[0];
  6929. if(strncasecmp(value, "Common", strlen(value)) == 0)
  6930. {
  6931. database.SaveCharacterCurrentLang(0, client->GetCharacterID(), client);
  6932. client->SendLanguagesUpdate(0);
  6933. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", value);
  6934. }
  6935. else
  6936. {
  6937. if(player->HasLanguage(value))
  6938. {
  6939. Language* language = player->GetPlayerLanguages()->GetLanguageByName(value);
  6940. database.SaveCharacterCurrentLang(language->GetID(), client->GetCharacterID(), client);
  6941. client->SendLanguagesUpdate(language->GetID());
  6942. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", language->GetName());
  6943. }
  6944. else
  6945. client->Message(CHANNEL_NARRATIVE, "You do not know how to speak %s", value);
  6946. }
  6947. }
  6948. else
  6949. {
  6950. //Number passed in
  6951. int32 id = atoul(sep->arg[0]);
  6952. if(player->HasLanguage(id))
  6953. {
  6954. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  6955. database.SaveCharacterCurrentLang(id, client->GetCharacterID(), client);
  6956. client->SendLanguagesUpdate(id);
  6957. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", language->GetName());
  6958. }
  6959. else
  6960. {
  6961. Language* language = master_languages_list.GetLanguage(id);
  6962. if(language)
  6963. client->Message(CHANNEL_NARRATIVE, "You do not know how to speak %s", language->GetName());
  6964. }
  6965. }
  6966. }
  6967. else
  6968. {
  6969. //No value was passed in
  6970. int32 id = database.GetCharacterCurrentLang(client->GetCharacterID(), player);
  6971. if(id > 0)
  6972. {
  6973. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  6974. client->Message(CHANNEL_NARRATIVE, "You are currently speaking %s ", language->GetName());
  6975. }
  6976. else
  6977. client->Message(CHANNEL_NARRATIVE, "You are currently speaking Common");
  6978. }
  6979. }
  6980. /*
  6981. Function: Command_LastName()
  6982. Purpose : Sets player surname
  6983. Params : Name text
  6984. Dev : theFoof
  6985. Example :
  6986. */
  6987. void Commands::Command_LastName(Client* client, Seperator* sep)
  6988. {
  6989. if (!client)
  6990. return;
  6991. if (sep && sep->arg[0])
  6992. {
  6993. if (!client->GetPlayer()->get_character_flag(CF_ENABLE_CHANGE_LASTNAME)){
  6994. client->Message(CHANNEL_COLOR_YELLOW, "You must be atleast level %i to change your last name.", rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Player, MinLastNameLevel)->GetInt8());
  6995. return;
  6996. }
  6997. client->RemovePendingLastName();
  6998. uchar* checkname = (uchar*)sep->arg[0];
  6999. bool valid_name = true;
  7000. for (int32 i = 0; i < strlen(sep->arg[0]); i++) {
  7001. if (!alpha_check(checkname[i])) {
  7002. valid_name = false;
  7003. break;
  7004. }
  7005. }
  7006. if (!valid_name) {
  7007. client->Message(CHANNEL_COLOR_YELLOW, "Your last name can only contain letters.", rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Player, MinLastNameLevel)->GetInt8());
  7008. return;
  7009. }
  7010. string last_name = (string)sep->arg[0];
  7011. int8 max_length = rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Player, MaxLastNameLength)->GetInt8();
  7012. int8 min_length = rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Player, MinLastNameLength)->GetInt8();
  7013. if (last_name.length() <= max_length && last_name.length() >= min_length){
  7014. client->SetPendingLastName(last_name);
  7015. client->SendLastNameConfirmation();
  7016. }
  7017. else
  7018. client->Message(CHANNEL_COLOR_YELLOW, "Your last name must be between %i and %i characters long.", min_length, max_length);
  7019. }
  7020. }
  7021. /*
  7022. Function: Command_ConfirmLastName()
  7023. Purpose : Confirms setting of player surname
  7024. Params : Name text
  7025. Dev : theFoof
  7026. Example :
  7027. */
  7028. void Commands::Command_ConfirmLastName(Client* client, Seperator* sep)
  7029. {
  7030. if (!client)
  7031. return;
  7032. string* name = client->GetPendingLastName();
  7033. if (name){
  7034. Player* player = client->GetPlayer();
  7035. player->SetLastName(name->c_str(), false);
  7036. client->SendTitleUpdate();
  7037. player->SetCharSheetChanged(true);
  7038. client->RemovePendingLastName();
  7039. }
  7040. }
  7041. /*
  7042. Function: Command_Location()
  7043. Purpose : Display's Help for /location commands
  7044. Params :
  7045. Dev : Scatman
  7046. Example : /location = show's help for command
  7047. */
  7048. void Commands::Command_Location(Client* client)
  7049. {
  7050. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Valid /location commands are:");
  7051. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location create [name] (include y). Include y defaults to false");
  7052. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location add [location id]");
  7053. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location remove [location point id]");
  7054. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location delete [location id]");
  7055. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location list [locations|points] [location id if points used]");
  7056. }
  7057. /*
  7058. Function: Command_LocationAdd()
  7059. Purpose : Add's a location to an existing location config
  7060. Params : location_id
  7061. Dev : Scatman
  7062. Example : /location add {location_id}
  7063. */
  7064. void Commands::Command_LocationAdd(Client* client, Seperator* sep)
  7065. {
  7066. if (sep && sep->arg[0] && sep->IsNumber(0))
  7067. {
  7068. int32 location_id = atoul(sep->arg[0]);
  7069. float x = client->GetPlayer()->GetX();
  7070. float y = client->GetPlayer()->GetY();
  7071. float z = client->GetPlayer()->GetZ();
  7072. if (database.AddLocationPoint(location_id, x, y, z))
  7073. client->Message(CHANNEL_COLOR_YELLOW, "Point (%f, %f, %f) was successfully added to location %u", x, y, z, location_id);
  7074. else
  7075. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist. Use /location create to create one", location_id);
  7076. }
  7077. else
  7078. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location add [location id]");
  7079. }
  7080. /*
  7081. Function: Command_LocationCreate()
  7082. Purpose : Creates a new location config
  7083. Params : location name, 0/1 for include_y (optional)
  7084. Dev : Scatman
  7085. Example : /location create Test 1 = creates a new location named Test with include_y True
  7086. */
  7087. void Commands::Command_LocationCreate(Client* client, Seperator* sep)
  7088. {
  7089. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  7090. {
  7091. const char* name = sep->arg[0];
  7092. bool include_y = false;
  7093. if (sep->arg[1] && sep->IsNumber(1) && atoi(sep->arg[1]) > 0)
  7094. include_y = true;
  7095. int32 location_id = database.CreateLocation(client->GetPlayer()->GetZone()->GetZoneID(), client->GetPlayer()->GetLocation(), name, include_y);
  7096. if (location_id > 0)
  7097. client->Message(CHANNEL_COLOR_YELLOW, "Location '%s' was successfully created with location id %u", name, location_id);
  7098. else
  7099. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the requested location");
  7100. }
  7101. else
  7102. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location create [name] (include_y). Include y defaults to false");
  7103. }
  7104. /*
  7105. Function: Command_LocationDelete()
  7106. Purpose : Delete's a location config and all it's location points
  7107. Params : location_id
  7108. Dev : Scatman
  7109. Example : /location delete {location_id}
  7110. */
  7111. void Commands::Command_LocationDelete(Client* client, Seperator* sep)
  7112. {
  7113. if (sep && sep->arg[0] && sep->IsNumber(0))
  7114. {
  7115. int32 location_id = atoul(sep->arg[0]);
  7116. if (database.DeleteLocation(location_id))
  7117. client->Message(CHANNEL_COLOR_YELLOW, "Location id %u and all its points were successfully deleted", location_id);
  7118. else
  7119. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist", location_id);
  7120. }
  7121. else
  7122. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location delete [location id]");
  7123. }
  7124. /*
  7125. Function: Command_LocationList()
  7126. Purpose : Display's a list of location points
  7127. Params : location_id
  7128. Dev : Scatman
  7129. Example : /location list {location_id}
  7130. */
  7131. void Commands::Command_LocationList(Client* client, Seperator* sep)
  7132. {
  7133. if (sep && sep->arg[0])
  7134. {
  7135. const char* option = sep->arg[0];
  7136. if (strncmp(option, "locations", strlen(option)) == 0)
  7137. database.ListLocations(client);
  7138. else if (strncmp(option, "points", strlen(option)) == 0 && sep->arg[1] && sep->IsNumber(1))
  7139. {
  7140. int32 location_id = atoul(sep->arg[1]);
  7141. database.ListLocationPoints(client, location_id);
  7142. }
  7143. else
  7144. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  7145. }
  7146. else
  7147. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  7148. }
  7149. /*
  7150. Function: Command_LocationRemove()
  7151. Purpose : Removes a single location point from a location config
  7152. Params : location_point_id (gotten from /location list {id})
  7153. Dev : Scatman
  7154. Example : /location remove 1 = will remove location_point_id 1
  7155. */
  7156. void Commands::Command_LocationRemove(Client* client, Seperator* sep)
  7157. {
  7158. if (sep && sep->arg[0] && sep->IsNumber(0))
  7159. {
  7160. int32 location_point_id = atoul(sep->arg[0]);
  7161. if (database.DeleteLocationPoint(location_point_id))
  7162. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Location point was successfully deleted");
  7163. else
  7164. client->Message(CHANNEL_COLOR_YELLOW, "Location point with ID %u does not exist", location_point_id);
  7165. }
  7166. else
  7167. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location remove [location point id]");
  7168. }
  7169. /*
  7170. Function: Command_Merchant()
  7171. Purpose : Handles Merchant commands
  7172. Params : list
  7173. Dev : Scatman
  7174. Example : /merchant list
  7175. */
  7176. void Commands::Command_Merchant(Client* client, Seperator* sep, int handler)
  7177. {
  7178. if( handler == COMMAND_MERCHANT )
  7179. {
  7180. // /merchant command by itself shows help (to be extended)
  7181. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  7182. return;
  7183. }
  7184. else if( handler == COMMAND_MERCHANT_LIST )
  7185. {
  7186. // /merchant list command expects "description" param
  7187. if (sep && sep->arg[0])
  7188. {
  7189. const char* merchant_description = sep->argplus[0];
  7190. client->Message(CHANNEL_COLOR_YELLOW, "Listing merchants like '%s':", merchant_description);
  7191. map<int32, MerchantInfo*>* merchant_info = world.GetMerchantInfo();
  7192. map<int32, MerchantInfo*>::iterator itr;
  7193. for (itr = merchant_info->begin(); itr != merchant_info->end(); itr++)
  7194. {
  7195. string description = database.GetMerchantDescription(itr->first);
  7196. if (ToLower(description).find(ToLower(string(merchant_description))) < 0xFFFFFFFF)
  7197. client->Message(CHANNEL_COLOR_YELLOW, "Merchant ID: %u, Description: %s", itr->first, description.c_str());
  7198. }
  7199. }
  7200. else // no description
  7201. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  7202. }
  7203. }
  7204. /*
  7205. Function: Command_Modify()
  7206. Purpose : to replace our other "set" commands
  7207. Params : System = the system to modify, Action = the action to perform, Target = what to change (target, or index)
  7208. Dev : John Adams
  7209. Example : /modify spell set name "Aegolism III"
  7210. */
  7211. void Commands::Command_Modify(Client* client)
  7212. {
  7213. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /modify [system] [action] [field] [value] {target|id}");
  7214. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Systems: character, faction, guild, item, skill, spawn, spell, zone");
  7215. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Actions: set, create, delete, add, remove");
  7216. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Value : field name in the table being modified");
  7217. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target : modify current target, or specified {system} ID");
  7218. }
  7219. /*
  7220. Function: Command_ModifySpawn()
  7221. Purpose : replace "spawn set" commands
  7222. Params : Action : the action to perform (or special handler)
  7223. : Field : the DB field to change
  7224. : Value : what to set the value to
  7225. : Target : what object to change (my target, or spawn_id)
  7226. Dev : John Adams
  7227. Example : /modify spawn set name "Lady Vox"
  7228. :
  7229. Note : Special Handlers, like "zoneto" for Signs
  7230. : /modify spawn zoneto
  7231. : Will set a sign's zone x/y/z to my current coords
  7232. */
  7233. void Commands::Command_ModifySpawn(Client* client, Seperator* sep)
  7234. {
  7235. PrintSep(sep, "COMMAND_MODIFY");
  7236. // need at least 2 args for a valid command
  7237. if( sep && sep->arg[1] )
  7238. {
  7239. // JA: just a quick implementation because I need it :)
  7240. if (strcmp(sep->arg[0], "zoneto") == 0)
  7241. {
  7242. if( sep->IsNumber(1) )
  7243. {
  7244. int32 spawn_id = atoul(sep->arg[1]);
  7245. float x_coord = client->GetPlayer()->GetX();
  7246. float y_coord = client->GetPlayer()->GetY();
  7247. float z_coord = client->GetPlayer()->GetZ();
  7248. float h_coord = client->GetPlayer()->GetHeading();
  7249. database.SaveSignZoneToCoords(spawn_id, x_coord, y_coord, z_coord, h_coord);
  7250. }
  7251. else
  7252. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify spawn zoneto spawn_id - sets spawn_id to your coords");
  7253. }
  7254. }
  7255. else
  7256. Command_Modify(client);
  7257. }
  7258. /*
  7259. Function: Command_ModifyCharacter()
  7260. Purpose : to replace our other "set" commands
  7261. Params : Action : Add, Remove
  7262. : Field : copper, silver, gold, plat
  7263. : Value : min 1, max unlimited
  7264. : Target : Self, Player
  7265. Dev : Cynnar
  7266. Example : /modify character add gold 50
  7267. : /modify character remove silver 25
  7268. */
  7269. void Commands::Command_ModifyCharacter(Client* client, Seperator* sep)
  7270. {
  7271. PrintSep(sep, "COMMAND_MODIFY");
  7272. int64 value = 0;
  7273. Player* player = client->GetPlayer();
  7274. Client* targetClient = client;
  7275. if (player->HasTarget() && player->GetTarget()->IsPlayer()) {
  7276. player = (Player*)player->GetTarget();
  7277. targetClient = player->GetClient();
  7278. }
  7279. // need at least 2 args for a valid command
  7280. if( sep && sep->arg[1] )
  7281. {
  7282. if (strcmp(sep->arg[0], "add") == 0)
  7283. {
  7284. if (strcmp(sep->arg[1], "copper") == 0)
  7285. {
  7286. value = atoi64(sep->arg[2]);
  7287. player->AddCoins(value);
  7288. if (client->GetPlayer() == player)
  7289. {
  7290. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu copper coin%s", value, (value > 1 ? "s" : ""));
  7291. }
  7292. else {
  7293. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu copper coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  7294. if(targetClient) {
  7295. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu copper coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  7296. }
  7297. }
  7298. }
  7299. else if (strcmp(sep->arg[1], "silver") == 0)
  7300. {
  7301. value = atoi64(sep->arg[2]) * 100;
  7302. player->AddCoins(value);
  7303. if (client->GetPlayer() == player)
  7304. {
  7305. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu silver coin%s", value / 100, (value > 1 ? "s" : ""));
  7306. }
  7307. else {
  7308. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu silver coin%s", player->GetName(), value / 100, (value > 1 ? "s" : ""));
  7309. if(targetClient) {
  7310. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu silver coin%s", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  7311. }
  7312. }
  7313. }
  7314. else if (strcmp(sep->arg[1], "gold") == 0)
  7315. {
  7316. value = atoi64(sep->arg[2]) * 10000;
  7317. player->AddCoins(value);
  7318. if (client->GetPlayer() == player)
  7319. {
  7320. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu gold coin%s", value / 10000, (value > 1 ? "s" : ""));
  7321. }
  7322. else {
  7323. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu gold coin%s", player->GetName(), value / 10000, (value > 1 ? "s" : ""));
  7324. if(targetClient) {
  7325. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu gold coin%s", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  7326. }
  7327. }
  7328. }
  7329. else if (strcmp(sep->arg[1], "plat") == 0)
  7330. {
  7331. value = atoi64(sep->arg[2]) * 1000000;
  7332. player->AddCoins(value);
  7333. if (client->GetPlayer() == player)
  7334. {
  7335. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu platinum coin%s", value / 1000000, (value > 1 ? "s" : ""));
  7336. }
  7337. else {
  7338. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu platinum coin%s", player->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  7339. if(targetClient) {
  7340. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu platinum coin%s", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  7341. }
  7342. }
  7343. }
  7344. else
  7345. {
  7346. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  7347. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  7348. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  7349. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character add copper 20");
  7350. }
  7351. }
  7352. else if (strcmp(sep->arg[0], "remove") == 0)
  7353. {
  7354. if (strcmp(sep->arg[1], "copper") == 0)
  7355. {
  7356. value = atoi64(sep->arg[2]);
  7357. player->RemoveCoins(value);
  7358. if (client->GetPlayer() == player)
  7359. {
  7360. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from yourself", value, (value > 1 ? "s" : ""));
  7361. }
  7362. else {
  7363. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from %s", value, (value > 1 ? "s" : ""), player->GetName());
  7364. if(targetClient) {
  7365. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu copper coin%s from you", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  7366. }
  7367. }
  7368. }
  7369. else if (strcmp(sep->arg[1], "silver") == 0)
  7370. {
  7371. value = atoi64(sep->arg[2]) * 100;
  7372. player->RemoveCoins(value);
  7373. if (client->GetPlayer() == player)
  7374. {
  7375. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from yourself", value / 100, (value > 1 ? "s" : ""));
  7376. }
  7377. else {
  7378. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from %s", value / 100, (value > 1 ? "s" : ""), player->GetName());
  7379. if(targetClient) {
  7380. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu silver coin%s from you", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  7381. }
  7382. }
  7383. }
  7384. else if (strcmp(sep->arg[1], "gold") == 0)
  7385. {
  7386. value = atoi64(sep->arg[2]) * 10000;
  7387. player->RemoveCoins(value);
  7388. if (client->GetPlayer() == player)
  7389. {
  7390. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from yourself", value / 10000, (value > 1 ? "s" : ""));
  7391. }
  7392. else {
  7393. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from %s", value / 10000, (value > 1 ? "s" : ""), player->GetName());
  7394. if(targetClient) {
  7395. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu gold coin%s from you", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  7396. }
  7397. }
  7398. }
  7399. else if (strcmp(sep->arg[1], "plat") == 0)
  7400. {
  7401. value = atoi64(sep->arg[2]) * 1000000;
  7402. player->RemoveCoins(value);
  7403. if (client->GetPlayer() == player)
  7404. {
  7405. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from yourself", value / 1000000, (value > 1 ? "s" : ""));
  7406. }
  7407. else {
  7408. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from %s", value / 1000000, (value > 1 ? "s" : ""), player->GetName());
  7409. if(targetClient) {
  7410. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu platinum coin%s from you", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  7411. }
  7412. }
  7413. }
  7414. else
  7415. {
  7416. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  7417. }
  7418. }
  7419. else if (strcmp(sep->arg[0], "set") == 0) {
  7420. if (strcmp(sep->arg[1], "tslevel") == 0) {
  7421. int8 level = atoi(sep->arg[2]);
  7422. if (level > 0 && level < 256) {
  7423. if (player) {
  7424. if (client->GetPlayer() == player)
  7425. client->ChangeTSLevel(player->GetTSLevel(), level);
  7426. else if(targetClient)
  7427. targetClient->ChangeTSLevel(player->GetTSLevel(), level);
  7428. }
  7429. }
  7430. else
  7431. client->SimpleMessage(CHANNEL_ERROR, "Level must be between 1 - 255");
  7432. }
  7433. else if (strcmp(sep->arg[1], "tsclass") == 0) {
  7434. int8 tsclass = atoi(sep->arg[2]);
  7435. player->SetTradeskillClass(tsclass);
  7436. player->GetInfoStruct()->set_tradeskill_class1(classes.GetTSBaseClass(player->GetTradeskillClass()));
  7437. player->GetInfoStruct()->set_tradeskill_class2(classes.GetSecondaryTSBaseClass(player->GetTradeskillClass()));
  7438. player->GetInfoStruct()->set_tradeskill_class3(player->GetTradeskillClass());
  7439. player->SetCharSheetChanged(true);
  7440. }
  7441. else if (strcmp(sep->arg[1], "gender") == 0) {
  7442. int8 gender = atoi(sep->arg[2]);
  7443. client->GetPlayer()->GetInfoStruct()->set_gender(gender);
  7444. client->GetPlayer()->SetCharSheetChanged(true);
  7445. client->UpdateTimeStampFlag ( GENDER_UPDATE_FLAG );
  7446. }
  7447. }
  7448. }
  7449. else
  7450. {
  7451. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  7452. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  7453. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  7454. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  7455. }
  7456. }
  7457. void Commands::Command_ModifyFaction(Client* client, Seperator* sep)
  7458. {
  7459. PrintSep(sep, "COMMAND_MODIFY");
  7460. // need at least 2 args for a valid command
  7461. if( sep && sep->arg[1] )
  7462. {
  7463. }
  7464. else
  7465. Command_Modify(client);
  7466. }
  7467. void Commands::Command_ModifyGuild(Client* client, Seperator* sep)
  7468. {
  7469. PrintSep(sep, "COMMAND_MODIFY");
  7470. // need at least 2 args for a valid command
  7471. if( sep && sep->arg[1] )
  7472. {
  7473. }
  7474. else
  7475. Command_Modify(client);
  7476. }
  7477. void Commands::Command_ModifyItem(Client* client, Seperator* sep)
  7478. {
  7479. PrintSep(sep, "COMMAND_MODIFY");
  7480. // need at least 2 args for a valid command
  7481. if( sep && sep->arg[1] )
  7482. {
  7483. }
  7484. else
  7485. Command_Modify(client);
  7486. }
  7487. /*
  7488. Function: Command_ModifyQuest()
  7489. Purpose : to list players quest and completed quests
  7490. Params : Action : list, completed
  7491. : Target : Self, Player
  7492. Dev : Cynnar
  7493. Example : /modify quest list
  7494. : /modify quest completed
  7495. */
  7496. void Commands::Command_ModifyQuest(Client* client, Seperator* sep)
  7497. {
  7498. PrintSep(sep, "COMMAND_MODIFY");
  7499. int64 value = 0;
  7500. Player* player = client->GetPlayer();
  7501. Client* targetClient = client;
  7502. if (player->HasTarget() && player->GetTarget()->IsPlayer()) {
  7503. player = (Player*)player->GetTarget();
  7504. targetClient = player->GetClient();
  7505. }
  7506. // need at least 2 args for a valid command
  7507. if (sep && sep->arg[1])
  7508. {
  7509. if (strcmp(sep->arg[0], "list") == 0)
  7510. {
  7511. map<int32, Quest*>* quests = player->GetPlayerQuests();
  7512. map<int32, Quest*>::iterator itr;
  7513. client->Message(CHANNEL_COLOR_YELLOW, "%s's Quest List:.", client->GetPlayer()->GetName());
  7514. if (quests->size() == 0)
  7515. client->Message(CHANNEL_COLOR_YELLOW, "%s has no quests.", client->GetPlayer()->GetName());
  7516. else
  7517. {
  7518. for (itr = quests->begin(); itr != quests->end(); itr++)
  7519. {
  7520. Quest* quest = itr->second;
  7521. if(quest) {
  7522. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  7523. }
  7524. }
  7525. }
  7526. }
  7527. else if (strcmp(sep->arg[0], "completed") == 0)
  7528. {
  7529. map<int32, Quest*>* quests = player->GetCompletedPlayerQuests();
  7530. map<int32, Quest*>::iterator itr;
  7531. client->Message(CHANNEL_COLOR_YELLOW, "%s's Completed Quest List:.", client->GetPlayer()->GetName());
  7532. if (quests->size() == 0)
  7533. client->Message(CHANNEL_COLOR_YELLOW, "%s has no completed quests.", client->GetPlayer()->GetName());
  7534. else
  7535. {
  7536. for (itr = quests->begin(); itr != quests->end(); itr++)
  7537. {
  7538. Quest* quest = itr->second;
  7539. if(quest) {
  7540. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  7541. }
  7542. }
  7543. }
  7544. }
  7545. // Add in a progress step, and a LogWrite() for tracking GM Commands.
  7546. // LogWrite(LUA__DEBUG, 0, "LUA", "Quest: %s, function: %s", quest->GetName(), function);
  7547. else if (strcmp(sep->arg[0], "remove") == 0)
  7548. {
  7549. int32 quest_id = 0;
  7550. if (sep && sep->arg[1] && sep->IsNumber(1))
  7551. quest_id = atoul(sep->arg[1]);
  7552. if (quest_id > 0)
  7553. {
  7554. if (lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0)
  7555. {
  7556. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  7557. if (quest)
  7558. if (client->GetPlayer() == player)
  7559. {
  7560. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been removed from your journal", quest->GetName());
  7561. }
  7562. else
  7563. {
  7564. client->Message(CHANNEL_COLOR_YELLOW, "You have removed the quest %s from %s's journal", quest->GetName(), player->GetName());
  7565. if(targetClient) {
  7566. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s has removed the quest %s from your journal", client->GetPlayer()->GetName(), quest->GetName());
  7567. }
  7568. }
  7569. LogWrite(COMMAND__INFO, 0, "GM Command", "%s removed the quest %s from %s", client->GetPlayer()->GetName(), quest->GetName(), player->GetName());
  7570. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  7571. }
  7572. client->RemovePlayerQuest(quest_id);
  7573. client->GetCurrentZone()->SendQuestUpdates(client);
  7574. }
  7575. }
  7576. else if (strcmp(sep->arg[0], "advance") == 0)
  7577. {
  7578. int32 quest_id = 0;
  7579. int32 step = 0;
  7580. if (sep && sep->arg[1] && sep->IsNumber(1))
  7581. {
  7582. quest_id = atoul(sep->arg[1]);
  7583. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  7584. if(!quest) {
  7585. client->Message(CHANNEL_COLOR_RED, "Quest not found!");
  7586. return;
  7587. }
  7588. if (sep && sep->arg[2] && sep->IsNumber(1))
  7589. {
  7590. step = atoul(sep->arg[2]);
  7591. if (quest_id > 0 && step > 0)
  7592. {
  7593. if (player && player->IsPlayer() && quest_id > 0 && step > 0 && (player->player_quests.count(quest_id) > 0))
  7594. {
  7595. if (client)
  7596. {
  7597. client->AddPendingQuestUpdate(quest_id, step);
  7598. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been advanced one step.", quest->GetName());
  7599. LogWrite(COMMAND__INFO, 0, "GM Command", "%s advanced the quest %s one step", client->GetPlayer()->GetName(), quest->GetName());
  7600. }
  7601. }
  7602. }
  7603. else
  7604. {
  7605. client->Message(CHANNEL_COLOR_RED, "Quest ID and Step Number must be greater than 0!");
  7606. }
  7607. }
  7608. else
  7609. {
  7610. client->Message(CHANNEL_COLOR_RED, "Step Number must be a number!");
  7611. }
  7612. }
  7613. else
  7614. {
  7615. client->Message(CHANNEL_COLOR_RED, "Quest ID must be a number!");
  7616. }
  7617. }
  7618. else
  7619. {
  7620. Command_Modify(client);
  7621. }
  7622. }
  7623. else
  7624. {
  7625. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify quest [action] [quest id] [step number]");
  7626. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: list, completed, remove, advance");
  7627. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest list");
  7628. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest remove 156");
  7629. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest advance 50 1");
  7630. }
  7631. }
  7632. void Commands::Command_ModifySkill(Client* client, Seperator* sep)
  7633. {
  7634. PrintSep(sep, "COMMAND_MODIFY");
  7635. // need at least 2 args for a valid command
  7636. if( sep && sep->arg[1] )
  7637. {
  7638. if (strcmp(sep->arg[0], "add") == 0) {
  7639. const char* skill_name = sep->argplus[1];
  7640. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  7641. if (skill) {
  7642. Player* player = 0;
  7643. Client* to_client = 0;
  7644. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  7645. player = (Player*)client->GetPlayer()->GetTarget();
  7646. to_client = player->GetClient();
  7647. }
  7648. else {
  7649. player = client->GetPlayer();
  7650. to_client = client;
  7651. }
  7652. if (player)
  7653. {
  7654. if (!player->GetSkills()->HasSkill(skill->skill_id))
  7655. {
  7656. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  7657. if (to_client == client) {
  7658. client->Message(CHANNEL_STATUS, "Added skill '%s'.", skill_name);
  7659. }
  7660. else {
  7661. client->Message(CHANNEL_STATUS, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  7662. to_client->Message(CHANNEL_STATUS, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  7663. }
  7664. }
  7665. else
  7666. client->Message(CHANNEL_STATUS, "%s already has the skill '%s'.", to_client == client ? "You" : player->GetName(), skill_name);
  7667. }
  7668. }
  7669. else
  7670. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  7671. }
  7672. else if (strcmp(sep->arg[0], "remove") == 0) {
  7673. const char* skill_name = sep->argplus[1];
  7674. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  7675. if (skill) {
  7676. Player* player = 0;
  7677. Client* to_client = 0;
  7678. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  7679. player = (Player*)client->GetPlayer()->GetTarget();
  7680. to_client = player->GetClient();
  7681. }
  7682. else {
  7683. player = client->GetPlayer();
  7684. to_client = client;
  7685. }
  7686. if (player)
  7687. {
  7688. if (player->GetSkills()->HasSkill(skill->skill_id))
  7689. {
  7690. player->RemoveSkillFromDB(skill, true);
  7691. if (client == to_client) {
  7692. client->Message(CHANNEL_STATUS, "Removed skill '%s'.", skill_name);
  7693. }
  7694. else {
  7695. client->Message(CHANNEL_STATUS, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  7696. if(to_client) {
  7697. to_client->Message(CHANNEL_STATUS, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  7698. }
  7699. }
  7700. }
  7701. else {
  7702. if (client == to_client)
  7703. client->Message(CHANNEL_STATUS, "You do not have the skill '%s'.", skill_name);
  7704. else
  7705. client->Message(CHANNEL_STATUS, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  7706. }
  7707. }
  7708. }
  7709. else
  7710. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  7711. }
  7712. else if (strcmp(sep->arg[0], "set") == 0) {
  7713. if (!sep->IsNumber(2)) {
  7714. client->Message(CHANNEL_STATUS, "The last parameter must be a number.");
  7715. return;
  7716. }
  7717. const char* skill_name = sep->arg[1];
  7718. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  7719. if (skill) {
  7720. int16 val = atoi(sep->arg[2]);
  7721. Player* player = 0;
  7722. Client* to_client = 0;
  7723. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  7724. player = (Player*)client->GetPlayer()->GetTarget();
  7725. to_client = player->GetClient();
  7726. }
  7727. else {
  7728. player = client->GetPlayer();
  7729. to_client = client;
  7730. }
  7731. if (player)
  7732. {
  7733. if (player->GetSkills()->HasSkill(skill->skill_id)) {
  7734. player->GetSkills()->SetSkill(skill->skill_id, val);
  7735. if (client != to_client)
  7736. client->Message(CHANNEL_STATUS, "You set %s's '%s' skill to %i.", player->GetName(), skill_name, val);
  7737. if(to_client) {
  7738. to_client->Message(CHANNEL_STATUS, "Your '%s' skill has been set to %i.", skill_name, val);
  7739. }
  7740. }
  7741. else {
  7742. client->Message(CHANNEL_STATUS, "Target does not have the skill '%s'.", skill_name);
  7743. }
  7744. }
  7745. }
  7746. else {
  7747. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  7748. }
  7749. }
  7750. else {
  7751. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  7752. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  7753. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  7754. }
  7755. }
  7756. else {
  7757. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  7758. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  7759. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  7760. }
  7761. }
  7762. void Commands::Command_ModifySpell(Client* client, Seperator* sep)
  7763. {
  7764. PrintSep(sep, "COMMAND_MODIFY");
  7765. // need at least 2 args for a valid command
  7766. if( sep && sep->arg[1] )
  7767. {
  7768. }
  7769. else
  7770. Command_Modify(client);
  7771. }
  7772. void Commands::Command_ModifyZone(Client* client, Seperator* sep)
  7773. {
  7774. PrintSep(sep, "COMMAND_MODIFY");
  7775. // need at least 2 args for a valid command
  7776. if( sep && sep->arg[1] )
  7777. {
  7778. }
  7779. else
  7780. Command_Modify(client);
  7781. }
  7782. /*
  7783. Function: Command_MOTD()
  7784. Purpose : Displays server MOTD
  7785. Params :
  7786. Dev : LethalEncounter
  7787. Example : /motd
  7788. */
  7789. void Commands::Command_MOTD(Client* client)
  7790. {
  7791. if (client)
  7792. ClientPacketFunctions::SendMOTD(client);
  7793. }
  7794. /*
  7795. Function: Command_Pet()
  7796. Purpose : Handle Pet {Command} commands
  7797. Params : attack, backoff, preserve_master, preserve_self, follow, stay, getlost
  7798. Dev :
  7799. Example : /pet preserve_master
  7800. */
  7801. void Commands::Command_Pet(Client* client, Seperator* sep)
  7802. {
  7803. PrintSep(sep, "COMMAND_PET");
  7804. //LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Pet Commands");
  7805. //client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7806. if (!sep || !sep->arg[0])
  7807. return; // should have sep->arg[0] filled
  7808. if (strcmp(sep->arg[0], "hide") == 0) {
  7809. // doing /pet hide will toggle the hide status on all the pets that can be hidden
  7810. Entity* pet = client->GetPlayer()->GetDeityPet();
  7811. if (pet) {
  7812. if (pet->IsPrivateSpawn())
  7813. client->GetPlayer()->HideDeityPet(false);
  7814. else
  7815. client->GetPlayer()->HideDeityPet(true);
  7816. }
  7817. pet = client->GetPlayer()->GetCosmeticPet();
  7818. if (pet) {
  7819. if (pet->IsPrivateSpawn())
  7820. client->GetPlayer()->HideCosmeticPet(false);
  7821. else
  7822. client->GetPlayer()->HideCosmeticPet(true);
  7823. }
  7824. return;
  7825. }
  7826. // below is for all combat pets
  7827. if (!client->GetPlayer()->HasPet()) {
  7828. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a pet.");
  7829. return;
  7830. }
  7831. if (strcmp(sep->arg[0], "stay") == 0 || strcmp(sep->arg[0], "stayhere") == 0) {
  7832. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to stay.");
  7833. client->GetPlayer()->GetInfoStruct()->set_pet_movement(1);
  7834. client->GetPlayer()->SetCharSheetChanged(true);
  7835. if (client->GetPlayer()->GetPet())
  7836. client->GetPlayer()->GetPet()->following = false;
  7837. if (client->GetPlayer()->GetCharmedPet())
  7838. client->GetPlayer()->GetCharmedPet()->following = false;
  7839. }
  7840. else if (strcmp(sep->arg[0], "follow") == 0 || strcmp(sep->arg[0], "followme") == 0) {
  7841. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to follow.");
  7842. client->GetPlayer()->GetInfoStruct()->set_pet_movement(2);
  7843. client->GetPlayer()->SetCharSheetChanged(true);
  7844. }
  7845. else if (strcmp(sep->arg[0], "preserve_master") == 0 || strcmp(sep->arg[0], "guardme") == 0) {
  7846. if (client->GetPlayer()->GetInfoStruct()->get_pet_behavior() & 1) {
  7847. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect you.");
  7848. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()-1);
  7849. }
  7850. else {
  7851. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect you.");
  7852. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()+1);
  7853. }
  7854. client->GetPlayer()->SetCharSheetChanged(true);
  7855. }
  7856. else if (strcmp(sep->arg[0], "preserve_self") == 0 || strcmp(sep->arg[0], "guardhere") == 0) { // guardhere might be accurate, diff logic
  7857. if (client->GetPlayer()->GetInfoStruct()->get_pet_behavior() & 2) {
  7858. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect itself.");
  7859. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()-2);
  7860. }
  7861. else {
  7862. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect itself.");
  7863. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()+2);
  7864. }
  7865. client->GetPlayer()->SetCharSheetChanged(true);
  7866. }
  7867. else if (strcmp(sep->arg[0], "backoff") == 0) {
  7868. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to back down.");
  7869. if (client->GetPlayer()->GetPet())
  7870. ((NPC*)client->GetPlayer()->GetPet())->Brain()->ClearHate();
  7871. if (client->GetPlayer()->GetCharmedPet())
  7872. ((NPC*)client->GetPlayer()->GetCharmedPet())->Brain()->ClearHate();
  7873. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(0);
  7874. client->GetPlayer()->SetCharSheetChanged(true);
  7875. }
  7876. else if (strcmp(sep->arg[0], "attack") == 0) {
  7877. if (client->GetPlayer()->HasTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  7878. if (client->GetPlayer()->AttackAllowed((Entity*)client->GetPlayer()->GetTarget())){
  7879. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to attack your target.");
  7880. if (client->GetPlayer()->GetPet())
  7881. client->GetPlayer()->GetPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  7882. if (client->GetPlayer()->GetCharmedPet())
  7883. client->GetPlayer()->GetCharmedPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  7884. }
  7885. else
  7886. client->Message(CHANNEL_COLOR_YELLOW, "You can not attack that.");
  7887. }
  7888. else
  7889. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a target.");
  7890. }
  7891. else if (strcmp(sep->arg[0], "getlost") == 0) {
  7892. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetPet());
  7893. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetCharmedPet());
  7894. client->Message(CHANNEL_COLOR_YELLOW, "You tell your pet to get lost.");
  7895. }
  7896. else
  7897. client->Message(CHANNEL_COLOR_YELLOW, "Unknown pet command %s.", sep->arg[0]);
  7898. }
  7899. /*
  7900. Function: Command_PetName()
  7901. Purpose : Pet your name (???)
  7902. Params :
  7903. Dev :
  7904. Example :
  7905. */
  7906. void Commands::Command_PetName(Client* client, Seperator* sep)
  7907. {
  7908. if (sep && sep->arg[0]) {
  7909. const char* pet_name = sep->argplus[0];
  7910. client->SetPetName(pet_name);
  7911. }
  7912. else {
  7913. client->GetPlayer()->GetInfoStruct()->set_pet_name("");
  7914. }
  7915. }
  7916. /*
  7917. Function: Command_NamePet()
  7918. Purpose : Name your pet
  7919. Params :
  7920. Dev :
  7921. Example :
  7922. */
  7923. void Commands::Command_NamePet(Client* client, Seperator* sep)
  7924. {
  7925. PrintSep(sep, "COMMAND_NAME_PET");
  7926. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Name Pet Command");
  7927. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7928. }
  7929. /*
  7930. Function: Command_Rename()
  7931. Purpose : Renames existing pet
  7932. Params :
  7933. Dev :
  7934. Example :
  7935. */
  7936. void Commands::Command_Rename(Client* client, Seperator* sep)
  7937. {
  7938. PrintSep(sep, "COMMAND_RENAME");
  7939. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Rename Pet Command");
  7940. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7941. }
  7942. /*
  7943. Function: Command_ConfirmRename()
  7944. Purpose : Confirms renaming your pet
  7945. Params :
  7946. Dev :
  7947. Example :
  7948. */
  7949. void Commands::Command_ConfirmRename(Client* client, Seperator* sep)
  7950. {
  7951. PrintSep(sep, "COMMAND_CONFIRMRENAME");
  7952. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Confirm Rename Pet Command");
  7953. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7954. }
  7955. /*
  7956. Function: Command_PetOptions()
  7957. Purpose : Sets various pet options
  7958. Params :
  7959. Dev :
  7960. Example :
  7961. */
  7962. void Commands::Command_PetOptions(Client* client, Seperator* sep)
  7963. {
  7964. PrintSep(sep, "COMMAND_PETOPTIONS");
  7965. Player* player = client->GetPlayer();
  7966. Spawn* target = player->GetTarget();
  7967. if (!target)
  7968. return;
  7969. if (target == player->GetPet())
  7970. client->SendPetOptionsWindow(player->GetPet()->GetName());
  7971. else if (target == player->GetCharmedPet())
  7972. client->SendPetOptionsWindow(player->GetCharmedPet()->GetName());
  7973. else if (target == player->GetCosmeticPet())
  7974. client->SendPetOptionsWindow(player->GetCosmeticPet()->GetName(), 0);
  7975. else if (target == player->GetDeityPet())
  7976. client->SendPetOptionsWindow(player->GetDeityPet()->GetName(), 0);
  7977. }
  7978. /*
  7979. Function: Command_Random()
  7980. Purpose : Handles /random dice roll in-game
  7981. Params : 1-100
  7982. Dev : Scatman
  7983. Example : /randon 1 100
  7984. */
  7985. void Commands::Command_Random(Client* client, Seperator* sep)
  7986. {
  7987. char message[256] = {0};
  7988. if (sep)
  7989. {
  7990. if (sep->GetArgNumber() == 0 && sep->IsNumber(0))
  7991. 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])));
  7992. else if (sep->GetArgNumber() > 0 && sep->IsNumber(0) && sep->IsNumber(1))
  7993. 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])));
  7994. else
  7995. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  7996. }
  7997. else
  7998. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  7999. client->GetPlayer()->GetZone()->HandleChatMessage(0, 0, CHANNEL_EMOTE, message);
  8000. }
  8001. /*
  8002. Function: Command_Randomize()
  8003. Purpose : Sets randomize (appearance) values for NPCs
  8004. Params : Attrib Name
  8005. Dev : Scatman
  8006. Example : /randomize gender 1 -- will randomize the NPCs gender (male/female)
  8007. */
  8008. void Commands::Command_Randomize(Client* client, Seperator* sep)
  8009. {
  8010. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  8011. if (target)
  8012. {
  8013. if (target->IsNPC())
  8014. {
  8015. if (sep && sep->arg[0] && !sep->IsNumber(0))
  8016. {
  8017. const char* value = sep->arg[0];
  8018. if (strncasecmp(value, "show", strlen(value)) == 0)
  8019. {
  8020. client->DisplayRandomizeFeatures(target->GetRandomize());
  8021. }
  8022. else
  8023. {
  8024. if (sep->arg[1] && sep->IsNumber(1))
  8025. {
  8026. int8 option = atoi(sep->arg[1]);
  8027. if (option == 0 || option == 1)
  8028. {
  8029. int32 feature = 0;
  8030. char feature_text[32] = {0};
  8031. if (strncasecmp(value, "gender", strlen(value)) == 0) {
  8032. feature = RANDOMIZE_GENDER;
  8033. strncpy(feature_text, "gender", sizeof(feature_text) - 1);
  8034. }
  8035. else if (strncasecmp(value, "race", strlen(value)) == 0) {
  8036. feature = RANDOMIZE_RACE;
  8037. strncpy(feature_text, "race", sizeof(feature_text) - 1);
  8038. }
  8039. else if (strncasecmp(value, "model", strlen(value)) == 0) {
  8040. feature = RANDOMIZE_MODEL_TYPE;
  8041. strncpy(feature_text, "model", sizeof(feature_text) - 1);
  8042. }
  8043. else if (strncasecmp(value, "facial_hair", strlen(value)) == 0) {
  8044. feature = RANDOMIZE_FACIAL_HAIR_TYPE;
  8045. strncpy(feature_text, "facial hair", sizeof(feature_text) - 1);
  8046. }
  8047. else if (strncasecmp(value, "hair", strlen(value)) == 0) {
  8048. feature = RANDOMIZE_HAIR_TYPE;
  8049. strncpy(feature_text, "hair", sizeof(feature_text) - 1);
  8050. }
  8051. else if (strncasecmp(value, "wing", strlen(value)) == 0) {
  8052. feature = RANDOMIZE_WING_TYPE;
  8053. strncpy(feature_text, "wings", sizeof(feature_text) - 1);
  8054. }
  8055. else if (strncasecmp(value, "cheek", strlen(value)) == 0) {
  8056. feature = RANDOMIZE_CHEEK_TYPE;
  8057. strncpy(feature_text, "cheeks", sizeof(feature_text) - 1);
  8058. }
  8059. else if (strncasecmp(value, "chin", strlen(value)) == 0) {
  8060. feature = RANDOMIZE_CHIN_TYPE;
  8061. strncpy(feature_text, "chin", sizeof(feature_text) - 1);
  8062. }
  8063. else if (strncasecmp(value, "ear", strlen(value)) == 0) {
  8064. feature = RANDOMIZE_EAR_TYPE;
  8065. strncpy(feature_text, "ears", sizeof(feature_text) - 1);
  8066. }
  8067. else if (strncasecmp(value, "eye_brow", strlen(value)) == 0) {
  8068. feature = RANDOMIZE_EYE_BROW_TYPE;
  8069. strncpy(feature_text, "eye brows", sizeof(feature_text) - 1);
  8070. }
  8071. else if (strncasecmp(value, "eye", strlen(value)) == 0) {
  8072. feature = RANDOMIZE_EYE_TYPE;
  8073. strncpy(feature_text, "eyes", sizeof(feature_text) - 1);
  8074. }
  8075. else if (strncasecmp(value, "lip", strlen(value)) == 0) {
  8076. feature = RANDOMIZE_LIP_TYPE;
  8077. strncpy(feature_text, "lips", sizeof(feature_text) - 1);
  8078. }
  8079. else if (strncasecmp(value, "nose", strlen(value)) == 0) {
  8080. feature = RANDOMIZE_NOSE_TYPE;
  8081. strncpy(feature_text, "nose", sizeof(feature_text) - 1);
  8082. }
  8083. else if (strncasecmp(value, "eye_color", strlen(value)) == 0) {
  8084. feature = RANDOMIZE_EYE_COLOR;
  8085. strncpy(feature_text, "eye color", sizeof(feature_text) - 1);
  8086. }
  8087. else if (strncasecmp(value, "hair_color", strlen(value)) == 0) {
  8088. feature = RANDOMIZE_HAIR_TYPE_COLOR;
  8089. strncpy(feature_text, "hair color", sizeof(feature_text) - 1);
  8090. }
  8091. else if (strncasecmp(value, "hair_color1", strlen(value)) == 0) {
  8092. feature = RANDOMIZE_HAIR_COLOR1;
  8093. strncpy(feature_text, "hair color1", sizeof(feature_text) - 1);
  8094. }
  8095. else if (strncasecmp(value, "hair_color2", strlen(value)) == 0) {
  8096. feature = RANDOMIZE_HAIR_COLOR2;
  8097. strncpy(feature_text, "hair color2", sizeof(feature_text) - 1);
  8098. }
  8099. else if (strncasecmp(value, "hair_highlight", strlen(value)) == 0) {
  8100. feature = RANDOMIZE_HAIR_HIGHLIGHT;
  8101. strncpy(feature_text, "hair highlights", sizeof(feature_text) - 1);
  8102. }
  8103. else if (strncasecmp(value, "facial_hair_color", strlen(value)) == 0) {
  8104. feature = RANDOMIZE_HAIR_FACE_COLOR;
  8105. strncpy(feature_text, "facial hair color", sizeof(feature_text) - 1);
  8106. }
  8107. else if (strncasecmp(value, "facial_hair_color_highlight", strlen(value)) == 0) {
  8108. feature = RANDOMIZE_HAIR_FACE_HIGHLIGHT_COLOR;
  8109. strncpy(feature_text, "facial hair color highlights", sizeof(feature_text) - 1);
  8110. }
  8111. else if (strncasecmp(value, "hair_color_highlight", strlen(value)) == 0) {
  8112. feature = RANDOMIZE_HAIR_TYPE_HIGHLIGHT_COLOR;
  8113. strncpy(feature_text, "hair color highlights", sizeof(feature_text) - 1);
  8114. }
  8115. else if (strncasecmp(value, "skin_color", strlen(value)) == 0) {
  8116. feature = RANDOMIZE_SKIN_COLOR;
  8117. strncpy(feature_text, "skin color", sizeof(feature_text) - 1);
  8118. }
  8119. else if (strncasecmp(value, "wing_color1", strlen(value)) == 0) {
  8120. feature = RANDOMIZE_WING_COLOR1;
  8121. strncpy(feature_text, "wing color1", sizeof(feature_text) - 1);
  8122. }
  8123. else if (strncasecmp(value, "wing_color2", strlen(value)) == 0) {
  8124. feature = RANDOMIZE_WING_COLOR2;
  8125. strncpy(feature_text, "wing color2", sizeof(feature_text) - 1);
  8126. }
  8127. else {
  8128. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is not a valid feature to randomize.", value);
  8129. 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'.");
  8130. }
  8131. if (feature > 0) {
  8132. if (option == 1) {
  8133. if (target->GetRandomize() & feature)
  8134. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is already set to randomly generate their %s.", target->GetName(), feature_text);
  8135. else {
  8136. target->AddRandomize(feature);
  8137. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(feature);
  8138. database.UpdateRandomize(target->GetDatabaseID(), feature);
  8139. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will now generate their %s randomly.", target->GetName(), feature_text);
  8140. }
  8141. }
  8142. else {
  8143. if (target->GetRandomize() & feature) {
  8144. target->AddRandomize(-feature);
  8145. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(-feature);
  8146. database.UpdateRandomize(target->GetDatabaseID(), -feature);
  8147. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will no longer generate their %s randomly.", target->GetName(), feature_text);
  8148. }
  8149. else
  8150. client->Message(CHANNEL_COLOR_YELLOW, "'%s' already does not randomly generate their %s.", target->GetName(), feature_text);
  8151. }
  8152. }
  8153. }
  8154. else
  8155. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  8156. }
  8157. else
  8158. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  8159. }
  8160. }
  8161. else {
  8162. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /randomize [show | [feature [1|0]]");
  8163. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "'show' will display current configured features");
  8164. 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'.");
  8165. }
  8166. }
  8167. else
  8168. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "The target you wish to randomize must be an NPC.");
  8169. }
  8170. else
  8171. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select the target you wish to randomize.");
  8172. }
  8173. /*
  8174. Function: Command_ShowCloak()
  8175. Purpose : Character Settings combo box for Show Cloak
  8176. Params : true/false
  8177. Dev : John Adams
  8178. Example :
  8179. */
  8180. void Commands::Command_ShowCloak(Client* client, Seperator* sep)
  8181. {
  8182. Player* player = client->GetPlayer();
  8183. if (sep && sep->arg[0])
  8184. {
  8185. const char* value = sep->arg[0];
  8186. if (strncasecmp(value, "true", strlen(value)) == 0)
  8187. {
  8188. player->set_character_flag(CF_SHOW_CLOAK);
  8189. player->reset_character_flag(CF2_SHOW_RANGED);
  8190. }
  8191. else if (strncasecmp(value, "false", strlen(value)) == 0)
  8192. player->reset_character_flag(CF_SHOW_CLOAK);
  8193. else
  8194. {
  8195. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8196. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8197. }
  8198. }
  8199. }
  8200. /*
  8201. Function: Command_ShowHelm()
  8202. Purpose : Character Settings combo box for Show Helm
  8203. Params : true/false
  8204. Dev : John Adams
  8205. Example :
  8206. */
  8207. void Commands::Command_ShowHelm(Client* client, Seperator* sep)
  8208. {
  8209. Player* player = client->GetPlayer();
  8210. if(client->GetVersion() <= 561) {
  8211. return; // not allowed/supported
  8212. }
  8213. if (sep && sep->arg[0])
  8214. {
  8215. PrintSep(sep, "Command_ShowHelm");
  8216. const char* value = sep->arg[0];
  8217. if (strncasecmp(value, "true", strlen(value)) == 0)
  8218. {
  8219. player->toggle_character_flag(CF_HIDE_HELM);
  8220. player->toggle_character_flag(CF_HIDE_HOOD);
  8221. }
  8222. else if (strncasecmp(value, "false", strlen(value)) == 0)
  8223. player->toggle_character_flag(CF_HIDE_HELM);
  8224. else
  8225. {
  8226. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8227. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8228. }
  8229. }
  8230. }
  8231. /*
  8232. Function: Command_ShowHood()
  8233. Purpose : Character Settings combo box for Show Hood
  8234. Params : true/false
  8235. Dev : John Adams
  8236. Example :
  8237. */
  8238. void Commands::Command_ShowHood(Client* client, Seperator* sep)
  8239. {
  8240. Player* player = client->GetPlayer();
  8241. if (sep && sep->arg[0])
  8242. {
  8243. PrintSep(sep, "Command_ShowHood");
  8244. const char* value = sep->arg[0];
  8245. if (strncasecmp(value, "true", strlen(value)) == 0)
  8246. {
  8247. player->toggle_character_flag(CF_HIDE_HOOD);
  8248. if(client->GetVersion() > 561) { // no hide helm support in DoF
  8249. player->toggle_character_flag(CF_HIDE_HELM);
  8250. }
  8251. }
  8252. else if (strncasecmp(value, "false", strlen(value)) == 0) {
  8253. player->toggle_character_flag(CF_HIDE_HOOD);
  8254. }
  8255. else
  8256. {
  8257. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8258. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8259. }
  8260. }
  8261. }
  8262. /*
  8263. Function: Command_ShowHoodHelm()
  8264. Purpose : Character Settings combo box for Show Helm or Hood
  8265. Params : true/false
  8266. Dev : John Adams
  8267. Example :
  8268. */
  8269. void Commands::Command_ShowHoodHelm(Client* client, Seperator* sep)
  8270. {
  8271. Player* player = client->GetPlayer();
  8272. if(client->GetVersion() <= 561) {
  8273. return; // not allowed/supported
  8274. }
  8275. if (sep && sep->arg[0])
  8276. {
  8277. PrintSep(sep, "Command_ShowHoodHelm");
  8278. const char* value = sep->arg[0];
  8279. if (strncasecmp(value, "true", strlen(value)) == 0)
  8280. {
  8281. player->toggle_character_flag(CF_HIDE_HOOD);
  8282. player->toggle_character_flag(CF_HIDE_HELM);
  8283. }
  8284. else if (strncasecmp(value, "false", strlen(value)) == 0)
  8285. {
  8286. // don't think we ever wind up in here...
  8287. player->toggle_character_flag(CF_HIDE_HOOD);
  8288. player->toggle_character_flag(CF_HIDE_HELM);
  8289. }
  8290. else
  8291. {
  8292. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8293. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8294. }
  8295. }
  8296. }
  8297. /*
  8298. Function: Command_ShowRanged()
  8299. Purpose : Character Settings combo box for Show Ranged weapon
  8300. Params : true/false
  8301. Dev : John Adams
  8302. Example :
  8303. */
  8304. void Commands::Command_ShowRanged(Client* client, Seperator* sep)
  8305. {
  8306. Player* player = client->GetPlayer();
  8307. if (sep && sep->arg[0])
  8308. {
  8309. const char* value = sep->arg[0];
  8310. if (strncasecmp(value, "true", strlen(value)) == 0)
  8311. {
  8312. player->set_character_flag(CF2_SHOW_RANGED);
  8313. player->reset_character_flag(CF_SHOW_CLOAK);
  8314. }
  8315. else if (strncasecmp(value, "false", strlen(value)) == 0)
  8316. player->reset_character_flag(CF2_SHOW_RANGED);
  8317. else
  8318. {
  8319. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8320. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8321. }
  8322. }
  8323. }
  8324. /*
  8325. Function:
  8326. Purpose :
  8327. Params :
  8328. Dev :
  8329. Example :
  8330. */
  8331. void Commands::Command_Skills(Client* client, Seperator* sep, int handler)
  8332. {
  8333. Player* player = 0;
  8334. Client* to_client = 0;
  8335. if(client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  8336. to_client = ((Player*)client->GetPlayer()->GetTarget())->GetClient();
  8337. switch(handler)
  8338. {
  8339. case COMMAND_SKILL:
  8340. {
  8341. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill [add|remove|list] [skill name]");
  8342. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to add/remove skills for that player.");
  8343. break;
  8344. }
  8345. case COMMAND_SKILL_ADD:
  8346. {
  8347. if (sep && sep->arg[0])
  8348. {
  8349. const char* skill_name = sep->argplus[0];
  8350. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  8351. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // add skill to your target, if target is not you
  8352. {
  8353. player = to_client->GetPlayer();
  8354. if (player)
  8355. {
  8356. if (!player->GetSkills()->HasSkill(skill->skill_id))
  8357. {
  8358. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  8359. client->Message(CHANNEL_COLOR_YELLOW, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  8360. to_client->Message(CHANNEL_COLOR_YELLOW, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  8361. }
  8362. else
  8363. client->Message(CHANNEL_COLOR_YELLOW, "%s already has the skill '%s'.", player->GetName(), skill_name);
  8364. }
  8365. }
  8366. else if (skill) // add skill to yourself
  8367. {
  8368. player = client->GetPlayer();
  8369. if (player)
  8370. {
  8371. if (!player->GetSkills()->HasSkill(skill->skill_id))
  8372. {
  8373. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  8374. client->Message(CHANNEL_COLOR_YELLOW, "Added skill '%s'.", skill_name);
  8375. }
  8376. else
  8377. client->Message(CHANNEL_COLOR_YELLOW, "You already have the skill '%s'.", skill_name);
  8378. }
  8379. }
  8380. else
  8381. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  8382. }
  8383. else
  8384. {
  8385. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill add [skill name]");
  8386. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  8387. }
  8388. break;
  8389. }
  8390. case COMMAND_SKILL_REMOVE:
  8391. {
  8392. if (sep && sep->arg[0])
  8393. {
  8394. const char* skill_name = sep->argplus[0];
  8395. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  8396. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // remove skill from your target, if target is not you
  8397. {
  8398. player = to_client->GetPlayer();
  8399. if (player)
  8400. {
  8401. if (player->GetSkills()->HasSkill(skill->skill_id))
  8402. {
  8403. player->RemoveSkillFromDB(skill, true);
  8404. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  8405. to_client->Message(CHANNEL_COLOR_YELLOW, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  8406. }
  8407. else
  8408. client->Message(CHANNEL_COLOR_YELLOW, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  8409. }
  8410. }
  8411. else if(skill) // remove skill from yourself
  8412. {
  8413. Player* player = client->GetPlayer();
  8414. if (player)
  8415. {
  8416. if (player->GetSkills()->HasSkill(skill->skill_id))
  8417. {
  8418. player->RemoveSkillFromDB(skill, true);
  8419. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s'.", skill_name);
  8420. }
  8421. else
  8422. client->Message(CHANNEL_COLOR_YELLOW, "You do not have the skill '%s'.", skill_name);
  8423. }
  8424. }
  8425. else
  8426. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  8427. }
  8428. else
  8429. {
  8430. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill remove [skill name]");
  8431. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  8432. }
  8433. break;
  8434. }
  8435. case COMMAND_SKILL_LIST:
  8436. {
  8437. if (sep && sep->arg[0])
  8438. {
  8439. const char* skill_name = sep->argplus[0];
  8440. client->Message(CHANNEL_COLOR_YELLOW, "Listing skills like '%s':", skill_name);
  8441. map<int32, Skill*>* skills = master_skill_list.GetAllSkills();
  8442. map<int32, Skill*>::iterator itr;
  8443. if (skills && skills->size() > 0)
  8444. {
  8445. for (itr = skills->begin(); itr != skills->end(); itr++)
  8446. {
  8447. Skill* skill = itr->second;
  8448. string current_skill_name = ::ToLower(string(skill->name.data.c_str()));
  8449. if (current_skill_name.find(::ToLower(string(skill_name))) < 0xFFFFFFFF)
  8450. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", skill->name.data.c_str(), skill->skill_id);
  8451. }
  8452. }
  8453. }
  8454. else
  8455. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill list [skill name]");
  8456. break;
  8457. }
  8458. }
  8459. }
  8460. /*
  8461. Function: Command_SpawnTemplate()
  8462. Purpose : Create or Use defined Spawn Templates
  8463. Params : create, save, rempve, list
  8464. Dev : John Adams
  8465. Example : /spawn template create "Test"
  8466. */
  8467. void Commands::Command_SpawnTemplate(Client* client, Seperator* sep)
  8468. {
  8469. if (sep == NULL || sep->arg[0] == NULL)
  8470. {
  8471. 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.");
  8472. return;
  8473. }
  8474. // got params, continue
  8475. const char * template_cmd = sep->arg[0];
  8476. if (strncasecmp(template_cmd, "list", strlen(template_cmd)) == 0)
  8477. {
  8478. if (!sep->IsSet(1))
  8479. {
  8480. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /spawn template list [name|location_id]");
  8481. 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.");
  8482. return;
  8483. }
  8484. map<int32, string>* template_names = 0;
  8485. if (sep->IsNumber(1))
  8486. {
  8487. int32 location_id = 0;
  8488. location_id = atoi(sep->arg[1]);
  8489. template_names = database.GetSpawnTemplateListByID(location_id);
  8490. }
  8491. else
  8492. {
  8493. const char* name = 0;
  8494. name = sep->argplus[1];
  8495. template_names = database.GetSpawnTemplateListByName(name);
  8496. }
  8497. if(!template_names)
  8498. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No templates found.");
  8499. else
  8500. {
  8501. map<int32, string>::iterator itr;
  8502. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  8503. for(itr = template_names->begin(); itr != template_names->end(); itr++)
  8504. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  8505. safe_delete(template_names);
  8506. }
  8507. }
  8508. else if (strncasecmp(template_cmd, "save", strlen(template_cmd)) == 0)
  8509. {
  8510. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  8511. if ( target && (target->IsNPC() || target->IsObject() || target->IsSign() || target->IsWidget() || target->IsGroundSpawn()) )
  8512. {
  8513. if (sep && sep->arg[1][0] && !sep->IsNumber(1))
  8514. {
  8515. // first, lookup to see if template name already exists
  8516. const char* name = 0;
  8517. name = sep->argplus[1];
  8518. map<int32, string>* template_names = database.GetSpawnTemplateListByName(name);
  8519. if(!template_names)
  8520. {
  8521. int32 new_template_id = database.SaveSpawnTemplate(target->GetSpawnLocationID(), name);
  8522. if( new_template_id > 0 )
  8523. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template '%s' added for spawn '%s' (%u) as TemplateID: %u", name, target->GetName(), target->GetSpawnLocationID(), new_template_id);
  8524. else
  8525. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' for spawn '%s' (%u).", name, target->GetName(), target->GetSpawnLocationID());
  8526. }
  8527. else
  8528. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' - Already exists!", name);
  8529. }
  8530. else
  8531. client->Message(CHANNEL_COLOR_RED, "ERROR: Saving a new spawn template requires a valid template name!");
  8532. }
  8533. else
  8534. client->Message(CHANNEL_COLOR_RED, "ERROR: You must target the spawn you wish to save as a template!");
  8535. }
  8536. else if (strncasecmp(template_cmd, "remove", strlen(template_cmd)) == 0)
  8537. {
  8538. if (sep && sep->arg[1][0] && sep->IsNumber(1))
  8539. {
  8540. int32 template_id = 0;
  8541. template_id = atoi(sep->arg[1]);
  8542. if (database.RemoveSpawnTemplate(template_id))
  8543. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template ID: %u successfully removed.", template_id);
  8544. else
  8545. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to remove spawn template ID: %u", template_id);
  8546. }
  8547. else
  8548. client->Message(CHANNEL_COLOR_RED, "ERROR: Removing a spawn template requires a valid template ID!");
  8549. }
  8550. // Renamed create to spawn
  8551. else if (strncasecmp(template_cmd, "spawn", strlen(template_cmd)) == 0)
  8552. {
  8553. if (sep && sep->arg[1][0])
  8554. {
  8555. int32 new_location = 0;
  8556. if (sep->IsNumber(1))
  8557. {
  8558. int32 template_id = 0;
  8559. template_id = atoi(sep->arg[1]);
  8560. new_location = database.CreateSpawnFromTemplateByID(client, template_id);
  8561. if( new_location > 0 )
  8562. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template ID: %u", new_location, template_id);
  8563. else
  8564. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template ID: %u", template_id);
  8565. }
  8566. else
  8567. {
  8568. const char* name = 0;
  8569. name = sep->argplus[1];
  8570. new_location = database.CreateSpawnFromTemplateByName(client, name);
  8571. if( new_location > 0 )
  8572. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template: '%s'", new_location, name);
  8573. else
  8574. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template: '%s'", name);
  8575. }
  8576. }
  8577. else
  8578. client->Message(CHANNEL_COLOR_RED, "ERROR: Spawning a new spawn location requires a valid template name or ID!");
  8579. }
  8580. else
  8581. client->Message(CHANNEL_COLOR_RED, "ERROR: Unknown /spawn template command.");
  8582. }
  8583. void Commands::Command_Speed(Client* client, Seperator* sep) {
  8584. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  8585. float new_speed = atof(sep->arg[0]);
  8586. if (new_speed > 0.0f)
  8587. {
  8588. client->GetPlayer()->SetSpeed(new_speed, true);
  8589. client->GetPlayer()->SetCharSheetChanged(true);
  8590. database.insertCharacterProperty(client, CHAR_PROPERTY_SPEED, sep->arg[0]);
  8591. client->Message(CHANNEL_STATUS, "Setting speed to %.2f.", new_speed);
  8592. }
  8593. else
  8594. client->Message(CHANNEL_STATUS, "Invalid speed provided %s.", sep->arg[0]);
  8595. }
  8596. else{
  8597. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /speed {new speed value}");
  8598. }
  8599. }
  8600. /*
  8601. Function: Command_StationMarketPlace()
  8602. Purpose : just trying to eat the console spam for now
  8603. Params :
  8604. Dev : John
  8605. */
  8606. void Commands::Command_StationMarketPlace(Client* client, Seperator* sep)
  8607. {
  8608. PrintSep(sep, "COMMAND_SMP");
  8609. // This will reduce the spam from once every 10 sec to once every 30 sec,
  8610. // can't seem to reduce it any more get rid of it completely...
  8611. if (sep && strcmp(sep->arg[0], "gkw") == 0) {
  8612. PacketStruct* packet = configReader.getStruct("WS_MarketFundsUpdate", client->GetVersion());
  8613. if (packet) {
  8614. packet->setDataByName("account_id", client->GetAccountID());
  8615. packet->setDataByName("character_id", client->GetCharacterID());
  8616. packet->setDataByName("unknown1", 1, 5);
  8617. packet->setDataByName("unknown1", 26, 6);
  8618. packet->setDataByName("unknown2", 0xFFFFFFFF);
  8619. packet->setDataByName("unknown3", 248, 1);
  8620. client->QueuePacket(packet->serialize());
  8621. }
  8622. safe_delete(packet);
  8623. }
  8624. }
  8625. /*
  8626. Function: Command_StopDrinking()
  8627. Purpose : Stops player from auto-consuming drink
  8628. Params :
  8629. Dev : Zcoretri
  8630. Example : /stopdrinking
  8631. */
  8632. void Commands::Command_StopDrinking(Client* client)
  8633. {
  8634. client->GetPlayer()->reset_character_flag(CF_DRINK_AUTO_CONSUME);
  8635. client->GetPlayer()->SetActiveDrinkUniqueID(0);
  8636. client->Message(CHANNEL_COLOR_YELLOW,"You stop drinking your current drink.");
  8637. }
  8638. /*
  8639. Function: Command_StopEating()
  8640. Purpose : Stops player from auto-consuming food
  8641. Params :
  8642. Dev : Zcoretri
  8643. Example : /stopeating
  8644. */
  8645. void Commands::Command_StopEating(Client* client)
  8646. {
  8647. client->GetPlayer()->reset_character_flag(CF_FOOD_AUTO_CONSUME);
  8648. client->GetPlayer()->SetActiveFoodUniqueID(0);
  8649. client->Message(CHANNEL_COLOR_YELLOW,"You stop eating your current food.");
  8650. }
  8651. /*
  8652. Function: Command_Title()
  8653. Purpose : Help for /title command
  8654. Params : n/a
  8655. Dev : Zcoretri
  8656. Example : /title
  8657. */
  8658. void Commands::Command_Title(Client* client)
  8659. {
  8660. client->Message(CHANNEL_COLOR_YELLOW, "Available subcommands: list, setprefix <index>, setsuffix <index>, fix");
  8661. }
  8662. /*
  8663. Function: Command_TitleList()
  8664. Purpose : List available titles for player
  8665. Params : n/a
  8666. Dev : Zcoretri
  8667. Example : /title list
  8668. */
  8669. void Commands::Command_TitleList(Client* client)
  8670. {
  8671. // must call release read lock before leaving function on GetPlayerTitles
  8672. vector<Title*>* titles = client->GetPlayer()->GetPlayerTitles()->GetAllTitles();
  8673. vector<Title*>::iterator itr;
  8674. Title* title;
  8675. sint32 i = 0;
  8676. client->Message(CHANNEL_NARRATIVE, "Listing available titles:");
  8677. for(itr = titles->begin(); itr != titles->end(); itr++)
  8678. {
  8679. title = *itr;
  8680. client->Message(CHANNEL_NARRATIVE, "%i: type=[%s] title=[%s]", i, title->GetPrefix() ? "Prefix":"Suffix", title->GetName());
  8681. i++;
  8682. }
  8683. client->GetPlayer()->GetPlayerTitles()->ReleaseReadLock();
  8684. }
  8685. /*
  8686. Function: Command_TitleSetPrefix()
  8687. Purpose : Set Prefix title for player
  8688. Params : Title ID
  8689. Dev : Zcoretri
  8690. Example : /title setprefix 1
  8691. */
  8692. void Commands::Command_TitleSetPrefix(Client* client, Seperator* sep)
  8693. {
  8694. if (sep && sep->arg[0] && sep->IsNumber(0))
  8695. {
  8696. sint32 index = atoul(sep->arg[0]);
  8697. if(index > -1)
  8698. {
  8699. Title* title = client->GetPlayer()->GetPlayerTitles()->GetTitle(index);
  8700. if(!title)
  8701. {
  8702. client->Message(CHANNEL_COLOR_RED, "Missing index %i to set title", index);
  8703. return;
  8704. }
  8705. else if(!title->GetPrefix())
  8706. {
  8707. client->Message(CHANNEL_COLOR_RED, "%s is not a prefix.", title->GetName());
  8708. return;
  8709. }
  8710. }
  8711. else // make sure client doesn't pass some bogus negative index
  8712. index = -1;
  8713. database.SaveCharPrefixIndex(index, client->GetCharacterID());
  8714. client->SendTitleUpdate();
  8715. }
  8716. }
  8717. /*
  8718. Function: Command_TitleSetSuffix()
  8719. Purpose : Set Suffix title for player
  8720. Params : Title ID
  8721. Dev : Zcoretri
  8722. Example : /title setsuffix 1
  8723. */
  8724. void Commands::Command_TitleSetSuffix(Client* client, Seperator* sep)
  8725. {
  8726. if (sep && sep->arg[0] && sep->IsNumber(0))
  8727. {
  8728. sint32 index = atoul(sep->arg[0]);
  8729. if(index > -1)
  8730. {
  8731. Title* title = client->GetPlayer()->GetPlayerTitles()->GetTitle(index);
  8732. if(!title)
  8733. {
  8734. client->Message(CHANNEL_COLOR_RED, "Missing index %i to set title", index);
  8735. return;
  8736. }
  8737. else if(title->GetPrefix())
  8738. {
  8739. client->Message(CHANNEL_COLOR_RED, "%s is not a suffix.", title->GetName());
  8740. return;
  8741. }
  8742. }
  8743. else // make sure client doesn't pass some bogus negative index
  8744. index = -1;
  8745. database.SaveCharSuffixIndex(index, client->GetCharacterID());
  8746. client->SendTitleUpdate();
  8747. }
  8748. }
  8749. /*
  8750. Function: Command_TitleFix()
  8751. Purpose : Fix title for player (???)
  8752. Params :
  8753. Dev : Zcoretri
  8754. Example :
  8755. */
  8756. void Commands::Command_TitleFix(Client* client, Seperator* sep)
  8757. {
  8758. PrintSep(sep, "COMMAND_TITLE_FIX");
  8759. LogWrite(MISC__TODO, 1, "Titles", "TODO-Command: TITLE_FIX");
  8760. }
  8761. /*
  8762. Function: Command_Toggle_Anonymous()
  8763. Purpose : Toggles player Anonymous
  8764. Params :
  8765. Dev : paulgh
  8766. Example : /anon
  8767. */
  8768. void Commands::Command_Toggle_Anonymous(Client* client)
  8769. {
  8770. Player* player = client->GetPlayer();
  8771. player->toggle_character_flag(CF_ANONYMOUS);
  8772. client->Message(CHANNEL_COLOR_YELLOW,"You are %s anonymous.", player->get_character_flag(CF_ANONYMOUS)?"now":"no longer");
  8773. if (player->get_character_flag(CF_ANONYMOUS))
  8774. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ANONYMOUS);
  8775. else
  8776. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ANONYMOUS);
  8777. }
  8778. /*
  8779. Function: Command_Toggle_AutoConsume()
  8780. Purpose : Toggles player food/drink auto consume
  8781. Params : unknown
  8782. Dev : paulgh
  8783. Example : /set_auto_consume
  8784. */
  8785. void Commands::Command_Toggle_AutoConsume(Client* client, Seperator* sep)
  8786. {
  8787. Player* player = client->GetPlayer();
  8788. if (sep && sep->arg[0])
  8789. PrintSep(sep, "COMMAND_SET_AUTO_CONSUME");
  8790. if (sep && sep->arg[0] && sep->IsNumber(0))
  8791. {
  8792. int8 slot = atoi(sep->arg[0]);
  8793. int8 flag = atoi(sep->arg[1]);
  8794. if (client->GetVersion() <= 373) {
  8795. slot += 4;
  8796. }
  8797. else if (client->GetVersion() <= 561) {
  8798. slot += 2;
  8799. }
  8800. if (slot == EQ2_FOOD_SLOT)
  8801. {
  8802. player->toggle_character_flag(CF_FOOD_AUTO_CONSUME);
  8803. player->SetCharSheetChanged(true);
  8804. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  8805. if (flag == 1)
  8806. client->Message(CHANNEL_NARRATIVE, "You decide to eat immediately whenever you become hungry.");
  8807. else
  8808. {
  8809. client->Message(CHANNEL_NARRATIVE, "You decide to ignore the hunger.");
  8810. return;
  8811. }
  8812. }
  8813. else
  8814. {
  8815. player->toggle_character_flag(CF_DRINK_AUTO_CONSUME);
  8816. player->SetCharSheetChanged(true);
  8817. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  8818. if (flag == 1)
  8819. client->Message(CHANNEL_NARRATIVE, "You decide to drink immediately whenever you become thirsty.");
  8820. else
  8821. {
  8822. client->Message(CHANNEL_NARRATIVE, "You decide to ignore the thirst.");
  8823. return;
  8824. }
  8825. }
  8826. if(!client->CheckConsumptionAllowed(slot, false))
  8827. return;
  8828. Item* item = player->GetEquipmentList()->GetItem(slot);
  8829. if(item)
  8830. client->ConsumeFoodDrink(item, slot);
  8831. }
  8832. }
  8833. /*
  8834. Function: Command_Toggle_BonusXP()
  8835. Purpose : Toggles player Bonus XP
  8836. Params :
  8837. Dev : John Adams
  8838. Example : /disable_char_bonus_exp
  8839. */
  8840. void Commands::Command_Toggle_BonusXP(Client* client)
  8841. {
  8842. Player* player = client->GetPlayer();
  8843. player->toggle_character_flag(CF2_CHARACTER_BONUS_EXPERIENCE_ENABLED);
  8844. player->SetCharSheetChanged(true);
  8845. }
  8846. /*
  8847. Function: Command_Toggle_CombatXP()
  8848. Purpose : Toggles player Adventure XP
  8849. Params :
  8850. Dev : John Adams
  8851. Example : /disable_combat_exp
  8852. */
  8853. void Commands::Command_Toggle_CombatXP(Client* client)
  8854. {
  8855. Player* player = client->GetPlayer();
  8856. player->toggle_character_flag(CF_COMBAT_EXPERIENCE_ENABLED);
  8857. player->SetCharSheetChanged(true);
  8858. }
  8859. /*
  8860. Function: Command_Toggle_GMHide()
  8861. Purpose : Toggles hiding player GM status
  8862. Params :
  8863. Dev : Scatman
  8864. Example : /gm_hide
  8865. */
  8866. void Commands::Command_Toggle_GMHide(Client* client)
  8867. {
  8868. Player* player = client->GetPlayer();
  8869. player->toggle_character_flag(CF_HIDE_STATUS);
  8870. client->Message(CHANNEL_COLOR_YELLOW,"You are %s hiding your GM status.", player->get_character_flag(CF_HIDE_STATUS)?"now":"no longer");
  8871. }
  8872. /*
  8873. Function: Command_Toggle_GMVanish()
  8874. Purpose : Toggles hiding GM players from /who searches
  8875. Params :
  8876. Dev : Scatman
  8877. Example : /gm_vanish
  8878. */
  8879. void Commands::Command_Toggle_GMVanish(Client* client)
  8880. {
  8881. Player* player = client->GetPlayer();
  8882. player->toggle_character_flag(CF_GM_HIDDEN);
  8883. client->Message(CHANNEL_COLOR_YELLOW,"You are %s invisible to who queries.", player->get_character_flag(CF_GM_HIDDEN)?"now":"no longer");
  8884. }
  8885. /*
  8886. Function: Command_Toggle_Illusions()
  8887. Purpose : Toggles player illusion form
  8888. Params : not sure sep is needed, testing
  8889. Dev : paulgh
  8890. Example : /hide_illusions
  8891. */
  8892. void Commands::Command_Toggle_Illusions(Client* client, Seperator* sep)
  8893. {
  8894. if (sep && sep->arg[0])
  8895. PrintSep(sep, "COMMAND_TOGGLE_ILLUSIONS");
  8896. client->GetPlayer()->toggle_character_flag(CF_SHOW_ILLUSION);
  8897. }
  8898. /*
  8899. Function: Command_Toggle_LFG()
  8900. Purpose : Toggles player LFG Flag
  8901. Params :
  8902. Dev : paulgh
  8903. Example : /lfg
  8904. */
  8905. void Commands::Command_Toggle_LFG(Client* client)
  8906. {
  8907. Player* player = client->GetPlayer();
  8908. player->toggle_character_flag(CF_LFG);
  8909. client->Message(CHANNEL_COLOR_YELLOW,"You are %s LFG.", player->get_character_flag(CF_LFG)?"now":"no longer");
  8910. if (player->get_character_flag(CF_LFG))
  8911. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFG);
  8912. else
  8913. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFG);
  8914. }
  8915. /*
  8916. Function: Command_Toggle_LFW()
  8917. Purpose : Toggles player LFW Flag
  8918. Params :
  8919. Dev : paulgh
  8920. Example : /lfw
  8921. */
  8922. void Commands::Command_Toggle_LFW(Client* client)
  8923. {
  8924. Player* player = client->GetPlayer();
  8925. player->toggle_character_flag(CF_LFW);
  8926. client->Message(CHANNEL_COLOR_YELLOW,"You %s looking for work.", player->get_character_flag(CF_LFW)?"let others know you are":"stop");
  8927. if (player->get_character_flag(CF_LFW))
  8928. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFW);
  8929. else
  8930. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFW);
  8931. }
  8932. /*
  8933. Function: Command_Toggle_QuestXP()
  8934. Purpose : Toggles player Quest XP
  8935. Params :
  8936. Dev : John Adams
  8937. Example : /disable_quest_exp
  8938. */
  8939. void Commands::Command_Toggle_QuestXP(Client* client)
  8940. {
  8941. Player* player = client->GetPlayer();
  8942. player->toggle_character_flag(CF_QUEST_EXPERIENCE_ENABLED);
  8943. player->SetCharSheetChanged(true);
  8944. }
  8945. /*
  8946. Function: Command_Toggle_Roleplaying()
  8947. Purpose : Toggles player Roleplaying flag
  8948. Params :
  8949. Dev : paulgh
  8950. Example : /role
  8951. */
  8952. void Commands::Command_Toggle_Roleplaying(Client* client)
  8953. {
  8954. Player* player = client->GetPlayer();
  8955. player->toggle_character_flag(CF_ROLEPLAYING);
  8956. client->Message(CHANNEL_COLOR_YELLOW,"You are %s roleplaying.", player->get_character_flag(CF_ROLEPLAYING)?"now":"no longer");
  8957. if (player->get_character_flag(CF_ROLEPLAYING))
  8958. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ROLEPLAYING);
  8959. else
  8960. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ROLEPLAYING);
  8961. }
  8962. void Commands::Command_Toggle_Duels(Client* client)
  8963. {
  8964. Player* player = client->GetPlayer();
  8965. player->toggle_character_flag(CF_ALLOW_DUEL_INVITES);
  8966. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting duel invites.", player->get_character_flag(CF_ALLOW_DUEL_INVITES)?"now":"no longer");
  8967. }
  8968. void Commands::Command_Toggle_Trades(Client* client)
  8969. {
  8970. Player* player = client->GetPlayer();
  8971. player->toggle_character_flag(CF_ALLOW_TRADE_INVITES);
  8972. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting trade invites.", player->get_character_flag(CF_ALLOW_TRADE_INVITES)?"now":"no longer");
  8973. }
  8974. void Commands::Command_Toggle_Guilds(Client* client)
  8975. {
  8976. Player* player = client->GetPlayer();
  8977. player->toggle_character_flag(CF_ALLOW_GUILD_INVITES);
  8978. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting guild invites.", player->get_character_flag(CF_ALLOW_GUILD_INVITES)?"now":"no longer");
  8979. }
  8980. void Commands::Command_Toggle_Groups(Client* client)
  8981. {
  8982. Player* player = client->GetPlayer();
  8983. player->toggle_character_flag(CF_ALLOW_GROUP_INVITES);
  8984. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting group invites.", player->get_character_flag(CF_ALLOW_GROUP_INVITES)?"now":"no longer");
  8985. }
  8986. void Commands::Command_Toggle_Raids(Client* client)
  8987. {
  8988. Player* player = client->GetPlayer();
  8989. player->toggle_character_flag(CF_ALLOW_RAID_INVITES);
  8990. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting raid invites.", player->get_character_flag(CF_ALLOW_RAID_INVITES)?"now":"no longer");
  8991. }
  8992. void Commands::Command_Toggle_LON(Client* client)
  8993. {
  8994. Player* player = client->GetPlayer();
  8995. player->toggle_character_flag(CF2_ALLOW_LON_INVITES);
  8996. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting LoN invites.", player->get_character_flag(CF2_ALLOW_LON_INVITES)?"now":"no longer");
  8997. }
  8998. void Commands::Command_Toggle_VoiceChat(Client* client)
  8999. {
  9000. Player* player = client->GetPlayer();
  9001. player->toggle_character_flag(CF2_ALLOW_VOICE_INVITES);
  9002. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting voice chat invites.", player->get_character_flag(CF2_ALLOW_VOICE_INVITES)?"now":"no longer");
  9003. }
  9004. /*
  9005. Function: Command_TradeStart()
  9006. Purpose : Starts item/coin trade between players
  9007. Params :
  9008. Dev :
  9009. Example :
  9010. */
  9011. #include "../Trade.h"
  9012. void Commands::Command_TradeStart(Client* client, Seperator* sep)
  9013. {
  9014. PrintSep(sep, "COMMAND_START_TRADE");
  9015. Entity* trader = client->GetPlayer();
  9016. Entity* trader2 = 0;
  9017. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  9018. Spawn* spawn = client->GetPlayer()->GetSpawnWithPlayerID(atoi(sep->arg[0]));
  9019. if (spawn) {
  9020. if (spawn->IsEntity())
  9021. trader2 = (Entity*)spawn;
  9022. }
  9023. }
  9024. else if (client->GetPlayer()->GetTarget()) {
  9025. if (client->GetPlayer()->GetTarget()->IsEntity())
  9026. trader2 = (Entity*)client->GetPlayer()->GetTarget();
  9027. }
  9028. // can only trade with player or bots
  9029. if (trader && trader2) {
  9030. if (trader == trader2) {
  9031. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade with yourself.");
  9032. }
  9033. else if (trader2->IsPlayer() || trader2->IsBot()) {
  9034. LogWrite(PLAYER__ERROR, 0, "Trade", "creating trade");
  9035. if (trader->trade)
  9036. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are already trading.");
  9037. else if (trader2->trade)
  9038. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is already trading.");
  9039. else {
  9040. Trade* trade = new Trade(trader, trader2);
  9041. trader->trade = trade;
  9042. trader2->trade = trade;
  9043. }
  9044. }
  9045. else {
  9046. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can only trade with another player or a bot.");
  9047. }
  9048. }
  9049. else
  9050. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to find target");
  9051. }
  9052. /*
  9053. Function: Command_Track()
  9054. Purpose : Starts/Stops Tracking for a player
  9055. Params :
  9056. Dev : Scatman
  9057. Example : /track
  9058. */
  9059. void Commands::Command_Track(Client* client)
  9060. {
  9061. if (!client->GetPlayer()->GetIsTracking())
  9062. client->GetPlayer()->GetZone()->AddPlayerTracking(client->GetPlayer());
  9063. else
  9064. client->GetPlayer()->GetZone()->RemovePlayerTracking(client->GetPlayer(), TRACKING_STOP);
  9065. }
  9066. /*
  9067. Function: Command_TradeAccept()
  9068. Purpose : Accepts item/coin trade between players
  9069. Params :
  9070. Dev :
  9071. Example :
  9072. */
  9073. void Commands::Command_TradeAccept(Client* client, Seperator* sep)
  9074. {
  9075. PrintSep(sep, "COMMAND_ACCEPT_TRADE");
  9076. Trade* trade = client->GetPlayer()->trade;
  9077. if (trade) {
  9078. bool trade_complete = trade->SetTradeAccepted(client->GetPlayer());
  9079. if (trade_complete)
  9080. safe_delete(trade);
  9081. }
  9082. else
  9083. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  9084. }
  9085. /*
  9086. Function: Command_TradeReject()
  9087. Purpose : Rejects item/coin trade between players
  9088. Params :
  9089. Dev :
  9090. Example :
  9091. */
  9092. void Commands::Command_TradeReject(Client* client, Seperator* sep)
  9093. {
  9094. PrintSep(sep, "COMMAND_REJECT_TRADE");
  9095. Command_TradeCancel(client, sep);
  9096. }
  9097. /*
  9098. Function: Command_TradeCancel()
  9099. Purpose : Cancels item/coin trade between players
  9100. Params :
  9101. Dev :
  9102. Example :
  9103. */
  9104. void Commands::Command_TradeCancel(Client* client, Seperator* sep)
  9105. {
  9106. PrintSep(sep, "COMMAND_CANCEL_TRADE");
  9107. Trade* trade = client->GetPlayer()->trade;
  9108. if (trade) {
  9109. trade->CancelTrade(client->GetPlayer());
  9110. safe_delete(trade);
  9111. }
  9112. else
  9113. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  9114. }
  9115. /*
  9116. Function: Command_TradeSetCoin()
  9117. Purpose : Sets coin trade between players
  9118. Params :
  9119. Dev :
  9120. Example :
  9121. */
  9122. void Commands::Command_TradeSetCoin(Client* client, Seperator* sep)
  9123. {
  9124. PrintSep(sep, "COMMAND_SET_TRADE_COIN");
  9125. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Set Trade Coin");
  9126. client->Message(CHANNEL_COLOR_YELLOW, "You cannot trade with other players (Not Implemented)");
  9127. }
  9128. /*
  9129. Function: Command_TradeAddCoin()
  9130. Purpose : Adds coin to trade between players
  9131. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  9132. Dev :
  9133. Example :
  9134. */
  9135. void Commands::Command_TradeAddCoin(Client* client, Seperator* sep, int handler)
  9136. {
  9137. PrintSep(sep, "COMMAND_ADD_TRADE_{coin type}");
  9138. Trade* trade = client->GetPlayer()->trade;
  9139. if (trade) {
  9140. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  9141. int32 amount = atoi(sep->arg[0]);
  9142. int64 val = 0;
  9143. switch (handler) {
  9144. case COMMAND_ADD_TRADE_COPPER:
  9145. {
  9146. val = amount;
  9147. trade->AddCoinToTrade(client->GetPlayer(), val);
  9148. break;
  9149. }
  9150. case COMMAND_ADD_TRADE_SILVER:
  9151. {
  9152. val = amount * 100;
  9153. trade->AddCoinToTrade(client->GetPlayer(), val);
  9154. break;
  9155. }
  9156. case COMMAND_ADD_TRADE_GOLD:
  9157. {
  9158. val = amount * 10000;
  9159. trade->AddCoinToTrade(client->GetPlayer(), val);
  9160. break;
  9161. }
  9162. case COMMAND_ADD_TRADE_PLAT:
  9163. {
  9164. val = amount * 1000000;
  9165. trade->AddCoinToTrade(client->GetPlayer(), val);
  9166. break;
  9167. }
  9168. default:
  9169. {
  9170. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  9171. break;
  9172. }
  9173. }
  9174. }
  9175. else
  9176. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount.");
  9177. }
  9178. else
  9179. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  9180. }
  9181. /*
  9182. Function: Command_TradeRemoveCoin()
  9183. Purpose : Removes coin from trade between players
  9184. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  9185. Dev :
  9186. Example :
  9187. */
  9188. void Commands::Command_TradeRemoveCoin(Client* client, Seperator* sep, int handler)
  9189. {
  9190. PrintSep(sep, "COMMAND_REMOVE_TRADE_{coin type}");
  9191. Trade* trade = client->GetPlayer()->trade;
  9192. if (trade) {
  9193. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  9194. int32 amount = atoi(sep->arg[0]);
  9195. int64 val = 0;
  9196. switch (handler) {
  9197. case COMMAND_REMOVE_TRADE_COPPER:
  9198. {
  9199. val = amount;
  9200. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  9201. break;
  9202. }
  9203. case COMMAND_REMOVE_TRADE_SILVER:
  9204. {
  9205. val = amount * 100;
  9206. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  9207. break;
  9208. }
  9209. case COMMAND_REMOVE_TRADE_GOLD:
  9210. {
  9211. val = amount * 10000;
  9212. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  9213. break;
  9214. }
  9215. case COMMAND_REMOVE_TRADE_PLAT:
  9216. {
  9217. val = amount * 1000000;
  9218. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  9219. break;
  9220. }
  9221. default:
  9222. {
  9223. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  9224. break;
  9225. }
  9226. }
  9227. }
  9228. else
  9229. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount");
  9230. }
  9231. else
  9232. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  9233. }
  9234. /*
  9235. Function: Command_TradeAddItem()
  9236. Purpose : Adds item to trade between players
  9237. Params :
  9238. Dev :
  9239. Example :
  9240. */
  9241. void Commands::Command_TradeAddItem(Client* client, Seperator* sep)
  9242. {
  9243. PrintSep(sep, "COMMAND_ADD_TRADE_ITEM");
  9244. /*
  9245. arg[0] = item index
  9246. arg[1] = slot
  9247. arg[2] = quantity
  9248. */
  9249. if (!client->GetPlayer()->trade) {
  9250. LogWrite(PLAYER__ERROR, 0, "Trade", "Player is not currently trading.");
  9251. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  9252. return;
  9253. }
  9254. if (sep && sep->IsSet(0) && sep->IsNumber(0) && sep->IsSet(1) && sep->IsNumber(1) && sep->IsSet(2) && sep->IsNumber(2)) {
  9255. Item* item = 0;
  9256. int32 index = atoi(sep->arg[0]);
  9257. item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(index);
  9258. if (item) {
  9259. int8 result = client->GetPlayer()->trade->AddItemToTrade(client->GetPlayer(), item, atoi(sep->arg[2]), atoi(sep->arg[1]));
  9260. if (result == 1)
  9261. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Item is already being traded.");
  9262. else if (result == 2)
  9263. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade NO-TRADE items.");
  9264. else if (result == 3)
  9265. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade HEIRLOOM items.");
  9266. else if (result == 254)
  9267. client->Message(CHANNEL_COLOR_YELLOW, "You are trading with an older client with a %u trade slot restriction...", client->GetPlayer()->trade->MaxSlots());
  9268. else if (result == 255)
  9269. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown error trying to add the item to the trade...");
  9270. }
  9271. else {
  9272. LogWrite(PLAYER__ERROR, 0, "Trade", "Unable to get an item for the player (%s) from the index (%u)", client->GetPlayer()->GetName(), index);
  9273. client->Message(CHANNEL_ERROR, "Unable to find item at index %u", index);
  9274. }
  9275. }
  9276. else
  9277. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  9278. }
  9279. /*
  9280. Function: Command_TradeRemoveItem()
  9281. Purpose : Removes item from trade between players
  9282. Params :
  9283. Dev :
  9284. Example :
  9285. */
  9286. void Commands::Command_TradeRemoveItem(Client* client, Seperator* sep)
  9287. {
  9288. PrintSep(sep, "COMMAND_REMOVE_TRADE_ITEM");
  9289. /*
  9290. arg[0] = trade window slot
  9291. */
  9292. Trade* trade = client->GetPlayer()->trade;
  9293. if (trade) {
  9294. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  9295. trade->RemoveItemFromTrade(client->GetPlayer(), atoi(sep->arg[0]));
  9296. }
  9297. else
  9298. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  9299. }
  9300. else
  9301. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  9302. }
  9303. void Commands::Command_TryOn(Client* client, Seperator* sep)
  9304. {
  9305. Item *item = 0;
  9306. sint32 crc;
  9307. if (sep) {
  9308. // 1096+ sends more info so need to do a version check so older clients (SF) still work
  9309. if (client->GetVersion() < 1096) {
  9310. if (sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2))
  9311. {
  9312. item = master_item_list.GetItem(atoul(sep->arg[1]));
  9313. crc = atol(sep->arg[2]);
  9314. }
  9315. }
  9316. else {
  9317. // From the broker and links in chat
  9318. if (strcmp(sep->arg[0], "crc") == 0) {
  9319. if (sep->IsNumber(2) && sep->IsNumber(3)) {
  9320. item = master_item_list.GetItem(atoul(sep->arg[2]));
  9321. crc = atol(sep->arg[3]);
  9322. }
  9323. }
  9324. // From inventory
  9325. if (strcmp(sep->arg[0], "dbid") == 0) {
  9326. if (sep->IsNumber(2) && sep->IsNumber(4)) {
  9327. item = master_item_list.GetItem(atoul(sep->arg[2]));
  9328. crc = atol(sep->arg[4]);
  9329. }
  9330. }
  9331. }
  9332. if (item)
  9333. client->ShowDressingRoom(item, crc);
  9334. }
  9335. }
  9336. void Commands::Command_JoinChannel(Client * client, Seperator *sep) {
  9337. const char *channel_name, *password = NULL;
  9338. if (sep == NULL || !sep->IsSet(0)) {
  9339. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /joinchannel <channel name> [password]");
  9340. return;
  9341. }
  9342. channel_name = sep->arg[0];
  9343. if (sep->IsSet(1))
  9344. password = sep->arg[1];
  9345. if (!chat.ChannelExists(channel_name) && !chat.CreateChannel(channel_name, password)) {
  9346. client->Message(CHANNEL_COLOR_RED, "Unable to create channel '%s'.", channel_name);
  9347. return;
  9348. }
  9349. if (chat.IsInChannel(client, channel_name)) {
  9350. client->Message(CHANNEL_NARRATIVE, "You are already in '%s'.", channel_name);
  9351. return;
  9352. }
  9353. if (chat.HasPassword(channel_name)) {
  9354. if (password == NULL) {
  9355. client->Message(CHANNEL_NARRATIVE, "Unable to join '%s': That channel is password protected.", channel_name);
  9356. return;
  9357. }
  9358. if (!chat.PasswordMatches(channel_name, password)) {
  9359. client->Message(CHANNEL_NARRATIVE, "Unable to join '%s': The password is not correc.t", channel_name);
  9360. return;
  9361. }
  9362. }
  9363. if (!chat.JoinChannel(client, channel_name))
  9364. client->Message(CHANNEL_COLOR_RED, "There was an internal error preventing you from joining '%s'.", channel_name);
  9365. }
  9366. void Commands::Command_JoinChannelFromLoad(Client * client, Seperator *sep) {
  9367. printf("ScatDebug: Received 'joinfromchannel', using the same function as 'joinchannel' (not sure what the difference is)\n");
  9368. Command_JoinChannel(client, sep);
  9369. }
  9370. void Commands::Command_TellChannel(Client *client, Seperator *sep) {
  9371. if (sep == NULL || !sep->IsSet(0) || !sep->IsSet(1)) {
  9372. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /tellchannel <channel name> <message>");
  9373. PrintSep(sep, "tellchannel");
  9374. return;
  9375. }
  9376. chat.TellChannel(client, sep->arg[0], sep->argplus[1]);
  9377. }
  9378. void Commands::Command_Test(Client* client, EQ2_16BitString* command_parms) {
  9379. Seperator* sep = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  9380. if (sep->IsSet(0)) {
  9381. if (atoi(sep->arg[0]) == 1) {
  9382. PacketStruct* packet2 = configReader.getStruct("WS_SpellGainedMsg", client->GetVersion());
  9383. if (packet2) {
  9384. packet2->setDataByName("spell_type", 2);
  9385. packet2->setDataByName("spell_id", 8308);
  9386. packet2->setDataByName("spell_name", "Sprint");
  9387. packet2->setDataByName("add_silently", 0);
  9388. packet2->setDataByName("tier", 1);
  9389. packet2->setDataByName("blah1", 1);
  9390. packet2->setDataByName("blah2", 1);
  9391. EQ2Packet* outapp = packet2->serialize();
  9392. DumpPacket(outapp);
  9393. client->QueuePacket(outapp);
  9394. safe_delete(packet2);
  9395. }
  9396. }
  9397. else if (atoi(sep->arg[0]) == 2) {
  9398. PacketStruct* packet2 = configReader.getStruct("WS_GuildUpdate", client->GetVersion());
  9399. if (packet2) {
  9400. packet2->setDataByName("guild_name", "Test");
  9401. packet2->setDataByName("guild_motd", "Test MOTD");
  9402. packet2->setDataByName("guild_id", 1234);
  9403. packet2->setDataByName("guild_level", 1);
  9404. packet2->setDataByName("unknown", 2);
  9405. packet2->setDataByName("unknown2", 3);
  9406. packet2->setDataByName("exp_current", 1);
  9407. packet2->setDataByName("exp_to_next_level", 4);
  9408. EQ2Packet* outapp = packet2->serialize();
  9409. DumpPacket(outapp);
  9410. client->QueuePacket(outapp);
  9411. safe_delete(packet2);
  9412. }
  9413. }
  9414. else if (atoi(sep->arg[0]) == 3) {
  9415. PacketStruct* packet2 = configReader.getStruct("WS_JoinGuildNotify", client->GetVersion());
  9416. if (packet2) {
  9417. packet2->setDataByName("guild_id", 1234);
  9418. packet2->setDataByName("character_id", 1);
  9419. packet2->setDataByName("account_id", 2);
  9420. packet2->setDataByName("guild_level", 1);
  9421. packet2->setDataByName("name", "Test");
  9422. packet2->setDataByName("unknown2", 0);
  9423. packet2->setDataByName("unknown3", 1);
  9424. packet2->setDataByName("adventure_class", 6);
  9425. packet2->setDataByName("adventure_level", 7);
  9426. packet2->setDataByName("tradeskill_class", 4);
  9427. packet2->setDataByName("tradeskill_level", 5);
  9428. packet2->setDataByName("rank", 0);
  9429. packet2->setDataByName("member_flags", 2);
  9430. packet2->setDataByName("join_date", 1591112273);
  9431. packet2->setDataByName("guild_status", 2);
  9432. packet2->setDataByName("last_login", 1591132273);
  9433. packet2->setDataByName("recruiter_id", 1);
  9434. packet2->setDataByName("points", 2345);
  9435. packet2->setDataByName("note", "note");
  9436. packet2->setMediumStringByName("officer_note", "O note");
  9437. packet2->setMediumStringByName("zone", "Blah");
  9438. EQ2Packet* outapp = packet2->serialize();
  9439. DumpPacket(outapp);
  9440. client->QueuePacket(outapp);
  9441. safe_delete(packet2);
  9442. }
  9443. }
  9444. else if (atoi(sep->arg[0]) == 5) {
  9445. int16 offset = atoi(sep->arg[1]);
  9446. int32 value1 = atol(sep->arg[2]);
  9447. EQ2Packet* outapp = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion(), offset, value1);
  9448. client->QueuePacket(outapp);
  9449. }
  9450. else if (atoi(sep->arg[0]) == 6) {
  9451. Spawn* spawn = client->GetPlayer()->GetTarget();
  9452. if (!spawn)
  9453. spawn = client->GetPlayer();
  9454. else if (spawn->IsEntity())
  9455. ((Entity*)spawn)->SetSpeed(atof(sep->arg[4]));
  9456. spawn->RunToLocation(atof(sep->arg[1]), atof(sep->arg[2]), atof(sep->arg[3]));
  9457. }
  9458. else if (atoi(sep->arg[0]) == 7) {
  9459. int32 id = 0;
  9460. Spawn* spawn = client->GetCurrentZone()->GetSpawn(7720001);
  9461. if (spawn) {
  9462. spawn->SetX(client->GetPlayer()->GetX() + .5, false);
  9463. spawn->SetY(client->GetPlayer()->GetY(), false);
  9464. spawn->SetZ(client->GetPlayer()->GetZ() + .5, false);
  9465. float heading = client->GetPlayer()->GetHeading() + 180;
  9466. if (heading > 360)
  9467. heading -= 360;
  9468. spawn->SetLevel(5);
  9469. spawn->SetAdventureClass(4);
  9470. spawn->SetHeading(heading, false);
  9471. spawn->SetSpawnOrigX(spawn->GetX());
  9472. spawn->SetSpawnOrigY(spawn->GetY());
  9473. spawn->SetSpawnOrigZ(spawn->GetZ());
  9474. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  9475. spawn->SetLocation(client->GetPlayer()->GetLocation());
  9476. spawn->appearance.targetable = 1;
  9477. if (spawn->IsNPC() && spawn->GetTotalHP() == 0) {
  9478. spawn->SetTotalHP(spawn->GetLevel() * 15);
  9479. spawn->SetHP(spawn->GetTotalHP());
  9480. }
  9481. if (spawn->GetTotalPower() == 0) {
  9482. spawn->SetTotalPower(spawn->GetLevel() * 15);
  9483. spawn->SetPower(spawn->GetTotalPower());
  9484. }
  9485. int16 offset = atoi(sep->arg[1]);
  9486. int32 value1 = atol(sep->arg[2]);
  9487. sprintf(spawn->appearance.name, "Offset %i", offset);
  9488. EQ2Packet* ret = spawn->spawn_serialize(client->GetPlayer(), client->GetVersion(), offset, value1);
  9489. DumpPacket(ret);
  9490. client->QueuePacket(ret);
  9491. }
  9492. }
  9493. else if (atoi(sep->arg[0]) == 8) {
  9494. int32 id = atoi(sep->arg[1]);
  9495. Spawn* spawn = client->GetCurrentZone()->GetSpawn(id);
  9496. if (spawn) {
  9497. spawn->SetX(client->GetPlayer()->GetX() + .5, false);
  9498. spawn->SetY(client->GetPlayer()->GetY(), false);
  9499. spawn->SetZ(client->GetPlayer()->GetZ() + .5, false);
  9500. float heading = client->GetPlayer()->GetHeading() + 180;
  9501. if (heading > 360)
  9502. heading -= 360;
  9503. spawn->SetLevel(5);
  9504. spawn->SetAdventureClass(4);
  9505. spawn->SetHeading(heading, false);
  9506. spawn->SetSpawnOrigX(spawn->GetX());
  9507. spawn->SetSpawnOrigY(spawn->GetY());
  9508. spawn->SetSpawnOrigZ(spawn->GetZ());
  9509. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  9510. spawn->SetLocation(client->GetPlayer()->GetLocation());
  9511. spawn->appearance.targetable = 1;
  9512. if (spawn->IsNPC() && spawn->GetTotalHP() == 0) {
  9513. spawn->SetTotalHP(spawn->GetLevel() * 15);
  9514. spawn->SetHP(spawn->GetTotalHP());
  9515. }
  9516. if (spawn->GetTotalPower() == 0) {
  9517. spawn->SetTotalPower(spawn->GetLevel() * 15);
  9518. spawn->SetPower(spawn->GetTotalPower());
  9519. }
  9520. int16 offset = atoi(sep->arg[2]);
  9521. int16 offset2 = atoi(sep->arg[3]);
  9522. int32 value1 = atol(sep->arg[4]);
  9523. int16 offset3 = 0;
  9524. int16 offset4 = 0;
  9525. int32 value2 = 0;
  9526. if (sep->IsSet(7)) {
  9527. offset3 = atoi(sep->arg[5]);
  9528. offset4 = atoi(sep->arg[6]);
  9529. value2 = atol(sep->arg[7]);
  9530. }
  9531. sprintf(spawn->appearance.name, "Offset %i to %i", offset, offset2);
  9532. spawn->AddPrimaryEntityCommand("attack", 10000, "attack","", 0, 0);
  9533. EQ2Packet* ret = spawn->spawn_serialize(client->GetPlayer(), client->GetVersion(), offset, value1, offset2, offset3, offset4, value2);
  9534. DumpPacket(ret);
  9535. client->QueuePacket(ret);
  9536. }
  9537. }
  9538. else if (atoi(sep->arg[0]) == 9) {
  9539. PacketStruct* packet2 = configReader.getStruct("WS_DeathWindow", client->GetVersion());
  9540. if (packet2) {
  9541. packet2->setArrayLengthByName("location_count", 1);
  9542. packet2->setArrayDataByName("location_ida", 1234);
  9543. packet2->setArrayDataByName("unknown2a", 3);
  9544. packet2->setArrayDataByName("zone_name", "Queen's Colony");
  9545. packet2->setArrayDataByName("location_name", "Myrrin's Tower");
  9546. packet2->setArrayDataByName("distance", 134);
  9547. EQ2Packet* app = packet2->serialize();
  9548. if (sep->IsSet(2)) {
  9549. int8 offset = atoi(sep->arg[1]);
  9550. uchar* ptr2 = app->pBuffer;
  9551. ptr2 += offset;
  9552. if (sep->IsNumber(2)) {
  9553. int32 value1 = atol(sep->arg[2]);
  9554. if (value1 > 0xFFFF)
  9555. memcpy(ptr2, (uchar*)&value1, 4);
  9556. else if (value1 > 0xFF)
  9557. memcpy(ptr2, (uchar*)&value1, 2);
  9558. else
  9559. memcpy(ptr2, (uchar*)&value1, 1);
  9560. }
  9561. else {
  9562. int8 len = strlen(sep->arg[2]);
  9563. memcpy(ptr2, (uchar*)&len, 1);
  9564. ptr2 += 1;
  9565. memcpy(ptr2, sep->arg[2], len);
  9566. }
  9567. }
  9568. DumpPacket(app);
  9569. client->QueuePacket(app);
  9570. safe_delete(packet2);
  9571. }
  9572. }
  9573. else if (atoi(sep->arg[0]) == 10) {
  9574. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalUpdate", client->GetVersion());
  9575. if (packet2) {
  9576. packet2->setArrayLengthByName("num_quests", 1);
  9577. packet2->setArrayDataByName("active", 1);
  9578. packet2->setArrayDataByName("name", "Tasks aboard the Far Journey");
  9579. packet2->setArrayDataByName("quest_type", "Hallmark");
  9580. packet2->setArrayDataByName("quest_zone", "Hallmark");
  9581. packet2->setArrayDataByName("journal_updated", 1);
  9582. packet2->setArrayDataByName("quest_id", 524);
  9583. packet2->setArrayDataByName("day", 19);
  9584. packet2->setArrayDataByName("month", 6);
  9585. packet2->setArrayDataByName("year", 20);
  9586. packet2->setArrayDataByName("level", 2);
  9587. packet2->setArrayDataByName("encounter_level", 4);
  9588. packet2->setArrayDataByName("difficulty", 3);
  9589. packet2->setArrayDataByName("visible", 1);
  9590. packet2->setDataByName("visible_quest_id", 524);
  9591. packet2->setDataByName("player_crc", 2900677088);
  9592. packet2->setDataByName("player_name", "LethalEncounter");
  9593. EQ2Packet* app = packet2->serialize();
  9594. if (sep->IsSet(2)) {
  9595. int8 offset = atoi(sep->arg[1]);
  9596. uchar* ptr2 = app->pBuffer;
  9597. ptr2 += offset;
  9598. if (sep->IsNumber(2)) {
  9599. int32 value1 = atol(sep->arg[2]);
  9600. if (value1 > 0xFFFF)
  9601. memcpy(ptr2, (uchar*)&value1, 4);
  9602. else if (value1 > 0xFF)
  9603. memcpy(ptr2, (uchar*)&value1, 2);
  9604. else
  9605. memcpy(ptr2, (uchar*)&value1, 1);
  9606. }
  9607. else {
  9608. int8 len = strlen(sep->arg[2]);
  9609. memcpy(ptr2, (uchar*)&len, 1);
  9610. ptr2 += 1;
  9611. memcpy(ptr2, sep->arg[2], len);
  9612. }
  9613. }
  9614. DumpPacket(app);
  9615. client->QueuePacket(app);
  9616. safe_delete(packet2);
  9617. }
  9618. }
  9619. else if (atoi(sep->arg[0]) == 11) {
  9620. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalReply", client->GetVersion());
  9621. if (packet2) {
  9622. packet2->setDataByName("quest_id", 524);
  9623. packet2->setDataByName("player_crc", 2900677088);
  9624. packet2->setDataByName("name", "Tasks aboard the Far Journey");
  9625. packet2->setDataByName("description", "I completed all the tasks assigned to me by Captain Varlos aboard the Far Journey");
  9626. packet2->setDataByName("type", "Hallmark");
  9627. packet2->setDataByName("complete_header", "To complete this quest, I must do the following tasks:");
  9628. packet2->setDataByName("day", 19);
  9629. packet2->setDataByName("month", 6);
  9630. packet2->setDataByName("year", 20);
  9631. packet2->setDataByName("level", 1);
  9632. packet2->setDataByName("encounter_level", 1);
  9633. packet2->setDataByName("difficulty", 1);
  9634. packet2->setDataByName("time_obtained", Timer::GetUnixTimeStamp());
  9635. //packet2->setDataByName("timer_start", Timer::GetUnixTimeStamp());
  9636. //packet2->setDataByName("timer_duration", 300);
  9637. //packet2->setDataByName("timer_running", 1);
  9638. packet2->setArrayLengthByName("task_groups_completed", 9);
  9639. packet2->setArrayLengthByName("num_task_groups", 10);
  9640. packet2->setArrayDataByName("task_group", "I spoke to Waulon as Captain Varlos had asked of me.");
  9641. packet2->setArrayDataByName("task_group", "I found Waulon's hat in one of the boxes.", 1);
  9642. packet2->setArrayDataByName("task_group", "I returned Waulon's hat.", 2);
  9643. packet2->setArrayDataByName("task_group", "I have spoken to Ingrid.", 3);
  9644. packet2->setArrayDataByName("task_group", "I purchased a Shard of Luclin.", 4);
  9645. packet2->setArrayDataByName("task_group", "I gave the Shard of Luclin to Ingrid.", 5);
  9646. packet2->setArrayDataByName("task_group", "I have spoken to Captain Varlos.", 6);
  9647. packet2->setArrayDataByName("task_group", "I killed the rats that Captain Varlos requested.", 7);
  9648. packet2->setArrayDataByName("task_group", "Captain Varlos has ordered you to kill the escaped goblin.", 8);
  9649. packet2->setArrayDataByName("task_group", "I killed the escaped goblin.", 9);
  9650. /*packet2->setSubArrayLengthByName("num_tasks", 1);
  9651. packet2->setSubArrayDataByName("task", "I need to talk to Garven Tralk");
  9652. packet2->setSubArrayLengthByName("num_updates", 1);
  9653. packet2->setSubArrayDataByName("update_currentval", 0);
  9654. packet2->setSubArrayDataByName("update_maxval", 1);
  9655. packet2->setSubArrayDataByName("icon", 11);
  9656. */
  9657. packet2->setArrayDataByName("waypoint", 0xFFFFFFFF);
  9658. packet2->setDataByName("journal_updated", 1);
  9659. packet2->setDataByName("bullets", 1);
  9660. EQ2Packet* app = packet2->serialize();
  9661. if (sep->IsSet(2)) {
  9662. int16 offset = atoi(sep->arg[1]);
  9663. uchar* ptr2 = app->pBuffer;
  9664. ptr2 += offset;
  9665. if (sep->IsNumber(2)) {
  9666. int32 value1 = atol(sep->arg[2]);
  9667. if (value1 > 0xFFFF)
  9668. memcpy(ptr2, (uchar*)&value1, 4);
  9669. else if (value1 > 0xFF)
  9670. memcpy(ptr2, (uchar*)&value1, 2);
  9671. else
  9672. memcpy(ptr2, (uchar*)&value1, 1);
  9673. }
  9674. else {
  9675. int16 len = strlen(sep->arg[2]);
  9676. memcpy(ptr2, (uchar*)&len, 2);
  9677. ptr2 += 2;
  9678. memcpy(ptr2, sep->arg[2], len);
  9679. }
  9680. }
  9681. DumpPacket(app);
  9682. client->QueuePacket(app);
  9683. safe_delete(packet2);
  9684. }
  9685. }
  9686. else if (atoi(sep->arg[0]) == 12) {
  9687. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalReply", client->GetVersion());
  9688. if (packet2) {
  9689. packet2->setDataByName("quest_id", 5725);
  9690. packet2->setDataByName("player_crc", 2900677088);
  9691. packet2->setDataByName("name", "Archetype Selection");
  9692. packet2->setDataByName("description", "I have reported my profession to Garven Tralk.");
  9693. packet2->setDataByName("type", "Hallmark");
  9694. packet2->setDataByName("complete_header", "To complete this quest, I must do the following tasks:");
  9695. packet2->setDataByName("day", 19);
  9696. packet2->setDataByName("month", 6);
  9697. packet2->setDataByName("year", 20);
  9698. packet2->setDataByName("level", 2);
  9699. packet2->setDataByName("encounter_level", 4);
  9700. packet2->setDataByName("difficulty", 3);
  9701. packet2->setDataByName("time_obtained", Timer::GetUnixTimeStamp());
  9702. packet2->setDataByName("timer_start", Timer::GetUnixTimeStamp());
  9703. packet2->setDataByName("timer_duration", 300);
  9704. packet2->setDataByName("timer_running", 1);
  9705. packet2->setArrayLengthByName("task_groups_completed", 0);
  9706. packet2->setArrayLengthByName("num_task_groups", 1);
  9707. packet2->setArrayDataByName("task_group", "I need to talk to Garven Tralk");
  9708. packet2->setSubArrayLengthByName("num_tasks", 1);
  9709. packet2->setSubArrayDataByName("task", "I need to talk to Garven Tralk");
  9710. packet2->setSubArrayLengthByName("num_updates", 1);
  9711. packet2->setSubArrayDataByName("update_currentval", 0);
  9712. packet2->setSubArrayDataByName("update_maxval", 1);
  9713. packet2->setSubArrayDataByName("icon", 11);
  9714. packet2->setArrayDataByName("waypoint", 0xFFFFFFFF);
  9715. packet2->setDataByName("journal_updated", 1);
  9716. packet2->setSubstructDataByName("reward_data", "unknown1", 255);
  9717. packet2->setSubstructDataByName("reward_data", "reward", "Quest Reward!");
  9718. packet2->setSubstructDataByName("reward_data", "unknown2", 0x3f);
  9719. packet2->setSubstructDataByName("reward_data", "coin", 150);
  9720. packet2->setSubstructDataByName("reward_data", "status_points", 5);
  9721. packet2->setSubstructDataByName("reward_data", "exp_bonus", 10);
  9722. packet2->setSubstructArrayLengthByName("reward_data", "num_rewards", 1);
  9723. packet2->setSubstructArrayDataByName("reward_data", "reward_id", 123);
  9724. Item* item = master_item_list.GetItem(152755);
  9725. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9726. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, client->GetClientItemPacketOffset());
  9727. /*packet2->setSubstructDataByName("item", "unique_id", 567);
  9728. packet2->setSubstructDataByName("item", "broker_item_id", 0xFFFFFFFFFFFFFFFF);
  9729. packet2->setSubstructDataByName("item", "icon", 0xe7);
  9730. packet2->setSubstructDataByName("item", "tier", 4);
  9731. packet2->setSubstructDataByName("item", "flags", 0x60);
  9732. packet2->setSubstructArrayLengthByName("item", "stat_count", 1);
  9733. packet2->setSubstructDataByName("item", "stat_type", 1);
  9734. packet2->setSubstructDataByName("item", "stat_subtype", 2);
  9735. packet2->setSubstructDataByName("item", "value", 3);
  9736. packet2->setSubstructDataByName("item", "condition", 100);
  9737. packet2->setSubstructDataByName("item", "weight", 1);
  9738. packet2->setSubstructDataByName("item", "skill_req1", 0xacafa99e);
  9739. packet2->setSubstructDataByName("item", "skill_req2", 0xacafa99e);
  9740. packet2->setSubstructDataByName("item", "skill_min", 1);
  9741. packet2->setSubstructArrayLengthByName("item", "class_count", 3);
  9742. packet2->setSubstructDataByName("item", "adventure_class", 1);
  9743. packet2->setSubstructDataByName("item", "adventure_class", 11, 0, 1);
  9744. packet2->setSubstructDataByName("item", "adventure_class", 0x1f, 0, 2);
  9745. packet2->setSubstructDataByName("item", "tradeskill_class", 255);
  9746. packet2->setSubstructDataByName("item", "tradeskill_class", 255, 0, 1);
  9747. packet2->setSubstructDataByName("item", "tradeskill_class", 255, 0, 2);
  9748. packet2->setSubstructDataByName("item", "level", 0x1e);
  9749. packet2->setSubstructDataByName("item", "level", 100, 0, 1);
  9750. packet2->setSubstructDataByName("item", "level", 100, 0, 2);
  9751. packet2->setSubstructDataByName("item_footer", "name", "Footman Gloves");*/
  9752. //packet2->PrintPacket();
  9753. EQ2Packet* app = packet2->serialize();
  9754. if (sep->IsSet(2)) {
  9755. int16 offset = atoi(sep->arg[1]);
  9756. uchar* ptr2 = app->pBuffer;
  9757. ptr2 += offset;
  9758. if (sep->IsNumber(2)) {
  9759. int32 value1 = atol(sep->arg[2]);
  9760. if (value1 > 0xFFFF)
  9761. memcpy(ptr2, (uchar*)&value1, 4);
  9762. else if (value1 > 0xFF)
  9763. memcpy(ptr2, (uchar*)&value1, 2);
  9764. else
  9765. memcpy(ptr2, (uchar*)&value1, 1);
  9766. }
  9767. else {
  9768. int16 len = strlen(sep->arg[2]);
  9769. memcpy(ptr2, (uchar*)&len, 2);
  9770. ptr2 += 2;
  9771. memcpy(ptr2, sep->arg[2], len);
  9772. }
  9773. }
  9774. DumpPacket(app);
  9775. client->QueuePacket(app);
  9776. safe_delete(packet2);
  9777. }
  9778. }
  9779. else if (atoi(sep->arg[0]) == 13) {
  9780. PacketStruct* packet2 = configReader.getStruct("WS_OnScreenMsg", client->GetVersion());
  9781. if (packet2 && sep->IsSet(7)) {
  9782. packet2->setDataByName("unknown", atoi(sep->arg[1]));
  9783. char blah[128];
  9784. sprintf(blah, "\\#6EFF6EYou get better at \12\\#C8FFC8%s\\#6EFF6E! (7/15)", sep->arg[2]);
  9785. packet2->setDataByName("text", blah);
  9786. packet2->setDataByName("message_type", sep->arg[3]);
  9787. packet2->setDataByName("size", atof(sep->arg[4]));
  9788. packet2->setDataByName("red", atoi(sep->arg[5]));
  9789. packet2->setDataByName("green", atoi(sep->arg[6]));
  9790. packet2->setDataByName("blue", atoi(sep->arg[7]));
  9791. EQ2Packet* app = packet2->serialize();
  9792. DumpPacket(app);
  9793. client->QueuePacket(app);
  9794. safe_delete(packet2);
  9795. }
  9796. }
  9797. else if (atoi(sep->arg[0]) == 14) {
  9798. PacketStruct* packet2 = configReader.getStruct("WS_InstructionWindow", client->GetVersion());
  9799. if (packet2 && sep->IsSet(3)) {
  9800. packet2->setDataByName("open_seconds_min", atof(sep->arg[1]));
  9801. packet2->setDataByName("open_seconds_max", atof(sep->arg[2]));
  9802. packet2->setDataByName("voice_sync", atoi(sep->arg[3]));
  9803. 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.");
  9804. packet2->setDataByName("voice", "voiceover/english/narrator/boat_06p_tutorial02/narrator_001_63779ca0.mp3");
  9805. packet2->setArrayLengthByName("num_goals", 1);
  9806. //packet2->setArrayDataByName("goal_text", )
  9807. packet2->setSubArrayLengthByName("num_tasks", 1);
  9808. packet2->setSubArrayDataByName("task_text", "continue");
  9809. packet2->setDataByName("complete_sound", "click");
  9810. packet2->setDataByName("signal", "introduction");
  9811. packet2->setDataByName("voice_key1", 0xcda65173);
  9812. packet2->setDataByName("voice_key2", 0x984bfc6d);
  9813. EQ2Packet* app = packet2->serialize();
  9814. DumpPacket(app);
  9815. client->QueuePacket(app);
  9816. safe_delete(packet2);
  9817. packet2 = configReader.getStruct("WS_ShowWindow", client->GetVersion());
  9818. packet2->setDataByName("window", "MainHUD.StartMenu");
  9819. packet2->setDataByName("show", 1);
  9820. app = packet2->serialize();
  9821. DumpPacket(app);
  9822. client->QueuePacket(app);
  9823. safe_delete(packet2);
  9824. packet2 = configReader.getStruct("WS_FlashWindow", client->GetVersion());
  9825. packet2->setDataByName("window", "MainHUD.StartMenu.help");
  9826. packet2->setDataByName("flash_seconds", 10);
  9827. app = packet2->serialize();
  9828. DumpPacket(app);
  9829. client->QueuePacket(app);
  9830. safe_delete(packet2);
  9831. }
  9832. }
  9833. else if (atoi(sep->arg[0]) == 15) {
  9834. PacketStruct* packet2 = configReader.getStruct("WS_UpdateLoot", client->GetVersion());
  9835. if (packet2) {
  9836. packet2->setArrayLengthByName("loot_count", 1);
  9837. packet2->setArrayDataByName("name", "Test");
  9838. packet2->setArrayDataByName("item_id", 1234);
  9839. packet2->setArrayDataByName("count", 1);
  9840. packet2->setArrayDataByName("icon", 258);
  9841. packet2->setArrayDataByName("ability_id", 0xFFFFFFFF);
  9842. Spawn* spawn = client->GetPlayer()->GetTarget();
  9843. if (spawn)
  9844. packet2->setDataByName("object_id", client->GetPlayer()->GetIDWithPlayerSpawn(spawn));
  9845. packet2->setDataByName("display", 1);
  9846. packet2->setDataByName("loot_type", 1);
  9847. packet2->setDataByName("lotto_timeout", 60);
  9848. EQ2Packet* app = packet2->serialize();
  9849. DumpPacket(app);
  9850. client->QueuePacket(app);
  9851. safe_delete(packet2);
  9852. }
  9853. }
  9854. else if (atoi(sep->arg[0]) == 16 && sep->IsNumber(1)) {
  9855. char blah[32];
  9856. sprintf(blah, "Testing: %i", atoi(sep->arg[1]));
  9857. client->SimpleMessage(atoi(sep->arg[1]), blah);
  9858. }
  9859. else if (atoi(sep->arg[0]) == 17 && sep->IsNumber(2)) {
  9860. if (sep->IsSet(2)) {
  9861. int16 offset = atoi(sep->arg[1]);
  9862. if (sep->IsNumber(2)) {
  9863. int32 value1 = atol(sep->arg[2]);
  9864. client->QueuePacket(client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion(), offset, value1));
  9865. cout << "Sent" << endl;
  9866. }
  9867. }
  9868. }
  9869. else if (atoi(sep->arg[0]) == 18) {
  9870. PacketStruct* packet2 = configReader.getStruct("WS_QuestRewardPackMsg", client->GetVersion());
  9871. if (packet2) {
  9872. packet2->setSubstructDataByName("reward_data", "unknown1", 255);
  9873. packet2->setSubstructDataByName("reward_data", "reward", "Quest Reward!");
  9874. packet2->setSubstructDataByName("reward_data", "max_coin", 0);
  9875. packet2->setSubstructDataByName("reward_data", "text", "Some custom text to mess things up?");
  9876. packet2->setSubstructDataByName("reward_data", "status_points", 5);
  9877. //packet2->setSubstructDataByName("reward_data", "exp_bonus", 10);
  9878. packet2->setSubstructArrayLengthByName("reward_data", "num_rewards", 1);
  9879. Item* item = new Item(master_item_list.GetItem(9357));
  9880. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9881. //item->stack_count = 20;
  9882. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, client->GetClientItemPacketOffset());
  9883. safe_delete(item);
  9884. /*item = new Item(master_item_list.GetItem(36685));
  9885. item->stack_count = 20;
  9886. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9887. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 1, 0, -1);
  9888. safe_delete(item);
  9889. item = master_item_list.GetItem(1414);
  9890. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9891. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 2, 0, -1);
  9892. item = master_item_list.GetItem(75057);
  9893. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9894. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 3, 0, -1);*/
  9895. EQ2Packet* app = packet2->serialize();
  9896. if (sep->IsSet(2)) {
  9897. int16 offset = atoi(sep->arg[1]);
  9898. uchar* ptr2 = app->pBuffer;
  9899. ptr2 += offset;
  9900. if (sep->IsNumber(2)) {
  9901. int32 value1 = atol(sep->arg[2]);
  9902. if (value1 > 0xFFFF)
  9903. memcpy(ptr2, (uchar*)&value1, 4);
  9904. else if (value1 > 0xFF)
  9905. memcpy(ptr2, (uchar*)&value1, 2);
  9906. else
  9907. memcpy(ptr2, (uchar*)&value1, 1);
  9908. }
  9909. else {
  9910. int16 len = strlen(sep->arg[2]);
  9911. memcpy(ptr2, (uchar*)&len, 2);
  9912. ptr2 += 2;
  9913. memcpy(ptr2, sep->arg[2], len);
  9914. }
  9915. }
  9916. DumpPacket(app);
  9917. client->QueuePacket(app);
  9918. safe_delete(packet2);
  9919. }
  9920. }
  9921. else if (atoi(sep->arg[0]) == 19) {
  9922. PacketStruct* packet2 = configReader.getStruct("WS_UpdateLoot", client->GetVersion());
  9923. Spawn* spawn = client->GetPlayer()->GetTarget();
  9924. if (packet2 && spawn) {
  9925. Item* item = master_item_list.GetItem(130053);
  9926. packet2->setArrayLengthByName("loot_count", 1);
  9927. packet2->setArrayDataByName("loot_id", item->details.item_id);
  9928. packet2->setArrayDataByName("unknown2", 1);
  9929. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, 2, true);
  9930. packet2->setDataByName("display", 1);
  9931. packet2->setDataByName("unknown2b", 1);
  9932. packet2->setDataByName("unknown3", 0x3c);
  9933. packet2->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(spawn));
  9934. packet2->PrintPacket();
  9935. EQ2Packet* app = packet2->serialize();
  9936. if (sep->IsSet(2)) {
  9937. int16 offset = atoi(sep->arg[1]);
  9938. int16 offset2 = 0;
  9939. int32 value1 = 0;
  9940. if (sep->IsSet(3)) {
  9941. offset2 = atoi(sep->arg[2]);
  9942. value1 = atol(sep->arg[3]);
  9943. }
  9944. else
  9945. value1 = atol(sep->arg[2]);
  9946. int16 offset3 = 0;
  9947. int16 offset4 = 0;
  9948. int32 value2 = 0;
  9949. if (sep->IsSet(6)) {
  9950. offset3 = atoi(sep->arg[4]);
  9951. offset4 = atoi(sep->arg[5]);
  9952. value2 = atol(sep->arg[6]);
  9953. }
  9954. offset--;
  9955. if (offset2 > 0 && offset2 >= offset) {
  9956. offset2--;
  9957. uchar* ptr2 = app->pBuffer;
  9958. ptr2 += offset;
  9959. for (int i = offset; i <= offset2; i++) {
  9960. if (value1 > 0xFFFF) {
  9961. memcpy(ptr2, (uchar*)&value1, 4);
  9962. i += 3;
  9963. ptr2 += 3;
  9964. }
  9965. else if (value1 > 0xFF) {
  9966. memcpy(ptr2, (uchar*)&value1, 2);
  9967. i++;
  9968. ptr2++;
  9969. }
  9970. else
  9971. memcpy(ptr2, (uchar*)&value1, 1);
  9972. ptr2++;
  9973. }
  9974. }
  9975. if (offset4 > 0 && offset4 >= offset3) {
  9976. offset3--;
  9977. offset4--;
  9978. uchar* ptr2 = app->pBuffer;
  9979. ptr2 += offset3;
  9980. for (int i = offset3; i <= offset4; i++) {
  9981. if (value2 > 0xFFFF) {
  9982. memcpy(ptr2, (uchar*)&value2, 4);
  9983. i += 3;
  9984. ptr2 += 3;
  9985. }
  9986. else if (value2 > 0xFF) {
  9987. memcpy(ptr2, (uchar*)&value2, 2);
  9988. i++;
  9989. ptr2++;
  9990. }
  9991. else
  9992. memcpy(ptr2, (uchar*)&value2, 1);
  9993. ptr2++;
  9994. }
  9995. }
  9996. }
  9997. DumpPacket(app);
  9998. client->QueuePacket(app);
  9999. safe_delete(packet2);
  10000. }
  10001. }
  10002. else if (atoi(sep->arg[0]) == 21) {
  10003. PacketStruct* packet2 = configReader.getStruct("WS_OfferQuest", client->GetVersion());
  10004. if (packet2) {
  10005. packet2->setDataByName("unknown0", 255);
  10006. packet2->setDataByName("reward", "New Quest");
  10007. packet2->setDataByName("title", "Title");
  10008. packet2->setDataByName("description", "description");
  10009. packet2->setDataByName("quest_difficulty", 3);
  10010. packet2->setDataByName("unknown1", 5);
  10011. packet2->setDataByName("level", 3);
  10012. packet2->setDataByName("coin", 150);
  10013. packet2->setDataByName("status_points", 5);
  10014. packet2->setDataByName("exp_bonus", 10);
  10015. packet2->setArrayLengthByName("num_rewards", 1);
  10016. Item* item = new Item(master_item_list.GetItem(36212));
  10017. packet2->setArrayDataByName("reward_id", item->details.item_id);
  10018. item->stack_count = 20;
  10019. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, client->GetClientItemPacketOffset());
  10020. safe_delete(item);
  10021. char accept[35] = { 0 };
  10022. char decline[35] = { 0 };
  10023. sprintf(accept, "q_accept_pending_quest %u", 0);
  10024. sprintf(decline, "q_deny_pending_quest %u", 0);
  10025. packet2->setDataByName("accept_command", accept);
  10026. packet2->setDataByName("decline_command", decline);
  10027. EQ2Packet* app = packet2->serialize();
  10028. if (sep->IsSet(2)) {
  10029. int16 offset = atoi(sep->arg[1]);
  10030. uchar* ptr2 = app->pBuffer;
  10031. ptr2 += offset;
  10032. if (sep->IsNumber(2)) {
  10033. int32 value1 = atol(sep->arg[2]);
  10034. if (value1 > 0xFFFF)
  10035. memcpy(ptr2, (uchar*)&value1, 4);
  10036. else if (value1 > 0xFF)
  10037. memcpy(ptr2, (uchar*)&value1, 2);
  10038. else
  10039. memcpy(ptr2, (uchar*)&value1, 1);
  10040. }
  10041. DumpPacket(app);
  10042. client->QueuePacket(app);
  10043. safe_delete(packet2);
  10044. }
  10045. }
  10046. }
  10047. else if (atoi(sep->arg[0]) == 22) { //same as 21, but 8bit string
  10048. PacketStruct* packet2 = configReader.getStruct("WS_OfferQuest", client->GetVersion());
  10049. if (packet2) {
  10050. packet2->setDataByName("unknown0", 255);
  10051. packet2->setDataByName("reward", "New Quest");
  10052. packet2->setDataByName("title", "Title");
  10053. packet2->setDataByName("description", "description");
  10054. packet2->setDataByName("quest_difficulty", 3);
  10055. packet2->setDataByName("unknown1", 5);
  10056. packet2->setDataByName("level", 3);
  10057. packet2->setDataByName("coin", 150);
  10058. packet2->setDataByName("status_points", 5);
  10059. packet2->setDataByName("exp_bonus", 10);
  10060. packet2->setArrayLengthByName("num_rewards", 1);
  10061. Item* item = new Item(master_item_list.GetItem(36212));
  10062. packet2->setArrayDataByName("reward_id", item->details.item_id);
  10063. item->stack_count = 20;
  10064. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, client->GetClientItemPacketOffset());
  10065. safe_delete(item);
  10066. char accept[35] = { 0 };
  10067. char decline[35] = { 0 };
  10068. sprintf(accept, "q_accept_pending_quest %u", 0);
  10069. sprintf(decline, "q_deny_pending_quest %u", 0);
  10070. packet2->setDataByName("accept_command", accept);
  10071. packet2->setDataByName("decline_command", decline);
  10072. EQ2Packet* app = packet2->serialize();
  10073. if (sep->IsSet(2)) {
  10074. int16 offset = atoi(sep->arg[1]);
  10075. uchar* ptr2 = app->pBuffer;
  10076. ptr2 += offset;
  10077. if (sep->IsNumber(2)) {
  10078. int32 value1 = atol(sep->arg[2]);
  10079. if (value1 > 0xFFFF)
  10080. memcpy(ptr2, (uchar*)&value1, 4);
  10081. else if (value1 > 0xFF)
  10082. memcpy(ptr2, (uchar*)&value1, 2);
  10083. else
  10084. memcpy(ptr2, (uchar*)&value1, 1);
  10085. }
  10086. else {
  10087. int8 len = strlen(sep->arg[2]);
  10088. memcpy(ptr2, (uchar*)&len, 1);
  10089. ptr2 += 1;
  10090. memcpy(ptr2, sep->arg[2], len);
  10091. }
  10092. }
  10093. DumpPacket(app);
  10094. client->QueuePacket(app);
  10095. safe_delete(packet2);
  10096. }
  10097. }
  10098. else if (atoi(sep->arg[0]) == 23) {
  10099. if (client->GetPlayer()->GetTarget()) {
  10100. PacketStruct* packet2 = configReader.getStruct("WS_UpdateMerchant", client->GetVersion());
  10101. if (packet2) {
  10102. Spawn* target = client->GetPlayer()->GetTarget();
  10103. packet2->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(target));
  10104. Item* item = new Item(master_item_list.GetItem(12565));
  10105. int8 i = 0;
  10106. packet2->setArrayLengthByName("num_items", 1);
  10107. packet2->setArrayDataByName("item_name", item->name.c_str(), i);
  10108. packet2->setArrayDataByName("item_id", item->details.item_id, i);
  10109. packet2->setArrayDataByName("stack_size", item->stack_count, i);
  10110. packet2->setArrayDataByName("icon", item->GetIcon(client->GetVersion()), i);
  10111. int8 tmp_level = 0;
  10112. if (item->generic_info.adventure_default_level > 0)
  10113. tmp_level = item->generic_info.adventure_default_level;
  10114. else
  10115. tmp_level = item->generic_info.tradeskill_default_level;
  10116. packet2->setArrayDataByName("level", tmp_level, i);
  10117. packet2->setArrayDataByName("tier", item->details.tier, i);
  10118. packet2->setArrayDataByName("item_id2", item->details.item_id, i);
  10119. int8 item_difficulty = client->GetPlayer()->GetArrowColor(tmp_level);
  10120. if (item_difficulty != ARROW_COLOR_WHITE && item_difficulty != ARROW_COLOR_RED && item_difficulty != ARROW_COLOR_GRAY)
  10121. item_difficulty = ARROW_COLOR_WHITE;
  10122. item_difficulty -= 6;
  10123. if (item_difficulty < 0)
  10124. item_difficulty *= -1;
  10125. packet2->setArrayDataByName("item_difficulty", item_difficulty, i);
  10126. packet2->setArrayDataByName("quantity", 2, i);
  10127. packet2->setArrayDataByName("unknown5", 255, i);
  10128. packet2->setArrayDataByName("stack_size2", item->stack_count, i);
  10129. packet2->setArrayDataByName("description", item->description.c_str(), i);
  10130. packet2->setDataByName("type", 2);
  10131. EQ2Packet* app = packet2->serialize();
  10132. if (sep->IsSet(2)) {
  10133. int16 offset = atoi(sep->arg[1]);
  10134. uchar* ptr2 = app->pBuffer;
  10135. ptr2 += offset;
  10136. if (sep->IsNumber(2)) {
  10137. int32 value1 = atol(sep->arg[2]);
  10138. if (value1 > 0xFFFF)
  10139. memcpy(ptr2, (uchar*)&value1, 4);
  10140. else if (value1 > 0xFF)
  10141. memcpy(ptr2, (uchar*)&value1, 2);
  10142. else
  10143. memcpy(ptr2, (uchar*)&value1, 1);
  10144. }
  10145. else {
  10146. int8 len = strlen(sep->arg[2]);
  10147. memcpy(ptr2, (uchar*)&len, 1);
  10148. ptr2 += 1;
  10149. memcpy(ptr2, sep->arg[2], len);
  10150. }
  10151. }
  10152. DumpPacket(app);
  10153. client->QueuePacket(app);
  10154. safe_delete(packet2);
  10155. }
  10156. }
  10157. }
  10158. else if (atoi(sep->arg[0]) == 24) {
  10159. PacketStruct* packet2 = configReader.getStruct("WS_EnableGameEvent", client->GetVersion());
  10160. if (packet2) {
  10161. if (sep->IsSet(2)) {
  10162. packet2->setDataByName("event_name", sep->arg[1]);
  10163. packet2->setDataByName("enabled", atoi(sep->arg[2]));
  10164. EQ2Packet* app = packet2->serialize();
  10165. DumpPacket(app);
  10166. client->QueuePacket(app);
  10167. safe_delete(packet2);
  10168. }
  10169. }
  10170. }
  10171. else if (atoi(sep->arg[0]) == 25) {
  10172. if (sep->IsSet(1)) {
  10173. Widget* new_spawn = new Widget();
  10174. int32 id = atoul(sep->arg[1]);
  10175. new_spawn->SetWidgetID(id);
  10176. EQ2Packet* ret = new_spawn->serialize(client->GetPlayer(), client->GetVersion());
  10177. client->QueuePacket(ret);
  10178. int8 index = client->GetPlayer()->GetIndexForSpawn(new_spawn);
  10179. PacketStruct* packet2 = configReader.getStruct("WS_DestroyGhostCmd", client->GetVersion());
  10180. if (packet2) {
  10181. packet2->setDataByName("spawn_index", index);
  10182. packet2->setDataByName("delete", 1);
  10183. EQ2Packet* app = packet2->serialize();
  10184. client->QueuePacket(app);
  10185. safe_delete(packet2);
  10186. }
  10187. }
  10188. }
  10189. else if (atoi(sep->arg[0]) == 26) {
  10190. if (sep->IsSet(4)) {
  10191. Widget* new_spawn = new Widget();
  10192. int32 id = atoul(sep->arg[1]);
  10193. new_spawn->SetWidgetID(id);
  10194. float x = atof(sep->arg[2]);
  10195. float y = atof(sep->arg[3]);
  10196. float z = atof(sep->arg[4]);
  10197. new_spawn->SetLocation(client->GetPlayer()->GetLocation());
  10198. new_spawn->SetWidgetX(x);
  10199. new_spawn->SetWidgetY(y);
  10200. new_spawn->SetWidgetZ(z);
  10201. new_spawn->SetX(x);
  10202. new_spawn->SetY(y);
  10203. new_spawn->SetZ(z);
  10204. EQ2Packet* ret = new_spawn->serialize(client->GetPlayer(), client->GetVersion());
  10205. client->QueuePacket(ret);
  10206. }
  10207. }
  10208. else if (atoi(sep->arg[0]) == 27) {
  10209. Spawn* target = client->GetPlayer()->GetTarget();
  10210. PacketStruct* packet2 = configReader.getStruct("WS_HearSimpleDamage", client->GetVersion());
  10211. if (packet2 && target && sep->IsSet(4)) {
  10212. client->GetPlayer()->GetZone()->SendDamagePacket(client->GetPlayer(), target, atoul(sep->arg[1]), atoul(sep->arg[2]), atoul(sep->arg[3]), atoul(sep->arg[4]), sep->arg[5] != nullptr ? sep->arg[5] : "");
  10213. }
  10214. }
  10215. else if (atoi(sep->arg[0]) == 28 && sep->IsNumber(1)) {
  10216. World::newValue = strtoull(sep->arg[1], NULL, 0);
  10217. }
  10218. else if (atoi(sep->arg[0]) == 29 && sep->IsNumber(1)) {
  10219. client->SendHearCast(client->GetPlayer(), client->GetPlayer()->GetTarget() ? client->GetPlayer()->GetTarget() : client->GetPlayer(),
  10220. strtoull(sep->arg[1], NULL, 0), atoul(sep->arg[2]));
  10221. }
  10222. else if (atoi(sep->arg[0]) == 30) {
  10223. PacketStruct* packet = configReader.getStruct("WS_UpdateSkillBook", client->GetVersion());
  10224. if (packet) {
  10225. packet->setDataByName("unknown", World::newValue);
  10226. EQ2Packet* outapp = packet->serialize();
  10227. DumpPacket(outapp);
  10228. client->QueuePacket(outapp);
  10229. safe_delete(packet);
  10230. }
  10231. }
  10232. else if (atoi(sep->arg[0]) == 31) {
  10233. client->SendRecipeList();
  10234. }
  10235. else if (atoi(sep->arg[0]) == 32 && sep->IsNumber(1) && sep->IsNumber(2)) {
  10236. if(client->GetVersion() <= 561) {
  10237. int32 param = atoul(sep->arg[1]);
  10238. int32 paramvalue = atoul(sep->arg[2]);
  10239. client->Message(CHANNEL_COLOR_YELLOW, "Send control flag param %u param value %u", param, paramvalue);
  10240. ClientPacketFunctions::SendServerControlFlagsClassic(client, param, paramvalue);
  10241. }
  10242. else if(sep->IsNumber(3)) {
  10243. int8 param1 = atoul(sep->arg[1]);
  10244. int8 param2 = atoul(sep->arg[2]);
  10245. int8 paramval = atoul(sep->arg[3]);
  10246. client->Message(CHANNEL_COLOR_YELLOW, "Send control flag param1 %u param2 %u param value %u", param1, param2, paramval);
  10247. ClientPacketFunctions::SendServerControlFlags(client, param1, param2, paramval);
  10248. }
  10249. }
  10250. else if (atoi(sep->arg[0]) == 33 && sep->IsNumber(1) && sep->IsNumber(2)) {
  10251. client->GetCurrentZone()->SendHealPacket(client->GetPlayer(), client->GetPlayer()->GetTarget() ? client->GetPlayer()->GetTarget() : client->GetPlayer(),
  10252. atoul(sep->arg[1]), atoul(sep->arg[2]), "TestSpell");
  10253. }
  10254. else if(atoi(sep->arg[0]) == 34 && sep->IsNumber(1) && sep->IsNumber(2)) {
  10255. PacketStruct* packet = configReader.getStruct("WS_QuestRewardPackMsg", client->GetVersion());
  10256. packet->setSubstructDataByName("reward_data", "unknown1", atoi(sep->arg[1]));
  10257. Item* item = master_item_list.GetItem(atoul(sep->arg[2]));
  10258. if(item) {
  10259. packet->setSubstructArrayLengthByName("reward_data", "num_select_rewards", 1);
  10260. packet->setArrayDataByName("select_reward_id", item->details.item_id, 0);
  10261. packet->setItemArrayDataByName("select_item", item, client->GetPlayer(), 0, 0, World::newValue - 2);
  10262. }
  10263. client->QueuePacket(packet->serialize());
  10264. safe_delete(packet);
  10265. }
  10266. else if(atoi(sep->arg[0]) == 35) {
  10267. if(client->GetPlayer()->GetGroupMemberInfo() && client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  10268. Entity* target = (Entity*)client->GetPlayer()->GetTarget();
  10269. if(target->GetGroupMemberInfo()) {
  10270. PlayerGroup* group = world.GetGroupManager()->GetGroup(client->GetPlayer()->GetGroupMemberInfo()->group_id);
  10271. PlayerGroup* group2 = world.GetGroupManager()->GetGroup(target->GetGroupMemberInfo()->group_id);
  10272. if(group && group2) {
  10273. group->AddGroupToRaid(group2->GetID());
  10274. group2->AddGroupToRaid(group->GetID());
  10275. }
  10276. }
  10277. }
  10278. }
  10279. else if(atoi(sep->arg[0]) == 36) {
  10280. EQ2Packet* packet = client->GetPlayer()->GetRaidUpdatePacket(client->GetVersion());
  10281. if(packet) {
  10282. client->QueuePacket(packet);
  10283. }
  10284. }
  10285. else if(atoi(sep->arg[0]) == 37) {
  10286. Guild* guild = client->GetPlayer()->GetGuild();
  10287. if(guild)
  10288. guild->SendGuildMemberList();
  10289. }
  10290. }
  10291. else {
  10292. PacketStruct* packet2 = configReader.getStruct("WS_ExaminePartialSpellInfo", client->GetVersion());
  10293. if (packet2) {
  10294. packet2->setSubstructDataByName("info_header", "show_name", 1);
  10295. packet2->setSubstructDataByName("info_header", "unknown", 7);
  10296. packet2->setSubstructDataByName("info_header", "unknown2", 1);
  10297. packet2->setSubstructDataByName("info_header", "unknown3", 1);
  10298. packet2->setSubstructDataByName("info_header", "unknown4", 1);
  10299. packet2->setSubstructDataByName("info_header", "unknown5", 1);
  10300. packet2->setSubstructDataByName("info_header", "unknown6", "Testing");
  10301. packet2->setSubstructDataByName("info_header", "unknown7", "Testing");
  10302. packet2->setSubstructDataByName("info_header", "unknown8", 66);
  10303. packet2->setSubstructDataByName("info_header", "title", "Blah Title Blah");
  10304. packet2->setSubstructDataByName("info_header", "title_text", "Blah Blah");
  10305. packet2->setSubstructDataByName("info_header", "title_text2", "Blah Blah2");
  10306. packet2->setSubstructDataByName("info_header", "show_popup", 1);
  10307. packet2->setSubstructDataByName("info_header", "packettype", 3);
  10308. packet2->setSubstructDataByName("spell_info", "skill_name", "Testing");
  10309. packet2->setSubstructDataByName("spell_info", "level", 19);
  10310. packet2->setSubstructDataByName("spell_info", "tier", 1);
  10311. packet2->setSubstructDataByName("spell_info", "health_cost", 5);
  10312. packet2->setSubstructDataByName("spell_info", "min_class_skill_req", 3);
  10313. packet2->setSubstructDataByName("spell_info", "mana_cost", 6);
  10314. packet2->setSubstructDataByName("spell_info", "req_concentration", 7);
  10315. packet2->setSubstructDataByName("spell_info", "cast_time", 200);
  10316. packet2->setSubstructDataByName("spell_info", "recovery", 220);
  10317. packet2->setSubstructDataByName("spell_info", "recast", 280);
  10318. packet2->setSubstructDataByName("spell_info", "beneficial", 1);
  10319. packet2->setSubstructDataByName("spell_info", "maintained", 1);
  10320. packet2->setSubstructDataByName("spell_info", "spell_book_type", 1);
  10321. packet2->setSubstructDataByName("spell_info", "quality", 3);
  10322. packet2->setSubstructDataByName("spell_info", "test_1a", 1);
  10323. packet2->setSubstructDataByName("spell_info", "test_1b", 1);
  10324. packet2->setSubstructDataByName("spell_info", "test_1c", 1);
  10325. packet2->setSubstructDataByName("spell_info", "test_1d", 1);
  10326. packet2->setSubstructDataByName("spell_info", "test_2a", 2);
  10327. packet2->setSubstructDataByName("spell_info", "test_2b", 2);
  10328. packet2->setSubstructDataByName("spell_info", "test_2c", 2);
  10329. packet2->setSubstructDataByName("spell_info", "test_2d", 2);
  10330. packet2->setSubstructDataByName("spell_info", "test_3", 3);
  10331. packet2->setSubstructDataByName("spell_info", "test_4", 4);
  10332. packet2->setSubstructDataByName("spell_info", "test_5", 5);
  10333. packet2->setSubstructDataByName("spell_info", "test_6", 6);
  10334. packet2->setSubstructDataByName("spell_info", "min_class_skill_req", 1);
  10335. packet2->setSubstructDataByName("spell_info", "min_class_skill_rec", 30123);
  10336. packet2->setSubstructDataByName("spell_info", "num_reagents", 1);
  10337. packet2->setSubstructArrayLengthByName("spell_info", "num_reagents", 1);
  10338. packet2->setArrayDataByName("reagent", "Alcohol");
  10339. packet2->setArrayDataByName("consumed", "123");
  10340. packet2->setSubstructDataByName("spell_info", "class_skill", 52);
  10341. packet2->setSubstructDataByName("spell_info", "id", 8308);
  10342. packet2->setSubstructDataByName("spell_info", "icon", 303);
  10343. packet2->setSubstructDataByName("spell_info", "icon2", 0xFFFF);
  10344. packet2->setSubstructDataByName("spell_info", "icontype", 317);
  10345. packet2->setSubstructDataByName("spell_info", "type", 2);
  10346. packet2->setSubstructDataByName("spell_info", "spell_text_color", 255);
  10347. packet2->setSubstructDataByName("spell_info", "duration1", 600);
  10348. packet2->setSubstructDataByName("spell_info", "duration2", 600);
  10349. packet2->setSubstructDataByName("spell_info", "name", "Sprint");
  10350. packet2->setSubstructDataByName("spell_info", "description", "Test description");
  10351. EQ2Packet* outapp = packet2->serialize();
  10352. DumpPacket(outapp);
  10353. client->QueuePacket(outapp);
  10354. safe_delete(packet2);
  10355. }
  10356. }
  10357. return;
  10358. PacketStruct* p = configReader.getStruct("WS_EqTargetItemCmd", client->GetVersion());
  10359. if (!p) return;
  10360. //Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  10361. //client->GetCurrentZone()->SendSpellFailedPacket(client, atoi(sep2->arg[0]));
  10362. //}
  10363. /*Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  10364. if (sep2 && sep2->arg[0] && sep2->IsNumber(0)) {
  10365. client->SetPendingFlightPath(atoi(sep2->arg[0]));
  10366. PacketStruct* packet = configReader.getStruct("WS_ReadyForTakeOff", client->GetVersion());
  10367. if (packet) {
  10368. client->QueuePacket(packet->serialize());
  10369. safe_delete(packet);
  10370. }
  10371. }*/
  10372. /*if (client->GetCurrentZone()->Grid != nullptr) {
  10373. int32 numFaces = 0;
  10374. int32 numGrids = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.size();
  10375. client->Message(CHANNEL_COLOR_YELLOW, "Num grids in cell: %u", numGrids);
  10376. map<int32, vector<Face*> >::iterator itr;
  10377. for (itr = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.begin(); itr != client->GetPlayer()->Cell_Info.CurrentCell->FaceList.end(); itr++)
  10378. numFaces += (*itr).second.size();
  10379. client->Message(CHANNEL_COLOR_YELLOW, "Num faces in cell: %u", numFaces);
  10380. }*/
  10381. //uchar blah[] = {
  10382. // 1208 - OP_EQUpdateStoreCmd
  10383. // /*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
  10384. // /*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
  10385. // 1193 - -- OP_ClientCmdMsg::OP_EqUpdateMerchantCmd --
  10386. // /*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
  10387. /*};
  10388. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  10389. int8 val = 0;
  10390. int16 pos = 0;
  10391. int idx = 0;
  10392. while(sep2 && sep2->arg[idx+1] && sep2->IsNumber(idx) && sep2->IsNumber(idx+1)){
  10393. pos = atoi(sep2->arg[idx]);
  10394. val = atoi(sep2->arg[idx+1]);
  10395. memset(blah+pos, val, 1);
  10396. idx+=2;
  10397. }
  10398. DumpPacket(blah, sizeof(blah));
  10399. client->QueuePacket(new EQ2Packet(OP_GroupCreatedMsg , blah, sizeof(blah)));*/
  10400. if (client->GetPlayer()->GetTarget()) {
  10401. PacketStruct* packet = configReader.getStruct("WS_SetControlGhost", client->GetVersion());
  10402. if (packet) {
  10403. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  10404. packet->setDataByName("size", 0);
  10405. packet->setDataByName("unknown2", 0);
  10406. EQ2Packet* app = packet->serialize();
  10407. client->QueuePacket(app);
  10408. safe_delete(packet);
  10409. }
  10410. PacketStruct* set_pov = configReader.getStruct("WS_SetPOVGhostCmd", client->GetVersion());
  10411. if (set_pov) {
  10412. set_pov->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  10413. EQ2Packet* app_pov = set_pov->serialize();
  10414. client->QueuePacket(app_pov);
  10415. safe_delete(set_pov);
  10416. }
  10417. }
  10418. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  10419. PacketStruct* packet = configReader.getStruct("WS_OpenCharCust", client->GetVersion());
  10420. if (packet) {
  10421. if (sep2 && sep2->arg[0] && sep2->IsNumber(0))
  10422. packet->setDataByName("Type", atoi(sep2->arg[0]));
  10423. else
  10424. packet->setDataByName("Type", 2);
  10425. if (sep2 && sep2->arg[1] && sep2->IsNumber(1))
  10426. packet->setDataByName("race_id", atoi(sep2->arg[1]));
  10427. else
  10428. packet->setDataByName("race_id", 0);
  10429. if (sep2 && sep2->arg[2] && sep2->IsNumber(2))
  10430. packet->setDataByName("gender", atoi(sep2->arg[2]));
  10431. else
  10432. packet->setDataByName("gender", 2);
  10433. if (sep2 && sep2->arg[3] && sep2->IsNumber(3))
  10434. packet->setDataByName("unknown", atoi(sep2->arg[3]), 0);
  10435. else
  10436. packet->setDataByName("unknown", 0, 0);
  10437. if (sep2 && sep2->arg[4] && sep2->IsNumber(4))
  10438. packet->setDataByName("unknown", atoi(sep2->arg[4]), 1);
  10439. else
  10440. packet->setDataByName("unknown", 0, 1);
  10441. if (sep2 && sep2->arg[5] && sep2->IsNumber(5))
  10442. packet->setDataByName("unknown", atoi(sep2->arg[5]), 2);
  10443. else
  10444. packet->setDataByName("unknown", 0, 2);
  10445. client->QueuePacket(packet->serialize());
  10446. }
  10447. safe_delete(packet);
  10448. safe_delete(sep2);
  10449. }
  10450. void Commands::Command_LeaveChannel(Client *client, Seperator *sep) {
  10451. const char *channel_name;
  10452. if (sep == NULL || !sep->IsSet(0)) {
  10453. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /leavechat <channel name>");
  10454. PrintSep(sep);
  10455. return;
  10456. }
  10457. channel_name = sep->arg[0];
  10458. if (!chat.IsInChannel(client, channel_name))
  10459. client->Message(CHANNEL_NARRATIVE, "Unable to leave '%s': You are not in the channel.", channel_name);
  10460. else if (!chat.LeaveChannel(client, channel_name))
  10461. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an internal error preventing you from leaving that channel MUAHAHA");
  10462. }
  10463. /*
  10464. Function:
  10465. Purpose :
  10466. Params :
  10467. Dev :
  10468. Example :
  10469. */
  10470. void Commands::Command_WeaponStats(Client* client)
  10471. {
  10472. Player* player = client->GetPlayer();
  10473. Spawn* target = player->GetTarget();
  10474. Item* primary = player->GetEquipmentList()->GetItem(EQ2_PRIMARY_SLOT);
  10475. Item* secondary = player->GetEquipmentList()->GetItem(EQ2_SECONDARY_SLOT);
  10476. Item* ranged = player->GetEquipmentList()->GetItem(EQ2_RANGE_SLOT);
  10477. const char* charName = player->GetName();
  10478. if(target && target->IsEntity()) {
  10479. primary = ((Entity*)target)->GetEquipmentList()->GetItem(EQ2_PRIMARY_SLOT);
  10480. secondary = ((Entity*)target)->GetEquipmentList()->GetItem(EQ2_SECONDARY_SLOT);
  10481. ranged = ((Entity*)target)->GetEquipmentList()->GetItem(EQ2_RANGE_SLOT);
  10482. charName = target->GetName();
  10483. }
  10484. else {
  10485. target = nullptr;
  10486. }
  10487. client->Message(0, "WeaponStats for %s", charName);
  10488. client->SimpleMessage(0, "Primary:");
  10489. if (primary) {
  10490. client->Message(0, "Name: %s", primary->name.c_str());
  10491. client->Message(0, "Base Damage: %u - %u", primary->weapon_info->damage_low3, primary->weapon_info->damage_high3);
  10492. client->Message(0, "Mastery Damage: %u - %u", primary->weapon_info->damage_low2, primary->weapon_info->damage_high2);
  10493. client->Message(0, "Damage: %u - %u", primary->weapon_info->damage_low1, primary->weapon_info->damage_high1);
  10494. client->Message(0, "Actual Damage: %u - %u", target ? ((Entity*)target)->GetPrimaryWeaponMinDamage() : player->GetPrimaryWeaponMinDamage(),
  10495. target ? ((Entity*)target)->GetPrimaryWeaponMaxDamage() : player->GetPrimaryWeaponMaxDamage());
  10496. client->Message(0, "Actual Delay: %u", target ? ((Entity*)target)->GetPrimaryWeaponDelay() : player->GetPrimaryWeaponDelay());
  10497. client->Message(0, "Proc Percent: %d%%", 0);
  10498. client->Message(0, "Procs Per Minute: %d", 0);
  10499. }
  10500. else {
  10501. client->SimpleMessage(0, "Name: fist");
  10502. client->Message(0, "Base Damage: %u - %u", target ? ((Entity*)target)->GetPrimaryWeaponMinDamage() : player->GetPrimaryWeaponMinDamage(),
  10503. target ? ((Entity*)target)->GetPrimaryWeaponMaxDamage() : player->GetPrimaryWeaponMaxDamage());
  10504. client->Message(0, "Actual Damage: %u - %u", target ? ((Entity*)target)->GetPrimaryWeaponMinDamage() : player->GetPrimaryWeaponMinDamage(),
  10505. target ? ((Entity*)target)->GetPrimaryWeaponMaxDamage() : player->GetPrimaryWeaponMaxDamage());
  10506. client->Message(0, "Actual Delay: %d", target ? ((Entity*)target)->GetPrimaryWeaponDelay() : player->GetPrimaryWeaponDelay() * 0.1);
  10507. client->Message(0, "Proc Percent: %d%%", 0);
  10508. client->Message(0, "Procs Per Minute: %d", 0);
  10509. }
  10510. client->SimpleMessage(0, " ");
  10511. client->SimpleMessage(0, " ");
  10512. if (secondary) {
  10513. client->SimpleMessage(0, "Secondary:");
  10514. client->Message(0, "Name: %s", secondary->name.c_str());
  10515. client->Message(0, "Base Damage: %u - %u", secondary->weapon_info->damage_low3, secondary->weapon_info->damage_high3);
  10516. client->Message(0, "Mastery Damage: %u - %u", secondary->weapon_info->damage_low2, secondary->weapon_info->damage_high2);
  10517. client->Message(0, "Damage: %u - %u", secondary->weapon_info->damage_low1, secondary->weapon_info->damage_high1);
  10518. client->Message(0, "Actual Damage: %u - %u", target ? ((Entity*)target)->GetSecondaryWeaponMinDamage() : player->GetSecondaryWeaponMinDamage(),
  10519. target ? ((Entity*)target)->GetSecondaryWeaponMaxDamage() : player->GetSecondaryWeaponMaxDamage());
  10520. client->Message(0, "Actual Delay: %d", target ? ((Entity*)target)->GetSecondaryWeaponDelay() : player->GetSecondaryWeaponDelay() * 0.1);
  10521. client->Message(0, "Proc Percent: %d%%", 0);
  10522. client->Message(0, "Procs Per Minute: %d", 0);
  10523. client->SimpleMessage(0, " ");
  10524. client->SimpleMessage(0, " ");
  10525. }
  10526. client->SimpleMessage(0, "Ranged:");
  10527. if (ranged) {
  10528. client->Message(0, "Name: %s", ranged->name.c_str());
  10529. client->Message(0, "Base Damage: %u - %u", ranged->ranged_info->weapon_info.damage_low3, ranged->ranged_info->weapon_info.damage_high3);
  10530. client->Message(0, "Mastery Damage: %u - %u", ranged->ranged_info->weapon_info.damage_low2, ranged->ranged_info->weapon_info.damage_high2);
  10531. client->Message(0, "Damage: %u - %u", ranged->ranged_info->weapon_info.damage_low1, ranged->ranged_info->weapon_info.damage_high1);
  10532. client->Message(0, "Actual Damage: %u - %u", target ? ((Entity*)target)->GetRangedWeaponMinDamage() : player->GetRangedWeaponMinDamage(),
  10533. target ? ((Entity*)target)->GetRangedWeaponMaxDamage() : player->GetRangedWeaponMaxDamage());
  10534. client->Message(0, "Actual Delay: %d", target ? ((Entity*)target)->GetRangeWeaponDelay() : player->GetRangeWeaponDelay() * 0.1);
  10535. client->Message(0, "Proc Percent: %d%%", 0);
  10536. client->Message(0, "Procs Per Minute: %d", 0);
  10537. }
  10538. else
  10539. client->SimpleMessage(0, "None");
  10540. }
  10541. void Commands::Command_WhoChannel(Client *client, Seperator *sep) {
  10542. const char *channel_name;
  10543. if (sep == NULL || !sep->IsSet(0)) {
  10544. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /chatwho <channel name>");
  10545. return;
  10546. }
  10547. channel_name = sep->arg[0];
  10548. if (!chat.ChannelExists(channel_name))
  10549. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That channel does not exist!");
  10550. else
  10551. chat.SendChannelUserList(client, channel_name);
  10552. }
  10553. void Commands::Command_ZoneSafeCoords(Client *client, Seperator *sep)
  10554. {
  10555. ZoneServer* zone = 0;
  10556. int32 zone_id = client->GetPlayer()->GetZone()->GetZoneID();
  10557. if (zone_id > 0)
  10558. {
  10559. ZoneChangeDetails zone_details;
  10560. if(zone_list.GetZone(&zone_details, zone_id, "", false, false, false)) {
  10561. zone = (ZoneServer*)zone_details.zonePtr;
  10562. }
  10563. if (zone)
  10564. {
  10565. zone->SetSafeX(client->GetPlayer()->GetX());
  10566. zone->SetSafeY(client->GetPlayer()->GetY());
  10567. zone->SetSafeZ(client->GetPlayer()->GetZ());
  10568. zone->SetSafeHeading(client->GetPlayer()->GetHeading());
  10569. if( database.SaveZoneSafeCoords(zone_id, zone->GetSafeX(), zone->GetSafeY(), zone->GetSafeZ(), zone->GetSafeHeading()) )
  10570. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Zone safe coordinates updated!");
  10571. else
  10572. client->SimpleMessage(CHANNEL_COLOR_RED, "FAILED to update zone safe coordinates!");
  10573. }
  10574. }
  10575. }
  10576. /*
  10577. Function:
  10578. Purpose :
  10579. Params :
  10580. Dev :
  10581. Example :
  10582. */
  10583. void Commands::Command_ZoneDetails(Client* client, Seperator* sep)
  10584. {
  10585. ZoneInfo* zone_info = new ZoneInfo;
  10586. if (sep && sep->arg[0])
  10587. {
  10588. if (sep->IsNumber(0))
  10589. zone_info->id = atoi(sep->arg[0]);
  10590. else
  10591. zone_info->id = database.GetZoneID(sep->arg[0]);
  10592. if (zone_info->id > 0)
  10593. {
  10594. database.LoadZoneInfo(zone_info);
  10595. 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);
  10596. 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);
  10597. 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);
  10598. 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);
  10599. 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);
  10600. 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);
  10601. 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);
  10602. client->Message(CHANNEL_COLOR_YELLOW, "zone_type: %s, sky_file: %s", zone_info->zone_type, zone_info->sky_file);
  10603. client->Message(CHANNEL_COLOR_YELLOW, "lua_script: %s", zone_info->lua_script);
  10604. client->Message(CHANNEL_COLOR_YELLOW, "zone_motd: %s", zone_info->zone_motd);
  10605. }
  10606. else
  10607. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  10608. }
  10609. else
  10610. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone details [zone id|zone name]");
  10611. safe_delete(zone_info);
  10612. }
  10613. /*
  10614. Function:
  10615. Purpose :
  10616. Params :
  10617. Dev :
  10618. Example :
  10619. */
  10620. void Commands::Command_ZoneSet(Client* client, Seperator* sep)
  10621. {
  10622. if (sep && sep->arg[0] && sep->arg[1] && sep->arg[2])
  10623. {
  10624. ZoneServer* zone = 0;
  10625. int32 zone_id = 0;
  10626. ZoneChangeDetails zone_details;
  10627. if (sep->IsNumber(0) && atoi(sep->arg[0]) > 0)
  10628. {
  10629. zone_id = atoul(sep->arg[0]);
  10630. if(zone_list.GetZone(&zone_details, zone_id, "", false, false, false, false)) {
  10631. zone = (ZoneServer*)zone_details.zonePtr;
  10632. }
  10633. }
  10634. else
  10635. {
  10636. zone_id = database.GetZoneID(sep->arg[0]);
  10637. if(zone_list.GetZone(&zone_details, zone_id, "", false, false, false, false)) {
  10638. zone = (ZoneServer*)zone_details.zonePtr;
  10639. }
  10640. }
  10641. if (zone_id > 0)
  10642. {
  10643. if (zone_set_values.count(string(sep->arg[1])) > 0)
  10644. SetZoneCommand(client, zone_id, zone, zone_set_values[sep->arg[1]], sep->arg[2]);
  10645. else
  10646. client->Message(CHANNEL_COLOR_YELLOW, "The attribute '%s' is not valid.", sep->arg[1]);
  10647. }
  10648. else
  10649. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  10650. }
  10651. else
  10652. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone set [zone id|zone name] [attribute] [value]");
  10653. }
  10654. void Commands::Command_Rain(Client* client, Seperator* sep) {
  10655. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  10656. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /rain <float>");
  10657. return;
  10658. }
  10659. client->Message(CHANNEL_COLOR_YELLOW,"Setting rain to %.2f", atof(sep->arg[0]));
  10660. client->GetCurrentZone()->SetRain(atof(sep->arg[0]));
  10661. client->GetCurrentZone()->SetCurrentWeather(atof(sep->arg[0]));
  10662. }
  10663. void Commands::Command_Wind(Client* client, Seperator* sep) {
  10664. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  10665. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /wind <float>");
  10666. return;
  10667. }
  10668. client->Message(CHANNEL_COLOR_YELLOW, "Setting wind to %.2f", atof(sep->arg[0]));
  10669. client->GetCurrentZone()->SetWind(atof(sep->arg[0]));
  10670. }
  10671. void Commands::Command_SendMerchantWindow(Client* client, Seperator* sep, bool sell) {
  10672. Spawn* spawn = client->GetPlayer()->GetTarget();
  10673. if(client->GetVersion() < 561) {
  10674. sell = false; // doesn't support in the same way as AoM just open the normal buy/sell window
  10675. }
  10676. if(spawn) {
  10677. client->SetMerchantTransaction(spawn);
  10678. if (spawn->GetMerchantID() > 0 && spawn->IsClientInMerchantLevelRange(client)){
  10679. client->SendHailCommand(spawn);
  10680. //MerchantFactionMultiplier* multiplier = world.GetMerchantMultiplier(spawn->GetMerchantID());
  10681. //if(!multiplier || (multiplier && client->GetPlayer()->GetFactions()->GetFactionValue(multiplier->faction_id) >= multiplier->faction_min)){
  10682. client->SendBuyMerchantList(sell);
  10683. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY))
  10684. client->SendSellMerchantList(sell);
  10685. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY_BACK))
  10686. client->SendBuyBackList(sell);
  10687. if(client->GetVersion() > 561) {
  10688. PacketStruct* packet = configReader.getStruct("WS_UpdateMerchant", client->GetVersion());
  10689. if (packet) {
  10690. packet->setDataByName("spawn_id", 0xFFFFFFFF);
  10691. packet->setDataByName("type", 16);
  10692. EQ2Packet* outapp = packet->serialize();
  10693. if (outapp)
  10694. client->QueuePacket(outapp);
  10695. safe_delete(packet);
  10696. }
  10697. }
  10698. }
  10699. if (spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR)
  10700. client->SendRepairList();
  10701. }
  10702. // client->SimpleMessage(CHANNEL_COLOR_RED, "Your faction is too low to use this merchant.");
  10703. }
  10704. void Commands::Command_Weather(Client* client, Seperator* sep)
  10705. {
  10706. //PrintSep(sep, "Weather");
  10707. if( sep && sep->arg[0] )
  10708. {
  10709. ZoneServer* zsZone = client->GetCurrentZone();
  10710. const char* value = sep->arg[0];
  10711. // process single-param commands first
  10712. if( strncasecmp(value, "details", strlen(value)) == 0 )
  10713. {
  10714. client->Message(CHANNEL_COLOR_YELLOW, "Weather Details for zone %s: ", zsZone->GetZoneName());
  10715. client->Message(CHANNEL_COLOR_YELLOW, "enabled: %i, allowed: %i, type: %i, frequency: %u", zsZone->isWeatherEnabled(), zsZone->isWeatherAllowed(), zsZone->GetWeatherType(), zsZone->GetWeatherFrequency());
  10716. client->Message(CHANNEL_COLOR_YELLOW, "severity: %.2f = %.2f, current: %.2f", zsZone->GetWeatherMinSeverity(), zsZone->GetWeatherMaxSeverity(), zsZone->GetCurrentWeather());
  10717. client->Message(CHANNEL_COLOR_YELLOW, "pattern: %i, chance: %i, amount: %.2f, offset: %.2f", zsZone->GetWeatherPattern(), zsZone->GetWeatherChance(), zsZone->GetWeatherChangeAmount(), zsZone->GetWeatherDynamicOffset());
  10718. }
  10719. else if( strncasecmp(value, "process", strlen(value)) == 0 )
  10720. {
  10721. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  10722. zsZone->ProcessWeather();
  10723. }
  10724. else if( strncasecmp(value, "reset", strlen(value)) == 0 )
  10725. {
  10726. zsZone->SetWeatherType(rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Zone, WeatherType)->GetInt8());
  10727. zsZone->SetWeatherFrequency(rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Zone, WeatherChangeFrequency)->GetInt32());
  10728. zsZone->SetWeatherMinSeverity(rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Zone, MinWeatherSeverity)->GetFloat());
  10729. zsZone->SetWeatherMaxSeverity(rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Zone, MaxWeatherSeverity)->GetFloat());
  10730. zsZone->SetCurrentWeather(zsZone->GetWeatherMinSeverity());
  10731. zsZone->SetWeatherPattern(1);
  10732. zsZone->SetWeatherChance(rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Zone, WeatherChangeChance)->GetInt8());
  10733. zsZone->SetWeatherChangeAmount(rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Zone, WeatherChangePerInterval)->GetFloat());
  10734. zsZone->SetWeatherDynamicOffset(rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Zone, WeatherDynamicMaxOffset)->GetFloat());
  10735. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  10736. zsZone->ProcessWeather();
  10737. }
  10738. // process commands with params
  10739. if( sep->arg[1] )
  10740. {
  10741. if( strncasecmp(value, "enable", strlen(value)) == 0 && sep->IsNumber(1) )
  10742. zsZone->SetWeatherEnabled( ( atoi(sep->arg[1]) == 1 ) ? true : false );
  10743. else if( strncasecmp(value, "type", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 3) )
  10744. zsZone->SetWeatherType(atoi(sep->arg[1]));
  10745. else if( strncasecmp(value, "frequency", strlen(value)) == 0 && sep->IsNumber(1))
  10746. zsZone->SetWeatherFrequency( atoul(sep->arg[1]) );
  10747. else if( strncasecmp(value, "range", strlen(value)) == 0 && sep->IsNumber(1) && sep->IsNumber(2) ) {
  10748. zsZone->SetWeatherMinSeverity(atof(sep->arg[1]));
  10749. zsZone->SetWeatherMaxSeverity(atof(sep->arg[2]));
  10750. zsZone->SetRain(zsZone->GetWeatherMinSeverity());
  10751. }
  10752. else if( strncasecmp(value, "current", strlen(value)) == 0 && sep->IsNumber(1) ) {
  10753. zsZone->SetCurrentWeather(atof(sep->arg[1]));
  10754. zsZone->SetRain(zsZone->GetCurrentWeather());
  10755. }
  10756. else if( strncasecmp(value, "pattern", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 2) )
  10757. zsZone->SetWeatherPattern( atoi(sep->arg[1]) );
  10758. else if( strncasecmp(value, "chance", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 100) )
  10759. zsZone->SetWeatherChance( atoi(sep->arg[1]) );
  10760. else if( strncasecmp(value, "amount", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  10761. zsZone->SetWeatherChangeAmount( atof(sep->arg[1]) );
  10762. else if( strncasecmp(value, "offset", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  10763. zsZone->SetWeatherDynamicOffset( atof(sep->arg[1]) );
  10764. }
  10765. }
  10766. else
  10767. {
  10768. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /weather [command] [param]");
  10769. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: enable (0|1), type (0-3), frequency (sec), range|current (0.0 - 1.0)");
  10770. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: details, process, pattern (0|1), chance (%), amount (float), offset (float)");
  10771. return;
  10772. }
  10773. }
  10774. void Commands::Command_Select(Client* client, Seperator* sep) {
  10775. if (sep && sep->arg[1]) {
  10776. Spawn* spawn = client->GetPlayer()->GetTarget();
  10777. if (spawn && strlen(sep->arg[1]) > 0)
  10778. client->GetCurrentZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_CUSTOM, client->GetPlayer(), sep->arg[1]);
  10779. }
  10780. }
  10781. /*
  10782. Function: Command_ConsumeFood()
  10783. Purpose : Consume Food/Drink and apply mods
  10784. Params : Slot ID - EQ2_FOOD_SLOT 22, EQ2_DRINK_SLOT 23
  10785. Dev : Zcoretri
  10786. Example : /consume_food 22
  10787. */
  10788. void Commands::Command_ConsumeFood(Client* client, Seperator* sep) {
  10789. if (sep && sep->arg[0] && sep->IsNumber(0))
  10790. {
  10791. Player* player = client->GetPlayer();
  10792. int32 slot = atoul(sep->arg[0]);
  10793. if (client->GetVersion() <= 373) {
  10794. if(client->GetVersion() <= 561) {
  10795. if(slot <= 255) {
  10796. slot = 255 - slot;
  10797. }
  10798. else {
  10799. if(slot == 256) { // first "new" item to inventory is assigned index 256 by client
  10800. slot = client->GetPlayer()->item_list.GetFirstNewItem();
  10801. }
  10802. else {
  10803. // otherwise the slot has to be mapped out depending on the amount of new items + index sent in
  10804. slot = client->GetPlayer()->item_list.GetNewItemByIndex((int16)slot - 255);
  10805. }
  10806. }
  10807. }
  10808. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(slot);
  10809. if(item && item->IsFood()) {
  10810. if(client->CheckConsumptionAllowed(slot)) {
  10811. if(item->IsFoodFood())
  10812. slot = EQ2_FOOD_SLOT;
  10813. else if(item->IsFoodDrink())
  10814. slot = EQ2_DRINK_SLOT;
  10815. else
  10816. return; // not valid item
  10817. client->ConsumeFoodDrink(item, slot);
  10818. }
  10819. }
  10820. }
  10821. else {
  10822. if (client->GetVersion() > 373 && client->GetVersion() <= 561) {
  10823. slot += 2;
  10824. }
  10825. Item* item = player->GetEquipmentList()->GetItem(slot);
  10826. if(client->CheckConsumptionAllowed(slot)) {
  10827. client->ConsumeFoodDrink(item, slot);
  10828. }
  10829. }
  10830. }
  10831. }
  10832. void Commands::Command_Aquaman(Client* client, Seperator* sep) {
  10833. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  10834. if (atoi(sep->arg[0]) == 1) {
  10835. client->GetPlayer()->GetInfoStruct()->set_vision(4);
  10836. client->GetPlayer()->GetInfoStruct()->set_breathe_underwater(1);
  10837. client->GetPlayer()->SetCharSheetChanged(true);
  10838. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Maybe you ought to stick to the shallow end until you know how to swim.");
  10839. }
  10840. else {
  10841. client->GetPlayer()->GetInfoStruct()->set_vision(0);
  10842. client->GetPlayer()->GetInfoStruct()->set_breathe_underwater(0);
  10843. client->GetPlayer()->SetCharSheetChanged(true);
  10844. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Aquaman mode turned off.");
  10845. }
  10846. }
  10847. else
  10848. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /aquaman [0|1]");
  10849. }
  10850. void Commands::Command_ReportBug(Client* client, Seperator* sep)
  10851. {
  10852. if(sep)
  10853. {
  10854. string data;
  10855. if(sep->arg[0]){
  10856. data = string(sep->arg[0]);
  10857. }
  10858. for(int i=1;i<sep->GetMaxArgNum();i++){
  10859. if(sep->arg[i])
  10860. data.append(" ").append(sep->arg[i]);
  10861. }
  10862. if(!sep->IsSet(7)){
  10863. data.append(" ").append(std::to_string(client->GetVersion())).append("\a");
  10864. }
  10865. const char* target_name = 0;
  10866. int32 spawn_id = 0;
  10867. if(client->GetPlayer()->GetTarget())
  10868. {
  10869. target_name = client->GetPlayer()->GetTarget()->GetName();
  10870. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  10871. }
  10872. else
  10873. target_name = "N/A";
  10874. LogWrite(COMMAND__DEBUG, 1, "Command", "%s", data.c_str());
  10875. if(world.ReportBug(data, client->GetPlayer()->GetName(), client->GetAccountID(), target_name, spawn_id, client->GetCurrentZone()->GetZoneID()))
  10876. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully submitted bug.");
  10877. else
  10878. client->SimpleMessage(CHANNEL_COLOR_RED, "Error submitting bug.");
  10879. }
  10880. }
  10881. void Commands::Command_Attune_Inv(Client* client, Seperator* sep) {
  10882. PrintSep(sep, "Command_Attune_Inv");
  10883. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  10884. // Get the item index from the first parameter
  10885. int16 index = atoi(sep->arg[0]);
  10886. // Check to see if this is a valid item index for the player, if not exit out of the function
  10887. if (client->GetPlayer()->item_list.indexed_items.count(index) == 0) {
  10888. LogWrite(ITEM__DEBUG, 0, "Items", "%s has no item with an index of %i", client->GetPlayer()->GetName(), index);
  10889. return;
  10890. }
  10891. // Get the item
  10892. Item* item = client->GetPlayer()->item_list.indexed_items[index];
  10893. if(item) {
  10894. // Valid item lets check to make sure this item is attunable, if not return out
  10895. if (!item->CheckFlag(ATTUNEABLE)) {
  10896. LogWrite(ITEM__DEBUG, 0, "Items", "attune_inv called for an item that is not attunable (%s)", item->name.c_str());
  10897. return;
  10898. }
  10899. // Remove the attunable flag
  10900. item->generic_info.item_flags -= ATTUNEABLE;
  10901. // Set the attuned flag
  10902. item->generic_info.item_flags += ATTUNED;
  10903. // Flag this item for saving
  10904. item->save_needed = true;
  10905. client->QueuePacket(item->serialize(client->GetVersion(), false, client->GetPlayer()));
  10906. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), 0, -1); // appearance type??
  10907. EQ2Packet* outapp = 0;
  10908. for (int32 i=0;i<packets.size();i++) {
  10909. outapp = packets[i];
  10910. if(outapp)
  10911. client->QueuePacket(outapp);
  10912. }
  10913. }
  10914. }
  10915. }
  10916. void Commands::Command_Reset_Zone_Timer(Client* client, Seperator* sep) {
  10917. PrintSep(sep, "Command_Reset_Zone_Timer");
  10918. /*if (sep && sep->arg[0] && sep->IsNumber(0)) {
  10919. int32 db_id = atoul(sep->arg[0]);
  10920. InstanceData* data = client->GetPlayer()->GetCharacterInstances().FindInstanceByDBID(db_id);
  10921. if (data) {
  10922. // TODO: add a check to timers to ensure it can be reset
  10923. // Delete the character from the instance
  10924. database.DeleteCharacterFromInstance(client->GetPlayer()->GetCharacterID(), data->instance_id);
  10925. data->instance_id = 0;
  10926. // Update the success time and set to 0 so the player can enter it again
  10927. database.UpdateCharacterInstance(client->GetPlayer()->GetCharacterID(), data->zone_name, 0, 1, 0);
  10928. data->last_success_timestamp = 0;
  10929. }
  10930. }*/
  10931. }
  10932. void Commands::Command_Player(Client* client, Seperator* sep) {
  10933. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player syntax --");
  10934. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins");
  10935. }
  10936. void Commands::Command_Player_Coins(Client* client, Seperator* sep) {
  10937. // /player coins add 10
  10938. // /player coins add plat 10
  10939. Player* player = client->GetPlayer();
  10940. Client* targetClient = client;
  10941. if (player->HasTarget() && player->GetTarget()->IsPlayer()) {
  10942. player = (Player*)player->GetTarget();
  10943. targetClient = player->GetClient();
  10944. }
  10945. if (sep && sep->arg[0] && sep->arg[1]) {
  10946. const char* action = sep->arg[0];
  10947. int64 value = 0;
  10948. if (strncasecmp(action, "add", strlen(action)) == 0) {
  10949. if (sep->IsNumber(1)) {
  10950. value = atoi64(sep->arg[1]);
  10951. player->AddCoins(value);
  10952. if (client->GetPlayer() == player)
  10953. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  10954. else {
  10955. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  10956. if(targetClient) {
  10957. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  10958. }
  10959. }
  10960. return;
  10961. }
  10962. else if (sep->arg[2] && sep->IsNumber(2)) {
  10963. const char* type = sep->arg[1];
  10964. if (strncasecmp(type, "copper", strlen(type)) == 0) {
  10965. value = atoi64(sep->arg[2]);
  10966. }
  10967. else if (strncasecmp(type, "silver", strlen(type)) == 0) {
  10968. value = atoi64(sep->arg[2]) * 100;
  10969. }
  10970. else if (strncasecmp(type, "gold", strlen(type)) == 0) {
  10971. value = atoi64(sep->arg[2]) * 10000;
  10972. }
  10973. else if (strncasecmp(type, "plat", strlen(type)) == 0) {
  10974. value = atoi64(sep->arg[2]) * 1000000;
  10975. }
  10976. player->AddCoins(value);
  10977. if (client->GetPlayer() == player)
  10978. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  10979. else {
  10980. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  10981. if(targetClient) {
  10982. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  10983. }
  10984. }
  10985. return;
  10986. }
  10987. }
  10988. }
  10989. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player coins syntax --");
  10990. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add [value] - adds the given number of coins to the player");
  10991. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add copper [value] - adds the given amount of copper to the player");
  10992. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add silver [value] - adds the given amount of silver to the player");
  10993. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add gold [value] - adds the given amount of gold to the player");
  10994. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add plat [value] - adds the given amount of platinum to the player");
  10995. }
  10996. void Commands::Command_AchievementAdd(Client* client, Seperator* sep) {
  10997. PrintSep(sep, "ACHIEVEMENT_ADD");
  10998. if (sep && sep->IsSet(0)) {
  10999. int32 spell_id = atoul(sep->arg[1]);
  11000. int8 spell_tier = 0;
  11001. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  11002. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  11003. // addspellbookentry here
  11004. if (spell_tier >= data->maxRank) {
  11005. return;
  11006. }
  11007. if (!spell_tier) {
  11008. spell_tier = 1;
  11009. }
  11010. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  11011. {
  11012. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  11013. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  11014. client->GetPlayer()->UnlockSpell(spell);
  11015. client->SendSpellUpdate(spell);
  11016. }
  11017. else
  11018. {
  11019. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1);
  11020. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  11021. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  11022. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  11023. client->GetPlayer()->UnlockSpell(spell);
  11024. client->SendSpellUpdate(spell);
  11025. }
  11026. // cast spell here
  11027. if (!spell_tier)
  11028. spell_tier = 1;
  11029. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  11030. if (spell) {
  11031. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  11032. }
  11033. }
  11034. else {
  11035. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  11036. }
  11037. if(client->GetVersion() > 561)
  11038. master_aa_list.DisplayAA(client, 0, 0);
  11039. }
  11040. void Commands::Command_Editor(Client* client, Seperator* sep) {
  11041. PacketStruct* packet = configReader.getStruct("WS_ChoiceWindow", client->GetVersion());
  11042. if (packet) {
  11043. string url = string(rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_World, EditorURL)->GetString());
  11044. if (rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_World, EditorOfficialServer)->GetBool()) {
  11045. char command[255];
  11046. url = "browser " + url;
  11047. int32 spawn_id = 0;
  11048. int32 zone_id = 0;
  11049. string type;
  11050. if (client->GetCurrentZone())
  11051. zone_id = client->GetCurrentZone()->GetZoneID();
  11052. if (client->GetPlayer()->GetTarget()) {
  11053. Spawn* target = client->GetPlayer()->GetTarget();
  11054. if (target->IsWidget())
  11055. type = "widgets";
  11056. else if (target->IsSign())
  11057. type = "signs";
  11058. else if (target->IsObject())
  11059. type = "objects";
  11060. else if (target->IsNPC())
  11061. type = "npcs";
  11062. else if (target->IsGroundSpawn())
  11063. type = "ground";
  11064. else
  11065. type = "spawn";
  11066. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  11067. }
  11068. sprintf(command, url.c_str(), zone_id, type.c_str(), spawn_id);
  11069. packet->setDataByName("accept_command", command);
  11070. }
  11071. else if (rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_World, EditorIncludeID)->GetBool()) {
  11072. char command[255];
  11073. url = "browser " + url;
  11074. if (client->GetPlayer()->GetTarget())
  11075. sprintf(command, url.c_str(), client->GetPlayer()->GetTarget()->GetDatabaseID());
  11076. packet->setDataByName("accept_command", command);
  11077. }
  11078. else {
  11079. string command = "browser " + url;
  11080. packet->setDataByName("accept_command", command.c_str());
  11081. }
  11082. packet->setDataByName("text", "Open the web editor?");
  11083. packet->setDataByName("accept_text", "Open");
  11084. packet->setDataByName("cancel_text", "Cancel");
  11085. // No clue if we even need the following 2 unknowns, just added them so the packet matches what live sends
  11086. packet->setDataByName("unknown2", 50);
  11087. packet->setDataByName("unknown4", 1);
  11088. client->QueuePacket(packet->serialize());
  11089. safe_delete(packet);
  11090. }
  11091. }
  11092. void Commands::Command_AcceptResurrection(Client* client, Seperator* sep) {
  11093. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  11094. return;
  11095. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  11096. if(client->GetCurrentRez()->active)
  11097. client->AcceptResurrection();
  11098. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  11099. }
  11100. void Commands::Command_DeclineResurrection(Client* client, Seperator* sep) {
  11101. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  11102. return;
  11103. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  11104. if(client->GetCurrentRez()->active)
  11105. client->GetCurrentRez()->should_delete = true;
  11106. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  11107. }
  11108. void Commands::Switch_AA_Profile(Client* client, Seperator* sep) {
  11109. PrintSep(sep, "Switch_AA_Profile");
  11110. if (sep && sep->IsSet(0)) {
  11111. string type = sep->arg[0];
  11112. int8 newtemplate = atoul(sep->arg[1]);
  11113. if(client->GetVersion() > 561)
  11114. master_aa_list.DisplayAA(client, newtemplate, 1);
  11115. }
  11116. }
  11117. void Commands::Get_AA_Xml(Client* client, Seperator* sep) {
  11118. PrintSep(sep, "Get_AA_Xml");
  11119. if (sep && sep->IsSet(0)) {
  11120. string tabnum = sep->arg[0];
  11121. string spellid = sep->arg[1];
  11122. }
  11123. }
  11124. void Commands::Add_AA(Client* client, Seperator* sep) {
  11125. PrintSep(sep, "Add_AA");
  11126. if (sep && sep->IsSet(0)) {
  11127. int32 spell_id = atoul(sep->arg[1]);
  11128. int8 spell_tier = 0;
  11129. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  11130. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  11131. // addspellbookentry here
  11132. if(!data) {
  11133. LogWrite(COMMAND__ERROR, 0, "Command", "Error in Add_AA no data for spell_id %u spell_tier %u", spell_id, spell_tier);
  11134. return;
  11135. }
  11136. if (spell_tier >= data->maxRank) {
  11137. LogWrite(COMMAND__ERROR, 0, "Command", "Error in Add_AA spell_tier %u >= maxRank %u", spell_tier, data->maxRank);
  11138. return;
  11139. }
  11140. if (!spell_tier) {
  11141. spell_tier = 1;
  11142. }
  11143. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  11144. {
  11145. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  11146. if(spell)
  11147. {
  11148. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  11149. client->GetPlayer()->UnlockSpell(spell);
  11150. client->SendSpellUpdate(spell);
  11151. }
  11152. }
  11153. else
  11154. {
  11155. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1 );
  11156. if(spell)
  11157. {
  11158. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  11159. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  11160. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  11161. client->GetPlayer()->UnlockSpell(spell);
  11162. client->SendSpellUpdate(spell);
  11163. }
  11164. }
  11165. // cast spell here
  11166. if (!spell_tier)
  11167. spell_tier = 1;
  11168. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  11169. if (spell) {
  11170. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  11171. }
  11172. }
  11173. else {
  11174. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  11175. }
  11176. if(client->GetVersion() > 561)
  11177. master_aa_list.DisplayAA(client, 0, 0);
  11178. }
  11179. void Commands::Commit_AA_Profile(Client* client, Seperator* sep) {
  11180. PrintSep(sep, "Commit_AA_Profile");
  11181. if (sep && sep->IsSet(0)) {
  11182. }
  11183. }
  11184. void Commands::Begin_AA_Profile(Client* client, Seperator* sep) {
  11185. PrintSep(sep, "Begin_AA_Profile");
  11186. if (sep && sep->IsSet(0)) {
  11187. if(client->GetVersion() > 561)
  11188. master_aa_list.DisplayAA(client, 100, 2);
  11189. }
  11190. }
  11191. void Commands::Back_AA(Client* client, Seperator* sep) {
  11192. if (sep && sep->IsSet(0)) {
  11193. PrintSep(sep, "Back_AA");
  11194. }
  11195. }
  11196. void Commands::Remove_AA(Client* client, Seperator* sep) {
  11197. if (sep && sep->IsSet(0)) {
  11198. PrintSep(sep, "Remove_AA");
  11199. }
  11200. }
  11201. void Commands::Cancel_AA_Profile(Client* client, Seperator* sep) {
  11202. MasterAAList master_aa_list;
  11203. PrintSep(sep, "Cancel_AA_Profile");
  11204. if(client->GetVersion() > 561)
  11205. master_aa_list.DisplayAA(client, 0, 0);
  11206. }
  11207. void Commands::Save_AA_Profile(Client* client, Seperator* sep) {
  11208. if (sep && sep->IsSet(0)) {
  11209. PrintSep(sep, "Save_AA_Profile");
  11210. }
  11211. }
  11212. void Commands::Command_TargetItem(Client* client, Seperator* sep) {
  11213. if (!sep || sep->GetArgNumber() < 1 || !client->GetPlayer()) return;
  11214. if (!sep->IsNumber(0)) return;
  11215. int32 request_id = atoul(sep->arg[0]);
  11216. if (!sep->IsNumber(1)) return;
  11217. sint32 item_id = atoi(sep->arg[1]);
  11218. if (client->IsCurrentTransmuteID(request_id)) {
  11219. Transmute::HandleItemResponse(client, client->GetPlayer(), request_id, reinterpret_cast<int32&>(item_id));
  11220. }
  11221. else if (client->IsCurrentTransmuteID(item_id)) {
  11222. if (!sep->IsSet(2)) return;
  11223. if (sep->IsNumber(2) && atoi(sep->arg[2]) == 1) {
  11224. Transmute::HandleConfirmResponse(client, client->GetPlayer(), reinterpret_cast<int32&>(item_id));
  11225. }
  11226. }
  11227. }
  11228. void Commands::Command_FindSpawn(Client* client, Seperator* sep) {
  11229. if(sep)
  11230. client->GetCurrentZone()->FindSpawn(client, (char*)sep->argplus[0]);
  11231. }
  11232. void Commands::Command_MoveCharacter(Client* client, Seperator* sep) {
  11233. if(sep && sep->arg[0][0] && sep->arg[1][0])
  11234. {
  11235. char* name = sep->arg[0];
  11236. char* zoneName = sep->arg[1];
  11237. char query[256];
  11238. 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);
  11239. if (database.RunQuery(query, strnlen(query, 256)))
  11240. {
  11241. client->Message(CHANNEL_COLOR_YELLOW, "Ran query:%s", query);
  11242. }
  11243. else
  11244. client->Message(CHANNEL_COLOR_RED, "Query FAILED to run: %s", query);
  11245. }
  11246. }
  11247. void Commands::Command_Mood(Client* client, Seperator* sep) {
  11248. Player* player = client->GetPlayer();
  11249. if( sep && sep->arg[0] )
  11250. {
  11251. const char* value = sep->arg[0];
  11252. InfoStruct* info = player->GetInfoStruct();
  11253. int32 cid = client->GetCharacterID();
  11254. char* characterName = database.GetCharacterName(cid);
  11255. char tmp[1024]; // our emote string "xyz appears zyx"
  11256. //char properties vals
  11257. char* pname = "mood";
  11258. char* pval; // mood value
  11259. bool pt; //used to verify return from DB.
  11260. //This should never be seen.
  11261. sprintf(tmp, " ");
  11262. if( strncasecmp(value, "angry", strlen(value)) == 0 )
  11263. {
  11264. sprintf(tmp, "%s appears angry", characterName);
  11265. pval = "11852";
  11266. player->SetMoodState(11852, 1);
  11267. info->set_mood(11852);
  11268. pt = database.insertCharacterProperty(client, pname, pval);
  11269. }
  11270. else if( strncasecmp(value, "afraid", strlen(value)) == 0 )
  11271. {
  11272. sprintf(tmp, "%s appears afraid", characterName);
  11273. pval = "11851";
  11274. player->SetMoodState(11851, 1);
  11275. info->set_mood(11851);
  11276. pt = database.insertCharacterProperty(client, pname, pval);
  11277. }
  11278. else if( strncasecmp(value, "happy", strlen(value)) == 0 )
  11279. {
  11280. sprintf(tmp, "%s appears happy", characterName);
  11281. pval = "11854";
  11282. player->SetMoodState(11854, 1);
  11283. info->set_mood(11854);
  11284. pt = database.insertCharacterProperty(client, pname, pval);
  11285. }
  11286. else if( strncasecmp(value, "sad", strlen(value)) == 0 ) {
  11287. sprintf(tmp, "%s appears sad", characterName);
  11288. pval = "11856";
  11289. player->SetMoodState(11856, 1);
  11290. info->set_mood(11856);
  11291. pt = database.insertCharacterProperty(client, pname, pval);
  11292. }
  11293. else if( strncasecmp(value, "tired", strlen(value)) == 0 )
  11294. {
  11295. sprintf(tmp, "%s appears tired", characterName);
  11296. pval = "11857";
  11297. player->SetMoodState(11857, 1);
  11298. info->set_mood(11857);
  11299. pt = database.insertCharacterProperty(client, pname, pval);
  11300. }
  11301. else if( strncasecmp(value, "none", strlen(value)) == 0 )
  11302. {
  11303. //using 11855 mood_idle for none, I assume thats what its for?
  11304. pval = "11855";
  11305. player->SetMoodState(11855, 1);
  11306. info->set_mood(11855);
  11307. pt = database.insertCharacterProperty(client, pname, pval);
  11308. //return since we have nothing left to do. No emote for none.
  11309. return;
  11310. }else{
  11311. client->SimpleMessage(CHANNEL_NARRATIVE, "Listing Available Moods:");
  11312. client->SimpleMessage(CHANNEL_NARRATIVE, "none");
  11313. client->SimpleMessage(CHANNEL_NARRATIVE, "afraid");
  11314. client->SimpleMessage(CHANNEL_NARRATIVE, "angry");
  11315. client->SimpleMessage(CHANNEL_NARRATIVE, "happy");
  11316. client->SimpleMessage(CHANNEL_NARRATIVE, "sad");
  11317. client->SimpleMessage(CHANNEL_NARRATIVE, "tired");
  11318. return;
  11319. }
  11320. client->GetPlayer()->GetZone()->HandleChatMessage(0, 0, CHANNEL_EMOTE, tmp);
  11321. return;
  11322. }
  11323. client->SimpleMessage(CHANNEL_NARRATIVE, "Listing Available Moods:");
  11324. client->SimpleMessage(CHANNEL_NARRATIVE, "none");
  11325. client->SimpleMessage(CHANNEL_NARRATIVE, "afraid");
  11326. client->SimpleMessage(CHANNEL_NARRATIVE, "angry");
  11327. client->SimpleMessage(CHANNEL_NARRATIVE, "happy");
  11328. client->SimpleMessage(CHANNEL_NARRATIVE, "sad");
  11329. client->SimpleMessage(CHANNEL_NARRATIVE, "tired");
  11330. return;
  11331. }
  11332. /*
  11333. Function: Command_CancelEffect()
  11334. Purpose : Cancels (good) effect spells
  11335. Example : /cancel_effect spell_id - would cancel the spell with the <spell_id> value in spell effects list
  11336. */
  11337. void Commands::Command_CancelEffect(Client* client, Seperator* sep)
  11338. {
  11339. if (sep && sep->arg[0] && sep->IsNumber(0))
  11340. {
  11341. int32 spell_id = atoul(sep->arg[0]);
  11342. SpellEffects* effect = client->GetPlayer()->GetSpellEffect(spell_id);
  11343. if(!effect || effect->spell->spell->GetSpellData()->det_type) {
  11344. return;
  11345. }
  11346. MaintainedEffects* meffect = effect->caster->GetMaintainedSpell(spell_id);
  11347. if (!meffect || !meffect->spell || !meffect->spell->caster || !meffect->spell->caster->GetZone() ||
  11348. !meffect->spell->caster->GetZone()->GetSpellProcess()->DeleteCasterSpell(meffect->spell, "canceled", false, client->GetPlayer()))
  11349. client->Message(CHANNEL_COLOR_RED, "The spell effect could not be cancelled.");
  11350. }
  11351. }
  11352. /*
  11353. Function: Command_CurePlayer()
  11354. Purpose : Identifies spell to cast for cure based on type
  11355. Example : /cureplayer ??
  11356. https://eq2.fandom.com/wiki/Update:58
  11357. New command /cureplayer [playername|group or raid position][trauma|arcane|noxious|elemental|curse] optional [spell|potion]
  11358. Example: /cureplayer g0 noxious spell
  11359. Will attempt to cure yourself of a noxious detriment with only spells and without using potions (even if you have them).
  11360. Example: /cureplayer r4 noxious
  11361. Will attempt to cure the character in raid slot 4 of a noxious detriment using a spell or potion (whichever is available).
  11362. */
  11363. void Commands::Command_CurePlayer(Client* client, Seperator* sep)
  11364. {
  11365. Entity* target = nullptr;
  11366. bool use_spells = true;
  11367. bool use_potions = true;
  11368. if (sep && sep->arg[0] && sep->arg[1]) {
  11369. if(sep->arg[2]) {
  11370. std::string type(sep->arg[2]);
  11371. boost::algorithm::to_lower(type);
  11372. if(type == "potion")
  11373. use_spells = false;
  11374. else if(type == "spell")
  11375. use_potions = false;
  11376. }
  11377. if(strlen(sep->arg[0]) > 1 && isdigit(sep->arg[0][1])) {
  11378. int32 mapped_position = (int32)(sep->arg[0][1]) - 48;
  11379. // TODO: RAID Support ('r' argument)
  11380. if(sep->arg[0][0] == 'g' && !mapped_position) {
  11381. target = (Entity*)client->GetPlayer();
  11382. }
  11383. else {
  11384. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  11385. if (gmi && gmi->group_id) {
  11386. PlayerGroup* group = world.GetGroupManager()->GetGroup(gmi->group_id);
  11387. if(group) {
  11388. target = group->GetGroupMemberByPosition(client->GetPlayer(), mapped_position);
  11389. }
  11390. }
  11391. }
  11392. }
  11393. else {
  11394. Client* target_client = zone_list.GetClientByCharName(sep->arg[0]);
  11395. if(target_client && target_client->GetPlayer() && target_client->GetPlayer()->GetZone() == client->GetPlayer()->GetZone()) {
  11396. target = (Entity*)target_client->GetPlayer();
  11397. }
  11398. }
  11399. ItemEffectType type = EFFECT_CURE_TYPE_ALL;
  11400. bool successful_spell = false;
  11401. bool successful_potion = false;
  11402. if(target) {
  11403. SpellBookEntry* entry = nullptr;
  11404. std::string str(sep->arg[1]);
  11405. boost::algorithm::to_lower(str);
  11406. if(str == "arcane") {
  11407. type = EFFECT_CURE_TYPE_ARCANE;
  11408. // cure arcane spell missing in DB?
  11409. if(use_spells && rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Spells, CureArcaneSpellID)->GetInt32()) {
  11410. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Spells, CureArcaneSpellID)->GetInt32()); // cure noxious
  11411. }
  11412. }
  11413. else if(str == "trauma") {
  11414. type = EFFECT_CURE_TYPE_TRAUMA;
  11415. // cure trauma spell missing in DB?
  11416. if(use_spells && rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Spells, CureTraumaSpellID)->GetInt32()) {
  11417. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Spells, CureTraumaSpellID)->GetInt32()); // cure noxious
  11418. }
  11419. }
  11420. else if(str == "noxious") {
  11421. type = EFFECT_CURE_TYPE_NOXIOUS;
  11422. if(use_spells && rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Spells, CureNoxiousSpellID)->GetInt32()) {
  11423. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Spells, CureNoxiousSpellID)->GetInt32()); // cure noxious
  11424. }
  11425. }
  11426. else if(str == "curse") {
  11427. type = EFFECT_CURE_TYPE_CURSE;
  11428. if(use_spells && rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Spells, CureCurseSpellID)->GetInt32()) {
  11429. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Spells, CureCurseSpellID)->GetInt32()); // cure curse
  11430. }
  11431. }
  11432. else if(str == "magic") {
  11433. type = EFFECT_CURE_TYPE_MAGIC;
  11434. if(use_spells && rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Spells, CureMagicSpellID)->GetInt32()) {
  11435. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Spells, CureMagicSpellID)->GetInt32()); // cure magic
  11436. }
  11437. }
  11438. if(use_spells) {
  11439. // check if any of the specific cure types are available, if not then check the base cures
  11440. if(!entry && rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Spells, CureSpellID)->GetInt32()) {
  11441. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Spells, CureSpellID)->GetInt32()); // cure
  11442. }
  11443. if(entry && entry->spell_id) {
  11444. Spell* spell = master_spell_list.GetSpell(entry->spell_id, entry->tier);
  11445. target->GetZone()->ProcessSpell(spell, (Entity*)client->GetPlayer(), target, true, false);
  11446. successful_spell = true;
  11447. }
  11448. }
  11449. }
  11450. if(!successful_spell && use_potions && target && type != NO_EFFECT_TYPE) {
  11451. vector<Item*>* potential_items = client->GetItemsByEffectType(type, EFFECT_CURE_TYPE_ALL);
  11452. if (potential_items && potential_items->size() > 0) {
  11453. vector<Item*>::iterator itr;
  11454. for (itr = potential_items->begin(); itr != potential_items->end(); itr++)
  11455. {
  11456. Item* item = *itr;
  11457. if(client->UseItem(item, target)) {
  11458. successful_potion = true;
  11459. break;
  11460. }
  11461. }
  11462. }
  11463. safe_delete(potential_items);
  11464. }
  11465. }
  11466. }
  11467. /*
  11468. Function: Command_ShareQuest()
  11469. Purpose : Share quest with the group
  11470. Example : /share_quest [quest_id]
  11471. */
  11472. void Commands::Command_ShareQuest(Client* client, Seperator* sep)
  11473. {
  11474. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  11475. int32 quest_id = atoul(sep->arg[0]);
  11476. bool hasQuest = client->GetPlayer()->HasAnyQuest(quest_id);
  11477. if(hasQuest) {
  11478. Quest* quest = master_quest_list.GetQuest(quest_id, false);
  11479. if(quest) {
  11480. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  11481. if (gmi && gmi->group_id) {
  11482. PlayerGroup* group = world.GetGroupManager()->GetGroup(gmi->group_id);
  11483. if (group) {
  11484. group->ShareQuestWithGroup(client, quest);
  11485. }
  11486. }
  11487. }
  11488. }
  11489. else {
  11490. client->SimpleMessage(CHANNEL_COLOR_RED, "Cannot find quest.");
  11491. }
  11492. }
  11493. }
  11494. /*
  11495. Function: Command_Yell()
  11496. Purpose : Yell to break an encounter
  11497. Example : /yell
  11498. * Uses self target, encounter target or no target
  11499. */
  11500. void Commands::Command_Yell(Client* client, Seperator* sep) {
  11501. Entity* player = (Entity*)client->GetPlayer();
  11502. Spawn* res = nullptr;
  11503. Spawn* prev = nullptr;
  11504. bool cycleAll = false;
  11505. if (player->GetTarget() == player) {
  11506. cycleAll = true; // self target breaks all encounters
  11507. }
  11508. else if (player->GetTarget()) {
  11509. res = player->GetTarget(); // selected target other than self only dis-engages that encounter
  11510. }
  11511. if (res && !client->GetPlayer()->IsEngagedBySpawnID(res->GetID()))
  11512. return;
  11513. bool groupPermissionYell = true;
  11514. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  11515. // If the player has a group and has a target
  11516. if (gmi) {
  11517. deque<GroupMemberInfo*>::iterator itr;
  11518. world.GetGroupManager()->GroupLock(__FUNCTION__, __LINE__);
  11519. PlayerGroup* group = world.GetGroupManager()->GetGroup(gmi->group_id);
  11520. if (group && !group->GetGroupOptions()->default_yell && !gmi->leader) { // default_yell_method = 0 means leader only
  11521. groupPermissionYell = false;
  11522. }
  11523. world.GetGroupManager()->ReleaseGroupLock(__FUNCTION__, __LINE__);
  11524. }
  11525. if (!groupPermissionYell) {
  11526. LogWrite(COMMAND__ERROR, 0, "Command", "%s permission to yell denied due to group yell method set to leader only", client->GetPlayer()->GetName());
  11527. return;
  11528. }
  11529. bool alreadyYelled = false;
  11530. do {
  11531. if (!res && player->IsEngagedInEncounter(&res)) { // no target is set, dis-engage top of hated by list
  11532. }
  11533. if (!res || prev == res) {
  11534. return;
  11535. }
  11536. if (res->IsNPC() && ((NPC*)res)->Brain()) {
  11537. if (!alreadyYelled) {
  11538. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You yell for help!");
  11539. string yellMsg = std::string(client->GetPlayer()->GetName()) + " yelled for help!";
  11540. client->GetPlayer()->GetZone()->SimpleMessage(CHANNEL_COLOR_RED, yellMsg.c_str(), client->GetPlayer(), 35.0f, false);
  11541. client->GetPlayer()->GetZone()->SendYellPacket(client->GetPlayer());
  11542. }
  11543. alreadyYelled = true;
  11544. NPC* npc = (NPC*)res;
  11545. npc->Brain()->ClearEncounter();
  11546. npc->SetLockedNoLoot(ENCOUNTER_STATE_BROKEN);
  11547. npc->UpdateEncounterState(ENCOUNTER_STATE_BROKEN);
  11548. }
  11549. prev = res;
  11550. res = nullptr;
  11551. } while (cycleAll);
  11552. if (!player->IsEngagedInEncounter()) {
  11553. if (player->GetInfoStruct()->get_engaged_encounter()) {
  11554. player->GetInfoStruct()->set_engaged_encounter(0);
  11555. player->SetRegenValues((player->GetInfoStruct()->get_effective_level() > 0) ? player->GetInfoStruct()->get_effective_level() : player->GetLevel());
  11556. client->GetPlayer()->SetCharSheetChanged(true);
  11557. player->info_changed = true;
  11558. }
  11559. }
  11560. }
  11561. /*
  11562. Function: Command_SetAutoLootMode()
  11563. Purpose : Set player auto loot mode (0 = disabled, 1 = need/lotto, 2 = decline).
  11564. Example : /setautolootmode [mode]
  11565. */
  11566. void Commands::Command_SetAutoLootMode(Client* client, Seperator* sep) {
  11567. if (sep && sep->IsNumber(0)) {
  11568. int8 mode = atoul(sep->arg[0]);
  11569. switch (mode) {
  11570. case AutoLootMode::METHOD_DISABLED: {
  11571. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Disabled auto loot mode");
  11572. break;
  11573. }
  11574. case AutoLootMode::METHOD_ACCEPT: {
  11575. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Enabled auto loot mode for need and lotto.");
  11576. break;
  11577. }
  11578. default: {
  11579. mode = AutoLootMode::METHOD_DECLINE;
  11580. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Enabled auto loot mode to decline need and lotto.");
  11581. break;
  11582. }
  11583. }
  11584. client->GetPlayer()->GetInfoStruct()->set_group_auto_loot_method(mode);
  11585. database.insertCharacterProperty(client, CHAR_PROPERTY_AUTOLOOTMETHOD, (char*)std::to_string(mode).c_str());
  11586. client->SendDefaultGroupOptions();
  11587. }
  11588. }
  11589. /*
  11590. Function: Command_AutoAttack()
  11591. Purpose : Attack / Auto Attack
  11592. Example : /attack, /autoattack type
  11593. */
  11594. void Commands::Command_AutoAttack(Client* client, Seperator* sep) {
  11595. int8 type = 1;
  11596. bool update = false;
  11597. Player* player = client->GetPlayer();
  11598. if(!player)
  11599. return;
  11600. bool incombat = player->EngagedInCombat();
  11601. if(sep && sep->arg[0] && sep->IsNumber(0))
  11602. type = atoi(sep->arg[0]);
  11603. if(!client->GetPlayer()->Alive()){
  11604. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  11605. return;
  11606. }
  11607. if(type == 0){
  11608. if(incombat)
  11609. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You stop fighting.");
  11610. player->StopCombat(type);
  11611. update = true;
  11612. }
  11613. else {
  11614. if(type == 2){
  11615. player->InCombat(false);
  11616. if(incombat && player->GetRangeAttack()){
  11617. player->StopCombat(type);
  11618. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You stop fighting.");
  11619. update = true;
  11620. }
  11621. else{
  11622. player->SetRangeAttack(true);
  11623. player->InCombat(true, true);
  11624. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You start fighting.");
  11625. update = true;
  11626. }
  11627. }
  11628. else {
  11629. player->InCombat(false, true);
  11630. player->SetRangeAttack(false);
  11631. player->InCombat(true);
  11632. if(!incombat) {
  11633. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You start fighting.");
  11634. update = true;
  11635. }
  11636. }
  11637. /*else
  11638. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You cannot attack that!");*/
  11639. }
  11640. if(update) {
  11641. player->SetCharSheetChanged(true);
  11642. }
  11643. }
  11644. /*
  11645. Function: Command_Assist()
  11646. Purpose : Assist target
  11647. Example : /assist [name]
  11648. * Uses target or character name
  11649. */
  11650. void Commands::Command_Assist(Client* client, Seperator* sep) {
  11651. Entity* player = (Entity*)client->GetPlayer();
  11652. Spawn* res = nullptr;
  11653. if(sep && sep->arg[0]) {
  11654. if(!stricmp(sep->arg[0], "on")) {
  11655. database.insertCharacterProperty(client, CHAR_PROPERTY_ASSISTAUTOATTACK, "1");
  11656. return;
  11657. }
  11658. else if(!stricmp(sep->arg[0], "off")) {
  11659. database.insertCharacterProperty(client, CHAR_PROPERTY_ASSISTAUTOATTACK, "0");
  11660. return;
  11661. }
  11662. Client* otherClient = client->GetPlayer()->GetZone()->GetClientByName(sep->arg[0]);
  11663. if(otherClient) {
  11664. res = otherClient->GetPlayer();
  11665. }
  11666. }
  11667. if (player->GetTarget()) {
  11668. res = player->GetTarget(); // selected target other than self only dis-engages that encounter
  11669. }
  11670. if(res && res->GetTarget()) {
  11671. res = res->GetTarget();
  11672. }
  11673. if(res) {
  11674. client->TargetSpawn(res);
  11675. if(client->GetPlayer()->GetInfoStruct()->get_assist_auto_attack() && !player->EngagedInCombat()) {
  11676. Command_AutoAttack(client, nullptr);
  11677. }
  11678. }
  11679. }
  11680. /*
  11681. Function: Command_Target()
  11682. Purpose : Target spawn/player
  11683. Example : /target [name]
  11684. * Uses target or character name
  11685. */
  11686. void Commands::Command_Target(Client* client, Seperator* sep) {
  11687. Entity* player = (Entity*)client->GetPlayer();
  11688. Spawn* res = nullptr;
  11689. if(sep && sep->arg[0] && player->GetZone()) {
  11690. float max_distance = rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Player, MaxTargetCommandDistance)->GetFloat();
  11691. if(max_distance < 1.0f) {
  11692. max_distance = 10.0f;
  11693. }
  11694. player->GetZone()->SetPlayerTargetByName(client, (char*)sep->argplus[0], max_distance);
  11695. }
  11696. }
  11697. /*
  11698. Function: Command_Target_Pet()
  11699. Purpose : Target pet
  11700. Example : /target_pet
  11701. * Use to target pet
  11702. */
  11703. void Commands::Command_Target_Pet(Client* client, Seperator* sep) {
  11704. Entity* player = (Entity*)client->GetPlayer();
  11705. Spawn* res = client->GetPlayer()->GetPet();
  11706. if(res) {
  11707. client->TargetSpawn(res);
  11708. }
  11709. }
  11710. /*
  11711. Function: Command_WhoGroup()
  11712. Purpose : Lists all members of current group
  11713. Example : /whogroup
  11714. */
  11715. void Commands::Command_WhoGroup(Client* client, Seperator* sep) {
  11716. Entity* player = (Entity*)client->GetPlayer();
  11717. if(player->GetGroupMemberInfo()) {
  11718. world.GetGroupManager()->SendWhoGroupMembers(client, player->GetGroupMemberInfo()->group_id);
  11719. }
  11720. else {
  11721. client->SimpleMessage(CHANNEL_COLOR_RED, "You are not currently in a group.");
  11722. }
  11723. }
  11724. /*
  11725. Function: Command_WhoRaid()
  11726. Purpose : Lists all members of raid
  11727. Example : /whoraid
  11728. */
  11729. void Commands::Command_WhoRaid(Client* client, Seperator* sep) {
  11730. Entity* player = (Entity*)client->GetPlayer();
  11731. if(player->GetGroupMemberInfo()) {
  11732. world.GetGroupManager()->SendWhoRaidMembers(client, player->GetGroupMemberInfo()->group_id);
  11733. }
  11734. else {
  11735. client->SimpleMessage(CHANNEL_COLOR_RED, "You are not currently in a group or raid.");
  11736. }
  11737. }
  11738. /*
  11739. Function: Command_RaidInvite()
  11740. Purpose : Invites a group to the raid
  11741. Example : /raidinvite
  11742. */
  11743. void Commands::Command_RaidInvite(Client* client, Seperator* sep) {
  11744. Entity* target = nullptr;
  11745. if( sep && sep->arg[0] ) {
  11746. Client* target_client = zone_list.GetClientByCharName(sep->arg[0]);
  11747. if(target_client)
  11748. target = (Entity*)target_client->GetPlayer();
  11749. }
  11750. if(!target) {
  11751. if(client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsEntity())
  11752. target = (Entity*)client->GetPlayer()->GetTarget();
  11753. }
  11754. world.GetGroupManager()->SendRaidInvite(client, target);
  11755. }
  11756. /*
  11757. Function: Command_Raid_Looter()
  11758. Purpose : Adds a looter to the raid loot list
  11759. Example : /raid_looter <name>
  11760. */
  11761. void Commands::Command_Raid_Looter(Client* client, Seperator* sep) {
  11762. if(!client->GetPlayer()->GetGroupMemberInfo() || client->GetPlayer()->GetGroupMemberInfo()->leader)
  11763. return;
  11764. Entity* target = nullptr;
  11765. if( sep && sep->arg[0] ) {
  11766. Client* target_client = zone_list.GetClientByCharName(sep->arg[0]);
  11767. if(target_client)
  11768. target = (Entity*)target_client->GetPlayer();
  11769. }
  11770. if(!target) {
  11771. if(client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsEntity())
  11772. target = (Entity*)client->GetPlayer()->GetTarget();
  11773. }
  11774. bool isLeaderRaid = world.GetGroupManager()->IsInRaidGroup(client->GetPlayer()->GetGroupMemberInfo()->group_id, client->GetPlayer()->GetGroupMemberInfo()->group_id, true);
  11775. if(isLeaderRaid && target && target->IsEntity()) {
  11776. if(((Entity*)target)->GetGroupMemberInfo() && world.GetGroupManager()->IsInRaidGroup(client->GetPlayer()->GetGroupMemberInfo()->group_id, ((Entity*)target)->GetGroupMemberInfo()->group_id, false)) {
  11777. if(((Entity*)target)->GetGroupMemberInfo()->is_raid_looter) {
  11778. client->Message(CHANNEL_COLOR_YELLOW, "%s removed as a raid looter.", target->GetName());
  11779. ((Entity*)target)->GetGroupMemberInfo()->is_raid_looter = false;
  11780. }
  11781. else {
  11782. client->Message(CHANNEL_COLOR_YELLOW, "%s added as a raid looter.", target->GetName());
  11783. ((Entity*)target)->GetGroupMemberInfo()->is_raid_looter = true;
  11784. }
  11785. }
  11786. }
  11787. }
  11788. /*
  11789. Function: Command_KickFromGroup()
  11790. Purpose : Kick a player from a group
  11791. Example : /kickfromgroup <name>
  11792. */
  11793. void Commands::Command_KickFromGroup(Client* client, Seperator* sep) {
  11794. Entity* target = nullptr;
  11795. Client* target_client = nullptr;
  11796. if( sep && sep->arg[0] ) {
  11797. target_client = zone_list.GetClientByCharName(sep->arg[0]);
  11798. if(target_client) {
  11799. target = target_client->GetPlayer();
  11800. }
  11801. }
  11802. if(!target) {
  11803. if(client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsEntity())
  11804. target = (Entity*)client->GetPlayer()->GetTarget();
  11805. if(target && target->IsPlayer())
  11806. target_client = ((Player*)target)->GetClient();
  11807. }
  11808. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  11809. if (gmi && gmi->leader && target && target->GetGroupMemberInfo() && gmi->group_id == target->GetGroupMemberInfo()->group_id) {
  11810. int32 group_id = gmi->group_id;
  11811. world.GetGroupManager()->RemoveGroupMember(group_id, target);
  11812. if (!world.GetGroupManager()->IsGroupIDValid(group_id)) {
  11813. // leader->Message(CHANNEL_COLOR_GROUP, "%s has left the group.", client->GetPlayer()->GetName());
  11814. }
  11815. else {
  11816. world.GetGroupManager()->GroupMessage(group_id, "%s has been removed from the group.", target->GetName());
  11817. }
  11818. if(target_client)
  11819. target_client->SimpleMessage(CHANNEL_GROUP_CHAT, "You have been kicked from the group");
  11820. }
  11821. }
  11822. /*
  11823. Function: Command_KickFromRaid()
  11824. Purpose : Kick a group from a raid
  11825. Example : /kickfromraid <name>
  11826. */
  11827. void Commands::Command_KickFromRaid(Client* client, Seperator* sep) {
  11828. Entity* target = nullptr;
  11829. Client* target_client = nullptr;
  11830. if( sep && sep->arg[0] ) {
  11831. target_client = zone_list.GetClientByCharName(sep->arg[0]);
  11832. if(target_client) {
  11833. target = target_client->GetPlayer();
  11834. }
  11835. }
  11836. if(!target) {
  11837. if(client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsEntity())
  11838. target = (Entity*)client->GetPlayer()->GetTarget();
  11839. if(target && target->IsPlayer())
  11840. target_client = ((Player*)target)->GetClient();
  11841. }
  11842. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  11843. if(gmi && gmi->leader && target && target->GetGroupMemberInfo() && world.GetGroupManager()->IsInRaidGroup(gmi->group_id, target->GetGroupMemberInfo()->group_id, false) &&
  11844. world.GetGroupManager()->IsInRaidGroup(gmi->group_id, gmi->group_id, true)) {
  11845. GroupOptions goptions;
  11846. world.GetGroupManager()->GetDefaultGroupOptions(gmi->group_id, &goptions);
  11847. world.GetGroupManager()->RemoveGroupFromRaid(gmi->group_id, target->GetGroupMemberInfo()->group_id);
  11848. std::vector<int32> raidGroups;
  11849. world.GetGroupManager()->GetRaidGroups(gmi->group_id, &raidGroups);
  11850. peer_manager.sendPeersNewGroupRequest("", 0, gmi->group_id, "", "", &goptions, "", &raidGroups, true);
  11851. std::vector<int32> emptyRaid;
  11852. peer_manager.sendPeersNewGroupRequest("", 0, target->GetGroupMemberInfo()->group_id, "", "", &goptions, "", &emptyRaid, true);
  11853. }
  11854. }
  11855. /*
  11856. Function: Command_LeaveRaid()
  11857. Purpose : Leave a raid
  11858. Example : /leaveraid
  11859. */
  11860. void Commands::Command_LeaveRaid(Client* client, Seperator* sep) {
  11861. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  11862. int32 orig_group_id = 0;
  11863. if(gmi && gmi->leader && world.GetGroupManager()->IsInRaidGroup(gmi->group_id, gmi->group_id, false)) {
  11864. orig_group_id = gmi->group_id;
  11865. GroupOptions goptions;
  11866. world.GetGroupManager()->GetDefaultGroupOptions(gmi->group_id, &goptions);
  11867. std::vector<int32> raidGroups;
  11868. world.GetGroupManager()->GetRaidGroups(gmi->group_id, &raidGroups);
  11869. std::vector<int32>::iterator cur_group_itr = std::find(raidGroups.begin(), raidGroups.end(), gmi->group_id);
  11870. if(cur_group_itr != raidGroups.end())
  11871. raidGroups.erase(cur_group_itr);
  11872. bool sendEmpty = false;
  11873. std::vector<int32> emptyRaid;
  11874. if(raidGroups.size() < 2) {
  11875. sendEmpty = true;
  11876. }
  11877. for(cur_group_itr = raidGroups.begin(); cur_group_itr != raidGroups.end(); cur_group_itr++) {
  11878. if(sendEmpty) {
  11879. world.GetGroupManager()->ClearGroupRaid((*cur_group_itr));
  11880. peer_manager.sendPeersNewGroupRequest("", 0, (*cur_group_itr), "", "", &goptions, "", &emptyRaid, true);
  11881. world.GetGroupManager()->SendGroupUpdate((*cur_group_itr), nullptr, true);
  11882. }
  11883. else {
  11884. world.GetGroupManager()->ReplaceRaidGroups((*cur_group_itr), &raidGroups);
  11885. }
  11886. }
  11887. if(!sendEmpty) {
  11888. peer_manager.sendPeersNewGroupRequest("", 0, orig_group_id, "", "", &goptions, "", &raidGroups, true);
  11889. }
  11890. world.GetGroupManager()->ClearGroupRaid(orig_group_id);
  11891. world.GetGroupManager()->SendGroupUpdate(orig_group_id, nullptr, true);
  11892. peer_manager.sendPeersNewGroupRequest("", 0, orig_group_id, "", "", &goptions, "", &emptyRaid, true);
  11893. }
  11894. }
  11895. /*
  11896. Function: Command_Split()
  11897. Purpose : split coin to group
  11898. Example : /split {plat} {gold} {silver} {copper}
  11899. */
  11900. void Commands::Command_Split(Client* client, Seperator* sep) {
  11901. // int32 item_id = atoul(sep->arg[0,1,2,3]);
  11902. int32 plat = 0, gold = 0, silver = 0, copper = 0;
  11903. if(sep->IsNumber(0))
  11904. plat = atoul(sep->arg[0]);
  11905. if(sep->IsNumber(1))
  11906. gold = atoul(sep->arg[1]);
  11907. if(sep->IsNumber(2))
  11908. silver = atoul(sep->arg[2]);
  11909. if(sep->IsNumber(3))
  11910. copper = atoul(sep->arg[3]);
  11911. world.GetGroupManager()->SplitWithGroupOrRaid(client, plat, gold, silver, copper);
  11912. }
  11913. /*
  11914. Function: Command_RaidSay()
  11915. Purpose : Speak to raid members
  11916. Example : /raidsay {message}, /rsay {message}
  11917. */
  11918. void Commands::Command_RaidSay(Client* client, Seperator* sep) {
  11919. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  11920. if(sep && sep->arg[0] && gmi) {
  11921. world.GetGroupManager()->GroupLock(__FUNCTION__, __LINE__);
  11922. int32 spawn_group_id = gmi->group_id;
  11923. PlayerGroup* spawn_group = world.GetGroupManager()->GetGroup(spawn_group_id);
  11924. bool israidgroup = (spawn_group && spawn_group->IsGroupRaid());
  11925. world.GetGroupManager()->ReleaseGroupLock(__FUNCTION__, __LINE__);
  11926. if(israidgroup) {
  11927. world.GetGroupManager()->GroupChatMessage(gmi->group_id, client->GetPlayer(), client->GetPlayer()->GetCurrentLanguage(), sep->argplus[0], CHANNEL_RAID_SAY);
  11928. peer_manager.SendPeersChannelMessage(gmi->group_id, std::string(client->GetPlayer()->GetName()), std::string(sep->argplus[0]), CHANNEL_RAID_SAY, client->GetPlayer()->GetCurrentLanguage());
  11929. }
  11930. }
  11931. }