Commands.cpp 438 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033
  1. /*
  2. EQ2Emulator: Everquest II Server Emulator
  3. Copyright (C) 2007 EQ2EMulator Development Team (http://www.eq2emulator.net)
  4. This file is part of EQ2Emulator.
  5. EQ2Emulator is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. EQ2Emulator is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with EQ2Emulator. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #include <sys/types.h>
  17. #include <boost/algorithm/string/predicate.hpp>
  18. #include <boost/algorithm/string.hpp>
  19. #include "Commands.h"
  20. #include "../ClientPacketFunctions.h"
  21. #include "../../common/version.h"
  22. #include "../../common/seperator.h"
  23. #include "../../common/servertalk.h"
  24. #include "../WorldDatabase.h"
  25. #include "../World.h"
  26. #include "../../common/ConfigReader.h"
  27. #include "../VisualStates.h"
  28. #include "../../common/debug.h"
  29. #include "../LuaInterface.h"
  30. #include "../Quests.h"
  31. #include "../client.h"
  32. #include "../NPC.h"
  33. #include "../Guilds/Guild.h"
  34. #include "../SpellProcess.h"
  35. #include "../Tradeskills/Tradeskills.h"
  36. #include "../../common/Log.h"
  37. #include "../../common/MiscFunctions.h"
  38. #include "../Languages.h"
  39. #include "../Traits/Traits.h"
  40. #include "../Chat/Chat.h"
  41. #include "../Rules/Rules.h"
  42. #include "../AltAdvancement/AltAdvancement.h"
  43. #include "../RaceTypes/RaceTypes.h"
  44. #include "../classes.h"
  45. #include "../Transmute.h"
  46. #include "../Bots/Bot.h"
  47. extern WorldDatabase database;
  48. extern MasterSpellList master_spell_list;
  49. extern MasterTraitList master_trait_list;
  50. extern MasterRecipeList master_recipe_list;
  51. extern MasterRecipeBookList master_recipebook_list;
  52. extern World world;
  53. extern ClientList client_list;
  54. extern ConfigReader configReader;
  55. extern VisualStates visual_states;
  56. extern ZoneList zone_list;
  57. extern LuaInterface* lua_interface;
  58. extern MasterQuestList master_quest_list;
  59. extern MasterCollectionList master_collection_list;
  60. extern MasterSkillList master_skill_list;
  61. extern MasterFactionList master_faction_list;
  62. extern GuildList guild_list;
  63. extern MasterLanguagesList master_languages_list;
  64. extern Chat chat;
  65. extern RuleManager rule_manager;
  66. extern MasterAAList master_aa_list;
  67. extern MasterRaceTypeList race_types_list;
  68. extern Classes classes;
  69. //devn00b: Fix for linux builds since we dont use stricmp we use strcasecmp
  70. #if defined(__GNUC__)
  71. #define stricmp strcasecmp
  72. #define strnicmp strncasecmp
  73. #endif
  74. EQ2Packet* RemoteCommands::serialize(){
  75. buffer.clear();
  76. vector<EQ2_RemoteCommandString>::iterator command_list;
  77. buffer.append((char*)&num_commands, sizeof(int16));
  78. for( command_list = commands.begin(); command_list != commands.end(); command_list++ ) {
  79. AddDataCommand(&(*command_list));
  80. }
  81. EQ2Packet* app = new EQ2Packet(OP_SetRemoteCmdsMsg, (uchar*)buffer.c_str(), buffer.length() + 1);
  82. return app;
  83. }
  84. Commands::Commands(){
  85. remote_commands = new RemoteCommands();
  86. spawn_set_values["list"] = SPAWN_SET_VALUE_LIST;
  87. spawn_set_values["name"] = SPAWN_SET_VALUE_NAME;
  88. spawn_set_values["level"] = SPAWN_SET_VALUE_LEVEL; // TODO: Fix this, min_level, max_level
  89. spawn_set_values["difficulty"] = SPAWN_SET_VALUE_DIFFICULTY;
  90. spawn_set_values["model_type"] = SPAWN_SET_VALUE_MODEL_TYPE;
  91. spawn_set_values["class"] = SPAWN_SET_VALUE_CLASS;
  92. spawn_set_values["gender"] = SPAWN_SET_VALUE_GENDER;
  93. spawn_set_values["show_name"] = SPAWN_SET_VALUE_SHOW_NAME;
  94. spawn_set_values["attackable"] = SPAWN_SET_VALUE_ATTACKABLE;
  95. spawn_set_values["show_level"] = SPAWN_SET_VALUE_SHOW_LEVEL;
  96. spawn_set_values["targetable"] = SPAWN_SET_VALUE_TARGETABLE;
  97. spawn_set_values["show_command_icon"] = SPAWN_SET_VALUE_SHOW_COMMAND_ICON;
  98. spawn_set_values["display_hand_icon"] = SPAWN_SET_VALUE_HAND_ICON;
  99. spawn_set_values["hair_type"] = SPAWN_SET_VALUE_HAIR_TYPE;
  100. spawn_set_values["facial_hair_type"] = SPAWN_SET_VALUE_FACIAL_HAIR_TYPE;
  101. spawn_set_values["wing_type"] = SPAWN_SET_VALUE_WING_TYPE;
  102. spawn_set_values["chest_type"] = SPAWN_SET_VALUE_CHEST_TYPE;
  103. spawn_set_values["legs_type"] = SPAWN_SET_VALUE_LEGS_TYPE;
  104. spawn_set_values["soga_hair_type"] = SPAWN_SET_VALUE_SOGA_HAIR_TYPE;
  105. spawn_set_values["soga_facial_hair_type"] = SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE;
  106. spawn_set_values["soga_model_type"] = SPAWN_SET_VALUE_SOGA_MODEL_TYPE;
  107. spawn_set_values["size"] = SPAWN_SET_VALUE_SIZE;
  108. spawn_set_values["hp"] = SPAWN_SET_VALUE_HP;
  109. spawn_set_values["power"] = SPAWN_SET_VALUE_POWER;
  110. spawn_set_values["heroic"] = SPAWN_SET_VALUE_HEROIC;
  111. spawn_set_values["respawn"] = SPAWN_SET_VALUE_RESPAWN;
  112. spawn_set_values["x"] = SPAWN_SET_VALUE_X;
  113. spawn_set_values["y"] = SPAWN_SET_VALUE_Y;
  114. spawn_set_values["z"] = SPAWN_SET_VALUE_Z;
  115. spawn_set_values["heading"] = SPAWN_SET_VALUE_HEADING;
  116. spawn_set_values["location"] = SPAWN_SET_VALUE_LOCATION;
  117. spawn_set_values["command_primary"] = SPAWN_SET_VALUE_COMMAND_PRIMARY;
  118. spawn_set_values["command_secondary"] = SPAWN_SET_VALUE_COMMAND_SECONDARY;
  119. spawn_set_values["visual_state"] = SPAWN_SET_VALUE_VISUAL_STATE;
  120. spawn_set_values["action_state"] = SPAWN_SET_VALUE_ACTION_STATE;
  121. spawn_set_values["mood_state"] = SPAWN_SET_VALUE_MOOD_STATE;
  122. spawn_set_values["initial_state"] = SPAWN_SET_VALUE_INITIAL_STATE;
  123. spawn_set_values["activity_state"] = SPAWN_SET_VALUE_ACTIVITY_STATE;
  124. spawn_set_values["collision_radius"] = SPAWN_SET_VALUE_COLLISION_RADIUS;
  125. spawn_set_values["faction"] = SPAWN_SET_VALUE_FACTION;
  126. spawn_set_values["spawn_script"] = SPAWN_SET_VALUE_SPAWN_SCRIPT;
  127. spawn_set_values["spawnentry_script"] = SPAWN_SET_VALUE_SPAWNENTRY_SCRIPT;
  128. spawn_set_values["spawnlocation_script"] = SPAWN_SET_VALUE_SPAWNLOCATION_SCRIPT;
  129. spawn_set_values["sub_title"] = SPAWN_SET_VALUE_SUB_TITLE;
  130. spawn_set_values["expire"] = SPAWN_SET_VALUE_EXPIRE;
  131. spawn_set_values["expire_offset"] = SPAWN_SET_VALUE_EXPIRE_OFFSET;
  132. spawn_set_values["x_offset"] = SPAWN_SET_VALUE_X_OFFSET;
  133. spawn_set_values["y_offset"] = SPAWN_SET_VALUE_Y_OFFSET;
  134. spawn_set_values["z_offset"] = SPAWN_SET_VALUE_Z_OFFSET;
  135. spawn_set_values["device_id"] = SPAWN_SET_VALUE_DEVICE_ID;
  136. spawn_set_values["pitch"] = SPAWN_SET_VALUE_PITCH;
  137. spawn_set_values["roll"] = SPAWN_SET_VALUE_ROLL;
  138. spawn_set_values["hide_hood"] = SPAWN_SET_VALUE_HIDE_HOOD;
  139. spawn_set_values["emote_state"] = SPAWN_SET_VALUE_EMOTE_STATE;
  140. spawn_set_values["icon"] = SPAWN_SET_VALUE_ICON;
  141. spawn_set_values["prefix"] = SPAWN_SET_VALUE_PREFIX;
  142. spawn_set_values["suffix"] = SPAWN_SET_VALUE_SUFFIX;
  143. spawn_set_values["lastname"] = SPAWN_SET_VALUE_LASTNAME;
  144. spawn_set_values["expansion_flag"] = SPAWN_SET_VALUE_EXPANSION_FLAG;
  145. spawn_set_values["holiday_flag"] = SPAWN_SET_VALUE_HOLIDAY_FLAG;
  146. spawn_set_values["merchant_min_level"] = SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL;
  147. spawn_set_values["merchant_max_level"] = SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL;
  148. spawn_set_values["skin_color"] = SPAWN_SET_SKIN_COLOR;
  149. spawn_set_values["aaxp_rewards"] = SPAWN_SET_AAXP_REWARDS;
  150. spawn_set_values["hair_color1"] = SPAWN_SET_HAIR_COLOR1;
  151. spawn_set_values["hair_color2"] = SPAWN_SET_HAIR_COLOR2;
  152. spawn_set_values["hair_type_color"] = SPAWN_SET_HAIR_TYPE_COLOR;
  153. spawn_set_values["hair_face_color"] = SPAWN_SET_HAIR_FACE_COLOR;
  154. spawn_set_values["hair_type_highlight_color"] = SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR;
  155. spawn_set_values["face_hairlight_color"] = SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR;
  156. spawn_set_values["hair_highlight"] = SPAWN_SET_HAIR_HIGHLIGHT;
  157. spawn_set_values["model_color"] = SPAWN_SET_MODEL_COLOR;
  158. spawn_set_values["eye_color"] = SPAWN_SET_EYE_COLOR;
  159. spawn_set_values["soga_skin_color"] = SPAWN_SET_SOGA_SKIN_COLOR;
  160. spawn_set_values["soga_hair_color1"] = SPAWN_SET_SOGA_HAIR_COLOR1;
  161. spawn_set_values["soga_hair_color2"] = SPAWN_SET_SOGA_HAIR_COLOR2;
  162. spawn_set_values["soga_hair_type_color"] = SPAWN_SET_SOGA_HAIR_TYPE_COLOR;
  163. spawn_set_values["soga_hair_face_color"] = SPAWN_SET_SOGA_HAIR_FACE_COLOR;
  164. spawn_set_values["soga_hair_type_highlight_color"] = SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR;
  165. spawn_set_values["soga_face_hairlight_color"] = SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR;
  166. spawn_set_values["soga_hair_highlight"] = SPAWN_SET_SOGA_HAIR_HIGHLIGHT;
  167. spawn_set_values["soga_model_color"] = SPAWN_SET_SOGA_MODEL_COLOR;
  168. spawn_set_values["soga_eye_color"] = SPAWN_SET_SOGA_EYE_COLOR;
  169. spawn_set_values["cheek_type"] = SPAWN_SET_CHEEK_TYPE;
  170. spawn_set_values["chin_type"] = SPAWN_SET_CHIN_TYPE;
  171. spawn_set_values["ear_type"] = SPAWN_SET_EAR_TYPE;
  172. spawn_set_values["eye_brow_type"] = SPAWN_SET_EYE_BROW_TYPE;
  173. spawn_set_values["eye_type"] = SPAWN_SET_EYE_TYPE;
  174. spawn_set_values["lip_type"] = SPAWN_SET_LIP_TYPE;
  175. spawn_set_values["nose_type"] = SPAWN_SET_NOSE_TYPE;
  176. spawn_set_values["body_size"] = SPAWN_SET_BODY_SIZE;
  177. spawn_set_values["body_age"] = SPAWN_SET_BODY_AGE;
  178. spawn_set_values["soga_cheek_type"] = SPAWN_SET_SOGA_CHEEK_TYPE;
  179. spawn_set_values["soga_chin_type"] = SPAWN_SET_SOGA_CHIN_TYPE;
  180. spawn_set_values["soga_ear_type"] = SPAWN_SET_SOGA_EAR_TYPE;
  181. spawn_set_values["soga_eye_brow_type"] = SPAWN_SET_SOGA_EYE_BROW_TYPE;
  182. spawn_set_values["soga_eye_type"] = SPAWN_SET_SOGA_EYE_TYPE;
  183. spawn_set_values["soga_lip_type"] = SPAWN_SET_SOGA_LIP_TYPE;
  184. spawn_set_values["soga_nose_type"] = SPAWN_SET_SOGA_NOSE_TYPE;
  185. spawn_set_values["soga_body_size"] = SPAWN_SET_SOGA_BODY_SIZE;
  186. spawn_set_values["soga_body_age"] = SPAWN_SET_SOGA_BODY_AGE;
  187. spawn_set_values["attack_type"] = SPAWN_SET_ATTACK_TYPE;
  188. spawn_set_values["race_type"] = SPAWN_SET_RACE_TYPE;
  189. spawn_set_values["loot_tier"] = SPAWN_SET_LOOT_TIER;
  190. spawn_set_values["loot_drop_type"] = SPAWN_SET_LOOT_DROP_TYPE;
  191. spawn_set_values["scared_strong_players"] = SPAWN_SET_SCARED_STRONG_PLAYERS;
  192. zone_set_values["expansion_id"] = ZONE_SET_VALUE_EXPANSION_ID;
  193. zone_set_values["name"] = ZONE_SET_VALUE_NAME;
  194. zone_set_values["file"] = ZONE_SET_VALUE_FILE ;
  195. zone_set_values["description"] = ZONE_SET_VALUE_DESCRIPTION;
  196. zone_set_values["safe_x"] = ZONE_SET_VALUE_SAFE_X;
  197. zone_set_values["safe_y"] = ZONE_SET_VALUE_SAFE_Y;
  198. zone_set_values["safe_z"] = ZONE_SET_VALUE_SAFE_Z;
  199. zone_set_values["underworld"] = ZONE_SET_VALUE_UNDERWORLD;
  200. zone_set_values["min_recommended"] = ZONE_SET_VALUE_MIN_RECOMMENDED;
  201. zone_set_values["max_recommended"] = ZONE_SET_VALUE_MAX_RECOMMENDED;
  202. zone_set_values["zone_type"] = ZONE_SET_VALUE_ZONE_TYPE;
  203. zone_set_values["always_loaded"] = ZONE_SET_VALUE_ALWAYS_LOADED;
  204. zone_set_values["city_zone"] = ZONE_SET_VALUE_CITY_ZONE;
  205. zone_set_values["weather_allowed"] = ZONE_SET_VALUE_WEATHER_ALLOWED;
  206. zone_set_values["min_status"] = ZONE_SET_VALUE_MIN_STATUS;
  207. zone_set_values["min_level"] = ZONE_SET_VALUE_MIN_LEVEL;
  208. zone_set_values["start_zone"] = ZONE_SET_VALUE_START_ZONE;
  209. zone_set_values["instance_type"] = ZONE_SET_VALUE_INSTANCE_TYPE;
  210. zone_set_values["default_reenter_time"] = ZONE_SET_VALUE_DEFAULT_REENTER_TIME;
  211. zone_set_values["default_reset_time"] = ZONE_SET_VALUE_DEFAULT_RESET_TIME;
  212. zone_set_values["default_lockout_time"] = ZONE_SET_VALUE_DEFAULT_LOCKOUT_TIME;
  213. zone_set_values["force_group_to_zone"] = ZONE_SET_VALUE_FORCE_GROUP_TO_ZONE;
  214. zone_set_values["lua_script"] = ZONE_SET_VALUE_LUA_SCRIPT;
  215. zone_set_values["shutdown_timer"] = ZONE_SET_VALUE_SHUTDOWN_TIMER;
  216. zone_set_values["zone_motd"] = ZONE_SET_VALUE_ZONE_MOTD;
  217. }
  218. Commands::~Commands() {
  219. safe_delete(remote_commands);
  220. }
  221. int32 Commands::GetSpawnSetType(string val){
  222. if(spawn_set_values.count(val) > 0)
  223. return spawn_set_values[val];
  224. return 0xFFFFFFFF;
  225. }
  226. bool Commands::SetSpawnCommand(Client* client, Spawn* target, int8 type, const char* value, bool send_update, bool temporary, string* temp_value, int8 index){
  227. if(!target)
  228. return false;
  229. int32 val = 0;
  230. try{
  231. if(type != SPAWN_SET_VALUE_NAME &&
  232. !(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))
  233. {
  234. switch(type)
  235. {
  236. case SPAWN_SET_SKIN_COLOR:
  237. case SPAWN_SET_HAIR_COLOR1:
  238. case SPAWN_SET_HAIR_COLOR2:
  239. case SPAWN_SET_HAIR_TYPE_COLOR:
  240. case SPAWN_SET_HAIR_FACE_COLOR:
  241. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  242. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  243. case SPAWN_SET_HAIR_HIGHLIGHT:
  244. case SPAWN_SET_EYE_COLOR:
  245. case SPAWN_SET_SOGA_SKIN_COLOR:
  246. case SPAWN_SET_SOGA_HAIR_COLOR1:
  247. case SPAWN_SET_SOGA_HAIR_COLOR2:
  248. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  249. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  250. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  251. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  252. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  253. case SPAWN_SET_SOGA_EYE_COLOR:
  254. case SPAWN_SET_RACE_TYPE:
  255. // ignore these are colors can't pass as a integer value
  256. break;
  257. default:
  258. val = atoul(value);
  259. }
  260. }
  261. }
  262. catch(...){
  263. if(client)
  264. client->Message(CHANNEL_COLOR_RED, "Invalid numeric spawn value: %s", value);
  265. return false;
  266. }
  267. if(temporary){
  268. char tmp[128] = {0};
  269. switch(type){
  270. case SPAWN_SET_VALUE_NAME:{
  271. sprintf(tmp, "%s", target->GetName());
  272. target->SetName(value);
  273. if(target->GetZone())
  274. target->GetZone()->SendUpdateTitles(target);
  275. break;
  276. }
  277. case SPAWN_SET_VALUE_X_OFFSET:
  278. {
  279. sprintf(tmp, "%f", target->GetXOffset());
  280. target->SetXOffset(float(val));
  281. break;
  282. }
  283. case SPAWN_SET_VALUE_Y_OFFSET:
  284. {
  285. sprintf(tmp, "%f", target->GetYOffset());
  286. target->SetYOffset(float(val));
  287. break;
  288. }
  289. case SPAWN_SET_VALUE_Z_OFFSET:
  290. {
  291. sprintf(tmp, "%f", target->GetZOffset());
  292. target->SetZOffset(float(val));
  293. break;
  294. }
  295. case SPAWN_SET_VALUE_EXPIRE: {
  296. sprintf(tmp, "%u", target->GetExpireTime());
  297. target->SetExpireTime(val);
  298. break;
  299. }
  300. case SPAWN_SET_VALUE_EXPIRE_OFFSET: {
  301. sprintf(tmp, "%u", target->GetExpireOffsetTime());
  302. target->SetExpireOffsetTime(val);
  303. break;
  304. }
  305. case SPAWN_SET_VALUE_SUB_TITLE: {
  306. sprintf(tmp, "%s", target->GetSubTitle());
  307. target->SetSubTitle(value);
  308. if(target->GetZone())
  309. target->GetZone()->SendUpdateTitles(target);
  310. break;
  311. }
  312. case SPAWN_SET_VALUE_LEVEL:{
  313. sprintf(tmp, "%i", target->GetLevel());
  314. target->SetLevel(val, send_update);
  315. break;
  316. }
  317. case SPAWN_SET_VALUE_DIFFICULTY:{
  318. sprintf(tmp, "%i", target->GetDifficulty());
  319. target->SetDifficulty(val, send_update);
  320. break;
  321. }
  322. case SPAWN_SET_VALUE_MODEL_TYPE:{
  323. sprintf(tmp, "%i", target->GetModelType());
  324. target->SetModelType(val, send_update);
  325. break;
  326. }
  327. case SPAWN_SET_VALUE_CLASS:{
  328. sprintf(tmp, "%i", target->GetAdventureClass());
  329. target->SetAdventureClass(val, send_update);
  330. break;
  331. }
  332. case SPAWN_SET_VALUE_GENDER:{
  333. sprintf(tmp, "%i", target->GetGender());
  334. target->SetGender(val, send_update);
  335. break;
  336. }
  337. case SPAWN_SET_VALUE_SHOW_NAME:{
  338. sprintf(tmp, "%i", target->GetShowName());
  339. target->SetShowName(val, send_update);
  340. break;
  341. }
  342. case SPAWN_SET_VALUE_ATTACKABLE:{
  343. sprintf(tmp, "%i", target->GetAttackable());
  344. target->SetAttackable(val, send_update);
  345. break;
  346. }
  347. case SPAWN_SET_VALUE_SHOW_LEVEL:{
  348. sprintf(tmp, "%i", target->GetShowLevel());
  349. target->SetShowLevel(val, send_update);
  350. break;
  351. }
  352. case SPAWN_SET_VALUE_TARGETABLE:{
  353. sprintf(tmp, "%i", target->GetTargetable());
  354. target->SetTargetable(val, send_update);
  355. break;
  356. }
  357. case SPAWN_SET_VALUE_SHOW_COMMAND_ICON:{
  358. sprintf(tmp, "%i", target->GetShowCommandIcon());
  359. target->SetShowCommandIcon(val, send_update);
  360. break;
  361. }
  362. case SPAWN_SET_VALUE_HAND_ICON:{
  363. sprintf(tmp, "%i", target->GetShowHandIcon());
  364. target->SetShowHandIcon(val, send_update);
  365. break;
  366. }
  367. case SPAWN_SET_VALUE_HAIR_TYPE:{
  368. if(target->IsEntity()){
  369. sprintf(tmp, "%i", ((Entity*)target)->GetHairType());
  370. ((Entity*)target)->SetHairType(val, send_update);
  371. }
  372. break;
  373. }
  374. case SPAWN_SET_VALUE_FACIAL_HAIR_TYPE:{
  375. if(target->IsEntity()){
  376. sprintf(tmp, "%i", ((Entity*)target)->GetFacialHairType());
  377. ((Entity*)target)->SetFacialHairType(val, send_update);
  378. }
  379. break;
  380. }
  381. case SPAWN_SET_VALUE_WING_TYPE:{
  382. if(target->IsEntity()){
  383. sprintf(tmp, "%i", ((Entity*)target)->GetWingType());
  384. ((Entity*)target)->SetWingType(val, send_update);
  385. }
  386. break;
  387. }
  388. case SPAWN_SET_VALUE_CHEST_TYPE:{
  389. if(target->IsEntity()){
  390. sprintf(tmp, "%i", ((Entity*)target)->GetChestType());
  391. ((Entity*)target)->SetChestType(val, send_update);
  392. }
  393. break;
  394. }
  395. case SPAWN_SET_VALUE_LEGS_TYPE:{
  396. if(target->IsEntity()){
  397. sprintf(tmp, "%i", ((Entity*)target)->GetLegsType());
  398. ((Entity*)target)->SetLegsType(val, send_update);
  399. }
  400. break;
  401. }
  402. case SPAWN_SET_VALUE_SOGA_HAIR_TYPE:{
  403. if(target->IsEntity()){
  404. sprintf(tmp, "%i", ((Entity*)target)->GetSogaHairType());
  405. ((Entity*)target)->SetSogaHairType(val, send_update);
  406. }
  407. break;
  408. }
  409. case SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE:{
  410. if(target->IsEntity()){
  411. sprintf(tmp, "%i", ((Entity*)target)->GetSogaFacialHairType());
  412. ((Entity*)target)->SetSogaFacialHairType(val, send_update);
  413. }
  414. break;
  415. }
  416. case SPAWN_SET_VALUE_SOGA_MODEL_TYPE:{
  417. sprintf(tmp, "%i", target->GetSogaModelType());
  418. target->SetSogaModelType(val, send_update);
  419. break;
  420. }
  421. case SPAWN_SET_VALUE_SIZE:{
  422. sprintf(tmp, "%i", target->GetSize());
  423. target->SetSize(val, send_update);
  424. break;
  425. }
  426. case SPAWN_SET_VALUE_HP:{
  427. sprintf(tmp, "%i", target->GetHP());
  428. target->SetHP(val, send_update);
  429. break;
  430. }
  431. case SPAWN_SET_VALUE_POWER:{
  432. sprintf(tmp, "%i", target->GetPower());
  433. target->SetPower(val, send_update);
  434. break;
  435. }
  436. case SPAWN_SET_VALUE_HEROIC:{
  437. sprintf(tmp, "%i", target->GetHeroic());
  438. target->SetHeroic(val, send_update);
  439. break;
  440. }
  441. case SPAWN_SET_VALUE_RESPAWN:{
  442. sprintf(tmp, "%u", target->GetRespawnTime());
  443. target->SetRespawnTime(val);
  444. break;
  445. }
  446. case SPAWN_SET_VALUE_X:{
  447. sprintf(tmp, "%f", target->GetX());
  448. target->SetX(atof(value), send_update);
  449. break;
  450. }
  451. case SPAWN_SET_VALUE_Y:{
  452. sprintf(tmp, "%f", target->GetY());
  453. target->SetY(atof(value), send_update);
  454. break;
  455. }
  456. case SPAWN_SET_VALUE_Z:{
  457. sprintf(tmp, "%f", target->GetZ());
  458. target->SetZ(atof(value), send_update);
  459. break;
  460. }
  461. case SPAWN_SET_VALUE_HEADING:{
  462. sprintf(tmp, "%f", target->GetHeading());
  463. target->SetHeading(atof(value) + 360, send_update);
  464. break;
  465. }
  466. case SPAWN_SET_VALUE_VISUAL_STATE:{
  467. sprintf(tmp, "%i", target->GetVisualState());
  468. target->SetVisualState(val, send_update);
  469. break;
  470. }
  471. case SPAWN_SET_VALUE_ACTION_STATE:{
  472. sprintf(tmp, "%i", target->GetActionState());
  473. target->SetActionState(val, send_update);
  474. break;
  475. }
  476. case SPAWN_SET_VALUE_MOOD_STATE:{
  477. sprintf(tmp, "%i", target->GetMoodState());
  478. target->SetMoodState(val, send_update);
  479. break;
  480. }
  481. case SPAWN_SET_VALUE_INITIAL_STATE:{
  482. sprintf(tmp, "%i", target->GetInitialState());
  483. target->SetInitialState(val, send_update);
  484. break;
  485. }
  486. case SPAWN_SET_VALUE_ACTIVITY_STATE:{
  487. sprintf(tmp, "%i", target->GetActivityStatus());
  488. target->SetActivityStatus(val, send_update);
  489. break;
  490. }
  491. case SPAWN_SET_VALUE_COLLISION_RADIUS:{
  492. sprintf(tmp, "%i", target->GetCollisionRadius());
  493. target->SetCollisionRadius(val, send_update);
  494. break;
  495. }
  496. case SPAWN_SET_VALUE_DEVICE_ID: {
  497. if (target->IsObject()) {
  498. sprintf(tmp, "%i", ((Object*)target)->GetDeviceID());
  499. ((Object*)target)->SetDeviceID(val);
  500. }
  501. break;
  502. }
  503. case SPAWN_SET_VALUE_PITCH: {
  504. sprintf(tmp, "%f", target->GetPitch());
  505. target->SetPitch(atof(value), send_update);
  506. break;
  507. }
  508. case SPAWN_SET_VALUE_ROLL: {
  509. sprintf(tmp, "%f", target->GetRoll());
  510. target->SetRoll(atof(value), send_update);
  511. break;
  512. }
  513. case SPAWN_SET_VALUE_HIDE_HOOD: {
  514. sprintf(tmp, "%i", target->appearance.hide_hood);
  515. target->SetHideHood(val);
  516. break;
  517. }
  518. case SPAWN_SET_VALUE_EMOTE_STATE: {
  519. sprintf(tmp, "%i", target->appearance.emote_state);
  520. target->SetEmoteState(val);
  521. break;
  522. }
  523. case SPAWN_SET_VALUE_ICON: {
  524. sprintf(tmp, "%i", target->GetIconValue());
  525. target->SetIcon(val);
  526. break;
  527. }
  528. case SPAWN_SET_VALUE_PREFIX: {
  529. sprintf(tmp, "%s", target->GetPrefixTitle());
  530. target->SetPrefixTitle(value);
  531. if(target->GetZone())
  532. target->GetZone()->SendUpdateTitles(target);
  533. break;
  534. }
  535. case SPAWN_SET_VALUE_SUFFIX: {
  536. sprintf(tmp, "%s", target->GetSuffixTitle());
  537. target->SetSuffixTitle(value);
  538. if(target->GetZone())
  539. target->GetZone()->SendUpdateTitles(target);
  540. break;
  541. }
  542. case SPAWN_SET_VALUE_LASTNAME: {
  543. sprintf(tmp, "%s", target->GetLastName());
  544. target->SetLastName(value);
  545. if(target->GetZone())
  546. target->GetZone()->SendUpdateTitles(target);
  547. break;
  548. }
  549. case SPAWN_SET_VALUE_EXPANSION_FLAG:
  550. case SPAWN_SET_VALUE_HOLIDAY_FLAG: {
  551. // nothing to do must reload spawns
  552. break;
  553. }
  554. case SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL: {
  555. sprintf(tmp, "%i", target->GetMerchantMinLevel());
  556. target->SetMerchantLevelRange(atoul(value), target->GetMerchantMaxLevel());
  557. break;
  558. }
  559. case SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL: {
  560. sprintf(tmp, "%i", target->GetMerchantMaxLevel());
  561. target->SetMerchantLevelRange(target->GetMerchantMinLevel(), atoul(value));
  562. break;
  563. }
  564. case SPAWN_SET_VALUE_FACTION:{
  565. sprintf(tmp, "%i", target->faction_id);
  566. ZoneServer* zone = target->GetZone();
  567. if (!zone && client)
  568. zone = client->GetCurrentZone();
  569. target->faction_id = atoul(value);
  570. if(zone)
  571. {
  572. zone->RemoveDeadEnemyList(target);
  573. if(target->IsNPC())
  574. zone->AddEnemyList((NPC*)target);
  575. }
  576. break;
  577. }
  578. case SPAWN_SET_SKIN_COLOR:
  579. case SPAWN_SET_HAIR_COLOR1:
  580. case SPAWN_SET_HAIR_COLOR2:
  581. case SPAWN_SET_HAIR_TYPE_COLOR:
  582. case SPAWN_SET_HAIR_FACE_COLOR:
  583. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  584. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  585. case SPAWN_SET_HAIR_HIGHLIGHT:
  586. case SPAWN_SET_MODEL_COLOR:
  587. case SPAWN_SET_EYE_COLOR:
  588. case SPAWN_SET_SOGA_SKIN_COLOR:
  589. case SPAWN_SET_SOGA_HAIR_COLOR1:
  590. case SPAWN_SET_SOGA_HAIR_COLOR2:
  591. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  592. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  593. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  594. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  595. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  596. case SPAWN_SET_SOGA_MODEL_COLOR:
  597. case SPAWN_SET_SOGA_EYE_COLOR:
  598. {
  599. if (target->IsEntity())
  600. {
  601. Seperator* skinsep = new Seperator(value, ' ', 3, 500, true);
  602. if (skinsep->IsNumber(0) && skinsep->IsNumber(1) && skinsep->IsNumber(2))
  603. {
  604. EQ2_Color clr;
  605. clr.red = atoul(skinsep->arg[0]);
  606. clr.green = atoul(skinsep->arg[1]);
  607. clr.blue = atoul(skinsep->arg[2]);
  608. switch(type)
  609. {
  610. case SPAWN_SET_SKIN_COLOR:
  611. ((Entity*)target)->SetSkinColor(clr);
  612. break;
  613. case SPAWN_SET_HAIR_COLOR1:
  614. ((Entity*)target)->SetHairColor1(clr);
  615. break;
  616. case SPAWN_SET_HAIR_COLOR2:
  617. ((Entity*)target)->SetHairColor2(clr);
  618. break;
  619. case SPAWN_SET_HAIR_TYPE_COLOR:
  620. ((Entity*)target)->SetHairColor(clr);
  621. break;
  622. case SPAWN_SET_HAIR_FACE_COLOR:
  623. ((Entity*)target)->SetFacialHairColor(clr);
  624. break;
  625. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  626. ((Entity*)target)->SetHairTypeHighlightColor(clr);
  627. break;
  628. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  629. ((Entity*)target)->SetFacialHairHighlightColor(clr);
  630. break;
  631. case SPAWN_SET_HAIR_HIGHLIGHT:
  632. ((Entity*)target)->SetHairHighlightColor(clr);
  633. break;
  634. case SPAWN_SET_MODEL_COLOR:
  635. ((Entity*)target)->SetModelColor(clr);
  636. break;
  637. case SPAWN_SET_EYE_COLOR:
  638. ((Entity*)target)->SetEyeColor(clr);
  639. break;
  640. case SPAWN_SET_SOGA_SKIN_COLOR:
  641. ((Entity*)target)->SetSogaSkinColor(clr);
  642. break;
  643. case SPAWN_SET_SOGA_HAIR_COLOR1:
  644. ((Entity*)target)->SetSogaHairColor1(clr);
  645. break;
  646. case SPAWN_SET_SOGA_HAIR_COLOR2:
  647. ((Entity*)target)->SetSogaHairColor2(clr);
  648. break;
  649. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  650. ((Entity*)target)->SetSogaHairColor(clr);
  651. break;
  652. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  653. ((Entity*)target)->SetSogaFacialHairColor(clr);
  654. break;
  655. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  656. ((Entity*)target)->SetSogaHairTypeHighlightColor(clr);
  657. break;
  658. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  659. ((Entity*)target)->SetSogaFacialHairHighlightColor(clr);
  660. break;
  661. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  662. ((Entity*)target)->SetSogaHairHighlightColor(clr);
  663. break;
  664. case SPAWN_SET_SOGA_MODEL_COLOR:
  665. ((Entity*)target)->SetSogaModelColor(clr);
  666. break;
  667. case SPAWN_SET_SOGA_EYE_COLOR:
  668. ((Entity*)target)->SetSogaEyeColor(clr);
  669. break;
  670. }
  671. }
  672. safe_delete(skinsep);
  673. }
  674. break;
  675. }
  676. case SPAWN_SET_AAXP_REWARDS: {
  677. target->SetAAXPRewards(atoul(value));
  678. break;
  679. }
  680. case SPAWN_SET_CHEEK_TYPE:{
  681. if(target->IsEntity() && index < 3){
  682. sprintf(tmp, "%i", ((Entity*)target)->features.cheek_type[index]);
  683. sint8 new_value = atoi(value);
  684. ((Entity*)target)->features.cheek_type[index] = new_value;
  685. ((Entity*)target)->info_changed = true;
  686. }
  687. break;
  688. }
  689. case SPAWN_SET_CHIN_TYPE:{
  690. if(target->IsEntity() && index < 3){
  691. sprintf(tmp, "%i", ((Entity*)target)->features.chin_type[index]);
  692. sint8 new_value = atoi(value);
  693. ((Entity*)target)->features.chin_type[index] = new_value;
  694. ((Entity*)target)->info_changed = true;
  695. }
  696. break;
  697. }
  698. case SPAWN_SET_EAR_TYPE:{
  699. if(target->IsEntity() && index < 3){
  700. sprintf(tmp, "%i", ((Entity*)target)->features.ear_type[index]);
  701. sint8 new_value = atoi(value);
  702. ((Entity*)target)->features.ear_type[index] = new_value;
  703. ((Entity*)target)->info_changed = true;
  704. }
  705. break;
  706. }
  707. case SPAWN_SET_EYE_BROW_TYPE:{
  708. if(target->IsEntity() && index < 3){
  709. sprintf(tmp, "%i", ((Entity*)target)->features.eye_brow_type[index]);
  710. sint8 new_value = atoi(value);
  711. ((Entity*)target)->features.eye_brow_type[index] = new_value;
  712. ((Entity*)target)->info_changed = true;
  713. }
  714. break;
  715. }
  716. case SPAWN_SET_EYE_TYPE:{
  717. if(target->IsEntity() && index < 3){
  718. sprintf(tmp, "%i", ((Entity*)target)->features.eye_type[index]);
  719. sint8 new_value = atoi(value);
  720. ((Entity*)target)->features.eye_type[index] = new_value;
  721. ((Entity*)target)->info_changed = true;
  722. }
  723. break;
  724. }
  725. case SPAWN_SET_LIP_TYPE:{
  726. if(target->IsEntity() && index < 3){
  727. sprintf(tmp, "%i", ((Entity*)target)->features.lip_type[index]);
  728. sint8 new_value = atoi(value);
  729. ((Entity*)target)->features.lip_type[index] = new_value;
  730. ((Entity*)target)->info_changed = true;
  731. }
  732. break;
  733. }
  734. case SPAWN_SET_NOSE_TYPE:{
  735. if(target->IsEntity() && index < 3){
  736. sprintf(tmp, "%i", ((Entity*)target)->features.nose_type[index]);
  737. sint8 new_value = atoi(value);
  738. ((Entity*)target)->features.nose_type[index] = new_value;
  739. ((Entity*)target)->info_changed = true;
  740. }
  741. break;
  742. }
  743. case SPAWN_SET_BODY_SIZE:{
  744. if(target->IsEntity()){
  745. sprintf(tmp, "%i", ((Entity*)target)->features.body_size);
  746. int8 new_value = atoul(value);
  747. ((Entity*)target)->features.body_size = new_value;
  748. ((Entity*)target)->info_changed = true;
  749. }
  750. break;
  751. }
  752. case SPAWN_SET_BODY_AGE:{
  753. if(target->IsEntity()){
  754. sprintf(tmp, "%i", ((Entity*)target)->features.body_age);
  755. int8 new_value = atoul(value);
  756. ((Entity*)target)->features.body_age = new_value;
  757. ((Entity*)target)->info_changed = true;
  758. }
  759. break;
  760. }
  761. case SPAWN_SET_SOGA_CHEEK_TYPE:{
  762. if(target->IsEntity() && index < 3){
  763. sprintf(tmp, "%i", ((Entity*)target)->features.soga_cheek_type[index]);
  764. sint8 new_value = atoi(value);
  765. ((Entity*)target)->features.soga_cheek_type[index] = new_value;
  766. ((Entity*)target)->info_changed = true;
  767. }
  768. break;
  769. }
  770. case SPAWN_SET_SOGA_CHIN_TYPE:{
  771. if(target->IsEntity() && index < 3){
  772. sprintf(tmp, "%i", ((Entity*)target)->features.soga_chin_type[index]);
  773. sint8 new_value = atoi(value);
  774. ((Entity*)target)->features.soga_chin_type[index] = new_value;
  775. ((Entity*)target)->info_changed = true;
  776. }
  777. break;
  778. }
  779. case SPAWN_SET_SOGA_EAR_TYPE:{
  780. if(target->IsEntity() && index < 3){
  781. sprintf(tmp, "%i", ((Entity*)target)->features.soga_ear_type[index]);
  782. sint8 new_value = atoi(value);
  783. ((Entity*)target)->features.soga_ear_type[index] = new_value;
  784. ((Entity*)target)->info_changed = true;
  785. }
  786. break;
  787. }
  788. case SPAWN_SET_SOGA_EYE_BROW_TYPE:{
  789. if(target->IsEntity() && index < 3){
  790. sprintf(tmp, "%i", ((Entity*)target)->features.soga_eye_brow_type[index]);
  791. sint8 new_value = atoi(value);
  792. ((Entity*)target)->features.soga_eye_brow_type[index] = new_value;
  793. ((Entity*)target)->info_changed = true;
  794. }
  795. break;
  796. }
  797. case SPAWN_SET_SOGA_EYE_TYPE:{
  798. if(target->IsEntity() && index < 3){
  799. sprintf(tmp, "%i", ((Entity*)target)->features.soga_eye_type[index]);
  800. sint8 new_value = atoi(value);
  801. ((Entity*)target)->features.soga_eye_type[index] = new_value;
  802. ((Entity*)target)->info_changed = true;
  803. }
  804. break;
  805. }
  806. case SPAWN_SET_SOGA_LIP_TYPE:{
  807. if(target->IsEntity() && index < 3){
  808. sprintf(tmp, "%i", ((Entity*)target)->features.soga_lip_type[index]);
  809. sint8 new_value = atoi(value);
  810. ((Entity*)target)->features.soga_lip_type[index] = new_value;
  811. ((Entity*)target)->info_changed = true;
  812. }
  813. break;
  814. }
  815. case SPAWN_SET_SOGA_BODY_SIZE:{
  816. if(target->IsEntity()){
  817. sprintf(tmp, "%i", ((Entity*)target)->features.soga_body_size);
  818. int8 new_value = atoul(value);
  819. ((Entity*)target)->features.soga_body_size = new_value;
  820. ((Entity*)target)->info_changed = true;
  821. }
  822. break;
  823. }
  824. case SPAWN_SET_SOGA_BODY_AGE:{
  825. if(target->IsEntity()){
  826. sprintf(tmp, "%i", ((Entity*)target)->features.soga_body_age);
  827. int8 new_value = atoul(value);
  828. ((Entity*)target)->features.soga_body_age = new_value;
  829. ((Entity*)target)->info_changed = true;
  830. }
  831. break;
  832. }
  833. case SPAWN_SET_ATTACK_TYPE:{
  834. if(target->IsEntity()){
  835. sprintf(tmp, "%u", ((Entity*)target)->GetInfoStruct()->get_attack_type());
  836. int8 new_value = atoul(value);
  837. ((Entity*)target)->GetInfoStruct()->set_attack_type(new_value);
  838. }
  839. break;
  840. }
  841. case SPAWN_SET_RACE_TYPE:{
  842. if(target->GetModelType() > 0){
  843. Seperator* tmpsep = new Seperator(value, ' ', 3, 500, true);
  844. if (tmpsep->IsNumber(0))
  845. {
  846. int16 race_type = atoul(value);
  847. const char* category = tmpsep->IsSet(1) ? tmpsep->arg[1] : "NULL";
  848. const char* subcategory = tmpsep->IsSet(2) ? tmpsep->arg[2] : "NULL";
  849. const char* model_name = tmpsep->IsSet(3) ? tmpsep->arg[3] : "NULL";
  850. if(race_types_list.AddRaceType(target->GetModelType(), race_type, category, subcategory, model_name)) {
  851. if(client) {
  852. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Race type added to memory, however not saved to database.");
  853. }
  854. }
  855. else {
  856. client->SimpleMessage(CHANNEL_COLOR_RED, "Model type already on the race_types_list, use spawn set database to override and update database.");
  857. }
  858. }
  859. safe_delete(tmpsep);
  860. }
  861. break;
  862. }
  863. case SPAWN_SET_LOOT_TIER:{
  864. if(target->IsEntity()){
  865. sprintf(tmp, "%u", target->GetLootTier());
  866. int32 new_value = atoul(value);
  867. target->SetLootTier(new_value);
  868. }
  869. break;
  870. }
  871. case SPAWN_SET_LOOT_DROP_TYPE:{
  872. if(target->IsEntity()){
  873. sprintf(tmp, "%u", target->GetLootDropType());
  874. int32 new_value = atoul(value);
  875. target->SetLootDropType(new_value);
  876. }
  877. break;
  878. }
  879. case SPAWN_SET_SCARED_STRONG_PLAYERS:{
  880. if(target->IsNPC()){
  881. sprintf(tmp, "%u", target->IsScaredByStrongPlayers());
  882. int32 new_value = atoul(value);
  883. target->SetScaredByStrongPlayers(new_value);
  884. }
  885. break;
  886. }
  887. if(temp_value)
  888. *temp_value = string(tmp);
  889. }
  890. }
  891. else{
  892. /**** NOT TEMPORARY ELSE STATEMENT ****/
  893. /**** MUST RE-DEFINE WHAT IS ALREADY IN THE IF TEMPORARY BLOCK HERE ****/
  894. switch(type){
  895. case SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL: {
  896. target->SetMerchantLevelRange(atoul(value), target->GetMerchantMaxLevel());
  897. break;
  898. }
  899. case SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL: {
  900. target->SetMerchantLevelRange(target->GetMerchantMinLevel(), atoul(value));
  901. break;
  902. }
  903. case SPAWN_SET_VALUE_EXPANSION_FLAG: {
  904. if (target->GetDatabaseID() > 0)
  905. {
  906. char query[256];
  907. snprintf(query, 256, "update spawn set expansion_flag=%u where id=%u", atoul(value), target->GetDatabaseID());
  908. if (database.RunQuery(query, strnlen(query, 256)))
  909. {
  910. if(client)
  911. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  912. }
  913. }
  914. break;
  915. }
  916. case SPAWN_SET_VALUE_HOLIDAY_FLAG: {
  917. if (target->GetDatabaseID() > 0)
  918. {
  919. char query[256];
  920. snprintf(query, 256, "update spawn set holiday_flag=%u where id=%u", atoul(value), target->GetDatabaseID());
  921. if (database.RunQuery(query, strnlen(query, 256)))
  922. {
  923. if(client)
  924. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  925. }
  926. }
  927. break;
  928. }
  929. case SPAWN_SET_AAXP_REWARDS: {
  930. if (target->GetDatabaseID() > 0)
  931. {
  932. char query[256];
  933. snprintf(query, 256, "update spawn set aaxp_rewards=%u where id=%u", atoul(value), target->GetDatabaseID());
  934. if (database.RunQuery(query, strnlen(query, 256)))
  935. {
  936. if(client)
  937. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  938. }
  939. }
  940. break;
  941. }
  942. case SPAWN_SET_VALUE_NAME:{
  943. target->SetName(value);
  944. if(target->GetZone())
  945. target->GetZone()->SendUpdateTitles(target);
  946. break;
  947. }
  948. case SPAWN_SET_VALUE_SUB_TITLE: {
  949. target->SetSubTitle(value);
  950. if(target->GetZone())
  951. target->GetZone()->SendUpdateTitles(target);
  952. break;
  953. }
  954. case SPAWN_SET_VALUE_X_OFFSET:
  955. {
  956. target->SetXOffset(atof(value));
  957. break;
  958. }
  959. case SPAWN_SET_VALUE_Y_OFFSET:
  960. {
  961. target->SetYOffset(atof(value));
  962. break;
  963. }
  964. case SPAWN_SET_VALUE_Z_OFFSET:
  965. {
  966. target->SetZOffset(atof(value));
  967. break;
  968. }
  969. case SPAWN_SET_VALUE_EXPIRE: {
  970. target->SetExpireTime(val);
  971. break;
  972. }
  973. case SPAWN_SET_VALUE_EXPIRE_OFFSET: {
  974. target->SetExpireOffsetTime(val);
  975. break;
  976. }
  977. case SPAWN_SET_VALUE_LEVEL:{
  978. target->SetLevel(val, send_update);
  979. break;
  980. }
  981. case SPAWN_SET_VALUE_DIFFICULTY:{
  982. target->SetDifficulty(val, send_update);
  983. break;
  984. }
  985. case SPAWN_SET_VALUE_MODEL_TYPE:{
  986. target->SetModelType(val, send_update);
  987. break;
  988. }
  989. case SPAWN_SET_VALUE_CLASS:{
  990. target->SetAdventureClass(val, send_update);
  991. break;
  992. }
  993. case SPAWN_SET_VALUE_GENDER:{
  994. target->SetGender(val, send_update);
  995. break;
  996. }
  997. case SPAWN_SET_VALUE_SHOW_NAME:{
  998. target->SetShowName(val, send_update);
  999. break;
  1000. }
  1001. case SPAWN_SET_VALUE_ATTACKABLE:{
  1002. target->SetAttackable(val, send_update);
  1003. break;
  1004. }
  1005. case SPAWN_SET_VALUE_SHOW_LEVEL:{
  1006. target->SetShowLevel(val, send_update);
  1007. break;
  1008. }
  1009. case SPAWN_SET_VALUE_TARGETABLE:{
  1010. target->SetTargetable(val, send_update);
  1011. break;
  1012. }
  1013. case SPAWN_SET_VALUE_SHOW_COMMAND_ICON:{
  1014. target->SetShowCommandIcon(val, send_update);
  1015. break;
  1016. }
  1017. case SPAWN_SET_VALUE_HAND_ICON:{
  1018. target->SetShowHandIcon(val, send_update);
  1019. break;
  1020. }
  1021. case SPAWN_SET_VALUE_HAIR_TYPE:{
  1022. if(target->IsEntity())
  1023. ((Entity*)target)->SetHairType(val, send_update);
  1024. break;
  1025. }
  1026. case SPAWN_SET_VALUE_FACIAL_HAIR_TYPE:{
  1027. if(target->IsEntity())
  1028. ((Entity*)target)->SetFacialHairType(val, send_update);
  1029. break;
  1030. }
  1031. case SPAWN_SET_VALUE_WING_TYPE:{
  1032. if(target->IsEntity())
  1033. ((Entity*)target)->SetWingType(val, send_update);
  1034. break;
  1035. }
  1036. case SPAWN_SET_VALUE_CHEST_TYPE:{
  1037. if(target->IsEntity())
  1038. ((Entity*)target)->SetChestType(val, send_update);
  1039. break;
  1040. }
  1041. case SPAWN_SET_VALUE_LEGS_TYPE:{
  1042. if(target->IsEntity())
  1043. ((Entity*)target)->SetLegsType(val, send_update);
  1044. break;
  1045. }
  1046. case SPAWN_SET_VALUE_SOGA_HAIR_TYPE:{
  1047. if(target->IsEntity())
  1048. ((Entity*)target)->SetSogaHairType(val, send_update);
  1049. break;
  1050. }
  1051. case SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE:{
  1052. if(target->IsEntity())
  1053. ((Entity*)target)->SetSogaFacialHairType(val, send_update);
  1054. break;
  1055. }
  1056. case SPAWN_SET_VALUE_SOGA_MODEL_TYPE:{
  1057. target->SetSogaModelType(val, send_update);
  1058. break;
  1059. }
  1060. case SPAWN_SET_VALUE_SIZE:{
  1061. target->SetSize(val, send_update);
  1062. break;
  1063. }
  1064. case SPAWN_SET_VALUE_HP:{
  1065. target->SetHP(val, send_update);
  1066. break;
  1067. }
  1068. case SPAWN_SET_VALUE_POWER:{
  1069. target->SetPower(val, send_update);
  1070. break;
  1071. }
  1072. case SPAWN_SET_VALUE_HEROIC:{
  1073. target->SetHeroic(val, send_update);
  1074. break;
  1075. }
  1076. case SPAWN_SET_VALUE_RESPAWN:{
  1077. target->SetRespawnTime(val);
  1078. break;
  1079. }
  1080. case SPAWN_SET_VALUE_X:{
  1081. target->SetX(atof(value), send_update);
  1082. target->SetSpawnOrigX(target->GetX());
  1083. break;
  1084. }
  1085. case SPAWN_SET_VALUE_Y:{
  1086. target->SetY(atof(value), send_update);
  1087. target->SetSpawnOrigY(target->GetY());
  1088. break;
  1089. }
  1090. case SPAWN_SET_VALUE_Z:{
  1091. target->SetZ(atof(value), send_update);
  1092. target->SetSpawnOrigZ(target->GetZ());
  1093. break;
  1094. }
  1095. case SPAWN_SET_VALUE_HEADING:{
  1096. target->SetHeading(atof(value), send_update);
  1097. target->SetSpawnOrigHeading(target->GetHeading());
  1098. break;
  1099. }
  1100. case SPAWN_SET_VALUE_COMMAND_PRIMARY:{
  1101. ZoneServer* zone = target->GetZone();
  1102. if (!zone && client)
  1103. zone = client->GetCurrentZone();
  1104. if(zone && zone->GetEntityCommandList(val))
  1105. target->SetPrimaryCommands(zone->GetEntityCommandList(val));
  1106. target->primary_command_list_id = val;
  1107. break;
  1108. }
  1109. case SPAWN_SET_VALUE_COMMAND_SECONDARY:{
  1110. ZoneServer* zone = target->GetZone();
  1111. if (!zone && client)
  1112. zone = client->GetCurrentZone();
  1113. if (zone && zone->GetEntityCommandList(val))
  1114. target->SetSecondaryCommands(zone->GetEntityCommandList(val));
  1115. target->secondary_command_list_id = val;
  1116. break;
  1117. }
  1118. case SPAWN_SET_VALUE_VISUAL_STATE:{
  1119. target->SetVisualState(val, send_update);
  1120. break;
  1121. }
  1122. case SPAWN_SET_VALUE_ACTION_STATE:{
  1123. target->SetActionState(val, send_update);
  1124. break;
  1125. }
  1126. case SPAWN_SET_VALUE_MOOD_STATE:{
  1127. target->SetMoodState(val, send_update);
  1128. break;
  1129. }
  1130. case SPAWN_SET_VALUE_INITIAL_STATE:{
  1131. target->SetInitialState(val, send_update);
  1132. break;
  1133. }
  1134. case SPAWN_SET_VALUE_ACTIVITY_STATE:{
  1135. target->SetActivityStatus(val, send_update);
  1136. break;
  1137. }
  1138. case SPAWN_SET_VALUE_COLLISION_RADIUS:{
  1139. target->SetCollisionRadius(val, send_update);
  1140. break;
  1141. }
  1142. case SPAWN_SET_VALUE_FACTION:{
  1143. ZoneServer* zone = target->GetZone();
  1144. if (!zone && client)
  1145. zone = client->GetCurrentZone();
  1146. target->faction_id = val;
  1147. if(zone)
  1148. {
  1149. zone->RemoveDeadEnemyList(target);
  1150. if(target->IsNPC())
  1151. zone->AddEnemyList((NPC*)target);
  1152. }
  1153. break;
  1154. }
  1155. case SPAWN_SET_VALUE_DEVICE_ID:{
  1156. if (target->IsObject())
  1157. ((Object*)target)->SetDeviceID(val);
  1158. break;
  1159. }
  1160. case SPAWN_SET_VALUE_PITCH: {
  1161. target->SetPitch(atof(value), send_update);
  1162. target->SetSpawnOrigPitch(atof(value));
  1163. break;
  1164. }
  1165. case SPAWN_SET_VALUE_ROLL: {
  1166. target->SetRoll(atof(value), send_update);
  1167. target->SetSpawnOrigRoll(atof(value));
  1168. break;
  1169. }
  1170. case SPAWN_SET_VALUE_HIDE_HOOD: {
  1171. target->SetHideHood(val);
  1172. break;
  1173. }
  1174. case SPAWN_SET_VALUE_EMOTE_STATE: {
  1175. target->SetEmoteState(val);
  1176. break;
  1177. }
  1178. case SPAWN_SET_VALUE_ICON: {
  1179. target->SetIcon(val);
  1180. break;
  1181. }
  1182. case SPAWN_SET_VALUE_PREFIX: {
  1183. target->SetPrefixTitle(value);
  1184. if(target->GetZone())
  1185. target->GetZone()->SendUpdateTitles(target);
  1186. break;
  1187. }
  1188. case SPAWN_SET_VALUE_SUFFIX: {
  1189. target->SetSuffixTitle(value);
  1190. if(target->GetZone())
  1191. target->GetZone()->SendUpdateTitles(target);
  1192. break;
  1193. }
  1194. case SPAWN_SET_VALUE_LASTNAME: {
  1195. target->SetLastName(value);
  1196. if(target->GetZone())
  1197. target->GetZone()->SendUpdateTitles(target);
  1198. break;
  1199. }
  1200. case SPAWN_SET_VALUE_SPAWN_SCRIPT:{
  1201. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  1202. if(client){
  1203. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  1204. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawn_script 'SpawnScripts/example.lua'");
  1205. }
  1206. return false;
  1207. }
  1208. else if(!database.UpdateSpawnScriptData(target->GetDatabaseID(), 0, 0, value))
  1209. return false;
  1210. else{
  1211. if(!world.GetSpawnLocationScript(target->GetSpawnLocationID()))
  1212. target->SetSpawnScript(value);
  1213. }
  1214. break;
  1215. }
  1216. case SPAWN_SET_VALUE_SPAWNLOCATION_SCRIPT:{
  1217. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  1218. if(client){
  1219. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  1220. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawnlocation_script 'SpawnScripts/example.lua'");
  1221. }
  1222. return false;
  1223. }
  1224. else if(!database.UpdateSpawnScriptData(0, target->GetSpawnLocationID(), 0, value))
  1225. return false;
  1226. else{
  1227. if(!world.GetSpawnEntryScript(target->GetSpawnEntryID()))
  1228. target->SetSpawnScript(value);
  1229. }
  1230. break;
  1231. }
  1232. case SPAWN_SET_VALUE_SPAWNENTRY_SCRIPT:{
  1233. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  1234. if(client){
  1235. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  1236. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawnentry_script 'SpawnScripts/example.lua'");
  1237. }
  1238. return false;
  1239. }
  1240. else if(!database.UpdateSpawnScriptData(0, 0, target->GetSpawnEntryID(), value))
  1241. return false;
  1242. else
  1243. target->SetSpawnScript(value);
  1244. break;
  1245. }
  1246. case SPAWN_SET_SKIN_COLOR:
  1247. case SPAWN_SET_HAIR_COLOR1:
  1248. case SPAWN_SET_HAIR_COLOR2:
  1249. case SPAWN_SET_HAIR_TYPE_COLOR:
  1250. case SPAWN_SET_HAIR_FACE_COLOR:
  1251. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  1252. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  1253. case SPAWN_SET_HAIR_HIGHLIGHT:
  1254. case SPAWN_SET_MODEL_COLOR:
  1255. case SPAWN_SET_EYE_COLOR:
  1256. case SPAWN_SET_SOGA_SKIN_COLOR:
  1257. case SPAWN_SET_SOGA_HAIR_COLOR1:
  1258. case SPAWN_SET_SOGA_HAIR_COLOR2:
  1259. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  1260. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  1261. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  1262. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  1263. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  1264. case SPAWN_SET_SOGA_MODEL_COLOR:
  1265. case SPAWN_SET_SOGA_EYE_COLOR: {
  1266. if (target->IsNPC())
  1267. {
  1268. Seperator* skinsep = new Seperator(value, ' ', 3, 500, true);
  1269. if (skinsep->IsNumber(0) && skinsep->IsNumber(1) && skinsep->IsNumber(2))
  1270. {
  1271. EQ2_Color clr;
  1272. clr.red = atoul(skinsep->arg[0]);
  1273. clr.green = atoul(skinsep->arg[1]);
  1274. clr.blue = atoul(skinsep->arg[2]);
  1275. Query replaceSkinQuery;
  1276. string fieldName("");
  1277. switch(type)
  1278. {
  1279. case SPAWN_SET_SKIN_COLOR:
  1280. ((Entity*)target)->SetSkinColor(clr);
  1281. fieldName.append("skin_color");
  1282. break;
  1283. case SPAWN_SET_HAIR_COLOR1:
  1284. ((Entity*)target)->SetHairColor1(clr);
  1285. fieldName.append("hair_color1");
  1286. break;
  1287. case SPAWN_SET_HAIR_COLOR2:
  1288. ((Entity*)target)->SetHairColor2(clr);
  1289. fieldName.append("hair_color2");
  1290. break;
  1291. case SPAWN_SET_HAIR_TYPE_COLOR:
  1292. ((Entity*)target)->SetHairColor(clr);
  1293. fieldName.append("hair_type_color");
  1294. break;
  1295. case SPAWN_SET_HAIR_FACE_COLOR:
  1296. ((Entity*)target)->SetFacialHairColor(clr);
  1297. fieldName.append("hair_face_color");
  1298. break;
  1299. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  1300. ((Entity*)target)->SetHairTypeHighlightColor(clr);
  1301. fieldName.append("hair_type_highlight_color");
  1302. break;
  1303. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  1304. ((Entity*)target)->SetFacialHairHighlightColor(clr);
  1305. fieldName.append("hair_face_highlight_color");
  1306. break;
  1307. case SPAWN_SET_HAIR_HIGHLIGHT:
  1308. ((Entity*)target)->SetHairHighlightColor(clr);
  1309. fieldName.append("hair_highlight");
  1310. break;
  1311. case SPAWN_SET_MODEL_COLOR:
  1312. ((Entity*)target)->SetModelColor(clr);
  1313. fieldName.append("model_color");
  1314. break;
  1315. case SPAWN_SET_EYE_COLOR:
  1316. ((Entity*)target)->SetEyeColor(clr);
  1317. fieldName.append("eye_color");
  1318. break;
  1319. case SPAWN_SET_SOGA_SKIN_COLOR:
  1320. ((Entity*)target)->SetSogaSkinColor(clr);
  1321. fieldName.append("soga_skin_color");
  1322. break;
  1323. case SPAWN_SET_SOGA_HAIR_COLOR1:
  1324. ((Entity*)target)->SetSogaHairColor1(clr);
  1325. fieldName.append("soga_hair_color1");
  1326. break;
  1327. case SPAWN_SET_SOGA_HAIR_COLOR2:
  1328. ((Entity*)target)->SetSogaHairColor2(clr);
  1329. fieldName.append("soga_hair_color2");
  1330. break;
  1331. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  1332. ((Entity*)target)->SetSogaHairColor(clr);
  1333. fieldName.append("soga_hair_type_color");
  1334. break;
  1335. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  1336. ((Entity*)target)->SetSogaFacialHairColor(clr);
  1337. fieldName.append("soga_hair_face_color");
  1338. break;
  1339. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  1340. ((Entity*)target)->SetSogaHairTypeHighlightColor(clr);
  1341. fieldName.append("soga_hair_type_highlight_color");
  1342. break;
  1343. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  1344. ((Entity*)target)->SetSogaFacialHairHighlightColor(clr);
  1345. fieldName.append("soga_hair_face_highlight_color");
  1346. break;
  1347. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  1348. ((Entity*)target)->SetSogaHairHighlightColor(clr);
  1349. fieldName.append("soga_hair_highlight");
  1350. break;
  1351. case SPAWN_SET_SOGA_MODEL_COLOR:
  1352. ((Entity*)target)->SetSogaModelColor(clr);
  1353. fieldName.append("soga_model_color");
  1354. break;
  1355. case SPAWN_SET_SOGA_EYE_COLOR:
  1356. ((Entity*)target)->SetSogaEyeColor(clr);
  1357. fieldName.append("soga_eye_color");
  1358. break;
  1359. }
  1360. replaceSkinQuery.AddQueryAsync(0, &database, Q_DELETE, "delete from npc_appearance where spawn_id=%u and type='%s'", target->GetDatabaseID(), fieldName.c_str());
  1361. 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);
  1362. }
  1363. safe_delete(skinsep);
  1364. }
  1365. break;
  1366. }
  1367. case SPAWN_SET_CHEEK_TYPE:{
  1368. if(target->IsEntity() && index < 3){
  1369. sint8 new_value = atoi(value);
  1370. ((Entity*)target)->features.cheek_type[index] = new_value;
  1371. UpdateDatabaseAppearance(client, target, "cheek_type", ((Entity*)target)->features.cheek_type[0], ((Entity*)target)->features.cheek_type[1], ((Entity*)target)->features.cheek_type[2]);
  1372. }
  1373. break;
  1374. }
  1375. case SPAWN_SET_CHIN_TYPE:{
  1376. if(target->IsEntity() && index < 3){
  1377. sint8 new_value = atoi(value);
  1378. ((Entity*)target)->features.chin_type[index] = new_value;
  1379. UpdateDatabaseAppearance(client, target, "chin_type", ((Entity*)target)->features.chin_type[0], ((Entity*)target)->features.chin_type[1], ((Entity*)target)->features.chin_type[2]);
  1380. }
  1381. break;
  1382. }
  1383. case SPAWN_SET_EAR_TYPE:{
  1384. if(target->IsEntity() && index < 3){
  1385. sint8 new_value = atoi(value);
  1386. ((Entity*)target)->features.ear_type[index] = new_value;
  1387. UpdateDatabaseAppearance(client, target, "ear_type", ((Entity*)target)->features.ear_type[0], ((Entity*)target)->features.ear_type[1], ((Entity*)target)->features.ear_type[2]);
  1388. }
  1389. break;
  1390. }
  1391. case SPAWN_SET_EYE_BROW_TYPE:{
  1392. if(target->IsEntity() && index < 3){
  1393. sint8 new_value = atoi(value);
  1394. ((Entity*)target)->features.eye_brow_type[index] = new_value;
  1395. 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]);
  1396. }
  1397. break;
  1398. }
  1399. case SPAWN_SET_EYE_TYPE:{
  1400. if(target->IsEntity() && index < 3){
  1401. sint8 new_value = atoi(value);
  1402. ((Entity*)target)->features.eye_type[index] = new_value;
  1403. UpdateDatabaseAppearance(client, target, "eye_type", ((Entity*)target)->features.eye_type[0], ((Entity*)target)->features.eye_type[1], ((Entity*)target)->features.eye_type[2]);
  1404. }
  1405. break;
  1406. }
  1407. case SPAWN_SET_LIP_TYPE:{
  1408. if(target->IsEntity() && index < 3){
  1409. sint8 new_value = atoi(value);
  1410. ((Entity*)target)->features.lip_type[index] = new_value;
  1411. UpdateDatabaseAppearance(client, target, "lip_type", ((Entity*)target)->features.lip_type[0], ((Entity*)target)->features.lip_type[1], ((Entity*)target)->features.lip_type[2]);
  1412. }
  1413. break;
  1414. }
  1415. case SPAWN_SET_NOSE_TYPE:{
  1416. if(target->IsEntity() && index < 3){
  1417. sint8 new_value = atoi(value);
  1418. ((Entity*)target)->features.nose_type[index] = new_value;
  1419. UpdateDatabaseAppearance(client, target, "nose_type", ((Entity*)target)->features.nose_type[0], ((Entity*)target)->features.nose_type[1], ((Entity*)target)->features.nose_type[2]);
  1420. }
  1421. break;
  1422. }
  1423. case SPAWN_SET_BODY_SIZE:{
  1424. if(target->IsEntity()){
  1425. int8 new_value = atoul(value);
  1426. ((Entity*)target)->features.body_size = new_value;
  1427. UpdateDatabaseAppearance(client, target, "body_size", ((Entity*)target)->features.body_size, 0, 0);
  1428. }
  1429. break;
  1430. }
  1431. case SPAWN_SET_BODY_AGE:{
  1432. if(target->IsEntity()){
  1433. int8 new_value = atoul(value);
  1434. ((Entity*)target)->features.body_age = new_value;
  1435. UpdateDatabaseAppearance(client, target, "body_age", ((Entity*)target)->features.body_age, 0, 0);
  1436. }
  1437. break;
  1438. }
  1439. case SPAWN_SET_SOGA_CHEEK_TYPE:{
  1440. if(target->IsEntity() && index < 3){
  1441. sint8 new_value = atoi(value);
  1442. ((Entity*)target)->features.soga_cheek_type[index] = new_value;
  1443. 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]);
  1444. }
  1445. break;
  1446. }
  1447. case SPAWN_SET_SOGA_CHIN_TYPE:{
  1448. if(target->IsEntity() && index < 3){
  1449. sint8 new_value = atoi(value);
  1450. ((Entity*)target)->features.soga_chin_type[index] = new_value;
  1451. 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]);
  1452. }
  1453. break;
  1454. }
  1455. case SPAWN_SET_SOGA_EAR_TYPE:{
  1456. if(target->IsEntity() && index < 3){
  1457. sint8 new_value = atoi(value);
  1458. ((Entity*)target)->features.soga_ear_type[index] = new_value;
  1459. 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]);
  1460. }
  1461. break;
  1462. }
  1463. case SPAWN_SET_SOGA_EYE_BROW_TYPE:{
  1464. if(target->IsEntity() && index < 3){
  1465. sint8 new_value = atoi(value);
  1466. ((Entity*)target)->features.soga_eye_brow_type[index] = new_value;
  1467. 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]);
  1468. }
  1469. break;
  1470. }
  1471. case SPAWN_SET_SOGA_EYE_TYPE:{
  1472. if(target->IsEntity() && index < 3){
  1473. sint8 new_value = atoi(value);
  1474. ((Entity*)target)->features.soga_eye_type[index] = new_value;
  1475. 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]);
  1476. }
  1477. break;
  1478. }
  1479. case SPAWN_SET_SOGA_LIP_TYPE:{
  1480. if(target->IsEntity() && index < 3){
  1481. sint8 new_value = atoi(value);
  1482. ((Entity*)target)->features.soga_lip_type[index] = new_value;
  1483. 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]);
  1484. }
  1485. break;
  1486. }
  1487. case SPAWN_SET_SOGA_NOSE_TYPE:{
  1488. if(target->IsEntity() && index < 3){
  1489. sint8 new_value = atoi(value);
  1490. ((Entity*)target)->features.soga_nose_type[index] = new_value;
  1491. 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]);
  1492. }
  1493. break;
  1494. }
  1495. case SPAWN_SET_SOGA_BODY_SIZE:{
  1496. if(target->IsEntity()){
  1497. int8 new_value = atoul(value);
  1498. ((Entity*)target)->features.body_size = new_value;
  1499. UpdateDatabaseAppearance(client, target, "body_size", ((Entity*)target)->features.body_size, 0, 0);
  1500. }
  1501. break;
  1502. }
  1503. case SPAWN_SET_SOGA_BODY_AGE:{
  1504. if(target->IsEntity()){
  1505. int8 new_value = atoul(value);
  1506. ((Entity*)target)->features.body_age = new_value;
  1507. UpdateDatabaseAppearance(client, target, "body_age", ((Entity*)target)->features.body_age, 0, 0);
  1508. }
  1509. break;
  1510. }
  1511. case SPAWN_SET_ATTACK_TYPE:{
  1512. if(target->IsEntity()){
  1513. int8 new_value = atoul(value);
  1514. ((Entity*)target)->GetInfoStruct()->set_attack_type(new_value);
  1515. if(target->IsNPC()) {
  1516. if(target->GetDatabaseID()) {
  1517. Query spawnNPCQuery;
  1518. spawnNPCQuery.AddQueryAsync(0, &database, Q_INSERT, "update spawn_npcs set attack_type=%u where id=%u", new_value, target->GetDatabaseID());
  1519. } else if(client) {
  1520. client->Message(CHANNEL_COLOR_RED, "Invalid spawn to update the database (NPC only) or no database id for the NPC present.");
  1521. }
  1522. }
  1523. }
  1524. break;
  1525. }
  1526. case SPAWN_SET_RACE_TYPE:{
  1527. if(target->GetModelType() > 0){
  1528. Seperator* tmpsep = new Seperator(value, ' ', 3, 500, true);
  1529. if (tmpsep->IsNumber(0))
  1530. {
  1531. Query typequery;
  1532. int16 race_type = atoul(value);
  1533. const char* category = tmpsep->IsSet(1) ? tmpsep->arg[1] : "NULL";
  1534. const char* subcategory = tmpsep->IsSet(2) ? tmpsep->arg[2] : "NULL";
  1535. const char* model_name = tmpsep->IsSet(3) ? tmpsep->arg[3] : "NULL";
  1536. if(race_types_list.AddRaceType(target->GetModelType(), race_type, category, subcategory, model_name)) {
  1537. 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);
  1538. 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);
  1539. }
  1540. else {
  1541. 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);
  1542. race_types_list.AddRaceType(target->GetModelType(), race_type, category, subcategory, model_name, true);
  1543. 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());
  1544. }
  1545. }
  1546. safe_delete(tmpsep);
  1547. }
  1548. break;
  1549. }
  1550. case SPAWN_SET_LOOT_TIER:{
  1551. int32 new_value = atoul(value);
  1552. target->SetLootTier(new_value);
  1553. if (target->GetDatabaseID() > 0)
  1554. {
  1555. char query[256];
  1556. snprintf(query, 256, "update spawn set loot_tier=%u where id=%u", atoul(value), target->GetDatabaseID());
  1557. if (database.RunQuery(query, strnlen(query, 256)))
  1558. {
  1559. if(client)
  1560. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  1561. }
  1562. }
  1563. break;
  1564. }
  1565. case SPAWN_SET_LOOT_DROP_TYPE:{
  1566. int32 new_value = atoul(value);
  1567. target->SetLootDropType(new_value);
  1568. if (target->GetDatabaseID() > 0)
  1569. {
  1570. char query[256];
  1571. snprintf(query, 256, "update spawn set loot_drop_type=%u where id=%u", atoul(value), target->GetDatabaseID());
  1572. if (database.RunQuery(query, strnlen(query, 256)))
  1573. {
  1574. if(client)
  1575. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  1576. }
  1577. }
  1578. break;
  1579. }
  1580. case SPAWN_SET_SCARED_STRONG_PLAYERS:{
  1581. int32 new_value = atoul(value);
  1582. target->SetScaredByStrongPlayers(new_value);
  1583. if (target->GetDatabaseID() > 0)
  1584. {
  1585. char query[256];
  1586. snprintf(query, 256, "update spawn_npcs set scared_by_strong_players=%u where id=%u", atoul(value), target->GetDatabaseID());
  1587. if (database.RunQuery(query, strnlen(query, 256)))
  1588. {
  1589. if(client)
  1590. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  1591. }
  1592. }
  1593. break;
  1594. }
  1595. }
  1596. }
  1597. return true;
  1598. }
  1599. void Commands::UpdateDatabaseAppearance(Client* client, Spawn* target, string fieldName, sint8 r, sint8 g, sint8 b)
  1600. {
  1601. Query replaceQuery;
  1602. if(target->IsBot())
  1603. {
  1604. Bot* bot = (Bot*)target;
  1605. if(bot->BotID)
  1606. database.SaveBotFloats(bot->BotID, fieldName.c_str(), r, g, b);
  1607. }
  1608. else if(target->IsPlayer())
  1609. {
  1610. replaceQuery.AddQueryAsync(0, &database, Q_DELETE, "delete from char_colors where char_id=%u and type='%s'", ((Player*)target)->GetCharacterID(), fieldName.c_str());
  1611. 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);
  1612. }
  1613. else
  1614. {
  1615. replaceQuery.AddQueryAsync(0, &database, Q_DELETE, "delete from npc_appearance where spawn_id=%u and type='%s'", target->GetDatabaseID(), fieldName.c_str());
  1616. 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);
  1617. }
  1618. ((Entity*)target)->changed = true;
  1619. ((Entity*)target)->info_changed = true;
  1620. if(target->GetZone())
  1621. target->GetZone()->AddChangedSpawn(target);
  1622. }
  1623. /* The zone object will be NULL if the zone is not currently running. We pass both of these in so we can update
  1624. the database fields always and also update the zone in memory if it's running. */
  1625. bool Commands::SetZoneCommand(Client* client, int32 zone_id, ZoneServer* zone, int8 type, const char* value) {
  1626. if (client && zone_id > 0 && type > 0 && value) {
  1627. sint32 int_value = 0;
  1628. float float_value = 0;
  1629. if (type == ZONE_SET_VALUE_SAFE_X || type == ZONE_SET_VALUE_SAFE_Y || type == ZONE_SET_VALUE_SAFE_Z || type == ZONE_SET_VALUE_UNDERWORLD) {
  1630. try {
  1631. float_value = atof(value);
  1632. }
  1633. catch (...) {
  1634. client->Message(CHANNEL_COLOR_RED, "Error converting '%s' to a float value", value);
  1635. return false;
  1636. }
  1637. }
  1638. 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) {
  1639. try {
  1640. int_value = atoi(value);
  1641. }
  1642. catch (...) {
  1643. client->Message(CHANNEL_COLOR_RED, "Error converting '%s' to an integer value", value);
  1644. return false;
  1645. }
  1646. }
  1647. switch (type) {
  1648. case ZONE_SET_VALUE_EXPANSION_ID: {
  1649. break;
  1650. }
  1651. case ZONE_SET_VALUE_NAME: {
  1652. if (zone)
  1653. zone->SetZoneName(const_cast<char*>(value));
  1654. database.SaveZoneInfo(zone_id, "name", value);
  1655. break;
  1656. }
  1657. case ZONE_SET_VALUE_FILE: {
  1658. if (zone)
  1659. zone->SetZoneFile(const_cast<char*>(value));
  1660. database.SaveZoneInfo(zone_id, "file", value);
  1661. break;
  1662. }
  1663. case ZONE_SET_VALUE_DESCRIPTION: {
  1664. if (zone)
  1665. zone->SetZoneDescription(const_cast<char*>(value));
  1666. database.SaveZoneInfo(zone_id, "description", value);
  1667. break;
  1668. }
  1669. case ZONE_SET_VALUE_SAFE_X: {
  1670. if (zone)
  1671. zone->SetSafeX(float_value);
  1672. database.SaveZoneInfo(zone_id, "safe_x", float_value);
  1673. break;
  1674. }
  1675. case ZONE_SET_VALUE_SAFE_Y: {
  1676. if (zone)
  1677. zone->SetSafeY(float_value);
  1678. database.SaveZoneInfo(zone_id, "safe_y", float_value);
  1679. break;
  1680. }
  1681. case ZONE_SET_VALUE_SAFE_Z: {
  1682. if (zone)
  1683. zone->SetSafeZ(float_value);
  1684. database.SaveZoneInfo(zone_id, "safe_z", float_value);
  1685. break;
  1686. }
  1687. case ZONE_SET_VALUE_UNDERWORLD: {
  1688. if (zone)
  1689. zone->SetUnderWorld(float_value);
  1690. database.SaveZoneInfo(zone_id, "underworld", float_value);
  1691. break;
  1692. }
  1693. case ZONE_SET_VALUE_MIN_RECOMMENDED: {
  1694. break;
  1695. }
  1696. case ZONE_SET_VALUE_MAX_RECOMMENDED: {
  1697. break;
  1698. }
  1699. case ZONE_SET_VALUE_ZONE_TYPE: {
  1700. break;
  1701. }
  1702. case ZONE_SET_VALUE_ALWAYS_LOADED: {
  1703. if (zone)
  1704. zone->SetAlwaysLoaded(int_value == 1);
  1705. database.SaveZoneInfo(zone_id, "always_loaded", int_value);
  1706. break;
  1707. }
  1708. case ZONE_SET_VALUE_CITY_ZONE: {
  1709. if (zone)
  1710. zone->SetCityZone(int_value == 1);
  1711. database.SaveZoneInfo(zone_id, "city_zone", int_value);
  1712. break;
  1713. }
  1714. case ZONE_SET_VALUE_WEATHER_ALLOWED: {
  1715. if (zone)
  1716. zone->SetWeatherAllowed(int_value == 1);
  1717. database.SaveZoneInfo(zone_id, "weather_allowed", int_value);
  1718. break;
  1719. }
  1720. case ZONE_SET_VALUE_MIN_STATUS: {
  1721. if (zone)
  1722. zone->SetMinimumStatus(int_value);
  1723. database.SaveZoneInfo(zone_id, "min_status", int_value);
  1724. break;
  1725. }
  1726. case ZONE_SET_VALUE_MIN_LEVEL: {
  1727. if (zone)
  1728. zone->SetMinimumLevel(int_value);
  1729. database.SaveZoneInfo(zone_id, "min_level", int_value);
  1730. break;
  1731. }
  1732. case ZONE_SET_VALUE_MAX_LEVEL: {
  1733. if (zone)
  1734. zone->SetMaximumLevel(int_value);
  1735. database.SaveZoneInfo(zone_id, "max_level", int_value);
  1736. break;
  1737. }
  1738. case ZONE_SET_VALUE_START_ZONE: {
  1739. database.SaveZoneInfo(zone_id, "start_zone", int_value);
  1740. break;
  1741. }
  1742. case ZONE_SET_VALUE_INSTANCE_TYPE: {
  1743. if (zone)
  1744. zone->SetInstanceType(int_value);
  1745. database.SaveZoneInfo(zone_id, "instance_type", int_value);
  1746. break;
  1747. }
  1748. case ZONE_SET_VALUE_DEFAULT_REENTER_TIME: {
  1749. if (zone)
  1750. zone->SetDefaultReenterTime(int_value);
  1751. database.SaveZoneInfo(zone_id, "default_reenter_time", int_value);
  1752. break;
  1753. }
  1754. case ZONE_SET_VALUE_DEFAULT_RESET_TIME: {
  1755. if (zone)
  1756. zone->SetDefaultResetTime(int_value);
  1757. database.SaveZoneInfo(zone_id, "default_reset_time", int_value);
  1758. break;
  1759. }
  1760. case ZONE_SET_VALUE_DEFAULT_LOCKOUT_TIME: {
  1761. if (zone)
  1762. zone->SetDefaultLockoutTime(int_value);
  1763. database.SaveZoneInfo(zone_id, "default_lockout_time", int_value);
  1764. break;
  1765. }
  1766. case ZONE_SET_VALUE_FORCE_GROUP_TO_ZONE: {
  1767. if (zone)
  1768. zone->SetForceGroupZoneOption(int_value);
  1769. database.SaveZoneInfo(zone_id, "force_group_to_zone", int_value);
  1770. break;
  1771. }
  1772. case ZONE_SET_VALUE_LUA_SCRIPT: {
  1773. if (lua_interface && lua_interface->GetZoneScript(value) == 0) {
  1774. client->Message(CHANNEL_COLOR_RED, "Invalid Zone Script file. Be sure you give the absolute path.");
  1775. client->Message(CHANNEL_COLOR_RED, "Example: /zone set lua_script 'ZoneScripts/QueensColony.lua'");
  1776. return false;
  1777. }
  1778. else {
  1779. world.AddZoneScript(zone_id, const_cast<char*>(value));
  1780. database.SaveZoneInfo(zone_id, "lua_script", value);
  1781. }
  1782. break;
  1783. }
  1784. case ZONE_SET_VALUE_SHUTDOWN_TIMER: {
  1785. if (zone)
  1786. zone->SetShutdownTimer(int_value);
  1787. database.SaveZoneInfo(zone_id, "shutdown_timer", int_value);
  1788. break;
  1789. }
  1790. case ZONE_SET_VALUE_ZONE_MOTD: {
  1791. if (zone)
  1792. zone->SetZoneMOTD(string(value));
  1793. database.SaveZoneInfo(zone_id, "zone_motd", value);
  1794. break;
  1795. }
  1796. default: {
  1797. client->Message(CHANNEL_COLOR_RED, "Invalid zone attribute %i", type);
  1798. return false;
  1799. }
  1800. }
  1801. }
  1802. else {
  1803. if (client)
  1804. client->SimpleMessage(CHANNEL_COLOR_RED, "An error occured saving new zone data.");
  1805. return false;
  1806. }
  1807. return true;
  1808. }
  1809. void Commands::Process(int32 index, EQ2_16BitString* command_parms, Client* client, Spawn* targetOverride) {
  1810. if (index >= remote_commands->commands.size()) {
  1811. LogWrite(COMMAND__ERROR, 0, "Command", "Error, command handler of %u was requested, but max handler is %u", index, remote_commands->commands.size());
  1812. return;
  1813. }
  1814. Spawn* cmdTarget = targetOverride ? targetOverride : client->GetPlayer()->GetTarget();
  1815. EQ2_RemoteCommandString* parent_command = 0;
  1816. EQ2_RemoteCommandString* command = &remote_commands->commands[index];
  1817. Seperator* sep = 0;
  1818. if (command_parms->size > 0) {
  1819. sep = new Seperator(command_parms->data.c_str(), ' ', 10, 500, true);
  1820. if (sep && sep->arg[0] && remote_commands->validSubCommand(command->command.data, string(sep->arg[0]))) {
  1821. parent_command = command;
  1822. command = &(remote_commands->subcommands[command->command.data][string(sep->arg[0])]);
  1823. safe_delete(sep);
  1824. if (command_parms->data.length() > (command->command.data.length() + 1))
  1825. sep = new Seperator(command_parms->data.c_str() + (command->command.data.length() + 1), ' ', 10, 500, true);
  1826. LogWrite(COMMAND__DEBUG, 1, "Command", "Handler: %u, COMMAND: '%s', SUBCOMMAND: '%s'", index, parent_command->command.data.c_str(), command->command.data.c_str());
  1827. }
  1828. else
  1829. LogWrite(COMMAND__DEBUG, 1, "Command", "Handler: %u, COMMAND: '%s'", index, command->command.data.c_str());
  1830. }
  1831. int ndx = 0;
  1832. if (command->required_status > client->GetAdminStatus())
  1833. {
  1834. 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());
  1835. safe_delete(sep);
  1836. client->SimpleMessage(3, "Error: Your status is insufficient for this command.");
  1837. return;
  1838. }
  1839. Player* player = client->GetPlayer();
  1840. LogWrite(COMMAND__DEBUG, 0, "Command", "Player '%s' (%u), Command: %s", player->GetName(), client->GetAccountID(), command->command.data.c_str());
  1841. switch (command->handler) {
  1842. case COMMAND_RELOAD: {
  1843. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reload commands:");
  1844. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload structs");
  1845. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload items");
  1846. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload luasystem");
  1847. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spawnscripts");
  1848. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spells");
  1849. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spells npc");
  1850. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload quests");
  1851. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spawns");
  1852. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload groundspawns");
  1853. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload zonescripts");
  1854. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload entity_commands");
  1855. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload factions");
  1856. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload mail");
  1857. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload guilds");
  1858. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload locations");
  1859. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload rules");
  1860. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload transporters");
  1861. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload startabilities");
  1862. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload voiceovers");
  1863. break;
  1864. }
  1865. case COMMAND_RELOADSTRUCTS: {
  1866. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Structs...");
  1867. world.SetReloadingSubsystem("Structs");
  1868. configReader.ReloadStructs();
  1869. world.RemoveReloadingSubSystem("Structs");
  1870. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1871. break;
  1872. }
  1873. case COMMAND_RELOAD_QUESTS: {
  1874. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Quests...");
  1875. world.SetReloadingSubsystem("Quests");
  1876. master_quest_list.Reload();
  1877. client_list.ReloadQuests();
  1878. zone_list.ReloadClientQuests();
  1879. world.RemoveReloadingSubSystem("Quests");
  1880. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1881. break;
  1882. }
  1883. case COMMAND_RELOAD_SPAWNS: {
  1884. client->GetCurrentZone()->ReloadSpawns();
  1885. break;
  1886. }
  1887. case COMMAND_RELOAD_SPELLS: {
  1888. if (sep && sep->arg[0] && strcmp(sep->arg[0], "npc") == 0) {
  1889. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading NPC Spells Lists (Note: Must Reload Spawns/Repop to reset npc spells)...");
  1890. world.PurgeNPCSpells();
  1891. database.LoadNPCSpells();
  1892. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1893. }
  1894. else {
  1895. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spells & NPC Spell Lists (Note: Must Reload Spawns/Repop to reset npc spells)...");
  1896. world.SetReloadingSubsystem("Spells");
  1897. zone_list.DeleteSpellProcess();
  1898. master_spell_list.Reload();
  1899. if (lua_interface)
  1900. lua_interface->ReloadSpells();
  1901. zone_list.LoadSpellProcess();
  1902. world.RemoveReloadingSubSystem("Spells");
  1903. world.PurgeNPCSpells();
  1904. database.LoadNPCSpells();
  1905. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1906. }
  1907. break;
  1908. }
  1909. case COMMAND_RELOAD_GROUNDSPAWNS: {
  1910. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Groundspawn Entries...");
  1911. world.SetReloadingSubsystem("GroundSpawns");
  1912. client->GetCurrentZone()->DeleteGroundSpawnItems();
  1913. client->GetCurrentZone()->LoadGroundSpawnEntries();
  1914. world.RemoveReloadingSubSystem("GroundSpawns");
  1915. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1916. break;
  1917. }
  1918. case COMMAND_RELOAD_ZONESCRIPTS: {
  1919. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Zone Scripts...");
  1920. world.SetReloadingSubsystem("ZoneScripts");
  1921. world.ResetZoneScripts();
  1922. database.LoadZoneScriptData();
  1923. if (lua_interface)
  1924. lua_interface->DestroyZoneScripts();
  1925. world.RemoveReloadingSubSystem("ZoneScripts");
  1926. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1927. break;
  1928. }
  1929. case COMMAND_RELOAD_ENTITYCOMMANDS: {
  1930. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Entity Commands...");
  1931. world.SetReloadingSubsystem("EntityCommands");
  1932. client->GetCurrentZone()->ClearEntityCommands();
  1933. database.LoadEntityCommands(client->GetCurrentZone());
  1934. world.RemoveReloadingSubSystem("EntityCommands");
  1935. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1936. break;
  1937. }
  1938. case COMMAND_RELOAD_FACTIONS: {
  1939. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Factions...");
  1940. world.SetReloadingSubsystem("Factions");
  1941. master_faction_list.Clear();
  1942. database.LoadFactionList();
  1943. world.RemoveReloadingSubSystem("Factions");
  1944. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1945. break;
  1946. }
  1947. case COMMAND_RELOAD_MAIL: {
  1948. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Mail...");
  1949. zone_list.ReloadMail();
  1950. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1951. break;
  1952. }
  1953. case COMMAND_RELOAD_GUILDS: {
  1954. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Guilds...");
  1955. world.ReloadGuilds();
  1956. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1957. break;
  1958. }
  1959. case COMMAND_RELOAD_LOCATIONS: {
  1960. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Locations...");
  1961. client->GetPlayer()->GetZone()->RemoveLocationGrids();
  1962. database.LoadLocationGrids(client->GetPlayer()->GetZone());
  1963. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1964. break;
  1965. }
  1966. case COMMAND_RELOAD_RULES: {
  1967. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Rules...");
  1968. database.LoadRuleSets(true);
  1969. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1970. break;
  1971. }
  1972. case COMMAND_RELOAD_TRANSPORTERS: {
  1973. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Transporters in your current zone...");
  1974. database.LoadTransporters(client->GetCurrentZone());
  1975. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1976. break;
  1977. }
  1978. case COMMAND_RELOAD_STARTABILITIES: {
  1979. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Starting Skills/Spells...");
  1980. world.PurgeStartingLists();
  1981. world.LoadStartingLists();
  1982. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1983. break;
  1984. }
  1985. case COMMAND_RELOAD_VOICEOVERS: {
  1986. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Voiceovers...");
  1987. world.PurgeVoiceOvers();
  1988. world.LoadVoiceOvers();
  1989. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1990. break;
  1991. }
  1992. case COMMAND_READ: {
  1993. if (sep && sep->arg[1][0] && sep->IsNumber(1)) {
  1994. if (strcmp(sep->arg[0], "read") == 0) {
  1995. int32 item_index = atol(sep->arg[1]);
  1996. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  1997. if (item) {
  1998. Spawn* spawn = cmdTarget;
  1999. client->SendShowBook(client->GetPlayer(), item->name, item->book_language, item->book_pages);
  2000. break;
  2001. }
  2002. }
  2003. }
  2004. break;
  2005. }
  2006. case COMMAND_USEABILITY:{
  2007. if (sep && sep->arg[0][0] && sep->IsNumber(0)) {
  2008. if (!client->GetPlayer()->Alive()) {
  2009. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot do that right now.");
  2010. }
  2011. else {
  2012. int32 spell_id = atoul(sep->arg[0]);
  2013. int8 spell_tier = 0;
  2014. if (sep->arg[1][0] && sep->IsNumber(1))
  2015. spell_tier = atoi(sep->arg[1]);
  2016. else
  2017. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  2018. if (!spell_tier)
  2019. spell_tier = 1;
  2020. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  2021. if (spell) {
  2022. 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)
  2023. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), cmdTarget, true, true);
  2024. else
  2025. {
  2026. if (cmdTarget)
  2027. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), cmdTarget);
  2028. else
  2029. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  2030. }
  2031. }
  2032. }
  2033. }
  2034. else if (cmdTarget && cmdTarget->IsWidget())
  2035. {
  2036. Widget* widget = (Widget*)cmdTarget;
  2037. widget->HandleUse(client, "use", WIDGET_TYPE_DOOR);
  2038. }
  2039. else
  2040. {
  2041. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /useability {spell_id} [spell_tier]");
  2042. }
  2043. break;
  2044. }
  2045. case COMMAND_INFO:{
  2046. if(sep && sep->arg[1][0] && sep->IsNumber(1)){
  2047. if(strcmp(sep->arg[0], "inventory") == 0){
  2048. int32 item_index = atol(sep->arg[1]);
  2049. if(client->GetVersion() <= 546 && item_index <= 255) {
  2050. item_index = 255 - item_index;
  2051. }
  2052. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  2053. if(item){
  2054. if (item->IsCollectable() && client->SendCollectionsForItem(item))
  2055. break;
  2056. EQ2Packet* app = item->serialize(client->GetVersion(), (!item->GetItemScript() || !lua_interface), client->GetPlayer());
  2057. //DumpPacket(app);
  2058. client->QueuePacket(app);
  2059. if(item->GetItemScript() && lua_interface)
  2060. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  2061. else if(item->generic_info.offers_quest_id > 0){ //leave the current functionality in place if it doesnt have an item script
  2062. Quest* quest = master_quest_list.GetQuest(item->generic_info.offers_quest_id, false);
  2063. if(quest && client->GetPlayer()->HasQuestBeenCompleted(item->generic_info.offers_quest_id) == 0 && client->GetPlayer()->HasActiveQuest(item->generic_info.offers_quest_id) == 0)
  2064. client->AddPendingQuest(new Quest(quest)); // copy quest since we pulled the master quest to see if it existed or not
  2065. }
  2066. }
  2067. else
  2068. LogWrite(COMMAND__ERROR, 0, "Command", "/info inventory: Unknown Index: %u", item_index);
  2069. }
  2070. else if(strcmp(sep->arg[0], "equipment") == 0){
  2071. int32 item_index = client->GetPlayer()->ConvertSlotFromClient(atol(sep->arg[1]), client->GetVersion());
  2072. Item* item = client->GetPlayer()->GetEquipmentList()->GetItem(item_index);
  2073. if(item){
  2074. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  2075. client->QueuePacket(app);
  2076. if(item->GetItemScript() && lua_interface)
  2077. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  2078. }
  2079. else
  2080. LogWrite(COMMAND__ERROR, 0, "Command", "/info equipment: Unknown Index: %u", item_index);
  2081. }
  2082. else if(strcmp(sep->arg[0], "appearance") == 0){
  2083. int32 item_index = client->GetPlayer()->ConvertSlotFromClient(atol(sep->arg[1]), client->GetVersion());
  2084. Item* item = client->GetPlayer()->GetAppearanceEquipmentList()->GetItem(item_index);
  2085. if(item){
  2086. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  2087. client->QueuePacket(app);
  2088. if(item->GetItemScript() && lua_interface)
  2089. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  2090. }
  2091. else
  2092. LogWrite(COMMAND__ERROR, 0, "Command", "/info appearance: Unknown Index: %u", item_index);
  2093. }
  2094. 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){
  2095. int32 item_id = atoul(sep->arg[1]);
  2096. Item* item = master_item_list.GetItem(item_id);
  2097. if(item){
  2098. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  2099. client->QueuePacket(app);
  2100. }
  2101. else
  2102. LogWrite(COMMAND__ERROR, 0, "Command", "/info item|merchant|store|buyback|consignment: Unknown Item ID: %u", item_id);
  2103. }
  2104. else if (strcmp(sep->arg[0], "spell") == 0) {
  2105. sint32 spell_id = atol(sep->arg[1]);
  2106. int8 tier = atoi(sep->arg[3]);
  2107. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, tier, client, true, 0x2A);
  2108. if (outapp)
  2109. client->QueuePacket(outapp);
  2110. else
  2111. LogWrite(COMMAND__ERROR, 0, "Command", "/info spell: Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  2112. }
  2113. else if (strcmp(sep->arg[0], "achievement") == 0) {
  2114. sint32 spell_id = atol(sep->arg[2]);
  2115. int8 group = atoi(sep->arg[1]);
  2116. AltAdvanceData* data = 0;
  2117. SpellBookEntry* spellentry = 0;
  2118. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  2119. LogWrite(COMMAND__ERROR, 0, "Command", "/info achievement: AA Spell ID and/or Tier, ID: %u, Group: %i", spell_id, group);
  2120. EQ2Packet* outapp = master_spell_list.GetAASpellPacket(spell_id, tier, client, true, 0x45);
  2121. if (outapp)
  2122. client->QueuePacket(outapp);
  2123. else
  2124. LogWrite(COMMAND__ERROR, 0, "Command", "/info achievement: Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, group);
  2125. }
  2126. else if (strcmp(sep->arg[0], "spellbook") == 0) {
  2127. sint32 spell_id = atol(sep->arg[1]);
  2128. int32 tier = atoi(sep->arg[2]);
  2129. if (tier > 255) {
  2130. SpellBookEntry* ent = client->GetPlayer()->GetSpellBookSpell(spell_id);
  2131. if (ent)
  2132. tier = ent->tier;
  2133. }
  2134. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, (int8)tier, client, true, 0x2A);
  2135. if (outapp)
  2136. client->QueuePacket(outapp);
  2137. else
  2138. LogWrite(COMMAND__ERROR, 0, "Command", "/info spellbook: Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  2139. }
  2140. else if (strcmp(sep->arg[0], "recipe") == 0) {
  2141. sint32 recipe_id = atol(sep->arg[1]);
  2142. EQ2Packet* outapp = master_recipe_list.GetRecipePacket(recipe_id, client, true, 0x2C);
  2143. if(outapp)
  2144. client->QueuePacket(outapp);
  2145. else
  2146. LogWrite(COMMAND__ERROR, 0, "Command", "/info recipe: Unknown Recipe ID: %u", recipe_id);
  2147. }
  2148. else if (strcmp(sep->arg[0], "recipe_product") == 0) {
  2149. sint32 recipe_id = atol(sep->arg[1]);
  2150. PlayerRecipeList* prl = client->GetPlayer()->GetRecipeList();
  2151. Recipe* recipe = nullptr;
  2152. if ((recipe = prl->GetRecipe(recipe_id)) && recipe->GetProductID()) {
  2153. RecipeProducts* rp = recipe->products[1];
  2154. if (recipe->GetProductID() > 0) {
  2155. Item* item = master_item_list.GetItem(recipe->GetProductID());
  2156. if(item){
  2157. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  2158. client->QueuePacket(app);
  2159. }
  2160. else
  2161. LogWrite(COMMAND__ERROR, 0, "Command", "/info recipe_product: Unknown Item ID: %u", recipe->GetProductID());
  2162. }
  2163. else {
  2164. LogWrite(COMMAND__ERROR, 0, "Command", "/info recipe_product: recipe->GetProductID() has value 0 for recipe id %u.", recipe_id);
  2165. }
  2166. }
  2167. else {
  2168. 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);
  2169. }
  2170. }
  2171. else if (strcmp(sep->arg[0], "maintained") ==0) {
  2172. int32 slot = atol(sep->arg[1]);
  2173. int32 spell_id = atol(sep->arg[2]);
  2174. LogWrite(COMMAND__DEBUG, 5, "Command", "/info maintained: Spell ID - Slot: %u unknown: %u", slot, spell_id);
  2175. //int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  2176. MaintainedEffects* info = client->GetPlayer()->GetMaintainedSpellBySlot(slot);
  2177. EQ2Packet* outapp = master_spell_list.GetSpellPacket(info->spell_id, info->tier, client, true, 0x00);
  2178. if(outapp)
  2179. client->QueuePacket(outapp);
  2180. else
  2181. LogWrite(COMMAND__ERROR, 0, "Command", "/info maintained: Unknown Spell ID: %u", spell_id);
  2182. }
  2183. else if (strcmp(sep->arg[0], "effect") == 0) {
  2184. int32 spell_id = atol(sep->arg[1]);
  2185. LogWrite(COMMAND__DEBUG, 5, "Command", "/info effect: Spell ID: %u", spell_id);
  2186. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  2187. int8 type = 0;
  2188. if (client->GetVersion() <= 546)
  2189. type = 1;
  2190. EQ2Packet* outapp = master_spell_list.GetSpecialSpellPacket(spell_id, tier, client, true, type);
  2191. if (outapp){
  2192. client->QueuePacket(outapp);
  2193. }
  2194. else
  2195. LogWrite(COMMAND__ERROR, 0, "Command", "/info effect: Unknown Spell ID: %u", spell_id);
  2196. }
  2197. }
  2198. else if (sep && strcmp(sep->arg[0], "overflow") == 0) {
  2199. Item* item = player->item_list.GetOverflowItem();
  2200. if(item) {
  2201. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  2202. client->QueuePacket(app);
  2203. }
  2204. else
  2205. LogWrite(COMMAND__ERROR, 0,"Command", "/info overflow: Unable to retrieve an overflow item.");
  2206. }
  2207. else
  2208. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /info {inventory|equipment|spell} {id}");
  2209. break;
  2210. }
  2211. case COMMAND_USE_EQUIPPED_ITEM:{
  2212. if (sep && sep->arg[0] && sep->IsNumber(0)){
  2213. int32 slot_id = atoul(sep->arg[0]);
  2214. Item* item = player->GetEquipmentList()->GetItem(slot_id);
  2215. if (item && item->generic_info.usable && item->GetItemScript()) {
  2216. if(!item->CheckFlag2(INDESTRUCTABLE) && item->generic_info.condition == 0) {
  2217. client->SimpleMessage(CHANNEL_COLOR_RED, "This item is broken and must be repaired at a mender before it can be used");
  2218. }
  2219. else if (item->CheckFlag(EVIL_ONLY) && client->GetPlayer()->GetAlignment() != ALIGNMENT_EVIL) {
  2220. client->Message(0, "%s requires an evil race.", item->name.c_str());
  2221. }
  2222. else if (item->CheckFlag(GOOD_ONLY) && client->GetPlayer()->GetAlignment() != ALIGNMENT_GOOD) {
  2223. client->Message(0, "%s requires a good race.", item->name.c_str());
  2224. }
  2225. else {
  2226. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player, player->GetTarget());
  2227. }
  2228. }
  2229. }
  2230. break;
  2231. }
  2232. case COMMAND_USE_ITEM: {
  2233. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  2234. int32 item_index = atoul(sep->arg[0]);
  2235. Item* item = player->item_list.GetItemFromIndex(item_index);
  2236. client->UseItem(item, client->GetPlayer()->GetTarget() ? client->GetPlayer()->GetTarget() : client->GetPlayer());
  2237. }
  2238. break;
  2239. }
  2240. case COMMAND_SCRIBE_SCROLL_ITEM: {
  2241. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  2242. Item* item = player->item_list.GetItemFromUniqueID(atoul(sep->arg[0]));
  2243. if (item) {
  2244. LogWrite(ITEM__DEBUG, 0, "Items", "ITEM ID: %u", item->details.item_id);
  2245. if(item->generic_info.item_type == 6) {
  2246. Spell* spell = master_spell_list.GetSpell(item->skill_info->spell_id, item->skill_info->spell_tier);
  2247. int8 old_slot = 0;
  2248. if (spell) {
  2249. if(!spell->ScribeAllowed(client->GetPlayer())) {
  2250. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not meet one of the requirements to scribe, due to class or level.");
  2251. break;
  2252. }
  2253. int16 tier_up = player->GetTierUp(spell->GetSpellTier());
  2254. if (rule_manager.GetGlobalRule(R_Spells, RequirePreviousTierScribe)->GetInt8() && !player->HasSpell(spell->GetSpellID(), tier_up, false, true))
  2255. client->SimpleMessage(CHANNEL_COLOR_RED, "You have not scribed the required previous version of this ability.");
  2256. else if (!player->HasSpell(spell->GetSpellID(), spell->GetSpellTier(), true)) {
  2257. old_slot = player->GetSpellSlot(spell->GetSpellID());
  2258. player->RemoveSpellBookEntry(spell->GetSpellID());
  2259. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  2260. player->UnlockSpell(spell);
  2261. client->SendSpellUpdate(spell);
  2262. database.DeleteItem(client->GetCharacterID(), item, 0);
  2263. player->item_list.RemoveItem(item, true);
  2264. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  2265. client->QueuePacket(player->SendInventoryUpdate(client->GetVersion()));
  2266. // force purge client cache and display updated spell for hover over
  2267. EQ2Packet* app = spell->SerializeSpell(client, false, false);
  2268. client->QueuePacket(app);
  2269. }
  2270. }
  2271. else
  2272. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown spell ID: %u and tier: %u", item->skill_info->spell_id, item->skill_info->spell_tier);
  2273. }
  2274. else if(item->generic_info.item_type == 7){
  2275. if(item->recipebook_info) {
  2276. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Scribing recipe book %s (%u) for player %s.", item->name.c_str(), item->recipebook_info->recipe_id, player->GetName());
  2277. client->AddRecipeBookToPlayer(item->recipebook_info->recipe_id, item);
  2278. }
  2279. else {
  2280. 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);
  2281. 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());
  2282. }
  2283. }
  2284. else {
  2285. LogWrite(COMMAND__ERROR, 0, "Command", "Recipe Book Info is not set for item %s.", item->name.c_str());
  2286. }
  2287. }
  2288. else
  2289. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown unique item ID: %s", sep->arg[0]);
  2290. }
  2291. break;
  2292. }
  2293. case COMMAND_SUMMONITEM: {
  2294. if (sep && sep->IsNumber(0)) {
  2295. int32 item_id = atol(sep->arg[0]);
  2296. int32 quantity = 1;
  2297. if (sep->arg[1] && sep->IsNumber(1))
  2298. quantity = atoi(sep->arg[1]);
  2299. if (sep->arg[2] && strncasecmp(sep->arg[2], "bank", 4) == 0) {
  2300. client->AddItemToBank(item_id,quantity);
  2301. }
  2302. else {
  2303. client->AddItem(item_id, quantity);
  2304. }
  2305. }
  2306. else {
  2307. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} [quantity] or");
  2308. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} {quantity} [location] where location = bank");
  2309. }
  2310. break;
  2311. }
  2312. case COMMAND_COLLECTION_ADDITEM: {
  2313. // takes 2 params: collection_id, slot
  2314. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  2315. Item *item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(atoul(sep->arg[1]));
  2316. if (item)
  2317. client->HandleCollectionAddItem(atoul(sep->arg[0]), item);
  2318. else
  2319. 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]));
  2320. }
  2321. else
  2322. LogWrite(COLLECTION__ERROR, 0, "Collect", "Received command 'COMMAND_COLLECTION_ADDITEM' with unhandeled argument types");
  2323. break;
  2324. }
  2325. case COMMAND_COLLECTION_FILTER_MATCHITEM: {
  2326. // takes 1 param: slot
  2327. printf("COMMAND_COLLECTION_FILTER_MATCHITEM:\n");
  2328. int i = 0;
  2329. while (sep->arg[i] && strlen(sep->arg[i]) > 0) {
  2330. printf("\t%u: %s\n", i, sep->arg[i]);
  2331. i++;
  2332. }
  2333. break;
  2334. }
  2335. case COMMAND_WAYPOINT: {
  2336. bool success = false;
  2337. client->ClearWaypoint();
  2338. if (sep && sep->IsNumber(0) && sep->IsNumber(1) && sep->IsNumber(2)) {
  2339. if (!client->ShowPathToTarget(atof(sep->arg[0]), atof(sep->arg[1]), atof(sep->arg[2]), 0))
  2340. client->Message(CHANNEL_COLOR_RED, "Invalid coordinates given");
  2341. }
  2342. else if ( client->GetAdminStatus() > 100 && cmdTarget ) {
  2343. if (!client->ShowPathToTarget(cmdTarget->GetX(), cmdTarget->GetY(), cmdTarget->GetZ(), 0))
  2344. client->Message(CHANNEL_COLOR_RED, "Invalid coordinates given");
  2345. }
  2346. else {
  2347. client->Message(CHANNEL_COLOR_YELLOW, "Usage: /waypoint x y z");
  2348. }
  2349. break;
  2350. }
  2351. case COMMAND_WHO:{
  2352. const char* who = 0;
  2353. if(sep && sep->arg[0]){
  2354. //cout << "Who query: \n";
  2355. who = sep->argplus[0];
  2356. //cout << who << endl;
  2357. }
  2358. zone_list.ProcessWhoQuery(who, client);
  2359. break;
  2360. }
  2361. case COMMAND_SELECT_JUNCTION:{
  2362. // transporters (bells birds) use OP_SelectZoneTeleporterDestinatio / ProcessTeleportLocation(app)
  2363. // this is only used for revive it seems
  2364. int32 choice = 0;
  2365. if(sep && sep->arg[0] && sep->IsNumber(0))
  2366. choice = atoul(sep->arg[0]);
  2367. if(!client->GetPlayer()->Alive()){ //dead and this is a revive request
  2368. client->HandlePlayerRevive(choice);
  2369. }
  2370. break;
  2371. }
  2372. case COMMAND_SPAWN_MOVE: {
  2373. if (cmdTarget && cmdTarget->IsPlayer() == false) {
  2374. PacketStruct* packet = configReader.getStruct("WS_MoveObjectMode", client->GetVersion());
  2375. if (packet) {
  2376. float unknown2_3 = 0;
  2377. int8 placement_mode = 0;
  2378. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::DEFAULT);
  2379. if (sep && sep->arg[0][0]) {
  2380. if (strcmp(sep->arg[0], "wall") == 0) {
  2381. placement_mode = 2;
  2382. unknown2_3 = 150;
  2383. }
  2384. else if (strcmp(sep->arg[0], "ceiling") == 0)
  2385. placement_mode = 1;
  2386. else if (strcmp(sep->arg[0], "openheading") == 0 && cmdTarget->IsWidget())
  2387. {
  2388. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "[PlacementMode] WIDGET OPEN HEADING MODE");
  2389. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::OPEN_HEADING);
  2390. }
  2391. else if (strcmp(sep->arg[0], "closeheading") == 0 && cmdTarget->IsWidget())
  2392. {
  2393. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "[PlacementMode] WIDGET CLOSE HEADING MODE");
  2394. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::CLOSE_HEADING);
  2395. }
  2396. else if (strcmp(sep->arg[0], "myloc") == 0)
  2397. {
  2398. if (cmdTarget->GetSpawnLocationPlacementID() < 1) {
  2399. client->Message(CHANNEL_COLOR_YELLOW, "[PlacementMode] Spawn %s cannot be moved it is not assigned a spawn location placement id.", cmdTarget->GetName());
  2400. safe_delete(packet);
  2401. break;
  2402. }
  2403. cmdTarget->SetX(client->GetPlayer()->GetX(), true);
  2404. cmdTarget->SetY(client->GetPlayer()->GetY(), true);
  2405. cmdTarget->SetZ(client->GetPlayer()->GetZ(), true);
  2406. cmdTarget->SetHeading(client->GetPlayer()->GetHeading(), true);
  2407. if (database.UpdateSpawnLocationSpawns(cmdTarget))
  2408. client->Message(CHANNEL_COLOR_YELLOW, "[PlacementMode] Spawn %s placed at your location. Updated spawn_location_placement for spawn.", cmdTarget->GetName());
  2409. safe_delete(packet);
  2410. break;
  2411. }
  2412. }
  2413. packet->setDataByName("placement_mode", placement_mode);
  2414. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget));
  2415. packet->setDataByName("model_type", cmdTarget->GetModelType());
  2416. packet->setDataByName("unknown", 1); //size
  2417. packet->setDataByName("unknown2", 1); //size 2
  2418. packet->setDataByName("unknown2", .5, 1); //size 3
  2419. packet->setDataByName("unknown2", 3, 2);
  2420. packet->setDataByName("unknown2", unknown2_3, 3);
  2421. packet->setDataByName("max_distance", 500);
  2422. packet->setDataByName("CoEunknown", 0xFFFFFFFF);
  2423. client->QueuePacket(packet->serialize());
  2424. safe_delete(packet);
  2425. }
  2426. }
  2427. else {
  2428. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /spawn move (wall OR ceiling)");
  2429. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Moves a spawn anywhere you like. Optionally wall/ceiling can be provided to place wall/ceiling items.");
  2430. }
  2431. break;
  2432. }
  2433. case COMMAND_HAIL:{
  2434. Spawn* spawn = cmdTarget;
  2435. if(spawn && spawn->GetTargetable())
  2436. {
  2437. char tmp[75] = {0};
  2438. sprintf(tmp, "Hail, %s", spawn->GetName());
  2439. bool show_bubble = true;
  2440. if (spawn->IsNPC())
  2441. show_bubble = false;
  2442. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp, HEAR_SPAWN_DISTANCE, 0, show_bubble, client->GetPlayer()->GetCurrentLanguage());
  2443. if(spawn->IsPlayer() == false && spawn->Alive() && spawn->GetDistance(client->GetPlayer()) < rule_manager.GetGlobalRule(R_Spawn, HailDistance)->GetInt32()){
  2444. if(spawn->IsNPC() && ((NPC*)spawn)->EngagedInCombat())
  2445. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED_BUSY, client->GetPlayer());
  2446. else
  2447. {
  2448. bool pauseRunback = false;
  2449. // prime runback as the heading or anything can be altered when hailing succeeds
  2450. if(spawn->IsNPC() && (spawn->HasMovementLoop() || spawn->HasMovementLocations()))
  2451. {
  2452. ((NPC*)spawn)->StartRunback();
  2453. pauseRunback = true;
  2454. }
  2455. if(spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED, client->GetPlayer()) && pauseRunback)
  2456. spawn->PauseMovement(rule_manager.GetGlobalRule(R_Spawn, HailMovementPause)->GetInt32());
  2457. else if(spawn->IsNPC() && pauseRunback)
  2458. ((NPC*)spawn)->ClearRunback();
  2459. }
  2460. }
  2461. }
  2462. else {
  2463. string tmp = "Hail";
  2464. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp.c_str(), HEAR_SPAWN_DISTANCE, 0, true, client->GetPlayer()->GetCurrentLanguage());
  2465. }
  2466. break;
  2467. }
  2468. case COMMAND_SAY:{
  2469. if (sep && sep->arg[0][0]) {
  2470. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, sep->argplus[0], HEAR_SPAWN_DISTANCE, 0, true, client->GetPlayer()->GetCurrentLanguage());
  2471. if (cmdTarget && !(cmdTarget->IsPlayer()))
  2472. client->GetCurrentZone()->CallSpawnScript(cmdTarget, SPAWN_SCRIPT_HEAR_SAY, client->GetPlayer(), sep->argplus[0]);
  2473. }
  2474. else
  2475. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /say {message}");
  2476. break;
  2477. }
  2478. case COMMAND_TELL:{
  2479. if(sep && sep->arg[0] && sep->argplus[1]){
  2480. if(!zone_list.HandleGlobalChatMessage(client, sep->arg[0], CHANNEL_PRIVATE_TELL, sep->argplus[1], 0, client->GetPlayer()->GetCurrentLanguage()))
  2481. client->Message(CHANNEL_COLOR_RED,"Unable to find client %s",sep->arg[0]);
  2482. }else
  2483. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /tell {character_name} {message}");
  2484. break;
  2485. }
  2486. case COMMAND_SHOUT:{
  2487. if(sep && sep->arg[0][0])
  2488. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SHOUT, sep->argplus[0], 0, 0, true, client->GetPlayer()->GetCurrentLanguage());
  2489. else
  2490. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /shout {message}");
  2491. break;
  2492. }
  2493. case COMMAND_AUCTION:{
  2494. if(sep && sep->arg[0][0])
  2495. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_AUCTION, sep->argplus[0], 0, 0, true, client->GetPlayer()->GetCurrentLanguage());
  2496. else
  2497. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /auction {message}");
  2498. break;
  2499. }
  2500. case COMMAND_OOC:{
  2501. //For now ooc will be the global chat channel, eventually when we create more channels we will create a global chat channel
  2502. if(sep && sep->arg[0][0])
  2503. zone_list.HandleGlobalChatMessage(client, 0, CHANNEL_OUT_OF_CHARACTER, sep->argplus[0], 0, client->GetPlayer()->GetCurrentLanguage());
  2504. else
  2505. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /ooc {message}");
  2506. break;
  2507. }
  2508. case COMMAND_EMOTE:{
  2509. if(sep && sep->arg[0][0])
  2510. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_EMOTE, sep->argplus[0]);
  2511. else
  2512. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /emote {action}");
  2513. break;
  2514. }
  2515. case COMMAND_RACE:{
  2516. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  2517. if(sep->arg[1][0] && sep->IsNumber(1)){
  2518. client->GetPlayer()->GetInfoStruct()->set_race(atoi(sep->arg[1]));
  2519. client->GetPlayer()->SetRace(atoi(sep->arg[1]));
  2520. client->UpdateTimeStampFlag ( RACE_UPDATE_FLAG );
  2521. client->GetPlayer()->SetCharSheetChanged(true);
  2522. }
  2523. client->GetPlayer()->SetModelType(atoi(sep->arg[0]));
  2524. //EQ2Packet* outapp = client->GetPlayer()->spawn_update_packet(client->GetPlayer(), client->GetVersion(), client->GetPlayer()->GetFeatures());
  2525. //client->QueuePacket(outapp);
  2526. }
  2527. else{
  2528. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /race {race type id} {race id}");
  2529. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "{race id} is optional");
  2530. }
  2531. break;
  2532. }
  2533. case COMMAND_BANK_DEPOSIT:{
  2534. if(client->GetBanker() && sep && sep->arg[0]){
  2535. int64 amount = 0;
  2536. string deposit = string(sep->arg[0]);
  2537. amount = atoi64(deposit.c_str());
  2538. client->BankDeposit(amount);
  2539. }
  2540. break;
  2541. }
  2542. case COMMAND_BANK_WITHDRAWAL:{
  2543. if(client->GetBanker() && sep && sep->arg[0] && sep->IsNumber(0)){
  2544. int64 amount = 0;
  2545. string deposit = string(sep->arg[0]);
  2546. amount = atoi64(deposit.c_str());
  2547. client->BankWithdrawal(amount);
  2548. }
  2549. break;
  2550. }
  2551. case COMMAND_BANK_CANCEL:{
  2552. Spawn* banker = cmdTarget;
  2553. client->Bank(banker, true);
  2554. break;
  2555. }
  2556. case COMMAND_BANK:{
  2557. LogWrite(PLAYER__DEBUG, 0, "Players", "Open Player Personal Bank...");
  2558. Spawn* banker = cmdTarget;
  2559. client->Bank(banker);
  2560. break;
  2561. }
  2562. case COMMAND_GUILD_BANK:{
  2563. LogWrite(GUILD__DEBUG, 0, "Guilds", "Open Guild Bank...");
  2564. //Spawn* banker = client->GetPlayer()->GetTarget();
  2565. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will eventually open the guild bank!");
  2566. break;
  2567. }
  2568. case COMMAND_START_MAIL: {
  2569. client->SetMailTransaction(cmdTarget);
  2570. client->SendMailList();
  2571. break;
  2572. }
  2573. case COMMAND_CANCEL_MAIL: {
  2574. client->SetMailTransaction(0);
  2575. break;
  2576. }
  2577. case COMMAND_GET_MAIL_MESSAGE: {
  2578. if (sep && sep->arg[0] && sep->IsNumber(0))
  2579. client->DisplayMailMessage(atoul(sep->arg[0]));
  2580. break;
  2581. }
  2582. case COMMAND_ADD_MAIL_PLAT: {
  2583. if (sep && sep->arg[0] && sep->IsNumber(0))
  2584. client->AddMailCoin(0, 0, 0, atoul(sep->arg[0]));
  2585. break;
  2586. }
  2587. case COMMAND_ADD_MAIL_GOLD: {
  2588. if (sep && sep->arg[0] && sep->IsNumber(0))
  2589. client->AddMailCoin(0, 0, atoul(sep->arg[0]));
  2590. break;
  2591. }
  2592. case COMMAND_ADD_MAIL_SILVER: {
  2593. if (sep && sep->arg[0] && sep->IsNumber(0))
  2594. client->AddMailCoin(0, atoul(sep->arg[0]));
  2595. break;
  2596. }
  2597. case COMMAND_ADD_MAIL_COPPER: {
  2598. if (sep && sep->arg[0] && sep->IsNumber(0))
  2599. client->AddMailCoin(atoul(sep->arg[0]));
  2600. break;
  2601. }
  2602. case COMMAND_SET_MAIL_ITEM: {
  2603. if(sep && sep->IsNumber(0) && sep->IsNumber(1))
  2604. {
  2605. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(atoul(sep->arg[0]));
  2606. if(item)
  2607. {
  2608. int16 quantity = atoul(sep->arg[1]);
  2609. if(item->CheckFlag(NO_TRADE) || item->CheckFlag(ATTUNED) || item->CheckFlag(ARTIFACT) || item->CheckFlag2(HEIRLOOM))
  2610. {
  2611. return;
  2612. }
  2613. if(item->IsBag())
  2614. {
  2615. vector<Item*>* bag_items = player->GetPlayerItemList()->GetItemsInBag(item);
  2616. if(bag_items && bag_items->size() > 0)
  2617. {
  2618. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot mail a bag with items inside it.");
  2619. safe_delete(bag_items);
  2620. return;
  2621. }
  2622. safe_delete(bag_items);
  2623. }
  2624. Item* itemtoadd = item;
  2625. if(quantity > 0)
  2626. {
  2627. if(quantity > item->details.count)
  2628. return;
  2629. Item* tmpItem = new Item(item);
  2630. tmpItem->details.count = quantity;
  2631. itemtoadd = tmpItem;
  2632. }
  2633. if(client->AddMailItem(itemtoadd))
  2634. {
  2635. client->RemoveItem(item, quantity, true);
  2636. }
  2637. }
  2638. }
  2639. break;
  2640. }
  2641. case COMMAND_REMOVE_MAIL_PLAT: {
  2642. if (sep && sep->arg[0] && sep->IsNumber(0))
  2643. client->RemoveMailCoin(0, 0, 0, atoul(sep->arg[0]));
  2644. break;
  2645. }
  2646. case COMMAND_REMOVE_MAIL_GOLD: {
  2647. if (sep && sep->arg[0] && sep->IsNumber(0))
  2648. client->RemoveMailCoin(0, 0, atoul(sep->arg[0]));
  2649. break;
  2650. }
  2651. case COMMAND_REMOVE_MAIL_SILVER: {
  2652. if (sep && sep->arg[0] && sep->IsNumber(0))
  2653. client->RemoveMailCoin(0, atoul(sep->arg[0]));
  2654. break;
  2655. }
  2656. case COMMAND_REMOVE_MAIL_COPPER: {
  2657. if (sep && sep->arg[0] && sep->IsNumber(0))
  2658. client->RemoveMailCoin(atoul(sep->arg[0]));
  2659. break;
  2660. }
  2661. case COMMAND_TAKE_MAIL_ATTACHMENTS: {
  2662. if (sep && sep->arg[0] && sep->IsNumber(0))
  2663. client->TakeMailAttachments(atoul(sep->arg[0]));
  2664. break;
  2665. }
  2666. case COMMAND_CANCEL_SEND_MAIL: {
  2667. client->ResetSendMail();
  2668. break;
  2669. }
  2670. case COMMAND_DELETE_MAIL_MESSAGE: {
  2671. if (sep && sep->arg[0] && sep->IsNumber(0))
  2672. client->DeleteMail(atoul(sep->arg[0]), true);
  2673. break;
  2674. }
  2675. case COMMAND_REPORT_SPAM: {
  2676. LogWrite(MISC__TODO, 1, "TODO", " received reportspam\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  2677. if (sep && sep->arg[0]) LogWrite(COMMAND__DEBUG, 0, "Command", "%s\n", sep->argplus[0]);
  2678. break;
  2679. }
  2680. case COMMAND_KILL:{
  2681. Spawn* dead = 0;
  2682. if (sep && sep->arg[0] && strncasecmp(sep->arg[0],"self",4)==0){
  2683. dead=client->GetPlayer();
  2684. client->GetPlayer()->SetHP(0);
  2685. client->GetPlayer()->KillSpawn(dead);
  2686. }else{
  2687. dead= cmdTarget;
  2688. if(dead && dead->IsPlayer() == false){
  2689. if(dead->IsNPC() && ((NPC*)dead)->Brain()) {
  2690. client->GetPlayer()->CheckEncounterState((Entity*)dead);
  2691. ((NPC*)dead)->Brain()->AddToEncounter(client->GetPlayer());
  2692. ((NPC*)dead)->AddTargetToEncounter(client->GetPlayer());
  2693. ((NPC*)dead)->Brain()->AddHate(client->GetPlayer(), 1);
  2694. }
  2695. dead->SetHP(0);
  2696. if(sep && sep->arg[0] && sep->IsNumber(0) && atoi(sep->arg[0]) == 1)
  2697. client->GetCurrentZone()->RemoveSpawn(dead, true, true, true, true, true);
  2698. else
  2699. client->GetPlayer()->KillSpawn(dead);
  2700. }else{
  2701. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /kill (self)");
  2702. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Kills currently selected non-player target.");
  2703. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Optionally, self may be used to kill yourself");
  2704. }
  2705. }
  2706. break;
  2707. }
  2708. case COMMAND_LEVEL:{
  2709. if(sep && sep->arg[ndx][0] && sep->IsNumber(0)){
  2710. int16 new_level = atoi(sep->arg[ndx]);
  2711. if (!client->GetPlayer()->CheckLevelStatus(new_level))
  2712. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have the required status to level up anymore!");
  2713. else {
  2714. if (new_level < 1)
  2715. new_level = 1;
  2716. if (new_level > 255)
  2717. new_level = 255;
  2718. client->ChangeLevel(client->GetPlayer()->GetLevel(), new_level);
  2719. }
  2720. }else
  2721. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /level {new_level}");
  2722. break;
  2723. }
  2724. case COMMAND_SIT: {
  2725. if(client->GetPlayer()->GetHP() > 0){
  2726. client->QueuePacket(new EQ2Packet(OP_SitMsg, 0, 0));
  2727. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You sit down.");
  2728. client->GetPlayer()->set_character_flag(CF_IS_SITTING);
  2729. }
  2730. break;
  2731. }
  2732. case COMMAND_STAND: {
  2733. if(client->GetPlayer()->GetHP() > 0){
  2734. client->QueuePacket(new EQ2Packet(OP_StandMsg, 0, 0));
  2735. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You stand up.");
  2736. client->GetPlayer()->reset_character_flag(CF_IS_SITTING);
  2737. }
  2738. break;
  2739. }
  2740. case COMMAND_CLASS:{
  2741. if(sep && sep->arg[ndx][0]){
  2742. client->GetPlayer()->SetPlayerAdventureClass(atoi(sep->arg[ndx]));
  2743. client->UpdateTimeStampFlag ( CLASS_UPDATE_FLAG );
  2744. }else
  2745. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /class {class_id}");
  2746. break;
  2747. }
  2748. case COMMAND_FLYMODE:{
  2749. if(sep && sep->arg[0] && sep->IsNumber(0)){
  2750. PrintSep(sep, "COMMAND_FLYMODE");
  2751. int8 val = atoul(sep->arg[0]);
  2752. ClientPacketFunctions::SendFlyMode(client, val);
  2753. }
  2754. else{
  2755. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage ON: /flymode [1|2] 1 = fly, 2 = no clip");
  2756. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage OFF: /flymode 0");
  2757. }
  2758. break;
  2759. }
  2760. case COMMAND_LOOT_LIST:{
  2761. Spawn* spawn = cmdTarget;
  2762. if(spawn && spawn->IsEntity()){
  2763. if (sep && sep->arg[0]) {
  2764. if (!spawn->GetDatabaseID())
  2765. {
  2766. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn has no database id to assign to loottables.");
  2767. break;
  2768. }
  2769. else if (!spawn->IsNPC())
  2770. {
  2771. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "these /loot list [add/remove/clearall] sub-commands are only designed for an NPC.");
  2772. break;
  2773. }
  2774. bool reloadLoot = false;
  2775. if (!stricmp(sep->arg[0], "remove") && sep->arg[1] && sep->IsNumber(1))
  2776. {
  2777. int32 loottable_id = atoul(sep->arg[1]);
  2778. if (loottable_id > 0 && database.RemoveSpawnLootTable(spawn, loottable_id))
  2779. {
  2780. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u loot table %u removed.", spawn->GetDatabaseID(), loottable_id);
  2781. reloadLoot = true;
  2782. }
  2783. else
  2784. client->Message(CHANNEL_COLOR_YELLOW, "/loot list remove [loottableid] - could not match any spawn_id entries against loottable_id %u.", loottable_id);
  2785. }
  2786. else if (!stricmp(sep->arg[0], "add") && sep->arg[1] && sep->IsNumber(1))
  2787. {
  2788. int32 loottable_id = atoul(sep->arg[1]);
  2789. if (loottable_id > 0)
  2790. {
  2791. database.AddLootTableToSpawn(spawn, loottable_id);
  2792. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u loot table %u added.", spawn->GetDatabaseID(), loottable_id);
  2793. reloadLoot = true;
  2794. }
  2795. else
  2796. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list add [loottableid] - cannot add a loottable id of 0.");
  2797. }
  2798. else if (!stricmp(sep->arg[0], "clearall"))
  2799. {
  2800. if (database.RemoveSpawnLootTable(spawn, 0))
  2801. {
  2802. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn loot tables removed.");
  2803. reloadLoot = true;
  2804. }
  2805. else
  2806. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list clearall - could not match any spawn_id entries in loottable_id.");
  2807. }
  2808. else
  2809. {
  2810. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list argument not supported.");
  2811. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list add [loottableid] - add new loottable to spawn");
  2812. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list remove [loottableid] - remove existing loottable from spawn");
  2813. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list clearall - remove all loottables from spawn");
  2814. break;
  2815. }
  2816. if (reloadLoot)
  2817. {
  2818. database.LoadSpawnLoot(spawn->GetZone(), spawn);
  2819. if (spawn->IsNPC())
  2820. {
  2821. Entity* ent = (Entity*)spawn;
  2822. ent->SetLootCoins(0);
  2823. ent->ClearLoot();
  2824. spawn->GetZone()->AddLoot((NPC*)spawn);
  2825. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u active loot purged and reloaded.", spawn->GetDatabaseID());
  2826. }
  2827. }
  2828. break; // nothing further this is the end of these sub commands
  2829. }
  2830. else
  2831. {
  2832. vector<int32> loot_list = client->GetCurrentZone()->GetSpawnLootList(spawn->GetDatabaseID(), spawn->GetZone()->GetZoneID(), spawn->GetLevel(), race_types_list.GetRaceType(spawn->GetModelType()), spawn);
  2833. if (loot_list.size() > 0) {
  2834. client->Message(CHANNEL_COLOR_YELLOW, "%s belongs to the following loot lists: ", spawn->GetName());
  2835. vector<int32>::iterator list_itr;
  2836. LootTable* table = 0;
  2837. for (list_itr = loot_list.begin(); list_itr != loot_list.end(); list_itr++) {
  2838. table = client->GetCurrentZone()->GetLootTable(*list_itr);
  2839. if (table)
  2840. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", *list_itr, table->name.c_str());
  2841. }
  2842. }
  2843. client->Message(CHANNEL_COLOR_YELLOW, "Coins being carried: %u", spawn->GetLootCoins());
  2844. vector<Item*>* items = spawn->GetLootItems();
  2845. if (items) {
  2846. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is carrying the following items: ");
  2847. vector<Item*>::iterator itr;
  2848. Item* item = 0;
  2849. for (itr = items->begin(); itr != items->end(); itr++) {
  2850. item = *itr;
  2851. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", item->details.item_id, item->name.c_str());
  2852. }
  2853. }
  2854. else
  2855. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is not carrying any items.");
  2856. }
  2857. }
  2858. break;
  2859. }
  2860. case COMMAND_LOOT_SETCOIN:{
  2861. Spawn* spawn = cmdTarget;
  2862. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2863. spawn->SetLootCoins(atoul(sep->arg[0]));
  2864. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully set coins.");
  2865. }
  2866. else
  2867. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot setcoin {amount}");
  2868. break;
  2869. }
  2870. case COMMAND_LOOT_ADDITEM:{
  2871. Spawn* spawn = cmdTarget;
  2872. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2873. int16 charges = 1;
  2874. if(sep->arg[1] && sep->IsNumber(1))
  2875. charges = atoi(sep->arg[1]);
  2876. spawn->AddLootItem(atoul(sep->arg[0]), charges);
  2877. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully added item.");
  2878. }
  2879. else
  2880. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot additem {item_id}");
  2881. break;
  2882. }
  2883. case COMMAND_LOOT_REMOVEITEM:{
  2884. Spawn* spawn = cmdTarget;
  2885. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2886. Item* item = spawn->LootItem(atoul(sep->arg[0]));
  2887. lua_interface->SetLuaUserDataStale(item);
  2888. safe_delete(item);
  2889. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully removed item.");
  2890. }
  2891. else
  2892. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot removeitem {item_id}");
  2893. break;
  2894. }
  2895. case COMMAND_LOOT_CORPSE:
  2896. case COMMAND_DISARM:
  2897. case COMMAND_LOOT:{
  2898. if (cmdTarget && ((Entity*)cmdTarget)->IsNPC() && cmdTarget->Alive())
  2899. {
  2900. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is not dead.");
  2901. break;
  2902. }
  2903. if(cmdTarget && cmdTarget->IsEntity()){
  2904. if (cmdTarget->GetDistance(client->GetPlayer()) <= rule_manager.GetGlobalRule(R_Loot, LootRadius)->GetFloat()){
  2905. if (!rule_manager.GetGlobalRule(R_Loot, AutoDisarmChest)->GetBool() && command->handler == COMMAND_DISARM )
  2906. client->OpenChest(cmdTarget, true);
  2907. else
  2908. client->Loot(cmdTarget, rule_manager.GetGlobalRule(R_Loot, AutoDisarmChest)->GetBool());
  2909. if (!(cmdTarget)->HasLoot()){
  2910. if (((Entity*)cmdTarget)->IsNPC())
  2911. client->GetCurrentZone()->RemoveDeadSpawn(cmdTarget);
  2912. }
  2913. }
  2914. else
  2915. client->Message(CHANNEL_COLOR_YELLOW, "You are too far away to interact with that");
  2916. }
  2917. else if(!cmdTarget || cmdTarget->GetHP() > 0)
  2918. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid target.");
  2919. break;
  2920. }
  2921. case COMMAND_RELOADSPAWNSCRIPTS:{
  2922. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spawn Scripts....");
  2923. if (lua_interface)
  2924. lua_interface->SetLuaSystemReloading(true);
  2925. world.ResetSpawnScripts();
  2926. database.LoadSpawnScriptData();
  2927. if(lua_interface) {
  2928. lua_interface->DestroySpawnScripts();
  2929. lua_interface->SetLuaSystemReloading(false);
  2930. }
  2931. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Success!");
  2932. break;
  2933. }
  2934. case COMMAND_RELOADREGIONSCRIPTS:{
  2935. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Region Scripts....");
  2936. if(lua_interface) {
  2937. lua_interface->DestroyRegionScripts();
  2938. }
  2939. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Success!");
  2940. break;
  2941. }
  2942. case COMMAND_RELOADLUASYSTEM:{
  2943. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Attempting to reload entire LUA system....");
  2944. world.SetReloadingSubsystem("LuaSystem");
  2945. if(lua_interface) {
  2946. lua_interface->SetLuaSystemReloading(true);
  2947. }
  2948. zone_list.DeleteSpellProcess();
  2949. master_spell_list.Reload();
  2950. if (lua_interface)
  2951. lua_interface->ReloadSpells();
  2952. zone_list.LoadSpellProcess();
  2953. if(lua_interface){
  2954. map<Client*, int32> debug_clients = lua_interface->GetDebugClients();
  2955. map<Client*, int32>::iterator itr;
  2956. for(itr = debug_clients.begin(); itr != debug_clients.end(); itr++){
  2957. if(lua_interface)
  2958. lua_interface->UpdateDebugClients(itr->first);
  2959. }
  2960. }
  2961. world.ResetSpawnScripts();
  2962. database.LoadSpawnScriptData();
  2963. world.ResetZoneScripts();
  2964. database.LoadZoneScriptData();
  2965. if(lua_interface) {
  2966. lua_interface->DestroySpawnScripts();
  2967. lua_interface->DestroyRegionScripts();
  2968. lua_interface->DestroyQuests();
  2969. lua_interface->DestroyItemScripts();
  2970. lua_interface->DestroyZoneScripts();
  2971. }
  2972. int32 quest_count = database.LoadQuests();
  2973. int32 spell_count = 0;
  2974. if(lua_interface) {
  2975. spell_count = database.LoadSpellScriptData();
  2976. lua_interface->SetLuaSystemReloading(false);
  2977. }
  2978. world.RemoveReloadingSubSystem("LuaSystem");
  2979. client->Message(CHANNEL_COLOR_YELLOW, "Successfully loaded %u spell(s), %u quest(s).", spell_count, quest_count);
  2980. break;
  2981. }
  2982. case COMMAND_DECLINE_QUEST:{
  2983. int32 quest_id = 0;
  2984. if(sep && sep->arg[0] && sep->IsNumber(0))
  2985. quest_id = atoul(sep->arg[0]);
  2986. if(quest_id > 0){
  2987. client->RemovePendingQuest(quest_id);
  2988. }
  2989. break;
  2990. }
  2991. case COMMAND_DELETE_QUEST:{
  2992. int32 quest_id = 0;
  2993. if(sep && sep->arg[0] && sep->IsNumber(0))
  2994. quest_id = atoul(sep->arg[0]);
  2995. if(quest_id > 0){
  2996. client->GetPlayer()->MPlayerQuests.readlock(__FUNCTION__, __LINE__);
  2997. if(lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0) {
  2998. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  2999. client->GetPlayer()->MPlayerQuests.releasereadlock(__FUNCTION__, __LINE__);
  3000. if (quest && quest->CanDeleteQuest()) {
  3001. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  3002. client->RemovePlayerQuest(quest_id);
  3003. client->GetCurrentZone()->SendQuestUpdates(client);
  3004. }
  3005. }
  3006. else {
  3007. client->GetPlayer()->MPlayerQuests.releasereadlock(__FUNCTION__, __LINE__);
  3008. }
  3009. }
  3010. break;
  3011. }
  3012. case COMMAND_ACCEPT_QUEST:{
  3013. int32 quest_id = 0;
  3014. if(sep && sep->arg[0] && sep->IsNumber(0))
  3015. quest_id = atoul(sep->arg[0]);
  3016. if(quest_id > 0){
  3017. client->AcceptQuest(quest_id);
  3018. }
  3019. break;
  3020. }
  3021. case COMMAND_NAME:{
  3022. if(sep && sep->arg[ndx][0]){
  3023. client->GetPlayer()->GetInfoStruct()->set_name(std::string(sep->arg[ndx]).substr(0,39));
  3024. client->GetPlayer()->SetCharSheetChanged(true);
  3025. }else
  3026. client->Message(CHANNEL_COLOR_YELLOW,"Usage: /name {new_name}");
  3027. break;
  3028. }
  3029. case COMMAND_GROUP: {
  3030. if(sep && sep->arg[0])
  3031. printf("Group: %s\n",sep->argplus[0]);
  3032. break;
  3033. }
  3034. case COMMAND_GROUPSAY:{
  3035. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  3036. if(sep && sep->arg[0] && gmi)
  3037. world.GetGroupManager()->GroupChatMessage(gmi->group_id, client->GetPlayer(), client->GetPlayer()->GetCurrentLanguage(), sep->argplus[0]);
  3038. break;
  3039. }
  3040. case COMMAND_GROUPINVITE: {
  3041. Entity* target = 0;
  3042. Client* target_client = 0;
  3043. if (client->GetPlayer()->GetGroupMemberInfo() && !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  3044. client->SimpleMessage(CHANNEL_COMMANDS, "You must be the group leader to invite.");
  3045. return;
  3046. }
  3047. // name provided with command so it has to be a player, npc not supported here
  3048. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0){
  3049. target_client = zone_list.GetClientByCharName(sep->arg[0]);
  3050. if (target_client) {
  3051. if (!target_client->IsConnected() || !target_client->IsReadyForSpawns())
  3052. target = 0;
  3053. else
  3054. target = target_client->GetPlayer();
  3055. }
  3056. }
  3057. // if name was not provided use the players target, npc or player supported here
  3058. if (!target && client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  3059. target = (Entity*)client->GetPlayer()->GetTarget();
  3060. if (target->IsPlayer()) {
  3061. target_client = client->GetCurrentZone()->GetClientBySpawn(target);
  3062. }
  3063. }
  3064. int8 result = world.GetGroupManager()->Invite(client->GetPlayer(), target);
  3065. if (result == 0) {
  3066. client->Message(CHANNEL_COMMANDS, "You invite %s to group with you.", target->GetName());
  3067. if (target_client) {
  3068. PacketStruct* packet = configReader.getStruct("WS_ReceiveOffer", target_client->GetVersion());
  3069. if (packet) {
  3070. packet->setDataByName("type", 1);
  3071. packet->setDataByName("name", client->GetPlayer()->GetName());
  3072. packet->setDataByName("unknown2", 1);
  3073. target_client->QueuePacket(packet->serialize());
  3074. safe_delete(packet);
  3075. }
  3076. }
  3077. }
  3078. else if (result == 1)
  3079. client->SimpleMessage(CHANNEL_COMMANDS, "That player is already in a group.");
  3080. else if (result == 2)
  3081. client->SimpleMessage(CHANNEL_COMMANDS, "That player has been invited to another group.");
  3082. else if (result == 3)
  3083. client->SimpleMessage(CHANNEL_COMMANDS, "Your group is already full.");
  3084. else if (result == 4)
  3085. client->SimpleMessage(CHANNEL_COMMANDS, "You have a pending invitation, cancel it first.");
  3086. else if (result == 5)
  3087. client->SimpleMessage(CHANNEL_COMMANDS, "You cannot invite yourself!");
  3088. else if (result == 6)
  3089. client->SimpleMessage(CHANNEL_COMMANDS, "Could not locate the player.");
  3090. else
  3091. client->SimpleMessage(CHANNEL_COMMANDS, "Group invite failed, unknown error!");
  3092. break;
  3093. }
  3094. case COMMAND_GROUPDISBAND: {
  3095. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  3096. if (gmi) { // TODO: Leader check
  3097. // world.GetGroupManager()->SimpleGroupMessage(gmi->group_id, "Your group has been disbanded.");
  3098. world.GetGroupManager()->RemoveGroup(gmi->group_id);
  3099. }
  3100. break;
  3101. }
  3102. case COMMAND_GROUP_LEAVE: {
  3103. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  3104. if (gmi) {
  3105. int32 group_id = gmi->group_id;
  3106. world.GetGroupManager()->RemoveGroupMember(group_id, client->GetPlayer());
  3107. if (!world.GetGroupManager()->IsGroupIDValid(group_id)) {
  3108. // leader->Message(CHANNEL_COLOR_GROUP, "%s has left the group.", client->GetPlayer()->GetName());
  3109. }
  3110. else {
  3111. world.GetGroupManager()->GroupMessage(group_id, "%s has left the group.", client->GetPlayer()->GetName());
  3112. }
  3113. client->SimpleMessage(CHANNEL_GROUP_CHAT, "You have left the group");
  3114. }
  3115. break;
  3116. }
  3117. case COMMAND_FRIEND_ADD:{
  3118. string name = "";
  3119. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  3120. name = database.GetPlayerName(sep->arg[0]);
  3121. else if(cmdTarget && cmdTarget->IsPlayer())
  3122. name = string(cmdTarget->GetName());
  3123. if(name.length() > 0){
  3124. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  3125. if(client->GetPlayer()->IsIgnored(name.c_str())){
  3126. client->GetPlayer()->RemoveIgnore(name.c_str());
  3127. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  3128. client->SendChatRelationship(3, name.c_str());
  3129. }
  3130. client->GetPlayer()->AddFriend(name.c_str(), true);
  3131. client->SendChatRelationship(0, name.c_str());
  3132. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added friend: %s", name.c_str());
  3133. if(zone_list.GetClientByCharName(name))
  3134. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Friend: %s has logged in.", name.c_str());
  3135. }
  3136. else
  3137. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot be more friendly towards yourself!");
  3138. }
  3139. else
  3140. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  3141. break;
  3142. }
  3143. case COMMAND_FRIEND_REMOVE:{
  3144. string name = "";
  3145. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  3146. name = database.GetPlayerName(sep->arg[0]);
  3147. else if(cmdTarget && cmdTarget->IsPlayer())
  3148. name = string(cmdTarget->GetName());
  3149. if(name.length() > 0){
  3150. client->GetPlayer()->RemoveFriend(name.c_str());
  3151. client->SendChatRelationship(1, name.c_str());
  3152. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  3153. }
  3154. else
  3155. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  3156. break;
  3157. }
  3158. case COMMAND_FRIENDS:{
  3159. break;
  3160. }
  3161. case COMMAND_IGNORE_ADD:{
  3162. string name = "";
  3163. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  3164. name = database.GetPlayerName(sep->arg[0]);
  3165. else if(cmdTarget && cmdTarget->IsPlayer())
  3166. name = string(cmdTarget->GetName());
  3167. if(name.length() > 0){
  3168. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  3169. if(client->GetPlayer()->IsFriend(name.c_str())){
  3170. client->GetPlayer()->RemoveFriend(name.c_str());
  3171. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  3172. client->SendChatRelationship(1, name.c_str());
  3173. }
  3174. client->GetPlayer()->AddIgnore(name.c_str(), true);
  3175. client->SendChatRelationship(2, name.c_str());
  3176. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added ignore: %s", name.c_str());
  3177. }
  3178. else
  3179. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot ignore yourself!");
  3180. }
  3181. else
  3182. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  3183. break;
  3184. }
  3185. case COMMAND_IGNORE_REMOVE:{
  3186. string name = "";
  3187. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  3188. name = database.GetPlayerName(sep->arg[0]);
  3189. else if(cmdTarget && cmdTarget->IsPlayer())
  3190. name = string(cmdTarget->GetName());
  3191. if(name.length() > 0){
  3192. client->GetPlayer()->RemoveIgnore(name.c_str());
  3193. client->SendChatRelationship(3, name.c_str());
  3194. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  3195. }
  3196. break;
  3197. }
  3198. case COMMAND_IGNORES:{
  3199. break;
  3200. }
  3201. case COMMAND_GROUP_KICK:{
  3202. Entity* kicked = 0;
  3203. Client* kicked_client = 0;
  3204. int32 group_id = 0;
  3205. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader)
  3206. return;
  3207. if (sep && sep->arg[0]) {
  3208. kicked_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  3209. if (kicked_client)
  3210. kicked = kicked_client->GetPlayer();
  3211. }
  3212. else if (cmdTarget && cmdTarget->IsEntity()) {
  3213. kicked = (Entity*)cmdTarget;
  3214. }
  3215. group_id = client->GetPlayer()->GetGroupMemberInfo()->group_id;
  3216. bool send_kicked_message = world.GetGroupManager()->GetGroupSize(group_id) > 2;
  3217. if (kicked)
  3218. world.GetGroupManager()->RemoveGroupMember(group_id, kicked);
  3219. if(send_kicked_message)
  3220. world.GetGroupManager()->GroupMessage(group_id, "%s was kicked from the group.", kicked->GetName());
  3221. else
  3222. client->Message(CHANNEL_GROUP_CHAT, "You kicked %s from the group", kicked->GetName());
  3223. if (kicked_client)
  3224. kicked_client->SimpleMessage(CHANNEL_GROUP_CHAT, "You were kicked from the group");
  3225. break;
  3226. }
  3227. case COMMAND_GROUP_MAKE_LEADER:{
  3228. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  3229. client->SimpleMessage(CHANNEL_COMMANDS, "You are not a group leader.");
  3230. return;
  3231. }
  3232. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 1) {
  3233. Client* new_leader = zone_list.GetClientByCharName(sep->arg[0]);
  3234. if (new_leader && new_leader->GetPlayer()->GetGroupMemberInfo() && new_leader->GetPlayer()->GetGroupMemberInfo()->group_id == client->GetPlayer()->GetGroupMemberInfo()->group_id) {
  3235. if (client->GetPlayer()->IsGroupMember(new_leader->GetPlayer())) {
  3236. if(world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, new_leader->GetPlayer())) {
  3237. world.GetGroupManager()->GroupMessage(client->GetPlayer()->GetGroupMemberInfo()->group_id, "%s is now leader of the group.", new_leader->GetPlayer()->GetName());
  3238. }
  3239. }
  3240. }
  3241. else
  3242. client->SimpleMessage(CHANNEL_COMMANDS, "Unable to find the given player.");
  3243. }
  3244. else if (cmdTarget && cmdTarget->IsPlayer() && ((Player*)cmdTarget)->GetGroupMemberInfo() && ((Player*)cmdTarget)->GetGroupMemberInfo()->group_id == client->GetPlayer()->GetGroupMemberInfo()->group_id) {
  3245. if(client->GetPlayer()->IsGroupMember((Player*)cmdTarget) && world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, (Entity*)cmdTarget)) {
  3246. world.GetGroupManager()->GroupMessage(client->GetPlayer()->GetGroupMemberInfo()->group_id, "%s is now leader of the group.", cmdTarget->GetName());
  3247. }
  3248. }
  3249. else
  3250. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to change group leader.");
  3251. break;
  3252. }
  3253. case COMMAND_GROUP_ACCEPT_INVITE: {
  3254. if((sep && sep->arg[0] && strcmp(sep->arg[0], "group") == 0) || (!sep && client->GetVersion() <= 546)) {
  3255. int8 result = world.GetGroupManager()->AcceptInvite(client->GetPlayer());
  3256. if (result == 0)
  3257. client->SimpleMessage(CHANNEL_GROUP_CHAT, "You have joined the group.");
  3258. else if (result == 1)
  3259. client->SimpleMessage(CHANNEL_GROUP_CHAT, "You do not have a pending invite.");
  3260. else if (result == 2)
  3261. client->SimpleMessage(CHANNEL_GROUP_CHAT, "Unable to join group - could not find leader.");
  3262. else
  3263. client->SimpleMessage(CHANNEL_GROUP_CHAT, "Unable to join group - unknown error.");
  3264. }
  3265. break;
  3266. }
  3267. case COMMAND_GROUP_DECLINE_INVITE: {
  3268. if(sep && sep->arg[0] && strcmp(sep->arg[0], "group") == 0) {
  3269. world.GetGroupManager()->DeclineInvite(client->GetPlayer()); // TODO: Add message to leader
  3270. }
  3271. break;
  3272. }
  3273. case COMMAND_SUMMON:{
  3274. char* search_name = 0;
  3275. if(sep && sep->arg[0][0])
  3276. search_name = sep->arg[0];
  3277. if(!search_name && !cmdTarget){
  3278. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /summon [name]");
  3279. 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.");
  3280. }
  3281. else{
  3282. if(!client->Summon(search_name))
  3283. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  3284. }
  3285. break;
  3286. }
  3287. case COMMAND_GOTO:{
  3288. const char* search_name = 0;
  3289. if(sep && sep->arg[0][0])
  3290. search_name = sep->argplus[0];
  3291. if(!search_name && !cmdTarget){
  3292. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /goto [name]");
  3293. 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.");
  3294. }
  3295. else{
  3296. if(!client->GotoSpawn(search_name))
  3297. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  3298. }
  3299. break;
  3300. }
  3301. case COMMAND_MOVE:{
  3302. bool success = false;
  3303. try{
  3304. if(sep && sep->arg[2][0] && sep->IsNumber(0) && sep->IsNumber(1) && sep->IsNumber(2)){
  3305. EQ2Packet* app = client->GetPlayer()->Move(atof(sep->arg[0]), atof(sep->arg[1]), atof(sep->arg[2]), client->GetVersion());
  3306. if(app){
  3307. client->QueuePacket(app);
  3308. success = true;
  3309. }
  3310. }
  3311. }
  3312. catch(...){}
  3313. if(!success){
  3314. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /move x y z");
  3315. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Moves the client to the given coordinates.");
  3316. }
  3317. break;
  3318. }
  3319. case COMMAND_SETTIME:{
  3320. if(sep && sep->arg[0]){
  3321. world.MWorldTime.writelock(__FUNCTION__, __LINE__);
  3322. sscanf (sep->arg[0], "%d:%d", &world.GetWorldTimeStruct()->hour, &world.GetWorldTimeStruct()->minute);
  3323. if(sep->arg[1] && sep->IsNumber(1))
  3324. world.GetWorldTimeStruct()->month = atoi(sep->arg[1]) - 1; //zero based indexes
  3325. if(sep->arg[2] && sep->IsNumber(2))
  3326. world.GetWorldTimeStruct()->day = atoi(sep->arg[2]) - 1; //zero based indexes
  3327. if(sep->arg[3] && sep->IsNumber(3))
  3328. world.GetWorldTimeStruct()->year = atoi(sep->arg[3]);
  3329. world.MWorldTime.releasewritelock(__FUNCTION__, __LINE__);
  3330. client->GetCurrentZone()->SendTimeUpdateToAllClients();
  3331. }
  3332. else{
  3333. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /settime [hour:minute] (month) (day) (year)");
  3334. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Example: /settime 8:30");
  3335. }
  3336. break;
  3337. }
  3338. case COMMAND_VERSION:{
  3339. client->Message(CHANNEL_COLOR_YELLOW,"%s %s", EQ2EMU_MODULE, CURRENT_VERSION);
  3340. client->Message(CHANNEL_COLOR_YELLOW,"Last Compiled on %s %s", COMPILE_DATE, COMPILE_TIME);
  3341. break;
  3342. }
  3343. case COMMAND_ZONE:{
  3344. int32 instanceID = 0;
  3345. string zone;
  3346. int32 zone_id = 0;
  3347. bool listSearch = false;
  3348. bool isInstance = false;
  3349. ZoneServer* zsZone = 0;
  3350. if(sep && sep->arg[0][0])
  3351. {
  3352. if(strncasecmp(sep->arg[0], "list", 4) == 0)
  3353. listSearch = true;
  3354. else if(strncasecmp(sep->arg[0], "active", 6) == 0)
  3355. {
  3356. zone_list.SendZoneList(client);
  3357. break;
  3358. }
  3359. else if(strncasecmp(sep->arg[0], "instance", 6) == 0)
  3360. {
  3361. if(sep->IsNumber(1))
  3362. instanceID = atol(sep->arg[1]);
  3363. }
  3364. else if(strncasecmp(sep->arg[0], "lock", 4) == 0)
  3365. {
  3366. PrintSep(sep, "ZONE LOCK");
  3367. if(sep->IsNumber(1))
  3368. zsZone = zone_list.Get(atoul(sep->arg[1]), false, false, false);
  3369. else
  3370. zsZone = zone_list.Get(sep->arg[1], false, false, false);
  3371. if( zsZone )
  3372. {
  3373. zsZone->SetZoneLockState(true);
  3374. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now locked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  3375. }
  3376. else
  3377. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be locked.", sep->arg[1]);
  3378. break;
  3379. }
  3380. else if(strncasecmp(sep->arg[0], "unlock", 6) == 0)
  3381. {
  3382. PrintSep(sep, "ZONE UNLOCK");
  3383. if(sep->IsNumber(1))
  3384. zsZone = zone_list.Get(atoul(sep->arg[1]), false, false, false);
  3385. else
  3386. zsZone = zone_list.Get(sep->arg[1], false, false, false);
  3387. if( zsZone )
  3388. {
  3389. zsZone->SetZoneLockState(false);
  3390. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now unlocked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  3391. }
  3392. else
  3393. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be unlocked.", sep->arg[1]);
  3394. break;
  3395. }
  3396. else
  3397. {
  3398. if(sep->IsNumber(0))
  3399. {
  3400. zone_id = atoul(sep->arg[0]);
  3401. string zonename = database.GetZoneName(zone_id);
  3402. if(zonename.length() > 0)
  3403. zone = zonename;
  3404. }
  3405. else
  3406. zone = sep->arg[0];
  3407. }
  3408. if(instanceID > 0)
  3409. {
  3410. ZoneServer* zsInstance = zone_list.GetByInstanceID(instanceID);
  3411. if(zsInstance != NULL)
  3412. {
  3413. instanceID = zsInstance->GetInstanceID();
  3414. zone = zsInstance->GetZoneName();
  3415. zone_id = zsInstance->GetZoneID();
  3416. isInstance = true;
  3417. }
  3418. }
  3419. }
  3420. if(!listSearch)
  3421. {
  3422. if(zone.length() == 0)
  3423. client->Message(CHANNEL_COLOR_RED, "Error: Invalid Zone");
  3424. else if(instanceID != client->GetCurrentZone()->GetInstanceID() ||
  3425. zone_id != client->GetCurrentZone()->GetZoneID())
  3426. {
  3427. const char* zonestr = zone.c_str();
  3428. if(database.VerifyZone(zonestr))
  3429. {
  3430. if(client->CheckZoneAccess(zonestr))
  3431. {
  3432. client->Message(CHANNEL_COLOR_YELLOW,"Zoning to %s...", zonestr);
  3433. if(isInstance)
  3434. client->Zone(instanceID,true,true,false);
  3435. else
  3436. client->Zone(zonestr);
  3437. }
  3438. }
  3439. else
  3440. client->Message(CHANNEL_COLOR_RED, "Error: Zone '%s' not found. To get a list type /zone list", zonestr);
  3441. }
  3442. else
  3443. client->Message(CHANNEL_COLOR_RED, "Error: You are already in that zone!");
  3444. }
  3445. else
  3446. {
  3447. const char* name = 0;
  3448. if(sep && sep->arg[1][0])
  3449. {
  3450. map<int32, string>* zone_names;
  3451. name = sep->argplus[1];
  3452. sint16 status = client->GetAdminStatus();
  3453. if( status > 0 )
  3454. {
  3455. client->SimpleMessage(CHANNEL_COLOR_RED, "ADMIN MODE");
  3456. zone_names = database.GetZoneList(name, true);
  3457. }
  3458. else
  3459. zone_names = database.GetZoneList(name);
  3460. if(!zone_names)
  3461. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No zones found.");
  3462. else
  3463. {
  3464. map<int32, string>::iterator itr;
  3465. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  3466. for(itr = zone_names->begin(); itr != zone_names->end(); itr++)
  3467. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  3468. safe_delete(zone_names);
  3469. }
  3470. }
  3471. else
  3472. {
  3473. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone [zone name]");
  3474. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone list [partial zone name]");
  3475. }
  3476. }
  3477. break;
  3478. }
  3479. case COMMAND_USE: {
  3480. Spawn* target = cmdTarget;
  3481. if (target && target->IsWidget())
  3482. ((Widget*)target)->HandleUse(client, "use");
  3483. break;
  3484. }
  3485. case COMMAND_OPEN: {
  3486. Spawn* target = cmdTarget;
  3487. if (target && target->IsWidget())
  3488. ((Widget*)target)->HandleUse(client, "Open", WIDGET_TYPE_DOOR);
  3489. break;
  3490. }
  3491. case COMMAND_CASTSPELL: {
  3492. if (sep && sep->arg[0] && sep->IsNumber(0))
  3493. {
  3494. int8 tier = 1;
  3495. if (sep->arg[1] && sep->IsNumber(1))
  3496. tier = atoul(sep->arg[1]);
  3497. int8 self = 1;
  3498. if (sep->arg[1] && sep->IsNumber(2))
  3499. {
  3500. self = atoul(sep->arg[2]);
  3501. if(self != 1 && !cmdTarget->IsEntity())
  3502. {
  3503. client->Message(CHANNEL_COLOR_RED, "Target is not an entity required to cast non-self spell.");
  3504. self = 1;
  3505. }
  3506. }
  3507. int32 spellid = atoul(sep->arg[0]);
  3508. Spell* spell = master_spell_list.GetSpell(spellid, tier);
  3509. if (spell)
  3510. {
  3511. client->Message(CHANNEL_COLOR_RED, "Casting spell %u.", spellid);
  3512. SpellProcess* spellProcess = 0;
  3513. // Get the current zones spell process
  3514. spellProcess = client->GetCurrentZone()->GetSpellProcess();
  3515. spellProcess->CastInstant(spell, (!cmdTarget || self == 1) ? (Entity*)client->GetPlayer() : (Entity*)cmdTarget, (cmdTarget && cmdTarget->IsEntity()) ? (Entity*)cmdTarget : (Entity*)client->GetPlayer());
  3516. }
  3517. else
  3518. {
  3519. client->Message(CHANNEL_COLOR_RED, "Could not find spell %u.",spellid);
  3520. }
  3521. }
  3522. else if (sep && sep->arg[0])
  3523. {
  3524. database.FindSpell(client, (char*)sep->argplus[0]);
  3525. }
  3526. else
  3527. {
  3528. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellid] (tier=1) - Cast Spell with specified spell id, tier is optional, default of 1.");
  3529. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellname] - Find spells wildcard match with a partial spell name");
  3530. }
  3531. break;
  3532. }
  3533. case COMMAND_KNOWLEDGEWINDOWSORT: {
  3534. if (sep && (client->GetVersion() <= 546 && sep->GetArgNumber() == 3) || sep->GetArgNumber() == 4)
  3535. {
  3536. int32 book = atoul(sep->arg[0]); // 0 - spells, 1 - combat, 2 - abilities, 3 - tradeskill
  3537. // cannot sort the ability book in this client it is greyed out
  3538. if (client->GetVersion() <= 546 && book == SPELL_BOOK_TYPE_ABILITY)
  3539. break;
  3540. int32 sort_by = atoul(sep->arg[1]); // 0 - alpha, 1 - level, 2 - category
  3541. int32 order = atoul(sep->arg[2]); // 0 - ascending, 1 - descending
  3542. int32 pattern = atoul(sep->arg[3]); // 0 - zigzag, 1 - down, 2 - across
  3543. int32 maxlvlonly = 0;
  3544. if(client->GetVersion() > 546 && sep->arg[4][0]) {
  3545. maxlvlonly = atoul(sep->arg[4]); // checkbox for newer clients
  3546. }
  3547. client->GetPlayer()->ResortSpellBook(sort_by, order, pattern, maxlvlonly, book);
  3548. ClientPacketFunctions::SendSkillSlotMappings(client);
  3549. }
  3550. else
  3551. {
  3552. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /knowledgewindow_sort [book] [sort_by] [order] [pattern]");
  3553. }
  3554. break;
  3555. }
  3556. case COMMAND_MOVE_ITEM:
  3557. {
  3558. int32 id = 0;
  3559. if (sep && sep->IsNumber(0))
  3560. id = atoul(sep->arg[0]);
  3561. Spawn* spawn = 0;
  3562. if (id == 0)
  3563. {
  3564. spawn = cmdTarget;
  3565. }
  3566. else
  3567. spawn = client->GetCurrentZone()->GetSpawnFromUniqueItemID(id);
  3568. if (!spawn || !client->HasOwnerOrEditAccess() || !spawn->GetPickupItemID())
  3569. break;
  3570. client->SendMoveObjectMode(spawn, 0);
  3571. break;
  3572. }
  3573. case COMMAND_PICKUP:
  3574. {
  3575. int32 id = 0;
  3576. if (sep && sep->IsNumber(0))
  3577. id = atoul(sep->arg[0]);
  3578. Spawn* spawn = 0;
  3579. if (id == 0)
  3580. {
  3581. spawn = cmdTarget;
  3582. }
  3583. else
  3584. spawn = client->GetCurrentZone()->GetSpawnFromUniqueItemID(id);
  3585. if (!spawn || !client->HasOwnerOrEditAccess() || !spawn->GetPickupItemID())
  3586. break;
  3587. if(client->AddItem(spawn->GetPickupItemID(), 1)) {
  3588. Query query;
  3589. 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());
  3590. if (database.RemoveSpawnFromSpawnLocation(spawn)) {
  3591. client->GetCurrentZone()->RemoveSpawn(spawn, true, true, true, true, true);
  3592. }
  3593. // we had a UI Window displayed, update the house items
  3594. if ( id > 0 )
  3595. client->GetCurrentZone()->SendHouseItems(client);
  3596. }
  3597. break;
  3598. }
  3599. case COMMAND_HOUSE_DEPOSIT:
  3600. {
  3601. PrintSep(sep, "COMMAND_HOUSE_DEPOSIT");
  3602. // arg0 = spawn_id for DoF, could also be house_id for newer clients
  3603. // arg1 = coin (in copper)
  3604. // arg2 = status? (not implemented yet)
  3605. PlayerHouse* ph = nullptr;
  3606. int32 spawn_id = 0;
  3607. if(sep && sep->arg[0]) {
  3608. spawn_id = atoul(sep->arg[0]);
  3609. ph = world.GetPlayerHouse(client, spawn_id, client->GetVersion() > 546 ? spawn_id : 0, nullptr);
  3610. }
  3611. if(!ph) {
  3612. ph = world.GetPlayerHouseByInstanceID(client->GetCurrentZone()->GetInstanceID());
  3613. }
  3614. if (ph && sep && sep->IsNumber(1))
  3615. {
  3616. int64 outValCoin = strtoull(sep->arg[1], NULL, 0);
  3617. int32 outValStatus = 0;
  3618. if(sep->IsNumber(2))
  3619. {
  3620. outValStatus = strtoull(sep->arg[2], NULL, 0);
  3621. if(outValStatus > client->GetPlayer()->GetInfoStruct()->get_status_points())
  3622. outValStatus = 0; // cheat check
  3623. }
  3624. if ((!outValCoin && outValStatus) || client->GetPlayer()->RemoveCoins(outValCoin))
  3625. {
  3626. if(outValStatus)
  3627. client->GetPlayer()->GetInfoStruct()->subtract_status_points(outValStatus);
  3628. char query[256];
  3629. map<string,Deposit>::iterator itr = ph->depositsMap.find(string(client->GetPlayer()->GetName()));
  3630. if (itr != ph->depositsMap.end())
  3631. {
  3632. 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());
  3633. }
  3634. else
  3635. 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);
  3636. if (database.RunQuery(query, strnlen(query, 256)))
  3637. {
  3638. ph->escrow_coins += outValCoin;
  3639. ph->escrow_status += outValStatus;
  3640. database.UpdateHouseEscrow(ph->house_id, ph->instance_id, ph->escrow_coins, ph->escrow_status);
  3641. database.LoadDeposits(ph);
  3642. client->PlaySound("coin_cha_ching");
  3643. HouseZone* hz = world.GetHouseZone(ph->house_id);
  3644. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetVersion() <= 546 ? spawn_id : client->GetPlayer()->GetID());
  3645. }
  3646. else
  3647. {
  3648. if(outValCoin)
  3649. client->GetPlayer()->AddCoins(outValCoin);
  3650. if(outValStatus)
  3651. client->GetPlayer()->GetInfoStruct()->add_status_points(outValStatus);
  3652. client->SimpleMessage(CHANNEL_COLOR_RED, "Deposit failed!");
  3653. }
  3654. }
  3655. }
  3656. break;
  3657. }
  3658. case COMMAND_HOUSE:
  3659. {
  3660. int32 spawn_id = 0;
  3661. if (sep && sep->IsNumber(0))
  3662. {
  3663. PlayerHouse* ph = nullptr;
  3664. if(!ph && sep && sep->arg[0]) {
  3665. spawn_id = atoul(sep->arg[0]);
  3666. ph = world.GetPlayerHouse(client, spawn_id, spawn_id, nullptr);
  3667. }
  3668. HouseZone* hz = 0;
  3669. if (ph)
  3670. hz = world.GetHouseZone(ph->house_id);
  3671. // there is a arg[1] that is true/false, but not sure what it is for investigate more later
  3672. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetVersion() <= 546 ? spawn_id : client->GetPlayer()->GetID());
  3673. }
  3674. else if (client->GetCurrentZone()->GetInstanceType() != 0)
  3675. {
  3676. // inside a house or something? Send the access window
  3677. PlayerHouse* ph = world.GetPlayerHouseByInstanceID(client->GetCurrentZone()->GetInstanceID());
  3678. HouseZone* hz = 0;
  3679. if ( ph )
  3680. hz = world.GetHouseZone(ph->house_id);
  3681. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetVersion() <= 546 ? spawn_id : client->GetPlayer()->GetID());
  3682. client->GetCurrentZone()->SendHouseItems(client);
  3683. }
  3684. break;
  3685. }
  3686. case COMMAND_HOUSE_UI:
  3687. {
  3688. if (sep && sep->IsNumber(0) && client->GetCurrentZone()->GetInstanceType() == Instance_Type::NONE)
  3689. {
  3690. int32 unique_id = atoi(sep->arg[0]);
  3691. PlayerHouse* ph = world.GetPlayerHouseByUniqueID(unique_id);
  3692. HouseZone* hz = 0;
  3693. if ( ph )
  3694. hz = world.GetHouseZone(ph->house_id);
  3695. // there is a arg[1] that is true/false, but not sure what it is for investigate more later
  3696. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  3697. }
  3698. break;
  3699. }
  3700. case COMMAND_PLACE_HOUSE_ITEM: {
  3701. if (sep && sep->IsNumber(0))
  3702. {
  3703. int32 uniqueid = atoi(sep->arg[0]);
  3704. Item* item = client->GetPlayer()->item_list.GetItemFromUniqueID(uniqueid);
  3705. //Item* item = player->GetEquipmentList()->GetItem(slot);
  3706. if (item && item->IsHouseItem())
  3707. {
  3708. if (!client->HasOwnerOrEditAccess())
  3709. {
  3710. client->SimpleMessage(CHANNEL_COLOR_RED, "This is not your home!");
  3711. break;
  3712. }
  3713. else if (!item->generic_info.appearance_id)
  3714. {
  3715. 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);
  3716. break;
  3717. }
  3718. else if(item->CheckFlag2(HOUSE_LORE) && client->GetCurrentZone()->HouseItemSpawnExists(item->details.item_id)) {
  3719. client->Message(CHANNEL_COLOR_RED, "Item %s is house lore and you cannot place another.", item->name.c_str());
  3720. break;
  3721. }
  3722. if (client->GetTempPlacementSpawn())
  3723. {
  3724. Spawn* tmp = client->GetTempPlacementSpawn();
  3725. client->GetCurrentZone()->RemoveSpawn(tmp, true, true, true, true, true);
  3726. client->SetTempPlacementSpawn(nullptr);
  3727. }
  3728. Object* obj = new Object();
  3729. Spawn* spawn = (Spawn*)obj;
  3730. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3731. strcpy(spawn->appearance.name, "temp");
  3732. spawn->SetX(client->GetPlayer()->GetX());
  3733. spawn->SetY(client->GetPlayer()->GetY());
  3734. spawn->SetZ(client->GetPlayer()->GetZ());
  3735. spawn->appearance.pos.collision_radius = 32;
  3736. spawn->SetHeading(client->GetPlayer()->GetHeading());
  3737. spawn->SetSpawnOrigX(spawn->GetX());
  3738. spawn->SetSpawnOrigY(spawn->GetY());
  3739. spawn->SetSpawnOrigZ(spawn->GetZ());
  3740. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  3741. spawn->appearance.targetable = 1;
  3742. spawn->appearance.activity_status = ACTIVITY_STATUS_SOLID;
  3743. spawn->appearance.race = item && item->generic_info.appearance_id ? item->generic_info.appearance_id : 1472;
  3744. spawn->SetModelType(item && item->generic_info.appearance_id ? item->generic_info.appearance_id : 1472);
  3745. spawn->SetLocation(client->GetPlayer()->GetLocation());
  3746. spawn->SetZone(client->GetCurrentZone());
  3747. client->SetTempPlacementSpawn(spawn);
  3748. client->SetPlacementUniqueItemID(uniqueid);
  3749. client->GetCurrentZone()->AddSpawn(spawn);
  3750. }
  3751. }
  3752. break;
  3753. }
  3754. case COMMAND_GM:
  3755. {
  3756. if (sep && sep->arg[0] && sep->arg[1])
  3757. {
  3758. bool onOff = (strcmp(sep->arg[1], "on") == 0);
  3759. if (strcmp(sep->arg[0], "vision") == 0)
  3760. {
  3761. client->GetPlayer()->SetGMVision(onOff);
  3762. #if defined(__GNUC__)
  3763. database.insertCharacterProperty(client, CHAR_PROPERTY_GMVISION, (onOff) ? (char*)"1" : (char*)"0");
  3764. #else
  3765. database.insertCharacterProperty(client, CHAR_PROPERTY_GMVISION, (onOff) ? "1" : "0");
  3766. #endif
  3767. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3768. if (onOff)
  3769. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Vision Enabled!");
  3770. else
  3771. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Vision Disabled!");
  3772. }
  3773. else if (strcmp(sep->arg[0], "tag") == 0)
  3774. {
  3775. int32 value = 0;
  3776. int16 tag_icon = 0;
  3777. // groundspawn has special exception -1 argument so it needs to be handled here
  3778. if(sep->arg[2] && sep->arg[3] && ((tag_icon = atoul(sep->arg[3])) > 0) || (strncasecmp(sep->arg[1], "groundspawn", 11) == 0)) {
  3779. value = atoul(sep->arg[2]);
  3780. if(strncasecmp(sep->arg[1], "faction", 7) == 0){
  3781. if(!value) {
  3782. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid faction id.");
  3783. break;
  3784. }
  3785. if(!tag_icon) {
  3786. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid tag icon id.");
  3787. break;
  3788. }
  3789. client->GetPlayer()->AddGMVisualFilter(GMTagFilterType::GMFILTERTYPE_FACTION, value, "", tag_icon);
  3790. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3791. client->Message(CHANNEL_COLOR_RED, "Adding faction id %u with tag icon %u.", value, tag_icon);
  3792. }
  3793. else if(strncasecmp(sep->arg[1], "spawngroup", 10) == 0){
  3794. if(value>0) {
  3795. value = 1;
  3796. }
  3797. if(!tag_icon) {
  3798. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid tag icon id.");
  3799. break;
  3800. }
  3801. client->GetPlayer()->AddGMVisualFilter(GMTagFilterType::GMFILTERTYPE_SPAWNGROUP, value, "", tag_icon);
  3802. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3803. client->Message(CHANNEL_COLOR_RED, "Adding spawn group tag \"%s\" with tag icon %u.", (value == 1) ? "on" : "off", tag_icon);
  3804. }
  3805. else if(strncasecmp(sep->arg[1], "race", 4 == 0)){
  3806. if(!value) {
  3807. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid race id.");
  3808. break;
  3809. }
  3810. if(!tag_icon) {
  3811. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid tag icon id.");
  3812. break;
  3813. }
  3814. client->GetPlayer()->AddGMVisualFilter(GMTagFilterType::GMFILTERTYPE_RACE, value, "", tag_icon);
  3815. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3816. client->Message(CHANNEL_COLOR_RED, "Adding race id %u with tag icon %u.", value, tag_icon);
  3817. }
  3818. else if(strncasecmp(sep->arg[1], "groundspawn", 11) == 0){
  3819. // one less argument value field not tag_icon for this one
  3820. if(!value) {
  3821. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid tag icon id.");
  3822. break;
  3823. }
  3824. client->GetPlayer()->AddGMVisualFilter(GMTagFilterType::GMFILTERTYPE_GROUNDSPAWN, 1, "", value);
  3825. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3826. client->Message(CHANNEL_COLOR_RED, "Adding groundspawns with tag icon %u.", value);
  3827. }
  3828. }
  3829. else {
  3830. if(strncasecmp(sep->arg[1], "clear", 5) == 0){
  3831. client->GetPlayer()->ClearGMVisualFilters();
  3832. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Tags Cleared!");
  3833. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3834. }
  3835. else {
  3836. client->SimpleMessage(CHANNEL_COLOR_RED, "GM Tagging Missing Arguments:");
  3837. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/gm tag [type] [value] [visual_icon_display]");
  3838. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/gm tag clear - Clears all GM visual tags");
  3839. client->SimpleMessage(CHANNEL_COLOR_RED, "Visual Type Options:");
  3840. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "type: faction, value: faction id of spawn(s)");
  3841. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "type: spawngroup, value: 1 to show grouped, 0 to show not grouped");
  3842. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "type: race, value: race id (either against base race or race id in spawn details)");
  3843. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "type: groundspawn, value: (not used)");
  3844. client->SimpleMessage(CHANNEL_COLOR_RED, "Visual Icon Options:");
  3845. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3846. "1 = skull, 2 = shield half dark blue / half light blue, 3 = purple? star, 4 = yellow sword, 5 = red X, 6 = green flame");
  3847. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3848. "7 = Number \"1\", 8 = Number \"2\", 9 = Number \"3\", 10 = Number \"4\", 11 = Number \"5\", 12 = Number \"6\"");
  3849. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3850. "25 = shield, 26 = green plus, 27 = crossed swords, 28 = bow with arrow in it, 29 = light blue lightning bolt");
  3851. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3852. "30 = bard instrument (hard to see), 31 = writ with shield, 32 = writ with green +, 33 = writ with crossed sword");
  3853. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3854. "34 = writ with bow, 35 = writ with light blue lightning bolt, 36 = same as 30, 37 = party with crossed sword, shield and lightning bolt");
  3855. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3856. "38 = shaking hands green background, 39 = shaking hands dark green background, unlocked keylock");
  3857. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3858. "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");
  3859. }
  3860. }
  3861. }
  3862. else if (strcmp(sep->arg[0], "regiondebug") == 0)
  3863. {
  3864. client->SetRegionDebug(onOff);
  3865. #if defined(__GNUC__)
  3866. database.insertCharacterProperty(client, CHAR_PROPERTY_REGIONDEBUG, (onOff) ? (char*)"1" : (char*)"0");
  3867. #else
  3868. database.insertCharacterProperty(client, CHAR_PROPERTY_REGIONDEBUG, (onOff) ? "1" : "0");
  3869. #endif
  3870. if (onOff)
  3871. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Region Debug Enabled!");
  3872. else
  3873. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Region Debug Disabled!");
  3874. }
  3875. else if (strcmp(sep->arg[0], "sight") == 0)
  3876. {
  3877. if(onOff && cmdTarget) {
  3878. client->SetPlayerPOVGhost(cmdTarget);
  3879. }
  3880. else
  3881. client->SetPlayerPOVGhost(nullptr);
  3882. }
  3883. else if (strcmp(sep->arg[0], "controleffects") == 0)
  3884. {
  3885. if(cmdTarget && cmdTarget->IsEntity()) {
  3886. ((Entity*)cmdTarget)->SendControlEffectDetailsToClient(client);
  3887. }
  3888. else {
  3889. client->GetPlayer()->SendControlEffectDetailsToClient(client);
  3890. }
  3891. }
  3892. else if (strcmp(sep->arg[0], "luadebug") == 0)
  3893. {
  3894. client->SetLuaDebugClient(onOff);
  3895. #if defined(__GNUC__)
  3896. database.insertCharacterProperty(client, CHAR_PROPERTY_LUADEBUG, (onOff) ? (char*)"1" : (char*)"0");
  3897. #else
  3898. database.insertCharacterProperty(client, CHAR_PROPERTY_LUADEBUG, (onOff) ? "1" : "0");
  3899. #endif
  3900. if (onOff)
  3901. {
  3902. if (lua_interface)
  3903. lua_interface->UpdateDebugClients(client);
  3904. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will now receive LUA error messages.");
  3905. }
  3906. else
  3907. {
  3908. if (lua_interface)
  3909. lua_interface->RemoveDebugClients(client);
  3910. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will no longer receive LUA error messages.");
  3911. }
  3912. }
  3913. }
  3914. break;
  3915. }
  3916. case COMMAND_ATTACK:
  3917. case COMMAND_AUTO_ATTACK:{
  3918. int8 type = 1;
  3919. bool update = false;
  3920. Player* player = client->GetPlayer();
  3921. if(!player)
  3922. break;
  3923. bool incombat = player->EngagedInCombat();
  3924. if(sep && sep->arg[0] && sep->IsNumber(0))
  3925. type = atoi(sep->arg[0]);
  3926. if(!client->GetPlayer()->Alive()){
  3927. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  3928. break;
  3929. }
  3930. if(type == 0){
  3931. if(incombat)
  3932. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You stop fighting.");
  3933. player->StopCombat(type);
  3934. update = true;
  3935. }
  3936. else {
  3937. if(type == 2){
  3938. player->InCombat(false);
  3939. if(incombat && player->GetRangeAttack()){
  3940. player->StopCombat(type);
  3941. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You stop fighting.");
  3942. update = true;
  3943. }
  3944. else{
  3945. player->SetRangeAttack(true);
  3946. player->InCombat(true, true);
  3947. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You start fighting.");
  3948. update = true;
  3949. }
  3950. }
  3951. else {
  3952. player->InCombat(false, true);
  3953. player->SetRangeAttack(false);
  3954. player->InCombat(true);
  3955. if(!incombat) {
  3956. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You start fighting.");
  3957. update = true;
  3958. }
  3959. }
  3960. /*else
  3961. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You cannot attack that!");*/
  3962. }
  3963. if(update) {
  3964. player->SetCharSheetChanged(true);
  3965. }
  3966. break;
  3967. }
  3968. case COMMAND_DEPOP:{
  3969. bool allow_respawns = false;
  3970. if(sep && sep->arg[0] && sep->IsNumber(0)){
  3971. if(atoi(sep->arg[0]) == 1)
  3972. allow_respawns = true;
  3973. }
  3974. client->GetCurrentZone()->Depop(allow_respawns);
  3975. break;
  3976. }
  3977. case COMMAND_REPOP:{
  3978. client->GetCurrentZone()->Depop(false, true);
  3979. break;
  3980. }
  3981. case COMMAND_BUYBACK:{
  3982. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  3983. // 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
  3984. int64 id = atoi64(sep->arg[0]);
  3985. // get the first int32, the item id
  3986. //int32 item_id = (int32)id;
  3987. // get the second int32, the unique id
  3988. int32 unique_id = (int32)(id>>32);
  3989. int8 quantity = atoi(sep->arg[1]);
  3990. if(quantity == 255)
  3991. quantity = 1;
  3992. client->BuyBack(unique_id, quantity);
  3993. }
  3994. break;
  3995. }
  3996. case COMMAND_MERCHANT_BUY:{
  3997. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  3998. int32 item_id = atoul(sep->arg[0]);
  3999. int8 quantity = atoi(sep->arg[1]);
  4000. client->BuyItem(item_id, quantity);
  4001. }
  4002. else
  4003. Command_SendMerchantWindow(client, sep);
  4004. break;
  4005. }
  4006. case COMMAND_MERCHANT_SELL:{
  4007. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  4008. // 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
  4009. int64 id = atoi64(sep->arg[0]);
  4010. // get the first int32, the item id
  4011. int32 item_id = (int32)id;
  4012. // get the second int32, the unique id
  4013. int32 unique_id = (int32)(id>>32);
  4014. int8 quantity = atoi(sep->arg[1]);
  4015. LogWrite(MERCHANT__DEBUG, 0, "Merchant", "Selling Item: Item Id = %ul, unique id = %ul, Quantity = %i", item_id, unique_id, quantity);
  4016. client->SellItem(item_id, quantity, unique_id);
  4017. }
  4018. break;
  4019. }
  4020. case COMMAND_MENDER_REPAIR: {
  4021. if (sep && sep->arg[0] && sep->IsNumber(0))
  4022. client->RepairItem(atoul(sep->arg[0]));
  4023. break;
  4024. }
  4025. case COMMAND_MENDER_REPAIR_ALL: {
  4026. client->RepairAllItems();
  4027. break;
  4028. }
  4029. case COMMAND_CANCEL_MERCHANT:{
  4030. client->SetMerchantTransaction(0);
  4031. break;
  4032. }
  4033. case COMMAND_START_MERCHANT:{
  4034. break;
  4035. }
  4036. case COMMAND_INVULNERABLE:{
  4037. sint8 val = -1;
  4038. if(sep && sep->arg[0] && sep->IsNumber(0)){
  4039. val = atoi(sep->arg[0]);
  4040. //devn00b: Fix for linux builds
  4041. #if defined(__GNUC__)
  4042. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? (char*) "1" : (char*) "0");
  4043. #else
  4044. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  4045. #endif
  4046. // database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  4047. client->GetPlayer()->SetInvulnerable(val==1);
  4048. if(client->GetPlayer()->GetInvulnerable())
  4049. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are now invulnerable!");
  4050. else
  4051. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are no longer invulnerable!");
  4052. }
  4053. if(val == -1)
  4054. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /invulnerable [0/1]");
  4055. break;
  4056. }
  4057. case COMMAND_REPAIR: {
  4058. Spawn* spawn = cmdTarget;
  4059. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR) {
  4060. client->SendHailCommand(spawn);
  4061. client->SetMerchantTransaction(spawn);
  4062. client->SendRepairList();
  4063. }
  4064. break;
  4065. }
  4066. case COMMAND_LOTTO: {
  4067. Spawn* spawn = cmdTarget;
  4068. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_LOTTO) {
  4069. client->SetMerchantTransaction(spawn);
  4070. client->ShowLottoWindow();
  4071. }
  4072. break;
  4073. }
  4074. case COMMAND_ACCEPT_REWARD:{
  4075. int32 unknown = 0;
  4076. int32 selectable_item_id = 0;
  4077. //Quest *quest = 0;
  4078. /* no idea what the first argument is for (faction maybe?)
  4079. if the reward has a selectable item reward, it's sent as the second argument
  4080. if neither of these are included in the reward, there is no sep
  4081. 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
  4082. only 1 quest or collection reward may be displayed at a time */
  4083. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  4084. unknown = atoul(sep->arg[0]);
  4085. selectable_item_id = atoul(sep->arg[1]);
  4086. }
  4087. /* 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
  4088. ** Otherwise it will likely be a DoF client scenario (pending item rewards, selectable item rewards) which is specifying an item id
  4089. ** 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
  4090. */
  4091. int32 item_id = 0;
  4092. if(sep && sep->arg[0][0] && sep->IsNumber(0))
  4093. item_id = atoul(sep->arg[0]);
  4094. bool collectedItems = client->GetPlayer()->AcceptQuestReward(item_id, selectable_item_id);
  4095. if (collectedItems) {
  4096. EQ2Packet* outapp = client->GetPlayer()->SendInventoryUpdate(client->GetVersion());
  4097. if (outapp)
  4098. client->QueuePacket(outapp);
  4099. }
  4100. else
  4101. LogWrite(COMMAND__ERROR, 0, "Command", "Error in COMMAND_ACCEPT_REWARD. No pending quest or collection reward was found (unknown=%u).", unknown);
  4102. break;
  4103. }
  4104. case COMMAND_BUY_FROM_BROKER:{
  4105. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  4106. int32 item_id = atoul(sep->arg[0]);
  4107. int16 quantity = atoul(sep->arg[1]);
  4108. Item* item = master_item_list.GetItem(item_id);
  4109. if(item && item->generic_info.max_charges > 1)
  4110. quantity = item->generic_info.max_charges;
  4111. client->AddItem(item_id, quantity, AddItemType::BUY_FROM_BROKER);
  4112. }
  4113. break;
  4114. }
  4115. case COMMAND_SEARCH_STORES_PAGE:{
  4116. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  4117. int32 page = atoul(sep->arg[0]);
  4118. client->SearchStore(page);
  4119. }
  4120. break;
  4121. }
  4122. case COMMAND_SEARCH_STORES:{
  4123. if(sep && sep->arg[0][0]){
  4124. const char* values = sep->argplus[0];
  4125. if(values){
  4126. LogWrite(ITEM__WARNING, 0, "Item", "SearchStores: %s", values);
  4127. map<string, string> str_values = TranslateBrokerRequest(values);
  4128. vector<Item*>* items = master_item_list.GetItems(str_values, client);
  4129. if(items){
  4130. client->SetItemSearch(items);
  4131. client->SearchStore(0);
  4132. }
  4133. }
  4134. }
  4135. break;
  4136. }
  4137. case COMMAND_LUADEBUG:{
  4138. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "start") == 0){
  4139. client->SetLuaDebugClient(true);
  4140. if(lua_interface)
  4141. lua_interface->UpdateDebugClients(client);
  4142. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will now receive LUA error messages.");
  4143. }
  4144. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "stop") == 0){
  4145. client->SetLuaDebugClient(false);
  4146. if(lua_interface)
  4147. lua_interface->RemoveDebugClients(client);
  4148. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will no longer receive LUA error messages.");
  4149. }
  4150. else{
  4151. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /luadebug {start | stop}");
  4152. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will allow you to receive lua debug messages normally seen only in the console.");
  4153. }
  4154. break;
  4155. }
  4156. case COMMAND_SPAWN_GROUP:
  4157. {
  4158. Spawn* target = cmdTarget;
  4159. if(target && target->IsPlayer() == false)
  4160. {
  4161. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "create") == 0)
  4162. {
  4163. if(target->GetSpawnLocationPlacementID() > 0)
  4164. {
  4165. if(sep->arg[1] && !sep->IsNumber(1) && strlen(sep->arg[1]) > 0)
  4166. {
  4167. int32 id = database.CreateSpawnGroup(target, sep->arg[1]);
  4168. if(id > 0)
  4169. client->Message(CHANNEL_COLOR_YELLOW, "Successfully created new spawn group with id: %u", id);
  4170. else
  4171. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error creating group, check console for details.");
  4172. target->SetSpawnGroupID(id);
  4173. target->AddSpawnToGroup(target);
  4174. }
  4175. else
  4176. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group create [name]");
  4177. }
  4178. else
  4179. 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.");
  4180. }
  4181. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "add") == 0)
  4182. {
  4183. if(sep->arg[1] && sep->IsNumber(1))
  4184. {
  4185. int32 group_id = atoul(sep->arg[1]);
  4186. Spawn* leader = client->GetCurrentZone()->GetSpawnGroup(group_id);
  4187. if(leader)
  4188. {
  4189. leader->AddSpawnToGroup(target);
  4190. target->SetSpawnGroupID(group_id);
  4191. if(database.SpawnGroupAddSpawn(target, group_id))
  4192. client->Message(CHANNEL_COLOR_YELLOW, "Successfully added '%s' to group id: %u", target->GetName(), group_id);
  4193. else
  4194. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error adding spawn to group, check console for details.");
  4195. }
  4196. else
  4197. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No spawns found in the current zone for that spawn group, be sure to use '/spawn group create' first!");
  4198. }
  4199. else
  4200. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group add [group id]");
  4201. }
  4202. else if(target->GetSpawnGroupID() == 0)
  4203. {
  4204. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That spawn is not in a group!");
  4205. }
  4206. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "remove") == 0)
  4207. {
  4208. int32 group_id = target->GetSpawnGroupID();
  4209. target->RemoveSpawnFromGroup();
  4210. if(database.SpawnGroupRemoveSpawn(target, group_id))
  4211. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed '%s' from group id: %u", target->GetName(), group_id);
  4212. else
  4213. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing spawn from group, check console for details.");
  4214. }
  4215. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "associate") == 0)
  4216. {
  4217. int32 group_id = target->GetSpawnGroupID();
  4218. if(sep->arg[1] && sep->IsNumber(1))
  4219. {
  4220. if(database.SpawnGroupAddAssociation(group_id, atoul(sep->arg[1])))
  4221. client->Message(CHANNEL_COLOR_YELLOW, "Successfully associated group id %u with group id %u", group_id, atoul(sep->arg[1]));
  4222. else
  4223. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error associating groups, check console for details.");
  4224. }
  4225. else
  4226. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Allows you to spawn only one associated group at once. Syntax: /spawn group associate [other group id]");
  4227. }
  4228. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "deassociate") == 0)
  4229. {
  4230. int32 group_id = target->GetSpawnGroupID();
  4231. if(sep->arg[1] && sep->IsNumber(1))
  4232. {
  4233. if(database.SpawnGroupRemoveAssociation(group_id, atoul(sep->arg[1])))
  4234. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed association between group id %u and group id %u", group_id, atoul(sep->arg[1]));
  4235. else
  4236. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing group associations, check console for details.");
  4237. }
  4238. else
  4239. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Removes previous group associations. Syntax: /spawn group deassociate [other group id]");
  4240. }
  4241. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "chance") == 0)
  4242. {
  4243. if(sep->arg[1] && sep->IsNumber(1))
  4244. {
  4245. if(database.SetGroupSpawnChance(target->GetSpawnGroupID(), atof(sep->arg[1])))
  4246. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set group spawn chance to %f for group id: %u", atof(sep->arg[1]), target->GetSpawnGroupID());
  4247. else
  4248. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error setting group spawn chance, check console for details.");
  4249. }
  4250. else
  4251. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group chance [group's spawn chance percentage]");
  4252. }
  4253. else
  4254. {
  4255. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command allows you to modify spawn groups.");
  4256. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group [create/add/remove/chance/associate/deassociate]");
  4257. }
  4258. }
  4259. else
  4260. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select a valid spawn to use this command.");
  4261. break;
  4262. }
  4263. case COMMAND_SPAWN_COMBINE:{
  4264. Spawn* spawn = cmdTarget;
  4265. float radius = 0;
  4266. bool failed = true;
  4267. if(spawn && !spawn->IsPlayer() && sep && sep->arg[0] && sep->arg[0][0]){
  4268. failed = false;
  4269. if(spawn->GetSpawnGroupID() > 0){
  4270. 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.");
  4271. }
  4272. else if(sep->IsNumber(0)){
  4273. radius = atof(sep->arg[0]);
  4274. client->CombineSpawns(radius, spawn);
  4275. }
  4276. else{
  4277. if(strncasecmp(sep->arg[0], "add", 3) == 0){
  4278. client->AddCombineSpawn(spawn);
  4279. }
  4280. else if(strncasecmp(sep->arg[0], "remove", 6) == 0){
  4281. client->RemoveCombineSpawn(spawn);
  4282. }
  4283. else if(strncasecmp(sep->arg[0], "save", 4) == 0){
  4284. const char* name = 0;
  4285. if(sep->arg[1] && sep->arg[1][0])
  4286. name = sep->argplus[1];
  4287. client->SaveCombineSpawns(name);
  4288. }
  4289. else
  4290. failed = true;
  4291. }
  4292. }
  4293. if(failed){
  4294. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command combines several spawns into a single spawn group.");
  4295. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn combine [radius/add/remove/save]");
  4296. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Ex: /spawn combine 1, /spawn combine save (spawn group name)");
  4297. }
  4298. break;
  4299. }
  4300. case COMMAND_SPAWN_CREATE:{
  4301. Spawn* spawn = 0;
  4302. if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "object", 6) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  4303. spawn = new Object();
  4304. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  4305. }
  4306. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "groundspawn", 11) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  4307. spawn = new GroundSpawn();
  4308. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  4309. }
  4310. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "sign", 4) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  4311. spawn = new Sign();
  4312. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  4313. }
  4314. else if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "npc", 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  4315. spawn = new NPC();
  4316. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  4317. spawn->appearance.pos.collision_radius = 32;
  4318. spawn->secondary_command_list_id = 0;
  4319. spawn->primary_command_list_id = 0;
  4320. spawn->appearance.display_name = 1;
  4321. spawn->appearance.show_level = 1;
  4322. spawn->appearance.attackable = 1;
  4323. }
  4324. else{
  4325. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn create [spawn type] [race type] [class type] [level] [name] (difficulty) (size)");
  4326. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are required except difficulty and size. Valid types are Object, NPC, Sign, or GroundSpawn");
  4327. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn create npc 203 1 50 'Lady Vox' 1 32");
  4328. break;
  4329. }
  4330. spawn->SetID(Spawn::NextID());
  4331. spawn->SetX(client->GetPlayer()->GetX());
  4332. spawn->SetY(client->GetPlayer()->GetY());
  4333. spawn->SetZ(client->GetPlayer()->GetZ());
  4334. spawn->SetHeading(client->GetPlayer()->GetHeading());
  4335. spawn->SetSpawnOrigX(spawn->GetX());
  4336. spawn->SetSpawnOrigY(spawn->GetY());
  4337. spawn->SetSpawnOrigZ(spawn->GetZ());
  4338. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  4339. if(spawn->IsSign())
  4340. {
  4341. ((Sign*)spawn)->SetSignType(SIGN_TYPE_GENERIC);
  4342. ((Sign*)spawn)->SetSignDistance(20.0f);
  4343. ((Sign*)spawn)->SetIncludeLocation(1);
  4344. ((Sign*)spawn)->SetIncludeHeading(1);
  4345. ((Sign*)spawn)->SetInitialState(1);
  4346. ((Sign*)spawn)->SetSignTitle(sep->arg[4]);
  4347. ((Sign*)spawn)->SetActivityStatus(64);
  4348. spawn->appearance.race = 0;
  4349. spawn->SetLevel(0);
  4350. spawn->SetHP(0);
  4351. spawn->SetTotalHP(0);
  4352. spawn->SetPower(0);
  4353. spawn->SetTotalPower(0);
  4354. spawn->SetDifficulty(0);
  4355. spawn->SetTargetable(0);
  4356. spawn->SetSogaModelType(0);
  4357. spawn->SetCollisionRadius(19);
  4358. ((Sign*)spawn)->SetWidgetX(client->GetPlayer()->GetX());
  4359. ((Sign*)spawn)->SetWidgetY(client->GetPlayer()->GetY());
  4360. ((Sign*)spawn)->SetWidgetZ(client->GetPlayer()->GetZ());
  4361. spawn->SetLocation(client->GetPlayer()->GetLocation());
  4362. spawn->appearance.model_type = atoul(sep->arg[1]);
  4363. }
  4364. else
  4365. {
  4366. spawn->appearance.targetable = 1;
  4367. spawn->appearance.race = 255;
  4368. spawn->SetLocation(client->GetPlayer()->GetLocation());
  4369. spawn->SetModelType(atoi(sep->arg[1]));
  4370. spawn->SetAdventureClass(atoi(sep->arg[2]));
  4371. spawn->SetLevel(atoi(sep->arg[3]));
  4372. spawn->SetName(sep->arg[4]);
  4373. if(sep->arg[5][0] && sep->IsNumber(5))
  4374. spawn->SetDifficulty(atoi(sep->arg[5]));
  4375. if(sep->arg[6][0] && sep->IsNumber(6))
  4376. spawn->size = atoi(sep->arg[6]);
  4377. if(spawn->GetTotalHP() == 0){
  4378. spawn->SetTotalHP(25*spawn->GetLevel() + 1);
  4379. spawn->SetHP(25*spawn->GetLevel() + 1);
  4380. }
  4381. if(spawn->GetTotalPower() == 0){
  4382. spawn->SetTotalPower(25*spawn->GetLevel() + 1);
  4383. spawn->SetPower(25*spawn->GetLevel() + 1);
  4384. }
  4385. }
  4386. client->GetCurrentZone()->AddSpawn(spawn);
  4387. break;
  4388. }
  4389. case COMMAND_SPAWN_EQUIPMENT:{
  4390. Spawn* spawn = cmdTarget;
  4391. if(spawn && sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1) && spawn->IsEntity()){
  4392. int8 slot = atoi(sep->arg[0]);
  4393. int16 type = atoi(sep->arg[1]);
  4394. int8 red = 0;
  4395. int8 green = 0;
  4396. int8 blue = 0;
  4397. int8 h_red = 0;
  4398. int8 h_green = 0;
  4399. int8 h_blue = 0;
  4400. if(sep->arg[2])
  4401. red = atoi(sep->arg[2]);
  4402. if(sep->arg[3])
  4403. green = atoi(sep->arg[3]);
  4404. if(sep->arg[4])
  4405. blue = atoi(sep->arg[4]);
  4406. if(sep->arg[5])
  4407. h_red = atoi(sep->arg[5]);
  4408. if(sep->arg[6])
  4409. h_green = atoi(sep->arg[6]);
  4410. if(sep->arg[7])
  4411. h_blue = atoi(sep->arg[7]);
  4412. ((Entity*)spawn)->SetEquipment(slot, type, red, green, blue, h_red, h_green, h_blue);
  4413. database.SaveNPCAppearanceEquipment(spawn->GetDatabaseID() , slot, type, red, green, blue, h_red, h_green, h_blue);
  4414. }
  4415. else{
  4416. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn equipment [slot] [appearance id] (red) (green) (blue) (highlight red) (hgreen) (hblue)");
  4417. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn's equipment. ");
  4418. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Slot is 0-24, Appearance ID from appearances table, Colors are 0-255");
  4419. }
  4420. break;
  4421. }
  4422. case COMMAND_SPAWN_DETAILS: {
  4423. Spawn* spawn = cmdTarget;
  4424. if (sep && sep->arg[0][0]) {
  4425. if (cmdTarget)
  4426. {
  4427. if (ToLower(string(sep->arg[0])) == "los")
  4428. {
  4429. bool hasLOS = client->GetPlayer()->CheckLoS(cmdTarget);
  4430. if (hasLOS)
  4431. client->Message(CHANNEL_COLOR_YELLOW, "You have line of sight with %s", spawn->GetName());
  4432. else
  4433. client->Message(CHANNEL_COLOR_RED, "You DO NOT have line of sight with %s", spawn->GetName());
  4434. break;
  4435. }
  4436. else if (ToLower(string(sep->arg[0])) == "bestz")
  4437. {
  4438. glm::vec3 targPos(cmdTarget->GetX(), cmdTarget->GetZ(), cmdTarget->GetY());
  4439. float bestZ = client->GetPlayer()->FindDestGroundZ(targPos, cmdTarget->GetYOffset());
  4440. client->Message(CHANNEL_COLOR_YELLOW, "Best Z for %s is %f", spawn->GetName(), bestZ);
  4441. break;
  4442. }
  4443. else if (ToLower(string(sep->arg[0])) == "inwater")
  4444. {
  4445. if (cmdTarget->GetRegionMap() == nullptr)
  4446. client->SimpleMessage(CHANNEL_COLOR_RED, "No water map for zone.");
  4447. else
  4448. {
  4449. bool inWater = cmdTarget->InWater();
  4450. client->Message(CHANNEL_COLOR_YELLOW, "%s is %s.", cmdTarget->GetName(), inWater ? "in water" : "out of water");
  4451. }
  4452. break;
  4453. }
  4454. else if (ToLower(string(sep->arg[0])) == "inlava")
  4455. {
  4456. if (cmdTarget->GetRegionMap() == nullptr)
  4457. client->SimpleMessage(CHANNEL_COLOR_RED, "No region map for zone.");
  4458. else
  4459. {
  4460. bool inLava = cmdTarget->InLava();
  4461. client->Message(CHANNEL_COLOR_YELLOW, "%s is %s.", cmdTarget->GetName(), inLava ? "in lava" : "out of lava");
  4462. }
  4463. break;
  4464. }
  4465. else if (ToLower(string(sep->arg[0])) == "regions")
  4466. {
  4467. glm::vec3 targPos(cmdTarget->GetX(), cmdTarget->GetY(), cmdTarget->GetZ());
  4468. if (cmdTarget->GetRegionMap() == nullptr)
  4469. client->SimpleMessage(CHANNEL_COLOR_RED, "No region map for zone.");
  4470. else
  4471. {
  4472. cmdTarget->GetRegionMap()->IdentifyRegionsInGrid(client, targPos);
  4473. }
  4474. break;
  4475. }
  4476. else if (ToLower(string(sep->arg[0])) == "behind")
  4477. {
  4478. bool isBehind = client->GetPlayer()->BehindTarget(cmdTarget);
  4479. client->Message(CHANNEL_COLOR_YELLOW, "%s %s.", isBehind ? "YOU are behind" : "YOU are NOT behind", cmdTarget->GetName());
  4480. break;
  4481. }
  4482. else if (ToLower(string(sep->arg[0])) == "infront")
  4483. {
  4484. bool isBehind = client->GetPlayer()->InFrontSpawn(cmdTarget, client->GetPlayer()->GetX(), client->GetPlayer()->GetZ());
  4485. client->Message(CHANNEL_COLOR_YELLOW, "%s %s.", isBehind ? "YOU are infront of" : "YOU are NOT infront of", cmdTarget->GetName());
  4486. break;
  4487. }
  4488. else if (ToLower(string(sep->arg[0])) == "flank")
  4489. {
  4490. bool isFlanking = client->GetPlayer()->FlankingTarget(cmdTarget);
  4491. client->Message(CHANNEL_COLOR_YELLOW, "%s is %s.", isFlanking ? "YOU are flanking" : "YOU are NOT flanking", cmdTarget->GetName());
  4492. break;
  4493. }
  4494. else if (ToLower(string(sep->arg[0])) == "aggro")
  4495. {
  4496. if(cmdTarget->IsNPC() && ((NPC*)cmdTarget)->Brain()) {
  4497. ((NPC*)cmdTarget)->Brain()->SendEncounterList(client);
  4498. ((NPC*)cmdTarget)->Brain()->SendHateList(client);
  4499. }
  4500. else {
  4501. client->SimpleMessage(CHANNEL_COLOR_RED, "/spawn details aggro is for NPCs only!");
  4502. }
  4503. break;
  4504. }
  4505. else if (ToLower(string(sep->arg[0])) == "angle")
  4506. {
  4507. float spawnAngle = client->GetPlayer()->GetFaceTarget(cmdTarget->GetX(), cmdTarget->GetZ());
  4508. 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());
  4509. break;
  4510. }
  4511. }
  4512. if (sep->IsNumber(0))
  4513. {
  4514. float radius = atof(sep->arg[0]);
  4515. if (!client->GetCurrentZone()->SendRadiusSpawnInfo(client, radius))
  4516. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No results in the radius were found.");
  4517. break;
  4518. }
  4519. }
  4520. if (spawn) {
  4521. const char* type = "NPC";
  4522. if (spawn->IsObject())
  4523. type = "Object";
  4524. else if (spawn->IsSign())
  4525. type = "Sign";
  4526. else if (spawn->IsWidget())
  4527. type = "Widget";
  4528. else if (spawn->IsGroundSpawn())
  4529. type = "GroundSpawn";
  4530. int16 race_type = race_types_list.GetRaceType(spawn->GetModelType());
  4531. int16 race_base_type = race_types_list.GetRaceBaseType(spawn->GetModelType());
  4532. char* category = race_types_list.GetRaceTypeCategory(spawn->GetModelType());
  4533. char* subcategory = race_types_list.GetRaceTypeSubCategory(spawn->GetModelType());
  4534. char* modelname = race_types_list.GetRaceTypeModelName(spawn->GetModelType());
  4535. client->Message(CHANNEL_COLOR_YELLOW, "Name: %s, %s ID: %u", spawn->GetName(), type, spawn->GetDatabaseID());
  4536. client->Message(CHANNEL_COLOR_YELLOW, "Last Name: %s, Sub-Title: %s, Prefix: %s, Suffix: %s", spawn->GetLastName(), spawn->GetSubTitle(), spawn->GetPrefixTitle(), spawn->GetSuffixTitle());
  4537. client->Message(CHANNEL_COLOR_YELLOW, "Spawn Location ID: %u, Spawn Group ID: %u", spawn->GetSpawnLocationID(), spawn->GetSpawnGroupID());
  4538. client->Message(CHANNEL_COLOR_YELLOW, "Faction ID: %u, Merchant ID: %u, Transporter ID: %u", spawn->GetFactionID(), spawn->GetMerchantID(), spawn->GetTransporterID());
  4539. client->Message(CHANNEL_COLOR_YELLOW, "Grid ID: %u", spawn->GetLocation());
  4540. client->Message(CHANNEL_COLOR_YELLOW, "Race: %i, Class: %i, Gender: %i", spawn->GetRace(), spawn->GetAdventureClass(), spawn->GetGender());
  4541. client->Message(CHANNEL_COLOR_YELLOW, "Level: %i, HP: %u / %u, Power: %u / %u", spawn->GetLevel(), spawn->GetHP(), spawn->GetTotalHP(), spawn->GetPower(), spawn->GetTotalPower());
  4542. 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());
  4543. client->Message(CHANNEL_COLOR_YELLOW, "Collision Radius: %i, Size: %i, Difficulty: %i, Heroic: %i", spawn->GetCollisionRadius(), spawn->GetSize(), spawn->GetDifficulty(), spawn->GetHeroic());
  4544. client->Message(CHANNEL_COLOR_YELLOW, "Targetable: %i, Show Name: %i, Attackable: %i, Show Level: %i", spawn->GetTargetable(), spawn->GetShowName(), spawn->GetAttackable(), spawn->GetShowLevel());
  4545. client->Message(CHANNEL_COLOR_YELLOW, "Show Command Icon: %i, Display Hand Icon: %i", spawn->GetShowCommandIcon(), spawn->GetShowHandIcon());
  4546. if (spawn->IsEntity()) {
  4547. 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());
  4548. 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());
  4549. }
  4550. 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);
  4551. client->Message(CHANNEL_COLOR_YELLOW, "Primary Command Type: %u, Secondary Command Type: %u", spawn->GetPrimaryCommandListID(), spawn->GetSecondaryCommandListID());
  4552. 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());
  4553. 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);
  4554. if (spawn->IsNPC())
  4555. client->Message(CHANNEL_COLOR_YELLOW, "Randomize: %u", ((NPC*)spawn)->GetRandomize());
  4556. if (spawn->IsNPC()){
  4557. client->Message(CHANNEL_COLOR_YELLOW, "Heat Resist/Base: %u/%u",((NPC*)spawn)->GetHeatResistance(), ((NPC*)spawn)->GetHeatResistanceBase());
  4558. client->Message(CHANNEL_COLOR_YELLOW, "Cold Resist/Base: %u/%u",((NPC*)spawn)->GetColdResistance(), ((NPC*)spawn)->GetColdResistanceBase());
  4559. client->Message(CHANNEL_COLOR_YELLOW, "Magic Resist/Base: %u/%u",((NPC*)spawn)->GetMagicResistance(), ((NPC*)spawn)->GetMagicResistanceBase());
  4560. client->Message(CHANNEL_COLOR_YELLOW, "Mental Resist/Base: %u/%u",((NPC*)spawn)->GetMentalResistance(), ((NPC*)spawn)->GetMentalResistanceBase());
  4561. client->Message(CHANNEL_COLOR_YELLOW, "Divine Resist/Base: %u/%u",((NPC*)spawn)->GetDivineResistance(), ((NPC*)spawn)->GetDivineResistanceBase());
  4562. client->Message(CHANNEL_COLOR_YELLOW, "Disease Resist/Base: %u/%u",((NPC*)spawn)->GetDiseaseResistance(), ((NPC*)spawn)->GetDiseaseResistanceBase());
  4563. client->Message(CHANNEL_COLOR_YELLOW, "Poison Resist/Base: %u/%u",((NPC*)spawn)->GetPoisonResistance(), ((NPC*)spawn)->GetPoisonResistanceBase());
  4564. }
  4565. string details;
  4566. details += "\\#0000FFName: " + string(spawn->GetName()) + "\n";
  4567. details += "Type: " + string(type) + "\n";
  4568. details += "ID: " + to_string(spawn->GetDatabaseID()) + "\n";
  4569. details += "Last Name: " + string(spawn->GetLastName()) + "\n";
  4570. details += "Sub-Title: " + string(spawn->GetSubTitle()) + "\n";
  4571. details += "Prefix: " + string(spawn->GetPrefixTitle()) + "\n";
  4572. details += "Suffix: " + string(spawn->GetSuffixTitle()) + "\n";
  4573. details += "Race: " + to_string(spawn->GetRace()) + "\n";
  4574. details += "Class: " + to_string(spawn->GetAdventureClass()) + "\n";
  4575. details += "Gender: " + to_string(spawn->GetGender()) + "\n";
  4576. details += "Level: " + to_string(spawn->GetLevel()) + "\n";
  4577. details += "HP: " + to_string(spawn->GetHP()) + " / " + to_string(spawn->GetTotalHP()) + "(" + to_string(spawn->GetIntHPRatio()) + "%)\n";
  4578. details += "Power: " + to_string(spawn->GetPower()) + + " / " + to_string(spawn->GetTotalPower()) + "\n";
  4579. details += "Difficulty: " + to_string(spawn->GetDifficulty()) + "\n";
  4580. details += "Heroic: " + to_string(spawn->GetHeroic()) + "\n";
  4581. details += "Group ID: " + to_string(spawn->GetSpawnGroupID()) + "\n";
  4582. details += "Faction ID: " + to_string(spawn->GetFactionID()) + "\n";
  4583. details += "Merchant ID: " + to_string(spawn->GetMerchantID()) + "\n";
  4584. details += "Transport ID: " + to_string(spawn->GetTransporterID()) + "\n";
  4585. details += "Location ID: " + to_string(spawn->GetSpawnLocationID()) + "\n";
  4586. char x[16];
  4587. sprintf(x, "%.2f", spawn->GetX());
  4588. char y[16];
  4589. sprintf(y, "%.2f", spawn->GetY());
  4590. char z[16];
  4591. sprintf(z, "%.2f", spawn->GetZ());
  4592. details += "Location: " + string(x) + ", " + string(y) + ", " + string(z) + "\n";
  4593. string details2;
  4594. details2 += "Heading: " + to_string(spawn->GetHeading()) + "\n";
  4595. details2 += "Grid ID: " + to_string(spawn->GetLocation()) + "\n";
  4596. details2 += "Size: " + to_string(spawn->GetSize()) + "\n";
  4597. details2 += "Collision Radius: " + to_string(spawn->GetCollisionRadius()) + "\n";
  4598. details2 += "Respawn Time: " + to_string(spawn->GetRespawnTime()) + "\n";
  4599. details2 += "Targetable: " + to_string(spawn->GetTargetable()) + "\n";
  4600. details2 += "Show Name: " + to_string(spawn->GetShowName()) + "\n";
  4601. details2 += "Attackable: " + to_string(spawn->GetAttackable()) + "\n";
  4602. details2 += "Show Level: " + to_string(spawn->GetShowLevel()) + "\n";
  4603. details2 += "Show Command Icon: " + to_string(spawn->GetShowCommandIcon()) + "\n";
  4604. details2 += "Display Hand Icon: " + to_string(spawn->GetShowHandIcon()) + "\n";
  4605. details2 += "Model Type: " + to_string(spawn->GetModelType()) + "\n";
  4606. details2 += "Soga Race Type: " + to_string(spawn->GetSogaModelType()) + "\n";
  4607. details2 += "Race Type: " + to_string(race_type) + "\n";
  4608. details2 += "Race Base Type: " + to_string(race_base_type) + "\n";
  4609. details2 += "Race Category (Sub Category): " + std::string(category) + " (" + std::string(subcategory) + ")\n";
  4610. details2 += "Model Name: " + std::string(modelname) + "\n";
  4611. details2 += "Primary Command ID: " + to_string(spawn->GetPrimaryCommandListID()) + "\n";
  4612. details2 += "Secondary Cmd ID: " + to_string(spawn->GetSecondaryCommandListID()) + "\n";
  4613. details2 += "Visual State: " + to_string(spawn->GetVisualState()) + "\n";
  4614. details2 += "Action State: " + to_string(spawn->GetActionState()) + "\n";
  4615. details2 += "Mood State: " + to_string(spawn->GetMoodState()) + "\n";
  4616. details2 += "Initial State: " + to_string(spawn->GetInitialState()) + "\n";
  4617. details2 += "Activity Status: " + to_string(spawn->GetActivityStatus()) + "\n";
  4618. details2 += "Emote State: " + to_string(spawn->GetEmoteState()) + "\n";
  4619. string details3;
  4620. details3 += "Pitch: " + to_string(spawn->GetPitch()) + "\n";
  4621. details3 += "Roll: " + to_string(spawn->GetRoll()) + "\n";
  4622. details3 += "Hide Hood: " + to_string(spawn->appearance.hide_hood) + "\n";
  4623. details3 += "Speed: " + to_string(spawn->GetSpeed()) + "\n";
  4624. details3 += "BaseSpeed: " + to_string(spawn->GetBaseSpeed()) + "\n";
  4625. if(spawn->IsSign()) {
  4626. details3 += "Sign Language: " + to_string(((Sign*)spawn)->GetLanguage()) + "\n";
  4627. }
  4628. if(spawn->IsEntity())
  4629. {
  4630. Entity* ent = (Entity*)spawn;
  4631. details3 += "STR / STRBase: " + to_string(ent->GetInfoStruct()->get_str()) + " / " + to_string(ent->GetInfoStruct()->get_str_base()) + "\n";
  4632. details3 += "AGI / AGIBase: " + to_string(ent->GetInfoStruct()->get_agi()) + " / " + to_string(ent->GetInfoStruct()->get_agi_base()) + "\n";
  4633. details3 += "STA / STABase: " + to_string(ent->GetInfoStruct()->get_sta()) + " / " + to_string(ent->GetInfoStruct()->get_sta_base()) + "\n";
  4634. details3 += "INT / INTBase: " + to_string(ent->GetInfoStruct()->get_intel()) + " / " + to_string(ent->GetInfoStruct()->get_intel_base()) + "\n";
  4635. details3 += "WIS / WISBase: " + to_string(ent->GetInfoStruct()->get_wis()) + " / " + to_string(ent->GetInfoStruct()->get_wis_base()) + "\n";
  4636. }
  4637. string details4;
  4638. if (spawn->IsEntity()) {
  4639. details4 += "Facial Hair Type: " + to_string(((Entity*)spawn)->GetFacialHairType()) + "\n";
  4640. details4 += "Hair Type: " + to_string(((Entity*)spawn)->GetHairType()) + "\n";
  4641. details4 += "Chest Type: " + to_string(((Entity*)spawn)->GetChestType()) + "\n";
  4642. details4 += "Legs Type: " + to_string(((Entity*)spawn)->GetLegsType()) + "\n";
  4643. details4 += "Soga Facial Hair Type: " + to_string(((Entity*)spawn)->GetSogaFacialHairType()) + "\n";
  4644. details4 += "Soga Hair Type: " + to_string(((Entity*)spawn)->GetSogaHairType()) + "\n";
  4645. details4 += "Wing Type: " + to_string(((Entity*)spawn)->GetWingType()) + "\n";
  4646. if (spawn->IsNPC()) {
  4647. details4 += "\nRandomize: " + to_string(((NPC*)spawn)->GetRandomize()) + "\n";
  4648. }
  4649. }
  4650. const char* spawnScriptMsg = (spawn->GetSpawnScript() && strlen(spawn->GetSpawnScript())>0) ? spawn->GetSpawnScript() : "Not Set";
  4651. details4 += "\nSpawnScript: " + std::string(spawnScriptMsg) + "\n";
  4652. string title = string(spawn->GetName()) + "(" + to_string(spawn->GetDatabaseID()) + ")";
  4653. client->SendShowBook(client->GetPlayer(), title, 0, 4, details, details2, details3, details4);
  4654. }
  4655. else {
  4656. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn details (radius)");
  4657. 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.");
  4658. }
  4659. break;
  4660. }
  4661. case COMMAND_SPAWN_TARGET:{
  4662. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  4663. int32 spawn_id = atoul(sep->arg[0]);
  4664. int16 response = client->GetCurrentZone()->SetSpawnTargetable(spawn_id);
  4665. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  4666. }
  4667. else if(sep && sep->arg[0][0] && sep->arg[1][0] && sep->IsNumber(1) && ToLower(string(sep->arg[0])) == "radius"){
  4668. float distance = atof(sep->arg[1]);
  4669. int16 response = client->GetCurrentZone()->SetSpawnTargetable(client->GetPlayer(), distance);
  4670. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  4671. }
  4672. else{
  4673. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn target [spawn id]");
  4674. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn as targetable. Used to change a spawn if it was set to untargetable.");
  4675. }
  4676. break;
  4677. }
  4678. case COMMAND_SPAWN_SET:
  4679. {
  4680. Spawn* spawn = cmdTarget;
  4681. sint16 set_type = -1;
  4682. string type_str;
  4683. if (spawn)
  4684. {
  4685. // check if parameters are (location or list or not player and not a 2nd param), and that there is at least 1 value
  4686. 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)
  4687. {
  4688. // set the type, which will be 0 if location or list or invalid
  4689. set_type = spawn_set_values[ToLower(string(sep->arg[0]))];
  4690. }
  4691. if(set_type > 0)
  4692. {
  4693. // check if spawn set is NOT a char update, or not location, or isn't a number
  4694. 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)
  4695. {
  4696. client->SimpleMessage(CHANNEL_COLOR_RED, "Invalid value for set command.");
  4697. }
  4698. else
  4699. {
  4700. string name = string(spawn->GetName());
  4701. bool customSetSpawn = false;
  4702. if(set_type >= SPAWN_SET_CHEEK_TYPE && set_type <= SPAWN_SET_SOGA_NOSE_TYPE)
  4703. {
  4704. int8 index = sep->IsNumber(2) ? atoul(sep->arg[2]) : 0;
  4705. // override the standard setspawncommand, we pass arguments different!
  4706. if(SetSpawnCommand(client, spawn, set_type, sep->arg[1], true, false, nullptr, index))
  4707. customSetSpawn = true;
  4708. }
  4709. if(customSetSpawn || SetSpawnCommand(client, spawn, set_type, sep->argplus[1]))
  4710. {
  4711. if (set_type == SPAWN_SET_VALUE_EXPANSION_FLAG || set_type == SPAWN_SET_VALUE_HOLIDAY_FLAG)
  4712. {
  4713. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "A /reload spawns is required to properly update the spawns with the xpack/holiday flag.");
  4714. }
  4715. else if (set_type == SPAWN_SET_VALUE_NAME)
  4716. {
  4717. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "New name will not be effective until zone reload.");
  4718. }
  4719. else if (set_type == SPAWN_SET_SKIN_COLOR || (set_type >= SPAWN_SET_HAIR_COLOR1 && set_type <= SPAWN_SET_SOGA_EYE_COLOR))
  4720. {
  4721. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set color field to R G B: %s.", sep->argplus[1]);
  4722. }
  4723. else if(set_type == SPAWN_SET_VALUE_LOCATION)
  4724. {
  4725. spawn->SetLocation(client->GetPlayer()->GetLocation());
  4726. 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());
  4727. }
  4728. else
  4729. {
  4730. 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());
  4731. }
  4732. switch (set_type)
  4733. {
  4734. case SPAWN_SET_VALUE_EXPANSION_FLAG:
  4735. case SPAWN_SET_VALUE_HOLIDAY_FLAG:
  4736. case SPAWN_SET_VALUE_FACTION:
  4737. case SPAWN_SET_AAXP_REWARDS:
  4738. case SPAWN_SET_CHEEK_TYPE:
  4739. case SPAWN_SET_CHIN_TYPE:
  4740. case SPAWN_SET_EAR_TYPE:
  4741. case SPAWN_SET_EYE_BROW_TYPE:
  4742. case SPAWN_SET_EYE_TYPE:
  4743. case SPAWN_SET_LIP_TYPE:
  4744. case SPAWN_SET_NOSE_TYPE:
  4745. case SPAWN_SET_BODY_SIZE:
  4746. case SPAWN_SET_BODY_AGE:
  4747. case SPAWN_SET_SOGA_CHEEK_TYPE:
  4748. case SPAWN_SET_SOGA_CHIN_TYPE:
  4749. case SPAWN_SET_SOGA_EAR_TYPE:
  4750. case SPAWN_SET_SOGA_EYE_BROW_TYPE:
  4751. case SPAWN_SET_SOGA_EYE_TYPE:
  4752. case SPAWN_SET_SOGA_LIP_TYPE:
  4753. case SPAWN_SET_SOGA_NOSE_TYPE:
  4754. case SPAWN_SET_SOGA_BODY_SIZE:
  4755. case SPAWN_SET_SOGA_BODY_AGE:
  4756. case SPAWN_SET_ATTACK_TYPE:
  4757. case SPAWN_SET_RACE_TYPE:
  4758. case SPAWN_SET_LOOT_TIER:
  4759. case SPAWN_SET_LOOT_DROP_TYPE:
  4760. case SPAWN_SET_SCARED_STRONG_PLAYERS:
  4761. {
  4762. // not applicable already ran db command
  4763. break;
  4764. }
  4765. default:
  4766. {
  4767. client->GetCurrentZone()->ApplySetSpawnCommand(client, spawn, set_type, sep->argplus[1]);
  4768. break;
  4769. }
  4770. }
  4771. 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))
  4772. {
  4773. if(spawn->GetSpawnLocationID() > 0 && database.UpdateSpawnLocationSpawns(spawn))
  4774. {
  4775. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information for spawn '%s' (DBID: %u)", name.c_str(), spawn->GetDatabaseID());
  4776. }
  4777. else if(spawn->GetSpawnLocationID() > 0)
  4778. {
  4779. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn information, see console window for details.");
  4780. }
  4781. }
  4782. else
  4783. {
  4784. if(spawn->GetDatabaseID() > 0 && database.SaveSpawnInfo(spawn))
  4785. {
  4786. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn for spawn '%s' (DBID: %u)", name.c_str(), spawn->GetDatabaseID());
  4787. }
  4788. else if(spawn->GetDatabaseID() > 0)
  4789. {
  4790. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn, see console window for details.");
  4791. }
  4792. }
  4793. }
  4794. }
  4795. }
  4796. else if(set_type == 0)
  4797. {
  4798. // /spawn set list - lists all possible attributes that can be changed with this command, 10 per line.
  4799. map<string, int8>::iterator itr;
  4800. int i=0;
  4801. string list;
  4802. for(itr = spawn_set_values.begin(); itr != spawn_set_values.end(); itr++, i++)
  4803. {
  4804. if(i==10)
  4805. {
  4806. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  4807. i = 0;
  4808. }
  4809. if(i>0)
  4810. {
  4811. list.append(", ").append(itr->first);
  4812. }
  4813. else
  4814. {
  4815. list = itr->first;
  4816. }
  4817. }
  4818. if(list.length() > 0)
  4819. {
  4820. // if 1 or more, display in client.
  4821. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  4822. }
  4823. }
  4824. else
  4825. {
  4826. // syntax fail
  4827. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn set [type] [value]");
  4828. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used to change various settings for the targeted NPC or Object.");
  4829. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "For a list of changeable settings use /spawn set list");
  4830. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Note: /spawn set location does not require a value. The client's current location is used.");
  4831. }
  4832. }
  4833. break;
  4834. }
  4835. case COMMAND_SPAWN_REMOVE:{
  4836. Spawn* spawn = cmdTarget;
  4837. if(spawn && !spawn->IsPlayer()){
  4838. if(spawn->GetSpawnLocationID() > 0){
  4839. string name = string(spawn->GetName());
  4840. int32 dbid = spawn->GetDatabaseID();
  4841. if(database.RemoveSpawnFromSpawnLocation(spawn)){
  4842. client->GetCurrentZone()->RemoveSpawn(spawn, true, false, true, true, true);
  4843. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed spawn from zone for spawn '%s' (DBID: %u)", name.c_str(), dbid);
  4844. }
  4845. else
  4846. client->SimpleMessage(CHANNEL_COLOR_RED, "Error removing spawn, see console window for details.");
  4847. }
  4848. else
  4849. client->SimpleMessage(CHANNEL_COLOR_RED, "This spawn does not have a spawn group associated with it");
  4850. }
  4851. else{
  4852. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn remove");
  4853. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for removing the targeted NPC or Object from the zone.");
  4854. }
  4855. break;
  4856. }
  4857. case COMMAND_SPAWN_LIST:{
  4858. if(sep && sep->arg[0][0]){
  4859. vector<string>* results = database.GetSpawnNameList(sep->argplus[0]);
  4860. vector<string>::iterator itr;
  4861. if(results){
  4862. for(itr=results->begin();itr!=results->end();itr++){
  4863. client->SimpleMessage(CHANNEL_COLOR_YELLOW, (*itr).c_str());
  4864. }
  4865. safe_delete(results);
  4866. }
  4867. else
  4868. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found. ");
  4869. }
  4870. else{
  4871. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn list [name]");
  4872. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Name can be a partial match.");
  4873. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn list Qeynos Guard");
  4874. }
  4875. break;
  4876. }
  4877. case COMMAND_SPAWN_ADD:{
  4878. Spawn* spawn = cmdTarget;
  4879. if(spawn && sep && sep->arg[1][0] && (sep->IsNumber(0) || strncasecmp(sep->arg[0], "new", 3) == 0)){
  4880. if(spawn->GetSpawnLocationID() > 0){
  4881. client->Message(CHANNEL_COLOR_RED, "This spawn already has a spawn group id of %u, use /spawn remove to reassign it", spawn->GetSpawnLocationID());
  4882. break;
  4883. }
  4884. if(spawn->GetDatabaseID() == 0){
  4885. if(database.SaveSpawnInfo(spawn)) {
  4886. char spawn_type[32];
  4887. memset(spawn_type, 0, sizeof(spawn_type));
  4888. if (spawn->IsNPC())
  4889. strncpy(spawn_type, "NPC", sizeof(spawn_type) - 1);
  4890. else if (spawn->IsObject())
  4891. strncpy(spawn_type, "Object", sizeof(spawn_type) - 1);
  4892. else if (spawn->IsSign())
  4893. strncpy(spawn_type, "Sign", sizeof(spawn_type) - 1);
  4894. else if (spawn->IsGroundSpawn())
  4895. strncpy(spawn_type, "GroundSpawn", sizeof(spawn_type) - 1);
  4896. else
  4897. strncpy(spawn_type, "Unknown", sizeof(spawn_type) - 1);
  4898. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information with a %s id of %u", spawn_type, spawn->GetDatabaseID());
  4899. }
  4900. else
  4901. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn information, see console window for details.");
  4902. }
  4903. int32 spawn_group_id = 0;
  4904. if(strncasecmp(sep->arg[0], "new", 3) == 0)
  4905. spawn_group_id = database.GetNextSpawnLocation();
  4906. else
  4907. spawn_group_id = atol(sep->arg[0]);
  4908. int8 percent = 100;
  4909. if(sep->arg[2] && sep->IsNumber(2))
  4910. percent = atoi(sep->arg[2]);
  4911. spawn->SetSpawnLocationID(spawn_group_id);
  4912. float x_offset = database.GetSpawnLocationPlacementOffsetX(spawn->GetSpawnLocationID());
  4913. float y_offset = database.GetSpawnLocationPlacementOffsetY(spawn->GetSpawnLocationID());
  4914. float z_offset = database.GetSpawnLocationPlacementOffsetZ(spawn->GetSpawnLocationID());
  4915. if(database.SaveSpawnEntry(spawn, sep->arg[1], percent, x_offset, y_offset, z_offset))
  4916. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn location with a spawn group of %u", spawn->GetSpawnLocationID());
  4917. else
  4918. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn location, see console window for details.");
  4919. }
  4920. else{
  4921. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn add [spawn group id] [spawn group name] (percentage)");
  4922. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for adding the targeted NPC or Object to the database.");
  4923. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can substitute new for [spawn group id] to create a new one.");
  4924. }
  4925. break;
  4926. }
  4927. case COMMAND_SPAWN:{
  4928. int32 id = 0;
  4929. Spawn* spawn = 0;
  4930. if(sep && sep->arg[0] && sep->IsNumber(0)){
  4931. id = atol(sep->arg[0]);
  4932. spawn = client->GetCurrentZone()->GetSpawn(id);
  4933. }
  4934. if(id > 0 && spawn && spawn->appearance.name[0] == 0)
  4935. id = 0;
  4936. if(!id || !spawn){
  4937. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn [spawn id] (x) (y) (z) (heading) (location)");
  4938. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are optional except the id. The spawn id must be in the database.");
  4939. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn 1 0 0 0 0");
  4940. safe_delete(sep);
  4941. return;
  4942. }
  4943. if(sep && sep->arg[1][0]){
  4944. float x = atof(sep->arg[1]);
  4945. spawn->appearance.pos.X = x;
  4946. }
  4947. else
  4948. spawn->SetX(client->GetPlayer()->GetX(), false);
  4949. if(sep && sep->arg[2][0]){
  4950. float y = atof(sep->arg[2]);
  4951. spawn->appearance.pos.Y = y;
  4952. }
  4953. else
  4954. spawn->SetY(client->GetPlayer()->GetY(), false);
  4955. if(sep && sep->arg[3][0]){
  4956. float z = atof(sep->arg[3]);
  4957. spawn->appearance.pos.Z = z;
  4958. }
  4959. else
  4960. spawn->SetZ(client->GetPlayer()->GetZ(), false);
  4961. if(sep && sep->arg[4][0]){
  4962. float heading = atof(sep->arg[4]);
  4963. spawn->SetHeading(heading);
  4964. }
  4965. else
  4966. spawn->SetHeading(client->GetPlayer()->GetHeading(), false);
  4967. spawn->SetSpawnOrigX(spawn->GetX());
  4968. spawn->SetSpawnOrigY(spawn->GetY());
  4969. spawn->SetSpawnOrigZ(spawn->GetZ());
  4970. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  4971. if(sep && sep->arg[5][0])
  4972. spawn->SetLocation(atoul(sep->arg[5]));
  4973. else
  4974. spawn->SetLocation(client->GetPlayer()->GetLocation());
  4975. if(spawn->IsNPC() && spawn->GetTotalHP() == 0){
  4976. spawn->SetTotalHP(spawn->GetLevel() * 15);
  4977. spawn->SetHP(spawn->GetTotalHP());
  4978. }
  4979. if(spawn->GetTotalPower() == 0){
  4980. spawn->SetTotalPower(spawn->GetLevel() * 15);
  4981. spawn->SetPower(spawn->GetTotalPower());
  4982. }
  4983. const char* script = world.GetSpawnScript(id);
  4984. if(script && lua_interface && lua_interface->GetSpawnScript(script) != 0)
  4985. spawn->SetSpawnScript(string(script));
  4986. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_PRESPAWN);
  4987. client->GetCurrentZone()->AddSpawn(spawn);
  4988. if(spawn->IsNPC())
  4989. spawn->GetZone()->AddLoot((NPC*)spawn);
  4990. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_SPAWN);
  4991. LogWrite(COMMAND__INFO, 0, "Command", "Received spawn command - Parms: %s", command_parms->data.c_str());
  4992. break;
  4993. }
  4994. case COMMAND_ADMINFLAG:
  4995. {
  4996. if(sep && sep->arg[0]){
  4997. sint16 tmp_status = database.GetCharacterAdminStatus(sep->arg[0]);
  4998. sint16 new_status = atoi(sep->arg[1]);
  4999. if(tmp_status == -10)
  5000. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character does not exist.");
  5001. else if(tmp_status >= client->GetAdminStatus())
  5002. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character has same or higher level status.");
  5003. else if (new_status > client->GetAdminStatus())
  5004. client->SimpleMessage(CHANNEL_ERROR, "Unable to flag character. Reason: New status is higher then your status.");
  5005. else{
  5006. Client* client2 = client->GetCurrentZone()->GetClientByName(sep->arg[0]);
  5007. if (!client2)
  5008. client2 = zone_list.GetClientByCharName(sep->arg[0]);
  5009. if(database.UpdateAdminStatus(sep->arg[0],new_status)) {
  5010. client->Message(CHANNEL_COLOR_YELLOW,"Character status updated to %i for %s.",new_status,sep->arg[0]);
  5011. if (client2) {
  5012. client2->SetAdminStatus(new_status);
  5013. client2->Message(CHANNEL_COLOR_YELLOW, "%s has set your admin status to %i.", client->GetPlayer()->GetName(), new_status);
  5014. }
  5015. }
  5016. else
  5017. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Unknown reason.");
  5018. }
  5019. }else{
  5020. sint16 status = database.GetCharacterAdminStatus(client->GetPlayer()->GetName());
  5021. if(status != client->GetAdminStatus())
  5022. {
  5023. client->Message(CHANNEL_COLOR_YELLOW,"Flag status was changed from %i to %i.",status,client->GetAdminStatus());
  5024. client->SetAdminStatus(status);
  5025. }
  5026. else
  5027. {
  5028. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /flag {name} {new_status}");
  5029. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Standard User: 0");
  5030. client->Message(CHANNEL_COLOR_YELLOW," Admin User: %i", status);
  5031. }
  5032. }
  5033. break;
  5034. }
  5035. case COMMAND_CANNEDEMOTE:{
  5036. client->GetCurrentZone()->HandleEmote(client->GetPlayer(), command_parms->data);
  5037. break;
  5038. }
  5039. case COMMAND_BROADCAST: {
  5040. if (sep && sep->arg[0])
  5041. zone_list.HandleGlobalBroadcast(sep->argplus[0]);
  5042. else
  5043. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /broadcast {message}");
  5044. break;
  5045. }
  5046. case COMMAND_ANNOUNCE: {
  5047. if (sep && sep->arg[0])
  5048. zone_list.HandleGlobalAnnouncement(sep->argplus[0]);
  5049. else
  5050. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /announce {message}");
  5051. break;
  5052. }
  5053. case COMMAND_RELOAD_ITEMS:{
  5054. LogWrite(COMMAND__INFO, 0, "Command", "Reloading items..");
  5055. int32 item_id = (sep && sep->arg[0]) ? atoul(sep->arg[0]) : 0;
  5056. if(item_id > 0) {
  5057. client->Message(CHANNEL_COLOR_YELLOW, "Reloading item %u based on /reload items [item_id].", item_id);
  5058. }
  5059. else {
  5060. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Started Reloading items (this might take a few minutes...)");
  5061. }
  5062. database.ReloadItemList(item_id);
  5063. if(!item_id) {
  5064. database.LoadMerchantInformation(); // we skip if there is only a reload of single item not all items
  5065. }
  5066. if(item_id > 0) {
  5067. client->Message(CHANNEL_COLOR_YELLOW, "Reloaded item %u.", item_id);
  5068. }
  5069. else {
  5070. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Finished Reloading items.");
  5071. }
  5072. break;
  5073. }
  5074. case COMMAND_ENABLE_ABILITY_QUE:{
  5075. EQ2Packet* app = client->GetPlayer()->GetSpellBookUpdatePacket(client->GetVersion());
  5076. if(app)
  5077. client->QueuePacket(app);
  5078. break;
  5079. }
  5080. case COMMAND_ITEMSEARCH:
  5081. case COMMAND_FROMBROKER:{
  5082. PacketStruct* packet = configReader.getStruct("WS_StartBroker", client->GetVersion());
  5083. if (packet) {
  5084. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  5085. //packet->setDataByName("unknown", 1);
  5086. packet->setDataByName("unknown2", 5, 0);
  5087. packet->setDataByName("unknown2", 20, 1);
  5088. packet->setDataByName("unknown2", 58, 3);
  5089. packet->setDataByName("unknown2", 40, 4);
  5090. client->QueuePacket(packet->serialize());
  5091. PacketStruct* packet2 = configReader.getStruct("WS_BrokerBags", client->GetVersion());
  5092. if (packet2) {
  5093. packet2->setDataByName("char_id", client->GetCharacterID());
  5094. client->QueuePacket(packet2->serialize()); //send this for now, needed to properly clear data
  5095. safe_delete(packet2);
  5096. }
  5097. safe_delete(packet);
  5098. }
  5099. break;
  5100. }
  5101. case COMMAND_ANIMTEST:{
  5102. PacketStruct* command_packet = configReader.getStruct("WS_CannedEmote", client->GetVersion());
  5103. if(command_packet){
  5104. int32 id = client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer());
  5105. if (cmdTarget)
  5106. id = client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget);
  5107. command_packet->setDataByName ( "spawn_id" , id);
  5108. int animID = 1;
  5109. if(sep && sep->arg[0] && sep->IsNumber(0))
  5110. animID = atoi(sep->arg[0]);
  5111. VisualState* vs = NULL;
  5112. if(animID == 0)
  5113. {
  5114. vs = visual_states.FindVisualState(sep->arg[0]);
  5115. }
  5116. char msg[128];
  5117. sprintf(msg,"Animation Test ID: %i",animID);
  5118. command_packet->setMediumStringByName ( "emote_msg" , msg );
  5119. if(vs != NULL)
  5120. command_packet->setDataByName ( "anim_type", vs->GetID ( ) );
  5121. else
  5122. command_packet->setDataByName ( "anim_type", animID );
  5123. command_packet->setDataByName ( "unknown0", 0 );
  5124. EQ2Packet* outapp = command_packet->serialize();
  5125. client->QueuePacket(outapp);
  5126. safe_delete(command_packet);
  5127. }
  5128. break;
  5129. }
  5130. case COMMAND_KICK:
  5131. {
  5132. if( sep == 0 || sep->arg[0] == 0)
  5133. {
  5134. client->SimpleMessage(CHANNEL_COLOR_RED, "/kick [name]");
  5135. }
  5136. else
  5137. {
  5138. Client* kickClient = zone_list.GetClientByCharName(string(sep->arg[0]));
  5139. if ( kickClient == client )
  5140. {
  5141. client->Message(CHANNEL_COLOR_RED, "You can't kick yourself!");
  5142. break;
  5143. }
  5144. else if(kickClient != NULL)
  5145. {
  5146. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  5147. if ( maxStatus >= client->GetAdminStatus( ) || kickClient->GetAdminStatus() >= client->GetAdminStatus() )
  5148. {
  5149. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  5150. break;
  5151. }
  5152. client->Message(CHANNEL_COLOR_RED, "Kicking %s...",sep->arg[0]);
  5153. kickClient->Disconnect();
  5154. }
  5155. else
  5156. {
  5157. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  5158. }
  5159. }
  5160. break;
  5161. }
  5162. case COMMAND_LOCK:
  5163. {
  5164. if( sep != NULL && sep->arg[0] != NULL && sep->IsNumber(0)){
  5165. int worldLocked = atoi(sep->arg[0]);
  5166. net.world_locked = worldLocked;
  5167. if ( worldLocked )
  5168. client->Message(CHANNEL_COLOR_YELLOW,"World server has been locked.");
  5169. else
  5170. client->Message(CHANNEL_COLOR_YELLOW,"World server has been unlocked.");
  5171. }
  5172. else
  5173. client->SimpleMessage(CHANNEL_COLOR_RED, "/lock [0/1]");
  5174. break;
  5175. }
  5176. case COMMAND_BAN:{
  5177. if( sep == 0 || sep->arg[0] == 0 || (sep->arg[1][0] != 0 && !sep->IsNumber(1) ) )
  5178. {
  5179. client->SimpleMessage(CHANNEL_COLOR_RED, "/ban [name] [permanent:0/1]");
  5180. }
  5181. else
  5182. {
  5183. Client* kickClient = zone_list.GetClientByCharName(sep->arg[0]);
  5184. if ( kickClient == client )
  5185. {
  5186. client->Message(CHANNEL_COLOR_RED, "You can't ban yourself!");
  5187. break;
  5188. }
  5189. else if(kickClient != NULL)
  5190. {
  5191. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  5192. if ( maxStatus > client->GetAdminStatus( ) ||
  5193. client->GetAdminStatus ( ) > kickClient->GetAdminStatus ( ) )
  5194. {
  5195. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  5196. break;
  5197. }
  5198. client->Message(CHANNEL_COLOR_RED, "Kicking & Banning %s...",sep->arg[0]);
  5199. int perm = atol(sep->arg[1]);
  5200. if ( perm == 1 )
  5201. database.UpdateAdminStatus(sep->arg[0],-2);
  5202. else
  5203. database.UpdateAdminStatus(sep->arg[0],-1);
  5204. kickClient->Disconnect();
  5205. }
  5206. else
  5207. {
  5208. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  5209. }
  5210. }
  5211. break;
  5212. }
  5213. case COMMAND_SET_COMBAT_VOICE:{
  5214. int32 value = 0;
  5215. if(sep && sep->arg[0] && sep->IsNumber(0))
  5216. value = atoi(sep->arg[0]);
  5217. client->GetPlayer()->SetCombatVoice(value);
  5218. break;
  5219. }
  5220. case COMMAND_SET_EMOTE_VOICE:{
  5221. int32 value = 0;
  5222. if(sep && sep->arg[0] && sep->IsNumber(0))
  5223. value = atoi(sep->arg[0]);
  5224. client->GetPlayer()->SetEmoteVoice(value);
  5225. break;
  5226. }
  5227. case COMMAND_GIVEITEM:{
  5228. if(sep && sep->arg[0][0] && sep->arg[0][1] && sep->IsNumber(1)){
  5229. Client* itemToClient = zone_list.GetClientByCharName(sep->arg[0]);
  5230. if ( itemToClient == NULL )
  5231. client->Message(CHANNEL_COLOR_YELLOW,"Could not find %s.",sep->arg[0]);
  5232. else
  5233. {
  5234. int32 item_id = atol(sep->arg[1]);
  5235. client->Message(CHANNEL_COLOR_YELLOW,"Gave %s item id %i.",sep->arg[0],item_id);
  5236. itemToClient->AddItem(item_id);
  5237. }
  5238. }
  5239. else
  5240. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /giveitem [name] [item_id]");
  5241. break;
  5242. }
  5243. case COMMAND_REPORT_BUG : { Command_ReportBug(client, sep); break; }
  5244. case COMMAND_INVENTORY : { Command_Inventory(client, sep, command); break; }
  5245. case COMMAND_WEAPONSTATS : { Command_WeaponStats(client); break; }
  5246. case COMMAND_SKILL :
  5247. case COMMAND_SKILL_ADD :
  5248. case COMMAND_SKILL_REMOVE :
  5249. case COMMAND_SKILL_LIST : { Command_Skills(client, sep, command->handler); break; }
  5250. case COMMAND_ZONE_SET : { Command_ZoneSet(client, sep); break; }
  5251. case COMMAND_ZONE_DETAILS : { Command_ZoneDetails(client, sep); break; }
  5252. case COMMAND_ENTITYCOMMAND :
  5253. case COMMAND_ENTITYCOMMAND_LIST : { Command_EntityCommand(client, sep, command->handler); break; }
  5254. case COMMAND_MERCHANT :
  5255. case COMMAND_MERCHANT_LIST : { Command_Merchant(client, sep, command->handler); break; }
  5256. case COMMAND_APPEARANCE :
  5257. case COMMAND_APPEARANCE_LIST : { Command_Appearance(client, sep, command->handler); break; }
  5258. case COMMAND_TRACK : { Command_Track(client); break; }
  5259. case COMMAND_DISTANCE : { Command_Distance(client); break; }
  5260. case COMMAND_INSPECT_PLAYER : { Command_InspectPlayer(client, sep); break; }
  5261. case COMMAND_ZONE_SAFE : { Command_ZoneSafeCoords(client, sep); break; }
  5262. case COMMAND_GUILDSAY : { Command_GuildSay(client, sep); break; }
  5263. case COMMAND_OFFICERSAY : { Command_OfficerSay(client, sep); break; }
  5264. case COMMAND_SET_GUILD_MEMBER_NOTE : { Command_SetGuildMemberNote(client, sep); break; }
  5265. case COMMAND_SET_GUILD_OFFICER_NOTE : { Command_SetGuildOfficerNote(client, sep); break; }
  5266. case COMMAND_GUILD : { Command_Guild(client, sep); break; }
  5267. case COMMAND_CREATE_GUILD : { Command_CreateGuild(client); break; }
  5268. case COMMAND_GUILDS : { Command_Guilds(client); break; }
  5269. case COMMAND_GUILDS_ADD : { Command_GuildsAdd(client, sep); break; }
  5270. case COMMAND_GUILDS_CREATE : { Command_GuildsCreate(client, sep); break; }
  5271. case COMMAND_GUILDS_DELETE : { Command_GuildsDelete(client, sep); break; }
  5272. case COMMAND_GUILDS_LIST : { Command_GuildsList(client); break; }
  5273. case COMMAND_GUILDS_REMOVE : { Command_GuildsRemove(client, sep); break; }
  5274. case COMMAND_CLAIM : { Command_Claim(client, sep); break; }
  5275. case COMMAND_CLEAR_ALL_QUEUED : { Command_ClearAllQueued(client); break; }
  5276. case COMMAND_LOCATION : { Command_Location(client); break; }
  5277. case COMMAND_LOCATION_ADD : { Command_LocationAdd(client, sep); break; }
  5278. case COMMAND_LOCATION_CREATE : { Command_LocationCreate(client, sep); break; }
  5279. case COMMAND_LOCATION_DELETE : { Command_LocationDelete(client, sep); break; }
  5280. case COMMAND_LOCATION_LIST : { Command_LocationList(client, sep); break; }
  5281. case COMMAND_LOCATION_REMOVE : { Command_LocationRemove(client, sep); break; }
  5282. case COMMAND_GRID : { Command_Grid(client, sep); break; }
  5283. case COMMAND_TRY_ON : { Command_TryOn(client, sep); break; }
  5284. case COMMAND_RANDOMIZE : { Command_Randomize(client, sep); break; }
  5285. case COMMAND_AFK : { Command_AFK(client, sep); break; }
  5286. case COMMAND_SHOW_CLOAK : { Command_ShowCloak(client, sep); break; }
  5287. case COMMAND_SHOW_HELM : { Command_ShowHelm(client, sep); break; }
  5288. case COMMAND_SHOW_HOOD : { Command_ShowHood(client, sep); break; }
  5289. case COMMAND_SHOW_HOOD_OR_HELM : { Command_ShowHoodHelm(client, sep); break; }
  5290. case COMMAND_SHOW_RANGED : { Command_ShowRanged(client, sep); break; }
  5291. case COMMAND_STOP_DRINKING : { Command_StopDrinking(client); break; }
  5292. case COMMAND_STOP_EATING : { Command_StopEating(client); break; }
  5293. case COMMAND_TOGGLE_ANONYMOUS : { Command_Toggle_Anonymous(client); break; }
  5294. case COMMAND_TOGGLE_AUTOCONSUME : { Command_Toggle_AutoConsume(client, sep); break; }
  5295. case COMMAND_TOGGLE_BONUS_EXP : { Command_Toggle_BonusXP(client); break; }
  5296. case COMMAND_TOGGLE_COMBAT_EXP : { Command_Toggle_CombatXP(client); break; }
  5297. case COMMAND_TOGGLE_GM_HIDE : { Command_Toggle_GMHide(client); break; }
  5298. case COMMAND_TOGGLE_GM_VANISH : { Command_Toggle_GMVanish(client); break; }
  5299. case COMMAND_TOGGLE_ILLUSIONS : { Command_Toggle_Illusions(client, sep); break; }
  5300. case COMMAND_TOGGLE_LFG : { Command_Toggle_LFG(client); break; }
  5301. case COMMAND_TOGGLE_LFW : { Command_Toggle_LFW(client); break; }
  5302. case COMMAND_TOGGLE_QUEST_EXP : { Command_Toggle_QuestXP(client); break; }
  5303. case COMMAND_TOGGLE_ROLEPLAYING : { Command_Toggle_Roleplaying(client); break; }
  5304. case COMMAND_TOGGLE_DUELS : { Command_Toggle_Duels(client); break; }
  5305. case COMMAND_TOGGLE_TRADES : { Command_Toggle_Trades(client); break; }
  5306. case COMMAND_TOGGLE_GUILDS : { Command_Toggle_Guilds(client); break; }
  5307. case COMMAND_TOGGLE_GROUPS : { Command_Toggle_Groups(client); break; }
  5308. case COMMAND_TOGGLE_RAIDS : { Command_Toggle_Raids(client); break; }
  5309. case COMMAND_TOGGLE_LON : { Command_Toggle_LON(client); break; }
  5310. case COMMAND_TOGGLE_VCINVITE : { Command_Toggle_VoiceChat(client); break; }
  5311. case COMMAND_CANCEL_MAINTAINED : { Command_CancelMaintained(client, sep); break; }
  5312. case COMMAND_MOTD : { Command_MOTD(client); break; }
  5313. case COMMAND_RANDOM : { Command_Random(client, sep); break; }
  5314. case COMMAND_CREATE : { Command_Create(client, sep); break; }
  5315. case COMMAND_CREATEFROMRECIPE : { Command_CreateFromRecipe(client, sep); break; }
  5316. case COMMAND_TITLE : { Command_Title(client); break; }
  5317. case COMMAND_TITLE_LIST : { Command_TitleList(client); break; }
  5318. case COMMAND_TITLE_SETPREFIX : { Command_TitleSetPrefix(client, sep); break; }
  5319. case COMMAND_TITLE_SETSUFFIX : { Command_TitleSetSuffix(client, sep); break; }
  5320. case COMMAND_TITLE_FIX : { Command_TitleFix(client, sep); break; }
  5321. case COMMAND_LANGUAGES : { Command_Languages(client, sep); break; }
  5322. case COMMAND_SET_LANGUAGE : { Command_SetLanguage(client, sep); break; }
  5323. case COMMAND_FOLLOW : { Command_Follow(client, sep); break; }
  5324. case COMMAND_STOP_FOLLOW : { Command_StopFollow(client, sep); break; }
  5325. case COMMAND_LASTNAME : { Command_LastName(client, sep); break; }
  5326. case COMMAND_CONFIRMLASTNAME : { Command_ConfirmLastName(client, sep); break; }
  5327. case COMMAND_PET : { Command_Pet(client, sep); break; }
  5328. case COMMAND_PETNAME : { Command_PetName(client, sep); break; }
  5329. case COMMAND_NAME_PET : { Command_NamePet(client, sep); break; }
  5330. case COMMAND_RENAME : { Command_Rename(client, sep); break; }
  5331. case COMMAND_CONFIRMRENAME : { Command_ConfirmRename(client, sep); break; }
  5332. case COMMAND_PETOPTIONS : { Command_PetOptions(client, sep); break; }
  5333. case COMMAND_START_TRADE : { Command_TradeStart(client, sep); break; }
  5334. case COMMAND_ACCEPT_TRADE : { Command_TradeAccept(client, sep); break; }
  5335. case COMMAND_REJECT_TRADE : { Command_TradeReject(client, sep); break; }
  5336. case COMMAND_CANCEL_TRADE : { Command_TradeCancel(client, sep); break; }
  5337. case COMMAND_SET_TRADE_COIN : { Command_TradeSetCoin(client, sep); break; }
  5338. case COMMAND_ADD_TRADE_COPPER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_COPPER); break; }
  5339. case COMMAND_ADD_TRADE_SILVER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_SILVER); break; }
  5340. case COMMAND_ADD_TRADE_GOLD : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_GOLD); break; }
  5341. case COMMAND_ADD_TRADE_PLAT : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_PLAT); break; }
  5342. case COMMAND_REMOVE_TRADE_COPPER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_COPPER); break; }
  5343. case COMMAND_REMOVE_TRADE_SILVER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_SILVER); break; }
  5344. case COMMAND_REMOVE_TRADE_GOLD : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_GOLD); break; }
  5345. case COMMAND_REMOVE_TRADE_PLAT : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_PLAT); break; }
  5346. case COMMAND_ADD_TRADE_ITEM : { Command_TradeAddItem(client, sep); break; }
  5347. case COMMAND_REMOVE_TRADE_ITEM : { Command_TradeRemoveItem(client, sep); break; }
  5348. case COMMAND_ACCEPT_ADVANCEMENT : { Command_AcceptAdvancement(client, sep); break; }
  5349. case COMMAND_DUEL : { Command_Duel(client, sep); break; }
  5350. case COMMAND_DUELBET : { Command_DuelBet(client, sep); break; }
  5351. case COMMAND_DUEL_ACCEPT : { Command_DuelAccept(client, sep); break; }
  5352. case COMMAND_DUEL_DECLINE : { Command_DuelDecline(client, sep); break; }
  5353. case COMMAND_DUEL_SURRENDER : { Command_DuelSurrender(client, sep); break; }
  5354. case COMMAND_DUEL_TOGGLE : { Command_DuelToggle(client, sep); break; }
  5355. case COMMAND_SPAWN_TEMPLATE : { Command_SpawnTemplate(client, sep); break; }
  5356. //devn00b
  5357. case COMMAND_MOOD : { Command_Mood(client, sep); break;}
  5358. case COMMAND_MODIFY : { Command_Modify(client); break; }
  5359. case COMMAND_MODIFY_CHARACTER : { Command_ModifyCharacter(client, sep); break; }
  5360. case COMMAND_MODIFY_QUEST : { Command_ModifyQuest(client, sep); break; }
  5361. case COMMAND_MODIFY_FACTION : { Command_ModifyFaction(client, sep); break; }
  5362. case COMMAND_MODIFY_GUILD : { Command_ModifyGuild(client, sep); break; }
  5363. case COMMAND_MODIFY_ITEM : { Command_ModifyItem(client, sep); break; }
  5364. case COMMAND_MODIFY_SKILL : { Command_ModifySkill(client, sep); break; }
  5365. case COMMAND_MODIFY_SPAWN : { Command_ModifySpawn(client, sep); break; }
  5366. case COMMAND_MODIFY_SPELL : { Command_ModifySpell(client, sep); break; }
  5367. case COMMAND_MODIFY_ZONE : { Command_ModifyZone(client, sep); break; }
  5368. case COMMAND_JOIN_CHANNEL : { Command_JoinChannel(client, sep); break;}
  5369. case COMMAND_JOIN_CHANNEL_FROM_LOAD: { Command_JoinChannelFromLoad(client, sep); break;}
  5370. case COMMAND_TELL_CHANNEL : { Command_TellChannel(client, sep); break;}
  5371. case COMMAND_LEAVE_CHANNEL : { Command_LeaveChannel(client, sep); break;}
  5372. case COMMAND_WHO_CHANNEL : { Command_WhoChannel(client, sep); break;}
  5373. case COMMAND_RAIN : { Command_Rain(client, sep); break; }
  5374. case COMMAND_WIND : { Command_Wind(client, sep); break; }
  5375. case COMMAND_WEATHER : { Command_Weather(client, sep); break; }
  5376. case COMMAND_FROM_MERCHANT : { Command_SendMerchantWindow(client, sep); break; }
  5377. case COMMAND_TO_MERCHANT : { Command_SendMerchantWindow(client, sep, true); break; }
  5378. case COMMAND_SELECT : { Command_Select(client, sep); break; }
  5379. case COMMAND_SMP : { Command_StationMarketPlace(client, sep); break; }
  5380. case COMMAND_CONSUME_FOOD : { Command_ConsumeFood(client, sep); break; }
  5381. case COMMAND_AQUAMAN : { Command_Aquaman(client, sep); break; }
  5382. case COMMAND_ATTUNE_INV : { Command_Attune_Inv(client, sep); break; }
  5383. case COMMAND_PLAYER : { Command_Player(client, sep); break; }
  5384. case COMMAND_PLAYER_COINS : { Command_Player_Coins(client, sep); break; }
  5385. case COMMAND_RESET_ZONE_TIMER : { Command_Reset_Zone_Timer(client, sep); break; }
  5386. case COMMAND_ACHIEVEMENT_ADD : { Command_AchievementAdd(client, sep); break; }
  5387. case COMMAND_EDITOR : { Command_Editor(client, sep); break; }
  5388. case COMMAND_ACCEPT_RESURRECTION: { Command_AcceptResurrection(client, sep); break; }
  5389. case COMMAND_DECLINE_RESURRECTION:{ Command_DeclineResurrection(client, sep); break; }
  5390. case COMMAND_TEST : { Command_Test(client, command_parms); break; }
  5391. case COMMAND_SPEED : { Command_Speed(client, sep); break; }
  5392. case COMMAND_BOT : { Command_Bot(client, sep); break; }
  5393. case COMMAND_BOT_CREATE : { Command_Bot_Create(client, sep); break; }
  5394. case COMMAND_BOT_CUSTOMIZE : { Command_Bot_Customize(client, sep); break; }
  5395. case COMMAND_BOT_SPAWN : { Command_Bot_Spawn(client, sep); break; }
  5396. case COMMAND_BOT_LIST : { Command_Bot_List(client, sep); break; }
  5397. case COMMAND_BOT_INV : { Command_Bot_Inv(client, sep); break; }
  5398. case COMMAND_BOT_SETTINGS : { Command_Bot_Settings(client, sep); break; }
  5399. case COMMAND_BOT_HELP : { Command_Bot_Help(client, sep); break; }
  5400. case GET_AA_XML : { Get_AA_Xml(client, sep); break; }
  5401. case ADD_AA : { Add_AA(client, sep); break; }
  5402. case COMMIT_AA_PROFILE : { Commit_AA_Profile(client, sep); break; }
  5403. case BEGIN_AA_PROFILE : { Begin_AA_Profile(client, sep); break; }
  5404. case BACK_AA : { Back_AA(client, sep); break; }
  5405. case REMOVE_AA : { Remove_AA(client, sep); break; }
  5406. case SWITCH_AA_PROFILE : { Switch_AA_Profile(client, sep); break; }
  5407. case CANCEL_AA_PROFILE : { Cancel_AA_Profile(client, sep); break; }
  5408. case SAVE_AA_PROFILE : { Save_AA_Profile(client, sep); break; }
  5409. case COMMAND_TARGETITEM : { Command_TargetItem(client, sep); break; }
  5410. case COMMAND_FINDSPAWN: { Command_FindSpawn(client, sep); break; }
  5411. case COMMAND_MOVECHARACTER: { Command_MoveCharacter(client, sep); break; }
  5412. case COMMAND_CRAFTITEM: {
  5413. Item* item = 0;
  5414. if (sep && sep->IsNumber(0)) {
  5415. int32 item_id = atol(sep->arg[0]);
  5416. int32 quantity = 1;
  5417. if (sep->arg[1] && sep->IsNumber(1))
  5418. quantity = atoi(sep->arg[1]);
  5419. item = new Item(master_item_list.GetItem(item_id));
  5420. if (!item) {
  5421. LogWrite(TRADESKILL__ERROR, 0, "CraftItem", "Item (%u) not found.", item_id);
  5422. }
  5423. else {
  5424. item->details.count = quantity;
  5425. // use CHANNEL_COLOR_CHAT_RELATIONSHIP as that is the same value (4) as it is in a log for this message
  5426. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You created %s.", item->CreateItemLink(client->GetVersion()).c_str());
  5427. bool itemDeleted = false;
  5428. client->AddItem(item, &itemDeleted);
  5429. //Check for crafting quest updates
  5430. int8 update_amt = 0;
  5431. if (!itemDeleted && item->stack_count > 1)
  5432. update_amt = 1;
  5433. else
  5434. update_amt = quantity;
  5435. if(!itemDeleted)
  5436. client->GetPlayer()->CheckQuestsCraftUpdate(item, update_amt);
  5437. }
  5438. }
  5439. else {
  5440. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /craftitem {item_id} [quantity] ");
  5441. }
  5442. break;
  5443. }
  5444. case COMMAND_UNMENTOR:
  5445. case COMMAND_MENTOR: {
  5446. client->GetPlayer()->MentorTarget();
  5447. break;
  5448. }
  5449. case COMMAND_CANCEL_EFFECT: { Command_CancelEffect(client, sep); break; }
  5450. case COMMAND_CUREPLAYER: { Command_CurePlayer(client, sep); break; }
  5451. case COMMAND_SHARE_QUEST: { Command_ShareQuest(client, sep); break; }
  5452. case COMMAND_YELL: { Command_Yell(client, sep); break; }
  5453. default:
  5454. {
  5455. LogWrite(COMMAND__WARNING, 0, "Command", "Unhandled command: %s", command->command.data.c_str());
  5456. break;
  5457. }
  5458. }
  5459. safe_delete(sep);
  5460. }
  5461. /******************** New COMMAND Handler Functions ********************/
  5462. /*
  5463. Started breaking apart the huge switch() for commands into sepErate
  5464. functions so it is easier to locate the blocks of code by command
  5465. -- JA 2012.03.03
  5466. */
  5467. // sample function header
  5468. /*
  5469. Function:
  5470. Purpose :
  5471. Params :
  5472. Dev :
  5473. Example :
  5474. */
  5475. //void Commands::Command()
  5476. //{
  5477. //}
  5478. /*
  5479. Function: Command_AcceptAdvancement()
  5480. Purpose : Player accepts a new advancement option
  5481. Params : Spell ID
  5482. Dev : Jabantiz
  5483. */
  5484. void Commands::Command_AcceptAdvancement(Client* client, Seperator* sep)
  5485. {
  5486. Player *player = client->GetPlayer();
  5487. if (sep && sep->IsSet(0)) {
  5488. TraitData* trait = master_trait_list.GetTrait(atoul(sep->arg[0]));
  5489. // Check to see if this is a trait or grandmaster training (traits are always new spells, training is always upgrades)
  5490. if (!player->HasSpell(trait->spellID, 0, true))
  5491. {
  5492. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  5493. player->AddSpellBookEntry(trait->spellID, trait->tier, player->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  5494. }
  5495. else
  5496. {
  5497. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  5498. int8 old_slot = player->GetSpellSlot(spell->GetSpellID());
  5499. player->RemoveSpellBookEntry(spell->GetSpellID());
  5500. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  5501. player->UnlockSpell(spell);
  5502. client->SendSpellUpdate(spell);
  5503. }
  5504. // Spell book update
  5505. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  5506. client->QueuePacket(master_trait_list.GetTraitListPacket(client));
  5507. }
  5508. }
  5509. /*
  5510. Function:
  5511. Purpose :
  5512. Params :
  5513. Dev :
  5514. Example :
  5515. */
  5516. void Commands::Command_AFK(Client* client, Seperator* sep)
  5517. {
  5518. Player* player = client->GetPlayer();
  5519. player->toggle_character_flag(CF_AFK);
  5520. client->Message(CHANNEL_COLOR_YELLOW,"You are %s afk.", client->GetPlayer()->get_character_flag(CF_AFK)?"now":"no longer");
  5521. if (player->get_character_flag(CF_AFK))
  5522. {
  5523. if (sep && sep->argplus[0])
  5524. player->SetAwayMessage("I am away from the keyboard, " + string(sep->argplus[0]));
  5525. else
  5526. player->SetAwayMessage("Sorry, I am A.F.K. (Away From Keyboard)");
  5527. string message = string(player->GetName()) + " is going afk.";
  5528. Spawn* target = player->GetTarget();
  5529. if (target && target != player)
  5530. {
  5531. message = string(player->GetName()) + " tells " + string(target->GetName()) + " that ";
  5532. player->GetGender() == 1 ? message += "he" : message += "she";
  5533. message += " is going afk.";
  5534. }
  5535. player->GetZone()->SimpleMessage(CHANNEL_COLOR_YELLOW, message.c_str(), player, 30);
  5536. }
  5537. }
  5538. /*
  5539. Function: Command_Appearance()
  5540. Purpose : Handles /appearance commands
  5541. Params : list
  5542. Dev : Scatman
  5543. Example : /appearance list
  5544. */
  5545. void Commands::Command_Appearance(Client* client, Seperator* sep, int handler)
  5546. {
  5547. if( handler == COMMAND_APPEARANCE )
  5548. {
  5549. // /appearance command by itself shows help (to be extended)
  5550. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  5551. return;
  5552. }
  5553. else if( handler == COMMAND_APPEARANCE_LIST )
  5554. {
  5555. // /appearance list command expects "name" param
  5556. if (sep && sep->arg[0])
  5557. {
  5558. const char* appearance_name = sep->argplus[0];
  5559. client->Message(CHANNEL_COLOR_YELLOW, "Listing appearances like '%s':", appearance_name);
  5560. vector<int16>* appearances = database.GetAppearanceIDsLikeName(string(appearance_name));
  5561. if (appearances)
  5562. {
  5563. vector<int16>::iterator itr;
  5564. for (itr = appearances->begin(); itr != appearances->end(); itr++)
  5565. {
  5566. int16 id = *itr;
  5567. string name = database.GetAppearanceName(id);
  5568. if (ToLower(name).find(ToLower(string(appearance_name))) < 0xFFFFFFFF)
  5569. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", name.c_str(), id);
  5570. }
  5571. safe_delete(appearances);
  5572. }
  5573. }
  5574. else // no param
  5575. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  5576. }
  5577. }
  5578. /*
  5579. Function: Command_Claim()
  5580. Purpose : Summon veteran rewards
  5581. Params : nothing = show claim window, any number claims that item.
  5582. Dev : devn00b
  5583. Example : /claim 0 (claims the 1st item added to the list claim[0])
  5584. */
  5585. void Commands::Command_Claim(Client* client, Seperator* sep)
  5586. {
  5587. //if we were passed a claim id
  5588. if (sep && sep->argplus[0] && sep->IsNumber(0))
  5589. {
  5590. int32 char_id = client->GetCharacterID();
  5591. int8 my_claim_id = atoi(sep->argplus[0]);
  5592. vector<ClaimItems> claim = database.LoadCharacterClaimItems(char_id);
  5593. Item* item = master_item_list.GetItem(claim[my_claim_id].item_id);
  5594. database.ClaimItem(char_id, item->details.item_id, client);
  5595. return;
  5596. }
  5597. else {
  5598. //if no arg just send the window.
  5599. client->ShowClaimWindow();
  5600. return;
  5601. }
  5602. return;
  5603. }
  5604. /*
  5605. Function: Command_ClearAllQueued()
  5606. Purpose :
  5607. Params :
  5608. Dev :
  5609. Example :
  5610. */
  5611. void Commands::Command_ClearAllQueued(Client* client)
  5612. {
  5613. ZoneServer* zone = client->GetPlayer()->GetZone();
  5614. if (zone && zone->GetSpellProcess())
  5615. zone->GetSpellProcess()->RemoveSpellFromQueue(client->GetPlayer());
  5616. }
  5617. /*
  5618. Function: Command_CancelMaintained()
  5619. Purpose : Cancels maintained spells
  5620. Params : Maintained Spell Index
  5621. Dev : Zcoretri
  5622. Example : /cancel_maintained 1 - would cancel the spell in slot 1 of Maintained Spells list
  5623. */
  5624. void Commands::Command_CancelMaintained(Client* client, Seperator* sep)
  5625. {
  5626. if (sep && sep->arg[0] && sep->IsNumber(0))
  5627. {
  5628. int32 spell_index = atoul(sep->arg[0]);
  5629. if(spell_index > 29)
  5630. return;
  5631. client->GetPlayer()->MMaintainedSpells.readlock(__FUNCTION__, __LINE__);
  5632. MaintainedEffects mEffects = client->GetPlayer()->GetInfoStruct()->maintained_effects[spell_index];
  5633. client->GetPlayer()->MMaintainedSpells.releasereadlock(__FUNCTION__, __LINE__);
  5634. if (!client->GetPlayer()->GetZone()->GetSpellProcess()->DeleteCasterSpell(mEffects.spell, "canceled", false))
  5635. client->Message(CHANNEL_COLOR_RED, "The maintained spell could not be cancelled.");
  5636. }
  5637. }
  5638. /*
  5639. Function: Command_Create()
  5640. Purpose : Handler for starting Tradeskilling table
  5641. Params :
  5642. Dev : Zcoretri
  5643. Example :
  5644. */
  5645. void Commands::Command_Create(Client* client, Seperator* sep)
  5646. {
  5647. PrintSep(sep, "COMMAND_CREATE");
  5648. client->ShowRecipeBook();
  5649. }
  5650. void Commands::Command_CreateFromRecipe(Client* client, Seperator* sep)
  5651. {
  5652. PrintSep(sep, "COMMAND_CREATEFROMRECIPE");
  5653. if (sep && sep->arg[0] && sep->IsNumber(0))
  5654. ClientPacketFunctions::SendCreateFromRecipe(client, atoul(sep->arg[0]));
  5655. }
  5656. /*
  5657. Function: Command_Distance()
  5658. Purpose : Displays distance from targeted spawn
  5659. Params :
  5660. Dev : Scatman
  5661. Example : /distance
  5662. */
  5663. void Commands::Command_Distance(Client* client)
  5664. {
  5665. Spawn* target = client->GetPlayer()->GetTarget();
  5666. if (target)
  5667. client->Message(CHANNEL_COLOR_YELLOW, "Your distance from %s is %f", target->GetName(), client->GetPlayer()->GetDistance(target));
  5668. else
  5669. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must have a spawn targeted to use /distance");
  5670. }
  5671. /*
  5672. Function: Command_Duel()
  5673. Purpose : Handle the /duel commands - not yet implemented
  5674. Params : unknown
  5675. Dev :
  5676. Example :
  5677. */
  5678. void Commands::Command_Duel(Client* client, Seperator* sep)
  5679. {
  5680. PrintSep(sep, "COMMAND_DUEL");
  5681. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Command");
  5682. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5683. }
  5684. /*
  5685. Function: Command_DuelBet()
  5686. Purpose : Handle the /duel commands - not yet implemented
  5687. Params : unknown
  5688. Dev :
  5689. Example :
  5690. */
  5691. void Commands::Command_DuelBet(Client* client, Seperator* sep)
  5692. {
  5693. PrintSep(sep, "COMMAND_DUELBET");
  5694. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Bet Command");
  5695. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5696. }
  5697. /*
  5698. Function: Command_DuelAccept()
  5699. Purpose : Handle the /duel commands - not yet implemented
  5700. Params : unknown
  5701. Dev :
  5702. Example :
  5703. */
  5704. void Commands::Command_DuelAccept(Client* client, Seperator* sep)
  5705. {
  5706. PrintSep(sep, "COMMAND_DUEL_ACCEPT");
  5707. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Accept Duel Command");
  5708. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5709. }
  5710. /*
  5711. Function: Command_DuelDecline()
  5712. Purpose : Handle the /duel commands - not yet implemented
  5713. Params : unknown
  5714. Dev :
  5715. Example :
  5716. */
  5717. void Commands::Command_DuelDecline(Client* client, Seperator* sep)
  5718. {
  5719. PrintSep(sep, "COMMAND_DUEL_DECLINE");
  5720. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Decline Duel Request Command");
  5721. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5722. }
  5723. /*
  5724. Function: Command_DuelSurrender()
  5725. Purpose : Handle the /duel commands - not yet implemented
  5726. Params : unknown
  5727. Dev :
  5728. Example :
  5729. */
  5730. void Commands::Command_DuelSurrender(Client* client, Seperator* sep)
  5731. {
  5732. PrintSep(sep, "COMMAND_DUEL_SURRENDER");
  5733. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Surrender Duel Command");
  5734. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5735. // JA, just messin around ;)
  5736. char surrender[64];
  5737. sprintf(surrender, "%s surrendered like a cowardly dog!", client->GetPlayer()->GetName());
  5738. zone_list.HandleGlobalAnnouncement(surrender);
  5739. }
  5740. /*
  5741. Function: Command_DuelToggle()
  5742. Purpose : Handle the /duel commands - not yet implemented
  5743. Params : unknown
  5744. Dev :
  5745. Example :
  5746. */
  5747. void Commands::Command_DuelToggle(Client* client, Seperator* sep)
  5748. {
  5749. PrintSep(sep, "COMMAND_DUEL");
  5750. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Commands");
  5751. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5752. }
  5753. /*
  5754. Function:
  5755. Purpose :
  5756. Params :
  5757. Dev :
  5758. Example :
  5759. */
  5760. void Commands::Command_EntityCommand(Client* client, Seperator* sep, int handler)
  5761. {
  5762. if( handler == COMMAND_ENTITYCOMMAND )
  5763. {
  5764. // /entitycommand command by itself shows help (to be extended)
  5765. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  5766. return;
  5767. }
  5768. else if( handler == COMMAND_ENTITYCOMMAND_LIST )
  5769. {
  5770. // /entitycommand list command expects "name" param
  5771. if (sep && sep->arg[0])
  5772. {
  5773. const char* entity_command_name = sep->argplus[0];
  5774. client->Message(CHANNEL_COLOR_YELLOW, "Listing entity commands like '%s':", entity_command_name);
  5775. map<int32, vector<EntityCommand*>*>* entity_command_list_all = client->GetCurrentZone()->GetEntityCommandListAll();
  5776. map<int32, vector<EntityCommand*>*>::iterator itr;
  5777. for (itr = entity_command_list_all->begin(); itr != entity_command_list_all->end(); itr++)
  5778. {
  5779. vector<EntityCommand*>* entity_command_list = itr->second;
  5780. vector<EntityCommand*>::iterator itr2;
  5781. for (itr2 = entity_command_list->begin(); itr2 != entity_command_list->end(); itr2++)
  5782. {
  5783. EntityCommand* entity_command = *itr2;
  5784. if (ToLower(entity_command->name).find(ToLower(string(entity_command_name))) < 0xFFFFFFFF)
  5785. 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);
  5786. }
  5787. }
  5788. }
  5789. else // no command name
  5790. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  5791. }
  5792. }
  5793. /*
  5794. Function: Command_Follow()
  5795. Purpose : Handle the /follow command - not yet implemented
  5796. Params :
  5797. Dev :
  5798. Example :
  5799. */
  5800. void Commands::Command_Follow(Client* client, Seperator* sep)
  5801. {
  5802. PrintSep(sep, "COMMAND_FOLLOW");
  5803. // flag to toggle if the players target is in the players group
  5804. bool targetInGroup = false;
  5805. // get a pointer to the players group
  5806. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  5807. // If the player has a group and has a target
  5808. if (gmi && client->GetPlayer()->GetTarget()) {
  5809. deque<GroupMemberInfo*>::iterator itr;
  5810. world.GetGroupManager()->GroupLock(__FUNCTION__, __LINE__);
  5811. PlayerGroup* group = world.GetGroupManager()->GetGroup(gmi->group_id);
  5812. if (group)
  5813. {
  5814. group->MGroupMembers.readlock(__FUNCTION__, __LINE__);
  5815. deque<GroupMemberInfo*>* members = group->GetMembers();
  5816. // Loop through the group members
  5817. for (itr = members->begin(); itr != members->end(); itr++) {
  5818. // If a group member matches a target
  5819. if ((*itr)->member && (*itr)->member == client->GetPlayer()->GetTarget()) {
  5820. // toggle the flag and break the loop
  5821. targetInGroup = true;
  5822. break;
  5823. }
  5824. }
  5825. group->MGroupMembers.releasereadlock(__FUNCTION__, __LINE__);
  5826. }
  5827. world.GetGroupManager()->ReleaseGroupLock(__FUNCTION__, __LINE__);
  5828. }
  5829. if (targetInGroup) {
  5830. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  5831. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You start to follow %s.", client->GetPlayer()->GetTarget()->GetName());
  5832. client->GetPlayer()->SetFollowTarget(client->GetPlayer()->GetTarget());
  5833. client->GetPlayer()->info_changed = true;
  5834. client->GetPlayer()->changed = true;
  5835. }
  5836. else
  5837. client->Message(CHANNEL_NARRATIVE, "You must first select a group member to follow.");
  5838. }
  5839. /*
  5840. Function: Command_StopFollow()
  5841. Purpose : Handle the /stop_follow command - not yet implemented
  5842. Params :
  5843. Dev :
  5844. Example :
  5845. */
  5846. void Commands::Command_StopFollow(Client* client, Seperator* sep)
  5847. {
  5848. PrintSep(sep, "COMMAND_STOP_FOLLOW");
  5849. if (client->GetPlayer()->GetFollowTarget()) {
  5850. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  5851. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You are no longer following %s", client->GetPlayer()->GetFollowTarget()->GetName());
  5852. client->GetPlayer()->SetFollowTarget(0);
  5853. client->GetPlayer()->info_changed = true;
  5854. client->GetPlayer()->changed = true;
  5855. }
  5856. }
  5857. /*
  5858. Function: Command_Grid()
  5859. Purpose : Show player's current Grid ID
  5860. Params :
  5861. Dev : Scatman
  5862. Example : /grid
  5863. */
  5864. void Commands::Command_Grid(Client* client, Seperator* sep)
  5865. {
  5866. if (client->GetPlayer()->GetMap() != nullptr) {
  5867. if(sep && sep->arg[0][0] && strncasecmp("spawns", sep->arg[0], 6) == 0) {
  5868. int32 grid = client->GetPlayer()->GetLocation();
  5869. if(sep->IsNumber(1))
  5870. grid = atoul(sep->arg[1]);
  5871. client->GetCurrentZone()->SendClientSpawnListInGrid(client, grid);
  5872. }
  5873. else {
  5874. client->Message(CHANNEL_COLOR_YELLOW, "Your Grid ID is %u", client->GetPlayer()->GetLocation());
  5875. auto loc = glm::vec3(client->GetPlayer()->GetX(), client->GetPlayer()->GetZ(), client->GetPlayer()->GetY());
  5876. uint32 GridID = 0;
  5877. uint32 WidgetID = 0;
  5878. float new_z = client->GetPlayer()->FindBestZ(loc, nullptr, &GridID, &WidgetID);
  5879. float minY = client->GetPlayer()->GetMap()->GetMinY();
  5880. float maxY = client->GetPlayer()->GetMap()->GetMaxY();
  5881. float minZ = client->GetPlayer()->GetMap()->GetMinZ();
  5882. float maxZ = client->GetPlayer()->GetMap()->GetMaxZ();
  5883. int32 grid_spawn_count = client->GetPlayer()->GetZone()->GetSpawnCountInGrid(GridID);
  5884. 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);
  5885. }
  5886. }
  5887. }
  5888. /*
  5889. Function: Command_Guild()
  5890. Purpose : Handler for all UI-related guild commands
  5891. Dev : Scatman
  5892. */
  5893. void Commands::Command_Guild(Client* client, Seperator* sep)
  5894. {
  5895. Guild* guild = client->GetPlayer()->GetGuild();
  5896. if (sep && sep->GetMaxArgNum() > 0 && sep->arg[0])
  5897. {
  5898. const char* command = sep->arg[0];
  5899. int32 length = strlen(command);
  5900. LogWrite(COMMAND__DEBUG, 0, "Command", "Guild Command: %s", command);
  5901. if (strncmp(command, "rank_name", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && guild)
  5902. guild->SetRankName(atoi(sep->arg[1]), sep->argplus[2]);
  5903. else if (strncmp(command, "rank_permission", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  5904. guild->SetPermission(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  5905. else if (strncmp(command, "filter_event", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  5906. guild->SetEventFilter(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  5907. else if (strncmp(command, "kick", length) == 0 && sep->arg[1] && guild)
  5908. guild->KickGuildMember(client, sep->arg[1]);
  5909. else if (strncmp(command, "demote", length) == 0 && sep->arg[1] && guild)
  5910. guild->DemoteGuildMember(client, sep->arg[1]);
  5911. else if (strncmp(command, "promote", length) == 0 && sep->arg[1] && guild)
  5912. guild->PromoteGuildMember(client, sep->arg[1]);
  5913. else if (strncmp(command, "points", length) == 0 && guild)
  5914. {
  5915. if (sep->arg[1] && strncmp(sep->arg[1], "add", length) == 0)
  5916. {
  5917. if (sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  5918. {
  5919. float points = atof(sep->arg[2]);
  5920. const char* option = sep->arg[3];
  5921. const char* comment = sep->argplus[4];
  5922. if (strncmp(option, "all", strlen(option)) == 0)
  5923. guild->AddPointsToAll(client, points, comment);
  5924. else if (strncmp(option, "online", strlen(option)) == 0)
  5925. guild->AddPointsToAllOnline(client, points, comment);
  5926. else if (strncmp(option, "group", strlen(option)) == 0)
  5927. guild->AddPointsToGroup(client, points, comment);
  5928. else if (strncmp(option, "raid", strlen(option)) == 0)
  5929. guild->AddPointsToRaid(client, points, comment);
  5930. else
  5931. guild->AddPointsToGuildMember(client, points, option, comment);
  5932. }
  5933. }
  5934. else if (sep->arg[1] && strncmp(sep->arg[1], "view", strlen(sep->arg[1])) == 0 && sep->arg[2])
  5935. guild->ViewGuildMemberPoints(client, sep->arg[2]);
  5936. else
  5937. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild points command: %s", sep->argplus[0]);
  5938. }
  5939. else if (strncmp(command, "motd", length) == 0 && sep->arg[1] && guild)
  5940. guild->SetMOTD(sep->argplus[1]);
  5941. else if (strncmp(command, "recruiting", length) == 0 && guild)
  5942. {
  5943. if (sep->arg[1])
  5944. {
  5945. const char* option = sep->arg[1];
  5946. if (strncmp(option, "short_text", strlen(option)) == 0 && sep->arg[2])
  5947. guild->SetRecruitingShortDesc(sep->argplus[2]);
  5948. else if (strncmp(option, "long_text", strlen(option)) == 0 && sep->arg[2])
  5949. guild->SetRecruitingFullDesc(sep->argplus[2]);
  5950. else if (strncmp(option, "flag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  5951. guild->SetRecruitingFlag(atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  5952. else if (strncmp(option, "min_level", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  5953. guild->SetRecruitingMinLevel(atoi(sep->arg[2]));
  5954. else if (strncmp(option, "playstyle", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  5955. guild->SetRecruitingPlayStyle(atoi(sep->arg[2]));
  5956. else if (strncmp(option, "tag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && sep->IsNumber(3))
  5957. guild->SetRecruitingDescTag(atoi(sep->arg[2]), atoi(sep->arg[3]));
  5958. else if (strncmp(command, "recruiting", strlen(option)) == 0)
  5959. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_RECRUITING_FOR_GUILD, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  5960. else
  5961. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  5962. }
  5963. else
  5964. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  5965. }
  5966. else if (strncmp(command, "notify_online", length) == 0 && sep->arg[1] && guild)
  5967. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_NOTIFY_LOGINS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  5968. else if (strncmp(command, "event_privacy", length) == 0 && sep->arg[1] && guild)
  5969. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_DONT_GENERATE_EVENTS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  5970. else if (strncmp(command, "recruiter", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  5971. guild->SetGuildRecruiter(client, sep->arg[1], strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  5972. else if (strncmp(command, "recruiter_description", length) == 0 && sep->arg[1] && guild)
  5973. guild->SetGuildRecruiterDescription(client, sep->argplus[1]);
  5974. else if (strncmp(command, "lock_event", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  5975. guild->LockGuildEvent(atoul(sep->arg[1]), strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  5976. else if (strncmp(command, "delete_event", length) == 0 && sep->arg[1] && guild)
  5977. guild->DeleteGuildEvent(atoul(sep->arg[1]));
  5978. else if (strncmp(command, "invite", length) == 0 && guild)
  5979. {
  5980. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  5981. guild->InvitePlayer(client, sep->arg[1]);
  5982. else
  5983. {
  5984. Spawn* target = client->GetPlayer()->GetTarget();
  5985. if (target)
  5986. {
  5987. if (target->IsPlayer())
  5988. guild->InvitePlayer(client, target->GetName());
  5989. else
  5990. client->Message(CHANNEL_NARRATIVE, "%s is not a player.", target->GetName());
  5991. }
  5992. }
  5993. }
  5994. else if (strncmp(command, "accept", length) == 0)
  5995. {
  5996. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  5997. if (pgi && pgi->guild && pgi->invited_by)
  5998. pgi->guild->AddNewGuildMember(client, pgi->invited_by->GetName());
  5999. client->SetPendingGuildInvite(0);
  6000. }
  6001. else if (strncmp(command, "decline", length) == 0)
  6002. {
  6003. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  6004. if (pgi && pgi->guild && pgi->invited_by)
  6005. {
  6006. Client* client_inviter = pgi->invited_by->GetZone()->GetClientBySpawn(pgi->invited_by);
  6007. if (client_inviter)
  6008. client_inviter->Message(CHANNEL_NARRATIVE, "%s has declined your invitation to join %s.", client->GetPlayer()->GetName(), pgi->guild->GetName());
  6009. }
  6010. client->SetPendingGuildInvite(0);
  6011. }
  6012. else if (strncmp(command, "create", length) == 0 && sep->arg[1])
  6013. {
  6014. const char* guild_name = sep->argplus[1];
  6015. if (!guild_list.GetGuild(guild_name))
  6016. world.CreateGuild(guild_name, client, client->GetPlayer()->GetGroupMemberInfo() ? client->GetPlayer()->GetGroupMemberInfo()->group_id : 0);
  6017. else
  6018. client->SimpleMessage(CHANNEL_NARRATIVE, "A guild with that name already exists.");
  6019. }
  6020. else if (strncmp(command, "search", length) == 0)
  6021. client->ShowGuildSearchWindow();
  6022. else if (strncmp(command, "recruiting_details", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  6023. {
  6024. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  6025. if (to_guild)
  6026. to_guild->SendGuildRecruitingDetails(client);
  6027. }
  6028. else if (strncmp(command, "recruiting_image", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  6029. {
  6030. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  6031. if (to_guild)
  6032. to_guild->SendGuildRecruitingImages(client);
  6033. }
  6034. else if (strncmp(command, "recruiter_adventure_class", length) == 0)
  6035. {
  6036. if (sep->arg[1])
  6037. {
  6038. const char* option = sep->arg[1];
  6039. if (strncmp(option, "toggle", strlen(option)) == 0)
  6040. guild->ToggleGuildRecruiterAdventureClass(client);
  6041. }
  6042. else
  6043. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiter_adventure_class command: '%s'", sep->argplus[0]);
  6044. }
  6045. else if (strncmp(command, "display_heraldry", length) == 0)
  6046. {
  6047. // JA: not sure this is right...
  6048. client->GetPlayer()->toggle_character_flag(CF_SHOW_GUILD_HERALDRY);
  6049. client->GetPlayer()->SetCharSheetChanged(true);
  6050. }
  6051. else
  6052. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild command: '%s'", sep->argplus[0]);
  6053. }
  6054. }
  6055. /*
  6056. Function: Command_GuildCreate()
  6057. Purpose : Display's in-game Guild Creation window
  6058. Dev : Scatman
  6059. */
  6060. void Commands::Command_CreateGuild(Client* client)
  6061. {
  6062. client->SendGuildCreateWindow();
  6063. }
  6064. /*
  6065. Function: Command_SetGuildOfficerNote()
  6066. Purpose :
  6067. Dev : Scatman
  6068. */
  6069. void Commands::Command_SetGuildOfficerNote(Client* client, Seperator* sep)
  6070. {
  6071. if (sep && sep->arg[0] && sep->arg[1])
  6072. {
  6073. Guild* guild = client->GetPlayer()->GetGuild();
  6074. if (guild)
  6075. guild->SetGuildOfficerNote(sep->arg[0], sep->argplus[1]);
  6076. }
  6077. }
  6078. /*
  6079. Function: Command_SetGuildMemberNote()
  6080. Purpose :
  6081. Dev : Scatman
  6082. */
  6083. void Commands::Command_SetGuildMemberNote(Client* client, Seperator* sep)
  6084. {
  6085. if (sep && sep->arg[0] && sep->arg[1])
  6086. {
  6087. Guild* guild = client->GetPlayer()->GetGuild();
  6088. if (guild)
  6089. guild->SetGuildMemberNote(sep->arg[0], sep->argplus[1]);
  6090. }
  6091. }
  6092. /*
  6093. Function: Command_GuildSay()
  6094. Purpose :
  6095. Dev : Scatman
  6096. */
  6097. void Commands::Command_GuildSay(Client* client, Seperator* sep)
  6098. {
  6099. Guild* guild = client->GetPlayer()->GetGuild();
  6100. if (guild)
  6101. {
  6102. if (sep && sep->arg[0])
  6103. guild->HandleGuildSay(client, sep->argplus[0]);
  6104. }
  6105. else
  6106. client->SimpleMessage(CHANNEL_NARRATIVE, "You are not a member of a guild");
  6107. }
  6108. /*
  6109. Function: Command_OfficerSay()
  6110. Purpose :
  6111. Dev : Scatman
  6112. */
  6113. void Commands::Command_OfficerSay(Client* client, Seperator* sep)
  6114. {
  6115. Guild* guild = client->GetPlayer()->GetGuild();
  6116. if (guild)
  6117. {
  6118. if (sep && sep->arg[0])
  6119. guild->HandleOfficerSay(client, sep->argplus[0]);
  6120. }
  6121. else
  6122. client->SimpleMessage(CHANNEL_NARRATIVE, "You are not a member of a guild");
  6123. }
  6124. /*
  6125. Function: Command_Guilds()
  6126. Purpose : Shows help for /guild command
  6127. Params :
  6128. Dev : Scatman
  6129. Example :
  6130. */
  6131. void Commands::Command_Guilds(Client* client)
  6132. {
  6133. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds [create|delete|add|remove|list]");
  6134. }
  6135. /*
  6136. Function: Command_GuildsAdd()
  6137. Purpose : Add's players to a guild
  6138. Params : guild_name|guild_id, player name
  6139. Dev : Scatman
  6140. Example : /guilds add 1 Admin = adds player Admin to guild_id 1
  6141. */
  6142. void Commands::Command_GuildsAdd(Client* client, Seperator* sep)
  6143. {
  6144. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  6145. {
  6146. Guild* guild = 0;
  6147. bool found = true;
  6148. if (sep->IsNumber(0))
  6149. {
  6150. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  6151. if (!guild)
  6152. {
  6153. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  6154. found = false;
  6155. }
  6156. }
  6157. else
  6158. {
  6159. guild = guild_list.GetGuild(sep->arg[0]);
  6160. if (!guild)
  6161. {
  6162. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  6163. found = false;
  6164. }
  6165. }
  6166. if (found)
  6167. {
  6168. Client* to_client = 0;
  6169. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  6170. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  6171. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  6172. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  6173. if (to_client)
  6174. guild->InvitePlayer(client, to_client->GetPlayer()->GetName());
  6175. else
  6176. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  6177. }
  6178. }
  6179. else
  6180. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds add [guild name|guild id] (player name).");
  6181. }
  6182. /*
  6183. Function: Command_GuildsCreate()
  6184. Purpose : Creates a guild
  6185. Params : guild_name, player_name (optional)
  6186. Dev : Scatman
  6187. Example : /guilds create [guild name] (player name)
  6188. */
  6189. void Commands::Command_GuildsCreate(Client* client, Seperator* sep)
  6190. {
  6191. if (sep && sep->arg[0])
  6192. {
  6193. const char* guild_name = sep->arg[0];
  6194. if (!guild_list.GetGuild(guild_name))
  6195. {
  6196. bool ret = false;
  6197. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  6198. {
  6199. Client* to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  6200. if (to_client)
  6201. {
  6202. world.CreateGuild(guild_name, to_client);
  6203. ret = true;
  6204. }
  6205. else
  6206. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player with name '%s'", sep->arg[1]);
  6207. }
  6208. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  6209. {
  6210. Client* to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  6211. if (to_client)
  6212. {
  6213. world.CreateGuild(guild_name, to_client);
  6214. ret = true;
  6215. }
  6216. }
  6217. else
  6218. {
  6219. world.CreateGuild(guild_name);
  6220. ret = true;
  6221. }
  6222. if (ret)
  6223. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully created.", guild_name);
  6224. else
  6225. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the guild.");
  6226. }
  6227. else
  6228. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' already exists.", guild_name);
  6229. }
  6230. else
  6231. 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.");
  6232. }
  6233. /*
  6234. Function: Command_GuildsDelete()
  6235. Purpose : Delete's a guild
  6236. Params : guild name
  6237. Dev : Scatman
  6238. Example : /guilds delete Test
  6239. */
  6240. void Commands::Command_GuildsDelete(Client* client, Seperator* sep)
  6241. {
  6242. if (sep && sep->arg[0])
  6243. {
  6244. Guild* guild = 0;
  6245. bool found = true;
  6246. if (sep->IsNumber(0))
  6247. {
  6248. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  6249. if (!guild)
  6250. {
  6251. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  6252. found = false;
  6253. }
  6254. }
  6255. else
  6256. {
  6257. guild = guild_list.GetGuild(sep->arg[0]);
  6258. if (!guild)
  6259. {
  6260. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  6261. found = false;
  6262. }
  6263. }
  6264. if (found)
  6265. {
  6266. guild->RemoveAllGuildMembers();
  6267. database.DeleteGuild(guild);
  6268. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully deleted.", guild->GetName());
  6269. guild_list.RemoveGuild(guild, true);
  6270. }
  6271. }
  6272. else
  6273. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds delete [guild name].");
  6274. }
  6275. /*
  6276. Function: Command_GuildsList()
  6277. Purpose : Lists current guilds on server
  6278. Params :
  6279. Dev : Scatman
  6280. Example : /guilds list
  6281. */
  6282. void Commands::Command_GuildsList(Client* client)
  6283. {
  6284. MutexMap<int32, Guild*>* guilds = guild_list.GetGuilds();
  6285. MutexMap<int32, Guild*>::iterator itr = guilds->begin();
  6286. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Guild List:");
  6287. if (guilds->size() == 0)
  6288. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "None.");
  6289. else {
  6290. while (itr.Next()) {
  6291. Guild* guild = itr.second;
  6292. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", guild->GetID(), guild->GetName());
  6293. }
  6294. }
  6295. }
  6296. /*
  6297. Function: Command_GuildsRemove()
  6298. Purpose : Removes a player from a guild
  6299. Params : guild name|guild id, player name
  6300. Dev : Scatman
  6301. Example : /guilds remove 1 Admin = removes Admin from guild 1
  6302. */
  6303. void Commands::Command_GuildsRemove(Client* client, Seperator* sep)
  6304. {
  6305. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  6306. {
  6307. Guild* guild = 0;
  6308. bool found = true;
  6309. if (sep->IsNumber(0))
  6310. {
  6311. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  6312. if (!guild)
  6313. {
  6314. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  6315. found = false;
  6316. }
  6317. }
  6318. else
  6319. {
  6320. guild = guild_list.GetGuild(sep->arg[0]);
  6321. if (!guild)
  6322. {
  6323. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  6324. found = false;
  6325. }
  6326. }
  6327. if (found)
  6328. {
  6329. Client* to_client = 0;
  6330. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  6331. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  6332. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  6333. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  6334. if (to_client)
  6335. {
  6336. Player* to_player = to_client->GetPlayer();
  6337. if (to_player->GetGuild())
  6338. {
  6339. if (to_player->GetGuild() == guild)
  6340. {
  6341. guild->KickGuildMember(client, to_player->GetName());
  6342. }
  6343. else
  6344. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in the guild '%s'.", to_player->GetName(), guild->GetName());
  6345. }
  6346. else
  6347. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in a guild.", to_player->GetName());
  6348. }
  6349. else
  6350. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  6351. }
  6352. }
  6353. else
  6354. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds remove [guild name|guild id] (player name).");
  6355. }
  6356. /*
  6357. Function: Command_InspectPlayer()
  6358. Purpose : Handle the Inspect functions
  6359. Params : Client to inspect
  6360. Dev : Scatman
  6361. Example : /inspect Scatman
  6362. */
  6363. void Commands::Command_InspectPlayer(Client* client, Seperator* sep)
  6364. {
  6365. if (sep && sep->arg[0])
  6366. {
  6367. Client* inspect_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  6368. if (inspect_client)
  6369. client->InspectPlayer(inspect_client->GetPlayer());
  6370. }
  6371. else
  6372. {
  6373. Spawn* target = client->GetPlayer()->GetTarget();
  6374. if (target && target->IsPlayer())
  6375. client->InspectPlayer((Player*)target);
  6376. }
  6377. }
  6378. /*
  6379. Function: Command_Inventory()
  6380. Purpose : Handle changes in player inventory
  6381. Params : <TBD>
  6382. Dev : All
  6383. Example : /inventory delete item_id
  6384. */
  6385. void Commands::Command_Inventory(Client* client, Seperator* sep, EQ2_RemoteCommandString* command)
  6386. {
  6387. PrintSep(sep, "Command_Inventory"); // temp to figure out the params
  6388. Player* player = client->GetPlayer();
  6389. if(sep && sep->arg[0][0])
  6390. {
  6391. LogWrite(COMMAND__INFO, 0, "Command", "command: %s", sep->argplus[0]);
  6392. if(!client->GetPlayer()->Alive())
  6393. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  6394. else if(sep->arg[1][0] && strncasecmp("destroy", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  6395. {
  6396. int16 index = atoi(sep->arg[1]);
  6397. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  6398. if(item)
  6399. {
  6400. if(item->details.item_locked) {
  6401. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot destroy the item in use.");
  6402. return;
  6403. }
  6404. else if(item->CheckFlag(NO_DESTROY)) {
  6405. client->SimpleMessage(CHANNEL_COLOR_RED, "You can't destroy this item.");
  6406. return;
  6407. }
  6408. if(item->GetItemScript() && lua_interface)
  6409. lua_interface->RunItemScript(item->GetItemScript(), "destroyed", item, client->GetPlayer());
  6410. //reobtain item make sure it wasn't removed
  6411. item = player->item_list.GetItemFromIndex(index);
  6412. int32 bag_id = 0;
  6413. if(item){
  6414. bag_id = item->details.inv_slot_id;
  6415. database.DeleteItem(client->GetCharacterID(), item, 0);
  6416. }
  6417. client->GetPlayer()->item_list.DestroyItem(index);
  6418. client->GetPlayer()->UpdateInventory(bag_id);
  6419. }
  6420. }
  6421. 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))
  6422. {
  6423. int16 from_index = atoi(sep->arg[1]);
  6424. sint16 to_slot = atoi(sep->arg[2]); // don't convert slot since this is inventory not equipment
  6425. sint32 bag_id = atol(sep->arg[3]);
  6426. int8 charges = atoi(sep->arg[4]);
  6427. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(from_index);
  6428. if(!item) {
  6429. client->SimpleMessage(CHANNEL_COLOR_RED, "You have no item.");
  6430. return;
  6431. }
  6432. if(to_slot == item->details.slot_id && (bag_id < 0 || bag_id == item->details.inv_slot_id)) {
  6433. return;
  6434. }
  6435. if(item->details.item_locked)
  6436. {
  6437. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot move the item in use.");
  6438. return;
  6439. }
  6440. if(bag_id == -4 && !client->GetPlayer()->item_list.SharedBankAddAllowed(item))
  6441. {
  6442. client->SimpleMessage(CHANNEL_COLOR_RED, "That item (or an item inside) cannot be shared.");
  6443. return;
  6444. }
  6445. sint32 old_inventory_id = 0;
  6446. if(item)
  6447. old_inventory_id = item->details.inv_slot_id;
  6448. //autobank
  6449. if (bag_id == -3 && to_slot == -1)
  6450. {
  6451. if (player->HasFreeBankSlot())
  6452. to_slot = player->FindFreeBankSlot();
  6453. else
  6454. {
  6455. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free bank slots.");
  6456. return;
  6457. }
  6458. }
  6459. //auto inventory
  6460. if (bag_id == 0 && to_slot == -1)
  6461. {
  6462. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  6463. {
  6464. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free slots.");
  6465. return;
  6466. }
  6467. }
  6468. bool item_deleted = false;
  6469. EQ2Packet* outapp = client->GetPlayer()->MoveInventoryItem(bag_id, from_index, (int8)to_slot, charges, 0, &item_deleted, client->GetVersion());
  6470. client->QueuePacket(outapp);
  6471. if(item_deleted)
  6472. item = nullptr;
  6473. //removed from bag send update
  6474. if(old_inventory_id > 0 && item && item->details.inv_slot_id != old_inventory_id)
  6475. {
  6476. outapp = client->GetPlayer()->SendBagUpdate(old_inventory_id, client->GetVersion());
  6477. if(outapp)
  6478. client->QueuePacket(outapp);
  6479. }
  6480. if(item && item->details.inv_slot_id > 0 && item->details.inv_slot_id != old_inventory_id)
  6481. {
  6482. outapp = client->GetPlayer()->SendBagUpdate(item->details.inv_slot_id, client->GetVersion());
  6483. if(outapp)
  6484. client->QueuePacket(outapp);
  6485. }
  6486. }
  6487. else if(sep->arg[1][0] && strncasecmp("equip", sep->arg[0], 5) == 0 && sep->IsNumber(1))
  6488. {
  6489. if(client->GetPlayer()->EngagedInCombat())
  6490. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not equip items while in combat.");
  6491. else
  6492. {
  6493. int16 index = atoi(sep->arg[1]);
  6494. int8 slot_id = 255;
  6495. int8 unk3 = 0;
  6496. int8 appearance_equip = 0;
  6497. if(sep->arg[2][0] && sep->IsNumber(2))
  6498. slot_id = player->ConvertSlotFromClient(atoi(sep->arg[2]), client->GetVersion());
  6499. if(sep->arg[3][0] && sep->IsNumber(3))
  6500. unk3 = atoul(sep->arg[3]);
  6501. if(sep->arg[4][0] && sep->IsNumber(4))
  6502. appearance_equip = atoul(sep->arg[4]);
  6503. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), appearance_equip, slot_id);
  6504. EQ2Packet* outapp = 0;
  6505. for(int32 i=0;i<packets.size();i++)
  6506. {
  6507. outapp = packets[i];
  6508. if(outapp)
  6509. client->QueuePacket(outapp);
  6510. }
  6511. client->GetPlayer()->UpdateWeapons();
  6512. EQ2Packet* characterSheetPackets = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion());
  6513. client->QueuePacket(characterSheetPackets);
  6514. }
  6515. }
  6516. else if (sep->arg[1][0] && strncasecmp("unpack", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  6517. {
  6518. if (client->GetPlayer()->EngagedInCombat())
  6519. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unpack items while in combat.");
  6520. else {
  6521. int16 index = atoi(sep->arg[1]);
  6522. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  6523. if (item) {
  6524. if(item->details.item_locked)
  6525. {
  6526. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot unpack the item in use.");
  6527. return;
  6528. }
  6529. // client->GetPlayer()->item_list.DestroyItem(index);
  6530. if (item->item_sets.size() > 0) {
  6531. for (int32 i = 0; i < item->item_sets.size(); i++) {
  6532. ItemSet* set = item->item_sets[i];
  6533. if (set->item_stack_size == 0)
  6534. set->item_stack_size += 1;
  6535. client->AddItem(set->item_id, set->item_stack_size);
  6536. }
  6537. }
  6538. }
  6539. client->RemoveItem(item, 1);
  6540. }
  6541. }
  6542. else if(sep->arg[1][0] && strncasecmp("unequip", sep->arg[0], 7) == 0 && sep->IsNumber(1))
  6543. {
  6544. if(client->GetPlayer()->EngagedInCombat())
  6545. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unequip items while in combat.");
  6546. else
  6547. {
  6548. int16 index = player->ConvertSlotFromClient(atoi(sep->arg[1]), client->GetVersion());
  6549. sint32 bag_id = -999;
  6550. int8 to_slot = 255;
  6551. if(sep->arg[3][0])
  6552. {
  6553. if(sep->IsNumber(2))
  6554. bag_id = atol(sep->arg[2]);
  6555. if(sep->IsNumber(3))
  6556. to_slot = atoi(sep->arg[3]);
  6557. }
  6558. sint8 unk4 = 0;
  6559. int8 appearance_equip = 0;
  6560. if(sep->arg[4][0] && sep->IsNumber(4))
  6561. unk4 = atoi(sep->arg[4]);
  6562. if(sep->arg[5][0] && sep->IsNumber(5))
  6563. appearance_equip = atoul(sep->arg[5]);
  6564. vector<EQ2Packet*> packets = client->GetPlayer()->UnequipItem(index, bag_id, to_slot, client->GetVersion(), appearance_equip);
  6565. EQ2Packet* outapp = 0;
  6566. for(int32 i=0;i<packets.size();i++)
  6567. {
  6568. outapp = packets[i];
  6569. if(outapp)
  6570. client->QueuePacket(outapp);
  6571. }
  6572. client->UnequipItem(index, bag_id, to_slot, appearance_equip);
  6573. }
  6574. }
  6575. else if(sep->arg[2][0] && strncasecmp("swap_equip", sep->arg[0], 10) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  6576. {
  6577. if(client->GetPlayer()->EngagedInCombat()) {
  6578. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not swap items while in combat.");
  6579. }
  6580. else {
  6581. int16 index1 = client->GetPlayer()->ConvertSlotFromClient(atoi(sep->arg[1]), client->GetVersion());
  6582. int16 index2 = client->GetPlayer()->ConvertSlotFromClient(atoi(sep->arg[2]), client->GetVersion());
  6583. int8 type = 0;
  6584. if(sep->IsNumber(3))
  6585. type = atoul(sep->arg[3]); // type 0 is combat, 3 = appearance
  6586. EQ2Packet* outapp = client->GetPlayer()->SwapEquippedItems(index1, index2, client->GetVersion(), type);
  6587. if(outapp)
  6588. client->QueuePacket(outapp);
  6589. else
  6590. {
  6591. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to swap items");
  6592. return;
  6593. }
  6594. }
  6595. }
  6596. else if (sep->arg[2][0] && strncasecmp("pop", sep->arg[0], 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  6597. {
  6598. sint16 to_slot = atoi(sep->arg[1]);
  6599. sint32 bag_id = atoi(sep->arg[2]);
  6600. Item* item = client->GetPlayer()->item_list.GetOverflowItem();
  6601. if (item) {
  6602. //auto inventory
  6603. if (bag_id == 0 && to_slot == -1)
  6604. {
  6605. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  6606. {
  6607. client->SimpleMessage(CHANNEL_ERROR, "You do not have any free slots.");
  6608. return;
  6609. }
  6610. // Set the slot for the item
  6611. item->details.inv_slot_id = bag_id;
  6612. item->details.slot_id = to_slot;
  6613. // Flag the item so it gets saved in its new location
  6614. item->save_needed = true;
  6615. // Add the item to its new location
  6616. if(player->item_list.AddItem(item)) {
  6617. // Remove the item from the overflow list
  6618. player->item_list.RemoveOverflowItem(item);
  6619. }
  6620. // Send the inventory update packet
  6621. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  6622. return;
  6623. }
  6624. else if (bag_id == -3 && to_slot == -1) {
  6625. // Auto Bank
  6626. if (!player->item_list.GetFirstFreeBankSlot(&bag_id, &to_slot)) {
  6627. client->SimpleMessage(CHANNEL_STATUS, "You do not have any free bank slots.");
  6628. return;
  6629. }
  6630. item->details.inv_slot_id = bag_id;
  6631. item->details.slot_id = to_slot;
  6632. item->save_needed = true;
  6633. if(player->item_list.AddItem(item)) {
  6634. player->item_list.RemoveOverflowItem(item);
  6635. }
  6636. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  6637. }
  6638. else if (bag_id == -4) {
  6639. // Shared Bank
  6640. if (!player->item_list.SharedBankAddAllowed(item)) {
  6641. client->SimpleMessage(CHANNEL_STATUS, "That item (or an item inside) cannot be shared.");
  6642. return;
  6643. }
  6644. Item* tmp_item = player->item_list.GetItem(-4, to_slot);
  6645. if (tmp_item) {
  6646. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  6647. return;
  6648. }
  6649. else {
  6650. item->details.inv_slot_id = bag_id;
  6651. item->details.slot_id = to_slot;
  6652. item->save_needed = true;
  6653. if(player->item_list.AddItem(item)) {
  6654. player->item_list.RemoveOverflowItem(item);
  6655. }
  6656. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  6657. return;
  6658. }
  6659. }
  6660. else {
  6661. // Try to get an item from the given bag id and slot id
  6662. Item* tmp_item = player->item_list.GetItem(bag_id, to_slot);
  6663. // Check to see if we got an item, if we do send an error,
  6664. // if we don't put the overflow item into this slot
  6665. if (tmp_item) {
  6666. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  6667. }
  6668. else {
  6669. item->details.inv_slot_id = bag_id;
  6670. item->details.slot_id = to_slot;
  6671. item->save_needed = true;
  6672. if(player->item_list.AddItem(item)) {
  6673. player->item_list.RemoveOverflowItem(item);
  6674. }
  6675. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  6676. return;
  6677. }
  6678. }
  6679. }
  6680. }
  6681. else if(sep->arg[2][0] && strncasecmp("nosale", sep->arg[0], 6) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  6682. {
  6683. sint64 data = strtoull(sep->arg[1], NULL, 0);
  6684. int32 character_item_id = (int32) (data >> 32);
  6685. int32 item_id = (int32) (data & 0xffffffffL);
  6686. int8 sale_setting = atoi(sep->arg[2]);
  6687. Item* item = client->GetPlayer()->item_list.GetItemFromUniqueID(character_item_id);
  6688. if(item)
  6689. {
  6690. item->no_sale = sale_setting;
  6691. item->save_needed = true;
  6692. client->SendSellMerchantList();
  6693. }
  6694. }
  6695. }
  6696. else
  6697. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /inventory {destroy|move|equip|unequip|swap_equip|pop} {item_id} [to_slot] [bag_id]");
  6698. }
  6699. /*
  6700. Function: Command_Languages()
  6701. Purpose : Show's languages the player knows
  6702. Params :
  6703. Dev : Zcoretri
  6704. Example :
  6705. */
  6706. void Commands::Command_Languages(Client* client, Seperator* sep)
  6707. {
  6708. list<Language*>* languages = client->GetPlayer()->GetPlayerLanguages()->GetAllLanguages();
  6709. list<Language*>::iterator itr;
  6710. Language* language;
  6711. client->Message(CHANNEL_NARRATIVE, "You know the following languages:");
  6712. for(itr = languages->begin(); itr != languages->end(); itr++)
  6713. {
  6714. language = *itr;
  6715. client->Message(CHANNEL_NARRATIVE, "%s", language->GetName());
  6716. }
  6717. }
  6718. /*
  6719. Function: Command_SetLanguage()
  6720. Purpose : Handles language commands
  6721. Params : Language ID
  6722. Dev : Zcoretri
  6723. Example :
  6724. */
  6725. void Commands::Command_SetLanguage(Client* client, Seperator* sep)
  6726. {
  6727. Player* player = client->GetPlayer();
  6728. if (sep && sep->arg[0])
  6729. {
  6730. if(!sep->IsNumber(0))
  6731. {
  6732. //String passed in
  6733. const char* value = sep->arg[0];
  6734. if(strncasecmp(value, "Common", strlen(value)) == 0)
  6735. {
  6736. database.SaveCharacterCurrentLang(0, client->GetCharacterID(), client);
  6737. client->SendLanguagesUpdate(0);
  6738. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", value);
  6739. }
  6740. else
  6741. {
  6742. if(player->HasLanguage(value))
  6743. {
  6744. Language* language = player->GetPlayerLanguages()->GetLanguageByName(value);
  6745. database.SaveCharacterCurrentLang(language->GetID(), client->GetCharacterID(), client);
  6746. client->SendLanguagesUpdate(language->GetID());
  6747. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", language->GetName());
  6748. }
  6749. else
  6750. client->Message(CHANNEL_NARRATIVE, "You do not know how to speak %s", value);
  6751. }
  6752. }
  6753. else
  6754. {
  6755. //Number passed in
  6756. int32 id = atoul(sep->arg[0]);
  6757. if(player->HasLanguage(id))
  6758. {
  6759. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  6760. database.SaveCharacterCurrentLang(id, client->GetCharacterID(), client);
  6761. client->SendLanguagesUpdate(id);
  6762. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", language->GetName());
  6763. }
  6764. else
  6765. {
  6766. Language* language = master_languages_list.GetLanguage(id);
  6767. if(language)
  6768. client->Message(CHANNEL_NARRATIVE, "You do not know how to speak %s", language->GetName());
  6769. }
  6770. }
  6771. }
  6772. else
  6773. {
  6774. //No value was passed in
  6775. int32 id = database.GetCharacterCurrentLang(client->GetCharacterID(), player);
  6776. if(id > 0)
  6777. {
  6778. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  6779. client->Message(CHANNEL_NARRATIVE, "You are currently speaking %s ", language->GetName());
  6780. }
  6781. else
  6782. client->Message(CHANNEL_NARRATIVE, "You are currently speaking Common");
  6783. }
  6784. }
  6785. /*
  6786. Function: Command_LastName()
  6787. Purpose : Sets player surname
  6788. Params : Name text
  6789. Dev : theFoof
  6790. Example :
  6791. */
  6792. void Commands::Command_LastName(Client* client, Seperator* sep)
  6793. {
  6794. if (!client)
  6795. return;
  6796. if (sep && sep->arg[0])
  6797. {
  6798. if (!client->GetPlayer()->get_character_flag(CF_ENABLE_CHANGE_LASTNAME)){
  6799. client->Message(CHANNEL_COLOR_YELLOW, "You must be atleast level %i to change your last name.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  6800. return;
  6801. }
  6802. client->RemovePendingLastName();
  6803. uchar* checkname = (uchar*)sep->arg[0];
  6804. bool valid_name = true;
  6805. for (int32 i = 0; i < strlen(sep->arg[0]); i++) {
  6806. if (!alpha_check(checkname[i])) {
  6807. valid_name = false;
  6808. break;
  6809. }
  6810. }
  6811. if (!valid_name) {
  6812. client->Message(CHANNEL_COLOR_YELLOW, "Your last name can only contain letters.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  6813. return;
  6814. }
  6815. string last_name = (string)sep->arg[0];
  6816. int8 max_length = rule_manager.GetGlobalRule(R_Player, MaxLastNameLength)->GetInt8();
  6817. int8 min_length = rule_manager.GetGlobalRule(R_Player, MinLastNameLength)->GetInt8();
  6818. if (last_name.length() <= max_length && last_name.length() >= min_length){
  6819. client->SetPendingLastName(last_name);
  6820. client->SendLastNameConfirmation();
  6821. }
  6822. else
  6823. client->Message(CHANNEL_COLOR_YELLOW, "Your last name must be between %i and %i characters long.", min_length, max_length);
  6824. }
  6825. }
  6826. /*
  6827. Function: Command_ConfirmLastName()
  6828. Purpose : Confirms setting of player surname
  6829. Params : Name text
  6830. Dev : theFoof
  6831. Example :
  6832. */
  6833. void Commands::Command_ConfirmLastName(Client* client, Seperator* sep)
  6834. {
  6835. if (!client)
  6836. return;
  6837. string* name = client->GetPendingLastName();
  6838. if (name){
  6839. Player* player = client->GetPlayer();
  6840. player->SetLastName(name->c_str(), false);
  6841. client->SendTitleUpdate();
  6842. player->SetCharSheetChanged(true);
  6843. client->RemovePendingLastName();
  6844. }
  6845. }
  6846. /*
  6847. Function: Command_Location()
  6848. Purpose : Display's Help for /location commands
  6849. Params :
  6850. Dev : Scatman
  6851. Example : /location = show's help for command
  6852. */
  6853. void Commands::Command_Location(Client* client)
  6854. {
  6855. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Valid /location commands are:");
  6856. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location create [name] (include y). Include y defaults to false");
  6857. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location add [location id]");
  6858. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location remove [location point id]");
  6859. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location delete [location id]");
  6860. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location list [locations|points] [location id if points used]");
  6861. }
  6862. /*
  6863. Function: Command_LocationAdd()
  6864. Purpose : Add's a location to an existing location config
  6865. Params : location_id
  6866. Dev : Scatman
  6867. Example : /location add {location_id}
  6868. */
  6869. void Commands::Command_LocationAdd(Client* client, Seperator* sep)
  6870. {
  6871. if (sep && sep->arg[0] && sep->IsNumber(0))
  6872. {
  6873. int32 location_id = atoul(sep->arg[0]);
  6874. float x = client->GetPlayer()->GetX();
  6875. float y = client->GetPlayer()->GetY();
  6876. float z = client->GetPlayer()->GetZ();
  6877. if (database.AddLocationPoint(location_id, x, y, z))
  6878. client->Message(CHANNEL_COLOR_YELLOW, "Point (%f, %f, %f) was successfully added to location %u", x, y, z, location_id);
  6879. else
  6880. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist. Use /location create to create one", location_id);
  6881. }
  6882. else
  6883. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location add [location id]");
  6884. }
  6885. /*
  6886. Function: Command_LocationCreate()
  6887. Purpose : Creates a new location config
  6888. Params : location name, 0/1 for include_y (optional)
  6889. Dev : Scatman
  6890. Example : /location create Test 1 = creates a new location named Test with include_y True
  6891. */
  6892. void Commands::Command_LocationCreate(Client* client, Seperator* sep)
  6893. {
  6894. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  6895. {
  6896. const char* name = sep->arg[0];
  6897. bool include_y = false;
  6898. if (sep->arg[1] && sep->IsNumber(1) && atoi(sep->arg[1]) > 0)
  6899. include_y = true;
  6900. int32 location_id = database.CreateLocation(client->GetPlayer()->GetZone()->GetZoneID(), client->GetPlayer()->GetLocation(), name, include_y);
  6901. if (location_id > 0)
  6902. client->Message(CHANNEL_COLOR_YELLOW, "Location '%s' was successfully created with location id %u", name, location_id);
  6903. else
  6904. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the requested location");
  6905. }
  6906. else
  6907. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location create [name] (include_y). Include y defaults to false");
  6908. }
  6909. /*
  6910. Function: Command_LocationDelete()
  6911. Purpose : Delete's a location config and all it's location points
  6912. Params : location_id
  6913. Dev : Scatman
  6914. Example : /location delete {location_id}
  6915. */
  6916. void Commands::Command_LocationDelete(Client* client, Seperator* sep)
  6917. {
  6918. if (sep && sep->arg[0] && sep->IsNumber(0))
  6919. {
  6920. int32 location_id = atoul(sep->arg[0]);
  6921. if (database.DeleteLocation(location_id))
  6922. client->Message(CHANNEL_COLOR_YELLOW, "Location id %u and all its points were successfully deleted", location_id);
  6923. else
  6924. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist", location_id);
  6925. }
  6926. else
  6927. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location delete [location id]");
  6928. }
  6929. /*
  6930. Function: Command_LocationList()
  6931. Purpose : Display's a list of location points
  6932. Params : location_id
  6933. Dev : Scatman
  6934. Example : /location list {location_id}
  6935. */
  6936. void Commands::Command_LocationList(Client* client, Seperator* sep)
  6937. {
  6938. if (sep && sep->arg[0])
  6939. {
  6940. const char* option = sep->arg[0];
  6941. if (strncmp(option, "locations", strlen(option)) == 0)
  6942. database.ListLocations(client);
  6943. else if (strncmp(option, "points", strlen(option)) == 0 && sep->arg[1] && sep->IsNumber(1))
  6944. {
  6945. int32 location_id = atoul(sep->arg[1]);
  6946. database.ListLocationPoints(client, location_id);
  6947. }
  6948. else
  6949. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  6950. }
  6951. else
  6952. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  6953. }
  6954. /*
  6955. Function: Command_LocationRemove()
  6956. Purpose : Removes a single location point from a location config
  6957. Params : location_point_id (gotten from /location list {id})
  6958. Dev : Scatman
  6959. Example : /location remove 1 = will remove location_point_id 1
  6960. */
  6961. void Commands::Command_LocationRemove(Client* client, Seperator* sep)
  6962. {
  6963. if (sep && sep->arg[0] && sep->IsNumber(0))
  6964. {
  6965. int32 location_point_id = atoul(sep->arg[0]);
  6966. if (database.DeleteLocationPoint(location_point_id))
  6967. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Location point was successfully deleted");
  6968. else
  6969. client->Message(CHANNEL_COLOR_YELLOW, "Location point with ID %u does not exist", location_point_id);
  6970. }
  6971. else
  6972. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location remove [location point id]");
  6973. }
  6974. /*
  6975. Function: Command_Merchant()
  6976. Purpose : Handles Merchant commands
  6977. Params : list
  6978. Dev : Scatman
  6979. Example : /merchant list
  6980. */
  6981. void Commands::Command_Merchant(Client* client, Seperator* sep, int handler)
  6982. {
  6983. if( handler == COMMAND_MERCHANT )
  6984. {
  6985. // /merchant command by itself shows help (to be extended)
  6986. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  6987. return;
  6988. }
  6989. else if( handler == COMMAND_MERCHANT_LIST )
  6990. {
  6991. // /merchant list command expects "description" param
  6992. if (sep && sep->arg[0])
  6993. {
  6994. const char* merchant_description = sep->argplus[0];
  6995. client->Message(CHANNEL_COLOR_YELLOW, "Listing merchants like '%s':", merchant_description);
  6996. map<int32, MerchantInfo*>* merchant_info = world.GetMerchantInfo();
  6997. map<int32, MerchantInfo*>::iterator itr;
  6998. for (itr = merchant_info->begin(); itr != merchant_info->end(); itr++)
  6999. {
  7000. string description = database.GetMerchantDescription(itr->first);
  7001. if (ToLower(description).find(ToLower(string(merchant_description))) < 0xFFFFFFFF)
  7002. client->Message(CHANNEL_COLOR_YELLOW, "Merchant ID: %u, Description: %s", itr->first, description.c_str());
  7003. }
  7004. }
  7005. else // no description
  7006. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  7007. }
  7008. }
  7009. /*
  7010. Function: Command_Modify()
  7011. Purpose : to replace our other "set" commands
  7012. Params : System = the system to modify, Action = the action to perform, Target = what to change (target, or index)
  7013. Dev : John Adams
  7014. Example : /modify spell set name "Aegolism III"
  7015. */
  7016. void Commands::Command_Modify(Client* client)
  7017. {
  7018. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /modify [system] [action] [field] [value] {target|id}");
  7019. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Systems: character, faction, guild, item, skill, spawn, spell, zone");
  7020. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Actions: set, create, delete, add, remove");
  7021. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Value : field name in the table being modified");
  7022. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target : modify current target, or specified {system} ID");
  7023. }
  7024. /*
  7025. Function: Command_ModifySpawn()
  7026. Purpose : replace "spawn set" commands
  7027. Params : Action : the action to perform (or special handler)
  7028. : Field : the DB field to change
  7029. : Value : what to set the value to
  7030. : Target : what object to change (my target, or spawn_id)
  7031. Dev : John Adams
  7032. Example : /modify spawn set name "Lady Vox"
  7033. :
  7034. Note : Special Handlers, like "zoneto" for Signs
  7035. : /modify spawn zoneto
  7036. : Will set a sign's zone x/y/z to my current coords
  7037. */
  7038. void Commands::Command_ModifySpawn(Client* client, Seperator* sep)
  7039. {
  7040. PrintSep(sep, "COMMAND_MODIFY");
  7041. // need at least 2 args for a valid command
  7042. if( sep && sep->arg[1] )
  7043. {
  7044. // JA: just a quick implementation because I need it :)
  7045. if (strcmp(sep->arg[0], "zoneto") == 0)
  7046. {
  7047. if( sep->IsNumber(1) )
  7048. {
  7049. int32 spawn_id = atoul(sep->arg[1]);
  7050. float x_coord = client->GetPlayer()->GetX();
  7051. float y_coord = client->GetPlayer()->GetY();
  7052. float z_coord = client->GetPlayer()->GetZ();
  7053. float h_coord = client->GetPlayer()->GetHeading();
  7054. database.SaveSignZoneToCoords(spawn_id, x_coord, y_coord, z_coord, h_coord);
  7055. }
  7056. else
  7057. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify spawn zoneto spawn_id - sets spawn_id to your coords");
  7058. }
  7059. }
  7060. else
  7061. Command_Modify(client);
  7062. }
  7063. /*
  7064. Function: Command_ModifyCharacter()
  7065. Purpose : to replace our other "set" commands
  7066. Params : Action : Add, Remove
  7067. : Field : copper, silver, gold, plat
  7068. : Value : min 1, max unlimited
  7069. : Target : Self, Player
  7070. Dev : Cynnar
  7071. Example : /modify character add gold 50
  7072. : /modify character remove silver 25
  7073. */
  7074. void Commands::Command_ModifyCharacter(Client* client, Seperator* sep)
  7075. {
  7076. PrintSep(sep, "COMMAND_MODIFY");
  7077. int64 value = 0;
  7078. Player* player = client->GetPlayer();
  7079. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  7080. player = (Player*)player->GetTarget();
  7081. // need at least 2 args for a valid command
  7082. if( sep && sep->arg[1] )
  7083. {
  7084. if (strcmp(sep->arg[0], "add") == 0)
  7085. {
  7086. if (strcmp(sep->arg[1], "copper") == 0)
  7087. {
  7088. value = atoi64(sep->arg[2]);
  7089. player->AddCoins(value);
  7090. if (client->GetPlayer() == player)
  7091. {
  7092. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu copper coin%s", value, (value > 1 ? "s" : ""));
  7093. }
  7094. else {
  7095. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu copper coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  7096. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu copper coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  7097. }
  7098. }
  7099. else if (strcmp(sep->arg[1], "silver") == 0)
  7100. {
  7101. value = atoi64(sep->arg[2]) * 100;
  7102. player->AddCoins(value);
  7103. if (client->GetPlayer() == player)
  7104. {
  7105. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu silver coin%s", value / 100, (value > 1 ? "s" : ""));
  7106. }
  7107. else {
  7108. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu silver coin%s", player->GetName(), value / 100, (value > 1 ? "s" : ""));
  7109. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu silver coin%s", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  7110. }
  7111. }
  7112. else if (strcmp(sep->arg[1], "gold") == 0)
  7113. {
  7114. value = atoi64(sep->arg[2]) * 10000;
  7115. player->AddCoins(value);
  7116. if (client->GetPlayer() == player)
  7117. {
  7118. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu gold coin%s", value / 10000, (value > 1 ? "s" : ""));
  7119. }
  7120. else {
  7121. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu gold coin%s", player->GetName(), value / 10000, (value > 1 ? "s" : ""));
  7122. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu gold coin%s", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  7123. }
  7124. }
  7125. else if (strcmp(sep->arg[1], "plat") == 0)
  7126. {
  7127. value = atoi64(sep->arg[2]) * 1000000;
  7128. player->AddCoins(value);
  7129. if (client->GetPlayer() == player)
  7130. {
  7131. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu platinum coin%s", value / 1000000, (value > 1 ? "s" : ""));
  7132. }
  7133. else {
  7134. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu platinum coin%s", player->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  7135. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu platinum coin%s", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  7136. }
  7137. }
  7138. else
  7139. {
  7140. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  7141. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  7142. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  7143. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character add copper 20");
  7144. }
  7145. }
  7146. else if (strcmp(sep->arg[0], "remove") == 0)
  7147. {
  7148. if (strcmp(sep->arg[1], "copper") == 0)
  7149. {
  7150. value = atoi64(sep->arg[2]);
  7151. player->RemoveCoins(value);
  7152. if (client->GetPlayer() == player)
  7153. {
  7154. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from yourself", value, (value > 1 ? "s" : ""));
  7155. }
  7156. else {
  7157. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from %s", value, (value > 1 ? "s" : ""), player->GetName());
  7158. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu copper coin%s from you", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  7159. }
  7160. }
  7161. else if (strcmp(sep->arg[1], "silver") == 0)
  7162. {
  7163. value = atoi64(sep->arg[2]) * 100;
  7164. player->RemoveCoins(value);
  7165. if (client->GetPlayer() == player)
  7166. {
  7167. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from yourself", value / 100, (value > 1 ? "s" : ""));
  7168. }
  7169. else {
  7170. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from %s", value / 100, (value > 1 ? "s" : ""), player->GetName());
  7171. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu silver coin%s from you", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  7172. }
  7173. }
  7174. else if (strcmp(sep->arg[1], "gold") == 0)
  7175. {
  7176. value = atoi64(sep->arg[2]) * 10000;
  7177. player->RemoveCoins(value);
  7178. if (client->GetPlayer() == player)
  7179. {
  7180. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from yourself", value / 10000, (value > 1 ? "s" : ""));
  7181. }
  7182. else {
  7183. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from %s", value / 10000, (value > 1 ? "s" : ""), player->GetName());
  7184. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu gold coin%s from you", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  7185. }
  7186. }
  7187. else if (strcmp(sep->arg[1], "plat") == 0)
  7188. {
  7189. value = atoi64(sep->arg[2]) * 1000000;
  7190. player->RemoveCoins(value);
  7191. if (client->GetPlayer() == player)
  7192. {
  7193. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from yourself", value / 1000000, (value > 1 ? "s" : ""));
  7194. }
  7195. else {
  7196. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from %s", value / 1000000, (value > 1 ? "s" : ""), player->GetName());
  7197. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu platinum coin%s from you", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  7198. }
  7199. }
  7200. else
  7201. {
  7202. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  7203. }
  7204. }
  7205. else if (strcmp(sep->arg[0], "set") == 0) {
  7206. if (strcmp(sep->arg[1], "tslevel") == 0) {
  7207. int8 level = atoi(sep->arg[2]);
  7208. if (level > 0 && level < 256) {
  7209. if (player) {
  7210. if (client->GetPlayer() == player)
  7211. client->ChangeTSLevel(player->GetTSLevel(), level);
  7212. else
  7213. player->GetZone()->GetClientBySpawn(player)->ChangeTSLevel(player->GetTSLevel(), level);
  7214. }
  7215. }
  7216. else
  7217. client->SimpleMessage(CHANNEL_ERROR, "Level must be between 1 - 255");
  7218. }
  7219. else if (strcmp(sep->arg[1], "tsclass") == 0) {
  7220. int8 tsclass = atoi(sep->arg[2]);
  7221. player->SetTradeskillClass(tsclass);
  7222. player->GetInfoStruct()->set_tradeskill_class1(classes.GetTSBaseClass(player->GetTradeskillClass()));
  7223. player->GetInfoStruct()->set_tradeskill_class2(classes.GetSecondaryTSBaseClass(player->GetTradeskillClass()));
  7224. player->GetInfoStruct()->set_tradeskill_class3(player->GetTradeskillClass());
  7225. player->SetCharSheetChanged(true);
  7226. }
  7227. else if (strcmp(sep->arg[1], "gender") == 0) {
  7228. int8 gender = atoi(sep->arg[2]);
  7229. client->GetPlayer()->GetInfoStruct()->set_gender(gender);
  7230. client->GetPlayer()->SetCharSheetChanged(true);
  7231. client->UpdateTimeStampFlag ( GENDER_UPDATE_FLAG );
  7232. }
  7233. }
  7234. }
  7235. else
  7236. {
  7237. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  7238. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  7239. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  7240. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  7241. }
  7242. }
  7243. void Commands::Command_ModifyFaction(Client* client, Seperator* sep)
  7244. {
  7245. PrintSep(sep, "COMMAND_MODIFY");
  7246. // need at least 2 args for a valid command
  7247. if( sep && sep->arg[1] )
  7248. {
  7249. }
  7250. else
  7251. Command_Modify(client);
  7252. }
  7253. void Commands::Command_ModifyGuild(Client* client, Seperator* sep)
  7254. {
  7255. PrintSep(sep, "COMMAND_MODIFY");
  7256. // need at least 2 args for a valid command
  7257. if( sep && sep->arg[1] )
  7258. {
  7259. }
  7260. else
  7261. Command_Modify(client);
  7262. }
  7263. void Commands::Command_ModifyItem(Client* client, Seperator* sep)
  7264. {
  7265. PrintSep(sep, "COMMAND_MODIFY");
  7266. // need at least 2 args for a valid command
  7267. if( sep && sep->arg[1] )
  7268. {
  7269. }
  7270. else
  7271. Command_Modify(client);
  7272. }
  7273. /*
  7274. Function: Command_ModifyQuest()
  7275. Purpose : to list players quest and completed quests
  7276. Params : Action : list, completed
  7277. : Target : Self, Player
  7278. Dev : Cynnar
  7279. Example : /modify quest list
  7280. : /modify quest completed
  7281. */
  7282. void Commands::Command_ModifyQuest(Client* client, Seperator* sep)
  7283. {
  7284. PrintSep(sep, "COMMAND_MODIFY");
  7285. int64 value = 0;
  7286. Player* player = client->GetPlayer();
  7287. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  7288. player = (Player*)player->GetTarget();
  7289. // need at least 2 args for a valid command
  7290. if (sep && sep->arg[1])
  7291. {
  7292. if (strcmp(sep->arg[0], "list") == 0)
  7293. {
  7294. map<int32, Quest*>* quests = player->GetPlayerQuests();
  7295. map<int32, Quest*>::iterator itr;
  7296. client->Message(CHANNEL_COLOR_YELLOW, "%s's Quest List:.", client->GetPlayer()->GetName());
  7297. if (quests->size() == 0)
  7298. client->Message(CHANNEL_COLOR_YELLOW, "%s has no quests.", client->GetPlayer()->GetName());
  7299. else
  7300. {
  7301. for (itr = quests->begin(); itr != quests->end(); itr++)
  7302. {
  7303. Quest* quest = itr->second;
  7304. if(quest) {
  7305. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  7306. }
  7307. }
  7308. }
  7309. }
  7310. else if (strcmp(sep->arg[0], "completed") == 0)
  7311. {
  7312. map<int32, Quest*>* quests = player->GetCompletedPlayerQuests();
  7313. map<int32, Quest*>::iterator itr;
  7314. client->Message(CHANNEL_COLOR_YELLOW, "%s's Completed Quest List:.", client->GetPlayer()->GetName());
  7315. if (quests->size() == 0)
  7316. client->Message(CHANNEL_COLOR_YELLOW, "%s has no completed quests.", client->GetPlayer()->GetName());
  7317. else
  7318. {
  7319. for (itr = quests->begin(); itr != quests->end(); itr++)
  7320. {
  7321. Quest* quest = itr->second;
  7322. if(quest) {
  7323. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  7324. }
  7325. }
  7326. }
  7327. }
  7328. // Add in a progress step, and a LogWrite() for tracking GM Commands.
  7329. // LogWrite(LUA__DEBUG, 0, "LUA", "Quest: %s, function: %s", quest->GetName(), function);
  7330. else if (strcmp(sep->arg[0], "remove") == 0)
  7331. {
  7332. int32 quest_id = 0;
  7333. if (sep && sep->arg[1] && sep->IsNumber(1))
  7334. quest_id = atoul(sep->arg[1]);
  7335. if (quest_id > 0)
  7336. {
  7337. if (lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0)
  7338. {
  7339. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  7340. if (quest)
  7341. if (client->GetPlayer() == player)
  7342. {
  7343. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been removed from your journal", quest->GetName());
  7344. }
  7345. else
  7346. {
  7347. client->Message(CHANNEL_COLOR_YELLOW, "You have removed the quest %s from %s's journal", quest->GetName(), player->GetName());
  7348. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s has removed the quest %s from your journal", client->GetPlayer()->GetName(), quest->GetName());
  7349. }
  7350. LogWrite(COMMAND__INFO, 0, "GM Command", "%s removed the quest %s from %s", client->GetPlayer()->GetName(), quest->GetName(), player->GetName());
  7351. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  7352. }
  7353. client->RemovePlayerQuest(quest_id);
  7354. client->GetCurrentZone()->SendQuestUpdates(client);
  7355. }
  7356. }
  7357. else if (strcmp(sep->arg[0], "advance") == 0)
  7358. {
  7359. int32 quest_id = 0;
  7360. int32 step = 0;
  7361. if (sep && sep->arg[1] && sep->IsNumber(1))
  7362. {
  7363. quest_id = atoul(sep->arg[1]);
  7364. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  7365. if(!quest) {
  7366. client->Message(CHANNEL_COLOR_RED, "Quest not found!");
  7367. return;
  7368. }
  7369. if (sep && sep->arg[2] && sep->IsNumber(1))
  7370. {
  7371. step = atoul(sep->arg[2]);
  7372. if (quest_id > 0 && step > 0)
  7373. {
  7374. if (player && player->IsPlayer() && quest_id > 0 && step > 0 && (player->player_quests.count(quest_id) > 0))
  7375. {
  7376. if (client)
  7377. {
  7378. client->AddPendingQuestUpdate(quest_id, step);
  7379. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been advanced one step.", quest->GetName());
  7380. LogWrite(COMMAND__INFO, 0, "GM Command", "%s advanced the quest %s one step", client->GetPlayer()->GetName(), quest->GetName());
  7381. }
  7382. }
  7383. }
  7384. else
  7385. {
  7386. client->Message(CHANNEL_COLOR_RED, "Quest ID and Step Number must be greater than 0!");
  7387. }
  7388. }
  7389. else
  7390. {
  7391. client->Message(CHANNEL_COLOR_RED, "Step Number must be a number!");
  7392. }
  7393. }
  7394. else
  7395. {
  7396. client->Message(CHANNEL_COLOR_RED, "Quest ID must be a number!");
  7397. }
  7398. }
  7399. else
  7400. {
  7401. Command_Modify(client);
  7402. }
  7403. }
  7404. else
  7405. {
  7406. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify quest [action] [quest id] [step number]");
  7407. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: list, completed, remove, advance");
  7408. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest list");
  7409. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest remove 156");
  7410. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest advance 50 1");
  7411. }
  7412. }
  7413. void Commands::Command_ModifySkill(Client* client, Seperator* sep)
  7414. {
  7415. PrintSep(sep, "COMMAND_MODIFY");
  7416. // need at least 2 args for a valid command
  7417. if( sep && sep->arg[1] )
  7418. {
  7419. if (strcmp(sep->arg[0], "add") == 0) {
  7420. const char* skill_name = sep->argplus[1];
  7421. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  7422. if (skill) {
  7423. Player* player = 0;
  7424. Client* to_client = 0;
  7425. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  7426. player = (Player*)client->GetPlayer()->GetTarget();
  7427. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  7428. }
  7429. else {
  7430. player = client->GetPlayer();
  7431. to_client = client;
  7432. }
  7433. if (player)
  7434. {
  7435. if (!player->GetSkills()->HasSkill(skill->skill_id))
  7436. {
  7437. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  7438. if (to_client == client) {
  7439. client->Message(CHANNEL_STATUS, "Added skill '%s'.", skill_name);
  7440. }
  7441. else {
  7442. client->Message(CHANNEL_STATUS, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  7443. to_client->Message(CHANNEL_STATUS, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  7444. }
  7445. }
  7446. else
  7447. client->Message(CHANNEL_STATUS, "%s already has the skill '%s'.", to_client == client ? "You" : player->GetName(), skill_name);
  7448. }
  7449. }
  7450. else
  7451. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  7452. }
  7453. else if (strcmp(sep->arg[0], "remove") == 0) {
  7454. const char* skill_name = sep->argplus[1];
  7455. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  7456. if (skill) {
  7457. Player* player = 0;
  7458. Client* to_client = 0;
  7459. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  7460. player = (Player*)client->GetPlayer()->GetTarget();
  7461. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  7462. }
  7463. else {
  7464. player = client->GetPlayer();
  7465. to_client = client;
  7466. }
  7467. if (player)
  7468. {
  7469. if (player->GetSkills()->HasSkill(skill->skill_id))
  7470. {
  7471. player->RemoveSkillFromDB(skill, true);
  7472. if (client == to_client) {
  7473. client->Message(CHANNEL_STATUS, "Removed skill '%s'.", skill_name);
  7474. }
  7475. else {
  7476. client->Message(CHANNEL_STATUS, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  7477. to_client->Message(CHANNEL_STATUS, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  7478. }
  7479. }
  7480. else {
  7481. if (client == to_client)
  7482. client->Message(CHANNEL_STATUS, "You do not have the skill '%s'.", skill_name);
  7483. else
  7484. client->Message(CHANNEL_STATUS, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  7485. }
  7486. }
  7487. }
  7488. else
  7489. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  7490. }
  7491. else if (strcmp(sep->arg[0], "set") == 0) {
  7492. if (!sep->IsNumber(2)) {
  7493. client->Message(CHANNEL_STATUS, "The last parameter must be a number.");
  7494. return;
  7495. }
  7496. const char* skill_name = sep->arg[1];
  7497. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  7498. if (skill) {
  7499. int16 val = atoi(sep->arg[2]);
  7500. Player* player = 0;
  7501. Client* to_client = 0;
  7502. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  7503. player = (Player*)client->GetPlayer()->GetTarget();
  7504. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  7505. }
  7506. else {
  7507. player = client->GetPlayer();
  7508. to_client = client;
  7509. }
  7510. if (player)
  7511. {
  7512. if (player->GetSkills()->HasSkill(skill->skill_id)) {
  7513. player->GetSkills()->SetSkill(skill->skill_id, val);
  7514. if (client != to_client)
  7515. client->Message(CHANNEL_STATUS, "You set %s's '%s' skill to %i.", player->GetName(), skill_name, val);
  7516. to_client->Message(CHANNEL_STATUS, "Your '%s' skill has been set to %i.", skill_name, val);
  7517. }
  7518. else {
  7519. client->Message(CHANNEL_STATUS, "Target does not have the skill '%s'.", skill_name);
  7520. }
  7521. }
  7522. }
  7523. else {
  7524. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  7525. }
  7526. }
  7527. else {
  7528. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  7529. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  7530. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  7531. }
  7532. }
  7533. else {
  7534. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  7535. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  7536. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  7537. }
  7538. }
  7539. void Commands::Command_ModifySpell(Client* client, Seperator* sep)
  7540. {
  7541. PrintSep(sep, "COMMAND_MODIFY");
  7542. // need at least 2 args for a valid command
  7543. if( sep && sep->arg[1] )
  7544. {
  7545. }
  7546. else
  7547. Command_Modify(client);
  7548. }
  7549. void Commands::Command_ModifyZone(Client* client, Seperator* sep)
  7550. {
  7551. PrintSep(sep, "COMMAND_MODIFY");
  7552. // need at least 2 args for a valid command
  7553. if( sep && sep->arg[1] )
  7554. {
  7555. }
  7556. else
  7557. Command_Modify(client);
  7558. }
  7559. /*
  7560. Function: Command_MOTD()
  7561. Purpose : Displays server MOTD
  7562. Params :
  7563. Dev : LethalEncounter
  7564. Example : /motd
  7565. */
  7566. void Commands::Command_MOTD(Client* client)
  7567. {
  7568. if (client)
  7569. ClientPacketFunctions::SendMOTD(client);
  7570. }
  7571. /*
  7572. Function: Command_Pet()
  7573. Purpose : Handle Pet {Command} commands
  7574. Params : attack, backoff, preserve_master, preserve_self, follow, stay, getlost
  7575. Dev :
  7576. Example : /pet preserve_master
  7577. */
  7578. void Commands::Command_Pet(Client* client, Seperator* sep)
  7579. {
  7580. PrintSep(sep, "COMMAND_PET");
  7581. //LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Pet Commands");
  7582. //client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7583. if (!sep || !sep->arg[0])
  7584. return; // should have sep->arg[0] filled
  7585. if (strcmp(sep->arg[0], "hide") == 0) {
  7586. // doing /pet hide will toggle the hide status on all the pets that can be hidden
  7587. Entity* pet = client->GetPlayer()->GetDeityPet();
  7588. if (pet) {
  7589. if (pet->IsPrivateSpawn())
  7590. client->GetPlayer()->HideDeityPet(false);
  7591. else
  7592. client->GetPlayer()->HideDeityPet(true);
  7593. }
  7594. pet = client->GetPlayer()->GetCosmeticPet();
  7595. if (pet) {
  7596. if (pet->IsPrivateSpawn())
  7597. client->GetPlayer()->HideCosmeticPet(false);
  7598. else
  7599. client->GetPlayer()->HideCosmeticPet(true);
  7600. }
  7601. return;
  7602. }
  7603. // below is for all combat pets
  7604. if (!client->GetPlayer()->HasPet()) {
  7605. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a pet.");
  7606. return;
  7607. }
  7608. if (strcmp(sep->arg[0], "stay") == 0) {
  7609. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to stay.");
  7610. client->GetPlayer()->GetInfoStruct()->set_pet_movement(1);
  7611. client->GetPlayer()->SetCharSheetChanged(true);
  7612. if (client->GetPlayer()->GetPet())
  7613. client->GetPlayer()->GetPet()->following = false;
  7614. if (client->GetPlayer()->GetCharmedPet())
  7615. client->GetPlayer()->GetCharmedPet()->following = false;
  7616. }
  7617. else if (strcmp(sep->arg[0], "follow") == 0) {
  7618. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to follow.");
  7619. client->GetPlayer()->GetInfoStruct()->set_pet_movement(2);
  7620. client->GetPlayer()->SetCharSheetChanged(true);
  7621. }
  7622. else if (strcmp(sep->arg[0], "preserve_master") == 0) {
  7623. if (client->GetPlayer()->GetInfoStruct()->get_pet_behavior() & 1) {
  7624. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect you.");
  7625. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()-1);
  7626. }
  7627. else {
  7628. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect you.");
  7629. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()+1);
  7630. }
  7631. client->GetPlayer()->SetCharSheetChanged(true);
  7632. }
  7633. else if (strcmp(sep->arg[0], "preserve_self") == 0) {
  7634. if (client->GetPlayer()->GetInfoStruct()->get_pet_behavior() & 2) {
  7635. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect itself.");
  7636. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()-2);
  7637. }
  7638. else {
  7639. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect itself.");
  7640. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()+2);
  7641. }
  7642. client->GetPlayer()->SetCharSheetChanged(true);
  7643. }
  7644. else if (strcmp(sep->arg[0], "backoff") == 0) {
  7645. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to back down.");
  7646. if (client->GetPlayer()->GetPet())
  7647. ((NPC*)client->GetPlayer()->GetPet())->Brain()->ClearHate();
  7648. if (client->GetPlayer()->GetCharmedPet())
  7649. ((NPC*)client->GetPlayer()->GetCharmedPet())->Brain()->ClearHate();
  7650. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(0);
  7651. client->GetPlayer()->SetCharSheetChanged(true);
  7652. }
  7653. else if (strcmp(sep->arg[0], "attack") == 0) {
  7654. if (client->GetPlayer()->HasTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  7655. if (client->GetPlayer()->AttackAllowed((Entity*)client->GetPlayer()->GetTarget())){
  7656. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to attack your target.");
  7657. if (client->GetPlayer()->GetPet())
  7658. client->GetPlayer()->GetPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  7659. if (client->GetPlayer()->GetCharmedPet())
  7660. client->GetPlayer()->GetCharmedPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  7661. }
  7662. else
  7663. client->Message(CHANNEL_COLOR_YELLOW, "You can not attack that.");
  7664. }
  7665. else
  7666. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a target.");
  7667. }
  7668. else if (strcmp(sep->arg[0], "getlost") == 0) {
  7669. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetPet());
  7670. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetCharmedPet());
  7671. client->Message(CHANNEL_COLOR_YELLOW, "You tell your pet to get lost.");
  7672. }
  7673. else
  7674. client->Message(CHANNEL_COLOR_YELLOW, "Unknown pet command.");
  7675. }
  7676. /*
  7677. Function: Command_PetName()
  7678. Purpose : Pet your name (???)
  7679. Params :
  7680. Dev :
  7681. Example :
  7682. */
  7683. void Commands::Command_PetName(Client* client, Seperator* sep)
  7684. {
  7685. if (sep && sep->arg[0]) {
  7686. const char* pet_name = sep->argplus[0];
  7687. client->SetPetName(pet_name);
  7688. }
  7689. else {
  7690. client->GetPlayer()->GetInfoStruct()->set_pet_name("");
  7691. }
  7692. }
  7693. /*
  7694. Function: Command_NamePet()
  7695. Purpose : Name your pet
  7696. Params :
  7697. Dev :
  7698. Example :
  7699. */
  7700. void Commands::Command_NamePet(Client* client, Seperator* sep)
  7701. {
  7702. PrintSep(sep, "COMMAND_NAME_PET");
  7703. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Name Pet Command");
  7704. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7705. }
  7706. /*
  7707. Function: Command_Rename()
  7708. Purpose : Renames existing pet
  7709. Params :
  7710. Dev :
  7711. Example :
  7712. */
  7713. void Commands::Command_Rename(Client* client, Seperator* sep)
  7714. {
  7715. PrintSep(sep, "COMMAND_RENAME");
  7716. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Rename Pet Command");
  7717. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7718. }
  7719. /*
  7720. Function: Command_ConfirmRename()
  7721. Purpose : Confirms renaming your pet
  7722. Params :
  7723. Dev :
  7724. Example :
  7725. */
  7726. void Commands::Command_ConfirmRename(Client* client, Seperator* sep)
  7727. {
  7728. PrintSep(sep, "COMMAND_CONFIRMRENAME");
  7729. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Confirm Rename Pet Command");
  7730. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7731. }
  7732. /*
  7733. Function: Command_PetOptions()
  7734. Purpose : Sets various pet options
  7735. Params :
  7736. Dev :
  7737. Example :
  7738. */
  7739. void Commands::Command_PetOptions(Client* client, Seperator* sep)
  7740. {
  7741. PrintSep(sep, "COMMAND_PETOPTIONS");
  7742. Player* player = client->GetPlayer();
  7743. Spawn* target = player->GetTarget();
  7744. if (!target)
  7745. return;
  7746. if (target == player->GetPet())
  7747. client->SendPetOptionsWindow(player->GetPet()->GetName());
  7748. else if (target == player->GetCharmedPet())
  7749. client->SendPetOptionsWindow(player->GetCharmedPet()->GetName());
  7750. else if (target == player->GetCosmeticPet())
  7751. client->SendPetOptionsWindow(player->GetCosmeticPet()->GetName(), 0);
  7752. else if (target == player->GetDeityPet())
  7753. client->SendPetOptionsWindow(player->GetDeityPet()->GetName(), 0);
  7754. }
  7755. /*
  7756. Function: Command_Random()
  7757. Purpose : Handles /random dice roll in-game
  7758. Params : 1-100
  7759. Dev : Scatman
  7760. Example : /randon 1 100
  7761. */
  7762. void Commands::Command_Random(Client* client, Seperator* sep)
  7763. {
  7764. char message[256] = {0};
  7765. if (sep)
  7766. {
  7767. if (sep->GetArgNumber() == 0 && sep->IsNumber(0))
  7768. 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])));
  7769. else if (sep->GetArgNumber() > 0 && sep->IsNumber(0) && sep->IsNumber(1))
  7770. 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])));
  7771. else
  7772. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  7773. }
  7774. else
  7775. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  7776. client->GetPlayer()->GetZone()->HandleChatMessage(0, 0, CHANNEL_EMOTE, message);
  7777. }
  7778. /*
  7779. Function: Command_Randomize()
  7780. Purpose : Sets randomize (appearance) values for NPCs
  7781. Params : Attrib Name
  7782. Dev : Scatman
  7783. Example : /randomize gender 1 -- will randomize the NPCs gender (male/female)
  7784. */
  7785. void Commands::Command_Randomize(Client* client, Seperator* sep)
  7786. {
  7787. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  7788. if (target)
  7789. {
  7790. if (target->IsNPC())
  7791. {
  7792. if (sep && sep->arg[0] && !sep->IsNumber(0))
  7793. {
  7794. const char* value = sep->arg[0];
  7795. if (strncasecmp(value, "show", strlen(value)) == 0)
  7796. {
  7797. client->DisplayRandomizeFeatures(target->GetRandomize());
  7798. }
  7799. else
  7800. {
  7801. if (sep->arg[1] && sep->IsNumber(1))
  7802. {
  7803. int8 option = atoi(sep->arg[1]);
  7804. if (option == 0 || option == 1)
  7805. {
  7806. int32 feature = 0;
  7807. char feature_text[32] = {0};
  7808. if (strncasecmp(value, "gender", strlen(value)) == 0) {
  7809. feature = RANDOMIZE_GENDER;
  7810. strncpy(feature_text, "gender", sizeof(feature_text) - 1);
  7811. }
  7812. else if (strncasecmp(value, "race", strlen(value)) == 0) {
  7813. feature = RANDOMIZE_RACE;
  7814. strncpy(feature_text, "race", sizeof(feature_text) - 1);
  7815. }
  7816. else if (strncasecmp(value, "model", strlen(value)) == 0) {
  7817. feature = RANDOMIZE_MODEL_TYPE;
  7818. strncpy(feature_text, "model", sizeof(feature_text) - 1);
  7819. }
  7820. else if (strncasecmp(value, "facial_hair", strlen(value)) == 0) {
  7821. feature = RANDOMIZE_FACIAL_HAIR_TYPE;
  7822. strncpy(feature_text, "facial hair", sizeof(feature_text) - 1);
  7823. }
  7824. else if (strncasecmp(value, "hair", strlen(value)) == 0) {
  7825. feature = RANDOMIZE_HAIR_TYPE;
  7826. strncpy(feature_text, "hair", sizeof(feature_text) - 1);
  7827. }
  7828. else if (strncasecmp(value, "wing", strlen(value)) == 0) {
  7829. feature = RANDOMIZE_WING_TYPE;
  7830. strncpy(feature_text, "wings", sizeof(feature_text) - 1);
  7831. }
  7832. else if (strncasecmp(value, "cheek", strlen(value)) == 0) {
  7833. feature = RANDOMIZE_CHEEK_TYPE;
  7834. strncpy(feature_text, "cheeks", sizeof(feature_text) - 1);
  7835. }
  7836. else if (strncasecmp(value, "chin", strlen(value)) == 0) {
  7837. feature = RANDOMIZE_CHIN_TYPE;
  7838. strncpy(feature_text, "chin", sizeof(feature_text) - 1);
  7839. }
  7840. else if (strncasecmp(value, "ear", strlen(value)) == 0) {
  7841. feature = RANDOMIZE_EAR_TYPE;
  7842. strncpy(feature_text, "ears", sizeof(feature_text) - 1);
  7843. }
  7844. else if (strncasecmp(value, "eye_brow", strlen(value)) == 0) {
  7845. feature = RANDOMIZE_EYE_BROW_TYPE;
  7846. strncpy(feature_text, "eye brows", sizeof(feature_text) - 1);
  7847. }
  7848. else if (strncasecmp(value, "eye", strlen(value)) == 0) {
  7849. feature = RANDOMIZE_EYE_TYPE;
  7850. strncpy(feature_text, "eyes", sizeof(feature_text) - 1);
  7851. }
  7852. else if (strncasecmp(value, "lip", strlen(value)) == 0) {
  7853. feature = RANDOMIZE_LIP_TYPE;
  7854. strncpy(feature_text, "lips", sizeof(feature_text) - 1);
  7855. }
  7856. else if (strncasecmp(value, "nose", strlen(value)) == 0) {
  7857. feature = RANDOMIZE_NOSE_TYPE;
  7858. strncpy(feature_text, "nose", sizeof(feature_text) - 1);
  7859. }
  7860. else if (strncasecmp(value, "eye_color", strlen(value)) == 0) {
  7861. feature = RANDOMIZE_EYE_COLOR;
  7862. strncpy(feature_text, "eye color", sizeof(feature_text) - 1);
  7863. }
  7864. else if (strncasecmp(value, "hair_color", strlen(value)) == 0) {
  7865. feature = RANDOMIZE_HAIR_TYPE_COLOR;
  7866. strncpy(feature_text, "hair color", sizeof(feature_text) - 1);
  7867. }
  7868. else if (strncasecmp(value, "hair_color1", strlen(value)) == 0) {
  7869. feature = RANDOMIZE_HAIR_COLOR1;
  7870. strncpy(feature_text, "hair color1", sizeof(feature_text) - 1);
  7871. }
  7872. else if (strncasecmp(value, "hair_color2", strlen(value)) == 0) {
  7873. feature = RANDOMIZE_HAIR_COLOR2;
  7874. strncpy(feature_text, "hair color2", sizeof(feature_text) - 1);
  7875. }
  7876. else if (strncasecmp(value, "hair_highlight", strlen(value)) == 0) {
  7877. feature = RANDOMIZE_HAIR_HIGHLIGHT;
  7878. strncpy(feature_text, "hair highlights", sizeof(feature_text) - 1);
  7879. }
  7880. else if (strncasecmp(value, "facial_hair_color", strlen(value)) == 0) {
  7881. feature = RANDOMIZE_HAIR_FACE_COLOR;
  7882. strncpy(feature_text, "facial hair color", sizeof(feature_text) - 1);
  7883. }
  7884. else if (strncasecmp(value, "facial_hair_color_highlight", strlen(value)) == 0) {
  7885. feature = RANDOMIZE_HAIR_FACE_HIGHLIGHT_COLOR;
  7886. strncpy(feature_text, "facial hair color highlights", sizeof(feature_text) - 1);
  7887. }
  7888. else if (strncasecmp(value, "hair_color_highlight", strlen(value)) == 0) {
  7889. feature = RANDOMIZE_HAIR_TYPE_HIGHLIGHT_COLOR;
  7890. strncpy(feature_text, "hair color highlights", sizeof(feature_text) - 1);
  7891. }
  7892. else if (strncasecmp(value, "skin_color", strlen(value)) == 0) {
  7893. feature = RANDOMIZE_SKIN_COLOR;
  7894. strncpy(feature_text, "skin color", sizeof(feature_text) - 1);
  7895. }
  7896. else if (strncasecmp(value, "wing_color1", strlen(value)) == 0) {
  7897. feature = RANDOMIZE_WING_COLOR1;
  7898. strncpy(feature_text, "wing color1", sizeof(feature_text) - 1);
  7899. }
  7900. else if (strncasecmp(value, "wing_color2", strlen(value)) == 0) {
  7901. feature = RANDOMIZE_WING_COLOR2;
  7902. strncpy(feature_text, "wing color2", sizeof(feature_text) - 1);
  7903. }
  7904. else {
  7905. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is not a valid feature to randomize.", value);
  7906. 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'.");
  7907. }
  7908. if (feature > 0) {
  7909. if (option == 1) {
  7910. if (target->GetRandomize() & feature)
  7911. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is already set to randomly generate their %s.", target->GetName(), feature_text);
  7912. else {
  7913. target->AddRandomize(feature);
  7914. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(feature);
  7915. database.UpdateRandomize(target->GetDatabaseID(), feature);
  7916. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will now generate their %s randomly.", target->GetName(), feature_text);
  7917. }
  7918. }
  7919. else {
  7920. if (target->GetRandomize() & feature) {
  7921. target->AddRandomize(-feature);
  7922. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(-feature);
  7923. database.UpdateRandomize(target->GetDatabaseID(), -feature);
  7924. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will no longer generate their %s randomly.", target->GetName(), feature_text);
  7925. }
  7926. else
  7927. client->Message(CHANNEL_COLOR_YELLOW, "'%s' already does not randomly generate their %s.", target->GetName(), feature_text);
  7928. }
  7929. }
  7930. }
  7931. else
  7932. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  7933. }
  7934. else
  7935. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  7936. }
  7937. }
  7938. else {
  7939. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /randomize [show | [feature [1|0]]");
  7940. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "'show' will display current configured features");
  7941. 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'.");
  7942. }
  7943. }
  7944. else
  7945. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "The target you wish to randomize must be an NPC.");
  7946. }
  7947. else
  7948. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select the target you wish to randomize.");
  7949. }
  7950. /*
  7951. Function: Command_ShowCloak()
  7952. Purpose : Character Settings combo box for Show Cloak
  7953. Params : true/false
  7954. Dev : John Adams
  7955. Example :
  7956. */
  7957. void Commands::Command_ShowCloak(Client* client, Seperator* sep)
  7958. {
  7959. Player* player = client->GetPlayer();
  7960. if (sep && sep->arg[0])
  7961. {
  7962. const char* value = sep->arg[0];
  7963. if (strncasecmp(value, "true", strlen(value)) == 0)
  7964. {
  7965. player->set_character_flag(CF_SHOW_CLOAK);
  7966. player->reset_character_flag(CF2_SHOW_RANGED);
  7967. }
  7968. else if (strncasecmp(value, "false", strlen(value)) == 0)
  7969. player->reset_character_flag(CF_SHOW_CLOAK);
  7970. else
  7971. {
  7972. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7973. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7974. }
  7975. }
  7976. }
  7977. /*
  7978. Function: Command_ShowHelm()
  7979. Purpose : Character Settings combo box for Show Helm
  7980. Params : true/false
  7981. Dev : John Adams
  7982. Example :
  7983. */
  7984. void Commands::Command_ShowHelm(Client* client, Seperator* sep)
  7985. {
  7986. Player* player = client->GetPlayer();
  7987. if(client->GetVersion() <= 546) {
  7988. return; // not allowed/supported
  7989. }
  7990. if (sep && sep->arg[0])
  7991. {
  7992. PrintSep(sep, "Command_ShowHelm");
  7993. const char* value = sep->arg[0];
  7994. if (strncasecmp(value, "true", strlen(value)) == 0)
  7995. {
  7996. player->toggle_character_flag(CF_HIDE_HELM);
  7997. player->toggle_character_flag(CF_HIDE_HOOD);
  7998. }
  7999. else if (strncasecmp(value, "false", strlen(value)) == 0)
  8000. player->toggle_character_flag(CF_HIDE_HELM);
  8001. else
  8002. {
  8003. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8004. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8005. }
  8006. }
  8007. }
  8008. /*
  8009. Function: Command_ShowHood()
  8010. Purpose : Character Settings combo box for Show Hood
  8011. Params : true/false
  8012. Dev : John Adams
  8013. Example :
  8014. */
  8015. void Commands::Command_ShowHood(Client* client, Seperator* sep)
  8016. {
  8017. Player* player = client->GetPlayer();
  8018. if (sep && sep->arg[0])
  8019. {
  8020. PrintSep(sep, "Command_ShowHood");
  8021. const char* value = sep->arg[0];
  8022. if (strncasecmp(value, "true", strlen(value)) == 0)
  8023. {
  8024. player->toggle_character_flag(CF_HIDE_HOOD);
  8025. if(client->GetVersion() > 546) { // no hide helm support in DoF
  8026. player->toggle_character_flag(CF_HIDE_HELM);
  8027. }
  8028. }
  8029. else if (strncasecmp(value, "false", strlen(value)) == 0) {
  8030. player->toggle_character_flag(CF_HIDE_HOOD);
  8031. }
  8032. else
  8033. {
  8034. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8035. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8036. }
  8037. }
  8038. }
  8039. /*
  8040. Function: Command_ShowHoodHelm()
  8041. Purpose : Character Settings combo box for Show Helm or Hood
  8042. Params : true/false
  8043. Dev : John Adams
  8044. Example :
  8045. */
  8046. void Commands::Command_ShowHoodHelm(Client* client, Seperator* sep)
  8047. {
  8048. Player* player = client->GetPlayer();
  8049. if(client->GetVersion() <= 546) {
  8050. return; // not allowed/supported
  8051. }
  8052. if (sep && sep->arg[0])
  8053. {
  8054. PrintSep(sep, "Command_ShowHoodHelm");
  8055. const char* value = sep->arg[0];
  8056. if (strncasecmp(value, "true", strlen(value)) == 0)
  8057. {
  8058. player->toggle_character_flag(CF_HIDE_HOOD);
  8059. player->toggle_character_flag(CF_HIDE_HELM);
  8060. }
  8061. else if (strncasecmp(value, "false", strlen(value)) == 0)
  8062. {
  8063. // don't think we ever wind up in here...
  8064. player->toggle_character_flag(CF_HIDE_HOOD);
  8065. player->toggle_character_flag(CF_HIDE_HELM);
  8066. }
  8067. else
  8068. {
  8069. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8070. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8071. }
  8072. }
  8073. }
  8074. /*
  8075. Function: Command_ShowRanged()
  8076. Purpose : Character Settings combo box for Show Ranged weapon
  8077. Params : true/false
  8078. Dev : John Adams
  8079. Example :
  8080. */
  8081. void Commands::Command_ShowRanged(Client* client, Seperator* sep)
  8082. {
  8083. Player* player = client->GetPlayer();
  8084. if (sep && sep->arg[0])
  8085. {
  8086. const char* value = sep->arg[0];
  8087. if (strncasecmp(value, "true", strlen(value)) == 0)
  8088. {
  8089. player->set_character_flag(CF2_SHOW_RANGED);
  8090. player->reset_character_flag(CF_SHOW_CLOAK);
  8091. }
  8092. else if (strncasecmp(value, "false", strlen(value)) == 0)
  8093. player->reset_character_flag(CF2_SHOW_RANGED);
  8094. else
  8095. {
  8096. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8097. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8098. }
  8099. }
  8100. }
  8101. /*
  8102. Function:
  8103. Purpose :
  8104. Params :
  8105. Dev :
  8106. Example :
  8107. */
  8108. void Commands::Command_Skills(Client* client, Seperator* sep, int handler)
  8109. {
  8110. Player* player = 0;
  8111. Client* to_client = 0;
  8112. if(client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  8113. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  8114. switch(handler)
  8115. {
  8116. case COMMAND_SKILL:
  8117. {
  8118. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill [add|remove|list] [skill name]");
  8119. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to add/remove skills for that player.");
  8120. break;
  8121. }
  8122. case COMMAND_SKILL_ADD:
  8123. {
  8124. if (sep && sep->arg[0])
  8125. {
  8126. const char* skill_name = sep->argplus[0];
  8127. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  8128. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // add skill to your target, if target is not you
  8129. {
  8130. player = to_client->GetPlayer();
  8131. if (player)
  8132. {
  8133. if (!player->GetSkills()->HasSkill(skill->skill_id))
  8134. {
  8135. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  8136. client->Message(CHANNEL_COLOR_YELLOW, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  8137. to_client->Message(CHANNEL_COLOR_YELLOW, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  8138. }
  8139. else
  8140. client->Message(CHANNEL_COLOR_YELLOW, "%s already has the skill '%s'.", player->GetName(), skill_name);
  8141. }
  8142. }
  8143. else if (skill) // add skill to yourself
  8144. {
  8145. player = client->GetPlayer();
  8146. if (player)
  8147. {
  8148. if (!player->GetSkills()->HasSkill(skill->skill_id))
  8149. {
  8150. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  8151. client->Message(CHANNEL_COLOR_YELLOW, "Added skill '%s'.", skill_name);
  8152. }
  8153. else
  8154. client->Message(CHANNEL_COLOR_YELLOW, "You already have the skill '%s'.", skill_name);
  8155. }
  8156. }
  8157. else
  8158. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  8159. }
  8160. else
  8161. {
  8162. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill add [skill name]");
  8163. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  8164. }
  8165. break;
  8166. }
  8167. case COMMAND_SKILL_REMOVE:
  8168. {
  8169. if (sep && sep->arg[0])
  8170. {
  8171. const char* skill_name = sep->argplus[0];
  8172. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  8173. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // remove skill from your target, if target is not you
  8174. {
  8175. player = to_client->GetPlayer();
  8176. if (player)
  8177. {
  8178. if (player->GetSkills()->HasSkill(skill->skill_id))
  8179. {
  8180. player->RemoveSkillFromDB(skill, true);
  8181. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  8182. to_client->Message(CHANNEL_COLOR_YELLOW, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  8183. }
  8184. else
  8185. client->Message(CHANNEL_COLOR_YELLOW, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  8186. }
  8187. }
  8188. else if(skill) // remove skill from yourself
  8189. {
  8190. Player* player = client->GetPlayer();
  8191. if (player)
  8192. {
  8193. if (player->GetSkills()->HasSkill(skill->skill_id))
  8194. {
  8195. player->RemoveSkillFromDB(skill, true);
  8196. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s'.", skill_name);
  8197. }
  8198. else
  8199. client->Message(CHANNEL_COLOR_YELLOW, "You do not have the skill '%s'.", skill_name);
  8200. }
  8201. }
  8202. else
  8203. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  8204. }
  8205. else
  8206. {
  8207. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill remove [skill name]");
  8208. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  8209. }
  8210. break;
  8211. }
  8212. case COMMAND_SKILL_LIST:
  8213. {
  8214. if (sep && sep->arg[0])
  8215. {
  8216. const char* skill_name = sep->argplus[0];
  8217. client->Message(CHANNEL_COLOR_YELLOW, "Listing skills like '%s':", skill_name);
  8218. map<int32, Skill*>* skills = master_skill_list.GetAllSkills();
  8219. map<int32, Skill*>::iterator itr;
  8220. if (skills && skills->size() > 0)
  8221. {
  8222. for (itr = skills->begin(); itr != skills->end(); itr++)
  8223. {
  8224. Skill* skill = itr->second;
  8225. string current_skill_name = ::ToLower(string(skill->name.data.c_str()));
  8226. if (current_skill_name.find(::ToLower(string(skill_name))) < 0xFFFFFFFF)
  8227. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", skill->name.data.c_str(), skill->skill_id);
  8228. }
  8229. }
  8230. }
  8231. else
  8232. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill list [skill name]");
  8233. break;
  8234. }
  8235. }
  8236. }
  8237. /*
  8238. Function: Command_SpawnTemplate()
  8239. Purpose : Create or Use defined Spawn Templates
  8240. Params : create, save, rempve, list
  8241. Dev : John Adams
  8242. Example : /spawn template create "Test"
  8243. */
  8244. void Commands::Command_SpawnTemplate(Client* client, Seperator* sep)
  8245. {
  8246. if (sep == NULL || sep->arg[0] == NULL)
  8247. {
  8248. 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.");
  8249. return;
  8250. }
  8251. // got params, continue
  8252. const char * template_cmd = sep->arg[0];
  8253. if (strncasecmp(template_cmd, "list", strlen(template_cmd)) == 0)
  8254. {
  8255. if (!sep->IsSet(1))
  8256. {
  8257. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /spawn template list [name|location_id]");
  8258. 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.");
  8259. return;
  8260. }
  8261. map<int32, string>* template_names = 0;
  8262. if (sep->IsNumber(1))
  8263. {
  8264. int32 location_id = 0;
  8265. location_id = atoi(sep->arg[1]);
  8266. template_names = database.GetSpawnTemplateListByID(location_id);
  8267. }
  8268. else
  8269. {
  8270. const char* name = 0;
  8271. name = sep->argplus[1];
  8272. template_names = database.GetSpawnTemplateListByName(name);
  8273. }
  8274. if(!template_names)
  8275. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No templates found.");
  8276. else
  8277. {
  8278. map<int32, string>::iterator itr;
  8279. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  8280. for(itr = template_names->begin(); itr != template_names->end(); itr++)
  8281. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  8282. safe_delete(template_names);
  8283. }
  8284. }
  8285. else if (strncasecmp(template_cmd, "save", strlen(template_cmd)) == 0)
  8286. {
  8287. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  8288. if ( target && (target->IsNPC() || target->IsObject() || target->IsSign() || target->IsWidget() || target->IsGroundSpawn()) )
  8289. {
  8290. if (sep && sep->arg[1][0] && !sep->IsNumber(1))
  8291. {
  8292. // first, lookup to see if template name already exists
  8293. const char* name = 0;
  8294. name = sep->argplus[1];
  8295. map<int32, string>* template_names = database.GetSpawnTemplateListByName(name);
  8296. if(!template_names)
  8297. {
  8298. int32 new_template_id = database.SaveSpawnTemplate(target->GetSpawnLocationID(), name);
  8299. if( new_template_id > 0 )
  8300. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template '%s' added for spawn '%s' (%u) as TemplateID: %u", name, target->GetName(), target->GetSpawnLocationID(), new_template_id);
  8301. else
  8302. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' for spawn '%s' (%u).", name, target->GetName(), target->GetSpawnLocationID());
  8303. }
  8304. else
  8305. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' - Already exists!", name);
  8306. }
  8307. else
  8308. client->Message(CHANNEL_COLOR_RED, "ERROR: Saving a new spawn template requires a valid template name!");
  8309. }
  8310. else
  8311. client->Message(CHANNEL_COLOR_RED, "ERROR: You must target the spawn you wish to save as a template!");
  8312. }
  8313. else if (strncasecmp(template_cmd, "remove", strlen(template_cmd)) == 0)
  8314. {
  8315. if (sep && sep->arg[1][0] && sep->IsNumber(1))
  8316. {
  8317. int32 template_id = 0;
  8318. template_id = atoi(sep->arg[1]);
  8319. if (database.RemoveSpawnTemplate(template_id))
  8320. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template ID: %u successfully removed.", template_id);
  8321. else
  8322. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to remove spawn template ID: %u", template_id);
  8323. }
  8324. else
  8325. client->Message(CHANNEL_COLOR_RED, "ERROR: Removing a spawn template requires a valid template ID!");
  8326. }
  8327. // Renamed create to spawn
  8328. else if (strncasecmp(template_cmd, "spawn", strlen(template_cmd)) == 0)
  8329. {
  8330. if (sep && sep->arg[1][0])
  8331. {
  8332. int32 new_location = 0;
  8333. if (sep->IsNumber(1))
  8334. {
  8335. int32 template_id = 0;
  8336. template_id = atoi(sep->arg[1]);
  8337. new_location = database.CreateSpawnFromTemplateByID(client, template_id);
  8338. if( new_location > 0 )
  8339. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template ID: %u", new_location, template_id);
  8340. else
  8341. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template ID: %u", template_id);
  8342. }
  8343. else
  8344. {
  8345. const char* name = 0;
  8346. name = sep->argplus[1];
  8347. new_location = database.CreateSpawnFromTemplateByName(client, name);
  8348. if( new_location > 0 )
  8349. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template: '%s'", new_location, name);
  8350. else
  8351. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template: '%s'", name);
  8352. }
  8353. }
  8354. else
  8355. client->Message(CHANNEL_COLOR_RED, "ERROR: Spawning a new spawn location requires a valid template name or ID!");
  8356. }
  8357. else
  8358. client->Message(CHANNEL_COLOR_RED, "ERROR: Unknown /spawn template command.");
  8359. }
  8360. void Commands::Command_Speed(Client* client, Seperator* sep) {
  8361. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  8362. float new_speed = atof(sep->arg[0]);
  8363. if (new_speed > 0.0f)
  8364. {
  8365. client->GetPlayer()->SetSpeed(new_speed, true);
  8366. client->GetPlayer()->SetCharSheetChanged(true);
  8367. database.insertCharacterProperty(client, CHAR_PROPERTY_SPEED, sep->arg[0]);
  8368. client->Message(CHANNEL_STATUS, "Setting speed to %.2f.", new_speed);
  8369. }
  8370. else
  8371. client->Message(CHANNEL_STATUS, "Invalid speed provided %s.", sep->arg[0]);
  8372. }
  8373. else{
  8374. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /speed {new speed value}");
  8375. }
  8376. }
  8377. /*
  8378. Function: Command_StationMarketPlace()
  8379. Purpose : just trying to eat the console spam for now
  8380. Params :
  8381. Dev : John
  8382. */
  8383. void Commands::Command_StationMarketPlace(Client* client, Seperator* sep)
  8384. {
  8385. PrintSep(sep, "COMMAND_SMP");
  8386. // This will reduce the spam from once every 10 sec to once every 30 sec,
  8387. // can't seem to reduce it any more get rid of it completely...
  8388. if (sep && strcmp(sep->arg[0], "gkw") == 0) {
  8389. PacketStruct* packet = configReader.getStruct("WS_MarketFundsUpdate", client->GetVersion());
  8390. if (packet) {
  8391. packet->setDataByName("account_id", client->GetAccountID());
  8392. packet->setDataByName("character_id", client->GetCharacterID());
  8393. packet->setDataByName("unknown1", 1, 5);
  8394. packet->setDataByName("unknown1", 26, 6);
  8395. packet->setDataByName("unknown2", 0xFFFFFFFF);
  8396. packet->setDataByName("unknown3", 248, 1);
  8397. client->QueuePacket(packet->serialize());
  8398. }
  8399. safe_delete(packet);
  8400. }
  8401. }
  8402. /*
  8403. Function: Command_StopDrinking()
  8404. Purpose : Stops player from auto-consuming drink
  8405. Params :
  8406. Dev : Zcoretri
  8407. Example : /stopdrinking
  8408. */
  8409. void Commands::Command_StopDrinking(Client* client)
  8410. {
  8411. client->GetPlayer()->reset_character_flag(CF_DRINK_AUTO_CONSUME);
  8412. client->Message(CHANNEL_COLOR_YELLOW,"You stop drinking your current drink.");
  8413. }
  8414. /*
  8415. Function: Command_StopEating()
  8416. Purpose : Stops player from auto-consuming food
  8417. Params :
  8418. Dev : Zcoretri
  8419. Example : /stopeating
  8420. */
  8421. void Commands::Command_StopEating(Client* client)
  8422. {
  8423. client->GetPlayer()->reset_character_flag(CF_FOOD_AUTO_CONSUME);
  8424. client->Message(CHANNEL_COLOR_YELLOW,"You stop eating your current food.");
  8425. }
  8426. /*
  8427. Function: Command_Title()
  8428. Purpose : Help for /title command
  8429. Params : n/a
  8430. Dev : Zcoretri
  8431. Example : /title
  8432. */
  8433. void Commands::Command_Title(Client* client)
  8434. {
  8435. client->Message(CHANNEL_COLOR_YELLOW, "Available subcommands: list, setprefix <index>, setsuffix <index>, fix");
  8436. }
  8437. /*
  8438. Function: Command_TitleList()
  8439. Purpose : List available titles for player
  8440. Params : n/a
  8441. Dev : Zcoretri
  8442. Example : /title list
  8443. */
  8444. void Commands::Command_TitleList(Client* client)
  8445. {
  8446. // must call release read lock before leaving function on GetPlayerTitles
  8447. vector<Title*>* titles = client->GetPlayer()->GetPlayerTitles()->GetAllTitles();
  8448. vector<Title*>::iterator itr;
  8449. Title* title;
  8450. sint32 i = 0;
  8451. client->Message(CHANNEL_NARRATIVE, "Listing available titles:");
  8452. for(itr = titles->begin(); itr != titles->end(); itr++)
  8453. {
  8454. title = *itr;
  8455. client->Message(CHANNEL_NARRATIVE, "%i: type=[%s] title=[%s]", i, title->GetPrefix() ? "Prefix":"Suffix", title->GetName());
  8456. i++;
  8457. }
  8458. client->GetPlayer()->GetPlayerTitles()->ReleaseReadLock();
  8459. }
  8460. /*
  8461. Function: Command_TitleSetPrefix()
  8462. Purpose : Set Prefix title for player
  8463. Params : Title ID
  8464. Dev : Zcoretri
  8465. Example : /title setprefix 1
  8466. */
  8467. void Commands::Command_TitleSetPrefix(Client* client, Seperator* sep)
  8468. {
  8469. if (sep && sep->arg[0] && sep->IsNumber(0))
  8470. {
  8471. sint32 index = atoul(sep->arg[0]);
  8472. if(index > -1)
  8473. {
  8474. Title* title = client->GetPlayer()->GetPlayerTitles()->GetTitle(index);
  8475. if(!title)
  8476. {
  8477. client->Message(CHANNEL_COLOR_RED, "Missing index %i to set title", index);
  8478. return;
  8479. }
  8480. else if(!title->GetPrefix())
  8481. {
  8482. client->Message(CHANNEL_COLOR_RED, "%s is not a prefix.", title->GetName());
  8483. return;
  8484. }
  8485. }
  8486. else // make sure client doesn't pass some bogus negative index
  8487. index = -1;
  8488. database.SaveCharPrefixIndex(index, client->GetCharacterID());
  8489. client->SendTitleUpdate();
  8490. }
  8491. }
  8492. /*
  8493. Function: Command_TitleSetSuffix()
  8494. Purpose : Set Suffix title for player
  8495. Params : Title ID
  8496. Dev : Zcoretri
  8497. Example : /title setsuffix 1
  8498. */
  8499. void Commands::Command_TitleSetSuffix(Client* client, Seperator* sep)
  8500. {
  8501. if (sep && sep->arg[0] && sep->IsNumber(0))
  8502. {
  8503. sint32 index = atoul(sep->arg[0]);
  8504. if(index > -1)
  8505. {
  8506. Title* title = client->GetPlayer()->GetPlayerTitles()->GetTitle(index);
  8507. if(!title)
  8508. {
  8509. client->Message(CHANNEL_COLOR_RED, "Missing index %i to set title", index);
  8510. return;
  8511. }
  8512. else if(title->GetPrefix())
  8513. {
  8514. client->Message(CHANNEL_COLOR_RED, "%s is not a suffix.", title->GetName());
  8515. return;
  8516. }
  8517. }
  8518. else // make sure client doesn't pass some bogus negative index
  8519. index = -1;
  8520. database.SaveCharSuffixIndex(index, client->GetCharacterID());
  8521. client->SendTitleUpdate();
  8522. }
  8523. }
  8524. /*
  8525. Function: Command_TitleFix()
  8526. Purpose : Fix title for player (???)
  8527. Params :
  8528. Dev : Zcoretri
  8529. Example :
  8530. */
  8531. void Commands::Command_TitleFix(Client* client, Seperator* sep)
  8532. {
  8533. PrintSep(sep, "COMMAND_TITLE_FIX");
  8534. LogWrite(MISC__TODO, 1, "Titles", "TODO-Command: TITLE_FIX");
  8535. }
  8536. /*
  8537. Function: Command_Toggle_Anonymous()
  8538. Purpose : Toggles player Anonymous
  8539. Params :
  8540. Dev : paulgh
  8541. Example : /anon
  8542. */
  8543. void Commands::Command_Toggle_Anonymous(Client* client)
  8544. {
  8545. Player* player = client->GetPlayer();
  8546. player->toggle_character_flag(CF_ANONYMOUS);
  8547. client->Message(CHANNEL_COLOR_YELLOW,"You are %s anonymous.", player->get_character_flag(CF_ANONYMOUS)?"now":"no longer");
  8548. if (player->get_character_flag(CF_ANONYMOUS))
  8549. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ANONYMOUS);
  8550. else
  8551. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ANONYMOUS);
  8552. }
  8553. /*
  8554. Function: Command_Toggle_AutoConsume()
  8555. Purpose : Toggles player food/drink auto consume
  8556. Params : unknown
  8557. Dev : paulgh
  8558. Example : /set_auto_consume
  8559. */
  8560. void Commands::Command_Toggle_AutoConsume(Client* client, Seperator* sep)
  8561. {
  8562. Player* player = client->GetPlayer();
  8563. if (sep && sep->arg[0])
  8564. PrintSep(sep, "COMMAND_SET_AUTO_CONSUME");
  8565. if (sep && sep->arg[0] && sep->IsNumber(0))
  8566. {
  8567. int8 slot = atoi(sep->arg[0]);
  8568. int8 flag = atoi(sep->arg[1]);
  8569. if (client->GetVersion() <= 283) {
  8570. slot += 4;
  8571. }
  8572. else if (client->GetVersion() <= 546) {
  8573. slot += 2;
  8574. }
  8575. if (slot == EQ2_FOOD_SLOT)
  8576. {
  8577. player->toggle_character_flag(CF_FOOD_AUTO_CONSUME);
  8578. player->SetCharSheetChanged(true);
  8579. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  8580. if (flag == 1)
  8581. client->Message(CHANNEL_NARRATIVE, "You decide to eat immediately whenever you become hungry.");
  8582. else
  8583. {
  8584. client->Message(CHANNEL_NARRATIVE, "You decide to ignore the hunger.");
  8585. return;
  8586. }
  8587. }
  8588. else
  8589. {
  8590. player->toggle_character_flag(CF_DRINK_AUTO_CONSUME);
  8591. player->SetCharSheetChanged(true);
  8592. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  8593. if (flag == 1)
  8594. client->Message(CHANNEL_NARRATIVE, "You decide to drink immediately whenever you become thirsty.");
  8595. else
  8596. {
  8597. client->Message(CHANNEL_NARRATIVE, "You decide to ignore the thirst.");
  8598. return;
  8599. }
  8600. }
  8601. if(!client->CheckConsumptionAllowed(slot, false))
  8602. return;
  8603. Item* item = player->GetEquipmentList()->GetItem(slot);
  8604. if(item)
  8605. client->ConsumeFoodDrink(item, slot);
  8606. }
  8607. }
  8608. /*
  8609. Function: Command_Toggle_BonusXP()
  8610. Purpose : Toggles player Bonus XP
  8611. Params :
  8612. Dev : John Adams
  8613. Example : /disable_char_bonus_exp
  8614. */
  8615. void Commands::Command_Toggle_BonusXP(Client* client)
  8616. {
  8617. Player* player = client->GetPlayer();
  8618. player->toggle_character_flag(CF2_CHARACTER_BONUS_EXPERIENCE_ENABLED);
  8619. player->SetCharSheetChanged(true);
  8620. }
  8621. /*
  8622. Function: Command_Toggle_CombatXP()
  8623. Purpose : Toggles player Adventure XP
  8624. Params :
  8625. Dev : John Adams
  8626. Example : /disable_combat_exp
  8627. */
  8628. void Commands::Command_Toggle_CombatXP(Client* client)
  8629. {
  8630. Player* player = client->GetPlayer();
  8631. player->toggle_character_flag(CF_COMBAT_EXPERIENCE_ENABLED);
  8632. player->SetCharSheetChanged(true);
  8633. }
  8634. /*
  8635. Function: Command_Toggle_GMHide()
  8636. Purpose : Toggles hiding player GM status
  8637. Params :
  8638. Dev : Scatman
  8639. Example : /gm_hide
  8640. */
  8641. void Commands::Command_Toggle_GMHide(Client* client)
  8642. {
  8643. Player* player = client->GetPlayer();
  8644. player->toggle_character_flag(CF_HIDE_STATUS);
  8645. client->Message(CHANNEL_COLOR_YELLOW,"You are %s hiding your GM status.", player->get_character_flag(CF_HIDE_STATUS)?"now":"no longer");
  8646. }
  8647. /*
  8648. Function: Command_Toggle_GMVanish()
  8649. Purpose : Toggles hiding GM players from /who searches
  8650. Params :
  8651. Dev : Scatman
  8652. Example : /gm_vanish
  8653. */
  8654. void Commands::Command_Toggle_GMVanish(Client* client)
  8655. {
  8656. Player* player = client->GetPlayer();
  8657. player->toggle_character_flag(CF_GM_HIDDEN);
  8658. client->Message(CHANNEL_COLOR_YELLOW,"You are %s invisible to who queries.", player->get_character_flag(CF_GM_HIDDEN)?"now":"no longer");
  8659. }
  8660. /*
  8661. Function: Command_Toggle_Illusions()
  8662. Purpose : Toggles player illusion form
  8663. Params : not sure sep is needed, testing
  8664. Dev : paulgh
  8665. Example : /hide_illusions
  8666. */
  8667. void Commands::Command_Toggle_Illusions(Client* client, Seperator* sep)
  8668. {
  8669. if (sep && sep->arg[0])
  8670. PrintSep(sep, "COMMAND_TOGGLE_ILLUSIONS");
  8671. client->GetPlayer()->toggle_character_flag(CF_SHOW_ILLUSION);
  8672. }
  8673. /*
  8674. Function: Command_Toggle_LFG()
  8675. Purpose : Toggles player LFG Flag
  8676. Params :
  8677. Dev : paulgh
  8678. Example : /lfg
  8679. */
  8680. void Commands::Command_Toggle_LFG(Client* client)
  8681. {
  8682. Player* player = client->GetPlayer();
  8683. player->toggle_character_flag(CF_LFG);
  8684. client->Message(CHANNEL_COLOR_YELLOW,"You are %s LFG.", player->get_character_flag(CF_LFG)?"now":"no longer");
  8685. if (player->get_character_flag(CF_LFG))
  8686. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFG);
  8687. else
  8688. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFG);
  8689. }
  8690. /*
  8691. Function: Command_Toggle_LFW()
  8692. Purpose : Toggles player LFW Flag
  8693. Params :
  8694. Dev : paulgh
  8695. Example : /lfw
  8696. */
  8697. void Commands::Command_Toggle_LFW(Client* client)
  8698. {
  8699. Player* player = client->GetPlayer();
  8700. player->toggle_character_flag(CF_LFW);
  8701. client->Message(CHANNEL_COLOR_YELLOW,"You %s looking for work.", player->get_character_flag(CF_LFW)?"let others know you are":"stop");
  8702. if (player->get_character_flag(CF_LFW))
  8703. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFW);
  8704. else
  8705. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFW);
  8706. }
  8707. /*
  8708. Function: Command_Toggle_QuestXP()
  8709. Purpose : Toggles player Quest XP
  8710. Params :
  8711. Dev : John Adams
  8712. Example : /disable_quest_exp
  8713. */
  8714. void Commands::Command_Toggle_QuestXP(Client* client)
  8715. {
  8716. Player* player = client->GetPlayer();
  8717. player->toggle_character_flag(CF_QUEST_EXPERIENCE_ENABLED);
  8718. player->SetCharSheetChanged(true);
  8719. }
  8720. /*
  8721. Function: Command_Toggle_Roleplaying()
  8722. Purpose : Toggles player Roleplaying flag
  8723. Params :
  8724. Dev : paulgh
  8725. Example : /role
  8726. */
  8727. void Commands::Command_Toggle_Roleplaying(Client* client)
  8728. {
  8729. Player* player = client->GetPlayer();
  8730. player->toggle_character_flag(CF_ROLEPLAYING);
  8731. client->Message(CHANNEL_COLOR_YELLOW,"You are %s roleplaying.", player->get_character_flag(CF_ROLEPLAYING)?"now":"no longer");
  8732. if (player->get_character_flag(CF_ROLEPLAYING))
  8733. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ROLEPLAYING);
  8734. else
  8735. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ROLEPLAYING);
  8736. }
  8737. void Commands::Command_Toggle_Duels(Client* client)
  8738. {
  8739. Player* player = client->GetPlayer();
  8740. player->toggle_character_flag(CF_ALLOW_DUEL_INVITES);
  8741. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting duel invites.", player->get_character_flag(CF_ALLOW_DUEL_INVITES)?"now":"no longer");
  8742. }
  8743. void Commands::Command_Toggle_Trades(Client* client)
  8744. {
  8745. Player* player = client->GetPlayer();
  8746. player->toggle_character_flag(CF_ALLOW_TRADE_INVITES);
  8747. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting trade invites.", player->get_character_flag(CF_ALLOW_TRADE_INVITES)?"now":"no longer");
  8748. }
  8749. void Commands::Command_Toggle_Guilds(Client* client)
  8750. {
  8751. Player* player = client->GetPlayer();
  8752. player->toggle_character_flag(CF_ALLOW_GUILD_INVITES);
  8753. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting guild invites.", player->get_character_flag(CF_ALLOW_GUILD_INVITES)?"now":"no longer");
  8754. }
  8755. void Commands::Command_Toggle_Groups(Client* client)
  8756. {
  8757. Player* player = client->GetPlayer();
  8758. player->toggle_character_flag(CF_ALLOW_GROUP_INVITES);
  8759. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting group invites.", player->get_character_flag(CF_ALLOW_GROUP_INVITES)?"now":"no longer");
  8760. }
  8761. void Commands::Command_Toggle_Raids(Client* client)
  8762. {
  8763. Player* player = client->GetPlayer();
  8764. player->toggle_character_flag(CF_ALLOW_RAID_INVITES);
  8765. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting raid invites.", player->get_character_flag(CF_ALLOW_RAID_INVITES)?"now":"no longer");
  8766. }
  8767. void Commands::Command_Toggle_LON(Client* client)
  8768. {
  8769. Player* player = client->GetPlayer();
  8770. player->toggle_character_flag(CF2_ALLOW_LON_INVITES);
  8771. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting LoN invites.", player->get_character_flag(CF2_ALLOW_LON_INVITES)?"now":"no longer");
  8772. }
  8773. void Commands::Command_Toggle_VoiceChat(Client* client)
  8774. {
  8775. Player* player = client->GetPlayer();
  8776. player->toggle_character_flag(CF2_ALLOW_VOICE_INVITES);
  8777. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting voice chat invites.", player->get_character_flag(CF2_ALLOW_VOICE_INVITES)?"now":"no longer");
  8778. }
  8779. /*
  8780. Function: Command_TradeStart()
  8781. Purpose : Starts item/coin trade between players
  8782. Params :
  8783. Dev :
  8784. Example :
  8785. */
  8786. #include "../Trade.h"
  8787. void Commands::Command_TradeStart(Client* client, Seperator* sep)
  8788. {
  8789. PrintSep(sep, "COMMAND_START_TRADE");
  8790. Entity* trader = client->GetPlayer();
  8791. Entity* trader2 = 0;
  8792. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  8793. Spawn* spawn = client->GetPlayer()->GetSpawnWithPlayerID(atoi(sep->arg[0]));
  8794. if (spawn) {
  8795. if (spawn->IsEntity())
  8796. trader2 = (Entity*)spawn;
  8797. }
  8798. }
  8799. else if (client->GetPlayer()->GetTarget()) {
  8800. if (client->GetPlayer()->GetTarget()->IsEntity())
  8801. trader2 = (Entity*)client->GetPlayer()->GetTarget();
  8802. }
  8803. // can only trade with player or bots
  8804. if (trader && trader2) {
  8805. if (trader == trader2) {
  8806. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade with yourself.");
  8807. }
  8808. else if (trader2->IsPlayer() || trader2->IsBot()) {
  8809. LogWrite(PLAYER__ERROR, 0, "Trade", "creating trade");
  8810. if (trader->trade)
  8811. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are already trading.");
  8812. else if (trader2->trade)
  8813. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is already trading.");
  8814. else {
  8815. Trade* trade = new Trade(trader, trader2);
  8816. trader->trade = trade;
  8817. trader2->trade = trade;
  8818. }
  8819. }
  8820. else {
  8821. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can only trade with another player or a bot.");
  8822. }
  8823. }
  8824. else
  8825. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to find target");
  8826. }
  8827. /*
  8828. Function: Command_Track()
  8829. Purpose : Starts/Stops Tracking for a player
  8830. Params :
  8831. Dev : Scatman
  8832. Example : /track
  8833. */
  8834. void Commands::Command_Track(Client* client)
  8835. {
  8836. if (!client->GetPlayer()->GetIsTracking())
  8837. client->GetPlayer()->GetZone()->AddPlayerTracking(client->GetPlayer());
  8838. else
  8839. client->GetPlayer()->GetZone()->RemovePlayerTracking(client->GetPlayer(), TRACKING_STOP);
  8840. }
  8841. /*
  8842. Function: Command_TradeAccept()
  8843. Purpose : Accepts item/coin trade between players
  8844. Params :
  8845. Dev :
  8846. Example :
  8847. */
  8848. void Commands::Command_TradeAccept(Client* client, Seperator* sep)
  8849. {
  8850. PrintSep(sep, "COMMAND_ACCEPT_TRADE");
  8851. Trade* trade = client->GetPlayer()->trade;
  8852. if (trade) {
  8853. bool trade_complete = trade->SetTradeAccepted(client->GetPlayer());
  8854. if (trade_complete)
  8855. safe_delete(trade);
  8856. }
  8857. else
  8858. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8859. }
  8860. /*
  8861. Function: Command_TradeReject()
  8862. Purpose : Rejects item/coin trade between players
  8863. Params :
  8864. Dev :
  8865. Example :
  8866. */
  8867. void Commands::Command_TradeReject(Client* client, Seperator* sep)
  8868. {
  8869. PrintSep(sep, "COMMAND_REJECT_TRADE");
  8870. Command_TradeCancel(client, sep);
  8871. }
  8872. /*
  8873. Function: Command_TradeCancel()
  8874. Purpose : Cancels item/coin trade between players
  8875. Params :
  8876. Dev :
  8877. Example :
  8878. */
  8879. void Commands::Command_TradeCancel(Client* client, Seperator* sep)
  8880. {
  8881. PrintSep(sep, "COMMAND_CANCEL_TRADE");
  8882. Trade* trade = client->GetPlayer()->trade;
  8883. if (trade) {
  8884. trade->CancelTrade(client->GetPlayer());
  8885. safe_delete(trade);
  8886. }
  8887. else
  8888. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8889. }
  8890. /*
  8891. Function: Command_TradeSetCoin()
  8892. Purpose : Sets coin trade between players
  8893. Params :
  8894. Dev :
  8895. Example :
  8896. */
  8897. void Commands::Command_TradeSetCoin(Client* client, Seperator* sep)
  8898. {
  8899. PrintSep(sep, "COMMAND_SET_TRADE_COIN");
  8900. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Set Trade Coin");
  8901. client->Message(CHANNEL_COLOR_YELLOW, "You cannot trade with other players (Not Implemented)");
  8902. }
  8903. /*
  8904. Function: Command_TradeAddCoin()
  8905. Purpose : Adds coin to trade between players
  8906. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  8907. Dev :
  8908. Example :
  8909. */
  8910. void Commands::Command_TradeAddCoin(Client* client, Seperator* sep, int handler)
  8911. {
  8912. PrintSep(sep, "COMMAND_ADD_TRADE_{coin type}");
  8913. Trade* trade = client->GetPlayer()->trade;
  8914. if (trade) {
  8915. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  8916. int32 amount = atoi(sep->arg[0]);
  8917. int64 val = 0;
  8918. switch (handler) {
  8919. case COMMAND_ADD_TRADE_COPPER:
  8920. {
  8921. val = amount;
  8922. trade->AddCoinToTrade(client->GetPlayer(), val);
  8923. break;
  8924. }
  8925. case COMMAND_ADD_TRADE_SILVER:
  8926. {
  8927. val = amount * 100;
  8928. trade->AddCoinToTrade(client->GetPlayer(), val);
  8929. break;
  8930. }
  8931. case COMMAND_ADD_TRADE_GOLD:
  8932. {
  8933. val = amount * 10000;
  8934. trade->AddCoinToTrade(client->GetPlayer(), val);
  8935. break;
  8936. }
  8937. case COMMAND_ADD_TRADE_PLAT:
  8938. {
  8939. val = amount * 1000000;
  8940. trade->AddCoinToTrade(client->GetPlayer(), val);
  8941. break;
  8942. }
  8943. default:
  8944. {
  8945. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  8946. break;
  8947. }
  8948. }
  8949. }
  8950. else
  8951. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount.");
  8952. }
  8953. else
  8954. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8955. }
  8956. /*
  8957. Function: Command_TradeRemoveCoin()
  8958. Purpose : Removes coin from trade between players
  8959. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  8960. Dev :
  8961. Example :
  8962. */
  8963. void Commands::Command_TradeRemoveCoin(Client* client, Seperator* sep, int handler)
  8964. {
  8965. PrintSep(sep, "COMMAND_REMOVE_TRADE_{coin type}");
  8966. Trade* trade = client->GetPlayer()->trade;
  8967. if (trade) {
  8968. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  8969. int32 amount = atoi(sep->arg[0]);
  8970. int64 val = 0;
  8971. switch (handler) {
  8972. case COMMAND_REMOVE_TRADE_COPPER:
  8973. {
  8974. val = amount;
  8975. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  8976. break;
  8977. }
  8978. case COMMAND_REMOVE_TRADE_SILVER:
  8979. {
  8980. val = amount * 100;
  8981. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  8982. break;
  8983. }
  8984. case COMMAND_REMOVE_TRADE_GOLD:
  8985. {
  8986. val = amount * 10000;
  8987. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  8988. break;
  8989. }
  8990. case COMMAND_REMOVE_TRADE_PLAT:
  8991. {
  8992. val = amount * 1000000;
  8993. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  8994. break;
  8995. }
  8996. default:
  8997. {
  8998. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  8999. break;
  9000. }
  9001. }
  9002. }
  9003. else
  9004. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount");
  9005. }
  9006. else
  9007. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  9008. }
  9009. /*
  9010. Function: Command_TradeAddItem()
  9011. Purpose : Adds item to trade between players
  9012. Params :
  9013. Dev :
  9014. Example :
  9015. */
  9016. void Commands::Command_TradeAddItem(Client* client, Seperator* sep)
  9017. {
  9018. PrintSep(sep, "COMMAND_ADD_TRADE_ITEM");
  9019. /*
  9020. arg[0] = item index
  9021. arg[1] = slot
  9022. arg[2] = quantity
  9023. */
  9024. if (!client->GetPlayer()->trade) {
  9025. LogWrite(PLAYER__ERROR, 0, "Trade", "Player is not currently trading.");
  9026. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  9027. return;
  9028. }
  9029. if (sep && sep->IsSet(0) && sep->IsNumber(0) && sep->IsSet(1) && sep->IsNumber(1) && sep->IsSet(2) && sep->IsNumber(2)) {
  9030. Item* item = 0;
  9031. int32 index = atoi(sep->arg[0]);
  9032. item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(index);
  9033. if (item) {
  9034. int8 result = client->GetPlayer()->trade->AddItemToTrade(client->GetPlayer(), item, atoi(sep->arg[2]), atoi(sep->arg[1]));
  9035. if (result == 1)
  9036. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Item is already being traded.");
  9037. else if (result == 2)
  9038. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade NO-TRADE items.");
  9039. else if (result == 3)
  9040. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade HEIRLOOM items.");
  9041. else if (result == 255)
  9042. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown error trying to add the item to the trade...");
  9043. }
  9044. else {
  9045. LogWrite(PLAYER__ERROR, 0, "Trade", "Unable to get an item for the player (%s) from the index (%u)", client->GetPlayer()->GetName(), index);
  9046. client->Message(CHANNEL_ERROR, "Unable to find item at index %u", index);
  9047. }
  9048. }
  9049. else
  9050. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  9051. }
  9052. /*
  9053. Function: Command_TradeRemoveItem()
  9054. Purpose : Removes item from trade between players
  9055. Params :
  9056. Dev :
  9057. Example :
  9058. */
  9059. void Commands::Command_TradeRemoveItem(Client* client, Seperator* sep)
  9060. {
  9061. PrintSep(sep, "COMMAND_REMOVE_TRADE_ITEM");
  9062. /*
  9063. arg[0] = trade window slot
  9064. */
  9065. Trade* trade = client->GetPlayer()->trade;
  9066. if (trade) {
  9067. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  9068. trade->RemoveItemFromTrade(client->GetPlayer(), atoi(sep->arg[0]));
  9069. }
  9070. else
  9071. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  9072. }
  9073. else
  9074. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  9075. }
  9076. void Commands::Command_TryOn(Client* client, Seperator* sep)
  9077. {
  9078. Item *item = 0;
  9079. sint32 crc;
  9080. if (sep) {
  9081. // 1096+ sends more info so need to do a version check so older clients (SF) still work
  9082. if (client->GetVersion() < 1096) {
  9083. if (sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2))
  9084. {
  9085. item = master_item_list.GetItem(atoul(sep->arg[1]));
  9086. crc = atol(sep->arg[2]);
  9087. }
  9088. }
  9089. else {
  9090. // From the broker and links in chat
  9091. if (strcmp(sep->arg[0], "crc") == 0) {
  9092. if (sep->IsNumber(2) && sep->IsNumber(3)) {
  9093. item = master_item_list.GetItem(atoul(sep->arg[2]));
  9094. crc = atol(sep->arg[3]);
  9095. }
  9096. }
  9097. // From inventory
  9098. if (strcmp(sep->arg[0], "dbid") == 0) {
  9099. if (sep->IsNumber(2) && sep->IsNumber(4)) {
  9100. item = master_item_list.GetItem(atoul(sep->arg[2]));
  9101. crc = atol(sep->arg[4]);
  9102. }
  9103. }
  9104. }
  9105. if (item)
  9106. client->ShowDressingRoom(item, crc);
  9107. }
  9108. }
  9109. void Commands::Command_JoinChannel(Client * client, Seperator *sep) {
  9110. const char *channel_name, *password = NULL;
  9111. if (sep == NULL || !sep->IsSet(0)) {
  9112. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /joinchannel <channel name> [password]");
  9113. return;
  9114. }
  9115. channel_name = sep->arg[0];
  9116. if (sep->IsSet(1))
  9117. password = sep->arg[1];
  9118. if (!chat.ChannelExists(channel_name) && !chat.CreateChannel(channel_name, password)) {
  9119. client->Message(CHANNEL_COLOR_RED, "Unable to create channel '%s'.", channel_name);
  9120. return;
  9121. }
  9122. if (chat.IsInChannel(client, channel_name)) {
  9123. client->Message(CHANNEL_NARRATIVE, "You are already in '%s'.", channel_name);
  9124. return;
  9125. }
  9126. if (chat.HasPassword(channel_name)) {
  9127. if (password == NULL) {
  9128. client->Message(CHANNEL_NARRATIVE, "Unable to join '%s': That channel is password protected.", channel_name);
  9129. return;
  9130. }
  9131. if (!chat.PasswordMatches(channel_name, password)) {
  9132. client->Message(CHANNEL_NARRATIVE, "Unable to join '%s': The password is not correc.t", channel_name);
  9133. return;
  9134. }
  9135. }
  9136. if (!chat.JoinChannel(client, channel_name))
  9137. client->Message(CHANNEL_COLOR_RED, "There was an internal error preventing you from joining '%s'.", channel_name);
  9138. }
  9139. void Commands::Command_JoinChannelFromLoad(Client * client, Seperator *sep) {
  9140. printf("ScatDebug: Received 'joinfromchannel', using the same function as 'joinchannel' (not sure what the difference is)\n");
  9141. Command_JoinChannel(client, sep);
  9142. }
  9143. void Commands::Command_TellChannel(Client *client, Seperator *sep) {
  9144. if (sep == NULL || !sep->IsSet(0) || !sep->IsSet(1)) {
  9145. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /tellchannel <channel name> <message>");
  9146. PrintSep(sep, "tellchannel");
  9147. return;
  9148. }
  9149. chat.TellChannel(client, sep->arg[0], sep->argplus[1]);
  9150. }
  9151. void Commands::Command_Test(Client* client, EQ2_16BitString* command_parms) {
  9152. Seperator* sep = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  9153. if (sep->IsSet(0)) {
  9154. if (atoi(sep->arg[0]) == 1) {
  9155. PacketStruct* packet2 = configReader.getStruct("WS_SpellGainedMsg", client->GetVersion());
  9156. if (packet2) {
  9157. packet2->setDataByName("spell_type", 2);
  9158. packet2->setDataByName("spell_id", 8308);
  9159. packet2->setDataByName("spell_name", "Sprint");
  9160. packet2->setDataByName("add_silently", 0);
  9161. packet2->setDataByName("tier", 1);
  9162. packet2->setDataByName("blah1", 1);
  9163. packet2->setDataByName("blah2", 1);
  9164. EQ2Packet* outapp = packet2->serialize();
  9165. DumpPacket(outapp);
  9166. client->QueuePacket(outapp);
  9167. safe_delete(packet2);
  9168. }
  9169. }
  9170. else if (atoi(sep->arg[0]) == 2) {
  9171. PacketStruct* packet2 = configReader.getStruct("WS_GuildUpdate", client->GetVersion());
  9172. if (packet2) {
  9173. packet2->setDataByName("guild_name", "Test");
  9174. packet2->setDataByName("guild_motd", "Test MOTD");
  9175. packet2->setDataByName("guild_id", 1234);
  9176. packet2->setDataByName("guild_level", 1);
  9177. packet2->setDataByName("unknown", 2);
  9178. packet2->setDataByName("unknown2", 3);
  9179. packet2->setDataByName("exp_current", 1);
  9180. packet2->setDataByName("exp_to_next_level", 4);
  9181. EQ2Packet* outapp = packet2->serialize();
  9182. DumpPacket(outapp);
  9183. client->QueuePacket(outapp);
  9184. safe_delete(packet2);
  9185. }
  9186. }
  9187. else if (atoi(sep->arg[0]) == 3) {
  9188. PacketStruct* packet2 = configReader.getStruct("WS_JoinGuildNotify", client->GetVersion());
  9189. if (packet2) {
  9190. packet2->setDataByName("guild_id", 1234);
  9191. packet2->setDataByName("character_id", 1);
  9192. packet2->setDataByName("account_id", 2);
  9193. packet2->setDataByName("guild_level", 1);
  9194. packet2->setDataByName("name", "Test");
  9195. packet2->setDataByName("unknown2", 0);
  9196. packet2->setDataByName("unknown3", 1);
  9197. packet2->setDataByName("adventure_class", 6);
  9198. packet2->setDataByName("adventure_level", 7);
  9199. packet2->setDataByName("tradeskill_class", 4);
  9200. packet2->setDataByName("tradeskill_level", 5);
  9201. packet2->setDataByName("rank", 0);
  9202. packet2->setDataByName("member_flags", 2);
  9203. packet2->setDataByName("join_date", 1591112273);
  9204. packet2->setDataByName("guild_status", 2);
  9205. packet2->setDataByName("last_login", 1591132273);
  9206. packet2->setDataByName("recruiter_id", 1);
  9207. packet2->setDataByName("points", 2345);
  9208. packet2->setDataByName("note", "note");
  9209. packet2->setMediumStringByName("officer_note", "O note");
  9210. packet2->setMediumStringByName("zone", "Blah");
  9211. EQ2Packet* outapp = packet2->serialize();
  9212. DumpPacket(outapp);
  9213. client->QueuePacket(outapp);
  9214. safe_delete(packet2);
  9215. }
  9216. }
  9217. else if (atoi(sep->arg[0]) == 5) {
  9218. int16 offset = atoi(sep->arg[1]);
  9219. int32 value1 = atol(sep->arg[2]);
  9220. EQ2Packet* outapp = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion(), offset, value1);
  9221. client->QueuePacket(outapp);
  9222. }
  9223. else if (atoi(sep->arg[0]) == 6) {
  9224. Spawn* spawn = client->GetPlayer()->GetTarget();
  9225. if (!spawn)
  9226. spawn = client->GetPlayer();
  9227. else if (spawn->IsEntity())
  9228. ((Entity*)spawn)->SetSpeed(atof(sep->arg[4]));
  9229. spawn->RunToLocation(atof(sep->arg[1]), atof(sep->arg[2]), atof(sep->arg[3]));
  9230. }
  9231. else if (atoi(sep->arg[0]) == 7) {
  9232. int32 id = 0;
  9233. Spawn* spawn = client->GetCurrentZone()->GetSpawn(7720001);
  9234. if (spawn) {
  9235. spawn->SetX(client->GetPlayer()->GetX() + .5, false);
  9236. spawn->SetY(client->GetPlayer()->GetY(), false);
  9237. spawn->SetZ(client->GetPlayer()->GetZ() + .5, false);
  9238. float heading = client->GetPlayer()->GetHeading() + 180;
  9239. if (heading > 360)
  9240. heading -= 360;
  9241. spawn->SetLevel(5);
  9242. spawn->SetAdventureClass(4);
  9243. spawn->SetHeading(heading, false);
  9244. spawn->SetSpawnOrigX(spawn->GetX());
  9245. spawn->SetSpawnOrigY(spawn->GetY());
  9246. spawn->SetSpawnOrigZ(spawn->GetZ());
  9247. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  9248. spawn->SetLocation(client->GetPlayer()->GetLocation());
  9249. spawn->appearance.targetable = 1;
  9250. if (spawn->IsNPC() && spawn->GetTotalHP() == 0) {
  9251. spawn->SetTotalHP(spawn->GetLevel() * 15);
  9252. spawn->SetHP(spawn->GetTotalHP());
  9253. }
  9254. if (spawn->GetTotalPower() == 0) {
  9255. spawn->SetTotalPower(spawn->GetLevel() * 15);
  9256. spawn->SetPower(spawn->GetTotalPower());
  9257. }
  9258. int16 offset = atoi(sep->arg[1]);
  9259. int32 value1 = atol(sep->arg[2]);
  9260. sprintf(spawn->appearance.name, "Offset %i", offset);
  9261. EQ2Packet* ret = spawn->spawn_serialize(client->GetPlayer(), client->GetVersion(), offset, value1);
  9262. DumpPacket(ret);
  9263. client->QueuePacket(ret);
  9264. }
  9265. }
  9266. else if (atoi(sep->arg[0]) == 8) {
  9267. int32 id = atoi(sep->arg[1]);
  9268. Spawn* spawn = client->GetCurrentZone()->GetSpawn(id);
  9269. if (spawn) {
  9270. spawn->SetX(client->GetPlayer()->GetX() + .5, false);
  9271. spawn->SetY(client->GetPlayer()->GetY(), false);
  9272. spawn->SetZ(client->GetPlayer()->GetZ() + .5, false);
  9273. float heading = client->GetPlayer()->GetHeading() + 180;
  9274. if (heading > 360)
  9275. heading -= 360;
  9276. spawn->SetLevel(5);
  9277. spawn->SetAdventureClass(4);
  9278. spawn->SetHeading(heading, false);
  9279. spawn->SetSpawnOrigX(spawn->GetX());
  9280. spawn->SetSpawnOrigY(spawn->GetY());
  9281. spawn->SetSpawnOrigZ(spawn->GetZ());
  9282. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  9283. spawn->SetLocation(client->GetPlayer()->GetLocation());
  9284. spawn->appearance.targetable = 1;
  9285. if (spawn->IsNPC() && spawn->GetTotalHP() == 0) {
  9286. spawn->SetTotalHP(spawn->GetLevel() * 15);
  9287. spawn->SetHP(spawn->GetTotalHP());
  9288. }
  9289. if (spawn->GetTotalPower() == 0) {
  9290. spawn->SetTotalPower(spawn->GetLevel() * 15);
  9291. spawn->SetPower(spawn->GetTotalPower());
  9292. }
  9293. int16 offset = atoi(sep->arg[2]);
  9294. int16 offset2 = atoi(sep->arg[3]);
  9295. int32 value1 = atol(sep->arg[4]);
  9296. int16 offset3 = 0;
  9297. int16 offset4 = 0;
  9298. int32 value2 = 0;
  9299. if (sep->IsSet(7)) {
  9300. offset3 = atoi(sep->arg[5]);
  9301. offset4 = atoi(sep->arg[6]);
  9302. value2 = atol(sep->arg[7]);
  9303. }
  9304. sprintf(spawn->appearance.name, "Offset %i to %i", offset, offset2);
  9305. spawn->AddPrimaryEntityCommand("attack", 10000, "attack","", 0, 0);
  9306. EQ2Packet* ret = spawn->spawn_serialize(client->GetPlayer(), client->GetVersion(), offset, value1, offset2, offset3, offset4, value2);
  9307. DumpPacket(ret);
  9308. client->QueuePacket(ret);
  9309. }
  9310. }
  9311. else if (atoi(sep->arg[0]) == 9) {
  9312. PacketStruct* packet2 = configReader.getStruct("WS_DeathWindow", client->GetVersion());
  9313. if (packet2) {
  9314. packet2->setArrayLengthByName("location_count", 1);
  9315. packet2->setArrayDataByName("location_ida", 1234);
  9316. packet2->setArrayDataByName("unknown2a", 3);
  9317. packet2->setArrayDataByName("zone_name", "Queen's Colony");
  9318. packet2->setArrayDataByName("location_name", "Myrrin's Tower");
  9319. packet2->setArrayDataByName("distance", 134);
  9320. EQ2Packet* app = packet2->serialize();
  9321. if (sep->IsSet(2)) {
  9322. int8 offset = atoi(sep->arg[1]);
  9323. uchar* ptr2 = app->pBuffer;
  9324. ptr2 += offset;
  9325. if (sep->IsNumber(2)) {
  9326. int32 value1 = atol(sep->arg[2]);
  9327. if (value1 > 0xFFFF)
  9328. memcpy(ptr2, (uchar*)&value1, 4);
  9329. else if (value1 > 0xFF)
  9330. memcpy(ptr2, (uchar*)&value1, 2);
  9331. else
  9332. memcpy(ptr2, (uchar*)&value1, 1);
  9333. }
  9334. else {
  9335. int8 len = strlen(sep->arg[2]);
  9336. memcpy(ptr2, (uchar*)&len, 1);
  9337. ptr2 += 1;
  9338. memcpy(ptr2, sep->arg[2], len);
  9339. }
  9340. }
  9341. DumpPacket(app);
  9342. client->QueuePacket(app);
  9343. safe_delete(packet2);
  9344. }
  9345. }
  9346. else if (atoi(sep->arg[0]) == 10) {
  9347. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalUpdate", client->GetVersion());
  9348. if (packet2) {
  9349. packet2->setArrayLengthByName("num_quests", 1);
  9350. packet2->setArrayDataByName("active", 1);
  9351. packet2->setArrayDataByName("name", "Tasks aboard the Far Journey");
  9352. packet2->setArrayDataByName("quest_type", "Hallmark");
  9353. packet2->setArrayDataByName("quest_zone", "Hallmark");
  9354. packet2->setArrayDataByName("journal_updated", 1);
  9355. packet2->setArrayDataByName("quest_id", 524);
  9356. packet2->setArrayDataByName("day", 19);
  9357. packet2->setArrayDataByName("month", 6);
  9358. packet2->setArrayDataByName("year", 20);
  9359. packet2->setArrayDataByName("level", 2);
  9360. packet2->setArrayDataByName("encounter_level", 4);
  9361. packet2->setArrayDataByName("difficulty", 3);
  9362. packet2->setArrayDataByName("visible", 1);
  9363. packet2->setDataByName("visible_quest_id", 524);
  9364. packet2->setDataByName("player_crc", 2900677088);
  9365. packet2->setDataByName("player_name", "LethalEncounter");
  9366. EQ2Packet* app = packet2->serialize();
  9367. if (sep->IsSet(2)) {
  9368. int8 offset = atoi(sep->arg[1]);
  9369. uchar* ptr2 = app->pBuffer;
  9370. ptr2 += offset;
  9371. if (sep->IsNumber(2)) {
  9372. int32 value1 = atol(sep->arg[2]);
  9373. if (value1 > 0xFFFF)
  9374. memcpy(ptr2, (uchar*)&value1, 4);
  9375. else if (value1 > 0xFF)
  9376. memcpy(ptr2, (uchar*)&value1, 2);
  9377. else
  9378. memcpy(ptr2, (uchar*)&value1, 1);
  9379. }
  9380. else {
  9381. int8 len = strlen(sep->arg[2]);
  9382. memcpy(ptr2, (uchar*)&len, 1);
  9383. ptr2 += 1;
  9384. memcpy(ptr2, sep->arg[2], len);
  9385. }
  9386. }
  9387. DumpPacket(app);
  9388. client->QueuePacket(app);
  9389. safe_delete(packet2);
  9390. }
  9391. }
  9392. else if (atoi(sep->arg[0]) == 11) {
  9393. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalReply", client->GetVersion());
  9394. if (packet2) {
  9395. packet2->setDataByName("quest_id", 524);
  9396. packet2->setDataByName("player_crc", 2900677088);
  9397. packet2->setDataByName("name", "Tasks aboard the Far Journey");
  9398. packet2->setDataByName("description", "I completed all the tasks assigned to me by Captain Varlos aboard the Far Journey");
  9399. packet2->setDataByName("type", "Hallmark");
  9400. packet2->setDataByName("complete_header", "To complete this quest, I must do the following tasks:");
  9401. packet2->setDataByName("day", 19);
  9402. packet2->setDataByName("month", 6);
  9403. packet2->setDataByName("year", 20);
  9404. packet2->setDataByName("level", 1);
  9405. packet2->setDataByName("encounter_level", 1);
  9406. packet2->setDataByName("difficulty", 1);
  9407. packet2->setDataByName("time_obtained", Timer::GetUnixTimeStamp());
  9408. //packet2->setDataByName("timer_start", Timer::GetUnixTimeStamp());
  9409. //packet2->setDataByName("timer_duration", 300);
  9410. //packet2->setDataByName("timer_running", 1);
  9411. packet2->setArrayLengthByName("task_groups_completed", 9);
  9412. packet2->setArrayLengthByName("num_task_groups", 10);
  9413. packet2->setArrayDataByName("task_group", "I spoke to Waulon as Captain Varlos had asked of me.");
  9414. packet2->setArrayDataByName("task_group", "I found Waulon's hat in one of the boxes.", 1);
  9415. packet2->setArrayDataByName("task_group", "I returned Waulon's hat.", 2);
  9416. packet2->setArrayDataByName("task_group", "I have spoken to Ingrid.", 3);
  9417. packet2->setArrayDataByName("task_group", "I purchased a Shard of Luclin.", 4);
  9418. packet2->setArrayDataByName("task_group", "I gave the Shard of Luclin to Ingrid.", 5);
  9419. packet2->setArrayDataByName("task_group", "I have spoken to Captain Varlos.", 6);
  9420. packet2->setArrayDataByName("task_group", "I killed the rats that Captain Varlos requested.", 7);
  9421. packet2->setArrayDataByName("task_group", "Captain Varlos has ordered you to kill the escaped goblin.", 8);
  9422. packet2->setArrayDataByName("task_group", "I killed the escaped goblin.", 9);
  9423. /*packet2->setSubArrayLengthByName("num_tasks", 1);
  9424. packet2->setSubArrayDataByName("task", "I need to talk to Garven Tralk");
  9425. packet2->setSubArrayLengthByName("num_updates", 1);
  9426. packet2->setSubArrayDataByName("update_currentval", 0);
  9427. packet2->setSubArrayDataByName("update_maxval", 1);
  9428. packet2->setSubArrayDataByName("icon", 11);
  9429. */
  9430. packet2->setArrayDataByName("waypoint", 0xFFFFFFFF);
  9431. packet2->setDataByName("journal_updated", 1);
  9432. packet2->setDataByName("bullets", 1);
  9433. EQ2Packet* app = packet2->serialize();
  9434. if (sep->IsSet(2)) {
  9435. int16 offset = atoi(sep->arg[1]);
  9436. uchar* ptr2 = app->pBuffer;
  9437. ptr2 += offset;
  9438. if (sep->IsNumber(2)) {
  9439. int32 value1 = atol(sep->arg[2]);
  9440. if (value1 > 0xFFFF)
  9441. memcpy(ptr2, (uchar*)&value1, 4);
  9442. else if (value1 > 0xFF)
  9443. memcpy(ptr2, (uchar*)&value1, 2);
  9444. else
  9445. memcpy(ptr2, (uchar*)&value1, 1);
  9446. }
  9447. else {
  9448. int16 len = strlen(sep->arg[2]);
  9449. memcpy(ptr2, (uchar*)&len, 2);
  9450. ptr2 += 2;
  9451. memcpy(ptr2, sep->arg[2], len);
  9452. }
  9453. }
  9454. DumpPacket(app);
  9455. client->QueuePacket(app);
  9456. safe_delete(packet2);
  9457. }
  9458. }
  9459. else if (atoi(sep->arg[0]) == 12) {
  9460. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalReply", client->GetVersion());
  9461. if (packet2) {
  9462. packet2->setDataByName("quest_id", 524);
  9463. packet2->setDataByName("player_crc", 2900677088);
  9464. packet2->setDataByName("name", "Archetype Selection");
  9465. packet2->setDataByName("description", "I have reported my profession to Garven Tralk.");
  9466. packet2->setDataByName("type", "Hallmark");
  9467. packet2->setDataByName("complete_header", "To complete this quest, I must do the following tasks:");
  9468. packet2->setDataByName("day", 19);
  9469. packet2->setDataByName("month", 6);
  9470. packet2->setDataByName("year", 20);
  9471. packet2->setDataByName("level", 2);
  9472. packet2->setDataByName("encounter_level", 4);
  9473. packet2->setDataByName("difficulty", 3);
  9474. packet2->setDataByName("time_obtained", Timer::GetUnixTimeStamp());
  9475. packet2->setDataByName("timer_start", Timer::GetUnixTimeStamp());
  9476. packet2->setDataByName("timer_duration", 300);
  9477. packet2->setDataByName("timer_running", 1);
  9478. packet2->setArrayLengthByName("task_groups_completed", 0);
  9479. packet2->setArrayLengthByName("num_task_groups", 1);
  9480. packet2->setArrayDataByName("task_group", "I need to talk to Garven Tralk");
  9481. packet2->setSubArrayLengthByName("num_tasks", 1);
  9482. packet2->setSubArrayDataByName("task", "I need to talk to Garven Tralk");
  9483. packet2->setSubArrayLengthByName("num_updates", 1);
  9484. packet2->setSubArrayDataByName("update_currentval", 0);
  9485. packet2->setSubArrayDataByName("update_maxval", 1);
  9486. packet2->setSubArrayDataByName("icon", 11);
  9487. packet2->setArrayDataByName("waypoint", 0xFFFFFFFF);
  9488. packet2->setDataByName("journal_updated", 1);
  9489. packet2->setSubstructDataByName("reward_data", "unknown1", 255);
  9490. packet2->setSubstructDataByName("reward_data", "reward", "Quest Reward!");
  9491. packet2->setSubstructDataByName("reward_data", "unknown2", 0x3f);
  9492. packet2->setSubstructDataByName("reward_data", "coin", 150);
  9493. packet2->setSubstructDataByName("reward_data", "status_points", 5);
  9494. packet2->setSubstructDataByName("reward_data", "exp_bonus", 10);
  9495. packet2->setSubstructArrayLengthByName("reward_data", "num_rewards", 1);
  9496. packet2->setSubstructArrayDataByName("reward_data", "reward_id", 123);
  9497. Item* item = master_item_list.GetItem(152755);
  9498. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9499. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  9500. /*packet2->setSubstructDataByName("item", "unique_id", 567);
  9501. packet2->setSubstructDataByName("item", "broker_item_id", 0xFFFFFFFFFFFFFFFF);
  9502. packet2->setSubstructDataByName("item", "icon", 0xe7);
  9503. packet2->setSubstructDataByName("item", "tier", 4);
  9504. packet2->setSubstructDataByName("item", "flags", 0x60);
  9505. packet2->setSubstructArrayLengthByName("item", "stat_count", 1);
  9506. packet2->setSubstructDataByName("item", "stat_type", 1);
  9507. packet2->setSubstructDataByName("item", "stat_subtype", 2);
  9508. packet2->setSubstructDataByName("item", "value", 3);
  9509. packet2->setSubstructDataByName("item", "condition", 100);
  9510. packet2->setSubstructDataByName("item", "weight", 1);
  9511. packet2->setSubstructDataByName("item", "skill_req1", 0xacafa99e);
  9512. packet2->setSubstructDataByName("item", "skill_req2", 0xacafa99e);
  9513. packet2->setSubstructDataByName("item", "skill_min", 1);
  9514. packet2->setSubstructArrayLengthByName("item", "class_count", 3);
  9515. packet2->setSubstructDataByName("item", "adventure_class", 1);
  9516. packet2->setSubstructDataByName("item", "adventure_class", 11, 0, 1);
  9517. packet2->setSubstructDataByName("item", "adventure_class", 0x1f, 0, 2);
  9518. packet2->setSubstructDataByName("item", "tradeskill_class", 255);
  9519. packet2->setSubstructDataByName("item", "tradeskill_class", 255, 0, 1);
  9520. packet2->setSubstructDataByName("item", "tradeskill_class", 255, 0, 2);
  9521. packet2->setSubstructDataByName("item", "level", 0x1e);
  9522. packet2->setSubstructDataByName("item", "level", 100, 0, 1);
  9523. packet2->setSubstructDataByName("item", "level", 100, 0, 2);
  9524. packet2->setSubstructDataByName("item_footer", "name", "Footman Gloves");*/
  9525. //packet2->PrintPacket();
  9526. EQ2Packet* app = packet2->serialize();
  9527. if (sep->IsSet(2)) {
  9528. int16 offset = atoi(sep->arg[1]);
  9529. uchar* ptr2 = app->pBuffer;
  9530. ptr2 += offset;
  9531. if (sep->IsNumber(2)) {
  9532. int32 value1 = atol(sep->arg[2]);
  9533. if (value1 > 0xFFFF)
  9534. memcpy(ptr2, (uchar*)&value1, 4);
  9535. else if (value1 > 0xFF)
  9536. memcpy(ptr2, (uchar*)&value1, 2);
  9537. else
  9538. memcpy(ptr2, (uchar*)&value1, 1);
  9539. }
  9540. else {
  9541. int16 len = strlen(sep->arg[2]);
  9542. memcpy(ptr2, (uchar*)&len, 2);
  9543. ptr2 += 2;
  9544. memcpy(ptr2, sep->arg[2], len);
  9545. }
  9546. }
  9547. DumpPacket(app);
  9548. client->QueuePacket(app);
  9549. safe_delete(packet2);
  9550. }
  9551. }
  9552. else if (atoi(sep->arg[0]) == 13) {
  9553. PacketStruct* packet2 = configReader.getStruct("WS_OnScreenMsg", client->GetVersion());
  9554. if (packet2 && sep->IsSet(7)) {
  9555. packet2->setDataByName("unknown", atoi(sep->arg[1]));
  9556. char blah[128];
  9557. sprintf(blah, "\\#6EFF6EYou get better at \12\\#C8FFC8%s\\#6EFF6E! (7/15)", sep->arg[2]);
  9558. packet2->setDataByName("text", blah);
  9559. packet2->setDataByName("message_type", sep->arg[3]);
  9560. packet2->setDataByName("size", atof(sep->arg[4]));
  9561. packet2->setDataByName("red", atoi(sep->arg[5]));
  9562. packet2->setDataByName("green", atoi(sep->arg[6]));
  9563. packet2->setDataByName("blue", atoi(sep->arg[7]));
  9564. EQ2Packet* app = packet2->serialize();
  9565. DumpPacket(app);
  9566. client->QueuePacket(app);
  9567. safe_delete(packet2);
  9568. }
  9569. }
  9570. else if (atoi(sep->arg[0]) == 14) {
  9571. PacketStruct* packet2 = configReader.getStruct("WS_InstructionWindow", client->GetVersion());
  9572. if (packet2 && sep->IsSet(3)) {
  9573. packet2->setDataByName("open_seconds_min", atof(sep->arg[1]));
  9574. packet2->setDataByName("open_seconds_max", atof(sep->arg[2]));
  9575. packet2->setDataByName("voice_sync", atoi(sep->arg[3]));
  9576. 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.");
  9577. packet2->setDataByName("voice", "voiceover/english/narrator/boat_06p_tutorial02/narrator_001_63779ca0.mp3");
  9578. packet2->setArrayLengthByName("num_goals", 1);
  9579. //packet2->setArrayDataByName("goal_text", )
  9580. packet2->setSubArrayLengthByName("num_tasks", 1);
  9581. packet2->setSubArrayDataByName("task_text", "continue");
  9582. packet2->setDataByName("complete_sound", "click");
  9583. packet2->setDataByName("signal", "introduction");
  9584. packet2->setDataByName("voice_key1", 0xcda65173);
  9585. packet2->setDataByName("voice_key2", 0x984bfc6d);
  9586. EQ2Packet* app = packet2->serialize();
  9587. DumpPacket(app);
  9588. client->QueuePacket(app);
  9589. safe_delete(packet2);
  9590. packet2 = configReader.getStruct("WS_ShowWindow", client->GetVersion());
  9591. packet2->setDataByName("window", "MainHUD.StartMenu");
  9592. packet2->setDataByName("show", 1);
  9593. app = packet2->serialize();
  9594. DumpPacket(app);
  9595. client->QueuePacket(app);
  9596. safe_delete(packet2);
  9597. packet2 = configReader.getStruct("WS_FlashWindow", client->GetVersion());
  9598. packet2->setDataByName("window", "MainHUD.StartMenu.help");
  9599. packet2->setDataByName("flash_seconds", 10);
  9600. app = packet2->serialize();
  9601. DumpPacket(app);
  9602. client->QueuePacket(app);
  9603. safe_delete(packet2);
  9604. }
  9605. }
  9606. else if (atoi(sep->arg[0]) == 15) {
  9607. PacketStruct* packet2 = configReader.getStruct("WS_UpdateLoot", client->GetVersion());
  9608. if (packet2) {
  9609. packet2->setArrayLengthByName("loot_count", 1);
  9610. packet2->setArrayDataByName("name", "Test");
  9611. packet2->setArrayDataByName("item_id", 1234);
  9612. packet2->setArrayDataByName("count", 1);
  9613. packet2->setArrayDataByName("icon", 258);
  9614. packet2->setArrayDataByName("ability_id", 0xFFFFFFFF);
  9615. Spawn* spawn = client->GetPlayer()->GetTarget();
  9616. if (spawn)
  9617. packet2->setDataByName("object_id", client->GetPlayer()->GetIDWithPlayerSpawn(spawn));
  9618. packet2->setDataByName("unknown3", 1);
  9619. packet2->setDataByName("unknown4", 1);
  9620. packet2->setDataByName("unknown5", 60);
  9621. EQ2Packet* app = packet2->serialize();
  9622. DumpPacket(app);
  9623. client->QueuePacket(app);
  9624. safe_delete(packet2);
  9625. }
  9626. }
  9627. else if (atoi(sep->arg[0]) == 16 && sep->IsNumber(1)) {
  9628. char blah[32];
  9629. sprintf(blah, "Testing: %i", atoi(sep->arg[1]));
  9630. client->SimpleMessage(atoi(sep->arg[1]), blah);
  9631. }
  9632. else if (atoi(sep->arg[0]) == 17 && sep->IsNumber(2)) {
  9633. if (sep->IsSet(2)) {
  9634. int16 offset = atoi(sep->arg[1]);
  9635. if (sep->IsNumber(2)) {
  9636. int32 value1 = atol(sep->arg[2]);
  9637. client->QueuePacket(client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion(), offset, value1));
  9638. cout << "Sent" << endl;
  9639. }
  9640. }
  9641. }
  9642. else if (atoi(sep->arg[0]) == 18) {
  9643. PacketStruct* packet2 = configReader.getStruct("WS_QuestRewardPackMsg", client->GetVersion());
  9644. if (packet2) {
  9645. packet2->setSubstructDataByName("reward_data", "unknown1", 255);
  9646. packet2->setSubstructDataByName("reward_data", "reward", "Quest Reward!");
  9647. packet2->setSubstructDataByName("reward_data", "max_coin", 0);
  9648. packet2->setSubstructDataByName("reward_data", "text", "Some custom text to mess things up?");
  9649. //packet2->setSubstructDataByName("reward_data", "status_points", 5);
  9650. //packet2->setSubstructDataByName("reward_data", "exp_bonus", 10);
  9651. packet2->setSubstructArrayLengthByName("reward_data", "num_rewards", 1);
  9652. Item* item = new Item(master_item_list.GetItem(9357));
  9653. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9654. //item->stack_count = 20;
  9655. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  9656. safe_delete(item);
  9657. /*item = new Item(master_item_list.GetItem(36685));
  9658. item->stack_count = 20;
  9659. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9660. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 1, 0, -1);
  9661. safe_delete(item);
  9662. item = master_item_list.GetItem(1414);
  9663. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9664. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 2, 0, -1);
  9665. item = master_item_list.GetItem(75057);
  9666. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9667. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 3, 0, -1);*/
  9668. EQ2Packet* app = packet2->serialize();
  9669. if (sep->IsSet(2)) {
  9670. int16 offset = atoi(sep->arg[1]);
  9671. uchar* ptr2 = app->pBuffer;
  9672. ptr2 += offset;
  9673. if (sep->IsNumber(2)) {
  9674. int32 value1 = atol(sep->arg[2]);
  9675. if (value1 > 0xFFFF)
  9676. memcpy(ptr2, (uchar*)&value1, 4);
  9677. else if (value1 > 0xFF)
  9678. memcpy(ptr2, (uchar*)&value1, 2);
  9679. else
  9680. memcpy(ptr2, (uchar*)&value1, 1);
  9681. }
  9682. else {
  9683. int16 len = strlen(sep->arg[2]);
  9684. memcpy(ptr2, (uchar*)&len, 2);
  9685. ptr2 += 2;
  9686. memcpy(ptr2, sep->arg[2], len);
  9687. }
  9688. }
  9689. DumpPacket(app);
  9690. client->QueuePacket(app);
  9691. safe_delete(packet2);
  9692. }
  9693. }
  9694. else if (atoi(sep->arg[0]) == 19) {
  9695. PacketStruct* packet2 = configReader.getStruct("WS_UpdateLoot", client->GetVersion());
  9696. Spawn* spawn = client->GetPlayer()->GetTarget();
  9697. if (packet2 && spawn) {
  9698. Item* item = master_item_list.GetItem(130053);
  9699. packet2->setArrayLengthByName("loot_count", 1);
  9700. packet2->setArrayDataByName("loot_id", item->details.item_id);
  9701. packet2->setArrayDataByName("unknown2", 1);
  9702. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, 2, true);
  9703. packet2->setDataByName("display", 1);
  9704. packet2->setDataByName("unknown2b", 1);
  9705. packet2->setDataByName("unknown3", 0x3c);
  9706. packet2->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(spawn));
  9707. packet2->PrintPacket();
  9708. EQ2Packet* app = packet2->serialize();
  9709. if (sep->IsSet(2)) {
  9710. int16 offset = atoi(sep->arg[1]);
  9711. int16 offset2 = 0;
  9712. int32 value1 = 0;
  9713. if (sep->IsSet(3)) {
  9714. offset2 = atoi(sep->arg[2]);
  9715. value1 = atol(sep->arg[3]);
  9716. }
  9717. else
  9718. value1 = atol(sep->arg[2]);
  9719. int16 offset3 = 0;
  9720. int16 offset4 = 0;
  9721. int32 value2 = 0;
  9722. if (sep->IsSet(6)) {
  9723. offset3 = atoi(sep->arg[4]);
  9724. offset4 = atoi(sep->arg[5]);
  9725. value2 = atol(sep->arg[6]);
  9726. }
  9727. offset--;
  9728. if (offset2 > 0 && offset2 >= offset) {
  9729. offset2--;
  9730. uchar* ptr2 = app->pBuffer;
  9731. ptr2 += offset;
  9732. for (int i = offset; i <= offset2; i++) {
  9733. if (value1 > 0xFFFF) {
  9734. memcpy(ptr2, (uchar*)&value1, 4);
  9735. i += 3;
  9736. ptr2 += 3;
  9737. }
  9738. else if (value1 > 0xFF) {
  9739. memcpy(ptr2, (uchar*)&value1, 2);
  9740. i++;
  9741. ptr2++;
  9742. }
  9743. else
  9744. memcpy(ptr2, (uchar*)&value1, 1);
  9745. ptr2++;
  9746. }
  9747. }
  9748. if (offset4 > 0 && offset4 >= offset3) {
  9749. offset3--;
  9750. offset4--;
  9751. uchar* ptr2 = app->pBuffer;
  9752. ptr2 += offset3;
  9753. for (int i = offset3; i <= offset4; i++) {
  9754. if (value2 > 0xFFFF) {
  9755. memcpy(ptr2, (uchar*)&value2, 4);
  9756. i += 3;
  9757. ptr2 += 3;
  9758. }
  9759. else if (value2 > 0xFF) {
  9760. memcpy(ptr2, (uchar*)&value2, 2);
  9761. i++;
  9762. ptr2++;
  9763. }
  9764. else
  9765. memcpy(ptr2, (uchar*)&value2, 1);
  9766. ptr2++;
  9767. }
  9768. }
  9769. }
  9770. DumpPacket(app);
  9771. client->QueuePacket(app);
  9772. safe_delete(packet2);
  9773. }
  9774. }
  9775. else if (atoi(sep->arg[0]) == 21) {
  9776. PacketStruct* packet2 = configReader.getStruct("WS_OfferQuest", client->GetVersion());
  9777. if (packet2) {
  9778. packet2->setDataByName("unknown0", 255);
  9779. packet2->setDataByName("reward", "New Quest");
  9780. packet2->setDataByName("title", "Title");
  9781. packet2->setDataByName("description", "description");
  9782. packet2->setDataByName("quest_difficulty", 3);
  9783. packet2->setDataByName("unknown1", 5);
  9784. packet2->setDataByName("level", 3);
  9785. packet2->setDataByName("coin", 150);
  9786. packet2->setDataByName("status_points", 5);
  9787. packet2->setDataByName("exp_bonus", 10);
  9788. packet2->setArrayLengthByName("num_rewards", 1);
  9789. Item* item = new Item(master_item_list.GetItem(36212));
  9790. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9791. item->stack_count = 20;
  9792. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  9793. safe_delete(item);
  9794. char accept[35] = { 0 };
  9795. char decline[35] = { 0 };
  9796. sprintf(accept, "q_accept_pending_quest %u", 0);
  9797. sprintf(decline, "q_deny_pending_quest %u", 0);
  9798. packet2->setDataByName("accept_command", accept);
  9799. packet2->setDataByName("decline_command", decline);
  9800. EQ2Packet* app = packet2->serialize();
  9801. if (sep->IsSet(2)) {
  9802. int16 offset = atoi(sep->arg[1]);
  9803. uchar* ptr2 = app->pBuffer;
  9804. ptr2 += offset;
  9805. if (sep->IsNumber(2)) {
  9806. int32 value1 = atol(sep->arg[2]);
  9807. if (value1 > 0xFFFF)
  9808. memcpy(ptr2, (uchar*)&value1, 4);
  9809. else if (value1 > 0xFF)
  9810. memcpy(ptr2, (uchar*)&value1, 2);
  9811. else
  9812. memcpy(ptr2, (uchar*)&value1, 1);
  9813. }
  9814. DumpPacket(app);
  9815. client->QueuePacket(app);
  9816. safe_delete(packet2);
  9817. }
  9818. }
  9819. }
  9820. else if (atoi(sep->arg[0]) == 22) { //same as 21, but 8bit string
  9821. PacketStruct* packet2 = configReader.getStruct("WS_OfferQuest", client->GetVersion());
  9822. if (packet2) {
  9823. packet2->setDataByName("unknown0", 255);
  9824. packet2->setDataByName("reward", "New Quest");
  9825. packet2->setDataByName("title", "Title");
  9826. packet2->setDataByName("description", "description");
  9827. packet2->setDataByName("quest_difficulty", 3);
  9828. packet2->setDataByName("unknown1", 5);
  9829. packet2->setDataByName("level", 3);
  9830. packet2->setDataByName("coin", 150);
  9831. packet2->setDataByName("status_points", 5);
  9832. packet2->setDataByName("exp_bonus", 10);
  9833. packet2->setArrayLengthByName("num_rewards", 1);
  9834. Item* item = new Item(master_item_list.GetItem(36212));
  9835. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9836. item->stack_count = 20;
  9837. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  9838. safe_delete(item);
  9839. char accept[35] = { 0 };
  9840. char decline[35] = { 0 };
  9841. sprintf(accept, "q_accept_pending_quest %u", 0);
  9842. sprintf(decline, "q_deny_pending_quest %u", 0);
  9843. packet2->setDataByName("accept_command", accept);
  9844. packet2->setDataByName("decline_command", decline);
  9845. EQ2Packet* app = packet2->serialize();
  9846. if (sep->IsSet(2)) {
  9847. int16 offset = atoi(sep->arg[1]);
  9848. uchar* ptr2 = app->pBuffer;
  9849. ptr2 += offset;
  9850. if (sep->IsNumber(2)) {
  9851. int32 value1 = atol(sep->arg[2]);
  9852. if (value1 > 0xFFFF)
  9853. memcpy(ptr2, (uchar*)&value1, 4);
  9854. else if (value1 > 0xFF)
  9855. memcpy(ptr2, (uchar*)&value1, 2);
  9856. else
  9857. memcpy(ptr2, (uchar*)&value1, 1);
  9858. }
  9859. else {
  9860. int8 len = strlen(sep->arg[2]);
  9861. memcpy(ptr2, (uchar*)&len, 1);
  9862. ptr2 += 1;
  9863. memcpy(ptr2, sep->arg[2], len);
  9864. }
  9865. }
  9866. DumpPacket(app);
  9867. client->QueuePacket(app);
  9868. safe_delete(packet2);
  9869. }
  9870. }
  9871. else if (atoi(sep->arg[0]) == 23) {
  9872. if (client->GetPlayer()->GetTarget()) {
  9873. PacketStruct* packet2 = configReader.getStruct("WS_UpdateMerchant", client->GetVersion());
  9874. if (packet2) {
  9875. Spawn* target = client->GetPlayer()->GetTarget();
  9876. packet2->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(target));
  9877. Item* item = new Item(master_item_list.GetItem(12565));
  9878. int8 i = 0;
  9879. packet2->setArrayLengthByName("num_items", 1);
  9880. packet2->setArrayDataByName("item_name", item->name.c_str(), i);
  9881. packet2->setArrayDataByName("item_id", item->details.item_id, i);
  9882. packet2->setArrayDataByName("stack_size", item->stack_count, i);
  9883. packet2->setArrayDataByName("icon", item->details.icon, i);
  9884. int8 tmp_level = 0;
  9885. if (item->generic_info.adventure_default_level > 0)
  9886. tmp_level = item->generic_info.adventure_default_level;
  9887. else
  9888. tmp_level = item->generic_info.tradeskill_default_level;
  9889. packet2->setArrayDataByName("level", tmp_level, i);
  9890. packet2->setArrayDataByName("tier", item->details.tier, i);
  9891. packet2->setArrayDataByName("item_id2", item->details.item_id, i);
  9892. int8 item_difficulty = client->GetPlayer()->GetArrowColor(tmp_level);
  9893. if (item_difficulty != ARROW_COLOR_WHITE && item_difficulty != ARROW_COLOR_RED && item_difficulty != ARROW_COLOR_GRAY)
  9894. item_difficulty = ARROW_COLOR_WHITE;
  9895. item_difficulty -= 6;
  9896. if (item_difficulty < 0)
  9897. item_difficulty *= -1;
  9898. packet2->setArrayDataByName("item_difficulty", item_difficulty, i);
  9899. packet2->setArrayDataByName("quantity", 2, i);
  9900. packet2->setArrayDataByName("unknown5", 255, i);
  9901. packet2->setArrayDataByName("stack_size2", item->stack_count, i);
  9902. packet2->setArrayDataByName("description", item->description.c_str(), i);
  9903. packet2->setDataByName("type", 2);
  9904. EQ2Packet* app = packet2->serialize();
  9905. if (sep->IsSet(2)) {
  9906. int16 offset = atoi(sep->arg[1]);
  9907. uchar* ptr2 = app->pBuffer;
  9908. ptr2 += offset;
  9909. if (sep->IsNumber(2)) {
  9910. int32 value1 = atol(sep->arg[2]);
  9911. if (value1 > 0xFFFF)
  9912. memcpy(ptr2, (uchar*)&value1, 4);
  9913. else if (value1 > 0xFF)
  9914. memcpy(ptr2, (uchar*)&value1, 2);
  9915. else
  9916. memcpy(ptr2, (uchar*)&value1, 1);
  9917. }
  9918. else {
  9919. int8 len = strlen(sep->arg[2]);
  9920. memcpy(ptr2, (uchar*)&len, 1);
  9921. ptr2 += 1;
  9922. memcpy(ptr2, sep->arg[2], len);
  9923. }
  9924. }
  9925. DumpPacket(app);
  9926. client->QueuePacket(app);
  9927. safe_delete(packet2);
  9928. }
  9929. }
  9930. }
  9931. else if (atoi(sep->arg[0]) == 24) {
  9932. PacketStruct* packet2 = configReader.getStruct("WS_EnableGameEvent", client->GetVersion());
  9933. if (packet2) {
  9934. if (sep->IsSet(2)) {
  9935. packet2->setDataByName("event_name", sep->arg[1]);
  9936. packet2->setDataByName("enabled", atoi(sep->arg[2]));
  9937. EQ2Packet* app = packet2->serialize();
  9938. DumpPacket(app);
  9939. client->QueuePacket(app);
  9940. safe_delete(packet2);
  9941. }
  9942. }
  9943. }
  9944. else if (atoi(sep->arg[0]) == 25) {
  9945. if (sep->IsSet(1)) {
  9946. Widget* new_spawn = new Widget();
  9947. int32 id = atoul(sep->arg[1]);
  9948. new_spawn->SetWidgetID(id);
  9949. EQ2Packet* ret = new_spawn->serialize(client->GetPlayer(), client->GetVersion());
  9950. client->QueuePacket(ret);
  9951. int8 index = client->GetPlayer()->GetIndexForSpawn(new_spawn);
  9952. PacketStruct* packet2 = configReader.getStruct("WS_DestroyGhostCmd", client->GetVersion());
  9953. if (packet2) {
  9954. packet2->setDataByName("spawn_index", index);
  9955. packet2->setDataByName("delete", 1);
  9956. EQ2Packet* app = packet2->serialize();
  9957. client->QueuePacket(app);
  9958. safe_delete(packet2);
  9959. }
  9960. }
  9961. }
  9962. else if (atoi(sep->arg[0]) == 26) {
  9963. if (sep->IsSet(4)) {
  9964. Widget* new_spawn = new Widget();
  9965. int32 id = atoul(sep->arg[1]);
  9966. new_spawn->SetWidgetID(id);
  9967. float x = atof(sep->arg[2]);
  9968. float y = atof(sep->arg[3]);
  9969. float z = atof(sep->arg[4]);
  9970. new_spawn->SetLocation(client->GetPlayer()->GetLocation());
  9971. new_spawn->SetWidgetX(x);
  9972. new_spawn->SetWidgetY(y);
  9973. new_spawn->SetWidgetZ(z);
  9974. new_spawn->SetX(x);
  9975. new_spawn->SetY(y);
  9976. new_spawn->SetZ(z);
  9977. EQ2Packet* ret = new_spawn->serialize(client->GetPlayer(), client->GetVersion());
  9978. client->QueuePacket(ret);
  9979. }
  9980. }
  9981. else if (atoi(sep->arg[0]) == 27) {
  9982. Spawn* target = client->GetPlayer()->GetTarget();
  9983. PacketStruct* packet2 = configReader.getStruct("WS_HearSimpleDamage", client->GetVersion());
  9984. if (packet2 && target && sep->IsSet(4)) {
  9985. 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] : "");
  9986. }
  9987. }
  9988. else if (atoi(sep->arg[0]) == 28 && sep->IsNumber(1)) {
  9989. World::newValue = strtoull(sep->arg[1], NULL, 0);
  9990. }
  9991. else if (atoi(sep->arg[0]) == 29 && sep->IsNumber(1)) {
  9992. client->SendHearCast(client->GetPlayer(), client->GetPlayer()->GetTarget() ? client->GetPlayer()->GetTarget() : client->GetPlayer(),
  9993. strtoull(sep->arg[1], NULL, 0), atoul(sep->arg[2]));
  9994. }
  9995. else if (atoi(sep->arg[0]) == 30) {
  9996. PacketStruct* packet = configReader.getStruct("WS_UpdateSkillBook", client->GetVersion());
  9997. if (packet) {
  9998. packet->setDataByName("unknown", World::newValue);
  9999. EQ2Packet* outapp = packet->serialize();
  10000. DumpPacket(outapp);
  10001. client->QueuePacket(outapp);
  10002. safe_delete(packet);
  10003. }
  10004. }
  10005. else if (atoi(sep->arg[0]) == 31) {
  10006. client->SendRecipeList();
  10007. }
  10008. else if (atoi(sep->arg[0]) == 32 && sep->IsNumber(1) && sep->IsNumber(2)) {
  10009. if(client->GetVersion() <= 546) {
  10010. int32 param = atoul(sep->arg[1]);
  10011. int32 paramvalue = atoul(sep->arg[2]);
  10012. client->Message(CHANNEL_COLOR_YELLOW, "Send control flag param %u param value %u", param, paramvalue);
  10013. ClientPacketFunctions::SendServerControlFlagsClassic(client, param, paramvalue);
  10014. }
  10015. else if(sep->IsNumber(3)) {
  10016. int8 param1 = atoul(sep->arg[1]);
  10017. int8 param2 = atoul(sep->arg[2]);
  10018. int8 paramval = atoul(sep->arg[3]);
  10019. client->Message(CHANNEL_COLOR_YELLOW, "Send control flag param1 %u param2 %u param value %u", param1, param2, paramval);
  10020. ClientPacketFunctions::SendServerControlFlags(client, param1, param2, paramval);
  10021. }
  10022. }
  10023. else if (atoi(sep->arg[0]) == 33 && sep->IsNumber(1) && sep->IsNumber(2)) {
  10024. client->GetCurrentZone()->SendHealPacket(client->GetPlayer(), client->GetPlayer()->GetTarget() ? client->GetPlayer()->GetTarget() : client->GetPlayer(),
  10025. atoul(sep->arg[1]), atoul(sep->arg[2]), "TestSpell");
  10026. }
  10027. }
  10028. else {
  10029. PacketStruct* packet2 = configReader.getStruct("WS_ExamineSpellInfo", client->GetVersion());
  10030. if (packet2) {
  10031. packet2->setSubstructDataByName("info_header", "show_name", 1);
  10032. packet2->setSubstructDataByName("info_header", "unknown", 7);
  10033. packet2->setSubstructDataByName("info_header", "unknown2", 1);
  10034. packet2->setSubstructDataByName("info_header", "unknown3", 1);
  10035. packet2->setSubstructDataByName("info_header", "unknown4", 1);
  10036. packet2->setSubstructDataByName("info_header", "unknown5", 1);
  10037. packet2->setSubstructDataByName("info_header", "unknown6", "Testing");
  10038. packet2->setSubstructDataByName("info_header", "unknown7", "Testing");
  10039. packet2->setSubstructDataByName("info_header", "unknown8", 66);
  10040. packet2->setSubstructDataByName("info_header", "title", "Blah Title Blah");
  10041. packet2->setSubstructDataByName("info_header", "title_text", "Blah Blah");
  10042. packet2->setSubstructDataByName("info_header", "title_text2", "Blah Blah2");
  10043. packet2->setSubstructDataByName("info_header", "show_popup", 1);
  10044. packet2->setSubstructDataByName("info_header", "packettype", 3);
  10045. packet2->setSubstructDataByName("spell_info", "skill_name", "Testing");
  10046. packet2->setSubstructDataByName("spell_info", "level", 19);
  10047. packet2->setSubstructDataByName("spell_info", "tier", 1);
  10048. packet2->setSubstructDataByName("spell_info", "health_cost", 5);
  10049. packet2->setSubstructDataByName("spell_info", "min_class_skill_req", 3);
  10050. packet2->setSubstructDataByName("spell_info", "mana_cost", 6);
  10051. packet2->setSubstructDataByName("spell_info", "req_concentration", 7);
  10052. packet2->setSubstructDataByName("spell_info", "cast_time", 200);
  10053. packet2->setSubstructDataByName("spell_info", "recovery", 220);
  10054. packet2->setSubstructDataByName("spell_info", "recast", 280);
  10055. packet2->setSubstructDataByName("spell_info", "beneficial", 1);
  10056. packet2->setSubstructDataByName("spell_info", "maintained", 1);
  10057. packet2->setSubstructDataByName("spell_info", "spell_book_type", 1);
  10058. packet2->setSubstructDataByName("spell_info", "quality", 3);
  10059. packet2->setSubstructDataByName("spell_info", "test_1a", 1);
  10060. packet2->setSubstructDataByName("spell_info", "test_1b", 1);
  10061. packet2->setSubstructDataByName("spell_info", "test_1c", 1);
  10062. packet2->setSubstructDataByName("spell_info", "test_1d", 1);
  10063. packet2->setSubstructDataByName("spell_info", "test_2a", 2);
  10064. packet2->setSubstructDataByName("spell_info", "test_2b", 2);
  10065. packet2->setSubstructDataByName("spell_info", "test_2c", 2);
  10066. packet2->setSubstructDataByName("spell_info", "test_2d", 2);
  10067. packet2->setSubstructDataByName("spell_info", "test_3", 3);
  10068. packet2->setSubstructDataByName("spell_info", "test_4", 4);
  10069. packet2->setSubstructDataByName("spell_info", "test_5", 5);
  10070. packet2->setSubstructDataByName("spell_info", "test_6", 6);
  10071. packet2->setSubstructDataByName("spell_info", "min_class_skill_req", 1);
  10072. packet2->setSubstructDataByName("spell_info", "min_class_skill_rec", 30123);
  10073. packet2->setSubstructDataByName("spell_info", "num_reagents", 1);
  10074. packet2->setSubstructArrayLengthByName("spell_info", "num_reagents", 1);
  10075. packet2->setArrayDataByName("reagent", "Alcohol");
  10076. packet2->setArrayDataByName("consumed", "123");
  10077. packet2->setSubstructDataByName("spell_info", "class_skill", 52);
  10078. packet2->setSubstructDataByName("spell_info", "id", 8308);
  10079. packet2->setSubstructDataByName("spell_info", "icon", 303);
  10080. packet2->setSubstructDataByName("spell_info", "icon2", 0xFFFF);
  10081. packet2->setSubstructDataByName("spell_info", "icontype", 317);
  10082. packet2->setSubstructDataByName("spell_info", "type", 2);
  10083. packet2->setSubstructDataByName("spell_info", "spell_text_color", 255);
  10084. packet2->setSubstructDataByName("spell_info", "duration1", 600);
  10085. packet2->setSubstructDataByName("spell_info", "duration2", 600);
  10086. packet2->setSubstructDataByName("spell_info", "name", "Sprint");
  10087. packet2->setSubstructDataByName("spell_info", "description", "Test description");
  10088. EQ2Packet* outapp = packet2->serialize();
  10089. DumpPacket(outapp);
  10090. client->QueuePacket(outapp);
  10091. safe_delete(packet2);
  10092. }
  10093. }
  10094. return;
  10095. PacketStruct* p = configReader.getStruct("WS_EqTargetItemCmd", client->GetVersion());
  10096. if (!p) return;
  10097. //Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  10098. //client->GetCurrentZone()->SendSpellFailedPacket(client, atoi(sep2->arg[0]));
  10099. //}
  10100. /*Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  10101. if (sep2 && sep2->arg[0] && sep2->IsNumber(0)) {
  10102. client->SetPendingFlightPath(atoi(sep2->arg[0]));
  10103. PacketStruct* packet = configReader.getStruct("WS_ReadyForTakeOff", client->GetVersion());
  10104. if (packet) {
  10105. client->QueuePacket(packet->serialize());
  10106. safe_delete(packet);
  10107. }
  10108. }*/
  10109. /*if (client->GetCurrentZone()->Grid != nullptr) {
  10110. int32 numFaces = 0;
  10111. int32 numGrids = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.size();
  10112. client->Message(CHANNEL_COLOR_YELLOW, "Num grids in cell: %u", numGrids);
  10113. map<int32, vector<Face*> >::iterator itr;
  10114. for (itr = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.begin(); itr != client->GetPlayer()->Cell_Info.CurrentCell->FaceList.end(); itr++)
  10115. numFaces += (*itr).second.size();
  10116. client->Message(CHANNEL_COLOR_YELLOW, "Num faces in cell: %u", numFaces);
  10117. }*/
  10118. //uchar blah[] = {
  10119. // 1208 - OP_EQUpdateStoreCmd
  10120. // /*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
  10121. // /*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
  10122. // 1193 - -- OP_ClientCmdMsg::OP_EqUpdateMerchantCmd --
  10123. // /*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
  10124. /*};
  10125. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  10126. int8 val = 0;
  10127. int16 pos = 0;
  10128. int idx = 0;
  10129. while(sep2 && sep2->arg[idx+1] && sep2->IsNumber(idx) && sep2->IsNumber(idx+1)){
  10130. pos = atoi(sep2->arg[idx]);
  10131. val = atoi(sep2->arg[idx+1]);
  10132. memset(blah+pos, val, 1);
  10133. idx+=2;
  10134. }
  10135. DumpPacket(blah, sizeof(blah));
  10136. client->QueuePacket(new EQ2Packet(OP_GroupCreatedMsg , blah, sizeof(blah)));*/
  10137. if (client->GetPlayer()->GetTarget()) {
  10138. PacketStruct* packet = configReader.getStruct("WS_SetControlGhost", client->GetVersion());
  10139. if (packet) {
  10140. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  10141. packet->setDataByName("size", 0);
  10142. packet->setDataByName("unknown2", 0);
  10143. EQ2Packet* app = packet->serialize();
  10144. client->QueuePacket(app);
  10145. safe_delete(packet);
  10146. }
  10147. PacketStruct* set_pov = configReader.getStruct("WS_SetPOVGhostCmd", client->GetVersion());
  10148. if (set_pov) {
  10149. set_pov->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  10150. EQ2Packet* app_pov = set_pov->serialize();
  10151. client->QueuePacket(app_pov);
  10152. safe_delete(set_pov);
  10153. }
  10154. }
  10155. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  10156. PacketStruct* packet = configReader.getStruct("WS_OpenCharCust", client->GetVersion());
  10157. if (packet) {
  10158. if (sep2 && sep2->arg[0] && sep2->IsNumber(0))
  10159. packet->setDataByName("Type", atoi(sep2->arg[0]));
  10160. else
  10161. packet->setDataByName("Type", 2);
  10162. if (sep2 && sep2->arg[1] && sep2->IsNumber(1))
  10163. packet->setDataByName("race_id", atoi(sep2->arg[1]));
  10164. else
  10165. packet->setDataByName("race_id", 0);
  10166. if (sep2 && sep2->arg[2] && sep2->IsNumber(2))
  10167. packet->setDataByName("gender", atoi(sep2->arg[2]));
  10168. else
  10169. packet->setDataByName("gender", 2);
  10170. if (sep2 && sep2->arg[3] && sep2->IsNumber(3))
  10171. packet->setDataByName("unknown", atoi(sep2->arg[3]), 0);
  10172. else
  10173. packet->setDataByName("unknown", 0, 0);
  10174. if (sep2 && sep2->arg[4] && sep2->IsNumber(4))
  10175. packet->setDataByName("unknown", atoi(sep2->arg[4]), 1);
  10176. else
  10177. packet->setDataByName("unknown", 0, 1);
  10178. if (sep2 && sep2->arg[5] && sep2->IsNumber(5))
  10179. packet->setDataByName("unknown", atoi(sep2->arg[5]), 2);
  10180. else
  10181. packet->setDataByName("unknown", 0, 2);
  10182. client->QueuePacket(packet->serialize());
  10183. }
  10184. safe_delete(packet);
  10185. safe_delete(sep2);
  10186. }
  10187. void Commands::Command_LeaveChannel(Client *client, Seperator *sep) {
  10188. const char *channel_name;
  10189. if (sep == NULL || !sep->IsSet(0)) {
  10190. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /leavechat <channel name>");
  10191. PrintSep(sep);
  10192. return;
  10193. }
  10194. channel_name = sep->arg[0];
  10195. if (!chat.IsInChannel(client, channel_name))
  10196. client->Message(CHANNEL_NARRATIVE, "Unable to leave '%s': You are not in the channel.", channel_name);
  10197. else if (!chat.LeaveChannel(client, channel_name))
  10198. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an internal error preventing you from leaving that channel MUAHAHA");
  10199. }
  10200. /*
  10201. Function:
  10202. Purpose :
  10203. Params :
  10204. Dev :
  10205. Example :
  10206. */
  10207. void Commands::Command_WeaponStats(Client* client)
  10208. {
  10209. Player* player = client->GetPlayer();
  10210. Spawn* target = player->GetTarget();
  10211. Item* primary = player->GetEquipmentList()->GetItem(EQ2_PRIMARY_SLOT);
  10212. Item* secondary = player->GetEquipmentList()->GetItem(EQ2_SECONDARY_SLOT);
  10213. Item* ranged = player->GetEquipmentList()->GetItem(EQ2_RANGE_SLOT);
  10214. const char* charName = player->GetName();
  10215. if(target && target->IsEntity()) {
  10216. primary = ((Entity*)target)->GetEquipmentList()->GetItem(EQ2_PRIMARY_SLOT);
  10217. secondary = ((Entity*)target)->GetEquipmentList()->GetItem(EQ2_SECONDARY_SLOT);
  10218. ranged = ((Entity*)target)->GetEquipmentList()->GetItem(EQ2_RANGE_SLOT);
  10219. charName = target->GetName();
  10220. }
  10221. else {
  10222. target = nullptr;
  10223. }
  10224. client->Message(0, "WeaponStats for %s", charName);
  10225. client->SimpleMessage(0, "Primary:");
  10226. if (primary) {
  10227. client->Message(0, "Name: %s", primary->name.c_str());
  10228. client->Message(0, "Base Damage: %u - %u", primary->weapon_info->damage_low3, primary->weapon_info->damage_high3);
  10229. client->Message(0, "Actual Damage: %u - %u", target ? ((Entity*)target)->GetPrimaryWeaponMinDamage() : player->GetPrimaryWeaponMinDamage(),
  10230. target ? ((Entity*)target)->GetPrimaryWeaponMaxDamage() : player->GetPrimaryWeaponMaxDamage());
  10231. client->Message(0, "Actual Delay: %u", target ? ((Entity*)target)->GetPrimaryWeaponDelay() : player->GetPrimaryWeaponDelay());
  10232. client->Message(0, "Proc Percent: %d%%", 0);
  10233. client->Message(0, "Procs Per Minute: %d", 0);
  10234. }
  10235. else {
  10236. client->SimpleMessage(0, "Name: fist");
  10237. client->Message(0, "Base Damage: %u - %u", target ? ((Entity*)target)->GetPrimaryWeaponMinDamage() : player->GetPrimaryWeaponMinDamage(),
  10238. target ? ((Entity*)target)->GetPrimaryWeaponMaxDamage() : player->GetPrimaryWeaponMaxDamage());
  10239. client->Message(0, "Actual Damage: %u - %u", target ? ((Entity*)target)->GetPrimaryWeaponMinDamage() : player->GetPrimaryWeaponMinDamage(),
  10240. target ? ((Entity*)target)->GetPrimaryWeaponMaxDamage() : player->GetPrimaryWeaponMaxDamage());
  10241. client->Message(0, "Actual Delay: %d", target ? ((Entity*)target)->GetPrimaryWeaponDelay() : player->GetPrimaryWeaponDelay() * 0.1);
  10242. client->Message(0, "Proc Percent: %d%%", 0);
  10243. client->Message(0, "Procs Per Minute: %d", 0);
  10244. }
  10245. client->SimpleMessage(0, " ");
  10246. client->SimpleMessage(0, " ");
  10247. if (secondary) {
  10248. client->SimpleMessage(0, "Secondary:");
  10249. client->Message(0, "Name: %s", secondary->name.c_str());
  10250. client->Message(0, "Base Damage: %u - %u", secondary->weapon_info->damage_low3, secondary->weapon_info->damage_high3);
  10251. client->Message(0, "Actual Damage: %u - %u", target ? ((Entity*)target)->GetSecondaryWeaponMinDamage() : player->GetSecondaryWeaponMinDamage(),
  10252. target ? ((Entity*)target)->GetSecondaryWeaponMaxDamage() : player->GetSecondaryWeaponMaxDamage());
  10253. client->Message(0, "Actual Delay: %d", target ? ((Entity*)target)->GetSecondaryWeaponDelay() : player->GetSecondaryWeaponDelay() * 0.1);
  10254. client->Message(0, "Proc Percent: %d%%", 0);
  10255. client->Message(0, "Procs Per Minute: %d", 0);
  10256. client->SimpleMessage(0, " ");
  10257. client->SimpleMessage(0, " ");
  10258. }
  10259. client->SimpleMessage(0, "Ranged:");
  10260. if (ranged) {
  10261. client->Message(0, "Name: %s", ranged->name.c_str());
  10262. client->Message(0, "Base Damage: %u - %u", ranged->ranged_info->weapon_info.damage_low3, ranged->ranged_info->weapon_info.damage_high3);
  10263. client->Message(0, "Actual Damage: %u - %u", target ? ((Entity*)target)->GetRangedWeaponMinDamage() : player->GetRangedWeaponMinDamage(),
  10264. target ? ((Entity*)target)->GetRangedWeaponMaxDamage() : player->GetRangedWeaponMaxDamage());
  10265. client->Message(0, "Actual Delay: %d", target ? ((Entity*)target)->GetRangeWeaponDelay() : player->GetRangeWeaponDelay() * 0.1);
  10266. client->Message(0, "Proc Percent: %d%%", 0);
  10267. client->Message(0, "Procs Per Minute: %d", 0);
  10268. }
  10269. else
  10270. client->SimpleMessage(0, "None");
  10271. }
  10272. void Commands::Command_WhoChannel(Client *client, Seperator *sep) {
  10273. const char *channel_name;
  10274. if (sep == NULL || !sep->IsSet(0)) {
  10275. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /chatwho <channel name>");
  10276. return;
  10277. }
  10278. channel_name = sep->arg[0];
  10279. if (!chat.ChannelExists(channel_name))
  10280. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That channel does not exist!");
  10281. else
  10282. chat.SendChannelUserList(client, channel_name);
  10283. }
  10284. void Commands::Command_ZoneSafeCoords(Client *client, Seperator *sep)
  10285. {
  10286. ZoneServer* zone = 0;
  10287. int32 zone_id = client->GetPlayer()->GetZone()->GetZoneID();
  10288. if (zone_id > 0)
  10289. {
  10290. zone = zone_list.Get(zone_id, false, false, false);
  10291. if (zone)
  10292. {
  10293. zone->SetSafeX(client->GetPlayer()->GetX());
  10294. zone->SetSafeY(client->GetPlayer()->GetY());
  10295. zone->SetSafeZ(client->GetPlayer()->GetZ());
  10296. zone->SetSafeHeading(client->GetPlayer()->GetHeading());
  10297. if( database.SaveZoneSafeCoords(zone_id, zone->GetSafeX(), zone->GetSafeY(), zone->GetSafeZ(), zone->GetSafeHeading()) )
  10298. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Zone safe coordinates updated!");
  10299. else
  10300. client->SimpleMessage(CHANNEL_COLOR_RED, "FAILED to update zone safe coordinates!");
  10301. }
  10302. }
  10303. }
  10304. /*
  10305. Function:
  10306. Purpose :
  10307. Params :
  10308. Dev :
  10309. Example :
  10310. */
  10311. void Commands::Command_ZoneDetails(Client* client, Seperator* sep)
  10312. {
  10313. ZoneInfo* zone_info = new ZoneInfo;
  10314. if (sep && sep->arg[0])
  10315. {
  10316. if (sep->IsNumber(0))
  10317. zone_info->id = atoi(sep->arg[0]);
  10318. else
  10319. zone_info->id = database.GetZoneID(sep->arg[0]);
  10320. if (zone_info->id > 0)
  10321. {
  10322. database.LoadZoneInfo(zone_info);
  10323. 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);
  10324. 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);
  10325. 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);
  10326. 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);
  10327. 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);
  10328. 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);
  10329. 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);
  10330. client->Message(CHANNEL_COLOR_YELLOW, "zone_type: %s, sky_file: %s", zone_info->zone_type, zone_info->sky_file);
  10331. client->Message(CHANNEL_COLOR_YELLOW, "lua_script: %s", zone_info->lua_script);
  10332. client->Message(CHANNEL_COLOR_YELLOW, "zone_motd: %s", zone_info->zone_motd);
  10333. }
  10334. else
  10335. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  10336. }
  10337. else
  10338. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone details [zone id|zone name]");
  10339. safe_delete(zone_info);
  10340. }
  10341. /*
  10342. Function:
  10343. Purpose :
  10344. Params :
  10345. Dev :
  10346. Example :
  10347. */
  10348. void Commands::Command_ZoneSet(Client* client, Seperator* sep)
  10349. {
  10350. if (sep && sep->arg[0] && sep->arg[1] && sep->arg[2])
  10351. {
  10352. ZoneServer* zone = 0;
  10353. int32 zone_id = 0;
  10354. if (sep->IsNumber(0) && atoi(sep->arg[0]) > 0)
  10355. {
  10356. zone_id = atoi(sep->arg[0]);
  10357. zone = zone_list.Get(atoi(sep->arg[0]), false, false, false);
  10358. }
  10359. else
  10360. {
  10361. zone_id = database.GetZoneID(sep->arg[0]);
  10362. if (zone_id > 0)
  10363. zone = zone_list.Get(sep->arg[0], false, false, false);
  10364. }
  10365. if (zone_id > 0)
  10366. {
  10367. if (zone_set_values.count(string(sep->arg[1])) > 0)
  10368. SetZoneCommand(client, zone_id, zone, zone_set_values[sep->arg[1]], sep->arg[2]);
  10369. else
  10370. client->Message(CHANNEL_COLOR_YELLOW, "The attribute '%s' is not valid.", sep->arg[1]);
  10371. }
  10372. else
  10373. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  10374. }
  10375. else
  10376. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone set [zone id|zone name] [attribute] [value]");
  10377. }
  10378. void Commands::Command_Rain(Client* client, Seperator* sep) {
  10379. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  10380. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /rain <float>");
  10381. return;
  10382. }
  10383. client->Message(CHANNEL_COLOR_YELLOW,"Setting rain to %.2f", atof(sep->arg[0]));
  10384. client->GetCurrentZone()->SetRain(atof(sep->arg[0]));
  10385. client->GetCurrentZone()->SetCurrentWeather(atof(sep->arg[0]));
  10386. }
  10387. void Commands::Command_Wind(Client* client, Seperator* sep) {
  10388. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  10389. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /wind <float>");
  10390. return;
  10391. }
  10392. client->Message(CHANNEL_COLOR_YELLOW, "Setting wind to %.2f", atof(sep->arg[0]));
  10393. client->GetCurrentZone()->SetWind(atof(sep->arg[0]));
  10394. }
  10395. void Commands::Command_SendMerchantWindow(Client* client, Seperator* sep, bool sell) {
  10396. Spawn* spawn = client->GetPlayer()->GetTarget();
  10397. if(client->GetVersion() <= 546) {
  10398. sell = false; // doesn't support in the same way as AoM just open the normal buy/sell window
  10399. }
  10400. if(spawn) {
  10401. client->SetMerchantTransaction(spawn);
  10402. if (spawn->GetMerchantID() > 0 && spawn->IsClientInMerchantLevelRange(client)){
  10403. client->SendHailCommand(spawn);
  10404. //MerchantFactionMultiplier* multiplier = world.GetMerchantMultiplier(spawn->GetMerchantID());
  10405. //if(!multiplier || (multiplier && client->GetPlayer()->GetFactions()->GetFactionValue(multiplier->faction_id) >= multiplier->faction_min)){
  10406. client->SendBuyMerchantList(sell);
  10407. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY))
  10408. client->SendSellMerchantList(sell);
  10409. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY_BACK))
  10410. client->SendBuyBackList(sell);
  10411. if(client->GetVersion() > 546) {
  10412. PacketStruct* packet = configReader.getStruct("WS_UpdateMerchant", client->GetVersion());
  10413. if (packet) {
  10414. packet->setDataByName("spawn_id", 0xFFFFFFFF);
  10415. packet->setDataByName("type", 16);
  10416. EQ2Packet* outapp = packet->serialize();
  10417. if (outapp)
  10418. client->QueuePacket(outapp);
  10419. safe_delete(packet);
  10420. }
  10421. }
  10422. }
  10423. if (spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR)
  10424. client->SendRepairList();
  10425. }
  10426. // client->SimpleMessage(CHANNEL_COLOR_RED, "Your faction is too low to use this merchant.");
  10427. }
  10428. void Commands::Command_Weather(Client* client, Seperator* sep)
  10429. {
  10430. //PrintSep(sep, "Weather");
  10431. if( sep && sep->arg[0] )
  10432. {
  10433. ZoneServer* zsZone = client->GetCurrentZone();
  10434. const char* value = sep->arg[0];
  10435. // process single-param commands first
  10436. if( strncasecmp(value, "details", strlen(value)) == 0 )
  10437. {
  10438. client->Message(CHANNEL_COLOR_YELLOW, "Weather Details for zone %s: ", zsZone->GetZoneName());
  10439. client->Message(CHANNEL_COLOR_YELLOW, "enabled: %i, allowed: %i, type: %i, frequency: %u", zsZone->isWeatherEnabled(), zsZone->isWeatherAllowed(), zsZone->GetWeatherType(), zsZone->GetWeatherFrequency());
  10440. client->Message(CHANNEL_COLOR_YELLOW, "severity: %.2f = %.2f, current: %.2f", zsZone->GetWeatherMinSeverity(), zsZone->GetWeatherMaxSeverity(), zsZone->GetCurrentWeather());
  10441. client->Message(CHANNEL_COLOR_YELLOW, "pattern: %i, chance: %i, amount: %.2f, offset: %.2f", zsZone->GetWeatherPattern(), zsZone->GetWeatherChance(), zsZone->GetWeatherChangeAmount(), zsZone->GetWeatherDynamicOffset());
  10442. }
  10443. else if( strncasecmp(value, "process", strlen(value)) == 0 )
  10444. {
  10445. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  10446. zsZone->ProcessWeather();
  10447. }
  10448. else if( strncasecmp(value, "reset", strlen(value)) == 0 )
  10449. {
  10450. zsZone->SetWeatherType(rule_manager.GetGlobalRule(R_Zone, WeatherType)->GetInt8());
  10451. zsZone->SetWeatherFrequency(rule_manager.GetGlobalRule(R_Zone, WeatherChangeFrequency)->GetInt32());
  10452. zsZone->SetWeatherMinSeverity(rule_manager.GetGlobalRule(R_Zone, MinWeatherSeverity)->GetFloat());
  10453. zsZone->SetWeatherMaxSeverity(rule_manager.GetGlobalRule(R_Zone, MaxWeatherSeverity)->GetFloat());
  10454. zsZone->SetCurrentWeather(zsZone->GetWeatherMinSeverity());
  10455. zsZone->SetWeatherPattern(1);
  10456. zsZone->SetWeatherChance(rule_manager.GetGlobalRule(R_Zone, WeatherChangeChance)->GetInt8());
  10457. zsZone->SetWeatherChangeAmount(rule_manager.GetGlobalRule(R_Zone, WeatherChangePerInterval)->GetFloat());
  10458. zsZone->SetWeatherDynamicOffset(rule_manager.GetGlobalRule(R_Zone, WeatherDynamicMaxOffset)->GetFloat());
  10459. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  10460. zsZone->ProcessWeather();
  10461. }
  10462. // process commands with params
  10463. if( sep->arg[1] )
  10464. {
  10465. if( strncasecmp(value, "enable", strlen(value)) == 0 && sep->IsNumber(1) )
  10466. zsZone->SetWeatherEnabled( ( atoi(sep->arg[1]) == 1 ) ? true : false );
  10467. else if( strncasecmp(value, "type", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 3) )
  10468. zsZone->SetWeatherType(atoi(sep->arg[1]));
  10469. else if( strncasecmp(value, "frequency", strlen(value)) == 0 && sep->IsNumber(1))
  10470. zsZone->SetWeatherFrequency( atoul(sep->arg[1]) );
  10471. else if( strncasecmp(value, "range", strlen(value)) == 0 && sep->IsNumber(1) && sep->IsNumber(2) ) {
  10472. zsZone->SetWeatherMinSeverity(atof(sep->arg[1]));
  10473. zsZone->SetWeatherMaxSeverity(atof(sep->arg[2]));
  10474. zsZone->SetRain(zsZone->GetWeatherMinSeverity());
  10475. }
  10476. else if( strncasecmp(value, "current", strlen(value)) == 0 && sep->IsNumber(1) ) {
  10477. zsZone->SetCurrentWeather(atof(sep->arg[1]));
  10478. zsZone->SetRain(zsZone->GetCurrentWeather());
  10479. }
  10480. else if( strncasecmp(value, "pattern", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 2) )
  10481. zsZone->SetWeatherPattern( atoi(sep->arg[1]) );
  10482. else if( strncasecmp(value, "chance", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 100) )
  10483. zsZone->SetWeatherChance( atoi(sep->arg[1]) );
  10484. else if( strncasecmp(value, "amount", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  10485. zsZone->SetWeatherChangeAmount( atof(sep->arg[1]) );
  10486. else if( strncasecmp(value, "offset", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  10487. zsZone->SetWeatherDynamicOffset( atof(sep->arg[1]) );
  10488. }
  10489. }
  10490. else
  10491. {
  10492. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /weather [command] [param]");
  10493. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: enable (0|1), type (0-3), frequency (sec), range|current (0.0 - 1.0)");
  10494. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: details, process, pattern (0|1), chance (%), amount (float), offset (float)");
  10495. return;
  10496. }
  10497. }
  10498. void Commands::Command_Select(Client* client, Seperator* sep) {
  10499. if (sep && sep->arg[1]) {
  10500. Spawn* spawn = client->GetPlayer()->GetTarget();
  10501. if (spawn && strlen(sep->arg[1]) > 0)
  10502. client->GetCurrentZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_CUSTOM, client->GetPlayer(), sep->arg[1]);
  10503. }
  10504. }
  10505. /*
  10506. Function: Command_ConsumeFood()
  10507. Purpose : Consume Food/Drink and apply mods
  10508. Params : Slot ID - EQ2_FOOD_SLOT 22, EQ2_DRINK_SLOT 23
  10509. Dev : Zcoretri
  10510. Example : /consume_food 22
  10511. */
  10512. void Commands::Command_ConsumeFood(Client* client, Seperator* sep) {
  10513. if (sep && sep->arg[0] && sep->IsNumber(0))
  10514. {
  10515. Player* player = client->GetPlayer();
  10516. int8 slot = atoi(sep->arg[0]);
  10517. if (client->GetVersion() <= 283) {
  10518. slot += 4;
  10519. }
  10520. else if (client->GetVersion() <= 546) {
  10521. slot += 2;
  10522. }
  10523. Item* item = player->GetEquipmentList()->GetItem(slot);
  10524. if(client->CheckConsumptionAllowed(slot)) {
  10525. client->ConsumeFoodDrink(item, slot);
  10526. }
  10527. }
  10528. }
  10529. void Commands::Command_Aquaman(Client* client, Seperator* sep) {
  10530. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  10531. if (atoi(sep->arg[0]) == 1) {
  10532. client->GetPlayer()->GetInfoStruct()->set_vision(4);
  10533. client->GetPlayer()->GetInfoStruct()->set_breathe_underwater(1);
  10534. client->GetPlayer()->SetCharSheetChanged(true);
  10535. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Maybe you ought to stick to the shallow end until you know how to swim.");
  10536. }
  10537. else {
  10538. client->GetPlayer()->GetInfoStruct()->set_vision(0);
  10539. client->GetPlayer()->GetInfoStruct()->set_breathe_underwater(0);
  10540. client->GetPlayer()->SetCharSheetChanged(true);
  10541. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Aquaman mode turned off.");
  10542. }
  10543. }
  10544. else
  10545. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /aquaman [0|1]");
  10546. }
  10547. void Commands::Command_ReportBug(Client* client, Seperator* sep)
  10548. {
  10549. if(sep)
  10550. {
  10551. string data;
  10552. if(sep->arg[0]){
  10553. data = string(sep->arg[0]);
  10554. }
  10555. for(int i=1;i<sep->GetMaxArgNum();i++){
  10556. if(sep->arg[i])
  10557. data.append(" ").append(sep->arg[i]);
  10558. }
  10559. const char* target_name = 0;
  10560. int32 spawn_id = 0;
  10561. if(client->GetPlayer()->GetTarget())
  10562. {
  10563. target_name = client->GetPlayer()->GetTarget()->GetName();
  10564. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  10565. }
  10566. else
  10567. target_name = "N/A";
  10568. LogWrite(COMMAND__DEBUG, 1, "Command", "%s", data.c_str());
  10569. if(world.ReportBug(data, client->GetPlayer()->GetName(), client->GetAccountID(), target_name, spawn_id, client->GetCurrentZone()->GetZoneID()))
  10570. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully submitted bug.");
  10571. else
  10572. client->SimpleMessage(CHANNEL_COLOR_RED, "Error submitting bug.");
  10573. }
  10574. }
  10575. void Commands::Command_Attune_Inv(Client* client, Seperator* sep) {
  10576. PrintSep(sep, "Command_Attune_Inv");
  10577. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  10578. // Get the item index from the first parameter
  10579. int16 index = atoi(sep->arg[0]);
  10580. // Check to see if this is a valid item index for the player, if not exit out of the function
  10581. if (client->GetPlayer()->item_list.indexed_items.count(index) == 0) {
  10582. LogWrite(ITEM__DEBUG, 0, "Items", "%s has no item with an index of %i", client->GetPlayer()->GetName(), index);
  10583. return;
  10584. }
  10585. // Get the item
  10586. Item* item = client->GetPlayer()->item_list.indexed_items[index];
  10587. if(item) {
  10588. // Valid item lets check to make sure this item is attunable, if not return out
  10589. if (!item->CheckFlag(ATTUNEABLE)) {
  10590. LogWrite(ITEM__DEBUG, 0, "Items", "attune_inv called for an item that is not attunable (%s)", item->name.c_str());
  10591. return;
  10592. }
  10593. // Remove the attunable flag
  10594. item->generic_info.item_flags -= ATTUNEABLE;
  10595. // Set the attuned flag
  10596. item->generic_info.item_flags += ATTUNED;
  10597. // Flag this item for saving
  10598. item->save_needed = true;
  10599. client->QueuePacket(item->serialize(client->GetVersion(), false, client->GetPlayer()));
  10600. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), 0, -1); // appearance type??
  10601. EQ2Packet* outapp = 0;
  10602. for (int32 i=0;i<packets.size();i++) {
  10603. outapp = packets[i];
  10604. if(outapp)
  10605. client->QueuePacket(outapp);
  10606. }
  10607. }
  10608. }
  10609. }
  10610. void Commands::Command_Reset_Zone_Timer(Client* client, Seperator* sep) {
  10611. PrintSep(sep, "Command_Reset_Zone_Timer");
  10612. /*if (sep && sep->arg[0] && sep->IsNumber(0)) {
  10613. int32 db_id = atoul(sep->arg[0]);
  10614. InstanceData* data = client->GetPlayer()->GetCharacterInstances().FindInstanceByDBID(db_id);
  10615. if (data) {
  10616. // TODO: add a check to timers to ensure it can be reset
  10617. // Delete the character from the instance
  10618. database.DeleteCharacterFromInstance(client->GetPlayer()->GetCharacterID(), data->instance_id);
  10619. data->instance_id = 0;
  10620. // Update the success time and set to 0 so the player can enter it again
  10621. database.UpdateCharacterInstance(client->GetPlayer()->GetCharacterID(), data->zone_name, 0, 1, 0);
  10622. data->last_success_timestamp = 0;
  10623. }
  10624. }*/
  10625. }
  10626. void Commands::Command_Player(Client* client, Seperator* sep) {
  10627. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player syntax --");
  10628. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins");
  10629. }
  10630. void Commands::Command_Player_Coins(Client* client, Seperator* sep) {
  10631. // /player coins add 10
  10632. // /player coins add plat 10
  10633. Player* player = client->GetPlayer();
  10634. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  10635. player = (Player*)player->GetTarget();
  10636. if (sep && sep->arg[0] && sep->arg[1]) {
  10637. const char* action = sep->arg[0];
  10638. int64 value = 0;
  10639. if (strncasecmp(action, "add", strlen(action)) == 0) {
  10640. if (sep->IsNumber(1)) {
  10641. value = atoi64(sep->arg[1]);
  10642. player->AddCoins(value);
  10643. if (client->GetPlayer() == player)
  10644. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  10645. else {
  10646. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  10647. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  10648. }
  10649. return;
  10650. }
  10651. else if (sep->arg[2] && sep->IsNumber(2)) {
  10652. const char* type = sep->arg[1];
  10653. if (strncasecmp(type, "copper", strlen(type)) == 0) {
  10654. value = atoi64(sep->arg[2]);
  10655. }
  10656. else if (strncasecmp(type, "silver", strlen(type)) == 0) {
  10657. value = atoi64(sep->arg[2]) * 100;
  10658. }
  10659. else if (strncasecmp(type, "gold", strlen(type)) == 0) {
  10660. value = atoi64(sep->arg[2]) * 10000;
  10661. }
  10662. else if (strncasecmp(type, "plat", strlen(type)) == 0) {
  10663. value = atoi64(sep->arg[2]) * 1000000;
  10664. }
  10665. player->AddCoins(value);
  10666. if (client->GetPlayer() == player)
  10667. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  10668. else {
  10669. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  10670. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  10671. }
  10672. return;
  10673. }
  10674. }
  10675. }
  10676. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player coins syntax --");
  10677. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add [value] - adds the given number of coins to the player");
  10678. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add copper [value] - adds the given amount of copper to the player");
  10679. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add silver [value] - adds the given amount of silver to the player");
  10680. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add gold [value] - adds the given amount of gold to the player");
  10681. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add plat [value] - adds the given amount of platinum to the player");
  10682. }
  10683. void Commands::Command_AchievementAdd(Client* client, Seperator* sep) {
  10684. PrintSep(sep, "ACHIEVEMENT_ADD");
  10685. if (sep && sep->IsSet(0)) {
  10686. int32 spell_id = atoul(sep->arg[1]);
  10687. int8 spell_tier = 0;
  10688. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  10689. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  10690. // addspellbookentry here
  10691. if (spell_tier >= data->maxRank) {
  10692. return;
  10693. }
  10694. if (!spell_tier) {
  10695. spell_tier = 1;
  10696. }
  10697. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  10698. {
  10699. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  10700. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  10701. client->GetPlayer()->UnlockSpell(spell);
  10702. client->SendSpellUpdate(spell);
  10703. }
  10704. else
  10705. {
  10706. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1);
  10707. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  10708. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  10709. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  10710. client->GetPlayer()->UnlockSpell(spell);
  10711. client->SendSpellUpdate(spell);
  10712. }
  10713. // cast spell here
  10714. if (!spell_tier)
  10715. spell_tier = 1;
  10716. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  10717. if (spell) {
  10718. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  10719. }
  10720. }
  10721. else {
  10722. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  10723. }
  10724. master_aa_list.DisplayAA(client, 0, 0);
  10725. }
  10726. void Commands::Command_Editor(Client* client, Seperator* sep) {
  10727. PacketStruct* packet = configReader.getStruct("WS_ChoiceWindow", client->GetVersion());
  10728. if (packet) {
  10729. string url = string(rule_manager.GetGlobalRule(R_World, EditorURL)->GetString());
  10730. if (rule_manager.GetGlobalRule(R_World, EditorOfficialServer)->GetBool()) {
  10731. char command[255];
  10732. url = "browser " + url;
  10733. int32 spawn_id = 0;
  10734. int32 zone_id = 0;
  10735. string type;
  10736. if (client->GetCurrentZone())
  10737. zone_id = client->GetCurrentZone()->GetZoneID();
  10738. if (client->GetPlayer()->GetTarget()) {
  10739. Spawn* target = client->GetPlayer()->GetTarget();
  10740. if (target->IsWidget())
  10741. type = "widgets";
  10742. else if (target->IsSign())
  10743. type = "signs";
  10744. else if (target->IsObject())
  10745. type = "objects";
  10746. else if (target->IsNPC())
  10747. type = "npcs";
  10748. else if (target->IsGroundSpawn())
  10749. type = "ground";
  10750. else
  10751. type = "spawn";
  10752. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  10753. }
  10754. sprintf(command, url.c_str(), zone_id, type.c_str(), spawn_id);
  10755. packet->setDataByName("accept_command", command);
  10756. }
  10757. else if (rule_manager.GetGlobalRule(R_World, EditorIncludeID)->GetBool()) {
  10758. char command[255];
  10759. url = "browser " + url;
  10760. if (client->GetPlayer()->GetTarget())
  10761. sprintf(command, url.c_str(), client->GetPlayer()->GetTarget()->GetDatabaseID());
  10762. packet->setDataByName("accept_command", command);
  10763. }
  10764. else {
  10765. string command = "browser " + url;
  10766. packet->setDataByName("accept_command", command.c_str());
  10767. }
  10768. packet->setDataByName("text", "Open the web editor?");
  10769. packet->setDataByName("accept_text", "Open");
  10770. packet->setDataByName("cancel_text", "Cancel");
  10771. // No clue if we even need the following 2 unknowns, just added them so the packet matches what live sends
  10772. packet->setDataByName("unknown2", 50);
  10773. packet->setDataByName("unknown4", 1);
  10774. client->QueuePacket(packet->serialize());
  10775. safe_delete(packet);
  10776. }
  10777. }
  10778. void Commands::Command_AcceptResurrection(Client* client, Seperator* sep) {
  10779. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  10780. return;
  10781. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  10782. if(client->GetCurrentRez()->active)
  10783. client->AcceptResurrection();
  10784. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  10785. }
  10786. void Commands::Command_DeclineResurrection(Client* client, Seperator* sep) {
  10787. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  10788. return;
  10789. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  10790. if(client->GetCurrentRez()->active)
  10791. client->GetCurrentRez()->should_delete = true;
  10792. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  10793. }
  10794. void Commands::Switch_AA_Profile(Client* client, Seperator* sep) {
  10795. PrintSep(sep, "Switch_AA_Profile");
  10796. if (sep && sep->IsSet(0)) {
  10797. string type = sep->arg[0];
  10798. int8 newtemplate = atoul(sep->arg[1]);
  10799. master_aa_list.DisplayAA(client, newtemplate, 1);
  10800. }
  10801. }
  10802. void Commands::Get_AA_Xml(Client* client, Seperator* sep) {
  10803. PrintSep(sep, "Get_AA_Xml");
  10804. if (sep && sep->IsSet(0)) {
  10805. string tabnum = sep->arg[0];
  10806. string spellid = sep->arg[1];
  10807. }
  10808. }
  10809. void Commands::Add_AA(Client* client, Seperator* sep) {
  10810. PrintSep(sep, "Add_AA");
  10811. if (sep && sep->IsSet(0)) {
  10812. int32 spell_id = atoul(sep->arg[1]);
  10813. int8 spell_tier = 0;
  10814. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  10815. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  10816. // addspellbookentry here
  10817. if(!data) {
  10818. LogWrite(COMMAND__ERROR, 0, "Command", "Error in Add_AA no data for spell_id %u spell_tier %u", spell_id, spell_tier);
  10819. return;
  10820. }
  10821. if (spell_tier >= data->maxRank) {
  10822. LogWrite(COMMAND__ERROR, 0, "Command", "Error in Add_AA spell_tier %u >= maxRank %u", spell_tier, data->maxRank);
  10823. return;
  10824. }
  10825. if (!spell_tier) {
  10826. spell_tier = 1;
  10827. }
  10828. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  10829. {
  10830. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  10831. if(spell)
  10832. {
  10833. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  10834. client->GetPlayer()->UnlockSpell(spell);
  10835. client->SendSpellUpdate(spell);
  10836. }
  10837. }
  10838. else
  10839. {
  10840. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1 );
  10841. if(spell)
  10842. {
  10843. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  10844. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  10845. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  10846. client->GetPlayer()->UnlockSpell(spell);
  10847. client->SendSpellUpdate(spell);
  10848. }
  10849. }
  10850. // cast spell here
  10851. if (!spell_tier)
  10852. spell_tier = 1;
  10853. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  10854. if (spell) {
  10855. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  10856. }
  10857. }
  10858. else {
  10859. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  10860. }
  10861. master_aa_list.DisplayAA(client, 0, 0);
  10862. }
  10863. void Commands::Commit_AA_Profile(Client* client, Seperator* sep) {
  10864. PrintSep(sep, "Commit_AA_Profile");
  10865. if (sep && sep->IsSet(0)) {
  10866. }
  10867. }
  10868. void Commands::Begin_AA_Profile(Client* client, Seperator* sep) {
  10869. PrintSep(sep, "Begin_AA_Profile");
  10870. if (sep && sep->IsSet(0)) {
  10871. master_aa_list.DisplayAA(client, 100, 2);
  10872. }
  10873. }
  10874. void Commands::Back_AA(Client* client, Seperator* sep) {
  10875. if (sep && sep->IsSet(0)) {
  10876. PrintSep(sep, "Back_AA");
  10877. }
  10878. }
  10879. void Commands::Remove_AA(Client* client, Seperator* sep) {
  10880. if (sep && sep->IsSet(0)) {
  10881. PrintSep(sep, "Remove_AA");
  10882. }
  10883. }
  10884. void Commands::Cancel_AA_Profile(Client* client, Seperator* sep) {
  10885. MasterAAList master_aa_list;
  10886. PrintSep(sep, "Cancel_AA_Profile");
  10887. master_aa_list.DisplayAA(client, 0, 0);
  10888. }
  10889. void Commands::Save_AA_Profile(Client* client, Seperator* sep) {
  10890. if (sep && sep->IsSet(0)) {
  10891. PrintSep(sep, "Save_AA_Profile");
  10892. }
  10893. }
  10894. void Commands::Command_TargetItem(Client* client, Seperator* sep) {
  10895. if (!sep || sep->GetArgNumber() < 1 || !client->GetPlayer()) return;
  10896. if (!sep->IsNumber(0)) return;
  10897. int32 request_id = atoul(sep->arg[0]);
  10898. if (!sep->IsNumber(1)) return;
  10899. sint32 item_id = atoi(sep->arg[1]);
  10900. if (client->IsCurrentTransmuteID(request_id)) {
  10901. Transmute::HandleItemResponse(client, client->GetPlayer(), request_id, reinterpret_cast<int32&>(item_id));
  10902. }
  10903. else if (client->IsCurrentTransmuteID(item_id)) {
  10904. if (!sep->IsSet(2)) return;
  10905. if (sep->IsNumber(2) && atoi(sep->arg[2]) == 1) {
  10906. Transmute::HandleConfirmResponse(client, client->GetPlayer(), reinterpret_cast<int32&>(item_id));
  10907. }
  10908. }
  10909. }
  10910. void Commands::Command_FindSpawn(Client* client, Seperator* sep) {
  10911. if(sep)
  10912. client->GetCurrentZone()->FindSpawn(client, (char*)sep->argplus[0]);
  10913. }
  10914. void Commands::Command_MoveCharacter(Client* client, Seperator* sep) {
  10915. if(sep && sep->arg[0][0] && sep->arg[1][0])
  10916. {
  10917. char* name = sep->arg[0];
  10918. char* zoneName = sep->arg[1];
  10919. char query[256];
  10920. 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);
  10921. if (database.RunQuery(query, strnlen(query, 256)))
  10922. {
  10923. client->Message(CHANNEL_COLOR_YELLOW, "Ran query:%s", query);
  10924. }
  10925. else
  10926. client->Message(CHANNEL_COLOR_RED, "Query FAILED to run: %s", query);
  10927. }
  10928. }
  10929. void Commands::Command_Mood(Client* client, Seperator* sep) {
  10930. Player* player = client->GetPlayer();
  10931. if( sep && sep->arg[0] )
  10932. {
  10933. const char* value = sep->arg[0];
  10934. InfoStruct* info = player->GetInfoStruct();
  10935. int32 cid = client->GetCharacterID();
  10936. char* characterName = database.GetCharacterName(cid);
  10937. char tmp[1024]; // our emote string "xyz appears zyx"
  10938. //char properties vals
  10939. char* pname = "mood";
  10940. char* pval; // mood value
  10941. bool pt; //used to verify return from DB.
  10942. //This should never be seen.
  10943. sprintf(tmp, " ");
  10944. if( strncasecmp(value, "angry", strlen(value)) == 0 )
  10945. {
  10946. sprintf(tmp, "%s appears angry", characterName);
  10947. pval = "11852";
  10948. player->SetMoodState(11852, 1);
  10949. info->set_mood(11852);
  10950. pt = database.insertCharacterProperty(client, pname, pval);
  10951. }
  10952. else if( strncasecmp(value, "afraid", strlen(value)) == 0 )
  10953. {
  10954. sprintf(tmp, "%s appears afraid", characterName);
  10955. pval = "11851";
  10956. player->SetMoodState(11851, 1);
  10957. info->set_mood(11851);
  10958. pt = database.insertCharacterProperty(client, pname, pval);
  10959. }
  10960. else if( strncasecmp(value, "happy", strlen(value)) == 0 )
  10961. {
  10962. sprintf(tmp, "%s appears happy", characterName);
  10963. pval = "11854";
  10964. player->SetMoodState(11854, 1);
  10965. info->set_mood(11854);
  10966. pt = database.insertCharacterProperty(client, pname, pval);
  10967. }
  10968. else if( strncasecmp(value, "sad", strlen(value)) == 0 ) {
  10969. sprintf(tmp, "%s appears sad", characterName);
  10970. pval = "11856";
  10971. player->SetMoodState(11856, 1);
  10972. info->set_mood(11856);
  10973. pt = database.insertCharacterProperty(client, pname, pval);
  10974. }
  10975. else if( strncasecmp(value, "tired", strlen(value)) == 0 )
  10976. {
  10977. sprintf(tmp, "%s appears tired", characterName);
  10978. pval = "11857";
  10979. player->SetMoodState(11857, 1);
  10980. info->set_mood(11857);
  10981. pt = database.insertCharacterProperty(client, pname, pval);
  10982. }
  10983. else if( strncasecmp(value, "none", strlen(value)) == 0 )
  10984. {
  10985. //using 11855 mood_idle for none, I assume thats what its for?
  10986. pval = "11855";
  10987. player->SetMoodState(11855, 1);
  10988. info->set_mood(11855);
  10989. pt = database.insertCharacterProperty(client, pname, pval);
  10990. //return since we have nothing left to do. No emote for none.
  10991. return;
  10992. }else{
  10993. client->SimpleMessage(CHANNEL_NARRATIVE, "Listing Available Moods:");
  10994. client->SimpleMessage(CHANNEL_NARRATIVE, "none");
  10995. client->SimpleMessage(CHANNEL_NARRATIVE, "afraid");
  10996. client->SimpleMessage(CHANNEL_NARRATIVE, "angry");
  10997. client->SimpleMessage(CHANNEL_NARRATIVE, "happy");
  10998. client->SimpleMessage(CHANNEL_NARRATIVE, "sad");
  10999. client->SimpleMessage(CHANNEL_NARRATIVE, "tired");
  11000. return;
  11001. }
  11002. client->GetPlayer()->GetZone()->HandleChatMessage(0, 0, CHANNEL_EMOTE, tmp);
  11003. return;
  11004. }
  11005. client->SimpleMessage(CHANNEL_NARRATIVE, "Listing Available Moods:");
  11006. client->SimpleMessage(CHANNEL_NARRATIVE, "none");
  11007. client->SimpleMessage(CHANNEL_NARRATIVE, "afraid");
  11008. client->SimpleMessage(CHANNEL_NARRATIVE, "angry");
  11009. client->SimpleMessage(CHANNEL_NARRATIVE, "happy");
  11010. client->SimpleMessage(CHANNEL_NARRATIVE, "sad");
  11011. client->SimpleMessage(CHANNEL_NARRATIVE, "tired");
  11012. return;
  11013. }
  11014. /*
  11015. Function: Command_CancelEffect()
  11016. Purpose : Cancels (good) effect spells
  11017. Example : /cancel_effect spell_id - would cancel the spell with the <spell_id> value in spell effects list
  11018. */
  11019. void Commands::Command_CancelEffect(Client* client, Seperator* sep)
  11020. {
  11021. if (sep && sep->arg[0] && sep->IsNumber(0))
  11022. {
  11023. int32 spell_id = atoul(sep->arg[0]);
  11024. SpellEffects* effect = client->GetPlayer()->GetSpellEffect(spell_id);
  11025. if(!effect || effect->spell->spell->GetSpellData()->det_type) {
  11026. return;
  11027. }
  11028. MaintainedEffects* meffect = effect->caster->GetMaintainedSpell(spell_id);
  11029. if (!meffect || !meffect->spell || !meffect->spell->caster || !meffect->spell->caster->GetZone() ||
  11030. !meffect->spell->caster->GetZone()->GetSpellProcess()->DeleteCasterSpell(meffect->spell, "canceled", false, client->GetPlayer()))
  11031. client->Message(CHANNEL_COLOR_RED, "The spell effect could not be cancelled.");
  11032. }
  11033. }
  11034. /*
  11035. Function: Command_CurePlayer()
  11036. Purpose : Identifies spell to cast for cure based on type
  11037. Example : /cureplayer ??
  11038. https://eq2.fandom.com/wiki/Update:58
  11039. New command /cureplayer [playername|group or raid position][trauma|arcane|noxious|elemental|curse] optional [spell|potion]
  11040. Example: /cureplayer g0 noxious spell
  11041. Will attempt to cure yourself of a noxious detriment with only spells and without using potions (even if you have them).
  11042. Example: /cureplayer r4 noxious
  11043. Will attempt to cure the character in raid slot 4 of a noxious detriment using a spell or potion (whichever is available).
  11044. */
  11045. void Commands::Command_CurePlayer(Client* client, Seperator* sep)
  11046. {
  11047. Entity* target = nullptr;
  11048. bool use_spells = true;
  11049. bool use_potions = true;
  11050. if (sep && sep->arg[0] && sep->arg[1]) {
  11051. if(sep->arg[2]) {
  11052. std::string type(sep->arg[2]);
  11053. boost::algorithm::to_lower(type);
  11054. if(type == "potion")
  11055. use_spells = false;
  11056. else if(type == "spell")
  11057. use_potions = false;
  11058. }
  11059. if(strlen(sep->arg[0]) > 1 && isdigit(sep->arg[0][1])) {
  11060. int32 mapped_position = (int32)(sep->arg[0][1]) - 48;
  11061. // TODO: RAID Support ('r' argument)
  11062. if(sep->arg[0][0] == 'g' && !mapped_position) {
  11063. target = (Entity*)client->GetPlayer();
  11064. }
  11065. else {
  11066. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  11067. if (gmi && gmi->group_id) {
  11068. PlayerGroup* group = world.GetGroupManager()->GetGroup(gmi->group_id);
  11069. if(group) {
  11070. target = group->GetGroupMemberByPosition(client->GetPlayer(), mapped_position);
  11071. }
  11072. }
  11073. }
  11074. }
  11075. else {
  11076. Client* target_client = zone_list.GetClientByCharName(sep->arg[0]);
  11077. if(target_client && target_client->GetPlayer() && target_client->GetPlayer()->GetZone() == client->GetPlayer()->GetZone()) {
  11078. target = (Entity*)target_client->GetPlayer();
  11079. }
  11080. }
  11081. ItemEffectType type = EFFECT_CURE_TYPE_ALL;
  11082. bool successful_spell = false;
  11083. bool successful_potion = false;
  11084. if(target) {
  11085. SpellBookEntry* entry = nullptr;
  11086. std::string str(sep->arg[1]);
  11087. boost::algorithm::to_lower(str);
  11088. if(str == "arcane") {
  11089. type = EFFECT_CURE_TYPE_ARCANE;
  11090. // cure arcane spell missing in DB?
  11091. if(use_spells && rule_manager.GetGlobalRule(R_Spells, CureArcaneSpellID)->GetInt32()) {
  11092. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureArcaneSpellID)->GetInt32()); // cure noxious
  11093. }
  11094. }
  11095. else if(str == "trauma") {
  11096. type = EFFECT_CURE_TYPE_TRAUMA;
  11097. // cure trauma spell missing in DB?
  11098. if(use_spells && rule_manager.GetGlobalRule(R_Spells, CureTraumaSpellID)->GetInt32()) {
  11099. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureTraumaSpellID)->GetInt32()); // cure noxious
  11100. }
  11101. }
  11102. else if(str == "noxious") {
  11103. type = EFFECT_CURE_TYPE_NOXIOUS;
  11104. if(use_spells && rule_manager.GetGlobalRule(R_Spells, CureNoxiousSpellID)->GetInt32()) {
  11105. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureNoxiousSpellID)->GetInt32()); // cure noxious
  11106. }
  11107. }
  11108. else if(str == "curse") {
  11109. type = EFFECT_CURE_TYPE_CURSE;
  11110. if(use_spells && rule_manager.GetGlobalRule(R_Spells, CureCurseSpellID)->GetInt32()) {
  11111. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureCurseSpellID)->GetInt32()); // cure curse
  11112. }
  11113. }
  11114. else if(str == "magic") {
  11115. type = EFFECT_CURE_TYPE_MAGIC;
  11116. if(use_spells && rule_manager.GetGlobalRule(R_Spells, CureMagicSpellID)->GetInt32()) {
  11117. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureMagicSpellID)->GetInt32()); // cure magic
  11118. }
  11119. }
  11120. if(use_spells) {
  11121. // check if any of the specific cure types are available, if not then check the base cures
  11122. if(!entry && rule_manager.GetGlobalRule(R_Spells, CureSpellID)->GetInt32()) {
  11123. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureSpellID)->GetInt32()); // cure
  11124. }
  11125. if(entry && entry->spell_id) {
  11126. Spell* spell = master_spell_list.GetSpell(entry->spell_id, entry->tier);
  11127. target->GetZone()->ProcessSpell(spell, (Entity*)client->GetPlayer(), target, true, false);
  11128. successful_spell = true;
  11129. }
  11130. }
  11131. }
  11132. if(!successful_spell && use_potions && target && type != NO_EFFECT_TYPE) {
  11133. vector<Item*>* potential_items = client->GetItemsByEffectType(type, EFFECT_CURE_TYPE_ALL);
  11134. if (potential_items && potential_items->size() > 0) {
  11135. vector<Item*>::iterator itr;
  11136. for (itr = potential_items->begin(); itr != potential_items->end(); itr++)
  11137. {
  11138. Item* item = *itr;
  11139. if(client->UseItem(item, target)) {
  11140. successful_potion = true;
  11141. break;
  11142. }
  11143. }
  11144. }
  11145. safe_delete(potential_items);
  11146. }
  11147. }
  11148. }
  11149. /*
  11150. Function: Command_ShareQuest()
  11151. Purpose : Share quest with the group
  11152. Example : /share_quest [quest_id]
  11153. */
  11154. void Commands::Command_ShareQuest(Client* client, Seperator* sep)
  11155. {
  11156. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  11157. int32 quest_id = atoul(sep->arg[0]);
  11158. bool hasQuest = client->GetPlayer()->HasAnyQuest(quest_id);
  11159. if(hasQuest) {
  11160. Quest* quest = master_quest_list.GetQuest(quest_id, false);
  11161. if(quest) {
  11162. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  11163. if (gmi && gmi->group_id) {
  11164. PlayerGroup* group = world.GetGroupManager()->GetGroup(gmi->group_id);
  11165. if (group) {
  11166. group->ShareQuestWithGroup(client, quest);
  11167. }
  11168. }
  11169. }
  11170. }
  11171. else {
  11172. client->SimpleMessage(CHANNEL_COLOR_RED, "Cannot find quest.");
  11173. }
  11174. }
  11175. }
  11176. /*
  11177. Function: Command_Yell()
  11178. Purpose : Yell to break an encounter
  11179. Example : /yell
  11180. * Uses self target, encounter target or no target
  11181. */
  11182. void Commands::Command_Yell(Client* client, Seperator* sep) {
  11183. Entity* player = (Entity*)client->GetPlayer();
  11184. Spawn* res = nullptr;
  11185. Spawn* prev = nullptr;
  11186. bool cycleAll = false;
  11187. if(player->GetTarget() == player) {
  11188. cycleAll = true; // self target breaks all encounters
  11189. }
  11190. else if(player->GetTarget()) {
  11191. res = player->GetTarget(); // selected target other than self only dis-engages that encounter
  11192. }
  11193. if(res && !client->GetPlayer()->IsEngagedBySpawnID(res->GetID()))
  11194. return;
  11195. bool alreadyYelled = false;
  11196. do {
  11197. if(!res && player->IsEngagedInEncounter(&res)) { // no target is set, dis-engage top of hated by list
  11198. }
  11199. if(!res || prev == res) {
  11200. return;
  11201. }
  11202. if(res->IsNPC() && ((NPC*)res)->Brain()) {
  11203. if(!alreadyYelled) {
  11204. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You yell for help!");
  11205. string yellMsg = std::string(client->GetPlayer()->GetName()) + " yelled for help!";
  11206. client->GetPlayer()->GetZone()->SimpleMessage(CHANNEL_COLOR_RED, yellMsg.c_str(), client->GetPlayer(), 35.0f, false);
  11207. client->GetPlayer()->GetZone()->SendYellPacket(client->GetPlayer());
  11208. }
  11209. alreadyYelled = true;
  11210. NPC* npc = (NPC*)res;
  11211. npc->Brain()->ClearEncounter();
  11212. npc->SetLockedNoLoot(ENCOUNTER_STATE_BROKEN);
  11213. npc->UpdateEncounterState(ENCOUNTER_STATE_BROKEN);
  11214. }
  11215. prev = res;
  11216. res = nullptr;
  11217. }while(cycleAll);
  11218. if(!player->IsEngagedInEncounter()) {
  11219. if(player->GetInfoStruct()->get_engaged_encounter()) {
  11220. player->GetInfoStruct()->set_engaged_encounter(0);
  11221. player->SetRegenValues((player->GetInfoStruct()->get_effective_level() > 0) ? player->GetInfoStruct()->get_effective_level() : player->GetLevel());
  11222. client->GetPlayer()->SetCharSheetChanged(true);
  11223. player->info_changed = true;
  11224. }
  11225. }
  11226. }