Commands.cpp 372 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374
  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 "Commands.h"
  18. #include "../ClientPacketFunctions.h"
  19. #include "../../common/version.h"
  20. #include "../../common/seperator.h"
  21. #include "../../common/servertalk.h"
  22. #include "../WorldDatabase.h"
  23. #include "../World.h"
  24. #include "../../common/ConfigReader.h"
  25. #include "../VisualStates.h"
  26. #include "../../common/debug.h"
  27. #include "../LuaInterface.h"
  28. #include "../Quests.h"
  29. #include "../client.h"
  30. #include "../NPC.h"
  31. #include "../Guilds/Guild.h"
  32. #include "../SpellProcess.h"
  33. #include "../Tradeskills/Tradeskills.h"
  34. #include "../../common/Log.h"
  35. #include "../../common/MiscFunctions.h"
  36. #include "../Languages.h"
  37. #include "../IRC/IRC.h"
  38. #include "../Traits/Traits.h"
  39. #include "../Chat/Chat.h"
  40. #include "../Rules/Rules.h"
  41. #include "../AltAdvancement/AltAdvancement.h"
  42. #include "../RaceTypes/RaceTypes.h"
  43. #include "../classes.h"
  44. #include "../Transmute.h"
  45. #include "../Zone/SPGrid.h"
  46. extern WorldDatabase database;
  47. extern MasterSpellList master_spell_list;
  48. extern MasterTraitList master_trait_list;
  49. extern MasterRecipeList master_recipe_list;
  50. extern MasterRecipeBookList master_recipebook_list;
  51. extern World world;
  52. extern ClientList client_list;
  53. extern ConfigReader configReader;
  54. extern VisualStates visual_states;
  55. extern ZoneList zone_list;
  56. extern LuaInterface* lua_interface;
  57. extern MasterQuestList master_quest_list;
  58. extern MasterCollectionList master_collection_list;
  59. extern MasterSkillList master_skill_list;
  60. extern MasterFactionList master_faction_list;
  61. extern GuildList guild_list;
  62. extern MasterLanguagesList master_languages_list;
  63. extern IRC irc;
  64. extern Chat chat;
  65. extern RuleManager rule_manager;
  66. extern MasterAAList master_aa_list;
  67. extern MasterRaceTypeList race_types_list;
  68. extern Classes classes;
  69. //devn00b: Fix for linux builds since we dont use stricmp we use strcasecmp
  70. #if defined(__GNUC__)
  71. #define stricmp strcasecmp
  72. #define strnicmp strncasecmp
  73. #endif
  74. EQ2Packet* RemoteCommands::serialize(){
  75. buffer.clear();
  76. vector<EQ2_RemoteCommandString>::iterator command_list;
  77. buffer.append((char*)&num_commands, sizeof(int16));
  78. for( command_list = commands.begin(); command_list != commands.end(); command_list++ ) {
  79. AddDataCommand(&(*command_list));
  80. }
  81. EQ2Packet* app = new EQ2Packet(OP_SetRemoteCmdsMsg, (uchar*)buffer.c_str(), buffer.length() + 1);
  82. return app;
  83. }
  84. Commands::Commands(){
  85. remote_commands = new RemoteCommands();
  86. spawn_set_values["list"] = SPAWN_SET_VALUE_LIST;
  87. spawn_set_values["name"] = SPAWN_SET_VALUE_NAME;
  88. spawn_set_values["level"] = SPAWN_SET_VALUE_LEVEL; // TODO: Fix this, min_level, max_level
  89. spawn_set_values["difficulty"] = SPAWN_SET_VALUE_DIFFICULTY;
  90. spawn_set_values["model_type"] = SPAWN_SET_VALUE_MODEL_TYPE;
  91. spawn_set_values["class"] = SPAWN_SET_VALUE_CLASS;
  92. spawn_set_values["gender"] = SPAWN_SET_VALUE_GENDER;
  93. spawn_set_values["show_name"] = SPAWN_SET_VALUE_SHOW_NAME;
  94. spawn_set_values["attackable"] = SPAWN_SET_VALUE_ATTACKABLE;
  95. spawn_set_values["show_level"] = SPAWN_SET_VALUE_SHOW_LEVEL;
  96. spawn_set_values["targetable"] = SPAWN_SET_VALUE_TARGETABLE;
  97. spawn_set_values["show_command_icon"] = SPAWN_SET_VALUE_SHOW_COMMAND_ICON;
  98. spawn_set_values["display_hand_icon"] = SPAWN_SET_VALUE_HAND_ICON;
  99. spawn_set_values["hair_type"] = SPAWN_SET_VALUE_HAIR_TYPE;
  100. spawn_set_values["facial_hair_type"] = SPAWN_SET_VALUE_FACIAL_HAIR_TYPE;
  101. spawn_set_values["wing_type"] = SPAWN_SET_VALUE_WING_TYPE;
  102. spawn_set_values["chest_type"] = SPAWN_SET_VALUE_CHEST_TYPE;
  103. spawn_set_values["legs_type"] = SPAWN_SET_VALUE_LEGS_TYPE;
  104. spawn_set_values["soga_hair_type"] = SPAWN_SET_VALUE_SOGA_HAIR_TYPE;
  105. spawn_set_values["soga_facial_hair_type"] = SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE;
  106. spawn_set_values["soga_model_type"] = SPAWN_SET_VALUE_SOGA_MODEL_TYPE;
  107. spawn_set_values["size"] = SPAWN_SET_VALUE_SIZE;
  108. spawn_set_values["hp"] = SPAWN_SET_VALUE_HP;
  109. spawn_set_values["power"] = SPAWN_SET_VALUE_POWER;
  110. spawn_set_values["heroic"] = SPAWN_SET_VALUE_HEROIC;
  111. spawn_set_values["respawn"] = SPAWN_SET_VALUE_RESPAWN;
  112. spawn_set_values["x"] = SPAWN_SET_VALUE_X;
  113. spawn_set_values["y"] = SPAWN_SET_VALUE_Y;
  114. spawn_set_values["z"] = SPAWN_SET_VALUE_Z;
  115. spawn_set_values["heading"] = SPAWN_SET_VALUE_HEADING;
  116. spawn_set_values["location"] = SPAWN_SET_VALUE_LOCATION;
  117. spawn_set_values["command_primary"] = SPAWN_SET_VALUE_COMMAND_PRIMARY;
  118. spawn_set_values["command_secondary"] = SPAWN_SET_VALUE_COMMAND_SECONDARY;
  119. spawn_set_values["visual_state"] = SPAWN_SET_VALUE_VISUAL_STATE;
  120. spawn_set_values["action_state"] = SPAWN_SET_VALUE_ACTION_STATE;
  121. spawn_set_values["mood_state"] = SPAWN_SET_VALUE_MOOD_STATE;
  122. spawn_set_values["initial_state"] = SPAWN_SET_VALUE_INITIAL_STATE;
  123. spawn_set_values["activity_state"] = SPAWN_SET_VALUE_ACTIVITY_STATE;
  124. spawn_set_values["collision_radius"] = SPAWN_SET_VALUE_COLLISION_RADIUS;
  125. spawn_set_values["faction"] = SPAWN_SET_VALUE_FACTION;
  126. spawn_set_values["spawn_script"] = SPAWN_SET_VALUE_SPAWN_SCRIPT;
  127. spawn_set_values["spawnentry_script"] = SPAWN_SET_VALUE_SPAWNENTRY_SCRIPT;
  128. spawn_set_values["spawnlocation_script"] = SPAWN_SET_VALUE_SPAWNLOCATION_SCRIPT;
  129. spawn_set_values["sub_title"] = SPAWN_SET_VALUE_SUB_TITLE;
  130. spawn_set_values["expire"] = SPAWN_SET_VALUE_EXPIRE;
  131. spawn_set_values["expire_offset"] = SPAWN_SET_VALUE_EXPIRE_OFFSET;
  132. spawn_set_values["x_offset"] = SPAWN_SET_VALUE_X_OFFSET;
  133. spawn_set_values["y_offset"] = SPAWN_SET_VALUE_Y_OFFSET;
  134. spawn_set_values["z_offset"] = SPAWN_SET_VALUE_Z_OFFSET;
  135. spawn_set_values["device_id"] = SPAWN_SET_VALUE_DEVICE_ID;
  136. spawn_set_values["pitch"] = SPAWN_SET_VALUE_PITCH;
  137. spawn_set_values["roll"] = SPAWN_SET_VALUE_ROLL;
  138. spawn_set_values["hide_hood"] = SPAWN_SET_VALUE_HIDE_HOOD;
  139. spawn_set_values["emote_state"] = SPAWN_SET_VALUE_EMOTE_STATE;
  140. spawn_set_values["icon"] = SPAWN_SET_VALUE_ICON;
  141. spawn_set_values["prefix"] = SPAWN_SET_VALUE_PREFIX;
  142. spawn_set_values["suffix"] = SPAWN_SET_VALUE_SUFFIX;
  143. spawn_set_values["lastname"] = SPAWN_SET_VALUE_LASTNAME;
  144. spawn_set_values["expansion_flag"] = SPAWN_SET_VALUE_EXPANSION_FLAG;
  145. spawn_set_values["holiday_flag"] = SPAWN_SET_VALUE_HOLIDAY_FLAG;
  146. spawn_set_values["merchant_min_level"] = SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL;
  147. spawn_set_values["merchant_max_level"] = SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL;
  148. spawn_set_values["skin_color"] = SPAWN_SET_SKIN_COLOR;
  149. zone_set_values["expansion_id"] = ZONE_SET_VALUE_EXPANSION_ID;
  150. zone_set_values["name"] = ZONE_SET_VALUE_NAME;
  151. zone_set_values["file"] = ZONE_SET_VALUE_FILE ;
  152. zone_set_values["description"] = ZONE_SET_VALUE_DESCRIPTION;
  153. zone_set_values["safe_x"] = ZONE_SET_VALUE_SAFE_X;
  154. zone_set_values["safe_y"] = ZONE_SET_VALUE_SAFE_Y;
  155. zone_set_values["safe_z"] = ZONE_SET_VALUE_SAFE_Z;
  156. zone_set_values["underworld"] = ZONE_SET_VALUE_UNDERWORLD;
  157. zone_set_values["min_recommended"] = ZONE_SET_VALUE_MIN_RECOMMENDED;
  158. zone_set_values["max_recommended"] = ZONE_SET_VALUE_MAX_RECOMMENDED;
  159. zone_set_values["zone_type"] = ZONE_SET_VALUE_ZONE_TYPE;
  160. zone_set_values["always_loaded"] = ZONE_SET_VALUE_ALWAYS_LOADED;
  161. zone_set_values["city_zone"] = ZONE_SET_VALUE_CITY_ZONE;
  162. zone_set_values["weather_allowed"] = ZONE_SET_VALUE_WEATHER_ALLOWED;
  163. zone_set_values["min_status"] = ZONE_SET_VALUE_MIN_STATUS;
  164. zone_set_values["min_level"] = ZONE_SET_VALUE_MIN_LEVEL;
  165. zone_set_values["start_zone"] = ZONE_SET_VALUE_START_ZONE;
  166. zone_set_values["instance_type"] = ZONE_SET_VALUE_INSTANCE_TYPE;
  167. zone_set_values["default_reenter_time"] = ZONE_SET_VALUE_DEFAULT_REENTER_TIME;
  168. zone_set_values["default_reset_time"] = ZONE_SET_VALUE_DEFAULT_RESET_TIME;
  169. zone_set_values["default_lockout_time"] = ZONE_SET_VALUE_DEFAULT_LOCKOUT_TIME;
  170. zone_set_values["force_group_to_zone"] = ZONE_SET_VALUE_FORCE_GROUP_TO_ZONE;
  171. zone_set_values["lua_script"] = ZONE_SET_VALUE_LUA_SCRIPT;
  172. zone_set_values["shutdown_timer"] = ZONE_SET_VALUE_SHUTDOWN_TIMER;
  173. zone_set_values["zone_motd"] = ZONE_SET_VALUE_ZONE_MOTD;
  174. }
  175. Commands::~Commands() {
  176. safe_delete(remote_commands);
  177. }
  178. int32 Commands::GetSpawnSetType(string val){
  179. if(spawn_set_values.count(val) > 0)
  180. return spawn_set_values[val];
  181. return 0xFFFFFFFF;
  182. }
  183. bool Commands::SetSpawnCommand(Client* client, Spawn* target, int8 type, const char* value, bool send_update, bool temporary, string* temp_value){
  184. if(!target)
  185. return false;
  186. int32 val = 0;
  187. try{
  188. if(type != SPAWN_SET_VALUE_NAME &&
  189. !(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)
  190. && type != SPAWN_SET_SKIN_COLOR)
  191. val = atoul(value);
  192. }
  193. catch(...){
  194. if(client)
  195. client->Message(CHANNEL_COLOR_RED, "Invalid numeric spawn value: %s", value);
  196. return false;
  197. }
  198. if(temporary){
  199. char tmp[128] = {0};
  200. switch(type){
  201. case SPAWN_SET_VALUE_NAME:{
  202. sprintf(tmp, "%s", target->GetName());
  203. target->SetName(value);
  204. client->GetCurrentZone()->SendUpdateTitles(target);
  205. break;
  206. }
  207. case SPAWN_SET_VALUE_X_OFFSET:
  208. {
  209. sprintf(tmp, "%f", target->GetXOffset());
  210. target->SetXOffset(float(val));
  211. break;
  212. }
  213. case SPAWN_SET_VALUE_Y_OFFSET:
  214. {
  215. sprintf(tmp, "%f", target->GetYOffset());
  216. target->SetYOffset(float(val));
  217. break;
  218. }
  219. case SPAWN_SET_VALUE_Z_OFFSET:
  220. {
  221. sprintf(tmp, "%f", target->GetZOffset());
  222. target->SetZOffset(float(val));
  223. break;
  224. }
  225. case SPAWN_SET_VALUE_EXPIRE: {
  226. sprintf(tmp, "%u", target->GetExpireTime());
  227. target->SetExpireTime(val);
  228. break;
  229. }
  230. case SPAWN_SET_VALUE_EXPIRE_OFFSET: {
  231. sprintf(tmp, "%u", target->GetExpireOffsetTime());
  232. target->SetExpireOffsetTime(val);
  233. break;
  234. }
  235. case SPAWN_SET_VALUE_SUB_TITLE: {
  236. sprintf(tmp, "%s", target->GetSubTitle());
  237. target->SetSubTitle(value);
  238. client->GetCurrentZone()->SendUpdateTitles(target);
  239. break;
  240. }
  241. case SPAWN_SET_VALUE_LEVEL:{
  242. sprintf(tmp, "%i", target->GetLevel());
  243. target->SetLevel(val, send_update);
  244. break;
  245. }
  246. case SPAWN_SET_VALUE_DIFFICULTY:{
  247. sprintf(tmp, "%i", target->GetEncounterLevel());
  248. target->SetEncounterLevel(val, send_update);
  249. break;
  250. }
  251. case SPAWN_SET_VALUE_MODEL_TYPE:{
  252. sprintf(tmp, "%i", target->GetModelType());
  253. target->SetModelType(val, send_update);
  254. break;
  255. }
  256. case SPAWN_SET_VALUE_CLASS:{
  257. sprintf(tmp, "%i", target->GetAdventureClass());
  258. target->SetAdventureClass(val, send_update);
  259. break;
  260. }
  261. case SPAWN_SET_VALUE_GENDER:{
  262. sprintf(tmp, "%i", target->GetGender());
  263. target->SetGender(val, send_update);
  264. break;
  265. }
  266. case SPAWN_SET_VALUE_SHOW_NAME:{
  267. sprintf(tmp, "%i", target->GetShowName());
  268. target->SetShowName(val, send_update);
  269. break;
  270. }
  271. case SPAWN_SET_VALUE_ATTACKABLE:{
  272. sprintf(tmp, "%i", target->GetAttackable());
  273. target->SetAttackable(val, send_update);
  274. break;
  275. }
  276. case SPAWN_SET_VALUE_SHOW_LEVEL:{
  277. sprintf(tmp, "%i", target->GetShowLevel());
  278. target->SetShowLevel(val, send_update);
  279. break;
  280. }
  281. case SPAWN_SET_VALUE_TARGETABLE:{
  282. sprintf(tmp, "%i", target->GetTargetable());
  283. target->SetTargetable(val, send_update);
  284. break;
  285. }
  286. case SPAWN_SET_VALUE_SHOW_COMMAND_ICON:{
  287. sprintf(tmp, "%i", target->GetShowCommandIcon());
  288. target->SetShowCommandIcon(val, send_update);
  289. break;
  290. }
  291. case SPAWN_SET_VALUE_HAND_ICON:{
  292. sprintf(tmp, "%i", target->GetShowHandIcon());
  293. target->SetShowHandIcon(val, send_update);
  294. break;
  295. }
  296. case SPAWN_SET_VALUE_HAIR_TYPE:{
  297. if(target->IsEntity()){
  298. sprintf(tmp, "%i", ((Entity*)target)->GetHairType());
  299. ((Entity*)target)->SetHairType(val, send_update);
  300. }
  301. break;
  302. }
  303. case SPAWN_SET_VALUE_FACIAL_HAIR_TYPE:{
  304. if(target->IsEntity()){
  305. sprintf(tmp, "%i", ((Entity*)target)->GetHairType());
  306. ((Entity*)target)->SetHairType(val, send_update);
  307. }
  308. break;
  309. }
  310. case SPAWN_SET_VALUE_WING_TYPE:{
  311. if(target->IsEntity()){
  312. sprintf(tmp, "%i", ((Entity*)target)->GetWingType());
  313. ((Entity*)target)->SetWingType(val, send_update);
  314. }
  315. break;
  316. }
  317. case SPAWN_SET_VALUE_CHEST_TYPE:{
  318. if(target->IsEntity()){
  319. sprintf(tmp, "%i", ((Entity*)target)->GetChestType());
  320. ((Entity*)target)->SetChestType(val, send_update);
  321. }
  322. break;
  323. }
  324. case SPAWN_SET_VALUE_LEGS_TYPE:{
  325. if(target->IsEntity()){
  326. sprintf(tmp, "%i", ((Entity*)target)->GetLegsType());
  327. ((Entity*)target)->SetLegsType(val, send_update);
  328. }
  329. break;
  330. }
  331. case SPAWN_SET_VALUE_SOGA_HAIR_TYPE:{
  332. if(target->IsEntity()){
  333. sprintf(tmp, "%i", ((Entity*)target)->GetSogaHairType());
  334. ((Entity*)target)->SetSogaHairType(val, send_update);
  335. }
  336. break;
  337. }
  338. case SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE:{
  339. if(target->IsEntity()){
  340. sprintf(tmp, "%i", ((Entity*)target)->GetSogaFacialHairType());
  341. ((Entity*)target)->SetSogaFacialHairType(val, send_update);
  342. }
  343. break;
  344. }
  345. case SPAWN_SET_VALUE_SOGA_MODEL_TYPE:{
  346. sprintf(tmp, "%i", target->GetSogaModelType());
  347. target->SetSogaModelType(val, send_update);
  348. break;
  349. }
  350. case SPAWN_SET_VALUE_SIZE:{
  351. sprintf(tmp, "%i", target->GetSize());
  352. target->SetSize(val, send_update);
  353. break;
  354. }
  355. case SPAWN_SET_VALUE_HP:{
  356. sprintf(tmp, "%i", target->GetHP());
  357. target->SetHP(val, send_update);
  358. break;
  359. }
  360. case SPAWN_SET_VALUE_POWER:{
  361. sprintf(tmp, "%i", target->GetPower());
  362. target->SetPower(val, send_update);
  363. break;
  364. }
  365. case SPAWN_SET_VALUE_HEROIC:{
  366. sprintf(tmp, "%i", target->GetHeroic());
  367. target->SetHeroic(val, send_update);
  368. break;
  369. }
  370. case SPAWN_SET_VALUE_RESPAWN:{
  371. sprintf(tmp, "%u", target->GetRespawnTime());
  372. target->SetRespawnTime(val);
  373. break;
  374. }
  375. case SPAWN_SET_VALUE_X:{
  376. sprintf(tmp, "%f", target->GetX());
  377. target->SetX(atof(value), send_update);
  378. break;
  379. }
  380. case SPAWN_SET_VALUE_Y:{
  381. sprintf(tmp, "%f", target->GetY());
  382. target->SetY(atof(value), send_update);
  383. break;
  384. }
  385. case SPAWN_SET_VALUE_Z:{
  386. sprintf(tmp, "%f", target->GetZ());
  387. target->SetZ(atof(value), send_update);
  388. break;
  389. }
  390. case SPAWN_SET_VALUE_HEADING:{
  391. sprintf(tmp, "%f", target->GetHeading());
  392. target->SetHeading(atof(value) + 360, send_update);
  393. break;
  394. }
  395. case SPAWN_SET_VALUE_VISUAL_STATE:{
  396. sprintf(tmp, "%i", target->GetVisualState());
  397. target->SetVisualState(val, send_update);
  398. break;
  399. }
  400. case SPAWN_SET_VALUE_ACTION_STATE:{
  401. sprintf(tmp, "%i", target->GetActionState());
  402. target->SetActionState(val, send_update);
  403. break;
  404. }
  405. case SPAWN_SET_VALUE_MOOD_STATE:{
  406. sprintf(tmp, "%i", target->GetMoodState());
  407. target->SetMoodState(val, send_update);
  408. break;
  409. }
  410. case SPAWN_SET_VALUE_INITIAL_STATE:{
  411. sprintf(tmp, "%i", target->GetInitialState());
  412. target->SetInitialState(val, send_update);
  413. break;
  414. }
  415. case SPAWN_SET_VALUE_ACTIVITY_STATE:{
  416. sprintf(tmp, "%i", target->GetActivityStatus());
  417. target->SetActivityStatus(val, send_update);
  418. break;
  419. }
  420. case SPAWN_SET_VALUE_COLLISION_RADIUS:{
  421. sprintf(tmp, "%i", target->GetCollisionRadius());
  422. target->SetCollisionRadius(val, send_update);
  423. break;
  424. }
  425. case SPAWN_SET_VALUE_DEVICE_ID: {
  426. if (target->IsObject()) {
  427. sprintf(tmp, "%i", ((Object*)target)->GetDeviceID());
  428. ((Object*)target)->SetDeviceID(val);
  429. }
  430. break;
  431. }
  432. case SPAWN_SET_VALUE_PITCH: {
  433. sprintf(tmp, "%f", target->GetPitch());
  434. target->SetPitch(atof(value), send_update);
  435. break;
  436. }
  437. case SPAWN_SET_VALUE_ROLL: {
  438. sprintf(tmp, "%f", target->GetRoll());
  439. target->SetRoll(atof(value), send_update);
  440. break;
  441. }
  442. case SPAWN_SET_VALUE_HIDE_HOOD: {
  443. sprintf(tmp, "%i", target->appearance.hide_hood);
  444. target->SetHideHood(val);
  445. break;
  446. }
  447. case SPAWN_SET_VALUE_EMOTE_STATE: {
  448. sprintf(tmp, "%i", target->appearance.emote_state);
  449. target->SetEmoteState(val);
  450. break;
  451. }
  452. case SPAWN_SET_VALUE_ICON: {
  453. sprintf(tmp, "%i", target->GetIconValue());
  454. target->SetIcon(val);
  455. break;
  456. }
  457. case SPAWN_SET_VALUE_PREFIX: {
  458. sprintf(tmp, "%s", target->GetPrefixTitle());
  459. target->SetPrefixTitle(value);
  460. client->GetCurrentZone()->SendUpdateTitles(target);
  461. break;
  462. }
  463. case SPAWN_SET_VALUE_SUFFIX: {
  464. sprintf(tmp, "%s", target->GetSuffixTitle());
  465. target->SetSuffixTitle(value);
  466. client->GetCurrentZone()->SendUpdateTitles(target);
  467. break;
  468. }
  469. case SPAWN_SET_VALUE_LASTNAME: {
  470. sprintf(tmp, "%s", target->GetLastName());
  471. target->SetLastName(value);
  472. client->GetCurrentZone()->SendUpdateTitles(target);
  473. break;
  474. }
  475. case SPAWN_SET_VALUE_EXPANSION_FLAG:
  476. case SPAWN_SET_VALUE_HOLIDAY_FLAG: {
  477. // nothing to do must reload spawns
  478. break;
  479. }
  480. case SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL: {
  481. sprintf(tmp, "%i", target->GetMerchantMinLevel());
  482. target->SetMerchantLevelRange(atoul(value), target->GetMerchantMaxLevel());
  483. break;
  484. }
  485. case SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL: {
  486. sprintf(tmp, "%i", target->GetMerchantMaxLevel());
  487. target->SetMerchantLevelRange(target->GetMerchantMinLevel(), atoul(value));
  488. break;
  489. }
  490. case SPAWN_SET_SKIN_COLOR: {
  491. if (target->IsNPC())
  492. {
  493. Seperator* skinsep = new Seperator(value, ' ', 3, 500, true);
  494. if (skinsep->IsNumber(0) && skinsep->IsNumber(1) && skinsep->IsNumber(2))
  495. {
  496. EQ2_Color clr;
  497. clr.red = atoul(skinsep->arg[0]);
  498. clr.green = atoul(skinsep->arg[1]);
  499. clr.blue = atoul(skinsep->arg[2]);
  500. ((Entity*)target)->SetSkinColor(clr);
  501. }
  502. safe_delete(skinsep);
  503. }
  504. break;
  505. }
  506. if(temp_value)
  507. *temp_value = string(tmp);
  508. }
  509. }
  510. else{
  511. switch(type){
  512. case SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL: {
  513. target->SetMerchantLevelRange(atoul(value), target->GetMerchantMaxLevel());
  514. break;
  515. }
  516. case SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL: {
  517. target->SetMerchantLevelRange(target->GetMerchantMinLevel(), atoul(value));
  518. break;
  519. }
  520. case SPAWN_SET_VALUE_EXPANSION_FLAG: {
  521. if (target->GetDatabaseID() > 0)
  522. {
  523. char query[256];
  524. snprintf(query, 256, "update spawn set expansion_flag=%i where id=%i", atoul(value), target->GetDatabaseID());
  525. if (database.RunQuery(query, strnlen(query, 256)))
  526. {
  527. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  528. }
  529. }
  530. break;
  531. }
  532. case SPAWN_SET_VALUE_HOLIDAY_FLAG: {
  533. if (target->GetDatabaseID() > 0)
  534. {
  535. char query[256];
  536. snprintf(query, 256, "update spawn set holiday_flag=%i where id=%i", atoul(value), target->GetDatabaseID());
  537. if (database.RunQuery(query, strnlen(query, 256)))
  538. {
  539. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  540. }
  541. }
  542. break;
  543. }
  544. case SPAWN_SET_VALUE_NAME:{
  545. target->SetName(value);
  546. client->GetCurrentZone()->SendUpdateTitles(target);
  547. break;
  548. }
  549. case SPAWN_SET_VALUE_SUB_TITLE: {
  550. target->SetSubTitle(value);
  551. client->GetCurrentZone()->SendUpdateTitles(target);
  552. break;
  553. }
  554. case SPAWN_SET_VALUE_X_OFFSET:
  555. {
  556. target->SetXOffset(atof(value));
  557. break;
  558. }
  559. case SPAWN_SET_VALUE_Y_OFFSET:
  560. {
  561. target->SetYOffset(atof(value));
  562. break;
  563. }
  564. case SPAWN_SET_VALUE_Z_OFFSET:
  565. {
  566. target->SetZOffset(atof(value));
  567. break;
  568. }
  569. case SPAWN_SET_VALUE_EXPIRE: {
  570. target->SetExpireTime(val);
  571. break;
  572. }
  573. case SPAWN_SET_VALUE_EXPIRE_OFFSET: {
  574. target->SetExpireOffsetTime(val);
  575. break;
  576. }
  577. case SPAWN_SET_VALUE_LEVEL:{
  578. target->SetLevel(val, send_update);
  579. break;
  580. }
  581. case SPAWN_SET_VALUE_DIFFICULTY:{
  582. target->SetEncounterLevel(val, send_update);
  583. break;
  584. }
  585. case SPAWN_SET_VALUE_MODEL_TYPE:{
  586. target->SetModelType(val, send_update);
  587. break;
  588. }
  589. case SPAWN_SET_VALUE_CLASS:{
  590. target->SetAdventureClass(val, send_update);
  591. break;
  592. }
  593. case SPAWN_SET_VALUE_GENDER:{
  594. target->SetGender(val, send_update);
  595. break;
  596. }
  597. case SPAWN_SET_VALUE_SHOW_NAME:{
  598. target->SetShowName(val, send_update);
  599. break;
  600. }
  601. case SPAWN_SET_VALUE_ATTACKABLE:{
  602. target->SetAttackable(val, send_update);
  603. break;
  604. }
  605. case SPAWN_SET_VALUE_SHOW_LEVEL:{
  606. target->SetShowLevel(val, send_update);
  607. break;
  608. }
  609. case SPAWN_SET_VALUE_TARGETABLE:{
  610. target->SetTargetable(val, send_update);
  611. break;
  612. }
  613. case SPAWN_SET_VALUE_SHOW_COMMAND_ICON:{
  614. target->SetShowCommandIcon(val, send_update);
  615. break;
  616. }
  617. case SPAWN_SET_VALUE_HAND_ICON:{
  618. target->SetShowHandIcon(val, send_update);
  619. break;
  620. }
  621. case SPAWN_SET_VALUE_HAIR_TYPE:{
  622. if(target->IsEntity())
  623. ((Entity*)target)->SetHairType(val, send_update);
  624. break;
  625. }
  626. case SPAWN_SET_VALUE_FACIAL_HAIR_TYPE:{
  627. if(target->IsEntity())
  628. ((Entity*)target)->SetHairType(val, send_update);
  629. break;
  630. }
  631. case SPAWN_SET_VALUE_WING_TYPE:{
  632. if(target->IsEntity())
  633. ((Entity*)target)->SetWingType(val, send_update);
  634. break;
  635. }
  636. case SPAWN_SET_VALUE_CHEST_TYPE:{
  637. if(target->IsEntity())
  638. ((Entity*)target)->SetChestType(val, send_update);
  639. break;
  640. }
  641. case SPAWN_SET_VALUE_LEGS_TYPE:{
  642. if(target->IsEntity())
  643. ((Entity*)target)->SetLegsType(val, send_update);
  644. break;
  645. }
  646. case SPAWN_SET_VALUE_SOGA_HAIR_TYPE:{
  647. if(target->IsEntity())
  648. ((Entity*)target)->SetSogaHairType(val, send_update);
  649. break;
  650. }
  651. case SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE:{
  652. if(target->IsEntity())
  653. ((Entity*)target)->SetSogaFacialHairType(val, send_update);
  654. break;
  655. }
  656. case SPAWN_SET_VALUE_SOGA_MODEL_TYPE:{
  657. target->SetSogaModelType(val, send_update);
  658. break;
  659. }
  660. case SPAWN_SET_VALUE_SIZE:{
  661. target->SetSize(val, send_update);
  662. break;
  663. }
  664. case SPAWN_SET_VALUE_HP:{
  665. target->SetHP(val, send_update);
  666. break;
  667. }
  668. case SPAWN_SET_VALUE_POWER:{
  669. target->SetPower(val, send_update);
  670. break;
  671. }
  672. case SPAWN_SET_VALUE_HEROIC:{
  673. target->SetHeroic(val, send_update);
  674. break;
  675. }
  676. case SPAWN_SET_VALUE_RESPAWN:{
  677. target->SetRespawnTime(val);
  678. break;
  679. }
  680. case SPAWN_SET_VALUE_X:{
  681. target->SetX(atof(value), send_update);
  682. target->SetSpawnOrigX(target->GetX());
  683. break;
  684. }
  685. case SPAWN_SET_VALUE_Y:{
  686. target->SetY(atof(value), send_update);
  687. target->SetSpawnOrigY(target->GetY());
  688. break;
  689. }
  690. case SPAWN_SET_VALUE_Z:{
  691. target->SetZ(atof(value), send_update);
  692. target->SetSpawnOrigZ(target->GetZ());
  693. break;
  694. }
  695. case SPAWN_SET_VALUE_HEADING:{
  696. target->SetHeading(atof(value), send_update);
  697. target->SetSpawnOrigHeading(target->GetHeading());
  698. break;
  699. }
  700. case SPAWN_SET_VALUE_COMMAND_PRIMARY:{
  701. ZoneServer* zone = target->GetZone();
  702. if (!zone)
  703. zone = client->GetCurrentZone();
  704. if(zone->GetEntityCommandList(val))
  705. target->SetPrimaryCommands(zone->GetEntityCommandList(val));
  706. target->primary_command_list_id = val;
  707. break;
  708. }
  709. case SPAWN_SET_VALUE_COMMAND_SECONDARY:{
  710. ZoneServer* zone = target->GetZone();
  711. if (!zone)
  712. zone = client->GetCurrentZone();
  713. if (zone->GetEntityCommandList(val))
  714. target->SetSecondaryCommands(zone->GetEntityCommandList(val));
  715. target->secondary_command_list_id = val;
  716. break;
  717. }
  718. case SPAWN_SET_VALUE_VISUAL_STATE:{
  719. target->SetVisualState(val, send_update);
  720. break;
  721. }
  722. case SPAWN_SET_VALUE_ACTION_STATE:{
  723. target->SetActionState(val, send_update);
  724. break;
  725. }
  726. case SPAWN_SET_VALUE_MOOD_STATE:{
  727. target->SetMoodState(val, send_update);
  728. break;
  729. }
  730. case SPAWN_SET_VALUE_INITIAL_STATE:{
  731. target->SetInitialState(val, send_update);
  732. break;
  733. }
  734. case SPAWN_SET_VALUE_ACTIVITY_STATE:{
  735. target->SetActivityStatus(val, send_update);
  736. break;
  737. }
  738. case SPAWN_SET_VALUE_COLLISION_RADIUS:{
  739. target->SetCollisionRadius(val, send_update);
  740. break;
  741. }
  742. case SPAWN_SET_VALUE_FACTION:{
  743. ZoneServer* zone = target->GetZone();
  744. if (!zone)
  745. zone = client->GetCurrentZone();
  746. target->faction_id = val;
  747. zone->RemoveDeadEnemyList(target);
  748. if(target->IsNPC())
  749. zone->AddEnemyList((NPC*)target);
  750. break;
  751. }
  752. case SPAWN_SET_VALUE_DEVICE_ID:{
  753. if (target->IsObject())
  754. ((Object*)target)->SetDeviceID(val);
  755. break;
  756. }
  757. case SPAWN_SET_VALUE_PITCH: {
  758. target->SetPitch(atof(value), send_update);
  759. target->SetSpawnOrigPitch(atof(value));
  760. break;
  761. }
  762. case SPAWN_SET_VALUE_ROLL: {
  763. target->SetRoll(atof(value), send_update);
  764. target->SetSpawnOrigRoll(atof(value));
  765. break;
  766. }
  767. case SPAWN_SET_VALUE_HIDE_HOOD: {
  768. target->SetHideHood(val);
  769. break;
  770. }
  771. case SPAWN_SET_VALUE_EMOTE_STATE: {
  772. target->SetEmoteState(val);
  773. break;
  774. }
  775. case SPAWN_SET_VALUE_ICON: {
  776. target->SetIcon(val);
  777. break;
  778. }
  779. case SPAWN_SET_VALUE_PREFIX: {
  780. target->SetPrefixTitle(value);
  781. client->GetCurrentZone()->SendUpdateTitles(target);
  782. break;
  783. }
  784. case SPAWN_SET_VALUE_SUFFIX: {
  785. target->SetSuffixTitle(value);
  786. client->GetCurrentZone()->SendUpdateTitles(target);
  787. break;
  788. }
  789. case SPAWN_SET_VALUE_LASTNAME: {
  790. target->SetLastName(value);
  791. client->GetCurrentZone()->SendUpdateTitles(target);
  792. break;
  793. }
  794. case SPAWN_SET_VALUE_SPAWN_SCRIPT:{
  795. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  796. if(client){
  797. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  798. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawn_script 'SpawnScripts/example.lua'");
  799. }
  800. return false;
  801. }
  802. else if(!database.UpdateSpawnScriptData(target->GetDatabaseID(), 0, 0, value))
  803. return false;
  804. else{
  805. if(!world.GetSpawnLocationScript(target->GetSpawnLocationID()))
  806. target->SetSpawnScript(value);
  807. }
  808. break;
  809. }
  810. case SPAWN_SET_VALUE_SPAWNLOCATION_SCRIPT:{
  811. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  812. if(client){
  813. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  814. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawnlocation_script 'SpawnScripts/example.lua'");
  815. }
  816. return false;
  817. }
  818. else if(!database.UpdateSpawnScriptData(0, target->GetSpawnLocationID(), 0, value))
  819. return false;
  820. else{
  821. if(!world.GetSpawnEntryScript(target->GetSpawnEntryID()))
  822. target->SetSpawnScript(value);
  823. }
  824. break;
  825. }
  826. case SPAWN_SET_VALUE_SPAWNENTRY_SCRIPT:{
  827. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  828. if(client){
  829. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  830. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawnentry_script 'SpawnScripts/example.lua'");
  831. }
  832. return false;
  833. }
  834. else if(!database.UpdateSpawnScriptData(0, 0, target->GetSpawnEntryID(), value))
  835. return false;
  836. else
  837. target->SetSpawnScript(value);
  838. break;
  839. }
  840. case SPAWN_SET_SKIN_COLOR: {
  841. if (target->IsNPC())
  842. {
  843. Seperator* skinsep = new Seperator(value, ' ', 3, 500, true);
  844. if (skinsep->IsNumber(0) && skinsep->IsNumber(1) && skinsep->IsNumber(2))
  845. {
  846. EQ2_Color clr;
  847. clr.red = atoul(skinsep->arg[0]);
  848. clr.green = atoul(skinsep->arg[1]);
  849. clr.blue = atoul(skinsep->arg[2]);
  850. ((Entity*)target)->SetSkinColor(clr);
  851. Query replaceSkinQuery;
  852. replaceSkinQuery.AddQueryAsync(0, &database, Q_DELETE, "delete from npc_appearance where spawn_id=%u and type='skin_color'", target->GetDatabaseID());
  853. replaceSkinQuery.AddQueryAsync(0, &database, Q_INSERT, "insert into npc_appearance set spawn_id=%u, type='skin_color', red=%u, green=%u, blue=%u", target->GetDatabaseID(), clr.red, clr.green, clr.blue);
  854. }
  855. safe_delete(skinsep);
  856. }
  857. break;
  858. }
  859. }
  860. }
  861. return true;
  862. }
  863. /* The zone object will be NULL if the zone is not currently running. We pass both of these in so we can update
  864. the database fields always and also update the zone in memory if it's running. */
  865. bool Commands::SetZoneCommand(Client* client, int32 zone_id, ZoneServer* zone, int8 type, const char* value) {
  866. if (client && zone_id > 0 && type > 0 && value) {
  867. sint32 int_value = 0;
  868. float float_value = 0;
  869. if (type == ZONE_SET_VALUE_SAFE_X || type == ZONE_SET_VALUE_SAFE_Y || type == ZONE_SET_VALUE_SAFE_Z || type == ZONE_SET_VALUE_UNDERWORLD) {
  870. try {
  871. float_value = atof(value);
  872. }
  873. catch (...) {
  874. client->Message(CHANNEL_COLOR_RED, "Error converting '%s' to a float value", value);
  875. return false;
  876. }
  877. }
  878. 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) {
  879. try {
  880. int_value = atoi(value);
  881. }
  882. catch (...) {
  883. client->Message(CHANNEL_COLOR_RED, "Error converting '%s' to an integer value", value);
  884. return false;
  885. }
  886. }
  887. switch (type) {
  888. case ZONE_SET_VALUE_EXPANSION_ID: {
  889. break;
  890. }
  891. case ZONE_SET_VALUE_NAME: {
  892. if (zone)
  893. zone->SetZoneName(const_cast<char*>(value));
  894. database.SaveZoneInfo(zone_id, "name", value);
  895. break;
  896. }
  897. case ZONE_SET_VALUE_FILE: {
  898. if (zone)
  899. zone->SetZoneFile(const_cast<char*>(value));
  900. database.SaveZoneInfo(zone_id, "file", value);
  901. break;
  902. }
  903. case ZONE_SET_VALUE_DESCRIPTION: {
  904. if (zone)
  905. zone->SetZoneDescription(const_cast<char*>(value));
  906. database.SaveZoneInfo(zone_id, "description", value);
  907. break;
  908. }
  909. case ZONE_SET_VALUE_SAFE_X: {
  910. if (zone)
  911. zone->SetSafeX(float_value);
  912. database.SaveZoneInfo(zone_id, "safe_x", float_value);
  913. break;
  914. }
  915. case ZONE_SET_VALUE_SAFE_Y: {
  916. if (zone)
  917. zone->SetSafeY(float_value);
  918. database.SaveZoneInfo(zone_id, "safe_y", float_value);
  919. break;
  920. }
  921. case ZONE_SET_VALUE_SAFE_Z: {
  922. if (zone)
  923. zone->SetSafeZ(float_value);
  924. database.SaveZoneInfo(zone_id, "safe_z", float_value);
  925. break;
  926. }
  927. case ZONE_SET_VALUE_UNDERWORLD: {
  928. if (zone)
  929. zone->SetUnderWorld(float_value);
  930. database.SaveZoneInfo(zone_id, "underworld", float_value);
  931. break;
  932. }
  933. case ZONE_SET_VALUE_MIN_RECOMMENDED: {
  934. break;
  935. }
  936. case ZONE_SET_VALUE_MAX_RECOMMENDED: {
  937. break;
  938. }
  939. case ZONE_SET_VALUE_ZONE_TYPE: {
  940. break;
  941. }
  942. case ZONE_SET_VALUE_ALWAYS_LOADED: {
  943. if (zone)
  944. zone->SetAlwaysLoaded(int_value == 1);
  945. database.SaveZoneInfo(zone_id, "always_loaded", int_value);
  946. break;
  947. }
  948. case ZONE_SET_VALUE_CITY_ZONE: {
  949. if (zone)
  950. zone->SetCityZone(int_value == 1);
  951. database.SaveZoneInfo(zone_id, "city_zone", int_value);
  952. break;
  953. }
  954. case ZONE_SET_VALUE_WEATHER_ALLOWED: {
  955. if (zone)
  956. zone->SetWeatherAllowed(int_value == 1);
  957. database.SaveZoneInfo(zone_id, "weather_allowed", int_value);
  958. break;
  959. }
  960. case ZONE_SET_VALUE_MIN_STATUS: {
  961. if (zone)
  962. zone->SetMinimumStatus(int_value);
  963. database.SaveZoneInfo(zone_id, "min_status", int_value);
  964. break;
  965. }
  966. case ZONE_SET_VALUE_MIN_LEVEL: {
  967. if (zone)
  968. zone->SetMinimumLevel(int_value);
  969. database.SaveZoneInfo(zone_id, "min_level", int_value);
  970. break;
  971. }
  972. case ZONE_SET_VALUE_MAX_LEVEL: {
  973. if (zone)
  974. zone->SetMaximumLevel(int_value);
  975. database.SaveZoneInfo(zone_id, "max_level", int_value);
  976. break;
  977. }
  978. case ZONE_SET_VALUE_START_ZONE: {
  979. database.SaveZoneInfo(zone_id, "start_zone", int_value);
  980. break;
  981. }
  982. case ZONE_SET_VALUE_INSTANCE_TYPE: {
  983. if (zone)
  984. zone->SetInstanceType(int_value);
  985. database.SaveZoneInfo(zone_id, "instance_type", int_value);
  986. break;
  987. }
  988. case ZONE_SET_VALUE_DEFAULT_REENTER_TIME: {
  989. if (zone)
  990. zone->SetDefaultReenterTime(int_value);
  991. database.SaveZoneInfo(zone_id, "default_reenter_time", int_value);
  992. break;
  993. }
  994. case ZONE_SET_VALUE_DEFAULT_RESET_TIME: {
  995. if (zone)
  996. zone->SetDefaultResetTime(int_value);
  997. database.SaveZoneInfo(zone_id, "default_reset_time", int_value);
  998. break;
  999. }
  1000. case ZONE_SET_VALUE_DEFAULT_LOCKOUT_TIME: {
  1001. if (zone)
  1002. zone->SetDefaultLockoutTime(int_value);
  1003. database.SaveZoneInfo(zone_id, "default_lockout_time", int_value);
  1004. break;
  1005. }
  1006. case ZONE_SET_VALUE_FORCE_GROUP_TO_ZONE: {
  1007. if (zone)
  1008. zone->SetForceGroupZoneOption(int_value);
  1009. database.SaveZoneInfo(zone_id, "force_group_to_zone", int_value);
  1010. break;
  1011. }
  1012. case ZONE_SET_VALUE_LUA_SCRIPT: {
  1013. if (lua_interface && lua_interface->GetZoneScript(value) == 0) {
  1014. client->Message(CHANNEL_COLOR_RED, "Invalid Zone Script file. Be sure you give the absolute path.");
  1015. client->Message(CHANNEL_COLOR_RED, "Example: /zone set lua_script 'ZoneScripts/QueensColony.lua'");
  1016. return false;
  1017. }
  1018. else {
  1019. world.AddZoneScript(zone_id, const_cast<char*>(value));
  1020. database.SaveZoneInfo(zone_id, "lua_script", value);
  1021. }
  1022. break;
  1023. }
  1024. case ZONE_SET_VALUE_SHUTDOWN_TIMER: {
  1025. if (zone)
  1026. zone->SetShutdownTimer(int_value);
  1027. database.SaveZoneInfo(zone_id, "shutdown_timer", int_value);
  1028. break;
  1029. }
  1030. case ZONE_SET_VALUE_ZONE_MOTD: {
  1031. if (zone)
  1032. zone->SetZoneMOTD(string(value));
  1033. database.SaveZoneInfo(zone_id, "zone_motd", value);
  1034. break;
  1035. }
  1036. default: {
  1037. client->Message(CHANNEL_COLOR_RED, "Invalid zone attribute %i", type);
  1038. return false;
  1039. }
  1040. }
  1041. }
  1042. else {
  1043. if (client)
  1044. client->SimpleMessage(CHANNEL_COLOR_RED, "An error occured saving new zone data.");
  1045. return false;
  1046. }
  1047. return true;
  1048. }
  1049. void Commands::Process(int32 index, EQ2_16BitString* command_parms, Client* client, Spawn* targetOverride) {
  1050. if (index >= remote_commands->commands.size()) {
  1051. LogWrite(COMMAND__ERROR, 0, "Command", "Error, command handler of %u was requested, but max handler is %u", index, remote_commands->commands.size());
  1052. return;
  1053. }
  1054. Spawn* cmdTarget = targetOverride ? targetOverride : client->GetPlayer()->GetTarget();
  1055. EQ2_RemoteCommandString* parent_command = 0;
  1056. EQ2_RemoteCommandString* command = &remote_commands->commands[index];
  1057. Seperator* sep = 0;
  1058. if (command_parms->size > 0) {
  1059. sep = new Seperator(command_parms->data.c_str(), ' ', 10, 500, true);
  1060. if (sep && sep->arg[0] && remote_commands->validSubCommand(command->command.data, string(sep->arg[0]))) {
  1061. parent_command = command;
  1062. command = &(remote_commands->subcommands[command->command.data][string(sep->arg[0])]);
  1063. safe_delete(sep);
  1064. if (command_parms->data.length() > (command->command.data.length() + 1))
  1065. sep = new Seperator(command_parms->data.c_str() + (command->command.data.length() + 1), ' ', 10, 500, true);
  1066. LogWrite(COMMAND__DEBUG, 1, "Command", "Handler: %u, COMMAND: '%s', SUBCOMMAND: '%s'", index, parent_command->command.data.c_str(), command->command.data.c_str());
  1067. }
  1068. else
  1069. LogWrite(COMMAND__DEBUG, 1, "Command", "Handler: %u, COMMAND: '%s'", index, command->command.data.c_str());
  1070. }
  1071. int ndx = 0;
  1072. if (command->required_status > client->GetAdminStatus())
  1073. {
  1074. 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());
  1075. safe_delete(sep);
  1076. client->SimpleMessage(3, "Error: Your status is insufficient for this command.");
  1077. return;
  1078. }
  1079. Player* player = client->GetPlayer();
  1080. LogWrite(COMMAND__DEBUG, 0, "Command", "Player '%s' (%u), Command: %s", player->GetName(), client->GetAccountID(), command->command.data.c_str());
  1081. switch (command->handler) {
  1082. case COMMAND_RELOAD: {
  1083. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reload commands:");
  1084. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload structs");
  1085. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload items");
  1086. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload luasystem");
  1087. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spawnscripts");
  1088. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spells");
  1089. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload quests");
  1090. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spawns");
  1091. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload groundspawns");
  1092. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload zonescripts");
  1093. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload entity_commands");
  1094. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload factions");
  1095. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload mail");
  1096. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload guilds");
  1097. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload locations");
  1098. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload rules");
  1099. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload transporters");
  1100. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload startabilities");
  1101. break;
  1102. }
  1103. case COMMAND_RELOADSTRUCTS: {
  1104. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Structs...");
  1105. world.SetReloadingSubsystem("Structs");
  1106. configReader.ReloadStructs();
  1107. world.RemoveReloadingSubSystem("Structs");
  1108. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1109. break;
  1110. }
  1111. case COMMAND_RELOAD_QUESTS: {
  1112. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Quests...");
  1113. world.SetReloadingSubsystem("Quests");
  1114. master_quest_list.Reload();
  1115. client_list.ReloadQuests();
  1116. zone_list.ReloadClientQuests();
  1117. world.RemoveReloadingSubSystem("Quests");
  1118. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1119. break;
  1120. }
  1121. case COMMAND_RELOAD_SPAWNS: {
  1122. client->GetCurrentZone()->ReloadSpawns();
  1123. break;
  1124. }
  1125. case COMMAND_RELOAD_SPELLS: {
  1126. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spells...");
  1127. world.SetReloadingSubsystem("Spells");
  1128. zone_list.DeleteSpellProcess();
  1129. master_spell_list.Reload();
  1130. if (lua_interface)
  1131. lua_interface->ReloadSpells();
  1132. zone_list.LoadSpellProcess();
  1133. world.RemoveReloadingSubSystem("Spells");
  1134. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1135. break;
  1136. }
  1137. case COMMAND_RELOAD_GROUNDSPAWNS: {
  1138. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Groundspawn Entries...");
  1139. world.SetReloadingSubsystem("GroundSpawns");
  1140. client->GetCurrentZone()->DeleteGroundSpawnItems();
  1141. client->GetCurrentZone()->LoadGroundSpawnEntries();
  1142. world.RemoveReloadingSubSystem("GroundSpawns");
  1143. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1144. break;
  1145. }
  1146. case COMMAND_RELOAD_ZONESCRIPTS: {
  1147. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Zone Scripts...");
  1148. world.SetReloadingSubsystem("ZoneScripts");
  1149. world.ResetZoneScripts();
  1150. database.LoadZoneScriptData();
  1151. if (lua_interface)
  1152. lua_interface->DestroyZoneScripts();
  1153. world.RemoveReloadingSubSystem("ZoneScripts");
  1154. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1155. break;
  1156. }
  1157. case COMMAND_RELOAD_ENTITYCOMMANDS: {
  1158. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Entity Commands...");
  1159. world.SetReloadingSubsystem("EntityCommands");
  1160. client->GetCurrentZone()->ClearEntityCommands();
  1161. database.LoadEntityCommands(client->GetCurrentZone());
  1162. world.RemoveReloadingSubSystem("EntityCommands");
  1163. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1164. break;
  1165. }
  1166. case COMMAND_RELOAD_FACTIONS: {
  1167. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Factions...");
  1168. world.SetReloadingSubsystem("Factions");
  1169. master_faction_list.Clear();
  1170. database.LoadFactionList();
  1171. world.RemoveReloadingSubSystem("Factions");
  1172. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1173. break;
  1174. }
  1175. case COMMAND_RELOAD_MAIL: {
  1176. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Mail...");
  1177. zone_list.ReloadMail();
  1178. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1179. break;
  1180. }
  1181. case COMMAND_RELOAD_GUILDS: {
  1182. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Guilds...");
  1183. world.ReloadGuilds();
  1184. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1185. break;
  1186. }
  1187. case COMMAND_RELOAD_LOCATIONS: {
  1188. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Locations...");
  1189. client->GetPlayer()->GetZone()->RemoveLocationGrids();
  1190. database.LoadLocationGrids(client->GetPlayer()->GetZone());
  1191. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1192. break;
  1193. }
  1194. case COMMAND_RELOAD_RULES: {
  1195. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Rules...");
  1196. database.LoadRuleSets(true);
  1197. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1198. break;
  1199. }
  1200. case COMMAND_RELOAD_TRANSPORTERS: {
  1201. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Transporters in your current zone...");
  1202. database.LoadTransporters(client->GetCurrentZone());
  1203. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1204. break;
  1205. }
  1206. case COMMAND_RELOAD_STARTABILITIES: {
  1207. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Starting Skills/Spells...");
  1208. world.PurgeStartingLists();
  1209. world.LoadStartingLists();
  1210. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1211. break;
  1212. }
  1213. case COMMAND_READ: {
  1214. if (sep && sep->arg[1][0] && sep->IsNumber(1)) {
  1215. if (strcmp(sep->arg[0], "read") == 0) {
  1216. int32 item_index = atol(sep->arg[1]);
  1217. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  1218. if (item) {
  1219. Spawn* spawn = cmdTarget;
  1220. client->SendShowBook(client->GetPlayer(), item->name, item->book_pages);
  1221. break;
  1222. }
  1223. }
  1224. }
  1225. break;
  1226. }
  1227. case COMMAND_USEABILITY:{
  1228. if (sep && sep->arg[0][0] && sep->IsNumber(0)) {
  1229. if (client->GetPlayer()->GetHP() == 0) {
  1230. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot do that right now.");
  1231. }
  1232. else {
  1233. int32 spell_id = atoul(sep->arg[0]);
  1234. int8 spell_tier = 0;
  1235. if (sep->arg[1][0] && sep->IsNumber(1))
  1236. spell_tier = atoi(sep->arg[1]);
  1237. else
  1238. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  1239. if (!spell_tier)
  1240. spell_tier = 1;
  1241. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  1242. if (spell) {
  1243. 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)
  1244. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), cmdTarget, true, true);
  1245. else
  1246. {
  1247. if (cmdTarget)
  1248. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), cmdTarget);
  1249. else
  1250. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  1251. }
  1252. }
  1253. }
  1254. }
  1255. else if (cmdTarget && cmdTarget->IsWidget())
  1256. {
  1257. Widget* widget = (Widget*)cmdTarget;
  1258. widget->HandleUse(client, "use", WIDGET_TYPE_DOOR);
  1259. }
  1260. else
  1261. {
  1262. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /useability {spell_id} [spell_tier]");
  1263. }
  1264. break;
  1265. }
  1266. case COMMAND_INFO:{
  1267. if(sep && sep->arg[1][0] && sep->IsNumber(1)){
  1268. if(strcmp(sep->arg[0], "inventory") == 0){
  1269. int32 item_index = atol(sep->arg[1]);
  1270. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  1271. if(item){
  1272. if (item->IsCollectable() && client->SendCollectionsForItem(item))
  1273. break;
  1274. EQ2Packet* app = item->serialize(client->GetVersion(), (!item->GetItemScript() || !lua_interface), client->GetPlayer());
  1275. //DumpPacket(app);
  1276. client->QueuePacket(app);
  1277. if(item->GetItemScript() && lua_interface)
  1278. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  1279. else if(item->generic_info.offers_quest_id > 0){ //leave the current functionality in place if it doesnt have an item script
  1280. Quest* quest = master_quest_list.GetQuest(item->generic_info.offers_quest_id);
  1281. if(quest && client->GetPlayer()->GetCompletedQuest(item->generic_info.offers_quest_id) == 0 && client->GetPlayer()->GetQuest(item->generic_info.offers_quest_id) == 0)
  1282. client->AddPendingQuest(quest);
  1283. }
  1284. }
  1285. else
  1286. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Index: %u", item_index);
  1287. }
  1288. else if(strcmp(sep->arg[0], "equipment") == 0){
  1289. int32 item_index = atol(sep->arg[1]);
  1290. Item* item = client->GetPlayer()->GetEquipmentList()->GetItem(item_index);
  1291. if(item){
  1292. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1293. client->QueuePacket(app);
  1294. if(item->GetItemScript() && lua_interface)
  1295. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  1296. }
  1297. else
  1298. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Index: %u", item_index);
  1299. }
  1300. 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){
  1301. int32 item_id = atoul(sep->arg[1]);
  1302. Item* item = master_item_list.GetItem(item_id);
  1303. if(item){
  1304. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1305. client->QueuePacket(app);
  1306. }
  1307. else
  1308. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Item ID: %u", item_id);
  1309. }
  1310. else if (strcmp(sep->arg[0], "spell") == 0) {
  1311. sint32 spell_id = atol(sep->arg[1]);
  1312. int8 tier = atoi(sep->arg[3]);
  1313. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, tier, client, true, 0x2A);
  1314. if (outapp)
  1315. client->QueuePacket(outapp);
  1316. else
  1317. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  1318. }
  1319. else if (strcmp(sep->arg[0], "achievement") == 0) {
  1320. sint32 spell_id = atol(sep->arg[2]);
  1321. int8 group = atoi(sep->arg[1]);
  1322. AltAdvanceData* data = 0;
  1323. SpellBookEntry* spellentry = 0;
  1324. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  1325. LogWrite(COMMAND__ERROR, 0, "Command", "AA Spell ID and/or Tier, ID: %u, Group: %i", spell_id, group);
  1326. EQ2Packet* outapp = master_spell_list.GetAASpellPacket(spell_id, tier, client, true, 0x45);
  1327. if (outapp)
  1328. client->QueuePacket(outapp);
  1329. else
  1330. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, group);
  1331. }
  1332. else if (strcmp(sep->arg[0], "spellbook") == 0) {
  1333. sint32 spell_id = atol(sep->arg[1]);
  1334. int32 tier = atoi(sep->arg[2]);
  1335. if (tier > 255) {
  1336. SpellBookEntry* ent = client->GetPlayer()->GetSpellBookSpell(spell_id);
  1337. if (ent)
  1338. tier = ent->tier;
  1339. }
  1340. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, (int8)tier, client, true, 0x2A);
  1341. if (outapp)
  1342. client->QueuePacket(outapp);
  1343. else
  1344. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  1345. }
  1346. else if (strcmp(sep->arg[0], "recipe") == 0) {
  1347. sint32 recipe_id = atol(sep->arg[1]);
  1348. EQ2Packet* outapp = master_recipe_list.GetRecipePacket(recipe_id, client, true, 0x2C);
  1349. if(outapp)
  1350. client->QueuePacket(outapp);
  1351. else
  1352. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Recipe ID: %u", recipe_id);
  1353. }
  1354. else if (strcmp(sep->arg[0], "maintained") ==0) {
  1355. int32 slot = atol(sep->arg[1]);
  1356. int32 spell_id = atol(sep->arg[2]);
  1357. LogWrite(COMMAND__DEBUG, 5, "Command", "Unknown Spell ID - Slot: %u unknown: %u", slot, spell_id);
  1358. //int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  1359. MaintainedEffects* info = client->GetPlayer()->GetMaintainedSpellBySlot(slot);
  1360. EQ2Packet* outapp = master_spell_list.GetSpellPacket(info->spell_id, info->tier, client, true, 0x00);
  1361. if(outapp)
  1362. client->QueuePacket(outapp);
  1363. else
  1364. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID: %u", spell_id);
  1365. }
  1366. else if (strcmp(sep->arg[0], "effect") == 0) {
  1367. int32 spell_id = atol(sep->arg[1]);
  1368. LogWrite(COMMAND__DEBUG, 5, "Command", "Unknown Spell ID: %u", spell_id);
  1369. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  1370. int8 type = 0;
  1371. if (client->GetVersion() <= 546)
  1372. type = 1;
  1373. EQ2Packet* outapp = master_spell_list.GetSpecialSpellPacket(spell_id, tier, client, true, type);
  1374. if (outapp){
  1375. client->QueuePacket(outapp);
  1376. }
  1377. else
  1378. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID: %u", spell_id);
  1379. }
  1380. }
  1381. else if (sep && strcmp(sep->arg[0], "overflow") == 0) {
  1382. Item* item = player->item_list.GetOverflowItem();
  1383. if(item) {
  1384. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1385. client->QueuePacket(app);
  1386. }
  1387. else
  1388. LogWrite(COMMAND__ERROR, 0,"Command", "Unable to retrieve an overflow item.");
  1389. }
  1390. else
  1391. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /info {inventory|equipment|spell} {id}");
  1392. break;
  1393. }
  1394. case COMMAND_USE_EQUIPPED_ITEM:{
  1395. if (sep && sep->arg[0] && sep->IsNumber(0)){
  1396. int32 slot_id = atoul(sep->arg[0]);
  1397. Item* item = player->GetEquipmentList()->GetItem(slot_id);
  1398. if (item && item->generic_info.usable && item->GetItemScript())
  1399. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player);
  1400. }
  1401. break;
  1402. }
  1403. case COMMAND_USE_ITEM: {
  1404. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  1405. int32 item_index = atoul(sep->arg[0]);
  1406. Item* item = player->item_list.GetItemFromIndex(item_index);
  1407. if (item && item->GetItemScript()) {
  1408. if (item->generic_info.max_charges == 0 || item->generic_info.max_charges == 0xFFFF)
  1409. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player);
  1410. else {
  1411. if (item->generic_info.display_charges > 0) {
  1412. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player);
  1413. item->generic_info.display_charges -= 1;
  1414. item->save_needed = true;
  1415. client->QueuePacket(item->serialize(client->GetVersion(), false, client->GetPlayer()));
  1416. }
  1417. else
  1418. LogWrite(PLAYER__ERROR, 0, "Command", "%s: Item %s (%i) attempted to be used, however display_charges is 0.", client->GetPlayer()->GetName(), item->name.c_str(), item->details.item_id);
  1419. }
  1420. }
  1421. }
  1422. break;
  1423. }
  1424. case COMMAND_SCRIBE_SCROLL_ITEM: {
  1425. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  1426. Item* item = player->item_list.GetItemFromUniqueID(atoul(sep->arg[0]));
  1427. if (item) {
  1428. LogWrite(ITEM__DEBUG, 0, "Items", "ITEM ID: %u", item->details.item_id);
  1429. if(item->generic_info.item_type == 6) {
  1430. Spell* spell = master_spell_list.GetSpell(item->skill_info->spell_id, item->skill_info->spell_tier);
  1431. int8 old_slot = 0;
  1432. if (spell) {
  1433. if (!player->HasSpell(spell->GetSpellID(), spell->GetSpellTier(), true)) {
  1434. old_slot = player->GetSpellSlot(spell->GetSpellID());
  1435. player->RemoveSpellBookEntry(spell->GetSpellID());
  1436. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  1437. player->UnlockSpell(spell);
  1438. client->SendSpellUpdate(spell);
  1439. database.DeleteItem(client->GetCharacterID(), item, 0);
  1440. player->item_list.RemoveItem(item, true);
  1441. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  1442. client->QueuePacket(player->SendInventoryUpdate(client->GetVersion()));
  1443. }
  1444. }
  1445. else
  1446. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown spell ID: %u and tier: %u", item->skill_info->spell_id, item->skill_info->spell_tier);
  1447. }
  1448. else if(item->generic_info.item_type == 7){
  1449. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Scribing recipe book %s (%u) for player %s.", item->name.c_str(), item->details.item_id, player->GetName());
  1450. Recipe* recipe_book = new Recipe(master_recipebook_list.GetRecipeBooks(item->details.item_id));
  1451. // if valid recipe book and the player doesn't have it
  1452. if (recipe_book && recipe_book->GetLevel() > client->GetPlayer()->GetTSLevel()) {
  1453. client->Message(CHANNEL_NARRATIVE, "Your tradeskill level is not high enough to scribe this book.");
  1454. safe_delete(recipe_book);
  1455. }
  1456. else if (recipe_book && !(client->GetPlayer()->GetRecipeBookList()->HasRecipeBook(item->details.item_id))) {
  1457. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Valid recipe book that the player doesn't have");
  1458. // Add recipe book to the players list
  1459. client->GetPlayer()->GetRecipeBookList()->AddRecipeBook(recipe_book);
  1460. // Get a list of all recipes this book contains
  1461. vector<Recipe*>* book_recipes = master_recipe_list.GetRecipes(recipe_book->GetBookName());
  1462. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "%i recipes found for %s book", book_recipes->size(), recipe_book->GetBookName());
  1463. // Create the packet to send to update the players recipe list
  1464. PacketStruct* packet = 0;
  1465. if (client->GetRecipeListSent()) {
  1466. packet = configReader.getStruct("WS_RecipeList", client->GetVersion());
  1467. if (packet)
  1468. packet->setArrayLengthByName("num_recipes", book_recipes->size());
  1469. }
  1470. // loop through the list
  1471. vector<Recipe*>::iterator itr;
  1472. int16 i = 0;
  1473. for (itr = book_recipes->begin(); itr != book_recipes->end(); itr++) {
  1474. // check to see if the player already has this recipe some how
  1475. if (!client->GetPlayer()->GetRecipeList()->GetRecipe((*itr)->GetID())) {
  1476. // Player doesn't already have this recipe so lets add it
  1477. Recipe* recipe = new Recipe(master_recipe_list.GetRecipe((*itr)->GetID()));
  1478. client->GetPlayer()->GetRecipeList()->AddRecipe(recipe);
  1479. database.SavePlayerRecipe(client->GetPlayer(), recipe->GetID());
  1480. client->Message(CHANNEL_NARRATIVE, "Recipe: \"%s\" put in recipe book.", recipe->GetName());
  1481. if (packet && client->GetRecipeListSent()) {
  1482. packet->setArrayDataByName("id", recipe->GetID(), i);
  1483. packet->setArrayDataByName("tier", recipe->GetTier(), i);
  1484. packet->setArrayDataByName("level", recipe->GetLevel(), i);
  1485. packet->setArrayDataByName("icon", recipe->GetIcon(), i);
  1486. packet->setArrayDataByName("classes", recipe->GetClasses(), i);
  1487. packet->setArrayDataByName("skill", recipe->GetSkill(), i);
  1488. packet->setArrayDataByName("technique", recipe->GetTechnique(), i);
  1489. packet->setArrayDataByName("knowledge", recipe->GetKnowledge(), i);
  1490. packet->setArrayDataByName("unknown2", recipe->GetUnknown2(), i);
  1491. packet->setArrayDataByName("recipe_name", recipe->GetName(), i);
  1492. packet->setArrayDataByName("recipe_book", recipe->GetBook(), i);
  1493. packet->setArrayDataByName("unknown3", recipe->GetUnknown3(), i);
  1494. i++;
  1495. }
  1496. }
  1497. }
  1498. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Done adding recipes");
  1499. database.SavePlayerRecipeBook(client->GetPlayer(), recipe_book->GetBookID());
  1500. database.DeleteItem(client->GetCharacterID(), item, 0);
  1501. client->GetPlayer()->item_list.RemoveItem(item, true);
  1502. client->QueuePacket(client->GetPlayer()->SendInventoryUpdate(client->GetVersion()));
  1503. if (packet && client->GetRecipeListSent())
  1504. client->QueuePacket(packet->serialize());
  1505. safe_delete(packet);
  1506. }
  1507. else {
  1508. if (recipe_book)
  1509. client->Message(CHANNEL_NARRATIVE, "You have already learned all you can from this item.");
  1510. safe_delete(recipe_book);
  1511. }
  1512. }
  1513. }
  1514. else
  1515. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown unique item ID: %s", sep->arg[0]);
  1516. }
  1517. break;
  1518. }
  1519. case COMMAND_SUMMONITEM: {
  1520. if (sep && sep->IsNumber(0)) {
  1521. int32 item_id = atol(sep->arg[0]);
  1522. int32 quantity = 1;
  1523. if (sep->arg[1] && sep->IsNumber(1))
  1524. quantity = atoi(sep->arg[1]);
  1525. if (sep->arg[2] && strncasecmp(sep->arg[2], "bank", 4) == 0) {
  1526. client->AddItemToBank(item_id,quantity);
  1527. }
  1528. else {
  1529. client->AddItem(item_id, quantity);
  1530. }
  1531. }
  1532. else {
  1533. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} [quantity] or");
  1534. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} {quantity} [location] where location = bank");
  1535. }
  1536. break;
  1537. }
  1538. case COMMAND_COLLECTION_ADDITEM: {
  1539. // takes 2 params: collection_id, slot
  1540. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  1541. Item *item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(atoul(sep->arg[1]));
  1542. if (item)
  1543. client->HandleCollectionAddItem(atoul(sep->arg[0]), item);
  1544. else
  1545. 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]));
  1546. }
  1547. else
  1548. LogWrite(COLLECTION__ERROR, 0, "Collect", "Received command 'COMMAND_COLLECTION_ADDITEM' with unhandeled argument types");
  1549. break;
  1550. }
  1551. case COMMAND_COLLECTION_FILTER_MATCHITEM: {
  1552. // takes 1 param: slot
  1553. printf("COMMAND_COLLECTION_FILTER_MATCHITEM:\n");
  1554. int i = 0;
  1555. while (sep->arg[i] && strlen(sep->arg[i]) > 0) {
  1556. printf("\t%u: %s\n", i, sep->arg[i]);
  1557. i++;
  1558. }
  1559. break;
  1560. }
  1561. case COMMAND_WAYPOINT: {
  1562. bool success = false;
  1563. if (sep && sep->IsNumber(0) && sep->IsNumber(1) && sep->IsNumber(2)) {
  1564. if (!client->ShowPathToTarget(atof(sep->arg[0]), atof(sep->arg[1]), atof(sep->arg[2]), 0))
  1565. client->Message(CHANNEL_COLOR_RED, "Invalid coordinates given");
  1566. }
  1567. else {
  1568. client->ClearWaypoint();
  1569. client->Message(CHANNEL_COLOR_YELLOW, "Usage: /waypoint x y z");
  1570. }
  1571. break;
  1572. }
  1573. case COMMAND_WHO:{
  1574. const char* who = 0;
  1575. if(sep && sep->arg[0]){
  1576. //cout << "Who query: \n";
  1577. who = sep->argplus[0];
  1578. //cout << who << endl;
  1579. }
  1580. zone_list.ProcessWhoQuery(who, client);
  1581. break;
  1582. }
  1583. case COMMAND_SELECT_JUNCTION:{
  1584. LogWrite(MISC__TODO, 1, "TODO", "For access/travel selections (i.e. Mariner Bells, Player Death Window, etc.)\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1585. int32 choice = 0;
  1586. if(sep && sep->arg[0] && sep->IsNumber(0))
  1587. choice = atoul(sep->arg[0]);
  1588. if(client->GetPlayer()->GetHP() == 0){ //dead and this is a revive request
  1589. client->HandlePlayerRevive(choice);
  1590. }
  1591. break;
  1592. }
  1593. case COMMAND_SPAWN_MOVE: {
  1594. if (cmdTarget && cmdTarget->IsPlayer() == false) {
  1595. PacketStruct* packet = configReader.getStruct("WS_MoveObjectMode", client->GetVersion());
  1596. if (packet) {
  1597. float unknown2_3 = 0;
  1598. int8 placement_mode = 0;
  1599. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::DEFAULT);
  1600. if (sep && sep->arg[0][0]) {
  1601. if (strcmp(sep->arg[0], "wall") == 0) {
  1602. placement_mode = 2;
  1603. unknown2_3 = 150;
  1604. }
  1605. else if (strcmp(sep->arg[0], "ceiling") == 0)
  1606. placement_mode = 1;
  1607. else if (strcmp(sep->arg[0], "openheading") == 0 && cmdTarget->IsWidget())
  1608. {
  1609. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "[PlacementMode] WIDGET OPEN HEADING MODE");
  1610. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::OPEN_HEADING);
  1611. }
  1612. else if (strcmp(sep->arg[0], "closeheading") == 0 && cmdTarget->IsWidget())
  1613. {
  1614. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "[PlacementMode] WIDGET CLOSE HEADING MODE");
  1615. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::CLOSE_HEADING);
  1616. }
  1617. else if (strcmp(sep->arg[0], "myloc") == 0)
  1618. {
  1619. if (cmdTarget->GetSpawnLocationPlacementID() < 1) {
  1620. client->Message(CHANNEL_COLOR_YELLOW, "[PlacementMode] Spawn %s cannot be moved it is not assigned a spawn location placement id.", cmdTarget->GetName());
  1621. safe_delete(packet);
  1622. break;
  1623. }
  1624. cmdTarget->SetX(client->GetPlayer()->GetX(), true);
  1625. cmdTarget->SetY(client->GetPlayer()->GetY(), true);
  1626. cmdTarget->SetZ(client->GetPlayer()->GetZ(), true);
  1627. cmdTarget->SetHeading(client->GetPlayer()->GetHeading(), true);
  1628. if (database.UpdateSpawnLocationSpawns(cmdTarget))
  1629. client->Message(CHANNEL_COLOR_YELLOW, "[PlacementMode] Spawn %s placed at your location. Updated spawn_location_placement for spawn.", cmdTarget->GetName());
  1630. safe_delete(packet);
  1631. break;
  1632. }
  1633. }
  1634. packet->setDataByName("placement_mode", placement_mode);
  1635. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget));
  1636. packet->setDataByName("model_type", cmdTarget->GetModelType());
  1637. packet->setDataByName("unknown", 1); //size
  1638. packet->setDataByName("unknown2", 1); //size 2
  1639. packet->setDataByName("unknown2", .5, 1); //size 3
  1640. packet->setDataByName("unknown2", 3, 2);
  1641. packet->setDataByName("unknown2", unknown2_3, 3);
  1642. packet->setDataByName("max_distance", 500);
  1643. packet->setDataByName("CoEunknown", 0xFFFFFFFF);
  1644. client->QueuePacket(packet->serialize());
  1645. safe_delete(packet);
  1646. }
  1647. }
  1648. else {
  1649. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /spawn move (wall OR ceiling)");
  1650. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Moves a spawn anywhere you like. Optionally wall/ceiling can be provided to place wall/ceiling items.");
  1651. }
  1652. break;
  1653. }
  1654. case COMMAND_HAIL:{
  1655. Spawn* spawn = cmdTarget;
  1656. if(spawn && spawn->GetTargetable())
  1657. {
  1658. char tmp[75] = {0};
  1659. sprintf(tmp, "Hail, %s", spawn->GetName());
  1660. bool show_bubble = true;
  1661. if (spawn->IsNPC())
  1662. show_bubble = false;
  1663. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp, HEAR_SPAWN_DISTANCE, 0, show_bubble);
  1664. if(spawn->IsPlayer() == false && spawn->GetDistance(client->GetPlayer()) < 30){
  1665. if(spawn->IsNPC() && ((NPC*)spawn)->EngagedInCombat())
  1666. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED_BUSY, client->GetPlayer());
  1667. else
  1668. spawn->ProcessMovement();
  1669. LogWrite(MISC__TODO, 0, "Check", "ProcessMovement has been called");
  1670. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED, client->GetPlayer());
  1671. }
  1672. }
  1673. else {
  1674. string tmp = "Hail";
  1675. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp.c_str(), HEAR_SPAWN_DISTANCE, 0, true);
  1676. }
  1677. break;
  1678. }
  1679. case COMMAND_SAY:{
  1680. if (sep && sep->arg[0][0]) {
  1681. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, sep->argplus[0], HEAR_SPAWN_DISTANCE);
  1682. if (cmdTarget && !(cmdTarget->IsPlayer()))
  1683. client->GetCurrentZone()->CallSpawnScript(cmdTarget, SPAWN_SCRIPT_HEAR_SAY, client->GetPlayer(), sep->argplus[0]);
  1684. }
  1685. else
  1686. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /say {message}");
  1687. break;
  1688. }
  1689. case COMMAND_TELL:{
  1690. if(sep && sep->arg[0] && sep->argplus[1]){
  1691. if(!zone_list.HandleGlobalChatMessage(client, sep->arg[0], CHANNEL_PRIVATE_TELL, sep->argplus[1]))
  1692. client->Message(CHANNEL_COLOR_RED,"Unable to find client %s",sep->arg[0]);
  1693. }else
  1694. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /tell {character_name} {message}");
  1695. break;
  1696. }
  1697. case COMMAND_SHOUT:{
  1698. if(sep && sep->arg[0][0])
  1699. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SHOUT, sep->argplus[0]);
  1700. else
  1701. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /shout {message}");
  1702. break;
  1703. }
  1704. case COMMAND_AUCTION:{
  1705. if(sep && sep->arg[0][0])
  1706. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_AUCTION, sep->argplus[0]);
  1707. else
  1708. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /auction {message}");
  1709. break;
  1710. }
  1711. case COMMAND_OOC:{
  1712. //For now ooc will be the global chat channel, eventually when we create more channels we will create a global chat channel
  1713. if(sep && sep->arg[0][0])
  1714. zone_list.HandleGlobalChatMessage(client, 0, CHANNEL_OUT_OF_CHARACTER, sep->argplus[0]);
  1715. else
  1716. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /ooc {message}");
  1717. break;
  1718. }
  1719. case COMMAND_EMOTE:{
  1720. if(sep && sep->arg[0][0])
  1721. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_EMOTE, sep->argplus[0]);
  1722. else
  1723. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /emote {action}");
  1724. break;
  1725. }
  1726. case COMMAND_RACE:{
  1727. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  1728. if(sep->arg[1][0] && sep->IsNumber(1)){
  1729. client->GetPlayer()->GetInfoStruct()->race = atoi(sep->arg[1]);
  1730. client->GetPlayer()->SetRace(atoi(sep->arg[1]));
  1731. client->UpdateTimeStampFlag ( RACE_UPDATE_FLAG );
  1732. client->GetPlayer()->SetCharSheetChanged(true);
  1733. }
  1734. client->GetPlayer()->SetModelType(atoi(sep->arg[0]));
  1735. //EQ2Packet* outapp = client->GetPlayer()->spawn_update_packet(client->GetPlayer(), client->GetVersion(), client->GetPlayer()->GetFeatures());
  1736. //client->QueuePacket(outapp);
  1737. }
  1738. else{
  1739. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /race {race type id} {race id}");
  1740. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "{race id} is optional");
  1741. }
  1742. break;
  1743. }
  1744. case COMMAND_BANK_DEPOSIT:{
  1745. if(client->GetBanker() && sep && sep->arg[0]){
  1746. int64 amount = 0;
  1747. string deposit = string(sep->arg[0]);
  1748. amount = atoi64(deposit.c_str());
  1749. client->BankDeposit(amount);
  1750. }
  1751. break;
  1752. }
  1753. case COMMAND_BANK_WITHDRAWAL:{
  1754. if(client->GetBanker() && sep && sep->arg[0] && sep->IsNumber(0)){
  1755. int64 amount = 0;
  1756. string deposit = string(sep->arg[0]);
  1757. amount = atoi64(deposit.c_str());
  1758. client->BankWithdrawal(amount);
  1759. }
  1760. break;
  1761. }
  1762. case COMMAND_BANK_CANCEL:{
  1763. Spawn* banker = cmdTarget;
  1764. client->Bank(banker, true);
  1765. break;
  1766. }
  1767. case COMMAND_BANK:{
  1768. LogWrite(PLAYER__DEBUG, 0, "Players", "Open Player Personal Bank...");
  1769. Spawn* banker = cmdTarget;
  1770. client->Bank(banker);
  1771. break;
  1772. }
  1773. case COMMAND_GUILD_BANK:{
  1774. LogWrite(GUILD__DEBUG, 0, "Guilds", "Open Guild Bank...");
  1775. //Spawn* banker = client->GetPlayer()->GetTarget();
  1776. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will eventually open the guild bank!");
  1777. break;
  1778. }
  1779. case COMMAND_START_MAIL: {
  1780. client->SetMailTransaction(cmdTarget);
  1781. client->SendMailList();
  1782. break;
  1783. }
  1784. case COMMAND_CANCEL_MAIL: {
  1785. client->SetMailTransaction(0);
  1786. break;
  1787. }
  1788. case COMMAND_GET_MAIL_MESSAGE: {
  1789. if (sep && sep->arg[0] && sep->IsNumber(0))
  1790. client->DisplayMailMessage(atoul(sep->arg[0]));
  1791. break;
  1792. }
  1793. case COMMAND_ADD_MAIL_PLAT: {
  1794. if (sep && sep->arg[0] && sep->IsNumber(0))
  1795. client->AddMailCoin(0, 0, 0, atoul(sep->arg[0]));
  1796. break;
  1797. }
  1798. case COMMAND_ADD_MAIL_GOLD: {
  1799. if (sep && sep->arg[0] && sep->IsNumber(0))
  1800. client->AddMailCoin(0, 0, atoul(sep->arg[0]));
  1801. break;
  1802. }
  1803. case COMMAND_ADD_MAIL_SILVER: {
  1804. if (sep && sep->arg[0] && sep->IsNumber(0))
  1805. client->AddMailCoin(0, atoul(sep->arg[0]));
  1806. break;
  1807. }
  1808. case COMMAND_ADD_MAIL_COPPER: {
  1809. if (sep && sep->arg[0] && sep->IsNumber(0))
  1810. client->AddMailCoin(atoul(sep->arg[0]));
  1811. break;
  1812. }
  1813. case COMMAND_SET_MAIL_ITEM: {
  1814. LogWrite(MISC__TODO, 1, "TODO", " received set_mail_item\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1815. if (sep && sep->arg[0]) LogWrite(COMMAND__DEBUG, 0, "Command", "%s\n", sep->argplus[0]);
  1816. break;
  1817. }
  1818. case COMMAND_REMOVE_MAIL_PLAT: {
  1819. if (sep && sep->arg[0] && sep->IsNumber(0))
  1820. client->RemoveMailCoin(0, 0, 0, atoul(sep->arg[0]));
  1821. break;
  1822. }
  1823. case COMMAND_REMOVE_MAIL_GOLD: {
  1824. if (sep && sep->arg[0] && sep->IsNumber(0))
  1825. client->RemoveMailCoin(0, 0, atoul(sep->arg[0]));
  1826. break;
  1827. }
  1828. case COMMAND_REMOVE_MAIL_SILVER: {
  1829. if (sep && sep->arg[0] && sep->IsNumber(0))
  1830. client->RemoveMailCoin(0, atoul(sep->arg[0]));
  1831. break;
  1832. }
  1833. case COMMAND_REMOVE_MAIL_COPPER: {
  1834. if (sep && sep->arg[0] && sep->IsNumber(0))
  1835. client->RemoveMailCoin(atoul(sep->arg[0]));
  1836. break;
  1837. }
  1838. case COMMAND_TAKE_MAIL_ATTACHMENTS: {
  1839. if (sep && sep->arg[0] && sep->IsNumber(0))
  1840. client->TakeMailAttachments(atoul(sep->arg[0]));
  1841. break;
  1842. }
  1843. case COMMAND_CANCEL_SEND_MAIL: {
  1844. client->CancelSendMail();
  1845. break;
  1846. }
  1847. case COMMAND_DELETE_MAIL_MESSAGE: {
  1848. if (sep && sep->arg[0] && sep->IsNumber(0))
  1849. client->DeleteMail(atoul(sep->arg[0]), true);
  1850. break;
  1851. }
  1852. case COMMAND_REPORT_SPAM: {
  1853. LogWrite(MISC__TODO, 1, "TODO", " received reportspam\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1854. if (sep && sep->arg[0]) LogWrite(COMMAND__DEBUG, 0, "Command", "%s\n", sep->argplus[0]);
  1855. break;
  1856. }
  1857. case COMMAND_KILL:{
  1858. Spawn* dead = 0;
  1859. if (sep && sep->arg[0] && strncasecmp(sep->arg[0],"self",4)==0){
  1860. dead=client->GetPlayer();
  1861. client->GetPlayer()->SetHP(0);
  1862. client->GetPlayer()->KillSpawn(dead);
  1863. }else{
  1864. dead= cmdTarget;
  1865. if(dead && dead->IsPlayer() == false){
  1866. dead->SetHP(0);
  1867. if(sep && sep->arg[0] && sep->IsNumber(0) && atoi(sep->arg[0]) == 1)
  1868. client->GetCurrentZone()->RemoveSpawn(false, dead, true);
  1869. else
  1870. client->GetPlayer()->KillSpawn(dead);
  1871. }else{
  1872. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /kill (self)");
  1873. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Kills currently selected non-player target.");
  1874. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Optionally, self may be used to kill yourself");
  1875. }
  1876. }
  1877. break;
  1878. }
  1879. case COMMAND_LEVEL:{
  1880. if(sep && sep->arg[ndx][0] && sep->IsNumber(0)){
  1881. int16 new_level = atoi(sep->arg[ndx]);
  1882. if (!client->GetPlayer()->CheckLevelStatus(new_level))
  1883. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have the required status to level up anymore!");
  1884. else {
  1885. if (new_level < 1)
  1886. new_level = 1;
  1887. if (new_level > 255)
  1888. new_level = 255;
  1889. client->ChangeLevel(client->GetPlayer()->GetLevel(), new_level);
  1890. }
  1891. }else
  1892. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /level {new_level}");
  1893. break;
  1894. }
  1895. case COMMAND_SIT: {
  1896. LogWrite(MISC__TODO, 1, "TODO", " Send update packet to all clients\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1897. if(client->GetPlayer()->GetHP() > 0){
  1898. client->QueuePacket(new EQ2Packet(OP_SitMsg, 0, 0));
  1899. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You sit down.");
  1900. client->GetPlayer()->set_character_flag(CF_IS_SITTING);
  1901. }
  1902. break;
  1903. }
  1904. case COMMAND_STAND: {
  1905. LogWrite(MISC__TODO, 1, "TODO", " Send update packet to all clients\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1906. if(client->GetPlayer()->GetHP() > 0){
  1907. client->QueuePacket(new EQ2Packet(OP_StandMsg, 0, 0));
  1908. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You stand up.");
  1909. client->GetPlayer()->reset_character_flag(CF_IS_SITTING);
  1910. }
  1911. break;
  1912. }
  1913. case COMMAND_CLASS:{
  1914. if(sep && sep->arg[ndx][0]){
  1915. client->GetPlayer()->SetPlayerAdventureClass(atoi(sep->arg[ndx]));
  1916. client->UpdateTimeStampFlag ( CLASS_UPDATE_FLAG );
  1917. }else
  1918. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /class {class_id}");
  1919. break;
  1920. }
  1921. case COMMAND_GENDER:{
  1922. if(sep && sep->arg[ndx][0]){
  1923. client->GetPlayer()->GetInfoStruct()->gender = atoi(sep->arg[ndx]);
  1924. client->GetPlayer()->SetCharSheetChanged(true);
  1925. client->UpdateTimeStampFlag ( GENDER_UPDATE_FLAG );
  1926. }else{
  1927. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /gender {new_gender_id}");
  1928. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Male: 1");
  1929. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Female: 2");
  1930. }
  1931. break;
  1932. }
  1933. case COMMAND_FLYMODE:{
  1934. if(sep && sep->arg[0] && sep->IsNumber(0)){
  1935. PrintSep(sep, "COMMAND_FLYMODE");
  1936. int8 val = atoi(sep->arg[0]);
  1937. ClientPacketFunctions::SendFlyMode(client, val);
  1938. }
  1939. else{
  1940. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage ON: /flymode 1");
  1941. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage OFF: /flymode 0");
  1942. }
  1943. break;
  1944. }
  1945. case COMMAND_LOOT_LIST:{
  1946. Spawn* spawn = cmdTarget;
  1947. if(spawn && spawn->IsEntity()){
  1948. if (sep && sep->arg[0]) {
  1949. if (!spawn->GetDatabaseID())
  1950. {
  1951. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn has no database id to assign to loottables.");
  1952. break;
  1953. }
  1954. else if (!spawn->IsNPC())
  1955. {
  1956. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "these /loot list [add/remove/clearall] sub-commands are only designed for an NPC.");
  1957. break;
  1958. }
  1959. bool reloadLoot = false;
  1960. if (!stricmp(sep->arg[0], "remove") && sep->arg[1] && sep->IsNumber(1))
  1961. {
  1962. int32 loottable_id = atoul(sep->arg[1]);
  1963. if (loottable_id > 0 && database.RemoveSpawnLootTable(spawn, loottable_id))
  1964. {
  1965. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u loot table %u removed.", spawn->GetDatabaseID(), loottable_id);
  1966. reloadLoot = true;
  1967. }
  1968. else
  1969. client->Message(CHANNEL_COLOR_YELLOW, "/loot list remove [loottableid] - could not match any spawn_id entries against loottable_id %u.", loottable_id);
  1970. }
  1971. else if (!stricmp(sep->arg[0], "add") && sep->arg[1] && sep->IsNumber(1))
  1972. {
  1973. int32 loottable_id = atoul(sep->arg[1]);
  1974. if (loottable_id > 0)
  1975. {
  1976. database.AddLootTableToSpawn(spawn, loottable_id);
  1977. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u loot table %u added.", spawn->GetDatabaseID(), loottable_id);
  1978. reloadLoot = true;
  1979. }
  1980. else
  1981. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list add [loottableid] - cannot add a loottable id of 0.");
  1982. }
  1983. else if (!stricmp(sep->arg[0], "clearall"))
  1984. {
  1985. if (database.RemoveSpawnLootTable(spawn, 0))
  1986. {
  1987. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn loot tables removed.");
  1988. reloadLoot = true;
  1989. }
  1990. else
  1991. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list clearall - could not match any spawn_id entries in loottable_id.");
  1992. }
  1993. else
  1994. {
  1995. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list argument not supported.");
  1996. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list add [loottableid] - add new loottable to spawn");
  1997. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list remove [loottableid] - remove existing loottable from spawn");
  1998. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list clearall - remove all loottables from spawn");
  1999. break;
  2000. }
  2001. if (reloadLoot)
  2002. {
  2003. database.LoadSpawnLoot(spawn->GetZone(), spawn);
  2004. if (spawn->IsNPC())
  2005. {
  2006. Entity* ent = (Entity*)spawn;
  2007. ent->SetLootCoins(0);
  2008. ent->ClearLootList();
  2009. spawn->GetZone()->AddLoot((NPC*)spawn);
  2010. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u active loot purged and reloaded.", spawn->GetDatabaseID());
  2011. }
  2012. }
  2013. break; // nothing further this is the end of these sub commands
  2014. }
  2015. else
  2016. {
  2017. vector<int32> loot_list = client->GetCurrentZone()->GetSpawnLootList(spawn->GetDatabaseID(), spawn->GetZone()->GetZoneID(), spawn->GetLevel(), race_types_list.GetRaceType(spawn->GetModelType()));
  2018. if (loot_list.size() > 0) {
  2019. client->Message(CHANNEL_COLOR_YELLOW, "%s belongs to the following loot lists: ", spawn->GetName());
  2020. vector<int32>::iterator list_itr;
  2021. LootTable* table = 0;
  2022. for (list_itr = loot_list.begin(); list_itr != loot_list.end(); list_itr++) {
  2023. table = client->GetCurrentZone()->GetLootTable(*list_itr);
  2024. if (table)
  2025. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", *list_itr, table->name.c_str());
  2026. }
  2027. }
  2028. client->Message(CHANNEL_COLOR_YELLOW, "Coins being carried: %u", spawn->GetLootCoins());
  2029. vector<Item*>* items = spawn->GetLootItems();
  2030. if (items) {
  2031. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is carrying the following items: ");
  2032. vector<Item*>::iterator itr;
  2033. Item* item = 0;
  2034. for (itr = items->begin(); itr != items->end(); itr++) {
  2035. item = *itr;
  2036. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", item->details.item_id, item->name.c_str());
  2037. }
  2038. }
  2039. else
  2040. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is not carrying any items.");
  2041. }
  2042. }
  2043. break;
  2044. }
  2045. case COMMAND_LOOT_SETCOIN:{
  2046. Spawn* spawn = cmdTarget;
  2047. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2048. spawn->SetLootCoins(atoul(sep->arg[0]));
  2049. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully set coins.");
  2050. }
  2051. else
  2052. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot setcoin {amount}");
  2053. break;
  2054. }
  2055. case COMMAND_LOOT_ADDITEM:{
  2056. Spawn* spawn = cmdTarget;
  2057. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2058. int16 charges = 1;
  2059. if(sep->arg[1] && sep->IsNumber(1))
  2060. charges = atoi(sep->arg[1]);
  2061. spawn->AddLootItem(atoul(sep->arg[0]), charges);
  2062. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully added item.");
  2063. }
  2064. else
  2065. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot additem {item_id}");
  2066. break;
  2067. }
  2068. case COMMAND_LOOT_REMOVEITEM:{
  2069. Spawn* spawn = cmdTarget;
  2070. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2071. spawn->LootItem(atoul(sep->arg[0]));
  2072. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully removed item.");
  2073. }
  2074. else
  2075. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot removeitem {item_id}");
  2076. break;
  2077. }
  2078. case COMMAND_LOOT_CORPSE:
  2079. case COMMAND_DISARM:
  2080. case COMMAND_LOOT:{
  2081. if (cmdTarget && ((Entity*)cmdTarget)->IsNPC() && cmdTarget->Alive())
  2082. {
  2083. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is not dead.");
  2084. break;
  2085. }
  2086. if(cmdTarget && cmdTarget->IsEntity()){
  2087. if (cmdTarget->GetDistance(client->GetPlayer()) <= rule_manager.GetGlobalRule(R_Loot, LootRadius)->GetFloat()){
  2088. if (!rule_manager.GetGlobalRule(R_Loot, AutoDisarmChest)->GetBool() && command->handler == COMMAND_DISARM )
  2089. client->OpenChest(cmdTarget, true);
  2090. else
  2091. client->Loot(cmdTarget, rule_manager.GetGlobalRule(R_Loot, AutoDisarmChest)->GetBool());
  2092. if (!(cmdTarget)->HasLoot()){
  2093. if (((Entity*)cmdTarget)->IsNPC())
  2094. client->GetCurrentZone()->RemoveDeadSpawn(cmdTarget);
  2095. }
  2096. }
  2097. else
  2098. client->Message(CHANNEL_COLOR_YELLOW, "You are too far away to interact with that");
  2099. }
  2100. else if(!cmdTarget || cmdTarget->GetHP() > 0)
  2101. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid target.");
  2102. break;
  2103. }
  2104. case COMMAND_RELOADSPAWNSCRIPTS:{
  2105. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spawn Scripts....");
  2106. if (lua_interface)
  2107. lua_interface->SetSpawnScriptsReloading(true);
  2108. world.ResetSpawnScripts();
  2109. database.LoadSpawnScriptData();
  2110. if(lua_interface) {
  2111. lua_interface->DestroySpawnScripts();
  2112. lua_interface->SetSpawnScriptsReloading(false);
  2113. }
  2114. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Success!");
  2115. break;
  2116. }
  2117. case COMMAND_RELOADREGIONSCRIPTS:{
  2118. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Region Scripts....");
  2119. if(lua_interface) {
  2120. lua_interface->DestroyRegionScripts();
  2121. }
  2122. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Success!");
  2123. break;
  2124. }
  2125. case COMMAND_RELOADLUASYSTEM:{
  2126. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Attempting to reload entire LUA system....");
  2127. map<Client*, int32> debug_clients = lua_interface->GetDebugClients();
  2128. safe_delete(lua_interface);
  2129. lua_interface = new LuaInterface();
  2130. if(lua_interface)
  2131. lua_interface->SetSpawnScriptsReloading(true);
  2132. if(lua_interface && debug_clients.size() > 0){
  2133. map<Client*, int32>::iterator itr;
  2134. for(itr = debug_clients.begin(); itr != debug_clients .end(); itr++){
  2135. if(lua_interface)
  2136. lua_interface->UpdateDebugClients(itr->first);
  2137. }
  2138. }
  2139. world.ResetSpawnScripts();
  2140. database.LoadSpawnScriptData();
  2141. world.ResetZoneScripts();
  2142. database.LoadZoneScriptData();
  2143. int32 quest_count = database.LoadQuests();
  2144. zone_list.DeleteSpellProcess();
  2145. master_spell_list.Reload();
  2146. int32 spell_count = 0;
  2147. if(lua_interface) {
  2148. lua_interface->DestroySpawnScripts();
  2149. lua_interface->DestroySpells();
  2150. spell_count = database.LoadSpellScriptData();
  2151. lua_interface->SetSpawnScriptsReloading(false);
  2152. }
  2153. zone_list.LoadSpellProcess();
  2154. client->Message(CHANNEL_COLOR_YELLOW, "Successfully loaded %u spell(s), %u quest(s).", spell_count, quest_count);
  2155. break;
  2156. }
  2157. case COMMAND_DECLINE_QUEST:{
  2158. int32 quest_id = 0;
  2159. if(sep && sep->arg[0] && sep->IsNumber(0))
  2160. quest_id = atoul(sep->arg[0]);
  2161. if(quest_id > 0){
  2162. Quest* quest = client->GetPendingQuest(quest_id);
  2163. if(quest){
  2164. client->RemovePendingQuest(quest);
  2165. if(lua_interface)
  2166. lua_interface->CallQuestFunction(quest, "Declined", client->GetPlayer());
  2167. safe_delete(quest);
  2168. client->GetCurrentZone()->SendQuestUpdates(client);
  2169. }
  2170. }
  2171. break;
  2172. }
  2173. case COMMAND_DELETE_QUEST:{
  2174. int32 quest_id = 0;
  2175. if(sep && sep->arg[0] && sep->IsNumber(0))
  2176. quest_id = atoul(sep->arg[0]);
  2177. if(quest_id > 0){
  2178. if(lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0) {
  2179. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  2180. if (quest)
  2181. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  2182. }
  2183. client->RemovePlayerQuest(quest_id);
  2184. client->GetCurrentZone()->SendQuestUpdates(client);
  2185. }
  2186. break;
  2187. }
  2188. case COMMAND_ACCEPT_QUEST:{
  2189. int32 quest_id = 0;
  2190. if(sep && sep->arg[0] && sep->IsNumber(0))
  2191. quest_id = atoul(sep->arg[0]);
  2192. if(quest_id > 0){
  2193. client->AcceptQuest(quest_id);
  2194. }
  2195. break;
  2196. }
  2197. case COMMAND_NAME:{
  2198. if(sep && sep->arg[ndx][0]){
  2199. memset(client->GetPlayer()->GetInfoStruct()->name, 0, 40);
  2200. strncpy(client->GetPlayer()->GetInfoStruct()->name, sep->arg[ndx], 39);
  2201. client->GetPlayer()->SetCharSheetChanged(true);
  2202. }else
  2203. client->Message(CHANNEL_COLOR_YELLOW,"Usage: /name {new_name}");
  2204. break;
  2205. }
  2206. case COMMAND_GROUPSAY:{
  2207. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  2208. if(sep && sep->arg[0] && gmi)
  2209. world.GetGroupManager()->GroupChatMessage(gmi->group_id, client->GetPlayer(), sep->argplus[0]);
  2210. break;
  2211. }
  2212. case COMMAND_GROUPINVITE: {
  2213. Entity* target = 0;
  2214. Client* target_client = 0;
  2215. if (client->GetPlayer()->GetGroupMemberInfo() && !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  2216. client->SimpleMessage(CHANNEL_COMMANDS, "You must be the group leader to invite.");
  2217. return;
  2218. }
  2219. // name provided with command so it has to be a player, npc not supported here
  2220. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0){
  2221. target_client = zone_list.GetClientByCharName(sep->arg[0]);
  2222. if (target_client) {
  2223. if (!target_client->IsConnected() || !target_client->IsReadyForSpawns())
  2224. target = 0;
  2225. else
  2226. target = target_client->GetPlayer();
  2227. }
  2228. }
  2229. // if name was not provided use the players target, npc or player supported here
  2230. if (!target && client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  2231. target = (Entity*)client->GetPlayer()->GetTarget();
  2232. if (target->IsPlayer()) {
  2233. target_client = client->GetCurrentZone()->GetClientBySpawn(target);
  2234. }
  2235. }
  2236. int8 result = world.GetGroupManager()->Invite(client->GetPlayer(), target);
  2237. if (result == 0) {
  2238. client->Message(CHANNEL_COMMANDS, "You invite %s to group with you.", target->GetName());
  2239. if (target_client) {
  2240. PacketStruct* packet = configReader.getStruct("WS_ReceiveOffer", target_client->GetVersion());
  2241. if (packet) {
  2242. packet->setDataByName("type", 1);
  2243. packet->setDataByName("name", client->GetPlayer()->GetName());
  2244. packet->setDataByName("unknown2", 1);
  2245. target_client->QueuePacket(packet->serialize());
  2246. safe_delete(packet);
  2247. }
  2248. }
  2249. }
  2250. else if (result == 1)
  2251. client->SimpleMessage(CHANNEL_COMMANDS, "That player is already in a group.");
  2252. else if (result == 2)
  2253. client->SimpleMessage(CHANNEL_COMMANDS, "That player has been invited to another group.");
  2254. else if (result == 3)
  2255. client->SimpleMessage(CHANNEL_COMMANDS, "Your group is already full.");
  2256. else if (result == 4)
  2257. client->SimpleMessage(CHANNEL_COMMANDS, "You have a pending invitation, cancel it first.");
  2258. else if (result == 5)
  2259. client->SimpleMessage(CHANNEL_COMMANDS, "You cannot invite yourself!");
  2260. else if (result == 6)
  2261. client->SimpleMessage(CHANNEL_COMMANDS, "Could not locate the player.");
  2262. else
  2263. client->SimpleMessage(CHANNEL_COMMANDS, "Group invite failed, unknown error!");
  2264. break;
  2265. }
  2266. case COMMAND_GROUPDISBAND: {
  2267. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  2268. if (gmi) { // TODO: Leader check
  2269. // world.GetGroupManager()->SimpleGroupMessage(gmi->group_id, "Your group has been disbanded.");
  2270. world.GetGroupManager()->RemoveGroup(gmi->group_id);
  2271. }
  2272. break;
  2273. }
  2274. case COMMAND_GROUP_LEAVE: {
  2275. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  2276. if (gmi) {
  2277. int32 group_id = gmi->group_id;
  2278. world.GetGroupManager()->RemoveGroupMember(group_id, client->GetPlayer());
  2279. if (!world.GetGroupManager()->IsGroupIDValid(group_id)) {
  2280. // leader->Message(CHANNEL_COLOR_GROUP, "%s has left the group.", client->GetPlayer()->GetName());
  2281. }
  2282. else {
  2283. world.GetGroupManager()->GroupMessage(group_id, "%s has left the group.", client->GetPlayer()->GetName());
  2284. }
  2285. client->SimpleMessage(CHANNEL_GROUP_CHAT, "You have left the group");
  2286. }
  2287. break;
  2288. }
  2289. case COMMAND_FRIEND_ADD:{
  2290. string name = "";
  2291. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2292. name = database.GetPlayerName(sep->arg[0]);
  2293. else if(cmdTarget && cmdTarget->IsPlayer())
  2294. name = string(cmdTarget->GetName());
  2295. if(name.length() > 0){
  2296. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  2297. if(client->GetPlayer()->IsIgnored(name.c_str())){
  2298. client->GetPlayer()->RemoveIgnore(name.c_str());
  2299. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  2300. client->SendChatRelationship(3, name.c_str());
  2301. }
  2302. client->GetPlayer()->AddFriend(name.c_str(), true);
  2303. client->SendChatRelationship(0, name.c_str());
  2304. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added friend: %s", name.c_str());
  2305. if(zone_list.GetClientByCharName(name))
  2306. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Friend: %s has logged in.", name.c_str());
  2307. }
  2308. else
  2309. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot be more friendly towards yourself!");
  2310. }
  2311. else
  2312. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  2313. break;
  2314. }
  2315. case COMMAND_FRIEND_REMOVE:{
  2316. string name = "";
  2317. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2318. name = database.GetPlayerName(sep->arg[0]);
  2319. else if(cmdTarget && cmdTarget->IsPlayer())
  2320. name = string(cmdTarget->GetName());
  2321. if(name.length() > 0){
  2322. client->GetPlayer()->RemoveFriend(name.c_str());
  2323. client->SendChatRelationship(1, name.c_str());
  2324. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  2325. }
  2326. else
  2327. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  2328. break;
  2329. }
  2330. case COMMAND_FRIENDS:{
  2331. break;
  2332. }
  2333. case COMMAND_IGNORE_ADD:{
  2334. string name = "";
  2335. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2336. name = database.GetPlayerName(sep->arg[0]);
  2337. else if(cmdTarget && cmdTarget->IsPlayer())
  2338. name = string(cmdTarget->GetName());
  2339. if(name.length() > 0){
  2340. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  2341. if(client->GetPlayer()->IsFriend(name.c_str())){
  2342. client->GetPlayer()->RemoveFriend(name.c_str());
  2343. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  2344. client->SendChatRelationship(1, name.c_str());
  2345. }
  2346. client->GetPlayer()->AddIgnore(name.c_str(), true);
  2347. client->SendChatRelationship(2, name.c_str());
  2348. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added ignore: %s", name.c_str());
  2349. }
  2350. else
  2351. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot ignore yourself!");
  2352. }
  2353. else
  2354. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  2355. break;
  2356. }
  2357. case COMMAND_IGNORE_REMOVE:{
  2358. string name = "";
  2359. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2360. name = database.GetPlayerName(sep->arg[0]);
  2361. else if(cmdTarget && cmdTarget->IsPlayer())
  2362. name = string(cmdTarget->GetName());
  2363. if(name.length() > 0){
  2364. client->GetPlayer()->RemoveIgnore(name.c_str());
  2365. client->SendChatRelationship(3, name.c_str());
  2366. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  2367. }
  2368. break;
  2369. }
  2370. case COMMAND_IGNORES:{
  2371. break;
  2372. }
  2373. case COMMAND_GROUP_KICK:{
  2374. Entity* kicked = 0;
  2375. Client* kicked_client = 0;
  2376. int32 group_id = 0;
  2377. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader)
  2378. return;
  2379. LogWrite(MISC__TODO, 0, "TODO", "Add a check to see if the client using the command (COMMAND_GROUP_KICK) is the group leader");
  2380. if (sep && sep->arg[0]) {
  2381. kicked_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  2382. if (kicked_client)
  2383. kicked = kicked_client->GetPlayer();
  2384. }
  2385. else if (cmdTarget && cmdTarget->IsEntity()) {
  2386. kicked = (Entity*)cmdTarget;
  2387. }
  2388. group_id = client->GetPlayer()->GetGroupMemberInfo()->group_id;
  2389. bool send_kicked_message = world.GetGroupManager()->GetGroupSize(group_id) > 2;
  2390. if (kicked)
  2391. world.GetGroupManager()->RemoveGroupMember(group_id, kicked);
  2392. if(send_kicked_message)
  2393. world.GetGroupManager()->GroupMessage(group_id, "%s was kicked from the group.", kicked->GetName());
  2394. else
  2395. client->Message(CHANNEL_GROUP_CHAT, "You kicked %s from the group", kicked->GetName());
  2396. if (kicked_client)
  2397. kicked_client->SimpleMessage(CHANNEL_GROUP_CHAT, "You were kicked from the group");
  2398. break;
  2399. }
  2400. case COMMAND_GROUP_MAKE_LEADER:{
  2401. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  2402. client->SimpleMessage(CHANNEL_COMMANDS, "You are not a group leader.");
  2403. return;
  2404. }
  2405. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 1) {
  2406. Client* new_leader = zone_list.GetClientByCharName(sep->arg[0]);
  2407. if (new_leader) {
  2408. if (client->GetPlayer()->IsGroupMember(new_leader->GetPlayer())) {
  2409. world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, new_leader->GetPlayer());
  2410. }
  2411. }
  2412. else
  2413. client->SimpleMessage(CHANNEL_COMMANDS, "Unable to find the given player.");
  2414. }
  2415. else if (cmdTarget && cmdTarget->IsPlayer())
  2416. world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, (Entity*)cmdTarget);
  2417. else
  2418. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to change group leader.");
  2419. break;
  2420. }
  2421. case COMMAND_GROUP_ACCEPT_INVITE: {
  2422. if(sep && sep->arg[0] && strcmp(sep->arg[0], "group") == 0) {
  2423. int8 result = world.GetGroupManager()->AcceptInvite(client->GetPlayer());
  2424. if (result == 0)
  2425. client->SimpleMessage(CHANNEL_GROUP_CHAT, "You have joined the group.");
  2426. else if (result == 1)
  2427. client->SimpleMessage(CHANNEL_GROUP_CHAT, "You do not have a pending invite.");
  2428. else if (result == 2)
  2429. client->SimpleMessage(CHANNEL_GROUP_CHAT, "Unable to join group - could not find leader.");
  2430. else
  2431. client->SimpleMessage(CHANNEL_GROUP_CHAT, "Unable to join group - unknown error.");
  2432. }
  2433. break;
  2434. }
  2435. case COMMAND_GROUP_DECLINE_INVITE: {
  2436. if(sep && sep->arg[0] && strcmp(sep->arg[0], "group") == 0) {
  2437. world.GetGroupManager()->DeclineInvite(client->GetPlayer()); // TODO: Add message to leader
  2438. }
  2439. break;
  2440. }
  2441. case COMMAND_SUMMON:{
  2442. char* search_name = 0;
  2443. if(sep && sep->arg[0][0])
  2444. search_name = sep->arg[0];
  2445. if(!search_name && !cmdTarget){
  2446. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /summon [name]");
  2447. 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.");
  2448. }
  2449. else{
  2450. if(!client->Summon(search_name))
  2451. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  2452. }
  2453. break;
  2454. }
  2455. case COMMAND_GOTO:{
  2456. const char* search_name = 0;
  2457. if(sep && sep->arg[0][0])
  2458. search_name = sep->argplus[0];
  2459. if(!search_name && !cmdTarget){
  2460. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /goto [name]");
  2461. 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.");
  2462. }
  2463. else{
  2464. if(!client->GotoSpawn(search_name))
  2465. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  2466. }
  2467. break;
  2468. }
  2469. case COMMAND_MOVE:{
  2470. bool success = false;
  2471. try{
  2472. if(sep && sep->arg[2][0] && sep->IsNumber(0) && sep->IsNumber(1) && sep->IsNumber(2)){
  2473. EQ2Packet* app = client->GetPlayer()->Move(atof(sep->arg[0]), atof(sep->arg[1]), atof(sep->arg[2]), client->GetVersion());
  2474. if(app){
  2475. client->QueuePacket(app);
  2476. success = true;
  2477. }
  2478. }
  2479. }
  2480. catch(...){}
  2481. if(!success){
  2482. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /move x y z");
  2483. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Moves the client to the given coordinates.");
  2484. }
  2485. break;
  2486. }
  2487. case COMMAND_SETTIME:{
  2488. if(sep && sep->arg[0]){
  2489. sscanf (sep->arg[0], "%d:%d", &world.GetWorldTimeStruct()->hour, &world.GetWorldTimeStruct()->minute);
  2490. if(sep->arg[1] && sep->IsNumber(1))
  2491. world.GetWorldTimeStruct()->month = atoi(sep->arg[1]) - 1; //zero based indexes
  2492. if(sep->arg[2] && sep->IsNumber(2))
  2493. world.GetWorldTimeStruct()->day = atoi(sep->arg[2]) - 1; //zero based indexes
  2494. if(sep->arg[3] && sep->IsNumber(3))
  2495. world.GetWorldTimeStruct()->year = atoi(sep->arg[3]);
  2496. client->GetCurrentZone()->SendTimeUpdateToAllClients();
  2497. }
  2498. else{
  2499. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /settime [hour:minute] (month) (day) (year)");
  2500. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Example: /settime 8:30");
  2501. }
  2502. break;
  2503. }
  2504. case COMMAND_VERSION:{
  2505. client->Message(CHANNEL_COLOR_YELLOW,"%s %s", EQ2EMU_MODULE, CURRENT_VERSION);
  2506. client->Message(CHANNEL_COLOR_YELLOW,"Last Compiled on %s %s", COMPILE_DATE, COMPILE_TIME);
  2507. break;
  2508. }
  2509. case COMMAND_ZONE:{
  2510. int32 instanceID = 0;
  2511. string zone;
  2512. int32 zone_id = 0;
  2513. bool listSearch = false;
  2514. bool isInstance = false;
  2515. ZoneServer* zsZone = 0;
  2516. if(sep && sep->arg[0][0])
  2517. {
  2518. if(strncasecmp(sep->arg[0], "list", 4) == 0)
  2519. listSearch = true;
  2520. else if(strncasecmp(sep->arg[0], "active", 6) == 0)
  2521. {
  2522. zone_list.SendZoneList(client);
  2523. break;
  2524. }
  2525. else if(strncasecmp(sep->arg[0], "instance", 6) == 0)
  2526. {
  2527. if(sep->IsNumber(1))
  2528. instanceID = atol(sep->arg[1]);
  2529. }
  2530. else if(strncasecmp(sep->arg[0], "lock", 4) == 0)
  2531. {
  2532. PrintSep(sep, "ZONE LOCK");
  2533. if(sep->IsNumber(1))
  2534. zsZone = zone_list.Get(atoul(sep->arg[1]), false);
  2535. else
  2536. zsZone = zone_list.Get(sep->arg[1], false);
  2537. if( zsZone )
  2538. {
  2539. zsZone->SetZoneLockState(true);
  2540. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now locked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  2541. }
  2542. else
  2543. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be locked.", sep->arg[1]);
  2544. break;
  2545. }
  2546. else if(strncasecmp(sep->arg[0], "unlock", 6) == 0)
  2547. {
  2548. PrintSep(sep, "ZONE UNLOCK");
  2549. if(sep->IsNumber(1))
  2550. zsZone = zone_list.Get(atoul(sep->arg[1]), false);
  2551. else
  2552. zsZone = zone_list.Get(sep->arg[1], false);
  2553. if( zsZone )
  2554. {
  2555. zsZone->SetZoneLockState(false);
  2556. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now unlocked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  2557. }
  2558. else
  2559. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be unlocked.", sep->arg[1]);
  2560. break;
  2561. }
  2562. else
  2563. {
  2564. if(sep->IsNumber(0))
  2565. {
  2566. zone_id = atoul(sep->arg[0]);
  2567. string zonename = database.GetZoneName(zone_id);
  2568. if(zonename.length() > 0)
  2569. zone = zonename;
  2570. }
  2571. else
  2572. zone = sep->arg[0];
  2573. }
  2574. if(instanceID > 0)
  2575. {
  2576. ZoneServer* zsInstance = zone_list.GetByInstanceID(instanceID);
  2577. if(zsInstance != NULL)
  2578. {
  2579. instanceID = zsInstance->GetInstanceID();
  2580. zone = zsInstance->GetZoneName();
  2581. zone_id = zsInstance->GetZoneID();
  2582. isInstance = true;
  2583. }
  2584. }
  2585. }
  2586. if(!listSearch)
  2587. {
  2588. if(zone.length() == 0)
  2589. client->Message(CHANNEL_COLOR_RED, "Error: Invalid Zone");
  2590. else if(instanceID != client->GetCurrentZone()->GetInstanceID() ||
  2591. zone_id != client->GetCurrentZone()->GetZoneID())
  2592. {
  2593. const char* zonestr = zone.c_str();
  2594. if(database.VerifyZone(zonestr))
  2595. {
  2596. if(client->CheckZoneAccess(zonestr))
  2597. {
  2598. client->Message(CHANNEL_COLOR_YELLOW,"Zoning to %s...", zonestr);
  2599. if(isInstance)
  2600. client->Zone(instanceID,true,true);
  2601. else
  2602. client->Zone(zonestr);
  2603. }
  2604. }
  2605. else
  2606. client->Message(CHANNEL_COLOR_RED, "Error: Zone '%s' not found. To get a list type /zone list", zonestr);
  2607. }
  2608. else
  2609. client->Message(CHANNEL_COLOR_RED, "Error: You are already in that zone!");
  2610. }
  2611. else
  2612. {
  2613. const char* name = 0;
  2614. if(sep && sep->arg[1][0])
  2615. {
  2616. map<int32, string>* zone_names;
  2617. name = sep->argplus[1];
  2618. sint16 status = client->GetAdminStatus();
  2619. if( status > 0 )
  2620. {
  2621. client->SimpleMessage(CHANNEL_COLOR_RED, "ADMIN MODE");
  2622. zone_names = database.GetZoneList(name, true);
  2623. }
  2624. else
  2625. zone_names = database.GetZoneList(name);
  2626. if(!zone_names)
  2627. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No zones found.");
  2628. else
  2629. {
  2630. map<int32, string>::iterator itr;
  2631. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  2632. for(itr = zone_names->begin(); itr != zone_names->end(); itr++)
  2633. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  2634. safe_delete(zone_names);
  2635. }
  2636. }
  2637. else
  2638. {
  2639. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone [zone name]");
  2640. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone list [partial zone name]");
  2641. }
  2642. }
  2643. break;
  2644. }
  2645. case COMMAND_USE: {
  2646. Spawn* target = cmdTarget;
  2647. if (target->IsWidget())
  2648. ((Widget*)target)->HandleUse(client, "use");
  2649. break;
  2650. }
  2651. case COMMAND_OPEN: {
  2652. Spawn* target = cmdTarget;
  2653. if (target->IsWidget())
  2654. ((Widget*)target)->HandleUse(client, "Open", WIDGET_TYPE_DOOR);
  2655. break;
  2656. }
  2657. case COMMAND_CASTSPELL: {
  2658. if (sep && sep->arg[0] && sep->IsNumber(0))
  2659. {
  2660. int8 tier = 1;
  2661. if (sep->arg[1] && sep->IsNumber(1))
  2662. tier = atoul(sep->arg[1]);
  2663. int32 spellid = atoul(sep->arg[0]);
  2664. Spell* spell = master_spell_list.GetSpell(spellid, tier);
  2665. if (spell)
  2666. {
  2667. client->Message(CHANNEL_COLOR_RED, "Casting spell %u.", spellid);
  2668. SpellProcess* spellProcess = 0;
  2669. // Get the current zones spell process
  2670. spellProcess = client->GetCurrentZone()->GetSpellProcess();
  2671. spellProcess->CastInstant(spell, (Entity*)client->GetPlayer(), (cmdTarget && cmdTarget->IsEntity()) ? (Entity*)cmdTarget : (Entity*)client->GetPlayer());
  2672. }
  2673. else
  2674. {
  2675. client->Message(CHANNEL_COLOR_RED, "Could not find spell %u.",spellid);
  2676. }
  2677. }
  2678. else if (sep && sep->arg[0])
  2679. {
  2680. database.FindSpell(client, (char*)sep->argplus[0]);
  2681. }
  2682. else
  2683. {
  2684. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellid] (tier=1) - Cast Spell with specified spell id, tier is optional, default of 1.");
  2685. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellname] - Find spells wildcard match with a partial spell name");
  2686. }
  2687. break;
  2688. }
  2689. case COMMAND_KNOWLEDGEWINDOWSORT: {
  2690. if (client->GetVersion() <= 546)
  2691. break;
  2692. if (sep && sep->GetArgNumber() == 4)
  2693. {
  2694. int32 book = atoul(sep->arg[0]); // 0 - spells, 1 - combat, 2 - abilities, 3 - tradeskill
  2695. int32 sort_by = atoul(sep->arg[1]); // 0 - alpha, 1 - level, 2 - category
  2696. int32 order = atoul(sep->arg[2]); // 0 - ascending, 1 - descending
  2697. int32 pattern = atoul(sep->arg[3]); // 0 - zigzag, 1 - down, 2 - across
  2698. int32 maxlvlonly = atoul(sep->arg[4]); // 0 - zigzag, 1 - down, 2 - across
  2699. client->GetPlayer()->ResortSpellBook(sort_by, order, pattern, maxlvlonly, book);
  2700. ClientPacketFunctions::SendSkillSlotMappings(client);
  2701. }
  2702. else
  2703. {
  2704. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /knowledgewindow_sort [book] [sort_by] [order] [pattern]");
  2705. }
  2706. break;
  2707. }
  2708. case COMMAND_MOVE_ITEM:
  2709. {
  2710. int32 id = 0;
  2711. if (sep->IsNumber(0))
  2712. id = atoul(sep->arg[0]);
  2713. Spawn* spawn = 0;
  2714. if (id == 0)
  2715. {
  2716. spawn = cmdTarget;
  2717. }
  2718. else
  2719. spawn = client->GetCurrentZone()->GetSpawnFromUniqueItemID(id);
  2720. if (!spawn || !client->HasOwnerOrEditAccess() || !spawn->GetPickupItemID())
  2721. break;
  2722. client->SendMoveObjectMode(spawn, 0);
  2723. break;
  2724. }
  2725. case COMMAND_PICKUP:
  2726. {
  2727. int32 id = 0;
  2728. if (sep->IsNumber(0))
  2729. id = atoul(sep->arg[0]);
  2730. Spawn* spawn = 0;
  2731. if (id == 0)
  2732. {
  2733. spawn = cmdTarget;
  2734. }
  2735. else
  2736. spawn = client->GetCurrentZone()->GetSpawnFromUniqueItemID(id);
  2737. if (!spawn || !client->HasOwnerOrEditAccess() || !spawn->GetPickupItemID())
  2738. break;
  2739. client->AddItem(spawn->GetPickupItemID(), 1);
  2740. Query query;
  2741. 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());
  2742. if (database.RemoveSpawnFromSpawnLocation(spawn)) {
  2743. client->GetCurrentZone()->RemoveSpawn(false, spawn, true, true);
  2744. }
  2745. // we had a UI Window displayed, update the house items
  2746. if ( id > 0 )
  2747. client->GetCurrentZone()->SendHouseItems(client);
  2748. break;
  2749. }
  2750. case COMMAND_HOUSE_DEPOSIT:
  2751. {
  2752. PrintSep(sep, "COMMAND_HOUSE_DEPOSIT");
  2753. // arg0 = ??? (set to 3)
  2754. // arg1 = coin (in copper)
  2755. // arg2 = status? (not implemented yet)
  2756. PlayerHouse* ph = world.GetPlayerHouseByInstanceID(client->GetCurrentZone()->GetInstanceID());
  2757. if (ph && sep && sep->IsNumber(1))
  2758. {
  2759. int64 outVal = strtoull(sep->arg[1], NULL, 0);
  2760. if (client->GetPlayer()->RemoveCoins(outVal))
  2761. {
  2762. char query[256];
  2763. map<string,Deposit>::iterator itr = ph->depositsMap.find(string(client->GetPlayer()->GetName()));
  2764. if (itr != ph->depositsMap.end())
  2765. {
  2766. snprintf(query, 256, "update character_house_deposits set timestamp = %u, amount = amount + %I64u, last_amount = %I64u where house_id = %u and instance_id = %u and name='%s'", Timer::GetUnixTimeStamp(), outVal, outVal, ph->house_id, ph->instance_id, client->GetPlayer()->GetName());
  2767. }
  2768. else
  2769. snprintf(query, 256, "insert into character_house_deposits set timestamp = %u, house_id = %u, instance_id = %u, name='%s', amount = %I64u", Timer::GetUnixTimeStamp(), ph->house_id, ph->instance_id, client->GetPlayer()->GetName(), outVal);
  2770. if (database.RunQuery(query, strnlen(query, 256)))
  2771. {
  2772. ph->escrow_coins += outVal;
  2773. database.UpdateHouseEscrow(ph->house_id, ph->instance_id, ph->escrow_coins);
  2774. database.LoadDeposits(ph);
  2775. client->PlaySound("coin_cha_ching");
  2776. HouseZone* hz = world.GetHouseZone(ph->house_id);
  2777. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  2778. }
  2779. else
  2780. {
  2781. client->GetPlayer()->AddCoins(outVal);
  2782. client->SimpleMessage(CHANNEL_COLOR_RED, "Deposit failed!");
  2783. }
  2784. }
  2785. }
  2786. break;
  2787. }
  2788. case COMMAND_HOUSE:
  2789. {
  2790. if (sep && sep->IsNumber(0))
  2791. {
  2792. int32 unique_id = atoi(sep->arg[0]);
  2793. PlayerHouse* ph = world.GetPlayerHouseByUniqueID(unique_id);
  2794. HouseZone* hz = 0;
  2795. if (ph)
  2796. hz = world.GetHouseZone(ph->house_id);
  2797. // there is a arg[1] that is true/false, but not sure what it is for investigate more later
  2798. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  2799. }
  2800. else if (client->GetCurrentZone()->GetInstanceType() != 0)
  2801. {
  2802. // inside a house or something? Send the access window
  2803. PlayerHouse* ph = world.GetPlayerHouseByInstanceID(client->GetCurrentZone()->GetInstanceID());
  2804. HouseZone* hz = 0;
  2805. if ( ph )
  2806. hz = world.GetHouseZone(ph->house_id);
  2807. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  2808. client->GetCurrentZone()->SendHouseItems(client);
  2809. }
  2810. break;
  2811. }
  2812. case COMMAND_HOUSE_UI:
  2813. {
  2814. if (sep && sep->IsNumber(0) && client->GetCurrentZone()->GetInstanceType() == Instance_Type::NONE)
  2815. {
  2816. int32 unique_id = atoi(sep->arg[0]);
  2817. PlayerHouse* ph = world.GetPlayerHouseByUniqueID(unique_id);
  2818. HouseZone* hz = 0;
  2819. if ( ph )
  2820. hz = world.GetHouseZone(ph->house_id);
  2821. // there is a arg[1] that is true/false, but not sure what it is for investigate more later
  2822. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, 0);
  2823. }
  2824. break;
  2825. }
  2826. case COMMAND_PLACE_HOUSE_ITEM: {
  2827. if (sep && sep->IsNumber(0))
  2828. {
  2829. int32 uniqueid = atoi(sep->arg[0]);
  2830. Item* item = client->GetPlayer()->item_list.GetItemFromUniqueID(uniqueid);
  2831. //Item* item = player->GetEquipmentList()->GetItem(slot);
  2832. if (item && item->IsHouseItem())
  2833. {
  2834. if (!client->HasOwnerOrEditAccess())
  2835. {
  2836. client->SimpleMessage(CHANNEL_COLOR_RED, "This is not your home!");
  2837. break;
  2838. }
  2839. else if (!item->generic_info.appearance_id)
  2840. {
  2841. 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);
  2842. break;
  2843. }
  2844. if (client->GetTempPlacementSpawn())
  2845. {
  2846. Spawn* tmp = client->GetTempPlacementSpawn();
  2847. client->GetCurrentZone()->RemoveSpawn(false, tmp);
  2848. delete tmp;
  2849. client->SetTempPlacementSpawn(nullptr);
  2850. }
  2851. Spawn* spawn = new Object();
  2852. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  2853. spawn->SetID(Spawn::NextID());
  2854. spawn->SetX(client->GetPlayer()->GetX());
  2855. spawn->SetY(client->GetPlayer()->GetY());
  2856. spawn->SetZ(client->GetPlayer()->GetZ());
  2857. spawn->SetHeading(client->GetPlayer()->GetHeading());
  2858. spawn->SetSpawnOrigX(spawn->GetX());
  2859. spawn->SetSpawnOrigY(spawn->GetY());
  2860. spawn->SetSpawnOrigZ(spawn->GetZ());
  2861. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  2862. spawn->appearance.targetable = 1;
  2863. spawn->appearance.activity_status = ACTIVITY_STATUS_SOLID;
  2864. spawn->appearance.race = item && item->generic_info.appearance_id ? item->generic_info.appearance_id : 1472;
  2865. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  2866. spawn->SetModelType(item && item->generic_info.appearance_id ? item->generic_info.appearance_id : 1472);
  2867. spawn->SetZone(client->GetCurrentZone());
  2868. client->GetCurrentZone()->SendSpawn(spawn, client);
  2869. client->SetTempPlacementSpawn(spawn);
  2870. client->SetPlacementUniqueItemID(uniqueid);
  2871. client->SendMoveObjectMode(spawn, 0);
  2872. }
  2873. }
  2874. break;
  2875. }
  2876. case COMMAND_GM:
  2877. {
  2878. if (sep->arg[0] && sep->arg[1])
  2879. {
  2880. bool onOff = (strcmp(sep->arg[1], "on") == 0);
  2881. if (strcmp(sep->arg[0], "vision") == 0)
  2882. {
  2883. client->GetPlayer()->SetGMVision(onOff);
  2884. #if defined(__GNUC__)
  2885. database.insertCharacterProperty(client, CHAR_PROPERTY_GMVISION, (onOff) ? (char*)"1" : (char*)"0");
  2886. #else
  2887. database.insertCharacterProperty(client, CHAR_PROPERTY_GMVISION, (onOff) ? "1" : "0");
  2888. #endif
  2889. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  2890. if (onOff)
  2891. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Vision Enabled!");
  2892. else
  2893. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Vision Disabled!");
  2894. }
  2895. else if (strcmp(sep->arg[0], "regiondebug") == 0)
  2896. {
  2897. client->SetRegionDebug(onOff);
  2898. #if defined(__GNUC__)
  2899. database.insertCharacterProperty(client, CHAR_PROPERTY_REGIONDEBUG, (onOff) ? (char*)"1" : (char*)"0");
  2900. #else
  2901. database.insertCharacterProperty(client, CHAR_PROPERTY_REGIONDEBUG, (onOff) ? "1" : "0");
  2902. #endif
  2903. if (onOff)
  2904. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Region Debug Enabled!");
  2905. else
  2906. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Region Debug Disabled!");
  2907. }
  2908. else if (strcmp(sep->arg[0], "luadebug") == 0)
  2909. {
  2910. client->SetLuaDebugClient(onOff);
  2911. #if defined(__GNUC__)
  2912. database.insertCharacterProperty(client, CHAR_PROPERTY_LUADEBUG, (onOff) ? (char*)"1" : (char*)"0");
  2913. #else
  2914. database.insertCharacterProperty(client, CHAR_PROPERTY_LUADEBUG, (onOff) ? "1" : "0");
  2915. #endif
  2916. if (onOff)
  2917. {
  2918. if (lua_interface)
  2919. lua_interface->UpdateDebugClients(client);
  2920. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will now receive LUA error messages.");
  2921. }
  2922. else
  2923. {
  2924. if (lua_interface)
  2925. lua_interface->RemoveDebugClients(client);
  2926. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will no longer receive LUA error messages.");
  2927. }
  2928. }
  2929. }
  2930. break;
  2931. }
  2932. case COMMAND_ATTACK:
  2933. case COMMAND_AUTO_ATTACK:{
  2934. int8 type = 1;
  2935. Player* player = client->GetPlayer();
  2936. if(!player)
  2937. break;
  2938. bool incombat = player->EngagedInCombat();
  2939. if(sep && sep->arg[0] && sep->IsNumber(0))
  2940. type = atoi(sep->arg[0]);
  2941. if(client->GetPlayer()->GetHP() == 0){
  2942. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  2943. break;
  2944. }
  2945. if(type == 0){
  2946. if(incombat)
  2947. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You stop fighting.");
  2948. player->InCombat(false);
  2949. player->InCombat(false, true);
  2950. player->SetRangeAttack(false);
  2951. }
  2952. else {
  2953. if(type == 2){
  2954. player->InCombat(false);
  2955. if(incombat && player->GetRangeAttack()){
  2956. player->SetRangeAttack(false);
  2957. player->InCombat(false, true);
  2958. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You stop fighting.");
  2959. }
  2960. else{
  2961. player->SetRangeAttack(true);
  2962. player->InCombat(true, true);
  2963. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You start fighting.");
  2964. }
  2965. }
  2966. else {
  2967. player->InCombat(false, true);
  2968. player->SetRangeAttack(false);
  2969. player->InCombat(true);
  2970. if(!incombat)
  2971. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You start fighting.");
  2972. }
  2973. /*else
  2974. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You cannot attack that!");*/
  2975. }
  2976. player->SetCharSheetChanged(true);
  2977. break;
  2978. }
  2979. case COMMAND_DEPOP:{
  2980. bool allow_respawns = false;
  2981. if(sep && sep->arg[0] && sep->IsNumber(0)){
  2982. if(atoi(sep->arg[0]) == 1)
  2983. allow_respawns = true;
  2984. }
  2985. client->GetCurrentZone()->Depop(allow_respawns);
  2986. break;
  2987. }
  2988. case COMMAND_REPOP:{
  2989. client->GetCurrentZone()->Depop(false, true);
  2990. break;
  2991. }
  2992. case COMMAND_BUYBACK:{
  2993. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  2994. // 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
  2995. int64 id = atoi64(sep->arg[0]);
  2996. // get the first int32, the item id
  2997. //int32 item_id = (int32)id;
  2998. // get the second int32, the unique id
  2999. int32 unique_id = (int32)(id>>32);
  3000. int8 quantity = atoi(sep->arg[1]);
  3001. if(quantity == 255)
  3002. quantity = 1;
  3003. client->BuyBack(unique_id, quantity);
  3004. }
  3005. break;
  3006. }
  3007. case COMMAND_MERCHANT_BUY:{
  3008. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  3009. int32 item_id = atoul(sep->arg[0]);
  3010. int8 quantity = atoi(sep->arg[1]);
  3011. client->BuyItem(item_id, quantity);
  3012. }
  3013. else
  3014. Command_SendMerchantWindow(client, sep);
  3015. break;
  3016. }
  3017. case COMMAND_MERCHANT_SELL:{
  3018. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  3019. // 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
  3020. int64 id = atoi64(sep->arg[0]);
  3021. // get the first int32, the item id
  3022. int32 item_id = (int32)id;
  3023. // get the second int32, the unique id
  3024. int32 unique_id = (int32)(id>>32);
  3025. int8 quantity = atoi(sep->arg[1]);
  3026. LogWrite(MERCHANT__DEBUG, 0, "Merchant", "Selling Item: Item Id = %ul, unique id = %ul, Quantity = %i", item_id, unique_id, quantity);
  3027. client->SellItem(item_id, quantity, unique_id);
  3028. }
  3029. break;
  3030. }
  3031. case COMMAND_MENDER_REPAIR: {
  3032. if (sep && sep->arg[0] && sep->IsNumber(0))
  3033. client->RepairItem(atoul(sep->arg[0]));
  3034. break;
  3035. }
  3036. case COMMAND_MENDER_REPAIR_ALL: {
  3037. client->RepairAllItems();
  3038. break;
  3039. }
  3040. case COMMAND_CANCEL_MERCHANT:{
  3041. client->SetMerchantTransaction(0);
  3042. break;
  3043. }
  3044. case COMMAND_START_MERCHANT:{
  3045. break;
  3046. }
  3047. case COMMAND_INVULNERABLE:{
  3048. sint8 val = -1;
  3049. if(sep && sep->arg[0] && sep->IsNumber(0)){
  3050. val = atoi(sep->arg[0]);
  3051. //devn00b: Fix for linux builds
  3052. #if defined(__GNUC__)
  3053. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? (char*) "1" : (char*) "0");
  3054. #else
  3055. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  3056. #endif
  3057. // database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  3058. client->GetPlayer()->SetInvulnerable(val==1);
  3059. if(client->GetPlayer()->GetInvulnerable())
  3060. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are now invulnerable!");
  3061. else
  3062. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are no longer invulnerable!");
  3063. }
  3064. if(val == -1)
  3065. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /invulnerable [0/1]");
  3066. break;
  3067. }
  3068. case COMMAND_REPAIR: {
  3069. Spawn* spawn = cmdTarget;
  3070. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR) {
  3071. client->SendHailCommand(spawn);
  3072. client->SetMerchantTransaction(spawn);
  3073. client->SendRepairList();
  3074. }
  3075. break;
  3076. }
  3077. case COMMAND_LOTTO: {
  3078. Spawn* spawn = cmdTarget;
  3079. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_LOTTO) {
  3080. client->SetMerchantTransaction(spawn);
  3081. client->ShowLottoWindow();
  3082. }
  3083. break;
  3084. }
  3085. case COMMAND_ACCEPT_REWARD:{
  3086. int32 unknown = 0;
  3087. int32 selectable_item_id = 0;
  3088. //Quest *quest = 0;
  3089. Collection *collection = 0;
  3090. /* no idea what the first argument is for (faction maybe?)
  3091. if the reward has a selectable item reward, it's sent as the second argument
  3092. if neither of these are included in the reward, there is no sep
  3093. 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
  3094. only 1 quest or collection reward may be displayed at a time */
  3095. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  3096. unknown = atoul(sep->arg[0]);
  3097. selectable_item_id = atoul(sep->arg[1]);
  3098. }
  3099. //if ((quest = player->GetPendingQuestReward()))
  3100. // client->AcceptQuestRewards(quest, selectable_item_id);
  3101. /* the below needs to go away eventually and be redone */
  3102. int32 item_id = 0;
  3103. if(sep && sep->arg[0][0] && sep->IsNumber(0))
  3104. item_id = atoul(sep->arg[0]);
  3105. Quest* quest = client->GetPendingQuestAcceptance(item_id);
  3106. if(quest){
  3107. client->AcceptQuestReward(quest, item_id);
  3108. break;
  3109. }
  3110. bool collectedItems = false;
  3111. if (collection = player->GetPendingCollectionReward())
  3112. client->AcceptCollectionRewards(collection, selectable_item_id);
  3113. else if (client->GetPlayer()->HasPendingItemRewards()) {
  3114. vector<Item*> items = client->GetPlayer()->GetPendingItemRewards();
  3115. if (items.size() > 0) {
  3116. collectedItems = true;
  3117. for (int i = 0; i < items.size(); i++) {
  3118. client->GetPlayer()->AddItem(new Item(items[i]));
  3119. }
  3120. client->GetPlayer()->ClearPendingItemRewards();
  3121. }
  3122. map<int32, Item*> selectable_item = client->GetPlayer()->GetPendingSelectableItemReward(item_id);
  3123. if (selectable_item.size() > 0) {
  3124. collectedItems = true;
  3125. map<int32, Item*>::iterator itr;
  3126. for (itr = selectable_item.begin(); itr != selectable_item.end(); itr++) {
  3127. client->GetPlayer()->AddItem(new Item(itr->second));
  3128. client->GetPlayer()->ClearPendingSelectableItemRewards(itr->first);
  3129. }
  3130. }
  3131. }
  3132. if (collectedItems) {
  3133. EQ2Packet* outapp = client->GetPlayer()->SendInventoryUpdate(client->GetVersion());
  3134. if (outapp)
  3135. client->QueuePacket(outapp);
  3136. }
  3137. else
  3138. LogWrite(COMMAND__ERROR, 0, "Command", "Error in COMMAND_ACCEPT_REWARD. No pending quest or collection reward was found (unknown=%u).", unknown);
  3139. break;
  3140. }
  3141. case COMMAND_BUY_FROM_BROKER:{
  3142. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  3143. int32 item_id = atoul(sep->arg[0]);
  3144. int16 quantity = atoul(sep->arg[1]);
  3145. client->AddItem(item_id, quantity);
  3146. }
  3147. break;
  3148. }
  3149. case COMMAND_SEARCH_STORES_PAGE:{
  3150. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  3151. int32 page = atoul(sep->arg[0]);
  3152. client->SearchStore(page);
  3153. }
  3154. break;
  3155. }
  3156. case COMMAND_SEARCH_STORES:{
  3157. if(sep && sep->arg[0][0]){
  3158. const char* values = sep->argplus[0];
  3159. if(values){
  3160. map<string, string> str_values = TranslateBrokerRequest(values);
  3161. vector<Item*>* items = master_item_list.GetItems(str_values);
  3162. if(items){
  3163. client->SetItemSearch(items);
  3164. client->SearchStore(0);
  3165. }
  3166. }
  3167. }
  3168. break;
  3169. }
  3170. case COMMAND_LUADEBUG:{
  3171. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "start") == 0){
  3172. client->SetLuaDebugClient(true);
  3173. if(lua_interface)
  3174. lua_interface->UpdateDebugClients(client);
  3175. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will now receive LUA error messages.");
  3176. }
  3177. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "stop") == 0){
  3178. client->SetLuaDebugClient(false);
  3179. if(lua_interface)
  3180. lua_interface->RemoveDebugClients(client);
  3181. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will no longer receive LUA error messages.");
  3182. }
  3183. else{
  3184. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /luadebug {start | stop}");
  3185. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will allow you to receive lua debug messages normally seen only in the console.");
  3186. }
  3187. break;
  3188. }
  3189. case COMMAND_SPAWN_GROUP:
  3190. {
  3191. Spawn* target = cmdTarget;
  3192. if(target && target->IsPlayer() == false)
  3193. {
  3194. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "create") == 0)
  3195. {
  3196. if(target->GetSpawnLocationPlacementID() > 0)
  3197. {
  3198. if(sep->arg[1] && !sep->IsNumber(1) && strlen(sep->arg[1]) > 0)
  3199. {
  3200. int32 id = database.CreateSpawnGroup(target, sep->arg[1]);
  3201. if(id > 0)
  3202. client->Message(CHANNEL_COLOR_YELLOW, "Successfully created new spawn group with id: %u", id);
  3203. else
  3204. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error creating group, check console for details.");
  3205. target->SetSpawnGroupID(id);
  3206. target->AddSpawnToGroup(target);
  3207. }
  3208. else
  3209. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group create [name]");
  3210. }
  3211. else
  3212. 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.");
  3213. }
  3214. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "add") == 0)
  3215. {
  3216. if(sep->arg[1] && sep->IsNumber(1))
  3217. {
  3218. int32 group_id = atoul(sep->arg[1]);
  3219. Spawn* leader = client->GetCurrentZone()->GetSpawnGroup(group_id);
  3220. if(leader)
  3221. {
  3222. leader->AddSpawnToGroup(target);
  3223. target->SetSpawnGroupID(group_id);
  3224. if(database.SpawnGroupAddSpawn(target, group_id))
  3225. client->Message(CHANNEL_COLOR_YELLOW, "Successfully added '%s' to group id: %u", target->GetName(), group_id);
  3226. else
  3227. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error adding spawn to group, check console for details.");
  3228. }
  3229. else
  3230. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No spawns found in the current zone for that spawn group, be sure to use '/spawn group create' first!");
  3231. }
  3232. else
  3233. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group add [group id]");
  3234. }
  3235. else if(target->GetSpawnGroupID() == 0)
  3236. {
  3237. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That spawn is not in a group!");
  3238. }
  3239. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "remove") == 0)
  3240. {
  3241. int32 group_id = target->GetSpawnGroupID();
  3242. target->RemoveSpawnFromGroup();
  3243. if(database.SpawnGroupRemoveSpawn(target, group_id))
  3244. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed '%s' from group id: %u", target->GetName(), group_id);
  3245. else
  3246. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing spawn from group, check console for details.");
  3247. }
  3248. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "associate") == 0)
  3249. {
  3250. int32 group_id = target->GetSpawnGroupID();
  3251. if(sep->arg[1] && sep->IsNumber(1))
  3252. {
  3253. if(database.SpawnGroupAddAssociation(group_id, atoul(sep->arg[1])))
  3254. client->Message(CHANNEL_COLOR_YELLOW, "Successfully associated group id %u with group id %u", group_id, atoul(sep->arg[1]));
  3255. else
  3256. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error associating groups, check console for details.");
  3257. }
  3258. else
  3259. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Allows you to spawn only one associated group at once. Syntax: /spawn group associate [other group id]");
  3260. }
  3261. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "deassociate") == 0)
  3262. {
  3263. int32 group_id = target->GetSpawnGroupID();
  3264. if(sep->arg[1] && sep->IsNumber(1))
  3265. {
  3266. if(database.SpawnGroupRemoveAssociation(group_id, atoul(sep->arg[1])))
  3267. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed association between group id %u and group id %u", group_id, atoul(sep->arg[1]));
  3268. else
  3269. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing group associations, check console for details.");
  3270. }
  3271. else
  3272. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Removes previous group associations. Syntax: /spawn group deassociate [other group id]");
  3273. }
  3274. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "chance") == 0)
  3275. {
  3276. if(sep->arg[1] && sep->IsNumber(1))
  3277. {
  3278. if(database.SetGroupSpawnChance(target->GetSpawnGroupID(), atof(sep->arg[1])))
  3279. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set group spawn chance to %f for group id: %u", atof(sep->arg[1]), target->GetSpawnGroupID());
  3280. else
  3281. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error setting group spawn chance, check console for details.");
  3282. }
  3283. else
  3284. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group chance [group's spawn chance percentage]");
  3285. }
  3286. else
  3287. {
  3288. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command allows you to modify spawn groups.");
  3289. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group [create/add/remove/chance/associate/deassociate]");
  3290. }
  3291. }
  3292. else
  3293. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select a valid spawn to use this command.");
  3294. break;
  3295. }
  3296. case COMMAND_SPAWN_COMBINE:{
  3297. Spawn* spawn = cmdTarget;
  3298. float radius = 0;
  3299. bool failed = true;
  3300. if(spawn && !spawn->IsPlayer() && sep && sep->arg[0] && sep->arg[0][0]){
  3301. failed = false;
  3302. if(spawn->GetSpawnGroupID() > 0){
  3303. 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.");
  3304. }
  3305. else if(sep->IsNumber(0)){
  3306. radius = atof(sep->arg[0]);
  3307. client->CombineSpawns(radius, spawn);
  3308. }
  3309. else{
  3310. if(strncasecmp(sep->arg[0], "add", 3) == 0){
  3311. client->AddCombineSpawn(spawn);
  3312. }
  3313. else if(strncasecmp(sep->arg[0], "remove", 6) == 0){
  3314. client->RemoveCombineSpawn(spawn);
  3315. }
  3316. else if(strncasecmp(sep->arg[0], "save", 4) == 0){
  3317. const char* name = 0;
  3318. if(sep->arg[1] && sep->arg[1][0])
  3319. name = sep->argplus[1];
  3320. client->SaveCombineSpawns(name);
  3321. }
  3322. else
  3323. failed = true;
  3324. }
  3325. }
  3326. if(failed){
  3327. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command combines several spawns into a single spawn group.");
  3328. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn combine [radius/add/remove/save]");
  3329. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Ex: /spawn combine 1, /spawn combine save (spawn group name)");
  3330. }
  3331. break;
  3332. }
  3333. case COMMAND_SPAWN_CREATE:{
  3334. Spawn* spawn = 0;
  3335. if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "object", 6) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  3336. spawn = new Object();
  3337. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3338. }
  3339. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "groundspawn", 11) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  3340. spawn = new GroundSpawn();
  3341. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3342. }
  3343. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "sign", 4) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  3344. spawn = new Sign();
  3345. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3346. }
  3347. else if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "npc", 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  3348. spawn = new NPC();
  3349. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3350. spawn->appearance.pos.collision_radius = 32;
  3351. spawn->secondary_command_list_id = 0;
  3352. spawn->primary_command_list_id = 0;
  3353. spawn->appearance.display_name = 1;
  3354. spawn->appearance.show_level = 1;
  3355. spawn->appearance.attackable = 1;
  3356. }
  3357. else{
  3358. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn create [spawn type] [race type] [class type] [level] [name] (difficulty) (size)");
  3359. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are required except difficulty and size. Valid types are Object, NPC, Sign, or GroundSpawn");
  3360. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn create npc 203 1 50 'Lady Vox' 1 32");
  3361. break;
  3362. }
  3363. spawn->SetID(Spawn::NextID());
  3364. spawn->SetX(client->GetPlayer()->GetX());
  3365. spawn->SetY(client->GetPlayer()->GetY());
  3366. spawn->SetZ(client->GetPlayer()->GetZ());
  3367. spawn->SetHeading(client->GetPlayer()->GetHeading());
  3368. spawn->SetSpawnOrigX(spawn->GetX());
  3369. spawn->SetSpawnOrigY(spawn->GetY());
  3370. spawn->SetSpawnOrigZ(spawn->GetZ());
  3371. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  3372. spawn->appearance.targetable = 1;
  3373. spawn->appearance.race = 255;
  3374. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  3375. spawn->SetModelType(atoi(sep->arg[1]));
  3376. spawn->SetAdventureClass(atoi(sep->arg[2]));
  3377. spawn->SetLevel(atoi(sep->arg[3]));
  3378. spawn->SetName(sep->arg[4]);
  3379. if(sep->arg[5][0] && sep->IsNumber(5))
  3380. spawn->SetEncounterLevel(atoi(sep->arg[5]));
  3381. if(sep->arg[6][0] && sep->IsNumber(6))
  3382. spawn->size = atoi(sep->arg[6]);
  3383. if(spawn->GetTotalHP() == 0){
  3384. spawn->SetTotalHP(25*spawn->GetLevel() + 1);
  3385. spawn->SetHP(25*spawn->GetLevel() + 1);
  3386. }
  3387. if(spawn->GetTotalPower() == 0){
  3388. spawn->SetTotalPower(25*spawn->GetLevel() + 1);
  3389. spawn->SetPower(25*spawn->GetLevel() + 1);
  3390. }
  3391. client->GetCurrentZone()->AddSpawn(spawn);
  3392. break;
  3393. }
  3394. case COMMAND_SPAWN_EQUIPMENT:{
  3395. Spawn* spawn = cmdTarget;
  3396. if(spawn && sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1) && spawn->IsEntity()){
  3397. int8 slot = atoi(sep->arg[0]);
  3398. int16 type = atoi(sep->arg[1]);
  3399. int8 red = 0;
  3400. int8 green = 0;
  3401. int8 blue = 0;
  3402. int8 h_red = 0;
  3403. int8 h_green = 0;
  3404. int8 h_blue = 0;
  3405. if(sep->arg[2])
  3406. red = atoi(sep->arg[2]);
  3407. if(sep->arg[3])
  3408. green = atoi(sep->arg[3]);
  3409. if(sep->arg[4])
  3410. blue = atoi(sep->arg[4]);
  3411. if(sep->arg[5])
  3412. h_red = atoi(sep->arg[5]);
  3413. if(sep->arg[6])
  3414. h_green = atoi(sep->arg[6]);
  3415. if(sep->arg[7])
  3416. h_blue = atoi(sep->arg[7]);
  3417. ((Entity*)spawn)->SetEquipment(slot, type, red, green, blue, h_red, h_green, h_blue);
  3418. database.SaveNPCAppearanceEquipment(spawn->GetDatabaseID() , slot, type, red, green, blue, h_red, h_green, h_blue);
  3419. }
  3420. else{
  3421. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn equipment [slot] [appearance id] (red) (green) (blue) (highlight red) (hgreen) (hblue)");
  3422. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn's equipment. ");
  3423. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Slot is 0-24, Appearance ID from appearances table, Colors are 0-255");
  3424. }
  3425. break;
  3426. }
  3427. case COMMAND_SPAWN_DETAILS: {
  3428. Spawn* spawn = cmdTarget;
  3429. if (sep && sep->arg[0][0]) {
  3430. if (cmdTarget)
  3431. {
  3432. if (ToLower(string(sep->arg[0])) == "los")
  3433. {
  3434. bool hasLOS = client->GetPlayer()->CheckLoS(cmdTarget);
  3435. if (hasLOS)
  3436. client->Message(CHANNEL_COLOR_YELLOW, "You have line of sight with %s", spawn->GetName());
  3437. else
  3438. client->Message(CHANNEL_COLOR_RED, "You DO NOT have line of sight with %s", spawn->GetName());
  3439. break;
  3440. }
  3441. else if (ToLower(string(sep->arg[0])) == "bestz")
  3442. {
  3443. glm::vec3 targPos(cmdTarget->GetX(), cmdTarget->GetZ(), cmdTarget->GetY());
  3444. float bestZ = client->GetPlayer()->FindDestGroundZ(targPos, cmdTarget->GetYOffset());
  3445. client->Message(CHANNEL_COLOR_YELLOW, "Best Z for %s is %f", spawn->GetName(), bestZ);
  3446. break;
  3447. }
  3448. else if (ToLower(string(sep->arg[0])) == "inwater")
  3449. {
  3450. if (cmdTarget->GetRegionMap() == nullptr)
  3451. client->SimpleMessage(CHANNEL_COLOR_RED, "No water map for zone.");
  3452. else
  3453. {
  3454. bool inWater = cmdTarget->InWater();
  3455. client->Message(CHANNEL_COLOR_YELLOW, "%s is %s.", cmdTarget->GetName(), inWater ? "in water" : "out of water");
  3456. }
  3457. break;
  3458. }
  3459. else if (ToLower(string(sep->arg[0])) == "inlava")
  3460. {
  3461. if (cmdTarget->GetRegionMap() == nullptr)
  3462. client->SimpleMessage(CHANNEL_COLOR_RED, "No region map for zone.");
  3463. else
  3464. {
  3465. bool inLava = cmdTarget->InLava();
  3466. client->Message(CHANNEL_COLOR_YELLOW, "%s is %s.", cmdTarget->GetName(), inLava ? "in lava" : "out of lava");
  3467. }
  3468. break;
  3469. }
  3470. else if (ToLower(string(sep->arg[0])) == "regions")
  3471. {
  3472. glm::vec3 targPos(cmdTarget->GetX(), cmdTarget->GetY(), cmdTarget->GetZ());
  3473. if (cmdTarget->GetRegionMap() == nullptr)
  3474. client->SimpleMessage(CHANNEL_COLOR_RED, "No region map for zone.");
  3475. else
  3476. {
  3477. cmdTarget->GetRegionMap()->IdentifyRegionsInGrid(client, targPos);
  3478. }
  3479. break;
  3480. }
  3481. else if (ToLower(string(sep->arg[0])) == "pathto")
  3482. {
  3483. break;
  3484. }
  3485. else if (ToLower(string(sep->arg[0])) == "pathfrom")
  3486. {
  3487. break;
  3488. }
  3489. }
  3490. if (sep->IsNumber(0))
  3491. {
  3492. float radius = atof(sep->arg[0]);
  3493. if (!client->GetCurrentZone()->SendRadiusSpawnInfo(client, radius))
  3494. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No results in the radius were found.");
  3495. break;
  3496. }
  3497. }
  3498. if (spawn) {
  3499. const char* type = "NPC";
  3500. if (spawn->IsObject())
  3501. type = "Object";
  3502. else if (spawn->IsSign())
  3503. type = "Sign";
  3504. else if (spawn->IsWidget())
  3505. type = "Widget";
  3506. else if (spawn->IsGroundSpawn())
  3507. type = "GroundSpawn";
  3508. client->Message(CHANNEL_COLOR_YELLOW, "Name: %s, %s ID: %u", spawn->GetName(), type, spawn->GetDatabaseID());
  3509. client->Message(CHANNEL_COLOR_YELLOW, "Last Name: %s, Sub-Title: %s, Prefix: %s, Suffix: %s", spawn->GetLastName(), spawn->GetSubTitle(), spawn->GetPrefixTitle(), spawn->GetSuffixTitle());
  3510. client->Message(CHANNEL_COLOR_YELLOW, "Spawn Location ID: %u, Spawn Group ID: %u", spawn->GetSpawnLocationID(), spawn->GetSpawnGroupID());
  3511. client->Message(CHANNEL_COLOR_YELLOW, "Faction ID: %u, Merchant ID: %u, Transporter ID: %u", spawn->GetFactionID(), spawn->GetMerchantID(), spawn->GetTransporterID());
  3512. client->Message(CHANNEL_COLOR_YELLOW, "Grid ID: %u", spawn->GetLocation());
  3513. client->Message(CHANNEL_COLOR_YELLOW, "Race: %i, Class: %i, Gender: %i", spawn->GetRace(), spawn->GetAdventureClass(), spawn->GetGender());
  3514. client->Message(CHANNEL_COLOR_YELLOW, "Level: %i, HP: %u, Power: %u", spawn->GetLevel(), spawn->GetHP(), spawn->GetPower());
  3515. 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());
  3516. client->Message(CHANNEL_COLOR_YELLOW, "Collision Radius: %i, Size: %i, Difficulty: %i, Heroic: %i", spawn->GetCollisionRadius(), spawn->GetSize(), spawn->GetEncounterLevel(), spawn->GetHeroic());
  3517. client->Message(CHANNEL_COLOR_YELLOW, "Targetable: %i, Show Name: %i, Attackable: %i, Show Level: %i", spawn->GetTargetable(), spawn->GetShowName(), spawn->GetAttackable(), spawn->GetShowLevel());
  3518. client->Message(CHANNEL_COLOR_YELLOW, "Show Command Icon: %i, Display Hand Icon: %i", spawn->GetShowCommandIcon(), spawn->GetShowHandIcon());
  3519. if (spawn->IsEntity()) {
  3520. 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());
  3521. 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());
  3522. }
  3523. client->Message(CHANNEL_COLOR_YELLOW, "Model Type: %i, Soga Race Type: %i", spawn->GetModelType(), spawn->GetSogaModelType());
  3524. client->Message(CHANNEL_COLOR_YELLOW, "Primary Command Type: %u, Secondary Command Type: %u", spawn->GetPrimaryCommandListID(), spawn->GetSecondaryCommandListID());
  3525. 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());
  3526. 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);
  3527. if (spawn->IsNPC())
  3528. client->Message(CHANNEL_COLOR_YELLOW, "Randomize: %u", ((NPC*)spawn)->GetRandomize());
  3529. string details;
  3530. details += "\\#0000FFName: " + string(spawn->GetName()) + "\n";
  3531. details += "Type: " + string(type) + "\n";
  3532. details += "ID: " + to_string(spawn->GetDatabaseID()) + "\n";
  3533. details += "Last Name: " + string(spawn->GetLastName()) + "\n";
  3534. details += "Sub-Title: " + string(spawn->GetSubTitle()) + "\n";
  3535. details += "Prefix: " + string(spawn->GetPrefixTitle()) + "\n";
  3536. details += "Suffix: " + string(spawn->GetSuffixTitle()) + "\n";
  3537. details += "Race: " + to_string(spawn->GetRace()) + "\n";
  3538. details += "Class: " + to_string(spawn->GetAdventureClass()) + "\n";
  3539. details += "Gender: " + to_string(spawn->GetGender()) + "\n";
  3540. details += "Level: " + to_string(spawn->GetLevel()) + "\n";
  3541. details += "HP: " + to_string(spawn->GetHP()) + "\n";
  3542. details += "Power: " + to_string(spawn->GetPower()) + "\n";
  3543. details += "Difficulty: " + to_string(spawn->GetEncounterLevel()) + "\n";
  3544. details += "Heroic: " + to_string(spawn->GetHeroic()) + "\n";
  3545. details += "Group ID: " + to_string(spawn->GetSpawnGroupID()) + "\n";
  3546. details += "Faction ID: " + to_string(spawn->GetFactionID()) + "\n";
  3547. details += "Merchant ID: " + to_string(spawn->GetMerchantID()) + "\n";
  3548. details += "Transport ID: " + to_string(spawn->GetTransporterID()) + "\n";
  3549. details += "Location ID: " + to_string(spawn->GetSpawnLocationID()) + "\n";
  3550. char x[16];
  3551. sprintf(x, "%.2f", spawn->GetX());
  3552. char y[16];
  3553. sprintf(y, "%.2f", spawn->GetY());
  3554. char z[16];
  3555. sprintf(z, "%.2f", spawn->GetZ());
  3556. details += "Location: " + string(x) + ", " + string(y) + ", " + string(z) + "\n";
  3557. string details2;
  3558. details2 += "Heading: " + to_string(spawn->GetHeading()) + "\n";
  3559. details2 += "Grid ID: " + to_string(spawn->GetLocation()) + "\n";
  3560. details2 += "Size: " + to_string(spawn->GetSize()) + "\n";
  3561. details2 += "Collision Radius: " + to_string(spawn->GetCollisionRadius()) + "\n";
  3562. details2 += "Respawn Time: " + to_string(spawn->GetRespawnTime()) + "\n";
  3563. details2 += "Targetable: " + to_string(spawn->GetTargetable()) + "\n";
  3564. details2 += "Show Name: " + to_string(spawn->GetShowName()) + "\n";
  3565. details2 += "Attackable: " + to_string(spawn->GetAttackable()) + "\n";
  3566. details2 += "Show Level: " + to_string(spawn->GetShowLevel()) + "\n";
  3567. details2 += "Show Command Icon: " + to_string(spawn->GetShowCommandIcon()) + "\n";
  3568. details2 += "Display Hand Icon: " + to_string(spawn->GetShowHandIcon()) + "\n";
  3569. details2 += "Model Type: " + to_string(spawn->GetModelType()) + "\n";
  3570. details2 += "Soga Race Type: " + to_string(spawn->GetSogaModelType()) + "\n";
  3571. details2 += "Primary Command ID: " + to_string(spawn->GetPrimaryCommandListID()) + "\n";
  3572. details2 += "Secondary Cmd ID: " + to_string(spawn->GetSecondaryCommandListID()) + "\n";
  3573. details2 += "Visual State: " + to_string(spawn->GetVisualState()) + "\n";
  3574. details2 += "Action State: " + to_string(spawn->GetActionState()) + "\n";
  3575. details2 += "Mood State: " + to_string(spawn->GetMoodState()) + "\n";
  3576. details2 += "Initial State: " + to_string(spawn->GetInitialState()) + "\n";
  3577. details2 += "Activity Status: " + to_string(spawn->GetActivityStatus()) + "\n";
  3578. details2 += "Emote State: " + to_string(spawn->GetEmoteState()) + "\n";
  3579. string details3;
  3580. details3 += "Pitch: " + to_string(spawn->GetPitch()) + "\n";
  3581. details3 += "Roll: " + to_string(spawn->GetRoll()) + "\n";
  3582. details3 += "Hide Hood: " + to_string(spawn->appearance.hide_hood) + "\n";
  3583. string details4;
  3584. if (spawn->IsEntity()) {
  3585. details4 += "Facial Hair Type: " + to_string(((Entity*)spawn)->GetFacialHairType()) + "\n";
  3586. details4 += "Hair Type: " + to_string(((Entity*)spawn)->GetHairType()) + "\n";
  3587. details4 += "Chest Type: " + to_string(((Entity*)spawn)->GetChestType()) + "\n";
  3588. details4 += "Legs Type: " + to_string(((Entity*)spawn)->GetLegsType()) + "\n";
  3589. details4 += "Soga Facial Hair Type: " + to_string(((Entity*)spawn)->GetSogaFacialHairType()) + "\n";
  3590. details4 += "Soga Hair Type: " + to_string(((Entity*)spawn)->GetSogaHairType()) + "\n";
  3591. details4 += "Wing Type: " + to_string(((Entity*)spawn)->GetWingType()) + "\n";
  3592. if (spawn->IsNPC()) {
  3593. details4 += "\nRandomize: " + to_string(((NPC*)spawn)->GetRandomize()) + "\n";
  3594. }
  3595. }
  3596. string title = string(spawn->GetName()) + "(" + to_string(spawn->GetDatabaseID()) + ")";
  3597. client->SendShowBook(client->GetPlayer(), title, 4, details, details2, details3, details4);
  3598. }
  3599. else {
  3600. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn details (radius)");
  3601. 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.");
  3602. }
  3603. break;
  3604. }
  3605. case COMMAND_SPAWN_TARGET:{
  3606. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  3607. int32 spawn_id = atoul(sep->arg[0]);
  3608. int16 response = client->GetCurrentZone()->SetSpawnTargetable(spawn_id);
  3609. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  3610. }
  3611. else if(sep && sep->arg[0][0] && sep->arg[1][0] && sep->IsNumber(1) && ToLower(string(sep->arg[0])) == "radius"){
  3612. float distance = atof(sep->arg[1]);
  3613. int16 response = client->GetCurrentZone()->SetSpawnTargetable(client->GetPlayer(), distance);
  3614. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  3615. }
  3616. else{
  3617. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn target [spawn id]");
  3618. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn as targetable. Used to change a spawn if it was set to untargetable.");
  3619. }
  3620. break;
  3621. }
  3622. case COMMAND_SPAWN_SET:
  3623. {
  3624. Spawn* spawn = cmdTarget;
  3625. sint16 set_type = -1;
  3626. string type_str;
  3627. if (spawn)
  3628. {
  3629. // check if parameters are (location or list or not player and not a 2nd param), and that there is at least 1 value
  3630. 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)
  3631. {
  3632. // set the type, which will be 0 if location or list or invalid
  3633. set_type = spawn_set_values[ToLower(string(sep->arg[0]))];
  3634. }
  3635. if(set_type > 0)
  3636. {
  3637. // check if spawn set is NOT a char update, or not location, or isn't a number
  3638. 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)
  3639. {
  3640. client->SimpleMessage(CHANNEL_COLOR_RED, "Invalid value for set command.");
  3641. }
  3642. else
  3643. {
  3644. string name = string(spawn->GetName());
  3645. if(SetSpawnCommand(client, spawn, set_type, sep->argplus[1]))
  3646. {
  3647. if (set_type == SPAWN_SET_VALUE_EXPANSION_FLAG || set_type == SPAWN_SET_VALUE_HOLIDAY_FLAG)
  3648. {
  3649. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "A /reload spawns is required to properly update the spawns with the xpack/holiday flag.");
  3650. }
  3651. else if (set_type == SPAWN_SET_VALUE_NAME)
  3652. {
  3653. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "New name will not be effective until zone reload.");
  3654. }
  3655. else if (set_type == SPAWN_SET_SKIN_COLOR)
  3656. {
  3657. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set skin_color to R G B: %s.", sep->argplus[1]);
  3658. }
  3659. else if(set_type == SPAWN_SET_VALUE_LOCATION)
  3660. {
  3661. spawn->SetLocation(client->GetPlayer()->GetLocation());
  3662. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set '%s' to '%u' for spawn '%s'", sep->arg[0], client->GetPlayer()->GetLocation(), name.c_str());
  3663. }
  3664. else
  3665. {
  3666. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set '%s' to '%s' for spawn '%s'", sep->arg[0], sep->arg[1], name.c_str());
  3667. }
  3668. switch (set_type)
  3669. {
  3670. case SPAWN_SET_VALUE_EXPANSION_FLAG:
  3671. case SPAWN_SET_VALUE_HOLIDAY_FLAG:
  3672. case SPAWN_SET_VALUE_FACTION:
  3673. {
  3674. // not applicable
  3675. break;
  3676. }
  3677. default:
  3678. {
  3679. client->GetCurrentZone()->ApplySetSpawnCommand(client, spawn, set_type, sep->argplus[1]);
  3680. break;
  3681. }
  3682. }
  3683. 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))
  3684. {
  3685. if(spawn->GetSpawnLocationID() > 0 && database.UpdateSpawnLocationSpawns(spawn))
  3686. {
  3687. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information.");
  3688. }
  3689. else if(spawn->GetSpawnLocationID() > 0)
  3690. {
  3691. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn information, see console window for details.");
  3692. }
  3693. }
  3694. else
  3695. {
  3696. if(spawn->GetDatabaseID() > 0 && database.SaveSpawnInfo(spawn))
  3697. {
  3698. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully saved spawn.");
  3699. }
  3700. else if(spawn->GetDatabaseID() > 0)
  3701. {
  3702. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn, see console window for details.");
  3703. }
  3704. }
  3705. }
  3706. }
  3707. }
  3708. else if(set_type == 0)
  3709. {
  3710. // /spawn set list - lists all possible attributes that can be changed with this command, 10 per line.
  3711. map<string, int8>::iterator itr;
  3712. int i=0;
  3713. string list;
  3714. for(itr = spawn_set_values.begin(); itr != spawn_set_values.end(); itr++, i++)
  3715. {
  3716. if(i==10)
  3717. {
  3718. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  3719. i = 0;
  3720. }
  3721. if(i>0)
  3722. {
  3723. list.append(", ").append(itr->first);
  3724. }
  3725. else
  3726. {
  3727. list = itr->first;
  3728. }
  3729. }
  3730. if(list.length() > 0)
  3731. {
  3732. // if 1 or more, display in client.
  3733. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  3734. }
  3735. }
  3736. else
  3737. {
  3738. // syntax fail
  3739. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn set [type] [value]");
  3740. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used to change various settings for the targeted NPC or Object.");
  3741. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "For a list of changeable settings use /spawn set list");
  3742. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Note: /spawn set location does not require a value. The client's current location is used.");
  3743. }
  3744. }
  3745. break;
  3746. }
  3747. case COMMAND_SPAWN_REMOVE:{
  3748. Spawn* spawn = cmdTarget;
  3749. if(spawn && !spawn->IsPlayer()){
  3750. if(spawn->GetSpawnLocationID() > 0){
  3751. if(database.RemoveSpawnFromSpawnLocation(spawn)){
  3752. client->GetCurrentZone()->RemoveSpawn(false, spawn, true, false);
  3753. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully removed spawn from zone");
  3754. }
  3755. else
  3756. client->SimpleMessage(CHANNEL_COLOR_RED, "Error removing spawn, see console window for details.");
  3757. }
  3758. else
  3759. client->SimpleMessage(CHANNEL_COLOR_RED, "This spawn does not have a spawn group associated with it");
  3760. }
  3761. else{
  3762. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn remove");
  3763. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for removing the targeted NPC or Object from the zone.");
  3764. }
  3765. break;
  3766. }
  3767. case COMMAND_SPAWN_LIST:{
  3768. if(sep && sep->arg[0][0]){
  3769. vector<string>* results = database.GetSpawnNameList(sep->argplus[0]);
  3770. vector<string>::iterator itr;
  3771. if(results){
  3772. for(itr=results->begin();itr!=results->end();itr++){
  3773. client->SimpleMessage(CHANNEL_COLOR_YELLOW, (*itr).c_str());
  3774. }
  3775. safe_delete(results);
  3776. }
  3777. else
  3778. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found. ");
  3779. }
  3780. else{
  3781. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn list [name]");
  3782. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Name can be a partial match.");
  3783. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn list Qeynos Guard");
  3784. }
  3785. break;
  3786. }
  3787. case COMMAND_SPAWN_ADD:{
  3788. Spawn* spawn = cmdTarget;
  3789. if(spawn && sep && sep->arg[1][0] && (sep->IsNumber(0) || strncasecmp(sep->arg[0], "new", 3) == 0)){
  3790. if(spawn->GetSpawnLocationID() > 0){
  3791. client->Message(CHANNEL_COLOR_RED, "This spawn already has a spawn group id of %u, use /spawn remove to reassign it", spawn->GetSpawnLocationID());
  3792. break;
  3793. }
  3794. if(spawn->GetDatabaseID() == 0){
  3795. if(database.SaveSpawnInfo(spawn)) {
  3796. char spawn_type[32];
  3797. memset(spawn_type, 0, sizeof(spawn_type));
  3798. if (spawn->IsNPC())
  3799. strncpy(spawn_type, "NPC", sizeof(spawn_type) - 1);
  3800. else if (spawn->IsObject())
  3801. strncpy(spawn_type, "Object", sizeof(spawn_type) - 1);
  3802. else if (spawn->IsSign())
  3803. strncpy(spawn_type, "Sign", sizeof(spawn_type) - 1);
  3804. else if (spawn->IsGroundSpawn())
  3805. strncpy(spawn_type, "GroundSpawn", sizeof(spawn_type) - 1);
  3806. else
  3807. strncpy(spawn_type, "Unknown", sizeof(spawn_type) - 1);
  3808. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information with a %s id of %u", spawn_type, spawn->GetDatabaseID());
  3809. }
  3810. else
  3811. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn information, see console window for details.");
  3812. }
  3813. int32 spawn_group_id = 0;
  3814. if(strncasecmp(sep->arg[0], "new", 3) == 0)
  3815. spawn_group_id = database.GetNextSpawnLocation();
  3816. else
  3817. spawn_group_id = atol(sep->arg[0]);
  3818. int8 percent = 100;
  3819. if(sep->arg[2] && sep->IsNumber(2))
  3820. percent = atoi(sep->arg[2]);
  3821. spawn->SetSpawnLocationID(spawn_group_id);
  3822. float x_offset = database.GetSpawnLocationPlacementOffsetX(spawn->GetSpawnLocationID());
  3823. float y_offset = database.GetSpawnLocationPlacementOffsetY(spawn->GetSpawnLocationID());
  3824. float z_offset = database.GetSpawnLocationPlacementOffsetZ(spawn->GetSpawnLocationID());
  3825. if(database.SaveSpawnEntry(spawn, sep->arg[1], percent, x_offset, y_offset, z_offset))
  3826. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn location with a spawn group of %u", spawn->GetSpawnLocationID());
  3827. else
  3828. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn location, see console window for details.");
  3829. }
  3830. else{
  3831. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn add [spawn group id] [spawn group name] (percentage)");
  3832. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for adding the targeted NPC or Object to the database.");
  3833. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can substitute new for [spawn group id] to create a new one.");
  3834. }
  3835. break;
  3836. }
  3837. case COMMAND_SPAWN:{
  3838. int32 id = 0;
  3839. Spawn* spawn = 0;
  3840. if(sep && sep->arg[0] && sep->IsNumber(0)){
  3841. id = atol(sep->arg[0]);
  3842. spawn = client->GetCurrentZone()->GetSpawn(id);
  3843. }
  3844. if(id > 0 && spawn && spawn->appearance.name[0] == 0)
  3845. id = 0;
  3846. if(!id || !spawn){
  3847. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn [spawn id] (x) (y) (z) (heading) (location)");
  3848. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are optional except the id. The spawn id must be in the database.");
  3849. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn 1 0 0 0 0");
  3850. safe_delete(sep);
  3851. return;
  3852. }
  3853. if(sep && sep->arg[1][0]){
  3854. float x = atof(sep->arg[1]);
  3855. spawn->appearance.pos.X = x;
  3856. }
  3857. else
  3858. spawn->SetX(client->GetPlayer()->GetX(), false);
  3859. if(sep && sep->arg[2][0]){
  3860. float y = atof(sep->arg[2]);
  3861. spawn->appearance.pos.Y = y;
  3862. }
  3863. else
  3864. spawn->SetY(client->GetPlayer()->GetY(), false);
  3865. if(sep && sep->arg[3][0]){
  3866. float z = atof(sep->arg[3]);
  3867. spawn->appearance.pos.Z = z;
  3868. }
  3869. else
  3870. spawn->SetZ(client->GetPlayer()->GetZ(), false);
  3871. if(sep && sep->arg[4][0]){
  3872. float heading = atof(sep->arg[4]);
  3873. spawn->SetHeading(heading);
  3874. }
  3875. else
  3876. spawn->SetHeading(client->GetPlayer()->GetHeading(), false);
  3877. spawn->SetSpawnOrigX(spawn->GetX());
  3878. spawn->SetSpawnOrigY(spawn->GetY());
  3879. spawn->SetSpawnOrigZ(spawn->GetZ());
  3880. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  3881. if(sep && sep->arg[5][0])
  3882. spawn->appearance.pos.grid_id = atol(sep->arg[5]);
  3883. else
  3884. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  3885. if(spawn->IsNPC() && spawn->GetTotalHP() == 0){
  3886. spawn->SetTotalHP(spawn->GetLevel() * 15);
  3887. spawn->SetHP(spawn->GetTotalHP());
  3888. }
  3889. if(spawn->GetTotalPower() == 0){
  3890. spawn->SetTotalPower(spawn->GetLevel() * 15);
  3891. spawn->SetPower(spawn->GetTotalPower());
  3892. }
  3893. const char* script = world.GetSpawnScript(id);
  3894. if(script && lua_interface && lua_interface->GetSpawnScript(script) != 0)
  3895. spawn->SetSpawnScript(string(script));
  3896. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_PRESPAWN);
  3897. client->GetCurrentZone()->AddSpawn(spawn);
  3898. if(spawn->IsNPC())
  3899. spawn->GetZone()->AddLoot((NPC*)spawn);
  3900. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_SPAWN);
  3901. LogWrite(COMMAND__INFO, 0, "Command", "Received spawn command - Parms: %s", command_parms->data.c_str());
  3902. break;
  3903. }
  3904. case COMMAND_ADMINFLAG:
  3905. {
  3906. if(sep && sep->arg[0]){
  3907. sint16 tmp_status = database.GetCharacterAdminStatus(sep->arg[0]);
  3908. sint16 new_status = atoi(sep->arg[1]);
  3909. if(tmp_status == -10)
  3910. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character does not exist.");
  3911. else if(tmp_status >= client->GetAdminStatus())
  3912. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character has same or higher level status.");
  3913. else if (new_status > client->GetAdminStatus())
  3914. client->SimpleMessage(CHANNEL_ERROR, "Unable to flag character. Reason: New status is higher then your status.");
  3915. else{
  3916. Client* client2 = client->GetCurrentZone()->GetClientByName(sep->arg[0]);
  3917. if (!client2)
  3918. client2 = zone_list.GetClientByCharName(sep->arg[0]);
  3919. if(database.UpdateAdminStatus(sep->arg[0],new_status)) {
  3920. client->Message(CHANNEL_COLOR_YELLOW,"Character status updated to %i for %s.",new_status,sep->arg[0]);
  3921. if (client2) {
  3922. client2->SetAdminStatus(new_status);
  3923. client2->Message(CHANNEL_COLOR_YELLOW, "%s has set your admin status to %i.", client->GetPlayer()->GetName(), new_status);
  3924. }
  3925. }
  3926. else
  3927. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Unknown reason.");
  3928. }
  3929. }else{
  3930. sint16 status = database.GetCharacterAdminStatus(client->GetPlayer()->GetName());
  3931. if(status != client->GetAdminStatus())
  3932. {
  3933. client->Message(CHANNEL_COLOR_YELLOW,"Flag status was changed from %i to %i.",status,client->GetAdminStatus());
  3934. client->SetAdminStatus(status);
  3935. }
  3936. else
  3937. {
  3938. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /flag {name} {new_status}");
  3939. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Standard User: 0");
  3940. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Admin User: 100");
  3941. }
  3942. }
  3943. break;
  3944. }
  3945. case COMMAND_CANNEDEMOTE:{
  3946. client->GetCurrentZone()->HandleEmote(client, command_parms->data);
  3947. break;
  3948. }
  3949. case COMMAND_BROADCAST: {
  3950. if (sep && sep->arg[0])
  3951. zone_list.HandleGlobalBroadcast(sep->argplus[0]);
  3952. else
  3953. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /broadcast {message}");
  3954. break;
  3955. }
  3956. case COMMAND_ANNOUNCE: {
  3957. if (sep && sep->arg[0])
  3958. zone_list.HandleGlobalAnnouncement(sep->argplus[0]);
  3959. else
  3960. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /announce {message}");
  3961. break;
  3962. }
  3963. case COMMAND_RELOAD_ITEMS:{
  3964. LogWrite(COMMAND__INFO, 0, "Command", "Reloading items..");
  3965. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Started Reloading items (this might take a few minutes...)");
  3966. database.ReloadItemList();
  3967. database.LoadMerchantInformation();
  3968. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Finished Reloading items.");
  3969. break;
  3970. }
  3971. case COMMAND_ENABLE_ABILITY_QUE:{
  3972. EQ2Packet* app = client->GetPlayer()->GetSpellBookUpdatePacket(client->GetVersion());
  3973. if(app)
  3974. client->QueuePacket(app);
  3975. break;
  3976. }
  3977. case COMMAND_ITEMSEARCH:{
  3978. PacketStruct* packet = configReader.getStruct("WS_StartBroker", client->GetVersion());
  3979. if (packet) {
  3980. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  3981. //packet->setDataByName("unknown", 1);
  3982. packet->setDataByName("unknown2", 5, 0);
  3983. packet->setDataByName("unknown2", 20, 1);
  3984. packet->setDataByName("unknown2", 58, 3);
  3985. packet->setDataByName("unknown2", 40, 4);
  3986. client->QueuePacket(packet->serialize());
  3987. PacketStruct* packet2 = configReader.getStruct("WS_BrokerBags", client->GetVersion());
  3988. if (packet2) {
  3989. packet2->setDataByName("char_id", client->GetCharacterID());
  3990. client->QueuePacket(packet2->serialize()); //send this for now, needed to properly clear data
  3991. safe_delete(packet2);
  3992. }
  3993. safe_delete(packet);
  3994. }
  3995. break;
  3996. }
  3997. case COMMAND_ANIMTEST:{
  3998. PacketStruct* command_packet = configReader.getStruct("WS_CannedEmote", client->GetVersion());
  3999. if(command_packet){
  4000. int32 id = client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer());
  4001. if (cmdTarget)
  4002. id = client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget);
  4003. command_packet->setDataByName ( "spawn_id" , id);
  4004. int animID = 1;
  4005. if(sep && sep->arg[0] && sep->IsNumber(0))
  4006. animID = atoi(sep->arg[0]);
  4007. VisualState* vs = NULL;
  4008. if(animID == 0)
  4009. {
  4010. vs = visual_states.FindVisualState(sep->arg[0]);
  4011. }
  4012. char msg[128];
  4013. sprintf(msg,"Animation Test ID: %i",animID);
  4014. command_packet->setMediumStringByName ( "emote_msg" , msg );
  4015. if(vs != NULL)
  4016. command_packet->setDataByName ( "anim_type", vs->GetID ( ) );
  4017. else
  4018. command_packet->setDataByName ( "anim_type", animID );
  4019. command_packet->setDataByName ( "unknown0", 0 );
  4020. EQ2Packet* outapp = command_packet->serialize();
  4021. client->QueuePacket(outapp);
  4022. safe_delete(command_packet);
  4023. }
  4024. break;
  4025. }
  4026. case COMMAND_KICK:
  4027. {
  4028. if( sep == 0 || sep->arg[0] == 0)
  4029. {
  4030. client->SimpleMessage(CHANNEL_COLOR_RED, "/kick [name]");
  4031. }
  4032. else
  4033. {
  4034. Client* kickClient = zone_list.GetClientByCharName(string(sep->arg[0]));
  4035. if ( kickClient == client )
  4036. {
  4037. client->Message(CHANNEL_COLOR_RED, "You can't kick yourself!");
  4038. break;
  4039. }
  4040. else if(kickClient != NULL)
  4041. {
  4042. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  4043. if ( maxStatus >= client->GetAdminStatus( ) || kickClient->GetAdminStatus() >= client->GetAdminStatus() )
  4044. {
  4045. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  4046. break;
  4047. }
  4048. client->Message(CHANNEL_COLOR_RED, "Kicking %s...",sep->arg[0]);
  4049. kickClient->Disconnect();
  4050. }
  4051. else
  4052. {
  4053. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  4054. }
  4055. }
  4056. break;
  4057. }
  4058. case COMMAND_LOCK:
  4059. {
  4060. if( sep != NULL && sep->arg[0] != NULL && sep->IsNumber(0)){
  4061. int worldLocked = atoi(sep->arg[0]);
  4062. net.world_locked = worldLocked;
  4063. if ( worldLocked )
  4064. client->Message(CHANNEL_COLOR_YELLOW,"World server has been locked.");
  4065. else
  4066. client->Message(CHANNEL_COLOR_YELLOW,"World server has been unlocked.");
  4067. }
  4068. else
  4069. client->SimpleMessage(CHANNEL_COLOR_RED, "/lock [0/1]");
  4070. break;
  4071. }
  4072. case COMMAND_BAN:{
  4073. if( sep == 0 || sep->arg[0] == 0 || (sep->arg[1][0] != 0 && !sep->IsNumber(1) ) )
  4074. {
  4075. client->SimpleMessage(CHANNEL_COLOR_RED, "/ban [name] [permanent:0/1]");
  4076. }
  4077. else
  4078. {
  4079. Client* kickClient = zone_list.GetClientByCharName(sep->arg[0]);
  4080. if ( kickClient == client )
  4081. {
  4082. client->Message(CHANNEL_COLOR_RED, "You can't ban yourself!");
  4083. break;
  4084. }
  4085. else if(kickClient != NULL)
  4086. {
  4087. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  4088. if ( maxStatus > client->GetAdminStatus( ) ||
  4089. client->GetAdminStatus ( ) > kickClient->GetAdminStatus ( ) )
  4090. {
  4091. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  4092. break;
  4093. }
  4094. client->Message(CHANNEL_COLOR_RED, "Kicking & Banning %s...",sep->arg[0]);
  4095. int perm = atol(sep->arg[1]);
  4096. if ( perm == 1 )
  4097. database.UpdateAdminStatus(sep->arg[0],-2);
  4098. else
  4099. database.UpdateAdminStatus(sep->arg[0],-1);
  4100. kickClient->Disconnect();
  4101. }
  4102. else
  4103. {
  4104. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  4105. }
  4106. }
  4107. break;
  4108. }
  4109. case COMMAND_SET_COMBAT_VOICE:{
  4110. int32 value = 0;
  4111. if(sep && sep->arg[0] && sep->IsNumber(0))
  4112. value = atoi(sep->arg[0]);
  4113. client->GetPlayer()->SetCombatVoice(value);
  4114. break;
  4115. }
  4116. case COMMAND_SET_EMOTE_VOICE:{
  4117. int32 value = 0;
  4118. if(sep && sep->arg[0] && sep->IsNumber(0))
  4119. value = atoi(sep->arg[0]);
  4120. client->GetPlayer()->SetEmoteVoice(value);
  4121. break;
  4122. }
  4123. case COMMAND_GIVEITEM:{
  4124. if(sep && sep->arg[0][0] && sep->arg[0][1] && sep->IsNumber(1)){
  4125. Client* itemToClient = zone_list.GetClientByCharName(sep->arg[0]);
  4126. if ( itemToClient == NULL )
  4127. client->Message(CHANNEL_COLOR_YELLOW,"Could not find %s.",sep->arg[0]);
  4128. else
  4129. {
  4130. int32 item_id = atol(sep->arg[1]);
  4131. client->Message(CHANNEL_COLOR_YELLOW,"Gave %s item id %i.",sep->arg[0],item_id);
  4132. itemToClient->AddItem(item_id);
  4133. }
  4134. }
  4135. else
  4136. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /giveitem [name] [item_id]");
  4137. break;
  4138. }
  4139. case COMMAND_REPORT_BUG : { Command_ReportBug(client, sep); break; }
  4140. case COMMAND_INVENTORY : { Command_Inventory(client, sep, command); break; }
  4141. case COMMAND_WEAPONSTATS : { Command_WeaponStats(client); break; }
  4142. case COMMAND_SKILL :
  4143. case COMMAND_SKILL_ADD :
  4144. case COMMAND_SKILL_REMOVE :
  4145. case COMMAND_SKILL_LIST : { Command_Skills(client, sep, command->handler); break; }
  4146. case COMMAND_ZONE_SET : { Command_ZoneSet(client, sep); break; }
  4147. case COMMAND_ZONE_DETAILS : { Command_ZoneDetails(client, sep); break; }
  4148. case COMMAND_ENTITYCOMMAND :
  4149. case COMMAND_ENTITYCOMMAND_LIST : { Command_EntityCommand(client, sep, command->handler); break; }
  4150. case COMMAND_MERCHANT :
  4151. case COMMAND_MERCHANT_LIST : { Command_Merchant(client, sep, command->handler); break; }
  4152. case COMMAND_APPEARANCE :
  4153. case COMMAND_APPEARANCE_LIST : { Command_Appearance(client, sep, command->handler); break; }
  4154. case COMMAND_TRACK : { Command_Track(client); break; }
  4155. case COMMAND_DISTANCE : { Command_Distance(client); break; }
  4156. case COMMAND_INSPECT_PLAYER : { Command_InspectPlayer(client, sep); break; }
  4157. case COMMAND_ZONE_SAFE : { Command_ZoneSafeCoords(client, sep); break; }
  4158. case COMMAND_GUILDSAY : { Command_GuildSay(client, sep); break; }
  4159. case COMMAND_OFFICERSAY : { Command_OfficerSay(client, sep); break; }
  4160. case COMMAND_SET_GUILD_MEMBER_NOTE : { Command_SetGuildMemberNote(client, sep); break; }
  4161. case COMMAND_SET_GUILD_OFFICER_NOTE : { Command_SetGuildOfficerNote(client, sep); break; }
  4162. case COMMAND_GUILD : { Command_Guild(client, sep); break; }
  4163. case COMMAND_CREATE_GUILD : { Command_CreateGuild(client); break; }
  4164. case COMMAND_GUILDS : { Command_Guilds(client); break; }
  4165. case COMMAND_GUILDS_ADD : { Command_GuildsAdd(client, sep); break; }
  4166. case COMMAND_GUILDS_CREATE : { Command_GuildsCreate(client, sep); break; }
  4167. case COMMAND_GUILDS_DELETE : { Command_GuildsDelete(client, sep); break; }
  4168. case COMMAND_GUILDS_LIST : { Command_GuildsList(client); break; }
  4169. case COMMAND_GUILDS_REMOVE : { Command_GuildsRemove(client, sep); break; }
  4170. case COMMAND_CLAIM : { Command_Claim(client, sep); break; }
  4171. case COMMAND_CLEAR_ALL_QUEUED : { Command_ClearAllQueued(client); break; }
  4172. case COMMAND_LOCATION : { Command_Location(client); break; }
  4173. case COMMAND_LOCATION_ADD : { Command_LocationAdd(client, sep); break; }
  4174. case COMMAND_LOCATION_CREATE : { Command_LocationCreate(client, sep); break; }
  4175. case COMMAND_LOCATION_DELETE : { Command_LocationDelete(client, sep); break; }
  4176. case COMMAND_LOCATION_LIST : { Command_LocationList(client, sep); break; }
  4177. case COMMAND_LOCATION_REMOVE : { Command_LocationRemove(client, sep); break; }
  4178. case COMMAND_GRID : { Command_Grid(client); break; }
  4179. case COMMAND_TRY_ON : { Command_TryOn(client, sep); break; }
  4180. case COMMAND_IRC : { Command_IRC(client, sep); break; }
  4181. case COMMAND_RANDOMIZE : { Command_Randomize(client, sep); break; }
  4182. case COMMAND_AFK : { Command_AFK(client, sep); break; }
  4183. case COMMAND_SHOW_CLOAK : { Command_ShowCloak(client, sep); break; }
  4184. case COMMAND_SHOW_HELM : { Command_ShowHelm(client, sep); break; }
  4185. case COMMAND_SHOW_HOOD : { Command_ShowHood(client, sep); break; }
  4186. case COMMAND_SHOW_HOOD_OR_HELM : { Command_ShowHoodHelm(client, sep); break; }
  4187. case COMMAND_SHOW_RANGED : { Command_ShowRanged(client, sep); break; }
  4188. case COMMAND_STOP_DRINKING : { Command_StopDrinking(client); break; }
  4189. case COMMAND_STOP_EATING : { Command_StopEating(client); break; }
  4190. case COMMAND_TOGGLE_ANONYMOUS : { Command_Toggle_Anonymous(client); break; }
  4191. case COMMAND_TOGGLE_AUTOCONSUME : { Command_Toggle_AutoConsume(client, sep); break; }
  4192. case COMMAND_TOGGLE_BONUS_EXP : { Command_Toggle_BonusXP(client); break; }
  4193. case COMMAND_TOGGLE_COMBAT_EXP : { Command_Toggle_CombatXP(client); break; }
  4194. case COMMAND_TOGGLE_GM_HIDE : { Command_Toggle_GMHide(client); break; }
  4195. case COMMAND_TOGGLE_GM_VANISH : { Command_Toggle_GMVanish(client); break; }
  4196. case COMMAND_TOGGLE_ILLUSIONS : { Command_Toggle_Illusions(client, sep); break; }
  4197. case COMMAND_TOGGLE_LFG : { Command_Toggle_LFG(client); break; }
  4198. case COMMAND_TOGGLE_LFW : { Command_Toggle_LFW(client); break; }
  4199. case COMMAND_TOGGLE_QUEST_EXP : { Command_Toggle_QuestXP(client); break; }
  4200. case COMMAND_TOGGLE_ROLEPLAYING : { Command_Toggle_Roleplaying(client); break; }
  4201. case COMMAND_TOGGLE_DUELS : { Command_Toggle_Duels(client); break; }
  4202. case COMMAND_TOGGLE_TRADES : { Command_Toggle_Trades(client); break; }
  4203. case COMMAND_TOGGLE_GUILDS : { Command_Toggle_Guilds(client); break; }
  4204. case COMMAND_TOGGLE_GROUPS : { Command_Toggle_Groups(client); break; }
  4205. case COMMAND_TOGGLE_RAIDS : { Command_Toggle_Raids(client); break; }
  4206. case COMMAND_TOGGLE_LON : { Command_Toggle_LON(client); break; }
  4207. case COMMAND_TOGGLE_VCINVITE : { Command_Toggle_VoiceChat(client); break; }
  4208. case COMMAND_CANCEL_MAINTAINED : { Command_CancelMaintained(client, sep); break; }
  4209. case COMMAND_MOTD : { Command_MOTD(client); break; }
  4210. case COMMAND_RANDOM : { Command_Random(client, sep); break; }
  4211. case COMMAND_CREATE : { Command_Create(client, sep); break; }
  4212. case COMMAND_CREATEFROMRECIPE : { Command_CreateFromRecipe(client, sep); break; }
  4213. case COMMAND_TITLE : { Command_Title(client); break; }
  4214. case COMMAND_TITLE_LIST : { Command_TitleList(client); break; }
  4215. case COMMAND_TITLE_SETPREFIX : { Command_TitleSetPrefix(client, sep); break; }
  4216. case COMMAND_TITLE_SETSUFFIX : { Command_TitleSetSuffix(client, sep); break; }
  4217. case COMMAND_TITLE_FIX : { Command_TitleFix(client, sep); break; }
  4218. case COMMAND_LANGUAGES : { Command_Languages(client, sep); break; }
  4219. case COMMAND_SET_LANGUAGE : { Command_SetLanguage(client, sep); break; }
  4220. case COMMAND_FOLLOW : { Command_Follow(client, sep); break; }
  4221. case COMMAND_STOP_FOLLOW : { Command_StopFollow(client, sep); break; }
  4222. case COMMAND_LASTNAME : { Command_LastName(client, sep); break; }
  4223. case COMMAND_CONFIRMLASTNAME : { Command_ConfirmLastName(client, sep); break; }
  4224. case COMMAND_PET : { Command_Pet(client, sep); break; }
  4225. case COMMAND_PETNAME : { Command_PetName(client, sep); break; }
  4226. case COMMAND_NAME_PET : { Command_NamePet(client, sep); break; }
  4227. case COMMAND_RENAME : { Command_Rename(client, sep); break; }
  4228. case COMMAND_CONFIRMRENAME : { Command_ConfirmRename(client, sep); break; }
  4229. case COMMAND_PETOPTIONS : { Command_PetOptions(client, sep); break; }
  4230. case COMMAND_START_TRADE : { Command_TradeStart(client, sep); break; }
  4231. case COMMAND_ACCEPT_TRADE : { Command_TradeAccept(client, sep); break; }
  4232. case COMMAND_REJECT_TRADE : { Command_TradeReject(client, sep); break; }
  4233. case COMMAND_CANCEL_TRADE : { Command_TradeCancel(client, sep); break; }
  4234. case COMMAND_SET_TRADE_COIN : { Command_TradeSetCoin(client, sep); break; }
  4235. case COMMAND_ADD_TRADE_COPPER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_COPPER); break; }
  4236. case COMMAND_ADD_TRADE_SILVER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_SILVER); break; }
  4237. case COMMAND_ADD_TRADE_GOLD : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_GOLD); break; }
  4238. case COMMAND_ADD_TRADE_PLAT : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_PLAT); break; }
  4239. case COMMAND_REMOVE_TRADE_COPPER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_COPPER); break; }
  4240. case COMMAND_REMOVE_TRADE_SILVER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_SILVER); break; }
  4241. case COMMAND_REMOVE_TRADE_GOLD : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_GOLD); break; }
  4242. case COMMAND_REMOVE_TRADE_PLAT : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_PLAT); break; }
  4243. case COMMAND_ADD_TRADE_ITEM : { Command_TradeAddItem(client, sep); break; }
  4244. case COMMAND_REMOVE_TRADE_ITEM : { Command_TradeRemoveItem(client, sep); break; }
  4245. case COMMAND_ACCEPT_ADVANCEMENT : { Command_AcceptAdvancement(client, sep); break; }
  4246. case COMMAND_DUEL : { Command_Duel(client, sep); break; }
  4247. case COMMAND_DUELBET : { Command_DuelBet(client, sep); break; }
  4248. case COMMAND_DUEL_ACCEPT : { Command_DuelAccept(client, sep); break; }
  4249. case COMMAND_DUEL_DECLINE : { Command_DuelDecline(client, sep); break; }
  4250. case COMMAND_DUEL_SURRENDER : { Command_DuelSurrender(client, sep); break; }
  4251. case COMMAND_DUEL_TOGGLE : { Command_DuelToggle(client, sep); break; }
  4252. case COMMAND_SPAWN_TEMPLATE : { Command_SpawnTemplate(client, sep); break; }
  4253. case COMMAND_MODIFY : { Command_Modify(client); break; }
  4254. case COMMAND_MODIFY_CHARACTER : { Command_ModifyCharacter(client, sep); break; }
  4255. case COMMAND_MODIFY_QUEST : { Command_ModifyQuest(client, sep); break; }
  4256. case COMMAND_MODIFY_FACTION : { Command_ModifyFaction(client, sep); break; }
  4257. case COMMAND_MODIFY_GUILD : { Command_ModifyGuild(client, sep); break; }
  4258. case COMMAND_MODIFY_ITEM : { Command_ModifyItem(client, sep); break; }
  4259. case COMMAND_MODIFY_SKILL : { Command_ModifySkill(client, sep); break; }
  4260. case COMMAND_MODIFY_SPAWN : { Command_ModifySpawn(client, sep); break; }
  4261. case COMMAND_MODIFY_SPELL : { Command_ModifySpell(client, sep); break; }
  4262. case COMMAND_MODIFY_ZONE : { Command_ModifyZone(client, sep); break; }
  4263. case COMMAND_JOIN_CHANNEL : { Command_JoinChannel(client, sep); break;}
  4264. case COMMAND_JOIN_CHANNEL_FROM_LOAD: { Command_JoinChannelFromLoad(client, sep); break;}
  4265. case COMMAND_TELL_CHANNEL : { Command_TellChannel(client, sep); break;}
  4266. case COMMAND_LEAVE_CHANNEL : { Command_LeaveChannel(client, sep); break;}
  4267. case COMMAND_WHO_CHANNEL : { Command_WhoChannel(client, sep); break;}
  4268. case COMMAND_RAIN : { Command_Rain(client, sep); break; }
  4269. case COMMAND_WIND : { Command_Wind(client, sep); break; }
  4270. case COMMAND_WEATHER : { Command_Weather(client, sep); break; }
  4271. case COMMAND_FROM_MERCHANT : { Command_SendMerchantWindow(client, sep); break; }
  4272. case COMMAND_TO_MERCHANT : { Command_SendMerchantWindow(client, sep, true); break; }
  4273. case COMMAND_SELECT : { Command_Select(client, sep); break; }
  4274. case COMMAND_SMP : { Command_StationMarketPlace(client, sep); break; }
  4275. case COMMAND_CONSUME_FOOD : { Command_ConsumeFood(client, sep); break; }
  4276. case COMMAND_AQUAMAN : { Command_Aquaman(client, sep); break; }
  4277. case COMMAND_ATTUNE_INV : { Command_Attune_Inv(client, sep); break; }
  4278. case COMMAND_PLAYER : { Command_Player(client, sep); break; }
  4279. case COMMAND_PLAYER_COINS : { Command_Player_Coins(client, sep); break; }
  4280. case COMMAND_RESET_ZONE_TIMER : { Command_Reset_Zone_Timer(client, sep); break; }
  4281. case COMMAND_ACHIEVEMENT_ADD : { Command_AchievementAdd(client, sep); break; }
  4282. case COMMAND_EDITOR : { Command_Editor(client, sep); break; }
  4283. case COMMAND_ACCEPT_RESURRECTION: { Command_AcceptResurrection(client, sep); break; }
  4284. case COMMAND_DECLINE_RESURRECTION:{ Command_DeclineResurrection(client, sep); break; }
  4285. case COMMAND_TEST : { Command_Test(client, command_parms); break; }
  4286. case COMMAND_SPEED : { Command_Speed(client, sep); break; }
  4287. case COMMAND_BOT : { Command_Bot(client, sep); break; }
  4288. case COMMAND_BOT_CREATE : { Command_Bot_Create(client, sep); break; }
  4289. case COMMAND_BOT_CUSTOMIZE : { Command_Bot_Customize(client, sep); break; }
  4290. case COMMAND_BOT_SPAWN : { Command_Bot_Spawn(client, sep); break; }
  4291. case COMMAND_BOT_LIST : { Command_Bot_List(client, sep); break; }
  4292. case COMMAND_BOT_INV : { Command_Bot_Inv(client, sep); break; }
  4293. case COMMAND_BOT_SETTINGS : { Command_Bot_Settings(client, sep); break; }
  4294. case COMMAND_BOT_HELP : { Command_Bot_Help(client, sep); break; }
  4295. case GET_AA_XML : { Get_AA_Xml(client, sep); break; }
  4296. case ADD_AA : { Add_AA(client, sep); break; }
  4297. case COMMIT_AA_PROFILE : { Commit_AA_Profile(client, sep); break; }
  4298. case BEGIN_AA_PROFILE : { Begin_AA_Profile(client, sep); break; }
  4299. case BACK_AA : { Back_AA(client, sep); break; }
  4300. case REMOVE_AA : { Remove_AA(client, sep); break; }
  4301. case SWITCH_AA_PROFILE : { Switch_AA_Profile(client, sep); break; }
  4302. case CANCEL_AA_PROFILE : { Cancel_AA_Profile(client, sep); break; }
  4303. case SAVE_AA_PROFILE : { Save_AA_Profile(client, sep); break; }
  4304. case COMMAND_TARGETITEM : { Command_TargetItem(client, sep); break; }
  4305. case COMMAND_FINDSPAWN: { Command_FindSpawn(client, sep); break; }
  4306. default:
  4307. {
  4308. LogWrite(COMMAND__WARNING, 0, "Command", "Unhandled command: %s", command->command.data.c_str());
  4309. break;
  4310. }
  4311. }
  4312. safe_delete(sep);
  4313. }
  4314. /******************** New COMMAND Handler Functions ********************/
  4315. /*
  4316. Started breaking apart the huge switch() for commands into sepErate
  4317. functions so it is easier to locate the blocks of code by command
  4318. -- JA 2012.03.03
  4319. */
  4320. // sample function header
  4321. /*
  4322. Function:
  4323. Purpose :
  4324. Params :
  4325. Dev :
  4326. Example :
  4327. */
  4328. //void Commands::Command()
  4329. //{
  4330. //}
  4331. /*
  4332. Function: Command_AcceptAdvancement()
  4333. Purpose : Player accepts a new advancement option
  4334. Params : Spell ID
  4335. Dev : Jabantiz
  4336. */
  4337. void Commands::Command_AcceptAdvancement(Client* client, Seperator* sep)
  4338. {
  4339. Player *player = client->GetPlayer();
  4340. if (sep && sep->IsSet(0)) {
  4341. TraitData* trait = master_trait_list.GetTrait(atoul(sep->arg[0]));
  4342. // Check to see if this is a trait or grandmaster training (traits are always new spells, training is always upgrades)
  4343. if (!player->HasSpell(trait->spellID, 0, true))
  4344. {
  4345. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  4346. player->AddSpellBookEntry(trait->spellID, trait->tier, player->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  4347. }
  4348. else
  4349. {
  4350. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  4351. int8 old_slot = player->GetSpellSlot(spell->GetSpellID());
  4352. player->RemoveSpellBookEntry(spell->GetSpellID());
  4353. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  4354. player->UnlockSpell(spell);
  4355. client->SendSpellUpdate(spell);
  4356. }
  4357. // Spell book update
  4358. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  4359. client->QueuePacket(master_trait_list.GetTraitListPacket(client));
  4360. }
  4361. }
  4362. /*
  4363. Function:
  4364. Purpose :
  4365. Params :
  4366. Dev :
  4367. Example :
  4368. */
  4369. void Commands::Command_AFK(Client* client, Seperator* sep)
  4370. {
  4371. Player* player = client->GetPlayer();
  4372. player->toggle_character_flag(CF_AFK);
  4373. client->Message(CHANNEL_COLOR_YELLOW,"You are %s afk.", client->GetPlayer()->get_character_flag(CF_AFK)?"now":"no longer");
  4374. if (player->get_character_flag(CF_AFK))
  4375. {
  4376. LogWrite(MISC__TODO, 1, "TODO", "player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_AFK); <-- need to find this");
  4377. /*player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_AFK); <-- need to find this */
  4378. if (sep && sep->argplus[0])
  4379. player->SetAwayMessage("I am away from the keyboard, " + string(sep->argplus[0]));
  4380. else
  4381. player->SetAwayMessage("Sorry, I am A.F.K. (Away From Keyboard)");
  4382. string message = string(player->GetName()) + " is going afk.";
  4383. Spawn* target = player->GetTarget();
  4384. if (target && target != player)
  4385. {
  4386. message = string(player->GetName()) + " tells " + string(target->GetName()) + " that ";
  4387. player->GetGender() == 1 ? message += "he" : message += "she";
  4388. message += " is going afk.";
  4389. }
  4390. player->GetZone()->SimpleMessage(CHANNEL_COLOR_YELLOW, message.c_str(), player, 30);
  4391. }
  4392. /*else
  4393. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_AFK); <-- need to find this */
  4394. }
  4395. /*
  4396. Function: Command_Appearance()
  4397. Purpose : Handles /appearance commands
  4398. Params : list
  4399. Dev : Scatman
  4400. Example : /appearance list
  4401. */
  4402. void Commands::Command_Appearance(Client* client, Seperator* sep, int handler)
  4403. {
  4404. if( handler == COMMAND_APPEARANCE )
  4405. {
  4406. // /appearance command by itself shows help (to be extended)
  4407. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  4408. return;
  4409. }
  4410. else if( handler == COMMAND_APPEARANCE_LIST )
  4411. {
  4412. // /appearance list command expects "name" param
  4413. if (sep && sep->arg[0])
  4414. {
  4415. const char* appearance_name = sep->argplus[0];
  4416. client->Message(CHANNEL_COLOR_YELLOW, "Listing appearances like '%s':", appearance_name);
  4417. vector<int16>* appearances = database.GetAppearanceIDsLikeName(string(appearance_name));
  4418. if (appearances)
  4419. {
  4420. vector<int16>::iterator itr;
  4421. for (itr = appearances->begin(); itr != appearances->end(); itr++)
  4422. {
  4423. int16 id = *itr;
  4424. string name = database.GetAppearanceName(id);
  4425. if (ToLower(name).find(ToLower(string(appearance_name))) < 0xFFFFFFFF)
  4426. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", name.c_str(), id);
  4427. }
  4428. safe_delete(appearances);
  4429. }
  4430. }
  4431. else // no param
  4432. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  4433. }
  4434. }
  4435. /*
  4436. Function: Command_Claim()
  4437. Purpose :
  4438. Params :
  4439. Dev :
  4440. Example :
  4441. */
  4442. void Commands::Command_Claim(Client* client, Seperator* sep)
  4443. {
  4444. if (sep && sep->arg[0] && sep->IsNumber(0))
  4445. {
  4446. LogWrite(MISC__TODO, 1, "TODO", "On Scatman's TODO list!\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  4447. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "On Scatman's TODO :)");
  4448. }
  4449. else
  4450. client->ShowClaimWindow();
  4451. }
  4452. /*
  4453. Function: Command_ClearAllQueued()
  4454. Purpose :
  4455. Params :
  4456. Dev :
  4457. Example :
  4458. */
  4459. void Commands::Command_ClearAllQueued(Client* client)
  4460. {
  4461. ZoneServer* zone = client->GetPlayer()->GetZone();
  4462. if (zone && zone->GetSpellProcess())
  4463. zone->GetSpellProcess()->RemoveSpellFromQueue(client->GetPlayer());
  4464. }
  4465. /*
  4466. Function: Command_CancelMaintained()
  4467. Purpose : Cancels maintained spells
  4468. Params : Maintained Spell Index
  4469. Dev : Zcoretri
  4470. Example : /cancel_maintained 1 - would cancel the spell in slot 1 of Maintained Spells list
  4471. */
  4472. void Commands::Command_CancelMaintained(Client* client, Seperator* sep)
  4473. {
  4474. if (sep && sep->arg[0] && sep->IsNumber(0))
  4475. {
  4476. int32 spell_index = atoul(sep->arg[0]);
  4477. MaintainedEffects mEffects = client->GetPlayer()->GetInfoStruct()->maintained_effects[spell_index];
  4478. //Spell* spell = master_spell_list.GetSpell(mEffects.spell_id, mEffects.tier);
  4479. // if (spell && spell->GetSpellData()->friendly_spell) -- NOTE::You can cancel hostile maintained spells,
  4480. // just not spelleffects/dets - Foof
  4481. //{
  4482. if (!client->GetPlayer()->GetZone()->GetSpellProcess()->DeleteCasterSpell(mEffects.spell, "canceled"))
  4483. client->Message(CHANNEL_COLOR_RED, "The maintained spell could not be cancelled.");
  4484. // }
  4485. //else
  4486. //client->Message(CHANNEL_COLOR_RED, "You can only cancel friendly spells!");
  4487. }
  4488. }
  4489. /*
  4490. Function: Command_Create()
  4491. Purpose : Handler for starting Tradeskilling table
  4492. Params :
  4493. Dev : Zcoretri
  4494. Example :
  4495. */
  4496. void Commands::Command_Create(Client* client, Seperator* sep)
  4497. {
  4498. PrintSep(sep, "COMMAND_CREATE");
  4499. client->SendRecipeList();
  4500. client->ShowRecipeBook();
  4501. }
  4502. void Commands::Command_CreateFromRecipe(Client* client, Seperator* sep)
  4503. {
  4504. PrintSep(sep, "COMMAND_CREATEFROMRECIPE");
  4505. if (sep && sep->arg[0] && sep->IsNumber(0))
  4506. ClientPacketFunctions::SendCreateFromRecipe(client, atoul(sep->arg[0]));
  4507. }
  4508. /*
  4509. Function: Command_Distance()
  4510. Purpose : Displays distance from targeted spawn
  4511. Params :
  4512. Dev : Scatman
  4513. Example : /distance
  4514. */
  4515. void Commands::Command_Distance(Client* client)
  4516. {
  4517. Spawn* target = client->GetPlayer()->GetTarget();
  4518. if (target)
  4519. client->Message(CHANNEL_COLOR_YELLOW, "Your distance from %s is %f", target->GetName(), client->GetPlayer()->GetDistance(target));
  4520. else
  4521. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must have a spawn targeted to use /distance");
  4522. }
  4523. /*
  4524. Function: Command_Duel()
  4525. Purpose : Handle the /duel commands - not yet implemented
  4526. Params : unknown
  4527. Dev :
  4528. Example :
  4529. */
  4530. void Commands::Command_Duel(Client* client, Seperator* sep)
  4531. {
  4532. PrintSep(sep, "COMMAND_DUEL");
  4533. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Command");
  4534. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4535. }
  4536. /*
  4537. Function: Command_DuelBet()
  4538. Purpose : Handle the /duel commands - not yet implemented
  4539. Params : unknown
  4540. Dev :
  4541. Example :
  4542. */
  4543. void Commands::Command_DuelBet(Client* client, Seperator* sep)
  4544. {
  4545. PrintSep(sep, "COMMAND_DUELBET");
  4546. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Bet Command");
  4547. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4548. }
  4549. /*
  4550. Function: Command_DuelAccept()
  4551. Purpose : Handle the /duel commands - not yet implemented
  4552. Params : unknown
  4553. Dev :
  4554. Example :
  4555. */
  4556. void Commands::Command_DuelAccept(Client* client, Seperator* sep)
  4557. {
  4558. PrintSep(sep, "COMMAND_DUEL_ACCEPT");
  4559. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Accept Duel Command");
  4560. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4561. }
  4562. /*
  4563. Function: Command_DuelDecline()
  4564. Purpose : Handle the /duel commands - not yet implemented
  4565. Params : unknown
  4566. Dev :
  4567. Example :
  4568. */
  4569. void Commands::Command_DuelDecline(Client* client, Seperator* sep)
  4570. {
  4571. PrintSep(sep, "COMMAND_DUEL_DECLINE");
  4572. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Decline Duel Request Command");
  4573. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4574. }
  4575. /*
  4576. Function: Command_DuelSurrender()
  4577. Purpose : Handle the /duel commands - not yet implemented
  4578. Params : unknown
  4579. Dev :
  4580. Example :
  4581. */
  4582. void Commands::Command_DuelSurrender(Client* client, Seperator* sep)
  4583. {
  4584. PrintSep(sep, "COMMAND_DUEL_SURRENDER");
  4585. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Surrender Duel Command");
  4586. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4587. // JA, just messin around ;)
  4588. char surrender[64];
  4589. sprintf(surrender, "%s surrendered like a cowardly dog!", client->GetPlayer()->GetName());
  4590. zone_list.HandleGlobalAnnouncement(surrender);
  4591. }
  4592. /*
  4593. Function: Command_DuelToggle()
  4594. Purpose : Handle the /duel commands - not yet implemented
  4595. Params : unknown
  4596. Dev :
  4597. Example :
  4598. */
  4599. void Commands::Command_DuelToggle(Client* client, Seperator* sep)
  4600. {
  4601. PrintSep(sep, "COMMAND_DUEL");
  4602. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Commands");
  4603. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4604. }
  4605. /*
  4606. Function:
  4607. Purpose :
  4608. Params :
  4609. Dev :
  4610. Example :
  4611. */
  4612. void Commands::Command_EntityCommand(Client* client, Seperator* sep, int handler)
  4613. {
  4614. if( handler == COMMAND_ENTITYCOMMAND )
  4615. {
  4616. // /entitycommand command by itself shows help (to be extended)
  4617. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  4618. return;
  4619. }
  4620. else if( handler == COMMAND_ENTITYCOMMAND_LIST )
  4621. {
  4622. // /entitycommand list command expects "name" param
  4623. if (sep && sep->arg[0])
  4624. {
  4625. const char* entity_command_name = sep->argplus[0];
  4626. client->Message(CHANNEL_COLOR_YELLOW, "Listing entity commands like '%s':", entity_command_name);
  4627. map<int32, vector<EntityCommand*>*>* entity_command_list_all = client->GetCurrentZone()->GetEntityCommandListAll();
  4628. map<int32, vector<EntityCommand*>*>::iterator itr;
  4629. for (itr = entity_command_list_all->begin(); itr != entity_command_list_all->end(); itr++)
  4630. {
  4631. vector<EntityCommand*>* entity_command_list = itr->second;
  4632. vector<EntityCommand*>::iterator itr2;
  4633. for (itr2 = entity_command_list->begin(); itr2 != entity_command_list->end(); itr2++)
  4634. {
  4635. EntityCommand* entity_command = *itr2;
  4636. if (ToLower(entity_command->name).find(ToLower(string(entity_command_name))) < 0xFFFFFFFF)
  4637. 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);
  4638. }
  4639. }
  4640. }
  4641. else // no command name
  4642. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  4643. }
  4644. }
  4645. /*
  4646. Function: Command_Follow()
  4647. Purpose : Handle the /follow command - not yet implemented
  4648. Params :
  4649. Dev :
  4650. Example :
  4651. */
  4652. void Commands::Command_Follow(Client* client, Seperator* sep)
  4653. {
  4654. PrintSep(sep, "COMMAND_FOLLOW");
  4655. // flag to toggle if the players target is in the players group
  4656. bool targetInGroup = false;
  4657. // get a pointer to the players group
  4658. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  4659. // If the player has a group and has a target
  4660. if (gmi && client->GetPlayer()->GetTarget()) {
  4661. deque<GroupMemberInfo*>::iterator itr;
  4662. world.GetGroupManager()->GroupLock(__FUNCTION__, __LINE__);
  4663. PlayerGroup* group = world.GetGroupManager()->GetGroup(gmi->group_id);
  4664. if (group)
  4665. {
  4666. group->MGroupMembers.readlock(__FUNCTION__, __LINE__);
  4667. deque<GroupMemberInfo*>* members = group->GetMembers();
  4668. // Loop through the group members
  4669. for (itr = members->begin(); itr != members->end(); itr++) {
  4670. // If a group member matches a target
  4671. if ((*itr)->member == client->GetPlayer()->GetTarget()) {
  4672. // toggle the flag and break the loop
  4673. targetInGroup = true;
  4674. break;
  4675. }
  4676. }
  4677. group->MGroupMembers.releasereadlock(__FUNCTION__, __LINE__);
  4678. }
  4679. world.GetGroupManager()->ReleaseGroupLock(__FUNCTION__, __LINE__);
  4680. }
  4681. if (targetInGroup) {
  4682. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  4683. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You start to follow %s.", client->GetPlayer()->GetTarget()->GetName());
  4684. client->GetPlayer()->SetFollowTarget(client->GetPlayer()->GetTarget());
  4685. client->GetPlayer()->info_changed = true;
  4686. client->GetPlayer()->changed = true;
  4687. }
  4688. else
  4689. client->Message(CHANNEL_NARRATIVE, "You must first select a group member to follow.");
  4690. }
  4691. /*
  4692. Function: Command_StopFollow()
  4693. Purpose : Handle the /stop_follow command - not yet implemented
  4694. Params :
  4695. Dev :
  4696. Example :
  4697. */
  4698. void Commands::Command_StopFollow(Client* client, Seperator* sep)
  4699. {
  4700. PrintSep(sep, "COMMAND_STOP_FOLLOW");
  4701. if (client->GetPlayer()->GetFollowTarget()) {
  4702. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  4703. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You are no longer following %s", client->GetPlayer()->GetFollowTarget()->GetName());
  4704. client->GetPlayer()->SetFollowTarget(0);
  4705. client->GetPlayer()->info_changed = true;
  4706. client->GetPlayer()->changed = true;
  4707. }
  4708. }
  4709. #include "../Zone/SPGrid.h"
  4710. /*
  4711. Function: Command_Grid()
  4712. Purpose : Show player's current Grid ID
  4713. Params :
  4714. Dev : Scatman
  4715. Example : /grid
  4716. */
  4717. void Commands::Command_Grid(Client* client)
  4718. {
  4719. client->Message(CHANNEL_COLOR_YELLOW, "Your Grid ID is %u", client->GetPlayer()->appearance.pos.grid_id);
  4720. if (client->GetPlayer()->GetMap() != nullptr) {
  4721. int32 grid = client->GetPlayer()->GetMap()->GetGrid()->GetGridID(client->GetPlayer());
  4722. client->Message(CHANNEL_COLOR_YELLOW, "SPGrid result is %u", grid);
  4723. }
  4724. }
  4725. /*
  4726. Function: Command_Guild()
  4727. Purpose : Handler for all UI-related guild commands
  4728. Dev : Scatman
  4729. */
  4730. void Commands::Command_Guild(Client* client, Seperator* sep)
  4731. {
  4732. Guild* guild = client->GetPlayer()->GetGuild();
  4733. if (sep && sep->GetMaxArgNum() > 0 && sep->arg[0])
  4734. {
  4735. const char* command = sep->arg[0];
  4736. int32 length = strlen(command);
  4737. LogWrite(COMMAND__DEBUG, 0, "Command", "Guild Command: %s", command);
  4738. if (strncmp(command, "rank_name", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && guild)
  4739. guild->SetRankName(atoi(sep->arg[1]), sep->argplus[2]);
  4740. else if (strncmp(command, "rank_permission", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  4741. guild->SetPermission(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  4742. else if (strncmp(command, "filter_event", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  4743. guild->SetEventFilter(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  4744. else if (strncmp(command, "kick", length) == 0 && sep->arg[1] && guild)
  4745. guild->KickGuildMember(client, sep->arg[1]);
  4746. else if (strncmp(command, "demote", length) == 0 && sep->arg[1] && guild)
  4747. guild->DemoteGuildMember(client, sep->arg[1]);
  4748. else if (strncmp(command, "promote", length) == 0 && sep->arg[1] && guild)
  4749. guild->PromoteGuildMember(client, sep->arg[1]);
  4750. else if (strncmp(command, "points", length) == 0 && guild)
  4751. {
  4752. if (sep->arg[1] && strncmp(sep->arg[1], "add", length) == 0)
  4753. {
  4754. if (sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  4755. {
  4756. float points = atof(sep->arg[2]);
  4757. const char* option = sep->arg[3];
  4758. const char* comment = sep->argplus[4];
  4759. if (strncmp(option, "all", strlen(option)) == 0)
  4760. guild->AddPointsToAll(client, points, comment);
  4761. else if (strncmp(option, "online", strlen(option)) == 0)
  4762. guild->AddPointsToAllOnline(client, points, comment);
  4763. else if (strncmp(option, "group", strlen(option)) == 0)
  4764. guild->AddPointsToGroup(client, points, comment);
  4765. else if (strncmp(option, "raid", strlen(option)) == 0)
  4766. guild->AddPointsToRaid(client, points, comment);
  4767. else
  4768. guild->AddPointsToGuildMember(client, points, option, comment);
  4769. }
  4770. }
  4771. else if (sep->arg[1] && strncmp(sep->arg[1], "view", strlen(sep->arg[1])) == 0 && sep->arg[2])
  4772. guild->ViewGuildMemberPoints(client, sep->arg[2]);
  4773. else
  4774. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild points command: %s", sep->argplus[0]);
  4775. }
  4776. else if (strncmp(command, "motd", length) == 0 && sep->arg[1] && guild)
  4777. guild->SetMOTD(sep->argplus[1]);
  4778. else if (strncmp(command, "recruiting", length) == 0 && guild)
  4779. {
  4780. if (sep->arg[1])
  4781. {
  4782. const char* option = sep->arg[1];
  4783. if (strncmp(option, "short_text", strlen(option)) == 0 && sep->arg[2])
  4784. guild->SetRecruitingShortDesc(sep->argplus[2]);
  4785. else if (strncmp(option, "long_text", strlen(option)) == 0 && sep->arg[2])
  4786. guild->SetRecruitingFullDesc(sep->argplus[2]);
  4787. else if (strncmp(option, "flag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  4788. guild->SetRecruitingFlag(atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  4789. else if (strncmp(option, "min_level", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  4790. guild->SetRecruitingMinLevel(atoi(sep->arg[2]));
  4791. else if (strncmp(option, "playstyle", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  4792. guild->SetRecruitingPlayStyle(atoi(sep->arg[2]));
  4793. else if (strncmp(option, "tag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && sep->IsNumber(3))
  4794. guild->SetRecruitingDescTag(atoi(sep->arg[2]), atoi(sep->arg[3]));
  4795. else if (strncmp(command, "recruiting", strlen(option)) == 0)
  4796. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_RECRUITING_FOR_GUILD, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  4797. else
  4798. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  4799. }
  4800. else
  4801. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  4802. }
  4803. else if (strncmp(command, "notify_online", length) == 0 && sep->arg[1] && guild)
  4804. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_NOTIFY_LOGINS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  4805. else if (strncmp(command, "event_privacy", length) == 0 && sep->arg[1] && guild)
  4806. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_DONT_GENERATE_EVENTS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  4807. else if (strncmp(command, "recruiter", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  4808. guild->SetGuildRecruiter(client, sep->arg[1], strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  4809. else if (strncmp(command, "recruiter_description", length) == 0 && sep->arg[1] && guild)
  4810. guild->SetGuildRecruiterDescription(client, sep->argplus[1]);
  4811. else if (strncmp(command, "lock_event", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  4812. guild->LockGuildEvent(atoul(sep->arg[1]), strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  4813. else if (strncmp(command, "delete_event", length) == 0 && sep->arg[1] && guild)
  4814. guild->DeleteGuildEvent(atoul(sep->arg[1]));
  4815. else if (strncmp(command, "invite", length) == 0 && guild)
  4816. {
  4817. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  4818. guild->InvitePlayer(client, sep->arg[1]);
  4819. else
  4820. {
  4821. Spawn* target = client->GetPlayer()->GetTarget();
  4822. if (target)
  4823. {
  4824. if (target->IsPlayer())
  4825. guild->InvitePlayer(client, target->GetName());
  4826. else
  4827. client->Message(CHANNEL_NARRATIVE, "%s is not a player.", target->GetName());
  4828. }
  4829. }
  4830. }
  4831. else if (strncmp(command, "accept", length) == 0)
  4832. {
  4833. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  4834. if (pgi && pgi->guild && pgi->invited_by)
  4835. pgi->guild->AddNewGuildMember(client, pgi->invited_by->GetName());
  4836. client->SetPendingGuildInvite(0);
  4837. }
  4838. else if (strncmp(command, "decline", length) == 0)
  4839. {
  4840. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  4841. if (pgi && pgi->guild && pgi->invited_by)
  4842. {
  4843. Client* client_inviter = pgi->invited_by->GetZone()->GetClientBySpawn(pgi->invited_by);
  4844. if (client_inviter)
  4845. client_inviter->Message(CHANNEL_NARRATIVE, "%s has declined your invitation to join %s.", client->GetPlayer()->GetName(), pgi->guild->GetName());
  4846. }
  4847. client->SetPendingGuildInvite(0);
  4848. }
  4849. else if (strncmp(command, "create", length) == 0 && sep->arg[1])
  4850. {
  4851. const char* guild_name = sep->argplus[1];
  4852. if (!guild_list.GetGuild(guild_name))
  4853. world.CreateGuild(guild_name, client, client->GetPlayer()->GetGroupMemberInfo() ? client->GetPlayer()->GetGroupMemberInfo()->group_id : 0);
  4854. else
  4855. client->SimpleMessage(CHANNEL_NARRATIVE, "A guild with that name already exists.");
  4856. }
  4857. else if (strncmp(command, "search", length) == 0)
  4858. client->ShowGuildSearchWindow();
  4859. else if (strncmp(command, "recruiting_details", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  4860. {
  4861. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  4862. if (to_guild)
  4863. to_guild->SendGuildRecruitingDetails(client);
  4864. }
  4865. else if (strncmp(command, "recruiting_image", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  4866. {
  4867. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  4868. if (to_guild)
  4869. to_guild->SendGuildRecruitingImages(client);
  4870. }
  4871. else if (strncmp(command, "recruiter_adventure_class", length) == 0)
  4872. {
  4873. if (sep->arg[1])
  4874. {
  4875. const char* option = sep->arg[1];
  4876. if (strncmp(option, "toggle", strlen(option)) == 0)
  4877. guild->ToggleGuildRecruiterAdventureClass(client);
  4878. }
  4879. else
  4880. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiter_adventure_class command: '%s'", sep->argplus[0]);
  4881. }
  4882. else if (strncmp(command, "display_heraldry", length) == 0)
  4883. {
  4884. // JA: not sure this is right...
  4885. client->GetPlayer()->toggle_character_flag(CF_SHOW_GUILD_HERALDRY);
  4886. client->GetPlayer()->SetCharSheetChanged(true);
  4887. }
  4888. else
  4889. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild command: '%s'", sep->argplus[0]);
  4890. }
  4891. }
  4892. /*
  4893. Function: Command_GuildCreate()
  4894. Purpose : Display's in-game Guild Creation window
  4895. Dev : Scatman
  4896. */
  4897. void Commands::Command_CreateGuild(Client* client)
  4898. {
  4899. client->SendGuildCreateWindow();
  4900. }
  4901. /*
  4902. Function: Command_SetGuildOfficerNote()
  4903. Purpose :
  4904. Dev : Scatman
  4905. */
  4906. void Commands::Command_SetGuildOfficerNote(Client* client, Seperator* sep)
  4907. {
  4908. if (sep && sep->arg[0] && sep->arg[1])
  4909. {
  4910. Guild* guild = client->GetPlayer()->GetGuild();
  4911. if (guild)
  4912. guild->SetGuildOfficerNote(sep->arg[0], sep->argplus[1]);
  4913. }
  4914. }
  4915. /*
  4916. Function: Command_SetGuildMemberNote()
  4917. Purpose :
  4918. Dev : Scatman
  4919. */
  4920. void Commands::Command_SetGuildMemberNote(Client* client, Seperator* sep)
  4921. {
  4922. if (sep && sep->arg[0] && sep->arg[1])
  4923. {
  4924. Guild* guild = client->GetPlayer()->GetGuild();
  4925. if (guild)
  4926. guild->SetGuildMemberNote(sep->arg[0], sep->argplus[1]);
  4927. }
  4928. }
  4929. /*
  4930. Function: Command_GuildSay()
  4931. Purpose :
  4932. Dev : Scatman
  4933. */
  4934. void Commands::Command_GuildSay(Client* client, Seperator* sep)
  4935. {
  4936. Guild* guild = client->GetPlayer()->GetGuild();
  4937. if (guild)
  4938. {
  4939. if (sep && sep->arg[0])
  4940. guild->HandleGuildSay(client, sep->argplus[0]);
  4941. }
  4942. else
  4943. client->SimpleMessage(CHANNEL_NARRATIVE, "You are not a member of a guild");
  4944. }
  4945. /*
  4946. Function: Command_OfficerSay()
  4947. Purpose :
  4948. Dev : Scatman
  4949. */
  4950. void Commands::Command_OfficerSay(Client* client, Seperator* sep)
  4951. {
  4952. Guild* guild = client->GetPlayer()->GetGuild();
  4953. if (guild)
  4954. {
  4955. if (sep && sep->arg[0])
  4956. guild->HandleOfficerSay(client, sep->argplus[0]);
  4957. }
  4958. else
  4959. client->SimpleMessage(CHANNEL_NARRATIVE, "You are not a member of a guild");
  4960. }
  4961. /*
  4962. Function: Command_Guilds()
  4963. Purpose : Shows help for /guild command
  4964. Params :
  4965. Dev : Scatman
  4966. Example :
  4967. */
  4968. void Commands::Command_Guilds(Client* client)
  4969. {
  4970. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds [create|delete|add|remove|list]");
  4971. }
  4972. /*
  4973. Function: Command_GuildsAdd()
  4974. Purpose : Add's players to a guild
  4975. Params : guild_name|guild_id, player name
  4976. Dev : Scatman
  4977. Example : /guilds add 1 Admin = adds player Admin to guild_id 1
  4978. */
  4979. void Commands::Command_GuildsAdd(Client* client, Seperator* sep)
  4980. {
  4981. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  4982. {
  4983. Guild* guild = 0;
  4984. bool found = true;
  4985. if (sep->IsNumber(0))
  4986. {
  4987. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  4988. if (!guild)
  4989. {
  4990. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  4991. found = false;
  4992. }
  4993. }
  4994. else
  4995. {
  4996. guild = guild_list.GetGuild(sep->arg[0]);
  4997. if (!guild)
  4998. {
  4999. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  5000. found = false;
  5001. }
  5002. }
  5003. if (found)
  5004. {
  5005. Client* to_client = 0;
  5006. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  5007. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  5008. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  5009. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  5010. if (to_client)
  5011. guild->InvitePlayer(client, to_client->GetPlayer()->GetName());
  5012. else
  5013. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  5014. }
  5015. }
  5016. else
  5017. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds add [guild name|guild id] (player name).");
  5018. }
  5019. /*
  5020. Function: Command_GuildsCreate()
  5021. Purpose : Creates a guild
  5022. Params : guild_name, player_name (optional)
  5023. Dev : Scatman
  5024. Example : /guilds create [guild name] (player name)
  5025. */
  5026. void Commands::Command_GuildsCreate(Client* client, Seperator* sep)
  5027. {
  5028. if (sep && sep->arg[0])
  5029. {
  5030. const char* guild_name = sep->arg[0];
  5031. if (!guild_list.GetGuild(guild_name))
  5032. {
  5033. bool ret = false;
  5034. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  5035. {
  5036. Client* to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  5037. if (to_client)
  5038. {
  5039. world.CreateGuild(guild_name, to_client);
  5040. ret = true;
  5041. }
  5042. else
  5043. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player with name '%s'", sep->arg[1]);
  5044. }
  5045. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  5046. {
  5047. Client* to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  5048. if (to_client)
  5049. {
  5050. world.CreateGuild(guild_name, to_client);
  5051. ret = true;
  5052. }
  5053. }
  5054. else
  5055. {
  5056. world.CreateGuild(guild_name);
  5057. ret = true;
  5058. }
  5059. if (ret)
  5060. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully created.", guild_name);
  5061. else
  5062. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the guild.");
  5063. }
  5064. else
  5065. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' already exists.", guild_name);
  5066. }
  5067. else
  5068. 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.");
  5069. }
  5070. /*
  5071. Function: Command_GuildsDelete()
  5072. Purpose : Delete's a guild
  5073. Params : guild name
  5074. Dev : Scatman
  5075. Example : /guilds delete Test
  5076. */
  5077. void Commands::Command_GuildsDelete(Client* client, Seperator* sep)
  5078. {
  5079. if (sep && sep->arg[0])
  5080. {
  5081. Guild* guild = 0;
  5082. bool found = true;
  5083. if (sep->IsNumber(0))
  5084. {
  5085. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  5086. if (!guild)
  5087. {
  5088. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  5089. found = false;
  5090. }
  5091. }
  5092. else
  5093. {
  5094. guild = guild_list.GetGuild(sep->arg[0]);
  5095. if (!guild)
  5096. {
  5097. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  5098. found = false;
  5099. }
  5100. }
  5101. if (found)
  5102. {
  5103. guild->RemoveAllGuildMembers();
  5104. database.DeleteGuild(guild);
  5105. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully deleted.", guild->GetName());
  5106. guild_list.RemoveGuild(guild, true);
  5107. }
  5108. }
  5109. else
  5110. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds delete [guild name].");
  5111. }
  5112. /*
  5113. Function: Command_GuildsList()
  5114. Purpose : Lists current guilds on server
  5115. Params :
  5116. Dev : Scatman
  5117. Example : /guilds list
  5118. */
  5119. void Commands::Command_GuildsList(Client* client)
  5120. {
  5121. MutexMap<int32, Guild*>* guilds = guild_list.GetGuilds();
  5122. MutexMap<int32, Guild*>::iterator itr = guilds->begin();
  5123. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Guild List:");
  5124. if (guilds->size() == 0)
  5125. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "None.");
  5126. else {
  5127. while (itr.Next()) {
  5128. Guild* guild = itr.second;
  5129. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", guild->GetID(), guild->GetName());
  5130. }
  5131. }
  5132. }
  5133. /*
  5134. Function: Command_GuildsRemove()
  5135. Purpose : Removes a player from a guild
  5136. Params : guild name|guild id, player name
  5137. Dev : Scatman
  5138. Example : /guilds remove 1 Admin = removes Admin from guild 1
  5139. */
  5140. void Commands::Command_GuildsRemove(Client* client, Seperator* sep)
  5141. {
  5142. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  5143. {
  5144. Guild* guild = 0;
  5145. bool found = true;
  5146. if (sep->IsNumber(0))
  5147. {
  5148. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  5149. if (!guild)
  5150. {
  5151. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  5152. found = false;
  5153. }
  5154. }
  5155. else
  5156. {
  5157. guild = guild_list.GetGuild(sep->arg[0]);
  5158. if (!guild)
  5159. {
  5160. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  5161. found = false;
  5162. }
  5163. }
  5164. if (found)
  5165. {
  5166. Client* to_client = 0;
  5167. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  5168. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  5169. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  5170. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  5171. if (to_client)
  5172. {
  5173. Player* to_player = to_client->GetPlayer();
  5174. if (to_player->GetGuild())
  5175. {
  5176. if (to_player->GetGuild() == guild)
  5177. {
  5178. guild->KickGuildMember(client, to_player->GetName());
  5179. }
  5180. else
  5181. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in the guild '%s'.", to_player->GetName(), guild->GetName());
  5182. }
  5183. else
  5184. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in a guild.", to_player->GetName());
  5185. }
  5186. else
  5187. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  5188. }
  5189. }
  5190. else
  5191. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds remove [guild name|guild id] (player name).");
  5192. }
  5193. /*
  5194. Function: Command_InspectPlayer()
  5195. Purpose : Handle the Inspect functions
  5196. Params : Client to inspect
  5197. Dev : Scatman
  5198. Example : /inspect Scatman
  5199. */
  5200. void Commands::Command_InspectPlayer(Client* client, Seperator* sep)
  5201. {
  5202. if (sep && sep->arg[0])
  5203. {
  5204. Client* inspect_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  5205. if (inspect_client)
  5206. client->InspectPlayer(inspect_client->GetPlayer());
  5207. }
  5208. else
  5209. {
  5210. Spawn* target = client->GetPlayer()->GetTarget();
  5211. if (target && target->IsPlayer())
  5212. client->InspectPlayer((Player*)target);
  5213. }
  5214. }
  5215. /*
  5216. Function: Command_Inventory()
  5217. Purpose : Handle changes in player inventory
  5218. Params : <TBD>
  5219. Dev : All
  5220. Example : /inventory delete item_id
  5221. */
  5222. void Commands::Command_Inventory(Client* client, Seperator* sep, EQ2_RemoteCommandString* command)
  5223. {
  5224. PrintSep(sep, "Command_Inventory"); // temp to figure out the params
  5225. Player* player = client->GetPlayer();
  5226. if(sep && sep->arg[0][0])
  5227. {
  5228. LogWrite(COMMAND__INFO, 0, "Command", "command: %s", command->command.data.c_str());
  5229. if(client->GetPlayer()->GetHP() == 0)
  5230. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  5231. else if(sep->arg[1][0] && strncasecmp("destroy", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  5232. {
  5233. int16 index = atoi(sep->arg[1]);
  5234. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  5235. if(item)
  5236. {
  5237. if(item->GetItemScript() && lua_interface)
  5238. lua_interface->RunItemScript(item->GetItemScript(), "destroyed", item, client->GetPlayer());
  5239. int32 bag_id = item->details.inv_slot_id;
  5240. database.DeleteItem(client->GetCharacterID(), item, 0);
  5241. client->GetPlayer()->item_list.DestroyItem(index);
  5242. EQ2Packet* outapp = client->GetPlayer()->SendInventoryUpdate(client->GetVersion());
  5243. client->QueuePacket(outapp);
  5244. outapp = client->GetPlayer()->SendBagUpdate(bag_id, client->GetVersion());
  5245. if (outapp)
  5246. client->QueuePacket(outapp);
  5247. }
  5248. }
  5249. 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))
  5250. {
  5251. int16 from_index = atoi(sep->arg[1]);
  5252. sint16 to_slot = atoi(sep->arg[2]);
  5253. sint32 bag_id = atol(sep->arg[3]);
  5254. int8 charges = atoi(sep->arg[4]);
  5255. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(from_index);
  5256. if(bag_id == -4 && !client->GetPlayer()->item_list.SharedBankAddAllowed(item))
  5257. {
  5258. client->SimpleMessage(CHANNEL_COLOR_RED, "That item (or an item inside) cannot be shared.");
  5259. return;
  5260. }
  5261. sint32 old_inventory_id = 0;
  5262. if(item)
  5263. old_inventory_id = item->details.inv_slot_id;
  5264. //autobank
  5265. if (bag_id == -3 && to_slot == -1)
  5266. {
  5267. if (player->HasFreeBankSlot())
  5268. to_slot = player->FindFreeBankSlot();
  5269. else
  5270. {
  5271. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free bank slots.");
  5272. return;
  5273. }
  5274. }
  5275. //auto inventory
  5276. if (bag_id == 0 && to_slot == -1)
  5277. {
  5278. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  5279. {
  5280. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free slots.");
  5281. return;
  5282. }
  5283. }
  5284. EQ2Packet* outapp = client->GetPlayer()->MoveInventoryItem(bag_id, from_index, (int8)to_slot, charges, client->GetVersion());
  5285. client->QueuePacket(outapp);
  5286. //removed from bag send update
  5287. if(old_inventory_id > 0 && item && item->details.inv_slot_id != old_inventory_id)
  5288. {
  5289. outapp = client->GetPlayer()->SendBagUpdate(old_inventory_id, client->GetVersion());
  5290. if(outapp)
  5291. client->QueuePacket(outapp);
  5292. }
  5293. if(item && item->details.inv_slot_id > 0 && item->details.inv_slot_id != old_inventory_id)
  5294. {
  5295. outapp = client->GetPlayer()->SendBagUpdate(item->details.inv_slot_id, client->GetVersion());
  5296. if(outapp)
  5297. client->QueuePacket(outapp);
  5298. }
  5299. }
  5300. else if(sep->arg[1][0] && strncasecmp("equip", sep->arg[0], 5) == 0 && sep->IsNumber(1))
  5301. {
  5302. if(client->GetPlayer()->EngagedInCombat())
  5303. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not equip items while in combat.");
  5304. else
  5305. {
  5306. int16 index = atoi(sep->arg[1]);
  5307. int8 slot_id = 255;
  5308. if(sep->arg[2][0] && sep->IsNumber(2))
  5309. slot_id = atoi(sep->arg[2]);
  5310. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), slot_id);
  5311. EQ2Packet* outapp = 0;
  5312. for(int32 i=0;i<packets.size();i++)
  5313. {
  5314. outapp = packets[i];
  5315. if(outapp)
  5316. client->QueuePacket(outapp);
  5317. }
  5318. client->GetPlayer()->ChangePrimaryWeapon();
  5319. client->GetPlayer()->ChangeSecondaryWeapon();
  5320. client->GetPlayer()->ChangeRangedWeapon();
  5321. EQ2Packet* characterSheetPackets = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion());
  5322. client->QueuePacket(characterSheetPackets);
  5323. }
  5324. }
  5325. else if (sep->arg[1][0] && strncasecmp("unpack", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  5326. {
  5327. if (client->GetPlayer()->EngagedInCombat())
  5328. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unpack items while in combat.");
  5329. else {
  5330. int16 index = atoi(sep->arg[1]);
  5331. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  5332. if (item) {
  5333. // client->GetPlayer()->item_list.DestroyItem(index);
  5334. if (item->item_sets.size() > 0) {
  5335. for (int32 i = 0; i < item->item_sets.size(); i++) {
  5336. ItemSet* set = item->item_sets[i];
  5337. if (set->item_stack_size == 0)
  5338. set->item_stack_size += 1;
  5339. client->AddItem(set->item_id, set->item_stack_size);
  5340. }
  5341. }
  5342. }
  5343. client->RemoveItem(item, 1);
  5344. }
  5345. }
  5346. else if(sep->arg[1][0] && strncasecmp("unequip", sep->arg[0], 7) == 0 && sep->IsNumber(1))
  5347. {
  5348. if(client->GetPlayer()->EngagedInCombat())
  5349. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unequip items while in combat.");
  5350. else
  5351. {
  5352. int16 index = atoi(sep->arg[1]);
  5353. sint32 bag_id = -999;
  5354. int8 to_slot = 255;
  5355. if(sep->arg[3][0])
  5356. {
  5357. if(sep->IsNumber(2))
  5358. bag_id = atol(sep->arg[2]);
  5359. if(sep->IsNumber(3))
  5360. to_slot = atoi(sep->arg[3]);
  5361. }
  5362. vector<EQ2Packet*> packets = client->GetPlayer()->UnequipItem(index, bag_id, to_slot, client->GetVersion());
  5363. EQ2Packet* outapp = 0;
  5364. for(int32 i=0;i<packets.size();i++)
  5365. {
  5366. outapp = packets[i];
  5367. if(outapp)
  5368. client->QueuePacket(outapp);
  5369. }
  5370. client->GetPlayer()->ChangePrimaryWeapon();
  5371. client->GetPlayer()->ChangeSecondaryWeapon();
  5372. client->GetPlayer()->ChangeRangedWeapon();
  5373. EQ2Packet* characterSheetPackets = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion());
  5374. client->QueuePacket(characterSheetPackets);
  5375. }
  5376. }
  5377. else if(sep->arg[2][0] && strncasecmp("swap_equip", sep->arg[0], 10) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  5378. {
  5379. LogWrite(MISC__TODO, 1, "TODO", " fix this, need to get how live does it\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  5380. int16 index1 = atoi(sep->arg[1]);
  5381. int16 index2 = atoi(sep->arg[2]);
  5382. EQ2Packet* outapp = client->GetPlayer()->SwapEquippedItems(index1, index2, client->GetVersion());
  5383. if(outapp)
  5384. client->QueuePacket(outapp);
  5385. else
  5386. {
  5387. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to swap items");
  5388. return;
  5389. }
  5390. }
  5391. else if (sep->arg[2][0] && strncasecmp("pop", sep->arg[0], 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  5392. {
  5393. sint16 to_slot = atoi(sep->arg[1]);
  5394. sint32 bag_id = atoi(sep->arg[2]);
  5395. Item* item = client->GetPlayer()->item_list.GetOverflowItem();
  5396. if (item) {
  5397. //auto inventory
  5398. if (bag_id == 0 && to_slot == -1)
  5399. {
  5400. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  5401. {
  5402. client->SimpleMessage(CHANNEL_ERROR, "You do not have any free slots.");
  5403. return;
  5404. }
  5405. // Set the slot for the item
  5406. item->details.inv_slot_id = bag_id;
  5407. item->details.slot_id = to_slot;
  5408. // Flag the item so it gets saved in its new location
  5409. item->save_needed = true;
  5410. // Add the item to its new location
  5411. player->item_list.AddItem(item);
  5412. // Remove the item from the overflow list
  5413. player->item_list.RemoveOverflowItem(item);
  5414. // Send the inventory update packet
  5415. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5416. return;
  5417. }
  5418. else if (bag_id == -3 && to_slot == -1) {
  5419. // Auto Bank
  5420. if (!player->item_list.GetFirstFreeBankSlot(&bag_id, &to_slot)) {
  5421. client->SimpleMessage(CHANNEL_STATUS, "You do not have any free bank slots.");
  5422. return;
  5423. }
  5424. item->details.inv_slot_id = bag_id;
  5425. item->details.slot_id = to_slot;
  5426. item->save_needed = true;
  5427. player->item_list.AddItem(item);
  5428. player->item_list.RemoveOverflowItem(item);
  5429. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5430. }
  5431. else if (bag_id == -4) {
  5432. // Shared Bank
  5433. if (!player->item_list.SharedBankAddAllowed(item)) {
  5434. client->SimpleMessage(CHANNEL_STATUS, "That item (or an item inside) cannot be shared.");
  5435. return;
  5436. }
  5437. Item* tmp_item = player->item_list.GetItem(-4, to_slot);
  5438. if (tmp_item) {
  5439. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  5440. return;
  5441. }
  5442. else {
  5443. item->details.inv_slot_id = bag_id;
  5444. item->details.slot_id = to_slot;
  5445. item->save_needed = true;
  5446. player->item_list.AddItem(item);
  5447. player->item_list.RemoveOverflowItem(item);
  5448. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5449. return;
  5450. }
  5451. }
  5452. else {
  5453. // Try to get an item from the given bag id and slot id
  5454. Item* tmp_item = player->item_list.GetItem(bag_id, to_slot);
  5455. // Check to see if we got an item, if we do send an error,
  5456. // if we don't put the overflow item into this slot
  5457. if (tmp_item) {
  5458. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  5459. }
  5460. else {
  5461. item->details.inv_slot_id = bag_id;
  5462. item->details.slot_id = to_slot;
  5463. item->save_needed = true;
  5464. player->item_list.AddItem(item);
  5465. player->item_list.RemoveOverflowItem(item);
  5466. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5467. return;
  5468. }
  5469. }
  5470. }
  5471. }
  5472. }
  5473. else
  5474. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /inventory {destroy|move|equip|unequip|swap_equip|pop} {item_id} [to_slot] [bag_id]");
  5475. }
  5476. /*
  5477. Function: Command_IRC()
  5478. Purpose : Handle the IRC functions
  5479. Params : IRC Commands
  5480. Dev : Scatman
  5481. Example : /irc say #Channel Hello World!
  5482. */
  5483. void Commands::Command_IRC(Client* client, Seperator* sep)
  5484. {
  5485. if (!rule_manager.GetGlobalRule(R_World, IRCEnabled)->GetBool()) {
  5486. client->SimpleMessage(CHANNEL_STATUS, "IRC is currently disabled on this server");
  5487. return;
  5488. }
  5489. if (sep && sep->arg[0][0]) {
  5490. if (strcasecmp(sep->arg[0], "say") == 0) {
  5491. if (sep->arg[1][0] && sep->arg[2][0]) {
  5492. if (sep->IsNumber(sep->arg[1]))
  5493. irc.Say(client, atoul(sep->arg[1]), sep->argplus[2]);
  5494. else
  5495. irc.Say(client, sep->arg[1], sep->argplus[2]);
  5496. }
  5497. else
  5498. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc say <channel name | channel index> <message>");
  5499. }
  5500. else if (strcasecmp(sep->arg[0], "join") == 0) {
  5501. if (sep->arg[1][0])
  5502. irc.JoinChannel(client, sep->arg[1]);
  5503. else
  5504. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc join <channel name>");
  5505. }
  5506. else if (strcasecmp(sep->arg[0], "leave") == 0) {
  5507. if (sep->arg[1][0])
  5508. irc.LeaveChannel(client, sep->arg[1]);
  5509. else
  5510. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc leave <channel name>");
  5511. }
  5512. else if (strcasecmp(sep->arg[0], "list") == 0)
  5513. irc.ListChannels(client);
  5514. else if (strcasecmp(sep->arg[0], "connect") == 0) {
  5515. if (sep->arg[1][0] && sep->arg[2][0] && sep->IsNumber(2))
  5516. irc.ConnectToServer(client, sep->arg[1], atoi(sep->arg[2]), sep->arg[3]);
  5517. else
  5518. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc connect <host> <port> (nick)");
  5519. }
  5520. else if (strcasecmp(sep->arg[0], "disconnect") == 0)
  5521. irc.DisconnectFromServer(client);
  5522. else
  5523. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown IRC command.");
  5524. }
  5525. else
  5526. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown IRC command.");
  5527. }
  5528. /*
  5529. Function: Command_Languages()
  5530. Purpose : Show's languages the player knows
  5531. Params :
  5532. Dev : Zcoretri
  5533. Example :
  5534. */
  5535. void Commands::Command_Languages(Client* client, Seperator* sep)
  5536. {
  5537. list<Language*>* languages = client->GetPlayer()->GetPlayerLanguages()->GetAllLanguages();
  5538. list<Language*>::iterator itr;
  5539. Language* language;
  5540. client->Message(CHANNEL_NARRATIVE, "You know the following languages:");
  5541. for(itr = languages->begin(); itr != languages->end(); itr++)
  5542. {
  5543. language = *itr;
  5544. client->Message(CHANNEL_NARRATIVE, "%s", language->GetName());
  5545. }
  5546. }
  5547. /*
  5548. Function: Command_SetLanguage()
  5549. Purpose : Handles language commands
  5550. Params : Language ID
  5551. Dev : Zcoretri
  5552. Example :
  5553. */
  5554. void Commands::Command_SetLanguage(Client* client, Seperator* sep)
  5555. {
  5556. Player* player = client->GetPlayer();
  5557. if (sep && sep->arg[0])
  5558. {
  5559. if(!sep->IsNumber(0))
  5560. {
  5561. //String passed in
  5562. const char* value = sep->arg[0];
  5563. if(strncasecmp(value, "Common", strlen(value)) == 0)
  5564. {
  5565. database.SaveCharacterCurrentLang(0, client->GetCharacterID(), client);
  5566. client->SendLanguagesUpdate(0);
  5567. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", value);
  5568. }
  5569. else
  5570. {
  5571. if(player->HasLanguage(value))
  5572. {
  5573. Language* language = player->GetPlayerLanguages()->GetLanguageByName(value);
  5574. database.SaveCharacterCurrentLang(language->GetID(), client->GetCharacterID(), client);
  5575. client->SendLanguagesUpdate(language->GetID());
  5576. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", language->GetName());
  5577. }
  5578. else
  5579. client->Message(CHANNEL_NARRATIVE, "You do not know how to speak %s", value);
  5580. }
  5581. }
  5582. else
  5583. {
  5584. //Number passed in
  5585. int32 id = atoul(sep->arg[0]);
  5586. if(player->HasLanguage(id))
  5587. {
  5588. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  5589. database.SaveCharacterCurrentLang(id, client->GetCharacterID(), client);
  5590. client->SendLanguagesUpdate(id);
  5591. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", language->GetName());
  5592. }
  5593. else
  5594. {
  5595. Language* language = master_languages_list.GetLanguage(id);
  5596. client->Message(CHANNEL_NARRATIVE, "You do not know how to speak %s", language->GetName());
  5597. }
  5598. }
  5599. }
  5600. else
  5601. {
  5602. //No value was passed in
  5603. int32 id = database.GetCharacterCurrentLang(client->GetCharacterID(), player);
  5604. if(id > 0)
  5605. {
  5606. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  5607. client->Message(CHANNEL_NARRATIVE, "You are currently speaking %s ", language->GetName());
  5608. }
  5609. else
  5610. client->Message(CHANNEL_NARRATIVE, "You are currently speaking Common");
  5611. }
  5612. }
  5613. /*
  5614. Function: Command_LastName()
  5615. Purpose : Sets player surname
  5616. Params : Name text
  5617. Dev : theFoof
  5618. Example :
  5619. */
  5620. void Commands::Command_LastName(Client* client, Seperator* sep)
  5621. {
  5622. if (!client)
  5623. return;
  5624. if (sep && sep->arg[0])
  5625. {
  5626. if (!client->GetPlayer()->get_character_flag(CF_ENABLE_CHANGE_LASTNAME)){
  5627. client->Message(CHANNEL_COLOR_YELLOW, "You must be atleast level %i to change your last name.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  5628. return;
  5629. }
  5630. client->RemovePendingLastName();
  5631. uchar* checkname = (uchar*)sep->arg[0];
  5632. bool valid_name = true;
  5633. for (int32 i = 0; i < strlen(sep->arg[0]); i++) {
  5634. if (!alpha_check(checkname[i])) {
  5635. valid_name = false;
  5636. break;
  5637. }
  5638. }
  5639. if (!valid_name) {
  5640. client->Message(CHANNEL_COLOR_YELLOW, "Your last name can only contain letters.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  5641. return;
  5642. }
  5643. string last_name = (string)sep->arg[0];
  5644. int8 max_length = rule_manager.GetGlobalRule(R_Player, MaxLastNameLength)->GetInt8();
  5645. int8 min_length = rule_manager.GetGlobalRule(R_Player, MinLastNameLength)->GetInt8();
  5646. if (last_name.length() <= max_length && last_name.length() >= min_length){
  5647. client->SetPendingLastName(last_name);
  5648. client->SendLastNameConfirmation();
  5649. }
  5650. else
  5651. client->Message(CHANNEL_COLOR_YELLOW, "Your last name must be between %i and %i characters long.", min_length, max_length);
  5652. }
  5653. }
  5654. /*
  5655. Function: Command_ConfirmLastName()
  5656. Purpose : Confirms setting of player surname
  5657. Params : Name text
  5658. Dev : theFoof
  5659. Example :
  5660. */
  5661. void Commands::Command_ConfirmLastName(Client* client, Seperator* sep)
  5662. {
  5663. if (!client)
  5664. return;
  5665. string* name = client->GetPendingLastName();
  5666. if (name){
  5667. Player* player = client->GetPlayer();
  5668. player->SetLastName(name->c_str(), false);
  5669. client->SendTitleUpdate();
  5670. player->SetCharSheetChanged(true);
  5671. client->RemovePendingLastName();
  5672. }
  5673. }
  5674. /*
  5675. Function: Command_Location()
  5676. Purpose : Display's Help for /location commands
  5677. Params :
  5678. Dev : Scatman
  5679. Example : /location = show's help for command
  5680. */
  5681. void Commands::Command_Location(Client* client)
  5682. {
  5683. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Valid /location commands are:");
  5684. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location create [name] (include y). Include y defaults to false");
  5685. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location add [location id]");
  5686. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location remove [location point id]");
  5687. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location delete [location id]");
  5688. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location list [locations|points] [location id if points used]");
  5689. }
  5690. /*
  5691. Function: Command_LocationAdd()
  5692. Purpose : Add's a location to an existing location config
  5693. Params : location_id
  5694. Dev : Scatman
  5695. Example : /location add {location_id}
  5696. */
  5697. void Commands::Command_LocationAdd(Client* client, Seperator* sep)
  5698. {
  5699. if (sep && sep->arg[0] && sep->IsNumber(0))
  5700. {
  5701. int32 location_id = atoul(sep->arg[0]);
  5702. float x = client->GetPlayer()->GetX();
  5703. float y = client->GetPlayer()->GetY();
  5704. float z = client->GetPlayer()->GetZ();
  5705. if (database.AddLocationPoint(location_id, x, y, z))
  5706. client->Message(CHANNEL_COLOR_YELLOW, "Point (%f, %f, %f) was successfully added to location %u", x, y, z, location_id);
  5707. else
  5708. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist. Use /location create to create one", location_id);
  5709. }
  5710. else
  5711. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location add [location id]");
  5712. }
  5713. /*
  5714. Function: Command_LocationCreate()
  5715. Purpose : Creates a new location config
  5716. Params : location name, 0/1 for include_y (optional)
  5717. Dev : Scatman
  5718. Example : /location create Test 1 = creates a new location named Test with include_y True
  5719. */
  5720. void Commands::Command_LocationCreate(Client* client, Seperator* sep)
  5721. {
  5722. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  5723. {
  5724. const char* name = sep->arg[0];
  5725. bool include_y = false;
  5726. if (sep->arg[1] && sep->IsNumber(1) && atoi(sep->arg[1]) > 0)
  5727. include_y = true;
  5728. int32 location_id = database.CreateLocation(client->GetPlayer()->GetZone()->GetZoneID(), client->GetPlayer()->appearance.pos.grid_id, name, include_y);
  5729. if (location_id > 0)
  5730. client->Message(CHANNEL_COLOR_YELLOW, "Location '%s' was successfully created with location id %u", name, location_id);
  5731. else
  5732. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the requested location");
  5733. }
  5734. else
  5735. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location create [name] (include_y). Include y defaults to false");
  5736. }
  5737. /*
  5738. Function: Command_LocationDelete()
  5739. Purpose : Delete's a location config and all it's location points
  5740. Params : location_id
  5741. Dev : Scatman
  5742. Example : /location delete {location_id}
  5743. */
  5744. void Commands::Command_LocationDelete(Client* client, Seperator* sep)
  5745. {
  5746. if (sep && sep->arg[0] && sep->IsNumber(0))
  5747. {
  5748. int32 location_id = atoul(sep->arg[0]);
  5749. if (database.DeleteLocation(location_id))
  5750. client->Message(CHANNEL_COLOR_YELLOW, "Location id %u and all its points were successfully deleted", location_id);
  5751. else
  5752. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist", location_id);
  5753. }
  5754. else
  5755. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location delete [location id]");
  5756. }
  5757. /*
  5758. Function: Command_LocationList()
  5759. Purpose : Display's a list of location points
  5760. Params : location_id
  5761. Dev : Scatman
  5762. Example : /location list {location_id}
  5763. */
  5764. void Commands::Command_LocationList(Client* client, Seperator* sep)
  5765. {
  5766. if (sep && sep->arg[0])
  5767. {
  5768. const char* option = sep->arg[0];
  5769. if (strncmp(option, "locations", strlen(option)) == 0)
  5770. database.ListLocations(client);
  5771. else if (strncmp(option, "points", strlen(option)) == 0 && sep->arg[1] && sep->IsNumber(1))
  5772. {
  5773. int32 location_id = atoul(sep->arg[1]);
  5774. database.ListLocationPoints(client, location_id);
  5775. }
  5776. else
  5777. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  5778. }
  5779. else
  5780. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  5781. }
  5782. /*
  5783. Function: Command_LocationRemove()
  5784. Purpose : Removes a single location point from a location config
  5785. Params : location_point_id (gotten from /location list {id})
  5786. Dev : Scatman
  5787. Example : /location remove 1 = will remove location_point_id 1
  5788. */
  5789. void Commands::Command_LocationRemove(Client* client, Seperator* sep)
  5790. {
  5791. if (sep && sep->arg[0] && sep->IsNumber(0))
  5792. {
  5793. int32 location_point_id = atoul(sep->arg[0]);
  5794. if (database.DeleteLocationPoint(location_point_id))
  5795. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Location point was successfully deleted");
  5796. else
  5797. client->Message(CHANNEL_COLOR_YELLOW, "Location point with ID %u does not exist", location_point_id);
  5798. }
  5799. else
  5800. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location remove [location point id]");
  5801. }
  5802. /*
  5803. Function: Command_Merchant()
  5804. Purpose : Handles Merchant commands
  5805. Params : list
  5806. Dev : Scatman
  5807. Example : /merchant list
  5808. */
  5809. void Commands::Command_Merchant(Client* client, Seperator* sep, int handler)
  5810. {
  5811. if( handler == COMMAND_MERCHANT )
  5812. {
  5813. // /merchant command by itself shows help (to be extended)
  5814. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  5815. return;
  5816. }
  5817. else if( handler == COMMAND_MERCHANT_LIST )
  5818. {
  5819. // /merchant list command expects "description" param
  5820. if (sep && sep->arg[0])
  5821. {
  5822. const char* merchant_description = sep->argplus[0];
  5823. client->Message(CHANNEL_COLOR_YELLOW, "Listing merchants like '%s':", merchant_description);
  5824. map<int32, MerchantInfo*>* merchant_info = world.GetMerchantInfo();
  5825. map<int32, MerchantInfo*>::iterator itr;
  5826. for (itr = merchant_info->begin(); itr != merchant_info->end(); itr++)
  5827. {
  5828. string description = database.GetMerchantDescription(itr->first);
  5829. if (ToLower(description).find(ToLower(string(merchant_description))) < 0xFFFFFFFF)
  5830. client->Message(CHANNEL_COLOR_YELLOW, "Merchant ID: %u, Description: %s", itr->first, description.c_str());
  5831. }
  5832. }
  5833. else // no description
  5834. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  5835. }
  5836. }
  5837. /*
  5838. Function: Command_Modify()
  5839. Purpose : to replace our other "set" commands
  5840. Params : System = the system to modify, Action = the action to perform, Target = what to change (target, or index)
  5841. Dev : John Adams
  5842. Example : /modify spell set name "Aegolism III"
  5843. */
  5844. void Commands::Command_Modify(Client* client)
  5845. {
  5846. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /modify [system] [action] [field] [value] {target|id}");
  5847. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Systems: character, faction, guild, item, skill, spawn, spell, zone");
  5848. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Actions: set, create, delete, add, remove");
  5849. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Value : field name in the table being modified");
  5850. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target : modify current target, or specified {system} ID");
  5851. }
  5852. /*
  5853. Function: Command_ModifySpawn()
  5854. Purpose : replace "spawn set" commands
  5855. Params : Action : the action to perform (or special handler)
  5856. : Field : the DB field to change
  5857. : Value : what to set the value to
  5858. : Target : what object to change (my target, or spawn_id)
  5859. Dev : John Adams
  5860. Example : /modify spawn set name "Lady Vox"
  5861. :
  5862. Note : Special Handlers, like "zoneto" for Signs
  5863. : /modify spawn zoneto
  5864. : Will set a sign's zone x/y/z to my current coords
  5865. */
  5866. void Commands::Command_ModifySpawn(Client* client, Seperator* sep)
  5867. {
  5868. PrintSep(sep, "COMMAND_MODIFY");
  5869. // need at least 2 args for a valid command
  5870. if( sep && sep->arg[1] )
  5871. {
  5872. // JA: just a quick implementation because I need it :)
  5873. if (strcmp(sep->arg[0], "zoneto") == 0)
  5874. {
  5875. if( sep->IsNumber(1) )
  5876. {
  5877. int32 spawn_id = atoul(sep->arg[1]);
  5878. float x_coord = client->GetPlayer()->GetX();
  5879. float y_coord = client->GetPlayer()->GetY();
  5880. float z_coord = client->GetPlayer()->GetZ();
  5881. float h_coord = client->GetPlayer()->GetHeading();
  5882. database.SaveSignZoneToCoords(spawn_id, x_coord, y_coord, z_coord, h_coord);
  5883. }
  5884. else
  5885. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify spawn zoneto spawn_id - sets spawn_id to your coords");
  5886. }
  5887. }
  5888. else
  5889. Command_Modify(client);
  5890. }
  5891. /*
  5892. Function: Command_ModifyCharacter()
  5893. Purpose : to replace our other "set" commands
  5894. Params : Action : Add, Remove
  5895. : Field : copper, silver, gold, plat
  5896. : Value : min 1, max unlimited
  5897. : Target : Self, Player
  5898. Dev : Cynnar
  5899. Example : /modify character add gold 50
  5900. : /modify character remove silver 25
  5901. */
  5902. void Commands::Command_ModifyCharacter(Client* client, Seperator* sep)
  5903. {
  5904. PrintSep(sep, "COMMAND_MODIFY");
  5905. int64 value = 0;
  5906. Player* player = client->GetPlayer();
  5907. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  5908. player = (Player*)player->GetTarget();
  5909. // need at least 2 args for a valid command
  5910. if( sep && sep->arg[1] )
  5911. {
  5912. if (strcmp(sep->arg[0], "add") == 0)
  5913. {
  5914. if (strcmp(sep->arg[1], "copper") == 0)
  5915. {
  5916. value = atoi64(sep->arg[2]);
  5917. player->AddCoins(value);
  5918. if (client->GetPlayer() == player)
  5919. {
  5920. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu copper coin%s", value, (value > 1 ? "s" : ""));
  5921. }
  5922. else {
  5923. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu copper coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  5924. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu copper coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  5925. }
  5926. }
  5927. else if (strcmp(sep->arg[1], "silver") == 0)
  5928. {
  5929. value = atoi64(sep->arg[2]) * 100;
  5930. player->AddCoins(value);
  5931. if (client->GetPlayer() == player)
  5932. {
  5933. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu silver coin%s", value / 100, (value > 1 ? "s" : ""));
  5934. }
  5935. else {
  5936. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu silver coin%s", player->GetName(), value / 100, (value > 1 ? "s" : ""));
  5937. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu silver coin%s", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  5938. }
  5939. }
  5940. else if (strcmp(sep->arg[1], "gold") == 0)
  5941. {
  5942. value = atoi64(sep->arg[2]) * 10000;
  5943. player->AddCoins(value);
  5944. if (client->GetPlayer() == player)
  5945. {
  5946. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu gold coin%s", value / 10000, (value > 1 ? "s" : ""));
  5947. }
  5948. else {
  5949. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu gold coin%s", player->GetName(), value / 10000, (value > 1 ? "s" : ""));
  5950. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu gold coin%s", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  5951. }
  5952. }
  5953. else if (strcmp(sep->arg[1], "plat") == 0)
  5954. {
  5955. value = atoi64(sep->arg[2]) * 1000000;
  5956. player->AddCoins(value);
  5957. if (client->GetPlayer() == player)
  5958. {
  5959. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu platinum coin%s", value / 1000000, (value > 1 ? "s" : ""));
  5960. }
  5961. else {
  5962. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu platinum coin%s", player->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  5963. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu platinum coin%s", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  5964. }
  5965. }
  5966. else
  5967. {
  5968. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  5969. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  5970. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  5971. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character add copper 20");
  5972. }
  5973. }
  5974. else if (strcmp(sep->arg[0], "remove") == 0)
  5975. {
  5976. if (strcmp(sep->arg[1], "copper") == 0)
  5977. {
  5978. value = atoi64(sep->arg[2]);
  5979. player->RemoveCoins(value);
  5980. if (client->GetPlayer() == player)
  5981. {
  5982. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from yourself", value, (value > 1 ? "s" : ""));
  5983. }
  5984. else {
  5985. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from %s", value, (value > 1 ? "s" : ""), player->GetName());
  5986. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu copper coin%s from you", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  5987. }
  5988. }
  5989. else if (strcmp(sep->arg[1], "silver") == 0)
  5990. {
  5991. value = atoi64(sep->arg[2]) * 100;
  5992. player->RemoveCoins(value);
  5993. if (client->GetPlayer() == player)
  5994. {
  5995. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from yourself", value / 100, (value > 1 ? "s" : ""));
  5996. }
  5997. else {
  5998. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from %s", value / 100, (value > 1 ? "s" : ""), player->GetName());
  5999. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu silver coin%s from you", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  6000. }
  6001. }
  6002. else if (strcmp(sep->arg[1], "gold") == 0)
  6003. {
  6004. value = atoi64(sep->arg[2]) * 10000;
  6005. player->RemoveCoins(value);
  6006. if (client->GetPlayer() == player)
  6007. {
  6008. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from yourself", value / 10000, (value > 1 ? "s" : ""));
  6009. }
  6010. else {
  6011. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from %s", value / 10000, (value > 1 ? "s" : ""), player->GetName());
  6012. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu gold coin%s from you", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  6013. }
  6014. }
  6015. else if (strcmp(sep->arg[1], "plat") == 0)
  6016. {
  6017. value = atoi64(sep->arg[2]) * 1000000;
  6018. player->RemoveCoins(value);
  6019. if (client->GetPlayer() == player)
  6020. {
  6021. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from yourself", value / 1000000, (value > 1 ? "s" : ""));
  6022. }
  6023. else {
  6024. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from %s", value / 1000000, (value > 1 ? "s" : ""), player->GetName());
  6025. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu platinum coin%s from you", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  6026. }
  6027. }
  6028. else
  6029. {
  6030. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  6031. }
  6032. }
  6033. else if (strcmp(sep->arg[0], "set") == 0) {
  6034. if (strcmp(sep->arg[1], "tslevel") == 0) {
  6035. int8 level = atoi(sep->arg[2]);
  6036. if (level > 0 && level < 256) {
  6037. if (player) {
  6038. if (client->GetPlayer() == player)
  6039. client->ChangeTSLevel(player->GetTSLevel(), level);
  6040. else
  6041. player->GetZone()->GetClientBySpawn(player)->ChangeTSLevel(player->GetTSLevel(), level);
  6042. }
  6043. }
  6044. else
  6045. client->SimpleMessage(CHANNEL_ERROR, "Level must be between 1 - 255");
  6046. }
  6047. else if (strcmp(sep->arg[1], "tsclass") == 0) {
  6048. int8 tsclass = atoi(sep->arg[2]);
  6049. player->SetTradeskillClass(tsclass);
  6050. player->GetInfoStruct()->tradeskill_class1 = classes.GetTSBaseClass(player->GetTradeskillClass());
  6051. player->GetInfoStruct()->tradeskill_class2 = classes.GetSecondaryTSBaseClass(player->GetTradeskillClass());
  6052. player->GetInfoStruct()->tradeskill_class3 = player->GetTradeskillClass();
  6053. player->SetCharSheetChanged(true);
  6054. }
  6055. }
  6056. }
  6057. else
  6058. {
  6059. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  6060. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  6061. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  6062. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  6063. }
  6064. }
  6065. void Commands::Command_ModifyFaction(Client* client, Seperator* sep)
  6066. {
  6067. PrintSep(sep, "COMMAND_MODIFY");
  6068. // need at least 2 args for a valid command
  6069. if( sep && sep->arg[1] )
  6070. {
  6071. }
  6072. else
  6073. Command_Modify(client);
  6074. }
  6075. void Commands::Command_ModifyGuild(Client* client, Seperator* sep)
  6076. {
  6077. PrintSep(sep, "COMMAND_MODIFY");
  6078. // need at least 2 args for a valid command
  6079. if( sep && sep->arg[1] )
  6080. {
  6081. }
  6082. else
  6083. Command_Modify(client);
  6084. }
  6085. void Commands::Command_ModifyItem(Client* client, Seperator* sep)
  6086. {
  6087. PrintSep(sep, "COMMAND_MODIFY");
  6088. // need at least 2 args for a valid command
  6089. if( sep && sep->arg[1] )
  6090. {
  6091. }
  6092. else
  6093. Command_Modify(client);
  6094. }
  6095. /*
  6096. Function: Command_ModifyQuest()
  6097. Purpose : to list players quest and completed quests
  6098. Params : Action : list, completed
  6099. : Target : Self, Player
  6100. Dev : Cynnar
  6101. Example : /modify quest list
  6102. : /modify quest completed
  6103. */
  6104. void Commands::Command_ModifyQuest(Client* client, Seperator* sep)
  6105. {
  6106. PrintSep(sep, "COMMAND_MODIFY");
  6107. int64 value = 0;
  6108. Player* player = client->GetPlayer();
  6109. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  6110. player = (Player*)player->GetTarget();
  6111. // need at least 2 args for a valid command
  6112. if (sep && sep->arg[1])
  6113. {
  6114. if (strcmp(sep->arg[0], "list") == 0)
  6115. {
  6116. map<int32, Quest*>* quests = player->GetPlayerQuests();
  6117. map<int32, Quest*>::iterator itr;
  6118. client->Message(CHANNEL_COLOR_YELLOW, "%s's Quest List:.", client->GetPlayer()->GetName());
  6119. if (quests->size() == 0)
  6120. client->Message(CHANNEL_COLOR_YELLOW, "%s has no quests.", client->GetPlayer()->GetName());
  6121. else
  6122. {
  6123. for (itr = quests->begin(); itr != quests->end(); itr++)
  6124. {
  6125. Quest* quest = itr->second;
  6126. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  6127. }
  6128. }
  6129. }
  6130. else if (strcmp(sep->arg[0], "completed") == 0)
  6131. {
  6132. map<int32, Quest*>* quests = player->GetCompletedPlayerQuests();
  6133. map<int32, Quest*>::iterator itr;
  6134. client->Message(CHANNEL_COLOR_YELLOW, "%s's Completed Quest List:.", client->GetPlayer()->GetName());
  6135. if (quests->size() == 0)
  6136. client->Message(CHANNEL_COLOR_YELLOW, "%s has no completed quests.", client->GetPlayer()->GetName());
  6137. else
  6138. {
  6139. for (itr = quests->begin(); itr != quests->end(); itr++)
  6140. {
  6141. Quest* quest = itr->second;
  6142. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  6143. }
  6144. }
  6145. }
  6146. // Add in a progress step, and a LogWrite() for tracking GM Commands.
  6147. // LogWrite(LUA__DEBUG, 0, "LUA", "Quest: %s, function: %s", quest->GetName(), function);
  6148. else if (strcmp(sep->arg[0], "remove") == 0)
  6149. {
  6150. int32 quest_id = 0;
  6151. if (sep && sep->arg[1] && sep->IsNumber(1))
  6152. quest_id = atoul(sep->arg[1]);
  6153. if (quest_id > 0)
  6154. {
  6155. if (lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0)
  6156. {
  6157. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  6158. if (quest)
  6159. if (client->GetPlayer() == player)
  6160. {
  6161. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been removed from your journal", quest->GetName());
  6162. }
  6163. else
  6164. {
  6165. client->Message(CHANNEL_COLOR_YELLOW, "You have removed the quest %s from %s's journal", quest->GetName(), player->GetName());
  6166. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s has removed the quest %s from your journal", client->GetPlayer()->GetName(), quest->GetName());
  6167. }
  6168. LogWrite(COMMAND__INFO, 0, "GM Command", "%s removed the quest %s from %s", client->GetPlayer()->GetName(), quest->GetName(), player->GetName());
  6169. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  6170. }
  6171. client->RemovePlayerQuest(quest_id);
  6172. client->GetCurrentZone()->SendQuestUpdates(client);
  6173. }
  6174. }
  6175. else if (strcmp(sep->arg[0], "advance") == 0)
  6176. {
  6177. int32 quest_id = 0;
  6178. int32 step = 0;
  6179. if (sep && sep->arg[1] && sep->IsNumber(1))
  6180. {
  6181. quest_id = atoul(sep->arg[1]);
  6182. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  6183. if (sep && sep->arg[2] && sep->IsNumber(1))
  6184. {
  6185. step = atoul(sep->arg[2]);
  6186. if (quest_id > 0 && step > 0)
  6187. {
  6188. if (player && player->IsPlayer() && quest_id > 0 && step > 0 && (player->player_quests.count(quest_id) > 0))
  6189. {
  6190. if (client)
  6191. {
  6192. client->AddPendingQuestUpdate(quest_id, step);
  6193. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been advanced one step.", quest->GetName());
  6194. LogWrite(COMMAND__INFO, 0, "GM Command", "%s advanced the quest %s one step", client->GetPlayer()->GetName(), quest->GetName());
  6195. }
  6196. }
  6197. }
  6198. else
  6199. {
  6200. client->Message(CHANNEL_COLOR_RED, "Quest ID and Step Number must be greater than 0!");
  6201. }
  6202. }
  6203. else
  6204. {
  6205. client->Message(CHANNEL_COLOR_RED, "Step Number must be a number!");
  6206. }
  6207. }
  6208. else
  6209. {
  6210. client->Message(CHANNEL_COLOR_RED, "Quest ID must be a number!");
  6211. }
  6212. }
  6213. else
  6214. {
  6215. Command_Modify(client);
  6216. }
  6217. }
  6218. else
  6219. {
  6220. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify quest [action] [quest id] [step number]");
  6221. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: list, completed, remove, advance");
  6222. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest list");
  6223. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest remove 156");
  6224. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest advance 50 1");
  6225. }
  6226. }
  6227. void Commands::Command_ModifySkill(Client* client, Seperator* sep)
  6228. {
  6229. PrintSep(sep, "COMMAND_MODIFY");
  6230. // need at least 2 args for a valid command
  6231. if( sep && sep->arg[1] )
  6232. {
  6233. if (strcmp(sep->arg[0], "add") == 0) {
  6234. const char* skill_name = sep->argplus[1];
  6235. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6236. if (skill) {
  6237. Player* player = 0;
  6238. Client* to_client = 0;
  6239. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  6240. player = (Player*)client->GetPlayer()->GetTarget();
  6241. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  6242. }
  6243. else {
  6244. player = client->GetPlayer();
  6245. to_client = client;
  6246. }
  6247. if (player)
  6248. {
  6249. if (!player->GetSkills()->HasSkill(skill->skill_id))
  6250. {
  6251. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  6252. if (to_client == client) {
  6253. client->Message(CHANNEL_STATUS, "Added skill '%s'.", skill_name);
  6254. }
  6255. else {
  6256. client->Message(CHANNEL_STATUS, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  6257. to_client->Message(CHANNEL_STATUS, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  6258. }
  6259. }
  6260. else
  6261. client->Message(CHANNEL_STATUS, "%s already has the skill '%s'.", to_client == client ? "You" : player->GetName(), skill_name);
  6262. }
  6263. }
  6264. else
  6265. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  6266. }
  6267. else if (strcmp(sep->arg[0], "remove") == 0) {
  6268. const char* skill_name = sep->argplus[1];
  6269. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6270. if (skill) {
  6271. Player* player = 0;
  6272. Client* to_client = 0;
  6273. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  6274. player = (Player*)client->GetPlayer()->GetTarget();
  6275. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  6276. }
  6277. else {
  6278. player = client->GetPlayer();
  6279. to_client = client;
  6280. }
  6281. if (player)
  6282. {
  6283. if (player->GetSkills()->HasSkill(skill->skill_id))
  6284. {
  6285. player->RemoveSkillFromDB(skill, true);
  6286. if (client == to_client) {
  6287. client->Message(CHANNEL_STATUS, "Removed skill '%s'.", skill_name);
  6288. }
  6289. else {
  6290. client->Message(CHANNEL_STATUS, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  6291. to_client->Message(CHANNEL_STATUS, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  6292. }
  6293. }
  6294. else {
  6295. if (client == to_client)
  6296. client->Message(CHANNEL_STATUS, "You do not have the skill '%s'.", skill_name);
  6297. else
  6298. client->Message(CHANNEL_STATUS, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  6299. }
  6300. }
  6301. }
  6302. else
  6303. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  6304. }
  6305. else if (strcmp(sep->arg[0], "set") == 0) {
  6306. if (!sep->IsNumber(2)) {
  6307. client->Message(CHANNEL_STATUS, "The last parameter must be a number.");
  6308. return;
  6309. }
  6310. const char* skill_name = sep->arg[1];
  6311. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6312. if (skill) {
  6313. int16 val = atoi(sep->arg[2]);
  6314. Player* player = 0;
  6315. Client* to_client = 0;
  6316. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  6317. player = (Player*)client->GetPlayer()->GetTarget();
  6318. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  6319. }
  6320. else {
  6321. player = client->GetPlayer();
  6322. to_client = client;
  6323. }
  6324. if (player)
  6325. {
  6326. if (player->GetSkills()->HasSkill(skill->skill_id)) {
  6327. player->GetSkills()->SetSkill(skill->skill_id, val);
  6328. if (client != to_client)
  6329. client->Message(CHANNEL_STATUS, "You set %s's '%s' skill to %i.", player->GetName(), skill_name, val);
  6330. to_client->Message(CHANNEL_STATUS, "Your '%s' skill has been set to %i.", skill_name, val);
  6331. }
  6332. else {
  6333. client->Message(CHANNEL_STATUS, "Target does not have the skill '%s'.", skill_name);
  6334. }
  6335. }
  6336. }
  6337. else {
  6338. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  6339. }
  6340. }
  6341. else {
  6342. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  6343. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  6344. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  6345. }
  6346. }
  6347. else {
  6348. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  6349. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  6350. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  6351. }
  6352. }
  6353. void Commands::Command_ModifySpell(Client* client, Seperator* sep)
  6354. {
  6355. PrintSep(sep, "COMMAND_MODIFY");
  6356. // need at least 2 args for a valid command
  6357. if( sep && sep->arg[1] )
  6358. {
  6359. }
  6360. else
  6361. Command_Modify(client);
  6362. }
  6363. void Commands::Command_ModifyZone(Client* client, Seperator* sep)
  6364. {
  6365. PrintSep(sep, "COMMAND_MODIFY");
  6366. // need at least 2 args for a valid command
  6367. if( sep && sep->arg[1] )
  6368. {
  6369. }
  6370. else
  6371. Command_Modify(client);
  6372. }
  6373. /*
  6374. Function: Command_MOTD()
  6375. Purpose : Displays server MOTD
  6376. Params :
  6377. Dev : LethalEncounter
  6378. Example : /motd
  6379. */
  6380. void Commands::Command_MOTD(Client* client)
  6381. {
  6382. if (client)
  6383. ClientPacketFunctions::SendMOTD(client);
  6384. }
  6385. /*
  6386. Function: Command_Pet()
  6387. Purpose : Handle Pet {Command} commands
  6388. Params : attack, backoff, preserve_master, preserve_self, follow, stay, getlost
  6389. Dev :
  6390. Example : /pet preserve_master
  6391. */
  6392. void Commands::Command_Pet(Client* client, Seperator* sep)
  6393. {
  6394. PrintSep(sep, "COMMAND_PET");
  6395. //LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Pet Commands");
  6396. //client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6397. if (!sep || !sep->arg[0])
  6398. return; // should have sep->arg[0] filled
  6399. if (strcmp(sep->arg[0], "hide") == 0) {
  6400. // doing /pet hide will toggle the hide status on all the pets that can be hidden
  6401. Entity* pet = client->GetPlayer()->GetDeityPet();
  6402. if (pet) {
  6403. if (pet->IsPrivateSpawn())
  6404. client->GetPlayer()->HideDeityPet(false);
  6405. else
  6406. client->GetPlayer()->HideDeityPet(true);
  6407. }
  6408. pet = client->GetPlayer()->GetCosmeticPet();
  6409. if (pet) {
  6410. if (pet->IsPrivateSpawn())
  6411. client->GetPlayer()->HideCosmeticPet(false);
  6412. else
  6413. client->GetPlayer()->HideCosmeticPet(true);
  6414. }
  6415. return;
  6416. }
  6417. // below is for all combat pets
  6418. if (!client->GetPlayer()->HasPet()) {
  6419. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a pet.");
  6420. return;
  6421. }
  6422. if (strcmp(sep->arg[0], "stay") == 0) {
  6423. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to stay.");
  6424. client->GetPlayer()->GetInfoStruct()->pet_movement = 1;
  6425. client->GetPlayer()->SetCharSheetChanged(true);
  6426. if (client->GetPlayer()->GetPet())
  6427. client->GetPlayer()->GetPet()->following = false;
  6428. if (client->GetPlayer()->GetCharmedPet())
  6429. client->GetPlayer()->GetCharmedPet()->following = false;
  6430. }
  6431. else if (strcmp(sep->arg[0], "follow") == 0) {
  6432. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to follow.");
  6433. client->GetPlayer()->GetInfoStruct()->pet_movement = 2;
  6434. client->GetPlayer()->SetCharSheetChanged(true);
  6435. }
  6436. else if (strcmp(sep->arg[0], "preserve_master") == 0) {
  6437. if (client->GetPlayer()->GetInfoStruct()->pet_behavior & 1) {
  6438. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect you.");
  6439. client->GetPlayer()->GetInfoStruct()->pet_behavior -= 1;
  6440. }
  6441. else {
  6442. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect you.");
  6443. client->GetPlayer()->GetInfoStruct()->pet_behavior += 1;
  6444. }
  6445. client->GetPlayer()->SetCharSheetChanged(true);
  6446. }
  6447. else if (strcmp(sep->arg[0], "preserve_self") == 0) {
  6448. if (client->GetPlayer()->GetInfoStruct()->pet_behavior & 2) {
  6449. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect itself.");
  6450. client->GetPlayer()->GetInfoStruct()->pet_behavior -= 2;
  6451. }
  6452. else {
  6453. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect itself.");
  6454. client->GetPlayer()->GetInfoStruct()->pet_behavior += 2;
  6455. }
  6456. client->GetPlayer()->SetCharSheetChanged(true);
  6457. }
  6458. else if (strcmp(sep->arg[0], "backoff") == 0) {
  6459. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to back down.");
  6460. if (client->GetPlayer()->GetPet())
  6461. ((NPC*)client->GetPlayer()->GetPet())->Brain()->ClearHate();
  6462. if (client->GetPlayer()->GetCharmedPet())
  6463. ((NPC*)client->GetPlayer()->GetCharmedPet())->Brain()->ClearHate();
  6464. client->GetPlayer()->GetInfoStruct()->pet_behavior = 0;
  6465. client->GetPlayer()->SetCharSheetChanged(true);
  6466. }
  6467. else if (strcmp(sep->arg[0], "attack") == 0) {
  6468. if (client->GetPlayer()->HasTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  6469. if (client->GetPlayer()->AttackAllowed((Entity*)client->GetPlayer()->GetTarget())){
  6470. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to attack your target.");
  6471. if (client->GetPlayer()->GetPet())
  6472. client->GetPlayer()->GetPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  6473. if (client->GetPlayer()->GetCharmedPet())
  6474. client->GetPlayer()->GetCharmedPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  6475. }
  6476. else
  6477. client->Message(CHANNEL_COLOR_YELLOW, "You can not attack that.");
  6478. }
  6479. else
  6480. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a target.");
  6481. }
  6482. else if (strcmp(sep->arg[0], "getlost") == 0) {
  6483. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetPet());
  6484. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetCharmedPet());
  6485. client->Message(CHANNEL_COLOR_YELLOW, "You tell your pet to get lost.");
  6486. }
  6487. else
  6488. client->Message(CHANNEL_COLOR_YELLOW, "Unknown pet command.");
  6489. }
  6490. /*
  6491. Function: Command_PetName()
  6492. Purpose : Pet your name (???)
  6493. Params :
  6494. Dev :
  6495. Example :
  6496. */
  6497. void Commands::Command_PetName(Client* client, Seperator* sep)
  6498. {
  6499. PrintSep(sep, "COMMAND_PETNAME");
  6500. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Pet Name Command");
  6501. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6502. }
  6503. /*
  6504. Function: Command_NamePet()
  6505. Purpose : Name your pet
  6506. Params :
  6507. Dev :
  6508. Example :
  6509. */
  6510. void Commands::Command_NamePet(Client* client, Seperator* sep)
  6511. {
  6512. PrintSep(sep, "COMMAND_NAME_PET");
  6513. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Name Pet Command");
  6514. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6515. }
  6516. /*
  6517. Function: Command_Rename()
  6518. Purpose : Renames existing pet
  6519. Params :
  6520. Dev :
  6521. Example :
  6522. */
  6523. void Commands::Command_Rename(Client* client, Seperator* sep)
  6524. {
  6525. PrintSep(sep, "COMMAND_RENAME");
  6526. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Rename Pet Command");
  6527. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6528. }
  6529. /*
  6530. Function: Command_ConfirmRename()
  6531. Purpose : Confirms renaming your pet
  6532. Params :
  6533. Dev :
  6534. Example :
  6535. */
  6536. void Commands::Command_ConfirmRename(Client* client, Seperator* sep)
  6537. {
  6538. PrintSep(sep, "COMMAND_CONFIRMRENAME");
  6539. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Confirm Rename Pet Command");
  6540. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6541. }
  6542. /*
  6543. Function: Command_PetOptions()
  6544. Purpose : Sets various pet options
  6545. Params :
  6546. Dev :
  6547. Example :
  6548. */
  6549. void Commands::Command_PetOptions(Client* client, Seperator* sep)
  6550. {
  6551. PrintSep(sep, "COMMAND_PETOPTIONS");
  6552. Player* player = client->GetPlayer();
  6553. Spawn* target = player->GetTarget();
  6554. if (!target)
  6555. return;
  6556. if (target == player->GetPet())
  6557. client->SendPetOptionsWindow(player->GetPet()->GetName());
  6558. else if (target == player->GetCharmedPet())
  6559. client->SendPetOptionsWindow(player->GetCharmedPet()->GetName());
  6560. else if (target == player->GetCosmeticPet())
  6561. client->SendPetOptionsWindow(player->GetCosmeticPet()->GetName(), 0);
  6562. else if (target == player->GetDeityPet())
  6563. client->SendPetOptionsWindow(player->GetDeityPet()->GetName(), 0);
  6564. }
  6565. /*
  6566. Function: Command_Random()
  6567. Purpose : Handles /random dice roll in-game
  6568. Params : 1-100
  6569. Dev : Scatman
  6570. Example : /randon 1 100
  6571. */
  6572. void Commands::Command_Random(Client* client, Seperator* sep)
  6573. {
  6574. char message[256] = {0};
  6575. if (sep)
  6576. {
  6577. if (sep->GetArgNumber() == 0 && sep->IsNumber(0))
  6578. 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])));
  6579. else if (sep->GetArgNumber() > 0 && sep->IsNumber(0) && sep->IsNumber(1))
  6580. 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])));
  6581. else
  6582. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  6583. }
  6584. else
  6585. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  6586. client->GetPlayer()->GetZone()->HandleChatMessage(0, 0, CHANNEL_EMOTE, message);
  6587. }
  6588. /*
  6589. Function: Command_Randomize()
  6590. Purpose : Sets randomize (appearance) values for NPCs
  6591. Params : Attrib Name
  6592. Dev : Scatman
  6593. Example : /randomize gender 1 -- will randomize the NPCs gender (male/female)
  6594. */
  6595. void Commands::Command_Randomize(Client* client, Seperator* sep)
  6596. {
  6597. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  6598. if (target)
  6599. {
  6600. if (target->IsNPC())
  6601. {
  6602. if (sep && sep->arg[0] && !sep->IsNumber(0))
  6603. {
  6604. const char* value = sep->arg[0];
  6605. if (strncasecmp(value, "show", strlen(value)) == 0)
  6606. {
  6607. client->DisplayRandomizeFeatures(target->GetRandomize());
  6608. }
  6609. else
  6610. {
  6611. if (sep->arg[1] && sep->IsNumber(1))
  6612. {
  6613. int8 option = atoi(sep->arg[1]);
  6614. if (option == 0 || option == 1)
  6615. {
  6616. int32 feature = 0;
  6617. char feature_text[32] = {0};
  6618. if (strncasecmp(value, "gender", strlen(value)) == 0) {
  6619. feature = RANDOMIZE_GENDER;
  6620. strncpy(feature_text, "gender", sizeof(feature_text) - 1);
  6621. }
  6622. else if (strncasecmp(value, "race", strlen(value)) == 0) {
  6623. feature = RANDOMIZE_RACE;
  6624. strncpy(feature_text, "race", sizeof(feature_text) - 1);
  6625. }
  6626. else if (strncasecmp(value, "model", strlen(value)) == 0) {
  6627. feature = RANDOMIZE_MODEL_TYPE;
  6628. strncpy(feature_text, "model", sizeof(feature_text) - 1);
  6629. }
  6630. else if (strncasecmp(value, "facial_hair", strlen(value)) == 0) {
  6631. feature = RANDOMIZE_FACIAL_HAIR_TYPE;
  6632. strncpy(feature_text, "facial hair", sizeof(feature_text) - 1);
  6633. }
  6634. else if (strncasecmp(value, "hair", strlen(value)) == 0) {
  6635. feature = RANDOMIZE_HAIR_TYPE;
  6636. strncpy(feature_text, "hair", sizeof(feature_text) - 1);
  6637. }
  6638. else if (strncasecmp(value, "wing", strlen(value)) == 0) {
  6639. feature = RANDOMIZE_WING_TYPE;
  6640. strncpy(feature_text, "wings", sizeof(feature_text) - 1);
  6641. }
  6642. else if (strncasecmp(value, "cheek", strlen(value)) == 0) {
  6643. feature = RANDOMIZE_CHEEK_TYPE;
  6644. strncpy(feature_text, "cheeks", sizeof(feature_text) - 1);
  6645. }
  6646. else if (strncasecmp(value, "chin", strlen(value)) == 0) {
  6647. feature = RANDOMIZE_CHIN_TYPE;
  6648. strncpy(feature_text, "chin", sizeof(feature_text) - 1);
  6649. }
  6650. else if (strncasecmp(value, "ear", strlen(value)) == 0) {
  6651. feature = RANDOMIZE_EAR_TYPE;
  6652. strncpy(feature_text, "ears", sizeof(feature_text) - 1);
  6653. }
  6654. else if (strncasecmp(value, "eye_brow", strlen(value)) == 0) {
  6655. feature = RANDOMIZE_EYE_BROW_TYPE;
  6656. strncpy(feature_text, "eye brows", sizeof(feature_text) - 1);
  6657. }
  6658. else if (strncasecmp(value, "eye", strlen(value)) == 0) {
  6659. feature = RANDOMIZE_EYE_TYPE;
  6660. strncpy(feature_text, "eyes", sizeof(feature_text) - 1);
  6661. }
  6662. else if (strncasecmp(value, "lip", strlen(value)) == 0) {
  6663. feature = RANDOMIZE_LIP_TYPE;
  6664. strncpy(feature_text, "lips", sizeof(feature_text) - 1);
  6665. }
  6666. else if (strncasecmp(value, "nose", strlen(value)) == 0) {
  6667. feature = RANDOMIZE_NOSE_TYPE;
  6668. strncpy(feature_text, "nose", sizeof(feature_text) - 1);
  6669. }
  6670. else if (strncasecmp(value, "eye_color", strlen(value)) == 0) {
  6671. feature = RANDOMIZE_EYE_COLOR;
  6672. strncpy(feature_text, "eye color", sizeof(feature_text) - 1);
  6673. }
  6674. else if (strncasecmp(value, "hair_color", strlen(value)) == 0) {
  6675. feature = RANDOMIZE_HAIR_TYPE_COLOR;
  6676. strncpy(feature_text, "hair color", sizeof(feature_text) - 1);
  6677. }
  6678. else if (strncasecmp(value, "hair_color1", strlen(value)) == 0) {
  6679. feature = RANDOMIZE_HAIR_COLOR1;
  6680. strncpy(feature_text, "hair color1", sizeof(feature_text) - 1);
  6681. }
  6682. else if (strncasecmp(value, "hair_color2", strlen(value)) == 0) {
  6683. feature = RANDOMIZE_HAIR_COLOR2;
  6684. strncpy(feature_text, "hair color2", sizeof(feature_text) - 1);
  6685. }
  6686. else if (strncasecmp(value, "hair_highlight", strlen(value)) == 0) {
  6687. feature = RANDOMIZE_HAIR_HIGHLIGHT;
  6688. strncpy(feature_text, "hair highlights", sizeof(feature_text) - 1);
  6689. }
  6690. else if (strncasecmp(value, "facial_hair_color", strlen(value)) == 0) {
  6691. feature = RANDOMIZE_HAIR_FACE_COLOR;
  6692. strncpy(feature_text, "facial hair color", sizeof(feature_text) - 1);
  6693. }
  6694. else if (strncasecmp(value, "facial_hair_color_highlight", strlen(value)) == 0) {
  6695. feature = RANDOMIZE_HAIR_FACE_HIGHLIGHT_COLOR;
  6696. strncpy(feature_text, "facial hair color highlights", sizeof(feature_text) - 1);
  6697. }
  6698. else if (strncasecmp(value, "hair_color_highlight", strlen(value)) == 0) {
  6699. feature = RANDOMIZE_HAIR_TYPE_HIGHLIGHT_COLOR;
  6700. strncpy(feature_text, "hair color highlights", sizeof(feature_text) - 1);
  6701. }
  6702. else if (strncasecmp(value, "skin_color", strlen(value)) == 0) {
  6703. feature = RANDOMIZE_SKIN_COLOR;
  6704. strncpy(feature_text, "skin color", sizeof(feature_text) - 1);
  6705. }
  6706. else if (strncasecmp(value, "wing_color1", strlen(value)) == 0) {
  6707. feature = RANDOMIZE_WING_COLOR1;
  6708. strncpy(feature_text, "wing color1", sizeof(feature_text) - 1);
  6709. }
  6710. else if (strncasecmp(value, "wing_color2", strlen(value)) == 0) {
  6711. feature = RANDOMIZE_WING_COLOR2;
  6712. strncpy(feature_text, "wing color2", sizeof(feature_text) - 1);
  6713. }
  6714. else {
  6715. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is not a valid feature to randomize.", value);
  6716. 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'.");
  6717. }
  6718. if (feature > 0) {
  6719. if (option == 1) {
  6720. if (target->GetRandomize() & feature)
  6721. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is already set to randomly generate their %s.", target->GetName(), feature_text);
  6722. else {
  6723. target->AddRandomize(feature);
  6724. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(feature);
  6725. database.UpdateRandomize(target->GetDatabaseID(), feature);
  6726. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will now generate their %s randomly.", target->GetName(), feature_text);
  6727. }
  6728. }
  6729. else {
  6730. if (target->GetRandomize() & feature) {
  6731. target->AddRandomize(-feature);
  6732. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(-feature);
  6733. database.UpdateRandomize(target->GetDatabaseID(), -feature);
  6734. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will no longer generate their %s randomly.", target->GetName(), feature_text);
  6735. }
  6736. else
  6737. client->Message(CHANNEL_COLOR_YELLOW, "'%s' already does not randomly generate their %s.", target->GetName(), feature_text);
  6738. }
  6739. }
  6740. }
  6741. else
  6742. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  6743. }
  6744. else
  6745. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  6746. }
  6747. }
  6748. else {
  6749. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /randomize [show | [feature [1|0]]");
  6750. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "'show' will display current configured features");
  6751. 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'.");
  6752. }
  6753. }
  6754. else
  6755. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "The target you wish to randomize must be an NPC.");
  6756. }
  6757. else
  6758. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select the target you wish to randomize.");
  6759. }
  6760. /*
  6761. Function: Command_ShowCloak()
  6762. Purpose : Character Settings combo box for Show Cloak
  6763. Params : true/false
  6764. Dev : John Adams
  6765. Example :
  6766. */
  6767. void Commands::Command_ShowCloak(Client* client, Seperator* sep)
  6768. {
  6769. Player* player = client->GetPlayer();
  6770. if (sep && sep->arg[0])
  6771. {
  6772. const char* value = sep->arg[0];
  6773. if (strncasecmp(value, "true", strlen(value)) == 0)
  6774. {
  6775. player->set_character_flag(CF_SHOW_CLOAK);
  6776. player->reset_character_flag(CF2_SHOW_RANGED);
  6777. }
  6778. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6779. player->reset_character_flag(CF_SHOW_CLOAK);
  6780. else
  6781. {
  6782. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6783. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6784. }
  6785. }
  6786. }
  6787. /*
  6788. Function: Command_ShowHelm()
  6789. Purpose : Character Settings combo box for Show Helm
  6790. Params : true/false
  6791. Dev : John Adams
  6792. Example :
  6793. */
  6794. void Commands::Command_ShowHelm(Client* client, Seperator* sep)
  6795. {
  6796. Player* player = client->GetPlayer();
  6797. if (sep && sep->arg[0])
  6798. {
  6799. const char* value = sep->arg[0];
  6800. if (strncasecmp(value, "true", strlen(value)) == 0)
  6801. {
  6802. player->reset_character_flag(CF_HIDE_HELM);
  6803. player->set_character_flag(CF_HIDE_HOOD);
  6804. }
  6805. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6806. player->set_character_flag(CF_HIDE_HELM);
  6807. else
  6808. {
  6809. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6810. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6811. }
  6812. }
  6813. }
  6814. /*
  6815. Function: Command_ShowHood()
  6816. Purpose : Character Settings combo box for Show Hood
  6817. Params : true/false
  6818. Dev : John Adams
  6819. Example :
  6820. */
  6821. void Commands::Command_ShowHood(Client* client, Seperator* sep)
  6822. {
  6823. Player* player = client->GetPlayer();
  6824. if (sep && sep->arg[0])
  6825. {
  6826. const char* value = sep->arg[0];
  6827. if (strncasecmp(value, "true", strlen(value)) == 0)
  6828. {
  6829. player->reset_character_flag(CF_HIDE_HOOD);
  6830. player->set_character_flag(CF_HIDE_HELM);
  6831. }
  6832. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6833. player->set_character_flag(CF_HIDE_HOOD);
  6834. else
  6835. {
  6836. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6837. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6838. }
  6839. }
  6840. }
  6841. /*
  6842. Function: Command_ShowHoodHelm()
  6843. Purpose : Character Settings combo box for Show Helm or Hood
  6844. Params : true/false
  6845. Dev : John Adams
  6846. Example :
  6847. */
  6848. void Commands::Command_ShowHoodHelm(Client* client, Seperator* sep)
  6849. {
  6850. Player* player = client->GetPlayer();
  6851. if (sep && sep->arg[0])
  6852. {
  6853. const char* value = sep->arg[0];
  6854. if (strncasecmp(value, "true", strlen(value)) == 0)
  6855. {
  6856. player->reset_character_flag(CF_HIDE_HOOD);
  6857. player->reset_character_flag(CF_HIDE_HELM);
  6858. }
  6859. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6860. {
  6861. // don't think we ever wind up in here...
  6862. player->set_character_flag(CF_HIDE_HOOD);
  6863. player->set_character_flag(CF_HIDE_HELM);
  6864. }
  6865. else
  6866. {
  6867. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6868. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6869. }
  6870. }
  6871. }
  6872. /*
  6873. Function: Command_ShowRanged()
  6874. Purpose : Character Settings combo box for Show Ranged weapon
  6875. Params : true/false
  6876. Dev : John Adams
  6877. Example :
  6878. */
  6879. void Commands::Command_ShowRanged(Client* client, Seperator* sep)
  6880. {
  6881. Player* player = client->GetPlayer();
  6882. if (sep && sep->arg[0])
  6883. {
  6884. const char* value = sep->arg[0];
  6885. if (strncasecmp(value, "true", strlen(value)) == 0)
  6886. {
  6887. player->set_character_flag(CF2_SHOW_RANGED);
  6888. player->reset_character_flag(CF_SHOW_CLOAK);
  6889. }
  6890. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6891. player->reset_character_flag(CF2_SHOW_RANGED);
  6892. else
  6893. {
  6894. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6895. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6896. }
  6897. }
  6898. }
  6899. /*
  6900. Function:
  6901. Purpose :
  6902. Params :
  6903. Dev :
  6904. Example :
  6905. */
  6906. void Commands::Command_Skills(Client* client, Seperator* sep, int handler)
  6907. {
  6908. Player* player = 0;
  6909. Client* to_client = 0;
  6910. if(client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  6911. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  6912. switch(handler)
  6913. {
  6914. case COMMAND_SKILL:
  6915. {
  6916. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill [add|remove|list] [skill name]");
  6917. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to add/remove skills for that player.");
  6918. break;
  6919. }
  6920. case COMMAND_SKILL_ADD:
  6921. {
  6922. if (sep && sep->arg[0])
  6923. {
  6924. const char* skill_name = sep->argplus[0];
  6925. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6926. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // add skill to your target, if target is not you
  6927. {
  6928. player = to_client->GetPlayer();
  6929. if (player)
  6930. {
  6931. if (!player->GetSkills()->HasSkill(skill->skill_id))
  6932. {
  6933. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  6934. client->Message(CHANNEL_COLOR_YELLOW, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  6935. to_client->Message(CHANNEL_COLOR_YELLOW, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  6936. }
  6937. else
  6938. client->Message(CHANNEL_COLOR_YELLOW, "%s already has the skill '%s'.", player->GetName(), skill_name);
  6939. }
  6940. }
  6941. else if (skill) // add skill to yourself
  6942. {
  6943. player = client->GetPlayer();
  6944. if (player)
  6945. {
  6946. if (!player->GetSkills()->HasSkill(skill->skill_id))
  6947. {
  6948. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  6949. client->Message(CHANNEL_COLOR_YELLOW, "Added skill '%s'.", skill_name);
  6950. }
  6951. else
  6952. client->Message(CHANNEL_COLOR_YELLOW, "You already have the skill '%s'.", skill_name);
  6953. }
  6954. }
  6955. else
  6956. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  6957. }
  6958. else
  6959. {
  6960. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill add [skill name]");
  6961. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  6962. }
  6963. break;
  6964. }
  6965. case COMMAND_SKILL_REMOVE:
  6966. {
  6967. if (sep && sep->arg[0])
  6968. {
  6969. const char* skill_name = sep->argplus[0];
  6970. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6971. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // remove skill from your target, if target is not you
  6972. {
  6973. player = to_client->GetPlayer();
  6974. if (player)
  6975. {
  6976. if (player->GetSkills()->HasSkill(skill->skill_id))
  6977. {
  6978. player->RemoveSkillFromDB(skill, true);
  6979. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  6980. to_client->Message(CHANNEL_COLOR_YELLOW, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  6981. }
  6982. else
  6983. client->Message(CHANNEL_COLOR_YELLOW, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  6984. }
  6985. }
  6986. else if(skill) // remove skill from yourself
  6987. {
  6988. Player* player = client->GetPlayer();
  6989. if (player)
  6990. {
  6991. if (player->GetSkills()->HasSkill(skill->skill_id))
  6992. {
  6993. player->RemoveSkillFromDB(skill, true);
  6994. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s'.", skill_name);
  6995. }
  6996. else
  6997. client->Message(CHANNEL_COLOR_YELLOW, "You do not have the skill '%s'.", skill_name);
  6998. }
  6999. }
  7000. else
  7001. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  7002. }
  7003. else
  7004. {
  7005. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill remove [skill name]");
  7006. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  7007. }
  7008. break;
  7009. }
  7010. case COMMAND_SKILL_LIST:
  7011. {
  7012. if (sep && sep->arg[0])
  7013. {
  7014. const char* skill_name = sep->argplus[0];
  7015. client->Message(CHANNEL_COLOR_YELLOW, "Listing skills like '%s':", skill_name);
  7016. map<int32, Skill*>* skills = master_skill_list.GetAllSkills();
  7017. map<int32, Skill*>::iterator itr;
  7018. if (skills && skills->size() > 0)
  7019. {
  7020. for (itr = skills->begin(); itr != skills->end(); itr++)
  7021. {
  7022. Skill* skill = itr->second;
  7023. string current_skill_name = ::ToLower(string(skill->name.data.c_str()));
  7024. if (current_skill_name.find(::ToLower(string(skill_name))) < 0xFFFFFFFF)
  7025. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", skill->name.data.c_str(), skill->skill_id);
  7026. }
  7027. }
  7028. }
  7029. else
  7030. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill list [skill name]");
  7031. break;
  7032. }
  7033. }
  7034. }
  7035. /*
  7036. Function: Command_SpawnTemplate()
  7037. Purpose : Create or Use defined Spawn Templates
  7038. Params : create, save, rempve, list
  7039. Dev : John Adams
  7040. Example : /spawn template create "Test"
  7041. */
  7042. void Commands::Command_SpawnTemplate(Client* client, Seperator* sep)
  7043. {
  7044. if (sep == NULL || sep->arg[0] == NULL)
  7045. {
  7046. 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.");
  7047. return;
  7048. }
  7049. // got params, continue
  7050. const char * template_cmd = sep->arg[0];
  7051. if (strncasecmp(template_cmd, "list", strlen(template_cmd)) == 0)
  7052. {
  7053. if (!sep->IsSet(1))
  7054. {
  7055. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /spawn template list [name|location_id]");
  7056. 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.");
  7057. return;
  7058. }
  7059. map<int32, string>* template_names = 0;
  7060. if (sep->IsNumber(1))
  7061. {
  7062. int32 location_id = 0;
  7063. location_id = atoi(sep->arg[1]);
  7064. template_names = database.GetSpawnTemplateListByID(location_id);
  7065. }
  7066. else
  7067. {
  7068. const char* name = 0;
  7069. name = sep->argplus[1];
  7070. template_names = database.GetSpawnTemplateListByName(name);
  7071. }
  7072. if(!template_names)
  7073. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No templates found.");
  7074. else
  7075. {
  7076. map<int32, string>::iterator itr;
  7077. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  7078. for(itr = template_names->begin(); itr != template_names->end(); itr++)
  7079. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  7080. safe_delete(template_names);
  7081. }
  7082. }
  7083. else if (strncasecmp(template_cmd, "save", strlen(template_cmd)) == 0)
  7084. {
  7085. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  7086. if ( target && (target->IsNPC() || target->IsObject() || target->IsSign() || target->IsWidget() || target->IsGroundSpawn()) )
  7087. {
  7088. if (sep && sep->arg[1][0] && !sep->IsNumber(1))
  7089. {
  7090. // first, lookup to see if template name already exists
  7091. const char* name = 0;
  7092. name = sep->argplus[1];
  7093. map<int32, string>* template_names = database.GetSpawnTemplateListByName(name);
  7094. if(!template_names)
  7095. {
  7096. int32 new_template_id = database.SaveSpawnTemplate(target->GetSpawnLocationID(), name);
  7097. if( new_template_id > 0 )
  7098. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template '%s' added for spawn '%s' (%u) as TemplateID: %u", name, target->GetName(), target->GetSpawnLocationID(), new_template_id);
  7099. else
  7100. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' for spawn '%s' (%u).", name, target->GetName(), target->GetSpawnLocationID());
  7101. }
  7102. else
  7103. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' - Already exists!", name);
  7104. }
  7105. else
  7106. client->Message(CHANNEL_COLOR_RED, "ERROR: Saving a new spawn template requires a valid template name!");
  7107. }
  7108. else
  7109. client->Message(CHANNEL_COLOR_RED, "ERROR: You must target the spawn you wish to save as a template!");
  7110. }
  7111. else if (strncasecmp(template_cmd, "remove", strlen(template_cmd)) == 0)
  7112. {
  7113. if (sep && sep->arg[1][0] && sep->IsNumber(1))
  7114. {
  7115. int32 template_id = 0;
  7116. template_id = atoi(sep->arg[1]);
  7117. if (database.RemoveSpawnTemplate(template_id))
  7118. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template ID: %u successfully removed.", template_id);
  7119. else
  7120. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to remove spawn template ID: %u", template_id);
  7121. }
  7122. else
  7123. client->Message(CHANNEL_COLOR_RED, "ERROR: Removing a spawn template requires a valid template ID!");
  7124. }
  7125. // Renamed create to spawn
  7126. else if (strncasecmp(template_cmd, "spawn", strlen(template_cmd)) == 0)
  7127. {
  7128. if (sep && sep->arg[1][0])
  7129. {
  7130. int32 new_location = 0;
  7131. if (sep->IsNumber(1))
  7132. {
  7133. int32 template_id = 0;
  7134. template_id = atoi(sep->arg[1]);
  7135. new_location = database.CreateSpawnFromTemplateByID(client, template_id);
  7136. if( new_location > 0 )
  7137. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template ID: %u", new_location, template_id);
  7138. else
  7139. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template ID: %u", template_id);
  7140. }
  7141. else
  7142. {
  7143. const char* name = 0;
  7144. name = sep->argplus[1];
  7145. new_location = database.CreateSpawnFromTemplateByName(client, name);
  7146. if( new_location > 0 )
  7147. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template: '%s'", new_location, name);
  7148. else
  7149. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template: '%s'", name);
  7150. }
  7151. }
  7152. else
  7153. client->Message(CHANNEL_COLOR_RED, "ERROR: Spawning a new spawn location requires a valid template name or ID!");
  7154. }
  7155. else
  7156. client->Message(CHANNEL_COLOR_RED, "ERROR: Unknown /spawn template command.");
  7157. }
  7158. void Commands::Command_Speed(Client* client, Seperator* sep) {
  7159. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  7160. float new_speed = atof(sep->arg[0]);
  7161. if (new_speed > 0.0f)
  7162. {
  7163. client->GetPlayer()->SetSpeed(new_speed, true);
  7164. client->GetPlayer()->SetCharSheetChanged(true);
  7165. database.insertCharacterProperty(client, CHAR_PROPERTY_SPEED, sep->arg[0]);
  7166. client->Message(CHANNEL_STATUS, "Setting speed to %.2f.", new_speed);
  7167. }
  7168. else
  7169. client->Message(CHANNEL_STATUS, "Invalid speed provided %s.", sep->arg[0]);
  7170. }
  7171. else{
  7172. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /speed {new speed value}");
  7173. }
  7174. }
  7175. /*
  7176. Function: Command_StationMarketPlace()
  7177. Purpose : just trying to eat the console spam for now
  7178. Params :
  7179. Dev : John
  7180. */
  7181. void Commands::Command_StationMarketPlace(Client* client, Seperator* sep)
  7182. {
  7183. PrintSep(sep, "COMMAND_SMP");
  7184. // This will reduce the spam from once every 10 sec to once every 30 sec,
  7185. // can't seem to reduce it any more get rid of it completely...
  7186. if (sep && strcmp(sep->arg[0], "gkw") == 0) {
  7187. PacketStruct* packet = configReader.getStruct("WS_MarketFundsUpdate", client->GetVersion());
  7188. if (packet) {
  7189. packet->setDataByName("account_id", client->GetAccountID());
  7190. packet->setDataByName("character_id", client->GetCharacterID());
  7191. packet->setDataByName("unknown1", 1, 5);
  7192. packet->setDataByName("unknown1", 26, 6);
  7193. packet->setDataByName("unknown2", 0xFFFFFFFF);
  7194. packet->setDataByName("unknown3", 248, 1);
  7195. client->QueuePacket(packet->serialize());
  7196. }
  7197. safe_delete(packet);
  7198. }
  7199. }
  7200. /*
  7201. Function: Command_StopDrinking()
  7202. Purpose : Stops player from auto-consuming drink
  7203. Params :
  7204. Dev : Zcoretri
  7205. Example : /stopdrinking
  7206. */
  7207. void Commands::Command_StopDrinking(Client* client)
  7208. {
  7209. client->GetPlayer()->reset_character_flag(CF_DRINK_AUTO_CONSUME);
  7210. client->Message(CHANNEL_COLOR_YELLOW,"You stop drinking your current drink.");
  7211. }
  7212. /*
  7213. Function: Command_StopEating()
  7214. Purpose : Stops player from auto-consuming food
  7215. Params :
  7216. Dev : Zcoretri
  7217. Example : /stopeating
  7218. */
  7219. void Commands::Command_StopEating(Client* client)
  7220. {
  7221. client->GetPlayer()->reset_character_flag(CF_FOOD_AUTO_CONSUME);
  7222. client->Message(CHANNEL_COLOR_YELLOW,"You stop eating your current food.");
  7223. }
  7224. /*
  7225. Function: Command_Title()
  7226. Purpose : Help for /title command
  7227. Params : n/a
  7228. Dev : Zcoretri
  7229. Example : /title
  7230. */
  7231. void Commands::Command_Title(Client* client)
  7232. {
  7233. client->Message(CHANNEL_COLOR_YELLOW, "Available subcommands: list, setprefix <index>, setsuffix <index>, fix");
  7234. }
  7235. /*
  7236. Function: Command_TitleList()
  7237. Purpose : List available titles for player
  7238. Params : n/a
  7239. Dev : Zcoretri
  7240. Example : /title list
  7241. */
  7242. void Commands::Command_TitleList(Client* client)
  7243. {
  7244. list<Title*>* titles = client->GetPlayer()->GetPlayerTitles()->GetAllTitles();
  7245. list<Title*>::iterator itr;
  7246. Title* title;
  7247. int16 i = 0;
  7248. client->Message(CHANNEL_NARRATIVE, "Listing available titles:");
  7249. for(itr = titles->begin(); itr != titles->end(); itr++)
  7250. {
  7251. title = *itr;
  7252. client->Message(CHANNEL_NARRATIVE, "%i: type=[%s] title=[%s]", i, title->GetPrefix() ? "Prefix":"Suffix", title->GetName());
  7253. i++;
  7254. }
  7255. }
  7256. /*
  7257. Function: Command_TitleSetPrefix()
  7258. Purpose : Set Prefix title for player
  7259. Params : Title ID
  7260. Dev : Zcoretri
  7261. Example : /title setprefix 1
  7262. */
  7263. void Commands::Command_TitleSetPrefix(Client* client, Seperator* sep)
  7264. {
  7265. if (sep && sep->arg[0] && sep->IsNumber(0))
  7266. {
  7267. int32 index = atoul(sep->arg[0]);
  7268. database.SaveCharPrefixIndex(index, client->GetCharacterID(), client);
  7269. client->SendTitleUpdate();
  7270. }
  7271. }
  7272. /*
  7273. Function: Command_TitleSetSuffix()
  7274. Purpose : Set Suffix title for player
  7275. Params : Title ID
  7276. Dev : Zcoretri
  7277. Example : /title setsuffix 1
  7278. */
  7279. void Commands::Command_TitleSetSuffix(Client* client, Seperator* sep)
  7280. {
  7281. if (sep && sep->arg[0] && sep->IsNumber(0))
  7282. {
  7283. int32 index = atoul(sep->arg[0]);
  7284. database.SaveCharSuffixIndex(index, client->GetCharacterID(), client);
  7285. client->SendTitleUpdate();
  7286. }
  7287. }
  7288. /*
  7289. Function: Command_TitleFix()
  7290. Purpose : Fix title for player (???)
  7291. Params :
  7292. Dev : Zcoretri
  7293. Example :
  7294. */
  7295. void Commands::Command_TitleFix(Client* client, Seperator* sep)
  7296. {
  7297. PrintSep(sep, "COMMAND_TITLE_FIX");
  7298. LogWrite(MISC__TODO, 1, "Titles", "TODO-Command: TITLE_FIX");
  7299. }
  7300. /*
  7301. Function: Command_Toggle_Anonymous()
  7302. Purpose : Toggles player Anonymous
  7303. Params :
  7304. Dev : paulgh
  7305. Example : /anon
  7306. */
  7307. void Commands::Command_Toggle_Anonymous(Client* client)
  7308. {
  7309. Player* player = client->GetPlayer();
  7310. player->toggle_character_flag(CF_ANONYMOUS);
  7311. client->Message(CHANNEL_COLOR_YELLOW,"You are %s anonymous.", player->get_character_flag(CF_ANONYMOUS)?"now":"no longer");
  7312. if (player->get_character_flag(CF_ANONYMOUS))
  7313. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ANONYMOUS);
  7314. else
  7315. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ANONYMOUS);
  7316. }
  7317. /*
  7318. Function: Command_Toggle_AutoConsume()
  7319. Purpose : Toggles player food/drink auto consume
  7320. Params : unknown
  7321. Dev : paulgh
  7322. Example : /set_auto_consume
  7323. */
  7324. void Commands::Command_Toggle_AutoConsume(Client* client, Seperator* sep)
  7325. {
  7326. Player* player = client->GetPlayer();
  7327. if (sep && sep->arg[0])
  7328. PrintSep(sep, "COMMAND_SET_AUTO_CONSUME");
  7329. if (sep && sep->arg[0] && sep->IsNumber(0))
  7330. {
  7331. int8 slot = atoi(sep->arg[0]);
  7332. int8 flag = atoi(sep->arg[1]);
  7333. if (client->GetVersion() <= 283) {
  7334. slot += 4;
  7335. }
  7336. else if (client->GetVersion() <= 546) {
  7337. slot += 2;
  7338. }
  7339. if (slot == EQ2_FOOD_SLOT)
  7340. {
  7341. player->toggle_character_flag(CF_FOOD_AUTO_CONSUME);
  7342. player->SetCharSheetChanged(true);
  7343. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  7344. if (flag == 1)
  7345. client->Message(CHANNEL_NARRATIVE, "You decide to eat immediately whenever you become hungry.");
  7346. else
  7347. client->Message(CHANNEL_NARRATIVE, "You decide to ignore the hunger.");
  7348. }
  7349. else
  7350. {
  7351. player->toggle_character_flag(CF_DRINK_AUTO_CONSUME);
  7352. player->SetCharSheetChanged(true);
  7353. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  7354. if (flag == 1)
  7355. client->Message(CHANNEL_NARRATIVE, "You decide to drink immediately whenever you become thirsty.");
  7356. else
  7357. client->Message(CHANNEL_NARRATIVE, "You decide to ignore the thirst.");
  7358. }
  7359. }
  7360. }
  7361. /*
  7362. Function: Command_Toggle_BonusXP()
  7363. Purpose : Toggles player Bonus XP
  7364. Params :
  7365. Dev : John Adams
  7366. Example : /disable_char_bonus_exp
  7367. */
  7368. void Commands::Command_Toggle_BonusXP(Client* client)
  7369. {
  7370. Player* player = client->GetPlayer();
  7371. player->toggle_character_flag(CF2_CHARACTER_BONUS_EXPERIENCE_ENABLED);
  7372. player->SetCharSheetChanged(true);
  7373. }
  7374. /*
  7375. Function: Command_Toggle_CombatXP()
  7376. Purpose : Toggles player Adventure XP
  7377. Params :
  7378. Dev : John Adams
  7379. Example : /disable_combat_exp
  7380. */
  7381. void Commands::Command_Toggle_CombatXP(Client* client)
  7382. {
  7383. Player* player = client->GetPlayer();
  7384. player->toggle_character_flag(CF_COMBAT_EXPERIENCE_ENABLED);
  7385. player->SetCharSheetChanged(true);
  7386. }
  7387. /*
  7388. Function: Command_Toggle_GMHide()
  7389. Purpose : Toggles hiding player GM status
  7390. Params :
  7391. Dev : Scatman
  7392. Example : /gm_hide
  7393. */
  7394. void Commands::Command_Toggle_GMHide(Client* client)
  7395. {
  7396. Player* player = client->GetPlayer();
  7397. player->toggle_character_flag(CF_HIDE_STATUS);
  7398. client->Message(CHANNEL_COLOR_YELLOW,"You are %s hiding your GM status.", player->get_character_flag(CF_HIDE_STATUS)?"now":"no longer");
  7399. }
  7400. /*
  7401. Function: Command_Toggle_GMVanish()
  7402. Purpose : Toggles hiding GM players from /who searches
  7403. Params :
  7404. Dev : Scatman
  7405. Example : /gm_vanish
  7406. */
  7407. void Commands::Command_Toggle_GMVanish(Client* client)
  7408. {
  7409. Player* player = client->GetPlayer();
  7410. player->toggle_character_flag(CF_GM_HIDDEN);
  7411. client->Message(CHANNEL_COLOR_YELLOW,"You are %s invisible to who queries.", player->get_character_flag(CF_GM_HIDDEN)?"now":"no longer");
  7412. }
  7413. /*
  7414. Function: Command_Toggle_Illusions()
  7415. Purpose : Toggles player illusion form
  7416. Params : not sure sep is needed, testing
  7417. Dev : paulgh
  7418. Example : /hide_illusions
  7419. */
  7420. void Commands::Command_Toggle_Illusions(Client* client, Seperator* sep)
  7421. {
  7422. if (sep && sep->arg[0])
  7423. PrintSep(sep, "COMMAND_TOGGLE_ILLUSIONS");
  7424. client->GetPlayer()->toggle_character_flag(CF_SHOW_ILLUSION);
  7425. }
  7426. /*
  7427. Function: Command_Toggle_LFG()
  7428. Purpose : Toggles player LFG Flag
  7429. Params :
  7430. Dev : paulgh
  7431. Example : /lfg
  7432. */
  7433. void Commands::Command_Toggle_LFG(Client* client)
  7434. {
  7435. Player* player = client->GetPlayer();
  7436. player->toggle_character_flag(CF_LFG);
  7437. client->Message(CHANNEL_COLOR_YELLOW,"You are %s LFG.", player->get_character_flag(CF_LFG)?"now":"no longer");
  7438. if (player->get_character_flag(CF_LFG))
  7439. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFG);
  7440. else
  7441. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFG);
  7442. }
  7443. /*
  7444. Function: Command_Toggle_LFW()
  7445. Purpose : Toggles player LFW Flag
  7446. Params :
  7447. Dev : paulgh
  7448. Example : /lfw
  7449. */
  7450. void Commands::Command_Toggle_LFW(Client* client)
  7451. {
  7452. Player* player = client->GetPlayer();
  7453. player->toggle_character_flag(CF_LFW);
  7454. client->Message(CHANNEL_COLOR_YELLOW,"You %s looking for work.", player->get_character_flag(CF_LFW)?"let others know you are":"stop");
  7455. if (player->get_character_flag(CF_LFW))
  7456. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFW);
  7457. else
  7458. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFW);
  7459. }
  7460. /*
  7461. Function: Command_Toggle_QuestXP()
  7462. Purpose : Toggles player Quest XP
  7463. Params :
  7464. Dev : John Adams
  7465. Example : /disable_quest_exp
  7466. */
  7467. void Commands::Command_Toggle_QuestXP(Client* client)
  7468. {
  7469. Player* player = client->GetPlayer();
  7470. player->toggle_character_flag(CF_QUEST_EXPERIENCE_ENABLED);
  7471. player->SetCharSheetChanged(true);
  7472. }
  7473. /*
  7474. Function: Command_Toggle_Roleplaying()
  7475. Purpose : Toggles player Roleplaying flag
  7476. Params :
  7477. Dev : paulgh
  7478. Example : /role
  7479. */
  7480. void Commands::Command_Toggle_Roleplaying(Client* client)
  7481. {
  7482. Player* player = client->GetPlayer();
  7483. player->toggle_character_flag(CF_ROLEPLAYING);
  7484. client->Message(CHANNEL_COLOR_YELLOW,"You are %s roleplaying.", player->get_character_flag(CF_ROLEPLAYING)?"now":"no longer");
  7485. if (player->get_character_flag(CF_ROLEPLAYING))
  7486. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ROLEPLAYING);
  7487. else
  7488. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ROLEPLAYING);
  7489. }
  7490. void Commands::Command_Toggle_Duels(Client* client)
  7491. {
  7492. Player* player = client->GetPlayer();
  7493. player->toggle_character_flag(CF_ALLOW_DUEL_INVITES);
  7494. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting duel invites.", player->get_character_flag(CF_ALLOW_DUEL_INVITES)?"now":"no longer");
  7495. }
  7496. void Commands::Command_Toggle_Trades(Client* client)
  7497. {
  7498. Player* player = client->GetPlayer();
  7499. player->toggle_character_flag(CF_ALLOW_TRADE_INVITES);
  7500. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting trade invites.", player->get_character_flag(CF_ALLOW_TRADE_INVITES)?"now":"no longer");
  7501. }
  7502. void Commands::Command_Toggle_Guilds(Client* client)
  7503. {
  7504. Player* player = client->GetPlayer();
  7505. player->toggle_character_flag(CF_ALLOW_GUILD_INVITES);
  7506. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting guild invites.", player->get_character_flag(CF_ALLOW_GUILD_INVITES)?"now":"no longer");
  7507. }
  7508. void Commands::Command_Toggle_Groups(Client* client)
  7509. {
  7510. Player* player = client->GetPlayer();
  7511. player->toggle_character_flag(CF_ALLOW_GROUP_INVITES);
  7512. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting group invites.", player->get_character_flag(CF_ALLOW_GROUP_INVITES)?"now":"no longer");
  7513. }
  7514. void Commands::Command_Toggle_Raids(Client* client)
  7515. {
  7516. Player* player = client->GetPlayer();
  7517. player->toggle_character_flag(CF_ALLOW_RAID_INVITES);
  7518. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting raid invites.", player->get_character_flag(CF_ALLOW_RAID_INVITES)?"now":"no longer");
  7519. }
  7520. void Commands::Command_Toggle_LON(Client* client)
  7521. {
  7522. Player* player = client->GetPlayer();
  7523. player->toggle_character_flag(CF2_ALLOW_LON_INVITES);
  7524. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting LoN invites.", player->get_character_flag(CF2_ALLOW_LON_INVITES)?"now":"no longer");
  7525. }
  7526. void Commands::Command_Toggle_VoiceChat(Client* client)
  7527. {
  7528. Player* player = client->GetPlayer();
  7529. player->toggle_character_flag(CF2_ALLOW_VOICE_INVITES);
  7530. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting voice chat invites.", player->get_character_flag(CF2_ALLOW_VOICE_INVITES)?"now":"no longer");
  7531. }
  7532. /*
  7533. Function: Command_TradeStart()
  7534. Purpose : Starts item/coin trade between players
  7535. Params :
  7536. Dev :
  7537. Example :
  7538. */
  7539. #include "../Trade.h"
  7540. void Commands::Command_TradeStart(Client* client, Seperator* sep)
  7541. {
  7542. PrintSep(sep, "COMMAND_START_TRADE");
  7543. Entity* trader = client->GetPlayer();
  7544. Entity* trader2 = 0;
  7545. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7546. Spawn* spawn = client->GetPlayer()->GetSpawnWithPlayerID(atoi(sep->arg[0]));
  7547. if (spawn) {
  7548. if (spawn->IsEntity())
  7549. trader2 = (Entity*)spawn;
  7550. }
  7551. }
  7552. else if (client->GetPlayer()->GetTarget()) {
  7553. if (client->GetPlayer()->GetTarget()->IsEntity())
  7554. trader2 = (Entity*)client->GetPlayer()->GetTarget();
  7555. }
  7556. // can only trade with player or bots
  7557. if (trader && trader2) {
  7558. if (trader == trader2) {
  7559. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade with yourself.");
  7560. }
  7561. else if (trader2->IsPlayer() || trader2->IsBot()) {
  7562. LogWrite(PLAYER__ERROR, 0, "Trade", "creating trade");
  7563. if (trader->trade)
  7564. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are already trading.");
  7565. else if (trader2->trade)
  7566. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is already trading.");
  7567. else {
  7568. Trade* trade = new Trade(trader, trader2);
  7569. trader->trade = trade;
  7570. trader2->trade = trade;
  7571. }
  7572. }
  7573. else {
  7574. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can only trade with another player or a bot.");
  7575. }
  7576. }
  7577. else
  7578. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to find target");
  7579. }
  7580. /*
  7581. Function: Command_Track()
  7582. Purpose : Starts/Stops Tracking for a player
  7583. Params :
  7584. Dev : Scatman
  7585. Example : /track
  7586. */
  7587. void Commands::Command_Track(Client* client)
  7588. {
  7589. if (!client->GetPlayer()->GetIsTracking())
  7590. client->GetPlayer()->GetZone()->AddPlayerTracking(client->GetPlayer());
  7591. else
  7592. client->GetPlayer()->GetZone()->RemovePlayerTracking(client->GetPlayer(), TRACKING_STOP);
  7593. }
  7594. /*
  7595. Function: Command_TradeAccept()
  7596. Purpose : Accepts item/coin trade between players
  7597. Params :
  7598. Dev :
  7599. Example :
  7600. */
  7601. void Commands::Command_TradeAccept(Client* client, Seperator* sep)
  7602. {
  7603. PrintSep(sep, "COMMAND_ACCEPT_TRADE");
  7604. Trade* trade = client->GetPlayer()->trade;
  7605. if (trade) {
  7606. bool trade_complete = trade->SetTradeAccepted(client->GetPlayer());
  7607. if (trade_complete)
  7608. safe_delete(trade);
  7609. }
  7610. else
  7611. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7612. }
  7613. /*
  7614. Function: Command_TradeReject()
  7615. Purpose : Rejects item/coin trade between players
  7616. Params :
  7617. Dev :
  7618. Example :
  7619. */
  7620. void Commands::Command_TradeReject(Client* client, Seperator* sep)
  7621. {
  7622. PrintSep(sep, "COMMAND_REJECT_TRADE");
  7623. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Reject Player Trading");
  7624. client->Message(CHANNEL_COLOR_YELLOW, "You cannot trade with other players (Not Implemented)");
  7625. }
  7626. /*
  7627. Function: Command_TradeCancel()
  7628. Purpose : Cancels item/coin trade between players
  7629. Params :
  7630. Dev :
  7631. Example :
  7632. */
  7633. void Commands::Command_TradeCancel(Client* client, Seperator* sep)
  7634. {
  7635. PrintSep(sep, "COMMAND_CANCEL_TRADE");
  7636. Trade* trade = client->GetPlayer()->trade;
  7637. if (trade) {
  7638. trade->CancelTrade(client->GetPlayer());
  7639. safe_delete(trade);
  7640. }
  7641. else
  7642. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7643. }
  7644. /*
  7645. Function: Command_TradeSetCoin()
  7646. Purpose : Sets coin trade between players
  7647. Params :
  7648. Dev :
  7649. Example :
  7650. */
  7651. void Commands::Command_TradeSetCoin(Client* client, Seperator* sep)
  7652. {
  7653. PrintSep(sep, "COMMAND_SET_TRADE_COIN");
  7654. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Set Trade Coin");
  7655. client->Message(CHANNEL_COLOR_YELLOW, "You cannot trade with other players (Not Implemented)");
  7656. }
  7657. /*
  7658. Function: Command_TradeAddCoin()
  7659. Purpose : Adds coin to trade between players
  7660. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  7661. Dev :
  7662. Example :
  7663. */
  7664. void Commands::Command_TradeAddCoin(Client* client, Seperator* sep, int handler)
  7665. {
  7666. PrintSep(sep, "COMMAND_ADD_TRADE_{coin type}");
  7667. Trade* trade = client->GetPlayer()->trade;
  7668. if (trade) {
  7669. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7670. int32 amount = atoi(sep->arg[0]);
  7671. int64 val = 0;
  7672. switch (handler) {
  7673. case COMMAND_ADD_TRADE_COPPER:
  7674. {
  7675. val = amount;
  7676. trade->AddCoinToTrade(client->GetPlayer(), val);
  7677. break;
  7678. }
  7679. case COMMAND_ADD_TRADE_SILVER:
  7680. {
  7681. val = amount * 100;
  7682. trade->AddCoinToTrade(client->GetPlayer(), val);
  7683. break;
  7684. }
  7685. case COMMAND_ADD_TRADE_GOLD:
  7686. {
  7687. val = amount * 10000;
  7688. trade->AddCoinToTrade(client->GetPlayer(), val);
  7689. break;
  7690. }
  7691. case COMMAND_ADD_TRADE_PLAT:
  7692. {
  7693. val = amount * 1000000;
  7694. trade->AddCoinToTrade(client->GetPlayer(), val);
  7695. break;
  7696. }
  7697. default:
  7698. {
  7699. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  7700. break;
  7701. }
  7702. }
  7703. }
  7704. else
  7705. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount.");
  7706. }
  7707. else
  7708. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7709. }
  7710. /*
  7711. Function: Command_TradeRemoveCoin()
  7712. Purpose : Removes coin from trade between players
  7713. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  7714. Dev :
  7715. Example :
  7716. */
  7717. void Commands::Command_TradeRemoveCoin(Client* client, Seperator* sep, int handler)
  7718. {
  7719. PrintSep(sep, "COMMAND_REMOVE_TRADE_{coin type}");
  7720. Trade* trade = client->GetPlayer()->trade;
  7721. if (trade) {
  7722. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7723. int32 amount = atoi(sep->arg[0]);
  7724. int64 val = 0;
  7725. switch (handler) {
  7726. case COMMAND_REMOVE_TRADE_COPPER:
  7727. {
  7728. val = amount;
  7729. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7730. break;
  7731. }
  7732. case COMMAND_REMOVE_TRADE_SILVER:
  7733. {
  7734. val = amount * 100;
  7735. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7736. break;
  7737. }
  7738. case COMMAND_REMOVE_TRADE_GOLD:
  7739. {
  7740. val = amount * 10000;
  7741. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7742. break;
  7743. }
  7744. case COMMAND_REMOVE_TRADE_PLAT:
  7745. {
  7746. val = amount * 1000000;
  7747. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7748. break;
  7749. }
  7750. default:
  7751. {
  7752. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  7753. break;
  7754. }
  7755. }
  7756. }
  7757. else
  7758. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount");
  7759. }
  7760. else
  7761. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7762. }
  7763. /*
  7764. Function: Command_TradeAddItem()
  7765. Purpose : Adds item to trade between players
  7766. Params :
  7767. Dev :
  7768. Example :
  7769. */
  7770. void Commands::Command_TradeAddItem(Client* client, Seperator* sep)
  7771. {
  7772. PrintSep(sep, "COMMAND_ADD_TRADE_ITEM");
  7773. /*
  7774. arg[0] = item index
  7775. arg[1] = slot
  7776. arg[2] = quantity
  7777. */
  7778. if (!client->GetPlayer()->trade) {
  7779. LogWrite(PLAYER__ERROR, 0, "Trade", "Player is not currently trading.");
  7780. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7781. return;
  7782. }
  7783. if (sep && sep->IsSet(0) && sep->IsNumber(0) && sep->IsSet(1) && sep->IsNumber(1) && sep->IsSet(2) && sep->IsNumber(2)) {
  7784. Item* item = 0;
  7785. int32 index = atoi(sep->arg[0]);
  7786. item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(index);
  7787. if (item) {
  7788. int8 result = client->GetPlayer()->trade->AddItemToTrade(client->GetPlayer(), item, atoi(sep->arg[2]), atoi(sep->arg[1]));
  7789. if (result == 1)
  7790. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Item is already being traded.");
  7791. else if (result == 2)
  7792. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade NO-TRADE items.");
  7793. else if (result == 3)
  7794. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade HEIRLOOM items.");
  7795. else if (result == 255)
  7796. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown error trying to add the item to the trade...");
  7797. }
  7798. else {
  7799. LogWrite(PLAYER__ERROR, 0, "Trade", "Unable to get an item for the player (%s) from the index (%u)", client->GetPlayer()->GetName(), index);
  7800. client->Message(CHANNEL_ERROR, "Unable to find item at index %u", index);
  7801. }
  7802. }
  7803. else
  7804. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  7805. }
  7806. /*
  7807. Function: Command_TradeRemoveItem()
  7808. Purpose : Removes item from trade between players
  7809. Params :
  7810. Dev :
  7811. Example :
  7812. */
  7813. void Commands::Command_TradeRemoveItem(Client* client, Seperator* sep)
  7814. {
  7815. PrintSep(sep, "COMMAND_REMOVE_TRADE_ITEM");
  7816. /*
  7817. arg[0] = trade window slot
  7818. */
  7819. Trade* trade = client->GetPlayer()->trade;
  7820. if (trade) {
  7821. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7822. trade->RemoveItemFromTrade(client->GetPlayer(), atoi(sep->arg[0]));
  7823. }
  7824. else
  7825. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  7826. }
  7827. else
  7828. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7829. }
  7830. void Commands::Command_TryOn(Client* client, Seperator* sep)
  7831. {
  7832. Item *item = 0;
  7833. sint32 crc;
  7834. if (sep) {
  7835. // 1096+ sends more info so need to do a version check so older clients (SF) still work
  7836. if (client->GetVersion() < 1096) {
  7837. if (sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2))
  7838. {
  7839. item = master_item_list.GetItem(atoul(sep->arg[1]));
  7840. crc = atol(sep->arg[2]);
  7841. }
  7842. }
  7843. else {
  7844. // From the broker and links in chat
  7845. if (strcmp(sep->arg[0], "crc") == 0) {
  7846. if (sep->IsNumber(2) && sep->IsNumber(3)) {
  7847. item = master_item_list.GetItem(atoul(sep->arg[2]));
  7848. crc = atol(sep->arg[3]);
  7849. }
  7850. }
  7851. // From inventory
  7852. if (strcmp(sep->arg[0], "dbid") == 0) {
  7853. if (sep->IsNumber(2) && sep->IsNumber(4)) {
  7854. item = master_item_list.GetItem(atoul(sep->arg[2]));
  7855. crc = atol(sep->arg[4]);
  7856. }
  7857. }
  7858. }
  7859. if (item)
  7860. client->ShowDressingRoom(item, crc);
  7861. }
  7862. }
  7863. void Commands::Command_JoinChannel(Client * client, Seperator *sep) {
  7864. const char *channel_name, *password = NULL;
  7865. if (sep == NULL || !sep->IsSet(0)) {
  7866. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /joinchannel <channel name> [password]");
  7867. return;
  7868. }
  7869. channel_name = sep->arg[0];
  7870. if (sep->IsSet(1))
  7871. password = sep->arg[1];
  7872. if (!chat.ChannelExists(channel_name) && !chat.CreateChannel(channel_name, password)) {
  7873. client->Message(CHANNEL_COLOR_RED, "Unable to create channel '%s'.", channel_name);
  7874. return;
  7875. }
  7876. if (chat.IsInChannel(client, channel_name)) {
  7877. client->Message(CHANNEL_NARRATIVE, "You are already in '%s'.", channel_name);
  7878. return;
  7879. }
  7880. if (chat.HasPassword(channel_name)) {
  7881. if (password == NULL) {
  7882. client->Message(CHANNEL_NARRATIVE, "Unable to join '%s': That channel is password protected.", channel_name);
  7883. return;
  7884. }
  7885. if (!chat.PasswordMatches(channel_name, password)) {
  7886. client->Message(CHANNEL_NARRATIVE, "Unable to join '%s': The password is not correc.t", channel_name);
  7887. return;
  7888. }
  7889. }
  7890. if (!chat.JoinChannel(client, channel_name))
  7891. client->Message(CHANNEL_COLOR_RED, "There was an internal error preventing you from joining '%s'.", channel_name);
  7892. }
  7893. void Commands::Command_JoinChannelFromLoad(Client * client, Seperator *sep) {
  7894. printf("ScatDebug: Received 'joinfromchannel', using the same function as 'joinchannel' (not sure what the difference is)\n");
  7895. Command_JoinChannel(client, sep);
  7896. }
  7897. void Commands::Command_TellChannel(Client *client, Seperator *sep) {
  7898. if (sep == NULL || !sep->IsSet(0) || !sep->IsSet(1)) {
  7899. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /tellchannel <channel name> <message>");
  7900. PrintSep(sep, "tellchannel");
  7901. return;
  7902. }
  7903. chat.TellChannel(client, sep->arg[0], sep->argplus[1]);
  7904. }
  7905. void Commands::Command_Test(Client* client, EQ2_16BitString* command_parms) {
  7906. Seperator* sep = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  7907. if (sep->IsSet(0)) {
  7908. if (atoi(sep->arg[0]) == 1) {
  7909. PacketStruct* packet2 = configReader.getStruct("WS_SpellGainedMsg", client->GetVersion());
  7910. if (packet2) {
  7911. packet2->setDataByName("spell_type", 2);
  7912. packet2->setDataByName("spell_id", 8308);
  7913. packet2->setDataByName("spell_name", "Sprint");
  7914. packet2->setDataByName("add_silently", 0);
  7915. packet2->setDataByName("tier", 1);
  7916. packet2->setDataByName("blah1", 1);
  7917. packet2->setDataByName("blah2", 1);
  7918. EQ2Packet* outapp = packet2->serialize();
  7919. DumpPacket(outapp);
  7920. client->QueuePacket(outapp);
  7921. safe_delete(packet2);
  7922. }
  7923. }
  7924. else if (atoi(sep->arg[0]) == 2) {
  7925. PacketStruct* packet2 = configReader.getStruct("WS_GuildUpdate", client->GetVersion());
  7926. if (packet2) {
  7927. packet2->setDataByName("guild_name", "Test");
  7928. packet2->setDataByName("guild_motd", "Test MOTD");
  7929. packet2->setDataByName("guild_id", 1234);
  7930. packet2->setDataByName("guild_level", 1);
  7931. packet2->setDataByName("unknown", 2);
  7932. packet2->setDataByName("unknown2", 3);
  7933. packet2->setDataByName("exp_current", 1);
  7934. packet2->setDataByName("exp_to_next_level", 4);
  7935. EQ2Packet* outapp = packet2->serialize();
  7936. DumpPacket(outapp);
  7937. client->QueuePacket(outapp);
  7938. safe_delete(packet2);
  7939. }
  7940. }
  7941. else if (atoi(sep->arg[0]) == 3) {
  7942. PacketStruct* packet2 = configReader.getStruct("WS_JoinGuildNotify", client->GetVersion());
  7943. if (packet2) {
  7944. packet2->setDataByName("guild_id", 1234);
  7945. packet2->setDataByName("character_id", 1);
  7946. packet2->setDataByName("account_id", 2);
  7947. packet2->setDataByName("guild_level", 1);
  7948. packet2->setDataByName("name", "Test");
  7949. packet2->setDataByName("unknown2", 0);
  7950. packet2->setDataByName("unknown3", 1);
  7951. packet2->setDataByName("adventure_class", 6);
  7952. packet2->setDataByName("adventure_level", 7);
  7953. packet2->setDataByName("tradeskill_class", 4);
  7954. packet2->setDataByName("tradeskill_level", 5);
  7955. packet2->setDataByName("rank", 0);
  7956. packet2->setDataByName("member_flags", 2);
  7957. packet2->setDataByName("join_date", 1591112273);
  7958. packet2->setDataByName("guild_status", 2);
  7959. packet2->setDataByName("last_login", 1591132273);
  7960. packet2->setDataByName("recruiter_id", 1);
  7961. packet2->setDataByName("points", 2345);
  7962. packet2->setDataByName("note", "note");
  7963. packet2->setMediumStringByName("officer_note", "O note");
  7964. packet2->setMediumStringByName("zone", "Blah");
  7965. EQ2Packet* outapp = packet2->serialize();
  7966. DumpPacket(outapp);
  7967. client->QueuePacket(outapp);
  7968. safe_delete(packet2);
  7969. }
  7970. }
  7971. else if (atoi(sep->arg[0]) == 5) {
  7972. int16 offset = atoi(sep->arg[1]);
  7973. int32 value1 = atol(sep->arg[2]);
  7974. EQ2Packet* outapp = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion(), offset, value1);
  7975. client->QueuePacket(outapp);
  7976. }
  7977. else if (atoi(sep->arg[0]) == 6) {
  7978. Spawn* spawn = client->GetPlayer()->GetTarget();
  7979. if (!spawn)
  7980. spawn = client->GetPlayer();
  7981. else if (spawn->IsEntity())
  7982. ((Entity*)spawn)->SetSpeed(atof(sep->arg[4]));
  7983. spawn->RunToLocation(atof(sep->arg[1]), atof(sep->arg[2]), atof(sep->arg[3]));
  7984. }
  7985. else if (atoi(sep->arg[0]) == 7) {
  7986. int32 id = 0;
  7987. Spawn* spawn = client->GetCurrentZone()->GetSpawn(7720001);
  7988. if (spawn) {
  7989. spawn->SetX(client->GetPlayer()->GetX() + .5, false);
  7990. spawn->SetY(client->GetPlayer()->GetY(), false);
  7991. spawn->SetZ(client->GetPlayer()->GetZ() + .5, false);
  7992. float heading = client->GetPlayer()->GetHeading() + 180;
  7993. if (heading > 360)
  7994. heading -= 360;
  7995. spawn->SetLevel(5);
  7996. spawn->SetAdventureClass(4);
  7997. spawn->SetHeading(heading, false);
  7998. spawn->SetSpawnOrigX(spawn->GetX());
  7999. spawn->SetSpawnOrigY(spawn->GetY());
  8000. spawn->SetSpawnOrigZ(spawn->GetZ());
  8001. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  8002. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  8003. spawn->appearance.targetable = 1;
  8004. if (spawn->IsNPC() && spawn->GetTotalHP() == 0) {
  8005. spawn->SetTotalHP(spawn->GetLevel() * 15);
  8006. spawn->SetHP(spawn->GetTotalHP());
  8007. }
  8008. if (spawn->GetTotalPower() == 0) {
  8009. spawn->SetTotalPower(spawn->GetLevel() * 15);
  8010. spawn->SetPower(spawn->GetTotalPower());
  8011. }
  8012. int16 offset = atoi(sep->arg[1]);
  8013. int32 value1 = atol(sep->arg[2]);
  8014. sprintf(spawn->appearance.name, "Offset %i", offset);
  8015. EQ2Packet* ret = spawn->spawn_serialize(client->GetPlayer(), client->GetVersion(), offset, value1);
  8016. DumpPacket(ret);
  8017. client->QueuePacket(ret);
  8018. }
  8019. }
  8020. else if (atoi(sep->arg[0]) == 8) {
  8021. int32 id = atoi(sep->arg[1]);
  8022. Spawn* spawn = client->GetCurrentZone()->GetSpawn(id);
  8023. if (spawn) {
  8024. spawn->SetX(client->GetPlayer()->GetX() + .5, false);
  8025. spawn->SetY(client->GetPlayer()->GetY(), false);
  8026. spawn->SetZ(client->GetPlayer()->GetZ() + .5, false);
  8027. float heading = client->GetPlayer()->GetHeading() + 180;
  8028. if (heading > 360)
  8029. heading -= 360;
  8030. spawn->SetLevel(5);
  8031. spawn->SetAdventureClass(4);
  8032. spawn->SetHeading(heading, false);
  8033. spawn->SetSpawnOrigX(spawn->GetX());
  8034. spawn->SetSpawnOrigY(spawn->GetY());
  8035. spawn->SetSpawnOrigZ(spawn->GetZ());
  8036. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  8037. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  8038. spawn->appearance.targetable = 1;
  8039. if (spawn->IsNPC() && spawn->GetTotalHP() == 0) {
  8040. spawn->SetTotalHP(spawn->GetLevel() * 15);
  8041. spawn->SetHP(spawn->GetTotalHP());
  8042. }
  8043. if (spawn->GetTotalPower() == 0) {
  8044. spawn->SetTotalPower(spawn->GetLevel() * 15);
  8045. spawn->SetPower(spawn->GetTotalPower());
  8046. }
  8047. int16 offset = atoi(sep->arg[2]);
  8048. int16 offset2 = atoi(sep->arg[3]);
  8049. int32 value1 = atol(sep->arg[4]);
  8050. int16 offset3 = 0;
  8051. int16 offset4 = 0;
  8052. int32 value2 = 0;
  8053. if (sep->IsSet(7)) {
  8054. offset3 = atoi(sep->arg[5]);
  8055. offset4 = atoi(sep->arg[6]);
  8056. value2 = atol(sep->arg[7]);
  8057. }
  8058. sprintf(spawn->appearance.name, "Offset %i to %i", offset, offset2);
  8059. spawn->AddPrimaryEntityCommand("attack", 10000, "attack","", 0, 0);
  8060. EQ2Packet* ret = spawn->spawn_serialize(client->GetPlayer(), client->GetVersion(), offset, value1, offset2, offset3, offset4, value2);
  8061. DumpPacket(ret);
  8062. client->QueuePacket(ret);
  8063. }
  8064. }
  8065. else if (atoi(sep->arg[0]) == 9) {
  8066. PacketStruct* packet2 = configReader.getStruct("WS_DeathWindow", client->GetVersion());
  8067. if (packet2) {
  8068. packet2->setArrayLengthByName("location_count", 1);
  8069. packet2->setArrayDataByName("location_ida", 1234);
  8070. packet2->setArrayDataByName("unknown2a", 3);
  8071. packet2->setArrayDataByName("zone_name", "Queen's Colony");
  8072. packet2->setArrayDataByName("location_name", "Myrrin's Tower");
  8073. packet2->setArrayDataByName("distance", 134);
  8074. EQ2Packet* app = packet2->serialize();
  8075. if (sep->IsSet(2)) {
  8076. int8 offset = atoi(sep->arg[1]);
  8077. uchar* ptr2 = app->pBuffer;
  8078. ptr2 += offset;
  8079. if (sep->IsNumber(2)) {
  8080. int32 value1 = atol(sep->arg[2]);
  8081. if (value1 > 0xFFFF)
  8082. memcpy(ptr2, (uchar*)&value1, 4);
  8083. else if (value1 > 0xFF)
  8084. memcpy(ptr2, (uchar*)&value1, 2);
  8085. else
  8086. memcpy(ptr2, (uchar*)&value1, 1);
  8087. }
  8088. else {
  8089. int8 len = strlen(sep->arg[2]);
  8090. memcpy(ptr2, (uchar*)&len, 1);
  8091. ptr2 += 1;
  8092. memcpy(ptr2, sep->arg[2], len);
  8093. }
  8094. }
  8095. DumpPacket(app);
  8096. client->QueuePacket(app);
  8097. safe_delete(packet2);
  8098. }
  8099. }
  8100. else if (atoi(sep->arg[0]) == 10) {
  8101. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalUpdate", client->GetVersion());
  8102. if (packet2) {
  8103. packet2->setArrayLengthByName("num_quests", 1);
  8104. packet2->setArrayDataByName("active", 1);
  8105. packet2->setArrayDataByName("name", "Tasks aboard the Far Journey");
  8106. packet2->setArrayDataByName("quest_type", "Hallmark");
  8107. packet2->setArrayDataByName("quest_zone", "Hallmark");
  8108. packet2->setArrayDataByName("journal_updated", 1);
  8109. packet2->setArrayDataByName("quest_id", 524);
  8110. packet2->setArrayDataByName("day", 19);
  8111. packet2->setArrayDataByName("month", 6);
  8112. packet2->setArrayDataByName("year", 20);
  8113. packet2->setArrayDataByName("level", 2);
  8114. packet2->setArrayDataByName("encounter_level", 4);
  8115. packet2->setArrayDataByName("difficulty", 3);
  8116. packet2->setArrayDataByName("visible", 1);
  8117. packet2->setDataByName("visible_quest_id", 524);
  8118. packet2->setDataByName("player_crc", 2900677088);
  8119. packet2->setDataByName("player_name", "LethalEncounter");
  8120. EQ2Packet* app = packet2->serialize();
  8121. if (sep->IsSet(2)) {
  8122. int8 offset = atoi(sep->arg[1]);
  8123. uchar* ptr2 = app->pBuffer;
  8124. ptr2 += offset;
  8125. if (sep->IsNumber(2)) {
  8126. int32 value1 = atol(sep->arg[2]);
  8127. if (value1 > 0xFFFF)
  8128. memcpy(ptr2, (uchar*)&value1, 4);
  8129. else if (value1 > 0xFF)
  8130. memcpy(ptr2, (uchar*)&value1, 2);
  8131. else
  8132. memcpy(ptr2, (uchar*)&value1, 1);
  8133. }
  8134. else {
  8135. int8 len = strlen(sep->arg[2]);
  8136. memcpy(ptr2, (uchar*)&len, 1);
  8137. ptr2 += 1;
  8138. memcpy(ptr2, sep->arg[2], len);
  8139. }
  8140. }
  8141. DumpPacket(app);
  8142. client->QueuePacket(app);
  8143. safe_delete(packet2);
  8144. }
  8145. }
  8146. else if (atoi(sep->arg[0]) == 11) {
  8147. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalReply", client->GetVersion());
  8148. if (packet2) {
  8149. packet2->setDataByName("quest_id", 524);
  8150. packet2->setDataByName("player_crc", 2900677088);
  8151. packet2->setDataByName("name", "Tasks aboard the Far Journey");
  8152. packet2->setDataByName("description", "I completed all the tasks assigned to me by Captain Varlos aboard the Far Journey");
  8153. packet2->setDataByName("type", "Hallmark");
  8154. packet2->setDataByName("complete_header", "To complete this quest, I must do the following tasks:");
  8155. packet2->setDataByName("day", 19);
  8156. packet2->setDataByName("month", 6);
  8157. packet2->setDataByName("year", 20);
  8158. packet2->setDataByName("level", 1);
  8159. packet2->setDataByName("encounter_level", 1);
  8160. packet2->setDataByName("difficulty", 1);
  8161. packet2->setDataByName("time_obtained", Timer::GetUnixTimeStamp());
  8162. //packet2->setDataByName("timer_start", Timer::GetUnixTimeStamp());
  8163. //packet2->setDataByName("timer_duration", 300);
  8164. //packet2->setDataByName("timer_running", 1);
  8165. packet2->setArrayLengthByName("task_groups_completed", 9);
  8166. packet2->setArrayLengthByName("num_task_groups", 10);
  8167. packet2->setArrayDataByName("task_group", "I spoke to Waulon as Captain Varlos had asked of me.");
  8168. packet2->setArrayDataByName("task_group", "I found Waulon's hat in one of the boxes.", 1);
  8169. packet2->setArrayDataByName("task_group", "I returned Waulon's hat.", 2);
  8170. packet2->setArrayDataByName("task_group", "I have spoken to Ingrid.", 3);
  8171. packet2->setArrayDataByName("task_group", "I purchased a Shard of Luclin.", 4);
  8172. packet2->setArrayDataByName("task_group", "I gave the Shard of Luclin to Ingrid.", 5);
  8173. packet2->setArrayDataByName("task_group", "I have spoken to Captain Varlos.", 6);
  8174. packet2->setArrayDataByName("task_group", "I killed the rats that Captain Varlos requested.", 7);
  8175. packet2->setArrayDataByName("task_group", "Captain Varlos has ordered you to kill the escaped goblin.", 8);
  8176. packet2->setArrayDataByName("task_group", "I killed the escaped goblin.", 9);
  8177. /*packet2->setSubArrayLengthByName("num_tasks", 1);
  8178. packet2->setSubArrayDataByName("task", "I need to talk to Garven Tralk");
  8179. packet2->setSubArrayLengthByName("num_updates", 1);
  8180. packet2->setSubArrayDataByName("update_currentval", 0);
  8181. packet2->setSubArrayDataByName("update_maxval", 1);
  8182. packet2->setSubArrayDataByName("icon", 11);
  8183. */
  8184. packet2->setArrayDataByName("waypoint", 0xFFFFFFFF);
  8185. packet2->setDataByName("journal_updated", 1);
  8186. packet2->setDataByName("bullets", 1);
  8187. EQ2Packet* app = packet2->serialize();
  8188. if (sep->IsSet(2)) {
  8189. int16 offset = atoi(sep->arg[1]);
  8190. uchar* ptr2 = app->pBuffer;
  8191. ptr2 += offset;
  8192. if (sep->IsNumber(2)) {
  8193. int32 value1 = atol(sep->arg[2]);
  8194. if (value1 > 0xFFFF)
  8195. memcpy(ptr2, (uchar*)&value1, 4);
  8196. else if (value1 > 0xFF)
  8197. memcpy(ptr2, (uchar*)&value1, 2);
  8198. else
  8199. memcpy(ptr2, (uchar*)&value1, 1);
  8200. }
  8201. else {
  8202. int16 len = strlen(sep->arg[2]);
  8203. memcpy(ptr2, (uchar*)&len, 2);
  8204. ptr2 += 2;
  8205. memcpy(ptr2, sep->arg[2], len);
  8206. }
  8207. }
  8208. DumpPacket(app);
  8209. client->QueuePacket(app);
  8210. safe_delete(packet2);
  8211. }
  8212. }
  8213. else if (atoi(sep->arg[0]) == 12) {
  8214. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalReply", client->GetVersion());
  8215. if (packet2) {
  8216. packet2->setDataByName("quest_id", 524);
  8217. packet2->setDataByName("player_crc", 2900677088);
  8218. packet2->setDataByName("name", "Archetype Selection");
  8219. packet2->setDataByName("description", "I have reported my profession to Garven Tralk.");
  8220. packet2->setDataByName("type", "Hallmark");
  8221. packet2->setDataByName("complete_header", "To complete this quest, I must do the following tasks:");
  8222. packet2->setDataByName("day", 19);
  8223. packet2->setDataByName("month", 6);
  8224. packet2->setDataByName("year", 20);
  8225. packet2->setDataByName("level", 2);
  8226. packet2->setDataByName("encounter_level", 4);
  8227. packet2->setDataByName("difficulty", 3);
  8228. packet2->setDataByName("time_obtained", Timer::GetUnixTimeStamp());
  8229. packet2->setDataByName("timer_start", Timer::GetUnixTimeStamp());
  8230. packet2->setDataByName("timer_duration", 300);
  8231. packet2->setDataByName("timer_running", 1);
  8232. packet2->setArrayLengthByName("task_groups_completed", 0);
  8233. packet2->setArrayLengthByName("num_task_groups", 1);
  8234. packet2->setArrayDataByName("task_group", "I need to talk to Garven Tralk");
  8235. packet2->setSubArrayLengthByName("num_tasks", 1);
  8236. packet2->setSubArrayDataByName("task", "I need to talk to Garven Tralk");
  8237. packet2->setSubArrayLengthByName("num_updates", 1);
  8238. packet2->setSubArrayDataByName("update_currentval", 0);
  8239. packet2->setSubArrayDataByName("update_maxval", 1);
  8240. packet2->setSubArrayDataByName("icon", 11);
  8241. packet2->setArrayDataByName("waypoint", 0xFFFFFFFF);
  8242. packet2->setDataByName("journal_updated", 1);
  8243. packet2->setSubstructDataByName("reward_data", "unknown1", 255);
  8244. packet2->setSubstructDataByName("reward_data", "reward", "Quest Reward!");
  8245. packet2->setSubstructDataByName("reward_data", "unknown2", 0x3f);
  8246. packet2->setSubstructDataByName("reward_data", "coin", 150);
  8247. packet2->setSubstructDataByName("reward_data", "status_points", 5);
  8248. packet2->setSubstructDataByName("reward_data", "exp_bonus", 10);
  8249. packet2->setSubstructArrayLengthByName("reward_data", "num_rewards", 1);
  8250. packet2->setSubstructArrayDataByName("reward_data", "reward_id", 123);
  8251. Item* item = master_item_list.GetItem(152755);
  8252. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8253. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  8254. /*packet2->setSubstructDataByName("item", "unique_id", 567);
  8255. packet2->setSubstructDataByName("item", "broker_item_id", 0xFFFFFFFFFFFFFFFF);
  8256. packet2->setSubstructDataByName("item", "icon", 0xe7);
  8257. packet2->setSubstructDataByName("item", "tier", 4);
  8258. packet2->setSubstructDataByName("item", "flags", 0x60);
  8259. packet2->setSubstructArrayLengthByName("item", "stat_count", 1);
  8260. packet2->setSubstructDataByName("item", "stat_type", 1);
  8261. packet2->setSubstructDataByName("item", "stat_subtype", 2);
  8262. packet2->setSubstructDataByName("item", "value", 3);
  8263. packet2->setSubstructDataByName("item", "condition", 100);
  8264. packet2->setSubstructDataByName("item", "weight", 1);
  8265. packet2->setSubstructDataByName("item", "skill_req1", 0xacafa99e);
  8266. packet2->setSubstructDataByName("item", "skill_req2", 0xacafa99e);
  8267. packet2->setSubstructDataByName("item", "skill_min", 1);
  8268. packet2->setSubstructArrayLengthByName("item", "class_count", 3);
  8269. packet2->setSubstructDataByName("item", "adventure_class", 1);
  8270. packet2->setSubstructDataByName("item", "adventure_class", 11, 0, 1);
  8271. packet2->setSubstructDataByName("item", "adventure_class", 0x1f, 0, 2);
  8272. packet2->setSubstructDataByName("item", "tradeskill_class", 255);
  8273. packet2->setSubstructDataByName("item", "tradeskill_class", 255, 0, 1);
  8274. packet2->setSubstructDataByName("item", "tradeskill_class", 255, 0, 2);
  8275. packet2->setSubstructDataByName("item", "level", 0x1e);
  8276. packet2->setSubstructDataByName("item", "level", 100, 0, 1);
  8277. packet2->setSubstructDataByName("item", "level", 100, 0, 2);
  8278. packet2->setSubstructDataByName("item_footer", "name", "Footman Gloves");*/
  8279. //packet2->PrintPacket();
  8280. EQ2Packet* app = packet2->serialize();
  8281. if (sep->IsSet(2)) {
  8282. int16 offset = atoi(sep->arg[1]);
  8283. uchar* ptr2 = app->pBuffer;
  8284. ptr2 += offset;
  8285. if (sep->IsNumber(2)) {
  8286. int32 value1 = atol(sep->arg[2]);
  8287. if (value1 > 0xFFFF)
  8288. memcpy(ptr2, (uchar*)&value1, 4);
  8289. else if (value1 > 0xFF)
  8290. memcpy(ptr2, (uchar*)&value1, 2);
  8291. else
  8292. memcpy(ptr2, (uchar*)&value1, 1);
  8293. }
  8294. else {
  8295. int16 len = strlen(sep->arg[2]);
  8296. memcpy(ptr2, (uchar*)&len, 2);
  8297. ptr2 += 2;
  8298. memcpy(ptr2, sep->arg[2], len);
  8299. }
  8300. }
  8301. DumpPacket(app);
  8302. client->QueuePacket(app);
  8303. safe_delete(packet2);
  8304. }
  8305. }
  8306. else if (atoi(sep->arg[0]) == 13) {
  8307. PacketStruct* packet2 = configReader.getStruct("WS_OnScreenMsg", client->GetVersion());
  8308. if (packet2 && sep->IsSet(7)) {
  8309. packet2->setDataByName("unknown", atoi(sep->arg[1]));
  8310. char blah[128];
  8311. sprintf(blah, "\\#6EFF6EYou get better at \12\\#C8FFC8%s\\#6EFF6E! (7/15)", sep->arg[2]);
  8312. packet2->setDataByName("text", blah);
  8313. packet2->setDataByName("message_type", sep->arg[3]);
  8314. packet2->setDataByName("size", atof(sep->arg[4]));
  8315. packet2->setDataByName("red", atoi(sep->arg[5]));
  8316. packet2->setDataByName("green", atoi(sep->arg[6]));
  8317. packet2->setDataByName("blue", atoi(sep->arg[7]));
  8318. EQ2Packet* app = packet2->serialize();
  8319. DumpPacket(app);
  8320. client->QueuePacket(app);
  8321. safe_delete(packet2);
  8322. }
  8323. }
  8324. else if (atoi(sep->arg[0]) == 14) {
  8325. PacketStruct* packet2 = configReader.getStruct("WS_InstructionWindow", client->GetVersion());
  8326. if (packet2 && sep->IsSet(3)) {
  8327. packet2->setDataByName("open_seconds_min", atof(sep->arg[1]));
  8328. packet2->setDataByName("open_seconds_max", atof(sep->arg[2]));
  8329. packet2->setDataByName("voice_sync", atoi(sep->arg[3]));
  8330. 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.");
  8331. packet2->setDataByName("voice", "voiceover/english/narrator/boat_06p_tutorial02/narrator_001_63779ca0.mp3");
  8332. packet2->setArrayLengthByName("num_goals", 1);
  8333. //packet2->setArrayDataByName("goal_text", )
  8334. packet2->setSubArrayLengthByName("num_tasks", 1);
  8335. packet2->setSubArrayDataByName("task_text", "continue");
  8336. packet2->setDataByName("complete_sound", "click");
  8337. packet2->setDataByName("signal", "introduction");
  8338. packet2->setDataByName("voice_key1", 0xcda65173);
  8339. packet2->setDataByName("voice_key2", 0x984bfc6d);
  8340. EQ2Packet* app = packet2->serialize();
  8341. DumpPacket(app);
  8342. client->QueuePacket(app);
  8343. safe_delete(packet2);
  8344. packet2 = configReader.getStruct("WS_ShowWindow", client->GetVersion());
  8345. packet2->setDataByName("window", "MainHUD.StartMenu");
  8346. packet2->setDataByName("show", 1);
  8347. app = packet2->serialize();
  8348. DumpPacket(app);
  8349. client->QueuePacket(app);
  8350. safe_delete(packet2);
  8351. packet2 = configReader.getStruct("WS_FlashWindow", client->GetVersion());
  8352. packet2->setDataByName("window", "MainHUD.StartMenu.help");
  8353. packet2->setDataByName("flash_seconds", 10);
  8354. app = packet2->serialize();
  8355. DumpPacket(app);
  8356. client->QueuePacket(app);
  8357. safe_delete(packet2);
  8358. }
  8359. }
  8360. else if (atoi(sep->arg[0]) == 15) {
  8361. PacketStruct* packet2 = configReader.getStruct("WS_UpdateLoot", client->GetVersion());
  8362. if (packet2) {
  8363. packet2->setArrayLengthByName("loot_count", 1);
  8364. packet2->setArrayDataByName("name", "Test");
  8365. packet2->setArrayDataByName("item_id", 1234);
  8366. packet2->setArrayDataByName("count", 1);
  8367. packet2->setArrayDataByName("icon", 258);
  8368. packet2->setArrayDataByName("ability_id", 0xFFFFFFFF);
  8369. Spawn* spawn = client->GetPlayer()->GetTarget();
  8370. if (spawn)
  8371. packet2->setDataByName("object_id", client->GetPlayer()->GetIDWithPlayerSpawn(spawn));
  8372. packet2->setDataByName("unknown3", 1);
  8373. packet2->setDataByName("unknown4", 1);
  8374. packet2->setDataByName("unknown5", 60);
  8375. EQ2Packet* app = packet2->serialize();
  8376. DumpPacket(app);
  8377. client->QueuePacket(app);
  8378. safe_delete(packet2);
  8379. }
  8380. }
  8381. else if (atoi(sep->arg[0]) == 16 && sep->IsNumber(1)) {
  8382. char blah[32];
  8383. sprintf(blah, "Testing: %i", atoi(sep->arg[1]));
  8384. client->SimpleMessage(atoi(sep->arg[1]), blah);
  8385. }
  8386. else if (atoi(sep->arg[0]) == 17 && sep->IsNumber(2)) {
  8387. if (sep->IsSet(2)) {
  8388. int16 offset = atoi(sep->arg[1]);
  8389. if (sep->IsNumber(2)) {
  8390. int32 value1 = atol(sep->arg[2]);
  8391. client->QueuePacket(client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion(), offset, value1));
  8392. cout << "Sent" << endl;
  8393. }
  8394. }
  8395. }
  8396. else if (atoi(sep->arg[0]) == 18) {
  8397. PacketStruct* packet2 = configReader.getStruct("WS_QuestRewardPackMsg", client->GetVersion());
  8398. if (packet2) {
  8399. packet2->setSubstructDataByName("reward_data", "unknown1", 255);
  8400. packet2->setSubstructDataByName("reward_data", "reward", "Quest Reward!");
  8401. packet2->setSubstructDataByName("reward_data", "coin", 150);
  8402. packet2->setSubstructDataByName("reward_data", "status_points", 5);
  8403. packet2->setSubstructDataByName("reward_data", "exp_bonus", 10);
  8404. packet2->setSubstructArrayLengthByName("reward_data", "num_rewards", 4);
  8405. Item* item = new Item(master_item_list.GetItem(36212));
  8406. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8407. item->stack_count = 20;
  8408. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  8409. safe_delete(item);
  8410. item = new Item(master_item_list.GetItem(36685));
  8411. item->stack_count = 20;
  8412. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8413. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 1, 0, -1);
  8414. safe_delete(item);
  8415. item = master_item_list.GetItem(1414);
  8416. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8417. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 2, 0, -1);
  8418. item = master_item_list.GetItem(75057);
  8419. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8420. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 3, 0, -1);
  8421. EQ2Packet* app = packet2->serialize();
  8422. if (sep->IsSet(2)) {
  8423. int16 offset = atoi(sep->arg[1]);
  8424. uchar* ptr2 = app->pBuffer;
  8425. ptr2 += offset;
  8426. if (sep->IsNumber(2)) {
  8427. int32 value1 = atol(sep->arg[2]);
  8428. if (value1 > 0xFFFF)
  8429. memcpy(ptr2, (uchar*)&value1, 4);
  8430. else if (value1 > 0xFF)
  8431. memcpy(ptr2, (uchar*)&value1, 2);
  8432. else
  8433. memcpy(ptr2, (uchar*)&value1, 1);
  8434. }
  8435. else {
  8436. int16 len = strlen(sep->arg[2]);
  8437. memcpy(ptr2, (uchar*)&len, 2);
  8438. ptr2 += 2;
  8439. memcpy(ptr2, sep->arg[2], len);
  8440. }
  8441. }
  8442. DumpPacket(app);
  8443. client->QueuePacket(app);
  8444. safe_delete(packet2);
  8445. }
  8446. }
  8447. else if (atoi(sep->arg[0]) == 19) {
  8448. PacketStruct* packet2 = configReader.getStruct("WS_UpdateLoot", client->GetVersion());
  8449. Spawn* spawn = client->GetPlayer()->GetTarget();
  8450. if (packet2 && spawn) {
  8451. Item* item = master_item_list.GetItem(130053);
  8452. packet2->setArrayLengthByName("loot_count", 1);
  8453. packet2->setArrayDataByName("loot_id", item->details.item_id);
  8454. packet2->setArrayDataByName("unknown2", 1);
  8455. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, 2, true);
  8456. packet2->setDataByName("display", 1);
  8457. packet2->setDataByName("unknown2b", 1);
  8458. packet2->setDataByName("unknown3", 0x3c);
  8459. packet2->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(spawn));
  8460. packet2->PrintPacket();
  8461. EQ2Packet* app = packet2->serialize();
  8462. if (sep->IsSet(2)) {
  8463. int16 offset = atoi(sep->arg[1]);
  8464. int16 offset2 = 0;
  8465. int32 value1 = 0;
  8466. if (sep->IsSet(3)) {
  8467. offset2 = atoi(sep->arg[2]);
  8468. value1 = atol(sep->arg[3]);
  8469. }
  8470. else
  8471. value1 = atol(sep->arg[2]);
  8472. int16 offset3 = 0;
  8473. int16 offset4 = 0;
  8474. int32 value2 = 0;
  8475. if (sep->IsSet(6)) {
  8476. offset3 = atoi(sep->arg[4]);
  8477. offset4 = atoi(sep->arg[5]);
  8478. value2 = atol(sep->arg[6]);
  8479. }
  8480. offset--;
  8481. if (offset2 > 0 && offset2 >= offset) {
  8482. offset2--;
  8483. uchar* ptr2 = app->pBuffer;
  8484. ptr2 += offset;
  8485. for (int i = offset; i <= offset2; i++) {
  8486. if (value1 > 0xFFFF) {
  8487. memcpy(ptr2, (uchar*)&value1, 4);
  8488. i += 3;
  8489. ptr2 += 3;
  8490. }
  8491. else if (value1 > 0xFF) {
  8492. memcpy(ptr2, (uchar*)&value1, 2);
  8493. i++;
  8494. ptr2++;
  8495. }
  8496. else
  8497. memcpy(ptr2, (uchar*)&value1, 1);
  8498. ptr2++;
  8499. }
  8500. }
  8501. if (offset4 > 0 && offset4 >= offset3) {
  8502. offset3--;
  8503. offset4--;
  8504. uchar* ptr2 = app->pBuffer;
  8505. ptr2 += offset3;
  8506. for (int i = offset3; i <= offset4; i++) {
  8507. if (value2 > 0xFFFF) {
  8508. memcpy(ptr2, (uchar*)&value2, 4);
  8509. i += 3;
  8510. ptr2 += 3;
  8511. }
  8512. else if (value2 > 0xFF) {
  8513. memcpy(ptr2, (uchar*)&value2, 2);
  8514. i++;
  8515. ptr2++;
  8516. }
  8517. else
  8518. memcpy(ptr2, (uchar*)&value2, 1);
  8519. ptr2++;
  8520. }
  8521. }
  8522. }
  8523. DumpPacket(app);
  8524. client->QueuePacket(app);
  8525. safe_delete(packet2);
  8526. }
  8527. }
  8528. else if (atoi(sep->arg[0]) == 21) {
  8529. PacketStruct* packet2 = configReader.getStruct("WS_OfferQuest", client->GetVersion());
  8530. if (packet2) {
  8531. packet2->setDataByName("unknown0", 255);
  8532. packet2->setDataByName("reward", "New Quest");
  8533. packet2->setDataByName("title", "Title");
  8534. packet2->setDataByName("description", "description");
  8535. packet2->setDataByName("quest_difficulty", 3);
  8536. packet2->setDataByName("unknown1", 5);
  8537. packet2->setDataByName("level", 3);
  8538. packet2->setDataByName("coin", 150);
  8539. packet2->setDataByName("status_points", 5);
  8540. packet2->setDataByName("exp_bonus", 10);
  8541. packet2->setArrayLengthByName("num_rewards", 1);
  8542. Item* item = new Item(master_item_list.GetItem(36212));
  8543. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8544. item->stack_count = 20;
  8545. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  8546. safe_delete(item);
  8547. char accept[35] = { 0 };
  8548. char decline[35] = { 0 };
  8549. sprintf(accept, "q_accept_pending_quest %u", 0);
  8550. sprintf(decline, "q_deny_pending_quest %u", 0);
  8551. packet2->setDataByName("accept_command", accept);
  8552. packet2->setDataByName("decline_command", decline);
  8553. EQ2Packet* app = packet2->serialize();
  8554. if (sep->IsSet(2)) {
  8555. int16 offset = atoi(sep->arg[1]);
  8556. uchar* ptr2 = app->pBuffer;
  8557. ptr2 += offset;
  8558. if (sep->IsNumber(2)) {
  8559. int32 value1 = atol(sep->arg[2]);
  8560. if (value1 > 0xFFFF)
  8561. memcpy(ptr2, (uchar*)&value1, 4);
  8562. else if (value1 > 0xFF)
  8563. memcpy(ptr2, (uchar*)&value1, 2);
  8564. else
  8565. memcpy(ptr2, (uchar*)&value1, 1);
  8566. }
  8567. DumpPacket(app);
  8568. client->QueuePacket(app);
  8569. safe_delete(packet2);
  8570. }
  8571. }
  8572. }
  8573. else if (atoi(sep->arg[0]) == 22) { //same as 21, but 8bit string
  8574. PacketStruct* packet2 = configReader.getStruct("WS_OfferQuest", client->GetVersion());
  8575. if (packet2) {
  8576. packet2->setDataByName("unknown0", 255);
  8577. packet2->setDataByName("reward", "New Quest");
  8578. packet2->setDataByName("title", "Title");
  8579. packet2->setDataByName("description", "description");
  8580. packet2->setDataByName("quest_difficulty", 3);
  8581. packet2->setDataByName("unknown1", 5);
  8582. packet2->setDataByName("level", 3);
  8583. packet2->setDataByName("coin", 150);
  8584. packet2->setDataByName("status_points", 5);
  8585. packet2->setDataByName("exp_bonus", 10);
  8586. packet2->setArrayLengthByName("num_rewards", 1);
  8587. Item* item = new Item(master_item_list.GetItem(36212));
  8588. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8589. item->stack_count = 20;
  8590. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  8591. safe_delete(item);
  8592. char accept[35] = { 0 };
  8593. char decline[35] = { 0 };
  8594. sprintf(accept, "q_accept_pending_quest %u", 0);
  8595. sprintf(decline, "q_deny_pending_quest %u", 0);
  8596. packet2->setDataByName("accept_command", accept);
  8597. packet2->setDataByName("decline_command", decline);
  8598. EQ2Packet* app = packet2->serialize();
  8599. if (sep->IsSet(2)) {
  8600. int16 offset = atoi(sep->arg[1]);
  8601. uchar* ptr2 = app->pBuffer;
  8602. ptr2 += offset;
  8603. if (sep->IsNumber(2)) {
  8604. int32 value1 = atol(sep->arg[2]);
  8605. if (value1 > 0xFFFF)
  8606. memcpy(ptr2, (uchar*)&value1, 4);
  8607. else if (value1 > 0xFF)
  8608. memcpy(ptr2, (uchar*)&value1, 2);
  8609. else
  8610. memcpy(ptr2, (uchar*)&value1, 1);
  8611. }
  8612. else {
  8613. int8 len = strlen(sep->arg[2]);
  8614. memcpy(ptr2, (uchar*)&len, 1);
  8615. ptr2 += 1;
  8616. memcpy(ptr2, sep->arg[2], len);
  8617. }
  8618. }
  8619. DumpPacket(app);
  8620. client->QueuePacket(app);
  8621. safe_delete(packet2);
  8622. }
  8623. }
  8624. else if (atoi(sep->arg[0]) == 23) {
  8625. if (client->GetPlayer()->GetTarget()) {
  8626. PacketStruct* packet2 = configReader.getStruct("WS_UpdateMerchant", client->GetVersion());
  8627. if (packet2) {
  8628. Spawn* target = client->GetPlayer()->GetTarget();
  8629. packet2->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(target));
  8630. Item* item = new Item(master_item_list.GetItem(12565));
  8631. int8 i = 0;
  8632. packet2->setArrayLengthByName("num_items", 1);
  8633. packet2->setArrayDataByName("item_name", item->name.c_str(), i);
  8634. packet2->setArrayDataByName("item_id", item->details.item_id, i);
  8635. packet2->setArrayDataByName("stack_size", item->stack_count, i);
  8636. packet2->setArrayDataByName("icon", item->details.icon, i);
  8637. int8 tmp_level = 0;
  8638. if (item->generic_info.adventure_default_level > 0)
  8639. tmp_level = item->generic_info.adventure_default_level;
  8640. else
  8641. tmp_level = item->generic_info.tradeskill_default_level;
  8642. packet2->setArrayDataByName("level", tmp_level, i);
  8643. packet2->setArrayDataByName("tier", item->details.tier, i);
  8644. packet2->setArrayDataByName("item_id2", item->details.item_id, i);
  8645. int8 item_difficulty = client->GetPlayer()->GetArrowColor(tmp_level);
  8646. if (item_difficulty != ARROW_COLOR_WHITE && item_difficulty != ARROW_COLOR_RED && item_difficulty != ARROW_COLOR_GRAY)
  8647. item_difficulty = ARROW_COLOR_WHITE;
  8648. item_difficulty -= 6;
  8649. if (item_difficulty < 0)
  8650. item_difficulty *= -1;
  8651. packet2->setArrayDataByName("item_difficulty", item_difficulty, i);
  8652. packet2->setArrayDataByName("quantity", 2, i);
  8653. packet2->setArrayDataByName("unknown5", 255, i);
  8654. packet2->setArrayDataByName("stack_size2", item->stack_count, i);
  8655. packet2->setArrayDataByName("description", item->description.c_str(), i);
  8656. packet2->setDataByName("type", 2);
  8657. EQ2Packet* app = packet2->serialize();
  8658. if (sep->IsSet(2)) {
  8659. int16 offset = atoi(sep->arg[1]);
  8660. uchar* ptr2 = app->pBuffer;
  8661. ptr2 += offset;
  8662. if (sep->IsNumber(2)) {
  8663. int32 value1 = atol(sep->arg[2]);
  8664. if (value1 > 0xFFFF)
  8665. memcpy(ptr2, (uchar*)&value1, 4);
  8666. else if (value1 > 0xFF)
  8667. memcpy(ptr2, (uchar*)&value1, 2);
  8668. else
  8669. memcpy(ptr2, (uchar*)&value1, 1);
  8670. }
  8671. else {
  8672. int8 len = strlen(sep->arg[2]);
  8673. memcpy(ptr2, (uchar*)&len, 1);
  8674. ptr2 += 1;
  8675. memcpy(ptr2, sep->arg[2], len);
  8676. }
  8677. }
  8678. DumpPacket(app);
  8679. client->QueuePacket(app);
  8680. safe_delete(packet2);
  8681. }
  8682. }
  8683. }
  8684. else if (atoi(sep->arg[0]) == 24) {
  8685. PacketStruct* packet2 = configReader.getStruct("WS_EnableGameEvent", client->GetVersion());
  8686. if (packet2) {
  8687. if (sep->IsSet(2)) {
  8688. packet2->setDataByName("event_name", sep->arg[1]);
  8689. packet2->setDataByName("enabled", atoi(sep->arg[2]));
  8690. EQ2Packet* app = packet2->serialize();
  8691. DumpPacket(app);
  8692. client->QueuePacket(app);
  8693. safe_delete(packet2);
  8694. }
  8695. }
  8696. }
  8697. else if (atoi(sep->arg[0]) == 25) {
  8698. if (sep->IsSet(1)) {
  8699. Widget* new_spawn = new Widget();
  8700. int32 id = atoul(sep->arg[1]);
  8701. new_spawn->SetWidgetID(id);
  8702. EQ2Packet* ret = new_spawn->serialize(client->GetPlayer(), client->GetVersion());
  8703. client->QueuePacket(ret);
  8704. int8 index = client->GetPlayer()->GetIndexForSpawn(new_spawn);
  8705. PacketStruct* packet2 = configReader.getStruct("WS_DestroyGhostCmd", client->GetVersion());
  8706. if (packet2) {
  8707. packet2->setDataByName("spawn_index", index);
  8708. packet2->setDataByName("delete", 1);
  8709. EQ2Packet* app = packet2->serialize();
  8710. client->QueuePacket(app);
  8711. safe_delete(packet2);
  8712. }
  8713. }
  8714. }
  8715. else if (atoi(sep->arg[0]) == 26) {
  8716. if (sep->IsSet(4)) {
  8717. Widget* new_spawn = new Widget();
  8718. int32 id = atoul(sep->arg[1]);
  8719. new_spawn->SetWidgetID(id);
  8720. float x = atof(sep->arg[2]);
  8721. float y = atof(sep->arg[3]);
  8722. float z = atof(sep->arg[4]);
  8723. new_spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  8724. new_spawn->SetWidgetX(x);
  8725. new_spawn->SetWidgetY(y);
  8726. new_spawn->SetWidgetZ(z);
  8727. new_spawn->SetX(x);
  8728. new_spawn->SetY(y);
  8729. new_spawn->SetZ(z);
  8730. EQ2Packet* ret = new_spawn->serialize(client->GetPlayer(), client->GetVersion());
  8731. client->QueuePacket(ret);
  8732. }
  8733. }
  8734. else if (atoi(sep->arg[0]) == 27) {
  8735. Spawn* target = client->GetPlayer()->GetTarget();
  8736. PacketStruct* packet2 = configReader.getStruct("WS_HearSimpleDamage", client->GetVersion());
  8737. if (packet2 && target && sep->IsSet(2)) {
  8738. packet2->setSubstructDataByName("header", "defender", client->GetPlayer()->GetIDWithPlayerSpawn(target));
  8739. packet2->setSubstructDataByName("header", "defender_proxy", client->GetPlayer()->GetIDWithPlayerSpawn(target));
  8740. packet2->setSubstructDataByName("header", "attacker", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  8741. packet2->setArrayLengthByName("num_dmg", 1);
  8742. packet2->setArrayDataByName("damage_type", atoi(sep->arg[1]));
  8743. packet2->setArrayDataByName("damage", atoi(sep->arg[2]));
  8744. packet2->setDataByName("spell", 1);
  8745. packet2->setDataByName("spell_name", "Testing");
  8746. EQ2Packet* app = packet2->serialize();
  8747. if (sep->IsSet(4)) {
  8748. int16 offset = atoi(sep->arg[3]);
  8749. uchar* ptr2 = app->pBuffer;
  8750. ptr2 += offset;
  8751. if (sep->IsNumber(4)) {
  8752. int32 value1 = atol(sep->arg[4]);
  8753. if (value1 > 0xFFFF)
  8754. memcpy(ptr2, (uchar*)&value1, 4);
  8755. else if (value1 > 0xFF)
  8756. memcpy(ptr2, (uchar*)&value1, 2);
  8757. else
  8758. memcpy(ptr2, (uchar*)&value1, 1);
  8759. }
  8760. else {
  8761. int8 len = strlen(sep->arg[4]);
  8762. memcpy(ptr2, (uchar*)&len, 1);
  8763. ptr2 += 1;
  8764. memcpy(ptr2, sep->arg[4], len);
  8765. }
  8766. }
  8767. if (sep->IsSet(6)) {
  8768. int16 offset = atoi(sep->arg[5]);
  8769. uchar* ptr2 = app->pBuffer;
  8770. ptr2 += offset;
  8771. if (sep->IsNumber(6)) {
  8772. int32 value1 = atol(sep->arg[6]);
  8773. if (value1 > 0xFFFF)
  8774. memcpy(ptr2, (uchar*)&value1, 4);
  8775. else if (value1 > 0xFF)
  8776. memcpy(ptr2, (uchar*)&value1, 2);
  8777. else
  8778. memcpy(ptr2, (uchar*)&value1, 1);
  8779. }
  8780. else {
  8781. int8 len = strlen(sep->arg[6]);
  8782. memcpy(ptr2, (uchar*)&len, 1);
  8783. ptr2 += 1;
  8784. memcpy(ptr2, sep->arg[6], len);
  8785. }
  8786. }
  8787. DumpPacket(app);
  8788. client->QueuePacket(app);
  8789. safe_delete(packet2);
  8790. }
  8791. }
  8792. }
  8793. else {
  8794. PacketStruct* packet2 = configReader.getStruct("WS_ExamineSpellInfo", client->GetVersion());
  8795. if (packet2) {
  8796. packet2->setSubstructDataByName("info_header", "show_name", 1);
  8797. packet2->setSubstructDataByName("info_header", "unknown", 7);
  8798. packet2->setSubstructDataByName("info_header", "unknown2", 1);
  8799. packet2->setSubstructDataByName("info_header", "unknown3", 1);
  8800. packet2->setSubstructDataByName("info_header", "unknown4", 1);
  8801. packet2->setSubstructDataByName("info_header", "unknown5", 1);
  8802. packet2->setSubstructDataByName("info_header", "unknown6", "Testing");
  8803. packet2->setSubstructDataByName("info_header", "unknown7", "Testing");
  8804. packet2->setSubstructDataByName("info_header", "unknown8", 66);
  8805. packet2->setSubstructDataByName("info_header", "title", "Blah Title Blah");
  8806. packet2->setSubstructDataByName("info_header", "title_text", "Blah Blah");
  8807. packet2->setSubstructDataByName("info_header", "title_text2", "Blah Blah2");
  8808. packet2->setSubstructDataByName("info_header", "show_popup", 1);
  8809. packet2->setSubstructDataByName("info_header", "packettype", 3);
  8810. packet2->setSubstructDataByName("spell_info", "skill_name", "Testing");
  8811. packet2->setSubstructDataByName("spell_info", "level", 19);
  8812. packet2->setSubstructDataByName("spell_info", "tier", 1);
  8813. packet2->setSubstructDataByName("spell_info", "health_cost", 5);
  8814. packet2->setSubstructDataByName("spell_info", "min_class_skill_req", 3);
  8815. packet2->setSubstructDataByName("spell_info", "mana_cost", 6);
  8816. packet2->setSubstructDataByName("spell_info", "req_concentration", 7);
  8817. packet2->setSubstructDataByName("spell_info", "cast_time", 200);
  8818. packet2->setSubstructDataByName("spell_info", "recovery", 220);
  8819. packet2->setSubstructDataByName("spell_info", "recast", 280);
  8820. packet2->setSubstructDataByName("spell_info", "beneficial", 1);
  8821. packet2->setSubstructDataByName("spell_info", "maintained", 1);
  8822. packet2->setSubstructDataByName("spell_info", "spell_book_type", 1);
  8823. packet2->setSubstructDataByName("spell_info", "quality", 3);
  8824. packet2->setSubstructDataByName("spell_info", "test_1a", 1);
  8825. packet2->setSubstructDataByName("spell_info", "test_1b", 1);
  8826. packet2->setSubstructDataByName("spell_info", "test_1c", 1);
  8827. packet2->setSubstructDataByName("spell_info", "test_1d", 1);
  8828. packet2->setSubstructDataByName("spell_info", "test_2a", 2);
  8829. packet2->setSubstructDataByName("spell_info", "test_2b", 2);
  8830. packet2->setSubstructDataByName("spell_info", "test_2c", 2);
  8831. packet2->setSubstructDataByName("spell_info", "test_2d", 2);
  8832. packet2->setSubstructDataByName("spell_info", "test_3", 3);
  8833. packet2->setSubstructDataByName("spell_info", "test_4", 4);
  8834. packet2->setSubstructDataByName("spell_info", "test_5", 5);
  8835. packet2->setSubstructDataByName("spell_info", "test_6", 6);
  8836. packet2->setSubstructDataByName("spell_info", "min_class_skill_req", 1);
  8837. packet2->setSubstructDataByName("spell_info", "min_class_skill_rec", 30123);
  8838. packet2->setSubstructDataByName("spell_info", "num_reagents", 1);
  8839. packet2->setSubstructArrayLengthByName("spell_info", "num_reagents", 1);
  8840. packet2->setArrayDataByName("reagent", "Alcohol");
  8841. packet2->setArrayDataByName("consumed", "123");
  8842. packet2->setSubstructDataByName("spell_info", "class_skill", 52);
  8843. packet2->setSubstructDataByName("spell_info", "id", 8308);
  8844. packet2->setSubstructDataByName("spell_info", "icon", 303);
  8845. packet2->setSubstructDataByName("spell_info", "icon2", 0xFFFF);
  8846. packet2->setSubstructDataByName("spell_info", "icontype", 317);
  8847. packet2->setSubstructDataByName("spell_info", "type", 2);
  8848. packet2->setSubstructDataByName("spell_info", "spell_text_color", 255);
  8849. packet2->setSubstructDataByName("spell_info", "duration1", 600);
  8850. packet2->setSubstructDataByName("spell_info", "duration2", 600);
  8851. packet2->setSubstructDataByName("spell_info", "name", "Sprint");
  8852. packet2->setSubstructDataByName("spell_info", "description", "Test description");
  8853. EQ2Packet* outapp = packet2->serialize();
  8854. DumpPacket(outapp);
  8855. client->QueuePacket(outapp);
  8856. safe_delete(packet2);
  8857. }
  8858. }
  8859. return;
  8860. PacketStruct* p = configReader.getStruct("WS_EqTargetItemCmd", client->GetVersion());
  8861. if (!p) return;
  8862. //Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  8863. //client->GetCurrentZone()->SendSpellFailedPacket(client, atoi(sep2->arg[0]));
  8864. //}
  8865. /*Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  8866. if (sep2 && sep2->arg[0] && sep2->IsNumber(0)) {
  8867. client->SetPendingFlightPath(atoi(sep2->arg[0]));
  8868. PacketStruct* packet = configReader.getStruct("WS_ReadyForTakeOff", client->GetVersion());
  8869. if (packet) {
  8870. client->QueuePacket(packet->serialize());
  8871. safe_delete(packet);
  8872. }
  8873. }*/
  8874. /*if (client->GetCurrentZone()->Grid != nullptr) {
  8875. int32 numFaces = 0;
  8876. int32 numGrids = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.size();
  8877. client->Message(CHANNEL_COLOR_YELLOW, "Num grids in cell: %u", numGrids);
  8878. map<int32, vector<Face*> >::iterator itr;
  8879. for (itr = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.begin(); itr != client->GetPlayer()->Cell_Info.CurrentCell->FaceList.end(); itr++)
  8880. numFaces += (*itr).second.size();
  8881. client->Message(CHANNEL_COLOR_YELLOW, "Num faces in cell: %u", numFaces);
  8882. }*/
  8883. //uchar blah[] = {
  8884. // 1208 - OP_EQUpdateStoreCmd
  8885. // /*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
  8886. // /*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
  8887. // 1193 - -- OP_ClientCmdMsg::OP_EqUpdateMerchantCmd --
  8888. // /*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
  8889. /*};
  8890. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  8891. int8 val = 0;
  8892. int16 pos = 0;
  8893. int idx = 0;
  8894. while(sep2 && sep2->arg[idx+1] && sep2->IsNumber(idx) && sep2->IsNumber(idx+1)){
  8895. pos = atoi(sep2->arg[idx]);
  8896. val = atoi(sep2->arg[idx+1]);
  8897. memset(blah+pos, val, 1);
  8898. idx+=2;
  8899. }
  8900. DumpPacket(blah, sizeof(blah));
  8901. client->QueuePacket(new EQ2Packet(OP_GroupCreatedMsg , blah, sizeof(blah)));*/
  8902. if (client->GetPlayer()->GetTarget()) {
  8903. PacketStruct* packet = configReader.getStruct("WS_SetControlGhost", client->GetVersion());
  8904. if (packet) {
  8905. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  8906. packet->setDataByName("size", 0);
  8907. packet->setDataByName("unknown2", 0);
  8908. EQ2Packet* app = packet->serialize();
  8909. client->QueuePacket(app);
  8910. safe_delete(packet);
  8911. }
  8912. PacketStruct* set_pov = configReader.getStruct("WS_SetPOVGhostCmd", client->GetVersion());
  8913. if (set_pov) {
  8914. set_pov->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  8915. EQ2Packet* app_pov = set_pov->serialize();
  8916. client->QueuePacket(app_pov);
  8917. safe_delete(set_pov);
  8918. }
  8919. }
  8920. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  8921. PacketStruct* packet = configReader.getStruct("WS_OpenCharCust", client->GetVersion());
  8922. if (packet) {
  8923. if (sep2 && sep2->arg[0] && sep2->IsNumber(0))
  8924. packet->setDataByName("Type", atoi(sep2->arg[0]));
  8925. else
  8926. packet->setDataByName("Type", 2);
  8927. if (sep2 && sep2->arg[1] && sep2->IsNumber(1))
  8928. packet->setDataByName("race_id", atoi(sep2->arg[1]));
  8929. else
  8930. packet->setDataByName("race_id", 0);
  8931. if (sep2 && sep2->arg[2] && sep2->IsNumber(2))
  8932. packet->setDataByName("gender", atoi(sep2->arg[2]));
  8933. else
  8934. packet->setDataByName("gender", 2);
  8935. if (sep2 && sep2->arg[3] && sep2->IsNumber(3))
  8936. packet->setDataByName("unknown", atoi(sep2->arg[3]), 0);
  8937. else
  8938. packet->setDataByName("unknown", 0, 0);
  8939. if (sep2 && sep2->arg[4] && sep2->IsNumber(4))
  8940. packet->setDataByName("unknown", atoi(sep2->arg[4]), 1);
  8941. else
  8942. packet->setDataByName("unknown", 0, 1);
  8943. if (sep2 && sep2->arg[5] && sep2->IsNumber(5))
  8944. packet->setDataByName("unknown", atoi(sep2->arg[5]), 2);
  8945. else
  8946. packet->setDataByName("unknown", 0, 2);
  8947. client->QueuePacket(packet->serialize());
  8948. }
  8949. safe_delete(packet);
  8950. safe_delete(sep2);
  8951. }
  8952. void Commands::Command_LeaveChannel(Client *client, Seperator *sep) {
  8953. const char *channel_name;
  8954. if (sep == NULL || !sep->IsSet(0)) {
  8955. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /leavechat <channel name>");
  8956. PrintSep(sep);
  8957. return;
  8958. }
  8959. channel_name = sep->arg[0];
  8960. if (!chat.IsInChannel(client, channel_name))
  8961. client->Message(CHANNEL_NARRATIVE, "Unable to leave '%s': You are not in the channel.", channel_name);
  8962. else if (!chat.LeaveChannel(client, channel_name))
  8963. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an internal error preventing you from leaving that channel MUAHAHA");
  8964. }
  8965. /*
  8966. Function:
  8967. Purpose :
  8968. Params :
  8969. Dev :
  8970. Example :
  8971. */
  8972. void Commands::Command_WeaponStats(Client* client)
  8973. {
  8974. Player* player = client->GetPlayer();
  8975. Item* primary = player->GetEquipmentList()->GetItem(EQ2_PRIMARY_SLOT);
  8976. Item* secondary = player->GetEquipmentList()->GetItem(EQ2_SECONDARY_SLOT);
  8977. Item* ranged = player->GetEquipmentList()->GetItem(EQ2_RANGE_SLOT);
  8978. client->SimpleMessage(0, "Primary:");
  8979. if (primary) {
  8980. client->Message(0, "Name: %s", primary->name.c_str());
  8981. client->Message(0, "Base Damage: %u - %u", primary->weapon_info->damage_low3, primary->weapon_info->damage_high3);
  8982. client->Message(0, "Actual Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  8983. client->Message(0, "Actual Delay: %u", player->GetPrimaryWeaponDelay());
  8984. client->Message(0, "Proc Percent: %d%%", 0);
  8985. client->Message(0, "Procs Per Minute: %d", 0);
  8986. }
  8987. else {
  8988. client->SimpleMessage(0, "Name: fist");
  8989. client->Message(0, "Base Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  8990. client->Message(0, "Actual Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  8991. client->Message(0, "Actual Delay: %d", player->GetPrimaryWeaponDelay() * 0.1);
  8992. client->Message(0, "Proc Percent: %d%%", 0);
  8993. client->Message(0, "Procs Per Minute: %d", 0);
  8994. }
  8995. client->SimpleMessage(0, " ");
  8996. client->SimpleMessage(0, " ");
  8997. if (secondary) {
  8998. client->SimpleMessage(0, "Secondary:");
  8999. client->Message(0, "Name: %s", secondary->name.c_str());
  9000. client->Message(0, "Base Damage: %u - %u", secondary->weapon_info->damage_low3, secondary->weapon_info->damage_high3);
  9001. client->Message(0, "Actual Damage: %u - %u", player->GetSecondaryWeaponMinDamage(), player->GetSecondaryWeaponMaxDamage());
  9002. client->Message(0, "Actual Delay: %d", player->GetSecondaryWeaponDelay() * 0.1);
  9003. client->Message(0, "Proc Percent: %d%%", 0);
  9004. client->Message(0, "Procs Per Minute: %d", 0);
  9005. client->SimpleMessage(0, " ");
  9006. client->SimpleMessage(0, " ");
  9007. }
  9008. client->SimpleMessage(0, "Ranged:");
  9009. if (ranged) {
  9010. client->Message(0, "Name: %s", ranged->name.c_str());
  9011. client->Message(0, "Base Damage: %u - %u", ranged->ranged_info->weapon_info.damage_low3, ranged->ranged_info->weapon_info.damage_high3);
  9012. client->Message(0, "Actual Damage: %u - %u", player->GetRangedWeaponMinDamage(), player->GetRangedWeaponMaxDamage());
  9013. client->Message(0, "Actual Delay: %d", player->GetRangeWeaponDelay() * 0.1);
  9014. client->Message(0, "Proc Percent: %d%%", 0);
  9015. client->Message(0, "Procs Per Minute: %d", 0);
  9016. }
  9017. else
  9018. client->SimpleMessage(0, "None");
  9019. }
  9020. void Commands::Command_WhoChannel(Client *client, Seperator *sep) {
  9021. const char *channel_name;
  9022. if (sep == NULL || !sep->IsSet(0)) {
  9023. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /chatwho <channel name>");
  9024. return;
  9025. }
  9026. channel_name = sep->arg[0];
  9027. if (!chat.ChannelExists(channel_name))
  9028. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That channel does not exist!");
  9029. else
  9030. chat.SendChannelUserList(client, channel_name);
  9031. }
  9032. void Commands::Command_ZoneSafeCoords(Client *client, Seperator *sep)
  9033. {
  9034. ZoneServer* zone = 0;
  9035. int32 zone_id = client->GetPlayer()->GetZone()->GetZoneID();
  9036. if (zone_id > 0)
  9037. {
  9038. zone = zone_list.Get(zone_id, false);
  9039. if (zone)
  9040. {
  9041. zone->SetSafeX(client->GetPlayer()->GetX());
  9042. zone->SetSafeY(client->GetPlayer()->GetY());
  9043. zone->SetSafeZ(client->GetPlayer()->GetZ());
  9044. zone->SetSafeHeading(client->GetPlayer()->GetHeading());
  9045. if( database.SaveZoneSafeCoords(zone_id, zone->GetSafeX(), zone->GetSafeY(), zone->GetSafeZ(), zone->GetSafeHeading()) )
  9046. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Zone safe coordinates updated!");
  9047. else
  9048. client->SimpleMessage(CHANNEL_COLOR_RED, "FAILED to update zone safe coordinates!");
  9049. }
  9050. }
  9051. }
  9052. /*
  9053. Function:
  9054. Purpose :
  9055. Params :
  9056. Dev :
  9057. Example :
  9058. */
  9059. void Commands::Command_ZoneDetails(Client* client, Seperator* sep)
  9060. {
  9061. ZoneInfo* zone_info = new ZoneInfo;
  9062. if (sep && sep->arg[0])
  9063. {
  9064. if (sep->IsNumber(0))
  9065. zone_info->id = atoi(sep->arg[0]);
  9066. else
  9067. zone_info->id = database.GetZoneID(sep->arg[0]);
  9068. if (zone_info->id > 0)
  9069. {
  9070. database.LoadZoneInfo(zone_info);
  9071. 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);
  9072. 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);
  9073. 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);
  9074. 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);
  9075. 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);
  9076. 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);
  9077. 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);
  9078. client->Message(CHANNEL_COLOR_YELLOW, "zone_type: %s", zone_info->zone_type);
  9079. client->Message(CHANNEL_COLOR_YELLOW, "lua_script: %s", zone_info->lua_script);
  9080. client->Message(CHANNEL_COLOR_YELLOW, "zone_motd: %s", zone_info->zone_motd);
  9081. }
  9082. else
  9083. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  9084. }
  9085. else
  9086. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone details [zone id|zone name]");
  9087. safe_delete(zone_info);
  9088. }
  9089. /*
  9090. Function:
  9091. Purpose :
  9092. Params :
  9093. Dev :
  9094. Example :
  9095. */
  9096. void Commands::Command_ZoneSet(Client* client, Seperator* sep)
  9097. {
  9098. if (sep && sep->arg[0] && sep->arg[1] && sep->arg[2])
  9099. {
  9100. ZoneServer* zone = 0;
  9101. int32 zone_id = 0;
  9102. if (sep->IsNumber(0) && atoi(sep->arg[0]) > 0)
  9103. {
  9104. zone_id = atoi(sep->arg[0]);
  9105. zone = zone_list.Get(atoi(sep->arg[0]), false);
  9106. }
  9107. else
  9108. {
  9109. zone_id = database.GetZoneID(sep->arg[0]);
  9110. if (zone_id > 0)
  9111. zone = zone_list.Get(sep->arg[0], false);
  9112. }
  9113. if (zone_id > 0)
  9114. {
  9115. if (zone_set_values.count(string(sep->arg[1])) > 0)
  9116. SetZoneCommand(client, zone_id, zone, zone_set_values[sep->arg[1]], sep->arg[2]);
  9117. else
  9118. client->Message(CHANNEL_COLOR_YELLOW, "The attribute '%s' is not valid.", sep->arg[1]);
  9119. }
  9120. else
  9121. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  9122. }
  9123. else
  9124. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone set [zone id|zone name] [attribute] [value]");
  9125. }
  9126. void Commands::Command_Rain(Client* client, Seperator* sep) {
  9127. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  9128. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /rain <float>");
  9129. return;
  9130. }
  9131. client->Message(CHANNEL_COLOR_YELLOW,"Setting rain to %.2f", atof(sep->arg[0]));
  9132. client->GetCurrentZone()->SetRain(atof(sep->arg[0]));
  9133. client->GetCurrentZone()->SetCurrentWeather(atof(sep->arg[0]));
  9134. }
  9135. void Commands::Command_Wind(Client* client, Seperator* sep) {
  9136. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  9137. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /wind <float>");
  9138. return;
  9139. }
  9140. client->Message(CHANNEL_COLOR_YELLOW, "Setting wind to %.2f", atof(sep->arg[0]));
  9141. client->GetCurrentZone()->SetWind(atof(sep->arg[0]));
  9142. }
  9143. void Commands::Command_SendMerchantWindow(Client* client, Seperator* sep, bool sell) {
  9144. Spawn* spawn = client->GetPlayer()->GetTarget();
  9145. if(spawn) {
  9146. client->SetMerchantTransaction(spawn);
  9147. if (spawn->GetMerchantID() > 0 && spawn->IsClientInMerchantLevelRange(client)){
  9148. client->SendHailCommand(spawn);
  9149. //MerchantFactionMultiplier* multiplier = world.GetMerchantMultiplier(spawn->GetMerchantID());
  9150. //if(!multiplier || (multiplier && client->GetPlayer()->GetFactions()->GetFactionValue(multiplier->faction_id) >= multiplier->faction_min)){
  9151. client->SendBuyMerchantList(sell);
  9152. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY))
  9153. client->SendSellMerchantList(sell);
  9154. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY_BACK))
  9155. client->SendBuyBackList(sell);
  9156. PacketStruct* packet = configReader.getStruct("WS_UpdateMerchant", client->GetVersion());
  9157. if (packet) {
  9158. packet->setDataByName("spawn_id", 0xFFFFFFFF);
  9159. packet->setDataByName("type", 16);
  9160. EQ2Packet* outapp = packet->serialize();
  9161. if (outapp)
  9162. client->QueuePacket(outapp);
  9163. safe_delete(packet);
  9164. }
  9165. }
  9166. if (spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR)
  9167. client->SendRepairList();
  9168. }
  9169. // client->SimpleMessage(CHANNEL_COLOR_RED, "Your faction is too low to use this merchant.");
  9170. }
  9171. void Commands::Command_Weather(Client* client, Seperator* sep)
  9172. {
  9173. //PrintSep(sep, "Weather");
  9174. if( sep && sep->arg[0] )
  9175. {
  9176. ZoneServer* zsZone = client->GetCurrentZone();
  9177. const char* value = sep->arg[0];
  9178. // process single-param commands first
  9179. if( strncasecmp(value, "details", strlen(value)) == 0 )
  9180. {
  9181. client->Message(CHANNEL_COLOR_YELLOW, "Weather Details for zone %s: ", zsZone->GetZoneName());
  9182. client->Message(CHANNEL_COLOR_YELLOW, "enabled: %i, allowed: %i, type: %i, frequency: %u", zsZone->isWeatherEnabled(), zsZone->isWeatherAllowed(), zsZone->GetWeatherType(), zsZone->GetWeatherFrequency());
  9183. client->Message(CHANNEL_COLOR_YELLOW, "severity: %.2f = %.2f, current: %.2f", zsZone->GetWeatherMinSeverity(), zsZone->GetWeatherMaxSeverity(), zsZone->GetCurrentWeather());
  9184. client->Message(CHANNEL_COLOR_YELLOW, "pattern: %i, chance: %i, amount: %.2f, offset: %.2f", zsZone->GetWeatherPattern(), zsZone->GetWeatherChance(), zsZone->GetWeatherChangeAmount(), zsZone->GetWeatherDynamicOffset());
  9185. }
  9186. else if( strncasecmp(value, "process", strlen(value)) == 0 )
  9187. {
  9188. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  9189. zsZone->ProcessWeather();
  9190. }
  9191. else if( strncasecmp(value, "reset", strlen(value)) == 0 )
  9192. {
  9193. zsZone->SetWeatherType(rule_manager.GetGlobalRule(R_Zone, WeatherType)->GetInt8());
  9194. zsZone->SetWeatherFrequency(rule_manager.GetGlobalRule(R_Zone, WeatherChangeFrequency)->GetInt32());
  9195. zsZone->SetWeatherMinSeverity(rule_manager.GetGlobalRule(R_Zone, MinWeatherSeverity)->GetFloat());
  9196. zsZone->SetWeatherMaxSeverity(rule_manager.GetGlobalRule(R_Zone, MaxWeatherSeverity)->GetFloat());
  9197. zsZone->SetCurrentWeather(zsZone->GetWeatherMinSeverity());
  9198. zsZone->SetWeatherPattern(1);
  9199. zsZone->SetWeatherChance(rule_manager.GetGlobalRule(R_Zone, WeatherChangeChance)->GetInt8());
  9200. zsZone->SetWeatherChangeAmount(rule_manager.GetGlobalRule(R_Zone, WeatherChangePerInterval)->GetFloat());
  9201. zsZone->SetWeatherDynamicOffset(rule_manager.GetGlobalRule(R_Zone, WeatherDynamicMaxOffset)->GetFloat());
  9202. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  9203. zsZone->ProcessWeather();
  9204. }
  9205. // process commands with params
  9206. if( sep->arg[1] )
  9207. {
  9208. if( strncasecmp(value, "enable", strlen(value)) == 0 && sep->IsNumber(1) )
  9209. zsZone->SetWeatherEnabled( ( atoi(sep->arg[1]) == 1 ) ? true : false );
  9210. else if( strncasecmp(value, "type", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 3) )
  9211. zsZone->SetWeatherType(atoi(sep->arg[1]));
  9212. else if( strncasecmp(value, "frequency", strlen(value)) == 0 && sep->IsNumber(1))
  9213. zsZone->SetWeatherFrequency( atoul(sep->arg[1]) );
  9214. else if( strncasecmp(value, "range", strlen(value)) == 0 && sep->IsNumber(1) && sep->IsNumber(2) ) {
  9215. zsZone->SetWeatherMinSeverity(atof(sep->arg[1]));
  9216. zsZone->SetWeatherMaxSeverity(atof(sep->arg[2]));
  9217. zsZone->SetRain(zsZone->GetWeatherMinSeverity());
  9218. }
  9219. else if( strncasecmp(value, "current", strlen(value)) == 0 && sep->IsNumber(1) ) {
  9220. zsZone->SetCurrentWeather(atof(sep->arg[1]));
  9221. zsZone->SetRain(zsZone->GetCurrentWeather());
  9222. }
  9223. else if( strncasecmp(value, "pattern", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 2) )
  9224. zsZone->SetWeatherPattern( atoi(sep->arg[1]) );
  9225. else if( strncasecmp(value, "chance", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 100) )
  9226. zsZone->SetWeatherChance( atoi(sep->arg[1]) );
  9227. else if( strncasecmp(value, "amount", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  9228. zsZone->SetWeatherChangeAmount( atof(sep->arg[1]) );
  9229. else if( strncasecmp(value, "offset", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  9230. zsZone->SetWeatherDynamicOffset( atof(sep->arg[1]) );
  9231. }
  9232. }
  9233. else
  9234. {
  9235. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /weather [command] [param]");
  9236. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: enable (0|1), type (0-3), frequency (sec), range|current (0.0 - 1.0)");
  9237. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: details, process, pattern (0|1), chance (%), amount (float), offset (float)");
  9238. return;
  9239. }
  9240. }
  9241. void Commands::Command_Select(Client* client, Seperator* sep) {
  9242. if (sep && sep->arg[1]) {
  9243. Spawn* spawn = client->GetPlayer()->GetTarget();
  9244. if (spawn && strlen(sep->arg[1]) > 0)
  9245. client->GetCurrentZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_CUSTOM, client->GetPlayer(), sep->arg[1]);
  9246. }
  9247. }
  9248. /*
  9249. Function: Command_ConsumeFood()
  9250. Purpose : Consume Food/Drink and apply mods
  9251. Params : Slot ID - EQ2_FOOD_SLOT 22, EQ2_DRINK_SLOT 23
  9252. Dev : Zcoretri
  9253. Example : /consume_food 22
  9254. */
  9255. void Commands::Command_ConsumeFood(Client* client, Seperator* sep) {
  9256. if (sep && sep->arg[0] && sep->IsNumber(0))
  9257. {
  9258. Player* player = client->GetPlayer();
  9259. int8 slot = atoi(sep->arg[0]);
  9260. Item* item = player->GetEquipmentList()->GetItem(slot);
  9261. if(item) {
  9262. LogWrite(MISC__INFO, 1, "Command", "ItemID: %u, ItemName: %s ItemCount: %i ", item->details.item_id, item->name.c_str(), item->details.count);
  9263. if(item->GetItemScript() && lua_interface){
  9264. lua_interface->RunItemScript(item->GetItemScript(), "cast", item, client->GetPlayer());
  9265. if (slot == 22)
  9266. client->Message(CHANNEL_NARRATIVE, "You eat a %s.", item->name.c_str());
  9267. else
  9268. client->Message(CHANNEL_NARRATIVE, "You drink a %s.", item->name.c_str());
  9269. }
  9270. }
  9271. if (item->details.count > 1) {
  9272. item->details.count -= 1;
  9273. item->save_needed = true;
  9274. }
  9275. else {
  9276. player->GetEquipmentList()->RemoveItem(slot, true);
  9277. database.DeleteItem(player->GetCharacterID(), item, "EQUIPPED");
  9278. }
  9279. client->GetPlayer()->SetCharSheetChanged(true);
  9280. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  9281. }
  9282. }
  9283. void Commands::Command_Aquaman(Client* client, Seperator* sep) {
  9284. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  9285. if (atoi(sep->arg[0]) == 1) {
  9286. client->GetPlayer()->GetInfoStruct()->vision = 4;
  9287. client->GetPlayer()->GetInfoStruct()->breathe_underwater = 1;
  9288. client->GetPlayer()->SetCharSheetChanged(true);
  9289. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Maybe you ought to stick to the shallow end until you know how to swim.");
  9290. }
  9291. else {
  9292. client->GetPlayer()->GetInfoStruct()->vision = 0;
  9293. client->GetPlayer()->GetInfoStruct()->breathe_underwater = 0;
  9294. client->GetPlayer()->SetCharSheetChanged(true);
  9295. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Aquaman mode turned off.");
  9296. }
  9297. }
  9298. else
  9299. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /aquaman [0|1]");
  9300. }
  9301. void Commands::Command_ReportBug(Client* client, Seperator* sep)
  9302. {
  9303. if(sep)
  9304. {
  9305. string data;
  9306. if(sep->arg[0]){
  9307. data = string(sep->arg[0]);
  9308. }
  9309. for(int i=1;i<sep->GetMaxArgNum();i++){
  9310. if(sep->arg[i])
  9311. data.append(" ").append(sep->arg[i]);
  9312. }
  9313. const char* target_name = 0;
  9314. int32 spawn_id = 0;
  9315. if(client->GetPlayer()->GetTarget())
  9316. {
  9317. target_name = client->GetPlayer()->GetTarget()->GetName();
  9318. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  9319. }
  9320. else
  9321. target_name = "N/A";
  9322. LogWrite(COMMAND__DEBUG, 1, "Command", "%s", data.c_str());
  9323. if(world.ReportBug(data, client->GetPlayer()->GetName(), client->GetAccountID(), target_name, spawn_id, client->GetCurrentZone()->GetZoneID()))
  9324. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully submitted bug.");
  9325. else
  9326. client->SimpleMessage(CHANNEL_COLOR_RED, "Error submitting bug.");
  9327. }
  9328. }
  9329. void Commands::Command_Attune_Inv(Client* client, Seperator* sep) {
  9330. PrintSep(sep, "Command_Attune_Inv");
  9331. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  9332. // Get the item index from the first parameter
  9333. int16 index = atoi(sep->arg[0]);
  9334. // Check to see if this is a valid item index for the player, if not exit out of the function
  9335. if (client->GetPlayer()->item_list.indexed_items.count(index) == 0) {
  9336. LogWrite(ITEM__DEBUG, 0, "Items", "%s has no item with an index of %i", client->GetPlayer()->GetName(), index);
  9337. return;
  9338. }
  9339. // Get the item
  9340. Item* item = client->GetPlayer()->item_list.indexed_items[index];
  9341. if(item) {
  9342. // Valid item lets check to make sure this item is attunable, if not return out
  9343. if (!item->CheckFlag(ATTUNEABLE)) {
  9344. LogWrite(ITEM__DEBUG, 0, "Items", "attune_inv called for an item that is not attunable (%s)", item->name.c_str());
  9345. return;
  9346. }
  9347. // Remove the attunable flag
  9348. item->generic_info.item_flags -= ATTUNEABLE;
  9349. // Set the attuned flag
  9350. item->generic_info.item_flags += ATTUNED;
  9351. // Flag this item for saving
  9352. item->save_needed = true;
  9353. client->QueuePacket(item->serialize(client->GetVersion(), false, client->GetPlayer()));
  9354. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), -1);
  9355. EQ2Packet* outapp = 0;
  9356. for (int32 i=0;i<packets.size();i++) {
  9357. outapp = packets[i];
  9358. if(outapp)
  9359. client->QueuePacket(outapp);
  9360. }
  9361. }
  9362. }
  9363. }
  9364. void Commands::Command_Reset_Zone_Timer(Client* client, Seperator* sep) {
  9365. PrintSep(sep, "Command_Reset_Zone_Timer");
  9366. /*if (sep && sep->arg[0] && sep->IsNumber(0)) {
  9367. int32 db_id = atoul(sep->arg[0]);
  9368. InstanceData* data = client->GetPlayer()->GetCharacterInstances().FindInstanceByDBID(db_id);
  9369. if (data) {
  9370. // TODO: add a check to timers to ensure it can be reset
  9371. // Delete the character from the instance
  9372. database.DeleteCharacterFromInstance(client->GetPlayer()->GetCharacterID(), data->instance_id);
  9373. data->instance_id = 0;
  9374. // Update the success time and set to 0 so the player can enter it again
  9375. database.UpdateCharacterInstance(client->GetPlayer()->GetCharacterID(), data->zone_name, 0, 1, 0);
  9376. data->last_success_timestamp = 0;
  9377. }
  9378. }*/
  9379. }
  9380. void Commands::Command_Player(Client* client, Seperator* sep) {
  9381. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player syntax --");
  9382. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins");
  9383. }
  9384. void Commands::Command_Player_Coins(Client* client, Seperator* sep) {
  9385. // /player coins add 10
  9386. // /player coins add plat 10
  9387. Player* player = client->GetPlayer();
  9388. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  9389. player = (Player*)player->GetTarget();
  9390. if (sep && sep->arg[0] && sep->arg[1]) {
  9391. const char* action = sep->arg[0];
  9392. int64 value = 0;
  9393. if (strncasecmp(action, "add", strlen(action)) == 0) {
  9394. if (sep->IsNumber(1)) {
  9395. value = atoi64(sep->arg[1]);
  9396. player->AddCoins(value);
  9397. if (client->GetPlayer() == player)
  9398. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  9399. else {
  9400. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  9401. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  9402. }
  9403. return;
  9404. }
  9405. else if (sep->arg[2] && sep->IsNumber(2)) {
  9406. const char* type = sep->arg[1];
  9407. if (strncasecmp(type, "copper", strlen(type)) == 0) {
  9408. value = atoi64(sep->arg[2]);
  9409. }
  9410. else if (strncasecmp(type, "silver", strlen(type)) == 0) {
  9411. value = atoi64(sep->arg[2]) * 100;
  9412. }
  9413. else if (strncasecmp(type, "gold", strlen(type)) == 0) {
  9414. value = atoi64(sep->arg[2]) * 10000;
  9415. }
  9416. else if (strncasecmp(type, "plat", strlen(type)) == 0) {
  9417. value = atoi64(sep->arg[2]) * 1000000;
  9418. }
  9419. player->AddCoins(value);
  9420. if (client->GetPlayer() == player)
  9421. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  9422. else {
  9423. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  9424. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  9425. }
  9426. return;
  9427. }
  9428. }
  9429. }
  9430. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player coins syntax --");
  9431. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add [value] - adds the given number of coins to the player");
  9432. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add copper [value] - adds the given amount of copper to the player");
  9433. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add silver [value] - adds the given amount of silver to the player");
  9434. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add gold [value] - adds the given amount of gold to the player");
  9435. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add plat [value] - adds the given amount of platinum to the player");
  9436. }
  9437. void Commands::Command_AchievementAdd(Client* client, Seperator* sep) {
  9438. PrintSep(sep, "ACHIEVEMENT_ADD");
  9439. if (sep && sep->IsSet(0)) {
  9440. int32 spell_id = atoul(sep->arg[1]);
  9441. int8 spell_tier = 0;
  9442. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  9443. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  9444. // addspellbookentry here
  9445. if (spell_tier >= data->maxRank) {
  9446. return;
  9447. }
  9448. if (!spell_tier) {
  9449. spell_tier = 1;
  9450. }
  9451. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  9452. {
  9453. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  9454. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  9455. client->GetPlayer()->UnlockSpell(spell);
  9456. client->SendSpellUpdate(spell);
  9457. }
  9458. else
  9459. {
  9460. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1);
  9461. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  9462. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  9463. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  9464. client->GetPlayer()->UnlockSpell(spell);
  9465. client->SendSpellUpdate(spell);
  9466. }
  9467. // cast spell here
  9468. if (!spell_tier)
  9469. spell_tier = 1;
  9470. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  9471. if (spell) {
  9472. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  9473. }
  9474. }
  9475. else {
  9476. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  9477. }
  9478. master_aa_list.DisplayAA(client, 0, 0);
  9479. }
  9480. void Commands::Command_Editor(Client* client, Seperator* sep) {
  9481. PacketStruct* packet = configReader.getStruct("WS_ChoiceWindow", client->GetVersion());
  9482. if (packet) {
  9483. string url = string(rule_manager.GetGlobalRule(R_World, EditorURL)->GetString());
  9484. if (rule_manager.GetGlobalRule(R_World, EditorOfficialServer)->GetBool()) {
  9485. char command[255];
  9486. url = "browser " + url;
  9487. int32 spawn_id = 0;
  9488. int32 zone_id = 0;
  9489. string type;
  9490. if (client->GetCurrentZone())
  9491. zone_id = client->GetCurrentZone()->GetZoneID();
  9492. if (client->GetPlayer()->GetTarget()) {
  9493. Spawn* target = client->GetPlayer()->GetTarget();
  9494. if (target->IsWidget())
  9495. type = "widgets";
  9496. else if (target->IsSign())
  9497. type = "signs";
  9498. else if (target->IsObject())
  9499. type = "objects";
  9500. else if (target->IsNPC())
  9501. type = "npcs";
  9502. else if (target->IsGroundSpawn())
  9503. type = "ground";
  9504. else
  9505. type = "spawn";
  9506. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  9507. }
  9508. sprintf(command, url.c_str(), zone_id, type.c_str(), spawn_id);
  9509. packet->setDataByName("accept_command", command);
  9510. }
  9511. else if (rule_manager.GetGlobalRule(R_World, EditorIncludeID)->GetBool()) {
  9512. char command[255];
  9513. url = "browser " + url;
  9514. if (client->GetPlayer()->GetTarget())
  9515. sprintf(command, url.c_str(), client->GetPlayer()->GetTarget()->GetDatabaseID());
  9516. packet->setDataByName("accept_command", command);
  9517. }
  9518. else {
  9519. string command = "browser " + url;
  9520. packet->setDataByName("accept_command", command.c_str());
  9521. }
  9522. packet->setDataByName("text", "Open the web editor?");
  9523. packet->setDataByName("accept_text", "Open");
  9524. packet->setDataByName("cancel_text", "Cancel");
  9525. // No clue if we even need the following 2 unknowns, just added them so the packet matches what live sends
  9526. packet->setDataByName("unknown2", 50);
  9527. packet->setDataByName("unknown4", 1);
  9528. client->QueuePacket(packet->serialize());
  9529. safe_delete(packet);
  9530. }
  9531. }
  9532. void Commands::Command_AcceptResurrection(Client* client, Seperator* sep) {
  9533. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  9534. return;
  9535. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  9536. if(client->GetCurrentRez()->active)
  9537. client->AcceptResurrection();
  9538. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  9539. }
  9540. void Commands::Command_DeclineResurrection(Client* client, Seperator* sep) {
  9541. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  9542. return;
  9543. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  9544. if(client->GetCurrentRez()->active)
  9545. client->GetCurrentRez()->should_delete = true;
  9546. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  9547. }
  9548. void Commands::Switch_AA_Profile(Client* client, Seperator* sep) {
  9549. PrintSep(sep, "Switch_AA_Profile");
  9550. if (sep && sep->IsSet(0)) {
  9551. string type = sep->arg[0];
  9552. int8 newtemplate = atoul(sep->arg[1]);
  9553. master_aa_list.DisplayAA(client, newtemplate, 1);
  9554. }
  9555. }
  9556. void Commands::Get_AA_Xml(Client* client, Seperator* sep) {
  9557. PrintSep(sep, "Get_AA_Xml");
  9558. if (sep && sep->IsSet(0)) {
  9559. string tabnum = sep->arg[0];
  9560. string spellid = sep->arg[1];
  9561. }
  9562. }
  9563. void Commands::Add_AA(Client* client, Seperator* sep) {
  9564. PrintSep(sep, "Add_AA");
  9565. if (sep && sep->IsSet(0)) {
  9566. int32 spell_id = atoul(sep->arg[1]);
  9567. int8 spell_tier = 0;
  9568. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  9569. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  9570. // addspellbookentry here
  9571. if (spell_tier >= data->maxRank) {
  9572. return;
  9573. }
  9574. if (!spell_tier) {
  9575. spell_tier = 1;
  9576. }
  9577. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  9578. {
  9579. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  9580. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  9581. client->GetPlayer()->UnlockSpell(spell);
  9582. client->SendSpellUpdate(spell);
  9583. }
  9584. else
  9585. {
  9586. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1 );
  9587. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  9588. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  9589. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  9590. client->GetPlayer()->UnlockSpell(spell);
  9591. client->SendSpellUpdate(spell);
  9592. }
  9593. // cast spell here
  9594. if (!spell_tier)
  9595. spell_tier = 1;
  9596. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  9597. if (spell) {
  9598. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  9599. }
  9600. }
  9601. else {
  9602. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  9603. }
  9604. master_aa_list.DisplayAA(client, 0, 0);
  9605. }
  9606. void Commands::Commit_AA_Profile(Client* client, Seperator* sep) {
  9607. PrintSep(sep, "Commit_AA_Profile");
  9608. if (sep && sep->IsSet(0)) {
  9609. }
  9610. }
  9611. void Commands::Begin_AA_Profile(Client* client, Seperator* sep) {
  9612. PrintSep(sep, "Begin_AA_Profile");
  9613. if (sep && sep->IsSet(0)) {
  9614. master_aa_list.DisplayAA(client, 100, 2);
  9615. }
  9616. }
  9617. void Commands::Back_AA(Client* client, Seperator* sep) {
  9618. if (sep && sep->IsSet(0)) {
  9619. PrintSep(sep, "Back_AA");
  9620. }
  9621. }
  9622. void Commands::Remove_AA(Client* client, Seperator* sep) {
  9623. if (sep && sep->IsSet(0)) {
  9624. PrintSep(sep, "Remove_AA");
  9625. }
  9626. }
  9627. void Commands::Cancel_AA_Profile(Client* client, Seperator* sep) {
  9628. MasterAAList master_aa_list;
  9629. PrintSep(sep, "Cancel_AA_Profile");
  9630. master_aa_list.DisplayAA(client, 0, 0);
  9631. }
  9632. void Commands::Save_AA_Profile(Client* client, Seperator* sep) {
  9633. if (sep && sep->IsSet(0)) {
  9634. PrintSep(sep, "Save_AA_Profile");
  9635. }
  9636. }
  9637. void Commands::Command_TargetItem(Client* client, Seperator* sep) {
  9638. if (!sep || sep->GetArgNumber() < 1 || !client->GetPlayer()) return;
  9639. if (!sep->IsNumber(0)) return;
  9640. int32 request_id = atoul(sep->arg[0]);
  9641. if (!sep->IsNumber(1)) return;
  9642. sint32 item_id = atoi(sep->arg[1]);
  9643. if (client->IsCurrentTransmuteID(request_id)) {
  9644. Transmute::HandleItemResponse(client, client->GetPlayer(), request_id, reinterpret_cast<int32&>(item_id));
  9645. }
  9646. else if (client->IsCurrentTransmuteID(item_id)) {
  9647. if (!sep->IsSet(2)) return;
  9648. if (sep->IsNumber(2) && atoi(sep->arg[2]) == 1) {
  9649. Transmute::HandleConfirmResponse(client, client->GetPlayer(), reinterpret_cast<int32&>(item_id));
  9650. }
  9651. }
  9652. }
  9653. void Commands::Command_FindSpawn(Client* client, Seperator* sep) {
  9654. if(sep)
  9655. client->GetCurrentZone()->FindSpawn(client, (char*)sep->argplus[0]);
  9656. }