Commands.cpp 441 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153
  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. LogWrite(COMMAND__DEBUG, 5, "Command", "/info inventory item original index %u", item_index);
  2050. if(client->GetVersion() <= 546) {
  2051. if(item_index <= 255) {
  2052. item_index = 255 - item_index;
  2053. }
  2054. else {
  2055. if(item_index == 256) { // first "new" item to inventory is assigned index 256 by client
  2056. item_index = client->GetPlayer()->item_list.GetFirstNewItem();
  2057. }
  2058. else {
  2059. // otherwise the slot has to be mapped out depending on the amount of new items + index sent in
  2060. item_index = client->GetPlayer()->item_list.GetNewItemByIndex((int16)item_index - 255);
  2061. }
  2062. }
  2063. }
  2064. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  2065. if(item){
  2066. if (item->IsCollectable() && client->SendCollectionsForItem(item))
  2067. break;
  2068. EQ2Packet* app = 0;
  2069. if(client->GetVersion() <= 546) {
  2070. app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  2071. }
  2072. else {
  2073. app = item->serialize(client->GetVersion(), (!item->GetItemScript() || !lua_interface), client->GetPlayer());
  2074. }
  2075. //DumpPacket(app);
  2076. client->QueuePacket(app);
  2077. if(item->GetItemScript() && lua_interface)
  2078. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  2079. else if(item->generic_info.offers_quest_id > 0){ //leave the current functionality in place if it doesnt have an item script
  2080. Quest* quest = master_quest_list.GetQuest(item->generic_info.offers_quest_id, false);
  2081. if(quest && client->GetPlayer()->HasQuestBeenCompleted(item->generic_info.offers_quest_id) == 0 && client->GetPlayer()->HasActiveQuest(item->generic_info.offers_quest_id) == 0)
  2082. client->AddPendingQuest(new Quest(quest)); // copy quest since we pulled the master quest to see if it existed or not
  2083. }
  2084. }
  2085. else
  2086. LogWrite(COMMAND__ERROR, 0, "Command", "/info inventory: Unknown Index: %u", item_index);
  2087. }
  2088. else if(strcmp(sep->arg[0], "equipment") == 0){
  2089. int32 item_index = client->GetPlayer()->ConvertSlotFromClient(atol(sep->arg[1]), client->GetVersion());
  2090. Item* item = client->GetPlayer()->GetEquipmentList()->GetItem(item_index);
  2091. if(item){
  2092. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  2093. client->QueuePacket(app);
  2094. if(item->GetItemScript() && lua_interface)
  2095. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  2096. }
  2097. else
  2098. LogWrite(COMMAND__ERROR, 0, "Command", "/info equipment: Unknown Index: %u", item_index);
  2099. }
  2100. else if(strcmp(sep->arg[0], "appearance") == 0){
  2101. int32 item_index = client->GetPlayer()->ConvertSlotFromClient(atol(sep->arg[1]), client->GetVersion());
  2102. Item* item = client->GetPlayer()->GetAppearanceEquipmentList()->GetItem(item_index);
  2103. if(item){
  2104. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  2105. client->QueuePacket(app);
  2106. if(item->GetItemScript() && lua_interface)
  2107. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  2108. }
  2109. else
  2110. LogWrite(COMMAND__ERROR, 0, "Command", "/info appearance: Unknown Index: %u", item_index);
  2111. }
  2112. 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){
  2113. int32 item_id = atoul(sep->arg[1]);
  2114. Item* item = master_item_list.GetItem(item_id);
  2115. if(item){
  2116. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  2117. client->QueuePacket(app);
  2118. }
  2119. else
  2120. LogWrite(COMMAND__ERROR, 0, "Command", "/info item|merchant|store|buyback|consignment: Unknown Item ID: %u", item_id);
  2121. }
  2122. else if (strcmp(sep->arg[0], "spell") == 0) {
  2123. sint32 spell_id = atol(sep->arg[1]);
  2124. int8 tier = atoi(sep->arg[3]);
  2125. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, tier, client, true, 0x2A);
  2126. if (outapp)
  2127. client->QueuePacket(outapp);
  2128. else
  2129. LogWrite(COMMAND__ERROR, 0, "Command", "/info spell: Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  2130. }
  2131. else if (strcmp(sep->arg[0], "achievement") == 0) {
  2132. sint32 spell_id = atol(sep->arg[2]);
  2133. int8 group = atoi(sep->arg[1]);
  2134. AltAdvanceData* data = 0;
  2135. SpellBookEntry* spellentry = 0;
  2136. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  2137. LogWrite(COMMAND__ERROR, 0, "Command", "/info achievement: AA Spell ID and/or Tier, ID: %u, Group: %i", spell_id, group);
  2138. EQ2Packet* outapp = master_spell_list.GetAASpellPacket(spell_id, tier, client, true, 0x45);
  2139. if (outapp)
  2140. client->QueuePacket(outapp);
  2141. else
  2142. LogWrite(COMMAND__ERROR, 0, "Command", "/info achievement: Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, group);
  2143. }
  2144. else if (strcmp(sep->arg[0], "spellbook") == 0) {
  2145. sint32 spell_id = atol(sep->arg[1]);
  2146. int32 tier = atoi(sep->arg[2]);
  2147. if (tier > 255) {
  2148. SpellBookEntry* ent = client->GetPlayer()->GetSpellBookSpell(spell_id);
  2149. if (ent)
  2150. tier = ent->tier;
  2151. }
  2152. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, (int8)tier, client, true, 0x2A);
  2153. if (outapp)
  2154. client->QueuePacket(outapp);
  2155. else
  2156. LogWrite(COMMAND__ERROR, 0, "Command", "/info spellbook: Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  2157. }
  2158. else if (strcmp(sep->arg[0], "recipe") == 0) {
  2159. sint32 recipe_id = atol(sep->arg[1]);
  2160. EQ2Packet* outapp = master_recipe_list.GetRecipePacket(recipe_id, client, true, 0x2C);
  2161. if(outapp)
  2162. client->QueuePacket(outapp);
  2163. else
  2164. LogWrite(COMMAND__ERROR, 0, "Command", "/info recipe: Unknown Recipe ID: %u", recipe_id);
  2165. }
  2166. else if (strcmp(sep->arg[0], "recipe_product") == 0) {
  2167. sint32 recipe_id = atol(sep->arg[1]);
  2168. PlayerRecipeList* prl = client->GetPlayer()->GetRecipeList();
  2169. Recipe* recipe = nullptr;
  2170. if ((recipe = prl->GetRecipe(recipe_id)) && recipe->GetProductID()) {
  2171. RecipeProducts* rp = recipe->products[1];
  2172. if (recipe->GetProductID() > 0) {
  2173. Item* item = master_item_list.GetItem(recipe->GetProductID());
  2174. if(item){
  2175. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  2176. client->QueuePacket(app);
  2177. }
  2178. else
  2179. LogWrite(COMMAND__ERROR, 0, "Command", "/info recipe_product: Unknown Item ID: %u", recipe->GetProductID());
  2180. }
  2181. else {
  2182. LogWrite(COMMAND__ERROR, 0, "Command", "/info recipe_product: recipe->GetProductID() has value 0 for recipe id %u.", recipe_id);
  2183. }
  2184. }
  2185. else {
  2186. 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);
  2187. }
  2188. }
  2189. else if (strcmp(sep->arg[0], "maintained") ==0) {
  2190. int32 slot = atol(sep->arg[1]);
  2191. int32 spell_id = atol(sep->arg[2]);
  2192. LogWrite(COMMAND__DEBUG, 5, "Command", "/info maintained: Spell ID - Slot: %u unknown: %u", slot, spell_id);
  2193. //int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  2194. MaintainedEffects* info = client->GetPlayer()->GetMaintainedSpellBySlot(slot);
  2195. EQ2Packet* outapp = master_spell_list.GetSpellPacket(info->spell_id, info->tier, client, true, 0x00);
  2196. if(outapp)
  2197. client->QueuePacket(outapp);
  2198. else
  2199. LogWrite(COMMAND__ERROR, 0, "Command", "/info maintained: Unknown Spell ID: %u", spell_id);
  2200. }
  2201. else if (strcmp(sep->arg[0], "effect") == 0) {
  2202. int32 spell_id = atol(sep->arg[1]);
  2203. LogWrite(COMMAND__DEBUG, 5, "Command", "/info effect: Spell ID: %u", spell_id);
  2204. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  2205. int8 type = 0;
  2206. if (client->GetVersion() <= 546)
  2207. type = 1;
  2208. EQ2Packet* outapp = master_spell_list.GetSpecialSpellPacket(spell_id, tier, client, true, type);
  2209. if (outapp){
  2210. client->QueuePacket(outapp);
  2211. }
  2212. else
  2213. LogWrite(COMMAND__ERROR, 0, "Command", "/info effect: Unknown Spell ID: %u", spell_id);
  2214. }
  2215. }
  2216. else if (sep && strcmp(sep->arg[0], "overflow") == 0) {
  2217. Item* item = player->item_list.GetOverflowItem();
  2218. if(item) {
  2219. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  2220. client->QueuePacket(app);
  2221. }
  2222. else
  2223. LogWrite(COMMAND__ERROR, 0,"Command", "/info overflow: Unable to retrieve an overflow item.");
  2224. }
  2225. else
  2226. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /info {inventory|equipment|spell} {id}");
  2227. break;
  2228. }
  2229. case COMMAND_USE_EQUIPPED_ITEM:{
  2230. if (sep && sep->arg[0] && sep->IsNumber(0)){
  2231. int32 slot_id = atoul(sep->arg[0]);
  2232. Item* item = player->GetEquipmentList()->GetItem(slot_id);
  2233. if (item && item->generic_info.usable && item->GetItemScript()) {
  2234. if(!item->CheckFlag2(INDESTRUCTABLE) && item->generic_info.condition == 0) {
  2235. client->SimpleMessage(CHANNEL_COLOR_RED, "This item is broken and must be repaired at a mender before it can be used");
  2236. }
  2237. else if (item->CheckFlag(EVIL_ONLY) && client->GetPlayer()->GetAlignment() != ALIGNMENT_EVIL) {
  2238. client->Message(0, "%s requires an evil race.", item->name.c_str());
  2239. }
  2240. else if (item->CheckFlag(GOOD_ONLY) && client->GetPlayer()->GetAlignment() != ALIGNMENT_GOOD) {
  2241. client->Message(0, "%s requires a good race.", item->name.c_str());
  2242. }
  2243. else {
  2244. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player, player->GetTarget());
  2245. }
  2246. }
  2247. }
  2248. break;
  2249. }
  2250. case COMMAND_USE_ITEM: {
  2251. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  2252. int32 item_index = atoul(sep->arg[0]);
  2253. Item* item = player->item_list.GetItemFromIndex(item_index);
  2254. client->UseItem(item, client->GetPlayer()->GetTarget() ? client->GetPlayer()->GetTarget() : client->GetPlayer());
  2255. }
  2256. break;
  2257. }
  2258. case COMMAND_SCRIBE_SCROLL_ITEM: {
  2259. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  2260. Item* item = player->item_list.GetItemFromUniqueID(atoul(sep->arg[0]));
  2261. if (item) {
  2262. LogWrite(ITEM__DEBUG, 0, "Items", "ITEM ID: %u", item->details.item_id);
  2263. if(item->generic_info.item_type == 6) {
  2264. Spell* spell = master_spell_list.GetSpell(item->skill_info->spell_id, item->skill_info->spell_tier);
  2265. int8 old_slot = 0;
  2266. if (spell) {
  2267. if(!spell->ScribeAllowed(client->GetPlayer())) {
  2268. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not meet one of the requirements to scribe, due to class or level.");
  2269. break;
  2270. }
  2271. int16 tier_up = player->GetTierUp(spell->GetSpellTier());
  2272. if (rule_manager.GetGlobalRule(R_Spells, RequirePreviousTierScribe)->GetInt8() && !player->HasSpell(spell->GetSpellID(), tier_up, false, true))
  2273. client->SimpleMessage(CHANNEL_COLOR_RED, "You have not scribed the required previous version of this ability.");
  2274. else if (!player->HasSpell(spell->GetSpellID(), spell->GetSpellTier(), true)) {
  2275. old_slot = player->GetSpellSlot(spell->GetSpellID());
  2276. player->RemoveSpellBookEntry(spell->GetSpellID());
  2277. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  2278. player->UnlockSpell(spell);
  2279. client->SendSpellUpdate(spell);
  2280. database.DeleteItem(client->GetCharacterID(), item, 0);
  2281. player->item_list.RemoveItem(item, true);
  2282. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  2283. client->QueuePacket(player->SendInventoryUpdate(client->GetVersion()));
  2284. // force purge client cache and display updated spell for hover over
  2285. EQ2Packet* app = spell->SerializeSpell(client, false, false);
  2286. client->QueuePacket(app);
  2287. }
  2288. }
  2289. else
  2290. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown spell ID: %u and tier: %u", item->skill_info->spell_id, item->skill_info->spell_tier);
  2291. }
  2292. else if(item->generic_info.item_type == 7){
  2293. if(item->recipebook_info) {
  2294. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Scribing recipe book %s (%u) for player %s.", item->name.c_str(), item->recipebook_info->recipe_id, player->GetName());
  2295. client->AddRecipeBookToPlayer(item->recipebook_info->recipe_id, item);
  2296. }
  2297. else {
  2298. 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);
  2299. 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());
  2300. }
  2301. }
  2302. else {
  2303. LogWrite(COMMAND__ERROR, 0, "Command", "Recipe Book Info is not set for item %s.", item->name.c_str());
  2304. }
  2305. }
  2306. else
  2307. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown unique item ID: %s", sep->arg[0]);
  2308. }
  2309. break;
  2310. }
  2311. case COMMAND_SUMMONITEM: {
  2312. if (sep && sep->IsNumber(0)) {
  2313. int32 item_id = atol(sep->arg[0]);
  2314. int32 quantity = 1;
  2315. if (sep->arg[1] && sep->IsNumber(1))
  2316. quantity = atoi(sep->arg[1]);
  2317. if (sep->arg[2] && strncasecmp(sep->arg[2], "bank", 4) == 0) {
  2318. client->AddItemToBank(item_id,quantity);
  2319. }
  2320. else {
  2321. client->AddItem(item_id, quantity);
  2322. }
  2323. }
  2324. else {
  2325. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} [quantity] or");
  2326. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} {quantity} [location] where location = bank");
  2327. }
  2328. break;
  2329. }
  2330. case COMMAND_COLLECTION_ADDITEM: {
  2331. // takes 2 params: collection_id, slot
  2332. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  2333. Item *item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(atoul(sep->arg[1]));
  2334. if (item)
  2335. client->HandleCollectionAddItem(atoul(sep->arg[0]), item);
  2336. else
  2337. 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]));
  2338. }
  2339. else
  2340. LogWrite(COLLECTION__ERROR, 0, "Collect", "Received command 'COMMAND_COLLECTION_ADDITEM' with unhandeled argument types");
  2341. break;
  2342. }
  2343. case COMMAND_COLLECTION_FILTER_MATCHITEM: {
  2344. // takes 1 param: slot
  2345. printf("COMMAND_COLLECTION_FILTER_MATCHITEM:\n");
  2346. int i = 0;
  2347. while (sep->arg[i] && strlen(sep->arg[i]) > 0) {
  2348. printf("\t%u: %s\n", i, sep->arg[i]);
  2349. i++;
  2350. }
  2351. break;
  2352. }
  2353. case COMMAND_WAYPOINT: {
  2354. bool success = false;
  2355. client->ClearWaypoint();
  2356. if (sep && sep->IsNumber(0) && sep->IsNumber(1) && sep->IsNumber(2)) {
  2357. if (!client->ShowPathToTarget(atof(sep->arg[0]), atof(sep->arg[1]), atof(sep->arg[2]), 0))
  2358. client->Message(CHANNEL_COLOR_RED, "Invalid coordinates given");
  2359. }
  2360. else if ( client->GetAdminStatus() > 100 && cmdTarget ) {
  2361. if (!client->ShowPathToTarget(cmdTarget->GetX(), cmdTarget->GetY(), cmdTarget->GetZ(), 0))
  2362. client->Message(CHANNEL_COLOR_RED, "Invalid coordinates given");
  2363. }
  2364. else {
  2365. client->Message(CHANNEL_COLOR_YELLOW, "Usage: /waypoint x y z");
  2366. }
  2367. break;
  2368. }
  2369. case COMMAND_WHO:{
  2370. const char* who = 0;
  2371. if(sep && sep->arg[0]){
  2372. //cout << "Who query: \n";
  2373. who = sep->argplus[0];
  2374. //cout << who << endl;
  2375. }
  2376. zone_list.ProcessWhoQuery(who, client);
  2377. break;
  2378. }
  2379. case COMMAND_SELECT_JUNCTION:{
  2380. // transporters (bells birds) use OP_SelectZoneTeleporterDestinatio / ProcessTeleportLocation(app)
  2381. // this is only used for revive it seems
  2382. int32 choice = 0;
  2383. if(sep && sep->arg[0] && sep->IsNumber(0))
  2384. choice = atoul(sep->arg[0]);
  2385. if(!client->GetPlayer()->Alive()){ //dead and this is a revive request
  2386. client->HandlePlayerRevive(choice);
  2387. }
  2388. break;
  2389. }
  2390. case COMMAND_SPAWN_MOVE: {
  2391. if (cmdTarget && cmdTarget->IsPlayer() == false) {
  2392. PacketStruct* packet = configReader.getStruct("WS_MoveObjectMode", client->GetVersion());
  2393. if (packet) {
  2394. float unknown2_3 = 0;
  2395. int8 placement_mode = 0;
  2396. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::DEFAULT);
  2397. if (sep && sep->arg[0][0]) {
  2398. if (strcmp(sep->arg[0], "wall") == 0) {
  2399. placement_mode = 2;
  2400. unknown2_3 = 150;
  2401. }
  2402. else if (strcmp(sep->arg[0], "ceiling") == 0)
  2403. placement_mode = 1;
  2404. else if (strcmp(sep->arg[0], "openheading") == 0 && cmdTarget->IsWidget())
  2405. {
  2406. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "[PlacementMode] WIDGET OPEN HEADING MODE");
  2407. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::OPEN_HEADING);
  2408. }
  2409. else if (strcmp(sep->arg[0], "closeheading") == 0 && cmdTarget->IsWidget())
  2410. {
  2411. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "[PlacementMode] WIDGET CLOSE HEADING MODE");
  2412. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::CLOSE_HEADING);
  2413. }
  2414. else if (strcmp(sep->arg[0], "myloc") == 0)
  2415. {
  2416. if (cmdTarget->GetSpawnLocationPlacementID() < 1) {
  2417. client->Message(CHANNEL_COLOR_YELLOW, "[PlacementMode] Spawn %s cannot be moved it is not assigned a spawn location placement id.", cmdTarget->GetName());
  2418. safe_delete(packet);
  2419. break;
  2420. }
  2421. cmdTarget->SetX(client->GetPlayer()->GetX(), true);
  2422. cmdTarget->SetY(client->GetPlayer()->GetY(), true);
  2423. cmdTarget->SetZ(client->GetPlayer()->GetZ(), true);
  2424. cmdTarget->SetHeading(client->GetPlayer()->GetHeading(), true);
  2425. if (database.UpdateSpawnLocationSpawns(cmdTarget))
  2426. client->Message(CHANNEL_COLOR_YELLOW, "[PlacementMode] Spawn %s placed at your location. Updated spawn_location_placement for spawn.", cmdTarget->GetName());
  2427. safe_delete(packet);
  2428. break;
  2429. }
  2430. }
  2431. packet->setDataByName("placement_mode", placement_mode);
  2432. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget));
  2433. packet->setDataByName("model_type", cmdTarget->GetModelType());
  2434. packet->setDataByName("unknown", 1); //size
  2435. packet->setDataByName("unknown2", 1); //size 2
  2436. packet->setDataByName("unknown2", .5, 1); //size 3
  2437. packet->setDataByName("unknown2", 3, 2);
  2438. packet->setDataByName("unknown2", unknown2_3, 3);
  2439. packet->setDataByName("max_distance", 500);
  2440. packet->setDataByName("CoEunknown", 0xFFFFFFFF);
  2441. client->QueuePacket(packet->serialize());
  2442. safe_delete(packet);
  2443. }
  2444. }
  2445. else {
  2446. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /spawn move (wall OR ceiling)");
  2447. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Moves a spawn anywhere you like. Optionally wall/ceiling can be provided to place wall/ceiling items.");
  2448. }
  2449. break;
  2450. }
  2451. case COMMAND_HAIL:{
  2452. Spawn* spawn = cmdTarget;
  2453. if(spawn && spawn->GetTargetable())
  2454. {
  2455. char tmp[75] = {0};
  2456. sprintf(tmp, "Hail, %s", spawn->GetName());
  2457. bool show_bubble = true;
  2458. if (spawn->IsNPC())
  2459. show_bubble = false;
  2460. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp, HEAR_SPAWN_DISTANCE, 0, show_bubble, client->GetPlayer()->GetCurrentLanguage());
  2461. if(spawn->IsPlayer() == false && spawn->Alive() && spawn->GetDistance(client->GetPlayer()) < rule_manager.GetGlobalRule(R_Spawn, HailDistance)->GetInt32()){
  2462. if(spawn->IsNPC() && ((NPC*)spawn)->EngagedInCombat())
  2463. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED_BUSY, client->GetPlayer());
  2464. else
  2465. {
  2466. bool pauseRunback = false;
  2467. // prime runback as the heading or anything can be altered when hailing succeeds
  2468. if(spawn->IsNPC() && (spawn->HasMovementLoop() || spawn->HasMovementLocations()))
  2469. {
  2470. ((NPC*)spawn)->StartRunback();
  2471. pauseRunback = true;
  2472. }
  2473. if(spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED, client->GetPlayer()) && pauseRunback)
  2474. spawn->PauseMovement(rule_manager.GetGlobalRule(R_Spawn, HailMovementPause)->GetInt32());
  2475. else if(spawn->IsNPC() && pauseRunback)
  2476. ((NPC*)spawn)->ClearRunback();
  2477. }
  2478. }
  2479. }
  2480. else {
  2481. string tmp = "Hail";
  2482. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp.c_str(), HEAR_SPAWN_DISTANCE, 0, true, client->GetPlayer()->GetCurrentLanguage());
  2483. }
  2484. break;
  2485. }
  2486. case COMMAND_SAY:{
  2487. if (sep && sep->arg[0][0]) {
  2488. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, sep->argplus[0], HEAR_SPAWN_DISTANCE, 0, true, client->GetPlayer()->GetCurrentLanguage());
  2489. if (cmdTarget && !(cmdTarget->IsPlayer()))
  2490. client->GetCurrentZone()->CallSpawnScript(cmdTarget, SPAWN_SCRIPT_HEAR_SAY, client->GetPlayer(), sep->argplus[0]);
  2491. }
  2492. else
  2493. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /say {message}");
  2494. break;
  2495. }
  2496. case COMMAND_TELL:{
  2497. if(sep && sep->arg[0] && sep->argplus[1]){
  2498. if(!zone_list.HandleGlobalChatMessage(client, sep->arg[0], CHANNEL_PRIVATE_TELL, sep->argplus[1], 0, client->GetPlayer()->GetCurrentLanguage()))
  2499. client->Message(CHANNEL_COLOR_RED,"Unable to find client %s",sep->arg[0]);
  2500. }else
  2501. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /tell {character_name} {message}");
  2502. break;
  2503. }
  2504. case COMMAND_SHOUT:{
  2505. if(sep && sep->arg[0][0])
  2506. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SHOUT, sep->argplus[0], 0, 0, true, client->GetPlayer()->GetCurrentLanguage());
  2507. else
  2508. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /shout {message}");
  2509. break;
  2510. }
  2511. case COMMAND_AUCTION:{
  2512. if(sep && sep->arg[0][0])
  2513. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_AUCTION, sep->argplus[0], 0, 0, true, client->GetPlayer()->GetCurrentLanguage());
  2514. else
  2515. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /auction {message}");
  2516. break;
  2517. }
  2518. case COMMAND_OOC:{
  2519. //For now ooc will be the global chat channel, eventually when we create more channels we will create a global chat channel
  2520. if(sep && sep->arg[0][0])
  2521. zone_list.HandleGlobalChatMessage(client, 0, CHANNEL_OUT_OF_CHARACTER, sep->argplus[0], 0, client->GetPlayer()->GetCurrentLanguage());
  2522. else
  2523. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /ooc {message}");
  2524. break;
  2525. }
  2526. case COMMAND_EMOTE:{
  2527. if(sep && sep->arg[0][0])
  2528. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_EMOTE, sep->argplus[0]);
  2529. else
  2530. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /emote {action}");
  2531. break;
  2532. }
  2533. case COMMAND_RACE:{
  2534. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  2535. if(sep->arg[1][0] && sep->IsNumber(1)){
  2536. client->GetPlayer()->GetInfoStruct()->set_race(atoi(sep->arg[1]));
  2537. client->GetPlayer()->SetRace(atoi(sep->arg[1]));
  2538. client->UpdateTimeStampFlag ( RACE_UPDATE_FLAG );
  2539. client->GetPlayer()->SetCharSheetChanged(true);
  2540. }
  2541. client->GetPlayer()->SetModelType(atoi(sep->arg[0]));
  2542. //EQ2Packet* outapp = client->GetPlayer()->spawn_update_packet(client->GetPlayer(), client->GetVersion(), client->GetPlayer()->GetFeatures());
  2543. //client->QueuePacket(outapp);
  2544. }
  2545. else{
  2546. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /race {race type id} {race id}");
  2547. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "{race id} is optional");
  2548. }
  2549. break;
  2550. }
  2551. case COMMAND_BANK_DEPOSIT:{
  2552. if(client->GetBanker() && sep && sep->arg[0]){
  2553. int64 amount = 0;
  2554. string deposit = string(sep->arg[0]);
  2555. amount = atoi64(deposit.c_str());
  2556. client->BankDeposit(amount);
  2557. }
  2558. break;
  2559. }
  2560. case COMMAND_BANK_WITHDRAWAL:{
  2561. if(client->GetBanker() && sep && sep->arg[0] && sep->IsNumber(0)){
  2562. int64 amount = 0;
  2563. string deposit = string(sep->arg[0]);
  2564. amount = atoi64(deposit.c_str());
  2565. client->BankWithdrawal(amount);
  2566. }
  2567. break;
  2568. }
  2569. case COMMAND_BANK_CANCEL:{
  2570. Spawn* banker = cmdTarget;
  2571. client->Bank(banker, true);
  2572. break;
  2573. }
  2574. case COMMAND_BANK:{
  2575. LogWrite(PLAYER__DEBUG, 0, "Players", "Open Player Personal Bank...");
  2576. Spawn* banker = cmdTarget;
  2577. client->Bank(banker);
  2578. break;
  2579. }
  2580. case COMMAND_GUILD_BANK:{
  2581. LogWrite(GUILD__DEBUG, 0, "Guilds", "Open Guild Bank...");
  2582. //Spawn* banker = client->GetPlayer()->GetTarget();
  2583. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will eventually open the guild bank!");
  2584. break;
  2585. }
  2586. case COMMAND_START_MAIL: {
  2587. client->SetMailTransaction(cmdTarget);
  2588. client->SendMailList();
  2589. break;
  2590. }
  2591. case COMMAND_CANCEL_MAIL: {
  2592. client->SetMailTransaction(0);
  2593. break;
  2594. }
  2595. case COMMAND_GET_MAIL_MESSAGE: {
  2596. if (sep && sep->arg[0] && sep->IsNumber(0))
  2597. client->DisplayMailMessage(atoul(sep->arg[0]));
  2598. break;
  2599. }
  2600. case COMMAND_ADD_MAIL_PLAT: {
  2601. if (sep && sep->arg[0] && sep->IsNumber(0))
  2602. client->AddMailCoin(0, 0, 0, atoul(sep->arg[0]));
  2603. break;
  2604. }
  2605. case COMMAND_ADD_MAIL_GOLD: {
  2606. if (sep && sep->arg[0] && sep->IsNumber(0))
  2607. client->AddMailCoin(0, 0, atoul(sep->arg[0]));
  2608. break;
  2609. }
  2610. case COMMAND_ADD_MAIL_SILVER: {
  2611. if (sep && sep->arg[0] && sep->IsNumber(0))
  2612. client->AddMailCoin(0, atoul(sep->arg[0]));
  2613. break;
  2614. }
  2615. case COMMAND_ADD_MAIL_COPPER: {
  2616. if (sep && sep->arg[0] && sep->IsNumber(0))
  2617. client->AddMailCoin(atoul(sep->arg[0]));
  2618. break;
  2619. }
  2620. case COMMAND_SET_MAIL_ITEM: {
  2621. if(sep && sep->IsNumber(0) && sep->IsNumber(1))
  2622. {
  2623. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(atoul(sep->arg[0]));
  2624. if(item)
  2625. {
  2626. int16 quantity = atoul(sep->arg[1]);
  2627. if(item->CheckFlag(NO_TRADE) || item->CheckFlag(ATTUNED) || item->CheckFlag(ARTIFACT) || item->CheckFlag2(HEIRLOOM))
  2628. {
  2629. return;
  2630. }
  2631. if(item->IsBag())
  2632. {
  2633. vector<Item*>* bag_items = player->GetPlayerItemList()->GetItemsInBag(item);
  2634. if(bag_items && bag_items->size() > 0)
  2635. {
  2636. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot mail a bag with items inside it.");
  2637. safe_delete(bag_items);
  2638. return;
  2639. }
  2640. safe_delete(bag_items);
  2641. }
  2642. Item* itemtoadd = item;
  2643. if(quantity > 0)
  2644. {
  2645. if(quantity > item->details.count)
  2646. return;
  2647. Item* tmpItem = new Item(item);
  2648. tmpItem->details.count = quantity;
  2649. itemtoadd = tmpItem;
  2650. }
  2651. if(client->AddMailItem(itemtoadd))
  2652. {
  2653. client->RemoveItem(item, quantity, true);
  2654. }
  2655. }
  2656. }
  2657. break;
  2658. }
  2659. case COMMAND_REMOVE_MAIL_PLAT: {
  2660. if (sep && sep->arg[0] && sep->IsNumber(0))
  2661. client->RemoveMailCoin(0, 0, 0, atoul(sep->arg[0]));
  2662. break;
  2663. }
  2664. case COMMAND_REMOVE_MAIL_GOLD: {
  2665. if (sep && sep->arg[0] && sep->IsNumber(0))
  2666. client->RemoveMailCoin(0, 0, atoul(sep->arg[0]));
  2667. break;
  2668. }
  2669. case COMMAND_REMOVE_MAIL_SILVER: {
  2670. if (sep && sep->arg[0] && sep->IsNumber(0))
  2671. client->RemoveMailCoin(0, atoul(sep->arg[0]));
  2672. break;
  2673. }
  2674. case COMMAND_REMOVE_MAIL_COPPER: {
  2675. if (sep && sep->arg[0] && sep->IsNumber(0))
  2676. client->RemoveMailCoin(atoul(sep->arg[0]));
  2677. break;
  2678. }
  2679. case COMMAND_TAKE_MAIL_ATTACHMENTS: {
  2680. if (sep && sep->arg[0] && sep->IsNumber(0))
  2681. client->TakeMailAttachments(atoul(sep->arg[0]));
  2682. break;
  2683. }
  2684. case COMMAND_CANCEL_SEND_MAIL: {
  2685. client->ResetSendMail();
  2686. break;
  2687. }
  2688. case COMMAND_DELETE_MAIL_MESSAGE: {
  2689. if (sep && sep->arg[0] && sep->IsNumber(0))
  2690. client->DeleteMail(atoul(sep->arg[0]), true);
  2691. break;
  2692. }
  2693. case COMMAND_REPORT_SPAM: {
  2694. LogWrite(MISC__TODO, 1, "TODO", " received reportspam\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  2695. if (sep && sep->arg[0]) LogWrite(COMMAND__DEBUG, 0, "Command", "%s\n", sep->argplus[0]);
  2696. break;
  2697. }
  2698. case COMMAND_KILL:{
  2699. Spawn* dead = 0;
  2700. if (sep && sep->arg[0] && strncasecmp(sep->arg[0],"self",4)==0){
  2701. dead=client->GetPlayer();
  2702. client->GetPlayer()->SetHP(0);
  2703. client->GetPlayer()->KillSpawn(dead);
  2704. }else{
  2705. dead= cmdTarget;
  2706. if(dead && dead->IsPlayer() == false){
  2707. if(dead->IsNPC() && ((NPC*)dead)->Brain()) {
  2708. client->GetPlayer()->CheckEncounterState((Entity*)dead);
  2709. ((NPC*)dead)->Brain()->AddToEncounter(client->GetPlayer());
  2710. ((NPC*)dead)->AddTargetToEncounter(client->GetPlayer());
  2711. ((NPC*)dead)->Brain()->AddHate(client->GetPlayer(), 1);
  2712. }
  2713. dead->SetHP(0);
  2714. if(sep && sep->arg[0] && sep->IsNumber(0) && atoi(sep->arg[0]) == 1)
  2715. client->GetCurrentZone()->RemoveSpawn(dead, true, true, true, true, true);
  2716. else
  2717. client->GetPlayer()->KillSpawn(dead);
  2718. }else{
  2719. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /kill (self)");
  2720. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Kills currently selected non-player target.");
  2721. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Optionally, self may be used to kill yourself");
  2722. }
  2723. }
  2724. break;
  2725. }
  2726. case COMMAND_LEVEL:{
  2727. if(sep && sep->arg[ndx][0] && sep->IsNumber(0)){
  2728. int16 new_level = atoi(sep->arg[ndx]);
  2729. if (!client->GetPlayer()->CheckLevelStatus(new_level))
  2730. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have the required status to level up anymore!");
  2731. else {
  2732. if (new_level < 1)
  2733. new_level = 1;
  2734. if (new_level > 255)
  2735. new_level = 255;
  2736. client->ChangeLevel(client->GetPlayer()->GetLevel(), new_level);
  2737. }
  2738. }else
  2739. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /level {new_level}");
  2740. break;
  2741. }
  2742. case COMMAND_SIT: {
  2743. if(client->GetPlayer()->GetHP() > 0){
  2744. client->QueuePacket(new EQ2Packet(OP_SitMsg, 0, 0));
  2745. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You sit down.");
  2746. client->GetPlayer()->set_character_flag(CF_IS_SITTING);
  2747. }
  2748. break;
  2749. }
  2750. case COMMAND_STAND: {
  2751. if(client->GetPlayer()->GetHP() > 0){
  2752. client->QueuePacket(new EQ2Packet(OP_StandMsg, 0, 0));
  2753. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You stand up.");
  2754. client->GetPlayer()->reset_character_flag(CF_IS_SITTING);
  2755. }
  2756. break;
  2757. }
  2758. case COMMAND_CLASS:{
  2759. if(sep && sep->arg[ndx][0]){
  2760. client->GetPlayer()->SetPlayerAdventureClass(atoi(sep->arg[ndx]));
  2761. client->UpdateTimeStampFlag ( CLASS_UPDATE_FLAG );
  2762. }else
  2763. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /class {class_id}");
  2764. break;
  2765. }
  2766. case COMMAND_FLYMODE:{
  2767. if(sep && sep->arg[0] && sep->IsNumber(0)){
  2768. PrintSep(sep, "COMMAND_FLYMODE");
  2769. int8 val = atoul(sep->arg[0]);
  2770. ClientPacketFunctions::SendFlyMode(client, val);
  2771. }
  2772. else{
  2773. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage ON: /flymode [1|2] 1 = fly, 2 = no clip");
  2774. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage OFF: /flymode 0");
  2775. }
  2776. break;
  2777. }
  2778. case COMMAND_LOOT_LIST:{
  2779. Spawn* spawn = cmdTarget;
  2780. if(spawn && spawn->IsEntity()){
  2781. if (sep && sep->arg[0]) {
  2782. if (!spawn->GetDatabaseID())
  2783. {
  2784. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "NOTE: Spawn has no database id to assign to loottables.");
  2785. }
  2786. if (!spawn->IsNPC())
  2787. {
  2788. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "these /loot list [add/remove/clearall] sub-commands are only designed for an NPC.");
  2789. break;
  2790. }
  2791. bool reloadLoot = false;
  2792. if (!stricmp(sep->arg[0], "remove") && sep->arg[1] && sep->IsNumber(1))
  2793. {
  2794. int32 loottable_id = atoul(sep->arg[1]);
  2795. if (loottable_id > 0 && database.RemoveSpawnLootTable(spawn, loottable_id))
  2796. {
  2797. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u loot table %u removed.", spawn->GetDatabaseID(), loottable_id);
  2798. reloadLoot = true;
  2799. }
  2800. else
  2801. client->Message(CHANNEL_COLOR_YELLOW, "/loot list remove [loottableid] - could not match any spawn_id entries against loottable_id %u.", loottable_id);
  2802. }
  2803. else if (!stricmp(sep->arg[0], "add") && sep->arg[1] && sep->IsNumber(1))
  2804. {
  2805. int32 loottable_id = atoul(sep->arg[1]);
  2806. if (loottable_id > 0)
  2807. {
  2808. database.AddLootTableToSpawn(spawn, loottable_id);
  2809. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u loot table %u added.", spawn->GetDatabaseID(), loottable_id);
  2810. reloadLoot = true;
  2811. }
  2812. else
  2813. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list add [loottableid] - cannot add a loottable id of 0.");
  2814. }
  2815. else if (!stricmp(sep->arg[0], "clearall"))
  2816. {
  2817. if (database.RemoveSpawnLootTable(spawn, 0))
  2818. {
  2819. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn loot tables removed.");
  2820. reloadLoot = true;
  2821. }
  2822. else
  2823. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list clearall - could not match any spawn_id entries in loottable_id.");
  2824. }
  2825. else if (!stricmp(sep->arg[0], "details"))
  2826. {
  2827. spawn->LockLoot();
  2828. client->SimpleMessage(CHANNEL_COMMANDS, "Loot Window List:");
  2829. if (spawn->GetLootWindowList()->size() > 0) {
  2830. std::map<int32, bool>::iterator itr;
  2831. for (itr = spawn->GetLootWindowList()->begin(); itr != spawn->GetLootWindowList()->end(); itr++) {
  2832. Spawn* looter = client->GetPlayer()->GetZone()->GetSpawnByID(itr->first);
  2833. if (looter) {
  2834. client->Message(CHANNEL_COLOR_YELLOW, "Looter: %s IsLootWindowOpen: %s, HasCompletedLootWindow: %s.", looter->GetName(), itr->second ? "NO" : "YES", spawn->HasSpawnLootWindowCompleted(itr->first) ? "YES" : "NO");
  2835. }
  2836. }
  2837. }
  2838. spawn->UnlockLoot();
  2839. }
  2840. else
  2841. {
  2842. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list argument not supported.");
  2843. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list add [loottableid] - add new loottable to spawn");
  2844. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list remove [loottableid] - remove existing loottable from spawn");
  2845. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list clearall - remove all loottables from spawn");
  2846. break;
  2847. }
  2848. if (reloadLoot)
  2849. {
  2850. database.LoadSpawnLoot(spawn->GetZone(), spawn);
  2851. if (spawn->IsNPC())
  2852. {
  2853. Entity* ent = (Entity*)spawn;
  2854. ent->SetLootCoins(0);
  2855. ent->ClearLoot();
  2856. spawn->GetZone()->AddLoot((NPC*)spawn);
  2857. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u active loot purged and reloaded.", spawn->GetDatabaseID());
  2858. }
  2859. }
  2860. break; // nothing further this is the end of these sub commands
  2861. }
  2862. else
  2863. {
  2864. vector<int32> loot_list = client->GetCurrentZone()->GetSpawnLootList(spawn->GetDatabaseID(), spawn->GetZone()->GetZoneID(), spawn->GetLevel(), race_types_list.GetRaceType(spawn->GetModelType()), spawn);
  2865. if (loot_list.size() > 0) {
  2866. client->Message(CHANNEL_COLOR_YELLOW, "%s belongs to the following loot lists: ", spawn->GetName());
  2867. vector<int32>::iterator list_itr;
  2868. LootTable* table = 0;
  2869. for (list_itr = loot_list.begin(); list_itr != loot_list.end(); list_itr++) {
  2870. table = client->GetCurrentZone()->GetLootTable(*list_itr);
  2871. if (table)
  2872. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", *list_itr, table->name.c_str());
  2873. }
  2874. }
  2875. client->Message(CHANNEL_COLOR_YELLOW, "Coins being carried: %u", spawn->GetLootCoins());
  2876. vector<Item*>* items = spawn->GetLootItems();
  2877. if (items) {
  2878. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is carrying the following items: ");
  2879. vector<Item*>::iterator itr;
  2880. Item* item = 0;
  2881. for (itr = items->begin(); itr != items->end(); itr++) {
  2882. item = *itr;
  2883. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", item->details.item_id, item->name.c_str());
  2884. }
  2885. }
  2886. else
  2887. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is not carrying any items.");
  2888. }
  2889. }
  2890. break;
  2891. }
  2892. case COMMAND_LOOT_SETCOIN:{
  2893. Spawn* spawn = cmdTarget;
  2894. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2895. spawn->SetLootCoins(atoul(sep->arg[0]));
  2896. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully set coins.");
  2897. }
  2898. else
  2899. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot setcoin {amount}");
  2900. break;
  2901. }
  2902. case COMMAND_LOOT_ADDITEM:{
  2903. Spawn* spawn = cmdTarget;
  2904. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2905. int16 charges = 1;
  2906. if(sep->arg[1] && sep->IsNumber(1))
  2907. charges = atoi(sep->arg[1]);
  2908. spawn->AddLootItem(atoul(sep->arg[0]), charges);
  2909. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully added item.");
  2910. }
  2911. else
  2912. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot additem {item_id}");
  2913. break;
  2914. }
  2915. case COMMAND_LOOT_REMOVEITEM:{
  2916. Spawn* spawn = cmdTarget;
  2917. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2918. Item* item = spawn->LootItem(atoul(sep->arg[0]));
  2919. lua_interface->SetLuaUserDataStale(item);
  2920. safe_delete(item);
  2921. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully removed item.");
  2922. }
  2923. else
  2924. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot removeitem {item_id}");
  2925. break;
  2926. }
  2927. case COMMAND_LOOT_CORPSE:
  2928. case COMMAND_DISARM:
  2929. case COMMAND_LOOT:{
  2930. if (cmdTarget && ((Entity*)cmdTarget)->IsNPC() && cmdTarget->Alive())
  2931. {
  2932. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is not dead.");
  2933. break;
  2934. }
  2935. if(cmdTarget && cmdTarget->IsEntity()){
  2936. if (cmdTarget->GetDistance(client->GetPlayer()) <= rule_manager.GetGlobalRule(R_Loot, LootRadius)->GetFloat()){
  2937. if (!rule_manager.GetGlobalRule(R_Loot, AutoDisarmChest)->GetBool() && command->handler == COMMAND_DISARM )
  2938. client->OpenChest(cmdTarget, true);
  2939. else
  2940. client->LootSpawnRequest(cmdTarget, rule_manager.GetGlobalRule(R_Loot, AutoDisarmChest)->GetBool());
  2941. if (!(cmdTarget)->HasLoot()){
  2942. if (((Entity*)cmdTarget)->IsNPC())
  2943. client->GetCurrentZone()->RemoveDeadSpawn(cmdTarget);
  2944. }
  2945. }
  2946. else
  2947. client->Message(CHANNEL_COLOR_YELLOW, "You are too far away to interact with that");
  2948. }
  2949. else if(!cmdTarget || cmdTarget->GetHP() > 0)
  2950. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid target.");
  2951. break;
  2952. }
  2953. case COMMAND_RELOADSPAWNSCRIPTS:{
  2954. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spawn Scripts....");
  2955. if (lua_interface)
  2956. lua_interface->SetLuaSystemReloading(true);
  2957. world.ResetSpawnScripts();
  2958. database.LoadSpawnScriptData();
  2959. if(lua_interface) {
  2960. lua_interface->DestroySpawnScripts();
  2961. lua_interface->SetLuaSystemReloading(false);
  2962. }
  2963. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Success!");
  2964. break;
  2965. }
  2966. case COMMAND_RELOADREGIONSCRIPTS:{
  2967. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Region Scripts....");
  2968. if(lua_interface) {
  2969. lua_interface->DestroyRegionScripts();
  2970. }
  2971. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Success!");
  2972. break;
  2973. }
  2974. case COMMAND_RELOADLUASYSTEM:{
  2975. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Attempting to reload entire LUA system....");
  2976. world.SetReloadingSubsystem("LuaSystem");
  2977. if(lua_interface) {
  2978. lua_interface->SetLuaSystemReloading(true);
  2979. }
  2980. zone_list.DeleteSpellProcess();
  2981. master_spell_list.Reload();
  2982. if (lua_interface)
  2983. lua_interface->ReloadSpells();
  2984. zone_list.LoadSpellProcess();
  2985. if(lua_interface){
  2986. map<Client*, int32> debug_clients = lua_interface->GetDebugClients();
  2987. map<Client*, int32>::iterator itr;
  2988. for(itr = debug_clients.begin(); itr != debug_clients.end(); itr++){
  2989. if(lua_interface)
  2990. lua_interface->UpdateDebugClients(itr->first);
  2991. }
  2992. }
  2993. world.ResetSpawnScripts();
  2994. database.LoadSpawnScriptData();
  2995. world.ResetZoneScripts();
  2996. database.LoadZoneScriptData();
  2997. if(lua_interface) {
  2998. lua_interface->DestroySpawnScripts();
  2999. lua_interface->DestroyRegionScripts();
  3000. lua_interface->DestroyQuests();
  3001. lua_interface->DestroyItemScripts();
  3002. lua_interface->DestroyZoneScripts();
  3003. }
  3004. int32 quest_count = database.LoadQuests();
  3005. int32 spell_count = 0;
  3006. if(lua_interface) {
  3007. spell_count = database.LoadSpellScriptData();
  3008. lua_interface->SetLuaSystemReloading(false);
  3009. }
  3010. world.RemoveReloadingSubSystem("LuaSystem");
  3011. client->Message(CHANNEL_COLOR_YELLOW, "Successfully loaded %u spell(s), %u quest(s).", spell_count, quest_count);
  3012. break;
  3013. }
  3014. case COMMAND_DECLINE_QUEST:{
  3015. int32 quest_id = 0;
  3016. if(sep && sep->arg[0] && sep->IsNumber(0))
  3017. quest_id = atoul(sep->arg[0]);
  3018. if(quest_id > 0){
  3019. client->RemovePendingQuest(quest_id);
  3020. }
  3021. break;
  3022. }
  3023. case COMMAND_DELETE_QUEST:{
  3024. int32 quest_id = 0;
  3025. if(sep && sep->arg[0] && sep->IsNumber(0))
  3026. quest_id = atoul(sep->arg[0]);
  3027. if(quest_id > 0){
  3028. client->GetPlayer()->MPlayerQuests.readlock(__FUNCTION__, __LINE__);
  3029. if(lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0) {
  3030. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  3031. client->GetPlayer()->MPlayerQuests.releasereadlock(__FUNCTION__, __LINE__);
  3032. if (quest && quest->CanDeleteQuest()) {
  3033. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  3034. client->RemovePlayerQuest(quest_id);
  3035. client->GetCurrentZone()->SendQuestUpdates(client);
  3036. }
  3037. }
  3038. else {
  3039. client->GetPlayer()->MPlayerQuests.releasereadlock(__FUNCTION__, __LINE__);
  3040. }
  3041. }
  3042. break;
  3043. }
  3044. case COMMAND_ACCEPT_QUEST:{
  3045. int32 quest_id = 0;
  3046. if(sep && sep->arg[0] && sep->IsNumber(0))
  3047. quest_id = atoul(sep->arg[0]);
  3048. if(quest_id > 0){
  3049. client->AcceptQuest(quest_id);
  3050. }
  3051. break;
  3052. }
  3053. case COMMAND_NAME:{
  3054. if(sep && sep->arg[ndx][0]){
  3055. client->GetPlayer()->GetInfoStruct()->set_name(std::string(sep->arg[ndx]).substr(0,39));
  3056. client->GetPlayer()->SetCharSheetChanged(true);
  3057. }else
  3058. client->Message(CHANNEL_COLOR_YELLOW,"Usage: /name {new_name}");
  3059. break;
  3060. }
  3061. case COMMAND_GROUP: {
  3062. if(sep && sep->arg[0])
  3063. printf("Group: %s\n",sep->argplus[0]);
  3064. break;
  3065. }
  3066. case COMMAND_GROUPSAY:{
  3067. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  3068. if(sep && sep->arg[0] && gmi)
  3069. world.GetGroupManager()->GroupChatMessage(gmi->group_id, client->GetPlayer(), client->GetPlayer()->GetCurrentLanguage(), sep->argplus[0]);
  3070. break;
  3071. }
  3072. case COMMAND_GROUPINVITE: {
  3073. Entity* target = 0;
  3074. Client* target_client = 0;
  3075. if (client->GetPlayer()->GetGroupMemberInfo() && !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  3076. client->SimpleMessage(CHANNEL_COMMANDS, "You must be the group leader to invite.");
  3077. return;
  3078. }
  3079. // name provided with command so it has to be a player, npc not supported here
  3080. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0){
  3081. target_client = zone_list.GetClientByCharName(sep->arg[0]);
  3082. if (target_client) {
  3083. if (!target_client->IsConnected() || !target_client->IsReadyForSpawns())
  3084. target = 0;
  3085. else
  3086. target = target_client->GetPlayer();
  3087. }
  3088. }
  3089. // if name was not provided use the players target, npc or player supported here
  3090. if (!target && client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  3091. target = (Entity*)client->GetPlayer()->GetTarget();
  3092. if (target->IsPlayer()) {
  3093. target_client = ((Player*)target)->GetClient();
  3094. }
  3095. }
  3096. int8 result = world.GetGroupManager()->Invite(client->GetPlayer(), target);
  3097. if (result == 0) {
  3098. client->Message(CHANNEL_COMMANDS, "You invite %s to group with you.", target->GetName());
  3099. if (target_client) {
  3100. PacketStruct* packet = configReader.getStruct("WS_ReceiveOffer", target_client->GetVersion());
  3101. if (packet) {
  3102. packet->setDataByName("type", 1);
  3103. packet->setDataByName("name", client->GetPlayer()->GetName());
  3104. packet->setDataByName("unknown2", 1);
  3105. target_client->QueuePacket(packet->serialize());
  3106. safe_delete(packet);
  3107. }
  3108. }
  3109. }
  3110. else if (result == 1)
  3111. client->SimpleMessage(CHANNEL_COMMANDS, "That player is already in a group.");
  3112. else if (result == 2)
  3113. client->SimpleMessage(CHANNEL_COMMANDS, "That player has been invited to another group.");
  3114. else if (result == 3)
  3115. client->SimpleMessage(CHANNEL_COMMANDS, "Your group is already full.");
  3116. else if (result == 4)
  3117. client->SimpleMessage(CHANNEL_COMMANDS, "You have a pending invitation, cancel it first.");
  3118. else if (result == 5)
  3119. client->SimpleMessage(CHANNEL_COMMANDS, "You cannot invite yourself!");
  3120. else if (result == 6)
  3121. client->SimpleMessage(CHANNEL_COMMANDS, "Could not locate the player.");
  3122. else
  3123. client->SimpleMessage(CHANNEL_COMMANDS, "Group invite failed, unknown error!");
  3124. break;
  3125. }
  3126. case COMMAND_GROUPDISBAND: {
  3127. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  3128. if (gmi) { // TODO: Leader check
  3129. // world.GetGroupManager()->SimpleGroupMessage(gmi->group_id, "Your group has been disbanded.");
  3130. world.GetGroupManager()->RemoveGroup(gmi->group_id);
  3131. }
  3132. break;
  3133. }
  3134. case COMMAND_GROUP_LEAVE: {
  3135. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  3136. if (gmi) {
  3137. int32 group_id = gmi->group_id;
  3138. world.GetGroupManager()->RemoveGroupMember(group_id, client->GetPlayer());
  3139. if (!world.GetGroupManager()->IsGroupIDValid(group_id)) {
  3140. // leader->Message(CHANNEL_COLOR_GROUP, "%s has left the group.", client->GetPlayer()->GetName());
  3141. }
  3142. else {
  3143. world.GetGroupManager()->GroupMessage(group_id, "%s has left the group.", client->GetPlayer()->GetName());
  3144. }
  3145. client->SimpleMessage(CHANNEL_GROUP_CHAT, "You have left the group");
  3146. }
  3147. break;
  3148. }
  3149. case COMMAND_FRIEND_ADD:{
  3150. string name = "";
  3151. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  3152. name = database.GetPlayerName(sep->arg[0]);
  3153. else if(cmdTarget && cmdTarget->IsPlayer())
  3154. name = string(cmdTarget->GetName());
  3155. if(name.length() > 0){
  3156. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  3157. if(client->GetPlayer()->IsIgnored(name.c_str())){
  3158. client->GetPlayer()->RemoveIgnore(name.c_str());
  3159. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  3160. client->SendChatRelationship(3, name.c_str());
  3161. }
  3162. client->GetPlayer()->AddFriend(name.c_str(), true);
  3163. client->SendChatRelationship(0, name.c_str());
  3164. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added friend: %s", name.c_str());
  3165. if(zone_list.GetClientByCharName(name))
  3166. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Friend: %s has logged in.", name.c_str());
  3167. }
  3168. else
  3169. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot be more friendly towards yourself!");
  3170. }
  3171. else
  3172. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  3173. break;
  3174. }
  3175. case COMMAND_FRIEND_REMOVE:{
  3176. string name = "";
  3177. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  3178. name = database.GetPlayerName(sep->arg[0]);
  3179. else if(cmdTarget && cmdTarget->IsPlayer())
  3180. name = string(cmdTarget->GetName());
  3181. if(name.length() > 0){
  3182. client->GetPlayer()->RemoveFriend(name.c_str());
  3183. client->SendChatRelationship(1, name.c_str());
  3184. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  3185. }
  3186. else
  3187. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  3188. break;
  3189. }
  3190. case COMMAND_FRIENDS:{
  3191. break;
  3192. }
  3193. case COMMAND_IGNORE_ADD:{
  3194. string name = "";
  3195. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  3196. name = database.GetPlayerName(sep->arg[0]);
  3197. else if(cmdTarget && cmdTarget->IsPlayer())
  3198. name = string(cmdTarget->GetName());
  3199. if(name.length() > 0){
  3200. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  3201. if(client->GetPlayer()->IsFriend(name.c_str())){
  3202. client->GetPlayer()->RemoveFriend(name.c_str());
  3203. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  3204. client->SendChatRelationship(1, name.c_str());
  3205. }
  3206. client->GetPlayer()->AddIgnore(name.c_str(), true);
  3207. client->SendChatRelationship(2, name.c_str());
  3208. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added ignore: %s", name.c_str());
  3209. }
  3210. else
  3211. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot ignore yourself!");
  3212. }
  3213. else
  3214. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  3215. break;
  3216. }
  3217. case COMMAND_IGNORE_REMOVE:{
  3218. string name = "";
  3219. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  3220. name = database.GetPlayerName(sep->arg[0]);
  3221. else if(cmdTarget && cmdTarget->IsPlayer())
  3222. name = string(cmdTarget->GetName());
  3223. if(name.length() > 0){
  3224. client->GetPlayer()->RemoveIgnore(name.c_str());
  3225. client->SendChatRelationship(3, name.c_str());
  3226. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  3227. }
  3228. break;
  3229. }
  3230. case COMMAND_IGNORES:{
  3231. break;
  3232. }
  3233. case COMMAND_GROUP_KICK:{
  3234. Entity* kicked = 0;
  3235. Client* kicked_client = 0;
  3236. int32 group_id = 0;
  3237. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader)
  3238. return;
  3239. if (sep && sep->arg[0]) {
  3240. kicked_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  3241. if (kicked_client)
  3242. kicked = kicked_client->GetPlayer();
  3243. }
  3244. else if (cmdTarget && cmdTarget->IsEntity()) {
  3245. kicked = (Entity*)cmdTarget;
  3246. }
  3247. group_id = client->GetPlayer()->GetGroupMemberInfo()->group_id;
  3248. bool send_kicked_message = world.GetGroupManager()->GetGroupSize(group_id) > 2;
  3249. if (kicked)
  3250. world.GetGroupManager()->RemoveGroupMember(group_id, kicked);
  3251. if(send_kicked_message)
  3252. world.GetGroupManager()->GroupMessage(group_id, "%s was kicked from the group.", kicked->GetName());
  3253. else
  3254. client->Message(CHANNEL_GROUP_CHAT, "You kicked %s from the group", kicked->GetName());
  3255. if (kicked_client)
  3256. kicked_client->SimpleMessage(CHANNEL_GROUP_CHAT, "You were kicked from the group");
  3257. break;
  3258. }
  3259. case COMMAND_GROUP_MAKE_LEADER:{
  3260. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  3261. client->SimpleMessage(CHANNEL_COMMANDS, "You are not a group leader.");
  3262. return;
  3263. }
  3264. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 1) {
  3265. Client* new_leader = zone_list.GetClientByCharName(sep->arg[0]);
  3266. if (new_leader && new_leader->GetPlayer()->GetGroupMemberInfo() && new_leader->GetPlayer()->GetGroupMemberInfo()->group_id == client->GetPlayer()->GetGroupMemberInfo()->group_id) {
  3267. if (client->GetPlayer()->IsGroupMember(new_leader->GetPlayer())) {
  3268. if(world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, new_leader->GetPlayer())) {
  3269. world.GetGroupManager()->GroupMessage(client->GetPlayer()->GetGroupMemberInfo()->group_id, "%s is now leader of the group.", new_leader->GetPlayer()->GetName());
  3270. }
  3271. }
  3272. }
  3273. else
  3274. client->SimpleMessage(CHANNEL_COMMANDS, "Unable to find the given player.");
  3275. }
  3276. else if (cmdTarget && cmdTarget->IsPlayer() && ((Player*)cmdTarget)->GetGroupMemberInfo() && ((Player*)cmdTarget)->GetGroupMemberInfo()->group_id == client->GetPlayer()->GetGroupMemberInfo()->group_id) {
  3277. if(client->GetPlayer()->IsGroupMember((Player*)cmdTarget) && world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, (Entity*)cmdTarget)) {
  3278. world.GetGroupManager()->GroupMessage(client->GetPlayer()->GetGroupMemberInfo()->group_id, "%s is now leader of the group.", cmdTarget->GetName());
  3279. }
  3280. }
  3281. else
  3282. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to change group leader.");
  3283. break;
  3284. }
  3285. case COMMAND_GROUP_ACCEPT_INVITE: {
  3286. if((sep && sep->arg[0] && strcmp(sep->arg[0], "group") == 0) || (!sep && client->GetVersion() <= 546)) {
  3287. int8 result = world.GetGroupManager()->AcceptInvite(client->GetPlayer());
  3288. if (result == 0)
  3289. client->SimpleMessage(CHANNEL_GROUP_CHAT, "You have joined the group.");
  3290. else if (result == 1)
  3291. client->SimpleMessage(CHANNEL_GROUP_CHAT, "You do not have a pending invite.");
  3292. else if (result == 2)
  3293. client->SimpleMessage(CHANNEL_GROUP_CHAT, "Unable to join group - could not find leader.");
  3294. else
  3295. client->SimpleMessage(CHANNEL_GROUP_CHAT, "Unable to join group - unknown error.");
  3296. }
  3297. break;
  3298. }
  3299. case COMMAND_GROUP_DECLINE_INVITE: {
  3300. if(sep && sep->arg[0] && strcmp(sep->arg[0], "group") == 0) {
  3301. world.GetGroupManager()->DeclineInvite(client->GetPlayer()); // TODO: Add message to leader
  3302. }
  3303. break;
  3304. }
  3305. case COMMAND_SUMMON:{
  3306. char* search_name = 0;
  3307. if(sep && sep->arg[0][0])
  3308. search_name = sep->arg[0];
  3309. if(!search_name && !cmdTarget){
  3310. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /summon [name]");
  3311. 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.");
  3312. }
  3313. else{
  3314. if(!client->Summon(search_name))
  3315. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  3316. }
  3317. break;
  3318. }
  3319. case COMMAND_GOTO:{
  3320. const char* search_name = 0;
  3321. if(sep && sep->arg[0][0])
  3322. search_name = sep->argplus[0];
  3323. if(!search_name && !cmdTarget){
  3324. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /goto [name]");
  3325. 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.");
  3326. }
  3327. else{
  3328. if(!client->GotoSpawn(search_name))
  3329. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  3330. }
  3331. break;
  3332. }
  3333. case COMMAND_MOVE:{
  3334. bool success = false;
  3335. try{
  3336. if(sep && sep->arg[2][0] && sep->IsNumber(0) && sep->IsNumber(1) && sep->IsNumber(2)){
  3337. EQ2Packet* app = client->GetPlayer()->Move(atof(sep->arg[0]), atof(sep->arg[1]), atof(sep->arg[2]), client->GetVersion());
  3338. if(app){
  3339. client->QueuePacket(app);
  3340. success = true;
  3341. }
  3342. }
  3343. }
  3344. catch(...){}
  3345. if(!success){
  3346. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /move x y z");
  3347. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Moves the client to the given coordinates.");
  3348. }
  3349. break;
  3350. }
  3351. case COMMAND_SETTIME:{
  3352. if(sep && sep->arg[0]){
  3353. world.MWorldTime.writelock(__FUNCTION__, __LINE__);
  3354. sscanf (sep->arg[0], "%d:%d", &world.GetWorldTimeStruct()->hour, &world.GetWorldTimeStruct()->minute);
  3355. if(sep->arg[1] && sep->IsNumber(1))
  3356. world.GetWorldTimeStruct()->month = atoi(sep->arg[1]) - 1; //zero based indexes
  3357. if(sep->arg[2] && sep->IsNumber(2))
  3358. world.GetWorldTimeStruct()->day = atoi(sep->arg[2]) - 1; //zero based indexes
  3359. if(sep->arg[3] && sep->IsNumber(3))
  3360. world.GetWorldTimeStruct()->year = atoi(sep->arg[3]);
  3361. world.MWorldTime.releasewritelock(__FUNCTION__, __LINE__);
  3362. client->GetCurrentZone()->SendTimeUpdateToAllClients();
  3363. }
  3364. else{
  3365. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /settime [hour:minute] (month) (day) (year)");
  3366. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Example: /settime 8:30");
  3367. }
  3368. break;
  3369. }
  3370. case COMMAND_VERSION:{
  3371. client->Message(CHANNEL_COLOR_YELLOW,"%s %s", EQ2EMU_MODULE, CURRENT_VERSION);
  3372. client->Message(CHANNEL_COLOR_YELLOW,"Last Compiled on %s %s", COMPILE_DATE, COMPILE_TIME);
  3373. break;
  3374. }
  3375. case COMMAND_ZONE:{
  3376. int32 instanceID = 0;
  3377. string zone;
  3378. int32 zone_id = 0;
  3379. bool listSearch = false;
  3380. bool isInstance = false;
  3381. ZoneServer* zsZone = 0;
  3382. if(sep && sep->arg[0][0])
  3383. {
  3384. if(strncasecmp(sep->arg[0], "list", 4) == 0)
  3385. listSearch = true;
  3386. else if(strncasecmp(sep->arg[0], "active", 6) == 0)
  3387. {
  3388. zone_list.SendZoneList(client);
  3389. break;
  3390. }
  3391. else if(strncasecmp(sep->arg[0], "instance", 6) == 0)
  3392. {
  3393. if(sep->IsNumber(1))
  3394. instanceID = atol(sep->arg[1]);
  3395. }
  3396. else if(strncasecmp(sep->arg[0], "lock", 4) == 0)
  3397. {
  3398. PrintSep(sep, "ZONE LOCK");
  3399. if(sep->IsNumber(1))
  3400. zsZone = zone_list.Get(atoul(sep->arg[1]), false, false, false);
  3401. else
  3402. zsZone = zone_list.Get(sep->arg[1], false, false, false);
  3403. if( zsZone )
  3404. {
  3405. zsZone->SetZoneLockState(true);
  3406. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now locked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  3407. }
  3408. else
  3409. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be locked.", sep->arg[1]);
  3410. break;
  3411. }
  3412. else if(strncasecmp(sep->arg[0], "unlock", 6) == 0)
  3413. {
  3414. PrintSep(sep, "ZONE UNLOCK");
  3415. if(sep->IsNumber(1))
  3416. zsZone = zone_list.Get(atoul(sep->arg[1]), false, false, false);
  3417. else
  3418. zsZone = zone_list.Get(sep->arg[1], false, false, false);
  3419. if( zsZone )
  3420. {
  3421. zsZone->SetZoneLockState(false);
  3422. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now unlocked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  3423. }
  3424. else
  3425. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be unlocked.", sep->arg[1]);
  3426. break;
  3427. }
  3428. else
  3429. {
  3430. if(sep->IsNumber(0))
  3431. {
  3432. zone_id = atoul(sep->arg[0]);
  3433. string zonename = database.GetZoneName(zone_id);
  3434. if(zonename.length() > 0)
  3435. zone = zonename;
  3436. }
  3437. else
  3438. zone = sep->arg[0];
  3439. }
  3440. if(instanceID > 0)
  3441. {
  3442. ZoneServer* zsInstance = zone_list.GetByInstanceID(instanceID);
  3443. if(zsInstance != NULL)
  3444. {
  3445. instanceID = zsInstance->GetInstanceID();
  3446. zone = zsInstance->GetZoneName();
  3447. zone_id = zsInstance->GetZoneID();
  3448. isInstance = true;
  3449. }
  3450. }
  3451. }
  3452. if(!listSearch)
  3453. {
  3454. if(zone.length() == 0)
  3455. client->Message(CHANNEL_COLOR_RED, "Error: Invalid Zone");
  3456. else if(instanceID != client->GetCurrentZone()->GetInstanceID() ||
  3457. zone_id != client->GetCurrentZone()->GetZoneID())
  3458. {
  3459. const char* zonestr = zone.c_str();
  3460. if(database.VerifyZone(zonestr))
  3461. {
  3462. if(client->CheckZoneAccess(zonestr))
  3463. {
  3464. client->Message(CHANNEL_COLOR_YELLOW,"Zoning to %s...", zonestr);
  3465. if(isInstance)
  3466. client->Zone(instanceID,true,true,false);
  3467. else
  3468. client->Zone(zonestr);
  3469. }
  3470. }
  3471. else
  3472. client->Message(CHANNEL_COLOR_RED, "Error: Zone '%s' not found. To get a list type /zone list", zonestr);
  3473. }
  3474. else
  3475. client->Message(CHANNEL_COLOR_RED, "Error: You are already in that zone!");
  3476. }
  3477. else
  3478. {
  3479. const char* name = 0;
  3480. if(sep && sep->arg[1][0])
  3481. {
  3482. map<int32, string>* zone_names;
  3483. name = sep->argplus[1];
  3484. sint16 status = client->GetAdminStatus();
  3485. if( status > 0 )
  3486. {
  3487. client->SimpleMessage(CHANNEL_COLOR_RED, "ADMIN MODE");
  3488. zone_names = database.GetZoneList(name, true);
  3489. }
  3490. else
  3491. zone_names = database.GetZoneList(name);
  3492. if(!zone_names)
  3493. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No zones found.");
  3494. else
  3495. {
  3496. map<int32, string>::iterator itr;
  3497. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  3498. for(itr = zone_names->begin(); itr != zone_names->end(); itr++)
  3499. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  3500. safe_delete(zone_names);
  3501. }
  3502. }
  3503. else
  3504. {
  3505. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone [zone name]");
  3506. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone list [partial zone name]");
  3507. }
  3508. }
  3509. break;
  3510. }
  3511. case COMMAND_USE: {
  3512. Spawn* target = cmdTarget;
  3513. if (target && target->IsWidget())
  3514. ((Widget*)target)->HandleUse(client, "use");
  3515. break;
  3516. }
  3517. case COMMAND_OPEN: {
  3518. Spawn* target = cmdTarget;
  3519. if (target && target->IsWidget())
  3520. ((Widget*)target)->HandleUse(client, "Open", WIDGET_TYPE_DOOR);
  3521. break;
  3522. }
  3523. case COMMAND_CASTSPELL: {
  3524. if (sep && sep->arg[0] && sep->IsNumber(0))
  3525. {
  3526. int8 tier = 1;
  3527. if (sep->arg[1] && sep->IsNumber(1))
  3528. tier = atoul(sep->arg[1]);
  3529. int8 self = 1;
  3530. if (sep->arg[1] && sep->IsNumber(2))
  3531. {
  3532. self = atoul(sep->arg[2]);
  3533. if(self != 1 && !cmdTarget->IsEntity())
  3534. {
  3535. client->Message(CHANNEL_COLOR_RED, "Target is not an entity required to cast non-self spell.");
  3536. self = 1;
  3537. }
  3538. }
  3539. int32 spellid = atoul(sep->arg[0]);
  3540. Spell* spell = master_spell_list.GetSpell(spellid, tier);
  3541. if (spell)
  3542. {
  3543. client->Message(CHANNEL_COLOR_RED, "Casting spell %u.", spellid);
  3544. SpellProcess* spellProcess = 0;
  3545. // Get the current zones spell process
  3546. spellProcess = client->GetCurrentZone()->GetSpellProcess();
  3547. spellProcess->CastInstant(spell, (!cmdTarget || self == 1) ? (Entity*)client->GetPlayer() : (Entity*)cmdTarget, (cmdTarget && cmdTarget->IsEntity()) ? (Entity*)cmdTarget : (Entity*)client->GetPlayer());
  3548. }
  3549. else
  3550. {
  3551. client->Message(CHANNEL_COLOR_RED, "Could not find spell %u.",spellid);
  3552. }
  3553. }
  3554. else if (sep && sep->arg[0])
  3555. {
  3556. database.FindSpell(client, (char*)sep->argplus[0]);
  3557. }
  3558. else
  3559. {
  3560. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellid] (tier=1) - Cast Spell with specified spell id, tier is optional, default of 1.");
  3561. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellname] - Find spells wildcard match with a partial spell name");
  3562. }
  3563. break;
  3564. }
  3565. case COMMAND_KNOWLEDGEWINDOWSORT: {
  3566. if (sep && (client->GetVersion() <= 546 && sep->GetArgNumber() == 3) || sep->GetArgNumber() == 4)
  3567. {
  3568. int32 book = atoul(sep->arg[0]); // 0 - spells, 1 - combat, 2 - abilities, 3 - tradeskill
  3569. // cannot sort the ability book in this client it is greyed out
  3570. if (client->GetVersion() <= 546 && book == SPELL_BOOK_TYPE_ABILITY)
  3571. break;
  3572. int32 sort_by = atoul(sep->arg[1]); // 0 - alpha, 1 - level, 2 - category
  3573. int32 order = atoul(sep->arg[2]); // 0 - ascending, 1 - descending
  3574. int32 pattern = atoul(sep->arg[3]); // 0 - zigzag, 1 - down, 2 - across
  3575. int32 maxlvlonly = 0;
  3576. if(client->GetVersion() > 546 && sep->arg[4][0]) {
  3577. maxlvlonly = atoul(sep->arg[4]); // checkbox for newer clients
  3578. }
  3579. client->GetPlayer()->ResortSpellBook(sort_by, order, pattern, maxlvlonly, book);
  3580. ClientPacketFunctions::SendSkillSlotMappings(client);
  3581. }
  3582. else
  3583. {
  3584. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /knowledgewindow_sort [book] [sort_by] [order] [pattern]");
  3585. }
  3586. break;
  3587. }
  3588. case COMMAND_MOVE_ITEM:
  3589. {
  3590. int32 id = 0;
  3591. if (sep && sep->IsNumber(0))
  3592. id = atoul(sep->arg[0]);
  3593. Spawn* spawn = 0;
  3594. if (id == 0)
  3595. {
  3596. spawn = cmdTarget;
  3597. }
  3598. else
  3599. spawn = client->GetCurrentZone()->GetSpawnFromUniqueItemID(id);
  3600. if (!spawn || !client->HasOwnerOrEditAccess() || !spawn->GetPickupItemID())
  3601. break;
  3602. client->SendMoveObjectMode(spawn, 0);
  3603. break;
  3604. }
  3605. case COMMAND_PICKUP:
  3606. {
  3607. int32 id = 0;
  3608. if (sep && sep->IsNumber(0))
  3609. id = atoul(sep->arg[0]);
  3610. Spawn* spawn = 0;
  3611. if (id == 0)
  3612. {
  3613. spawn = cmdTarget;
  3614. }
  3615. else
  3616. spawn = client->GetCurrentZone()->GetSpawnFromUniqueItemID(id);
  3617. if (!spawn || !client->HasOwnerOrEditAccess() || !spawn->GetPickupItemID())
  3618. break;
  3619. if(client->AddItem(spawn->GetPickupItemID(), 1)) {
  3620. Query query;
  3621. 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());
  3622. if (database.RemoveSpawnFromSpawnLocation(spawn)) {
  3623. client->GetCurrentZone()->RemoveSpawn(spawn, true, true, true, true, true);
  3624. }
  3625. // we had a UI Window displayed, update the house items
  3626. if ( id > 0 )
  3627. client->GetCurrentZone()->SendHouseItems(client);
  3628. }
  3629. break;
  3630. }
  3631. case COMMAND_HOUSE_DEPOSIT:
  3632. {
  3633. PrintSep(sep, "COMMAND_HOUSE_DEPOSIT");
  3634. // arg0 = spawn_id for DoF, could also be house_id for newer clients
  3635. // arg1 = coin (in copper)
  3636. // arg2 = status? (not implemented yet)
  3637. PlayerHouse* ph = nullptr;
  3638. int32 spawn_id = 0;
  3639. if(sep && sep->arg[0]) {
  3640. spawn_id = atoul(sep->arg[0]);
  3641. ph = world.GetPlayerHouse(client, spawn_id, client->GetVersion() > 546 ? spawn_id : 0, nullptr);
  3642. }
  3643. if(!ph) {
  3644. ph = world.GetPlayerHouseByInstanceID(client->GetCurrentZone()->GetInstanceID());
  3645. }
  3646. if (ph && sep && sep->IsNumber(1))
  3647. {
  3648. int64 outValCoin = strtoull(sep->arg[1], NULL, 0);
  3649. int32 outValStatus = 0;
  3650. if(sep->IsNumber(2))
  3651. {
  3652. outValStatus = strtoull(sep->arg[2], NULL, 0);
  3653. if(outValStatus > client->GetPlayer()->GetInfoStruct()->get_status_points())
  3654. outValStatus = 0; // cheat check
  3655. }
  3656. if ((!outValCoin && outValStatus) || client->GetPlayer()->RemoveCoins(outValCoin))
  3657. {
  3658. if(outValStatus)
  3659. client->GetPlayer()->GetInfoStruct()->subtract_status_points(outValStatus);
  3660. char query[256];
  3661. map<string,Deposit>::iterator itr = ph->depositsMap.find(string(client->GetPlayer()->GetName()));
  3662. if (itr != ph->depositsMap.end())
  3663. {
  3664. 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());
  3665. }
  3666. else
  3667. 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);
  3668. if (database.RunQuery(query, strnlen(query, 256)))
  3669. {
  3670. ph->escrow_coins += outValCoin;
  3671. ph->escrow_status += outValStatus;
  3672. database.UpdateHouseEscrow(ph->house_id, ph->instance_id, ph->escrow_coins, ph->escrow_status);
  3673. database.LoadDeposits(ph);
  3674. client->PlaySound("coin_cha_ching");
  3675. HouseZone* hz = world.GetHouseZone(ph->house_id);
  3676. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetVersion() <= 546 ? spawn_id : client->GetPlayer()->GetID());
  3677. }
  3678. else
  3679. {
  3680. if(outValCoin)
  3681. client->GetPlayer()->AddCoins(outValCoin);
  3682. if(outValStatus)
  3683. client->GetPlayer()->GetInfoStruct()->add_status_points(outValStatus);
  3684. client->SimpleMessage(CHANNEL_COLOR_RED, "Deposit failed!");
  3685. }
  3686. }
  3687. }
  3688. break;
  3689. }
  3690. case COMMAND_HOUSE:
  3691. {
  3692. int32 spawn_id = 0;
  3693. if (sep && sep->IsNumber(0))
  3694. {
  3695. PlayerHouse* ph = nullptr;
  3696. if(!ph && sep && sep->arg[0]) {
  3697. spawn_id = atoul(sep->arg[0]);
  3698. ph = world.GetPlayerHouse(client, spawn_id, spawn_id, nullptr);
  3699. }
  3700. HouseZone* hz = 0;
  3701. if (ph)
  3702. hz = world.GetHouseZone(ph->house_id);
  3703. // there is a arg[1] that is true/false, but not sure what it is for investigate more later
  3704. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetVersion() <= 546 ? spawn_id : client->GetPlayer()->GetID());
  3705. }
  3706. else if (client->GetCurrentZone()->GetInstanceType() != 0)
  3707. {
  3708. // inside a house or something? Send the access window
  3709. PlayerHouse* ph = world.GetPlayerHouseByInstanceID(client->GetCurrentZone()->GetInstanceID());
  3710. HouseZone* hz = 0;
  3711. if ( ph )
  3712. hz = world.GetHouseZone(ph->house_id);
  3713. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetVersion() <= 546 ? spawn_id : client->GetPlayer()->GetID());
  3714. client->GetCurrentZone()->SendHouseItems(client);
  3715. }
  3716. break;
  3717. }
  3718. case COMMAND_HOUSE_UI:
  3719. {
  3720. if (sep && sep->IsNumber(0) && client->GetCurrentZone()->GetInstanceType() == Instance_Type::NONE)
  3721. {
  3722. int32 unique_id = atoi(sep->arg[0]);
  3723. PlayerHouse* ph = world.GetPlayerHouseByUniqueID(unique_id);
  3724. HouseZone* hz = 0;
  3725. if ( ph )
  3726. hz = world.GetHouseZone(ph->house_id);
  3727. // there is a arg[1] that is true/false, but not sure what it is for investigate more later
  3728. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  3729. }
  3730. break;
  3731. }
  3732. case COMMAND_PLACE_HOUSE_ITEM: {
  3733. if (sep && sep->IsNumber(0))
  3734. {
  3735. int32 uniqueid = atoi(sep->arg[0]);
  3736. Item* item = client->GetPlayer()->item_list.GetItemFromUniqueID(uniqueid);
  3737. //Item* item = player->GetEquipmentList()->GetItem(slot);
  3738. if (item && item->IsHouseItem())
  3739. {
  3740. if (!client->HasOwnerOrEditAccess())
  3741. {
  3742. client->SimpleMessage(CHANNEL_COLOR_RED, "This is not your home!");
  3743. break;
  3744. }
  3745. else if (!item->generic_info.appearance_id)
  3746. {
  3747. 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);
  3748. break;
  3749. }
  3750. else if(item->CheckFlag2(HOUSE_LORE) && client->GetCurrentZone()->HouseItemSpawnExists(item->details.item_id)) {
  3751. client->Message(CHANNEL_COLOR_RED, "Item %s is house lore and you cannot place another.", item->name.c_str());
  3752. break;
  3753. }
  3754. if (client->GetTempPlacementSpawn())
  3755. {
  3756. Spawn* tmp = client->GetTempPlacementSpawn();
  3757. client->GetCurrentZone()->RemoveSpawn(tmp, true, true, true, true, true);
  3758. client->SetTempPlacementSpawn(nullptr);
  3759. }
  3760. Object* obj = new Object();
  3761. Spawn* spawn = (Spawn*)obj;
  3762. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3763. strcpy(spawn->appearance.name, "temp");
  3764. spawn->SetX(client->GetPlayer()->GetX());
  3765. spawn->SetY(client->GetPlayer()->GetY());
  3766. spawn->SetZ(client->GetPlayer()->GetZ());
  3767. spawn->appearance.pos.collision_radius = 32;
  3768. spawn->SetHeading(client->GetPlayer()->GetHeading());
  3769. spawn->SetSpawnOrigX(spawn->GetX());
  3770. spawn->SetSpawnOrigY(spawn->GetY());
  3771. spawn->SetSpawnOrigZ(spawn->GetZ());
  3772. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  3773. spawn->appearance.targetable = 1;
  3774. spawn->appearance.activity_status = ACTIVITY_STATUS_SOLID;
  3775. spawn->appearance.race = item && item->generic_info.appearance_id ? item->generic_info.appearance_id : 1472;
  3776. spawn->SetModelType(item && item->generic_info.appearance_id ? item->generic_info.appearance_id : 1472);
  3777. spawn->SetLocation(client->GetPlayer()->GetLocation());
  3778. spawn->SetZone(client->GetCurrentZone());
  3779. client->SetTempPlacementSpawn(spawn);
  3780. client->SetPlacementUniqueItemID(uniqueid);
  3781. client->GetCurrentZone()->AddSpawn(spawn);
  3782. }
  3783. }
  3784. break;
  3785. }
  3786. case COMMAND_GM:
  3787. {
  3788. if (sep && sep->arg[0] && sep->arg[1])
  3789. {
  3790. bool onOff = (strcmp(sep->arg[1], "on") == 0);
  3791. if (strcmp(sep->arg[0], "vision") == 0)
  3792. {
  3793. client->GetPlayer()->SetGMVision(onOff);
  3794. #if defined(__GNUC__)
  3795. database.insertCharacterProperty(client, CHAR_PROPERTY_GMVISION, (onOff) ? (char*)"1" : (char*)"0");
  3796. #else
  3797. database.insertCharacterProperty(client, CHAR_PROPERTY_GMVISION, (onOff) ? "1" : "0");
  3798. #endif
  3799. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3800. if (onOff)
  3801. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Vision Enabled!");
  3802. else
  3803. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Vision Disabled!");
  3804. }
  3805. else if (strcmp(sep->arg[0], "tag") == 0)
  3806. {
  3807. int32 value = 0;
  3808. int16 tag_icon = 0;
  3809. // groundspawn has special exception -1 argument so it needs to be handled here
  3810. if(sep->arg[2] && sep->arg[3] && ((tag_icon = atoul(sep->arg[3])) > 0) || (strncasecmp(sep->arg[1], "groundspawn", 11) == 0)) {
  3811. value = atoul(sep->arg[2]);
  3812. if(strncasecmp(sep->arg[1], "faction", 7) == 0){
  3813. if(!value) {
  3814. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid faction id.");
  3815. break;
  3816. }
  3817. if(!tag_icon) {
  3818. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid tag icon id.");
  3819. break;
  3820. }
  3821. client->GetPlayer()->AddGMVisualFilter(GMTagFilterType::GMFILTERTYPE_FACTION, value, "", tag_icon);
  3822. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3823. client->Message(CHANNEL_COLOR_RED, "Adding faction id %u with tag icon %u.", value, tag_icon);
  3824. }
  3825. else if(strncasecmp(sep->arg[1], "spawngroup", 10) == 0){
  3826. if(value>0) {
  3827. value = 1;
  3828. }
  3829. if(!tag_icon) {
  3830. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid tag icon id.");
  3831. break;
  3832. }
  3833. client->GetPlayer()->AddGMVisualFilter(GMTagFilterType::GMFILTERTYPE_SPAWNGROUP, value, "", tag_icon);
  3834. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3835. client->Message(CHANNEL_COLOR_RED, "Adding spawn group tag \"%s\" with tag icon %u.", (value == 1) ? "on" : "off", tag_icon);
  3836. }
  3837. else if(strncasecmp(sep->arg[1], "race", 4 == 0)){
  3838. if(!value) {
  3839. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid race id.");
  3840. break;
  3841. }
  3842. if(!tag_icon) {
  3843. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid tag icon id.");
  3844. break;
  3845. }
  3846. client->GetPlayer()->AddGMVisualFilter(GMTagFilterType::GMFILTERTYPE_RACE, value, "", tag_icon);
  3847. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3848. client->Message(CHANNEL_COLOR_RED, "Adding race id %u with tag icon %u.", value, tag_icon);
  3849. }
  3850. else if(strncasecmp(sep->arg[1], "groundspawn", 11) == 0){
  3851. // one less argument value field not tag_icon for this one
  3852. if(!value) {
  3853. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid tag icon id.");
  3854. break;
  3855. }
  3856. client->GetPlayer()->AddGMVisualFilter(GMTagFilterType::GMFILTERTYPE_GROUNDSPAWN, 1, "", value);
  3857. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3858. client->Message(CHANNEL_COLOR_RED, "Adding groundspawns with tag icon %u.", value);
  3859. }
  3860. }
  3861. else {
  3862. if(strncasecmp(sep->arg[1], "clear", 5) == 0){
  3863. client->GetPlayer()->ClearGMVisualFilters();
  3864. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Tags Cleared!");
  3865. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3866. }
  3867. else {
  3868. client->SimpleMessage(CHANNEL_COLOR_RED, "GM Tagging Missing Arguments:");
  3869. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/gm tag [type] [value] [visual_icon_display]");
  3870. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/gm tag clear - Clears all GM visual tags");
  3871. client->SimpleMessage(CHANNEL_COLOR_RED, "Visual Type Options:");
  3872. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "type: faction, value: faction id of spawn(s)");
  3873. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "type: spawngroup, value: 1 to show grouped, 0 to show not grouped");
  3874. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "type: race, value: race id (either against base race or race id in spawn details)");
  3875. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "type: groundspawn, value: (not used)");
  3876. client->SimpleMessage(CHANNEL_COLOR_RED, "Visual Icon Options:");
  3877. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3878. "1 = skull, 2 = shield half dark blue / half light blue, 3 = purple? star, 4 = yellow sword, 5 = red X, 6 = green flame");
  3879. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3880. "7 = Number \"1\", 8 = Number \"2\", 9 = Number \"3\", 10 = Number \"4\", 11 = Number \"5\", 12 = Number \"6\"");
  3881. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3882. "25 = shield, 26 = green plus, 27 = crossed swords, 28 = bow with arrow in it, 29 = light blue lightning bolt");
  3883. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3884. "30 = bard instrument (hard to see), 31 = writ with shield, 32 = writ with green +, 33 = writ with crossed sword");
  3885. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3886. "34 = writ with bow, 35 = writ with light blue lightning bolt, 36 = same as 30, 37 = party with crossed sword, shield and lightning bolt");
  3887. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3888. "38 = shaking hands green background, 39 = shaking hands dark green background, unlocked keylock");
  3889. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3890. "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");
  3891. }
  3892. }
  3893. }
  3894. else if (strcmp(sep->arg[0], "regiondebug") == 0)
  3895. {
  3896. client->SetRegionDebug(onOff);
  3897. #if defined(__GNUC__)
  3898. database.insertCharacterProperty(client, CHAR_PROPERTY_REGIONDEBUG, (onOff) ? (char*)"1" : (char*)"0");
  3899. #else
  3900. database.insertCharacterProperty(client, CHAR_PROPERTY_REGIONDEBUG, (onOff) ? "1" : "0");
  3901. #endif
  3902. if (onOff)
  3903. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Region Debug Enabled!");
  3904. else
  3905. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Region Debug Disabled!");
  3906. }
  3907. else if (strcmp(sep->arg[0], "sight") == 0)
  3908. {
  3909. if(onOff && cmdTarget) {
  3910. client->SetPlayerPOVGhost(cmdTarget);
  3911. }
  3912. else
  3913. client->SetPlayerPOVGhost(nullptr);
  3914. }
  3915. else if (strcmp(sep->arg[0], "controleffects") == 0)
  3916. {
  3917. if(cmdTarget && cmdTarget->IsEntity()) {
  3918. ((Entity*)cmdTarget)->SendControlEffectDetailsToClient(client);
  3919. }
  3920. else {
  3921. client->GetPlayer()->SendControlEffectDetailsToClient(client);
  3922. }
  3923. }
  3924. else if (strcmp(sep->arg[0], "luadebug") == 0)
  3925. {
  3926. client->SetLuaDebugClient(onOff);
  3927. #if defined(__GNUC__)
  3928. database.insertCharacterProperty(client, CHAR_PROPERTY_LUADEBUG, (onOff) ? (char*)"1" : (char*)"0");
  3929. #else
  3930. database.insertCharacterProperty(client, CHAR_PROPERTY_LUADEBUG, (onOff) ? "1" : "0");
  3931. #endif
  3932. if (onOff)
  3933. {
  3934. if (lua_interface)
  3935. lua_interface->UpdateDebugClients(client);
  3936. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will now receive LUA error messages.");
  3937. }
  3938. else
  3939. {
  3940. if (lua_interface)
  3941. lua_interface->RemoveDebugClients(client);
  3942. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will no longer receive LUA error messages.");
  3943. }
  3944. }
  3945. }
  3946. break;
  3947. }
  3948. case COMMAND_ATTACK:
  3949. case COMMAND_AUTO_ATTACK:{
  3950. int8 type = 1;
  3951. bool update = false;
  3952. Player* player = client->GetPlayer();
  3953. if(!player)
  3954. break;
  3955. bool incombat = player->EngagedInCombat();
  3956. if(sep && sep->arg[0] && sep->IsNumber(0))
  3957. type = atoi(sep->arg[0]);
  3958. if(!client->GetPlayer()->Alive()){
  3959. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  3960. break;
  3961. }
  3962. if(type == 0){
  3963. if(incombat)
  3964. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You stop fighting.");
  3965. player->StopCombat(type);
  3966. update = true;
  3967. }
  3968. else {
  3969. if(type == 2){
  3970. player->InCombat(false);
  3971. if(incombat && player->GetRangeAttack()){
  3972. player->StopCombat(type);
  3973. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You stop fighting.");
  3974. update = true;
  3975. }
  3976. else{
  3977. player->SetRangeAttack(true);
  3978. player->InCombat(true, true);
  3979. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You start fighting.");
  3980. update = true;
  3981. }
  3982. }
  3983. else {
  3984. player->InCombat(false, true);
  3985. player->SetRangeAttack(false);
  3986. player->InCombat(true);
  3987. if(!incombat) {
  3988. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You start fighting.");
  3989. update = true;
  3990. }
  3991. }
  3992. /*else
  3993. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You cannot attack that!");*/
  3994. }
  3995. if(update) {
  3996. player->SetCharSheetChanged(true);
  3997. }
  3998. break;
  3999. }
  4000. case COMMAND_DEPOP:{
  4001. bool allow_respawns = false;
  4002. if(sep && sep->arg[0] && sep->IsNumber(0)){
  4003. if(atoi(sep->arg[0]) == 1)
  4004. allow_respawns = true;
  4005. }
  4006. client->GetCurrentZone()->Depop(allow_respawns);
  4007. break;
  4008. }
  4009. case COMMAND_REPOP:{
  4010. client->GetCurrentZone()->Depop(false, true);
  4011. break;
  4012. }
  4013. case COMMAND_BUYBACK:{
  4014. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  4015. // 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
  4016. int64 id = atoi64(sep->arg[0]);
  4017. // get the first int32, the item id
  4018. //int32 item_id = (int32)id;
  4019. // get the second int32, the unique id
  4020. int32 unique_id = (int32)(id>>32);
  4021. int8 quantity = atoi(sep->arg[1]);
  4022. if(quantity == 255)
  4023. quantity = 1;
  4024. client->BuyBack(unique_id, quantity);
  4025. }
  4026. break;
  4027. }
  4028. case COMMAND_MERCHANT_BUY:{
  4029. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  4030. int32 item_id = atoul(sep->arg[0]);
  4031. int8 quantity = atoi(sep->arg[1]);
  4032. client->BuyItem(item_id, quantity);
  4033. }
  4034. else
  4035. Command_SendMerchantWindow(client, sep);
  4036. break;
  4037. }
  4038. case COMMAND_MERCHANT_SELL:{
  4039. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  4040. // 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
  4041. int64 id = atoi64(sep->arg[0]);
  4042. // get the first int32, the item id
  4043. int32 item_id = (int32)id;
  4044. // get the second int32, the unique id
  4045. int32 unique_id = (int32)(id>>32);
  4046. int8 quantity = atoi(sep->arg[1]);
  4047. LogWrite(MERCHANT__DEBUG, 0, "Merchant", "Selling Item: Item Id = %ul, unique id = %ul, Quantity = %i", item_id, unique_id, quantity);
  4048. client->SellItem(item_id, quantity, unique_id);
  4049. }
  4050. break;
  4051. }
  4052. case COMMAND_MENDER_REPAIR: {
  4053. if (sep && sep->arg[0] && sep->IsNumber(0))
  4054. client->RepairItem(atoul(sep->arg[0]));
  4055. break;
  4056. }
  4057. case COMMAND_MENDER_REPAIR_ALL: {
  4058. client->RepairAllItems();
  4059. break;
  4060. }
  4061. case COMMAND_CANCEL_MERCHANT:{
  4062. client->SetMerchantTransaction(0);
  4063. break;
  4064. }
  4065. case COMMAND_START_MERCHANT:{
  4066. break;
  4067. }
  4068. case COMMAND_INVULNERABLE:{
  4069. sint8 val = -1;
  4070. if(sep && sep->arg[0] && sep->IsNumber(0)){
  4071. val = atoi(sep->arg[0]);
  4072. //devn00b: Fix for linux builds
  4073. #if defined(__GNUC__)
  4074. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? (char*) "1" : (char*) "0");
  4075. #else
  4076. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  4077. #endif
  4078. // database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  4079. client->GetPlayer()->SetInvulnerable(val==1);
  4080. if(client->GetPlayer()->GetInvulnerable())
  4081. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are now invulnerable!");
  4082. else
  4083. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are no longer invulnerable!");
  4084. }
  4085. if(val == -1)
  4086. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /invulnerable [0/1]");
  4087. break;
  4088. }
  4089. case COMMAND_REPAIR: {
  4090. Spawn* spawn = cmdTarget;
  4091. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR) {
  4092. client->SendHailCommand(spawn);
  4093. client->SetMerchantTransaction(spawn);
  4094. client->SendRepairList();
  4095. }
  4096. break;
  4097. }
  4098. case COMMAND_LOTTO: {
  4099. Spawn* spawn = cmdTarget;
  4100. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_LOTTO) {
  4101. client->SetMerchantTransaction(spawn);
  4102. client->ShowLottoWindow();
  4103. }
  4104. break;
  4105. }
  4106. case COMMAND_ACCEPT_REWARD:{
  4107. int32 unknown = 0;
  4108. int32 selectable_item_id = 0;
  4109. //Quest *quest = 0;
  4110. /* no idea what the first argument is for (faction maybe?)
  4111. if the reward has a selectable item reward, it's sent as the second argument
  4112. if neither of these are included in the reward, there is no sep
  4113. 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
  4114. only 1 quest or collection reward may be displayed at a time */
  4115. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  4116. unknown = atoul(sep->arg[0]);
  4117. selectable_item_id = atoul(sep->arg[1]);
  4118. }
  4119. /* 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
  4120. ** Otherwise it will likely be a DoF client scenario (pending item rewards, selectable item rewards) which is specifying an item id
  4121. ** 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
  4122. */
  4123. int32 item_id = 0;
  4124. if(sep && sep->arg[0][0] && sep->IsNumber(0))
  4125. item_id = atoul(sep->arg[0]);
  4126. bool collectedItems = client->GetPlayer()->AcceptQuestReward(item_id, selectable_item_id);
  4127. if (collectedItems) {
  4128. EQ2Packet* outapp = client->GetPlayer()->SendInventoryUpdate(client->GetVersion());
  4129. if (outapp)
  4130. client->QueuePacket(outapp);
  4131. }
  4132. else
  4133. LogWrite(COMMAND__ERROR, 0, "Command", "Error in COMMAND_ACCEPT_REWARD. No pending quest or collection reward was found (unknown=%u).", unknown);
  4134. break;
  4135. }
  4136. case COMMAND_BUY_FROM_BROKER:{
  4137. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  4138. int32 item_id = atoul(sep->arg[0]);
  4139. int16 quantity = atoul(sep->arg[1]);
  4140. Item* item = master_item_list.GetItem(item_id);
  4141. if(item && item->generic_info.max_charges > 1)
  4142. quantity = item->generic_info.max_charges;
  4143. client->AddItem(item_id, quantity, AddItemType::BUY_FROM_BROKER);
  4144. }
  4145. break;
  4146. }
  4147. case COMMAND_SEARCH_STORES_PAGE:{
  4148. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  4149. int32 page = atoul(sep->arg[0]);
  4150. client->SearchStore(page);
  4151. }
  4152. break;
  4153. }
  4154. case COMMAND_SEARCH_STORES:{
  4155. if(sep && sep->arg[0][0]){
  4156. const char* values = sep->argplus[0];
  4157. if(values){
  4158. LogWrite(ITEM__WARNING, 0, "Item", "SearchStores: %s", values);
  4159. map<string, string> str_values = TranslateBrokerRequest(values);
  4160. vector<Item*>* items = master_item_list.GetItems(str_values, client);
  4161. if(items){
  4162. client->SetItemSearch(items);
  4163. client->SearchStore(0);
  4164. }
  4165. }
  4166. }
  4167. break;
  4168. }
  4169. case COMMAND_LUADEBUG:{
  4170. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "start") == 0){
  4171. client->SetLuaDebugClient(true);
  4172. if(lua_interface)
  4173. lua_interface->UpdateDebugClients(client);
  4174. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will now receive LUA error messages.");
  4175. }
  4176. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "stop") == 0){
  4177. client->SetLuaDebugClient(false);
  4178. if(lua_interface)
  4179. lua_interface->RemoveDebugClients(client);
  4180. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will no longer receive LUA error messages.");
  4181. }
  4182. else{
  4183. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /luadebug {start | stop}");
  4184. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will allow you to receive lua debug messages normally seen only in the console.");
  4185. }
  4186. break;
  4187. }
  4188. case COMMAND_SPAWN_GROUP:
  4189. {
  4190. Spawn* target = cmdTarget;
  4191. if(target && target->IsPlayer() == false)
  4192. {
  4193. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "create") == 0)
  4194. {
  4195. if(target->GetSpawnLocationPlacementID() > 0)
  4196. {
  4197. if(sep->arg[1] && !sep->IsNumber(1) && strlen(sep->arg[1]) > 0)
  4198. {
  4199. int32 id = database.CreateSpawnGroup(target, sep->arg[1]);
  4200. if(id > 0)
  4201. client->Message(CHANNEL_COLOR_YELLOW, "Successfully created new spawn group with id: %u", id);
  4202. else
  4203. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error creating group, check console for details.");
  4204. target->SetSpawnGroupID(id);
  4205. target->AddSpawnToGroup(target);
  4206. }
  4207. else
  4208. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group create [name]");
  4209. }
  4210. else
  4211. 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.");
  4212. }
  4213. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "add") == 0)
  4214. {
  4215. if(sep->arg[1] && sep->IsNumber(1))
  4216. {
  4217. int32 group_id = atoul(sep->arg[1]);
  4218. Spawn* leader = client->GetCurrentZone()->GetSpawnGroup(group_id);
  4219. if(leader)
  4220. {
  4221. leader->AddSpawnToGroup(target);
  4222. target->SetSpawnGroupID(group_id);
  4223. if(database.SpawnGroupAddSpawn(target, group_id))
  4224. client->Message(CHANNEL_COLOR_YELLOW, "Successfully added '%s' to group id: %u", target->GetName(), group_id);
  4225. else
  4226. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error adding spawn to group, check console for details.");
  4227. }
  4228. else
  4229. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No spawns found in the current zone for that spawn group, be sure to use '/spawn group create' first!");
  4230. }
  4231. else
  4232. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group add [group id]");
  4233. }
  4234. else if(target->GetSpawnGroupID() == 0)
  4235. {
  4236. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That spawn is not in a group!");
  4237. }
  4238. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "remove") == 0)
  4239. {
  4240. int32 group_id = target->GetSpawnGroupID();
  4241. target->RemoveSpawnFromGroup();
  4242. if(database.SpawnGroupRemoveSpawn(target, group_id))
  4243. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed '%s' from group id: %u", target->GetName(), group_id);
  4244. else
  4245. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing spawn from group, check console for details.");
  4246. }
  4247. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "associate") == 0)
  4248. {
  4249. int32 group_id = target->GetSpawnGroupID();
  4250. if(sep->arg[1] && sep->IsNumber(1))
  4251. {
  4252. if(database.SpawnGroupAddAssociation(group_id, atoul(sep->arg[1])))
  4253. client->Message(CHANNEL_COLOR_YELLOW, "Successfully associated group id %u with group id %u", group_id, atoul(sep->arg[1]));
  4254. else
  4255. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error associating groups, check console for details.");
  4256. }
  4257. else
  4258. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Allows you to spawn only one associated group at once. Syntax: /spawn group associate [other group id]");
  4259. }
  4260. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "deassociate") == 0)
  4261. {
  4262. int32 group_id = target->GetSpawnGroupID();
  4263. if(sep->arg[1] && sep->IsNumber(1))
  4264. {
  4265. if(database.SpawnGroupRemoveAssociation(group_id, atoul(sep->arg[1])))
  4266. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed association between group id %u and group id %u", group_id, atoul(sep->arg[1]));
  4267. else
  4268. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing group associations, check console for details.");
  4269. }
  4270. else
  4271. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Removes previous group associations. Syntax: /spawn group deassociate [other group id]");
  4272. }
  4273. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "chance") == 0)
  4274. {
  4275. if(sep->arg[1] && sep->IsNumber(1))
  4276. {
  4277. if(database.SetGroupSpawnChance(target->GetSpawnGroupID(), atof(sep->arg[1])))
  4278. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set group spawn chance to %f for group id: %u", atof(sep->arg[1]), target->GetSpawnGroupID());
  4279. else
  4280. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error setting group spawn chance, check console for details.");
  4281. }
  4282. else
  4283. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group chance [group's spawn chance percentage]");
  4284. }
  4285. else
  4286. {
  4287. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command allows you to modify spawn groups.");
  4288. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group [create/add/remove/chance/associate/deassociate]");
  4289. }
  4290. }
  4291. else
  4292. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select a valid spawn to use this command.");
  4293. break;
  4294. }
  4295. case COMMAND_SPAWN_COMBINE:{
  4296. Spawn* spawn = cmdTarget;
  4297. float radius = 0;
  4298. bool failed = true;
  4299. if(spawn && !spawn->IsPlayer() && sep && sep->arg[0] && sep->arg[0][0]){
  4300. failed = false;
  4301. if(spawn->GetSpawnGroupID() > 0){
  4302. 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.");
  4303. }
  4304. else if(sep->IsNumber(0)){
  4305. radius = atof(sep->arg[0]);
  4306. client->CombineSpawns(radius, spawn);
  4307. }
  4308. else{
  4309. if(strncasecmp(sep->arg[0], "add", 3) == 0){
  4310. client->AddCombineSpawn(spawn);
  4311. }
  4312. else if(strncasecmp(sep->arg[0], "remove", 6) == 0){
  4313. client->RemoveCombineSpawn(spawn);
  4314. }
  4315. else if(strncasecmp(sep->arg[0], "save", 4) == 0){
  4316. const char* name = 0;
  4317. if(sep->arg[1] && sep->arg[1][0])
  4318. name = sep->argplus[1];
  4319. client->SaveCombineSpawns(name);
  4320. }
  4321. else
  4322. failed = true;
  4323. }
  4324. }
  4325. if(failed){
  4326. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command combines several spawns into a single spawn group.");
  4327. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn combine [radius/add/remove/save]");
  4328. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Ex: /spawn combine 1, /spawn combine save (spawn group name)");
  4329. }
  4330. break;
  4331. }
  4332. case COMMAND_SPAWN_CREATE:{
  4333. Spawn* spawn = 0;
  4334. if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "object", 6) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  4335. spawn = new Object();
  4336. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  4337. }
  4338. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "groundspawn", 11) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  4339. spawn = new GroundSpawn();
  4340. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  4341. }
  4342. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "sign", 4) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  4343. spawn = new Sign();
  4344. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  4345. }
  4346. else if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "npc", 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  4347. spawn = new NPC();
  4348. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  4349. spawn->appearance.pos.collision_radius = 32;
  4350. spawn->secondary_command_list_id = 0;
  4351. spawn->primary_command_list_id = 0;
  4352. spawn->appearance.display_name = 1;
  4353. spawn->appearance.show_level = 1;
  4354. spawn->appearance.attackable = 1;
  4355. }
  4356. else{
  4357. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn create [spawn type] [race type] [class type] [level] [name] (difficulty) (size)");
  4358. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are required except difficulty and size. Valid types are Object, NPC, Sign, or GroundSpawn");
  4359. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn create npc 203 1 50 'Lady Vox' 1 32");
  4360. break;
  4361. }
  4362. spawn->SetID(Spawn::NextID());
  4363. spawn->SetX(client->GetPlayer()->GetX());
  4364. spawn->SetY(client->GetPlayer()->GetY());
  4365. spawn->SetZ(client->GetPlayer()->GetZ());
  4366. spawn->SetHeading(client->GetPlayer()->GetHeading());
  4367. spawn->SetSpawnOrigX(spawn->GetX());
  4368. spawn->SetSpawnOrigY(spawn->GetY());
  4369. spawn->SetSpawnOrigZ(spawn->GetZ());
  4370. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  4371. if(spawn->IsSign())
  4372. {
  4373. ((Sign*)spawn)->SetSignType(SIGN_TYPE_GENERIC);
  4374. ((Sign*)spawn)->SetSignDistance(20.0f);
  4375. ((Sign*)spawn)->SetIncludeLocation(1);
  4376. ((Sign*)spawn)->SetIncludeHeading(1);
  4377. ((Sign*)spawn)->SetInitialState(1);
  4378. ((Sign*)spawn)->SetSignTitle(sep->arg[4]);
  4379. ((Sign*)spawn)->SetActivityStatus(64);
  4380. spawn->appearance.race = 0;
  4381. spawn->SetLevel(0);
  4382. spawn->SetHP(0);
  4383. spawn->SetTotalHP(0);
  4384. spawn->SetPower(0);
  4385. spawn->SetTotalPower(0);
  4386. spawn->SetDifficulty(0);
  4387. spawn->SetTargetable(0);
  4388. spawn->SetSogaModelType(0);
  4389. spawn->SetCollisionRadius(19);
  4390. ((Sign*)spawn)->SetWidgetX(client->GetPlayer()->GetX());
  4391. ((Sign*)spawn)->SetWidgetY(client->GetPlayer()->GetY());
  4392. ((Sign*)spawn)->SetWidgetZ(client->GetPlayer()->GetZ());
  4393. spawn->SetLocation(client->GetPlayer()->GetLocation());
  4394. spawn->appearance.model_type = atoul(sep->arg[1]);
  4395. }
  4396. else
  4397. {
  4398. spawn->appearance.targetable = 1;
  4399. spawn->appearance.race = 255;
  4400. spawn->SetLocation(client->GetPlayer()->GetLocation());
  4401. spawn->SetModelType(atoi(sep->arg[1]));
  4402. spawn->SetAdventureClass(atoi(sep->arg[2]));
  4403. spawn->SetLevel(atoi(sep->arg[3]));
  4404. spawn->SetName(sep->arg[4]);
  4405. if(sep->arg[5][0] && sep->IsNumber(5))
  4406. spawn->SetDifficulty(atoi(sep->arg[5]));
  4407. if(sep->arg[6][0] && sep->IsNumber(6))
  4408. spawn->size = atoi(sep->arg[6]);
  4409. if(spawn->GetTotalHP() == 0){
  4410. spawn->SetTotalHP(25*spawn->GetLevel() + 1);
  4411. spawn->SetHP(25*spawn->GetLevel() + 1);
  4412. }
  4413. if(spawn->GetTotalPower() == 0){
  4414. spawn->SetTotalPower(25*spawn->GetLevel() + 1);
  4415. spawn->SetPower(25*spawn->GetLevel() + 1);
  4416. }
  4417. }
  4418. client->GetCurrentZone()->AddSpawn(spawn);
  4419. break;
  4420. }
  4421. case COMMAND_SPAWN_EQUIPMENT:{
  4422. Spawn* spawn = cmdTarget;
  4423. if(spawn && sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1) && spawn->IsEntity()){
  4424. int8 slot = atoi(sep->arg[0]);
  4425. int16 type = atoi(sep->arg[1]);
  4426. int8 red = 0;
  4427. int8 green = 0;
  4428. int8 blue = 0;
  4429. int8 h_red = 0;
  4430. int8 h_green = 0;
  4431. int8 h_blue = 0;
  4432. if(sep->arg[2])
  4433. red = atoi(sep->arg[2]);
  4434. if(sep->arg[3])
  4435. green = atoi(sep->arg[3]);
  4436. if(sep->arg[4])
  4437. blue = atoi(sep->arg[4]);
  4438. if(sep->arg[5])
  4439. h_red = atoi(sep->arg[5]);
  4440. if(sep->arg[6])
  4441. h_green = atoi(sep->arg[6]);
  4442. if(sep->arg[7])
  4443. h_blue = atoi(sep->arg[7]);
  4444. ((Entity*)spawn)->SetEquipment(slot, type, red, green, blue, h_red, h_green, h_blue);
  4445. database.SaveNPCAppearanceEquipment(spawn->GetDatabaseID() , slot, type, red, green, blue, h_red, h_green, h_blue);
  4446. }
  4447. else{
  4448. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn equipment [slot] [appearance id] (red) (green) (blue) (highlight red) (hgreen) (hblue)");
  4449. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn's equipment. ");
  4450. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Slot is 0-24, Appearance ID from appearances table, Colors are 0-255");
  4451. }
  4452. break;
  4453. }
  4454. case COMMAND_SPAWN_DETAILS: {
  4455. Spawn* spawn = cmdTarget;
  4456. if (sep && sep->arg[0][0]) {
  4457. if (cmdTarget)
  4458. {
  4459. if (ToLower(string(sep->arg[0])) == "los")
  4460. {
  4461. bool hasLOS = client->GetPlayer()->CheckLoS(cmdTarget);
  4462. if (hasLOS)
  4463. client->Message(CHANNEL_COLOR_YELLOW, "You have line of sight with %s", spawn->GetName());
  4464. else
  4465. client->Message(CHANNEL_COLOR_RED, "You DO NOT have line of sight with %s", spawn->GetName());
  4466. break;
  4467. }
  4468. else if (ToLower(string(sep->arg[0])) == "bestz")
  4469. {
  4470. glm::vec3 targPos(cmdTarget->GetX(), cmdTarget->GetZ(), cmdTarget->GetY());
  4471. float bestZ = client->GetPlayer()->FindDestGroundZ(targPos, cmdTarget->GetYOffset());
  4472. client->Message(CHANNEL_COLOR_YELLOW, "Best Z for %s is %f", spawn->GetName(), bestZ);
  4473. break;
  4474. }
  4475. else if (ToLower(string(sep->arg[0])) == "inwater")
  4476. {
  4477. if (cmdTarget->GetRegionMap() == nullptr)
  4478. client->SimpleMessage(CHANNEL_COLOR_RED, "No water map for zone.");
  4479. else
  4480. {
  4481. bool inWater = cmdTarget->InWater();
  4482. client->Message(CHANNEL_COLOR_YELLOW, "%s is %s.", cmdTarget->GetName(), inWater ? "in water" : "out of water");
  4483. }
  4484. break;
  4485. }
  4486. else if (ToLower(string(sep->arg[0])) == "inlava")
  4487. {
  4488. if (cmdTarget->GetRegionMap() == nullptr)
  4489. client->SimpleMessage(CHANNEL_COLOR_RED, "No region map for zone.");
  4490. else
  4491. {
  4492. bool inLava = cmdTarget->InLava();
  4493. client->Message(CHANNEL_COLOR_YELLOW, "%s is %s.", cmdTarget->GetName(), inLava ? "in lava" : "out of lava");
  4494. }
  4495. break;
  4496. }
  4497. else if (ToLower(string(sep->arg[0])) == "regions")
  4498. {
  4499. glm::vec3 targPos(cmdTarget->GetX(), cmdTarget->GetY(), cmdTarget->GetZ());
  4500. if (cmdTarget->GetRegionMap() == nullptr)
  4501. client->SimpleMessage(CHANNEL_COLOR_RED, "No region map for zone.");
  4502. else
  4503. {
  4504. cmdTarget->GetRegionMap()->IdentifyRegionsInGrid(client, targPos);
  4505. }
  4506. break;
  4507. }
  4508. else if (ToLower(string(sep->arg[0])) == "behind")
  4509. {
  4510. bool isBehind = client->GetPlayer()->BehindTarget(cmdTarget);
  4511. client->Message(CHANNEL_COLOR_YELLOW, "%s %s.", isBehind ? "YOU are behind" : "YOU are NOT behind", cmdTarget->GetName());
  4512. break;
  4513. }
  4514. else if (ToLower(string(sep->arg[0])) == "infront")
  4515. {
  4516. bool isBehind = client->GetPlayer()->InFrontSpawn(cmdTarget, client->GetPlayer()->GetX(), client->GetPlayer()->GetZ());
  4517. client->Message(CHANNEL_COLOR_YELLOW, "%s %s.", isBehind ? "YOU are infront of" : "YOU are NOT infront of", cmdTarget->GetName());
  4518. break;
  4519. }
  4520. else if (ToLower(string(sep->arg[0])) == "flank")
  4521. {
  4522. bool isFlanking = client->GetPlayer()->FlankingTarget(cmdTarget);
  4523. client->Message(CHANNEL_COLOR_YELLOW, "%s is %s.", isFlanking ? "YOU are flanking" : "YOU are NOT flanking", cmdTarget->GetName());
  4524. break;
  4525. }
  4526. else if (ToLower(string(sep->arg[0])) == "aggro")
  4527. {
  4528. if(cmdTarget->IsNPC() && ((NPC*)cmdTarget)->Brain()) {
  4529. ((NPC*)cmdTarget)->Brain()->SendEncounterList(client);
  4530. ((NPC*)cmdTarget)->Brain()->SendHateList(client);
  4531. }
  4532. else {
  4533. client->SimpleMessage(CHANNEL_COLOR_RED, "/spawn details aggro is for NPCs only!");
  4534. }
  4535. break;
  4536. }
  4537. else if (ToLower(string(sep->arg[0])) == "angle")
  4538. {
  4539. float spawnAngle = client->GetPlayer()->GetFaceTarget(cmdTarget->GetX(), cmdTarget->GetZ());
  4540. 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());
  4541. break;
  4542. }
  4543. }
  4544. if (sep->IsNumber(0))
  4545. {
  4546. float radius = atof(sep->arg[0]);
  4547. if (!client->GetCurrentZone()->SendRadiusSpawnInfo(client, radius))
  4548. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No results in the radius were found.");
  4549. break;
  4550. }
  4551. }
  4552. if (spawn) {
  4553. const char* type = "NPC";
  4554. if (spawn->IsObject())
  4555. type = "Object";
  4556. else if (spawn->IsSign())
  4557. type = "Sign";
  4558. else if (spawn->IsWidget())
  4559. type = "Widget";
  4560. else if (spawn->IsGroundSpawn())
  4561. type = "GroundSpawn";
  4562. int16 race_type = race_types_list.GetRaceType(spawn->GetModelType());
  4563. int16 race_base_type = race_types_list.GetRaceBaseType(spawn->GetModelType());
  4564. char* category = race_types_list.GetRaceTypeCategory(spawn->GetModelType());
  4565. char* subcategory = race_types_list.GetRaceTypeSubCategory(spawn->GetModelType());
  4566. char* modelname = race_types_list.GetRaceTypeModelName(spawn->GetModelType());
  4567. client->Message(CHANNEL_COLOR_YELLOW, "Name: %s, %s ID: %u", spawn->GetName(), type, spawn->GetDatabaseID());
  4568. client->Message(CHANNEL_COLOR_YELLOW, "Last Name: %s, Sub-Title: %s, Prefix: %s, Suffix: %s", spawn->GetLastName(), spawn->GetSubTitle(), spawn->GetPrefixTitle(), spawn->GetSuffixTitle());
  4569. client->Message(CHANNEL_COLOR_YELLOW, "Spawn Location ID: %u, Spawn Group ID: %u", spawn->GetSpawnLocationID(), spawn->GetSpawnGroupID());
  4570. client->Message(CHANNEL_COLOR_YELLOW, "Faction ID: %u, Merchant ID: %u, Transporter ID: %u", spawn->GetFactionID(), spawn->GetMerchantID(), spawn->GetTransporterID());
  4571. client->Message(CHANNEL_COLOR_YELLOW, "Grid ID: %u", spawn->GetLocation());
  4572. client->Message(CHANNEL_COLOR_YELLOW, "Race: %i, Class: %i, Gender: %i", spawn->GetRace(), spawn->GetAdventureClass(), spawn->GetGender());
  4573. client->Message(CHANNEL_COLOR_YELLOW, "Level: %i, HP: %u / %u, Power: %u / %u", spawn->GetLevel(), spawn->GetHP(), spawn->GetTotalHP(), spawn->GetPower(), spawn->GetTotalPower());
  4574. 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());
  4575. client->Message(CHANNEL_COLOR_YELLOW, "Collision Radius: %i, Size: %i, Difficulty: %i, Heroic: %i", spawn->GetCollisionRadius(), spawn->GetSize(), spawn->GetDifficulty(), spawn->GetHeroic());
  4576. client->Message(CHANNEL_COLOR_YELLOW, "Targetable: %i, Show Name: %i, Attackable: %i, Show Level: %i", spawn->GetTargetable(), spawn->GetShowName(), spawn->GetAttackable(), spawn->GetShowLevel());
  4577. client->Message(CHANNEL_COLOR_YELLOW, "Show Command Icon: %i, Display Hand Icon: %i", spawn->GetShowCommandIcon(), spawn->GetShowHandIcon());
  4578. if (spawn->IsEntity()) {
  4579. 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());
  4580. 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());
  4581. }
  4582. 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);
  4583. client->Message(CHANNEL_COLOR_YELLOW, "Primary Command Type: %u, Secondary Command Type: %u", spawn->GetPrimaryCommandListID(), spawn->GetSecondaryCommandListID());
  4584. 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());
  4585. 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);
  4586. if (spawn->IsNPC())
  4587. client->Message(CHANNEL_COLOR_YELLOW, "Randomize: %u", ((NPC*)spawn)->GetRandomize());
  4588. if (spawn->IsNPC()){
  4589. client->Message(CHANNEL_COLOR_YELLOW, "Heat Resist/Base: %u/%u",((NPC*)spawn)->GetHeatResistance(), ((NPC*)spawn)->GetHeatResistanceBase());
  4590. client->Message(CHANNEL_COLOR_YELLOW, "Cold Resist/Base: %u/%u",((NPC*)spawn)->GetColdResistance(), ((NPC*)spawn)->GetColdResistanceBase());
  4591. client->Message(CHANNEL_COLOR_YELLOW, "Magic Resist/Base: %u/%u",((NPC*)spawn)->GetMagicResistance(), ((NPC*)spawn)->GetMagicResistanceBase());
  4592. client->Message(CHANNEL_COLOR_YELLOW, "Mental Resist/Base: %u/%u",((NPC*)spawn)->GetMentalResistance(), ((NPC*)spawn)->GetMentalResistanceBase());
  4593. client->Message(CHANNEL_COLOR_YELLOW, "Divine Resist/Base: %u/%u",((NPC*)spawn)->GetDivineResistance(), ((NPC*)spawn)->GetDivineResistanceBase());
  4594. client->Message(CHANNEL_COLOR_YELLOW, "Disease Resist/Base: %u/%u",((NPC*)spawn)->GetDiseaseResistance(), ((NPC*)spawn)->GetDiseaseResistanceBase());
  4595. client->Message(CHANNEL_COLOR_YELLOW, "Poison Resist/Base: %u/%u",((NPC*)spawn)->GetPoisonResistance(), ((NPC*)spawn)->GetPoisonResistanceBase());
  4596. }
  4597. string details;
  4598. details += "\\#0000FFName: " + string(spawn->GetName()) + "\n";
  4599. details += "Type: " + string(type) + "\n";
  4600. details += "ID: " + to_string(spawn->GetDatabaseID()) + "\n";
  4601. details += "Last Name: " + string(spawn->GetLastName()) + "\n";
  4602. details += "Sub-Title: " + string(spawn->GetSubTitle()) + "\n";
  4603. details += "Prefix: " + string(spawn->GetPrefixTitle()) + "\n";
  4604. details += "Suffix: " + string(spawn->GetSuffixTitle()) + "\n";
  4605. details += "Race: " + to_string(spawn->GetRace()) + "\n";
  4606. details += "Class: " + to_string(spawn->GetAdventureClass()) + "\n";
  4607. details += "Gender: " + to_string(spawn->GetGender()) + "\n";
  4608. details += "Level: " + to_string(spawn->GetLevel()) + "\n";
  4609. details += "HP: " + to_string(spawn->GetHP()) + " / " + to_string(spawn->GetTotalHP()) + "(" + to_string(spawn->GetIntHPRatio()) + "%)\n";
  4610. details += "Power: " + to_string(spawn->GetPower()) + + " / " + to_string(spawn->GetTotalPower()) + "\n";
  4611. details += "Difficulty: " + to_string(spawn->GetDifficulty()) + "\n";
  4612. details += "Heroic: " + to_string(spawn->GetHeroic()) + "\n";
  4613. details += "Group ID: " + to_string(spawn->GetSpawnGroupID()) + "\n";
  4614. details += "Faction ID: " + to_string(spawn->GetFactionID()) + "\n";
  4615. details += "Merchant ID: " + to_string(spawn->GetMerchantID()) + "\n";
  4616. details += "Transport ID: " + to_string(spawn->GetTransporterID()) + "\n";
  4617. details += "Location ID: " + to_string(spawn->GetSpawnLocationID()) + "\n";
  4618. char x[16];
  4619. sprintf(x, "%.2f", spawn->GetX());
  4620. char y[16];
  4621. sprintf(y, "%.2f", spawn->GetY());
  4622. char z[16];
  4623. sprintf(z, "%.2f", spawn->GetZ());
  4624. details += "Location: " + string(x) + ", " + string(y) + ", " + string(z) + "\n";
  4625. string details2;
  4626. details2 += "Heading: " + to_string(spawn->GetHeading()) + "\n";
  4627. details2 += "Grid ID: " + to_string(spawn->GetLocation()) + "\n";
  4628. details2 += "Size: " + to_string(spawn->GetSize()) + "\n";
  4629. details2 += "Collision Radius: " + to_string(spawn->GetCollisionRadius()) + "\n";
  4630. details2 += "Respawn Time: " + to_string(spawn->GetRespawnTime()) + "\n";
  4631. details2 += "Targetable: " + to_string(spawn->GetTargetable()) + "\n";
  4632. details2 += "Show Name: " + to_string(spawn->GetShowName()) + "\n";
  4633. details2 += "Attackable: " + to_string(spawn->GetAttackable()) + "\n";
  4634. details2 += "Show Level: " + to_string(spawn->GetShowLevel()) + "\n";
  4635. details2 += "Show Command Icon: " + to_string(spawn->GetShowCommandIcon()) + "\n";
  4636. details2 += "Display Hand Icon: " + to_string(spawn->GetShowHandIcon()) + "\n";
  4637. details2 += "Model Type: " + to_string(spawn->GetModelType()) + "\n";
  4638. details2 += "Soga Race Type: " + to_string(spawn->GetSogaModelType()) + "\n";
  4639. details2 += "Race Type: " + to_string(race_type) + "\n";
  4640. details2 += "Race Base Type: " + to_string(race_base_type) + "\n";
  4641. details2 += "Race Category (Sub Category): " + std::string(category) + " (" + std::string(subcategory) + ")\n";
  4642. details2 += "Model Name: " + std::string(modelname) + "\n";
  4643. details2 += "Primary Command ID: " + to_string(spawn->GetPrimaryCommandListID()) + "\n";
  4644. details2 += "Secondary Cmd ID: " + to_string(spawn->GetSecondaryCommandListID()) + "\n";
  4645. details2 += "Visual State: " + to_string(spawn->GetVisualState()) + "\n";
  4646. details2 += "Action State: " + to_string(spawn->GetActionState()) + "\n";
  4647. details2 += "Mood State: " + to_string(spawn->GetMoodState()) + "\n";
  4648. details2 += "Initial State: " + to_string(spawn->GetInitialState()) + "\n";
  4649. details2 += "Activity Status: " + to_string(spawn->GetActivityStatus()) + "\n";
  4650. details2 += "Emote State: " + to_string(spawn->GetEmoteState()) + "\n";
  4651. string details3;
  4652. details3 += "Pitch: " + to_string(spawn->GetPitch()) + "\n";
  4653. details3 += "Roll: " + to_string(spawn->GetRoll()) + "\n";
  4654. details3 += "Hide Hood: " + to_string(spawn->appearance.hide_hood) + "\n";
  4655. details3 += "Speed: " + to_string(spawn->GetSpeed()) + "\n";
  4656. details3 += "BaseSpeed: " + to_string(spawn->GetBaseSpeed()) + "\n";
  4657. if(spawn->IsSign()) {
  4658. details3 += "Sign Language: " + to_string(((Sign*)spawn)->GetLanguage()) + "\n";
  4659. }
  4660. if(spawn->IsEntity())
  4661. {
  4662. Entity* ent = (Entity*)spawn;
  4663. details3 += "STR / STRBase: " + to_string(ent->GetInfoStruct()->get_str()) + " / " + to_string(ent->GetInfoStruct()->get_str_base()) + "\n";
  4664. details3 += "AGI / AGIBase: " + to_string(ent->GetInfoStruct()->get_agi()) + " / " + to_string(ent->GetInfoStruct()->get_agi_base()) + "\n";
  4665. details3 += "STA / STABase: " + to_string(ent->GetInfoStruct()->get_sta()) + " / " + to_string(ent->GetInfoStruct()->get_sta_base()) + "\n";
  4666. details3 += "INT / INTBase: " + to_string(ent->GetInfoStruct()->get_intel()) + " / " + to_string(ent->GetInfoStruct()->get_intel_base()) + "\n";
  4667. details3 += "WIS / WISBase: " + to_string(ent->GetInfoStruct()->get_wis()) + " / " + to_string(ent->GetInfoStruct()->get_wis_base()) + "\n";
  4668. }
  4669. string details4;
  4670. if (spawn->IsEntity()) {
  4671. details4 += "Facial Hair Type: " + to_string(((Entity*)spawn)->GetFacialHairType()) + "\n";
  4672. details4 += "Hair Type: " + to_string(((Entity*)spawn)->GetHairType()) + "\n";
  4673. details4 += "Chest Type: " + to_string(((Entity*)spawn)->GetChestType()) + "\n";
  4674. details4 += "Legs Type: " + to_string(((Entity*)spawn)->GetLegsType()) + "\n";
  4675. details4 += "Soga Facial Hair Type: " + to_string(((Entity*)spawn)->GetSogaFacialHairType()) + "\n";
  4676. details4 += "Soga Hair Type: " + to_string(((Entity*)spawn)->GetSogaHairType()) + "\n";
  4677. details4 += "Wing Type: " + to_string(((Entity*)spawn)->GetWingType()) + "\n";
  4678. if (spawn->IsNPC()) {
  4679. details4 += "\nRandomize: " + to_string(((NPC*)spawn)->GetRandomize()) + "\n";
  4680. }
  4681. }
  4682. const char* spawnScriptMsg = (spawn->GetSpawnScript() && strlen(spawn->GetSpawnScript())>0) ? spawn->GetSpawnScript() : "Not Set";
  4683. details4 += "\nSpawnScript: " + std::string(spawnScriptMsg) + "\n";
  4684. string title = string(spawn->GetName()) + "(" + to_string(spawn->GetDatabaseID()) + ")";
  4685. client->SendShowBook(client->GetPlayer(), title, 0, 4, details, details2, details3, details4);
  4686. }
  4687. else {
  4688. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn details (radius)");
  4689. 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.");
  4690. }
  4691. break;
  4692. }
  4693. case COMMAND_SPAWN_TARGET:{
  4694. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  4695. int32 spawn_id = atoul(sep->arg[0]);
  4696. int16 response = client->GetCurrentZone()->SetSpawnTargetable(spawn_id);
  4697. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  4698. }
  4699. else if(sep && sep->arg[0][0] && sep->arg[1][0] && sep->IsNumber(1) && ToLower(string(sep->arg[0])) == "radius"){
  4700. float distance = atof(sep->arg[1]);
  4701. int16 response = client->GetCurrentZone()->SetSpawnTargetable(client->GetPlayer(), distance);
  4702. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  4703. }
  4704. else{
  4705. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn target [spawn id]");
  4706. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn as targetable. Used to change a spawn if it was set to untargetable.");
  4707. }
  4708. break;
  4709. }
  4710. case COMMAND_SPAWN_SET:
  4711. {
  4712. Spawn* spawn = cmdTarget;
  4713. sint16 set_type = -1;
  4714. string type_str;
  4715. if (spawn)
  4716. {
  4717. // check if parameters are (location or list or not player and not a 2nd param), and that there is at least 1 value
  4718. 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)
  4719. {
  4720. // set the type, which will be 0 if location or list or invalid
  4721. set_type = spawn_set_values[ToLower(string(sep->arg[0]))];
  4722. }
  4723. if(set_type > 0)
  4724. {
  4725. // check if spawn set is NOT a char update, or not location, or isn't a number
  4726. 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)
  4727. {
  4728. client->SimpleMessage(CHANNEL_COLOR_RED, "Invalid value for set command.");
  4729. }
  4730. else
  4731. {
  4732. string name = string(spawn->GetName());
  4733. bool customSetSpawn = false;
  4734. if(set_type >= SPAWN_SET_CHEEK_TYPE && set_type <= SPAWN_SET_SOGA_NOSE_TYPE)
  4735. {
  4736. int8 index = sep->IsNumber(2) ? atoul(sep->arg[2]) : 0;
  4737. // override the standard setspawncommand, we pass arguments different!
  4738. if(SetSpawnCommand(client, spawn, set_type, sep->arg[1], true, false, nullptr, index))
  4739. customSetSpawn = true;
  4740. }
  4741. if(customSetSpawn || SetSpawnCommand(client, spawn, set_type, sep->argplus[1]))
  4742. {
  4743. if (set_type == SPAWN_SET_VALUE_EXPANSION_FLAG || set_type == SPAWN_SET_VALUE_HOLIDAY_FLAG)
  4744. {
  4745. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "A /reload spawns is required to properly update the spawns with the xpack/holiday flag.");
  4746. }
  4747. else if (set_type == SPAWN_SET_VALUE_NAME)
  4748. {
  4749. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "New name will not be effective until zone reload.");
  4750. }
  4751. else if (set_type == SPAWN_SET_SKIN_COLOR || (set_type >= SPAWN_SET_HAIR_COLOR1 && set_type <= SPAWN_SET_SOGA_EYE_COLOR))
  4752. {
  4753. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set color field to R G B: %s.", sep->argplus[1]);
  4754. }
  4755. else if(set_type == SPAWN_SET_VALUE_LOCATION)
  4756. {
  4757. spawn->SetLocation(client->GetPlayer()->GetLocation());
  4758. 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());
  4759. }
  4760. else
  4761. {
  4762. 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());
  4763. }
  4764. switch (set_type)
  4765. {
  4766. case SPAWN_SET_VALUE_EXPANSION_FLAG:
  4767. case SPAWN_SET_VALUE_HOLIDAY_FLAG:
  4768. case SPAWN_SET_VALUE_FACTION:
  4769. case SPAWN_SET_AAXP_REWARDS:
  4770. case SPAWN_SET_CHEEK_TYPE:
  4771. case SPAWN_SET_CHIN_TYPE:
  4772. case SPAWN_SET_EAR_TYPE:
  4773. case SPAWN_SET_EYE_BROW_TYPE:
  4774. case SPAWN_SET_EYE_TYPE:
  4775. case SPAWN_SET_LIP_TYPE:
  4776. case SPAWN_SET_NOSE_TYPE:
  4777. case SPAWN_SET_BODY_SIZE:
  4778. case SPAWN_SET_BODY_AGE:
  4779. case SPAWN_SET_SOGA_CHEEK_TYPE:
  4780. case SPAWN_SET_SOGA_CHIN_TYPE:
  4781. case SPAWN_SET_SOGA_EAR_TYPE:
  4782. case SPAWN_SET_SOGA_EYE_BROW_TYPE:
  4783. case SPAWN_SET_SOGA_EYE_TYPE:
  4784. case SPAWN_SET_SOGA_LIP_TYPE:
  4785. case SPAWN_SET_SOGA_NOSE_TYPE:
  4786. case SPAWN_SET_SOGA_BODY_SIZE:
  4787. case SPAWN_SET_SOGA_BODY_AGE:
  4788. case SPAWN_SET_ATTACK_TYPE:
  4789. case SPAWN_SET_RACE_TYPE:
  4790. case SPAWN_SET_LOOT_TIER:
  4791. case SPAWN_SET_LOOT_DROP_TYPE:
  4792. case SPAWN_SET_SCARED_STRONG_PLAYERS:
  4793. {
  4794. // not applicable already ran db command
  4795. break;
  4796. }
  4797. default:
  4798. {
  4799. client->GetCurrentZone()->ApplySetSpawnCommand(client, spawn, set_type, sep->argplus[1]);
  4800. break;
  4801. }
  4802. }
  4803. 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))
  4804. {
  4805. if(spawn->GetSpawnLocationID() > 0 && database.UpdateSpawnLocationSpawns(spawn))
  4806. {
  4807. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information for spawn '%s' (DBID: %u)", name.c_str(), spawn->GetDatabaseID());
  4808. }
  4809. else if(spawn->GetSpawnLocationID() > 0)
  4810. {
  4811. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn information, see console window for details.");
  4812. }
  4813. }
  4814. else
  4815. {
  4816. if(spawn->GetDatabaseID() > 0 && database.SaveSpawnInfo(spawn))
  4817. {
  4818. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn for spawn '%s' (DBID: %u)", name.c_str(), spawn->GetDatabaseID());
  4819. }
  4820. else if(spawn->GetDatabaseID() > 0)
  4821. {
  4822. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn, see console window for details.");
  4823. }
  4824. }
  4825. }
  4826. }
  4827. }
  4828. else if(set_type == 0)
  4829. {
  4830. // /spawn set list - lists all possible attributes that can be changed with this command, 10 per line.
  4831. map<string, int8>::iterator itr;
  4832. int i=0;
  4833. string list;
  4834. for(itr = spawn_set_values.begin(); itr != spawn_set_values.end(); itr++, i++)
  4835. {
  4836. if(i==10)
  4837. {
  4838. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  4839. i = 0;
  4840. }
  4841. if(i>0)
  4842. {
  4843. list.append(", ").append(itr->first);
  4844. }
  4845. else
  4846. {
  4847. list = itr->first;
  4848. }
  4849. }
  4850. if(list.length() > 0)
  4851. {
  4852. // if 1 or more, display in client.
  4853. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  4854. }
  4855. }
  4856. else
  4857. {
  4858. // syntax fail
  4859. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn set [type] [value]");
  4860. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used to change various settings for the targeted NPC or Object.");
  4861. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "For a list of changeable settings use /spawn set list");
  4862. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Note: /spawn set location does not require a value. The client's current location is used.");
  4863. }
  4864. }
  4865. break;
  4866. }
  4867. case COMMAND_SPAWN_REMOVE:{
  4868. Spawn* spawn = cmdTarget;
  4869. if(spawn && !spawn->IsPlayer()){
  4870. if(spawn->GetSpawnLocationID() > 0){
  4871. string name = string(spawn->GetName());
  4872. int32 dbid = spawn->GetDatabaseID();
  4873. if(database.RemoveSpawnFromSpawnLocation(spawn)){
  4874. client->GetCurrentZone()->RemoveSpawn(spawn, true, false, true, true, true);
  4875. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed spawn from zone for spawn '%s' (DBID: %u)", name.c_str(), dbid);
  4876. }
  4877. else
  4878. client->SimpleMessage(CHANNEL_COLOR_RED, "Error removing spawn, see console window for details.");
  4879. }
  4880. else
  4881. client->SimpleMessage(CHANNEL_COLOR_RED, "This spawn does not have a spawn group associated with it");
  4882. }
  4883. else{
  4884. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn remove");
  4885. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for removing the targeted NPC or Object from the zone.");
  4886. }
  4887. break;
  4888. }
  4889. case COMMAND_SPAWN_LIST:{
  4890. if(sep && sep->arg[0][0]){
  4891. vector<string>* results = database.GetSpawnNameList(sep->argplus[0]);
  4892. vector<string>::iterator itr;
  4893. if(results){
  4894. for(itr=results->begin();itr!=results->end();itr++){
  4895. client->SimpleMessage(CHANNEL_COLOR_YELLOW, (*itr).c_str());
  4896. }
  4897. safe_delete(results);
  4898. }
  4899. else
  4900. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found. ");
  4901. }
  4902. else{
  4903. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn list [name]");
  4904. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Name can be a partial match.");
  4905. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn list Qeynos Guard");
  4906. }
  4907. break;
  4908. }
  4909. case COMMAND_SPAWN_ADD:{
  4910. Spawn* spawn = cmdTarget;
  4911. if(spawn && sep && sep->arg[1][0] && (sep->IsNumber(0) || strncasecmp(sep->arg[0], "new", 3) == 0)){
  4912. if(spawn->GetSpawnLocationID() > 0){
  4913. client->Message(CHANNEL_COLOR_RED, "This spawn already has a spawn group id of %u, use /spawn remove to reassign it", spawn->GetSpawnLocationID());
  4914. break;
  4915. }
  4916. if(spawn->GetDatabaseID() == 0){
  4917. if(database.SaveSpawnInfo(spawn)) {
  4918. char spawn_type[32];
  4919. memset(spawn_type, 0, sizeof(spawn_type));
  4920. if (spawn->IsNPC())
  4921. strncpy(spawn_type, "NPC", sizeof(spawn_type) - 1);
  4922. else if (spawn->IsObject())
  4923. strncpy(spawn_type, "Object", sizeof(spawn_type) - 1);
  4924. else if (spawn->IsSign())
  4925. strncpy(spawn_type, "Sign", sizeof(spawn_type) - 1);
  4926. else if (spawn->IsGroundSpawn())
  4927. strncpy(spawn_type, "GroundSpawn", sizeof(spawn_type) - 1);
  4928. else
  4929. strncpy(spawn_type, "Unknown", sizeof(spawn_type) - 1);
  4930. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information with a %s id of %u", spawn_type, spawn->GetDatabaseID());
  4931. }
  4932. else
  4933. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn information, see console window for details.");
  4934. }
  4935. int32 spawn_group_id = 0;
  4936. if(strncasecmp(sep->arg[0], "new", 3) == 0)
  4937. spawn_group_id = database.GetNextSpawnLocation();
  4938. else
  4939. spawn_group_id = atol(sep->arg[0]);
  4940. int8 percent = 100;
  4941. if(sep->arg[2] && sep->IsNumber(2))
  4942. percent = atoi(sep->arg[2]);
  4943. spawn->SetSpawnLocationID(spawn_group_id);
  4944. float x_offset = database.GetSpawnLocationPlacementOffsetX(spawn->GetSpawnLocationID());
  4945. float y_offset = database.GetSpawnLocationPlacementOffsetY(spawn->GetSpawnLocationID());
  4946. float z_offset = database.GetSpawnLocationPlacementOffsetZ(spawn->GetSpawnLocationID());
  4947. if(database.SaveSpawnEntry(spawn, sep->arg[1], percent, x_offset, y_offset, z_offset))
  4948. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn location with a spawn group of %u", spawn->GetSpawnLocationID());
  4949. else
  4950. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn location, see console window for details.");
  4951. }
  4952. else{
  4953. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn add [spawn group id] [spawn group name] (percentage)");
  4954. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for adding the targeted NPC or Object to the database.");
  4955. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can substitute new for [spawn group id] to create a new one.");
  4956. }
  4957. break;
  4958. }
  4959. case COMMAND_SPAWN:{
  4960. int32 id = 0;
  4961. Spawn* spawn = 0;
  4962. if(sep && sep->arg[0] && sep->IsNumber(0)){
  4963. id = atol(sep->arg[0]);
  4964. spawn = client->GetCurrentZone()->GetSpawn(id);
  4965. }
  4966. if(id > 0 && spawn && spawn->appearance.name[0] == 0)
  4967. id = 0;
  4968. if(!id || !spawn){
  4969. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn [spawn id] (x) (y) (z) (heading) (location)");
  4970. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are optional except the id. The spawn id must be in the database.");
  4971. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn 1 0 0 0 0");
  4972. safe_delete(sep);
  4973. return;
  4974. }
  4975. if(sep && sep->arg[1][0]){
  4976. float x = atof(sep->arg[1]);
  4977. spawn->appearance.pos.X = x;
  4978. }
  4979. else
  4980. spawn->SetX(client->GetPlayer()->GetX(), false);
  4981. if(sep && sep->arg[2][0]){
  4982. float y = atof(sep->arg[2]);
  4983. spawn->appearance.pos.Y = y;
  4984. }
  4985. else
  4986. spawn->SetY(client->GetPlayer()->GetY(), false);
  4987. if(sep && sep->arg[3][0]){
  4988. float z = atof(sep->arg[3]);
  4989. spawn->appearance.pos.Z = z;
  4990. }
  4991. else
  4992. spawn->SetZ(client->GetPlayer()->GetZ(), false);
  4993. if(sep && sep->arg[4][0]){
  4994. float heading = atof(sep->arg[4]);
  4995. spawn->SetHeading(heading);
  4996. }
  4997. else
  4998. spawn->SetHeading(client->GetPlayer()->GetHeading(), false);
  4999. spawn->SetSpawnOrigX(spawn->GetX());
  5000. spawn->SetSpawnOrigY(spawn->GetY());
  5001. spawn->SetSpawnOrigZ(spawn->GetZ());
  5002. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  5003. if(sep && sep->arg[5][0])
  5004. spawn->SetLocation(atoul(sep->arg[5]));
  5005. else
  5006. spawn->SetLocation(client->GetPlayer()->GetLocation());
  5007. if(spawn->IsNPC() && spawn->GetTotalHP() == 0){
  5008. spawn->SetTotalHP(spawn->GetLevel() * 15);
  5009. spawn->SetHP(spawn->GetTotalHP());
  5010. }
  5011. if(spawn->GetTotalPower() == 0){
  5012. spawn->SetTotalPower(spawn->GetLevel() * 15);
  5013. spawn->SetPower(spawn->GetTotalPower());
  5014. }
  5015. const char* script = world.GetSpawnScript(id);
  5016. if(script && lua_interface && lua_interface->GetSpawnScript(script) != 0)
  5017. spawn->SetSpawnScript(string(script));
  5018. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_PRESPAWN);
  5019. client->GetCurrentZone()->AddSpawn(spawn);
  5020. if(spawn->IsNPC())
  5021. spawn->GetZone()->AddLoot((NPC*)spawn);
  5022. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_SPAWN);
  5023. LogWrite(COMMAND__INFO, 0, "Command", "Received spawn command - Parms: %s", command_parms->data.c_str());
  5024. break;
  5025. }
  5026. case COMMAND_ADMINFLAG:
  5027. {
  5028. if(sep && sep->arg[0]){
  5029. sint16 tmp_status = database.GetCharacterAdminStatus(sep->arg[0]);
  5030. sint16 new_status = atoi(sep->arg[1]);
  5031. if(tmp_status == -10)
  5032. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character does not exist.");
  5033. else if(tmp_status >= client->GetAdminStatus())
  5034. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character has same or higher level status.");
  5035. else if (new_status > client->GetAdminStatus())
  5036. client->SimpleMessage(CHANNEL_ERROR, "Unable to flag character. Reason: New status is higher then your status.");
  5037. else{
  5038. Client* client2 = client->GetCurrentZone()->GetClientByName(sep->arg[0]);
  5039. if (!client2)
  5040. client2 = zone_list.GetClientByCharName(sep->arg[0]);
  5041. if(database.UpdateAdminStatus(sep->arg[0],new_status)) {
  5042. client->Message(CHANNEL_COLOR_YELLOW,"Character status updated to %i for %s.",new_status,sep->arg[0]);
  5043. if (client2) {
  5044. client2->SetAdminStatus(new_status);
  5045. client2->Message(CHANNEL_COLOR_YELLOW, "%s has set your admin status to %i.", client->GetPlayer()->GetName(), new_status);
  5046. }
  5047. }
  5048. else
  5049. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Unknown reason.");
  5050. }
  5051. }else{
  5052. sint16 status = database.GetCharacterAdminStatus(client->GetPlayer()->GetName());
  5053. if(status != client->GetAdminStatus())
  5054. {
  5055. client->Message(CHANNEL_COLOR_YELLOW,"Flag status was changed from %i to %i.",status,client->GetAdminStatus());
  5056. client->SetAdminStatus(status);
  5057. }
  5058. else
  5059. {
  5060. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /flag {name} {new_status}");
  5061. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Standard User: 0");
  5062. client->Message(CHANNEL_COLOR_YELLOW," Admin User: %i", status);
  5063. }
  5064. }
  5065. break;
  5066. }
  5067. case COMMAND_CANNEDEMOTE:{
  5068. client->GetCurrentZone()->HandleEmote(client->GetPlayer(), command_parms->data);
  5069. break;
  5070. }
  5071. case COMMAND_BROADCAST: {
  5072. if (sep && sep->arg[0])
  5073. zone_list.HandleGlobalBroadcast(sep->argplus[0]);
  5074. else
  5075. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /broadcast {message}");
  5076. break;
  5077. }
  5078. case COMMAND_ANNOUNCE: {
  5079. if (sep && sep->arg[0])
  5080. zone_list.HandleGlobalAnnouncement(sep->argplus[0]);
  5081. else
  5082. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /announce {message}");
  5083. break;
  5084. }
  5085. case COMMAND_RELOAD_ITEMS:{
  5086. LogWrite(COMMAND__INFO, 0, "Command", "Reloading items..");
  5087. int32 item_id = (sep && sep->arg[0]) ? atoul(sep->arg[0]) : 0;
  5088. if(item_id > 0) {
  5089. client->Message(CHANNEL_COLOR_YELLOW, "Reloading item %u based on /reload items [item_id].", item_id);
  5090. }
  5091. else {
  5092. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Started Reloading items (this might take a few minutes...)");
  5093. }
  5094. database.ReloadItemList(item_id);
  5095. if(!item_id) {
  5096. database.LoadMerchantInformation(); // we skip if there is only a reload of single item not all items
  5097. }
  5098. if(item_id > 0) {
  5099. client->Message(CHANNEL_COLOR_YELLOW, "Reloaded item %u.", item_id);
  5100. }
  5101. else {
  5102. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Finished Reloading items.");
  5103. }
  5104. break;
  5105. }
  5106. case COMMAND_ENABLE_ABILITY_QUE:{
  5107. EQ2Packet* app = client->GetPlayer()->GetSpellBookUpdatePacket(client->GetVersion());
  5108. if(app)
  5109. client->QueuePacket(app);
  5110. break;
  5111. }
  5112. case COMMAND_ITEMSEARCH:
  5113. case COMMAND_FROMBROKER:{
  5114. PacketStruct* packet = configReader.getStruct("WS_StartBroker", client->GetVersion());
  5115. if (packet) {
  5116. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  5117. //packet->setDataByName("unknown", 1);
  5118. packet->setDataByName("unknown2", 5, 0);
  5119. packet->setDataByName("unknown2", 20, 1);
  5120. packet->setDataByName("unknown2", 58, 3);
  5121. packet->setDataByName("unknown2", 40, 4);
  5122. client->QueuePacket(packet->serialize());
  5123. PacketStruct* packet2 = configReader.getStruct("WS_BrokerBags", client->GetVersion());
  5124. if (packet2) {
  5125. packet2->setDataByName("char_id", client->GetCharacterID());
  5126. client->QueuePacket(packet2->serialize()); //send this for now, needed to properly clear data
  5127. safe_delete(packet2);
  5128. }
  5129. safe_delete(packet);
  5130. }
  5131. break;
  5132. }
  5133. case COMMAND_ANIMTEST:{
  5134. PacketStruct* command_packet = configReader.getStruct("WS_CannedEmote", client->GetVersion());
  5135. if(command_packet){
  5136. int32 id = client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer());
  5137. if (cmdTarget)
  5138. id = client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget);
  5139. command_packet->setDataByName ( "spawn_id" , id);
  5140. int animID = 1;
  5141. if(sep && sep->arg[0] && sep->IsNumber(0))
  5142. animID = atoi(sep->arg[0]);
  5143. VisualState* vs = NULL;
  5144. if(animID == 0)
  5145. {
  5146. vs = visual_states.FindVisualState(sep->arg[0]);
  5147. }
  5148. char msg[128];
  5149. sprintf(msg,"Animation Test ID: %i",animID);
  5150. command_packet->setMediumStringByName ( "emote_msg" , msg );
  5151. if(vs != NULL)
  5152. command_packet->setDataByName ( "anim_type", vs->GetID ( ) );
  5153. else
  5154. command_packet->setDataByName ( "anim_type", animID );
  5155. command_packet->setDataByName ( "unknown0", 0 );
  5156. EQ2Packet* outapp = command_packet->serialize();
  5157. client->QueuePacket(outapp);
  5158. safe_delete(command_packet);
  5159. }
  5160. break;
  5161. }
  5162. case COMMAND_KICK:
  5163. {
  5164. if( sep == 0 || sep->arg[0] == 0)
  5165. {
  5166. client->SimpleMessage(CHANNEL_COLOR_RED, "/kick [name]");
  5167. }
  5168. else
  5169. {
  5170. Client* kickClient = zone_list.GetClientByCharName(string(sep->arg[0]));
  5171. if ( kickClient == client )
  5172. {
  5173. client->Message(CHANNEL_COLOR_RED, "You can't kick yourself!");
  5174. break;
  5175. }
  5176. else if(kickClient != NULL)
  5177. {
  5178. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  5179. if ( maxStatus >= client->GetAdminStatus( ) || kickClient->GetAdminStatus() >= client->GetAdminStatus() )
  5180. {
  5181. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  5182. break;
  5183. }
  5184. client->Message(CHANNEL_COLOR_RED, "Kicking %s...",sep->arg[0]);
  5185. kickClient->Disconnect();
  5186. }
  5187. else
  5188. {
  5189. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  5190. }
  5191. }
  5192. break;
  5193. }
  5194. case COMMAND_LOCK:
  5195. {
  5196. if( sep != NULL && sep->arg[0] != NULL && sep->IsNumber(0)){
  5197. int worldLocked = atoi(sep->arg[0]);
  5198. net.world_locked = worldLocked;
  5199. if ( worldLocked )
  5200. client->Message(CHANNEL_COLOR_YELLOW,"World server has been locked.");
  5201. else
  5202. client->Message(CHANNEL_COLOR_YELLOW,"World server has been unlocked.");
  5203. }
  5204. else
  5205. client->SimpleMessage(CHANNEL_COLOR_RED, "/lock [0/1]");
  5206. break;
  5207. }
  5208. case COMMAND_BAN:{
  5209. if( sep == 0 || sep->arg[0] == 0 || (sep->arg[1][0] != 0 && !sep->IsNumber(1) ) )
  5210. {
  5211. client->SimpleMessage(CHANNEL_COLOR_RED, "/ban [name] [permanent:0/1]");
  5212. }
  5213. else
  5214. {
  5215. Client* kickClient = zone_list.GetClientByCharName(sep->arg[0]);
  5216. if ( kickClient == client )
  5217. {
  5218. client->Message(CHANNEL_COLOR_RED, "You can't ban yourself!");
  5219. break;
  5220. }
  5221. else if(kickClient != NULL)
  5222. {
  5223. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  5224. if ( maxStatus > client->GetAdminStatus( ) ||
  5225. client->GetAdminStatus ( ) > kickClient->GetAdminStatus ( ) )
  5226. {
  5227. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  5228. break;
  5229. }
  5230. client->Message(CHANNEL_COLOR_RED, "Kicking & Banning %s...",sep->arg[0]);
  5231. int perm = atol(sep->arg[1]);
  5232. if ( perm == 1 )
  5233. database.UpdateAdminStatus(sep->arg[0],-2);
  5234. else
  5235. database.UpdateAdminStatus(sep->arg[0],-1);
  5236. kickClient->Disconnect();
  5237. }
  5238. else
  5239. {
  5240. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  5241. }
  5242. }
  5243. break;
  5244. }
  5245. case COMMAND_SET_COMBAT_VOICE:{
  5246. int32 value = 0;
  5247. if(sep && sep->arg[0] && sep->IsNumber(0))
  5248. value = atoi(sep->arg[0]);
  5249. client->GetPlayer()->SetCombatVoice(value);
  5250. break;
  5251. }
  5252. case COMMAND_SET_EMOTE_VOICE:{
  5253. int32 value = 0;
  5254. if(sep && sep->arg[0] && sep->IsNumber(0))
  5255. value = atoi(sep->arg[0]);
  5256. client->GetPlayer()->SetEmoteVoice(value);
  5257. break;
  5258. }
  5259. case COMMAND_GIVEITEM:{
  5260. if(sep && sep->arg[0][0] && sep->arg[0][1] && sep->IsNumber(1)){
  5261. Client* itemToClient = zone_list.GetClientByCharName(sep->arg[0]);
  5262. if ( itemToClient == NULL )
  5263. client->Message(CHANNEL_COLOR_YELLOW,"Could not find %s.",sep->arg[0]);
  5264. else
  5265. {
  5266. int32 item_id = atol(sep->arg[1]);
  5267. client->Message(CHANNEL_COLOR_YELLOW,"Gave %s item id %i.",sep->arg[0],item_id);
  5268. itemToClient->AddItem(item_id);
  5269. }
  5270. }
  5271. else
  5272. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /giveitem [name] [item_id]");
  5273. break;
  5274. }
  5275. case COMMAND_REPORT_BUG : { Command_ReportBug(client, sep); break; }
  5276. case COMMAND_INVENTORY : { Command_Inventory(client, sep, command); break; }
  5277. case COMMAND_WEAPONSTATS : { Command_WeaponStats(client); break; }
  5278. case COMMAND_SKILL :
  5279. case COMMAND_SKILL_ADD :
  5280. case COMMAND_SKILL_REMOVE :
  5281. case COMMAND_SKILL_LIST : { Command_Skills(client, sep, command->handler); break; }
  5282. case COMMAND_ZONE_SET : { Command_ZoneSet(client, sep); break; }
  5283. case COMMAND_ZONE_DETAILS : { Command_ZoneDetails(client, sep); break; }
  5284. case COMMAND_ENTITYCOMMAND :
  5285. case COMMAND_ENTITYCOMMAND_LIST : { Command_EntityCommand(client, sep, command->handler); break; }
  5286. case COMMAND_MERCHANT :
  5287. case COMMAND_MERCHANT_LIST : { Command_Merchant(client, sep, command->handler); break; }
  5288. case COMMAND_APPEARANCE :
  5289. case COMMAND_APPEARANCE_LIST : { Command_Appearance(client, sep, command->handler); break; }
  5290. case COMMAND_TRACK : { Command_Track(client); break; }
  5291. case COMMAND_DISTANCE : { Command_Distance(client); break; }
  5292. case COMMAND_INSPECT_PLAYER : { Command_InspectPlayer(client, sep); break; }
  5293. case COMMAND_ZONE_SAFE : { Command_ZoneSafeCoords(client, sep); break; }
  5294. case COMMAND_GUILDSAY : { Command_GuildSay(client, sep); break; }
  5295. case COMMAND_OFFICERSAY : { Command_OfficerSay(client, sep); break; }
  5296. case COMMAND_SET_GUILD_MEMBER_NOTE : { Command_SetGuildMemberNote(client, sep); break; }
  5297. case COMMAND_SET_GUILD_OFFICER_NOTE : { Command_SetGuildOfficerNote(client, sep); break; }
  5298. case COMMAND_GUILD : { Command_Guild(client, sep); break; }
  5299. case COMMAND_CREATE_GUILD : { Command_CreateGuild(client); break; }
  5300. case COMMAND_GUILDS : { Command_Guilds(client); break; }
  5301. case COMMAND_GUILDS_ADD : { Command_GuildsAdd(client, sep); break; }
  5302. case COMMAND_GUILDS_CREATE : { Command_GuildsCreate(client, sep); break; }
  5303. case COMMAND_GUILDS_DELETE : { Command_GuildsDelete(client, sep); break; }
  5304. case COMMAND_GUILDS_LIST : { Command_GuildsList(client); break; }
  5305. case COMMAND_GUILDS_REMOVE : { Command_GuildsRemove(client, sep); break; }
  5306. case COMMAND_CLAIM : { Command_Claim(client, sep); break; }
  5307. case COMMAND_CLEAR_ALL_QUEUED : { Command_ClearAllQueued(client); break; }
  5308. case COMMAND_LOCATION : { Command_Location(client); break; }
  5309. case COMMAND_LOCATION_ADD : { Command_LocationAdd(client, sep); break; }
  5310. case COMMAND_LOCATION_CREATE : { Command_LocationCreate(client, sep); break; }
  5311. case COMMAND_LOCATION_DELETE : { Command_LocationDelete(client, sep); break; }
  5312. case COMMAND_LOCATION_LIST : { Command_LocationList(client, sep); break; }
  5313. case COMMAND_LOCATION_REMOVE : { Command_LocationRemove(client, sep); break; }
  5314. case COMMAND_GRID : { Command_Grid(client, sep); break; }
  5315. case COMMAND_TRY_ON : { Command_TryOn(client, sep); break; }
  5316. case COMMAND_RANDOMIZE : { Command_Randomize(client, sep); break; }
  5317. case COMMAND_AFK : { Command_AFK(client, sep); break; }
  5318. case COMMAND_SHOW_CLOAK : { Command_ShowCloak(client, sep); break; }
  5319. case COMMAND_SHOW_HELM : { Command_ShowHelm(client, sep); break; }
  5320. case COMMAND_SHOW_HOOD : { Command_ShowHood(client, sep); break; }
  5321. case COMMAND_SHOW_HOOD_OR_HELM : { Command_ShowHoodHelm(client, sep); break; }
  5322. case COMMAND_SHOW_RANGED : { Command_ShowRanged(client, sep); break; }
  5323. case COMMAND_STOP_DRINKING : { Command_StopDrinking(client); break; }
  5324. case COMMAND_STOP_EATING : { Command_StopEating(client); break; }
  5325. case COMMAND_TOGGLE_ANONYMOUS : { Command_Toggle_Anonymous(client); break; }
  5326. case COMMAND_TOGGLE_AUTOCONSUME : { Command_Toggle_AutoConsume(client, sep); break; }
  5327. case COMMAND_TOGGLE_BONUS_EXP : { Command_Toggle_BonusXP(client); break; }
  5328. case COMMAND_TOGGLE_COMBAT_EXP : { Command_Toggle_CombatXP(client); break; }
  5329. case COMMAND_TOGGLE_GM_HIDE : { Command_Toggle_GMHide(client); break; }
  5330. case COMMAND_TOGGLE_GM_VANISH : { Command_Toggle_GMVanish(client); break; }
  5331. case COMMAND_TOGGLE_ILLUSIONS : { Command_Toggle_Illusions(client, sep); break; }
  5332. case COMMAND_TOGGLE_LFG : { Command_Toggle_LFG(client); break; }
  5333. case COMMAND_TOGGLE_LFW : { Command_Toggle_LFW(client); break; }
  5334. case COMMAND_TOGGLE_QUEST_EXP : { Command_Toggle_QuestXP(client); break; }
  5335. case COMMAND_TOGGLE_ROLEPLAYING : { Command_Toggle_Roleplaying(client); break; }
  5336. case COMMAND_TOGGLE_DUELS : { Command_Toggle_Duels(client); break; }
  5337. case COMMAND_TOGGLE_TRADES : { Command_Toggle_Trades(client); break; }
  5338. case COMMAND_TOGGLE_GUILDS : { Command_Toggle_Guilds(client); break; }
  5339. case COMMAND_TOGGLE_GROUPS : { Command_Toggle_Groups(client); break; }
  5340. case COMMAND_TOGGLE_RAIDS : { Command_Toggle_Raids(client); break; }
  5341. case COMMAND_TOGGLE_LON : { Command_Toggle_LON(client); break; }
  5342. case COMMAND_TOGGLE_VCINVITE : { Command_Toggle_VoiceChat(client); break; }
  5343. case COMMAND_CANCEL_MAINTAINED : { Command_CancelMaintained(client, sep); break; }
  5344. case COMMAND_MOTD : { Command_MOTD(client); break; }
  5345. case COMMAND_RANDOM : { Command_Random(client, sep); break; }
  5346. case COMMAND_CREATE : { Command_Create(client, sep); break; }
  5347. case COMMAND_CREATEFROMRECIPE : { Command_CreateFromRecipe(client, sep); break; }
  5348. case COMMAND_TITLE : { Command_Title(client); break; }
  5349. case COMMAND_TITLE_LIST : { Command_TitleList(client); break; }
  5350. case COMMAND_TITLE_SETPREFIX : { Command_TitleSetPrefix(client, sep); break; }
  5351. case COMMAND_TITLE_SETSUFFIX : { Command_TitleSetSuffix(client, sep); break; }
  5352. case COMMAND_TITLE_FIX : { Command_TitleFix(client, sep); break; }
  5353. case COMMAND_LANGUAGES : { Command_Languages(client, sep); break; }
  5354. case COMMAND_SET_LANGUAGE : { Command_SetLanguage(client, sep); break; }
  5355. case COMMAND_FOLLOW : { Command_Follow(client, sep); break; }
  5356. case COMMAND_STOP_FOLLOW : { Command_StopFollow(client, sep); break; }
  5357. case COMMAND_LASTNAME : { Command_LastName(client, sep); break; }
  5358. case COMMAND_CONFIRMLASTNAME : { Command_ConfirmLastName(client, sep); break; }
  5359. case COMMAND_PET : { Command_Pet(client, sep); break; }
  5360. case COMMAND_PETNAME : { Command_PetName(client, sep); break; }
  5361. case COMMAND_NAME_PET : { Command_NamePet(client, sep); break; }
  5362. case COMMAND_RENAME : { Command_Rename(client, sep); break; }
  5363. case COMMAND_CONFIRMRENAME : { Command_ConfirmRename(client, sep); break; }
  5364. case COMMAND_PETOPTIONS : { Command_PetOptions(client, sep); break; }
  5365. case COMMAND_START_TRADE : { Command_TradeStart(client, sep); break; }
  5366. case COMMAND_ACCEPT_TRADE : { Command_TradeAccept(client, sep); break; }
  5367. case COMMAND_REJECT_TRADE : { Command_TradeReject(client, sep); break; }
  5368. case COMMAND_CANCEL_TRADE : { Command_TradeCancel(client, sep); break; }
  5369. case COMMAND_SET_TRADE_COIN : { Command_TradeSetCoin(client, sep); break; }
  5370. case COMMAND_ADD_TRADE_COPPER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_COPPER); break; }
  5371. case COMMAND_ADD_TRADE_SILVER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_SILVER); break; }
  5372. case COMMAND_ADD_TRADE_GOLD : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_GOLD); break; }
  5373. case COMMAND_ADD_TRADE_PLAT : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_PLAT); break; }
  5374. case COMMAND_REMOVE_TRADE_COPPER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_COPPER); break; }
  5375. case COMMAND_REMOVE_TRADE_SILVER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_SILVER); break; }
  5376. case COMMAND_REMOVE_TRADE_GOLD : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_GOLD); break; }
  5377. case COMMAND_REMOVE_TRADE_PLAT : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_PLAT); break; }
  5378. case COMMAND_ADD_TRADE_ITEM : { Command_TradeAddItem(client, sep); break; }
  5379. case COMMAND_REMOVE_TRADE_ITEM : { Command_TradeRemoveItem(client, sep); break; }
  5380. case COMMAND_ACCEPT_ADVANCEMENT : { Command_AcceptAdvancement(client, sep); break; }
  5381. case COMMAND_DUEL : { Command_Duel(client, sep); break; }
  5382. case COMMAND_DUELBET : { Command_DuelBet(client, sep); break; }
  5383. case COMMAND_DUEL_ACCEPT : { Command_DuelAccept(client, sep); break; }
  5384. case COMMAND_DUEL_DECLINE : { Command_DuelDecline(client, sep); break; }
  5385. case COMMAND_DUEL_SURRENDER : { Command_DuelSurrender(client, sep); break; }
  5386. case COMMAND_DUEL_TOGGLE : { Command_DuelToggle(client, sep); break; }
  5387. case COMMAND_SPAWN_TEMPLATE : { Command_SpawnTemplate(client, sep); break; }
  5388. //devn00b
  5389. case COMMAND_MOOD : { Command_Mood(client, sep); break;}
  5390. case COMMAND_MODIFY : { Command_Modify(client); break; }
  5391. case COMMAND_MODIFY_CHARACTER : { Command_ModifyCharacter(client, sep); break; }
  5392. case COMMAND_MODIFY_QUEST : { Command_ModifyQuest(client, sep); break; }
  5393. case COMMAND_MODIFY_FACTION : { Command_ModifyFaction(client, sep); break; }
  5394. case COMMAND_MODIFY_GUILD : { Command_ModifyGuild(client, sep); break; }
  5395. case COMMAND_MODIFY_ITEM : { Command_ModifyItem(client, sep); break; }
  5396. case COMMAND_MODIFY_SKILL : { Command_ModifySkill(client, sep); break; }
  5397. case COMMAND_MODIFY_SPAWN : { Command_ModifySpawn(client, sep); break; }
  5398. case COMMAND_MODIFY_SPELL : { Command_ModifySpell(client, sep); break; }
  5399. case COMMAND_MODIFY_ZONE : { Command_ModifyZone(client, sep); break; }
  5400. case COMMAND_JOIN_CHANNEL : { Command_JoinChannel(client, sep); break;}
  5401. case COMMAND_JOIN_CHANNEL_FROM_LOAD: { Command_JoinChannelFromLoad(client, sep); break;}
  5402. case COMMAND_TELL_CHANNEL : { Command_TellChannel(client, sep); break;}
  5403. case COMMAND_LEAVE_CHANNEL : { Command_LeaveChannel(client, sep); break;}
  5404. case COMMAND_WHO_CHANNEL : { Command_WhoChannel(client, sep); break;}
  5405. case COMMAND_RAIN : { Command_Rain(client, sep); break; }
  5406. case COMMAND_WIND : { Command_Wind(client, sep); break; }
  5407. case COMMAND_WEATHER : { Command_Weather(client, sep); break; }
  5408. case COMMAND_FROM_MERCHANT : { Command_SendMerchantWindow(client, sep); break; }
  5409. case COMMAND_TO_MERCHANT : { Command_SendMerchantWindow(client, sep, true); break; }
  5410. case COMMAND_SELECT : { Command_Select(client, sep); break; }
  5411. case COMMAND_SMP : { Command_StationMarketPlace(client, sep); break; }
  5412. case COMMAND_CONSUME_FOOD : { Command_ConsumeFood(client, sep); break; }
  5413. case COMMAND_AQUAMAN : { Command_Aquaman(client, sep); break; }
  5414. case COMMAND_ATTUNE_INV : { Command_Attune_Inv(client, sep); break; }
  5415. case COMMAND_PLAYER : { Command_Player(client, sep); break; }
  5416. case COMMAND_PLAYER_COINS : { Command_Player_Coins(client, sep); break; }
  5417. case COMMAND_RESET_ZONE_TIMER : { Command_Reset_Zone_Timer(client, sep); break; }
  5418. case COMMAND_ACHIEVEMENT_ADD : { Command_AchievementAdd(client, sep); break; }
  5419. case COMMAND_EDITOR : { Command_Editor(client, sep); break; }
  5420. case COMMAND_ACCEPT_RESURRECTION: { Command_AcceptResurrection(client, sep); break; }
  5421. case COMMAND_DECLINE_RESURRECTION:{ Command_DeclineResurrection(client, sep); break; }
  5422. case COMMAND_TEST : { Command_Test(client, command_parms); break; }
  5423. case COMMAND_SPEED : { Command_Speed(client, sep); break; }
  5424. case COMMAND_BOT : { Command_Bot(client, sep); break; }
  5425. case COMMAND_BOT_CREATE : { Command_Bot_Create(client, sep); break; }
  5426. case COMMAND_BOT_CUSTOMIZE : { Command_Bot_Customize(client, sep); break; }
  5427. case COMMAND_BOT_SPAWN : { Command_Bot_Spawn(client, sep); break; }
  5428. case COMMAND_BOT_LIST : { Command_Bot_List(client, sep); break; }
  5429. case COMMAND_BOT_INV : { Command_Bot_Inv(client, sep); break; }
  5430. case COMMAND_BOT_SETTINGS : { Command_Bot_Settings(client, sep); break; }
  5431. case COMMAND_BOT_HELP : { Command_Bot_Help(client, sep); break; }
  5432. case GET_AA_XML : { Get_AA_Xml(client, sep); break; }
  5433. case ADD_AA : { Add_AA(client, sep); break; }
  5434. case COMMIT_AA_PROFILE : { Commit_AA_Profile(client, sep); break; }
  5435. case BEGIN_AA_PROFILE : { Begin_AA_Profile(client, sep); break; }
  5436. case BACK_AA : { Back_AA(client, sep); break; }
  5437. case REMOVE_AA : { Remove_AA(client, sep); break; }
  5438. case SWITCH_AA_PROFILE : { Switch_AA_Profile(client, sep); break; }
  5439. case CANCEL_AA_PROFILE : { Cancel_AA_Profile(client, sep); break; }
  5440. case SAVE_AA_PROFILE : { Save_AA_Profile(client, sep); break; }
  5441. case COMMAND_TARGETITEM : { Command_TargetItem(client, sep); break; }
  5442. case COMMAND_FINDSPAWN: { Command_FindSpawn(client, sep); break; }
  5443. case COMMAND_MOVECHARACTER: { Command_MoveCharacter(client, sep); break; }
  5444. case COMMAND_CRAFTITEM: {
  5445. Item* item = 0;
  5446. if (sep && sep->IsNumber(0)) {
  5447. int32 item_id = atol(sep->arg[0]);
  5448. int32 quantity = 1;
  5449. if (sep->arg[1] && sep->IsNumber(1))
  5450. quantity = atoi(sep->arg[1]);
  5451. item = new Item(master_item_list.GetItem(item_id));
  5452. if (!item) {
  5453. LogWrite(TRADESKILL__ERROR, 0, "CraftItem", "Item (%u) not found.", item_id);
  5454. }
  5455. else {
  5456. item->details.count = quantity;
  5457. // use CHANNEL_COLOR_CHAT_RELATIONSHIP as that is the same value (4) as it is in a log for this message
  5458. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You created %s.", item->CreateItemLink(client->GetVersion()).c_str());
  5459. bool itemDeleted = false;
  5460. client->AddItem(item, &itemDeleted);
  5461. //Check for crafting quest updates
  5462. int8 update_amt = 0;
  5463. if (!itemDeleted && item->stack_count > 1)
  5464. update_amt = 1;
  5465. else
  5466. update_amt = quantity;
  5467. if(!itemDeleted)
  5468. client->GetPlayer()->CheckQuestsCraftUpdate(item, update_amt);
  5469. }
  5470. }
  5471. else {
  5472. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /craftitem {item_id} [quantity] ");
  5473. }
  5474. break;
  5475. }
  5476. case COMMAND_UNMENTOR:
  5477. case COMMAND_MENTOR: {
  5478. client->GetPlayer()->MentorTarget();
  5479. break;
  5480. }
  5481. case COMMAND_CANCEL_EFFECT: { Command_CancelEffect(client, sep); break; }
  5482. case COMMAND_CUREPLAYER: { Command_CurePlayer(client, sep); break; }
  5483. case COMMAND_SHARE_QUEST: { Command_ShareQuest(client, sep); break; }
  5484. case COMMAND_YELL: { Command_Yell(client, sep); break; }
  5485. case COMMAND_SETAUTOLOOTMODE: { Command_SetAutoLootMode(client, sep); break; }
  5486. default:
  5487. {
  5488. LogWrite(COMMAND__WARNING, 0, "Command", "Unhandled command: %s", command->command.data.c_str());
  5489. break;
  5490. }
  5491. }
  5492. safe_delete(sep);
  5493. }
  5494. /******************** New COMMAND Handler Functions ********************/
  5495. /*
  5496. Started breaking apart the huge switch() for commands into sepErate
  5497. functions so it is easier to locate the blocks of code by command
  5498. -- JA 2012.03.03
  5499. */
  5500. // sample function header
  5501. /*
  5502. Function:
  5503. Purpose :
  5504. Params :
  5505. Dev :
  5506. Example :
  5507. */
  5508. //void Commands::Command()
  5509. //{
  5510. //}
  5511. /*
  5512. Function: Command_AcceptAdvancement()
  5513. Purpose : Player accepts a new advancement option
  5514. Params : Spell ID
  5515. Dev : Jabantiz
  5516. */
  5517. void Commands::Command_AcceptAdvancement(Client* client, Seperator* sep)
  5518. {
  5519. Player *player = client->GetPlayer();
  5520. if (sep && sep->IsSet(0)) {
  5521. TraitData* trait = master_trait_list.GetTrait(atoul(sep->arg[0]));
  5522. // Check to see if this is a trait or grandmaster training (traits are always new spells, training is always upgrades)
  5523. if (!player->HasSpell(trait->spellID, 0, true))
  5524. {
  5525. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  5526. player->AddSpellBookEntry(trait->spellID, trait->tier, player->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  5527. }
  5528. else
  5529. {
  5530. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  5531. int8 old_slot = player->GetSpellSlot(spell->GetSpellID());
  5532. player->RemoveSpellBookEntry(spell->GetSpellID());
  5533. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  5534. player->UnlockSpell(spell);
  5535. client->SendSpellUpdate(spell);
  5536. }
  5537. // Spell book update
  5538. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  5539. client->QueuePacket(master_trait_list.GetTraitListPacket(client));
  5540. }
  5541. }
  5542. /*
  5543. Function:
  5544. Purpose :
  5545. Params :
  5546. Dev :
  5547. Example :
  5548. */
  5549. void Commands::Command_AFK(Client* client, Seperator* sep)
  5550. {
  5551. Player* player = client->GetPlayer();
  5552. player->toggle_character_flag(CF_AFK);
  5553. client->Message(CHANNEL_COLOR_YELLOW,"You are %s afk.", client->GetPlayer()->get_character_flag(CF_AFK)?"now":"no longer");
  5554. if (player->get_character_flag(CF_AFK))
  5555. {
  5556. if (sep && sep->argplus[0])
  5557. player->SetAwayMessage("I am away from the keyboard, " + string(sep->argplus[0]));
  5558. else
  5559. player->SetAwayMessage("Sorry, I am A.F.K. (Away From Keyboard)");
  5560. string message = string(player->GetName()) + " is going afk.";
  5561. Spawn* target = player->GetTarget();
  5562. if (target && target != player)
  5563. {
  5564. message = string(player->GetName()) + " tells " + string(target->GetName()) + " that ";
  5565. player->GetGender() == 1 ? message += "he" : message += "she";
  5566. message += " is going afk.";
  5567. }
  5568. player->GetZone()->SimpleMessage(CHANNEL_COLOR_YELLOW, message.c_str(), player, 30);
  5569. }
  5570. }
  5571. /*
  5572. Function: Command_Appearance()
  5573. Purpose : Handles /appearance commands
  5574. Params : list
  5575. Dev : Scatman
  5576. Example : /appearance list
  5577. */
  5578. void Commands::Command_Appearance(Client* client, Seperator* sep, int handler)
  5579. {
  5580. if( handler == COMMAND_APPEARANCE )
  5581. {
  5582. // /appearance command by itself shows help (to be extended)
  5583. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  5584. return;
  5585. }
  5586. else if( handler == COMMAND_APPEARANCE_LIST )
  5587. {
  5588. // /appearance list command expects "name" param
  5589. if (sep && sep->arg[0])
  5590. {
  5591. const char* appearance_name = sep->argplus[0];
  5592. client->Message(CHANNEL_COLOR_YELLOW, "Listing appearances like '%s':", appearance_name);
  5593. vector<int16>* appearances = database.GetAppearanceIDsLikeName(string(appearance_name));
  5594. if (appearances)
  5595. {
  5596. vector<int16>::iterator itr;
  5597. for (itr = appearances->begin(); itr != appearances->end(); itr++)
  5598. {
  5599. int16 id = *itr;
  5600. string name = database.GetAppearanceName(id);
  5601. if (ToLower(name).find(ToLower(string(appearance_name))) < 0xFFFFFFFF)
  5602. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", name.c_str(), id);
  5603. }
  5604. safe_delete(appearances);
  5605. }
  5606. }
  5607. else // no param
  5608. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  5609. }
  5610. }
  5611. /*
  5612. Function: Command_Claim()
  5613. Purpose : Summon veteran rewards
  5614. Params : nothing = show claim window, any number claims that item.
  5615. Dev : devn00b
  5616. Example : /claim 0 (claims the 1st item added to the list claim[0])
  5617. */
  5618. void Commands::Command_Claim(Client* client, Seperator* sep)
  5619. {
  5620. //if we were passed a claim id
  5621. if (sep && sep->argplus[0] && sep->IsNumber(0))
  5622. {
  5623. int32 char_id = client->GetCharacterID();
  5624. int8 my_claim_id = atoi(sep->argplus[0]);
  5625. vector<ClaimItems> claim = database.LoadCharacterClaimItems(char_id);
  5626. Item* item = master_item_list.GetItem(claim[my_claim_id].item_id);
  5627. database.ClaimItem(char_id, item->details.item_id, client);
  5628. return;
  5629. }
  5630. else {
  5631. //if no arg just send the window.
  5632. client->ShowClaimWindow();
  5633. return;
  5634. }
  5635. return;
  5636. }
  5637. /*
  5638. Function: Command_ClearAllQueued()
  5639. Purpose :
  5640. Params :
  5641. Dev :
  5642. Example :
  5643. */
  5644. void Commands::Command_ClearAllQueued(Client* client)
  5645. {
  5646. ZoneServer* zone = client->GetPlayer()->GetZone();
  5647. if (zone && zone->GetSpellProcess())
  5648. zone->GetSpellProcess()->RemoveSpellFromQueue(client->GetPlayer());
  5649. }
  5650. /*
  5651. Function: Command_CancelMaintained()
  5652. Purpose : Cancels maintained spells
  5653. Params : Maintained Spell Index
  5654. Dev : Zcoretri
  5655. Example : /cancel_maintained 1 - would cancel the spell in slot 1 of Maintained Spells list
  5656. */
  5657. void Commands::Command_CancelMaintained(Client* client, Seperator* sep)
  5658. {
  5659. if (sep && sep->arg[0] && sep->IsNumber(0))
  5660. {
  5661. int32 spell_index = atoul(sep->arg[0]);
  5662. if(spell_index > 29)
  5663. return;
  5664. client->GetPlayer()->MMaintainedSpells.readlock(__FUNCTION__, __LINE__);
  5665. MaintainedEffects mEffects = client->GetPlayer()->GetInfoStruct()->maintained_effects[spell_index];
  5666. client->GetPlayer()->MMaintainedSpells.releasereadlock(__FUNCTION__, __LINE__);
  5667. if (!client->GetPlayer()->GetZone()->GetSpellProcess()->DeleteCasterSpell(mEffects.spell, "canceled", false))
  5668. client->Message(CHANNEL_COLOR_RED, "The maintained spell could not be cancelled.");
  5669. }
  5670. }
  5671. /*
  5672. Function: Command_Create()
  5673. Purpose : Handler for starting Tradeskilling table
  5674. Params :
  5675. Dev : Zcoretri
  5676. Example :
  5677. */
  5678. void Commands::Command_Create(Client* client, Seperator* sep)
  5679. {
  5680. PrintSep(sep, "COMMAND_CREATE");
  5681. client->ShowRecipeBook();
  5682. }
  5683. void Commands::Command_CreateFromRecipe(Client* client, Seperator* sep)
  5684. {
  5685. PrintSep(sep, "COMMAND_CREATEFROMRECIPE");
  5686. if (sep && sep->arg[0] && sep->IsNumber(0))
  5687. ClientPacketFunctions::SendCreateFromRecipe(client, atoul(sep->arg[0]));
  5688. }
  5689. /*
  5690. Function: Command_Distance()
  5691. Purpose : Displays distance from targeted spawn
  5692. Params :
  5693. Dev : Scatman
  5694. Example : /distance
  5695. */
  5696. void Commands::Command_Distance(Client* client)
  5697. {
  5698. Spawn* target = client->GetPlayer()->GetTarget();
  5699. if (target)
  5700. client->Message(CHANNEL_COLOR_YELLOW, "Your distance from %s is %f", target->GetName(), client->GetPlayer()->GetDistance(target));
  5701. else
  5702. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must have a spawn targeted to use /distance");
  5703. }
  5704. /*
  5705. Function: Command_Duel()
  5706. Purpose : Handle the /duel commands - not yet implemented
  5707. Params : unknown
  5708. Dev :
  5709. Example :
  5710. */
  5711. void Commands::Command_Duel(Client* client, Seperator* sep)
  5712. {
  5713. PrintSep(sep, "COMMAND_DUEL");
  5714. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Command");
  5715. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5716. }
  5717. /*
  5718. Function: Command_DuelBet()
  5719. Purpose : Handle the /duel commands - not yet implemented
  5720. Params : unknown
  5721. Dev :
  5722. Example :
  5723. */
  5724. void Commands::Command_DuelBet(Client* client, Seperator* sep)
  5725. {
  5726. PrintSep(sep, "COMMAND_DUELBET");
  5727. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Bet Command");
  5728. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5729. }
  5730. /*
  5731. Function: Command_DuelAccept()
  5732. Purpose : Handle the /duel commands - not yet implemented
  5733. Params : unknown
  5734. Dev :
  5735. Example :
  5736. */
  5737. void Commands::Command_DuelAccept(Client* client, Seperator* sep)
  5738. {
  5739. PrintSep(sep, "COMMAND_DUEL_ACCEPT");
  5740. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Accept Duel Command");
  5741. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5742. }
  5743. /*
  5744. Function: Command_DuelDecline()
  5745. Purpose : Handle the /duel commands - not yet implemented
  5746. Params : unknown
  5747. Dev :
  5748. Example :
  5749. */
  5750. void Commands::Command_DuelDecline(Client* client, Seperator* sep)
  5751. {
  5752. PrintSep(sep, "COMMAND_DUEL_DECLINE");
  5753. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Decline Duel Request Command");
  5754. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5755. }
  5756. /*
  5757. Function: Command_DuelSurrender()
  5758. Purpose : Handle the /duel commands - not yet implemented
  5759. Params : unknown
  5760. Dev :
  5761. Example :
  5762. */
  5763. void Commands::Command_DuelSurrender(Client* client, Seperator* sep)
  5764. {
  5765. PrintSep(sep, "COMMAND_DUEL_SURRENDER");
  5766. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Surrender Duel Command");
  5767. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5768. // JA, just messin around ;)
  5769. char surrender[64];
  5770. sprintf(surrender, "%s surrendered like a cowardly dog!", client->GetPlayer()->GetName());
  5771. zone_list.HandleGlobalAnnouncement(surrender);
  5772. }
  5773. /*
  5774. Function: Command_DuelToggle()
  5775. Purpose : Handle the /duel commands - not yet implemented
  5776. Params : unknown
  5777. Dev :
  5778. Example :
  5779. */
  5780. void Commands::Command_DuelToggle(Client* client, Seperator* sep)
  5781. {
  5782. PrintSep(sep, "COMMAND_DUEL");
  5783. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Commands");
  5784. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5785. }
  5786. /*
  5787. Function:
  5788. Purpose :
  5789. Params :
  5790. Dev :
  5791. Example :
  5792. */
  5793. void Commands::Command_EntityCommand(Client* client, Seperator* sep, int handler)
  5794. {
  5795. if( handler == COMMAND_ENTITYCOMMAND )
  5796. {
  5797. // /entitycommand command by itself shows help (to be extended)
  5798. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  5799. return;
  5800. }
  5801. else if( handler == COMMAND_ENTITYCOMMAND_LIST )
  5802. {
  5803. // /entitycommand list command expects "name" param
  5804. if (sep && sep->arg[0])
  5805. {
  5806. const char* entity_command_name = sep->argplus[0];
  5807. client->Message(CHANNEL_COLOR_YELLOW, "Listing entity commands like '%s':", entity_command_name);
  5808. map<int32, vector<EntityCommand*>*>* entity_command_list_all = client->GetCurrentZone()->GetEntityCommandListAll();
  5809. map<int32, vector<EntityCommand*>*>::iterator itr;
  5810. for (itr = entity_command_list_all->begin(); itr != entity_command_list_all->end(); itr++)
  5811. {
  5812. vector<EntityCommand*>* entity_command_list = itr->second;
  5813. vector<EntityCommand*>::iterator itr2;
  5814. for (itr2 = entity_command_list->begin(); itr2 != entity_command_list->end(); itr2++)
  5815. {
  5816. EntityCommand* entity_command = *itr2;
  5817. if (ToLower(entity_command->name).find(ToLower(string(entity_command_name))) < 0xFFFFFFFF)
  5818. 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);
  5819. }
  5820. }
  5821. }
  5822. else // no command name
  5823. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  5824. }
  5825. }
  5826. /*
  5827. Function: Command_Follow()
  5828. Purpose : Handle the /follow command - not yet implemented
  5829. Params :
  5830. Dev :
  5831. Example :
  5832. */
  5833. void Commands::Command_Follow(Client* client, Seperator* sep)
  5834. {
  5835. PrintSep(sep, "COMMAND_FOLLOW");
  5836. // flag to toggle if the players target is in the players group
  5837. bool targetInGroup = false;
  5838. // get a pointer to the players group
  5839. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  5840. // If the player has a group and has a target
  5841. if (gmi && client->GetPlayer()->GetTarget()) {
  5842. deque<GroupMemberInfo*>::iterator itr;
  5843. world.GetGroupManager()->GroupLock(__FUNCTION__, __LINE__);
  5844. PlayerGroup* group = world.GetGroupManager()->GetGroup(gmi->group_id);
  5845. if (group)
  5846. {
  5847. group->MGroupMembers.readlock(__FUNCTION__, __LINE__);
  5848. deque<GroupMemberInfo*>* members = group->GetMembers();
  5849. // Loop through the group members
  5850. for (itr = members->begin(); itr != members->end(); itr++) {
  5851. // If a group member matches a target
  5852. if ((*itr)->member && (*itr)->member == client->GetPlayer()->GetTarget()) {
  5853. // toggle the flag and break the loop
  5854. targetInGroup = true;
  5855. break;
  5856. }
  5857. }
  5858. group->MGroupMembers.releasereadlock(__FUNCTION__, __LINE__);
  5859. }
  5860. world.GetGroupManager()->ReleaseGroupLock(__FUNCTION__, __LINE__);
  5861. }
  5862. if (targetInGroup) {
  5863. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  5864. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You start to follow %s.", client->GetPlayer()->GetTarget()->GetName());
  5865. client->GetPlayer()->SetFollowTarget(client->GetPlayer()->GetTarget());
  5866. client->GetPlayer()->info_changed = true;
  5867. client->GetPlayer()->changed = true;
  5868. }
  5869. else
  5870. client->Message(CHANNEL_NARRATIVE, "You must first select a group member to follow.");
  5871. }
  5872. /*
  5873. Function: Command_StopFollow()
  5874. Purpose : Handle the /stop_follow command - not yet implemented
  5875. Params :
  5876. Dev :
  5877. Example :
  5878. */
  5879. void Commands::Command_StopFollow(Client* client, Seperator* sep)
  5880. {
  5881. PrintSep(sep, "COMMAND_STOP_FOLLOW");
  5882. if (client->GetPlayer()->GetFollowTarget()) {
  5883. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  5884. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You are no longer following %s", client->GetPlayer()->GetFollowTarget()->GetName());
  5885. client->GetPlayer()->SetFollowTarget(0);
  5886. client->GetPlayer()->info_changed = true;
  5887. client->GetPlayer()->changed = true;
  5888. }
  5889. }
  5890. /*
  5891. Function: Command_Grid()
  5892. Purpose : Show player's current Grid ID
  5893. Params :
  5894. Dev : Scatman
  5895. Example : /grid
  5896. */
  5897. void Commands::Command_Grid(Client* client, Seperator* sep)
  5898. {
  5899. if (client->GetPlayer()->GetMap() != nullptr) {
  5900. if(sep && sep->arg[0][0] && strncasecmp("spawns", sep->arg[0], 6) == 0) {
  5901. int32 grid = client->GetPlayer()->GetLocation();
  5902. if(sep->IsNumber(1))
  5903. grid = atoul(sep->arg[1]);
  5904. client->GetCurrentZone()->SendClientSpawnListInGrid(client, grid);
  5905. }
  5906. else {
  5907. client->Message(CHANNEL_COLOR_YELLOW, "Your Grid ID is %u", client->GetPlayer()->GetLocation());
  5908. auto loc = glm::vec3(client->GetPlayer()->GetX(), client->GetPlayer()->GetZ(), client->GetPlayer()->GetY());
  5909. uint32 GridID = 0;
  5910. uint32 WidgetID = 0;
  5911. float new_z = client->GetPlayer()->FindBestZ(loc, nullptr, &GridID, &WidgetID);
  5912. float minY = client->GetPlayer()->GetMap()->GetMinY();
  5913. float maxY = client->GetPlayer()->GetMap()->GetMaxY();
  5914. float minZ = client->GetPlayer()->GetMap()->GetMinZ();
  5915. float maxZ = client->GetPlayer()->GetMap()->GetMaxZ();
  5916. int32 grid_spawn_count = client->GetPlayer()->GetZone()->GetSpawnCountInGrid(GridID);
  5917. 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);
  5918. }
  5919. }
  5920. }
  5921. /*
  5922. Function: Command_Guild()
  5923. Purpose : Handler for all UI-related guild commands
  5924. Dev : Scatman
  5925. */
  5926. void Commands::Command_Guild(Client* client, Seperator* sep)
  5927. {
  5928. Guild* guild = client->GetPlayer()->GetGuild();
  5929. if (sep && sep->GetMaxArgNum() > 0 && sep->arg[0])
  5930. {
  5931. const char* command = sep->arg[0];
  5932. int32 length = strlen(command);
  5933. LogWrite(COMMAND__DEBUG, 0, "Command", "Guild Command: %s", command);
  5934. if (strncmp(command, "rank_name", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && guild)
  5935. guild->SetRankName(atoi(sep->arg[1]), sep->argplus[2]);
  5936. else if (strncmp(command, "rank_permission", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  5937. guild->SetPermission(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  5938. else if (strncmp(command, "filter_event", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  5939. guild->SetEventFilter(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  5940. else if (strncmp(command, "kick", length) == 0 && sep->arg[1] && guild)
  5941. guild->KickGuildMember(client, sep->arg[1]);
  5942. else if (strncmp(command, "demote", length) == 0 && sep->arg[1] && guild)
  5943. guild->DemoteGuildMember(client, sep->arg[1]);
  5944. else if (strncmp(command, "promote", length) == 0 && sep->arg[1] && guild)
  5945. guild->PromoteGuildMember(client, sep->arg[1]);
  5946. else if (strncmp(command, "points", length) == 0 && guild)
  5947. {
  5948. if (sep->arg[1] && strncmp(sep->arg[1], "add", length) == 0)
  5949. {
  5950. if (sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  5951. {
  5952. float points = atof(sep->arg[2]);
  5953. const char* option = sep->arg[3];
  5954. const char* comment = sep->argplus[4];
  5955. if (strncmp(option, "all", strlen(option)) == 0)
  5956. guild->AddPointsToAll(client, points, comment);
  5957. else if (strncmp(option, "online", strlen(option)) == 0)
  5958. guild->AddPointsToAllOnline(client, points, comment);
  5959. else if (strncmp(option, "group", strlen(option)) == 0)
  5960. guild->AddPointsToGroup(client, points, comment);
  5961. else if (strncmp(option, "raid", strlen(option)) == 0)
  5962. guild->AddPointsToRaid(client, points, comment);
  5963. else
  5964. guild->AddPointsToGuildMember(client, points, option, comment);
  5965. }
  5966. }
  5967. else if (sep->arg[1] && strncmp(sep->arg[1], "view", strlen(sep->arg[1])) == 0 && sep->arg[2])
  5968. guild->ViewGuildMemberPoints(client, sep->arg[2]);
  5969. else
  5970. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild points command: %s", sep->argplus[0]);
  5971. }
  5972. else if (strncmp(command, "motd", length) == 0 && sep->arg[1] && guild)
  5973. guild->SetMOTD(sep->argplus[1]);
  5974. else if (strncmp(command, "recruiting", length) == 0 && guild)
  5975. {
  5976. if (sep->arg[1])
  5977. {
  5978. const char* option = sep->arg[1];
  5979. if (strncmp(option, "short_text", strlen(option)) == 0 && sep->arg[2])
  5980. guild->SetRecruitingShortDesc(sep->argplus[2]);
  5981. else if (strncmp(option, "long_text", strlen(option)) == 0 && sep->arg[2])
  5982. guild->SetRecruitingFullDesc(sep->argplus[2]);
  5983. else if (strncmp(option, "flag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  5984. guild->SetRecruitingFlag(atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  5985. else if (strncmp(option, "min_level", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  5986. guild->SetRecruitingMinLevel(atoi(sep->arg[2]));
  5987. else if (strncmp(option, "playstyle", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  5988. guild->SetRecruitingPlayStyle(atoi(sep->arg[2]));
  5989. else if (strncmp(option, "tag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && sep->IsNumber(3))
  5990. guild->SetRecruitingDescTag(atoi(sep->arg[2]), atoi(sep->arg[3]));
  5991. else if (strncmp(command, "recruiting", strlen(option)) == 0)
  5992. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_RECRUITING_FOR_GUILD, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  5993. else
  5994. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  5995. }
  5996. else
  5997. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  5998. }
  5999. else if (strncmp(command, "notify_online", length) == 0 && sep->arg[1] && guild)
  6000. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_NOTIFY_LOGINS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  6001. else if (strncmp(command, "event_privacy", length) == 0 && sep->arg[1] && guild)
  6002. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_DONT_GENERATE_EVENTS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  6003. else if (strncmp(command, "recruiter", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  6004. guild->SetGuildRecruiter(client, sep->arg[1], strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  6005. else if (strncmp(command, "recruiter_description", length) == 0 && sep->arg[1] && guild)
  6006. guild->SetGuildRecruiterDescription(client, sep->argplus[1]);
  6007. else if (strncmp(command, "lock_event", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  6008. guild->LockGuildEvent(atoul(sep->arg[1]), strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  6009. else if (strncmp(command, "delete_event", length) == 0 && sep->arg[1] && guild)
  6010. guild->DeleteGuildEvent(atoul(sep->arg[1]));
  6011. else if (strncmp(command, "invite", length) == 0 && guild)
  6012. {
  6013. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  6014. guild->InvitePlayer(client, sep->arg[1]);
  6015. else
  6016. {
  6017. Spawn* target = client->GetPlayer()->GetTarget();
  6018. if (target)
  6019. {
  6020. if (target->IsPlayer())
  6021. guild->InvitePlayer(client, target->GetName());
  6022. else
  6023. client->Message(CHANNEL_NARRATIVE, "%s is not a player.", target->GetName());
  6024. }
  6025. }
  6026. }
  6027. else if (strncmp(command, "accept", length) == 0)
  6028. {
  6029. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  6030. if (pgi && pgi->guild && pgi->invited_by)
  6031. pgi->guild->AddNewGuildMember(client, pgi->invited_by->GetName());
  6032. client->SetPendingGuildInvite(0);
  6033. }
  6034. else if (strncmp(command, "decline", length) == 0)
  6035. {
  6036. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  6037. if (pgi && pgi->guild && pgi->invited_by && pgi->invited_by->IsPlayer())
  6038. {
  6039. Client* client_inviter = ((Player*)pgi->invited_by)->GetClient();
  6040. if (client_inviter) {
  6041. client_inviter->Message(CHANNEL_NARRATIVE, "%s has declined your invitation to join %s.", client->GetPlayer()->GetName(), pgi->guild->GetName());
  6042. }
  6043. }
  6044. client->SetPendingGuildInvite(0);
  6045. }
  6046. else if (strncmp(command, "create", length) == 0 && sep->arg[1])
  6047. {
  6048. const char* guild_name = sep->argplus[1];
  6049. if (!guild_list.GetGuild(guild_name))
  6050. world.CreateGuild(guild_name, client, client->GetPlayer()->GetGroupMemberInfo() ? client->GetPlayer()->GetGroupMemberInfo()->group_id : 0);
  6051. else
  6052. client->SimpleMessage(CHANNEL_NARRATIVE, "A guild with that name already exists.");
  6053. }
  6054. else if (strncmp(command, "search", length) == 0)
  6055. client->ShowGuildSearchWindow();
  6056. else if (strncmp(command, "recruiting_details", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  6057. {
  6058. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  6059. if (to_guild)
  6060. to_guild->SendGuildRecruitingDetails(client);
  6061. }
  6062. else if (strncmp(command, "recruiting_image", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  6063. {
  6064. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  6065. if (to_guild)
  6066. to_guild->SendGuildRecruitingImages(client);
  6067. }
  6068. else if (strncmp(command, "recruiter_adventure_class", length) == 0)
  6069. {
  6070. if (sep->arg[1])
  6071. {
  6072. const char* option = sep->arg[1];
  6073. if (strncmp(option, "toggle", strlen(option)) == 0)
  6074. guild->ToggleGuildRecruiterAdventureClass(client);
  6075. }
  6076. else
  6077. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiter_adventure_class command: '%s'", sep->argplus[0]);
  6078. }
  6079. else if (strncmp(command, "display_heraldry", length) == 0)
  6080. {
  6081. // JA: not sure this is right...
  6082. client->GetPlayer()->toggle_character_flag(CF_SHOW_GUILD_HERALDRY);
  6083. client->GetPlayer()->SetCharSheetChanged(true);
  6084. }
  6085. else
  6086. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild command: '%s'", sep->argplus[0]);
  6087. }
  6088. }
  6089. /*
  6090. Function: Command_GuildCreate()
  6091. Purpose : Display's in-game Guild Creation window
  6092. Dev : Scatman
  6093. */
  6094. void Commands::Command_CreateGuild(Client* client)
  6095. {
  6096. client->SendGuildCreateWindow();
  6097. }
  6098. /*
  6099. Function: Command_SetGuildOfficerNote()
  6100. Purpose :
  6101. Dev : Scatman
  6102. */
  6103. void Commands::Command_SetGuildOfficerNote(Client* client, Seperator* sep)
  6104. {
  6105. if (sep && sep->arg[0] && sep->arg[1])
  6106. {
  6107. Guild* guild = client->GetPlayer()->GetGuild();
  6108. if (guild)
  6109. guild->SetGuildOfficerNote(sep->arg[0], sep->argplus[1]);
  6110. }
  6111. }
  6112. /*
  6113. Function: Command_SetGuildMemberNote()
  6114. Purpose :
  6115. Dev : Scatman
  6116. */
  6117. void Commands::Command_SetGuildMemberNote(Client* client, Seperator* sep)
  6118. {
  6119. if (sep && sep->arg[0] && sep->arg[1])
  6120. {
  6121. Guild* guild = client->GetPlayer()->GetGuild();
  6122. if (guild)
  6123. guild->SetGuildMemberNote(sep->arg[0], sep->argplus[1]);
  6124. }
  6125. }
  6126. /*
  6127. Function: Command_GuildSay()
  6128. Purpose :
  6129. Dev : Scatman
  6130. */
  6131. void Commands::Command_GuildSay(Client* client, Seperator* sep)
  6132. {
  6133. Guild* guild = client->GetPlayer()->GetGuild();
  6134. if (guild)
  6135. {
  6136. if (sep && sep->arg[0])
  6137. guild->HandleGuildSay(client, sep->argplus[0]);
  6138. }
  6139. else
  6140. client->SimpleMessage(CHANNEL_NARRATIVE, "You are not a member of a guild");
  6141. }
  6142. /*
  6143. Function: Command_OfficerSay()
  6144. Purpose :
  6145. Dev : Scatman
  6146. */
  6147. void Commands::Command_OfficerSay(Client* client, Seperator* sep)
  6148. {
  6149. Guild* guild = client->GetPlayer()->GetGuild();
  6150. if (guild)
  6151. {
  6152. if (sep && sep->arg[0])
  6153. guild->HandleOfficerSay(client, sep->argplus[0]);
  6154. }
  6155. else
  6156. client->SimpleMessage(CHANNEL_NARRATIVE, "You are not a member of a guild");
  6157. }
  6158. /*
  6159. Function: Command_Guilds()
  6160. Purpose : Shows help for /guild command
  6161. Params :
  6162. Dev : Scatman
  6163. Example :
  6164. */
  6165. void Commands::Command_Guilds(Client* client)
  6166. {
  6167. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds [create|delete|add|remove|list]");
  6168. }
  6169. /*
  6170. Function: Command_GuildsAdd()
  6171. Purpose : Add's players to a guild
  6172. Params : guild_name|guild_id, player name
  6173. Dev : Scatman
  6174. Example : /guilds add 1 Admin = adds player Admin to guild_id 1
  6175. */
  6176. void Commands::Command_GuildsAdd(Client* client, Seperator* sep)
  6177. {
  6178. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  6179. {
  6180. Guild* guild = 0;
  6181. bool found = true;
  6182. if (sep->IsNumber(0))
  6183. {
  6184. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  6185. if (!guild)
  6186. {
  6187. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  6188. found = false;
  6189. }
  6190. }
  6191. else
  6192. {
  6193. guild = guild_list.GetGuild(sep->arg[0]);
  6194. if (!guild)
  6195. {
  6196. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  6197. found = false;
  6198. }
  6199. }
  6200. if (found)
  6201. {
  6202. Client* to_client = 0;
  6203. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  6204. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  6205. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  6206. to_client = ((Player*)client->GetPlayer()->GetTarget())->GetClient();
  6207. if (to_client)
  6208. guild->InvitePlayer(client, to_client->GetPlayer()->GetName());
  6209. else
  6210. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  6211. }
  6212. }
  6213. else
  6214. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds add [guild name|guild id] (player name).");
  6215. }
  6216. /*
  6217. Function: Command_GuildsCreate()
  6218. Purpose : Creates a guild
  6219. Params : guild_name, player_name (optional)
  6220. Dev : Scatman
  6221. Example : /guilds create [guild name] (player name)
  6222. */
  6223. void Commands::Command_GuildsCreate(Client* client, Seperator* sep)
  6224. {
  6225. if (sep && sep->arg[0])
  6226. {
  6227. const char* guild_name = sep->arg[0];
  6228. if (!guild_list.GetGuild(guild_name))
  6229. {
  6230. bool ret = false;
  6231. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  6232. {
  6233. Client* to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  6234. if (to_client)
  6235. {
  6236. world.CreateGuild(guild_name, to_client);
  6237. ret = true;
  6238. }
  6239. else
  6240. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player with name '%s'", sep->arg[1]);
  6241. }
  6242. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  6243. {
  6244. Client* to_client = ((Player*)client->GetPlayer()->GetTarget())->GetClient();
  6245. if (to_client)
  6246. {
  6247. world.CreateGuild(guild_name, to_client);
  6248. ret = true;
  6249. }
  6250. }
  6251. else
  6252. {
  6253. world.CreateGuild(guild_name);
  6254. ret = true;
  6255. }
  6256. if (ret)
  6257. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully created.", guild_name);
  6258. else
  6259. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the guild.");
  6260. }
  6261. else
  6262. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' already exists.", guild_name);
  6263. }
  6264. else
  6265. 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.");
  6266. }
  6267. /*
  6268. Function: Command_GuildsDelete()
  6269. Purpose : Delete's a guild
  6270. Params : guild name
  6271. Dev : Scatman
  6272. Example : /guilds delete Test
  6273. */
  6274. void Commands::Command_GuildsDelete(Client* client, Seperator* sep)
  6275. {
  6276. if (sep && sep->arg[0])
  6277. {
  6278. Guild* guild = 0;
  6279. bool found = true;
  6280. if (sep->IsNumber(0))
  6281. {
  6282. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  6283. if (!guild)
  6284. {
  6285. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  6286. found = false;
  6287. }
  6288. }
  6289. else
  6290. {
  6291. guild = guild_list.GetGuild(sep->arg[0]);
  6292. if (!guild)
  6293. {
  6294. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  6295. found = false;
  6296. }
  6297. }
  6298. if (found)
  6299. {
  6300. guild->RemoveAllGuildMembers();
  6301. database.DeleteGuild(guild);
  6302. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully deleted.", guild->GetName());
  6303. guild_list.RemoveGuild(guild, true);
  6304. }
  6305. }
  6306. else
  6307. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds delete [guild name].");
  6308. }
  6309. /*
  6310. Function: Command_GuildsList()
  6311. Purpose : Lists current guilds on server
  6312. Params :
  6313. Dev : Scatman
  6314. Example : /guilds list
  6315. */
  6316. void Commands::Command_GuildsList(Client* client)
  6317. {
  6318. MutexMap<int32, Guild*>* guilds = guild_list.GetGuilds();
  6319. MutexMap<int32, Guild*>::iterator itr = guilds->begin();
  6320. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Guild List:");
  6321. if (guilds->size() == 0)
  6322. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "None.");
  6323. else {
  6324. while (itr.Next()) {
  6325. Guild* guild = itr.second;
  6326. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", guild->GetID(), guild->GetName());
  6327. }
  6328. }
  6329. }
  6330. /*
  6331. Function: Command_GuildsRemove()
  6332. Purpose : Removes a player from a guild
  6333. Params : guild name|guild id, player name
  6334. Dev : Scatman
  6335. Example : /guilds remove 1 Admin = removes Admin from guild 1
  6336. */
  6337. void Commands::Command_GuildsRemove(Client* client, Seperator* sep)
  6338. {
  6339. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  6340. {
  6341. Guild* guild = 0;
  6342. bool found = true;
  6343. if (sep->IsNumber(0))
  6344. {
  6345. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  6346. if (!guild)
  6347. {
  6348. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  6349. found = false;
  6350. }
  6351. }
  6352. else
  6353. {
  6354. guild = guild_list.GetGuild(sep->arg[0]);
  6355. if (!guild)
  6356. {
  6357. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  6358. found = false;
  6359. }
  6360. }
  6361. if (found)
  6362. {
  6363. Client* to_client = 0;
  6364. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  6365. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  6366. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  6367. to_client = ((Player*)client->GetPlayer()->GetTarget())->GetClient();
  6368. if (to_client)
  6369. {
  6370. Player* to_player = to_client->GetPlayer();
  6371. if (to_player->GetGuild())
  6372. {
  6373. if (to_player->GetGuild() == guild)
  6374. {
  6375. guild->KickGuildMember(client, to_player->GetName());
  6376. }
  6377. else
  6378. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in the guild '%s'.", to_player->GetName(), guild->GetName());
  6379. }
  6380. else
  6381. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in a guild.", to_player->GetName());
  6382. }
  6383. else
  6384. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  6385. }
  6386. }
  6387. else
  6388. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds remove [guild name|guild id] (player name).");
  6389. }
  6390. /*
  6391. Function: Command_InspectPlayer()
  6392. Purpose : Handle the Inspect functions
  6393. Params : Client to inspect
  6394. Dev : Scatman
  6395. Example : /inspect Scatman
  6396. */
  6397. void Commands::Command_InspectPlayer(Client* client, Seperator* sep)
  6398. {
  6399. if (sep && sep->arg[0])
  6400. {
  6401. Client* inspect_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  6402. if (inspect_client)
  6403. client->InspectPlayer(inspect_client->GetPlayer());
  6404. }
  6405. else
  6406. {
  6407. Spawn* target = client->GetPlayer()->GetTarget();
  6408. if (target && target->IsPlayer())
  6409. client->InspectPlayer((Player*)target);
  6410. }
  6411. }
  6412. /*
  6413. Function: Command_Inventory()
  6414. Purpose : Handle changes in player inventory
  6415. Params : <TBD>
  6416. Dev : All
  6417. Example : /inventory delete item_id
  6418. */
  6419. void Commands::Command_Inventory(Client* client, Seperator* sep, EQ2_RemoteCommandString* command)
  6420. {
  6421. PrintSep(sep, "Command_Inventory"); // temp to figure out the params
  6422. Player* player = client->GetPlayer();
  6423. if(sep && sep->arg[0][0])
  6424. {
  6425. LogWrite(COMMAND__INFO, 0, "Command", "command: %s", sep->argplus[0]);
  6426. if(!client->GetPlayer()->Alive())
  6427. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  6428. else if(sep->arg[1][0] && strncasecmp("destroy", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  6429. {
  6430. int16 index = atoi(sep->arg[1]);
  6431. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  6432. if(item)
  6433. {
  6434. if(item->details.item_locked) {
  6435. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot destroy the item in use.");
  6436. return;
  6437. }
  6438. else if(item->CheckFlag(NO_DESTROY)) {
  6439. client->SimpleMessage(CHANNEL_COLOR_RED, "You can't destroy this item.");
  6440. return;
  6441. }
  6442. if(item->GetItemScript() && lua_interface)
  6443. lua_interface->RunItemScript(item->GetItemScript(), "destroyed", item, client->GetPlayer());
  6444. //reobtain item make sure it wasn't removed
  6445. item = player->item_list.GetItemFromIndex(index);
  6446. int32 bag_id = 0;
  6447. if(item){
  6448. bag_id = item->details.inv_slot_id;
  6449. database.DeleteItem(client->GetCharacterID(), item, 0);
  6450. }
  6451. client->GetPlayer()->item_list.DestroyItem(index);
  6452. client->GetPlayer()->UpdateInventory(bag_id);
  6453. }
  6454. }
  6455. 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))
  6456. {
  6457. int16 from_index = atoi(sep->arg[1]);
  6458. sint16 to_slot = atoi(sep->arg[2]); // don't convert slot since this is inventory not equipment
  6459. sint32 bag_id = atol(sep->arg[3]);
  6460. int8 charges = atoi(sep->arg[4]);
  6461. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(from_index);
  6462. if(!item) {
  6463. client->SimpleMessage(CHANNEL_COLOR_RED, "You have no item.");
  6464. return;
  6465. }
  6466. if(to_slot == item->details.slot_id && (bag_id < 0 || bag_id == item->details.inv_slot_id)) {
  6467. return;
  6468. }
  6469. if(item->details.item_locked)
  6470. {
  6471. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot move the item in use.");
  6472. return;
  6473. }
  6474. if(bag_id == -4 && !client->GetPlayer()->item_list.SharedBankAddAllowed(item))
  6475. {
  6476. client->SimpleMessage(CHANNEL_COLOR_RED, "That item (or an item inside) cannot be shared.");
  6477. return;
  6478. }
  6479. sint32 old_inventory_id = 0;
  6480. if(item)
  6481. old_inventory_id = item->details.inv_slot_id;
  6482. //autobank
  6483. if (bag_id == -3 && to_slot == -1)
  6484. {
  6485. if (player->HasFreeBankSlot())
  6486. to_slot = player->FindFreeBankSlot();
  6487. else
  6488. {
  6489. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free bank slots.");
  6490. return;
  6491. }
  6492. }
  6493. //auto inventory
  6494. if (bag_id == 0 && to_slot == -1)
  6495. {
  6496. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  6497. {
  6498. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free slots.");
  6499. return;
  6500. }
  6501. }
  6502. bool item_deleted = false;
  6503. EQ2Packet* outapp = client->GetPlayer()->MoveInventoryItem(bag_id, from_index, (int8)to_slot, charges, 0, &item_deleted, client->GetVersion());
  6504. client->QueuePacket(outapp);
  6505. if(item_deleted)
  6506. item = nullptr;
  6507. //removed from bag send update
  6508. if(old_inventory_id > 0 && item && item->details.inv_slot_id != old_inventory_id)
  6509. {
  6510. outapp = client->GetPlayer()->SendBagUpdate(old_inventory_id, client->GetVersion());
  6511. if(outapp)
  6512. client->QueuePacket(outapp);
  6513. }
  6514. if(item && item->details.inv_slot_id > 0 && item->details.inv_slot_id != old_inventory_id)
  6515. {
  6516. outapp = client->GetPlayer()->SendBagUpdate(item->details.inv_slot_id, client->GetVersion());
  6517. if(outapp)
  6518. client->QueuePacket(outapp);
  6519. }
  6520. }
  6521. else if(sep->arg[1][0] && strncasecmp("equip", sep->arg[0], 5) == 0 && sep->IsNumber(1))
  6522. {
  6523. if(client->GetPlayer()->EngagedInCombat())
  6524. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not equip items while in combat.");
  6525. else
  6526. {
  6527. int16 index = atoi(sep->arg[1]);
  6528. int8 slot_id = 255;
  6529. int8 unk3 = 0;
  6530. int8 appearance_equip = 0;
  6531. if(sep->arg[2][0] && sep->IsNumber(2))
  6532. slot_id = player->ConvertSlotFromClient(atoi(sep->arg[2]), client->GetVersion());
  6533. if(sep->arg[3][0] && sep->IsNumber(3))
  6534. unk3 = atoul(sep->arg[3]);
  6535. if(sep->arg[4][0] && sep->IsNumber(4))
  6536. appearance_equip = atoul(sep->arg[4]);
  6537. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), appearance_equip, slot_id);
  6538. EQ2Packet* outapp = 0;
  6539. for(int32 i=0;i<packets.size();i++)
  6540. {
  6541. outapp = packets[i];
  6542. if(outapp)
  6543. client->QueuePacket(outapp);
  6544. }
  6545. client->GetPlayer()->UpdateWeapons();
  6546. EQ2Packet* characterSheetPackets = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion());
  6547. client->QueuePacket(characterSheetPackets);
  6548. }
  6549. }
  6550. else if (sep->arg[1][0] && strncasecmp("unpack", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  6551. {
  6552. if (client->GetPlayer()->EngagedInCombat())
  6553. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unpack items while in combat.");
  6554. else {
  6555. int16 index = atoi(sep->arg[1]);
  6556. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  6557. if (item) {
  6558. if(item->details.item_locked)
  6559. {
  6560. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot unpack the item in use.");
  6561. return;
  6562. }
  6563. // client->GetPlayer()->item_list.DestroyItem(index);
  6564. if (item->item_sets.size() > 0) {
  6565. for (int32 i = 0; i < item->item_sets.size(); i++) {
  6566. ItemSet* set = item->item_sets[i];
  6567. if (set->item_stack_size == 0)
  6568. set->item_stack_size += 1;
  6569. client->AddItem(set->item_id, set->item_stack_size);
  6570. }
  6571. }
  6572. }
  6573. client->RemoveItem(item, 1);
  6574. }
  6575. }
  6576. else if(sep->arg[1][0] && strncasecmp("unequip", sep->arg[0], 7) == 0 && sep->IsNumber(1))
  6577. {
  6578. if(client->GetPlayer()->EngagedInCombat())
  6579. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unequip items while in combat.");
  6580. else
  6581. {
  6582. int16 index = player->ConvertSlotFromClient(atoi(sep->arg[1]), client->GetVersion());
  6583. sint32 bag_id = -999;
  6584. int8 to_slot = 255;
  6585. if(sep->arg[3][0])
  6586. {
  6587. if(sep->IsNumber(2))
  6588. bag_id = atol(sep->arg[2]);
  6589. if(sep->IsNumber(3))
  6590. to_slot = atoi(sep->arg[3]);
  6591. }
  6592. sint8 unk4 = 0;
  6593. int8 appearance_equip = 0;
  6594. if(sep->arg[4][0] && sep->IsNumber(4))
  6595. unk4 = atoi(sep->arg[4]);
  6596. if(sep->arg[5][0] && sep->IsNumber(5))
  6597. appearance_equip = atoul(sep->arg[5]);
  6598. vector<EQ2Packet*> packets = client->GetPlayer()->UnequipItem(index, bag_id, to_slot, client->GetVersion(), appearance_equip);
  6599. EQ2Packet* outapp = 0;
  6600. for(int32 i=0;i<packets.size();i++)
  6601. {
  6602. outapp = packets[i];
  6603. if(outapp)
  6604. client->QueuePacket(outapp);
  6605. }
  6606. client->UnequipItem(index, bag_id, to_slot, appearance_equip);
  6607. }
  6608. }
  6609. else if(sep->arg[2][0] && strncasecmp("swap_equip", sep->arg[0], 10) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  6610. {
  6611. if(client->GetPlayer()->EngagedInCombat()) {
  6612. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not swap items while in combat.");
  6613. }
  6614. else {
  6615. int16 index1 = client->GetPlayer()->ConvertSlotFromClient(atoi(sep->arg[1]), client->GetVersion());
  6616. int16 index2 = client->GetPlayer()->ConvertSlotFromClient(atoi(sep->arg[2]), client->GetVersion());
  6617. int8 type = 0;
  6618. if(sep->IsNumber(3))
  6619. type = atoul(sep->arg[3]); // type 0 is combat, 3 = appearance
  6620. EQ2Packet* outapp = client->GetPlayer()->SwapEquippedItems(index1, index2, client->GetVersion(), type);
  6621. if(outapp)
  6622. client->QueuePacket(outapp);
  6623. else
  6624. {
  6625. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to swap items");
  6626. return;
  6627. }
  6628. }
  6629. }
  6630. else if (sep->arg[2][0] && strncasecmp("pop", sep->arg[0], 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  6631. {
  6632. sint16 to_slot = atoi(sep->arg[1]);
  6633. sint32 bag_id = atoi(sep->arg[2]);
  6634. Item* item = client->GetPlayer()->item_list.GetOverflowItem();
  6635. if (item) {
  6636. //auto inventory
  6637. if (bag_id == 0 && to_slot == -1)
  6638. {
  6639. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  6640. {
  6641. client->SimpleMessage(CHANNEL_ERROR, "You do not have any free slots.");
  6642. return;
  6643. }
  6644. // Set the slot for the item
  6645. item->details.inv_slot_id = bag_id;
  6646. item->details.slot_id = to_slot;
  6647. // Flag the item so it gets saved in its new location
  6648. item->save_needed = true;
  6649. // Add the item to its new location
  6650. if(player->item_list.AddItem(item)) {
  6651. // Remove the item from the overflow list
  6652. player->item_list.RemoveOverflowItem(item);
  6653. }
  6654. // Send the inventory update packet
  6655. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  6656. return;
  6657. }
  6658. else if (bag_id == -3 && to_slot == -1) {
  6659. // Auto Bank
  6660. if (!player->item_list.GetFirstFreeBankSlot(&bag_id, &to_slot)) {
  6661. client->SimpleMessage(CHANNEL_STATUS, "You do not have any free bank slots.");
  6662. return;
  6663. }
  6664. item->details.inv_slot_id = bag_id;
  6665. item->details.slot_id = to_slot;
  6666. item->save_needed = true;
  6667. if(player->item_list.AddItem(item)) {
  6668. player->item_list.RemoveOverflowItem(item);
  6669. }
  6670. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  6671. }
  6672. else if (bag_id == -4) {
  6673. // Shared Bank
  6674. if (!player->item_list.SharedBankAddAllowed(item)) {
  6675. client->SimpleMessage(CHANNEL_STATUS, "That item (or an item inside) cannot be shared.");
  6676. return;
  6677. }
  6678. Item* tmp_item = player->item_list.GetItem(-4, to_slot);
  6679. if (tmp_item) {
  6680. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  6681. return;
  6682. }
  6683. else {
  6684. item->details.inv_slot_id = bag_id;
  6685. item->details.slot_id = to_slot;
  6686. item->save_needed = true;
  6687. if(player->item_list.AddItem(item)) {
  6688. player->item_list.RemoveOverflowItem(item);
  6689. }
  6690. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  6691. return;
  6692. }
  6693. }
  6694. else {
  6695. // Try to get an item from the given bag id and slot id
  6696. Item* tmp_item = player->item_list.GetItem(bag_id, to_slot);
  6697. // Check to see if we got an item, if we do send an error,
  6698. // if we don't put the overflow item into this slot
  6699. if (tmp_item) {
  6700. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  6701. }
  6702. else {
  6703. item->details.inv_slot_id = bag_id;
  6704. item->details.slot_id = to_slot;
  6705. item->save_needed = true;
  6706. if(player->item_list.AddItem(item)) {
  6707. player->item_list.RemoveOverflowItem(item);
  6708. }
  6709. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  6710. return;
  6711. }
  6712. }
  6713. }
  6714. }
  6715. else if(sep->arg[2][0] && strncasecmp("nosale", sep->arg[0], 6) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  6716. {
  6717. sint64 data = strtoull(sep->arg[1], NULL, 0);
  6718. int32 character_item_id = (int32) (data >> 32);
  6719. int32 item_id = (int32) (data & 0xffffffffL);
  6720. int8 sale_setting = atoi(sep->arg[2]);
  6721. Item* item = client->GetPlayer()->item_list.GetItemFromUniqueID(character_item_id);
  6722. if(item)
  6723. {
  6724. item->no_sale = sale_setting;
  6725. item->save_needed = true;
  6726. client->SendSellMerchantList();
  6727. }
  6728. }
  6729. }
  6730. else
  6731. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /inventory {destroy|move|equip|unequip|swap_equip|pop} {item_id} [to_slot] [bag_id]");
  6732. }
  6733. /*
  6734. Function: Command_Languages()
  6735. Purpose : Show's languages the player knows
  6736. Params :
  6737. Dev : Zcoretri
  6738. Example :
  6739. */
  6740. void Commands::Command_Languages(Client* client, Seperator* sep)
  6741. {
  6742. list<Language*>* languages = client->GetPlayer()->GetPlayerLanguages()->GetAllLanguages();
  6743. list<Language*>::iterator itr;
  6744. Language* language;
  6745. client->Message(CHANNEL_NARRATIVE, "You know the following languages:");
  6746. for(itr = languages->begin(); itr != languages->end(); itr++)
  6747. {
  6748. language = *itr;
  6749. client->Message(CHANNEL_NARRATIVE, "%s", language->GetName());
  6750. }
  6751. }
  6752. /*
  6753. Function: Command_SetLanguage()
  6754. Purpose : Handles language commands
  6755. Params : Language ID
  6756. Dev : Zcoretri
  6757. Example :
  6758. */
  6759. void Commands::Command_SetLanguage(Client* client, Seperator* sep)
  6760. {
  6761. Player* player = client->GetPlayer();
  6762. if (sep && sep->arg[0])
  6763. {
  6764. if(!sep->IsNumber(0))
  6765. {
  6766. //String passed in
  6767. const char* value = sep->arg[0];
  6768. if(strncasecmp(value, "Common", strlen(value)) == 0)
  6769. {
  6770. database.SaveCharacterCurrentLang(0, client->GetCharacterID(), client);
  6771. client->SendLanguagesUpdate(0);
  6772. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", value);
  6773. }
  6774. else
  6775. {
  6776. if(player->HasLanguage(value))
  6777. {
  6778. Language* language = player->GetPlayerLanguages()->GetLanguageByName(value);
  6779. database.SaveCharacterCurrentLang(language->GetID(), client->GetCharacterID(), client);
  6780. client->SendLanguagesUpdate(language->GetID());
  6781. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", language->GetName());
  6782. }
  6783. else
  6784. client->Message(CHANNEL_NARRATIVE, "You do not know how to speak %s", value);
  6785. }
  6786. }
  6787. else
  6788. {
  6789. //Number passed in
  6790. int32 id = atoul(sep->arg[0]);
  6791. if(player->HasLanguage(id))
  6792. {
  6793. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  6794. database.SaveCharacterCurrentLang(id, client->GetCharacterID(), client);
  6795. client->SendLanguagesUpdate(id);
  6796. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", language->GetName());
  6797. }
  6798. else
  6799. {
  6800. Language* language = master_languages_list.GetLanguage(id);
  6801. if(language)
  6802. client->Message(CHANNEL_NARRATIVE, "You do not know how to speak %s", language->GetName());
  6803. }
  6804. }
  6805. }
  6806. else
  6807. {
  6808. //No value was passed in
  6809. int32 id = database.GetCharacterCurrentLang(client->GetCharacterID(), player);
  6810. if(id > 0)
  6811. {
  6812. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  6813. client->Message(CHANNEL_NARRATIVE, "You are currently speaking %s ", language->GetName());
  6814. }
  6815. else
  6816. client->Message(CHANNEL_NARRATIVE, "You are currently speaking Common");
  6817. }
  6818. }
  6819. /*
  6820. Function: Command_LastName()
  6821. Purpose : Sets player surname
  6822. Params : Name text
  6823. Dev : theFoof
  6824. Example :
  6825. */
  6826. void Commands::Command_LastName(Client* client, Seperator* sep)
  6827. {
  6828. if (!client)
  6829. return;
  6830. if (sep && sep->arg[0])
  6831. {
  6832. if (!client->GetPlayer()->get_character_flag(CF_ENABLE_CHANGE_LASTNAME)){
  6833. client->Message(CHANNEL_COLOR_YELLOW, "You must be atleast level %i to change your last name.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  6834. return;
  6835. }
  6836. client->RemovePendingLastName();
  6837. uchar* checkname = (uchar*)sep->arg[0];
  6838. bool valid_name = true;
  6839. for (int32 i = 0; i < strlen(sep->arg[0]); i++) {
  6840. if (!alpha_check(checkname[i])) {
  6841. valid_name = false;
  6842. break;
  6843. }
  6844. }
  6845. if (!valid_name) {
  6846. client->Message(CHANNEL_COLOR_YELLOW, "Your last name can only contain letters.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  6847. return;
  6848. }
  6849. string last_name = (string)sep->arg[0];
  6850. int8 max_length = rule_manager.GetGlobalRule(R_Player, MaxLastNameLength)->GetInt8();
  6851. int8 min_length = rule_manager.GetGlobalRule(R_Player, MinLastNameLength)->GetInt8();
  6852. if (last_name.length() <= max_length && last_name.length() >= min_length){
  6853. client->SetPendingLastName(last_name);
  6854. client->SendLastNameConfirmation();
  6855. }
  6856. else
  6857. client->Message(CHANNEL_COLOR_YELLOW, "Your last name must be between %i and %i characters long.", min_length, max_length);
  6858. }
  6859. }
  6860. /*
  6861. Function: Command_ConfirmLastName()
  6862. Purpose : Confirms setting of player surname
  6863. Params : Name text
  6864. Dev : theFoof
  6865. Example :
  6866. */
  6867. void Commands::Command_ConfirmLastName(Client* client, Seperator* sep)
  6868. {
  6869. if (!client)
  6870. return;
  6871. string* name = client->GetPendingLastName();
  6872. if (name){
  6873. Player* player = client->GetPlayer();
  6874. player->SetLastName(name->c_str(), false);
  6875. client->SendTitleUpdate();
  6876. player->SetCharSheetChanged(true);
  6877. client->RemovePendingLastName();
  6878. }
  6879. }
  6880. /*
  6881. Function: Command_Location()
  6882. Purpose : Display's Help for /location commands
  6883. Params :
  6884. Dev : Scatman
  6885. Example : /location = show's help for command
  6886. */
  6887. void Commands::Command_Location(Client* client)
  6888. {
  6889. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Valid /location commands are:");
  6890. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location create [name] (include y). Include y defaults to false");
  6891. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location add [location id]");
  6892. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location remove [location point id]");
  6893. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location delete [location id]");
  6894. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location list [locations|points] [location id if points used]");
  6895. }
  6896. /*
  6897. Function: Command_LocationAdd()
  6898. Purpose : Add's a location to an existing location config
  6899. Params : location_id
  6900. Dev : Scatman
  6901. Example : /location add {location_id}
  6902. */
  6903. void Commands::Command_LocationAdd(Client* client, Seperator* sep)
  6904. {
  6905. if (sep && sep->arg[0] && sep->IsNumber(0))
  6906. {
  6907. int32 location_id = atoul(sep->arg[0]);
  6908. float x = client->GetPlayer()->GetX();
  6909. float y = client->GetPlayer()->GetY();
  6910. float z = client->GetPlayer()->GetZ();
  6911. if (database.AddLocationPoint(location_id, x, y, z))
  6912. client->Message(CHANNEL_COLOR_YELLOW, "Point (%f, %f, %f) was successfully added to location %u", x, y, z, location_id);
  6913. else
  6914. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist. Use /location create to create one", location_id);
  6915. }
  6916. else
  6917. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location add [location id]");
  6918. }
  6919. /*
  6920. Function: Command_LocationCreate()
  6921. Purpose : Creates a new location config
  6922. Params : location name, 0/1 for include_y (optional)
  6923. Dev : Scatman
  6924. Example : /location create Test 1 = creates a new location named Test with include_y True
  6925. */
  6926. void Commands::Command_LocationCreate(Client* client, Seperator* sep)
  6927. {
  6928. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  6929. {
  6930. const char* name = sep->arg[0];
  6931. bool include_y = false;
  6932. if (sep->arg[1] && sep->IsNumber(1) && atoi(sep->arg[1]) > 0)
  6933. include_y = true;
  6934. int32 location_id = database.CreateLocation(client->GetPlayer()->GetZone()->GetZoneID(), client->GetPlayer()->GetLocation(), name, include_y);
  6935. if (location_id > 0)
  6936. client->Message(CHANNEL_COLOR_YELLOW, "Location '%s' was successfully created with location id %u", name, location_id);
  6937. else
  6938. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the requested location");
  6939. }
  6940. else
  6941. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location create [name] (include_y). Include y defaults to false");
  6942. }
  6943. /*
  6944. Function: Command_LocationDelete()
  6945. Purpose : Delete's a location config and all it's location points
  6946. Params : location_id
  6947. Dev : Scatman
  6948. Example : /location delete {location_id}
  6949. */
  6950. void Commands::Command_LocationDelete(Client* client, Seperator* sep)
  6951. {
  6952. if (sep && sep->arg[0] && sep->IsNumber(0))
  6953. {
  6954. int32 location_id = atoul(sep->arg[0]);
  6955. if (database.DeleteLocation(location_id))
  6956. client->Message(CHANNEL_COLOR_YELLOW, "Location id %u and all its points were successfully deleted", location_id);
  6957. else
  6958. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist", location_id);
  6959. }
  6960. else
  6961. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location delete [location id]");
  6962. }
  6963. /*
  6964. Function: Command_LocationList()
  6965. Purpose : Display's a list of location points
  6966. Params : location_id
  6967. Dev : Scatman
  6968. Example : /location list {location_id}
  6969. */
  6970. void Commands::Command_LocationList(Client* client, Seperator* sep)
  6971. {
  6972. if (sep && sep->arg[0])
  6973. {
  6974. const char* option = sep->arg[0];
  6975. if (strncmp(option, "locations", strlen(option)) == 0)
  6976. database.ListLocations(client);
  6977. else if (strncmp(option, "points", strlen(option)) == 0 && sep->arg[1] && sep->IsNumber(1))
  6978. {
  6979. int32 location_id = atoul(sep->arg[1]);
  6980. database.ListLocationPoints(client, location_id);
  6981. }
  6982. else
  6983. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  6984. }
  6985. else
  6986. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  6987. }
  6988. /*
  6989. Function: Command_LocationRemove()
  6990. Purpose : Removes a single location point from a location config
  6991. Params : location_point_id (gotten from /location list {id})
  6992. Dev : Scatman
  6993. Example : /location remove 1 = will remove location_point_id 1
  6994. */
  6995. void Commands::Command_LocationRemove(Client* client, Seperator* sep)
  6996. {
  6997. if (sep && sep->arg[0] && sep->IsNumber(0))
  6998. {
  6999. int32 location_point_id = atoul(sep->arg[0]);
  7000. if (database.DeleteLocationPoint(location_point_id))
  7001. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Location point was successfully deleted");
  7002. else
  7003. client->Message(CHANNEL_COLOR_YELLOW, "Location point with ID %u does not exist", location_point_id);
  7004. }
  7005. else
  7006. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location remove [location point id]");
  7007. }
  7008. /*
  7009. Function: Command_Merchant()
  7010. Purpose : Handles Merchant commands
  7011. Params : list
  7012. Dev : Scatman
  7013. Example : /merchant list
  7014. */
  7015. void Commands::Command_Merchant(Client* client, Seperator* sep, int handler)
  7016. {
  7017. if( handler == COMMAND_MERCHANT )
  7018. {
  7019. // /merchant command by itself shows help (to be extended)
  7020. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  7021. return;
  7022. }
  7023. else if( handler == COMMAND_MERCHANT_LIST )
  7024. {
  7025. // /merchant list command expects "description" param
  7026. if (sep && sep->arg[0])
  7027. {
  7028. const char* merchant_description = sep->argplus[0];
  7029. client->Message(CHANNEL_COLOR_YELLOW, "Listing merchants like '%s':", merchant_description);
  7030. map<int32, MerchantInfo*>* merchant_info = world.GetMerchantInfo();
  7031. map<int32, MerchantInfo*>::iterator itr;
  7032. for (itr = merchant_info->begin(); itr != merchant_info->end(); itr++)
  7033. {
  7034. string description = database.GetMerchantDescription(itr->first);
  7035. if (ToLower(description).find(ToLower(string(merchant_description))) < 0xFFFFFFFF)
  7036. client->Message(CHANNEL_COLOR_YELLOW, "Merchant ID: %u, Description: %s", itr->first, description.c_str());
  7037. }
  7038. }
  7039. else // no description
  7040. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  7041. }
  7042. }
  7043. /*
  7044. Function: Command_Modify()
  7045. Purpose : to replace our other "set" commands
  7046. Params : System = the system to modify, Action = the action to perform, Target = what to change (target, or index)
  7047. Dev : John Adams
  7048. Example : /modify spell set name "Aegolism III"
  7049. */
  7050. void Commands::Command_Modify(Client* client)
  7051. {
  7052. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /modify [system] [action] [field] [value] {target|id}");
  7053. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Systems: character, faction, guild, item, skill, spawn, spell, zone");
  7054. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Actions: set, create, delete, add, remove");
  7055. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Value : field name in the table being modified");
  7056. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target : modify current target, or specified {system} ID");
  7057. }
  7058. /*
  7059. Function: Command_ModifySpawn()
  7060. Purpose : replace "spawn set" commands
  7061. Params : Action : the action to perform (or special handler)
  7062. : Field : the DB field to change
  7063. : Value : what to set the value to
  7064. : Target : what object to change (my target, or spawn_id)
  7065. Dev : John Adams
  7066. Example : /modify spawn set name "Lady Vox"
  7067. :
  7068. Note : Special Handlers, like "zoneto" for Signs
  7069. : /modify spawn zoneto
  7070. : Will set a sign's zone x/y/z to my current coords
  7071. */
  7072. void Commands::Command_ModifySpawn(Client* client, Seperator* sep)
  7073. {
  7074. PrintSep(sep, "COMMAND_MODIFY");
  7075. // need at least 2 args for a valid command
  7076. if( sep && sep->arg[1] )
  7077. {
  7078. // JA: just a quick implementation because I need it :)
  7079. if (strcmp(sep->arg[0], "zoneto") == 0)
  7080. {
  7081. if( sep->IsNumber(1) )
  7082. {
  7083. int32 spawn_id = atoul(sep->arg[1]);
  7084. float x_coord = client->GetPlayer()->GetX();
  7085. float y_coord = client->GetPlayer()->GetY();
  7086. float z_coord = client->GetPlayer()->GetZ();
  7087. float h_coord = client->GetPlayer()->GetHeading();
  7088. database.SaveSignZoneToCoords(spawn_id, x_coord, y_coord, z_coord, h_coord);
  7089. }
  7090. else
  7091. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify spawn zoneto spawn_id - sets spawn_id to your coords");
  7092. }
  7093. }
  7094. else
  7095. Command_Modify(client);
  7096. }
  7097. /*
  7098. Function: Command_ModifyCharacter()
  7099. Purpose : to replace our other "set" commands
  7100. Params : Action : Add, Remove
  7101. : Field : copper, silver, gold, plat
  7102. : Value : min 1, max unlimited
  7103. : Target : Self, Player
  7104. Dev : Cynnar
  7105. Example : /modify character add gold 50
  7106. : /modify character remove silver 25
  7107. */
  7108. void Commands::Command_ModifyCharacter(Client* client, Seperator* sep)
  7109. {
  7110. PrintSep(sep, "COMMAND_MODIFY");
  7111. int64 value = 0;
  7112. Player* player = client->GetPlayer();
  7113. Client* targetClient = client;
  7114. if (player->HasTarget() && player->GetTarget()->IsPlayer()) {
  7115. player = (Player*)player->GetTarget();
  7116. targetClient = player->GetClient();
  7117. }
  7118. // need at least 2 args for a valid command
  7119. if( sep && sep->arg[1] )
  7120. {
  7121. if (strcmp(sep->arg[0], "add") == 0)
  7122. {
  7123. if (strcmp(sep->arg[1], "copper") == 0)
  7124. {
  7125. value = atoi64(sep->arg[2]);
  7126. player->AddCoins(value);
  7127. if (client->GetPlayer() == player)
  7128. {
  7129. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu copper coin%s", value, (value > 1 ? "s" : ""));
  7130. }
  7131. else {
  7132. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu copper coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  7133. if(targetClient) {
  7134. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu copper coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  7135. }
  7136. }
  7137. }
  7138. else if (strcmp(sep->arg[1], "silver") == 0)
  7139. {
  7140. value = atoi64(sep->arg[2]) * 100;
  7141. player->AddCoins(value);
  7142. if (client->GetPlayer() == player)
  7143. {
  7144. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu silver coin%s", value / 100, (value > 1 ? "s" : ""));
  7145. }
  7146. else {
  7147. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu silver coin%s", player->GetName(), value / 100, (value > 1 ? "s" : ""));
  7148. if(targetClient) {
  7149. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu silver coin%s", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  7150. }
  7151. }
  7152. }
  7153. else if (strcmp(sep->arg[1], "gold") == 0)
  7154. {
  7155. value = atoi64(sep->arg[2]) * 10000;
  7156. player->AddCoins(value);
  7157. if (client->GetPlayer() == player)
  7158. {
  7159. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu gold coin%s", value / 10000, (value > 1 ? "s" : ""));
  7160. }
  7161. else {
  7162. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu gold coin%s", player->GetName(), value / 10000, (value > 1 ? "s" : ""));
  7163. if(targetClient) {
  7164. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu gold coin%s", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  7165. }
  7166. }
  7167. }
  7168. else if (strcmp(sep->arg[1], "plat") == 0)
  7169. {
  7170. value = atoi64(sep->arg[2]) * 1000000;
  7171. player->AddCoins(value);
  7172. if (client->GetPlayer() == player)
  7173. {
  7174. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu platinum coin%s", value / 1000000, (value > 1 ? "s" : ""));
  7175. }
  7176. else {
  7177. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu platinum coin%s", player->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  7178. if(targetClient) {
  7179. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu platinum coin%s", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  7180. }
  7181. }
  7182. }
  7183. else
  7184. {
  7185. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  7186. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  7187. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  7188. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character add copper 20");
  7189. }
  7190. }
  7191. else if (strcmp(sep->arg[0], "remove") == 0)
  7192. {
  7193. if (strcmp(sep->arg[1], "copper") == 0)
  7194. {
  7195. value = atoi64(sep->arg[2]);
  7196. player->RemoveCoins(value);
  7197. if (client->GetPlayer() == player)
  7198. {
  7199. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from yourself", value, (value > 1 ? "s" : ""));
  7200. }
  7201. else {
  7202. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from %s", value, (value > 1 ? "s" : ""), player->GetName());
  7203. if(targetClient) {
  7204. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu copper coin%s from you", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  7205. }
  7206. }
  7207. }
  7208. else if (strcmp(sep->arg[1], "silver") == 0)
  7209. {
  7210. value = atoi64(sep->arg[2]) * 100;
  7211. player->RemoveCoins(value);
  7212. if (client->GetPlayer() == player)
  7213. {
  7214. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from yourself", value / 100, (value > 1 ? "s" : ""));
  7215. }
  7216. else {
  7217. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from %s", value / 100, (value > 1 ? "s" : ""), player->GetName());
  7218. if(targetClient) {
  7219. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu silver coin%s from you", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  7220. }
  7221. }
  7222. }
  7223. else if (strcmp(sep->arg[1], "gold") == 0)
  7224. {
  7225. value = atoi64(sep->arg[2]) * 10000;
  7226. player->RemoveCoins(value);
  7227. if (client->GetPlayer() == player)
  7228. {
  7229. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from yourself", value / 10000, (value > 1 ? "s" : ""));
  7230. }
  7231. else {
  7232. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from %s", value / 10000, (value > 1 ? "s" : ""), player->GetName());
  7233. if(targetClient) {
  7234. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu gold coin%s from you", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  7235. }
  7236. }
  7237. }
  7238. else if (strcmp(sep->arg[1], "plat") == 0)
  7239. {
  7240. value = atoi64(sep->arg[2]) * 1000000;
  7241. player->RemoveCoins(value);
  7242. if (client->GetPlayer() == player)
  7243. {
  7244. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from yourself", value / 1000000, (value > 1 ? "s" : ""));
  7245. }
  7246. else {
  7247. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from %s", value / 1000000, (value > 1 ? "s" : ""), player->GetName());
  7248. if(targetClient) {
  7249. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu platinum coin%s from you", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  7250. }
  7251. }
  7252. }
  7253. else
  7254. {
  7255. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  7256. }
  7257. }
  7258. else if (strcmp(sep->arg[0], "set") == 0) {
  7259. if (strcmp(sep->arg[1], "tslevel") == 0) {
  7260. int8 level = atoi(sep->arg[2]);
  7261. if (level > 0 && level < 256) {
  7262. if (player) {
  7263. if (client->GetPlayer() == player)
  7264. client->ChangeTSLevel(player->GetTSLevel(), level);
  7265. else if(targetClient)
  7266. targetClient->ChangeTSLevel(player->GetTSLevel(), level);
  7267. }
  7268. }
  7269. else
  7270. client->SimpleMessage(CHANNEL_ERROR, "Level must be between 1 - 255");
  7271. }
  7272. else if (strcmp(sep->arg[1], "tsclass") == 0) {
  7273. int8 tsclass = atoi(sep->arg[2]);
  7274. player->SetTradeskillClass(tsclass);
  7275. player->GetInfoStruct()->set_tradeskill_class1(classes.GetTSBaseClass(player->GetTradeskillClass()));
  7276. player->GetInfoStruct()->set_tradeskill_class2(classes.GetSecondaryTSBaseClass(player->GetTradeskillClass()));
  7277. player->GetInfoStruct()->set_tradeskill_class3(player->GetTradeskillClass());
  7278. player->SetCharSheetChanged(true);
  7279. }
  7280. else if (strcmp(sep->arg[1], "gender") == 0) {
  7281. int8 gender = atoi(sep->arg[2]);
  7282. client->GetPlayer()->GetInfoStruct()->set_gender(gender);
  7283. client->GetPlayer()->SetCharSheetChanged(true);
  7284. client->UpdateTimeStampFlag ( GENDER_UPDATE_FLAG );
  7285. }
  7286. }
  7287. }
  7288. else
  7289. {
  7290. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  7291. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  7292. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  7293. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  7294. }
  7295. }
  7296. void Commands::Command_ModifyFaction(Client* client, Seperator* sep)
  7297. {
  7298. PrintSep(sep, "COMMAND_MODIFY");
  7299. // need at least 2 args for a valid command
  7300. if( sep && sep->arg[1] )
  7301. {
  7302. }
  7303. else
  7304. Command_Modify(client);
  7305. }
  7306. void Commands::Command_ModifyGuild(Client* client, Seperator* sep)
  7307. {
  7308. PrintSep(sep, "COMMAND_MODIFY");
  7309. // need at least 2 args for a valid command
  7310. if( sep && sep->arg[1] )
  7311. {
  7312. }
  7313. else
  7314. Command_Modify(client);
  7315. }
  7316. void Commands::Command_ModifyItem(Client* client, Seperator* sep)
  7317. {
  7318. PrintSep(sep, "COMMAND_MODIFY");
  7319. // need at least 2 args for a valid command
  7320. if( sep && sep->arg[1] )
  7321. {
  7322. }
  7323. else
  7324. Command_Modify(client);
  7325. }
  7326. /*
  7327. Function: Command_ModifyQuest()
  7328. Purpose : to list players quest and completed quests
  7329. Params : Action : list, completed
  7330. : Target : Self, Player
  7331. Dev : Cynnar
  7332. Example : /modify quest list
  7333. : /modify quest completed
  7334. */
  7335. void Commands::Command_ModifyQuest(Client* client, Seperator* sep)
  7336. {
  7337. PrintSep(sep, "COMMAND_MODIFY");
  7338. int64 value = 0;
  7339. Player* player = client->GetPlayer();
  7340. Client* targetClient = client;
  7341. if (player->HasTarget() && player->GetTarget()->IsPlayer()) {
  7342. player = (Player*)player->GetTarget();
  7343. targetClient = player->GetClient();
  7344. }
  7345. // need at least 2 args for a valid command
  7346. if (sep && sep->arg[1])
  7347. {
  7348. if (strcmp(sep->arg[0], "list") == 0)
  7349. {
  7350. map<int32, Quest*>* quests = player->GetPlayerQuests();
  7351. map<int32, Quest*>::iterator itr;
  7352. client->Message(CHANNEL_COLOR_YELLOW, "%s's Quest List:.", client->GetPlayer()->GetName());
  7353. if (quests->size() == 0)
  7354. client->Message(CHANNEL_COLOR_YELLOW, "%s has no quests.", client->GetPlayer()->GetName());
  7355. else
  7356. {
  7357. for (itr = quests->begin(); itr != quests->end(); itr++)
  7358. {
  7359. Quest* quest = itr->second;
  7360. if(quest) {
  7361. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  7362. }
  7363. }
  7364. }
  7365. }
  7366. else if (strcmp(sep->arg[0], "completed") == 0)
  7367. {
  7368. map<int32, Quest*>* quests = player->GetCompletedPlayerQuests();
  7369. map<int32, Quest*>::iterator itr;
  7370. client->Message(CHANNEL_COLOR_YELLOW, "%s's Completed Quest List:.", client->GetPlayer()->GetName());
  7371. if (quests->size() == 0)
  7372. client->Message(CHANNEL_COLOR_YELLOW, "%s has no completed quests.", client->GetPlayer()->GetName());
  7373. else
  7374. {
  7375. for (itr = quests->begin(); itr != quests->end(); itr++)
  7376. {
  7377. Quest* quest = itr->second;
  7378. if(quest) {
  7379. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  7380. }
  7381. }
  7382. }
  7383. }
  7384. // Add in a progress step, and a LogWrite() for tracking GM Commands.
  7385. // LogWrite(LUA__DEBUG, 0, "LUA", "Quest: %s, function: %s", quest->GetName(), function);
  7386. else if (strcmp(sep->arg[0], "remove") == 0)
  7387. {
  7388. int32 quest_id = 0;
  7389. if (sep && sep->arg[1] && sep->IsNumber(1))
  7390. quest_id = atoul(sep->arg[1]);
  7391. if (quest_id > 0)
  7392. {
  7393. if (lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0)
  7394. {
  7395. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  7396. if (quest)
  7397. if (client->GetPlayer() == player)
  7398. {
  7399. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been removed from your journal", quest->GetName());
  7400. }
  7401. else
  7402. {
  7403. client->Message(CHANNEL_COLOR_YELLOW, "You have removed the quest %s from %s's journal", quest->GetName(), player->GetName());
  7404. if(targetClient) {
  7405. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s has removed the quest %s from your journal", client->GetPlayer()->GetName(), quest->GetName());
  7406. }
  7407. }
  7408. LogWrite(COMMAND__INFO, 0, "GM Command", "%s removed the quest %s from %s", client->GetPlayer()->GetName(), quest->GetName(), player->GetName());
  7409. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  7410. }
  7411. client->RemovePlayerQuest(quest_id);
  7412. client->GetCurrentZone()->SendQuestUpdates(client);
  7413. }
  7414. }
  7415. else if (strcmp(sep->arg[0], "advance") == 0)
  7416. {
  7417. int32 quest_id = 0;
  7418. int32 step = 0;
  7419. if (sep && sep->arg[1] && sep->IsNumber(1))
  7420. {
  7421. quest_id = atoul(sep->arg[1]);
  7422. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  7423. if(!quest) {
  7424. client->Message(CHANNEL_COLOR_RED, "Quest not found!");
  7425. return;
  7426. }
  7427. if (sep && sep->arg[2] && sep->IsNumber(1))
  7428. {
  7429. step = atoul(sep->arg[2]);
  7430. if (quest_id > 0 && step > 0)
  7431. {
  7432. if (player && player->IsPlayer() && quest_id > 0 && step > 0 && (player->player_quests.count(quest_id) > 0))
  7433. {
  7434. if (client)
  7435. {
  7436. client->AddPendingQuestUpdate(quest_id, step);
  7437. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been advanced one step.", quest->GetName());
  7438. LogWrite(COMMAND__INFO, 0, "GM Command", "%s advanced the quest %s one step", client->GetPlayer()->GetName(), quest->GetName());
  7439. }
  7440. }
  7441. }
  7442. else
  7443. {
  7444. client->Message(CHANNEL_COLOR_RED, "Quest ID and Step Number must be greater than 0!");
  7445. }
  7446. }
  7447. else
  7448. {
  7449. client->Message(CHANNEL_COLOR_RED, "Step Number must be a number!");
  7450. }
  7451. }
  7452. else
  7453. {
  7454. client->Message(CHANNEL_COLOR_RED, "Quest ID must be a number!");
  7455. }
  7456. }
  7457. else
  7458. {
  7459. Command_Modify(client);
  7460. }
  7461. }
  7462. else
  7463. {
  7464. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify quest [action] [quest id] [step number]");
  7465. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: list, completed, remove, advance");
  7466. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest list");
  7467. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest remove 156");
  7468. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest advance 50 1");
  7469. }
  7470. }
  7471. void Commands::Command_ModifySkill(Client* client, Seperator* sep)
  7472. {
  7473. PrintSep(sep, "COMMAND_MODIFY");
  7474. // need at least 2 args for a valid command
  7475. if( sep && sep->arg[1] )
  7476. {
  7477. if (strcmp(sep->arg[0], "add") == 0) {
  7478. const char* skill_name = sep->argplus[1];
  7479. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  7480. if (skill) {
  7481. Player* player = 0;
  7482. Client* to_client = 0;
  7483. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  7484. player = (Player*)client->GetPlayer()->GetTarget();
  7485. to_client = player->GetClient();
  7486. }
  7487. else {
  7488. player = client->GetPlayer();
  7489. to_client = client;
  7490. }
  7491. if (player)
  7492. {
  7493. if (!player->GetSkills()->HasSkill(skill->skill_id))
  7494. {
  7495. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  7496. if (to_client == client) {
  7497. client->Message(CHANNEL_STATUS, "Added skill '%s'.", skill_name);
  7498. }
  7499. else {
  7500. client->Message(CHANNEL_STATUS, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  7501. to_client->Message(CHANNEL_STATUS, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  7502. }
  7503. }
  7504. else
  7505. client->Message(CHANNEL_STATUS, "%s already has the skill '%s'.", to_client == client ? "You" : player->GetName(), skill_name);
  7506. }
  7507. }
  7508. else
  7509. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  7510. }
  7511. else if (strcmp(sep->arg[0], "remove") == 0) {
  7512. const char* skill_name = sep->argplus[1];
  7513. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  7514. if (skill) {
  7515. Player* player = 0;
  7516. Client* to_client = 0;
  7517. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  7518. player = (Player*)client->GetPlayer()->GetTarget();
  7519. to_client = player->GetClient();
  7520. }
  7521. else {
  7522. player = client->GetPlayer();
  7523. to_client = client;
  7524. }
  7525. if (player)
  7526. {
  7527. if (player->GetSkills()->HasSkill(skill->skill_id))
  7528. {
  7529. player->RemoveSkillFromDB(skill, true);
  7530. if (client == to_client) {
  7531. client->Message(CHANNEL_STATUS, "Removed skill '%s'.", skill_name);
  7532. }
  7533. else {
  7534. client->Message(CHANNEL_STATUS, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  7535. if(to_client) {
  7536. to_client->Message(CHANNEL_STATUS, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  7537. }
  7538. }
  7539. }
  7540. else {
  7541. if (client == to_client)
  7542. client->Message(CHANNEL_STATUS, "You do not have the skill '%s'.", skill_name);
  7543. else
  7544. client->Message(CHANNEL_STATUS, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  7545. }
  7546. }
  7547. }
  7548. else
  7549. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  7550. }
  7551. else if (strcmp(sep->arg[0], "set") == 0) {
  7552. if (!sep->IsNumber(2)) {
  7553. client->Message(CHANNEL_STATUS, "The last parameter must be a number.");
  7554. return;
  7555. }
  7556. const char* skill_name = sep->arg[1];
  7557. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  7558. if (skill) {
  7559. int16 val = atoi(sep->arg[2]);
  7560. Player* player = 0;
  7561. Client* to_client = 0;
  7562. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  7563. player = (Player*)client->GetPlayer()->GetTarget();
  7564. to_client = player->GetClient();
  7565. }
  7566. else {
  7567. player = client->GetPlayer();
  7568. to_client = client;
  7569. }
  7570. if (player)
  7571. {
  7572. if (player->GetSkills()->HasSkill(skill->skill_id)) {
  7573. player->GetSkills()->SetSkill(skill->skill_id, val);
  7574. if (client != to_client)
  7575. client->Message(CHANNEL_STATUS, "You set %s's '%s' skill to %i.", player->GetName(), skill_name, val);
  7576. if(to_client) {
  7577. to_client->Message(CHANNEL_STATUS, "Your '%s' skill has been set to %i.", skill_name, val);
  7578. }
  7579. }
  7580. else {
  7581. client->Message(CHANNEL_STATUS, "Target does not have the skill '%s'.", skill_name);
  7582. }
  7583. }
  7584. }
  7585. else {
  7586. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  7587. }
  7588. }
  7589. else {
  7590. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  7591. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  7592. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  7593. }
  7594. }
  7595. else {
  7596. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  7597. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  7598. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  7599. }
  7600. }
  7601. void Commands::Command_ModifySpell(Client* client, Seperator* sep)
  7602. {
  7603. PrintSep(sep, "COMMAND_MODIFY");
  7604. // need at least 2 args for a valid command
  7605. if( sep && sep->arg[1] )
  7606. {
  7607. }
  7608. else
  7609. Command_Modify(client);
  7610. }
  7611. void Commands::Command_ModifyZone(Client* client, Seperator* sep)
  7612. {
  7613. PrintSep(sep, "COMMAND_MODIFY");
  7614. // need at least 2 args for a valid command
  7615. if( sep && sep->arg[1] )
  7616. {
  7617. }
  7618. else
  7619. Command_Modify(client);
  7620. }
  7621. /*
  7622. Function: Command_MOTD()
  7623. Purpose : Displays server MOTD
  7624. Params :
  7625. Dev : LethalEncounter
  7626. Example : /motd
  7627. */
  7628. void Commands::Command_MOTD(Client* client)
  7629. {
  7630. if (client)
  7631. ClientPacketFunctions::SendMOTD(client);
  7632. }
  7633. /*
  7634. Function: Command_Pet()
  7635. Purpose : Handle Pet {Command} commands
  7636. Params : attack, backoff, preserve_master, preserve_self, follow, stay, getlost
  7637. Dev :
  7638. Example : /pet preserve_master
  7639. */
  7640. void Commands::Command_Pet(Client* client, Seperator* sep)
  7641. {
  7642. PrintSep(sep, "COMMAND_PET");
  7643. //LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Pet Commands");
  7644. //client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7645. if (!sep || !sep->arg[0])
  7646. return; // should have sep->arg[0] filled
  7647. if (strcmp(sep->arg[0], "hide") == 0) {
  7648. // doing /pet hide will toggle the hide status on all the pets that can be hidden
  7649. Entity* pet = client->GetPlayer()->GetDeityPet();
  7650. if (pet) {
  7651. if (pet->IsPrivateSpawn())
  7652. client->GetPlayer()->HideDeityPet(false);
  7653. else
  7654. client->GetPlayer()->HideDeityPet(true);
  7655. }
  7656. pet = client->GetPlayer()->GetCosmeticPet();
  7657. if (pet) {
  7658. if (pet->IsPrivateSpawn())
  7659. client->GetPlayer()->HideCosmeticPet(false);
  7660. else
  7661. client->GetPlayer()->HideCosmeticPet(true);
  7662. }
  7663. return;
  7664. }
  7665. // below is for all combat pets
  7666. if (!client->GetPlayer()->HasPet()) {
  7667. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a pet.");
  7668. return;
  7669. }
  7670. if (strcmp(sep->arg[0], "stay") == 0) {
  7671. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to stay.");
  7672. client->GetPlayer()->GetInfoStruct()->set_pet_movement(1);
  7673. client->GetPlayer()->SetCharSheetChanged(true);
  7674. if (client->GetPlayer()->GetPet())
  7675. client->GetPlayer()->GetPet()->following = false;
  7676. if (client->GetPlayer()->GetCharmedPet())
  7677. client->GetPlayer()->GetCharmedPet()->following = false;
  7678. }
  7679. else if (strcmp(sep->arg[0], "follow") == 0) {
  7680. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to follow.");
  7681. client->GetPlayer()->GetInfoStruct()->set_pet_movement(2);
  7682. client->GetPlayer()->SetCharSheetChanged(true);
  7683. }
  7684. else if (strcmp(sep->arg[0], "preserve_master") == 0) {
  7685. if (client->GetPlayer()->GetInfoStruct()->get_pet_behavior() & 1) {
  7686. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect you.");
  7687. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()-1);
  7688. }
  7689. else {
  7690. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect you.");
  7691. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()+1);
  7692. }
  7693. client->GetPlayer()->SetCharSheetChanged(true);
  7694. }
  7695. else if (strcmp(sep->arg[0], "preserve_self") == 0) {
  7696. if (client->GetPlayer()->GetInfoStruct()->get_pet_behavior() & 2) {
  7697. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect itself.");
  7698. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()-2);
  7699. }
  7700. else {
  7701. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect itself.");
  7702. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()+2);
  7703. }
  7704. client->GetPlayer()->SetCharSheetChanged(true);
  7705. }
  7706. else if (strcmp(sep->arg[0], "backoff") == 0) {
  7707. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to back down.");
  7708. if (client->GetPlayer()->GetPet())
  7709. ((NPC*)client->GetPlayer()->GetPet())->Brain()->ClearHate();
  7710. if (client->GetPlayer()->GetCharmedPet())
  7711. ((NPC*)client->GetPlayer()->GetCharmedPet())->Brain()->ClearHate();
  7712. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(0);
  7713. client->GetPlayer()->SetCharSheetChanged(true);
  7714. }
  7715. else if (strcmp(sep->arg[0], "attack") == 0) {
  7716. if (client->GetPlayer()->HasTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  7717. if (client->GetPlayer()->AttackAllowed((Entity*)client->GetPlayer()->GetTarget())){
  7718. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to attack your target.");
  7719. if (client->GetPlayer()->GetPet())
  7720. client->GetPlayer()->GetPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  7721. if (client->GetPlayer()->GetCharmedPet())
  7722. client->GetPlayer()->GetCharmedPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  7723. }
  7724. else
  7725. client->Message(CHANNEL_COLOR_YELLOW, "You can not attack that.");
  7726. }
  7727. else
  7728. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a target.");
  7729. }
  7730. else if (strcmp(sep->arg[0], "getlost") == 0) {
  7731. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetPet());
  7732. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetCharmedPet());
  7733. client->Message(CHANNEL_COLOR_YELLOW, "You tell your pet to get lost.");
  7734. }
  7735. else
  7736. client->Message(CHANNEL_COLOR_YELLOW, "Unknown pet command.");
  7737. }
  7738. /*
  7739. Function: Command_PetName()
  7740. Purpose : Pet your name (???)
  7741. Params :
  7742. Dev :
  7743. Example :
  7744. */
  7745. void Commands::Command_PetName(Client* client, Seperator* sep)
  7746. {
  7747. if (sep && sep->arg[0]) {
  7748. const char* pet_name = sep->argplus[0];
  7749. client->SetPetName(pet_name);
  7750. }
  7751. else {
  7752. client->GetPlayer()->GetInfoStruct()->set_pet_name("");
  7753. }
  7754. }
  7755. /*
  7756. Function: Command_NamePet()
  7757. Purpose : Name your pet
  7758. Params :
  7759. Dev :
  7760. Example :
  7761. */
  7762. void Commands::Command_NamePet(Client* client, Seperator* sep)
  7763. {
  7764. PrintSep(sep, "COMMAND_NAME_PET");
  7765. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Name Pet Command");
  7766. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7767. }
  7768. /*
  7769. Function: Command_Rename()
  7770. Purpose : Renames existing pet
  7771. Params :
  7772. Dev :
  7773. Example :
  7774. */
  7775. void Commands::Command_Rename(Client* client, Seperator* sep)
  7776. {
  7777. PrintSep(sep, "COMMAND_RENAME");
  7778. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Rename Pet Command");
  7779. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7780. }
  7781. /*
  7782. Function: Command_ConfirmRename()
  7783. Purpose : Confirms renaming your pet
  7784. Params :
  7785. Dev :
  7786. Example :
  7787. */
  7788. void Commands::Command_ConfirmRename(Client* client, Seperator* sep)
  7789. {
  7790. PrintSep(sep, "COMMAND_CONFIRMRENAME");
  7791. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Confirm Rename Pet Command");
  7792. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7793. }
  7794. /*
  7795. Function: Command_PetOptions()
  7796. Purpose : Sets various pet options
  7797. Params :
  7798. Dev :
  7799. Example :
  7800. */
  7801. void Commands::Command_PetOptions(Client* client, Seperator* sep)
  7802. {
  7803. PrintSep(sep, "COMMAND_PETOPTIONS");
  7804. Player* player = client->GetPlayer();
  7805. Spawn* target = player->GetTarget();
  7806. if (!target)
  7807. return;
  7808. if (target == player->GetPet())
  7809. client->SendPetOptionsWindow(player->GetPet()->GetName());
  7810. else if (target == player->GetCharmedPet())
  7811. client->SendPetOptionsWindow(player->GetCharmedPet()->GetName());
  7812. else if (target == player->GetCosmeticPet())
  7813. client->SendPetOptionsWindow(player->GetCosmeticPet()->GetName(), 0);
  7814. else if (target == player->GetDeityPet())
  7815. client->SendPetOptionsWindow(player->GetDeityPet()->GetName(), 0);
  7816. }
  7817. /*
  7818. Function: Command_Random()
  7819. Purpose : Handles /random dice roll in-game
  7820. Params : 1-100
  7821. Dev : Scatman
  7822. Example : /randon 1 100
  7823. */
  7824. void Commands::Command_Random(Client* client, Seperator* sep)
  7825. {
  7826. char message[256] = {0};
  7827. if (sep)
  7828. {
  7829. if (sep->GetArgNumber() == 0 && sep->IsNumber(0))
  7830. 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])));
  7831. else if (sep->GetArgNumber() > 0 && sep->IsNumber(0) && sep->IsNumber(1))
  7832. 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])));
  7833. else
  7834. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  7835. }
  7836. else
  7837. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  7838. client->GetPlayer()->GetZone()->HandleChatMessage(0, 0, CHANNEL_EMOTE, message);
  7839. }
  7840. /*
  7841. Function: Command_Randomize()
  7842. Purpose : Sets randomize (appearance) values for NPCs
  7843. Params : Attrib Name
  7844. Dev : Scatman
  7845. Example : /randomize gender 1 -- will randomize the NPCs gender (male/female)
  7846. */
  7847. void Commands::Command_Randomize(Client* client, Seperator* sep)
  7848. {
  7849. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  7850. if (target)
  7851. {
  7852. if (target->IsNPC())
  7853. {
  7854. if (sep && sep->arg[0] && !sep->IsNumber(0))
  7855. {
  7856. const char* value = sep->arg[0];
  7857. if (strncasecmp(value, "show", strlen(value)) == 0)
  7858. {
  7859. client->DisplayRandomizeFeatures(target->GetRandomize());
  7860. }
  7861. else
  7862. {
  7863. if (sep->arg[1] && sep->IsNumber(1))
  7864. {
  7865. int8 option = atoi(sep->arg[1]);
  7866. if (option == 0 || option == 1)
  7867. {
  7868. int32 feature = 0;
  7869. char feature_text[32] = {0};
  7870. if (strncasecmp(value, "gender", strlen(value)) == 0) {
  7871. feature = RANDOMIZE_GENDER;
  7872. strncpy(feature_text, "gender", sizeof(feature_text) - 1);
  7873. }
  7874. else if (strncasecmp(value, "race", strlen(value)) == 0) {
  7875. feature = RANDOMIZE_RACE;
  7876. strncpy(feature_text, "race", sizeof(feature_text) - 1);
  7877. }
  7878. else if (strncasecmp(value, "model", strlen(value)) == 0) {
  7879. feature = RANDOMIZE_MODEL_TYPE;
  7880. strncpy(feature_text, "model", sizeof(feature_text) - 1);
  7881. }
  7882. else if (strncasecmp(value, "facial_hair", strlen(value)) == 0) {
  7883. feature = RANDOMIZE_FACIAL_HAIR_TYPE;
  7884. strncpy(feature_text, "facial hair", sizeof(feature_text) - 1);
  7885. }
  7886. else if (strncasecmp(value, "hair", strlen(value)) == 0) {
  7887. feature = RANDOMIZE_HAIR_TYPE;
  7888. strncpy(feature_text, "hair", sizeof(feature_text) - 1);
  7889. }
  7890. else if (strncasecmp(value, "wing", strlen(value)) == 0) {
  7891. feature = RANDOMIZE_WING_TYPE;
  7892. strncpy(feature_text, "wings", sizeof(feature_text) - 1);
  7893. }
  7894. else if (strncasecmp(value, "cheek", strlen(value)) == 0) {
  7895. feature = RANDOMIZE_CHEEK_TYPE;
  7896. strncpy(feature_text, "cheeks", sizeof(feature_text) - 1);
  7897. }
  7898. else if (strncasecmp(value, "chin", strlen(value)) == 0) {
  7899. feature = RANDOMIZE_CHIN_TYPE;
  7900. strncpy(feature_text, "chin", sizeof(feature_text) - 1);
  7901. }
  7902. else if (strncasecmp(value, "ear", strlen(value)) == 0) {
  7903. feature = RANDOMIZE_EAR_TYPE;
  7904. strncpy(feature_text, "ears", sizeof(feature_text) - 1);
  7905. }
  7906. else if (strncasecmp(value, "eye_brow", strlen(value)) == 0) {
  7907. feature = RANDOMIZE_EYE_BROW_TYPE;
  7908. strncpy(feature_text, "eye brows", sizeof(feature_text) - 1);
  7909. }
  7910. else if (strncasecmp(value, "eye", strlen(value)) == 0) {
  7911. feature = RANDOMIZE_EYE_TYPE;
  7912. strncpy(feature_text, "eyes", sizeof(feature_text) - 1);
  7913. }
  7914. else if (strncasecmp(value, "lip", strlen(value)) == 0) {
  7915. feature = RANDOMIZE_LIP_TYPE;
  7916. strncpy(feature_text, "lips", sizeof(feature_text) - 1);
  7917. }
  7918. else if (strncasecmp(value, "nose", strlen(value)) == 0) {
  7919. feature = RANDOMIZE_NOSE_TYPE;
  7920. strncpy(feature_text, "nose", sizeof(feature_text) - 1);
  7921. }
  7922. else if (strncasecmp(value, "eye_color", strlen(value)) == 0) {
  7923. feature = RANDOMIZE_EYE_COLOR;
  7924. strncpy(feature_text, "eye color", sizeof(feature_text) - 1);
  7925. }
  7926. else if (strncasecmp(value, "hair_color", strlen(value)) == 0) {
  7927. feature = RANDOMIZE_HAIR_TYPE_COLOR;
  7928. strncpy(feature_text, "hair color", sizeof(feature_text) - 1);
  7929. }
  7930. else if (strncasecmp(value, "hair_color1", strlen(value)) == 0) {
  7931. feature = RANDOMIZE_HAIR_COLOR1;
  7932. strncpy(feature_text, "hair color1", sizeof(feature_text) - 1);
  7933. }
  7934. else if (strncasecmp(value, "hair_color2", strlen(value)) == 0) {
  7935. feature = RANDOMIZE_HAIR_COLOR2;
  7936. strncpy(feature_text, "hair color2", sizeof(feature_text) - 1);
  7937. }
  7938. else if (strncasecmp(value, "hair_highlight", strlen(value)) == 0) {
  7939. feature = RANDOMIZE_HAIR_HIGHLIGHT;
  7940. strncpy(feature_text, "hair highlights", sizeof(feature_text) - 1);
  7941. }
  7942. else if (strncasecmp(value, "facial_hair_color", strlen(value)) == 0) {
  7943. feature = RANDOMIZE_HAIR_FACE_COLOR;
  7944. strncpy(feature_text, "facial hair color", sizeof(feature_text) - 1);
  7945. }
  7946. else if (strncasecmp(value, "facial_hair_color_highlight", strlen(value)) == 0) {
  7947. feature = RANDOMIZE_HAIR_FACE_HIGHLIGHT_COLOR;
  7948. strncpy(feature_text, "facial hair color highlights", sizeof(feature_text) - 1);
  7949. }
  7950. else if (strncasecmp(value, "hair_color_highlight", strlen(value)) == 0) {
  7951. feature = RANDOMIZE_HAIR_TYPE_HIGHLIGHT_COLOR;
  7952. strncpy(feature_text, "hair color highlights", sizeof(feature_text) - 1);
  7953. }
  7954. else if (strncasecmp(value, "skin_color", strlen(value)) == 0) {
  7955. feature = RANDOMIZE_SKIN_COLOR;
  7956. strncpy(feature_text, "skin color", sizeof(feature_text) - 1);
  7957. }
  7958. else if (strncasecmp(value, "wing_color1", strlen(value)) == 0) {
  7959. feature = RANDOMIZE_WING_COLOR1;
  7960. strncpy(feature_text, "wing color1", sizeof(feature_text) - 1);
  7961. }
  7962. else if (strncasecmp(value, "wing_color2", strlen(value)) == 0) {
  7963. feature = RANDOMIZE_WING_COLOR2;
  7964. strncpy(feature_text, "wing color2", sizeof(feature_text) - 1);
  7965. }
  7966. else {
  7967. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is not a valid feature to randomize.", value);
  7968. 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'.");
  7969. }
  7970. if (feature > 0) {
  7971. if (option == 1) {
  7972. if (target->GetRandomize() & feature)
  7973. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is already set to randomly generate their %s.", target->GetName(), feature_text);
  7974. else {
  7975. target->AddRandomize(feature);
  7976. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(feature);
  7977. database.UpdateRandomize(target->GetDatabaseID(), feature);
  7978. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will now generate their %s randomly.", target->GetName(), feature_text);
  7979. }
  7980. }
  7981. else {
  7982. if (target->GetRandomize() & feature) {
  7983. target->AddRandomize(-feature);
  7984. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(-feature);
  7985. database.UpdateRandomize(target->GetDatabaseID(), -feature);
  7986. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will no longer generate their %s randomly.", target->GetName(), feature_text);
  7987. }
  7988. else
  7989. client->Message(CHANNEL_COLOR_YELLOW, "'%s' already does not randomly generate their %s.", target->GetName(), feature_text);
  7990. }
  7991. }
  7992. }
  7993. else
  7994. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  7995. }
  7996. else
  7997. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  7998. }
  7999. }
  8000. else {
  8001. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /randomize [show | [feature [1|0]]");
  8002. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "'show' will display current configured features");
  8003. 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'.");
  8004. }
  8005. }
  8006. else
  8007. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "The target you wish to randomize must be an NPC.");
  8008. }
  8009. else
  8010. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select the target you wish to randomize.");
  8011. }
  8012. /*
  8013. Function: Command_ShowCloak()
  8014. Purpose : Character Settings combo box for Show Cloak
  8015. Params : true/false
  8016. Dev : John Adams
  8017. Example :
  8018. */
  8019. void Commands::Command_ShowCloak(Client* client, Seperator* sep)
  8020. {
  8021. Player* player = client->GetPlayer();
  8022. if (sep && sep->arg[0])
  8023. {
  8024. const char* value = sep->arg[0];
  8025. if (strncasecmp(value, "true", strlen(value)) == 0)
  8026. {
  8027. player->set_character_flag(CF_SHOW_CLOAK);
  8028. player->reset_character_flag(CF2_SHOW_RANGED);
  8029. }
  8030. else if (strncasecmp(value, "false", strlen(value)) == 0)
  8031. player->reset_character_flag(CF_SHOW_CLOAK);
  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_ShowHelm()
  8041. Purpose : Character Settings combo box for Show Helm
  8042. Params : true/false
  8043. Dev : John Adams
  8044. Example :
  8045. */
  8046. void Commands::Command_ShowHelm(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_ShowHelm");
  8055. const char* value = sep->arg[0];
  8056. if (strncasecmp(value, "true", strlen(value)) == 0)
  8057. {
  8058. player->toggle_character_flag(CF_HIDE_HELM);
  8059. player->toggle_character_flag(CF_HIDE_HOOD);
  8060. }
  8061. else if (strncasecmp(value, "false", strlen(value)) == 0)
  8062. player->toggle_character_flag(CF_HIDE_HELM);
  8063. else
  8064. {
  8065. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8066. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8067. }
  8068. }
  8069. }
  8070. /*
  8071. Function: Command_ShowHood()
  8072. Purpose : Character Settings combo box for Show Hood
  8073. Params : true/false
  8074. Dev : John Adams
  8075. Example :
  8076. */
  8077. void Commands::Command_ShowHood(Client* client, Seperator* sep)
  8078. {
  8079. Player* player = client->GetPlayer();
  8080. if (sep && sep->arg[0])
  8081. {
  8082. PrintSep(sep, "Command_ShowHood");
  8083. const char* value = sep->arg[0];
  8084. if (strncasecmp(value, "true", strlen(value)) == 0)
  8085. {
  8086. player->toggle_character_flag(CF_HIDE_HOOD);
  8087. if(client->GetVersion() > 546) { // no hide helm support in DoF
  8088. player->toggle_character_flag(CF_HIDE_HELM);
  8089. }
  8090. }
  8091. else if (strncasecmp(value, "false", strlen(value)) == 0) {
  8092. player->toggle_character_flag(CF_HIDE_HOOD);
  8093. }
  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: Command_ShowHoodHelm()
  8103. Purpose : Character Settings combo box for Show Helm or Hood
  8104. Params : true/false
  8105. Dev : John Adams
  8106. Example :
  8107. */
  8108. void Commands::Command_ShowHoodHelm(Client* client, Seperator* sep)
  8109. {
  8110. Player* player = client->GetPlayer();
  8111. if(client->GetVersion() <= 546) {
  8112. return; // not allowed/supported
  8113. }
  8114. if (sep && sep->arg[0])
  8115. {
  8116. PrintSep(sep, "Command_ShowHoodHelm");
  8117. const char* value = sep->arg[0];
  8118. if (strncasecmp(value, "true", strlen(value)) == 0)
  8119. {
  8120. player->toggle_character_flag(CF_HIDE_HOOD);
  8121. player->toggle_character_flag(CF_HIDE_HELM);
  8122. }
  8123. else if (strncasecmp(value, "false", strlen(value)) == 0)
  8124. {
  8125. // don't think we ever wind up in here...
  8126. player->toggle_character_flag(CF_HIDE_HOOD);
  8127. player->toggle_character_flag(CF_HIDE_HELM);
  8128. }
  8129. else
  8130. {
  8131. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8132. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8133. }
  8134. }
  8135. }
  8136. /*
  8137. Function: Command_ShowRanged()
  8138. Purpose : Character Settings combo box for Show Ranged weapon
  8139. Params : true/false
  8140. Dev : John Adams
  8141. Example :
  8142. */
  8143. void Commands::Command_ShowRanged(Client* client, Seperator* sep)
  8144. {
  8145. Player* player = client->GetPlayer();
  8146. if (sep && sep->arg[0])
  8147. {
  8148. const char* value = sep->arg[0];
  8149. if (strncasecmp(value, "true", strlen(value)) == 0)
  8150. {
  8151. player->set_character_flag(CF2_SHOW_RANGED);
  8152. player->reset_character_flag(CF_SHOW_CLOAK);
  8153. }
  8154. else if (strncasecmp(value, "false", strlen(value)) == 0)
  8155. player->reset_character_flag(CF2_SHOW_RANGED);
  8156. else
  8157. {
  8158. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8159. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8160. }
  8161. }
  8162. }
  8163. /*
  8164. Function:
  8165. Purpose :
  8166. Params :
  8167. Dev :
  8168. Example :
  8169. */
  8170. void Commands::Command_Skills(Client* client, Seperator* sep, int handler)
  8171. {
  8172. Player* player = 0;
  8173. Client* to_client = 0;
  8174. if(client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  8175. to_client = ((Player*)client->GetPlayer()->GetTarget())->GetClient();
  8176. switch(handler)
  8177. {
  8178. case COMMAND_SKILL:
  8179. {
  8180. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill [add|remove|list] [skill name]");
  8181. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to add/remove skills for that player.");
  8182. break;
  8183. }
  8184. case COMMAND_SKILL_ADD:
  8185. {
  8186. if (sep && sep->arg[0])
  8187. {
  8188. const char* skill_name = sep->argplus[0];
  8189. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  8190. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // add skill to your target, if target is not you
  8191. {
  8192. player = to_client->GetPlayer();
  8193. if (player)
  8194. {
  8195. if (!player->GetSkills()->HasSkill(skill->skill_id))
  8196. {
  8197. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  8198. client->Message(CHANNEL_COLOR_YELLOW, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  8199. to_client->Message(CHANNEL_COLOR_YELLOW, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  8200. }
  8201. else
  8202. client->Message(CHANNEL_COLOR_YELLOW, "%s already has the skill '%s'.", player->GetName(), skill_name);
  8203. }
  8204. }
  8205. else if (skill) // add skill to yourself
  8206. {
  8207. player = client->GetPlayer();
  8208. if (player)
  8209. {
  8210. if (!player->GetSkills()->HasSkill(skill->skill_id))
  8211. {
  8212. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  8213. client->Message(CHANNEL_COLOR_YELLOW, "Added skill '%s'.", skill_name);
  8214. }
  8215. else
  8216. client->Message(CHANNEL_COLOR_YELLOW, "You already have the skill '%s'.", skill_name);
  8217. }
  8218. }
  8219. else
  8220. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  8221. }
  8222. else
  8223. {
  8224. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill add [skill name]");
  8225. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  8226. }
  8227. break;
  8228. }
  8229. case COMMAND_SKILL_REMOVE:
  8230. {
  8231. if (sep && sep->arg[0])
  8232. {
  8233. const char* skill_name = sep->argplus[0];
  8234. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  8235. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // remove skill from your target, if target is not you
  8236. {
  8237. player = to_client->GetPlayer();
  8238. if (player)
  8239. {
  8240. if (player->GetSkills()->HasSkill(skill->skill_id))
  8241. {
  8242. player->RemoveSkillFromDB(skill, true);
  8243. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  8244. to_client->Message(CHANNEL_COLOR_YELLOW, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  8245. }
  8246. else
  8247. client->Message(CHANNEL_COLOR_YELLOW, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  8248. }
  8249. }
  8250. else if(skill) // remove skill from yourself
  8251. {
  8252. Player* player = client->GetPlayer();
  8253. if (player)
  8254. {
  8255. if (player->GetSkills()->HasSkill(skill->skill_id))
  8256. {
  8257. player->RemoveSkillFromDB(skill, true);
  8258. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s'.", skill_name);
  8259. }
  8260. else
  8261. client->Message(CHANNEL_COLOR_YELLOW, "You do not have the skill '%s'.", skill_name);
  8262. }
  8263. }
  8264. else
  8265. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  8266. }
  8267. else
  8268. {
  8269. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill remove [skill name]");
  8270. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  8271. }
  8272. break;
  8273. }
  8274. case COMMAND_SKILL_LIST:
  8275. {
  8276. if (sep && sep->arg[0])
  8277. {
  8278. const char* skill_name = sep->argplus[0];
  8279. client->Message(CHANNEL_COLOR_YELLOW, "Listing skills like '%s':", skill_name);
  8280. map<int32, Skill*>* skills = master_skill_list.GetAllSkills();
  8281. map<int32, Skill*>::iterator itr;
  8282. if (skills && skills->size() > 0)
  8283. {
  8284. for (itr = skills->begin(); itr != skills->end(); itr++)
  8285. {
  8286. Skill* skill = itr->second;
  8287. string current_skill_name = ::ToLower(string(skill->name.data.c_str()));
  8288. if (current_skill_name.find(::ToLower(string(skill_name))) < 0xFFFFFFFF)
  8289. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", skill->name.data.c_str(), skill->skill_id);
  8290. }
  8291. }
  8292. }
  8293. else
  8294. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill list [skill name]");
  8295. break;
  8296. }
  8297. }
  8298. }
  8299. /*
  8300. Function: Command_SpawnTemplate()
  8301. Purpose : Create or Use defined Spawn Templates
  8302. Params : create, save, rempve, list
  8303. Dev : John Adams
  8304. Example : /spawn template create "Test"
  8305. */
  8306. void Commands::Command_SpawnTemplate(Client* client, Seperator* sep)
  8307. {
  8308. if (sep == NULL || sep->arg[0] == NULL)
  8309. {
  8310. 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.");
  8311. return;
  8312. }
  8313. // got params, continue
  8314. const char * template_cmd = sep->arg[0];
  8315. if (strncasecmp(template_cmd, "list", strlen(template_cmd)) == 0)
  8316. {
  8317. if (!sep->IsSet(1))
  8318. {
  8319. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /spawn template list [name|location_id]");
  8320. 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.");
  8321. return;
  8322. }
  8323. map<int32, string>* template_names = 0;
  8324. if (sep->IsNumber(1))
  8325. {
  8326. int32 location_id = 0;
  8327. location_id = atoi(sep->arg[1]);
  8328. template_names = database.GetSpawnTemplateListByID(location_id);
  8329. }
  8330. else
  8331. {
  8332. const char* name = 0;
  8333. name = sep->argplus[1];
  8334. template_names = database.GetSpawnTemplateListByName(name);
  8335. }
  8336. if(!template_names)
  8337. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No templates found.");
  8338. else
  8339. {
  8340. map<int32, string>::iterator itr;
  8341. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  8342. for(itr = template_names->begin(); itr != template_names->end(); itr++)
  8343. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  8344. safe_delete(template_names);
  8345. }
  8346. }
  8347. else if (strncasecmp(template_cmd, "save", strlen(template_cmd)) == 0)
  8348. {
  8349. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  8350. if ( target && (target->IsNPC() || target->IsObject() || target->IsSign() || target->IsWidget() || target->IsGroundSpawn()) )
  8351. {
  8352. if (sep && sep->arg[1][0] && !sep->IsNumber(1))
  8353. {
  8354. // first, lookup to see if template name already exists
  8355. const char* name = 0;
  8356. name = sep->argplus[1];
  8357. map<int32, string>* template_names = database.GetSpawnTemplateListByName(name);
  8358. if(!template_names)
  8359. {
  8360. int32 new_template_id = database.SaveSpawnTemplate(target->GetSpawnLocationID(), name);
  8361. if( new_template_id > 0 )
  8362. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template '%s' added for spawn '%s' (%u) as TemplateID: %u", name, target->GetName(), target->GetSpawnLocationID(), new_template_id);
  8363. else
  8364. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' for spawn '%s' (%u).", name, target->GetName(), target->GetSpawnLocationID());
  8365. }
  8366. else
  8367. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' - Already exists!", name);
  8368. }
  8369. else
  8370. client->Message(CHANNEL_COLOR_RED, "ERROR: Saving a new spawn template requires a valid template name!");
  8371. }
  8372. else
  8373. client->Message(CHANNEL_COLOR_RED, "ERROR: You must target the spawn you wish to save as a template!");
  8374. }
  8375. else if (strncasecmp(template_cmd, "remove", strlen(template_cmd)) == 0)
  8376. {
  8377. if (sep && sep->arg[1][0] && sep->IsNumber(1))
  8378. {
  8379. int32 template_id = 0;
  8380. template_id = atoi(sep->arg[1]);
  8381. if (database.RemoveSpawnTemplate(template_id))
  8382. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template ID: %u successfully removed.", template_id);
  8383. else
  8384. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to remove spawn template ID: %u", template_id);
  8385. }
  8386. else
  8387. client->Message(CHANNEL_COLOR_RED, "ERROR: Removing a spawn template requires a valid template ID!");
  8388. }
  8389. // Renamed create to spawn
  8390. else if (strncasecmp(template_cmd, "spawn", strlen(template_cmd)) == 0)
  8391. {
  8392. if (sep && sep->arg[1][0])
  8393. {
  8394. int32 new_location = 0;
  8395. if (sep->IsNumber(1))
  8396. {
  8397. int32 template_id = 0;
  8398. template_id = atoi(sep->arg[1]);
  8399. new_location = database.CreateSpawnFromTemplateByID(client, template_id);
  8400. if( new_location > 0 )
  8401. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template ID: %u", new_location, template_id);
  8402. else
  8403. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template ID: %u", template_id);
  8404. }
  8405. else
  8406. {
  8407. const char* name = 0;
  8408. name = sep->argplus[1];
  8409. new_location = database.CreateSpawnFromTemplateByName(client, name);
  8410. if( new_location > 0 )
  8411. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template: '%s'", new_location, name);
  8412. else
  8413. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template: '%s'", name);
  8414. }
  8415. }
  8416. else
  8417. client->Message(CHANNEL_COLOR_RED, "ERROR: Spawning a new spawn location requires a valid template name or ID!");
  8418. }
  8419. else
  8420. client->Message(CHANNEL_COLOR_RED, "ERROR: Unknown /spawn template command.");
  8421. }
  8422. void Commands::Command_Speed(Client* client, Seperator* sep) {
  8423. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  8424. float new_speed = atof(sep->arg[0]);
  8425. if (new_speed > 0.0f)
  8426. {
  8427. client->GetPlayer()->SetSpeed(new_speed, true);
  8428. client->GetPlayer()->SetCharSheetChanged(true);
  8429. database.insertCharacterProperty(client, CHAR_PROPERTY_SPEED, sep->arg[0]);
  8430. client->Message(CHANNEL_STATUS, "Setting speed to %.2f.", new_speed);
  8431. }
  8432. else
  8433. client->Message(CHANNEL_STATUS, "Invalid speed provided %s.", sep->arg[0]);
  8434. }
  8435. else{
  8436. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /speed {new speed value}");
  8437. }
  8438. }
  8439. /*
  8440. Function: Command_StationMarketPlace()
  8441. Purpose : just trying to eat the console spam for now
  8442. Params :
  8443. Dev : John
  8444. */
  8445. void Commands::Command_StationMarketPlace(Client* client, Seperator* sep)
  8446. {
  8447. PrintSep(sep, "COMMAND_SMP");
  8448. // This will reduce the spam from once every 10 sec to once every 30 sec,
  8449. // can't seem to reduce it any more get rid of it completely...
  8450. if (sep && strcmp(sep->arg[0], "gkw") == 0) {
  8451. PacketStruct* packet = configReader.getStruct("WS_MarketFundsUpdate", client->GetVersion());
  8452. if (packet) {
  8453. packet->setDataByName("account_id", client->GetAccountID());
  8454. packet->setDataByName("character_id", client->GetCharacterID());
  8455. packet->setDataByName("unknown1", 1, 5);
  8456. packet->setDataByName("unknown1", 26, 6);
  8457. packet->setDataByName("unknown2", 0xFFFFFFFF);
  8458. packet->setDataByName("unknown3", 248, 1);
  8459. client->QueuePacket(packet->serialize());
  8460. }
  8461. safe_delete(packet);
  8462. }
  8463. }
  8464. /*
  8465. Function: Command_StopDrinking()
  8466. Purpose : Stops player from auto-consuming drink
  8467. Params :
  8468. Dev : Zcoretri
  8469. Example : /stopdrinking
  8470. */
  8471. void Commands::Command_StopDrinking(Client* client)
  8472. {
  8473. client->GetPlayer()->reset_character_flag(CF_DRINK_AUTO_CONSUME);
  8474. client->Message(CHANNEL_COLOR_YELLOW,"You stop drinking your current drink.");
  8475. }
  8476. /*
  8477. Function: Command_StopEating()
  8478. Purpose : Stops player from auto-consuming food
  8479. Params :
  8480. Dev : Zcoretri
  8481. Example : /stopeating
  8482. */
  8483. void Commands::Command_StopEating(Client* client)
  8484. {
  8485. client->GetPlayer()->reset_character_flag(CF_FOOD_AUTO_CONSUME);
  8486. client->Message(CHANNEL_COLOR_YELLOW,"You stop eating your current food.");
  8487. }
  8488. /*
  8489. Function: Command_Title()
  8490. Purpose : Help for /title command
  8491. Params : n/a
  8492. Dev : Zcoretri
  8493. Example : /title
  8494. */
  8495. void Commands::Command_Title(Client* client)
  8496. {
  8497. client->Message(CHANNEL_COLOR_YELLOW, "Available subcommands: list, setprefix <index>, setsuffix <index>, fix");
  8498. }
  8499. /*
  8500. Function: Command_TitleList()
  8501. Purpose : List available titles for player
  8502. Params : n/a
  8503. Dev : Zcoretri
  8504. Example : /title list
  8505. */
  8506. void Commands::Command_TitleList(Client* client)
  8507. {
  8508. // must call release read lock before leaving function on GetPlayerTitles
  8509. vector<Title*>* titles = client->GetPlayer()->GetPlayerTitles()->GetAllTitles();
  8510. vector<Title*>::iterator itr;
  8511. Title* title;
  8512. sint32 i = 0;
  8513. client->Message(CHANNEL_NARRATIVE, "Listing available titles:");
  8514. for(itr = titles->begin(); itr != titles->end(); itr++)
  8515. {
  8516. title = *itr;
  8517. client->Message(CHANNEL_NARRATIVE, "%i: type=[%s] title=[%s]", i, title->GetPrefix() ? "Prefix":"Suffix", title->GetName());
  8518. i++;
  8519. }
  8520. client->GetPlayer()->GetPlayerTitles()->ReleaseReadLock();
  8521. }
  8522. /*
  8523. Function: Command_TitleSetPrefix()
  8524. Purpose : Set Prefix title for player
  8525. Params : Title ID
  8526. Dev : Zcoretri
  8527. Example : /title setprefix 1
  8528. */
  8529. void Commands::Command_TitleSetPrefix(Client* client, Seperator* sep)
  8530. {
  8531. if (sep && sep->arg[0] && sep->IsNumber(0))
  8532. {
  8533. sint32 index = atoul(sep->arg[0]);
  8534. if(index > -1)
  8535. {
  8536. Title* title = client->GetPlayer()->GetPlayerTitles()->GetTitle(index);
  8537. if(!title)
  8538. {
  8539. client->Message(CHANNEL_COLOR_RED, "Missing index %i to set title", index);
  8540. return;
  8541. }
  8542. else if(!title->GetPrefix())
  8543. {
  8544. client->Message(CHANNEL_COLOR_RED, "%s is not a prefix.", title->GetName());
  8545. return;
  8546. }
  8547. }
  8548. else // make sure client doesn't pass some bogus negative index
  8549. index = -1;
  8550. database.SaveCharPrefixIndex(index, client->GetCharacterID());
  8551. client->SendTitleUpdate();
  8552. }
  8553. }
  8554. /*
  8555. Function: Command_TitleSetSuffix()
  8556. Purpose : Set Suffix title for player
  8557. Params : Title ID
  8558. Dev : Zcoretri
  8559. Example : /title setsuffix 1
  8560. */
  8561. void Commands::Command_TitleSetSuffix(Client* client, Seperator* sep)
  8562. {
  8563. if (sep && sep->arg[0] && sep->IsNumber(0))
  8564. {
  8565. sint32 index = atoul(sep->arg[0]);
  8566. if(index > -1)
  8567. {
  8568. Title* title = client->GetPlayer()->GetPlayerTitles()->GetTitle(index);
  8569. if(!title)
  8570. {
  8571. client->Message(CHANNEL_COLOR_RED, "Missing index %i to set title", index);
  8572. return;
  8573. }
  8574. else if(title->GetPrefix())
  8575. {
  8576. client->Message(CHANNEL_COLOR_RED, "%s is not a suffix.", title->GetName());
  8577. return;
  8578. }
  8579. }
  8580. else // make sure client doesn't pass some bogus negative index
  8581. index = -1;
  8582. database.SaveCharSuffixIndex(index, client->GetCharacterID());
  8583. client->SendTitleUpdate();
  8584. }
  8585. }
  8586. /*
  8587. Function: Command_TitleFix()
  8588. Purpose : Fix title for player (???)
  8589. Params :
  8590. Dev : Zcoretri
  8591. Example :
  8592. */
  8593. void Commands::Command_TitleFix(Client* client, Seperator* sep)
  8594. {
  8595. PrintSep(sep, "COMMAND_TITLE_FIX");
  8596. LogWrite(MISC__TODO, 1, "Titles", "TODO-Command: TITLE_FIX");
  8597. }
  8598. /*
  8599. Function: Command_Toggle_Anonymous()
  8600. Purpose : Toggles player Anonymous
  8601. Params :
  8602. Dev : paulgh
  8603. Example : /anon
  8604. */
  8605. void Commands::Command_Toggle_Anonymous(Client* client)
  8606. {
  8607. Player* player = client->GetPlayer();
  8608. player->toggle_character_flag(CF_ANONYMOUS);
  8609. client->Message(CHANNEL_COLOR_YELLOW,"You are %s anonymous.", player->get_character_flag(CF_ANONYMOUS)?"now":"no longer");
  8610. if (player->get_character_flag(CF_ANONYMOUS))
  8611. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ANONYMOUS);
  8612. else
  8613. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ANONYMOUS);
  8614. }
  8615. /*
  8616. Function: Command_Toggle_AutoConsume()
  8617. Purpose : Toggles player food/drink auto consume
  8618. Params : unknown
  8619. Dev : paulgh
  8620. Example : /set_auto_consume
  8621. */
  8622. void Commands::Command_Toggle_AutoConsume(Client* client, Seperator* sep)
  8623. {
  8624. Player* player = client->GetPlayer();
  8625. if (sep && sep->arg[0])
  8626. PrintSep(sep, "COMMAND_SET_AUTO_CONSUME");
  8627. if (sep && sep->arg[0] && sep->IsNumber(0))
  8628. {
  8629. int8 slot = atoi(sep->arg[0]);
  8630. int8 flag = atoi(sep->arg[1]);
  8631. if (client->GetVersion() <= 283) {
  8632. slot += 4;
  8633. }
  8634. else if (client->GetVersion() <= 546) {
  8635. slot += 2;
  8636. }
  8637. if (slot == EQ2_FOOD_SLOT)
  8638. {
  8639. player->toggle_character_flag(CF_FOOD_AUTO_CONSUME);
  8640. player->SetCharSheetChanged(true);
  8641. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  8642. if (flag == 1)
  8643. client->Message(CHANNEL_NARRATIVE, "You decide to eat immediately whenever you become hungry.");
  8644. else
  8645. {
  8646. client->Message(CHANNEL_NARRATIVE, "You decide to ignore the hunger.");
  8647. return;
  8648. }
  8649. }
  8650. else
  8651. {
  8652. player->toggle_character_flag(CF_DRINK_AUTO_CONSUME);
  8653. player->SetCharSheetChanged(true);
  8654. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  8655. if (flag == 1)
  8656. client->Message(CHANNEL_NARRATIVE, "You decide to drink immediately whenever you become thirsty.");
  8657. else
  8658. {
  8659. client->Message(CHANNEL_NARRATIVE, "You decide to ignore the thirst.");
  8660. return;
  8661. }
  8662. }
  8663. if(!client->CheckConsumptionAllowed(slot, false))
  8664. return;
  8665. Item* item = player->GetEquipmentList()->GetItem(slot);
  8666. if(item)
  8667. client->ConsumeFoodDrink(item, slot);
  8668. }
  8669. }
  8670. /*
  8671. Function: Command_Toggle_BonusXP()
  8672. Purpose : Toggles player Bonus XP
  8673. Params :
  8674. Dev : John Adams
  8675. Example : /disable_char_bonus_exp
  8676. */
  8677. void Commands::Command_Toggle_BonusXP(Client* client)
  8678. {
  8679. Player* player = client->GetPlayer();
  8680. player->toggle_character_flag(CF2_CHARACTER_BONUS_EXPERIENCE_ENABLED);
  8681. player->SetCharSheetChanged(true);
  8682. }
  8683. /*
  8684. Function: Command_Toggle_CombatXP()
  8685. Purpose : Toggles player Adventure XP
  8686. Params :
  8687. Dev : John Adams
  8688. Example : /disable_combat_exp
  8689. */
  8690. void Commands::Command_Toggle_CombatXP(Client* client)
  8691. {
  8692. Player* player = client->GetPlayer();
  8693. player->toggle_character_flag(CF_COMBAT_EXPERIENCE_ENABLED);
  8694. player->SetCharSheetChanged(true);
  8695. }
  8696. /*
  8697. Function: Command_Toggle_GMHide()
  8698. Purpose : Toggles hiding player GM status
  8699. Params :
  8700. Dev : Scatman
  8701. Example : /gm_hide
  8702. */
  8703. void Commands::Command_Toggle_GMHide(Client* client)
  8704. {
  8705. Player* player = client->GetPlayer();
  8706. player->toggle_character_flag(CF_HIDE_STATUS);
  8707. client->Message(CHANNEL_COLOR_YELLOW,"You are %s hiding your GM status.", player->get_character_flag(CF_HIDE_STATUS)?"now":"no longer");
  8708. }
  8709. /*
  8710. Function: Command_Toggle_GMVanish()
  8711. Purpose : Toggles hiding GM players from /who searches
  8712. Params :
  8713. Dev : Scatman
  8714. Example : /gm_vanish
  8715. */
  8716. void Commands::Command_Toggle_GMVanish(Client* client)
  8717. {
  8718. Player* player = client->GetPlayer();
  8719. player->toggle_character_flag(CF_GM_HIDDEN);
  8720. client->Message(CHANNEL_COLOR_YELLOW,"You are %s invisible to who queries.", player->get_character_flag(CF_GM_HIDDEN)?"now":"no longer");
  8721. }
  8722. /*
  8723. Function: Command_Toggle_Illusions()
  8724. Purpose : Toggles player illusion form
  8725. Params : not sure sep is needed, testing
  8726. Dev : paulgh
  8727. Example : /hide_illusions
  8728. */
  8729. void Commands::Command_Toggle_Illusions(Client* client, Seperator* sep)
  8730. {
  8731. if (sep && sep->arg[0])
  8732. PrintSep(sep, "COMMAND_TOGGLE_ILLUSIONS");
  8733. client->GetPlayer()->toggle_character_flag(CF_SHOW_ILLUSION);
  8734. }
  8735. /*
  8736. Function: Command_Toggle_LFG()
  8737. Purpose : Toggles player LFG Flag
  8738. Params :
  8739. Dev : paulgh
  8740. Example : /lfg
  8741. */
  8742. void Commands::Command_Toggle_LFG(Client* client)
  8743. {
  8744. Player* player = client->GetPlayer();
  8745. player->toggle_character_flag(CF_LFG);
  8746. client->Message(CHANNEL_COLOR_YELLOW,"You are %s LFG.", player->get_character_flag(CF_LFG)?"now":"no longer");
  8747. if (player->get_character_flag(CF_LFG))
  8748. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFG);
  8749. else
  8750. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFG);
  8751. }
  8752. /*
  8753. Function: Command_Toggle_LFW()
  8754. Purpose : Toggles player LFW Flag
  8755. Params :
  8756. Dev : paulgh
  8757. Example : /lfw
  8758. */
  8759. void Commands::Command_Toggle_LFW(Client* client)
  8760. {
  8761. Player* player = client->GetPlayer();
  8762. player->toggle_character_flag(CF_LFW);
  8763. client->Message(CHANNEL_COLOR_YELLOW,"You %s looking for work.", player->get_character_flag(CF_LFW)?"let others know you are":"stop");
  8764. if (player->get_character_flag(CF_LFW))
  8765. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFW);
  8766. else
  8767. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFW);
  8768. }
  8769. /*
  8770. Function: Command_Toggle_QuestXP()
  8771. Purpose : Toggles player Quest XP
  8772. Params :
  8773. Dev : John Adams
  8774. Example : /disable_quest_exp
  8775. */
  8776. void Commands::Command_Toggle_QuestXP(Client* client)
  8777. {
  8778. Player* player = client->GetPlayer();
  8779. player->toggle_character_flag(CF_QUEST_EXPERIENCE_ENABLED);
  8780. player->SetCharSheetChanged(true);
  8781. }
  8782. /*
  8783. Function: Command_Toggle_Roleplaying()
  8784. Purpose : Toggles player Roleplaying flag
  8785. Params :
  8786. Dev : paulgh
  8787. Example : /role
  8788. */
  8789. void Commands::Command_Toggle_Roleplaying(Client* client)
  8790. {
  8791. Player* player = client->GetPlayer();
  8792. player->toggle_character_flag(CF_ROLEPLAYING);
  8793. client->Message(CHANNEL_COLOR_YELLOW,"You are %s roleplaying.", player->get_character_flag(CF_ROLEPLAYING)?"now":"no longer");
  8794. if (player->get_character_flag(CF_ROLEPLAYING))
  8795. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ROLEPLAYING);
  8796. else
  8797. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ROLEPLAYING);
  8798. }
  8799. void Commands::Command_Toggle_Duels(Client* client)
  8800. {
  8801. Player* player = client->GetPlayer();
  8802. player->toggle_character_flag(CF_ALLOW_DUEL_INVITES);
  8803. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting duel invites.", player->get_character_flag(CF_ALLOW_DUEL_INVITES)?"now":"no longer");
  8804. }
  8805. void Commands::Command_Toggle_Trades(Client* client)
  8806. {
  8807. Player* player = client->GetPlayer();
  8808. player->toggle_character_flag(CF_ALLOW_TRADE_INVITES);
  8809. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting trade invites.", player->get_character_flag(CF_ALLOW_TRADE_INVITES)?"now":"no longer");
  8810. }
  8811. void Commands::Command_Toggle_Guilds(Client* client)
  8812. {
  8813. Player* player = client->GetPlayer();
  8814. player->toggle_character_flag(CF_ALLOW_GUILD_INVITES);
  8815. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting guild invites.", player->get_character_flag(CF_ALLOW_GUILD_INVITES)?"now":"no longer");
  8816. }
  8817. void Commands::Command_Toggle_Groups(Client* client)
  8818. {
  8819. Player* player = client->GetPlayer();
  8820. player->toggle_character_flag(CF_ALLOW_GROUP_INVITES);
  8821. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting group invites.", player->get_character_flag(CF_ALLOW_GROUP_INVITES)?"now":"no longer");
  8822. }
  8823. void Commands::Command_Toggle_Raids(Client* client)
  8824. {
  8825. Player* player = client->GetPlayer();
  8826. player->toggle_character_flag(CF_ALLOW_RAID_INVITES);
  8827. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting raid invites.", player->get_character_flag(CF_ALLOW_RAID_INVITES)?"now":"no longer");
  8828. }
  8829. void Commands::Command_Toggle_LON(Client* client)
  8830. {
  8831. Player* player = client->GetPlayer();
  8832. player->toggle_character_flag(CF2_ALLOW_LON_INVITES);
  8833. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting LoN invites.", player->get_character_flag(CF2_ALLOW_LON_INVITES)?"now":"no longer");
  8834. }
  8835. void Commands::Command_Toggle_VoiceChat(Client* client)
  8836. {
  8837. Player* player = client->GetPlayer();
  8838. player->toggle_character_flag(CF2_ALLOW_VOICE_INVITES);
  8839. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting voice chat invites.", player->get_character_flag(CF2_ALLOW_VOICE_INVITES)?"now":"no longer");
  8840. }
  8841. /*
  8842. Function: Command_TradeStart()
  8843. Purpose : Starts item/coin trade between players
  8844. Params :
  8845. Dev :
  8846. Example :
  8847. */
  8848. #include "../Trade.h"
  8849. void Commands::Command_TradeStart(Client* client, Seperator* sep)
  8850. {
  8851. PrintSep(sep, "COMMAND_START_TRADE");
  8852. Entity* trader = client->GetPlayer();
  8853. Entity* trader2 = 0;
  8854. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  8855. Spawn* spawn = client->GetPlayer()->GetSpawnWithPlayerID(atoi(sep->arg[0]));
  8856. if (spawn) {
  8857. if (spawn->IsEntity())
  8858. trader2 = (Entity*)spawn;
  8859. }
  8860. }
  8861. else if (client->GetPlayer()->GetTarget()) {
  8862. if (client->GetPlayer()->GetTarget()->IsEntity())
  8863. trader2 = (Entity*)client->GetPlayer()->GetTarget();
  8864. }
  8865. // can only trade with player or bots
  8866. if (trader && trader2) {
  8867. if (trader == trader2) {
  8868. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade with yourself.");
  8869. }
  8870. else if (trader2->IsPlayer() || trader2->IsBot()) {
  8871. LogWrite(PLAYER__ERROR, 0, "Trade", "creating trade");
  8872. if (trader->trade)
  8873. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are already trading.");
  8874. else if (trader2->trade)
  8875. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is already trading.");
  8876. else {
  8877. Trade* trade = new Trade(trader, trader2);
  8878. trader->trade = trade;
  8879. trader2->trade = trade;
  8880. }
  8881. }
  8882. else {
  8883. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can only trade with another player or a bot.");
  8884. }
  8885. }
  8886. else
  8887. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to find target");
  8888. }
  8889. /*
  8890. Function: Command_Track()
  8891. Purpose : Starts/Stops Tracking for a player
  8892. Params :
  8893. Dev : Scatman
  8894. Example : /track
  8895. */
  8896. void Commands::Command_Track(Client* client)
  8897. {
  8898. if (!client->GetPlayer()->GetIsTracking())
  8899. client->GetPlayer()->GetZone()->AddPlayerTracking(client->GetPlayer());
  8900. else
  8901. client->GetPlayer()->GetZone()->RemovePlayerTracking(client->GetPlayer(), TRACKING_STOP);
  8902. }
  8903. /*
  8904. Function: Command_TradeAccept()
  8905. Purpose : Accepts item/coin trade between players
  8906. Params :
  8907. Dev :
  8908. Example :
  8909. */
  8910. void Commands::Command_TradeAccept(Client* client, Seperator* sep)
  8911. {
  8912. PrintSep(sep, "COMMAND_ACCEPT_TRADE");
  8913. Trade* trade = client->GetPlayer()->trade;
  8914. if (trade) {
  8915. bool trade_complete = trade->SetTradeAccepted(client->GetPlayer());
  8916. if (trade_complete)
  8917. safe_delete(trade);
  8918. }
  8919. else
  8920. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8921. }
  8922. /*
  8923. Function: Command_TradeReject()
  8924. Purpose : Rejects item/coin trade between players
  8925. Params :
  8926. Dev :
  8927. Example :
  8928. */
  8929. void Commands::Command_TradeReject(Client* client, Seperator* sep)
  8930. {
  8931. PrintSep(sep, "COMMAND_REJECT_TRADE");
  8932. Command_TradeCancel(client, sep);
  8933. }
  8934. /*
  8935. Function: Command_TradeCancel()
  8936. Purpose : Cancels item/coin trade between players
  8937. Params :
  8938. Dev :
  8939. Example :
  8940. */
  8941. void Commands::Command_TradeCancel(Client* client, Seperator* sep)
  8942. {
  8943. PrintSep(sep, "COMMAND_CANCEL_TRADE");
  8944. Trade* trade = client->GetPlayer()->trade;
  8945. if (trade) {
  8946. trade->CancelTrade(client->GetPlayer());
  8947. safe_delete(trade);
  8948. }
  8949. else
  8950. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8951. }
  8952. /*
  8953. Function: Command_TradeSetCoin()
  8954. Purpose : Sets coin trade between players
  8955. Params :
  8956. Dev :
  8957. Example :
  8958. */
  8959. void Commands::Command_TradeSetCoin(Client* client, Seperator* sep)
  8960. {
  8961. PrintSep(sep, "COMMAND_SET_TRADE_COIN");
  8962. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Set Trade Coin");
  8963. client->Message(CHANNEL_COLOR_YELLOW, "You cannot trade with other players (Not Implemented)");
  8964. }
  8965. /*
  8966. Function: Command_TradeAddCoin()
  8967. Purpose : Adds coin to trade between players
  8968. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  8969. Dev :
  8970. Example :
  8971. */
  8972. void Commands::Command_TradeAddCoin(Client* client, Seperator* sep, int handler)
  8973. {
  8974. PrintSep(sep, "COMMAND_ADD_TRADE_{coin type}");
  8975. Trade* trade = client->GetPlayer()->trade;
  8976. if (trade) {
  8977. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  8978. int32 amount = atoi(sep->arg[0]);
  8979. int64 val = 0;
  8980. switch (handler) {
  8981. case COMMAND_ADD_TRADE_COPPER:
  8982. {
  8983. val = amount;
  8984. trade->AddCoinToTrade(client->GetPlayer(), val);
  8985. break;
  8986. }
  8987. case COMMAND_ADD_TRADE_SILVER:
  8988. {
  8989. val = amount * 100;
  8990. trade->AddCoinToTrade(client->GetPlayer(), val);
  8991. break;
  8992. }
  8993. case COMMAND_ADD_TRADE_GOLD:
  8994. {
  8995. val = amount * 10000;
  8996. trade->AddCoinToTrade(client->GetPlayer(), val);
  8997. break;
  8998. }
  8999. case COMMAND_ADD_TRADE_PLAT:
  9000. {
  9001. val = amount * 1000000;
  9002. trade->AddCoinToTrade(client->GetPlayer(), val);
  9003. break;
  9004. }
  9005. default:
  9006. {
  9007. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  9008. break;
  9009. }
  9010. }
  9011. }
  9012. else
  9013. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount.");
  9014. }
  9015. else
  9016. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  9017. }
  9018. /*
  9019. Function: Command_TradeRemoveCoin()
  9020. Purpose : Removes coin from trade between players
  9021. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  9022. Dev :
  9023. Example :
  9024. */
  9025. void Commands::Command_TradeRemoveCoin(Client* client, Seperator* sep, int handler)
  9026. {
  9027. PrintSep(sep, "COMMAND_REMOVE_TRADE_{coin type}");
  9028. Trade* trade = client->GetPlayer()->trade;
  9029. if (trade) {
  9030. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  9031. int32 amount = atoi(sep->arg[0]);
  9032. int64 val = 0;
  9033. switch (handler) {
  9034. case COMMAND_REMOVE_TRADE_COPPER:
  9035. {
  9036. val = amount;
  9037. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  9038. break;
  9039. }
  9040. case COMMAND_REMOVE_TRADE_SILVER:
  9041. {
  9042. val = amount * 100;
  9043. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  9044. break;
  9045. }
  9046. case COMMAND_REMOVE_TRADE_GOLD:
  9047. {
  9048. val = amount * 10000;
  9049. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  9050. break;
  9051. }
  9052. case COMMAND_REMOVE_TRADE_PLAT:
  9053. {
  9054. val = amount * 1000000;
  9055. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  9056. break;
  9057. }
  9058. default:
  9059. {
  9060. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  9061. break;
  9062. }
  9063. }
  9064. }
  9065. else
  9066. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount");
  9067. }
  9068. else
  9069. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  9070. }
  9071. /*
  9072. Function: Command_TradeAddItem()
  9073. Purpose : Adds item to trade between players
  9074. Params :
  9075. Dev :
  9076. Example :
  9077. */
  9078. void Commands::Command_TradeAddItem(Client* client, Seperator* sep)
  9079. {
  9080. PrintSep(sep, "COMMAND_ADD_TRADE_ITEM");
  9081. /*
  9082. arg[0] = item index
  9083. arg[1] = slot
  9084. arg[2] = quantity
  9085. */
  9086. if (!client->GetPlayer()->trade) {
  9087. LogWrite(PLAYER__ERROR, 0, "Trade", "Player is not currently trading.");
  9088. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  9089. return;
  9090. }
  9091. if (sep && sep->IsSet(0) && sep->IsNumber(0) && sep->IsSet(1) && sep->IsNumber(1) && sep->IsSet(2) && sep->IsNumber(2)) {
  9092. Item* item = 0;
  9093. int32 index = atoi(sep->arg[0]);
  9094. item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(index);
  9095. if (item) {
  9096. int8 result = client->GetPlayer()->trade->AddItemToTrade(client->GetPlayer(), item, atoi(sep->arg[2]), atoi(sep->arg[1]));
  9097. if (result == 1)
  9098. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Item is already being traded.");
  9099. else if (result == 2)
  9100. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade NO-TRADE items.");
  9101. else if (result == 3)
  9102. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade HEIRLOOM items.");
  9103. else if (result == 255)
  9104. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown error trying to add the item to the trade...");
  9105. }
  9106. else {
  9107. LogWrite(PLAYER__ERROR, 0, "Trade", "Unable to get an item for the player (%s) from the index (%u)", client->GetPlayer()->GetName(), index);
  9108. client->Message(CHANNEL_ERROR, "Unable to find item at index %u", index);
  9109. }
  9110. }
  9111. else
  9112. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  9113. }
  9114. /*
  9115. Function: Command_TradeRemoveItem()
  9116. Purpose : Removes item from trade between players
  9117. Params :
  9118. Dev :
  9119. Example :
  9120. */
  9121. void Commands::Command_TradeRemoveItem(Client* client, Seperator* sep)
  9122. {
  9123. PrintSep(sep, "COMMAND_REMOVE_TRADE_ITEM");
  9124. /*
  9125. arg[0] = trade window slot
  9126. */
  9127. Trade* trade = client->GetPlayer()->trade;
  9128. if (trade) {
  9129. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  9130. trade->RemoveItemFromTrade(client->GetPlayer(), atoi(sep->arg[0]));
  9131. }
  9132. else
  9133. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  9134. }
  9135. else
  9136. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  9137. }
  9138. void Commands::Command_TryOn(Client* client, Seperator* sep)
  9139. {
  9140. Item *item = 0;
  9141. sint32 crc;
  9142. if (sep) {
  9143. // 1096+ sends more info so need to do a version check so older clients (SF) still work
  9144. if (client->GetVersion() < 1096) {
  9145. if (sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2))
  9146. {
  9147. item = master_item_list.GetItem(atoul(sep->arg[1]));
  9148. crc = atol(sep->arg[2]);
  9149. }
  9150. }
  9151. else {
  9152. // From the broker and links in chat
  9153. if (strcmp(sep->arg[0], "crc") == 0) {
  9154. if (sep->IsNumber(2) && sep->IsNumber(3)) {
  9155. item = master_item_list.GetItem(atoul(sep->arg[2]));
  9156. crc = atol(sep->arg[3]);
  9157. }
  9158. }
  9159. // From inventory
  9160. if (strcmp(sep->arg[0], "dbid") == 0) {
  9161. if (sep->IsNumber(2) && sep->IsNumber(4)) {
  9162. item = master_item_list.GetItem(atoul(sep->arg[2]));
  9163. crc = atol(sep->arg[4]);
  9164. }
  9165. }
  9166. }
  9167. if (item)
  9168. client->ShowDressingRoom(item, crc);
  9169. }
  9170. }
  9171. void Commands::Command_JoinChannel(Client * client, Seperator *sep) {
  9172. const char *channel_name, *password = NULL;
  9173. if (sep == NULL || !sep->IsSet(0)) {
  9174. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /joinchannel <channel name> [password]");
  9175. return;
  9176. }
  9177. channel_name = sep->arg[0];
  9178. if (sep->IsSet(1))
  9179. password = sep->arg[1];
  9180. if (!chat.ChannelExists(channel_name) && !chat.CreateChannel(channel_name, password)) {
  9181. client->Message(CHANNEL_COLOR_RED, "Unable to create channel '%s'.", channel_name);
  9182. return;
  9183. }
  9184. if (chat.IsInChannel(client, channel_name)) {
  9185. client->Message(CHANNEL_NARRATIVE, "You are already in '%s'.", channel_name);
  9186. return;
  9187. }
  9188. if (chat.HasPassword(channel_name)) {
  9189. if (password == NULL) {
  9190. client->Message(CHANNEL_NARRATIVE, "Unable to join '%s': That channel is password protected.", channel_name);
  9191. return;
  9192. }
  9193. if (!chat.PasswordMatches(channel_name, password)) {
  9194. client->Message(CHANNEL_NARRATIVE, "Unable to join '%s': The password is not correc.t", channel_name);
  9195. return;
  9196. }
  9197. }
  9198. if (!chat.JoinChannel(client, channel_name))
  9199. client->Message(CHANNEL_COLOR_RED, "There was an internal error preventing you from joining '%s'.", channel_name);
  9200. }
  9201. void Commands::Command_JoinChannelFromLoad(Client * client, Seperator *sep) {
  9202. printf("ScatDebug: Received 'joinfromchannel', using the same function as 'joinchannel' (not sure what the difference is)\n");
  9203. Command_JoinChannel(client, sep);
  9204. }
  9205. void Commands::Command_TellChannel(Client *client, Seperator *sep) {
  9206. if (sep == NULL || !sep->IsSet(0) || !sep->IsSet(1)) {
  9207. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /tellchannel <channel name> <message>");
  9208. PrintSep(sep, "tellchannel");
  9209. return;
  9210. }
  9211. chat.TellChannel(client, sep->arg[0], sep->argplus[1]);
  9212. }
  9213. void Commands::Command_Test(Client* client, EQ2_16BitString* command_parms) {
  9214. Seperator* sep = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  9215. if (sep->IsSet(0)) {
  9216. if (atoi(sep->arg[0]) == 1) {
  9217. PacketStruct* packet2 = configReader.getStruct("WS_SpellGainedMsg", client->GetVersion());
  9218. if (packet2) {
  9219. packet2->setDataByName("spell_type", 2);
  9220. packet2->setDataByName("spell_id", 8308);
  9221. packet2->setDataByName("spell_name", "Sprint");
  9222. packet2->setDataByName("add_silently", 0);
  9223. packet2->setDataByName("tier", 1);
  9224. packet2->setDataByName("blah1", 1);
  9225. packet2->setDataByName("blah2", 1);
  9226. EQ2Packet* outapp = packet2->serialize();
  9227. DumpPacket(outapp);
  9228. client->QueuePacket(outapp);
  9229. safe_delete(packet2);
  9230. }
  9231. }
  9232. else if (atoi(sep->arg[0]) == 2) {
  9233. PacketStruct* packet2 = configReader.getStruct("WS_GuildUpdate", client->GetVersion());
  9234. if (packet2) {
  9235. packet2->setDataByName("guild_name", "Test");
  9236. packet2->setDataByName("guild_motd", "Test MOTD");
  9237. packet2->setDataByName("guild_id", 1234);
  9238. packet2->setDataByName("guild_level", 1);
  9239. packet2->setDataByName("unknown", 2);
  9240. packet2->setDataByName("unknown2", 3);
  9241. packet2->setDataByName("exp_current", 1);
  9242. packet2->setDataByName("exp_to_next_level", 4);
  9243. EQ2Packet* outapp = packet2->serialize();
  9244. DumpPacket(outapp);
  9245. client->QueuePacket(outapp);
  9246. safe_delete(packet2);
  9247. }
  9248. }
  9249. else if (atoi(sep->arg[0]) == 3) {
  9250. PacketStruct* packet2 = configReader.getStruct("WS_JoinGuildNotify", client->GetVersion());
  9251. if (packet2) {
  9252. packet2->setDataByName("guild_id", 1234);
  9253. packet2->setDataByName("character_id", 1);
  9254. packet2->setDataByName("account_id", 2);
  9255. packet2->setDataByName("guild_level", 1);
  9256. packet2->setDataByName("name", "Test");
  9257. packet2->setDataByName("unknown2", 0);
  9258. packet2->setDataByName("unknown3", 1);
  9259. packet2->setDataByName("adventure_class", 6);
  9260. packet2->setDataByName("adventure_level", 7);
  9261. packet2->setDataByName("tradeskill_class", 4);
  9262. packet2->setDataByName("tradeskill_level", 5);
  9263. packet2->setDataByName("rank", 0);
  9264. packet2->setDataByName("member_flags", 2);
  9265. packet2->setDataByName("join_date", 1591112273);
  9266. packet2->setDataByName("guild_status", 2);
  9267. packet2->setDataByName("last_login", 1591132273);
  9268. packet2->setDataByName("recruiter_id", 1);
  9269. packet2->setDataByName("points", 2345);
  9270. packet2->setDataByName("note", "note");
  9271. packet2->setMediumStringByName("officer_note", "O note");
  9272. packet2->setMediumStringByName("zone", "Blah");
  9273. EQ2Packet* outapp = packet2->serialize();
  9274. DumpPacket(outapp);
  9275. client->QueuePacket(outapp);
  9276. safe_delete(packet2);
  9277. }
  9278. }
  9279. else if (atoi(sep->arg[0]) == 5) {
  9280. int16 offset = atoi(sep->arg[1]);
  9281. int32 value1 = atol(sep->arg[2]);
  9282. EQ2Packet* outapp = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion(), offset, value1);
  9283. client->QueuePacket(outapp);
  9284. }
  9285. else if (atoi(sep->arg[0]) == 6) {
  9286. Spawn* spawn = client->GetPlayer()->GetTarget();
  9287. if (!spawn)
  9288. spawn = client->GetPlayer();
  9289. else if (spawn->IsEntity())
  9290. ((Entity*)spawn)->SetSpeed(atof(sep->arg[4]));
  9291. spawn->RunToLocation(atof(sep->arg[1]), atof(sep->arg[2]), atof(sep->arg[3]));
  9292. }
  9293. else if (atoi(sep->arg[0]) == 7) {
  9294. int32 id = 0;
  9295. Spawn* spawn = client->GetCurrentZone()->GetSpawn(7720001);
  9296. if (spawn) {
  9297. spawn->SetX(client->GetPlayer()->GetX() + .5, false);
  9298. spawn->SetY(client->GetPlayer()->GetY(), false);
  9299. spawn->SetZ(client->GetPlayer()->GetZ() + .5, false);
  9300. float heading = client->GetPlayer()->GetHeading() + 180;
  9301. if (heading > 360)
  9302. heading -= 360;
  9303. spawn->SetLevel(5);
  9304. spawn->SetAdventureClass(4);
  9305. spawn->SetHeading(heading, false);
  9306. spawn->SetSpawnOrigX(spawn->GetX());
  9307. spawn->SetSpawnOrigY(spawn->GetY());
  9308. spawn->SetSpawnOrigZ(spawn->GetZ());
  9309. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  9310. spawn->SetLocation(client->GetPlayer()->GetLocation());
  9311. spawn->appearance.targetable = 1;
  9312. if (spawn->IsNPC() && spawn->GetTotalHP() == 0) {
  9313. spawn->SetTotalHP(spawn->GetLevel() * 15);
  9314. spawn->SetHP(spawn->GetTotalHP());
  9315. }
  9316. if (spawn->GetTotalPower() == 0) {
  9317. spawn->SetTotalPower(spawn->GetLevel() * 15);
  9318. spawn->SetPower(spawn->GetTotalPower());
  9319. }
  9320. int16 offset = atoi(sep->arg[1]);
  9321. int32 value1 = atol(sep->arg[2]);
  9322. sprintf(spawn->appearance.name, "Offset %i", offset);
  9323. EQ2Packet* ret = spawn->spawn_serialize(client->GetPlayer(), client->GetVersion(), offset, value1);
  9324. DumpPacket(ret);
  9325. client->QueuePacket(ret);
  9326. }
  9327. }
  9328. else if (atoi(sep->arg[0]) == 8) {
  9329. int32 id = atoi(sep->arg[1]);
  9330. Spawn* spawn = client->GetCurrentZone()->GetSpawn(id);
  9331. if (spawn) {
  9332. spawn->SetX(client->GetPlayer()->GetX() + .5, false);
  9333. spawn->SetY(client->GetPlayer()->GetY(), false);
  9334. spawn->SetZ(client->GetPlayer()->GetZ() + .5, false);
  9335. float heading = client->GetPlayer()->GetHeading() + 180;
  9336. if (heading > 360)
  9337. heading -= 360;
  9338. spawn->SetLevel(5);
  9339. spawn->SetAdventureClass(4);
  9340. spawn->SetHeading(heading, false);
  9341. spawn->SetSpawnOrigX(spawn->GetX());
  9342. spawn->SetSpawnOrigY(spawn->GetY());
  9343. spawn->SetSpawnOrigZ(spawn->GetZ());
  9344. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  9345. spawn->SetLocation(client->GetPlayer()->GetLocation());
  9346. spawn->appearance.targetable = 1;
  9347. if (spawn->IsNPC() && spawn->GetTotalHP() == 0) {
  9348. spawn->SetTotalHP(spawn->GetLevel() * 15);
  9349. spawn->SetHP(spawn->GetTotalHP());
  9350. }
  9351. if (spawn->GetTotalPower() == 0) {
  9352. spawn->SetTotalPower(spawn->GetLevel() * 15);
  9353. spawn->SetPower(spawn->GetTotalPower());
  9354. }
  9355. int16 offset = atoi(sep->arg[2]);
  9356. int16 offset2 = atoi(sep->arg[3]);
  9357. int32 value1 = atol(sep->arg[4]);
  9358. int16 offset3 = 0;
  9359. int16 offset4 = 0;
  9360. int32 value2 = 0;
  9361. if (sep->IsSet(7)) {
  9362. offset3 = atoi(sep->arg[5]);
  9363. offset4 = atoi(sep->arg[6]);
  9364. value2 = atol(sep->arg[7]);
  9365. }
  9366. sprintf(spawn->appearance.name, "Offset %i to %i", offset, offset2);
  9367. spawn->AddPrimaryEntityCommand("attack", 10000, "attack","", 0, 0);
  9368. EQ2Packet* ret = spawn->spawn_serialize(client->GetPlayer(), client->GetVersion(), offset, value1, offset2, offset3, offset4, value2);
  9369. DumpPacket(ret);
  9370. client->QueuePacket(ret);
  9371. }
  9372. }
  9373. else if (atoi(sep->arg[0]) == 9) {
  9374. PacketStruct* packet2 = configReader.getStruct("WS_DeathWindow", client->GetVersion());
  9375. if (packet2) {
  9376. packet2->setArrayLengthByName("location_count", 1);
  9377. packet2->setArrayDataByName("location_ida", 1234);
  9378. packet2->setArrayDataByName("unknown2a", 3);
  9379. packet2->setArrayDataByName("zone_name", "Queen's Colony");
  9380. packet2->setArrayDataByName("location_name", "Myrrin's Tower");
  9381. packet2->setArrayDataByName("distance", 134);
  9382. EQ2Packet* app = packet2->serialize();
  9383. if (sep->IsSet(2)) {
  9384. int8 offset = atoi(sep->arg[1]);
  9385. uchar* ptr2 = app->pBuffer;
  9386. ptr2 += offset;
  9387. if (sep->IsNumber(2)) {
  9388. int32 value1 = atol(sep->arg[2]);
  9389. if (value1 > 0xFFFF)
  9390. memcpy(ptr2, (uchar*)&value1, 4);
  9391. else if (value1 > 0xFF)
  9392. memcpy(ptr2, (uchar*)&value1, 2);
  9393. else
  9394. memcpy(ptr2, (uchar*)&value1, 1);
  9395. }
  9396. else {
  9397. int8 len = strlen(sep->arg[2]);
  9398. memcpy(ptr2, (uchar*)&len, 1);
  9399. ptr2 += 1;
  9400. memcpy(ptr2, sep->arg[2], len);
  9401. }
  9402. }
  9403. DumpPacket(app);
  9404. client->QueuePacket(app);
  9405. safe_delete(packet2);
  9406. }
  9407. }
  9408. else if (atoi(sep->arg[0]) == 10) {
  9409. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalUpdate", client->GetVersion());
  9410. if (packet2) {
  9411. packet2->setArrayLengthByName("num_quests", 1);
  9412. packet2->setArrayDataByName("active", 1);
  9413. packet2->setArrayDataByName("name", "Tasks aboard the Far Journey");
  9414. packet2->setArrayDataByName("quest_type", "Hallmark");
  9415. packet2->setArrayDataByName("quest_zone", "Hallmark");
  9416. packet2->setArrayDataByName("journal_updated", 1);
  9417. packet2->setArrayDataByName("quest_id", 524);
  9418. packet2->setArrayDataByName("day", 19);
  9419. packet2->setArrayDataByName("month", 6);
  9420. packet2->setArrayDataByName("year", 20);
  9421. packet2->setArrayDataByName("level", 2);
  9422. packet2->setArrayDataByName("encounter_level", 4);
  9423. packet2->setArrayDataByName("difficulty", 3);
  9424. packet2->setArrayDataByName("visible", 1);
  9425. packet2->setDataByName("visible_quest_id", 524);
  9426. packet2->setDataByName("player_crc", 2900677088);
  9427. packet2->setDataByName("player_name", "LethalEncounter");
  9428. EQ2Packet* app = packet2->serialize();
  9429. if (sep->IsSet(2)) {
  9430. int8 offset = atoi(sep->arg[1]);
  9431. uchar* ptr2 = app->pBuffer;
  9432. ptr2 += offset;
  9433. if (sep->IsNumber(2)) {
  9434. int32 value1 = atol(sep->arg[2]);
  9435. if (value1 > 0xFFFF)
  9436. memcpy(ptr2, (uchar*)&value1, 4);
  9437. else if (value1 > 0xFF)
  9438. memcpy(ptr2, (uchar*)&value1, 2);
  9439. else
  9440. memcpy(ptr2, (uchar*)&value1, 1);
  9441. }
  9442. else {
  9443. int8 len = strlen(sep->arg[2]);
  9444. memcpy(ptr2, (uchar*)&len, 1);
  9445. ptr2 += 1;
  9446. memcpy(ptr2, sep->arg[2], len);
  9447. }
  9448. }
  9449. DumpPacket(app);
  9450. client->QueuePacket(app);
  9451. safe_delete(packet2);
  9452. }
  9453. }
  9454. else if (atoi(sep->arg[0]) == 11) {
  9455. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalReply", client->GetVersion());
  9456. if (packet2) {
  9457. packet2->setDataByName("quest_id", 524);
  9458. packet2->setDataByName("player_crc", 2900677088);
  9459. packet2->setDataByName("name", "Tasks aboard the Far Journey");
  9460. packet2->setDataByName("description", "I completed all the tasks assigned to me by Captain Varlos aboard the Far Journey");
  9461. packet2->setDataByName("type", "Hallmark");
  9462. packet2->setDataByName("complete_header", "To complete this quest, I must do the following tasks:");
  9463. packet2->setDataByName("day", 19);
  9464. packet2->setDataByName("month", 6);
  9465. packet2->setDataByName("year", 20);
  9466. packet2->setDataByName("level", 1);
  9467. packet2->setDataByName("encounter_level", 1);
  9468. packet2->setDataByName("difficulty", 1);
  9469. packet2->setDataByName("time_obtained", Timer::GetUnixTimeStamp());
  9470. //packet2->setDataByName("timer_start", Timer::GetUnixTimeStamp());
  9471. //packet2->setDataByName("timer_duration", 300);
  9472. //packet2->setDataByName("timer_running", 1);
  9473. packet2->setArrayLengthByName("task_groups_completed", 9);
  9474. packet2->setArrayLengthByName("num_task_groups", 10);
  9475. packet2->setArrayDataByName("task_group", "I spoke to Waulon as Captain Varlos had asked of me.");
  9476. packet2->setArrayDataByName("task_group", "I found Waulon's hat in one of the boxes.", 1);
  9477. packet2->setArrayDataByName("task_group", "I returned Waulon's hat.", 2);
  9478. packet2->setArrayDataByName("task_group", "I have spoken to Ingrid.", 3);
  9479. packet2->setArrayDataByName("task_group", "I purchased a Shard of Luclin.", 4);
  9480. packet2->setArrayDataByName("task_group", "I gave the Shard of Luclin to Ingrid.", 5);
  9481. packet2->setArrayDataByName("task_group", "I have spoken to Captain Varlos.", 6);
  9482. packet2->setArrayDataByName("task_group", "I killed the rats that Captain Varlos requested.", 7);
  9483. packet2->setArrayDataByName("task_group", "Captain Varlos has ordered you to kill the escaped goblin.", 8);
  9484. packet2->setArrayDataByName("task_group", "I killed the escaped goblin.", 9);
  9485. /*packet2->setSubArrayLengthByName("num_tasks", 1);
  9486. packet2->setSubArrayDataByName("task", "I need to talk to Garven Tralk");
  9487. packet2->setSubArrayLengthByName("num_updates", 1);
  9488. packet2->setSubArrayDataByName("update_currentval", 0);
  9489. packet2->setSubArrayDataByName("update_maxval", 1);
  9490. packet2->setSubArrayDataByName("icon", 11);
  9491. */
  9492. packet2->setArrayDataByName("waypoint", 0xFFFFFFFF);
  9493. packet2->setDataByName("journal_updated", 1);
  9494. packet2->setDataByName("bullets", 1);
  9495. EQ2Packet* app = packet2->serialize();
  9496. if (sep->IsSet(2)) {
  9497. int16 offset = atoi(sep->arg[1]);
  9498. uchar* ptr2 = app->pBuffer;
  9499. ptr2 += offset;
  9500. if (sep->IsNumber(2)) {
  9501. int32 value1 = atol(sep->arg[2]);
  9502. if (value1 > 0xFFFF)
  9503. memcpy(ptr2, (uchar*)&value1, 4);
  9504. else if (value1 > 0xFF)
  9505. memcpy(ptr2, (uchar*)&value1, 2);
  9506. else
  9507. memcpy(ptr2, (uchar*)&value1, 1);
  9508. }
  9509. else {
  9510. int16 len = strlen(sep->arg[2]);
  9511. memcpy(ptr2, (uchar*)&len, 2);
  9512. ptr2 += 2;
  9513. memcpy(ptr2, sep->arg[2], len);
  9514. }
  9515. }
  9516. DumpPacket(app);
  9517. client->QueuePacket(app);
  9518. safe_delete(packet2);
  9519. }
  9520. }
  9521. else if (atoi(sep->arg[0]) == 12) {
  9522. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalReply", client->GetVersion());
  9523. if (packet2) {
  9524. packet2->setDataByName("quest_id", 524);
  9525. packet2->setDataByName("player_crc", 2900677088);
  9526. packet2->setDataByName("name", "Archetype Selection");
  9527. packet2->setDataByName("description", "I have reported my profession to Garven Tralk.");
  9528. packet2->setDataByName("type", "Hallmark");
  9529. packet2->setDataByName("complete_header", "To complete this quest, I must do the following tasks:");
  9530. packet2->setDataByName("day", 19);
  9531. packet2->setDataByName("month", 6);
  9532. packet2->setDataByName("year", 20);
  9533. packet2->setDataByName("level", 2);
  9534. packet2->setDataByName("encounter_level", 4);
  9535. packet2->setDataByName("difficulty", 3);
  9536. packet2->setDataByName("time_obtained", Timer::GetUnixTimeStamp());
  9537. packet2->setDataByName("timer_start", Timer::GetUnixTimeStamp());
  9538. packet2->setDataByName("timer_duration", 300);
  9539. packet2->setDataByName("timer_running", 1);
  9540. packet2->setArrayLengthByName("task_groups_completed", 0);
  9541. packet2->setArrayLengthByName("num_task_groups", 1);
  9542. packet2->setArrayDataByName("task_group", "I need to talk to Garven Tralk");
  9543. packet2->setSubArrayLengthByName("num_tasks", 1);
  9544. packet2->setSubArrayDataByName("task", "I need to talk to Garven Tralk");
  9545. packet2->setSubArrayLengthByName("num_updates", 1);
  9546. packet2->setSubArrayDataByName("update_currentval", 0);
  9547. packet2->setSubArrayDataByName("update_maxval", 1);
  9548. packet2->setSubArrayDataByName("icon", 11);
  9549. packet2->setArrayDataByName("waypoint", 0xFFFFFFFF);
  9550. packet2->setDataByName("journal_updated", 1);
  9551. packet2->setSubstructDataByName("reward_data", "unknown1", 255);
  9552. packet2->setSubstructDataByName("reward_data", "reward", "Quest Reward!");
  9553. packet2->setSubstructDataByName("reward_data", "unknown2", 0x3f);
  9554. packet2->setSubstructDataByName("reward_data", "coin", 150);
  9555. packet2->setSubstructDataByName("reward_data", "status_points", 5);
  9556. packet2->setSubstructDataByName("reward_data", "exp_bonus", 10);
  9557. packet2->setSubstructArrayLengthByName("reward_data", "num_rewards", 1);
  9558. packet2->setSubstructArrayDataByName("reward_data", "reward_id", 123);
  9559. Item* item = master_item_list.GetItem(152755);
  9560. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9561. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  9562. /*packet2->setSubstructDataByName("item", "unique_id", 567);
  9563. packet2->setSubstructDataByName("item", "broker_item_id", 0xFFFFFFFFFFFFFFFF);
  9564. packet2->setSubstructDataByName("item", "icon", 0xe7);
  9565. packet2->setSubstructDataByName("item", "tier", 4);
  9566. packet2->setSubstructDataByName("item", "flags", 0x60);
  9567. packet2->setSubstructArrayLengthByName("item", "stat_count", 1);
  9568. packet2->setSubstructDataByName("item", "stat_type", 1);
  9569. packet2->setSubstructDataByName("item", "stat_subtype", 2);
  9570. packet2->setSubstructDataByName("item", "value", 3);
  9571. packet2->setSubstructDataByName("item", "condition", 100);
  9572. packet2->setSubstructDataByName("item", "weight", 1);
  9573. packet2->setSubstructDataByName("item", "skill_req1", 0xacafa99e);
  9574. packet2->setSubstructDataByName("item", "skill_req2", 0xacafa99e);
  9575. packet2->setSubstructDataByName("item", "skill_min", 1);
  9576. packet2->setSubstructArrayLengthByName("item", "class_count", 3);
  9577. packet2->setSubstructDataByName("item", "adventure_class", 1);
  9578. packet2->setSubstructDataByName("item", "adventure_class", 11, 0, 1);
  9579. packet2->setSubstructDataByName("item", "adventure_class", 0x1f, 0, 2);
  9580. packet2->setSubstructDataByName("item", "tradeskill_class", 255);
  9581. packet2->setSubstructDataByName("item", "tradeskill_class", 255, 0, 1);
  9582. packet2->setSubstructDataByName("item", "tradeskill_class", 255, 0, 2);
  9583. packet2->setSubstructDataByName("item", "level", 0x1e);
  9584. packet2->setSubstructDataByName("item", "level", 100, 0, 1);
  9585. packet2->setSubstructDataByName("item", "level", 100, 0, 2);
  9586. packet2->setSubstructDataByName("item_footer", "name", "Footman Gloves");*/
  9587. //packet2->PrintPacket();
  9588. EQ2Packet* app = packet2->serialize();
  9589. if (sep->IsSet(2)) {
  9590. int16 offset = atoi(sep->arg[1]);
  9591. uchar* ptr2 = app->pBuffer;
  9592. ptr2 += offset;
  9593. if (sep->IsNumber(2)) {
  9594. int32 value1 = atol(sep->arg[2]);
  9595. if (value1 > 0xFFFF)
  9596. memcpy(ptr2, (uchar*)&value1, 4);
  9597. else if (value1 > 0xFF)
  9598. memcpy(ptr2, (uchar*)&value1, 2);
  9599. else
  9600. memcpy(ptr2, (uchar*)&value1, 1);
  9601. }
  9602. else {
  9603. int16 len = strlen(sep->arg[2]);
  9604. memcpy(ptr2, (uchar*)&len, 2);
  9605. ptr2 += 2;
  9606. memcpy(ptr2, sep->arg[2], len);
  9607. }
  9608. }
  9609. DumpPacket(app);
  9610. client->QueuePacket(app);
  9611. safe_delete(packet2);
  9612. }
  9613. }
  9614. else if (atoi(sep->arg[0]) == 13) {
  9615. PacketStruct* packet2 = configReader.getStruct("WS_OnScreenMsg", client->GetVersion());
  9616. if (packet2 && sep->IsSet(7)) {
  9617. packet2->setDataByName("unknown", atoi(sep->arg[1]));
  9618. char blah[128];
  9619. sprintf(blah, "\\#6EFF6EYou get better at \12\\#C8FFC8%s\\#6EFF6E! (7/15)", sep->arg[2]);
  9620. packet2->setDataByName("text", blah);
  9621. packet2->setDataByName("message_type", sep->arg[3]);
  9622. packet2->setDataByName("size", atof(sep->arg[4]));
  9623. packet2->setDataByName("red", atoi(sep->arg[5]));
  9624. packet2->setDataByName("green", atoi(sep->arg[6]));
  9625. packet2->setDataByName("blue", atoi(sep->arg[7]));
  9626. EQ2Packet* app = packet2->serialize();
  9627. DumpPacket(app);
  9628. client->QueuePacket(app);
  9629. safe_delete(packet2);
  9630. }
  9631. }
  9632. else if (atoi(sep->arg[0]) == 14) {
  9633. PacketStruct* packet2 = configReader.getStruct("WS_InstructionWindow", client->GetVersion());
  9634. if (packet2 && sep->IsSet(3)) {
  9635. packet2->setDataByName("open_seconds_min", atof(sep->arg[1]));
  9636. packet2->setDataByName("open_seconds_max", atof(sep->arg[2]));
  9637. packet2->setDataByName("voice_sync", atoi(sep->arg[3]));
  9638. 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.");
  9639. packet2->setDataByName("voice", "voiceover/english/narrator/boat_06p_tutorial02/narrator_001_63779ca0.mp3");
  9640. packet2->setArrayLengthByName("num_goals", 1);
  9641. //packet2->setArrayDataByName("goal_text", )
  9642. packet2->setSubArrayLengthByName("num_tasks", 1);
  9643. packet2->setSubArrayDataByName("task_text", "continue");
  9644. packet2->setDataByName("complete_sound", "click");
  9645. packet2->setDataByName("signal", "introduction");
  9646. packet2->setDataByName("voice_key1", 0xcda65173);
  9647. packet2->setDataByName("voice_key2", 0x984bfc6d);
  9648. EQ2Packet* app = packet2->serialize();
  9649. DumpPacket(app);
  9650. client->QueuePacket(app);
  9651. safe_delete(packet2);
  9652. packet2 = configReader.getStruct("WS_ShowWindow", client->GetVersion());
  9653. packet2->setDataByName("window", "MainHUD.StartMenu");
  9654. packet2->setDataByName("show", 1);
  9655. app = packet2->serialize();
  9656. DumpPacket(app);
  9657. client->QueuePacket(app);
  9658. safe_delete(packet2);
  9659. packet2 = configReader.getStruct("WS_FlashWindow", client->GetVersion());
  9660. packet2->setDataByName("window", "MainHUD.StartMenu.help");
  9661. packet2->setDataByName("flash_seconds", 10);
  9662. app = packet2->serialize();
  9663. DumpPacket(app);
  9664. client->QueuePacket(app);
  9665. safe_delete(packet2);
  9666. }
  9667. }
  9668. else if (atoi(sep->arg[0]) == 15) {
  9669. PacketStruct* packet2 = configReader.getStruct("WS_UpdateLoot", client->GetVersion());
  9670. if (packet2) {
  9671. packet2->setArrayLengthByName("loot_count", 1);
  9672. packet2->setArrayDataByName("name", "Test");
  9673. packet2->setArrayDataByName("item_id", 1234);
  9674. packet2->setArrayDataByName("count", 1);
  9675. packet2->setArrayDataByName("icon", 258);
  9676. packet2->setArrayDataByName("ability_id", 0xFFFFFFFF);
  9677. Spawn* spawn = client->GetPlayer()->GetTarget();
  9678. if (spawn)
  9679. packet2->setDataByName("object_id", client->GetPlayer()->GetIDWithPlayerSpawn(spawn));
  9680. packet2->setDataByName("unknown3", 1);
  9681. packet2->setDataByName("unknown4", 1);
  9682. packet2->setDataByName("unknown5", 60);
  9683. EQ2Packet* app = packet2->serialize();
  9684. DumpPacket(app);
  9685. client->QueuePacket(app);
  9686. safe_delete(packet2);
  9687. }
  9688. }
  9689. else if (atoi(sep->arg[0]) == 16 && sep->IsNumber(1)) {
  9690. char blah[32];
  9691. sprintf(blah, "Testing: %i", atoi(sep->arg[1]));
  9692. client->SimpleMessage(atoi(sep->arg[1]), blah);
  9693. }
  9694. else if (atoi(sep->arg[0]) == 17 && sep->IsNumber(2)) {
  9695. if (sep->IsSet(2)) {
  9696. int16 offset = atoi(sep->arg[1]);
  9697. if (sep->IsNumber(2)) {
  9698. int32 value1 = atol(sep->arg[2]);
  9699. client->QueuePacket(client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion(), offset, value1));
  9700. cout << "Sent" << endl;
  9701. }
  9702. }
  9703. }
  9704. else if (atoi(sep->arg[0]) == 18) {
  9705. PacketStruct* packet2 = configReader.getStruct("WS_QuestRewardPackMsg", client->GetVersion());
  9706. if (packet2) {
  9707. packet2->setSubstructDataByName("reward_data", "unknown1", 255);
  9708. packet2->setSubstructDataByName("reward_data", "reward", "Quest Reward!");
  9709. packet2->setSubstructDataByName("reward_data", "max_coin", 0);
  9710. packet2->setSubstructDataByName("reward_data", "text", "Some custom text to mess things up?");
  9711. //packet2->setSubstructDataByName("reward_data", "status_points", 5);
  9712. //packet2->setSubstructDataByName("reward_data", "exp_bonus", 10);
  9713. packet2->setSubstructArrayLengthByName("reward_data", "num_rewards", 1);
  9714. Item* item = new Item(master_item_list.GetItem(9357));
  9715. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9716. //item->stack_count = 20;
  9717. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  9718. safe_delete(item);
  9719. /*item = new Item(master_item_list.GetItem(36685));
  9720. item->stack_count = 20;
  9721. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9722. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 1, 0, -1);
  9723. safe_delete(item);
  9724. item = master_item_list.GetItem(1414);
  9725. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9726. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 2, 0, -1);
  9727. item = master_item_list.GetItem(75057);
  9728. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9729. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 3, 0, -1);*/
  9730. EQ2Packet* app = packet2->serialize();
  9731. if (sep->IsSet(2)) {
  9732. int16 offset = atoi(sep->arg[1]);
  9733. uchar* ptr2 = app->pBuffer;
  9734. ptr2 += offset;
  9735. if (sep->IsNumber(2)) {
  9736. int32 value1 = atol(sep->arg[2]);
  9737. if (value1 > 0xFFFF)
  9738. memcpy(ptr2, (uchar*)&value1, 4);
  9739. else if (value1 > 0xFF)
  9740. memcpy(ptr2, (uchar*)&value1, 2);
  9741. else
  9742. memcpy(ptr2, (uchar*)&value1, 1);
  9743. }
  9744. else {
  9745. int16 len = strlen(sep->arg[2]);
  9746. memcpy(ptr2, (uchar*)&len, 2);
  9747. ptr2 += 2;
  9748. memcpy(ptr2, sep->arg[2], len);
  9749. }
  9750. }
  9751. DumpPacket(app);
  9752. client->QueuePacket(app);
  9753. safe_delete(packet2);
  9754. }
  9755. }
  9756. else if (atoi(sep->arg[0]) == 19) {
  9757. PacketStruct* packet2 = configReader.getStruct("WS_UpdateLoot", client->GetVersion());
  9758. Spawn* spawn = client->GetPlayer()->GetTarget();
  9759. if (packet2 && spawn) {
  9760. Item* item = master_item_list.GetItem(130053);
  9761. packet2->setArrayLengthByName("loot_count", 1);
  9762. packet2->setArrayDataByName("loot_id", item->details.item_id);
  9763. packet2->setArrayDataByName("unknown2", 1);
  9764. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, 2, true);
  9765. packet2->setDataByName("display", 1);
  9766. packet2->setDataByName("unknown2b", 1);
  9767. packet2->setDataByName("unknown3", 0x3c);
  9768. packet2->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(spawn));
  9769. packet2->PrintPacket();
  9770. EQ2Packet* app = packet2->serialize();
  9771. if (sep->IsSet(2)) {
  9772. int16 offset = atoi(sep->arg[1]);
  9773. int16 offset2 = 0;
  9774. int32 value1 = 0;
  9775. if (sep->IsSet(3)) {
  9776. offset2 = atoi(sep->arg[2]);
  9777. value1 = atol(sep->arg[3]);
  9778. }
  9779. else
  9780. value1 = atol(sep->arg[2]);
  9781. int16 offset3 = 0;
  9782. int16 offset4 = 0;
  9783. int32 value2 = 0;
  9784. if (sep->IsSet(6)) {
  9785. offset3 = atoi(sep->arg[4]);
  9786. offset4 = atoi(sep->arg[5]);
  9787. value2 = atol(sep->arg[6]);
  9788. }
  9789. offset--;
  9790. if (offset2 > 0 && offset2 >= offset) {
  9791. offset2--;
  9792. uchar* ptr2 = app->pBuffer;
  9793. ptr2 += offset;
  9794. for (int i = offset; i <= offset2; i++) {
  9795. if (value1 > 0xFFFF) {
  9796. memcpy(ptr2, (uchar*)&value1, 4);
  9797. i += 3;
  9798. ptr2 += 3;
  9799. }
  9800. else if (value1 > 0xFF) {
  9801. memcpy(ptr2, (uchar*)&value1, 2);
  9802. i++;
  9803. ptr2++;
  9804. }
  9805. else
  9806. memcpy(ptr2, (uchar*)&value1, 1);
  9807. ptr2++;
  9808. }
  9809. }
  9810. if (offset4 > 0 && offset4 >= offset3) {
  9811. offset3--;
  9812. offset4--;
  9813. uchar* ptr2 = app->pBuffer;
  9814. ptr2 += offset3;
  9815. for (int i = offset3; i <= offset4; i++) {
  9816. if (value2 > 0xFFFF) {
  9817. memcpy(ptr2, (uchar*)&value2, 4);
  9818. i += 3;
  9819. ptr2 += 3;
  9820. }
  9821. else if (value2 > 0xFF) {
  9822. memcpy(ptr2, (uchar*)&value2, 2);
  9823. i++;
  9824. ptr2++;
  9825. }
  9826. else
  9827. memcpy(ptr2, (uchar*)&value2, 1);
  9828. ptr2++;
  9829. }
  9830. }
  9831. }
  9832. DumpPacket(app);
  9833. client->QueuePacket(app);
  9834. safe_delete(packet2);
  9835. }
  9836. }
  9837. else if (atoi(sep->arg[0]) == 21) {
  9838. PacketStruct* packet2 = configReader.getStruct("WS_OfferQuest", client->GetVersion());
  9839. if (packet2) {
  9840. packet2->setDataByName("unknown0", 255);
  9841. packet2->setDataByName("reward", "New Quest");
  9842. packet2->setDataByName("title", "Title");
  9843. packet2->setDataByName("description", "description");
  9844. packet2->setDataByName("quest_difficulty", 3);
  9845. packet2->setDataByName("unknown1", 5);
  9846. packet2->setDataByName("level", 3);
  9847. packet2->setDataByName("coin", 150);
  9848. packet2->setDataByName("status_points", 5);
  9849. packet2->setDataByName("exp_bonus", 10);
  9850. packet2->setArrayLengthByName("num_rewards", 1);
  9851. Item* item = new Item(master_item_list.GetItem(36212));
  9852. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9853. item->stack_count = 20;
  9854. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  9855. safe_delete(item);
  9856. char accept[35] = { 0 };
  9857. char decline[35] = { 0 };
  9858. sprintf(accept, "q_accept_pending_quest %u", 0);
  9859. sprintf(decline, "q_deny_pending_quest %u", 0);
  9860. packet2->setDataByName("accept_command", accept);
  9861. packet2->setDataByName("decline_command", decline);
  9862. EQ2Packet* app = packet2->serialize();
  9863. if (sep->IsSet(2)) {
  9864. int16 offset = atoi(sep->arg[1]);
  9865. uchar* ptr2 = app->pBuffer;
  9866. ptr2 += offset;
  9867. if (sep->IsNumber(2)) {
  9868. int32 value1 = atol(sep->arg[2]);
  9869. if (value1 > 0xFFFF)
  9870. memcpy(ptr2, (uchar*)&value1, 4);
  9871. else if (value1 > 0xFF)
  9872. memcpy(ptr2, (uchar*)&value1, 2);
  9873. else
  9874. memcpy(ptr2, (uchar*)&value1, 1);
  9875. }
  9876. DumpPacket(app);
  9877. client->QueuePacket(app);
  9878. safe_delete(packet2);
  9879. }
  9880. }
  9881. }
  9882. else if (atoi(sep->arg[0]) == 22) { //same as 21, but 8bit string
  9883. PacketStruct* packet2 = configReader.getStruct("WS_OfferQuest", client->GetVersion());
  9884. if (packet2) {
  9885. packet2->setDataByName("unknown0", 255);
  9886. packet2->setDataByName("reward", "New Quest");
  9887. packet2->setDataByName("title", "Title");
  9888. packet2->setDataByName("description", "description");
  9889. packet2->setDataByName("quest_difficulty", 3);
  9890. packet2->setDataByName("unknown1", 5);
  9891. packet2->setDataByName("level", 3);
  9892. packet2->setDataByName("coin", 150);
  9893. packet2->setDataByName("status_points", 5);
  9894. packet2->setDataByName("exp_bonus", 10);
  9895. packet2->setArrayLengthByName("num_rewards", 1);
  9896. Item* item = new Item(master_item_list.GetItem(36212));
  9897. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9898. item->stack_count = 20;
  9899. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  9900. safe_delete(item);
  9901. char accept[35] = { 0 };
  9902. char decline[35] = { 0 };
  9903. sprintf(accept, "q_accept_pending_quest %u", 0);
  9904. sprintf(decline, "q_deny_pending_quest %u", 0);
  9905. packet2->setDataByName("accept_command", accept);
  9906. packet2->setDataByName("decline_command", decline);
  9907. EQ2Packet* app = packet2->serialize();
  9908. if (sep->IsSet(2)) {
  9909. int16 offset = atoi(sep->arg[1]);
  9910. uchar* ptr2 = app->pBuffer;
  9911. ptr2 += offset;
  9912. if (sep->IsNumber(2)) {
  9913. int32 value1 = atol(sep->arg[2]);
  9914. if (value1 > 0xFFFF)
  9915. memcpy(ptr2, (uchar*)&value1, 4);
  9916. else if (value1 > 0xFF)
  9917. memcpy(ptr2, (uchar*)&value1, 2);
  9918. else
  9919. memcpy(ptr2, (uchar*)&value1, 1);
  9920. }
  9921. else {
  9922. int8 len = strlen(sep->arg[2]);
  9923. memcpy(ptr2, (uchar*)&len, 1);
  9924. ptr2 += 1;
  9925. memcpy(ptr2, sep->arg[2], len);
  9926. }
  9927. }
  9928. DumpPacket(app);
  9929. client->QueuePacket(app);
  9930. safe_delete(packet2);
  9931. }
  9932. }
  9933. else if (atoi(sep->arg[0]) == 23) {
  9934. if (client->GetPlayer()->GetTarget()) {
  9935. PacketStruct* packet2 = configReader.getStruct("WS_UpdateMerchant", client->GetVersion());
  9936. if (packet2) {
  9937. Spawn* target = client->GetPlayer()->GetTarget();
  9938. packet2->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(target));
  9939. Item* item = new Item(master_item_list.GetItem(12565));
  9940. int8 i = 0;
  9941. packet2->setArrayLengthByName("num_items", 1);
  9942. packet2->setArrayDataByName("item_name", item->name.c_str(), i);
  9943. packet2->setArrayDataByName("item_id", item->details.item_id, i);
  9944. packet2->setArrayDataByName("stack_size", item->stack_count, i);
  9945. packet2->setArrayDataByName("icon", item->details.icon, i);
  9946. int8 tmp_level = 0;
  9947. if (item->generic_info.adventure_default_level > 0)
  9948. tmp_level = item->generic_info.adventure_default_level;
  9949. else
  9950. tmp_level = item->generic_info.tradeskill_default_level;
  9951. packet2->setArrayDataByName("level", tmp_level, i);
  9952. packet2->setArrayDataByName("tier", item->details.tier, i);
  9953. packet2->setArrayDataByName("item_id2", item->details.item_id, i);
  9954. int8 item_difficulty = client->GetPlayer()->GetArrowColor(tmp_level);
  9955. if (item_difficulty != ARROW_COLOR_WHITE && item_difficulty != ARROW_COLOR_RED && item_difficulty != ARROW_COLOR_GRAY)
  9956. item_difficulty = ARROW_COLOR_WHITE;
  9957. item_difficulty -= 6;
  9958. if (item_difficulty < 0)
  9959. item_difficulty *= -1;
  9960. packet2->setArrayDataByName("item_difficulty", item_difficulty, i);
  9961. packet2->setArrayDataByName("quantity", 2, i);
  9962. packet2->setArrayDataByName("unknown5", 255, i);
  9963. packet2->setArrayDataByName("stack_size2", item->stack_count, i);
  9964. packet2->setArrayDataByName("description", item->description.c_str(), i);
  9965. packet2->setDataByName("type", 2);
  9966. EQ2Packet* app = packet2->serialize();
  9967. if (sep->IsSet(2)) {
  9968. int16 offset = atoi(sep->arg[1]);
  9969. uchar* ptr2 = app->pBuffer;
  9970. ptr2 += offset;
  9971. if (sep->IsNumber(2)) {
  9972. int32 value1 = atol(sep->arg[2]);
  9973. if (value1 > 0xFFFF)
  9974. memcpy(ptr2, (uchar*)&value1, 4);
  9975. else if (value1 > 0xFF)
  9976. memcpy(ptr2, (uchar*)&value1, 2);
  9977. else
  9978. memcpy(ptr2, (uchar*)&value1, 1);
  9979. }
  9980. else {
  9981. int8 len = strlen(sep->arg[2]);
  9982. memcpy(ptr2, (uchar*)&len, 1);
  9983. ptr2 += 1;
  9984. memcpy(ptr2, sep->arg[2], len);
  9985. }
  9986. }
  9987. DumpPacket(app);
  9988. client->QueuePacket(app);
  9989. safe_delete(packet2);
  9990. }
  9991. }
  9992. }
  9993. else if (atoi(sep->arg[0]) == 24) {
  9994. PacketStruct* packet2 = configReader.getStruct("WS_EnableGameEvent", client->GetVersion());
  9995. if (packet2) {
  9996. if (sep->IsSet(2)) {
  9997. packet2->setDataByName("event_name", sep->arg[1]);
  9998. packet2->setDataByName("enabled", atoi(sep->arg[2]));
  9999. EQ2Packet* app = packet2->serialize();
  10000. DumpPacket(app);
  10001. client->QueuePacket(app);
  10002. safe_delete(packet2);
  10003. }
  10004. }
  10005. }
  10006. else if (atoi(sep->arg[0]) == 25) {
  10007. if (sep->IsSet(1)) {
  10008. Widget* new_spawn = new Widget();
  10009. int32 id = atoul(sep->arg[1]);
  10010. new_spawn->SetWidgetID(id);
  10011. EQ2Packet* ret = new_spawn->serialize(client->GetPlayer(), client->GetVersion());
  10012. client->QueuePacket(ret);
  10013. int8 index = client->GetPlayer()->GetIndexForSpawn(new_spawn);
  10014. PacketStruct* packet2 = configReader.getStruct("WS_DestroyGhostCmd", client->GetVersion());
  10015. if (packet2) {
  10016. packet2->setDataByName("spawn_index", index);
  10017. packet2->setDataByName("delete", 1);
  10018. EQ2Packet* app = packet2->serialize();
  10019. client->QueuePacket(app);
  10020. safe_delete(packet2);
  10021. }
  10022. }
  10023. }
  10024. else if (atoi(sep->arg[0]) == 26) {
  10025. if (sep->IsSet(4)) {
  10026. Widget* new_spawn = new Widget();
  10027. int32 id = atoul(sep->arg[1]);
  10028. new_spawn->SetWidgetID(id);
  10029. float x = atof(sep->arg[2]);
  10030. float y = atof(sep->arg[3]);
  10031. float z = atof(sep->arg[4]);
  10032. new_spawn->SetLocation(client->GetPlayer()->GetLocation());
  10033. new_spawn->SetWidgetX(x);
  10034. new_spawn->SetWidgetY(y);
  10035. new_spawn->SetWidgetZ(z);
  10036. new_spawn->SetX(x);
  10037. new_spawn->SetY(y);
  10038. new_spawn->SetZ(z);
  10039. EQ2Packet* ret = new_spawn->serialize(client->GetPlayer(), client->GetVersion());
  10040. client->QueuePacket(ret);
  10041. }
  10042. }
  10043. else if (atoi(sep->arg[0]) == 27) {
  10044. Spawn* target = client->GetPlayer()->GetTarget();
  10045. PacketStruct* packet2 = configReader.getStruct("WS_HearSimpleDamage", client->GetVersion());
  10046. if (packet2 && target && sep->IsSet(4)) {
  10047. 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] : "");
  10048. }
  10049. }
  10050. else if (atoi(sep->arg[0]) == 28 && sep->IsNumber(1)) {
  10051. World::newValue = strtoull(sep->arg[1], NULL, 0);
  10052. }
  10053. else if (atoi(sep->arg[0]) == 29 && sep->IsNumber(1)) {
  10054. client->SendHearCast(client->GetPlayer(), client->GetPlayer()->GetTarget() ? client->GetPlayer()->GetTarget() : client->GetPlayer(),
  10055. strtoull(sep->arg[1], NULL, 0), atoul(sep->arg[2]));
  10056. }
  10057. else if (atoi(sep->arg[0]) == 30) {
  10058. PacketStruct* packet = configReader.getStruct("WS_UpdateSkillBook", client->GetVersion());
  10059. if (packet) {
  10060. packet->setDataByName("unknown", World::newValue);
  10061. EQ2Packet* outapp = packet->serialize();
  10062. DumpPacket(outapp);
  10063. client->QueuePacket(outapp);
  10064. safe_delete(packet);
  10065. }
  10066. }
  10067. else if (atoi(sep->arg[0]) == 31) {
  10068. client->SendRecipeList();
  10069. }
  10070. else if (atoi(sep->arg[0]) == 32 && sep->IsNumber(1) && sep->IsNumber(2)) {
  10071. if(client->GetVersion() <= 546) {
  10072. int32 param = atoul(sep->arg[1]);
  10073. int32 paramvalue = atoul(sep->arg[2]);
  10074. client->Message(CHANNEL_COLOR_YELLOW, "Send control flag param %u param value %u", param, paramvalue);
  10075. ClientPacketFunctions::SendServerControlFlagsClassic(client, param, paramvalue);
  10076. }
  10077. else if(sep->IsNumber(3)) {
  10078. int8 param1 = atoul(sep->arg[1]);
  10079. int8 param2 = atoul(sep->arg[2]);
  10080. int8 paramval = atoul(sep->arg[3]);
  10081. client->Message(CHANNEL_COLOR_YELLOW, "Send control flag param1 %u param2 %u param value %u", param1, param2, paramval);
  10082. ClientPacketFunctions::SendServerControlFlags(client, param1, param2, paramval);
  10083. }
  10084. }
  10085. else if (atoi(sep->arg[0]) == 33 && sep->IsNumber(1) && sep->IsNumber(2)) {
  10086. client->GetCurrentZone()->SendHealPacket(client->GetPlayer(), client->GetPlayer()->GetTarget() ? client->GetPlayer()->GetTarget() : client->GetPlayer(),
  10087. atoul(sep->arg[1]), atoul(sep->arg[2]), "TestSpell");
  10088. }
  10089. }
  10090. else {
  10091. PacketStruct* packet2 = configReader.getStruct("WS_ExamineSpellInfo", client->GetVersion());
  10092. if (packet2) {
  10093. packet2->setSubstructDataByName("info_header", "show_name", 1);
  10094. packet2->setSubstructDataByName("info_header", "unknown", 7);
  10095. packet2->setSubstructDataByName("info_header", "unknown2", 1);
  10096. packet2->setSubstructDataByName("info_header", "unknown3", 1);
  10097. packet2->setSubstructDataByName("info_header", "unknown4", 1);
  10098. packet2->setSubstructDataByName("info_header", "unknown5", 1);
  10099. packet2->setSubstructDataByName("info_header", "unknown6", "Testing");
  10100. packet2->setSubstructDataByName("info_header", "unknown7", "Testing");
  10101. packet2->setSubstructDataByName("info_header", "unknown8", 66);
  10102. packet2->setSubstructDataByName("info_header", "title", "Blah Title Blah");
  10103. packet2->setSubstructDataByName("info_header", "title_text", "Blah Blah");
  10104. packet2->setSubstructDataByName("info_header", "title_text2", "Blah Blah2");
  10105. packet2->setSubstructDataByName("info_header", "show_popup", 1);
  10106. packet2->setSubstructDataByName("info_header", "packettype", 3);
  10107. packet2->setSubstructDataByName("spell_info", "skill_name", "Testing");
  10108. packet2->setSubstructDataByName("spell_info", "level", 19);
  10109. packet2->setSubstructDataByName("spell_info", "tier", 1);
  10110. packet2->setSubstructDataByName("spell_info", "health_cost", 5);
  10111. packet2->setSubstructDataByName("spell_info", "min_class_skill_req", 3);
  10112. packet2->setSubstructDataByName("spell_info", "mana_cost", 6);
  10113. packet2->setSubstructDataByName("spell_info", "req_concentration", 7);
  10114. packet2->setSubstructDataByName("spell_info", "cast_time", 200);
  10115. packet2->setSubstructDataByName("spell_info", "recovery", 220);
  10116. packet2->setSubstructDataByName("spell_info", "recast", 280);
  10117. packet2->setSubstructDataByName("spell_info", "beneficial", 1);
  10118. packet2->setSubstructDataByName("spell_info", "maintained", 1);
  10119. packet2->setSubstructDataByName("spell_info", "spell_book_type", 1);
  10120. packet2->setSubstructDataByName("spell_info", "quality", 3);
  10121. packet2->setSubstructDataByName("spell_info", "test_1a", 1);
  10122. packet2->setSubstructDataByName("spell_info", "test_1b", 1);
  10123. packet2->setSubstructDataByName("spell_info", "test_1c", 1);
  10124. packet2->setSubstructDataByName("spell_info", "test_1d", 1);
  10125. packet2->setSubstructDataByName("spell_info", "test_2a", 2);
  10126. packet2->setSubstructDataByName("spell_info", "test_2b", 2);
  10127. packet2->setSubstructDataByName("spell_info", "test_2c", 2);
  10128. packet2->setSubstructDataByName("spell_info", "test_2d", 2);
  10129. packet2->setSubstructDataByName("spell_info", "test_3", 3);
  10130. packet2->setSubstructDataByName("spell_info", "test_4", 4);
  10131. packet2->setSubstructDataByName("spell_info", "test_5", 5);
  10132. packet2->setSubstructDataByName("spell_info", "test_6", 6);
  10133. packet2->setSubstructDataByName("spell_info", "min_class_skill_req", 1);
  10134. packet2->setSubstructDataByName("spell_info", "min_class_skill_rec", 30123);
  10135. packet2->setSubstructDataByName("spell_info", "num_reagents", 1);
  10136. packet2->setSubstructArrayLengthByName("spell_info", "num_reagents", 1);
  10137. packet2->setArrayDataByName("reagent", "Alcohol");
  10138. packet2->setArrayDataByName("consumed", "123");
  10139. packet2->setSubstructDataByName("spell_info", "class_skill", 52);
  10140. packet2->setSubstructDataByName("spell_info", "id", 8308);
  10141. packet2->setSubstructDataByName("spell_info", "icon", 303);
  10142. packet2->setSubstructDataByName("spell_info", "icon2", 0xFFFF);
  10143. packet2->setSubstructDataByName("spell_info", "icontype", 317);
  10144. packet2->setSubstructDataByName("spell_info", "type", 2);
  10145. packet2->setSubstructDataByName("spell_info", "spell_text_color", 255);
  10146. packet2->setSubstructDataByName("spell_info", "duration1", 600);
  10147. packet2->setSubstructDataByName("spell_info", "duration2", 600);
  10148. packet2->setSubstructDataByName("spell_info", "name", "Sprint");
  10149. packet2->setSubstructDataByName("spell_info", "description", "Test description");
  10150. EQ2Packet* outapp = packet2->serialize();
  10151. DumpPacket(outapp);
  10152. client->QueuePacket(outapp);
  10153. safe_delete(packet2);
  10154. }
  10155. }
  10156. return;
  10157. PacketStruct* p = configReader.getStruct("WS_EqTargetItemCmd", client->GetVersion());
  10158. if (!p) return;
  10159. //Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  10160. //client->GetCurrentZone()->SendSpellFailedPacket(client, atoi(sep2->arg[0]));
  10161. //}
  10162. /*Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  10163. if (sep2 && sep2->arg[0] && sep2->IsNumber(0)) {
  10164. client->SetPendingFlightPath(atoi(sep2->arg[0]));
  10165. PacketStruct* packet = configReader.getStruct("WS_ReadyForTakeOff", client->GetVersion());
  10166. if (packet) {
  10167. client->QueuePacket(packet->serialize());
  10168. safe_delete(packet);
  10169. }
  10170. }*/
  10171. /*if (client->GetCurrentZone()->Grid != nullptr) {
  10172. int32 numFaces = 0;
  10173. int32 numGrids = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.size();
  10174. client->Message(CHANNEL_COLOR_YELLOW, "Num grids in cell: %u", numGrids);
  10175. map<int32, vector<Face*> >::iterator itr;
  10176. for (itr = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.begin(); itr != client->GetPlayer()->Cell_Info.CurrentCell->FaceList.end(); itr++)
  10177. numFaces += (*itr).second.size();
  10178. client->Message(CHANNEL_COLOR_YELLOW, "Num faces in cell: %u", numFaces);
  10179. }*/
  10180. //uchar blah[] = {
  10181. // 1208 - OP_EQUpdateStoreCmd
  10182. // /*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
  10183. // /*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
  10184. // 1193 - -- OP_ClientCmdMsg::OP_EqUpdateMerchantCmd --
  10185. // /*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
  10186. /*};
  10187. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  10188. int8 val = 0;
  10189. int16 pos = 0;
  10190. int idx = 0;
  10191. while(sep2 && sep2->arg[idx+1] && sep2->IsNumber(idx) && sep2->IsNumber(idx+1)){
  10192. pos = atoi(sep2->arg[idx]);
  10193. val = atoi(sep2->arg[idx+1]);
  10194. memset(blah+pos, val, 1);
  10195. idx+=2;
  10196. }
  10197. DumpPacket(blah, sizeof(blah));
  10198. client->QueuePacket(new EQ2Packet(OP_GroupCreatedMsg , blah, sizeof(blah)));*/
  10199. if (client->GetPlayer()->GetTarget()) {
  10200. PacketStruct* packet = configReader.getStruct("WS_SetControlGhost", client->GetVersion());
  10201. if (packet) {
  10202. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  10203. packet->setDataByName("size", 0);
  10204. packet->setDataByName("unknown2", 0);
  10205. EQ2Packet* app = packet->serialize();
  10206. client->QueuePacket(app);
  10207. safe_delete(packet);
  10208. }
  10209. PacketStruct* set_pov = configReader.getStruct("WS_SetPOVGhostCmd", client->GetVersion());
  10210. if (set_pov) {
  10211. set_pov->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  10212. EQ2Packet* app_pov = set_pov->serialize();
  10213. client->QueuePacket(app_pov);
  10214. safe_delete(set_pov);
  10215. }
  10216. }
  10217. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  10218. PacketStruct* packet = configReader.getStruct("WS_OpenCharCust", client->GetVersion());
  10219. if (packet) {
  10220. if (sep2 && sep2->arg[0] && sep2->IsNumber(0))
  10221. packet->setDataByName("Type", atoi(sep2->arg[0]));
  10222. else
  10223. packet->setDataByName("Type", 2);
  10224. if (sep2 && sep2->arg[1] && sep2->IsNumber(1))
  10225. packet->setDataByName("race_id", atoi(sep2->arg[1]));
  10226. else
  10227. packet->setDataByName("race_id", 0);
  10228. if (sep2 && sep2->arg[2] && sep2->IsNumber(2))
  10229. packet->setDataByName("gender", atoi(sep2->arg[2]));
  10230. else
  10231. packet->setDataByName("gender", 2);
  10232. if (sep2 && sep2->arg[3] && sep2->IsNumber(3))
  10233. packet->setDataByName("unknown", atoi(sep2->arg[3]), 0);
  10234. else
  10235. packet->setDataByName("unknown", 0, 0);
  10236. if (sep2 && sep2->arg[4] && sep2->IsNumber(4))
  10237. packet->setDataByName("unknown", atoi(sep2->arg[4]), 1);
  10238. else
  10239. packet->setDataByName("unknown", 0, 1);
  10240. if (sep2 && sep2->arg[5] && sep2->IsNumber(5))
  10241. packet->setDataByName("unknown", atoi(sep2->arg[5]), 2);
  10242. else
  10243. packet->setDataByName("unknown", 0, 2);
  10244. client->QueuePacket(packet->serialize());
  10245. }
  10246. safe_delete(packet);
  10247. safe_delete(sep2);
  10248. }
  10249. void Commands::Command_LeaveChannel(Client *client, Seperator *sep) {
  10250. const char *channel_name;
  10251. if (sep == NULL || !sep->IsSet(0)) {
  10252. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /leavechat <channel name>");
  10253. PrintSep(sep);
  10254. return;
  10255. }
  10256. channel_name = sep->arg[0];
  10257. if (!chat.IsInChannel(client, channel_name))
  10258. client->Message(CHANNEL_NARRATIVE, "Unable to leave '%s': You are not in the channel.", channel_name);
  10259. else if (!chat.LeaveChannel(client, channel_name))
  10260. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an internal error preventing you from leaving that channel MUAHAHA");
  10261. }
  10262. /*
  10263. Function:
  10264. Purpose :
  10265. Params :
  10266. Dev :
  10267. Example :
  10268. */
  10269. void Commands::Command_WeaponStats(Client* client)
  10270. {
  10271. Player* player = client->GetPlayer();
  10272. Spawn* target = player->GetTarget();
  10273. Item* primary = player->GetEquipmentList()->GetItem(EQ2_PRIMARY_SLOT);
  10274. Item* secondary = player->GetEquipmentList()->GetItem(EQ2_SECONDARY_SLOT);
  10275. Item* ranged = player->GetEquipmentList()->GetItem(EQ2_RANGE_SLOT);
  10276. const char* charName = player->GetName();
  10277. if(target && target->IsEntity()) {
  10278. primary = ((Entity*)target)->GetEquipmentList()->GetItem(EQ2_PRIMARY_SLOT);
  10279. secondary = ((Entity*)target)->GetEquipmentList()->GetItem(EQ2_SECONDARY_SLOT);
  10280. ranged = ((Entity*)target)->GetEquipmentList()->GetItem(EQ2_RANGE_SLOT);
  10281. charName = target->GetName();
  10282. }
  10283. else {
  10284. target = nullptr;
  10285. }
  10286. client->Message(0, "WeaponStats for %s", charName);
  10287. client->SimpleMessage(0, "Primary:");
  10288. if (primary) {
  10289. client->Message(0, "Name: %s", primary->name.c_str());
  10290. client->Message(0, "Base Damage: %u - %u", primary->weapon_info->damage_low3, primary->weapon_info->damage_high3);
  10291. client->Message(0, "Actual Damage: %u - %u", target ? ((Entity*)target)->GetPrimaryWeaponMinDamage() : player->GetPrimaryWeaponMinDamage(),
  10292. target ? ((Entity*)target)->GetPrimaryWeaponMaxDamage() : player->GetPrimaryWeaponMaxDamage());
  10293. client->Message(0, "Actual Delay: %u", target ? ((Entity*)target)->GetPrimaryWeaponDelay() : player->GetPrimaryWeaponDelay());
  10294. client->Message(0, "Proc Percent: %d%%", 0);
  10295. client->Message(0, "Procs Per Minute: %d", 0);
  10296. }
  10297. else {
  10298. client->SimpleMessage(0, "Name: fist");
  10299. client->Message(0, "Base Damage: %u - %u", target ? ((Entity*)target)->GetPrimaryWeaponMinDamage() : player->GetPrimaryWeaponMinDamage(),
  10300. target ? ((Entity*)target)->GetPrimaryWeaponMaxDamage() : player->GetPrimaryWeaponMaxDamage());
  10301. client->Message(0, "Actual Damage: %u - %u", target ? ((Entity*)target)->GetPrimaryWeaponMinDamage() : player->GetPrimaryWeaponMinDamage(),
  10302. target ? ((Entity*)target)->GetPrimaryWeaponMaxDamage() : player->GetPrimaryWeaponMaxDamage());
  10303. client->Message(0, "Actual Delay: %d", target ? ((Entity*)target)->GetPrimaryWeaponDelay() : player->GetPrimaryWeaponDelay() * 0.1);
  10304. client->Message(0, "Proc Percent: %d%%", 0);
  10305. client->Message(0, "Procs Per Minute: %d", 0);
  10306. }
  10307. client->SimpleMessage(0, " ");
  10308. client->SimpleMessage(0, " ");
  10309. if (secondary) {
  10310. client->SimpleMessage(0, "Secondary:");
  10311. client->Message(0, "Name: %s", secondary->name.c_str());
  10312. client->Message(0, "Base Damage: %u - %u", secondary->weapon_info->damage_low3, secondary->weapon_info->damage_high3);
  10313. client->Message(0, "Actual Damage: %u - %u", target ? ((Entity*)target)->GetSecondaryWeaponMinDamage() : player->GetSecondaryWeaponMinDamage(),
  10314. target ? ((Entity*)target)->GetSecondaryWeaponMaxDamage() : player->GetSecondaryWeaponMaxDamage());
  10315. client->Message(0, "Actual Delay: %d", target ? ((Entity*)target)->GetSecondaryWeaponDelay() : player->GetSecondaryWeaponDelay() * 0.1);
  10316. client->Message(0, "Proc Percent: %d%%", 0);
  10317. client->Message(0, "Procs Per Minute: %d", 0);
  10318. client->SimpleMessage(0, " ");
  10319. client->SimpleMessage(0, " ");
  10320. }
  10321. client->SimpleMessage(0, "Ranged:");
  10322. if (ranged) {
  10323. client->Message(0, "Name: %s", ranged->name.c_str());
  10324. client->Message(0, "Base Damage: %u - %u", ranged->ranged_info->weapon_info.damage_low3, ranged->ranged_info->weapon_info.damage_high3);
  10325. client->Message(0, "Actual Damage: %u - %u", target ? ((Entity*)target)->GetRangedWeaponMinDamage() : player->GetRangedWeaponMinDamage(),
  10326. target ? ((Entity*)target)->GetRangedWeaponMaxDamage() : player->GetRangedWeaponMaxDamage());
  10327. client->Message(0, "Actual Delay: %d", target ? ((Entity*)target)->GetRangeWeaponDelay() : player->GetRangeWeaponDelay() * 0.1);
  10328. client->Message(0, "Proc Percent: %d%%", 0);
  10329. client->Message(0, "Procs Per Minute: %d", 0);
  10330. }
  10331. else
  10332. client->SimpleMessage(0, "None");
  10333. }
  10334. void Commands::Command_WhoChannel(Client *client, Seperator *sep) {
  10335. const char *channel_name;
  10336. if (sep == NULL || !sep->IsSet(0)) {
  10337. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /chatwho <channel name>");
  10338. return;
  10339. }
  10340. channel_name = sep->arg[0];
  10341. if (!chat.ChannelExists(channel_name))
  10342. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That channel does not exist!");
  10343. else
  10344. chat.SendChannelUserList(client, channel_name);
  10345. }
  10346. void Commands::Command_ZoneSafeCoords(Client *client, Seperator *sep)
  10347. {
  10348. ZoneServer* zone = 0;
  10349. int32 zone_id = client->GetPlayer()->GetZone()->GetZoneID();
  10350. if (zone_id > 0)
  10351. {
  10352. zone = zone_list.Get(zone_id, false, false, false);
  10353. if (zone)
  10354. {
  10355. zone->SetSafeX(client->GetPlayer()->GetX());
  10356. zone->SetSafeY(client->GetPlayer()->GetY());
  10357. zone->SetSafeZ(client->GetPlayer()->GetZ());
  10358. zone->SetSafeHeading(client->GetPlayer()->GetHeading());
  10359. if( database.SaveZoneSafeCoords(zone_id, zone->GetSafeX(), zone->GetSafeY(), zone->GetSafeZ(), zone->GetSafeHeading()) )
  10360. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Zone safe coordinates updated!");
  10361. else
  10362. client->SimpleMessage(CHANNEL_COLOR_RED, "FAILED to update zone safe coordinates!");
  10363. }
  10364. }
  10365. }
  10366. /*
  10367. Function:
  10368. Purpose :
  10369. Params :
  10370. Dev :
  10371. Example :
  10372. */
  10373. void Commands::Command_ZoneDetails(Client* client, Seperator* sep)
  10374. {
  10375. ZoneInfo* zone_info = new ZoneInfo;
  10376. if (sep && sep->arg[0])
  10377. {
  10378. if (sep->IsNumber(0))
  10379. zone_info->id = atoi(sep->arg[0]);
  10380. else
  10381. zone_info->id = database.GetZoneID(sep->arg[0]);
  10382. if (zone_info->id > 0)
  10383. {
  10384. database.LoadZoneInfo(zone_info);
  10385. 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);
  10386. 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);
  10387. 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);
  10388. 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);
  10389. 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);
  10390. 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);
  10391. 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);
  10392. client->Message(CHANNEL_COLOR_YELLOW, "zone_type: %s, sky_file: %s", zone_info->zone_type, zone_info->sky_file);
  10393. client->Message(CHANNEL_COLOR_YELLOW, "lua_script: %s", zone_info->lua_script);
  10394. client->Message(CHANNEL_COLOR_YELLOW, "zone_motd: %s", zone_info->zone_motd);
  10395. }
  10396. else
  10397. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  10398. }
  10399. else
  10400. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone details [zone id|zone name]");
  10401. safe_delete(zone_info);
  10402. }
  10403. /*
  10404. Function:
  10405. Purpose :
  10406. Params :
  10407. Dev :
  10408. Example :
  10409. */
  10410. void Commands::Command_ZoneSet(Client* client, Seperator* sep)
  10411. {
  10412. if (sep && sep->arg[0] && sep->arg[1] && sep->arg[2])
  10413. {
  10414. ZoneServer* zone = 0;
  10415. int32 zone_id = 0;
  10416. if (sep->IsNumber(0) && atoi(sep->arg[0]) > 0)
  10417. {
  10418. zone_id = atoi(sep->arg[0]);
  10419. zone = zone_list.Get(atoi(sep->arg[0]), false, false, false);
  10420. }
  10421. else
  10422. {
  10423. zone_id = database.GetZoneID(sep->arg[0]);
  10424. if (zone_id > 0)
  10425. zone = zone_list.Get(sep->arg[0], false, false, false);
  10426. }
  10427. if (zone_id > 0)
  10428. {
  10429. if (zone_set_values.count(string(sep->arg[1])) > 0)
  10430. SetZoneCommand(client, zone_id, zone, zone_set_values[sep->arg[1]], sep->arg[2]);
  10431. else
  10432. client->Message(CHANNEL_COLOR_YELLOW, "The attribute '%s' is not valid.", sep->arg[1]);
  10433. }
  10434. else
  10435. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  10436. }
  10437. else
  10438. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone set [zone id|zone name] [attribute] [value]");
  10439. }
  10440. void Commands::Command_Rain(Client* client, Seperator* sep) {
  10441. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  10442. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /rain <float>");
  10443. return;
  10444. }
  10445. client->Message(CHANNEL_COLOR_YELLOW,"Setting rain to %.2f", atof(sep->arg[0]));
  10446. client->GetCurrentZone()->SetRain(atof(sep->arg[0]));
  10447. client->GetCurrentZone()->SetCurrentWeather(atof(sep->arg[0]));
  10448. }
  10449. void Commands::Command_Wind(Client* client, Seperator* sep) {
  10450. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  10451. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /wind <float>");
  10452. return;
  10453. }
  10454. client->Message(CHANNEL_COLOR_YELLOW, "Setting wind to %.2f", atof(sep->arg[0]));
  10455. client->GetCurrentZone()->SetWind(atof(sep->arg[0]));
  10456. }
  10457. void Commands::Command_SendMerchantWindow(Client* client, Seperator* sep, bool sell) {
  10458. Spawn* spawn = client->GetPlayer()->GetTarget();
  10459. if(client->GetVersion() <= 546) {
  10460. sell = false; // doesn't support in the same way as AoM just open the normal buy/sell window
  10461. }
  10462. if(spawn) {
  10463. client->SetMerchantTransaction(spawn);
  10464. if (spawn->GetMerchantID() > 0 && spawn->IsClientInMerchantLevelRange(client)){
  10465. client->SendHailCommand(spawn);
  10466. //MerchantFactionMultiplier* multiplier = world.GetMerchantMultiplier(spawn->GetMerchantID());
  10467. //if(!multiplier || (multiplier && client->GetPlayer()->GetFactions()->GetFactionValue(multiplier->faction_id) >= multiplier->faction_min)){
  10468. client->SendBuyMerchantList(sell);
  10469. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY))
  10470. client->SendSellMerchantList(sell);
  10471. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY_BACK))
  10472. client->SendBuyBackList(sell);
  10473. if(client->GetVersion() > 546) {
  10474. PacketStruct* packet = configReader.getStruct("WS_UpdateMerchant", client->GetVersion());
  10475. if (packet) {
  10476. packet->setDataByName("spawn_id", 0xFFFFFFFF);
  10477. packet->setDataByName("type", 16);
  10478. EQ2Packet* outapp = packet->serialize();
  10479. if (outapp)
  10480. client->QueuePacket(outapp);
  10481. safe_delete(packet);
  10482. }
  10483. }
  10484. }
  10485. if (spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR)
  10486. client->SendRepairList();
  10487. }
  10488. // client->SimpleMessage(CHANNEL_COLOR_RED, "Your faction is too low to use this merchant.");
  10489. }
  10490. void Commands::Command_Weather(Client* client, Seperator* sep)
  10491. {
  10492. //PrintSep(sep, "Weather");
  10493. if( sep && sep->arg[0] )
  10494. {
  10495. ZoneServer* zsZone = client->GetCurrentZone();
  10496. const char* value = sep->arg[0];
  10497. // process single-param commands first
  10498. if( strncasecmp(value, "details", strlen(value)) == 0 )
  10499. {
  10500. client->Message(CHANNEL_COLOR_YELLOW, "Weather Details for zone %s: ", zsZone->GetZoneName());
  10501. client->Message(CHANNEL_COLOR_YELLOW, "enabled: %i, allowed: %i, type: %i, frequency: %u", zsZone->isWeatherEnabled(), zsZone->isWeatherAllowed(), zsZone->GetWeatherType(), zsZone->GetWeatherFrequency());
  10502. client->Message(CHANNEL_COLOR_YELLOW, "severity: %.2f = %.2f, current: %.2f", zsZone->GetWeatherMinSeverity(), zsZone->GetWeatherMaxSeverity(), zsZone->GetCurrentWeather());
  10503. client->Message(CHANNEL_COLOR_YELLOW, "pattern: %i, chance: %i, amount: %.2f, offset: %.2f", zsZone->GetWeatherPattern(), zsZone->GetWeatherChance(), zsZone->GetWeatherChangeAmount(), zsZone->GetWeatherDynamicOffset());
  10504. }
  10505. else if( strncasecmp(value, "process", strlen(value)) == 0 )
  10506. {
  10507. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  10508. zsZone->ProcessWeather();
  10509. }
  10510. else if( strncasecmp(value, "reset", strlen(value)) == 0 )
  10511. {
  10512. zsZone->SetWeatherType(rule_manager.GetGlobalRule(R_Zone, WeatherType)->GetInt8());
  10513. zsZone->SetWeatherFrequency(rule_manager.GetGlobalRule(R_Zone, WeatherChangeFrequency)->GetInt32());
  10514. zsZone->SetWeatherMinSeverity(rule_manager.GetGlobalRule(R_Zone, MinWeatherSeverity)->GetFloat());
  10515. zsZone->SetWeatherMaxSeverity(rule_manager.GetGlobalRule(R_Zone, MaxWeatherSeverity)->GetFloat());
  10516. zsZone->SetCurrentWeather(zsZone->GetWeatherMinSeverity());
  10517. zsZone->SetWeatherPattern(1);
  10518. zsZone->SetWeatherChance(rule_manager.GetGlobalRule(R_Zone, WeatherChangeChance)->GetInt8());
  10519. zsZone->SetWeatherChangeAmount(rule_manager.GetGlobalRule(R_Zone, WeatherChangePerInterval)->GetFloat());
  10520. zsZone->SetWeatherDynamicOffset(rule_manager.GetGlobalRule(R_Zone, WeatherDynamicMaxOffset)->GetFloat());
  10521. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  10522. zsZone->ProcessWeather();
  10523. }
  10524. // process commands with params
  10525. if( sep->arg[1] )
  10526. {
  10527. if( strncasecmp(value, "enable", strlen(value)) == 0 && sep->IsNumber(1) )
  10528. zsZone->SetWeatherEnabled( ( atoi(sep->arg[1]) == 1 ) ? true : false );
  10529. else if( strncasecmp(value, "type", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 3) )
  10530. zsZone->SetWeatherType(atoi(sep->arg[1]));
  10531. else if( strncasecmp(value, "frequency", strlen(value)) == 0 && sep->IsNumber(1))
  10532. zsZone->SetWeatherFrequency( atoul(sep->arg[1]) );
  10533. else if( strncasecmp(value, "range", strlen(value)) == 0 && sep->IsNumber(1) && sep->IsNumber(2) ) {
  10534. zsZone->SetWeatherMinSeverity(atof(sep->arg[1]));
  10535. zsZone->SetWeatherMaxSeverity(atof(sep->arg[2]));
  10536. zsZone->SetRain(zsZone->GetWeatherMinSeverity());
  10537. }
  10538. else if( strncasecmp(value, "current", strlen(value)) == 0 && sep->IsNumber(1) ) {
  10539. zsZone->SetCurrentWeather(atof(sep->arg[1]));
  10540. zsZone->SetRain(zsZone->GetCurrentWeather());
  10541. }
  10542. else if( strncasecmp(value, "pattern", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 2) )
  10543. zsZone->SetWeatherPattern( atoi(sep->arg[1]) );
  10544. else if( strncasecmp(value, "chance", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 100) )
  10545. zsZone->SetWeatherChance( atoi(sep->arg[1]) );
  10546. else if( strncasecmp(value, "amount", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  10547. zsZone->SetWeatherChangeAmount( atof(sep->arg[1]) );
  10548. else if( strncasecmp(value, "offset", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  10549. zsZone->SetWeatherDynamicOffset( atof(sep->arg[1]) );
  10550. }
  10551. }
  10552. else
  10553. {
  10554. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /weather [command] [param]");
  10555. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: enable (0|1), type (0-3), frequency (sec), range|current (0.0 - 1.0)");
  10556. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: details, process, pattern (0|1), chance (%), amount (float), offset (float)");
  10557. return;
  10558. }
  10559. }
  10560. void Commands::Command_Select(Client* client, Seperator* sep) {
  10561. if (sep && sep->arg[1]) {
  10562. Spawn* spawn = client->GetPlayer()->GetTarget();
  10563. if (spawn && strlen(sep->arg[1]) > 0)
  10564. client->GetCurrentZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_CUSTOM, client->GetPlayer(), sep->arg[1]);
  10565. }
  10566. }
  10567. /*
  10568. Function: Command_ConsumeFood()
  10569. Purpose : Consume Food/Drink and apply mods
  10570. Params : Slot ID - EQ2_FOOD_SLOT 22, EQ2_DRINK_SLOT 23
  10571. Dev : Zcoretri
  10572. Example : /consume_food 22
  10573. */
  10574. void Commands::Command_ConsumeFood(Client* client, Seperator* sep) {
  10575. if (sep && sep->arg[0] && sep->IsNumber(0))
  10576. {
  10577. Player* player = client->GetPlayer();
  10578. int8 slot = atoi(sep->arg[0]);
  10579. if (client->GetVersion() <= 283) {
  10580. slot += 4;
  10581. }
  10582. else if (client->GetVersion() <= 546) {
  10583. slot += 2;
  10584. }
  10585. Item* item = player->GetEquipmentList()->GetItem(slot);
  10586. if(client->CheckConsumptionAllowed(slot)) {
  10587. client->ConsumeFoodDrink(item, slot);
  10588. }
  10589. }
  10590. }
  10591. void Commands::Command_Aquaman(Client* client, Seperator* sep) {
  10592. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  10593. if (atoi(sep->arg[0]) == 1) {
  10594. client->GetPlayer()->GetInfoStruct()->set_vision(4);
  10595. client->GetPlayer()->GetInfoStruct()->set_breathe_underwater(1);
  10596. client->GetPlayer()->SetCharSheetChanged(true);
  10597. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Maybe you ought to stick to the shallow end until you know how to swim.");
  10598. }
  10599. else {
  10600. client->GetPlayer()->GetInfoStruct()->set_vision(0);
  10601. client->GetPlayer()->GetInfoStruct()->set_breathe_underwater(0);
  10602. client->GetPlayer()->SetCharSheetChanged(true);
  10603. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Aquaman mode turned off.");
  10604. }
  10605. }
  10606. else
  10607. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /aquaman [0|1]");
  10608. }
  10609. void Commands::Command_ReportBug(Client* client, Seperator* sep)
  10610. {
  10611. if(sep)
  10612. {
  10613. string data;
  10614. if(sep->arg[0]){
  10615. data = string(sep->arg[0]);
  10616. }
  10617. for(int i=1;i<sep->GetMaxArgNum();i++){
  10618. if(sep->arg[i])
  10619. data.append(" ").append(sep->arg[i]);
  10620. }
  10621. const char* target_name = 0;
  10622. int32 spawn_id = 0;
  10623. if(client->GetPlayer()->GetTarget())
  10624. {
  10625. target_name = client->GetPlayer()->GetTarget()->GetName();
  10626. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  10627. }
  10628. else
  10629. target_name = "N/A";
  10630. LogWrite(COMMAND__DEBUG, 1, "Command", "%s", data.c_str());
  10631. if(world.ReportBug(data, client->GetPlayer()->GetName(), client->GetAccountID(), target_name, spawn_id, client->GetCurrentZone()->GetZoneID()))
  10632. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully submitted bug.");
  10633. else
  10634. client->SimpleMessage(CHANNEL_COLOR_RED, "Error submitting bug.");
  10635. }
  10636. }
  10637. void Commands::Command_Attune_Inv(Client* client, Seperator* sep) {
  10638. PrintSep(sep, "Command_Attune_Inv");
  10639. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  10640. // Get the item index from the first parameter
  10641. int16 index = atoi(sep->arg[0]);
  10642. // Check to see if this is a valid item index for the player, if not exit out of the function
  10643. if (client->GetPlayer()->item_list.indexed_items.count(index) == 0) {
  10644. LogWrite(ITEM__DEBUG, 0, "Items", "%s has no item with an index of %i", client->GetPlayer()->GetName(), index);
  10645. return;
  10646. }
  10647. // Get the item
  10648. Item* item = client->GetPlayer()->item_list.indexed_items[index];
  10649. if(item) {
  10650. // Valid item lets check to make sure this item is attunable, if not return out
  10651. if (!item->CheckFlag(ATTUNEABLE)) {
  10652. LogWrite(ITEM__DEBUG, 0, "Items", "attune_inv called for an item that is not attunable (%s)", item->name.c_str());
  10653. return;
  10654. }
  10655. // Remove the attunable flag
  10656. item->generic_info.item_flags -= ATTUNEABLE;
  10657. // Set the attuned flag
  10658. item->generic_info.item_flags += ATTUNED;
  10659. // Flag this item for saving
  10660. item->save_needed = true;
  10661. client->QueuePacket(item->serialize(client->GetVersion(), false, client->GetPlayer()));
  10662. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), 0, -1); // appearance type??
  10663. EQ2Packet* outapp = 0;
  10664. for (int32 i=0;i<packets.size();i++) {
  10665. outapp = packets[i];
  10666. if(outapp)
  10667. client->QueuePacket(outapp);
  10668. }
  10669. }
  10670. }
  10671. }
  10672. void Commands::Command_Reset_Zone_Timer(Client* client, Seperator* sep) {
  10673. PrintSep(sep, "Command_Reset_Zone_Timer");
  10674. /*if (sep && sep->arg[0] && sep->IsNumber(0)) {
  10675. int32 db_id = atoul(sep->arg[0]);
  10676. InstanceData* data = client->GetPlayer()->GetCharacterInstances().FindInstanceByDBID(db_id);
  10677. if (data) {
  10678. // TODO: add a check to timers to ensure it can be reset
  10679. // Delete the character from the instance
  10680. database.DeleteCharacterFromInstance(client->GetPlayer()->GetCharacterID(), data->instance_id);
  10681. data->instance_id = 0;
  10682. // Update the success time and set to 0 so the player can enter it again
  10683. database.UpdateCharacterInstance(client->GetPlayer()->GetCharacterID(), data->zone_name, 0, 1, 0);
  10684. data->last_success_timestamp = 0;
  10685. }
  10686. }*/
  10687. }
  10688. void Commands::Command_Player(Client* client, Seperator* sep) {
  10689. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player syntax --");
  10690. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins");
  10691. }
  10692. void Commands::Command_Player_Coins(Client* client, Seperator* sep) {
  10693. // /player coins add 10
  10694. // /player coins add plat 10
  10695. Player* player = client->GetPlayer();
  10696. Client* targetClient = client;
  10697. if (player->HasTarget() && player->GetTarget()->IsPlayer()) {
  10698. player = (Player*)player->GetTarget();
  10699. targetClient = player->GetClient();
  10700. }
  10701. if (sep && sep->arg[0] && sep->arg[1]) {
  10702. const char* action = sep->arg[0];
  10703. int64 value = 0;
  10704. if (strncasecmp(action, "add", strlen(action)) == 0) {
  10705. if (sep->IsNumber(1)) {
  10706. value = atoi64(sep->arg[1]);
  10707. player->AddCoins(value);
  10708. if (client->GetPlayer() == player)
  10709. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  10710. else {
  10711. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  10712. if(targetClient) {
  10713. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  10714. }
  10715. }
  10716. return;
  10717. }
  10718. else if (sep->arg[2] && sep->IsNumber(2)) {
  10719. const char* type = sep->arg[1];
  10720. if (strncasecmp(type, "copper", strlen(type)) == 0) {
  10721. value = atoi64(sep->arg[2]);
  10722. }
  10723. else if (strncasecmp(type, "silver", strlen(type)) == 0) {
  10724. value = atoi64(sep->arg[2]) * 100;
  10725. }
  10726. else if (strncasecmp(type, "gold", strlen(type)) == 0) {
  10727. value = atoi64(sep->arg[2]) * 10000;
  10728. }
  10729. else if (strncasecmp(type, "plat", strlen(type)) == 0) {
  10730. value = atoi64(sep->arg[2]) * 1000000;
  10731. }
  10732. player->AddCoins(value);
  10733. if (client->GetPlayer() == player)
  10734. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  10735. else {
  10736. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  10737. if(targetClient) {
  10738. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  10739. }
  10740. }
  10741. return;
  10742. }
  10743. }
  10744. }
  10745. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player coins syntax --");
  10746. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add [value] - adds the given number of coins to the player");
  10747. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add copper [value] - adds the given amount of copper to the player");
  10748. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add silver [value] - adds the given amount of silver to the player");
  10749. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add gold [value] - adds the given amount of gold to the player");
  10750. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add plat [value] - adds the given amount of platinum to the player");
  10751. }
  10752. void Commands::Command_AchievementAdd(Client* client, Seperator* sep) {
  10753. PrintSep(sep, "ACHIEVEMENT_ADD");
  10754. if (sep && sep->IsSet(0)) {
  10755. int32 spell_id = atoul(sep->arg[1]);
  10756. int8 spell_tier = 0;
  10757. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  10758. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  10759. // addspellbookentry here
  10760. if (spell_tier >= data->maxRank) {
  10761. return;
  10762. }
  10763. if (!spell_tier) {
  10764. spell_tier = 1;
  10765. }
  10766. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  10767. {
  10768. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  10769. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  10770. client->GetPlayer()->UnlockSpell(spell);
  10771. client->SendSpellUpdate(spell);
  10772. }
  10773. else
  10774. {
  10775. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1);
  10776. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  10777. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  10778. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  10779. client->GetPlayer()->UnlockSpell(spell);
  10780. client->SendSpellUpdate(spell);
  10781. }
  10782. // cast spell here
  10783. if (!spell_tier)
  10784. spell_tier = 1;
  10785. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  10786. if (spell) {
  10787. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  10788. }
  10789. }
  10790. else {
  10791. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  10792. }
  10793. master_aa_list.DisplayAA(client, 0, 0);
  10794. }
  10795. void Commands::Command_Editor(Client* client, Seperator* sep) {
  10796. PacketStruct* packet = configReader.getStruct("WS_ChoiceWindow", client->GetVersion());
  10797. if (packet) {
  10798. string url = string(rule_manager.GetGlobalRule(R_World, EditorURL)->GetString());
  10799. if (rule_manager.GetGlobalRule(R_World, EditorOfficialServer)->GetBool()) {
  10800. char command[255];
  10801. url = "browser " + url;
  10802. int32 spawn_id = 0;
  10803. int32 zone_id = 0;
  10804. string type;
  10805. if (client->GetCurrentZone())
  10806. zone_id = client->GetCurrentZone()->GetZoneID();
  10807. if (client->GetPlayer()->GetTarget()) {
  10808. Spawn* target = client->GetPlayer()->GetTarget();
  10809. if (target->IsWidget())
  10810. type = "widgets";
  10811. else if (target->IsSign())
  10812. type = "signs";
  10813. else if (target->IsObject())
  10814. type = "objects";
  10815. else if (target->IsNPC())
  10816. type = "npcs";
  10817. else if (target->IsGroundSpawn())
  10818. type = "ground";
  10819. else
  10820. type = "spawn";
  10821. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  10822. }
  10823. sprintf(command, url.c_str(), zone_id, type.c_str(), spawn_id);
  10824. packet->setDataByName("accept_command", command);
  10825. }
  10826. else if (rule_manager.GetGlobalRule(R_World, EditorIncludeID)->GetBool()) {
  10827. char command[255];
  10828. url = "browser " + url;
  10829. if (client->GetPlayer()->GetTarget())
  10830. sprintf(command, url.c_str(), client->GetPlayer()->GetTarget()->GetDatabaseID());
  10831. packet->setDataByName("accept_command", command);
  10832. }
  10833. else {
  10834. string command = "browser " + url;
  10835. packet->setDataByName("accept_command", command.c_str());
  10836. }
  10837. packet->setDataByName("text", "Open the web editor?");
  10838. packet->setDataByName("accept_text", "Open");
  10839. packet->setDataByName("cancel_text", "Cancel");
  10840. // No clue if we even need the following 2 unknowns, just added them so the packet matches what live sends
  10841. packet->setDataByName("unknown2", 50);
  10842. packet->setDataByName("unknown4", 1);
  10843. client->QueuePacket(packet->serialize());
  10844. safe_delete(packet);
  10845. }
  10846. }
  10847. void Commands::Command_AcceptResurrection(Client* client, Seperator* sep) {
  10848. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  10849. return;
  10850. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  10851. if(client->GetCurrentRez()->active)
  10852. client->AcceptResurrection();
  10853. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  10854. }
  10855. void Commands::Command_DeclineResurrection(Client* client, Seperator* sep) {
  10856. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  10857. return;
  10858. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  10859. if(client->GetCurrentRez()->active)
  10860. client->GetCurrentRez()->should_delete = true;
  10861. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  10862. }
  10863. void Commands::Switch_AA_Profile(Client* client, Seperator* sep) {
  10864. PrintSep(sep, "Switch_AA_Profile");
  10865. if (sep && sep->IsSet(0)) {
  10866. string type = sep->arg[0];
  10867. int8 newtemplate = atoul(sep->arg[1]);
  10868. master_aa_list.DisplayAA(client, newtemplate, 1);
  10869. }
  10870. }
  10871. void Commands::Get_AA_Xml(Client* client, Seperator* sep) {
  10872. PrintSep(sep, "Get_AA_Xml");
  10873. if (sep && sep->IsSet(0)) {
  10874. string tabnum = sep->arg[0];
  10875. string spellid = sep->arg[1];
  10876. }
  10877. }
  10878. void Commands::Add_AA(Client* client, Seperator* sep) {
  10879. PrintSep(sep, "Add_AA");
  10880. if (sep && sep->IsSet(0)) {
  10881. int32 spell_id = atoul(sep->arg[1]);
  10882. int8 spell_tier = 0;
  10883. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  10884. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  10885. // addspellbookentry here
  10886. if(!data) {
  10887. LogWrite(COMMAND__ERROR, 0, "Command", "Error in Add_AA no data for spell_id %u spell_tier %u", spell_id, spell_tier);
  10888. return;
  10889. }
  10890. if (spell_tier >= data->maxRank) {
  10891. LogWrite(COMMAND__ERROR, 0, "Command", "Error in Add_AA spell_tier %u >= maxRank %u", spell_tier, data->maxRank);
  10892. return;
  10893. }
  10894. if (!spell_tier) {
  10895. spell_tier = 1;
  10896. }
  10897. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  10898. {
  10899. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  10900. if(spell)
  10901. {
  10902. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  10903. client->GetPlayer()->UnlockSpell(spell);
  10904. client->SendSpellUpdate(spell);
  10905. }
  10906. }
  10907. else
  10908. {
  10909. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1 );
  10910. if(spell)
  10911. {
  10912. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  10913. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  10914. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  10915. client->GetPlayer()->UnlockSpell(spell);
  10916. client->SendSpellUpdate(spell);
  10917. }
  10918. }
  10919. // cast spell here
  10920. if (!spell_tier)
  10921. spell_tier = 1;
  10922. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  10923. if (spell) {
  10924. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  10925. }
  10926. }
  10927. else {
  10928. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  10929. }
  10930. master_aa_list.DisplayAA(client, 0, 0);
  10931. }
  10932. void Commands::Commit_AA_Profile(Client* client, Seperator* sep) {
  10933. PrintSep(sep, "Commit_AA_Profile");
  10934. if (sep && sep->IsSet(0)) {
  10935. }
  10936. }
  10937. void Commands::Begin_AA_Profile(Client* client, Seperator* sep) {
  10938. PrintSep(sep, "Begin_AA_Profile");
  10939. if (sep && sep->IsSet(0)) {
  10940. master_aa_list.DisplayAA(client, 100, 2);
  10941. }
  10942. }
  10943. void Commands::Back_AA(Client* client, Seperator* sep) {
  10944. if (sep && sep->IsSet(0)) {
  10945. PrintSep(sep, "Back_AA");
  10946. }
  10947. }
  10948. void Commands::Remove_AA(Client* client, Seperator* sep) {
  10949. if (sep && sep->IsSet(0)) {
  10950. PrintSep(sep, "Remove_AA");
  10951. }
  10952. }
  10953. void Commands::Cancel_AA_Profile(Client* client, Seperator* sep) {
  10954. MasterAAList master_aa_list;
  10955. PrintSep(sep, "Cancel_AA_Profile");
  10956. master_aa_list.DisplayAA(client, 0, 0);
  10957. }
  10958. void Commands::Save_AA_Profile(Client* client, Seperator* sep) {
  10959. if (sep && sep->IsSet(0)) {
  10960. PrintSep(sep, "Save_AA_Profile");
  10961. }
  10962. }
  10963. void Commands::Command_TargetItem(Client* client, Seperator* sep) {
  10964. if (!sep || sep->GetArgNumber() < 1 || !client->GetPlayer()) return;
  10965. if (!sep->IsNumber(0)) return;
  10966. int32 request_id = atoul(sep->arg[0]);
  10967. if (!sep->IsNumber(1)) return;
  10968. sint32 item_id = atoi(sep->arg[1]);
  10969. if (client->IsCurrentTransmuteID(request_id)) {
  10970. Transmute::HandleItemResponse(client, client->GetPlayer(), request_id, reinterpret_cast<int32&>(item_id));
  10971. }
  10972. else if (client->IsCurrentTransmuteID(item_id)) {
  10973. if (!sep->IsSet(2)) return;
  10974. if (sep->IsNumber(2) && atoi(sep->arg[2]) == 1) {
  10975. Transmute::HandleConfirmResponse(client, client->GetPlayer(), reinterpret_cast<int32&>(item_id));
  10976. }
  10977. }
  10978. }
  10979. void Commands::Command_FindSpawn(Client* client, Seperator* sep) {
  10980. if(sep)
  10981. client->GetCurrentZone()->FindSpawn(client, (char*)sep->argplus[0]);
  10982. }
  10983. void Commands::Command_MoveCharacter(Client* client, Seperator* sep) {
  10984. if(sep && sep->arg[0][0] && sep->arg[1][0])
  10985. {
  10986. char* name = sep->arg[0];
  10987. char* zoneName = sep->arg[1];
  10988. char query[256];
  10989. 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);
  10990. if (database.RunQuery(query, strnlen(query, 256)))
  10991. {
  10992. client->Message(CHANNEL_COLOR_YELLOW, "Ran query:%s", query);
  10993. }
  10994. else
  10995. client->Message(CHANNEL_COLOR_RED, "Query FAILED to run: %s", query);
  10996. }
  10997. }
  10998. void Commands::Command_Mood(Client* client, Seperator* sep) {
  10999. Player* player = client->GetPlayer();
  11000. if( sep && sep->arg[0] )
  11001. {
  11002. const char* value = sep->arg[0];
  11003. InfoStruct* info = player->GetInfoStruct();
  11004. int32 cid = client->GetCharacterID();
  11005. char* characterName = database.GetCharacterName(cid);
  11006. char tmp[1024]; // our emote string "xyz appears zyx"
  11007. //char properties vals
  11008. char* pname = "mood";
  11009. char* pval; // mood value
  11010. bool pt; //used to verify return from DB.
  11011. //This should never be seen.
  11012. sprintf(tmp, " ");
  11013. if( strncasecmp(value, "angry", strlen(value)) == 0 )
  11014. {
  11015. sprintf(tmp, "%s appears angry", characterName);
  11016. pval = "11852";
  11017. player->SetMoodState(11852, 1);
  11018. info->set_mood(11852);
  11019. pt = database.insertCharacterProperty(client, pname, pval);
  11020. }
  11021. else if( strncasecmp(value, "afraid", strlen(value)) == 0 )
  11022. {
  11023. sprintf(tmp, "%s appears afraid", characterName);
  11024. pval = "11851";
  11025. player->SetMoodState(11851, 1);
  11026. info->set_mood(11851);
  11027. pt = database.insertCharacterProperty(client, pname, pval);
  11028. }
  11029. else if( strncasecmp(value, "happy", strlen(value)) == 0 )
  11030. {
  11031. sprintf(tmp, "%s appears happy", characterName);
  11032. pval = "11854";
  11033. player->SetMoodState(11854, 1);
  11034. info->set_mood(11854);
  11035. pt = database.insertCharacterProperty(client, pname, pval);
  11036. }
  11037. else if( strncasecmp(value, "sad", strlen(value)) == 0 ) {
  11038. sprintf(tmp, "%s appears sad", characterName);
  11039. pval = "11856";
  11040. player->SetMoodState(11856, 1);
  11041. info->set_mood(11856);
  11042. pt = database.insertCharacterProperty(client, pname, pval);
  11043. }
  11044. else if( strncasecmp(value, "tired", strlen(value)) == 0 )
  11045. {
  11046. sprintf(tmp, "%s appears tired", characterName);
  11047. pval = "11857";
  11048. player->SetMoodState(11857, 1);
  11049. info->set_mood(11857);
  11050. pt = database.insertCharacterProperty(client, pname, pval);
  11051. }
  11052. else if( strncasecmp(value, "none", strlen(value)) == 0 )
  11053. {
  11054. //using 11855 mood_idle for none, I assume thats what its for?
  11055. pval = "11855";
  11056. player->SetMoodState(11855, 1);
  11057. info->set_mood(11855);
  11058. pt = database.insertCharacterProperty(client, pname, pval);
  11059. //return since we have nothing left to do. No emote for none.
  11060. return;
  11061. }else{
  11062. client->SimpleMessage(CHANNEL_NARRATIVE, "Listing Available Moods:");
  11063. client->SimpleMessage(CHANNEL_NARRATIVE, "none");
  11064. client->SimpleMessage(CHANNEL_NARRATIVE, "afraid");
  11065. client->SimpleMessage(CHANNEL_NARRATIVE, "angry");
  11066. client->SimpleMessage(CHANNEL_NARRATIVE, "happy");
  11067. client->SimpleMessage(CHANNEL_NARRATIVE, "sad");
  11068. client->SimpleMessage(CHANNEL_NARRATIVE, "tired");
  11069. return;
  11070. }
  11071. client->GetPlayer()->GetZone()->HandleChatMessage(0, 0, CHANNEL_EMOTE, tmp);
  11072. return;
  11073. }
  11074. client->SimpleMessage(CHANNEL_NARRATIVE, "Listing Available Moods:");
  11075. client->SimpleMessage(CHANNEL_NARRATIVE, "none");
  11076. client->SimpleMessage(CHANNEL_NARRATIVE, "afraid");
  11077. client->SimpleMessage(CHANNEL_NARRATIVE, "angry");
  11078. client->SimpleMessage(CHANNEL_NARRATIVE, "happy");
  11079. client->SimpleMessage(CHANNEL_NARRATIVE, "sad");
  11080. client->SimpleMessage(CHANNEL_NARRATIVE, "tired");
  11081. return;
  11082. }
  11083. /*
  11084. Function: Command_CancelEffect()
  11085. Purpose : Cancels (good) effect spells
  11086. Example : /cancel_effect spell_id - would cancel the spell with the <spell_id> value in spell effects list
  11087. */
  11088. void Commands::Command_CancelEffect(Client* client, Seperator* sep)
  11089. {
  11090. if (sep && sep->arg[0] && sep->IsNumber(0))
  11091. {
  11092. int32 spell_id = atoul(sep->arg[0]);
  11093. SpellEffects* effect = client->GetPlayer()->GetSpellEffect(spell_id);
  11094. if(!effect || effect->spell->spell->GetSpellData()->det_type) {
  11095. return;
  11096. }
  11097. MaintainedEffects* meffect = effect->caster->GetMaintainedSpell(spell_id);
  11098. if (!meffect || !meffect->spell || !meffect->spell->caster || !meffect->spell->caster->GetZone() ||
  11099. !meffect->spell->caster->GetZone()->GetSpellProcess()->DeleteCasterSpell(meffect->spell, "canceled", false, client->GetPlayer()))
  11100. client->Message(CHANNEL_COLOR_RED, "The spell effect could not be cancelled.");
  11101. }
  11102. }
  11103. /*
  11104. Function: Command_CurePlayer()
  11105. Purpose : Identifies spell to cast for cure based on type
  11106. Example : /cureplayer ??
  11107. https://eq2.fandom.com/wiki/Update:58
  11108. New command /cureplayer [playername|group or raid position][trauma|arcane|noxious|elemental|curse] optional [spell|potion]
  11109. Example: /cureplayer g0 noxious spell
  11110. Will attempt to cure yourself of a noxious detriment with only spells and without using potions (even if you have them).
  11111. Example: /cureplayer r4 noxious
  11112. Will attempt to cure the character in raid slot 4 of a noxious detriment using a spell or potion (whichever is available).
  11113. */
  11114. void Commands::Command_CurePlayer(Client* client, Seperator* sep)
  11115. {
  11116. Entity* target = nullptr;
  11117. bool use_spells = true;
  11118. bool use_potions = true;
  11119. if (sep && sep->arg[0] && sep->arg[1]) {
  11120. if(sep->arg[2]) {
  11121. std::string type(sep->arg[2]);
  11122. boost::algorithm::to_lower(type);
  11123. if(type == "potion")
  11124. use_spells = false;
  11125. else if(type == "spell")
  11126. use_potions = false;
  11127. }
  11128. if(strlen(sep->arg[0]) > 1 && isdigit(sep->arg[0][1])) {
  11129. int32 mapped_position = (int32)(sep->arg[0][1]) - 48;
  11130. // TODO: RAID Support ('r' argument)
  11131. if(sep->arg[0][0] == 'g' && !mapped_position) {
  11132. target = (Entity*)client->GetPlayer();
  11133. }
  11134. else {
  11135. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  11136. if (gmi && gmi->group_id) {
  11137. PlayerGroup* group = world.GetGroupManager()->GetGroup(gmi->group_id);
  11138. if(group) {
  11139. target = group->GetGroupMemberByPosition(client->GetPlayer(), mapped_position);
  11140. }
  11141. }
  11142. }
  11143. }
  11144. else {
  11145. Client* target_client = zone_list.GetClientByCharName(sep->arg[0]);
  11146. if(target_client && target_client->GetPlayer() && target_client->GetPlayer()->GetZone() == client->GetPlayer()->GetZone()) {
  11147. target = (Entity*)target_client->GetPlayer();
  11148. }
  11149. }
  11150. ItemEffectType type = EFFECT_CURE_TYPE_ALL;
  11151. bool successful_spell = false;
  11152. bool successful_potion = false;
  11153. if(target) {
  11154. SpellBookEntry* entry = nullptr;
  11155. std::string str(sep->arg[1]);
  11156. boost::algorithm::to_lower(str);
  11157. if(str == "arcane") {
  11158. type = EFFECT_CURE_TYPE_ARCANE;
  11159. // cure arcane spell missing in DB?
  11160. if(use_spells && rule_manager.GetGlobalRule(R_Spells, CureArcaneSpellID)->GetInt32()) {
  11161. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureArcaneSpellID)->GetInt32()); // cure noxious
  11162. }
  11163. }
  11164. else if(str == "trauma") {
  11165. type = EFFECT_CURE_TYPE_TRAUMA;
  11166. // cure trauma spell missing in DB?
  11167. if(use_spells && rule_manager.GetGlobalRule(R_Spells, CureTraumaSpellID)->GetInt32()) {
  11168. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureTraumaSpellID)->GetInt32()); // cure noxious
  11169. }
  11170. }
  11171. else if(str == "noxious") {
  11172. type = EFFECT_CURE_TYPE_NOXIOUS;
  11173. if(use_spells && rule_manager.GetGlobalRule(R_Spells, CureNoxiousSpellID)->GetInt32()) {
  11174. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureNoxiousSpellID)->GetInt32()); // cure noxious
  11175. }
  11176. }
  11177. else if(str == "curse") {
  11178. type = EFFECT_CURE_TYPE_CURSE;
  11179. if(use_spells && rule_manager.GetGlobalRule(R_Spells, CureCurseSpellID)->GetInt32()) {
  11180. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureCurseSpellID)->GetInt32()); // cure curse
  11181. }
  11182. }
  11183. else if(str == "magic") {
  11184. type = EFFECT_CURE_TYPE_MAGIC;
  11185. if(use_spells && rule_manager.GetGlobalRule(R_Spells, CureMagicSpellID)->GetInt32()) {
  11186. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureMagicSpellID)->GetInt32()); // cure magic
  11187. }
  11188. }
  11189. if(use_spells) {
  11190. // check if any of the specific cure types are available, if not then check the base cures
  11191. if(!entry && rule_manager.GetGlobalRule(R_Spells, CureSpellID)->GetInt32()) {
  11192. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureSpellID)->GetInt32()); // cure
  11193. }
  11194. if(entry && entry->spell_id) {
  11195. Spell* spell = master_spell_list.GetSpell(entry->spell_id, entry->tier);
  11196. target->GetZone()->ProcessSpell(spell, (Entity*)client->GetPlayer(), target, true, false);
  11197. successful_spell = true;
  11198. }
  11199. }
  11200. }
  11201. if(!successful_spell && use_potions && target && type != NO_EFFECT_TYPE) {
  11202. vector<Item*>* potential_items = client->GetItemsByEffectType(type, EFFECT_CURE_TYPE_ALL);
  11203. if (potential_items && potential_items->size() > 0) {
  11204. vector<Item*>::iterator itr;
  11205. for (itr = potential_items->begin(); itr != potential_items->end(); itr++)
  11206. {
  11207. Item* item = *itr;
  11208. if(client->UseItem(item, target)) {
  11209. successful_potion = true;
  11210. break;
  11211. }
  11212. }
  11213. }
  11214. safe_delete(potential_items);
  11215. }
  11216. }
  11217. }
  11218. /*
  11219. Function: Command_ShareQuest()
  11220. Purpose : Share quest with the group
  11221. Example : /share_quest [quest_id]
  11222. */
  11223. void Commands::Command_ShareQuest(Client* client, Seperator* sep)
  11224. {
  11225. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  11226. int32 quest_id = atoul(sep->arg[0]);
  11227. bool hasQuest = client->GetPlayer()->HasAnyQuest(quest_id);
  11228. if(hasQuest) {
  11229. Quest* quest = master_quest_list.GetQuest(quest_id, false);
  11230. if(quest) {
  11231. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  11232. if (gmi && gmi->group_id) {
  11233. PlayerGroup* group = world.GetGroupManager()->GetGroup(gmi->group_id);
  11234. if (group) {
  11235. group->ShareQuestWithGroup(client, quest);
  11236. }
  11237. }
  11238. }
  11239. }
  11240. else {
  11241. client->SimpleMessage(CHANNEL_COLOR_RED, "Cannot find quest.");
  11242. }
  11243. }
  11244. }
  11245. /*
  11246. Function: Command_Yell()
  11247. Purpose : Yell to break an encounter
  11248. Example : /yell
  11249. * Uses self target, encounter target or no target
  11250. */
  11251. void Commands::Command_Yell(Client* client, Seperator* sep) {
  11252. Entity* player = (Entity*)client->GetPlayer();
  11253. Spawn* res = nullptr;
  11254. Spawn* prev = nullptr;
  11255. bool cycleAll = false;
  11256. if (player->GetTarget() == player) {
  11257. cycleAll = true; // self target breaks all encounters
  11258. }
  11259. else if (player->GetTarget()) {
  11260. res = player->GetTarget(); // selected target other than self only dis-engages that encounter
  11261. }
  11262. if (res && !client->GetPlayer()->IsEngagedBySpawnID(res->GetID()))
  11263. return;
  11264. bool groupPermissionYell = true;
  11265. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  11266. // If the player has a group and has a target
  11267. if (gmi) {
  11268. deque<GroupMemberInfo*>::iterator itr;
  11269. world.GetGroupManager()->GroupLock(__FUNCTION__, __LINE__);
  11270. PlayerGroup* group = world.GetGroupManager()->GetGroup(gmi->group_id);
  11271. if (group && !group->GetGroupOptions()->default_yell && !gmi->leader) { // default_yell_method = 0 means leader only
  11272. groupPermissionYell = false;
  11273. }
  11274. world.GetGroupManager()->ReleaseGroupLock(__FUNCTION__, __LINE__);
  11275. }
  11276. if (!groupPermissionYell) {
  11277. LogWrite(COMMAND__ERROR, 0, "Command", "%s permission to yell denied due to group yell method set to leader only", client->GetPlayer()->GetName());
  11278. return;
  11279. }
  11280. bool alreadyYelled = false;
  11281. do {
  11282. if (!res && player->IsEngagedInEncounter(&res)) { // no target is set, dis-engage top of hated by list
  11283. }
  11284. if (!res || prev == res) {
  11285. return;
  11286. }
  11287. if (res->IsNPC() && ((NPC*)res)->Brain()) {
  11288. if (!alreadyYelled) {
  11289. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You yell for help!");
  11290. string yellMsg = std::string(client->GetPlayer()->GetName()) + " yelled for help!";
  11291. client->GetPlayer()->GetZone()->SimpleMessage(CHANNEL_COLOR_RED, yellMsg.c_str(), client->GetPlayer(), 35.0f, false);
  11292. client->GetPlayer()->GetZone()->SendYellPacket(client->GetPlayer());
  11293. }
  11294. alreadyYelled = true;
  11295. NPC* npc = (NPC*)res;
  11296. npc->Brain()->ClearEncounter();
  11297. npc->SetLockedNoLoot(ENCOUNTER_STATE_BROKEN);
  11298. npc->UpdateEncounterState(ENCOUNTER_STATE_BROKEN);
  11299. }
  11300. prev = res;
  11301. res = nullptr;
  11302. } while (cycleAll);
  11303. if (!player->IsEngagedInEncounter()) {
  11304. if (player->GetInfoStruct()->get_engaged_encounter()) {
  11305. player->GetInfoStruct()->set_engaged_encounter(0);
  11306. player->SetRegenValues((player->GetInfoStruct()->get_effective_level() > 0) ? player->GetInfoStruct()->get_effective_level() : player->GetLevel());
  11307. client->GetPlayer()->SetCharSheetChanged(true);
  11308. player->info_changed = true;
  11309. }
  11310. }
  11311. }
  11312. /*
  11313. Function: Command_SetAutoLootMode()
  11314. Purpose : Set player auto loot mode (0 = disabled, 1 = need/lotto, 2 = decline).
  11315. Example : /setautolootmode [mode]
  11316. */
  11317. void Commands::Command_SetAutoLootMode(Client* client, Seperator* sep) {
  11318. if (sep && sep->IsNumber(0)) {
  11319. int8 mode = atoul(sep->arg[0]);
  11320. switch (mode) {
  11321. case AutoLootMode::METHOD_DISABLED: {
  11322. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Disabled auto loot mode");
  11323. break;
  11324. }
  11325. case AutoLootMode::METHOD_ACCEPT: {
  11326. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Enabled auto loot mode for need and lotto.");
  11327. break;
  11328. }
  11329. default: {
  11330. mode = AutoLootMode::METHOD_DISABLED;
  11331. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Enabled auto loot mode to decline need and lotto.");
  11332. break;
  11333. }
  11334. }
  11335. client->GetPlayer()->GetInfoStruct()->set_group_auto_loot_method(mode);
  11336. database.insertCharacterProperty(client, CHAR_PROPERTY_AUTOLOOTMETHOD, (char*)std::to_string(mode).c_str());
  11337. client->SendDefaultGroupOptions();
  11338. }
  11339. }