Commands.cpp 467 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771
  1. /*
  2. EQ2Emulator: Everquest II Server Emulator
  3. Copyright (C) 2007 EQ2EMulator Development Team (http://www.eq2emulator.net)
  4. This file is part of EQ2Emulator.
  5. EQ2Emulator is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. EQ2Emulator is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with EQ2Emulator. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #include <sys/types.h>
  17. #include <boost/algorithm/string/predicate.hpp>
  18. #include <boost/algorithm/string.hpp>
  19. #include "Commands.h"
  20. #include "../ClientPacketFunctions.h"
  21. #include "../../common/version.h"
  22. #include "../../common/seperator.h"
  23. #include "../../common/servertalk.h"
  24. #include "../WorldDatabase.h"
  25. #include "../World.h"
  26. #include "../../common/ConfigReader.h"
  27. #include "../VisualStates.h"
  28. #include "../../common/debug.h"
  29. #include "../LuaInterface.h"
  30. #include "../Quests.h"
  31. #include "../client.h"
  32. #include "../NPC.h"
  33. #include "../Guilds/Guild.h"
  34. #include "../SpellProcess.h"
  35. #include "../Tradeskills/Tradeskills.h"
  36. #include "../../common/Log.h"
  37. #include "../../common/MiscFunctions.h"
  38. #include "../Languages.h"
  39. #include "../Traits/Traits.h"
  40. #include "../Chat/Chat.h"
  41. #include "../Rules/Rules.h"
  42. #include "../AltAdvancement/AltAdvancement.h"
  43. #include "../RaceTypes/RaceTypes.h"
  44. #include "../classes.h"
  45. #include "../Transmute.h"
  46. #include "../Bots/Bot.h"
  47. #include "../Web/PeerManager.h"
  48. extern WorldDatabase database;
  49. extern MasterSpellList master_spell_list;
  50. extern MasterTraitList master_trait_list;
  51. extern MasterRecipeList master_recipe_list;
  52. extern MasterRecipeBookList master_recipebook_list;
  53. extern World world;
  54. extern ClientList client_list;
  55. extern ConfigReader configReader;
  56. extern VisualStates visual_states;
  57. extern ZoneList zone_list;
  58. extern LuaInterface* lua_interface;
  59. extern MasterQuestList master_quest_list;
  60. extern MasterCollectionList master_collection_list;
  61. extern MasterSkillList master_skill_list;
  62. extern MasterFactionList master_faction_list;
  63. extern GuildList guild_list;
  64. extern MasterLanguagesList master_languages_list;
  65. extern Chat chat;
  66. extern RuleManager rule_manager;
  67. extern MasterAAList master_aa_list;
  68. extern MasterRaceTypeList race_types_list;
  69. extern Classes classes;
  70. extern PeerManager peer_manager;
  71. //devn00b: Fix for linux builds since we dont use stricmp we use strcasecmp
  72. #if defined(__GNUC__)
  73. #define stricmp strcasecmp
  74. #define strnicmp strncasecmp
  75. #endif
  76. EQ2Packet* RemoteCommands::serialize(int16 version){
  77. buffer.clear();
  78. vector<EQ2_RemoteCommandString>::iterator command_list;
  79. buffer.append((char*)&num_commands, sizeof(int16));
  80. for( command_list = commands.begin(); command_list != commands.end(); command_list++ ) {
  81. AddDataCommand(&(*command_list));
  82. }
  83. EQ2Packet* app = new EQ2Packet(OP_SetRemoteCmdsMsg, (uchar*)buffer.c_str(), buffer.length() + 1);
  84. return app;
  85. }
  86. Commands::Commands(){
  87. remote_commands = new RemoteCommands();
  88. spawn_set_values["list"] = SPAWN_SET_VALUE_LIST;
  89. spawn_set_values["name"] = SPAWN_SET_VALUE_NAME;
  90. spawn_set_values["level"] = SPAWN_SET_VALUE_LEVEL; // TODO: Fix this, min_level, max_level
  91. spawn_set_values["difficulty"] = SPAWN_SET_VALUE_DIFFICULTY;
  92. spawn_set_values["model_type"] = SPAWN_SET_VALUE_MODEL_TYPE;
  93. spawn_set_values["class"] = SPAWN_SET_VALUE_CLASS;
  94. spawn_set_values["gender"] = SPAWN_SET_VALUE_GENDER;
  95. spawn_set_values["show_name"] = SPAWN_SET_VALUE_SHOW_NAME;
  96. spawn_set_values["attackable"] = SPAWN_SET_VALUE_ATTACKABLE;
  97. spawn_set_values["show_level"] = SPAWN_SET_VALUE_SHOW_LEVEL;
  98. spawn_set_values["targetable"] = SPAWN_SET_VALUE_TARGETABLE;
  99. spawn_set_values["show_command_icon"] = SPAWN_SET_VALUE_SHOW_COMMAND_ICON;
  100. spawn_set_values["display_hand_icon"] = SPAWN_SET_VALUE_HAND_ICON;
  101. spawn_set_values["hair_type"] = SPAWN_SET_VALUE_HAIR_TYPE;
  102. spawn_set_values["facial_hair_type"] = SPAWN_SET_VALUE_FACIAL_HAIR_TYPE;
  103. spawn_set_values["wing_type"] = SPAWN_SET_VALUE_WING_TYPE;
  104. spawn_set_values["chest_type"] = SPAWN_SET_VALUE_CHEST_TYPE;
  105. spawn_set_values["legs_type"] = SPAWN_SET_VALUE_LEGS_TYPE;
  106. spawn_set_values["soga_hair_type"] = SPAWN_SET_VALUE_SOGA_HAIR_TYPE;
  107. spawn_set_values["soga_facial_hair_type"] = SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE;
  108. spawn_set_values["soga_model_type"] = SPAWN_SET_VALUE_SOGA_MODEL_TYPE;
  109. spawn_set_values["size"] = SPAWN_SET_VALUE_SIZE;
  110. spawn_set_values["hp"] = SPAWN_SET_VALUE_HP;
  111. spawn_set_values["power"] = SPAWN_SET_VALUE_POWER;
  112. spawn_set_values["heroic"] = SPAWN_SET_VALUE_HEROIC;
  113. spawn_set_values["respawn"] = SPAWN_SET_VALUE_RESPAWN;
  114. spawn_set_values["x"] = SPAWN_SET_VALUE_X;
  115. spawn_set_values["y"] = SPAWN_SET_VALUE_Y;
  116. spawn_set_values["z"] = SPAWN_SET_VALUE_Z;
  117. spawn_set_values["heading"] = SPAWN_SET_VALUE_HEADING;
  118. spawn_set_values["location"] = SPAWN_SET_VALUE_LOCATION;
  119. spawn_set_values["command_primary"] = SPAWN_SET_VALUE_COMMAND_PRIMARY;
  120. spawn_set_values["command_secondary"] = SPAWN_SET_VALUE_COMMAND_SECONDARY;
  121. spawn_set_values["visual_state"] = SPAWN_SET_VALUE_VISUAL_STATE;
  122. spawn_set_values["action_state"] = SPAWN_SET_VALUE_ACTION_STATE;
  123. spawn_set_values["mood_state"] = SPAWN_SET_VALUE_MOOD_STATE;
  124. spawn_set_values["initial_state"] = SPAWN_SET_VALUE_INITIAL_STATE;
  125. spawn_set_values["activity_state"] = SPAWN_SET_VALUE_ACTIVITY_STATE;
  126. spawn_set_values["collision_radius"] = SPAWN_SET_VALUE_COLLISION_RADIUS;
  127. spawn_set_values["faction"] = SPAWN_SET_VALUE_FACTION;
  128. spawn_set_values["spawn_script"] = SPAWN_SET_VALUE_SPAWN_SCRIPT;
  129. spawn_set_values["spawnentry_script"] = SPAWN_SET_VALUE_SPAWNENTRY_SCRIPT;
  130. spawn_set_values["spawnlocation_script"] = SPAWN_SET_VALUE_SPAWNLOCATION_SCRIPT;
  131. spawn_set_values["sub_title"] = SPAWN_SET_VALUE_SUB_TITLE;
  132. spawn_set_values["expire"] = SPAWN_SET_VALUE_EXPIRE;
  133. spawn_set_values["expire_offset"] = SPAWN_SET_VALUE_EXPIRE_OFFSET;
  134. spawn_set_values["x_offset"] = SPAWN_SET_VALUE_X_OFFSET;
  135. spawn_set_values["y_offset"] = SPAWN_SET_VALUE_Y_OFFSET;
  136. spawn_set_values["z_offset"] = SPAWN_SET_VALUE_Z_OFFSET;
  137. spawn_set_values["device_id"] = SPAWN_SET_VALUE_DEVICE_ID;
  138. spawn_set_values["pitch"] = SPAWN_SET_VALUE_PITCH;
  139. spawn_set_values["roll"] = SPAWN_SET_VALUE_ROLL;
  140. spawn_set_values["hide_hood"] = SPAWN_SET_VALUE_HIDE_HOOD;
  141. spawn_set_values["emote_state"] = SPAWN_SET_VALUE_EMOTE_STATE;
  142. spawn_set_values["icon"] = SPAWN_SET_VALUE_ICON;
  143. spawn_set_values["prefix"] = SPAWN_SET_VALUE_PREFIX;
  144. spawn_set_values["suffix"] = SPAWN_SET_VALUE_SUFFIX;
  145. spawn_set_values["lastname"] = SPAWN_SET_VALUE_LASTNAME;
  146. spawn_set_values["expansion_flag"] = SPAWN_SET_VALUE_EXPANSION_FLAG;
  147. spawn_set_values["holiday_flag"] = SPAWN_SET_VALUE_HOLIDAY_FLAG;
  148. spawn_set_values["merchant_min_level"] = SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL;
  149. spawn_set_values["merchant_max_level"] = SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL;
  150. spawn_set_values["skin_color"] = SPAWN_SET_SKIN_COLOR;
  151. spawn_set_values["aaxp_rewards"] = SPAWN_SET_AAXP_REWARDS;
  152. spawn_set_values["hair_color1"] = SPAWN_SET_HAIR_COLOR1;
  153. spawn_set_values["hair_color2"] = SPAWN_SET_HAIR_COLOR2;
  154. spawn_set_values["hair_type_color"] = SPAWN_SET_HAIR_TYPE_COLOR;
  155. spawn_set_values["hair_face_color"] = SPAWN_SET_HAIR_FACE_COLOR;
  156. spawn_set_values["hair_type_highlight_color"] = SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR;
  157. spawn_set_values["face_hairlight_color"] = SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR;
  158. spawn_set_values["hair_highlight"] = SPAWN_SET_HAIR_HIGHLIGHT;
  159. spawn_set_values["model_color"] = SPAWN_SET_MODEL_COLOR;
  160. spawn_set_values["eye_color"] = SPAWN_SET_EYE_COLOR;
  161. spawn_set_values["soga_skin_color"] = SPAWN_SET_SOGA_SKIN_COLOR;
  162. spawn_set_values["soga_hair_color1"] = SPAWN_SET_SOGA_HAIR_COLOR1;
  163. spawn_set_values["soga_hair_color2"] = SPAWN_SET_SOGA_HAIR_COLOR2;
  164. spawn_set_values["soga_hair_type_color"] = SPAWN_SET_SOGA_HAIR_TYPE_COLOR;
  165. spawn_set_values["soga_hair_face_color"] = SPAWN_SET_SOGA_HAIR_FACE_COLOR;
  166. spawn_set_values["soga_hair_type_highlight_color"] = SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR;
  167. spawn_set_values["soga_face_hairlight_color"] = SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR;
  168. spawn_set_values["soga_hair_highlight"] = SPAWN_SET_SOGA_HAIR_HIGHLIGHT;
  169. spawn_set_values["soga_model_color"] = SPAWN_SET_SOGA_MODEL_COLOR;
  170. spawn_set_values["soga_eye_color"] = SPAWN_SET_SOGA_EYE_COLOR;
  171. spawn_set_values["cheek_type"] = SPAWN_SET_CHEEK_TYPE;
  172. spawn_set_values["chin_type"] = SPAWN_SET_CHIN_TYPE;
  173. spawn_set_values["ear_type"] = SPAWN_SET_EAR_TYPE;
  174. spawn_set_values["eye_brow_type"] = SPAWN_SET_EYE_BROW_TYPE;
  175. spawn_set_values["eye_type"] = SPAWN_SET_EYE_TYPE;
  176. spawn_set_values["lip_type"] = SPAWN_SET_LIP_TYPE;
  177. spawn_set_values["nose_type"] = SPAWN_SET_NOSE_TYPE;
  178. spawn_set_values["body_size"] = SPAWN_SET_BODY_SIZE;
  179. spawn_set_values["body_age"] = SPAWN_SET_BODY_AGE;
  180. spawn_set_values["soga_cheek_type"] = SPAWN_SET_SOGA_CHEEK_TYPE;
  181. spawn_set_values["soga_chin_type"] = SPAWN_SET_SOGA_CHIN_TYPE;
  182. spawn_set_values["soga_ear_type"] = SPAWN_SET_SOGA_EAR_TYPE;
  183. spawn_set_values["soga_eye_brow_type"] = SPAWN_SET_SOGA_EYE_BROW_TYPE;
  184. spawn_set_values["soga_eye_type"] = SPAWN_SET_SOGA_EYE_TYPE;
  185. spawn_set_values["soga_lip_type"] = SPAWN_SET_SOGA_LIP_TYPE;
  186. spawn_set_values["soga_nose_type"] = SPAWN_SET_SOGA_NOSE_TYPE;
  187. spawn_set_values["soga_body_size"] = SPAWN_SET_SOGA_BODY_SIZE;
  188. spawn_set_values["soga_body_age"] = SPAWN_SET_SOGA_BODY_AGE;
  189. spawn_set_values["attack_type"] = SPAWN_SET_ATTACK_TYPE;
  190. spawn_set_values["race_type"] = SPAWN_SET_RACE_TYPE;
  191. spawn_set_values["loot_tier"] = SPAWN_SET_LOOT_TIER;
  192. spawn_set_values["loot_drop_type"] = SPAWN_SET_LOOT_DROP_TYPE;
  193. spawn_set_values["scared_strong_players"] = SPAWN_SET_SCARED_STRONG_PLAYERS;
  194. zone_set_values["expansion_id"] = ZONE_SET_VALUE_EXPANSION_ID;
  195. zone_set_values["name"] = ZONE_SET_VALUE_NAME;
  196. zone_set_values["file"] = ZONE_SET_VALUE_FILE ;
  197. zone_set_values["description"] = ZONE_SET_VALUE_DESCRIPTION;
  198. zone_set_values["safe_x"] = ZONE_SET_VALUE_SAFE_X;
  199. zone_set_values["safe_y"] = ZONE_SET_VALUE_SAFE_Y;
  200. zone_set_values["safe_z"] = ZONE_SET_VALUE_SAFE_Z;
  201. zone_set_values["underworld"] = ZONE_SET_VALUE_UNDERWORLD;
  202. zone_set_values["min_recommended"] = ZONE_SET_VALUE_MIN_RECOMMENDED;
  203. zone_set_values["max_recommended"] = ZONE_SET_VALUE_MAX_RECOMMENDED;
  204. zone_set_values["zone_type"] = ZONE_SET_VALUE_ZONE_TYPE;
  205. zone_set_values["always_loaded"] = ZONE_SET_VALUE_ALWAYS_LOADED;
  206. zone_set_values["city_zone"] = ZONE_SET_VALUE_CITY_ZONE;
  207. zone_set_values["weather_allowed"] = ZONE_SET_VALUE_WEATHER_ALLOWED;
  208. zone_set_values["min_status"] = ZONE_SET_VALUE_MIN_STATUS;
  209. zone_set_values["min_level"] = ZONE_SET_VALUE_MIN_LEVEL;
  210. zone_set_values["start_zone"] = ZONE_SET_VALUE_START_ZONE;
  211. zone_set_values["instance_type"] = ZONE_SET_VALUE_INSTANCE_TYPE;
  212. zone_set_values["default_reenter_time"] = ZONE_SET_VALUE_DEFAULT_REENTER_TIME;
  213. zone_set_values["default_reset_time"] = ZONE_SET_VALUE_DEFAULT_RESET_TIME;
  214. zone_set_values["default_lockout_time"] = ZONE_SET_VALUE_DEFAULT_LOCKOUT_TIME;
  215. zone_set_values["force_group_to_zone"] = ZONE_SET_VALUE_FORCE_GROUP_TO_ZONE;
  216. zone_set_values["lua_script"] = ZONE_SET_VALUE_LUA_SCRIPT;
  217. zone_set_values["shutdown_timer"] = ZONE_SET_VALUE_SHUTDOWN_TIMER;
  218. zone_set_values["zone_motd"] = ZONE_SET_VALUE_ZONE_MOTD;
  219. }
  220. Commands::~Commands() {
  221. safe_delete(remote_commands);
  222. }
  223. int32 Commands::GetSpawnSetType(string val){
  224. if(spawn_set_values.count(val) > 0)
  225. return spawn_set_values[val];
  226. return 0xFFFFFFFF;
  227. }
  228. bool Commands::SetSpawnCommand(Client* client, Spawn* target, int8 type, const char* value, bool send_update, bool temporary, string* temp_value, int8 index){
  229. if(!target)
  230. return false;
  231. int32 val = 0;
  232. try{
  233. if(type != SPAWN_SET_VALUE_NAME &&
  234. !(type >= SPAWN_SET_VALUE_SPAWN_SCRIPT && type <= SPAWN_SET_VALUE_SUB_TITLE) && !(type >= SPAWN_SET_VALUE_PREFIX && type <= SPAWN_SET_VALUE_EXPANSION_FLAG || type == SPAWN_SET_VALUE_HOLIDAY_FLAG))
  235. {
  236. switch(type)
  237. {
  238. case SPAWN_SET_SKIN_COLOR:
  239. case SPAWN_SET_HAIR_COLOR1:
  240. case SPAWN_SET_HAIR_COLOR2:
  241. case SPAWN_SET_HAIR_TYPE_COLOR:
  242. case SPAWN_SET_HAIR_FACE_COLOR:
  243. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  244. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  245. case SPAWN_SET_HAIR_HIGHLIGHT:
  246. case SPAWN_SET_EYE_COLOR:
  247. case SPAWN_SET_SOGA_SKIN_COLOR:
  248. case SPAWN_SET_SOGA_HAIR_COLOR1:
  249. case SPAWN_SET_SOGA_HAIR_COLOR2:
  250. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  251. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  252. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  253. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  254. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  255. case SPAWN_SET_SOGA_EYE_COLOR:
  256. case SPAWN_SET_RACE_TYPE:
  257. // ignore these are colors can't pass as a integer value
  258. break;
  259. default:
  260. val = atoul(value);
  261. }
  262. }
  263. }
  264. catch(...){
  265. if(client)
  266. client->Message(CHANNEL_COLOR_RED, "Invalid numeric spawn value: %s", value);
  267. return false;
  268. }
  269. if(temporary){
  270. char tmp[128] = {0};
  271. switch(type){
  272. case SPAWN_SET_VALUE_NAME:{
  273. sprintf(tmp, "%s", target->GetName());
  274. target->SetName(value);
  275. if(target->GetZone())
  276. target->GetZone()->SendUpdateTitles(target);
  277. break;
  278. }
  279. case SPAWN_SET_VALUE_X_OFFSET:
  280. {
  281. sprintf(tmp, "%f", target->GetXOffset());
  282. target->SetXOffset(float(val));
  283. break;
  284. }
  285. case SPAWN_SET_VALUE_Y_OFFSET:
  286. {
  287. sprintf(tmp, "%f", target->GetYOffset());
  288. target->SetYOffset(float(val));
  289. break;
  290. }
  291. case SPAWN_SET_VALUE_Z_OFFSET:
  292. {
  293. sprintf(tmp, "%f", target->GetZOffset());
  294. target->SetZOffset(float(val));
  295. break;
  296. }
  297. case SPAWN_SET_VALUE_EXPIRE: {
  298. sprintf(tmp, "%u", target->GetExpireTime());
  299. target->SetExpireTime(val);
  300. break;
  301. }
  302. case SPAWN_SET_VALUE_EXPIRE_OFFSET: {
  303. sprintf(tmp, "%u", target->GetExpireOffsetTime());
  304. target->SetExpireOffsetTime(val);
  305. break;
  306. }
  307. case SPAWN_SET_VALUE_SUB_TITLE: {
  308. sprintf(tmp, "%s", target->GetSubTitle());
  309. target->SetSubTitle(value);
  310. if(target->GetZone())
  311. target->GetZone()->SendUpdateTitles(target);
  312. break;
  313. }
  314. case SPAWN_SET_VALUE_LEVEL:{
  315. sprintf(tmp, "%i", target->GetLevel());
  316. target->SetLevel(val, send_update);
  317. break;
  318. }
  319. case SPAWN_SET_VALUE_DIFFICULTY:{
  320. sprintf(tmp, "%i", target->GetDifficulty());
  321. target->SetDifficulty(val, send_update);
  322. break;
  323. }
  324. case SPAWN_SET_VALUE_MODEL_TYPE:{
  325. sprintf(tmp, "%i", target->GetModelType());
  326. target->SetModelType(val, send_update);
  327. break;
  328. }
  329. case SPAWN_SET_VALUE_CLASS:{
  330. sprintf(tmp, "%i", target->GetAdventureClass());
  331. target->SetAdventureClass(val, send_update);
  332. break;
  333. }
  334. case SPAWN_SET_VALUE_GENDER:{
  335. sprintf(tmp, "%i", target->GetGender());
  336. target->SetGender(val, send_update);
  337. break;
  338. }
  339. case SPAWN_SET_VALUE_SHOW_NAME:{
  340. sprintf(tmp, "%i", target->GetShowName());
  341. target->SetShowName(val, send_update);
  342. break;
  343. }
  344. case SPAWN_SET_VALUE_ATTACKABLE:{
  345. sprintf(tmp, "%i", target->GetAttackable());
  346. target->SetAttackable(val, send_update);
  347. break;
  348. }
  349. case SPAWN_SET_VALUE_SHOW_LEVEL:{
  350. sprintf(tmp, "%i", target->GetShowLevel());
  351. target->SetShowLevel(val, send_update);
  352. break;
  353. }
  354. case SPAWN_SET_VALUE_TARGETABLE:{
  355. sprintf(tmp, "%i", target->GetTargetable());
  356. target->SetTargetable(val, send_update);
  357. break;
  358. }
  359. case SPAWN_SET_VALUE_SHOW_COMMAND_ICON:{
  360. sprintf(tmp, "%i", target->GetShowCommandIcon());
  361. target->SetShowCommandIcon(val, send_update);
  362. break;
  363. }
  364. case SPAWN_SET_VALUE_HAND_ICON:{
  365. sprintf(tmp, "%i", target->GetShowHandIcon());
  366. target->SetShowHandIcon(val, send_update);
  367. break;
  368. }
  369. case SPAWN_SET_VALUE_HAIR_TYPE:{
  370. if(target->IsEntity()){
  371. sprintf(tmp, "%i", ((Entity*)target)->GetHairType());
  372. ((Entity*)target)->SetHairType(val, send_update);
  373. }
  374. break;
  375. }
  376. case SPAWN_SET_VALUE_FACIAL_HAIR_TYPE:{
  377. if(target->IsEntity()){
  378. sprintf(tmp, "%i", ((Entity*)target)->GetFacialHairType());
  379. ((Entity*)target)->SetFacialHairType(val, send_update);
  380. }
  381. break;
  382. }
  383. case SPAWN_SET_VALUE_WING_TYPE:{
  384. if(target->IsEntity()){
  385. sprintf(tmp, "%i", ((Entity*)target)->GetWingType());
  386. ((Entity*)target)->SetWingType(val, send_update);
  387. }
  388. break;
  389. }
  390. case SPAWN_SET_VALUE_CHEST_TYPE:{
  391. if(target->IsEntity()){
  392. sprintf(tmp, "%i", ((Entity*)target)->GetChestType());
  393. ((Entity*)target)->SetChestType(val, send_update);
  394. }
  395. break;
  396. }
  397. case SPAWN_SET_VALUE_LEGS_TYPE:{
  398. if(target->IsEntity()){
  399. sprintf(tmp, "%i", ((Entity*)target)->GetLegsType());
  400. ((Entity*)target)->SetLegsType(val, send_update);
  401. }
  402. break;
  403. }
  404. case SPAWN_SET_VALUE_SOGA_HAIR_TYPE:{
  405. if(target->IsEntity()){
  406. sprintf(tmp, "%i", ((Entity*)target)->GetSogaHairType());
  407. ((Entity*)target)->SetSogaHairType(val, send_update);
  408. }
  409. break;
  410. }
  411. case SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE:{
  412. if(target->IsEntity()){
  413. sprintf(tmp, "%i", ((Entity*)target)->GetSogaFacialHairType());
  414. ((Entity*)target)->SetSogaFacialHairType(val, send_update);
  415. }
  416. break;
  417. }
  418. case SPAWN_SET_VALUE_SOGA_MODEL_TYPE:{
  419. sprintf(tmp, "%i", target->GetSogaModelType());
  420. target->SetSogaModelType(val, send_update);
  421. break;
  422. }
  423. case SPAWN_SET_VALUE_SIZE:{
  424. sprintf(tmp, "%i", target->GetSize());
  425. target->SetSize(val, send_update);
  426. break;
  427. }
  428. case SPAWN_SET_VALUE_HP:{
  429. sprintf(tmp, "%i", target->GetHP());
  430. target->SetTotalHPBase(val);
  431. target->SetHP(val, send_update);
  432. break;
  433. }
  434. case SPAWN_SET_VALUE_POWER:{
  435. sprintf(tmp, "%i", target->GetPower());
  436. target->SetTotalPowerBase(val);
  437. target->SetPower(val, send_update);
  438. break;
  439. }
  440. case SPAWN_SET_VALUE_HEROIC:{
  441. sprintf(tmp, "%i", target->GetHeroic());
  442. target->SetHeroic(val, send_update);
  443. break;
  444. }
  445. case SPAWN_SET_VALUE_RESPAWN:{
  446. sprintf(tmp, "%u", target->GetRespawnTime());
  447. target->SetRespawnTime(val);
  448. break;
  449. }
  450. case SPAWN_SET_VALUE_X:{
  451. sprintf(tmp, "%f", target->GetX());
  452. target->SetX(atof(value), send_update);
  453. break;
  454. }
  455. case SPAWN_SET_VALUE_Y:{
  456. sprintf(tmp, "%f", target->GetY());
  457. target->SetY(atof(value), send_update);
  458. break;
  459. }
  460. case SPAWN_SET_VALUE_Z:{
  461. sprintf(tmp, "%f", target->GetZ());
  462. target->SetZ(atof(value), send_update);
  463. break;
  464. }
  465. case SPAWN_SET_VALUE_HEADING:{
  466. sprintf(tmp, "%f", target->GetHeading());
  467. target->SetHeading(atof(value) + 360, send_update);
  468. break;
  469. }
  470. case SPAWN_SET_VALUE_VISUAL_STATE:{
  471. sprintf(tmp, "%i", target->GetVisualState());
  472. target->SetVisualState(val, send_update);
  473. break;
  474. }
  475. case SPAWN_SET_VALUE_ACTION_STATE:{
  476. sprintf(tmp, "%i", target->GetActionState());
  477. target->SetActionState(val, send_update);
  478. break;
  479. }
  480. case SPAWN_SET_VALUE_MOOD_STATE:{
  481. sprintf(tmp, "%i", target->GetMoodState());
  482. target->SetMoodState(val, send_update);
  483. break;
  484. }
  485. case SPAWN_SET_VALUE_INITIAL_STATE:{
  486. sprintf(tmp, "%i", target->GetInitialState());
  487. target->SetInitialState(val, send_update);
  488. break;
  489. }
  490. case SPAWN_SET_VALUE_ACTIVITY_STATE:{
  491. sprintf(tmp, "%i", target->GetActivityStatus());
  492. target->SetActivityStatus(val, send_update);
  493. break;
  494. }
  495. case SPAWN_SET_VALUE_COLLISION_RADIUS:{
  496. sprintf(tmp, "%i", target->GetCollisionRadius());
  497. target->SetCollisionRadius(val, send_update);
  498. break;
  499. }
  500. case SPAWN_SET_VALUE_DEVICE_ID: {
  501. if (target->IsObject()) {
  502. sprintf(tmp, "%i", ((Object*)target)->GetDeviceID());
  503. ((Object*)target)->SetDeviceID(val);
  504. }
  505. break;
  506. }
  507. case SPAWN_SET_VALUE_PITCH: {
  508. sprintf(tmp, "%f", target->GetPitch());
  509. target->SetPitch(atof(value), send_update);
  510. break;
  511. }
  512. case SPAWN_SET_VALUE_ROLL: {
  513. sprintf(tmp, "%f", target->GetRoll());
  514. target->SetRoll(atof(value), send_update);
  515. break;
  516. }
  517. case SPAWN_SET_VALUE_HIDE_HOOD: {
  518. sprintf(tmp, "%i", target->appearance.hide_hood);
  519. target->SetHideHood(val);
  520. break;
  521. }
  522. case SPAWN_SET_VALUE_EMOTE_STATE: {
  523. sprintf(tmp, "%i", target->appearance.emote_state);
  524. target->SetEmoteState(val);
  525. break;
  526. }
  527. case SPAWN_SET_VALUE_ICON: {
  528. sprintf(tmp, "%i", target->GetIconValue());
  529. target->SetIcon(val);
  530. break;
  531. }
  532. case SPAWN_SET_VALUE_PREFIX: {
  533. sprintf(tmp, "%s", target->GetPrefixTitle());
  534. target->SetPrefixTitle(value);
  535. if(target->GetZone())
  536. target->GetZone()->SendUpdateTitles(target);
  537. break;
  538. }
  539. case SPAWN_SET_VALUE_SUFFIX: {
  540. sprintf(tmp, "%s", target->GetSuffixTitle());
  541. target->SetSuffixTitle(value);
  542. if(target->GetZone())
  543. target->GetZone()->SendUpdateTitles(target);
  544. break;
  545. }
  546. case SPAWN_SET_VALUE_LASTNAME: {
  547. sprintf(tmp, "%s", target->GetLastName());
  548. target->SetLastName(value);
  549. if(target->GetZone())
  550. target->GetZone()->SendUpdateTitles(target);
  551. break;
  552. }
  553. case SPAWN_SET_VALUE_EXPANSION_FLAG:
  554. case SPAWN_SET_VALUE_HOLIDAY_FLAG: {
  555. // nothing to do must reload spawns
  556. break;
  557. }
  558. case SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL: {
  559. sprintf(tmp, "%i", target->GetMerchantMinLevel());
  560. target->SetMerchantLevelRange(atoul(value), target->GetMerchantMaxLevel());
  561. break;
  562. }
  563. case SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL: {
  564. sprintf(tmp, "%i", target->GetMerchantMaxLevel());
  565. target->SetMerchantLevelRange(target->GetMerchantMinLevel(), atoul(value));
  566. break;
  567. }
  568. case SPAWN_SET_VALUE_FACTION:{
  569. sprintf(tmp, "%i", target->faction_id);
  570. ZoneServer* zone = target->GetZone();
  571. if (!zone && client)
  572. zone = client->GetCurrentZone();
  573. target->faction_id = atoul(value);
  574. if(zone)
  575. {
  576. zone->RemoveDeadEnemyList(target);
  577. if(target->IsNPC())
  578. zone->AddEnemyList((NPC*)target);
  579. }
  580. break;
  581. }
  582. case SPAWN_SET_SKIN_COLOR:
  583. case SPAWN_SET_HAIR_COLOR1:
  584. case SPAWN_SET_HAIR_COLOR2:
  585. case SPAWN_SET_HAIR_TYPE_COLOR:
  586. case SPAWN_SET_HAIR_FACE_COLOR:
  587. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  588. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  589. case SPAWN_SET_HAIR_HIGHLIGHT:
  590. case SPAWN_SET_MODEL_COLOR:
  591. case SPAWN_SET_EYE_COLOR:
  592. case SPAWN_SET_SOGA_SKIN_COLOR:
  593. case SPAWN_SET_SOGA_HAIR_COLOR1:
  594. case SPAWN_SET_SOGA_HAIR_COLOR2:
  595. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  596. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  597. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  598. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  599. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  600. case SPAWN_SET_SOGA_MODEL_COLOR:
  601. case SPAWN_SET_SOGA_EYE_COLOR:
  602. {
  603. if (target->IsEntity())
  604. {
  605. Seperator* skinsep = new Seperator(value, ' ', 3, 500, true);
  606. if (skinsep->IsNumber(0) && skinsep->IsNumber(1) && skinsep->IsNumber(2))
  607. {
  608. EQ2_Color clr;
  609. clr.red = atoul(skinsep->arg[0]);
  610. clr.green = atoul(skinsep->arg[1]);
  611. clr.blue = atoul(skinsep->arg[2]);
  612. switch(type)
  613. {
  614. case SPAWN_SET_SKIN_COLOR:
  615. ((Entity*)target)->SetSkinColor(clr);
  616. break;
  617. case SPAWN_SET_HAIR_COLOR1:
  618. ((Entity*)target)->SetHairColor1(clr);
  619. break;
  620. case SPAWN_SET_HAIR_COLOR2:
  621. ((Entity*)target)->SetHairColor2(clr);
  622. break;
  623. case SPAWN_SET_HAIR_TYPE_COLOR:
  624. ((Entity*)target)->SetHairColor(clr);
  625. break;
  626. case SPAWN_SET_HAIR_FACE_COLOR:
  627. ((Entity*)target)->SetFacialHairColor(clr);
  628. break;
  629. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  630. ((Entity*)target)->SetHairTypeHighlightColor(clr);
  631. break;
  632. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  633. ((Entity*)target)->SetFacialHairHighlightColor(clr);
  634. break;
  635. case SPAWN_SET_HAIR_HIGHLIGHT:
  636. ((Entity*)target)->SetHairHighlightColor(clr);
  637. break;
  638. case SPAWN_SET_MODEL_COLOR:
  639. ((Entity*)target)->SetModelColor(clr);
  640. break;
  641. case SPAWN_SET_EYE_COLOR:
  642. ((Entity*)target)->SetEyeColor(clr);
  643. break;
  644. case SPAWN_SET_SOGA_SKIN_COLOR:
  645. ((Entity*)target)->SetSogaSkinColor(clr);
  646. break;
  647. case SPAWN_SET_SOGA_HAIR_COLOR1:
  648. ((Entity*)target)->SetSogaHairColor1(clr);
  649. break;
  650. case SPAWN_SET_SOGA_HAIR_COLOR2:
  651. ((Entity*)target)->SetSogaHairColor2(clr);
  652. break;
  653. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  654. ((Entity*)target)->SetSogaHairColor(clr);
  655. break;
  656. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  657. ((Entity*)target)->SetSogaFacialHairColor(clr);
  658. break;
  659. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  660. ((Entity*)target)->SetSogaHairTypeHighlightColor(clr);
  661. break;
  662. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  663. ((Entity*)target)->SetSogaFacialHairHighlightColor(clr);
  664. break;
  665. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  666. ((Entity*)target)->SetSogaHairHighlightColor(clr);
  667. break;
  668. case SPAWN_SET_SOGA_MODEL_COLOR:
  669. ((Entity*)target)->SetSogaModelColor(clr);
  670. break;
  671. case SPAWN_SET_SOGA_EYE_COLOR:
  672. ((Entity*)target)->SetSogaEyeColor(clr);
  673. break;
  674. }
  675. }
  676. safe_delete(skinsep);
  677. }
  678. break;
  679. }
  680. case SPAWN_SET_AAXP_REWARDS: {
  681. target->SetAAXPRewards(atoul(value));
  682. break;
  683. }
  684. case SPAWN_SET_CHEEK_TYPE:{
  685. if(target->IsEntity() && index < 3){
  686. sprintf(tmp, "%i", ((Entity*)target)->features.cheek_type[index]);
  687. sint8 new_value = atoi(value);
  688. ((Entity*)target)->features.cheek_type[index] = new_value;
  689. ((Entity*)target)->info_changed = true;
  690. }
  691. break;
  692. }
  693. case SPAWN_SET_CHIN_TYPE:{
  694. if(target->IsEntity() && index < 3){
  695. sprintf(tmp, "%i", ((Entity*)target)->features.chin_type[index]);
  696. sint8 new_value = atoi(value);
  697. ((Entity*)target)->features.chin_type[index] = new_value;
  698. ((Entity*)target)->info_changed = true;
  699. }
  700. break;
  701. }
  702. case SPAWN_SET_EAR_TYPE:{
  703. if(target->IsEntity() && index < 3){
  704. sprintf(tmp, "%i", ((Entity*)target)->features.ear_type[index]);
  705. sint8 new_value = atoi(value);
  706. ((Entity*)target)->features.ear_type[index] = new_value;
  707. ((Entity*)target)->info_changed = true;
  708. }
  709. break;
  710. }
  711. case SPAWN_SET_EYE_BROW_TYPE:{
  712. if(target->IsEntity() && index < 3){
  713. sprintf(tmp, "%i", ((Entity*)target)->features.eye_brow_type[index]);
  714. sint8 new_value = atoi(value);
  715. ((Entity*)target)->features.eye_brow_type[index] = new_value;
  716. ((Entity*)target)->info_changed = true;
  717. }
  718. break;
  719. }
  720. case SPAWN_SET_EYE_TYPE:{
  721. if(target->IsEntity() && index < 3){
  722. sprintf(tmp, "%i", ((Entity*)target)->features.eye_type[index]);
  723. sint8 new_value = atoi(value);
  724. ((Entity*)target)->features.eye_type[index] = new_value;
  725. ((Entity*)target)->info_changed = true;
  726. }
  727. break;
  728. }
  729. case SPAWN_SET_LIP_TYPE:{
  730. if(target->IsEntity() && index < 3){
  731. sprintf(tmp, "%i", ((Entity*)target)->features.lip_type[index]);
  732. sint8 new_value = atoi(value);
  733. ((Entity*)target)->features.lip_type[index] = new_value;
  734. ((Entity*)target)->info_changed = true;
  735. }
  736. break;
  737. }
  738. case SPAWN_SET_NOSE_TYPE:{
  739. if(target->IsEntity() && index < 3){
  740. sprintf(tmp, "%i", ((Entity*)target)->features.nose_type[index]);
  741. sint8 new_value = atoi(value);
  742. ((Entity*)target)->features.nose_type[index] = new_value;
  743. ((Entity*)target)->info_changed = true;
  744. }
  745. break;
  746. }
  747. case SPAWN_SET_BODY_SIZE:{
  748. if(target->IsEntity()){
  749. sprintf(tmp, "%i", ((Entity*)target)->features.body_size);
  750. int8 new_value = atoul(value);
  751. ((Entity*)target)->features.body_size = new_value;
  752. ((Entity*)target)->info_changed = true;
  753. }
  754. break;
  755. }
  756. case SPAWN_SET_BODY_AGE:{
  757. if(target->IsEntity()){
  758. sprintf(tmp, "%i", ((Entity*)target)->features.body_age);
  759. int8 new_value = atoul(value);
  760. ((Entity*)target)->features.body_age = new_value;
  761. ((Entity*)target)->info_changed = true;
  762. }
  763. break;
  764. }
  765. case SPAWN_SET_SOGA_CHEEK_TYPE:{
  766. if(target->IsEntity() && index < 3){
  767. sprintf(tmp, "%i", ((Entity*)target)->features.soga_cheek_type[index]);
  768. sint8 new_value = atoi(value);
  769. ((Entity*)target)->features.soga_cheek_type[index] = new_value;
  770. ((Entity*)target)->info_changed = true;
  771. }
  772. break;
  773. }
  774. case SPAWN_SET_SOGA_CHIN_TYPE:{
  775. if(target->IsEntity() && index < 3){
  776. sprintf(tmp, "%i", ((Entity*)target)->features.soga_chin_type[index]);
  777. sint8 new_value = atoi(value);
  778. ((Entity*)target)->features.soga_chin_type[index] = new_value;
  779. ((Entity*)target)->info_changed = true;
  780. }
  781. break;
  782. }
  783. case SPAWN_SET_SOGA_EAR_TYPE:{
  784. if(target->IsEntity() && index < 3){
  785. sprintf(tmp, "%i", ((Entity*)target)->features.soga_ear_type[index]);
  786. sint8 new_value = atoi(value);
  787. ((Entity*)target)->features.soga_ear_type[index] = new_value;
  788. ((Entity*)target)->info_changed = true;
  789. }
  790. break;
  791. }
  792. case SPAWN_SET_SOGA_EYE_BROW_TYPE:{
  793. if(target->IsEntity() && index < 3){
  794. sprintf(tmp, "%i", ((Entity*)target)->features.soga_eye_brow_type[index]);
  795. sint8 new_value = atoi(value);
  796. ((Entity*)target)->features.soga_eye_brow_type[index] = new_value;
  797. ((Entity*)target)->info_changed = true;
  798. }
  799. break;
  800. }
  801. case SPAWN_SET_SOGA_EYE_TYPE:{
  802. if(target->IsEntity() && index < 3){
  803. sprintf(tmp, "%i", ((Entity*)target)->features.soga_eye_type[index]);
  804. sint8 new_value = atoi(value);
  805. ((Entity*)target)->features.soga_eye_type[index] = new_value;
  806. ((Entity*)target)->info_changed = true;
  807. }
  808. break;
  809. }
  810. case SPAWN_SET_SOGA_LIP_TYPE:{
  811. if(target->IsEntity() && index < 3){
  812. sprintf(tmp, "%i", ((Entity*)target)->features.soga_lip_type[index]);
  813. sint8 new_value = atoi(value);
  814. ((Entity*)target)->features.soga_lip_type[index] = new_value;
  815. ((Entity*)target)->info_changed = true;
  816. }
  817. break;
  818. }
  819. case SPAWN_SET_SOGA_BODY_SIZE:{
  820. if(target->IsEntity()){
  821. sprintf(tmp, "%i", ((Entity*)target)->features.soga_body_size);
  822. int8 new_value = atoul(value);
  823. ((Entity*)target)->features.soga_body_size = new_value;
  824. ((Entity*)target)->info_changed = true;
  825. }
  826. break;
  827. }
  828. case SPAWN_SET_SOGA_BODY_AGE:{
  829. if(target->IsEntity()){
  830. sprintf(tmp, "%i", ((Entity*)target)->features.soga_body_age);
  831. int8 new_value = atoul(value);
  832. ((Entity*)target)->features.soga_body_age = new_value;
  833. ((Entity*)target)->info_changed = true;
  834. }
  835. break;
  836. }
  837. case SPAWN_SET_ATTACK_TYPE:{
  838. if(target->IsEntity()){
  839. sprintf(tmp, "%u", ((Entity*)target)->GetInfoStruct()->get_attack_type());
  840. int8 new_value = atoul(value);
  841. ((Entity*)target)->GetInfoStruct()->set_attack_type(new_value);
  842. }
  843. break;
  844. }
  845. case SPAWN_SET_RACE_TYPE:{
  846. if(target->GetModelType() > 0){
  847. Seperator* tmpsep = new Seperator(value, ' ', 3, 500, true);
  848. if (tmpsep->IsNumber(0))
  849. {
  850. int16 race_type = atoul(value);
  851. const char* category = tmpsep->IsSet(1) ? tmpsep->arg[1] : "NULL";
  852. const char* subcategory = tmpsep->IsSet(2) ? tmpsep->arg[2] : "NULL";
  853. const char* model_name = tmpsep->IsSet(3) ? tmpsep->arg[3] : "NULL";
  854. if(race_types_list.AddRaceType(target->GetModelType(), race_type, category, subcategory, model_name)) {
  855. if(client) {
  856. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Race type added to memory, however not saved to database.");
  857. }
  858. }
  859. else if(client) {
  860. client->SimpleMessage(CHANNEL_COLOR_RED, "Model type already on the race_types_list, use spawn set database to override and update database.");
  861. }
  862. }
  863. safe_delete(tmpsep);
  864. }
  865. break;
  866. }
  867. case SPAWN_SET_LOOT_TIER:{
  868. if(target->IsEntity()){
  869. sprintf(tmp, "%u", target->GetLootTier());
  870. int32 new_value = atoul(value);
  871. target->SetLootTier(new_value);
  872. }
  873. break;
  874. }
  875. case SPAWN_SET_LOOT_DROP_TYPE:{
  876. if(target->IsEntity()){
  877. sprintf(tmp, "%u", target->GetLootDropType());
  878. int32 new_value = atoul(value);
  879. target->SetLootDropType(new_value);
  880. }
  881. break;
  882. }
  883. case SPAWN_SET_SCARED_STRONG_PLAYERS:{
  884. if(target->IsNPC()){
  885. sprintf(tmp, "%u", target->IsScaredByStrongPlayers());
  886. int32 new_value = atoul(value);
  887. target->SetScaredByStrongPlayers(new_value);
  888. }
  889. break;
  890. }
  891. if(temp_value)
  892. *temp_value = string(tmp);
  893. }
  894. }
  895. else{
  896. /**** NOT TEMPORARY ELSE STATEMENT ****/
  897. /**** MUST RE-DEFINE WHAT IS ALREADY IN THE IF TEMPORARY BLOCK HERE ****/
  898. switch(type){
  899. case SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL: {
  900. target->SetMerchantLevelRange(atoul(value), target->GetMerchantMaxLevel());
  901. break;
  902. }
  903. case SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL: {
  904. target->SetMerchantLevelRange(target->GetMerchantMinLevel(), atoul(value));
  905. break;
  906. }
  907. case SPAWN_SET_VALUE_EXPANSION_FLAG: {
  908. if (target->GetDatabaseID() > 0)
  909. {
  910. char query[256];
  911. snprintf(query, 256, "update spawn set expansion_flag=%u where id=%u", atoul(value), target->GetDatabaseID());
  912. if (database.RunQuery(query, strnlen(query, 256)))
  913. {
  914. if(client)
  915. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  916. }
  917. }
  918. break;
  919. }
  920. case SPAWN_SET_VALUE_HOLIDAY_FLAG: {
  921. if (target->GetDatabaseID() > 0)
  922. {
  923. char query[256];
  924. snprintf(query, 256, "update spawn set holiday_flag=%u where id=%u", atoul(value), target->GetDatabaseID());
  925. if (database.RunQuery(query, strnlen(query, 256)))
  926. {
  927. if(client)
  928. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  929. }
  930. }
  931. break;
  932. }
  933. case SPAWN_SET_AAXP_REWARDS: {
  934. if (target->GetDatabaseID() > 0)
  935. {
  936. char query[256];
  937. snprintf(query, 256, "update spawn set aaxp_rewards=%u where id=%u", atoul(value), target->GetDatabaseID());
  938. if (database.RunQuery(query, strnlen(query, 256)))
  939. {
  940. if(client)
  941. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  942. }
  943. }
  944. break;
  945. }
  946. case SPAWN_SET_VALUE_NAME:{
  947. target->SetName(value);
  948. if(target->GetZone())
  949. target->GetZone()->SendUpdateTitles(target);
  950. break;
  951. }
  952. case SPAWN_SET_VALUE_SUB_TITLE: {
  953. target->SetSubTitle(value);
  954. if(target->GetZone())
  955. target->GetZone()->SendUpdateTitles(target);
  956. break;
  957. }
  958. case SPAWN_SET_VALUE_X_OFFSET:
  959. {
  960. target->SetXOffset(atof(value));
  961. break;
  962. }
  963. case SPAWN_SET_VALUE_Y_OFFSET:
  964. {
  965. target->SetYOffset(atof(value));
  966. break;
  967. }
  968. case SPAWN_SET_VALUE_Z_OFFSET:
  969. {
  970. target->SetZOffset(atof(value));
  971. break;
  972. }
  973. case SPAWN_SET_VALUE_EXPIRE: {
  974. target->SetExpireTime(val);
  975. break;
  976. }
  977. case SPAWN_SET_VALUE_EXPIRE_OFFSET: {
  978. target->SetExpireOffsetTime(val);
  979. break;
  980. }
  981. case SPAWN_SET_VALUE_LEVEL:{
  982. target->SetLevel(val, send_update);
  983. break;
  984. }
  985. case SPAWN_SET_VALUE_DIFFICULTY:{
  986. target->SetDifficulty(val, send_update);
  987. break;
  988. }
  989. case SPAWN_SET_VALUE_MODEL_TYPE:{
  990. target->SetModelType(val, send_update);
  991. break;
  992. }
  993. case SPAWN_SET_VALUE_CLASS:{
  994. target->SetAdventureClass(val, send_update);
  995. break;
  996. }
  997. case SPAWN_SET_VALUE_GENDER:{
  998. target->SetGender(val, send_update);
  999. break;
  1000. }
  1001. case SPAWN_SET_VALUE_SHOW_NAME:{
  1002. target->SetShowName(val, send_update);
  1003. break;
  1004. }
  1005. case SPAWN_SET_VALUE_ATTACKABLE:{
  1006. target->SetAttackable(val, send_update);
  1007. break;
  1008. }
  1009. case SPAWN_SET_VALUE_SHOW_LEVEL:{
  1010. target->SetShowLevel(val, send_update);
  1011. break;
  1012. }
  1013. case SPAWN_SET_VALUE_TARGETABLE:{
  1014. target->SetTargetable(val, send_update);
  1015. break;
  1016. }
  1017. case SPAWN_SET_VALUE_SHOW_COMMAND_ICON:{
  1018. target->SetShowCommandIcon(val, send_update);
  1019. break;
  1020. }
  1021. case SPAWN_SET_VALUE_HAND_ICON:{
  1022. target->SetShowHandIcon(val, send_update);
  1023. break;
  1024. }
  1025. case SPAWN_SET_VALUE_HAIR_TYPE:{
  1026. if(target->IsEntity())
  1027. ((Entity*)target)->SetHairType(val, send_update);
  1028. break;
  1029. }
  1030. case SPAWN_SET_VALUE_FACIAL_HAIR_TYPE:{
  1031. if(target->IsEntity())
  1032. ((Entity*)target)->SetFacialHairType(val, send_update);
  1033. break;
  1034. }
  1035. case SPAWN_SET_VALUE_WING_TYPE:{
  1036. if(target->IsEntity())
  1037. ((Entity*)target)->SetWingType(val, send_update);
  1038. break;
  1039. }
  1040. case SPAWN_SET_VALUE_CHEST_TYPE:{
  1041. if(target->IsEntity())
  1042. ((Entity*)target)->SetChestType(val, send_update);
  1043. break;
  1044. }
  1045. case SPAWN_SET_VALUE_LEGS_TYPE:{
  1046. if(target->IsEntity())
  1047. ((Entity*)target)->SetLegsType(val, send_update);
  1048. break;
  1049. }
  1050. case SPAWN_SET_VALUE_SOGA_HAIR_TYPE:{
  1051. if(target->IsEntity())
  1052. ((Entity*)target)->SetSogaHairType(val, send_update);
  1053. break;
  1054. }
  1055. case SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE:{
  1056. if(target->IsEntity())
  1057. ((Entity*)target)->SetSogaFacialHairType(val, send_update);
  1058. break;
  1059. }
  1060. case SPAWN_SET_VALUE_SOGA_MODEL_TYPE:{
  1061. target->SetSogaModelType(val, send_update);
  1062. break;
  1063. }
  1064. case SPAWN_SET_VALUE_SIZE:{
  1065. target->SetSize(val, send_update);
  1066. break;
  1067. }
  1068. case SPAWN_SET_VALUE_HP:{
  1069. target->SetTotalHPBase(val);
  1070. target->SetHP(val, send_update);
  1071. break;
  1072. }
  1073. case SPAWN_SET_VALUE_POWER:{
  1074. target->SetTotalPowerBase(val);
  1075. target->SetPower(val, send_update);
  1076. break;
  1077. }
  1078. case SPAWN_SET_VALUE_HEROIC:{
  1079. target->SetHeroic(val, send_update);
  1080. break;
  1081. }
  1082. case SPAWN_SET_VALUE_RESPAWN:{
  1083. target->SetRespawnTime(val);
  1084. break;
  1085. }
  1086. case SPAWN_SET_VALUE_X:{
  1087. target->SetX(atof(value), send_update);
  1088. target->SetSpawnOrigX(target->GetX());
  1089. break;
  1090. }
  1091. case SPAWN_SET_VALUE_Y:{
  1092. target->SetY(atof(value), send_update);
  1093. target->SetSpawnOrigY(target->GetY());
  1094. break;
  1095. }
  1096. case SPAWN_SET_VALUE_Z:{
  1097. target->SetZ(atof(value), send_update);
  1098. target->SetSpawnOrigZ(target->GetZ());
  1099. break;
  1100. }
  1101. case SPAWN_SET_VALUE_HEADING:{
  1102. target->SetHeading(atof(value), send_update);
  1103. target->SetSpawnOrigHeading(target->GetHeading());
  1104. break;
  1105. }
  1106. case SPAWN_SET_VALUE_COMMAND_PRIMARY:{
  1107. ZoneServer* zone = target->GetZone();
  1108. if (!zone && client)
  1109. zone = client->GetCurrentZone();
  1110. if(zone && zone->GetEntityCommandList(val))
  1111. target->SetPrimaryCommands(zone->GetEntityCommandList(val));
  1112. target->primary_command_list_id = val;
  1113. break;
  1114. }
  1115. case SPAWN_SET_VALUE_COMMAND_SECONDARY:{
  1116. ZoneServer* zone = target->GetZone();
  1117. if (!zone && client)
  1118. zone = client->GetCurrentZone();
  1119. if (zone && zone->GetEntityCommandList(val))
  1120. target->SetSecondaryCommands(zone->GetEntityCommandList(val));
  1121. target->secondary_command_list_id = val;
  1122. break;
  1123. }
  1124. case SPAWN_SET_VALUE_VISUAL_STATE:{
  1125. target->SetVisualState(val, send_update);
  1126. break;
  1127. }
  1128. case SPAWN_SET_VALUE_ACTION_STATE:{
  1129. target->SetActionState(val, send_update);
  1130. break;
  1131. }
  1132. case SPAWN_SET_VALUE_MOOD_STATE:{
  1133. target->SetMoodState(val, send_update);
  1134. break;
  1135. }
  1136. case SPAWN_SET_VALUE_INITIAL_STATE:{
  1137. target->SetInitialState(val, send_update);
  1138. break;
  1139. }
  1140. case SPAWN_SET_VALUE_ACTIVITY_STATE:{
  1141. target->SetActivityStatus(val, send_update);
  1142. break;
  1143. }
  1144. case SPAWN_SET_VALUE_COLLISION_RADIUS:{
  1145. target->SetCollisionRadius(val, send_update);
  1146. break;
  1147. }
  1148. case SPAWN_SET_VALUE_FACTION:{
  1149. ZoneServer* zone = target->GetZone();
  1150. if (!zone && client)
  1151. zone = client->GetCurrentZone();
  1152. target->faction_id = val;
  1153. if(zone)
  1154. {
  1155. zone->RemoveDeadEnemyList(target);
  1156. if(target->IsNPC())
  1157. zone->AddEnemyList((NPC*)target);
  1158. }
  1159. break;
  1160. }
  1161. case SPAWN_SET_VALUE_DEVICE_ID:{
  1162. if (target->IsObject())
  1163. ((Object*)target)->SetDeviceID(val);
  1164. break;
  1165. }
  1166. case SPAWN_SET_VALUE_PITCH: {
  1167. target->SetPitch(atof(value), send_update);
  1168. target->SetSpawnOrigPitch(atof(value));
  1169. break;
  1170. }
  1171. case SPAWN_SET_VALUE_ROLL: {
  1172. target->SetRoll(atof(value), send_update);
  1173. target->SetSpawnOrigRoll(atof(value));
  1174. break;
  1175. }
  1176. case SPAWN_SET_VALUE_HIDE_HOOD: {
  1177. target->SetHideHood(val);
  1178. break;
  1179. }
  1180. case SPAWN_SET_VALUE_EMOTE_STATE: {
  1181. target->SetEmoteState(val);
  1182. break;
  1183. }
  1184. case SPAWN_SET_VALUE_ICON: {
  1185. target->SetIcon(val);
  1186. break;
  1187. }
  1188. case SPAWN_SET_VALUE_PREFIX: {
  1189. target->SetPrefixTitle(value);
  1190. if(target->GetZone())
  1191. target->GetZone()->SendUpdateTitles(target);
  1192. break;
  1193. }
  1194. case SPAWN_SET_VALUE_SUFFIX: {
  1195. target->SetSuffixTitle(value);
  1196. if(target->GetZone())
  1197. target->GetZone()->SendUpdateTitles(target);
  1198. break;
  1199. }
  1200. case SPAWN_SET_VALUE_LASTNAME: {
  1201. target->SetLastName(value);
  1202. if(target->GetZone())
  1203. target->GetZone()->SendUpdateTitles(target);
  1204. break;
  1205. }
  1206. case SPAWN_SET_VALUE_SPAWN_SCRIPT:{
  1207. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  1208. if(client){
  1209. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  1210. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawn_script 'SpawnScripts/example.lua'");
  1211. }
  1212. return false;
  1213. }
  1214. else if(!database.UpdateSpawnScriptData(target->GetDatabaseID(), 0, 0, value))
  1215. return false;
  1216. else{
  1217. if(!world.GetSpawnLocationScript(target->GetSpawnLocationID()))
  1218. target->SetSpawnScript(value);
  1219. }
  1220. break;
  1221. }
  1222. case SPAWN_SET_VALUE_SPAWNLOCATION_SCRIPT:{
  1223. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  1224. if(client){
  1225. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  1226. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawnlocation_script 'SpawnScripts/example.lua'");
  1227. }
  1228. return false;
  1229. }
  1230. else if(!database.UpdateSpawnScriptData(0, target->GetSpawnLocationID(), 0, value))
  1231. return false;
  1232. else{
  1233. if(!world.GetSpawnEntryScript(target->GetSpawnEntryID()))
  1234. target->SetSpawnScript(value);
  1235. }
  1236. break;
  1237. }
  1238. case SPAWN_SET_VALUE_SPAWNENTRY_SCRIPT:{
  1239. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  1240. if(client){
  1241. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  1242. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawnentry_script 'SpawnScripts/example.lua'");
  1243. }
  1244. return false;
  1245. }
  1246. else if(!database.UpdateSpawnScriptData(0, 0, target->GetSpawnEntryID(), value))
  1247. return false;
  1248. else
  1249. target->SetSpawnScript(value);
  1250. break;
  1251. }
  1252. case SPAWN_SET_SKIN_COLOR:
  1253. case SPAWN_SET_HAIR_COLOR1:
  1254. case SPAWN_SET_HAIR_COLOR2:
  1255. case SPAWN_SET_HAIR_TYPE_COLOR:
  1256. case SPAWN_SET_HAIR_FACE_COLOR:
  1257. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  1258. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  1259. case SPAWN_SET_HAIR_HIGHLIGHT:
  1260. case SPAWN_SET_MODEL_COLOR:
  1261. case SPAWN_SET_EYE_COLOR:
  1262. case SPAWN_SET_SOGA_SKIN_COLOR:
  1263. case SPAWN_SET_SOGA_HAIR_COLOR1:
  1264. case SPAWN_SET_SOGA_HAIR_COLOR2:
  1265. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  1266. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  1267. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  1268. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  1269. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  1270. case SPAWN_SET_SOGA_MODEL_COLOR:
  1271. case SPAWN_SET_SOGA_EYE_COLOR: {
  1272. if (target->IsNPC())
  1273. {
  1274. Seperator* skinsep = new Seperator(value, ' ', 3, 500, true);
  1275. if (skinsep->IsNumber(0) && skinsep->IsNumber(1) && skinsep->IsNumber(2))
  1276. {
  1277. EQ2_Color clr;
  1278. clr.red = atoul(skinsep->arg[0]);
  1279. clr.green = atoul(skinsep->arg[1]);
  1280. clr.blue = atoul(skinsep->arg[2]);
  1281. Query replaceSkinQuery;
  1282. string fieldName("");
  1283. switch(type)
  1284. {
  1285. case SPAWN_SET_SKIN_COLOR:
  1286. ((Entity*)target)->SetSkinColor(clr);
  1287. fieldName.append("skin_color");
  1288. break;
  1289. case SPAWN_SET_HAIR_COLOR1:
  1290. ((Entity*)target)->SetHairColor1(clr);
  1291. fieldName.append("hair_color1");
  1292. break;
  1293. case SPAWN_SET_HAIR_COLOR2:
  1294. ((Entity*)target)->SetHairColor2(clr);
  1295. fieldName.append("hair_color2");
  1296. break;
  1297. case SPAWN_SET_HAIR_TYPE_COLOR:
  1298. ((Entity*)target)->SetHairColor(clr);
  1299. fieldName.append("hair_type_color");
  1300. break;
  1301. case SPAWN_SET_HAIR_FACE_COLOR:
  1302. ((Entity*)target)->SetFacialHairColor(clr);
  1303. fieldName.append("hair_face_color");
  1304. break;
  1305. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  1306. ((Entity*)target)->SetHairTypeHighlightColor(clr);
  1307. fieldName.append("hair_type_highlight_color");
  1308. break;
  1309. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  1310. ((Entity*)target)->SetFacialHairHighlightColor(clr);
  1311. fieldName.append("hair_face_highlight_color");
  1312. break;
  1313. case SPAWN_SET_HAIR_HIGHLIGHT:
  1314. ((Entity*)target)->SetHairHighlightColor(clr);
  1315. fieldName.append("hair_highlight");
  1316. break;
  1317. case SPAWN_SET_MODEL_COLOR:
  1318. ((Entity*)target)->SetModelColor(clr);
  1319. fieldName.append("model_color");
  1320. break;
  1321. case SPAWN_SET_EYE_COLOR:
  1322. ((Entity*)target)->SetEyeColor(clr);
  1323. fieldName.append("eye_color");
  1324. break;
  1325. case SPAWN_SET_SOGA_SKIN_COLOR:
  1326. ((Entity*)target)->SetSogaSkinColor(clr);
  1327. fieldName.append("soga_skin_color");
  1328. break;
  1329. case SPAWN_SET_SOGA_HAIR_COLOR1:
  1330. ((Entity*)target)->SetSogaHairColor1(clr);
  1331. fieldName.append("soga_hair_color1");
  1332. break;
  1333. case SPAWN_SET_SOGA_HAIR_COLOR2:
  1334. ((Entity*)target)->SetSogaHairColor2(clr);
  1335. fieldName.append("soga_hair_color2");
  1336. break;
  1337. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  1338. ((Entity*)target)->SetSogaHairColor(clr);
  1339. fieldName.append("soga_hair_type_color");
  1340. break;
  1341. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  1342. ((Entity*)target)->SetSogaFacialHairColor(clr);
  1343. fieldName.append("soga_hair_face_color");
  1344. break;
  1345. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  1346. ((Entity*)target)->SetSogaHairTypeHighlightColor(clr);
  1347. fieldName.append("soga_hair_type_highlight_color");
  1348. break;
  1349. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  1350. ((Entity*)target)->SetSogaFacialHairHighlightColor(clr);
  1351. fieldName.append("soga_hair_face_highlight_color");
  1352. break;
  1353. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  1354. ((Entity*)target)->SetSogaHairHighlightColor(clr);
  1355. fieldName.append("soga_hair_highlight");
  1356. break;
  1357. case SPAWN_SET_SOGA_MODEL_COLOR:
  1358. ((Entity*)target)->SetSogaModelColor(clr);
  1359. fieldName.append("soga_model_color");
  1360. break;
  1361. case SPAWN_SET_SOGA_EYE_COLOR:
  1362. ((Entity*)target)->SetSogaEyeColor(clr);
  1363. fieldName.append("soga_eye_color");
  1364. break;
  1365. }
  1366. replaceSkinQuery.AddQueryAsync(0, &database, Q_DELETE, "delete from npc_appearance where spawn_id=%u and type='%s'", target->GetDatabaseID(), fieldName.c_str());
  1367. replaceSkinQuery.AddQueryAsync(0, &database, Q_INSERT, "insert into npc_appearance set spawn_id=%u, type='%s', red=%u, green=%u, blue=%u", target->GetDatabaseID(), fieldName.c_str(), clr.red, clr.green, clr.blue);
  1368. }
  1369. safe_delete(skinsep);
  1370. }
  1371. break;
  1372. }
  1373. case SPAWN_SET_CHEEK_TYPE:{
  1374. if(target->IsEntity() && index < 3){
  1375. sint8 new_value = atoi(value);
  1376. ((Entity*)target)->features.cheek_type[index] = new_value;
  1377. UpdateDatabaseAppearance(client, target, "cheek_type", ((Entity*)target)->features.cheek_type[0], ((Entity*)target)->features.cheek_type[1], ((Entity*)target)->features.cheek_type[2]);
  1378. }
  1379. break;
  1380. }
  1381. case SPAWN_SET_CHIN_TYPE:{
  1382. if(target->IsEntity() && index < 3){
  1383. sint8 new_value = atoi(value);
  1384. ((Entity*)target)->features.chin_type[index] = new_value;
  1385. UpdateDatabaseAppearance(client, target, "chin_type", ((Entity*)target)->features.chin_type[0], ((Entity*)target)->features.chin_type[1], ((Entity*)target)->features.chin_type[2]);
  1386. }
  1387. break;
  1388. }
  1389. case SPAWN_SET_EAR_TYPE:{
  1390. if(target->IsEntity() && index < 3){
  1391. sint8 new_value = atoi(value);
  1392. ((Entity*)target)->features.ear_type[index] = new_value;
  1393. UpdateDatabaseAppearance(client, target, "ear_type", ((Entity*)target)->features.ear_type[0], ((Entity*)target)->features.ear_type[1], ((Entity*)target)->features.ear_type[2]);
  1394. }
  1395. break;
  1396. }
  1397. case SPAWN_SET_EYE_BROW_TYPE:{
  1398. if(target->IsEntity() && index < 3){
  1399. sint8 new_value = atoi(value);
  1400. ((Entity*)target)->features.eye_brow_type[index] = new_value;
  1401. UpdateDatabaseAppearance(client, target, "eye_brow_type", ((Entity*)target)->features.eye_brow_type[0], ((Entity*)target)->features.eye_brow_type[1], ((Entity*)target)->features.eye_brow_type[2]);
  1402. }
  1403. break;
  1404. }
  1405. case SPAWN_SET_EYE_TYPE:{
  1406. if(target->IsEntity() && index < 3){
  1407. sint8 new_value = atoi(value);
  1408. ((Entity*)target)->features.eye_type[index] = new_value;
  1409. UpdateDatabaseAppearance(client, target, "eye_type", ((Entity*)target)->features.eye_type[0], ((Entity*)target)->features.eye_type[1], ((Entity*)target)->features.eye_type[2]);
  1410. }
  1411. break;
  1412. }
  1413. case SPAWN_SET_LIP_TYPE:{
  1414. if(target->IsEntity() && index < 3){
  1415. sint8 new_value = atoi(value);
  1416. ((Entity*)target)->features.lip_type[index] = new_value;
  1417. UpdateDatabaseAppearance(client, target, "lip_type", ((Entity*)target)->features.lip_type[0], ((Entity*)target)->features.lip_type[1], ((Entity*)target)->features.lip_type[2]);
  1418. }
  1419. break;
  1420. }
  1421. case SPAWN_SET_NOSE_TYPE:{
  1422. if(target->IsEntity() && index < 3){
  1423. sint8 new_value = atoi(value);
  1424. ((Entity*)target)->features.nose_type[index] = new_value;
  1425. UpdateDatabaseAppearance(client, target, "nose_type", ((Entity*)target)->features.nose_type[0], ((Entity*)target)->features.nose_type[1], ((Entity*)target)->features.nose_type[2]);
  1426. }
  1427. break;
  1428. }
  1429. case SPAWN_SET_BODY_SIZE:{
  1430. if(target->IsEntity()){
  1431. int8 new_value = atoul(value);
  1432. ((Entity*)target)->features.body_size = new_value;
  1433. UpdateDatabaseAppearance(client, target, "body_size", ((Entity*)target)->features.body_size, 0, 0);
  1434. }
  1435. break;
  1436. }
  1437. case SPAWN_SET_BODY_AGE:{
  1438. if(target->IsEntity()){
  1439. int8 new_value = atoul(value);
  1440. ((Entity*)target)->features.body_age = new_value;
  1441. UpdateDatabaseAppearance(client, target, "body_age", ((Entity*)target)->features.body_age, 0, 0);
  1442. }
  1443. break;
  1444. }
  1445. case SPAWN_SET_SOGA_CHEEK_TYPE:{
  1446. if(target->IsEntity() && index < 3){
  1447. sint8 new_value = atoi(value);
  1448. ((Entity*)target)->features.soga_cheek_type[index] = new_value;
  1449. UpdateDatabaseAppearance(client, target, "soga_cheek_type", ((Entity*)target)->features.soga_cheek_type[0], ((Entity*)target)->features.soga_cheek_type[1], ((Entity*)target)->features.soga_cheek_type[2]);
  1450. }
  1451. break;
  1452. }
  1453. case SPAWN_SET_SOGA_CHIN_TYPE:{
  1454. if(target->IsEntity() && index < 3){
  1455. sint8 new_value = atoi(value);
  1456. ((Entity*)target)->features.soga_chin_type[index] = new_value;
  1457. UpdateDatabaseAppearance(client, target, "soga_chin_type", ((Entity*)target)->features.soga_chin_type[0], ((Entity*)target)->features.soga_chin_type[1], ((Entity*)target)->features.soga_chin_type[2]);
  1458. }
  1459. break;
  1460. }
  1461. case SPAWN_SET_SOGA_EAR_TYPE:{
  1462. if(target->IsEntity() && index < 3){
  1463. sint8 new_value = atoi(value);
  1464. ((Entity*)target)->features.soga_ear_type[index] = new_value;
  1465. UpdateDatabaseAppearance(client, target, "soga_ear_type", ((Entity*)target)->features.soga_ear_type[0], ((Entity*)target)->features.soga_ear_type[1], ((Entity*)target)->features.soga_ear_type[2]);
  1466. }
  1467. break;
  1468. }
  1469. case SPAWN_SET_SOGA_EYE_BROW_TYPE:{
  1470. if(target->IsEntity() && index < 3){
  1471. sint8 new_value = atoi(value);
  1472. ((Entity*)target)->features.soga_eye_brow_type[index] = new_value;
  1473. UpdateDatabaseAppearance(client, target, "soga_eye_brow_type", ((Entity*)target)->features.soga_eye_brow_type[0], ((Entity*)target)->features.soga_eye_brow_type[1], ((Entity*)target)->features.soga_eye_brow_type[2]);
  1474. }
  1475. break;
  1476. }
  1477. case SPAWN_SET_SOGA_EYE_TYPE:{
  1478. if(target->IsEntity() && index < 3){
  1479. sint8 new_value = atoi(value);
  1480. ((Entity*)target)->features.soga_eye_type[index] = new_value;
  1481. UpdateDatabaseAppearance(client, target, "soga_eye_type", ((Entity*)target)->features.soga_eye_type[0], ((Entity*)target)->features.soga_eye_type[1], ((Entity*)target)->features.soga_eye_type[2]);
  1482. }
  1483. break;
  1484. }
  1485. case SPAWN_SET_SOGA_LIP_TYPE:{
  1486. if(target->IsEntity() && index < 3){
  1487. sint8 new_value = atoi(value);
  1488. ((Entity*)target)->features.soga_lip_type[index] = new_value;
  1489. UpdateDatabaseAppearance(client, target, "soga_lip_type", ((Entity*)target)->features.soga_lip_type[0], ((Entity*)target)->features.soga_lip_type[1], ((Entity*)target)->features.soga_lip_type[2]);
  1490. }
  1491. break;
  1492. }
  1493. case SPAWN_SET_SOGA_NOSE_TYPE:{
  1494. if(target->IsEntity() && index < 3){
  1495. sint8 new_value = atoi(value);
  1496. ((Entity*)target)->features.soga_nose_type[index] = new_value;
  1497. UpdateDatabaseAppearance(client, target, "soga_nose_type", ((Entity*)target)->features.soga_nose_type[0], ((Entity*)target)->features.soga_nose_type[1], ((Entity*)target)->features.soga_nose_type[2]);
  1498. }
  1499. break;
  1500. }
  1501. case SPAWN_SET_SOGA_BODY_SIZE:{
  1502. if(target->IsEntity()){
  1503. int8 new_value = atoul(value);
  1504. ((Entity*)target)->features.body_size = new_value;
  1505. UpdateDatabaseAppearance(client, target, "body_size", ((Entity*)target)->features.body_size, 0, 0);
  1506. }
  1507. break;
  1508. }
  1509. case SPAWN_SET_SOGA_BODY_AGE:{
  1510. if(target->IsEntity()){
  1511. int8 new_value = atoul(value);
  1512. ((Entity*)target)->features.body_age = new_value;
  1513. UpdateDatabaseAppearance(client, target, "body_age", ((Entity*)target)->features.body_age, 0, 0);
  1514. }
  1515. break;
  1516. }
  1517. case SPAWN_SET_ATTACK_TYPE:{
  1518. if(target->IsEntity()){
  1519. int8 new_value = atoul(value);
  1520. ((Entity*)target)->GetInfoStruct()->set_attack_type(new_value);
  1521. if(target->IsNPC()) {
  1522. if(target->GetDatabaseID()) {
  1523. Query spawnNPCQuery;
  1524. spawnNPCQuery.AddQueryAsync(0, &database, Q_INSERT, "update spawn_npcs set attack_type=%u where id=%u", new_value, target->GetDatabaseID());
  1525. } else if(client) {
  1526. client->Message(CHANNEL_COLOR_RED, "Invalid spawn to update the database (NPC only) or no database id for the NPC present.");
  1527. }
  1528. }
  1529. }
  1530. break;
  1531. }
  1532. case SPAWN_SET_RACE_TYPE:{
  1533. if(target->GetModelType() > 0){
  1534. Seperator* tmpsep = new Seperator(value, ' ', 3, 500, true);
  1535. if (tmpsep->IsNumber(0))
  1536. {
  1537. Query typequery;
  1538. int16 race_type = atoul(value);
  1539. const char* category = tmpsep->IsSet(1) ? tmpsep->arg[1] : "NULL";
  1540. const char* subcategory = tmpsep->IsSet(2) ? tmpsep->arg[2] : "NULL";
  1541. const char* model_name = tmpsep->IsSet(3) ? tmpsep->arg[3] : "NULL";
  1542. if(race_types_list.AddRaceType(target->GetModelType(), race_type, category, subcategory, model_name)) {
  1543. if(client)
  1544. client->Message(CHANNEL_COLOR_YELLOW, "Model Type %u Race type %u inserted into memory + replaced into database, Model Type: %u set to Race Type: %u, Category: %s, SubCategory: %s, Model Name: %s.", race_type, target->GetModelType(), race_type, category, subcategory, model_name);
  1545. typequery.AddQueryAsync(0, &database, Q_INSERT, "insert into race_types (model_type, race_id, category, subcategory, model_name) values(%u, %u, '%s', '%s', '%s')", target->GetModelType(), race_type, category, subcategory, model_name);
  1546. }
  1547. else {
  1548. if(client)
  1549. client->Message(CHANNEL_COLOR_RED, "Model Type: %u Race type %u overrided in memory + replaced into database, Model Type: %u set to Race Type: %u, Category: %s, SubCategory: %s, Model Name: %s.", race_type, target->GetModelType(), race_type, category, subcategory, model_name);
  1550. race_types_list.AddRaceType(target->GetModelType(), race_type, category, subcategory, model_name, true);
  1551. typequery.AddQueryAsync(0, &database, Q_INSERT, "update race_types set race_id=%u, category='%s', subcategory='%s', model_name='%s' where model_type=%u", race_type, category, subcategory, model_name, target->GetModelType());
  1552. }
  1553. }
  1554. safe_delete(tmpsep);
  1555. }
  1556. break;
  1557. }
  1558. case SPAWN_SET_LOOT_TIER:{
  1559. int32 new_value = atoul(value);
  1560. target->SetLootTier(new_value);
  1561. if (target->GetDatabaseID() > 0)
  1562. {
  1563. char query[256];
  1564. snprintf(query, 256, "update spawn set loot_tier=%u where id=%u", atoul(value), target->GetDatabaseID());
  1565. if (database.RunQuery(query, strnlen(query, 256)))
  1566. {
  1567. if(client)
  1568. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  1569. }
  1570. }
  1571. break;
  1572. }
  1573. case SPAWN_SET_LOOT_DROP_TYPE:{
  1574. int32 new_value = atoul(value);
  1575. target->SetLootDropType(new_value);
  1576. if (target->GetDatabaseID() > 0)
  1577. {
  1578. char query[256];
  1579. snprintf(query, 256, "update spawn set loot_drop_type=%u where id=%u", atoul(value), target->GetDatabaseID());
  1580. if (database.RunQuery(query, strnlen(query, 256)))
  1581. {
  1582. if(client)
  1583. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  1584. }
  1585. }
  1586. break;
  1587. }
  1588. case SPAWN_SET_SCARED_STRONG_PLAYERS:{
  1589. int32 new_value = atoul(value);
  1590. target->SetScaredByStrongPlayers(new_value);
  1591. if (target->GetDatabaseID() > 0)
  1592. {
  1593. char query[256];
  1594. snprintf(query, 256, "update spawn_npcs set scared_by_strong_players=%u where id=%u", atoul(value), target->GetDatabaseID());
  1595. if (database.RunQuery(query, strnlen(query, 256)))
  1596. {
  1597. if(client)
  1598. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  1599. }
  1600. }
  1601. break;
  1602. }
  1603. }
  1604. }
  1605. return true;
  1606. }
  1607. void Commands::UpdateDatabaseAppearance(Client* client, Spawn* target, string fieldName, sint8 r, sint8 g, sint8 b)
  1608. {
  1609. Query replaceQuery;
  1610. if(target->IsBot())
  1611. {
  1612. Bot* bot = (Bot*)target;
  1613. if(bot->BotID)
  1614. database.SaveBotFloats(bot->BotID, fieldName.c_str(), r, g, b);
  1615. }
  1616. else if(target->IsPlayer())
  1617. {
  1618. replaceQuery.AddQueryAsync(0, &database, Q_DELETE, "delete from char_colors where char_id=%u and type='%s'", ((Player*)target)->GetCharacterID(), fieldName.c_str());
  1619. replaceQuery.AddQueryAsync(0, &database, Q_INSERT, "insert into char_colors set char_id=%u, type='%s', red=%i, green=%i, blue=%i", ((Player*)target)->GetCharacterID(), fieldName.c_str(), r, g, b);
  1620. }
  1621. else
  1622. {
  1623. replaceQuery.AddQueryAsync(0, &database, Q_DELETE, "delete from npc_appearance where spawn_id=%u and type='%s'", target->GetDatabaseID(), fieldName.c_str());
  1624. replaceQuery.AddQueryAsync(0, &database, Q_INSERT, "insert into npc_appearance set spawn_id=%u, type='%s', red=%i, green=%i, blue=%i", target->GetDatabaseID(), fieldName.c_str(), r, g, b);
  1625. }
  1626. ((Entity*)target)->changed = true;
  1627. ((Entity*)target)->info_changed = true;
  1628. if(target->GetZone())
  1629. target->GetZone()->AddChangedSpawn(target);
  1630. }
  1631. /* The zone object will be NULL if the zone is not currently running. We pass both of these in so we can update
  1632. the database fields always and also update the zone in memory if it's running. */
  1633. bool Commands::SetZoneCommand(Client* client, int32 zone_id, ZoneServer* zone, int8 type, const char* value) {
  1634. if (client && zone_id > 0 && type > 0 && value) {
  1635. sint32 int_value = 0;
  1636. float float_value = 0;
  1637. if (type == ZONE_SET_VALUE_SAFE_X || type == ZONE_SET_VALUE_SAFE_Y || type == ZONE_SET_VALUE_SAFE_Z || type == ZONE_SET_VALUE_UNDERWORLD) {
  1638. try {
  1639. float_value = atof(value);
  1640. }
  1641. catch (...) {
  1642. client->Message(CHANNEL_COLOR_RED, "Error converting '%s' to a float value", value);
  1643. return false;
  1644. }
  1645. }
  1646. else if (type != ZONE_SET_VALUE_NAME && type != ZONE_SET_VALUE_FILE && type != ZONE_SET_VALUE_DESCRIPTION && type != ZONE_SET_VALUE_ZONE_TYPE && type != ZONE_SET_VALUE_LUA_SCRIPT && type != ZONE_SET_VALUE_ZONE_MOTD) {
  1647. try {
  1648. int_value = atoi(value);
  1649. }
  1650. catch (...) {
  1651. client->Message(CHANNEL_COLOR_RED, "Error converting '%s' to an integer value", value);
  1652. return false;
  1653. }
  1654. }
  1655. switch (type) {
  1656. case ZONE_SET_VALUE_EXPANSION_ID: {
  1657. break;
  1658. }
  1659. case ZONE_SET_VALUE_NAME: {
  1660. if (zone)
  1661. zone->SetZoneName(const_cast<char*>(value));
  1662. database.SaveZoneInfo(zone_id, "name", value);
  1663. break;
  1664. }
  1665. case ZONE_SET_VALUE_FILE: {
  1666. if (zone)
  1667. zone->SetZoneFile(const_cast<char*>(value));
  1668. database.SaveZoneInfo(zone_id, "file", value);
  1669. break;
  1670. }
  1671. case ZONE_SET_VALUE_DESCRIPTION: {
  1672. if (zone)
  1673. zone->SetZoneDescription(const_cast<char*>(value));
  1674. database.SaveZoneInfo(zone_id, "description", value);
  1675. break;
  1676. }
  1677. case ZONE_SET_VALUE_SAFE_X: {
  1678. if (zone)
  1679. zone->SetSafeX(float_value);
  1680. database.SaveZoneInfo(zone_id, "safe_x", float_value);
  1681. break;
  1682. }
  1683. case ZONE_SET_VALUE_SAFE_Y: {
  1684. if (zone)
  1685. zone->SetSafeY(float_value);
  1686. database.SaveZoneInfo(zone_id, "safe_y", float_value);
  1687. break;
  1688. }
  1689. case ZONE_SET_VALUE_SAFE_Z: {
  1690. if (zone)
  1691. zone->SetSafeZ(float_value);
  1692. database.SaveZoneInfo(zone_id, "safe_z", float_value);
  1693. break;
  1694. }
  1695. case ZONE_SET_VALUE_UNDERWORLD: {
  1696. if (zone)
  1697. zone->SetUnderWorld(float_value);
  1698. database.SaveZoneInfo(zone_id, "underworld", float_value);
  1699. break;
  1700. }
  1701. case ZONE_SET_VALUE_MIN_RECOMMENDED: {
  1702. break;
  1703. }
  1704. case ZONE_SET_VALUE_MAX_RECOMMENDED: {
  1705. break;
  1706. }
  1707. case ZONE_SET_VALUE_ZONE_TYPE: {
  1708. break;
  1709. }
  1710. case ZONE_SET_VALUE_ALWAYS_LOADED: {
  1711. if (zone)
  1712. zone->SetAlwaysLoaded(int_value == 1);
  1713. database.SaveZoneInfo(zone_id, "always_loaded", int_value);
  1714. break;
  1715. }
  1716. case ZONE_SET_VALUE_CITY_ZONE: {
  1717. if (zone)
  1718. zone->SetCityZone(int_value == 1);
  1719. database.SaveZoneInfo(zone_id, "city_zone", int_value);
  1720. break;
  1721. }
  1722. case ZONE_SET_VALUE_WEATHER_ALLOWED: {
  1723. if (zone)
  1724. zone->SetWeatherAllowed(int_value == 1);
  1725. database.SaveZoneInfo(zone_id, "weather_allowed", int_value);
  1726. break;
  1727. }
  1728. case ZONE_SET_VALUE_MIN_STATUS: {
  1729. if (zone)
  1730. zone->SetMinimumStatus(int_value);
  1731. database.SaveZoneInfo(zone_id, "min_status", int_value);
  1732. break;
  1733. }
  1734. case ZONE_SET_VALUE_MIN_LEVEL: {
  1735. if (zone)
  1736. zone->SetMinimumLevel(int_value);
  1737. database.SaveZoneInfo(zone_id, "min_level", int_value);
  1738. break;
  1739. }
  1740. case ZONE_SET_VALUE_MAX_LEVEL: {
  1741. if (zone)
  1742. zone->SetMaximumLevel(int_value);
  1743. database.SaveZoneInfo(zone_id, "max_level", int_value);
  1744. break;
  1745. }
  1746. case ZONE_SET_VALUE_START_ZONE: {
  1747. database.SaveZoneInfo(zone_id, "start_zone", int_value);
  1748. break;
  1749. }
  1750. case ZONE_SET_VALUE_INSTANCE_TYPE: {
  1751. if (zone)
  1752. zone->SetInstanceType(int_value);
  1753. database.SaveZoneInfo(zone_id, "instance_type", int_value);
  1754. break;
  1755. }
  1756. case ZONE_SET_VALUE_DEFAULT_REENTER_TIME: {
  1757. if (zone)
  1758. zone->SetDefaultReenterTime(int_value);
  1759. database.SaveZoneInfo(zone_id, "default_reenter_time", int_value);
  1760. break;
  1761. }
  1762. case ZONE_SET_VALUE_DEFAULT_RESET_TIME: {
  1763. if (zone)
  1764. zone->SetDefaultResetTime(int_value);
  1765. database.SaveZoneInfo(zone_id, "default_reset_time", int_value);
  1766. break;
  1767. }
  1768. case ZONE_SET_VALUE_DEFAULT_LOCKOUT_TIME: {
  1769. if (zone)
  1770. zone->SetDefaultLockoutTime(int_value);
  1771. database.SaveZoneInfo(zone_id, "default_lockout_time", int_value);
  1772. break;
  1773. }
  1774. case ZONE_SET_VALUE_FORCE_GROUP_TO_ZONE: {
  1775. if (zone)
  1776. zone->SetForceGroupZoneOption(int_value);
  1777. database.SaveZoneInfo(zone_id, "force_group_to_zone", int_value);
  1778. break;
  1779. }
  1780. case ZONE_SET_VALUE_LUA_SCRIPT: {
  1781. if (lua_interface && lua_interface->GetZoneScript(value) == 0) {
  1782. client->Message(CHANNEL_COLOR_RED, "Invalid Zone Script file. Be sure you give the absolute path.");
  1783. client->Message(CHANNEL_COLOR_RED, "Example: /zone set lua_script 'ZoneScripts/QueensColony.lua'");
  1784. return false;
  1785. }
  1786. else {
  1787. world.AddZoneScript(zone_id, const_cast<char*>(value));
  1788. database.SaveZoneInfo(zone_id, "lua_script", value);
  1789. }
  1790. break;
  1791. }
  1792. case ZONE_SET_VALUE_SHUTDOWN_TIMER: {
  1793. if (zone)
  1794. zone->SetShutdownTimer(int_value);
  1795. database.SaveZoneInfo(zone_id, "shutdown_timer", int_value);
  1796. break;
  1797. }
  1798. case ZONE_SET_VALUE_ZONE_MOTD: {
  1799. if (zone)
  1800. zone->SetZoneMOTD(string(value));
  1801. database.SaveZoneInfo(zone_id, "zone_motd", value);
  1802. break;
  1803. }
  1804. default: {
  1805. client->Message(CHANNEL_COLOR_RED, "Invalid zone attribute %i", type);
  1806. return false;
  1807. }
  1808. }
  1809. }
  1810. else {
  1811. if (client)
  1812. client->SimpleMessage(CHANNEL_COLOR_RED, "An error occured saving new zone data.");
  1813. return false;
  1814. }
  1815. return true;
  1816. }
  1817. void Commands::Process(int32 index, EQ2_16BitString* command_parms, Client* client, Spawn* targetOverride) {
  1818. if (index >= remote_commands->commands.size()) {
  1819. LogWrite(COMMAND__ERROR, 0, "Command", "Error, command handler of %u was requested, but max handler is %u", index, remote_commands->commands.size());
  1820. return;
  1821. }
  1822. Spawn* cmdTarget = targetOverride ? targetOverride : client->GetPlayer()->GetTarget();
  1823. EQ2_RemoteCommandString* parent_command = 0;
  1824. EQ2_RemoteCommandString* command = &remote_commands->commands[index];
  1825. Seperator* sep = 0;
  1826. if (command_parms->size > 0) {
  1827. sep = new Seperator(command_parms->data.c_str(), ' ', 10, 500, true);
  1828. if (sep && sep->arg[0] && remote_commands->validSubCommand(command->command.data, string(sep->arg[0]))) {
  1829. parent_command = command;
  1830. command = &(remote_commands->subcommands[command->command.data][string(sep->arg[0])]);
  1831. safe_delete(sep);
  1832. if (command_parms->data.length() > (command->command.data.length() + 1))
  1833. sep = new Seperator(command_parms->data.c_str() + (command->command.data.length() + 1), ' ', 10, 500, true);
  1834. LogWrite(COMMAND__DEBUG, 1, "Command", "Handler: %u, COMMAND: '%s', SUBCOMMAND: '%s'", index, parent_command->command.data.c_str(), command->command.data.c_str());
  1835. }
  1836. else
  1837. LogWrite(COMMAND__DEBUG, 1, "Command", "Handler: %u, COMMAND: '%s'", index, command->command.data.c_str());
  1838. }
  1839. int ndx = 0;
  1840. if (command->required_status > client->GetAdminStatus())
  1841. {
  1842. LogWrite(COMMAND__ERROR, 0, "Command", "Player '%s' (%u) needs status %i to use command: %s", client->GetPlayer()->GetName(), client->GetAccountID(), command->required_status, command->command.data.c_str());
  1843. safe_delete(sep);
  1844. client->SimpleMessage(3, "Error: Your status is insufficient for this command.");
  1845. return;
  1846. }
  1847. Player* player = client->GetPlayer();
  1848. LogWrite(COMMAND__DEBUG, 0, "Command", "Player '%s' (%u), Command: %s", player->GetName(), client->GetAccountID(), command->command.data.c_str());
  1849. switch (command->handler) {
  1850. case COMMAND_RELOAD: {
  1851. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reload commands:");
  1852. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload structs");
  1853. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload items");
  1854. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload luasystem");
  1855. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spawnscripts");
  1856. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spells");
  1857. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spells npc");
  1858. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload quests");
  1859. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spawns");
  1860. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload groundspawns");
  1861. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload zonescripts");
  1862. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload entity_commands");
  1863. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload factions");
  1864. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload mail");
  1865. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload guilds");
  1866. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload locations");
  1867. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload rules");
  1868. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload transporters");
  1869. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload startabilities");
  1870. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload voiceovers");
  1871. break;
  1872. }
  1873. case COMMAND_RELOADSTRUCTS: {
  1874. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Structs...");
  1875. world.SetReloadingSubsystem("Structs");
  1876. configReader.ReloadStructs();
  1877. world.RemoveReloadingSubSystem("Structs");
  1878. peer_manager.sendPeersMessage("/reloadcommand", command->handler);
  1879. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1880. break;
  1881. }
  1882. case COMMAND_RELOAD_QUESTS: {
  1883. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Quests...");
  1884. world.SetReloadingSubsystem("Quests");
  1885. master_quest_list.Reload();
  1886. client_list.ReloadQuests();
  1887. zone_list.ReloadClientQuests();
  1888. world.RemoveReloadingSubSystem("Quests");
  1889. peer_manager.sendPeersMessage("/reloadcommand", command->handler);
  1890. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1891. break;
  1892. }
  1893. case COMMAND_RELOAD_SPAWNS: {
  1894. client->GetCurrentZone()->ReloadSpawns();
  1895. break;
  1896. }
  1897. case COMMAND_RELOAD_SPELLS: {
  1898. if (sep && sep->arg[0] && strcmp(sep->arg[0], "npc") == 0) {
  1899. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading NPC Spells Lists (Note: Must Reload Spawns/Repop to reset npc spells)...");
  1900. world.PurgeNPCSpells();
  1901. database.LoadNPCSpells();
  1902. peer_manager.sendPeersMessage("/reloadcommand", command->handler, 1);
  1903. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1904. }
  1905. else {
  1906. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spells & NPC Spell Lists (Note: Must Reload Spawns/Repop to reset npc spells)...");
  1907. world.SetReloadingSubsystem("Spells");
  1908. zone_list.DeleteSpellProcess();
  1909. if (lua_interface)
  1910. lua_interface->DestroySpells();
  1911. master_spell_list.Reload();
  1912. zone_list.LoadSpellProcess();
  1913. world.RemoveReloadingSubSystem("Spells");
  1914. world.PurgeNPCSpells();
  1915. database.LoadNPCSpells();
  1916. peer_manager.sendPeersMessage("/reloadcommand", command->handler);
  1917. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1918. }
  1919. break;
  1920. }
  1921. case COMMAND_RELOAD_GROUNDSPAWNS: {
  1922. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Groundspawn Entries...");
  1923. world.SetReloadingSubsystem("GroundSpawns");
  1924. client->GetCurrentZone()->DeleteGroundSpawnItems();
  1925. client->GetCurrentZone()->LoadGroundSpawnEntries();
  1926. world.RemoveReloadingSubSystem("GroundSpawns");
  1927. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1928. break;
  1929. }
  1930. case COMMAND_RELOAD_ZONESCRIPTS: {
  1931. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Zone Scripts...");
  1932. world.SetReloadingSubsystem("ZoneScripts");
  1933. world.ResetZoneScripts();
  1934. database.LoadZoneScriptData();
  1935. if (lua_interface)
  1936. lua_interface->DestroyZoneScripts();
  1937. world.RemoveReloadingSubSystem("ZoneScripts");
  1938. peer_manager.sendPeersMessage("/reloadcommand", command->handler);
  1939. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1940. break;
  1941. }
  1942. case COMMAND_RELOAD_ENTITYCOMMANDS: {
  1943. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Entity Commands...");
  1944. world.SetReloadingSubsystem("EntityCommands");
  1945. client->GetCurrentZone()->ClearEntityCommands();
  1946. database.LoadEntityCommands(client->GetCurrentZone());
  1947. world.RemoveReloadingSubSystem("EntityCommands");
  1948. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1949. break;
  1950. }
  1951. case COMMAND_RELOAD_FACTIONS: {
  1952. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Factions...");
  1953. world.SetReloadingSubsystem("Factions");
  1954. master_faction_list.Clear();
  1955. database.LoadFactionList();
  1956. world.RemoveReloadingSubSystem("Factions");
  1957. peer_manager.sendPeersMessage("/reloadcommand", command->handler);
  1958. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1959. break;
  1960. }
  1961. case COMMAND_RELOAD_MAIL: {
  1962. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Mail...");
  1963. zone_list.ReloadMail();
  1964. peer_manager.sendPeersMessage("/reloadcommand", command->handler);
  1965. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1966. break;
  1967. }
  1968. case COMMAND_RELOAD_GUILDS: {
  1969. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Guilds...");
  1970. world.ReloadGuilds();
  1971. peer_manager.sendPeersMessage("/reloadcommand", command->handler);
  1972. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1973. break;
  1974. }
  1975. case COMMAND_RELOAD_LOCATIONS: {
  1976. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Locations...");
  1977. client->GetPlayer()->GetZone()->RemoveLocationGrids();
  1978. database.LoadLocationGrids(client->GetPlayer()->GetZone());
  1979. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1980. break;
  1981. }
  1982. case COMMAND_RELOAD_RULES: {
  1983. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Rules...");
  1984. database.LoadRuleSets(true);
  1985. peer_manager.sendPeersMessage("/reloadcommand", command->handler);
  1986. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1987. break;
  1988. }
  1989. case COMMAND_RELOAD_TRANSPORTERS: {
  1990. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Transporters in your current zone...");
  1991. database.LoadTransporters(client->GetCurrentZone());
  1992. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1993. break;
  1994. }
  1995. case COMMAND_RELOAD_STARTABILITIES: {
  1996. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Starting Skills/Spells...");
  1997. world.PurgeStartingLists();
  1998. world.LoadStartingLists();
  1999. peer_manager.sendPeersMessage("/reloadcommand", command->handler);
  2000. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  2001. break;
  2002. }
  2003. case COMMAND_RELOAD_VOICEOVERS: {
  2004. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Voiceovers...");
  2005. world.PurgeVoiceOvers();
  2006. world.LoadVoiceOvers();
  2007. peer_manager.sendPeersMessage("/reloadcommand", command->handler);
  2008. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  2009. break;
  2010. }
  2011. case COMMAND_READ: {
  2012. if (sep && sep->arg[1][0] && sep->IsNumber(1)) {
  2013. if (strcmp(sep->arg[0], "read") == 0) {
  2014. int32 item_index = atol(sep->arg[1]);
  2015. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  2016. if (item) {
  2017. Spawn* spawn = cmdTarget;
  2018. client->SendShowBook(client->GetPlayer(), item->name, item->book_language, item->book_pages);
  2019. break;
  2020. }
  2021. }
  2022. }
  2023. break;
  2024. }
  2025. case COMMAND_USEABILITY:{
  2026. if (sep && sep->arg[0][0] && sep->IsNumber(0)) {
  2027. if (!client->GetPlayer()->Alive()) {
  2028. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot do that right now.");
  2029. }
  2030. else {
  2031. int32 spell_id = atoul(sep->arg[0]);
  2032. int8 spell_tier = 0;
  2033. if (sep->arg[1][0] && sep->IsNumber(1))
  2034. spell_tier = atoi(sep->arg[1]);
  2035. else
  2036. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  2037. if (!spell_tier)
  2038. spell_tier = 1;
  2039. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  2040. if (spell) {
  2041. if (strncmp(spell->GetName(), "Gathering", 9) == 0 || strncmp(spell->GetName(), "Mining", 6) == 0 || strncmp(spell->GetName(), "Trapping", 8) == 0 || strncmp(spell->GetName(), "Foresting", 9) == 0 || strncmp(spell->GetName(), "Fishing", 7) == 0 || strncmp(spell->GetName(), "Collecting", 10) == 0)
  2042. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), cmdTarget, true, true);
  2043. else
  2044. {
  2045. if (cmdTarget)
  2046. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), cmdTarget);
  2047. else
  2048. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  2049. }
  2050. }
  2051. }
  2052. }
  2053. else if (cmdTarget && cmdTarget->IsWidget())
  2054. {
  2055. Widget* widget = (Widget*)cmdTarget;
  2056. widget->HandleUse(client, "use", WIDGET_TYPE_DOOR);
  2057. }
  2058. else
  2059. {
  2060. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /useability {spell_id} [spell_tier]");
  2061. }
  2062. break;
  2063. }
  2064. case COMMAND_INFO:{
  2065. bool check_self_trade = true;
  2066. if(sep && sep->arg[1][0] && sep->IsNumber(1)){
  2067. if(strcmp(sep->arg[0], "inventory") == 0){
  2068. int32 item_index = atol(sep->arg[1]);
  2069. LogWrite(COMMAND__DEBUG, 5, "Command", "/info inventory item original index %u", item_index);
  2070. if(client->GetVersion() <= 561) {
  2071. if(item_index <= 255) {
  2072. item_index = 255 - item_index;
  2073. }
  2074. else {
  2075. if(item_index == 256) { // first "new" item to inventory is assigned index 256 by client
  2076. item_index = client->GetPlayer()->item_list.GetFirstNewItem();
  2077. }
  2078. else {
  2079. // otherwise the slot has to be mapped out depending on the amount of new items + index sent in
  2080. item_index = client->GetPlayer()->item_list.GetNewItemByIndex((int16)item_index - 255);
  2081. }
  2082. }
  2083. }
  2084. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  2085. if(item){
  2086. if (item->IsCollectable() && client->SendCollectionsForItem(item))
  2087. break;
  2088. EQ2Packet* app = 0;
  2089. if(client->GetVersion() <= 561) {
  2090. app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  2091. }
  2092. else {
  2093. app = item->serialize(client->GetVersion(), (!item->GetItemScript() || !lua_interface), client->GetPlayer());
  2094. }
  2095. //DumpPacket(app);
  2096. client->QueuePacket(app);
  2097. if(item->GetItemScript() && lua_interface)
  2098. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  2099. else if(item->generic_info.offers_quest_id > 0){ //leave the current functionality in place if it doesnt have an item script
  2100. Quest* quest = master_quest_list.GetQuest(item->generic_info.offers_quest_id, false);
  2101. if(quest && client->GetPlayer()->HasQuestBeenCompleted(item->generic_info.offers_quest_id) == 0 && client->GetPlayer()->HasActiveQuest(item->generic_info.offers_quest_id) == 0)
  2102. client->AddPendingQuest(new Quest(quest)); // copy quest since we pulled the master quest to see if it existed or not
  2103. }
  2104. }
  2105. else
  2106. LogWrite(COMMAND__ERROR, 0, "Command", "/info inventory: Unknown Index: %u", item_index);
  2107. }
  2108. else if(strcmp(sep->arg[0], "equipment") == 0){
  2109. int32 item_index = client->GetPlayer()->ConvertSlotFromClient(atol(sep->arg[1]), client->GetVersion());
  2110. Item* item = client->GetPlayer()->GetEquipmentList()->GetItem(item_index);
  2111. if(item){
  2112. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  2113. client->QueuePacket(app);
  2114. if(item->GetItemScript() && lua_interface)
  2115. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  2116. }
  2117. else
  2118. LogWrite(COMMAND__ERROR, 0, "Command", "/info equipment: Unknown Index: %u", item_index);
  2119. }
  2120. else if(strcmp(sep->arg[0], "appearance") == 0){
  2121. int32 item_index = client->GetPlayer()->ConvertSlotFromClient(atol(sep->arg[1]), client->GetVersion());
  2122. Item* item = client->GetPlayer()->GetAppearanceEquipmentList()->GetItem(item_index);
  2123. if(item){
  2124. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  2125. client->QueuePacket(app);
  2126. if(item->GetItemScript() && lua_interface)
  2127. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  2128. }
  2129. else
  2130. LogWrite(COMMAND__ERROR, 0, "Command", "/info appearance: Unknown Index: %u", item_index);
  2131. }
  2132. else if(strcmp(sep->arg[0], "item") == 0 || strcmp(sep->arg[0], "merchant") == 0 || strcmp(sep->arg[0], "store") == 0 || strcmp(sep->arg[0], "buyback") == 0 || strcmp(sep->arg[0], "consignment") == 0){
  2133. int32 item_id = atoul(sep->arg[1]);
  2134. Item* item = master_item_list.GetItem(item_id);
  2135. if(item){
  2136. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  2137. client->QueuePacket(app);
  2138. }
  2139. else
  2140. LogWrite(COMMAND__ERROR, 0, "Command", "/info item|merchant|store|buyback|consignment: Unknown Item ID: %u", item_id);
  2141. }
  2142. else if (strcmp(sep->arg[0], "spell") == 0) {
  2143. sint32 spell_id = atol(sep->arg[1]);
  2144. int8 tier = atoi(sep->arg[3]);
  2145. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, tier, client, true, 0x2A);
  2146. if (outapp)
  2147. client->QueuePacket(outapp);
  2148. else
  2149. LogWrite(COMMAND__ERROR, 0, "Command", "/info spell: Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  2150. }
  2151. else if (strcmp(sep->arg[0], "achievement") == 0) {
  2152. sint32 spell_id = atol(sep->arg[2]);
  2153. int8 group = atoi(sep->arg[1]);
  2154. AltAdvanceData* data = 0;
  2155. SpellBookEntry* spellentry = 0;
  2156. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  2157. LogWrite(COMMAND__ERROR, 0, "Command", "/info achievement: AA Spell ID and/or Tier, ID: %u, Group: %i", spell_id, group);
  2158. EQ2Packet* outapp = master_spell_list.GetAASpellPacket(spell_id, tier, client, true, 0x45);
  2159. if (outapp)
  2160. client->QueuePacket(outapp);
  2161. else
  2162. LogWrite(COMMAND__ERROR, 0, "Command", "/info achievement: Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, group);
  2163. }
  2164. else if (strcmp(sep->arg[0], "spellbook") == 0) {
  2165. sint32 spell_id = atol(sep->arg[1]);
  2166. int32 tier = atoi(sep->arg[2]);
  2167. if (tier > 255) {
  2168. SpellBookEntry* ent = client->GetPlayer()->GetSpellBookSpell(spell_id);
  2169. if (ent)
  2170. tier = ent->tier;
  2171. }
  2172. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, (int8)tier, client, true, 0x2A);
  2173. if (outapp)
  2174. client->QueuePacket(outapp);
  2175. else
  2176. LogWrite(COMMAND__ERROR, 0, "Command", "/info spellbook: Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  2177. }
  2178. else if (strcmp(sep->arg[0], "recipe") == 0) {
  2179. sint32 recipe_id = atol(sep->arg[1]);
  2180. EQ2Packet* outapp = master_recipe_list.GetRecipePacket(recipe_id, client, true, 0x2C);
  2181. if(outapp)
  2182. client->QueuePacket(outapp);
  2183. else
  2184. LogWrite(COMMAND__ERROR, 0, "Command", "/info recipe: Unknown Recipe ID: %u", recipe_id);
  2185. }
  2186. else if (strcmp(sep->arg[0], "recipe_product") == 0) {
  2187. sint32 recipe_id = atol(sep->arg[1]);
  2188. PlayerRecipeList* prl = client->GetPlayer()->GetRecipeList();
  2189. Recipe* recipe = nullptr;
  2190. if ((recipe = prl->GetRecipe(recipe_id)) && recipe->GetProductID()) {
  2191. RecipeProducts* rp = recipe->products[1];
  2192. if (recipe->GetProductID() > 0) {
  2193. Item* item = master_item_list.GetItem(recipe->GetProductID());
  2194. if(item){
  2195. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  2196. client->QueuePacket(app);
  2197. }
  2198. else
  2199. LogWrite(COMMAND__ERROR, 0, "Command", "/info recipe_product: Unknown Item ID: %u", recipe->GetProductID());
  2200. }
  2201. else {
  2202. LogWrite(COMMAND__ERROR, 0, "Command", "/info recipe_product: recipe->GetProductID() has value 0 for recipe id %u.", recipe_id);
  2203. }
  2204. }
  2205. else {
  2206. LogWrite(COMMAND__ERROR, 0, "Command", "/info recipe_product: with recipe id %u not found (recipe missing or no product in stage 1 assigned).", recipe_id);
  2207. }
  2208. }
  2209. else if (strcmp(sep->arg[0], "maintained") ==0) {
  2210. int32 slot = atol(sep->arg[1]);
  2211. int32 spell_id = atol(sep->arg[2]);
  2212. LogWrite(COMMAND__DEBUG, 5, "Command", "/info maintained: Spell ID - Slot: %u unknown: %u", slot, spell_id);
  2213. //int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  2214. MaintainedEffects* info = client->GetPlayer()->GetMaintainedSpellBySlot(slot);
  2215. EQ2Packet* outapp = master_spell_list.GetSpellPacket(info->spell_id, info->tier, client, true, 0x00);
  2216. if(outapp)
  2217. client->QueuePacket(outapp);
  2218. else
  2219. LogWrite(COMMAND__ERROR, 0, "Command", "/info maintained: Unknown Spell ID: %u", spell_id);
  2220. }
  2221. else if (strcmp(sep->arg[0], "effect") == 0) {
  2222. int32 spell_id = atol(sep->arg[1]);
  2223. LogWrite(COMMAND__DEBUG, 5, "Command", "/info effect: Spell ID: %u", spell_id);
  2224. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  2225. int8 type = 0;
  2226. if (client->GetVersion() <= 561)
  2227. type = 1;
  2228. EQ2Packet* outapp = master_spell_list.GetSpecialSpellPacket(spell_id, tier, client, true, type);
  2229. if (outapp){
  2230. client->QueuePacket(outapp);
  2231. }
  2232. else
  2233. LogWrite(COMMAND__ERROR, 0, "Command", "/info effect: Unknown Spell ID: %u", spell_id);
  2234. }
  2235. else if(sep->IsNumber(1) && ((strncasecmp("your_trade", sep->arg[0], 10) == 0) ||
  2236. (strncasecmp("their_trade", sep->arg[0], 11) == 0)))
  2237. {
  2238. if(strncasecmp("t", sep->arg[0], 1) == 0) { // their_trade not self trade
  2239. check_self_trade = false;
  2240. }
  2241. int8 slot_id = atoul(sep->arg[1]);
  2242. if(client->GetPlayer()->trade) {
  2243. Entity* traderToCheck = client->GetPlayer();
  2244. if(!check_self_trade) {
  2245. traderToCheck = client->GetPlayer()->trade->GetTradee(client->GetPlayer());
  2246. }
  2247. Item* tradeItem = client->GetPlayer()->trade->GetTraderSlot(traderToCheck, slot_id);
  2248. if(tradeItem != nullptr) {
  2249. EQ2Packet* app = tradeItem->serialize(client->GetVersion(), true, client->GetPlayer(), true, 0, 0, client->GetVersion() > 561 ? true : false);
  2250. client->QueuePacket(app);
  2251. }
  2252. }
  2253. }
  2254. }
  2255. else if (sep && strcmp(sep->arg[0], "overflow") == 0) {
  2256. Item* item = player->item_list.GetOverflowItem();
  2257. if(item) {
  2258. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  2259. client->QueuePacket(app);
  2260. }
  2261. else
  2262. LogWrite(COMMAND__ERROR, 0,"Command", "/info overflow: Unable to retrieve an overflow item.");
  2263. }
  2264. else
  2265. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /info {inventory|equipment|spell} {id}");
  2266. break;
  2267. }
  2268. case COMMAND_USE_EQUIPPED_ITEM:{
  2269. if (sep && sep->arg[0] && sep->IsNumber(0)){
  2270. int32 slot_id = atoul(sep->arg[0]);
  2271. Item* item = player->GetEquipmentList()->GetItem(slot_id);
  2272. if (item && item->generic_info.usable && item->GetItemScript()) {
  2273. if(!item->CheckFlag2(INDESTRUCTABLE) && item->generic_info.condition == 0) {
  2274. client->SimpleMessage(CHANNEL_COLOR_RED, "This item is broken and must be repaired at a mender before it can be used");
  2275. }
  2276. else if (item->CheckFlag(EVIL_ONLY) && client->GetPlayer()->GetAlignment() != ALIGNMENT_EVIL) {
  2277. client->Message(0, "%s requires an evil race.", item->name.c_str());
  2278. }
  2279. else if (item->CheckFlag(GOOD_ONLY) && client->GetPlayer()->GetAlignment() != ALIGNMENT_GOOD) {
  2280. client->Message(0, "%s requires a good race.", item->name.c_str());
  2281. }
  2282. else {
  2283. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player, player->GetTarget());
  2284. }
  2285. }
  2286. }
  2287. break;
  2288. }
  2289. case COMMAND_USE_ITEM: {
  2290. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  2291. int32 item_index = atoul(sep->arg[0]);
  2292. Item* item = player->item_list.GetItemFromIndex(item_index);
  2293. client->UseItem(item, client->GetPlayer()->GetTarget() ? client->GetPlayer()->GetTarget() : client->GetPlayer());
  2294. }
  2295. break;
  2296. }
  2297. case COMMAND_SCRIBE_SCROLL_ITEM: {
  2298. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  2299. Item* item = player->item_list.GetItemFromUniqueID(atoul(sep->arg[0]));
  2300. if (item) {
  2301. LogWrite(ITEM__DEBUG, 0, "Items", "ITEM ID: %u", item->details.item_id);
  2302. if(item->generic_info.item_type == 6) {
  2303. Spell* spell = master_spell_list.GetSpell(item->skill_info->spell_id, item->skill_info->spell_tier);
  2304. int8 old_slot = 0;
  2305. if (spell) {
  2306. if(!spell->ScribeAllowed(client->GetPlayer())) {
  2307. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not meet one of the requirements to scribe, due to class or level.");
  2308. break;
  2309. }
  2310. int16 tier_up = player->GetTierUp(spell->GetSpellTier());
  2311. if (rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Spells, RequirePreviousTierScribe)->GetInt8() && !player->HasSpell(spell->GetSpellID(), tier_up, false, true))
  2312. client->SimpleMessage(CHANNEL_COLOR_RED, "You have not scribed the required previous version of this ability.");
  2313. else if (!player->HasSpell(spell->GetSpellID(), spell->GetSpellTier(), true)) {
  2314. old_slot = player->GetSpellSlot(spell->GetSpellID());
  2315. player->RemoveSpellBookEntry(spell->GetSpellID());
  2316. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  2317. player->UnlockSpell(spell);
  2318. client->SendSpellUpdate(spell);
  2319. database.DeleteItem(client->GetCharacterID(), item, 0);
  2320. player->item_list.RemoveItem(item, true);
  2321. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  2322. client->QueuePacket(player->SendInventoryUpdate(client->GetVersion()));
  2323. // force purge client cache and display updated spell for hover over
  2324. EQ2Packet* app = spell->SerializeSpell(client, false, false);
  2325. client->QueuePacket(app);
  2326. }
  2327. }
  2328. else
  2329. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown spell ID: %u and tier: %u", item->skill_info->spell_id, item->skill_info->spell_tier);
  2330. }
  2331. else if(item->generic_info.item_type == 7){
  2332. if(item->recipebook_info) {
  2333. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Scribing recipe book %s (%u) for player %s.", item->name.c_str(), item->recipebook_info->recipe_id, player->GetName());
  2334. client->AddRecipeBookToPlayer(item->recipebook_info->recipe_id, item);
  2335. }
  2336. else {
  2337. client->Message(CHANNEL_NARRATIVE, "Recipe book is unavailable! Report to admin recipe id %u could not be retrieved.", item->recipebook_info ? item->recipebook_info->recipe_id : 0);
  2338. LogWrite(COMMAND__ERROR, 0, "Command", "Recipe Book %u could not be retrieved for item %s.", item->recipebook_info ? item->recipebook_info->recipe_id : 0, item->name.c_str());
  2339. }
  2340. }
  2341. else {
  2342. LogWrite(COMMAND__ERROR, 0, "Command", "Recipe Book Info is not set for item %s.", item->name.c_str());
  2343. }
  2344. }
  2345. else
  2346. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown unique item ID: %s", sep->arg[0]);
  2347. }
  2348. break;
  2349. }
  2350. case COMMAND_SUMMONITEM: {
  2351. if (sep && sep->IsNumber(0)) {
  2352. int32 item_id = atol(sep->arg[0]);
  2353. int32 quantity = 1;
  2354. if (sep->arg[1] && sep->IsNumber(1))
  2355. quantity = atoi(sep->arg[1]);
  2356. if (sep->arg[2] && strncasecmp(sep->arg[2], "bank", 4) == 0) {
  2357. client->AddItemToBank(item_id,quantity);
  2358. }
  2359. else {
  2360. client->AddItem(item_id, quantity);
  2361. }
  2362. }
  2363. else {
  2364. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} [quantity] or");
  2365. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} {quantity} [location] where location = bank");
  2366. }
  2367. break;
  2368. }
  2369. case COMMAND_COLLECTION_ADDITEM: {
  2370. // takes 2 params: collection_id, slot
  2371. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  2372. Item *item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(atoul(sep->arg[1]));
  2373. if (item)
  2374. client->HandleCollectionAddItem(atoul(sep->arg[0]), item);
  2375. else
  2376. LogWrite(COLLECTION__ERROR, 0, "Collect", "Error in 'COMMAND_COLLECTION_ADDITEM'. Unable to get item from player '%s' at index %u", client->GetPlayer()->GetName(), atoul(sep->arg[0]));
  2377. }
  2378. else
  2379. LogWrite(COLLECTION__ERROR, 0, "Collect", "Received command 'COMMAND_COLLECTION_ADDITEM' with unhandeled argument types");
  2380. break;
  2381. }
  2382. case COMMAND_COLLECTION_FILTER_MATCHITEM: {
  2383. // takes 1 param: slot
  2384. printf("COMMAND_COLLECTION_FILTER_MATCHITEM:\n");
  2385. int i = 0;
  2386. while (sep->arg[i] && strlen(sep->arg[i]) > 0) {
  2387. printf("\t%u: %s\n", i, sep->arg[i]);
  2388. i++;
  2389. }
  2390. break;
  2391. }
  2392. case COMMAND_WAYPOINT: {
  2393. bool success = false;
  2394. client->ClearWaypoint();
  2395. if (sep && sep->IsNumber(0) && sep->IsNumber(1) && sep->IsNumber(2)) {
  2396. if (!client->ShowPathToTarget(atof(sep->arg[0]), atof(sep->arg[1]), atof(sep->arg[2]), 0))
  2397. client->Message(CHANNEL_COLOR_RED, "Invalid coordinates given");
  2398. }
  2399. else if ( client->GetAdminStatus() > 100 && cmdTarget ) {
  2400. if (!client->ShowPathToTarget(cmdTarget->GetX(), cmdTarget->GetY(), cmdTarget->GetZ(), 0))
  2401. client->Message(CHANNEL_COLOR_RED, "Invalid coordinates given");
  2402. }
  2403. else {
  2404. client->Message(CHANNEL_COLOR_YELLOW, "Usage: /waypoint x y z");
  2405. }
  2406. break;
  2407. }
  2408. case COMMAND_WHO:{
  2409. const char* who = 0;
  2410. if(sep && sep->arg[0]){
  2411. //cout << "Who query: \n";
  2412. who = sep->argplus[0];
  2413. //cout << who << endl;
  2414. }
  2415. zone_list.ProcessWhoQuery(who, client);
  2416. break;
  2417. }
  2418. case COMMAND_SELECT_JUNCTION:{
  2419. // transporters (bells birds) use OP_SelectZoneTeleporterDestinatio / ProcessTeleportLocation(app)
  2420. // this is only used for revive it seems
  2421. int32 choice = 0;
  2422. if(sep && sep->arg[0] && sep->IsNumber(0))
  2423. choice = atoul(sep->arg[0]);
  2424. if(!client->GetPlayer()->Alive()){ //dead and this is a revive request
  2425. client->HandlePlayerRevive(choice);
  2426. }
  2427. break;
  2428. }
  2429. case COMMAND_SPAWN_MOVE: {
  2430. if (cmdTarget && cmdTarget->IsPlayer() == false) {
  2431. PacketStruct* packet = configReader.getStruct("WS_MoveObjectMode", client->GetVersion());
  2432. if (packet) {
  2433. float unknown2_3 = 0;
  2434. int8 placement_mode = 0;
  2435. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::DEFAULT);
  2436. if (sep && sep->arg[0][0]) {
  2437. if (strcmp(sep->arg[0], "wall") == 0) {
  2438. placement_mode = 2;
  2439. unknown2_3 = 150;
  2440. }
  2441. else if (strcmp(sep->arg[0], "ceiling") == 0)
  2442. placement_mode = 1;
  2443. else if (strcmp(sep->arg[0], "openheading") == 0 && cmdTarget->IsWidget())
  2444. {
  2445. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "[PlacementMode] WIDGET OPEN HEADING MODE");
  2446. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::OPEN_HEADING);
  2447. }
  2448. else if (strcmp(sep->arg[0], "closeheading") == 0 && cmdTarget->IsWidget())
  2449. {
  2450. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "[PlacementMode] WIDGET CLOSE HEADING MODE");
  2451. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::CLOSE_HEADING);
  2452. }
  2453. else if (strcmp(sep->arg[0], "myloc") == 0)
  2454. {
  2455. if (cmdTarget->GetSpawnLocationPlacementID() < 1) {
  2456. client->Message(CHANNEL_COLOR_YELLOW, "[PlacementMode] Spawn %s cannot be moved it is not assigned a spawn location placement id.", cmdTarget->GetName());
  2457. safe_delete(packet);
  2458. break;
  2459. }
  2460. cmdTarget->SetX(client->GetPlayer()->GetX(), true);
  2461. cmdTarget->SetY(client->GetPlayer()->GetY(), true);
  2462. cmdTarget->SetZ(client->GetPlayer()->GetZ(), true);
  2463. cmdTarget->SetHeading(client->GetPlayer()->GetHeading(), true);
  2464. if (database.UpdateSpawnLocationSpawns(cmdTarget))
  2465. client->Message(CHANNEL_COLOR_YELLOW, "[PlacementMode] Spawn %s placed at your location. Updated spawn_location_placement for spawn.", cmdTarget->GetName());
  2466. safe_delete(packet);
  2467. break;
  2468. }
  2469. }
  2470. packet->setDataByName("placement_mode", placement_mode);
  2471. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget));
  2472. packet->setDataByName("model_type", cmdTarget->GetModelType());
  2473. packet->setDataByName("unknown", 1); //size
  2474. packet->setDataByName("unknown2", 1); //size 2
  2475. packet->setDataByName("unknown2", .5, 1); //size 3
  2476. packet->setDataByName("unknown2", 3, 2);
  2477. packet->setDataByName("unknown2", unknown2_3, 3);
  2478. packet->setDataByName("max_distance", 500);
  2479. packet->setDataByName("CoEunknown", 0xFFFFFFFF);
  2480. client->QueuePacket(packet->serialize());
  2481. safe_delete(packet);
  2482. }
  2483. }
  2484. else {
  2485. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /spawn move (wall OR ceiling)");
  2486. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Moves a spawn anywhere you like. Optionally wall/ceiling can be provided to place wall/ceiling items.");
  2487. }
  2488. break;
  2489. }
  2490. case COMMAND_HAIL:{
  2491. Spawn* spawn = cmdTarget;
  2492. if(spawn && spawn->GetTargetable())
  2493. {
  2494. char tmp[75] = {0};
  2495. sprintf(tmp, "Hail, %s", spawn->GetName());
  2496. bool show_bubble = true;
  2497. if (spawn->IsNPC())
  2498. show_bubble = false;
  2499. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp, HEAR_SPAWN_DISTANCE, 0, show_bubble, client->GetPlayer()->GetCurrentLanguage());
  2500. if(spawn->IsPlayer() == false && spawn->Alive() && spawn->GetDistance(client->GetPlayer()) < rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Spawn, HailDistance)->GetInt32()){
  2501. if(spawn->IsNPC() && ((NPC*)spawn)->EngagedInCombat())
  2502. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED_BUSY, client->GetPlayer());
  2503. else
  2504. {
  2505. bool pauseRunback = false;
  2506. // prime runback as the heading or anything can be altered when hailing succeeds
  2507. if(spawn->IsNPC() && (spawn->HasMovementLoop() || spawn->HasMovementLocations()))
  2508. {
  2509. ((NPC*)spawn)->StartRunback();
  2510. pauseRunback = true;
  2511. }
  2512. if(spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED, client->GetPlayer()) && pauseRunback)
  2513. spawn->PauseMovement(rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Spawn, HailMovementPause)->GetInt32());
  2514. else if(spawn->IsNPC() && pauseRunback)
  2515. ((NPC*)spawn)->ClearRunback();
  2516. }
  2517. }
  2518. }
  2519. else {
  2520. string tmp = "Hail";
  2521. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp.c_str(), HEAR_SPAWN_DISTANCE, 0, true, client->GetPlayer()->GetCurrentLanguage());
  2522. }
  2523. break;
  2524. }
  2525. case COMMAND_SAY:{
  2526. if (sep && sep->arg[0][0]) {
  2527. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, sep->argplus[0], HEAR_SPAWN_DISTANCE, 0, true, client->GetPlayer()->GetCurrentLanguage());
  2528. if (cmdTarget && !(cmdTarget->IsPlayer()))
  2529. client->GetCurrentZone()->CallSpawnScript(cmdTarget, SPAWN_SCRIPT_HEAR_SAY, client->GetPlayer(), sep->argplus[0]);
  2530. }
  2531. else
  2532. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /say {message}");
  2533. break;
  2534. }
  2535. case COMMAND_TELL:{
  2536. if(sep && sep->arg[0] && sep->argplus[1]){
  2537. if(!zone_list.HandleGlobalChatMessage(client, sep->arg[0], CHANNEL_PRIVATE_TELL, sep->argplus[1], 0, client->GetPlayer()->GetCurrentLanguage()))
  2538. client->Message(CHANNEL_COLOR_RED,"Unable to find client %s",sep->arg[0]);
  2539. }else
  2540. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /tell {character_name} {message}");
  2541. break;
  2542. }
  2543. case COMMAND_SHOUT:{
  2544. if(sep && sep->arg[0][0])
  2545. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SHOUT, sep->argplus[0], 0, 0, true, client->GetPlayer()->GetCurrentLanguage());
  2546. else
  2547. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /shout {message}");
  2548. break;
  2549. }
  2550. case COMMAND_AUCTION:{
  2551. if(sep && sep->arg[0][0])
  2552. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_AUCTION, sep->argplus[0], 0, 0, true, client->GetPlayer()->GetCurrentLanguage());
  2553. else
  2554. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /auction {message}");
  2555. break;
  2556. }
  2557. case COMMAND_OOC:{
  2558. //For now ooc will be the global chat channel, eventually when we create more channels we will create a global chat channel
  2559. if(sep && sep->arg[0][0])
  2560. zone_list.HandleGlobalChatMessage(client, 0, CHANNEL_OUT_OF_CHARACTER, sep->argplus[0], 0, client->GetPlayer()->GetCurrentLanguage());
  2561. else
  2562. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /ooc {message}");
  2563. break;
  2564. }
  2565. case COMMAND_EMOTE:{
  2566. if(sep && sep->arg[0][0])
  2567. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_EMOTE, sep->argplus[0]);
  2568. else
  2569. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /emote {action}");
  2570. break;
  2571. }
  2572. case COMMAND_RACE:{
  2573. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  2574. if(sep->arg[1][0] && sep->IsNumber(1)){
  2575. client->GetPlayer()->GetInfoStruct()->set_race(atoi(sep->arg[1]));
  2576. client->GetPlayer()->SetRace(atoi(sep->arg[1]));
  2577. client->UpdateTimeStampFlag ( RACE_UPDATE_FLAG );
  2578. client->GetPlayer()->SetCharSheetChanged(true);
  2579. }
  2580. client->GetPlayer()->SetModelType(atoi(sep->arg[0]));
  2581. //EQ2Packet* outapp = client->GetPlayer()->spawn_update_packet(client->GetPlayer(), client->GetVersion(), client->GetPlayer()->GetFeatures());
  2582. //client->QueuePacket(outapp);
  2583. }
  2584. else{
  2585. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /race {race type id} {race id}");
  2586. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "{race id} is optional");
  2587. }
  2588. break;
  2589. }
  2590. case COMMAND_BANK_DEPOSIT:{
  2591. if(client->GetBanker() && sep && sep->arg[0]){
  2592. int64 amount = 0;
  2593. string deposit = string(sep->arg[0]);
  2594. amount = atoi64(deposit.c_str());
  2595. client->BankDeposit(amount);
  2596. }
  2597. break;
  2598. }
  2599. case COMMAND_BANK_WITHDRAWAL:{
  2600. if(client->GetBanker() && sep && sep->arg[0] && sep->IsNumber(0)){
  2601. int64 amount = 0;
  2602. string deposit = string(sep->arg[0]);
  2603. amount = atoi64(deposit.c_str());
  2604. client->BankWithdrawal(amount);
  2605. }
  2606. break;
  2607. }
  2608. case COMMAND_BANK_CANCEL:{
  2609. Spawn* banker = cmdTarget;
  2610. client->Bank(banker, true);
  2611. break;
  2612. }
  2613. case COMMAND_BANK:{
  2614. LogWrite(PLAYER__DEBUG, 0, "Players", "Open Player Personal Bank...");
  2615. Spawn* banker = cmdTarget;
  2616. client->Bank(banker);
  2617. break;
  2618. }
  2619. case COMMAND_GUILD_BANK:{
  2620. LogWrite(GUILD__DEBUG, 0, "Guilds", "Open Guild Bank...");
  2621. //Spawn* banker = client->GetPlayer()->GetTarget();
  2622. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will eventually open the guild bank!");
  2623. break;
  2624. }
  2625. case COMMAND_START_MAIL: {
  2626. client->SetMailTransaction(cmdTarget);
  2627. client->SendMailList();
  2628. break;
  2629. }
  2630. case COMMAND_CANCEL_MAIL: {
  2631. client->SetMailTransaction(0);
  2632. break;
  2633. }
  2634. case COMMAND_GET_MAIL_MESSAGE: {
  2635. if (sep && sep->arg[0] && sep->IsNumber(0))
  2636. client->DisplayMailMessage(atoul(sep->arg[0]));
  2637. break;
  2638. }
  2639. case COMMAND_ADD_MAIL_PLAT: {
  2640. if (sep && sep->arg[0] && sep->IsNumber(0))
  2641. client->AddMailCoin(0, 0, 0, atoul(sep->arg[0]));
  2642. break;
  2643. }
  2644. case COMMAND_ADD_MAIL_GOLD: {
  2645. if (sep && sep->arg[0] && sep->IsNumber(0))
  2646. client->AddMailCoin(0, 0, atoul(sep->arg[0]));
  2647. break;
  2648. }
  2649. case COMMAND_ADD_MAIL_SILVER: {
  2650. if (sep && sep->arg[0] && sep->IsNumber(0))
  2651. client->AddMailCoin(0, atoul(sep->arg[0]));
  2652. break;
  2653. }
  2654. case COMMAND_ADD_MAIL_COPPER: {
  2655. if (sep && sep->arg[0] && sep->IsNumber(0))
  2656. client->AddMailCoin(atoul(sep->arg[0]));
  2657. break;
  2658. }
  2659. case COMMAND_SET_MAIL_ITEM: {
  2660. if(sep && sep->IsNumber(0) && sep->IsNumber(1))
  2661. {
  2662. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(atoul(sep->arg[0]));
  2663. if(item)
  2664. {
  2665. int16 quantity = atoul(sep->arg[1]);
  2666. if(item->CheckFlag(NO_TRADE) || item->CheckFlag(ATTUNED) || item->CheckFlag(ARTIFACT) || item->CheckFlag2(HEIRLOOM))
  2667. {
  2668. return;
  2669. }
  2670. if(item->IsBag())
  2671. {
  2672. vector<Item*>* bag_items = player->GetPlayerItemList()->GetItemsInBag(item);
  2673. if(bag_items && bag_items->size() > 0)
  2674. {
  2675. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot mail a bag with items inside it.");
  2676. safe_delete(bag_items);
  2677. return;
  2678. }
  2679. safe_delete(bag_items);
  2680. }
  2681. Item* itemtoadd = item;
  2682. if(quantity > 0)
  2683. {
  2684. if(quantity > item->details.count)
  2685. return;
  2686. Item* tmpItem = new Item(item);
  2687. tmpItem->details.count = quantity;
  2688. itemtoadd = tmpItem;
  2689. }
  2690. if(client->AddMailItem(itemtoadd))
  2691. {
  2692. client->RemoveItem(item, quantity, true);
  2693. }
  2694. }
  2695. }
  2696. break;
  2697. }
  2698. case COMMAND_REMOVE_MAIL_PLAT: {
  2699. if (sep && sep->arg[0] && sep->IsNumber(0))
  2700. client->RemoveMailCoin(0, 0, 0, atoul(sep->arg[0]));
  2701. break;
  2702. }
  2703. case COMMAND_REMOVE_MAIL_GOLD: {
  2704. if (sep && sep->arg[0] && sep->IsNumber(0))
  2705. client->RemoveMailCoin(0, 0, atoul(sep->arg[0]));
  2706. break;
  2707. }
  2708. case COMMAND_REMOVE_MAIL_SILVER: {
  2709. if (sep && sep->arg[0] && sep->IsNumber(0))
  2710. client->RemoveMailCoin(0, atoul(sep->arg[0]));
  2711. break;
  2712. }
  2713. case COMMAND_REMOVE_MAIL_COPPER: {
  2714. if (sep && sep->arg[0] && sep->IsNumber(0))
  2715. client->RemoveMailCoin(atoul(sep->arg[0]));
  2716. break;
  2717. }
  2718. case COMMAND_TAKE_MAIL_ATTACHMENTS: {
  2719. if (sep && sep->arg[0] && sep->IsNumber(0))
  2720. client->TakeMailAttachments(atoul(sep->arg[0]));
  2721. break;
  2722. }
  2723. case COMMAND_CANCEL_SEND_MAIL: {
  2724. client->ResetSendMail();
  2725. break;
  2726. }
  2727. case COMMAND_DELETE_MAIL_MESSAGE: {
  2728. if (sep && sep->arg[0] && sep->IsNumber(0))
  2729. client->DeleteMail(atoul(sep->arg[0]), true);
  2730. break;
  2731. }
  2732. case COMMAND_REPORT_SPAM: {
  2733. LogWrite(MISC__TODO, 1, "TODO", " received reportspam\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  2734. if (sep && sep->arg[0]) LogWrite(COMMAND__DEBUG, 0, "Command", "%s\n", sep->argplus[0]);
  2735. break;
  2736. }
  2737. case COMMAND_KILL:{
  2738. Spawn* dead = 0;
  2739. if (sep && sep->arg[0] && strncasecmp(sep->arg[0],"self",4)==0){
  2740. dead=client->GetPlayer();
  2741. client->GetPlayer()->SetHP(0);
  2742. client->GetPlayer()->KillSpawn(dead);
  2743. }else{
  2744. dead= cmdTarget;
  2745. if(dead && dead->IsPlayer() == false){
  2746. if(dead->IsNPC() && ((NPC*)dead)->Brain()) {
  2747. client->GetPlayer()->CheckEncounterState((Entity*)dead);
  2748. ((NPC*)dead)->Brain()->AddToEncounter(client->GetPlayer());
  2749. ((NPC*)dead)->AddTargetToEncounter(client->GetPlayer());
  2750. ((NPC*)dead)->Brain()->AddHate(client->GetPlayer(), 1);
  2751. }
  2752. dead->SetHP(0);
  2753. if(sep && sep->arg[0] && sep->IsNumber(0) && atoi(sep->arg[0]) == 1)
  2754. client->GetCurrentZone()->RemoveSpawn(dead, true, true, true, true, true);
  2755. else
  2756. client->GetPlayer()->KillSpawn(dead);
  2757. }else{
  2758. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /kill (self)");
  2759. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Kills currently selected non-player target.");
  2760. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Optionally, self may be used to kill yourself");
  2761. }
  2762. }
  2763. break;
  2764. }
  2765. case COMMAND_LEVEL:{
  2766. if(sep && sep->arg[ndx][0] && sep->IsNumber(0)){
  2767. int16 new_level = atoi(sep->arg[ndx]);
  2768. if (!client->GetPlayer()->CheckLevelStatus(new_level))
  2769. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have the required status to level up anymore!");
  2770. else {
  2771. if (new_level < 1)
  2772. new_level = 1;
  2773. if (new_level > 255)
  2774. new_level = 255;
  2775. client->ChangeLevel(client->GetPlayer()->GetLevel(), new_level);
  2776. }
  2777. }else
  2778. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /level {new_level}");
  2779. break;
  2780. }
  2781. case COMMAND_SIT: {
  2782. if(client->GetPlayer()->GetHP() > 0){
  2783. client->QueuePacket(new EQ2Packet(OP_SitMsg, 0, 0));
  2784. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You sit down.");
  2785. client->GetPlayer()->set_character_flag(CF_IS_SITTING);
  2786. }
  2787. break;
  2788. }
  2789. case COMMAND_STAND: {
  2790. if(client->GetPlayer()->GetHP() > 0){
  2791. client->QueuePacket(new EQ2Packet(OP_StandMsg, 0, 0));
  2792. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You stand up.");
  2793. client->GetPlayer()->reset_character_flag(CF_IS_SITTING);
  2794. }
  2795. break;
  2796. }
  2797. case COMMAND_CLASS:{
  2798. if(sep && sep->arg[ndx][0]){
  2799. client->GetPlayer()->SetPlayerAdventureClass(atoi(sep->arg[ndx]));
  2800. client->UpdateTimeStampFlag ( CLASS_UPDATE_FLAG );
  2801. }else
  2802. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /class {class_id}");
  2803. break;
  2804. }
  2805. case COMMAND_FLYMODE:{
  2806. if(sep && sep->arg[0] && sep->IsNumber(0)){
  2807. PrintSep(sep, "COMMAND_FLYMODE");
  2808. int8 val = atoul(sep->arg[0]);
  2809. ClientPacketFunctions::SendFlyMode(client, val);
  2810. }
  2811. else{
  2812. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage ON: /flymode [1|2] 1 = fly, 2 = no clip");
  2813. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage OFF: /flymode 0");
  2814. }
  2815. break;
  2816. }
  2817. case COMMAND_LOOT_LIST:{
  2818. Spawn* spawn = cmdTarget;
  2819. if(spawn && spawn->IsEntity()){
  2820. if (sep && sep->arg[0]) {
  2821. if (!spawn->GetDatabaseID())
  2822. {
  2823. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "NOTE: Spawn has no database id to assign to loottables.");
  2824. }
  2825. if (!spawn->IsNPC())
  2826. {
  2827. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "these /loot list [add/remove/clearall] sub-commands are only designed for an NPC.");
  2828. break;
  2829. }
  2830. bool reloadLoot = false;
  2831. if (!stricmp(sep->arg[0], "remove") && sep->arg[1] && sep->IsNumber(1))
  2832. {
  2833. int32 loottable_id = atoul(sep->arg[1]);
  2834. if (loottable_id > 0 && database.RemoveSpawnLootTable(spawn, loottable_id))
  2835. {
  2836. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u loot table %u removed.", spawn->GetDatabaseID(), loottable_id);
  2837. reloadLoot = true;
  2838. }
  2839. else
  2840. client->Message(CHANNEL_COLOR_YELLOW, "/loot list remove [loottableid] - could not match any spawn_id entries against loottable_id %u.", loottable_id);
  2841. }
  2842. else if (!stricmp(sep->arg[0], "add") && sep->arg[1] && sep->IsNumber(1))
  2843. {
  2844. int32 loottable_id = atoul(sep->arg[1]);
  2845. if (loottable_id > 0)
  2846. {
  2847. database.AddLootTableToSpawn(spawn, loottable_id);
  2848. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u loot table %u added.", spawn->GetDatabaseID(), loottable_id);
  2849. reloadLoot = true;
  2850. }
  2851. else
  2852. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list add [loottableid] - cannot add a loottable id of 0.");
  2853. }
  2854. else if (!stricmp(sep->arg[0], "clearall"))
  2855. {
  2856. if (database.RemoveSpawnLootTable(spawn, 0))
  2857. {
  2858. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn loot tables removed.");
  2859. reloadLoot = true;
  2860. }
  2861. else
  2862. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list clearall - could not match any spawn_id entries in loottable_id.");
  2863. }
  2864. else if (!stricmp(sep->arg[0], "details"))
  2865. {
  2866. spawn->LockLoot();
  2867. client->SimpleMessage(CHANNEL_COMMANDS, "Loot Window List:");
  2868. if (spawn->GetLootWindowList()->size() > 0) {
  2869. std::map<int32, bool>::iterator itr;
  2870. for (itr = spawn->GetLootWindowList()->begin(); itr != spawn->GetLootWindowList()->end(); itr++) {
  2871. Spawn* looter = client->GetPlayer()->GetZone()->GetSpawnByID(itr->first);
  2872. if (looter) {
  2873. client->Message(CHANNEL_COLOR_YELLOW, "Looter: %s IsLootWindowOpen: %s, HasCompletedLootWindow: %s.", looter->GetName(), itr->second ? "NO" : "YES", spawn->HasSpawnLootWindowCompleted(itr->first) ? "YES" : "NO");
  2874. }
  2875. }
  2876. }
  2877. spawn->UnlockLoot();
  2878. }
  2879. else
  2880. {
  2881. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list argument not supported.");
  2882. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list add [loottableid] - add new loottable to spawn");
  2883. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list remove [loottableid] - remove existing loottable from spawn");
  2884. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list clearall - remove all loottables from spawn");
  2885. break;
  2886. }
  2887. if (reloadLoot)
  2888. {
  2889. database.LoadSpawnLoot(spawn->GetZone(), spawn);
  2890. if (spawn->IsNPC())
  2891. {
  2892. Entity* ent = (Entity*)spawn;
  2893. ent->SetLootCoins(0);
  2894. ent->ClearLoot();
  2895. spawn->GetZone()->AddLoot((NPC*)spawn);
  2896. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u active loot purged and reloaded.", spawn->GetDatabaseID());
  2897. }
  2898. }
  2899. break; // nothing further this is the end of these sub commands
  2900. }
  2901. else
  2902. {
  2903. vector<int32> loot_list = client->GetCurrentZone()->GetSpawnLootList(spawn->GetDatabaseID(), spawn->GetZone()->GetZoneID(), spawn->GetLevel(), race_types_list.GetRaceType(spawn->GetModelType()), spawn);
  2904. if (loot_list.size() > 0) {
  2905. client->Message(CHANNEL_COLOR_YELLOW, "%s belongs to the following loot lists: ", spawn->GetName());
  2906. vector<int32>::iterator list_itr;
  2907. LootTable* table = 0;
  2908. for (list_itr = loot_list.begin(); list_itr != loot_list.end(); list_itr++) {
  2909. table = client->GetCurrentZone()->GetLootTable(*list_itr);
  2910. if (table)
  2911. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", *list_itr, table->name.c_str());
  2912. }
  2913. }
  2914. client->Message(CHANNEL_COLOR_YELLOW, "Coins being carried: %u", spawn->GetLootCoins());
  2915. vector<Item*>* items = spawn->GetLootItems();
  2916. if (items) {
  2917. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is carrying the following items: ");
  2918. vector<Item*>::iterator itr;
  2919. Item* item = 0;
  2920. for (itr = items->begin(); itr != items->end(); itr++) {
  2921. item = *itr;
  2922. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", item->details.item_id, item->name.c_str());
  2923. }
  2924. }
  2925. else
  2926. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is not carrying any items.");
  2927. }
  2928. }
  2929. break;
  2930. }
  2931. case COMMAND_LOOT_SETCOIN:{
  2932. Spawn* spawn = cmdTarget;
  2933. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2934. spawn->SetLootCoins(atoul(sep->arg[0]));
  2935. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully set coins.");
  2936. }
  2937. else
  2938. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot setcoin {amount}");
  2939. break;
  2940. }
  2941. case COMMAND_LOOT_ADDITEM:{
  2942. Spawn* spawn = cmdTarget;
  2943. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2944. int16 charges = 1;
  2945. if(sep->arg[1] && sep->IsNumber(1))
  2946. charges = atoi(sep->arg[1]);
  2947. spawn->AddLootItem(atoul(sep->arg[0]), charges);
  2948. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully added item.");
  2949. }
  2950. else
  2951. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot additem {item_id}");
  2952. break;
  2953. }
  2954. case COMMAND_LOOT_REMOVEITEM:{
  2955. Spawn* spawn = cmdTarget;
  2956. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2957. Item* item = spawn->LootItem(atoul(sep->arg[0]));
  2958. lua_interface->SetLuaUserDataStale(item);
  2959. safe_delete(item);
  2960. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully removed item.");
  2961. }
  2962. else
  2963. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot removeitem {item_id}");
  2964. break;
  2965. }
  2966. case COMMAND_LOOT_CORPSE:
  2967. case COMMAND_DISARM:
  2968. case COMMAND_LOOT:{
  2969. if (cmdTarget && ((Entity*)cmdTarget)->IsNPC() && cmdTarget->Alive())
  2970. {
  2971. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is not dead.");
  2972. break;
  2973. }
  2974. if(cmdTarget && cmdTarget->IsEntity()){
  2975. if (cmdTarget->GetDistance(client->GetPlayer()) <= rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Loot, LootRadius)->GetFloat()){
  2976. if (!rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Loot, AutoDisarmChest)->GetBool() && command->handler == COMMAND_DISARM )
  2977. client->OpenChest(cmdTarget, true);
  2978. else
  2979. client->LootSpawnRequest(cmdTarget, rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Loot, AutoDisarmChest)->GetBool());
  2980. if (!(cmdTarget)->HasLoot()){
  2981. if (((Entity*)cmdTarget)->IsNPC())
  2982. client->GetCurrentZone()->RemoveDeadSpawn(cmdTarget);
  2983. }
  2984. }
  2985. else
  2986. client->Message(CHANNEL_COLOR_YELLOW, "You are too far away to interact with that");
  2987. }
  2988. else if(!cmdTarget || cmdTarget->GetHP() > 0)
  2989. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid target.");
  2990. break;
  2991. }
  2992. case COMMAND_RELOADSPAWNSCRIPTS:{
  2993. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spawn Scripts....");
  2994. if (lua_interface)
  2995. lua_interface->SetLuaSystemReloading(true);
  2996. world.ResetSpawnScripts();
  2997. database.LoadSpawnScriptData();
  2998. if(lua_interface) {
  2999. lua_interface->DestroySpawnScripts();
  3000. lua_interface->SetLuaSystemReloading(false);
  3001. }
  3002. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Success!");
  3003. break;
  3004. }
  3005. case COMMAND_RELOADREGIONSCRIPTS:{
  3006. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Region Scripts....");
  3007. if(lua_interface) {
  3008. lua_interface->DestroyRegionScripts();
  3009. }
  3010. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Success!");
  3011. break;
  3012. }
  3013. case COMMAND_RELOADLUASYSTEM:{
  3014. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Attempting to reload entire LUA system....");
  3015. world.SetReloadingSubsystem("LuaSystem");
  3016. if(lua_interface) {
  3017. lua_interface->SetLuaSystemReloading(true);
  3018. }
  3019. zone_list.DeleteSpellProcess();
  3020. if (lua_interface)
  3021. lua_interface->DestroySpells();
  3022. master_spell_list.Reload();
  3023. zone_list.LoadSpellProcess();
  3024. if(lua_interface){
  3025. map<Client*, int32> debug_clients = lua_interface->GetDebugClients();
  3026. map<Client*, int32>::iterator itr;
  3027. for(itr = debug_clients.begin(); itr != debug_clients.end(); itr++){
  3028. if(lua_interface)
  3029. lua_interface->UpdateDebugClients(itr->first);
  3030. }
  3031. }
  3032. world.ResetSpawnScripts();
  3033. database.LoadSpawnScriptData();
  3034. world.ResetZoneScripts();
  3035. database.LoadZoneScriptData();
  3036. if(lua_interface) {
  3037. lua_interface->DestroySpawnScripts();
  3038. lua_interface->DestroyRegionScripts();
  3039. lua_interface->DestroyQuests();
  3040. lua_interface->DestroyItemScripts();
  3041. lua_interface->DestroyZoneScripts();
  3042. }
  3043. int32 quest_count = database.LoadQuests();
  3044. int32 spell_count = 0;
  3045. if(lua_interface) {
  3046. spell_count = database.LoadSpellScriptData();
  3047. lua_interface->SetLuaSystemReloading(false);
  3048. }
  3049. world.RemoveReloadingSubSystem("LuaSystem");
  3050. client->Message(CHANNEL_COLOR_YELLOW, "Successfully loaded %u spell(s), %u quest(s).", spell_count, quest_count);
  3051. break;
  3052. }
  3053. case COMMAND_DECLINE_QUEST:{
  3054. int32 quest_id = 0;
  3055. if(sep && sep->arg[0] && sep->IsNumber(0))
  3056. quest_id = atoul(sep->arg[0]);
  3057. if(quest_id > 0){
  3058. client->RemovePendingQuest(quest_id);
  3059. }
  3060. break;
  3061. }
  3062. case COMMAND_DELETE_QUEST:{
  3063. int32 quest_id = 0;
  3064. if(sep && sep->arg[0] && sep->IsNumber(0))
  3065. quest_id = atoul(sep->arg[0]);
  3066. if(quest_id > 0){
  3067. client->GetPlayer()->MPlayerQuests.readlock(__FUNCTION__, __LINE__);
  3068. if(lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0) {
  3069. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  3070. client->GetPlayer()->MPlayerQuests.releasereadlock(__FUNCTION__, __LINE__);
  3071. if (quest && quest->CanDeleteQuest()) {
  3072. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  3073. client->RemovePlayerQuest(quest_id);
  3074. client->GetCurrentZone()->SendQuestUpdates(client);
  3075. }
  3076. }
  3077. else {
  3078. client->GetPlayer()->MPlayerQuests.releasereadlock(__FUNCTION__, __LINE__);
  3079. }
  3080. }
  3081. break;
  3082. }
  3083. case COMMAND_ACCEPT_QUEST:{
  3084. int32 quest_id = 0;
  3085. if(sep && sep->arg[0] && sep->IsNumber(0))
  3086. quest_id = atoul(sep->arg[0]);
  3087. if(quest_id > 0){
  3088. client->AcceptQuest(quest_id);
  3089. }
  3090. break;
  3091. }
  3092. case COMMAND_NAME:{
  3093. if(sep && sep->arg[ndx][0]){
  3094. client->GetPlayer()->GetInfoStruct()->set_name(std::string(sep->arg[ndx]).substr(0,39));
  3095. client->GetPlayer()->SetCharSheetChanged(true);
  3096. }else
  3097. client->Message(CHANNEL_COLOR_YELLOW,"Usage: /name {new_name}");
  3098. break;
  3099. }
  3100. case COMMAND_GROUP: {
  3101. if(sep && sep->arg[0])
  3102. printf("Group: %s\n",sep->argplus[0]);
  3103. break;
  3104. }
  3105. case COMMAND_GROUPSAY:{
  3106. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  3107. if(sep && sep->arg[0] && gmi) {
  3108. world.GetGroupManager()->GroupChatMessage(gmi->group_id, client->GetPlayer(), client->GetPlayer()->GetCurrentLanguage(), sep->argplus[0]);
  3109. peer_manager.SendPeersChannelMessage(gmi->group_id, std::string(client->GetPlayer()->GetName()), std::string(sep->argplus[0]), CHANNEL_GROUP_SAY, client->GetPlayer()->GetCurrentLanguage());
  3110. }
  3111. break;
  3112. }
  3113. case COMMAND_GROUPINVITE: {
  3114. Entity* target = 0;
  3115. Client* target_client = 0;
  3116. if (client->GetPlayer()->GetGroupMemberInfo() && !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  3117. client->SimpleMessage(CHANNEL_COMMANDS, "You must be the group leader to invite.");
  3118. return;
  3119. }
  3120. // name provided with command so it has to be a player, npc not supported here
  3121. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0){
  3122. target_client = zone_list.GetClientByCharName(sep->arg[0]);
  3123. if (target_client) {
  3124. if (!target_client->IsConnected() || !target_client->IsReadyForSpawns())
  3125. target = 0;
  3126. else
  3127. target = target_client->GetPlayer();
  3128. }
  3129. }
  3130. // if name was not provided use the players target, npc or player supported here
  3131. if (!target && client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  3132. target = (Entity*)client->GetPlayer()->GetTarget();
  3133. if (target->IsPlayer()) {
  3134. target_client = ((Player*)target)->GetClient();
  3135. }
  3136. }
  3137. int8 result = world.GetGroupManager()->Invite(client->GetPlayer(), target);
  3138. if (target && result == 0) {
  3139. client->Message(CHANNEL_COMMANDS, "You invite %s to group with you.", target->GetName());
  3140. if (target_client) {
  3141. client->SendReceiveOffer(target_client, 1, std::string(client->GetPlayer()->GetName()), 1);
  3142. }
  3143. }
  3144. else if (result == 1)
  3145. client->SimpleMessage(CHANNEL_COMMANDS, "That player is already in a group.");
  3146. else if (result == 2)
  3147. client->SimpleMessage(CHANNEL_COMMANDS, "That player has been invited to another group.");
  3148. else if (result == 3)
  3149. client->SimpleMessage(CHANNEL_COMMANDS, "Your group is already full.");
  3150. else if (result == 4)
  3151. client->SimpleMessage(CHANNEL_COMMANDS, "You have a pending invitation, cancel it first.");
  3152. else if (result == 5)
  3153. client->SimpleMessage(CHANNEL_COMMANDS, "You cannot invite yourself!");
  3154. else if (result == 6)
  3155. client->SimpleMessage(CHANNEL_COMMANDS, "Could not locate the player.");
  3156. else
  3157. client->SimpleMessage(CHANNEL_COMMANDS, "Group invite failed, unknown error!");
  3158. break;
  3159. }
  3160. case COMMAND_GROUPDISBAND: {
  3161. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  3162. if (gmi && gmi->leader) { // TODO: Leader check..DONE! :X
  3163. // world.GetGroupManager()->SimpleGroupMessage(gmi->group_id, "Your group has been disbanded.");
  3164. world.GetGroupManager()->RemoveGroup(gmi->group_id);
  3165. peer_manager.sendPeersDisbandGroup(gmi->group_id);
  3166. }
  3167. break;
  3168. }
  3169. case COMMAND_GROUP_LEAVE: {
  3170. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  3171. if (gmi) {
  3172. int32 group_id = gmi->group_id;
  3173. world.GetGroupManager()->RemoveGroupMember(group_id, client->GetPlayer());
  3174. if (!world.GetGroupManager()->IsGroupIDValid(group_id)) {
  3175. // leader->Message(CHANNEL_COLOR_GROUP, "%s has left the group.", client->GetPlayer()->GetName());
  3176. }
  3177. else {
  3178. world.GetGroupManager()->GroupMessage(group_id, "%s has left the group.", client->GetPlayer()->GetName());
  3179. }
  3180. client->SimpleMessage(CHANNEL_GROUP_CHAT, "You have left the group");
  3181. }
  3182. break;
  3183. }
  3184. case COMMAND_FRIEND_ADD:{
  3185. string name = "";
  3186. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  3187. name = database.GetPlayerName(sep->arg[0]);
  3188. else if(cmdTarget && cmdTarget->IsPlayer())
  3189. name = string(cmdTarget->GetName());
  3190. if(name.length() > 0){
  3191. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  3192. if(client->GetPlayer()->IsIgnored(name.c_str())){
  3193. client->GetPlayer()->RemoveIgnore(name.c_str());
  3194. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  3195. client->SendChatRelationship(3, name.c_str());
  3196. }
  3197. client->GetPlayer()->AddFriend(name.c_str(), true);
  3198. client->SendChatRelationship(0, name.c_str());
  3199. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added friend: %s", name.c_str());
  3200. if(zone_list.GetClientByCharName(name))
  3201. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Friend: %s has logged in.", name.c_str());
  3202. }
  3203. else
  3204. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot be more friendly towards yourself!");
  3205. }
  3206. else
  3207. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  3208. break;
  3209. }
  3210. case COMMAND_FRIEND_REMOVE:{
  3211. string name = "";
  3212. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  3213. name = database.GetPlayerName(sep->arg[0]);
  3214. else if(cmdTarget && cmdTarget->IsPlayer())
  3215. name = string(cmdTarget->GetName());
  3216. if(name.length() > 0){
  3217. client->GetPlayer()->RemoveFriend(name.c_str());
  3218. client->SendChatRelationship(1, name.c_str());
  3219. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  3220. }
  3221. else
  3222. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  3223. break;
  3224. }
  3225. case COMMAND_FRIENDS:{
  3226. break;
  3227. }
  3228. case COMMAND_IGNORE_ADD:{
  3229. string name = "";
  3230. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  3231. name = database.GetPlayerName(sep->arg[0]);
  3232. else if(cmdTarget && cmdTarget->IsPlayer())
  3233. name = string(cmdTarget->GetName());
  3234. if(name.length() > 0){
  3235. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  3236. if(client->GetPlayer()->IsFriend(name.c_str())){
  3237. client->GetPlayer()->RemoveFriend(name.c_str());
  3238. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  3239. client->SendChatRelationship(1, name.c_str());
  3240. }
  3241. client->GetPlayer()->AddIgnore(name.c_str(), true);
  3242. client->SendChatRelationship(2, name.c_str());
  3243. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added ignore: %s", name.c_str());
  3244. }
  3245. else
  3246. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot ignore yourself!");
  3247. }
  3248. else
  3249. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  3250. break;
  3251. }
  3252. case COMMAND_IGNORE_REMOVE:{
  3253. string name = "";
  3254. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  3255. name = database.GetPlayerName(sep->arg[0]);
  3256. else if(cmdTarget && cmdTarget->IsPlayer())
  3257. name = string(cmdTarget->GetName());
  3258. if(name.length() > 0){
  3259. client->GetPlayer()->RemoveIgnore(name.c_str());
  3260. client->SendChatRelationship(3, name.c_str());
  3261. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  3262. }
  3263. break;
  3264. }
  3265. case COMMAND_IGNORES:{
  3266. break;
  3267. }
  3268. case COMMAND_GROUP_KICK:{
  3269. Entity* kicked = 0;
  3270. Client* kicked_client = 0;
  3271. int32 group_id = 0;
  3272. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader)
  3273. return;
  3274. if (sep && sep->arg[0]) {
  3275. kicked_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  3276. if (kicked_client)
  3277. kicked = kicked_client->GetPlayer();
  3278. }
  3279. else if (cmdTarget && cmdTarget->IsEntity()) {
  3280. kicked = (Entity*)cmdTarget;
  3281. }
  3282. group_id = client->GetPlayer()->GetGroupMemberInfo()->group_id;
  3283. bool send_kicked_message = world.GetGroupManager()->GetGroupSize(group_id) > 2;
  3284. if (kicked)
  3285. world.GetGroupManager()->RemoveGroupMember(group_id, kicked);
  3286. if(send_kicked_message)
  3287. world.GetGroupManager()->GroupMessage(group_id, "%s was kicked from the group.", kicked->GetName());
  3288. else
  3289. client->Message(CHANNEL_GROUP_CHAT, "You kicked %s from the group", kicked->GetName());
  3290. if (kicked_client)
  3291. kicked_client->SimpleMessage(CHANNEL_GROUP_CHAT, "You were kicked from the group");
  3292. break;
  3293. }
  3294. case COMMAND_GROUP_MAKE_LEADER:{
  3295. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  3296. client->SimpleMessage(CHANNEL_COMMANDS, "You are not a group leader.");
  3297. return;
  3298. }
  3299. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 1) {
  3300. Client* new_leader = zone_list.GetClientByCharName(sep->arg[0]);
  3301. if (new_leader && new_leader->GetPlayer()->GetGroupMemberInfo() && new_leader->GetPlayer()->GetGroupMemberInfo()->group_id == client->GetPlayer()->GetGroupMemberInfo()->group_id) {
  3302. if (client->GetPlayer()->IsGroupMember(new_leader->GetPlayer())) {
  3303. if(world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, new_leader->GetPlayer())) {
  3304. world.GetGroupManager()->GroupMessage(client->GetPlayer()->GetGroupMemberInfo()->group_id, "%s is now leader of the group.", new_leader->GetPlayer()->GetName());
  3305. }
  3306. }
  3307. }
  3308. else
  3309. client->SimpleMessage(CHANNEL_COMMANDS, "Unable to find the given player.");
  3310. }
  3311. else if (cmdTarget && cmdTarget->IsPlayer() && ((Player*)cmdTarget)->GetGroupMemberInfo() && ((Player*)cmdTarget)->GetGroupMemberInfo()->group_id == client->GetPlayer()->GetGroupMemberInfo()->group_id) {
  3312. if(client->GetPlayer()->IsGroupMember((Player*)cmdTarget) && world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, (Entity*)cmdTarget)) {
  3313. world.GetGroupManager()->GroupMessage(client->GetPlayer()->GetGroupMemberInfo()->group_id, "%s is now leader of the group.", cmdTarget->GetName());
  3314. }
  3315. }
  3316. else
  3317. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to change group leader.");
  3318. break;
  3319. }
  3320. case COMMAND_GROUP_ACCEPT_INVITE: {
  3321. int8 result = 3;
  3322. std::string leader = world.GetGroupManager()->HasPendingInvite(client->GetPlayer());
  3323. std::string playerName(client->GetPlayer()->GetName());
  3324. Client* leader_client = client->GetCurrentZone()->GetClientByName((char*)leader.c_str());
  3325. bool group_existed = false;
  3326. if(leader_client && leader_client->GetPlayer()->GetGroupMemberInfo()) {
  3327. group_existed = true;
  3328. }
  3329. if(client->GetPlayer()->GetGroupMemberInfo() && client->GetPlayer()->GetGroupMemberInfo()->leader) {
  3330. int8 raid_result = world.GetGroupManager()->AcceptRaidInvite(std::string(client->GetPlayer()->GetName()), client->GetPlayer()->GetGroupMemberInfo()->group_id);
  3331. if(raid_result == 1) {
  3332. GroupOptions options;
  3333. if(world.GetGroupManager()->GetDefaultGroupOptions(client->GetPlayer()->GetGroupMemberInfo()->group_id, &options)) {
  3334. std::vector<int32> raidGroups;
  3335. world.GetGroupManager()->GetRaidGroups(client->GetPlayer()->GetGroupMemberInfo()->group_id, &raidGroups);
  3336. peer_manager.sendPeersNewGroupRequest("", 0, client->GetPlayer()->GetGroupMemberInfo()->group_id, "", "", &options, "", &raidGroups, true);
  3337. }
  3338. world.GetGroupManager()->ClearGroupRaidLooterFlag(client->GetPlayer()->GetGroupMemberInfo()->group_id);
  3339. world.GetGroupManager()->SendGroupUpdate(client->GetPlayer()->GetGroupMemberInfo()->group_id);
  3340. break;
  3341. }
  3342. }
  3343. if(net.is_primary) {
  3344. int32 group_id = 0;
  3345. result = world.GetGroupManager()->AcceptInvite(client->GetPlayer(), &group_id, false);
  3346. client->HandleGroupAcceptResponse(result);
  3347. if(result == 0) {
  3348. GroupOptions options;
  3349. if(leader_client) {
  3350. if(!group_existed) {
  3351. leader_client->SetGroupOptionsReference(&options);
  3352. peer_manager.sendPeersNewGroupRequest("", 0, group_id, leader, playerName, &options);
  3353. }
  3354. world.GetGroupManager()->AddGroupMember(group_id, leader_client->GetPlayer(), true);
  3355. world.GetGroupManager()->GroupMessage(leader_client->GetPlayer()->GetGroupMemberInfo()->group_id, "%s has joined the group.", playerName.c_str());
  3356. world.GetGroupManager()->AddGroupMember(leader_client->GetPlayer()->GetGroupMemberInfo()->group_id, client->GetPlayer());
  3357. }
  3358. }
  3359. }
  3360. else {
  3361. if(leader.size() < 1) {
  3362. client->HandleGroupAcceptResponse(1);
  3363. }
  3364. else {
  3365. Client* leader_client = client->GetCurrentZone()->GetClientByName((char*)leader.c_str());
  3366. GroupOptions options;
  3367. if(leader_client) {
  3368. leader_client->SetGroupOptionsReference(&options);
  3369. world.GetGroupManager()->AddInvite(leader_client->GetPlayer(), client->GetPlayer());
  3370. peer_manager.sendPrimaryNewGroupRequest(leader, playerName, client->GetPlayer()->GetID(), &options);
  3371. }
  3372. else {
  3373. client->HandleGroupAcceptResponse(2);
  3374. }
  3375. }
  3376. }
  3377. break;
  3378. }
  3379. case COMMAND_GROUP_DECLINE_INVITE: {
  3380. world.GetGroupManager()->DeclineInvite(client->GetPlayer()); // TODO: Add message to leader
  3381. break;
  3382. }
  3383. case COMMAND_SUMMON:{
  3384. char* search_name = 0;
  3385. if(sep && sep->arg[0][0])
  3386. search_name = sep->arg[0];
  3387. if(!search_name && !cmdTarget){
  3388. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /summon [name]");
  3389. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Summons a targeted spawn or a spawn by name to you. If more than one spawn matches name, it will summon closest.");
  3390. }
  3391. else{
  3392. if(!client->Summon(search_name))
  3393. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  3394. }
  3395. break;
  3396. }
  3397. case COMMAND_GOTO:{
  3398. const char* search_name = 0;
  3399. if(sep && sep->arg[0][0])
  3400. search_name = sep->argplus[0];
  3401. if(!search_name && !cmdTarget){
  3402. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /goto [name]");
  3403. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Moves to targeted spawn or to a spawn by name. If more than one spawn matches name, you will move to closest.");
  3404. }
  3405. else{
  3406. if(!client->GotoSpawn(search_name))
  3407. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  3408. }
  3409. break;
  3410. }
  3411. case COMMAND_MOVE:{
  3412. bool success = false;
  3413. try{
  3414. if(sep && sep->arg[2][0] && sep->IsNumber(0) && sep->IsNumber(1) && sep->IsNumber(2)){
  3415. EQ2Packet* app = client->GetPlayer()->Move(atof(sep->arg[0]), atof(sep->arg[1]), atof(sep->arg[2]), client->GetVersion());
  3416. if(app){
  3417. client->QueuePacket(app);
  3418. success = true;
  3419. }
  3420. }
  3421. }
  3422. catch(...){}
  3423. if(!success){
  3424. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /move x y z");
  3425. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Moves the client to the given coordinates.");
  3426. }
  3427. break;
  3428. }
  3429. case COMMAND_SETTIME:{
  3430. if(sep && sep->arg[0]){
  3431. world.MWorldTime.writelock(__FUNCTION__, __LINE__);
  3432. sscanf (sep->arg[0], "%d:%d", &world.GetWorldTimeStruct()->hour, &world.GetWorldTimeStruct()->minute);
  3433. if(sep->arg[1] && sep->IsNumber(1))
  3434. world.GetWorldTimeStruct()->month = atoi(sep->arg[1]) - 1; //zero based indexes
  3435. if(sep->arg[2] && sep->IsNumber(2))
  3436. world.GetWorldTimeStruct()->day = atoi(sep->arg[2]) - 1; //zero based indexes
  3437. if(sep->arg[3] && sep->IsNumber(3))
  3438. world.GetWorldTimeStruct()->year = atoi(sep->arg[3]);
  3439. world.MWorldTime.releasewritelock(__FUNCTION__, __LINE__);
  3440. client->GetCurrentZone()->SendTimeUpdateToAllClients();
  3441. }
  3442. else{
  3443. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /settime [hour:minute] (month) (day) (year)");
  3444. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Example: /settime 8:30");
  3445. }
  3446. break;
  3447. }
  3448. case COMMAND_VERSION:{
  3449. client->Message(CHANNEL_COLOR_YELLOW,"%s %s", EQ2EMU_MODULE, CURRENT_VERSION);
  3450. client->Message(CHANNEL_COLOR_YELLOW,"Last Compiled on %s %s", COMPILE_DATE, COMPILE_TIME);
  3451. auto [days, hours, minutes, seconds] = convertTimestampDuration((getCurrentTimestamp() - world.world_uptime));
  3452. client->Message(CHANNEL_COLOR_YELLOW,"Uptime %u day(s), %u hour(s), %u minute(s), %u second(s).", days, hours, minutes, seconds);
  3453. break;
  3454. }
  3455. case COMMAND_ZONE:{
  3456. int32 instanceID = 0;
  3457. string zone;
  3458. int32 zone_id = 0;
  3459. bool listSearch = false;
  3460. bool isInstance = false;
  3461. bool notZoningCommand = false;
  3462. ZoneServer* zsZone = 0;
  3463. ZoneChangeDetails zone_details;
  3464. if(sep && sep->arg[0][0])
  3465. {
  3466. if(strncasecmp(sep->arg[0], "list", 4) == 0)
  3467. listSearch = true;
  3468. else if(strncasecmp(sep->arg[0], "active", 6) == 0)
  3469. {
  3470. zone_list.SendZoneList(client);
  3471. notZoningCommand = true;
  3472. break;
  3473. }
  3474. else if(strncasecmp(sep->arg[0], "instance", 6) == 0)
  3475. {
  3476. if(sep->IsNumber(1))
  3477. instanceID = atol(sep->arg[1]);
  3478. }
  3479. else if(strncasecmp(sep->arg[0], "lock", 4) == 0)
  3480. {
  3481. PrintSep(sep, "ZONE LOCK");
  3482. if(sep->IsNumber(1)) {
  3483. if(zone_list.GetZone(&zone_details, atoul(sep->arg[1]), "", false, false, false, false)) {
  3484. zsZone = (ZoneServer*)zone_details.zonePtr;
  3485. }
  3486. }
  3487. else {
  3488. if(zone_list.GetZone(&zone_details, 0, std::string(sep->arg[1]), false, false, false, false)) {
  3489. zsZone = (ZoneServer*)zone_details.zonePtr;
  3490. }
  3491. }
  3492. if( zsZone )
  3493. {
  3494. zsZone->SetZoneLockState(true);
  3495. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now locked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  3496. }
  3497. else
  3498. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be locked.", sep->arg[1]);
  3499. notZoningCommand = true;
  3500. break;
  3501. }
  3502. else if(strncasecmp(sep->arg[0], "unlock", 6) == 0)
  3503. {
  3504. PrintSep(sep, "ZONE UNLOCK");
  3505. if(sep->IsNumber(1)) {
  3506. if(zone_list.GetZone(&zone_details, atoul(sep->arg[1]), "", false, false, false, false)) {
  3507. zsZone = (ZoneServer*)zone_details.zonePtr;
  3508. }
  3509. }
  3510. else {
  3511. if(zone_list.GetZone(&zone_details, 0, std::string(sep->arg[1]), false, false, false, false)) {
  3512. zsZone = (ZoneServer*)zone_details.zonePtr;
  3513. }
  3514. }
  3515. if( zsZone )
  3516. {
  3517. zsZone->SetZoneLockState(false);
  3518. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now unlocked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  3519. }
  3520. else
  3521. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be unlocked.", sep->arg[1]);
  3522. notZoningCommand = true;
  3523. break;
  3524. }
  3525. else
  3526. {
  3527. if(sep->IsNumber(0))
  3528. {
  3529. zone_id = atoul(sep->arg[0]);
  3530. string zonename = database.GetZoneName(zone_id);
  3531. if(zonename.length() > 0)
  3532. zone = zonename;
  3533. }
  3534. else
  3535. zone = sep->arg[0];
  3536. }
  3537. if(instanceID > 0)
  3538. {
  3539. if(zone_list.GetZoneByInstance(&zone_details, instanceID, 0, true)) {
  3540. instanceID = zone_details.instanceId;
  3541. zone = zone_details.zoneName;
  3542. zone_id = zone_details.zoneId;
  3543. }
  3544. isInstance = true;
  3545. }
  3546. }
  3547. if(!listSearch)
  3548. {
  3549. if(zone.length() == 0)
  3550. client->Message(CHANNEL_COLOR_RED, "Error: Invalid Zone");
  3551. else if(instanceID != client->GetCurrentZone()->GetInstanceID() ||
  3552. zone_id != client->GetCurrentZone()->GetZoneID())
  3553. {
  3554. const char* zonestr = zone.c_str();
  3555. if(database.VerifyZone(zonestr))
  3556. {
  3557. if(client->CheckZoneAccess(zonestr))
  3558. {
  3559. client->Message(CHANNEL_COLOR_YELLOW,"Zoning to %s...", zonestr);
  3560. if(isInstance)
  3561. client->Zone(&zone_details,(ZoneServer*)zone_details.zonePtr,true,false);
  3562. else
  3563. client->Zone(zonestr);
  3564. }
  3565. }
  3566. else
  3567. client->Message(CHANNEL_COLOR_RED, "Error: Zone '%s' not found. To get a list type /zone list", zonestr);
  3568. }
  3569. else
  3570. client->Message(CHANNEL_COLOR_RED, "Error: You are already in that zone!");
  3571. }
  3572. else
  3573. {
  3574. const char* name = 0;
  3575. if(sep && sep->arg[1][0])
  3576. {
  3577. map<int32, string>* zone_names;
  3578. name = sep->argplus[1];
  3579. sint16 status = client->GetAdminStatus();
  3580. if( status > 0 )
  3581. {
  3582. client->SimpleMessage(CHANNEL_COLOR_RED, "ADMIN MODE");
  3583. zone_names = database.GetZoneList(name, true);
  3584. }
  3585. else
  3586. zone_names = database.GetZoneList(name);
  3587. if(!zone_names)
  3588. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No zones found.");
  3589. else
  3590. {
  3591. map<int32, string>::iterator itr;
  3592. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  3593. for(itr = zone_names->begin(); itr != zone_names->end(); itr++)
  3594. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  3595. safe_delete(zone_names);
  3596. }
  3597. }
  3598. else
  3599. {
  3600. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone [zone name]");
  3601. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone list [partial zone name]");
  3602. }
  3603. }
  3604. break;
  3605. }
  3606. case COMMAND_USE: {
  3607. Spawn* target = cmdTarget;
  3608. if (target && target->IsWidget())
  3609. ((Widget*)target)->HandleUse(client, "use");
  3610. break;
  3611. }
  3612. case COMMAND_OPEN: {
  3613. Spawn* target = cmdTarget;
  3614. if (target && target->IsWidget())
  3615. ((Widget*)target)->HandleUse(client, "Open", WIDGET_TYPE_DOOR);
  3616. break;
  3617. }
  3618. case COMMAND_CASTSPELL: {
  3619. if (sep && sep->arg[0] && sep->IsNumber(0))
  3620. {
  3621. int8 tier = 1;
  3622. if (sep->arg[1] && sep->IsNumber(1))
  3623. tier = atoul(sep->arg[1]);
  3624. int8 self = 1;
  3625. if (sep->arg[1] && sep->IsNumber(2))
  3626. {
  3627. self = atoul(sep->arg[2]);
  3628. if(self != 1 && !cmdTarget->IsEntity())
  3629. {
  3630. client->Message(CHANNEL_COLOR_RED, "Target is not an entity required to cast non-self spell.");
  3631. self = 1;
  3632. }
  3633. }
  3634. int32 spellid = atoul(sep->arg[0]);
  3635. Spell* spell = master_spell_list.GetSpell(spellid, tier);
  3636. if (spell)
  3637. {
  3638. client->Message(CHANNEL_COLOR_RED, "Casting spell %u.", spellid);
  3639. SpellProcess* spellProcess = 0;
  3640. // Get the current zones spell process
  3641. spellProcess = client->GetCurrentZone()->GetSpellProcess();
  3642. spellProcess->CastInstant(spell, (!cmdTarget || self == 1) ? (Entity*)client->GetPlayer() : (Entity*)cmdTarget, (cmdTarget && cmdTarget->IsEntity()) ? (Entity*)cmdTarget : (Entity*)client->GetPlayer());
  3643. }
  3644. else
  3645. {
  3646. client->Message(CHANNEL_COLOR_RED, "Could not find spell %u.",spellid);
  3647. }
  3648. }
  3649. else if (sep && sep->arg[0])
  3650. {
  3651. database.FindSpell(client, (char*)sep->argplus[0]);
  3652. }
  3653. else
  3654. {
  3655. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellid] (tier=1) - Cast Spell with specified spell id, tier is optional, default of 1.");
  3656. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellname] - Find spells wildcard match with a partial spell name");
  3657. }
  3658. break;
  3659. }
  3660. case COMMAND_KNOWLEDGEWINDOWSORT: {
  3661. if (sep && (client->GetVersion() <= 561 && sep->GetArgNumber() == 3) || sep->GetArgNumber() == 4)
  3662. {
  3663. int32 book = atoul(sep->arg[0]); // 0 - spells, 1 - combat, 2 - abilities, 3 - tradeskill
  3664. // cannot sort the ability book in this client it is greyed out
  3665. if (client->GetVersion() <= 561 && book == SPELL_BOOK_TYPE_ABILITY)
  3666. break;
  3667. int32 sort_by = atoul(sep->arg[1]); // 0 - alpha, 1 - level, 2 - category
  3668. int32 order = atoul(sep->arg[2]); // 0 - ascending, 1 - descending
  3669. int32 pattern = atoul(sep->arg[3]); // 0 - zigzag, 1 - down, 2 - across
  3670. int32 maxlvlonly = 0;
  3671. if(client->GetVersion() > 561 && sep->arg[4][0]) {
  3672. maxlvlonly = atoul(sep->arg[4]); // checkbox for newer clients
  3673. }
  3674. client->GetPlayer()->ResortSpellBook(sort_by, order, pattern, maxlvlonly, book);
  3675. ClientPacketFunctions::SendSkillSlotMappings(client);
  3676. }
  3677. else
  3678. {
  3679. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /knowledgewindow_sort [book] [sort_by] [order] [pattern]");
  3680. }
  3681. break;
  3682. }
  3683. case COMMAND_MOVE_ITEM:
  3684. {
  3685. int32 id = 0;
  3686. if (sep && sep->IsNumber(0))
  3687. id = atoul(sep->arg[0]);
  3688. Spawn* spawn = 0;
  3689. if (id == 0)
  3690. {
  3691. spawn = cmdTarget;
  3692. }
  3693. else
  3694. spawn = client->GetCurrentZone()->GetSpawnFromUniqueItemID(id);
  3695. if (!spawn || !client->HasOwnerOrEditAccess() || !spawn->GetPickupItemID())
  3696. break;
  3697. Item* item = master_item_list.GetItem(spawn->GetPickupItemID());
  3698. client->SendMoveObjectMode(spawn, (item && item->houseitem_info) ? item->houseitem_info->house_location : 0);
  3699. break;
  3700. }
  3701. case COMMAND_PICKUP:
  3702. {
  3703. int32 id = 0;
  3704. if (sep && sep->IsNumber(0))
  3705. id = atoul(sep->arg[0]);
  3706. Spawn* spawn = 0;
  3707. if (id == 0)
  3708. {
  3709. spawn = cmdTarget;
  3710. }
  3711. else
  3712. spawn = client->GetCurrentZone()->GetSpawnFromUniqueItemID(id);
  3713. if (!spawn || !client->HasOwnerOrEditAccess() || !spawn->GetPickupItemID())
  3714. break;
  3715. if(client->AddItem(spawn->GetPickupItemID(), 1)) {
  3716. Query query;
  3717. query.RunQuery2(Q_INSERT, "delete from spawn_instance_data where spawn_id = %u and spawn_location_id = %u and pickup_item_id = %u", spawn->GetDatabaseID(), spawn->GetSpawnLocationID(), spawn->GetPickupItemID());
  3718. if (database.RemoveSpawnFromSpawnLocation(spawn)) {
  3719. client->GetCurrentZone()->RemoveSpawn(spawn, true, true, true, true, true);
  3720. }
  3721. // we had a UI Window displayed, update the house items
  3722. if ( id > 0 )
  3723. client->GetCurrentZone()->SendHouseItems(client);
  3724. }
  3725. break;
  3726. }
  3727. case COMMAND_HOUSE_DEPOSIT:
  3728. {
  3729. PrintSep(sep, "COMMAND_HOUSE_DEPOSIT");
  3730. // arg0 = spawn_id for DoF, could also be house_id for newer clients
  3731. // arg1 = coin (in copper)
  3732. // arg2 = status? (not implemented yet)
  3733. PlayerHouse* ph = nullptr;
  3734. int32 spawn_id = 0;
  3735. if(sep && sep->arg[0]) {
  3736. spawn_id = atoul(sep->arg[0]);
  3737. ph = world.GetPlayerHouse(client, spawn_id, client->GetVersion() > 561 ? spawn_id : 0, nullptr);
  3738. }
  3739. if(!ph) {
  3740. ph = world.GetPlayerHouseByInstanceID(client->GetCurrentZone()->GetInstanceID());
  3741. }
  3742. if (ph && sep && sep->IsNumber(1))
  3743. {
  3744. int64 outValCoin = strtoull(sep->arg[1], NULL, 0);
  3745. int32 outValStatus = 0;
  3746. if(sep->IsNumber(2))
  3747. {
  3748. outValStatus = strtoull(sep->arg[2], NULL, 0);
  3749. if(outValStatus > client->GetPlayer()->GetInfoStruct()->get_status_points())
  3750. outValStatus = 0; // cheat check
  3751. }
  3752. if ((!outValCoin && outValStatus) || client->GetPlayer()->RemoveCoins(outValCoin))
  3753. {
  3754. if(outValStatus)
  3755. client->GetPlayer()->GetInfoStruct()->subtract_status_points(outValStatus);
  3756. char query[256];
  3757. map<string,Deposit>::iterator itr = ph->depositsMap.find(string(client->GetPlayer()->GetName()));
  3758. if (itr != ph->depositsMap.end())
  3759. {
  3760. snprintf(query, 256, "update character_house_deposits set timestamp = %u, amount = amount + %llu, last_amount = %llu, status = status + %u, last_status = %u where house_id = %u and instance_id = %u and name='%s'", Timer::GetUnixTimeStamp(), outValCoin, outValCoin, outValStatus, outValStatus, ph->house_id, ph->instance_id, client->GetPlayer()->GetName());
  3761. }
  3762. else
  3763. snprintf(query, 256, "insert into character_house_deposits set timestamp = %u, house_id = %u, instance_id = %u, name='%s', amount = %llu, status = %u", Timer::GetUnixTimeStamp(), ph->house_id, ph->instance_id, client->GetPlayer()->GetName(), outValCoin, outValStatus);
  3764. if (database.RunQuery(query, strnlen(query, 256)))
  3765. {
  3766. ph->escrow_coins += outValCoin;
  3767. ph->escrow_status += outValStatus;
  3768. database.UpdateHouseEscrow(ph->house_id, ph->instance_id, ph->escrow_coins, ph->escrow_status);
  3769. database.LoadDeposits(ph);
  3770. client->PlaySound("coin_cha_ching");
  3771. HouseZone* hz = world.GetHouseZone(ph->house_id);
  3772. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetVersion() <= 561 ? spawn_id : client->GetPlayer()->GetID());
  3773. }
  3774. else
  3775. {
  3776. if(outValCoin)
  3777. client->GetPlayer()->AddCoins(outValCoin);
  3778. if(outValStatus)
  3779. client->GetPlayer()->GetInfoStruct()->add_status_points(outValStatus);
  3780. client->SimpleMessage(CHANNEL_COLOR_RED, "Deposit failed!");
  3781. }
  3782. }
  3783. }
  3784. break;
  3785. }
  3786. case COMMAND_HOUSE:
  3787. {
  3788. int32 spawn_id = 0;
  3789. if (sep && sep->IsNumber(0))
  3790. {
  3791. PlayerHouse* ph = nullptr;
  3792. if(!ph && sep && sep->arg[0]) {
  3793. spawn_id = atoul(sep->arg[0]);
  3794. ph = world.GetPlayerHouse(client, spawn_id, spawn_id, nullptr);
  3795. }
  3796. HouseZone* hz = 0;
  3797. if (ph)
  3798. hz = world.GetHouseZone(ph->house_id);
  3799. // there is a arg[1] that is true/false, but not sure what it is for investigate more later
  3800. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetVersion() <= 561 ? spawn_id : client->GetPlayer()->GetID());
  3801. }
  3802. else if (client->GetCurrentZone()->GetInstanceType() != 0)
  3803. {
  3804. // inside a house or something? Send the access window
  3805. PlayerHouse* ph = world.GetPlayerHouseByInstanceID(client->GetCurrentZone()->GetInstanceID());
  3806. HouseZone* hz = 0;
  3807. if ( ph )
  3808. hz = world.GetHouseZone(ph->house_id);
  3809. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetVersion() <= 561 ? spawn_id : client->GetPlayer()->GetID());
  3810. client->GetCurrentZone()->SendHouseItems(client);
  3811. }
  3812. break;
  3813. }
  3814. case COMMAND_HOUSE_UI:
  3815. {
  3816. if (sep && sep->IsNumber(0) && client->GetCurrentZone()->GetInstanceType() == Instance_Type::NONE)
  3817. {
  3818. int32 unique_id = atoi(sep->arg[0]);
  3819. PlayerHouse* ph = world.GetPlayerHouseByUniqueID(unique_id);
  3820. HouseZone* hz = 0;
  3821. if ( ph )
  3822. hz = world.GetHouseZone(ph->house_id);
  3823. // there is a arg[1] that is true/false, but not sure what it is for investigate more later
  3824. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  3825. }
  3826. break;
  3827. }
  3828. case COMMAND_PLACE_HOUSE_ITEM: {
  3829. if (sep && sep->IsNumber(0))
  3830. {
  3831. int32 uniqueid = atoi(sep->arg[0]);
  3832. Item* item = client->GetPlayer()->item_list.GetItemFromUniqueID(uniqueid);
  3833. //Item* item = player->GetEquipmentList()->GetItem(slot);
  3834. if (item && item->IsHouseItem())
  3835. {
  3836. if (!client->HasOwnerOrEditAccess())
  3837. {
  3838. client->SimpleMessage(CHANNEL_COLOR_RED, "This is not your home!");
  3839. break;
  3840. }
  3841. else if (!item->generic_info.appearance_id)
  3842. {
  3843. client->Message(CHANNEL_COLOR_RED, "This item has not been configured in the database, %s (%u) needs an entry where ?? has the model type id, eg. insert into item_appearances set item_id=%u,equip_type=??;", item->name.c_str(), item->details.item_id, item->details.item_id);
  3844. break;
  3845. }
  3846. else if(item->CheckFlag2(HOUSE_LORE) && client->GetCurrentZone()->HouseItemSpawnExists(item->details.item_id)) {
  3847. client->Message(CHANNEL_COLOR_RED, "Item %s is house lore and you cannot place another.", item->name.c_str());
  3848. break;
  3849. }
  3850. if (client->GetTempPlacementSpawn())
  3851. {
  3852. Spawn* tmp = client->GetTempPlacementSpawn();
  3853. client->GetCurrentZone()->RemoveSpawn(tmp, true, true, true, true, true);
  3854. client->SetTempPlacementSpawn(nullptr);
  3855. }
  3856. Object* obj = new Object();
  3857. Spawn* spawn = (Spawn*)obj;
  3858. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3859. strcpy(spawn->appearance.name, "temp");
  3860. spawn->SetX(client->GetPlayer()->GetX());
  3861. spawn->SetY(client->GetPlayer()->GetY());
  3862. spawn->SetZ(client->GetPlayer()->GetZ());
  3863. spawn->appearance.pos.collision_radius = 32;
  3864. spawn->SetHeading(client->GetPlayer()->GetHeading());
  3865. spawn->SetSpawnOrigX(spawn->GetX());
  3866. spawn->SetSpawnOrigY(spawn->GetY());
  3867. spawn->SetSpawnOrigZ(spawn->GetZ());
  3868. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  3869. spawn->appearance.targetable = 1;
  3870. spawn->appearance.activity_status = ACTIVITY_STATUS_SOLID;
  3871. spawn->appearance.race = item && item->generic_info.appearance_id ? item->generic_info.appearance_id : 1472;
  3872. spawn->SetModelType(item && item->generic_info.appearance_id ? item->generic_info.appearance_id : 1472);
  3873. spawn->SetLocation(client->GetPlayer()->GetLocation());
  3874. spawn->SetZone(client->GetCurrentZone());
  3875. client->SetTempPlacementSpawn(spawn);
  3876. client->SetPlacementUniqueItemID(uniqueid);
  3877. client->GetCurrentZone()->AddSpawn(spawn);
  3878. }
  3879. }
  3880. break;
  3881. }
  3882. case COMMAND_GM:
  3883. {
  3884. if (sep && sep->arg[0] && sep->arg[1])
  3885. {
  3886. bool onOff = (strcmp(sep->arg[1], "on") == 0);
  3887. if (strcmp(sep->arg[0], "vision") == 0)
  3888. {
  3889. client->GetPlayer()->SetGMVision(onOff);
  3890. #if defined(__GNUC__)
  3891. database.insertCharacterProperty(client, CHAR_PROPERTY_GMVISION, (onOff) ? (char*)"1" : (char*)"0");
  3892. #else
  3893. database.insertCharacterProperty(client, CHAR_PROPERTY_GMVISION, (onOff) ? "1" : "0");
  3894. #endif
  3895. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3896. if (onOff)
  3897. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Vision Enabled!");
  3898. else
  3899. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Vision Disabled!");
  3900. }
  3901. else if (strcmp(sep->arg[0], "tag") == 0)
  3902. {
  3903. int32 value = 0;
  3904. int16 tag_icon = 0;
  3905. // groundspawn has special exception -1 argument so it needs to be handled here
  3906. if(sep->arg[2] && sep->arg[3] && ((tag_icon = atoul(sep->arg[3])) > 0) || (strncasecmp(sep->arg[1], "groundspawn", 11) == 0)) {
  3907. value = atoul(sep->arg[2]);
  3908. if(strncasecmp(sep->arg[1], "faction", 7) == 0){
  3909. if(!value) {
  3910. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid faction id.");
  3911. break;
  3912. }
  3913. if(!tag_icon) {
  3914. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid tag icon id.");
  3915. break;
  3916. }
  3917. client->GetPlayer()->AddGMVisualFilter(GMTagFilterType::GMFILTERTYPE_FACTION, value, "", tag_icon);
  3918. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3919. client->Message(CHANNEL_COLOR_RED, "Adding faction id %u with tag icon %u.", value, tag_icon);
  3920. }
  3921. else if(strncasecmp(sep->arg[1], "spawngroup", 10) == 0){
  3922. if(value>0) {
  3923. value = 1;
  3924. }
  3925. if(!tag_icon) {
  3926. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid tag icon id.");
  3927. break;
  3928. }
  3929. client->GetPlayer()->AddGMVisualFilter(GMTagFilterType::GMFILTERTYPE_SPAWNGROUP, value, "", tag_icon);
  3930. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3931. client->Message(CHANNEL_COLOR_RED, "Adding spawn group tag \"%s\" with tag icon %u.", (value == 1) ? "on" : "off", tag_icon);
  3932. }
  3933. else if(strncasecmp(sep->arg[1], "race", 4 == 0)){
  3934. if(!value) {
  3935. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid race id.");
  3936. break;
  3937. }
  3938. if(!tag_icon) {
  3939. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid tag icon id.");
  3940. break;
  3941. }
  3942. client->GetPlayer()->AddGMVisualFilter(GMTagFilterType::GMFILTERTYPE_RACE, value, "", tag_icon);
  3943. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3944. client->Message(CHANNEL_COLOR_RED, "Adding race id %u with tag icon %u.", value, tag_icon);
  3945. }
  3946. else if(strncasecmp(sep->arg[1], "groundspawn", 11) == 0){
  3947. // one less argument value field not tag_icon for this one
  3948. if(!value) {
  3949. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid tag icon id.");
  3950. break;
  3951. }
  3952. client->GetPlayer()->AddGMVisualFilter(GMTagFilterType::GMFILTERTYPE_GROUNDSPAWN, 1, "", value);
  3953. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3954. client->Message(CHANNEL_COLOR_RED, "Adding groundspawns with tag icon %u.", value);
  3955. }
  3956. }
  3957. else {
  3958. if(strncasecmp(sep->arg[1], "clear", 5) == 0){
  3959. client->GetPlayer()->ClearGMVisualFilters();
  3960. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Tags Cleared!");
  3961. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3962. }
  3963. else {
  3964. client->SimpleMessage(CHANNEL_COLOR_RED, "GM Tagging Missing Arguments:");
  3965. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/gm tag [type] [value] [visual_icon_display]");
  3966. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/gm tag clear - Clears all GM visual tags");
  3967. client->SimpleMessage(CHANNEL_COLOR_RED, "Visual Type Options:");
  3968. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "type: faction, value: faction id of spawn(s)");
  3969. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "type: spawngroup, value: 1 to show grouped, 0 to show not grouped");
  3970. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "type: race, value: race id (either against base race or race id in spawn details)");
  3971. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "type: groundspawn, value: (not used)");
  3972. client->SimpleMessage(CHANNEL_COLOR_RED, "Visual Icon Options:");
  3973. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3974. "1 = skull, 2 = shield half dark blue / half light blue, 3 = purple? star, 4 = yellow sword, 5 = red X, 6 = green flame");
  3975. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3976. "7 = Number \"1\", 8 = Number \"2\", 9 = Number \"3\", 10 = Number \"4\", 11 = Number \"5\", 12 = Number \"6\"");
  3977. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3978. "25 = shield, 26 = green plus, 27 = crossed swords, 28 = bow with arrow in it, 29 = light blue lightning bolt");
  3979. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3980. "30 = bard instrument (hard to see), 31 = writ with shield, 32 = writ with green +, 33 = writ with crossed sword");
  3981. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3982. "34 = writ with bow, 35 = writ with light blue lightning bolt, 36 = same as 30, 37 = party with crossed sword, shield and lightning bolt");
  3983. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3984. "38 = shaking hands green background, 39 = shaking hands dark green background, unlocked keylock");
  3985. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3986. "40 = red aura icon with black shadow of person and big red aura, 41 = green aura icon with black shadow of person big green aura");
  3987. }
  3988. }
  3989. }
  3990. else if (strcmp(sep->arg[0], "regiondebug") == 0)
  3991. {
  3992. client->SetRegionDebug(onOff);
  3993. #if defined(__GNUC__)
  3994. database.insertCharacterProperty(client, CHAR_PROPERTY_REGIONDEBUG, (onOff) ? (char*)"1" : (char*)"0");
  3995. #else
  3996. database.insertCharacterProperty(client, CHAR_PROPERTY_REGIONDEBUG, (onOff) ? "1" : "0");
  3997. #endif
  3998. if (onOff)
  3999. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Region Debug Enabled!");
  4000. else
  4001. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Region Debug Disabled!");
  4002. }
  4003. else if (strcmp(sep->arg[0], "sight") == 0)
  4004. {
  4005. if(onOff && cmdTarget) {
  4006. client->SetPlayerPOVGhost(cmdTarget);
  4007. }
  4008. else
  4009. client->SetPlayerPOVGhost(nullptr);
  4010. }
  4011. else if (strcmp(sep->arg[0], "controleffects") == 0)
  4012. {
  4013. if(cmdTarget && cmdTarget->IsEntity()) {
  4014. ((Entity*)cmdTarget)->SendControlEffectDetailsToClient(client);
  4015. }
  4016. else {
  4017. client->GetPlayer()->SendControlEffectDetailsToClient(client);
  4018. }
  4019. }
  4020. else if (strcmp(sep->arg[0], "luadebug") == 0)
  4021. {
  4022. client->SetLuaDebugClient(onOff);
  4023. #if defined(__GNUC__)
  4024. database.insertCharacterProperty(client, CHAR_PROPERTY_LUADEBUG, (onOff) ? (char*)"1" : (char*)"0");
  4025. #else
  4026. database.insertCharacterProperty(client, CHAR_PROPERTY_LUADEBUG, (onOff) ? "1" : "0");
  4027. #endif
  4028. if (onOff)
  4029. {
  4030. if (lua_interface)
  4031. lua_interface->UpdateDebugClients(client);
  4032. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will now receive LUA error messages.");
  4033. }
  4034. else
  4035. {
  4036. if (lua_interface)
  4037. lua_interface->RemoveDebugClients(client);
  4038. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will no longer receive LUA error messages.");
  4039. }
  4040. }
  4041. }
  4042. break;
  4043. }
  4044. case COMMAND_ATTACK:
  4045. case COMMAND_AUTO_ATTACK:{
  4046. Command_AutoAttack(client, sep);
  4047. break;
  4048. }
  4049. case COMMAND_DEPOP:{
  4050. bool allow_respawns = false;
  4051. if(sep && sep->arg[0] && sep->IsNumber(0)){
  4052. if(atoi(sep->arg[0]) == 1)
  4053. allow_respawns = true;
  4054. }
  4055. client->GetCurrentZone()->Depop(allow_respawns);
  4056. break;
  4057. }
  4058. case COMMAND_REPOP:{
  4059. client->GetCurrentZone()->Depop(false, true);
  4060. break;
  4061. }
  4062. case COMMAND_BUYBACK:{
  4063. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  4064. // Item ID and Unique ID get combined in this command so we need to get the number as an int64 and break it into 2 int32's
  4065. int64 id = atoi64(sep->arg[0]);
  4066. // get the first int32, the item id
  4067. //int32 item_id = (int32)id;
  4068. // get the second int32, the unique id
  4069. int32 unique_id = (int32)(id>>32);
  4070. int8 quantity = atoi(sep->arg[1]);
  4071. if(quantity == 255)
  4072. quantity = 1;
  4073. client->BuyBack(unique_id, quantity);
  4074. }
  4075. break;
  4076. }
  4077. case COMMAND_MERCHANT_BUY:{
  4078. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  4079. int32 item_id = atoul(sep->arg[0]);
  4080. int8 quantity = atoi(sep->arg[1]);
  4081. client->BuyItem(item_id, quantity);
  4082. }
  4083. else
  4084. Command_SendMerchantWindow(client, sep);
  4085. break;
  4086. }
  4087. case COMMAND_MERCHANT_SELL:{
  4088. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  4089. // Item ID and Unique ID get combined in this command so we need to get the number as an int64 and break it into 2 int32's
  4090. int64 id = atoi64(sep->arg[0]);
  4091. // get the first int32, the item id
  4092. int32 item_id = (int32)id;
  4093. // get the second int32, the unique id
  4094. int32 unique_id = (int32)(id>>32);
  4095. int8 quantity = atoi(sep->arg[1]);
  4096. LogWrite(MERCHANT__DEBUG, 0, "Merchant", "Selling Item: Item Id = %ul, unique id = %ul, Quantity = %i", item_id, unique_id, quantity);
  4097. client->SellItem(item_id, quantity, unique_id);
  4098. }
  4099. break;
  4100. }
  4101. case COMMAND_MENDER_REPAIR: {
  4102. if (sep && sep->arg[0] && sep->IsNumber(0))
  4103. client->RepairItem(atoul(sep->arg[0]));
  4104. break;
  4105. }
  4106. case COMMAND_MENDER_REPAIR_ALL: {
  4107. client->RepairAllItems();
  4108. break;
  4109. }
  4110. case COMMAND_CANCEL_MERCHANT:{
  4111. client->SetMerchantTransaction(0);
  4112. break;
  4113. }
  4114. case COMMAND_START_MERCHANT:{
  4115. break;
  4116. }
  4117. case COMMAND_INVULNERABLE:{
  4118. sint8 val = -1;
  4119. if(sep && sep->arg[0] && sep->IsNumber(0)){
  4120. val = atoi(sep->arg[0]);
  4121. //devn00b: Fix for linux builds
  4122. #if defined(__GNUC__)
  4123. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? (char*) "1" : (char*) "0");
  4124. #else
  4125. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  4126. #endif
  4127. // database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  4128. client->GetPlayer()->SetInvulnerable(val==1);
  4129. if(client->GetPlayer()->GetInvulnerable())
  4130. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are now invulnerable!");
  4131. else
  4132. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are no longer invulnerable!");
  4133. }
  4134. if(val == -1)
  4135. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /invulnerable [0/1]");
  4136. break;
  4137. }
  4138. case COMMAND_REPAIR: {
  4139. Spawn* spawn = cmdTarget;
  4140. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR) {
  4141. client->SendHailCommand(spawn);
  4142. client->SetMerchantTransaction(spawn);
  4143. client->SendRepairList();
  4144. }
  4145. break;
  4146. }
  4147. case COMMAND_LOTTO: {
  4148. Spawn* spawn = cmdTarget;
  4149. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_LOTTO) {
  4150. client->SetMerchantTransaction(spawn);
  4151. client->ShowLottoWindow();
  4152. }
  4153. break;
  4154. }
  4155. case COMMAND_ACCEPT_REWARD:{
  4156. int32 unknown = 0;
  4157. int32 selectable_item_id = 0;
  4158. //Quest *quest = 0;
  4159. /* no idea what the first argument is for (faction maybe?)
  4160. if the reward has a selectable item reward, it's sent as the second argument
  4161. if neither of these are included in the reward, there is no sep
  4162. since the regular item rewards are manditary to receive, we don't have to know what they are until we accept the collection or quest
  4163. only 1 quest or collection reward may be displayed at a time */
  4164. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  4165. unknown = atoul(sep->arg[0]);
  4166. selectable_item_id = atoul(sep->arg[1]);
  4167. }
  4168. /* this logic here may seem unexpected, but the quest queue response for GetPendingQuestAcceptance is only populated if it is the current reward displayed to the client based on a quest
  4169. ** Otherwise it will likely be a DoF client scenario (pending item rewards, selectable item rewards) which is specifying an item id
  4170. ** lastly it will be a collection which also supplies an item id and you can only have one pending collection turn in at a time (they queue against Client::HandInCollections
  4171. */
  4172. int32 item_id = 0;
  4173. if(sep && sep->arg[0][0] && sep->IsNumber(0))
  4174. item_id = atoul(sep->arg[0]);
  4175. bool collectedItems = client->GetPlayer()->AcceptQuestReward(item_id, selectable_item_id);
  4176. if (collectedItems) {
  4177. EQ2Packet* outapp = client->GetPlayer()->SendInventoryUpdate(client->GetVersion());
  4178. if (outapp)
  4179. client->QueuePacket(outapp);
  4180. }
  4181. else
  4182. LogWrite(COMMAND__ERROR, 0, "Command", "Error in COMMAND_ACCEPT_REWARD. No pending quest or collection reward was found (unknown=%u).", unknown);
  4183. break;
  4184. }
  4185. case COMMAND_BUY_FROM_BROKER:{
  4186. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  4187. int32 item_id = atoul(sep->arg[0]);
  4188. int16 quantity = atoul(sep->arg[1]);
  4189. Item* item = master_item_list.GetItem(item_id);
  4190. if(item && item->generic_info.max_charges > 1)
  4191. quantity = item->generic_info.max_charges;
  4192. client->AddItem(item_id, quantity, AddItemType::BUY_FROM_BROKER);
  4193. }
  4194. break;
  4195. }
  4196. case COMMAND_SEARCH_STORES_PAGE:{
  4197. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  4198. int32 page = atoul(sep->arg[0]);
  4199. client->SearchStore(page);
  4200. }
  4201. break;
  4202. }
  4203. case COMMAND_SEARCH_STORES:{
  4204. if(sep && sep->arg[0][0]){
  4205. const char* values = sep->argplus[0];
  4206. if(values){
  4207. LogWrite(ITEM__WARNING, 0, "Item", "SearchStores: %s", values);
  4208. map<string, string> str_values = TranslateBrokerRequest(values);
  4209. vector<Item*>* items = master_item_list.GetItems(str_values, client);
  4210. if(items){
  4211. client->SetItemSearch(items);
  4212. client->SearchStore(0);
  4213. }
  4214. }
  4215. }
  4216. break;
  4217. }
  4218. case COMMAND_LUADEBUG:{
  4219. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "start") == 0){
  4220. client->SetLuaDebugClient(true);
  4221. if(lua_interface)
  4222. lua_interface->UpdateDebugClients(client);
  4223. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will now receive LUA error messages.");
  4224. }
  4225. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "stop") == 0){
  4226. client->SetLuaDebugClient(false);
  4227. if(lua_interface)
  4228. lua_interface->RemoveDebugClients(client);
  4229. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will no longer receive LUA error messages.");
  4230. }
  4231. else{
  4232. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /luadebug {start | stop}");
  4233. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will allow you to receive lua debug messages normally seen only in the console.");
  4234. }
  4235. break;
  4236. }
  4237. case COMMAND_SPAWN_GROUP:
  4238. {
  4239. Spawn* target = cmdTarget;
  4240. if(target && target->IsPlayer() == false)
  4241. {
  4242. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "create") == 0)
  4243. {
  4244. if(target->GetSpawnLocationPlacementID() > 0)
  4245. {
  4246. if(sep->arg[1] && !sep->IsNumber(1) && strlen(sep->arg[1]) > 0)
  4247. {
  4248. int32 id = database.CreateSpawnGroup(target, sep->arg[1]);
  4249. if(id > 0)
  4250. client->Message(CHANNEL_COLOR_YELLOW, "Successfully created new spawn group with id: %u", id);
  4251. else
  4252. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error creating group, check console for details.");
  4253. target->SetSpawnGroupID(id);
  4254. target->AddSpawnToGroup(target);
  4255. }
  4256. else
  4257. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group create [name]");
  4258. }
  4259. else
  4260. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Could not use spawn to create a new group. Likely cause would be a newly spawned spawn that did not exist when /reload spawns was last used.");
  4261. }
  4262. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "add") == 0)
  4263. {
  4264. if(sep->arg[1] && sep->IsNumber(1))
  4265. {
  4266. int32 group_id = atoul(sep->arg[1]);
  4267. Spawn* leader = client->GetCurrentZone()->GetSpawnGroup(group_id);
  4268. if(leader)
  4269. {
  4270. leader->AddSpawnToGroup(target);
  4271. target->SetSpawnGroupID(group_id);
  4272. if(database.SpawnGroupAddSpawn(target, group_id))
  4273. client->Message(CHANNEL_COLOR_YELLOW, "Successfully added '%s' to group id: %u", target->GetName(), group_id);
  4274. else
  4275. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error adding spawn to group, check console for details.");
  4276. }
  4277. else
  4278. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No spawns found in the current zone for that spawn group, be sure to use '/spawn group create' first!");
  4279. }
  4280. else
  4281. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group add [group id]");
  4282. }
  4283. else if(target->GetSpawnGroupID() == 0)
  4284. {
  4285. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That spawn is not in a group!");
  4286. }
  4287. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "remove") == 0)
  4288. {
  4289. int32 group_id = target->GetSpawnGroupID();
  4290. target->RemoveSpawnFromGroup();
  4291. if(database.SpawnGroupRemoveSpawn(target, group_id))
  4292. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed '%s' from group id: %u", target->GetName(), group_id);
  4293. else
  4294. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing spawn from group, check console for details.");
  4295. }
  4296. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "associate") == 0)
  4297. {
  4298. int32 group_id = target->GetSpawnGroupID();
  4299. if(sep->arg[1] && sep->IsNumber(1))
  4300. {
  4301. if(database.SpawnGroupAddAssociation(group_id, atoul(sep->arg[1])))
  4302. client->Message(CHANNEL_COLOR_YELLOW, "Successfully associated group id %u with group id %u", group_id, atoul(sep->arg[1]));
  4303. else
  4304. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error associating groups, check console for details.");
  4305. }
  4306. else
  4307. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Allows you to spawn only one associated group at once. Syntax: /spawn group associate [other group id]");
  4308. }
  4309. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "deassociate") == 0)
  4310. {
  4311. int32 group_id = target->GetSpawnGroupID();
  4312. if(sep->arg[1] && sep->IsNumber(1))
  4313. {
  4314. if(database.SpawnGroupRemoveAssociation(group_id, atoul(sep->arg[1])))
  4315. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed association between group id %u and group id %u", group_id, atoul(sep->arg[1]));
  4316. else
  4317. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing group associations, check console for details.");
  4318. }
  4319. else
  4320. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Removes previous group associations. Syntax: /spawn group deassociate [other group id]");
  4321. }
  4322. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "chance") == 0)
  4323. {
  4324. if(sep->arg[1] && sep->IsNumber(1))
  4325. {
  4326. if(database.SetGroupSpawnChance(target->GetSpawnGroupID(), atof(sep->arg[1])))
  4327. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set group spawn chance to %f for group id: %u", atof(sep->arg[1]), target->GetSpawnGroupID());
  4328. else
  4329. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error setting group spawn chance, check console for details.");
  4330. }
  4331. else
  4332. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group chance [group's spawn chance percentage]");
  4333. }
  4334. else
  4335. {
  4336. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command allows you to modify spawn groups.");
  4337. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group [create/add/remove/chance/associate/deassociate]");
  4338. }
  4339. }
  4340. else
  4341. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select a valid spawn to use this command.");
  4342. break;
  4343. }
  4344. case COMMAND_SPAWN_COMBINE:{
  4345. Spawn* spawn = cmdTarget;
  4346. float radius = 0;
  4347. bool failed = true;
  4348. if(spawn && !spawn->IsPlayer() && sep && sep->arg[0] && sep->arg[0][0]){
  4349. failed = false;
  4350. if(spawn->GetSpawnGroupID() > 0){
  4351. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Can not combine this spawn as it is in a spawn group. Remove it from the group and try again.");
  4352. }
  4353. else if(sep->IsNumber(0)){
  4354. radius = atof(sep->arg[0]);
  4355. client->CombineSpawns(radius, spawn);
  4356. }
  4357. else{
  4358. if(strncasecmp(sep->arg[0], "add", 3) == 0){
  4359. client->AddCombineSpawn(spawn);
  4360. }
  4361. else if(strncasecmp(sep->arg[0], "remove", 6) == 0){
  4362. client->RemoveCombineSpawn(spawn);
  4363. }
  4364. else if(strncasecmp(sep->arg[0], "save", 4) == 0){
  4365. const char* name = 0;
  4366. if(sep->arg[1] && sep->arg[1][0])
  4367. name = sep->argplus[1];
  4368. client->SaveCombineSpawns(name);
  4369. }
  4370. else
  4371. failed = true;
  4372. }
  4373. }
  4374. if(failed){
  4375. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command combines several spawns into a single spawn group.");
  4376. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn combine [radius/add/remove/save]");
  4377. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Ex: /spawn combine 1, /spawn combine save (spawn group name)");
  4378. }
  4379. break;
  4380. }
  4381. case COMMAND_SPAWN_CREATE:{
  4382. Spawn* spawn = 0;
  4383. if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "object", 6) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  4384. spawn = new Object();
  4385. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  4386. }
  4387. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "groundspawn", 11) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  4388. spawn = new GroundSpawn();
  4389. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  4390. }
  4391. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "sign", 4) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  4392. spawn = new Sign();
  4393. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  4394. }
  4395. else if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "npc", 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  4396. spawn = new NPC();
  4397. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  4398. spawn->appearance.pos.collision_radius = 32;
  4399. spawn->secondary_command_list_id = 0;
  4400. spawn->primary_command_list_id = 0;
  4401. spawn->appearance.display_name = 1;
  4402. spawn->appearance.show_level = 1;
  4403. spawn->appearance.attackable = 1;
  4404. }
  4405. else{
  4406. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn create [spawn type] [race type] [class type] [level] [name] (difficulty) (size)");
  4407. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are required except difficulty and size. Valid types are Object, NPC, Sign, or GroundSpawn");
  4408. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn create npc 203 1 50 'Lady Vox' 1 32");
  4409. break;
  4410. }
  4411. spawn->SetID(Spawn::NextID());
  4412. spawn->SetX(client->GetPlayer()->GetX());
  4413. spawn->SetY(client->GetPlayer()->GetY());
  4414. spawn->SetZ(client->GetPlayer()->GetZ());
  4415. spawn->SetHeading(client->GetPlayer()->GetHeading());
  4416. spawn->SetSpawnOrigX(spawn->GetX());
  4417. spawn->SetSpawnOrigY(spawn->GetY());
  4418. spawn->SetSpawnOrigZ(spawn->GetZ());
  4419. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  4420. if(spawn->IsSign())
  4421. {
  4422. ((Sign*)spawn)->SetSignType(SIGN_TYPE_GENERIC);
  4423. ((Sign*)spawn)->SetSignDistance(20.0f);
  4424. ((Sign*)spawn)->SetIncludeLocation(1);
  4425. ((Sign*)spawn)->SetIncludeHeading(1);
  4426. ((Sign*)spawn)->SetInitialState(1);
  4427. ((Sign*)spawn)->SetSignTitle(sep->arg[4]);
  4428. ((Sign*)spawn)->SetActivityStatus(64);
  4429. spawn->appearance.race = 0;
  4430. spawn->SetLevel(0);
  4431. spawn->SetHP(0);
  4432. spawn->SetTotalHP(0);
  4433. spawn->SetPower(0);
  4434. spawn->SetTotalPower(0);
  4435. spawn->SetDifficulty(0);
  4436. spawn->SetTargetable(0);
  4437. spawn->SetSogaModelType(0);
  4438. spawn->SetCollisionRadius(19);
  4439. ((Sign*)spawn)->SetWidgetX(client->GetPlayer()->GetX());
  4440. ((Sign*)spawn)->SetWidgetY(client->GetPlayer()->GetY());
  4441. ((Sign*)spawn)->SetWidgetZ(client->GetPlayer()->GetZ());
  4442. spawn->SetLocation(client->GetPlayer()->GetLocation());
  4443. spawn->appearance.model_type = atoul(sep->arg[1]);
  4444. }
  4445. else
  4446. {
  4447. spawn->appearance.targetable = 1;
  4448. spawn->appearance.race = 255;
  4449. spawn->SetLocation(client->GetPlayer()->GetLocation());
  4450. spawn->SetModelType(atoi(sep->arg[1]));
  4451. spawn->SetAdventureClass(atoi(sep->arg[2]));
  4452. spawn->SetLevel(atoi(sep->arg[3]));
  4453. spawn->SetName(sep->arg[4]);
  4454. if(sep->arg[5][0] && sep->IsNumber(5))
  4455. spawn->SetDifficulty(atoi(sep->arg[5]));
  4456. if(sep->arg[6][0] && sep->IsNumber(6))
  4457. spawn->size = atoi(sep->arg[6]);
  4458. if(spawn->GetTotalHP() == 0){
  4459. spawn->SetTotalHP(25*spawn->GetLevel() + 1);
  4460. spawn->SetHP(25*spawn->GetLevel() + 1);
  4461. }
  4462. if(spawn->GetTotalPower() == 0){
  4463. spawn->SetTotalPower(25*spawn->GetLevel() + 1);
  4464. spawn->SetPower(25*spawn->GetLevel() + 1);
  4465. }
  4466. }
  4467. client->GetCurrentZone()->AddSpawn(spawn);
  4468. break;
  4469. }
  4470. case COMMAND_SPAWN_EQUIPMENT:{
  4471. Spawn* spawn = cmdTarget;
  4472. if(spawn && sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1) && spawn->IsEntity()){
  4473. int8 slot = atoi(sep->arg[0]);
  4474. int16 type = atoi(sep->arg[1]);
  4475. int8 red = 0;
  4476. int8 green = 0;
  4477. int8 blue = 0;
  4478. int8 h_red = 0;
  4479. int8 h_green = 0;
  4480. int8 h_blue = 0;
  4481. if(sep->arg[2])
  4482. red = atoi(sep->arg[2]);
  4483. if(sep->arg[3])
  4484. green = atoi(sep->arg[3]);
  4485. if(sep->arg[4])
  4486. blue = atoi(sep->arg[4]);
  4487. if(sep->arg[5])
  4488. h_red = atoi(sep->arg[5]);
  4489. if(sep->arg[6])
  4490. h_green = atoi(sep->arg[6]);
  4491. if(sep->arg[7])
  4492. h_blue = atoi(sep->arg[7]);
  4493. ((Entity*)spawn)->SetEquipment(slot, type, red, green, blue, h_red, h_green, h_blue);
  4494. database.SaveNPCAppearanceEquipment(spawn->GetDatabaseID() , slot, type, red, green, blue, h_red, h_green, h_blue);
  4495. }
  4496. else{
  4497. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn equipment [slot] [appearance id] (red) (green) (blue) (highlight red) (hgreen) (hblue)");
  4498. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn's equipment. ");
  4499. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Slot is 0-24, Appearance ID from appearances table, Colors are 0-255");
  4500. }
  4501. break;
  4502. }
  4503. case COMMAND_SPAWN_DETAILS: {
  4504. Spawn* spawn = cmdTarget;
  4505. if (sep && sep->arg[0][0]) {
  4506. if (cmdTarget)
  4507. {
  4508. if (ToLower(string(sep->arg[0])) == "los")
  4509. {
  4510. bool hasLOS = client->GetPlayer()->CheckLoS(cmdTarget);
  4511. if (hasLOS)
  4512. client->Message(CHANNEL_COLOR_YELLOW, "You have line of sight with %s", spawn->GetName());
  4513. else
  4514. client->Message(CHANNEL_COLOR_RED, "You DO NOT have line of sight with %s", spawn->GetName());
  4515. break;
  4516. }
  4517. else if (ToLower(string(sep->arg[0])) == "bestz")
  4518. {
  4519. glm::vec3 targPos(cmdTarget->GetX(), cmdTarget->GetZ(), cmdTarget->GetY());
  4520. float bestZ = client->GetPlayer()->FindDestGroundZ(targPos, cmdTarget->GetYOffset());
  4521. client->Message(CHANNEL_COLOR_YELLOW, "Best Z for %s is %f", spawn->GetName(), bestZ);
  4522. break;
  4523. }
  4524. else if (ToLower(string(sep->arg[0])) == "inwater")
  4525. {
  4526. if (cmdTarget->GetRegionMap() == nullptr)
  4527. client->SimpleMessage(CHANNEL_COLOR_RED, "No water map for zone.");
  4528. else
  4529. {
  4530. bool inWater = cmdTarget->InWater();
  4531. client->Message(CHANNEL_COLOR_YELLOW, "%s is %s.", cmdTarget->GetName(), inWater ? "in water" : "out of water");
  4532. }
  4533. break;
  4534. }
  4535. else if (ToLower(string(sep->arg[0])) == "inlava")
  4536. {
  4537. if (cmdTarget->GetRegionMap() == nullptr)
  4538. client->SimpleMessage(CHANNEL_COLOR_RED, "No region map for zone.");
  4539. else
  4540. {
  4541. bool inLava = cmdTarget->InLava();
  4542. client->Message(CHANNEL_COLOR_YELLOW, "%s is %s.", cmdTarget->GetName(), inLava ? "in lava" : "out of lava");
  4543. }
  4544. break;
  4545. }
  4546. else if (ToLower(string(sep->arg[0])) == "regions")
  4547. {
  4548. glm::vec3 targPos(cmdTarget->GetX(), cmdTarget->GetY(), cmdTarget->GetZ());
  4549. if (cmdTarget->GetRegionMap() == nullptr)
  4550. client->SimpleMessage(CHANNEL_COLOR_RED, "No region map for zone.");
  4551. else
  4552. {
  4553. cmdTarget->GetRegionMap()->IdentifyRegionsInGrid(client, targPos);
  4554. }
  4555. break;
  4556. }
  4557. else if (ToLower(string(sep->arg[0])) == "behind")
  4558. {
  4559. bool isBehind = client->GetPlayer()->BehindTarget(cmdTarget);
  4560. client->Message(CHANNEL_COLOR_YELLOW, "%s %s.", isBehind ? "YOU are behind" : "YOU are NOT behind", cmdTarget->GetName());
  4561. break;
  4562. }
  4563. else if (ToLower(string(sep->arg[0])) == "infront")
  4564. {
  4565. bool isBehind = client->GetPlayer()->InFrontSpawn(cmdTarget, client->GetPlayer()->GetX(), client->GetPlayer()->GetZ());
  4566. client->Message(CHANNEL_COLOR_YELLOW, "%s %s.", isBehind ? "YOU are infront of" : "YOU are NOT infront of", cmdTarget->GetName());
  4567. break;
  4568. }
  4569. else if (ToLower(string(sep->arg[0])) == "flank")
  4570. {
  4571. bool isFlanking = client->GetPlayer()->FlankingTarget(cmdTarget);
  4572. client->Message(CHANNEL_COLOR_YELLOW, "%s is %s.", isFlanking ? "YOU are flanking" : "YOU are NOT flanking", cmdTarget->GetName());
  4573. break;
  4574. }
  4575. else if (ToLower(string(sep->arg[0])) == "aggro")
  4576. {
  4577. if(cmdTarget->IsNPC() && ((NPC*)cmdTarget)->Brain()) {
  4578. ((NPC*)cmdTarget)->Brain()->SendEncounterList(client);
  4579. ((NPC*)cmdTarget)->Brain()->SendHateList(client);
  4580. }
  4581. else {
  4582. client->SimpleMessage(CHANNEL_COLOR_RED, "/spawn details aggro is for NPCs only!");
  4583. }
  4584. break;
  4585. }
  4586. else if (ToLower(string(sep->arg[0])) == "angle")
  4587. {
  4588. float spawnAngle = client->GetPlayer()->GetFaceTarget(cmdTarget->GetX(), cmdTarget->GetZ());
  4589. client->Message(CHANNEL_COLOR_YELLOW, "Angle %f between player %s and target %s", spawnAngle, client->GetPlayer()->GetTarget() ? client->GetPlayer()->GetTarget()->GetName() : client->GetPlayer()->GetName(), client->GetPlayer()->GetName());
  4590. break;
  4591. }
  4592. }
  4593. if (sep->IsNumber(0))
  4594. {
  4595. float radius = atof(sep->arg[0]);
  4596. if (!client->GetCurrentZone()->SendRadiusSpawnInfo(client, radius))
  4597. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No results in the radius were found.");
  4598. break;
  4599. }
  4600. }
  4601. if (spawn) {
  4602. const char* type = "NPC";
  4603. if (spawn->IsObject())
  4604. type = "Object";
  4605. else if (spawn->IsSign())
  4606. type = "Sign";
  4607. else if (spawn->IsWidget())
  4608. type = "Widget";
  4609. else if (spawn->IsGroundSpawn())
  4610. type = "GroundSpawn";
  4611. int16 race_type = race_types_list.GetRaceType(spawn->GetModelType());
  4612. int16 race_base_type = race_types_list.GetRaceBaseType(spawn->GetModelType());
  4613. char* category = race_types_list.GetRaceTypeCategory(spawn->GetModelType());
  4614. char* subcategory = race_types_list.GetRaceTypeSubCategory(spawn->GetModelType());
  4615. char* modelname = race_types_list.GetRaceTypeModelName(spawn->GetModelType());
  4616. client->Message(CHANNEL_COLOR_YELLOW, "Name: %s, %s ID: %u", spawn->GetName(), type, spawn->GetDatabaseID());
  4617. client->Message(CHANNEL_COLOR_YELLOW, "Last Name: %s, Sub-Title: %s, Prefix: %s, Suffix: %s", spawn->GetLastName(), spawn->GetSubTitle(), spawn->GetPrefixTitle(), spawn->GetSuffixTitle());
  4618. client->Message(CHANNEL_COLOR_YELLOW, "Spawn Location ID: %u, Spawn Group ID: %u", spawn->GetSpawnLocationID(), spawn->GetSpawnGroupID());
  4619. client->Message(CHANNEL_COLOR_YELLOW, "Faction ID: %u, Merchant ID: %u, Transporter ID: %u", spawn->GetFactionID(), spawn->GetMerchantID(), spawn->GetTransporterID());
  4620. client->Message(CHANNEL_COLOR_YELLOW, "Grid ID: %u", spawn->GetLocation());
  4621. client->Message(CHANNEL_COLOR_YELLOW, "Race: %i, Class: %i, Gender: %i", spawn->GetRace(), spawn->GetAdventureClass(), spawn->GetGender());
  4622. client->Message(CHANNEL_COLOR_YELLOW, "Level: %i, HP: %u / %u, Power: %u / %u", spawn->GetLevel(), spawn->GetHP(), spawn->GetTotalHP(), spawn->GetPower(), spawn->GetTotalPower());
  4623. client->Message(CHANNEL_COLOR_YELLOW, "Respawn Time: %u (sec), X: %f, Y: %f, Z: %f Heading: %f", spawn->GetRespawnTime(), spawn->GetX(), spawn->GetY(), spawn->GetZ(), spawn->GetHeading());
  4624. client->Message(CHANNEL_COLOR_YELLOW, "Collision Radius: %i, Size: %i, Difficulty: %i, Heroic: %i", spawn->GetCollisionRadius(), spawn->GetSize(), spawn->GetDifficulty(), spawn->GetHeroic());
  4625. client->Message(CHANNEL_COLOR_YELLOW, "Targetable: %i, Show Name: %i, Attackable: %i, Show Level: %i", spawn->GetTargetable(), spawn->GetShowName(), spawn->GetAttackable(), spawn->GetShowLevel());
  4626. client->Message(CHANNEL_COLOR_YELLOW, "Show Command Icon: %i, Display Hand Icon: %i", spawn->GetShowCommandIcon(), spawn->GetShowHandIcon());
  4627. if (spawn->IsEntity()) {
  4628. client->Message(CHANNEL_COLOR_YELLOW, "Facial Hair Type: %i, Hair Type: %i, Chest Type: %i, Legs Type: %i", ((Entity*)spawn)->GetFacialHairType(), ((Entity*)spawn)->GetHairType(), ((Entity*)spawn)->GetChestType(), ((Entity*)spawn)->GetLegsType());
  4629. client->Message(CHANNEL_COLOR_YELLOW, "Soga Facial Hair Type: %i, Soga Hair Type: %i, Wing Type: %i", ((Entity*)spawn)->GetSogaFacialHairType(), ((Entity*)spawn)->GetSogaHairType(), ((Entity*)spawn)->GetWingType());
  4630. }
  4631. client->Message(CHANNEL_COLOR_YELLOW, "Model Type: %i, Soga Race Type: %i, Race Type: %u, Race Base Type: %u, Race Category: %s (subcategory: %s), Model Name: %s.", spawn->GetModelType(), spawn->GetSogaModelType(), race_type, race_base_type, category, subcategory, modelname);
  4632. client->Message(CHANNEL_COLOR_YELLOW, "Primary Command Type: %u, Secondary Command Type: %u", spawn->GetPrimaryCommandListID(), spawn->GetSecondaryCommandListID());
  4633. client->Message(CHANNEL_COLOR_YELLOW, "Visual State: %i, Action State: %i, Mood State: %i, Initial State: %i, Activity Status: %i", spawn->GetVisualState(), spawn->GetActionState(), spawn->GetMoodState(), spawn->GetInitialState(), spawn->GetActivityStatus());
  4634. client->Message(CHANNEL_COLOR_YELLOW, "Emote State: %i, Pitch: %f, Roll: %f, Hide Hood: %i", spawn->GetEmoteState(), spawn->GetPitch(), spawn->GetRoll(), spawn->appearance.hide_hood);
  4635. if (spawn->IsNPC())
  4636. client->Message(CHANNEL_COLOR_YELLOW, "Randomize: %u", ((NPC*)spawn)->GetRandomize());
  4637. if (spawn->IsNPC()){
  4638. client->Message(CHANNEL_COLOR_YELLOW, "Heat Resist/Base: %u/%u",((NPC*)spawn)->GetHeatResistance(), ((NPC*)spawn)->GetHeatResistanceBase());
  4639. client->Message(CHANNEL_COLOR_YELLOW, "Cold Resist/Base: %u/%u",((NPC*)spawn)->GetColdResistance(), ((NPC*)spawn)->GetColdResistanceBase());
  4640. client->Message(CHANNEL_COLOR_YELLOW, "Magic Resist/Base: %u/%u",((NPC*)spawn)->GetMagicResistance(), ((NPC*)spawn)->GetMagicResistanceBase());
  4641. client->Message(CHANNEL_COLOR_YELLOW, "Mental Resist/Base: %u/%u",((NPC*)spawn)->GetMentalResistance(), ((NPC*)spawn)->GetMentalResistanceBase());
  4642. client->Message(CHANNEL_COLOR_YELLOW, "Divine Resist/Base: %u/%u",((NPC*)spawn)->GetDivineResistance(), ((NPC*)spawn)->GetDivineResistanceBase());
  4643. client->Message(CHANNEL_COLOR_YELLOW, "Disease Resist/Base: %u/%u",((NPC*)spawn)->GetDiseaseResistance(), ((NPC*)spawn)->GetDiseaseResistanceBase());
  4644. client->Message(CHANNEL_COLOR_YELLOW, "Poison Resist/Base: %u/%u",((NPC*)spawn)->GetPoisonResistance(), ((NPC*)spawn)->GetPoisonResistanceBase());
  4645. }
  4646. string details;
  4647. details += "\\#0000FFName: " + string(spawn->GetName()) + "\n";
  4648. details += "Type: " + string(type) + "\n";
  4649. details += "ID: " + to_string(spawn->GetDatabaseID()) + "\n";
  4650. details += "Last Name: " + string(spawn->GetLastName()) + "\n";
  4651. details += "Sub-Title: " + string(spawn->GetSubTitle()) + "\n";
  4652. details += "Prefix: " + string(spawn->GetPrefixTitle()) + "\n";
  4653. details += "Suffix: " + string(spawn->GetSuffixTitle()) + "\n";
  4654. details += "Race: " + to_string(spawn->GetRace()) + "\n";
  4655. details += "Class: " + to_string(spawn->GetAdventureClass()) + "\n";
  4656. details += "Gender: " + to_string(spawn->GetGender()) + "\n";
  4657. details += "Level: " + to_string(spawn->GetLevel()) + "\n";
  4658. details += "HP: " + to_string(spawn->GetHP()) + " / " + to_string(spawn->GetTotalHP()) + "(" + to_string(spawn->GetIntHPRatio()) + "%)\n";
  4659. details += "Power: " + to_string(spawn->GetPower()) + + " / " + to_string(spawn->GetTotalPower()) + "\n";
  4660. details += "Difficulty: " + to_string(spawn->GetDifficulty()) + "\n";
  4661. details += "Heroic: " + to_string(spawn->GetHeroic()) + "\n";
  4662. details += "Group ID: " + to_string(spawn->GetSpawnGroupID()) + "\n";
  4663. details += "Faction ID: " + to_string(spawn->GetFactionID()) + "\n";
  4664. details += "Merchant ID: " + to_string(spawn->GetMerchantID()) + "\n";
  4665. details += "Transport ID: " + to_string(spawn->GetTransporterID()) + "\n";
  4666. details += "Location ID: " + to_string(spawn->GetSpawnLocationID()) + "\n";
  4667. char x[16];
  4668. sprintf(x, "%.2f", spawn->GetX());
  4669. char y[16];
  4670. sprintf(y, "%.2f", spawn->GetY());
  4671. char z[16];
  4672. sprintf(z, "%.2f", spawn->GetZ());
  4673. details += "Location: " + string(x) + ", " + string(y) + ", " + string(z) + "\n";
  4674. string details2;
  4675. details2 += "Heading: " + to_string(spawn->GetHeading()) + "\n";
  4676. details2 += "Grid ID: " + to_string(spawn->GetLocation()) + "\n";
  4677. details2 += "Size: " + to_string(spawn->GetSize()) + "\n";
  4678. details2 += "Collision Radius: " + to_string(spawn->GetCollisionRadius()) + "\n";
  4679. details2 += "Respawn Time: " + to_string(spawn->GetRespawnTime()) + "\n";
  4680. details2 += "Targetable: " + to_string(spawn->GetTargetable()) + "\n";
  4681. details2 += "Show Name: " + to_string(spawn->GetShowName()) + "\n";
  4682. details2 += "Attackable: " + to_string(spawn->GetAttackable()) + "\n";
  4683. details2 += "Show Level: " + to_string(spawn->GetShowLevel()) + "\n";
  4684. details2 += "Show Command Icon: " + to_string(spawn->GetShowCommandIcon()) + "\n";
  4685. details2 += "Display Hand Icon: " + to_string(spawn->GetShowHandIcon()) + "\n";
  4686. details2 += "Model Type: " + to_string(spawn->GetModelType()) + "\n";
  4687. details2 += "Soga Race Type: " + to_string(spawn->GetSogaModelType()) + "\n";
  4688. details2 += "Race Type: " + to_string(race_type) + "\n";
  4689. details2 += "Race Base Type: " + to_string(race_base_type) + "\n";
  4690. details2 += "Race Category (Sub Category): " + std::string(category) + " (" + std::string(subcategory) + ")\n";
  4691. details2 += "Model Name: " + std::string(modelname) + "\n";
  4692. details2 += "Primary Command ID: " + to_string(spawn->GetPrimaryCommandListID()) + "\n";
  4693. details2 += "Secondary Cmd ID: " + to_string(spawn->GetSecondaryCommandListID()) + "\n";
  4694. details2 += "Visual State: " + to_string(spawn->GetVisualState()) + "\n";
  4695. details2 += "Action State: " + to_string(spawn->GetActionState()) + "\n";
  4696. details2 += "Mood State: " + to_string(spawn->GetMoodState()) + "\n";
  4697. details2 += "Initial State: " + to_string(spawn->GetInitialState()) + "\n";
  4698. details2 += "Activity Status: " + to_string(spawn->GetActivityStatus()) + "\n";
  4699. details2 += "Emote State: " + to_string(spawn->GetEmoteState()) + "\n";
  4700. string details3;
  4701. details3 += "Pitch: " + to_string(spawn->GetPitch()) + "\n";
  4702. details3 += "Roll: " + to_string(spawn->GetRoll()) + "\n";
  4703. details3 += "Hide Hood: " + to_string(spawn->appearance.hide_hood) + "\n";
  4704. details3 += "Speed: " + to_string(spawn->GetSpeed()) + "\n";
  4705. details3 += "BaseSpeed: " + to_string(spawn->GetBaseSpeed()) + "\n";
  4706. if(spawn->IsSign()) {
  4707. details3 += "Sign Language: " + to_string(((Sign*)spawn)->GetLanguage()) + "\n";
  4708. }
  4709. if(spawn->IsEntity())
  4710. {
  4711. Entity* ent = (Entity*)spawn;
  4712. details3 += "STR / STRBase: " + to_string(ent->GetInfoStruct()->get_str()) + " / " + to_string(ent->GetInfoStruct()->get_str_base()) + "\n";
  4713. details3 += "AGI / AGIBase: " + to_string(ent->GetInfoStruct()->get_agi()) + " / " + to_string(ent->GetInfoStruct()->get_agi_base()) + "\n";
  4714. details3 += "STA / STABase: " + to_string(ent->GetInfoStruct()->get_sta()) + " / " + to_string(ent->GetInfoStruct()->get_sta_base()) + "\n";
  4715. details3 += "INT / INTBase: " + to_string(ent->GetInfoStruct()->get_intel()) + " / " + to_string(ent->GetInfoStruct()->get_intel_base()) + "\n";
  4716. details3 += "WIS / WISBase: " + to_string(ent->GetInfoStruct()->get_wis()) + " / " + to_string(ent->GetInfoStruct()->get_wis_base()) + "\n";
  4717. }
  4718. string details4;
  4719. if (spawn->IsEntity()) {
  4720. details4 += "Facial Hair Type: " + to_string(((Entity*)spawn)->GetFacialHairType()) + "\n";
  4721. details4 += "Hair Type: " + to_string(((Entity*)spawn)->GetHairType()) + "\n";
  4722. details4 += "Chest Type: " + to_string(((Entity*)spawn)->GetChestType()) + "\n";
  4723. details4 += "Legs Type: " + to_string(((Entity*)spawn)->GetLegsType()) + "\n";
  4724. details4 += "Soga Facial Hair Type: " + to_string(((Entity*)spawn)->GetSogaFacialHairType()) + "\n";
  4725. details4 += "Soga Hair Type: " + to_string(((Entity*)spawn)->GetSogaHairType()) + "\n";
  4726. details4 += "Wing Type: " + to_string(((Entity*)spawn)->GetWingType()) + "\n";
  4727. if (spawn->IsNPC()) {
  4728. details4 += "\nRandomize: " + to_string(((NPC*)spawn)->GetRandomize()) + "\n";
  4729. }
  4730. }
  4731. const char* spawnScriptMsg = (spawn->GetSpawnScript() && strlen(spawn->GetSpawnScript())>0) ? spawn->GetSpawnScript() : "Not Set";
  4732. details4 += "\nSpawnScript: " + std::string(spawnScriptMsg) + "\n";
  4733. string title = string(spawn->GetName()) + "(" + to_string(spawn->GetDatabaseID()) + ")";
  4734. client->SendShowBook(client->GetPlayer(), title, 0, 4, details, details2, details3, details4);
  4735. }
  4736. else {
  4737. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn details (radius)");
  4738. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will display information about the currently selected spawn, or in the case of specifying a numerical radius will show minor details about spawns in the players radius.");
  4739. }
  4740. break;
  4741. }
  4742. case COMMAND_SPAWN_TARGET:{
  4743. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  4744. int32 spawn_id = atoul(sep->arg[0]);
  4745. int16 response = client->GetCurrentZone()->SetSpawnTargetable(spawn_id);
  4746. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  4747. }
  4748. else if(sep && sep->arg[0][0] && sep->arg[1][0] && sep->IsNumber(1) && ToLower(string(sep->arg[0])) == "radius"){
  4749. float distance = atof(sep->arg[1]);
  4750. int16 response = client->GetCurrentZone()->SetSpawnTargetable(client->GetPlayer(), distance);
  4751. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  4752. }
  4753. else{
  4754. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn target [spawn id]");
  4755. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn as targetable. Used to change a spawn if it was set to untargetable.");
  4756. }
  4757. break;
  4758. }
  4759. case COMMAND_SPAWN_SET:
  4760. {
  4761. Spawn* spawn = cmdTarget;
  4762. sint16 set_type = -1;
  4763. string type_str;
  4764. if (spawn)
  4765. {
  4766. // check if parameters are (location or list or not player and not a 2nd param), and that there is at least 1 value
  4767. if(sep && ((sep->arg[0][0] && ToLower(string(sep->arg[0])) == "location") || (sep->arg[0][0] && ToLower(string(sep->arg[0])) == "list") || (spawn && spawn->IsPlayer() == false && sep->arg[1][0])) && spawn_set_values.count(ToLower(string(sep->arg[0]))) == 1)
  4768. {
  4769. // set the type, which will be 0 if location or list or invalid
  4770. set_type = spawn_set_values[ToLower(string(sep->arg[0]))];
  4771. }
  4772. if(set_type > 0)
  4773. {
  4774. // check if spawn set is NOT a char update, or not location, or isn't a number
  4775. if(!(set_type >= SPAWN_SET_VALUE_PREFIX) && !(set_type <= SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL) && set_type != SPAWN_SET_VALUE_NAME && ((set_type < SPAWN_SET_VALUE_SPAWN_SCRIPT) || (set_type > SPAWN_SET_VALUE_SUB_TITLE)) && set_type != SPAWN_SET_VALUE_LOCATION && sep->IsNumber(1) == false)
  4776. {
  4777. client->SimpleMessage(CHANNEL_COLOR_RED, "Invalid value for set command.");
  4778. }
  4779. else
  4780. {
  4781. string name = string(spawn->GetName());
  4782. bool customSetSpawn = false;
  4783. if(set_type >= SPAWN_SET_CHEEK_TYPE && set_type <= SPAWN_SET_SOGA_NOSE_TYPE)
  4784. {
  4785. int8 index = sep->IsNumber(2) ? atoul(sep->arg[2]) : 0;
  4786. // override the standard setspawncommand, we pass arguments different!
  4787. if(SetSpawnCommand(client, spawn, set_type, sep->arg[1], true, false, nullptr, index))
  4788. customSetSpawn = true;
  4789. }
  4790. if(customSetSpawn || SetSpawnCommand(client, spawn, set_type, sep->argplus[1]))
  4791. {
  4792. if (set_type == SPAWN_SET_VALUE_EXPANSION_FLAG || set_type == SPAWN_SET_VALUE_HOLIDAY_FLAG)
  4793. {
  4794. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "A /reload spawns is required to properly update the spawns with the xpack/holiday flag.");
  4795. }
  4796. else if (set_type == SPAWN_SET_VALUE_NAME)
  4797. {
  4798. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "New name will not be effective until zone reload.");
  4799. }
  4800. else if (set_type == SPAWN_SET_SKIN_COLOR || (set_type >= SPAWN_SET_HAIR_COLOR1 && set_type <= SPAWN_SET_SOGA_EYE_COLOR))
  4801. {
  4802. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set color field to R G B: %s.", sep->argplus[1]);
  4803. }
  4804. else if(set_type == SPAWN_SET_VALUE_LOCATION)
  4805. {
  4806. spawn->SetLocation(client->GetPlayer()->GetLocation());
  4807. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set '%s' to '%u' for spawn '%s' (DBID: %u)", sep->arg[0], client->GetPlayer()->GetLocation(), name.c_str(), spawn->GetDatabaseID());
  4808. }
  4809. else
  4810. {
  4811. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set '%s' to '%s' for spawn '%s' (DBID: %u)", sep->arg[0], sep->arg[1], name.c_str(), spawn->GetDatabaseID());
  4812. }
  4813. switch (set_type)
  4814. {
  4815. case SPAWN_SET_VALUE_EXPANSION_FLAG:
  4816. case SPAWN_SET_VALUE_HOLIDAY_FLAG:
  4817. case SPAWN_SET_VALUE_FACTION:
  4818. case SPAWN_SET_AAXP_REWARDS:
  4819. case SPAWN_SET_CHEEK_TYPE:
  4820. case SPAWN_SET_CHIN_TYPE:
  4821. case SPAWN_SET_EAR_TYPE:
  4822. case SPAWN_SET_EYE_BROW_TYPE:
  4823. case SPAWN_SET_EYE_TYPE:
  4824. case SPAWN_SET_LIP_TYPE:
  4825. case SPAWN_SET_NOSE_TYPE:
  4826. case SPAWN_SET_BODY_SIZE:
  4827. case SPAWN_SET_BODY_AGE:
  4828. case SPAWN_SET_SOGA_CHEEK_TYPE:
  4829. case SPAWN_SET_SOGA_CHIN_TYPE:
  4830. case SPAWN_SET_SOGA_EAR_TYPE:
  4831. case SPAWN_SET_SOGA_EYE_BROW_TYPE:
  4832. case SPAWN_SET_SOGA_EYE_TYPE:
  4833. case SPAWN_SET_SOGA_LIP_TYPE:
  4834. case SPAWN_SET_SOGA_NOSE_TYPE:
  4835. case SPAWN_SET_SOGA_BODY_SIZE:
  4836. case SPAWN_SET_SOGA_BODY_AGE:
  4837. case SPAWN_SET_ATTACK_TYPE:
  4838. case SPAWN_SET_RACE_TYPE:
  4839. case SPAWN_SET_LOOT_TIER:
  4840. case SPAWN_SET_LOOT_DROP_TYPE:
  4841. case SPAWN_SET_SCARED_STRONG_PLAYERS:
  4842. {
  4843. // not applicable already ran db command
  4844. break;
  4845. }
  4846. default:
  4847. {
  4848. client->GetCurrentZone()->ApplySetSpawnCommand(client, spawn, set_type, sep->argplus[1]);
  4849. break;
  4850. }
  4851. }
  4852. if((set_type >= SPAWN_SET_VALUE_RESPAWN && set_type <=SPAWN_SET_VALUE_LOCATION) || (set_type >= SPAWN_SET_VALUE_EXPIRE && set_type <=SPAWN_SET_VALUE_Z_OFFSET) || (set_type == SPAWN_SET_VALUE_PITCH || set_type == SPAWN_SET_VALUE_ROLL))
  4853. {
  4854. if(spawn->GetSpawnLocationID() > 0 && database.UpdateSpawnLocationSpawns(spawn))
  4855. {
  4856. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information for spawn '%s' (DBID: %u)", name.c_str(), spawn->GetDatabaseID());
  4857. }
  4858. else if(spawn->GetSpawnLocationID() > 0)
  4859. {
  4860. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn information, see console window for details.");
  4861. }
  4862. }
  4863. else
  4864. {
  4865. if(spawn->GetDatabaseID() > 0 && database.SaveSpawnInfo(spawn))
  4866. {
  4867. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn for spawn '%s' (DBID: %u)", name.c_str(), spawn->GetDatabaseID());
  4868. }
  4869. else if(spawn->GetDatabaseID() > 0)
  4870. {
  4871. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn, see console window for details.");
  4872. }
  4873. }
  4874. }
  4875. }
  4876. }
  4877. else if(set_type == 0)
  4878. {
  4879. // /spawn set list - lists all possible attributes that can be changed with this command, 10 per line.
  4880. map<string, int8>::iterator itr;
  4881. int i=0;
  4882. string list;
  4883. for(itr = spawn_set_values.begin(); itr != spawn_set_values.end(); itr++, i++)
  4884. {
  4885. if(i==10)
  4886. {
  4887. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  4888. i = 0;
  4889. }
  4890. if(i>0)
  4891. {
  4892. list.append(", ").append(itr->first);
  4893. }
  4894. else
  4895. {
  4896. list = itr->first;
  4897. }
  4898. }
  4899. if(list.length() > 0)
  4900. {
  4901. // if 1 or more, display in client.
  4902. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  4903. }
  4904. }
  4905. else
  4906. {
  4907. // syntax fail
  4908. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn set [type] [value]");
  4909. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used to change various settings for the targeted NPC or Object.");
  4910. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "For a list of changeable settings use /spawn set list");
  4911. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Note: /spawn set location does not require a value. The client's current location is used.");
  4912. }
  4913. }
  4914. break;
  4915. }
  4916. case COMMAND_SPAWN_REMOVE:{
  4917. Spawn* spawn = cmdTarget;
  4918. if(spawn && !spawn->IsPlayer()){
  4919. if(spawn->GetSpawnLocationID() > 0){
  4920. string name = string(spawn->GetName());
  4921. int32 dbid = spawn->GetDatabaseID();
  4922. if(database.RemoveSpawnFromSpawnLocation(spawn)){
  4923. client->GetCurrentZone()->RemoveSpawn(spawn, true, false, true, true, true);
  4924. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed spawn from zone for spawn '%s' (DBID: %u)", name.c_str(), dbid);
  4925. }
  4926. else
  4927. client->SimpleMessage(CHANNEL_COLOR_RED, "Error removing spawn, see console window for details.");
  4928. }
  4929. else
  4930. client->SimpleMessage(CHANNEL_COLOR_RED, "This spawn does not have a spawn group associated with it");
  4931. }
  4932. else{
  4933. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn remove");
  4934. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for removing the targeted NPC or Object from the zone.");
  4935. }
  4936. break;
  4937. }
  4938. case COMMAND_SPAWN_LIST:{
  4939. if(sep && sep->arg[0][0]){
  4940. vector<string>* results = database.GetSpawnNameList(sep->argplus[0]);
  4941. vector<string>::iterator itr;
  4942. if(results){
  4943. for(itr=results->begin();itr!=results->end();itr++){
  4944. client->SimpleMessage(CHANNEL_COLOR_YELLOW, (*itr).c_str());
  4945. }
  4946. safe_delete(results);
  4947. }
  4948. else
  4949. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found. ");
  4950. }
  4951. else{
  4952. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn list [name]");
  4953. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Name can be a partial match.");
  4954. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn list Qeynos Guard");
  4955. }
  4956. break;
  4957. }
  4958. case COMMAND_SPAWN_ADD:{
  4959. Spawn* spawn = cmdTarget;
  4960. if(spawn && sep && ((sep->arg[1][0] && sep->IsNumber(0)) || (sep->arg[0][0] && strncasecmp(sep->arg[0], "new", 3) == 0))){
  4961. if(spawn->GetSpawnLocationID() > 0){
  4962. client->Message(CHANNEL_COLOR_RED, "This spawn already has a spawn group id of %u, use /spawn remove to reassign it", spawn->GetSpawnLocationID());
  4963. break;
  4964. }
  4965. if(spawn->GetDatabaseID() == 0){
  4966. if(database.SaveSpawnInfo(spawn)) {
  4967. char spawn_type[32];
  4968. memset(spawn_type, 0, sizeof(spawn_type));
  4969. if (spawn->IsNPC())
  4970. strncpy(spawn_type, "NPC", sizeof(spawn_type) - 1);
  4971. else if (spawn->IsObject())
  4972. strncpy(spawn_type, "Object", sizeof(spawn_type) - 1);
  4973. else if (spawn->IsSign())
  4974. strncpy(spawn_type, "Sign", sizeof(spawn_type) - 1);
  4975. else if (spawn->IsGroundSpawn())
  4976. strncpy(spawn_type, "GroundSpawn", sizeof(spawn_type) - 1);
  4977. else
  4978. strncpy(spawn_type, "Unknown", sizeof(spawn_type) - 1);
  4979. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information with a %s id of %u", spawn_type, spawn->GetDatabaseID());
  4980. }
  4981. else
  4982. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn information, see console window for details.");
  4983. }
  4984. int32 spawn_group_id = 0;
  4985. if(strncasecmp(sep->arg[0], "new", 3) == 0)
  4986. spawn_group_id = database.GetNextSpawnLocation();
  4987. else
  4988. spawn_group_id = atol(sep->arg[0]);
  4989. int8 percent = 100;
  4990. if(sep->arg[2] && sep->IsNumber(2))
  4991. percent = atoi(sep->arg[2]);
  4992. spawn->SetSpawnLocationID(spawn_group_id);
  4993. float x_offset = database.GetSpawnLocationPlacementOffsetX(spawn->GetSpawnLocationID());
  4994. float y_offset = database.GetSpawnLocationPlacementOffsetY(spawn->GetSpawnLocationID());
  4995. float z_offset = database.GetSpawnLocationPlacementOffsetZ(spawn->GetSpawnLocationID());
  4996. if(database.SaveSpawnEntry(spawn, sep->arg[1], percent, x_offset, y_offset, z_offset))
  4997. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn location with a spawn group of %u", spawn->GetSpawnLocationID());
  4998. else
  4999. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn location, see console window for details.");
  5000. }
  5001. else{
  5002. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn add [spawn group id] [spawn group name] (percentage)");
  5003. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for adding the targeted NPC or Object to the database.");
  5004. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can substitute new for [spawn group id] to create a new one.");
  5005. }
  5006. break;
  5007. }
  5008. case COMMAND_SPAWN:{
  5009. int32 id = 0;
  5010. Spawn* spawn = 0;
  5011. if(sep && sep->arg[0] && sep->IsNumber(0)){
  5012. id = atol(sep->arg[0]);
  5013. spawn = client->GetCurrentZone()->GetSpawn(id);
  5014. }
  5015. if(id > 0 && spawn && spawn->appearance.name[0] == 0)
  5016. id = 0;
  5017. if(!id || !spawn){
  5018. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn [spawn id] (x) (y) (z) (heading) (location)");
  5019. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are optional except the id. The spawn id must be in the database.");
  5020. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn 1 0 0 0 0");
  5021. safe_delete(sep);
  5022. return;
  5023. }
  5024. if(sep && sep->arg[1][0]){
  5025. float x = atof(sep->arg[1]);
  5026. spawn->appearance.pos.X = x;
  5027. }
  5028. else
  5029. spawn->SetX(client->GetPlayer()->GetX(), false);
  5030. if(sep && sep->arg[2][0]){
  5031. float y = atof(sep->arg[2]);
  5032. spawn->appearance.pos.Y = y;
  5033. }
  5034. else
  5035. spawn->SetY(client->GetPlayer()->GetY(), false);
  5036. if(sep && sep->arg[3][0]){
  5037. float z = atof(sep->arg[3]);
  5038. spawn->appearance.pos.Z = z;
  5039. }
  5040. else
  5041. spawn->SetZ(client->GetPlayer()->GetZ(), false);
  5042. if(sep && sep->arg[4][0]){
  5043. float heading = atof(sep->arg[4]);
  5044. spawn->SetHeading(heading);
  5045. }
  5046. else
  5047. spawn->SetHeading(client->GetPlayer()->GetHeading(), false);
  5048. spawn->SetSpawnOrigX(spawn->GetX());
  5049. spawn->SetSpawnOrigY(spawn->GetY());
  5050. spawn->SetSpawnOrigZ(spawn->GetZ());
  5051. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  5052. if(sep && sep->arg[5][0])
  5053. spawn->SetLocation(atoul(sep->arg[5]));
  5054. else
  5055. spawn->SetLocation(client->GetPlayer()->GetLocation());
  5056. if(spawn->IsNPC() && spawn->GetTotalHP() == 0){
  5057. spawn->SetTotalHP(spawn->GetLevel() * 15);
  5058. spawn->SetHP(spawn->GetTotalHP());
  5059. }
  5060. if(spawn->GetTotalPower() == 0){
  5061. spawn->SetTotalPower(spawn->GetLevel() * 15);
  5062. spawn->SetPower(spawn->GetTotalPower());
  5063. }
  5064. const char* script = world.GetSpawnScript(id);
  5065. if(script && lua_interface && lua_interface->GetSpawnScript(script) != 0)
  5066. spawn->SetSpawnScript(string(script));
  5067. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_PRESPAWN);
  5068. client->GetCurrentZone()->AddSpawn(spawn);
  5069. if(spawn->IsNPC())
  5070. spawn->GetZone()->AddLoot((NPC*)spawn);
  5071. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_SPAWN);
  5072. LogWrite(COMMAND__INFO, 0, "Command", "Received spawn command - Parms: %s", command_parms->data.c_str());
  5073. break;
  5074. }
  5075. case COMMAND_ADMINFLAG:
  5076. {
  5077. if(sep && sep->arg[0]){
  5078. sint16 tmp_status = database.GetCharacterAdminStatus(sep->arg[0]);
  5079. sint16 new_status = atoi(sep->arg[1]);
  5080. if(tmp_status == -10)
  5081. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character does not exist.");
  5082. else if(tmp_status >= client->GetAdminStatus())
  5083. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character has same or higher level status.");
  5084. else if (new_status > client->GetAdminStatus())
  5085. client->SimpleMessage(CHANNEL_ERROR, "Unable to flag character. Reason: New status is higher then your status.");
  5086. else{
  5087. Client* client2 = client->GetCurrentZone()->GetClientByName(sep->arg[0]);
  5088. if (!client2)
  5089. client2 = zone_list.GetClientByCharName(sep->arg[0]);
  5090. if(database.UpdateAdminStatus(sep->arg[0],new_status)) {
  5091. client->Message(CHANNEL_COLOR_YELLOW,"Character status updated to %i for %s.",new_status,sep->arg[0]);
  5092. if (client2) {
  5093. client2->SetAdminStatus(new_status);
  5094. client2->Message(CHANNEL_COLOR_YELLOW, "%s has set your admin status to %i.", client->GetPlayer()->GetName(), new_status);
  5095. }
  5096. }
  5097. else
  5098. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Unknown reason.");
  5099. }
  5100. }else{
  5101. sint16 status = database.GetCharacterAdminStatus(client->GetPlayer()->GetName());
  5102. if(status != client->GetAdminStatus())
  5103. {
  5104. client->Message(CHANNEL_COLOR_YELLOW,"Flag status was changed from %i to %i.",status,client->GetAdminStatus());
  5105. client->SetAdminStatus(status);
  5106. }
  5107. else
  5108. {
  5109. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /flag {name} {new_status}");
  5110. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Standard User: 0");
  5111. client->Message(CHANNEL_COLOR_YELLOW," Admin User: %i", status);
  5112. }
  5113. }
  5114. break;
  5115. }
  5116. case COMMAND_CANNEDEMOTE:{
  5117. client->GetCurrentZone()->HandleEmote(client->GetPlayer(), command_parms->data);
  5118. break;
  5119. }
  5120. case COMMAND_BROADCAST: {
  5121. if (sep && sep->arg[0])
  5122. zone_list.HandleGlobalBroadcast(sep->argplus[0]);
  5123. else
  5124. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /broadcast {message}");
  5125. break;
  5126. }
  5127. case COMMAND_ANNOUNCE: {
  5128. if (sep && sep->arg[0])
  5129. zone_list.HandleGlobalAnnouncement(sep->argplus[0]);
  5130. else
  5131. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /announce {message}");
  5132. break;
  5133. }
  5134. case COMMAND_RELOAD_ITEMS:{
  5135. LogWrite(COMMAND__INFO, 0, "Command", "Reloading items..");
  5136. int32 item_id = (sep && sep->arg[0]) ? atoul(sep->arg[0]) : 0;
  5137. if(item_id > 0) {
  5138. client->Message(CHANNEL_COLOR_YELLOW, "Reloading item %u based on /reload items [item_id].", item_id);
  5139. }
  5140. else {
  5141. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Started Reloading items (this might take a few minutes...)");
  5142. }
  5143. database.ReloadItemList(item_id);
  5144. if(!item_id) {
  5145. database.LoadMerchantInformation(); // we skip if there is only a reload of single item not all items
  5146. }
  5147. if(item_id > 0) {
  5148. client->Message(CHANNEL_COLOR_YELLOW, "Reloaded item %u.", item_id);
  5149. }
  5150. else {
  5151. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Finished Reloading items.");
  5152. }
  5153. break;
  5154. }
  5155. case COMMAND_ENABLE_ABILITY_QUE:{
  5156. EQ2Packet* app = client->GetPlayer()->GetSpellBookUpdatePacket(client->GetVersion());
  5157. if(app)
  5158. client->QueuePacket(app);
  5159. break;
  5160. }
  5161. case COMMAND_ITEMSEARCH:
  5162. case COMMAND_FROMBROKER:{
  5163. PacketStruct* packet = configReader.getStruct("WS_StartBroker", client->GetVersion());
  5164. if (packet) {
  5165. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  5166. //packet->setDataByName("unknown", 1);
  5167. packet->setDataByName("unknown2", 5, 0);
  5168. packet->setDataByName("unknown2", 20, 1);
  5169. packet->setDataByName("unknown2", 58, 3);
  5170. packet->setDataByName("unknown2", 40, 4);
  5171. client->QueuePacket(packet->serialize());
  5172. PacketStruct* packet2 = configReader.getStruct("WS_BrokerBags", client->GetVersion());
  5173. if (packet2) {
  5174. packet2->setDataByName("char_id", client->GetCharacterID());
  5175. client->QueuePacket(packet2->serialize()); //send this for now, needed to properly clear data
  5176. safe_delete(packet2);
  5177. }
  5178. safe_delete(packet);
  5179. }
  5180. break;
  5181. }
  5182. case COMMAND_ANIMTEST:{
  5183. PacketStruct* command_packet = configReader.getStruct("WS_CannedEmote", client->GetVersion());
  5184. if(command_packet){
  5185. int32 id = client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer());
  5186. if (cmdTarget)
  5187. id = client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget);
  5188. command_packet->setDataByName ( "spawn_id" , id);
  5189. int animID = 1;
  5190. if(sep && sep->arg[0] && sep->IsNumber(0))
  5191. animID = atoi(sep->arg[0]);
  5192. VisualState* vs = NULL;
  5193. if(animID == 0)
  5194. {
  5195. vs = visual_states.FindVisualState(sep->arg[0]);
  5196. }
  5197. char msg[128];
  5198. sprintf(msg,"Animation Test ID: %i",animID);
  5199. command_packet->setMediumStringByName ( "emote_msg" , msg );
  5200. if(vs != NULL)
  5201. command_packet->setDataByName ( "anim_type", vs->GetID ( ) );
  5202. else
  5203. command_packet->setDataByName ( "anim_type", animID );
  5204. command_packet->setDataByName ( "unknown0", 0 );
  5205. EQ2Packet* outapp = command_packet->serialize();
  5206. client->QueuePacket(outapp);
  5207. safe_delete(command_packet);
  5208. }
  5209. break;
  5210. }
  5211. case COMMAND_KICK:
  5212. {
  5213. if( sep == 0 || sep->arg[0] == 0)
  5214. {
  5215. client->SimpleMessage(CHANNEL_COLOR_RED, "/kick [name]");
  5216. }
  5217. else
  5218. {
  5219. Client* kickClient = zone_list.GetClientByCharName(string(sep->arg[0]));
  5220. if ( kickClient == client )
  5221. {
  5222. client->Message(CHANNEL_COLOR_RED, "You can't kick yourself!");
  5223. break;
  5224. }
  5225. else if(kickClient != NULL)
  5226. {
  5227. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  5228. if ( maxStatus >= client->GetAdminStatus( ) || kickClient->GetAdminStatus() >= client->GetAdminStatus() )
  5229. {
  5230. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  5231. break;
  5232. }
  5233. client->Message(CHANNEL_COLOR_RED, "Kicking %s...",sep->arg[0]);
  5234. kickClient->Disconnect();
  5235. }
  5236. else
  5237. {
  5238. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  5239. }
  5240. }
  5241. break;
  5242. }
  5243. case COMMAND_LOCK:
  5244. {
  5245. if( sep != NULL && sep->arg[0] != NULL && sep->IsNumber(0)){
  5246. int worldLocked = atoi(sep->arg[0]);
  5247. net.world_locked = worldLocked;
  5248. if ( worldLocked )
  5249. client->Message(CHANNEL_COLOR_YELLOW,"World server has been locked.");
  5250. else
  5251. client->Message(CHANNEL_COLOR_YELLOW,"World server has been unlocked.");
  5252. }
  5253. else
  5254. client->SimpleMessage(CHANNEL_COLOR_RED, "/lock [0/1]");
  5255. break;
  5256. }
  5257. case COMMAND_BAN:{
  5258. if( sep == 0 || sep->arg[0] == 0 || (sep->arg[1][0] != 0 && !sep->IsNumber(1) ) )
  5259. {
  5260. client->SimpleMessage(CHANNEL_COLOR_RED, "/ban [name] [permanent:0/1]");
  5261. }
  5262. else
  5263. {
  5264. Client* kickClient = zone_list.GetClientByCharName(sep->arg[0]);
  5265. if ( kickClient == client )
  5266. {
  5267. client->Message(CHANNEL_COLOR_RED, "You can't ban yourself!");
  5268. break;
  5269. }
  5270. else if(kickClient != NULL)
  5271. {
  5272. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  5273. if ( maxStatus > client->GetAdminStatus( ) ||
  5274. client->GetAdminStatus ( ) > kickClient->GetAdminStatus ( ) )
  5275. {
  5276. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  5277. break;
  5278. }
  5279. client->Message(CHANNEL_COLOR_RED, "Kicking & Banning %s...",sep->arg[0]);
  5280. int perm = atol(sep->arg[1]);
  5281. if ( perm == 1 )
  5282. database.UpdateAdminStatus(sep->arg[0],-2);
  5283. else
  5284. database.UpdateAdminStatus(sep->arg[0],-1);
  5285. kickClient->Disconnect();
  5286. }
  5287. else
  5288. {
  5289. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  5290. }
  5291. }
  5292. break;
  5293. }
  5294. case COMMAND_SET_COMBAT_VOICE:{
  5295. int32 value = 0;
  5296. if(sep && sep->arg[0] && sep->IsNumber(0))
  5297. value = atoi(sep->arg[0]);
  5298. client->GetPlayer()->SetCombatVoice(value);
  5299. break;
  5300. }
  5301. case COMMAND_SET_EMOTE_VOICE:{
  5302. int32 value = 0;
  5303. if(sep && sep->arg[0] && sep->IsNumber(0))
  5304. value = atoi(sep->arg[0]);
  5305. client->GetPlayer()->SetEmoteVoice(value);
  5306. break;
  5307. }
  5308. case COMMAND_GIVEITEM:{
  5309. if(sep && sep->arg[0][0] && sep->arg[0][1] && sep->IsNumber(1)){
  5310. Client* itemToClient = zone_list.GetClientByCharName(sep->arg[0]);
  5311. if ( itemToClient == NULL )
  5312. client->Message(CHANNEL_COLOR_YELLOW,"Could not find %s.",sep->arg[0]);
  5313. else
  5314. {
  5315. int32 item_id = atol(sep->arg[1]);
  5316. client->Message(CHANNEL_COLOR_YELLOW,"Gave %s item id %i.",sep->arg[0],item_id);
  5317. itemToClient->AddItem(item_id);
  5318. }
  5319. }
  5320. else
  5321. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /giveitem [name] [item_id]");
  5322. break;
  5323. }
  5324. case COMMAND_REPORT_BUG : { Command_ReportBug(client, sep); break; }
  5325. case COMMAND_INVENTORY : { Command_Inventory(client, sep, command); break; }
  5326. case COMMAND_WEAPONSTATS : { Command_WeaponStats(client); break; }
  5327. case COMMAND_SKILL :
  5328. case COMMAND_SKILL_ADD :
  5329. case COMMAND_SKILL_REMOVE :
  5330. case COMMAND_SKILL_LIST : { Command_Skills(client, sep, command->handler); break; }
  5331. case COMMAND_ZONE_SET : { Command_ZoneSet(client, sep); break; }
  5332. case COMMAND_ZONE_DETAILS : { Command_ZoneDetails(client, sep); break; }
  5333. case COMMAND_ENTITYCOMMAND :
  5334. case COMMAND_ENTITYCOMMAND_LIST : { Command_EntityCommand(client, sep, command->handler); break; }
  5335. case COMMAND_MERCHANT :
  5336. case COMMAND_MERCHANT_LIST : { Command_Merchant(client, sep, command->handler); break; }
  5337. case COMMAND_APPEARANCE :
  5338. case COMMAND_APPEARANCE_LIST : { Command_Appearance(client, sep, command->handler); break; }
  5339. case COMMAND_TRACK : { Command_Track(client); break; }
  5340. case COMMAND_DISTANCE : { Command_Distance(client); break; }
  5341. case COMMAND_INSPECT_PLAYER : { Command_InspectPlayer(client, sep); break; }
  5342. case COMMAND_ZONE_SAFE : { Command_ZoneSafeCoords(client, sep); break; }
  5343. case COMMAND_GUILDSAY : { Command_GuildSay(client, sep); break; }
  5344. case COMMAND_OFFICERSAY : { Command_OfficerSay(client, sep); break; }
  5345. case COMMAND_SET_GUILD_MEMBER_NOTE : { Command_SetGuildMemberNote(client, sep); break; }
  5346. case COMMAND_SET_GUILD_OFFICER_NOTE : { Command_SetGuildOfficerNote(client, sep); break; }
  5347. case COMMAND_GUILD : { Command_Guild(client, sep); break; }
  5348. case COMMAND_CREATE_GUILD : { Command_CreateGuild(client); break; }
  5349. case COMMAND_GUILDS : { Command_Guilds(client); break; }
  5350. case COMMAND_GUILDS_ADD : { Command_GuildsAdd(client, sep); break; }
  5351. case COMMAND_GUILDS_CREATE : { Command_GuildsCreate(client, sep); break; }
  5352. case COMMAND_GUILDS_DELETE : { Command_GuildsDelete(client, sep); break; }
  5353. case COMMAND_GUILDS_LIST : { Command_GuildsList(client); break; }
  5354. case COMMAND_GUILDS_REMOVE : { Command_GuildsRemove(client, sep); break; }
  5355. case COMMAND_CLAIM : { Command_Claim(client, sep); break; }
  5356. case COMMAND_CLEAR_ALL_QUEUED : { Command_ClearAllQueued(client); break; }
  5357. case COMMAND_LOCATION : { Command_Location(client); break; }
  5358. case COMMAND_LOCATION_ADD : { Command_LocationAdd(client, sep); break; }
  5359. case COMMAND_LOCATION_CREATE : { Command_LocationCreate(client, sep); break; }
  5360. case COMMAND_LOCATION_DELETE : { Command_LocationDelete(client, sep); break; }
  5361. case COMMAND_LOCATION_LIST : { Command_LocationList(client, sep); break; }
  5362. case COMMAND_LOCATION_REMOVE : { Command_LocationRemove(client, sep); break; }
  5363. case COMMAND_GRID : { Command_Grid(client, sep); break; }
  5364. case COMMAND_TRY_ON : { Command_TryOn(client, sep); break; }
  5365. case COMMAND_RANDOMIZE : { Command_Randomize(client, sep); break; }
  5366. case COMMAND_AFK : { Command_AFK(client, sep); break; }
  5367. case COMMAND_SHOW_CLOAK : { Command_ShowCloak(client, sep); break; }
  5368. case COMMAND_SHOW_HELM : { Command_ShowHelm(client, sep); break; }
  5369. case COMMAND_SHOW_HOOD : { Command_ShowHood(client, sep); break; }
  5370. case COMMAND_SHOW_HOOD_OR_HELM : { Command_ShowHoodHelm(client, sep); break; }
  5371. case COMMAND_SHOW_RANGED : { Command_ShowRanged(client, sep); break; }
  5372. case COMMAND_STOP_DRINKING : { Command_StopDrinking(client); break; }
  5373. case COMMAND_STOP_EATING : { Command_StopEating(client); break; }
  5374. case COMMAND_TOGGLE_ANONYMOUS : { Command_Toggle_Anonymous(client); break; }
  5375. case COMMAND_TOGGLE_AUTOCONSUME : { Command_Toggle_AutoConsume(client, sep); break; }
  5376. case COMMAND_TOGGLE_BONUS_EXP : { Command_Toggle_BonusXP(client); break; }
  5377. case COMMAND_TOGGLE_COMBAT_EXP : { Command_Toggle_CombatXP(client); break; }
  5378. case COMMAND_TOGGLE_GM_HIDE : { Command_Toggle_GMHide(client); break; }
  5379. case COMMAND_TOGGLE_GM_VANISH : { Command_Toggle_GMVanish(client); break; }
  5380. case COMMAND_TOGGLE_ILLUSIONS : { Command_Toggle_Illusions(client, sep); break; }
  5381. case COMMAND_TOGGLE_LFG : { Command_Toggle_LFG(client); break; }
  5382. case COMMAND_TOGGLE_LFW : { Command_Toggle_LFW(client); break; }
  5383. case COMMAND_TOGGLE_QUEST_EXP : { Command_Toggle_QuestXP(client); break; }
  5384. case COMMAND_TOGGLE_ROLEPLAYING : { Command_Toggle_Roleplaying(client); break; }
  5385. case COMMAND_TOGGLE_DUELS : { Command_Toggle_Duels(client); break; }
  5386. case COMMAND_TOGGLE_TRADES : { Command_Toggle_Trades(client); break; }
  5387. case COMMAND_TOGGLE_GUILDS : { Command_Toggle_Guilds(client); break; }
  5388. case COMMAND_TOGGLE_GROUPS : { Command_Toggle_Groups(client); break; }
  5389. case COMMAND_TOGGLE_RAIDS : { Command_Toggle_Raids(client); break; }
  5390. case COMMAND_TOGGLE_LON : { Command_Toggle_LON(client); break; }
  5391. case COMMAND_TOGGLE_VCINVITE : { Command_Toggle_VoiceChat(client); break; }
  5392. case COMMAND_CANCEL_MAINTAINED : { Command_CancelMaintained(client, sep); break; }
  5393. case COMMAND_MOTD : { Command_MOTD(client); break; }
  5394. case COMMAND_RANDOM : { Command_Random(client, sep); break; }
  5395. case COMMAND_CREATE : { Command_Create(client, sep); break; }
  5396. case COMMAND_CREATEFROMRECIPE : { Command_CreateFromRecipe(client, sep); break; }
  5397. case COMMAND_TITLE : { Command_Title(client); break; }
  5398. case COMMAND_TITLE_LIST : { Command_TitleList(client); break; }
  5399. case COMMAND_TITLE_SETPREFIX : { Command_TitleSetPrefix(client, sep); break; }
  5400. case COMMAND_TITLE_SETSUFFIX : { Command_TitleSetSuffix(client, sep); break; }
  5401. case COMMAND_TITLE_FIX : { Command_TitleFix(client, sep); break; }
  5402. case COMMAND_LANGUAGES : { Command_Languages(client, sep); break; }
  5403. case COMMAND_SET_LANGUAGE : { Command_SetLanguage(client, sep); break; }
  5404. case COMMAND_FOLLOW : { Command_Follow(client, sep); break; }
  5405. case COMMAND_STOP_FOLLOW : { Command_StopFollow(client, sep); break; }
  5406. case COMMAND_LASTNAME : { Command_LastName(client, sep); break; }
  5407. case COMMAND_CONFIRMLASTNAME : { Command_ConfirmLastName(client, sep); break; }
  5408. case COMMAND_PET : { Command_Pet(client, sep); break; }
  5409. case COMMAND_PETNAME : { Command_PetName(client, sep); break; }
  5410. case COMMAND_NAME_PET : { Command_NamePet(client, sep); break; }
  5411. case COMMAND_RENAME : { Command_Rename(client, sep); break; }
  5412. case COMMAND_CONFIRMRENAME : { Command_ConfirmRename(client, sep); break; }
  5413. case COMMAND_PETOPTIONS : { Command_PetOptions(client, sep); break; }
  5414. case COMMAND_START_TRADE : { Command_TradeStart(client, sep); break; }
  5415. case COMMAND_ACCEPT_TRADE : { Command_TradeAccept(client, sep); break; }
  5416. case COMMAND_REJECT_TRADE : { Command_TradeReject(client, sep); break; }
  5417. case COMMAND_CANCEL_TRADE : { Command_TradeCancel(client, sep); break; }
  5418. case COMMAND_SET_TRADE_COIN : { Command_TradeSetCoin(client, sep); break; }
  5419. case COMMAND_ADD_TRADE_COPPER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_COPPER); break; }
  5420. case COMMAND_ADD_TRADE_SILVER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_SILVER); break; }
  5421. case COMMAND_ADD_TRADE_GOLD : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_GOLD); break; }
  5422. case COMMAND_ADD_TRADE_PLAT : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_PLAT); break; }
  5423. case COMMAND_REMOVE_TRADE_COPPER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_COPPER); break; }
  5424. case COMMAND_REMOVE_TRADE_SILVER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_SILVER); break; }
  5425. case COMMAND_REMOVE_TRADE_GOLD : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_GOLD); break; }
  5426. case COMMAND_REMOVE_TRADE_PLAT : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_PLAT); break; }
  5427. case COMMAND_ADD_TRADE_ITEM : { Command_TradeAddItem(client, sep); break; }
  5428. case COMMAND_REMOVE_TRADE_ITEM : { Command_TradeRemoveItem(client, sep); break; }
  5429. case COMMAND_ACCEPT_ADVANCEMENT : { Command_AcceptAdvancement(client, sep); break; }
  5430. case COMMAND_DUEL : { Command_Duel(client, sep); break; }
  5431. case COMMAND_DUELBET : { Command_DuelBet(client, sep); break; }
  5432. case COMMAND_DUEL_ACCEPT : { Command_DuelAccept(client, sep); break; }
  5433. case COMMAND_DUEL_DECLINE : { Command_DuelDecline(client, sep); break; }
  5434. case COMMAND_DUEL_SURRENDER : { Command_DuelSurrender(client, sep); break; }
  5435. case COMMAND_DUEL_TOGGLE : { Command_DuelToggle(client, sep); break; }
  5436. case COMMAND_SPAWN_TEMPLATE : { Command_SpawnTemplate(client, sep); break; }
  5437. //devn00b
  5438. case COMMAND_MOOD : { Command_Mood(client, sep); break;}
  5439. case COMMAND_MODIFY : { Command_Modify(client); break; }
  5440. case COMMAND_MODIFY_CHARACTER : { Command_ModifyCharacter(client, sep); break; }
  5441. case COMMAND_MODIFY_QUEST : { Command_ModifyQuest(client, sep); break; }
  5442. case COMMAND_MODIFY_FACTION : { Command_ModifyFaction(client, sep); break; }
  5443. case COMMAND_MODIFY_GUILD : { Command_ModifyGuild(client, sep); break; }
  5444. case COMMAND_MODIFY_ITEM : { Command_ModifyItem(client, sep); break; }
  5445. case COMMAND_MODIFY_SKILL : { Command_ModifySkill(client, sep); break; }
  5446. case COMMAND_MODIFY_SPAWN : { Command_ModifySpawn(client, sep); break; }
  5447. case COMMAND_MODIFY_SPELL : { Command_ModifySpell(client, sep); break; }
  5448. case COMMAND_MODIFY_ZONE : { Command_ModifyZone(client, sep); break; }
  5449. case COMMAND_JOIN_CHANNEL : { Command_JoinChannel(client, sep); break;}
  5450. case COMMAND_JOIN_CHANNEL_FROM_LOAD: { Command_JoinChannelFromLoad(client, sep); break;}
  5451. case COMMAND_TELL_CHANNEL : { Command_TellChannel(client, sep); break;}
  5452. case COMMAND_LEAVE_CHANNEL : { Command_LeaveChannel(client, sep); break;}
  5453. case COMMAND_WHO_CHANNEL : { Command_WhoChannel(client, sep); break;}
  5454. case COMMAND_RAIN : { Command_Rain(client, sep); break; }
  5455. case COMMAND_WIND : { Command_Wind(client, sep); break; }
  5456. case COMMAND_WEATHER : { Command_Weather(client, sep); break; }
  5457. case COMMAND_FROM_MERCHANT : { Command_SendMerchantWindow(client, sep); break; }
  5458. case COMMAND_TO_MERCHANT : { Command_SendMerchantWindow(client, sep, true); break; }
  5459. case COMMAND_SELECT : { Command_Select(client, sep); break; }
  5460. case COMMAND_SMP : { Command_StationMarketPlace(client, sep); break; }
  5461. case COMMAND_CONSUME_FOOD : { Command_ConsumeFood(client, sep); break; }
  5462. case COMMAND_SET_CONSUME_FOOD : { Command_ConsumeFood(client, sep); break; }
  5463. case COMMAND_AQUAMAN : { Command_Aquaman(client, sep); break; }
  5464. case COMMAND_ATTUNE_INV : { Command_Attune_Inv(client, sep); break; }
  5465. case COMMAND_PLAYER : { Command_Player(client, sep); break; }
  5466. case COMMAND_PLAYER_COINS : { Command_Player_Coins(client, sep); break; }
  5467. case COMMAND_RESET_ZONE_TIMER : { Command_Reset_Zone_Timer(client, sep); break; }
  5468. case COMMAND_ACHIEVEMENT_ADD : { Command_AchievementAdd(client, sep); break; }
  5469. case COMMAND_EDITOR : { Command_Editor(client, sep); break; }
  5470. case COMMAND_ACCEPT_RESURRECTION: { Command_AcceptResurrection(client, sep); break; }
  5471. case COMMAND_DECLINE_RESURRECTION:{ Command_DeclineResurrection(client, sep); break; }
  5472. case COMMAND_TEST : { Command_Test(client, command_parms); break; }
  5473. case COMMAND_SPEED : { Command_Speed(client, sep); break; }
  5474. case COMMAND_BOT : { Command_Bot(client, sep); break; }
  5475. case COMMAND_BOT_CREATE : { Command_Bot_Create(client, sep); break; }
  5476. case COMMAND_BOT_CUSTOMIZE : { Command_Bot_Customize(client, sep); break; }
  5477. case COMMAND_BOT_SPAWN : { Command_Bot_Spawn(client, sep); break; }
  5478. case COMMAND_BOT_LIST : { Command_Bot_List(client, sep); break; }
  5479. case COMMAND_BOT_INV : { Command_Bot_Inv(client, sep); break; }
  5480. case COMMAND_BOT_SETTINGS : { Command_Bot_Settings(client, sep); break; }
  5481. case COMMAND_BOT_HELP : { Command_Bot_Help(client, sep); break; }
  5482. case GET_AA_XML : { Get_AA_Xml(client, sep); break; }
  5483. case ADD_AA : { Add_AA(client, sep); break; }
  5484. case COMMIT_AA_PROFILE : { Commit_AA_Profile(client, sep); break; }
  5485. case BEGIN_AA_PROFILE : { Begin_AA_Profile(client, sep); break; }
  5486. case BACK_AA : { Back_AA(client, sep); break; }
  5487. case REMOVE_AA : { Remove_AA(client, sep); break; }
  5488. case SWITCH_AA_PROFILE : { Switch_AA_Profile(client, sep); break; }
  5489. case CANCEL_AA_PROFILE : { Cancel_AA_Profile(client, sep); break; }
  5490. case SAVE_AA_PROFILE : { Save_AA_Profile(client, sep); break; }
  5491. case COMMAND_TARGETITEM : { Command_TargetItem(client, sep); break; }
  5492. case COMMAND_FINDSPAWN: { Command_FindSpawn(client, sep); break; }
  5493. case COMMAND_MOVECHARACTER: { Command_MoveCharacter(client, sep); break; }
  5494. case COMMAND_CRAFTITEM: {
  5495. Item* item = 0;
  5496. if (sep && sep->IsNumber(0)) {
  5497. int32 item_id = atol(sep->arg[0]);
  5498. int32 quantity = 1;
  5499. if (sep->arg[1] && sep->IsNumber(1))
  5500. quantity = atoi(sep->arg[1]);
  5501. item = new Item(master_item_list.GetItem(item_id));
  5502. if (!item) {
  5503. LogWrite(TRADESKILL__ERROR, 0, "CraftItem", "Item (%u) not found.", item_id);
  5504. }
  5505. else {
  5506. item->details.count = quantity;
  5507. // use CHANNEL_COLOR_CHAT_RELATIONSHIP as that is the same value (4) as it is in a log for this message
  5508. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You created %s.", item->CreateItemLink(client->GetVersion()).c_str());
  5509. bool itemDeleted = false;
  5510. client->AddItem(item, &itemDeleted);
  5511. //Check for crafting quest updates
  5512. int8 update_amt = 0;
  5513. if (!itemDeleted && item->stack_count > 1)
  5514. update_amt = 1;
  5515. else
  5516. update_amt = quantity;
  5517. if(!itemDeleted)
  5518. client->GetPlayer()->CheckQuestsCraftUpdate(item, update_amt);
  5519. }
  5520. }
  5521. else {
  5522. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /craftitem {item_id} [quantity] ");
  5523. }
  5524. break;
  5525. }
  5526. case COMMAND_UNMENTOR:
  5527. case COMMAND_MENTOR: {
  5528. client->GetPlayer()->MentorTarget();
  5529. break;
  5530. }
  5531. case COMMAND_CANCEL_EFFECT: { Command_CancelEffect(client, sep); break; }
  5532. case COMMAND_CUREPLAYER: { Command_CurePlayer(client, sep); break; }
  5533. case COMMAND_SHARE_QUEST: { Command_ShareQuest(client, sep); break; }
  5534. case COMMAND_YELL: { Command_Yell(client, sep); break; }
  5535. case COMMAND_SETAUTOLOOTMODE: { Command_SetAutoLootMode(client, sep); break; }
  5536. case COMMAND_ASSIST: { Command_Assist(client, sep); break; }
  5537. case COMMAND_TARGET: { Command_Target(client, sep); break; }
  5538. case COMMAND_TARGET_PET: { Command_Target_Pet(client, sep); break; }
  5539. case COMMAND_WHOGROUP: { Command_WhoGroup(client, sep); break; }
  5540. case COMMAND_WHORAID: { Command_WhoRaid(client, sep); break; }
  5541. case COMMAND_RAIDINVITE: { Command_RaidInvite(client, sep); break; }
  5542. case COMMAND_RAID_LOOTER: { Command_Raid_Looter(client, sep); break; }
  5543. case COMMAND_KICKFROMGROUP: { Command_KickFromGroup(client, sep); break; }
  5544. case COMMAND_KICKFROMRAID: { Command_KickFromRaid(client, sep); break; }
  5545. case COMMAND_LEAVERAID: { Command_LeaveRaid(client, sep); break; }
  5546. case COMMAND_SPLIT: { Command_Split(client, sep); break; }
  5547. case COMMAND_RAIDSAY: { Command_RaidSay(client, sep); break; }
  5548. default:
  5549. {
  5550. LogWrite(COMMAND__WARNING, 0, "Command", "Unhandled command: %s", command->command.data.c_str());
  5551. break;
  5552. }
  5553. }
  5554. safe_delete(sep);
  5555. }
  5556. /******************** New COMMAND Handler Functions ********************/
  5557. /*
  5558. Started breaking apart the huge switch() for commands into sepErate
  5559. functions so it is easier to locate the blocks of code by command
  5560. -- JA 2012.03.03
  5561. */
  5562. // sample function header
  5563. /*
  5564. Function:
  5565. Purpose :
  5566. Params :
  5567. Dev :
  5568. Example :
  5569. */
  5570. //void Commands::Command()
  5571. //{
  5572. //}
  5573. /*
  5574. Function: Command_AcceptAdvancement()
  5575. Purpose : Player accepts a new advancement option
  5576. Params : Spell ID
  5577. Dev : Jabantiz
  5578. */
  5579. void Commands::Command_AcceptAdvancement(Client* client, Seperator* sep)
  5580. {
  5581. Player *player = client->GetPlayer();
  5582. if (sep && sep->IsSet(0)) {
  5583. int32 trait_id = atoul(sep->arg[0]);
  5584. TraitData* trait = nullptr;
  5585. if(client->GetVersion() <= 561) {
  5586. trait = master_trait_list.GetTraitByItemID(trait_id);
  5587. }
  5588. else {
  5589. trait = master_trait_list.GetTrait(trait_id);
  5590. }
  5591. if(!trait) {
  5592. LogWrite(COMMAND__ERROR, 0, "Command", "Invalid accept advancement of trait %u, no trait found.", trait_id);
  5593. return; // not valid lets not crash!
  5594. }
  5595. if(!master_trait_list.IsPlayerAllowedTrait(client, trait)) {
  5596. client->SimpleMessage(CHANNEL_COLOR_RED, "Not enough trait points to accept trait.");
  5597. return;
  5598. }
  5599. // Check to see if this is a trait or grandmaster training (traits are always new spells, training is always upgrades)
  5600. if (!player->HasSpell(trait->spellID, 0, true))
  5601. {
  5602. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  5603. if(spell) {
  5604. player->AddSpellBookEntry(trait->spellID, trait->tier, player->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  5605. }
  5606. else {
  5607. client->Message(CHANNEL_COLOR_RED, "ERROR! Trait is not a valid spell id %u may be disabled.", trait->spellID);
  5608. }
  5609. }
  5610. else
  5611. {
  5612. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  5613. if(spell) {
  5614. int8 old_slot = player->GetSpellSlot(spell->GetSpellID());
  5615. player->RemoveSpellBookEntry(spell->GetSpellID());
  5616. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  5617. player->UnlockSpell(spell);
  5618. client->SendSpellUpdate(spell);
  5619. }
  5620. else {
  5621. client->Message(CHANNEL_COLOR_RED, "ERROR! Trait is not a valid spell id %u may be disabled.", trait->spellID);
  5622. }
  5623. }
  5624. // Spell book update
  5625. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  5626. client->QueuePacket(master_trait_list.GetTraitListPacket(client));
  5627. if(client->GetVersion() <= 561) {
  5628. master_trait_list.ChooseNextTrait(client);
  5629. }
  5630. }
  5631. }
  5632. /*
  5633. Function:
  5634. Purpose :
  5635. Params :
  5636. Dev :
  5637. Example :
  5638. */
  5639. void Commands::Command_AFK(Client* client, Seperator* sep)
  5640. {
  5641. Player* player = client->GetPlayer();
  5642. player->toggle_character_flag(CF_AFK);
  5643. client->Message(CHANNEL_COLOR_YELLOW,"You are %s afk.", client->GetPlayer()->get_character_flag(CF_AFK)?"now":"no longer");
  5644. if (player->get_character_flag(CF_AFK))
  5645. {
  5646. if (sep && sep->argplus[0])
  5647. player->SetAwayMessage("I am away from the keyboard, " + string(sep->argplus[0]));
  5648. else
  5649. player->SetAwayMessage("Sorry, I am A.F.K. (Away From Keyboard)");
  5650. string message = string(player->GetName()) + " is going afk.";
  5651. Spawn* target = player->GetTarget();
  5652. if (target && target != player)
  5653. {
  5654. message = string(player->GetName()) + " tells " + string(target->GetName()) + " that ";
  5655. player->GetGender() == 1 ? message += "he" : message += "she";
  5656. message += " is going afk.";
  5657. }
  5658. player->GetZone()->SimpleMessage(CHANNEL_COLOR_YELLOW, message.c_str(), player, 30);
  5659. }
  5660. if (player->get_character_flag(CF_AFK))
  5661. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_AFK);
  5662. else
  5663. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_AFK);
  5664. }
  5665. /*
  5666. Function: Command_Appearance()
  5667. Purpose : Handles /appearance commands
  5668. Params : list
  5669. Dev : Scatman
  5670. Example : /appearance list
  5671. */
  5672. void Commands::Command_Appearance(Client* client, Seperator* sep, int handler)
  5673. {
  5674. if( handler == COMMAND_APPEARANCE )
  5675. {
  5676. // /appearance command by itself shows help (to be extended)
  5677. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  5678. return;
  5679. }
  5680. else if( handler == COMMAND_APPEARANCE_LIST )
  5681. {
  5682. // /appearance list command expects "name" param
  5683. if (sep && sep->arg[0])
  5684. {
  5685. const char* appearance_name = sep->argplus[0];
  5686. client->Message(CHANNEL_COLOR_YELLOW, "Listing appearances like '%s':", appearance_name);
  5687. vector<int16>* appearances = database.GetAppearanceIDsLikeName(string(appearance_name));
  5688. if (appearances)
  5689. {
  5690. vector<int16>::iterator itr;
  5691. for (itr = appearances->begin(); itr != appearances->end(); itr++)
  5692. {
  5693. int16 id = *itr;
  5694. string name = database.GetAppearanceName(id);
  5695. if (ToLower(name).find(ToLower(string(appearance_name))) < 0xFFFFFFFF)
  5696. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", name.c_str(), id);
  5697. }
  5698. safe_delete(appearances);
  5699. }
  5700. }
  5701. else // no param
  5702. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  5703. }
  5704. }
  5705. /*
  5706. Function: Command_Claim()
  5707. Purpose : Summon veteran rewards
  5708. Params : nothing = show claim window, any number claims that item.
  5709. Dev : devn00b
  5710. Example : /claim 0 (claims the 1st item added to the list claim[0])
  5711. */
  5712. void Commands::Command_Claim(Client* client, Seperator* sep)
  5713. {
  5714. //if we were passed a claim id
  5715. if (sep && sep->argplus[0] && sep->IsNumber(0))
  5716. {
  5717. int32 char_id = client->GetCharacterID();
  5718. int8 my_claim_id = atoi(sep->argplus[0]);
  5719. vector<ClaimItems> claim = database.LoadCharacterClaimItems(char_id);
  5720. Item* item = master_item_list.GetItem(claim[my_claim_id].item_id);
  5721. database.ClaimItem(char_id, item->details.item_id, client);
  5722. return;
  5723. }
  5724. else {
  5725. //if no arg just send the window.
  5726. client->ShowClaimWindow();
  5727. return;
  5728. }
  5729. return;
  5730. }
  5731. /*
  5732. Function: Command_ClearAllQueued()
  5733. Purpose :
  5734. Params :
  5735. Dev :
  5736. Example :
  5737. */
  5738. void Commands::Command_ClearAllQueued(Client* client)
  5739. {
  5740. ZoneServer* zone = client->GetPlayer()->GetZone();
  5741. if (zone && zone->GetSpellProcess())
  5742. zone->GetSpellProcess()->RemoveSpellFromQueue(client->GetPlayer());
  5743. }
  5744. /*
  5745. Function: Command_CancelMaintained()
  5746. Purpose : Cancels maintained spells
  5747. Params : Maintained Spell Index
  5748. Dev : Zcoretri
  5749. Example : /cancel_maintained 1 - would cancel the spell in slot 1 of Maintained Spells list
  5750. */
  5751. void Commands::Command_CancelMaintained(Client* client, Seperator* sep)
  5752. {
  5753. if (sep && sep->arg[0] && sep->IsNumber(0))
  5754. {
  5755. int32 spell_index = atoul(sep->arg[0]);
  5756. if(spell_index > 29)
  5757. return;
  5758. client->GetPlayer()->MMaintainedSpells.readlock(__FUNCTION__, __LINE__);
  5759. MaintainedEffects mEffects = client->GetPlayer()->GetInfoStruct()->maintained_effects[spell_index];
  5760. client->GetPlayer()->MMaintainedSpells.releasereadlock(__FUNCTION__, __LINE__);
  5761. if (!client->GetPlayer()->GetZone()->GetSpellProcess()->DeleteCasterSpell(mEffects.spell, "canceled", false))
  5762. client->Message(CHANNEL_COLOR_RED, "The maintained spell could not be cancelled.");
  5763. }
  5764. }
  5765. /*
  5766. Function: Command_Create()
  5767. Purpose : Handler for starting Tradeskilling table
  5768. Params :
  5769. Dev : Zcoretri
  5770. Example :
  5771. */
  5772. void Commands::Command_Create(Client* client, Seperator* sep)
  5773. {
  5774. PrintSep(sep, "COMMAND_CREATE");
  5775. client->ShowRecipeBook();
  5776. }
  5777. void Commands::Command_CreateFromRecipe(Client* client, Seperator* sep)
  5778. {
  5779. PrintSep(sep, "COMMAND_CREATEFROMRECIPE");
  5780. if (sep && sep->arg[0] && sep->IsNumber(0))
  5781. ClientPacketFunctions::SendCreateFromRecipe(client, atoul(sep->arg[0]));
  5782. }
  5783. /*
  5784. Function: Command_Distance()
  5785. Purpose : Displays distance from targeted spawn
  5786. Params :
  5787. Dev : Scatman
  5788. Example : /distance
  5789. */
  5790. void Commands::Command_Distance(Client* client)
  5791. {
  5792. Spawn* target = client->GetPlayer()->GetTarget();
  5793. if (target)
  5794. client->Message(CHANNEL_COLOR_YELLOW, "Your distance from %s is %f", target->GetName(), client->GetPlayer()->GetDistance(target));
  5795. else
  5796. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must have a spawn targeted to use /distance");
  5797. }
  5798. /*
  5799. Function: Command_Duel()
  5800. Purpose : Handle the /duel commands - not yet implemented
  5801. Params : unknown
  5802. Dev :
  5803. Example :
  5804. */
  5805. void Commands::Command_Duel(Client* client, Seperator* sep)
  5806. {
  5807. PrintSep(sep, "COMMAND_DUEL");
  5808. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Command");
  5809. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5810. }
  5811. /*
  5812. Function: Command_DuelBet()
  5813. Purpose : Handle the /duel commands - not yet implemented
  5814. Params : unknown
  5815. Dev :
  5816. Example :
  5817. */
  5818. void Commands::Command_DuelBet(Client* client, Seperator* sep)
  5819. {
  5820. PrintSep(sep, "COMMAND_DUELBET");
  5821. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Bet Command");
  5822. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5823. }
  5824. /*
  5825. Function: Command_DuelAccept()
  5826. Purpose : Handle the /duel commands - not yet implemented
  5827. Params : unknown
  5828. Dev :
  5829. Example :
  5830. */
  5831. void Commands::Command_DuelAccept(Client* client, Seperator* sep)
  5832. {
  5833. PrintSep(sep, "COMMAND_DUEL_ACCEPT");
  5834. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Accept Duel Command");
  5835. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5836. }
  5837. /*
  5838. Function: Command_DuelDecline()
  5839. Purpose : Handle the /duel commands - not yet implemented
  5840. Params : unknown
  5841. Dev :
  5842. Example :
  5843. */
  5844. void Commands::Command_DuelDecline(Client* client, Seperator* sep)
  5845. {
  5846. PrintSep(sep, "COMMAND_DUEL_DECLINE");
  5847. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Decline Duel Request Command");
  5848. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5849. }
  5850. /*
  5851. Function: Command_DuelSurrender()
  5852. Purpose : Handle the /duel commands - not yet implemented
  5853. Params : unknown
  5854. Dev :
  5855. Example :
  5856. */
  5857. void Commands::Command_DuelSurrender(Client* client, Seperator* sep)
  5858. {
  5859. PrintSep(sep, "COMMAND_DUEL_SURRENDER");
  5860. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Surrender Duel Command");
  5861. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5862. // JA, just messin around ;)
  5863. char surrender[64];
  5864. sprintf(surrender, "%s surrendered like a cowardly dog!", client->GetPlayer()->GetName());
  5865. zone_list.HandleGlobalAnnouncement(surrender);
  5866. }
  5867. /*
  5868. Function: Command_DuelToggle()
  5869. Purpose : Handle the /duel commands - not yet implemented
  5870. Params : unknown
  5871. Dev :
  5872. Example :
  5873. */
  5874. void Commands::Command_DuelToggle(Client* client, Seperator* sep)
  5875. {
  5876. PrintSep(sep, "COMMAND_DUEL");
  5877. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Commands");
  5878. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5879. }
  5880. /*
  5881. Function:
  5882. Purpose :
  5883. Params :
  5884. Dev :
  5885. Example :
  5886. */
  5887. void Commands::Command_EntityCommand(Client* client, Seperator* sep, int handler)
  5888. {
  5889. if( handler == COMMAND_ENTITYCOMMAND )
  5890. {
  5891. // /entitycommand command by itself shows help (to be extended)
  5892. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  5893. return;
  5894. }
  5895. else if( handler == COMMAND_ENTITYCOMMAND_LIST )
  5896. {
  5897. // /entitycommand list command expects "name" param
  5898. if (sep && sep->arg[0])
  5899. {
  5900. const char* entity_command_name = sep->argplus[0];
  5901. client->Message(CHANNEL_COLOR_YELLOW, "Listing entity commands like '%s':", entity_command_name);
  5902. map<int32, vector<EntityCommand*>*>* entity_command_list_all = client->GetCurrentZone()->GetEntityCommandListAll();
  5903. map<int32, vector<EntityCommand*>*>::iterator itr;
  5904. for (itr = entity_command_list_all->begin(); itr != entity_command_list_all->end(); itr++)
  5905. {
  5906. vector<EntityCommand*>* entity_command_list = itr->second;
  5907. vector<EntityCommand*>::iterator itr2;
  5908. for (itr2 = entity_command_list->begin(); itr2 != entity_command_list->end(); itr2++)
  5909. {
  5910. EntityCommand* entity_command = *itr2;
  5911. if (ToLower(entity_command->name).find(ToLower(string(entity_command_name))) < 0xFFFFFFFF)
  5912. client->Message(CHANNEL_COLOR_YELLOW, "Command Text: %s, Command List ID: %u, Distance: %f\n", entity_command->name.c_str(), itr->first, entity_command->distance);
  5913. }
  5914. }
  5915. }
  5916. else // no command name
  5917. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  5918. }
  5919. }
  5920. /*
  5921. Function: Command_Follow()
  5922. Purpose : Handle the /follow command - not yet implemented
  5923. Params :
  5924. Dev :
  5925. Example :
  5926. */
  5927. void Commands::Command_Follow(Client* client, Seperator* sep)
  5928. {
  5929. PrintSep(sep, "COMMAND_FOLLOW");
  5930. // flag to toggle if the players target is in the players group
  5931. bool targetInGroup = false;
  5932. // get a pointer to the players group
  5933. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  5934. // If the player has a group and has a target
  5935. if (gmi && client->GetPlayer()->GetTarget()) {
  5936. deque<GroupMemberInfo*>::iterator itr;
  5937. world.GetGroupManager()->GroupLock(__FUNCTION__, __LINE__);
  5938. PlayerGroup* group = world.GetGroupManager()->GetGroup(gmi->group_id);
  5939. if (group)
  5940. {
  5941. group->MGroupMembers.readlock(__FUNCTION__, __LINE__);
  5942. deque<GroupMemberInfo*>* members = group->GetMembers();
  5943. // Loop through the group members
  5944. for (itr = members->begin(); itr != members->end(); itr++) {
  5945. // If a group member matches a target
  5946. if ((*itr)->member && (*itr)->member == client->GetPlayer()->GetTarget()) {
  5947. // toggle the flag and break the loop
  5948. targetInGroup = true;
  5949. break;
  5950. }
  5951. }
  5952. group->MGroupMembers.releasereadlock(__FUNCTION__, __LINE__);
  5953. }
  5954. world.GetGroupManager()->ReleaseGroupLock(__FUNCTION__, __LINE__);
  5955. }
  5956. if (targetInGroup) {
  5957. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  5958. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You start to follow %s.", client->GetPlayer()->GetTarget()->GetName());
  5959. client->GetPlayer()->SetFollowTarget(client->GetPlayer()->GetTarget());
  5960. client->GetPlayer()->info_changed = true;
  5961. client->GetPlayer()->changed = true;
  5962. }
  5963. else
  5964. client->Message(CHANNEL_NARRATIVE, "You must first select a group member to follow.");
  5965. }
  5966. /*
  5967. Function: Command_StopFollow()
  5968. Purpose : Handle the /stop_follow command - not yet implemented
  5969. Params :
  5970. Dev :
  5971. Example :
  5972. */
  5973. void Commands::Command_StopFollow(Client* client, Seperator* sep)
  5974. {
  5975. PrintSep(sep, "COMMAND_STOP_FOLLOW");
  5976. if (client->GetPlayer()->GetFollowTarget()) {
  5977. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  5978. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You are no longer following %s", client->GetPlayer()->GetFollowTarget()->GetName());
  5979. client->GetPlayer()->SetFollowTarget(0);
  5980. client->GetPlayer()->info_changed = true;
  5981. client->GetPlayer()->changed = true;
  5982. }
  5983. }
  5984. /*
  5985. Function: Command_Grid()
  5986. Purpose : Show player's current Grid ID
  5987. Params :
  5988. Dev : Scatman
  5989. Example : /grid
  5990. */
  5991. void Commands::Command_Grid(Client* client, Seperator* sep)
  5992. {
  5993. if (client->GetPlayer()->GetMap() != nullptr) {
  5994. if(sep && sep->arg[0][0] && strncasecmp("spawns", sep->arg[0], 6) == 0) {
  5995. int32 grid = client->GetPlayer()->GetLocation();
  5996. if(sep->IsNumber(1))
  5997. grid = atoul(sep->arg[1]);
  5998. client->GetCurrentZone()->SendClientSpawnListInGrid(client, grid);
  5999. }
  6000. if(sep && sep->arg[0][0] && strncasecmp("boundary", sep->arg[0], 8) == 0) {
  6001. int32 grid = client->GetPlayer()->GetLocation();
  6002. if(sep->IsNumber(1))
  6003. grid = atoul(sep->arg[1]);
  6004. if(!client->GetPlayer()->GetMap()) {
  6005. client->Message(CHANNEL_COLOR_RED, "No map to check grid!");
  6006. return;
  6007. }
  6008. GridMapBorder* gmb = client->GetPlayer()->GetMap()->GetMapGridBorder(grid, false);
  6009. if(gmb) {
  6010. client->Message(CHANNEL_COLOR_YELLOW, "Grid %u border MinX %f MaxX %f, MinY %f MaxY %f, MinZ %f MaxZ %f", grid, gmb->m_MinX, gmb->m_MaxX, gmb->m_MinY, gmb->m_MaxY, gmb->m_MinZ, gmb->m_MaxZ);
  6011. }
  6012. else {
  6013. client->Message(CHANNEL_COLOR_RED, "Grid %u has no grid map border", grid);
  6014. }
  6015. }
  6016. else {
  6017. client->Message(CHANNEL_COLOR_YELLOW, "Your Grid ID is %u", client->GetPlayer()->GetLocation());
  6018. auto loc = glm::vec3(client->GetPlayer()->GetX(), client->GetPlayer()->GetZ(), client->GetPlayer()->GetY());
  6019. uint32 GridID = 0;
  6020. uint32 WidgetID = 0;
  6021. float new_z = client->GetPlayer()->FindBestZ(loc, nullptr, &GridID, &WidgetID);
  6022. float minY = client->GetPlayer()->GetMap()->GetMinY();
  6023. float maxY = client->GetPlayer()->GetMap()->GetMaxY();
  6024. float minZ = client->GetPlayer()->GetMap()->GetMinZ();
  6025. float maxZ = client->GetPlayer()->GetMap()->GetMaxZ();
  6026. int32 grid_spawn_count = client->GetPlayer()->GetZone()->GetSpawnCountInGrid(GridID);
  6027. client->Message(CHANNEL_COLOR_YELLOW, "Grid result is %u, at EQ2 Y coordinate %f. Spawns on grid: %u. Min/Max Y %f/%f Z %f/%f. Widget ID: %u", GridID, new_z, grid_spawn_count, minY, maxY, minZ, maxZ, WidgetID);
  6028. }
  6029. }
  6030. }
  6031. /*
  6032. Function: Command_Guild()
  6033. Purpose : Handler for all UI-related guild commands
  6034. Dev : Scatman
  6035. */
  6036. void Commands::Command_Guild(Client* client, Seperator* sep)
  6037. {
  6038. Guild* guild = client->GetPlayer()->GetGuild();
  6039. if (sep && sep->GetMaxArgNum() > 0 && sep->arg[0])
  6040. {
  6041. const char* command = sep->arg[0];
  6042. int32 length = strlen(command);
  6043. LogWrite(COMMAND__DEBUG, 0, "Command", "Guild Command: %s", command);
  6044. if (strncmp(command, "rank_name", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && guild)
  6045. guild->SetRankName(atoi(sep->arg[1]), sep->argplus[2]);
  6046. else if (strncmp(command, "rank_permission", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild) {
  6047. guild->SetPermission(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  6048. peer_manager.sendPeersGuildPermission(guild->GetID(), atoul(sep->arg[1]), atoul(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  6049. }
  6050. else if (strncmp(command, "filter_event", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild) {
  6051. guild->SetEventFilter(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  6052. peer_manager.sendPeersGuildEventFilter(guild->GetID(), atoul(sep->arg[1]), atoul(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  6053. }
  6054. else if (strncmp(command, "kick", length) == 0 && sep->arg[1] && guild) {
  6055. int32 character_id = guild->KickGuildMember(client, sep->arg[1]);
  6056. if(character_id > 0) {
  6057. peer_manager.sendPeersRemoveGuildMember(character_id, guild->GetID(), std::string(client->GetPlayer()->GetName()));
  6058. }
  6059. }
  6060. else if (strncmp(command, "demote", length) == 0 && sep->arg[1] && guild)
  6061. guild->DemoteGuildMember(client, sep->arg[1]);
  6062. else if (strncmp(command, "promote", length) == 0 && sep->arg[1] && guild)
  6063. guild->PromoteGuildMember(client, sep->arg[1]);
  6064. else if (strncmp(command, "points", length) == 0 && guild)
  6065. {
  6066. if (sep->arg[1] && strncmp(sep->arg[1], "add", length) == 0)
  6067. {
  6068. if (sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  6069. {
  6070. float points = atof(sep->arg[2]);
  6071. const char* option = sep->arg[3];
  6072. const char* comment = sep->argplus[4];
  6073. if (strncmp(option, "all", strlen(option)) == 0)
  6074. guild->AddPointsToAll(client, points, comment);
  6075. else if (strncmp(option, "online", strlen(option)) == 0)
  6076. guild->AddPointsToAllOnline(client, points, comment);
  6077. else if (strncmp(option, "group", strlen(option)) == 0)
  6078. guild->AddPointsToGroup(client, points, comment);
  6079. else if (strncmp(option, "raid", strlen(option)) == 0)
  6080. guild->AddPointsToRaid(client, points, comment);
  6081. else
  6082. guild->AddPointsToGuildMember(client, points, option, comment);
  6083. }
  6084. }
  6085. else if (sep->arg[1] && strncmp(sep->arg[1], "view", strlen(sep->arg[1])) == 0 && sep->arg[2])
  6086. guild->ViewGuildMemberPoints(client, sep->arg[2]);
  6087. else
  6088. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild points command: %s", sep->argplus[0]);
  6089. }
  6090. else if (strncmp(command, "motd", length) == 0 && sep->arg[1] && guild)
  6091. guild->SetMOTD(sep->argplus[1]);
  6092. else if (strncmp(command, "recruiting", length) == 0 && guild)
  6093. {
  6094. if (sep->arg[1])
  6095. {
  6096. const char* option = sep->arg[1];
  6097. if (strncmp(option, "short_text", strlen(option)) == 0 && sep->arg[2])
  6098. guild->SetRecruitingShortDesc(sep->argplus[2]);
  6099. else if (strncmp(option, "long_text", strlen(option)) == 0 && sep->arg[2])
  6100. guild->SetRecruitingFullDesc(sep->argplus[2]);
  6101. else if (strncmp(option, "flag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  6102. guild->SetRecruitingFlag(atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  6103. else if (strncmp(option, "min_level", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  6104. guild->SetRecruitingMinLevel(atoi(sep->arg[2]));
  6105. else if (strncmp(option, "playstyle", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  6106. guild->SetRecruitingPlayStyle(atoi(sep->arg[2]));
  6107. else if (strncmp(option, "tag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && sep->IsNumber(3))
  6108. guild->SetRecruitingDescTag(atoi(sep->arg[2]), atoi(sep->arg[3]));
  6109. else if (strncmp(command, "recruiting", strlen(option)) == 0)
  6110. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_RECRUITING_FOR_GUILD, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  6111. else
  6112. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  6113. }
  6114. else
  6115. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  6116. }
  6117. else if (strncmp(command, "notify_online", length) == 0 && sep->arg[1] && guild)
  6118. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_NOTIFY_LOGINS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  6119. else if (strncmp(command, "event_privacy", length) == 0 && sep->arg[1] && guild)
  6120. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_DONT_GENERATE_EVENTS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  6121. else if (strncmp(command, "recruiter", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  6122. guild->SetGuildRecruiter(client, sep->arg[1], strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  6123. else if (strncmp(command, "recruiter_description", length) == 0 && sep->arg[1] && guild)
  6124. guild->SetGuildRecruiterDescription(client, sep->argplus[1]);
  6125. else if (strncmp(command, "lock_event", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  6126. guild->LockGuildEvent(atoul(sep->arg[1]), strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  6127. else if (strncmp(command, "delete_event", length) == 0 && sep->arg[1] && guild)
  6128. guild->DeleteGuildEvent(atoul(sep->arg[1]));
  6129. else if (strncmp(command, "invite", length) == 0 && guild)
  6130. {
  6131. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  6132. guild->InvitePlayer(client, sep->arg[1]);
  6133. else
  6134. {
  6135. Spawn* target = client->GetPlayer()->GetTarget();
  6136. if (target)
  6137. {
  6138. if (target->IsPlayer())
  6139. guild->InvitePlayer(client, target->GetName());
  6140. else
  6141. client->Message(CHANNEL_NARRATIVE, "%s is not a player.", target->GetName());
  6142. }
  6143. }
  6144. }
  6145. else if (strncmp(command, "accept", length) == 0)
  6146. {
  6147. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  6148. if (pgi && pgi->guild && pgi->invited_by)
  6149. pgi->guild->AddNewGuildMember(client, pgi->invited_by->GetName());
  6150. client->SetPendingGuildInvite(0);
  6151. }
  6152. else if (strncmp(command, "decline", length) == 0)
  6153. {
  6154. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  6155. if (pgi && pgi->guild && pgi->invited_by && pgi->invited_by->IsPlayer())
  6156. {
  6157. Client* client_inviter = ((Player*)pgi->invited_by)->GetClient();
  6158. if (client_inviter) {
  6159. client_inviter->Message(CHANNEL_NARRATIVE, "%s has declined your invitation to join %s.", client->GetPlayer()->GetName(), pgi->guild->GetName());
  6160. }
  6161. }
  6162. client->SetPendingGuildInvite(0);
  6163. }
  6164. else if (strncmp(command, "create", length) == 0 && sep->arg[1])
  6165. {
  6166. const char* guild_name = sep->argplus[1];
  6167. if(!guild_name || strlen(guild_name) < 4) {
  6168. client->SimpleMessage(CHANNEL_NARRATIVE, "Guild name is too short.");
  6169. }
  6170. else if (!guild_list.GetGuild(guild_name)) {
  6171. if(net.is_primary) {
  6172. int32 guildID = world.CreateGuild(guild_name, client, client->GetPlayer()->GetGroupMemberInfo() ? client->GetPlayer()->GetGroupMemberInfo()->group_id : 0);
  6173. if(guildID > 0)
  6174. peer_manager.sendPeersCreateGuild(guildID);
  6175. }
  6176. else {
  6177. peer_manager.sendPrimaryCreateGuildRequest(std::string(guild_name), std::string(client->GetPlayer()->GetName()));
  6178. }
  6179. }
  6180. else
  6181. client->SimpleMessage(CHANNEL_NARRATIVE, "A guild with that name already exists.");
  6182. }
  6183. else if (strncmp(command, "search", length) == 0)
  6184. client->ShowGuildSearchWindow();
  6185. else if (strncmp(command, "recruiting_details", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  6186. {
  6187. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  6188. if (to_guild)
  6189. to_guild->SendGuildRecruitingDetails(client);
  6190. }
  6191. else if (strncmp(command, "recruiting_image", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  6192. {
  6193. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  6194. if (to_guild)
  6195. to_guild->SendGuildRecruitingImages(client);
  6196. }
  6197. else if (strncmp(command, "recruiter_adventure_class", length) == 0)
  6198. {
  6199. if (sep->arg[1])
  6200. {
  6201. const char* option = sep->arg[1];
  6202. if (strncmp(option, "toggle", strlen(option)) == 0)
  6203. guild->ToggleGuildRecruiterAdventureClass(client);
  6204. }
  6205. else
  6206. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiter_adventure_class command: '%s'", sep->argplus[0]);
  6207. }
  6208. else if (strncmp(command, "display_heraldry", length) == 0)
  6209. {
  6210. // JA: not sure this is right...
  6211. client->GetPlayer()->toggle_character_flag(CF_SHOW_GUILD_HERALDRY);
  6212. client->GetPlayer()->SetCharSheetChanged(true);
  6213. }
  6214. else
  6215. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild command: '%s'", sep->argplus[0]);
  6216. }
  6217. }
  6218. /*
  6219. Function: Command_GuildCreate()
  6220. Purpose : Display's in-game Guild Creation window
  6221. Dev : Scatman
  6222. */
  6223. void Commands::Command_CreateGuild(Client* client)
  6224. {
  6225. client->SendGuildCreateWindow();
  6226. }
  6227. /*
  6228. Function: Command_SetGuildOfficerNote()
  6229. Purpose :
  6230. Dev : Scatman
  6231. */
  6232. void Commands::Command_SetGuildOfficerNote(Client* client, Seperator* sep)
  6233. {
  6234. if (sep && sep->arg[0] && sep->arg[1])
  6235. {
  6236. Guild* guild = client->GetPlayer()->GetGuild();
  6237. if (guild)
  6238. guild->SetGuildOfficerNote(sep->arg[0], sep->argplus[1]);
  6239. }
  6240. }
  6241. /*
  6242. Function: Command_SetGuildMemberNote()
  6243. Purpose :
  6244. Dev : Scatman
  6245. */
  6246. void Commands::Command_SetGuildMemberNote(Client* client, Seperator* sep)
  6247. {
  6248. if (sep && sep->arg[0] && sep->arg[1])
  6249. {
  6250. Guild* guild = client->GetPlayer()->GetGuild();
  6251. if (guild)
  6252. guild->SetGuildMemberNote(sep->arg[0], sep->argplus[1]);
  6253. }
  6254. }
  6255. /*
  6256. Function: Command_GuildSay()
  6257. Purpose :
  6258. Dev : Scatman
  6259. */
  6260. void Commands::Command_GuildSay(Client* client, Seperator* sep)
  6261. {
  6262. Guild* guild = client->GetPlayer()->GetGuild();
  6263. if (guild)
  6264. {
  6265. if (sep && sep->arg[0]) {
  6266. bool success = guild->HandleGuildSay(client, sep->argplus[0]);
  6267. if(success)
  6268. peer_manager.SendPeersGuildChannelMessage(guild->GetID(), std::string(client->GetPlayer()->GetName()), std::string(sep->argplus[0]), CHANNEL_GUILD_SAY, client->GetPlayer()->GetCurrentLanguage());
  6269. }
  6270. }
  6271. else
  6272. client->SimpleMessage(CHANNEL_NARRATIVE, "You are not a member of a guild");
  6273. }
  6274. /*
  6275. Function: Command_OfficerSay()
  6276. Purpose :
  6277. Dev : Scatman
  6278. */
  6279. void Commands::Command_OfficerSay(Client* client, Seperator* sep)
  6280. {
  6281. Guild* guild = client->GetPlayer()->GetGuild();
  6282. if (guild)
  6283. {
  6284. if (sep && sep->arg[0]) {
  6285. bool success = guild->HandleOfficerSay(client, sep->argplus[0]);
  6286. if(success)
  6287. peer_manager.SendPeersGuildChannelMessage(guild->GetID(), std::string(client->GetPlayer()->GetName()), std::string(sep->argplus[0]), CHANNEL_OFFICER_SAY, client->GetPlayer()->GetCurrentLanguage());
  6288. }
  6289. }
  6290. else
  6291. client->SimpleMessage(CHANNEL_NARRATIVE, "You are not a member of a guild");
  6292. }
  6293. /*
  6294. Function: Command_Guilds()
  6295. Purpose : Shows help for /guild command
  6296. Params :
  6297. Dev : Scatman
  6298. Example :
  6299. */
  6300. void Commands::Command_Guilds(Client* client)
  6301. {
  6302. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds [create|delete|add|remove|list]");
  6303. }
  6304. /*
  6305. Function: Command_GuildsAdd()
  6306. Purpose : Add's players to a guild
  6307. Params : guild_name|guild_id, player name
  6308. Dev : Scatman
  6309. Example : /guilds add 1 Admin = adds player Admin to guild_id 1
  6310. */
  6311. void Commands::Command_GuildsAdd(Client* client, Seperator* sep)
  6312. {
  6313. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  6314. {
  6315. Guild* guild = 0;
  6316. bool found = true;
  6317. if (sep->IsNumber(0))
  6318. {
  6319. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  6320. if (!guild)
  6321. {
  6322. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  6323. found = false;
  6324. }
  6325. }
  6326. else
  6327. {
  6328. guild = guild_list.GetGuild(sep->arg[0]);
  6329. if (!guild)
  6330. {
  6331. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  6332. found = false;
  6333. }
  6334. }
  6335. if (found)
  6336. {
  6337. Client* to_client = 0;
  6338. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  6339. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  6340. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  6341. to_client = ((Player*)client->GetPlayer()->GetTarget())->GetClient();
  6342. if (to_client)
  6343. guild->InvitePlayer(client, to_client->GetPlayer()->GetName());
  6344. else
  6345. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  6346. }
  6347. }
  6348. else
  6349. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds add [guild name|guild id] (player name).");
  6350. }
  6351. /*
  6352. Function: Command_GuildsCreate()
  6353. Purpose : Creates a guild
  6354. Params : guild_name, player_name (optional)
  6355. Dev : Scatman
  6356. Example : /guilds create [guild name] (player name)
  6357. */
  6358. void Commands::Command_GuildsCreate(Client* client, Seperator* sep)
  6359. {
  6360. if (sep && sep->arg[0])
  6361. {
  6362. const char* guild_name = sep->arg[0];
  6363. if(!guild_name || strlen(guild_name) < 4) {
  6364. client->Message(CHANNEL_COLOR_YELLOW, "Guild name is too short.");
  6365. }
  6366. else if (!guild_list.GetGuild(guild_name))
  6367. {
  6368. bool ret = false;
  6369. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  6370. {
  6371. Client* to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  6372. if (to_client)
  6373. {
  6374. if(net.is_primary) {
  6375. int32 guildID = world.CreateGuild(guild_name, to_client, to_client->GetPlayer()->GetGroupMemberInfo() ? to_client->GetPlayer()->GetGroupMemberInfo()->group_id : 0);
  6376. if(guildID > 0)
  6377. peer_manager.sendPeersCreateGuild(guildID);
  6378. }
  6379. else {
  6380. peer_manager.sendPrimaryCreateGuildRequest(std::string(guild_name), std::string(to_client->GetPlayer()->GetName()));
  6381. }
  6382. ret = true;
  6383. }
  6384. else
  6385. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player with name '%s'", sep->arg[1]);
  6386. }
  6387. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  6388. {
  6389. Client* to_client = ((Player*)client->GetPlayer()->GetTarget())->GetClient();
  6390. if (to_client)
  6391. {
  6392. if(net.is_primary) {
  6393. int32 guildID = world.CreateGuild(guild_name, to_client, to_client->GetPlayer()->GetGroupMemberInfo() ? to_client->GetPlayer()->GetGroupMemberInfo()->group_id : 0);
  6394. if(guildID > 0)
  6395. peer_manager.sendPeersCreateGuild(guildID);
  6396. }
  6397. else {
  6398. peer_manager.sendPrimaryCreateGuildRequest(std::string(guild_name), std::string(to_client->GetPlayer()->GetName()));
  6399. }
  6400. ret = true;
  6401. }
  6402. }
  6403. else
  6404. {
  6405. if(net.is_primary) {
  6406. int32 guildID = world.CreateGuild(guild_name);
  6407. if(guildID > 0)
  6408. peer_manager.sendPeersCreateGuild(guildID);
  6409. }
  6410. else {
  6411. peer_manager.sendPrimaryCreateGuildRequest(std::string(guild_name), "");
  6412. }
  6413. ret = true;
  6414. }
  6415. if (ret)
  6416. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully created.", guild_name);
  6417. else
  6418. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the guild.");
  6419. }
  6420. else
  6421. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' already exists.", guild_name);
  6422. }
  6423. else
  6424. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds create [guild name] (player name). If no player is specified, the player's target will be used. If the player has no target, a guild with no members will be created.");
  6425. }
  6426. /*
  6427. Function: Command_GuildsDelete()
  6428. Purpose : Delete's a guild
  6429. Params : guild name
  6430. Dev : Scatman
  6431. Example : /guilds delete Test
  6432. */
  6433. void Commands::Command_GuildsDelete(Client* client, Seperator* sep)
  6434. {
  6435. if (sep && sep->arg[0])
  6436. {
  6437. Guild* guild = 0;
  6438. bool found = true;
  6439. if (sep->IsNumber(0))
  6440. {
  6441. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  6442. if (!guild)
  6443. {
  6444. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  6445. found = false;
  6446. }
  6447. }
  6448. else
  6449. {
  6450. guild = guild_list.GetGuild(sep->arg[0]);
  6451. if (!guild)
  6452. {
  6453. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  6454. found = false;
  6455. }
  6456. }
  6457. if (found)
  6458. {
  6459. guild->RemoveAllGuildMembers();
  6460. database.DeleteGuild(guild);
  6461. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully deleted.", guild->GetName());
  6462. guild_list.RemoveGuild(guild, true);
  6463. }
  6464. }
  6465. else
  6466. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds delete [guild name].");
  6467. }
  6468. /*
  6469. Function: Command_GuildsList()
  6470. Purpose : Lists current guilds on server
  6471. Params :
  6472. Dev : Scatman
  6473. Example : /guilds list
  6474. */
  6475. void Commands::Command_GuildsList(Client* client)
  6476. {
  6477. MutexMap<int32, Guild*>* guilds = guild_list.GetGuilds();
  6478. MutexMap<int32, Guild*>::iterator itr = guilds->begin();
  6479. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Guild List:");
  6480. if (guilds->size() == 0)
  6481. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "None.");
  6482. else {
  6483. while (itr.Next()) {
  6484. Guild* guild = itr.second;
  6485. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", guild->GetID(), guild->GetName());
  6486. }
  6487. }
  6488. }
  6489. /*
  6490. Function: Command_GuildsRemove()
  6491. Purpose : Removes a player from a guild
  6492. Params : guild name|guild id, player name
  6493. Dev : Scatman
  6494. Example : /guilds remove 1 Admin = removes Admin from guild 1
  6495. */
  6496. void Commands::Command_GuildsRemove(Client* client, Seperator* sep)
  6497. {
  6498. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  6499. {
  6500. Guild* guild = 0;
  6501. bool found = true;
  6502. if (sep->IsNumber(0))
  6503. {
  6504. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  6505. if (!guild)
  6506. {
  6507. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  6508. found = false;
  6509. }
  6510. }
  6511. else
  6512. {
  6513. guild = guild_list.GetGuild(sep->arg[0]);
  6514. if (!guild)
  6515. {
  6516. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  6517. found = false;
  6518. }
  6519. }
  6520. if (found)
  6521. {
  6522. Client* to_client = 0;
  6523. char* charName = nullptr;
  6524. if(sep->arg[1][0])
  6525. charName = sep->arg[1];
  6526. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  6527. charName = ((Player*)client->GetPlayer()->GetTarget())->GetName();
  6528. else
  6529. {
  6530. client->Message(CHANNEL_COLOR_YELLOW, "Missing player name or not a valid target to remove from the guild.");
  6531. return;
  6532. }
  6533. int32 character_id = guild->KickGuildMember(client, charName);
  6534. if(character_id > 0)
  6535. peer_manager.sendPeersRemoveGuildMember(character_id, guild->GetID(), std::string(client->GetPlayer()->GetName()));
  6536. else
  6537. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to remove from the guild.", charName);
  6538. }
  6539. }
  6540. else
  6541. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds remove [guild name|guild id] (player name).");
  6542. }
  6543. /*
  6544. Function: Command_InspectPlayer()
  6545. Purpose : Handle the Inspect functions
  6546. Params : Client to inspect
  6547. Dev : Scatman
  6548. Example : /inspect Scatman
  6549. */
  6550. void Commands::Command_InspectPlayer(Client* client, Seperator* sep)
  6551. {
  6552. if (sep && sep->arg[0])
  6553. {
  6554. Client* inspect_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  6555. if (inspect_client)
  6556. client->InspectPlayer(inspect_client->GetPlayer());
  6557. }
  6558. else
  6559. {
  6560. Spawn* target = client->GetPlayer()->GetTarget();
  6561. if (target && target->IsPlayer())
  6562. client->InspectPlayer((Player*)target);
  6563. }
  6564. }
  6565. /*
  6566. Function: Command_Inventory()
  6567. Purpose : Handle changes in player inventory
  6568. Params : <TBD>
  6569. Dev : All
  6570. Example : /inventory delete item_id
  6571. */
  6572. void Commands::Command_Inventory(Client* client, Seperator* sep, EQ2_RemoteCommandString* command)
  6573. {
  6574. PrintSep(sep, "Command_Inventory"); // temp to figure out the params
  6575. Player* player = client->GetPlayer();
  6576. if(sep && sep->arg[0][0])
  6577. {
  6578. LogWrite(COMMAND__INFO, 0, "Command", "command: %s", sep->argplus[0]);
  6579. if(!client->GetPlayer()->Alive())
  6580. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  6581. else if(sep->arg[1][0] && strncasecmp("destroy", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  6582. {
  6583. int16 index = atoi(sep->arg[1]);
  6584. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  6585. if(item)
  6586. {
  6587. if(item->details.item_locked) {
  6588. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot destroy the item in use.");
  6589. return;
  6590. }
  6591. else if(item->IsBag() && item->details.equip_slot_id) {
  6592. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot destroy the item, it is being used as quiver.");
  6593. return;
  6594. }
  6595. else if(item->CheckFlag(NO_DESTROY)) {
  6596. client->SimpleMessage(CHANNEL_COLOR_RED, "You can't destroy this item.");
  6597. return;
  6598. }
  6599. if(item->GetItemScript() && lua_interface)
  6600. lua_interface->RunItemScript(item->GetItemScript(), "destroyed", item, client->GetPlayer());
  6601. //reobtain item make sure it wasn't removed
  6602. item = player->item_list.GetItemFromIndex(index);
  6603. int32 bag_id = 0;
  6604. if(item){
  6605. bag_id = item->details.inv_slot_id;
  6606. database.DeleteItem(client->GetCharacterID(), item, 0);
  6607. }
  6608. client->GetPlayer()->item_list.DestroyItem(index);
  6609. client->GetPlayer()->UpdateInventory(bag_id);
  6610. client->GetPlayer()->CalculateApplyWeight();
  6611. }
  6612. }
  6613. else if(sep->arg[4][0] && strncasecmp("move", sep->arg[0], 4) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3) && sep->IsNumber(4))
  6614. {
  6615. int16 from_index = atoi(sep->arg[1]);
  6616. sint16 to_slot = atoi(sep->arg[2]); // don't convert slot since this is inventory not equipment
  6617. sint32 bag_id = atol(sep->arg[3]);
  6618. int8 charges = atoi(sep->arg[4]);
  6619. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(from_index);
  6620. if(!item) {
  6621. client->SimpleMessage(CHANNEL_COLOR_RED, "You have no item.");
  6622. return;
  6623. }
  6624. if(to_slot == item->details.slot_id && (bag_id < 0 || bag_id == item->details.inv_slot_id)) {
  6625. return;
  6626. }
  6627. if(item->details.item_locked)
  6628. {
  6629. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot move the item in use.");
  6630. return;
  6631. }
  6632. if(bag_id == -4 && !client->GetPlayer()->item_list.SharedBankAddAllowed(item))
  6633. {
  6634. client->SimpleMessage(CHANNEL_COLOR_RED, "That item (or an item inside) cannot be shared.");
  6635. return;
  6636. }
  6637. sint32 old_inventory_id = 0;
  6638. if(item)
  6639. old_inventory_id = item->details.inv_slot_id;
  6640. //autobank
  6641. if (bag_id == -3 && to_slot == -1)
  6642. {
  6643. if (player->HasFreeBankSlot())
  6644. to_slot = player->FindFreeBankSlot();
  6645. else
  6646. {
  6647. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free bank slots.");
  6648. return;
  6649. }
  6650. }
  6651. //auto inventory
  6652. if (bag_id == 0 && to_slot == -1)
  6653. {
  6654. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  6655. {
  6656. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free slots.");
  6657. return;
  6658. }
  6659. }
  6660. bool item_deleted = false;
  6661. EQ2Packet* outapp = client->GetPlayer()->MoveInventoryItem(bag_id, from_index, (int8)to_slot, charges, 0, &item_deleted, client->GetVersion());
  6662. client->QueuePacket(outapp);
  6663. if(item_deleted)
  6664. item = nullptr;
  6665. //removed from bag send update
  6666. if(old_inventory_id > 0 && item && item->details.inv_slot_id != old_inventory_id)
  6667. {
  6668. outapp = client->GetPlayer()->SendBagUpdate(old_inventory_id, client->GetVersion());
  6669. if(outapp)
  6670. client->QueuePacket(outapp);
  6671. }
  6672. if(item && item->details.inv_slot_id > 0 && item->details.inv_slot_id != old_inventory_id)
  6673. {
  6674. outapp = client->GetPlayer()->SendBagUpdate(item->details.inv_slot_id, client->GetVersion());
  6675. if(outapp)
  6676. client->QueuePacket(outapp);
  6677. }
  6678. client->GetPlayer()->CalculateApplyWeight();
  6679. }
  6680. else if(sep->arg[1][0] && strncasecmp("equip", sep->arg[0], 5) == 0 && sep->IsNumber(1))
  6681. {
  6682. int16 index = atoi(sep->arg[1]);
  6683. int8 slot_id = 255;
  6684. int8 unk3 = 0;
  6685. int8 appearance_equip = 0;
  6686. if(sep->arg[2][0] && sep->IsNumber(2))
  6687. slot_id = player->ConvertSlotFromClient(atoi(sep->arg[2]), client->GetVersion());
  6688. if(sep->arg[3][0] && sep->IsNumber(3))
  6689. unk3 = atoul(sep->arg[3]);
  6690. if(sep->arg[4][0] && sep->IsNumber(4))
  6691. appearance_equip = atoul(sep->arg[4]);
  6692. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), appearance_equip, slot_id);
  6693. EQ2Packet* outapp = 0;
  6694. for(int32 i=0;i<packets.size();i++)
  6695. {
  6696. outapp = packets[i];
  6697. if(outapp)
  6698. client->QueuePacket(outapp);
  6699. }
  6700. client->GetPlayer()->UpdateWeapons();
  6701. EQ2Packet* characterSheetPackets = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion());
  6702. client->QueuePacket(characterSheetPackets);
  6703. }
  6704. else if (sep->arg[1][0] && strncasecmp("unpack", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  6705. {
  6706. if (client->GetPlayer()->EngagedInCombat())
  6707. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unpack items while in combat.");
  6708. else {
  6709. int16 index = atoi(sep->arg[1]);
  6710. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  6711. if (item) {
  6712. if(item->details.item_locked)
  6713. {
  6714. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot unpack the item in use.");
  6715. return;
  6716. }
  6717. // client->GetPlayer()->item_list.DestroyItem(index);
  6718. if (item->item_sets.size() > 0) {
  6719. for (int32 i = 0; i < item->item_sets.size(); i++) {
  6720. ItemSet* set = item->item_sets[i];
  6721. if (set->item_stack_size == 0)
  6722. set->item_stack_size += 1;
  6723. client->AddItem(set->item_id, set->item_stack_size);
  6724. }
  6725. }
  6726. }
  6727. client->RemoveItem(item, 1);
  6728. }
  6729. }
  6730. else if(sep->arg[1][0] && strncasecmp("unequip", sep->arg[0], 7) == 0 && sep->IsNumber(1))
  6731. {
  6732. int16 index = player->ConvertSlotFromClient(atoi(sep->arg[1]), client->GetVersion());
  6733. sint32 bag_id = -999;
  6734. int8 to_slot = 255;
  6735. if(sep->arg[3][0])
  6736. {
  6737. if(sep->IsNumber(2))
  6738. bag_id = atol(sep->arg[2]);
  6739. if(sep->IsNumber(3))
  6740. to_slot = atoi(sep->arg[3]);
  6741. }
  6742. sint8 unk4 = 0;
  6743. int8 appearance_equip = 0;
  6744. if(sep->arg[4][0] && sep->IsNumber(4))
  6745. unk4 = atoi(sep->arg[4]);
  6746. if(sep->arg[5][0] && sep->IsNumber(5))
  6747. appearance_equip = atoul(sep->arg[5]);
  6748. vector<EQ2Packet*> packets = client->GetPlayer()->UnequipItem(index, bag_id, to_slot, client->GetVersion(), appearance_equip);
  6749. EQ2Packet* outapp = 0;
  6750. for(int32 i=0;i<packets.size();i++)
  6751. {
  6752. outapp = packets[i];
  6753. if(outapp)
  6754. client->QueuePacket(outapp);
  6755. }
  6756. client->UnequipItem(index, bag_id, to_slot, appearance_equip);
  6757. }
  6758. else if(sep->arg[2][0] && strncasecmp("swap_equip", sep->arg[0], 10) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  6759. {
  6760. if(client->GetPlayer()->EngagedInCombat() && rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Player, AllowPlayerEquipCombat)->GetInt8() == 0) {
  6761. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not swap items while in combat.");
  6762. }
  6763. else {
  6764. int16 index1 = client->GetPlayer()->ConvertSlotFromClient(atoi(sep->arg[1]), client->GetVersion());
  6765. int16 index2 = client->GetPlayer()->ConvertSlotFromClient(atoi(sep->arg[2]), client->GetVersion());
  6766. int8 type = 0;
  6767. if(sep->IsNumber(3))
  6768. type = atoul(sep->arg[3]); // type 0 is combat, 3 = appearance
  6769. EQ2Packet* outapp = client->GetPlayer()->SwapEquippedItems(index1, index2, client->GetVersion(), type);
  6770. if(outapp)
  6771. client->QueuePacket(outapp);
  6772. else
  6773. {
  6774. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to swap items");
  6775. return;
  6776. }
  6777. }
  6778. }
  6779. else if (sep->arg[2][0] && strncasecmp("pop", sep->arg[0], 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  6780. {
  6781. sint16 to_slot = atoi(sep->arg[1]);
  6782. sint32 bag_id = atoi(sep->arg[2]);
  6783. Item* item = client->GetPlayer()->item_list.GetOverflowItem();
  6784. if (item) {
  6785. //auto inventory
  6786. if (bag_id == 0 && to_slot == -1)
  6787. {
  6788. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  6789. {
  6790. client->SimpleMessage(CHANNEL_ERROR, "You do not have any free slots.");
  6791. return;
  6792. }
  6793. // Set the slot for the item
  6794. item->details.inv_slot_id = bag_id;
  6795. item->details.slot_id = to_slot;
  6796. // Flag the item so it gets saved in its new location
  6797. item->save_needed = true;
  6798. // Add the item to its new location
  6799. if(player->item_list.AddItem(item)) {
  6800. // Remove the item from the overflow list
  6801. player->item_list.RemoveOverflowItem(item);
  6802. }
  6803. // Send the inventory update packet
  6804. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  6805. return;
  6806. }
  6807. else if (bag_id == -3 && to_slot == -1) {
  6808. // Auto Bank
  6809. if (!player->item_list.GetFirstFreeBankSlot(&bag_id, &to_slot)) {
  6810. client->SimpleMessage(CHANNEL_STATUS, "You do not have any free bank slots.");
  6811. return;
  6812. }
  6813. item->details.inv_slot_id = bag_id;
  6814. item->details.slot_id = to_slot;
  6815. item->save_needed = true;
  6816. if(player->item_list.AddItem(item)) {
  6817. player->item_list.RemoveOverflowItem(item);
  6818. }
  6819. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  6820. }
  6821. else if (bag_id == -4) {
  6822. // Shared Bank
  6823. if (!player->item_list.SharedBankAddAllowed(item)) {
  6824. client->SimpleMessage(CHANNEL_STATUS, "That item (or an item inside) cannot be shared.");
  6825. return;
  6826. }
  6827. Item* tmp_item = player->item_list.GetItem(-4, to_slot);
  6828. if (tmp_item) {
  6829. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  6830. return;
  6831. }
  6832. else {
  6833. item->details.inv_slot_id = bag_id;
  6834. item->details.slot_id = to_slot;
  6835. item->save_needed = true;
  6836. if(player->item_list.AddItem(item)) {
  6837. player->item_list.RemoveOverflowItem(item);
  6838. }
  6839. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  6840. return;
  6841. }
  6842. }
  6843. else {
  6844. // Try to get an item from the given bag id and slot id
  6845. Item* tmp_item = player->item_list.GetItem(bag_id, to_slot);
  6846. // Check to see if we got an item, if we do send an error,
  6847. // if we don't put the overflow item into this slot
  6848. if (tmp_item) {
  6849. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  6850. }
  6851. else {
  6852. item->details.inv_slot_id = bag_id;
  6853. item->details.slot_id = to_slot;
  6854. item->save_needed = true;
  6855. if(player->item_list.AddItem(item)) {
  6856. player->item_list.RemoveOverflowItem(item);
  6857. }
  6858. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  6859. return;
  6860. }
  6861. }
  6862. }
  6863. }
  6864. else if(sep->arg[2][0] && strncasecmp("nosale", sep->arg[0], 6) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  6865. {
  6866. sint64 data = strtoull(sep->arg[1], NULL, 0);
  6867. int32 character_item_id = (int32) (data >> 32);
  6868. int32 item_id = (int32) (data & 0xffffffffL);
  6869. int8 sale_setting = atoi(sep->arg[2]);
  6870. Item* item = client->GetPlayer()->item_list.GetItemFromUniqueID(character_item_id);
  6871. if(item)
  6872. {
  6873. item->no_sale = sale_setting;
  6874. item->save_needed = true;
  6875. client->SendSellMerchantList();
  6876. }
  6877. }
  6878. }
  6879. else
  6880. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /inventory {destroy|move|equip|unequip|swap_equip|pop} {item_id} [to_slot] [bag_id]");
  6881. }
  6882. /*
  6883. Function: Command_Languages()
  6884. Purpose : Show's languages the player knows
  6885. Params :
  6886. Dev : Zcoretri
  6887. Example :
  6888. */
  6889. void Commands::Command_Languages(Client* client, Seperator* sep)
  6890. {
  6891. list<Language*>* languages = client->GetPlayer()->GetPlayerLanguages()->GetAllLanguages();
  6892. list<Language*>::iterator itr;
  6893. Language* language;
  6894. client->Message(CHANNEL_NARRATIVE, "You know the following languages:");
  6895. for(itr = languages->begin(); itr != languages->end(); itr++)
  6896. {
  6897. language = *itr;
  6898. client->Message(CHANNEL_NARRATIVE, "%s", language->GetName());
  6899. }
  6900. }
  6901. /*
  6902. Function: Command_SetLanguage()
  6903. Purpose : Handles language commands
  6904. Params : Language ID
  6905. Dev : Zcoretri
  6906. Example :
  6907. */
  6908. void Commands::Command_SetLanguage(Client* client, Seperator* sep)
  6909. {
  6910. Player* player = client->GetPlayer();
  6911. if (sep && sep->arg[0])
  6912. {
  6913. if(!sep->IsNumber(0))
  6914. {
  6915. //String passed in
  6916. const char* value = sep->arg[0];
  6917. if(strncasecmp(value, "Common", strlen(value)) == 0)
  6918. {
  6919. database.SaveCharacterCurrentLang(0, client->GetCharacterID(), client);
  6920. client->SendLanguagesUpdate(0);
  6921. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", value);
  6922. }
  6923. else
  6924. {
  6925. if(player->HasLanguage(value))
  6926. {
  6927. Language* language = player->GetPlayerLanguages()->GetLanguageByName(value);
  6928. database.SaveCharacterCurrentLang(language->GetID(), client->GetCharacterID(), client);
  6929. client->SendLanguagesUpdate(language->GetID());
  6930. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", language->GetName());
  6931. }
  6932. else
  6933. client->Message(CHANNEL_NARRATIVE, "You do not know how to speak %s", value);
  6934. }
  6935. }
  6936. else
  6937. {
  6938. //Number passed in
  6939. int32 id = atoul(sep->arg[0]);
  6940. if(player->HasLanguage(id))
  6941. {
  6942. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  6943. database.SaveCharacterCurrentLang(id, client->GetCharacterID(), client);
  6944. client->SendLanguagesUpdate(id);
  6945. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", language->GetName());
  6946. }
  6947. else
  6948. {
  6949. Language* language = master_languages_list.GetLanguage(id);
  6950. if(language)
  6951. client->Message(CHANNEL_NARRATIVE, "You do not know how to speak %s", language->GetName());
  6952. }
  6953. }
  6954. }
  6955. else
  6956. {
  6957. //No value was passed in
  6958. int32 id = database.GetCharacterCurrentLang(client->GetCharacterID(), player);
  6959. if(id > 0)
  6960. {
  6961. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  6962. client->Message(CHANNEL_NARRATIVE, "You are currently speaking %s ", language->GetName());
  6963. }
  6964. else
  6965. client->Message(CHANNEL_NARRATIVE, "You are currently speaking Common");
  6966. }
  6967. }
  6968. /*
  6969. Function: Command_LastName()
  6970. Purpose : Sets player surname
  6971. Params : Name text
  6972. Dev : theFoof
  6973. Example :
  6974. */
  6975. void Commands::Command_LastName(Client* client, Seperator* sep)
  6976. {
  6977. if (!client)
  6978. return;
  6979. if (sep && sep->arg[0])
  6980. {
  6981. if (!client->GetPlayer()->get_character_flag(CF_ENABLE_CHANGE_LASTNAME)){
  6982. 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());
  6983. return;
  6984. }
  6985. client->RemovePendingLastName();
  6986. uchar* checkname = (uchar*)sep->arg[0];
  6987. bool valid_name = true;
  6988. for (int32 i = 0; i < strlen(sep->arg[0]); i++) {
  6989. if (!alpha_check(checkname[i])) {
  6990. valid_name = false;
  6991. break;
  6992. }
  6993. }
  6994. if (!valid_name) {
  6995. client->Message(CHANNEL_COLOR_YELLOW, "Your last name can only contain letters.", rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Player, MinLastNameLevel)->GetInt8());
  6996. return;
  6997. }
  6998. string last_name = (string)sep->arg[0];
  6999. int8 max_length = rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Player, MaxLastNameLength)->GetInt8();
  7000. int8 min_length = rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Player, MinLastNameLength)->GetInt8();
  7001. if (last_name.length() <= max_length && last_name.length() >= min_length){
  7002. client->SetPendingLastName(last_name);
  7003. client->SendLastNameConfirmation();
  7004. }
  7005. else
  7006. client->Message(CHANNEL_COLOR_YELLOW, "Your last name must be between %i and %i characters long.", min_length, max_length);
  7007. }
  7008. }
  7009. /*
  7010. Function: Command_ConfirmLastName()
  7011. Purpose : Confirms setting of player surname
  7012. Params : Name text
  7013. Dev : theFoof
  7014. Example :
  7015. */
  7016. void Commands::Command_ConfirmLastName(Client* client, Seperator* sep)
  7017. {
  7018. if (!client)
  7019. return;
  7020. string* name = client->GetPendingLastName();
  7021. if (name){
  7022. Player* player = client->GetPlayer();
  7023. player->SetLastName(name->c_str(), false);
  7024. client->SendTitleUpdate();
  7025. player->SetCharSheetChanged(true);
  7026. client->RemovePendingLastName();
  7027. }
  7028. }
  7029. /*
  7030. Function: Command_Location()
  7031. Purpose : Display's Help for /location commands
  7032. Params :
  7033. Dev : Scatman
  7034. Example : /location = show's help for command
  7035. */
  7036. void Commands::Command_Location(Client* client)
  7037. {
  7038. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Valid /location commands are:");
  7039. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location create [name] (include y). Include y defaults to false");
  7040. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location add [location id]");
  7041. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location remove [location point id]");
  7042. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location delete [location id]");
  7043. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location list [locations|points] [location id if points used]");
  7044. }
  7045. /*
  7046. Function: Command_LocationAdd()
  7047. Purpose : Add's a location to an existing location config
  7048. Params : location_id
  7049. Dev : Scatman
  7050. Example : /location add {location_id}
  7051. */
  7052. void Commands::Command_LocationAdd(Client* client, Seperator* sep)
  7053. {
  7054. if (sep && sep->arg[0] && sep->IsNumber(0))
  7055. {
  7056. int32 location_id = atoul(sep->arg[0]);
  7057. float x = client->GetPlayer()->GetX();
  7058. float y = client->GetPlayer()->GetY();
  7059. float z = client->GetPlayer()->GetZ();
  7060. if (database.AddLocationPoint(location_id, x, y, z))
  7061. client->Message(CHANNEL_COLOR_YELLOW, "Point (%f, %f, %f) was successfully added to location %u", x, y, z, location_id);
  7062. else
  7063. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist. Use /location create to create one", location_id);
  7064. }
  7065. else
  7066. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location add [location id]");
  7067. }
  7068. /*
  7069. Function: Command_LocationCreate()
  7070. Purpose : Creates a new location config
  7071. Params : location name, 0/1 for include_y (optional)
  7072. Dev : Scatman
  7073. Example : /location create Test 1 = creates a new location named Test with include_y True
  7074. */
  7075. void Commands::Command_LocationCreate(Client* client, Seperator* sep)
  7076. {
  7077. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  7078. {
  7079. const char* name = sep->arg[0];
  7080. bool include_y = false;
  7081. if (sep->arg[1] && sep->IsNumber(1) && atoi(sep->arg[1]) > 0)
  7082. include_y = true;
  7083. int32 location_id = database.CreateLocation(client->GetPlayer()->GetZone()->GetZoneID(), client->GetPlayer()->GetLocation(), name, include_y);
  7084. if (location_id > 0)
  7085. client->Message(CHANNEL_COLOR_YELLOW, "Location '%s' was successfully created with location id %u", name, location_id);
  7086. else
  7087. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the requested location");
  7088. }
  7089. else
  7090. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location create [name] (include_y). Include y defaults to false");
  7091. }
  7092. /*
  7093. Function: Command_LocationDelete()
  7094. Purpose : Delete's a location config and all it's location points
  7095. Params : location_id
  7096. Dev : Scatman
  7097. Example : /location delete {location_id}
  7098. */
  7099. void Commands::Command_LocationDelete(Client* client, Seperator* sep)
  7100. {
  7101. if (sep && sep->arg[0] && sep->IsNumber(0))
  7102. {
  7103. int32 location_id = atoul(sep->arg[0]);
  7104. if (database.DeleteLocation(location_id))
  7105. client->Message(CHANNEL_COLOR_YELLOW, "Location id %u and all its points were successfully deleted", location_id);
  7106. else
  7107. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist", location_id);
  7108. }
  7109. else
  7110. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location delete [location id]");
  7111. }
  7112. /*
  7113. Function: Command_LocationList()
  7114. Purpose : Display's a list of location points
  7115. Params : location_id
  7116. Dev : Scatman
  7117. Example : /location list {location_id}
  7118. */
  7119. void Commands::Command_LocationList(Client* client, Seperator* sep)
  7120. {
  7121. if (sep && sep->arg[0])
  7122. {
  7123. const char* option = sep->arg[0];
  7124. if (strncmp(option, "locations", strlen(option)) == 0)
  7125. database.ListLocations(client);
  7126. else if (strncmp(option, "points", strlen(option)) == 0 && sep->arg[1] && sep->IsNumber(1))
  7127. {
  7128. int32 location_id = atoul(sep->arg[1]);
  7129. database.ListLocationPoints(client, location_id);
  7130. }
  7131. else
  7132. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  7133. }
  7134. else
  7135. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  7136. }
  7137. /*
  7138. Function: Command_LocationRemove()
  7139. Purpose : Removes a single location point from a location config
  7140. Params : location_point_id (gotten from /location list {id})
  7141. Dev : Scatman
  7142. Example : /location remove 1 = will remove location_point_id 1
  7143. */
  7144. void Commands::Command_LocationRemove(Client* client, Seperator* sep)
  7145. {
  7146. if (sep && sep->arg[0] && sep->IsNumber(0))
  7147. {
  7148. int32 location_point_id = atoul(sep->arg[0]);
  7149. if (database.DeleteLocationPoint(location_point_id))
  7150. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Location point was successfully deleted");
  7151. else
  7152. client->Message(CHANNEL_COLOR_YELLOW, "Location point with ID %u does not exist", location_point_id);
  7153. }
  7154. else
  7155. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location remove [location point id]");
  7156. }
  7157. /*
  7158. Function: Command_Merchant()
  7159. Purpose : Handles Merchant commands
  7160. Params : list
  7161. Dev : Scatman
  7162. Example : /merchant list
  7163. */
  7164. void Commands::Command_Merchant(Client* client, Seperator* sep, int handler)
  7165. {
  7166. if( handler == COMMAND_MERCHANT )
  7167. {
  7168. // /merchant command by itself shows help (to be extended)
  7169. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  7170. return;
  7171. }
  7172. else if( handler == COMMAND_MERCHANT_LIST )
  7173. {
  7174. // /merchant list command expects "description" param
  7175. if (sep && sep->arg[0])
  7176. {
  7177. const char* merchant_description = sep->argplus[0];
  7178. client->Message(CHANNEL_COLOR_YELLOW, "Listing merchants like '%s':", merchant_description);
  7179. map<int32, MerchantInfo*>* merchant_info = world.GetMerchantInfo();
  7180. map<int32, MerchantInfo*>::iterator itr;
  7181. for (itr = merchant_info->begin(); itr != merchant_info->end(); itr++)
  7182. {
  7183. string description = database.GetMerchantDescription(itr->first);
  7184. if (ToLower(description).find(ToLower(string(merchant_description))) < 0xFFFFFFFF)
  7185. client->Message(CHANNEL_COLOR_YELLOW, "Merchant ID: %u, Description: %s", itr->first, description.c_str());
  7186. }
  7187. }
  7188. else // no description
  7189. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  7190. }
  7191. }
  7192. /*
  7193. Function: Command_Modify()
  7194. Purpose : to replace our other "set" commands
  7195. Params : System = the system to modify, Action = the action to perform, Target = what to change (target, or index)
  7196. Dev : John Adams
  7197. Example : /modify spell set name "Aegolism III"
  7198. */
  7199. void Commands::Command_Modify(Client* client)
  7200. {
  7201. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /modify [system] [action] [field] [value] {target|id}");
  7202. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Systems: character, faction, guild, item, skill, spawn, spell, zone");
  7203. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Actions: set, create, delete, add, remove");
  7204. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Value : field name in the table being modified");
  7205. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target : modify current target, or specified {system} ID");
  7206. }
  7207. /*
  7208. Function: Command_ModifySpawn()
  7209. Purpose : replace "spawn set" commands
  7210. Params : Action : the action to perform (or special handler)
  7211. : Field : the DB field to change
  7212. : Value : what to set the value to
  7213. : Target : what object to change (my target, or spawn_id)
  7214. Dev : John Adams
  7215. Example : /modify spawn set name "Lady Vox"
  7216. :
  7217. Note : Special Handlers, like "zoneto" for Signs
  7218. : /modify spawn zoneto
  7219. : Will set a sign's zone x/y/z to my current coords
  7220. */
  7221. void Commands::Command_ModifySpawn(Client* client, Seperator* sep)
  7222. {
  7223. PrintSep(sep, "COMMAND_MODIFY");
  7224. // need at least 2 args for a valid command
  7225. if( sep && sep->arg[1] )
  7226. {
  7227. // JA: just a quick implementation because I need it :)
  7228. if (strcmp(sep->arg[0], "zoneto") == 0)
  7229. {
  7230. if( sep->IsNumber(1) )
  7231. {
  7232. int32 spawn_id = atoul(sep->arg[1]);
  7233. float x_coord = client->GetPlayer()->GetX();
  7234. float y_coord = client->GetPlayer()->GetY();
  7235. float z_coord = client->GetPlayer()->GetZ();
  7236. float h_coord = client->GetPlayer()->GetHeading();
  7237. database.SaveSignZoneToCoords(spawn_id, x_coord, y_coord, z_coord, h_coord);
  7238. }
  7239. else
  7240. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify spawn zoneto spawn_id - sets spawn_id to your coords");
  7241. }
  7242. }
  7243. else
  7244. Command_Modify(client);
  7245. }
  7246. /*
  7247. Function: Command_ModifyCharacter()
  7248. Purpose : to replace our other "set" commands
  7249. Params : Action : Add, Remove
  7250. : Field : copper, silver, gold, plat
  7251. : Value : min 1, max unlimited
  7252. : Target : Self, Player
  7253. Dev : Cynnar
  7254. Example : /modify character add gold 50
  7255. : /modify character remove silver 25
  7256. */
  7257. void Commands::Command_ModifyCharacter(Client* client, Seperator* sep)
  7258. {
  7259. PrintSep(sep, "COMMAND_MODIFY");
  7260. int64 value = 0;
  7261. Player* player = client->GetPlayer();
  7262. Client* targetClient = client;
  7263. if (player->HasTarget() && player->GetTarget()->IsPlayer()) {
  7264. player = (Player*)player->GetTarget();
  7265. targetClient = player->GetClient();
  7266. }
  7267. // need at least 2 args for a valid command
  7268. if( sep && sep->arg[1] )
  7269. {
  7270. if (strcmp(sep->arg[0], "add") == 0)
  7271. {
  7272. if (strcmp(sep->arg[1], "copper") == 0)
  7273. {
  7274. value = atoi64(sep->arg[2]);
  7275. player->AddCoins(value);
  7276. if (client->GetPlayer() == player)
  7277. {
  7278. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu copper coin%s", value, (value > 1 ? "s" : ""));
  7279. }
  7280. else {
  7281. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu copper coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  7282. if(targetClient) {
  7283. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu copper coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  7284. }
  7285. }
  7286. }
  7287. else if (strcmp(sep->arg[1], "silver") == 0)
  7288. {
  7289. value = atoi64(sep->arg[2]) * 100;
  7290. player->AddCoins(value);
  7291. if (client->GetPlayer() == player)
  7292. {
  7293. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu silver coin%s", value / 100, (value > 1 ? "s" : ""));
  7294. }
  7295. else {
  7296. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu silver coin%s", player->GetName(), value / 100, (value > 1 ? "s" : ""));
  7297. if(targetClient) {
  7298. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu silver coin%s", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  7299. }
  7300. }
  7301. }
  7302. else if (strcmp(sep->arg[1], "gold") == 0)
  7303. {
  7304. value = atoi64(sep->arg[2]) * 10000;
  7305. player->AddCoins(value);
  7306. if (client->GetPlayer() == player)
  7307. {
  7308. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu gold coin%s", value / 10000, (value > 1 ? "s" : ""));
  7309. }
  7310. else {
  7311. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu gold coin%s", player->GetName(), value / 10000, (value > 1 ? "s" : ""));
  7312. if(targetClient) {
  7313. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu gold coin%s", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  7314. }
  7315. }
  7316. }
  7317. else if (strcmp(sep->arg[1], "plat") == 0)
  7318. {
  7319. value = atoi64(sep->arg[2]) * 1000000;
  7320. player->AddCoins(value);
  7321. if (client->GetPlayer() == player)
  7322. {
  7323. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu platinum coin%s", value / 1000000, (value > 1 ? "s" : ""));
  7324. }
  7325. else {
  7326. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu platinum coin%s", player->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  7327. if(targetClient) {
  7328. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu platinum coin%s", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  7329. }
  7330. }
  7331. }
  7332. else
  7333. {
  7334. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  7335. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  7336. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  7337. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character add copper 20");
  7338. }
  7339. }
  7340. else if (strcmp(sep->arg[0], "remove") == 0)
  7341. {
  7342. if (strcmp(sep->arg[1], "copper") == 0)
  7343. {
  7344. value = atoi64(sep->arg[2]);
  7345. player->RemoveCoins(value);
  7346. if (client->GetPlayer() == player)
  7347. {
  7348. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from yourself", value, (value > 1 ? "s" : ""));
  7349. }
  7350. else {
  7351. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from %s", value, (value > 1 ? "s" : ""), player->GetName());
  7352. if(targetClient) {
  7353. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu copper coin%s from you", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  7354. }
  7355. }
  7356. }
  7357. else if (strcmp(sep->arg[1], "silver") == 0)
  7358. {
  7359. value = atoi64(sep->arg[2]) * 100;
  7360. player->RemoveCoins(value);
  7361. if (client->GetPlayer() == player)
  7362. {
  7363. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from yourself", value / 100, (value > 1 ? "s" : ""));
  7364. }
  7365. else {
  7366. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from %s", value / 100, (value > 1 ? "s" : ""), player->GetName());
  7367. if(targetClient) {
  7368. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu silver coin%s from you", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  7369. }
  7370. }
  7371. }
  7372. else if (strcmp(sep->arg[1], "gold") == 0)
  7373. {
  7374. value = atoi64(sep->arg[2]) * 10000;
  7375. player->RemoveCoins(value);
  7376. if (client->GetPlayer() == player)
  7377. {
  7378. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from yourself", value / 10000, (value > 1 ? "s" : ""));
  7379. }
  7380. else {
  7381. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from %s", value / 10000, (value > 1 ? "s" : ""), player->GetName());
  7382. if(targetClient) {
  7383. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu gold coin%s from you", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  7384. }
  7385. }
  7386. }
  7387. else if (strcmp(sep->arg[1], "plat") == 0)
  7388. {
  7389. value = atoi64(sep->arg[2]) * 1000000;
  7390. player->RemoveCoins(value);
  7391. if (client->GetPlayer() == player)
  7392. {
  7393. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from yourself", value / 1000000, (value > 1 ? "s" : ""));
  7394. }
  7395. else {
  7396. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from %s", value / 1000000, (value > 1 ? "s" : ""), player->GetName());
  7397. if(targetClient) {
  7398. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu platinum coin%s from you", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  7399. }
  7400. }
  7401. }
  7402. else
  7403. {
  7404. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  7405. }
  7406. }
  7407. else if (strcmp(sep->arg[0], "set") == 0) {
  7408. if (strcmp(sep->arg[1], "tslevel") == 0) {
  7409. int8 level = atoi(sep->arg[2]);
  7410. if (level > 0 && level < 256) {
  7411. if (player) {
  7412. if (client->GetPlayer() == player)
  7413. client->ChangeTSLevel(player->GetTSLevel(), level);
  7414. else if(targetClient)
  7415. targetClient->ChangeTSLevel(player->GetTSLevel(), level);
  7416. }
  7417. }
  7418. else
  7419. client->SimpleMessage(CHANNEL_ERROR, "Level must be between 1 - 255");
  7420. }
  7421. else if (strcmp(sep->arg[1], "tsclass") == 0) {
  7422. int8 tsclass = atoi(sep->arg[2]);
  7423. player->SetTradeskillClass(tsclass);
  7424. player->GetInfoStruct()->set_tradeskill_class1(classes.GetTSBaseClass(player->GetTradeskillClass()));
  7425. player->GetInfoStruct()->set_tradeskill_class2(classes.GetSecondaryTSBaseClass(player->GetTradeskillClass()));
  7426. player->GetInfoStruct()->set_tradeskill_class3(player->GetTradeskillClass());
  7427. player->SetCharSheetChanged(true);
  7428. }
  7429. else if (strcmp(sep->arg[1], "gender") == 0) {
  7430. int8 gender = atoi(sep->arg[2]);
  7431. client->GetPlayer()->GetInfoStruct()->set_gender(gender);
  7432. client->GetPlayer()->SetCharSheetChanged(true);
  7433. client->UpdateTimeStampFlag ( GENDER_UPDATE_FLAG );
  7434. }
  7435. }
  7436. }
  7437. else
  7438. {
  7439. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  7440. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  7441. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  7442. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  7443. }
  7444. }
  7445. void Commands::Command_ModifyFaction(Client* client, Seperator* sep)
  7446. {
  7447. PrintSep(sep, "COMMAND_MODIFY");
  7448. // need at least 2 args for a valid command
  7449. if( sep && sep->arg[1] )
  7450. {
  7451. }
  7452. else
  7453. Command_Modify(client);
  7454. }
  7455. void Commands::Command_ModifyGuild(Client* client, Seperator* sep)
  7456. {
  7457. PrintSep(sep, "COMMAND_MODIFY");
  7458. // need at least 2 args for a valid command
  7459. if( sep && sep->arg[1] )
  7460. {
  7461. }
  7462. else
  7463. Command_Modify(client);
  7464. }
  7465. void Commands::Command_ModifyItem(Client* client, Seperator* sep)
  7466. {
  7467. PrintSep(sep, "COMMAND_MODIFY");
  7468. // need at least 2 args for a valid command
  7469. if( sep && sep->arg[1] )
  7470. {
  7471. }
  7472. else
  7473. Command_Modify(client);
  7474. }
  7475. /*
  7476. Function: Command_ModifyQuest()
  7477. Purpose : to list players quest and completed quests
  7478. Params : Action : list, completed
  7479. : Target : Self, Player
  7480. Dev : Cynnar
  7481. Example : /modify quest list
  7482. : /modify quest completed
  7483. */
  7484. void Commands::Command_ModifyQuest(Client* client, Seperator* sep)
  7485. {
  7486. PrintSep(sep, "COMMAND_MODIFY");
  7487. int64 value = 0;
  7488. Player* player = client->GetPlayer();
  7489. Client* targetClient = client;
  7490. if (player->HasTarget() && player->GetTarget()->IsPlayer()) {
  7491. player = (Player*)player->GetTarget();
  7492. targetClient = player->GetClient();
  7493. }
  7494. // need at least 2 args for a valid command
  7495. if (sep && sep->arg[1])
  7496. {
  7497. if (strcmp(sep->arg[0], "list") == 0)
  7498. {
  7499. map<int32, Quest*>* quests = player->GetPlayerQuests();
  7500. map<int32, Quest*>::iterator itr;
  7501. client->Message(CHANNEL_COLOR_YELLOW, "%s's Quest List:.", client->GetPlayer()->GetName());
  7502. if (quests->size() == 0)
  7503. client->Message(CHANNEL_COLOR_YELLOW, "%s has no quests.", client->GetPlayer()->GetName());
  7504. else
  7505. {
  7506. for (itr = quests->begin(); itr != quests->end(); itr++)
  7507. {
  7508. Quest* quest = itr->second;
  7509. if(quest) {
  7510. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  7511. }
  7512. }
  7513. }
  7514. }
  7515. else if (strcmp(sep->arg[0], "completed") == 0)
  7516. {
  7517. map<int32, Quest*>* quests = player->GetCompletedPlayerQuests();
  7518. map<int32, Quest*>::iterator itr;
  7519. client->Message(CHANNEL_COLOR_YELLOW, "%s's Completed Quest List:.", client->GetPlayer()->GetName());
  7520. if (quests->size() == 0)
  7521. client->Message(CHANNEL_COLOR_YELLOW, "%s has no completed quests.", client->GetPlayer()->GetName());
  7522. else
  7523. {
  7524. for (itr = quests->begin(); itr != quests->end(); itr++)
  7525. {
  7526. Quest* quest = itr->second;
  7527. if(quest) {
  7528. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  7529. }
  7530. }
  7531. }
  7532. }
  7533. // Add in a progress step, and a LogWrite() for tracking GM Commands.
  7534. // LogWrite(LUA__DEBUG, 0, "LUA", "Quest: %s, function: %s", quest->GetName(), function);
  7535. else if (strcmp(sep->arg[0], "remove") == 0)
  7536. {
  7537. int32 quest_id = 0;
  7538. if (sep && sep->arg[1] && sep->IsNumber(1))
  7539. quest_id = atoul(sep->arg[1]);
  7540. if (quest_id > 0)
  7541. {
  7542. if (lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0)
  7543. {
  7544. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  7545. if (quest)
  7546. if (client->GetPlayer() == player)
  7547. {
  7548. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been removed from your journal", quest->GetName());
  7549. }
  7550. else
  7551. {
  7552. client->Message(CHANNEL_COLOR_YELLOW, "You have removed the quest %s from %s's journal", quest->GetName(), player->GetName());
  7553. if(targetClient) {
  7554. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s has removed the quest %s from your journal", client->GetPlayer()->GetName(), quest->GetName());
  7555. }
  7556. }
  7557. LogWrite(COMMAND__INFO, 0, "GM Command", "%s removed the quest %s from %s", client->GetPlayer()->GetName(), quest->GetName(), player->GetName());
  7558. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  7559. }
  7560. client->RemovePlayerQuest(quest_id);
  7561. client->GetCurrentZone()->SendQuestUpdates(client);
  7562. }
  7563. }
  7564. else if (strcmp(sep->arg[0], "advance") == 0)
  7565. {
  7566. int32 quest_id = 0;
  7567. int32 step = 0;
  7568. if (sep && sep->arg[1] && sep->IsNumber(1))
  7569. {
  7570. quest_id = atoul(sep->arg[1]);
  7571. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  7572. if(!quest) {
  7573. client->Message(CHANNEL_COLOR_RED, "Quest not found!");
  7574. return;
  7575. }
  7576. if (sep && sep->arg[2] && sep->IsNumber(1))
  7577. {
  7578. step = atoul(sep->arg[2]);
  7579. if (quest_id > 0 && step > 0)
  7580. {
  7581. if (player && player->IsPlayer() && quest_id > 0 && step > 0 && (player->player_quests.count(quest_id) > 0))
  7582. {
  7583. if (client)
  7584. {
  7585. client->AddPendingQuestUpdate(quest_id, step);
  7586. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been advanced one step.", quest->GetName());
  7587. LogWrite(COMMAND__INFO, 0, "GM Command", "%s advanced the quest %s one step", client->GetPlayer()->GetName(), quest->GetName());
  7588. }
  7589. }
  7590. }
  7591. else
  7592. {
  7593. client->Message(CHANNEL_COLOR_RED, "Quest ID and Step Number must be greater than 0!");
  7594. }
  7595. }
  7596. else
  7597. {
  7598. client->Message(CHANNEL_COLOR_RED, "Step Number must be a number!");
  7599. }
  7600. }
  7601. else
  7602. {
  7603. client->Message(CHANNEL_COLOR_RED, "Quest ID must be a number!");
  7604. }
  7605. }
  7606. else
  7607. {
  7608. Command_Modify(client);
  7609. }
  7610. }
  7611. else
  7612. {
  7613. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify quest [action] [quest id] [step number]");
  7614. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: list, completed, remove, advance");
  7615. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest list");
  7616. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest remove 156");
  7617. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest advance 50 1");
  7618. }
  7619. }
  7620. void Commands::Command_ModifySkill(Client* client, Seperator* sep)
  7621. {
  7622. PrintSep(sep, "COMMAND_MODIFY");
  7623. // need at least 2 args for a valid command
  7624. if( sep && sep->arg[1] )
  7625. {
  7626. if (strcmp(sep->arg[0], "add") == 0) {
  7627. const char* skill_name = sep->argplus[1];
  7628. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  7629. if (skill) {
  7630. Player* player = 0;
  7631. Client* to_client = 0;
  7632. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  7633. player = (Player*)client->GetPlayer()->GetTarget();
  7634. to_client = player->GetClient();
  7635. }
  7636. else {
  7637. player = client->GetPlayer();
  7638. to_client = client;
  7639. }
  7640. if (player)
  7641. {
  7642. if (!player->GetSkills()->HasSkill(skill->skill_id))
  7643. {
  7644. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  7645. if (to_client == client) {
  7646. client->Message(CHANNEL_STATUS, "Added skill '%s'.", skill_name);
  7647. }
  7648. else {
  7649. client->Message(CHANNEL_STATUS, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  7650. to_client->Message(CHANNEL_STATUS, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  7651. }
  7652. }
  7653. else
  7654. client->Message(CHANNEL_STATUS, "%s already has the skill '%s'.", to_client == client ? "You" : player->GetName(), skill_name);
  7655. }
  7656. }
  7657. else
  7658. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  7659. }
  7660. else if (strcmp(sep->arg[0], "remove") == 0) {
  7661. const char* skill_name = sep->argplus[1];
  7662. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  7663. if (skill) {
  7664. Player* player = 0;
  7665. Client* to_client = 0;
  7666. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  7667. player = (Player*)client->GetPlayer()->GetTarget();
  7668. to_client = player->GetClient();
  7669. }
  7670. else {
  7671. player = client->GetPlayer();
  7672. to_client = client;
  7673. }
  7674. if (player)
  7675. {
  7676. if (player->GetSkills()->HasSkill(skill->skill_id))
  7677. {
  7678. player->RemoveSkillFromDB(skill, true);
  7679. if (client == to_client) {
  7680. client->Message(CHANNEL_STATUS, "Removed skill '%s'.", skill_name);
  7681. }
  7682. else {
  7683. client->Message(CHANNEL_STATUS, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  7684. if(to_client) {
  7685. to_client->Message(CHANNEL_STATUS, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  7686. }
  7687. }
  7688. }
  7689. else {
  7690. if (client == to_client)
  7691. client->Message(CHANNEL_STATUS, "You do not have the skill '%s'.", skill_name);
  7692. else
  7693. client->Message(CHANNEL_STATUS, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  7694. }
  7695. }
  7696. }
  7697. else
  7698. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  7699. }
  7700. else if (strcmp(sep->arg[0], "set") == 0) {
  7701. if (!sep->IsNumber(2)) {
  7702. client->Message(CHANNEL_STATUS, "The last parameter must be a number.");
  7703. return;
  7704. }
  7705. const char* skill_name = sep->arg[1];
  7706. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  7707. if (skill) {
  7708. int16 val = atoi(sep->arg[2]);
  7709. Player* player = 0;
  7710. Client* to_client = 0;
  7711. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  7712. player = (Player*)client->GetPlayer()->GetTarget();
  7713. to_client = player->GetClient();
  7714. }
  7715. else {
  7716. player = client->GetPlayer();
  7717. to_client = client;
  7718. }
  7719. if (player)
  7720. {
  7721. if (player->GetSkills()->HasSkill(skill->skill_id)) {
  7722. player->GetSkills()->SetSkill(skill->skill_id, val);
  7723. if (client != to_client)
  7724. client->Message(CHANNEL_STATUS, "You set %s's '%s' skill to %i.", player->GetName(), skill_name, val);
  7725. if(to_client) {
  7726. to_client->Message(CHANNEL_STATUS, "Your '%s' skill has been set to %i.", skill_name, val);
  7727. }
  7728. }
  7729. else {
  7730. client->Message(CHANNEL_STATUS, "Target does not have the skill '%s'.", skill_name);
  7731. }
  7732. }
  7733. }
  7734. else {
  7735. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  7736. }
  7737. }
  7738. else {
  7739. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  7740. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  7741. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  7742. }
  7743. }
  7744. else {
  7745. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  7746. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  7747. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  7748. }
  7749. }
  7750. void Commands::Command_ModifySpell(Client* client, Seperator* sep)
  7751. {
  7752. PrintSep(sep, "COMMAND_MODIFY");
  7753. // need at least 2 args for a valid command
  7754. if( sep && sep->arg[1] )
  7755. {
  7756. }
  7757. else
  7758. Command_Modify(client);
  7759. }
  7760. void Commands::Command_ModifyZone(Client* client, Seperator* sep)
  7761. {
  7762. PrintSep(sep, "COMMAND_MODIFY");
  7763. // need at least 2 args for a valid command
  7764. if( sep && sep->arg[1] )
  7765. {
  7766. }
  7767. else
  7768. Command_Modify(client);
  7769. }
  7770. /*
  7771. Function: Command_MOTD()
  7772. Purpose : Displays server MOTD
  7773. Params :
  7774. Dev : LethalEncounter
  7775. Example : /motd
  7776. */
  7777. void Commands::Command_MOTD(Client* client)
  7778. {
  7779. if (client)
  7780. ClientPacketFunctions::SendMOTD(client);
  7781. }
  7782. /*
  7783. Function: Command_Pet()
  7784. Purpose : Handle Pet {Command} commands
  7785. Params : attack, backoff, preserve_master, preserve_self, follow, stay, getlost
  7786. Dev :
  7787. Example : /pet preserve_master
  7788. */
  7789. void Commands::Command_Pet(Client* client, Seperator* sep)
  7790. {
  7791. PrintSep(sep, "COMMAND_PET");
  7792. //LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Pet Commands");
  7793. //client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7794. if (!sep || !sep->arg[0])
  7795. return; // should have sep->arg[0] filled
  7796. if (strcmp(sep->arg[0], "hide") == 0) {
  7797. // doing /pet hide will toggle the hide status on all the pets that can be hidden
  7798. Entity* pet = client->GetPlayer()->GetDeityPet();
  7799. if (pet) {
  7800. if (pet->IsPrivateSpawn())
  7801. client->GetPlayer()->HideDeityPet(false);
  7802. else
  7803. client->GetPlayer()->HideDeityPet(true);
  7804. }
  7805. pet = client->GetPlayer()->GetCosmeticPet();
  7806. if (pet) {
  7807. if (pet->IsPrivateSpawn())
  7808. client->GetPlayer()->HideCosmeticPet(false);
  7809. else
  7810. client->GetPlayer()->HideCosmeticPet(true);
  7811. }
  7812. return;
  7813. }
  7814. // below is for all combat pets
  7815. if (!client->GetPlayer()->HasPet()) {
  7816. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a pet.");
  7817. return;
  7818. }
  7819. if (strcmp(sep->arg[0], "stay") == 0 || strcmp(sep->arg[0], "stayhere") == 0) {
  7820. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to stay.");
  7821. client->GetPlayer()->GetInfoStruct()->set_pet_movement(1);
  7822. client->GetPlayer()->SetCharSheetChanged(true);
  7823. if (client->GetPlayer()->GetPet())
  7824. client->GetPlayer()->GetPet()->following = false;
  7825. if (client->GetPlayer()->GetCharmedPet())
  7826. client->GetPlayer()->GetCharmedPet()->following = false;
  7827. }
  7828. else if (strcmp(sep->arg[0], "follow") == 0 || strcmp(sep->arg[0], "followme") == 0) {
  7829. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to follow.");
  7830. client->GetPlayer()->GetInfoStruct()->set_pet_movement(2);
  7831. client->GetPlayer()->SetCharSheetChanged(true);
  7832. }
  7833. else if (strcmp(sep->arg[0], "preserve_master") == 0 || strcmp(sep->arg[0], "guardme") == 0) {
  7834. if (client->GetPlayer()->GetInfoStruct()->get_pet_behavior() & 1) {
  7835. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect you.");
  7836. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()-1);
  7837. }
  7838. else {
  7839. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect you.");
  7840. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()+1);
  7841. }
  7842. client->GetPlayer()->SetCharSheetChanged(true);
  7843. }
  7844. else if (strcmp(sep->arg[0], "preserve_self") == 0 || strcmp(sep->arg[0], "guardhere") == 0) { // guardhere might be accurate, diff logic
  7845. if (client->GetPlayer()->GetInfoStruct()->get_pet_behavior() & 2) {
  7846. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect itself.");
  7847. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()-2);
  7848. }
  7849. else {
  7850. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect itself.");
  7851. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()+2);
  7852. }
  7853. client->GetPlayer()->SetCharSheetChanged(true);
  7854. }
  7855. else if (strcmp(sep->arg[0], "backoff") == 0) {
  7856. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to back down.");
  7857. if (client->GetPlayer()->GetPet())
  7858. ((NPC*)client->GetPlayer()->GetPet())->Brain()->ClearHate();
  7859. if (client->GetPlayer()->GetCharmedPet())
  7860. ((NPC*)client->GetPlayer()->GetCharmedPet())->Brain()->ClearHate();
  7861. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(0);
  7862. client->GetPlayer()->SetCharSheetChanged(true);
  7863. }
  7864. else if (strcmp(sep->arg[0], "attack") == 0) {
  7865. if (client->GetPlayer()->HasTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  7866. if (client->GetPlayer()->AttackAllowed((Entity*)client->GetPlayer()->GetTarget())){
  7867. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to attack your target.");
  7868. if (client->GetPlayer()->GetPet())
  7869. client->GetPlayer()->GetPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  7870. if (client->GetPlayer()->GetCharmedPet())
  7871. client->GetPlayer()->GetCharmedPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  7872. }
  7873. else
  7874. client->Message(CHANNEL_COLOR_YELLOW, "You can not attack that.");
  7875. }
  7876. else
  7877. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a target.");
  7878. }
  7879. else if (strcmp(sep->arg[0], "getlost") == 0) {
  7880. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetPet());
  7881. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetCharmedPet());
  7882. client->Message(CHANNEL_COLOR_YELLOW, "You tell your pet to get lost.");
  7883. }
  7884. else
  7885. client->Message(CHANNEL_COLOR_YELLOW, "Unknown pet command %s.", sep->arg[0]);
  7886. }
  7887. /*
  7888. Function: Command_PetName()
  7889. Purpose : Pet your name (???)
  7890. Params :
  7891. Dev :
  7892. Example :
  7893. */
  7894. void Commands::Command_PetName(Client* client, Seperator* sep)
  7895. {
  7896. if (sep && sep->arg[0]) {
  7897. const char* pet_name = sep->argplus[0];
  7898. client->SetPetName(pet_name);
  7899. }
  7900. else {
  7901. client->GetPlayer()->GetInfoStruct()->set_pet_name("");
  7902. }
  7903. }
  7904. /*
  7905. Function: Command_NamePet()
  7906. Purpose : Name your pet
  7907. Params :
  7908. Dev :
  7909. Example :
  7910. */
  7911. void Commands::Command_NamePet(Client* client, Seperator* sep)
  7912. {
  7913. PrintSep(sep, "COMMAND_NAME_PET");
  7914. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Name Pet Command");
  7915. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7916. }
  7917. /*
  7918. Function: Command_Rename()
  7919. Purpose : Renames existing pet
  7920. Params :
  7921. Dev :
  7922. Example :
  7923. */
  7924. void Commands::Command_Rename(Client* client, Seperator* sep)
  7925. {
  7926. PrintSep(sep, "COMMAND_RENAME");
  7927. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Rename Pet Command");
  7928. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7929. }
  7930. /*
  7931. Function: Command_ConfirmRename()
  7932. Purpose : Confirms renaming your pet
  7933. Params :
  7934. Dev :
  7935. Example :
  7936. */
  7937. void Commands::Command_ConfirmRename(Client* client, Seperator* sep)
  7938. {
  7939. PrintSep(sep, "COMMAND_CONFIRMRENAME");
  7940. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Confirm Rename Pet Command");
  7941. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7942. }
  7943. /*
  7944. Function: Command_PetOptions()
  7945. Purpose : Sets various pet options
  7946. Params :
  7947. Dev :
  7948. Example :
  7949. */
  7950. void Commands::Command_PetOptions(Client* client, Seperator* sep)
  7951. {
  7952. PrintSep(sep, "COMMAND_PETOPTIONS");
  7953. Player* player = client->GetPlayer();
  7954. Spawn* target = player->GetTarget();
  7955. if (!target)
  7956. return;
  7957. if (target == player->GetPet())
  7958. client->SendPetOptionsWindow(player->GetPet()->GetName());
  7959. else if (target == player->GetCharmedPet())
  7960. client->SendPetOptionsWindow(player->GetCharmedPet()->GetName());
  7961. else if (target == player->GetCosmeticPet())
  7962. client->SendPetOptionsWindow(player->GetCosmeticPet()->GetName(), 0);
  7963. else if (target == player->GetDeityPet())
  7964. client->SendPetOptionsWindow(player->GetDeityPet()->GetName(), 0);
  7965. }
  7966. /*
  7967. Function: Command_Random()
  7968. Purpose : Handles /random dice roll in-game
  7969. Params : 1-100
  7970. Dev : Scatman
  7971. Example : /randon 1 100
  7972. */
  7973. void Commands::Command_Random(Client* client, Seperator* sep)
  7974. {
  7975. char message[256] = {0};
  7976. if (sep)
  7977. {
  7978. if (sep->GetArgNumber() == 0 && sep->IsNumber(0))
  7979. 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])));
  7980. else if (sep->GetArgNumber() > 0 && sep->IsNumber(0) && sep->IsNumber(1))
  7981. 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])));
  7982. else
  7983. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  7984. }
  7985. else
  7986. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  7987. client->GetPlayer()->GetZone()->HandleChatMessage(0, 0, CHANNEL_EMOTE, message);
  7988. }
  7989. /*
  7990. Function: Command_Randomize()
  7991. Purpose : Sets randomize (appearance) values for NPCs
  7992. Params : Attrib Name
  7993. Dev : Scatman
  7994. Example : /randomize gender 1 -- will randomize the NPCs gender (male/female)
  7995. */
  7996. void Commands::Command_Randomize(Client* client, Seperator* sep)
  7997. {
  7998. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  7999. if (target)
  8000. {
  8001. if (target->IsNPC())
  8002. {
  8003. if (sep && sep->arg[0] && !sep->IsNumber(0))
  8004. {
  8005. const char* value = sep->arg[0];
  8006. if (strncasecmp(value, "show", strlen(value)) == 0)
  8007. {
  8008. client->DisplayRandomizeFeatures(target->GetRandomize());
  8009. }
  8010. else
  8011. {
  8012. if (sep->arg[1] && sep->IsNumber(1))
  8013. {
  8014. int8 option = atoi(sep->arg[1]);
  8015. if (option == 0 || option == 1)
  8016. {
  8017. int32 feature = 0;
  8018. char feature_text[32] = {0};
  8019. if (strncasecmp(value, "gender", strlen(value)) == 0) {
  8020. feature = RANDOMIZE_GENDER;
  8021. strncpy(feature_text, "gender", sizeof(feature_text) - 1);
  8022. }
  8023. else if (strncasecmp(value, "race", strlen(value)) == 0) {
  8024. feature = RANDOMIZE_RACE;
  8025. strncpy(feature_text, "race", sizeof(feature_text) - 1);
  8026. }
  8027. else if (strncasecmp(value, "model", strlen(value)) == 0) {
  8028. feature = RANDOMIZE_MODEL_TYPE;
  8029. strncpy(feature_text, "model", sizeof(feature_text) - 1);
  8030. }
  8031. else if (strncasecmp(value, "facial_hair", strlen(value)) == 0) {
  8032. feature = RANDOMIZE_FACIAL_HAIR_TYPE;
  8033. strncpy(feature_text, "facial hair", sizeof(feature_text) - 1);
  8034. }
  8035. else if (strncasecmp(value, "hair", strlen(value)) == 0) {
  8036. feature = RANDOMIZE_HAIR_TYPE;
  8037. strncpy(feature_text, "hair", sizeof(feature_text) - 1);
  8038. }
  8039. else if (strncasecmp(value, "wing", strlen(value)) == 0) {
  8040. feature = RANDOMIZE_WING_TYPE;
  8041. strncpy(feature_text, "wings", sizeof(feature_text) - 1);
  8042. }
  8043. else if (strncasecmp(value, "cheek", strlen(value)) == 0) {
  8044. feature = RANDOMIZE_CHEEK_TYPE;
  8045. strncpy(feature_text, "cheeks", sizeof(feature_text) - 1);
  8046. }
  8047. else if (strncasecmp(value, "chin", strlen(value)) == 0) {
  8048. feature = RANDOMIZE_CHIN_TYPE;
  8049. strncpy(feature_text, "chin", sizeof(feature_text) - 1);
  8050. }
  8051. else if (strncasecmp(value, "ear", strlen(value)) == 0) {
  8052. feature = RANDOMIZE_EAR_TYPE;
  8053. strncpy(feature_text, "ears", sizeof(feature_text) - 1);
  8054. }
  8055. else if (strncasecmp(value, "eye_brow", strlen(value)) == 0) {
  8056. feature = RANDOMIZE_EYE_BROW_TYPE;
  8057. strncpy(feature_text, "eye brows", sizeof(feature_text) - 1);
  8058. }
  8059. else if (strncasecmp(value, "eye", strlen(value)) == 0) {
  8060. feature = RANDOMIZE_EYE_TYPE;
  8061. strncpy(feature_text, "eyes", sizeof(feature_text) - 1);
  8062. }
  8063. else if (strncasecmp(value, "lip", strlen(value)) == 0) {
  8064. feature = RANDOMIZE_LIP_TYPE;
  8065. strncpy(feature_text, "lips", sizeof(feature_text) - 1);
  8066. }
  8067. else if (strncasecmp(value, "nose", strlen(value)) == 0) {
  8068. feature = RANDOMIZE_NOSE_TYPE;
  8069. strncpy(feature_text, "nose", sizeof(feature_text) - 1);
  8070. }
  8071. else if (strncasecmp(value, "eye_color", strlen(value)) == 0) {
  8072. feature = RANDOMIZE_EYE_COLOR;
  8073. strncpy(feature_text, "eye color", sizeof(feature_text) - 1);
  8074. }
  8075. else if (strncasecmp(value, "hair_color", strlen(value)) == 0) {
  8076. feature = RANDOMIZE_HAIR_TYPE_COLOR;
  8077. strncpy(feature_text, "hair color", sizeof(feature_text) - 1);
  8078. }
  8079. else if (strncasecmp(value, "hair_color1", strlen(value)) == 0) {
  8080. feature = RANDOMIZE_HAIR_COLOR1;
  8081. strncpy(feature_text, "hair color1", sizeof(feature_text) - 1);
  8082. }
  8083. else if (strncasecmp(value, "hair_color2", strlen(value)) == 0) {
  8084. feature = RANDOMIZE_HAIR_COLOR2;
  8085. strncpy(feature_text, "hair color2", sizeof(feature_text) - 1);
  8086. }
  8087. else if (strncasecmp(value, "hair_highlight", strlen(value)) == 0) {
  8088. feature = RANDOMIZE_HAIR_HIGHLIGHT;
  8089. strncpy(feature_text, "hair highlights", sizeof(feature_text) - 1);
  8090. }
  8091. else if (strncasecmp(value, "facial_hair_color", strlen(value)) == 0) {
  8092. feature = RANDOMIZE_HAIR_FACE_COLOR;
  8093. strncpy(feature_text, "facial hair color", sizeof(feature_text) - 1);
  8094. }
  8095. else if (strncasecmp(value, "facial_hair_color_highlight", strlen(value)) == 0) {
  8096. feature = RANDOMIZE_HAIR_FACE_HIGHLIGHT_COLOR;
  8097. strncpy(feature_text, "facial hair color highlights", sizeof(feature_text) - 1);
  8098. }
  8099. else if (strncasecmp(value, "hair_color_highlight", strlen(value)) == 0) {
  8100. feature = RANDOMIZE_HAIR_TYPE_HIGHLIGHT_COLOR;
  8101. strncpy(feature_text, "hair color highlights", sizeof(feature_text) - 1);
  8102. }
  8103. else if (strncasecmp(value, "skin_color", strlen(value)) == 0) {
  8104. feature = RANDOMIZE_SKIN_COLOR;
  8105. strncpy(feature_text, "skin color", sizeof(feature_text) - 1);
  8106. }
  8107. else if (strncasecmp(value, "wing_color1", strlen(value)) == 0) {
  8108. feature = RANDOMIZE_WING_COLOR1;
  8109. strncpy(feature_text, "wing color1", sizeof(feature_text) - 1);
  8110. }
  8111. else if (strncasecmp(value, "wing_color2", strlen(value)) == 0) {
  8112. feature = RANDOMIZE_WING_COLOR2;
  8113. strncpy(feature_text, "wing color2", sizeof(feature_text) - 1);
  8114. }
  8115. else {
  8116. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is not a valid feature to randomize.", value);
  8117. 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'.");
  8118. }
  8119. if (feature > 0) {
  8120. if (option == 1) {
  8121. if (target->GetRandomize() & feature)
  8122. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is already set to randomly generate their %s.", target->GetName(), feature_text);
  8123. else {
  8124. target->AddRandomize(feature);
  8125. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(feature);
  8126. database.UpdateRandomize(target->GetDatabaseID(), feature);
  8127. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will now generate their %s randomly.", target->GetName(), feature_text);
  8128. }
  8129. }
  8130. else {
  8131. if (target->GetRandomize() & feature) {
  8132. target->AddRandomize(-feature);
  8133. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(-feature);
  8134. database.UpdateRandomize(target->GetDatabaseID(), -feature);
  8135. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will no longer generate their %s randomly.", target->GetName(), feature_text);
  8136. }
  8137. else
  8138. client->Message(CHANNEL_COLOR_YELLOW, "'%s' already does not randomly generate their %s.", target->GetName(), feature_text);
  8139. }
  8140. }
  8141. }
  8142. else
  8143. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  8144. }
  8145. else
  8146. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  8147. }
  8148. }
  8149. else {
  8150. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /randomize [show | [feature [1|0]]");
  8151. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "'show' will display current configured features");
  8152. 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'.");
  8153. }
  8154. }
  8155. else
  8156. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "The target you wish to randomize must be an NPC.");
  8157. }
  8158. else
  8159. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select the target you wish to randomize.");
  8160. }
  8161. /*
  8162. Function: Command_ShowCloak()
  8163. Purpose : Character Settings combo box for Show Cloak
  8164. Params : true/false
  8165. Dev : John Adams
  8166. Example :
  8167. */
  8168. void Commands::Command_ShowCloak(Client* client, Seperator* sep)
  8169. {
  8170. Player* player = client->GetPlayer();
  8171. if (sep && sep->arg[0])
  8172. {
  8173. const char* value = sep->arg[0];
  8174. if (strncasecmp(value, "true", strlen(value)) == 0)
  8175. {
  8176. player->set_character_flag(CF_SHOW_CLOAK);
  8177. player->reset_character_flag(CF2_SHOW_RANGED);
  8178. }
  8179. else if (strncasecmp(value, "false", strlen(value)) == 0)
  8180. player->reset_character_flag(CF_SHOW_CLOAK);
  8181. else
  8182. {
  8183. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8184. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8185. }
  8186. }
  8187. }
  8188. /*
  8189. Function: Command_ShowHelm()
  8190. Purpose : Character Settings combo box for Show Helm
  8191. Params : true/false
  8192. Dev : John Adams
  8193. Example :
  8194. */
  8195. void Commands::Command_ShowHelm(Client* client, Seperator* sep)
  8196. {
  8197. Player* player = client->GetPlayer();
  8198. if(client->GetVersion() <= 561) {
  8199. return; // not allowed/supported
  8200. }
  8201. if (sep && sep->arg[0])
  8202. {
  8203. PrintSep(sep, "Command_ShowHelm");
  8204. const char* value = sep->arg[0];
  8205. if (strncasecmp(value, "true", strlen(value)) == 0)
  8206. {
  8207. player->toggle_character_flag(CF_HIDE_HELM);
  8208. player->toggle_character_flag(CF_HIDE_HOOD);
  8209. }
  8210. else if (strncasecmp(value, "false", strlen(value)) == 0)
  8211. player->toggle_character_flag(CF_HIDE_HELM);
  8212. else
  8213. {
  8214. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8215. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8216. }
  8217. }
  8218. }
  8219. /*
  8220. Function: Command_ShowHood()
  8221. Purpose : Character Settings combo box for Show Hood
  8222. Params : true/false
  8223. Dev : John Adams
  8224. Example :
  8225. */
  8226. void Commands::Command_ShowHood(Client* client, Seperator* sep)
  8227. {
  8228. Player* player = client->GetPlayer();
  8229. if (sep && sep->arg[0])
  8230. {
  8231. PrintSep(sep, "Command_ShowHood");
  8232. const char* value = sep->arg[0];
  8233. if (strncasecmp(value, "true", strlen(value)) == 0)
  8234. {
  8235. player->toggle_character_flag(CF_HIDE_HOOD);
  8236. if(client->GetVersion() > 561) { // no hide helm support in DoF
  8237. player->toggle_character_flag(CF_HIDE_HELM);
  8238. }
  8239. }
  8240. else if (strncasecmp(value, "false", strlen(value)) == 0) {
  8241. player->toggle_character_flag(CF_HIDE_HOOD);
  8242. }
  8243. else
  8244. {
  8245. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8246. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8247. }
  8248. }
  8249. }
  8250. /*
  8251. Function: Command_ShowHoodHelm()
  8252. Purpose : Character Settings combo box for Show Helm or Hood
  8253. Params : true/false
  8254. Dev : John Adams
  8255. Example :
  8256. */
  8257. void Commands::Command_ShowHoodHelm(Client* client, Seperator* sep)
  8258. {
  8259. Player* player = client->GetPlayer();
  8260. if(client->GetVersion() <= 561) {
  8261. return; // not allowed/supported
  8262. }
  8263. if (sep && sep->arg[0])
  8264. {
  8265. PrintSep(sep, "Command_ShowHoodHelm");
  8266. const char* value = sep->arg[0];
  8267. if (strncasecmp(value, "true", strlen(value)) == 0)
  8268. {
  8269. player->toggle_character_flag(CF_HIDE_HOOD);
  8270. player->toggle_character_flag(CF_HIDE_HELM);
  8271. }
  8272. else if (strncasecmp(value, "false", strlen(value)) == 0)
  8273. {
  8274. // don't think we ever wind up in here...
  8275. player->toggle_character_flag(CF_HIDE_HOOD);
  8276. player->toggle_character_flag(CF_HIDE_HELM);
  8277. }
  8278. else
  8279. {
  8280. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8281. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8282. }
  8283. }
  8284. }
  8285. /*
  8286. Function: Command_ShowRanged()
  8287. Purpose : Character Settings combo box for Show Ranged weapon
  8288. Params : true/false
  8289. Dev : John Adams
  8290. Example :
  8291. */
  8292. void Commands::Command_ShowRanged(Client* client, Seperator* sep)
  8293. {
  8294. Player* player = client->GetPlayer();
  8295. if (sep && sep->arg[0])
  8296. {
  8297. const char* value = sep->arg[0];
  8298. if (strncasecmp(value, "true", strlen(value)) == 0)
  8299. {
  8300. player->set_character_flag(CF2_SHOW_RANGED);
  8301. player->reset_character_flag(CF_SHOW_CLOAK);
  8302. }
  8303. else if (strncasecmp(value, "false", strlen(value)) == 0)
  8304. player->reset_character_flag(CF2_SHOW_RANGED);
  8305. else
  8306. {
  8307. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8308. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8309. }
  8310. }
  8311. }
  8312. /*
  8313. Function:
  8314. Purpose :
  8315. Params :
  8316. Dev :
  8317. Example :
  8318. */
  8319. void Commands::Command_Skills(Client* client, Seperator* sep, int handler)
  8320. {
  8321. Player* player = 0;
  8322. Client* to_client = 0;
  8323. if(client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  8324. to_client = ((Player*)client->GetPlayer()->GetTarget())->GetClient();
  8325. switch(handler)
  8326. {
  8327. case COMMAND_SKILL:
  8328. {
  8329. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill [add|remove|list] [skill name]");
  8330. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to add/remove skills for that player.");
  8331. break;
  8332. }
  8333. case COMMAND_SKILL_ADD:
  8334. {
  8335. if (sep && sep->arg[0])
  8336. {
  8337. const char* skill_name = sep->argplus[0];
  8338. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  8339. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // add skill to your target, if target is not you
  8340. {
  8341. player = to_client->GetPlayer();
  8342. if (player)
  8343. {
  8344. if (!player->GetSkills()->HasSkill(skill->skill_id))
  8345. {
  8346. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  8347. client->Message(CHANNEL_COLOR_YELLOW, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  8348. to_client->Message(CHANNEL_COLOR_YELLOW, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  8349. }
  8350. else
  8351. client->Message(CHANNEL_COLOR_YELLOW, "%s already has the skill '%s'.", player->GetName(), skill_name);
  8352. }
  8353. }
  8354. else if (skill) // add skill to yourself
  8355. {
  8356. player = client->GetPlayer();
  8357. if (player)
  8358. {
  8359. if (!player->GetSkills()->HasSkill(skill->skill_id))
  8360. {
  8361. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  8362. client->Message(CHANNEL_COLOR_YELLOW, "Added skill '%s'.", skill_name);
  8363. }
  8364. else
  8365. client->Message(CHANNEL_COLOR_YELLOW, "You already have the skill '%s'.", skill_name);
  8366. }
  8367. }
  8368. else
  8369. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  8370. }
  8371. else
  8372. {
  8373. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill add [skill name]");
  8374. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  8375. }
  8376. break;
  8377. }
  8378. case COMMAND_SKILL_REMOVE:
  8379. {
  8380. if (sep && sep->arg[0])
  8381. {
  8382. const char* skill_name = sep->argplus[0];
  8383. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  8384. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // remove skill from your target, if target is not you
  8385. {
  8386. player = to_client->GetPlayer();
  8387. if (player)
  8388. {
  8389. if (player->GetSkills()->HasSkill(skill->skill_id))
  8390. {
  8391. player->RemoveSkillFromDB(skill, true);
  8392. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  8393. to_client->Message(CHANNEL_COLOR_YELLOW, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  8394. }
  8395. else
  8396. client->Message(CHANNEL_COLOR_YELLOW, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  8397. }
  8398. }
  8399. else if(skill) // remove skill from yourself
  8400. {
  8401. Player* player = client->GetPlayer();
  8402. if (player)
  8403. {
  8404. if (player->GetSkills()->HasSkill(skill->skill_id))
  8405. {
  8406. player->RemoveSkillFromDB(skill, true);
  8407. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s'.", skill_name);
  8408. }
  8409. else
  8410. client->Message(CHANNEL_COLOR_YELLOW, "You do not have the skill '%s'.", skill_name);
  8411. }
  8412. }
  8413. else
  8414. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  8415. }
  8416. else
  8417. {
  8418. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill remove [skill name]");
  8419. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  8420. }
  8421. break;
  8422. }
  8423. case COMMAND_SKILL_LIST:
  8424. {
  8425. if (sep && sep->arg[0])
  8426. {
  8427. const char* skill_name = sep->argplus[0];
  8428. client->Message(CHANNEL_COLOR_YELLOW, "Listing skills like '%s':", skill_name);
  8429. map<int32, Skill*>* skills = master_skill_list.GetAllSkills();
  8430. map<int32, Skill*>::iterator itr;
  8431. if (skills && skills->size() > 0)
  8432. {
  8433. for (itr = skills->begin(); itr != skills->end(); itr++)
  8434. {
  8435. Skill* skill = itr->second;
  8436. string current_skill_name = ::ToLower(string(skill->name.data.c_str()));
  8437. if (current_skill_name.find(::ToLower(string(skill_name))) < 0xFFFFFFFF)
  8438. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", skill->name.data.c_str(), skill->skill_id);
  8439. }
  8440. }
  8441. }
  8442. else
  8443. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill list [skill name]");
  8444. break;
  8445. }
  8446. }
  8447. }
  8448. /*
  8449. Function: Command_SpawnTemplate()
  8450. Purpose : Create or Use defined Spawn Templates
  8451. Params : create, save, rempve, list
  8452. Dev : John Adams
  8453. Example : /spawn template create "Test"
  8454. */
  8455. void Commands::Command_SpawnTemplate(Client* client, Seperator* sep)
  8456. {
  8457. if (sep == NULL || sep->arg[0] == NULL)
  8458. {
  8459. 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.");
  8460. return;
  8461. }
  8462. // got params, continue
  8463. const char * template_cmd = sep->arg[0];
  8464. if (strncasecmp(template_cmd, "list", strlen(template_cmd)) == 0)
  8465. {
  8466. if (!sep->IsSet(1))
  8467. {
  8468. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /spawn template list [name|location_id]");
  8469. 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.");
  8470. return;
  8471. }
  8472. map<int32, string>* template_names = 0;
  8473. if (sep->IsNumber(1))
  8474. {
  8475. int32 location_id = 0;
  8476. location_id = atoi(sep->arg[1]);
  8477. template_names = database.GetSpawnTemplateListByID(location_id);
  8478. }
  8479. else
  8480. {
  8481. const char* name = 0;
  8482. name = sep->argplus[1];
  8483. template_names = database.GetSpawnTemplateListByName(name);
  8484. }
  8485. if(!template_names)
  8486. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No templates found.");
  8487. else
  8488. {
  8489. map<int32, string>::iterator itr;
  8490. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  8491. for(itr = template_names->begin(); itr != template_names->end(); itr++)
  8492. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  8493. safe_delete(template_names);
  8494. }
  8495. }
  8496. else if (strncasecmp(template_cmd, "save", strlen(template_cmd)) == 0)
  8497. {
  8498. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  8499. if ( target && (target->IsNPC() || target->IsObject() || target->IsSign() || target->IsWidget() || target->IsGroundSpawn()) )
  8500. {
  8501. if (sep && sep->arg[1][0] && !sep->IsNumber(1))
  8502. {
  8503. // first, lookup to see if template name already exists
  8504. const char* name = 0;
  8505. name = sep->argplus[1];
  8506. map<int32, string>* template_names = database.GetSpawnTemplateListByName(name);
  8507. if(!template_names)
  8508. {
  8509. int32 new_template_id = database.SaveSpawnTemplate(target->GetSpawnLocationID(), name);
  8510. if( new_template_id > 0 )
  8511. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template '%s' added for spawn '%s' (%u) as TemplateID: %u", name, target->GetName(), target->GetSpawnLocationID(), new_template_id);
  8512. else
  8513. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' for spawn '%s' (%u).", name, target->GetName(), target->GetSpawnLocationID());
  8514. }
  8515. else
  8516. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' - Already exists!", name);
  8517. }
  8518. else
  8519. client->Message(CHANNEL_COLOR_RED, "ERROR: Saving a new spawn template requires a valid template name!");
  8520. }
  8521. else
  8522. client->Message(CHANNEL_COLOR_RED, "ERROR: You must target the spawn you wish to save as a template!");
  8523. }
  8524. else if (strncasecmp(template_cmd, "remove", strlen(template_cmd)) == 0)
  8525. {
  8526. if (sep && sep->arg[1][0] && sep->IsNumber(1))
  8527. {
  8528. int32 template_id = 0;
  8529. template_id = atoi(sep->arg[1]);
  8530. if (database.RemoveSpawnTemplate(template_id))
  8531. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template ID: %u successfully removed.", template_id);
  8532. else
  8533. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to remove spawn template ID: %u", template_id);
  8534. }
  8535. else
  8536. client->Message(CHANNEL_COLOR_RED, "ERROR: Removing a spawn template requires a valid template ID!");
  8537. }
  8538. // Renamed create to spawn
  8539. else if (strncasecmp(template_cmd, "spawn", strlen(template_cmd)) == 0)
  8540. {
  8541. if (sep && sep->arg[1][0])
  8542. {
  8543. int32 new_location = 0;
  8544. if (sep->IsNumber(1))
  8545. {
  8546. int32 template_id = 0;
  8547. template_id = atoi(sep->arg[1]);
  8548. new_location = database.CreateSpawnFromTemplateByID(client, template_id);
  8549. if( new_location > 0 )
  8550. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template ID: %u", new_location, template_id);
  8551. else
  8552. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template ID: %u", template_id);
  8553. }
  8554. else
  8555. {
  8556. const char* name = 0;
  8557. name = sep->argplus[1];
  8558. new_location = database.CreateSpawnFromTemplateByName(client, name);
  8559. if( new_location > 0 )
  8560. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template: '%s'", new_location, name);
  8561. else
  8562. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template: '%s'", name);
  8563. }
  8564. }
  8565. else
  8566. client->Message(CHANNEL_COLOR_RED, "ERROR: Spawning a new spawn location requires a valid template name or ID!");
  8567. }
  8568. else
  8569. client->Message(CHANNEL_COLOR_RED, "ERROR: Unknown /spawn template command.");
  8570. }
  8571. void Commands::Command_Speed(Client* client, Seperator* sep) {
  8572. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  8573. float new_speed = atof(sep->arg[0]);
  8574. if (new_speed > 0.0f)
  8575. {
  8576. client->GetPlayer()->SetSpeed(new_speed, true);
  8577. client->GetPlayer()->SetCharSheetChanged(true);
  8578. database.insertCharacterProperty(client, CHAR_PROPERTY_SPEED, sep->arg[0]);
  8579. client->Message(CHANNEL_STATUS, "Setting speed to %.2f.", new_speed);
  8580. }
  8581. else
  8582. client->Message(CHANNEL_STATUS, "Invalid speed provided %s.", sep->arg[0]);
  8583. }
  8584. else{
  8585. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /speed {new speed value}");
  8586. }
  8587. }
  8588. /*
  8589. Function: Command_StationMarketPlace()
  8590. Purpose : just trying to eat the console spam for now
  8591. Params :
  8592. Dev : John
  8593. */
  8594. void Commands::Command_StationMarketPlace(Client* client, Seperator* sep)
  8595. {
  8596. PrintSep(sep, "COMMAND_SMP");
  8597. // This will reduce the spam from once every 10 sec to once every 30 sec,
  8598. // can't seem to reduce it any more get rid of it completely...
  8599. if (sep && strcmp(sep->arg[0], "gkw") == 0) {
  8600. PacketStruct* packet = configReader.getStruct("WS_MarketFundsUpdate", client->GetVersion());
  8601. if (packet) {
  8602. packet->setDataByName("account_id", client->GetAccountID());
  8603. packet->setDataByName("character_id", client->GetCharacterID());
  8604. packet->setDataByName("unknown1", 1, 5);
  8605. packet->setDataByName("unknown1", 26, 6);
  8606. packet->setDataByName("unknown2", 0xFFFFFFFF);
  8607. packet->setDataByName("unknown3", 248, 1);
  8608. client->QueuePacket(packet->serialize());
  8609. }
  8610. safe_delete(packet);
  8611. }
  8612. }
  8613. /*
  8614. Function: Command_StopDrinking()
  8615. Purpose : Stops player from auto-consuming drink
  8616. Params :
  8617. Dev : Zcoretri
  8618. Example : /stopdrinking
  8619. */
  8620. void Commands::Command_StopDrinking(Client* client)
  8621. {
  8622. client->GetPlayer()->reset_character_flag(CF_DRINK_AUTO_CONSUME);
  8623. client->GetPlayer()->SetActiveDrinkUniqueID(0);
  8624. client->Message(CHANNEL_COLOR_YELLOW,"You stop drinking your current drink.");
  8625. }
  8626. /*
  8627. Function: Command_StopEating()
  8628. Purpose : Stops player from auto-consuming food
  8629. Params :
  8630. Dev : Zcoretri
  8631. Example : /stopeating
  8632. */
  8633. void Commands::Command_StopEating(Client* client)
  8634. {
  8635. client->GetPlayer()->reset_character_flag(CF_FOOD_AUTO_CONSUME);
  8636. client->GetPlayer()->SetActiveFoodUniqueID(0);
  8637. client->Message(CHANNEL_COLOR_YELLOW,"You stop eating your current food.");
  8638. }
  8639. /*
  8640. Function: Command_Title()
  8641. Purpose : Help for /title command
  8642. Params : n/a
  8643. Dev : Zcoretri
  8644. Example : /title
  8645. */
  8646. void Commands::Command_Title(Client* client)
  8647. {
  8648. client->Message(CHANNEL_COLOR_YELLOW, "Available subcommands: list, setprefix <index>, setsuffix <index>, fix");
  8649. }
  8650. /*
  8651. Function: Command_TitleList()
  8652. Purpose : List available titles for player
  8653. Params : n/a
  8654. Dev : Zcoretri
  8655. Example : /title list
  8656. */
  8657. void Commands::Command_TitleList(Client* client)
  8658. {
  8659. // must call release read lock before leaving function on GetPlayerTitles
  8660. vector<Title*>* titles = client->GetPlayer()->GetPlayerTitles()->GetAllTitles();
  8661. vector<Title*>::iterator itr;
  8662. Title* title;
  8663. sint32 i = 0;
  8664. client->Message(CHANNEL_NARRATIVE, "Listing available titles:");
  8665. for(itr = titles->begin(); itr != titles->end(); itr++)
  8666. {
  8667. title = *itr;
  8668. client->Message(CHANNEL_NARRATIVE, "%i: type=[%s] title=[%s]", i, title->GetPrefix() ? "Prefix":"Suffix", title->GetName());
  8669. i++;
  8670. }
  8671. client->GetPlayer()->GetPlayerTitles()->ReleaseReadLock();
  8672. }
  8673. /*
  8674. Function: Command_TitleSetPrefix()
  8675. Purpose : Set Prefix title for player
  8676. Params : Title ID
  8677. Dev : Zcoretri
  8678. Example : /title setprefix 1
  8679. */
  8680. void Commands::Command_TitleSetPrefix(Client* client, Seperator* sep)
  8681. {
  8682. if (sep && sep->arg[0] && sep->IsNumber(0))
  8683. {
  8684. sint32 index = atoul(sep->arg[0]);
  8685. if(index > -1)
  8686. {
  8687. Title* title = client->GetPlayer()->GetPlayerTitles()->GetTitle(index);
  8688. if(!title)
  8689. {
  8690. client->Message(CHANNEL_COLOR_RED, "Missing index %i to set title", index);
  8691. return;
  8692. }
  8693. else if(!title->GetPrefix())
  8694. {
  8695. client->Message(CHANNEL_COLOR_RED, "%s is not a prefix.", title->GetName());
  8696. return;
  8697. }
  8698. }
  8699. else // make sure client doesn't pass some bogus negative index
  8700. index = -1;
  8701. database.SaveCharPrefixIndex(index, client->GetCharacterID());
  8702. client->SendTitleUpdate();
  8703. }
  8704. }
  8705. /*
  8706. Function: Command_TitleSetSuffix()
  8707. Purpose : Set Suffix title for player
  8708. Params : Title ID
  8709. Dev : Zcoretri
  8710. Example : /title setsuffix 1
  8711. */
  8712. void Commands::Command_TitleSetSuffix(Client* client, Seperator* sep)
  8713. {
  8714. if (sep && sep->arg[0] && sep->IsNumber(0))
  8715. {
  8716. sint32 index = atoul(sep->arg[0]);
  8717. if(index > -1)
  8718. {
  8719. Title* title = client->GetPlayer()->GetPlayerTitles()->GetTitle(index);
  8720. if(!title)
  8721. {
  8722. client->Message(CHANNEL_COLOR_RED, "Missing index %i to set title", index);
  8723. return;
  8724. }
  8725. else if(title->GetPrefix())
  8726. {
  8727. client->Message(CHANNEL_COLOR_RED, "%s is not a suffix.", title->GetName());
  8728. return;
  8729. }
  8730. }
  8731. else // make sure client doesn't pass some bogus negative index
  8732. index = -1;
  8733. database.SaveCharSuffixIndex(index, client->GetCharacterID());
  8734. client->SendTitleUpdate();
  8735. }
  8736. }
  8737. /*
  8738. Function: Command_TitleFix()
  8739. Purpose : Fix title for player (???)
  8740. Params :
  8741. Dev : Zcoretri
  8742. Example :
  8743. */
  8744. void Commands::Command_TitleFix(Client* client, Seperator* sep)
  8745. {
  8746. PrintSep(sep, "COMMAND_TITLE_FIX");
  8747. LogWrite(MISC__TODO, 1, "Titles", "TODO-Command: TITLE_FIX");
  8748. }
  8749. /*
  8750. Function: Command_Toggle_Anonymous()
  8751. Purpose : Toggles player Anonymous
  8752. Params :
  8753. Dev : paulgh
  8754. Example : /anon
  8755. */
  8756. void Commands::Command_Toggle_Anonymous(Client* client)
  8757. {
  8758. Player* player = client->GetPlayer();
  8759. player->toggle_character_flag(CF_ANONYMOUS);
  8760. client->Message(CHANNEL_COLOR_YELLOW,"You are %s anonymous.", player->get_character_flag(CF_ANONYMOUS)?"now":"no longer");
  8761. if (player->get_character_flag(CF_ANONYMOUS))
  8762. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ANONYMOUS);
  8763. else
  8764. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ANONYMOUS);
  8765. }
  8766. /*
  8767. Function: Command_Toggle_AutoConsume()
  8768. Purpose : Toggles player food/drink auto consume
  8769. Params : unknown
  8770. Dev : paulgh
  8771. Example : /set_auto_consume
  8772. */
  8773. void Commands::Command_Toggle_AutoConsume(Client* client, Seperator* sep)
  8774. {
  8775. Player* player = client->GetPlayer();
  8776. if (sep && sep->arg[0])
  8777. PrintSep(sep, "COMMAND_SET_AUTO_CONSUME");
  8778. if (sep && sep->arg[0] && sep->IsNumber(0))
  8779. {
  8780. int8 slot = atoi(sep->arg[0]);
  8781. int8 flag = atoi(sep->arg[1]);
  8782. if (client->GetVersion() <= 373) {
  8783. slot += 4;
  8784. }
  8785. else if (client->GetVersion() <= 561) {
  8786. slot += 2;
  8787. }
  8788. if (slot == EQ2_FOOD_SLOT)
  8789. {
  8790. player->toggle_character_flag(CF_FOOD_AUTO_CONSUME);
  8791. player->SetCharSheetChanged(true);
  8792. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  8793. if (flag == 1)
  8794. client->Message(CHANNEL_NARRATIVE, "You decide to eat immediately whenever you become hungry.");
  8795. else
  8796. {
  8797. client->Message(CHANNEL_NARRATIVE, "You decide to ignore the hunger.");
  8798. return;
  8799. }
  8800. }
  8801. else
  8802. {
  8803. player->toggle_character_flag(CF_DRINK_AUTO_CONSUME);
  8804. player->SetCharSheetChanged(true);
  8805. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  8806. if (flag == 1)
  8807. client->Message(CHANNEL_NARRATIVE, "You decide to drink immediately whenever you become thirsty.");
  8808. else
  8809. {
  8810. client->Message(CHANNEL_NARRATIVE, "You decide to ignore the thirst.");
  8811. return;
  8812. }
  8813. }
  8814. if(!client->CheckConsumptionAllowed(slot, false))
  8815. return;
  8816. Item* item = player->GetEquipmentList()->GetItem(slot);
  8817. if(item)
  8818. client->ConsumeFoodDrink(item, slot);
  8819. }
  8820. }
  8821. /*
  8822. Function: Command_Toggle_BonusXP()
  8823. Purpose : Toggles player Bonus XP
  8824. Params :
  8825. Dev : John Adams
  8826. Example : /disable_char_bonus_exp
  8827. */
  8828. void Commands::Command_Toggle_BonusXP(Client* client)
  8829. {
  8830. Player* player = client->GetPlayer();
  8831. player->toggle_character_flag(CF2_CHARACTER_BONUS_EXPERIENCE_ENABLED);
  8832. player->SetCharSheetChanged(true);
  8833. }
  8834. /*
  8835. Function: Command_Toggle_CombatXP()
  8836. Purpose : Toggles player Adventure XP
  8837. Params :
  8838. Dev : John Adams
  8839. Example : /disable_combat_exp
  8840. */
  8841. void Commands::Command_Toggle_CombatXP(Client* client)
  8842. {
  8843. Player* player = client->GetPlayer();
  8844. player->toggle_character_flag(CF_COMBAT_EXPERIENCE_ENABLED);
  8845. player->SetCharSheetChanged(true);
  8846. }
  8847. /*
  8848. Function: Command_Toggle_GMHide()
  8849. Purpose : Toggles hiding player GM status
  8850. Params :
  8851. Dev : Scatman
  8852. Example : /gm_hide
  8853. */
  8854. void Commands::Command_Toggle_GMHide(Client* client)
  8855. {
  8856. Player* player = client->GetPlayer();
  8857. player->toggle_character_flag(CF_HIDE_STATUS);
  8858. client->Message(CHANNEL_COLOR_YELLOW,"You are %s hiding your GM status.", player->get_character_flag(CF_HIDE_STATUS)?"now":"no longer");
  8859. }
  8860. /*
  8861. Function: Command_Toggle_GMVanish()
  8862. Purpose : Toggles hiding GM players from /who searches
  8863. Params :
  8864. Dev : Scatman
  8865. Example : /gm_vanish
  8866. */
  8867. void Commands::Command_Toggle_GMVanish(Client* client)
  8868. {
  8869. Player* player = client->GetPlayer();
  8870. player->toggle_character_flag(CF_GM_HIDDEN);
  8871. client->Message(CHANNEL_COLOR_YELLOW,"You are %s invisible to who queries.", player->get_character_flag(CF_GM_HIDDEN)?"now":"no longer");
  8872. }
  8873. /*
  8874. Function: Command_Toggle_Illusions()
  8875. Purpose : Toggles player illusion form
  8876. Params : not sure sep is needed, testing
  8877. Dev : paulgh
  8878. Example : /hide_illusions
  8879. */
  8880. void Commands::Command_Toggle_Illusions(Client* client, Seperator* sep)
  8881. {
  8882. if (sep && sep->arg[0])
  8883. PrintSep(sep, "COMMAND_TOGGLE_ILLUSIONS");
  8884. client->GetPlayer()->toggle_character_flag(CF_SHOW_ILLUSION);
  8885. }
  8886. /*
  8887. Function: Command_Toggle_LFG()
  8888. Purpose : Toggles player LFG Flag
  8889. Params :
  8890. Dev : paulgh
  8891. Example : /lfg
  8892. */
  8893. void Commands::Command_Toggle_LFG(Client* client)
  8894. {
  8895. Player* player = client->GetPlayer();
  8896. player->toggle_character_flag(CF_LFG);
  8897. client->Message(CHANNEL_COLOR_YELLOW,"You are %s LFG.", player->get_character_flag(CF_LFG)?"now":"no longer");
  8898. if (player->get_character_flag(CF_LFG))
  8899. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFG);
  8900. else
  8901. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFG);
  8902. }
  8903. /*
  8904. Function: Command_Toggle_LFW()
  8905. Purpose : Toggles player LFW Flag
  8906. Params :
  8907. Dev : paulgh
  8908. Example : /lfw
  8909. */
  8910. void Commands::Command_Toggle_LFW(Client* client)
  8911. {
  8912. Player* player = client->GetPlayer();
  8913. player->toggle_character_flag(CF_LFW);
  8914. client->Message(CHANNEL_COLOR_YELLOW,"You %s looking for work.", player->get_character_flag(CF_LFW)?"let others know you are":"stop");
  8915. if (player->get_character_flag(CF_LFW))
  8916. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFW);
  8917. else
  8918. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFW);
  8919. }
  8920. /*
  8921. Function: Command_Toggle_QuestXP()
  8922. Purpose : Toggles player Quest XP
  8923. Params :
  8924. Dev : John Adams
  8925. Example : /disable_quest_exp
  8926. */
  8927. void Commands::Command_Toggle_QuestXP(Client* client)
  8928. {
  8929. Player* player = client->GetPlayer();
  8930. player->toggle_character_flag(CF_QUEST_EXPERIENCE_ENABLED);
  8931. player->SetCharSheetChanged(true);
  8932. }
  8933. /*
  8934. Function: Command_Toggle_Roleplaying()
  8935. Purpose : Toggles player Roleplaying flag
  8936. Params :
  8937. Dev : paulgh
  8938. Example : /role
  8939. */
  8940. void Commands::Command_Toggle_Roleplaying(Client* client)
  8941. {
  8942. Player* player = client->GetPlayer();
  8943. player->toggle_character_flag(CF_ROLEPLAYING);
  8944. client->Message(CHANNEL_COLOR_YELLOW,"You are %s roleplaying.", player->get_character_flag(CF_ROLEPLAYING)?"now":"no longer");
  8945. if (player->get_character_flag(CF_ROLEPLAYING))
  8946. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ROLEPLAYING);
  8947. else
  8948. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ROLEPLAYING);
  8949. }
  8950. void Commands::Command_Toggle_Duels(Client* client)
  8951. {
  8952. Player* player = client->GetPlayer();
  8953. player->toggle_character_flag(CF_ALLOW_DUEL_INVITES);
  8954. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting duel invites.", player->get_character_flag(CF_ALLOW_DUEL_INVITES)?"now":"no longer");
  8955. }
  8956. void Commands::Command_Toggle_Trades(Client* client)
  8957. {
  8958. Player* player = client->GetPlayer();
  8959. player->toggle_character_flag(CF_ALLOW_TRADE_INVITES);
  8960. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting trade invites.", player->get_character_flag(CF_ALLOW_TRADE_INVITES)?"now":"no longer");
  8961. }
  8962. void Commands::Command_Toggle_Guilds(Client* client)
  8963. {
  8964. Player* player = client->GetPlayer();
  8965. player->toggle_character_flag(CF_ALLOW_GUILD_INVITES);
  8966. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting guild invites.", player->get_character_flag(CF_ALLOW_GUILD_INVITES)?"now":"no longer");
  8967. }
  8968. void Commands::Command_Toggle_Groups(Client* client)
  8969. {
  8970. Player* player = client->GetPlayer();
  8971. player->toggle_character_flag(CF_ALLOW_GROUP_INVITES);
  8972. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting group invites.", player->get_character_flag(CF_ALLOW_GROUP_INVITES)?"now":"no longer");
  8973. }
  8974. void Commands::Command_Toggle_Raids(Client* client)
  8975. {
  8976. Player* player = client->GetPlayer();
  8977. player->toggle_character_flag(CF_ALLOW_RAID_INVITES);
  8978. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting raid invites.", player->get_character_flag(CF_ALLOW_RAID_INVITES)?"now":"no longer");
  8979. }
  8980. void Commands::Command_Toggle_LON(Client* client)
  8981. {
  8982. Player* player = client->GetPlayer();
  8983. player->toggle_character_flag(CF2_ALLOW_LON_INVITES);
  8984. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting LoN invites.", player->get_character_flag(CF2_ALLOW_LON_INVITES)?"now":"no longer");
  8985. }
  8986. void Commands::Command_Toggle_VoiceChat(Client* client)
  8987. {
  8988. Player* player = client->GetPlayer();
  8989. player->toggle_character_flag(CF2_ALLOW_VOICE_INVITES);
  8990. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting voice chat invites.", player->get_character_flag(CF2_ALLOW_VOICE_INVITES)?"now":"no longer");
  8991. }
  8992. /*
  8993. Function: Command_TradeStart()
  8994. Purpose : Starts item/coin trade between players
  8995. Params :
  8996. Dev :
  8997. Example :
  8998. */
  8999. #include "../Trade.h"
  9000. void Commands::Command_TradeStart(Client* client, Seperator* sep)
  9001. {
  9002. PrintSep(sep, "COMMAND_START_TRADE");
  9003. Entity* trader = client->GetPlayer();
  9004. Entity* trader2 = 0;
  9005. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  9006. Spawn* spawn = client->GetPlayer()->GetSpawnWithPlayerID(atoi(sep->arg[0]));
  9007. if (spawn) {
  9008. if (spawn->IsEntity())
  9009. trader2 = (Entity*)spawn;
  9010. }
  9011. }
  9012. else if (client->GetPlayer()->GetTarget()) {
  9013. if (client->GetPlayer()->GetTarget()->IsEntity())
  9014. trader2 = (Entity*)client->GetPlayer()->GetTarget();
  9015. }
  9016. // can only trade with player or bots
  9017. if (trader && trader2) {
  9018. if (trader == trader2) {
  9019. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade with yourself.");
  9020. }
  9021. else if (trader2->IsPlayer() || trader2->IsBot()) {
  9022. LogWrite(PLAYER__ERROR, 0, "Trade", "creating trade");
  9023. if (trader->trade)
  9024. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are already trading.");
  9025. else if (trader2->trade)
  9026. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is already trading.");
  9027. else {
  9028. Trade* trade = new Trade(trader, trader2);
  9029. trader->trade = trade;
  9030. trader2->trade = trade;
  9031. }
  9032. }
  9033. else {
  9034. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can only trade with another player or a bot.");
  9035. }
  9036. }
  9037. else
  9038. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to find target");
  9039. }
  9040. /*
  9041. Function: Command_Track()
  9042. Purpose : Starts/Stops Tracking for a player
  9043. Params :
  9044. Dev : Scatman
  9045. Example : /track
  9046. */
  9047. void Commands::Command_Track(Client* client)
  9048. {
  9049. if (!client->GetPlayer()->GetIsTracking())
  9050. client->GetPlayer()->GetZone()->AddPlayerTracking(client->GetPlayer());
  9051. else
  9052. client->GetPlayer()->GetZone()->RemovePlayerTracking(client->GetPlayer(), TRACKING_STOP);
  9053. }
  9054. /*
  9055. Function: Command_TradeAccept()
  9056. Purpose : Accepts item/coin trade between players
  9057. Params :
  9058. Dev :
  9059. Example :
  9060. */
  9061. void Commands::Command_TradeAccept(Client* client, Seperator* sep)
  9062. {
  9063. PrintSep(sep, "COMMAND_ACCEPT_TRADE");
  9064. Trade* trade = client->GetPlayer()->trade;
  9065. if (trade) {
  9066. bool trade_complete = trade->SetTradeAccepted(client->GetPlayer());
  9067. if (trade_complete)
  9068. safe_delete(trade);
  9069. }
  9070. else
  9071. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  9072. }
  9073. /*
  9074. Function: Command_TradeReject()
  9075. Purpose : Rejects item/coin trade between players
  9076. Params :
  9077. Dev :
  9078. Example :
  9079. */
  9080. void Commands::Command_TradeReject(Client* client, Seperator* sep)
  9081. {
  9082. PrintSep(sep, "COMMAND_REJECT_TRADE");
  9083. Command_TradeCancel(client, sep);
  9084. }
  9085. /*
  9086. Function: Command_TradeCancel()
  9087. Purpose : Cancels item/coin trade between players
  9088. Params :
  9089. Dev :
  9090. Example :
  9091. */
  9092. void Commands::Command_TradeCancel(Client* client, Seperator* sep)
  9093. {
  9094. PrintSep(sep, "COMMAND_CANCEL_TRADE");
  9095. Trade* trade = client->GetPlayer()->trade;
  9096. if (trade) {
  9097. trade->CancelTrade(client->GetPlayer());
  9098. safe_delete(trade);
  9099. }
  9100. else
  9101. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  9102. }
  9103. /*
  9104. Function: Command_TradeSetCoin()
  9105. Purpose : Sets coin trade between players
  9106. Params :
  9107. Dev :
  9108. Example :
  9109. */
  9110. void Commands::Command_TradeSetCoin(Client* client, Seperator* sep)
  9111. {
  9112. PrintSep(sep, "COMMAND_SET_TRADE_COIN");
  9113. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Set Trade Coin");
  9114. client->Message(CHANNEL_COLOR_YELLOW, "You cannot trade with other players (Not Implemented)");
  9115. }
  9116. /*
  9117. Function: Command_TradeAddCoin()
  9118. Purpose : Adds coin to trade between players
  9119. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  9120. Dev :
  9121. Example :
  9122. */
  9123. void Commands::Command_TradeAddCoin(Client* client, Seperator* sep, int handler)
  9124. {
  9125. PrintSep(sep, "COMMAND_ADD_TRADE_{coin type}");
  9126. Trade* trade = client->GetPlayer()->trade;
  9127. if (trade) {
  9128. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  9129. int32 amount = atoi(sep->arg[0]);
  9130. int64 val = 0;
  9131. switch (handler) {
  9132. case COMMAND_ADD_TRADE_COPPER:
  9133. {
  9134. val = amount;
  9135. trade->AddCoinToTrade(client->GetPlayer(), val);
  9136. break;
  9137. }
  9138. case COMMAND_ADD_TRADE_SILVER:
  9139. {
  9140. val = amount * 100;
  9141. trade->AddCoinToTrade(client->GetPlayer(), val);
  9142. break;
  9143. }
  9144. case COMMAND_ADD_TRADE_GOLD:
  9145. {
  9146. val = amount * 10000;
  9147. trade->AddCoinToTrade(client->GetPlayer(), val);
  9148. break;
  9149. }
  9150. case COMMAND_ADD_TRADE_PLAT:
  9151. {
  9152. val = amount * 1000000;
  9153. trade->AddCoinToTrade(client->GetPlayer(), val);
  9154. break;
  9155. }
  9156. default:
  9157. {
  9158. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  9159. break;
  9160. }
  9161. }
  9162. }
  9163. else
  9164. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount.");
  9165. }
  9166. else
  9167. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  9168. }
  9169. /*
  9170. Function: Command_TradeRemoveCoin()
  9171. Purpose : Removes coin from trade between players
  9172. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  9173. Dev :
  9174. Example :
  9175. */
  9176. void Commands::Command_TradeRemoveCoin(Client* client, Seperator* sep, int handler)
  9177. {
  9178. PrintSep(sep, "COMMAND_REMOVE_TRADE_{coin type}");
  9179. Trade* trade = client->GetPlayer()->trade;
  9180. if (trade) {
  9181. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  9182. int32 amount = atoi(sep->arg[0]);
  9183. int64 val = 0;
  9184. switch (handler) {
  9185. case COMMAND_REMOVE_TRADE_COPPER:
  9186. {
  9187. val = amount;
  9188. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  9189. break;
  9190. }
  9191. case COMMAND_REMOVE_TRADE_SILVER:
  9192. {
  9193. val = amount * 100;
  9194. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  9195. break;
  9196. }
  9197. case COMMAND_REMOVE_TRADE_GOLD:
  9198. {
  9199. val = amount * 10000;
  9200. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  9201. break;
  9202. }
  9203. case COMMAND_REMOVE_TRADE_PLAT:
  9204. {
  9205. val = amount * 1000000;
  9206. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  9207. break;
  9208. }
  9209. default:
  9210. {
  9211. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  9212. break;
  9213. }
  9214. }
  9215. }
  9216. else
  9217. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount");
  9218. }
  9219. else
  9220. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  9221. }
  9222. /*
  9223. Function: Command_TradeAddItem()
  9224. Purpose : Adds item to trade between players
  9225. Params :
  9226. Dev :
  9227. Example :
  9228. */
  9229. void Commands::Command_TradeAddItem(Client* client, Seperator* sep)
  9230. {
  9231. PrintSep(sep, "COMMAND_ADD_TRADE_ITEM");
  9232. /*
  9233. arg[0] = item index
  9234. arg[1] = slot
  9235. arg[2] = quantity
  9236. */
  9237. if (!client->GetPlayer()->trade) {
  9238. LogWrite(PLAYER__ERROR, 0, "Trade", "Player is not currently trading.");
  9239. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  9240. return;
  9241. }
  9242. if (sep && sep->IsSet(0) && sep->IsNumber(0) && sep->IsSet(1) && sep->IsNumber(1) && sep->IsSet(2) && sep->IsNumber(2)) {
  9243. Item* item = 0;
  9244. int32 index = atoi(sep->arg[0]);
  9245. item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(index);
  9246. if (item) {
  9247. int8 result = client->GetPlayer()->trade->AddItemToTrade(client->GetPlayer(), item, atoi(sep->arg[2]), atoi(sep->arg[1]));
  9248. if (result == 1)
  9249. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Item is already being traded.");
  9250. else if (result == 2)
  9251. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade NO-TRADE items.");
  9252. else if (result == 3)
  9253. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade HEIRLOOM items.");
  9254. else if (result == 254)
  9255. client->Message(CHANNEL_COLOR_YELLOW, "You are trading with an older client with a %u trade slot restriction...", client->GetPlayer()->trade->MaxSlots());
  9256. else if (result == 255)
  9257. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown error trying to add the item to the trade...");
  9258. }
  9259. else {
  9260. LogWrite(PLAYER__ERROR, 0, "Trade", "Unable to get an item for the player (%s) from the index (%u)", client->GetPlayer()->GetName(), index);
  9261. client->Message(CHANNEL_ERROR, "Unable to find item at index %u", index);
  9262. }
  9263. }
  9264. else
  9265. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  9266. }
  9267. /*
  9268. Function: Command_TradeRemoveItem()
  9269. Purpose : Removes item from trade between players
  9270. Params :
  9271. Dev :
  9272. Example :
  9273. */
  9274. void Commands::Command_TradeRemoveItem(Client* client, Seperator* sep)
  9275. {
  9276. PrintSep(sep, "COMMAND_REMOVE_TRADE_ITEM");
  9277. /*
  9278. arg[0] = trade window slot
  9279. */
  9280. Trade* trade = client->GetPlayer()->trade;
  9281. if (trade) {
  9282. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  9283. trade->RemoveItemFromTrade(client->GetPlayer(), atoi(sep->arg[0]));
  9284. }
  9285. else
  9286. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  9287. }
  9288. else
  9289. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  9290. }
  9291. void Commands::Command_TryOn(Client* client, Seperator* sep)
  9292. {
  9293. Item *item = 0;
  9294. sint32 crc;
  9295. if (sep) {
  9296. // 1096+ sends more info so need to do a version check so older clients (SF) still work
  9297. if (client->GetVersion() < 1096) {
  9298. if (sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2))
  9299. {
  9300. item = master_item_list.GetItem(atoul(sep->arg[1]));
  9301. crc = atol(sep->arg[2]);
  9302. }
  9303. }
  9304. else {
  9305. // From the broker and links in chat
  9306. if (strcmp(sep->arg[0], "crc") == 0) {
  9307. if (sep->IsNumber(2) && sep->IsNumber(3)) {
  9308. item = master_item_list.GetItem(atoul(sep->arg[2]));
  9309. crc = atol(sep->arg[3]);
  9310. }
  9311. }
  9312. // From inventory
  9313. if (strcmp(sep->arg[0], "dbid") == 0) {
  9314. if (sep->IsNumber(2) && sep->IsNumber(4)) {
  9315. item = master_item_list.GetItem(atoul(sep->arg[2]));
  9316. crc = atol(sep->arg[4]);
  9317. }
  9318. }
  9319. }
  9320. if (item)
  9321. client->ShowDressingRoom(item, crc);
  9322. }
  9323. }
  9324. void Commands::Command_JoinChannel(Client * client, Seperator *sep) {
  9325. const char *channel_name, *password = NULL;
  9326. if (sep == NULL || !sep->IsSet(0)) {
  9327. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /joinchannel <channel name> [password]");
  9328. return;
  9329. }
  9330. channel_name = sep->arg[0];
  9331. if (sep->IsSet(1))
  9332. password = sep->arg[1];
  9333. if (!chat.ChannelExists(channel_name) && !chat.CreateChannel(channel_name, password)) {
  9334. client->Message(CHANNEL_COLOR_RED, "Unable to create channel '%s'.", channel_name);
  9335. return;
  9336. }
  9337. if (chat.IsInChannel(client, channel_name)) {
  9338. client->Message(CHANNEL_NARRATIVE, "You are already in '%s'.", channel_name);
  9339. return;
  9340. }
  9341. if (chat.HasPassword(channel_name)) {
  9342. if (password == NULL) {
  9343. client->Message(CHANNEL_NARRATIVE, "Unable to join '%s': That channel is password protected.", channel_name);
  9344. return;
  9345. }
  9346. if (!chat.PasswordMatches(channel_name, password)) {
  9347. client->Message(CHANNEL_NARRATIVE, "Unable to join '%s': The password is not correc.t", channel_name);
  9348. return;
  9349. }
  9350. }
  9351. if (!chat.JoinChannel(client, channel_name))
  9352. client->Message(CHANNEL_COLOR_RED, "There was an internal error preventing you from joining '%s'.", channel_name);
  9353. }
  9354. void Commands::Command_JoinChannelFromLoad(Client * client, Seperator *sep) {
  9355. printf("ScatDebug: Received 'joinfromchannel', using the same function as 'joinchannel' (not sure what the difference is)\n");
  9356. Command_JoinChannel(client, sep);
  9357. }
  9358. void Commands::Command_TellChannel(Client *client, Seperator *sep) {
  9359. if (sep == NULL || !sep->IsSet(0) || !sep->IsSet(1)) {
  9360. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /tellchannel <channel name> <message>");
  9361. PrintSep(sep, "tellchannel");
  9362. return;
  9363. }
  9364. chat.TellChannel(client, sep->arg[0], sep->argplus[1]);
  9365. }
  9366. void Commands::Command_Test(Client* client, EQ2_16BitString* command_parms) {
  9367. Seperator* sep = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  9368. if (sep->IsSet(0)) {
  9369. if (atoi(sep->arg[0]) == 1) {
  9370. PacketStruct* packet2 = configReader.getStruct("WS_SpellGainedMsg", client->GetVersion());
  9371. if (packet2) {
  9372. packet2->setDataByName("spell_type", 2);
  9373. packet2->setDataByName("spell_id", 8308);
  9374. packet2->setDataByName("spell_name", "Sprint");
  9375. packet2->setDataByName("add_silently", 0);
  9376. packet2->setDataByName("tier", 1);
  9377. packet2->setDataByName("blah1", 1);
  9378. packet2->setDataByName("blah2", 1);
  9379. EQ2Packet* outapp = packet2->serialize();
  9380. DumpPacket(outapp);
  9381. client->QueuePacket(outapp);
  9382. safe_delete(packet2);
  9383. }
  9384. }
  9385. else if (atoi(sep->arg[0]) == 2) {
  9386. PacketStruct* packet2 = configReader.getStruct("WS_GuildUpdate", client->GetVersion());
  9387. if (packet2) {
  9388. packet2->setDataByName("guild_name", "Test");
  9389. packet2->setDataByName("guild_motd", "Test MOTD");
  9390. packet2->setDataByName("guild_id", 1234);
  9391. packet2->setDataByName("guild_level", 1);
  9392. packet2->setDataByName("unknown", 2);
  9393. packet2->setDataByName("unknown2", 3);
  9394. packet2->setDataByName("exp_current", 1);
  9395. packet2->setDataByName("exp_to_next_level", 4);
  9396. EQ2Packet* outapp = packet2->serialize();
  9397. DumpPacket(outapp);
  9398. client->QueuePacket(outapp);
  9399. safe_delete(packet2);
  9400. }
  9401. }
  9402. else if (atoi(sep->arg[0]) == 3) {
  9403. PacketStruct* packet2 = configReader.getStruct("WS_JoinGuildNotify", client->GetVersion());
  9404. if (packet2) {
  9405. packet2->setDataByName("guild_id", 1234);
  9406. packet2->setDataByName("character_id", 1);
  9407. packet2->setDataByName("account_id", 2);
  9408. packet2->setDataByName("guild_level", 1);
  9409. packet2->setDataByName("name", "Test");
  9410. packet2->setDataByName("unknown2", 0);
  9411. packet2->setDataByName("unknown3", 1);
  9412. packet2->setDataByName("adventure_class", 6);
  9413. packet2->setDataByName("adventure_level", 7);
  9414. packet2->setDataByName("tradeskill_class", 4);
  9415. packet2->setDataByName("tradeskill_level", 5);
  9416. packet2->setDataByName("rank", 0);
  9417. packet2->setDataByName("member_flags", 2);
  9418. packet2->setDataByName("join_date", 1591112273);
  9419. packet2->setDataByName("guild_status", 2);
  9420. packet2->setDataByName("last_login", 1591132273);
  9421. packet2->setDataByName("recruiter_id", 1);
  9422. packet2->setDataByName("points", 2345);
  9423. packet2->setDataByName("note", "note");
  9424. packet2->setMediumStringByName("officer_note", "O note");
  9425. packet2->setMediumStringByName("zone", "Blah");
  9426. EQ2Packet* outapp = packet2->serialize();
  9427. DumpPacket(outapp);
  9428. client->QueuePacket(outapp);
  9429. safe_delete(packet2);
  9430. }
  9431. }
  9432. else if (atoi(sep->arg[0]) == 5) {
  9433. int16 offset = atoi(sep->arg[1]);
  9434. int32 value1 = atol(sep->arg[2]);
  9435. EQ2Packet* outapp = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion(), offset, value1);
  9436. client->QueuePacket(outapp);
  9437. }
  9438. else if (atoi(sep->arg[0]) == 6) {
  9439. Spawn* spawn = client->GetPlayer()->GetTarget();
  9440. if (!spawn)
  9441. spawn = client->GetPlayer();
  9442. else if (spawn->IsEntity())
  9443. ((Entity*)spawn)->SetSpeed(atof(sep->arg[4]));
  9444. spawn->RunToLocation(atof(sep->arg[1]), atof(sep->arg[2]), atof(sep->arg[3]));
  9445. }
  9446. else if (atoi(sep->arg[0]) == 7) {
  9447. int32 id = 0;
  9448. Spawn* spawn = client->GetCurrentZone()->GetSpawn(7720001);
  9449. if (spawn) {
  9450. spawn->SetX(client->GetPlayer()->GetX() + .5, false);
  9451. spawn->SetY(client->GetPlayer()->GetY(), false);
  9452. spawn->SetZ(client->GetPlayer()->GetZ() + .5, false);
  9453. float heading = client->GetPlayer()->GetHeading() + 180;
  9454. if (heading > 360)
  9455. heading -= 360;
  9456. spawn->SetLevel(5);
  9457. spawn->SetAdventureClass(4);
  9458. spawn->SetHeading(heading, false);
  9459. spawn->SetSpawnOrigX(spawn->GetX());
  9460. spawn->SetSpawnOrigY(spawn->GetY());
  9461. spawn->SetSpawnOrigZ(spawn->GetZ());
  9462. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  9463. spawn->SetLocation(client->GetPlayer()->GetLocation());
  9464. spawn->appearance.targetable = 1;
  9465. if (spawn->IsNPC() && spawn->GetTotalHP() == 0) {
  9466. spawn->SetTotalHP(spawn->GetLevel() * 15);
  9467. spawn->SetHP(spawn->GetTotalHP());
  9468. }
  9469. if (spawn->GetTotalPower() == 0) {
  9470. spawn->SetTotalPower(spawn->GetLevel() * 15);
  9471. spawn->SetPower(spawn->GetTotalPower());
  9472. }
  9473. int16 offset = atoi(sep->arg[1]);
  9474. int32 value1 = atol(sep->arg[2]);
  9475. sprintf(spawn->appearance.name, "Offset %i", offset);
  9476. EQ2Packet* ret = spawn->spawn_serialize(client->GetPlayer(), client->GetVersion(), offset, value1);
  9477. DumpPacket(ret);
  9478. client->QueuePacket(ret);
  9479. }
  9480. }
  9481. else if (atoi(sep->arg[0]) == 8) {
  9482. int32 id = atoi(sep->arg[1]);
  9483. Spawn* spawn = client->GetCurrentZone()->GetSpawn(id);
  9484. if (spawn) {
  9485. spawn->SetX(client->GetPlayer()->GetX() + .5, false);
  9486. spawn->SetY(client->GetPlayer()->GetY(), false);
  9487. spawn->SetZ(client->GetPlayer()->GetZ() + .5, false);
  9488. float heading = client->GetPlayer()->GetHeading() + 180;
  9489. if (heading > 360)
  9490. heading -= 360;
  9491. spawn->SetLevel(5);
  9492. spawn->SetAdventureClass(4);
  9493. spawn->SetHeading(heading, false);
  9494. spawn->SetSpawnOrigX(spawn->GetX());
  9495. spawn->SetSpawnOrigY(spawn->GetY());
  9496. spawn->SetSpawnOrigZ(spawn->GetZ());
  9497. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  9498. spawn->SetLocation(client->GetPlayer()->GetLocation());
  9499. spawn->appearance.targetable = 1;
  9500. if (spawn->IsNPC() && spawn->GetTotalHP() == 0) {
  9501. spawn->SetTotalHP(spawn->GetLevel() * 15);
  9502. spawn->SetHP(spawn->GetTotalHP());
  9503. }
  9504. if (spawn->GetTotalPower() == 0) {
  9505. spawn->SetTotalPower(spawn->GetLevel() * 15);
  9506. spawn->SetPower(spawn->GetTotalPower());
  9507. }
  9508. int16 offset = atoi(sep->arg[2]);
  9509. int16 offset2 = atoi(sep->arg[3]);
  9510. int32 value1 = atol(sep->arg[4]);
  9511. int16 offset3 = 0;
  9512. int16 offset4 = 0;
  9513. int32 value2 = 0;
  9514. if (sep->IsSet(7)) {
  9515. offset3 = atoi(sep->arg[5]);
  9516. offset4 = atoi(sep->arg[6]);
  9517. value2 = atol(sep->arg[7]);
  9518. }
  9519. sprintf(spawn->appearance.name, "Offset %i to %i", offset, offset2);
  9520. spawn->AddPrimaryEntityCommand("attack", 10000, "attack","", 0, 0);
  9521. EQ2Packet* ret = spawn->spawn_serialize(client->GetPlayer(), client->GetVersion(), offset, value1, offset2, offset3, offset4, value2);
  9522. DumpPacket(ret);
  9523. client->QueuePacket(ret);
  9524. }
  9525. }
  9526. else if (atoi(sep->arg[0]) == 9) {
  9527. PacketStruct* packet2 = configReader.getStruct("WS_DeathWindow", client->GetVersion());
  9528. if (packet2) {
  9529. packet2->setArrayLengthByName("location_count", 1);
  9530. packet2->setArrayDataByName("location_ida", 1234);
  9531. packet2->setArrayDataByName("unknown2a", 3);
  9532. packet2->setArrayDataByName("zone_name", "Queen's Colony");
  9533. packet2->setArrayDataByName("location_name", "Myrrin's Tower");
  9534. packet2->setArrayDataByName("distance", 134);
  9535. EQ2Packet* app = packet2->serialize();
  9536. if (sep->IsSet(2)) {
  9537. int8 offset = atoi(sep->arg[1]);
  9538. uchar* ptr2 = app->pBuffer;
  9539. ptr2 += offset;
  9540. if (sep->IsNumber(2)) {
  9541. int32 value1 = atol(sep->arg[2]);
  9542. if (value1 > 0xFFFF)
  9543. memcpy(ptr2, (uchar*)&value1, 4);
  9544. else if (value1 > 0xFF)
  9545. memcpy(ptr2, (uchar*)&value1, 2);
  9546. else
  9547. memcpy(ptr2, (uchar*)&value1, 1);
  9548. }
  9549. else {
  9550. int8 len = strlen(sep->arg[2]);
  9551. memcpy(ptr2, (uchar*)&len, 1);
  9552. ptr2 += 1;
  9553. memcpy(ptr2, sep->arg[2], len);
  9554. }
  9555. }
  9556. DumpPacket(app);
  9557. client->QueuePacket(app);
  9558. safe_delete(packet2);
  9559. }
  9560. }
  9561. else if (atoi(sep->arg[0]) == 10) {
  9562. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalUpdate", client->GetVersion());
  9563. if (packet2) {
  9564. packet2->setArrayLengthByName("num_quests", 1);
  9565. packet2->setArrayDataByName("active", 1);
  9566. packet2->setArrayDataByName("name", "Tasks aboard the Far Journey");
  9567. packet2->setArrayDataByName("quest_type", "Hallmark");
  9568. packet2->setArrayDataByName("quest_zone", "Hallmark");
  9569. packet2->setArrayDataByName("journal_updated", 1);
  9570. packet2->setArrayDataByName("quest_id", 524);
  9571. packet2->setArrayDataByName("day", 19);
  9572. packet2->setArrayDataByName("month", 6);
  9573. packet2->setArrayDataByName("year", 20);
  9574. packet2->setArrayDataByName("level", 2);
  9575. packet2->setArrayDataByName("encounter_level", 4);
  9576. packet2->setArrayDataByName("difficulty", 3);
  9577. packet2->setArrayDataByName("visible", 1);
  9578. packet2->setDataByName("visible_quest_id", 524);
  9579. packet2->setDataByName("player_crc", 2900677088);
  9580. packet2->setDataByName("player_name", "LethalEncounter");
  9581. EQ2Packet* app = packet2->serialize();
  9582. if (sep->IsSet(2)) {
  9583. int8 offset = atoi(sep->arg[1]);
  9584. uchar* ptr2 = app->pBuffer;
  9585. ptr2 += offset;
  9586. if (sep->IsNumber(2)) {
  9587. int32 value1 = atol(sep->arg[2]);
  9588. if (value1 > 0xFFFF)
  9589. memcpy(ptr2, (uchar*)&value1, 4);
  9590. else if (value1 > 0xFF)
  9591. memcpy(ptr2, (uchar*)&value1, 2);
  9592. else
  9593. memcpy(ptr2, (uchar*)&value1, 1);
  9594. }
  9595. else {
  9596. int8 len = strlen(sep->arg[2]);
  9597. memcpy(ptr2, (uchar*)&len, 1);
  9598. ptr2 += 1;
  9599. memcpy(ptr2, sep->arg[2], len);
  9600. }
  9601. }
  9602. DumpPacket(app);
  9603. client->QueuePacket(app);
  9604. safe_delete(packet2);
  9605. }
  9606. }
  9607. else if (atoi(sep->arg[0]) == 11) {
  9608. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalReply", client->GetVersion());
  9609. if (packet2) {
  9610. packet2->setDataByName("quest_id", 524);
  9611. packet2->setDataByName("player_crc", 2900677088);
  9612. packet2->setDataByName("name", "Tasks aboard the Far Journey");
  9613. packet2->setDataByName("description", "I completed all the tasks assigned to me by Captain Varlos aboard the Far Journey");
  9614. packet2->setDataByName("type", "Hallmark");
  9615. packet2->setDataByName("complete_header", "To complete this quest, I must do the following tasks:");
  9616. packet2->setDataByName("day", 19);
  9617. packet2->setDataByName("month", 6);
  9618. packet2->setDataByName("year", 20);
  9619. packet2->setDataByName("level", 1);
  9620. packet2->setDataByName("encounter_level", 1);
  9621. packet2->setDataByName("difficulty", 1);
  9622. packet2->setDataByName("time_obtained", Timer::GetUnixTimeStamp());
  9623. //packet2->setDataByName("timer_start", Timer::GetUnixTimeStamp());
  9624. //packet2->setDataByName("timer_duration", 300);
  9625. //packet2->setDataByName("timer_running", 1);
  9626. packet2->setArrayLengthByName("task_groups_completed", 9);
  9627. packet2->setArrayLengthByName("num_task_groups", 10);
  9628. packet2->setArrayDataByName("task_group", "I spoke to Waulon as Captain Varlos had asked of me.");
  9629. packet2->setArrayDataByName("task_group", "I found Waulon's hat in one of the boxes.", 1);
  9630. packet2->setArrayDataByName("task_group", "I returned Waulon's hat.", 2);
  9631. packet2->setArrayDataByName("task_group", "I have spoken to Ingrid.", 3);
  9632. packet2->setArrayDataByName("task_group", "I purchased a Shard of Luclin.", 4);
  9633. packet2->setArrayDataByName("task_group", "I gave the Shard of Luclin to Ingrid.", 5);
  9634. packet2->setArrayDataByName("task_group", "I have spoken to Captain Varlos.", 6);
  9635. packet2->setArrayDataByName("task_group", "I killed the rats that Captain Varlos requested.", 7);
  9636. packet2->setArrayDataByName("task_group", "Captain Varlos has ordered you to kill the escaped goblin.", 8);
  9637. packet2->setArrayDataByName("task_group", "I killed the escaped goblin.", 9);
  9638. /*packet2->setSubArrayLengthByName("num_tasks", 1);
  9639. packet2->setSubArrayDataByName("task", "I need to talk to Garven Tralk");
  9640. packet2->setSubArrayLengthByName("num_updates", 1);
  9641. packet2->setSubArrayDataByName("update_currentval", 0);
  9642. packet2->setSubArrayDataByName("update_maxval", 1);
  9643. packet2->setSubArrayDataByName("icon", 11);
  9644. */
  9645. packet2->setArrayDataByName("waypoint", 0xFFFFFFFF);
  9646. packet2->setDataByName("journal_updated", 1);
  9647. packet2->setDataByName("bullets", 1);
  9648. EQ2Packet* app = packet2->serialize();
  9649. if (sep->IsSet(2)) {
  9650. int16 offset = atoi(sep->arg[1]);
  9651. uchar* ptr2 = app->pBuffer;
  9652. ptr2 += offset;
  9653. if (sep->IsNumber(2)) {
  9654. int32 value1 = atol(sep->arg[2]);
  9655. if (value1 > 0xFFFF)
  9656. memcpy(ptr2, (uchar*)&value1, 4);
  9657. else if (value1 > 0xFF)
  9658. memcpy(ptr2, (uchar*)&value1, 2);
  9659. else
  9660. memcpy(ptr2, (uchar*)&value1, 1);
  9661. }
  9662. else {
  9663. int16 len = strlen(sep->arg[2]);
  9664. memcpy(ptr2, (uchar*)&len, 2);
  9665. ptr2 += 2;
  9666. memcpy(ptr2, sep->arg[2], len);
  9667. }
  9668. }
  9669. DumpPacket(app);
  9670. client->QueuePacket(app);
  9671. safe_delete(packet2);
  9672. }
  9673. }
  9674. else if (atoi(sep->arg[0]) == 12) {
  9675. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalReply", client->GetVersion());
  9676. if (packet2) {
  9677. packet2->setDataByName("quest_id", 5725);
  9678. packet2->setDataByName("player_crc", 2900677088);
  9679. packet2->setDataByName("name", "Archetype Selection");
  9680. packet2->setDataByName("description", "I have reported my profession to Garven Tralk.");
  9681. packet2->setDataByName("type", "Hallmark");
  9682. packet2->setDataByName("complete_header", "To complete this quest, I must do the following tasks:");
  9683. packet2->setDataByName("day", 19);
  9684. packet2->setDataByName("month", 6);
  9685. packet2->setDataByName("year", 20);
  9686. packet2->setDataByName("level", 2);
  9687. packet2->setDataByName("encounter_level", 4);
  9688. packet2->setDataByName("difficulty", 3);
  9689. packet2->setDataByName("time_obtained", Timer::GetUnixTimeStamp());
  9690. packet2->setDataByName("timer_start", Timer::GetUnixTimeStamp());
  9691. packet2->setDataByName("timer_duration", 300);
  9692. packet2->setDataByName("timer_running", 1);
  9693. packet2->setArrayLengthByName("task_groups_completed", 0);
  9694. packet2->setArrayLengthByName("num_task_groups", 1);
  9695. packet2->setArrayDataByName("task_group", "I need to talk to Garven Tralk");
  9696. packet2->setSubArrayLengthByName("num_tasks", 1);
  9697. packet2->setSubArrayDataByName("task", "I need to talk to Garven Tralk");
  9698. packet2->setSubArrayLengthByName("num_updates", 1);
  9699. packet2->setSubArrayDataByName("update_currentval", 0);
  9700. packet2->setSubArrayDataByName("update_maxval", 1);
  9701. packet2->setSubArrayDataByName("icon", 11);
  9702. packet2->setArrayDataByName("waypoint", 0xFFFFFFFF);
  9703. packet2->setDataByName("journal_updated", 1);
  9704. packet2->setSubstructDataByName("reward_data", "unknown1", 255);
  9705. packet2->setSubstructDataByName("reward_data", "reward", "Quest Reward!");
  9706. packet2->setSubstructDataByName("reward_data", "unknown2", 0x3f);
  9707. packet2->setSubstructDataByName("reward_data", "coin", 150);
  9708. packet2->setSubstructDataByName("reward_data", "status_points", 5);
  9709. packet2->setSubstructDataByName("reward_data", "exp_bonus", 10);
  9710. packet2->setSubstructArrayLengthByName("reward_data", "num_rewards", 1);
  9711. packet2->setSubstructArrayDataByName("reward_data", "reward_id", 123);
  9712. Item* item = master_item_list.GetItem(152755);
  9713. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9714. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, client->GetClientItemPacketOffset());
  9715. /*packet2->setSubstructDataByName("item", "unique_id", 567);
  9716. packet2->setSubstructDataByName("item", "broker_item_id", 0xFFFFFFFFFFFFFFFF);
  9717. packet2->setSubstructDataByName("item", "icon", 0xe7);
  9718. packet2->setSubstructDataByName("item", "tier", 4);
  9719. packet2->setSubstructDataByName("item", "flags", 0x60);
  9720. packet2->setSubstructArrayLengthByName("item", "stat_count", 1);
  9721. packet2->setSubstructDataByName("item", "stat_type", 1);
  9722. packet2->setSubstructDataByName("item", "stat_subtype", 2);
  9723. packet2->setSubstructDataByName("item", "value", 3);
  9724. packet2->setSubstructDataByName("item", "condition", 100);
  9725. packet2->setSubstructDataByName("item", "weight", 1);
  9726. packet2->setSubstructDataByName("item", "skill_req1", 0xacafa99e);
  9727. packet2->setSubstructDataByName("item", "skill_req2", 0xacafa99e);
  9728. packet2->setSubstructDataByName("item", "skill_min", 1);
  9729. packet2->setSubstructArrayLengthByName("item", "class_count", 3);
  9730. packet2->setSubstructDataByName("item", "adventure_class", 1);
  9731. packet2->setSubstructDataByName("item", "adventure_class", 11, 0, 1);
  9732. packet2->setSubstructDataByName("item", "adventure_class", 0x1f, 0, 2);
  9733. packet2->setSubstructDataByName("item", "tradeskill_class", 255);
  9734. packet2->setSubstructDataByName("item", "tradeskill_class", 255, 0, 1);
  9735. packet2->setSubstructDataByName("item", "tradeskill_class", 255, 0, 2);
  9736. packet2->setSubstructDataByName("item", "level", 0x1e);
  9737. packet2->setSubstructDataByName("item", "level", 100, 0, 1);
  9738. packet2->setSubstructDataByName("item", "level", 100, 0, 2);
  9739. packet2->setSubstructDataByName("item_footer", "name", "Footman Gloves");*/
  9740. //packet2->PrintPacket();
  9741. EQ2Packet* app = packet2->serialize();
  9742. if (sep->IsSet(2)) {
  9743. int16 offset = atoi(sep->arg[1]);
  9744. uchar* ptr2 = app->pBuffer;
  9745. ptr2 += offset;
  9746. if (sep->IsNumber(2)) {
  9747. int32 value1 = atol(sep->arg[2]);
  9748. if (value1 > 0xFFFF)
  9749. memcpy(ptr2, (uchar*)&value1, 4);
  9750. else if (value1 > 0xFF)
  9751. memcpy(ptr2, (uchar*)&value1, 2);
  9752. else
  9753. memcpy(ptr2, (uchar*)&value1, 1);
  9754. }
  9755. else {
  9756. int16 len = strlen(sep->arg[2]);
  9757. memcpy(ptr2, (uchar*)&len, 2);
  9758. ptr2 += 2;
  9759. memcpy(ptr2, sep->arg[2], len);
  9760. }
  9761. }
  9762. DumpPacket(app);
  9763. client->QueuePacket(app);
  9764. safe_delete(packet2);
  9765. }
  9766. }
  9767. else if (atoi(sep->arg[0]) == 13) {
  9768. PacketStruct* packet2 = configReader.getStruct("WS_OnScreenMsg", client->GetVersion());
  9769. if (packet2 && sep->IsSet(7)) {
  9770. packet2->setDataByName("unknown", atoi(sep->arg[1]));
  9771. char blah[128];
  9772. sprintf(blah, "\\#6EFF6EYou get better at \12\\#C8FFC8%s\\#6EFF6E! (7/15)", sep->arg[2]);
  9773. packet2->setDataByName("text", blah);
  9774. packet2->setDataByName("message_type", sep->arg[3]);
  9775. packet2->setDataByName("size", atof(sep->arg[4]));
  9776. packet2->setDataByName("red", atoi(sep->arg[5]));
  9777. packet2->setDataByName("green", atoi(sep->arg[6]));
  9778. packet2->setDataByName("blue", atoi(sep->arg[7]));
  9779. EQ2Packet* app = packet2->serialize();
  9780. DumpPacket(app);
  9781. client->QueuePacket(app);
  9782. safe_delete(packet2);
  9783. }
  9784. }
  9785. else if (atoi(sep->arg[0]) == 14) {
  9786. PacketStruct* packet2 = configReader.getStruct("WS_InstructionWindow", client->GetVersion());
  9787. if (packet2 && sep->IsSet(3)) {
  9788. packet2->setDataByName("open_seconds_min", atof(sep->arg[1]));
  9789. packet2->setDataByName("open_seconds_max", atof(sep->arg[2]));
  9790. packet2->setDataByName("voice_sync", atoi(sep->arg[3]));
  9791. 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.");
  9792. packet2->setDataByName("voice", "voiceover/english/narrator/boat_06p_tutorial02/narrator_001_63779ca0.mp3");
  9793. packet2->setArrayLengthByName("num_goals", 1);
  9794. //packet2->setArrayDataByName("goal_text", )
  9795. packet2->setSubArrayLengthByName("num_tasks", 1);
  9796. packet2->setSubArrayDataByName("task_text", "continue");
  9797. packet2->setDataByName("complete_sound", "click");
  9798. packet2->setDataByName("signal", "introduction");
  9799. packet2->setDataByName("voice_key1", 0xcda65173);
  9800. packet2->setDataByName("voice_key2", 0x984bfc6d);
  9801. EQ2Packet* app = packet2->serialize();
  9802. DumpPacket(app);
  9803. client->QueuePacket(app);
  9804. safe_delete(packet2);
  9805. packet2 = configReader.getStruct("WS_ShowWindow", client->GetVersion());
  9806. packet2->setDataByName("window", "MainHUD.StartMenu");
  9807. packet2->setDataByName("show", 1);
  9808. app = packet2->serialize();
  9809. DumpPacket(app);
  9810. client->QueuePacket(app);
  9811. safe_delete(packet2);
  9812. packet2 = configReader.getStruct("WS_FlashWindow", client->GetVersion());
  9813. packet2->setDataByName("window", "MainHUD.StartMenu.help");
  9814. packet2->setDataByName("flash_seconds", 10);
  9815. app = packet2->serialize();
  9816. DumpPacket(app);
  9817. client->QueuePacket(app);
  9818. safe_delete(packet2);
  9819. }
  9820. }
  9821. else if (atoi(sep->arg[0]) == 15) {
  9822. PacketStruct* packet2 = configReader.getStruct("WS_UpdateLoot", client->GetVersion());
  9823. if (packet2) {
  9824. packet2->setArrayLengthByName("loot_count", 1);
  9825. packet2->setArrayDataByName("name", "Test");
  9826. packet2->setArrayDataByName("item_id", 1234);
  9827. packet2->setArrayDataByName("count", 1);
  9828. packet2->setArrayDataByName("icon", 258);
  9829. packet2->setArrayDataByName("ability_id", 0xFFFFFFFF);
  9830. Spawn* spawn = client->GetPlayer()->GetTarget();
  9831. if (spawn)
  9832. packet2->setDataByName("object_id", client->GetPlayer()->GetIDWithPlayerSpawn(spawn));
  9833. packet2->setDataByName("display", 1);
  9834. packet2->setDataByName("loot_type", 1);
  9835. packet2->setDataByName("lotto_timeout", 60);
  9836. EQ2Packet* app = packet2->serialize();
  9837. DumpPacket(app);
  9838. client->QueuePacket(app);
  9839. safe_delete(packet2);
  9840. }
  9841. }
  9842. else if (atoi(sep->arg[0]) == 16 && sep->IsNumber(1)) {
  9843. char blah[32];
  9844. sprintf(blah, "Testing: %i", atoi(sep->arg[1]));
  9845. client->SimpleMessage(atoi(sep->arg[1]), blah);
  9846. }
  9847. else if (atoi(sep->arg[0]) == 17 && sep->IsNumber(2)) {
  9848. if (sep->IsSet(2)) {
  9849. int16 offset = atoi(sep->arg[1]);
  9850. if (sep->IsNumber(2)) {
  9851. int32 value1 = atol(sep->arg[2]);
  9852. client->QueuePacket(client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion(), offset, value1));
  9853. cout << "Sent" << endl;
  9854. }
  9855. }
  9856. }
  9857. else if (atoi(sep->arg[0]) == 18) {
  9858. PacketStruct* packet2 = configReader.getStruct("WS_QuestRewardPackMsg", client->GetVersion());
  9859. if (packet2) {
  9860. packet2->setSubstructDataByName("reward_data", "unknown1", 255);
  9861. packet2->setSubstructDataByName("reward_data", "reward", "Quest Reward!");
  9862. packet2->setSubstructDataByName("reward_data", "max_coin", 0);
  9863. packet2->setSubstructDataByName("reward_data", "text", "Some custom text to mess things up?");
  9864. packet2->setSubstructDataByName("reward_data", "status_points", 5);
  9865. //packet2->setSubstructDataByName("reward_data", "exp_bonus", 10);
  9866. packet2->setSubstructArrayLengthByName("reward_data", "num_rewards", 1);
  9867. Item* item = new Item(master_item_list.GetItem(9357));
  9868. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9869. //item->stack_count = 20;
  9870. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, client->GetClientItemPacketOffset());
  9871. safe_delete(item);
  9872. /*item = new Item(master_item_list.GetItem(36685));
  9873. item->stack_count = 20;
  9874. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9875. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 1, 0, -1);
  9876. safe_delete(item);
  9877. item = master_item_list.GetItem(1414);
  9878. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9879. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 2, 0, -1);
  9880. item = master_item_list.GetItem(75057);
  9881. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9882. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 3, 0, -1);*/
  9883. EQ2Packet* app = packet2->serialize();
  9884. if (sep->IsSet(2)) {
  9885. int16 offset = atoi(sep->arg[1]);
  9886. uchar* ptr2 = app->pBuffer;
  9887. ptr2 += offset;
  9888. if (sep->IsNumber(2)) {
  9889. int32 value1 = atol(sep->arg[2]);
  9890. if (value1 > 0xFFFF)
  9891. memcpy(ptr2, (uchar*)&value1, 4);
  9892. else if (value1 > 0xFF)
  9893. memcpy(ptr2, (uchar*)&value1, 2);
  9894. else
  9895. memcpy(ptr2, (uchar*)&value1, 1);
  9896. }
  9897. else {
  9898. int16 len = strlen(sep->arg[2]);
  9899. memcpy(ptr2, (uchar*)&len, 2);
  9900. ptr2 += 2;
  9901. memcpy(ptr2, sep->arg[2], len);
  9902. }
  9903. }
  9904. DumpPacket(app);
  9905. client->QueuePacket(app);
  9906. safe_delete(packet2);
  9907. }
  9908. }
  9909. else if (atoi(sep->arg[0]) == 19) {
  9910. PacketStruct* packet2 = configReader.getStruct("WS_UpdateLoot", client->GetVersion());
  9911. Spawn* spawn = client->GetPlayer()->GetTarget();
  9912. if (packet2 && spawn) {
  9913. Item* item = master_item_list.GetItem(130053);
  9914. packet2->setArrayLengthByName("loot_count", 1);
  9915. packet2->setArrayDataByName("loot_id", item->details.item_id);
  9916. packet2->setArrayDataByName("unknown2", 1);
  9917. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, 2, true);
  9918. packet2->setDataByName("display", 1);
  9919. packet2->setDataByName("unknown2b", 1);
  9920. packet2->setDataByName("unknown3", 0x3c);
  9921. packet2->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(spawn));
  9922. packet2->PrintPacket();
  9923. EQ2Packet* app = packet2->serialize();
  9924. if (sep->IsSet(2)) {
  9925. int16 offset = atoi(sep->arg[1]);
  9926. int16 offset2 = 0;
  9927. int32 value1 = 0;
  9928. if (sep->IsSet(3)) {
  9929. offset2 = atoi(sep->arg[2]);
  9930. value1 = atol(sep->arg[3]);
  9931. }
  9932. else
  9933. value1 = atol(sep->arg[2]);
  9934. int16 offset3 = 0;
  9935. int16 offset4 = 0;
  9936. int32 value2 = 0;
  9937. if (sep->IsSet(6)) {
  9938. offset3 = atoi(sep->arg[4]);
  9939. offset4 = atoi(sep->arg[5]);
  9940. value2 = atol(sep->arg[6]);
  9941. }
  9942. offset--;
  9943. if (offset2 > 0 && offset2 >= offset) {
  9944. offset2--;
  9945. uchar* ptr2 = app->pBuffer;
  9946. ptr2 += offset;
  9947. for (int i = offset; i <= offset2; i++) {
  9948. if (value1 > 0xFFFF) {
  9949. memcpy(ptr2, (uchar*)&value1, 4);
  9950. i += 3;
  9951. ptr2 += 3;
  9952. }
  9953. else if (value1 > 0xFF) {
  9954. memcpy(ptr2, (uchar*)&value1, 2);
  9955. i++;
  9956. ptr2++;
  9957. }
  9958. else
  9959. memcpy(ptr2, (uchar*)&value1, 1);
  9960. ptr2++;
  9961. }
  9962. }
  9963. if (offset4 > 0 && offset4 >= offset3) {
  9964. offset3--;
  9965. offset4--;
  9966. uchar* ptr2 = app->pBuffer;
  9967. ptr2 += offset3;
  9968. for (int i = offset3; i <= offset4; i++) {
  9969. if (value2 > 0xFFFF) {
  9970. memcpy(ptr2, (uchar*)&value2, 4);
  9971. i += 3;
  9972. ptr2 += 3;
  9973. }
  9974. else if (value2 > 0xFF) {
  9975. memcpy(ptr2, (uchar*)&value2, 2);
  9976. i++;
  9977. ptr2++;
  9978. }
  9979. else
  9980. memcpy(ptr2, (uchar*)&value2, 1);
  9981. ptr2++;
  9982. }
  9983. }
  9984. }
  9985. DumpPacket(app);
  9986. client->QueuePacket(app);
  9987. safe_delete(packet2);
  9988. }
  9989. }
  9990. else if (atoi(sep->arg[0]) == 21) {
  9991. PacketStruct* packet2 = configReader.getStruct("WS_OfferQuest", client->GetVersion());
  9992. if (packet2) {
  9993. packet2->setDataByName("unknown0", 255);
  9994. packet2->setDataByName("reward", "New Quest");
  9995. packet2->setDataByName("title", "Title");
  9996. packet2->setDataByName("description", "description");
  9997. packet2->setDataByName("quest_difficulty", 3);
  9998. packet2->setDataByName("unknown1", 5);
  9999. packet2->setDataByName("level", 3);
  10000. packet2->setDataByName("coin", 150);
  10001. packet2->setDataByName("status_points", 5);
  10002. packet2->setDataByName("exp_bonus", 10);
  10003. packet2->setArrayLengthByName("num_rewards", 1);
  10004. Item* item = new Item(master_item_list.GetItem(36212));
  10005. packet2->setArrayDataByName("reward_id", item->details.item_id);
  10006. item->stack_count = 20;
  10007. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, client->GetClientItemPacketOffset());
  10008. safe_delete(item);
  10009. char accept[35] = { 0 };
  10010. char decline[35] = { 0 };
  10011. sprintf(accept, "q_accept_pending_quest %u", 0);
  10012. sprintf(decline, "q_deny_pending_quest %u", 0);
  10013. packet2->setDataByName("accept_command", accept);
  10014. packet2->setDataByName("decline_command", decline);
  10015. EQ2Packet* app = packet2->serialize();
  10016. if (sep->IsSet(2)) {
  10017. int16 offset = atoi(sep->arg[1]);
  10018. uchar* ptr2 = app->pBuffer;
  10019. ptr2 += offset;
  10020. if (sep->IsNumber(2)) {
  10021. int32 value1 = atol(sep->arg[2]);
  10022. if (value1 > 0xFFFF)
  10023. memcpy(ptr2, (uchar*)&value1, 4);
  10024. else if (value1 > 0xFF)
  10025. memcpy(ptr2, (uchar*)&value1, 2);
  10026. else
  10027. memcpy(ptr2, (uchar*)&value1, 1);
  10028. }
  10029. DumpPacket(app);
  10030. client->QueuePacket(app);
  10031. safe_delete(packet2);
  10032. }
  10033. }
  10034. }
  10035. else if (atoi(sep->arg[0]) == 22) { //same as 21, but 8bit string
  10036. PacketStruct* packet2 = configReader.getStruct("WS_OfferQuest", client->GetVersion());
  10037. if (packet2) {
  10038. packet2->setDataByName("unknown0", 255);
  10039. packet2->setDataByName("reward", "New Quest");
  10040. packet2->setDataByName("title", "Title");
  10041. packet2->setDataByName("description", "description");
  10042. packet2->setDataByName("quest_difficulty", 3);
  10043. packet2->setDataByName("unknown1", 5);
  10044. packet2->setDataByName("level", 3);
  10045. packet2->setDataByName("coin", 150);
  10046. packet2->setDataByName("status_points", 5);
  10047. packet2->setDataByName("exp_bonus", 10);
  10048. packet2->setArrayLengthByName("num_rewards", 1);
  10049. Item* item = new Item(master_item_list.GetItem(36212));
  10050. packet2->setArrayDataByName("reward_id", item->details.item_id);
  10051. item->stack_count = 20;
  10052. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, client->GetClientItemPacketOffset());
  10053. safe_delete(item);
  10054. char accept[35] = { 0 };
  10055. char decline[35] = { 0 };
  10056. sprintf(accept, "q_accept_pending_quest %u", 0);
  10057. sprintf(decline, "q_deny_pending_quest %u", 0);
  10058. packet2->setDataByName("accept_command", accept);
  10059. packet2->setDataByName("decline_command", decline);
  10060. EQ2Packet* app = packet2->serialize();
  10061. if (sep->IsSet(2)) {
  10062. int16 offset = atoi(sep->arg[1]);
  10063. uchar* ptr2 = app->pBuffer;
  10064. ptr2 += offset;
  10065. if (sep->IsNumber(2)) {
  10066. int32 value1 = atol(sep->arg[2]);
  10067. if (value1 > 0xFFFF)
  10068. memcpy(ptr2, (uchar*)&value1, 4);
  10069. else if (value1 > 0xFF)
  10070. memcpy(ptr2, (uchar*)&value1, 2);
  10071. else
  10072. memcpy(ptr2, (uchar*)&value1, 1);
  10073. }
  10074. else {
  10075. int8 len = strlen(sep->arg[2]);
  10076. memcpy(ptr2, (uchar*)&len, 1);
  10077. ptr2 += 1;
  10078. memcpy(ptr2, sep->arg[2], len);
  10079. }
  10080. }
  10081. DumpPacket(app);
  10082. client->QueuePacket(app);
  10083. safe_delete(packet2);
  10084. }
  10085. }
  10086. else if (atoi(sep->arg[0]) == 23) {
  10087. if (client->GetPlayer()->GetTarget()) {
  10088. PacketStruct* packet2 = configReader.getStruct("WS_UpdateMerchant", client->GetVersion());
  10089. if (packet2) {
  10090. Spawn* target = client->GetPlayer()->GetTarget();
  10091. packet2->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(target));
  10092. Item* item = new Item(master_item_list.GetItem(12565));
  10093. int8 i = 0;
  10094. packet2->setArrayLengthByName("num_items", 1);
  10095. packet2->setArrayDataByName("item_name", item->name.c_str(), i);
  10096. packet2->setArrayDataByName("item_id", item->details.item_id, i);
  10097. packet2->setArrayDataByName("stack_size", item->stack_count, i);
  10098. packet2->setArrayDataByName("icon", item->GetIcon(client->GetVersion()), i);
  10099. int8 tmp_level = 0;
  10100. if (item->generic_info.adventure_default_level > 0)
  10101. tmp_level = item->generic_info.adventure_default_level;
  10102. else
  10103. tmp_level = item->generic_info.tradeskill_default_level;
  10104. packet2->setArrayDataByName("level", tmp_level, i);
  10105. packet2->setArrayDataByName("tier", item->details.tier, i);
  10106. packet2->setArrayDataByName("item_id2", item->details.item_id, i);
  10107. int8 item_difficulty = client->GetPlayer()->GetArrowColor(tmp_level);
  10108. if (item_difficulty != ARROW_COLOR_WHITE && item_difficulty != ARROW_COLOR_RED && item_difficulty != ARROW_COLOR_GRAY)
  10109. item_difficulty = ARROW_COLOR_WHITE;
  10110. item_difficulty -= 6;
  10111. if (item_difficulty < 0)
  10112. item_difficulty *= -1;
  10113. packet2->setArrayDataByName("item_difficulty", item_difficulty, i);
  10114. packet2->setArrayDataByName("quantity", 2, i);
  10115. packet2->setArrayDataByName("unknown5", 255, i);
  10116. packet2->setArrayDataByName("stack_size2", item->stack_count, i);
  10117. packet2->setArrayDataByName("description", item->description.c_str(), i);
  10118. packet2->setDataByName("type", 2);
  10119. EQ2Packet* app = packet2->serialize();
  10120. if (sep->IsSet(2)) {
  10121. int16 offset = atoi(sep->arg[1]);
  10122. uchar* ptr2 = app->pBuffer;
  10123. ptr2 += offset;
  10124. if (sep->IsNumber(2)) {
  10125. int32 value1 = atol(sep->arg[2]);
  10126. if (value1 > 0xFFFF)
  10127. memcpy(ptr2, (uchar*)&value1, 4);
  10128. else if (value1 > 0xFF)
  10129. memcpy(ptr2, (uchar*)&value1, 2);
  10130. else
  10131. memcpy(ptr2, (uchar*)&value1, 1);
  10132. }
  10133. else {
  10134. int8 len = strlen(sep->arg[2]);
  10135. memcpy(ptr2, (uchar*)&len, 1);
  10136. ptr2 += 1;
  10137. memcpy(ptr2, sep->arg[2], len);
  10138. }
  10139. }
  10140. DumpPacket(app);
  10141. client->QueuePacket(app);
  10142. safe_delete(packet2);
  10143. }
  10144. }
  10145. }
  10146. else if (atoi(sep->arg[0]) == 24) {
  10147. PacketStruct* packet2 = configReader.getStruct("WS_EnableGameEvent", client->GetVersion());
  10148. if (packet2) {
  10149. if (sep->IsSet(2)) {
  10150. packet2->setDataByName("event_name", sep->arg[1]);
  10151. packet2->setDataByName("enabled", atoi(sep->arg[2]));
  10152. EQ2Packet* app = packet2->serialize();
  10153. DumpPacket(app);
  10154. client->QueuePacket(app);
  10155. safe_delete(packet2);
  10156. }
  10157. }
  10158. }
  10159. else if (atoi(sep->arg[0]) == 25) {
  10160. if (sep->IsSet(1)) {
  10161. Widget* new_spawn = new Widget();
  10162. int32 id = atoul(sep->arg[1]);
  10163. new_spawn->SetWidgetID(id);
  10164. EQ2Packet* ret = new_spawn->serialize(client->GetPlayer(), client->GetVersion());
  10165. client->QueuePacket(ret);
  10166. int8 index = client->GetPlayer()->GetIndexForSpawn(new_spawn);
  10167. PacketStruct* packet2 = configReader.getStruct("WS_DestroyGhostCmd", client->GetVersion());
  10168. if (packet2) {
  10169. packet2->setDataByName("spawn_index", index);
  10170. packet2->setDataByName("delete", 1);
  10171. EQ2Packet* app = packet2->serialize();
  10172. client->QueuePacket(app);
  10173. safe_delete(packet2);
  10174. }
  10175. }
  10176. }
  10177. else if (atoi(sep->arg[0]) == 26) {
  10178. if (sep->IsSet(4)) {
  10179. Widget* new_spawn = new Widget();
  10180. int32 id = atoul(sep->arg[1]);
  10181. new_spawn->SetWidgetID(id);
  10182. float x = atof(sep->arg[2]);
  10183. float y = atof(sep->arg[3]);
  10184. float z = atof(sep->arg[4]);
  10185. new_spawn->SetLocation(client->GetPlayer()->GetLocation());
  10186. new_spawn->SetWidgetX(x);
  10187. new_spawn->SetWidgetY(y);
  10188. new_spawn->SetWidgetZ(z);
  10189. new_spawn->SetX(x);
  10190. new_spawn->SetY(y);
  10191. new_spawn->SetZ(z);
  10192. EQ2Packet* ret = new_spawn->serialize(client->GetPlayer(), client->GetVersion());
  10193. client->QueuePacket(ret);
  10194. }
  10195. }
  10196. else if (atoi(sep->arg[0]) == 27) {
  10197. Spawn* target = client->GetPlayer()->GetTarget();
  10198. PacketStruct* packet2 = configReader.getStruct("WS_HearSimpleDamage", client->GetVersion());
  10199. if (packet2 && target && sep->IsSet(4)) {
  10200. 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] : "");
  10201. }
  10202. }
  10203. else if (atoi(sep->arg[0]) == 28 && sep->IsNumber(1)) {
  10204. World::newValue = strtoull(sep->arg[1], NULL, 0);
  10205. }
  10206. else if (atoi(sep->arg[0]) == 29 && sep->IsNumber(1)) {
  10207. client->SendHearCast(client->GetPlayer(), client->GetPlayer()->GetTarget() ? client->GetPlayer()->GetTarget() : client->GetPlayer(),
  10208. strtoull(sep->arg[1], NULL, 0), atoul(sep->arg[2]));
  10209. }
  10210. else if (atoi(sep->arg[0]) == 30) {
  10211. PacketStruct* packet = configReader.getStruct("WS_UpdateSkillBook", client->GetVersion());
  10212. if (packet) {
  10213. packet->setDataByName("unknown", World::newValue);
  10214. EQ2Packet* outapp = packet->serialize();
  10215. DumpPacket(outapp);
  10216. client->QueuePacket(outapp);
  10217. safe_delete(packet);
  10218. }
  10219. }
  10220. else if (atoi(sep->arg[0]) == 31) {
  10221. client->SendRecipeList();
  10222. }
  10223. else if (atoi(sep->arg[0]) == 32 && sep->IsNumber(1) && sep->IsNumber(2)) {
  10224. if(client->GetVersion() <= 561) {
  10225. int32 param = atoul(sep->arg[1]);
  10226. int32 paramvalue = atoul(sep->arg[2]);
  10227. client->Message(CHANNEL_COLOR_YELLOW, "Send control flag param %u param value %u", param, paramvalue);
  10228. ClientPacketFunctions::SendServerControlFlagsClassic(client, param, paramvalue);
  10229. }
  10230. else if(sep->IsNumber(3)) {
  10231. int8 param1 = atoul(sep->arg[1]);
  10232. int8 param2 = atoul(sep->arg[2]);
  10233. int8 paramval = atoul(sep->arg[3]);
  10234. client->Message(CHANNEL_COLOR_YELLOW, "Send control flag param1 %u param2 %u param value %u", param1, param2, paramval);
  10235. ClientPacketFunctions::SendServerControlFlags(client, param1, param2, paramval);
  10236. }
  10237. }
  10238. else if (atoi(sep->arg[0]) == 33 && sep->IsNumber(1) && sep->IsNumber(2)) {
  10239. client->GetCurrentZone()->SendHealPacket(client->GetPlayer(), client->GetPlayer()->GetTarget() ? client->GetPlayer()->GetTarget() : client->GetPlayer(),
  10240. atoul(sep->arg[1]), atoul(sep->arg[2]), "TestSpell");
  10241. }
  10242. else if(atoi(sep->arg[0]) == 34 && sep->IsNumber(1) && sep->IsNumber(2)) {
  10243. PacketStruct* packet = configReader.getStruct("WS_QuestRewardPackMsg", client->GetVersion());
  10244. packet->setSubstructDataByName("reward_data", "unknown1", atoi(sep->arg[1]));
  10245. Item* item = master_item_list.GetItem(atoul(sep->arg[2]));
  10246. if(item) {
  10247. packet->setSubstructArrayLengthByName("reward_data", "num_select_rewards", 1);
  10248. packet->setArrayDataByName("select_reward_id", item->details.item_id, 0);
  10249. packet->setItemArrayDataByName("select_item", item, client->GetPlayer(), 0, 0, World::newValue - 2);
  10250. }
  10251. client->QueuePacket(packet->serialize());
  10252. safe_delete(packet);
  10253. }
  10254. else if(atoi(sep->arg[0]) == 35) {
  10255. if(client->GetPlayer()->GetGroupMemberInfo() && client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  10256. Entity* target = (Entity*)client->GetPlayer()->GetTarget();
  10257. if(target->GetGroupMemberInfo()) {
  10258. PlayerGroup* group = world.GetGroupManager()->GetGroup(client->GetPlayer()->GetGroupMemberInfo()->group_id);
  10259. PlayerGroup* group2 = world.GetGroupManager()->GetGroup(target->GetGroupMemberInfo()->group_id);
  10260. if(group && group2) {
  10261. group->AddGroupToRaid(group2->GetID());
  10262. group2->AddGroupToRaid(group->GetID());
  10263. }
  10264. }
  10265. }
  10266. }
  10267. else if(atoi(sep->arg[0]) == 36) {
  10268. EQ2Packet* packet = client->GetPlayer()->GetRaidUpdatePacket(client->GetVersion());
  10269. if(packet) {
  10270. client->QueuePacket(packet);
  10271. }
  10272. }
  10273. else if(atoi(sep->arg[0]) == 37) {
  10274. Guild* guild = client->GetPlayer()->GetGuild();
  10275. if(guild)
  10276. guild->SendGuildMemberList();
  10277. }
  10278. }
  10279. else {
  10280. PacketStruct* packet2 = configReader.getStruct("WS_ExaminePartialSpellInfo", client->GetVersion());
  10281. if (packet2) {
  10282. packet2->setSubstructDataByName("info_header", "show_name", 1);
  10283. packet2->setSubstructDataByName("info_header", "unknown", 7);
  10284. packet2->setSubstructDataByName("info_header", "unknown2", 1);
  10285. packet2->setSubstructDataByName("info_header", "unknown3", 1);
  10286. packet2->setSubstructDataByName("info_header", "unknown4", 1);
  10287. packet2->setSubstructDataByName("info_header", "unknown5", 1);
  10288. packet2->setSubstructDataByName("info_header", "unknown6", "Testing");
  10289. packet2->setSubstructDataByName("info_header", "unknown7", "Testing");
  10290. packet2->setSubstructDataByName("info_header", "unknown8", 66);
  10291. packet2->setSubstructDataByName("info_header", "title", "Blah Title Blah");
  10292. packet2->setSubstructDataByName("info_header", "title_text", "Blah Blah");
  10293. packet2->setSubstructDataByName("info_header", "title_text2", "Blah Blah2");
  10294. packet2->setSubstructDataByName("info_header", "show_popup", 1);
  10295. packet2->setSubstructDataByName("info_header", "packettype", 3);
  10296. packet2->setSubstructDataByName("spell_info", "skill_name", "Testing");
  10297. packet2->setSubstructDataByName("spell_info", "level", 19);
  10298. packet2->setSubstructDataByName("spell_info", "tier", 1);
  10299. packet2->setSubstructDataByName("spell_info", "health_cost", 5);
  10300. packet2->setSubstructDataByName("spell_info", "min_class_skill_req", 3);
  10301. packet2->setSubstructDataByName("spell_info", "mana_cost", 6);
  10302. packet2->setSubstructDataByName("spell_info", "req_concentration", 7);
  10303. packet2->setSubstructDataByName("spell_info", "cast_time", 200);
  10304. packet2->setSubstructDataByName("spell_info", "recovery", 220);
  10305. packet2->setSubstructDataByName("spell_info", "recast", 280);
  10306. packet2->setSubstructDataByName("spell_info", "beneficial", 1);
  10307. packet2->setSubstructDataByName("spell_info", "maintained", 1);
  10308. packet2->setSubstructDataByName("spell_info", "spell_book_type", 1);
  10309. packet2->setSubstructDataByName("spell_info", "quality", 3);
  10310. packet2->setSubstructDataByName("spell_info", "test_1a", 1);
  10311. packet2->setSubstructDataByName("spell_info", "test_1b", 1);
  10312. packet2->setSubstructDataByName("spell_info", "test_1c", 1);
  10313. packet2->setSubstructDataByName("spell_info", "test_1d", 1);
  10314. packet2->setSubstructDataByName("spell_info", "test_2a", 2);
  10315. packet2->setSubstructDataByName("spell_info", "test_2b", 2);
  10316. packet2->setSubstructDataByName("spell_info", "test_2c", 2);
  10317. packet2->setSubstructDataByName("spell_info", "test_2d", 2);
  10318. packet2->setSubstructDataByName("spell_info", "test_3", 3);
  10319. packet2->setSubstructDataByName("spell_info", "test_4", 4);
  10320. packet2->setSubstructDataByName("spell_info", "test_5", 5);
  10321. packet2->setSubstructDataByName("spell_info", "test_6", 6);
  10322. packet2->setSubstructDataByName("spell_info", "min_class_skill_req", 1);
  10323. packet2->setSubstructDataByName("spell_info", "min_class_skill_rec", 30123);
  10324. packet2->setSubstructDataByName("spell_info", "num_reagents", 1);
  10325. packet2->setSubstructArrayLengthByName("spell_info", "num_reagents", 1);
  10326. packet2->setArrayDataByName("reagent", "Alcohol");
  10327. packet2->setArrayDataByName("consumed", "123");
  10328. packet2->setSubstructDataByName("spell_info", "class_skill", 52);
  10329. packet2->setSubstructDataByName("spell_info", "id", 8308);
  10330. packet2->setSubstructDataByName("spell_info", "icon", 303);
  10331. packet2->setSubstructDataByName("spell_info", "icon2", 0xFFFF);
  10332. packet2->setSubstructDataByName("spell_info", "icontype", 317);
  10333. packet2->setSubstructDataByName("spell_info", "type", 2);
  10334. packet2->setSubstructDataByName("spell_info", "spell_text_color", 255);
  10335. packet2->setSubstructDataByName("spell_info", "duration1", 600);
  10336. packet2->setSubstructDataByName("spell_info", "duration2", 600);
  10337. packet2->setSubstructDataByName("spell_info", "name", "Sprint");
  10338. packet2->setSubstructDataByName("spell_info", "description", "Test description");
  10339. EQ2Packet* outapp = packet2->serialize();
  10340. DumpPacket(outapp);
  10341. client->QueuePacket(outapp);
  10342. safe_delete(packet2);
  10343. }
  10344. }
  10345. return;
  10346. PacketStruct* p = configReader.getStruct("WS_EqTargetItemCmd", client->GetVersion());
  10347. if (!p) return;
  10348. //Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  10349. //client->GetCurrentZone()->SendSpellFailedPacket(client, atoi(sep2->arg[0]));
  10350. //}
  10351. /*Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  10352. if (sep2 && sep2->arg[0] && sep2->IsNumber(0)) {
  10353. client->SetPendingFlightPath(atoi(sep2->arg[0]));
  10354. PacketStruct* packet = configReader.getStruct("WS_ReadyForTakeOff", client->GetVersion());
  10355. if (packet) {
  10356. client->QueuePacket(packet->serialize());
  10357. safe_delete(packet);
  10358. }
  10359. }*/
  10360. /*if (client->GetCurrentZone()->Grid != nullptr) {
  10361. int32 numFaces = 0;
  10362. int32 numGrids = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.size();
  10363. client->Message(CHANNEL_COLOR_YELLOW, "Num grids in cell: %u", numGrids);
  10364. map<int32, vector<Face*> >::iterator itr;
  10365. for (itr = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.begin(); itr != client->GetPlayer()->Cell_Info.CurrentCell->FaceList.end(); itr++)
  10366. numFaces += (*itr).second.size();
  10367. client->Message(CHANNEL_COLOR_YELLOW, "Num faces in cell: %u", numFaces);
  10368. }*/
  10369. //uchar blah[] = {
  10370. // 1208 - OP_EQUpdateStoreCmd
  10371. // /*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
  10372. // /*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
  10373. // 1193 - -- OP_ClientCmdMsg::OP_EqUpdateMerchantCmd --
  10374. // /*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
  10375. /*};
  10376. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  10377. int8 val = 0;
  10378. int16 pos = 0;
  10379. int idx = 0;
  10380. while(sep2 && sep2->arg[idx+1] && sep2->IsNumber(idx) && sep2->IsNumber(idx+1)){
  10381. pos = atoi(sep2->arg[idx]);
  10382. val = atoi(sep2->arg[idx+1]);
  10383. memset(blah+pos, val, 1);
  10384. idx+=2;
  10385. }
  10386. DumpPacket(blah, sizeof(blah));
  10387. client->QueuePacket(new EQ2Packet(OP_GroupCreatedMsg , blah, sizeof(blah)));*/
  10388. if (client->GetPlayer()->GetTarget()) {
  10389. PacketStruct* packet = configReader.getStruct("WS_SetControlGhost", client->GetVersion());
  10390. if (packet) {
  10391. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  10392. packet->setDataByName("size", 0);
  10393. packet->setDataByName("unknown2", 0);
  10394. EQ2Packet* app = packet->serialize();
  10395. client->QueuePacket(app);
  10396. safe_delete(packet);
  10397. }
  10398. PacketStruct* set_pov = configReader.getStruct("WS_SetPOVGhostCmd", client->GetVersion());
  10399. if (set_pov) {
  10400. set_pov->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  10401. EQ2Packet* app_pov = set_pov->serialize();
  10402. client->QueuePacket(app_pov);
  10403. safe_delete(set_pov);
  10404. }
  10405. }
  10406. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  10407. PacketStruct* packet = configReader.getStruct("WS_OpenCharCust", client->GetVersion());
  10408. if (packet) {
  10409. if (sep2 && sep2->arg[0] && sep2->IsNumber(0))
  10410. packet->setDataByName("Type", atoi(sep2->arg[0]));
  10411. else
  10412. packet->setDataByName("Type", 2);
  10413. if (sep2 && sep2->arg[1] && sep2->IsNumber(1))
  10414. packet->setDataByName("race_id", atoi(sep2->arg[1]));
  10415. else
  10416. packet->setDataByName("race_id", 0);
  10417. if (sep2 && sep2->arg[2] && sep2->IsNumber(2))
  10418. packet->setDataByName("gender", atoi(sep2->arg[2]));
  10419. else
  10420. packet->setDataByName("gender", 2);
  10421. if (sep2 && sep2->arg[3] && sep2->IsNumber(3))
  10422. packet->setDataByName("unknown", atoi(sep2->arg[3]), 0);
  10423. else
  10424. packet->setDataByName("unknown", 0, 0);
  10425. if (sep2 && sep2->arg[4] && sep2->IsNumber(4))
  10426. packet->setDataByName("unknown", atoi(sep2->arg[4]), 1);
  10427. else
  10428. packet->setDataByName("unknown", 0, 1);
  10429. if (sep2 && sep2->arg[5] && sep2->IsNumber(5))
  10430. packet->setDataByName("unknown", atoi(sep2->arg[5]), 2);
  10431. else
  10432. packet->setDataByName("unknown", 0, 2);
  10433. client->QueuePacket(packet->serialize());
  10434. }
  10435. safe_delete(packet);
  10436. safe_delete(sep2);
  10437. }
  10438. void Commands::Command_LeaveChannel(Client *client, Seperator *sep) {
  10439. const char *channel_name;
  10440. if (sep == NULL || !sep->IsSet(0)) {
  10441. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /leavechat <channel name>");
  10442. PrintSep(sep);
  10443. return;
  10444. }
  10445. channel_name = sep->arg[0];
  10446. if (!chat.IsInChannel(client, channel_name))
  10447. client->Message(CHANNEL_NARRATIVE, "Unable to leave '%s': You are not in the channel.", channel_name);
  10448. else if (!chat.LeaveChannel(client, channel_name))
  10449. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an internal error preventing you from leaving that channel MUAHAHA");
  10450. }
  10451. /*
  10452. Function:
  10453. Purpose :
  10454. Params :
  10455. Dev :
  10456. Example :
  10457. */
  10458. void Commands::Command_WeaponStats(Client* client)
  10459. {
  10460. Player* player = client->GetPlayer();
  10461. Spawn* target = player->GetTarget();
  10462. Item* primary = player->GetEquipmentList()->GetItem(EQ2_PRIMARY_SLOT);
  10463. Item* secondary = player->GetEquipmentList()->GetItem(EQ2_SECONDARY_SLOT);
  10464. Item* ranged = player->GetEquipmentList()->GetItem(EQ2_RANGE_SLOT);
  10465. const char* charName = player->GetName();
  10466. if(target && target->IsEntity()) {
  10467. primary = ((Entity*)target)->GetEquipmentList()->GetItem(EQ2_PRIMARY_SLOT);
  10468. secondary = ((Entity*)target)->GetEquipmentList()->GetItem(EQ2_SECONDARY_SLOT);
  10469. ranged = ((Entity*)target)->GetEquipmentList()->GetItem(EQ2_RANGE_SLOT);
  10470. charName = target->GetName();
  10471. }
  10472. else {
  10473. target = nullptr;
  10474. }
  10475. client->Message(0, "WeaponStats for %s", charName);
  10476. client->SimpleMessage(0, "Primary:");
  10477. if (primary) {
  10478. client->Message(0, "Name: %s", primary->name.c_str());
  10479. client->Message(0, "Base Damage: %u - %u", primary->weapon_info->damage_low3, primary->weapon_info->damage_high3);
  10480. client->Message(0, "Mastery Damage: %u - %u", primary->weapon_info->damage_low2, primary->weapon_info->damage_high2);
  10481. client->Message(0, "Damage: %u - %u", primary->weapon_info->damage_low1, primary->weapon_info->damage_high1);
  10482. client->Message(0, "Actual Damage: %u - %u", target ? ((Entity*)target)->GetPrimaryWeaponMinDamage() : player->GetPrimaryWeaponMinDamage(),
  10483. target ? ((Entity*)target)->GetPrimaryWeaponMaxDamage() : player->GetPrimaryWeaponMaxDamage());
  10484. client->Message(0, "Actual Delay: %u", target ? ((Entity*)target)->GetPrimaryWeaponDelay() : player->GetPrimaryWeaponDelay());
  10485. client->Message(0, "Proc Percent: %d%%", 0);
  10486. client->Message(0, "Procs Per Minute: %d", 0);
  10487. }
  10488. else {
  10489. client->SimpleMessage(0, "Name: fist");
  10490. client->Message(0, "Base Damage: %u - %u", target ? ((Entity*)target)->GetPrimaryWeaponMinDamage() : player->GetPrimaryWeaponMinDamage(),
  10491. target ? ((Entity*)target)->GetPrimaryWeaponMaxDamage() : player->GetPrimaryWeaponMaxDamage());
  10492. client->Message(0, "Actual Damage: %u - %u", target ? ((Entity*)target)->GetPrimaryWeaponMinDamage() : player->GetPrimaryWeaponMinDamage(),
  10493. target ? ((Entity*)target)->GetPrimaryWeaponMaxDamage() : player->GetPrimaryWeaponMaxDamage());
  10494. client->Message(0, "Actual Delay: %d", target ? ((Entity*)target)->GetPrimaryWeaponDelay() : player->GetPrimaryWeaponDelay() * 0.1);
  10495. client->Message(0, "Proc Percent: %d%%", 0);
  10496. client->Message(0, "Procs Per Minute: %d", 0);
  10497. }
  10498. client->SimpleMessage(0, " ");
  10499. client->SimpleMessage(0, " ");
  10500. if (secondary) {
  10501. client->SimpleMessage(0, "Secondary:");
  10502. client->Message(0, "Name: %s", secondary->name.c_str());
  10503. client->Message(0, "Base Damage: %u - %u", secondary->weapon_info->damage_low3, secondary->weapon_info->damage_high3);
  10504. client->Message(0, "Mastery Damage: %u - %u", secondary->weapon_info->damage_low2, secondary->weapon_info->damage_high2);
  10505. client->Message(0, "Damage: %u - %u", secondary->weapon_info->damage_low1, secondary->weapon_info->damage_high1);
  10506. client->Message(0, "Actual Damage: %u - %u", target ? ((Entity*)target)->GetSecondaryWeaponMinDamage() : player->GetSecondaryWeaponMinDamage(),
  10507. target ? ((Entity*)target)->GetSecondaryWeaponMaxDamage() : player->GetSecondaryWeaponMaxDamage());
  10508. client->Message(0, "Actual Delay: %d", target ? ((Entity*)target)->GetSecondaryWeaponDelay() : player->GetSecondaryWeaponDelay() * 0.1);
  10509. client->Message(0, "Proc Percent: %d%%", 0);
  10510. client->Message(0, "Procs Per Minute: %d", 0);
  10511. client->SimpleMessage(0, " ");
  10512. client->SimpleMessage(0, " ");
  10513. }
  10514. client->SimpleMessage(0, "Ranged:");
  10515. if (ranged) {
  10516. client->Message(0, "Name: %s", ranged->name.c_str());
  10517. client->Message(0, "Base Damage: %u - %u", ranged->ranged_info->weapon_info.damage_low3, ranged->ranged_info->weapon_info.damage_high3);
  10518. client->Message(0, "Mastery Damage: %u - %u", ranged->ranged_info->weapon_info.damage_low2, ranged->ranged_info->weapon_info.damage_high2);
  10519. client->Message(0, "Damage: %u - %u", ranged->ranged_info->weapon_info.damage_low1, ranged->ranged_info->weapon_info.damage_high1);
  10520. client->Message(0, "Actual Damage: %u - %u", target ? ((Entity*)target)->GetRangedWeaponMinDamage() : player->GetRangedWeaponMinDamage(),
  10521. target ? ((Entity*)target)->GetRangedWeaponMaxDamage() : player->GetRangedWeaponMaxDamage());
  10522. client->Message(0, "Actual Delay: %d", target ? ((Entity*)target)->GetRangeWeaponDelay() : player->GetRangeWeaponDelay() * 0.1);
  10523. client->Message(0, "Proc Percent: %d%%", 0);
  10524. client->Message(0, "Procs Per Minute: %d", 0);
  10525. }
  10526. else
  10527. client->SimpleMessage(0, "None");
  10528. }
  10529. void Commands::Command_WhoChannel(Client *client, Seperator *sep) {
  10530. const char *channel_name;
  10531. if (sep == NULL || !sep->IsSet(0)) {
  10532. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /chatwho <channel name>");
  10533. return;
  10534. }
  10535. channel_name = sep->arg[0];
  10536. if (!chat.ChannelExists(channel_name))
  10537. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That channel does not exist!");
  10538. else
  10539. chat.SendChannelUserList(client, channel_name);
  10540. }
  10541. void Commands::Command_ZoneSafeCoords(Client *client, Seperator *sep)
  10542. {
  10543. ZoneServer* zone = 0;
  10544. int32 zone_id = client->GetPlayer()->GetZone()->GetZoneID();
  10545. if (zone_id > 0)
  10546. {
  10547. ZoneChangeDetails zone_details;
  10548. if(zone_list.GetZone(&zone_details, zone_id, "", false, false, false)) {
  10549. zone = (ZoneServer*)zone_details.zonePtr;
  10550. }
  10551. if (zone)
  10552. {
  10553. zone->SetSafeX(client->GetPlayer()->GetX());
  10554. zone->SetSafeY(client->GetPlayer()->GetY());
  10555. zone->SetSafeZ(client->GetPlayer()->GetZ());
  10556. zone->SetSafeHeading(client->GetPlayer()->GetHeading());
  10557. if( database.SaveZoneSafeCoords(zone_id, zone->GetSafeX(), zone->GetSafeY(), zone->GetSafeZ(), zone->GetSafeHeading()) )
  10558. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Zone safe coordinates updated!");
  10559. else
  10560. client->SimpleMessage(CHANNEL_COLOR_RED, "FAILED to update zone safe coordinates!");
  10561. }
  10562. }
  10563. }
  10564. /*
  10565. Function:
  10566. Purpose :
  10567. Params :
  10568. Dev :
  10569. Example :
  10570. */
  10571. void Commands::Command_ZoneDetails(Client* client, Seperator* sep)
  10572. {
  10573. ZoneInfo* zone_info = new ZoneInfo;
  10574. if (sep && sep->arg[0])
  10575. {
  10576. if (sep->IsNumber(0))
  10577. zone_info->id = atoi(sep->arg[0]);
  10578. else
  10579. zone_info->id = database.GetZoneID(sep->arg[0]);
  10580. if (zone_info->id > 0)
  10581. {
  10582. database.LoadZoneInfo(zone_info);
  10583. 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);
  10584. 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);
  10585. 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);
  10586. 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);
  10587. 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);
  10588. 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);
  10589. 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);
  10590. client->Message(CHANNEL_COLOR_YELLOW, "zone_type: %s, sky_file: %s", zone_info->zone_type, zone_info->sky_file);
  10591. client->Message(CHANNEL_COLOR_YELLOW, "lua_script: %s", zone_info->lua_script);
  10592. client->Message(CHANNEL_COLOR_YELLOW, "zone_motd: %s", zone_info->zone_motd);
  10593. }
  10594. else
  10595. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  10596. }
  10597. else
  10598. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone details [zone id|zone name]");
  10599. safe_delete(zone_info);
  10600. }
  10601. /*
  10602. Function:
  10603. Purpose :
  10604. Params :
  10605. Dev :
  10606. Example :
  10607. */
  10608. void Commands::Command_ZoneSet(Client* client, Seperator* sep)
  10609. {
  10610. if (sep && sep->arg[0] && sep->arg[1] && sep->arg[2])
  10611. {
  10612. ZoneServer* zone = 0;
  10613. int32 zone_id = 0;
  10614. ZoneChangeDetails zone_details;
  10615. if (sep->IsNumber(0) && atoi(sep->arg[0]) > 0)
  10616. {
  10617. zone_id = atoul(sep->arg[0]);
  10618. if(zone_list.GetZone(&zone_details, zone_id, "", false, false, false, false)) {
  10619. zone = (ZoneServer*)zone_details.zonePtr;
  10620. }
  10621. }
  10622. else
  10623. {
  10624. zone_id = database.GetZoneID(sep->arg[0]);
  10625. if(zone_list.GetZone(&zone_details, zone_id, "", false, false, false, false)) {
  10626. zone = (ZoneServer*)zone_details.zonePtr;
  10627. }
  10628. }
  10629. if (zone_id > 0)
  10630. {
  10631. if (zone_set_values.count(string(sep->arg[1])) > 0)
  10632. SetZoneCommand(client, zone_id, zone, zone_set_values[sep->arg[1]], sep->arg[2]);
  10633. else
  10634. client->Message(CHANNEL_COLOR_YELLOW, "The attribute '%s' is not valid.", sep->arg[1]);
  10635. }
  10636. else
  10637. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  10638. }
  10639. else
  10640. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone set [zone id|zone name] [attribute] [value]");
  10641. }
  10642. void Commands::Command_Rain(Client* client, Seperator* sep) {
  10643. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  10644. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /rain <float>");
  10645. return;
  10646. }
  10647. client->Message(CHANNEL_COLOR_YELLOW,"Setting rain to %.2f", atof(sep->arg[0]));
  10648. client->GetCurrentZone()->SetRain(atof(sep->arg[0]));
  10649. client->GetCurrentZone()->SetCurrentWeather(atof(sep->arg[0]));
  10650. }
  10651. void Commands::Command_Wind(Client* client, Seperator* sep) {
  10652. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  10653. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /wind <float>");
  10654. return;
  10655. }
  10656. client->Message(CHANNEL_COLOR_YELLOW, "Setting wind to %.2f", atof(sep->arg[0]));
  10657. client->GetCurrentZone()->SetWind(atof(sep->arg[0]));
  10658. }
  10659. void Commands::Command_SendMerchantWindow(Client* client, Seperator* sep, bool sell) {
  10660. Spawn* spawn = client->GetPlayer()->GetTarget();
  10661. if(client->GetVersion() < 561) {
  10662. sell = false; // doesn't support in the same way as AoM just open the normal buy/sell window
  10663. }
  10664. if(spawn) {
  10665. client->SetMerchantTransaction(spawn);
  10666. if (spawn->GetMerchantID() > 0 && spawn->IsClientInMerchantLevelRange(client)){
  10667. client->SendHailCommand(spawn);
  10668. //MerchantFactionMultiplier* multiplier = world.GetMerchantMultiplier(spawn->GetMerchantID());
  10669. //if(!multiplier || (multiplier && client->GetPlayer()->GetFactions()->GetFactionValue(multiplier->faction_id) >= multiplier->faction_min)){
  10670. client->SendBuyMerchantList(sell);
  10671. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY))
  10672. client->SendSellMerchantList(sell);
  10673. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY_BACK))
  10674. client->SendBuyBackList(sell);
  10675. if(client->GetVersion() > 561) {
  10676. PacketStruct* packet = configReader.getStruct("WS_UpdateMerchant", client->GetVersion());
  10677. if (packet) {
  10678. packet->setDataByName("spawn_id", 0xFFFFFFFF);
  10679. packet->setDataByName("type", 16);
  10680. EQ2Packet* outapp = packet->serialize();
  10681. if (outapp)
  10682. client->QueuePacket(outapp);
  10683. safe_delete(packet);
  10684. }
  10685. }
  10686. }
  10687. if (spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR)
  10688. client->SendRepairList();
  10689. }
  10690. // client->SimpleMessage(CHANNEL_COLOR_RED, "Your faction is too low to use this merchant.");
  10691. }
  10692. void Commands::Command_Weather(Client* client, Seperator* sep)
  10693. {
  10694. //PrintSep(sep, "Weather");
  10695. if( sep && sep->arg[0] )
  10696. {
  10697. ZoneServer* zsZone = client->GetCurrentZone();
  10698. const char* value = sep->arg[0];
  10699. // process single-param commands first
  10700. if( strncasecmp(value, "details", strlen(value)) == 0 )
  10701. {
  10702. client->Message(CHANNEL_COLOR_YELLOW, "Weather Details for zone %s: ", zsZone->GetZoneName());
  10703. client->Message(CHANNEL_COLOR_YELLOW, "enabled: %i, allowed: %i, type: %i, frequency: %u", zsZone->isWeatherEnabled(), zsZone->isWeatherAllowed(), zsZone->GetWeatherType(), zsZone->GetWeatherFrequency());
  10704. client->Message(CHANNEL_COLOR_YELLOW, "severity: %.2f = %.2f, current: %.2f", zsZone->GetWeatherMinSeverity(), zsZone->GetWeatherMaxSeverity(), zsZone->GetCurrentWeather());
  10705. client->Message(CHANNEL_COLOR_YELLOW, "pattern: %i, chance: %i, amount: %.2f, offset: %.2f", zsZone->GetWeatherPattern(), zsZone->GetWeatherChance(), zsZone->GetWeatherChangeAmount(), zsZone->GetWeatherDynamicOffset());
  10706. }
  10707. else if( strncasecmp(value, "process", strlen(value)) == 0 )
  10708. {
  10709. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  10710. zsZone->ProcessWeather();
  10711. }
  10712. else if( strncasecmp(value, "reset", strlen(value)) == 0 )
  10713. {
  10714. zsZone->SetWeatherType(rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Zone, WeatherType)->GetInt8());
  10715. zsZone->SetWeatherFrequency(rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Zone, WeatherChangeFrequency)->GetInt32());
  10716. zsZone->SetWeatherMinSeverity(rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Zone, MinWeatherSeverity)->GetFloat());
  10717. zsZone->SetWeatherMaxSeverity(rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Zone, MaxWeatherSeverity)->GetFloat());
  10718. zsZone->SetCurrentWeather(zsZone->GetWeatherMinSeverity());
  10719. zsZone->SetWeatherPattern(1);
  10720. zsZone->SetWeatherChance(rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Zone, WeatherChangeChance)->GetInt8());
  10721. zsZone->SetWeatherChangeAmount(rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Zone, WeatherChangePerInterval)->GetFloat());
  10722. zsZone->SetWeatherDynamicOffset(rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Zone, WeatherDynamicMaxOffset)->GetFloat());
  10723. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  10724. zsZone->ProcessWeather();
  10725. }
  10726. // process commands with params
  10727. if( sep->arg[1] )
  10728. {
  10729. if( strncasecmp(value, "enable", strlen(value)) == 0 && sep->IsNumber(1) )
  10730. zsZone->SetWeatherEnabled( ( atoi(sep->arg[1]) == 1 ) ? true : false );
  10731. else if( strncasecmp(value, "type", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 3) )
  10732. zsZone->SetWeatherType(atoi(sep->arg[1]));
  10733. else if( strncasecmp(value, "frequency", strlen(value)) == 0 && sep->IsNumber(1))
  10734. zsZone->SetWeatherFrequency( atoul(sep->arg[1]) );
  10735. else if( strncasecmp(value, "range", strlen(value)) == 0 && sep->IsNumber(1) && sep->IsNumber(2) ) {
  10736. zsZone->SetWeatherMinSeverity(atof(sep->arg[1]));
  10737. zsZone->SetWeatherMaxSeverity(atof(sep->arg[2]));
  10738. zsZone->SetRain(zsZone->GetWeatherMinSeverity());
  10739. }
  10740. else if( strncasecmp(value, "current", strlen(value)) == 0 && sep->IsNumber(1) ) {
  10741. zsZone->SetCurrentWeather(atof(sep->arg[1]));
  10742. zsZone->SetRain(zsZone->GetCurrentWeather());
  10743. }
  10744. else if( strncasecmp(value, "pattern", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 2) )
  10745. zsZone->SetWeatherPattern( atoi(sep->arg[1]) );
  10746. else if( strncasecmp(value, "chance", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 100) )
  10747. zsZone->SetWeatherChance( atoi(sep->arg[1]) );
  10748. else if( strncasecmp(value, "amount", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  10749. zsZone->SetWeatherChangeAmount( atof(sep->arg[1]) );
  10750. else if( strncasecmp(value, "offset", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  10751. zsZone->SetWeatherDynamicOffset( atof(sep->arg[1]) );
  10752. }
  10753. }
  10754. else
  10755. {
  10756. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /weather [command] [param]");
  10757. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: enable (0|1), type (0-3), frequency (sec), range|current (0.0 - 1.0)");
  10758. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: details, process, pattern (0|1), chance (%), amount (float), offset (float)");
  10759. return;
  10760. }
  10761. }
  10762. void Commands::Command_Select(Client* client, Seperator* sep) {
  10763. if (sep && sep->arg[1]) {
  10764. Spawn* spawn = client->GetPlayer()->GetTarget();
  10765. if (spawn && strlen(sep->arg[1]) > 0)
  10766. client->GetCurrentZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_CUSTOM, client->GetPlayer(), sep->arg[1]);
  10767. }
  10768. }
  10769. /*
  10770. Function: Command_ConsumeFood()
  10771. Purpose : Consume Food/Drink and apply mods
  10772. Params : Slot ID - EQ2_FOOD_SLOT 22, EQ2_DRINK_SLOT 23
  10773. Dev : Zcoretri
  10774. Example : /consume_food 22
  10775. */
  10776. void Commands::Command_ConsumeFood(Client* client, Seperator* sep) {
  10777. if (sep && sep->arg[0] && sep->IsNumber(0))
  10778. {
  10779. Player* player = client->GetPlayer();
  10780. int32 slot = atoul(sep->arg[0]);
  10781. if (client->GetVersion() <= 373) {
  10782. if(client->GetVersion() <= 561) {
  10783. if(slot <= 255) {
  10784. slot = 255 - slot;
  10785. }
  10786. else {
  10787. if(slot == 256) { // first "new" item to inventory is assigned index 256 by client
  10788. slot = client->GetPlayer()->item_list.GetFirstNewItem();
  10789. }
  10790. else {
  10791. // otherwise the slot has to be mapped out depending on the amount of new items + index sent in
  10792. slot = client->GetPlayer()->item_list.GetNewItemByIndex((int16)slot - 255);
  10793. }
  10794. }
  10795. }
  10796. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(slot);
  10797. if(item && item->IsFood()) {
  10798. if(client->CheckConsumptionAllowed(slot)) {
  10799. if(item->IsFoodFood())
  10800. slot = EQ2_FOOD_SLOT;
  10801. else if(item->IsFoodDrink())
  10802. slot = EQ2_DRINK_SLOT;
  10803. else
  10804. return; // not valid item
  10805. client->ConsumeFoodDrink(item, slot);
  10806. }
  10807. }
  10808. }
  10809. else {
  10810. if (client->GetVersion() > 373 && client->GetVersion() <= 561) {
  10811. slot += 2;
  10812. }
  10813. Item* item = player->GetEquipmentList()->GetItem(slot);
  10814. if(client->CheckConsumptionAllowed(slot)) {
  10815. client->ConsumeFoodDrink(item, slot);
  10816. }
  10817. }
  10818. }
  10819. }
  10820. void Commands::Command_Aquaman(Client* client, Seperator* sep) {
  10821. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  10822. if (atoi(sep->arg[0]) == 1) {
  10823. client->GetPlayer()->GetInfoStruct()->set_vision(4);
  10824. client->GetPlayer()->GetInfoStruct()->set_breathe_underwater(1);
  10825. client->GetPlayer()->SetCharSheetChanged(true);
  10826. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Maybe you ought to stick to the shallow end until you know how to swim.");
  10827. }
  10828. else {
  10829. client->GetPlayer()->GetInfoStruct()->set_vision(0);
  10830. client->GetPlayer()->GetInfoStruct()->set_breathe_underwater(0);
  10831. client->GetPlayer()->SetCharSheetChanged(true);
  10832. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Aquaman mode turned off.");
  10833. }
  10834. }
  10835. else
  10836. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /aquaman [0|1]");
  10837. }
  10838. void Commands::Command_ReportBug(Client* client, Seperator* sep)
  10839. {
  10840. if(sep)
  10841. {
  10842. string data;
  10843. if(sep->arg[0]){
  10844. data = string(sep->arg[0]);
  10845. }
  10846. for(int i=1;i<sep->GetMaxArgNum();i++){
  10847. if(sep->arg[i])
  10848. data.append(" ").append(sep->arg[i]);
  10849. }
  10850. if(!sep->IsSet(7)){
  10851. data.append(" ").append(std::to_string(client->GetVersion())).append("\a");
  10852. }
  10853. const char* target_name = 0;
  10854. int32 spawn_id = 0;
  10855. if(client->GetPlayer()->GetTarget())
  10856. {
  10857. target_name = client->GetPlayer()->GetTarget()->GetName();
  10858. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  10859. }
  10860. else
  10861. target_name = "N/A";
  10862. LogWrite(COMMAND__DEBUG, 1, "Command", "%s", data.c_str());
  10863. if(world.ReportBug(data, client->GetPlayer()->GetName(), client->GetAccountID(), target_name, spawn_id, client->GetCurrentZone()->GetZoneID()))
  10864. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully submitted bug.");
  10865. else
  10866. client->SimpleMessage(CHANNEL_COLOR_RED, "Error submitting bug.");
  10867. }
  10868. }
  10869. void Commands::Command_Attune_Inv(Client* client, Seperator* sep) {
  10870. PrintSep(sep, "Command_Attune_Inv");
  10871. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  10872. // Get the item index from the first parameter
  10873. int16 index = atoi(sep->arg[0]);
  10874. // Check to see if this is a valid item index for the player, if not exit out of the function
  10875. if (client->GetPlayer()->item_list.indexed_items.count(index) == 0) {
  10876. LogWrite(ITEM__DEBUG, 0, "Items", "%s has no item with an index of %i", client->GetPlayer()->GetName(), index);
  10877. return;
  10878. }
  10879. // Get the item
  10880. Item* item = client->GetPlayer()->item_list.indexed_items[index];
  10881. if(item) {
  10882. // Valid item lets check to make sure this item is attunable, if not return out
  10883. if (!item->CheckFlag(ATTUNEABLE)) {
  10884. LogWrite(ITEM__DEBUG, 0, "Items", "attune_inv called for an item that is not attunable (%s)", item->name.c_str());
  10885. return;
  10886. }
  10887. // Remove the attunable flag
  10888. item->generic_info.item_flags -= ATTUNEABLE;
  10889. // Set the attuned flag
  10890. item->generic_info.item_flags += ATTUNED;
  10891. // Flag this item for saving
  10892. item->save_needed = true;
  10893. client->QueuePacket(item->serialize(client->GetVersion(), false, client->GetPlayer()));
  10894. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), 0, -1); // appearance type??
  10895. EQ2Packet* outapp = 0;
  10896. for (int32 i=0;i<packets.size();i++) {
  10897. outapp = packets[i];
  10898. if(outapp)
  10899. client->QueuePacket(outapp);
  10900. }
  10901. }
  10902. }
  10903. }
  10904. void Commands::Command_Reset_Zone_Timer(Client* client, Seperator* sep) {
  10905. PrintSep(sep, "Command_Reset_Zone_Timer");
  10906. /*if (sep && sep->arg[0] && sep->IsNumber(0)) {
  10907. int32 db_id = atoul(sep->arg[0]);
  10908. InstanceData* data = client->GetPlayer()->GetCharacterInstances().FindInstanceByDBID(db_id);
  10909. if (data) {
  10910. // TODO: add a check to timers to ensure it can be reset
  10911. // Delete the character from the instance
  10912. database.DeleteCharacterFromInstance(client->GetPlayer()->GetCharacterID(), data->instance_id);
  10913. data->instance_id = 0;
  10914. // Update the success time and set to 0 so the player can enter it again
  10915. database.UpdateCharacterInstance(client->GetPlayer()->GetCharacterID(), data->zone_name, 0, 1, 0);
  10916. data->last_success_timestamp = 0;
  10917. }
  10918. }*/
  10919. }
  10920. void Commands::Command_Player(Client* client, Seperator* sep) {
  10921. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player syntax --");
  10922. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins");
  10923. }
  10924. void Commands::Command_Player_Coins(Client* client, Seperator* sep) {
  10925. // /player coins add 10
  10926. // /player coins add plat 10
  10927. Player* player = client->GetPlayer();
  10928. Client* targetClient = client;
  10929. if (player->HasTarget() && player->GetTarget()->IsPlayer()) {
  10930. player = (Player*)player->GetTarget();
  10931. targetClient = player->GetClient();
  10932. }
  10933. if (sep && sep->arg[0] && sep->arg[1]) {
  10934. const char* action = sep->arg[0];
  10935. int64 value = 0;
  10936. if (strncasecmp(action, "add", strlen(action)) == 0) {
  10937. if (sep->IsNumber(1)) {
  10938. value = atoi64(sep->arg[1]);
  10939. player->AddCoins(value);
  10940. if (client->GetPlayer() == player)
  10941. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  10942. else {
  10943. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  10944. if(targetClient) {
  10945. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  10946. }
  10947. }
  10948. return;
  10949. }
  10950. else if (sep->arg[2] && sep->IsNumber(2)) {
  10951. const char* type = sep->arg[1];
  10952. if (strncasecmp(type, "copper", strlen(type)) == 0) {
  10953. value = atoi64(sep->arg[2]);
  10954. }
  10955. else if (strncasecmp(type, "silver", strlen(type)) == 0) {
  10956. value = atoi64(sep->arg[2]) * 100;
  10957. }
  10958. else if (strncasecmp(type, "gold", strlen(type)) == 0) {
  10959. value = atoi64(sep->arg[2]) * 10000;
  10960. }
  10961. else if (strncasecmp(type, "plat", strlen(type)) == 0) {
  10962. value = atoi64(sep->arg[2]) * 1000000;
  10963. }
  10964. player->AddCoins(value);
  10965. if (client->GetPlayer() == player)
  10966. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  10967. else {
  10968. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  10969. if(targetClient) {
  10970. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  10971. }
  10972. }
  10973. return;
  10974. }
  10975. }
  10976. }
  10977. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player coins syntax --");
  10978. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add [value] - adds the given number of coins to the player");
  10979. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add copper [value] - adds the given amount of copper to the player");
  10980. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add silver [value] - adds the given amount of silver to the player");
  10981. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add gold [value] - adds the given amount of gold to the player");
  10982. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add plat [value] - adds the given amount of platinum to the player");
  10983. }
  10984. void Commands::Command_AchievementAdd(Client* client, Seperator* sep) {
  10985. PrintSep(sep, "ACHIEVEMENT_ADD");
  10986. if (sep && sep->IsSet(0)) {
  10987. int32 spell_id = atoul(sep->arg[1]);
  10988. int8 spell_tier = 0;
  10989. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  10990. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  10991. // addspellbookentry here
  10992. if (spell_tier >= data->maxRank) {
  10993. return;
  10994. }
  10995. if (!spell_tier) {
  10996. spell_tier = 1;
  10997. }
  10998. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  10999. {
  11000. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  11001. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  11002. client->GetPlayer()->UnlockSpell(spell);
  11003. client->SendSpellUpdate(spell);
  11004. }
  11005. else
  11006. {
  11007. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1);
  11008. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  11009. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  11010. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  11011. client->GetPlayer()->UnlockSpell(spell);
  11012. client->SendSpellUpdate(spell);
  11013. }
  11014. // cast spell here
  11015. if (!spell_tier)
  11016. spell_tier = 1;
  11017. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  11018. if (spell) {
  11019. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  11020. }
  11021. }
  11022. else {
  11023. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  11024. }
  11025. if(client->GetVersion() > 561)
  11026. master_aa_list.DisplayAA(client, 0, 0);
  11027. }
  11028. void Commands::Command_Editor(Client* client, Seperator* sep) {
  11029. PacketStruct* packet = configReader.getStruct("WS_ChoiceWindow", client->GetVersion());
  11030. if (packet) {
  11031. string url = string(rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_World, EditorURL)->GetString());
  11032. if (rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_World, EditorOfficialServer)->GetBool()) {
  11033. char command[255];
  11034. url = "browser " + url;
  11035. int32 spawn_id = 0;
  11036. int32 zone_id = 0;
  11037. string type;
  11038. if (client->GetCurrentZone())
  11039. zone_id = client->GetCurrentZone()->GetZoneID();
  11040. if (client->GetPlayer()->GetTarget()) {
  11041. Spawn* target = client->GetPlayer()->GetTarget();
  11042. if (target->IsWidget())
  11043. type = "widgets";
  11044. else if (target->IsSign())
  11045. type = "signs";
  11046. else if (target->IsObject())
  11047. type = "objects";
  11048. else if (target->IsNPC())
  11049. type = "npcs";
  11050. else if (target->IsGroundSpawn())
  11051. type = "ground";
  11052. else
  11053. type = "spawn";
  11054. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  11055. }
  11056. sprintf(command, url.c_str(), zone_id, type.c_str(), spawn_id);
  11057. packet->setDataByName("accept_command", command);
  11058. }
  11059. else if (rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_World, EditorIncludeID)->GetBool()) {
  11060. char command[255];
  11061. url = "browser " + url;
  11062. if (client->GetPlayer()->GetTarget())
  11063. sprintf(command, url.c_str(), client->GetPlayer()->GetTarget()->GetDatabaseID());
  11064. packet->setDataByName("accept_command", command);
  11065. }
  11066. else {
  11067. string command = "browser " + url;
  11068. packet->setDataByName("accept_command", command.c_str());
  11069. }
  11070. packet->setDataByName("text", "Open the web editor?");
  11071. packet->setDataByName("accept_text", "Open");
  11072. packet->setDataByName("cancel_text", "Cancel");
  11073. // No clue if we even need the following 2 unknowns, just added them so the packet matches what live sends
  11074. packet->setDataByName("unknown2", 50);
  11075. packet->setDataByName("unknown4", 1);
  11076. client->QueuePacket(packet->serialize());
  11077. safe_delete(packet);
  11078. }
  11079. }
  11080. void Commands::Command_AcceptResurrection(Client* client, Seperator* sep) {
  11081. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  11082. return;
  11083. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  11084. if(client->GetCurrentRez()->active)
  11085. client->AcceptResurrection();
  11086. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  11087. }
  11088. void Commands::Command_DeclineResurrection(Client* client, Seperator* sep) {
  11089. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  11090. return;
  11091. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  11092. if(client->GetCurrentRez()->active)
  11093. client->GetCurrentRez()->should_delete = true;
  11094. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  11095. }
  11096. void Commands::Switch_AA_Profile(Client* client, Seperator* sep) {
  11097. PrintSep(sep, "Switch_AA_Profile");
  11098. if (sep && sep->IsSet(0)) {
  11099. string type = sep->arg[0];
  11100. int8 newtemplate = atoul(sep->arg[1]);
  11101. if(client->GetVersion() > 561)
  11102. master_aa_list.DisplayAA(client, newtemplate, 1);
  11103. }
  11104. }
  11105. void Commands::Get_AA_Xml(Client* client, Seperator* sep) {
  11106. PrintSep(sep, "Get_AA_Xml");
  11107. if (sep && sep->IsSet(0)) {
  11108. string tabnum = sep->arg[0];
  11109. string spellid = sep->arg[1];
  11110. }
  11111. }
  11112. void Commands::Add_AA(Client* client, Seperator* sep) {
  11113. PrintSep(sep, "Add_AA");
  11114. if (sep && sep->IsSet(0)) {
  11115. int32 spell_id = atoul(sep->arg[1]);
  11116. int8 spell_tier = 0;
  11117. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  11118. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  11119. // addspellbookentry here
  11120. if(!data) {
  11121. LogWrite(COMMAND__ERROR, 0, "Command", "Error in Add_AA no data for spell_id %u spell_tier %u", spell_id, spell_tier);
  11122. return;
  11123. }
  11124. if (spell_tier >= data->maxRank) {
  11125. LogWrite(COMMAND__ERROR, 0, "Command", "Error in Add_AA spell_tier %u >= maxRank %u", spell_tier, data->maxRank);
  11126. return;
  11127. }
  11128. if (!spell_tier) {
  11129. spell_tier = 1;
  11130. }
  11131. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  11132. {
  11133. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  11134. if(spell)
  11135. {
  11136. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  11137. client->GetPlayer()->UnlockSpell(spell);
  11138. client->SendSpellUpdate(spell);
  11139. }
  11140. }
  11141. else
  11142. {
  11143. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1 );
  11144. if(spell)
  11145. {
  11146. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  11147. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  11148. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  11149. client->GetPlayer()->UnlockSpell(spell);
  11150. client->SendSpellUpdate(spell);
  11151. }
  11152. }
  11153. // cast spell here
  11154. if (!spell_tier)
  11155. spell_tier = 1;
  11156. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  11157. if (spell) {
  11158. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  11159. }
  11160. }
  11161. else {
  11162. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  11163. }
  11164. if(client->GetVersion() > 561)
  11165. master_aa_list.DisplayAA(client, 0, 0);
  11166. }
  11167. void Commands::Commit_AA_Profile(Client* client, Seperator* sep) {
  11168. PrintSep(sep, "Commit_AA_Profile");
  11169. if (sep && sep->IsSet(0)) {
  11170. }
  11171. }
  11172. void Commands::Begin_AA_Profile(Client* client, Seperator* sep) {
  11173. PrintSep(sep, "Begin_AA_Profile");
  11174. if (sep && sep->IsSet(0)) {
  11175. if(client->GetVersion() > 561)
  11176. master_aa_list.DisplayAA(client, 100, 2);
  11177. }
  11178. }
  11179. void Commands::Back_AA(Client* client, Seperator* sep) {
  11180. if (sep && sep->IsSet(0)) {
  11181. PrintSep(sep, "Back_AA");
  11182. }
  11183. }
  11184. void Commands::Remove_AA(Client* client, Seperator* sep) {
  11185. if (sep && sep->IsSet(0)) {
  11186. PrintSep(sep, "Remove_AA");
  11187. }
  11188. }
  11189. void Commands::Cancel_AA_Profile(Client* client, Seperator* sep) {
  11190. MasterAAList master_aa_list;
  11191. PrintSep(sep, "Cancel_AA_Profile");
  11192. if(client->GetVersion() > 561)
  11193. master_aa_list.DisplayAA(client, 0, 0);
  11194. }
  11195. void Commands::Save_AA_Profile(Client* client, Seperator* sep) {
  11196. if (sep && sep->IsSet(0)) {
  11197. PrintSep(sep, "Save_AA_Profile");
  11198. }
  11199. }
  11200. void Commands::Command_TargetItem(Client* client, Seperator* sep) {
  11201. if (!sep || sep->GetArgNumber() < 1 || !client->GetPlayer()) return;
  11202. if (!sep->IsNumber(0)) return;
  11203. int32 request_id = atoul(sep->arg[0]);
  11204. if (!sep->IsNumber(1)) return;
  11205. sint32 item_id = atoi(sep->arg[1]);
  11206. if (client->IsCurrentTransmuteID(request_id)) {
  11207. Transmute::HandleItemResponse(client, client->GetPlayer(), request_id, reinterpret_cast<int32&>(item_id));
  11208. }
  11209. else if (client->IsCurrentTransmuteID(item_id)) {
  11210. if (!sep->IsSet(2)) return;
  11211. if (sep->IsNumber(2) && atoi(sep->arg[2]) == 1) {
  11212. Transmute::HandleConfirmResponse(client, client->GetPlayer(), reinterpret_cast<int32&>(item_id));
  11213. }
  11214. }
  11215. }
  11216. void Commands::Command_FindSpawn(Client* client, Seperator* sep) {
  11217. if(sep)
  11218. client->GetCurrentZone()->FindSpawn(client, (char*)sep->argplus[0]);
  11219. }
  11220. void Commands::Command_MoveCharacter(Client* client, Seperator* sep) {
  11221. if(sep && sep->arg[0][0] && sep->arg[1][0])
  11222. {
  11223. char* name = sep->arg[0];
  11224. char* zoneName = sep->arg[1];
  11225. char query[256];
  11226. 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);
  11227. if (database.RunQuery(query, strnlen(query, 256)))
  11228. {
  11229. client->Message(CHANNEL_COLOR_YELLOW, "Ran query:%s", query);
  11230. }
  11231. else
  11232. client->Message(CHANNEL_COLOR_RED, "Query FAILED to run: %s", query);
  11233. }
  11234. }
  11235. void Commands::Command_Mood(Client* client, Seperator* sep) {
  11236. Player* player = client->GetPlayer();
  11237. if( sep && sep->arg[0] )
  11238. {
  11239. const char* value = sep->arg[0];
  11240. InfoStruct* info = player->GetInfoStruct();
  11241. int32 cid = client->GetCharacterID();
  11242. char* characterName = database.GetCharacterName(cid);
  11243. char tmp[1024]; // our emote string "xyz appears zyx"
  11244. //char properties vals
  11245. char* pname = "mood";
  11246. char* pval; // mood value
  11247. bool pt; //used to verify return from DB.
  11248. //This should never be seen.
  11249. sprintf(tmp, " ");
  11250. if( strncasecmp(value, "angry", strlen(value)) == 0 )
  11251. {
  11252. sprintf(tmp, "%s appears angry", characterName);
  11253. pval = "11852";
  11254. player->SetMoodState(11852, 1);
  11255. info->set_mood(11852);
  11256. pt = database.insertCharacterProperty(client, pname, pval);
  11257. }
  11258. else if( strncasecmp(value, "afraid", strlen(value)) == 0 )
  11259. {
  11260. sprintf(tmp, "%s appears afraid", characterName);
  11261. pval = "11851";
  11262. player->SetMoodState(11851, 1);
  11263. info->set_mood(11851);
  11264. pt = database.insertCharacterProperty(client, pname, pval);
  11265. }
  11266. else if( strncasecmp(value, "happy", strlen(value)) == 0 )
  11267. {
  11268. sprintf(tmp, "%s appears happy", characterName);
  11269. pval = "11854";
  11270. player->SetMoodState(11854, 1);
  11271. info->set_mood(11854);
  11272. pt = database.insertCharacterProperty(client, pname, pval);
  11273. }
  11274. else if( strncasecmp(value, "sad", strlen(value)) == 0 ) {
  11275. sprintf(tmp, "%s appears sad", characterName);
  11276. pval = "11856";
  11277. player->SetMoodState(11856, 1);
  11278. info->set_mood(11856);
  11279. pt = database.insertCharacterProperty(client, pname, pval);
  11280. }
  11281. else if( strncasecmp(value, "tired", strlen(value)) == 0 )
  11282. {
  11283. sprintf(tmp, "%s appears tired", characterName);
  11284. pval = "11857";
  11285. player->SetMoodState(11857, 1);
  11286. info->set_mood(11857);
  11287. pt = database.insertCharacterProperty(client, pname, pval);
  11288. }
  11289. else if( strncasecmp(value, "none", strlen(value)) == 0 )
  11290. {
  11291. //using 11855 mood_idle for none, I assume thats what its for?
  11292. pval = "11855";
  11293. player->SetMoodState(11855, 1);
  11294. info->set_mood(11855);
  11295. pt = database.insertCharacterProperty(client, pname, pval);
  11296. //return since we have nothing left to do. No emote for none.
  11297. return;
  11298. }else{
  11299. client->SimpleMessage(CHANNEL_NARRATIVE, "Listing Available Moods:");
  11300. client->SimpleMessage(CHANNEL_NARRATIVE, "none");
  11301. client->SimpleMessage(CHANNEL_NARRATIVE, "afraid");
  11302. client->SimpleMessage(CHANNEL_NARRATIVE, "angry");
  11303. client->SimpleMessage(CHANNEL_NARRATIVE, "happy");
  11304. client->SimpleMessage(CHANNEL_NARRATIVE, "sad");
  11305. client->SimpleMessage(CHANNEL_NARRATIVE, "tired");
  11306. return;
  11307. }
  11308. client->GetPlayer()->GetZone()->HandleChatMessage(0, 0, CHANNEL_EMOTE, tmp);
  11309. return;
  11310. }
  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. /*
  11321. Function: Command_CancelEffect()
  11322. Purpose : Cancels (good) effect spells
  11323. Example : /cancel_effect spell_id - would cancel the spell with the <spell_id> value in spell effects list
  11324. */
  11325. void Commands::Command_CancelEffect(Client* client, Seperator* sep)
  11326. {
  11327. if (sep && sep->arg[0] && sep->IsNumber(0))
  11328. {
  11329. int32 spell_id = atoul(sep->arg[0]);
  11330. SpellEffects* effect = client->GetPlayer()->GetSpellEffect(spell_id);
  11331. if(!effect || effect->spell->spell->GetSpellData()->det_type) {
  11332. return;
  11333. }
  11334. MaintainedEffects* meffect = effect->caster->GetMaintainedSpell(spell_id);
  11335. if (!meffect || !meffect->spell || !meffect->spell->caster || !meffect->spell->caster->GetZone() ||
  11336. !meffect->spell->caster->GetZone()->GetSpellProcess()->DeleteCasterSpell(meffect->spell, "canceled", false, client->GetPlayer()))
  11337. client->Message(CHANNEL_COLOR_RED, "The spell effect could not be cancelled.");
  11338. }
  11339. }
  11340. /*
  11341. Function: Command_CurePlayer()
  11342. Purpose : Identifies spell to cast for cure based on type
  11343. Example : /cureplayer ??
  11344. https://eq2.fandom.com/wiki/Update:58
  11345. New command /cureplayer [playername|group or raid position][trauma|arcane|noxious|elemental|curse] optional [spell|potion]
  11346. Example: /cureplayer g0 noxious spell
  11347. Will attempt to cure yourself of a noxious detriment with only spells and without using potions (even if you have them).
  11348. Example: /cureplayer r4 noxious
  11349. Will attempt to cure the character in raid slot 4 of a noxious detriment using a spell or potion (whichever is available).
  11350. */
  11351. void Commands::Command_CurePlayer(Client* client, Seperator* sep)
  11352. {
  11353. Entity* target = nullptr;
  11354. bool use_spells = true;
  11355. bool use_potions = true;
  11356. if (sep && sep->arg[0] && sep->arg[1]) {
  11357. if(sep->arg[2]) {
  11358. std::string type(sep->arg[2]);
  11359. boost::algorithm::to_lower(type);
  11360. if(type == "potion")
  11361. use_spells = false;
  11362. else if(type == "spell")
  11363. use_potions = false;
  11364. }
  11365. if(strlen(sep->arg[0]) > 1 && isdigit(sep->arg[0][1])) {
  11366. int32 mapped_position = (int32)(sep->arg[0][1]) - 48;
  11367. // TODO: RAID Support ('r' argument)
  11368. if(sep->arg[0][0] == 'g' && !mapped_position) {
  11369. target = (Entity*)client->GetPlayer();
  11370. }
  11371. else {
  11372. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  11373. if (gmi && gmi->group_id) {
  11374. PlayerGroup* group = world.GetGroupManager()->GetGroup(gmi->group_id);
  11375. if(group) {
  11376. target = group->GetGroupMemberByPosition(client->GetPlayer(), mapped_position);
  11377. }
  11378. }
  11379. }
  11380. }
  11381. else {
  11382. Client* target_client = zone_list.GetClientByCharName(sep->arg[0]);
  11383. if(target_client && target_client->GetPlayer() && target_client->GetPlayer()->GetZone() == client->GetPlayer()->GetZone()) {
  11384. target = (Entity*)target_client->GetPlayer();
  11385. }
  11386. }
  11387. ItemEffectType type = EFFECT_CURE_TYPE_ALL;
  11388. bool successful_spell = false;
  11389. bool successful_potion = false;
  11390. if(target) {
  11391. SpellBookEntry* entry = nullptr;
  11392. std::string str(sep->arg[1]);
  11393. boost::algorithm::to_lower(str);
  11394. if(str == "arcane") {
  11395. type = EFFECT_CURE_TYPE_ARCANE;
  11396. // cure arcane spell missing in DB?
  11397. if(use_spells && rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Spells, CureArcaneSpellID)->GetInt32()) {
  11398. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Spells, CureArcaneSpellID)->GetInt32()); // cure noxious
  11399. }
  11400. }
  11401. else if(str == "trauma") {
  11402. type = EFFECT_CURE_TYPE_TRAUMA;
  11403. // cure trauma spell missing in DB?
  11404. if(use_spells && rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Spells, CureTraumaSpellID)->GetInt32()) {
  11405. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Spells, CureTraumaSpellID)->GetInt32()); // cure noxious
  11406. }
  11407. }
  11408. else if(str == "noxious") {
  11409. type = EFFECT_CURE_TYPE_NOXIOUS;
  11410. if(use_spells && rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Spells, CureNoxiousSpellID)->GetInt32()) {
  11411. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Spells, CureNoxiousSpellID)->GetInt32()); // cure noxious
  11412. }
  11413. }
  11414. else if(str == "curse") {
  11415. type = EFFECT_CURE_TYPE_CURSE;
  11416. if(use_spells && rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Spells, CureCurseSpellID)->GetInt32()) {
  11417. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Spells, CureCurseSpellID)->GetInt32()); // cure curse
  11418. }
  11419. }
  11420. else if(str == "magic") {
  11421. type = EFFECT_CURE_TYPE_MAGIC;
  11422. if(use_spells && rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Spells, CureMagicSpellID)->GetInt32()) {
  11423. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Spells, CureMagicSpellID)->GetInt32()); // cure magic
  11424. }
  11425. }
  11426. if(use_spells) {
  11427. // check if any of the specific cure types are available, if not then check the base cures
  11428. if(!entry && rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Spells, CureSpellID)->GetInt32()) {
  11429. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Spells, CureSpellID)->GetInt32()); // cure
  11430. }
  11431. if(entry && entry->spell_id) {
  11432. Spell* spell = master_spell_list.GetSpell(entry->spell_id, entry->tier);
  11433. target->GetZone()->ProcessSpell(spell, (Entity*)client->GetPlayer(), target, true, false);
  11434. successful_spell = true;
  11435. }
  11436. }
  11437. }
  11438. if(!successful_spell && use_potions && target && type != NO_EFFECT_TYPE) {
  11439. vector<Item*>* potential_items = client->GetItemsByEffectType(type, EFFECT_CURE_TYPE_ALL);
  11440. if (potential_items && potential_items->size() > 0) {
  11441. vector<Item*>::iterator itr;
  11442. for (itr = potential_items->begin(); itr != potential_items->end(); itr++)
  11443. {
  11444. Item* item = *itr;
  11445. if(client->UseItem(item, target)) {
  11446. successful_potion = true;
  11447. break;
  11448. }
  11449. }
  11450. }
  11451. safe_delete(potential_items);
  11452. }
  11453. }
  11454. }
  11455. /*
  11456. Function: Command_ShareQuest()
  11457. Purpose : Share quest with the group
  11458. Example : /share_quest [quest_id]
  11459. */
  11460. void Commands::Command_ShareQuest(Client* client, Seperator* sep)
  11461. {
  11462. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  11463. int32 quest_id = atoul(sep->arg[0]);
  11464. bool hasQuest = client->GetPlayer()->HasAnyQuest(quest_id);
  11465. if(hasQuest) {
  11466. Quest* quest = master_quest_list.GetQuest(quest_id, false);
  11467. if(quest) {
  11468. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  11469. if (gmi && gmi->group_id) {
  11470. PlayerGroup* group = world.GetGroupManager()->GetGroup(gmi->group_id);
  11471. if (group) {
  11472. group->ShareQuestWithGroup(client, quest);
  11473. }
  11474. }
  11475. }
  11476. }
  11477. else {
  11478. client->SimpleMessage(CHANNEL_COLOR_RED, "Cannot find quest.");
  11479. }
  11480. }
  11481. }
  11482. /*
  11483. Function: Command_Yell()
  11484. Purpose : Yell to break an encounter
  11485. Example : /yell
  11486. * Uses self target, encounter target or no target
  11487. */
  11488. void Commands::Command_Yell(Client* client, Seperator* sep) {
  11489. Entity* player = (Entity*)client->GetPlayer();
  11490. Spawn* res = nullptr;
  11491. Spawn* prev = nullptr;
  11492. bool cycleAll = false;
  11493. if (player->GetTarget() == player) {
  11494. cycleAll = true; // self target breaks all encounters
  11495. }
  11496. else if (player->GetTarget()) {
  11497. res = player->GetTarget(); // selected target other than self only dis-engages that encounter
  11498. }
  11499. if (res && !client->GetPlayer()->IsEngagedBySpawnID(res->GetID()))
  11500. return;
  11501. bool groupPermissionYell = true;
  11502. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  11503. // If the player has a group and has a target
  11504. if (gmi) {
  11505. deque<GroupMemberInfo*>::iterator itr;
  11506. world.GetGroupManager()->GroupLock(__FUNCTION__, __LINE__);
  11507. PlayerGroup* group = world.GetGroupManager()->GetGroup(gmi->group_id);
  11508. if (group && !group->GetGroupOptions()->default_yell && !gmi->leader) { // default_yell_method = 0 means leader only
  11509. groupPermissionYell = false;
  11510. }
  11511. world.GetGroupManager()->ReleaseGroupLock(__FUNCTION__, __LINE__);
  11512. }
  11513. if (!groupPermissionYell) {
  11514. LogWrite(COMMAND__ERROR, 0, "Command", "%s permission to yell denied due to group yell method set to leader only", client->GetPlayer()->GetName());
  11515. return;
  11516. }
  11517. bool alreadyYelled = false;
  11518. do {
  11519. if (!res && player->IsEngagedInEncounter(&res)) { // no target is set, dis-engage top of hated by list
  11520. }
  11521. if (!res || prev == res) {
  11522. return;
  11523. }
  11524. if (res->IsNPC() && ((NPC*)res)->Brain()) {
  11525. if (!alreadyYelled) {
  11526. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You yell for help!");
  11527. string yellMsg = std::string(client->GetPlayer()->GetName()) + " yelled for help!";
  11528. client->GetPlayer()->GetZone()->SimpleMessage(CHANNEL_COLOR_RED, yellMsg.c_str(), client->GetPlayer(), 35.0f, false);
  11529. client->GetPlayer()->GetZone()->SendYellPacket(client->GetPlayer());
  11530. }
  11531. alreadyYelled = true;
  11532. NPC* npc = (NPC*)res;
  11533. npc->Brain()->ClearEncounter();
  11534. npc->SetLockedNoLoot(ENCOUNTER_STATE_BROKEN);
  11535. npc->UpdateEncounterState(ENCOUNTER_STATE_BROKEN);
  11536. }
  11537. prev = res;
  11538. res = nullptr;
  11539. } while (cycleAll);
  11540. if (!player->IsEngagedInEncounter()) {
  11541. if (player->GetInfoStruct()->get_engaged_encounter()) {
  11542. player->GetInfoStruct()->set_engaged_encounter(0);
  11543. player->SetRegenValues((player->GetInfoStruct()->get_effective_level() > 0) ? player->GetInfoStruct()->get_effective_level() : player->GetLevel());
  11544. client->GetPlayer()->SetCharSheetChanged(true);
  11545. player->info_changed = true;
  11546. }
  11547. }
  11548. }
  11549. /*
  11550. Function: Command_SetAutoLootMode()
  11551. Purpose : Set player auto loot mode (0 = disabled, 1 = need/lotto, 2 = decline).
  11552. Example : /setautolootmode [mode]
  11553. */
  11554. void Commands::Command_SetAutoLootMode(Client* client, Seperator* sep) {
  11555. if (sep && sep->IsNumber(0)) {
  11556. int8 mode = atoul(sep->arg[0]);
  11557. switch (mode) {
  11558. case AutoLootMode::METHOD_DISABLED: {
  11559. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Disabled auto loot mode");
  11560. break;
  11561. }
  11562. case AutoLootMode::METHOD_ACCEPT: {
  11563. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Enabled auto loot mode for need and lotto.");
  11564. break;
  11565. }
  11566. default: {
  11567. mode = AutoLootMode::METHOD_DECLINE;
  11568. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Enabled auto loot mode to decline need and lotto.");
  11569. break;
  11570. }
  11571. }
  11572. client->GetPlayer()->GetInfoStruct()->set_group_auto_loot_method(mode);
  11573. database.insertCharacterProperty(client, CHAR_PROPERTY_AUTOLOOTMETHOD, (char*)std::to_string(mode).c_str());
  11574. client->SendDefaultGroupOptions();
  11575. }
  11576. }
  11577. /*
  11578. Function: Command_AutoAttack()
  11579. Purpose : Attack / Auto Attack
  11580. Example : /attack, /autoattack type
  11581. */
  11582. void Commands::Command_AutoAttack(Client* client, Seperator* sep) {
  11583. int8 type = 1;
  11584. bool update = false;
  11585. Player* player = client->GetPlayer();
  11586. if(!player)
  11587. return;
  11588. bool incombat = player->EngagedInCombat();
  11589. if(sep && sep->arg[0] && sep->IsNumber(0))
  11590. type = atoi(sep->arg[0]);
  11591. if(!client->GetPlayer()->Alive()){
  11592. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  11593. return;
  11594. }
  11595. if(type == 0){
  11596. if(incombat)
  11597. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You stop fighting.");
  11598. player->StopCombat(type);
  11599. update = true;
  11600. }
  11601. else {
  11602. if(type == 2){
  11603. player->InCombat(false);
  11604. if(incombat && player->GetRangeAttack()){
  11605. player->StopCombat(type);
  11606. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You stop fighting.");
  11607. update = true;
  11608. }
  11609. else{
  11610. player->SetRangeAttack(true);
  11611. player->InCombat(true, true);
  11612. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You start fighting.");
  11613. update = true;
  11614. }
  11615. }
  11616. else {
  11617. player->InCombat(false, true);
  11618. player->SetRangeAttack(false);
  11619. player->InCombat(true);
  11620. if(!incombat) {
  11621. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You start fighting.");
  11622. update = true;
  11623. }
  11624. }
  11625. /*else
  11626. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You cannot attack that!");*/
  11627. }
  11628. if(update) {
  11629. player->SetCharSheetChanged(true);
  11630. }
  11631. }
  11632. /*
  11633. Function: Command_Assist()
  11634. Purpose : Assist target
  11635. Example : /assist [name]
  11636. * Uses target or character name
  11637. */
  11638. void Commands::Command_Assist(Client* client, Seperator* sep) {
  11639. Entity* player = (Entity*)client->GetPlayer();
  11640. Spawn* res = nullptr;
  11641. if(sep && sep->arg[0]) {
  11642. if(!stricmp(sep->arg[0], "on")) {
  11643. database.insertCharacterProperty(client, CHAR_PROPERTY_ASSISTAUTOATTACK, "1");
  11644. return;
  11645. }
  11646. else if(!stricmp(sep->arg[0], "off")) {
  11647. database.insertCharacterProperty(client, CHAR_PROPERTY_ASSISTAUTOATTACK, "0");
  11648. return;
  11649. }
  11650. Client* otherClient = client->GetPlayer()->GetZone()->GetClientByName(sep->arg[0]);
  11651. if(otherClient) {
  11652. res = otherClient->GetPlayer();
  11653. }
  11654. }
  11655. if (player->GetTarget()) {
  11656. res = player->GetTarget(); // selected target other than self only dis-engages that encounter
  11657. }
  11658. if(res && res->GetTarget()) {
  11659. res = res->GetTarget();
  11660. }
  11661. if(res) {
  11662. client->TargetSpawn(res);
  11663. if(client->GetPlayer()->GetInfoStruct()->get_assist_auto_attack() && !player->EngagedInCombat()) {
  11664. Command_AutoAttack(client, nullptr);
  11665. }
  11666. }
  11667. }
  11668. /*
  11669. Function: Command_Target()
  11670. Purpose : Target spawn/player
  11671. Example : /target [name]
  11672. * Uses target or character name
  11673. */
  11674. void Commands::Command_Target(Client* client, Seperator* sep) {
  11675. Entity* player = (Entity*)client->GetPlayer();
  11676. Spawn* res = nullptr;
  11677. if(sep && sep->arg[0] && player->GetZone()) {
  11678. float max_distance = rule_manager.GetZoneRule(client->GetCurrentZoneID(), R_Player, MaxTargetCommandDistance)->GetFloat();
  11679. if(max_distance < 1.0f) {
  11680. max_distance = 10.0f;
  11681. }
  11682. player->GetZone()->SetPlayerTargetByName(client, (char*)sep->argplus[0], max_distance);
  11683. }
  11684. }
  11685. /*
  11686. Function: Command_Target_Pet()
  11687. Purpose : Target pet
  11688. Example : /target_pet
  11689. * Use to target pet
  11690. */
  11691. void Commands::Command_Target_Pet(Client* client, Seperator* sep) {
  11692. Entity* player = (Entity*)client->GetPlayer();
  11693. Spawn* res = client->GetPlayer()->GetPet();
  11694. if(res) {
  11695. client->TargetSpawn(res);
  11696. }
  11697. }
  11698. /*
  11699. Function: Command_WhoGroup()
  11700. Purpose : Lists all members of current group
  11701. Example : /whogroup
  11702. */
  11703. void Commands::Command_WhoGroup(Client* client, Seperator* sep) {
  11704. Entity* player = (Entity*)client->GetPlayer();
  11705. if(player->GetGroupMemberInfo()) {
  11706. world.GetGroupManager()->SendWhoGroupMembers(client, player->GetGroupMemberInfo()->group_id);
  11707. }
  11708. else {
  11709. client->SimpleMessage(CHANNEL_COLOR_RED, "You are not currently in a group.");
  11710. }
  11711. }
  11712. /*
  11713. Function: Command_WhoRaid()
  11714. Purpose : Lists all members of raid
  11715. Example : /whoraid
  11716. */
  11717. void Commands::Command_WhoRaid(Client* client, Seperator* sep) {
  11718. Entity* player = (Entity*)client->GetPlayer();
  11719. if(player->GetGroupMemberInfo()) {
  11720. world.GetGroupManager()->SendWhoRaidMembers(client, player->GetGroupMemberInfo()->group_id);
  11721. }
  11722. else {
  11723. client->SimpleMessage(CHANNEL_COLOR_RED, "You are not currently in a group or raid.");
  11724. }
  11725. }
  11726. /*
  11727. Function: Command_RaidInvite()
  11728. Purpose : Invites a group to the raid
  11729. Example : /raidinvite
  11730. */
  11731. void Commands::Command_RaidInvite(Client* client, Seperator* sep) {
  11732. Entity* target = nullptr;
  11733. if( sep && sep->arg[0] ) {
  11734. Client* target_client = zone_list.GetClientByCharName(sep->arg[0]);
  11735. if(target_client)
  11736. target = (Entity*)target_client->GetPlayer();
  11737. }
  11738. if(!target) {
  11739. if(client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsEntity())
  11740. target = (Entity*)client->GetPlayer()->GetTarget();
  11741. }
  11742. world.GetGroupManager()->SendRaidInvite(client, target);
  11743. }
  11744. /*
  11745. Function: Command_Raid_Looter()
  11746. Purpose : Adds a looter to the raid loot list
  11747. Example : /raid_looter <name>
  11748. */
  11749. void Commands::Command_Raid_Looter(Client* client, Seperator* sep) {
  11750. if(!client->GetPlayer()->GetGroupMemberInfo() || client->GetPlayer()->GetGroupMemberInfo()->leader)
  11751. return;
  11752. Entity* target = nullptr;
  11753. if( sep && sep->arg[0] ) {
  11754. Client* target_client = zone_list.GetClientByCharName(sep->arg[0]);
  11755. if(target_client)
  11756. target = (Entity*)target_client->GetPlayer();
  11757. }
  11758. if(!target) {
  11759. if(client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsEntity())
  11760. target = (Entity*)client->GetPlayer()->GetTarget();
  11761. }
  11762. bool isLeaderRaid = world.GetGroupManager()->IsInRaidGroup(client->GetPlayer()->GetGroupMemberInfo()->group_id, client->GetPlayer()->GetGroupMemberInfo()->group_id, true);
  11763. if(isLeaderRaid && target && target->IsEntity()) {
  11764. if(((Entity*)target)->GetGroupMemberInfo() && world.GetGroupManager()->IsInRaidGroup(client->GetPlayer()->GetGroupMemberInfo()->group_id, ((Entity*)target)->GetGroupMemberInfo()->group_id, false)) {
  11765. if(((Entity*)target)->GetGroupMemberInfo()->is_raid_looter) {
  11766. client->Message(CHANNEL_COLOR_YELLOW, "%s removed as a raid looter.", target->GetName());
  11767. ((Entity*)target)->GetGroupMemberInfo()->is_raid_looter = false;
  11768. }
  11769. else {
  11770. client->Message(CHANNEL_COLOR_YELLOW, "%s added as a raid looter.", target->GetName());
  11771. ((Entity*)target)->GetGroupMemberInfo()->is_raid_looter = true;
  11772. }
  11773. }
  11774. }
  11775. }
  11776. /*
  11777. Function: Command_KickFromGroup()
  11778. Purpose : Kick a player from a group
  11779. Example : /kickfromgroup <name>
  11780. */
  11781. void Commands::Command_KickFromGroup(Client* client, Seperator* sep) {
  11782. Entity* target = nullptr;
  11783. Client* target_client = nullptr;
  11784. if( sep && sep->arg[0] ) {
  11785. target_client = zone_list.GetClientByCharName(sep->arg[0]);
  11786. if(target_client) {
  11787. target = target_client->GetPlayer();
  11788. }
  11789. }
  11790. if(!target) {
  11791. if(client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsEntity())
  11792. target = (Entity*)client->GetPlayer()->GetTarget();
  11793. if(target && target->IsPlayer())
  11794. target_client = ((Player*)target)->GetClient();
  11795. }
  11796. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  11797. if (gmi && gmi->leader && target && target->GetGroupMemberInfo() && gmi->group_id == target->GetGroupMemberInfo()->group_id) {
  11798. int32 group_id = gmi->group_id;
  11799. world.GetGroupManager()->RemoveGroupMember(group_id, target);
  11800. if (!world.GetGroupManager()->IsGroupIDValid(group_id)) {
  11801. // leader->Message(CHANNEL_COLOR_GROUP, "%s has left the group.", client->GetPlayer()->GetName());
  11802. }
  11803. else {
  11804. world.GetGroupManager()->GroupMessage(group_id, "%s has been removed from the group.", target->GetName());
  11805. }
  11806. if(target_client)
  11807. target_client->SimpleMessage(CHANNEL_GROUP_CHAT, "You have been kicked from the group");
  11808. }
  11809. }
  11810. /*
  11811. Function: Command_KickFromRaid()
  11812. Purpose : Kick a group from a raid
  11813. Example : /kickfromraid <name>
  11814. */
  11815. void Commands::Command_KickFromRaid(Client* client, Seperator* sep) {
  11816. Entity* target = nullptr;
  11817. Client* target_client = nullptr;
  11818. if( sep && sep->arg[0] ) {
  11819. target_client = zone_list.GetClientByCharName(sep->arg[0]);
  11820. if(target_client) {
  11821. target = target_client->GetPlayer();
  11822. }
  11823. }
  11824. if(!target) {
  11825. if(client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsEntity())
  11826. target = (Entity*)client->GetPlayer()->GetTarget();
  11827. if(target && target->IsPlayer())
  11828. target_client = ((Player*)target)->GetClient();
  11829. }
  11830. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  11831. if(gmi && gmi->leader && target && target->GetGroupMemberInfo() && world.GetGroupManager()->IsInRaidGroup(gmi->group_id, target->GetGroupMemberInfo()->group_id, false) &&
  11832. world.GetGroupManager()->IsInRaidGroup(gmi->group_id, gmi->group_id, true)) {
  11833. GroupOptions goptions;
  11834. world.GetGroupManager()->GetDefaultGroupOptions(gmi->group_id, &goptions);
  11835. world.GetGroupManager()->RemoveGroupFromRaid(gmi->group_id, target->GetGroupMemberInfo()->group_id);
  11836. std::vector<int32> raidGroups;
  11837. world.GetGroupManager()->GetRaidGroups(gmi->group_id, &raidGroups);
  11838. peer_manager.sendPeersNewGroupRequest("", 0, gmi->group_id, "", "", &goptions, "", &raidGroups, true);
  11839. std::vector<int32> emptyRaid;
  11840. peer_manager.sendPeersNewGroupRequest("", 0, target->GetGroupMemberInfo()->group_id, "", "", &goptions, "", &emptyRaid, true);
  11841. }
  11842. }
  11843. /*
  11844. Function: Command_LeaveRaid()
  11845. Purpose : Leave a raid
  11846. Example : /leaveraid
  11847. */
  11848. void Commands::Command_LeaveRaid(Client* client, Seperator* sep) {
  11849. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  11850. int32 orig_group_id = 0;
  11851. if(gmi && gmi->leader && world.GetGroupManager()->IsInRaidGroup(gmi->group_id, gmi->group_id, false)) {
  11852. orig_group_id = gmi->group_id;
  11853. GroupOptions goptions;
  11854. world.GetGroupManager()->GetDefaultGroupOptions(gmi->group_id, &goptions);
  11855. std::vector<int32> raidGroups;
  11856. world.GetGroupManager()->GetRaidGroups(gmi->group_id, &raidGroups);
  11857. std::vector<int32>::iterator cur_group_itr = std::find(raidGroups.begin(), raidGroups.end(), gmi->group_id);
  11858. if(cur_group_itr != raidGroups.end())
  11859. raidGroups.erase(cur_group_itr);
  11860. bool sendEmpty = false;
  11861. std::vector<int32> emptyRaid;
  11862. if(raidGroups.size() < 2) {
  11863. sendEmpty = true;
  11864. }
  11865. for(cur_group_itr = raidGroups.begin(); cur_group_itr != raidGroups.end(); cur_group_itr++) {
  11866. if(sendEmpty) {
  11867. world.GetGroupManager()->ClearGroupRaid((*cur_group_itr));
  11868. peer_manager.sendPeersNewGroupRequest("", 0, (*cur_group_itr), "", "", &goptions, "", &emptyRaid, true);
  11869. world.GetGroupManager()->SendGroupUpdate((*cur_group_itr), nullptr, true);
  11870. }
  11871. else {
  11872. world.GetGroupManager()->ReplaceRaidGroups((*cur_group_itr), &raidGroups);
  11873. }
  11874. }
  11875. if(!sendEmpty) {
  11876. peer_manager.sendPeersNewGroupRequest("", 0, orig_group_id, "", "", &goptions, "", &raidGroups, true);
  11877. }
  11878. world.GetGroupManager()->ClearGroupRaid(orig_group_id);
  11879. world.GetGroupManager()->SendGroupUpdate(orig_group_id, nullptr, true);
  11880. peer_manager.sendPeersNewGroupRequest("", 0, orig_group_id, "", "", &goptions, "", &emptyRaid, true);
  11881. }
  11882. }
  11883. /*
  11884. Function: Command_Split()
  11885. Purpose : split coin to group
  11886. Example : /split {plat} {gold} {silver} {copper}
  11887. */
  11888. void Commands::Command_Split(Client* client, Seperator* sep) {
  11889. // int32 item_id = atoul(sep->arg[0,1,2,3]);
  11890. int32 plat = 0, gold = 0, silver = 0, copper = 0;
  11891. if(sep->IsNumber(0))
  11892. plat = atoul(sep->arg[0]);
  11893. if(sep->IsNumber(1))
  11894. gold = atoul(sep->arg[1]);
  11895. if(sep->IsNumber(2))
  11896. silver = atoul(sep->arg[2]);
  11897. if(sep->IsNumber(3))
  11898. copper = atoul(sep->arg[3]);
  11899. world.GetGroupManager()->SplitWithGroupOrRaid(client, plat, gold, silver, copper);
  11900. }
  11901. /*
  11902. Function: Command_RaidSay()
  11903. Purpose : Speak to raid members
  11904. Example : /raidsay {message}, /rsay {message}
  11905. */
  11906. void Commands::Command_RaidSay(Client* client, Seperator* sep) {
  11907. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  11908. if(sep && sep->arg[0] && gmi) {
  11909. world.GetGroupManager()->GroupLock(__FUNCTION__, __LINE__);
  11910. int32 spawn_group_id = gmi->group_id;
  11911. PlayerGroup* spawn_group = world.GetGroupManager()->GetGroup(spawn_group_id);
  11912. bool israidgroup = (spawn_group && spawn_group->IsGroupRaid());
  11913. world.GetGroupManager()->ReleaseGroupLock(__FUNCTION__, __LINE__);
  11914. if(israidgroup) {
  11915. world.GetGroupManager()->GroupChatMessage(gmi->group_id, client->GetPlayer(), client->GetPlayer()->GetCurrentLanguage(), sep->argplus[0], CHANNEL_RAID_SAY);
  11916. peer_manager.SendPeersChannelMessage(gmi->group_id, std::string(client->GetPlayer()->GetName()), std::string(sep->argplus[0]), CHANNEL_RAID_SAY, client->GetPlayer()->GetCurrentLanguage());
  11917. }
  11918. }
  11919. }