Commands.cpp 450 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381
  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(int16 version){
  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->SetTotalHPBase(val);
  429. target->SetHP(val, send_update);
  430. break;
  431. }
  432. case SPAWN_SET_VALUE_POWER:{
  433. sprintf(tmp, "%i", target->GetPower());
  434. target->SetTotalPowerBase(val);
  435. target->SetPower(val, send_update);
  436. break;
  437. }
  438. case SPAWN_SET_VALUE_HEROIC:{
  439. sprintf(tmp, "%i", target->GetHeroic());
  440. target->SetHeroic(val, send_update);
  441. break;
  442. }
  443. case SPAWN_SET_VALUE_RESPAWN:{
  444. sprintf(tmp, "%u", target->GetRespawnTime());
  445. target->SetRespawnTime(val);
  446. break;
  447. }
  448. case SPAWN_SET_VALUE_X:{
  449. sprintf(tmp, "%f", target->GetX());
  450. target->SetX(atof(value), send_update);
  451. break;
  452. }
  453. case SPAWN_SET_VALUE_Y:{
  454. sprintf(tmp, "%f", target->GetY());
  455. target->SetY(atof(value), send_update);
  456. break;
  457. }
  458. case SPAWN_SET_VALUE_Z:{
  459. sprintf(tmp, "%f", target->GetZ());
  460. target->SetZ(atof(value), send_update);
  461. break;
  462. }
  463. case SPAWN_SET_VALUE_HEADING:{
  464. sprintf(tmp, "%f", target->GetHeading());
  465. target->SetHeading(atof(value) + 360, send_update);
  466. break;
  467. }
  468. case SPAWN_SET_VALUE_VISUAL_STATE:{
  469. sprintf(tmp, "%i", target->GetVisualState());
  470. target->SetVisualState(val, send_update);
  471. break;
  472. }
  473. case SPAWN_SET_VALUE_ACTION_STATE:{
  474. sprintf(tmp, "%i", target->GetActionState());
  475. target->SetActionState(val, send_update);
  476. break;
  477. }
  478. case SPAWN_SET_VALUE_MOOD_STATE:{
  479. sprintf(tmp, "%i", target->GetMoodState());
  480. target->SetMoodState(val, send_update);
  481. break;
  482. }
  483. case SPAWN_SET_VALUE_INITIAL_STATE:{
  484. sprintf(tmp, "%i", target->GetInitialState());
  485. target->SetInitialState(val, send_update);
  486. break;
  487. }
  488. case SPAWN_SET_VALUE_ACTIVITY_STATE:{
  489. sprintf(tmp, "%i", target->GetActivityStatus());
  490. target->SetActivityStatus(val, send_update);
  491. break;
  492. }
  493. case SPAWN_SET_VALUE_COLLISION_RADIUS:{
  494. sprintf(tmp, "%i", target->GetCollisionRadius());
  495. target->SetCollisionRadius(val, send_update);
  496. break;
  497. }
  498. case SPAWN_SET_VALUE_DEVICE_ID: {
  499. if (target->IsObject()) {
  500. sprintf(tmp, "%i", ((Object*)target)->GetDeviceID());
  501. ((Object*)target)->SetDeviceID(val);
  502. }
  503. break;
  504. }
  505. case SPAWN_SET_VALUE_PITCH: {
  506. sprintf(tmp, "%f", target->GetPitch());
  507. target->SetPitch(atof(value), send_update);
  508. break;
  509. }
  510. case SPAWN_SET_VALUE_ROLL: {
  511. sprintf(tmp, "%f", target->GetRoll());
  512. target->SetRoll(atof(value), send_update);
  513. break;
  514. }
  515. case SPAWN_SET_VALUE_HIDE_HOOD: {
  516. sprintf(tmp, "%i", target->appearance.hide_hood);
  517. target->SetHideHood(val);
  518. break;
  519. }
  520. case SPAWN_SET_VALUE_EMOTE_STATE: {
  521. sprintf(tmp, "%i", target->appearance.emote_state);
  522. target->SetEmoteState(val);
  523. break;
  524. }
  525. case SPAWN_SET_VALUE_ICON: {
  526. sprintf(tmp, "%i", target->GetIconValue());
  527. target->SetIcon(val);
  528. break;
  529. }
  530. case SPAWN_SET_VALUE_PREFIX: {
  531. sprintf(tmp, "%s", target->GetPrefixTitle());
  532. target->SetPrefixTitle(value);
  533. if(target->GetZone())
  534. target->GetZone()->SendUpdateTitles(target);
  535. break;
  536. }
  537. case SPAWN_SET_VALUE_SUFFIX: {
  538. sprintf(tmp, "%s", target->GetSuffixTitle());
  539. target->SetSuffixTitle(value);
  540. if(target->GetZone())
  541. target->GetZone()->SendUpdateTitles(target);
  542. break;
  543. }
  544. case SPAWN_SET_VALUE_LASTNAME: {
  545. sprintf(tmp, "%s", target->GetLastName());
  546. target->SetLastName(value);
  547. if(target->GetZone())
  548. target->GetZone()->SendUpdateTitles(target);
  549. break;
  550. }
  551. case SPAWN_SET_VALUE_EXPANSION_FLAG:
  552. case SPAWN_SET_VALUE_HOLIDAY_FLAG: {
  553. // nothing to do must reload spawns
  554. break;
  555. }
  556. case SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL: {
  557. sprintf(tmp, "%i", target->GetMerchantMinLevel());
  558. target->SetMerchantLevelRange(atoul(value), target->GetMerchantMaxLevel());
  559. break;
  560. }
  561. case SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL: {
  562. sprintf(tmp, "%i", target->GetMerchantMaxLevel());
  563. target->SetMerchantLevelRange(target->GetMerchantMinLevel(), atoul(value));
  564. break;
  565. }
  566. case SPAWN_SET_VALUE_FACTION:{
  567. sprintf(tmp, "%i", target->faction_id);
  568. ZoneServer* zone = target->GetZone();
  569. if (!zone && client)
  570. zone = client->GetCurrentZone();
  571. target->faction_id = atoul(value);
  572. if(zone)
  573. {
  574. zone->RemoveDeadEnemyList(target);
  575. if(target->IsNPC())
  576. zone->AddEnemyList((NPC*)target);
  577. }
  578. break;
  579. }
  580. case SPAWN_SET_SKIN_COLOR:
  581. case SPAWN_SET_HAIR_COLOR1:
  582. case SPAWN_SET_HAIR_COLOR2:
  583. case SPAWN_SET_HAIR_TYPE_COLOR:
  584. case SPAWN_SET_HAIR_FACE_COLOR:
  585. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  586. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  587. case SPAWN_SET_HAIR_HIGHLIGHT:
  588. case SPAWN_SET_MODEL_COLOR:
  589. case SPAWN_SET_EYE_COLOR:
  590. case SPAWN_SET_SOGA_SKIN_COLOR:
  591. case SPAWN_SET_SOGA_HAIR_COLOR1:
  592. case SPAWN_SET_SOGA_HAIR_COLOR2:
  593. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  594. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  595. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  596. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  597. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  598. case SPAWN_SET_SOGA_MODEL_COLOR:
  599. case SPAWN_SET_SOGA_EYE_COLOR:
  600. {
  601. if (target->IsEntity())
  602. {
  603. Seperator* skinsep = new Seperator(value, ' ', 3, 500, true);
  604. if (skinsep->IsNumber(0) && skinsep->IsNumber(1) && skinsep->IsNumber(2))
  605. {
  606. EQ2_Color clr;
  607. clr.red = atoul(skinsep->arg[0]);
  608. clr.green = atoul(skinsep->arg[1]);
  609. clr.blue = atoul(skinsep->arg[2]);
  610. switch(type)
  611. {
  612. case SPAWN_SET_SKIN_COLOR:
  613. ((Entity*)target)->SetSkinColor(clr);
  614. break;
  615. case SPAWN_SET_HAIR_COLOR1:
  616. ((Entity*)target)->SetHairColor1(clr);
  617. break;
  618. case SPAWN_SET_HAIR_COLOR2:
  619. ((Entity*)target)->SetHairColor2(clr);
  620. break;
  621. case SPAWN_SET_HAIR_TYPE_COLOR:
  622. ((Entity*)target)->SetHairColor(clr);
  623. break;
  624. case SPAWN_SET_HAIR_FACE_COLOR:
  625. ((Entity*)target)->SetFacialHairColor(clr);
  626. break;
  627. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  628. ((Entity*)target)->SetHairTypeHighlightColor(clr);
  629. break;
  630. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  631. ((Entity*)target)->SetFacialHairHighlightColor(clr);
  632. break;
  633. case SPAWN_SET_HAIR_HIGHLIGHT:
  634. ((Entity*)target)->SetHairHighlightColor(clr);
  635. break;
  636. case SPAWN_SET_MODEL_COLOR:
  637. ((Entity*)target)->SetModelColor(clr);
  638. break;
  639. case SPAWN_SET_EYE_COLOR:
  640. ((Entity*)target)->SetEyeColor(clr);
  641. break;
  642. case SPAWN_SET_SOGA_SKIN_COLOR:
  643. ((Entity*)target)->SetSogaSkinColor(clr);
  644. break;
  645. case SPAWN_SET_SOGA_HAIR_COLOR1:
  646. ((Entity*)target)->SetSogaHairColor1(clr);
  647. break;
  648. case SPAWN_SET_SOGA_HAIR_COLOR2:
  649. ((Entity*)target)->SetSogaHairColor2(clr);
  650. break;
  651. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  652. ((Entity*)target)->SetSogaHairColor(clr);
  653. break;
  654. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  655. ((Entity*)target)->SetSogaFacialHairColor(clr);
  656. break;
  657. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  658. ((Entity*)target)->SetSogaHairTypeHighlightColor(clr);
  659. break;
  660. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  661. ((Entity*)target)->SetSogaFacialHairHighlightColor(clr);
  662. break;
  663. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  664. ((Entity*)target)->SetSogaHairHighlightColor(clr);
  665. break;
  666. case SPAWN_SET_SOGA_MODEL_COLOR:
  667. ((Entity*)target)->SetSogaModelColor(clr);
  668. break;
  669. case SPAWN_SET_SOGA_EYE_COLOR:
  670. ((Entity*)target)->SetSogaEyeColor(clr);
  671. break;
  672. }
  673. }
  674. safe_delete(skinsep);
  675. }
  676. break;
  677. }
  678. case SPAWN_SET_AAXP_REWARDS: {
  679. target->SetAAXPRewards(atoul(value));
  680. break;
  681. }
  682. case SPAWN_SET_CHEEK_TYPE:{
  683. if(target->IsEntity() && index < 3){
  684. sprintf(tmp, "%i", ((Entity*)target)->features.cheek_type[index]);
  685. sint8 new_value = atoi(value);
  686. ((Entity*)target)->features.cheek_type[index] = new_value;
  687. ((Entity*)target)->info_changed = true;
  688. }
  689. break;
  690. }
  691. case SPAWN_SET_CHIN_TYPE:{
  692. if(target->IsEntity() && index < 3){
  693. sprintf(tmp, "%i", ((Entity*)target)->features.chin_type[index]);
  694. sint8 new_value = atoi(value);
  695. ((Entity*)target)->features.chin_type[index] = new_value;
  696. ((Entity*)target)->info_changed = true;
  697. }
  698. break;
  699. }
  700. case SPAWN_SET_EAR_TYPE:{
  701. if(target->IsEntity() && index < 3){
  702. sprintf(tmp, "%i", ((Entity*)target)->features.ear_type[index]);
  703. sint8 new_value = atoi(value);
  704. ((Entity*)target)->features.ear_type[index] = new_value;
  705. ((Entity*)target)->info_changed = true;
  706. }
  707. break;
  708. }
  709. case SPAWN_SET_EYE_BROW_TYPE:{
  710. if(target->IsEntity() && index < 3){
  711. sprintf(tmp, "%i", ((Entity*)target)->features.eye_brow_type[index]);
  712. sint8 new_value = atoi(value);
  713. ((Entity*)target)->features.eye_brow_type[index] = new_value;
  714. ((Entity*)target)->info_changed = true;
  715. }
  716. break;
  717. }
  718. case SPAWN_SET_EYE_TYPE:{
  719. if(target->IsEntity() && index < 3){
  720. sprintf(tmp, "%i", ((Entity*)target)->features.eye_type[index]);
  721. sint8 new_value = atoi(value);
  722. ((Entity*)target)->features.eye_type[index] = new_value;
  723. ((Entity*)target)->info_changed = true;
  724. }
  725. break;
  726. }
  727. case SPAWN_SET_LIP_TYPE:{
  728. if(target->IsEntity() && index < 3){
  729. sprintf(tmp, "%i", ((Entity*)target)->features.lip_type[index]);
  730. sint8 new_value = atoi(value);
  731. ((Entity*)target)->features.lip_type[index] = new_value;
  732. ((Entity*)target)->info_changed = true;
  733. }
  734. break;
  735. }
  736. case SPAWN_SET_NOSE_TYPE:{
  737. if(target->IsEntity() && index < 3){
  738. sprintf(tmp, "%i", ((Entity*)target)->features.nose_type[index]);
  739. sint8 new_value = atoi(value);
  740. ((Entity*)target)->features.nose_type[index] = new_value;
  741. ((Entity*)target)->info_changed = true;
  742. }
  743. break;
  744. }
  745. case SPAWN_SET_BODY_SIZE:{
  746. if(target->IsEntity()){
  747. sprintf(tmp, "%i", ((Entity*)target)->features.body_size);
  748. int8 new_value = atoul(value);
  749. ((Entity*)target)->features.body_size = new_value;
  750. ((Entity*)target)->info_changed = true;
  751. }
  752. break;
  753. }
  754. case SPAWN_SET_BODY_AGE:{
  755. if(target->IsEntity()){
  756. sprintf(tmp, "%i", ((Entity*)target)->features.body_age);
  757. int8 new_value = atoul(value);
  758. ((Entity*)target)->features.body_age = new_value;
  759. ((Entity*)target)->info_changed = true;
  760. }
  761. break;
  762. }
  763. case SPAWN_SET_SOGA_CHEEK_TYPE:{
  764. if(target->IsEntity() && index < 3){
  765. sprintf(tmp, "%i", ((Entity*)target)->features.soga_cheek_type[index]);
  766. sint8 new_value = atoi(value);
  767. ((Entity*)target)->features.soga_cheek_type[index] = new_value;
  768. ((Entity*)target)->info_changed = true;
  769. }
  770. break;
  771. }
  772. case SPAWN_SET_SOGA_CHIN_TYPE:{
  773. if(target->IsEntity() && index < 3){
  774. sprintf(tmp, "%i", ((Entity*)target)->features.soga_chin_type[index]);
  775. sint8 new_value = atoi(value);
  776. ((Entity*)target)->features.soga_chin_type[index] = new_value;
  777. ((Entity*)target)->info_changed = true;
  778. }
  779. break;
  780. }
  781. case SPAWN_SET_SOGA_EAR_TYPE:{
  782. if(target->IsEntity() && index < 3){
  783. sprintf(tmp, "%i", ((Entity*)target)->features.soga_ear_type[index]);
  784. sint8 new_value = atoi(value);
  785. ((Entity*)target)->features.soga_ear_type[index] = new_value;
  786. ((Entity*)target)->info_changed = true;
  787. }
  788. break;
  789. }
  790. case SPAWN_SET_SOGA_EYE_BROW_TYPE:{
  791. if(target->IsEntity() && index < 3){
  792. sprintf(tmp, "%i", ((Entity*)target)->features.soga_eye_brow_type[index]);
  793. sint8 new_value = atoi(value);
  794. ((Entity*)target)->features.soga_eye_brow_type[index] = new_value;
  795. ((Entity*)target)->info_changed = true;
  796. }
  797. break;
  798. }
  799. case SPAWN_SET_SOGA_EYE_TYPE:{
  800. if(target->IsEntity() && index < 3){
  801. sprintf(tmp, "%i", ((Entity*)target)->features.soga_eye_type[index]);
  802. sint8 new_value = atoi(value);
  803. ((Entity*)target)->features.soga_eye_type[index] = new_value;
  804. ((Entity*)target)->info_changed = true;
  805. }
  806. break;
  807. }
  808. case SPAWN_SET_SOGA_LIP_TYPE:{
  809. if(target->IsEntity() && index < 3){
  810. sprintf(tmp, "%i", ((Entity*)target)->features.soga_lip_type[index]);
  811. sint8 new_value = atoi(value);
  812. ((Entity*)target)->features.soga_lip_type[index] = new_value;
  813. ((Entity*)target)->info_changed = true;
  814. }
  815. break;
  816. }
  817. case SPAWN_SET_SOGA_BODY_SIZE:{
  818. if(target->IsEntity()){
  819. sprintf(tmp, "%i", ((Entity*)target)->features.soga_body_size);
  820. int8 new_value = atoul(value);
  821. ((Entity*)target)->features.soga_body_size = new_value;
  822. ((Entity*)target)->info_changed = true;
  823. }
  824. break;
  825. }
  826. case SPAWN_SET_SOGA_BODY_AGE:{
  827. if(target->IsEntity()){
  828. sprintf(tmp, "%i", ((Entity*)target)->features.soga_body_age);
  829. int8 new_value = atoul(value);
  830. ((Entity*)target)->features.soga_body_age = new_value;
  831. ((Entity*)target)->info_changed = true;
  832. }
  833. break;
  834. }
  835. case SPAWN_SET_ATTACK_TYPE:{
  836. if(target->IsEntity()){
  837. sprintf(tmp, "%u", ((Entity*)target)->GetInfoStruct()->get_attack_type());
  838. int8 new_value = atoul(value);
  839. ((Entity*)target)->GetInfoStruct()->set_attack_type(new_value);
  840. }
  841. break;
  842. }
  843. case SPAWN_SET_RACE_TYPE:{
  844. if(target->GetModelType() > 0){
  845. Seperator* tmpsep = new Seperator(value, ' ', 3, 500, true);
  846. if (tmpsep->IsNumber(0))
  847. {
  848. int16 race_type = atoul(value);
  849. const char* category = tmpsep->IsSet(1) ? tmpsep->arg[1] : "NULL";
  850. const char* subcategory = tmpsep->IsSet(2) ? tmpsep->arg[2] : "NULL";
  851. const char* model_name = tmpsep->IsSet(3) ? tmpsep->arg[3] : "NULL";
  852. if(race_types_list.AddRaceType(target->GetModelType(), race_type, category, subcategory, model_name)) {
  853. if(client) {
  854. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Race type added to memory, however not saved to database.");
  855. }
  856. }
  857. else if(client) {
  858. client->SimpleMessage(CHANNEL_COLOR_RED, "Model type already on the race_types_list, use spawn set database to override and update database.");
  859. }
  860. }
  861. safe_delete(tmpsep);
  862. }
  863. break;
  864. }
  865. case SPAWN_SET_LOOT_TIER:{
  866. if(target->IsEntity()){
  867. sprintf(tmp, "%u", target->GetLootTier());
  868. int32 new_value = atoul(value);
  869. target->SetLootTier(new_value);
  870. }
  871. break;
  872. }
  873. case SPAWN_SET_LOOT_DROP_TYPE:{
  874. if(target->IsEntity()){
  875. sprintf(tmp, "%u", target->GetLootDropType());
  876. int32 new_value = atoul(value);
  877. target->SetLootDropType(new_value);
  878. }
  879. break;
  880. }
  881. case SPAWN_SET_SCARED_STRONG_PLAYERS:{
  882. if(target->IsNPC()){
  883. sprintf(tmp, "%u", target->IsScaredByStrongPlayers());
  884. int32 new_value = atoul(value);
  885. target->SetScaredByStrongPlayers(new_value);
  886. }
  887. break;
  888. }
  889. if(temp_value)
  890. *temp_value = string(tmp);
  891. }
  892. }
  893. else{
  894. /**** NOT TEMPORARY ELSE STATEMENT ****/
  895. /**** MUST RE-DEFINE WHAT IS ALREADY IN THE IF TEMPORARY BLOCK HERE ****/
  896. switch(type){
  897. case SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL: {
  898. target->SetMerchantLevelRange(atoul(value), target->GetMerchantMaxLevel());
  899. break;
  900. }
  901. case SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL: {
  902. target->SetMerchantLevelRange(target->GetMerchantMinLevel(), atoul(value));
  903. break;
  904. }
  905. case SPAWN_SET_VALUE_EXPANSION_FLAG: {
  906. if (target->GetDatabaseID() > 0)
  907. {
  908. char query[256];
  909. snprintf(query, 256, "update spawn set expansion_flag=%u where id=%u", atoul(value), target->GetDatabaseID());
  910. if (database.RunQuery(query, strnlen(query, 256)))
  911. {
  912. if(client)
  913. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  914. }
  915. }
  916. break;
  917. }
  918. case SPAWN_SET_VALUE_HOLIDAY_FLAG: {
  919. if (target->GetDatabaseID() > 0)
  920. {
  921. char query[256];
  922. snprintf(query, 256, "update spawn set holiday_flag=%u where id=%u", atoul(value), target->GetDatabaseID());
  923. if (database.RunQuery(query, strnlen(query, 256)))
  924. {
  925. if(client)
  926. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  927. }
  928. }
  929. break;
  930. }
  931. case SPAWN_SET_AAXP_REWARDS: {
  932. if (target->GetDatabaseID() > 0)
  933. {
  934. char query[256];
  935. snprintf(query, 256, "update spawn set aaxp_rewards=%u where id=%u", atoul(value), target->GetDatabaseID());
  936. if (database.RunQuery(query, strnlen(query, 256)))
  937. {
  938. if(client)
  939. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  940. }
  941. }
  942. break;
  943. }
  944. case SPAWN_SET_VALUE_NAME:{
  945. target->SetName(value);
  946. if(target->GetZone())
  947. target->GetZone()->SendUpdateTitles(target);
  948. break;
  949. }
  950. case SPAWN_SET_VALUE_SUB_TITLE: {
  951. target->SetSubTitle(value);
  952. if(target->GetZone())
  953. target->GetZone()->SendUpdateTitles(target);
  954. break;
  955. }
  956. case SPAWN_SET_VALUE_X_OFFSET:
  957. {
  958. target->SetXOffset(atof(value));
  959. break;
  960. }
  961. case SPAWN_SET_VALUE_Y_OFFSET:
  962. {
  963. target->SetYOffset(atof(value));
  964. break;
  965. }
  966. case SPAWN_SET_VALUE_Z_OFFSET:
  967. {
  968. target->SetZOffset(atof(value));
  969. break;
  970. }
  971. case SPAWN_SET_VALUE_EXPIRE: {
  972. target->SetExpireTime(val);
  973. break;
  974. }
  975. case SPAWN_SET_VALUE_EXPIRE_OFFSET: {
  976. target->SetExpireOffsetTime(val);
  977. break;
  978. }
  979. case SPAWN_SET_VALUE_LEVEL:{
  980. target->SetLevel(val, send_update);
  981. break;
  982. }
  983. case SPAWN_SET_VALUE_DIFFICULTY:{
  984. target->SetDifficulty(val, send_update);
  985. break;
  986. }
  987. case SPAWN_SET_VALUE_MODEL_TYPE:{
  988. target->SetModelType(val, send_update);
  989. break;
  990. }
  991. case SPAWN_SET_VALUE_CLASS:{
  992. target->SetAdventureClass(val, send_update);
  993. break;
  994. }
  995. case SPAWN_SET_VALUE_GENDER:{
  996. target->SetGender(val, send_update);
  997. break;
  998. }
  999. case SPAWN_SET_VALUE_SHOW_NAME:{
  1000. target->SetShowName(val, send_update);
  1001. break;
  1002. }
  1003. case SPAWN_SET_VALUE_ATTACKABLE:{
  1004. target->SetAttackable(val, send_update);
  1005. break;
  1006. }
  1007. case SPAWN_SET_VALUE_SHOW_LEVEL:{
  1008. target->SetShowLevel(val, send_update);
  1009. break;
  1010. }
  1011. case SPAWN_SET_VALUE_TARGETABLE:{
  1012. target->SetTargetable(val, send_update);
  1013. break;
  1014. }
  1015. case SPAWN_SET_VALUE_SHOW_COMMAND_ICON:{
  1016. target->SetShowCommandIcon(val, send_update);
  1017. break;
  1018. }
  1019. case SPAWN_SET_VALUE_HAND_ICON:{
  1020. target->SetShowHandIcon(val, send_update);
  1021. break;
  1022. }
  1023. case SPAWN_SET_VALUE_HAIR_TYPE:{
  1024. if(target->IsEntity())
  1025. ((Entity*)target)->SetHairType(val, send_update);
  1026. break;
  1027. }
  1028. case SPAWN_SET_VALUE_FACIAL_HAIR_TYPE:{
  1029. if(target->IsEntity())
  1030. ((Entity*)target)->SetFacialHairType(val, send_update);
  1031. break;
  1032. }
  1033. case SPAWN_SET_VALUE_WING_TYPE:{
  1034. if(target->IsEntity())
  1035. ((Entity*)target)->SetWingType(val, send_update);
  1036. break;
  1037. }
  1038. case SPAWN_SET_VALUE_CHEST_TYPE:{
  1039. if(target->IsEntity())
  1040. ((Entity*)target)->SetChestType(val, send_update);
  1041. break;
  1042. }
  1043. case SPAWN_SET_VALUE_LEGS_TYPE:{
  1044. if(target->IsEntity())
  1045. ((Entity*)target)->SetLegsType(val, send_update);
  1046. break;
  1047. }
  1048. case SPAWN_SET_VALUE_SOGA_HAIR_TYPE:{
  1049. if(target->IsEntity())
  1050. ((Entity*)target)->SetSogaHairType(val, send_update);
  1051. break;
  1052. }
  1053. case SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE:{
  1054. if(target->IsEntity())
  1055. ((Entity*)target)->SetSogaFacialHairType(val, send_update);
  1056. break;
  1057. }
  1058. case SPAWN_SET_VALUE_SOGA_MODEL_TYPE:{
  1059. target->SetSogaModelType(val, send_update);
  1060. break;
  1061. }
  1062. case SPAWN_SET_VALUE_SIZE:{
  1063. target->SetSize(val, send_update);
  1064. break;
  1065. }
  1066. case SPAWN_SET_VALUE_HP:{
  1067. target->SetTotalHPBase(val);
  1068. target->SetHP(val, send_update);
  1069. break;
  1070. }
  1071. case SPAWN_SET_VALUE_POWER:{
  1072. target->SetTotalPowerBase(val);
  1073. target->SetPower(val, send_update);
  1074. break;
  1075. }
  1076. case SPAWN_SET_VALUE_HEROIC:{
  1077. target->SetHeroic(val, send_update);
  1078. break;
  1079. }
  1080. case SPAWN_SET_VALUE_RESPAWN:{
  1081. target->SetRespawnTime(val);
  1082. break;
  1083. }
  1084. case SPAWN_SET_VALUE_X:{
  1085. target->SetX(atof(value), send_update);
  1086. target->SetSpawnOrigX(target->GetX());
  1087. break;
  1088. }
  1089. case SPAWN_SET_VALUE_Y:{
  1090. target->SetY(atof(value), send_update);
  1091. target->SetSpawnOrigY(target->GetY());
  1092. break;
  1093. }
  1094. case SPAWN_SET_VALUE_Z:{
  1095. target->SetZ(atof(value), send_update);
  1096. target->SetSpawnOrigZ(target->GetZ());
  1097. break;
  1098. }
  1099. case SPAWN_SET_VALUE_HEADING:{
  1100. target->SetHeading(atof(value), send_update);
  1101. target->SetSpawnOrigHeading(target->GetHeading());
  1102. break;
  1103. }
  1104. case SPAWN_SET_VALUE_COMMAND_PRIMARY:{
  1105. ZoneServer* zone = target->GetZone();
  1106. if (!zone && client)
  1107. zone = client->GetCurrentZone();
  1108. if(zone && zone->GetEntityCommandList(val))
  1109. target->SetPrimaryCommands(zone->GetEntityCommandList(val));
  1110. target->primary_command_list_id = val;
  1111. break;
  1112. }
  1113. case SPAWN_SET_VALUE_COMMAND_SECONDARY:{
  1114. ZoneServer* zone = target->GetZone();
  1115. if (!zone && client)
  1116. zone = client->GetCurrentZone();
  1117. if (zone && zone->GetEntityCommandList(val))
  1118. target->SetSecondaryCommands(zone->GetEntityCommandList(val));
  1119. target->secondary_command_list_id = val;
  1120. break;
  1121. }
  1122. case SPAWN_SET_VALUE_VISUAL_STATE:{
  1123. target->SetVisualState(val, send_update);
  1124. break;
  1125. }
  1126. case SPAWN_SET_VALUE_ACTION_STATE:{
  1127. target->SetActionState(val, send_update);
  1128. break;
  1129. }
  1130. case SPAWN_SET_VALUE_MOOD_STATE:{
  1131. target->SetMoodState(val, send_update);
  1132. break;
  1133. }
  1134. case SPAWN_SET_VALUE_INITIAL_STATE:{
  1135. target->SetInitialState(val, send_update);
  1136. break;
  1137. }
  1138. case SPAWN_SET_VALUE_ACTIVITY_STATE:{
  1139. target->SetActivityStatus(val, send_update);
  1140. break;
  1141. }
  1142. case SPAWN_SET_VALUE_COLLISION_RADIUS:{
  1143. target->SetCollisionRadius(val, send_update);
  1144. break;
  1145. }
  1146. case SPAWN_SET_VALUE_FACTION:{
  1147. ZoneServer* zone = target->GetZone();
  1148. if (!zone && client)
  1149. zone = client->GetCurrentZone();
  1150. target->faction_id = val;
  1151. if(zone)
  1152. {
  1153. zone->RemoveDeadEnemyList(target);
  1154. if(target->IsNPC())
  1155. zone->AddEnemyList((NPC*)target);
  1156. }
  1157. break;
  1158. }
  1159. case SPAWN_SET_VALUE_DEVICE_ID:{
  1160. if (target->IsObject())
  1161. ((Object*)target)->SetDeviceID(val);
  1162. break;
  1163. }
  1164. case SPAWN_SET_VALUE_PITCH: {
  1165. target->SetPitch(atof(value), send_update);
  1166. target->SetSpawnOrigPitch(atof(value));
  1167. break;
  1168. }
  1169. case SPAWN_SET_VALUE_ROLL: {
  1170. target->SetRoll(atof(value), send_update);
  1171. target->SetSpawnOrigRoll(atof(value));
  1172. break;
  1173. }
  1174. case SPAWN_SET_VALUE_HIDE_HOOD: {
  1175. target->SetHideHood(val);
  1176. break;
  1177. }
  1178. case SPAWN_SET_VALUE_EMOTE_STATE: {
  1179. target->SetEmoteState(val);
  1180. break;
  1181. }
  1182. case SPAWN_SET_VALUE_ICON: {
  1183. target->SetIcon(val);
  1184. break;
  1185. }
  1186. case SPAWN_SET_VALUE_PREFIX: {
  1187. target->SetPrefixTitle(value);
  1188. if(target->GetZone())
  1189. target->GetZone()->SendUpdateTitles(target);
  1190. break;
  1191. }
  1192. case SPAWN_SET_VALUE_SUFFIX: {
  1193. target->SetSuffixTitle(value);
  1194. if(target->GetZone())
  1195. target->GetZone()->SendUpdateTitles(target);
  1196. break;
  1197. }
  1198. case SPAWN_SET_VALUE_LASTNAME: {
  1199. target->SetLastName(value);
  1200. if(target->GetZone())
  1201. target->GetZone()->SendUpdateTitles(target);
  1202. break;
  1203. }
  1204. case SPAWN_SET_VALUE_SPAWN_SCRIPT:{
  1205. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  1206. if(client){
  1207. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  1208. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawn_script 'SpawnScripts/example.lua'");
  1209. }
  1210. return false;
  1211. }
  1212. else if(!database.UpdateSpawnScriptData(target->GetDatabaseID(), 0, 0, value))
  1213. return false;
  1214. else{
  1215. if(!world.GetSpawnLocationScript(target->GetSpawnLocationID()))
  1216. target->SetSpawnScript(value);
  1217. }
  1218. break;
  1219. }
  1220. case SPAWN_SET_VALUE_SPAWNLOCATION_SCRIPT:{
  1221. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  1222. if(client){
  1223. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  1224. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawnlocation_script 'SpawnScripts/example.lua'");
  1225. }
  1226. return false;
  1227. }
  1228. else if(!database.UpdateSpawnScriptData(0, target->GetSpawnLocationID(), 0, value))
  1229. return false;
  1230. else{
  1231. if(!world.GetSpawnEntryScript(target->GetSpawnEntryID()))
  1232. target->SetSpawnScript(value);
  1233. }
  1234. break;
  1235. }
  1236. case SPAWN_SET_VALUE_SPAWNENTRY_SCRIPT:{
  1237. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  1238. if(client){
  1239. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  1240. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawnentry_script 'SpawnScripts/example.lua'");
  1241. }
  1242. return false;
  1243. }
  1244. else if(!database.UpdateSpawnScriptData(0, 0, target->GetSpawnEntryID(), value))
  1245. return false;
  1246. else
  1247. target->SetSpawnScript(value);
  1248. break;
  1249. }
  1250. case SPAWN_SET_SKIN_COLOR:
  1251. case SPAWN_SET_HAIR_COLOR1:
  1252. case SPAWN_SET_HAIR_COLOR2:
  1253. case SPAWN_SET_HAIR_TYPE_COLOR:
  1254. case SPAWN_SET_HAIR_FACE_COLOR:
  1255. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  1256. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  1257. case SPAWN_SET_HAIR_HIGHLIGHT:
  1258. case SPAWN_SET_MODEL_COLOR:
  1259. case SPAWN_SET_EYE_COLOR:
  1260. case SPAWN_SET_SOGA_SKIN_COLOR:
  1261. case SPAWN_SET_SOGA_HAIR_COLOR1:
  1262. case SPAWN_SET_SOGA_HAIR_COLOR2:
  1263. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  1264. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  1265. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  1266. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  1267. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  1268. case SPAWN_SET_SOGA_MODEL_COLOR:
  1269. case SPAWN_SET_SOGA_EYE_COLOR: {
  1270. if (target->IsNPC())
  1271. {
  1272. Seperator* skinsep = new Seperator(value, ' ', 3, 500, true);
  1273. if (skinsep->IsNumber(0) && skinsep->IsNumber(1) && skinsep->IsNumber(2))
  1274. {
  1275. EQ2_Color clr;
  1276. clr.red = atoul(skinsep->arg[0]);
  1277. clr.green = atoul(skinsep->arg[1]);
  1278. clr.blue = atoul(skinsep->arg[2]);
  1279. Query replaceSkinQuery;
  1280. string fieldName("");
  1281. switch(type)
  1282. {
  1283. case SPAWN_SET_SKIN_COLOR:
  1284. ((Entity*)target)->SetSkinColor(clr);
  1285. fieldName.append("skin_color");
  1286. break;
  1287. case SPAWN_SET_HAIR_COLOR1:
  1288. ((Entity*)target)->SetHairColor1(clr);
  1289. fieldName.append("hair_color1");
  1290. break;
  1291. case SPAWN_SET_HAIR_COLOR2:
  1292. ((Entity*)target)->SetHairColor2(clr);
  1293. fieldName.append("hair_color2");
  1294. break;
  1295. case SPAWN_SET_HAIR_TYPE_COLOR:
  1296. ((Entity*)target)->SetHairColor(clr);
  1297. fieldName.append("hair_type_color");
  1298. break;
  1299. case SPAWN_SET_HAIR_FACE_COLOR:
  1300. ((Entity*)target)->SetFacialHairColor(clr);
  1301. fieldName.append("hair_face_color");
  1302. break;
  1303. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  1304. ((Entity*)target)->SetHairTypeHighlightColor(clr);
  1305. fieldName.append("hair_type_highlight_color");
  1306. break;
  1307. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  1308. ((Entity*)target)->SetFacialHairHighlightColor(clr);
  1309. fieldName.append("hair_face_highlight_color");
  1310. break;
  1311. case SPAWN_SET_HAIR_HIGHLIGHT:
  1312. ((Entity*)target)->SetHairHighlightColor(clr);
  1313. fieldName.append("hair_highlight");
  1314. break;
  1315. case SPAWN_SET_MODEL_COLOR:
  1316. ((Entity*)target)->SetModelColor(clr);
  1317. fieldName.append("model_color");
  1318. break;
  1319. case SPAWN_SET_EYE_COLOR:
  1320. ((Entity*)target)->SetEyeColor(clr);
  1321. fieldName.append("eye_color");
  1322. break;
  1323. case SPAWN_SET_SOGA_SKIN_COLOR:
  1324. ((Entity*)target)->SetSogaSkinColor(clr);
  1325. fieldName.append("soga_skin_color");
  1326. break;
  1327. case SPAWN_SET_SOGA_HAIR_COLOR1:
  1328. ((Entity*)target)->SetSogaHairColor1(clr);
  1329. fieldName.append("soga_hair_color1");
  1330. break;
  1331. case SPAWN_SET_SOGA_HAIR_COLOR2:
  1332. ((Entity*)target)->SetSogaHairColor2(clr);
  1333. fieldName.append("soga_hair_color2");
  1334. break;
  1335. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  1336. ((Entity*)target)->SetSogaHairColor(clr);
  1337. fieldName.append("soga_hair_type_color");
  1338. break;
  1339. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  1340. ((Entity*)target)->SetSogaFacialHairColor(clr);
  1341. fieldName.append("soga_hair_face_color");
  1342. break;
  1343. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  1344. ((Entity*)target)->SetSogaHairTypeHighlightColor(clr);
  1345. fieldName.append("soga_hair_type_highlight_color");
  1346. break;
  1347. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  1348. ((Entity*)target)->SetSogaFacialHairHighlightColor(clr);
  1349. fieldName.append("soga_hair_face_highlight_color");
  1350. break;
  1351. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  1352. ((Entity*)target)->SetSogaHairHighlightColor(clr);
  1353. fieldName.append("soga_hair_highlight");
  1354. break;
  1355. case SPAWN_SET_SOGA_MODEL_COLOR:
  1356. ((Entity*)target)->SetSogaModelColor(clr);
  1357. fieldName.append("soga_model_color");
  1358. break;
  1359. case SPAWN_SET_SOGA_EYE_COLOR:
  1360. ((Entity*)target)->SetSogaEyeColor(clr);
  1361. fieldName.append("soga_eye_color");
  1362. break;
  1363. }
  1364. replaceSkinQuery.AddQueryAsync(0, &database, Q_DELETE, "delete from npc_appearance where spawn_id=%u and type='%s'", target->GetDatabaseID(), fieldName.c_str());
  1365. 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);
  1366. }
  1367. safe_delete(skinsep);
  1368. }
  1369. break;
  1370. }
  1371. case SPAWN_SET_CHEEK_TYPE:{
  1372. if(target->IsEntity() && index < 3){
  1373. sint8 new_value = atoi(value);
  1374. ((Entity*)target)->features.cheek_type[index] = new_value;
  1375. UpdateDatabaseAppearance(client, target, "cheek_type", ((Entity*)target)->features.cheek_type[0], ((Entity*)target)->features.cheek_type[1], ((Entity*)target)->features.cheek_type[2]);
  1376. }
  1377. break;
  1378. }
  1379. case SPAWN_SET_CHIN_TYPE:{
  1380. if(target->IsEntity() && index < 3){
  1381. sint8 new_value = atoi(value);
  1382. ((Entity*)target)->features.chin_type[index] = new_value;
  1383. UpdateDatabaseAppearance(client, target, "chin_type", ((Entity*)target)->features.chin_type[0], ((Entity*)target)->features.chin_type[1], ((Entity*)target)->features.chin_type[2]);
  1384. }
  1385. break;
  1386. }
  1387. case SPAWN_SET_EAR_TYPE:{
  1388. if(target->IsEntity() && index < 3){
  1389. sint8 new_value = atoi(value);
  1390. ((Entity*)target)->features.ear_type[index] = new_value;
  1391. UpdateDatabaseAppearance(client, target, "ear_type", ((Entity*)target)->features.ear_type[0], ((Entity*)target)->features.ear_type[1], ((Entity*)target)->features.ear_type[2]);
  1392. }
  1393. break;
  1394. }
  1395. case SPAWN_SET_EYE_BROW_TYPE:{
  1396. if(target->IsEntity() && index < 3){
  1397. sint8 new_value = atoi(value);
  1398. ((Entity*)target)->features.eye_brow_type[index] = new_value;
  1399. 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]);
  1400. }
  1401. break;
  1402. }
  1403. case SPAWN_SET_EYE_TYPE:{
  1404. if(target->IsEntity() && index < 3){
  1405. sint8 new_value = atoi(value);
  1406. ((Entity*)target)->features.eye_type[index] = new_value;
  1407. UpdateDatabaseAppearance(client, target, "eye_type", ((Entity*)target)->features.eye_type[0], ((Entity*)target)->features.eye_type[1], ((Entity*)target)->features.eye_type[2]);
  1408. }
  1409. break;
  1410. }
  1411. case SPAWN_SET_LIP_TYPE:{
  1412. if(target->IsEntity() && index < 3){
  1413. sint8 new_value = atoi(value);
  1414. ((Entity*)target)->features.lip_type[index] = new_value;
  1415. UpdateDatabaseAppearance(client, target, "lip_type", ((Entity*)target)->features.lip_type[0], ((Entity*)target)->features.lip_type[1], ((Entity*)target)->features.lip_type[2]);
  1416. }
  1417. break;
  1418. }
  1419. case SPAWN_SET_NOSE_TYPE:{
  1420. if(target->IsEntity() && index < 3){
  1421. sint8 new_value = atoi(value);
  1422. ((Entity*)target)->features.nose_type[index] = new_value;
  1423. UpdateDatabaseAppearance(client, target, "nose_type", ((Entity*)target)->features.nose_type[0], ((Entity*)target)->features.nose_type[1], ((Entity*)target)->features.nose_type[2]);
  1424. }
  1425. break;
  1426. }
  1427. case SPAWN_SET_BODY_SIZE:{
  1428. if(target->IsEntity()){
  1429. int8 new_value = atoul(value);
  1430. ((Entity*)target)->features.body_size = new_value;
  1431. UpdateDatabaseAppearance(client, target, "body_size", ((Entity*)target)->features.body_size, 0, 0);
  1432. }
  1433. break;
  1434. }
  1435. case SPAWN_SET_BODY_AGE:{
  1436. if(target->IsEntity()){
  1437. int8 new_value = atoul(value);
  1438. ((Entity*)target)->features.body_age = new_value;
  1439. UpdateDatabaseAppearance(client, target, "body_age", ((Entity*)target)->features.body_age, 0, 0);
  1440. }
  1441. break;
  1442. }
  1443. case SPAWN_SET_SOGA_CHEEK_TYPE:{
  1444. if(target->IsEntity() && index < 3){
  1445. sint8 new_value = atoi(value);
  1446. ((Entity*)target)->features.soga_cheek_type[index] = new_value;
  1447. 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]);
  1448. }
  1449. break;
  1450. }
  1451. case SPAWN_SET_SOGA_CHIN_TYPE:{
  1452. if(target->IsEntity() && index < 3){
  1453. sint8 new_value = atoi(value);
  1454. ((Entity*)target)->features.soga_chin_type[index] = new_value;
  1455. 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]);
  1456. }
  1457. break;
  1458. }
  1459. case SPAWN_SET_SOGA_EAR_TYPE:{
  1460. if(target->IsEntity() && index < 3){
  1461. sint8 new_value = atoi(value);
  1462. ((Entity*)target)->features.soga_ear_type[index] = new_value;
  1463. 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]);
  1464. }
  1465. break;
  1466. }
  1467. case SPAWN_SET_SOGA_EYE_BROW_TYPE:{
  1468. if(target->IsEntity() && index < 3){
  1469. sint8 new_value = atoi(value);
  1470. ((Entity*)target)->features.soga_eye_brow_type[index] = new_value;
  1471. 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]);
  1472. }
  1473. break;
  1474. }
  1475. case SPAWN_SET_SOGA_EYE_TYPE:{
  1476. if(target->IsEntity() && index < 3){
  1477. sint8 new_value = atoi(value);
  1478. ((Entity*)target)->features.soga_eye_type[index] = new_value;
  1479. 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]);
  1480. }
  1481. break;
  1482. }
  1483. case SPAWN_SET_SOGA_LIP_TYPE:{
  1484. if(target->IsEntity() && index < 3){
  1485. sint8 new_value = atoi(value);
  1486. ((Entity*)target)->features.soga_lip_type[index] = new_value;
  1487. 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]);
  1488. }
  1489. break;
  1490. }
  1491. case SPAWN_SET_SOGA_NOSE_TYPE:{
  1492. if(target->IsEntity() && index < 3){
  1493. sint8 new_value = atoi(value);
  1494. ((Entity*)target)->features.soga_nose_type[index] = new_value;
  1495. 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]);
  1496. }
  1497. break;
  1498. }
  1499. case SPAWN_SET_SOGA_BODY_SIZE:{
  1500. if(target->IsEntity()){
  1501. int8 new_value = atoul(value);
  1502. ((Entity*)target)->features.body_size = new_value;
  1503. UpdateDatabaseAppearance(client, target, "body_size", ((Entity*)target)->features.body_size, 0, 0);
  1504. }
  1505. break;
  1506. }
  1507. case SPAWN_SET_SOGA_BODY_AGE:{
  1508. if(target->IsEntity()){
  1509. int8 new_value = atoul(value);
  1510. ((Entity*)target)->features.body_age = new_value;
  1511. UpdateDatabaseAppearance(client, target, "body_age", ((Entity*)target)->features.body_age, 0, 0);
  1512. }
  1513. break;
  1514. }
  1515. case SPAWN_SET_ATTACK_TYPE:{
  1516. if(target->IsEntity()){
  1517. int8 new_value = atoul(value);
  1518. ((Entity*)target)->GetInfoStruct()->set_attack_type(new_value);
  1519. if(target->IsNPC()) {
  1520. if(target->GetDatabaseID()) {
  1521. Query spawnNPCQuery;
  1522. spawnNPCQuery.AddQueryAsync(0, &database, Q_INSERT, "update spawn_npcs set attack_type=%u where id=%u", new_value, target->GetDatabaseID());
  1523. } else if(client) {
  1524. client->Message(CHANNEL_COLOR_RED, "Invalid spawn to update the database (NPC only) or no database id for the NPC present.");
  1525. }
  1526. }
  1527. }
  1528. break;
  1529. }
  1530. case SPAWN_SET_RACE_TYPE:{
  1531. if(target->GetModelType() > 0){
  1532. Seperator* tmpsep = new Seperator(value, ' ', 3, 500, true);
  1533. if (tmpsep->IsNumber(0))
  1534. {
  1535. Query typequery;
  1536. int16 race_type = atoul(value);
  1537. const char* category = tmpsep->IsSet(1) ? tmpsep->arg[1] : "NULL";
  1538. const char* subcategory = tmpsep->IsSet(2) ? tmpsep->arg[2] : "NULL";
  1539. const char* model_name = tmpsep->IsSet(3) ? tmpsep->arg[3] : "NULL";
  1540. if(race_types_list.AddRaceType(target->GetModelType(), race_type, category, subcategory, model_name)) {
  1541. if(client)
  1542. 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);
  1543. 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);
  1544. }
  1545. else {
  1546. if(client)
  1547. 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);
  1548. race_types_list.AddRaceType(target->GetModelType(), race_type, category, subcategory, model_name, true);
  1549. 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());
  1550. }
  1551. }
  1552. safe_delete(tmpsep);
  1553. }
  1554. break;
  1555. }
  1556. case SPAWN_SET_LOOT_TIER:{
  1557. int32 new_value = atoul(value);
  1558. target->SetLootTier(new_value);
  1559. if (target->GetDatabaseID() > 0)
  1560. {
  1561. char query[256];
  1562. snprintf(query, 256, "update spawn set loot_tier=%u where id=%u", atoul(value), target->GetDatabaseID());
  1563. if (database.RunQuery(query, strnlen(query, 256)))
  1564. {
  1565. if(client)
  1566. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  1567. }
  1568. }
  1569. break;
  1570. }
  1571. case SPAWN_SET_LOOT_DROP_TYPE:{
  1572. int32 new_value = atoul(value);
  1573. target->SetLootDropType(new_value);
  1574. if (target->GetDatabaseID() > 0)
  1575. {
  1576. char query[256];
  1577. snprintf(query, 256, "update spawn set loot_drop_type=%u where id=%u", atoul(value), target->GetDatabaseID());
  1578. if (database.RunQuery(query, strnlen(query, 256)))
  1579. {
  1580. if(client)
  1581. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  1582. }
  1583. }
  1584. break;
  1585. }
  1586. case SPAWN_SET_SCARED_STRONG_PLAYERS:{
  1587. int32 new_value = atoul(value);
  1588. target->SetScaredByStrongPlayers(new_value);
  1589. if (target->GetDatabaseID() > 0)
  1590. {
  1591. char query[256];
  1592. snprintf(query, 256, "update spawn_npcs set scared_by_strong_players=%u where id=%u", atoul(value), target->GetDatabaseID());
  1593. if (database.RunQuery(query, strnlen(query, 256)))
  1594. {
  1595. if(client)
  1596. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  1597. }
  1598. }
  1599. break;
  1600. }
  1601. }
  1602. }
  1603. return true;
  1604. }
  1605. void Commands::UpdateDatabaseAppearance(Client* client, Spawn* target, string fieldName, sint8 r, sint8 g, sint8 b)
  1606. {
  1607. Query replaceQuery;
  1608. if(target->IsBot())
  1609. {
  1610. Bot* bot = (Bot*)target;
  1611. if(bot->BotID)
  1612. database.SaveBotFloats(bot->BotID, fieldName.c_str(), r, g, b);
  1613. }
  1614. else if(target->IsPlayer())
  1615. {
  1616. replaceQuery.AddQueryAsync(0, &database, Q_DELETE, "delete from char_colors where char_id=%u and type='%s'", ((Player*)target)->GetCharacterID(), fieldName.c_str());
  1617. 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);
  1618. }
  1619. else
  1620. {
  1621. replaceQuery.AddQueryAsync(0, &database, Q_DELETE, "delete from npc_appearance where spawn_id=%u and type='%s'", target->GetDatabaseID(), fieldName.c_str());
  1622. 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);
  1623. }
  1624. ((Entity*)target)->changed = true;
  1625. ((Entity*)target)->info_changed = true;
  1626. if(target->GetZone())
  1627. target->GetZone()->AddChangedSpawn(target);
  1628. }
  1629. /* The zone object will be NULL if the zone is not currently running. We pass both of these in so we can update
  1630. the database fields always and also update the zone in memory if it's running. */
  1631. bool Commands::SetZoneCommand(Client* client, int32 zone_id, ZoneServer* zone, int8 type, const char* value) {
  1632. if (client && zone_id > 0 && type > 0 && value) {
  1633. sint32 int_value = 0;
  1634. float float_value = 0;
  1635. if (type == ZONE_SET_VALUE_SAFE_X || type == ZONE_SET_VALUE_SAFE_Y || type == ZONE_SET_VALUE_SAFE_Z || type == ZONE_SET_VALUE_UNDERWORLD) {
  1636. try {
  1637. float_value = atof(value);
  1638. }
  1639. catch (...) {
  1640. client->Message(CHANNEL_COLOR_RED, "Error converting '%s' to a float value", value);
  1641. return false;
  1642. }
  1643. }
  1644. 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) {
  1645. try {
  1646. int_value = atoi(value);
  1647. }
  1648. catch (...) {
  1649. client->Message(CHANNEL_COLOR_RED, "Error converting '%s' to an integer value", value);
  1650. return false;
  1651. }
  1652. }
  1653. switch (type) {
  1654. case ZONE_SET_VALUE_EXPANSION_ID: {
  1655. break;
  1656. }
  1657. case ZONE_SET_VALUE_NAME: {
  1658. if (zone)
  1659. zone->SetZoneName(const_cast<char*>(value));
  1660. database.SaveZoneInfo(zone_id, "name", value);
  1661. break;
  1662. }
  1663. case ZONE_SET_VALUE_FILE: {
  1664. if (zone)
  1665. zone->SetZoneFile(const_cast<char*>(value));
  1666. database.SaveZoneInfo(zone_id, "file", value);
  1667. break;
  1668. }
  1669. case ZONE_SET_VALUE_DESCRIPTION: {
  1670. if (zone)
  1671. zone->SetZoneDescription(const_cast<char*>(value));
  1672. database.SaveZoneInfo(zone_id, "description", value);
  1673. break;
  1674. }
  1675. case ZONE_SET_VALUE_SAFE_X: {
  1676. if (zone)
  1677. zone->SetSafeX(float_value);
  1678. database.SaveZoneInfo(zone_id, "safe_x", float_value);
  1679. break;
  1680. }
  1681. case ZONE_SET_VALUE_SAFE_Y: {
  1682. if (zone)
  1683. zone->SetSafeY(float_value);
  1684. database.SaveZoneInfo(zone_id, "safe_y", float_value);
  1685. break;
  1686. }
  1687. case ZONE_SET_VALUE_SAFE_Z: {
  1688. if (zone)
  1689. zone->SetSafeZ(float_value);
  1690. database.SaveZoneInfo(zone_id, "safe_z", float_value);
  1691. break;
  1692. }
  1693. case ZONE_SET_VALUE_UNDERWORLD: {
  1694. if (zone)
  1695. zone->SetUnderWorld(float_value);
  1696. database.SaveZoneInfo(zone_id, "underworld", float_value);
  1697. break;
  1698. }
  1699. case ZONE_SET_VALUE_MIN_RECOMMENDED: {
  1700. break;
  1701. }
  1702. case ZONE_SET_VALUE_MAX_RECOMMENDED: {
  1703. break;
  1704. }
  1705. case ZONE_SET_VALUE_ZONE_TYPE: {
  1706. break;
  1707. }
  1708. case ZONE_SET_VALUE_ALWAYS_LOADED: {
  1709. if (zone)
  1710. zone->SetAlwaysLoaded(int_value == 1);
  1711. database.SaveZoneInfo(zone_id, "always_loaded", int_value);
  1712. break;
  1713. }
  1714. case ZONE_SET_VALUE_CITY_ZONE: {
  1715. if (zone)
  1716. zone->SetCityZone(int_value == 1);
  1717. database.SaveZoneInfo(zone_id, "city_zone", int_value);
  1718. break;
  1719. }
  1720. case ZONE_SET_VALUE_WEATHER_ALLOWED: {
  1721. if (zone)
  1722. zone->SetWeatherAllowed(int_value == 1);
  1723. database.SaveZoneInfo(zone_id, "weather_allowed", int_value);
  1724. break;
  1725. }
  1726. case ZONE_SET_VALUE_MIN_STATUS: {
  1727. if (zone)
  1728. zone->SetMinimumStatus(int_value);
  1729. database.SaveZoneInfo(zone_id, "min_status", int_value);
  1730. break;
  1731. }
  1732. case ZONE_SET_VALUE_MIN_LEVEL: {
  1733. if (zone)
  1734. zone->SetMinimumLevel(int_value);
  1735. database.SaveZoneInfo(zone_id, "min_level", int_value);
  1736. break;
  1737. }
  1738. case ZONE_SET_VALUE_MAX_LEVEL: {
  1739. if (zone)
  1740. zone->SetMaximumLevel(int_value);
  1741. database.SaveZoneInfo(zone_id, "max_level", int_value);
  1742. break;
  1743. }
  1744. case ZONE_SET_VALUE_START_ZONE: {
  1745. database.SaveZoneInfo(zone_id, "start_zone", int_value);
  1746. break;
  1747. }
  1748. case ZONE_SET_VALUE_INSTANCE_TYPE: {
  1749. if (zone)
  1750. zone->SetInstanceType(int_value);
  1751. database.SaveZoneInfo(zone_id, "instance_type", int_value);
  1752. break;
  1753. }
  1754. case ZONE_SET_VALUE_DEFAULT_REENTER_TIME: {
  1755. if (zone)
  1756. zone->SetDefaultReenterTime(int_value);
  1757. database.SaveZoneInfo(zone_id, "default_reenter_time", int_value);
  1758. break;
  1759. }
  1760. case ZONE_SET_VALUE_DEFAULT_RESET_TIME: {
  1761. if (zone)
  1762. zone->SetDefaultResetTime(int_value);
  1763. database.SaveZoneInfo(zone_id, "default_reset_time", int_value);
  1764. break;
  1765. }
  1766. case ZONE_SET_VALUE_DEFAULT_LOCKOUT_TIME: {
  1767. if (zone)
  1768. zone->SetDefaultLockoutTime(int_value);
  1769. database.SaveZoneInfo(zone_id, "default_lockout_time", int_value);
  1770. break;
  1771. }
  1772. case ZONE_SET_VALUE_FORCE_GROUP_TO_ZONE: {
  1773. if (zone)
  1774. zone->SetForceGroupZoneOption(int_value);
  1775. database.SaveZoneInfo(zone_id, "force_group_to_zone", int_value);
  1776. break;
  1777. }
  1778. case ZONE_SET_VALUE_LUA_SCRIPT: {
  1779. if (lua_interface && lua_interface->GetZoneScript(value) == 0) {
  1780. client->Message(CHANNEL_COLOR_RED, "Invalid Zone Script file. Be sure you give the absolute path.");
  1781. client->Message(CHANNEL_COLOR_RED, "Example: /zone set lua_script 'ZoneScripts/QueensColony.lua'");
  1782. return false;
  1783. }
  1784. else {
  1785. world.AddZoneScript(zone_id, const_cast<char*>(value));
  1786. database.SaveZoneInfo(zone_id, "lua_script", value);
  1787. }
  1788. break;
  1789. }
  1790. case ZONE_SET_VALUE_SHUTDOWN_TIMER: {
  1791. if (zone)
  1792. zone->SetShutdownTimer(int_value);
  1793. database.SaveZoneInfo(zone_id, "shutdown_timer", int_value);
  1794. break;
  1795. }
  1796. case ZONE_SET_VALUE_ZONE_MOTD: {
  1797. if (zone)
  1798. zone->SetZoneMOTD(string(value));
  1799. database.SaveZoneInfo(zone_id, "zone_motd", value);
  1800. break;
  1801. }
  1802. default: {
  1803. client->Message(CHANNEL_COLOR_RED, "Invalid zone attribute %i", type);
  1804. return false;
  1805. }
  1806. }
  1807. }
  1808. else {
  1809. if (client)
  1810. client->SimpleMessage(CHANNEL_COLOR_RED, "An error occured saving new zone data.");
  1811. return false;
  1812. }
  1813. return true;
  1814. }
  1815. void Commands::Process(int32 index, EQ2_16BitString* command_parms, Client* client, Spawn* targetOverride) {
  1816. if (index >= remote_commands->commands.size()) {
  1817. LogWrite(COMMAND__ERROR, 0, "Command", "Error, command handler of %u was requested, but max handler is %u", index, remote_commands->commands.size());
  1818. return;
  1819. }
  1820. Spawn* cmdTarget = targetOverride ? targetOverride : client->GetPlayer()->GetTarget();
  1821. EQ2_RemoteCommandString* parent_command = 0;
  1822. EQ2_RemoteCommandString* command = &remote_commands->commands[index];
  1823. Seperator* sep = 0;
  1824. if (command_parms->size > 0) {
  1825. sep = new Seperator(command_parms->data.c_str(), ' ', 10, 500, true);
  1826. if (sep && sep->arg[0] && remote_commands->validSubCommand(command->command.data, string(sep->arg[0]))) {
  1827. parent_command = command;
  1828. command = &(remote_commands->subcommands[command->command.data][string(sep->arg[0])]);
  1829. safe_delete(sep);
  1830. if (command_parms->data.length() > (command->command.data.length() + 1))
  1831. sep = new Seperator(command_parms->data.c_str() + (command->command.data.length() + 1), ' ', 10, 500, true);
  1832. LogWrite(COMMAND__DEBUG, 1, "Command", "Handler: %u, COMMAND: '%s', SUBCOMMAND: '%s'", index, parent_command->command.data.c_str(), command->command.data.c_str());
  1833. }
  1834. else
  1835. LogWrite(COMMAND__DEBUG, 1, "Command", "Handler: %u, COMMAND: '%s'", index, command->command.data.c_str());
  1836. }
  1837. int ndx = 0;
  1838. if (command->required_status > client->GetAdminStatus())
  1839. {
  1840. 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());
  1841. safe_delete(sep);
  1842. client->SimpleMessage(3, "Error: Your status is insufficient for this command.");
  1843. return;
  1844. }
  1845. Player* player = client->GetPlayer();
  1846. LogWrite(COMMAND__DEBUG, 0, "Command", "Player '%s' (%u), Command: %s", player->GetName(), client->GetAccountID(), command->command.data.c_str());
  1847. switch (command->handler) {
  1848. case COMMAND_RELOAD: {
  1849. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reload commands:");
  1850. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload structs");
  1851. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload items");
  1852. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload luasystem");
  1853. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spawnscripts");
  1854. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spells");
  1855. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spells npc");
  1856. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload quests");
  1857. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spawns");
  1858. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload groundspawns");
  1859. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload zonescripts");
  1860. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload entity_commands");
  1861. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload factions");
  1862. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload mail");
  1863. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload guilds");
  1864. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload locations");
  1865. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload rules");
  1866. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload transporters");
  1867. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload startabilities");
  1868. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload voiceovers");
  1869. break;
  1870. }
  1871. case COMMAND_RELOADSTRUCTS: {
  1872. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Structs...");
  1873. world.SetReloadingSubsystem("Structs");
  1874. configReader.ReloadStructs();
  1875. world.RemoveReloadingSubSystem("Structs");
  1876. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1877. break;
  1878. }
  1879. case COMMAND_RELOAD_QUESTS: {
  1880. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Quests...");
  1881. world.SetReloadingSubsystem("Quests");
  1882. master_quest_list.Reload();
  1883. client_list.ReloadQuests();
  1884. zone_list.ReloadClientQuests();
  1885. world.RemoveReloadingSubSystem("Quests");
  1886. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1887. break;
  1888. }
  1889. case COMMAND_RELOAD_SPAWNS: {
  1890. client->GetCurrentZone()->ReloadSpawns();
  1891. break;
  1892. }
  1893. case COMMAND_RELOAD_SPELLS: {
  1894. if (sep && sep->arg[0] && strcmp(sep->arg[0], "npc") == 0) {
  1895. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading NPC Spells Lists (Note: Must Reload Spawns/Repop to reset npc spells)...");
  1896. world.PurgeNPCSpells();
  1897. database.LoadNPCSpells();
  1898. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1899. }
  1900. else {
  1901. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spells & NPC Spell Lists (Note: Must Reload Spawns/Repop to reset npc spells)...");
  1902. world.SetReloadingSubsystem("Spells");
  1903. zone_list.DeleteSpellProcess();
  1904. if (lua_interface)
  1905. lua_interface->DestroySpells();
  1906. master_spell_list.Reload();
  1907. zone_list.LoadSpellProcess();
  1908. world.RemoveReloadingSubSystem("Spells");
  1909. world.PurgeNPCSpells();
  1910. database.LoadNPCSpells();
  1911. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1912. }
  1913. break;
  1914. }
  1915. case COMMAND_RELOAD_GROUNDSPAWNS: {
  1916. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Groundspawn Entries...");
  1917. world.SetReloadingSubsystem("GroundSpawns");
  1918. client->GetCurrentZone()->DeleteGroundSpawnItems();
  1919. client->GetCurrentZone()->LoadGroundSpawnEntries();
  1920. world.RemoveReloadingSubSystem("GroundSpawns");
  1921. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1922. break;
  1923. }
  1924. case COMMAND_RELOAD_ZONESCRIPTS: {
  1925. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Zone Scripts...");
  1926. world.SetReloadingSubsystem("ZoneScripts");
  1927. world.ResetZoneScripts();
  1928. database.LoadZoneScriptData();
  1929. if (lua_interface)
  1930. lua_interface->DestroyZoneScripts();
  1931. world.RemoveReloadingSubSystem("ZoneScripts");
  1932. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1933. break;
  1934. }
  1935. case COMMAND_RELOAD_ENTITYCOMMANDS: {
  1936. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Entity Commands...");
  1937. world.SetReloadingSubsystem("EntityCommands");
  1938. client->GetCurrentZone()->ClearEntityCommands();
  1939. database.LoadEntityCommands(client->GetCurrentZone());
  1940. world.RemoveReloadingSubSystem("EntityCommands");
  1941. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1942. break;
  1943. }
  1944. case COMMAND_RELOAD_FACTIONS: {
  1945. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Factions...");
  1946. world.SetReloadingSubsystem("Factions");
  1947. master_faction_list.Clear();
  1948. database.LoadFactionList();
  1949. world.RemoveReloadingSubSystem("Factions");
  1950. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1951. break;
  1952. }
  1953. case COMMAND_RELOAD_MAIL: {
  1954. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Mail...");
  1955. zone_list.ReloadMail();
  1956. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1957. break;
  1958. }
  1959. case COMMAND_RELOAD_GUILDS: {
  1960. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Guilds...");
  1961. world.ReloadGuilds();
  1962. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1963. break;
  1964. }
  1965. case COMMAND_RELOAD_LOCATIONS: {
  1966. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Locations...");
  1967. client->GetPlayer()->GetZone()->RemoveLocationGrids();
  1968. database.LoadLocationGrids(client->GetPlayer()->GetZone());
  1969. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1970. break;
  1971. }
  1972. case COMMAND_RELOAD_RULES: {
  1973. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Rules...");
  1974. database.LoadRuleSets(true);
  1975. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1976. break;
  1977. }
  1978. case COMMAND_RELOAD_TRANSPORTERS: {
  1979. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Transporters in your current zone...");
  1980. database.LoadTransporters(client->GetCurrentZone());
  1981. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1982. break;
  1983. }
  1984. case COMMAND_RELOAD_STARTABILITIES: {
  1985. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Starting Skills/Spells...");
  1986. world.PurgeStartingLists();
  1987. world.LoadStartingLists();
  1988. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1989. break;
  1990. }
  1991. case COMMAND_RELOAD_VOICEOVERS: {
  1992. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Voiceovers...");
  1993. world.PurgeVoiceOvers();
  1994. world.LoadVoiceOvers();
  1995. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1996. break;
  1997. }
  1998. case COMMAND_READ: {
  1999. if (sep && sep->arg[1][0] && sep->IsNumber(1)) {
  2000. if (strcmp(sep->arg[0], "read") == 0) {
  2001. int32 item_index = atol(sep->arg[1]);
  2002. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  2003. if (item) {
  2004. Spawn* spawn = cmdTarget;
  2005. client->SendShowBook(client->GetPlayer(), item->name, item->book_language, item->book_pages);
  2006. break;
  2007. }
  2008. }
  2009. }
  2010. break;
  2011. }
  2012. case COMMAND_USEABILITY:{
  2013. if (sep && sep->arg[0][0] && sep->IsNumber(0)) {
  2014. if (!client->GetPlayer()->Alive()) {
  2015. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot do that right now.");
  2016. }
  2017. else {
  2018. int32 spell_id = atoul(sep->arg[0]);
  2019. int8 spell_tier = 0;
  2020. if (sep->arg[1][0] && sep->IsNumber(1))
  2021. spell_tier = atoi(sep->arg[1]);
  2022. else
  2023. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  2024. if (!spell_tier)
  2025. spell_tier = 1;
  2026. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  2027. if (spell) {
  2028. 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)
  2029. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), cmdTarget, true, true);
  2030. else
  2031. {
  2032. if (cmdTarget)
  2033. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), cmdTarget);
  2034. else
  2035. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  2036. }
  2037. }
  2038. }
  2039. }
  2040. else if (cmdTarget && cmdTarget->IsWidget())
  2041. {
  2042. Widget* widget = (Widget*)cmdTarget;
  2043. widget->HandleUse(client, "use", WIDGET_TYPE_DOOR);
  2044. }
  2045. else
  2046. {
  2047. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /useability {spell_id} [spell_tier]");
  2048. }
  2049. break;
  2050. }
  2051. case COMMAND_INFO:{
  2052. bool check_self_trade = true;
  2053. if(sep && sep->arg[1][0] && sep->IsNumber(1)){
  2054. if(strcmp(sep->arg[0], "inventory") == 0){
  2055. int32 item_index = atol(sep->arg[1]);
  2056. LogWrite(COMMAND__DEBUG, 5, "Command", "/info inventory item original index %u", item_index);
  2057. if(client->GetVersion() <= 561) {
  2058. if(item_index <= 255) {
  2059. item_index = 255 - item_index;
  2060. }
  2061. else {
  2062. if(item_index == 256) { // first "new" item to inventory is assigned index 256 by client
  2063. item_index = client->GetPlayer()->item_list.GetFirstNewItem();
  2064. }
  2065. else {
  2066. // otherwise the slot has to be mapped out depending on the amount of new items + index sent in
  2067. item_index = client->GetPlayer()->item_list.GetNewItemByIndex((int16)item_index - 255);
  2068. }
  2069. }
  2070. }
  2071. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  2072. if(item){
  2073. if (item->IsCollectable() && client->SendCollectionsForItem(item))
  2074. break;
  2075. EQ2Packet* app = 0;
  2076. if(client->GetVersion() <= 561) {
  2077. app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  2078. }
  2079. else {
  2080. app = item->serialize(client->GetVersion(), (!item->GetItemScript() || !lua_interface), client->GetPlayer());
  2081. }
  2082. //DumpPacket(app);
  2083. client->QueuePacket(app);
  2084. if(item->GetItemScript() && lua_interface)
  2085. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  2086. else if(item->generic_info.offers_quest_id > 0){ //leave the current functionality in place if it doesnt have an item script
  2087. Quest* quest = master_quest_list.GetQuest(item->generic_info.offers_quest_id, false);
  2088. if(quest && client->GetPlayer()->HasQuestBeenCompleted(item->generic_info.offers_quest_id) == 0 && client->GetPlayer()->HasActiveQuest(item->generic_info.offers_quest_id) == 0)
  2089. client->AddPendingQuest(new Quest(quest)); // copy quest since we pulled the master quest to see if it existed or not
  2090. }
  2091. }
  2092. else
  2093. LogWrite(COMMAND__ERROR, 0, "Command", "/info inventory: Unknown Index: %u", item_index);
  2094. }
  2095. else if(strcmp(sep->arg[0], "equipment") == 0){
  2096. int32 item_index = client->GetPlayer()->ConvertSlotFromClient(atol(sep->arg[1]), client->GetVersion());
  2097. Item* item = client->GetPlayer()->GetEquipmentList()->GetItem(item_index);
  2098. if(item){
  2099. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  2100. client->QueuePacket(app);
  2101. if(item->GetItemScript() && lua_interface)
  2102. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  2103. }
  2104. else
  2105. LogWrite(COMMAND__ERROR, 0, "Command", "/info equipment: Unknown Index: %u", item_index);
  2106. }
  2107. else if(strcmp(sep->arg[0], "appearance") == 0){
  2108. int32 item_index = client->GetPlayer()->ConvertSlotFromClient(atol(sep->arg[1]), client->GetVersion());
  2109. Item* item = client->GetPlayer()->GetAppearanceEquipmentList()->GetItem(item_index);
  2110. if(item){
  2111. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  2112. client->QueuePacket(app);
  2113. if(item->GetItemScript() && lua_interface)
  2114. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  2115. }
  2116. else
  2117. LogWrite(COMMAND__ERROR, 0, "Command", "/info appearance: Unknown Index: %u", item_index);
  2118. }
  2119. 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){
  2120. int32 item_id = atoul(sep->arg[1]);
  2121. Item* item = master_item_list.GetItem(item_id);
  2122. if(item){
  2123. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  2124. client->QueuePacket(app);
  2125. }
  2126. else
  2127. LogWrite(COMMAND__ERROR, 0, "Command", "/info item|merchant|store|buyback|consignment: Unknown Item ID: %u", item_id);
  2128. }
  2129. else if (strcmp(sep->arg[0], "spell") == 0) {
  2130. sint32 spell_id = atol(sep->arg[1]);
  2131. int8 tier = atoi(sep->arg[3]);
  2132. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, tier, client, true, 0x2A);
  2133. if (outapp)
  2134. client->QueuePacket(outapp);
  2135. else
  2136. LogWrite(COMMAND__ERROR, 0, "Command", "/info spell: Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  2137. }
  2138. else if (strcmp(sep->arg[0], "achievement") == 0) {
  2139. sint32 spell_id = atol(sep->arg[2]);
  2140. int8 group = atoi(sep->arg[1]);
  2141. AltAdvanceData* data = 0;
  2142. SpellBookEntry* spellentry = 0;
  2143. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  2144. LogWrite(COMMAND__ERROR, 0, "Command", "/info achievement: AA Spell ID and/or Tier, ID: %u, Group: %i", spell_id, group);
  2145. EQ2Packet* outapp = master_spell_list.GetAASpellPacket(spell_id, tier, client, true, 0x45);
  2146. if (outapp)
  2147. client->QueuePacket(outapp);
  2148. else
  2149. LogWrite(COMMAND__ERROR, 0, "Command", "/info achievement: Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, group);
  2150. }
  2151. else if (strcmp(sep->arg[0], "spellbook") == 0) {
  2152. sint32 spell_id = atol(sep->arg[1]);
  2153. int32 tier = atoi(sep->arg[2]);
  2154. if (tier > 255) {
  2155. SpellBookEntry* ent = client->GetPlayer()->GetSpellBookSpell(spell_id);
  2156. if (ent)
  2157. tier = ent->tier;
  2158. }
  2159. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, (int8)tier, client, true, 0x2A);
  2160. if (outapp)
  2161. client->QueuePacket(outapp);
  2162. else
  2163. LogWrite(COMMAND__ERROR, 0, "Command", "/info spellbook: Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  2164. }
  2165. else if (strcmp(sep->arg[0], "recipe") == 0) {
  2166. sint32 recipe_id = atol(sep->arg[1]);
  2167. EQ2Packet* outapp = master_recipe_list.GetRecipePacket(recipe_id, client, true, 0x2C);
  2168. if(outapp)
  2169. client->QueuePacket(outapp);
  2170. else
  2171. LogWrite(COMMAND__ERROR, 0, "Command", "/info recipe: Unknown Recipe ID: %u", recipe_id);
  2172. }
  2173. else if (strcmp(sep->arg[0], "recipe_product") == 0) {
  2174. sint32 recipe_id = atol(sep->arg[1]);
  2175. PlayerRecipeList* prl = client->GetPlayer()->GetRecipeList();
  2176. Recipe* recipe = nullptr;
  2177. if ((recipe = prl->GetRecipe(recipe_id)) && recipe->GetProductID()) {
  2178. RecipeProducts* rp = recipe->products[1];
  2179. if (recipe->GetProductID() > 0) {
  2180. Item* item = master_item_list.GetItem(recipe->GetProductID());
  2181. if(item){
  2182. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  2183. client->QueuePacket(app);
  2184. }
  2185. else
  2186. LogWrite(COMMAND__ERROR, 0, "Command", "/info recipe_product: Unknown Item ID: %u", recipe->GetProductID());
  2187. }
  2188. else {
  2189. LogWrite(COMMAND__ERROR, 0, "Command", "/info recipe_product: recipe->GetProductID() has value 0 for recipe id %u.", recipe_id);
  2190. }
  2191. }
  2192. else {
  2193. 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);
  2194. }
  2195. }
  2196. else if (strcmp(sep->arg[0], "maintained") ==0) {
  2197. int32 slot = atol(sep->arg[1]);
  2198. int32 spell_id = atol(sep->arg[2]);
  2199. LogWrite(COMMAND__DEBUG, 5, "Command", "/info maintained: Spell ID - Slot: %u unknown: %u", slot, spell_id);
  2200. //int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  2201. MaintainedEffects* info = client->GetPlayer()->GetMaintainedSpellBySlot(slot);
  2202. EQ2Packet* outapp = master_spell_list.GetSpellPacket(info->spell_id, info->tier, client, true, 0x00);
  2203. if(outapp)
  2204. client->QueuePacket(outapp);
  2205. else
  2206. LogWrite(COMMAND__ERROR, 0, "Command", "/info maintained: Unknown Spell ID: %u", spell_id);
  2207. }
  2208. else if (strcmp(sep->arg[0], "effect") == 0) {
  2209. int32 spell_id = atol(sep->arg[1]);
  2210. LogWrite(COMMAND__DEBUG, 5, "Command", "/info effect: Spell ID: %u", spell_id);
  2211. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  2212. int8 type = 0;
  2213. if (client->GetVersion() <= 561)
  2214. type = 1;
  2215. EQ2Packet* outapp = master_spell_list.GetSpecialSpellPacket(spell_id, tier, client, true, type);
  2216. if (outapp){
  2217. client->QueuePacket(outapp);
  2218. }
  2219. else
  2220. LogWrite(COMMAND__ERROR, 0, "Command", "/info effect: Unknown Spell ID: %u", spell_id);
  2221. }
  2222. else if(sep->IsNumber(1) && ((strncasecmp("your_trade", sep->arg[0], 10) == 0) ||
  2223. (strncasecmp("their_trade", sep->arg[0], 11) == 0)))
  2224. {
  2225. if(strncasecmp("t", sep->arg[0], 1) == 0) { // their_trade not self trade
  2226. check_self_trade = false;
  2227. }
  2228. int8 slot_id = atoul(sep->arg[1]);
  2229. if(client->GetPlayer()->trade) {
  2230. Entity* traderToCheck = client->GetPlayer();
  2231. if(!check_self_trade) {
  2232. traderToCheck = client->GetPlayer()->trade->GetTradee(client->GetPlayer());
  2233. }
  2234. Item* tradeItem = client->GetPlayer()->trade->GetTraderSlot(traderToCheck, slot_id);
  2235. if(tradeItem != nullptr) {
  2236. EQ2Packet* app = tradeItem->serialize(client->GetVersion(), true, client->GetPlayer(), true, 0, 0, client->GetVersion() > 561 ? true : false);
  2237. client->QueuePacket(app);
  2238. }
  2239. }
  2240. }
  2241. }
  2242. else if (sep && strcmp(sep->arg[0], "overflow") == 0) {
  2243. Item* item = player->item_list.GetOverflowItem();
  2244. if(item) {
  2245. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  2246. client->QueuePacket(app);
  2247. }
  2248. else
  2249. LogWrite(COMMAND__ERROR, 0,"Command", "/info overflow: Unable to retrieve an overflow item.");
  2250. }
  2251. else
  2252. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /info {inventory|equipment|spell} {id}");
  2253. break;
  2254. }
  2255. case COMMAND_USE_EQUIPPED_ITEM:{
  2256. if (sep && sep->arg[0] && sep->IsNumber(0)){
  2257. int32 slot_id = atoul(sep->arg[0]);
  2258. Item* item = player->GetEquipmentList()->GetItem(slot_id);
  2259. if (item && item->generic_info.usable && item->GetItemScript()) {
  2260. if(!item->CheckFlag2(INDESTRUCTABLE) && item->generic_info.condition == 0) {
  2261. client->SimpleMessage(CHANNEL_COLOR_RED, "This item is broken and must be repaired at a mender before it can be used");
  2262. }
  2263. else if (item->CheckFlag(EVIL_ONLY) && client->GetPlayer()->GetAlignment() != ALIGNMENT_EVIL) {
  2264. client->Message(0, "%s requires an evil race.", item->name.c_str());
  2265. }
  2266. else if (item->CheckFlag(GOOD_ONLY) && client->GetPlayer()->GetAlignment() != ALIGNMENT_GOOD) {
  2267. client->Message(0, "%s requires a good race.", item->name.c_str());
  2268. }
  2269. else {
  2270. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player, player->GetTarget());
  2271. }
  2272. }
  2273. }
  2274. break;
  2275. }
  2276. case COMMAND_USE_ITEM: {
  2277. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  2278. int32 item_index = atoul(sep->arg[0]);
  2279. Item* item = player->item_list.GetItemFromIndex(item_index);
  2280. client->UseItem(item, client->GetPlayer()->GetTarget() ? client->GetPlayer()->GetTarget() : client->GetPlayer());
  2281. }
  2282. break;
  2283. }
  2284. case COMMAND_SCRIBE_SCROLL_ITEM: {
  2285. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  2286. Item* item = player->item_list.GetItemFromUniqueID(atoul(sep->arg[0]));
  2287. if (item) {
  2288. LogWrite(ITEM__DEBUG, 0, "Items", "ITEM ID: %u", item->details.item_id);
  2289. if(item->generic_info.item_type == 6) {
  2290. Spell* spell = master_spell_list.GetSpell(item->skill_info->spell_id, item->skill_info->spell_tier);
  2291. int8 old_slot = 0;
  2292. if (spell) {
  2293. if(!spell->ScribeAllowed(client->GetPlayer())) {
  2294. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not meet one of the requirements to scribe, due to class or level.");
  2295. break;
  2296. }
  2297. int16 tier_up = player->GetTierUp(spell->GetSpellTier());
  2298. if (rule_manager.GetGlobalRule(R_Spells, RequirePreviousTierScribe)->GetInt8() && !player->HasSpell(spell->GetSpellID(), tier_up, false, true))
  2299. client->SimpleMessage(CHANNEL_COLOR_RED, "You have not scribed the required previous version of this ability.");
  2300. else if (!player->HasSpell(spell->GetSpellID(), spell->GetSpellTier(), true)) {
  2301. old_slot = player->GetSpellSlot(spell->GetSpellID());
  2302. player->RemoveSpellBookEntry(spell->GetSpellID());
  2303. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  2304. player->UnlockSpell(spell);
  2305. client->SendSpellUpdate(spell);
  2306. database.DeleteItem(client->GetCharacterID(), item, 0);
  2307. player->item_list.RemoveItem(item, true);
  2308. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  2309. client->QueuePacket(player->SendInventoryUpdate(client->GetVersion()));
  2310. // force purge client cache and display updated spell for hover over
  2311. EQ2Packet* app = spell->SerializeSpell(client, false, false);
  2312. client->QueuePacket(app);
  2313. }
  2314. }
  2315. else
  2316. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown spell ID: %u and tier: %u", item->skill_info->spell_id, item->skill_info->spell_tier);
  2317. }
  2318. else if(item->generic_info.item_type == 7){
  2319. if(item->recipebook_info) {
  2320. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Scribing recipe book %s (%u) for player %s.", item->name.c_str(), item->recipebook_info->recipe_id, player->GetName());
  2321. client->AddRecipeBookToPlayer(item->recipebook_info->recipe_id, item);
  2322. }
  2323. else {
  2324. 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);
  2325. 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());
  2326. }
  2327. }
  2328. else {
  2329. LogWrite(COMMAND__ERROR, 0, "Command", "Recipe Book Info is not set for item %s.", item->name.c_str());
  2330. }
  2331. }
  2332. else
  2333. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown unique item ID: %s", sep->arg[0]);
  2334. }
  2335. break;
  2336. }
  2337. case COMMAND_SUMMONITEM: {
  2338. if (sep && sep->IsNumber(0)) {
  2339. int32 item_id = atol(sep->arg[0]);
  2340. int32 quantity = 1;
  2341. if (sep->arg[1] && sep->IsNumber(1))
  2342. quantity = atoi(sep->arg[1]);
  2343. if (sep->arg[2] && strncasecmp(sep->arg[2], "bank", 4) == 0) {
  2344. client->AddItemToBank(item_id,quantity);
  2345. }
  2346. else {
  2347. client->AddItem(item_id, quantity);
  2348. }
  2349. }
  2350. else {
  2351. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} [quantity] or");
  2352. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} {quantity} [location] where location = bank");
  2353. }
  2354. break;
  2355. }
  2356. case COMMAND_COLLECTION_ADDITEM: {
  2357. // takes 2 params: collection_id, slot
  2358. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  2359. Item *item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(atoul(sep->arg[1]));
  2360. if (item)
  2361. client->HandleCollectionAddItem(atoul(sep->arg[0]), item);
  2362. else
  2363. 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]));
  2364. }
  2365. else
  2366. LogWrite(COLLECTION__ERROR, 0, "Collect", "Received command 'COMMAND_COLLECTION_ADDITEM' with unhandeled argument types");
  2367. break;
  2368. }
  2369. case COMMAND_COLLECTION_FILTER_MATCHITEM: {
  2370. // takes 1 param: slot
  2371. printf("COMMAND_COLLECTION_FILTER_MATCHITEM:\n");
  2372. int i = 0;
  2373. while (sep->arg[i] && strlen(sep->arg[i]) > 0) {
  2374. printf("\t%u: %s\n", i, sep->arg[i]);
  2375. i++;
  2376. }
  2377. break;
  2378. }
  2379. case COMMAND_WAYPOINT: {
  2380. bool success = false;
  2381. client->ClearWaypoint();
  2382. if (sep && sep->IsNumber(0) && sep->IsNumber(1) && sep->IsNumber(2)) {
  2383. if (!client->ShowPathToTarget(atof(sep->arg[0]), atof(sep->arg[1]), atof(sep->arg[2]), 0))
  2384. client->Message(CHANNEL_COLOR_RED, "Invalid coordinates given");
  2385. }
  2386. else if ( client->GetAdminStatus() > 100 && cmdTarget ) {
  2387. if (!client->ShowPathToTarget(cmdTarget->GetX(), cmdTarget->GetY(), cmdTarget->GetZ(), 0))
  2388. client->Message(CHANNEL_COLOR_RED, "Invalid coordinates given");
  2389. }
  2390. else {
  2391. client->Message(CHANNEL_COLOR_YELLOW, "Usage: /waypoint x y z");
  2392. }
  2393. break;
  2394. }
  2395. case COMMAND_WHO:{
  2396. const char* who = 0;
  2397. if(sep && sep->arg[0]){
  2398. //cout << "Who query: \n";
  2399. who = sep->argplus[0];
  2400. //cout << who << endl;
  2401. }
  2402. zone_list.ProcessWhoQuery(who, client);
  2403. break;
  2404. }
  2405. case COMMAND_SELECT_JUNCTION:{
  2406. // transporters (bells birds) use OP_SelectZoneTeleporterDestinatio / ProcessTeleportLocation(app)
  2407. // this is only used for revive it seems
  2408. int32 choice = 0;
  2409. if(sep && sep->arg[0] && sep->IsNumber(0))
  2410. choice = atoul(sep->arg[0]);
  2411. if(!client->GetPlayer()->Alive()){ //dead and this is a revive request
  2412. client->HandlePlayerRevive(choice);
  2413. }
  2414. break;
  2415. }
  2416. case COMMAND_SPAWN_MOVE: {
  2417. if (cmdTarget && cmdTarget->IsPlayer() == false) {
  2418. PacketStruct* packet = configReader.getStruct("WS_MoveObjectMode", client->GetVersion());
  2419. if (packet) {
  2420. float unknown2_3 = 0;
  2421. int8 placement_mode = 0;
  2422. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::DEFAULT);
  2423. if (sep && sep->arg[0][0]) {
  2424. if (strcmp(sep->arg[0], "wall") == 0) {
  2425. placement_mode = 2;
  2426. unknown2_3 = 150;
  2427. }
  2428. else if (strcmp(sep->arg[0], "ceiling") == 0)
  2429. placement_mode = 1;
  2430. else if (strcmp(sep->arg[0], "openheading") == 0 && cmdTarget->IsWidget())
  2431. {
  2432. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "[PlacementMode] WIDGET OPEN HEADING MODE");
  2433. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::OPEN_HEADING);
  2434. }
  2435. else if (strcmp(sep->arg[0], "closeheading") == 0 && cmdTarget->IsWidget())
  2436. {
  2437. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "[PlacementMode] WIDGET CLOSE HEADING MODE");
  2438. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::CLOSE_HEADING);
  2439. }
  2440. else if (strcmp(sep->arg[0], "myloc") == 0)
  2441. {
  2442. if (cmdTarget->GetSpawnLocationPlacementID() < 1) {
  2443. client->Message(CHANNEL_COLOR_YELLOW, "[PlacementMode] Spawn %s cannot be moved it is not assigned a spawn location placement id.", cmdTarget->GetName());
  2444. safe_delete(packet);
  2445. break;
  2446. }
  2447. cmdTarget->SetX(client->GetPlayer()->GetX(), true);
  2448. cmdTarget->SetY(client->GetPlayer()->GetY(), true);
  2449. cmdTarget->SetZ(client->GetPlayer()->GetZ(), true);
  2450. cmdTarget->SetHeading(client->GetPlayer()->GetHeading(), true);
  2451. if (database.UpdateSpawnLocationSpawns(cmdTarget))
  2452. client->Message(CHANNEL_COLOR_YELLOW, "[PlacementMode] Spawn %s placed at your location. Updated spawn_location_placement for spawn.", cmdTarget->GetName());
  2453. safe_delete(packet);
  2454. break;
  2455. }
  2456. }
  2457. packet->setDataByName("placement_mode", placement_mode);
  2458. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget));
  2459. packet->setDataByName("model_type", cmdTarget->GetModelType());
  2460. packet->setDataByName("unknown", 1); //size
  2461. packet->setDataByName("unknown2", 1); //size 2
  2462. packet->setDataByName("unknown2", .5, 1); //size 3
  2463. packet->setDataByName("unknown2", 3, 2);
  2464. packet->setDataByName("unknown2", unknown2_3, 3);
  2465. packet->setDataByName("max_distance", 500);
  2466. packet->setDataByName("CoEunknown", 0xFFFFFFFF);
  2467. client->QueuePacket(packet->serialize());
  2468. safe_delete(packet);
  2469. }
  2470. }
  2471. else {
  2472. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /spawn move (wall OR ceiling)");
  2473. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Moves a spawn anywhere you like. Optionally wall/ceiling can be provided to place wall/ceiling items.");
  2474. }
  2475. break;
  2476. }
  2477. case COMMAND_HAIL:{
  2478. Spawn* spawn = cmdTarget;
  2479. if(spawn && spawn->GetTargetable())
  2480. {
  2481. char tmp[75] = {0};
  2482. sprintf(tmp, "Hail, %s", spawn->GetName());
  2483. bool show_bubble = true;
  2484. if (spawn->IsNPC())
  2485. show_bubble = false;
  2486. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp, HEAR_SPAWN_DISTANCE, 0, show_bubble, client->GetPlayer()->GetCurrentLanguage());
  2487. if(spawn->IsPlayer() == false && spawn->Alive() && spawn->GetDistance(client->GetPlayer()) < rule_manager.GetGlobalRule(R_Spawn, HailDistance)->GetInt32()){
  2488. if(spawn->IsNPC() && ((NPC*)spawn)->EngagedInCombat())
  2489. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED_BUSY, client->GetPlayer());
  2490. else
  2491. {
  2492. bool pauseRunback = false;
  2493. // prime runback as the heading or anything can be altered when hailing succeeds
  2494. if(spawn->IsNPC() && (spawn->HasMovementLoop() || spawn->HasMovementLocations()))
  2495. {
  2496. ((NPC*)spawn)->StartRunback();
  2497. pauseRunback = true;
  2498. }
  2499. if(spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED, client->GetPlayer()) && pauseRunback)
  2500. spawn->PauseMovement(rule_manager.GetGlobalRule(R_Spawn, HailMovementPause)->GetInt32());
  2501. else if(spawn->IsNPC() && pauseRunback)
  2502. ((NPC*)spawn)->ClearRunback();
  2503. }
  2504. }
  2505. }
  2506. else {
  2507. string tmp = "Hail";
  2508. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp.c_str(), HEAR_SPAWN_DISTANCE, 0, true, client->GetPlayer()->GetCurrentLanguage());
  2509. }
  2510. break;
  2511. }
  2512. case COMMAND_SAY:{
  2513. if (sep && sep->arg[0][0]) {
  2514. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, sep->argplus[0], HEAR_SPAWN_DISTANCE, 0, true, client->GetPlayer()->GetCurrentLanguage());
  2515. if (cmdTarget && !(cmdTarget->IsPlayer()))
  2516. client->GetCurrentZone()->CallSpawnScript(cmdTarget, SPAWN_SCRIPT_HEAR_SAY, client->GetPlayer(), sep->argplus[0]);
  2517. }
  2518. else
  2519. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /say {message}");
  2520. break;
  2521. }
  2522. case COMMAND_TELL:{
  2523. if(sep && sep->arg[0] && sep->argplus[1]){
  2524. if(!zone_list.HandleGlobalChatMessage(client, sep->arg[0], CHANNEL_PRIVATE_TELL, sep->argplus[1], 0, client->GetPlayer()->GetCurrentLanguage()))
  2525. client->Message(CHANNEL_COLOR_RED,"Unable to find client %s",sep->arg[0]);
  2526. }else
  2527. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /tell {character_name} {message}");
  2528. break;
  2529. }
  2530. case COMMAND_SHOUT:{
  2531. if(sep && sep->arg[0][0])
  2532. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SHOUT, sep->argplus[0], 0, 0, true, client->GetPlayer()->GetCurrentLanguage());
  2533. else
  2534. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /shout {message}");
  2535. break;
  2536. }
  2537. case COMMAND_AUCTION:{
  2538. if(sep && sep->arg[0][0])
  2539. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_AUCTION, sep->argplus[0], 0, 0, true, client->GetPlayer()->GetCurrentLanguage());
  2540. else
  2541. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /auction {message}");
  2542. break;
  2543. }
  2544. case COMMAND_OOC:{
  2545. //For now ooc will be the global chat channel, eventually when we create more channels we will create a global chat channel
  2546. if(sep && sep->arg[0][0])
  2547. zone_list.HandleGlobalChatMessage(client, 0, CHANNEL_OUT_OF_CHARACTER, sep->argplus[0], 0, client->GetPlayer()->GetCurrentLanguage());
  2548. else
  2549. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /ooc {message}");
  2550. break;
  2551. }
  2552. case COMMAND_EMOTE:{
  2553. if(sep && sep->arg[0][0])
  2554. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_EMOTE, sep->argplus[0]);
  2555. else
  2556. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /emote {action}");
  2557. break;
  2558. }
  2559. case COMMAND_RACE:{
  2560. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  2561. if(sep->arg[1][0] && sep->IsNumber(1)){
  2562. client->GetPlayer()->GetInfoStruct()->set_race(atoi(sep->arg[1]));
  2563. client->GetPlayer()->SetRace(atoi(sep->arg[1]));
  2564. client->UpdateTimeStampFlag ( RACE_UPDATE_FLAG );
  2565. client->GetPlayer()->SetCharSheetChanged(true);
  2566. }
  2567. client->GetPlayer()->SetModelType(atoi(sep->arg[0]));
  2568. //EQ2Packet* outapp = client->GetPlayer()->spawn_update_packet(client->GetPlayer(), client->GetVersion(), client->GetPlayer()->GetFeatures());
  2569. //client->QueuePacket(outapp);
  2570. }
  2571. else{
  2572. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /race {race type id} {race id}");
  2573. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "{race id} is optional");
  2574. }
  2575. break;
  2576. }
  2577. case COMMAND_BANK_DEPOSIT:{
  2578. if(client->GetBanker() && sep && sep->arg[0]){
  2579. int64 amount = 0;
  2580. string deposit = string(sep->arg[0]);
  2581. amount = atoi64(deposit.c_str());
  2582. client->BankDeposit(amount);
  2583. }
  2584. break;
  2585. }
  2586. case COMMAND_BANK_WITHDRAWAL:{
  2587. if(client->GetBanker() && sep && sep->arg[0] && sep->IsNumber(0)){
  2588. int64 amount = 0;
  2589. string deposit = string(sep->arg[0]);
  2590. amount = atoi64(deposit.c_str());
  2591. client->BankWithdrawal(amount);
  2592. }
  2593. break;
  2594. }
  2595. case COMMAND_BANK_CANCEL:{
  2596. Spawn* banker = cmdTarget;
  2597. client->Bank(banker, true);
  2598. break;
  2599. }
  2600. case COMMAND_BANK:{
  2601. LogWrite(PLAYER__DEBUG, 0, "Players", "Open Player Personal Bank...");
  2602. Spawn* banker = cmdTarget;
  2603. client->Bank(banker);
  2604. break;
  2605. }
  2606. case COMMAND_GUILD_BANK:{
  2607. LogWrite(GUILD__DEBUG, 0, "Guilds", "Open Guild Bank...");
  2608. //Spawn* banker = client->GetPlayer()->GetTarget();
  2609. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will eventually open the guild bank!");
  2610. break;
  2611. }
  2612. case COMMAND_START_MAIL: {
  2613. client->SetMailTransaction(cmdTarget);
  2614. client->SendMailList();
  2615. break;
  2616. }
  2617. case COMMAND_CANCEL_MAIL: {
  2618. client->SetMailTransaction(0);
  2619. break;
  2620. }
  2621. case COMMAND_GET_MAIL_MESSAGE: {
  2622. if (sep && sep->arg[0] && sep->IsNumber(0))
  2623. client->DisplayMailMessage(atoul(sep->arg[0]));
  2624. break;
  2625. }
  2626. case COMMAND_ADD_MAIL_PLAT: {
  2627. if (sep && sep->arg[0] && sep->IsNumber(0))
  2628. client->AddMailCoin(0, 0, 0, atoul(sep->arg[0]));
  2629. break;
  2630. }
  2631. case COMMAND_ADD_MAIL_GOLD: {
  2632. if (sep && sep->arg[0] && sep->IsNumber(0))
  2633. client->AddMailCoin(0, 0, atoul(sep->arg[0]));
  2634. break;
  2635. }
  2636. case COMMAND_ADD_MAIL_SILVER: {
  2637. if (sep && sep->arg[0] && sep->IsNumber(0))
  2638. client->AddMailCoin(0, atoul(sep->arg[0]));
  2639. break;
  2640. }
  2641. case COMMAND_ADD_MAIL_COPPER: {
  2642. if (sep && sep->arg[0] && sep->IsNumber(0))
  2643. client->AddMailCoin(atoul(sep->arg[0]));
  2644. break;
  2645. }
  2646. case COMMAND_SET_MAIL_ITEM: {
  2647. if(sep && sep->IsNumber(0) && sep->IsNumber(1))
  2648. {
  2649. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(atoul(sep->arg[0]));
  2650. if(item)
  2651. {
  2652. int16 quantity = atoul(sep->arg[1]);
  2653. if(item->CheckFlag(NO_TRADE) || item->CheckFlag(ATTUNED) || item->CheckFlag(ARTIFACT) || item->CheckFlag2(HEIRLOOM))
  2654. {
  2655. return;
  2656. }
  2657. if(item->IsBag())
  2658. {
  2659. vector<Item*>* bag_items = player->GetPlayerItemList()->GetItemsInBag(item);
  2660. if(bag_items && bag_items->size() > 0)
  2661. {
  2662. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot mail a bag with items inside it.");
  2663. safe_delete(bag_items);
  2664. return;
  2665. }
  2666. safe_delete(bag_items);
  2667. }
  2668. Item* itemtoadd = item;
  2669. if(quantity > 0)
  2670. {
  2671. if(quantity > item->details.count)
  2672. return;
  2673. Item* tmpItem = new Item(item);
  2674. tmpItem->details.count = quantity;
  2675. itemtoadd = tmpItem;
  2676. }
  2677. if(client->AddMailItem(itemtoadd))
  2678. {
  2679. client->RemoveItem(item, quantity, true);
  2680. }
  2681. }
  2682. }
  2683. break;
  2684. }
  2685. case COMMAND_REMOVE_MAIL_PLAT: {
  2686. if (sep && sep->arg[0] && sep->IsNumber(0))
  2687. client->RemoveMailCoin(0, 0, 0, atoul(sep->arg[0]));
  2688. break;
  2689. }
  2690. case COMMAND_REMOVE_MAIL_GOLD: {
  2691. if (sep && sep->arg[0] && sep->IsNumber(0))
  2692. client->RemoveMailCoin(0, 0, atoul(sep->arg[0]));
  2693. break;
  2694. }
  2695. case COMMAND_REMOVE_MAIL_SILVER: {
  2696. if (sep && sep->arg[0] && sep->IsNumber(0))
  2697. client->RemoveMailCoin(0, atoul(sep->arg[0]));
  2698. break;
  2699. }
  2700. case COMMAND_REMOVE_MAIL_COPPER: {
  2701. if (sep && sep->arg[0] && sep->IsNumber(0))
  2702. client->RemoveMailCoin(atoul(sep->arg[0]));
  2703. break;
  2704. }
  2705. case COMMAND_TAKE_MAIL_ATTACHMENTS: {
  2706. if (sep && sep->arg[0] && sep->IsNumber(0))
  2707. client->TakeMailAttachments(atoul(sep->arg[0]));
  2708. break;
  2709. }
  2710. case COMMAND_CANCEL_SEND_MAIL: {
  2711. client->ResetSendMail();
  2712. break;
  2713. }
  2714. case COMMAND_DELETE_MAIL_MESSAGE: {
  2715. if (sep && sep->arg[0] && sep->IsNumber(0))
  2716. client->DeleteMail(atoul(sep->arg[0]), true);
  2717. break;
  2718. }
  2719. case COMMAND_REPORT_SPAM: {
  2720. LogWrite(MISC__TODO, 1, "TODO", " received reportspam\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  2721. if (sep && sep->arg[0]) LogWrite(COMMAND__DEBUG, 0, "Command", "%s\n", sep->argplus[0]);
  2722. break;
  2723. }
  2724. case COMMAND_KILL:{
  2725. Spawn* dead = 0;
  2726. if (sep && sep->arg[0] && strncasecmp(sep->arg[0],"self",4)==0){
  2727. dead=client->GetPlayer();
  2728. client->GetPlayer()->SetHP(0);
  2729. client->GetPlayer()->KillSpawn(dead);
  2730. }else{
  2731. dead= cmdTarget;
  2732. if(dead && dead->IsPlayer() == false){
  2733. if(dead->IsNPC() && ((NPC*)dead)->Brain()) {
  2734. client->GetPlayer()->CheckEncounterState((Entity*)dead);
  2735. ((NPC*)dead)->Brain()->AddToEncounter(client->GetPlayer());
  2736. ((NPC*)dead)->AddTargetToEncounter(client->GetPlayer());
  2737. ((NPC*)dead)->Brain()->AddHate(client->GetPlayer(), 1);
  2738. }
  2739. dead->SetHP(0);
  2740. if(sep && sep->arg[0] && sep->IsNumber(0) && atoi(sep->arg[0]) == 1)
  2741. client->GetCurrentZone()->RemoveSpawn(dead, true, true, true, true, true);
  2742. else
  2743. client->GetPlayer()->KillSpawn(dead);
  2744. }else{
  2745. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /kill (self)");
  2746. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Kills currently selected non-player target.");
  2747. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Optionally, self may be used to kill yourself");
  2748. }
  2749. }
  2750. break;
  2751. }
  2752. case COMMAND_LEVEL:{
  2753. if(sep && sep->arg[ndx][0] && sep->IsNumber(0)){
  2754. int16 new_level = atoi(sep->arg[ndx]);
  2755. if (!client->GetPlayer()->CheckLevelStatus(new_level))
  2756. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have the required status to level up anymore!");
  2757. else {
  2758. if (new_level < 1)
  2759. new_level = 1;
  2760. if (new_level > 255)
  2761. new_level = 255;
  2762. client->ChangeLevel(client->GetPlayer()->GetLevel(), new_level);
  2763. }
  2764. }else
  2765. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /level {new_level}");
  2766. break;
  2767. }
  2768. case COMMAND_SIT: {
  2769. if(client->GetPlayer()->GetHP() > 0){
  2770. client->QueuePacket(new EQ2Packet(OP_SitMsg, 0, 0));
  2771. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You sit down.");
  2772. client->GetPlayer()->set_character_flag(CF_IS_SITTING);
  2773. }
  2774. break;
  2775. }
  2776. case COMMAND_STAND: {
  2777. if(client->GetPlayer()->GetHP() > 0){
  2778. client->QueuePacket(new EQ2Packet(OP_StandMsg, 0, 0));
  2779. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You stand up.");
  2780. client->GetPlayer()->reset_character_flag(CF_IS_SITTING);
  2781. }
  2782. break;
  2783. }
  2784. case COMMAND_CLASS:{
  2785. if(sep && sep->arg[ndx][0]){
  2786. client->GetPlayer()->SetPlayerAdventureClass(atoi(sep->arg[ndx]));
  2787. client->UpdateTimeStampFlag ( CLASS_UPDATE_FLAG );
  2788. }else
  2789. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /class {class_id}");
  2790. break;
  2791. }
  2792. case COMMAND_FLYMODE:{
  2793. if(sep && sep->arg[0] && sep->IsNumber(0)){
  2794. PrintSep(sep, "COMMAND_FLYMODE");
  2795. int8 val = atoul(sep->arg[0]);
  2796. ClientPacketFunctions::SendFlyMode(client, val);
  2797. }
  2798. else{
  2799. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage ON: /flymode [1|2] 1 = fly, 2 = no clip");
  2800. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage OFF: /flymode 0");
  2801. }
  2802. break;
  2803. }
  2804. case COMMAND_LOOT_LIST:{
  2805. Spawn* spawn = cmdTarget;
  2806. if(spawn && spawn->IsEntity()){
  2807. if (sep && sep->arg[0]) {
  2808. if (!spawn->GetDatabaseID())
  2809. {
  2810. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "NOTE: Spawn has no database id to assign to loottables.");
  2811. }
  2812. if (!spawn->IsNPC())
  2813. {
  2814. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "these /loot list [add/remove/clearall] sub-commands are only designed for an NPC.");
  2815. break;
  2816. }
  2817. bool reloadLoot = false;
  2818. if (!stricmp(sep->arg[0], "remove") && sep->arg[1] && sep->IsNumber(1))
  2819. {
  2820. int32 loottable_id = atoul(sep->arg[1]);
  2821. if (loottable_id > 0 && database.RemoveSpawnLootTable(spawn, loottable_id))
  2822. {
  2823. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u loot table %u removed.", spawn->GetDatabaseID(), loottable_id);
  2824. reloadLoot = true;
  2825. }
  2826. else
  2827. client->Message(CHANNEL_COLOR_YELLOW, "/loot list remove [loottableid] - could not match any spawn_id entries against loottable_id %u.", loottable_id);
  2828. }
  2829. else if (!stricmp(sep->arg[0], "add") && sep->arg[1] && sep->IsNumber(1))
  2830. {
  2831. int32 loottable_id = atoul(sep->arg[1]);
  2832. if (loottable_id > 0)
  2833. {
  2834. database.AddLootTableToSpawn(spawn, loottable_id);
  2835. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u loot table %u added.", spawn->GetDatabaseID(), loottable_id);
  2836. reloadLoot = true;
  2837. }
  2838. else
  2839. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list add [loottableid] - cannot add a loottable id of 0.");
  2840. }
  2841. else if (!stricmp(sep->arg[0], "clearall"))
  2842. {
  2843. if (database.RemoveSpawnLootTable(spawn, 0))
  2844. {
  2845. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn loot tables removed.");
  2846. reloadLoot = true;
  2847. }
  2848. else
  2849. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list clearall - could not match any spawn_id entries in loottable_id.");
  2850. }
  2851. else if (!stricmp(sep->arg[0], "details"))
  2852. {
  2853. spawn->LockLoot();
  2854. client->SimpleMessage(CHANNEL_COMMANDS, "Loot Window List:");
  2855. if (spawn->GetLootWindowList()->size() > 0) {
  2856. std::map<int32, bool>::iterator itr;
  2857. for (itr = spawn->GetLootWindowList()->begin(); itr != spawn->GetLootWindowList()->end(); itr++) {
  2858. Spawn* looter = client->GetPlayer()->GetZone()->GetSpawnByID(itr->first);
  2859. if (looter) {
  2860. client->Message(CHANNEL_COLOR_YELLOW, "Looter: %s IsLootWindowOpen: %s, HasCompletedLootWindow: %s.", looter->GetName(), itr->second ? "NO" : "YES", spawn->HasSpawnLootWindowCompleted(itr->first) ? "YES" : "NO");
  2861. }
  2862. }
  2863. }
  2864. spawn->UnlockLoot();
  2865. }
  2866. else
  2867. {
  2868. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list argument not supported.");
  2869. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list add [loottableid] - add new loottable to spawn");
  2870. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list remove [loottableid] - remove existing loottable from spawn");
  2871. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list clearall - remove all loottables from spawn");
  2872. break;
  2873. }
  2874. if (reloadLoot)
  2875. {
  2876. database.LoadSpawnLoot(spawn->GetZone(), spawn);
  2877. if (spawn->IsNPC())
  2878. {
  2879. Entity* ent = (Entity*)spawn;
  2880. ent->SetLootCoins(0);
  2881. ent->ClearLoot();
  2882. spawn->GetZone()->AddLoot((NPC*)spawn);
  2883. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u active loot purged and reloaded.", spawn->GetDatabaseID());
  2884. }
  2885. }
  2886. break; // nothing further this is the end of these sub commands
  2887. }
  2888. else
  2889. {
  2890. vector<int32> loot_list = client->GetCurrentZone()->GetSpawnLootList(spawn->GetDatabaseID(), spawn->GetZone()->GetZoneID(), spawn->GetLevel(), race_types_list.GetRaceType(spawn->GetModelType()), spawn);
  2891. if (loot_list.size() > 0) {
  2892. client->Message(CHANNEL_COLOR_YELLOW, "%s belongs to the following loot lists: ", spawn->GetName());
  2893. vector<int32>::iterator list_itr;
  2894. LootTable* table = 0;
  2895. for (list_itr = loot_list.begin(); list_itr != loot_list.end(); list_itr++) {
  2896. table = client->GetCurrentZone()->GetLootTable(*list_itr);
  2897. if (table)
  2898. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", *list_itr, table->name.c_str());
  2899. }
  2900. }
  2901. client->Message(CHANNEL_COLOR_YELLOW, "Coins being carried: %u", spawn->GetLootCoins());
  2902. vector<Item*>* items = spawn->GetLootItems();
  2903. if (items) {
  2904. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is carrying the following items: ");
  2905. vector<Item*>::iterator itr;
  2906. Item* item = 0;
  2907. for (itr = items->begin(); itr != items->end(); itr++) {
  2908. item = *itr;
  2909. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", item->details.item_id, item->name.c_str());
  2910. }
  2911. }
  2912. else
  2913. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is not carrying any items.");
  2914. }
  2915. }
  2916. break;
  2917. }
  2918. case COMMAND_LOOT_SETCOIN:{
  2919. Spawn* spawn = cmdTarget;
  2920. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2921. spawn->SetLootCoins(atoul(sep->arg[0]));
  2922. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully set coins.");
  2923. }
  2924. else
  2925. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot setcoin {amount}");
  2926. break;
  2927. }
  2928. case COMMAND_LOOT_ADDITEM:{
  2929. Spawn* spawn = cmdTarget;
  2930. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2931. int16 charges = 1;
  2932. if(sep->arg[1] && sep->IsNumber(1))
  2933. charges = atoi(sep->arg[1]);
  2934. spawn->AddLootItem(atoul(sep->arg[0]), charges);
  2935. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully added item.");
  2936. }
  2937. else
  2938. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot additem {item_id}");
  2939. break;
  2940. }
  2941. case COMMAND_LOOT_REMOVEITEM:{
  2942. Spawn* spawn = cmdTarget;
  2943. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2944. Item* item = spawn->LootItem(atoul(sep->arg[0]));
  2945. lua_interface->SetLuaUserDataStale(item);
  2946. safe_delete(item);
  2947. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully removed item.");
  2948. }
  2949. else
  2950. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot removeitem {item_id}");
  2951. break;
  2952. }
  2953. case COMMAND_LOOT_CORPSE:
  2954. case COMMAND_DISARM:
  2955. case COMMAND_LOOT:{
  2956. if (cmdTarget && ((Entity*)cmdTarget)->IsNPC() && cmdTarget->Alive())
  2957. {
  2958. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is not dead.");
  2959. break;
  2960. }
  2961. if(cmdTarget && cmdTarget->IsEntity()){
  2962. if (cmdTarget->GetDistance(client->GetPlayer()) <= rule_manager.GetGlobalRule(R_Loot, LootRadius)->GetFloat()){
  2963. if (!rule_manager.GetGlobalRule(R_Loot, AutoDisarmChest)->GetBool() && command->handler == COMMAND_DISARM )
  2964. client->OpenChest(cmdTarget, true);
  2965. else
  2966. client->LootSpawnRequest(cmdTarget, rule_manager.GetGlobalRule(R_Loot, AutoDisarmChest)->GetBool());
  2967. if (!(cmdTarget)->HasLoot()){
  2968. if (((Entity*)cmdTarget)->IsNPC())
  2969. client->GetCurrentZone()->RemoveDeadSpawn(cmdTarget);
  2970. }
  2971. }
  2972. else
  2973. client->Message(CHANNEL_COLOR_YELLOW, "You are too far away to interact with that");
  2974. }
  2975. else if(!cmdTarget || cmdTarget->GetHP() > 0)
  2976. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid target.");
  2977. break;
  2978. }
  2979. case COMMAND_RELOADSPAWNSCRIPTS:{
  2980. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spawn Scripts....");
  2981. if (lua_interface)
  2982. lua_interface->SetLuaSystemReloading(true);
  2983. world.ResetSpawnScripts();
  2984. database.LoadSpawnScriptData();
  2985. if(lua_interface) {
  2986. lua_interface->DestroySpawnScripts();
  2987. lua_interface->SetLuaSystemReloading(false);
  2988. }
  2989. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Success!");
  2990. break;
  2991. }
  2992. case COMMAND_RELOADREGIONSCRIPTS:{
  2993. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Region Scripts....");
  2994. if(lua_interface) {
  2995. lua_interface->DestroyRegionScripts();
  2996. }
  2997. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Success!");
  2998. break;
  2999. }
  3000. case COMMAND_RELOADLUASYSTEM:{
  3001. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Attempting to reload entire LUA system....");
  3002. world.SetReloadingSubsystem("LuaSystem");
  3003. if(lua_interface) {
  3004. lua_interface->SetLuaSystemReloading(true);
  3005. }
  3006. zone_list.DeleteSpellProcess();
  3007. if (lua_interface)
  3008. lua_interface->DestroySpells();
  3009. master_spell_list.Reload();
  3010. zone_list.LoadSpellProcess();
  3011. if(lua_interface){
  3012. map<Client*, int32> debug_clients = lua_interface->GetDebugClients();
  3013. map<Client*, int32>::iterator itr;
  3014. for(itr = debug_clients.begin(); itr != debug_clients.end(); itr++){
  3015. if(lua_interface)
  3016. lua_interface->UpdateDebugClients(itr->first);
  3017. }
  3018. }
  3019. world.ResetSpawnScripts();
  3020. database.LoadSpawnScriptData();
  3021. world.ResetZoneScripts();
  3022. database.LoadZoneScriptData();
  3023. if(lua_interface) {
  3024. lua_interface->DestroySpawnScripts();
  3025. lua_interface->DestroyRegionScripts();
  3026. lua_interface->DestroyQuests();
  3027. lua_interface->DestroyItemScripts();
  3028. lua_interface->DestroyZoneScripts();
  3029. }
  3030. int32 quest_count = database.LoadQuests();
  3031. int32 spell_count = 0;
  3032. if(lua_interface) {
  3033. spell_count = database.LoadSpellScriptData();
  3034. lua_interface->SetLuaSystemReloading(false);
  3035. }
  3036. world.RemoveReloadingSubSystem("LuaSystem");
  3037. client->Message(CHANNEL_COLOR_YELLOW, "Successfully loaded %u spell(s), %u quest(s).", spell_count, quest_count);
  3038. break;
  3039. }
  3040. case COMMAND_DECLINE_QUEST:{
  3041. int32 quest_id = 0;
  3042. if(sep && sep->arg[0] && sep->IsNumber(0))
  3043. quest_id = atoul(sep->arg[0]);
  3044. if(quest_id > 0){
  3045. client->RemovePendingQuest(quest_id);
  3046. }
  3047. break;
  3048. }
  3049. case COMMAND_DELETE_QUEST:{
  3050. int32 quest_id = 0;
  3051. if(sep && sep->arg[0] && sep->IsNumber(0))
  3052. quest_id = atoul(sep->arg[0]);
  3053. if(quest_id > 0){
  3054. client->GetPlayer()->MPlayerQuests.readlock(__FUNCTION__, __LINE__);
  3055. if(lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0) {
  3056. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  3057. client->GetPlayer()->MPlayerQuests.releasereadlock(__FUNCTION__, __LINE__);
  3058. if (quest && quest->CanDeleteQuest()) {
  3059. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  3060. client->RemovePlayerQuest(quest_id);
  3061. client->GetCurrentZone()->SendQuestUpdates(client);
  3062. }
  3063. }
  3064. else {
  3065. client->GetPlayer()->MPlayerQuests.releasereadlock(__FUNCTION__, __LINE__);
  3066. }
  3067. }
  3068. break;
  3069. }
  3070. case COMMAND_ACCEPT_QUEST:{
  3071. int32 quest_id = 0;
  3072. if(sep && sep->arg[0] && sep->IsNumber(0))
  3073. quest_id = atoul(sep->arg[0]);
  3074. if(quest_id > 0){
  3075. client->AcceptQuest(quest_id);
  3076. }
  3077. break;
  3078. }
  3079. case COMMAND_NAME:{
  3080. if(sep && sep->arg[ndx][0]){
  3081. client->GetPlayer()->GetInfoStruct()->set_name(std::string(sep->arg[ndx]).substr(0,39));
  3082. client->GetPlayer()->SetCharSheetChanged(true);
  3083. }else
  3084. client->Message(CHANNEL_COLOR_YELLOW,"Usage: /name {new_name}");
  3085. break;
  3086. }
  3087. case COMMAND_GROUP: {
  3088. if(sep && sep->arg[0])
  3089. printf("Group: %s\n",sep->argplus[0]);
  3090. break;
  3091. }
  3092. case COMMAND_GROUPSAY:{
  3093. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  3094. if(sep && sep->arg[0] && gmi)
  3095. world.GetGroupManager()->GroupChatMessage(gmi->group_id, client->GetPlayer(), client->GetPlayer()->GetCurrentLanguage(), sep->argplus[0]);
  3096. break;
  3097. }
  3098. case COMMAND_GROUPINVITE: {
  3099. Entity* target = 0;
  3100. Client* target_client = 0;
  3101. if (client->GetPlayer()->GetGroupMemberInfo() && !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  3102. client->SimpleMessage(CHANNEL_COMMANDS, "You must be the group leader to invite.");
  3103. return;
  3104. }
  3105. // name provided with command so it has to be a player, npc not supported here
  3106. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0){
  3107. target_client = zone_list.GetClientByCharName(sep->arg[0]);
  3108. if (target_client) {
  3109. if (!target_client->IsConnected() || !target_client->IsReadyForSpawns())
  3110. target = 0;
  3111. else
  3112. target = target_client->GetPlayer();
  3113. }
  3114. }
  3115. // if name was not provided use the players target, npc or player supported here
  3116. if (!target && client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  3117. target = (Entity*)client->GetPlayer()->GetTarget();
  3118. if (target->IsPlayer()) {
  3119. target_client = ((Player*)target)->GetClient();
  3120. }
  3121. }
  3122. int8 result = world.GetGroupManager()->Invite(client->GetPlayer(), target);
  3123. if (result == 0) {
  3124. client->Message(CHANNEL_COMMANDS, "You invite %s to group with you.", target->GetName());
  3125. if (target_client) {
  3126. PacketStruct* packet = configReader.getStruct("WS_ReceiveOffer", target_client->GetVersion());
  3127. if (packet) {
  3128. packet->setDataByName("type", 1);
  3129. packet->setDataByName("name", client->GetPlayer()->GetName());
  3130. packet->setDataByName("unknown2", 1);
  3131. target_client->QueuePacket(packet->serialize());
  3132. safe_delete(packet);
  3133. }
  3134. }
  3135. }
  3136. else if (result == 1)
  3137. client->SimpleMessage(CHANNEL_COMMANDS, "That player is already in a group.");
  3138. else if (result == 2)
  3139. client->SimpleMessage(CHANNEL_COMMANDS, "That player has been invited to another group.");
  3140. else if (result == 3)
  3141. client->SimpleMessage(CHANNEL_COMMANDS, "Your group is already full.");
  3142. else if (result == 4)
  3143. client->SimpleMessage(CHANNEL_COMMANDS, "You have a pending invitation, cancel it first.");
  3144. else if (result == 5)
  3145. client->SimpleMessage(CHANNEL_COMMANDS, "You cannot invite yourself!");
  3146. else if (result == 6)
  3147. client->SimpleMessage(CHANNEL_COMMANDS, "Could not locate the player.");
  3148. else
  3149. client->SimpleMessage(CHANNEL_COMMANDS, "Group invite failed, unknown error!");
  3150. break;
  3151. }
  3152. case COMMAND_GROUPDISBAND: {
  3153. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  3154. if (gmi) { // TODO: Leader check
  3155. // world.GetGroupManager()->SimpleGroupMessage(gmi->group_id, "Your group has been disbanded.");
  3156. world.GetGroupManager()->RemoveGroup(gmi->group_id);
  3157. }
  3158. break;
  3159. }
  3160. case COMMAND_GROUP_LEAVE: {
  3161. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  3162. if (gmi) {
  3163. int32 group_id = gmi->group_id;
  3164. world.GetGroupManager()->RemoveGroupMember(group_id, client->GetPlayer());
  3165. if (!world.GetGroupManager()->IsGroupIDValid(group_id)) {
  3166. // leader->Message(CHANNEL_COLOR_GROUP, "%s has left the group.", client->GetPlayer()->GetName());
  3167. }
  3168. else {
  3169. world.GetGroupManager()->GroupMessage(group_id, "%s has left the group.", client->GetPlayer()->GetName());
  3170. }
  3171. client->SimpleMessage(CHANNEL_GROUP_CHAT, "You have left the group");
  3172. }
  3173. break;
  3174. }
  3175. case COMMAND_FRIEND_ADD:{
  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. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  3183. if(client->GetPlayer()->IsIgnored(name.c_str())){
  3184. client->GetPlayer()->RemoveIgnore(name.c_str());
  3185. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  3186. client->SendChatRelationship(3, name.c_str());
  3187. }
  3188. client->GetPlayer()->AddFriend(name.c_str(), true);
  3189. client->SendChatRelationship(0, name.c_str());
  3190. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added friend: %s", name.c_str());
  3191. if(zone_list.GetClientByCharName(name))
  3192. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Friend: %s has logged in.", name.c_str());
  3193. }
  3194. else
  3195. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot be more friendly towards yourself!");
  3196. }
  3197. else
  3198. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  3199. break;
  3200. }
  3201. case COMMAND_FRIEND_REMOVE:{
  3202. string name = "";
  3203. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  3204. name = database.GetPlayerName(sep->arg[0]);
  3205. else if(cmdTarget && cmdTarget->IsPlayer())
  3206. name = string(cmdTarget->GetName());
  3207. if(name.length() > 0){
  3208. client->GetPlayer()->RemoveFriend(name.c_str());
  3209. client->SendChatRelationship(1, name.c_str());
  3210. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  3211. }
  3212. else
  3213. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  3214. break;
  3215. }
  3216. case COMMAND_FRIENDS:{
  3217. break;
  3218. }
  3219. case COMMAND_IGNORE_ADD:{
  3220. string name = "";
  3221. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  3222. name = database.GetPlayerName(sep->arg[0]);
  3223. else if(cmdTarget && cmdTarget->IsPlayer())
  3224. name = string(cmdTarget->GetName());
  3225. if(name.length() > 0){
  3226. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  3227. if(client->GetPlayer()->IsFriend(name.c_str())){
  3228. client->GetPlayer()->RemoveFriend(name.c_str());
  3229. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  3230. client->SendChatRelationship(1, name.c_str());
  3231. }
  3232. client->GetPlayer()->AddIgnore(name.c_str(), true);
  3233. client->SendChatRelationship(2, name.c_str());
  3234. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added ignore: %s", name.c_str());
  3235. }
  3236. else
  3237. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot ignore yourself!");
  3238. }
  3239. else
  3240. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  3241. break;
  3242. }
  3243. case COMMAND_IGNORE_REMOVE:{
  3244. string name = "";
  3245. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  3246. name = database.GetPlayerName(sep->arg[0]);
  3247. else if(cmdTarget && cmdTarget->IsPlayer())
  3248. name = string(cmdTarget->GetName());
  3249. if(name.length() > 0){
  3250. client->GetPlayer()->RemoveIgnore(name.c_str());
  3251. client->SendChatRelationship(3, name.c_str());
  3252. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  3253. }
  3254. break;
  3255. }
  3256. case COMMAND_IGNORES:{
  3257. break;
  3258. }
  3259. case COMMAND_GROUP_KICK:{
  3260. Entity* kicked = 0;
  3261. Client* kicked_client = 0;
  3262. int32 group_id = 0;
  3263. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader)
  3264. return;
  3265. if (sep && sep->arg[0]) {
  3266. kicked_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  3267. if (kicked_client)
  3268. kicked = kicked_client->GetPlayer();
  3269. }
  3270. else if (cmdTarget && cmdTarget->IsEntity()) {
  3271. kicked = (Entity*)cmdTarget;
  3272. }
  3273. group_id = client->GetPlayer()->GetGroupMemberInfo()->group_id;
  3274. bool send_kicked_message = world.GetGroupManager()->GetGroupSize(group_id) > 2;
  3275. if (kicked)
  3276. world.GetGroupManager()->RemoveGroupMember(group_id, kicked);
  3277. if(send_kicked_message)
  3278. world.GetGroupManager()->GroupMessage(group_id, "%s was kicked from the group.", kicked->GetName());
  3279. else
  3280. client->Message(CHANNEL_GROUP_CHAT, "You kicked %s from the group", kicked->GetName());
  3281. if (kicked_client)
  3282. kicked_client->SimpleMessage(CHANNEL_GROUP_CHAT, "You were kicked from the group");
  3283. break;
  3284. }
  3285. case COMMAND_GROUP_MAKE_LEADER:{
  3286. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  3287. client->SimpleMessage(CHANNEL_COMMANDS, "You are not a group leader.");
  3288. return;
  3289. }
  3290. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 1) {
  3291. Client* new_leader = zone_list.GetClientByCharName(sep->arg[0]);
  3292. if (new_leader && new_leader->GetPlayer()->GetGroupMemberInfo() && new_leader->GetPlayer()->GetGroupMemberInfo()->group_id == client->GetPlayer()->GetGroupMemberInfo()->group_id) {
  3293. if (client->GetPlayer()->IsGroupMember(new_leader->GetPlayer())) {
  3294. if(world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, new_leader->GetPlayer())) {
  3295. world.GetGroupManager()->GroupMessage(client->GetPlayer()->GetGroupMemberInfo()->group_id, "%s is now leader of the group.", new_leader->GetPlayer()->GetName());
  3296. }
  3297. }
  3298. }
  3299. else
  3300. client->SimpleMessage(CHANNEL_COMMANDS, "Unable to find the given player.");
  3301. }
  3302. else if (cmdTarget && cmdTarget->IsPlayer() && ((Player*)cmdTarget)->GetGroupMemberInfo() && ((Player*)cmdTarget)->GetGroupMemberInfo()->group_id == client->GetPlayer()->GetGroupMemberInfo()->group_id) {
  3303. if(client->GetPlayer()->IsGroupMember((Player*)cmdTarget) && world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, (Entity*)cmdTarget)) {
  3304. world.GetGroupManager()->GroupMessage(client->GetPlayer()->GetGroupMemberInfo()->group_id, "%s is now leader of the group.", cmdTarget->GetName());
  3305. }
  3306. }
  3307. else
  3308. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to change group leader.");
  3309. break;
  3310. }
  3311. case COMMAND_GROUP_ACCEPT_INVITE: {
  3312. if((sep && sep->arg[0] && strcmp(sep->arg[0], "group") == 0) || (!sep && client->GetVersion() <= 561)) {
  3313. int8 result = world.GetGroupManager()->AcceptInvite(client->GetPlayer());
  3314. if (result == 0)
  3315. client->SimpleMessage(CHANNEL_GROUP_CHAT, "You have joined the group.");
  3316. else if (result == 1)
  3317. client->SimpleMessage(CHANNEL_GROUP_CHAT, "You do not have a pending invite.");
  3318. else if (result == 2)
  3319. client->SimpleMessage(CHANNEL_GROUP_CHAT, "Unable to join group - could not find leader.");
  3320. else
  3321. client->SimpleMessage(CHANNEL_GROUP_CHAT, "Unable to join group - unknown error.");
  3322. }
  3323. break;
  3324. }
  3325. case COMMAND_GROUP_DECLINE_INVITE: {
  3326. if(sep && sep->arg[0] && strcmp(sep->arg[0], "group") == 0) {
  3327. world.GetGroupManager()->DeclineInvite(client->GetPlayer()); // TODO: Add message to leader
  3328. }
  3329. break;
  3330. }
  3331. case COMMAND_SUMMON:{
  3332. char* search_name = 0;
  3333. if(sep && sep->arg[0][0])
  3334. search_name = sep->arg[0];
  3335. if(!search_name && !cmdTarget){
  3336. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /summon [name]");
  3337. 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.");
  3338. }
  3339. else{
  3340. if(!client->Summon(search_name))
  3341. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  3342. }
  3343. break;
  3344. }
  3345. case COMMAND_GOTO:{
  3346. const char* search_name = 0;
  3347. if(sep && sep->arg[0][0])
  3348. search_name = sep->argplus[0];
  3349. if(!search_name && !cmdTarget){
  3350. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /goto [name]");
  3351. 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.");
  3352. }
  3353. else{
  3354. if(!client->GotoSpawn(search_name))
  3355. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  3356. }
  3357. break;
  3358. }
  3359. case COMMAND_MOVE:{
  3360. bool success = false;
  3361. try{
  3362. if(sep && sep->arg[2][0] && sep->IsNumber(0) && sep->IsNumber(1) && sep->IsNumber(2)){
  3363. EQ2Packet* app = client->GetPlayer()->Move(atof(sep->arg[0]), atof(sep->arg[1]), atof(sep->arg[2]), client->GetVersion());
  3364. if(app){
  3365. client->QueuePacket(app);
  3366. success = true;
  3367. }
  3368. }
  3369. }
  3370. catch(...){}
  3371. if(!success){
  3372. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /move x y z");
  3373. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Moves the client to the given coordinates.");
  3374. }
  3375. break;
  3376. }
  3377. case COMMAND_SETTIME:{
  3378. if(sep && sep->arg[0]){
  3379. world.MWorldTime.writelock(__FUNCTION__, __LINE__);
  3380. sscanf (sep->arg[0], "%d:%d", &world.GetWorldTimeStruct()->hour, &world.GetWorldTimeStruct()->minute);
  3381. if(sep->arg[1] && sep->IsNumber(1))
  3382. world.GetWorldTimeStruct()->month = atoi(sep->arg[1]) - 1; //zero based indexes
  3383. if(sep->arg[2] && sep->IsNumber(2))
  3384. world.GetWorldTimeStruct()->day = atoi(sep->arg[2]) - 1; //zero based indexes
  3385. if(sep->arg[3] && sep->IsNumber(3))
  3386. world.GetWorldTimeStruct()->year = atoi(sep->arg[3]);
  3387. world.MWorldTime.releasewritelock(__FUNCTION__, __LINE__);
  3388. client->GetCurrentZone()->SendTimeUpdateToAllClients();
  3389. }
  3390. else{
  3391. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /settime [hour:minute] (month) (day) (year)");
  3392. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Example: /settime 8:30");
  3393. }
  3394. break;
  3395. }
  3396. case COMMAND_VERSION:{
  3397. client->Message(CHANNEL_COLOR_YELLOW,"%s %s", EQ2EMU_MODULE, CURRENT_VERSION);
  3398. client->Message(CHANNEL_COLOR_YELLOW,"Last Compiled on %s %s", COMPILE_DATE, COMPILE_TIME);
  3399. auto [days, hours, minutes, seconds] = convertTimestampDuration((getCurrentTimestamp() - world.world_uptime));
  3400. client->Message(CHANNEL_COLOR_YELLOW,"Uptime %u day(s), %u hour(s), %u minute(s), %u second(s).", days, hours, minutes, seconds);
  3401. break;
  3402. }
  3403. case COMMAND_ZONE:{
  3404. int32 instanceID = 0;
  3405. string zone;
  3406. int32 zone_id = 0;
  3407. bool listSearch = false;
  3408. bool isInstance = false;
  3409. ZoneServer* zsZone = 0;
  3410. if(sep && sep->arg[0][0])
  3411. {
  3412. if(strncasecmp(sep->arg[0], "list", 4) == 0)
  3413. listSearch = true;
  3414. else if(strncasecmp(sep->arg[0], "active", 6) == 0)
  3415. {
  3416. zone_list.SendZoneList(client);
  3417. break;
  3418. }
  3419. else if(strncasecmp(sep->arg[0], "instance", 6) == 0)
  3420. {
  3421. if(sep->IsNumber(1))
  3422. instanceID = atol(sep->arg[1]);
  3423. }
  3424. else if(strncasecmp(sep->arg[0], "lock", 4) == 0)
  3425. {
  3426. PrintSep(sep, "ZONE LOCK");
  3427. if(sep->IsNumber(1))
  3428. zsZone = zone_list.Get(atoul(sep->arg[1]), false, false, false);
  3429. else
  3430. zsZone = zone_list.Get(sep->arg[1], false, false, false);
  3431. if( zsZone )
  3432. {
  3433. zsZone->SetZoneLockState(true);
  3434. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now locked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  3435. }
  3436. else
  3437. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be locked.", sep->arg[1]);
  3438. break;
  3439. }
  3440. else if(strncasecmp(sep->arg[0], "unlock", 6) == 0)
  3441. {
  3442. PrintSep(sep, "ZONE UNLOCK");
  3443. if(sep->IsNumber(1))
  3444. zsZone = zone_list.Get(atoul(sep->arg[1]), false, false, false);
  3445. else
  3446. zsZone = zone_list.Get(sep->arg[1], false, false, false);
  3447. if( zsZone )
  3448. {
  3449. zsZone->SetZoneLockState(false);
  3450. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now unlocked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  3451. }
  3452. else
  3453. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be unlocked.", sep->arg[1]);
  3454. break;
  3455. }
  3456. else
  3457. {
  3458. if(sep->IsNumber(0))
  3459. {
  3460. zone_id = atoul(sep->arg[0]);
  3461. string zonename = database.GetZoneName(zone_id);
  3462. if(zonename.length() > 0)
  3463. zone = zonename;
  3464. }
  3465. else
  3466. zone = sep->arg[0];
  3467. }
  3468. if(instanceID > 0)
  3469. {
  3470. ZoneServer* zsInstance = zone_list.GetByInstanceID(instanceID);
  3471. if(zsInstance != NULL)
  3472. {
  3473. instanceID = zsInstance->GetInstanceID();
  3474. zone = zsInstance->GetZoneName();
  3475. zone_id = zsInstance->GetZoneID();
  3476. isInstance = true;
  3477. }
  3478. }
  3479. }
  3480. if(!listSearch)
  3481. {
  3482. if(zone.length() == 0)
  3483. client->Message(CHANNEL_COLOR_RED, "Error: Invalid Zone");
  3484. else if(instanceID != client->GetCurrentZone()->GetInstanceID() ||
  3485. zone_id != client->GetCurrentZone()->GetZoneID())
  3486. {
  3487. const char* zonestr = zone.c_str();
  3488. if(database.VerifyZone(zonestr))
  3489. {
  3490. if(client->CheckZoneAccess(zonestr))
  3491. {
  3492. client->Message(CHANNEL_COLOR_YELLOW,"Zoning to %s...", zonestr);
  3493. if(isInstance)
  3494. client->Zone(instanceID,true,true,false);
  3495. else
  3496. client->Zone(zonestr);
  3497. }
  3498. }
  3499. else
  3500. client->Message(CHANNEL_COLOR_RED, "Error: Zone '%s' not found. To get a list type /zone list", zonestr);
  3501. }
  3502. else
  3503. client->Message(CHANNEL_COLOR_RED, "Error: You are already in that zone!");
  3504. }
  3505. else
  3506. {
  3507. const char* name = 0;
  3508. if(sep && sep->arg[1][0])
  3509. {
  3510. map<int32, string>* zone_names;
  3511. name = sep->argplus[1];
  3512. sint16 status = client->GetAdminStatus();
  3513. if( status > 0 )
  3514. {
  3515. client->SimpleMessage(CHANNEL_COLOR_RED, "ADMIN MODE");
  3516. zone_names = database.GetZoneList(name, true);
  3517. }
  3518. else
  3519. zone_names = database.GetZoneList(name);
  3520. if(!zone_names)
  3521. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No zones found.");
  3522. else
  3523. {
  3524. map<int32, string>::iterator itr;
  3525. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  3526. for(itr = zone_names->begin(); itr != zone_names->end(); itr++)
  3527. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  3528. safe_delete(zone_names);
  3529. }
  3530. }
  3531. else
  3532. {
  3533. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone [zone name]");
  3534. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone list [partial zone name]");
  3535. }
  3536. }
  3537. break;
  3538. }
  3539. case COMMAND_USE: {
  3540. Spawn* target = cmdTarget;
  3541. if (target && target->IsWidget())
  3542. ((Widget*)target)->HandleUse(client, "use");
  3543. break;
  3544. }
  3545. case COMMAND_OPEN: {
  3546. Spawn* target = cmdTarget;
  3547. if (target && target->IsWidget())
  3548. ((Widget*)target)->HandleUse(client, "Open", WIDGET_TYPE_DOOR);
  3549. break;
  3550. }
  3551. case COMMAND_CASTSPELL: {
  3552. if (sep && sep->arg[0] && sep->IsNumber(0))
  3553. {
  3554. int8 tier = 1;
  3555. if (sep->arg[1] && sep->IsNumber(1))
  3556. tier = atoul(sep->arg[1]);
  3557. int8 self = 1;
  3558. if (sep->arg[1] && sep->IsNumber(2))
  3559. {
  3560. self = atoul(sep->arg[2]);
  3561. if(self != 1 && !cmdTarget->IsEntity())
  3562. {
  3563. client->Message(CHANNEL_COLOR_RED, "Target is not an entity required to cast non-self spell.");
  3564. self = 1;
  3565. }
  3566. }
  3567. int32 spellid = atoul(sep->arg[0]);
  3568. Spell* spell = master_spell_list.GetSpell(spellid, tier);
  3569. if (spell)
  3570. {
  3571. client->Message(CHANNEL_COLOR_RED, "Casting spell %u.", spellid);
  3572. SpellProcess* spellProcess = 0;
  3573. // Get the current zones spell process
  3574. spellProcess = client->GetCurrentZone()->GetSpellProcess();
  3575. spellProcess->CastInstant(spell, (!cmdTarget || self == 1) ? (Entity*)client->GetPlayer() : (Entity*)cmdTarget, (cmdTarget && cmdTarget->IsEntity()) ? (Entity*)cmdTarget : (Entity*)client->GetPlayer());
  3576. }
  3577. else
  3578. {
  3579. client->Message(CHANNEL_COLOR_RED, "Could not find spell %u.",spellid);
  3580. }
  3581. }
  3582. else if (sep && sep->arg[0])
  3583. {
  3584. database.FindSpell(client, (char*)sep->argplus[0]);
  3585. }
  3586. else
  3587. {
  3588. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellid] (tier=1) - Cast Spell with specified spell id, tier is optional, default of 1.");
  3589. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellname] - Find spells wildcard match with a partial spell name");
  3590. }
  3591. break;
  3592. }
  3593. case COMMAND_KNOWLEDGEWINDOWSORT: {
  3594. if (sep && (client->GetVersion() <= 561 && sep->GetArgNumber() == 3) || sep->GetArgNumber() == 4)
  3595. {
  3596. int32 book = atoul(sep->arg[0]); // 0 - spells, 1 - combat, 2 - abilities, 3 - tradeskill
  3597. // cannot sort the ability book in this client it is greyed out
  3598. if (client->GetVersion() <= 561 && book == SPELL_BOOK_TYPE_ABILITY)
  3599. break;
  3600. int32 sort_by = atoul(sep->arg[1]); // 0 - alpha, 1 - level, 2 - category
  3601. int32 order = atoul(sep->arg[2]); // 0 - ascending, 1 - descending
  3602. int32 pattern = atoul(sep->arg[3]); // 0 - zigzag, 1 - down, 2 - across
  3603. int32 maxlvlonly = 0;
  3604. if(client->GetVersion() > 561 && sep->arg[4][0]) {
  3605. maxlvlonly = atoul(sep->arg[4]); // checkbox for newer clients
  3606. }
  3607. client->GetPlayer()->ResortSpellBook(sort_by, order, pattern, maxlvlonly, book);
  3608. ClientPacketFunctions::SendSkillSlotMappings(client);
  3609. }
  3610. else
  3611. {
  3612. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /knowledgewindow_sort [book] [sort_by] [order] [pattern]");
  3613. }
  3614. break;
  3615. }
  3616. case COMMAND_MOVE_ITEM:
  3617. {
  3618. int32 id = 0;
  3619. if (sep && sep->IsNumber(0))
  3620. id = atoul(sep->arg[0]);
  3621. Spawn* spawn = 0;
  3622. if (id == 0)
  3623. {
  3624. spawn = cmdTarget;
  3625. }
  3626. else
  3627. spawn = client->GetCurrentZone()->GetSpawnFromUniqueItemID(id);
  3628. if (!spawn || !client->HasOwnerOrEditAccess() || !spawn->GetPickupItemID())
  3629. break;
  3630. client->SendMoveObjectMode(spawn, 0);
  3631. break;
  3632. }
  3633. case COMMAND_PICKUP:
  3634. {
  3635. int32 id = 0;
  3636. if (sep && sep->IsNumber(0))
  3637. id = atoul(sep->arg[0]);
  3638. Spawn* spawn = 0;
  3639. if (id == 0)
  3640. {
  3641. spawn = cmdTarget;
  3642. }
  3643. else
  3644. spawn = client->GetCurrentZone()->GetSpawnFromUniqueItemID(id);
  3645. if (!spawn || !client->HasOwnerOrEditAccess() || !spawn->GetPickupItemID())
  3646. break;
  3647. if(client->AddItem(spawn->GetPickupItemID(), 1)) {
  3648. Query query;
  3649. 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());
  3650. if (database.RemoveSpawnFromSpawnLocation(spawn)) {
  3651. client->GetCurrentZone()->RemoveSpawn(spawn, true, true, true, true, true);
  3652. }
  3653. // we had a UI Window displayed, update the house items
  3654. if ( id > 0 )
  3655. client->GetCurrentZone()->SendHouseItems(client);
  3656. }
  3657. break;
  3658. }
  3659. case COMMAND_HOUSE_DEPOSIT:
  3660. {
  3661. PrintSep(sep, "COMMAND_HOUSE_DEPOSIT");
  3662. // arg0 = spawn_id for DoF, could also be house_id for newer clients
  3663. // arg1 = coin (in copper)
  3664. // arg2 = status? (not implemented yet)
  3665. PlayerHouse* ph = nullptr;
  3666. int32 spawn_id = 0;
  3667. if(sep && sep->arg[0]) {
  3668. spawn_id = atoul(sep->arg[0]);
  3669. ph = world.GetPlayerHouse(client, spawn_id, client->GetVersion() > 561 ? spawn_id : 0, nullptr);
  3670. }
  3671. if(!ph) {
  3672. ph = world.GetPlayerHouseByInstanceID(client->GetCurrentZone()->GetInstanceID());
  3673. }
  3674. if (ph && sep && sep->IsNumber(1))
  3675. {
  3676. int64 outValCoin = strtoull(sep->arg[1], NULL, 0);
  3677. int32 outValStatus = 0;
  3678. if(sep->IsNumber(2))
  3679. {
  3680. outValStatus = strtoull(sep->arg[2], NULL, 0);
  3681. if(outValStatus > client->GetPlayer()->GetInfoStruct()->get_status_points())
  3682. outValStatus = 0; // cheat check
  3683. }
  3684. if ((!outValCoin && outValStatus) || client->GetPlayer()->RemoveCoins(outValCoin))
  3685. {
  3686. if(outValStatus)
  3687. client->GetPlayer()->GetInfoStruct()->subtract_status_points(outValStatus);
  3688. char query[256];
  3689. map<string,Deposit>::iterator itr = ph->depositsMap.find(string(client->GetPlayer()->GetName()));
  3690. if (itr != ph->depositsMap.end())
  3691. {
  3692. 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());
  3693. }
  3694. else
  3695. 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);
  3696. if (database.RunQuery(query, strnlen(query, 256)))
  3697. {
  3698. ph->escrow_coins += outValCoin;
  3699. ph->escrow_status += outValStatus;
  3700. database.UpdateHouseEscrow(ph->house_id, ph->instance_id, ph->escrow_coins, ph->escrow_status);
  3701. database.LoadDeposits(ph);
  3702. client->PlaySound("coin_cha_ching");
  3703. HouseZone* hz = world.GetHouseZone(ph->house_id);
  3704. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetVersion() <= 561 ? spawn_id : client->GetPlayer()->GetID());
  3705. }
  3706. else
  3707. {
  3708. if(outValCoin)
  3709. client->GetPlayer()->AddCoins(outValCoin);
  3710. if(outValStatus)
  3711. client->GetPlayer()->GetInfoStruct()->add_status_points(outValStatus);
  3712. client->SimpleMessage(CHANNEL_COLOR_RED, "Deposit failed!");
  3713. }
  3714. }
  3715. }
  3716. break;
  3717. }
  3718. case COMMAND_HOUSE:
  3719. {
  3720. int32 spawn_id = 0;
  3721. if (sep && sep->IsNumber(0))
  3722. {
  3723. PlayerHouse* ph = nullptr;
  3724. if(!ph && sep && sep->arg[0]) {
  3725. spawn_id = atoul(sep->arg[0]);
  3726. ph = world.GetPlayerHouse(client, spawn_id, spawn_id, nullptr);
  3727. }
  3728. HouseZone* hz = 0;
  3729. if (ph)
  3730. hz = world.GetHouseZone(ph->house_id);
  3731. // there is a arg[1] that is true/false, but not sure what it is for investigate more later
  3732. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetVersion() <= 561 ? spawn_id : client->GetPlayer()->GetID());
  3733. }
  3734. else if (client->GetCurrentZone()->GetInstanceType() != 0)
  3735. {
  3736. // inside a house or something? Send the access window
  3737. PlayerHouse* ph = world.GetPlayerHouseByInstanceID(client->GetCurrentZone()->GetInstanceID());
  3738. HouseZone* hz = 0;
  3739. if ( ph )
  3740. hz = world.GetHouseZone(ph->house_id);
  3741. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetVersion() <= 561 ? spawn_id : client->GetPlayer()->GetID());
  3742. client->GetCurrentZone()->SendHouseItems(client);
  3743. }
  3744. break;
  3745. }
  3746. case COMMAND_HOUSE_UI:
  3747. {
  3748. if (sep && sep->IsNumber(0) && client->GetCurrentZone()->GetInstanceType() == Instance_Type::NONE)
  3749. {
  3750. int32 unique_id = atoi(sep->arg[0]);
  3751. PlayerHouse* ph = world.GetPlayerHouseByUniqueID(unique_id);
  3752. HouseZone* hz = 0;
  3753. if ( ph )
  3754. hz = world.GetHouseZone(ph->house_id);
  3755. // there is a arg[1] that is true/false, but not sure what it is for investigate more later
  3756. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  3757. }
  3758. break;
  3759. }
  3760. case COMMAND_PLACE_HOUSE_ITEM: {
  3761. if (sep && sep->IsNumber(0))
  3762. {
  3763. int32 uniqueid = atoi(sep->arg[0]);
  3764. Item* item = client->GetPlayer()->item_list.GetItemFromUniqueID(uniqueid);
  3765. //Item* item = player->GetEquipmentList()->GetItem(slot);
  3766. if (item && item->IsHouseItem())
  3767. {
  3768. if (!client->HasOwnerOrEditAccess())
  3769. {
  3770. client->SimpleMessage(CHANNEL_COLOR_RED, "This is not your home!");
  3771. break;
  3772. }
  3773. else if (!item->generic_info.appearance_id)
  3774. {
  3775. 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);
  3776. break;
  3777. }
  3778. else if(item->CheckFlag2(HOUSE_LORE) && client->GetCurrentZone()->HouseItemSpawnExists(item->details.item_id)) {
  3779. client->Message(CHANNEL_COLOR_RED, "Item %s is house lore and you cannot place another.", item->name.c_str());
  3780. break;
  3781. }
  3782. if (client->GetTempPlacementSpawn())
  3783. {
  3784. Spawn* tmp = client->GetTempPlacementSpawn();
  3785. client->GetCurrentZone()->RemoveSpawn(tmp, true, true, true, true, true);
  3786. client->SetTempPlacementSpawn(nullptr);
  3787. }
  3788. Object* obj = new Object();
  3789. Spawn* spawn = (Spawn*)obj;
  3790. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3791. strcpy(spawn->appearance.name, "temp");
  3792. spawn->SetX(client->GetPlayer()->GetX());
  3793. spawn->SetY(client->GetPlayer()->GetY());
  3794. spawn->SetZ(client->GetPlayer()->GetZ());
  3795. spawn->appearance.pos.collision_radius = 32;
  3796. spawn->SetHeading(client->GetPlayer()->GetHeading());
  3797. spawn->SetSpawnOrigX(spawn->GetX());
  3798. spawn->SetSpawnOrigY(spawn->GetY());
  3799. spawn->SetSpawnOrigZ(spawn->GetZ());
  3800. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  3801. spawn->appearance.targetable = 1;
  3802. spawn->appearance.activity_status = ACTIVITY_STATUS_SOLID;
  3803. spawn->appearance.race = item && item->generic_info.appearance_id ? item->generic_info.appearance_id : 1472;
  3804. spawn->SetModelType(item && item->generic_info.appearance_id ? item->generic_info.appearance_id : 1472);
  3805. spawn->SetLocation(client->GetPlayer()->GetLocation());
  3806. spawn->SetZone(client->GetCurrentZone());
  3807. client->SetTempPlacementSpawn(spawn);
  3808. client->SetPlacementUniqueItemID(uniqueid);
  3809. client->GetCurrentZone()->AddSpawn(spawn);
  3810. }
  3811. }
  3812. break;
  3813. }
  3814. case COMMAND_GM:
  3815. {
  3816. if (sep && sep->arg[0] && sep->arg[1])
  3817. {
  3818. bool onOff = (strcmp(sep->arg[1], "on") == 0);
  3819. if (strcmp(sep->arg[0], "vision") == 0)
  3820. {
  3821. client->GetPlayer()->SetGMVision(onOff);
  3822. #if defined(__GNUC__)
  3823. database.insertCharacterProperty(client, CHAR_PROPERTY_GMVISION, (onOff) ? (char*)"1" : (char*)"0");
  3824. #else
  3825. database.insertCharacterProperty(client, CHAR_PROPERTY_GMVISION, (onOff) ? "1" : "0");
  3826. #endif
  3827. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3828. if (onOff)
  3829. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Vision Enabled!");
  3830. else
  3831. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Vision Disabled!");
  3832. }
  3833. else if (strcmp(sep->arg[0], "tag") == 0)
  3834. {
  3835. int32 value = 0;
  3836. int16 tag_icon = 0;
  3837. // groundspawn has special exception -1 argument so it needs to be handled here
  3838. if(sep->arg[2] && sep->arg[3] && ((tag_icon = atoul(sep->arg[3])) > 0) || (strncasecmp(sep->arg[1], "groundspawn", 11) == 0)) {
  3839. value = atoul(sep->arg[2]);
  3840. if(strncasecmp(sep->arg[1], "faction", 7) == 0){
  3841. if(!value) {
  3842. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid faction id.");
  3843. break;
  3844. }
  3845. if(!tag_icon) {
  3846. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid tag icon id.");
  3847. break;
  3848. }
  3849. client->GetPlayer()->AddGMVisualFilter(GMTagFilterType::GMFILTERTYPE_FACTION, value, "", tag_icon);
  3850. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3851. client->Message(CHANNEL_COLOR_RED, "Adding faction id %u with tag icon %u.", value, tag_icon);
  3852. }
  3853. else if(strncasecmp(sep->arg[1], "spawngroup", 10) == 0){
  3854. if(value>0) {
  3855. value = 1;
  3856. }
  3857. if(!tag_icon) {
  3858. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid tag icon id.");
  3859. break;
  3860. }
  3861. client->GetPlayer()->AddGMVisualFilter(GMTagFilterType::GMFILTERTYPE_SPAWNGROUP, value, "", tag_icon);
  3862. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3863. client->Message(CHANNEL_COLOR_RED, "Adding spawn group tag \"%s\" with tag icon %u.", (value == 1) ? "on" : "off", tag_icon);
  3864. }
  3865. else if(strncasecmp(sep->arg[1], "race", 4 == 0)){
  3866. if(!value) {
  3867. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid race id.");
  3868. break;
  3869. }
  3870. if(!tag_icon) {
  3871. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid tag icon id.");
  3872. break;
  3873. }
  3874. client->GetPlayer()->AddGMVisualFilter(GMTagFilterType::GMFILTERTYPE_RACE, value, "", tag_icon);
  3875. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3876. client->Message(CHANNEL_COLOR_RED, "Adding race id %u with tag icon %u.", value, tag_icon);
  3877. }
  3878. else if(strncasecmp(sep->arg[1], "groundspawn", 11) == 0){
  3879. // one less argument value field not tag_icon for this one
  3880. if(!value) {
  3881. client->SimpleMessage(CHANNEL_COLOR_RED, "Need to supply a valid tag icon id.");
  3882. break;
  3883. }
  3884. client->GetPlayer()->AddGMVisualFilter(GMTagFilterType::GMFILTERTYPE_GROUNDSPAWN, 1, "", value);
  3885. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3886. client->Message(CHANNEL_COLOR_RED, "Adding groundspawns with tag icon %u.", value);
  3887. }
  3888. }
  3889. else {
  3890. if(strncasecmp(sep->arg[1], "clear", 5) == 0){
  3891. client->GetPlayer()->ClearGMVisualFilters();
  3892. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Tags Cleared!");
  3893. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3894. }
  3895. else {
  3896. client->SimpleMessage(CHANNEL_COLOR_RED, "GM Tagging Missing Arguments:");
  3897. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/gm tag [type] [value] [visual_icon_display]");
  3898. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/gm tag clear - Clears all GM visual tags");
  3899. client->SimpleMessage(CHANNEL_COLOR_RED, "Visual Type Options:");
  3900. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "type: faction, value: faction id of spawn(s)");
  3901. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "type: spawngroup, value: 1 to show grouped, 0 to show not grouped");
  3902. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "type: race, value: race id (either against base race or race id in spawn details)");
  3903. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "type: groundspawn, value: (not used)");
  3904. client->SimpleMessage(CHANNEL_COLOR_RED, "Visual Icon Options:");
  3905. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3906. "1 = skull, 2 = shield half dark blue / half light blue, 3 = purple? star, 4 = yellow sword, 5 = red X, 6 = green flame");
  3907. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3908. "7 = Number \"1\", 8 = Number \"2\", 9 = Number \"3\", 10 = Number \"4\", 11 = Number \"5\", 12 = Number \"6\"");
  3909. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3910. "25 = shield, 26 = green plus, 27 = crossed swords, 28 = bow with arrow in it, 29 = light blue lightning bolt");
  3911. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3912. "30 = bard instrument (hard to see), 31 = writ with shield, 32 = writ with green +, 33 = writ with crossed sword");
  3913. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3914. "34 = writ with bow, 35 = writ with light blue lightning bolt, 36 = same as 30, 37 = party with crossed sword, shield and lightning bolt");
  3915. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3916. "38 = shaking hands green background, 39 = shaking hands dark green background, unlocked keylock");
  3917. client->SimpleMessage(CHANNEL_COLOR_YELLOW,
  3918. "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");
  3919. }
  3920. }
  3921. }
  3922. else if (strcmp(sep->arg[0], "regiondebug") == 0)
  3923. {
  3924. client->SetRegionDebug(onOff);
  3925. #if defined(__GNUC__)
  3926. database.insertCharacterProperty(client, CHAR_PROPERTY_REGIONDEBUG, (onOff) ? (char*)"1" : (char*)"0");
  3927. #else
  3928. database.insertCharacterProperty(client, CHAR_PROPERTY_REGIONDEBUG, (onOff) ? "1" : "0");
  3929. #endif
  3930. if (onOff)
  3931. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Region Debug Enabled!");
  3932. else
  3933. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Region Debug Disabled!");
  3934. }
  3935. else if (strcmp(sep->arg[0], "sight") == 0)
  3936. {
  3937. if(onOff && cmdTarget) {
  3938. client->SetPlayerPOVGhost(cmdTarget);
  3939. }
  3940. else
  3941. client->SetPlayerPOVGhost(nullptr);
  3942. }
  3943. else if (strcmp(sep->arg[0], "controleffects") == 0)
  3944. {
  3945. if(cmdTarget && cmdTarget->IsEntity()) {
  3946. ((Entity*)cmdTarget)->SendControlEffectDetailsToClient(client);
  3947. }
  3948. else {
  3949. client->GetPlayer()->SendControlEffectDetailsToClient(client);
  3950. }
  3951. }
  3952. else if (strcmp(sep->arg[0], "luadebug") == 0)
  3953. {
  3954. client->SetLuaDebugClient(onOff);
  3955. #if defined(__GNUC__)
  3956. database.insertCharacterProperty(client, CHAR_PROPERTY_LUADEBUG, (onOff) ? (char*)"1" : (char*)"0");
  3957. #else
  3958. database.insertCharacterProperty(client, CHAR_PROPERTY_LUADEBUG, (onOff) ? "1" : "0");
  3959. #endif
  3960. if (onOff)
  3961. {
  3962. if (lua_interface)
  3963. lua_interface->UpdateDebugClients(client);
  3964. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will now receive LUA error messages.");
  3965. }
  3966. else
  3967. {
  3968. if (lua_interface)
  3969. lua_interface->RemoveDebugClients(client);
  3970. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will no longer receive LUA error messages.");
  3971. }
  3972. }
  3973. }
  3974. break;
  3975. }
  3976. case COMMAND_ATTACK:
  3977. case COMMAND_AUTO_ATTACK:{
  3978. Command_AutoAttack(client, sep);
  3979. break;
  3980. }
  3981. case COMMAND_DEPOP:{
  3982. bool allow_respawns = false;
  3983. if(sep && sep->arg[0] && sep->IsNumber(0)){
  3984. if(atoi(sep->arg[0]) == 1)
  3985. allow_respawns = true;
  3986. }
  3987. client->GetCurrentZone()->Depop(allow_respawns);
  3988. break;
  3989. }
  3990. case COMMAND_REPOP:{
  3991. client->GetCurrentZone()->Depop(false, true);
  3992. break;
  3993. }
  3994. case COMMAND_BUYBACK:{
  3995. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  3996. // 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
  3997. int64 id = atoi64(sep->arg[0]);
  3998. // get the first int32, the item id
  3999. //int32 item_id = (int32)id;
  4000. // get the second int32, the unique id
  4001. int32 unique_id = (int32)(id>>32);
  4002. int8 quantity = atoi(sep->arg[1]);
  4003. if(quantity == 255)
  4004. quantity = 1;
  4005. client->BuyBack(unique_id, quantity);
  4006. }
  4007. break;
  4008. }
  4009. case COMMAND_MERCHANT_BUY:{
  4010. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  4011. int32 item_id = atoul(sep->arg[0]);
  4012. int8 quantity = atoi(sep->arg[1]);
  4013. client->BuyItem(item_id, quantity);
  4014. }
  4015. else
  4016. Command_SendMerchantWindow(client, sep);
  4017. break;
  4018. }
  4019. case COMMAND_MERCHANT_SELL:{
  4020. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  4021. // 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
  4022. int64 id = atoi64(sep->arg[0]);
  4023. // get the first int32, the item id
  4024. int32 item_id = (int32)id;
  4025. // get the second int32, the unique id
  4026. int32 unique_id = (int32)(id>>32);
  4027. int8 quantity = atoi(sep->arg[1]);
  4028. LogWrite(MERCHANT__DEBUG, 0, "Merchant", "Selling Item: Item Id = %ul, unique id = %ul, Quantity = %i", item_id, unique_id, quantity);
  4029. client->SellItem(item_id, quantity, unique_id);
  4030. }
  4031. break;
  4032. }
  4033. case COMMAND_MENDER_REPAIR: {
  4034. if (sep && sep->arg[0] && sep->IsNumber(0))
  4035. client->RepairItem(atoul(sep->arg[0]));
  4036. break;
  4037. }
  4038. case COMMAND_MENDER_REPAIR_ALL: {
  4039. client->RepairAllItems();
  4040. break;
  4041. }
  4042. case COMMAND_CANCEL_MERCHANT:{
  4043. client->SetMerchantTransaction(0);
  4044. break;
  4045. }
  4046. case COMMAND_START_MERCHANT:{
  4047. break;
  4048. }
  4049. case COMMAND_INVULNERABLE:{
  4050. sint8 val = -1;
  4051. if(sep && sep->arg[0] && sep->IsNumber(0)){
  4052. val = atoi(sep->arg[0]);
  4053. //devn00b: Fix for linux builds
  4054. #if defined(__GNUC__)
  4055. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? (char*) "1" : (char*) "0");
  4056. #else
  4057. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  4058. #endif
  4059. // database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  4060. client->GetPlayer()->SetInvulnerable(val==1);
  4061. if(client->GetPlayer()->GetInvulnerable())
  4062. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are now invulnerable!");
  4063. else
  4064. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are no longer invulnerable!");
  4065. }
  4066. if(val == -1)
  4067. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /invulnerable [0/1]");
  4068. break;
  4069. }
  4070. case COMMAND_REPAIR: {
  4071. Spawn* spawn = cmdTarget;
  4072. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR) {
  4073. client->SendHailCommand(spawn);
  4074. client->SetMerchantTransaction(spawn);
  4075. client->SendRepairList();
  4076. }
  4077. break;
  4078. }
  4079. case COMMAND_LOTTO: {
  4080. Spawn* spawn = cmdTarget;
  4081. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_LOTTO) {
  4082. client->SetMerchantTransaction(spawn);
  4083. client->ShowLottoWindow();
  4084. }
  4085. break;
  4086. }
  4087. case COMMAND_ACCEPT_REWARD:{
  4088. int32 unknown = 0;
  4089. int32 selectable_item_id = 0;
  4090. //Quest *quest = 0;
  4091. /* no idea what the first argument is for (faction maybe?)
  4092. if the reward has a selectable item reward, it's sent as the second argument
  4093. if neither of these are included in the reward, there is no sep
  4094. 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
  4095. only 1 quest or collection reward may be displayed at a time */
  4096. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  4097. unknown = atoul(sep->arg[0]);
  4098. selectable_item_id = atoul(sep->arg[1]);
  4099. }
  4100. /* 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
  4101. ** Otherwise it will likely be a DoF client scenario (pending item rewards, selectable item rewards) which is specifying an item id
  4102. ** 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
  4103. */
  4104. int32 item_id = 0;
  4105. if(sep && sep->arg[0][0] && sep->IsNumber(0))
  4106. item_id = atoul(sep->arg[0]);
  4107. bool collectedItems = client->GetPlayer()->AcceptQuestReward(item_id, selectable_item_id);
  4108. if (collectedItems) {
  4109. EQ2Packet* outapp = client->GetPlayer()->SendInventoryUpdate(client->GetVersion());
  4110. if (outapp)
  4111. client->QueuePacket(outapp);
  4112. }
  4113. else
  4114. LogWrite(COMMAND__ERROR, 0, "Command", "Error in COMMAND_ACCEPT_REWARD. No pending quest or collection reward was found (unknown=%u).", unknown);
  4115. break;
  4116. }
  4117. case COMMAND_BUY_FROM_BROKER:{
  4118. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  4119. int32 item_id = atoul(sep->arg[0]);
  4120. int16 quantity = atoul(sep->arg[1]);
  4121. Item* item = master_item_list.GetItem(item_id);
  4122. if(item && item->generic_info.max_charges > 1)
  4123. quantity = item->generic_info.max_charges;
  4124. client->AddItem(item_id, quantity, AddItemType::BUY_FROM_BROKER);
  4125. }
  4126. break;
  4127. }
  4128. case COMMAND_SEARCH_STORES_PAGE:{
  4129. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  4130. int32 page = atoul(sep->arg[0]);
  4131. client->SearchStore(page);
  4132. }
  4133. break;
  4134. }
  4135. case COMMAND_SEARCH_STORES:{
  4136. if(sep && sep->arg[0][0]){
  4137. const char* values = sep->argplus[0];
  4138. if(values){
  4139. LogWrite(ITEM__WARNING, 0, "Item", "SearchStores: %s", values);
  4140. map<string, string> str_values = TranslateBrokerRequest(values);
  4141. vector<Item*>* items = master_item_list.GetItems(str_values, client);
  4142. if(items){
  4143. client->SetItemSearch(items);
  4144. client->SearchStore(0);
  4145. }
  4146. }
  4147. }
  4148. break;
  4149. }
  4150. case COMMAND_LUADEBUG:{
  4151. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "start") == 0){
  4152. client->SetLuaDebugClient(true);
  4153. if(lua_interface)
  4154. lua_interface->UpdateDebugClients(client);
  4155. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will now receive LUA error messages.");
  4156. }
  4157. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "stop") == 0){
  4158. client->SetLuaDebugClient(false);
  4159. if(lua_interface)
  4160. lua_interface->RemoveDebugClients(client);
  4161. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will no longer receive LUA error messages.");
  4162. }
  4163. else{
  4164. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /luadebug {start | stop}");
  4165. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will allow you to receive lua debug messages normally seen only in the console.");
  4166. }
  4167. break;
  4168. }
  4169. case COMMAND_SPAWN_GROUP:
  4170. {
  4171. Spawn* target = cmdTarget;
  4172. if(target && target->IsPlayer() == false)
  4173. {
  4174. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "create") == 0)
  4175. {
  4176. if(target->GetSpawnLocationPlacementID() > 0)
  4177. {
  4178. if(sep->arg[1] && !sep->IsNumber(1) && strlen(sep->arg[1]) > 0)
  4179. {
  4180. int32 id = database.CreateSpawnGroup(target, sep->arg[1]);
  4181. if(id > 0)
  4182. client->Message(CHANNEL_COLOR_YELLOW, "Successfully created new spawn group with id: %u", id);
  4183. else
  4184. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error creating group, check console for details.");
  4185. target->SetSpawnGroupID(id);
  4186. target->AddSpawnToGroup(target);
  4187. }
  4188. else
  4189. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group create [name]");
  4190. }
  4191. else
  4192. 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.");
  4193. }
  4194. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "add") == 0)
  4195. {
  4196. if(sep->arg[1] && sep->IsNumber(1))
  4197. {
  4198. int32 group_id = atoul(sep->arg[1]);
  4199. Spawn* leader = client->GetCurrentZone()->GetSpawnGroup(group_id);
  4200. if(leader)
  4201. {
  4202. leader->AddSpawnToGroup(target);
  4203. target->SetSpawnGroupID(group_id);
  4204. if(database.SpawnGroupAddSpawn(target, group_id))
  4205. client->Message(CHANNEL_COLOR_YELLOW, "Successfully added '%s' to group id: %u", target->GetName(), group_id);
  4206. else
  4207. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error adding spawn to group, check console for details.");
  4208. }
  4209. else
  4210. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No spawns found in the current zone for that spawn group, be sure to use '/spawn group create' first!");
  4211. }
  4212. else
  4213. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group add [group id]");
  4214. }
  4215. else if(target->GetSpawnGroupID() == 0)
  4216. {
  4217. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That spawn is not in a group!");
  4218. }
  4219. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "remove") == 0)
  4220. {
  4221. int32 group_id = target->GetSpawnGroupID();
  4222. target->RemoveSpawnFromGroup();
  4223. if(database.SpawnGroupRemoveSpawn(target, group_id))
  4224. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed '%s' from group id: %u", target->GetName(), group_id);
  4225. else
  4226. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing spawn from group, check console for details.");
  4227. }
  4228. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "associate") == 0)
  4229. {
  4230. int32 group_id = target->GetSpawnGroupID();
  4231. if(sep->arg[1] && sep->IsNumber(1))
  4232. {
  4233. if(database.SpawnGroupAddAssociation(group_id, atoul(sep->arg[1])))
  4234. client->Message(CHANNEL_COLOR_YELLOW, "Successfully associated group id %u with group id %u", group_id, atoul(sep->arg[1]));
  4235. else
  4236. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error associating groups, check console for details.");
  4237. }
  4238. else
  4239. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Allows you to spawn only one associated group at once. Syntax: /spawn group associate [other group id]");
  4240. }
  4241. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "deassociate") == 0)
  4242. {
  4243. int32 group_id = target->GetSpawnGroupID();
  4244. if(sep->arg[1] && sep->IsNumber(1))
  4245. {
  4246. if(database.SpawnGroupRemoveAssociation(group_id, atoul(sep->arg[1])))
  4247. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed association between group id %u and group id %u", group_id, atoul(sep->arg[1]));
  4248. else
  4249. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing group associations, check console for details.");
  4250. }
  4251. else
  4252. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Removes previous group associations. Syntax: /spawn group deassociate [other group id]");
  4253. }
  4254. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "chance") == 0)
  4255. {
  4256. if(sep->arg[1] && sep->IsNumber(1))
  4257. {
  4258. if(database.SetGroupSpawnChance(target->GetSpawnGroupID(), atof(sep->arg[1])))
  4259. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set group spawn chance to %f for group id: %u", atof(sep->arg[1]), target->GetSpawnGroupID());
  4260. else
  4261. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error setting group spawn chance, check console for details.");
  4262. }
  4263. else
  4264. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group chance [group's spawn chance percentage]");
  4265. }
  4266. else
  4267. {
  4268. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command allows you to modify spawn groups.");
  4269. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group [create/add/remove/chance/associate/deassociate]");
  4270. }
  4271. }
  4272. else
  4273. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select a valid spawn to use this command.");
  4274. break;
  4275. }
  4276. case COMMAND_SPAWN_COMBINE:{
  4277. Spawn* spawn = cmdTarget;
  4278. float radius = 0;
  4279. bool failed = true;
  4280. if(spawn && !spawn->IsPlayer() && sep && sep->arg[0] && sep->arg[0][0]){
  4281. failed = false;
  4282. if(spawn->GetSpawnGroupID() > 0){
  4283. 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.");
  4284. }
  4285. else if(sep->IsNumber(0)){
  4286. radius = atof(sep->arg[0]);
  4287. client->CombineSpawns(radius, spawn);
  4288. }
  4289. else{
  4290. if(strncasecmp(sep->arg[0], "add", 3) == 0){
  4291. client->AddCombineSpawn(spawn);
  4292. }
  4293. else if(strncasecmp(sep->arg[0], "remove", 6) == 0){
  4294. client->RemoveCombineSpawn(spawn);
  4295. }
  4296. else if(strncasecmp(sep->arg[0], "save", 4) == 0){
  4297. const char* name = 0;
  4298. if(sep->arg[1] && sep->arg[1][0])
  4299. name = sep->argplus[1];
  4300. client->SaveCombineSpawns(name);
  4301. }
  4302. else
  4303. failed = true;
  4304. }
  4305. }
  4306. if(failed){
  4307. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command combines several spawns into a single spawn group.");
  4308. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn combine [radius/add/remove/save]");
  4309. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Ex: /spawn combine 1, /spawn combine save (spawn group name)");
  4310. }
  4311. break;
  4312. }
  4313. case COMMAND_SPAWN_CREATE:{
  4314. Spawn* spawn = 0;
  4315. if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "object", 6) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  4316. spawn = new Object();
  4317. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  4318. }
  4319. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "groundspawn", 11) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  4320. spawn = new GroundSpawn();
  4321. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  4322. }
  4323. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "sign", 4) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  4324. spawn = new Sign();
  4325. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  4326. }
  4327. else if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "npc", 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  4328. spawn = new NPC();
  4329. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  4330. spawn->appearance.pos.collision_radius = 32;
  4331. spawn->secondary_command_list_id = 0;
  4332. spawn->primary_command_list_id = 0;
  4333. spawn->appearance.display_name = 1;
  4334. spawn->appearance.show_level = 1;
  4335. spawn->appearance.attackable = 1;
  4336. }
  4337. else{
  4338. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn create [spawn type] [race type] [class type] [level] [name] (difficulty) (size)");
  4339. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are required except difficulty and size. Valid types are Object, NPC, Sign, or GroundSpawn");
  4340. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn create npc 203 1 50 'Lady Vox' 1 32");
  4341. break;
  4342. }
  4343. spawn->SetID(Spawn::NextID());
  4344. spawn->SetX(client->GetPlayer()->GetX());
  4345. spawn->SetY(client->GetPlayer()->GetY());
  4346. spawn->SetZ(client->GetPlayer()->GetZ());
  4347. spawn->SetHeading(client->GetPlayer()->GetHeading());
  4348. spawn->SetSpawnOrigX(spawn->GetX());
  4349. spawn->SetSpawnOrigY(spawn->GetY());
  4350. spawn->SetSpawnOrigZ(spawn->GetZ());
  4351. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  4352. if(spawn->IsSign())
  4353. {
  4354. ((Sign*)spawn)->SetSignType(SIGN_TYPE_GENERIC);
  4355. ((Sign*)spawn)->SetSignDistance(20.0f);
  4356. ((Sign*)spawn)->SetIncludeLocation(1);
  4357. ((Sign*)spawn)->SetIncludeHeading(1);
  4358. ((Sign*)spawn)->SetInitialState(1);
  4359. ((Sign*)spawn)->SetSignTitle(sep->arg[4]);
  4360. ((Sign*)spawn)->SetActivityStatus(64);
  4361. spawn->appearance.race = 0;
  4362. spawn->SetLevel(0);
  4363. spawn->SetHP(0);
  4364. spawn->SetTotalHP(0);
  4365. spawn->SetPower(0);
  4366. spawn->SetTotalPower(0);
  4367. spawn->SetDifficulty(0);
  4368. spawn->SetTargetable(0);
  4369. spawn->SetSogaModelType(0);
  4370. spawn->SetCollisionRadius(19);
  4371. ((Sign*)spawn)->SetWidgetX(client->GetPlayer()->GetX());
  4372. ((Sign*)spawn)->SetWidgetY(client->GetPlayer()->GetY());
  4373. ((Sign*)spawn)->SetWidgetZ(client->GetPlayer()->GetZ());
  4374. spawn->SetLocation(client->GetPlayer()->GetLocation());
  4375. spawn->appearance.model_type = atoul(sep->arg[1]);
  4376. }
  4377. else
  4378. {
  4379. spawn->appearance.targetable = 1;
  4380. spawn->appearance.race = 255;
  4381. spawn->SetLocation(client->GetPlayer()->GetLocation());
  4382. spawn->SetModelType(atoi(sep->arg[1]));
  4383. spawn->SetAdventureClass(atoi(sep->arg[2]));
  4384. spawn->SetLevel(atoi(sep->arg[3]));
  4385. spawn->SetName(sep->arg[4]);
  4386. if(sep->arg[5][0] && sep->IsNumber(5))
  4387. spawn->SetDifficulty(atoi(sep->arg[5]));
  4388. if(sep->arg[6][0] && sep->IsNumber(6))
  4389. spawn->size = atoi(sep->arg[6]);
  4390. if(spawn->GetTotalHP() == 0){
  4391. spawn->SetTotalHP(25*spawn->GetLevel() + 1);
  4392. spawn->SetHP(25*spawn->GetLevel() + 1);
  4393. }
  4394. if(spawn->GetTotalPower() == 0){
  4395. spawn->SetTotalPower(25*spawn->GetLevel() + 1);
  4396. spawn->SetPower(25*spawn->GetLevel() + 1);
  4397. }
  4398. }
  4399. client->GetCurrentZone()->AddSpawn(spawn);
  4400. break;
  4401. }
  4402. case COMMAND_SPAWN_EQUIPMENT:{
  4403. Spawn* spawn = cmdTarget;
  4404. if(spawn && sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1) && spawn->IsEntity()){
  4405. int8 slot = atoi(sep->arg[0]);
  4406. int16 type = atoi(sep->arg[1]);
  4407. int8 red = 0;
  4408. int8 green = 0;
  4409. int8 blue = 0;
  4410. int8 h_red = 0;
  4411. int8 h_green = 0;
  4412. int8 h_blue = 0;
  4413. if(sep->arg[2])
  4414. red = atoi(sep->arg[2]);
  4415. if(sep->arg[3])
  4416. green = atoi(sep->arg[3]);
  4417. if(sep->arg[4])
  4418. blue = atoi(sep->arg[4]);
  4419. if(sep->arg[5])
  4420. h_red = atoi(sep->arg[5]);
  4421. if(sep->arg[6])
  4422. h_green = atoi(sep->arg[6]);
  4423. if(sep->arg[7])
  4424. h_blue = atoi(sep->arg[7]);
  4425. ((Entity*)spawn)->SetEquipment(slot, type, red, green, blue, h_red, h_green, h_blue);
  4426. database.SaveNPCAppearanceEquipment(spawn->GetDatabaseID() , slot, type, red, green, blue, h_red, h_green, h_blue);
  4427. }
  4428. else{
  4429. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn equipment [slot] [appearance id] (red) (green) (blue) (highlight red) (hgreen) (hblue)");
  4430. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn's equipment. ");
  4431. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Slot is 0-24, Appearance ID from appearances table, Colors are 0-255");
  4432. }
  4433. break;
  4434. }
  4435. case COMMAND_SPAWN_DETAILS: {
  4436. Spawn* spawn = cmdTarget;
  4437. if (sep && sep->arg[0][0]) {
  4438. if (cmdTarget)
  4439. {
  4440. if (ToLower(string(sep->arg[0])) == "los")
  4441. {
  4442. bool hasLOS = client->GetPlayer()->CheckLoS(cmdTarget);
  4443. if (hasLOS)
  4444. client->Message(CHANNEL_COLOR_YELLOW, "You have line of sight with %s", spawn->GetName());
  4445. else
  4446. client->Message(CHANNEL_COLOR_RED, "You DO NOT have line of sight with %s", spawn->GetName());
  4447. break;
  4448. }
  4449. else if (ToLower(string(sep->arg[0])) == "bestz")
  4450. {
  4451. glm::vec3 targPos(cmdTarget->GetX(), cmdTarget->GetZ(), cmdTarget->GetY());
  4452. float bestZ = client->GetPlayer()->FindDestGroundZ(targPos, cmdTarget->GetYOffset());
  4453. client->Message(CHANNEL_COLOR_YELLOW, "Best Z for %s is %f", spawn->GetName(), bestZ);
  4454. break;
  4455. }
  4456. else if (ToLower(string(sep->arg[0])) == "inwater")
  4457. {
  4458. if (cmdTarget->GetRegionMap() == nullptr)
  4459. client->SimpleMessage(CHANNEL_COLOR_RED, "No water map for zone.");
  4460. else
  4461. {
  4462. bool inWater = cmdTarget->InWater();
  4463. client->Message(CHANNEL_COLOR_YELLOW, "%s is %s.", cmdTarget->GetName(), inWater ? "in water" : "out of water");
  4464. }
  4465. break;
  4466. }
  4467. else if (ToLower(string(sep->arg[0])) == "inlava")
  4468. {
  4469. if (cmdTarget->GetRegionMap() == nullptr)
  4470. client->SimpleMessage(CHANNEL_COLOR_RED, "No region map for zone.");
  4471. else
  4472. {
  4473. bool inLava = cmdTarget->InLava();
  4474. client->Message(CHANNEL_COLOR_YELLOW, "%s is %s.", cmdTarget->GetName(), inLava ? "in lava" : "out of lava");
  4475. }
  4476. break;
  4477. }
  4478. else if (ToLower(string(sep->arg[0])) == "regions")
  4479. {
  4480. glm::vec3 targPos(cmdTarget->GetX(), cmdTarget->GetY(), cmdTarget->GetZ());
  4481. if (cmdTarget->GetRegionMap() == nullptr)
  4482. client->SimpleMessage(CHANNEL_COLOR_RED, "No region map for zone.");
  4483. else
  4484. {
  4485. cmdTarget->GetRegionMap()->IdentifyRegionsInGrid(client, targPos);
  4486. }
  4487. break;
  4488. }
  4489. else if (ToLower(string(sep->arg[0])) == "behind")
  4490. {
  4491. bool isBehind = client->GetPlayer()->BehindTarget(cmdTarget);
  4492. client->Message(CHANNEL_COLOR_YELLOW, "%s %s.", isBehind ? "YOU are behind" : "YOU are NOT behind", cmdTarget->GetName());
  4493. break;
  4494. }
  4495. else if (ToLower(string(sep->arg[0])) == "infront")
  4496. {
  4497. bool isBehind = client->GetPlayer()->InFrontSpawn(cmdTarget, client->GetPlayer()->GetX(), client->GetPlayer()->GetZ());
  4498. client->Message(CHANNEL_COLOR_YELLOW, "%s %s.", isBehind ? "YOU are infront of" : "YOU are NOT infront of", cmdTarget->GetName());
  4499. break;
  4500. }
  4501. else if (ToLower(string(sep->arg[0])) == "flank")
  4502. {
  4503. bool isFlanking = client->GetPlayer()->FlankingTarget(cmdTarget);
  4504. client->Message(CHANNEL_COLOR_YELLOW, "%s is %s.", isFlanking ? "YOU are flanking" : "YOU are NOT flanking", cmdTarget->GetName());
  4505. break;
  4506. }
  4507. else if (ToLower(string(sep->arg[0])) == "aggro")
  4508. {
  4509. if(cmdTarget->IsNPC() && ((NPC*)cmdTarget)->Brain()) {
  4510. ((NPC*)cmdTarget)->Brain()->SendEncounterList(client);
  4511. ((NPC*)cmdTarget)->Brain()->SendHateList(client);
  4512. }
  4513. else {
  4514. client->SimpleMessage(CHANNEL_COLOR_RED, "/spawn details aggro is for NPCs only!");
  4515. }
  4516. break;
  4517. }
  4518. else if (ToLower(string(sep->arg[0])) == "angle")
  4519. {
  4520. float spawnAngle = client->GetPlayer()->GetFaceTarget(cmdTarget->GetX(), cmdTarget->GetZ());
  4521. 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());
  4522. break;
  4523. }
  4524. }
  4525. if (sep->IsNumber(0))
  4526. {
  4527. float radius = atof(sep->arg[0]);
  4528. if (!client->GetCurrentZone()->SendRadiusSpawnInfo(client, radius))
  4529. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No results in the radius were found.");
  4530. break;
  4531. }
  4532. }
  4533. if (spawn) {
  4534. const char* type = "NPC";
  4535. if (spawn->IsObject())
  4536. type = "Object";
  4537. else if (spawn->IsSign())
  4538. type = "Sign";
  4539. else if (spawn->IsWidget())
  4540. type = "Widget";
  4541. else if (spawn->IsGroundSpawn())
  4542. type = "GroundSpawn";
  4543. int16 race_type = race_types_list.GetRaceType(spawn->GetModelType());
  4544. int16 race_base_type = race_types_list.GetRaceBaseType(spawn->GetModelType());
  4545. char* category = race_types_list.GetRaceTypeCategory(spawn->GetModelType());
  4546. char* subcategory = race_types_list.GetRaceTypeSubCategory(spawn->GetModelType());
  4547. char* modelname = race_types_list.GetRaceTypeModelName(spawn->GetModelType());
  4548. client->Message(CHANNEL_COLOR_YELLOW, "Name: %s, %s ID: %u", spawn->GetName(), type, spawn->GetDatabaseID());
  4549. client->Message(CHANNEL_COLOR_YELLOW, "Last Name: %s, Sub-Title: %s, Prefix: %s, Suffix: %s", spawn->GetLastName(), spawn->GetSubTitle(), spawn->GetPrefixTitle(), spawn->GetSuffixTitle());
  4550. client->Message(CHANNEL_COLOR_YELLOW, "Spawn Location ID: %u, Spawn Group ID: %u", spawn->GetSpawnLocationID(), spawn->GetSpawnGroupID());
  4551. client->Message(CHANNEL_COLOR_YELLOW, "Faction ID: %u, Merchant ID: %u, Transporter ID: %u", spawn->GetFactionID(), spawn->GetMerchantID(), spawn->GetTransporterID());
  4552. client->Message(CHANNEL_COLOR_YELLOW, "Grid ID: %u", spawn->GetLocation());
  4553. client->Message(CHANNEL_COLOR_YELLOW, "Race: %i, Class: %i, Gender: %i", spawn->GetRace(), spawn->GetAdventureClass(), spawn->GetGender());
  4554. client->Message(CHANNEL_COLOR_YELLOW, "Level: %i, HP: %u / %u, Power: %u / %u", spawn->GetLevel(), spawn->GetHP(), spawn->GetTotalHP(), spawn->GetPower(), spawn->GetTotalPower());
  4555. 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());
  4556. client->Message(CHANNEL_COLOR_YELLOW, "Collision Radius: %i, Size: %i, Difficulty: %i, Heroic: %i", spawn->GetCollisionRadius(), spawn->GetSize(), spawn->GetDifficulty(), spawn->GetHeroic());
  4557. client->Message(CHANNEL_COLOR_YELLOW, "Targetable: %i, Show Name: %i, Attackable: %i, Show Level: %i", spawn->GetTargetable(), spawn->GetShowName(), spawn->GetAttackable(), spawn->GetShowLevel());
  4558. client->Message(CHANNEL_COLOR_YELLOW, "Show Command Icon: %i, Display Hand Icon: %i", spawn->GetShowCommandIcon(), spawn->GetShowHandIcon());
  4559. if (spawn->IsEntity()) {
  4560. 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());
  4561. 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());
  4562. }
  4563. 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);
  4564. client->Message(CHANNEL_COLOR_YELLOW, "Primary Command Type: %u, Secondary Command Type: %u", spawn->GetPrimaryCommandListID(), spawn->GetSecondaryCommandListID());
  4565. 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());
  4566. 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);
  4567. if (spawn->IsNPC())
  4568. client->Message(CHANNEL_COLOR_YELLOW, "Randomize: %u", ((NPC*)spawn)->GetRandomize());
  4569. if (spawn->IsNPC()){
  4570. client->Message(CHANNEL_COLOR_YELLOW, "Heat Resist/Base: %u/%u",((NPC*)spawn)->GetHeatResistance(), ((NPC*)spawn)->GetHeatResistanceBase());
  4571. client->Message(CHANNEL_COLOR_YELLOW, "Cold Resist/Base: %u/%u",((NPC*)spawn)->GetColdResistance(), ((NPC*)spawn)->GetColdResistanceBase());
  4572. client->Message(CHANNEL_COLOR_YELLOW, "Magic Resist/Base: %u/%u",((NPC*)spawn)->GetMagicResistance(), ((NPC*)spawn)->GetMagicResistanceBase());
  4573. client->Message(CHANNEL_COLOR_YELLOW, "Mental Resist/Base: %u/%u",((NPC*)spawn)->GetMentalResistance(), ((NPC*)spawn)->GetMentalResistanceBase());
  4574. client->Message(CHANNEL_COLOR_YELLOW, "Divine Resist/Base: %u/%u",((NPC*)spawn)->GetDivineResistance(), ((NPC*)spawn)->GetDivineResistanceBase());
  4575. client->Message(CHANNEL_COLOR_YELLOW, "Disease Resist/Base: %u/%u",((NPC*)spawn)->GetDiseaseResistance(), ((NPC*)spawn)->GetDiseaseResistanceBase());
  4576. client->Message(CHANNEL_COLOR_YELLOW, "Poison Resist/Base: %u/%u",((NPC*)spawn)->GetPoisonResistance(), ((NPC*)spawn)->GetPoisonResistanceBase());
  4577. }
  4578. string details;
  4579. details += "\\#0000FFName: " + string(spawn->GetName()) + "\n";
  4580. details += "Type: " + string(type) + "\n";
  4581. details += "ID: " + to_string(spawn->GetDatabaseID()) + "\n";
  4582. details += "Last Name: " + string(spawn->GetLastName()) + "\n";
  4583. details += "Sub-Title: " + string(spawn->GetSubTitle()) + "\n";
  4584. details += "Prefix: " + string(spawn->GetPrefixTitle()) + "\n";
  4585. details += "Suffix: " + string(spawn->GetSuffixTitle()) + "\n";
  4586. details += "Race: " + to_string(spawn->GetRace()) + "\n";
  4587. details += "Class: " + to_string(spawn->GetAdventureClass()) + "\n";
  4588. details += "Gender: " + to_string(spawn->GetGender()) + "\n";
  4589. details += "Level: " + to_string(spawn->GetLevel()) + "\n";
  4590. details += "HP: " + to_string(spawn->GetHP()) + " / " + to_string(spawn->GetTotalHP()) + "(" + to_string(spawn->GetIntHPRatio()) + "%)\n";
  4591. details += "Power: " + to_string(spawn->GetPower()) + + " / " + to_string(spawn->GetTotalPower()) + "\n";
  4592. details += "Difficulty: " + to_string(spawn->GetDifficulty()) + "\n";
  4593. details += "Heroic: " + to_string(spawn->GetHeroic()) + "\n";
  4594. details += "Group ID: " + to_string(spawn->GetSpawnGroupID()) + "\n";
  4595. details += "Faction ID: " + to_string(spawn->GetFactionID()) + "\n";
  4596. details += "Merchant ID: " + to_string(spawn->GetMerchantID()) + "\n";
  4597. details += "Transport ID: " + to_string(spawn->GetTransporterID()) + "\n";
  4598. details += "Location ID: " + to_string(spawn->GetSpawnLocationID()) + "\n";
  4599. char x[16];
  4600. sprintf(x, "%.2f", spawn->GetX());
  4601. char y[16];
  4602. sprintf(y, "%.2f", spawn->GetY());
  4603. char z[16];
  4604. sprintf(z, "%.2f", spawn->GetZ());
  4605. details += "Location: " + string(x) + ", " + string(y) + ", " + string(z) + "\n";
  4606. string details2;
  4607. details2 += "Heading: " + to_string(spawn->GetHeading()) + "\n";
  4608. details2 += "Grid ID: " + to_string(spawn->GetLocation()) + "\n";
  4609. details2 += "Size: " + to_string(spawn->GetSize()) + "\n";
  4610. details2 += "Collision Radius: " + to_string(spawn->GetCollisionRadius()) + "\n";
  4611. details2 += "Respawn Time: " + to_string(spawn->GetRespawnTime()) + "\n";
  4612. details2 += "Targetable: " + to_string(spawn->GetTargetable()) + "\n";
  4613. details2 += "Show Name: " + to_string(spawn->GetShowName()) + "\n";
  4614. details2 += "Attackable: " + to_string(spawn->GetAttackable()) + "\n";
  4615. details2 += "Show Level: " + to_string(spawn->GetShowLevel()) + "\n";
  4616. details2 += "Show Command Icon: " + to_string(spawn->GetShowCommandIcon()) + "\n";
  4617. details2 += "Display Hand Icon: " + to_string(spawn->GetShowHandIcon()) + "\n";
  4618. details2 += "Model Type: " + to_string(spawn->GetModelType()) + "\n";
  4619. details2 += "Soga Race Type: " + to_string(spawn->GetSogaModelType()) + "\n";
  4620. details2 += "Race Type: " + to_string(race_type) + "\n";
  4621. details2 += "Race Base Type: " + to_string(race_base_type) + "\n";
  4622. details2 += "Race Category (Sub Category): " + std::string(category) + " (" + std::string(subcategory) + ")\n";
  4623. details2 += "Model Name: " + std::string(modelname) + "\n";
  4624. details2 += "Primary Command ID: " + to_string(spawn->GetPrimaryCommandListID()) + "\n";
  4625. details2 += "Secondary Cmd ID: " + to_string(spawn->GetSecondaryCommandListID()) + "\n";
  4626. details2 += "Visual State: " + to_string(spawn->GetVisualState()) + "\n";
  4627. details2 += "Action State: " + to_string(spawn->GetActionState()) + "\n";
  4628. details2 += "Mood State: " + to_string(spawn->GetMoodState()) + "\n";
  4629. details2 += "Initial State: " + to_string(spawn->GetInitialState()) + "\n";
  4630. details2 += "Activity Status: " + to_string(spawn->GetActivityStatus()) + "\n";
  4631. details2 += "Emote State: " + to_string(spawn->GetEmoteState()) + "\n";
  4632. string details3;
  4633. details3 += "Pitch: " + to_string(spawn->GetPitch()) + "\n";
  4634. details3 += "Roll: " + to_string(spawn->GetRoll()) + "\n";
  4635. details3 += "Hide Hood: " + to_string(spawn->appearance.hide_hood) + "\n";
  4636. details3 += "Speed: " + to_string(spawn->GetSpeed()) + "\n";
  4637. details3 += "BaseSpeed: " + to_string(spawn->GetBaseSpeed()) + "\n";
  4638. if(spawn->IsSign()) {
  4639. details3 += "Sign Language: " + to_string(((Sign*)spawn)->GetLanguage()) + "\n";
  4640. }
  4641. if(spawn->IsEntity())
  4642. {
  4643. Entity* ent = (Entity*)spawn;
  4644. details3 += "STR / STRBase: " + to_string(ent->GetInfoStruct()->get_str()) + " / " + to_string(ent->GetInfoStruct()->get_str_base()) + "\n";
  4645. details3 += "AGI / AGIBase: " + to_string(ent->GetInfoStruct()->get_agi()) + " / " + to_string(ent->GetInfoStruct()->get_agi_base()) + "\n";
  4646. details3 += "STA / STABase: " + to_string(ent->GetInfoStruct()->get_sta()) + " / " + to_string(ent->GetInfoStruct()->get_sta_base()) + "\n";
  4647. details3 += "INT / INTBase: " + to_string(ent->GetInfoStruct()->get_intel()) + " / " + to_string(ent->GetInfoStruct()->get_intel_base()) + "\n";
  4648. details3 += "WIS / WISBase: " + to_string(ent->GetInfoStruct()->get_wis()) + " / " + to_string(ent->GetInfoStruct()->get_wis_base()) + "\n";
  4649. }
  4650. string details4;
  4651. if (spawn->IsEntity()) {
  4652. details4 += "Facial Hair Type: " + to_string(((Entity*)spawn)->GetFacialHairType()) + "\n";
  4653. details4 += "Hair Type: " + to_string(((Entity*)spawn)->GetHairType()) + "\n";
  4654. details4 += "Chest Type: " + to_string(((Entity*)spawn)->GetChestType()) + "\n";
  4655. details4 += "Legs Type: " + to_string(((Entity*)spawn)->GetLegsType()) + "\n";
  4656. details4 += "Soga Facial Hair Type: " + to_string(((Entity*)spawn)->GetSogaFacialHairType()) + "\n";
  4657. details4 += "Soga Hair Type: " + to_string(((Entity*)spawn)->GetSogaHairType()) + "\n";
  4658. details4 += "Wing Type: " + to_string(((Entity*)spawn)->GetWingType()) + "\n";
  4659. if (spawn->IsNPC()) {
  4660. details4 += "\nRandomize: " + to_string(((NPC*)spawn)->GetRandomize()) + "\n";
  4661. }
  4662. }
  4663. const char* spawnScriptMsg = (spawn->GetSpawnScript() && strlen(spawn->GetSpawnScript())>0) ? spawn->GetSpawnScript() : "Not Set";
  4664. details4 += "\nSpawnScript: " + std::string(spawnScriptMsg) + "\n";
  4665. string title = string(spawn->GetName()) + "(" + to_string(spawn->GetDatabaseID()) + ")";
  4666. client->SendShowBook(client->GetPlayer(), title, 0, 4, details, details2, details3, details4);
  4667. }
  4668. else {
  4669. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn details (radius)");
  4670. 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.");
  4671. }
  4672. break;
  4673. }
  4674. case COMMAND_SPAWN_TARGET:{
  4675. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  4676. int32 spawn_id = atoul(sep->arg[0]);
  4677. int16 response = client->GetCurrentZone()->SetSpawnTargetable(spawn_id);
  4678. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  4679. }
  4680. else if(sep && sep->arg[0][0] && sep->arg[1][0] && sep->IsNumber(1) && ToLower(string(sep->arg[0])) == "radius"){
  4681. float distance = atof(sep->arg[1]);
  4682. int16 response = client->GetCurrentZone()->SetSpawnTargetable(client->GetPlayer(), distance);
  4683. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  4684. }
  4685. else{
  4686. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn target [spawn id]");
  4687. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn as targetable. Used to change a spawn if it was set to untargetable.");
  4688. }
  4689. break;
  4690. }
  4691. case COMMAND_SPAWN_SET:
  4692. {
  4693. Spawn* spawn = cmdTarget;
  4694. sint16 set_type = -1;
  4695. string type_str;
  4696. if (spawn)
  4697. {
  4698. // check if parameters are (location or list or not player and not a 2nd param), and that there is at least 1 value
  4699. 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)
  4700. {
  4701. // set the type, which will be 0 if location or list or invalid
  4702. set_type = spawn_set_values[ToLower(string(sep->arg[0]))];
  4703. }
  4704. if(set_type > 0)
  4705. {
  4706. // check if spawn set is NOT a char update, or not location, or isn't a number
  4707. 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)
  4708. {
  4709. client->SimpleMessage(CHANNEL_COLOR_RED, "Invalid value for set command.");
  4710. }
  4711. else
  4712. {
  4713. string name = string(spawn->GetName());
  4714. bool customSetSpawn = false;
  4715. if(set_type >= SPAWN_SET_CHEEK_TYPE && set_type <= SPAWN_SET_SOGA_NOSE_TYPE)
  4716. {
  4717. int8 index = sep->IsNumber(2) ? atoul(sep->arg[2]) : 0;
  4718. // override the standard setspawncommand, we pass arguments different!
  4719. if(SetSpawnCommand(client, spawn, set_type, sep->arg[1], true, false, nullptr, index))
  4720. customSetSpawn = true;
  4721. }
  4722. if(customSetSpawn || SetSpawnCommand(client, spawn, set_type, sep->argplus[1]))
  4723. {
  4724. if (set_type == SPAWN_SET_VALUE_EXPANSION_FLAG || set_type == SPAWN_SET_VALUE_HOLIDAY_FLAG)
  4725. {
  4726. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "A /reload spawns is required to properly update the spawns with the xpack/holiday flag.");
  4727. }
  4728. else if (set_type == SPAWN_SET_VALUE_NAME)
  4729. {
  4730. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "New name will not be effective until zone reload.");
  4731. }
  4732. else if (set_type == SPAWN_SET_SKIN_COLOR || (set_type >= SPAWN_SET_HAIR_COLOR1 && set_type <= SPAWN_SET_SOGA_EYE_COLOR))
  4733. {
  4734. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set color field to R G B: %s.", sep->argplus[1]);
  4735. }
  4736. else if(set_type == SPAWN_SET_VALUE_LOCATION)
  4737. {
  4738. spawn->SetLocation(client->GetPlayer()->GetLocation());
  4739. 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());
  4740. }
  4741. else
  4742. {
  4743. 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());
  4744. }
  4745. switch (set_type)
  4746. {
  4747. case SPAWN_SET_VALUE_EXPANSION_FLAG:
  4748. case SPAWN_SET_VALUE_HOLIDAY_FLAG:
  4749. case SPAWN_SET_VALUE_FACTION:
  4750. case SPAWN_SET_AAXP_REWARDS:
  4751. case SPAWN_SET_CHEEK_TYPE:
  4752. case SPAWN_SET_CHIN_TYPE:
  4753. case SPAWN_SET_EAR_TYPE:
  4754. case SPAWN_SET_EYE_BROW_TYPE:
  4755. case SPAWN_SET_EYE_TYPE:
  4756. case SPAWN_SET_LIP_TYPE:
  4757. case SPAWN_SET_NOSE_TYPE:
  4758. case SPAWN_SET_BODY_SIZE:
  4759. case SPAWN_SET_BODY_AGE:
  4760. case SPAWN_SET_SOGA_CHEEK_TYPE:
  4761. case SPAWN_SET_SOGA_CHIN_TYPE:
  4762. case SPAWN_SET_SOGA_EAR_TYPE:
  4763. case SPAWN_SET_SOGA_EYE_BROW_TYPE:
  4764. case SPAWN_SET_SOGA_EYE_TYPE:
  4765. case SPAWN_SET_SOGA_LIP_TYPE:
  4766. case SPAWN_SET_SOGA_NOSE_TYPE:
  4767. case SPAWN_SET_SOGA_BODY_SIZE:
  4768. case SPAWN_SET_SOGA_BODY_AGE:
  4769. case SPAWN_SET_ATTACK_TYPE:
  4770. case SPAWN_SET_RACE_TYPE:
  4771. case SPAWN_SET_LOOT_TIER:
  4772. case SPAWN_SET_LOOT_DROP_TYPE:
  4773. case SPAWN_SET_SCARED_STRONG_PLAYERS:
  4774. {
  4775. // not applicable already ran db command
  4776. break;
  4777. }
  4778. default:
  4779. {
  4780. client->GetCurrentZone()->ApplySetSpawnCommand(client, spawn, set_type, sep->argplus[1]);
  4781. break;
  4782. }
  4783. }
  4784. 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))
  4785. {
  4786. if(spawn->GetSpawnLocationID() > 0 && database.UpdateSpawnLocationSpawns(spawn))
  4787. {
  4788. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information for spawn '%s' (DBID: %u)", name.c_str(), spawn->GetDatabaseID());
  4789. }
  4790. else if(spawn->GetSpawnLocationID() > 0)
  4791. {
  4792. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn information, see console window for details.");
  4793. }
  4794. }
  4795. else
  4796. {
  4797. if(spawn->GetDatabaseID() > 0 && database.SaveSpawnInfo(spawn))
  4798. {
  4799. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn for spawn '%s' (DBID: %u)", name.c_str(), spawn->GetDatabaseID());
  4800. }
  4801. else if(spawn->GetDatabaseID() > 0)
  4802. {
  4803. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn, see console window for details.");
  4804. }
  4805. }
  4806. }
  4807. }
  4808. }
  4809. else if(set_type == 0)
  4810. {
  4811. // /spawn set list - lists all possible attributes that can be changed with this command, 10 per line.
  4812. map<string, int8>::iterator itr;
  4813. int i=0;
  4814. string list;
  4815. for(itr = spawn_set_values.begin(); itr != spawn_set_values.end(); itr++, i++)
  4816. {
  4817. if(i==10)
  4818. {
  4819. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  4820. i = 0;
  4821. }
  4822. if(i>0)
  4823. {
  4824. list.append(", ").append(itr->first);
  4825. }
  4826. else
  4827. {
  4828. list = itr->first;
  4829. }
  4830. }
  4831. if(list.length() > 0)
  4832. {
  4833. // if 1 or more, display in client.
  4834. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  4835. }
  4836. }
  4837. else
  4838. {
  4839. // syntax fail
  4840. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn set [type] [value]");
  4841. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used to change various settings for the targeted NPC or Object.");
  4842. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "For a list of changeable settings use /spawn set list");
  4843. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Note: /spawn set location does not require a value. The client's current location is used.");
  4844. }
  4845. }
  4846. break;
  4847. }
  4848. case COMMAND_SPAWN_REMOVE:{
  4849. Spawn* spawn = cmdTarget;
  4850. if(spawn && !spawn->IsPlayer()){
  4851. if(spawn->GetSpawnLocationID() > 0){
  4852. string name = string(spawn->GetName());
  4853. int32 dbid = spawn->GetDatabaseID();
  4854. if(database.RemoveSpawnFromSpawnLocation(spawn)){
  4855. client->GetCurrentZone()->RemoveSpawn(spawn, true, false, true, true, true);
  4856. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed spawn from zone for spawn '%s' (DBID: %u)", name.c_str(), dbid);
  4857. }
  4858. else
  4859. client->SimpleMessage(CHANNEL_COLOR_RED, "Error removing spawn, see console window for details.");
  4860. }
  4861. else
  4862. client->SimpleMessage(CHANNEL_COLOR_RED, "This spawn does not have a spawn group associated with it");
  4863. }
  4864. else{
  4865. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn remove");
  4866. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for removing the targeted NPC or Object from the zone.");
  4867. }
  4868. break;
  4869. }
  4870. case COMMAND_SPAWN_LIST:{
  4871. if(sep && sep->arg[0][0]){
  4872. vector<string>* results = database.GetSpawnNameList(sep->argplus[0]);
  4873. vector<string>::iterator itr;
  4874. if(results){
  4875. for(itr=results->begin();itr!=results->end();itr++){
  4876. client->SimpleMessage(CHANNEL_COLOR_YELLOW, (*itr).c_str());
  4877. }
  4878. safe_delete(results);
  4879. }
  4880. else
  4881. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found. ");
  4882. }
  4883. else{
  4884. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn list [name]");
  4885. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Name can be a partial match.");
  4886. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn list Qeynos Guard");
  4887. }
  4888. break;
  4889. }
  4890. case COMMAND_SPAWN_ADD:{
  4891. Spawn* spawn = cmdTarget;
  4892. if(spawn && sep && ((sep->arg[1][0] && sep->IsNumber(0)) || (sep->arg[0][0] && strncasecmp(sep->arg[0], "new", 3) == 0))){
  4893. if(spawn->GetSpawnLocationID() > 0){
  4894. client->Message(CHANNEL_COLOR_RED, "This spawn already has a spawn group id of %u, use /spawn remove to reassign it", spawn->GetSpawnLocationID());
  4895. break;
  4896. }
  4897. if(spawn->GetDatabaseID() == 0){
  4898. if(database.SaveSpawnInfo(spawn)) {
  4899. char spawn_type[32];
  4900. memset(spawn_type, 0, sizeof(spawn_type));
  4901. if (spawn->IsNPC())
  4902. strncpy(spawn_type, "NPC", sizeof(spawn_type) - 1);
  4903. else if (spawn->IsObject())
  4904. strncpy(spawn_type, "Object", sizeof(spawn_type) - 1);
  4905. else if (spawn->IsSign())
  4906. strncpy(spawn_type, "Sign", sizeof(spawn_type) - 1);
  4907. else if (spawn->IsGroundSpawn())
  4908. strncpy(spawn_type, "GroundSpawn", sizeof(spawn_type) - 1);
  4909. else
  4910. strncpy(spawn_type, "Unknown", sizeof(spawn_type) - 1);
  4911. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information with a %s id of %u", spawn_type, spawn->GetDatabaseID());
  4912. }
  4913. else
  4914. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn information, see console window for details.");
  4915. }
  4916. int32 spawn_group_id = 0;
  4917. if(strncasecmp(sep->arg[0], "new", 3) == 0)
  4918. spawn_group_id = database.GetNextSpawnLocation();
  4919. else
  4920. spawn_group_id = atol(sep->arg[0]);
  4921. int8 percent = 100;
  4922. if(sep->arg[2] && sep->IsNumber(2))
  4923. percent = atoi(sep->arg[2]);
  4924. spawn->SetSpawnLocationID(spawn_group_id);
  4925. float x_offset = database.GetSpawnLocationPlacementOffsetX(spawn->GetSpawnLocationID());
  4926. float y_offset = database.GetSpawnLocationPlacementOffsetY(spawn->GetSpawnLocationID());
  4927. float z_offset = database.GetSpawnLocationPlacementOffsetZ(spawn->GetSpawnLocationID());
  4928. if(database.SaveSpawnEntry(spawn, sep->arg[1], percent, x_offset, y_offset, z_offset))
  4929. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn location with a spawn group of %u", spawn->GetSpawnLocationID());
  4930. else
  4931. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn location, see console window for details.");
  4932. }
  4933. else{
  4934. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn add [spawn group id] [spawn group name] (percentage)");
  4935. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for adding the targeted NPC or Object to the database.");
  4936. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can substitute new for [spawn group id] to create a new one.");
  4937. }
  4938. break;
  4939. }
  4940. case COMMAND_SPAWN:{
  4941. int32 id = 0;
  4942. Spawn* spawn = 0;
  4943. if(sep && sep->arg[0] && sep->IsNumber(0)){
  4944. id = atol(sep->arg[0]);
  4945. spawn = client->GetCurrentZone()->GetSpawn(id);
  4946. }
  4947. if(id > 0 && spawn && spawn->appearance.name[0] == 0)
  4948. id = 0;
  4949. if(!id || !spawn){
  4950. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn [spawn id] (x) (y) (z) (heading) (location)");
  4951. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are optional except the id. The spawn id must be in the database.");
  4952. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn 1 0 0 0 0");
  4953. safe_delete(sep);
  4954. return;
  4955. }
  4956. if(sep && sep->arg[1][0]){
  4957. float x = atof(sep->arg[1]);
  4958. spawn->appearance.pos.X = x;
  4959. }
  4960. else
  4961. spawn->SetX(client->GetPlayer()->GetX(), false);
  4962. if(sep && sep->arg[2][0]){
  4963. float y = atof(sep->arg[2]);
  4964. spawn->appearance.pos.Y = y;
  4965. }
  4966. else
  4967. spawn->SetY(client->GetPlayer()->GetY(), false);
  4968. if(sep && sep->arg[3][0]){
  4969. float z = atof(sep->arg[3]);
  4970. spawn->appearance.pos.Z = z;
  4971. }
  4972. else
  4973. spawn->SetZ(client->GetPlayer()->GetZ(), false);
  4974. if(sep && sep->arg[4][0]){
  4975. float heading = atof(sep->arg[4]);
  4976. spawn->SetHeading(heading);
  4977. }
  4978. else
  4979. spawn->SetHeading(client->GetPlayer()->GetHeading(), false);
  4980. spawn->SetSpawnOrigX(spawn->GetX());
  4981. spawn->SetSpawnOrigY(spawn->GetY());
  4982. spawn->SetSpawnOrigZ(spawn->GetZ());
  4983. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  4984. if(sep && sep->arg[5][0])
  4985. spawn->SetLocation(atoul(sep->arg[5]));
  4986. else
  4987. spawn->SetLocation(client->GetPlayer()->GetLocation());
  4988. if(spawn->IsNPC() && spawn->GetTotalHP() == 0){
  4989. spawn->SetTotalHP(spawn->GetLevel() * 15);
  4990. spawn->SetHP(spawn->GetTotalHP());
  4991. }
  4992. if(spawn->GetTotalPower() == 0){
  4993. spawn->SetTotalPower(spawn->GetLevel() * 15);
  4994. spawn->SetPower(spawn->GetTotalPower());
  4995. }
  4996. const char* script = world.GetSpawnScript(id);
  4997. if(script && lua_interface && lua_interface->GetSpawnScript(script) != 0)
  4998. spawn->SetSpawnScript(string(script));
  4999. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_PRESPAWN);
  5000. client->GetCurrentZone()->AddSpawn(spawn);
  5001. if(spawn->IsNPC())
  5002. spawn->GetZone()->AddLoot((NPC*)spawn);
  5003. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_SPAWN);
  5004. LogWrite(COMMAND__INFO, 0, "Command", "Received spawn command - Parms: %s", command_parms->data.c_str());
  5005. break;
  5006. }
  5007. case COMMAND_ADMINFLAG:
  5008. {
  5009. if(sep && sep->arg[0]){
  5010. sint16 tmp_status = database.GetCharacterAdminStatus(sep->arg[0]);
  5011. sint16 new_status = atoi(sep->arg[1]);
  5012. if(tmp_status == -10)
  5013. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character does not exist.");
  5014. else if(tmp_status >= client->GetAdminStatus())
  5015. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character has same or higher level status.");
  5016. else if (new_status > client->GetAdminStatus())
  5017. client->SimpleMessage(CHANNEL_ERROR, "Unable to flag character. Reason: New status is higher then your status.");
  5018. else{
  5019. Client* client2 = client->GetCurrentZone()->GetClientByName(sep->arg[0]);
  5020. if (!client2)
  5021. client2 = zone_list.GetClientByCharName(sep->arg[0]);
  5022. if(database.UpdateAdminStatus(sep->arg[0],new_status)) {
  5023. client->Message(CHANNEL_COLOR_YELLOW,"Character status updated to %i for %s.",new_status,sep->arg[0]);
  5024. if (client2) {
  5025. client2->SetAdminStatus(new_status);
  5026. client2->Message(CHANNEL_COLOR_YELLOW, "%s has set your admin status to %i.", client->GetPlayer()->GetName(), new_status);
  5027. }
  5028. }
  5029. else
  5030. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Unknown reason.");
  5031. }
  5032. }else{
  5033. sint16 status = database.GetCharacterAdminStatus(client->GetPlayer()->GetName());
  5034. if(status != client->GetAdminStatus())
  5035. {
  5036. client->Message(CHANNEL_COLOR_YELLOW,"Flag status was changed from %i to %i.",status,client->GetAdminStatus());
  5037. client->SetAdminStatus(status);
  5038. }
  5039. else
  5040. {
  5041. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /flag {name} {new_status}");
  5042. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Standard User: 0");
  5043. client->Message(CHANNEL_COLOR_YELLOW," Admin User: %i", status);
  5044. }
  5045. }
  5046. break;
  5047. }
  5048. case COMMAND_CANNEDEMOTE:{
  5049. client->GetCurrentZone()->HandleEmote(client->GetPlayer(), command_parms->data);
  5050. break;
  5051. }
  5052. case COMMAND_BROADCAST: {
  5053. if (sep && sep->arg[0])
  5054. zone_list.HandleGlobalBroadcast(sep->argplus[0]);
  5055. else
  5056. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /broadcast {message}");
  5057. break;
  5058. }
  5059. case COMMAND_ANNOUNCE: {
  5060. if (sep && sep->arg[0])
  5061. zone_list.HandleGlobalAnnouncement(sep->argplus[0]);
  5062. else
  5063. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /announce {message}");
  5064. break;
  5065. }
  5066. case COMMAND_RELOAD_ITEMS:{
  5067. LogWrite(COMMAND__INFO, 0, "Command", "Reloading items..");
  5068. int32 item_id = (sep && sep->arg[0]) ? atoul(sep->arg[0]) : 0;
  5069. if(item_id > 0) {
  5070. client->Message(CHANNEL_COLOR_YELLOW, "Reloading item %u based on /reload items [item_id].", item_id);
  5071. }
  5072. else {
  5073. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Started Reloading items (this might take a few minutes...)");
  5074. }
  5075. database.ReloadItemList(item_id);
  5076. if(!item_id) {
  5077. database.LoadMerchantInformation(); // we skip if there is only a reload of single item not all items
  5078. }
  5079. if(item_id > 0) {
  5080. client->Message(CHANNEL_COLOR_YELLOW, "Reloaded item %u.", item_id);
  5081. }
  5082. else {
  5083. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Finished Reloading items.");
  5084. }
  5085. break;
  5086. }
  5087. case COMMAND_ENABLE_ABILITY_QUE:{
  5088. EQ2Packet* app = client->GetPlayer()->GetSpellBookUpdatePacket(client->GetVersion());
  5089. if(app)
  5090. client->QueuePacket(app);
  5091. break;
  5092. }
  5093. case COMMAND_ITEMSEARCH:
  5094. case COMMAND_FROMBROKER:{
  5095. PacketStruct* packet = configReader.getStruct("WS_StartBroker", client->GetVersion());
  5096. if (packet) {
  5097. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  5098. //packet->setDataByName("unknown", 1);
  5099. packet->setDataByName("unknown2", 5, 0);
  5100. packet->setDataByName("unknown2", 20, 1);
  5101. packet->setDataByName("unknown2", 58, 3);
  5102. packet->setDataByName("unknown2", 40, 4);
  5103. client->QueuePacket(packet->serialize());
  5104. PacketStruct* packet2 = configReader.getStruct("WS_BrokerBags", client->GetVersion());
  5105. if (packet2) {
  5106. packet2->setDataByName("char_id", client->GetCharacterID());
  5107. client->QueuePacket(packet2->serialize()); //send this for now, needed to properly clear data
  5108. safe_delete(packet2);
  5109. }
  5110. safe_delete(packet);
  5111. }
  5112. break;
  5113. }
  5114. case COMMAND_ANIMTEST:{
  5115. PacketStruct* command_packet = configReader.getStruct("WS_CannedEmote", client->GetVersion());
  5116. if(command_packet){
  5117. int32 id = client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer());
  5118. if (cmdTarget)
  5119. id = client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget);
  5120. command_packet->setDataByName ( "spawn_id" , id);
  5121. int animID = 1;
  5122. if(sep && sep->arg[0] && sep->IsNumber(0))
  5123. animID = atoi(sep->arg[0]);
  5124. VisualState* vs = NULL;
  5125. if(animID == 0)
  5126. {
  5127. vs = visual_states.FindVisualState(sep->arg[0]);
  5128. }
  5129. char msg[128];
  5130. sprintf(msg,"Animation Test ID: %i",animID);
  5131. command_packet->setMediumStringByName ( "emote_msg" , msg );
  5132. if(vs != NULL)
  5133. command_packet->setDataByName ( "anim_type", vs->GetID ( ) );
  5134. else
  5135. command_packet->setDataByName ( "anim_type", animID );
  5136. command_packet->setDataByName ( "unknown0", 0 );
  5137. EQ2Packet* outapp = command_packet->serialize();
  5138. client->QueuePacket(outapp);
  5139. safe_delete(command_packet);
  5140. }
  5141. break;
  5142. }
  5143. case COMMAND_KICK:
  5144. {
  5145. if( sep == 0 || sep->arg[0] == 0)
  5146. {
  5147. client->SimpleMessage(CHANNEL_COLOR_RED, "/kick [name]");
  5148. }
  5149. else
  5150. {
  5151. Client* kickClient = zone_list.GetClientByCharName(string(sep->arg[0]));
  5152. if ( kickClient == client )
  5153. {
  5154. client->Message(CHANNEL_COLOR_RED, "You can't kick yourself!");
  5155. break;
  5156. }
  5157. else if(kickClient != NULL)
  5158. {
  5159. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  5160. if ( maxStatus >= client->GetAdminStatus( ) || kickClient->GetAdminStatus() >= client->GetAdminStatus() )
  5161. {
  5162. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  5163. break;
  5164. }
  5165. client->Message(CHANNEL_COLOR_RED, "Kicking %s...",sep->arg[0]);
  5166. kickClient->Disconnect();
  5167. }
  5168. else
  5169. {
  5170. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  5171. }
  5172. }
  5173. break;
  5174. }
  5175. case COMMAND_LOCK:
  5176. {
  5177. if( sep != NULL && sep->arg[0] != NULL && sep->IsNumber(0)){
  5178. int worldLocked = atoi(sep->arg[0]);
  5179. net.world_locked = worldLocked;
  5180. if ( worldLocked )
  5181. client->Message(CHANNEL_COLOR_YELLOW,"World server has been locked.");
  5182. else
  5183. client->Message(CHANNEL_COLOR_YELLOW,"World server has been unlocked.");
  5184. }
  5185. else
  5186. client->SimpleMessage(CHANNEL_COLOR_RED, "/lock [0/1]");
  5187. break;
  5188. }
  5189. case COMMAND_BAN:{
  5190. if( sep == 0 || sep->arg[0] == 0 || (sep->arg[1][0] != 0 && !sep->IsNumber(1) ) )
  5191. {
  5192. client->SimpleMessage(CHANNEL_COLOR_RED, "/ban [name] [permanent:0/1]");
  5193. }
  5194. else
  5195. {
  5196. Client* kickClient = zone_list.GetClientByCharName(sep->arg[0]);
  5197. if ( kickClient == client )
  5198. {
  5199. client->Message(CHANNEL_COLOR_RED, "You can't ban yourself!");
  5200. break;
  5201. }
  5202. else if(kickClient != NULL)
  5203. {
  5204. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  5205. if ( maxStatus > client->GetAdminStatus( ) ||
  5206. client->GetAdminStatus ( ) > kickClient->GetAdminStatus ( ) )
  5207. {
  5208. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  5209. break;
  5210. }
  5211. client->Message(CHANNEL_COLOR_RED, "Kicking & Banning %s...",sep->arg[0]);
  5212. int perm = atol(sep->arg[1]);
  5213. if ( perm == 1 )
  5214. database.UpdateAdminStatus(sep->arg[0],-2);
  5215. else
  5216. database.UpdateAdminStatus(sep->arg[0],-1);
  5217. kickClient->Disconnect();
  5218. }
  5219. else
  5220. {
  5221. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  5222. }
  5223. }
  5224. break;
  5225. }
  5226. case COMMAND_SET_COMBAT_VOICE:{
  5227. int32 value = 0;
  5228. if(sep && sep->arg[0] && sep->IsNumber(0))
  5229. value = atoi(sep->arg[0]);
  5230. client->GetPlayer()->SetCombatVoice(value);
  5231. break;
  5232. }
  5233. case COMMAND_SET_EMOTE_VOICE:{
  5234. int32 value = 0;
  5235. if(sep && sep->arg[0] && sep->IsNumber(0))
  5236. value = atoi(sep->arg[0]);
  5237. client->GetPlayer()->SetEmoteVoice(value);
  5238. break;
  5239. }
  5240. case COMMAND_GIVEITEM:{
  5241. if(sep && sep->arg[0][0] && sep->arg[0][1] && sep->IsNumber(1)){
  5242. Client* itemToClient = zone_list.GetClientByCharName(sep->arg[0]);
  5243. if ( itemToClient == NULL )
  5244. client->Message(CHANNEL_COLOR_YELLOW,"Could not find %s.",sep->arg[0]);
  5245. else
  5246. {
  5247. int32 item_id = atol(sep->arg[1]);
  5248. client->Message(CHANNEL_COLOR_YELLOW,"Gave %s item id %i.",sep->arg[0],item_id);
  5249. itemToClient->AddItem(item_id);
  5250. }
  5251. }
  5252. else
  5253. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /giveitem [name] [item_id]");
  5254. break;
  5255. }
  5256. case COMMAND_REPORT_BUG : { Command_ReportBug(client, sep); break; }
  5257. case COMMAND_INVENTORY : { Command_Inventory(client, sep, command); break; }
  5258. case COMMAND_WEAPONSTATS : { Command_WeaponStats(client); break; }
  5259. case COMMAND_SKILL :
  5260. case COMMAND_SKILL_ADD :
  5261. case COMMAND_SKILL_REMOVE :
  5262. case COMMAND_SKILL_LIST : { Command_Skills(client, sep, command->handler); break; }
  5263. case COMMAND_ZONE_SET : { Command_ZoneSet(client, sep); break; }
  5264. case COMMAND_ZONE_DETAILS : { Command_ZoneDetails(client, sep); break; }
  5265. case COMMAND_ENTITYCOMMAND :
  5266. case COMMAND_ENTITYCOMMAND_LIST : { Command_EntityCommand(client, sep, command->handler); break; }
  5267. case COMMAND_MERCHANT :
  5268. case COMMAND_MERCHANT_LIST : { Command_Merchant(client, sep, command->handler); break; }
  5269. case COMMAND_APPEARANCE :
  5270. case COMMAND_APPEARANCE_LIST : { Command_Appearance(client, sep, command->handler); break; }
  5271. case COMMAND_TRACK : { Command_Track(client); break; }
  5272. case COMMAND_DISTANCE : { Command_Distance(client); break; }
  5273. case COMMAND_INSPECT_PLAYER : { Command_InspectPlayer(client, sep); break; }
  5274. case COMMAND_ZONE_SAFE : { Command_ZoneSafeCoords(client, sep); break; }
  5275. case COMMAND_GUILDSAY : { Command_GuildSay(client, sep); break; }
  5276. case COMMAND_OFFICERSAY : { Command_OfficerSay(client, sep); break; }
  5277. case COMMAND_SET_GUILD_MEMBER_NOTE : { Command_SetGuildMemberNote(client, sep); break; }
  5278. case COMMAND_SET_GUILD_OFFICER_NOTE : { Command_SetGuildOfficerNote(client, sep); break; }
  5279. case COMMAND_GUILD : { Command_Guild(client, sep); break; }
  5280. case COMMAND_CREATE_GUILD : { Command_CreateGuild(client); break; }
  5281. case COMMAND_GUILDS : { Command_Guilds(client); break; }
  5282. case COMMAND_GUILDS_ADD : { Command_GuildsAdd(client, sep); break; }
  5283. case COMMAND_GUILDS_CREATE : { Command_GuildsCreate(client, sep); break; }
  5284. case COMMAND_GUILDS_DELETE : { Command_GuildsDelete(client, sep); break; }
  5285. case COMMAND_GUILDS_LIST : { Command_GuildsList(client); break; }
  5286. case COMMAND_GUILDS_REMOVE : { Command_GuildsRemove(client, sep); break; }
  5287. case COMMAND_CLAIM : { Command_Claim(client, sep); break; }
  5288. case COMMAND_CLEAR_ALL_QUEUED : { Command_ClearAllQueued(client); break; }
  5289. case COMMAND_LOCATION : { Command_Location(client); break; }
  5290. case COMMAND_LOCATION_ADD : { Command_LocationAdd(client, sep); break; }
  5291. case COMMAND_LOCATION_CREATE : { Command_LocationCreate(client, sep); break; }
  5292. case COMMAND_LOCATION_DELETE : { Command_LocationDelete(client, sep); break; }
  5293. case COMMAND_LOCATION_LIST : { Command_LocationList(client, sep); break; }
  5294. case COMMAND_LOCATION_REMOVE : { Command_LocationRemove(client, sep); break; }
  5295. case COMMAND_GRID : { Command_Grid(client, sep); break; }
  5296. case COMMAND_TRY_ON : { Command_TryOn(client, sep); break; }
  5297. case COMMAND_RANDOMIZE : { Command_Randomize(client, sep); break; }
  5298. case COMMAND_AFK : { Command_AFK(client, sep); break; }
  5299. case COMMAND_SHOW_CLOAK : { Command_ShowCloak(client, sep); break; }
  5300. case COMMAND_SHOW_HELM : { Command_ShowHelm(client, sep); break; }
  5301. case COMMAND_SHOW_HOOD : { Command_ShowHood(client, sep); break; }
  5302. case COMMAND_SHOW_HOOD_OR_HELM : { Command_ShowHoodHelm(client, sep); break; }
  5303. case COMMAND_SHOW_RANGED : { Command_ShowRanged(client, sep); break; }
  5304. case COMMAND_STOP_DRINKING : { Command_StopDrinking(client); break; }
  5305. case COMMAND_STOP_EATING : { Command_StopEating(client); break; }
  5306. case COMMAND_TOGGLE_ANONYMOUS : { Command_Toggle_Anonymous(client); break; }
  5307. case COMMAND_TOGGLE_AUTOCONSUME : { Command_Toggle_AutoConsume(client, sep); break; }
  5308. case COMMAND_TOGGLE_BONUS_EXP : { Command_Toggle_BonusXP(client); break; }
  5309. case COMMAND_TOGGLE_COMBAT_EXP : { Command_Toggle_CombatXP(client); break; }
  5310. case COMMAND_TOGGLE_GM_HIDE : { Command_Toggle_GMHide(client); break; }
  5311. case COMMAND_TOGGLE_GM_VANISH : { Command_Toggle_GMVanish(client); break; }
  5312. case COMMAND_TOGGLE_ILLUSIONS : { Command_Toggle_Illusions(client, sep); break; }
  5313. case COMMAND_TOGGLE_LFG : { Command_Toggle_LFG(client); break; }
  5314. case COMMAND_TOGGLE_LFW : { Command_Toggle_LFW(client); break; }
  5315. case COMMAND_TOGGLE_QUEST_EXP : { Command_Toggle_QuestXP(client); break; }
  5316. case COMMAND_TOGGLE_ROLEPLAYING : { Command_Toggle_Roleplaying(client); break; }
  5317. case COMMAND_TOGGLE_DUELS : { Command_Toggle_Duels(client); break; }
  5318. case COMMAND_TOGGLE_TRADES : { Command_Toggle_Trades(client); break; }
  5319. case COMMAND_TOGGLE_GUILDS : { Command_Toggle_Guilds(client); break; }
  5320. case COMMAND_TOGGLE_GROUPS : { Command_Toggle_Groups(client); break; }
  5321. case COMMAND_TOGGLE_RAIDS : { Command_Toggle_Raids(client); break; }
  5322. case COMMAND_TOGGLE_LON : { Command_Toggle_LON(client); break; }
  5323. case COMMAND_TOGGLE_VCINVITE : { Command_Toggle_VoiceChat(client); break; }
  5324. case COMMAND_CANCEL_MAINTAINED : { Command_CancelMaintained(client, sep); break; }
  5325. case COMMAND_MOTD : { Command_MOTD(client); break; }
  5326. case COMMAND_RANDOM : { Command_Random(client, sep); break; }
  5327. case COMMAND_CREATE : { Command_Create(client, sep); break; }
  5328. case COMMAND_CREATEFROMRECIPE : { Command_CreateFromRecipe(client, sep); break; }
  5329. case COMMAND_TITLE : { Command_Title(client); break; }
  5330. case COMMAND_TITLE_LIST : { Command_TitleList(client); break; }
  5331. case COMMAND_TITLE_SETPREFIX : { Command_TitleSetPrefix(client, sep); break; }
  5332. case COMMAND_TITLE_SETSUFFIX : { Command_TitleSetSuffix(client, sep); break; }
  5333. case COMMAND_TITLE_FIX : { Command_TitleFix(client, sep); break; }
  5334. case COMMAND_LANGUAGES : { Command_Languages(client, sep); break; }
  5335. case COMMAND_SET_LANGUAGE : { Command_SetLanguage(client, sep); break; }
  5336. case COMMAND_FOLLOW : { Command_Follow(client, sep); break; }
  5337. case COMMAND_STOP_FOLLOW : { Command_StopFollow(client, sep); break; }
  5338. case COMMAND_LASTNAME : { Command_LastName(client, sep); break; }
  5339. case COMMAND_CONFIRMLASTNAME : { Command_ConfirmLastName(client, sep); break; }
  5340. case COMMAND_PET : { Command_Pet(client, sep); break; }
  5341. case COMMAND_PETNAME : { Command_PetName(client, sep); break; }
  5342. case COMMAND_NAME_PET : { Command_NamePet(client, sep); break; }
  5343. case COMMAND_RENAME : { Command_Rename(client, sep); break; }
  5344. case COMMAND_CONFIRMRENAME : { Command_ConfirmRename(client, sep); break; }
  5345. case COMMAND_PETOPTIONS : { Command_PetOptions(client, sep); break; }
  5346. case COMMAND_START_TRADE : { Command_TradeStart(client, sep); break; }
  5347. case COMMAND_ACCEPT_TRADE : { Command_TradeAccept(client, sep); break; }
  5348. case COMMAND_REJECT_TRADE : { Command_TradeReject(client, sep); break; }
  5349. case COMMAND_CANCEL_TRADE : { Command_TradeCancel(client, sep); break; }
  5350. case COMMAND_SET_TRADE_COIN : { Command_TradeSetCoin(client, sep); break; }
  5351. case COMMAND_ADD_TRADE_COPPER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_COPPER); break; }
  5352. case COMMAND_ADD_TRADE_SILVER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_SILVER); break; }
  5353. case COMMAND_ADD_TRADE_GOLD : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_GOLD); break; }
  5354. case COMMAND_ADD_TRADE_PLAT : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_PLAT); break; }
  5355. case COMMAND_REMOVE_TRADE_COPPER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_COPPER); break; }
  5356. case COMMAND_REMOVE_TRADE_SILVER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_SILVER); break; }
  5357. case COMMAND_REMOVE_TRADE_GOLD : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_GOLD); break; }
  5358. case COMMAND_REMOVE_TRADE_PLAT : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_PLAT); break; }
  5359. case COMMAND_ADD_TRADE_ITEM : { Command_TradeAddItem(client, sep); break; }
  5360. case COMMAND_REMOVE_TRADE_ITEM : { Command_TradeRemoveItem(client, sep); break; }
  5361. case COMMAND_ACCEPT_ADVANCEMENT : { Command_AcceptAdvancement(client, sep); break; }
  5362. case COMMAND_DUEL : { Command_Duel(client, sep); break; }
  5363. case COMMAND_DUELBET : { Command_DuelBet(client, sep); break; }
  5364. case COMMAND_DUEL_ACCEPT : { Command_DuelAccept(client, sep); break; }
  5365. case COMMAND_DUEL_DECLINE : { Command_DuelDecline(client, sep); break; }
  5366. case COMMAND_DUEL_SURRENDER : { Command_DuelSurrender(client, sep); break; }
  5367. case COMMAND_DUEL_TOGGLE : { Command_DuelToggle(client, sep); break; }
  5368. case COMMAND_SPAWN_TEMPLATE : { Command_SpawnTemplate(client, sep); break; }
  5369. //devn00b
  5370. case COMMAND_MOOD : { Command_Mood(client, sep); break;}
  5371. case COMMAND_MODIFY : { Command_Modify(client); break; }
  5372. case COMMAND_MODIFY_CHARACTER : { Command_ModifyCharacter(client, sep); break; }
  5373. case COMMAND_MODIFY_QUEST : { Command_ModifyQuest(client, sep); break; }
  5374. case COMMAND_MODIFY_FACTION : { Command_ModifyFaction(client, sep); break; }
  5375. case COMMAND_MODIFY_GUILD : { Command_ModifyGuild(client, sep); break; }
  5376. case COMMAND_MODIFY_ITEM : { Command_ModifyItem(client, sep); break; }
  5377. case COMMAND_MODIFY_SKILL : { Command_ModifySkill(client, sep); break; }
  5378. case COMMAND_MODIFY_SPAWN : { Command_ModifySpawn(client, sep); break; }
  5379. case COMMAND_MODIFY_SPELL : { Command_ModifySpell(client, sep); break; }
  5380. case COMMAND_MODIFY_ZONE : { Command_ModifyZone(client, sep); break; }
  5381. case COMMAND_JOIN_CHANNEL : { Command_JoinChannel(client, sep); break;}
  5382. case COMMAND_JOIN_CHANNEL_FROM_LOAD: { Command_JoinChannelFromLoad(client, sep); break;}
  5383. case COMMAND_TELL_CHANNEL : { Command_TellChannel(client, sep); break;}
  5384. case COMMAND_LEAVE_CHANNEL : { Command_LeaveChannel(client, sep); break;}
  5385. case COMMAND_WHO_CHANNEL : { Command_WhoChannel(client, sep); break;}
  5386. case COMMAND_RAIN : { Command_Rain(client, sep); break; }
  5387. case COMMAND_WIND : { Command_Wind(client, sep); break; }
  5388. case COMMAND_WEATHER : { Command_Weather(client, sep); break; }
  5389. case COMMAND_FROM_MERCHANT : { Command_SendMerchantWindow(client, sep); break; }
  5390. case COMMAND_TO_MERCHANT : { Command_SendMerchantWindow(client, sep, true); break; }
  5391. case COMMAND_SELECT : { Command_Select(client, sep); break; }
  5392. case COMMAND_SMP : { Command_StationMarketPlace(client, sep); break; }
  5393. case COMMAND_CONSUME_FOOD : { Command_ConsumeFood(client, sep); break; }
  5394. case COMMAND_SET_CONSUME_FOOD : { Command_ConsumeFood(client, sep); break; }
  5395. case COMMAND_AQUAMAN : { Command_Aquaman(client, sep); break; }
  5396. case COMMAND_ATTUNE_INV : { Command_Attune_Inv(client, sep); break; }
  5397. case COMMAND_PLAYER : { Command_Player(client, sep); break; }
  5398. case COMMAND_PLAYER_COINS : { Command_Player_Coins(client, sep); break; }
  5399. case COMMAND_RESET_ZONE_TIMER : { Command_Reset_Zone_Timer(client, sep); break; }
  5400. case COMMAND_ACHIEVEMENT_ADD : { Command_AchievementAdd(client, sep); break; }
  5401. case COMMAND_EDITOR : { Command_Editor(client, sep); break; }
  5402. case COMMAND_ACCEPT_RESURRECTION: { Command_AcceptResurrection(client, sep); break; }
  5403. case COMMAND_DECLINE_RESURRECTION:{ Command_DeclineResurrection(client, sep); break; }
  5404. case COMMAND_TEST : { Command_Test(client, command_parms); break; }
  5405. case COMMAND_SPEED : { Command_Speed(client, sep); break; }
  5406. case COMMAND_BOT : { Command_Bot(client, sep); break; }
  5407. case COMMAND_BOT_CREATE : { Command_Bot_Create(client, sep); break; }
  5408. case COMMAND_BOT_CUSTOMIZE : { Command_Bot_Customize(client, sep); break; }
  5409. case COMMAND_BOT_SPAWN : { Command_Bot_Spawn(client, sep); break; }
  5410. case COMMAND_BOT_LIST : { Command_Bot_List(client, sep); break; }
  5411. case COMMAND_BOT_INV : { Command_Bot_Inv(client, sep); break; }
  5412. case COMMAND_BOT_SETTINGS : { Command_Bot_Settings(client, sep); break; }
  5413. case COMMAND_BOT_HELP : { Command_Bot_Help(client, sep); break; }
  5414. case GET_AA_XML : { Get_AA_Xml(client, sep); break; }
  5415. case ADD_AA : { Add_AA(client, sep); break; }
  5416. case COMMIT_AA_PROFILE : { Commit_AA_Profile(client, sep); break; }
  5417. case BEGIN_AA_PROFILE : { Begin_AA_Profile(client, sep); break; }
  5418. case BACK_AA : { Back_AA(client, sep); break; }
  5419. case REMOVE_AA : { Remove_AA(client, sep); break; }
  5420. case SWITCH_AA_PROFILE : { Switch_AA_Profile(client, sep); break; }
  5421. case CANCEL_AA_PROFILE : { Cancel_AA_Profile(client, sep); break; }
  5422. case SAVE_AA_PROFILE : { Save_AA_Profile(client, sep); break; }
  5423. case COMMAND_TARGETITEM : { Command_TargetItem(client, sep); break; }
  5424. case COMMAND_FINDSPAWN: { Command_FindSpawn(client, sep); break; }
  5425. case COMMAND_MOVECHARACTER: { Command_MoveCharacter(client, sep); break; }
  5426. case COMMAND_CRAFTITEM: {
  5427. Item* item = 0;
  5428. if (sep && sep->IsNumber(0)) {
  5429. int32 item_id = atol(sep->arg[0]);
  5430. int32 quantity = 1;
  5431. if (sep->arg[1] && sep->IsNumber(1))
  5432. quantity = atoi(sep->arg[1]);
  5433. item = new Item(master_item_list.GetItem(item_id));
  5434. if (!item) {
  5435. LogWrite(TRADESKILL__ERROR, 0, "CraftItem", "Item (%u) not found.", item_id);
  5436. }
  5437. else {
  5438. item->details.count = quantity;
  5439. // use CHANNEL_COLOR_CHAT_RELATIONSHIP as that is the same value (4) as it is in a log for this message
  5440. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You created %s.", item->CreateItemLink(client->GetVersion()).c_str());
  5441. bool itemDeleted = false;
  5442. client->AddItem(item, &itemDeleted);
  5443. //Check for crafting quest updates
  5444. int8 update_amt = 0;
  5445. if (!itemDeleted && item->stack_count > 1)
  5446. update_amt = 1;
  5447. else
  5448. update_amt = quantity;
  5449. if(!itemDeleted)
  5450. client->GetPlayer()->CheckQuestsCraftUpdate(item, update_amt);
  5451. }
  5452. }
  5453. else {
  5454. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /craftitem {item_id} [quantity] ");
  5455. }
  5456. break;
  5457. }
  5458. case COMMAND_UNMENTOR:
  5459. case COMMAND_MENTOR: {
  5460. client->GetPlayer()->MentorTarget();
  5461. break;
  5462. }
  5463. case COMMAND_CANCEL_EFFECT: { Command_CancelEffect(client, sep); break; }
  5464. case COMMAND_CUREPLAYER: { Command_CurePlayer(client, sep); break; }
  5465. case COMMAND_SHARE_QUEST: { Command_ShareQuest(client, sep); break; }
  5466. case COMMAND_YELL: { Command_Yell(client, sep); break; }
  5467. case COMMAND_SETAUTOLOOTMODE: { Command_SetAutoLootMode(client, sep); break; }
  5468. case COMMAND_ASSIST: { Command_Assist(client, sep); break; }
  5469. case COMMAND_TARGET: { Command_Target(client, sep); break; }
  5470. case COMMAND_TARGET_PET: { Command_Target_Pet(client, sep); break; }
  5471. default:
  5472. {
  5473. LogWrite(COMMAND__WARNING, 0, "Command", "Unhandled command: %s", command->command.data.c_str());
  5474. break;
  5475. }
  5476. }
  5477. safe_delete(sep);
  5478. }
  5479. /******************** New COMMAND Handler Functions ********************/
  5480. /*
  5481. Started breaking apart the huge switch() for commands into sepErate
  5482. functions so it is easier to locate the blocks of code by command
  5483. -- JA 2012.03.03
  5484. */
  5485. // sample function header
  5486. /*
  5487. Function:
  5488. Purpose :
  5489. Params :
  5490. Dev :
  5491. Example :
  5492. */
  5493. //void Commands::Command()
  5494. //{
  5495. //}
  5496. /*
  5497. Function: Command_AcceptAdvancement()
  5498. Purpose : Player accepts a new advancement option
  5499. Params : Spell ID
  5500. Dev : Jabantiz
  5501. */
  5502. void Commands::Command_AcceptAdvancement(Client* client, Seperator* sep)
  5503. {
  5504. Player *player = client->GetPlayer();
  5505. if (sep && sep->IsSet(0)) {
  5506. int32 trait_id = atoul(sep->arg[0]);
  5507. TraitData* trait = nullptr;
  5508. if(client->GetVersion() <= 561) {
  5509. trait = master_trait_list.GetTraitByItemID(trait_id);
  5510. }
  5511. else {
  5512. trait = master_trait_list.GetTrait(trait_id);
  5513. }
  5514. if(!trait) {
  5515. LogWrite(COMMAND__ERROR, 0, "Command", "Invalid accept advancement of trait %u, no trait found.", trait_id);
  5516. return; // not valid lets not crash!
  5517. }
  5518. if(!master_trait_list.IsPlayerAllowedTrait(client, trait)) {
  5519. client->SimpleMessage(CHANNEL_COLOR_RED, "Not enough trait points to accept trait.");
  5520. return;
  5521. }
  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. if(spell) {
  5527. player->AddSpellBookEntry(trait->spellID, trait->tier, player->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  5528. }
  5529. else {
  5530. client->Message(CHANNEL_COLOR_RED, "ERROR! Trait is not a valid spell id %u may be disabled.", trait->spellID);
  5531. }
  5532. }
  5533. else
  5534. {
  5535. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  5536. if(spell) {
  5537. int8 old_slot = player->GetSpellSlot(spell->GetSpellID());
  5538. player->RemoveSpellBookEntry(spell->GetSpellID());
  5539. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  5540. player->UnlockSpell(spell);
  5541. client->SendSpellUpdate(spell);
  5542. }
  5543. else {
  5544. client->Message(CHANNEL_COLOR_RED, "ERROR! Trait is not a valid spell id %u may be disabled.", trait->spellID);
  5545. }
  5546. }
  5547. // Spell book update
  5548. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  5549. client->QueuePacket(master_trait_list.GetTraitListPacket(client));
  5550. if(client->GetVersion() <= 561) {
  5551. master_trait_list.ChooseNextTrait(client);
  5552. }
  5553. }
  5554. }
  5555. /*
  5556. Function:
  5557. Purpose :
  5558. Params :
  5559. Dev :
  5560. Example :
  5561. */
  5562. void Commands::Command_AFK(Client* client, Seperator* sep)
  5563. {
  5564. Player* player = client->GetPlayer();
  5565. player->toggle_character_flag(CF_AFK);
  5566. client->Message(CHANNEL_COLOR_YELLOW,"You are %s afk.", client->GetPlayer()->get_character_flag(CF_AFK)?"now":"no longer");
  5567. if (player->get_character_flag(CF_AFK))
  5568. {
  5569. if (sep && sep->argplus[0])
  5570. player->SetAwayMessage("I am away from the keyboard, " + string(sep->argplus[0]));
  5571. else
  5572. player->SetAwayMessage("Sorry, I am A.F.K. (Away From Keyboard)");
  5573. string message = string(player->GetName()) + " is going afk.";
  5574. Spawn* target = player->GetTarget();
  5575. if (target && target != player)
  5576. {
  5577. message = string(player->GetName()) + " tells " + string(target->GetName()) + " that ";
  5578. player->GetGender() == 1 ? message += "he" : message += "she";
  5579. message += " is going afk.";
  5580. }
  5581. player->GetZone()->SimpleMessage(CHANNEL_COLOR_YELLOW, message.c_str(), player, 30);
  5582. }
  5583. if (player->get_character_flag(CF_AFK))
  5584. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_AFK);
  5585. else
  5586. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_AFK);
  5587. }
  5588. /*
  5589. Function: Command_Appearance()
  5590. Purpose : Handles /appearance commands
  5591. Params : list
  5592. Dev : Scatman
  5593. Example : /appearance list
  5594. */
  5595. void Commands::Command_Appearance(Client* client, Seperator* sep, int handler)
  5596. {
  5597. if( handler == COMMAND_APPEARANCE )
  5598. {
  5599. // /appearance command by itself shows help (to be extended)
  5600. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  5601. return;
  5602. }
  5603. else if( handler == COMMAND_APPEARANCE_LIST )
  5604. {
  5605. // /appearance list command expects "name" param
  5606. if (sep && sep->arg[0])
  5607. {
  5608. const char* appearance_name = sep->argplus[0];
  5609. client->Message(CHANNEL_COLOR_YELLOW, "Listing appearances like '%s':", appearance_name);
  5610. vector<int16>* appearances = database.GetAppearanceIDsLikeName(string(appearance_name));
  5611. if (appearances)
  5612. {
  5613. vector<int16>::iterator itr;
  5614. for (itr = appearances->begin(); itr != appearances->end(); itr++)
  5615. {
  5616. int16 id = *itr;
  5617. string name = database.GetAppearanceName(id);
  5618. if (ToLower(name).find(ToLower(string(appearance_name))) < 0xFFFFFFFF)
  5619. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", name.c_str(), id);
  5620. }
  5621. safe_delete(appearances);
  5622. }
  5623. }
  5624. else // no param
  5625. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  5626. }
  5627. }
  5628. /*
  5629. Function: Command_Claim()
  5630. Purpose : Summon veteran rewards
  5631. Params : nothing = show claim window, any number claims that item.
  5632. Dev : devn00b
  5633. Example : /claim 0 (claims the 1st item added to the list claim[0])
  5634. */
  5635. void Commands::Command_Claim(Client* client, Seperator* sep)
  5636. {
  5637. //if we were passed a claim id
  5638. if (sep && sep->argplus[0] && sep->IsNumber(0))
  5639. {
  5640. int32 char_id = client->GetCharacterID();
  5641. int8 my_claim_id = atoi(sep->argplus[0]);
  5642. vector<ClaimItems> claim = database.LoadCharacterClaimItems(char_id);
  5643. Item* item = master_item_list.GetItem(claim[my_claim_id].item_id);
  5644. database.ClaimItem(char_id, item->details.item_id, client);
  5645. return;
  5646. }
  5647. else {
  5648. //if no arg just send the window.
  5649. client->ShowClaimWindow();
  5650. return;
  5651. }
  5652. return;
  5653. }
  5654. /*
  5655. Function: Command_ClearAllQueued()
  5656. Purpose :
  5657. Params :
  5658. Dev :
  5659. Example :
  5660. */
  5661. void Commands::Command_ClearAllQueued(Client* client)
  5662. {
  5663. ZoneServer* zone = client->GetPlayer()->GetZone();
  5664. if (zone && zone->GetSpellProcess())
  5665. zone->GetSpellProcess()->RemoveSpellFromQueue(client->GetPlayer());
  5666. }
  5667. /*
  5668. Function: Command_CancelMaintained()
  5669. Purpose : Cancels maintained spells
  5670. Params : Maintained Spell Index
  5671. Dev : Zcoretri
  5672. Example : /cancel_maintained 1 - would cancel the spell in slot 1 of Maintained Spells list
  5673. */
  5674. void Commands::Command_CancelMaintained(Client* client, Seperator* sep)
  5675. {
  5676. if (sep && sep->arg[0] && sep->IsNumber(0))
  5677. {
  5678. int32 spell_index = atoul(sep->arg[0]);
  5679. if(spell_index > 29)
  5680. return;
  5681. client->GetPlayer()->MMaintainedSpells.readlock(__FUNCTION__, __LINE__);
  5682. MaintainedEffects mEffects = client->GetPlayer()->GetInfoStruct()->maintained_effects[spell_index];
  5683. client->GetPlayer()->MMaintainedSpells.releasereadlock(__FUNCTION__, __LINE__);
  5684. if (!client->GetPlayer()->GetZone()->GetSpellProcess()->DeleteCasterSpell(mEffects.spell, "canceled", false))
  5685. client->Message(CHANNEL_COLOR_RED, "The maintained spell could not be cancelled.");
  5686. }
  5687. }
  5688. /*
  5689. Function: Command_Create()
  5690. Purpose : Handler for starting Tradeskilling table
  5691. Params :
  5692. Dev : Zcoretri
  5693. Example :
  5694. */
  5695. void Commands::Command_Create(Client* client, Seperator* sep)
  5696. {
  5697. PrintSep(sep, "COMMAND_CREATE");
  5698. client->ShowRecipeBook();
  5699. }
  5700. void Commands::Command_CreateFromRecipe(Client* client, Seperator* sep)
  5701. {
  5702. PrintSep(sep, "COMMAND_CREATEFROMRECIPE");
  5703. if (sep && sep->arg[0] && sep->IsNumber(0))
  5704. ClientPacketFunctions::SendCreateFromRecipe(client, atoul(sep->arg[0]));
  5705. }
  5706. /*
  5707. Function: Command_Distance()
  5708. Purpose : Displays distance from targeted spawn
  5709. Params :
  5710. Dev : Scatman
  5711. Example : /distance
  5712. */
  5713. void Commands::Command_Distance(Client* client)
  5714. {
  5715. Spawn* target = client->GetPlayer()->GetTarget();
  5716. if (target)
  5717. client->Message(CHANNEL_COLOR_YELLOW, "Your distance from %s is %f", target->GetName(), client->GetPlayer()->GetDistance(target));
  5718. else
  5719. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must have a spawn targeted to use /distance");
  5720. }
  5721. /*
  5722. Function: Command_Duel()
  5723. Purpose : Handle the /duel commands - not yet implemented
  5724. Params : unknown
  5725. Dev :
  5726. Example :
  5727. */
  5728. void Commands::Command_Duel(Client* client, Seperator* sep)
  5729. {
  5730. PrintSep(sep, "COMMAND_DUEL");
  5731. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Command");
  5732. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5733. }
  5734. /*
  5735. Function: Command_DuelBet()
  5736. Purpose : Handle the /duel commands - not yet implemented
  5737. Params : unknown
  5738. Dev :
  5739. Example :
  5740. */
  5741. void Commands::Command_DuelBet(Client* client, Seperator* sep)
  5742. {
  5743. PrintSep(sep, "COMMAND_DUELBET");
  5744. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Bet Command");
  5745. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5746. }
  5747. /*
  5748. Function: Command_DuelAccept()
  5749. Purpose : Handle the /duel commands - not yet implemented
  5750. Params : unknown
  5751. Dev :
  5752. Example :
  5753. */
  5754. void Commands::Command_DuelAccept(Client* client, Seperator* sep)
  5755. {
  5756. PrintSep(sep, "COMMAND_DUEL_ACCEPT");
  5757. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Accept Duel Command");
  5758. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5759. }
  5760. /*
  5761. Function: Command_DuelDecline()
  5762. Purpose : Handle the /duel commands - not yet implemented
  5763. Params : unknown
  5764. Dev :
  5765. Example :
  5766. */
  5767. void Commands::Command_DuelDecline(Client* client, Seperator* sep)
  5768. {
  5769. PrintSep(sep, "COMMAND_DUEL_DECLINE");
  5770. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Decline Duel Request Command");
  5771. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5772. }
  5773. /*
  5774. Function: Command_DuelSurrender()
  5775. Purpose : Handle the /duel commands - not yet implemented
  5776. Params : unknown
  5777. Dev :
  5778. Example :
  5779. */
  5780. void Commands::Command_DuelSurrender(Client* client, Seperator* sep)
  5781. {
  5782. PrintSep(sep, "COMMAND_DUEL_SURRENDER");
  5783. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Surrender Duel Command");
  5784. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5785. // JA, just messin around ;)
  5786. char surrender[64];
  5787. sprintf(surrender, "%s surrendered like a cowardly dog!", client->GetPlayer()->GetName());
  5788. zone_list.HandleGlobalAnnouncement(surrender);
  5789. }
  5790. /*
  5791. Function: Command_DuelToggle()
  5792. Purpose : Handle the /duel commands - not yet implemented
  5793. Params : unknown
  5794. Dev :
  5795. Example :
  5796. */
  5797. void Commands::Command_DuelToggle(Client* client, Seperator* sep)
  5798. {
  5799. PrintSep(sep, "COMMAND_DUEL");
  5800. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Commands");
  5801. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5802. }
  5803. /*
  5804. Function:
  5805. Purpose :
  5806. Params :
  5807. Dev :
  5808. Example :
  5809. */
  5810. void Commands::Command_EntityCommand(Client* client, Seperator* sep, int handler)
  5811. {
  5812. if( handler == COMMAND_ENTITYCOMMAND )
  5813. {
  5814. // /entitycommand command by itself shows help (to be extended)
  5815. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  5816. return;
  5817. }
  5818. else if( handler == COMMAND_ENTITYCOMMAND_LIST )
  5819. {
  5820. // /entitycommand list command expects "name" param
  5821. if (sep && sep->arg[0])
  5822. {
  5823. const char* entity_command_name = sep->argplus[0];
  5824. client->Message(CHANNEL_COLOR_YELLOW, "Listing entity commands like '%s':", entity_command_name);
  5825. map<int32, vector<EntityCommand*>*>* entity_command_list_all = client->GetCurrentZone()->GetEntityCommandListAll();
  5826. map<int32, vector<EntityCommand*>*>::iterator itr;
  5827. for (itr = entity_command_list_all->begin(); itr != entity_command_list_all->end(); itr++)
  5828. {
  5829. vector<EntityCommand*>* entity_command_list = itr->second;
  5830. vector<EntityCommand*>::iterator itr2;
  5831. for (itr2 = entity_command_list->begin(); itr2 != entity_command_list->end(); itr2++)
  5832. {
  5833. EntityCommand* entity_command = *itr2;
  5834. if (ToLower(entity_command->name).find(ToLower(string(entity_command_name))) < 0xFFFFFFFF)
  5835. 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);
  5836. }
  5837. }
  5838. }
  5839. else // no command name
  5840. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  5841. }
  5842. }
  5843. /*
  5844. Function: Command_Follow()
  5845. Purpose : Handle the /follow command - not yet implemented
  5846. Params :
  5847. Dev :
  5848. Example :
  5849. */
  5850. void Commands::Command_Follow(Client* client, Seperator* sep)
  5851. {
  5852. PrintSep(sep, "COMMAND_FOLLOW");
  5853. // flag to toggle if the players target is in the players group
  5854. bool targetInGroup = false;
  5855. // get a pointer to the players group
  5856. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  5857. // If the player has a group and has a target
  5858. if (gmi && client->GetPlayer()->GetTarget()) {
  5859. deque<GroupMemberInfo*>::iterator itr;
  5860. world.GetGroupManager()->GroupLock(__FUNCTION__, __LINE__);
  5861. PlayerGroup* group = world.GetGroupManager()->GetGroup(gmi->group_id);
  5862. if (group)
  5863. {
  5864. group->MGroupMembers.readlock(__FUNCTION__, __LINE__);
  5865. deque<GroupMemberInfo*>* members = group->GetMembers();
  5866. // Loop through the group members
  5867. for (itr = members->begin(); itr != members->end(); itr++) {
  5868. // If a group member matches a target
  5869. if ((*itr)->member && (*itr)->member == client->GetPlayer()->GetTarget()) {
  5870. // toggle the flag and break the loop
  5871. targetInGroup = true;
  5872. break;
  5873. }
  5874. }
  5875. group->MGroupMembers.releasereadlock(__FUNCTION__, __LINE__);
  5876. }
  5877. world.GetGroupManager()->ReleaseGroupLock(__FUNCTION__, __LINE__);
  5878. }
  5879. if (targetInGroup) {
  5880. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  5881. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You start to follow %s.", client->GetPlayer()->GetTarget()->GetName());
  5882. client->GetPlayer()->SetFollowTarget(client->GetPlayer()->GetTarget());
  5883. client->GetPlayer()->info_changed = true;
  5884. client->GetPlayer()->changed = true;
  5885. }
  5886. else
  5887. client->Message(CHANNEL_NARRATIVE, "You must first select a group member to follow.");
  5888. }
  5889. /*
  5890. Function: Command_StopFollow()
  5891. Purpose : Handle the /stop_follow command - not yet implemented
  5892. Params :
  5893. Dev :
  5894. Example :
  5895. */
  5896. void Commands::Command_StopFollow(Client* client, Seperator* sep)
  5897. {
  5898. PrintSep(sep, "COMMAND_STOP_FOLLOW");
  5899. if (client->GetPlayer()->GetFollowTarget()) {
  5900. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  5901. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You are no longer following %s", client->GetPlayer()->GetFollowTarget()->GetName());
  5902. client->GetPlayer()->SetFollowTarget(0);
  5903. client->GetPlayer()->info_changed = true;
  5904. client->GetPlayer()->changed = true;
  5905. }
  5906. }
  5907. /*
  5908. Function: Command_Grid()
  5909. Purpose : Show player's current Grid ID
  5910. Params :
  5911. Dev : Scatman
  5912. Example : /grid
  5913. */
  5914. void Commands::Command_Grid(Client* client, Seperator* sep)
  5915. {
  5916. if (client->GetPlayer()->GetMap() != nullptr) {
  5917. if(sep && sep->arg[0][0] && strncasecmp("spawns", sep->arg[0], 6) == 0) {
  5918. int32 grid = client->GetPlayer()->GetLocation();
  5919. if(sep->IsNumber(1))
  5920. grid = atoul(sep->arg[1]);
  5921. client->GetCurrentZone()->SendClientSpawnListInGrid(client, grid);
  5922. }
  5923. if(sep && sep->arg[0][0] && strncasecmp("boundary", sep->arg[0], 8) == 0) {
  5924. int32 grid = client->GetPlayer()->GetLocation();
  5925. if(sep->IsNumber(1))
  5926. grid = atoul(sep->arg[1]);
  5927. if(!client->GetPlayer()->GetMap()) {
  5928. client->Message(CHANNEL_COLOR_RED, "No map to check grid!");
  5929. return;
  5930. }
  5931. GridMapBorder* gmb = client->GetPlayer()->GetMap()->GetMapGridBorder(grid, false);
  5932. if(gmb) {
  5933. client->Message(CHANNEL_COLOR_YELLOW, "Grid %u border MinX %f MaxX %f, MinY %f MaxY %f, MinZ %f MaxZ %f", grid, gmb->m_MinX, gmb->m_MaxX, gmb->m_MinY, gmb->m_MaxY, gmb->m_MinZ, gmb->m_MaxZ);
  5934. }
  5935. else {
  5936. client->Message(CHANNEL_COLOR_RED, "Grid %u has no grid map border", grid);
  5937. }
  5938. }
  5939. else {
  5940. client->Message(CHANNEL_COLOR_YELLOW, "Your Grid ID is %u", client->GetPlayer()->GetLocation());
  5941. auto loc = glm::vec3(client->GetPlayer()->GetX(), client->GetPlayer()->GetZ(), client->GetPlayer()->GetY());
  5942. uint32 GridID = 0;
  5943. uint32 WidgetID = 0;
  5944. float new_z = client->GetPlayer()->FindBestZ(loc, nullptr, &GridID, &WidgetID);
  5945. float minY = client->GetPlayer()->GetMap()->GetMinY();
  5946. float maxY = client->GetPlayer()->GetMap()->GetMaxY();
  5947. float minZ = client->GetPlayer()->GetMap()->GetMinZ();
  5948. float maxZ = client->GetPlayer()->GetMap()->GetMaxZ();
  5949. int32 grid_spawn_count = client->GetPlayer()->GetZone()->GetSpawnCountInGrid(GridID);
  5950. 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);
  5951. }
  5952. }
  5953. }
  5954. /*
  5955. Function: Command_Guild()
  5956. Purpose : Handler for all UI-related guild commands
  5957. Dev : Scatman
  5958. */
  5959. void Commands::Command_Guild(Client* client, Seperator* sep)
  5960. {
  5961. Guild* guild = client->GetPlayer()->GetGuild();
  5962. if (sep && sep->GetMaxArgNum() > 0 && sep->arg[0])
  5963. {
  5964. const char* command = sep->arg[0];
  5965. int32 length = strlen(command);
  5966. LogWrite(COMMAND__DEBUG, 0, "Command", "Guild Command: %s", command);
  5967. if (strncmp(command, "rank_name", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && guild)
  5968. guild->SetRankName(atoi(sep->arg[1]), sep->argplus[2]);
  5969. else if (strncmp(command, "rank_permission", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  5970. guild->SetPermission(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  5971. else if (strncmp(command, "filter_event", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  5972. guild->SetEventFilter(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  5973. else if (strncmp(command, "kick", length) == 0 && sep->arg[1] && guild)
  5974. guild->KickGuildMember(client, sep->arg[1]);
  5975. else if (strncmp(command, "demote", length) == 0 && sep->arg[1] && guild)
  5976. guild->DemoteGuildMember(client, sep->arg[1]);
  5977. else if (strncmp(command, "promote", length) == 0 && sep->arg[1] && guild)
  5978. guild->PromoteGuildMember(client, sep->arg[1]);
  5979. else if (strncmp(command, "points", length) == 0 && guild)
  5980. {
  5981. if (sep->arg[1] && strncmp(sep->arg[1], "add", length) == 0)
  5982. {
  5983. if (sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  5984. {
  5985. float points = atof(sep->arg[2]);
  5986. const char* option = sep->arg[3];
  5987. const char* comment = sep->argplus[4];
  5988. if (strncmp(option, "all", strlen(option)) == 0)
  5989. guild->AddPointsToAll(client, points, comment);
  5990. else if (strncmp(option, "online", strlen(option)) == 0)
  5991. guild->AddPointsToAllOnline(client, points, comment);
  5992. else if (strncmp(option, "group", strlen(option)) == 0)
  5993. guild->AddPointsToGroup(client, points, comment);
  5994. else if (strncmp(option, "raid", strlen(option)) == 0)
  5995. guild->AddPointsToRaid(client, points, comment);
  5996. else
  5997. guild->AddPointsToGuildMember(client, points, option, comment);
  5998. }
  5999. }
  6000. else if (sep->arg[1] && strncmp(sep->arg[1], "view", strlen(sep->arg[1])) == 0 && sep->arg[2])
  6001. guild->ViewGuildMemberPoints(client, sep->arg[2]);
  6002. else
  6003. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild points command: %s", sep->argplus[0]);
  6004. }
  6005. else if (strncmp(command, "motd", length) == 0 && sep->arg[1] && guild)
  6006. guild->SetMOTD(sep->argplus[1]);
  6007. else if (strncmp(command, "recruiting", length) == 0 && guild)
  6008. {
  6009. if (sep->arg[1])
  6010. {
  6011. const char* option = sep->arg[1];
  6012. if (strncmp(option, "short_text", strlen(option)) == 0 && sep->arg[2])
  6013. guild->SetRecruitingShortDesc(sep->argplus[2]);
  6014. else if (strncmp(option, "long_text", strlen(option)) == 0 && sep->arg[2])
  6015. guild->SetRecruitingFullDesc(sep->argplus[2]);
  6016. else if (strncmp(option, "flag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  6017. guild->SetRecruitingFlag(atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  6018. else if (strncmp(option, "min_level", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  6019. guild->SetRecruitingMinLevel(atoi(sep->arg[2]));
  6020. else if (strncmp(option, "playstyle", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  6021. guild->SetRecruitingPlayStyle(atoi(sep->arg[2]));
  6022. else if (strncmp(option, "tag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && sep->IsNumber(3))
  6023. guild->SetRecruitingDescTag(atoi(sep->arg[2]), atoi(sep->arg[3]));
  6024. else if (strncmp(command, "recruiting", strlen(option)) == 0)
  6025. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_RECRUITING_FOR_GUILD, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  6026. else
  6027. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  6028. }
  6029. else
  6030. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  6031. }
  6032. else if (strncmp(command, "notify_online", length) == 0 && sep->arg[1] && guild)
  6033. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_NOTIFY_LOGINS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  6034. else if (strncmp(command, "event_privacy", length) == 0 && sep->arg[1] && guild)
  6035. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_DONT_GENERATE_EVENTS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  6036. else if (strncmp(command, "recruiter", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  6037. guild->SetGuildRecruiter(client, sep->arg[1], strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  6038. else if (strncmp(command, "recruiter_description", length) == 0 && sep->arg[1] && guild)
  6039. guild->SetGuildRecruiterDescription(client, sep->argplus[1]);
  6040. else if (strncmp(command, "lock_event", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  6041. guild->LockGuildEvent(atoul(sep->arg[1]), strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  6042. else if (strncmp(command, "delete_event", length) == 0 && sep->arg[1] && guild)
  6043. guild->DeleteGuildEvent(atoul(sep->arg[1]));
  6044. else if (strncmp(command, "invite", length) == 0 && guild)
  6045. {
  6046. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  6047. guild->InvitePlayer(client, sep->arg[1]);
  6048. else
  6049. {
  6050. Spawn* target = client->GetPlayer()->GetTarget();
  6051. if (target)
  6052. {
  6053. if (target->IsPlayer())
  6054. guild->InvitePlayer(client, target->GetName());
  6055. else
  6056. client->Message(CHANNEL_NARRATIVE, "%s is not a player.", target->GetName());
  6057. }
  6058. }
  6059. }
  6060. else if (strncmp(command, "accept", length) == 0)
  6061. {
  6062. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  6063. if (pgi && pgi->guild && pgi->invited_by)
  6064. pgi->guild->AddNewGuildMember(client, pgi->invited_by->GetName());
  6065. client->SetPendingGuildInvite(0);
  6066. }
  6067. else if (strncmp(command, "decline", length) == 0)
  6068. {
  6069. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  6070. if (pgi && pgi->guild && pgi->invited_by && pgi->invited_by->IsPlayer())
  6071. {
  6072. Client* client_inviter = ((Player*)pgi->invited_by)->GetClient();
  6073. if (client_inviter) {
  6074. client_inviter->Message(CHANNEL_NARRATIVE, "%s has declined your invitation to join %s.", client->GetPlayer()->GetName(), pgi->guild->GetName());
  6075. }
  6076. }
  6077. client->SetPendingGuildInvite(0);
  6078. }
  6079. else if (strncmp(command, "create", length) == 0 && sep->arg[1])
  6080. {
  6081. const char* guild_name = sep->argplus[1];
  6082. if (!guild_list.GetGuild(guild_name))
  6083. world.CreateGuild(guild_name, client, client->GetPlayer()->GetGroupMemberInfo() ? client->GetPlayer()->GetGroupMemberInfo()->group_id : 0);
  6084. else
  6085. client->SimpleMessage(CHANNEL_NARRATIVE, "A guild with that name already exists.");
  6086. }
  6087. else if (strncmp(command, "search", length) == 0)
  6088. client->ShowGuildSearchWindow();
  6089. else if (strncmp(command, "recruiting_details", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  6090. {
  6091. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  6092. if (to_guild)
  6093. to_guild->SendGuildRecruitingDetails(client);
  6094. }
  6095. else if (strncmp(command, "recruiting_image", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  6096. {
  6097. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  6098. if (to_guild)
  6099. to_guild->SendGuildRecruitingImages(client);
  6100. }
  6101. else if (strncmp(command, "recruiter_adventure_class", length) == 0)
  6102. {
  6103. if (sep->arg[1])
  6104. {
  6105. const char* option = sep->arg[1];
  6106. if (strncmp(option, "toggle", strlen(option)) == 0)
  6107. guild->ToggleGuildRecruiterAdventureClass(client);
  6108. }
  6109. else
  6110. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiter_adventure_class command: '%s'", sep->argplus[0]);
  6111. }
  6112. else if (strncmp(command, "display_heraldry", length) == 0)
  6113. {
  6114. // JA: not sure this is right...
  6115. client->GetPlayer()->toggle_character_flag(CF_SHOW_GUILD_HERALDRY);
  6116. client->GetPlayer()->SetCharSheetChanged(true);
  6117. }
  6118. else
  6119. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild command: '%s'", sep->argplus[0]);
  6120. }
  6121. }
  6122. /*
  6123. Function: Command_GuildCreate()
  6124. Purpose : Display's in-game Guild Creation window
  6125. Dev : Scatman
  6126. */
  6127. void Commands::Command_CreateGuild(Client* client)
  6128. {
  6129. client->SendGuildCreateWindow();
  6130. }
  6131. /*
  6132. Function: Command_SetGuildOfficerNote()
  6133. Purpose :
  6134. Dev : Scatman
  6135. */
  6136. void Commands::Command_SetGuildOfficerNote(Client* client, Seperator* sep)
  6137. {
  6138. if (sep && sep->arg[0] && sep->arg[1])
  6139. {
  6140. Guild* guild = client->GetPlayer()->GetGuild();
  6141. if (guild)
  6142. guild->SetGuildOfficerNote(sep->arg[0], sep->argplus[1]);
  6143. }
  6144. }
  6145. /*
  6146. Function: Command_SetGuildMemberNote()
  6147. Purpose :
  6148. Dev : Scatman
  6149. */
  6150. void Commands::Command_SetGuildMemberNote(Client* client, Seperator* sep)
  6151. {
  6152. if (sep && sep->arg[0] && sep->arg[1])
  6153. {
  6154. Guild* guild = client->GetPlayer()->GetGuild();
  6155. if (guild)
  6156. guild->SetGuildMemberNote(sep->arg[0], sep->argplus[1]);
  6157. }
  6158. }
  6159. /*
  6160. Function: Command_GuildSay()
  6161. Purpose :
  6162. Dev : Scatman
  6163. */
  6164. void Commands::Command_GuildSay(Client* client, Seperator* sep)
  6165. {
  6166. Guild* guild = client->GetPlayer()->GetGuild();
  6167. if (guild)
  6168. {
  6169. if (sep && sep->arg[0])
  6170. guild->HandleGuildSay(client, sep->argplus[0]);
  6171. }
  6172. else
  6173. client->SimpleMessage(CHANNEL_NARRATIVE, "You are not a member of a guild");
  6174. }
  6175. /*
  6176. Function: Command_OfficerSay()
  6177. Purpose :
  6178. Dev : Scatman
  6179. */
  6180. void Commands::Command_OfficerSay(Client* client, Seperator* sep)
  6181. {
  6182. Guild* guild = client->GetPlayer()->GetGuild();
  6183. if (guild)
  6184. {
  6185. if (sep && sep->arg[0])
  6186. guild->HandleOfficerSay(client, sep->argplus[0]);
  6187. }
  6188. else
  6189. client->SimpleMessage(CHANNEL_NARRATIVE, "You are not a member of a guild");
  6190. }
  6191. /*
  6192. Function: Command_Guilds()
  6193. Purpose : Shows help for /guild command
  6194. Params :
  6195. Dev : Scatman
  6196. Example :
  6197. */
  6198. void Commands::Command_Guilds(Client* client)
  6199. {
  6200. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds [create|delete|add|remove|list]");
  6201. }
  6202. /*
  6203. Function: Command_GuildsAdd()
  6204. Purpose : Add's players to a guild
  6205. Params : guild_name|guild_id, player name
  6206. Dev : Scatman
  6207. Example : /guilds add 1 Admin = adds player Admin to guild_id 1
  6208. */
  6209. void Commands::Command_GuildsAdd(Client* client, Seperator* sep)
  6210. {
  6211. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  6212. {
  6213. Guild* guild = 0;
  6214. bool found = true;
  6215. if (sep->IsNumber(0))
  6216. {
  6217. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  6218. if (!guild)
  6219. {
  6220. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  6221. found = false;
  6222. }
  6223. }
  6224. else
  6225. {
  6226. guild = guild_list.GetGuild(sep->arg[0]);
  6227. if (!guild)
  6228. {
  6229. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  6230. found = false;
  6231. }
  6232. }
  6233. if (found)
  6234. {
  6235. Client* to_client = 0;
  6236. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  6237. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  6238. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  6239. to_client = ((Player*)client->GetPlayer()->GetTarget())->GetClient();
  6240. if (to_client)
  6241. guild->InvitePlayer(client, to_client->GetPlayer()->GetName());
  6242. else
  6243. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  6244. }
  6245. }
  6246. else
  6247. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds add [guild name|guild id] (player name).");
  6248. }
  6249. /*
  6250. Function: Command_GuildsCreate()
  6251. Purpose : Creates a guild
  6252. Params : guild_name, player_name (optional)
  6253. Dev : Scatman
  6254. Example : /guilds create [guild name] (player name)
  6255. */
  6256. void Commands::Command_GuildsCreate(Client* client, Seperator* sep)
  6257. {
  6258. if (sep && sep->arg[0])
  6259. {
  6260. const char* guild_name = sep->arg[0];
  6261. if (!guild_list.GetGuild(guild_name))
  6262. {
  6263. bool ret = false;
  6264. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  6265. {
  6266. Client* to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  6267. if (to_client)
  6268. {
  6269. world.CreateGuild(guild_name, to_client);
  6270. ret = true;
  6271. }
  6272. else
  6273. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player with name '%s'", sep->arg[1]);
  6274. }
  6275. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  6276. {
  6277. Client* to_client = ((Player*)client->GetPlayer()->GetTarget())->GetClient();
  6278. if (to_client)
  6279. {
  6280. world.CreateGuild(guild_name, to_client);
  6281. ret = true;
  6282. }
  6283. }
  6284. else
  6285. {
  6286. world.CreateGuild(guild_name);
  6287. ret = true;
  6288. }
  6289. if (ret)
  6290. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully created.", guild_name);
  6291. else
  6292. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the guild.");
  6293. }
  6294. else
  6295. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' already exists.", guild_name);
  6296. }
  6297. else
  6298. 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.");
  6299. }
  6300. /*
  6301. Function: Command_GuildsDelete()
  6302. Purpose : Delete's a guild
  6303. Params : guild name
  6304. Dev : Scatman
  6305. Example : /guilds delete Test
  6306. */
  6307. void Commands::Command_GuildsDelete(Client* client, Seperator* sep)
  6308. {
  6309. if (sep && sep->arg[0])
  6310. {
  6311. Guild* guild = 0;
  6312. bool found = true;
  6313. if (sep->IsNumber(0))
  6314. {
  6315. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  6316. if (!guild)
  6317. {
  6318. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  6319. found = false;
  6320. }
  6321. }
  6322. else
  6323. {
  6324. guild = guild_list.GetGuild(sep->arg[0]);
  6325. if (!guild)
  6326. {
  6327. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  6328. found = false;
  6329. }
  6330. }
  6331. if (found)
  6332. {
  6333. guild->RemoveAllGuildMembers();
  6334. database.DeleteGuild(guild);
  6335. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully deleted.", guild->GetName());
  6336. guild_list.RemoveGuild(guild, true);
  6337. }
  6338. }
  6339. else
  6340. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds delete [guild name].");
  6341. }
  6342. /*
  6343. Function: Command_GuildsList()
  6344. Purpose : Lists current guilds on server
  6345. Params :
  6346. Dev : Scatman
  6347. Example : /guilds list
  6348. */
  6349. void Commands::Command_GuildsList(Client* client)
  6350. {
  6351. MutexMap<int32, Guild*>* guilds = guild_list.GetGuilds();
  6352. MutexMap<int32, Guild*>::iterator itr = guilds->begin();
  6353. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Guild List:");
  6354. if (guilds->size() == 0)
  6355. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "None.");
  6356. else {
  6357. while (itr.Next()) {
  6358. Guild* guild = itr.second;
  6359. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", guild->GetID(), guild->GetName());
  6360. }
  6361. }
  6362. }
  6363. /*
  6364. Function: Command_GuildsRemove()
  6365. Purpose : Removes a player from a guild
  6366. Params : guild name|guild id, player name
  6367. Dev : Scatman
  6368. Example : /guilds remove 1 Admin = removes Admin from guild 1
  6369. */
  6370. void Commands::Command_GuildsRemove(Client* client, Seperator* sep)
  6371. {
  6372. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  6373. {
  6374. Guild* guild = 0;
  6375. bool found = true;
  6376. if (sep->IsNumber(0))
  6377. {
  6378. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  6379. if (!guild)
  6380. {
  6381. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  6382. found = false;
  6383. }
  6384. }
  6385. else
  6386. {
  6387. guild = guild_list.GetGuild(sep->arg[0]);
  6388. if (!guild)
  6389. {
  6390. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  6391. found = false;
  6392. }
  6393. }
  6394. if (found)
  6395. {
  6396. Client* to_client = 0;
  6397. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  6398. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  6399. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  6400. to_client = ((Player*)client->GetPlayer()->GetTarget())->GetClient();
  6401. if (to_client)
  6402. {
  6403. Player* to_player = to_client->GetPlayer();
  6404. if (to_player->GetGuild())
  6405. {
  6406. if (to_player->GetGuild() == guild)
  6407. {
  6408. guild->KickGuildMember(client, to_player->GetName());
  6409. }
  6410. else
  6411. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in the guild '%s'.", to_player->GetName(), guild->GetName());
  6412. }
  6413. else
  6414. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in a guild.", to_player->GetName());
  6415. }
  6416. else
  6417. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  6418. }
  6419. }
  6420. else
  6421. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds remove [guild name|guild id] (player name).");
  6422. }
  6423. /*
  6424. Function: Command_InspectPlayer()
  6425. Purpose : Handle the Inspect functions
  6426. Params : Client to inspect
  6427. Dev : Scatman
  6428. Example : /inspect Scatman
  6429. */
  6430. void Commands::Command_InspectPlayer(Client* client, Seperator* sep)
  6431. {
  6432. if (sep && sep->arg[0])
  6433. {
  6434. Client* inspect_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  6435. if (inspect_client)
  6436. client->InspectPlayer(inspect_client->GetPlayer());
  6437. }
  6438. else
  6439. {
  6440. Spawn* target = client->GetPlayer()->GetTarget();
  6441. if (target && target->IsPlayer())
  6442. client->InspectPlayer((Player*)target);
  6443. }
  6444. }
  6445. /*
  6446. Function: Command_Inventory()
  6447. Purpose : Handle changes in player inventory
  6448. Params : <TBD>
  6449. Dev : All
  6450. Example : /inventory delete item_id
  6451. */
  6452. void Commands::Command_Inventory(Client* client, Seperator* sep, EQ2_RemoteCommandString* command)
  6453. {
  6454. PrintSep(sep, "Command_Inventory"); // temp to figure out the params
  6455. Player* player = client->GetPlayer();
  6456. if(sep && sep->arg[0][0])
  6457. {
  6458. LogWrite(COMMAND__INFO, 0, "Command", "command: %s", sep->argplus[0]);
  6459. if(!client->GetPlayer()->Alive())
  6460. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  6461. else if(sep->arg[1][0] && strncasecmp("destroy", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  6462. {
  6463. int16 index = atoi(sep->arg[1]);
  6464. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  6465. if(item)
  6466. {
  6467. if(item->details.item_locked) {
  6468. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot destroy the item in use.");
  6469. return;
  6470. }
  6471. else if(item->IsBag() && item->details.equip_slot_id) {
  6472. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot destroy the item, it is being used as quiver.");
  6473. return;
  6474. }
  6475. else if(item->CheckFlag(NO_DESTROY)) {
  6476. client->SimpleMessage(CHANNEL_COLOR_RED, "You can't destroy this item.");
  6477. return;
  6478. }
  6479. if(item->GetItemScript() && lua_interface)
  6480. lua_interface->RunItemScript(item->GetItemScript(), "destroyed", item, client->GetPlayer());
  6481. //reobtain item make sure it wasn't removed
  6482. item = player->item_list.GetItemFromIndex(index);
  6483. int32 bag_id = 0;
  6484. if(item){
  6485. bag_id = item->details.inv_slot_id;
  6486. database.DeleteItem(client->GetCharacterID(), item, 0);
  6487. }
  6488. client->GetPlayer()->item_list.DestroyItem(index);
  6489. client->GetPlayer()->UpdateInventory(bag_id);
  6490. client->GetPlayer()->CalculateApplyWeight();
  6491. }
  6492. }
  6493. 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))
  6494. {
  6495. int16 from_index = atoi(sep->arg[1]);
  6496. sint16 to_slot = atoi(sep->arg[2]); // don't convert slot since this is inventory not equipment
  6497. sint32 bag_id = atol(sep->arg[3]);
  6498. int8 charges = atoi(sep->arg[4]);
  6499. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(from_index);
  6500. if(!item) {
  6501. client->SimpleMessage(CHANNEL_COLOR_RED, "You have no item.");
  6502. return;
  6503. }
  6504. if(to_slot == item->details.slot_id && (bag_id < 0 || bag_id == item->details.inv_slot_id)) {
  6505. return;
  6506. }
  6507. if(item->details.item_locked)
  6508. {
  6509. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot move the item in use.");
  6510. return;
  6511. }
  6512. if(bag_id == -4 && !client->GetPlayer()->item_list.SharedBankAddAllowed(item))
  6513. {
  6514. client->SimpleMessage(CHANNEL_COLOR_RED, "That item (or an item inside) cannot be shared.");
  6515. return;
  6516. }
  6517. sint32 old_inventory_id = 0;
  6518. if(item)
  6519. old_inventory_id = item->details.inv_slot_id;
  6520. //autobank
  6521. if (bag_id == -3 && to_slot == -1)
  6522. {
  6523. if (player->HasFreeBankSlot())
  6524. to_slot = player->FindFreeBankSlot();
  6525. else
  6526. {
  6527. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free bank slots.");
  6528. return;
  6529. }
  6530. }
  6531. //auto inventory
  6532. if (bag_id == 0 && to_slot == -1)
  6533. {
  6534. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  6535. {
  6536. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free slots.");
  6537. return;
  6538. }
  6539. }
  6540. bool item_deleted = false;
  6541. EQ2Packet* outapp = client->GetPlayer()->MoveInventoryItem(bag_id, from_index, (int8)to_slot, charges, 0, &item_deleted, client->GetVersion());
  6542. client->QueuePacket(outapp);
  6543. if(item_deleted)
  6544. item = nullptr;
  6545. //removed from bag send update
  6546. if(old_inventory_id > 0 && item && item->details.inv_slot_id != old_inventory_id)
  6547. {
  6548. outapp = client->GetPlayer()->SendBagUpdate(old_inventory_id, client->GetVersion());
  6549. if(outapp)
  6550. client->QueuePacket(outapp);
  6551. }
  6552. if(item && item->details.inv_slot_id > 0 && item->details.inv_slot_id != old_inventory_id)
  6553. {
  6554. outapp = client->GetPlayer()->SendBagUpdate(item->details.inv_slot_id, client->GetVersion());
  6555. if(outapp)
  6556. client->QueuePacket(outapp);
  6557. }
  6558. }
  6559. else if(sep->arg[1][0] && strncasecmp("equip", sep->arg[0], 5) == 0 && sep->IsNumber(1))
  6560. {
  6561. int16 index = atoi(sep->arg[1]);
  6562. int8 slot_id = 255;
  6563. int8 unk3 = 0;
  6564. int8 appearance_equip = 0;
  6565. if(sep->arg[2][0] && sep->IsNumber(2))
  6566. slot_id = player->ConvertSlotFromClient(atoi(sep->arg[2]), client->GetVersion());
  6567. if(sep->arg[3][0] && sep->IsNumber(3))
  6568. unk3 = atoul(sep->arg[3]);
  6569. if(sep->arg[4][0] && sep->IsNumber(4))
  6570. appearance_equip = atoul(sep->arg[4]);
  6571. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), appearance_equip, slot_id);
  6572. EQ2Packet* outapp = 0;
  6573. for(int32 i=0;i<packets.size();i++)
  6574. {
  6575. outapp = packets[i];
  6576. if(outapp)
  6577. client->QueuePacket(outapp);
  6578. }
  6579. client->GetPlayer()->UpdateWeapons();
  6580. EQ2Packet* characterSheetPackets = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion());
  6581. client->QueuePacket(characterSheetPackets);
  6582. }
  6583. else if (sep->arg[1][0] && strncasecmp("unpack", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  6584. {
  6585. if (client->GetPlayer()->EngagedInCombat())
  6586. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unpack items while in combat.");
  6587. else {
  6588. int16 index = atoi(sep->arg[1]);
  6589. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  6590. if (item) {
  6591. if(item->details.item_locked)
  6592. {
  6593. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot unpack the item in use.");
  6594. return;
  6595. }
  6596. // client->GetPlayer()->item_list.DestroyItem(index);
  6597. if (item->item_sets.size() > 0) {
  6598. for (int32 i = 0; i < item->item_sets.size(); i++) {
  6599. ItemSet* set = item->item_sets[i];
  6600. if (set->item_stack_size == 0)
  6601. set->item_stack_size += 1;
  6602. client->AddItem(set->item_id, set->item_stack_size);
  6603. }
  6604. }
  6605. }
  6606. client->RemoveItem(item, 1);
  6607. }
  6608. }
  6609. else if(sep->arg[1][0] && strncasecmp("unequip", sep->arg[0], 7) == 0 && sep->IsNumber(1))
  6610. {
  6611. int16 index = player->ConvertSlotFromClient(atoi(sep->arg[1]), client->GetVersion());
  6612. sint32 bag_id = -999;
  6613. int8 to_slot = 255;
  6614. if(sep->arg[3][0])
  6615. {
  6616. if(sep->IsNumber(2))
  6617. bag_id = atol(sep->arg[2]);
  6618. if(sep->IsNumber(3))
  6619. to_slot = atoi(sep->arg[3]);
  6620. }
  6621. sint8 unk4 = 0;
  6622. int8 appearance_equip = 0;
  6623. if(sep->arg[4][0] && sep->IsNumber(4))
  6624. unk4 = atoi(sep->arg[4]);
  6625. if(sep->arg[5][0] && sep->IsNumber(5))
  6626. appearance_equip = atoul(sep->arg[5]);
  6627. vector<EQ2Packet*> packets = client->GetPlayer()->UnequipItem(index, bag_id, to_slot, client->GetVersion(), appearance_equip);
  6628. EQ2Packet* outapp = 0;
  6629. for(int32 i=0;i<packets.size();i++)
  6630. {
  6631. outapp = packets[i];
  6632. if(outapp)
  6633. client->QueuePacket(outapp);
  6634. }
  6635. client->UnequipItem(index, bag_id, to_slot, appearance_equip);
  6636. }
  6637. else if(sep->arg[2][0] && strncasecmp("swap_equip", sep->arg[0], 10) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  6638. {
  6639. if(client->GetPlayer()->EngagedInCombat() && rule_manager.GetGlobalRule(R_Player, AllowPlayerEquipCombat)->GetInt8() == 0) {
  6640. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not swap items while in combat.");
  6641. }
  6642. else {
  6643. int16 index1 = client->GetPlayer()->ConvertSlotFromClient(atoi(sep->arg[1]), client->GetVersion());
  6644. int16 index2 = client->GetPlayer()->ConvertSlotFromClient(atoi(sep->arg[2]), client->GetVersion());
  6645. int8 type = 0;
  6646. if(sep->IsNumber(3))
  6647. type = atoul(sep->arg[3]); // type 0 is combat, 3 = appearance
  6648. EQ2Packet* outapp = client->GetPlayer()->SwapEquippedItems(index1, index2, client->GetVersion(), type);
  6649. if(outapp)
  6650. client->QueuePacket(outapp);
  6651. else
  6652. {
  6653. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to swap items");
  6654. return;
  6655. }
  6656. }
  6657. }
  6658. else if (sep->arg[2][0] && strncasecmp("pop", sep->arg[0], 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  6659. {
  6660. sint16 to_slot = atoi(sep->arg[1]);
  6661. sint32 bag_id = atoi(sep->arg[2]);
  6662. Item* item = client->GetPlayer()->item_list.GetOverflowItem();
  6663. if (item) {
  6664. //auto inventory
  6665. if (bag_id == 0 && to_slot == -1)
  6666. {
  6667. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  6668. {
  6669. client->SimpleMessage(CHANNEL_ERROR, "You do not have any free slots.");
  6670. return;
  6671. }
  6672. // Set the slot for the item
  6673. item->details.inv_slot_id = bag_id;
  6674. item->details.slot_id = to_slot;
  6675. // Flag the item so it gets saved in its new location
  6676. item->save_needed = true;
  6677. // Add the item to its new location
  6678. if(player->item_list.AddItem(item)) {
  6679. // Remove the item from the overflow list
  6680. player->item_list.RemoveOverflowItem(item);
  6681. }
  6682. // Send the inventory update packet
  6683. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  6684. return;
  6685. }
  6686. else if (bag_id == -3 && to_slot == -1) {
  6687. // Auto Bank
  6688. if (!player->item_list.GetFirstFreeBankSlot(&bag_id, &to_slot)) {
  6689. client->SimpleMessage(CHANNEL_STATUS, "You do not have any free bank slots.");
  6690. return;
  6691. }
  6692. item->details.inv_slot_id = bag_id;
  6693. item->details.slot_id = to_slot;
  6694. item->save_needed = true;
  6695. if(player->item_list.AddItem(item)) {
  6696. player->item_list.RemoveOverflowItem(item);
  6697. }
  6698. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  6699. }
  6700. else if (bag_id == -4) {
  6701. // Shared Bank
  6702. if (!player->item_list.SharedBankAddAllowed(item)) {
  6703. client->SimpleMessage(CHANNEL_STATUS, "That item (or an item inside) cannot be shared.");
  6704. return;
  6705. }
  6706. Item* tmp_item = player->item_list.GetItem(-4, to_slot);
  6707. if (tmp_item) {
  6708. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  6709. return;
  6710. }
  6711. else {
  6712. item->details.inv_slot_id = bag_id;
  6713. item->details.slot_id = to_slot;
  6714. item->save_needed = true;
  6715. if(player->item_list.AddItem(item)) {
  6716. player->item_list.RemoveOverflowItem(item);
  6717. }
  6718. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  6719. return;
  6720. }
  6721. }
  6722. else {
  6723. // Try to get an item from the given bag id and slot id
  6724. Item* tmp_item = player->item_list.GetItem(bag_id, to_slot);
  6725. // Check to see if we got an item, if we do send an error,
  6726. // if we don't put the overflow item into this slot
  6727. if (tmp_item) {
  6728. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  6729. }
  6730. else {
  6731. item->details.inv_slot_id = bag_id;
  6732. item->details.slot_id = to_slot;
  6733. item->save_needed = true;
  6734. if(player->item_list.AddItem(item)) {
  6735. player->item_list.RemoveOverflowItem(item);
  6736. }
  6737. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  6738. return;
  6739. }
  6740. }
  6741. }
  6742. }
  6743. else if(sep->arg[2][0] && strncasecmp("nosale", sep->arg[0], 6) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  6744. {
  6745. sint64 data = strtoull(sep->arg[1], NULL, 0);
  6746. int32 character_item_id = (int32) (data >> 32);
  6747. int32 item_id = (int32) (data & 0xffffffffL);
  6748. int8 sale_setting = atoi(sep->arg[2]);
  6749. Item* item = client->GetPlayer()->item_list.GetItemFromUniqueID(character_item_id);
  6750. if(item)
  6751. {
  6752. item->no_sale = sale_setting;
  6753. item->save_needed = true;
  6754. client->SendSellMerchantList();
  6755. }
  6756. }
  6757. }
  6758. else
  6759. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /inventory {destroy|move|equip|unequip|swap_equip|pop} {item_id} [to_slot] [bag_id]");
  6760. }
  6761. /*
  6762. Function: Command_Languages()
  6763. Purpose : Show's languages the player knows
  6764. Params :
  6765. Dev : Zcoretri
  6766. Example :
  6767. */
  6768. void Commands::Command_Languages(Client* client, Seperator* sep)
  6769. {
  6770. list<Language*>* languages = client->GetPlayer()->GetPlayerLanguages()->GetAllLanguages();
  6771. list<Language*>::iterator itr;
  6772. Language* language;
  6773. client->Message(CHANNEL_NARRATIVE, "You know the following languages:");
  6774. for(itr = languages->begin(); itr != languages->end(); itr++)
  6775. {
  6776. language = *itr;
  6777. client->Message(CHANNEL_NARRATIVE, "%s", language->GetName());
  6778. }
  6779. }
  6780. /*
  6781. Function: Command_SetLanguage()
  6782. Purpose : Handles language commands
  6783. Params : Language ID
  6784. Dev : Zcoretri
  6785. Example :
  6786. */
  6787. void Commands::Command_SetLanguage(Client* client, Seperator* sep)
  6788. {
  6789. Player* player = client->GetPlayer();
  6790. if (sep && sep->arg[0])
  6791. {
  6792. if(!sep->IsNumber(0))
  6793. {
  6794. //String passed in
  6795. const char* value = sep->arg[0];
  6796. if(strncasecmp(value, "Common", strlen(value)) == 0)
  6797. {
  6798. database.SaveCharacterCurrentLang(0, client->GetCharacterID(), client);
  6799. client->SendLanguagesUpdate(0);
  6800. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", value);
  6801. }
  6802. else
  6803. {
  6804. if(player->HasLanguage(value))
  6805. {
  6806. Language* language = player->GetPlayerLanguages()->GetLanguageByName(value);
  6807. database.SaveCharacterCurrentLang(language->GetID(), client->GetCharacterID(), client);
  6808. client->SendLanguagesUpdate(language->GetID());
  6809. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", language->GetName());
  6810. }
  6811. else
  6812. client->Message(CHANNEL_NARRATIVE, "You do not know how to speak %s", value);
  6813. }
  6814. }
  6815. else
  6816. {
  6817. //Number passed in
  6818. int32 id = atoul(sep->arg[0]);
  6819. if(player->HasLanguage(id))
  6820. {
  6821. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  6822. database.SaveCharacterCurrentLang(id, client->GetCharacterID(), client);
  6823. client->SendLanguagesUpdate(id);
  6824. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", language->GetName());
  6825. }
  6826. else
  6827. {
  6828. Language* language = master_languages_list.GetLanguage(id);
  6829. if(language)
  6830. client->Message(CHANNEL_NARRATIVE, "You do not know how to speak %s", language->GetName());
  6831. }
  6832. }
  6833. }
  6834. else
  6835. {
  6836. //No value was passed in
  6837. int32 id = database.GetCharacterCurrentLang(client->GetCharacterID(), player);
  6838. if(id > 0)
  6839. {
  6840. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  6841. client->Message(CHANNEL_NARRATIVE, "You are currently speaking %s ", language->GetName());
  6842. }
  6843. else
  6844. client->Message(CHANNEL_NARRATIVE, "You are currently speaking Common");
  6845. }
  6846. }
  6847. /*
  6848. Function: Command_LastName()
  6849. Purpose : Sets player surname
  6850. Params : Name text
  6851. Dev : theFoof
  6852. Example :
  6853. */
  6854. void Commands::Command_LastName(Client* client, Seperator* sep)
  6855. {
  6856. if (!client)
  6857. return;
  6858. if (sep && sep->arg[0])
  6859. {
  6860. if (!client->GetPlayer()->get_character_flag(CF_ENABLE_CHANGE_LASTNAME)){
  6861. client->Message(CHANNEL_COLOR_YELLOW, "You must be atleast level %i to change your last name.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  6862. return;
  6863. }
  6864. client->RemovePendingLastName();
  6865. uchar* checkname = (uchar*)sep->arg[0];
  6866. bool valid_name = true;
  6867. for (int32 i = 0; i < strlen(sep->arg[0]); i++) {
  6868. if (!alpha_check(checkname[i])) {
  6869. valid_name = false;
  6870. break;
  6871. }
  6872. }
  6873. if (!valid_name) {
  6874. client->Message(CHANNEL_COLOR_YELLOW, "Your last name can only contain letters.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  6875. return;
  6876. }
  6877. string last_name = (string)sep->arg[0];
  6878. int8 max_length = rule_manager.GetGlobalRule(R_Player, MaxLastNameLength)->GetInt8();
  6879. int8 min_length = rule_manager.GetGlobalRule(R_Player, MinLastNameLength)->GetInt8();
  6880. if (last_name.length() <= max_length && last_name.length() >= min_length){
  6881. client->SetPendingLastName(last_name);
  6882. client->SendLastNameConfirmation();
  6883. }
  6884. else
  6885. client->Message(CHANNEL_COLOR_YELLOW, "Your last name must be between %i and %i characters long.", min_length, max_length);
  6886. }
  6887. }
  6888. /*
  6889. Function: Command_ConfirmLastName()
  6890. Purpose : Confirms setting of player surname
  6891. Params : Name text
  6892. Dev : theFoof
  6893. Example :
  6894. */
  6895. void Commands::Command_ConfirmLastName(Client* client, Seperator* sep)
  6896. {
  6897. if (!client)
  6898. return;
  6899. string* name = client->GetPendingLastName();
  6900. if (name){
  6901. Player* player = client->GetPlayer();
  6902. player->SetLastName(name->c_str(), false);
  6903. client->SendTitleUpdate();
  6904. player->SetCharSheetChanged(true);
  6905. client->RemovePendingLastName();
  6906. }
  6907. }
  6908. /*
  6909. Function: Command_Location()
  6910. Purpose : Display's Help for /location commands
  6911. Params :
  6912. Dev : Scatman
  6913. Example : /location = show's help for command
  6914. */
  6915. void Commands::Command_Location(Client* client)
  6916. {
  6917. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Valid /location commands are:");
  6918. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location create [name] (include y). Include y defaults to false");
  6919. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location add [location id]");
  6920. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location remove [location point id]");
  6921. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location delete [location id]");
  6922. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location list [locations|points] [location id if points used]");
  6923. }
  6924. /*
  6925. Function: Command_LocationAdd()
  6926. Purpose : Add's a location to an existing location config
  6927. Params : location_id
  6928. Dev : Scatman
  6929. Example : /location add {location_id}
  6930. */
  6931. void Commands::Command_LocationAdd(Client* client, Seperator* sep)
  6932. {
  6933. if (sep && sep->arg[0] && sep->IsNumber(0))
  6934. {
  6935. int32 location_id = atoul(sep->arg[0]);
  6936. float x = client->GetPlayer()->GetX();
  6937. float y = client->GetPlayer()->GetY();
  6938. float z = client->GetPlayer()->GetZ();
  6939. if (database.AddLocationPoint(location_id, x, y, z))
  6940. client->Message(CHANNEL_COLOR_YELLOW, "Point (%f, %f, %f) was successfully added to location %u", x, y, z, location_id);
  6941. else
  6942. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist. Use /location create to create one", location_id);
  6943. }
  6944. else
  6945. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location add [location id]");
  6946. }
  6947. /*
  6948. Function: Command_LocationCreate()
  6949. Purpose : Creates a new location config
  6950. Params : location name, 0/1 for include_y (optional)
  6951. Dev : Scatman
  6952. Example : /location create Test 1 = creates a new location named Test with include_y True
  6953. */
  6954. void Commands::Command_LocationCreate(Client* client, Seperator* sep)
  6955. {
  6956. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  6957. {
  6958. const char* name = sep->arg[0];
  6959. bool include_y = false;
  6960. if (sep->arg[1] && sep->IsNumber(1) && atoi(sep->arg[1]) > 0)
  6961. include_y = true;
  6962. int32 location_id = database.CreateLocation(client->GetPlayer()->GetZone()->GetZoneID(), client->GetPlayer()->GetLocation(), name, include_y);
  6963. if (location_id > 0)
  6964. client->Message(CHANNEL_COLOR_YELLOW, "Location '%s' was successfully created with location id %u", name, location_id);
  6965. else
  6966. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the requested location");
  6967. }
  6968. else
  6969. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location create [name] (include_y). Include y defaults to false");
  6970. }
  6971. /*
  6972. Function: Command_LocationDelete()
  6973. Purpose : Delete's a location config and all it's location points
  6974. Params : location_id
  6975. Dev : Scatman
  6976. Example : /location delete {location_id}
  6977. */
  6978. void Commands::Command_LocationDelete(Client* client, Seperator* sep)
  6979. {
  6980. if (sep && sep->arg[0] && sep->IsNumber(0))
  6981. {
  6982. int32 location_id = atoul(sep->arg[0]);
  6983. if (database.DeleteLocation(location_id))
  6984. client->Message(CHANNEL_COLOR_YELLOW, "Location id %u and all its points were successfully deleted", location_id);
  6985. else
  6986. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist", location_id);
  6987. }
  6988. else
  6989. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location delete [location id]");
  6990. }
  6991. /*
  6992. Function: Command_LocationList()
  6993. Purpose : Display's a list of location points
  6994. Params : location_id
  6995. Dev : Scatman
  6996. Example : /location list {location_id}
  6997. */
  6998. void Commands::Command_LocationList(Client* client, Seperator* sep)
  6999. {
  7000. if (sep && sep->arg[0])
  7001. {
  7002. const char* option = sep->arg[0];
  7003. if (strncmp(option, "locations", strlen(option)) == 0)
  7004. database.ListLocations(client);
  7005. else if (strncmp(option, "points", strlen(option)) == 0 && sep->arg[1] && sep->IsNumber(1))
  7006. {
  7007. int32 location_id = atoul(sep->arg[1]);
  7008. database.ListLocationPoints(client, location_id);
  7009. }
  7010. else
  7011. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  7012. }
  7013. else
  7014. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  7015. }
  7016. /*
  7017. Function: Command_LocationRemove()
  7018. Purpose : Removes a single location point from a location config
  7019. Params : location_point_id (gotten from /location list {id})
  7020. Dev : Scatman
  7021. Example : /location remove 1 = will remove location_point_id 1
  7022. */
  7023. void Commands::Command_LocationRemove(Client* client, Seperator* sep)
  7024. {
  7025. if (sep && sep->arg[0] && sep->IsNumber(0))
  7026. {
  7027. int32 location_point_id = atoul(sep->arg[0]);
  7028. if (database.DeleteLocationPoint(location_point_id))
  7029. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Location point was successfully deleted");
  7030. else
  7031. client->Message(CHANNEL_COLOR_YELLOW, "Location point with ID %u does not exist", location_point_id);
  7032. }
  7033. else
  7034. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location remove [location point id]");
  7035. }
  7036. /*
  7037. Function: Command_Merchant()
  7038. Purpose : Handles Merchant commands
  7039. Params : list
  7040. Dev : Scatman
  7041. Example : /merchant list
  7042. */
  7043. void Commands::Command_Merchant(Client* client, Seperator* sep, int handler)
  7044. {
  7045. if( handler == COMMAND_MERCHANT )
  7046. {
  7047. // /merchant command by itself shows help (to be extended)
  7048. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  7049. return;
  7050. }
  7051. else if( handler == COMMAND_MERCHANT_LIST )
  7052. {
  7053. // /merchant list command expects "description" param
  7054. if (sep && sep->arg[0])
  7055. {
  7056. const char* merchant_description = sep->argplus[0];
  7057. client->Message(CHANNEL_COLOR_YELLOW, "Listing merchants like '%s':", merchant_description);
  7058. map<int32, MerchantInfo*>* merchant_info = world.GetMerchantInfo();
  7059. map<int32, MerchantInfo*>::iterator itr;
  7060. for (itr = merchant_info->begin(); itr != merchant_info->end(); itr++)
  7061. {
  7062. string description = database.GetMerchantDescription(itr->first);
  7063. if (ToLower(description).find(ToLower(string(merchant_description))) < 0xFFFFFFFF)
  7064. client->Message(CHANNEL_COLOR_YELLOW, "Merchant ID: %u, Description: %s", itr->first, description.c_str());
  7065. }
  7066. }
  7067. else // no description
  7068. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  7069. }
  7070. }
  7071. /*
  7072. Function: Command_Modify()
  7073. Purpose : to replace our other "set" commands
  7074. Params : System = the system to modify, Action = the action to perform, Target = what to change (target, or index)
  7075. Dev : John Adams
  7076. Example : /modify spell set name "Aegolism III"
  7077. */
  7078. void Commands::Command_Modify(Client* client)
  7079. {
  7080. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /modify [system] [action] [field] [value] {target|id}");
  7081. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Systems: character, faction, guild, item, skill, spawn, spell, zone");
  7082. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Actions: set, create, delete, add, remove");
  7083. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Value : field name in the table being modified");
  7084. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target : modify current target, or specified {system} ID");
  7085. }
  7086. /*
  7087. Function: Command_ModifySpawn()
  7088. Purpose : replace "spawn set" commands
  7089. Params : Action : the action to perform (or special handler)
  7090. : Field : the DB field to change
  7091. : Value : what to set the value to
  7092. : Target : what object to change (my target, or spawn_id)
  7093. Dev : John Adams
  7094. Example : /modify spawn set name "Lady Vox"
  7095. :
  7096. Note : Special Handlers, like "zoneto" for Signs
  7097. : /modify spawn zoneto
  7098. : Will set a sign's zone x/y/z to my current coords
  7099. */
  7100. void Commands::Command_ModifySpawn(Client* client, Seperator* sep)
  7101. {
  7102. PrintSep(sep, "COMMAND_MODIFY");
  7103. // need at least 2 args for a valid command
  7104. if( sep && sep->arg[1] )
  7105. {
  7106. // JA: just a quick implementation because I need it :)
  7107. if (strcmp(sep->arg[0], "zoneto") == 0)
  7108. {
  7109. if( sep->IsNumber(1) )
  7110. {
  7111. int32 spawn_id = atoul(sep->arg[1]);
  7112. float x_coord = client->GetPlayer()->GetX();
  7113. float y_coord = client->GetPlayer()->GetY();
  7114. float z_coord = client->GetPlayer()->GetZ();
  7115. float h_coord = client->GetPlayer()->GetHeading();
  7116. database.SaveSignZoneToCoords(spawn_id, x_coord, y_coord, z_coord, h_coord);
  7117. }
  7118. else
  7119. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify spawn zoneto spawn_id - sets spawn_id to your coords");
  7120. }
  7121. }
  7122. else
  7123. Command_Modify(client);
  7124. }
  7125. /*
  7126. Function: Command_ModifyCharacter()
  7127. Purpose : to replace our other "set" commands
  7128. Params : Action : Add, Remove
  7129. : Field : copper, silver, gold, plat
  7130. : Value : min 1, max unlimited
  7131. : Target : Self, Player
  7132. Dev : Cynnar
  7133. Example : /modify character add gold 50
  7134. : /modify character remove silver 25
  7135. */
  7136. void Commands::Command_ModifyCharacter(Client* client, Seperator* sep)
  7137. {
  7138. PrintSep(sep, "COMMAND_MODIFY");
  7139. int64 value = 0;
  7140. Player* player = client->GetPlayer();
  7141. Client* targetClient = client;
  7142. if (player->HasTarget() && player->GetTarget()->IsPlayer()) {
  7143. player = (Player*)player->GetTarget();
  7144. targetClient = player->GetClient();
  7145. }
  7146. // need at least 2 args for a valid command
  7147. if( sep && sep->arg[1] )
  7148. {
  7149. if (strcmp(sep->arg[0], "add") == 0)
  7150. {
  7151. if (strcmp(sep->arg[1], "copper") == 0)
  7152. {
  7153. value = atoi64(sep->arg[2]);
  7154. player->AddCoins(value);
  7155. if (client->GetPlayer() == player)
  7156. {
  7157. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu copper coin%s", value, (value > 1 ? "s" : ""));
  7158. }
  7159. else {
  7160. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu copper coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  7161. if(targetClient) {
  7162. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu copper coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  7163. }
  7164. }
  7165. }
  7166. else if (strcmp(sep->arg[1], "silver") == 0)
  7167. {
  7168. value = atoi64(sep->arg[2]) * 100;
  7169. player->AddCoins(value);
  7170. if (client->GetPlayer() == player)
  7171. {
  7172. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu silver coin%s", value / 100, (value > 1 ? "s" : ""));
  7173. }
  7174. else {
  7175. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu silver coin%s", player->GetName(), value / 100, (value > 1 ? "s" : ""));
  7176. if(targetClient) {
  7177. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu silver coin%s", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  7178. }
  7179. }
  7180. }
  7181. else if (strcmp(sep->arg[1], "gold") == 0)
  7182. {
  7183. value = atoi64(sep->arg[2]) * 10000;
  7184. player->AddCoins(value);
  7185. if (client->GetPlayer() == player)
  7186. {
  7187. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu gold coin%s", value / 10000, (value > 1 ? "s" : ""));
  7188. }
  7189. else {
  7190. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu gold coin%s", player->GetName(), value / 10000, (value > 1 ? "s" : ""));
  7191. if(targetClient) {
  7192. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu gold coin%s", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  7193. }
  7194. }
  7195. }
  7196. else if (strcmp(sep->arg[1], "plat") == 0)
  7197. {
  7198. value = atoi64(sep->arg[2]) * 1000000;
  7199. player->AddCoins(value);
  7200. if (client->GetPlayer() == player)
  7201. {
  7202. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu platinum coin%s", value / 1000000, (value > 1 ? "s" : ""));
  7203. }
  7204. else {
  7205. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu platinum coin%s", player->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  7206. if(targetClient) {
  7207. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu platinum coin%s", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  7208. }
  7209. }
  7210. }
  7211. else
  7212. {
  7213. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  7214. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  7215. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  7216. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character add copper 20");
  7217. }
  7218. }
  7219. else if (strcmp(sep->arg[0], "remove") == 0)
  7220. {
  7221. if (strcmp(sep->arg[1], "copper") == 0)
  7222. {
  7223. value = atoi64(sep->arg[2]);
  7224. player->RemoveCoins(value);
  7225. if (client->GetPlayer() == player)
  7226. {
  7227. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from yourself", value, (value > 1 ? "s" : ""));
  7228. }
  7229. else {
  7230. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from %s", value, (value > 1 ? "s" : ""), player->GetName());
  7231. if(targetClient) {
  7232. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu copper coin%s from you", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  7233. }
  7234. }
  7235. }
  7236. else if (strcmp(sep->arg[1], "silver") == 0)
  7237. {
  7238. value = atoi64(sep->arg[2]) * 100;
  7239. player->RemoveCoins(value);
  7240. if (client->GetPlayer() == player)
  7241. {
  7242. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from yourself", value / 100, (value > 1 ? "s" : ""));
  7243. }
  7244. else {
  7245. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from %s", value / 100, (value > 1 ? "s" : ""), player->GetName());
  7246. if(targetClient) {
  7247. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu silver coin%s from you", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  7248. }
  7249. }
  7250. }
  7251. else if (strcmp(sep->arg[1], "gold") == 0)
  7252. {
  7253. value = atoi64(sep->arg[2]) * 10000;
  7254. player->RemoveCoins(value);
  7255. if (client->GetPlayer() == player)
  7256. {
  7257. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from yourself", value / 10000, (value > 1 ? "s" : ""));
  7258. }
  7259. else {
  7260. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from %s", value / 10000, (value > 1 ? "s" : ""), player->GetName());
  7261. if(targetClient) {
  7262. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu gold coin%s from you", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  7263. }
  7264. }
  7265. }
  7266. else if (strcmp(sep->arg[1], "plat") == 0)
  7267. {
  7268. value = atoi64(sep->arg[2]) * 1000000;
  7269. player->RemoveCoins(value);
  7270. if (client->GetPlayer() == player)
  7271. {
  7272. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from yourself", value / 1000000, (value > 1 ? "s" : ""));
  7273. }
  7274. else {
  7275. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from %s", value / 1000000, (value > 1 ? "s" : ""), player->GetName());
  7276. if(targetClient) {
  7277. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu platinum coin%s from you", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  7278. }
  7279. }
  7280. }
  7281. else
  7282. {
  7283. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  7284. }
  7285. }
  7286. else if (strcmp(sep->arg[0], "set") == 0) {
  7287. if (strcmp(sep->arg[1], "tslevel") == 0) {
  7288. int8 level = atoi(sep->arg[2]);
  7289. if (level > 0 && level < 256) {
  7290. if (player) {
  7291. if (client->GetPlayer() == player)
  7292. client->ChangeTSLevel(player->GetTSLevel(), level);
  7293. else if(targetClient)
  7294. targetClient->ChangeTSLevel(player->GetTSLevel(), level);
  7295. }
  7296. }
  7297. else
  7298. client->SimpleMessage(CHANNEL_ERROR, "Level must be between 1 - 255");
  7299. }
  7300. else if (strcmp(sep->arg[1], "tsclass") == 0) {
  7301. int8 tsclass = atoi(sep->arg[2]);
  7302. player->SetTradeskillClass(tsclass);
  7303. player->GetInfoStruct()->set_tradeskill_class1(classes.GetTSBaseClass(player->GetTradeskillClass()));
  7304. player->GetInfoStruct()->set_tradeskill_class2(classes.GetSecondaryTSBaseClass(player->GetTradeskillClass()));
  7305. player->GetInfoStruct()->set_tradeskill_class3(player->GetTradeskillClass());
  7306. player->SetCharSheetChanged(true);
  7307. }
  7308. else if (strcmp(sep->arg[1], "gender") == 0) {
  7309. int8 gender = atoi(sep->arg[2]);
  7310. client->GetPlayer()->GetInfoStruct()->set_gender(gender);
  7311. client->GetPlayer()->SetCharSheetChanged(true);
  7312. client->UpdateTimeStampFlag ( GENDER_UPDATE_FLAG );
  7313. }
  7314. }
  7315. }
  7316. else
  7317. {
  7318. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  7319. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  7320. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  7321. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  7322. }
  7323. }
  7324. void Commands::Command_ModifyFaction(Client* client, Seperator* sep)
  7325. {
  7326. PrintSep(sep, "COMMAND_MODIFY");
  7327. // need at least 2 args for a valid command
  7328. if( sep && sep->arg[1] )
  7329. {
  7330. }
  7331. else
  7332. Command_Modify(client);
  7333. }
  7334. void Commands::Command_ModifyGuild(Client* client, Seperator* sep)
  7335. {
  7336. PrintSep(sep, "COMMAND_MODIFY");
  7337. // need at least 2 args for a valid command
  7338. if( sep && sep->arg[1] )
  7339. {
  7340. }
  7341. else
  7342. Command_Modify(client);
  7343. }
  7344. void Commands::Command_ModifyItem(Client* client, Seperator* sep)
  7345. {
  7346. PrintSep(sep, "COMMAND_MODIFY");
  7347. // need at least 2 args for a valid command
  7348. if( sep && sep->arg[1] )
  7349. {
  7350. }
  7351. else
  7352. Command_Modify(client);
  7353. }
  7354. /*
  7355. Function: Command_ModifyQuest()
  7356. Purpose : to list players quest and completed quests
  7357. Params : Action : list, completed
  7358. : Target : Self, Player
  7359. Dev : Cynnar
  7360. Example : /modify quest list
  7361. : /modify quest completed
  7362. */
  7363. void Commands::Command_ModifyQuest(Client* client, Seperator* sep)
  7364. {
  7365. PrintSep(sep, "COMMAND_MODIFY");
  7366. int64 value = 0;
  7367. Player* player = client->GetPlayer();
  7368. Client* targetClient = client;
  7369. if (player->HasTarget() && player->GetTarget()->IsPlayer()) {
  7370. player = (Player*)player->GetTarget();
  7371. targetClient = player->GetClient();
  7372. }
  7373. // need at least 2 args for a valid command
  7374. if (sep && sep->arg[1])
  7375. {
  7376. if (strcmp(sep->arg[0], "list") == 0)
  7377. {
  7378. map<int32, Quest*>* quests = player->GetPlayerQuests();
  7379. map<int32, Quest*>::iterator itr;
  7380. client->Message(CHANNEL_COLOR_YELLOW, "%s's Quest List:.", client->GetPlayer()->GetName());
  7381. if (quests->size() == 0)
  7382. client->Message(CHANNEL_COLOR_YELLOW, "%s has no quests.", client->GetPlayer()->GetName());
  7383. else
  7384. {
  7385. for (itr = quests->begin(); itr != quests->end(); itr++)
  7386. {
  7387. Quest* quest = itr->second;
  7388. if(quest) {
  7389. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  7390. }
  7391. }
  7392. }
  7393. }
  7394. else if (strcmp(sep->arg[0], "completed") == 0)
  7395. {
  7396. map<int32, Quest*>* quests = player->GetCompletedPlayerQuests();
  7397. map<int32, Quest*>::iterator itr;
  7398. client->Message(CHANNEL_COLOR_YELLOW, "%s's Completed Quest List:.", client->GetPlayer()->GetName());
  7399. if (quests->size() == 0)
  7400. client->Message(CHANNEL_COLOR_YELLOW, "%s has no completed quests.", client->GetPlayer()->GetName());
  7401. else
  7402. {
  7403. for (itr = quests->begin(); itr != quests->end(); itr++)
  7404. {
  7405. Quest* quest = itr->second;
  7406. if(quest) {
  7407. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  7408. }
  7409. }
  7410. }
  7411. }
  7412. // Add in a progress step, and a LogWrite() for tracking GM Commands.
  7413. // LogWrite(LUA__DEBUG, 0, "LUA", "Quest: %s, function: %s", quest->GetName(), function);
  7414. else if (strcmp(sep->arg[0], "remove") == 0)
  7415. {
  7416. int32 quest_id = 0;
  7417. if (sep && sep->arg[1] && sep->IsNumber(1))
  7418. quest_id = atoul(sep->arg[1]);
  7419. if (quest_id > 0)
  7420. {
  7421. if (lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0)
  7422. {
  7423. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  7424. if (quest)
  7425. if (client->GetPlayer() == player)
  7426. {
  7427. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been removed from your journal", quest->GetName());
  7428. }
  7429. else
  7430. {
  7431. client->Message(CHANNEL_COLOR_YELLOW, "You have removed the quest %s from %s's journal", quest->GetName(), player->GetName());
  7432. if(targetClient) {
  7433. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s has removed the quest %s from your journal", client->GetPlayer()->GetName(), quest->GetName());
  7434. }
  7435. }
  7436. LogWrite(COMMAND__INFO, 0, "GM Command", "%s removed the quest %s from %s", client->GetPlayer()->GetName(), quest->GetName(), player->GetName());
  7437. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  7438. }
  7439. client->RemovePlayerQuest(quest_id);
  7440. client->GetCurrentZone()->SendQuestUpdates(client);
  7441. }
  7442. }
  7443. else if (strcmp(sep->arg[0], "advance") == 0)
  7444. {
  7445. int32 quest_id = 0;
  7446. int32 step = 0;
  7447. if (sep && sep->arg[1] && sep->IsNumber(1))
  7448. {
  7449. quest_id = atoul(sep->arg[1]);
  7450. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  7451. if(!quest) {
  7452. client->Message(CHANNEL_COLOR_RED, "Quest not found!");
  7453. return;
  7454. }
  7455. if (sep && sep->arg[2] && sep->IsNumber(1))
  7456. {
  7457. step = atoul(sep->arg[2]);
  7458. if (quest_id > 0 && step > 0)
  7459. {
  7460. if (player && player->IsPlayer() && quest_id > 0 && step > 0 && (player->player_quests.count(quest_id) > 0))
  7461. {
  7462. if (client)
  7463. {
  7464. client->AddPendingQuestUpdate(quest_id, step);
  7465. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been advanced one step.", quest->GetName());
  7466. LogWrite(COMMAND__INFO, 0, "GM Command", "%s advanced the quest %s one step", client->GetPlayer()->GetName(), quest->GetName());
  7467. }
  7468. }
  7469. }
  7470. else
  7471. {
  7472. client->Message(CHANNEL_COLOR_RED, "Quest ID and Step Number must be greater than 0!");
  7473. }
  7474. }
  7475. else
  7476. {
  7477. client->Message(CHANNEL_COLOR_RED, "Step Number must be a number!");
  7478. }
  7479. }
  7480. else
  7481. {
  7482. client->Message(CHANNEL_COLOR_RED, "Quest ID must be a number!");
  7483. }
  7484. }
  7485. else
  7486. {
  7487. Command_Modify(client);
  7488. }
  7489. }
  7490. else
  7491. {
  7492. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify quest [action] [quest id] [step number]");
  7493. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: list, completed, remove, advance");
  7494. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest list");
  7495. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest remove 156");
  7496. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest advance 50 1");
  7497. }
  7498. }
  7499. void Commands::Command_ModifySkill(Client* client, Seperator* sep)
  7500. {
  7501. PrintSep(sep, "COMMAND_MODIFY");
  7502. // need at least 2 args for a valid command
  7503. if( sep && sep->arg[1] )
  7504. {
  7505. if (strcmp(sep->arg[0], "add") == 0) {
  7506. const char* skill_name = sep->argplus[1];
  7507. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  7508. if (skill) {
  7509. Player* player = 0;
  7510. Client* to_client = 0;
  7511. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  7512. player = (Player*)client->GetPlayer()->GetTarget();
  7513. to_client = player->GetClient();
  7514. }
  7515. else {
  7516. player = client->GetPlayer();
  7517. to_client = client;
  7518. }
  7519. if (player)
  7520. {
  7521. if (!player->GetSkills()->HasSkill(skill->skill_id))
  7522. {
  7523. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  7524. if (to_client == client) {
  7525. client->Message(CHANNEL_STATUS, "Added skill '%s'.", skill_name);
  7526. }
  7527. else {
  7528. client->Message(CHANNEL_STATUS, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  7529. to_client->Message(CHANNEL_STATUS, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  7530. }
  7531. }
  7532. else
  7533. client->Message(CHANNEL_STATUS, "%s already has the skill '%s'.", to_client == client ? "You" : player->GetName(), skill_name);
  7534. }
  7535. }
  7536. else
  7537. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  7538. }
  7539. else if (strcmp(sep->arg[0], "remove") == 0) {
  7540. const char* skill_name = sep->argplus[1];
  7541. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  7542. if (skill) {
  7543. Player* player = 0;
  7544. Client* to_client = 0;
  7545. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  7546. player = (Player*)client->GetPlayer()->GetTarget();
  7547. to_client = player->GetClient();
  7548. }
  7549. else {
  7550. player = client->GetPlayer();
  7551. to_client = client;
  7552. }
  7553. if (player)
  7554. {
  7555. if (player->GetSkills()->HasSkill(skill->skill_id))
  7556. {
  7557. player->RemoveSkillFromDB(skill, true);
  7558. if (client == to_client) {
  7559. client->Message(CHANNEL_STATUS, "Removed skill '%s'.", skill_name);
  7560. }
  7561. else {
  7562. client->Message(CHANNEL_STATUS, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  7563. if(to_client) {
  7564. to_client->Message(CHANNEL_STATUS, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  7565. }
  7566. }
  7567. }
  7568. else {
  7569. if (client == to_client)
  7570. client->Message(CHANNEL_STATUS, "You do not have the skill '%s'.", skill_name);
  7571. else
  7572. client->Message(CHANNEL_STATUS, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  7573. }
  7574. }
  7575. }
  7576. else
  7577. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  7578. }
  7579. else if (strcmp(sep->arg[0], "set") == 0) {
  7580. if (!sep->IsNumber(2)) {
  7581. client->Message(CHANNEL_STATUS, "The last parameter must be a number.");
  7582. return;
  7583. }
  7584. const char* skill_name = sep->arg[1];
  7585. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  7586. if (skill) {
  7587. int16 val = atoi(sep->arg[2]);
  7588. Player* player = 0;
  7589. Client* to_client = 0;
  7590. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  7591. player = (Player*)client->GetPlayer()->GetTarget();
  7592. to_client = player->GetClient();
  7593. }
  7594. else {
  7595. player = client->GetPlayer();
  7596. to_client = client;
  7597. }
  7598. if (player)
  7599. {
  7600. if (player->GetSkills()->HasSkill(skill->skill_id)) {
  7601. player->GetSkills()->SetSkill(skill->skill_id, val);
  7602. if (client != to_client)
  7603. client->Message(CHANNEL_STATUS, "You set %s's '%s' skill to %i.", player->GetName(), skill_name, val);
  7604. if(to_client) {
  7605. to_client->Message(CHANNEL_STATUS, "Your '%s' skill has been set to %i.", skill_name, val);
  7606. }
  7607. }
  7608. else {
  7609. client->Message(CHANNEL_STATUS, "Target does not have the skill '%s'.", skill_name);
  7610. }
  7611. }
  7612. }
  7613. else {
  7614. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  7615. }
  7616. }
  7617. else {
  7618. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  7619. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  7620. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  7621. }
  7622. }
  7623. else {
  7624. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  7625. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  7626. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  7627. }
  7628. }
  7629. void Commands::Command_ModifySpell(Client* client, Seperator* sep)
  7630. {
  7631. PrintSep(sep, "COMMAND_MODIFY");
  7632. // need at least 2 args for a valid command
  7633. if( sep && sep->arg[1] )
  7634. {
  7635. }
  7636. else
  7637. Command_Modify(client);
  7638. }
  7639. void Commands::Command_ModifyZone(Client* client, Seperator* sep)
  7640. {
  7641. PrintSep(sep, "COMMAND_MODIFY");
  7642. // need at least 2 args for a valid command
  7643. if( sep && sep->arg[1] )
  7644. {
  7645. }
  7646. else
  7647. Command_Modify(client);
  7648. }
  7649. /*
  7650. Function: Command_MOTD()
  7651. Purpose : Displays server MOTD
  7652. Params :
  7653. Dev : LethalEncounter
  7654. Example : /motd
  7655. */
  7656. void Commands::Command_MOTD(Client* client)
  7657. {
  7658. if (client)
  7659. ClientPacketFunctions::SendMOTD(client);
  7660. }
  7661. /*
  7662. Function: Command_Pet()
  7663. Purpose : Handle Pet {Command} commands
  7664. Params : attack, backoff, preserve_master, preserve_self, follow, stay, getlost
  7665. Dev :
  7666. Example : /pet preserve_master
  7667. */
  7668. void Commands::Command_Pet(Client* client, Seperator* sep)
  7669. {
  7670. PrintSep(sep, "COMMAND_PET");
  7671. //LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Pet Commands");
  7672. //client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7673. if (!sep || !sep->arg[0])
  7674. return; // should have sep->arg[0] filled
  7675. if (strcmp(sep->arg[0], "hide") == 0) {
  7676. // doing /pet hide will toggle the hide status on all the pets that can be hidden
  7677. Entity* pet = client->GetPlayer()->GetDeityPet();
  7678. if (pet) {
  7679. if (pet->IsPrivateSpawn())
  7680. client->GetPlayer()->HideDeityPet(false);
  7681. else
  7682. client->GetPlayer()->HideDeityPet(true);
  7683. }
  7684. pet = client->GetPlayer()->GetCosmeticPet();
  7685. if (pet) {
  7686. if (pet->IsPrivateSpawn())
  7687. client->GetPlayer()->HideCosmeticPet(false);
  7688. else
  7689. client->GetPlayer()->HideCosmeticPet(true);
  7690. }
  7691. return;
  7692. }
  7693. // below is for all combat pets
  7694. if (!client->GetPlayer()->HasPet()) {
  7695. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a pet.");
  7696. return;
  7697. }
  7698. if (strcmp(sep->arg[0], "stay") == 0 || strcmp(sep->arg[0], "stayhere") == 0) {
  7699. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to stay.");
  7700. client->GetPlayer()->GetInfoStruct()->set_pet_movement(1);
  7701. client->GetPlayer()->SetCharSheetChanged(true);
  7702. if (client->GetPlayer()->GetPet())
  7703. client->GetPlayer()->GetPet()->following = false;
  7704. if (client->GetPlayer()->GetCharmedPet())
  7705. client->GetPlayer()->GetCharmedPet()->following = false;
  7706. }
  7707. else if (strcmp(sep->arg[0], "follow") == 0 || strcmp(sep->arg[0], "followme") == 0) {
  7708. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to follow.");
  7709. client->GetPlayer()->GetInfoStruct()->set_pet_movement(2);
  7710. client->GetPlayer()->SetCharSheetChanged(true);
  7711. }
  7712. else if (strcmp(sep->arg[0], "preserve_master") == 0 || strcmp(sep->arg[0], "guardme") == 0) {
  7713. if (client->GetPlayer()->GetInfoStruct()->get_pet_behavior() & 1) {
  7714. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect you.");
  7715. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()-1);
  7716. }
  7717. else {
  7718. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect you.");
  7719. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()+1);
  7720. }
  7721. client->GetPlayer()->SetCharSheetChanged(true);
  7722. }
  7723. else if (strcmp(sep->arg[0], "preserve_self") == 0 || strcmp(sep->arg[0], "guardhere") == 0) { // guardhere might be accurate, diff logic
  7724. if (client->GetPlayer()->GetInfoStruct()->get_pet_behavior() & 2) {
  7725. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect itself.");
  7726. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()-2);
  7727. }
  7728. else {
  7729. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect itself.");
  7730. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()+2);
  7731. }
  7732. client->GetPlayer()->SetCharSheetChanged(true);
  7733. }
  7734. else if (strcmp(sep->arg[0], "backoff") == 0) {
  7735. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to back down.");
  7736. if (client->GetPlayer()->GetPet())
  7737. ((NPC*)client->GetPlayer()->GetPet())->Brain()->ClearHate();
  7738. if (client->GetPlayer()->GetCharmedPet())
  7739. ((NPC*)client->GetPlayer()->GetCharmedPet())->Brain()->ClearHate();
  7740. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(0);
  7741. client->GetPlayer()->SetCharSheetChanged(true);
  7742. }
  7743. else if (strcmp(sep->arg[0], "attack") == 0) {
  7744. if (client->GetPlayer()->HasTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  7745. if (client->GetPlayer()->AttackAllowed((Entity*)client->GetPlayer()->GetTarget())){
  7746. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to attack your target.");
  7747. if (client->GetPlayer()->GetPet())
  7748. client->GetPlayer()->GetPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  7749. if (client->GetPlayer()->GetCharmedPet())
  7750. client->GetPlayer()->GetCharmedPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  7751. }
  7752. else
  7753. client->Message(CHANNEL_COLOR_YELLOW, "You can not attack that.");
  7754. }
  7755. else
  7756. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a target.");
  7757. }
  7758. else if (strcmp(sep->arg[0], "getlost") == 0) {
  7759. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetPet());
  7760. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetCharmedPet());
  7761. client->Message(CHANNEL_COLOR_YELLOW, "You tell your pet to get lost.");
  7762. }
  7763. else
  7764. client->Message(CHANNEL_COLOR_YELLOW, "Unknown pet command %s.", sep->arg[0]);
  7765. }
  7766. /*
  7767. Function: Command_PetName()
  7768. Purpose : Pet your name (???)
  7769. Params :
  7770. Dev :
  7771. Example :
  7772. */
  7773. void Commands::Command_PetName(Client* client, Seperator* sep)
  7774. {
  7775. if (sep && sep->arg[0]) {
  7776. const char* pet_name = sep->argplus[0];
  7777. client->SetPetName(pet_name);
  7778. }
  7779. else {
  7780. client->GetPlayer()->GetInfoStruct()->set_pet_name("");
  7781. }
  7782. }
  7783. /*
  7784. Function: Command_NamePet()
  7785. Purpose : Name your pet
  7786. Params :
  7787. Dev :
  7788. Example :
  7789. */
  7790. void Commands::Command_NamePet(Client* client, Seperator* sep)
  7791. {
  7792. PrintSep(sep, "COMMAND_NAME_PET");
  7793. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Name Pet Command");
  7794. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7795. }
  7796. /*
  7797. Function: Command_Rename()
  7798. Purpose : Renames existing pet
  7799. Params :
  7800. Dev :
  7801. Example :
  7802. */
  7803. void Commands::Command_Rename(Client* client, Seperator* sep)
  7804. {
  7805. PrintSep(sep, "COMMAND_RENAME");
  7806. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Rename Pet Command");
  7807. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7808. }
  7809. /*
  7810. Function: Command_ConfirmRename()
  7811. Purpose : Confirms renaming your pet
  7812. Params :
  7813. Dev :
  7814. Example :
  7815. */
  7816. void Commands::Command_ConfirmRename(Client* client, Seperator* sep)
  7817. {
  7818. PrintSep(sep, "COMMAND_CONFIRMRENAME");
  7819. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Confirm Rename Pet Command");
  7820. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7821. }
  7822. /*
  7823. Function: Command_PetOptions()
  7824. Purpose : Sets various pet options
  7825. Params :
  7826. Dev :
  7827. Example :
  7828. */
  7829. void Commands::Command_PetOptions(Client* client, Seperator* sep)
  7830. {
  7831. PrintSep(sep, "COMMAND_PETOPTIONS");
  7832. Player* player = client->GetPlayer();
  7833. Spawn* target = player->GetTarget();
  7834. if (!target)
  7835. return;
  7836. if (target == player->GetPet())
  7837. client->SendPetOptionsWindow(player->GetPet()->GetName());
  7838. else if (target == player->GetCharmedPet())
  7839. client->SendPetOptionsWindow(player->GetCharmedPet()->GetName());
  7840. else if (target == player->GetCosmeticPet())
  7841. client->SendPetOptionsWindow(player->GetCosmeticPet()->GetName(), 0);
  7842. else if (target == player->GetDeityPet())
  7843. client->SendPetOptionsWindow(player->GetDeityPet()->GetName(), 0);
  7844. }
  7845. /*
  7846. Function: Command_Random()
  7847. Purpose : Handles /random dice roll in-game
  7848. Params : 1-100
  7849. Dev : Scatman
  7850. Example : /randon 1 100
  7851. */
  7852. void Commands::Command_Random(Client* client, Seperator* sep)
  7853. {
  7854. char message[256] = {0};
  7855. if (sep)
  7856. {
  7857. if (sep->GetArgNumber() == 0 && sep->IsNumber(0))
  7858. 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])));
  7859. else if (sep->GetArgNumber() > 0 && sep->IsNumber(0) && sep->IsNumber(1))
  7860. 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])));
  7861. else
  7862. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  7863. }
  7864. else
  7865. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  7866. client->GetPlayer()->GetZone()->HandleChatMessage(0, 0, CHANNEL_EMOTE, message);
  7867. }
  7868. /*
  7869. Function: Command_Randomize()
  7870. Purpose : Sets randomize (appearance) values for NPCs
  7871. Params : Attrib Name
  7872. Dev : Scatman
  7873. Example : /randomize gender 1 -- will randomize the NPCs gender (male/female)
  7874. */
  7875. void Commands::Command_Randomize(Client* client, Seperator* sep)
  7876. {
  7877. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  7878. if (target)
  7879. {
  7880. if (target->IsNPC())
  7881. {
  7882. if (sep && sep->arg[0] && !sep->IsNumber(0))
  7883. {
  7884. const char* value = sep->arg[0];
  7885. if (strncasecmp(value, "show", strlen(value)) == 0)
  7886. {
  7887. client->DisplayRandomizeFeatures(target->GetRandomize());
  7888. }
  7889. else
  7890. {
  7891. if (sep->arg[1] && sep->IsNumber(1))
  7892. {
  7893. int8 option = atoi(sep->arg[1]);
  7894. if (option == 0 || option == 1)
  7895. {
  7896. int32 feature = 0;
  7897. char feature_text[32] = {0};
  7898. if (strncasecmp(value, "gender", strlen(value)) == 0) {
  7899. feature = RANDOMIZE_GENDER;
  7900. strncpy(feature_text, "gender", sizeof(feature_text) - 1);
  7901. }
  7902. else if (strncasecmp(value, "race", strlen(value)) == 0) {
  7903. feature = RANDOMIZE_RACE;
  7904. strncpy(feature_text, "race", sizeof(feature_text) - 1);
  7905. }
  7906. else if (strncasecmp(value, "model", strlen(value)) == 0) {
  7907. feature = RANDOMIZE_MODEL_TYPE;
  7908. strncpy(feature_text, "model", sizeof(feature_text) - 1);
  7909. }
  7910. else if (strncasecmp(value, "facial_hair", strlen(value)) == 0) {
  7911. feature = RANDOMIZE_FACIAL_HAIR_TYPE;
  7912. strncpy(feature_text, "facial hair", sizeof(feature_text) - 1);
  7913. }
  7914. else if (strncasecmp(value, "hair", strlen(value)) == 0) {
  7915. feature = RANDOMIZE_HAIR_TYPE;
  7916. strncpy(feature_text, "hair", sizeof(feature_text) - 1);
  7917. }
  7918. else if (strncasecmp(value, "wing", strlen(value)) == 0) {
  7919. feature = RANDOMIZE_WING_TYPE;
  7920. strncpy(feature_text, "wings", sizeof(feature_text) - 1);
  7921. }
  7922. else if (strncasecmp(value, "cheek", strlen(value)) == 0) {
  7923. feature = RANDOMIZE_CHEEK_TYPE;
  7924. strncpy(feature_text, "cheeks", sizeof(feature_text) - 1);
  7925. }
  7926. else if (strncasecmp(value, "chin", strlen(value)) == 0) {
  7927. feature = RANDOMIZE_CHIN_TYPE;
  7928. strncpy(feature_text, "chin", sizeof(feature_text) - 1);
  7929. }
  7930. else if (strncasecmp(value, "ear", strlen(value)) == 0) {
  7931. feature = RANDOMIZE_EAR_TYPE;
  7932. strncpy(feature_text, "ears", sizeof(feature_text) - 1);
  7933. }
  7934. else if (strncasecmp(value, "eye_brow", strlen(value)) == 0) {
  7935. feature = RANDOMIZE_EYE_BROW_TYPE;
  7936. strncpy(feature_text, "eye brows", sizeof(feature_text) - 1);
  7937. }
  7938. else if (strncasecmp(value, "eye", strlen(value)) == 0) {
  7939. feature = RANDOMIZE_EYE_TYPE;
  7940. strncpy(feature_text, "eyes", sizeof(feature_text) - 1);
  7941. }
  7942. else if (strncasecmp(value, "lip", strlen(value)) == 0) {
  7943. feature = RANDOMIZE_LIP_TYPE;
  7944. strncpy(feature_text, "lips", sizeof(feature_text) - 1);
  7945. }
  7946. else if (strncasecmp(value, "nose", strlen(value)) == 0) {
  7947. feature = RANDOMIZE_NOSE_TYPE;
  7948. strncpy(feature_text, "nose", sizeof(feature_text) - 1);
  7949. }
  7950. else if (strncasecmp(value, "eye_color", strlen(value)) == 0) {
  7951. feature = RANDOMIZE_EYE_COLOR;
  7952. strncpy(feature_text, "eye color", sizeof(feature_text) - 1);
  7953. }
  7954. else if (strncasecmp(value, "hair_color", strlen(value)) == 0) {
  7955. feature = RANDOMIZE_HAIR_TYPE_COLOR;
  7956. strncpy(feature_text, "hair color", sizeof(feature_text) - 1);
  7957. }
  7958. else if (strncasecmp(value, "hair_color1", strlen(value)) == 0) {
  7959. feature = RANDOMIZE_HAIR_COLOR1;
  7960. strncpy(feature_text, "hair color1", sizeof(feature_text) - 1);
  7961. }
  7962. else if (strncasecmp(value, "hair_color2", strlen(value)) == 0) {
  7963. feature = RANDOMIZE_HAIR_COLOR2;
  7964. strncpy(feature_text, "hair color2", sizeof(feature_text) - 1);
  7965. }
  7966. else if (strncasecmp(value, "hair_highlight", strlen(value)) == 0) {
  7967. feature = RANDOMIZE_HAIR_HIGHLIGHT;
  7968. strncpy(feature_text, "hair highlights", sizeof(feature_text) - 1);
  7969. }
  7970. else if (strncasecmp(value, "facial_hair_color", strlen(value)) == 0) {
  7971. feature = RANDOMIZE_HAIR_FACE_COLOR;
  7972. strncpy(feature_text, "facial hair color", sizeof(feature_text) - 1);
  7973. }
  7974. else if (strncasecmp(value, "facial_hair_color_highlight", strlen(value)) == 0) {
  7975. feature = RANDOMIZE_HAIR_FACE_HIGHLIGHT_COLOR;
  7976. strncpy(feature_text, "facial hair color highlights", sizeof(feature_text) - 1);
  7977. }
  7978. else if (strncasecmp(value, "hair_color_highlight", strlen(value)) == 0) {
  7979. feature = RANDOMIZE_HAIR_TYPE_HIGHLIGHT_COLOR;
  7980. strncpy(feature_text, "hair color highlights", sizeof(feature_text) - 1);
  7981. }
  7982. else if (strncasecmp(value, "skin_color", strlen(value)) == 0) {
  7983. feature = RANDOMIZE_SKIN_COLOR;
  7984. strncpy(feature_text, "skin color", sizeof(feature_text) - 1);
  7985. }
  7986. else if (strncasecmp(value, "wing_color1", strlen(value)) == 0) {
  7987. feature = RANDOMIZE_WING_COLOR1;
  7988. strncpy(feature_text, "wing color1", sizeof(feature_text) - 1);
  7989. }
  7990. else if (strncasecmp(value, "wing_color2", strlen(value)) == 0) {
  7991. feature = RANDOMIZE_WING_COLOR2;
  7992. strncpy(feature_text, "wing color2", sizeof(feature_text) - 1);
  7993. }
  7994. else {
  7995. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is not a valid feature to randomize.", value);
  7996. 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'.");
  7997. }
  7998. if (feature > 0) {
  7999. if (option == 1) {
  8000. if (target->GetRandomize() & feature)
  8001. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is already set to randomly generate their %s.", target->GetName(), feature_text);
  8002. else {
  8003. target->AddRandomize(feature);
  8004. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(feature);
  8005. database.UpdateRandomize(target->GetDatabaseID(), feature);
  8006. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will now generate their %s randomly.", target->GetName(), feature_text);
  8007. }
  8008. }
  8009. else {
  8010. if (target->GetRandomize() & feature) {
  8011. target->AddRandomize(-feature);
  8012. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(-feature);
  8013. database.UpdateRandomize(target->GetDatabaseID(), -feature);
  8014. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will no longer generate their %s randomly.", target->GetName(), feature_text);
  8015. }
  8016. else
  8017. client->Message(CHANNEL_COLOR_YELLOW, "'%s' already does not randomly generate their %s.", target->GetName(), feature_text);
  8018. }
  8019. }
  8020. }
  8021. else
  8022. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  8023. }
  8024. else
  8025. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  8026. }
  8027. }
  8028. else {
  8029. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /randomize [show | [feature [1|0]]");
  8030. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "'show' will display current configured features");
  8031. 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'.");
  8032. }
  8033. }
  8034. else
  8035. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "The target you wish to randomize must be an NPC.");
  8036. }
  8037. else
  8038. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select the target you wish to randomize.");
  8039. }
  8040. /*
  8041. Function: Command_ShowCloak()
  8042. Purpose : Character Settings combo box for Show Cloak
  8043. Params : true/false
  8044. Dev : John Adams
  8045. Example :
  8046. */
  8047. void Commands::Command_ShowCloak(Client* client, Seperator* sep)
  8048. {
  8049. Player* player = client->GetPlayer();
  8050. if (sep && sep->arg[0])
  8051. {
  8052. const char* value = sep->arg[0];
  8053. if (strncasecmp(value, "true", strlen(value)) == 0)
  8054. {
  8055. player->set_character_flag(CF_SHOW_CLOAK);
  8056. player->reset_character_flag(CF2_SHOW_RANGED);
  8057. }
  8058. else if (strncasecmp(value, "false", strlen(value)) == 0)
  8059. player->reset_character_flag(CF_SHOW_CLOAK);
  8060. else
  8061. {
  8062. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8063. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8064. }
  8065. }
  8066. }
  8067. /*
  8068. Function: Command_ShowHelm()
  8069. Purpose : Character Settings combo box for Show Helm
  8070. Params : true/false
  8071. Dev : John Adams
  8072. Example :
  8073. */
  8074. void Commands::Command_ShowHelm(Client* client, Seperator* sep)
  8075. {
  8076. Player* player = client->GetPlayer();
  8077. if(client->GetVersion() <= 561) {
  8078. return; // not allowed/supported
  8079. }
  8080. if (sep && sep->arg[0])
  8081. {
  8082. PrintSep(sep, "Command_ShowHelm");
  8083. const char* value = sep->arg[0];
  8084. if (strncasecmp(value, "true", strlen(value)) == 0)
  8085. {
  8086. player->toggle_character_flag(CF_HIDE_HELM);
  8087. player->toggle_character_flag(CF_HIDE_HOOD);
  8088. }
  8089. else if (strncasecmp(value, "false", strlen(value)) == 0)
  8090. player->toggle_character_flag(CF_HIDE_HELM);
  8091. else
  8092. {
  8093. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8094. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8095. }
  8096. }
  8097. }
  8098. /*
  8099. Function: Command_ShowHood()
  8100. Purpose : Character Settings combo box for Show Hood
  8101. Params : true/false
  8102. Dev : John Adams
  8103. Example :
  8104. */
  8105. void Commands::Command_ShowHood(Client* client, Seperator* sep)
  8106. {
  8107. Player* player = client->GetPlayer();
  8108. if (sep && sep->arg[0])
  8109. {
  8110. PrintSep(sep, "Command_ShowHood");
  8111. const char* value = sep->arg[0];
  8112. if (strncasecmp(value, "true", strlen(value)) == 0)
  8113. {
  8114. player->toggle_character_flag(CF_HIDE_HOOD);
  8115. if(client->GetVersion() > 561) { // no hide helm support in DoF
  8116. player->toggle_character_flag(CF_HIDE_HELM);
  8117. }
  8118. }
  8119. else if (strncasecmp(value, "false", strlen(value)) == 0) {
  8120. player->toggle_character_flag(CF_HIDE_HOOD);
  8121. }
  8122. else
  8123. {
  8124. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8125. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8126. }
  8127. }
  8128. }
  8129. /*
  8130. Function: Command_ShowHoodHelm()
  8131. Purpose : Character Settings combo box for Show Helm or Hood
  8132. Params : true/false
  8133. Dev : John Adams
  8134. Example :
  8135. */
  8136. void Commands::Command_ShowHoodHelm(Client* client, Seperator* sep)
  8137. {
  8138. Player* player = client->GetPlayer();
  8139. if(client->GetVersion() <= 561) {
  8140. return; // not allowed/supported
  8141. }
  8142. if (sep && sep->arg[0])
  8143. {
  8144. PrintSep(sep, "Command_ShowHoodHelm");
  8145. const char* value = sep->arg[0];
  8146. if (strncasecmp(value, "true", strlen(value)) == 0)
  8147. {
  8148. player->toggle_character_flag(CF_HIDE_HOOD);
  8149. player->toggle_character_flag(CF_HIDE_HELM);
  8150. }
  8151. else if (strncasecmp(value, "false", strlen(value)) == 0)
  8152. {
  8153. // don't think we ever wind up in here...
  8154. player->toggle_character_flag(CF_HIDE_HOOD);
  8155. player->toggle_character_flag(CF_HIDE_HELM);
  8156. }
  8157. else
  8158. {
  8159. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8160. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8161. }
  8162. }
  8163. }
  8164. /*
  8165. Function: Command_ShowRanged()
  8166. Purpose : Character Settings combo box for Show Ranged weapon
  8167. Params : true/false
  8168. Dev : John Adams
  8169. Example :
  8170. */
  8171. void Commands::Command_ShowRanged(Client* client, Seperator* sep)
  8172. {
  8173. Player* player = client->GetPlayer();
  8174. if (sep && sep->arg[0])
  8175. {
  8176. const char* value = sep->arg[0];
  8177. if (strncasecmp(value, "true", strlen(value)) == 0)
  8178. {
  8179. player->set_character_flag(CF2_SHOW_RANGED);
  8180. player->reset_character_flag(CF_SHOW_CLOAK);
  8181. }
  8182. else if (strncasecmp(value, "false", strlen(value)) == 0)
  8183. player->reset_character_flag(CF2_SHOW_RANGED);
  8184. else
  8185. {
  8186. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8187. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  8188. }
  8189. }
  8190. }
  8191. /*
  8192. Function:
  8193. Purpose :
  8194. Params :
  8195. Dev :
  8196. Example :
  8197. */
  8198. void Commands::Command_Skills(Client* client, Seperator* sep, int handler)
  8199. {
  8200. Player* player = 0;
  8201. Client* to_client = 0;
  8202. if(client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  8203. to_client = ((Player*)client->GetPlayer()->GetTarget())->GetClient();
  8204. switch(handler)
  8205. {
  8206. case COMMAND_SKILL:
  8207. {
  8208. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill [add|remove|list] [skill name]");
  8209. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to add/remove skills for that player.");
  8210. break;
  8211. }
  8212. case COMMAND_SKILL_ADD:
  8213. {
  8214. if (sep && sep->arg[0])
  8215. {
  8216. const char* skill_name = sep->argplus[0];
  8217. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  8218. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // add skill to your target, if target is not you
  8219. {
  8220. player = to_client->GetPlayer();
  8221. if (player)
  8222. {
  8223. if (!player->GetSkills()->HasSkill(skill->skill_id))
  8224. {
  8225. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  8226. client->Message(CHANNEL_COLOR_YELLOW, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  8227. to_client->Message(CHANNEL_COLOR_YELLOW, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  8228. }
  8229. else
  8230. client->Message(CHANNEL_COLOR_YELLOW, "%s already has the skill '%s'.", player->GetName(), skill_name);
  8231. }
  8232. }
  8233. else if (skill) // add skill to yourself
  8234. {
  8235. player = client->GetPlayer();
  8236. if (player)
  8237. {
  8238. if (!player->GetSkills()->HasSkill(skill->skill_id))
  8239. {
  8240. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  8241. client->Message(CHANNEL_COLOR_YELLOW, "Added skill '%s'.", skill_name);
  8242. }
  8243. else
  8244. client->Message(CHANNEL_COLOR_YELLOW, "You already have the skill '%s'.", skill_name);
  8245. }
  8246. }
  8247. else
  8248. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  8249. }
  8250. else
  8251. {
  8252. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill add [skill name]");
  8253. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  8254. }
  8255. break;
  8256. }
  8257. case COMMAND_SKILL_REMOVE:
  8258. {
  8259. if (sep && sep->arg[0])
  8260. {
  8261. const char* skill_name = sep->argplus[0];
  8262. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  8263. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // remove skill from your target, if target is not you
  8264. {
  8265. player = to_client->GetPlayer();
  8266. if (player)
  8267. {
  8268. if (player->GetSkills()->HasSkill(skill->skill_id))
  8269. {
  8270. player->RemoveSkillFromDB(skill, true);
  8271. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  8272. to_client->Message(CHANNEL_COLOR_YELLOW, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  8273. }
  8274. else
  8275. client->Message(CHANNEL_COLOR_YELLOW, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  8276. }
  8277. }
  8278. else if(skill) // remove skill from yourself
  8279. {
  8280. Player* player = client->GetPlayer();
  8281. if (player)
  8282. {
  8283. if (player->GetSkills()->HasSkill(skill->skill_id))
  8284. {
  8285. player->RemoveSkillFromDB(skill, true);
  8286. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s'.", skill_name);
  8287. }
  8288. else
  8289. client->Message(CHANNEL_COLOR_YELLOW, "You do not have the skill '%s'.", skill_name);
  8290. }
  8291. }
  8292. else
  8293. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  8294. }
  8295. else
  8296. {
  8297. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill remove [skill name]");
  8298. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  8299. }
  8300. break;
  8301. }
  8302. case COMMAND_SKILL_LIST:
  8303. {
  8304. if (sep && sep->arg[0])
  8305. {
  8306. const char* skill_name = sep->argplus[0];
  8307. client->Message(CHANNEL_COLOR_YELLOW, "Listing skills like '%s':", skill_name);
  8308. map<int32, Skill*>* skills = master_skill_list.GetAllSkills();
  8309. map<int32, Skill*>::iterator itr;
  8310. if (skills && skills->size() > 0)
  8311. {
  8312. for (itr = skills->begin(); itr != skills->end(); itr++)
  8313. {
  8314. Skill* skill = itr->second;
  8315. string current_skill_name = ::ToLower(string(skill->name.data.c_str()));
  8316. if (current_skill_name.find(::ToLower(string(skill_name))) < 0xFFFFFFFF)
  8317. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", skill->name.data.c_str(), skill->skill_id);
  8318. }
  8319. }
  8320. }
  8321. else
  8322. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill list [skill name]");
  8323. break;
  8324. }
  8325. }
  8326. }
  8327. /*
  8328. Function: Command_SpawnTemplate()
  8329. Purpose : Create or Use defined Spawn Templates
  8330. Params : create, save, rempve, list
  8331. Dev : John Adams
  8332. Example : /spawn template create "Test"
  8333. */
  8334. void Commands::Command_SpawnTemplate(Client* client, Seperator* sep)
  8335. {
  8336. if (sep == NULL || sep->arg[0] == NULL)
  8337. {
  8338. 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.");
  8339. return;
  8340. }
  8341. // got params, continue
  8342. const char * template_cmd = sep->arg[0];
  8343. if (strncasecmp(template_cmd, "list", strlen(template_cmd)) == 0)
  8344. {
  8345. if (!sep->IsSet(1))
  8346. {
  8347. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /spawn template list [name|location_id]");
  8348. 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.");
  8349. return;
  8350. }
  8351. map<int32, string>* template_names = 0;
  8352. if (sep->IsNumber(1))
  8353. {
  8354. int32 location_id = 0;
  8355. location_id = atoi(sep->arg[1]);
  8356. template_names = database.GetSpawnTemplateListByID(location_id);
  8357. }
  8358. else
  8359. {
  8360. const char* name = 0;
  8361. name = sep->argplus[1];
  8362. template_names = database.GetSpawnTemplateListByName(name);
  8363. }
  8364. if(!template_names)
  8365. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No templates found.");
  8366. else
  8367. {
  8368. map<int32, string>::iterator itr;
  8369. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  8370. for(itr = template_names->begin(); itr != template_names->end(); itr++)
  8371. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  8372. safe_delete(template_names);
  8373. }
  8374. }
  8375. else if (strncasecmp(template_cmd, "save", strlen(template_cmd)) == 0)
  8376. {
  8377. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  8378. if ( target && (target->IsNPC() || target->IsObject() || target->IsSign() || target->IsWidget() || target->IsGroundSpawn()) )
  8379. {
  8380. if (sep && sep->arg[1][0] && !sep->IsNumber(1))
  8381. {
  8382. // first, lookup to see if template name already exists
  8383. const char* name = 0;
  8384. name = sep->argplus[1];
  8385. map<int32, string>* template_names = database.GetSpawnTemplateListByName(name);
  8386. if(!template_names)
  8387. {
  8388. int32 new_template_id = database.SaveSpawnTemplate(target->GetSpawnLocationID(), name);
  8389. if( new_template_id > 0 )
  8390. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template '%s' added for spawn '%s' (%u) as TemplateID: %u", name, target->GetName(), target->GetSpawnLocationID(), new_template_id);
  8391. else
  8392. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' for spawn '%s' (%u).", name, target->GetName(), target->GetSpawnLocationID());
  8393. }
  8394. else
  8395. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' - Already exists!", name);
  8396. }
  8397. else
  8398. client->Message(CHANNEL_COLOR_RED, "ERROR: Saving a new spawn template requires a valid template name!");
  8399. }
  8400. else
  8401. client->Message(CHANNEL_COLOR_RED, "ERROR: You must target the spawn you wish to save as a template!");
  8402. }
  8403. else if (strncasecmp(template_cmd, "remove", strlen(template_cmd)) == 0)
  8404. {
  8405. if (sep && sep->arg[1][0] && sep->IsNumber(1))
  8406. {
  8407. int32 template_id = 0;
  8408. template_id = atoi(sep->arg[1]);
  8409. if (database.RemoveSpawnTemplate(template_id))
  8410. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template ID: %u successfully removed.", template_id);
  8411. else
  8412. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to remove spawn template ID: %u", template_id);
  8413. }
  8414. else
  8415. client->Message(CHANNEL_COLOR_RED, "ERROR: Removing a spawn template requires a valid template ID!");
  8416. }
  8417. // Renamed create to spawn
  8418. else if (strncasecmp(template_cmd, "spawn", strlen(template_cmd)) == 0)
  8419. {
  8420. if (sep && sep->arg[1][0])
  8421. {
  8422. int32 new_location = 0;
  8423. if (sep->IsNumber(1))
  8424. {
  8425. int32 template_id = 0;
  8426. template_id = atoi(sep->arg[1]);
  8427. new_location = database.CreateSpawnFromTemplateByID(client, template_id);
  8428. if( new_location > 0 )
  8429. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template ID: %u", new_location, template_id);
  8430. else
  8431. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template ID: %u", template_id);
  8432. }
  8433. else
  8434. {
  8435. const char* name = 0;
  8436. name = sep->argplus[1];
  8437. new_location = database.CreateSpawnFromTemplateByName(client, name);
  8438. if( new_location > 0 )
  8439. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template: '%s'", new_location, name);
  8440. else
  8441. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template: '%s'", name);
  8442. }
  8443. }
  8444. else
  8445. client->Message(CHANNEL_COLOR_RED, "ERROR: Spawning a new spawn location requires a valid template name or ID!");
  8446. }
  8447. else
  8448. client->Message(CHANNEL_COLOR_RED, "ERROR: Unknown /spawn template command.");
  8449. }
  8450. void Commands::Command_Speed(Client* client, Seperator* sep) {
  8451. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  8452. float new_speed = atof(sep->arg[0]);
  8453. if (new_speed > 0.0f)
  8454. {
  8455. client->GetPlayer()->SetSpeed(new_speed, true);
  8456. client->GetPlayer()->SetCharSheetChanged(true);
  8457. database.insertCharacterProperty(client, CHAR_PROPERTY_SPEED, sep->arg[0]);
  8458. client->Message(CHANNEL_STATUS, "Setting speed to %.2f.", new_speed);
  8459. }
  8460. else
  8461. client->Message(CHANNEL_STATUS, "Invalid speed provided %s.", sep->arg[0]);
  8462. }
  8463. else{
  8464. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /speed {new speed value}");
  8465. }
  8466. }
  8467. /*
  8468. Function: Command_StationMarketPlace()
  8469. Purpose : just trying to eat the console spam for now
  8470. Params :
  8471. Dev : John
  8472. */
  8473. void Commands::Command_StationMarketPlace(Client* client, Seperator* sep)
  8474. {
  8475. PrintSep(sep, "COMMAND_SMP");
  8476. // This will reduce the spam from once every 10 sec to once every 30 sec,
  8477. // can't seem to reduce it any more get rid of it completely...
  8478. if (sep && strcmp(sep->arg[0], "gkw") == 0) {
  8479. PacketStruct* packet = configReader.getStruct("WS_MarketFundsUpdate", client->GetVersion());
  8480. if (packet) {
  8481. packet->setDataByName("account_id", client->GetAccountID());
  8482. packet->setDataByName("character_id", client->GetCharacterID());
  8483. packet->setDataByName("unknown1", 1, 5);
  8484. packet->setDataByName("unknown1", 26, 6);
  8485. packet->setDataByName("unknown2", 0xFFFFFFFF);
  8486. packet->setDataByName("unknown3", 248, 1);
  8487. client->QueuePacket(packet->serialize());
  8488. }
  8489. safe_delete(packet);
  8490. }
  8491. }
  8492. /*
  8493. Function: Command_StopDrinking()
  8494. Purpose : Stops player from auto-consuming drink
  8495. Params :
  8496. Dev : Zcoretri
  8497. Example : /stopdrinking
  8498. */
  8499. void Commands::Command_StopDrinking(Client* client)
  8500. {
  8501. client->GetPlayer()->reset_character_flag(CF_DRINK_AUTO_CONSUME);
  8502. client->GetPlayer()->SetActiveDrinkUniqueID(0);
  8503. client->Message(CHANNEL_COLOR_YELLOW,"You stop drinking your current drink.");
  8504. }
  8505. /*
  8506. Function: Command_StopEating()
  8507. Purpose : Stops player from auto-consuming food
  8508. Params :
  8509. Dev : Zcoretri
  8510. Example : /stopeating
  8511. */
  8512. void Commands::Command_StopEating(Client* client)
  8513. {
  8514. client->GetPlayer()->reset_character_flag(CF_FOOD_AUTO_CONSUME);
  8515. client->GetPlayer()->SetActiveFoodUniqueID(0);
  8516. client->Message(CHANNEL_COLOR_YELLOW,"You stop eating your current food.");
  8517. }
  8518. /*
  8519. Function: Command_Title()
  8520. Purpose : Help for /title command
  8521. Params : n/a
  8522. Dev : Zcoretri
  8523. Example : /title
  8524. */
  8525. void Commands::Command_Title(Client* client)
  8526. {
  8527. client->Message(CHANNEL_COLOR_YELLOW, "Available subcommands: list, setprefix <index>, setsuffix <index>, fix");
  8528. }
  8529. /*
  8530. Function: Command_TitleList()
  8531. Purpose : List available titles for player
  8532. Params : n/a
  8533. Dev : Zcoretri
  8534. Example : /title list
  8535. */
  8536. void Commands::Command_TitleList(Client* client)
  8537. {
  8538. // must call release read lock before leaving function on GetPlayerTitles
  8539. vector<Title*>* titles = client->GetPlayer()->GetPlayerTitles()->GetAllTitles();
  8540. vector<Title*>::iterator itr;
  8541. Title* title;
  8542. sint32 i = 0;
  8543. client->Message(CHANNEL_NARRATIVE, "Listing available titles:");
  8544. for(itr = titles->begin(); itr != titles->end(); itr++)
  8545. {
  8546. title = *itr;
  8547. client->Message(CHANNEL_NARRATIVE, "%i: type=[%s] title=[%s]", i, title->GetPrefix() ? "Prefix":"Suffix", title->GetName());
  8548. i++;
  8549. }
  8550. client->GetPlayer()->GetPlayerTitles()->ReleaseReadLock();
  8551. }
  8552. /*
  8553. Function: Command_TitleSetPrefix()
  8554. Purpose : Set Prefix title for player
  8555. Params : Title ID
  8556. Dev : Zcoretri
  8557. Example : /title setprefix 1
  8558. */
  8559. void Commands::Command_TitleSetPrefix(Client* client, Seperator* sep)
  8560. {
  8561. if (sep && sep->arg[0] && sep->IsNumber(0))
  8562. {
  8563. sint32 index = atoul(sep->arg[0]);
  8564. if(index > -1)
  8565. {
  8566. Title* title = client->GetPlayer()->GetPlayerTitles()->GetTitle(index);
  8567. if(!title)
  8568. {
  8569. client->Message(CHANNEL_COLOR_RED, "Missing index %i to set title", index);
  8570. return;
  8571. }
  8572. else if(!title->GetPrefix())
  8573. {
  8574. client->Message(CHANNEL_COLOR_RED, "%s is not a prefix.", title->GetName());
  8575. return;
  8576. }
  8577. }
  8578. else // make sure client doesn't pass some bogus negative index
  8579. index = -1;
  8580. database.SaveCharPrefixIndex(index, client->GetCharacterID());
  8581. client->SendTitleUpdate();
  8582. }
  8583. }
  8584. /*
  8585. Function: Command_TitleSetSuffix()
  8586. Purpose : Set Suffix title for player
  8587. Params : Title ID
  8588. Dev : Zcoretri
  8589. Example : /title setsuffix 1
  8590. */
  8591. void Commands::Command_TitleSetSuffix(Client* client, Seperator* sep)
  8592. {
  8593. if (sep && sep->arg[0] && sep->IsNumber(0))
  8594. {
  8595. sint32 index = atoul(sep->arg[0]);
  8596. if(index > -1)
  8597. {
  8598. Title* title = client->GetPlayer()->GetPlayerTitles()->GetTitle(index);
  8599. if(!title)
  8600. {
  8601. client->Message(CHANNEL_COLOR_RED, "Missing index %i to set title", index);
  8602. return;
  8603. }
  8604. else if(title->GetPrefix())
  8605. {
  8606. client->Message(CHANNEL_COLOR_RED, "%s is not a suffix.", title->GetName());
  8607. return;
  8608. }
  8609. }
  8610. else // make sure client doesn't pass some bogus negative index
  8611. index = -1;
  8612. database.SaveCharSuffixIndex(index, client->GetCharacterID());
  8613. client->SendTitleUpdate();
  8614. }
  8615. }
  8616. /*
  8617. Function: Command_TitleFix()
  8618. Purpose : Fix title for player (???)
  8619. Params :
  8620. Dev : Zcoretri
  8621. Example :
  8622. */
  8623. void Commands::Command_TitleFix(Client* client, Seperator* sep)
  8624. {
  8625. PrintSep(sep, "COMMAND_TITLE_FIX");
  8626. LogWrite(MISC__TODO, 1, "Titles", "TODO-Command: TITLE_FIX");
  8627. }
  8628. /*
  8629. Function: Command_Toggle_Anonymous()
  8630. Purpose : Toggles player Anonymous
  8631. Params :
  8632. Dev : paulgh
  8633. Example : /anon
  8634. */
  8635. void Commands::Command_Toggle_Anonymous(Client* client)
  8636. {
  8637. Player* player = client->GetPlayer();
  8638. player->toggle_character_flag(CF_ANONYMOUS);
  8639. client->Message(CHANNEL_COLOR_YELLOW,"You are %s anonymous.", player->get_character_flag(CF_ANONYMOUS)?"now":"no longer");
  8640. if (player->get_character_flag(CF_ANONYMOUS))
  8641. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ANONYMOUS);
  8642. else
  8643. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ANONYMOUS);
  8644. }
  8645. /*
  8646. Function: Command_Toggle_AutoConsume()
  8647. Purpose : Toggles player food/drink auto consume
  8648. Params : unknown
  8649. Dev : paulgh
  8650. Example : /set_auto_consume
  8651. */
  8652. void Commands::Command_Toggle_AutoConsume(Client* client, Seperator* sep)
  8653. {
  8654. Player* player = client->GetPlayer();
  8655. if (sep && sep->arg[0])
  8656. PrintSep(sep, "COMMAND_SET_AUTO_CONSUME");
  8657. if (sep && sep->arg[0] && sep->IsNumber(0))
  8658. {
  8659. int8 slot = atoi(sep->arg[0]);
  8660. int8 flag = atoi(sep->arg[1]);
  8661. if (client->GetVersion() <= 373) {
  8662. slot += 4;
  8663. }
  8664. else if (client->GetVersion() <= 561) {
  8665. slot += 2;
  8666. }
  8667. if (slot == EQ2_FOOD_SLOT)
  8668. {
  8669. player->toggle_character_flag(CF_FOOD_AUTO_CONSUME);
  8670. player->SetCharSheetChanged(true);
  8671. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  8672. if (flag == 1)
  8673. client->Message(CHANNEL_NARRATIVE, "You decide to eat immediately whenever you become hungry.");
  8674. else
  8675. {
  8676. client->Message(CHANNEL_NARRATIVE, "You decide to ignore the hunger.");
  8677. return;
  8678. }
  8679. }
  8680. else
  8681. {
  8682. player->toggle_character_flag(CF_DRINK_AUTO_CONSUME);
  8683. player->SetCharSheetChanged(true);
  8684. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  8685. if (flag == 1)
  8686. client->Message(CHANNEL_NARRATIVE, "You decide to drink immediately whenever you become thirsty.");
  8687. else
  8688. {
  8689. client->Message(CHANNEL_NARRATIVE, "You decide to ignore the thirst.");
  8690. return;
  8691. }
  8692. }
  8693. if(!client->CheckConsumptionAllowed(slot, false))
  8694. return;
  8695. Item* item = player->GetEquipmentList()->GetItem(slot);
  8696. if(item)
  8697. client->ConsumeFoodDrink(item, slot);
  8698. }
  8699. }
  8700. /*
  8701. Function: Command_Toggle_BonusXP()
  8702. Purpose : Toggles player Bonus XP
  8703. Params :
  8704. Dev : John Adams
  8705. Example : /disable_char_bonus_exp
  8706. */
  8707. void Commands::Command_Toggle_BonusXP(Client* client)
  8708. {
  8709. Player* player = client->GetPlayer();
  8710. player->toggle_character_flag(CF2_CHARACTER_BONUS_EXPERIENCE_ENABLED);
  8711. player->SetCharSheetChanged(true);
  8712. }
  8713. /*
  8714. Function: Command_Toggle_CombatXP()
  8715. Purpose : Toggles player Adventure XP
  8716. Params :
  8717. Dev : John Adams
  8718. Example : /disable_combat_exp
  8719. */
  8720. void Commands::Command_Toggle_CombatXP(Client* client)
  8721. {
  8722. Player* player = client->GetPlayer();
  8723. player->toggle_character_flag(CF_COMBAT_EXPERIENCE_ENABLED);
  8724. player->SetCharSheetChanged(true);
  8725. }
  8726. /*
  8727. Function: Command_Toggle_GMHide()
  8728. Purpose : Toggles hiding player GM status
  8729. Params :
  8730. Dev : Scatman
  8731. Example : /gm_hide
  8732. */
  8733. void Commands::Command_Toggle_GMHide(Client* client)
  8734. {
  8735. Player* player = client->GetPlayer();
  8736. player->toggle_character_flag(CF_HIDE_STATUS);
  8737. client->Message(CHANNEL_COLOR_YELLOW,"You are %s hiding your GM status.", player->get_character_flag(CF_HIDE_STATUS)?"now":"no longer");
  8738. }
  8739. /*
  8740. Function: Command_Toggle_GMVanish()
  8741. Purpose : Toggles hiding GM players from /who searches
  8742. Params :
  8743. Dev : Scatman
  8744. Example : /gm_vanish
  8745. */
  8746. void Commands::Command_Toggle_GMVanish(Client* client)
  8747. {
  8748. Player* player = client->GetPlayer();
  8749. player->toggle_character_flag(CF_GM_HIDDEN);
  8750. client->Message(CHANNEL_COLOR_YELLOW,"You are %s invisible to who queries.", player->get_character_flag(CF_GM_HIDDEN)?"now":"no longer");
  8751. }
  8752. /*
  8753. Function: Command_Toggle_Illusions()
  8754. Purpose : Toggles player illusion form
  8755. Params : not sure sep is needed, testing
  8756. Dev : paulgh
  8757. Example : /hide_illusions
  8758. */
  8759. void Commands::Command_Toggle_Illusions(Client* client, Seperator* sep)
  8760. {
  8761. if (sep && sep->arg[0])
  8762. PrintSep(sep, "COMMAND_TOGGLE_ILLUSIONS");
  8763. client->GetPlayer()->toggle_character_flag(CF_SHOW_ILLUSION);
  8764. }
  8765. /*
  8766. Function: Command_Toggle_LFG()
  8767. Purpose : Toggles player LFG Flag
  8768. Params :
  8769. Dev : paulgh
  8770. Example : /lfg
  8771. */
  8772. void Commands::Command_Toggle_LFG(Client* client)
  8773. {
  8774. Player* player = client->GetPlayer();
  8775. player->toggle_character_flag(CF_LFG);
  8776. client->Message(CHANNEL_COLOR_YELLOW,"You are %s LFG.", player->get_character_flag(CF_LFG)?"now":"no longer");
  8777. if (player->get_character_flag(CF_LFG))
  8778. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFG);
  8779. else
  8780. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFG);
  8781. }
  8782. /*
  8783. Function: Command_Toggle_LFW()
  8784. Purpose : Toggles player LFW Flag
  8785. Params :
  8786. Dev : paulgh
  8787. Example : /lfw
  8788. */
  8789. void Commands::Command_Toggle_LFW(Client* client)
  8790. {
  8791. Player* player = client->GetPlayer();
  8792. player->toggle_character_flag(CF_LFW);
  8793. client->Message(CHANNEL_COLOR_YELLOW,"You %s looking for work.", player->get_character_flag(CF_LFW)?"let others know you are":"stop");
  8794. if (player->get_character_flag(CF_LFW))
  8795. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFW);
  8796. else
  8797. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFW);
  8798. }
  8799. /*
  8800. Function: Command_Toggle_QuestXP()
  8801. Purpose : Toggles player Quest XP
  8802. Params :
  8803. Dev : John Adams
  8804. Example : /disable_quest_exp
  8805. */
  8806. void Commands::Command_Toggle_QuestXP(Client* client)
  8807. {
  8808. Player* player = client->GetPlayer();
  8809. player->toggle_character_flag(CF_QUEST_EXPERIENCE_ENABLED);
  8810. player->SetCharSheetChanged(true);
  8811. }
  8812. /*
  8813. Function: Command_Toggle_Roleplaying()
  8814. Purpose : Toggles player Roleplaying flag
  8815. Params :
  8816. Dev : paulgh
  8817. Example : /role
  8818. */
  8819. void Commands::Command_Toggle_Roleplaying(Client* client)
  8820. {
  8821. Player* player = client->GetPlayer();
  8822. player->toggle_character_flag(CF_ROLEPLAYING);
  8823. client->Message(CHANNEL_COLOR_YELLOW,"You are %s roleplaying.", player->get_character_flag(CF_ROLEPLAYING)?"now":"no longer");
  8824. if (player->get_character_flag(CF_ROLEPLAYING))
  8825. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ROLEPLAYING);
  8826. else
  8827. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ROLEPLAYING);
  8828. }
  8829. void Commands::Command_Toggle_Duels(Client* client)
  8830. {
  8831. Player* player = client->GetPlayer();
  8832. player->toggle_character_flag(CF_ALLOW_DUEL_INVITES);
  8833. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting duel invites.", player->get_character_flag(CF_ALLOW_DUEL_INVITES)?"now":"no longer");
  8834. }
  8835. void Commands::Command_Toggle_Trades(Client* client)
  8836. {
  8837. Player* player = client->GetPlayer();
  8838. player->toggle_character_flag(CF_ALLOW_TRADE_INVITES);
  8839. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting trade invites.", player->get_character_flag(CF_ALLOW_TRADE_INVITES)?"now":"no longer");
  8840. }
  8841. void Commands::Command_Toggle_Guilds(Client* client)
  8842. {
  8843. Player* player = client->GetPlayer();
  8844. player->toggle_character_flag(CF_ALLOW_GUILD_INVITES);
  8845. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting guild invites.", player->get_character_flag(CF_ALLOW_GUILD_INVITES)?"now":"no longer");
  8846. }
  8847. void Commands::Command_Toggle_Groups(Client* client)
  8848. {
  8849. Player* player = client->GetPlayer();
  8850. player->toggle_character_flag(CF_ALLOW_GROUP_INVITES);
  8851. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting group invites.", player->get_character_flag(CF_ALLOW_GROUP_INVITES)?"now":"no longer");
  8852. }
  8853. void Commands::Command_Toggle_Raids(Client* client)
  8854. {
  8855. Player* player = client->GetPlayer();
  8856. player->toggle_character_flag(CF_ALLOW_RAID_INVITES);
  8857. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting raid invites.", player->get_character_flag(CF_ALLOW_RAID_INVITES)?"now":"no longer");
  8858. }
  8859. void Commands::Command_Toggle_LON(Client* client)
  8860. {
  8861. Player* player = client->GetPlayer();
  8862. player->toggle_character_flag(CF2_ALLOW_LON_INVITES);
  8863. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting LoN invites.", player->get_character_flag(CF2_ALLOW_LON_INVITES)?"now":"no longer");
  8864. }
  8865. void Commands::Command_Toggle_VoiceChat(Client* client)
  8866. {
  8867. Player* player = client->GetPlayer();
  8868. player->toggle_character_flag(CF2_ALLOW_VOICE_INVITES);
  8869. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting voice chat invites.", player->get_character_flag(CF2_ALLOW_VOICE_INVITES)?"now":"no longer");
  8870. }
  8871. /*
  8872. Function: Command_TradeStart()
  8873. Purpose : Starts item/coin trade between players
  8874. Params :
  8875. Dev :
  8876. Example :
  8877. */
  8878. #include "../Trade.h"
  8879. void Commands::Command_TradeStart(Client* client, Seperator* sep)
  8880. {
  8881. PrintSep(sep, "COMMAND_START_TRADE");
  8882. Entity* trader = client->GetPlayer();
  8883. Entity* trader2 = 0;
  8884. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  8885. Spawn* spawn = client->GetPlayer()->GetSpawnWithPlayerID(atoi(sep->arg[0]));
  8886. if (spawn) {
  8887. if (spawn->IsEntity())
  8888. trader2 = (Entity*)spawn;
  8889. }
  8890. }
  8891. else if (client->GetPlayer()->GetTarget()) {
  8892. if (client->GetPlayer()->GetTarget()->IsEntity())
  8893. trader2 = (Entity*)client->GetPlayer()->GetTarget();
  8894. }
  8895. // can only trade with player or bots
  8896. if (trader && trader2) {
  8897. if (trader == trader2) {
  8898. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade with yourself.");
  8899. }
  8900. else if (trader2->IsPlayer() || trader2->IsBot()) {
  8901. LogWrite(PLAYER__ERROR, 0, "Trade", "creating trade");
  8902. if (trader->trade)
  8903. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are already trading.");
  8904. else if (trader2->trade)
  8905. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is already trading.");
  8906. else {
  8907. Trade* trade = new Trade(trader, trader2);
  8908. trader->trade = trade;
  8909. trader2->trade = trade;
  8910. }
  8911. }
  8912. else {
  8913. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can only trade with another player or a bot.");
  8914. }
  8915. }
  8916. else
  8917. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to find target");
  8918. }
  8919. /*
  8920. Function: Command_Track()
  8921. Purpose : Starts/Stops Tracking for a player
  8922. Params :
  8923. Dev : Scatman
  8924. Example : /track
  8925. */
  8926. void Commands::Command_Track(Client* client)
  8927. {
  8928. if (!client->GetPlayer()->GetIsTracking())
  8929. client->GetPlayer()->GetZone()->AddPlayerTracking(client->GetPlayer());
  8930. else
  8931. client->GetPlayer()->GetZone()->RemovePlayerTracking(client->GetPlayer(), TRACKING_STOP);
  8932. }
  8933. /*
  8934. Function: Command_TradeAccept()
  8935. Purpose : Accepts item/coin trade between players
  8936. Params :
  8937. Dev :
  8938. Example :
  8939. */
  8940. void Commands::Command_TradeAccept(Client* client, Seperator* sep)
  8941. {
  8942. PrintSep(sep, "COMMAND_ACCEPT_TRADE");
  8943. Trade* trade = client->GetPlayer()->trade;
  8944. if (trade) {
  8945. bool trade_complete = trade->SetTradeAccepted(client->GetPlayer());
  8946. if (trade_complete)
  8947. safe_delete(trade);
  8948. }
  8949. else
  8950. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8951. }
  8952. /*
  8953. Function: Command_TradeReject()
  8954. Purpose : Rejects item/coin trade between players
  8955. Params :
  8956. Dev :
  8957. Example :
  8958. */
  8959. void Commands::Command_TradeReject(Client* client, Seperator* sep)
  8960. {
  8961. PrintSep(sep, "COMMAND_REJECT_TRADE");
  8962. Command_TradeCancel(client, sep);
  8963. }
  8964. /*
  8965. Function: Command_TradeCancel()
  8966. Purpose : Cancels item/coin trade between players
  8967. Params :
  8968. Dev :
  8969. Example :
  8970. */
  8971. void Commands::Command_TradeCancel(Client* client, Seperator* sep)
  8972. {
  8973. PrintSep(sep, "COMMAND_CANCEL_TRADE");
  8974. Trade* trade = client->GetPlayer()->trade;
  8975. if (trade) {
  8976. trade->CancelTrade(client->GetPlayer());
  8977. safe_delete(trade);
  8978. }
  8979. else
  8980. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8981. }
  8982. /*
  8983. Function: Command_TradeSetCoin()
  8984. Purpose : Sets coin trade between players
  8985. Params :
  8986. Dev :
  8987. Example :
  8988. */
  8989. void Commands::Command_TradeSetCoin(Client* client, Seperator* sep)
  8990. {
  8991. PrintSep(sep, "COMMAND_SET_TRADE_COIN");
  8992. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Set Trade Coin");
  8993. client->Message(CHANNEL_COLOR_YELLOW, "You cannot trade with other players (Not Implemented)");
  8994. }
  8995. /*
  8996. Function: Command_TradeAddCoin()
  8997. Purpose : Adds coin to trade between players
  8998. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  8999. Dev :
  9000. Example :
  9001. */
  9002. void Commands::Command_TradeAddCoin(Client* client, Seperator* sep, int handler)
  9003. {
  9004. PrintSep(sep, "COMMAND_ADD_TRADE_{coin type}");
  9005. Trade* trade = client->GetPlayer()->trade;
  9006. if (trade) {
  9007. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  9008. int32 amount = atoi(sep->arg[0]);
  9009. int64 val = 0;
  9010. switch (handler) {
  9011. case COMMAND_ADD_TRADE_COPPER:
  9012. {
  9013. val = amount;
  9014. trade->AddCoinToTrade(client->GetPlayer(), val);
  9015. break;
  9016. }
  9017. case COMMAND_ADD_TRADE_SILVER:
  9018. {
  9019. val = amount * 100;
  9020. trade->AddCoinToTrade(client->GetPlayer(), val);
  9021. break;
  9022. }
  9023. case COMMAND_ADD_TRADE_GOLD:
  9024. {
  9025. val = amount * 10000;
  9026. trade->AddCoinToTrade(client->GetPlayer(), val);
  9027. break;
  9028. }
  9029. case COMMAND_ADD_TRADE_PLAT:
  9030. {
  9031. val = amount * 1000000;
  9032. trade->AddCoinToTrade(client->GetPlayer(), val);
  9033. break;
  9034. }
  9035. default:
  9036. {
  9037. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  9038. break;
  9039. }
  9040. }
  9041. }
  9042. else
  9043. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount.");
  9044. }
  9045. else
  9046. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  9047. }
  9048. /*
  9049. Function: Command_TradeRemoveCoin()
  9050. Purpose : Removes coin from trade between players
  9051. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  9052. Dev :
  9053. Example :
  9054. */
  9055. void Commands::Command_TradeRemoveCoin(Client* client, Seperator* sep, int handler)
  9056. {
  9057. PrintSep(sep, "COMMAND_REMOVE_TRADE_{coin type}");
  9058. Trade* trade = client->GetPlayer()->trade;
  9059. if (trade) {
  9060. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  9061. int32 amount = atoi(sep->arg[0]);
  9062. int64 val = 0;
  9063. switch (handler) {
  9064. case COMMAND_REMOVE_TRADE_COPPER:
  9065. {
  9066. val = amount;
  9067. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  9068. break;
  9069. }
  9070. case COMMAND_REMOVE_TRADE_SILVER:
  9071. {
  9072. val = amount * 100;
  9073. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  9074. break;
  9075. }
  9076. case COMMAND_REMOVE_TRADE_GOLD:
  9077. {
  9078. val = amount * 10000;
  9079. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  9080. break;
  9081. }
  9082. case COMMAND_REMOVE_TRADE_PLAT:
  9083. {
  9084. val = amount * 1000000;
  9085. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  9086. break;
  9087. }
  9088. default:
  9089. {
  9090. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  9091. break;
  9092. }
  9093. }
  9094. }
  9095. else
  9096. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount");
  9097. }
  9098. else
  9099. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  9100. }
  9101. /*
  9102. Function: Command_TradeAddItem()
  9103. Purpose : Adds item to trade between players
  9104. Params :
  9105. Dev :
  9106. Example :
  9107. */
  9108. void Commands::Command_TradeAddItem(Client* client, Seperator* sep)
  9109. {
  9110. PrintSep(sep, "COMMAND_ADD_TRADE_ITEM");
  9111. /*
  9112. arg[0] = item index
  9113. arg[1] = slot
  9114. arg[2] = quantity
  9115. */
  9116. if (!client->GetPlayer()->trade) {
  9117. LogWrite(PLAYER__ERROR, 0, "Trade", "Player is not currently trading.");
  9118. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  9119. return;
  9120. }
  9121. if (sep && sep->IsSet(0) && sep->IsNumber(0) && sep->IsSet(1) && sep->IsNumber(1) && sep->IsSet(2) && sep->IsNumber(2)) {
  9122. Item* item = 0;
  9123. int32 index = atoi(sep->arg[0]);
  9124. item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(index);
  9125. if (item) {
  9126. int8 result = client->GetPlayer()->trade->AddItemToTrade(client->GetPlayer(), item, atoi(sep->arg[2]), atoi(sep->arg[1]));
  9127. if (result == 1)
  9128. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Item is already being traded.");
  9129. else if (result == 2)
  9130. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade NO-TRADE items.");
  9131. else if (result == 3)
  9132. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade HEIRLOOM items.");
  9133. else if (result == 254)
  9134. client->Message(CHANNEL_COLOR_YELLOW, "You are trading with an older client with a %u trade slot restriction...", client->GetPlayer()->trade->MaxSlots());
  9135. else if (result == 255)
  9136. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown error trying to add the item to the trade...");
  9137. }
  9138. else {
  9139. LogWrite(PLAYER__ERROR, 0, "Trade", "Unable to get an item for the player (%s) from the index (%u)", client->GetPlayer()->GetName(), index);
  9140. client->Message(CHANNEL_ERROR, "Unable to find item at index %u", index);
  9141. }
  9142. }
  9143. else
  9144. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  9145. }
  9146. /*
  9147. Function: Command_TradeRemoveItem()
  9148. Purpose : Removes item from trade between players
  9149. Params :
  9150. Dev :
  9151. Example :
  9152. */
  9153. void Commands::Command_TradeRemoveItem(Client* client, Seperator* sep)
  9154. {
  9155. PrintSep(sep, "COMMAND_REMOVE_TRADE_ITEM");
  9156. /*
  9157. arg[0] = trade window slot
  9158. */
  9159. Trade* trade = client->GetPlayer()->trade;
  9160. if (trade) {
  9161. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  9162. trade->RemoveItemFromTrade(client->GetPlayer(), atoi(sep->arg[0]));
  9163. }
  9164. else
  9165. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  9166. }
  9167. else
  9168. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  9169. }
  9170. void Commands::Command_TryOn(Client* client, Seperator* sep)
  9171. {
  9172. Item *item = 0;
  9173. sint32 crc;
  9174. if (sep) {
  9175. // 1096+ sends more info so need to do a version check so older clients (SF) still work
  9176. if (client->GetVersion() < 1096) {
  9177. if (sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2))
  9178. {
  9179. item = master_item_list.GetItem(atoul(sep->arg[1]));
  9180. crc = atol(sep->arg[2]);
  9181. }
  9182. }
  9183. else {
  9184. // From the broker and links in chat
  9185. if (strcmp(sep->arg[0], "crc") == 0) {
  9186. if (sep->IsNumber(2) && sep->IsNumber(3)) {
  9187. item = master_item_list.GetItem(atoul(sep->arg[2]));
  9188. crc = atol(sep->arg[3]);
  9189. }
  9190. }
  9191. // From inventory
  9192. if (strcmp(sep->arg[0], "dbid") == 0) {
  9193. if (sep->IsNumber(2) && sep->IsNumber(4)) {
  9194. item = master_item_list.GetItem(atoul(sep->arg[2]));
  9195. crc = atol(sep->arg[4]);
  9196. }
  9197. }
  9198. }
  9199. if (item)
  9200. client->ShowDressingRoom(item, crc);
  9201. }
  9202. }
  9203. void Commands::Command_JoinChannel(Client * client, Seperator *sep) {
  9204. const char *channel_name, *password = NULL;
  9205. if (sep == NULL || !sep->IsSet(0)) {
  9206. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /joinchannel <channel name> [password]");
  9207. return;
  9208. }
  9209. channel_name = sep->arg[0];
  9210. if (sep->IsSet(1))
  9211. password = sep->arg[1];
  9212. if (!chat.ChannelExists(channel_name) && !chat.CreateChannel(channel_name, password)) {
  9213. client->Message(CHANNEL_COLOR_RED, "Unable to create channel '%s'.", channel_name);
  9214. return;
  9215. }
  9216. if (chat.IsInChannel(client, channel_name)) {
  9217. client->Message(CHANNEL_NARRATIVE, "You are already in '%s'.", channel_name);
  9218. return;
  9219. }
  9220. if (chat.HasPassword(channel_name)) {
  9221. if (password == NULL) {
  9222. client->Message(CHANNEL_NARRATIVE, "Unable to join '%s': That channel is password protected.", channel_name);
  9223. return;
  9224. }
  9225. if (!chat.PasswordMatches(channel_name, password)) {
  9226. client->Message(CHANNEL_NARRATIVE, "Unable to join '%s': The password is not correc.t", channel_name);
  9227. return;
  9228. }
  9229. }
  9230. if (!chat.JoinChannel(client, channel_name))
  9231. client->Message(CHANNEL_COLOR_RED, "There was an internal error preventing you from joining '%s'.", channel_name);
  9232. }
  9233. void Commands::Command_JoinChannelFromLoad(Client * client, Seperator *sep) {
  9234. printf("ScatDebug: Received 'joinfromchannel', using the same function as 'joinchannel' (not sure what the difference is)\n");
  9235. Command_JoinChannel(client, sep);
  9236. }
  9237. void Commands::Command_TellChannel(Client *client, Seperator *sep) {
  9238. if (sep == NULL || !sep->IsSet(0) || !sep->IsSet(1)) {
  9239. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /tellchannel <channel name> <message>");
  9240. PrintSep(sep, "tellchannel");
  9241. return;
  9242. }
  9243. chat.TellChannel(client, sep->arg[0], sep->argplus[1]);
  9244. }
  9245. void Commands::Command_Test(Client* client, EQ2_16BitString* command_parms) {
  9246. Seperator* sep = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  9247. if (sep->IsSet(0)) {
  9248. if (atoi(sep->arg[0]) == 1) {
  9249. PacketStruct* packet2 = configReader.getStruct("WS_SpellGainedMsg", client->GetVersion());
  9250. if (packet2) {
  9251. packet2->setDataByName("spell_type", 2);
  9252. packet2->setDataByName("spell_id", 8308);
  9253. packet2->setDataByName("spell_name", "Sprint");
  9254. packet2->setDataByName("add_silently", 0);
  9255. packet2->setDataByName("tier", 1);
  9256. packet2->setDataByName("blah1", 1);
  9257. packet2->setDataByName("blah2", 1);
  9258. EQ2Packet* outapp = packet2->serialize();
  9259. DumpPacket(outapp);
  9260. client->QueuePacket(outapp);
  9261. safe_delete(packet2);
  9262. }
  9263. }
  9264. else if (atoi(sep->arg[0]) == 2) {
  9265. PacketStruct* packet2 = configReader.getStruct("WS_GuildUpdate", client->GetVersion());
  9266. if (packet2) {
  9267. packet2->setDataByName("guild_name", "Test");
  9268. packet2->setDataByName("guild_motd", "Test MOTD");
  9269. packet2->setDataByName("guild_id", 1234);
  9270. packet2->setDataByName("guild_level", 1);
  9271. packet2->setDataByName("unknown", 2);
  9272. packet2->setDataByName("unknown2", 3);
  9273. packet2->setDataByName("exp_current", 1);
  9274. packet2->setDataByName("exp_to_next_level", 4);
  9275. EQ2Packet* outapp = packet2->serialize();
  9276. DumpPacket(outapp);
  9277. client->QueuePacket(outapp);
  9278. safe_delete(packet2);
  9279. }
  9280. }
  9281. else if (atoi(sep->arg[0]) == 3) {
  9282. PacketStruct* packet2 = configReader.getStruct("WS_JoinGuildNotify", client->GetVersion());
  9283. if (packet2) {
  9284. packet2->setDataByName("guild_id", 1234);
  9285. packet2->setDataByName("character_id", 1);
  9286. packet2->setDataByName("account_id", 2);
  9287. packet2->setDataByName("guild_level", 1);
  9288. packet2->setDataByName("name", "Test");
  9289. packet2->setDataByName("unknown2", 0);
  9290. packet2->setDataByName("unknown3", 1);
  9291. packet2->setDataByName("adventure_class", 6);
  9292. packet2->setDataByName("adventure_level", 7);
  9293. packet2->setDataByName("tradeskill_class", 4);
  9294. packet2->setDataByName("tradeskill_level", 5);
  9295. packet2->setDataByName("rank", 0);
  9296. packet2->setDataByName("member_flags", 2);
  9297. packet2->setDataByName("join_date", 1591112273);
  9298. packet2->setDataByName("guild_status", 2);
  9299. packet2->setDataByName("last_login", 1591132273);
  9300. packet2->setDataByName("recruiter_id", 1);
  9301. packet2->setDataByName("points", 2345);
  9302. packet2->setDataByName("note", "note");
  9303. packet2->setMediumStringByName("officer_note", "O note");
  9304. packet2->setMediumStringByName("zone", "Blah");
  9305. EQ2Packet* outapp = packet2->serialize();
  9306. DumpPacket(outapp);
  9307. client->QueuePacket(outapp);
  9308. safe_delete(packet2);
  9309. }
  9310. }
  9311. else if (atoi(sep->arg[0]) == 5) {
  9312. int16 offset = atoi(sep->arg[1]);
  9313. int32 value1 = atol(sep->arg[2]);
  9314. EQ2Packet* outapp = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion(), offset, value1);
  9315. client->QueuePacket(outapp);
  9316. }
  9317. else if (atoi(sep->arg[0]) == 6) {
  9318. Spawn* spawn = client->GetPlayer()->GetTarget();
  9319. if (!spawn)
  9320. spawn = client->GetPlayer();
  9321. else if (spawn->IsEntity())
  9322. ((Entity*)spawn)->SetSpeed(atof(sep->arg[4]));
  9323. spawn->RunToLocation(atof(sep->arg[1]), atof(sep->arg[2]), atof(sep->arg[3]));
  9324. }
  9325. else if (atoi(sep->arg[0]) == 7) {
  9326. int32 id = 0;
  9327. Spawn* spawn = client->GetCurrentZone()->GetSpawn(7720001);
  9328. if (spawn) {
  9329. spawn->SetX(client->GetPlayer()->GetX() + .5, false);
  9330. spawn->SetY(client->GetPlayer()->GetY(), false);
  9331. spawn->SetZ(client->GetPlayer()->GetZ() + .5, false);
  9332. float heading = client->GetPlayer()->GetHeading() + 180;
  9333. if (heading > 360)
  9334. heading -= 360;
  9335. spawn->SetLevel(5);
  9336. spawn->SetAdventureClass(4);
  9337. spawn->SetHeading(heading, false);
  9338. spawn->SetSpawnOrigX(spawn->GetX());
  9339. spawn->SetSpawnOrigY(spawn->GetY());
  9340. spawn->SetSpawnOrigZ(spawn->GetZ());
  9341. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  9342. spawn->SetLocation(client->GetPlayer()->GetLocation());
  9343. spawn->appearance.targetable = 1;
  9344. if (spawn->IsNPC() && spawn->GetTotalHP() == 0) {
  9345. spawn->SetTotalHP(spawn->GetLevel() * 15);
  9346. spawn->SetHP(spawn->GetTotalHP());
  9347. }
  9348. if (spawn->GetTotalPower() == 0) {
  9349. spawn->SetTotalPower(spawn->GetLevel() * 15);
  9350. spawn->SetPower(spawn->GetTotalPower());
  9351. }
  9352. int16 offset = atoi(sep->arg[1]);
  9353. int32 value1 = atol(sep->arg[2]);
  9354. sprintf(spawn->appearance.name, "Offset %i", offset);
  9355. EQ2Packet* ret = spawn->spawn_serialize(client->GetPlayer(), client->GetVersion(), offset, value1);
  9356. DumpPacket(ret);
  9357. client->QueuePacket(ret);
  9358. }
  9359. }
  9360. else if (atoi(sep->arg[0]) == 8) {
  9361. int32 id = atoi(sep->arg[1]);
  9362. Spawn* spawn = client->GetCurrentZone()->GetSpawn(id);
  9363. if (spawn) {
  9364. spawn->SetX(client->GetPlayer()->GetX() + .5, false);
  9365. spawn->SetY(client->GetPlayer()->GetY(), false);
  9366. spawn->SetZ(client->GetPlayer()->GetZ() + .5, false);
  9367. float heading = client->GetPlayer()->GetHeading() + 180;
  9368. if (heading > 360)
  9369. heading -= 360;
  9370. spawn->SetLevel(5);
  9371. spawn->SetAdventureClass(4);
  9372. spawn->SetHeading(heading, false);
  9373. spawn->SetSpawnOrigX(spawn->GetX());
  9374. spawn->SetSpawnOrigY(spawn->GetY());
  9375. spawn->SetSpawnOrigZ(spawn->GetZ());
  9376. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  9377. spawn->SetLocation(client->GetPlayer()->GetLocation());
  9378. spawn->appearance.targetable = 1;
  9379. if (spawn->IsNPC() && spawn->GetTotalHP() == 0) {
  9380. spawn->SetTotalHP(spawn->GetLevel() * 15);
  9381. spawn->SetHP(spawn->GetTotalHP());
  9382. }
  9383. if (spawn->GetTotalPower() == 0) {
  9384. spawn->SetTotalPower(spawn->GetLevel() * 15);
  9385. spawn->SetPower(spawn->GetTotalPower());
  9386. }
  9387. int16 offset = atoi(sep->arg[2]);
  9388. int16 offset2 = atoi(sep->arg[3]);
  9389. int32 value1 = atol(sep->arg[4]);
  9390. int16 offset3 = 0;
  9391. int16 offset4 = 0;
  9392. int32 value2 = 0;
  9393. if (sep->IsSet(7)) {
  9394. offset3 = atoi(sep->arg[5]);
  9395. offset4 = atoi(sep->arg[6]);
  9396. value2 = atol(sep->arg[7]);
  9397. }
  9398. sprintf(spawn->appearance.name, "Offset %i to %i", offset, offset2);
  9399. spawn->AddPrimaryEntityCommand("attack", 10000, "attack","", 0, 0);
  9400. EQ2Packet* ret = spawn->spawn_serialize(client->GetPlayer(), client->GetVersion(), offset, value1, offset2, offset3, offset4, value2);
  9401. DumpPacket(ret);
  9402. client->QueuePacket(ret);
  9403. }
  9404. }
  9405. else if (atoi(sep->arg[0]) == 9) {
  9406. PacketStruct* packet2 = configReader.getStruct("WS_DeathWindow", client->GetVersion());
  9407. if (packet2) {
  9408. packet2->setArrayLengthByName("location_count", 1);
  9409. packet2->setArrayDataByName("location_ida", 1234);
  9410. packet2->setArrayDataByName("unknown2a", 3);
  9411. packet2->setArrayDataByName("zone_name", "Queen's Colony");
  9412. packet2->setArrayDataByName("location_name", "Myrrin's Tower");
  9413. packet2->setArrayDataByName("distance", 134);
  9414. EQ2Packet* app = packet2->serialize();
  9415. if (sep->IsSet(2)) {
  9416. int8 offset = atoi(sep->arg[1]);
  9417. uchar* ptr2 = app->pBuffer;
  9418. ptr2 += offset;
  9419. if (sep->IsNumber(2)) {
  9420. int32 value1 = atol(sep->arg[2]);
  9421. if (value1 > 0xFFFF)
  9422. memcpy(ptr2, (uchar*)&value1, 4);
  9423. else if (value1 > 0xFF)
  9424. memcpy(ptr2, (uchar*)&value1, 2);
  9425. else
  9426. memcpy(ptr2, (uchar*)&value1, 1);
  9427. }
  9428. else {
  9429. int8 len = strlen(sep->arg[2]);
  9430. memcpy(ptr2, (uchar*)&len, 1);
  9431. ptr2 += 1;
  9432. memcpy(ptr2, sep->arg[2], len);
  9433. }
  9434. }
  9435. DumpPacket(app);
  9436. client->QueuePacket(app);
  9437. safe_delete(packet2);
  9438. }
  9439. }
  9440. else if (atoi(sep->arg[0]) == 10) {
  9441. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalUpdate", client->GetVersion());
  9442. if (packet2) {
  9443. packet2->setArrayLengthByName("num_quests", 1);
  9444. packet2->setArrayDataByName("active", 1);
  9445. packet2->setArrayDataByName("name", "Tasks aboard the Far Journey");
  9446. packet2->setArrayDataByName("quest_type", "Hallmark");
  9447. packet2->setArrayDataByName("quest_zone", "Hallmark");
  9448. packet2->setArrayDataByName("journal_updated", 1);
  9449. packet2->setArrayDataByName("quest_id", 524);
  9450. packet2->setArrayDataByName("day", 19);
  9451. packet2->setArrayDataByName("month", 6);
  9452. packet2->setArrayDataByName("year", 20);
  9453. packet2->setArrayDataByName("level", 2);
  9454. packet2->setArrayDataByName("encounter_level", 4);
  9455. packet2->setArrayDataByName("difficulty", 3);
  9456. packet2->setArrayDataByName("visible", 1);
  9457. packet2->setDataByName("visible_quest_id", 524);
  9458. packet2->setDataByName("player_crc", 2900677088);
  9459. packet2->setDataByName("player_name", "LethalEncounter");
  9460. EQ2Packet* app = packet2->serialize();
  9461. if (sep->IsSet(2)) {
  9462. int8 offset = atoi(sep->arg[1]);
  9463. uchar* ptr2 = app->pBuffer;
  9464. ptr2 += offset;
  9465. if (sep->IsNumber(2)) {
  9466. int32 value1 = atol(sep->arg[2]);
  9467. if (value1 > 0xFFFF)
  9468. memcpy(ptr2, (uchar*)&value1, 4);
  9469. else if (value1 > 0xFF)
  9470. memcpy(ptr2, (uchar*)&value1, 2);
  9471. else
  9472. memcpy(ptr2, (uchar*)&value1, 1);
  9473. }
  9474. else {
  9475. int8 len = strlen(sep->arg[2]);
  9476. memcpy(ptr2, (uchar*)&len, 1);
  9477. ptr2 += 1;
  9478. memcpy(ptr2, sep->arg[2], len);
  9479. }
  9480. }
  9481. DumpPacket(app);
  9482. client->QueuePacket(app);
  9483. safe_delete(packet2);
  9484. }
  9485. }
  9486. else if (atoi(sep->arg[0]) == 11) {
  9487. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalReply", client->GetVersion());
  9488. if (packet2) {
  9489. packet2->setDataByName("quest_id", 524);
  9490. packet2->setDataByName("player_crc", 2900677088);
  9491. packet2->setDataByName("name", "Tasks aboard the Far Journey");
  9492. packet2->setDataByName("description", "I completed all the tasks assigned to me by Captain Varlos aboard the Far Journey");
  9493. packet2->setDataByName("type", "Hallmark");
  9494. packet2->setDataByName("complete_header", "To complete this quest, I must do the following tasks:");
  9495. packet2->setDataByName("day", 19);
  9496. packet2->setDataByName("month", 6);
  9497. packet2->setDataByName("year", 20);
  9498. packet2->setDataByName("level", 1);
  9499. packet2->setDataByName("encounter_level", 1);
  9500. packet2->setDataByName("difficulty", 1);
  9501. packet2->setDataByName("time_obtained", Timer::GetUnixTimeStamp());
  9502. //packet2->setDataByName("timer_start", Timer::GetUnixTimeStamp());
  9503. //packet2->setDataByName("timer_duration", 300);
  9504. //packet2->setDataByName("timer_running", 1);
  9505. packet2->setArrayLengthByName("task_groups_completed", 9);
  9506. packet2->setArrayLengthByName("num_task_groups", 10);
  9507. packet2->setArrayDataByName("task_group", "I spoke to Waulon as Captain Varlos had asked of me.");
  9508. packet2->setArrayDataByName("task_group", "I found Waulon's hat in one of the boxes.", 1);
  9509. packet2->setArrayDataByName("task_group", "I returned Waulon's hat.", 2);
  9510. packet2->setArrayDataByName("task_group", "I have spoken to Ingrid.", 3);
  9511. packet2->setArrayDataByName("task_group", "I purchased a Shard of Luclin.", 4);
  9512. packet2->setArrayDataByName("task_group", "I gave the Shard of Luclin to Ingrid.", 5);
  9513. packet2->setArrayDataByName("task_group", "I have spoken to Captain Varlos.", 6);
  9514. packet2->setArrayDataByName("task_group", "I killed the rats that Captain Varlos requested.", 7);
  9515. packet2->setArrayDataByName("task_group", "Captain Varlos has ordered you to kill the escaped goblin.", 8);
  9516. packet2->setArrayDataByName("task_group", "I killed the escaped goblin.", 9);
  9517. /*packet2->setSubArrayLengthByName("num_tasks", 1);
  9518. packet2->setSubArrayDataByName("task", "I need to talk to Garven Tralk");
  9519. packet2->setSubArrayLengthByName("num_updates", 1);
  9520. packet2->setSubArrayDataByName("update_currentval", 0);
  9521. packet2->setSubArrayDataByName("update_maxval", 1);
  9522. packet2->setSubArrayDataByName("icon", 11);
  9523. */
  9524. packet2->setArrayDataByName("waypoint", 0xFFFFFFFF);
  9525. packet2->setDataByName("journal_updated", 1);
  9526. packet2->setDataByName("bullets", 1);
  9527. EQ2Packet* app = packet2->serialize();
  9528. if (sep->IsSet(2)) {
  9529. int16 offset = atoi(sep->arg[1]);
  9530. uchar* ptr2 = app->pBuffer;
  9531. ptr2 += offset;
  9532. if (sep->IsNumber(2)) {
  9533. int32 value1 = atol(sep->arg[2]);
  9534. if (value1 > 0xFFFF)
  9535. memcpy(ptr2, (uchar*)&value1, 4);
  9536. else if (value1 > 0xFF)
  9537. memcpy(ptr2, (uchar*)&value1, 2);
  9538. else
  9539. memcpy(ptr2, (uchar*)&value1, 1);
  9540. }
  9541. else {
  9542. int16 len = strlen(sep->arg[2]);
  9543. memcpy(ptr2, (uchar*)&len, 2);
  9544. ptr2 += 2;
  9545. memcpy(ptr2, sep->arg[2], len);
  9546. }
  9547. }
  9548. DumpPacket(app);
  9549. client->QueuePacket(app);
  9550. safe_delete(packet2);
  9551. }
  9552. }
  9553. else if (atoi(sep->arg[0]) == 12) {
  9554. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalReply", client->GetVersion());
  9555. if (packet2) {
  9556. packet2->setDataByName("quest_id", 5725);
  9557. packet2->setDataByName("player_crc", 2900677088);
  9558. packet2->setDataByName("name", "Archetype Selection");
  9559. packet2->setDataByName("description", "I have reported my profession to Garven Tralk.");
  9560. packet2->setDataByName("type", "Hallmark");
  9561. packet2->setDataByName("complete_header", "To complete this quest, I must do the following tasks:");
  9562. packet2->setDataByName("day", 19);
  9563. packet2->setDataByName("month", 6);
  9564. packet2->setDataByName("year", 20);
  9565. packet2->setDataByName("level", 2);
  9566. packet2->setDataByName("encounter_level", 4);
  9567. packet2->setDataByName("difficulty", 3);
  9568. packet2->setDataByName("time_obtained", Timer::GetUnixTimeStamp());
  9569. packet2->setDataByName("timer_start", Timer::GetUnixTimeStamp());
  9570. packet2->setDataByName("timer_duration", 300);
  9571. packet2->setDataByName("timer_running", 1);
  9572. packet2->setArrayLengthByName("task_groups_completed", 0);
  9573. packet2->setArrayLengthByName("num_task_groups", 1);
  9574. packet2->setArrayDataByName("task_group", "I need to talk to Garven Tralk");
  9575. packet2->setSubArrayLengthByName("num_tasks", 1);
  9576. packet2->setSubArrayDataByName("task", "I need to talk to Garven Tralk");
  9577. packet2->setSubArrayLengthByName("num_updates", 1);
  9578. packet2->setSubArrayDataByName("update_currentval", 0);
  9579. packet2->setSubArrayDataByName("update_maxval", 1);
  9580. packet2->setSubArrayDataByName("icon", 11);
  9581. packet2->setArrayDataByName("waypoint", 0xFFFFFFFF);
  9582. packet2->setDataByName("journal_updated", 1);
  9583. packet2->setSubstructDataByName("reward_data", "unknown1", 255);
  9584. packet2->setSubstructDataByName("reward_data", "reward", "Quest Reward!");
  9585. packet2->setSubstructDataByName("reward_data", "unknown2", 0x3f);
  9586. packet2->setSubstructDataByName("reward_data", "coin", 150);
  9587. packet2->setSubstructDataByName("reward_data", "status_points", 5);
  9588. packet2->setSubstructDataByName("reward_data", "exp_bonus", 10);
  9589. packet2->setSubstructArrayLengthByName("reward_data", "num_rewards", 1);
  9590. packet2->setSubstructArrayDataByName("reward_data", "reward_id", 123);
  9591. Item* item = master_item_list.GetItem(152755);
  9592. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9593. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, client->GetClientItemPacketOffset());
  9594. /*packet2->setSubstructDataByName("item", "unique_id", 567);
  9595. packet2->setSubstructDataByName("item", "broker_item_id", 0xFFFFFFFFFFFFFFFF);
  9596. packet2->setSubstructDataByName("item", "icon", 0xe7);
  9597. packet2->setSubstructDataByName("item", "tier", 4);
  9598. packet2->setSubstructDataByName("item", "flags", 0x60);
  9599. packet2->setSubstructArrayLengthByName("item", "stat_count", 1);
  9600. packet2->setSubstructDataByName("item", "stat_type", 1);
  9601. packet2->setSubstructDataByName("item", "stat_subtype", 2);
  9602. packet2->setSubstructDataByName("item", "value", 3);
  9603. packet2->setSubstructDataByName("item", "condition", 100);
  9604. packet2->setSubstructDataByName("item", "weight", 1);
  9605. packet2->setSubstructDataByName("item", "skill_req1", 0xacafa99e);
  9606. packet2->setSubstructDataByName("item", "skill_req2", 0xacafa99e);
  9607. packet2->setSubstructDataByName("item", "skill_min", 1);
  9608. packet2->setSubstructArrayLengthByName("item", "class_count", 3);
  9609. packet2->setSubstructDataByName("item", "adventure_class", 1);
  9610. packet2->setSubstructDataByName("item", "adventure_class", 11, 0, 1);
  9611. packet2->setSubstructDataByName("item", "adventure_class", 0x1f, 0, 2);
  9612. packet2->setSubstructDataByName("item", "tradeskill_class", 255);
  9613. packet2->setSubstructDataByName("item", "tradeskill_class", 255, 0, 1);
  9614. packet2->setSubstructDataByName("item", "tradeskill_class", 255, 0, 2);
  9615. packet2->setSubstructDataByName("item", "level", 0x1e);
  9616. packet2->setSubstructDataByName("item", "level", 100, 0, 1);
  9617. packet2->setSubstructDataByName("item", "level", 100, 0, 2);
  9618. packet2->setSubstructDataByName("item_footer", "name", "Footman Gloves");*/
  9619. //packet2->PrintPacket();
  9620. EQ2Packet* app = packet2->serialize();
  9621. if (sep->IsSet(2)) {
  9622. int16 offset = atoi(sep->arg[1]);
  9623. uchar* ptr2 = app->pBuffer;
  9624. ptr2 += offset;
  9625. if (sep->IsNumber(2)) {
  9626. int32 value1 = atol(sep->arg[2]);
  9627. if (value1 > 0xFFFF)
  9628. memcpy(ptr2, (uchar*)&value1, 4);
  9629. else if (value1 > 0xFF)
  9630. memcpy(ptr2, (uchar*)&value1, 2);
  9631. else
  9632. memcpy(ptr2, (uchar*)&value1, 1);
  9633. }
  9634. else {
  9635. int16 len = strlen(sep->arg[2]);
  9636. memcpy(ptr2, (uchar*)&len, 2);
  9637. ptr2 += 2;
  9638. memcpy(ptr2, sep->arg[2], len);
  9639. }
  9640. }
  9641. DumpPacket(app);
  9642. client->QueuePacket(app);
  9643. safe_delete(packet2);
  9644. }
  9645. }
  9646. else if (atoi(sep->arg[0]) == 13) {
  9647. PacketStruct* packet2 = configReader.getStruct("WS_OnScreenMsg", client->GetVersion());
  9648. if (packet2 && sep->IsSet(7)) {
  9649. packet2->setDataByName("unknown", atoi(sep->arg[1]));
  9650. char blah[128];
  9651. sprintf(blah, "\\#6EFF6EYou get better at \12\\#C8FFC8%s\\#6EFF6E! (7/15)", sep->arg[2]);
  9652. packet2->setDataByName("text", blah);
  9653. packet2->setDataByName("message_type", sep->arg[3]);
  9654. packet2->setDataByName("size", atof(sep->arg[4]));
  9655. packet2->setDataByName("red", atoi(sep->arg[5]));
  9656. packet2->setDataByName("green", atoi(sep->arg[6]));
  9657. packet2->setDataByName("blue", atoi(sep->arg[7]));
  9658. EQ2Packet* app = packet2->serialize();
  9659. DumpPacket(app);
  9660. client->QueuePacket(app);
  9661. safe_delete(packet2);
  9662. }
  9663. }
  9664. else if (atoi(sep->arg[0]) == 14) {
  9665. PacketStruct* packet2 = configReader.getStruct("WS_InstructionWindow", client->GetVersion());
  9666. if (packet2 && sep->IsSet(3)) {
  9667. packet2->setDataByName("open_seconds_min", atof(sep->arg[1]));
  9668. packet2->setDataByName("open_seconds_max", atof(sep->arg[2]));
  9669. packet2->setDataByName("voice_sync", atoi(sep->arg[3]));
  9670. 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.");
  9671. packet2->setDataByName("voice", "voiceover/english/narrator/boat_06p_tutorial02/narrator_001_63779ca0.mp3");
  9672. packet2->setArrayLengthByName("num_goals", 1);
  9673. //packet2->setArrayDataByName("goal_text", )
  9674. packet2->setSubArrayLengthByName("num_tasks", 1);
  9675. packet2->setSubArrayDataByName("task_text", "continue");
  9676. packet2->setDataByName("complete_sound", "click");
  9677. packet2->setDataByName("signal", "introduction");
  9678. packet2->setDataByName("voice_key1", 0xcda65173);
  9679. packet2->setDataByName("voice_key2", 0x984bfc6d);
  9680. EQ2Packet* app = packet2->serialize();
  9681. DumpPacket(app);
  9682. client->QueuePacket(app);
  9683. safe_delete(packet2);
  9684. packet2 = configReader.getStruct("WS_ShowWindow", client->GetVersion());
  9685. packet2->setDataByName("window", "MainHUD.StartMenu");
  9686. packet2->setDataByName("show", 1);
  9687. app = packet2->serialize();
  9688. DumpPacket(app);
  9689. client->QueuePacket(app);
  9690. safe_delete(packet2);
  9691. packet2 = configReader.getStruct("WS_FlashWindow", client->GetVersion());
  9692. packet2->setDataByName("window", "MainHUD.StartMenu.help");
  9693. packet2->setDataByName("flash_seconds", 10);
  9694. app = packet2->serialize();
  9695. DumpPacket(app);
  9696. client->QueuePacket(app);
  9697. safe_delete(packet2);
  9698. }
  9699. }
  9700. else if (atoi(sep->arg[0]) == 15) {
  9701. PacketStruct* packet2 = configReader.getStruct("WS_UpdateLoot", client->GetVersion());
  9702. if (packet2) {
  9703. packet2->setArrayLengthByName("loot_count", 1);
  9704. packet2->setArrayDataByName("name", "Test");
  9705. packet2->setArrayDataByName("item_id", 1234);
  9706. packet2->setArrayDataByName("count", 1);
  9707. packet2->setArrayDataByName("icon", 258);
  9708. packet2->setArrayDataByName("ability_id", 0xFFFFFFFF);
  9709. Spawn* spawn = client->GetPlayer()->GetTarget();
  9710. if (spawn)
  9711. packet2->setDataByName("object_id", client->GetPlayer()->GetIDWithPlayerSpawn(spawn));
  9712. packet2->setDataByName("display", 1);
  9713. packet2->setDataByName("loot_type", 1);
  9714. packet2->setDataByName("lotto_timeout", 60);
  9715. EQ2Packet* app = packet2->serialize();
  9716. DumpPacket(app);
  9717. client->QueuePacket(app);
  9718. safe_delete(packet2);
  9719. }
  9720. }
  9721. else if (atoi(sep->arg[0]) == 16 && sep->IsNumber(1)) {
  9722. char blah[32];
  9723. sprintf(blah, "Testing: %i", atoi(sep->arg[1]));
  9724. client->SimpleMessage(atoi(sep->arg[1]), blah);
  9725. }
  9726. else if (atoi(sep->arg[0]) == 17 && sep->IsNumber(2)) {
  9727. if (sep->IsSet(2)) {
  9728. int16 offset = atoi(sep->arg[1]);
  9729. if (sep->IsNumber(2)) {
  9730. int32 value1 = atol(sep->arg[2]);
  9731. client->QueuePacket(client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion(), offset, value1));
  9732. cout << "Sent" << endl;
  9733. }
  9734. }
  9735. }
  9736. else if (atoi(sep->arg[0]) == 18) {
  9737. PacketStruct* packet2 = configReader.getStruct("WS_QuestRewardPackMsg", client->GetVersion());
  9738. if (packet2) {
  9739. packet2->setSubstructDataByName("reward_data", "unknown1", 255);
  9740. packet2->setSubstructDataByName("reward_data", "reward", "Quest Reward!");
  9741. packet2->setSubstructDataByName("reward_data", "max_coin", 0);
  9742. packet2->setSubstructDataByName("reward_data", "text", "Some custom text to mess things up?");
  9743. packet2->setSubstructDataByName("reward_data", "status_points", 5);
  9744. //packet2->setSubstructDataByName("reward_data", "exp_bonus", 10);
  9745. packet2->setSubstructArrayLengthByName("reward_data", "num_rewards", 1);
  9746. Item* item = new Item(master_item_list.GetItem(9357));
  9747. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9748. //item->stack_count = 20;
  9749. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, client->GetClientItemPacketOffset());
  9750. safe_delete(item);
  9751. /*item = new Item(master_item_list.GetItem(36685));
  9752. item->stack_count = 20;
  9753. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9754. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 1, 0, -1);
  9755. safe_delete(item);
  9756. item = master_item_list.GetItem(1414);
  9757. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9758. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 2, 0, -1);
  9759. item = master_item_list.GetItem(75057);
  9760. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9761. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 3, 0, -1);*/
  9762. EQ2Packet* app = packet2->serialize();
  9763. if (sep->IsSet(2)) {
  9764. int16 offset = atoi(sep->arg[1]);
  9765. uchar* ptr2 = app->pBuffer;
  9766. ptr2 += offset;
  9767. if (sep->IsNumber(2)) {
  9768. int32 value1 = atol(sep->arg[2]);
  9769. if (value1 > 0xFFFF)
  9770. memcpy(ptr2, (uchar*)&value1, 4);
  9771. else if (value1 > 0xFF)
  9772. memcpy(ptr2, (uchar*)&value1, 2);
  9773. else
  9774. memcpy(ptr2, (uchar*)&value1, 1);
  9775. }
  9776. else {
  9777. int16 len = strlen(sep->arg[2]);
  9778. memcpy(ptr2, (uchar*)&len, 2);
  9779. ptr2 += 2;
  9780. memcpy(ptr2, sep->arg[2], len);
  9781. }
  9782. }
  9783. DumpPacket(app);
  9784. client->QueuePacket(app);
  9785. safe_delete(packet2);
  9786. }
  9787. }
  9788. else if (atoi(sep->arg[0]) == 19) {
  9789. PacketStruct* packet2 = configReader.getStruct("WS_UpdateLoot", client->GetVersion());
  9790. Spawn* spawn = client->GetPlayer()->GetTarget();
  9791. if (packet2 && spawn) {
  9792. Item* item = master_item_list.GetItem(130053);
  9793. packet2->setArrayLengthByName("loot_count", 1);
  9794. packet2->setArrayDataByName("loot_id", item->details.item_id);
  9795. packet2->setArrayDataByName("unknown2", 1);
  9796. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, 2, true);
  9797. packet2->setDataByName("display", 1);
  9798. packet2->setDataByName("unknown2b", 1);
  9799. packet2->setDataByName("unknown3", 0x3c);
  9800. packet2->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(spawn));
  9801. packet2->PrintPacket();
  9802. EQ2Packet* app = packet2->serialize();
  9803. if (sep->IsSet(2)) {
  9804. int16 offset = atoi(sep->arg[1]);
  9805. int16 offset2 = 0;
  9806. int32 value1 = 0;
  9807. if (sep->IsSet(3)) {
  9808. offset2 = atoi(sep->arg[2]);
  9809. value1 = atol(sep->arg[3]);
  9810. }
  9811. else
  9812. value1 = atol(sep->arg[2]);
  9813. int16 offset3 = 0;
  9814. int16 offset4 = 0;
  9815. int32 value2 = 0;
  9816. if (sep->IsSet(6)) {
  9817. offset3 = atoi(sep->arg[4]);
  9818. offset4 = atoi(sep->arg[5]);
  9819. value2 = atol(sep->arg[6]);
  9820. }
  9821. offset--;
  9822. if (offset2 > 0 && offset2 >= offset) {
  9823. offset2--;
  9824. uchar* ptr2 = app->pBuffer;
  9825. ptr2 += offset;
  9826. for (int i = offset; i <= offset2; i++) {
  9827. if (value1 > 0xFFFF) {
  9828. memcpy(ptr2, (uchar*)&value1, 4);
  9829. i += 3;
  9830. ptr2 += 3;
  9831. }
  9832. else if (value1 > 0xFF) {
  9833. memcpy(ptr2, (uchar*)&value1, 2);
  9834. i++;
  9835. ptr2++;
  9836. }
  9837. else
  9838. memcpy(ptr2, (uchar*)&value1, 1);
  9839. ptr2++;
  9840. }
  9841. }
  9842. if (offset4 > 0 && offset4 >= offset3) {
  9843. offset3--;
  9844. offset4--;
  9845. uchar* ptr2 = app->pBuffer;
  9846. ptr2 += offset3;
  9847. for (int i = offset3; i <= offset4; i++) {
  9848. if (value2 > 0xFFFF) {
  9849. memcpy(ptr2, (uchar*)&value2, 4);
  9850. i += 3;
  9851. ptr2 += 3;
  9852. }
  9853. else if (value2 > 0xFF) {
  9854. memcpy(ptr2, (uchar*)&value2, 2);
  9855. i++;
  9856. ptr2++;
  9857. }
  9858. else
  9859. memcpy(ptr2, (uchar*)&value2, 1);
  9860. ptr2++;
  9861. }
  9862. }
  9863. }
  9864. DumpPacket(app);
  9865. client->QueuePacket(app);
  9866. safe_delete(packet2);
  9867. }
  9868. }
  9869. else if (atoi(sep->arg[0]) == 21) {
  9870. PacketStruct* packet2 = configReader.getStruct("WS_OfferQuest", client->GetVersion());
  9871. if (packet2) {
  9872. packet2->setDataByName("unknown0", 255);
  9873. packet2->setDataByName("reward", "New Quest");
  9874. packet2->setDataByName("title", "Title");
  9875. packet2->setDataByName("description", "description");
  9876. packet2->setDataByName("quest_difficulty", 3);
  9877. packet2->setDataByName("unknown1", 5);
  9878. packet2->setDataByName("level", 3);
  9879. packet2->setDataByName("coin", 150);
  9880. packet2->setDataByName("status_points", 5);
  9881. packet2->setDataByName("exp_bonus", 10);
  9882. packet2->setArrayLengthByName("num_rewards", 1);
  9883. Item* item = new Item(master_item_list.GetItem(36212));
  9884. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9885. item->stack_count = 20;
  9886. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, client->GetClientItemPacketOffset());
  9887. safe_delete(item);
  9888. char accept[35] = { 0 };
  9889. char decline[35] = { 0 };
  9890. sprintf(accept, "q_accept_pending_quest %u", 0);
  9891. sprintf(decline, "q_deny_pending_quest %u", 0);
  9892. packet2->setDataByName("accept_command", accept);
  9893. packet2->setDataByName("decline_command", decline);
  9894. EQ2Packet* app = packet2->serialize();
  9895. if (sep->IsSet(2)) {
  9896. int16 offset = atoi(sep->arg[1]);
  9897. uchar* ptr2 = app->pBuffer;
  9898. ptr2 += offset;
  9899. if (sep->IsNumber(2)) {
  9900. int32 value1 = atol(sep->arg[2]);
  9901. if (value1 > 0xFFFF)
  9902. memcpy(ptr2, (uchar*)&value1, 4);
  9903. else if (value1 > 0xFF)
  9904. memcpy(ptr2, (uchar*)&value1, 2);
  9905. else
  9906. memcpy(ptr2, (uchar*)&value1, 1);
  9907. }
  9908. DumpPacket(app);
  9909. client->QueuePacket(app);
  9910. safe_delete(packet2);
  9911. }
  9912. }
  9913. }
  9914. else if (atoi(sep->arg[0]) == 22) { //same as 21, but 8bit string
  9915. PacketStruct* packet2 = configReader.getStruct("WS_OfferQuest", client->GetVersion());
  9916. if (packet2) {
  9917. packet2->setDataByName("unknown0", 255);
  9918. packet2->setDataByName("reward", "New Quest");
  9919. packet2->setDataByName("title", "Title");
  9920. packet2->setDataByName("description", "description");
  9921. packet2->setDataByName("quest_difficulty", 3);
  9922. packet2->setDataByName("unknown1", 5);
  9923. packet2->setDataByName("level", 3);
  9924. packet2->setDataByName("coin", 150);
  9925. packet2->setDataByName("status_points", 5);
  9926. packet2->setDataByName("exp_bonus", 10);
  9927. packet2->setArrayLengthByName("num_rewards", 1);
  9928. Item* item = new Item(master_item_list.GetItem(36212));
  9929. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9930. item->stack_count = 20;
  9931. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, client->GetClientItemPacketOffset());
  9932. safe_delete(item);
  9933. char accept[35] = { 0 };
  9934. char decline[35] = { 0 };
  9935. sprintf(accept, "q_accept_pending_quest %u", 0);
  9936. sprintf(decline, "q_deny_pending_quest %u", 0);
  9937. packet2->setDataByName("accept_command", accept);
  9938. packet2->setDataByName("decline_command", decline);
  9939. EQ2Packet* app = packet2->serialize();
  9940. if (sep->IsSet(2)) {
  9941. int16 offset = atoi(sep->arg[1]);
  9942. uchar* ptr2 = app->pBuffer;
  9943. ptr2 += offset;
  9944. if (sep->IsNumber(2)) {
  9945. int32 value1 = atol(sep->arg[2]);
  9946. if (value1 > 0xFFFF)
  9947. memcpy(ptr2, (uchar*)&value1, 4);
  9948. else if (value1 > 0xFF)
  9949. memcpy(ptr2, (uchar*)&value1, 2);
  9950. else
  9951. memcpy(ptr2, (uchar*)&value1, 1);
  9952. }
  9953. else {
  9954. int8 len = strlen(sep->arg[2]);
  9955. memcpy(ptr2, (uchar*)&len, 1);
  9956. ptr2 += 1;
  9957. memcpy(ptr2, sep->arg[2], len);
  9958. }
  9959. }
  9960. DumpPacket(app);
  9961. client->QueuePacket(app);
  9962. safe_delete(packet2);
  9963. }
  9964. }
  9965. else if (atoi(sep->arg[0]) == 23) {
  9966. if (client->GetPlayer()->GetTarget()) {
  9967. PacketStruct* packet2 = configReader.getStruct("WS_UpdateMerchant", client->GetVersion());
  9968. if (packet2) {
  9969. Spawn* target = client->GetPlayer()->GetTarget();
  9970. packet2->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(target));
  9971. Item* item = new Item(master_item_list.GetItem(12565));
  9972. int8 i = 0;
  9973. packet2->setArrayLengthByName("num_items", 1);
  9974. packet2->setArrayDataByName("item_name", item->name.c_str(), i);
  9975. packet2->setArrayDataByName("item_id", item->details.item_id, i);
  9976. packet2->setArrayDataByName("stack_size", item->stack_count, i);
  9977. packet2->setArrayDataByName("icon", item->GetIcon(client->GetVersion()), i);
  9978. int8 tmp_level = 0;
  9979. if (item->generic_info.adventure_default_level > 0)
  9980. tmp_level = item->generic_info.adventure_default_level;
  9981. else
  9982. tmp_level = item->generic_info.tradeskill_default_level;
  9983. packet2->setArrayDataByName("level", tmp_level, i);
  9984. packet2->setArrayDataByName("tier", item->details.tier, i);
  9985. packet2->setArrayDataByName("item_id2", item->details.item_id, i);
  9986. int8 item_difficulty = client->GetPlayer()->GetArrowColor(tmp_level);
  9987. if (item_difficulty != ARROW_COLOR_WHITE && item_difficulty != ARROW_COLOR_RED && item_difficulty != ARROW_COLOR_GRAY)
  9988. item_difficulty = ARROW_COLOR_WHITE;
  9989. item_difficulty -= 6;
  9990. if (item_difficulty < 0)
  9991. item_difficulty *= -1;
  9992. packet2->setArrayDataByName("item_difficulty", item_difficulty, i);
  9993. packet2->setArrayDataByName("quantity", 2, i);
  9994. packet2->setArrayDataByName("unknown5", 255, i);
  9995. packet2->setArrayDataByName("stack_size2", item->stack_count, i);
  9996. packet2->setArrayDataByName("description", item->description.c_str(), i);
  9997. packet2->setDataByName("type", 2);
  9998. EQ2Packet* app = packet2->serialize();
  9999. if (sep->IsSet(2)) {
  10000. int16 offset = atoi(sep->arg[1]);
  10001. uchar* ptr2 = app->pBuffer;
  10002. ptr2 += offset;
  10003. if (sep->IsNumber(2)) {
  10004. int32 value1 = atol(sep->arg[2]);
  10005. if (value1 > 0xFFFF)
  10006. memcpy(ptr2, (uchar*)&value1, 4);
  10007. else if (value1 > 0xFF)
  10008. memcpy(ptr2, (uchar*)&value1, 2);
  10009. else
  10010. memcpy(ptr2, (uchar*)&value1, 1);
  10011. }
  10012. else {
  10013. int8 len = strlen(sep->arg[2]);
  10014. memcpy(ptr2, (uchar*)&len, 1);
  10015. ptr2 += 1;
  10016. memcpy(ptr2, sep->arg[2], len);
  10017. }
  10018. }
  10019. DumpPacket(app);
  10020. client->QueuePacket(app);
  10021. safe_delete(packet2);
  10022. }
  10023. }
  10024. }
  10025. else if (atoi(sep->arg[0]) == 24) {
  10026. PacketStruct* packet2 = configReader.getStruct("WS_EnableGameEvent", client->GetVersion());
  10027. if (packet2) {
  10028. if (sep->IsSet(2)) {
  10029. packet2->setDataByName("event_name", sep->arg[1]);
  10030. packet2->setDataByName("enabled", atoi(sep->arg[2]));
  10031. EQ2Packet* app = packet2->serialize();
  10032. DumpPacket(app);
  10033. client->QueuePacket(app);
  10034. safe_delete(packet2);
  10035. }
  10036. }
  10037. }
  10038. else if (atoi(sep->arg[0]) == 25) {
  10039. if (sep->IsSet(1)) {
  10040. Widget* new_spawn = new Widget();
  10041. int32 id = atoul(sep->arg[1]);
  10042. new_spawn->SetWidgetID(id);
  10043. EQ2Packet* ret = new_spawn->serialize(client->GetPlayer(), client->GetVersion());
  10044. client->QueuePacket(ret);
  10045. int8 index = client->GetPlayer()->GetIndexForSpawn(new_spawn);
  10046. PacketStruct* packet2 = configReader.getStruct("WS_DestroyGhostCmd", client->GetVersion());
  10047. if (packet2) {
  10048. packet2->setDataByName("spawn_index", index);
  10049. packet2->setDataByName("delete", 1);
  10050. EQ2Packet* app = packet2->serialize();
  10051. client->QueuePacket(app);
  10052. safe_delete(packet2);
  10053. }
  10054. }
  10055. }
  10056. else if (atoi(sep->arg[0]) == 26) {
  10057. if (sep->IsSet(4)) {
  10058. Widget* new_spawn = new Widget();
  10059. int32 id = atoul(sep->arg[1]);
  10060. new_spawn->SetWidgetID(id);
  10061. float x = atof(sep->arg[2]);
  10062. float y = atof(sep->arg[3]);
  10063. float z = atof(sep->arg[4]);
  10064. new_spawn->SetLocation(client->GetPlayer()->GetLocation());
  10065. new_spawn->SetWidgetX(x);
  10066. new_spawn->SetWidgetY(y);
  10067. new_spawn->SetWidgetZ(z);
  10068. new_spawn->SetX(x);
  10069. new_spawn->SetY(y);
  10070. new_spawn->SetZ(z);
  10071. EQ2Packet* ret = new_spawn->serialize(client->GetPlayer(), client->GetVersion());
  10072. client->QueuePacket(ret);
  10073. }
  10074. }
  10075. else if (atoi(sep->arg[0]) == 27) {
  10076. Spawn* target = client->GetPlayer()->GetTarget();
  10077. PacketStruct* packet2 = configReader.getStruct("WS_HearSimpleDamage", client->GetVersion());
  10078. if (packet2 && target && sep->IsSet(4)) {
  10079. 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] : "");
  10080. }
  10081. }
  10082. else if (atoi(sep->arg[0]) == 28 && sep->IsNumber(1)) {
  10083. World::newValue = strtoull(sep->arg[1], NULL, 0);
  10084. }
  10085. else if (atoi(sep->arg[0]) == 29 && sep->IsNumber(1)) {
  10086. client->SendHearCast(client->GetPlayer(), client->GetPlayer()->GetTarget() ? client->GetPlayer()->GetTarget() : client->GetPlayer(),
  10087. strtoull(sep->arg[1], NULL, 0), atoul(sep->arg[2]));
  10088. }
  10089. else if (atoi(sep->arg[0]) == 30) {
  10090. PacketStruct* packet = configReader.getStruct("WS_UpdateSkillBook", client->GetVersion());
  10091. if (packet) {
  10092. packet->setDataByName("unknown", World::newValue);
  10093. EQ2Packet* outapp = packet->serialize();
  10094. DumpPacket(outapp);
  10095. client->QueuePacket(outapp);
  10096. safe_delete(packet);
  10097. }
  10098. }
  10099. else if (atoi(sep->arg[0]) == 31) {
  10100. client->SendRecipeList();
  10101. }
  10102. else if (atoi(sep->arg[0]) == 32 && sep->IsNumber(1) && sep->IsNumber(2)) {
  10103. if(client->GetVersion() <= 561) {
  10104. int32 param = atoul(sep->arg[1]);
  10105. int32 paramvalue = atoul(sep->arg[2]);
  10106. client->Message(CHANNEL_COLOR_YELLOW, "Send control flag param %u param value %u", param, paramvalue);
  10107. ClientPacketFunctions::SendServerControlFlagsClassic(client, param, paramvalue);
  10108. }
  10109. else if(sep->IsNumber(3)) {
  10110. int8 param1 = atoul(sep->arg[1]);
  10111. int8 param2 = atoul(sep->arg[2]);
  10112. int8 paramval = atoul(sep->arg[3]);
  10113. client->Message(CHANNEL_COLOR_YELLOW, "Send control flag param1 %u param2 %u param value %u", param1, param2, paramval);
  10114. ClientPacketFunctions::SendServerControlFlags(client, param1, param2, paramval);
  10115. }
  10116. }
  10117. else if (atoi(sep->arg[0]) == 33 && sep->IsNumber(1) && sep->IsNumber(2)) {
  10118. client->GetCurrentZone()->SendHealPacket(client->GetPlayer(), client->GetPlayer()->GetTarget() ? client->GetPlayer()->GetTarget() : client->GetPlayer(),
  10119. atoul(sep->arg[1]), atoul(sep->arg[2]), "TestSpell");
  10120. }
  10121. else if(atoi(sep->arg[0]) == 34 && sep->IsNumber(1) && sep->IsNumber(2)) {
  10122. PacketStruct* packet = configReader.getStruct("WS_QuestRewardPackMsg", client->GetVersion());
  10123. packet->setSubstructDataByName("reward_data", "unknown1", atoi(sep->arg[1]));
  10124. Item* item = master_item_list.GetItem(atoul(sep->arg[2]));
  10125. if(item) {
  10126. packet->setSubstructArrayLengthByName("reward_data", "num_select_rewards", 1);
  10127. packet->setArrayDataByName("select_reward_id", item->details.item_id, 0);
  10128. packet->setItemArrayDataByName("select_item", item, client->GetPlayer(), 0, 0, World::newValue - 2);
  10129. }
  10130. client->QueuePacket(packet->serialize());
  10131. safe_delete(packet);
  10132. }
  10133. }
  10134. else {
  10135. PacketStruct* packet2 = configReader.getStruct("WS_ExaminePartialSpellInfo", client->GetVersion());
  10136. if (packet2) {
  10137. packet2->setSubstructDataByName("info_header", "show_name", 1);
  10138. packet2->setSubstructDataByName("info_header", "unknown", 7);
  10139. packet2->setSubstructDataByName("info_header", "unknown2", 1);
  10140. packet2->setSubstructDataByName("info_header", "unknown3", 1);
  10141. packet2->setSubstructDataByName("info_header", "unknown4", 1);
  10142. packet2->setSubstructDataByName("info_header", "unknown5", 1);
  10143. packet2->setSubstructDataByName("info_header", "unknown6", "Testing");
  10144. packet2->setSubstructDataByName("info_header", "unknown7", "Testing");
  10145. packet2->setSubstructDataByName("info_header", "unknown8", 66);
  10146. packet2->setSubstructDataByName("info_header", "title", "Blah Title Blah");
  10147. packet2->setSubstructDataByName("info_header", "title_text", "Blah Blah");
  10148. packet2->setSubstructDataByName("info_header", "title_text2", "Blah Blah2");
  10149. packet2->setSubstructDataByName("info_header", "show_popup", 1);
  10150. packet2->setSubstructDataByName("info_header", "packettype", 3);
  10151. packet2->setSubstructDataByName("spell_info", "skill_name", "Testing");
  10152. packet2->setSubstructDataByName("spell_info", "level", 19);
  10153. packet2->setSubstructDataByName("spell_info", "tier", 1);
  10154. packet2->setSubstructDataByName("spell_info", "health_cost", 5);
  10155. packet2->setSubstructDataByName("spell_info", "min_class_skill_req", 3);
  10156. packet2->setSubstructDataByName("spell_info", "mana_cost", 6);
  10157. packet2->setSubstructDataByName("spell_info", "req_concentration", 7);
  10158. packet2->setSubstructDataByName("spell_info", "cast_time", 200);
  10159. packet2->setSubstructDataByName("spell_info", "recovery", 220);
  10160. packet2->setSubstructDataByName("spell_info", "recast", 280);
  10161. packet2->setSubstructDataByName("spell_info", "beneficial", 1);
  10162. packet2->setSubstructDataByName("spell_info", "maintained", 1);
  10163. packet2->setSubstructDataByName("spell_info", "spell_book_type", 1);
  10164. packet2->setSubstructDataByName("spell_info", "quality", 3);
  10165. packet2->setSubstructDataByName("spell_info", "test_1a", 1);
  10166. packet2->setSubstructDataByName("spell_info", "test_1b", 1);
  10167. packet2->setSubstructDataByName("spell_info", "test_1c", 1);
  10168. packet2->setSubstructDataByName("spell_info", "test_1d", 1);
  10169. packet2->setSubstructDataByName("spell_info", "test_2a", 2);
  10170. packet2->setSubstructDataByName("spell_info", "test_2b", 2);
  10171. packet2->setSubstructDataByName("spell_info", "test_2c", 2);
  10172. packet2->setSubstructDataByName("spell_info", "test_2d", 2);
  10173. packet2->setSubstructDataByName("spell_info", "test_3", 3);
  10174. packet2->setSubstructDataByName("spell_info", "test_4", 4);
  10175. packet2->setSubstructDataByName("spell_info", "test_5", 5);
  10176. packet2->setSubstructDataByName("spell_info", "test_6", 6);
  10177. packet2->setSubstructDataByName("spell_info", "min_class_skill_req", 1);
  10178. packet2->setSubstructDataByName("spell_info", "min_class_skill_rec", 30123);
  10179. packet2->setSubstructDataByName("spell_info", "num_reagents", 1);
  10180. packet2->setSubstructArrayLengthByName("spell_info", "num_reagents", 1);
  10181. packet2->setArrayDataByName("reagent", "Alcohol");
  10182. packet2->setArrayDataByName("consumed", "123");
  10183. packet2->setSubstructDataByName("spell_info", "class_skill", 52);
  10184. packet2->setSubstructDataByName("spell_info", "id", 8308);
  10185. packet2->setSubstructDataByName("spell_info", "icon", 303);
  10186. packet2->setSubstructDataByName("spell_info", "icon2", 0xFFFF);
  10187. packet2->setSubstructDataByName("spell_info", "icontype", 317);
  10188. packet2->setSubstructDataByName("spell_info", "type", 2);
  10189. packet2->setSubstructDataByName("spell_info", "spell_text_color", 255);
  10190. packet2->setSubstructDataByName("spell_info", "duration1", 600);
  10191. packet2->setSubstructDataByName("spell_info", "duration2", 600);
  10192. packet2->setSubstructDataByName("spell_info", "name", "Sprint");
  10193. packet2->setSubstructDataByName("spell_info", "description", "Test description");
  10194. EQ2Packet* outapp = packet2->serialize();
  10195. DumpPacket(outapp);
  10196. client->QueuePacket(outapp);
  10197. safe_delete(packet2);
  10198. }
  10199. }
  10200. return;
  10201. PacketStruct* p = configReader.getStruct("WS_EqTargetItemCmd", client->GetVersion());
  10202. if (!p) return;
  10203. //Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  10204. //client->GetCurrentZone()->SendSpellFailedPacket(client, atoi(sep2->arg[0]));
  10205. //}
  10206. /*Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  10207. if (sep2 && sep2->arg[0] && sep2->IsNumber(0)) {
  10208. client->SetPendingFlightPath(atoi(sep2->arg[0]));
  10209. PacketStruct* packet = configReader.getStruct("WS_ReadyForTakeOff", client->GetVersion());
  10210. if (packet) {
  10211. client->QueuePacket(packet->serialize());
  10212. safe_delete(packet);
  10213. }
  10214. }*/
  10215. /*if (client->GetCurrentZone()->Grid != nullptr) {
  10216. int32 numFaces = 0;
  10217. int32 numGrids = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.size();
  10218. client->Message(CHANNEL_COLOR_YELLOW, "Num grids in cell: %u", numGrids);
  10219. map<int32, vector<Face*> >::iterator itr;
  10220. for (itr = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.begin(); itr != client->GetPlayer()->Cell_Info.CurrentCell->FaceList.end(); itr++)
  10221. numFaces += (*itr).second.size();
  10222. client->Message(CHANNEL_COLOR_YELLOW, "Num faces in cell: %u", numFaces);
  10223. }*/
  10224. //uchar blah[] = {
  10225. // 1208 - OP_EQUpdateStoreCmd
  10226. // /*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
  10227. // /*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
  10228. // 1193 - -- OP_ClientCmdMsg::OP_EqUpdateMerchantCmd --
  10229. // /*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
  10230. /*};
  10231. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  10232. int8 val = 0;
  10233. int16 pos = 0;
  10234. int idx = 0;
  10235. while(sep2 && sep2->arg[idx+1] && sep2->IsNumber(idx) && sep2->IsNumber(idx+1)){
  10236. pos = atoi(sep2->arg[idx]);
  10237. val = atoi(sep2->arg[idx+1]);
  10238. memset(blah+pos, val, 1);
  10239. idx+=2;
  10240. }
  10241. DumpPacket(blah, sizeof(blah));
  10242. client->QueuePacket(new EQ2Packet(OP_GroupCreatedMsg , blah, sizeof(blah)));*/
  10243. if (client->GetPlayer()->GetTarget()) {
  10244. PacketStruct* packet = configReader.getStruct("WS_SetControlGhost", client->GetVersion());
  10245. if (packet) {
  10246. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  10247. packet->setDataByName("size", 0);
  10248. packet->setDataByName("unknown2", 0);
  10249. EQ2Packet* app = packet->serialize();
  10250. client->QueuePacket(app);
  10251. safe_delete(packet);
  10252. }
  10253. PacketStruct* set_pov = configReader.getStruct("WS_SetPOVGhostCmd", client->GetVersion());
  10254. if (set_pov) {
  10255. set_pov->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  10256. EQ2Packet* app_pov = set_pov->serialize();
  10257. client->QueuePacket(app_pov);
  10258. safe_delete(set_pov);
  10259. }
  10260. }
  10261. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  10262. PacketStruct* packet = configReader.getStruct("WS_OpenCharCust", client->GetVersion());
  10263. if (packet) {
  10264. if (sep2 && sep2->arg[0] && sep2->IsNumber(0))
  10265. packet->setDataByName("Type", atoi(sep2->arg[0]));
  10266. else
  10267. packet->setDataByName("Type", 2);
  10268. if (sep2 && sep2->arg[1] && sep2->IsNumber(1))
  10269. packet->setDataByName("race_id", atoi(sep2->arg[1]));
  10270. else
  10271. packet->setDataByName("race_id", 0);
  10272. if (sep2 && sep2->arg[2] && sep2->IsNumber(2))
  10273. packet->setDataByName("gender", atoi(sep2->arg[2]));
  10274. else
  10275. packet->setDataByName("gender", 2);
  10276. if (sep2 && sep2->arg[3] && sep2->IsNumber(3))
  10277. packet->setDataByName("unknown", atoi(sep2->arg[3]), 0);
  10278. else
  10279. packet->setDataByName("unknown", 0, 0);
  10280. if (sep2 && sep2->arg[4] && sep2->IsNumber(4))
  10281. packet->setDataByName("unknown", atoi(sep2->arg[4]), 1);
  10282. else
  10283. packet->setDataByName("unknown", 0, 1);
  10284. if (sep2 && sep2->arg[5] && sep2->IsNumber(5))
  10285. packet->setDataByName("unknown", atoi(sep2->arg[5]), 2);
  10286. else
  10287. packet->setDataByName("unknown", 0, 2);
  10288. client->QueuePacket(packet->serialize());
  10289. }
  10290. safe_delete(packet);
  10291. safe_delete(sep2);
  10292. }
  10293. void Commands::Command_LeaveChannel(Client *client, Seperator *sep) {
  10294. const char *channel_name;
  10295. if (sep == NULL || !sep->IsSet(0)) {
  10296. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /leavechat <channel name>");
  10297. PrintSep(sep);
  10298. return;
  10299. }
  10300. channel_name = sep->arg[0];
  10301. if (!chat.IsInChannel(client, channel_name))
  10302. client->Message(CHANNEL_NARRATIVE, "Unable to leave '%s': You are not in the channel.", channel_name);
  10303. else if (!chat.LeaveChannel(client, channel_name))
  10304. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an internal error preventing you from leaving that channel MUAHAHA");
  10305. }
  10306. /*
  10307. Function:
  10308. Purpose :
  10309. Params :
  10310. Dev :
  10311. Example :
  10312. */
  10313. void Commands::Command_WeaponStats(Client* client)
  10314. {
  10315. Player* player = client->GetPlayer();
  10316. Spawn* target = player->GetTarget();
  10317. Item* primary = player->GetEquipmentList()->GetItem(EQ2_PRIMARY_SLOT);
  10318. Item* secondary = player->GetEquipmentList()->GetItem(EQ2_SECONDARY_SLOT);
  10319. Item* ranged = player->GetEquipmentList()->GetItem(EQ2_RANGE_SLOT);
  10320. const char* charName = player->GetName();
  10321. if(target && target->IsEntity()) {
  10322. primary = ((Entity*)target)->GetEquipmentList()->GetItem(EQ2_PRIMARY_SLOT);
  10323. secondary = ((Entity*)target)->GetEquipmentList()->GetItem(EQ2_SECONDARY_SLOT);
  10324. ranged = ((Entity*)target)->GetEquipmentList()->GetItem(EQ2_RANGE_SLOT);
  10325. charName = target->GetName();
  10326. }
  10327. else {
  10328. target = nullptr;
  10329. }
  10330. client->Message(0, "WeaponStats for %s", charName);
  10331. client->SimpleMessage(0, "Primary:");
  10332. if (primary) {
  10333. client->Message(0, "Name: %s", primary->name.c_str());
  10334. client->Message(0, "Base Damage: %u - %u", primary->weapon_info->damage_low3, primary->weapon_info->damage_high3);
  10335. client->Message(0, "Mastery Damage: %u - %u", primary->weapon_info->damage_low2, primary->weapon_info->damage_high2);
  10336. client->Message(0, "Damage: %u - %u", primary->weapon_info->damage_low1, primary->weapon_info->damage_high1);
  10337. client->Message(0, "Actual Damage: %u - %u", target ? ((Entity*)target)->GetPrimaryWeaponMinDamage() : player->GetPrimaryWeaponMinDamage(),
  10338. target ? ((Entity*)target)->GetPrimaryWeaponMaxDamage() : player->GetPrimaryWeaponMaxDamage());
  10339. client->Message(0, "Actual Delay: %u", target ? ((Entity*)target)->GetPrimaryWeaponDelay() : player->GetPrimaryWeaponDelay());
  10340. client->Message(0, "Proc Percent: %d%%", 0);
  10341. client->Message(0, "Procs Per Minute: %d", 0);
  10342. }
  10343. else {
  10344. client->SimpleMessage(0, "Name: fist");
  10345. client->Message(0, "Base Damage: %u - %u", target ? ((Entity*)target)->GetPrimaryWeaponMinDamage() : player->GetPrimaryWeaponMinDamage(),
  10346. target ? ((Entity*)target)->GetPrimaryWeaponMaxDamage() : player->GetPrimaryWeaponMaxDamage());
  10347. client->Message(0, "Actual Damage: %u - %u", target ? ((Entity*)target)->GetPrimaryWeaponMinDamage() : player->GetPrimaryWeaponMinDamage(),
  10348. target ? ((Entity*)target)->GetPrimaryWeaponMaxDamage() : player->GetPrimaryWeaponMaxDamage());
  10349. client->Message(0, "Actual Delay: %d", target ? ((Entity*)target)->GetPrimaryWeaponDelay() : player->GetPrimaryWeaponDelay() * 0.1);
  10350. client->Message(0, "Proc Percent: %d%%", 0);
  10351. client->Message(0, "Procs Per Minute: %d", 0);
  10352. }
  10353. client->SimpleMessage(0, " ");
  10354. client->SimpleMessage(0, " ");
  10355. if (secondary) {
  10356. client->SimpleMessage(0, "Secondary:");
  10357. client->Message(0, "Name: %s", secondary->name.c_str());
  10358. client->Message(0, "Base Damage: %u - %u", secondary->weapon_info->damage_low3, secondary->weapon_info->damage_high3);
  10359. client->Message(0, "Mastery Damage: %u - %u", secondary->weapon_info->damage_low2, secondary->weapon_info->damage_high2);
  10360. client->Message(0, "Damage: %u - %u", secondary->weapon_info->damage_low1, secondary->weapon_info->damage_high1);
  10361. client->Message(0, "Actual Damage: %u - %u", target ? ((Entity*)target)->GetSecondaryWeaponMinDamage() : player->GetSecondaryWeaponMinDamage(),
  10362. target ? ((Entity*)target)->GetSecondaryWeaponMaxDamage() : player->GetSecondaryWeaponMaxDamage());
  10363. client->Message(0, "Actual Delay: %d", target ? ((Entity*)target)->GetSecondaryWeaponDelay() : player->GetSecondaryWeaponDelay() * 0.1);
  10364. client->Message(0, "Proc Percent: %d%%", 0);
  10365. client->Message(0, "Procs Per Minute: %d", 0);
  10366. client->SimpleMessage(0, " ");
  10367. client->SimpleMessage(0, " ");
  10368. }
  10369. client->SimpleMessage(0, "Ranged:");
  10370. if (ranged) {
  10371. client->Message(0, "Name: %s", ranged->name.c_str());
  10372. client->Message(0, "Base Damage: %u - %u", ranged->ranged_info->weapon_info.damage_low3, ranged->ranged_info->weapon_info.damage_high3);
  10373. client->Message(0, "Mastery Damage: %u - %u", ranged->ranged_info->weapon_info.damage_low2, ranged->ranged_info->weapon_info.damage_high2);
  10374. client->Message(0, "Damage: %u - %u", ranged->ranged_info->weapon_info.damage_low1, ranged->ranged_info->weapon_info.damage_high1);
  10375. client->Message(0, "Actual Damage: %u - %u", target ? ((Entity*)target)->GetRangedWeaponMinDamage() : player->GetRangedWeaponMinDamage(),
  10376. target ? ((Entity*)target)->GetRangedWeaponMaxDamage() : player->GetRangedWeaponMaxDamage());
  10377. client->Message(0, "Actual Delay: %d", target ? ((Entity*)target)->GetRangeWeaponDelay() : player->GetRangeWeaponDelay() * 0.1);
  10378. client->Message(0, "Proc Percent: %d%%", 0);
  10379. client->Message(0, "Procs Per Minute: %d", 0);
  10380. }
  10381. else
  10382. client->SimpleMessage(0, "None");
  10383. }
  10384. void Commands::Command_WhoChannel(Client *client, Seperator *sep) {
  10385. const char *channel_name;
  10386. if (sep == NULL || !sep->IsSet(0)) {
  10387. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /chatwho <channel name>");
  10388. return;
  10389. }
  10390. channel_name = sep->arg[0];
  10391. if (!chat.ChannelExists(channel_name))
  10392. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That channel does not exist!");
  10393. else
  10394. chat.SendChannelUserList(client, channel_name);
  10395. }
  10396. void Commands::Command_ZoneSafeCoords(Client *client, Seperator *sep)
  10397. {
  10398. ZoneServer* zone = 0;
  10399. int32 zone_id = client->GetPlayer()->GetZone()->GetZoneID();
  10400. if (zone_id > 0)
  10401. {
  10402. zone = zone_list.Get(zone_id, false, false, false);
  10403. if (zone)
  10404. {
  10405. zone->SetSafeX(client->GetPlayer()->GetX());
  10406. zone->SetSafeY(client->GetPlayer()->GetY());
  10407. zone->SetSafeZ(client->GetPlayer()->GetZ());
  10408. zone->SetSafeHeading(client->GetPlayer()->GetHeading());
  10409. if( database.SaveZoneSafeCoords(zone_id, zone->GetSafeX(), zone->GetSafeY(), zone->GetSafeZ(), zone->GetSafeHeading()) )
  10410. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Zone safe coordinates updated!");
  10411. else
  10412. client->SimpleMessage(CHANNEL_COLOR_RED, "FAILED to update zone safe coordinates!");
  10413. }
  10414. }
  10415. }
  10416. /*
  10417. Function:
  10418. Purpose :
  10419. Params :
  10420. Dev :
  10421. Example :
  10422. */
  10423. void Commands::Command_ZoneDetails(Client* client, Seperator* sep)
  10424. {
  10425. ZoneInfo* zone_info = new ZoneInfo;
  10426. if (sep && sep->arg[0])
  10427. {
  10428. if (sep->IsNumber(0))
  10429. zone_info->id = atoi(sep->arg[0]);
  10430. else
  10431. zone_info->id = database.GetZoneID(sep->arg[0]);
  10432. if (zone_info->id > 0)
  10433. {
  10434. database.LoadZoneInfo(zone_info);
  10435. 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);
  10436. 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);
  10437. 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);
  10438. 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);
  10439. 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);
  10440. 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);
  10441. 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);
  10442. client->Message(CHANNEL_COLOR_YELLOW, "zone_type: %s, sky_file: %s", zone_info->zone_type, zone_info->sky_file);
  10443. client->Message(CHANNEL_COLOR_YELLOW, "lua_script: %s", zone_info->lua_script);
  10444. client->Message(CHANNEL_COLOR_YELLOW, "zone_motd: %s", zone_info->zone_motd);
  10445. }
  10446. else
  10447. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  10448. }
  10449. else
  10450. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone details [zone id|zone name]");
  10451. safe_delete(zone_info);
  10452. }
  10453. /*
  10454. Function:
  10455. Purpose :
  10456. Params :
  10457. Dev :
  10458. Example :
  10459. */
  10460. void Commands::Command_ZoneSet(Client* client, Seperator* sep)
  10461. {
  10462. if (sep && sep->arg[0] && sep->arg[1] && sep->arg[2])
  10463. {
  10464. ZoneServer* zone = 0;
  10465. int32 zone_id = 0;
  10466. if (sep->IsNumber(0) && atoi(sep->arg[0]) > 0)
  10467. {
  10468. zone_id = atoi(sep->arg[0]);
  10469. zone = zone_list.Get(atoi(sep->arg[0]), false, false, false);
  10470. }
  10471. else
  10472. {
  10473. zone_id = database.GetZoneID(sep->arg[0]);
  10474. if (zone_id > 0)
  10475. zone = zone_list.Get(sep->arg[0], false, false, false);
  10476. }
  10477. if (zone_id > 0)
  10478. {
  10479. if (zone_set_values.count(string(sep->arg[1])) > 0)
  10480. SetZoneCommand(client, zone_id, zone, zone_set_values[sep->arg[1]], sep->arg[2]);
  10481. else
  10482. client->Message(CHANNEL_COLOR_YELLOW, "The attribute '%s' is not valid.", sep->arg[1]);
  10483. }
  10484. else
  10485. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  10486. }
  10487. else
  10488. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone set [zone id|zone name] [attribute] [value]");
  10489. }
  10490. void Commands::Command_Rain(Client* client, Seperator* sep) {
  10491. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  10492. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /rain <float>");
  10493. return;
  10494. }
  10495. client->Message(CHANNEL_COLOR_YELLOW,"Setting rain to %.2f", atof(sep->arg[0]));
  10496. client->GetCurrentZone()->SetRain(atof(sep->arg[0]));
  10497. client->GetCurrentZone()->SetCurrentWeather(atof(sep->arg[0]));
  10498. }
  10499. void Commands::Command_Wind(Client* client, Seperator* sep) {
  10500. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  10501. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /wind <float>");
  10502. return;
  10503. }
  10504. client->Message(CHANNEL_COLOR_YELLOW, "Setting wind to %.2f", atof(sep->arg[0]));
  10505. client->GetCurrentZone()->SetWind(atof(sep->arg[0]));
  10506. }
  10507. void Commands::Command_SendMerchantWindow(Client* client, Seperator* sep, bool sell) {
  10508. Spawn* spawn = client->GetPlayer()->GetTarget();
  10509. if(client->GetVersion() < 561) {
  10510. sell = false; // doesn't support in the same way as AoM just open the normal buy/sell window
  10511. }
  10512. if(spawn) {
  10513. client->SetMerchantTransaction(spawn);
  10514. if (spawn->GetMerchantID() > 0 && spawn->IsClientInMerchantLevelRange(client)){
  10515. client->SendHailCommand(spawn);
  10516. //MerchantFactionMultiplier* multiplier = world.GetMerchantMultiplier(spawn->GetMerchantID());
  10517. //if(!multiplier || (multiplier && client->GetPlayer()->GetFactions()->GetFactionValue(multiplier->faction_id) >= multiplier->faction_min)){
  10518. client->SendBuyMerchantList(sell);
  10519. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY))
  10520. client->SendSellMerchantList(sell);
  10521. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY_BACK))
  10522. client->SendBuyBackList(sell);
  10523. if(client->GetVersion() > 561) {
  10524. PacketStruct* packet = configReader.getStruct("WS_UpdateMerchant", client->GetVersion());
  10525. if (packet) {
  10526. packet->setDataByName("spawn_id", 0xFFFFFFFF);
  10527. packet->setDataByName("type", 16);
  10528. EQ2Packet* outapp = packet->serialize();
  10529. if (outapp)
  10530. client->QueuePacket(outapp);
  10531. safe_delete(packet);
  10532. }
  10533. }
  10534. }
  10535. if (spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR)
  10536. client->SendRepairList();
  10537. }
  10538. // client->SimpleMessage(CHANNEL_COLOR_RED, "Your faction is too low to use this merchant.");
  10539. }
  10540. void Commands::Command_Weather(Client* client, Seperator* sep)
  10541. {
  10542. //PrintSep(sep, "Weather");
  10543. if( sep && sep->arg[0] )
  10544. {
  10545. ZoneServer* zsZone = client->GetCurrentZone();
  10546. const char* value = sep->arg[0];
  10547. // process single-param commands first
  10548. if( strncasecmp(value, "details", strlen(value)) == 0 )
  10549. {
  10550. client->Message(CHANNEL_COLOR_YELLOW, "Weather Details for zone %s: ", zsZone->GetZoneName());
  10551. client->Message(CHANNEL_COLOR_YELLOW, "enabled: %i, allowed: %i, type: %i, frequency: %u", zsZone->isWeatherEnabled(), zsZone->isWeatherAllowed(), zsZone->GetWeatherType(), zsZone->GetWeatherFrequency());
  10552. client->Message(CHANNEL_COLOR_YELLOW, "severity: %.2f = %.2f, current: %.2f", zsZone->GetWeatherMinSeverity(), zsZone->GetWeatherMaxSeverity(), zsZone->GetCurrentWeather());
  10553. client->Message(CHANNEL_COLOR_YELLOW, "pattern: %i, chance: %i, amount: %.2f, offset: %.2f", zsZone->GetWeatherPattern(), zsZone->GetWeatherChance(), zsZone->GetWeatherChangeAmount(), zsZone->GetWeatherDynamicOffset());
  10554. }
  10555. else if( strncasecmp(value, "process", strlen(value)) == 0 )
  10556. {
  10557. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  10558. zsZone->ProcessWeather();
  10559. }
  10560. else if( strncasecmp(value, "reset", strlen(value)) == 0 )
  10561. {
  10562. zsZone->SetWeatherType(rule_manager.GetGlobalRule(R_Zone, WeatherType)->GetInt8());
  10563. zsZone->SetWeatherFrequency(rule_manager.GetGlobalRule(R_Zone, WeatherChangeFrequency)->GetInt32());
  10564. zsZone->SetWeatherMinSeverity(rule_manager.GetGlobalRule(R_Zone, MinWeatherSeverity)->GetFloat());
  10565. zsZone->SetWeatherMaxSeverity(rule_manager.GetGlobalRule(R_Zone, MaxWeatherSeverity)->GetFloat());
  10566. zsZone->SetCurrentWeather(zsZone->GetWeatherMinSeverity());
  10567. zsZone->SetWeatherPattern(1);
  10568. zsZone->SetWeatherChance(rule_manager.GetGlobalRule(R_Zone, WeatherChangeChance)->GetInt8());
  10569. zsZone->SetWeatherChangeAmount(rule_manager.GetGlobalRule(R_Zone, WeatherChangePerInterval)->GetFloat());
  10570. zsZone->SetWeatherDynamicOffset(rule_manager.GetGlobalRule(R_Zone, WeatherDynamicMaxOffset)->GetFloat());
  10571. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  10572. zsZone->ProcessWeather();
  10573. }
  10574. // process commands with params
  10575. if( sep->arg[1] )
  10576. {
  10577. if( strncasecmp(value, "enable", strlen(value)) == 0 && sep->IsNumber(1) )
  10578. zsZone->SetWeatherEnabled( ( atoi(sep->arg[1]) == 1 ) ? true : false );
  10579. else if( strncasecmp(value, "type", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 3) )
  10580. zsZone->SetWeatherType(atoi(sep->arg[1]));
  10581. else if( strncasecmp(value, "frequency", strlen(value)) == 0 && sep->IsNumber(1))
  10582. zsZone->SetWeatherFrequency( atoul(sep->arg[1]) );
  10583. else if( strncasecmp(value, "range", strlen(value)) == 0 && sep->IsNumber(1) && sep->IsNumber(2) ) {
  10584. zsZone->SetWeatherMinSeverity(atof(sep->arg[1]));
  10585. zsZone->SetWeatherMaxSeverity(atof(sep->arg[2]));
  10586. zsZone->SetRain(zsZone->GetWeatherMinSeverity());
  10587. }
  10588. else if( strncasecmp(value, "current", strlen(value)) == 0 && sep->IsNumber(1) ) {
  10589. zsZone->SetCurrentWeather(atof(sep->arg[1]));
  10590. zsZone->SetRain(zsZone->GetCurrentWeather());
  10591. }
  10592. else if( strncasecmp(value, "pattern", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 2) )
  10593. zsZone->SetWeatherPattern( atoi(sep->arg[1]) );
  10594. else if( strncasecmp(value, "chance", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 100) )
  10595. zsZone->SetWeatherChance( atoi(sep->arg[1]) );
  10596. else if( strncasecmp(value, "amount", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  10597. zsZone->SetWeatherChangeAmount( atof(sep->arg[1]) );
  10598. else if( strncasecmp(value, "offset", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  10599. zsZone->SetWeatherDynamicOffset( atof(sep->arg[1]) );
  10600. }
  10601. }
  10602. else
  10603. {
  10604. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /weather [command] [param]");
  10605. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: enable (0|1), type (0-3), frequency (sec), range|current (0.0 - 1.0)");
  10606. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: details, process, pattern (0|1), chance (%), amount (float), offset (float)");
  10607. return;
  10608. }
  10609. }
  10610. void Commands::Command_Select(Client* client, Seperator* sep) {
  10611. if (sep && sep->arg[1]) {
  10612. Spawn* spawn = client->GetPlayer()->GetTarget();
  10613. if (spawn && strlen(sep->arg[1]) > 0)
  10614. client->GetCurrentZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_CUSTOM, client->GetPlayer(), sep->arg[1]);
  10615. }
  10616. }
  10617. /*
  10618. Function: Command_ConsumeFood()
  10619. Purpose : Consume Food/Drink and apply mods
  10620. Params : Slot ID - EQ2_FOOD_SLOT 22, EQ2_DRINK_SLOT 23
  10621. Dev : Zcoretri
  10622. Example : /consume_food 22
  10623. */
  10624. void Commands::Command_ConsumeFood(Client* client, Seperator* sep) {
  10625. if (sep && sep->arg[0] && sep->IsNumber(0))
  10626. {
  10627. Player* player = client->GetPlayer();
  10628. int32 slot = atoul(sep->arg[0]);
  10629. if (client->GetVersion() <= 373) {
  10630. if(client->GetVersion() <= 561) {
  10631. if(slot <= 255) {
  10632. slot = 255 - slot;
  10633. }
  10634. else {
  10635. if(slot == 256) { // first "new" item to inventory is assigned index 256 by client
  10636. slot = client->GetPlayer()->item_list.GetFirstNewItem();
  10637. }
  10638. else {
  10639. // otherwise the slot has to be mapped out depending on the amount of new items + index sent in
  10640. slot = client->GetPlayer()->item_list.GetNewItemByIndex((int16)slot - 255);
  10641. }
  10642. }
  10643. }
  10644. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(slot);
  10645. if(item && item->IsFood()) {
  10646. if(client->CheckConsumptionAllowed(slot)) {
  10647. if(item->IsFoodFood())
  10648. slot = EQ2_FOOD_SLOT;
  10649. else if(item->IsFoodDrink())
  10650. slot = EQ2_DRINK_SLOT;
  10651. else
  10652. return; // not valid item
  10653. client->ConsumeFoodDrink(item, slot);
  10654. }
  10655. }
  10656. }
  10657. else {
  10658. if (client->GetVersion() > 373 && client->GetVersion() <= 561) {
  10659. slot += 2;
  10660. }
  10661. Item* item = player->GetEquipmentList()->GetItem(slot);
  10662. if(client->CheckConsumptionAllowed(slot)) {
  10663. client->ConsumeFoodDrink(item, slot);
  10664. }
  10665. }
  10666. }
  10667. }
  10668. void Commands::Command_Aquaman(Client* client, Seperator* sep) {
  10669. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  10670. if (atoi(sep->arg[0]) == 1) {
  10671. client->GetPlayer()->GetInfoStruct()->set_vision(4);
  10672. client->GetPlayer()->GetInfoStruct()->set_breathe_underwater(1);
  10673. client->GetPlayer()->SetCharSheetChanged(true);
  10674. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Maybe you ought to stick to the shallow end until you know how to swim.");
  10675. }
  10676. else {
  10677. client->GetPlayer()->GetInfoStruct()->set_vision(0);
  10678. client->GetPlayer()->GetInfoStruct()->set_breathe_underwater(0);
  10679. client->GetPlayer()->SetCharSheetChanged(true);
  10680. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Aquaman mode turned off.");
  10681. }
  10682. }
  10683. else
  10684. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /aquaman [0|1]");
  10685. }
  10686. void Commands::Command_ReportBug(Client* client, Seperator* sep)
  10687. {
  10688. if(sep)
  10689. {
  10690. string data;
  10691. if(sep->arg[0]){
  10692. data = string(sep->arg[0]);
  10693. }
  10694. for(int i=1;i<sep->GetMaxArgNum();i++){
  10695. if(sep->arg[i])
  10696. data.append(" ").append(sep->arg[i]);
  10697. }
  10698. if(!sep->IsSet(7)){
  10699. data.append(" ").append(std::to_string(client->GetVersion())).append("\a");
  10700. }
  10701. const char* target_name = 0;
  10702. int32 spawn_id = 0;
  10703. if(client->GetPlayer()->GetTarget())
  10704. {
  10705. target_name = client->GetPlayer()->GetTarget()->GetName();
  10706. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  10707. }
  10708. else
  10709. target_name = "N/A";
  10710. LogWrite(COMMAND__DEBUG, 1, "Command", "%s", data.c_str());
  10711. if(world.ReportBug(data, client->GetPlayer()->GetName(), client->GetAccountID(), target_name, spawn_id, client->GetCurrentZone()->GetZoneID()))
  10712. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully submitted bug.");
  10713. else
  10714. client->SimpleMessage(CHANNEL_COLOR_RED, "Error submitting bug.");
  10715. }
  10716. }
  10717. void Commands::Command_Attune_Inv(Client* client, Seperator* sep) {
  10718. PrintSep(sep, "Command_Attune_Inv");
  10719. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  10720. // Get the item index from the first parameter
  10721. int16 index = atoi(sep->arg[0]);
  10722. // Check to see if this is a valid item index for the player, if not exit out of the function
  10723. if (client->GetPlayer()->item_list.indexed_items.count(index) == 0) {
  10724. LogWrite(ITEM__DEBUG, 0, "Items", "%s has no item with an index of %i", client->GetPlayer()->GetName(), index);
  10725. return;
  10726. }
  10727. // Get the item
  10728. Item* item = client->GetPlayer()->item_list.indexed_items[index];
  10729. if(item) {
  10730. // Valid item lets check to make sure this item is attunable, if not return out
  10731. if (!item->CheckFlag(ATTUNEABLE)) {
  10732. LogWrite(ITEM__DEBUG, 0, "Items", "attune_inv called for an item that is not attunable (%s)", item->name.c_str());
  10733. return;
  10734. }
  10735. // Remove the attunable flag
  10736. item->generic_info.item_flags -= ATTUNEABLE;
  10737. // Set the attuned flag
  10738. item->generic_info.item_flags += ATTUNED;
  10739. // Flag this item for saving
  10740. item->save_needed = true;
  10741. client->QueuePacket(item->serialize(client->GetVersion(), false, client->GetPlayer()));
  10742. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), 0, -1); // appearance type??
  10743. EQ2Packet* outapp = 0;
  10744. for (int32 i=0;i<packets.size();i++) {
  10745. outapp = packets[i];
  10746. if(outapp)
  10747. client->QueuePacket(outapp);
  10748. }
  10749. }
  10750. }
  10751. }
  10752. void Commands::Command_Reset_Zone_Timer(Client* client, Seperator* sep) {
  10753. PrintSep(sep, "Command_Reset_Zone_Timer");
  10754. /*if (sep && sep->arg[0] && sep->IsNumber(0)) {
  10755. int32 db_id = atoul(sep->arg[0]);
  10756. InstanceData* data = client->GetPlayer()->GetCharacterInstances().FindInstanceByDBID(db_id);
  10757. if (data) {
  10758. // TODO: add a check to timers to ensure it can be reset
  10759. // Delete the character from the instance
  10760. database.DeleteCharacterFromInstance(client->GetPlayer()->GetCharacterID(), data->instance_id);
  10761. data->instance_id = 0;
  10762. // Update the success time and set to 0 so the player can enter it again
  10763. database.UpdateCharacterInstance(client->GetPlayer()->GetCharacterID(), data->zone_name, 0, 1, 0);
  10764. data->last_success_timestamp = 0;
  10765. }
  10766. }*/
  10767. }
  10768. void Commands::Command_Player(Client* client, Seperator* sep) {
  10769. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player syntax --");
  10770. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins");
  10771. }
  10772. void Commands::Command_Player_Coins(Client* client, Seperator* sep) {
  10773. // /player coins add 10
  10774. // /player coins add plat 10
  10775. Player* player = client->GetPlayer();
  10776. Client* targetClient = client;
  10777. if (player->HasTarget() && player->GetTarget()->IsPlayer()) {
  10778. player = (Player*)player->GetTarget();
  10779. targetClient = player->GetClient();
  10780. }
  10781. if (sep && sep->arg[0] && sep->arg[1]) {
  10782. const char* action = sep->arg[0];
  10783. int64 value = 0;
  10784. if (strncasecmp(action, "add", strlen(action)) == 0) {
  10785. if (sep->IsNumber(1)) {
  10786. value = atoi64(sep->arg[1]);
  10787. player->AddCoins(value);
  10788. if (client->GetPlayer() == player)
  10789. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  10790. else {
  10791. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  10792. if(targetClient) {
  10793. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  10794. }
  10795. }
  10796. return;
  10797. }
  10798. else if (sep->arg[2] && sep->IsNumber(2)) {
  10799. const char* type = sep->arg[1];
  10800. if (strncasecmp(type, "copper", strlen(type)) == 0) {
  10801. value = atoi64(sep->arg[2]);
  10802. }
  10803. else if (strncasecmp(type, "silver", strlen(type)) == 0) {
  10804. value = atoi64(sep->arg[2]) * 100;
  10805. }
  10806. else if (strncasecmp(type, "gold", strlen(type)) == 0) {
  10807. value = atoi64(sep->arg[2]) * 10000;
  10808. }
  10809. else if (strncasecmp(type, "plat", strlen(type)) == 0) {
  10810. value = atoi64(sep->arg[2]) * 1000000;
  10811. }
  10812. player->AddCoins(value);
  10813. if (client->GetPlayer() == player)
  10814. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  10815. else {
  10816. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  10817. if(targetClient) {
  10818. targetClient->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  10819. }
  10820. }
  10821. return;
  10822. }
  10823. }
  10824. }
  10825. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player coins syntax --");
  10826. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add [value] - adds the given number of coins to the player");
  10827. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add copper [value] - adds the given amount of copper to the player");
  10828. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add silver [value] - adds the given amount of silver to the player");
  10829. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add gold [value] - adds the given amount of gold to the player");
  10830. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add plat [value] - adds the given amount of platinum to the player");
  10831. }
  10832. void Commands::Command_AchievementAdd(Client* client, Seperator* sep) {
  10833. PrintSep(sep, "ACHIEVEMENT_ADD");
  10834. if (sep && sep->IsSet(0)) {
  10835. int32 spell_id = atoul(sep->arg[1]);
  10836. int8 spell_tier = 0;
  10837. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  10838. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  10839. // addspellbookentry here
  10840. if (spell_tier >= data->maxRank) {
  10841. return;
  10842. }
  10843. if (!spell_tier) {
  10844. spell_tier = 1;
  10845. }
  10846. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  10847. {
  10848. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  10849. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  10850. client->GetPlayer()->UnlockSpell(spell);
  10851. client->SendSpellUpdate(spell);
  10852. }
  10853. else
  10854. {
  10855. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1);
  10856. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  10857. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  10858. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  10859. client->GetPlayer()->UnlockSpell(spell);
  10860. client->SendSpellUpdate(spell);
  10861. }
  10862. // cast spell here
  10863. if (!spell_tier)
  10864. spell_tier = 1;
  10865. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  10866. if (spell) {
  10867. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  10868. }
  10869. }
  10870. else {
  10871. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  10872. }
  10873. if(client->GetVersion() > 561)
  10874. master_aa_list.DisplayAA(client, 0, 0);
  10875. }
  10876. void Commands::Command_Editor(Client* client, Seperator* sep) {
  10877. PacketStruct* packet = configReader.getStruct("WS_ChoiceWindow", client->GetVersion());
  10878. if (packet) {
  10879. string url = string(rule_manager.GetGlobalRule(R_World, EditorURL)->GetString());
  10880. if (rule_manager.GetGlobalRule(R_World, EditorOfficialServer)->GetBool()) {
  10881. char command[255];
  10882. url = "browser " + url;
  10883. int32 spawn_id = 0;
  10884. int32 zone_id = 0;
  10885. string type;
  10886. if (client->GetCurrentZone())
  10887. zone_id = client->GetCurrentZone()->GetZoneID();
  10888. if (client->GetPlayer()->GetTarget()) {
  10889. Spawn* target = client->GetPlayer()->GetTarget();
  10890. if (target->IsWidget())
  10891. type = "widgets";
  10892. else if (target->IsSign())
  10893. type = "signs";
  10894. else if (target->IsObject())
  10895. type = "objects";
  10896. else if (target->IsNPC())
  10897. type = "npcs";
  10898. else if (target->IsGroundSpawn())
  10899. type = "ground";
  10900. else
  10901. type = "spawn";
  10902. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  10903. }
  10904. sprintf(command, url.c_str(), zone_id, type.c_str(), spawn_id);
  10905. packet->setDataByName("accept_command", command);
  10906. }
  10907. else if (rule_manager.GetGlobalRule(R_World, EditorIncludeID)->GetBool()) {
  10908. char command[255];
  10909. url = "browser " + url;
  10910. if (client->GetPlayer()->GetTarget())
  10911. sprintf(command, url.c_str(), client->GetPlayer()->GetTarget()->GetDatabaseID());
  10912. packet->setDataByName("accept_command", command);
  10913. }
  10914. else {
  10915. string command = "browser " + url;
  10916. packet->setDataByName("accept_command", command.c_str());
  10917. }
  10918. packet->setDataByName("text", "Open the web editor?");
  10919. packet->setDataByName("accept_text", "Open");
  10920. packet->setDataByName("cancel_text", "Cancel");
  10921. // No clue if we even need the following 2 unknowns, just added them so the packet matches what live sends
  10922. packet->setDataByName("unknown2", 50);
  10923. packet->setDataByName("unknown4", 1);
  10924. client->QueuePacket(packet->serialize());
  10925. safe_delete(packet);
  10926. }
  10927. }
  10928. void Commands::Command_AcceptResurrection(Client* client, Seperator* sep) {
  10929. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  10930. return;
  10931. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  10932. if(client->GetCurrentRez()->active)
  10933. client->AcceptResurrection();
  10934. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  10935. }
  10936. void Commands::Command_DeclineResurrection(Client* client, Seperator* sep) {
  10937. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  10938. return;
  10939. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  10940. if(client->GetCurrentRez()->active)
  10941. client->GetCurrentRez()->should_delete = true;
  10942. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  10943. }
  10944. void Commands::Switch_AA_Profile(Client* client, Seperator* sep) {
  10945. PrintSep(sep, "Switch_AA_Profile");
  10946. if (sep && sep->IsSet(0)) {
  10947. string type = sep->arg[0];
  10948. int8 newtemplate = atoul(sep->arg[1]);
  10949. if(client->GetVersion() > 561)
  10950. master_aa_list.DisplayAA(client, newtemplate, 1);
  10951. }
  10952. }
  10953. void Commands::Get_AA_Xml(Client* client, Seperator* sep) {
  10954. PrintSep(sep, "Get_AA_Xml");
  10955. if (sep && sep->IsSet(0)) {
  10956. string tabnum = sep->arg[0];
  10957. string spellid = sep->arg[1];
  10958. }
  10959. }
  10960. void Commands::Add_AA(Client* client, Seperator* sep) {
  10961. PrintSep(sep, "Add_AA");
  10962. if (sep && sep->IsSet(0)) {
  10963. int32 spell_id = atoul(sep->arg[1]);
  10964. int8 spell_tier = 0;
  10965. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  10966. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  10967. // addspellbookentry here
  10968. if(!data) {
  10969. LogWrite(COMMAND__ERROR, 0, "Command", "Error in Add_AA no data for spell_id %u spell_tier %u", spell_id, spell_tier);
  10970. return;
  10971. }
  10972. if (spell_tier >= data->maxRank) {
  10973. LogWrite(COMMAND__ERROR, 0, "Command", "Error in Add_AA spell_tier %u >= maxRank %u", spell_tier, data->maxRank);
  10974. return;
  10975. }
  10976. if (!spell_tier) {
  10977. spell_tier = 1;
  10978. }
  10979. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  10980. {
  10981. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  10982. if(spell)
  10983. {
  10984. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  10985. client->GetPlayer()->UnlockSpell(spell);
  10986. client->SendSpellUpdate(spell);
  10987. }
  10988. }
  10989. else
  10990. {
  10991. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1 );
  10992. if(spell)
  10993. {
  10994. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  10995. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  10996. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  10997. client->GetPlayer()->UnlockSpell(spell);
  10998. client->SendSpellUpdate(spell);
  10999. }
  11000. }
  11001. // cast spell here
  11002. if (!spell_tier)
  11003. spell_tier = 1;
  11004. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  11005. if (spell) {
  11006. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  11007. }
  11008. }
  11009. else {
  11010. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  11011. }
  11012. if(client->GetVersion() > 561)
  11013. master_aa_list.DisplayAA(client, 0, 0);
  11014. }
  11015. void Commands::Commit_AA_Profile(Client* client, Seperator* sep) {
  11016. PrintSep(sep, "Commit_AA_Profile");
  11017. if (sep && sep->IsSet(0)) {
  11018. }
  11019. }
  11020. void Commands::Begin_AA_Profile(Client* client, Seperator* sep) {
  11021. PrintSep(sep, "Begin_AA_Profile");
  11022. if (sep && sep->IsSet(0)) {
  11023. if(client->GetVersion() > 561)
  11024. master_aa_list.DisplayAA(client, 100, 2);
  11025. }
  11026. }
  11027. void Commands::Back_AA(Client* client, Seperator* sep) {
  11028. if (sep && sep->IsSet(0)) {
  11029. PrintSep(sep, "Back_AA");
  11030. }
  11031. }
  11032. void Commands::Remove_AA(Client* client, Seperator* sep) {
  11033. if (sep && sep->IsSet(0)) {
  11034. PrintSep(sep, "Remove_AA");
  11035. }
  11036. }
  11037. void Commands::Cancel_AA_Profile(Client* client, Seperator* sep) {
  11038. MasterAAList master_aa_list;
  11039. PrintSep(sep, "Cancel_AA_Profile");
  11040. if(client->GetVersion() > 561)
  11041. master_aa_list.DisplayAA(client, 0, 0);
  11042. }
  11043. void Commands::Save_AA_Profile(Client* client, Seperator* sep) {
  11044. if (sep && sep->IsSet(0)) {
  11045. PrintSep(sep, "Save_AA_Profile");
  11046. }
  11047. }
  11048. void Commands::Command_TargetItem(Client* client, Seperator* sep) {
  11049. if (!sep || sep->GetArgNumber() < 1 || !client->GetPlayer()) return;
  11050. if (!sep->IsNumber(0)) return;
  11051. int32 request_id = atoul(sep->arg[0]);
  11052. if (!sep->IsNumber(1)) return;
  11053. sint32 item_id = atoi(sep->arg[1]);
  11054. if (client->IsCurrentTransmuteID(request_id)) {
  11055. Transmute::HandleItemResponse(client, client->GetPlayer(), request_id, reinterpret_cast<int32&>(item_id));
  11056. }
  11057. else if (client->IsCurrentTransmuteID(item_id)) {
  11058. if (!sep->IsSet(2)) return;
  11059. if (sep->IsNumber(2) && atoi(sep->arg[2]) == 1) {
  11060. Transmute::HandleConfirmResponse(client, client->GetPlayer(), reinterpret_cast<int32&>(item_id));
  11061. }
  11062. }
  11063. }
  11064. void Commands::Command_FindSpawn(Client* client, Seperator* sep) {
  11065. if(sep)
  11066. client->GetCurrentZone()->FindSpawn(client, (char*)sep->argplus[0]);
  11067. }
  11068. void Commands::Command_MoveCharacter(Client* client, Seperator* sep) {
  11069. if(sep && sep->arg[0][0] && sep->arg[1][0])
  11070. {
  11071. char* name = sep->arg[0];
  11072. char* zoneName = sep->arg[1];
  11073. char query[256];
  11074. 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);
  11075. if (database.RunQuery(query, strnlen(query, 256)))
  11076. {
  11077. client->Message(CHANNEL_COLOR_YELLOW, "Ran query:%s", query);
  11078. }
  11079. else
  11080. client->Message(CHANNEL_COLOR_RED, "Query FAILED to run: %s", query);
  11081. }
  11082. }
  11083. void Commands::Command_Mood(Client* client, Seperator* sep) {
  11084. Player* player = client->GetPlayer();
  11085. if( sep && sep->arg[0] )
  11086. {
  11087. const char* value = sep->arg[0];
  11088. InfoStruct* info = player->GetInfoStruct();
  11089. int32 cid = client->GetCharacterID();
  11090. char* characterName = database.GetCharacterName(cid);
  11091. char tmp[1024]; // our emote string "xyz appears zyx"
  11092. //char properties vals
  11093. char* pname = "mood";
  11094. char* pval; // mood value
  11095. bool pt; //used to verify return from DB.
  11096. //This should never be seen.
  11097. sprintf(tmp, " ");
  11098. if( strncasecmp(value, "angry", strlen(value)) == 0 )
  11099. {
  11100. sprintf(tmp, "%s appears angry", characterName);
  11101. pval = "11852";
  11102. player->SetMoodState(11852, 1);
  11103. info->set_mood(11852);
  11104. pt = database.insertCharacterProperty(client, pname, pval);
  11105. }
  11106. else if( strncasecmp(value, "afraid", strlen(value)) == 0 )
  11107. {
  11108. sprintf(tmp, "%s appears afraid", characterName);
  11109. pval = "11851";
  11110. player->SetMoodState(11851, 1);
  11111. info->set_mood(11851);
  11112. pt = database.insertCharacterProperty(client, pname, pval);
  11113. }
  11114. else if( strncasecmp(value, "happy", strlen(value)) == 0 )
  11115. {
  11116. sprintf(tmp, "%s appears happy", characterName);
  11117. pval = "11854";
  11118. player->SetMoodState(11854, 1);
  11119. info->set_mood(11854);
  11120. pt = database.insertCharacterProperty(client, pname, pval);
  11121. }
  11122. else if( strncasecmp(value, "sad", strlen(value)) == 0 ) {
  11123. sprintf(tmp, "%s appears sad", characterName);
  11124. pval = "11856";
  11125. player->SetMoodState(11856, 1);
  11126. info->set_mood(11856);
  11127. pt = database.insertCharacterProperty(client, pname, pval);
  11128. }
  11129. else if( strncasecmp(value, "tired", strlen(value)) == 0 )
  11130. {
  11131. sprintf(tmp, "%s appears tired", characterName);
  11132. pval = "11857";
  11133. player->SetMoodState(11857, 1);
  11134. info->set_mood(11857);
  11135. pt = database.insertCharacterProperty(client, pname, pval);
  11136. }
  11137. else if( strncasecmp(value, "none", strlen(value)) == 0 )
  11138. {
  11139. //using 11855 mood_idle for none, I assume thats what its for?
  11140. pval = "11855";
  11141. player->SetMoodState(11855, 1);
  11142. info->set_mood(11855);
  11143. pt = database.insertCharacterProperty(client, pname, pval);
  11144. //return since we have nothing left to do. No emote for none.
  11145. return;
  11146. }else{
  11147. client->SimpleMessage(CHANNEL_NARRATIVE, "Listing Available Moods:");
  11148. client->SimpleMessage(CHANNEL_NARRATIVE, "none");
  11149. client->SimpleMessage(CHANNEL_NARRATIVE, "afraid");
  11150. client->SimpleMessage(CHANNEL_NARRATIVE, "angry");
  11151. client->SimpleMessage(CHANNEL_NARRATIVE, "happy");
  11152. client->SimpleMessage(CHANNEL_NARRATIVE, "sad");
  11153. client->SimpleMessage(CHANNEL_NARRATIVE, "tired");
  11154. return;
  11155. }
  11156. client->GetPlayer()->GetZone()->HandleChatMessage(0, 0, CHANNEL_EMOTE, tmp);
  11157. return;
  11158. }
  11159. client->SimpleMessage(CHANNEL_NARRATIVE, "Listing Available Moods:");
  11160. client->SimpleMessage(CHANNEL_NARRATIVE, "none");
  11161. client->SimpleMessage(CHANNEL_NARRATIVE, "afraid");
  11162. client->SimpleMessage(CHANNEL_NARRATIVE, "angry");
  11163. client->SimpleMessage(CHANNEL_NARRATIVE, "happy");
  11164. client->SimpleMessage(CHANNEL_NARRATIVE, "sad");
  11165. client->SimpleMessage(CHANNEL_NARRATIVE, "tired");
  11166. return;
  11167. }
  11168. /*
  11169. Function: Command_CancelEffect()
  11170. Purpose : Cancels (good) effect spells
  11171. Example : /cancel_effect spell_id - would cancel the spell with the <spell_id> value in spell effects list
  11172. */
  11173. void Commands::Command_CancelEffect(Client* client, Seperator* sep)
  11174. {
  11175. if (sep && sep->arg[0] && sep->IsNumber(0))
  11176. {
  11177. int32 spell_id = atoul(sep->arg[0]);
  11178. SpellEffects* effect = client->GetPlayer()->GetSpellEffect(spell_id);
  11179. if(!effect || effect->spell->spell->GetSpellData()->det_type) {
  11180. return;
  11181. }
  11182. MaintainedEffects* meffect = effect->caster->GetMaintainedSpell(spell_id);
  11183. if (!meffect || !meffect->spell || !meffect->spell->caster || !meffect->spell->caster->GetZone() ||
  11184. !meffect->spell->caster->GetZone()->GetSpellProcess()->DeleteCasterSpell(meffect->spell, "canceled", false, client->GetPlayer()))
  11185. client->Message(CHANNEL_COLOR_RED, "The spell effect could not be cancelled.");
  11186. }
  11187. }
  11188. /*
  11189. Function: Command_CurePlayer()
  11190. Purpose : Identifies spell to cast for cure based on type
  11191. Example : /cureplayer ??
  11192. https://eq2.fandom.com/wiki/Update:58
  11193. New command /cureplayer [playername|group or raid position][trauma|arcane|noxious|elemental|curse] optional [spell|potion]
  11194. Example: /cureplayer g0 noxious spell
  11195. Will attempt to cure yourself of a noxious detriment with only spells and without using potions (even if you have them).
  11196. Example: /cureplayer r4 noxious
  11197. Will attempt to cure the character in raid slot 4 of a noxious detriment using a spell or potion (whichever is available).
  11198. */
  11199. void Commands::Command_CurePlayer(Client* client, Seperator* sep)
  11200. {
  11201. Entity* target = nullptr;
  11202. bool use_spells = true;
  11203. bool use_potions = true;
  11204. if (sep && sep->arg[0] && sep->arg[1]) {
  11205. if(sep->arg[2]) {
  11206. std::string type(sep->arg[2]);
  11207. boost::algorithm::to_lower(type);
  11208. if(type == "potion")
  11209. use_spells = false;
  11210. else if(type == "spell")
  11211. use_potions = false;
  11212. }
  11213. if(strlen(sep->arg[0]) > 1 && isdigit(sep->arg[0][1])) {
  11214. int32 mapped_position = (int32)(sep->arg[0][1]) - 48;
  11215. // TODO: RAID Support ('r' argument)
  11216. if(sep->arg[0][0] == 'g' && !mapped_position) {
  11217. target = (Entity*)client->GetPlayer();
  11218. }
  11219. else {
  11220. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  11221. if (gmi && gmi->group_id) {
  11222. PlayerGroup* group = world.GetGroupManager()->GetGroup(gmi->group_id);
  11223. if(group) {
  11224. target = group->GetGroupMemberByPosition(client->GetPlayer(), mapped_position);
  11225. }
  11226. }
  11227. }
  11228. }
  11229. else {
  11230. Client* target_client = zone_list.GetClientByCharName(sep->arg[0]);
  11231. if(target_client && target_client->GetPlayer() && target_client->GetPlayer()->GetZone() == client->GetPlayer()->GetZone()) {
  11232. target = (Entity*)target_client->GetPlayer();
  11233. }
  11234. }
  11235. ItemEffectType type = EFFECT_CURE_TYPE_ALL;
  11236. bool successful_spell = false;
  11237. bool successful_potion = false;
  11238. if(target) {
  11239. SpellBookEntry* entry = nullptr;
  11240. std::string str(sep->arg[1]);
  11241. boost::algorithm::to_lower(str);
  11242. if(str == "arcane") {
  11243. type = EFFECT_CURE_TYPE_ARCANE;
  11244. // cure arcane spell missing in DB?
  11245. if(use_spells && rule_manager.GetGlobalRule(R_Spells, CureArcaneSpellID)->GetInt32()) {
  11246. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureArcaneSpellID)->GetInt32()); // cure noxious
  11247. }
  11248. }
  11249. else if(str == "trauma") {
  11250. type = EFFECT_CURE_TYPE_TRAUMA;
  11251. // cure trauma spell missing in DB?
  11252. if(use_spells && rule_manager.GetGlobalRule(R_Spells, CureTraumaSpellID)->GetInt32()) {
  11253. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureTraumaSpellID)->GetInt32()); // cure noxious
  11254. }
  11255. }
  11256. else if(str == "noxious") {
  11257. type = EFFECT_CURE_TYPE_NOXIOUS;
  11258. if(use_spells && rule_manager.GetGlobalRule(R_Spells, CureNoxiousSpellID)->GetInt32()) {
  11259. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureNoxiousSpellID)->GetInt32()); // cure noxious
  11260. }
  11261. }
  11262. else if(str == "curse") {
  11263. type = EFFECT_CURE_TYPE_CURSE;
  11264. if(use_spells && rule_manager.GetGlobalRule(R_Spells, CureCurseSpellID)->GetInt32()) {
  11265. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureCurseSpellID)->GetInt32()); // cure curse
  11266. }
  11267. }
  11268. else if(str == "magic") {
  11269. type = EFFECT_CURE_TYPE_MAGIC;
  11270. if(use_spells && rule_manager.GetGlobalRule(R_Spells, CureMagicSpellID)->GetInt32()) {
  11271. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureMagicSpellID)->GetInt32()); // cure magic
  11272. }
  11273. }
  11274. if(use_spells) {
  11275. // check if any of the specific cure types are available, if not then check the base cures
  11276. if(!entry && rule_manager.GetGlobalRule(R_Spells, CureSpellID)->GetInt32()) {
  11277. entry = client->GetPlayer()->GetSpellBookSpell(rule_manager.GetGlobalRule(R_Spells, CureSpellID)->GetInt32()); // cure
  11278. }
  11279. if(entry && entry->spell_id) {
  11280. Spell* spell = master_spell_list.GetSpell(entry->spell_id, entry->tier);
  11281. target->GetZone()->ProcessSpell(spell, (Entity*)client->GetPlayer(), target, true, false);
  11282. successful_spell = true;
  11283. }
  11284. }
  11285. }
  11286. if(!successful_spell && use_potions && target && type != NO_EFFECT_TYPE) {
  11287. vector<Item*>* potential_items = client->GetItemsByEffectType(type, EFFECT_CURE_TYPE_ALL);
  11288. if (potential_items && potential_items->size() > 0) {
  11289. vector<Item*>::iterator itr;
  11290. for (itr = potential_items->begin(); itr != potential_items->end(); itr++)
  11291. {
  11292. Item* item = *itr;
  11293. if(client->UseItem(item, target)) {
  11294. successful_potion = true;
  11295. break;
  11296. }
  11297. }
  11298. }
  11299. safe_delete(potential_items);
  11300. }
  11301. }
  11302. }
  11303. /*
  11304. Function: Command_ShareQuest()
  11305. Purpose : Share quest with the group
  11306. Example : /share_quest [quest_id]
  11307. */
  11308. void Commands::Command_ShareQuest(Client* client, Seperator* sep)
  11309. {
  11310. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  11311. int32 quest_id = atoul(sep->arg[0]);
  11312. bool hasQuest = client->GetPlayer()->HasAnyQuest(quest_id);
  11313. if(hasQuest) {
  11314. Quest* quest = master_quest_list.GetQuest(quest_id, false);
  11315. if(quest) {
  11316. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  11317. if (gmi && gmi->group_id) {
  11318. PlayerGroup* group = world.GetGroupManager()->GetGroup(gmi->group_id);
  11319. if (group) {
  11320. group->ShareQuestWithGroup(client, quest);
  11321. }
  11322. }
  11323. }
  11324. }
  11325. else {
  11326. client->SimpleMessage(CHANNEL_COLOR_RED, "Cannot find quest.");
  11327. }
  11328. }
  11329. }
  11330. /*
  11331. Function: Command_Yell()
  11332. Purpose : Yell to break an encounter
  11333. Example : /yell
  11334. * Uses self target, encounter target or no target
  11335. */
  11336. void Commands::Command_Yell(Client* client, Seperator* sep) {
  11337. Entity* player = (Entity*)client->GetPlayer();
  11338. Spawn* res = nullptr;
  11339. Spawn* prev = nullptr;
  11340. bool cycleAll = false;
  11341. if (player->GetTarget() == player) {
  11342. cycleAll = true; // self target breaks all encounters
  11343. }
  11344. else if (player->GetTarget()) {
  11345. res = player->GetTarget(); // selected target other than self only dis-engages that encounter
  11346. }
  11347. if (res && !client->GetPlayer()->IsEngagedBySpawnID(res->GetID()))
  11348. return;
  11349. bool groupPermissionYell = true;
  11350. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  11351. // If the player has a group and has a target
  11352. if (gmi) {
  11353. deque<GroupMemberInfo*>::iterator itr;
  11354. world.GetGroupManager()->GroupLock(__FUNCTION__, __LINE__);
  11355. PlayerGroup* group = world.GetGroupManager()->GetGroup(gmi->group_id);
  11356. if (group && !group->GetGroupOptions()->default_yell && !gmi->leader) { // default_yell_method = 0 means leader only
  11357. groupPermissionYell = false;
  11358. }
  11359. world.GetGroupManager()->ReleaseGroupLock(__FUNCTION__, __LINE__);
  11360. }
  11361. if (!groupPermissionYell) {
  11362. LogWrite(COMMAND__ERROR, 0, "Command", "%s permission to yell denied due to group yell method set to leader only", client->GetPlayer()->GetName());
  11363. return;
  11364. }
  11365. bool alreadyYelled = false;
  11366. do {
  11367. if (!res && player->IsEngagedInEncounter(&res)) { // no target is set, dis-engage top of hated by list
  11368. }
  11369. if (!res || prev == res) {
  11370. return;
  11371. }
  11372. if (res->IsNPC() && ((NPC*)res)->Brain()) {
  11373. if (!alreadyYelled) {
  11374. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You yell for help!");
  11375. string yellMsg = std::string(client->GetPlayer()->GetName()) + " yelled for help!";
  11376. client->GetPlayer()->GetZone()->SimpleMessage(CHANNEL_COLOR_RED, yellMsg.c_str(), client->GetPlayer(), 35.0f, false);
  11377. client->GetPlayer()->GetZone()->SendYellPacket(client->GetPlayer());
  11378. }
  11379. alreadyYelled = true;
  11380. NPC* npc = (NPC*)res;
  11381. npc->Brain()->ClearEncounter();
  11382. npc->SetLockedNoLoot(ENCOUNTER_STATE_BROKEN);
  11383. npc->UpdateEncounterState(ENCOUNTER_STATE_BROKEN);
  11384. }
  11385. prev = res;
  11386. res = nullptr;
  11387. } while (cycleAll);
  11388. if (!player->IsEngagedInEncounter()) {
  11389. if (player->GetInfoStruct()->get_engaged_encounter()) {
  11390. player->GetInfoStruct()->set_engaged_encounter(0);
  11391. player->SetRegenValues((player->GetInfoStruct()->get_effective_level() > 0) ? player->GetInfoStruct()->get_effective_level() : player->GetLevel());
  11392. client->GetPlayer()->SetCharSheetChanged(true);
  11393. player->info_changed = true;
  11394. }
  11395. }
  11396. }
  11397. /*
  11398. Function: Command_SetAutoLootMode()
  11399. Purpose : Set player auto loot mode (0 = disabled, 1 = need/lotto, 2 = decline).
  11400. Example : /setautolootmode [mode]
  11401. */
  11402. void Commands::Command_SetAutoLootMode(Client* client, Seperator* sep) {
  11403. if (sep && sep->IsNumber(0)) {
  11404. int8 mode = atoul(sep->arg[0]);
  11405. switch (mode) {
  11406. case AutoLootMode::METHOD_DISABLED: {
  11407. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Disabled auto loot mode");
  11408. break;
  11409. }
  11410. case AutoLootMode::METHOD_ACCEPT: {
  11411. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Enabled auto loot mode for need and lotto.");
  11412. break;
  11413. }
  11414. default: {
  11415. mode = AutoLootMode::METHOD_DECLINE;
  11416. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Enabled auto loot mode to decline need and lotto.");
  11417. break;
  11418. }
  11419. }
  11420. client->GetPlayer()->GetInfoStruct()->set_group_auto_loot_method(mode);
  11421. database.insertCharacterProperty(client, CHAR_PROPERTY_AUTOLOOTMETHOD, (char*)std::to_string(mode).c_str());
  11422. client->SendDefaultGroupOptions();
  11423. }
  11424. }
  11425. /*
  11426. Function: Command_AutoAttack()
  11427. Purpose : Attack / Auto Attack
  11428. Example : /attack, /autoattack type
  11429. */
  11430. void Commands::Command_AutoAttack(Client* client, Seperator* sep) {
  11431. int8 type = 1;
  11432. bool update = false;
  11433. Player* player = client->GetPlayer();
  11434. if(!player)
  11435. return;
  11436. bool incombat = player->EngagedInCombat();
  11437. if(sep && sep->arg[0] && sep->IsNumber(0))
  11438. type = atoi(sep->arg[0]);
  11439. if(!client->GetPlayer()->Alive()){
  11440. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  11441. return;
  11442. }
  11443. if(type == 0){
  11444. if(incombat)
  11445. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You stop fighting.");
  11446. player->StopCombat(type);
  11447. update = true;
  11448. }
  11449. else {
  11450. if(type == 2){
  11451. player->InCombat(false);
  11452. if(incombat && player->GetRangeAttack()){
  11453. player->StopCombat(type);
  11454. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You stop fighting.");
  11455. update = true;
  11456. }
  11457. else{
  11458. player->SetRangeAttack(true);
  11459. player->InCombat(true, true);
  11460. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You start fighting.");
  11461. update = true;
  11462. }
  11463. }
  11464. else {
  11465. player->InCombat(false, true);
  11466. player->SetRangeAttack(false);
  11467. player->InCombat(true);
  11468. if(!incombat) {
  11469. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You start fighting.");
  11470. update = true;
  11471. }
  11472. }
  11473. /*else
  11474. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You cannot attack that!");*/
  11475. }
  11476. if(update) {
  11477. player->SetCharSheetChanged(true);
  11478. }
  11479. }
  11480. /*
  11481. Function: Command_Assist()
  11482. Purpose : Assist target
  11483. Example : /assist [name]
  11484. * Uses target or character name
  11485. */
  11486. void Commands::Command_Assist(Client* client, Seperator* sep) {
  11487. Entity* player = (Entity*)client->GetPlayer();
  11488. Spawn* res = nullptr;
  11489. if(sep && sep->arg[0]) {
  11490. if(!stricmp(sep->arg[0], "on")) {
  11491. database.insertCharacterProperty(client, CHAR_PROPERTY_ASSISTAUTOATTACK, "1");
  11492. return;
  11493. }
  11494. else if(!stricmp(sep->arg[0], "off")) {
  11495. database.insertCharacterProperty(client, CHAR_PROPERTY_ASSISTAUTOATTACK, "0");
  11496. return;
  11497. }
  11498. Client* otherClient = client->GetPlayer()->GetZone()->GetClientByName(sep->arg[0]);
  11499. if(otherClient) {
  11500. res = otherClient->GetPlayer();
  11501. }
  11502. }
  11503. if (player->GetTarget()) {
  11504. res = player->GetTarget(); // selected target other than self only dis-engages that encounter
  11505. }
  11506. if(res && res->GetTarget()) {
  11507. res = res->GetTarget();
  11508. }
  11509. if(res) {
  11510. client->TargetSpawn(res);
  11511. if(client->GetPlayer()->GetInfoStruct()->get_assist_auto_attack() && !player->EngagedInCombat()) {
  11512. Command_AutoAttack(client, nullptr);
  11513. }
  11514. }
  11515. }
  11516. /*
  11517. Function: Command_Target()
  11518. Purpose : Target spawn/player
  11519. Example : /target [name]
  11520. * Uses target or character name
  11521. */
  11522. void Commands::Command_Target(Client* client, Seperator* sep) {
  11523. Entity* player = (Entity*)client->GetPlayer();
  11524. Spawn* res = nullptr;
  11525. if(sep && sep->arg[0] && player->GetZone()) {
  11526. float max_distance = rule_manager.GetGlobalRule(R_Player, MaxTargetCommandDistance)->GetFloat();
  11527. if(max_distance < 1.0f) {
  11528. max_distance = 10.0f;
  11529. }
  11530. player->GetZone()->SetPlayerTargetByName(client, (char*)sep->argplus[0], max_distance);
  11531. }
  11532. }
  11533. /*
  11534. Function: Command_Target_Pet()
  11535. Purpose : Target pet
  11536. Example : /target_pet
  11537. * Use to target pet
  11538. */
  11539. void Commands::Command_Target_Pet(Client* client, Seperator* sep) {
  11540. Entity* player = (Entity*)client->GetPlayer();
  11541. Spawn* res = client->GetPlayer()->GetPet();
  11542. if(res) {
  11543. client->TargetSpawn(res);
  11544. }
  11545. }