9
3

Commands.cpp 362 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122
  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. zone_set_values["expansion_id"] = ZONE_SET_VALUE_EXPANSION_ID;
  149. zone_set_values["name"] = ZONE_SET_VALUE_NAME;
  150. zone_set_values["file"] = ZONE_SET_VALUE_FILE ;
  151. zone_set_values["description"] = ZONE_SET_VALUE_DESCRIPTION;
  152. zone_set_values["safe_x"] = ZONE_SET_VALUE_SAFE_X;
  153. zone_set_values["safe_y"] = ZONE_SET_VALUE_SAFE_Y;
  154. zone_set_values["safe_z"] = ZONE_SET_VALUE_SAFE_Z;
  155. zone_set_values["underworld"] = ZONE_SET_VALUE_UNDERWORLD;
  156. zone_set_values["min_recommended"] = ZONE_SET_VALUE_MIN_RECOMMENDED;
  157. zone_set_values["max_recommended"] = ZONE_SET_VALUE_MAX_RECOMMENDED;
  158. zone_set_values["zone_type"] = ZONE_SET_VALUE_ZONE_TYPE;
  159. zone_set_values["always_loaded"] = ZONE_SET_VALUE_ALWAYS_LOADED;
  160. zone_set_values["city_zone"] = ZONE_SET_VALUE_CITY_ZONE;
  161. zone_set_values["weather_allowed"] = ZONE_SET_VALUE_WEATHER_ALLOWED;
  162. zone_set_values["min_status"] = ZONE_SET_VALUE_MIN_STATUS;
  163. zone_set_values["min_level"] = ZONE_SET_VALUE_MIN_LEVEL;
  164. zone_set_values["start_zone"] = ZONE_SET_VALUE_START_ZONE;
  165. zone_set_values["instance_type"] = ZONE_SET_VALUE_INSTANCE_TYPE;
  166. zone_set_values["default_reenter_time"] = ZONE_SET_VALUE_DEFAULT_REENTER_TIME;
  167. zone_set_values["default_reset_time"] = ZONE_SET_VALUE_DEFAULT_RESET_TIME;
  168. zone_set_values["default_lockout_time"] = ZONE_SET_VALUE_DEFAULT_LOCKOUT_TIME;
  169. zone_set_values["force_group_to_zone"] = ZONE_SET_VALUE_FORCE_GROUP_TO_ZONE;
  170. zone_set_values["lua_script"] = ZONE_SET_VALUE_LUA_SCRIPT;
  171. zone_set_values["shutdown_timer"] = ZONE_SET_VALUE_SHUTDOWN_TIMER;
  172. zone_set_values["zone_motd"] = ZONE_SET_VALUE_ZONE_MOTD;
  173. }
  174. Commands::~Commands() {
  175. safe_delete(remote_commands);
  176. }
  177. int32 Commands::GetSpawnSetType(string val){
  178. if(spawn_set_values.count(val) > 0)
  179. return spawn_set_values[val];
  180. return 0xFFFFFFFF;
  181. }
  182. bool Commands::SetSpawnCommand(Client* client, Spawn* target, int8 type, const char* value, bool send_update, bool temporary, string* temp_value){
  183. if(!target)
  184. return false;
  185. int32 val = 0;
  186. try{
  187. if(type != SPAWN_SET_VALUE_NAME && !(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))
  188. val = atoul(value);
  189. }
  190. catch(...){
  191. if(client)
  192. client->Message(CHANNEL_COLOR_RED, "Invalid numeric spawn value: %s", value);
  193. return false;
  194. }
  195. if(temporary && temp_value){
  196. char tmp[128] = {0};
  197. switch(type){
  198. case SPAWN_SET_VALUE_NAME:{
  199. sprintf(tmp, "%s", target->GetName());
  200. target->SetName(value);
  201. client->GetCurrentZone()->SendUpdateTitles(target);
  202. break;
  203. }
  204. case SPAWN_SET_VALUE_X_OFFSET:
  205. {
  206. sprintf(tmp, "%f", target->GetXOffset());
  207. target->SetXOffset(float(val));
  208. break;
  209. }
  210. case SPAWN_SET_VALUE_Y_OFFSET:
  211. {
  212. sprintf(tmp, "%f", target->GetYOffset());
  213. target->SetYOffset(float(val));
  214. break;
  215. }
  216. case SPAWN_SET_VALUE_Z_OFFSET:
  217. {
  218. sprintf(tmp, "%f", target->GetZOffset());
  219. target->SetZOffset(float(val));
  220. break;
  221. }
  222. case SPAWN_SET_VALUE_EXPIRE: {
  223. sprintf(tmp, "%u", target->GetExpireTime());
  224. target->SetExpireTime(val);
  225. break;
  226. }
  227. case SPAWN_SET_VALUE_EXPIRE_OFFSET: {
  228. sprintf(tmp, "%u", target->GetExpireOffsetTime());
  229. target->SetExpireOffsetTime(val);
  230. break;
  231. }
  232. case SPAWN_SET_VALUE_SUB_TITLE: {
  233. sprintf(tmp, "%s", target->GetSubTitle());
  234. target->SetSubTitle(value);
  235. client->GetCurrentZone()->SendUpdateTitles(target);
  236. break;
  237. }
  238. case SPAWN_SET_VALUE_LEVEL:{
  239. sprintf(tmp, "%i", target->GetLevel());
  240. target->SetLevel(val, send_update);
  241. break;
  242. }
  243. case SPAWN_SET_VALUE_DIFFICULTY:{
  244. sprintf(tmp, "%i", target->GetEncounterLevel());
  245. target->SetEncounterLevel(val, send_update);
  246. break;
  247. }
  248. case SPAWN_SET_VALUE_MODEL_TYPE:{
  249. sprintf(tmp, "%i", target->GetModelType());
  250. target->SetModelType(val, send_update);
  251. break;
  252. }
  253. case SPAWN_SET_VALUE_CLASS:{
  254. sprintf(tmp, "%i", target->GetAdventureClass());
  255. target->SetAdventureClass(val, send_update);
  256. break;
  257. }
  258. case SPAWN_SET_VALUE_GENDER:{
  259. sprintf(tmp, "%i", target->GetGender());
  260. target->SetGender(val, send_update);
  261. break;
  262. }
  263. case SPAWN_SET_VALUE_SHOW_NAME:{
  264. sprintf(tmp, "%i", target->GetShowName());
  265. target->SetShowName(val, send_update);
  266. break;
  267. }
  268. case SPAWN_SET_VALUE_ATTACKABLE:{
  269. sprintf(tmp, "%i", target->GetAttackable());
  270. target->SetAttackable(val, send_update);
  271. break;
  272. }
  273. case SPAWN_SET_VALUE_SHOW_LEVEL:{
  274. sprintf(tmp, "%i", target->GetShowLevel());
  275. target->SetShowLevel(val, send_update);
  276. break;
  277. }
  278. case SPAWN_SET_VALUE_TARGETABLE:{
  279. sprintf(tmp, "%i", target->GetTargetable());
  280. target->SetTargetable(val, send_update);
  281. break;
  282. }
  283. case SPAWN_SET_VALUE_SHOW_COMMAND_ICON:{
  284. sprintf(tmp, "%i", target->GetShowCommandIcon());
  285. target->SetShowCommandIcon(val, send_update);
  286. break;
  287. }
  288. case SPAWN_SET_VALUE_HAND_ICON:{
  289. sprintf(tmp, "%i", target->GetShowHandIcon());
  290. target->SetShowHandIcon(val, send_update);
  291. break;
  292. }
  293. case SPAWN_SET_VALUE_HAIR_TYPE:{
  294. if(target->IsEntity()){
  295. sprintf(tmp, "%i", ((Entity*)target)->GetHairType());
  296. ((Entity*)target)->SetHairType(val, send_update);
  297. }
  298. break;
  299. }
  300. case SPAWN_SET_VALUE_FACIAL_HAIR_TYPE:{
  301. if(target->IsEntity()){
  302. sprintf(tmp, "%i", ((Entity*)target)->GetHairType());
  303. ((Entity*)target)->SetHairType(val, send_update);
  304. }
  305. break;
  306. }
  307. case SPAWN_SET_VALUE_WING_TYPE:{
  308. if(target->IsEntity()){
  309. sprintf(tmp, "%i", ((Entity*)target)->GetWingType());
  310. ((Entity*)target)->SetWingType(val, send_update);
  311. }
  312. break;
  313. }
  314. case SPAWN_SET_VALUE_CHEST_TYPE:{
  315. if(target->IsEntity()){
  316. sprintf(tmp, "%i", ((Entity*)target)->GetChestType());
  317. ((Entity*)target)->SetChestType(val, send_update);
  318. }
  319. break;
  320. }
  321. case SPAWN_SET_VALUE_LEGS_TYPE:{
  322. if(target->IsEntity()){
  323. sprintf(tmp, "%i", ((Entity*)target)->GetLegsType());
  324. ((Entity*)target)->SetLegsType(val, send_update);
  325. }
  326. break;
  327. }
  328. case SPAWN_SET_VALUE_SOGA_HAIR_TYPE:{
  329. if(target->IsEntity()){
  330. sprintf(tmp, "%i", ((Entity*)target)->GetSogaHairType());
  331. ((Entity*)target)->SetSogaHairType(val, send_update);
  332. }
  333. break;
  334. }
  335. case SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE:{
  336. if(target->IsEntity()){
  337. sprintf(tmp, "%i", ((Entity*)target)->GetSogaFacialHairType());
  338. ((Entity*)target)->SetSogaFacialHairType(val, send_update);
  339. }
  340. break;
  341. }
  342. case SPAWN_SET_VALUE_SOGA_MODEL_TYPE:{
  343. sprintf(tmp, "%i", target->GetSogaModelType());
  344. target->SetSogaModelType(val, send_update);
  345. break;
  346. }
  347. case SPAWN_SET_VALUE_SIZE:{
  348. sprintf(tmp, "%i", target->GetSize());
  349. target->SetSize(val, send_update);
  350. break;
  351. }
  352. case SPAWN_SET_VALUE_HP:{
  353. sprintf(tmp, "%i", target->GetHP());
  354. target->SetHP(val, send_update);
  355. break;
  356. }
  357. case SPAWN_SET_VALUE_POWER:{
  358. sprintf(tmp, "%i", target->GetPower());
  359. target->SetPower(val, send_update);
  360. break;
  361. }
  362. case SPAWN_SET_VALUE_HEROIC:{
  363. sprintf(tmp, "%i", target->GetHeroic());
  364. target->SetHeroic(val, send_update);
  365. break;
  366. }
  367. case SPAWN_SET_VALUE_RESPAWN:{
  368. sprintf(tmp, "%u", target->GetRespawnTime());
  369. target->SetRespawnTime(val);
  370. break;
  371. }
  372. case SPAWN_SET_VALUE_X:{
  373. sprintf(tmp, "%f", target->GetX());
  374. target->SetX(atof(value), send_update);
  375. break;
  376. }
  377. case SPAWN_SET_VALUE_Y:{
  378. sprintf(tmp, "%f", target->GetY());
  379. target->SetY(atof(value), send_update);
  380. break;
  381. }
  382. case SPAWN_SET_VALUE_Z:{
  383. sprintf(tmp, "%f", target->GetZ());
  384. target->SetZ(atof(value), send_update);
  385. break;
  386. }
  387. case SPAWN_SET_VALUE_HEADING:{
  388. sprintf(tmp, "%f", target->GetHeading());
  389. target->SetHeading(atof(value) + 360, send_update);
  390. break;
  391. }
  392. case SPAWN_SET_VALUE_VISUAL_STATE:{
  393. sprintf(tmp, "%i", target->GetVisualState());
  394. target->SetVisualState(val, send_update);
  395. break;
  396. }
  397. case SPAWN_SET_VALUE_ACTION_STATE:{
  398. sprintf(tmp, "%i", target->GetActionState());
  399. target->SetActionState(val, send_update);
  400. break;
  401. }
  402. case SPAWN_SET_VALUE_MOOD_STATE:{
  403. sprintf(tmp, "%i", target->GetMoodState());
  404. target->SetMoodState(val, send_update);
  405. break;
  406. }
  407. case SPAWN_SET_VALUE_INITIAL_STATE:{
  408. sprintf(tmp, "%i", target->GetInitialState());
  409. target->SetInitialState(val, send_update);
  410. break;
  411. }
  412. case SPAWN_SET_VALUE_ACTIVITY_STATE:{
  413. sprintf(tmp, "%i", target->GetActivityStatus());
  414. target->SetActivityStatus(val, send_update);
  415. break;
  416. }
  417. case SPAWN_SET_VALUE_COLLISION_RADIUS:{
  418. sprintf(tmp, "%i", target->GetCollisionRadius());
  419. target->SetCollisionRadius(val, send_update);
  420. break;
  421. }
  422. case SPAWN_SET_VALUE_DEVICE_ID: {
  423. if (target->IsObject()) {
  424. sprintf(tmp, "%i", ((Object*)target)->GetDeviceID());
  425. ((Object*)target)->SetDeviceID(val);
  426. }
  427. break;
  428. }
  429. case SPAWN_SET_VALUE_PITCH: {
  430. sprintf(tmp, "%f", target->GetPitch());
  431. target->SetPitch(atof(value), send_update);
  432. break;
  433. }
  434. case SPAWN_SET_VALUE_ROLL: {
  435. sprintf(tmp, "%f", target->GetRoll());
  436. target->SetRoll(atof(value), send_update);
  437. break;
  438. }
  439. case SPAWN_SET_VALUE_HIDE_HOOD: {
  440. sprintf(tmp, "%i", target->appearance.hide_hood);
  441. target->SetHideHood(val);
  442. break;
  443. }
  444. case SPAWN_SET_VALUE_EMOTE_STATE: {
  445. sprintf(tmp, "%i", target->appearance.emote_state);
  446. target->SetEmoteState(val);
  447. break;
  448. }
  449. case SPAWN_SET_VALUE_ICON: {
  450. sprintf(tmp, "%i", target->GetIconValue());
  451. target->SetIcon(val);
  452. break;
  453. }
  454. case SPAWN_SET_VALUE_PREFIX: {
  455. sprintf(tmp, "%s", target->GetPrefixTitle());
  456. target->SetPrefixTitle(value);
  457. client->GetCurrentZone()->SendUpdateTitles(target);
  458. break;
  459. }
  460. case SPAWN_SET_VALUE_SUFFIX: {
  461. sprintf(tmp, "%s", target->GetSuffixTitle());
  462. target->SetSuffixTitle(value);
  463. client->GetCurrentZone()->SendUpdateTitles(target);
  464. break;
  465. }
  466. case SPAWN_SET_VALUE_LASTNAME: {
  467. sprintf(tmp, "%s", target->GetLastName());
  468. target->SetLastName(value);
  469. client->GetCurrentZone()->SendUpdateTitles(target);
  470. break;
  471. }
  472. case SPAWN_SET_VALUE_EXPANSION_FLAG:
  473. case SPAWN_SET_VALUE_HOLIDAY_FLAG: {
  474. // nothing to do must reload spawns
  475. break;
  476. }
  477. case SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL: {
  478. sprintf(tmp, "%i", target->GetMerchantMinLevel());
  479. target->SetMerchantLevelRange(atoul(value), target->GetMerchantMaxLevel());
  480. break;
  481. }
  482. case SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL: {
  483. sprintf(tmp, "%i", target->GetMerchantMaxLevel());
  484. target->SetMerchantLevelRange(target->GetMerchantMinLevel(), atoul(value));
  485. break;
  486. }
  487. *temp_value = string(tmp);
  488. }
  489. }
  490. else{
  491. switch(type){
  492. case SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL: {
  493. target->SetMerchantLevelRange(atoul(value), target->GetMerchantMaxLevel());
  494. break;
  495. }
  496. case SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL: {
  497. target->SetMerchantLevelRange(target->GetMerchantMinLevel(), atoul(value));
  498. break;
  499. }
  500. case SPAWN_SET_VALUE_EXPANSION_FLAG: {
  501. if (target->GetDatabaseID() > 0)
  502. {
  503. char query[256];
  504. snprintf(query, 256, "update spawn set expansion_flag=%i where id=%i", atoul(value), target->GetDatabaseID());
  505. if (database.RunQuery(query, strnlen(query, 256)))
  506. {
  507. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  508. }
  509. }
  510. break;
  511. }
  512. case SPAWN_SET_VALUE_HOLIDAY_FLAG: {
  513. if (target->GetDatabaseID() > 0)
  514. {
  515. char query[256];
  516. snprintf(query, 256, "update spawn set holiday_flag=%i where id=%i", atoul(value), target->GetDatabaseID());
  517. if (database.RunQuery(query, strnlen(query, 256)))
  518. {
  519. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  520. }
  521. }
  522. break;
  523. }
  524. case SPAWN_SET_VALUE_NAME:{
  525. target->SetName(value);
  526. client->GetCurrentZone()->SendUpdateTitles(target);
  527. break;
  528. }
  529. case SPAWN_SET_VALUE_SUB_TITLE: {
  530. target->SetSubTitle(value);
  531. client->GetCurrentZone()->SendUpdateTitles(target);
  532. break;
  533. }
  534. case SPAWN_SET_VALUE_X_OFFSET:
  535. {
  536. target->SetXOffset(atof(value));
  537. break;
  538. }
  539. case SPAWN_SET_VALUE_Y_OFFSET:
  540. {
  541. target->SetYOffset(atof(value));
  542. break;
  543. }
  544. case SPAWN_SET_VALUE_Z_OFFSET:
  545. {
  546. target->SetZOffset(atof(value));
  547. break;
  548. }
  549. case SPAWN_SET_VALUE_EXPIRE: {
  550. target->SetExpireTime(val);
  551. break;
  552. }
  553. case SPAWN_SET_VALUE_EXPIRE_OFFSET: {
  554. target->SetExpireOffsetTime(val);
  555. break;
  556. }
  557. case SPAWN_SET_VALUE_LEVEL:{
  558. target->SetLevel(val, send_update);
  559. break;
  560. }
  561. case SPAWN_SET_VALUE_DIFFICULTY:{
  562. target->SetEncounterLevel(val, send_update);
  563. break;
  564. }
  565. case SPAWN_SET_VALUE_MODEL_TYPE:{
  566. target->SetModelType(val, send_update);
  567. break;
  568. }
  569. case SPAWN_SET_VALUE_CLASS:{
  570. target->SetAdventureClass(val, send_update);
  571. break;
  572. }
  573. case SPAWN_SET_VALUE_GENDER:{
  574. target->SetGender(val, send_update);
  575. break;
  576. }
  577. case SPAWN_SET_VALUE_SHOW_NAME:{
  578. target->SetShowName(val, send_update);
  579. break;
  580. }
  581. case SPAWN_SET_VALUE_ATTACKABLE:{
  582. target->SetAttackable(val, send_update);
  583. break;
  584. }
  585. case SPAWN_SET_VALUE_SHOW_LEVEL:{
  586. target->SetShowLevel(val, send_update);
  587. break;
  588. }
  589. case SPAWN_SET_VALUE_TARGETABLE:{
  590. target->SetTargetable(val, send_update);
  591. break;
  592. }
  593. case SPAWN_SET_VALUE_SHOW_COMMAND_ICON:{
  594. target->SetShowCommandIcon(val, send_update);
  595. break;
  596. }
  597. case SPAWN_SET_VALUE_HAND_ICON:{
  598. target->SetShowHandIcon(val, send_update);
  599. break;
  600. }
  601. case SPAWN_SET_VALUE_HAIR_TYPE:{
  602. if(target->IsEntity())
  603. ((Entity*)target)->SetHairType(val, send_update);
  604. break;
  605. }
  606. case SPAWN_SET_VALUE_FACIAL_HAIR_TYPE:{
  607. if(target->IsEntity())
  608. ((Entity*)target)->SetHairType(val, send_update);
  609. break;
  610. }
  611. case SPAWN_SET_VALUE_WING_TYPE:{
  612. if(target->IsEntity())
  613. ((Entity*)target)->SetWingType(val, send_update);
  614. break;
  615. }
  616. case SPAWN_SET_VALUE_CHEST_TYPE:{
  617. if(target->IsEntity())
  618. ((Entity*)target)->SetChestType(val, send_update);
  619. break;
  620. }
  621. case SPAWN_SET_VALUE_LEGS_TYPE:{
  622. if(target->IsEntity())
  623. ((Entity*)target)->SetLegsType(val, send_update);
  624. break;
  625. }
  626. case SPAWN_SET_VALUE_SOGA_HAIR_TYPE:{
  627. if(target->IsEntity())
  628. ((Entity*)target)->SetSogaHairType(val, send_update);
  629. break;
  630. }
  631. case SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE:{
  632. if(target->IsEntity())
  633. ((Entity*)target)->SetSogaFacialHairType(val, send_update);
  634. break;
  635. }
  636. case SPAWN_SET_VALUE_SOGA_MODEL_TYPE:{
  637. target->SetSogaModelType(val, send_update);
  638. break;
  639. }
  640. case SPAWN_SET_VALUE_SIZE:{
  641. target->SetSize(val, send_update);
  642. break;
  643. }
  644. case SPAWN_SET_VALUE_HP:{
  645. target->SetHP(val, send_update);
  646. break;
  647. }
  648. case SPAWN_SET_VALUE_POWER:{
  649. target->SetPower(val, send_update);
  650. break;
  651. }
  652. case SPAWN_SET_VALUE_HEROIC:{
  653. target->SetHeroic(val, send_update);
  654. break;
  655. }
  656. case SPAWN_SET_VALUE_RESPAWN:{
  657. target->SetRespawnTime(val);
  658. break;
  659. }
  660. case SPAWN_SET_VALUE_X:{
  661. target->SetX(atof(value), send_update);
  662. target->SetSpawnOrigX(target->GetX());
  663. break;
  664. }
  665. case SPAWN_SET_VALUE_Y:{
  666. target->SetY(atof(value), send_update);
  667. target->SetSpawnOrigY(target->GetY());
  668. break;
  669. }
  670. case SPAWN_SET_VALUE_Z:{
  671. target->SetZ(atof(value), send_update);
  672. target->SetSpawnOrigZ(target->GetZ());
  673. break;
  674. }
  675. case SPAWN_SET_VALUE_HEADING:{
  676. target->SetHeading(atof(value), send_update);
  677. target->SetSpawnOrigHeading(target->GetHeading());
  678. break;
  679. }
  680. case SPAWN_SET_VALUE_COMMAND_PRIMARY:{
  681. ZoneServer* zone = target->GetZone();
  682. if (!zone)
  683. zone = client->GetCurrentZone();
  684. if(zone->GetEntityCommandList(val))
  685. target->SetPrimaryCommands(zone->GetEntityCommandList(val));
  686. target->primary_command_list_id = val;
  687. break;
  688. }
  689. case SPAWN_SET_VALUE_COMMAND_SECONDARY:{
  690. ZoneServer* zone = target->GetZone();
  691. if (!zone)
  692. zone = client->GetCurrentZone();
  693. if (zone->GetEntityCommandList(val))
  694. target->SetSecondaryCommands(zone->GetEntityCommandList(val));
  695. target->secondary_command_list_id = val;
  696. break;
  697. }
  698. case SPAWN_SET_VALUE_VISUAL_STATE:{
  699. target->SetVisualState(val, send_update);
  700. break;
  701. }
  702. case SPAWN_SET_VALUE_ACTION_STATE:{
  703. target->SetActionState(val, send_update);
  704. break;
  705. }
  706. case SPAWN_SET_VALUE_MOOD_STATE:{
  707. target->SetMoodState(val, send_update);
  708. break;
  709. }
  710. case SPAWN_SET_VALUE_INITIAL_STATE:{
  711. target->SetInitialState(val, send_update);
  712. break;
  713. }
  714. case SPAWN_SET_VALUE_ACTIVITY_STATE:{
  715. target->SetActivityStatus(val, send_update);
  716. break;
  717. }
  718. case SPAWN_SET_VALUE_COLLISION_RADIUS:{
  719. target->SetCollisionRadius(val, send_update);
  720. break;
  721. }
  722. case SPAWN_SET_VALUE_FACTION:{
  723. ZoneServer* zone = target->GetZone();
  724. if (!zone)
  725. zone = client->GetCurrentZone();
  726. target->faction_id = val;
  727. zone->RemoveDeadEnemyList(target);
  728. if(target->IsNPC())
  729. zone->AddEnemyList((NPC*)target);
  730. break;
  731. }
  732. case SPAWN_SET_VALUE_DEVICE_ID:{
  733. if (target->IsObject())
  734. ((Object*)target)->SetDeviceID(val);
  735. break;
  736. }
  737. case SPAWN_SET_VALUE_PITCH: {
  738. target->SetPitch(atof(value), send_update);
  739. target->SetSpawnOrigPitch(atof(value));
  740. break;
  741. }
  742. case SPAWN_SET_VALUE_ROLL: {
  743. target->SetRoll(atof(value), send_update);
  744. target->SetSpawnOrigRoll(atof(value));
  745. break;
  746. }
  747. case SPAWN_SET_VALUE_HIDE_HOOD: {
  748. target->SetHideHood(val);
  749. break;
  750. }
  751. case SPAWN_SET_VALUE_EMOTE_STATE: {
  752. target->SetEmoteState(val);
  753. break;
  754. }
  755. case SPAWN_SET_VALUE_ICON: {
  756. target->SetIcon(val);
  757. break;
  758. }
  759. case SPAWN_SET_VALUE_PREFIX: {
  760. target->SetPrefixTitle(value);
  761. client->GetCurrentZone()->SendUpdateTitles(target);
  762. break;
  763. }
  764. case SPAWN_SET_VALUE_SUFFIX: {
  765. target->SetSuffixTitle(value);
  766. client->GetCurrentZone()->SendUpdateTitles(target);
  767. break;
  768. }
  769. case SPAWN_SET_VALUE_LASTNAME: {
  770. target->SetLastName(value);
  771. client->GetCurrentZone()->SendUpdateTitles(target);
  772. break;
  773. }
  774. case SPAWN_SET_VALUE_SPAWN_SCRIPT:{
  775. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  776. if(client){
  777. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  778. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawn_script 'SpawnScripts/example.lua'");
  779. }
  780. return false;
  781. }
  782. else if(!database.UpdateSpawnScriptData(target->GetDatabaseID(), 0, 0, value))
  783. return false;
  784. else{
  785. if(!world.GetSpawnLocationScript(target->GetSpawnLocationID()))
  786. target->SetSpawnScript(value);
  787. }
  788. break;
  789. }
  790. case SPAWN_SET_VALUE_SPAWNLOCATION_SCRIPT:{
  791. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  792. if(client){
  793. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  794. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawnlocation_script 'SpawnScripts/example.lua'");
  795. }
  796. return false;
  797. }
  798. else if(!database.UpdateSpawnScriptData(0, target->GetSpawnLocationID(), 0, value))
  799. return false;
  800. else{
  801. if(!world.GetSpawnEntryScript(target->GetSpawnEntryID()))
  802. target->SetSpawnScript(value);
  803. }
  804. break;
  805. }
  806. case SPAWN_SET_VALUE_SPAWNENTRY_SCRIPT:{
  807. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  808. if(client){
  809. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  810. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawnentry_script 'SpawnScripts/example.lua'");
  811. }
  812. return false;
  813. }
  814. else if(!database.UpdateSpawnScriptData(0, 0, target->GetSpawnEntryID(), value))
  815. return false;
  816. else
  817. target->SetSpawnScript(value);
  818. break;
  819. }
  820. }
  821. }
  822. return true;
  823. }
  824. /* The zone object will be NULL if the zone is not currently running. We pass both of these in so we can update
  825. the database fields always and also update the zone in memory if it's running. */
  826. bool Commands::SetZoneCommand(Client* client, int32 zone_id, ZoneServer* zone, int8 type, const char* value) {
  827. if (client && zone_id > 0 && type > 0 && value) {
  828. sint32 int_value = 0;
  829. float float_value = 0;
  830. if (type == ZONE_SET_VALUE_SAFE_X || type == ZONE_SET_VALUE_SAFE_Y || type == ZONE_SET_VALUE_SAFE_Z || type == ZONE_SET_VALUE_UNDERWORLD) {
  831. try {
  832. float_value = atof(value);
  833. }
  834. catch (...) {
  835. client->Message(CHANNEL_COLOR_RED, "Error converting '%s' to a float value", value);
  836. return false;
  837. }
  838. }
  839. 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) {
  840. try {
  841. int_value = atoi(value);
  842. }
  843. catch (...) {
  844. client->Message(CHANNEL_COLOR_RED, "Error converting '%s' to an integer value", value);
  845. return false;
  846. }
  847. }
  848. switch (type) {
  849. case ZONE_SET_VALUE_EXPANSION_ID: {
  850. break;
  851. }
  852. case ZONE_SET_VALUE_NAME: {
  853. if (zone)
  854. zone->SetZoneName(const_cast<char*>(value));
  855. database.SaveZoneInfo(zone_id, "name", value);
  856. break;
  857. }
  858. case ZONE_SET_VALUE_FILE: {
  859. if (zone)
  860. zone->SetZoneFile(const_cast<char*>(value));
  861. database.SaveZoneInfo(zone_id, "file", value);
  862. break;
  863. }
  864. case ZONE_SET_VALUE_DESCRIPTION: {
  865. if (zone)
  866. zone->SetZoneDescription(const_cast<char*>(value));
  867. database.SaveZoneInfo(zone_id, "description", value);
  868. break;
  869. }
  870. case ZONE_SET_VALUE_SAFE_X: {
  871. if (zone)
  872. zone->SetSafeX(float_value);
  873. database.SaveZoneInfo(zone_id, "safe_x", float_value);
  874. break;
  875. }
  876. case ZONE_SET_VALUE_SAFE_Y: {
  877. if (zone)
  878. zone->SetSafeY(float_value);
  879. database.SaveZoneInfo(zone_id, "safe_y", float_value);
  880. break;
  881. }
  882. case ZONE_SET_VALUE_SAFE_Z: {
  883. if (zone)
  884. zone->SetSafeZ(float_value);
  885. database.SaveZoneInfo(zone_id, "safe_z", float_value);
  886. break;
  887. }
  888. case ZONE_SET_VALUE_UNDERWORLD: {
  889. if (zone)
  890. zone->SetUnderWorld(float_value);
  891. database.SaveZoneInfo(zone_id, "underworld", float_value);
  892. break;
  893. }
  894. case ZONE_SET_VALUE_MIN_RECOMMENDED: {
  895. break;
  896. }
  897. case ZONE_SET_VALUE_MAX_RECOMMENDED: {
  898. break;
  899. }
  900. case ZONE_SET_VALUE_ZONE_TYPE: {
  901. break;
  902. }
  903. case ZONE_SET_VALUE_ALWAYS_LOADED: {
  904. if (zone)
  905. zone->SetAlwaysLoaded(int_value == 1);
  906. database.SaveZoneInfo(zone_id, "always_loaded", int_value);
  907. break;
  908. }
  909. case ZONE_SET_VALUE_CITY_ZONE: {
  910. if (zone)
  911. zone->SetCityZone(int_value == 1);
  912. database.SaveZoneInfo(zone_id, "city_zone", int_value);
  913. break;
  914. }
  915. case ZONE_SET_VALUE_WEATHER_ALLOWED: {
  916. if (zone)
  917. zone->SetWeatherAllowed(int_value == 1);
  918. database.SaveZoneInfo(zone_id, "weather_allowed", int_value);
  919. break;
  920. }
  921. case ZONE_SET_VALUE_MIN_STATUS: {
  922. if (zone)
  923. zone->SetMinimumStatus(int_value);
  924. database.SaveZoneInfo(zone_id, "min_status", int_value);
  925. break;
  926. }
  927. case ZONE_SET_VALUE_MIN_LEVEL: {
  928. if (zone)
  929. zone->SetMinimumLevel(int_value);
  930. database.SaveZoneInfo(zone_id, "min_level", int_value);
  931. break;
  932. }
  933. case ZONE_SET_VALUE_MAX_LEVEL: {
  934. if (zone)
  935. zone->SetMaximumLevel(int_value);
  936. database.SaveZoneInfo(zone_id, "max_level", int_value);
  937. break;
  938. }
  939. case ZONE_SET_VALUE_START_ZONE: {
  940. database.SaveZoneInfo(zone_id, "start_zone", int_value);
  941. break;
  942. }
  943. case ZONE_SET_VALUE_INSTANCE_TYPE: {
  944. if (zone)
  945. zone->SetInstanceType(int_value);
  946. database.SaveZoneInfo(zone_id, "instance_type", int_value);
  947. break;
  948. }
  949. case ZONE_SET_VALUE_DEFAULT_REENTER_TIME: {
  950. if (zone)
  951. zone->SetDefaultReenterTime(int_value);
  952. database.SaveZoneInfo(zone_id, "default_reenter_time", int_value);
  953. break;
  954. }
  955. case ZONE_SET_VALUE_DEFAULT_RESET_TIME: {
  956. if (zone)
  957. zone->SetDefaultResetTime(int_value);
  958. database.SaveZoneInfo(zone_id, "default_reset_time", int_value);
  959. break;
  960. }
  961. case ZONE_SET_VALUE_DEFAULT_LOCKOUT_TIME: {
  962. if (zone)
  963. zone->SetDefaultLockoutTime(int_value);
  964. database.SaveZoneInfo(zone_id, "default_lockout_time", int_value);
  965. break;
  966. }
  967. case ZONE_SET_VALUE_FORCE_GROUP_TO_ZONE: {
  968. if (zone)
  969. zone->SetForceGroupZoneOption(int_value);
  970. database.SaveZoneInfo(zone_id, "force_group_to_zone", int_value);
  971. break;
  972. }
  973. case ZONE_SET_VALUE_LUA_SCRIPT: {
  974. if (lua_interface && lua_interface->GetZoneScript(value) == 0) {
  975. client->Message(CHANNEL_COLOR_RED, "Invalid Zone Script file. Be sure you give the absolute path.");
  976. client->Message(CHANNEL_COLOR_RED, "Example: /zone set lua_script 'ZoneScripts/QueensColony.lua'");
  977. return false;
  978. }
  979. else {
  980. world.AddZoneScript(zone_id, const_cast<char*>(value));
  981. database.SaveZoneInfo(zone_id, "lua_script", value);
  982. }
  983. break;
  984. }
  985. case ZONE_SET_VALUE_SHUTDOWN_TIMER: {
  986. if (zone)
  987. zone->SetShutdownTimer(int_value);
  988. database.SaveZoneInfo(zone_id, "shutdown_timer", int_value);
  989. break;
  990. }
  991. case ZONE_SET_VALUE_ZONE_MOTD: {
  992. if (zone)
  993. zone->SetZoneMOTD(string(value));
  994. database.SaveZoneInfo(zone_id, "zone_motd", value);
  995. break;
  996. }
  997. default: {
  998. client->Message(CHANNEL_COLOR_RED, "Invalid zone attribute %i", type);
  999. return false;
  1000. }
  1001. }
  1002. }
  1003. else {
  1004. if (client)
  1005. client->SimpleMessage(CHANNEL_COLOR_RED, "An error occured saving new zone data.");
  1006. return false;
  1007. }
  1008. return true;
  1009. }
  1010. void Commands::Process(int32 index, EQ2_16BitString* command_parms, Client* client, Spawn* targetOverride) {
  1011. if (index >= remote_commands->commands.size()) {
  1012. LogWrite(COMMAND__ERROR, 0, "Command", "Error, command handler of %u was requested, but max handler is %u", index, remote_commands->commands.size());
  1013. return;
  1014. }
  1015. Spawn* cmdTarget = targetOverride ? targetOverride : client->GetPlayer()->GetTarget();
  1016. EQ2_RemoteCommandString* parent_command = 0;
  1017. EQ2_RemoteCommandString* command = &remote_commands->commands[index];
  1018. Seperator* sep = 0;
  1019. if (command_parms->size > 0) {
  1020. sep = new Seperator(command_parms->data.c_str(), ' ', 10, 500, true);
  1021. if (sep && sep->arg[0] && remote_commands->validSubCommand(command->command.data, string(sep->arg[0]))) {
  1022. parent_command = command;
  1023. command = &(remote_commands->subcommands[command->command.data][string(sep->arg[0])]);
  1024. safe_delete(sep);
  1025. if (command_parms->data.length() > (command->command.data.length() + 1))
  1026. sep = new Seperator(command_parms->data.c_str() + (command->command.data.length() + 1), ' ', 10, 500, true);
  1027. LogWrite(COMMAND__DEBUG, 1, "Command", "Handler: %u, COMMAND: '%s', SUBCOMMAND: '%s'", index, parent_command->command.data.c_str(), command->command.data.c_str());
  1028. }
  1029. else
  1030. LogWrite(COMMAND__DEBUG, 1, "Command", "Handler: %u, COMMAND: '%s'", index, command->command.data.c_str());
  1031. }
  1032. int ndx = 0;
  1033. if (command->required_status > client->GetAdminStatus())
  1034. {
  1035. 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());
  1036. safe_delete(sep);
  1037. client->SimpleMessage(3, "Error: Your status is insufficient for this command.");
  1038. return;
  1039. }
  1040. Player* player = client->GetPlayer();
  1041. LogWrite(COMMAND__DEBUG, 0, "Command", "Player '%s' (%u), Command: %s", player->GetName(), client->GetAccountID(), command->command.data.c_str());
  1042. switch (command->handler) {
  1043. case COMMAND_RELOAD: {
  1044. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reload commands:");
  1045. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload structs");
  1046. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload items");
  1047. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload luasystem");
  1048. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spawnscripts");
  1049. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spells");
  1050. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload quests");
  1051. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spawns");
  1052. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload groundspawns");
  1053. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload zonescripts");
  1054. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload entity_commands");
  1055. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload factions");
  1056. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload mail");
  1057. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload guilds");
  1058. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload locations");
  1059. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload rules");
  1060. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload transporters");
  1061. break;
  1062. }
  1063. case COMMAND_RELOADSTRUCTS: {
  1064. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Structs...");
  1065. configReader.ReloadStructs();
  1066. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1067. break;
  1068. }
  1069. case COMMAND_RELOAD_QUESTS: {
  1070. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Quests...");
  1071. master_quest_list.Reload();
  1072. client_list.ReloadQuests();
  1073. zone_list.ReloadClientQuests();
  1074. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1075. break;
  1076. }
  1077. case COMMAND_RELOAD_SPAWNS: {
  1078. client->GetCurrentZone()->ReloadSpawns();
  1079. break;
  1080. }
  1081. case COMMAND_RELOAD_SPELLS: {
  1082. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spells...");
  1083. zone_list.DeleteSpellProcess();
  1084. master_spell_list.Reload();
  1085. if (lua_interface)
  1086. lua_interface->ReloadSpells();
  1087. zone_list.LoadSpellProcess();
  1088. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1089. break;
  1090. }
  1091. case COMMAND_RELOAD_GROUNDSPAWNS: {
  1092. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Groundspawn Entries...");
  1093. client->GetCurrentZone()->DeleteGroundSpawnItems();
  1094. client->GetCurrentZone()->LoadGroundSpawnEntries();
  1095. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1096. break;
  1097. }
  1098. case COMMAND_RELOAD_ZONESCRIPTS: {
  1099. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Zone Scripts...");
  1100. world.ResetZoneScripts();
  1101. database.LoadZoneScriptData();
  1102. if (lua_interface)
  1103. lua_interface->DestroyZoneScripts();
  1104. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1105. break;
  1106. }
  1107. case COMMAND_RELOAD_ENTITYCOMMANDS: {
  1108. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Entity Commands...");
  1109. client->GetCurrentZone()->ClearEntityCommands();
  1110. database.LoadEntityCommands(client->GetCurrentZone());
  1111. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1112. break;
  1113. }
  1114. case COMMAND_RELOAD_FACTIONS: {
  1115. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Factions...");
  1116. master_faction_list.Clear();
  1117. database.LoadFactionList();
  1118. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1119. break;
  1120. }
  1121. case COMMAND_RELOAD_MAIL: {
  1122. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Mail...");
  1123. zone_list.ReloadMail();
  1124. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1125. break;
  1126. }
  1127. case COMMAND_RELOAD_GUILDS: {
  1128. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Guilds...");
  1129. world.ReloadGuilds();
  1130. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1131. break;
  1132. }
  1133. case COMMAND_RELOAD_LOCATIONS: {
  1134. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Locations...");
  1135. client->GetPlayer()->GetZone()->RemoveLocationGrids();
  1136. database.LoadLocationGrids(client->GetPlayer()->GetZone());
  1137. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1138. break;
  1139. }
  1140. case COMMAND_RELOAD_RULES: {
  1141. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Rules...");
  1142. database.LoadRuleSets(true);
  1143. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1144. break;
  1145. }
  1146. case COMMAND_RELOAD_TRANSPORTERS: {
  1147. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Transporters in your current zone...");
  1148. database.LoadTransporters(client->GetCurrentZone());
  1149. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1150. break;
  1151. }
  1152. case COMMAND_READ: {
  1153. if (sep && sep->arg[1][0] && sep->IsNumber(1)) {
  1154. if (strcmp(sep->arg[0], "read") == 0) {
  1155. int32 item_index = atol(sep->arg[1]);
  1156. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  1157. if (item) {
  1158. Spawn* spawn = cmdTarget;
  1159. int8 numpages = item->book_pages.size();
  1160. string page1 = string(item->book_pages[0]->page_text.data);
  1161. PacketStruct* packet = configReader.getStruct("WS_EqShowBook", client->GetVersion());
  1162. string title = item->name;
  1163. if (packet) {
  1164. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  1165. packet->setDataByName("book_title", title.c_str());
  1166. packet->setDataByName("book_type", "simple");
  1167. packet->setDataByName("unknown2", 1);
  1168. packet->setDataByName("unknown5", 1, 4);
  1169. packet->setArrayLengthByName("num_pages", numpages);
  1170. for (int8 pages = 1; pages <= numpages; pages++) {
  1171. int8 pagenum = int8(item->book_pages[pages - 1]->page);
  1172. string page = string(item->book_pages[pages-1]->page_text.data);
  1173. int8 valign = int8(item->book_pages[pages - 1]->valign);
  1174. int8 halign = int8(item->book_pages[pages - 1]->halign);
  1175. packet->setArrayDataByName("page_text", page.c_str(), pagenum -1);
  1176. packet->setArrayDataByName("page_text_valign", valign , pagenum - 1);
  1177. packet->setArrayDataByName("page_text_halign", halign, pagenum - 1);
  1178. // Need to add support for images
  1179. }
  1180. client->QueuePacket(packet->serialize());
  1181. safe_delete(packet);
  1182. }
  1183. break;
  1184. }
  1185. }
  1186. }
  1187. }
  1188. case COMMAND_USEABILITY:{
  1189. if (sep && sep->arg[0][0] && sep->IsNumber(0)) {
  1190. if (client->GetPlayer()->GetHP() == 0) {
  1191. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot do that right now.");
  1192. }
  1193. else {
  1194. int32 spell_id = atoul(sep->arg[0]);
  1195. int8 spell_tier = 0;
  1196. if (sep->arg[1][0] && sep->IsNumber(1))
  1197. spell_tier = atoi(sep->arg[1]);
  1198. else
  1199. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  1200. if (!spell_tier)
  1201. spell_tier = 1;
  1202. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  1203. if (spell) {
  1204. 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)
  1205. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), cmdTarget, true, true);
  1206. else
  1207. {
  1208. if (cmdTarget)
  1209. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), cmdTarget);
  1210. else
  1211. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  1212. }
  1213. }
  1214. }
  1215. }
  1216. else if (cmdTarget && cmdTarget->IsWidget())
  1217. {
  1218. Widget* widget = (Widget*)cmdTarget;
  1219. widget->HandleUse(client, "use", WIDGET_TYPE_DOOR);
  1220. }
  1221. else
  1222. {
  1223. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /useability {spell_id} [spell_tier]");
  1224. }
  1225. break;
  1226. }
  1227. case COMMAND_INFO:{
  1228. if(sep && sep->arg[1][0] && sep->IsNumber(1)){
  1229. if(strcmp(sep->arg[0], "inventory") == 0){
  1230. int32 item_index = atol(sep->arg[1]);
  1231. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  1232. if(item){
  1233. if (item->IsCollectable() && client->SendCollectionsForItem(item))
  1234. break;
  1235. EQ2Packet* app = item->serialize(client->GetVersion(), (!item->GetItemScript() || !lua_interface), client->GetPlayer());
  1236. //DumpPacket(app);
  1237. client->QueuePacket(app);
  1238. if(item->GetItemScript() && lua_interface)
  1239. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  1240. else if(item->generic_info.offers_quest_id > 0){ //leave the current functionality in place if it doesnt have an item script
  1241. Quest* quest = master_quest_list.GetQuest(item->generic_info.offers_quest_id);
  1242. if(quest && client->GetPlayer()->GetCompletedQuest(item->generic_info.offers_quest_id) == 0 && client->GetPlayer()->GetQuest(item->generic_info.offers_quest_id) == 0)
  1243. client->AddPendingQuest(quest);
  1244. }
  1245. }
  1246. else
  1247. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Index: %u", item_index);
  1248. }
  1249. else if(strcmp(sep->arg[0], "equipment") == 0){
  1250. int32 item_index = atol(sep->arg[1]);
  1251. Item* item = client->GetPlayer()->GetEquipmentList()->GetItem(item_index);
  1252. if(item){
  1253. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1254. client->QueuePacket(app);
  1255. if(item->GetItemScript() && lua_interface)
  1256. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  1257. }
  1258. else
  1259. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Index: %u", item_index);
  1260. }
  1261. 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){
  1262. int32 item_id = atoul(sep->arg[1]);
  1263. Item* item = master_item_list.GetItem(item_id);
  1264. if(item){
  1265. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1266. client->QueuePacket(app);
  1267. }
  1268. else
  1269. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Item ID: %u", item_id);
  1270. }
  1271. else if (strcmp(sep->arg[0], "spell") == 0) {
  1272. sint32 spell_id = atol(sep->arg[1]);
  1273. int8 tier = atoi(sep->arg[3]);
  1274. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, tier, client, true, 0x2A);
  1275. if (outapp)
  1276. client->QueuePacket(outapp);
  1277. else
  1278. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  1279. }
  1280. else if (strcmp(sep->arg[0], "achievement") == 0) {
  1281. sint32 spell_id = atol(sep->arg[2]);
  1282. int8 group = atoi(sep->arg[1]);
  1283. AltAdvanceData* data = 0;
  1284. SpellBookEntry* spellentry = 0;
  1285. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  1286. LogWrite(COMMAND__ERROR, 0, "Command", "AA Spell ID and/or Tier, ID: %u, Group: %i", spell_id, group);
  1287. EQ2Packet* outapp = master_spell_list.GetAASpellPacket(spell_id, tier, client, true, 0x45);
  1288. if (outapp)
  1289. client->QueuePacket(outapp);
  1290. else
  1291. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, group);
  1292. }
  1293. else if (strcmp(sep->arg[0], "spellbook") == 0) {
  1294. sint32 spell_id = atol(sep->arg[1]);
  1295. int8 tier = atoi(sep->arg[2]);
  1296. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, tier, client, true, 0x2A);
  1297. if (outapp)
  1298. client->QueuePacket(outapp);
  1299. else
  1300. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  1301. }
  1302. else if (strcmp(sep->arg[0], "recipe") == 0) {
  1303. sint32 recipe_id = atol(sep->arg[1]);
  1304. EQ2Packet* outapp = master_recipe_list.GetRecipePacket(recipe_id, client, true, 0x2C);
  1305. if(outapp)
  1306. client->QueuePacket(outapp);
  1307. else
  1308. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Recipe ID: %u", recipe_id);
  1309. }
  1310. else if (strcmp(sep->arg[0], "maintained") ==0) {
  1311. int32 slot = atol(sep->arg[1]);
  1312. int32 spell_id = atol(sep->arg[2]);
  1313. LogWrite(COMMAND__DEBUG, 5, "Command", "Unknown Spell ID - Slot: %u unknown: %u", slot, spell_id);
  1314. //int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  1315. MaintainedEffects* info = client->GetPlayer()->GetMaintainedSpellBySlot(slot);
  1316. EQ2Packet* outapp = master_spell_list.GetSpellPacket(info->spell_id, info->tier, client, true, 0x00);
  1317. if(outapp)
  1318. client->QueuePacket(outapp);
  1319. else
  1320. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID: %u", spell_id);
  1321. }
  1322. else if (strcmp(sep->arg[0], "effect") == 0) {
  1323. int32 spell_id = atol(sep->arg[1]);
  1324. LogWrite(COMMAND__DEBUG, 5, "Command", "Unknown Spell ID: %u", spell_id);
  1325. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  1326. EQ2Packet* outapp = master_spell_list.GetSpecialSpellPacket(spell_id, tier, client, true, 0x00);
  1327. if (outapp){
  1328. client->QueuePacket(outapp);
  1329. }
  1330. else
  1331. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID: %u", spell_id);
  1332. }
  1333. }
  1334. else if (sep && strcmp(sep->arg[0], "overflow") == 0) {
  1335. Item* item = player->item_list.GetOverflowItem();
  1336. if(item) {
  1337. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1338. client->QueuePacket(app);
  1339. }
  1340. else
  1341. LogWrite(COMMAND__ERROR, 0,"Command", "Unable to retrieve an overflow item.");
  1342. }
  1343. else
  1344. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /info {inventory|equipment|spell} {id}");
  1345. break;
  1346. }
  1347. case COMMAND_USE_EQUIPPED_ITEM:{
  1348. if (sep && sep->arg[0] && sep->IsNumber(0)){
  1349. int32 slot_id = atoul(sep->arg[0]);
  1350. Item* item = player->GetEquipmentList()->GetItem(slot_id);
  1351. if (item && item->generic_info.usable && item->GetItemScript())
  1352. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player);
  1353. }
  1354. break;
  1355. }
  1356. case COMMAND_USE_ITEM: {
  1357. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  1358. int32 item_index = atoul(sep->arg[0]);
  1359. Item* item = player->item_list.GetItemFromIndex(item_index);
  1360. if (item && item->GetItemScript()) {
  1361. if (item->generic_info.max_charges == 0 || item->generic_info.max_charges == 0xFFFF)
  1362. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player);
  1363. else {
  1364. if (item->generic_info.display_charges > 0) {
  1365. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player);
  1366. item->generic_info.display_charges -= 1;
  1367. item->save_needed = true;
  1368. client->QueuePacket(item->serialize(client->GetVersion(), false, client->GetPlayer()));
  1369. }
  1370. }
  1371. }
  1372. }
  1373. break;
  1374. }
  1375. case COMMAND_SCRIBE_SCROLL_ITEM: {
  1376. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  1377. Item* item = player->item_list.GetItemFromUniqueID(atoul(sep->arg[0]));
  1378. if (item) {
  1379. LogWrite(ITEM__DEBUG, 0, "Items", "ITEM ID: %u", item->details.item_id);
  1380. if(item->generic_info.item_type == 6) {
  1381. Spell* spell = master_spell_list.GetSpell(item->skill_info->spell_id, item->skill_info->spell_tier);
  1382. int8 old_slot = 0;
  1383. if (spell) {
  1384. if (!player->HasSpell(spell->GetSpellID(), spell->GetSpellTier(), true)) {
  1385. old_slot = player->GetSpellSlot(spell->GetSpellID());
  1386. player->RemoveSpellBookEntry(spell->GetSpellID());
  1387. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  1388. player->UnlockSpell(spell);
  1389. client->SendSpellUpdate(spell);
  1390. database.DeleteItem(client->GetCharacterID(), item, 0);
  1391. player->item_list.RemoveItem(item, true);
  1392. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  1393. client->QueuePacket(player->SendInventoryUpdate(client->GetVersion()));
  1394. }
  1395. }
  1396. else
  1397. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown spell ID: %u and tier: %u", item->skill_info->spell_id, item->skill_info->spell_tier);
  1398. }
  1399. else if(item->generic_info.item_type == 7){
  1400. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Scribing recipe book %s (%u) for player %s.", item->name.c_str(), item->details.item_id, player->GetName());
  1401. Recipe* recipe_book = new Recipe(master_recipebook_list.GetRecipeBooks(item->details.item_id));
  1402. // if valid recipe book and the player doesn't have it
  1403. if (recipe_book && recipe_book->GetLevel() > client->GetPlayer()->GetTSLevel()) {
  1404. client->Message(CHANNEL_COLOR_WHITE, "Your tradeskill level is not high enough to scribe this book.");
  1405. safe_delete(recipe_book);
  1406. }
  1407. else if (recipe_book && !(client->GetPlayer()->GetRecipeBookList()->HasRecipeBook(item->details.item_id))) {
  1408. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Valid recipe book that the player doesn't have");
  1409. // Add recipe book to the players list
  1410. client->GetPlayer()->GetRecipeBookList()->AddRecipeBook(recipe_book);
  1411. // Get a list of all recipes this book contains
  1412. vector<Recipe*>* book_recipes = master_recipe_list.GetRecipes(recipe_book->GetBookName());
  1413. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "%i recipes found for %s book", book_recipes->size(), recipe_book->GetBookName());
  1414. // Create the packet to send to update the players recipe list
  1415. PacketStruct* packet = 0;
  1416. if (client->GetRecipeListSent()) {
  1417. packet = configReader.getStruct("WS_RecipeList", client->GetVersion());
  1418. if (packet)
  1419. packet->setArrayLengthByName("num_recipes", book_recipes->size());
  1420. }
  1421. // loop through the list
  1422. vector<Recipe*>::iterator itr;
  1423. int16 i = 0;
  1424. for (itr = book_recipes->begin(); itr != book_recipes->end(); itr++) {
  1425. // check to see if the player already has this recipe some how
  1426. if (!client->GetPlayer()->GetRecipeList()->GetRecipe((*itr)->GetID())) {
  1427. // Player doesn't already have this recipe so lets add it
  1428. Recipe* recipe = new Recipe(master_recipe_list.GetRecipe((*itr)->GetID()));
  1429. client->GetPlayer()->GetRecipeList()->AddRecipe(recipe);
  1430. database.SavePlayerRecipe(client->GetPlayer(), recipe->GetID());
  1431. client->Message(CHANNEL_COLOR_WHITE, "Recipe: \"%s\" put in recipe book.", recipe->GetName());
  1432. if (packet && client->GetRecipeListSent()) {
  1433. packet->setArrayDataByName("id", recipe->GetID(), i);
  1434. packet->setArrayDataByName("tier", recipe->GetTier(), i);
  1435. packet->setArrayDataByName("level", recipe->GetLevel(), i);
  1436. packet->setArrayDataByName("icon", recipe->GetIcon(), i);
  1437. packet->setArrayDataByName("classes", recipe->GetClasses(), i);
  1438. packet->setArrayDataByName("skill", recipe->GetSkill(), i);
  1439. packet->setArrayDataByName("technique", recipe->GetTechnique(), i);
  1440. packet->setArrayDataByName("knowledge", recipe->GetKnowledge(), i);
  1441. packet->setArrayDataByName("unknown2", recipe->GetUnknown2(), i);
  1442. packet->setArrayDataByName("recipe_name", recipe->GetName(), i);
  1443. packet->setArrayDataByName("recipe_book", recipe->GetBook(), i);
  1444. packet->setArrayDataByName("unknown3", recipe->GetUnknown3(), i);
  1445. i++;
  1446. }
  1447. }
  1448. }
  1449. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Done adding recipes");
  1450. database.SavePlayerRecipeBook(client->GetPlayer(), recipe_book->GetBookID());
  1451. database.DeleteItem(client->GetCharacterID(), item, 0);
  1452. client->GetPlayer()->item_list.RemoveItem(item, true);
  1453. client->QueuePacket(client->GetPlayer()->SendInventoryUpdate(client->GetVersion()));
  1454. if (packet && client->GetRecipeListSent())
  1455. client->QueuePacket(packet->serialize());
  1456. safe_delete(packet);
  1457. }
  1458. else {
  1459. if (recipe_book)
  1460. client->Message(CHANNEL_COLOR_WHITE, "You have already learned all you can from this item.");
  1461. safe_delete(recipe_book);
  1462. }
  1463. }
  1464. }
  1465. else
  1466. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown unique item ID: %s", sep->arg[0]);
  1467. }
  1468. break;
  1469. }
  1470. case COMMAND_SUMMONITEM: {
  1471. if (sep && sep->IsNumber(0)) {
  1472. int32 item_id = atol(sep->arg[0]);
  1473. int32 quantity = 1;
  1474. if (sep->arg[1] && sep->IsNumber(1))
  1475. quantity = atoi(sep->arg[1]);
  1476. if (sep->arg[2] && strncasecmp(sep->arg[2], "bank", 4) == 0) {
  1477. client->AddItemToBank(item_id,quantity);
  1478. }
  1479. else {
  1480. client->AddItem(item_id, quantity);
  1481. }
  1482. }
  1483. else {
  1484. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} [quantity] or");
  1485. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} {quantity} [location] where location = bank");
  1486. }
  1487. break;
  1488. }
  1489. case COMMAND_COLLECTION_ADDITEM: {
  1490. // takes 2 params: collection_id, slot
  1491. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  1492. Item *item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(atoul(sep->arg[1]));
  1493. if (item)
  1494. client->HandleCollectionAddItem(atoul(sep->arg[0]), item);
  1495. else
  1496. 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]));
  1497. }
  1498. else
  1499. LogWrite(COLLECTION__ERROR, 0, "Collect", "Received command 'COMMAND_COLLECTION_ADDITEM' with unhandeled argument types");
  1500. break;
  1501. }
  1502. case COMMAND_COLLECTION_FILTER_MATCHITEM: {
  1503. // takes 1 param: slot
  1504. printf("COMMAND_COLLECTION_FILTER_MATCHITEM:\n");
  1505. int i = 0;
  1506. while (sep->arg[i] && strlen(sep->arg[i]) > 0) {
  1507. printf("\t%u: %s\n", i, sep->arg[i]);
  1508. i++;
  1509. }
  1510. break;
  1511. }
  1512. case COMMAND_WHO:{
  1513. const char* who = 0;
  1514. if(sep && sep->arg[0]){
  1515. //cout << "Who query: \n";
  1516. who = sep->argplus[0];
  1517. //cout << who << endl;
  1518. }
  1519. zone_list.ProcessWhoQuery(who, client);
  1520. break;
  1521. }
  1522. case COMMAND_SELECT_JUNCTION:{
  1523. 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__);
  1524. int32 choice = 0;
  1525. if(sep && sep->arg[0] && sep->IsNumber(0))
  1526. choice = atoul(sep->arg[0]);
  1527. if(client->GetPlayer()->GetHP() == 0){ //dead and this is a revive request
  1528. client->HandlePlayerRevive(choice);
  1529. }
  1530. break;
  1531. }
  1532. case COMMAND_SPAWN_MOVE: {
  1533. if (cmdTarget && cmdTarget->IsPlayer() == false) {
  1534. PacketStruct* packet = configReader.getStruct("WS_MoveObjectMode", client->GetVersion());
  1535. if (packet) {
  1536. float unknown2_3 = 0;
  1537. int8 placement_mode = 0;
  1538. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::DEFAULT);
  1539. if (sep && sep->arg[0][0]) {
  1540. if (strcmp(sep->arg[0], "wall") == 0) {
  1541. placement_mode = 2;
  1542. unknown2_3 = 150;
  1543. }
  1544. else if (strcmp(sep->arg[0], "ceiling") == 0)
  1545. placement_mode = 1;
  1546. else if (strcmp(sep->arg[0], "openheading") == 0 && cmdTarget->IsWidget())
  1547. {
  1548. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "[PlacementMode] WIDGET OPEN HEADING MODE");
  1549. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::OPEN_HEADING);
  1550. }
  1551. else if (strcmp(sep->arg[0], "closeheading") == 0 && cmdTarget->IsWidget())
  1552. {
  1553. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "[PlacementMode] WIDGET CLOSE HEADING MODE");
  1554. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::CLOSE_HEADING);
  1555. }
  1556. else if (strcmp(sep->arg[0], "myloc") == 0)
  1557. {
  1558. if (cmdTarget->GetSpawnLocationPlacementID() < 1) {
  1559. client->Message(CHANNEL_COLOR_YELLOW, "[PlacementMode] Spawn %s cannot be moved it is not assigned a spawn location placement id.", cmdTarget->GetName());
  1560. safe_delete(packet);
  1561. break;
  1562. }
  1563. cmdTarget->SetX(client->GetPlayer()->GetX(), true);
  1564. cmdTarget->SetY(client->GetPlayer()->GetY(), true);
  1565. cmdTarget->SetZ(client->GetPlayer()->GetZ(), true);
  1566. cmdTarget->SetHeading(client->GetPlayer()->GetHeading(), true);
  1567. if (database.UpdateSpawnLocationSpawns(cmdTarget))
  1568. client->Message(CHANNEL_COLOR_YELLOW, "[PlacementMode] Spawn %s placed at your location. Updated spawn_location_placement for spawn.", cmdTarget->GetName());
  1569. safe_delete(packet);
  1570. break;
  1571. }
  1572. }
  1573. packet->setDataByName("placement_mode", placement_mode);
  1574. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget));
  1575. packet->setDataByName("model_type", cmdTarget->GetModelType());
  1576. packet->setDataByName("unknown", 1); //size
  1577. packet->setDataByName("unknown2", 1); //size 2
  1578. packet->setDataByName("unknown2", .5, 1); //size 3
  1579. packet->setDataByName("unknown2", 3, 2);
  1580. packet->setDataByName("unknown2", unknown2_3, 3);
  1581. packet->setDataByName("max_distance", 500);
  1582. packet->setDataByName("CoEunknown", 0xFFFFFFFF);
  1583. client->QueuePacket(packet->serialize());
  1584. safe_delete(packet);
  1585. }
  1586. }
  1587. else {
  1588. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /spawn move (wall OR ceiling)");
  1589. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Moves a spawn anywhere you like. Optionally wall/ceiling can be provided to place wall/ceiling items.");
  1590. }
  1591. break;
  1592. }
  1593. case COMMAND_HAIL:{
  1594. Spawn* spawn = cmdTarget;
  1595. if(spawn && spawn->GetTargetable())
  1596. {
  1597. char tmp[75] = {0};
  1598. sprintf(tmp, "Hail, %s", spawn->GetName());
  1599. bool show_bubble = true;
  1600. if (spawn->IsNPC())
  1601. show_bubble = false;
  1602. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp, HEAR_SPAWN_DISTANCE, 0, show_bubble);
  1603. if(spawn->IsPlayer() == false && spawn->GetDistance(client->GetPlayer()) < 30){
  1604. if(spawn->IsNPC() && ((NPC*)spawn)->EngagedInCombat())
  1605. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED_BUSY, client->GetPlayer());
  1606. else
  1607. spawn->ProcessMovement();
  1608. LogWrite(MISC__TODO, 0, "Check", "ProcessMovement has been called");
  1609. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED, client->GetPlayer());
  1610. }
  1611. }
  1612. else {
  1613. string tmp = "Hail";
  1614. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp.c_str(), HEAR_SPAWN_DISTANCE, 0, true);
  1615. }
  1616. break;
  1617. }
  1618. case COMMAND_SAY:{
  1619. if (sep && sep->arg[0][0]) {
  1620. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, sep->argplus[0], HEAR_SPAWN_DISTANCE);
  1621. if (cmdTarget && !(cmdTarget->IsPlayer()))
  1622. client->GetCurrentZone()->CallSpawnScript(cmdTarget, SPAWN_SCRIPT_HEAR_SAY, client->GetPlayer(), sep->argplus[0]);
  1623. }
  1624. else
  1625. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /say {message}");
  1626. break;
  1627. }
  1628. case COMMAND_TELL:{
  1629. if(sep && sep->arg[0] && sep->argplus[1]){
  1630. if(!zone_list.HandleGlobalChatMessage(client, sep->arg[0], CHANNEL_TELL, sep->argplus[1]))
  1631. client->Message(CHANNEL_COLOR_RED,"Unable to find client %s",sep->arg[0]);
  1632. }else
  1633. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /tell {character_name} {message}");
  1634. break;
  1635. }
  1636. case COMMAND_SHOUT:{
  1637. if(sep && sep->arg[0][0])
  1638. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SHOUT, sep->argplus[0]);
  1639. else
  1640. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /shout {message}");
  1641. break;
  1642. }
  1643. case COMMAND_AUCTION:{
  1644. if(sep && sep->arg[0][0])
  1645. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_AUCTION, sep->argplus[0]);
  1646. else
  1647. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /auction {message}");
  1648. break;
  1649. }
  1650. case COMMAND_OOC:{
  1651. //For now ooc will be the global chat channel, eventually when we create more channels we will create a global chat channel
  1652. if(sep && sep->arg[0][0])
  1653. zone_list.HandleGlobalChatMessage(client, 0, CHANNEL_OOC, sep->argplus[0]);
  1654. else
  1655. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /ooc {message}");
  1656. break;
  1657. }
  1658. case COMMAND_EMOTE:{
  1659. if(sep && sep->arg[0][0])
  1660. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_EMOTE, sep->argplus[0]);
  1661. else
  1662. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /emote {action}");
  1663. break;
  1664. }
  1665. case COMMAND_RACE:{
  1666. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  1667. if(sep->arg[1][0] && sep->IsNumber(1)){
  1668. client->GetPlayer()->GetInfoStruct()->race = atoi(sep->arg[1]);
  1669. client->GetPlayer()->SetRace(atoi(sep->arg[1]));
  1670. client->UpdateTimeStampFlag ( RACE_UPDATE_FLAG );
  1671. client->GetPlayer()->SetCharSheetChanged(true);
  1672. }
  1673. client->GetPlayer()->SetModelType(atoi(sep->arg[0]));
  1674. //EQ2Packet* outapp = client->GetPlayer()->spawn_update_packet(client->GetPlayer(), client->GetVersion(), client->GetPlayer()->GetFeatures());
  1675. //client->QueuePacket(outapp);
  1676. }
  1677. else{
  1678. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /race {race type id} {race id}");
  1679. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "{race id} is optional");
  1680. }
  1681. break;
  1682. }
  1683. case COMMAND_BANK_DEPOSIT:{
  1684. if(client->GetBanker() && sep && sep->arg[0]){
  1685. int64 amount = 0;
  1686. string deposit = string(sep->arg[0]);
  1687. amount = atoi64(deposit.c_str());
  1688. client->BankDeposit(amount);
  1689. }
  1690. break;
  1691. }
  1692. case COMMAND_BANK_WITHDRAWAL:{
  1693. if(client->GetBanker() && sep && sep->arg[0] && sep->IsNumber(0)){
  1694. int64 amount = 0;
  1695. string deposit = string(sep->arg[0]);
  1696. amount = atoi64(deposit.c_str());
  1697. client->BankWithdrawal(amount);
  1698. }
  1699. break;
  1700. }
  1701. case COMMAND_BANK_CANCEL:{
  1702. Spawn* banker = cmdTarget;
  1703. client->Bank(banker, true);
  1704. break;
  1705. }
  1706. case COMMAND_BANK:{
  1707. LogWrite(PLAYER__DEBUG, 0, "Players", "Open Player Personal Bank...");
  1708. Spawn* banker = cmdTarget;
  1709. client->Bank(banker);
  1710. break;
  1711. }
  1712. case COMMAND_GUILD_BANK:{
  1713. LogWrite(GUILD__DEBUG, 0, "Guilds", "Open Guild Bank...");
  1714. //Spawn* banker = client->GetPlayer()->GetTarget();
  1715. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will eventually open the guild bank!");
  1716. break;
  1717. }
  1718. case COMMAND_START_MAIL: {
  1719. client->SetMailTransaction(cmdTarget);
  1720. client->SendMailList();
  1721. break;
  1722. }
  1723. case COMMAND_CANCEL_MAIL: {
  1724. client->SetMailTransaction(0);
  1725. break;
  1726. }
  1727. case COMMAND_GET_MAIL_MESSAGE: {
  1728. if (sep && sep->arg[0] && sep->IsNumber(0))
  1729. client->DisplayMailMessage(atoul(sep->arg[0]));
  1730. break;
  1731. }
  1732. case COMMAND_ADD_MAIL_PLAT: {
  1733. if (sep && sep->arg[0] && sep->IsNumber(0))
  1734. client->AddMailCoin(0, 0, 0, atoul(sep->arg[0]));
  1735. break;
  1736. }
  1737. case COMMAND_ADD_MAIL_GOLD: {
  1738. if (sep && sep->arg[0] && sep->IsNumber(0))
  1739. client->AddMailCoin(0, 0, atoul(sep->arg[0]));
  1740. break;
  1741. }
  1742. case COMMAND_ADD_MAIL_SILVER: {
  1743. if (sep && sep->arg[0] && sep->IsNumber(0))
  1744. client->AddMailCoin(0, atoul(sep->arg[0]));
  1745. break;
  1746. }
  1747. case COMMAND_ADD_MAIL_COPPER: {
  1748. if (sep && sep->arg[0] && sep->IsNumber(0))
  1749. client->AddMailCoin(atoul(sep->arg[0]));
  1750. break;
  1751. }
  1752. case COMMAND_SET_MAIL_ITEM: {
  1753. LogWrite(MISC__TODO, 1, "TODO", " received set_mail_item\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1754. if (sep && sep->arg[0]) LogWrite(COMMAND__DEBUG, 0, "Command", "%s\n", sep->argplus[0]);
  1755. break;
  1756. }
  1757. case COMMAND_REMOVE_MAIL_PLAT: {
  1758. if (sep && sep->arg[0] && sep->IsNumber(0))
  1759. client->RemoveMailCoin(0, 0, 0, atoul(sep->arg[0]));
  1760. break;
  1761. }
  1762. case COMMAND_REMOVE_MAIL_GOLD: {
  1763. if (sep && sep->arg[0] && sep->IsNumber(0))
  1764. client->RemoveMailCoin(0, 0, atoul(sep->arg[0]));
  1765. break;
  1766. }
  1767. case COMMAND_REMOVE_MAIL_SILVER: {
  1768. if (sep && sep->arg[0] && sep->IsNumber(0))
  1769. client->RemoveMailCoin(0, atoul(sep->arg[0]));
  1770. break;
  1771. }
  1772. case COMMAND_REMOVE_MAIL_COPPER: {
  1773. if (sep && sep->arg[0] && sep->IsNumber(0))
  1774. client->RemoveMailCoin(atoul(sep->arg[0]));
  1775. break;
  1776. }
  1777. case COMMAND_TAKE_MAIL_ATTACHMENTS: {
  1778. if (sep && sep->arg[0] && sep->IsNumber(0))
  1779. client->TakeMailAttachments(atoul(sep->arg[0]));
  1780. break;
  1781. }
  1782. case COMMAND_CANCEL_SEND_MAIL: {
  1783. client->CancelSendMail();
  1784. break;
  1785. }
  1786. case COMMAND_DELETE_MAIL_MESSAGE: {
  1787. if (sep && sep->arg[0] && sep->IsNumber(0))
  1788. client->DeleteMail(atoul(sep->arg[0]), true);
  1789. break;
  1790. }
  1791. case COMMAND_REPORT_SPAM: {
  1792. LogWrite(MISC__TODO, 1, "TODO", " received reportspam\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1793. if (sep && sep->arg[0]) LogWrite(COMMAND__DEBUG, 0, "Command", "%s\n", sep->argplus[0]);
  1794. break;
  1795. }
  1796. case COMMAND_KILL:{
  1797. Spawn* dead = 0;
  1798. if (sep && sep->arg[0] && strncasecmp(sep->arg[0],"self",4)==0){
  1799. dead=client->GetPlayer();
  1800. client->GetPlayer()->SetHP(0);
  1801. client->GetPlayer()->KillSpawn(dead);
  1802. }else{
  1803. dead= cmdTarget;
  1804. if(dead && dead->IsPlayer() == false){
  1805. dead->SetHP(0);
  1806. if(sep && sep->arg[0] && sep->IsNumber(0) && atoi(sep->arg[0]) == 1)
  1807. client->GetCurrentZone()->RemoveSpawn(false, dead, true);
  1808. else
  1809. client->GetPlayer()->KillSpawn(dead);
  1810. }else{
  1811. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /kill (self)");
  1812. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Kills currently selected non-player target.");
  1813. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Optionally, self may be used to kill yourself");
  1814. }
  1815. }
  1816. break;
  1817. }
  1818. case COMMAND_LEVEL:{
  1819. if(sep && sep->arg[ndx][0] && sep->IsNumber(0)){
  1820. int16 new_level = atoi(sep->arg[ndx]);
  1821. if (!client->GetPlayer()->CheckLevelStatus(new_level))
  1822. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have the required status to level up anymore!");
  1823. else {
  1824. if (new_level < 1)
  1825. new_level = 1;
  1826. if (new_level > 255)
  1827. new_level = 255;
  1828. client->ChangeLevel(client->GetPlayer()->GetLevel(), new_level);
  1829. client->GetPlayer()->SetXP(1);
  1830. client->GetPlayer()->SetNeededXP();
  1831. }
  1832. }else
  1833. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /level {new_level}");
  1834. break;
  1835. }
  1836. case COMMAND_SIT: {
  1837. LogWrite(MISC__TODO, 1, "TODO", " Send update packet to all clients\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1838. if(client->GetPlayer()->GetHP() > 0){
  1839. client->QueuePacket(new EQ2Packet(OP_SitMsg, 0, 0));
  1840. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You sit down.");
  1841. client->GetPlayer()->set_character_flag(CF_IS_SITTING);
  1842. }
  1843. break;
  1844. }
  1845. case COMMAND_STAND: {
  1846. LogWrite(MISC__TODO, 1, "TODO", " Send update packet to all clients\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1847. if(client->GetPlayer()->GetHP() > 0){
  1848. client->QueuePacket(new EQ2Packet(OP_StandMsg, 0, 0));
  1849. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You stand up.");
  1850. client->GetPlayer()->reset_character_flag(CF_IS_SITTING);
  1851. }
  1852. break;
  1853. }
  1854. case COMMAND_CLASS:{
  1855. if(sep && sep->arg[ndx][0]){
  1856. client->GetPlayer()->SetPlayerAdventureClass(atoi(sep->arg[ndx]));
  1857. client->UpdateTimeStampFlag ( CLASS_UPDATE_FLAG );
  1858. }else
  1859. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /class {class_id}");
  1860. break;
  1861. }
  1862. case COMMAND_GENDER:{
  1863. if(sep && sep->arg[ndx][0]){
  1864. client->GetPlayer()->GetInfoStruct()->gender = atoi(sep->arg[ndx]);
  1865. client->GetPlayer()->SetCharSheetChanged(true);
  1866. client->UpdateTimeStampFlag ( GENDER_UPDATE_FLAG );
  1867. }else{
  1868. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /gender {new_gender_id}");
  1869. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Male: 1");
  1870. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Female: 2");
  1871. }
  1872. break;
  1873. }
  1874. case COMMAND_FLYMODE:{
  1875. if(sep && sep->arg[0] && sep->IsNumber(0)){
  1876. PrintSep(sep, "COMMAND_FLYMODE");
  1877. int8 val = atoi(sep->arg[0]);
  1878. ClientPacketFunctions::SendFlyMode(client, val);
  1879. }
  1880. else{
  1881. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage ON: /flymode 1");
  1882. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage OFF: /flymode 0");
  1883. }
  1884. break;
  1885. }
  1886. case COMMAND_LOOT_LIST:{
  1887. Spawn* spawn = cmdTarget;
  1888. if(spawn && spawn->IsEntity()){
  1889. if (sep && sep->arg[0]) {
  1890. if (!spawn->GetDatabaseID())
  1891. {
  1892. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn has no database id to assign to loottables.");
  1893. break;
  1894. }
  1895. else if (!spawn->IsNPC())
  1896. {
  1897. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "these /loot list [add/remove/clearall] sub-commands are only designed for an NPC.");
  1898. break;
  1899. }
  1900. bool reloadLoot = false;
  1901. if (!stricmp(sep->arg[0], "remove") && sep->arg[1] && sep->IsNumber(1))
  1902. {
  1903. int32 loottable_id = atoul(sep->arg[1]);
  1904. if (loottable_id > 0 && database.RemoveSpawnLootTable(spawn, loottable_id))
  1905. {
  1906. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u loot table %u removed.", spawn->GetDatabaseID(), loottable_id);
  1907. reloadLoot = true;
  1908. }
  1909. else
  1910. client->Message(CHANNEL_COLOR_YELLOW, "/loot list remove [loottableid] - could not match any spawn_id entries against loottable_id %u.", loottable_id);
  1911. }
  1912. else if (!stricmp(sep->arg[0], "add") && sep->arg[1] && sep->IsNumber(1))
  1913. {
  1914. int32 loottable_id = atoul(sep->arg[1]);
  1915. if (loottable_id > 0)
  1916. {
  1917. database.AddLootTableToSpawn(spawn, loottable_id);
  1918. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u loot table %u added.", spawn->GetDatabaseID(), loottable_id);
  1919. reloadLoot = true;
  1920. }
  1921. else
  1922. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list add [loottableid] - cannot add a loottable id of 0.");
  1923. }
  1924. else if (!stricmp(sep->arg[0], "clearall"))
  1925. {
  1926. if (database.RemoveSpawnLootTable(spawn, 0))
  1927. {
  1928. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn loot tables removed.");
  1929. reloadLoot = true;
  1930. }
  1931. else
  1932. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list clearall - could not match any spawn_id entries in loottable_id.");
  1933. }
  1934. else
  1935. {
  1936. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list argument not supported.");
  1937. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list add [loottableid] - add new loottable to spawn");
  1938. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list remove [loottableid] - remove existing loottable from spawn");
  1939. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list clearall - remove all loottables from spawn");
  1940. break;
  1941. }
  1942. if (reloadLoot)
  1943. {
  1944. database.LoadSpawnLoot(spawn->GetZone(), spawn);
  1945. if (spawn->IsNPC())
  1946. {
  1947. Entity* ent = (Entity*)spawn;
  1948. ent->SetLootCoins(0);
  1949. ent->ClearLootList();
  1950. spawn->GetZone()->AddLoot((NPC*)spawn);
  1951. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u active loot purged and reloaded.", spawn->GetDatabaseID());
  1952. }
  1953. }
  1954. break; // nothing further this is the end of these sub commands
  1955. }
  1956. else
  1957. {
  1958. vector<int32> loot_list = client->GetCurrentZone()->GetSpawnLootList(spawn->GetDatabaseID(), spawn->GetZone()->GetZoneID(), spawn->GetLevel(), race_types_list.GetRaceType(spawn->GetModelType()));
  1959. if (loot_list.size() > 0) {
  1960. client->Message(CHANNEL_COLOR_YELLOW, "%s belongs to the following loot lists: ", spawn->GetName());
  1961. vector<int32>::iterator list_itr;
  1962. LootTable* table = 0;
  1963. for (list_itr = loot_list.begin(); list_itr != loot_list.end(); list_itr++) {
  1964. table = client->GetCurrentZone()->GetLootTable(*list_itr);
  1965. if (table)
  1966. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", *list_itr, table->name.c_str());
  1967. }
  1968. }
  1969. client->Message(CHANNEL_COLOR_YELLOW, "Coins being carried: %u", spawn->GetLootCoins());
  1970. vector<Item*>* items = spawn->GetLootItems();
  1971. if (items) {
  1972. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is carrying the following items: ");
  1973. vector<Item*>::iterator itr;
  1974. Item* item = 0;
  1975. for (itr = items->begin(); itr != items->end(); itr++) {
  1976. item = *itr;
  1977. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", item->details.item_id, item->name.c_str());
  1978. }
  1979. }
  1980. else
  1981. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is not carrying any items.");
  1982. }
  1983. }
  1984. break;
  1985. }
  1986. case COMMAND_LOOT_SETCOIN:{
  1987. Spawn* spawn = cmdTarget;
  1988. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  1989. spawn->SetLootCoins(atoul(sep->arg[0]));
  1990. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully set coins.");
  1991. }
  1992. else
  1993. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot setcoin {amount}");
  1994. break;
  1995. }
  1996. case COMMAND_LOOT_ADDITEM:{
  1997. Spawn* spawn = cmdTarget;
  1998. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  1999. int16 charges = 1;
  2000. if(sep->arg[1] && sep->IsNumber(1))
  2001. charges = atoi(sep->arg[1]);
  2002. spawn->AddLootItem(atoul(sep->arg[0]), charges);
  2003. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully added item.");
  2004. }
  2005. else
  2006. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot additem {item_id}");
  2007. break;
  2008. }
  2009. case COMMAND_LOOT_REMOVEITEM:{
  2010. Spawn* spawn = cmdTarget;
  2011. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2012. spawn->LootItem(atoul(sep->arg[0]));
  2013. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully removed item.");
  2014. }
  2015. else
  2016. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot removeitem {item_id}");
  2017. break;
  2018. }
  2019. case COMMAND_LOOT_CORPSE:
  2020. case COMMAND_DISARM:
  2021. case COMMAND_LOOT:{
  2022. if (cmdTarget && ((Entity*)cmdTarget)->IsNPC() && cmdTarget->Alive())
  2023. {
  2024. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is not dead.");
  2025. break;
  2026. }
  2027. if(cmdTarget && cmdTarget->IsEntity()){
  2028. if (cmdTarget->GetDistance(client->GetPlayer()) <= rule_manager.GetGlobalRule(R_Loot, LootRadius)->GetFloat()){
  2029. if (!rule_manager.GetGlobalRule(R_Loot, AutoDisarmChest)->GetBool() && command->handler == COMMAND_DISARM )
  2030. client->OpenChest(cmdTarget, true);
  2031. else
  2032. client->Loot(cmdTarget, rule_manager.GetGlobalRule(R_Loot, AutoDisarmChest)->GetBool());
  2033. if (!(cmdTarget)->HasLoot()){
  2034. if (((Entity*)cmdTarget)->IsNPC())
  2035. client->GetCurrentZone()->RemoveDeadSpawn(cmdTarget);
  2036. }
  2037. }
  2038. else
  2039. client->Message(CHANNEL_COLOR_YELLOW, "You are too far away to interact with that");
  2040. }
  2041. else if(!cmdTarget || cmdTarget->GetHP() > 0)
  2042. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid target.");
  2043. break;
  2044. }
  2045. case COMMAND_RELOADSPAWNSCRIPTS:{
  2046. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spawn Scripts....");
  2047. if (lua_interface)
  2048. lua_interface->SetSpawnScriptsReloading(true);
  2049. world.ResetSpawnScripts();
  2050. database.LoadSpawnScriptData();
  2051. if(lua_interface) {
  2052. lua_interface->DestroySpawnScripts();
  2053. lua_interface->SetSpawnScriptsReloading(false);
  2054. }
  2055. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Success!");
  2056. break;
  2057. }
  2058. case COMMAND_RELOADLUASYSTEM:{
  2059. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Attempting to reload entire LUA system....");
  2060. map<Client*, int32> debug_clients = lua_interface->GetDebugClients();
  2061. safe_delete(lua_interface);
  2062. lua_interface = new LuaInterface();
  2063. if(lua_interface)
  2064. lua_interface->SetSpawnScriptsReloading(true);
  2065. if(lua_interface && debug_clients.size() > 0){
  2066. map<Client*, int32>::iterator itr;
  2067. for(itr = debug_clients.begin(); itr != debug_clients .end(); itr++){
  2068. if(lua_interface)
  2069. lua_interface->UpdateDebugClients(itr->first);
  2070. }
  2071. }
  2072. world.ResetSpawnScripts();
  2073. database.LoadSpawnScriptData();
  2074. world.ResetZoneScripts();
  2075. database.LoadZoneScriptData();
  2076. int32 quest_count = database.LoadQuests();
  2077. zone_list.DeleteSpellProcess();
  2078. master_spell_list.Reload();
  2079. int32 spell_count = 0;
  2080. if(lua_interface) {
  2081. lua_interface->DestroySpawnScripts();
  2082. lua_interface->DestroySpells();
  2083. spell_count = database.LoadSpellScriptData();
  2084. lua_interface->SetSpawnScriptsReloading(false);
  2085. }
  2086. zone_list.LoadSpellProcess();
  2087. client->Message(CHANNEL_COLOR_YELLOW, "Successfully loaded %u spell(s), %u quest(s).", spell_count, quest_count);
  2088. break;
  2089. }
  2090. case COMMAND_DECLINE_QUEST:{
  2091. int32 quest_id = 0;
  2092. if(sep && sep->arg[0] && sep->IsNumber(0))
  2093. quest_id = atoul(sep->arg[0]);
  2094. if(quest_id > 0){
  2095. Quest* quest = client->GetPendingQuest(quest_id);
  2096. if(quest){
  2097. client->RemovePendingQuest(quest);
  2098. if(lua_interface)
  2099. lua_interface->CallQuestFunction(quest, "Declined", client->GetPlayer());
  2100. safe_delete(quest);
  2101. client->GetCurrentZone()->SendQuestUpdates(client);
  2102. }
  2103. }
  2104. break;
  2105. }
  2106. case COMMAND_DELETE_QUEST:{
  2107. int32 quest_id = 0;
  2108. if(sep && sep->arg[0] && sep->IsNumber(0))
  2109. quest_id = atoul(sep->arg[0]);
  2110. if(quest_id > 0){
  2111. if(lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0) {
  2112. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  2113. if (quest)
  2114. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  2115. }
  2116. client->RemovePlayerQuest(quest_id);
  2117. client->GetCurrentZone()->SendQuestUpdates(client);
  2118. }
  2119. break;
  2120. }
  2121. case COMMAND_ACCEPT_QUEST:{
  2122. int32 quest_id = 0;
  2123. if(sep && sep->arg[0] && sep->IsNumber(0))
  2124. quest_id = atoul(sep->arg[0]);
  2125. if(quest_id > 0){
  2126. client->AcceptQuest(quest_id);
  2127. }
  2128. break;
  2129. }
  2130. case COMMAND_NAME:{
  2131. if(sep && sep->arg[ndx][0]){
  2132. memset(client->GetPlayer()->GetInfoStruct()->name, 0, 40);
  2133. strncpy(client->GetPlayer()->GetInfoStruct()->name, sep->arg[ndx], 39);
  2134. client->GetPlayer()->SetCharSheetChanged(true);
  2135. }else
  2136. client->Message(CHANNEL_COLOR_YELLOW,"Usage: /name {new_name}");
  2137. break;
  2138. }
  2139. case COMMAND_GROUPSAY:{
  2140. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  2141. if(sep && sep->arg[0] && gmi)
  2142. world.GetGroupManager()->GroupChatMessage(gmi->group_id, client->GetPlayer(), sep->argplus[0]);
  2143. break;
  2144. }
  2145. case COMMAND_GROUPINVITE: {
  2146. Entity* target = 0;
  2147. Client* target_client = 0;
  2148. if (client->GetPlayer()->GetGroupMemberInfo() && !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  2149. client->SimpleMessage(CHANNEL_COMMANDS, "You must be the group leader to invite.");
  2150. return;
  2151. }
  2152. // name provided with command so it has to be a player, npc not supported here
  2153. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0){
  2154. target_client = zone_list.GetClientByCharName(sep->arg[0]);
  2155. if (target_client) {
  2156. if (!target_client->IsConnected() || !target_client->IsReadyForSpawns())
  2157. target = 0;
  2158. else
  2159. target = target_client->GetPlayer();
  2160. }
  2161. }
  2162. // if name was not provided use the players target, npc or player supported here
  2163. if (!target && client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  2164. target = (Entity*)client->GetPlayer()->GetTarget();
  2165. if (target->IsPlayer()) {
  2166. target_client = client->GetCurrentZone()->GetClientBySpawn(target);
  2167. }
  2168. }
  2169. int8 result = world.GetGroupManager()->Invite(client->GetPlayer(), target);
  2170. if (result == 0) {
  2171. client->Message(CHANNEL_COMMANDS, "You invite %s to group with you.", target->GetName());
  2172. if (target_client) {
  2173. PacketStruct* packet = configReader.getStruct("WS_ReceiveOffer", target_client->GetVersion());
  2174. if (packet) {
  2175. packet->setDataByName("type", 1);
  2176. packet->setDataByName("name", client->GetPlayer()->GetName());
  2177. packet->setDataByName("unknown2", 1);
  2178. target_client->QueuePacket(packet->serialize());
  2179. safe_delete(packet);
  2180. }
  2181. }
  2182. }
  2183. else if (result == 1)
  2184. client->SimpleMessage(CHANNEL_COMMANDS, "That player is already in a group.");
  2185. else if (result == 2)
  2186. client->SimpleMessage(CHANNEL_COMMANDS, "That player has been invited to another group.");
  2187. else if (result == 3)
  2188. client->SimpleMessage(CHANNEL_COMMANDS, "Your group is already full.");
  2189. else if (result == 4)
  2190. client->SimpleMessage(CHANNEL_COMMANDS, "You have a pending invitation, cancel it first.");
  2191. else if (result == 5)
  2192. client->SimpleMessage(CHANNEL_COMMANDS, "You cannot invite yourself!");
  2193. else if (result == 6)
  2194. client->SimpleMessage(CHANNEL_COMMANDS, "Could not locate the player.");
  2195. else
  2196. client->SimpleMessage(CHANNEL_COMMANDS, "Group invite failed, unknown error!");
  2197. break;
  2198. }
  2199. case COMMAND_GROUPDISBAND: {
  2200. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  2201. if (gmi) { // TODO: Leader check
  2202. // world.GetGroupManager()->SimpleGroupMessage(gmi->group_id, "Your group has been disbanded.");
  2203. world.GetGroupManager()->RemoveGroup(gmi->group_id);
  2204. }
  2205. break;
  2206. }
  2207. case COMMAND_GROUP_LEAVE: {
  2208. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  2209. if (gmi) {
  2210. int32 group_id = gmi->group_id;
  2211. world.GetGroupManager()->RemoveGroupMember(group_id, client->GetPlayer());
  2212. if (!world.GetGroupManager()->IsGroupIDValid(group_id)) {
  2213. // leader->Message(CHANNEL_COLOR_GROUP, "%s has left the group.", client->GetPlayer()->GetName());
  2214. }
  2215. else {
  2216. world.GetGroupManager()->GroupMessage(group_id, "%s has left the group.", client->GetPlayer()->GetName());
  2217. }
  2218. client->SimpleMessage(CHANNEL_COLOR_GROUP, "You have left the group");
  2219. }
  2220. break;
  2221. }
  2222. case COMMAND_FRIEND_ADD:{
  2223. string name = "";
  2224. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2225. name = database.GetPlayerName(sep->arg[0]);
  2226. else if(cmdTarget && cmdTarget->IsPlayer())
  2227. name = string(cmdTarget->GetName());
  2228. if(name.length() > 0){
  2229. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  2230. if(client->GetPlayer()->IsIgnored(name.c_str())){
  2231. client->GetPlayer()->RemoveIgnore(name.c_str());
  2232. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  2233. client->SendChatRelationship(3, name.c_str());
  2234. }
  2235. client->GetPlayer()->AddFriend(name.c_str(), true);
  2236. client->SendChatRelationship(0, name.c_str());
  2237. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added friend: %s", name.c_str());
  2238. if(zone_list.GetClientByCharName(name))
  2239. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Friend: %s has logged in.", name.c_str());
  2240. }
  2241. else
  2242. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot be more friendly towards yourself!");
  2243. }
  2244. else
  2245. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  2246. break;
  2247. }
  2248. case COMMAND_FRIEND_REMOVE:{
  2249. string name = "";
  2250. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2251. name = database.GetPlayerName(sep->arg[0]);
  2252. else if(cmdTarget && cmdTarget->IsPlayer())
  2253. name = string(cmdTarget->GetName());
  2254. if(name.length() > 0){
  2255. client->GetPlayer()->RemoveFriend(name.c_str());
  2256. client->SendChatRelationship(1, name.c_str());
  2257. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  2258. }
  2259. else
  2260. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  2261. break;
  2262. }
  2263. case COMMAND_FRIENDS:{
  2264. break;
  2265. }
  2266. case COMMAND_IGNORE_ADD:{
  2267. string name = "";
  2268. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2269. name = database.GetPlayerName(sep->arg[0]);
  2270. else if(cmdTarget && cmdTarget->IsPlayer())
  2271. name = string(cmdTarget->GetName());
  2272. if(name.length() > 0){
  2273. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  2274. if(client->GetPlayer()->IsFriend(name.c_str())){
  2275. client->GetPlayer()->RemoveFriend(name.c_str());
  2276. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  2277. client->SendChatRelationship(1, name.c_str());
  2278. }
  2279. client->GetPlayer()->AddIgnore(name.c_str(), true);
  2280. client->SendChatRelationship(2, name.c_str());
  2281. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added ignore: %s", name.c_str());
  2282. }
  2283. else
  2284. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot ignore yourself!");
  2285. }
  2286. else
  2287. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  2288. break;
  2289. }
  2290. case COMMAND_IGNORE_REMOVE:{
  2291. string name = "";
  2292. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2293. name = database.GetPlayerName(sep->arg[0]);
  2294. else if(cmdTarget && cmdTarget->IsPlayer())
  2295. name = string(cmdTarget->GetName());
  2296. if(name.length() > 0){
  2297. client->GetPlayer()->RemoveIgnore(name.c_str());
  2298. client->SendChatRelationship(3, name.c_str());
  2299. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  2300. }
  2301. break;
  2302. }
  2303. case COMMAND_IGNORES:{
  2304. break;
  2305. }
  2306. case COMMAND_GROUP_KICK:{
  2307. Entity* kicked = 0;
  2308. Client* kicked_client = 0;
  2309. int32 group_id = 0;
  2310. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader)
  2311. return;
  2312. LogWrite(MISC__TODO, 0, "TODO", "Add a check to see if the client using the command (COMMAND_GROUP_KICK) is the group leader");
  2313. if (sep && sep->arg[0]) {
  2314. kicked_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  2315. if (kicked_client)
  2316. kicked = kicked_client->GetPlayer();
  2317. }
  2318. else if (cmdTarget && cmdTarget->IsEntity()) {
  2319. kicked = (Entity*)cmdTarget;
  2320. }
  2321. group_id = client->GetPlayer()->GetGroupMemberInfo()->group_id;
  2322. bool send_kicked_message = world.GetGroupManager()->GetGroupSize(group_id) > 2;
  2323. if (kicked)
  2324. world.GetGroupManager()->RemoveGroupMember(group_id, kicked);
  2325. if(send_kicked_message)
  2326. world.GetGroupManager()->GroupMessage(group_id, "%s was kicked from the group.", kicked->GetName());
  2327. else
  2328. client->Message(CHANNEL_COLOR_GROUP, "You kicked %s from the group", kicked->GetName());
  2329. if (kicked_client)
  2330. kicked_client->SimpleMessage(CHANNEL_COLOR_GROUP, "You were kicked from the group");
  2331. break;
  2332. }
  2333. case COMMAND_GROUP_MAKE_LEADER:{
  2334. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  2335. client->SimpleMessage(CHANNEL_COMMANDS, "You are not a group leader.");
  2336. return;
  2337. }
  2338. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 1) {
  2339. Client* new_leader = zone_list.GetClientByCharName(sep->arg[0]);
  2340. if (new_leader) {
  2341. if (client->GetPlayer()->IsGroupMember(new_leader->GetPlayer())) {
  2342. world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, new_leader->GetPlayer());
  2343. }
  2344. }
  2345. else
  2346. client->SimpleMessage(CHANNEL_COMMANDS, "Unable to find the given player.");
  2347. }
  2348. else if (cmdTarget && cmdTarget->IsPlayer())
  2349. world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, (Entity*)cmdTarget);
  2350. else
  2351. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to change group leader.");
  2352. break;
  2353. }
  2354. case COMMAND_GROUP_ACCEPT_INVITE: {
  2355. if(sep && sep->arg[0] && strcmp(sep->arg[0], "group") == 0) {
  2356. int8 result = world.GetGroupManager()->AcceptInvite(client->GetPlayer());
  2357. if (result == 0)
  2358. client->SimpleMessage(CHANNEL_GROUP, "You have joined the group.");
  2359. else if (result == 1)
  2360. client->SimpleMessage(CHANNEL_GROUP, "You do not have a pending invite.");
  2361. else if (result == 2)
  2362. client->SimpleMessage(CHANNEL_GROUP, "Unable to join group - could not find leader.");
  2363. else
  2364. client->SimpleMessage(CHANNEL_GROUP, "Unable to join group - unknown error.");
  2365. }
  2366. break;
  2367. }
  2368. case COMMAND_GROUP_DECLINE_INVITE: {
  2369. if(sep && sep->arg[0] && strcmp(sep->arg[0], "group") == 0) {
  2370. world.GetGroupManager()->DeclineInvite(client->GetPlayer()); // TODO: Add message to leader
  2371. }
  2372. break;
  2373. }
  2374. case COMMAND_SUMMON:{
  2375. char* search_name = 0;
  2376. if(sep && sep->arg[0][0])
  2377. search_name = sep->arg[0];
  2378. if(!search_name && !cmdTarget){
  2379. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /summon [name]");
  2380. 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.");
  2381. }
  2382. else{
  2383. if(!client->Summon(search_name))
  2384. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  2385. }
  2386. break;
  2387. }
  2388. case COMMAND_GOTO:{
  2389. const char* search_name = 0;
  2390. if(sep && sep->arg[0][0])
  2391. search_name = sep->argplus[0];
  2392. if(!search_name && !cmdTarget){
  2393. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /goto [name]");
  2394. 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.");
  2395. }
  2396. else{
  2397. if(!client->GotoSpawn(search_name))
  2398. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  2399. }
  2400. break;
  2401. }
  2402. case COMMAND_MOVE:{
  2403. bool success = false;
  2404. try{
  2405. if(sep && sep->arg[2][0] && sep->IsNumber(0) && sep->IsNumber(1) && sep->IsNumber(2)){
  2406. EQ2Packet* app = client->GetPlayer()->Move(atof(sep->arg[0]), atof(sep->arg[1]), atof(sep->arg[2]), client->GetVersion());
  2407. if(app){
  2408. client->QueuePacket(app);
  2409. success = true;
  2410. }
  2411. }
  2412. }
  2413. catch(...){}
  2414. if(!success){
  2415. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /move x y z");
  2416. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Moves the client to the given coordinates.");
  2417. }
  2418. break;
  2419. }
  2420. case COMMAND_SETTIME:{
  2421. if(sep && sep->arg[0]){
  2422. sscanf (sep->arg[0], "%d:%d", &world.GetWorldTimeStruct()->hour, &world.GetWorldTimeStruct()->minute);
  2423. if(sep->arg[1] && sep->IsNumber(1))
  2424. world.GetWorldTimeStruct()->month = atoi(sep->arg[1]) - 1; //zero based indexes
  2425. if(sep->arg[2] && sep->IsNumber(2))
  2426. world.GetWorldTimeStruct()->day = atoi(sep->arg[2]) - 1; //zero based indexes
  2427. if(sep->arg[3] && sep->IsNumber(3))
  2428. world.GetWorldTimeStruct()->year = atoi(sep->arg[3]);
  2429. client->GetCurrentZone()->SendTimeUpdateToAllClients();
  2430. }
  2431. else{
  2432. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /settime [hour:minute] (month) (day) (year)");
  2433. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Example: /settime 8:30");
  2434. }
  2435. break;
  2436. }
  2437. case COMMAND_VERSION:{
  2438. client->Message(CHANNEL_COLOR_YELLOW,"%s %s", EQ2EMU_MODULE, CURRENT_VERSION);
  2439. client->Message(CHANNEL_COLOR_YELLOW,"Last Compiled on %s %s", COMPILE_DATE, COMPILE_TIME);
  2440. break;
  2441. }
  2442. case COMMAND_ZONE:{
  2443. string* zonename = 0;
  2444. int32 instanceID = 0;
  2445. const char* zone = 0;
  2446. int32 zone_id = 0;
  2447. bool listSearch = false;
  2448. bool isInstance = false;
  2449. ZoneServer* zsZone = 0;
  2450. if(sep && sep->arg[0][0])
  2451. {
  2452. if(strncasecmp(sep->arg[0], "list", 4) == 0)
  2453. listSearch = true;
  2454. else if(strncasecmp(sep->arg[0], "active", 6) == 0)
  2455. {
  2456. zone_list.SendZoneList(client);
  2457. break;
  2458. }
  2459. else if(strncasecmp(sep->arg[0], "instance", 6) == 0)
  2460. {
  2461. if(sep->IsNumber(1))
  2462. instanceID = atol(sep->arg[1]);
  2463. }
  2464. else if(strncasecmp(sep->arg[0], "lock", 4) == 0)
  2465. {
  2466. PrintSep(sep, "ZONE LOCK");
  2467. if(sep->IsNumber(1))
  2468. zsZone = zone_list.Get(atoul(sep->arg[1]), false);
  2469. else
  2470. zsZone = zone_list.Get(sep->arg[1], false);
  2471. if( zsZone )
  2472. {
  2473. zsZone->SetZoneLockState(true);
  2474. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now locked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  2475. }
  2476. else
  2477. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be locked.", sep->arg[1]);
  2478. break;
  2479. }
  2480. else if(strncasecmp(sep->arg[0], "unlock", 6) == 0)
  2481. {
  2482. PrintSep(sep, "ZONE UNLOCK");
  2483. if(sep->IsNumber(1))
  2484. zsZone = zone_list.Get(atoul(sep->arg[1]), false);
  2485. else
  2486. zsZone = zone_list.Get(sep->arg[1], false);
  2487. if( zsZone )
  2488. {
  2489. zsZone->SetZoneLockState(false);
  2490. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now unlocked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  2491. }
  2492. else
  2493. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be unlocked.", sep->arg[1]);
  2494. break;
  2495. }
  2496. else
  2497. {
  2498. if(sep->IsNumber(0))
  2499. {
  2500. zone_id = atoul(sep->arg[0]);
  2501. zonename = database.GetZoneName(zone_id);
  2502. if(zonename)
  2503. zone = zonename->c_str();
  2504. }
  2505. else
  2506. zone = sep->arg[0];
  2507. }
  2508. if(instanceID > 0)
  2509. {
  2510. ZoneServer* zsInstance = zone_list.GetByInstanceID(instanceID);
  2511. if(zsInstance != NULL)
  2512. {
  2513. instanceID = zsInstance->GetInstanceID();
  2514. zone = zsInstance->GetZoneName();
  2515. zone_id = zsInstance->GetZoneID();
  2516. isInstance = true;
  2517. }
  2518. }
  2519. }
  2520. if(!listSearch)
  2521. {
  2522. if(!zone)
  2523. client->Message(CHANNEL_COLOR_RED, "Error: Invalid Zone");
  2524. else if(instanceID != client->GetCurrentZone()->GetInstanceID() ||
  2525. zone_id != client->GetCurrentZone()->GetZoneID())
  2526. {
  2527. if(database.VerifyZone(zone))
  2528. {
  2529. if(client->CheckZoneAccess(zone))
  2530. {
  2531. client->Message(CHANNEL_COLOR_YELLOW,"Zoning to %s...", zone);
  2532. if(isInstance)
  2533. client->Zone(instanceID,true,true);
  2534. else
  2535. client->Zone(zone);
  2536. }
  2537. }
  2538. else
  2539. client->Message(CHANNEL_COLOR_RED, "Error: Zone '%s' not found. To get a list type /zone list", zone);
  2540. }
  2541. else
  2542. client->Message(CHANNEL_COLOR_RED, "Error: You are already in that zone!");
  2543. }
  2544. else
  2545. {
  2546. const char* name = 0;
  2547. if(sep && sep->arg[1][0])
  2548. {
  2549. map<int32, string>* zone_names;
  2550. name = sep->argplus[1];
  2551. sint16 status = client->GetAdminStatus();
  2552. if( status > 0 )
  2553. {
  2554. client->SimpleMessage(CHANNEL_COLOR_RED, "ADMIN MODE");
  2555. zone_names = database.GetZoneList(name, true);
  2556. }
  2557. else
  2558. zone_names = database.GetZoneList(name);
  2559. if(!zone_names)
  2560. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No zones found.");
  2561. else
  2562. {
  2563. map<int32, string>::iterator itr;
  2564. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  2565. for(itr = zone_names->begin(); itr != zone_names->end(); itr++)
  2566. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  2567. safe_delete(zone_names);
  2568. }
  2569. }
  2570. else
  2571. {
  2572. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone [zone name]");
  2573. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone list [partial zone name]");
  2574. }
  2575. }
  2576. safe_delete(zonename);
  2577. break;
  2578. }
  2579. case COMMAND_USE: {
  2580. Spawn* target = cmdTarget;
  2581. if (target->IsWidget())
  2582. ((Widget*)target)->HandleUse(client, "use");
  2583. break;
  2584. }
  2585. case COMMAND_OPEN: {
  2586. Spawn* target = cmdTarget;
  2587. if (target->IsWidget())
  2588. ((Widget*)target)->HandleUse(client, "Open", WIDGET_TYPE_DOOR);
  2589. break;
  2590. }
  2591. case COMMAND_CASTSPELL: {
  2592. if (sep && sep->arg[0] && sep->IsNumber(0))
  2593. {
  2594. int8 tier = 1;
  2595. if (sep->arg[1] && sep->IsNumber(1))
  2596. tier = atoul(sep->arg[1]);
  2597. int32 spellid = atoul(sep->arg[0]);
  2598. Spell* spell = master_spell_list.GetSpell(spellid, tier);
  2599. if (spell)
  2600. {
  2601. client->Message(CHANNEL_COLOR_RED, "Casting spell %u.", spellid);
  2602. SpellProcess* spellProcess = 0;
  2603. // Get the current zones spell process
  2604. spellProcess = client->GetCurrentZone()->GetSpellProcess();
  2605. spellProcess->CastInstant(spell, (Entity*)client->GetPlayer(), (cmdTarget && cmdTarget->IsEntity()) ? (Entity*)cmdTarget : (Entity*)client->GetPlayer());
  2606. }
  2607. else
  2608. {
  2609. client->Message(CHANNEL_COLOR_RED, "Could not find spell %u.",spellid);
  2610. }
  2611. }
  2612. else if (sep && sep->arg[0])
  2613. {
  2614. database.FindSpell(client, (char*)sep->argplus[0]);
  2615. }
  2616. else
  2617. {
  2618. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellid] (tier=1) - Cast Spell with specified spell id, tier is optional, default of 1.");
  2619. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellname] - Find spells wildcard match with a partial spell name");
  2620. }
  2621. break;
  2622. }
  2623. case COMMAND_KNOWLEDGEWINDOWSORT: {
  2624. if (client->GetVersion() <= 546)
  2625. break;
  2626. if (sep && sep->GetArgNumber() == 4)
  2627. {
  2628. int32 book = atoul(sep->arg[0]); // 0 - spells, 1 - combat, 2 - abilities, 3 - tradeskill
  2629. int32 sort_by = atoul(sep->arg[1]); // 0 - alpha, 1 - level, 2 - category
  2630. int32 order = atoul(sep->arg[2]); // 0 - ascending, 1 - descending
  2631. int32 pattern = atoul(sep->arg[3]); // 0 - zigzag, 1 - down, 2 - across
  2632. int32 maxlvlonly = atoul(sep->arg[4]); // 0 - zigzag, 1 - down, 2 - across
  2633. client->GetPlayer()->ResortSpellBook(sort_by, order, pattern, maxlvlonly, book);
  2634. ClientPacketFunctions::SendSkillSlotMappings(client);
  2635. }
  2636. else
  2637. {
  2638. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /knowledgewindow_sort [book] [sort_by] [order] [pattern]");
  2639. }
  2640. break;
  2641. }
  2642. case COMMAND_MOVE_ITEM:
  2643. {
  2644. int32 id = 0;
  2645. if (sep->IsNumber(0))
  2646. id = atoul(sep->arg[0]);
  2647. Spawn* spawn = 0;
  2648. if (id == 0)
  2649. {
  2650. spawn = cmdTarget;
  2651. }
  2652. else
  2653. spawn = client->GetCurrentZone()->GetSpawnFromUniqueItemID(id);
  2654. if (!spawn || !client->HasOwnerOrEditAccess() || !spawn->GetPickupItemID())
  2655. break;
  2656. client->SendMoveObjectMode(spawn, 0);
  2657. break;
  2658. }
  2659. case COMMAND_PICKUP:
  2660. {
  2661. int32 id = 0;
  2662. if (sep->IsNumber(0))
  2663. id = atoul(sep->arg[0]);
  2664. Spawn* spawn = 0;
  2665. if (id == 0)
  2666. {
  2667. spawn = cmdTarget;
  2668. }
  2669. else
  2670. spawn = client->GetCurrentZone()->GetSpawnFromUniqueItemID(id);
  2671. if (!spawn || !client->HasOwnerOrEditAccess() || !spawn->GetPickupItemID())
  2672. break;
  2673. client->AddItem(spawn->GetPickupItemID(), 1);
  2674. Query query;
  2675. 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());
  2676. if (database.RemoveSpawnFromSpawnLocation(spawn)) {
  2677. client->GetCurrentZone()->RemoveSpawn(false, spawn, true, true);
  2678. }
  2679. // we had a UI Window displayed, update the house items
  2680. if ( id > 0 )
  2681. client->GetCurrentZone()->SendHouseItems(client);
  2682. break;
  2683. }
  2684. case COMMAND_HOUSE_DEPOSIT:
  2685. {
  2686. PrintSep(sep, "COMMAND_HOUSE_DEPOSIT");
  2687. // arg0 = ??? (set to 3)
  2688. // arg1 = coin (in copper)
  2689. // arg2 = status? (not implemented yet)
  2690. PlayerHouse* ph = world.GetPlayerHouseByInstanceID(client->GetCurrentZone()->GetInstanceID());
  2691. if (ph && sep && sep->IsNumber(1))
  2692. {
  2693. int64 outVal = strtoull(sep->arg[1], NULL, 0);
  2694. if (client->GetPlayer()->RemoveCoins(outVal))
  2695. {
  2696. char query[256];
  2697. map<string,Deposit>::iterator itr = ph->depositsMap.find(string(client->GetPlayer()->GetName()));
  2698. if (itr != ph->depositsMap.end())
  2699. {
  2700. 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());
  2701. }
  2702. else
  2703. 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);
  2704. if (database.RunQuery(query, strnlen(query, 256)))
  2705. {
  2706. ph->escrow_coins += outVal;
  2707. database.UpdateHouseEscrow(ph->house_id, ph->instance_id, ph->escrow_coins);
  2708. database.LoadDeposits(ph);
  2709. client->PlaySound("coin_cha_ching");
  2710. HouseZone* hz = world.GetHouseZone(ph->house_id);
  2711. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  2712. }
  2713. else
  2714. {
  2715. client->GetPlayer()->AddCoins(outVal);
  2716. client->SimpleMessage(CHANNEL_COLOR_RED, "Deposit failed!");
  2717. }
  2718. }
  2719. }
  2720. break;
  2721. }
  2722. case COMMAND_HOUSE:
  2723. {
  2724. if (sep && sep->IsNumber(0))
  2725. {
  2726. int32 unique_id = atoi(sep->arg[0]);
  2727. PlayerHouse* ph = world.GetPlayerHouseByUniqueID(unique_id);
  2728. HouseZone* hz = 0;
  2729. if (ph)
  2730. hz = world.GetHouseZone(ph->house_id);
  2731. // there is a arg[1] that is true/false, but not sure what it is for investigate more later
  2732. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  2733. }
  2734. else if (client->GetCurrentZone()->GetInstanceType() != 0)
  2735. {
  2736. // inside a house or something? Send the access window
  2737. PlayerHouse* ph = world.GetPlayerHouseByInstanceID(client->GetCurrentZone()->GetInstanceID());
  2738. HouseZone* hz = 0;
  2739. if ( ph )
  2740. hz = world.GetHouseZone(ph->house_id);
  2741. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  2742. client->GetCurrentZone()->SendHouseItems(client);
  2743. }
  2744. break;
  2745. }
  2746. case COMMAND_HOUSE_UI:
  2747. {
  2748. if (sep && sep->IsNumber(0) && client->GetCurrentZone()->GetInstanceType() == Instance_Type::NONE)
  2749. {
  2750. int32 unique_id = atoi(sep->arg[0]);
  2751. PlayerHouse* ph = world.GetPlayerHouseByUniqueID(unique_id);
  2752. HouseZone* hz = 0;
  2753. if ( ph )
  2754. hz = world.GetHouseZone(ph->house_id);
  2755. // there is a arg[1] that is true/false, but not sure what it is for investigate more later
  2756. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, 0);
  2757. }
  2758. break;
  2759. }
  2760. case COMMAND_PLACE_HOUSE_ITEM: {
  2761. if (sep && sep->IsNumber(0))
  2762. {
  2763. int32 uniqueid = atoi(sep->arg[0]);
  2764. Item* item = client->GetPlayer()->item_list.GetItemFromUniqueID(uniqueid);
  2765. //Item* item = player->GetEquipmentList()->GetItem(slot);
  2766. if (item && item->IsHouseItem())
  2767. {
  2768. if (!client->HasOwnerOrEditAccess())
  2769. {
  2770. client->SimpleMessage(CHANNEL_COLOR_RED, "This is not your home!");
  2771. break;
  2772. }
  2773. else if (!item->generic_info.appearance_id)
  2774. {
  2775. 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);
  2776. break;
  2777. }
  2778. if (client->GetTempPlacementSpawn())
  2779. {
  2780. Spawn* tmp = client->GetTempPlacementSpawn();
  2781. client->GetCurrentZone()->RemoveSpawn(false, tmp);
  2782. delete tmp;
  2783. client->SetTempPlacementSpawn(nullptr);
  2784. }
  2785. Spawn* spawn = new Object();
  2786. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  2787. spawn->SetID(Spawn::NextID());
  2788. spawn->SetX(client->GetPlayer()->GetX());
  2789. spawn->SetY(client->GetPlayer()->GetY());
  2790. spawn->SetZ(client->GetPlayer()->GetZ());
  2791. spawn->SetHeading(client->GetPlayer()->GetHeading());
  2792. spawn->SetSpawnOrigX(spawn->GetX());
  2793. spawn->SetSpawnOrigY(spawn->GetY());
  2794. spawn->SetSpawnOrigZ(spawn->GetZ());
  2795. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  2796. spawn->appearance.targetable = 1;
  2797. spawn->appearance.activity_status = ACTIVITY_STATUS_SOLID;
  2798. spawn->appearance.race = item && item->generic_info.appearance_id ? item->generic_info.appearance_id : 1472;
  2799. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  2800. spawn->SetModelType(item && item->generic_info.appearance_id ? item->generic_info.appearance_id : 1472);
  2801. spawn->SetZone(client->GetCurrentZone());
  2802. client->GetCurrentZone()->SendSpawn(spawn, client);
  2803. client->SetTempPlacementSpawn(spawn);
  2804. client->SetPlacementUniqueItemID(uniqueid);
  2805. client->SendMoveObjectMode(spawn, 0);
  2806. }
  2807. }
  2808. break;
  2809. }
  2810. case COMMAND_GM:
  2811. {
  2812. if (sep->arg[0] && sep->arg[1])
  2813. {
  2814. bool onOff = (strcmp(sep->arg[1], "on") == 0);
  2815. if (strcmp(sep->arg[0], "vision") == 0)
  2816. {
  2817. client->GetPlayer()->SetGMVision(onOff);
  2818. #if defined(__GNUC__)
  2819. database.insertCharacterProperty(client, CHAR_PROPERTY_GMVISION, (onOff) ? (char*)"1" : (char*)"0");
  2820. #else
  2821. database.insertCharacterProperty(client, CHAR_PROPERTY_GMVISION, (onOff) ? "1" : "0");
  2822. #endif
  2823. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  2824. if (onOff)
  2825. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Vision Enabled!");
  2826. else
  2827. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Vision Disabled!");
  2828. }
  2829. else if (strcmp(sep->arg[0], "luadebug") == 0)
  2830. {
  2831. client->SetLuaDebugClient(onOff);
  2832. #if defined(__GNUC__)
  2833. database.insertCharacterProperty(client, CHAR_PROPERTY_LUADEBUG, (onOff) ? (char*)"1" : (char*)"0");
  2834. #else
  2835. database.insertCharacterProperty(client, CHAR_PROPERTY_LUADEBUG, (onOff) ? "1" : "0");
  2836. #endif
  2837. if (onOff)
  2838. {
  2839. if (lua_interface)
  2840. lua_interface->UpdateDebugClients(client);
  2841. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will now receive LUA error messages.");
  2842. }
  2843. else
  2844. {
  2845. if (lua_interface)
  2846. lua_interface->RemoveDebugClients(client);
  2847. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will no longer receive LUA error messages.");
  2848. }
  2849. }
  2850. }
  2851. break;
  2852. }
  2853. case COMMAND_ATTACK:
  2854. case COMMAND_AUTO_ATTACK:{
  2855. int8 type = 1;
  2856. Player* player = client->GetPlayer();
  2857. if(!player)
  2858. break;
  2859. bool incombat = player->EngagedInCombat();
  2860. if(sep && sep->arg[0] && sep->IsNumber(0))
  2861. type = atoi(sep->arg[0]);
  2862. if(client->GetPlayer()->GetHP() == 0){
  2863. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  2864. break;
  2865. }
  2866. if(type == 0){
  2867. if(incombat)
  2868. client->SimpleMessage(CHANNEL_COLOR_COMBAT, "You stop fighting.");
  2869. player->InCombat(false);
  2870. player->InCombat(false, true);
  2871. player->SetRangeAttack(false);
  2872. }
  2873. else {
  2874. if(type == 2){
  2875. player->InCombat(false);
  2876. if(incombat && player->GetRangeAttack()){
  2877. player->SetRangeAttack(false);
  2878. player->InCombat(false, true);
  2879. client->SimpleMessage(CHANNEL_COLOR_COMBAT, "You stop fighting.");
  2880. }
  2881. else{
  2882. player->SetRangeAttack(true);
  2883. player->InCombat(true, true);
  2884. client->SimpleMessage(CHANNEL_COLOR_COMBAT, "You start fighting.");
  2885. }
  2886. }
  2887. else {
  2888. player->InCombat(false, true);
  2889. player->SetRangeAttack(false);
  2890. player->InCombat(true);
  2891. if(!incombat)
  2892. client->SimpleMessage(CHANNEL_COLOR_COMBAT, "You start fighting.");
  2893. }
  2894. /*else
  2895. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You cannot attack that!");*/
  2896. }
  2897. player->SetCharSheetChanged(true);
  2898. break;
  2899. }
  2900. case COMMAND_DEPOP:{
  2901. bool allow_respawns = false;
  2902. if(sep && sep->arg[0] && sep->IsNumber(0)){
  2903. if(atoi(sep->arg[0]) == 1)
  2904. allow_respawns = true;
  2905. }
  2906. client->GetCurrentZone()->Depop(allow_respawns);
  2907. break;
  2908. }
  2909. case COMMAND_REPOP:{
  2910. client->GetCurrentZone()->Depop(false, true);
  2911. break;
  2912. }
  2913. case COMMAND_BUYBACK:{
  2914. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  2915. // 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
  2916. int64 id = atoi64(sep->arg[0]);
  2917. // get the first int32, the item id
  2918. //int32 item_id = (int32)id;
  2919. // get the second int32, the unique id
  2920. int32 unique_id = (int32)(id>>32);
  2921. int8 quantity = atoi(sep->arg[1]);
  2922. if(quantity == 255)
  2923. quantity = 1;
  2924. client->BuyBack(unique_id, quantity);
  2925. }
  2926. break;
  2927. }
  2928. case COMMAND_MERCHANT_BUY:{
  2929. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  2930. int32 item_id = atoul(sep->arg[0]);
  2931. int8 quantity = atoi(sep->arg[1]);
  2932. client->BuyItem(item_id, quantity);
  2933. }
  2934. break;
  2935. }
  2936. case COMMAND_MERCHANT_SELL:{
  2937. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  2938. // 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
  2939. int64 id = atoi64(sep->arg[0]);
  2940. // get the first int32, the item id
  2941. int32 item_id = (int32)id;
  2942. // get the second int32, the unique id
  2943. int32 unique_id = (int32)(id>>32);
  2944. int8 quantity = atoi(sep->arg[1]);
  2945. LogWrite(MERCHANT__DEBUG, 0, "Merchant", "Selling Item: Item Id = %ul, unique id = %ul, Quantity = %i", item_id, unique_id, quantity);
  2946. client->SellItem(item_id, quantity, unique_id);
  2947. }
  2948. break;
  2949. }
  2950. case COMMAND_MENDER_REPAIR: {
  2951. if (sep && sep->arg[0] && sep->IsNumber(0))
  2952. client->RepairItem(atoul(sep->arg[0]));
  2953. break;
  2954. }
  2955. case COMMAND_MENDER_REPAIR_ALL: {
  2956. client->RepairAllItems();
  2957. break;
  2958. }
  2959. case COMMAND_CANCEL_MERCHANT:{
  2960. client->SetMerchantTransaction(0);
  2961. break;
  2962. }
  2963. case COMMAND_START_MERCHANT:{
  2964. break;
  2965. }
  2966. case COMMAND_INVULNERABLE:{
  2967. sint8 val = -1;
  2968. if(sep && sep->arg[0] && sep->IsNumber(0)){
  2969. val = atoi(sep->arg[0]);
  2970. //devn00b: Fix for linux builds
  2971. #if defined(__GNUC__)
  2972. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? (char*) "1" : (char*) "0");
  2973. #else
  2974. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  2975. #endif
  2976. // database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  2977. client->GetPlayer()->SetInvulnerable(val==1);
  2978. if(client->GetPlayer()->GetInvulnerable())
  2979. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are now invulnerable!");
  2980. else
  2981. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are no longer invulnerable!");
  2982. }
  2983. if(val == -1)
  2984. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /invulnerable [0/1]");
  2985. break;
  2986. }
  2987. case COMMAND_REPAIR: {
  2988. Spawn* spawn = cmdTarget;
  2989. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR) {
  2990. client->SendHailCommand(spawn);
  2991. client->SetMerchantTransaction(spawn);
  2992. client->SendRepairList();
  2993. }
  2994. break;
  2995. }
  2996. case COMMAND_LOTTO: {
  2997. Spawn* spawn = cmdTarget;
  2998. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_LOTTO) {
  2999. client->SetMerchantTransaction(spawn);
  3000. client->ShowLottoWindow();
  3001. }
  3002. break;
  3003. }
  3004. case COMMAND_ACCEPT_REWARD:{
  3005. int32 unknown = 0;
  3006. int32 selectable_item_id = 0;
  3007. //Quest *quest = 0;
  3008. Collection *collection = 0;
  3009. /* no idea what the first argument is for (faction maybe?)
  3010. if the reward has a selectable item reward, it's sent as the second argument
  3011. if neither of these are included in the reward, there is no sep
  3012. 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
  3013. only 1 quest or collection reward may be displayed at a time */
  3014. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  3015. unknown = atoul(sep->arg[0]);
  3016. selectable_item_id = atoul(sep->arg[1]);
  3017. }
  3018. //if ((quest = player->GetPendingQuestReward()))
  3019. // client->AcceptQuestRewards(quest, selectable_item_id);
  3020. /* the below needs to go away eventually and be redone */
  3021. int32 item_id = 0;
  3022. if(sep && sep->arg[0][0] && sep->IsNumber(0))
  3023. item_id = atoul(sep->arg[0]);
  3024. Quest* quest = client->GetPendingQuestAcceptance(item_id);
  3025. if(quest){
  3026. client->AcceptQuestReward(quest, item_id);
  3027. break;
  3028. }
  3029. if (collection = player->GetPendingCollectionReward())
  3030. client->AcceptCollectionRewards(collection, selectable_item_id);
  3031. else
  3032. LogWrite(COMMAND__ERROR, 0, "Command", "Error in COMMAND_ACCEPT_REWARD. No pending quest or collection reward was found (unknown=%u).", unknown);
  3033. break;
  3034. }
  3035. case COMMAND_BUY_FROM_BROKER:{
  3036. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  3037. int32 item_id = atoul(sep->arg[0]);
  3038. int16 quantity = atoul(sep->arg[1]);
  3039. client->AddItem(item_id, quantity);
  3040. }
  3041. break;
  3042. }
  3043. case COMMAND_SEARCH_STORES_PAGE:{
  3044. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  3045. int32 page = atoul(sep->arg[0]);
  3046. client->SearchStore(page);
  3047. }
  3048. break;
  3049. }
  3050. case COMMAND_SEARCH_STORES:{
  3051. if(sep && sep->arg[0][0]){
  3052. const char* values = sep->argplus[0];
  3053. if(values){
  3054. map<string, string> str_values = TranslateBrokerRequest(values);
  3055. vector<Item*>* items = master_item_list.GetItems(str_values);
  3056. if(items){
  3057. client->SetItemSearch(items);
  3058. client->SearchStore(0);
  3059. }
  3060. }
  3061. }
  3062. break;
  3063. }
  3064. case COMMAND_LUADEBUG:{
  3065. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "start") == 0){
  3066. client->SetLuaDebugClient(true);
  3067. if(lua_interface)
  3068. lua_interface->UpdateDebugClients(client);
  3069. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will now receive LUA error messages.");
  3070. }
  3071. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "stop") == 0){
  3072. client->SetLuaDebugClient(false);
  3073. if(lua_interface)
  3074. lua_interface->RemoveDebugClients(client);
  3075. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will no longer receive LUA error messages.");
  3076. }
  3077. else{
  3078. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /luadebug {start | stop}");
  3079. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will allow you to receive lua debug messages normally seen only in the console.");
  3080. }
  3081. break;
  3082. }
  3083. case COMMAND_SPAWN_GROUP:
  3084. {
  3085. Spawn* target = cmdTarget;
  3086. if(target && target->IsPlayer() == false)
  3087. {
  3088. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "create") == 0)
  3089. {
  3090. if(target->GetSpawnLocationPlacementID() > 0)
  3091. {
  3092. if(sep->arg[1] && !sep->IsNumber(1) && strlen(sep->arg[1]) > 0)
  3093. {
  3094. int32 id = database.CreateSpawnGroup(target, sep->arg[1]);
  3095. if(id > 0)
  3096. client->Message(CHANNEL_COLOR_YELLOW, "Successfully created new spawn group with id: %u", id);
  3097. else
  3098. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error creating group, check console for details.");
  3099. target->SetSpawnGroupID(id);
  3100. target->AddSpawnToGroup(target);
  3101. }
  3102. else
  3103. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group create [name]");
  3104. }
  3105. else
  3106. 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.");
  3107. }
  3108. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "add") == 0)
  3109. {
  3110. if(sep->arg[1] && sep->IsNumber(1))
  3111. {
  3112. int32 group_id = atoul(sep->arg[1]);
  3113. Spawn* leader = client->GetCurrentZone()->GetSpawnGroup(group_id);
  3114. if(leader)
  3115. {
  3116. leader->AddSpawnToGroup(target);
  3117. target->SetSpawnGroupID(group_id);
  3118. if(database.SpawnGroupAddSpawn(target, group_id))
  3119. client->Message(CHANNEL_COLOR_YELLOW, "Successfully added '%s' to group id: %u", target->GetName(), group_id);
  3120. else
  3121. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error adding spawn to group, check console for details.");
  3122. }
  3123. else
  3124. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No spawns found in the current zone for that spawn group, be sure to use '/spawn group create' first!");
  3125. }
  3126. else
  3127. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group add [group id]");
  3128. }
  3129. else if(target->GetSpawnGroupID() == 0)
  3130. {
  3131. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That spawn is not in a group!");
  3132. }
  3133. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "remove") == 0)
  3134. {
  3135. int32 group_id = target->GetSpawnGroupID();
  3136. target->RemoveSpawnFromGroup();
  3137. if(database.SpawnGroupRemoveSpawn(target, group_id))
  3138. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed '%s' from group id: %u", target->GetName(), group_id);
  3139. else
  3140. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing spawn from group, check console for details.");
  3141. }
  3142. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "associate") == 0)
  3143. {
  3144. int32 group_id = target->GetSpawnGroupID();
  3145. if(sep->arg[1] && sep->IsNumber(1))
  3146. {
  3147. if(database.SpawnGroupAddAssociation(group_id, atoul(sep->arg[1])))
  3148. client->Message(CHANNEL_COLOR_YELLOW, "Successfully associated group id %u with group id %u", group_id, atoul(sep->arg[1]));
  3149. else
  3150. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error associating groups, check console for details.");
  3151. }
  3152. else
  3153. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Allows you to spawn only one associated group at once. Syntax: /spawn group associate [other group id]");
  3154. }
  3155. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "deassociate") == 0)
  3156. {
  3157. int32 group_id = target->GetSpawnGroupID();
  3158. if(sep->arg[1] && sep->IsNumber(1))
  3159. {
  3160. if(database.SpawnGroupRemoveAssociation(group_id, atoul(sep->arg[1])))
  3161. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed association between group id %u and group id %u", group_id, atoul(sep->arg[1]));
  3162. else
  3163. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing group associations, check console for details.");
  3164. }
  3165. else
  3166. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Removes previous group associations. Syntax: /spawn group deassociate [other group id]");
  3167. }
  3168. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "chance") == 0)
  3169. {
  3170. if(sep->arg[1] && sep->IsNumber(1))
  3171. {
  3172. if(database.SetGroupSpawnChance(target->GetSpawnGroupID(), atof(sep->arg[1])))
  3173. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set group spawn chance to %f for group id: %u", atof(sep->arg[1]), target->GetSpawnGroupID());
  3174. else
  3175. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error setting group spawn chance, check console for details.");
  3176. }
  3177. else
  3178. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group chance [group's spawn chance percentage]");
  3179. }
  3180. else
  3181. {
  3182. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command allows you to modify spawn groups.");
  3183. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group [create/add/remove/chance/associate/deassociate]");
  3184. }
  3185. }
  3186. else
  3187. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select a valid spawn to use this command.");
  3188. break;
  3189. }
  3190. case COMMAND_SPAWN_COMBINE:{
  3191. Spawn* spawn = cmdTarget;
  3192. float radius = 0;
  3193. bool failed = true;
  3194. if(spawn && !spawn->IsPlayer() && sep && sep->arg[0] && sep->arg[0][0]){
  3195. failed = false;
  3196. if(spawn->GetSpawnGroupID() > 0){
  3197. 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.");
  3198. }
  3199. else if(sep->IsNumber(0)){
  3200. radius = atof(sep->arg[0]);
  3201. client->CombineSpawns(radius, spawn);
  3202. }
  3203. else{
  3204. if(strncasecmp(sep->arg[0], "add", 3) == 0){
  3205. client->AddCombineSpawn(spawn);
  3206. }
  3207. else if(strncasecmp(sep->arg[0], "remove", 6) == 0){
  3208. client->RemoveCombineSpawn(spawn);
  3209. }
  3210. else if(strncasecmp(sep->arg[0], "save", 4) == 0){
  3211. const char* name = 0;
  3212. if(sep->arg[1] && sep->arg[1][0])
  3213. name = sep->argplus[1];
  3214. client->SaveCombineSpawns(name);
  3215. }
  3216. else
  3217. failed = true;
  3218. }
  3219. }
  3220. if(failed){
  3221. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command combines several spawns into a single spawn group.");
  3222. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn combine [radius/add/remove/save]");
  3223. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Ex: /spawn combine 1, /spawn combine save (spawn group name)");
  3224. }
  3225. break;
  3226. }
  3227. case COMMAND_SPAWN_CREATE:{
  3228. Spawn* spawn = 0;
  3229. if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "object", 6) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  3230. spawn = new Object();
  3231. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3232. }
  3233. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "groundspawn", 11) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  3234. spawn = new GroundSpawn();
  3235. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3236. }
  3237. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "sign", 4) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  3238. spawn = new Sign();
  3239. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3240. }
  3241. else if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "npc", 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  3242. spawn = new NPC();
  3243. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3244. spawn->appearance.pos.collision_radius = 32;
  3245. spawn->secondary_command_list_id = 0;
  3246. spawn->primary_command_list_id = 0;
  3247. spawn->appearance.display_name = 1;
  3248. spawn->appearance.show_level = 1;
  3249. spawn->appearance.attackable = 1;
  3250. }
  3251. else{
  3252. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn create [spawn type] [race type] [class type] [level] [name] (difficulty) (size)");
  3253. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are required except difficulty and size. Valid types are Object, NPC, Sign, or GroundSpawn");
  3254. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn create npc 203 1 50 'Lady Vox' 1 32");
  3255. break;
  3256. }
  3257. spawn->SetID(Spawn::NextID());
  3258. spawn->SetX(client->GetPlayer()->GetX());
  3259. spawn->SetY(client->GetPlayer()->GetY());
  3260. spawn->SetZ(client->GetPlayer()->GetZ());
  3261. spawn->SetHeading(client->GetPlayer()->GetHeading());
  3262. spawn->SetSpawnOrigX(spawn->GetX());
  3263. spawn->SetSpawnOrigY(spawn->GetY());
  3264. spawn->SetSpawnOrigZ(spawn->GetZ());
  3265. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  3266. spawn->appearance.targetable = 1;
  3267. spawn->appearance.race = 255;
  3268. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  3269. spawn->SetModelType(atoi(sep->arg[1]));
  3270. spawn->SetAdventureClass(atoi(sep->arg[2]));
  3271. spawn->SetLevel(atoi(sep->arg[3]));
  3272. spawn->SetName(sep->arg[4]);
  3273. if(sep->arg[5][0] && sep->IsNumber(5))
  3274. spawn->SetEncounterLevel(atoi(sep->arg[5]));
  3275. if(sep->arg[6][0] && sep->IsNumber(6))
  3276. spawn->size = atoi(sep->arg[6]);
  3277. if(spawn->GetTotalHP() == 0){
  3278. spawn->SetTotalHP(25*spawn->GetLevel() + 1);
  3279. spawn->SetHP(25*spawn->GetLevel() + 1);
  3280. }
  3281. if(spawn->GetTotalPower() == 0){
  3282. spawn->SetTotalPower(25*spawn->GetLevel() + 1);
  3283. spawn->SetPower(25*spawn->GetLevel() + 1);
  3284. }
  3285. client->GetCurrentZone()->AddSpawn(spawn);
  3286. break;
  3287. }
  3288. case COMMAND_SPAWN_EQUIPMENT:{
  3289. Spawn* spawn = cmdTarget;
  3290. if(spawn && sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1) && spawn->IsEntity()){
  3291. int8 slot = atoi(sep->arg[0]);
  3292. int16 type = atoi(sep->arg[1]);
  3293. int8 red = 0;
  3294. int8 green = 0;
  3295. int8 blue = 0;
  3296. int8 h_red = 0;
  3297. int8 h_green = 0;
  3298. int8 h_blue = 0;
  3299. if(sep->arg[2])
  3300. red = atoi(sep->arg[2]);
  3301. if(sep->arg[3])
  3302. green = atoi(sep->arg[3]);
  3303. if(sep->arg[4])
  3304. blue = atoi(sep->arg[4]);
  3305. if(sep->arg[5])
  3306. h_red = atoi(sep->arg[5]);
  3307. if(sep->arg[6])
  3308. h_green = atoi(sep->arg[6]);
  3309. if(sep->arg[7])
  3310. h_blue = atoi(sep->arg[7]);
  3311. ((Entity*)spawn)->SetEquipment(slot, type, red, green, blue, h_red, h_green, h_blue);
  3312. database.SaveNPCAppearanceEquipment(spawn->GetDatabaseID() , slot, type, red, green, blue, h_red, h_green, h_blue);
  3313. }
  3314. else{
  3315. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn equipment [slot] [appearance id] (red) (green) (blue) (highlight red) (hgreen) (hblue)");
  3316. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn's equipment. ");
  3317. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Slot is 0-24, Appearance ID from appearances table, Colors are 0-255");
  3318. }
  3319. break;
  3320. }
  3321. case COMMAND_SPAWN_DETAILS:{
  3322. Spawn* spawn = cmdTarget;
  3323. if (sep && sep->arg[0][0]) {
  3324. if (cmdTarget)
  3325. {
  3326. if (ToLower(string(sep->arg[0])) == "los")
  3327. {
  3328. bool hasLOS = client->GetPlayer()->CheckLoS(cmdTarget);
  3329. if (hasLOS)
  3330. client->Message(CHANNEL_COLOR_YELLOW, "You have line of sight with %s", spawn->GetName());
  3331. else
  3332. client->Message(CHANNEL_COLOR_RED, "You DO NOT have line of sight with %s", spawn->GetName());
  3333. break;
  3334. }
  3335. else if (ToLower(string(sep->arg[0])) == "bestz")
  3336. {
  3337. glm::vec3 targPos(cmdTarget->GetX(), cmdTarget->GetZ(), cmdTarget->GetY());
  3338. float bestZ = client->GetPlayer()->FindDestGroundZ(targPos, cmdTarget->GetYOffset());
  3339. client->Message(CHANNEL_COLOR_YELLOW, "Best Z for %s is %f", spawn->GetName(), bestZ);
  3340. break;
  3341. }
  3342. else if (ToLower(string(sep->arg[0])) == "pathto")
  3343. {
  3344. break;
  3345. }
  3346. else if (ToLower(string(sep->arg[0])) == "pathfrom")
  3347. {
  3348. break;
  3349. }
  3350. }
  3351. if (sep->IsNumber(0))
  3352. {
  3353. float radius = atof(sep->arg[0]);
  3354. if (!client->GetCurrentZone()->SendRadiusSpawnInfo(client, radius))
  3355. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No results in the radius were found.");
  3356. break;
  3357. }
  3358. }
  3359. if(spawn){
  3360. const char* type = "NPC";
  3361. if(spawn->IsObject())
  3362. type = "Object";
  3363. else if(spawn->IsSign())
  3364. type = "Sign";
  3365. else if(spawn->IsWidget())
  3366. type = "Widget";
  3367. else if(spawn->IsGroundSpawn())
  3368. type = "GroundSpawn";
  3369. client->Message(CHANNEL_COLOR_YELLOW, "Name: %s, %s ID: %u", spawn->GetName(), type, spawn->GetDatabaseID());
  3370. client->Message(CHANNEL_COLOR_YELLOW, "Last Name: %s, Sub-Title: %s, Prefix: %s, Suffix: %s", spawn->GetLastName(), spawn->GetSubTitle(), spawn->GetPrefixTitle(), spawn->GetSuffixTitle());
  3371. client->Message(CHANNEL_COLOR_YELLOW, "Spawn Location ID: %u, Spawn Group ID: %u", spawn->GetSpawnLocationID(), spawn->GetSpawnGroupID());
  3372. client->Message(CHANNEL_COLOR_YELLOW, "Faction ID: %u, Merchant ID: %u, Transporter ID: %u", spawn->GetFactionID(), spawn->GetMerchantID(), spawn->GetTransporterID());
  3373. client->Message(CHANNEL_COLOR_YELLOW, "Grid ID: %u", spawn->GetLocation());
  3374. client->Message(CHANNEL_COLOR_YELLOW, "Race: %i, Class: %i, Gender: %i", spawn->GetRace(), spawn->GetAdventureClass(), spawn->GetGender());
  3375. client->Message(CHANNEL_COLOR_YELLOW, "Level: %i, HP: %u, Power: %u", spawn->GetLevel(), spawn->GetHP(), spawn->GetPower());
  3376. 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());
  3377. client->Message(CHANNEL_COLOR_YELLOW, "Collision Radius: %i, Size: %i, Difficulty: %i, Heroic: %i", spawn->GetCollisionRadius(), spawn->GetSize(), spawn->GetEncounterLevel(), spawn->GetHeroic());
  3378. client->Message(CHANNEL_COLOR_YELLOW, "Targetable: %i, Show Name: %i, Attackable: %i, Show Level: %i", spawn->GetTargetable(), spawn->GetShowName(), spawn->GetAttackable(), spawn->GetShowLevel());
  3379. client->Message(CHANNEL_COLOR_YELLOW, "Show Command Icon: %i, Display Hand Icon: %i", spawn->GetShowCommandIcon(), spawn->GetShowHandIcon());
  3380. if(spawn->IsEntity()){
  3381. 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());
  3382. 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());
  3383. }
  3384. client->Message(CHANNEL_COLOR_YELLOW, "Model Type: %i, Soga Race Type: %i", spawn->GetModelType(), spawn->GetSogaModelType());
  3385. client->Message(CHANNEL_COLOR_YELLOW, "Primary Command Type: %u, Secondary Command Type: %u", spawn->GetPrimaryCommandListID(), spawn->GetSecondaryCommandListID());
  3386. 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());
  3387. 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);
  3388. if (spawn->IsNPC())
  3389. client->Message(CHANNEL_COLOR_YELLOW, "Randomize: %u", ((NPC*)spawn)->GetRandomize());
  3390. PacketStruct* packet = configReader.getStruct("WS_EqShowBook", client->GetVersion());
  3391. if (packet) {
  3392. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  3393. string title = string(spawn->GetName()) + "(" + to_string(spawn->GetDatabaseID()) + ")";
  3394. packet->setDataByName("book_title", title.c_str());
  3395. packet->setDataByName("book_type", "simple");
  3396. packet->setDataByName("unknown2", 1);
  3397. packet->setDataByName("unknown5", 1, 4);
  3398. packet->setArrayLengthByName("num_pages", 4);
  3399. string details;
  3400. details += "\\#0000FFName: " + string(spawn->GetName()) + "\n";
  3401. details += "Type: " + string(type) + "\n";
  3402. details += "ID: " + to_string(spawn->GetDatabaseID()) + "\n";
  3403. details += "Last Name: " + string(spawn->GetLastName()) + "\n";
  3404. details += "Sub-Title: " + string(spawn->GetSubTitle()) + "\n";
  3405. details += "Prefix: " + string(spawn->GetPrefixTitle()) + "\n";
  3406. details += "Suffix: " + string(spawn->GetSuffixTitle()) + "\n";
  3407. details += "Race: " + to_string(spawn->GetRace()) + "\n";
  3408. details += "Class: " + to_string(spawn->GetAdventureClass()) + "\n";
  3409. details += "Gender: " + to_string(spawn->GetGender()) + "\n";
  3410. details += "Level: " + to_string(spawn->GetLevel()) + "\n";
  3411. details += "HP: " + to_string(spawn->GetHP()) + "\n";
  3412. details += "Power: " + to_string(spawn->GetPower()) + "\n";
  3413. details += "Difficulty: " + to_string(spawn->GetEncounterLevel()) + "\n";
  3414. details += "Heroic: " + to_string(spawn->GetHeroic()) + "\n";
  3415. details += "Group ID: " + to_string(spawn->GetSpawnGroupID()) + "\n";
  3416. details += "Faction ID: " + to_string(spawn->GetFactionID()) + "\n";
  3417. details += "Merchant ID: " + to_string(spawn->GetMerchantID()) + "\n";
  3418. details += "Transport ID: " + to_string(spawn->GetTransporterID()) + "\n";
  3419. details += "Location ID: " + to_string(spawn->GetSpawnLocationID()) + "\n";
  3420. char x[16];
  3421. sprintf(x, "%.2f", spawn->GetX());
  3422. char y[16];
  3423. sprintf(y, "%.2f", spawn->GetY());
  3424. char z[16];
  3425. sprintf(z, "%.2f", spawn->GetZ());
  3426. details += "Location: " + string(x) + ", " + string(y) + ", " + string(z) + "\n";
  3427. string details2;
  3428. details2 += "Heading: " + to_string(spawn->GetHeading()) + "\n";
  3429. details2 += "Grid ID: " + to_string(spawn->GetLocation()) + "\n";
  3430. details2 += "Size: " + to_string(spawn->GetSize()) + "\n";
  3431. details2 += "Collision Radius: " + to_string(spawn->GetCollisionRadius()) + "\n";
  3432. details2 += "Respawn Time: " + to_string(spawn->GetRespawnTime()) + "\n";
  3433. details2 += "Targetable: " + to_string(spawn->GetTargetable()) + "\n";
  3434. details2 += "Show Name: " + to_string(spawn->GetShowName()) + "\n";
  3435. details2 += "Attackable: " + to_string(spawn->GetAttackable()) + "\n";
  3436. details2 += "Show Level: " + to_string(spawn->GetShowLevel()) + "\n";
  3437. details2 += "Show Command Icon: " + to_string(spawn->GetShowCommandIcon()) + "\n";
  3438. details2 += "Display Hand Icon: " + to_string(spawn->GetShowHandIcon()) + "\n";
  3439. details2 += "Model Type: " + to_string(spawn->GetModelType()) + "\n";
  3440. details2 += "Soga Race Type: " + to_string(spawn->GetSogaModelType()) + "\n";
  3441. details2 += "Primary Command ID: " + to_string(spawn->GetPrimaryCommandListID()) + "\n";
  3442. details2 += "Secondary Cmd ID: " + to_string(spawn->GetSecondaryCommandListID()) + "\n";
  3443. details2 += "Visual State: " + to_string(spawn->GetVisualState()) + "\n";
  3444. details2 += "Action State: " + to_string(spawn->GetActionState()) + "\n";
  3445. details2 += "Mood State: " + to_string(spawn->GetMoodState()) + "\n";
  3446. details2 += "Initial State: " + to_string(spawn->GetInitialState()) + "\n";
  3447. details2 += "Activity Status: " + to_string(spawn->GetActivityStatus()) + "\n";
  3448. details2 += "Emote State: " + to_string(spawn->GetEmoteState()) + "\n";
  3449. string details3;
  3450. details3 += "Pitch: " + to_string(spawn->GetPitch()) + "\n";
  3451. details3 += "Roll: " + to_string(spawn->GetRoll()) + "\n";
  3452. details3 += "Hide Hood: " + to_string(spawn->appearance.hide_hood) + "\n";
  3453. string details4;
  3454. if (spawn->IsEntity()) {
  3455. details4 += "Facial Hair Type: " + to_string(((Entity*)spawn)->GetFacialHairType()) + "\n";
  3456. details4 += "Hair Type: " + to_string(((Entity*)spawn)->GetHairType()) + "\n";
  3457. details4 += "Chest Type: " + to_string(((Entity*)spawn)->GetChestType()) + "\n";
  3458. details4 += "Legs Type: " + to_string(((Entity*)spawn)->GetLegsType()) + "\n";
  3459. details4 += "Soga Facial Hair Type: " + to_string(((Entity*)spawn)->GetSogaFacialHairType()) + "\n";
  3460. details4 += "Soga Hair Type: " + to_string(((Entity*)spawn)->GetSogaHairType()) + "\n";
  3461. details4 += "Wing Type: " + to_string(((Entity*)spawn)->GetWingType()) + "\n";
  3462. if (spawn->IsNPC()) {
  3463. details4 += "\nRandomize: " + to_string(((NPC*)spawn)->GetRandomize()) + "\n";
  3464. }
  3465. }
  3466. //details2 += "" + to_string() + "\n";
  3467. packet->setArrayDataByName("page_text", details.c_str());
  3468. packet->setArrayDataByName("page_text", details2.c_str(), 1);
  3469. packet->setArrayDataByName("page_text", details3.c_str(), 2);
  3470. packet->setArrayDataByName("page_text", details4.c_str(), 3);
  3471. client->QueuePacket(packet->serialize());
  3472. safe_delete(packet);
  3473. }
  3474. }
  3475. else {
  3476. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn details (radius)");
  3477. 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.");
  3478. }
  3479. break;
  3480. }
  3481. case COMMAND_SPAWN_TARGET:{
  3482. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  3483. int32 spawn_id = atoul(sep->arg[0]);
  3484. int16 response = client->GetCurrentZone()->SetSpawnTargetable(spawn_id);
  3485. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  3486. }
  3487. else if(sep && sep->arg[0][0] && sep->arg[1][0] && sep->IsNumber(1) && ToLower(string(sep->arg[0])) == "radius"){
  3488. float distance = atof(sep->arg[1]);
  3489. int16 response = client->GetCurrentZone()->SetSpawnTargetable(client->GetPlayer(), distance);
  3490. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  3491. }
  3492. else{
  3493. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn target [spawn id]");
  3494. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn as targetable. Used to change a spawn if it was set to untargetable.");
  3495. }
  3496. break;
  3497. }
  3498. case COMMAND_SPAWN_SET:
  3499. {
  3500. Spawn* spawn = cmdTarget;
  3501. sint16 set_type = -1;
  3502. string type_str;
  3503. if (spawn)
  3504. {
  3505. // check if parameters are (location or list or not player and not a 2nd param), and that there is at least 1 value
  3506. 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)
  3507. {
  3508. // set the type, which will be 0 if location or list or invalid
  3509. set_type = spawn_set_values[ToLower(string(sep->arg[0]))];
  3510. }
  3511. if(set_type > 0)
  3512. {
  3513. // check if spawn set is NOT a char update, or not location, or isn't a number
  3514. 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)
  3515. {
  3516. client->SimpleMessage(CHANNEL_COLOR_RED, "Invalid value for set command.");
  3517. }
  3518. else
  3519. {
  3520. string name = string(spawn->GetName());
  3521. if(SetSpawnCommand(client, spawn, set_type, sep->arg[1]))
  3522. {
  3523. if (set_type == SPAWN_SET_VALUE_EXPANSION_FLAG || set_type == SPAWN_SET_VALUE_HOLIDAY_FLAG)
  3524. {
  3525. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "A /reload spawns is required to properly update the spawns with the xpack/holiday flag.");
  3526. }
  3527. else if(set_type == SPAWN_SET_VALUE_NAME)
  3528. {
  3529. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "New name will not be effective until zone reload.");
  3530. }
  3531. else if(set_type == SPAWN_SET_VALUE_LOCATION)
  3532. {
  3533. spawn->SetLocation(client->GetPlayer()->GetLocation());
  3534. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set '%s' to '%u' for spawn '%s'", sep->arg[0], client->GetPlayer()->GetLocation(), name.c_str());
  3535. }
  3536. else
  3537. {
  3538. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set '%s' to '%s' for spawn '%s'", sep->arg[0], sep->arg[1], name.c_str());
  3539. }
  3540. switch (set_type)
  3541. {
  3542. case SPAWN_SET_VALUE_EXPANSION_FLAG:
  3543. case SPAWN_SET_VALUE_HOLIDAY_FLAG:
  3544. case SPAWN_SET_VALUE_FACTION:
  3545. {
  3546. // not applicable
  3547. break;
  3548. }
  3549. default:
  3550. {
  3551. client->GetCurrentZone()->ApplySetSpawnCommand(client, spawn, set_type, sep->arg[1]);
  3552. break;
  3553. }
  3554. }
  3555. 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))
  3556. {
  3557. if(spawn->GetSpawnLocationID() > 0 && database.UpdateSpawnLocationSpawns(spawn))
  3558. {
  3559. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information.");
  3560. }
  3561. else if(spawn->GetSpawnLocationID() > 0)
  3562. {
  3563. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn information, see console window for details.");
  3564. }
  3565. }
  3566. else
  3567. {
  3568. if(spawn->GetDatabaseID() > 0 && database.SaveSpawnInfo(spawn))
  3569. {
  3570. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully saved spawn.");
  3571. }
  3572. else if(spawn->GetDatabaseID() > 0)
  3573. {
  3574. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn, see console window for details.");
  3575. }
  3576. }
  3577. }
  3578. }
  3579. }
  3580. else if(set_type == 0)
  3581. {
  3582. // /spawn set list - lists all possible attributes that can be changed with this command, 10 per line.
  3583. map<string, int8>::iterator itr;
  3584. int i=0;
  3585. string list;
  3586. for(itr = spawn_set_values.begin(); itr != spawn_set_values.end(); itr++, i++)
  3587. {
  3588. if(i==10)
  3589. {
  3590. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  3591. i = 0;
  3592. }
  3593. if(i>0)
  3594. {
  3595. list.append(", ").append(itr->first);
  3596. }
  3597. else
  3598. {
  3599. list = itr->first;
  3600. }
  3601. }
  3602. if(list.length() > 0)
  3603. {
  3604. // if 1 or more, display in client.
  3605. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  3606. }
  3607. }
  3608. else
  3609. {
  3610. // syntax fail
  3611. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn set [type] [value]");
  3612. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used to change various settings for the targeted NPC or Object.");
  3613. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "For a list of changeable settings use /spawn set list");
  3614. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Note: /spawn set location does not require a value. The client's current location is used.");
  3615. }
  3616. }
  3617. break;
  3618. }
  3619. case COMMAND_SPAWN_REMOVE:{
  3620. Spawn* spawn = cmdTarget;
  3621. if(spawn && !spawn->IsPlayer()){
  3622. if(spawn->GetSpawnLocationID() > 0){
  3623. if(database.RemoveSpawnFromSpawnLocation(spawn)){
  3624. bool delete_spawn = false;
  3625. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  3626. if(atoi(sep->arg[0]) == 1)
  3627. delete_spawn = true;
  3628. }
  3629. if(delete_spawn)
  3630. client->GetCurrentZone()->RemoveSpawn(false, spawn, true, false);
  3631. else
  3632. spawn->SetSpawnLocationID(0);
  3633. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully removed spawn from zone");
  3634. }
  3635. else
  3636. client->SimpleMessage(CHANNEL_COLOR_RED, "Error removing spawn, see console window for details.");
  3637. }
  3638. else
  3639. client->SimpleMessage(CHANNEL_COLOR_RED, "This spawn does not have a spawn group associated with it");
  3640. }
  3641. else{
  3642. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn remove");
  3643. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for removing the targeted NPC or Object from the zone.");
  3644. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Optionally, you can supply a 1 after the command to despawn it as well. IE /spawn remove 1");
  3645. }
  3646. break;
  3647. }
  3648. case COMMAND_SPAWN_LIST:{
  3649. if(sep && sep->arg[0][0]){
  3650. vector<string>* results = database.GetSpawnNameList(sep->argplus[0]);
  3651. vector<string>::iterator itr;
  3652. if(results){
  3653. for(itr=results->begin();itr!=results->end();itr++){
  3654. client->SimpleMessage(CHANNEL_COLOR_YELLOW, (*itr).c_str());
  3655. }
  3656. safe_delete(results);
  3657. }
  3658. else
  3659. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found. ");
  3660. }
  3661. else{
  3662. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn list [name]");
  3663. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Name can be a partial match.");
  3664. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn list Qeynos Guard");
  3665. }
  3666. break;
  3667. }
  3668. case COMMAND_SPAWN_ADD:{
  3669. Spawn* spawn = cmdTarget;
  3670. if(spawn && sep && sep->arg[1][0] && (sep->IsNumber(0) || strncasecmp(sep->arg[0], "new", 3) == 0)){
  3671. if(spawn->GetSpawnLocationID() > 0){
  3672. client->Message(CHANNEL_COLOR_RED, "This spawn already has a spawn group id of %u, use /spawn remove to reassign it", spawn->GetSpawnLocationID());
  3673. break;
  3674. }
  3675. if(spawn->GetDatabaseID() == 0){
  3676. if(database.SaveSpawnInfo(spawn)) {
  3677. char spawn_type[32];
  3678. memset(spawn_type, 0, sizeof(spawn_type));
  3679. if (spawn->IsNPC())
  3680. strncpy(spawn_type, "NPC", sizeof(spawn_type) - 1);
  3681. else if (spawn->IsObject())
  3682. strncpy(spawn_type, "Object", sizeof(spawn_type) - 1);
  3683. else if (spawn->IsSign())
  3684. strncpy(spawn_type, "Sign", sizeof(spawn_type) - 1);
  3685. else if (spawn->IsGroundSpawn())
  3686. strncpy(spawn_type, "GroundSpawn", sizeof(spawn_type) - 1);
  3687. else
  3688. strncpy(spawn_type, "Unknown", sizeof(spawn_type) - 1);
  3689. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information with a %s id of %u", spawn_type, spawn->GetDatabaseID());
  3690. }
  3691. else
  3692. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn information, see console window for details.");
  3693. }
  3694. int32 spawn_group_id = 0;
  3695. if(strncasecmp(sep->arg[0], "new", 3) == 0)
  3696. spawn_group_id = database.GetNextSpawnLocation();
  3697. else
  3698. spawn_group_id = atol(sep->arg[0]);
  3699. int8 percent = 100;
  3700. if(sep->arg[2] && sep->IsNumber(2))
  3701. percent = atoi(sep->arg[2]);
  3702. spawn->SetSpawnLocationID(spawn_group_id);
  3703. float x_offset = database.GetSpawnLocationPlacementOffsetX(spawn->GetSpawnLocationID());
  3704. float y_offset = database.GetSpawnLocationPlacementOffsetY(spawn->GetSpawnLocationID());
  3705. float z_offset = database.GetSpawnLocationPlacementOffsetZ(spawn->GetSpawnLocationID());
  3706. if(database.SaveSpawnEntry(spawn, sep->arg[1], percent, x_offset, y_offset, z_offset))
  3707. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn location with a spawn group of %u", spawn->GetSpawnLocationID());
  3708. else
  3709. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn location, see console window for details.");
  3710. }
  3711. else{
  3712. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn add [spawn group id] [spawn group name] (percentage)");
  3713. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for adding the targeted NPC or Object to the database.");
  3714. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can substitute new for [spawn group id] to create a new one.");
  3715. }
  3716. break;
  3717. }
  3718. case COMMAND_SPAWN:{
  3719. int32 id = 0;
  3720. Spawn* spawn = 0;
  3721. if(sep && sep->arg[0] && sep->IsNumber(0)){
  3722. id = atol(sep->arg[0]);
  3723. spawn = client->GetCurrentZone()->GetSpawn(id);
  3724. }
  3725. if(id > 0 && spawn && spawn->appearance.name[0] == 0)
  3726. id = 0;
  3727. if(!id || !spawn){
  3728. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn [spawn id] (x) (y) (z) (heading) (location)");
  3729. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are optional except the id. The spawn id must be in the database.");
  3730. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn 1 0 0 0 0");
  3731. safe_delete(sep);
  3732. return;
  3733. }
  3734. if(sep && sep->arg[1][0]){
  3735. float x = atof(sep->arg[1]);
  3736. spawn->appearance.pos.X = x;
  3737. }
  3738. else
  3739. spawn->SetX(client->GetPlayer()->GetX(), false);
  3740. if(sep && sep->arg[2][0]){
  3741. float y = atof(sep->arg[2]);
  3742. spawn->appearance.pos.Y = y;
  3743. }
  3744. else
  3745. spawn->SetY(client->GetPlayer()->GetY(), false);
  3746. if(sep && sep->arg[3][0]){
  3747. float z = atof(sep->arg[3]);
  3748. spawn->appearance.pos.Z = z;
  3749. }
  3750. else
  3751. spawn->SetZ(client->GetPlayer()->GetZ(), false);
  3752. if(sep && sep->arg[4][0]){
  3753. float heading = atof(sep->arg[4]);
  3754. spawn->SetHeading(heading);
  3755. }
  3756. else
  3757. spawn->SetHeading(client->GetPlayer()->GetHeading(), false);
  3758. spawn->SetSpawnOrigX(spawn->GetX());
  3759. spawn->SetSpawnOrigY(spawn->GetY());
  3760. spawn->SetSpawnOrigZ(spawn->GetZ());
  3761. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  3762. if(sep && sep->arg[5][0])
  3763. spawn->appearance.pos.grid_id = atol(sep->arg[5]);
  3764. else
  3765. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  3766. if(spawn->IsNPC() && spawn->GetTotalHP() == 0){
  3767. spawn->SetTotalHP(spawn->GetLevel() * 15);
  3768. spawn->SetHP(spawn->GetTotalHP());
  3769. }
  3770. if(spawn->GetTotalPower() == 0){
  3771. spawn->SetTotalPower(spawn->GetLevel() * 15);
  3772. spawn->SetPower(spawn->GetTotalPower());
  3773. }
  3774. const char* script = world.GetSpawnScript(id);
  3775. if(script && lua_interface && lua_interface->GetSpawnScript(script) != 0)
  3776. spawn->SetSpawnScript(string(script));
  3777. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_PRESPAWN);
  3778. client->GetCurrentZone()->AddSpawn(spawn);
  3779. if(spawn->IsNPC())
  3780. spawn->GetZone()->AddLoot((NPC*)spawn);
  3781. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_SPAWN);
  3782. LogWrite(COMMAND__INFO, 0, "Command", "Received spawn command - Parms: %s", command_parms->data.c_str());
  3783. break;
  3784. }
  3785. case COMMAND_ADMINFLAG:
  3786. {
  3787. if(sep && sep->arg[0]){
  3788. sint16 tmp_status = database.GetCharacterAdminStatus(sep->arg[0]);
  3789. sint16 new_status = atoi(sep->arg[1]);
  3790. if(tmp_status == -10)
  3791. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character does not exist.");
  3792. else if(tmp_status >= client->GetAdminStatus())
  3793. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character has same or higher level status.");
  3794. else if (new_status > client->GetAdminStatus())
  3795. client->SimpleMessage(CHANNEL_ERROR, "Unable to flag character. Reason: New status is higher then your status.");
  3796. else{
  3797. Client* client2 = client->GetCurrentZone()->GetClientByName(sep->arg[0]);
  3798. if (!client2)
  3799. client2 = zone_list.GetClientByCharName(sep->arg[0]);
  3800. if(database.UpdateAdminStatus(sep->arg[0],new_status)) {
  3801. client->Message(CHANNEL_COLOR_YELLOW,"Character status updated to %i for %s.",new_status,sep->arg[0]);
  3802. if (client2) {
  3803. client2->SetAdminStatus(new_status);
  3804. client2->Message(CHANNEL_COLOR_YELLOW, "%s has set your admin status to %i.", client->GetPlayer()->GetName(), new_status);
  3805. }
  3806. }
  3807. else
  3808. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Unknown reason.");
  3809. }
  3810. }else{
  3811. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /flag {name} {new_status}");
  3812. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Standard User: 0");
  3813. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Admin User: 100");
  3814. }
  3815. break;
  3816. }
  3817. case COMMAND_CANNEDEMOTE:{
  3818. client->GetCurrentZone()->HandleEmote(client, command_parms->data);
  3819. break;
  3820. }
  3821. case COMMAND_BROADCAST: {
  3822. if (sep && sep->arg[0])
  3823. zone_list.HandleGlobalBroadcast(sep->argplus[0]);
  3824. else
  3825. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /broadcast {message}");
  3826. break;
  3827. }
  3828. case COMMAND_ANNOUNCE: {
  3829. if (sep && sep->arg[0])
  3830. zone_list.HandleGlobalAnnouncement(sep->argplus[0]);
  3831. else
  3832. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /announce {message}");
  3833. break;
  3834. }
  3835. case COMMAND_RELOAD_ITEMS:{
  3836. LogWrite(COMMAND__INFO, 0, "Command", "Reloading items..");
  3837. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Started Reloading items (this might take a few minutes...)");
  3838. database.ReloadItemList();
  3839. database.LoadMerchantInformation();
  3840. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Finished Reloading items.");
  3841. break;
  3842. }
  3843. case COMMAND_ENABLE_ABILITY_QUE:{
  3844. EQ2Packet* app = client->GetPlayer()->GetSpellBookUpdatePacket(client->GetVersion());
  3845. if(app)
  3846. client->QueuePacket(app);
  3847. break;
  3848. }
  3849. case COMMAND_ITEMSEARCH:{
  3850. PacketStruct* packet = configReader.getStruct("WS_StartBroker", client->GetVersion());
  3851. if (packet) {
  3852. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  3853. //packet->setDataByName("unknown", 1);
  3854. packet->setDataByName("unknown2", 5, 0);
  3855. packet->setDataByName("unknown2", 20, 1);
  3856. packet->setDataByName("unknown2", 58, 3);
  3857. packet->setDataByName("unknown2", 40, 4);
  3858. client->QueuePacket(packet->serialize());
  3859. PacketStruct* packet2 = configReader.getStruct("WS_BrokerBags", client->GetVersion());
  3860. if (packet2) {
  3861. packet2->setDataByName("char_id", client->GetCharacterID());
  3862. client->QueuePacket(packet2->serialize()); //send this for now, needed to properly clear data
  3863. safe_delete(packet2);
  3864. }
  3865. safe_delete(packet);
  3866. }
  3867. break;
  3868. }
  3869. case COMMAND_ANIMTEST:{
  3870. PacketStruct* command_packet = configReader.getStruct("WS_CannedEmote", client->GetVersion());
  3871. if(command_packet){
  3872. int32 id = client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer());
  3873. if (cmdTarget)
  3874. id = client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget);
  3875. command_packet->setDataByName ( "spawn_id" , id);
  3876. int animID = 1;
  3877. if(sep && sep->arg[0] && sep->IsNumber(0))
  3878. animID = atoi(sep->arg[0]);
  3879. VisualState* vs = NULL;
  3880. if(animID == 0)
  3881. {
  3882. vs = visual_states.FindVisualState(sep->arg[0]);
  3883. }
  3884. char msg[128];
  3885. sprintf(msg,"Animation Test ID: %i",animID);
  3886. command_packet->setMediumStringByName ( "emote_msg" , msg );
  3887. if(vs != NULL)
  3888. command_packet->setDataByName ( "anim_type", vs->GetID ( ) );
  3889. else
  3890. command_packet->setDataByName ( "anim_type", animID );
  3891. command_packet->setDataByName ( "unknown0", 0 );
  3892. EQ2Packet* outapp = command_packet->serialize();
  3893. client->QueuePacket(outapp);
  3894. safe_delete(command_packet);
  3895. }
  3896. break;
  3897. }
  3898. case COMMAND_KICK:
  3899. {
  3900. if( sep == 0 || sep->arg[0] == 0)
  3901. {
  3902. client->SimpleMessage(CHANNEL_COLOR_RED, "/kick [name]");
  3903. }
  3904. else
  3905. {
  3906. Client* kickClient = zone_list.GetClientByCharName(string(sep->arg[0]));
  3907. if ( kickClient == client )
  3908. {
  3909. client->Message(CHANNEL_COLOR_RED, "You can't kick yourself!");
  3910. break;
  3911. }
  3912. else if(kickClient != NULL)
  3913. {
  3914. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  3915. if ( maxStatus >= client->GetAdminStatus( ) || kickClient->GetAdminStatus() >= client->GetAdminStatus() )
  3916. {
  3917. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  3918. break;
  3919. }
  3920. client->Message(CHANNEL_COLOR_RED, "Kicking %s...",sep->arg[0]);
  3921. kickClient->Disconnect();
  3922. }
  3923. else
  3924. {
  3925. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  3926. }
  3927. }
  3928. break;
  3929. }
  3930. case COMMAND_LOCK:
  3931. {
  3932. if( sep != NULL && sep->arg[0] != NULL && sep->IsNumber(0)){
  3933. int worldLocked = atoi(sep->arg[0]);
  3934. net.world_locked = worldLocked;
  3935. if ( worldLocked )
  3936. client->Message(CHANNEL_COLOR_YELLOW,"World server has been locked.");
  3937. else
  3938. client->Message(CHANNEL_COLOR_YELLOW,"World server has been unlocked.");
  3939. }
  3940. else
  3941. client->SimpleMessage(CHANNEL_COLOR_RED, "/lock [0/1]");
  3942. break;
  3943. }
  3944. case COMMAND_BAN:{
  3945. if( sep == 0 || sep->arg[0] == 0 || (sep->arg[1][0] != 0 && !sep->IsNumber(1) ) )
  3946. {
  3947. client->SimpleMessage(CHANNEL_COLOR_RED, "/ban [name] [permanent:0/1]");
  3948. }
  3949. else
  3950. {
  3951. Client* kickClient = zone_list.GetClientByCharName(sep->arg[0]);
  3952. if ( kickClient == client )
  3953. {
  3954. client->Message(CHANNEL_COLOR_RED, "You can't ban yourself!");
  3955. break;
  3956. }
  3957. else if(kickClient != NULL)
  3958. {
  3959. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  3960. if ( maxStatus > client->GetAdminStatus( ) ||
  3961. client->GetAdminStatus ( ) > kickClient->GetAdminStatus ( ) )
  3962. {
  3963. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  3964. break;
  3965. }
  3966. client->Message(CHANNEL_COLOR_RED, "Kicking & Banning %s...",sep->arg[0]);
  3967. int perm = atol(sep->arg[1]);
  3968. if ( perm == 1 )
  3969. database.UpdateAdminStatus(sep->arg[0],-2);
  3970. else
  3971. database.UpdateAdminStatus(sep->arg[0],-1);
  3972. kickClient->Disconnect();
  3973. }
  3974. else
  3975. {
  3976. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  3977. }
  3978. }
  3979. break;
  3980. }
  3981. case COMMAND_SET_COMBAT_VOICE:{
  3982. int32 value = 0;
  3983. if(sep && sep->arg[0] && sep->IsNumber(0))
  3984. value = atoi(sep->arg[0]);
  3985. client->GetPlayer()->SetCombatVoice(value);
  3986. break;
  3987. }
  3988. case COMMAND_SET_EMOTE_VOICE:{
  3989. int32 value = 0;
  3990. if(sep && sep->arg[0] && sep->IsNumber(0))
  3991. value = atoi(sep->arg[0]);
  3992. client->GetPlayer()->SetEmoteVoice(value);
  3993. break;
  3994. }
  3995. case COMMAND_GIVEITEM:{
  3996. if(sep && sep->arg[0][0] && sep->arg[0][1] && sep->IsNumber(1)){
  3997. Client* itemToClient = zone_list.GetClientByCharName(sep->arg[0]);
  3998. if ( itemToClient == NULL )
  3999. client->Message(CHANNEL_COLOR_YELLOW,"Could not find %s.",sep->arg[0]);
  4000. else
  4001. {
  4002. int32 item_id = atol(sep->arg[1]);
  4003. client->Message(CHANNEL_COLOR_YELLOW,"Gave %s item id %i.",sep->arg[0],item_id);
  4004. itemToClient->AddItem(item_id);
  4005. }
  4006. }
  4007. else
  4008. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /giveitem [name] [item_id]");
  4009. break;
  4010. }
  4011. case COMMAND_REPORT_BUG : { Command_ReportBug(client, sep); break; }
  4012. case COMMAND_INVENTORY : { Command_Inventory(client, sep, command); break; }
  4013. case COMMAND_WEAPONSTATS : { Command_WeaponStats(client); break; }
  4014. case COMMAND_SKILL :
  4015. case COMMAND_SKILL_ADD :
  4016. case COMMAND_SKILL_REMOVE :
  4017. case COMMAND_SKILL_LIST : { Command_Skills(client, sep, command->handler); break; }
  4018. case COMMAND_ZONE_SET : { Command_ZoneSet(client, sep); break; }
  4019. case COMMAND_ZONE_DETAILS : { Command_ZoneDetails(client, sep); break; }
  4020. case COMMAND_ENTITYCOMMAND :
  4021. case COMMAND_ENTITYCOMMAND_LIST : { Command_EntityCommand(client, sep, command->handler); break; }
  4022. case COMMAND_MERCHANT :
  4023. case COMMAND_MERCHANT_LIST : { Command_Merchant(client, sep, command->handler); break; }
  4024. case COMMAND_APPEARANCE :
  4025. case COMMAND_APPEARANCE_LIST : { Command_Appearance(client, sep, command->handler); break; }
  4026. case COMMAND_TRACK : { Command_Track(client); break; }
  4027. case COMMAND_DISTANCE : { Command_Distance(client); break; }
  4028. case COMMAND_INSPECT_PLAYER : { Command_InspectPlayer(client, sep); break; }
  4029. case COMMAND_ZONE_SAFE : { Command_ZoneSafeCoords(client, sep); break; }
  4030. case COMMAND_GUILDSAY : { Command_GuildSay(client, sep); break; }
  4031. case COMMAND_OFFICERSAY : { Command_OfficerSay(client, sep); break; }
  4032. case COMMAND_SET_GUILD_MEMBER_NOTE : { Command_SetGuildMemberNote(client, sep); break; }
  4033. case COMMAND_SET_GUILD_OFFICER_NOTE : { Command_SetGuildOfficerNote(client, sep); break; }
  4034. case COMMAND_GUILD : { Command_Guild(client, sep); break; }
  4035. case COMMAND_CREATE_GUILD : { Command_CreateGuild(client); break; }
  4036. case COMMAND_GUILDS : { Command_Guilds(client); break; }
  4037. case COMMAND_GUILDS_ADD : { Command_GuildsAdd(client, sep); break; }
  4038. case COMMAND_GUILDS_CREATE : { Command_GuildsCreate(client, sep); break; }
  4039. case COMMAND_GUILDS_DELETE : { Command_GuildsDelete(client, sep); break; }
  4040. case COMMAND_GUILDS_LIST : { Command_GuildsList(client); break; }
  4041. case COMMAND_GUILDS_REMOVE : { Command_GuildsRemove(client, sep); break; }
  4042. case COMMAND_CLAIM : { Command_Claim(client, sep); break; }
  4043. case COMMAND_CLEAR_ALL_QUEUED : { Command_ClearAllQueued(client); break; }
  4044. case COMMAND_LOCATION : { Command_Location(client); break; }
  4045. case COMMAND_LOCATION_ADD : { Command_LocationAdd(client, sep); break; }
  4046. case COMMAND_LOCATION_CREATE : { Command_LocationCreate(client, sep); break; }
  4047. case COMMAND_LOCATION_DELETE : { Command_LocationDelete(client, sep); break; }
  4048. case COMMAND_LOCATION_LIST : { Command_LocationList(client, sep); break; }
  4049. case COMMAND_LOCATION_REMOVE : { Command_LocationRemove(client, sep); break; }
  4050. case COMMAND_GRID : { Command_Grid(client); break; }
  4051. case COMMAND_TRY_ON : { Command_TryOn(client, sep); break; }
  4052. case COMMAND_IRC : { Command_IRC(client, sep); break; }
  4053. case COMMAND_RANDOMIZE : { Command_Randomize(client, sep); break; }
  4054. case COMMAND_AFK : { Command_AFK(client, sep); break; }
  4055. case COMMAND_SHOW_CLOAK : { Command_ShowCloak(client, sep); break; }
  4056. case COMMAND_SHOW_HELM : { Command_ShowHelm(client, sep); break; }
  4057. case COMMAND_SHOW_HOOD : { Command_ShowHood(client, sep); break; }
  4058. case COMMAND_SHOW_HOOD_OR_HELM : { Command_ShowHoodHelm(client, sep); break; }
  4059. case COMMAND_SHOW_RANGED : { Command_ShowRanged(client, sep); break; }
  4060. case COMMAND_STOP_DRINKING : { Command_StopDrinking(client); break; }
  4061. case COMMAND_STOP_EATING : { Command_StopEating(client); break; }
  4062. case COMMAND_TOGGLE_ANONYMOUS : { Command_Toggle_Anonymous(client); break; }
  4063. case COMMAND_TOGGLE_AUTOCONSUME : { Command_Toggle_AutoConsume(client, sep); break; }
  4064. case COMMAND_TOGGLE_BONUS_EXP : { Command_Toggle_BonusXP(client); break; }
  4065. case COMMAND_TOGGLE_COMBAT_EXP : { Command_Toggle_CombatXP(client); break; }
  4066. case COMMAND_TOGGLE_GM_HIDE : { Command_Toggle_GMHide(client); break; }
  4067. case COMMAND_TOGGLE_GM_VANISH : { Command_Toggle_GMVanish(client); break; }
  4068. case COMMAND_TOGGLE_ILLUSIONS : { Command_Toggle_Illusions(client, sep); break; }
  4069. case COMMAND_TOGGLE_LFG : { Command_Toggle_LFG(client); break; }
  4070. case COMMAND_TOGGLE_LFW : { Command_Toggle_LFW(client); break; }
  4071. case COMMAND_TOGGLE_QUEST_EXP : { Command_Toggle_QuestXP(client); break; }
  4072. case COMMAND_TOGGLE_ROLEPLAYING : { Command_Toggle_Roleplaying(client); break; }
  4073. case COMMAND_TOGGLE_DUELS : { Command_Toggle_Duels(client); break; }
  4074. case COMMAND_TOGGLE_TRADES : { Command_Toggle_Trades(client); break; }
  4075. case COMMAND_TOGGLE_GUILDS : { Command_Toggle_Guilds(client); break; }
  4076. case COMMAND_TOGGLE_GROUPS : { Command_Toggle_Groups(client); break; }
  4077. case COMMAND_TOGGLE_RAIDS : { Command_Toggle_Raids(client); break; }
  4078. case COMMAND_TOGGLE_LON : { Command_Toggle_LON(client); break; }
  4079. case COMMAND_TOGGLE_VCINVITE : { Command_Toggle_VoiceChat(client); break; }
  4080. case COMMAND_CANCEL_MAINTAINED : { Command_CancelMaintained(client, sep); break; }
  4081. case COMMAND_MOTD : { Command_MOTD(client); break; }
  4082. case COMMAND_RANDOM : { Command_Random(client, sep); break; }
  4083. case COMMAND_CREATE : { Command_Create(client, sep); break; }
  4084. case COMMAND_CREATEFROMRECIPE : { Command_CreateFromRecipe(client, sep); break; }
  4085. case COMMAND_TITLE : { Command_Title(client); break; }
  4086. case COMMAND_TITLE_LIST : { Command_TitleList(client); break; }
  4087. case COMMAND_TITLE_SETPREFIX : { Command_TitleSetPrefix(client, sep); break; }
  4088. case COMMAND_TITLE_SETSUFFIX : { Command_TitleSetSuffix(client, sep); break; }
  4089. case COMMAND_TITLE_FIX : { Command_TitleFix(client, sep); break; }
  4090. case COMMAND_LANGUAGES : { Command_Languages(client, sep); break; }
  4091. case COMMAND_SET_LANGUAGE : { Command_SetLanguage(client, sep); break; }
  4092. case COMMAND_FOLLOW : { Command_Follow(client, sep); break; }
  4093. case COMMAND_STOP_FOLLOW : { Command_StopFollow(client, sep); break; }
  4094. case COMMAND_LASTNAME : { Command_LastName(client, sep); break; }
  4095. case COMMAND_CONFIRMLASTNAME : { Command_ConfirmLastName(client, sep); break; }
  4096. case COMMAND_PET : { Command_Pet(client, sep); break; }
  4097. case COMMAND_PETNAME : { Command_PetName(client, sep); break; }
  4098. case COMMAND_NAME_PET : { Command_NamePet(client, sep); break; }
  4099. case COMMAND_RENAME : { Command_Rename(client, sep); break; }
  4100. case COMMAND_CONFIRMRENAME : { Command_ConfirmRename(client, sep); break; }
  4101. case COMMAND_PETOPTIONS : { Command_PetOptions(client, sep); break; }
  4102. case COMMAND_START_TRADE : { Command_TradeStart(client, sep); break; }
  4103. case COMMAND_ACCEPT_TRADE : { Command_TradeAccept(client, sep); break; }
  4104. case COMMAND_REJECT_TRADE : { Command_TradeReject(client, sep); break; }
  4105. case COMMAND_CANCEL_TRADE : { Command_TradeCancel(client, sep); break; }
  4106. case COMMAND_SET_TRADE_COIN : { Command_TradeSetCoin(client, sep); break; }
  4107. case COMMAND_ADD_TRADE_COPPER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_COPPER); break; }
  4108. case COMMAND_ADD_TRADE_SILVER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_SILVER); break; }
  4109. case COMMAND_ADD_TRADE_GOLD : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_GOLD); break; }
  4110. case COMMAND_ADD_TRADE_PLAT : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_PLAT); break; }
  4111. case COMMAND_REMOVE_TRADE_COPPER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_COPPER); break; }
  4112. case COMMAND_REMOVE_TRADE_SILVER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_SILVER); break; }
  4113. case COMMAND_REMOVE_TRADE_GOLD : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_GOLD); break; }
  4114. case COMMAND_REMOVE_TRADE_PLAT : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_PLAT); break; }
  4115. case COMMAND_ADD_TRADE_ITEM : { Command_TradeAddItem(client, sep); break; }
  4116. case COMMAND_REMOVE_TRADE_ITEM : { Command_TradeRemoveItem(client, sep); break; }
  4117. case COMMAND_ACCEPT_ADVANCEMENT : { Command_AcceptAdvancement(client, sep); break; }
  4118. case COMMAND_DUEL : { Command_Duel(client, sep); break; }
  4119. case COMMAND_DUELBET : { Command_DuelBet(client, sep); break; }
  4120. case COMMAND_DUEL_ACCEPT : { Command_DuelAccept(client, sep); break; }
  4121. case COMMAND_DUEL_DECLINE : { Command_DuelDecline(client, sep); break; }
  4122. case COMMAND_DUEL_SURRENDER : { Command_DuelSurrender(client, sep); break; }
  4123. case COMMAND_DUEL_TOGGLE : { Command_DuelToggle(client, sep); break; }
  4124. case COMMAND_SPAWN_TEMPLATE : { Command_SpawnTemplate(client, sep); break; }
  4125. case COMMAND_MODIFY : { Command_Modify(client); break; }
  4126. case COMMAND_MODIFY_CHARACTER : { Command_ModifyCharacter(client, sep); break; }
  4127. case COMMAND_MODIFY_QUEST : { Command_ModifyQuest(client, sep); break; }
  4128. case COMMAND_MODIFY_FACTION : { Command_ModifyFaction(client, sep); break; }
  4129. case COMMAND_MODIFY_GUILD : { Command_ModifyGuild(client, sep); break; }
  4130. case COMMAND_MODIFY_ITEM : { Command_ModifyItem(client, sep); break; }
  4131. case COMMAND_MODIFY_SKILL : { Command_ModifySkill(client, sep); break; }
  4132. case COMMAND_MODIFY_SPAWN : { Command_ModifySpawn(client, sep); break; }
  4133. case COMMAND_MODIFY_SPELL : { Command_ModifySpell(client, sep); break; }
  4134. case COMMAND_MODIFY_ZONE : { Command_ModifyZone(client, sep); break; }
  4135. case COMMAND_JOIN_CHANNEL : { Command_JoinChannel(client, sep); break;}
  4136. case COMMAND_JOIN_CHANNEL_FROM_LOAD: { Command_JoinChannelFromLoad(client, sep); break;}
  4137. case COMMAND_TELL_CHANNEL : { Command_TellChannel(client, sep); break;}
  4138. case COMMAND_LEAVE_CHANNEL : { Command_LeaveChannel(client, sep); break;}
  4139. case COMMAND_WHO_CHANNEL : { Command_WhoChannel(client, sep); break;}
  4140. case COMMAND_RAIN : { Command_Rain(client, sep); break; }
  4141. case COMMAND_WIND : { Command_Wind(client, sep); break; }
  4142. case COMMAND_WEATHER : { Command_Weather(client, sep); break; }
  4143. case COMMAND_FROM_MERCHANT : { Command_SendMerchantWindow(client, sep); break; }
  4144. case COMMAND_TO_MERCHANT : { Command_SendMerchantWindow(client, sep, true); break; }
  4145. case COMMAND_SELECT : { Command_Select(client, sep); break; }
  4146. case COMMAND_SMP : { Command_StationMarketPlace(client, sep); break; }
  4147. case COMMAND_CONSUME_FOOD : { Command_ConsumeFood(client, sep); break; }
  4148. case COMMAND_AQUAMAN : { Command_Aquaman(client, sep); break; }
  4149. case COMMAND_ATTUNE_INV : { Command_Attune_Inv(client, sep); break; }
  4150. case COMMAND_PLAYER : { Command_Player(client, sep); break; }
  4151. case COMMAND_PLAYER_COINS : { Command_Player_Coins(client, sep); break; }
  4152. case COMMAND_RESET_ZONE_TIMER : { Command_Reset_Zone_Timer(client, sep); break; }
  4153. case COMMAND_ACHIEVEMENT_ADD : { Command_AchievementAdd(client, sep); break; }
  4154. case COMMAND_EDITOR : { Command_Editor(client, sep); break; }
  4155. case COMMAND_ACCEPT_RESURRECTION: { Command_AcceptResurrection(client, sep); break; }
  4156. case COMMAND_DECLINE_RESURRECTION:{ Command_DeclineResurrection(client, sep); break; }
  4157. case COMMAND_TEST : { Command_Test(client, command_parms); break; }
  4158. case COMMAND_SPEED : { Command_Speed(client, sep); break; }
  4159. case COMMAND_BOT : { Command_Bot(client, sep); break; }
  4160. case COMMAND_BOT_CREATE : { Command_Bot_Create(client, sep); break; }
  4161. case COMMAND_BOT_CUSTOMIZE : { Command_Bot_Customize(client, sep); break; }
  4162. case COMMAND_BOT_SPAWN : { Command_Bot_Spawn(client, sep); break; }
  4163. case COMMAND_BOT_LIST : { Command_Bot_List(client, sep); break; }
  4164. case COMMAND_BOT_INV : { Command_Bot_Inv(client, sep); break; }
  4165. case COMMAND_BOT_SETTINGS : { Command_Bot_Settings(client, sep); break; }
  4166. case COMMAND_BOT_HELP : { Command_Bot_Help(client, sep); break; }
  4167. case GET_AA_XML : { Get_AA_Xml(client, sep); break; }
  4168. case ADD_AA : { Add_AA(client, sep); break; }
  4169. case COMMIT_AA_PROFILE : { Commit_AA_Profile(client, sep); break; }
  4170. case BEGIN_AA_PROFILE : { Begin_AA_Profile(client, sep); break; }
  4171. case BACK_AA : { Back_AA(client, sep); break; }
  4172. case REMOVE_AA : { Remove_AA(client, sep); break; }
  4173. case SWITCH_AA_PROFILE : { Switch_AA_Profile(client, sep); break; }
  4174. case CANCEL_AA_PROFILE : { Cancel_AA_Profile(client, sep); break; }
  4175. case SAVE_AA_PROFILE : { Save_AA_Profile(client, sep); break; }
  4176. case COMMAND_TARGETITEM : { Command_TargetItem(client, sep); break; }
  4177. case COMMAND_FINDSPAWN: { Command_FindSpawn(client, sep); break; }
  4178. default:
  4179. {
  4180. LogWrite(COMMAND__WARNING, 0, "Command", "Unhandled command: %s", command->command.data.c_str());
  4181. break;
  4182. }
  4183. }
  4184. safe_delete(sep);
  4185. }
  4186. /******************** New COMMAND Handler Functions ********************/
  4187. /*
  4188. Started breaking apart the huge switch() for commands into sepErate
  4189. functions so it is easier to locate the blocks of code by command
  4190. -- JA 2012.03.03
  4191. */
  4192. // sample function header
  4193. /*
  4194. Function:
  4195. Purpose :
  4196. Params :
  4197. Dev :
  4198. Example :
  4199. */
  4200. //void Commands::Command()
  4201. //{
  4202. //}
  4203. /*
  4204. Function: Command_AcceptAdvancement()
  4205. Purpose : Player accepts a new advancement option
  4206. Params : Spell ID
  4207. Dev : Jabantiz
  4208. */
  4209. void Commands::Command_AcceptAdvancement(Client* client, Seperator* sep)
  4210. {
  4211. Player *player = client->GetPlayer();
  4212. if (sep && sep->IsSet(0)) {
  4213. TraitData* trait = master_trait_list.GetTrait(atoul(sep->arg[0]));
  4214. // Check to see if this is a trait or grandmaster training (traits are always new spells, training is always upgrades)
  4215. if (!player->HasSpell(trait->spellID, 0, true))
  4216. {
  4217. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  4218. player->AddSpellBookEntry(trait->spellID, trait->tier, player->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  4219. }
  4220. else
  4221. {
  4222. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  4223. int8 old_slot = player->GetSpellSlot(spell->GetSpellID());
  4224. player->RemoveSpellBookEntry(spell->GetSpellID());
  4225. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  4226. player->UnlockSpell(spell);
  4227. client->SendSpellUpdate(spell);
  4228. }
  4229. // Spell book update
  4230. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  4231. client->QueuePacket(master_trait_list.GetTraitListPacket(client));
  4232. }
  4233. }
  4234. /*
  4235. Function:
  4236. Purpose :
  4237. Params :
  4238. Dev :
  4239. Example :
  4240. */
  4241. void Commands::Command_AFK(Client* client, Seperator* sep)
  4242. {
  4243. Player* player = client->GetPlayer();
  4244. player->toggle_character_flag(CF_AFK);
  4245. client->Message(CHANNEL_COLOR_YELLOW,"You are %s afk.", client->GetPlayer()->get_character_flag(CF_AFK)?"now":"no longer");
  4246. if (player->get_character_flag(CF_AFK))
  4247. {
  4248. LogWrite(MISC__TODO, 1, "TODO", "player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_AFK); <-- need to find this");
  4249. /*player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_AFK); <-- need to find this */
  4250. if (sep && sep->argplus[0])
  4251. player->SetAwayMessage("I am away from the keyboard, " + string(sep->argplus[0]));
  4252. else
  4253. player->SetAwayMessage("Sorry, I am A.F.K. (Away From Keyboard)");
  4254. string message = string(player->GetName()) + " is going afk.";
  4255. Spawn* target = player->GetTarget();
  4256. if (target && target != player)
  4257. {
  4258. message = string(player->GetName()) + " tells " + string(target->GetName()) + " that ";
  4259. player->GetGender() == 1 ? message += "he" : message += "she";
  4260. message += " is going afk.";
  4261. }
  4262. player->GetZone()->SimpleMessage(CHANNEL_COLOR_YELLOW, message.c_str(), player, 30);
  4263. }
  4264. /*else
  4265. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_AFK); <-- need to find this */
  4266. }
  4267. /*
  4268. Function: Command_Appearance()
  4269. Purpose : Handles /appearance commands
  4270. Params : list
  4271. Dev : Scatman
  4272. Example : /appearance list
  4273. */
  4274. void Commands::Command_Appearance(Client* client, Seperator* sep, int handler)
  4275. {
  4276. if( handler == COMMAND_APPEARANCE )
  4277. {
  4278. // /appearance command by itself shows help (to be extended)
  4279. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  4280. return;
  4281. }
  4282. else if( handler == COMMAND_APPEARANCE_LIST )
  4283. {
  4284. // /appearance list command expects "name" param
  4285. if (sep && sep->arg[0])
  4286. {
  4287. const char* appearance_name = sep->argplus[0];
  4288. client->Message(CHANNEL_COLOR_YELLOW, "Listing appearances like '%s':", appearance_name);
  4289. vector<int16>* appearances = database.GetAppearanceIDsLikeName(string(appearance_name));
  4290. if (appearances)
  4291. {
  4292. vector<int16>::iterator itr;
  4293. for (itr = appearances->begin(); itr != appearances->end(); itr++)
  4294. {
  4295. int16 id = *itr;
  4296. string name = database.GetAppearanceName(id);
  4297. if (ToLower(name).find(ToLower(string(appearance_name))) < 0xFFFFFFFF)
  4298. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", name.c_str(), id);
  4299. }
  4300. safe_delete(appearances);
  4301. }
  4302. }
  4303. else // no param
  4304. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  4305. }
  4306. }
  4307. /*
  4308. Function: Command_Claim()
  4309. Purpose :
  4310. Params :
  4311. Dev :
  4312. Example :
  4313. */
  4314. void Commands::Command_Claim(Client* client, Seperator* sep)
  4315. {
  4316. if (sep && sep->arg[0] && sep->IsNumber(0))
  4317. {
  4318. LogWrite(MISC__TODO, 1, "TODO", "On Scatman's TODO list!\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  4319. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "On Scatman's TODO :)");
  4320. }
  4321. else
  4322. client->ShowClaimWindow();
  4323. }
  4324. /*
  4325. Function: Command_ClearAllQueued()
  4326. Purpose :
  4327. Params :
  4328. Dev :
  4329. Example :
  4330. */
  4331. void Commands::Command_ClearAllQueued(Client* client)
  4332. {
  4333. ZoneServer* zone = client->GetPlayer()->GetZone();
  4334. if (zone && zone->GetSpellProcess())
  4335. zone->GetSpellProcess()->RemoveSpellFromQueue(client->GetPlayer());
  4336. }
  4337. /*
  4338. Function: Command_CancelMaintained()
  4339. Purpose : Cancels maintained spells
  4340. Params : Maintained Spell Index
  4341. Dev : Zcoretri
  4342. Example : /cancel_maintained 1 - would cancel the spell in slot 1 of Maintained Spells list
  4343. */
  4344. void Commands::Command_CancelMaintained(Client* client, Seperator* sep)
  4345. {
  4346. if (sep && sep->arg[0] && sep->IsNumber(0))
  4347. {
  4348. int32 spell_index = atoul(sep->arg[0]);
  4349. MaintainedEffects mEffects = client->GetPlayer()->GetInfoStruct()->maintained_effects[spell_index];
  4350. //Spell* spell = master_spell_list.GetSpell(mEffects.spell_id, mEffects.tier);
  4351. // if (spell && spell->GetSpellData()->friendly_spell) -- NOTE::You can cancel hostile maintained spells,
  4352. // just not spelleffects/dets - Foof
  4353. //{
  4354. if (!client->GetPlayer()->GetZone()->GetSpellProcess()->DeleteCasterSpell(mEffects.spell))
  4355. client->Message(CHANNEL_COLOR_RED, "The maintained spell could not be cancelled.");
  4356. // }
  4357. //else
  4358. //client->Message(CHANNEL_COLOR_RED, "You can only cancel friendly spells!");
  4359. }
  4360. }
  4361. /*
  4362. Function: Command_Create()
  4363. Purpose : Handler for starting Tradeskilling table
  4364. Params :
  4365. Dev : Zcoretri
  4366. Example :
  4367. */
  4368. void Commands::Command_Create(Client* client, Seperator* sep)
  4369. {
  4370. PrintSep(sep, "COMMAND_CREATE");
  4371. client->SendRecipeList();
  4372. client->ShowRecipeBook();
  4373. }
  4374. void Commands::Command_CreateFromRecipe(Client* client, Seperator* sep)
  4375. {
  4376. PrintSep(sep, "COMMAND_CREATEFROMRECIPE");
  4377. if (sep && sep->arg[0] && sep->IsNumber(0))
  4378. ClientPacketFunctions::SendCreateFromRecipe(client, atoul(sep->arg[0]));
  4379. }
  4380. /*
  4381. Function: Command_Distance()
  4382. Purpose : Displays distance from targeted spawn
  4383. Params :
  4384. Dev : Scatman
  4385. Example : /distance
  4386. */
  4387. void Commands::Command_Distance(Client* client)
  4388. {
  4389. Spawn* target = client->GetPlayer()->GetTarget();
  4390. if (target)
  4391. client->Message(CHANNEL_COLOR_YELLOW, "Your distance from %s is %f", target->GetName(), client->GetPlayer()->GetDistance(target));
  4392. else
  4393. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must have a spawn targeted to use /distance");
  4394. }
  4395. /*
  4396. Function: Command_Duel()
  4397. Purpose : Handle the /duel commands - not yet implemented
  4398. Params : unknown
  4399. Dev :
  4400. Example :
  4401. */
  4402. void Commands::Command_Duel(Client* client, Seperator* sep)
  4403. {
  4404. PrintSep(sep, "COMMAND_DUEL");
  4405. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Command");
  4406. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4407. }
  4408. /*
  4409. Function: Command_DuelBet()
  4410. Purpose : Handle the /duel commands - not yet implemented
  4411. Params : unknown
  4412. Dev :
  4413. Example :
  4414. */
  4415. void Commands::Command_DuelBet(Client* client, Seperator* sep)
  4416. {
  4417. PrintSep(sep, "COMMAND_DUELBET");
  4418. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Bet Command");
  4419. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4420. }
  4421. /*
  4422. Function: Command_DuelAccept()
  4423. Purpose : Handle the /duel commands - not yet implemented
  4424. Params : unknown
  4425. Dev :
  4426. Example :
  4427. */
  4428. void Commands::Command_DuelAccept(Client* client, Seperator* sep)
  4429. {
  4430. PrintSep(sep, "COMMAND_DUEL_ACCEPT");
  4431. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Accept Duel Command");
  4432. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4433. }
  4434. /*
  4435. Function: Command_DuelDecline()
  4436. Purpose : Handle the /duel commands - not yet implemented
  4437. Params : unknown
  4438. Dev :
  4439. Example :
  4440. */
  4441. void Commands::Command_DuelDecline(Client* client, Seperator* sep)
  4442. {
  4443. PrintSep(sep, "COMMAND_DUEL_DECLINE");
  4444. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Decline Duel Request Command");
  4445. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4446. }
  4447. /*
  4448. Function: Command_DuelSurrender()
  4449. Purpose : Handle the /duel commands - not yet implemented
  4450. Params : unknown
  4451. Dev :
  4452. Example :
  4453. */
  4454. void Commands::Command_DuelSurrender(Client* client, Seperator* sep)
  4455. {
  4456. PrintSep(sep, "COMMAND_DUEL_SURRENDER");
  4457. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Surrender Duel Command");
  4458. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4459. // JA, just messin around ;)
  4460. char surrender[64];
  4461. sprintf(surrender, "%s surrendered like a cowardly dog!", client->GetPlayer()->GetName());
  4462. zone_list.HandleGlobalAnnouncement(surrender);
  4463. }
  4464. /*
  4465. Function: Command_DuelToggle()
  4466. Purpose : Handle the /duel commands - not yet implemented
  4467. Params : unknown
  4468. Dev :
  4469. Example :
  4470. */
  4471. void Commands::Command_DuelToggle(Client* client, Seperator* sep)
  4472. {
  4473. PrintSep(sep, "COMMAND_DUEL");
  4474. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Commands");
  4475. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4476. }
  4477. /*
  4478. Function:
  4479. Purpose :
  4480. Params :
  4481. Dev :
  4482. Example :
  4483. */
  4484. void Commands::Command_EntityCommand(Client* client, Seperator* sep, int handler)
  4485. {
  4486. if( handler == COMMAND_ENTITYCOMMAND )
  4487. {
  4488. // /entitycommand command by itself shows help (to be extended)
  4489. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  4490. return;
  4491. }
  4492. else if( handler == COMMAND_ENTITYCOMMAND_LIST )
  4493. {
  4494. // /entitycommand list command expects "name" param
  4495. if (sep && sep->arg[0])
  4496. {
  4497. const char* entity_command_name = sep->argplus[0];
  4498. client->Message(CHANNEL_COLOR_YELLOW, "Listing entity commands like '%s':", entity_command_name);
  4499. map<int32, vector<EntityCommand*>*>* entity_command_list_all = client->GetCurrentZone()->GetEntityCommandListAll();
  4500. map<int32, vector<EntityCommand*>*>::iterator itr;
  4501. for (itr = entity_command_list_all->begin(); itr != entity_command_list_all->end(); itr++)
  4502. {
  4503. vector<EntityCommand*>* entity_command_list = itr->second;
  4504. vector<EntityCommand*>::iterator itr2;
  4505. for (itr2 = entity_command_list->begin(); itr2 != entity_command_list->end(); itr2++)
  4506. {
  4507. EntityCommand* entity_command = *itr2;
  4508. if (ToLower(entity_command->name).find(ToLower(string(entity_command_name))) < 0xFFFFFFFF)
  4509. 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);
  4510. }
  4511. }
  4512. }
  4513. else // no command name
  4514. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  4515. }
  4516. }
  4517. /*
  4518. Function: Command_Follow()
  4519. Purpose : Handle the /follow command - not yet implemented
  4520. Params :
  4521. Dev :
  4522. Example :
  4523. */
  4524. void Commands::Command_Follow(Client* client, Seperator* sep)
  4525. {
  4526. PrintSep(sep, "COMMAND_FOLLOW");
  4527. // flag to toggle if the players target is in the players group
  4528. bool targetInGroup = false;
  4529. // get a pointer to the players group
  4530. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  4531. // If the player has a group and has a target
  4532. if (gmi && client->GetPlayer()->GetTarget()) {
  4533. deque<GroupMemberInfo*>::iterator itr;
  4534. world.GetGroupManager()->GroupLock(__FUNCTION__, __LINE__);
  4535. deque<GroupMemberInfo*>* members = world.GetGroupManager()->GetGroupMembers(gmi->group_id);
  4536. // Loop through the group members
  4537. for (itr = members->begin(); itr != members->end(); itr++) {
  4538. // If a group member matches a target
  4539. if ((*itr)->member == client->GetPlayer()->GetTarget()) {
  4540. // toggle the flag and break the loop
  4541. targetInGroup = true;
  4542. break;
  4543. }
  4544. }
  4545. world.GetGroupManager()->ReleaseGroupLock(__FUNCTION__, __LINE__);
  4546. }
  4547. if (targetInGroup) {
  4548. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  4549. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You start to follow %s.", client->GetPlayer()->GetTarget()->GetName());
  4550. client->GetPlayer()->SetFollowTarget(client->GetPlayer()->GetTarget());
  4551. client->GetPlayer()->info_changed = true;
  4552. client->GetPlayer()->changed = true;
  4553. }
  4554. else
  4555. client->Message(CHANNEL_COLOR_WHITE, "You must first select a group member to follow.");
  4556. }
  4557. /*
  4558. Function: Command_StopFollow()
  4559. Purpose : Handle the /stop_follow command - not yet implemented
  4560. Params :
  4561. Dev :
  4562. Example :
  4563. */
  4564. void Commands::Command_StopFollow(Client* client, Seperator* sep)
  4565. {
  4566. PrintSep(sep, "COMMAND_STOP_FOLLOW");
  4567. if (client->GetPlayer()->GetFollowTarget()) {
  4568. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  4569. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You are no longer following %s", client->GetPlayer()->GetFollowTarget()->GetName());
  4570. client->GetPlayer()->SetFollowTarget(0);
  4571. client->GetPlayer()->info_changed = true;
  4572. client->GetPlayer()->changed = true;
  4573. }
  4574. }
  4575. #include "../Zone/SPGrid.h"
  4576. /*
  4577. Function: Command_Grid()
  4578. Purpose : Show player's current Grid ID
  4579. Params :
  4580. Dev : Scatman
  4581. Example : /grid
  4582. */
  4583. void Commands::Command_Grid(Client* client)
  4584. {
  4585. client->Message(CHANNEL_COLOR_YELLOW, "Your Grid ID is %u", client->GetPlayer()->appearance.pos.grid_id);
  4586. if (client->GetCurrentZone()->Grid != nullptr) {
  4587. int32 grid = client->GetCurrentZone()->Grid->GetGridID(client->GetPlayer());
  4588. client->Message(CHANNEL_COLOR_YELLOW, "SPGrid result is %u", grid);
  4589. }
  4590. }
  4591. /*
  4592. Function: Command_Guild()
  4593. Purpose : Handler for all UI-related guild commands
  4594. Dev : Scatman
  4595. */
  4596. void Commands::Command_Guild(Client* client, Seperator* sep)
  4597. {
  4598. Guild* guild = client->GetPlayer()->GetGuild();
  4599. if (sep && sep->GetMaxArgNum() > 0 && sep->arg[0])
  4600. {
  4601. const char* command = sep->arg[0];
  4602. int32 length = strlen(command);
  4603. LogWrite(COMMAND__DEBUG, 0, "Command", "Guild Command: %s", command);
  4604. if (strncmp(command, "rank_name", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && guild)
  4605. guild->SetRankName(atoi(sep->arg[1]), sep->argplus[2]);
  4606. else if (strncmp(command, "rank_permission", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  4607. guild->SetPermission(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  4608. else if (strncmp(command, "filter_event", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  4609. guild->SetEventFilter(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  4610. else if (strncmp(command, "kick", length) == 0 && sep->arg[1] && guild)
  4611. guild->KickGuildMember(client, sep->arg[1]);
  4612. else if (strncmp(command, "demote", length) == 0 && sep->arg[1] && guild)
  4613. guild->DemoteGuildMember(client, sep->arg[1]);
  4614. else if (strncmp(command, "promote", length) == 0 && sep->arg[1] && guild)
  4615. guild->PromoteGuildMember(client, sep->arg[1]);
  4616. else if (strncmp(command, "points", length) == 0 && guild)
  4617. {
  4618. if (sep->arg[1] && strncmp(sep->arg[1], "add", length) == 0)
  4619. {
  4620. if (sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  4621. {
  4622. float points = atof(sep->arg[2]);
  4623. const char* option = sep->arg[3];
  4624. const char* comment = sep->argplus[4];
  4625. if (strncmp(option, "all", strlen(option)) == 0)
  4626. guild->AddPointsToAll(client, points, comment);
  4627. else if (strncmp(option, "online", strlen(option)) == 0)
  4628. guild->AddPointsToAllOnline(client, points, comment);
  4629. else if (strncmp(option, "group", strlen(option)) == 0)
  4630. guild->AddPointsToGroup(client, points, comment);
  4631. else if (strncmp(option, "raid", strlen(option)) == 0)
  4632. guild->AddPointsToRaid(client, points, comment);
  4633. else
  4634. guild->AddPointsToGuildMember(client, points, option, comment);
  4635. }
  4636. }
  4637. else if (sep->arg[1] && strncmp(sep->arg[1], "view", strlen(sep->arg[1])) == 0 && sep->arg[2])
  4638. guild->ViewGuildMemberPoints(client, sep->arg[2]);
  4639. else
  4640. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild points command: %s", sep->argplus[0]);
  4641. }
  4642. else if (strncmp(command, "motd", length) == 0 && sep->arg[1] && guild)
  4643. guild->SetMOTD(sep->argplus[1]);
  4644. else if (strncmp(command, "recruiting", length) == 0 && guild)
  4645. {
  4646. if (sep->arg[1])
  4647. {
  4648. const char* option = sep->arg[1];
  4649. if (strncmp(option, "short_text", strlen(option)) == 0 && sep->arg[2])
  4650. guild->SetRecruitingShortDesc(sep->argplus[2]);
  4651. else if (strncmp(option, "long_text", strlen(option)) == 0 && sep->arg[2])
  4652. guild->SetRecruitingFullDesc(sep->argplus[2]);
  4653. else if (strncmp(option, "flag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  4654. guild->SetRecruitingFlag(atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  4655. else if (strncmp(option, "min_level", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  4656. guild->SetRecruitingMinLevel(atoi(sep->arg[2]));
  4657. else if (strncmp(option, "playstyle", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  4658. guild->SetRecruitingPlayStyle(atoi(sep->arg[2]));
  4659. else if (strncmp(option, "tag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && sep->IsNumber(3))
  4660. guild->SetRecruitingDescTag(atoi(sep->arg[2]), atoi(sep->arg[3]));
  4661. else if (strncmp(command, "recruiting", strlen(option)) == 0)
  4662. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_RECRUITING_FOR_GUILD, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  4663. else
  4664. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  4665. }
  4666. else
  4667. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  4668. }
  4669. else if (strncmp(command, "notify_online", length) == 0 && sep->arg[1] && guild)
  4670. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_NOTIFY_LOGINS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  4671. else if (strncmp(command, "event_privacy", length) == 0 && sep->arg[1] && guild)
  4672. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_DONT_GENERATE_EVENTS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  4673. else if (strncmp(command, "recruiter", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  4674. guild->SetGuildRecruiter(client, sep->arg[1], strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  4675. else if (strncmp(command, "recruiter_description", length) == 0 && sep->arg[1] && guild)
  4676. guild->SetGuildRecruiterDescription(client, sep->argplus[1]);
  4677. else if (strncmp(command, "lock_event", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  4678. guild->LockGuildEvent(atoul(sep->arg[1]), strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  4679. else if (strncmp(command, "delete_event", length) == 0 && sep->arg[1] && guild)
  4680. guild->DeleteGuildEvent(atoul(sep->arg[1]));
  4681. else if (strncmp(command, "invite", length) == 0 && guild)
  4682. {
  4683. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  4684. guild->InvitePlayer(client, sep->arg[1]);
  4685. else
  4686. {
  4687. Spawn* target = client->GetPlayer()->GetTarget();
  4688. if (target)
  4689. {
  4690. if (target->IsPlayer())
  4691. guild->InvitePlayer(client, target->GetName());
  4692. else
  4693. client->Message(CHANNEL_COLOR_WHITE, "%s is not a player.", target->GetName());
  4694. }
  4695. }
  4696. }
  4697. else if (strncmp(command, "accept", length) == 0)
  4698. {
  4699. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  4700. if (pgi && pgi->guild && pgi->invited_by)
  4701. pgi->guild->AddNewGuildMember(client, pgi->invited_by->GetName());
  4702. client->SetPendingGuildInvite(0);
  4703. }
  4704. else if (strncmp(command, "decline", length) == 0)
  4705. {
  4706. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  4707. if (pgi && pgi->guild && pgi->invited_by)
  4708. {
  4709. Client* client_inviter = pgi->invited_by->GetZone()->GetClientBySpawn(pgi->invited_by);
  4710. if (client_inviter)
  4711. client_inviter->Message(CHANNEL_COLOR_WHITE, "%s has declined your invitation to join %s.", client->GetPlayer()->GetName(), pgi->guild->GetName());
  4712. }
  4713. client->SetPendingGuildInvite(0);
  4714. }
  4715. else if (strncmp(command, "create", length) == 0 && sep->arg[1])
  4716. {
  4717. const char* guild_name = sep->argplus[1];
  4718. if (!guild_list.GetGuild(guild_name))
  4719. world.CreateGuild(guild_name, client, client->GetPlayer()->GetGroupMemberInfo() ? client->GetPlayer()->GetGroupMemberInfo()->group_id : 0);
  4720. else
  4721. client->SimpleMessage(CHANNEL_COLOR_WHITE, "A guild with that name already exists.");
  4722. }
  4723. else if (strncmp(command, "search", length) == 0)
  4724. client->ShowGuildSearchWindow();
  4725. else if (strncmp(command, "recruiting_details", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  4726. {
  4727. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  4728. if (to_guild)
  4729. to_guild->SendGuildRecruitingDetails(client);
  4730. }
  4731. else if (strncmp(command, "recruiting_image", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  4732. {
  4733. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  4734. if (to_guild)
  4735. to_guild->SendGuildRecruitingImages(client);
  4736. }
  4737. else if (strncmp(command, "recruiter_adventure_class", length) == 0)
  4738. {
  4739. if (sep->arg[1])
  4740. {
  4741. const char* option = sep->arg[1];
  4742. if (strncmp(option, "toggle", strlen(option)) == 0)
  4743. guild->ToggleGuildRecruiterAdventureClass(client);
  4744. }
  4745. else
  4746. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiter_adventure_class command: '%s'", sep->argplus[0]);
  4747. }
  4748. else if (strncmp(command, "display_heraldry", length) == 0)
  4749. {
  4750. // JA: not sure this is right...
  4751. client->GetPlayer()->toggle_character_flag(CF_SHOW_GUILD_HERALDRY);
  4752. client->GetPlayer()->SetCharSheetChanged(true);
  4753. }
  4754. else
  4755. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild command: '%s'", sep->argplus[0]);
  4756. }
  4757. }
  4758. /*
  4759. Function: Command_GuildCreate()
  4760. Purpose : Display's in-game Guild Creation window
  4761. Dev : Scatman
  4762. */
  4763. void Commands::Command_CreateGuild(Client* client)
  4764. {
  4765. client->SendGuildCreateWindow();
  4766. }
  4767. /*
  4768. Function: Command_SetGuildOfficerNote()
  4769. Purpose :
  4770. Dev : Scatman
  4771. */
  4772. void Commands::Command_SetGuildOfficerNote(Client* client, Seperator* sep)
  4773. {
  4774. if (sep && sep->arg[0] && sep->arg[1])
  4775. {
  4776. Guild* guild = client->GetPlayer()->GetGuild();
  4777. if (guild)
  4778. guild->SetGuildOfficerNote(sep->arg[0], sep->argplus[1]);
  4779. }
  4780. }
  4781. /*
  4782. Function: Command_SetGuildMemberNote()
  4783. Purpose :
  4784. Dev : Scatman
  4785. */
  4786. void Commands::Command_SetGuildMemberNote(Client* client, Seperator* sep)
  4787. {
  4788. if (sep && sep->arg[0] && sep->arg[1])
  4789. {
  4790. Guild* guild = client->GetPlayer()->GetGuild();
  4791. if (guild)
  4792. guild->SetGuildMemberNote(sep->arg[0], sep->argplus[1]);
  4793. }
  4794. }
  4795. /*
  4796. Function: Command_GuildSay()
  4797. Purpose :
  4798. Dev : Scatman
  4799. */
  4800. void Commands::Command_GuildSay(Client* client, Seperator* sep)
  4801. {
  4802. Guild* guild = client->GetPlayer()->GetGuild();
  4803. if (guild)
  4804. {
  4805. if (sep && sep->arg[0])
  4806. guild->HandleGuildSay(client, sep->argplus[0]);
  4807. }
  4808. else
  4809. client->SimpleMessage(CHANNEL_COLOR_WHITE, "You are not a member of a guild");
  4810. }
  4811. /*
  4812. Function: Command_OfficerSay()
  4813. Purpose :
  4814. Dev : Scatman
  4815. */
  4816. void Commands::Command_OfficerSay(Client* client, Seperator* sep)
  4817. {
  4818. Guild* guild = client->GetPlayer()->GetGuild();
  4819. if (guild)
  4820. {
  4821. if (sep && sep->arg[0])
  4822. guild->HandleOfficerSay(client, sep->argplus[0]);
  4823. }
  4824. else
  4825. client->SimpleMessage(CHANNEL_COLOR_WHITE, "You are not a member of a guild");
  4826. }
  4827. /*
  4828. Function: Command_Guilds()
  4829. Purpose : Shows help for /guild command
  4830. Params :
  4831. Dev : Scatman
  4832. Example :
  4833. */
  4834. void Commands::Command_Guilds(Client* client)
  4835. {
  4836. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds [create|delete|add|remove|list]");
  4837. }
  4838. /*
  4839. Function: Command_GuildsAdd()
  4840. Purpose : Add's players to a guild
  4841. Params : guild_name|guild_id, player name
  4842. Dev : Scatman
  4843. Example : /guilds add 1 Admin = adds player Admin to guild_id 1
  4844. */
  4845. void Commands::Command_GuildsAdd(Client* client, Seperator* sep)
  4846. {
  4847. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  4848. {
  4849. Guild* guild = 0;
  4850. bool found = true;
  4851. if (sep->IsNumber(0))
  4852. {
  4853. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  4854. if (!guild)
  4855. {
  4856. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  4857. found = false;
  4858. }
  4859. }
  4860. else
  4861. {
  4862. guild = guild_list.GetGuild(sep->arg[0]);
  4863. if (!guild)
  4864. {
  4865. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  4866. found = false;
  4867. }
  4868. }
  4869. if (found)
  4870. {
  4871. Client* to_client = 0;
  4872. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  4873. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  4874. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  4875. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  4876. if (to_client)
  4877. guild->InvitePlayer(client, to_client->GetPlayer()->GetName());
  4878. else
  4879. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  4880. }
  4881. }
  4882. else
  4883. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds add [guild name|guild id] (player name).");
  4884. }
  4885. /*
  4886. Function: Command_GuildsCreate()
  4887. Purpose : Creates a guild
  4888. Params : guild_name, player_name (optional)
  4889. Dev : Scatman
  4890. Example : /guilds create [guild name] (player name)
  4891. */
  4892. void Commands::Command_GuildsCreate(Client* client, Seperator* sep)
  4893. {
  4894. if (sep && sep->arg[0])
  4895. {
  4896. const char* guild_name = sep->arg[0];
  4897. if (!guild_list.GetGuild(guild_name))
  4898. {
  4899. bool ret = false;
  4900. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  4901. {
  4902. Client* to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  4903. if (to_client)
  4904. {
  4905. world.CreateGuild(guild_name, to_client);
  4906. ret = true;
  4907. }
  4908. else
  4909. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player with name '%s'", sep->arg[1]);
  4910. }
  4911. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  4912. {
  4913. Client* to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  4914. if (to_client)
  4915. {
  4916. world.CreateGuild(guild_name, to_client);
  4917. ret = true;
  4918. }
  4919. }
  4920. else
  4921. {
  4922. world.CreateGuild(guild_name);
  4923. ret = true;
  4924. }
  4925. if (ret)
  4926. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully created.", guild_name);
  4927. else
  4928. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the guild.");
  4929. }
  4930. else
  4931. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' already exists.", guild_name);
  4932. }
  4933. else
  4934. 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.");
  4935. }
  4936. /*
  4937. Function: Command_GuildsDelete()
  4938. Purpose : Delete's a guild
  4939. Params : guild name
  4940. Dev : Scatman
  4941. Example : /guilds delete Test
  4942. */
  4943. void Commands::Command_GuildsDelete(Client* client, Seperator* sep)
  4944. {
  4945. if (sep && sep->arg[0])
  4946. {
  4947. Guild* guild = 0;
  4948. bool found = true;
  4949. if (sep->IsNumber(0))
  4950. {
  4951. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  4952. if (!guild)
  4953. {
  4954. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  4955. found = false;
  4956. }
  4957. }
  4958. else
  4959. {
  4960. guild = guild_list.GetGuild(sep->arg[0]);
  4961. if (!guild)
  4962. {
  4963. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  4964. found = false;
  4965. }
  4966. }
  4967. if (found)
  4968. {
  4969. guild->RemoveAllGuildMembers();
  4970. database.DeleteGuild(guild);
  4971. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully deleted.", guild->GetName());
  4972. guild_list.RemoveGuild(guild, true);
  4973. }
  4974. }
  4975. else
  4976. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds delete [guild name].");
  4977. }
  4978. /*
  4979. Function: Command_GuildsList()
  4980. Purpose : Lists current guilds on server
  4981. Params :
  4982. Dev : Scatman
  4983. Example : /guilds list
  4984. */
  4985. void Commands::Command_GuildsList(Client* client)
  4986. {
  4987. MutexMap<int32, Guild*>* guilds = guild_list.GetGuilds();
  4988. MutexMap<int32, Guild*>::iterator itr = guilds->begin();
  4989. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Guild List:");
  4990. if (guilds->size() == 0)
  4991. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "None.");
  4992. else {
  4993. while (itr.Next()) {
  4994. Guild* guild = itr.second;
  4995. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", guild->GetID(), guild->GetName());
  4996. }
  4997. }
  4998. }
  4999. /*
  5000. Function: Command_GuildsRemove()
  5001. Purpose : Removes a player from a guild
  5002. Params : guild name|guild id, player name
  5003. Dev : Scatman
  5004. Example : /guilds remove 1 Admin = removes Admin from guild 1
  5005. */
  5006. void Commands::Command_GuildsRemove(Client* client, Seperator* sep)
  5007. {
  5008. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  5009. {
  5010. Guild* guild = 0;
  5011. bool found = true;
  5012. if (sep->IsNumber(0))
  5013. {
  5014. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  5015. if (!guild)
  5016. {
  5017. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  5018. found = false;
  5019. }
  5020. }
  5021. else
  5022. {
  5023. guild = guild_list.GetGuild(sep->arg[0]);
  5024. if (!guild)
  5025. {
  5026. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  5027. found = false;
  5028. }
  5029. }
  5030. if (found)
  5031. {
  5032. Client* to_client = 0;
  5033. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  5034. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  5035. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  5036. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  5037. if (to_client)
  5038. {
  5039. Player* to_player = to_client->GetPlayer();
  5040. if (to_player->GetGuild())
  5041. {
  5042. if (to_player->GetGuild() == guild)
  5043. {
  5044. guild->KickGuildMember(client, to_player->GetName());
  5045. }
  5046. else
  5047. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in the guild '%s'.", to_player->GetName(), guild->GetName());
  5048. }
  5049. else
  5050. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in a guild.", to_player->GetName());
  5051. }
  5052. else
  5053. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  5054. }
  5055. }
  5056. else
  5057. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds remove [guild name|guild id] (player name).");
  5058. }
  5059. /*
  5060. Function: Command_InspectPlayer()
  5061. Purpose : Handle the Inspect functions
  5062. Params : Client to inspect
  5063. Dev : Scatman
  5064. Example : /inspect Scatman
  5065. */
  5066. void Commands::Command_InspectPlayer(Client* client, Seperator* sep)
  5067. {
  5068. if (sep && sep->arg[0])
  5069. {
  5070. Client* inspect_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  5071. if (inspect_client)
  5072. client->InspectPlayer(inspect_client->GetPlayer());
  5073. }
  5074. else
  5075. {
  5076. Spawn* target = client->GetPlayer()->GetTarget();
  5077. if (target && target->IsPlayer())
  5078. client->InspectPlayer((Player*)target);
  5079. }
  5080. }
  5081. /*
  5082. Function: Command_Inventory()
  5083. Purpose : Handle changes in player inventory
  5084. Params : <TBD>
  5085. Dev : All
  5086. Example : /inventory delete item_id
  5087. */
  5088. void Commands::Command_Inventory(Client* client, Seperator* sep, EQ2_RemoteCommandString* command)
  5089. {
  5090. PrintSep(sep, "Command_Inventory"); // temp to figure out the params
  5091. Player* player = client->GetPlayer();
  5092. if(sep && sep->arg[0][0])
  5093. {
  5094. LogWrite(COMMAND__INFO, 0, "Command", "command: %s", command->command.data.c_str());
  5095. if(client->GetPlayer()->GetHP() == 0)
  5096. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  5097. else if(sep->arg[1][0] && strncasecmp("destroy", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  5098. {
  5099. int16 index = atoi(sep->arg[1]);
  5100. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  5101. if(item)
  5102. {
  5103. if(item->GetItemScript() && lua_interface)
  5104. lua_interface->RunItemScript(item->GetItemScript(), "destroyed", item, client->GetPlayer());
  5105. int32 bag_id = item->details.inv_slot_id;
  5106. database.DeleteItem(client->GetCharacterID(), item, 0);
  5107. client->GetPlayer()->item_list.DestroyItem(index);
  5108. EQ2Packet* outapp = client->GetPlayer()->SendInventoryUpdate(client->GetVersion());
  5109. client->QueuePacket(outapp);
  5110. outapp = client->GetPlayer()->SendBagUpdate(bag_id, client->GetVersion());
  5111. if (outapp)
  5112. client->QueuePacket(outapp);
  5113. }
  5114. }
  5115. 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))
  5116. {
  5117. int16 from_index = atoi(sep->arg[1]);
  5118. sint16 to_slot = atoi(sep->arg[2]);
  5119. sint32 bag_id = atol(sep->arg[3]);
  5120. int8 charges = atoi(sep->arg[4]);
  5121. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(from_index);
  5122. if(bag_id == -4 && !client->GetPlayer()->item_list.SharedBankAddAllowed(item))
  5123. {
  5124. client->SimpleMessage(CHANNEL_COLOR_RED, "That item (or an item inside) cannot be shared.");
  5125. return;
  5126. }
  5127. sint32 old_inventory_id = 0;
  5128. if(item)
  5129. old_inventory_id = item->details.inv_slot_id;
  5130. //autobank
  5131. if (bag_id == -3 && to_slot == -1)
  5132. {
  5133. if (player->HasFreeBankSlot())
  5134. to_slot = player->FindFreeBankSlot();
  5135. else
  5136. {
  5137. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free bank slots.");
  5138. return;
  5139. }
  5140. }
  5141. //auto inventory
  5142. if (bag_id == 0 && to_slot == -1)
  5143. {
  5144. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  5145. {
  5146. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free slots.");
  5147. return;
  5148. }
  5149. }
  5150. EQ2Packet* outapp = client->GetPlayer()->MoveInventoryItem(bag_id, from_index, (int8)to_slot, charges, client->GetVersion());
  5151. client->QueuePacket(outapp);
  5152. //removed from bag send update
  5153. if(old_inventory_id > 0 && item && item->details.inv_slot_id != old_inventory_id)
  5154. {
  5155. outapp = client->GetPlayer()->SendBagUpdate(old_inventory_id, client->GetVersion());
  5156. if(outapp)
  5157. client->QueuePacket(outapp);
  5158. }
  5159. if(item && item->details.inv_slot_id > 0 && item->details.inv_slot_id != old_inventory_id)
  5160. {
  5161. outapp = client->GetPlayer()->SendBagUpdate(item->details.inv_slot_id, client->GetVersion());
  5162. if(outapp)
  5163. client->QueuePacket(outapp);
  5164. }
  5165. }
  5166. else if(sep->arg[1][0] && strncasecmp("equip", sep->arg[0], 5) == 0 && sep->IsNumber(1))
  5167. {
  5168. if(client->GetPlayer()->EngagedInCombat())
  5169. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not equip items while in combat.");
  5170. else
  5171. {
  5172. int16 index = atoi(sep->arg[1]);
  5173. int8 slot_id = 255;
  5174. if(sep->arg[2][0] && sep->IsNumber(2))
  5175. slot_id = atoi(sep->arg[2]);
  5176. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), slot_id);
  5177. EQ2Packet* outapp = 0;
  5178. for(int32 i=0;i<packets.size();i++)
  5179. {
  5180. outapp = packets[i];
  5181. if(outapp)
  5182. client->QueuePacket(outapp);
  5183. }
  5184. client->GetPlayer()->ChangePrimaryWeapon();
  5185. client->GetPlayer()->ChangeSecondaryWeapon();
  5186. client->GetPlayer()->ChangeRangedWeapon();
  5187. EQ2Packet* characterSheetPackets = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion());
  5188. client->QueuePacket(characterSheetPackets);
  5189. }
  5190. }
  5191. else if (sep->arg[1][0] && strncasecmp("unpack", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  5192. {
  5193. if (client->GetPlayer()->EngagedInCombat())
  5194. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unpack items while in combat.");
  5195. else {
  5196. int16 index = atoi(sep->arg[1]);
  5197. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  5198. if (item) {
  5199. // client->GetPlayer()->item_list.DestroyItem(index);
  5200. if (item->item_sets.size() > 0) {
  5201. for (int32 i = 0; i < item->item_sets.size(); i++) {
  5202. ItemSet* set = item->item_sets[i];
  5203. if (set->item_stack_size == 0)
  5204. set->item_stack_size += 1;
  5205. client->AddItem(set->item_id, set->item_stack_size);
  5206. }
  5207. }
  5208. }
  5209. client->RemoveItem(item, 1);
  5210. }
  5211. }
  5212. else if(sep->arg[1][0] && strncasecmp("unequip", sep->arg[0], 7) == 0 && sep->IsNumber(1))
  5213. {
  5214. if(client->GetPlayer()->EngagedInCombat())
  5215. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unequip items while in combat.");
  5216. else
  5217. {
  5218. int16 index = atoi(sep->arg[1]);
  5219. sint32 bag_id = -999;
  5220. int8 to_slot = 255;
  5221. if(sep->arg[3][0])
  5222. {
  5223. if(sep->IsNumber(2))
  5224. bag_id = atol(sep->arg[2]);
  5225. if(sep->IsNumber(3))
  5226. to_slot = atoi(sep->arg[3]);
  5227. }
  5228. vector<EQ2Packet*> packets = client->GetPlayer()->UnequipItem(index, bag_id, to_slot, client->GetVersion());
  5229. EQ2Packet* outapp = 0;
  5230. for(int32 i=0;i<packets.size();i++)
  5231. {
  5232. outapp = packets[i];
  5233. if(outapp)
  5234. client->QueuePacket(outapp);
  5235. }
  5236. client->GetPlayer()->ChangePrimaryWeapon();
  5237. client->GetPlayer()->ChangeSecondaryWeapon();
  5238. client->GetPlayer()->ChangeRangedWeapon();
  5239. EQ2Packet* characterSheetPackets = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion());
  5240. client->QueuePacket(characterSheetPackets);
  5241. }
  5242. }
  5243. else if(sep->arg[2][0] && strncasecmp("swap_equip", sep->arg[0], 10) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  5244. {
  5245. LogWrite(MISC__TODO, 1, "TODO", " fix this, need to get how live does it\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  5246. int16 index1 = atoi(sep->arg[1]);
  5247. int16 index2 = atoi(sep->arg[2]);
  5248. EQ2Packet* outapp = client->GetPlayer()->SwapEquippedItems(index1, index2, client->GetVersion());
  5249. if(outapp)
  5250. client->QueuePacket(outapp);
  5251. else
  5252. {
  5253. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to swap items");
  5254. return;
  5255. }
  5256. }
  5257. else if (sep->arg[2][0] && strncasecmp("pop", sep->arg[0], 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  5258. {
  5259. sint16 to_slot = atoi(sep->arg[1]);
  5260. sint32 bag_id = atoi(sep->arg[2]);
  5261. Item* item = client->GetPlayer()->item_list.GetOverflowItem();
  5262. if (item) {
  5263. //auto inventory
  5264. if (bag_id == 0 && to_slot == -1)
  5265. {
  5266. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  5267. {
  5268. client->SimpleMessage(CHANNEL_ERROR, "You do not have any free slots.");
  5269. return;
  5270. }
  5271. // Set the slot for the item
  5272. item->details.inv_slot_id = bag_id;
  5273. item->details.slot_id = to_slot;
  5274. // Flag the item so it gets saved in its new location
  5275. item->save_needed = true;
  5276. // Add the item to its new location
  5277. player->item_list.AddItem(item);
  5278. // Remove the item from the overflow list
  5279. player->item_list.RemoveOverflowItem(item);
  5280. // Send the inventory update packet
  5281. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5282. return;
  5283. }
  5284. else if (bag_id == -3 && to_slot == -1) {
  5285. // Auto Bank
  5286. if (!player->item_list.GetFirstFreeBankSlot(&bag_id, &to_slot)) {
  5287. client->SimpleMessage(CHANNEL_STATUS, "You do not have any free bank slots.");
  5288. return;
  5289. }
  5290. item->details.inv_slot_id = bag_id;
  5291. item->details.slot_id = to_slot;
  5292. item->save_needed = true;
  5293. player->item_list.AddItem(item);
  5294. player->item_list.RemoveOverflowItem(item);
  5295. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5296. }
  5297. else if (bag_id == -4) {
  5298. // Shared Bank
  5299. if (!player->item_list.SharedBankAddAllowed(item)) {
  5300. client->SimpleMessage(CHANNEL_STATUS, "That item (or an item inside) cannot be shared.");
  5301. return;
  5302. }
  5303. Item* tmp_item = player->item_list.GetItem(-4, to_slot);
  5304. if (tmp_item) {
  5305. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  5306. return;
  5307. }
  5308. else {
  5309. item->details.inv_slot_id = bag_id;
  5310. item->details.slot_id = to_slot;
  5311. item->save_needed = true;
  5312. player->item_list.AddItem(item);
  5313. player->item_list.RemoveOverflowItem(item);
  5314. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5315. return;
  5316. }
  5317. }
  5318. else {
  5319. // Try to get an item from the given bag id and slot id
  5320. Item* tmp_item = player->item_list.GetItem(bag_id, to_slot);
  5321. // Check to see if we got an item, if we do send an error,
  5322. // if we don't put the overflow item into this slot
  5323. if (tmp_item) {
  5324. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  5325. }
  5326. else {
  5327. item->details.inv_slot_id = bag_id;
  5328. item->details.slot_id = to_slot;
  5329. item->save_needed = true;
  5330. player->item_list.AddItem(item);
  5331. player->item_list.RemoveOverflowItem(item);
  5332. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5333. return;
  5334. }
  5335. }
  5336. }
  5337. }
  5338. }
  5339. else
  5340. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /inventory {destroy|move|equip|unequip|swap_equip|pop} {item_id} [to_slot] [bag_id]");
  5341. }
  5342. /*
  5343. Function: Command_IRC()
  5344. Purpose : Handle the IRC functions
  5345. Params : IRC Commands
  5346. Dev : Scatman
  5347. Example : /irc say #Channel Hello World!
  5348. */
  5349. void Commands::Command_IRC(Client* client, Seperator* sep)
  5350. {
  5351. if (!rule_manager.GetGlobalRule(R_World, IRCEnabled)->GetBool()) {
  5352. client->SimpleMessage(CHANNEL_STATUS, "IRC is currently disabled on this server");
  5353. return;
  5354. }
  5355. if (sep && sep->arg[0][0]) {
  5356. if (strcasecmp(sep->arg[0], "say") == 0) {
  5357. if (sep->arg[1][0] && sep->arg[2][0]) {
  5358. if (sep->IsNumber(sep->arg[1]))
  5359. irc.Say(client, atoul(sep->arg[1]), sep->argplus[2]);
  5360. else
  5361. irc.Say(client, sep->arg[1], sep->argplus[2]);
  5362. }
  5363. else
  5364. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc say <channel name | channel index> <message>");
  5365. }
  5366. else if (strcasecmp(sep->arg[0], "join") == 0) {
  5367. if (sep->arg[1][0])
  5368. irc.JoinChannel(client, sep->arg[1]);
  5369. else
  5370. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc join <channel name>");
  5371. }
  5372. else if (strcasecmp(sep->arg[0], "leave") == 0) {
  5373. if (sep->arg[1][0])
  5374. irc.LeaveChannel(client, sep->arg[1]);
  5375. else
  5376. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc leave <channel name>");
  5377. }
  5378. else if (strcasecmp(sep->arg[0], "list") == 0)
  5379. irc.ListChannels(client);
  5380. else if (strcasecmp(sep->arg[0], "connect") == 0) {
  5381. if (sep->arg[1][0] && sep->arg[2][0] && sep->IsNumber(2))
  5382. irc.ConnectToServer(client, sep->arg[1], atoi(sep->arg[2]), sep->arg[3]);
  5383. else
  5384. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc connect <host> <port> (nick)");
  5385. }
  5386. else if (strcasecmp(sep->arg[0], "disconnect") == 0)
  5387. irc.DisconnectFromServer(client);
  5388. else
  5389. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown IRC command.");
  5390. }
  5391. else
  5392. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown IRC command.");
  5393. }
  5394. /*
  5395. Function: Command_Languages()
  5396. Purpose : Show's languages the player knows
  5397. Params :
  5398. Dev : Zcoretri
  5399. Example :
  5400. */
  5401. void Commands::Command_Languages(Client* client, Seperator* sep)
  5402. {
  5403. list<Language*>* languages = client->GetPlayer()->GetPlayerLanguages()->GetAllLanguages();
  5404. list<Language*>::iterator itr;
  5405. Language* language;
  5406. client->Message(CHANNEL_COLOR_WHITE, "You know the following languages:");
  5407. for(itr = languages->begin(); itr != languages->end(); itr++)
  5408. {
  5409. language = *itr;
  5410. client->Message(CHANNEL_COLOR_WHITE, "%s", language->GetName());
  5411. }
  5412. }
  5413. /*
  5414. Function: Command_SetLanguage()
  5415. Purpose : Handles language commands
  5416. Params : Language ID
  5417. Dev : Zcoretri
  5418. Example :
  5419. */
  5420. void Commands::Command_SetLanguage(Client* client, Seperator* sep)
  5421. {
  5422. Player* player = client->GetPlayer();
  5423. if (sep && sep->arg[0])
  5424. {
  5425. if(!sep->IsNumber(0))
  5426. {
  5427. //String passed in
  5428. const char* value = sep->arg[0];
  5429. if(strncasecmp(value, "Common", strlen(value)) == 0)
  5430. {
  5431. database.SaveCharacterCurrentLang(0, client->GetCharacterID(), client);
  5432. client->SendLanguagesUpdate(0);
  5433. client->Message(CHANNEL_COLOR_WHITE, "You are now speaking %s", value);
  5434. }
  5435. else
  5436. {
  5437. if(player->HasLanguage(value))
  5438. {
  5439. Language* language = player->GetPlayerLanguages()->GetLanguageByName(value);
  5440. database.SaveCharacterCurrentLang(language->GetID(), client->GetCharacterID(), client);
  5441. client->SendLanguagesUpdate(language->GetID());
  5442. client->Message(CHANNEL_COLOR_WHITE, "You are now speaking %s", language->GetName());
  5443. }
  5444. else
  5445. client->Message(CHANNEL_COLOR_WHITE, "You do not know how to speak %s", value);
  5446. }
  5447. }
  5448. else
  5449. {
  5450. //Number passed in
  5451. int32 id = atoul(sep->arg[0]);
  5452. if(player->HasLanguage(id))
  5453. {
  5454. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  5455. database.SaveCharacterCurrentLang(id, client->GetCharacterID(), client);
  5456. client->SendLanguagesUpdate(id);
  5457. client->Message(CHANNEL_COLOR_WHITE, "You are now speaking %s", language->GetName());
  5458. }
  5459. else
  5460. {
  5461. Language* language = master_languages_list.GetLanguage(id);
  5462. client->Message(CHANNEL_COLOR_WHITE, "You do not know how to speak %s", language->GetName());
  5463. }
  5464. }
  5465. }
  5466. else
  5467. {
  5468. //No value was passed in
  5469. int32 id = database.GetCharacterCurrentLang(client->GetCharacterID(), player);
  5470. if(id > 0)
  5471. {
  5472. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  5473. client->Message(CHANNEL_COLOR_WHITE, "You are currently speaking %s ", language->GetName());
  5474. }
  5475. else
  5476. client->Message(CHANNEL_COLOR_WHITE, "You are currently speaking Common");
  5477. }
  5478. }
  5479. /*
  5480. Function: Command_LastName()
  5481. Purpose : Sets player surname
  5482. Params : Name text
  5483. Dev : theFoof
  5484. Example :
  5485. */
  5486. void Commands::Command_LastName(Client* client, Seperator* sep)
  5487. {
  5488. if (!client)
  5489. return;
  5490. if (sep && sep->arg[0])
  5491. {
  5492. if (!client->GetPlayer()->get_character_flag(CF_ENABLE_CHANGE_LASTNAME)){
  5493. client->Message(CHANNEL_COLOR_YELLOW, "You must be atleast level %i to change your last name.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  5494. return;
  5495. }
  5496. client->RemovePendingLastName();
  5497. uchar* checkname = (uchar*)sep->arg[0];
  5498. bool valid_name = true;
  5499. for (int32 i = 0; i < strlen(sep->arg[0]); i++) {
  5500. if (!alpha_check(checkname[i])) {
  5501. valid_name = false;
  5502. break;
  5503. }
  5504. }
  5505. if (!valid_name) {
  5506. client->Message(CHANNEL_COLOR_YELLOW, "Your last name can only contain letters.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  5507. return;
  5508. }
  5509. string last_name = (string)sep->arg[0];
  5510. int8 max_length = rule_manager.GetGlobalRule(R_Player, MaxLastNameLength)->GetInt8();
  5511. int8 min_length = rule_manager.GetGlobalRule(R_Player, MinLastNameLength)->GetInt8();
  5512. if (last_name.length() <= max_length && last_name.length() >= min_length){
  5513. client->SetPendingLastName(last_name);
  5514. client->SendLastNameConfirmation();
  5515. }
  5516. else
  5517. client->Message(CHANNEL_COLOR_YELLOW, "Your last name must be between %i and %i characters long.", min_length, max_length);
  5518. }
  5519. }
  5520. /*
  5521. Function: Command_ConfirmLastName()
  5522. Purpose : Confirms setting of player surname
  5523. Params : Name text
  5524. Dev : theFoof
  5525. Example :
  5526. */
  5527. void Commands::Command_ConfirmLastName(Client* client, Seperator* sep)
  5528. {
  5529. if (!client)
  5530. return;
  5531. string* name = client->GetPendingLastName();
  5532. if (name){
  5533. Player* player = client->GetPlayer();
  5534. player->SetLastName(name->c_str(), false);
  5535. client->SendTitleUpdate();
  5536. player->SetCharSheetChanged(true);
  5537. client->RemovePendingLastName();
  5538. }
  5539. }
  5540. /*
  5541. Function: Command_Location()
  5542. Purpose : Display's Help for /location commands
  5543. Params :
  5544. Dev : Scatman
  5545. Example : /location = show's help for command
  5546. */
  5547. void Commands::Command_Location(Client* client)
  5548. {
  5549. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Valid /location commands are:");
  5550. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location create [name] (include y). Include y defaults to false");
  5551. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location add [location id]");
  5552. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location remove [location point id]");
  5553. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location delete [location id]");
  5554. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location list [locations|points] [location id if points used]");
  5555. }
  5556. /*
  5557. Function: Command_LocationAdd()
  5558. Purpose : Add's a location to an existing location config
  5559. Params : location_id
  5560. Dev : Scatman
  5561. Example : /location add {location_id}
  5562. */
  5563. void Commands::Command_LocationAdd(Client* client, Seperator* sep)
  5564. {
  5565. if (sep && sep->arg[0] && sep->IsNumber(0))
  5566. {
  5567. int32 location_id = atoul(sep->arg[0]);
  5568. float x = client->GetPlayer()->GetX();
  5569. float y = client->GetPlayer()->GetY();
  5570. float z = client->GetPlayer()->GetZ();
  5571. if (database.AddLocationPoint(location_id, x, y, z))
  5572. client->Message(CHANNEL_COLOR_YELLOW, "Point (%f, %f, %f) was successfully added to location %u", x, y, z, location_id);
  5573. else
  5574. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist. Use /location create to create one", location_id);
  5575. }
  5576. else
  5577. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location add [location id]");
  5578. }
  5579. /*
  5580. Function: Command_LocationCreate()
  5581. Purpose : Creates a new location config
  5582. Params : location name, 0/1 for include_y (optional)
  5583. Dev : Scatman
  5584. Example : /location create Test 1 = creates a new location named Test with include_y True
  5585. */
  5586. void Commands::Command_LocationCreate(Client* client, Seperator* sep)
  5587. {
  5588. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  5589. {
  5590. const char* name = sep->arg[0];
  5591. bool include_y = false;
  5592. if (sep->arg[1] && sep->IsNumber(1) && atoi(sep->arg[1]) > 0)
  5593. include_y = true;
  5594. int32 location_id = database.CreateLocation(client->GetPlayer()->GetZone()->GetZoneID(), client->GetPlayer()->appearance.pos.grid_id, name, include_y);
  5595. if (location_id > 0)
  5596. client->Message(CHANNEL_COLOR_YELLOW, "Location '%s' was successfully created with location id %u", name, location_id);
  5597. else
  5598. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the requested location");
  5599. }
  5600. else
  5601. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location create [name] (include_y). Include y defaults to false");
  5602. }
  5603. /*
  5604. Function: Command_LocationDelete()
  5605. Purpose : Delete's a location config and all it's location points
  5606. Params : location_id
  5607. Dev : Scatman
  5608. Example : /location delete {location_id}
  5609. */
  5610. void Commands::Command_LocationDelete(Client* client, Seperator* sep)
  5611. {
  5612. if (sep && sep->arg[0] && sep->IsNumber(0))
  5613. {
  5614. int32 location_id = atoul(sep->arg[0]);
  5615. if (database.DeleteLocation(location_id))
  5616. client->Message(CHANNEL_COLOR_YELLOW, "Location id %u and all its points were successfully deleted", location_id);
  5617. else
  5618. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist", location_id);
  5619. }
  5620. else
  5621. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location delete [location id]");
  5622. }
  5623. /*
  5624. Function: Command_LocationList()
  5625. Purpose : Display's a list of location points
  5626. Params : location_id
  5627. Dev : Scatman
  5628. Example : /location list {location_id}
  5629. */
  5630. void Commands::Command_LocationList(Client* client, Seperator* sep)
  5631. {
  5632. if (sep && sep->arg[0])
  5633. {
  5634. const char* option = sep->arg[0];
  5635. if (strncmp(option, "locations", strlen(option)) == 0)
  5636. database.ListLocations(client);
  5637. else if (strncmp(option, "points", strlen(option)) == 0 && sep->arg[1] && sep->IsNumber(1))
  5638. {
  5639. int32 location_id = atoul(sep->arg[1]);
  5640. database.ListLocationPoints(client, location_id);
  5641. }
  5642. else
  5643. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  5644. }
  5645. else
  5646. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  5647. }
  5648. /*
  5649. Function: Command_LocationRemove()
  5650. Purpose : Removes a single location point from a location config
  5651. Params : location_point_id (gotten from /location list {id})
  5652. Dev : Scatman
  5653. Example : /location remove 1 = will remove location_point_id 1
  5654. */
  5655. void Commands::Command_LocationRemove(Client* client, Seperator* sep)
  5656. {
  5657. if (sep && sep->arg[0] && sep->IsNumber(0))
  5658. {
  5659. int32 location_point_id = atoul(sep->arg[0]);
  5660. if (database.DeleteLocationPoint(location_point_id))
  5661. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Location point was successfully deleted");
  5662. else
  5663. client->Message(CHANNEL_COLOR_YELLOW, "Location point with ID %u does not exist", location_point_id);
  5664. }
  5665. else
  5666. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location remove [location point id]");
  5667. }
  5668. /*
  5669. Function: Command_Merchant()
  5670. Purpose : Handles Merchant commands
  5671. Params : list
  5672. Dev : Scatman
  5673. Example : /merchant list
  5674. */
  5675. void Commands::Command_Merchant(Client* client, Seperator* sep, int handler)
  5676. {
  5677. if( handler == COMMAND_MERCHANT )
  5678. {
  5679. // /merchant command by itself shows help (to be extended)
  5680. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  5681. return;
  5682. }
  5683. else if( handler == COMMAND_MERCHANT_LIST )
  5684. {
  5685. // /merchant list command expects "description" param
  5686. if (sep && sep->arg[0])
  5687. {
  5688. const char* merchant_description = sep->argplus[0];
  5689. client->Message(CHANNEL_COLOR_YELLOW, "Listing merchants like '%s':", merchant_description);
  5690. map<int32, MerchantInfo*>* merchant_info = world.GetMerchantInfo();
  5691. map<int32, MerchantInfo*>::iterator itr;
  5692. for (itr = merchant_info->begin(); itr != merchant_info->end(); itr++)
  5693. {
  5694. string description = database.GetMerchantDescription(itr->first);
  5695. if (ToLower(description).find(ToLower(string(merchant_description))) < 0xFFFFFFFF)
  5696. client->Message(CHANNEL_COLOR_YELLOW, "Merchant ID: %u, Description: %s", itr->first, description.c_str());
  5697. }
  5698. }
  5699. else // no description
  5700. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  5701. }
  5702. }
  5703. /*
  5704. Function: Command_Modify()
  5705. Purpose : to replace our other "set" commands
  5706. Params : System = the system to modify, Action = the action to perform, Target = what to change (target, or index)
  5707. Dev : John Adams
  5708. Example : /modify spell set name "Aegolism III"
  5709. */
  5710. void Commands::Command_Modify(Client* client)
  5711. {
  5712. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /modify [system] [action] [field] [value] {target|id}");
  5713. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Systems: character, faction, guild, item, skill, spawn, spell, zone");
  5714. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Actions: set, create, delete, add, remove");
  5715. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Value : field name in the table being modified");
  5716. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target : modify current target, or specified {system} ID");
  5717. }
  5718. /*
  5719. Function: Command_ModifySpawn()
  5720. Purpose : replace "spawn set" commands
  5721. Params : Action : the action to perform (or special handler)
  5722. : Field : the DB field to change
  5723. : Value : what to set the value to
  5724. : Target : what object to change (my target, or spawn_id)
  5725. Dev : John Adams
  5726. Example : /modify spawn set name "Lady Vox"
  5727. :
  5728. Note : Special Handlers, like "zoneto" for Signs
  5729. : /modify spawn zoneto
  5730. : Will set a sign's zone x/y/z to my current coords
  5731. */
  5732. void Commands::Command_ModifySpawn(Client* client, Seperator* sep)
  5733. {
  5734. PrintSep(sep, "COMMAND_MODIFY");
  5735. // need at least 2 args for a valid command
  5736. if( sep && sep->arg[1] )
  5737. {
  5738. // JA: just a quick implementation because I need it :)
  5739. if (strcmp(sep->arg[0], "zoneto") == 0)
  5740. {
  5741. if( sep->IsNumber(1) )
  5742. {
  5743. int32 spawn_id = atoul(sep->arg[1]);
  5744. float x_coord = client->GetPlayer()->GetX();
  5745. float y_coord = client->GetPlayer()->GetY();
  5746. float z_coord = client->GetPlayer()->GetZ();
  5747. float h_coord = client->GetPlayer()->GetHeading();
  5748. database.SaveSignZoneToCoords(spawn_id, x_coord, y_coord, z_coord, h_coord);
  5749. }
  5750. else
  5751. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify spawn zoneto spawn_id - sets spawn_id to your coords");
  5752. }
  5753. }
  5754. else
  5755. Command_Modify(client);
  5756. }
  5757. /*
  5758. Function: Command_ModifyCharacter()
  5759. Purpose : to replace our other "set" commands
  5760. Params : Action : Add, Remove
  5761. : Field : copper, silver, gold, plat
  5762. : Value : min 1, max unlimited
  5763. : Target : Self, Player
  5764. Dev : Cynnar
  5765. Example : /modify character add gold 50
  5766. : /modify character remove silver 25
  5767. */
  5768. void Commands::Command_ModifyCharacter(Client* client, Seperator* sep)
  5769. {
  5770. PrintSep(sep, "COMMAND_MODIFY");
  5771. int64 value = 0;
  5772. Player* player = client->GetPlayer();
  5773. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  5774. player = (Player*)player->GetTarget();
  5775. // need at least 2 args for a valid command
  5776. if( sep && sep->arg[1] )
  5777. {
  5778. if (strcmp(sep->arg[0], "add") == 0)
  5779. {
  5780. if (strcmp(sep->arg[1], "copper") == 0)
  5781. {
  5782. value = atoi64(sep->arg[2]);
  5783. player->AddCoins(value);
  5784. if (client->GetPlayer() == player)
  5785. {
  5786. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu copper coin%s", value, (value > 1 ? "s" : ""));
  5787. }
  5788. else {
  5789. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu copper coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  5790. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu copper coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  5791. }
  5792. }
  5793. else if (strcmp(sep->arg[1], "silver") == 0)
  5794. {
  5795. value = atoi64(sep->arg[2]) * 100;
  5796. player->AddCoins(value);
  5797. if (client->GetPlayer() == player)
  5798. {
  5799. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu silver coin%s", value / 100, (value > 1 ? "s" : ""));
  5800. }
  5801. else {
  5802. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu silver coin%s", player->GetName(), value / 100, (value > 1 ? "s" : ""));
  5803. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu silver coin%s", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  5804. }
  5805. }
  5806. else if (strcmp(sep->arg[1], "gold") == 0)
  5807. {
  5808. value = atoi64(sep->arg[2]) * 10000;
  5809. player->AddCoins(value);
  5810. if (client->GetPlayer() == player)
  5811. {
  5812. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu gold coin%s", value / 10000, (value > 1 ? "s" : ""));
  5813. }
  5814. else {
  5815. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu gold coin%s", player->GetName(), value / 10000, (value > 1 ? "s" : ""));
  5816. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu gold coin%s", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  5817. }
  5818. }
  5819. else if (strcmp(sep->arg[1], "plat") == 0)
  5820. {
  5821. value = atoi64(sep->arg[2]) * 1000000;
  5822. player->AddCoins(value);
  5823. if (client->GetPlayer() == player)
  5824. {
  5825. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu platinum coin%s", value / 1000000, (value > 1 ? "s" : ""));
  5826. }
  5827. else {
  5828. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu platinum coin%s", player->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  5829. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu platinum coin%s", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  5830. }
  5831. }
  5832. else
  5833. {
  5834. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  5835. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  5836. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  5837. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character add copper 20");
  5838. }
  5839. }
  5840. else if (strcmp(sep->arg[0], "remove") == 0)
  5841. {
  5842. if (strcmp(sep->arg[1], "copper") == 0)
  5843. {
  5844. value = atoi64(sep->arg[2]);
  5845. player->RemoveCoins(value);
  5846. if (client->GetPlayer() == player)
  5847. {
  5848. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from yourself", value, (value > 1 ? "s" : ""));
  5849. }
  5850. else {
  5851. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from %s", value, (value > 1 ? "s" : ""), player->GetName());
  5852. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu copper coin%s from you", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  5853. }
  5854. }
  5855. else if (strcmp(sep->arg[1], "silver") == 0)
  5856. {
  5857. value = atoi64(sep->arg[2]) * 100;
  5858. player->RemoveCoins(value);
  5859. if (client->GetPlayer() == player)
  5860. {
  5861. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from yourself", value / 100, (value > 1 ? "s" : ""));
  5862. }
  5863. else {
  5864. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from %s", value / 100, (value > 1 ? "s" : ""), player->GetName());
  5865. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu silver coin%s from you", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  5866. }
  5867. }
  5868. else if (strcmp(sep->arg[1], "gold") == 0)
  5869. {
  5870. value = atoi64(sep->arg[2]) * 10000;
  5871. player->RemoveCoins(value);
  5872. if (client->GetPlayer() == player)
  5873. {
  5874. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from yourself", value / 10000, (value > 1 ? "s" : ""));
  5875. }
  5876. else {
  5877. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from %s", value / 10000, (value > 1 ? "s" : ""), player->GetName());
  5878. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu gold coin%s from you", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  5879. }
  5880. }
  5881. else if (strcmp(sep->arg[1], "plat") == 0)
  5882. {
  5883. value = atoi64(sep->arg[2]) * 1000000;
  5884. player->RemoveCoins(value);
  5885. if (client->GetPlayer() == player)
  5886. {
  5887. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from yourself", value / 1000000, (value > 1 ? "s" : ""));
  5888. }
  5889. else {
  5890. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from %s", value / 1000000, (value > 1 ? "s" : ""), player->GetName());
  5891. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu platinum coin%s from you", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  5892. }
  5893. }
  5894. else
  5895. {
  5896. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  5897. }
  5898. }
  5899. else if (strcmp(sep->arg[0], "set") == 0) {
  5900. if (strcmp(sep->arg[1], "tslevel") == 0) {
  5901. int8 level = atoi(sep->arg[2]);
  5902. if (level > 0 && level < 256) {
  5903. if (player) {
  5904. if (client->GetPlayer() == player)
  5905. client->ChangeTSLevel(player->GetTSLevel(), level);
  5906. else
  5907. player->GetZone()->GetClientBySpawn(player)->ChangeTSLevel(player->GetTSLevel(), level);
  5908. }
  5909. }
  5910. else
  5911. client->SimpleMessage(CHANNEL_ERROR, "Level must be between 1 - 255");
  5912. }
  5913. else if (strcmp(sep->arg[1], "tsclass") == 0) {
  5914. int8 tsclass = atoi(sep->arg[2]);
  5915. player->SetTradeskillClass(tsclass);
  5916. player->GetInfoStruct()->tradeskill_class1 = classes.GetTSBaseClass(player->GetTradeskillClass());
  5917. player->GetInfoStruct()->tradeskill_class2 = classes.GetSecondaryTSBaseClass(player->GetTradeskillClass());
  5918. player->GetInfoStruct()->tradeskill_class3 = player->GetTradeskillClass();
  5919. player->SetCharSheetChanged(true);
  5920. }
  5921. }
  5922. }
  5923. else
  5924. {
  5925. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  5926. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  5927. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  5928. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  5929. }
  5930. }
  5931. void Commands::Command_ModifyFaction(Client* client, Seperator* sep)
  5932. {
  5933. PrintSep(sep, "COMMAND_MODIFY");
  5934. // need at least 2 args for a valid command
  5935. if( sep && sep->arg[1] )
  5936. {
  5937. }
  5938. else
  5939. Command_Modify(client);
  5940. }
  5941. void Commands::Command_ModifyGuild(Client* client, Seperator* sep)
  5942. {
  5943. PrintSep(sep, "COMMAND_MODIFY");
  5944. // need at least 2 args for a valid command
  5945. if( sep && sep->arg[1] )
  5946. {
  5947. }
  5948. else
  5949. Command_Modify(client);
  5950. }
  5951. void Commands::Command_ModifyItem(Client* client, Seperator* sep)
  5952. {
  5953. PrintSep(sep, "COMMAND_MODIFY");
  5954. // need at least 2 args for a valid command
  5955. if( sep && sep->arg[1] )
  5956. {
  5957. }
  5958. else
  5959. Command_Modify(client);
  5960. }
  5961. /*
  5962. Function: Command_ModifyQuest()
  5963. Purpose : to list players quest and completed quests
  5964. Params : Action : list, completed
  5965. : Target : Self, Player
  5966. Dev : Cynnar
  5967. Example : /modify quest list
  5968. : /modify quest completed
  5969. */
  5970. void Commands::Command_ModifyQuest(Client* client, Seperator* sep)
  5971. {
  5972. PrintSep(sep, "COMMAND_MODIFY");
  5973. int64 value = 0;
  5974. Player* player = client->GetPlayer();
  5975. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  5976. player = (Player*)player->GetTarget();
  5977. // need at least 2 args for a valid command
  5978. if (sep && sep->arg[1])
  5979. {
  5980. if (strcmp(sep->arg[0], "list") == 0)
  5981. {
  5982. map<int32, Quest*>* quests = player->GetPlayerQuests();
  5983. map<int32, Quest*>::iterator itr;
  5984. client->Message(CHANNEL_COLOR_YELLOW, "%s's Quest List:.", client->GetPlayer()->GetName());
  5985. if (quests->size() == 0)
  5986. client->Message(CHANNEL_COLOR_YELLOW, "%s has no quests.", client->GetPlayer()->GetName());
  5987. else
  5988. {
  5989. for (itr = quests->begin(); itr != quests->end(); itr++)
  5990. {
  5991. Quest* quest = itr->second;
  5992. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  5993. }
  5994. }
  5995. }
  5996. else if (strcmp(sep->arg[0], "completed") == 0)
  5997. {
  5998. map<int32, Quest*>* quests = player->GetCompletedPlayerQuests();
  5999. map<int32, Quest*>::iterator itr;
  6000. client->Message(CHANNEL_COLOR_YELLOW, "%s's Completed Quest List:.", client->GetPlayer()->GetName());
  6001. if (quests->size() == 0)
  6002. client->Message(CHANNEL_COLOR_YELLOW, "%s has no completed quests.", client->GetPlayer()->GetName());
  6003. else
  6004. {
  6005. for (itr = quests->begin(); itr != quests->end(); itr++)
  6006. {
  6007. Quest* quest = itr->second;
  6008. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  6009. }
  6010. }
  6011. }
  6012. // Add in a progress step, and a LogWrite() for tracking GM Commands.
  6013. // LogWrite(LUA__DEBUG, 0, "LUA", "Quest: %s, function: %s", quest->GetName(), function);
  6014. else if (strcmp(sep->arg[0], "remove") == 0)
  6015. {
  6016. int32 quest_id = 0;
  6017. if (sep && sep->arg[1] && sep->IsNumber(1))
  6018. quest_id = atoul(sep->arg[1]);
  6019. if (quest_id > 0)
  6020. {
  6021. if (lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0)
  6022. {
  6023. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  6024. if (quest)
  6025. if (client->GetPlayer() == player)
  6026. {
  6027. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been removed from your journal", quest->GetName());
  6028. }
  6029. else
  6030. {
  6031. client->Message(CHANNEL_COLOR_YELLOW, "You have removed the quest %s from %s's journal", quest->GetName(), player->GetName());
  6032. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s has removed the quest %s from your journal", client->GetPlayer()->GetName(), quest->GetName());
  6033. }
  6034. LogWrite(COMMAND__INFO, 0, "GM Command", "%s removed the quest %s from %s", client->GetPlayer()->GetName(), quest->GetName(), player->GetName());
  6035. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  6036. }
  6037. client->RemovePlayerQuest(quest_id);
  6038. client->GetCurrentZone()->SendQuestUpdates(client);
  6039. }
  6040. }
  6041. else if (strcmp(sep->arg[0], "advance") == 0)
  6042. {
  6043. int32 quest_id = 0;
  6044. int32 step = 0;
  6045. if (sep && sep->arg[1] && sep->IsNumber(1))
  6046. {
  6047. quest_id = atoul(sep->arg[1]);
  6048. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  6049. if (sep && sep->arg[2] && sep->IsNumber(1))
  6050. {
  6051. step = atoul(sep->arg[2]);
  6052. if (quest_id > 0 && step > 0)
  6053. {
  6054. if (player && player->IsPlayer() && quest_id > 0 && step > 0 && (player->player_quests.count(quest_id) > 0))
  6055. {
  6056. if (client)
  6057. {
  6058. client->AddPendingQuestUpdate(quest_id, step);
  6059. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been advanced one step.", quest->GetName());
  6060. LogWrite(COMMAND__INFO, 0, "GM Command", "%s advanced the quest %s one step", client->GetPlayer()->GetName(), quest->GetName());
  6061. }
  6062. }
  6063. }
  6064. else
  6065. {
  6066. client->Message(CHANNEL_COLOR_RED, "Quest ID and Step Number must be greater than 0!");
  6067. }
  6068. }
  6069. else
  6070. {
  6071. client->Message(CHANNEL_COLOR_RED, "Step Number must be a number!");
  6072. }
  6073. }
  6074. else
  6075. {
  6076. client->Message(CHANNEL_COLOR_RED, "Quest ID must be a number!");
  6077. }
  6078. }
  6079. else
  6080. {
  6081. Command_Modify(client);
  6082. }
  6083. }
  6084. else
  6085. {
  6086. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify quest [action] [quest id] [step number]");
  6087. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: list, completed, remove, advance");
  6088. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest list");
  6089. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest remove 156");
  6090. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest advance 50 1");
  6091. }
  6092. }
  6093. void Commands::Command_ModifySkill(Client* client, Seperator* sep)
  6094. {
  6095. PrintSep(sep, "COMMAND_MODIFY");
  6096. // need at least 2 args for a valid command
  6097. if( sep && sep->arg[1] )
  6098. {
  6099. if (strcmp(sep->arg[0], "add") == 0) {
  6100. const char* skill_name = sep->argplus[1];
  6101. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6102. if (skill) {
  6103. Player* player = 0;
  6104. Client* to_client = 0;
  6105. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  6106. player = (Player*)client->GetPlayer()->GetTarget();
  6107. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  6108. }
  6109. else {
  6110. player = client->GetPlayer();
  6111. to_client = client;
  6112. }
  6113. if (player)
  6114. {
  6115. if (!player->GetSkills()->HasSkill(skill->skill_id))
  6116. {
  6117. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  6118. if (to_client == client) {
  6119. client->Message(CHANNEL_STATUS, "Added skill '%s'.", skill_name);
  6120. }
  6121. else {
  6122. client->Message(CHANNEL_STATUS, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  6123. to_client->Message(CHANNEL_STATUS, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  6124. }
  6125. }
  6126. else
  6127. client->Message(CHANNEL_STATUS, "%s already has the skill '%s'.", to_client == client ? "You" : player->GetName(), skill_name);
  6128. }
  6129. }
  6130. else
  6131. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  6132. }
  6133. else if (strcmp(sep->arg[0], "remove") == 0) {
  6134. const char* skill_name = sep->argplus[1];
  6135. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6136. if (skill) {
  6137. Player* player = 0;
  6138. Client* to_client = 0;
  6139. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  6140. player = (Player*)client->GetPlayer()->GetTarget();
  6141. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  6142. }
  6143. else {
  6144. player = client->GetPlayer();
  6145. to_client = client;
  6146. }
  6147. if (player)
  6148. {
  6149. if (player->GetSkills()->HasSkill(skill->skill_id))
  6150. {
  6151. player->RemoveSkillFromDB(skill, true);
  6152. if (client == to_client) {
  6153. client->Message(CHANNEL_STATUS, "Removed skill '%s'.", skill_name);
  6154. }
  6155. else {
  6156. client->Message(CHANNEL_STATUS, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  6157. to_client->Message(CHANNEL_STATUS, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  6158. }
  6159. }
  6160. else {
  6161. if (client == to_client)
  6162. client->Message(CHANNEL_STATUS, "You do not have the skill '%s'.", skill_name);
  6163. else
  6164. client->Message(CHANNEL_STATUS, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  6165. }
  6166. }
  6167. }
  6168. else
  6169. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  6170. }
  6171. else if (strcmp(sep->arg[0], "set") == 0) {
  6172. if (!sep->IsNumber(2)) {
  6173. client->Message(CHANNEL_STATUS, "The last parameter must be a number.");
  6174. return;
  6175. }
  6176. const char* skill_name = sep->arg[1];
  6177. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6178. if (skill) {
  6179. int16 val = atoi(sep->arg[2]);
  6180. Player* player = 0;
  6181. Client* to_client = 0;
  6182. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  6183. player = (Player*)client->GetPlayer()->GetTarget();
  6184. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  6185. }
  6186. else {
  6187. player = client->GetPlayer();
  6188. to_client = client;
  6189. }
  6190. if (player)
  6191. {
  6192. if (player->GetSkills()->HasSkill(skill->skill_id)) {
  6193. player->GetSkills()->SetSkill(skill->skill_id, val);
  6194. if (client != to_client)
  6195. client->Message(CHANNEL_STATUS, "You set %s's '%s' skill to %i.", player->GetName(), skill_name, val);
  6196. to_client->Message(CHANNEL_STATUS, "Your '%s' skill has been set to %i.", skill_name, val);
  6197. }
  6198. else {
  6199. client->Message(CHANNEL_STATUS, "Target does not have the skill '%s'.", skill_name);
  6200. }
  6201. }
  6202. }
  6203. else {
  6204. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  6205. }
  6206. }
  6207. else {
  6208. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  6209. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  6210. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  6211. }
  6212. }
  6213. else {
  6214. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  6215. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  6216. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  6217. }
  6218. }
  6219. void Commands::Command_ModifySpell(Client* client, Seperator* sep)
  6220. {
  6221. PrintSep(sep, "COMMAND_MODIFY");
  6222. // need at least 2 args for a valid command
  6223. if( sep && sep->arg[1] )
  6224. {
  6225. }
  6226. else
  6227. Command_Modify(client);
  6228. }
  6229. void Commands::Command_ModifyZone(Client* client, Seperator* sep)
  6230. {
  6231. PrintSep(sep, "COMMAND_MODIFY");
  6232. // need at least 2 args for a valid command
  6233. if( sep && sep->arg[1] )
  6234. {
  6235. }
  6236. else
  6237. Command_Modify(client);
  6238. }
  6239. /*
  6240. Function: Command_MOTD()
  6241. Purpose : Displays server MOTD
  6242. Params :
  6243. Dev : LethalEncounter
  6244. Example : /motd
  6245. */
  6246. void Commands::Command_MOTD(Client* client)
  6247. {
  6248. if (client)
  6249. ClientPacketFunctions::SendMOTD(client);
  6250. }
  6251. /*
  6252. Function: Command_Pet()
  6253. Purpose : Handle Pet {Command} commands
  6254. Params : attack, backoff, preserve_master, preserve_self, follow, stay, getlost
  6255. Dev :
  6256. Example : /pet preserve_master
  6257. */
  6258. void Commands::Command_Pet(Client* client, Seperator* sep)
  6259. {
  6260. PrintSep(sep, "COMMAND_PET");
  6261. //LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Pet Commands");
  6262. //client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6263. if (strcmp(sep->arg[0], "hide") == 0) {
  6264. // doing /pet hide will toggle the hide status on all the pets that can be hidden
  6265. Entity* pet = client->GetPlayer()->GetDeityPet();
  6266. if (pet) {
  6267. if (pet->IsPrivateSpawn())
  6268. client->GetPlayer()->HideDeityPet(false);
  6269. else
  6270. client->GetPlayer()->HideDeityPet(true);
  6271. }
  6272. pet = client->GetPlayer()->GetCosmeticPet();
  6273. if (pet) {
  6274. if (pet->IsPrivateSpawn())
  6275. client->GetPlayer()->HideCosmeticPet(false);
  6276. else
  6277. client->GetPlayer()->HideCosmeticPet(true);
  6278. }
  6279. return;
  6280. }
  6281. // below is for all combat pets
  6282. if (!client->GetPlayer()->HasPet()) {
  6283. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a pet.");
  6284. return;
  6285. }
  6286. if (strcmp(sep->arg[0], "stay") == 0) {
  6287. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to stay.");
  6288. client->GetPlayer()->GetInfoStruct()->pet_movement = 1;
  6289. client->GetPlayer()->SetCharSheetChanged(true);
  6290. if (client->GetPlayer()->GetPet())
  6291. client->GetPlayer()->GetPet()->following = false;
  6292. if (client->GetPlayer()->GetCharmedPet())
  6293. client->GetPlayer()->GetCharmedPet()->following = false;
  6294. }
  6295. else if (strcmp(sep->arg[0], "follow") == 0) {
  6296. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to follow.");
  6297. client->GetPlayer()->GetInfoStruct()->pet_movement = 2;
  6298. client->GetPlayer()->SetCharSheetChanged(true);
  6299. }
  6300. else if (strcmp(sep->arg[0], "preserve_master") == 0) {
  6301. if (client->GetPlayer()->GetInfoStruct()->pet_behavior & 1) {
  6302. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect you.");
  6303. client->GetPlayer()->GetInfoStruct()->pet_behavior -= 1;
  6304. }
  6305. else {
  6306. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect you.");
  6307. client->GetPlayer()->GetInfoStruct()->pet_behavior += 1;
  6308. }
  6309. client->GetPlayer()->SetCharSheetChanged(true);
  6310. }
  6311. else if (strcmp(sep->arg[0], "preserve_self") == 0) {
  6312. if (client->GetPlayer()->GetInfoStruct()->pet_behavior & 2) {
  6313. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect itself.");
  6314. client->GetPlayer()->GetInfoStruct()->pet_behavior -= 2;
  6315. }
  6316. else {
  6317. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect itself.");
  6318. client->GetPlayer()->GetInfoStruct()->pet_behavior += 2;
  6319. }
  6320. client->GetPlayer()->SetCharSheetChanged(true);
  6321. }
  6322. else if (strcmp(sep->arg[0], "backoff") == 0) {
  6323. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to back down.");
  6324. if (client->GetPlayer()->GetPet())
  6325. ((NPC*)client->GetPlayer()->GetPet())->Brain()->ClearHate();
  6326. if (client->GetPlayer()->GetCharmedPet())
  6327. ((NPC*)client->GetPlayer()->GetCharmedPet())->Brain()->ClearHate();
  6328. client->GetPlayer()->GetInfoStruct()->pet_behavior = 0;
  6329. client->GetPlayer()->SetCharSheetChanged(true);
  6330. }
  6331. else if (strcmp(sep->arg[0], "attack") == 0) {
  6332. if (client->GetPlayer()->HasTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  6333. if (client->GetPlayer()->AttackAllowed((Entity*)client->GetPlayer()->GetTarget())){
  6334. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to attack your target.");
  6335. if (client->GetPlayer()->GetPet())
  6336. client->GetPlayer()->GetPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  6337. if (client->GetPlayer()->GetCharmedPet())
  6338. client->GetPlayer()->GetCharmedPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  6339. }
  6340. else
  6341. client->Message(CHANNEL_COLOR_YELLOW, "You can not attack that.");
  6342. }
  6343. else
  6344. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a target.");
  6345. }
  6346. else if (strcmp(sep->arg[0], "getlost") == 0) {
  6347. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetPet());
  6348. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetCharmedPet());
  6349. client->Message(CHANNEL_COLOR_YELLOW, "You tell your pet to get lost.");
  6350. }
  6351. else
  6352. client->Message(CHANNEL_COLOR_YELLOW, "Unknown pet command.");
  6353. }
  6354. /*
  6355. Function: Command_PetName()
  6356. Purpose : Pet your name (???)
  6357. Params :
  6358. Dev :
  6359. Example :
  6360. */
  6361. void Commands::Command_PetName(Client* client, Seperator* sep)
  6362. {
  6363. PrintSep(sep, "COMMAND_PETNAME");
  6364. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Pet Name Command");
  6365. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6366. }
  6367. /*
  6368. Function: Command_NamePet()
  6369. Purpose : Name your pet
  6370. Params :
  6371. Dev :
  6372. Example :
  6373. */
  6374. void Commands::Command_NamePet(Client* client, Seperator* sep)
  6375. {
  6376. PrintSep(sep, "COMMAND_NAME_PET");
  6377. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Name Pet Command");
  6378. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6379. }
  6380. /*
  6381. Function: Command_Rename()
  6382. Purpose : Renames existing pet
  6383. Params :
  6384. Dev :
  6385. Example :
  6386. */
  6387. void Commands::Command_Rename(Client* client, Seperator* sep)
  6388. {
  6389. PrintSep(sep, "COMMAND_RENAME");
  6390. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Rename Pet Command");
  6391. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6392. }
  6393. /*
  6394. Function: Command_ConfirmRename()
  6395. Purpose : Confirms renaming your pet
  6396. Params :
  6397. Dev :
  6398. Example :
  6399. */
  6400. void Commands::Command_ConfirmRename(Client* client, Seperator* sep)
  6401. {
  6402. PrintSep(sep, "COMMAND_CONFIRMRENAME");
  6403. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Confirm Rename Pet Command");
  6404. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6405. }
  6406. /*
  6407. Function: Command_PetOptions()
  6408. Purpose : Sets various pet options
  6409. Params :
  6410. Dev :
  6411. Example :
  6412. */
  6413. void Commands::Command_PetOptions(Client* client, Seperator* sep)
  6414. {
  6415. PrintSep(sep, "COMMAND_PETOPTIONS");
  6416. Player* player = client->GetPlayer();
  6417. Spawn* target = player->GetTarget();
  6418. if (!target)
  6419. return;
  6420. if (target == player->GetPet())
  6421. client->SendPetOptionsWindow(player->GetPet()->GetName());
  6422. else if (target == player->GetCharmedPet())
  6423. client->SendPetOptionsWindow(player->GetCharmedPet()->GetName());
  6424. else if (target == player->GetCosmeticPet())
  6425. client->SendPetOptionsWindow(player->GetCosmeticPet()->GetName(), 0);
  6426. else if (target == player->GetDeityPet())
  6427. client->SendPetOptionsWindow(player->GetDeityPet()->GetName(), 0);
  6428. }
  6429. /*
  6430. Function: Command_Random()
  6431. Purpose : Handles /random dice roll in-game
  6432. Params : 1-100
  6433. Dev : Scatman
  6434. Example : /randon 1 100
  6435. */
  6436. void Commands::Command_Random(Client* client, Seperator* sep)
  6437. {
  6438. char message[256] = {0};
  6439. if (sep)
  6440. {
  6441. if (sep->GetArgNumber() == 0 && sep->IsNumber(0))
  6442. 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])));
  6443. else if (sep->GetArgNumber() > 0 && sep->IsNumber(0) && sep->IsNumber(1))
  6444. 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])));
  6445. else
  6446. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  6447. }
  6448. else
  6449. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  6450. client->GetPlayer()->GetZone()->HandleChatMessage(0, 0, CHANNEL_EMOTE, message);
  6451. }
  6452. /*
  6453. Function: Command_Randomize()
  6454. Purpose : Sets randomize (appearance) values for NPCs
  6455. Params : Attrib Name
  6456. Dev : Scatman
  6457. Example : /randomize gender 1 -- will randomize the NPCs gender (male/female)
  6458. */
  6459. void Commands::Command_Randomize(Client* client, Seperator* sep)
  6460. {
  6461. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  6462. if (target)
  6463. {
  6464. if (target->IsNPC())
  6465. {
  6466. if (sep && sep->arg[0] && !sep->IsNumber(0))
  6467. {
  6468. const char* value = sep->arg[0];
  6469. if (strncasecmp(value, "show", strlen(value)) == 0)
  6470. {
  6471. client->DisplayRandomizeFeatures(target->GetRandomize());
  6472. }
  6473. else
  6474. {
  6475. if (sep->arg[1] && sep->IsNumber(1))
  6476. {
  6477. int8 option = atoi(sep->arg[1]);
  6478. if (option == 0 || option == 1)
  6479. {
  6480. int32 feature = 0;
  6481. char feature_text[32] = {0};
  6482. if (strncasecmp(value, "gender", strlen(value)) == 0) {
  6483. feature = RANDOMIZE_GENDER;
  6484. strncpy(feature_text, "gender", sizeof(feature_text) - 1);
  6485. }
  6486. else if (strncasecmp(value, "race", strlen(value)) == 0) {
  6487. feature = RANDOMIZE_RACE;
  6488. strncpy(feature_text, "race", sizeof(feature_text) - 1);
  6489. }
  6490. else if (strncasecmp(value, "model", strlen(value)) == 0) {
  6491. feature = RANDOMIZE_MODEL_TYPE;
  6492. strncpy(feature_text, "model", sizeof(feature_text) - 1);
  6493. }
  6494. else if (strncasecmp(value, "facial_hair", strlen(value)) == 0) {
  6495. feature = RANDOMIZE_FACIAL_HAIR_TYPE;
  6496. strncpy(feature_text, "facial hair", sizeof(feature_text) - 1);
  6497. }
  6498. else if (strncasecmp(value, "hair", strlen(value)) == 0) {
  6499. feature = RANDOMIZE_HAIR_TYPE;
  6500. strncpy(feature_text, "hair", sizeof(feature_text) - 1);
  6501. }
  6502. else if (strncasecmp(value, "wing", strlen(value)) == 0) {
  6503. feature = RANDOMIZE_WING_TYPE;
  6504. strncpy(feature_text, "wings", sizeof(feature_text) - 1);
  6505. }
  6506. else if (strncasecmp(value, "cheek", strlen(value)) == 0) {
  6507. feature = RANDOMIZE_CHEEK_TYPE;
  6508. strncpy(feature_text, "cheeks", sizeof(feature_text) - 1);
  6509. }
  6510. else if (strncasecmp(value, "chin", strlen(value)) == 0) {
  6511. feature = RANDOMIZE_CHIN_TYPE;
  6512. strncpy(feature_text, "chin", sizeof(feature_text) - 1);
  6513. }
  6514. else if (strncasecmp(value, "ear", strlen(value)) == 0) {
  6515. feature = RANDOMIZE_EAR_TYPE;
  6516. strncpy(feature_text, "ears", sizeof(feature_text) - 1);
  6517. }
  6518. else if (strncasecmp(value, "eye_brow", strlen(value)) == 0) {
  6519. feature = RANDOMIZE_EYE_BROW_TYPE;
  6520. strncpy(feature_text, "eye brows", sizeof(feature_text) - 1);
  6521. }
  6522. else if (strncasecmp(value, "eye", strlen(value)) == 0) {
  6523. feature = RANDOMIZE_EYE_TYPE;
  6524. strncpy(feature_text, "eyes", sizeof(feature_text) - 1);
  6525. }
  6526. else if (strncasecmp(value, "lip", strlen(value)) == 0) {
  6527. feature = RANDOMIZE_LIP_TYPE;
  6528. strncpy(feature_text, "lips", sizeof(feature_text) - 1);
  6529. }
  6530. else if (strncasecmp(value, "nose", strlen(value)) == 0) {
  6531. feature = RANDOMIZE_NOSE_TYPE;
  6532. strncpy(feature_text, "nose", sizeof(feature_text) - 1);
  6533. }
  6534. else if (strncasecmp(value, "eye_color", strlen(value)) == 0) {
  6535. feature = RANDOMIZE_EYE_COLOR;
  6536. strncpy(feature_text, "eye color", sizeof(feature_text) - 1);
  6537. }
  6538. else if (strncasecmp(value, "hair_color", strlen(value)) == 0) {
  6539. feature = RANDOMIZE_HAIR_TYPE_COLOR;
  6540. strncpy(feature_text, "hair color", sizeof(feature_text) - 1);
  6541. }
  6542. else if (strncasecmp(value, "hair_color1", strlen(value)) == 0) {
  6543. feature = RANDOMIZE_HAIR_COLOR1;
  6544. strncpy(feature_text, "hair color1", sizeof(feature_text) - 1);
  6545. }
  6546. else if (strncasecmp(value, "hair_color2", strlen(value)) == 0) {
  6547. feature = RANDOMIZE_HAIR_COLOR2;
  6548. strncpy(feature_text, "hair color2", sizeof(feature_text) - 1);
  6549. }
  6550. else if (strncasecmp(value, "hair_highlight", strlen(value)) == 0) {
  6551. feature = RANDOMIZE_HAIR_HIGHLIGHT;
  6552. strncpy(feature_text, "hair highlights", sizeof(feature_text) - 1);
  6553. }
  6554. else if (strncasecmp(value, "facial_hair_color", strlen(value)) == 0) {
  6555. feature = RANDOMIZE_HAIR_FACE_COLOR;
  6556. strncpy(feature_text, "facial hair color", sizeof(feature_text) - 1);
  6557. }
  6558. else if (strncasecmp(value, "facial_hair_color_highlight", strlen(value)) == 0) {
  6559. feature = RANDOMIZE_HAIR_FACE_HIGHLIGHT_COLOR;
  6560. strncpy(feature_text, "facial hair color highlights", sizeof(feature_text) - 1);
  6561. }
  6562. else if (strncasecmp(value, "hair_color_highlight", strlen(value)) == 0) {
  6563. feature = RANDOMIZE_HAIR_TYPE_HIGHLIGHT_COLOR;
  6564. strncpy(feature_text, "hair color highlights", sizeof(feature_text) - 1);
  6565. }
  6566. else if (strncasecmp(value, "skin_color", strlen(value)) == 0) {
  6567. feature = RANDOMIZE_SKIN_COLOR;
  6568. strncpy(feature_text, "skin color", sizeof(feature_text) - 1);
  6569. }
  6570. else if (strncasecmp(value, "wing_color1", strlen(value)) == 0) {
  6571. feature = RANDOMIZE_WING_COLOR1;
  6572. strncpy(feature_text, "wing color1", sizeof(feature_text) - 1);
  6573. }
  6574. else if (strncasecmp(value, "wing_color2", strlen(value)) == 0) {
  6575. feature = RANDOMIZE_WING_COLOR2;
  6576. strncpy(feature_text, "wing color2", sizeof(feature_text) - 1);
  6577. }
  6578. else {
  6579. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is not a valid feature to randomize.", value);
  6580. 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'.");
  6581. }
  6582. if (feature > 0) {
  6583. if (option == 1) {
  6584. if (target->GetRandomize() & feature)
  6585. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is already set to randomly generate their %s.", target->GetName(), feature_text);
  6586. else {
  6587. target->AddRandomize(feature);
  6588. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(feature);
  6589. database.UpdateRandomize(target->GetDatabaseID(), feature);
  6590. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will now generate their %s randomly.", target->GetName(), feature_text);
  6591. }
  6592. }
  6593. else {
  6594. if (target->GetRandomize() & feature) {
  6595. target->AddRandomize(-feature);
  6596. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(-feature);
  6597. database.UpdateRandomize(target->GetDatabaseID(), -feature);
  6598. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will no longer generate their %s randomly.", target->GetName(), feature_text);
  6599. }
  6600. else
  6601. client->Message(CHANNEL_COLOR_YELLOW, "'%s' already does not randomly generate their %s.", target->GetName(), feature_text);
  6602. }
  6603. }
  6604. }
  6605. else
  6606. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  6607. }
  6608. else
  6609. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  6610. }
  6611. }
  6612. else {
  6613. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /randomize [show | [feature [1|0]]");
  6614. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "'show' will display current configured features");
  6615. 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'.");
  6616. }
  6617. }
  6618. else
  6619. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "The target you wish to randomize must be an NPC.");
  6620. }
  6621. else
  6622. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select the target you wish to randomize.");
  6623. }
  6624. /*
  6625. Function: Command_ShowCloak()
  6626. Purpose : Character Settings combo box for Show Cloak
  6627. Params : true/false
  6628. Dev : John Adams
  6629. Example :
  6630. */
  6631. void Commands::Command_ShowCloak(Client* client, Seperator* sep)
  6632. {
  6633. Player* player = client->GetPlayer();
  6634. if (sep && sep->arg[0])
  6635. {
  6636. const char* value = sep->arg[0];
  6637. if (strncasecmp(value, "true", strlen(value)) == 0)
  6638. {
  6639. player->set_character_flag(CF_SHOW_CLOAK);
  6640. player->reset_character_flag(CF2_SHOW_RANGED);
  6641. }
  6642. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6643. player->reset_character_flag(CF_SHOW_CLOAK);
  6644. else
  6645. {
  6646. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6647. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6648. }
  6649. }
  6650. }
  6651. /*
  6652. Function: Command_ShowHelm()
  6653. Purpose : Character Settings combo box for Show Helm
  6654. Params : true/false
  6655. Dev : John Adams
  6656. Example :
  6657. */
  6658. void Commands::Command_ShowHelm(Client* client, Seperator* sep)
  6659. {
  6660. Player* player = client->GetPlayer();
  6661. if (sep && sep->arg[0])
  6662. {
  6663. const char* value = sep->arg[0];
  6664. if (strncasecmp(value, "true", strlen(value)) == 0)
  6665. {
  6666. player->reset_character_flag(CF_HIDE_HELM);
  6667. player->set_character_flag(CF_HIDE_HOOD);
  6668. }
  6669. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6670. player->set_character_flag(CF_HIDE_HELM);
  6671. else
  6672. {
  6673. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6674. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6675. }
  6676. }
  6677. }
  6678. /*
  6679. Function: Command_ShowHood()
  6680. Purpose : Character Settings combo box for Show Hood
  6681. Params : true/false
  6682. Dev : John Adams
  6683. Example :
  6684. */
  6685. void Commands::Command_ShowHood(Client* client, Seperator* sep)
  6686. {
  6687. Player* player = client->GetPlayer();
  6688. if (sep && sep->arg[0])
  6689. {
  6690. const char* value = sep->arg[0];
  6691. if (strncasecmp(value, "true", strlen(value)) == 0)
  6692. {
  6693. player->reset_character_flag(CF_HIDE_HOOD);
  6694. player->set_character_flag(CF_HIDE_HELM);
  6695. }
  6696. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6697. player->set_character_flag(CF_HIDE_HOOD);
  6698. else
  6699. {
  6700. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6701. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6702. }
  6703. }
  6704. }
  6705. /*
  6706. Function: Command_ShowHoodHelm()
  6707. Purpose : Character Settings combo box for Show Helm or Hood
  6708. Params : true/false
  6709. Dev : John Adams
  6710. Example :
  6711. */
  6712. void Commands::Command_ShowHoodHelm(Client* client, Seperator* sep)
  6713. {
  6714. Player* player = client->GetPlayer();
  6715. if (sep && sep->arg[0])
  6716. {
  6717. const char* value = sep->arg[0];
  6718. if (strncasecmp(value, "true", strlen(value)) == 0)
  6719. {
  6720. player->reset_character_flag(CF_HIDE_HOOD);
  6721. player->reset_character_flag(CF_HIDE_HELM);
  6722. }
  6723. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6724. {
  6725. // don't think we ever wind up in here...
  6726. player->set_character_flag(CF_HIDE_HOOD);
  6727. player->set_character_flag(CF_HIDE_HELM);
  6728. }
  6729. else
  6730. {
  6731. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6732. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6733. }
  6734. }
  6735. }
  6736. /*
  6737. Function: Command_ShowRanged()
  6738. Purpose : Character Settings combo box for Show Ranged weapon
  6739. Params : true/false
  6740. Dev : John Adams
  6741. Example :
  6742. */
  6743. void Commands::Command_ShowRanged(Client* client, Seperator* sep)
  6744. {
  6745. Player* player = client->GetPlayer();
  6746. if (sep && sep->arg[0])
  6747. {
  6748. const char* value = sep->arg[0];
  6749. if (strncasecmp(value, "true", strlen(value)) == 0)
  6750. {
  6751. player->set_character_flag(CF2_SHOW_RANGED);
  6752. player->reset_character_flag(CF_SHOW_CLOAK);
  6753. }
  6754. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6755. player->reset_character_flag(CF2_SHOW_RANGED);
  6756. else
  6757. {
  6758. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6759. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6760. }
  6761. }
  6762. }
  6763. /*
  6764. Function:
  6765. Purpose :
  6766. Params :
  6767. Dev :
  6768. Example :
  6769. */
  6770. void Commands::Command_Skills(Client* client, Seperator* sep, int handler)
  6771. {
  6772. Player* player = 0;
  6773. Client* to_client = 0;
  6774. if(client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  6775. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  6776. switch(handler)
  6777. {
  6778. case COMMAND_SKILL:
  6779. {
  6780. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill [add|remove|list] [skill name]");
  6781. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to add/remove skills for that player.");
  6782. break;
  6783. }
  6784. case COMMAND_SKILL_ADD:
  6785. {
  6786. if (sep && sep->arg[0])
  6787. {
  6788. const char* skill_name = sep->argplus[0];
  6789. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6790. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // add skill to your target, if target is not you
  6791. {
  6792. player = to_client->GetPlayer();
  6793. if (player)
  6794. {
  6795. if (!player->GetSkills()->HasSkill(skill->skill_id))
  6796. {
  6797. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  6798. client->Message(CHANNEL_COLOR_YELLOW, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  6799. to_client->Message(CHANNEL_COLOR_YELLOW, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  6800. }
  6801. else
  6802. client->Message(CHANNEL_COLOR_YELLOW, "%s already has the skill '%s'.", player->GetName(), skill_name);
  6803. }
  6804. }
  6805. else if (skill) // add skill to yourself
  6806. {
  6807. player = client->GetPlayer();
  6808. if (player)
  6809. {
  6810. if (!player->GetSkills()->HasSkill(skill->skill_id))
  6811. {
  6812. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  6813. client->Message(CHANNEL_COLOR_YELLOW, "Added skill '%s'.", skill_name);
  6814. }
  6815. else
  6816. client->Message(CHANNEL_COLOR_YELLOW, "You already have the skill '%s'.", skill_name);
  6817. }
  6818. }
  6819. else
  6820. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  6821. }
  6822. else
  6823. {
  6824. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill add [skill name]");
  6825. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  6826. }
  6827. break;
  6828. }
  6829. case COMMAND_SKILL_REMOVE:
  6830. {
  6831. if (sep && sep->arg[0])
  6832. {
  6833. const char* skill_name = sep->argplus[0];
  6834. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6835. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // remove skill from your target, if target is not you
  6836. {
  6837. player = to_client->GetPlayer();
  6838. if (player)
  6839. {
  6840. if (player->GetSkills()->HasSkill(skill->skill_id))
  6841. {
  6842. player->RemoveSkillFromDB(skill, true);
  6843. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  6844. to_client->Message(CHANNEL_COLOR_YELLOW, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  6845. }
  6846. else
  6847. client->Message(CHANNEL_COLOR_YELLOW, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  6848. }
  6849. }
  6850. else if(skill) // remove skill from yourself
  6851. {
  6852. Player* player = client->GetPlayer();
  6853. if (player)
  6854. {
  6855. if (player->GetSkills()->HasSkill(skill->skill_id))
  6856. {
  6857. player->RemoveSkillFromDB(skill, true);
  6858. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s'.", skill_name);
  6859. }
  6860. else
  6861. client->Message(CHANNEL_COLOR_YELLOW, "You do not have the skill '%s'.", skill_name);
  6862. }
  6863. }
  6864. else
  6865. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  6866. }
  6867. else
  6868. {
  6869. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill remove [skill name]");
  6870. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  6871. }
  6872. break;
  6873. }
  6874. case COMMAND_SKILL_LIST:
  6875. {
  6876. if (sep && sep->arg[0])
  6877. {
  6878. const char* skill_name = sep->argplus[0];
  6879. client->Message(CHANNEL_COLOR_YELLOW, "Listing skills like '%s':", skill_name);
  6880. map<int32, Skill*>* skills = master_skill_list.GetAllSkills();
  6881. map<int32, Skill*>::iterator itr;
  6882. if (skills && skills->size() > 0)
  6883. {
  6884. for (itr = skills->begin(); itr != skills->end(); itr++)
  6885. {
  6886. Skill* skill = itr->second;
  6887. string current_skill_name = ::ToLower(string(skill->name.data.c_str()));
  6888. if (current_skill_name.find(::ToLower(string(skill_name))) < 0xFFFFFFFF)
  6889. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", skill->name.data.c_str(), skill->skill_id);
  6890. }
  6891. }
  6892. }
  6893. else
  6894. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill list [skill name]");
  6895. break;
  6896. }
  6897. }
  6898. }
  6899. /*
  6900. Function: Command_SpawnTemplate()
  6901. Purpose : Create or Use defined Spawn Templates
  6902. Params : create, save, rempve, list
  6903. Dev : John Adams
  6904. Example : /spawn template create "Test"
  6905. */
  6906. void Commands::Command_SpawnTemplate(Client* client, Seperator* sep)
  6907. {
  6908. if (sep == NULL || sep->arg[0] == NULL)
  6909. {
  6910. 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.");
  6911. return;
  6912. }
  6913. // got params, continue
  6914. const char * template_cmd = sep->arg[0];
  6915. if (strncasecmp(template_cmd, "list", strlen(template_cmd)) == 0)
  6916. {
  6917. if (!sep->IsSet(1))
  6918. {
  6919. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /spawn template list [name|location_id]");
  6920. 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.");
  6921. return;
  6922. }
  6923. map<int32, string>* template_names = 0;
  6924. if (sep->IsNumber(1))
  6925. {
  6926. int32 location_id = 0;
  6927. location_id = atoi(sep->arg[1]);
  6928. template_names = database.GetSpawnTemplateListByID(location_id);
  6929. }
  6930. else
  6931. {
  6932. const char* name = 0;
  6933. name = sep->argplus[1];
  6934. template_names = database.GetSpawnTemplateListByName(name);
  6935. }
  6936. if(!template_names)
  6937. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No templates found.");
  6938. else
  6939. {
  6940. map<int32, string>::iterator itr;
  6941. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  6942. for(itr = template_names->begin(); itr != template_names->end(); itr++)
  6943. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  6944. safe_delete(template_names);
  6945. }
  6946. }
  6947. else if (strncasecmp(template_cmd, "save", strlen(template_cmd)) == 0)
  6948. {
  6949. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  6950. if ( target && (target->IsNPC() || target->IsObject() || target->IsSign() || target->IsWidget() || target->IsGroundSpawn()) )
  6951. {
  6952. if (sep && sep->arg[1][0] && !sep->IsNumber(1))
  6953. {
  6954. // first, lookup to see if template name already exists
  6955. const char* name = 0;
  6956. name = sep->argplus[1];
  6957. map<int32, string>* template_names = database.GetSpawnTemplateListByName(name);
  6958. if(!template_names)
  6959. {
  6960. int32 new_template_id = database.SaveSpawnTemplate(target->GetSpawnLocationID(), name);
  6961. if( new_template_id > 0 )
  6962. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template '%s' added for spawn '%s' (%u) as TemplateID: %u", name, target->GetName(), target->GetSpawnLocationID(), new_template_id);
  6963. else
  6964. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' for spawn '%s' (%u).", name, target->GetName(), target->GetSpawnLocationID());
  6965. }
  6966. else
  6967. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' - Already exists!", name);
  6968. }
  6969. else
  6970. client->Message(CHANNEL_COLOR_RED, "ERROR: Saving a new spawn template requires a valid template name!");
  6971. }
  6972. else
  6973. client->Message(CHANNEL_COLOR_RED, "ERROR: You must target the spawn you wish to save as a template!");
  6974. }
  6975. else if (strncasecmp(template_cmd, "remove", strlen(template_cmd)) == 0)
  6976. {
  6977. if (sep && sep->arg[1][0] && sep->IsNumber(1))
  6978. {
  6979. int32 template_id = 0;
  6980. template_id = atoi(sep->arg[1]);
  6981. if (database.RemoveSpawnTemplate(template_id))
  6982. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template ID: %u successfully removed.", template_id);
  6983. else
  6984. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to remove spawn template ID: %u", template_id);
  6985. }
  6986. else
  6987. client->Message(CHANNEL_COLOR_RED, "ERROR: Removing a spawn template requires a valid template ID!");
  6988. }
  6989. // Renamed create to spawn
  6990. else if (strncasecmp(template_cmd, "spawn", strlen(template_cmd)) == 0)
  6991. {
  6992. if (sep && sep->arg[1][0])
  6993. {
  6994. int32 new_location = 0;
  6995. if (sep->IsNumber(1))
  6996. {
  6997. int32 template_id = 0;
  6998. template_id = atoi(sep->arg[1]);
  6999. new_location = database.CreateSpawnFromTemplateByID(client, template_id);
  7000. if( new_location > 0 )
  7001. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template ID: %u", new_location, template_id);
  7002. else
  7003. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template ID: %u", template_id);
  7004. }
  7005. else
  7006. {
  7007. const char* name = 0;
  7008. name = sep->argplus[1];
  7009. new_location = database.CreateSpawnFromTemplateByName(client, name);
  7010. if( new_location > 0 )
  7011. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template: '%s'", new_location, name);
  7012. else
  7013. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template: '%s'", name);
  7014. }
  7015. }
  7016. else
  7017. client->Message(CHANNEL_COLOR_RED, "ERROR: Spawning a new spawn location requires a valid template name or ID!");
  7018. }
  7019. else
  7020. client->Message(CHANNEL_COLOR_RED, "ERROR: Unknown /spawn template command.");
  7021. }
  7022. void Commands::Command_Speed(Client* client, Seperator* sep) {
  7023. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  7024. float new_speed = atof(sep->arg[0]);
  7025. if (new_speed > 0.0f)
  7026. {
  7027. client->GetPlayer()->SetSpeed(new_speed, true);
  7028. client->GetPlayer()->SetCharSheetChanged(true);
  7029. database.insertCharacterProperty(client, CHAR_PROPERTY_SPEED, sep->arg[0]);
  7030. client->Message(CHANNEL_STATUS, "Setting speed to %.2f.", new_speed);
  7031. }
  7032. else
  7033. client->Message(CHANNEL_STATUS, "Invalid speed provided %s.", sep->arg[0]);
  7034. }
  7035. else{
  7036. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /speed {new speed value}");
  7037. }
  7038. }
  7039. /*
  7040. Function: Command_StationMarketPlace()
  7041. Purpose : just trying to eat the console spam for now
  7042. Params :
  7043. Dev : John
  7044. */
  7045. void Commands::Command_StationMarketPlace(Client* client, Seperator* sep)
  7046. {
  7047. PrintSep(sep, "COMMAND_SMP");
  7048. // This will reduce the spam from once every 10 sec to once every 30 sec,
  7049. // can't seem to reduce it any more get rid of it completely...
  7050. if (sep && strcmp(sep->arg[0], "gkw") == 0) {
  7051. PacketStruct* packet = configReader.getStruct("WS_MarketFundsUpdate", client->GetVersion());
  7052. if (packet) {
  7053. packet->setDataByName("account_id", client->GetAccountID());
  7054. packet->setDataByName("character_id", client->GetCharacterID());
  7055. packet->setDataByName("unknown1", 1, 5);
  7056. packet->setDataByName("unknown1", 26, 6);
  7057. packet->setDataByName("unknown2", 0xFFFFFFFF);
  7058. packet->setDataByName("unknown3", 248, 1);
  7059. client->QueuePacket(packet->serialize());
  7060. }
  7061. safe_delete(packet);
  7062. }
  7063. }
  7064. /*
  7065. Function: Command_StopDrinking()
  7066. Purpose : Stops player from auto-consuming drink
  7067. Params :
  7068. Dev : Zcoretri
  7069. Example : /stopdrinking
  7070. */
  7071. void Commands::Command_StopDrinking(Client* client)
  7072. {
  7073. client->GetPlayer()->reset_character_flag(CF_DRINK_AUTO_CONSUME);
  7074. client->Message(CHANNEL_COLOR_YELLOW,"You stop drinking your current drink.");
  7075. }
  7076. /*
  7077. Function: Command_StopEating()
  7078. Purpose : Stops player from auto-consuming food
  7079. Params :
  7080. Dev : Zcoretri
  7081. Example : /stopeating
  7082. */
  7083. void Commands::Command_StopEating(Client* client)
  7084. {
  7085. client->GetPlayer()->reset_character_flag(CF_FOOD_AUTO_CONSUME);
  7086. client->Message(CHANNEL_COLOR_YELLOW,"You stop eating your current food.");
  7087. }
  7088. /*
  7089. Function: Command_Title()
  7090. Purpose : Help for /title command
  7091. Params : n/a
  7092. Dev : Zcoretri
  7093. Example : /title
  7094. */
  7095. void Commands::Command_Title(Client* client)
  7096. {
  7097. client->Message(CHANNEL_COLOR_YELLOW, "Available subcommands: list, setprefix <index>, setsuffix <index>, fix");
  7098. }
  7099. /*
  7100. Function: Command_TitleList()
  7101. Purpose : List available titles for player
  7102. Params : n/a
  7103. Dev : Zcoretri
  7104. Example : /title list
  7105. */
  7106. void Commands::Command_TitleList(Client* client)
  7107. {
  7108. list<Title*>* titles = client->GetPlayer()->GetPlayerTitles()->GetAllTitles();
  7109. list<Title*>::iterator itr;
  7110. Title* title;
  7111. int16 i = 0;
  7112. client->Message(CHANNEL_COLOR_WHITE, "Listing available titles:");
  7113. for(itr = titles->begin(); itr != titles->end(); itr++)
  7114. {
  7115. title = *itr;
  7116. client->Message(CHANNEL_COLOR_WHITE, "%i: type=[%s] title=[%s]", i, title->GetPrefix() ? "Prefix":"Suffix", title->GetName());
  7117. i++;
  7118. }
  7119. }
  7120. /*
  7121. Function: Command_TitleSetPrefix()
  7122. Purpose : Set Prefix title for player
  7123. Params : Title ID
  7124. Dev : Zcoretri
  7125. Example : /title setprefix 1
  7126. */
  7127. void Commands::Command_TitleSetPrefix(Client* client, Seperator* sep)
  7128. {
  7129. if (sep && sep->arg[0] && sep->IsNumber(0))
  7130. {
  7131. int32 index = atoul(sep->arg[0]);
  7132. database.SaveCharPrefixIndex(index, client->GetCharacterID(), client);
  7133. client->SendTitleUpdate();
  7134. }
  7135. }
  7136. /*
  7137. Function: Command_TitleSetSuffix()
  7138. Purpose : Set Suffix title for player
  7139. Params : Title ID
  7140. Dev : Zcoretri
  7141. Example : /title setsuffix 1
  7142. */
  7143. void Commands::Command_TitleSetSuffix(Client* client, Seperator* sep)
  7144. {
  7145. if (sep && sep->arg[0] && sep->IsNumber(0))
  7146. {
  7147. int32 index = atoul(sep->arg[0]);
  7148. database.SaveCharSuffixIndex(index, client->GetCharacterID(), client);
  7149. client->SendTitleUpdate();
  7150. }
  7151. }
  7152. /*
  7153. Function: Command_TitleFix()
  7154. Purpose : Fix title for player (???)
  7155. Params :
  7156. Dev : Zcoretri
  7157. Example :
  7158. */
  7159. void Commands::Command_TitleFix(Client* client, Seperator* sep)
  7160. {
  7161. PrintSep(sep, "COMMAND_TITLE_FIX");
  7162. LogWrite(MISC__TODO, 1, "Titles", "TODO-Command: TITLE_FIX");
  7163. }
  7164. /*
  7165. Function: Command_Toggle_Anonymous()
  7166. Purpose : Toggles player Anonymous
  7167. Params :
  7168. Dev : paulgh
  7169. Example : /anon
  7170. */
  7171. void Commands::Command_Toggle_Anonymous(Client* client)
  7172. {
  7173. Player* player = client->GetPlayer();
  7174. player->toggle_character_flag(CF_ANONYMOUS);
  7175. client->Message(CHANNEL_COLOR_YELLOW,"You are %s anonymous.", player->get_character_flag(CF_ANONYMOUS)?"now":"no longer");
  7176. if (player->get_character_flag(CF_ANONYMOUS))
  7177. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ANONYMOUS);
  7178. else
  7179. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ANONYMOUS);
  7180. }
  7181. /*
  7182. Function: Command_Toggle_AutoConsume()
  7183. Purpose : Toggles player food/drink auto consume
  7184. Params : unknown
  7185. Dev : paulgh
  7186. Example : /set_auto_consume
  7187. */
  7188. void Commands::Command_Toggle_AutoConsume(Client* client, Seperator* sep)
  7189. {
  7190. Player* player = client->GetPlayer();
  7191. if (sep && sep->arg[0])
  7192. PrintSep(sep, "COMMAND_SET_AUTO_CONSUME");
  7193. if (sep && sep->arg[0] && sep->IsNumber(0))
  7194. {
  7195. int8 slot = atoi(sep->arg[0]);
  7196. int8 flag = atoi(sep->arg[1]);
  7197. if (slot == EQ2_FOOD_SLOT)
  7198. {
  7199. player->toggle_character_flag(CF_FOOD_AUTO_CONSUME);
  7200. player->SetCharSheetChanged(true);
  7201. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  7202. if (flag == 1)
  7203. client->Message(CHANNEL_COLOR_WHITE, "You decide to eat immediately whenever you become hungry.");
  7204. else
  7205. client->Message(CHANNEL_COLOR_WHITE, "You decide to ignore the hunger.");
  7206. }
  7207. else
  7208. {
  7209. player->toggle_character_flag(CF_DRINK_AUTO_CONSUME);
  7210. player->SetCharSheetChanged(true);
  7211. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  7212. if (flag == 1)
  7213. client->Message(CHANNEL_COLOR_WHITE, "You decide to drink immediately whenever you become thirsty.");
  7214. else
  7215. client->Message(CHANNEL_COLOR_WHITE, "You decide to ignore the thirst.");
  7216. }
  7217. }
  7218. }
  7219. /*
  7220. Function: Command_Toggle_BonusXP()
  7221. Purpose : Toggles player Bonus XP
  7222. Params :
  7223. Dev : John Adams
  7224. Example : /disable_char_bonus_exp
  7225. */
  7226. void Commands::Command_Toggle_BonusXP(Client* client)
  7227. {
  7228. Player* player = client->GetPlayer();
  7229. player->toggle_character_flag(CF2_CHARACTER_BONUS_EXPERIENCE_ENABLED);
  7230. player->SetCharSheetChanged(true);
  7231. }
  7232. /*
  7233. Function: Command_Toggle_CombatXP()
  7234. Purpose : Toggles player Adventure XP
  7235. Params :
  7236. Dev : John Adams
  7237. Example : /disable_combat_exp
  7238. */
  7239. void Commands::Command_Toggle_CombatXP(Client* client)
  7240. {
  7241. Player* player = client->GetPlayer();
  7242. player->toggle_character_flag(CF_COMBAT_EXPERIENCE_ENABLED);
  7243. player->SetCharSheetChanged(true);
  7244. }
  7245. /*
  7246. Function: Command_Toggle_GMHide()
  7247. Purpose : Toggles hiding player GM status
  7248. Params :
  7249. Dev : Scatman
  7250. Example : /gm_hide
  7251. */
  7252. void Commands::Command_Toggle_GMHide(Client* client)
  7253. {
  7254. Player* player = client->GetPlayer();
  7255. player->toggle_character_flag(CF_HIDE_STATUS);
  7256. client->Message(CHANNEL_COLOR_YELLOW,"You are %s hiding your GM status.", player->get_character_flag(CF_HIDE_STATUS)?"now":"no longer");
  7257. }
  7258. /*
  7259. Function: Command_Toggle_GMVanish()
  7260. Purpose : Toggles hiding GM players from /who searches
  7261. Params :
  7262. Dev : Scatman
  7263. Example : /gm_vanish
  7264. */
  7265. void Commands::Command_Toggle_GMVanish(Client* client)
  7266. {
  7267. Player* player = client->GetPlayer();
  7268. player->toggle_character_flag(CF_GM_HIDDEN);
  7269. client->Message(CHANNEL_COLOR_YELLOW,"You are %s invisible to who queries.", player->get_character_flag(CF_GM_HIDDEN)?"now":"no longer");
  7270. }
  7271. /*
  7272. Function: Command_Toggle_Illusions()
  7273. Purpose : Toggles player illusion form
  7274. Params : not sure sep is needed, testing
  7275. Dev : paulgh
  7276. Example : /hide_illusions
  7277. */
  7278. void Commands::Command_Toggle_Illusions(Client* client, Seperator* sep)
  7279. {
  7280. if (sep && sep->arg[0])
  7281. PrintSep(sep, "COMMAND_TOGGLE_ILLUSIONS");
  7282. client->GetPlayer()->toggle_character_flag(CF_SHOW_ILLUSION);
  7283. }
  7284. /*
  7285. Function: Command_Toggle_LFG()
  7286. Purpose : Toggles player LFG Flag
  7287. Params :
  7288. Dev : paulgh
  7289. Example : /lfg
  7290. */
  7291. void Commands::Command_Toggle_LFG(Client* client)
  7292. {
  7293. Player* player = client->GetPlayer();
  7294. player->toggle_character_flag(CF_LFG);
  7295. client->Message(CHANNEL_COLOR_YELLOW,"You are %s LFG.", player->get_character_flag(CF_LFG)?"now":"no longer");
  7296. if (player->get_character_flag(CF_LFG))
  7297. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFG);
  7298. else
  7299. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFG);
  7300. }
  7301. /*
  7302. Function: Command_Toggle_LFW()
  7303. Purpose : Toggles player LFW Flag
  7304. Params :
  7305. Dev : paulgh
  7306. Example : /lfw
  7307. */
  7308. void Commands::Command_Toggle_LFW(Client* client)
  7309. {
  7310. Player* player = client->GetPlayer();
  7311. player->toggle_character_flag(CF_LFW);
  7312. client->Message(CHANNEL_COLOR_YELLOW,"You %s looking for work.", player->get_character_flag(CF_LFW)?"let others know you are":"stop");
  7313. if (player->get_character_flag(CF_LFW))
  7314. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFW);
  7315. else
  7316. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFW);
  7317. }
  7318. /*
  7319. Function: Command_Toggle_QuestXP()
  7320. Purpose : Toggles player Quest XP
  7321. Params :
  7322. Dev : John Adams
  7323. Example : /disable_quest_exp
  7324. */
  7325. void Commands::Command_Toggle_QuestXP(Client* client)
  7326. {
  7327. Player* player = client->GetPlayer();
  7328. player->toggle_character_flag(CF_QUEST_EXPERIENCE_ENABLED);
  7329. player->SetCharSheetChanged(true);
  7330. }
  7331. /*
  7332. Function: Command_Toggle_Roleplaying()
  7333. Purpose : Toggles player Roleplaying flag
  7334. Params :
  7335. Dev : paulgh
  7336. Example : /role
  7337. */
  7338. void Commands::Command_Toggle_Roleplaying(Client* client)
  7339. {
  7340. Player* player = client->GetPlayer();
  7341. player->toggle_character_flag(CF_ROLEPLAYING);
  7342. client->Message(CHANNEL_COLOR_YELLOW,"You are %s roleplaying.", player->get_character_flag(CF_ROLEPLAYING)?"now":"no longer");
  7343. if (player->get_character_flag(CF_ROLEPLAYING))
  7344. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ROLEPLAYING);
  7345. else
  7346. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ROLEPLAYING);
  7347. }
  7348. void Commands::Command_Toggle_Duels(Client* client)
  7349. {
  7350. Player* player = client->GetPlayer();
  7351. player->toggle_character_flag(CF_ALLOW_DUEL_INVITES);
  7352. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting duel invites.", player->get_character_flag(CF_ALLOW_DUEL_INVITES)?"now":"no longer");
  7353. }
  7354. void Commands::Command_Toggle_Trades(Client* client)
  7355. {
  7356. Player* player = client->GetPlayer();
  7357. player->toggle_character_flag(CF_ALLOW_TRADE_INVITES);
  7358. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting trade invites.", player->get_character_flag(CF_ALLOW_TRADE_INVITES)?"now":"no longer");
  7359. }
  7360. void Commands::Command_Toggle_Guilds(Client* client)
  7361. {
  7362. Player* player = client->GetPlayer();
  7363. player->toggle_character_flag(CF_ALLOW_GUILD_INVITES);
  7364. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting guild invites.", player->get_character_flag(CF_ALLOW_GUILD_INVITES)?"now":"no longer");
  7365. }
  7366. void Commands::Command_Toggle_Groups(Client* client)
  7367. {
  7368. Player* player = client->GetPlayer();
  7369. player->toggle_character_flag(CF_ALLOW_GROUP_INVITES);
  7370. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting group invites.", player->get_character_flag(CF_ALLOW_GROUP_INVITES)?"now":"no longer");
  7371. }
  7372. void Commands::Command_Toggle_Raids(Client* client)
  7373. {
  7374. Player* player = client->GetPlayer();
  7375. player->toggle_character_flag(CF_ALLOW_RAID_INVITES);
  7376. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting raid invites.", player->get_character_flag(CF_ALLOW_RAID_INVITES)?"now":"no longer");
  7377. }
  7378. void Commands::Command_Toggle_LON(Client* client)
  7379. {
  7380. Player* player = client->GetPlayer();
  7381. player->toggle_character_flag(CF2_ALLOW_LON_INVITES);
  7382. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting LoN invites.", player->get_character_flag(CF2_ALLOW_LON_INVITES)?"now":"no longer");
  7383. }
  7384. void Commands::Command_Toggle_VoiceChat(Client* client)
  7385. {
  7386. Player* player = client->GetPlayer();
  7387. player->toggle_character_flag(CF2_ALLOW_VOICE_INVITES);
  7388. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting voice chat invites.", player->get_character_flag(CF2_ALLOW_VOICE_INVITES)?"now":"no longer");
  7389. }
  7390. /*
  7391. Function: Command_TradeStart()
  7392. Purpose : Starts item/coin trade between players
  7393. Params :
  7394. Dev :
  7395. Example :
  7396. */
  7397. #include "../Trade.h"
  7398. void Commands::Command_TradeStart(Client* client, Seperator* sep)
  7399. {
  7400. PrintSep(sep, "COMMAND_START_TRADE");
  7401. Entity* trader = client->GetPlayer();
  7402. Entity* trader2 = 0;
  7403. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7404. Spawn* spawn = client->GetPlayer()->GetSpawnWithPlayerID(atoi(sep->arg[0]));
  7405. if (spawn) {
  7406. if (spawn->IsEntity())
  7407. trader2 = (Entity*)spawn;
  7408. }
  7409. }
  7410. else if (client->GetPlayer()->GetTarget()) {
  7411. if (client->GetPlayer()->GetTarget()->IsEntity())
  7412. trader2 = (Entity*)client->GetPlayer()->GetTarget();
  7413. }
  7414. // can only trade with player or bots
  7415. if (trader && trader2) {
  7416. if (trader == trader2) {
  7417. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade with yourself.");
  7418. }
  7419. else if (trader2->IsPlayer() || trader2->IsBot()) {
  7420. LogWrite(PLAYER__ERROR, 0, "Trade", "creating trade");
  7421. if (trader->trade)
  7422. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are already trading.");
  7423. else if (trader2->trade)
  7424. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is already trading.");
  7425. else {
  7426. Trade* trade = new Trade(trader, trader2);
  7427. trader->trade = trade;
  7428. trader2->trade = trade;
  7429. }
  7430. }
  7431. else {
  7432. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can only trade with another player or a bot.");
  7433. }
  7434. }
  7435. else
  7436. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to find target");
  7437. }
  7438. /*
  7439. Function: Command_Track()
  7440. Purpose : Starts/Stops Tracking for a player
  7441. Params :
  7442. Dev : Scatman
  7443. Example : /track
  7444. */
  7445. void Commands::Command_Track(Client* client)
  7446. {
  7447. if (!client->GetPlayer()->GetIsTracking())
  7448. client->GetPlayer()->GetZone()->AddPlayerTracking(client->GetPlayer());
  7449. else
  7450. client->GetPlayer()->GetZone()->RemovePlayerTracking(client->GetPlayer(), TRACKING_STOP);
  7451. }
  7452. /*
  7453. Function: Command_TradeAccept()
  7454. Purpose : Accepts item/coin trade between players
  7455. Params :
  7456. Dev :
  7457. Example :
  7458. */
  7459. void Commands::Command_TradeAccept(Client* client, Seperator* sep)
  7460. {
  7461. PrintSep(sep, "COMMAND_ACCEPT_TRADE");
  7462. Trade* trade = client->GetPlayer()->trade;
  7463. if (trade) {
  7464. bool trade_complete = trade->SetTradeAccepted(client->GetPlayer());
  7465. if (trade_complete)
  7466. safe_delete(trade);
  7467. }
  7468. else
  7469. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7470. }
  7471. /*
  7472. Function: Command_TradeReject()
  7473. Purpose : Rejects item/coin trade between players
  7474. Params :
  7475. Dev :
  7476. Example :
  7477. */
  7478. void Commands::Command_TradeReject(Client* client, Seperator* sep)
  7479. {
  7480. PrintSep(sep, "COMMAND_REJECT_TRADE");
  7481. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Reject Player Trading");
  7482. client->Message(CHANNEL_COLOR_YELLOW, "You cannot trade with other players (Not Implemented)");
  7483. }
  7484. /*
  7485. Function: Command_TradeCancel()
  7486. Purpose : Cancels item/coin trade between players
  7487. Params :
  7488. Dev :
  7489. Example :
  7490. */
  7491. void Commands::Command_TradeCancel(Client* client, Seperator* sep)
  7492. {
  7493. PrintSep(sep, "COMMAND_CANCEL_TRADE");
  7494. Trade* trade = client->GetPlayer()->trade;
  7495. if (trade) {
  7496. trade->CancelTrade(client->GetPlayer());
  7497. safe_delete(trade);
  7498. }
  7499. else
  7500. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7501. }
  7502. /*
  7503. Function: Command_TradeSetCoin()
  7504. Purpose : Sets coin trade between players
  7505. Params :
  7506. Dev :
  7507. Example :
  7508. */
  7509. void Commands::Command_TradeSetCoin(Client* client, Seperator* sep)
  7510. {
  7511. PrintSep(sep, "COMMAND_SET_TRADE_COIN");
  7512. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Set Trade Coin");
  7513. client->Message(CHANNEL_COLOR_YELLOW, "You cannot trade with other players (Not Implemented)");
  7514. }
  7515. /*
  7516. Function: Command_TradeAddCoin()
  7517. Purpose : Adds coin to trade between players
  7518. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  7519. Dev :
  7520. Example :
  7521. */
  7522. void Commands::Command_TradeAddCoin(Client* client, Seperator* sep, int handler)
  7523. {
  7524. PrintSep(sep, "COMMAND_ADD_TRADE_{coin type}");
  7525. Trade* trade = client->GetPlayer()->trade;
  7526. if (trade) {
  7527. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7528. int32 amount = atoi(sep->arg[0]);
  7529. int64 val = 0;
  7530. switch (handler) {
  7531. case COMMAND_ADD_TRADE_COPPER:
  7532. {
  7533. val = amount;
  7534. trade->AddCoinToTrade(client->GetPlayer(), val);
  7535. break;
  7536. }
  7537. case COMMAND_ADD_TRADE_SILVER:
  7538. {
  7539. val = amount * 100;
  7540. trade->AddCoinToTrade(client->GetPlayer(), val);
  7541. break;
  7542. }
  7543. case COMMAND_ADD_TRADE_GOLD:
  7544. {
  7545. val = amount * 10000;
  7546. trade->AddCoinToTrade(client->GetPlayer(), val);
  7547. break;
  7548. }
  7549. case COMMAND_ADD_TRADE_PLAT:
  7550. {
  7551. val = amount * 1000000;
  7552. trade->AddCoinToTrade(client->GetPlayer(), val);
  7553. break;
  7554. }
  7555. default:
  7556. {
  7557. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  7558. break;
  7559. }
  7560. }
  7561. }
  7562. else
  7563. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount.");
  7564. }
  7565. else
  7566. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7567. }
  7568. /*
  7569. Function: Command_TradeRemoveCoin()
  7570. Purpose : Removes coin from trade between players
  7571. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  7572. Dev :
  7573. Example :
  7574. */
  7575. void Commands::Command_TradeRemoveCoin(Client* client, Seperator* sep, int handler)
  7576. {
  7577. PrintSep(sep, "COMMAND_REMOVE_TRADE_{coin type}");
  7578. Trade* trade = client->GetPlayer()->trade;
  7579. if (trade) {
  7580. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7581. int32 amount = atoi(sep->arg[0]);
  7582. int64 val = 0;
  7583. switch (handler) {
  7584. case COMMAND_REMOVE_TRADE_COPPER:
  7585. {
  7586. val = amount;
  7587. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7588. break;
  7589. }
  7590. case COMMAND_REMOVE_TRADE_SILVER:
  7591. {
  7592. val = amount * 100;
  7593. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7594. break;
  7595. }
  7596. case COMMAND_REMOVE_TRADE_GOLD:
  7597. {
  7598. val = amount * 10000;
  7599. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7600. break;
  7601. }
  7602. case COMMAND_REMOVE_TRADE_PLAT:
  7603. {
  7604. val = amount * 1000000;
  7605. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7606. break;
  7607. }
  7608. default:
  7609. {
  7610. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  7611. break;
  7612. }
  7613. }
  7614. }
  7615. else
  7616. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount");
  7617. }
  7618. else
  7619. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7620. }
  7621. /*
  7622. Function: Command_TradeAddItem()
  7623. Purpose : Adds item to trade between players
  7624. Params :
  7625. Dev :
  7626. Example :
  7627. */
  7628. void Commands::Command_TradeAddItem(Client* client, Seperator* sep)
  7629. {
  7630. PrintSep(sep, "COMMAND_ADD_TRADE_ITEM");
  7631. /*
  7632. arg[0] = item index
  7633. arg[1] = slot
  7634. arg[2] = quantity
  7635. */
  7636. if (!client->GetPlayer()->trade) {
  7637. LogWrite(PLAYER__ERROR, 0, "Trade", "Player is not currently trading.");
  7638. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7639. return;
  7640. }
  7641. if (sep && sep->IsSet(0) && sep->IsNumber(0) && sep->IsSet(1) && sep->IsNumber(1) && sep->IsSet(2) && sep->IsNumber(2)) {
  7642. Item* item = 0;
  7643. int32 index = atoi(sep->arg[0]);
  7644. item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(index);
  7645. if (item) {
  7646. int8 result = client->GetPlayer()->trade->AddItemToTrade(client->GetPlayer(), item, atoi(sep->arg[2]), atoi(sep->arg[1]));
  7647. if (result == 1)
  7648. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Item is already being traded.");
  7649. else if (result == 2)
  7650. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade NO-TRADE items.");
  7651. else if (result == 3)
  7652. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade HEIRLOOM items.");
  7653. else if (result == 255)
  7654. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown error trying to add the item to the trade...");
  7655. }
  7656. else {
  7657. LogWrite(PLAYER__ERROR, 0, "Trade", "Unable to get an item for the player (%s) from the index (%u)", client->GetPlayer()->GetName(), index);
  7658. client->Message(CHANNEL_ERROR, "Unable to find item at index %u", index);
  7659. }
  7660. }
  7661. else
  7662. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  7663. }
  7664. /*
  7665. Function: Command_TradeRemoveItem()
  7666. Purpose : Removes item from trade between players
  7667. Params :
  7668. Dev :
  7669. Example :
  7670. */
  7671. void Commands::Command_TradeRemoveItem(Client* client, Seperator* sep)
  7672. {
  7673. PrintSep(sep, "COMMAND_REMOVE_TRADE_ITEM");
  7674. /*
  7675. arg[0] = trade window slot
  7676. */
  7677. Trade* trade = client->GetPlayer()->trade;
  7678. if (trade) {
  7679. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7680. trade->RemoveItemFromTrade(client->GetPlayer(), atoi(sep->arg[0]));
  7681. }
  7682. else
  7683. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  7684. }
  7685. else
  7686. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7687. }
  7688. void Commands::Command_TryOn(Client* client, Seperator* sep)
  7689. {
  7690. Item *item = 0;
  7691. sint32 crc;
  7692. if (sep) {
  7693. // 1096+ sends more info so need to do a version check so older clients (SF) still work
  7694. if (client->GetVersion() < 1096) {
  7695. if (sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2))
  7696. {
  7697. item = master_item_list.GetItem(atoul(sep->arg[1]));
  7698. crc = atol(sep->arg[2]);
  7699. }
  7700. }
  7701. else {
  7702. // From the broker and links in chat
  7703. if (strcmp(sep->arg[0], "crc") == 0) {
  7704. if (sep->IsNumber(2) && sep->IsNumber(3)) {
  7705. item = master_item_list.GetItem(atoul(sep->arg[2]));
  7706. crc = atol(sep->arg[3]);
  7707. }
  7708. }
  7709. // From inventory
  7710. if (strcmp(sep->arg[0], "dbid") == 0) {
  7711. if (sep->IsNumber(2) && sep->IsNumber(4)) {
  7712. item = master_item_list.GetItem(atoul(sep->arg[2]));
  7713. crc = atol(sep->arg[4]);
  7714. }
  7715. }
  7716. }
  7717. if (item)
  7718. client->ShowDressingRoom(item, crc);
  7719. }
  7720. }
  7721. void Commands::Command_JoinChannel(Client * client, Seperator *sep) {
  7722. const char *channel_name, *password = NULL;
  7723. if (sep == NULL || !sep->IsSet(0)) {
  7724. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /joinchannel <channel name> [password]");
  7725. return;
  7726. }
  7727. channel_name = sep->arg[0];
  7728. if (sep->IsSet(1))
  7729. password = sep->arg[1];
  7730. if (!chat.ChannelExists(channel_name) && !chat.CreateChannel(channel_name, password)) {
  7731. client->Message(CHANNEL_COLOR_RED, "Unable to create channel '%s'.", channel_name);
  7732. return;
  7733. }
  7734. if (chat.IsInChannel(client, channel_name)) {
  7735. client->Message(CHANNEL_COLOR_WHITE, "You are already in '%s'.", channel_name);
  7736. return;
  7737. }
  7738. if (chat.HasPassword(channel_name)) {
  7739. if (password == NULL) {
  7740. client->Message(CHANNEL_COLOR_WHITE, "Unable to join '%s': That channel is password protected.", channel_name);
  7741. return;
  7742. }
  7743. if (!chat.PasswordMatches(channel_name, password)) {
  7744. client->Message(CHANNEL_COLOR_WHITE, "Unable to join '%s': The password is not correc.t", channel_name);
  7745. return;
  7746. }
  7747. }
  7748. if (!chat.JoinChannel(client, channel_name))
  7749. client->Message(CHANNEL_COLOR_RED, "There was an internal error preventing you from joining '%s'.", channel_name);
  7750. }
  7751. void Commands::Command_JoinChannelFromLoad(Client * client, Seperator *sep) {
  7752. printf("ScatDebug: Received 'joinfromchannel', using the same function as 'joinchannel' (not sure what the difference is)\n");
  7753. Command_JoinChannel(client, sep);
  7754. }
  7755. void Commands::Command_TellChannel(Client *client, Seperator *sep) {
  7756. if (sep == NULL || !sep->IsSet(0) || !sep->IsSet(1)) {
  7757. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /tellchannel <channel name> <message>");
  7758. PrintSep(sep, "tellchannel");
  7759. return;
  7760. }
  7761. chat.TellChannel(client, sep->arg[0], sep->argplus[1]);
  7762. }
  7763. void Commands::Command_Test(Client* client, EQ2_16BitString* command_parms) {
  7764. Seperator* sep = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  7765. if (sep->IsSet(0)) {
  7766. if (atoi(sep->arg[0]) == 1) {
  7767. PacketStruct* packet2 = configReader.getStruct("WS_SpellGainedMsg", client->GetVersion());
  7768. if (packet2) {
  7769. packet2->setDataByName("spell_type", 2);
  7770. packet2->setDataByName("spell_id", 8308);
  7771. packet2->setDataByName("spell_name", "Sprint");
  7772. packet2->setDataByName("add_silently", 0);
  7773. packet2->setDataByName("tier", 1);
  7774. packet2->setDataByName("blah1", 1);
  7775. packet2->setDataByName("blah2", 1);
  7776. EQ2Packet* outapp = packet2->serialize();
  7777. DumpPacket(outapp);
  7778. client->QueuePacket(outapp);
  7779. safe_delete(packet2);
  7780. }
  7781. }
  7782. else if (atoi(sep->arg[0]) == 2) {
  7783. PacketStruct* packet2 = configReader.getStruct("WS_GuildUpdate", client->GetVersion());
  7784. if (packet2) {
  7785. packet2->setDataByName("guild_name", "Test");
  7786. packet2->setDataByName("guild_motd", "Test MOTD");
  7787. packet2->setDataByName("guild_id", 1234);
  7788. packet2->setDataByName("guild_level", 1);
  7789. packet2->setDataByName("unknown", 2);
  7790. packet2->setDataByName("unknown2", 3);
  7791. packet2->setDataByName("exp_current", 1);
  7792. packet2->setDataByName("exp_to_next_level", 4);
  7793. EQ2Packet* outapp = packet2->serialize();
  7794. DumpPacket(outapp);
  7795. client->QueuePacket(outapp);
  7796. safe_delete(packet2);
  7797. }
  7798. }
  7799. else if (atoi(sep->arg[0]) == 3) {
  7800. PacketStruct* packet2 = configReader.getStruct("WS_JoinGuildNotify", client->GetVersion());
  7801. if (packet2) {
  7802. packet2->setDataByName("guild_id", 1234);
  7803. packet2->setDataByName("character_id", 1);
  7804. packet2->setDataByName("account_id", 2);
  7805. packet2->setDataByName("guild_level", 1);
  7806. packet2->setDataByName("name", "Test");
  7807. packet2->setDataByName("unknown2", 0);
  7808. packet2->setDataByName("unknown3", 1);
  7809. packet2->setDataByName("adventure_class", 6);
  7810. packet2->setDataByName("adventure_level", 7);
  7811. packet2->setDataByName("tradeskill_class", 4);
  7812. packet2->setDataByName("tradeskill_level", 5);
  7813. packet2->setDataByName("rank", 0);
  7814. packet2->setDataByName("member_flags", 2);
  7815. packet2->setDataByName("join_date", 1591112273);
  7816. packet2->setDataByName("guild_status", 2);
  7817. packet2->setDataByName("last_login", 1591132273);
  7818. packet2->setDataByName("recruiter_id", 1);
  7819. packet2->setDataByName("points", 2345);
  7820. packet2->setDataByName("note", "note");
  7821. packet2->setMediumStringByName("officer_note", "O note");
  7822. packet2->setMediumStringByName("zone", "Blah");
  7823. EQ2Packet* outapp = packet2->serialize();
  7824. DumpPacket(outapp);
  7825. client->QueuePacket(outapp);
  7826. safe_delete(packet2);
  7827. }
  7828. }
  7829. else if (atoi(sep->arg[0]) == 5) {
  7830. client->GetPlayer()->GetTarget();
  7831. int16 offset = atoi(sep->arg[2]);
  7832. int32 value1 = atol(sep->arg[4]);
  7833. EQ2Packet* outapp = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion(), offset, value1);
  7834. client->QueuePacket(outapp);
  7835. }
  7836. else if (atoi(sep->arg[0]) == 6) {
  7837. Spawn* spawn = client->GetPlayer()->GetTarget();
  7838. if (!spawn)
  7839. spawn = client->GetPlayer();
  7840. else if (spawn->IsEntity())
  7841. ((Entity*)spawn)->SetSpeed(atof(sep->arg[4]));
  7842. spawn->RunToLocation(atof(sep->arg[1]), atof(sep->arg[2]), atof(sep->arg[3]));
  7843. }
  7844. else if (atoi(sep->arg[0]) == 7) {
  7845. int32 id = 0;
  7846. Spawn* spawn = client->GetCurrentZone()->GetSpawn(7720001);
  7847. if (spawn) {
  7848. spawn->SetX(client->GetPlayer()->GetX() + .5, false);
  7849. spawn->SetY(client->GetPlayer()->GetY(), false);
  7850. spawn->SetZ(client->GetPlayer()->GetZ() + .5, false);
  7851. float heading = client->GetPlayer()->GetHeading() + 180;
  7852. if (heading > 360)
  7853. heading -= 360;
  7854. spawn->SetLevel(5);
  7855. spawn->SetAdventureClass(4);
  7856. spawn->SetHeading(heading, false);
  7857. spawn->SetSpawnOrigX(spawn->GetX());
  7858. spawn->SetSpawnOrigY(spawn->GetY());
  7859. spawn->SetSpawnOrigZ(spawn->GetZ());
  7860. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  7861. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  7862. spawn->appearance.targetable = 1;
  7863. if (spawn->IsNPC() && spawn->GetTotalHP() == 0) {
  7864. spawn->SetTotalHP(spawn->GetLevel() * 15);
  7865. spawn->SetHP(spawn->GetTotalHP());
  7866. }
  7867. if (spawn->GetTotalPower() == 0) {
  7868. spawn->SetTotalPower(spawn->GetLevel() * 15);
  7869. spawn->SetPower(spawn->GetTotalPower());
  7870. }
  7871. int16 offset = atoi(sep->arg[1]);
  7872. int32 value1 = atol(sep->arg[2]);
  7873. sprintf(spawn->appearance.name, "Offset %i", offset);
  7874. EQ2Packet* ret = spawn->spawn_serialize(client->GetPlayer(), client->GetVersion(), offset, value1);
  7875. DumpPacket(ret);
  7876. client->QueuePacket(ret);
  7877. }
  7878. }
  7879. else if (atoi(sep->arg[0]) == 8) {
  7880. int32 id = atoi(sep->arg[1]);
  7881. Spawn* spawn = client->GetCurrentZone()->GetSpawn(id);
  7882. if (spawn) {
  7883. spawn->SetX(client->GetPlayer()->GetX() + .5, false);
  7884. spawn->SetY(client->GetPlayer()->GetY(), false);
  7885. spawn->SetZ(client->GetPlayer()->GetZ() + .5, false);
  7886. float heading = client->GetPlayer()->GetHeading() + 180;
  7887. if (heading > 360)
  7888. heading -= 360;
  7889. spawn->SetLevel(5);
  7890. spawn->SetAdventureClass(4);
  7891. spawn->SetHeading(heading, false);
  7892. spawn->SetSpawnOrigX(spawn->GetX());
  7893. spawn->SetSpawnOrigY(spawn->GetY());
  7894. spawn->SetSpawnOrigZ(spawn->GetZ());
  7895. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  7896. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  7897. spawn->appearance.targetable = 1;
  7898. if (spawn->IsNPC() && spawn->GetTotalHP() == 0) {
  7899. spawn->SetTotalHP(spawn->GetLevel() * 15);
  7900. spawn->SetHP(spawn->GetTotalHP());
  7901. }
  7902. if (spawn->GetTotalPower() == 0) {
  7903. spawn->SetTotalPower(spawn->GetLevel() * 15);
  7904. spawn->SetPower(spawn->GetTotalPower());
  7905. }
  7906. int16 offset = atoi(sep->arg[2]);
  7907. int16 offset2 = atoi(sep->arg[3]);
  7908. int32 value1 = atol(sep->arg[4]);
  7909. int16 offset3 = 0;
  7910. int16 offset4 = 0;
  7911. int32 value2 = 0;
  7912. if (sep->IsSet(7)) {
  7913. offset3 = atoi(sep->arg[5]);
  7914. offset4 = atoi(sep->arg[6]);
  7915. value2 = atol(sep->arg[7]);
  7916. }
  7917. sprintf(spawn->appearance.name, "Offset %i to %i", offset, offset2);
  7918. EQ2Packet* ret = spawn->spawn_serialize(client->GetPlayer(), client->GetVersion(), offset, value1, offset2, offset3, offset4, value2);
  7919. DumpPacket(ret);
  7920. client->QueuePacket(ret);
  7921. }
  7922. }
  7923. else if (atoi(sep->arg[0]) == 9) {
  7924. Item* item = master_item_list.GetItem(70007);
  7925. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  7926. if (sep->IsSet(2)) {
  7927. int8 offset = atoi(sep->arg[1]);
  7928. uchar* ptr2 = app->pBuffer;
  7929. ptr2 += offset;
  7930. if (sep->IsNumber(2)) {
  7931. int32 value1 = atol(sep->arg[2]);
  7932. if (value1 > 0xFFFF)
  7933. memcpy(ptr2, (uchar*)&value1, 4);
  7934. else if (value1 > 0xFF)
  7935. memcpy(ptr2, (uchar*)&value1, 2);
  7936. else
  7937. memcpy(ptr2, (uchar*)&value1, 1);
  7938. }
  7939. else {
  7940. int8 len = strlen(sep->arg[2]);
  7941. memcpy(ptr2, (uchar*)&len, 1);
  7942. ptr2 += 1;
  7943. memcpy(ptr2, sep->arg[2], len);
  7944. }
  7945. }
  7946. if (sep->IsSet(4)) {
  7947. int8 offset = atoi(sep->arg[3]);
  7948. uchar* ptr2 = app->pBuffer;
  7949. ptr2 += offset;
  7950. if (sep->IsNumber(4)) {
  7951. int32 value1 = atol(sep->arg[4]);
  7952. if (value1 > 0xFFFF)
  7953. memcpy(ptr2, (uchar*)&value1, 4);
  7954. else if (value1 > 0xFF)
  7955. memcpy(ptr2, (uchar*)&value1, 2);
  7956. else
  7957. memcpy(ptr2, (uchar*)&value1, 1);
  7958. }
  7959. else {
  7960. int8 len = strlen(sep->arg[4]);
  7961. memcpy(ptr2, (uchar*)&len, 1);
  7962. ptr2 += 1;
  7963. memcpy(ptr2, sep->arg[4], len);
  7964. }
  7965. }
  7966. DumpPacket(app);
  7967. client->QueuePacket(app);
  7968. }
  7969. else if (atoi(sep->arg[0]) == 10) {
  7970. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalUpdate", client->GetVersion());
  7971. if (packet2) {
  7972. packet2->setArrayLengthByName("num_quests", 1);
  7973. packet2->setArrayDataByName("active", 1);
  7974. packet2->setArrayDataByName("name", "Archetype Selection");
  7975. packet2->setArrayDataByName("quest_type", "Hallmark");
  7976. packet2->setArrayDataByName("quest_zone", "Hallmark");
  7977. packet2->setArrayDataByName("journal_updated", 1);
  7978. packet2->setArrayDataByName("quest_id", 5);
  7979. packet2->setArrayDataByName("day", 19);
  7980. packet2->setArrayDataByName("month", 6);
  7981. packet2->setArrayDataByName("year", 20);
  7982. packet2->setArrayDataByName("level", 2);
  7983. packet2->setArrayDataByName("encounter_level", 4);
  7984. packet2->setArrayDataByName("difficulty", 3);
  7985. packet2->setArrayDataByName("visible", 1);
  7986. packet2->setDataByName("visible_quest_id", 5);
  7987. packet2->setDataByName("player_crc", 2900677088);
  7988. packet2->setDataByName("player_name", "LethalEncounter");
  7989. EQ2Packet* app = packet2->serialize();
  7990. if (sep->IsSet(2)) {
  7991. int8 offset = atoi(sep->arg[1]);
  7992. uchar* ptr2 = app->pBuffer;
  7993. ptr2 += offset;
  7994. if (sep->IsNumber(2)) {
  7995. int32 value1 = atol(sep->arg[2]);
  7996. if (value1 > 0xFFFF)
  7997. memcpy(ptr2, (uchar*)&value1, 4);
  7998. else if (value1 > 0xFF)
  7999. memcpy(ptr2, (uchar*)&value1, 2);
  8000. else
  8001. memcpy(ptr2, (uchar*)&value1, 1);
  8002. }
  8003. else {
  8004. int8 len = strlen(sep->arg[2]);
  8005. memcpy(ptr2, (uchar*)&len, 1);
  8006. ptr2 += 1;
  8007. memcpy(ptr2, sep->arg[2], len);
  8008. }
  8009. }
  8010. DumpPacket(app);
  8011. client->QueuePacket(app);
  8012. safe_delete(packet2);
  8013. }
  8014. }
  8015. else if (atoi(sep->arg[0]) == 11) {
  8016. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalReply", client->GetVersion());
  8017. if (packet2) {
  8018. packet2->setDataByName("quest_id", 5);
  8019. packet2->setDataByName("player_crc", 2900677088);
  8020. packet2->setDataByName("name", "Archetype Selection");
  8021. packet2->setDataByName("description", "I have reported my profession to Garven Tralk");
  8022. packet2->setDataByName("type", "Hallmark");
  8023. packet2->setDataByName("complete_header", "To complete this quest, I must do the following tasks:");
  8024. packet2->setDataByName("day", 19);
  8025. packet2->setDataByName("month", 6);
  8026. packet2->setDataByName("year", 20);
  8027. packet2->setDataByName("level", 2);
  8028. packet2->setDataByName("encounter_level", 4);
  8029. packet2->setDataByName("difficulty", 3);
  8030. packet2->setDataByName("time_obtained", Timer::GetUnixTimeStamp());
  8031. packet2->setDataByName("timer_start", Timer::GetUnixTimeStamp());
  8032. packet2->setDataByName("timer_duration", 300);
  8033. packet2->setDataByName("timer_running", 1);
  8034. packet2->setArrayLengthByName("task_groups_completed", 0);
  8035. packet2->setArrayLengthByName("num_task_groups", 1);
  8036. packet2->setArrayDataByName("task_group", "I need to talk to Garven Tralk");
  8037. packet2->setSubArrayLengthByName("num_tasks", 1);
  8038. packet2->setSubArrayDataByName("task", "I need to talk to Garven Tralk");
  8039. packet2->setSubArrayLengthByName("num_updates", 1);
  8040. packet2->setSubArrayDataByName("update_currentval", 0);
  8041. packet2->setSubArrayDataByName("update_maxval", 1);
  8042. packet2->setSubArrayDataByName("icon", 11);
  8043. packet2->setArrayDataByName("waypoint", 0xFFFFFFFF);
  8044. packet2->setDataByName("journal_updated", 1);
  8045. EQ2Packet* app = packet2->serialize();
  8046. if (sep->IsSet(2)) {
  8047. int16 offset = atoi(sep->arg[1]);
  8048. uchar* ptr2 = app->pBuffer;
  8049. ptr2 += offset;
  8050. if (sep->IsNumber(2)) {
  8051. int32 value1 = atol(sep->arg[2]);
  8052. if (value1 > 0xFFFF)
  8053. memcpy(ptr2, (uchar*)&value1, 4);
  8054. else if (value1 > 0xFF)
  8055. memcpy(ptr2, (uchar*)&value1, 2);
  8056. else
  8057. memcpy(ptr2, (uchar*)&value1, 1);
  8058. }
  8059. else {
  8060. int16 len = strlen(sep->arg[2]);
  8061. memcpy(ptr2, (uchar*)&len, 2);
  8062. ptr2 += 2;
  8063. memcpy(ptr2, sep->arg[2], len);
  8064. }
  8065. }
  8066. DumpPacket(app);
  8067. client->QueuePacket(app);
  8068. safe_delete(packet2);
  8069. }
  8070. }
  8071. else if (atoi(sep->arg[0]) == 12) {
  8072. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalReply", client->GetVersion());
  8073. if (packet2) {
  8074. packet2->setDataByName("quest_id", 5);
  8075. packet2->setDataByName("player_crc", 2900677088);
  8076. packet2->setDataByName("name", "Archetype Selection");
  8077. packet2->setDataByName("description", "I have reported my profession to Garven Tralk.");
  8078. packet2->setDataByName("type", "Hallmark");
  8079. packet2->setDataByName("complete_header", "To complete this quest, I must do the following tasks:");
  8080. packet2->setDataByName("day", 19);
  8081. packet2->setDataByName("month", 6);
  8082. packet2->setDataByName("year", 20);
  8083. packet2->setDataByName("level", 2);
  8084. packet2->setDataByName("encounter_level", 4);
  8085. packet2->setDataByName("difficulty", 3);
  8086. packet2->setDataByName("time_obtained", Timer::GetUnixTimeStamp());
  8087. packet2->setDataByName("timer_start", Timer::GetUnixTimeStamp());
  8088. packet2->setDataByName("timer_duration", 300);
  8089. packet2->setDataByName("timer_running", 1);
  8090. packet2->setArrayLengthByName("task_groups_completed", 0);
  8091. packet2->setArrayLengthByName("num_task_groups", 1);
  8092. packet2->setArrayDataByName("task_group", "I need to talk to Garven Tralk");
  8093. packet2->setSubArrayLengthByName("num_tasks", 1);
  8094. packet2->setSubArrayDataByName("task", "I need to talk to Garven Tralk");
  8095. packet2->setSubArrayLengthByName("num_updates", 1);
  8096. packet2->setSubArrayDataByName("update_currentval", 0);
  8097. packet2->setSubArrayDataByName("update_maxval", 1);
  8098. packet2->setSubArrayDataByName("icon", 11);
  8099. packet2->setArrayDataByName("waypoint", 0xFFFFFFFF);
  8100. packet2->setDataByName("journal_updated", 1);
  8101. packet2->setSubstructDataByName("reward_data", "unknown1", 255);
  8102. packet2->setSubstructDataByName("reward_data", "reward", "Quest Reward!");
  8103. packet2->setSubstructDataByName("reward_data", "unknown2", 0x3f);
  8104. packet2->setSubstructDataByName("reward_data", "coin", 150);
  8105. packet2->setSubstructDataByName("reward_data", "status_points", 5);
  8106. packet2->setSubstructDataByName("reward_data", "exp_bonus", 10);
  8107. packet2->setSubstructArrayLengthByName("reward_data", "num_rewards", 1);
  8108. packet2->setSubstructArrayDataByName("reward_data", "reward_id", 123);
  8109. Item* item = master_item_list.GetItem(152755);
  8110. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8111. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  8112. /*packet2->setSubstructDataByName("item", "unique_id", 567);
  8113. packet2->setSubstructDataByName("item", "broker_item_id", 0xFFFFFFFFFFFFFFFF);
  8114. packet2->setSubstructDataByName("item", "icon", 0xe7);
  8115. packet2->setSubstructDataByName("item", "tier", 4);
  8116. packet2->setSubstructDataByName("item", "flags", 0x60);
  8117. packet2->setSubstructArrayLengthByName("item", "stat_count", 1);
  8118. packet2->setSubstructDataByName("item", "stat_type", 1);
  8119. packet2->setSubstructDataByName("item", "stat_subtype", 2);
  8120. packet2->setSubstructDataByName("item", "value", 3);
  8121. packet2->setSubstructDataByName("item", "condition", 100);
  8122. packet2->setSubstructDataByName("item", "weight", 1);
  8123. packet2->setSubstructDataByName("item", "skill_req1", 0xacafa99e);
  8124. packet2->setSubstructDataByName("item", "skill_req2", 0xacafa99e);
  8125. packet2->setSubstructDataByName("item", "skill_min", 1);
  8126. packet2->setSubstructArrayLengthByName("item", "class_count", 3);
  8127. packet2->setSubstructDataByName("item", "adventure_class", 1);
  8128. packet2->setSubstructDataByName("item", "adventure_class", 11, 0, 1);
  8129. packet2->setSubstructDataByName("item", "adventure_class", 0x1f, 0, 2);
  8130. packet2->setSubstructDataByName("item", "tradeskill_class", 255);
  8131. packet2->setSubstructDataByName("item", "tradeskill_class", 255, 0, 1);
  8132. packet2->setSubstructDataByName("item", "tradeskill_class", 255, 0, 2);
  8133. packet2->setSubstructDataByName("item", "level", 0x1e);
  8134. packet2->setSubstructDataByName("item", "level", 100, 0, 1);
  8135. packet2->setSubstructDataByName("item", "level", 100, 0, 2);
  8136. packet2->setSubstructDataByName("item_footer", "name", "Footman Gloves");*/
  8137. //packet2->PrintPacket();
  8138. EQ2Packet* app = packet2->serialize();
  8139. if (sep->IsSet(2)) {
  8140. int16 offset = atoi(sep->arg[1]);
  8141. uchar* ptr2 = app->pBuffer;
  8142. ptr2 += offset;
  8143. if (sep->IsNumber(2)) {
  8144. int32 value1 = atol(sep->arg[2]);
  8145. if (value1 > 0xFFFF)
  8146. memcpy(ptr2, (uchar*)&value1, 4);
  8147. else if (value1 > 0xFF)
  8148. memcpy(ptr2, (uchar*)&value1, 2);
  8149. else
  8150. memcpy(ptr2, (uchar*)&value1, 1);
  8151. }
  8152. else {
  8153. int16 len = strlen(sep->arg[2]);
  8154. memcpy(ptr2, (uchar*)&len, 2);
  8155. ptr2 += 2;
  8156. memcpy(ptr2, sep->arg[2], len);
  8157. }
  8158. }
  8159. DumpPacket(app);
  8160. client->QueuePacket(app);
  8161. safe_delete(packet2);
  8162. }
  8163. }
  8164. else if (atoi(sep->arg[0]) == 13) {
  8165. PacketStruct* packet2 = configReader.getStruct("WS_OnScreenMsg", client->GetVersion());
  8166. if (packet2 && sep->IsSet(7)) {
  8167. packet2->setDataByName("unknown", atoi(sep->arg[1]));
  8168. char blah[128];
  8169. sprintf(blah, "\\#6EFF6EYou get better at \12\\#C8FFC8%s\\#6EFF6E! (7/15)", sep->arg[2]);
  8170. packet2->setDataByName("text", blah);
  8171. packet2->setDataByName("message_type", sep->arg[3]);
  8172. packet2->setDataByName("size", atof(sep->arg[4]));
  8173. packet2->setDataByName("red", atoi(sep->arg[5]));
  8174. packet2->setDataByName("green", atoi(sep->arg[6]));
  8175. packet2->setDataByName("blue", atoi(sep->arg[7]));
  8176. EQ2Packet* app = packet2->serialize();
  8177. DumpPacket(app);
  8178. client->QueuePacket(app);
  8179. safe_delete(packet2);
  8180. }
  8181. }
  8182. else if (atoi(sep->arg[0]) == 14) {
  8183. PacketStruct* packet2 = configReader.getStruct("WS_InstructionWindow", client->GetVersion());
  8184. if (packet2 && sep->IsSet(3)) {
  8185. packet2->setDataByName("open_seconds_min", atof(sep->arg[1]));
  8186. packet2->setDataByName("open_seconds_max", atof(sep->arg[2]));
  8187. packet2->setDataByName("voice_sync", atoi(sep->arg[3]));
  8188. 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.");
  8189. packet2->setDataByName("voice", "voiceover/english/narrator/boat_06p_tutorial02/narrator_001_63779ca0.mp3");
  8190. packet2->setArrayLengthByName("num_goals", 1);
  8191. //packet2->setArrayDataByName("goal_text", )
  8192. packet2->setSubArrayLengthByName("num_tasks", 1);
  8193. packet2->setSubArrayDataByName("task_text", "continue");
  8194. packet2->setDataByName("complete_sound", "click");
  8195. packet2->setDataByName("signal", "introduction");
  8196. packet2->setDataByName("voice_key1", 0xcda65173);
  8197. packet2->setDataByName("voice_key2", 0x984bfc6d);
  8198. EQ2Packet* app = packet2->serialize();
  8199. DumpPacket(app);
  8200. client->QueuePacket(app);
  8201. safe_delete(packet2);
  8202. packet2 = configReader.getStruct("WS_ShowWindow", client->GetVersion());
  8203. packet2->setDataByName("window", "MainHUD.StartMenu");
  8204. packet2->setDataByName("show", 1);
  8205. app = packet2->serialize();
  8206. DumpPacket(app);
  8207. client->QueuePacket(app);
  8208. safe_delete(packet2);
  8209. packet2 = configReader.getStruct("WS_FlashWindow", client->GetVersion());
  8210. packet2->setDataByName("window", "MainHUD.StartMenu.help");
  8211. packet2->setDataByName("flash_seconds", 10);
  8212. app = packet2->serialize();
  8213. DumpPacket(app);
  8214. client->QueuePacket(app);
  8215. safe_delete(packet2);
  8216. }
  8217. }
  8218. else if (atoi(sep->arg[0]) == 15) {
  8219. PacketStruct* packet2 = configReader.getStruct("WS_UpdateLoot", client->GetVersion());
  8220. if (packet2) {
  8221. packet2->setArrayLengthByName("loot_count", 1);
  8222. packet2->setArrayDataByName("name", "Test");
  8223. packet2->setArrayDataByName("item_id", 1234);
  8224. packet2->setArrayDataByName("count", 1);
  8225. packet2->setArrayDataByName("icon", 258);
  8226. packet2->setArrayDataByName("ability_id", 0xFFFFFFFF);
  8227. Spawn* spawn = client->GetPlayer()->GetTarget();
  8228. if (spawn)
  8229. packet2->setDataByName("object_id", client->GetPlayer()->GetIDWithPlayerSpawn(spawn));
  8230. packet2->setDataByName("unknown3", 1);
  8231. packet2->setDataByName("unknown4", 1);
  8232. packet2->setDataByName("unknown5", 60);
  8233. EQ2Packet* app = packet2->serialize();
  8234. DumpPacket(app);
  8235. client->QueuePacket(app);
  8236. safe_delete(packet2);
  8237. }
  8238. }
  8239. else if (atoi(sep->arg[0]) == 16 && sep->IsNumber(1)) {
  8240. char blah[32];
  8241. sprintf(blah, "Testing: %i", atoi(sep->arg[1]));
  8242. client->SimpleMessage(atoi(sep->arg[1]), blah);
  8243. }
  8244. else if (atoi(sep->arg[0]) == 17 && sep->IsNumber(2)) {
  8245. if (sep->IsSet(2)) {
  8246. int16 offset = atoi(sep->arg[1]);
  8247. if (sep->IsNumber(2)) {
  8248. int32 value1 = atol(sep->arg[2]);
  8249. client->QueuePacket(client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion(), offset, value1));
  8250. cout << "Sent" << endl;
  8251. }
  8252. }
  8253. }
  8254. else if (atoi(sep->arg[0]) == 18) {
  8255. PacketStruct* packet2 = configReader.getStruct("WS_QuestRewardPackMsg", client->GetVersion());
  8256. if (packet2) {
  8257. packet2->setSubstructDataByName("reward_data", "unknown1", 255);
  8258. packet2->setSubstructDataByName("reward_data", "reward", "Quest Reward!");
  8259. packet2->setSubstructDataByName("reward_data", "coin", 150);
  8260. packet2->setSubstructDataByName("reward_data", "status_points", 5);
  8261. packet2->setSubstructDataByName("reward_data", "exp_bonus", 10);
  8262. packet2->setSubstructArrayLengthByName("reward_data", "num_rewards", 4);
  8263. Item* item = new Item(master_item_list.GetItem(36212));
  8264. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8265. item->stack_count = 20;
  8266. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  8267. safe_delete(item);
  8268. item = new Item(master_item_list.GetItem(36685));
  8269. item->stack_count = 20;
  8270. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8271. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 1, 0, -1);
  8272. safe_delete(item);
  8273. item = master_item_list.GetItem(1414);
  8274. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8275. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 2, 0, -1);
  8276. item = master_item_list.GetItem(75057);
  8277. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8278. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 3, 0, -1);
  8279. EQ2Packet* app = packet2->serialize();
  8280. if (sep->IsSet(2)) {
  8281. int16 offset = atoi(sep->arg[1]);
  8282. uchar* ptr2 = app->pBuffer;
  8283. ptr2 += offset;
  8284. if (sep->IsNumber(2)) {
  8285. int32 value1 = atol(sep->arg[2]);
  8286. if (value1 > 0xFFFF)
  8287. memcpy(ptr2, (uchar*)&value1, 4);
  8288. else if (value1 > 0xFF)
  8289. memcpy(ptr2, (uchar*)&value1, 2);
  8290. else
  8291. memcpy(ptr2, (uchar*)&value1, 1);
  8292. }
  8293. else {
  8294. int16 len = strlen(sep->arg[2]);
  8295. memcpy(ptr2, (uchar*)&len, 2);
  8296. ptr2 += 2;
  8297. memcpy(ptr2, sep->arg[2], len);
  8298. }
  8299. }
  8300. DumpPacket(app);
  8301. client->QueuePacket(app);
  8302. safe_delete(packet2);
  8303. }
  8304. }
  8305. else if (atoi(sep->arg[0]) == 19) {
  8306. PacketStruct* packet2 = configReader.getStruct("WS_UpdateLoot", client->GetVersion());
  8307. Spawn* spawn = client->GetPlayer()->GetTarget();
  8308. if (packet2 && spawn) {
  8309. Item* item = master_item_list.GetItem(130053);
  8310. packet2->setArrayLengthByName("loot_count", 1);
  8311. packet2->setArrayDataByName("loot_id", item->details.item_id);
  8312. packet2->setArrayDataByName("unknown2", 1);
  8313. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, 2, true);
  8314. packet2->setDataByName("display", 1);
  8315. packet2->setDataByName("unknown2b", 1);
  8316. packet2->setDataByName("unknown3", 0x3c);
  8317. packet2->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(spawn));
  8318. packet2->PrintPacket();
  8319. EQ2Packet* app = packet2->serialize();
  8320. if (sep->IsSet(2)) {
  8321. int16 offset = atoi(sep->arg[1]);
  8322. int16 offset2 = 0;
  8323. int32 value1 = 0;
  8324. if (sep->IsSet(3)) {
  8325. offset2 = atoi(sep->arg[2]);
  8326. value1 = atol(sep->arg[3]);
  8327. }
  8328. else
  8329. value1 = atol(sep->arg[2]);
  8330. int16 offset3 = 0;
  8331. int16 offset4 = 0;
  8332. int32 value2 = 0;
  8333. if (sep->IsSet(6)) {
  8334. offset3 = atoi(sep->arg[4]);
  8335. offset4 = atoi(sep->arg[5]);
  8336. value2 = atol(sep->arg[6]);
  8337. }
  8338. offset--;
  8339. if (offset2 > 0 && offset2 >= offset) {
  8340. offset2--;
  8341. uchar* ptr2 = app->pBuffer;
  8342. ptr2 += offset;
  8343. for (int i = offset; i <= offset2; i++) {
  8344. if (value1 > 0xFFFF) {
  8345. memcpy(ptr2, (uchar*)&value1, 4);
  8346. i += 3;
  8347. ptr2 += 3;
  8348. }
  8349. else if (value1 > 0xFF) {
  8350. memcpy(ptr2, (uchar*)&value1, 2);
  8351. i++;
  8352. ptr2++;
  8353. }
  8354. else
  8355. memcpy(ptr2, (uchar*)&value1, 1);
  8356. ptr2++;
  8357. }
  8358. }
  8359. if (offset4 > 0 && offset4 >= offset3) {
  8360. offset3--;
  8361. offset4--;
  8362. uchar* ptr2 = app->pBuffer;
  8363. ptr2 += offset3;
  8364. for (int i = offset3; i <= offset4; i++) {
  8365. if (value2 > 0xFFFF) {
  8366. memcpy(ptr2, (uchar*)&value2, 4);
  8367. i += 3;
  8368. ptr2 += 3;
  8369. }
  8370. else if (value2 > 0xFF) {
  8371. memcpy(ptr2, (uchar*)&value2, 2);
  8372. i++;
  8373. ptr2++;
  8374. }
  8375. else
  8376. memcpy(ptr2, (uchar*)&value2, 1);
  8377. ptr2++;
  8378. }
  8379. }
  8380. }
  8381. DumpPacket(app);
  8382. client->QueuePacket(app);
  8383. safe_delete(packet2);
  8384. }
  8385. }
  8386. else if (atoi(sep->arg[0]) == 20) {
  8387. uchar blah[] = { 0x09,0x01,0x00,0x00,0xff,0xc9,0x01,0x03,0x00,0x4d,0xf0,0x00,0x00,0x01
  8388. ,0x00,0x00,0x00,0x4d,0xf0,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xd7
  8389. ,0x05,0x01,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
  8390. ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x64,0x0a,0x8c,0x5a,0xf1,0xd2,0x8c,0x5a,0xf1
  8391. ,0xd2,0x01,0x01,0x00,0xff,0x1e,0x00,0x01,0x03,0x03,0x00,0x00,0x00,0x03,0x07
  8392. ,0x07,0x00,0x10,0x74,0x68,0x72,0x65,0x61,0x64,0x62,0x61,0x72,0x65,0x20,0x74,0x75
  8393. ,0x6e,0x69,0x63,0x00,0x00,0x4e,0xf0,0x00,0x00,0x01,0x00,0x04,0x00,0x4e,0xf0,0x00
  8394. ,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0a,0x00,0x01,0x60,0x00,0x00,0x00
  8395. ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
  8396. ,0x00,0x64,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x03
  8397. ,0x00,0x00,0x00,0x05,0x04,0x04,0x00,0x00,0x00,0x00,0x09,0x73,0x6d,0x61,0x6c,0x6c
  8398. ,0x20,0x62,0x61,0x67,0x00,0x00,0x4f,0xf0,0x00,0x00,0x01,0x00,0x04,0x00,0x4f,0xf0
  8399. ,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x02,0x01,0x01,0x60,0x01,0x00
  8400. ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
  8401. ,0x00,0x00,0x64,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00
  8402. ,0x03,0x00,0x00,0x00,0x00,0x00,0x0c,0x57,0x61,0x75,0x6c,0x6f,0x6e,0x27,0x73,0x20
  8403. ,0x48,0x61,0x74,0x00,0x00,0x01,0x01,0x00,0x00,0x00,0x3c,0x00,0x00,0x00,0x0d,0x00
  8404. ,0x00,0x00 };
  8405. EQ2Packet* app = new EQ2Packet(OP_ClientCmdMsg, blah, sizeof(blah));
  8406. if (sep->IsSet(2)) {
  8407. int16 offset = atoi(sep->arg[1]);
  8408. uchar* ptr2 = app->pBuffer;
  8409. ptr2 += offset;
  8410. if (sep->IsNumber(2)) {
  8411. int32 value1 = atol(sep->arg[2]);
  8412. if (value1 > 0xFFFF)
  8413. memcpy(ptr2, (uchar*)&value1, 4);
  8414. else if (value1 > 0xFF)
  8415. memcpy(ptr2, (uchar*)&value1, 2);
  8416. else
  8417. memcpy(ptr2, (uchar*)&value1, 1);
  8418. }
  8419. else {
  8420. int16 len = strlen(sep->arg[2]);
  8421. memcpy(ptr2, (uchar*)&len, 2);
  8422. ptr2 += 2;
  8423. memcpy(ptr2, sep->arg[2], len);
  8424. }
  8425. }
  8426. DumpPacket(app);
  8427. client->QueuePacket(app);
  8428. }
  8429. }
  8430. else if (atoi(sep->arg[0]) == 21) {
  8431. PacketStruct* packet2 = configReader.getStruct("WS_OfferQuest", client->GetVersion());
  8432. if (packet2) {
  8433. packet2->setDataByName("unknown0", 255);
  8434. packet2->setDataByName("reward", "New Quest");
  8435. packet2->setDataByName("title", "Title");
  8436. packet2->setDataByName("description", "description");
  8437. packet2->setDataByName("quest_difficulty", 3);
  8438. packet2->setDataByName("unknown1", 5);
  8439. packet2->setDataByName("level", 3);
  8440. packet2->setDataByName("coin", 150);
  8441. packet2->setDataByName("status_points", 5);
  8442. packet2->setDataByName("exp_bonus", 10);
  8443. packet2->setArrayLengthByName("num_rewards", 1);
  8444. Item* item = new Item(master_item_list.GetItem(36212));
  8445. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8446. item->stack_count = 20;
  8447. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  8448. safe_delete(item);
  8449. char accept[35] = { 0 };
  8450. char decline[35] = { 0 };
  8451. sprintf(accept, "q_accept_pending_quest %u", 0);
  8452. sprintf(decline, "q_deny_pending_quest %u", 0);
  8453. packet2->setDataByName("accept_command", accept);
  8454. packet2->setDataByName("decline_command", decline);
  8455. EQ2Packet* app = packet2->serialize();
  8456. if (sep->IsSet(2)) {
  8457. int16 offset = atoi(sep->arg[1]);
  8458. uchar* ptr2 = app->pBuffer;
  8459. ptr2 += offset;
  8460. if (sep->IsNumber(2)) {
  8461. int32 value1 = atol(sep->arg[2]);
  8462. if (value1 > 0xFFFF)
  8463. memcpy(ptr2, (uchar*)&value1, 4);
  8464. else if (value1 > 0xFF)
  8465. memcpy(ptr2, (uchar*)&value1, 2);
  8466. else
  8467. memcpy(ptr2, (uchar*)&value1, 1);
  8468. }
  8469. else {
  8470. int16 len = strlen(sep->arg[2]);
  8471. memcpy(ptr2, (uchar*)&len, 2);
  8472. ptr2 += 2;
  8473. memcpy(ptr2, sep->arg[2], len);
  8474. }
  8475. }
  8476. DumpPacket(app);
  8477. client->QueuePacket(app);
  8478. safe_delete(packet2);
  8479. }
  8480. }
  8481. else if (atoi(sep->arg[0]) == 22) { //same as 21, but 8bit string
  8482. PacketStruct* packet2 = configReader.getStruct("WS_OfferQuest", client->GetVersion());
  8483. if (packet2) {
  8484. packet2->setDataByName("unknown0", 255);
  8485. packet2->setDataByName("reward", "New Quest");
  8486. packet2->setDataByName("title", "Title");
  8487. packet2->setDataByName("description", "description");
  8488. packet2->setDataByName("quest_difficulty", 3);
  8489. packet2->setDataByName("unknown1", 5);
  8490. packet2->setDataByName("level", 3);
  8491. packet2->setDataByName("coin", 150);
  8492. packet2->setDataByName("status_points", 5);
  8493. packet2->setDataByName("exp_bonus", 10);
  8494. packet2->setArrayLengthByName("num_rewards", 1);
  8495. Item* item = new Item(master_item_list.GetItem(36212));
  8496. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8497. item->stack_count = 20;
  8498. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  8499. safe_delete(item);
  8500. char accept[35] = { 0 };
  8501. char decline[35] = { 0 };
  8502. sprintf(accept, "q_accept_pending_quest %u", 0);
  8503. sprintf(decline, "q_deny_pending_quest %u", 0);
  8504. packet2->setDataByName("accept_command", accept);
  8505. packet2->setDataByName("decline_command", decline);
  8506. EQ2Packet* app = packet2->serialize();
  8507. if (sep->IsSet(2)) {
  8508. int16 offset = atoi(sep->arg[1]);
  8509. uchar* ptr2 = app->pBuffer;
  8510. ptr2 += offset;
  8511. if (sep->IsNumber(2)) {
  8512. int32 value1 = atol(sep->arg[2]);
  8513. if (value1 > 0xFFFF)
  8514. memcpy(ptr2, (uchar*)&value1, 4);
  8515. else if (value1 > 0xFF)
  8516. memcpy(ptr2, (uchar*)&value1, 2);
  8517. else
  8518. memcpy(ptr2, (uchar*)&value1, 1);
  8519. }
  8520. else {
  8521. int8 len = strlen(sep->arg[2]);
  8522. memcpy(ptr2, (uchar*)&len, 1);
  8523. ptr2 += 1;
  8524. memcpy(ptr2, sep->arg[2], len);
  8525. }
  8526. }
  8527. DumpPacket(app);
  8528. client->QueuePacket(app);
  8529. safe_delete(packet2);
  8530. }
  8531. }
  8532. else {
  8533. PacketStruct* packet2 = configReader.getStruct("WS_ExamineSpellInfo", client->GetVersion());
  8534. if (packet2) {
  8535. packet2->setSubstructDataByName("info_header", "show_name", 1);
  8536. packet2->setSubstructDataByName("info_header", "unknown", 7);
  8537. packet2->setSubstructDataByName("info_header", "unknown2", 1);
  8538. packet2->setSubstructDataByName("info_header", "unknown3", 1);
  8539. packet2->setSubstructDataByName("info_header", "unknown4", 1);
  8540. packet2->setSubstructDataByName("info_header", "unknown5", 1);
  8541. packet2->setSubstructDataByName("info_header", "unknown6", "Testing");
  8542. packet2->setSubstructDataByName("info_header", "unknown7", "Testing");
  8543. packet2->setSubstructDataByName("info_header", "unknown8", 66);
  8544. packet2->setSubstructDataByName("info_header", "title", "Blah Title Blah");
  8545. packet2->setSubstructDataByName("info_header", "title_text", "Blah Blah");
  8546. packet2->setSubstructDataByName("info_header", "title_text2", "Blah Blah2");
  8547. packet2->setSubstructDataByName("info_header", "show_popup", 1);
  8548. packet2->setSubstructDataByName("info_header", "packettype", 3);
  8549. packet2->setSubstructDataByName("spell_info", "skill_name", "Testing");
  8550. packet2->setSubstructDataByName("spell_info", "level", 19);
  8551. packet2->setSubstructDataByName("spell_info", "tier", 1);
  8552. packet2->setSubstructDataByName("spell_info", "health_cost", 5);
  8553. packet2->setSubstructDataByName("spell_info", "min_class_skill_req", 3);
  8554. packet2->setSubstructDataByName("spell_info", "mana_cost", 6);
  8555. packet2->setSubstructDataByName("spell_info", "req_concentration", 7);
  8556. packet2->setSubstructDataByName("spell_info", "cast_time", 200);
  8557. packet2->setSubstructDataByName("spell_info", "recovery", 220);
  8558. packet2->setSubstructDataByName("spell_info", "recast", 280);
  8559. packet2->setSubstructDataByName("spell_info", "beneficial", 1);
  8560. packet2->setSubstructDataByName("spell_info", "maintained", 1);
  8561. packet2->setSubstructDataByName("spell_info", "spell_book_type", 1);
  8562. packet2->setSubstructDataByName("spell_info", "quality", 3);
  8563. packet2->setSubstructDataByName("spell_info", "test_1a", 1);
  8564. packet2->setSubstructDataByName("spell_info", "test_1b", 1);
  8565. packet2->setSubstructDataByName("spell_info", "test_1c", 1);
  8566. packet2->setSubstructDataByName("spell_info", "test_1d", 1);
  8567. packet2->setSubstructDataByName("spell_info", "test_2a", 2);
  8568. packet2->setSubstructDataByName("spell_info", "test_2b", 2);
  8569. packet2->setSubstructDataByName("spell_info", "test_2c", 2);
  8570. packet2->setSubstructDataByName("spell_info", "test_2d", 2);
  8571. packet2->setSubstructDataByName("spell_info", "test_3", 3);
  8572. packet2->setSubstructDataByName("spell_info", "test_4", 4);
  8573. packet2->setSubstructDataByName("spell_info", "test_5", 5);
  8574. packet2->setSubstructDataByName("spell_info", "test_6", 6);
  8575. packet2->setSubstructDataByName("spell_info", "min_class_skill_req", 1);
  8576. packet2->setSubstructDataByName("spell_info", "min_class_skill_rec", 30123);
  8577. packet2->setSubstructDataByName("spell_info", "num_reagents", 1);
  8578. packet2->setSubstructArrayLengthByName("spell_info", "num_reagents", 1);
  8579. packet2->setArrayDataByName("reagent", "Alcohol");
  8580. packet2->setArrayDataByName("consumed", "123");
  8581. packet2->setSubstructDataByName("spell_info", "class_skill", 52);
  8582. packet2->setSubstructDataByName("spell_info", "id", 8308);
  8583. packet2->setSubstructDataByName("spell_info", "icon", 303);
  8584. packet2->setSubstructDataByName("spell_info", "icon2", 0xFFFF);
  8585. packet2->setSubstructDataByName("spell_info", "icontype", 317);
  8586. packet2->setSubstructDataByName("spell_info", "type", 2);
  8587. packet2->setSubstructDataByName("spell_info", "spell_text_color", 255);
  8588. packet2->setSubstructDataByName("spell_info", "duration1", 600);
  8589. packet2->setSubstructDataByName("spell_info", "duration2", 600);
  8590. packet2->setSubstructDataByName("spell_info", "name", "Sprint");
  8591. packet2->setSubstructDataByName("spell_info", "description", "Test description");
  8592. EQ2Packet* outapp = packet2->serialize();
  8593. DumpPacket(outapp);
  8594. client->QueuePacket(outapp);
  8595. safe_delete(packet2);
  8596. }
  8597. }
  8598. return;
  8599. PacketStruct* p = configReader.getStruct("WS_EqTargetItemCmd", client->GetVersion());
  8600. if (!p) return;
  8601. //Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  8602. //client->GetCurrentZone()->SendSpellFailedPacket(client, atoi(sep2->arg[0]));
  8603. //}
  8604. /*Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  8605. if (sep2 && sep2->arg[0] && sep2->IsNumber(0)) {
  8606. client->SetPendingFlightPath(atoi(sep2->arg[0]));
  8607. PacketStruct* packet = configReader.getStruct("WS_ReadyForTakeOff", client->GetVersion());
  8608. if (packet) {
  8609. client->QueuePacket(packet->serialize());
  8610. safe_delete(packet);
  8611. }
  8612. }*/
  8613. /*if (client->GetCurrentZone()->Grid != nullptr) {
  8614. int32 numFaces = 0;
  8615. int32 numGrids = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.size();
  8616. client->Message(CHANNEL_COLOR_YELLOW, "Num grids in cell: %u", numGrids);
  8617. map<int32, vector<Face*> >::iterator itr;
  8618. for (itr = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.begin(); itr != client->GetPlayer()->Cell_Info.CurrentCell->FaceList.end(); itr++)
  8619. numFaces += (*itr).second.size();
  8620. client->Message(CHANNEL_COLOR_YELLOW, "Num faces in cell: %u", numFaces);
  8621. }*/
  8622. //uchar blah[] = {
  8623. // 1208 - OP_EQUpdateStoreCmd
  8624. // /*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
  8625. // /*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
  8626. // 1193 - -- OP_ClientCmdMsg::OP_EqUpdateMerchantCmd --
  8627. // /*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
  8628. /*};
  8629. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  8630. int8 val = 0;
  8631. int16 pos = 0;
  8632. int idx = 0;
  8633. while(sep2 && sep2->arg[idx+1] && sep2->IsNumber(idx) && sep2->IsNumber(idx+1)){
  8634. pos = atoi(sep2->arg[idx]);
  8635. val = atoi(sep2->arg[idx+1]);
  8636. memset(blah+pos, val, 1);
  8637. idx+=2;
  8638. }
  8639. DumpPacket(blah, sizeof(blah));
  8640. client->QueuePacket(new EQ2Packet(OP_GroupCreatedMsg , blah, sizeof(blah)));*/
  8641. if (client->GetPlayer()->GetTarget()) {
  8642. PacketStruct* packet = configReader.getStruct("WS_SetControlGhost", client->GetVersion());
  8643. if (packet) {
  8644. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  8645. packet->setDataByName("size", 0);
  8646. packet->setDataByName("unknown2", 0);
  8647. EQ2Packet* app = packet->serialize();
  8648. client->QueuePacket(app);
  8649. safe_delete(packet);
  8650. }
  8651. PacketStruct* set_pov = configReader.getStruct("WS_SetPOVGhostCmd", client->GetVersion());
  8652. if (set_pov) {
  8653. set_pov->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  8654. EQ2Packet* app_pov = set_pov->serialize();
  8655. client->QueuePacket(app_pov);
  8656. safe_delete(set_pov);
  8657. }
  8658. }
  8659. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  8660. PacketStruct* packet = configReader.getStruct("WS_OpenCharCust", client->GetVersion());
  8661. if (packet) {
  8662. if (sep2 && sep2->arg[0] && sep2->IsNumber(0))
  8663. packet->setDataByName("Type", atoi(sep2->arg[0]));
  8664. else
  8665. packet->setDataByName("Type", 2);
  8666. if (sep2 && sep2->arg[1] && sep2->IsNumber(1))
  8667. packet->setDataByName("race_id", atoi(sep2->arg[1]));
  8668. else
  8669. packet->setDataByName("race_id", 0);
  8670. if (sep2 && sep2->arg[2] && sep2->IsNumber(2))
  8671. packet->setDataByName("gender", atoi(sep2->arg[2]));
  8672. else
  8673. packet->setDataByName("gender", 2);
  8674. if (sep2 && sep2->arg[3] && sep2->IsNumber(3))
  8675. packet->setDataByName("unknown", atoi(sep2->arg[3]), 0);
  8676. else
  8677. packet->setDataByName("unknown", 0, 0);
  8678. if (sep2 && sep2->arg[4] && sep2->IsNumber(4))
  8679. packet->setDataByName("unknown", atoi(sep2->arg[4]), 1);
  8680. else
  8681. packet->setDataByName("unknown", 0, 1);
  8682. if (sep2 && sep2->arg[5] && sep2->IsNumber(5))
  8683. packet->setDataByName("unknown", atoi(sep2->arg[5]), 2);
  8684. else
  8685. packet->setDataByName("unknown", 0, 2);
  8686. client->QueuePacket(packet->serialize());
  8687. }
  8688. safe_delete(packet);
  8689. safe_delete(sep2);
  8690. }
  8691. void Commands::Command_LeaveChannel(Client *client, Seperator *sep) {
  8692. const char *channel_name;
  8693. if (sep == NULL || !sep->IsSet(0)) {
  8694. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /leavechat <channel name>");
  8695. PrintSep(sep);
  8696. return;
  8697. }
  8698. channel_name = sep->arg[0];
  8699. if (!chat.IsInChannel(client, channel_name))
  8700. client->Message(CHANNEL_COLOR_WHITE, "Unable to leave '%s': You are not in the channel.", channel_name);
  8701. else if (!chat.LeaveChannel(client, channel_name))
  8702. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an internal error preventing you from leaving that channel MUAHAHA");
  8703. }
  8704. /*
  8705. Function:
  8706. Purpose :
  8707. Params :
  8708. Dev :
  8709. Example :
  8710. */
  8711. void Commands::Command_WeaponStats(Client* client)
  8712. {
  8713. Player* player = client->GetPlayer();
  8714. Item* primary = player->GetEquipmentList()->GetItem(EQ2_PRIMARY_SLOT);
  8715. Item* secondary = player->GetEquipmentList()->GetItem(EQ2_SECONDARY_SLOT);
  8716. Item* ranged = player->GetEquipmentList()->GetItem(EQ2_RANGE_SLOT);
  8717. client->SimpleMessage(0, "Primary:");
  8718. if (primary) {
  8719. client->Message(0, "Name: %s", primary->name.c_str());
  8720. client->Message(0, "Base Damage: %u - %u", primary->weapon_info->damage_low3, primary->weapon_info->damage_high3);
  8721. client->Message(0, "Actual Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  8722. client->Message(0, "Actual Delay: %u", player->GetPrimaryWeaponDelay());
  8723. client->Message(0, "Proc Percent: %d%%", 0);
  8724. client->Message(0, "Procs Per Minute: %d", 0);
  8725. }
  8726. else {
  8727. client->SimpleMessage(0, "Name: fist");
  8728. client->Message(0, "Base Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  8729. client->Message(0, "Actual Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  8730. client->Message(0, "Actual Delay: %d", player->GetPrimaryWeaponDelay() * 0.1);
  8731. client->Message(0, "Proc Percent: %d%%", 0);
  8732. client->Message(0, "Procs Per Minute: %d", 0);
  8733. }
  8734. client->SimpleMessage(0, " ");
  8735. client->SimpleMessage(0, " ");
  8736. if (secondary) {
  8737. client->SimpleMessage(0, "Secondary:");
  8738. client->Message(0, "Name: %s", secondary->name.c_str());
  8739. client->Message(0, "Base Damage: %u - %u", secondary->weapon_info->damage_low3, secondary->weapon_info->damage_high3);
  8740. client->Message(0, "Actual Damage: %u - %u", player->GetSecondaryWeaponMinDamage(), player->GetSecondaryWeaponMaxDamage());
  8741. client->Message(0, "Actual Delay: %d", player->GetSecondaryWeaponDelay() * 0.1);
  8742. client->Message(0, "Proc Percent: %d%%", 0);
  8743. client->Message(0, "Procs Per Minute: %d", 0);
  8744. client->SimpleMessage(0, " ");
  8745. client->SimpleMessage(0, " ");
  8746. }
  8747. client->SimpleMessage(0, "Ranged:");
  8748. if (ranged) {
  8749. client->Message(0, "Name: %s", ranged->name.c_str());
  8750. client->Message(0, "Base Damage: %u - %u", ranged->ranged_info->weapon_info.damage_low3, ranged->ranged_info->weapon_info.damage_high3);
  8751. client->Message(0, "Actual Damage: %u - %u", player->GetRangedWeaponMinDamage(), player->GetRangedWeaponMaxDamage());
  8752. client->Message(0, "Actual Delay: %d", player->GetRangeWeaponDelay() * 0.1);
  8753. client->Message(0, "Proc Percent: %d%%", 0);
  8754. client->Message(0, "Procs Per Minute: %d", 0);
  8755. }
  8756. else
  8757. client->SimpleMessage(0, "None");
  8758. }
  8759. void Commands::Command_WhoChannel(Client *client, Seperator *sep) {
  8760. const char *channel_name;
  8761. if (sep == NULL || !sep->IsSet(0)) {
  8762. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /chatwho <channel name>");
  8763. return;
  8764. }
  8765. channel_name = sep->arg[0];
  8766. if (!chat.ChannelExists(channel_name))
  8767. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That channel does not exist!");
  8768. else
  8769. chat.SendChannelUserList(client, channel_name);
  8770. }
  8771. void Commands::Command_ZoneSafeCoords(Client *client, Seperator *sep)
  8772. {
  8773. ZoneServer* zone = 0;
  8774. int32 zone_id = client->GetPlayer()->GetZone()->GetZoneID();
  8775. if (zone_id > 0)
  8776. {
  8777. zone = zone_list.Get(zone_id, false);
  8778. if (zone)
  8779. {
  8780. zone->SetSafeX(client->GetPlayer()->GetX());
  8781. zone->SetSafeY(client->GetPlayer()->GetY());
  8782. zone->SetSafeZ(client->GetPlayer()->GetZ());
  8783. zone->SetSafeHeading(client->GetPlayer()->GetHeading());
  8784. if( database.SaveZoneSafeCoords(zone_id, zone->GetSafeX(), zone->GetSafeY(), zone->GetSafeZ(), zone->GetSafeHeading()) )
  8785. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Zone safe coordinates updated!");
  8786. else
  8787. client->SimpleMessage(CHANNEL_COLOR_RED, "FAILED to update zone safe coordinates!");
  8788. }
  8789. }
  8790. }
  8791. /*
  8792. Function:
  8793. Purpose :
  8794. Params :
  8795. Dev :
  8796. Example :
  8797. */
  8798. void Commands::Command_ZoneDetails(Client* client, Seperator* sep)
  8799. {
  8800. ZoneInfo* zone_info = new ZoneInfo;
  8801. if (sep && sep->arg[0])
  8802. {
  8803. if (sep->IsNumber(0))
  8804. zone_info->id = atoi(sep->arg[0]);
  8805. else
  8806. zone_info->id = database.GetZoneID(sep->arg[0]);
  8807. if (zone_info->id > 0)
  8808. {
  8809. database.LoadZoneInfo(zone_info);
  8810. 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);
  8811. 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);
  8812. 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);
  8813. 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);
  8814. 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);
  8815. 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);
  8816. 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);
  8817. client->Message(CHANNEL_COLOR_YELLOW, "zone_type: %s", zone_info->zone_type);
  8818. client->Message(CHANNEL_COLOR_YELLOW, "lua_script: %s", zone_info->lua_script);
  8819. client->Message(CHANNEL_COLOR_YELLOW, "zone_motd: %s", zone_info->zone_motd);
  8820. }
  8821. else
  8822. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  8823. }
  8824. else
  8825. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone details [zone id|zone name]");
  8826. safe_delete(zone_info);
  8827. }
  8828. /*
  8829. Function:
  8830. Purpose :
  8831. Params :
  8832. Dev :
  8833. Example :
  8834. */
  8835. void Commands::Command_ZoneSet(Client* client, Seperator* sep)
  8836. {
  8837. if (sep && sep->arg[0] && sep->arg[1] && sep->arg[2])
  8838. {
  8839. ZoneServer* zone = 0;
  8840. int32 zone_id = 0;
  8841. if (sep->IsNumber(0) && atoi(sep->arg[0]) > 0)
  8842. {
  8843. zone_id = atoi(sep->arg[0]);
  8844. zone = zone_list.Get(atoi(sep->arg[0]), false);
  8845. }
  8846. else
  8847. {
  8848. zone_id = database.GetZoneID(sep->arg[0]);
  8849. if (zone_id > 0)
  8850. zone = zone_list.Get(sep->arg[0], false);
  8851. }
  8852. if (zone_id > 0)
  8853. {
  8854. if (zone_set_values.count(string(sep->arg[1])) > 0)
  8855. SetZoneCommand(client, zone_id, zone, zone_set_values[sep->arg[1]], sep->arg[2]);
  8856. else
  8857. client->Message(CHANNEL_COLOR_YELLOW, "The attribute '%s' is not valid.", sep->arg[1]);
  8858. }
  8859. else
  8860. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  8861. }
  8862. else
  8863. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone set [zone id|zone name] [attribute] [value]");
  8864. }
  8865. void Commands::Command_Rain(Client* client, Seperator* sep) {
  8866. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  8867. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /rain <float>");
  8868. return;
  8869. }
  8870. client->Message(CHANNEL_COLOR_YELLOW,"Setting rain to %.2f", atof(sep->arg[0]));
  8871. client->GetCurrentZone()->SetRain(atof(sep->arg[0]));
  8872. client->GetCurrentZone()->SetCurrentWeather(atof(sep->arg[0]));
  8873. }
  8874. void Commands::Command_Wind(Client* client, Seperator* sep) {
  8875. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  8876. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /wind <float>");
  8877. return;
  8878. }
  8879. client->Message(CHANNEL_COLOR_YELLOW, "Setting wind to %.2f", atof(sep->arg[0]));
  8880. client->GetCurrentZone()->SetWind(atof(sep->arg[0]));
  8881. }
  8882. void Commands::Command_SendMerchantWindow(Client* client, Seperator* sep, bool sell) {
  8883. Spawn* spawn = client->GetPlayer()->GetTarget();
  8884. if(spawn) {
  8885. client->SetMerchantTransaction(spawn);
  8886. if (spawn->GetMerchantID() > 0 && spawn->IsClientInMerchantLevelRange(client)){
  8887. client->SendHailCommand(spawn);
  8888. //MerchantFactionMultiplier* multiplier = world.GetMerchantMultiplier(spawn->GetMerchantID());
  8889. //if(!multiplier || (multiplier && client->GetPlayer()->GetFactions()->GetFactionValue(multiplier->faction_id) >= multiplier->faction_min)){
  8890. client->SendBuyMerchantList(sell);
  8891. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY))
  8892. client->SendSellMerchantList(sell);
  8893. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY_BACK))
  8894. client->SendBuyBackList(sell);
  8895. PacketStruct* packet = configReader.getStruct("WS_UpdateMerchant", client->GetVersion());
  8896. if (packet) {
  8897. packet->setDataByName("spawn_id", 0xFFFFFFFF);
  8898. packet->setDataByName("type", 16);
  8899. EQ2Packet* outapp = packet->serialize();
  8900. if (outapp)
  8901. client->QueuePacket(outapp);
  8902. safe_delete(packet);
  8903. }
  8904. }
  8905. if (spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR)
  8906. client->SendRepairList();
  8907. }
  8908. // client->SimpleMessage(CHANNEL_COLOR_RED, "Your faction is too low to use this merchant.");
  8909. }
  8910. void Commands::Command_Weather(Client* client, Seperator* sep)
  8911. {
  8912. //PrintSep(sep, "Weather");
  8913. if( sep && sep->arg[0] )
  8914. {
  8915. ZoneServer* zsZone = client->GetCurrentZone();
  8916. const char* value = sep->arg[0];
  8917. // process single-param commands first
  8918. if( strncasecmp(value, "details", strlen(value)) == 0 )
  8919. {
  8920. client->Message(CHANNEL_COLOR_YELLOW, "Weather Details for zone %s: ", zsZone->GetZoneName());
  8921. client->Message(CHANNEL_COLOR_YELLOW, "enabled: %i, allowed: %i, type: %i, frequency: %u", zsZone->isWeatherEnabled(), zsZone->isWeatherAllowed(), zsZone->GetWeatherType(), zsZone->GetWeatherFrequency());
  8922. client->Message(CHANNEL_COLOR_YELLOW, "severity: %.2f = %.2f, current: %.2f", zsZone->GetWeatherMinSeverity(), zsZone->GetWeatherMaxSeverity(), zsZone->GetCurrentWeather());
  8923. client->Message(CHANNEL_COLOR_YELLOW, "pattern: %i, chance: %i, amount: %.2f, offset: %.2f", zsZone->GetWeatherPattern(), zsZone->GetWeatherChance(), zsZone->GetWeatherChangeAmount(), zsZone->GetWeatherDynamicOffset());
  8924. }
  8925. else if( strncasecmp(value, "process", strlen(value)) == 0 )
  8926. {
  8927. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  8928. zsZone->ProcessWeather();
  8929. }
  8930. else if( strncasecmp(value, "reset", strlen(value)) == 0 )
  8931. {
  8932. zsZone->SetWeatherType(rule_manager.GetGlobalRule(R_Zone, WeatherType)->GetInt8());
  8933. zsZone->SetWeatherFrequency(rule_manager.GetGlobalRule(R_Zone, WeatherChangeFrequency)->GetInt32());
  8934. zsZone->SetWeatherMinSeverity(rule_manager.GetGlobalRule(R_Zone, MinWeatherSeverity)->GetFloat());
  8935. zsZone->SetWeatherMaxSeverity(rule_manager.GetGlobalRule(R_Zone, MaxWeatherSeverity)->GetFloat());
  8936. zsZone->SetCurrentWeather(zsZone->GetWeatherMinSeverity());
  8937. zsZone->SetWeatherPattern(1);
  8938. zsZone->SetWeatherChance(rule_manager.GetGlobalRule(R_Zone, WeatherChangeChance)->GetInt8());
  8939. zsZone->SetWeatherChangeAmount(rule_manager.GetGlobalRule(R_Zone, WeatherChangePerInterval)->GetFloat());
  8940. zsZone->SetWeatherDynamicOffset(rule_manager.GetGlobalRule(R_Zone, WeatherDynamicMaxOffset)->GetFloat());
  8941. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  8942. zsZone->ProcessWeather();
  8943. }
  8944. // process commands with params
  8945. if( sep->arg[1] )
  8946. {
  8947. if( strncasecmp(value, "enable", strlen(value)) == 0 && sep->IsNumber(1) )
  8948. zsZone->SetWeatherEnabled( ( atoi(sep->arg[1]) == 1 ) ? true : false );
  8949. else if( strncasecmp(value, "type", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 3) )
  8950. zsZone->SetWeatherType(atoi(sep->arg[1]));
  8951. else if( strncasecmp(value, "frequency", strlen(value)) == 0 && sep->IsNumber(1))
  8952. zsZone->SetWeatherFrequency( atoul(sep->arg[1]) );
  8953. else if( strncasecmp(value, "range", strlen(value)) == 0 && sep->IsNumber(1) && sep->IsNumber(2) ) {
  8954. zsZone->SetWeatherMinSeverity(atof(sep->arg[1]));
  8955. zsZone->SetWeatherMaxSeverity(atof(sep->arg[2]));
  8956. zsZone->SetRain(zsZone->GetWeatherMinSeverity());
  8957. }
  8958. else if( strncasecmp(value, "current", strlen(value)) == 0 && sep->IsNumber(1) ) {
  8959. zsZone->SetCurrentWeather(atof(sep->arg[1]));
  8960. zsZone->SetRain(zsZone->GetCurrentWeather());
  8961. }
  8962. else if( strncasecmp(value, "pattern", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 2) )
  8963. zsZone->SetWeatherPattern( atoi(sep->arg[1]) );
  8964. else if( strncasecmp(value, "chance", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 100) )
  8965. zsZone->SetWeatherChance( atoi(sep->arg[1]) );
  8966. else if( strncasecmp(value, "amount", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  8967. zsZone->SetWeatherChangeAmount( atof(sep->arg[1]) );
  8968. else if( strncasecmp(value, "offset", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  8969. zsZone->SetWeatherDynamicOffset( atof(sep->arg[1]) );
  8970. }
  8971. }
  8972. else
  8973. {
  8974. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /weather [command] [param]");
  8975. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: enable (0|1), type (0-3), frequency (sec), range|current (0.0 - 1.0)");
  8976. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: details, process, pattern (0|1), chance (%), amount (float), offset (float)");
  8977. return;
  8978. }
  8979. }
  8980. void Commands::Command_Select(Client* client, Seperator* sep) {
  8981. if (sep && sep->arg[1]) {
  8982. Spawn* spawn = client->GetPlayer()->GetTarget();
  8983. if (spawn && strlen(sep->arg[1]) > 0)
  8984. client->GetCurrentZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_CUSTOM, client->GetPlayer(), sep->arg[1]);
  8985. }
  8986. }
  8987. /*
  8988. Function: Command_ConsumeFood()
  8989. Purpose : Consume Food/Drink and apply mods
  8990. Params : Slot ID - EQ2_FOOD_SLOT 22, EQ2_DRINK_SLOT 23
  8991. Dev : Zcoretri
  8992. Example : /consume_food 22
  8993. */
  8994. void Commands::Command_ConsumeFood(Client* client, Seperator* sep) {
  8995. if (sep && sep->arg[0] && sep->IsNumber(0))
  8996. {
  8997. Player* player = client->GetPlayer();
  8998. int8 slot = atoi(sep->arg[0]);
  8999. Item* item = player->GetEquipmentList()->GetItem(slot);
  9000. if(item) {
  9001. LogWrite(MISC__INFO, 1, "Command", "ItemID: %u, ItemName: %s ItemCount: %i ", item->details.item_id, item->name.c_str(), item->details.count);
  9002. if(item->GetItemScript() && lua_interface){
  9003. lua_interface->RunItemScript(item->GetItemScript(), "cast", item, client->GetPlayer());
  9004. if (slot == 22)
  9005. client->Message(CHANNEL_COLOR_WHITE, "You eat a %s.", item->name.c_str());
  9006. else
  9007. client->Message(CHANNEL_COLOR_WHITE, "You drink a %s.", item->name.c_str());
  9008. }
  9009. }
  9010. if (item->details.count > 1) {
  9011. item->details.count -= 1;
  9012. item->save_needed = true;
  9013. }
  9014. else {
  9015. player->GetEquipmentList()->RemoveItem(slot, true);
  9016. database.DeleteItem(player->GetCharacterID(), item, "EQUIPPED");
  9017. }
  9018. client->GetPlayer()->SetCharSheetChanged(true);
  9019. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  9020. }
  9021. }
  9022. void Commands::Command_Aquaman(Client* client, Seperator* sep) {
  9023. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  9024. if (atoi(sep->arg[0]) == 1) {
  9025. client->GetPlayer()->GetInfoStruct()->vision = 4;
  9026. client->GetPlayer()->GetInfoStruct()->breathe_underwater = 1;
  9027. client->GetPlayer()->SetCharSheetChanged(true);
  9028. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Maybe you ought to stick to the shallow end until you know how to swim.");
  9029. }
  9030. else {
  9031. client->GetPlayer()->GetInfoStruct()->vision = 0;
  9032. client->GetPlayer()->GetInfoStruct()->breathe_underwater = 0;
  9033. client->GetPlayer()->SetCharSheetChanged(true);
  9034. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Aquaman mode turned off.");
  9035. }
  9036. }
  9037. else
  9038. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /aquaman [0|1]");
  9039. }
  9040. void Commands::Command_ReportBug(Client* client, Seperator* sep)
  9041. {
  9042. if(sep)
  9043. {
  9044. string data;
  9045. if(sep->arg[0]){
  9046. data = string(sep->arg[0]);
  9047. }
  9048. for(int i=1;i<sep->GetMaxArgNum();i++){
  9049. if(sep->arg[i])
  9050. data.append(" ").append(sep->arg[i]);
  9051. }
  9052. const char* target_name = 0;
  9053. int32 spawn_id = 0;
  9054. if(client->GetPlayer()->GetTarget())
  9055. {
  9056. target_name = client->GetPlayer()->GetTarget()->GetName();
  9057. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  9058. }
  9059. else
  9060. target_name = "N/A";
  9061. LogWrite(COMMAND__DEBUG, 1, "Command", "%s", data.c_str());
  9062. if(world.ReportBug(data, client->GetPlayer()->GetName(), client->GetAccountID(), target_name, spawn_id, client->GetCurrentZone()->GetZoneID()))
  9063. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully submitted bug.");
  9064. else
  9065. client->SimpleMessage(CHANNEL_COLOR_RED, "Error submitting bug.");
  9066. }
  9067. }
  9068. void Commands::Command_Attune_Inv(Client* client, Seperator* sep) {
  9069. PrintSep(sep, "Command_Attune_Inv");
  9070. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  9071. // Get the item index from the first parameter
  9072. int16 index = atoi(sep->arg[0]);
  9073. // Check to see if this is a valid item index for the player, if not exit out of the function
  9074. if (client->GetPlayer()->item_list.indexed_items.count(index) == 0) {
  9075. LogWrite(ITEM__DEBUG, 0, "Items", "%s has no item with an index of %i", client->GetPlayer()->GetName(), index);
  9076. return;
  9077. }
  9078. // Get the item
  9079. Item* item = client->GetPlayer()->item_list.indexed_items[index];
  9080. if(item) {
  9081. // Valid item lets check to make sure this item is attunable, if not return out
  9082. if (!item->CheckFlag(ATTUNEABLE)) {
  9083. LogWrite(ITEM__DEBUG, 0, "Items", "attune_inv called for an item that is not attunable (%s)", item->name.c_str());
  9084. return;
  9085. }
  9086. // Remove the attunable flag
  9087. item->generic_info.item_flags -= ATTUNEABLE;
  9088. // Set the attuned flag
  9089. item->generic_info.item_flags += ATTUNED;
  9090. // Flag this item for saving
  9091. item->save_needed = true;
  9092. client->QueuePacket(item->serialize(client->GetVersion(), false, client->GetPlayer()));
  9093. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), -1);
  9094. EQ2Packet* outapp = 0;
  9095. for (int32 i=0;i<packets.size();i++) {
  9096. outapp = packets[i];
  9097. if(outapp)
  9098. client->QueuePacket(outapp);
  9099. }
  9100. }
  9101. }
  9102. }
  9103. void Commands::Command_Reset_Zone_Timer(Client* client, Seperator* sep) {
  9104. PrintSep(sep, "Command_Reset_Zone_Timer");
  9105. /*if (sep && sep->arg[0] && sep->IsNumber(0)) {
  9106. int32 db_id = atoul(sep->arg[0]);
  9107. InstanceData* data = client->GetPlayer()->GetCharacterInstances().FindInstanceByDBID(db_id);
  9108. if (data) {
  9109. // TODO: add a check to timers to ensure it can be reset
  9110. // Delete the character from the instance
  9111. database.DeleteCharacterFromInstance(client->GetPlayer()->GetCharacterID(), data->instance_id);
  9112. data->instance_id = 0;
  9113. // Update the success time and set to 0 so the player can enter it again
  9114. database.UpdateCharacterInstance(client->GetPlayer()->GetCharacterID(), data->zone_name, 0, 1, 0);
  9115. data->last_success_timestamp = 0;
  9116. }
  9117. }*/
  9118. }
  9119. void Commands::Command_Player(Client* client, Seperator* sep) {
  9120. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player syntax --");
  9121. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins");
  9122. }
  9123. void Commands::Command_Player_Coins(Client* client, Seperator* sep) {
  9124. // /player coins add 10
  9125. // /player coins add plat 10
  9126. Player* player = client->GetPlayer();
  9127. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  9128. player = (Player*)player->GetTarget();
  9129. if (sep && sep->arg[0] && sep->arg[1]) {
  9130. const char* action = sep->arg[0];
  9131. int64 value = 0;
  9132. if (strncasecmp(action, "add", strlen(action)) == 0) {
  9133. if (sep->IsNumber(1)) {
  9134. value = atoi64(sep->arg[1]);
  9135. player->AddCoins(value);
  9136. if (client->GetPlayer() == player)
  9137. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  9138. else {
  9139. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  9140. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  9141. }
  9142. return;
  9143. }
  9144. else if (sep->arg[2] && sep->IsNumber(2)) {
  9145. const char* type = sep->arg[1];
  9146. if (strncasecmp(type, "copper", strlen(type)) == 0) {
  9147. value = atoi64(sep->arg[2]);
  9148. }
  9149. else if (strncasecmp(type, "silver", strlen(type)) == 0) {
  9150. value = atoi64(sep->arg[2]) * 100;
  9151. }
  9152. else if (strncasecmp(type, "gold", strlen(type)) == 0) {
  9153. value = atoi64(sep->arg[2]) * 10000;
  9154. }
  9155. else if (strncasecmp(type, "plat", strlen(type)) == 0) {
  9156. value = atoi64(sep->arg[2]) * 1000000;
  9157. }
  9158. player->AddCoins(value);
  9159. if (client->GetPlayer() == player)
  9160. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  9161. else {
  9162. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  9163. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  9164. }
  9165. return;
  9166. }
  9167. }
  9168. }
  9169. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player coins syntax --");
  9170. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add [value] - adds the given number of coins to the player");
  9171. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add copper [value] - adds the given amount of copper to the player");
  9172. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add silver [value] - adds the given amount of silver to the player");
  9173. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add gold [value] - adds the given amount of gold to the player");
  9174. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add plat [value] - adds the given amount of platinum to the player");
  9175. }
  9176. void Commands::Command_AchievementAdd(Client* client, Seperator* sep) {
  9177. PrintSep(sep, "ACHIEVEMENT_ADD");
  9178. if (sep && sep->IsSet(0)) {
  9179. int32 spell_id = atoul(sep->arg[1]);
  9180. int8 spell_tier = 0;
  9181. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  9182. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  9183. // addspellbookentry here
  9184. if (spell_tier >= data->maxRank) {
  9185. return;
  9186. }
  9187. if (!spell_tier) {
  9188. spell_tier = 1;
  9189. }
  9190. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  9191. {
  9192. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  9193. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  9194. client->GetPlayer()->UnlockSpell(spell);
  9195. client->SendSpellUpdate(spell);
  9196. }
  9197. else
  9198. {
  9199. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1);
  9200. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  9201. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  9202. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  9203. client->GetPlayer()->UnlockSpell(spell);
  9204. client->SendSpellUpdate(spell);
  9205. }
  9206. // cast spell here
  9207. if (!spell_tier)
  9208. spell_tier = 1;
  9209. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  9210. if (spell) {
  9211. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  9212. }
  9213. }
  9214. else {
  9215. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  9216. }
  9217. master_aa_list.DisplayAA(client, 0, 0);
  9218. }
  9219. void Commands::Command_Editor(Client* client, Seperator* sep) {
  9220. PacketStruct* packet = configReader.getStruct("WS_ChoiceWindow", client->GetVersion());
  9221. if (packet) {
  9222. string url = string(rule_manager.GetGlobalRule(R_World, EditorURL)->GetString());
  9223. if (rule_manager.GetGlobalRule(R_World, EditorOfficialServer)->GetBool()) {
  9224. char command[255];
  9225. url = "browser " + url;
  9226. int32 spawn_id = 0;
  9227. int32 zone_id = 0;
  9228. string type;
  9229. if (client->GetCurrentZone())
  9230. zone_id = client->GetCurrentZone()->GetZoneID();
  9231. if (client->GetPlayer()->GetTarget()) {
  9232. Spawn* target = client->GetPlayer()->GetTarget();
  9233. if (target->IsWidget())
  9234. type = "widgets";
  9235. else if (target->IsSign())
  9236. type = "signs";
  9237. else if (target->IsObject())
  9238. type = "objects";
  9239. else if (target->IsNPC())
  9240. type = "npcs";
  9241. else if (target->IsGroundSpawn())
  9242. type = "ground";
  9243. else
  9244. type = "spawn";
  9245. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  9246. }
  9247. sprintf(command, url.c_str(), zone_id, type.c_str(), spawn_id);
  9248. packet->setDataByName("accept_command", command);
  9249. }
  9250. else if (rule_manager.GetGlobalRule(R_World, EditorIncludeID)->GetBool()) {
  9251. char command[255];
  9252. url = "browser " + url;
  9253. if (client->GetPlayer()->GetTarget())
  9254. sprintf(command, url.c_str(), client->GetPlayer()->GetTarget()->GetDatabaseID());
  9255. packet->setDataByName("accept_command", command);
  9256. }
  9257. else {
  9258. string command = "browser " + url;
  9259. packet->setDataByName("accept_command", command.c_str());
  9260. }
  9261. packet->setDataByName("text", "Open the web editor?");
  9262. packet->setDataByName("accept_text", "Open");
  9263. packet->setDataByName("cancel_text", "Cancel");
  9264. // No clue if we even need the following 2 unknowns, just added them so the packet matches what live sends
  9265. packet->setDataByName("unknown2", 50);
  9266. packet->setDataByName("unknown4", 1);
  9267. client->QueuePacket(packet->serialize());
  9268. safe_delete(packet);
  9269. }
  9270. }
  9271. void Commands::Command_AcceptResurrection(Client* client, Seperator* sep) {
  9272. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  9273. return;
  9274. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  9275. if(client->GetCurrentRez()->active)
  9276. client->AcceptResurrection();
  9277. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  9278. }
  9279. void Commands::Command_DeclineResurrection(Client* client, Seperator* sep) {
  9280. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  9281. return;
  9282. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  9283. if(client->GetCurrentRez()->active)
  9284. client->GetCurrentRez()->should_delete = true;
  9285. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  9286. }
  9287. void Commands::Switch_AA_Profile(Client* client, Seperator* sep) {
  9288. PrintSep(sep, "Switch_AA_Profile");
  9289. if (sep && sep->IsSet(0)) {
  9290. string type = sep->arg[0];
  9291. int8 newtemplate = atoul(sep->arg[1]);
  9292. master_aa_list.DisplayAA(client, newtemplate, 1);
  9293. }
  9294. }
  9295. void Commands::Get_AA_Xml(Client* client, Seperator* sep) {
  9296. PrintSep(sep, "Get_AA_Xml");
  9297. if (sep && sep->IsSet(0)) {
  9298. string tabnum = sep->arg[0];
  9299. string spellid = sep->arg[1];
  9300. }
  9301. }
  9302. void Commands::Add_AA(Client* client, Seperator* sep) {
  9303. PrintSep(sep, "Add_AA");
  9304. if (sep && sep->IsSet(0)) {
  9305. int32 spell_id = atoul(sep->arg[1]);
  9306. int8 spell_tier = 0;
  9307. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  9308. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  9309. // addspellbookentry here
  9310. if (spell_tier >= data->maxRank) {
  9311. return;
  9312. }
  9313. if (!spell_tier) {
  9314. spell_tier = 1;
  9315. }
  9316. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  9317. {
  9318. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  9319. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  9320. client->GetPlayer()->UnlockSpell(spell);
  9321. client->SendSpellUpdate(spell);
  9322. }
  9323. else
  9324. {
  9325. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1 );
  9326. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  9327. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  9328. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  9329. client->GetPlayer()->UnlockSpell(spell);
  9330. client->SendSpellUpdate(spell);
  9331. }
  9332. // cast spell here
  9333. if (!spell_tier)
  9334. spell_tier = 1;
  9335. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  9336. if (spell) {
  9337. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  9338. }
  9339. }
  9340. else {
  9341. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  9342. }
  9343. master_aa_list.DisplayAA(client, 0, 0);
  9344. }
  9345. void Commands::Commit_AA_Profile(Client* client, Seperator* sep) {
  9346. PrintSep(sep, "Commit_AA_Profile");
  9347. if (sep && sep->IsSet(0)) {
  9348. }
  9349. }
  9350. void Commands::Begin_AA_Profile(Client* client, Seperator* sep) {
  9351. PrintSep(sep, "Begin_AA_Profile");
  9352. if (sep && sep->IsSet(0)) {
  9353. master_aa_list.DisplayAA(client, 100, 2);
  9354. }
  9355. }
  9356. void Commands::Back_AA(Client* client, Seperator* sep) {
  9357. if (sep && sep->IsSet(0)) {
  9358. PrintSep(sep, "Back_AA");
  9359. }
  9360. }
  9361. void Commands::Remove_AA(Client* client, Seperator* sep) {
  9362. if (sep && sep->IsSet(0)) {
  9363. PrintSep(sep, "Remove_AA");
  9364. }
  9365. }
  9366. void Commands::Cancel_AA_Profile(Client* client, Seperator* sep) {
  9367. MasterAAList master_aa_list;
  9368. PrintSep(sep, "Cancel_AA_Profile");
  9369. master_aa_list.DisplayAA(client, 0, 0);
  9370. }
  9371. void Commands::Save_AA_Profile(Client* client, Seperator* sep) {
  9372. if (sep && sep->IsSet(0)) {
  9373. PrintSep(sep, "Save_AA_Profile");
  9374. }
  9375. }
  9376. void Commands::Command_TargetItem(Client* client, Seperator* sep) {
  9377. if (!sep || sep->GetArgNumber() < 1 || !client->GetPlayer()) return;
  9378. if (!sep->IsNumber(0)) return;
  9379. int32 request_id = atoul(sep->arg[0]);
  9380. if (!sep->IsNumber(1)) return;
  9381. sint32 item_id = atoi(sep->arg[1]);
  9382. if (client->IsCurrentTransmuteID(request_id)) {
  9383. Transmute::HandleItemResponse(client, client->GetPlayer(), request_id, reinterpret_cast<int32&>(item_id));
  9384. }
  9385. else if (client->IsCurrentTransmuteID(item_id)) {
  9386. if (!sep->IsSet(2)) return;
  9387. if (sep->IsNumber(2) && atoi(sep->arg[2]) == 1) {
  9388. Transmute::HandleConfirmResponse(client, client->GetPlayer(), reinterpret_cast<int32&>(item_id));
  9389. }
  9390. }
  9391. }
  9392. void Commands::Command_FindSpawn(Client* client, Seperator* sep) {
  9393. client->GetCurrentZone()->FindSpawn(client, (char*)sep->argplus[0]);
  9394. }