Commands.cpp 372 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377
  1. /*
  2. EQ2Emulator: Everquest II Server Emulator
  3. Copyright (C) 2007 EQ2EMulator Development Team (http://www.eq2emulator.net)
  4. This file is part of EQ2Emulator.
  5. EQ2Emulator is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. EQ2Emulator is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with EQ2Emulator. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #include <sys/types.h>
  17. #include "Commands.h"
  18. #include "../ClientPacketFunctions.h"
  19. #include "../../common/version.h"
  20. #include "../../common/seperator.h"
  21. #include "../../common/servertalk.h"
  22. #include "../WorldDatabase.h"
  23. #include "../World.h"
  24. #include "../../common/ConfigReader.h"
  25. #include "../VisualStates.h"
  26. #include "../../common/debug.h"
  27. #include "../LuaInterface.h"
  28. #include "../Quests.h"
  29. #include "../client.h"
  30. #include "../NPC.h"
  31. #include "../Guilds/Guild.h"
  32. #include "../SpellProcess.h"
  33. #include "../Tradeskills/Tradeskills.h"
  34. #include "../../common/Log.h"
  35. #include "../../common/MiscFunctions.h"
  36. #include "../Languages.h"
  37. #include "../IRC/IRC.h"
  38. #include "../Traits/Traits.h"
  39. #include "../Chat/Chat.h"
  40. #include "../Rules/Rules.h"
  41. #include "../AltAdvancement/AltAdvancement.h"
  42. #include "../RaceTypes/RaceTypes.h"
  43. #include "../classes.h"
  44. #include "../Transmute.h"
  45. #include "../Zone/SPGrid.h"
  46. extern WorldDatabase database;
  47. extern MasterSpellList master_spell_list;
  48. extern MasterTraitList master_trait_list;
  49. extern MasterRecipeList master_recipe_list;
  50. extern MasterRecipeBookList master_recipebook_list;
  51. extern World world;
  52. extern ClientList client_list;
  53. extern ConfigReader configReader;
  54. extern VisualStates visual_states;
  55. extern ZoneList zone_list;
  56. extern LuaInterface* lua_interface;
  57. extern MasterQuestList master_quest_list;
  58. extern MasterCollectionList master_collection_list;
  59. extern MasterSkillList master_skill_list;
  60. extern MasterFactionList master_faction_list;
  61. extern GuildList guild_list;
  62. extern MasterLanguagesList master_languages_list;
  63. extern IRC irc;
  64. extern Chat chat;
  65. extern RuleManager rule_manager;
  66. extern MasterAAList master_aa_list;
  67. extern MasterRaceTypeList race_types_list;
  68. extern Classes classes;
  69. //devn00b: Fix for linux builds since we dont use stricmp we use strcasecmp
  70. #if defined(__GNUC__)
  71. #define stricmp strcasecmp
  72. #define strnicmp strncasecmp
  73. #endif
  74. EQ2Packet* RemoteCommands::serialize(){
  75. buffer.clear();
  76. vector<EQ2_RemoteCommandString>::iterator command_list;
  77. buffer.append((char*)&num_commands, sizeof(int16));
  78. for( command_list = commands.begin(); command_list != commands.end(); command_list++ ) {
  79. AddDataCommand(&(*command_list));
  80. }
  81. EQ2Packet* app = new EQ2Packet(OP_SetRemoteCmdsMsg, (uchar*)buffer.c_str(), buffer.length() + 1);
  82. return app;
  83. }
  84. Commands::Commands(){
  85. remote_commands = new RemoteCommands();
  86. spawn_set_values["list"] = SPAWN_SET_VALUE_LIST;
  87. spawn_set_values["name"] = SPAWN_SET_VALUE_NAME;
  88. spawn_set_values["level"] = SPAWN_SET_VALUE_LEVEL; // TODO: Fix this, min_level, max_level
  89. spawn_set_values["difficulty"] = SPAWN_SET_VALUE_DIFFICULTY;
  90. spawn_set_values["model_type"] = SPAWN_SET_VALUE_MODEL_TYPE;
  91. spawn_set_values["class"] = SPAWN_SET_VALUE_CLASS;
  92. spawn_set_values["gender"] = SPAWN_SET_VALUE_GENDER;
  93. spawn_set_values["show_name"] = SPAWN_SET_VALUE_SHOW_NAME;
  94. spawn_set_values["attackable"] = SPAWN_SET_VALUE_ATTACKABLE;
  95. spawn_set_values["show_level"] = SPAWN_SET_VALUE_SHOW_LEVEL;
  96. spawn_set_values["targetable"] = SPAWN_SET_VALUE_TARGETABLE;
  97. spawn_set_values["show_command_icon"] = SPAWN_SET_VALUE_SHOW_COMMAND_ICON;
  98. spawn_set_values["display_hand_icon"] = SPAWN_SET_VALUE_HAND_ICON;
  99. spawn_set_values["hair_type"] = SPAWN_SET_VALUE_HAIR_TYPE;
  100. spawn_set_values["facial_hair_type"] = SPAWN_SET_VALUE_FACIAL_HAIR_TYPE;
  101. spawn_set_values["wing_type"] = SPAWN_SET_VALUE_WING_TYPE;
  102. spawn_set_values["chest_type"] = SPAWN_SET_VALUE_CHEST_TYPE;
  103. spawn_set_values["legs_type"] = SPAWN_SET_VALUE_LEGS_TYPE;
  104. spawn_set_values["soga_hair_type"] = SPAWN_SET_VALUE_SOGA_HAIR_TYPE;
  105. spawn_set_values["soga_facial_hair_type"] = SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE;
  106. spawn_set_values["soga_model_type"] = SPAWN_SET_VALUE_SOGA_MODEL_TYPE;
  107. spawn_set_values["size"] = SPAWN_SET_VALUE_SIZE;
  108. spawn_set_values["hp"] = SPAWN_SET_VALUE_HP;
  109. spawn_set_values["power"] = SPAWN_SET_VALUE_POWER;
  110. spawn_set_values["heroic"] = SPAWN_SET_VALUE_HEROIC;
  111. spawn_set_values["respawn"] = SPAWN_SET_VALUE_RESPAWN;
  112. spawn_set_values["x"] = SPAWN_SET_VALUE_X;
  113. spawn_set_values["y"] = SPAWN_SET_VALUE_Y;
  114. spawn_set_values["z"] = SPAWN_SET_VALUE_Z;
  115. spawn_set_values["heading"] = SPAWN_SET_VALUE_HEADING;
  116. spawn_set_values["location"] = SPAWN_SET_VALUE_LOCATION;
  117. spawn_set_values["command_primary"] = SPAWN_SET_VALUE_COMMAND_PRIMARY;
  118. spawn_set_values["command_secondary"] = SPAWN_SET_VALUE_COMMAND_SECONDARY;
  119. spawn_set_values["visual_state"] = SPAWN_SET_VALUE_VISUAL_STATE;
  120. spawn_set_values["action_state"] = SPAWN_SET_VALUE_ACTION_STATE;
  121. spawn_set_values["mood_state"] = SPAWN_SET_VALUE_MOOD_STATE;
  122. spawn_set_values["initial_state"] = SPAWN_SET_VALUE_INITIAL_STATE;
  123. spawn_set_values["activity_state"] = SPAWN_SET_VALUE_ACTIVITY_STATE;
  124. spawn_set_values["collision_radius"] = SPAWN_SET_VALUE_COLLISION_RADIUS;
  125. spawn_set_values["faction"] = SPAWN_SET_VALUE_FACTION;
  126. spawn_set_values["spawn_script"] = SPAWN_SET_VALUE_SPAWN_SCRIPT;
  127. spawn_set_values["spawnentry_script"] = SPAWN_SET_VALUE_SPAWNENTRY_SCRIPT;
  128. spawn_set_values["spawnlocation_script"] = SPAWN_SET_VALUE_SPAWNLOCATION_SCRIPT;
  129. spawn_set_values["sub_title"] = SPAWN_SET_VALUE_SUB_TITLE;
  130. spawn_set_values["expire"] = SPAWN_SET_VALUE_EXPIRE;
  131. spawn_set_values["expire_offset"] = SPAWN_SET_VALUE_EXPIRE_OFFSET;
  132. spawn_set_values["x_offset"] = SPAWN_SET_VALUE_X_OFFSET;
  133. spawn_set_values["y_offset"] = SPAWN_SET_VALUE_Y_OFFSET;
  134. spawn_set_values["z_offset"] = SPAWN_SET_VALUE_Z_OFFSET;
  135. spawn_set_values["device_id"] = SPAWN_SET_VALUE_DEVICE_ID;
  136. spawn_set_values["pitch"] = SPAWN_SET_VALUE_PITCH;
  137. spawn_set_values["roll"] = SPAWN_SET_VALUE_ROLL;
  138. spawn_set_values["hide_hood"] = SPAWN_SET_VALUE_HIDE_HOOD;
  139. spawn_set_values["emote_state"] = SPAWN_SET_VALUE_EMOTE_STATE;
  140. spawn_set_values["icon"] = SPAWN_SET_VALUE_ICON;
  141. spawn_set_values["prefix"] = SPAWN_SET_VALUE_PREFIX;
  142. spawn_set_values["suffix"] = SPAWN_SET_VALUE_SUFFIX;
  143. spawn_set_values["lastname"] = SPAWN_SET_VALUE_LASTNAME;
  144. spawn_set_values["expansion_flag"] = SPAWN_SET_VALUE_EXPANSION_FLAG;
  145. spawn_set_values["holiday_flag"] = SPAWN_SET_VALUE_HOLIDAY_FLAG;
  146. spawn_set_values["merchant_min_level"] = SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL;
  147. spawn_set_values["merchant_max_level"] = SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL;
  148. spawn_set_values["skin_color"] = SPAWN_SET_SKIN_COLOR;
  149. zone_set_values["expansion_id"] = ZONE_SET_VALUE_EXPANSION_ID;
  150. zone_set_values["name"] = ZONE_SET_VALUE_NAME;
  151. zone_set_values["file"] = ZONE_SET_VALUE_FILE ;
  152. zone_set_values["description"] = ZONE_SET_VALUE_DESCRIPTION;
  153. zone_set_values["safe_x"] = ZONE_SET_VALUE_SAFE_X;
  154. zone_set_values["safe_y"] = ZONE_SET_VALUE_SAFE_Y;
  155. zone_set_values["safe_z"] = ZONE_SET_VALUE_SAFE_Z;
  156. zone_set_values["underworld"] = ZONE_SET_VALUE_UNDERWORLD;
  157. zone_set_values["min_recommended"] = ZONE_SET_VALUE_MIN_RECOMMENDED;
  158. zone_set_values["max_recommended"] = ZONE_SET_VALUE_MAX_RECOMMENDED;
  159. zone_set_values["zone_type"] = ZONE_SET_VALUE_ZONE_TYPE;
  160. zone_set_values["always_loaded"] = ZONE_SET_VALUE_ALWAYS_LOADED;
  161. zone_set_values["city_zone"] = ZONE_SET_VALUE_CITY_ZONE;
  162. zone_set_values["weather_allowed"] = ZONE_SET_VALUE_WEATHER_ALLOWED;
  163. zone_set_values["min_status"] = ZONE_SET_VALUE_MIN_STATUS;
  164. zone_set_values["min_level"] = ZONE_SET_VALUE_MIN_LEVEL;
  165. zone_set_values["start_zone"] = ZONE_SET_VALUE_START_ZONE;
  166. zone_set_values["instance_type"] = ZONE_SET_VALUE_INSTANCE_TYPE;
  167. zone_set_values["default_reenter_time"] = ZONE_SET_VALUE_DEFAULT_REENTER_TIME;
  168. zone_set_values["default_reset_time"] = ZONE_SET_VALUE_DEFAULT_RESET_TIME;
  169. zone_set_values["default_lockout_time"] = ZONE_SET_VALUE_DEFAULT_LOCKOUT_TIME;
  170. zone_set_values["force_group_to_zone"] = ZONE_SET_VALUE_FORCE_GROUP_TO_ZONE;
  171. zone_set_values["lua_script"] = ZONE_SET_VALUE_LUA_SCRIPT;
  172. zone_set_values["shutdown_timer"] = ZONE_SET_VALUE_SHUTDOWN_TIMER;
  173. zone_set_values["zone_motd"] = ZONE_SET_VALUE_ZONE_MOTD;
  174. }
  175. Commands::~Commands() {
  176. safe_delete(remote_commands);
  177. }
  178. int32 Commands::GetSpawnSetType(string val){
  179. if(spawn_set_values.count(val) > 0)
  180. return spawn_set_values[val];
  181. return 0xFFFFFFFF;
  182. }
  183. bool Commands::SetSpawnCommand(Client* client, Spawn* target, int8 type, const char* value, bool send_update, bool temporary, string* temp_value){
  184. if(!target)
  185. return false;
  186. int32 val = 0;
  187. try{
  188. if(type != SPAWN_SET_VALUE_NAME &&
  189. !(type >= SPAWN_SET_VALUE_SPAWN_SCRIPT && type <= SPAWN_SET_VALUE_SUB_TITLE) && !(type >= SPAWN_SET_VALUE_PREFIX && type <= SPAWN_SET_VALUE_EXPANSION_FLAG || type == SPAWN_SET_VALUE_HOLIDAY_FLAG)
  190. && type != SPAWN_SET_SKIN_COLOR)
  191. val = atoul(value);
  192. }
  193. catch(...){
  194. if(client)
  195. client->Message(CHANNEL_COLOR_RED, "Invalid numeric spawn value: %s", value);
  196. return false;
  197. }
  198. if(temporary){
  199. char tmp[128] = {0};
  200. switch(type){
  201. case SPAWN_SET_VALUE_NAME:{
  202. sprintf(tmp, "%s", target->GetName());
  203. target->SetName(value);
  204. client->GetCurrentZone()->SendUpdateTitles(target);
  205. break;
  206. }
  207. case SPAWN_SET_VALUE_X_OFFSET:
  208. {
  209. sprintf(tmp, "%f", target->GetXOffset());
  210. target->SetXOffset(float(val));
  211. break;
  212. }
  213. case SPAWN_SET_VALUE_Y_OFFSET:
  214. {
  215. sprintf(tmp, "%f", target->GetYOffset());
  216. target->SetYOffset(float(val));
  217. break;
  218. }
  219. case SPAWN_SET_VALUE_Z_OFFSET:
  220. {
  221. sprintf(tmp, "%f", target->GetZOffset());
  222. target->SetZOffset(float(val));
  223. break;
  224. }
  225. case SPAWN_SET_VALUE_EXPIRE: {
  226. sprintf(tmp, "%u", target->GetExpireTime());
  227. target->SetExpireTime(val);
  228. break;
  229. }
  230. case SPAWN_SET_VALUE_EXPIRE_OFFSET: {
  231. sprintf(tmp, "%u", target->GetExpireOffsetTime());
  232. target->SetExpireOffsetTime(val);
  233. break;
  234. }
  235. case SPAWN_SET_VALUE_SUB_TITLE: {
  236. sprintf(tmp, "%s", target->GetSubTitle());
  237. target->SetSubTitle(value);
  238. client->GetCurrentZone()->SendUpdateTitles(target);
  239. break;
  240. }
  241. case SPAWN_SET_VALUE_LEVEL:{
  242. sprintf(tmp, "%i", target->GetLevel());
  243. target->SetLevel(val, send_update);
  244. break;
  245. }
  246. case SPAWN_SET_VALUE_DIFFICULTY:{
  247. sprintf(tmp, "%i", target->GetEncounterLevel());
  248. target->SetEncounterLevel(val, send_update);
  249. break;
  250. }
  251. case SPAWN_SET_VALUE_MODEL_TYPE:{
  252. sprintf(tmp, "%i", target->GetModelType());
  253. target->SetModelType(val, send_update);
  254. break;
  255. }
  256. case SPAWN_SET_VALUE_CLASS:{
  257. sprintf(tmp, "%i", target->GetAdventureClass());
  258. target->SetAdventureClass(val, send_update);
  259. break;
  260. }
  261. case SPAWN_SET_VALUE_GENDER:{
  262. sprintf(tmp, "%i", target->GetGender());
  263. target->SetGender(val, send_update);
  264. break;
  265. }
  266. case SPAWN_SET_VALUE_SHOW_NAME:{
  267. sprintf(tmp, "%i", target->GetShowName());
  268. target->SetShowName(val, send_update);
  269. break;
  270. }
  271. case SPAWN_SET_VALUE_ATTACKABLE:{
  272. sprintf(tmp, "%i", target->GetAttackable());
  273. target->SetAttackable(val, send_update);
  274. break;
  275. }
  276. case SPAWN_SET_VALUE_SHOW_LEVEL:{
  277. sprintf(tmp, "%i", target->GetShowLevel());
  278. target->SetShowLevel(val, send_update);
  279. break;
  280. }
  281. case SPAWN_SET_VALUE_TARGETABLE:{
  282. sprintf(tmp, "%i", target->GetTargetable());
  283. target->SetTargetable(val, send_update);
  284. break;
  285. }
  286. case SPAWN_SET_VALUE_SHOW_COMMAND_ICON:{
  287. sprintf(tmp, "%i", target->GetShowCommandIcon());
  288. target->SetShowCommandIcon(val, send_update);
  289. break;
  290. }
  291. case SPAWN_SET_VALUE_HAND_ICON:{
  292. sprintf(tmp, "%i", target->GetShowHandIcon());
  293. target->SetShowHandIcon(val, send_update);
  294. break;
  295. }
  296. case SPAWN_SET_VALUE_HAIR_TYPE:{
  297. if(target->IsEntity()){
  298. sprintf(tmp, "%i", ((Entity*)target)->GetHairType());
  299. ((Entity*)target)->SetHairType(val, send_update);
  300. }
  301. break;
  302. }
  303. case SPAWN_SET_VALUE_FACIAL_HAIR_TYPE:{
  304. if(target->IsEntity()){
  305. sprintf(tmp, "%i", ((Entity*)target)->GetHairType());
  306. ((Entity*)target)->SetHairType(val, send_update);
  307. }
  308. break;
  309. }
  310. case SPAWN_SET_VALUE_WING_TYPE:{
  311. if(target->IsEntity()){
  312. sprintf(tmp, "%i", ((Entity*)target)->GetWingType());
  313. ((Entity*)target)->SetWingType(val, send_update);
  314. }
  315. break;
  316. }
  317. case SPAWN_SET_VALUE_CHEST_TYPE:{
  318. if(target->IsEntity()){
  319. sprintf(tmp, "%i", ((Entity*)target)->GetChestType());
  320. ((Entity*)target)->SetChestType(val, send_update);
  321. }
  322. break;
  323. }
  324. case SPAWN_SET_VALUE_LEGS_TYPE:{
  325. if(target->IsEntity()){
  326. sprintf(tmp, "%i", ((Entity*)target)->GetLegsType());
  327. ((Entity*)target)->SetLegsType(val, send_update);
  328. }
  329. break;
  330. }
  331. case SPAWN_SET_VALUE_SOGA_HAIR_TYPE:{
  332. if(target->IsEntity()){
  333. sprintf(tmp, "%i", ((Entity*)target)->GetSogaHairType());
  334. ((Entity*)target)->SetSogaHairType(val, send_update);
  335. }
  336. break;
  337. }
  338. case SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE:{
  339. if(target->IsEntity()){
  340. sprintf(tmp, "%i", ((Entity*)target)->GetSogaFacialHairType());
  341. ((Entity*)target)->SetSogaFacialHairType(val, send_update);
  342. }
  343. break;
  344. }
  345. case SPAWN_SET_VALUE_SOGA_MODEL_TYPE:{
  346. sprintf(tmp, "%i", target->GetSogaModelType());
  347. target->SetSogaModelType(val, send_update);
  348. break;
  349. }
  350. case SPAWN_SET_VALUE_SIZE:{
  351. sprintf(tmp, "%i", target->GetSize());
  352. target->SetSize(val, send_update);
  353. break;
  354. }
  355. case SPAWN_SET_VALUE_HP:{
  356. sprintf(tmp, "%i", target->GetHP());
  357. target->SetHP(val, send_update);
  358. break;
  359. }
  360. case SPAWN_SET_VALUE_POWER:{
  361. sprintf(tmp, "%i", target->GetPower());
  362. target->SetPower(val, send_update);
  363. break;
  364. }
  365. case SPAWN_SET_VALUE_HEROIC:{
  366. sprintf(tmp, "%i", target->GetHeroic());
  367. target->SetHeroic(val, send_update);
  368. break;
  369. }
  370. case SPAWN_SET_VALUE_RESPAWN:{
  371. sprintf(tmp, "%u", target->GetRespawnTime());
  372. target->SetRespawnTime(val);
  373. break;
  374. }
  375. case SPAWN_SET_VALUE_X:{
  376. sprintf(tmp, "%f", target->GetX());
  377. target->SetX(atof(value), send_update);
  378. break;
  379. }
  380. case SPAWN_SET_VALUE_Y:{
  381. sprintf(tmp, "%f", target->GetY());
  382. target->SetY(atof(value), send_update);
  383. break;
  384. }
  385. case SPAWN_SET_VALUE_Z:{
  386. sprintf(tmp, "%f", target->GetZ());
  387. target->SetZ(atof(value), send_update);
  388. break;
  389. }
  390. case SPAWN_SET_VALUE_HEADING:{
  391. sprintf(tmp, "%f", target->GetHeading());
  392. target->SetHeading(atof(value) + 360, send_update);
  393. break;
  394. }
  395. case SPAWN_SET_VALUE_VISUAL_STATE:{
  396. sprintf(tmp, "%i", target->GetVisualState());
  397. target->SetVisualState(val, send_update);
  398. break;
  399. }
  400. case SPAWN_SET_VALUE_ACTION_STATE:{
  401. sprintf(tmp, "%i", target->GetActionState());
  402. target->SetActionState(val, send_update);
  403. break;
  404. }
  405. case SPAWN_SET_VALUE_MOOD_STATE:{
  406. sprintf(tmp, "%i", target->GetMoodState());
  407. target->SetMoodState(val, send_update);
  408. break;
  409. }
  410. case SPAWN_SET_VALUE_INITIAL_STATE:{
  411. sprintf(tmp, "%i", target->GetInitialState());
  412. target->SetInitialState(val, send_update);
  413. break;
  414. }
  415. case SPAWN_SET_VALUE_ACTIVITY_STATE:{
  416. sprintf(tmp, "%i", target->GetActivityStatus());
  417. target->SetActivityStatus(val, send_update);
  418. break;
  419. }
  420. case SPAWN_SET_VALUE_COLLISION_RADIUS:{
  421. sprintf(tmp, "%i", target->GetCollisionRadius());
  422. target->SetCollisionRadius(val, send_update);
  423. break;
  424. }
  425. case SPAWN_SET_VALUE_DEVICE_ID: {
  426. if (target->IsObject()) {
  427. sprintf(tmp, "%i", ((Object*)target)->GetDeviceID());
  428. ((Object*)target)->SetDeviceID(val);
  429. }
  430. break;
  431. }
  432. case SPAWN_SET_VALUE_PITCH: {
  433. sprintf(tmp, "%f", target->GetPitch());
  434. target->SetPitch(atof(value), send_update);
  435. break;
  436. }
  437. case SPAWN_SET_VALUE_ROLL: {
  438. sprintf(tmp, "%f", target->GetRoll());
  439. target->SetRoll(atof(value), send_update);
  440. break;
  441. }
  442. case SPAWN_SET_VALUE_HIDE_HOOD: {
  443. sprintf(tmp, "%i", target->appearance.hide_hood);
  444. target->SetHideHood(val);
  445. break;
  446. }
  447. case SPAWN_SET_VALUE_EMOTE_STATE: {
  448. sprintf(tmp, "%i", target->appearance.emote_state);
  449. target->SetEmoteState(val);
  450. break;
  451. }
  452. case SPAWN_SET_VALUE_ICON: {
  453. sprintf(tmp, "%i", target->GetIconValue());
  454. target->SetIcon(val);
  455. break;
  456. }
  457. case SPAWN_SET_VALUE_PREFIX: {
  458. sprintf(tmp, "%s", target->GetPrefixTitle());
  459. target->SetPrefixTitle(value);
  460. client->GetCurrentZone()->SendUpdateTitles(target);
  461. break;
  462. }
  463. case SPAWN_SET_VALUE_SUFFIX: {
  464. sprintf(tmp, "%s", target->GetSuffixTitle());
  465. target->SetSuffixTitle(value);
  466. client->GetCurrentZone()->SendUpdateTitles(target);
  467. break;
  468. }
  469. case SPAWN_SET_VALUE_LASTNAME: {
  470. sprintf(tmp, "%s", target->GetLastName());
  471. target->SetLastName(value);
  472. client->GetCurrentZone()->SendUpdateTitles(target);
  473. break;
  474. }
  475. case SPAWN_SET_VALUE_EXPANSION_FLAG:
  476. case SPAWN_SET_VALUE_HOLIDAY_FLAG: {
  477. // nothing to do must reload spawns
  478. break;
  479. }
  480. case SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL: {
  481. sprintf(tmp, "%i", target->GetMerchantMinLevel());
  482. target->SetMerchantLevelRange(atoul(value), target->GetMerchantMaxLevel());
  483. break;
  484. }
  485. case SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL: {
  486. sprintf(tmp, "%i", target->GetMerchantMaxLevel());
  487. target->SetMerchantLevelRange(target->GetMerchantMinLevel(), atoul(value));
  488. break;
  489. }
  490. case SPAWN_SET_SKIN_COLOR: {
  491. if (target->IsNPC())
  492. {
  493. Seperator* skinsep = new Seperator(value, ' ', 3, 500, true);
  494. if (skinsep->IsNumber(0) && skinsep->IsNumber(1) && skinsep->IsNumber(2))
  495. {
  496. EQ2_Color clr;
  497. clr.red = atoul(skinsep->arg[0]);
  498. clr.green = atoul(skinsep->arg[1]);
  499. clr.blue = atoul(skinsep->arg[2]);
  500. ((Entity*)target)->SetSkinColor(clr);
  501. }
  502. safe_delete(skinsep);
  503. }
  504. break;
  505. }
  506. if(temp_value)
  507. *temp_value = string(tmp);
  508. }
  509. }
  510. else{
  511. switch(type){
  512. case SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL: {
  513. target->SetMerchantLevelRange(atoul(value), target->GetMerchantMaxLevel());
  514. break;
  515. }
  516. case SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL: {
  517. target->SetMerchantLevelRange(target->GetMerchantMinLevel(), atoul(value));
  518. break;
  519. }
  520. case SPAWN_SET_VALUE_EXPANSION_FLAG: {
  521. if (target->GetDatabaseID() > 0)
  522. {
  523. char query[256];
  524. snprintf(query, 256, "update spawn set expansion_flag=%i where id=%i", atoul(value), target->GetDatabaseID());
  525. if (database.RunQuery(query, strnlen(query, 256)))
  526. {
  527. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  528. }
  529. }
  530. break;
  531. }
  532. case SPAWN_SET_VALUE_HOLIDAY_FLAG: {
  533. if (target->GetDatabaseID() > 0)
  534. {
  535. char query[256];
  536. snprintf(query, 256, "update spawn set holiday_flag=%i where id=%i", atoul(value), target->GetDatabaseID());
  537. if (database.RunQuery(query, strnlen(query, 256)))
  538. {
  539. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  540. }
  541. }
  542. break;
  543. }
  544. case SPAWN_SET_VALUE_NAME:{
  545. target->SetName(value);
  546. client->GetCurrentZone()->SendUpdateTitles(target);
  547. break;
  548. }
  549. case SPAWN_SET_VALUE_SUB_TITLE: {
  550. target->SetSubTitle(value);
  551. client->GetCurrentZone()->SendUpdateTitles(target);
  552. break;
  553. }
  554. case SPAWN_SET_VALUE_X_OFFSET:
  555. {
  556. target->SetXOffset(atof(value));
  557. break;
  558. }
  559. case SPAWN_SET_VALUE_Y_OFFSET:
  560. {
  561. target->SetYOffset(atof(value));
  562. break;
  563. }
  564. case SPAWN_SET_VALUE_Z_OFFSET:
  565. {
  566. target->SetZOffset(atof(value));
  567. break;
  568. }
  569. case SPAWN_SET_VALUE_EXPIRE: {
  570. target->SetExpireTime(val);
  571. break;
  572. }
  573. case SPAWN_SET_VALUE_EXPIRE_OFFSET: {
  574. target->SetExpireOffsetTime(val);
  575. break;
  576. }
  577. case SPAWN_SET_VALUE_LEVEL:{
  578. target->SetLevel(val, send_update);
  579. break;
  580. }
  581. case SPAWN_SET_VALUE_DIFFICULTY:{
  582. target->SetEncounterLevel(val, send_update);
  583. break;
  584. }
  585. case SPAWN_SET_VALUE_MODEL_TYPE:{
  586. target->SetModelType(val, send_update);
  587. break;
  588. }
  589. case SPAWN_SET_VALUE_CLASS:{
  590. target->SetAdventureClass(val, send_update);
  591. break;
  592. }
  593. case SPAWN_SET_VALUE_GENDER:{
  594. target->SetGender(val, send_update);
  595. break;
  596. }
  597. case SPAWN_SET_VALUE_SHOW_NAME:{
  598. target->SetShowName(val, send_update);
  599. break;
  600. }
  601. case SPAWN_SET_VALUE_ATTACKABLE:{
  602. target->SetAttackable(val, send_update);
  603. break;
  604. }
  605. case SPAWN_SET_VALUE_SHOW_LEVEL:{
  606. target->SetShowLevel(val, send_update);
  607. break;
  608. }
  609. case SPAWN_SET_VALUE_TARGETABLE:{
  610. target->SetTargetable(val, send_update);
  611. break;
  612. }
  613. case SPAWN_SET_VALUE_SHOW_COMMAND_ICON:{
  614. target->SetShowCommandIcon(val, send_update);
  615. break;
  616. }
  617. case SPAWN_SET_VALUE_HAND_ICON:{
  618. target->SetShowHandIcon(val, send_update);
  619. break;
  620. }
  621. case SPAWN_SET_VALUE_HAIR_TYPE:{
  622. if(target->IsEntity())
  623. ((Entity*)target)->SetHairType(val, send_update);
  624. break;
  625. }
  626. case SPAWN_SET_VALUE_FACIAL_HAIR_TYPE:{
  627. if(target->IsEntity())
  628. ((Entity*)target)->SetHairType(val, send_update);
  629. break;
  630. }
  631. case SPAWN_SET_VALUE_WING_TYPE:{
  632. if(target->IsEntity())
  633. ((Entity*)target)->SetWingType(val, send_update);
  634. break;
  635. }
  636. case SPAWN_SET_VALUE_CHEST_TYPE:{
  637. if(target->IsEntity())
  638. ((Entity*)target)->SetChestType(val, send_update);
  639. break;
  640. }
  641. case SPAWN_SET_VALUE_LEGS_TYPE:{
  642. if(target->IsEntity())
  643. ((Entity*)target)->SetLegsType(val, send_update);
  644. break;
  645. }
  646. case SPAWN_SET_VALUE_SOGA_HAIR_TYPE:{
  647. if(target->IsEntity())
  648. ((Entity*)target)->SetSogaHairType(val, send_update);
  649. break;
  650. }
  651. case SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE:{
  652. if(target->IsEntity())
  653. ((Entity*)target)->SetSogaFacialHairType(val, send_update);
  654. break;
  655. }
  656. case SPAWN_SET_VALUE_SOGA_MODEL_TYPE:{
  657. target->SetSogaModelType(val, send_update);
  658. break;
  659. }
  660. case SPAWN_SET_VALUE_SIZE:{
  661. target->SetSize(val, send_update);
  662. break;
  663. }
  664. case SPAWN_SET_VALUE_HP:{
  665. target->SetHP(val, send_update);
  666. break;
  667. }
  668. case SPAWN_SET_VALUE_POWER:{
  669. target->SetPower(val, send_update);
  670. break;
  671. }
  672. case SPAWN_SET_VALUE_HEROIC:{
  673. target->SetHeroic(val, send_update);
  674. break;
  675. }
  676. case SPAWN_SET_VALUE_RESPAWN:{
  677. target->SetRespawnTime(val);
  678. break;
  679. }
  680. case SPAWN_SET_VALUE_X:{
  681. target->SetX(atof(value), send_update);
  682. target->SetSpawnOrigX(target->GetX());
  683. break;
  684. }
  685. case SPAWN_SET_VALUE_Y:{
  686. target->SetY(atof(value), send_update);
  687. target->SetSpawnOrigY(target->GetY());
  688. break;
  689. }
  690. case SPAWN_SET_VALUE_Z:{
  691. target->SetZ(atof(value), send_update);
  692. target->SetSpawnOrigZ(target->GetZ());
  693. break;
  694. }
  695. case SPAWN_SET_VALUE_HEADING:{
  696. target->SetHeading(atof(value), send_update);
  697. target->SetSpawnOrigHeading(target->GetHeading());
  698. break;
  699. }
  700. case SPAWN_SET_VALUE_COMMAND_PRIMARY:{
  701. ZoneServer* zone = target->GetZone();
  702. if (!zone)
  703. zone = client->GetCurrentZone();
  704. if(zone->GetEntityCommandList(val))
  705. target->SetPrimaryCommands(zone->GetEntityCommandList(val));
  706. target->primary_command_list_id = val;
  707. break;
  708. }
  709. case SPAWN_SET_VALUE_COMMAND_SECONDARY:{
  710. ZoneServer* zone = target->GetZone();
  711. if (!zone)
  712. zone = client->GetCurrentZone();
  713. if (zone->GetEntityCommandList(val))
  714. target->SetSecondaryCommands(zone->GetEntityCommandList(val));
  715. target->secondary_command_list_id = val;
  716. break;
  717. }
  718. case SPAWN_SET_VALUE_VISUAL_STATE:{
  719. target->SetVisualState(val, send_update);
  720. break;
  721. }
  722. case SPAWN_SET_VALUE_ACTION_STATE:{
  723. target->SetActionState(val, send_update);
  724. break;
  725. }
  726. case SPAWN_SET_VALUE_MOOD_STATE:{
  727. target->SetMoodState(val, send_update);
  728. break;
  729. }
  730. case SPAWN_SET_VALUE_INITIAL_STATE:{
  731. target->SetInitialState(val, send_update);
  732. break;
  733. }
  734. case SPAWN_SET_VALUE_ACTIVITY_STATE:{
  735. target->SetActivityStatus(val, send_update);
  736. break;
  737. }
  738. case SPAWN_SET_VALUE_COLLISION_RADIUS:{
  739. target->SetCollisionRadius(val, send_update);
  740. break;
  741. }
  742. case SPAWN_SET_VALUE_FACTION:{
  743. ZoneServer* zone = target->GetZone();
  744. if (!zone)
  745. zone = client->GetCurrentZone();
  746. target->faction_id = val;
  747. zone->RemoveDeadEnemyList(target);
  748. if(target->IsNPC())
  749. zone->AddEnemyList((NPC*)target);
  750. break;
  751. }
  752. case SPAWN_SET_VALUE_DEVICE_ID:{
  753. if (target->IsObject())
  754. ((Object*)target)->SetDeviceID(val);
  755. break;
  756. }
  757. case SPAWN_SET_VALUE_PITCH: {
  758. target->SetPitch(atof(value), send_update);
  759. target->SetSpawnOrigPitch(atof(value));
  760. break;
  761. }
  762. case SPAWN_SET_VALUE_ROLL: {
  763. target->SetRoll(atof(value), send_update);
  764. target->SetSpawnOrigRoll(atof(value));
  765. break;
  766. }
  767. case SPAWN_SET_VALUE_HIDE_HOOD: {
  768. target->SetHideHood(val);
  769. break;
  770. }
  771. case SPAWN_SET_VALUE_EMOTE_STATE: {
  772. target->SetEmoteState(val);
  773. break;
  774. }
  775. case SPAWN_SET_VALUE_ICON: {
  776. target->SetIcon(val);
  777. break;
  778. }
  779. case SPAWN_SET_VALUE_PREFIX: {
  780. target->SetPrefixTitle(value);
  781. client->GetCurrentZone()->SendUpdateTitles(target);
  782. break;
  783. }
  784. case SPAWN_SET_VALUE_SUFFIX: {
  785. target->SetSuffixTitle(value);
  786. client->GetCurrentZone()->SendUpdateTitles(target);
  787. break;
  788. }
  789. case SPAWN_SET_VALUE_LASTNAME: {
  790. target->SetLastName(value);
  791. client->GetCurrentZone()->SendUpdateTitles(target);
  792. break;
  793. }
  794. case SPAWN_SET_VALUE_SPAWN_SCRIPT:{
  795. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  796. if(client){
  797. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  798. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawn_script 'SpawnScripts/example.lua'");
  799. }
  800. return false;
  801. }
  802. else if(!database.UpdateSpawnScriptData(target->GetDatabaseID(), 0, 0, value))
  803. return false;
  804. else{
  805. if(!world.GetSpawnLocationScript(target->GetSpawnLocationID()))
  806. target->SetSpawnScript(value);
  807. }
  808. break;
  809. }
  810. case SPAWN_SET_VALUE_SPAWNLOCATION_SCRIPT:{
  811. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  812. if(client){
  813. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  814. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawnlocation_script 'SpawnScripts/example.lua'");
  815. }
  816. return false;
  817. }
  818. else if(!database.UpdateSpawnScriptData(0, target->GetSpawnLocationID(), 0, value))
  819. return false;
  820. else{
  821. if(!world.GetSpawnEntryScript(target->GetSpawnEntryID()))
  822. target->SetSpawnScript(value);
  823. }
  824. break;
  825. }
  826. case SPAWN_SET_VALUE_SPAWNENTRY_SCRIPT:{
  827. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  828. if(client){
  829. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  830. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawnentry_script 'SpawnScripts/example.lua'");
  831. }
  832. return false;
  833. }
  834. else if(!database.UpdateSpawnScriptData(0, 0, target->GetSpawnEntryID(), value))
  835. return false;
  836. else
  837. target->SetSpawnScript(value);
  838. break;
  839. }
  840. case SPAWN_SET_SKIN_COLOR: {
  841. if (target->IsNPC())
  842. {
  843. Seperator* skinsep = new Seperator(value, ' ', 3, 500, true);
  844. if (skinsep->IsNumber(0) && skinsep->IsNumber(1) && skinsep->IsNumber(2))
  845. {
  846. EQ2_Color clr;
  847. clr.red = atoul(skinsep->arg[0]);
  848. clr.green = atoul(skinsep->arg[1]);
  849. clr.blue = atoul(skinsep->arg[2]);
  850. ((Entity*)target)->SetSkinColor(clr);
  851. Query replaceSkinQuery;
  852. replaceSkinQuery.AddQueryAsync(0, &database, Q_DELETE, "delete from npc_appearance where spawn_id=%u and type='skin_color'", target->GetDatabaseID());
  853. replaceSkinQuery.AddQueryAsync(0, &database, Q_INSERT, "insert into npc_appearance set spawn_id=%u, type='skin_color', red=%u, green=%u, blue=%u", target->GetDatabaseID(), clr.red, clr.green, clr.blue);
  854. }
  855. safe_delete(skinsep);
  856. }
  857. break;
  858. }
  859. }
  860. }
  861. return true;
  862. }
  863. /* The zone object will be NULL if the zone is not currently running. We pass both of these in so we can update
  864. the database fields always and also update the zone in memory if it's running. */
  865. bool Commands::SetZoneCommand(Client* client, int32 zone_id, ZoneServer* zone, int8 type, const char* value) {
  866. if (client && zone_id > 0 && type > 0 && value) {
  867. sint32 int_value = 0;
  868. float float_value = 0;
  869. if (type == ZONE_SET_VALUE_SAFE_X || type == ZONE_SET_VALUE_SAFE_Y || type == ZONE_SET_VALUE_SAFE_Z || type == ZONE_SET_VALUE_UNDERWORLD) {
  870. try {
  871. float_value = atof(value);
  872. }
  873. catch (...) {
  874. client->Message(CHANNEL_COLOR_RED, "Error converting '%s' to a float value", value);
  875. return false;
  876. }
  877. }
  878. else if (type != ZONE_SET_VALUE_NAME && type != ZONE_SET_VALUE_FILE && type != ZONE_SET_VALUE_DESCRIPTION && type != ZONE_SET_VALUE_ZONE_TYPE && type != ZONE_SET_VALUE_LUA_SCRIPT && type != ZONE_SET_VALUE_ZONE_MOTD) {
  879. try {
  880. int_value = atoi(value);
  881. }
  882. catch (...) {
  883. client->Message(CHANNEL_COLOR_RED, "Error converting '%s' to an integer value", value);
  884. return false;
  885. }
  886. }
  887. switch (type) {
  888. case ZONE_SET_VALUE_EXPANSION_ID: {
  889. break;
  890. }
  891. case ZONE_SET_VALUE_NAME: {
  892. if (zone)
  893. zone->SetZoneName(const_cast<char*>(value));
  894. database.SaveZoneInfo(zone_id, "name", value);
  895. break;
  896. }
  897. case ZONE_SET_VALUE_FILE: {
  898. if (zone)
  899. zone->SetZoneFile(const_cast<char*>(value));
  900. database.SaveZoneInfo(zone_id, "file", value);
  901. break;
  902. }
  903. case ZONE_SET_VALUE_DESCRIPTION: {
  904. if (zone)
  905. zone->SetZoneDescription(const_cast<char*>(value));
  906. database.SaveZoneInfo(zone_id, "description", value);
  907. break;
  908. }
  909. case ZONE_SET_VALUE_SAFE_X: {
  910. if (zone)
  911. zone->SetSafeX(float_value);
  912. database.SaveZoneInfo(zone_id, "safe_x", float_value);
  913. break;
  914. }
  915. case ZONE_SET_VALUE_SAFE_Y: {
  916. if (zone)
  917. zone->SetSafeY(float_value);
  918. database.SaveZoneInfo(zone_id, "safe_y", float_value);
  919. break;
  920. }
  921. case ZONE_SET_VALUE_SAFE_Z: {
  922. if (zone)
  923. zone->SetSafeZ(float_value);
  924. database.SaveZoneInfo(zone_id, "safe_z", float_value);
  925. break;
  926. }
  927. case ZONE_SET_VALUE_UNDERWORLD: {
  928. if (zone)
  929. zone->SetUnderWorld(float_value);
  930. database.SaveZoneInfo(zone_id, "underworld", float_value);
  931. break;
  932. }
  933. case ZONE_SET_VALUE_MIN_RECOMMENDED: {
  934. break;
  935. }
  936. case ZONE_SET_VALUE_MAX_RECOMMENDED: {
  937. break;
  938. }
  939. case ZONE_SET_VALUE_ZONE_TYPE: {
  940. break;
  941. }
  942. case ZONE_SET_VALUE_ALWAYS_LOADED: {
  943. if (zone)
  944. zone->SetAlwaysLoaded(int_value == 1);
  945. database.SaveZoneInfo(zone_id, "always_loaded", int_value);
  946. break;
  947. }
  948. case ZONE_SET_VALUE_CITY_ZONE: {
  949. if (zone)
  950. zone->SetCityZone(int_value == 1);
  951. database.SaveZoneInfo(zone_id, "city_zone", int_value);
  952. break;
  953. }
  954. case ZONE_SET_VALUE_WEATHER_ALLOWED: {
  955. if (zone)
  956. zone->SetWeatherAllowed(int_value == 1);
  957. database.SaveZoneInfo(zone_id, "weather_allowed", int_value);
  958. break;
  959. }
  960. case ZONE_SET_VALUE_MIN_STATUS: {
  961. if (zone)
  962. zone->SetMinimumStatus(int_value);
  963. database.SaveZoneInfo(zone_id, "min_status", int_value);
  964. break;
  965. }
  966. case ZONE_SET_VALUE_MIN_LEVEL: {
  967. if (zone)
  968. zone->SetMinimumLevel(int_value);
  969. database.SaveZoneInfo(zone_id, "min_level", int_value);
  970. break;
  971. }
  972. case ZONE_SET_VALUE_MAX_LEVEL: {
  973. if (zone)
  974. zone->SetMaximumLevel(int_value);
  975. database.SaveZoneInfo(zone_id, "max_level", int_value);
  976. break;
  977. }
  978. case ZONE_SET_VALUE_START_ZONE: {
  979. database.SaveZoneInfo(zone_id, "start_zone", int_value);
  980. break;
  981. }
  982. case ZONE_SET_VALUE_INSTANCE_TYPE: {
  983. if (zone)
  984. zone->SetInstanceType(int_value);
  985. database.SaveZoneInfo(zone_id, "instance_type", int_value);
  986. break;
  987. }
  988. case ZONE_SET_VALUE_DEFAULT_REENTER_TIME: {
  989. if (zone)
  990. zone->SetDefaultReenterTime(int_value);
  991. database.SaveZoneInfo(zone_id, "default_reenter_time", int_value);
  992. break;
  993. }
  994. case ZONE_SET_VALUE_DEFAULT_RESET_TIME: {
  995. if (zone)
  996. zone->SetDefaultResetTime(int_value);
  997. database.SaveZoneInfo(zone_id, "default_reset_time", int_value);
  998. break;
  999. }
  1000. case ZONE_SET_VALUE_DEFAULT_LOCKOUT_TIME: {
  1001. if (zone)
  1002. zone->SetDefaultLockoutTime(int_value);
  1003. database.SaveZoneInfo(zone_id, "default_lockout_time", int_value);
  1004. break;
  1005. }
  1006. case ZONE_SET_VALUE_FORCE_GROUP_TO_ZONE: {
  1007. if (zone)
  1008. zone->SetForceGroupZoneOption(int_value);
  1009. database.SaveZoneInfo(zone_id, "force_group_to_zone", int_value);
  1010. break;
  1011. }
  1012. case ZONE_SET_VALUE_LUA_SCRIPT: {
  1013. if (lua_interface && lua_interface->GetZoneScript(value) == 0) {
  1014. client->Message(CHANNEL_COLOR_RED, "Invalid Zone Script file. Be sure you give the absolute path.");
  1015. client->Message(CHANNEL_COLOR_RED, "Example: /zone set lua_script 'ZoneScripts/QueensColony.lua'");
  1016. return false;
  1017. }
  1018. else {
  1019. world.AddZoneScript(zone_id, const_cast<char*>(value));
  1020. database.SaveZoneInfo(zone_id, "lua_script", value);
  1021. }
  1022. break;
  1023. }
  1024. case ZONE_SET_VALUE_SHUTDOWN_TIMER: {
  1025. if (zone)
  1026. zone->SetShutdownTimer(int_value);
  1027. database.SaveZoneInfo(zone_id, "shutdown_timer", int_value);
  1028. break;
  1029. }
  1030. case ZONE_SET_VALUE_ZONE_MOTD: {
  1031. if (zone)
  1032. zone->SetZoneMOTD(string(value));
  1033. database.SaveZoneInfo(zone_id, "zone_motd", value);
  1034. break;
  1035. }
  1036. default: {
  1037. client->Message(CHANNEL_COLOR_RED, "Invalid zone attribute %i", type);
  1038. return false;
  1039. }
  1040. }
  1041. }
  1042. else {
  1043. if (client)
  1044. client->SimpleMessage(CHANNEL_COLOR_RED, "An error occured saving new zone data.");
  1045. return false;
  1046. }
  1047. return true;
  1048. }
  1049. void Commands::Process(int32 index, EQ2_16BitString* command_parms, Client* client, Spawn* targetOverride) {
  1050. if (index >= remote_commands->commands.size()) {
  1051. LogWrite(COMMAND__ERROR, 0, "Command", "Error, command handler of %u was requested, but max handler is %u", index, remote_commands->commands.size());
  1052. return;
  1053. }
  1054. Spawn* cmdTarget = targetOverride ? targetOverride : client->GetPlayer()->GetTarget();
  1055. EQ2_RemoteCommandString* parent_command = 0;
  1056. EQ2_RemoteCommandString* command = &remote_commands->commands[index];
  1057. Seperator* sep = 0;
  1058. if (command_parms->size > 0) {
  1059. sep = new Seperator(command_parms->data.c_str(), ' ', 10, 500, true);
  1060. if (sep && sep->arg[0] && remote_commands->validSubCommand(command->command.data, string(sep->arg[0]))) {
  1061. parent_command = command;
  1062. command = &(remote_commands->subcommands[command->command.data][string(sep->arg[0])]);
  1063. safe_delete(sep);
  1064. if (command_parms->data.length() > (command->command.data.length() + 1))
  1065. sep = new Seperator(command_parms->data.c_str() + (command->command.data.length() + 1), ' ', 10, 500, true);
  1066. LogWrite(COMMAND__DEBUG, 1, "Command", "Handler: %u, COMMAND: '%s', SUBCOMMAND: '%s'", index, parent_command->command.data.c_str(), command->command.data.c_str());
  1067. }
  1068. else
  1069. LogWrite(COMMAND__DEBUG, 1, "Command", "Handler: %u, COMMAND: '%s'", index, command->command.data.c_str());
  1070. }
  1071. int ndx = 0;
  1072. if (command->required_status > client->GetAdminStatus())
  1073. {
  1074. LogWrite(COMMAND__ERROR, 0, "Command", "Player '%s' (%u) needs status %i to use command: %s", client->GetPlayer()->GetName(), client->GetAccountID(), command->required_status, command->command.data.c_str());
  1075. safe_delete(sep);
  1076. client->SimpleMessage(3, "Error: Your status is insufficient for this command.");
  1077. return;
  1078. }
  1079. Player* player = client->GetPlayer();
  1080. LogWrite(COMMAND__DEBUG, 0, "Command", "Player '%s' (%u), Command: %s", player->GetName(), client->GetAccountID(), command->command.data.c_str());
  1081. switch (command->handler) {
  1082. case COMMAND_RELOAD: {
  1083. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reload commands:");
  1084. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload structs");
  1085. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload items");
  1086. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload luasystem");
  1087. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spawnscripts");
  1088. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spells");
  1089. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload quests");
  1090. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spawns");
  1091. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload groundspawns");
  1092. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload zonescripts");
  1093. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload entity_commands");
  1094. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload factions");
  1095. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload mail");
  1096. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload guilds");
  1097. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload locations");
  1098. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload rules");
  1099. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload transporters");
  1100. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload startabilities");
  1101. break;
  1102. }
  1103. case COMMAND_RELOADSTRUCTS: {
  1104. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Structs...");
  1105. world.SetReloadingSubsystem("Structs");
  1106. configReader.ReloadStructs();
  1107. world.RemoveReloadingSubSystem("Structs");
  1108. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1109. break;
  1110. }
  1111. case COMMAND_RELOAD_QUESTS: {
  1112. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Quests...");
  1113. world.SetReloadingSubsystem("Quests");
  1114. master_quest_list.Reload();
  1115. client_list.ReloadQuests();
  1116. zone_list.ReloadClientQuests();
  1117. world.RemoveReloadingSubSystem("Quests");
  1118. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1119. break;
  1120. }
  1121. case COMMAND_RELOAD_SPAWNS: {
  1122. client->GetCurrentZone()->ReloadSpawns();
  1123. break;
  1124. }
  1125. case COMMAND_RELOAD_SPELLS: {
  1126. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spells...");
  1127. world.SetReloadingSubsystem("Spells");
  1128. zone_list.DeleteSpellProcess();
  1129. master_spell_list.Reload();
  1130. if (lua_interface)
  1131. lua_interface->ReloadSpells();
  1132. zone_list.LoadSpellProcess();
  1133. world.RemoveReloadingSubSystem("Spells");
  1134. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1135. break;
  1136. }
  1137. case COMMAND_RELOAD_GROUNDSPAWNS: {
  1138. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Groundspawn Entries...");
  1139. world.SetReloadingSubsystem("GroundSpawns");
  1140. client->GetCurrentZone()->DeleteGroundSpawnItems();
  1141. client->GetCurrentZone()->LoadGroundSpawnEntries();
  1142. world.RemoveReloadingSubSystem("GroundSpawns");
  1143. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1144. break;
  1145. }
  1146. case COMMAND_RELOAD_ZONESCRIPTS: {
  1147. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Zone Scripts...");
  1148. world.SetReloadingSubsystem("ZoneScripts");
  1149. world.ResetZoneScripts();
  1150. database.LoadZoneScriptData();
  1151. if (lua_interface)
  1152. lua_interface->DestroyZoneScripts();
  1153. world.RemoveReloadingSubSystem("ZoneScripts");
  1154. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1155. break;
  1156. }
  1157. case COMMAND_RELOAD_ENTITYCOMMANDS: {
  1158. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Entity Commands...");
  1159. world.SetReloadingSubsystem("EntityCommands");
  1160. client->GetCurrentZone()->ClearEntityCommands();
  1161. database.LoadEntityCommands(client->GetCurrentZone());
  1162. world.RemoveReloadingSubSystem("EntityCommands");
  1163. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1164. break;
  1165. }
  1166. case COMMAND_RELOAD_FACTIONS: {
  1167. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Factions...");
  1168. world.SetReloadingSubsystem("Factions");
  1169. master_faction_list.Clear();
  1170. database.LoadFactionList();
  1171. world.RemoveReloadingSubSystem("Factions");
  1172. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1173. break;
  1174. }
  1175. case COMMAND_RELOAD_MAIL: {
  1176. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Mail...");
  1177. zone_list.ReloadMail();
  1178. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1179. break;
  1180. }
  1181. case COMMAND_RELOAD_GUILDS: {
  1182. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Guilds...");
  1183. world.ReloadGuilds();
  1184. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1185. break;
  1186. }
  1187. case COMMAND_RELOAD_LOCATIONS: {
  1188. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Locations...");
  1189. client->GetPlayer()->GetZone()->RemoveLocationGrids();
  1190. database.LoadLocationGrids(client->GetPlayer()->GetZone());
  1191. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1192. break;
  1193. }
  1194. case COMMAND_RELOAD_RULES: {
  1195. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Rules...");
  1196. database.LoadRuleSets(true);
  1197. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1198. break;
  1199. }
  1200. case COMMAND_RELOAD_TRANSPORTERS: {
  1201. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Transporters in your current zone...");
  1202. database.LoadTransporters(client->GetCurrentZone());
  1203. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1204. break;
  1205. }
  1206. case COMMAND_RELOAD_STARTABILITIES: {
  1207. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Starting Skills/Spells...");
  1208. world.PurgeStartingLists();
  1209. world.LoadStartingLists();
  1210. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1211. break;
  1212. }
  1213. case COMMAND_READ: {
  1214. if (sep && sep->arg[1][0] && sep->IsNumber(1)) {
  1215. if (strcmp(sep->arg[0], "read") == 0) {
  1216. int32 item_index = atol(sep->arg[1]);
  1217. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  1218. if (item) {
  1219. Spawn* spawn = cmdTarget;
  1220. client->SendShowBook(client->GetPlayer(), item->name, item->book_pages);
  1221. break;
  1222. }
  1223. }
  1224. }
  1225. break;
  1226. }
  1227. case COMMAND_USEABILITY:{
  1228. if (sep && sep->arg[0][0] && sep->IsNumber(0)) {
  1229. if (client->GetPlayer()->GetHP() == 0) {
  1230. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot do that right now.");
  1231. }
  1232. else {
  1233. int32 spell_id = atoul(sep->arg[0]);
  1234. int8 spell_tier = 0;
  1235. if (sep->arg[1][0] && sep->IsNumber(1))
  1236. spell_tier = atoi(sep->arg[1]);
  1237. else
  1238. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  1239. if (!spell_tier)
  1240. spell_tier = 1;
  1241. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  1242. if (spell) {
  1243. if (strncmp(spell->GetName(), "Gathering", 9) == 0 || strncmp(spell->GetName(), "Mining", 6) == 0 || strncmp(spell->GetName(), "Trapping", 8) == 0 || strncmp(spell->GetName(), "Foresting", 9) == 0 || strncmp(spell->GetName(), "Fishing", 7) == 0 || strncmp(spell->GetName(), "Collecting", 10) == 0)
  1244. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), cmdTarget, true, true);
  1245. else
  1246. {
  1247. if (cmdTarget)
  1248. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), cmdTarget);
  1249. else
  1250. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  1251. }
  1252. }
  1253. }
  1254. }
  1255. else if (cmdTarget && cmdTarget->IsWidget())
  1256. {
  1257. Widget* widget = (Widget*)cmdTarget;
  1258. widget->HandleUse(client, "use", WIDGET_TYPE_DOOR);
  1259. }
  1260. else
  1261. {
  1262. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /useability {spell_id} [spell_tier]");
  1263. }
  1264. break;
  1265. }
  1266. case COMMAND_INFO:{
  1267. if(sep && sep->arg[1][0] && sep->IsNumber(1)){
  1268. if(strcmp(sep->arg[0], "inventory") == 0){
  1269. int32 item_index = atol(sep->arg[1]);
  1270. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  1271. if(item){
  1272. if (item->IsCollectable() && client->SendCollectionsForItem(item))
  1273. break;
  1274. EQ2Packet* app = item->serialize(client->GetVersion(), (!item->GetItemScript() || !lua_interface), client->GetPlayer());
  1275. //DumpPacket(app);
  1276. client->QueuePacket(app);
  1277. if(item->GetItemScript() && lua_interface)
  1278. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  1279. else if(item->generic_info.offers_quest_id > 0){ //leave the current functionality in place if it doesnt have an item script
  1280. Quest* quest = master_quest_list.GetQuest(item->generic_info.offers_quest_id);
  1281. if(quest && client->GetPlayer()->GetCompletedQuest(item->generic_info.offers_quest_id) == 0 && client->GetPlayer()->GetQuest(item->generic_info.offers_quest_id) == 0)
  1282. client->AddPendingQuest(quest);
  1283. }
  1284. }
  1285. else
  1286. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Index: %u", item_index);
  1287. }
  1288. else if(strcmp(sep->arg[0], "equipment") == 0){
  1289. int32 item_index = atol(sep->arg[1]);
  1290. Item* item = client->GetPlayer()->GetEquipmentList()->GetItem(item_index);
  1291. if(item){
  1292. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1293. client->QueuePacket(app);
  1294. if(item->GetItemScript() && lua_interface)
  1295. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  1296. }
  1297. else
  1298. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Index: %u", item_index);
  1299. }
  1300. else if(strcmp(sep->arg[0], "item") == 0 || strcmp(sep->arg[0], "merchant") == 0 || strcmp(sep->arg[0], "store") == 0 || strcmp(sep->arg[0], "buyback") == 0 || strcmp(sep->arg[0], "consignment") == 0){
  1301. int32 item_id = atoul(sep->arg[1]);
  1302. Item* item = master_item_list.GetItem(item_id);
  1303. if(item){
  1304. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1305. client->QueuePacket(app);
  1306. }
  1307. else
  1308. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Item ID: %u", item_id);
  1309. }
  1310. else if (strcmp(sep->arg[0], "spell") == 0) {
  1311. sint32 spell_id = atol(sep->arg[1]);
  1312. int8 tier = atoi(sep->arg[3]);
  1313. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, tier, client, true, 0x2A);
  1314. if (outapp)
  1315. client->QueuePacket(outapp);
  1316. else
  1317. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  1318. }
  1319. else if (strcmp(sep->arg[0], "achievement") == 0) {
  1320. sint32 spell_id = atol(sep->arg[2]);
  1321. int8 group = atoi(sep->arg[1]);
  1322. AltAdvanceData* data = 0;
  1323. SpellBookEntry* spellentry = 0;
  1324. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  1325. LogWrite(COMMAND__ERROR, 0, "Command", "AA Spell ID and/or Tier, ID: %u, Group: %i", spell_id, group);
  1326. EQ2Packet* outapp = master_spell_list.GetAASpellPacket(spell_id, tier, client, true, 0x45);
  1327. if (outapp)
  1328. client->QueuePacket(outapp);
  1329. else
  1330. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, group);
  1331. }
  1332. else if (strcmp(sep->arg[0], "spellbook") == 0) {
  1333. sint32 spell_id = atol(sep->arg[1]);
  1334. int32 tier = atoi(sep->arg[2]);
  1335. if (tier > 255) {
  1336. SpellBookEntry* ent = client->GetPlayer()->GetSpellBookSpell(spell_id);
  1337. if (ent)
  1338. tier = ent->tier;
  1339. }
  1340. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, (int8)tier, client, true, 0x2A);
  1341. if (outapp)
  1342. client->QueuePacket(outapp);
  1343. else
  1344. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  1345. }
  1346. else if (strcmp(sep->arg[0], "recipe") == 0) {
  1347. sint32 recipe_id = atol(sep->arg[1]);
  1348. EQ2Packet* outapp = master_recipe_list.GetRecipePacket(recipe_id, client, true, 0x2C);
  1349. if(outapp)
  1350. client->QueuePacket(outapp);
  1351. else
  1352. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Recipe ID: %u", recipe_id);
  1353. }
  1354. else if (strcmp(sep->arg[0], "maintained") ==0) {
  1355. int32 slot = atol(sep->arg[1]);
  1356. int32 spell_id = atol(sep->arg[2]);
  1357. LogWrite(COMMAND__DEBUG, 5, "Command", "Unknown Spell ID - Slot: %u unknown: %u", slot, spell_id);
  1358. //int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  1359. MaintainedEffects* info = client->GetPlayer()->GetMaintainedSpellBySlot(slot);
  1360. EQ2Packet* outapp = master_spell_list.GetSpellPacket(info->spell_id, info->tier, client, true, 0x00);
  1361. if(outapp)
  1362. client->QueuePacket(outapp);
  1363. else
  1364. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID: %u", spell_id);
  1365. }
  1366. else if (strcmp(sep->arg[0], "effect") == 0) {
  1367. int32 spell_id = atol(sep->arg[1]);
  1368. LogWrite(COMMAND__DEBUG, 5, "Command", "Unknown Spell ID: %u", spell_id);
  1369. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  1370. int8 type = 0;
  1371. if (client->GetVersion() <= 546)
  1372. type = 1;
  1373. EQ2Packet* outapp = master_spell_list.GetSpecialSpellPacket(spell_id, tier, client, true, type);
  1374. if (outapp){
  1375. client->QueuePacket(outapp);
  1376. }
  1377. else
  1378. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID: %u", spell_id);
  1379. }
  1380. }
  1381. else if (sep && strcmp(sep->arg[0], "overflow") == 0) {
  1382. Item* item = player->item_list.GetOverflowItem();
  1383. if(item) {
  1384. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1385. client->QueuePacket(app);
  1386. }
  1387. else
  1388. LogWrite(COMMAND__ERROR, 0,"Command", "Unable to retrieve an overflow item.");
  1389. }
  1390. else
  1391. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /info {inventory|equipment|spell} {id}");
  1392. break;
  1393. }
  1394. case COMMAND_USE_EQUIPPED_ITEM:{
  1395. if (sep && sep->arg[0] && sep->IsNumber(0)){
  1396. int32 slot_id = atoul(sep->arg[0]);
  1397. Item* item = player->GetEquipmentList()->GetItem(slot_id);
  1398. if (item && item->generic_info.usable && item->GetItemScript())
  1399. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player);
  1400. }
  1401. break;
  1402. }
  1403. case COMMAND_USE_ITEM: {
  1404. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  1405. int32 item_index = atoul(sep->arg[0]);
  1406. Item* item = player->item_list.GetItemFromIndex(item_index);
  1407. if (item && item->GetItemScript()) {
  1408. if (item->generic_info.max_charges == 0 || item->generic_info.max_charges == 0xFFFF)
  1409. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player);
  1410. else {
  1411. if (item->generic_info.display_charges > 0) {
  1412. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player);
  1413. item->generic_info.display_charges -= 1;
  1414. item->save_needed = true;
  1415. client->QueuePacket(item->serialize(client->GetVersion(), false, client->GetPlayer()));
  1416. }
  1417. else
  1418. LogWrite(PLAYER__ERROR, 0, "Command", "%s: Item %s (%i) attempted to be used, however display_charges is 0.", client->GetPlayer()->GetName(), item->name.c_str(), item->details.item_id);
  1419. }
  1420. }
  1421. }
  1422. break;
  1423. }
  1424. case COMMAND_SCRIBE_SCROLL_ITEM: {
  1425. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  1426. Item* item = player->item_list.GetItemFromUniqueID(atoul(sep->arg[0]));
  1427. if (item) {
  1428. LogWrite(ITEM__DEBUG, 0, "Items", "ITEM ID: %u", item->details.item_id);
  1429. if(item->generic_info.item_type == 6) {
  1430. Spell* spell = master_spell_list.GetSpell(item->skill_info->spell_id, item->skill_info->spell_tier);
  1431. int8 old_slot = 0;
  1432. if (spell) {
  1433. if (!player->HasSpell(spell->GetSpellID(), spell->GetSpellTier(), true)) {
  1434. old_slot = player->GetSpellSlot(spell->GetSpellID());
  1435. player->RemoveSpellBookEntry(spell->GetSpellID());
  1436. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  1437. player->UnlockSpell(spell);
  1438. client->SendSpellUpdate(spell);
  1439. database.DeleteItem(client->GetCharacterID(), item, 0);
  1440. player->item_list.RemoveItem(item, true);
  1441. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  1442. client->QueuePacket(player->SendInventoryUpdate(client->GetVersion()));
  1443. }
  1444. }
  1445. else
  1446. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown spell ID: %u and tier: %u", item->skill_info->spell_id, item->skill_info->spell_tier);
  1447. }
  1448. else if(item->generic_info.item_type == 7){
  1449. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Scribing recipe book %s (%u) for player %s.", item->name.c_str(), item->details.item_id, player->GetName());
  1450. Recipe* recipe_book = new Recipe(master_recipebook_list.GetRecipeBooks(item->details.item_id));
  1451. // if valid recipe book and the player doesn't have it
  1452. if (recipe_book && recipe_book->GetLevel() > client->GetPlayer()->GetTSLevel()) {
  1453. client->Message(CHANNEL_NARRATIVE, "Your tradeskill level is not high enough to scribe this book.");
  1454. safe_delete(recipe_book);
  1455. }
  1456. else if (recipe_book && !(client->GetPlayer()->GetRecipeBookList()->HasRecipeBook(item->details.item_id))) {
  1457. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Valid recipe book that the player doesn't have");
  1458. // Add recipe book to the players list
  1459. client->GetPlayer()->GetRecipeBookList()->AddRecipeBook(recipe_book);
  1460. // Get a list of all recipes this book contains
  1461. vector<Recipe*>* book_recipes = master_recipe_list.GetRecipes(recipe_book->GetBookName());
  1462. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "%i recipes found for %s book", book_recipes->size(), recipe_book->GetBookName());
  1463. // Create the packet to send to update the players recipe list
  1464. PacketStruct* packet = 0;
  1465. if (client->GetRecipeListSent()) {
  1466. packet = configReader.getStruct("WS_RecipeList", client->GetVersion());
  1467. if (packet)
  1468. packet->setArrayLengthByName("num_recipes", book_recipes->size());
  1469. }
  1470. // loop through the list
  1471. vector<Recipe*>::iterator itr;
  1472. int16 i = 0;
  1473. for (itr = book_recipes->begin(); itr != book_recipes->end(); itr++) {
  1474. // check to see if the player already has this recipe some how
  1475. if (!client->GetPlayer()->GetRecipeList()->GetRecipe((*itr)->GetID())) {
  1476. // Player doesn't already have this recipe so lets add it
  1477. Recipe* recipe = new Recipe(master_recipe_list.GetRecipe((*itr)->GetID()));
  1478. client->GetPlayer()->GetRecipeList()->AddRecipe(recipe);
  1479. database.SavePlayerRecipe(client->GetPlayer(), recipe->GetID());
  1480. client->Message(CHANNEL_NARRATIVE, "Recipe: \"%s\" put in recipe book.", recipe->GetName());
  1481. if (packet && client->GetRecipeListSent()) {
  1482. packet->setArrayDataByName("id", recipe->GetID(), i);
  1483. packet->setArrayDataByName("tier", recipe->GetTier(), i);
  1484. packet->setArrayDataByName("level", recipe->GetLevel(), i);
  1485. packet->setArrayDataByName("icon", recipe->GetIcon(), i);
  1486. packet->setArrayDataByName("classes", recipe->GetClasses(), i);
  1487. packet->setArrayDataByName("skill", recipe->GetSkill(), i);
  1488. packet->setArrayDataByName("technique", recipe->GetTechnique(), i);
  1489. packet->setArrayDataByName("knowledge", recipe->GetKnowledge(), i);
  1490. packet->setArrayDataByName("unknown2", recipe->GetUnknown2(), i);
  1491. packet->setArrayDataByName("recipe_name", recipe->GetName(), i);
  1492. packet->setArrayDataByName("recipe_book", recipe->GetBook(), i);
  1493. packet->setArrayDataByName("unknown3", recipe->GetUnknown3(), i);
  1494. i++;
  1495. }
  1496. }
  1497. }
  1498. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Done adding recipes");
  1499. database.SavePlayerRecipeBook(client->GetPlayer(), recipe_book->GetBookID());
  1500. database.DeleteItem(client->GetCharacterID(), item, 0);
  1501. client->GetPlayer()->item_list.RemoveItem(item, true);
  1502. client->QueuePacket(client->GetPlayer()->SendInventoryUpdate(client->GetVersion()));
  1503. if (packet && client->GetRecipeListSent())
  1504. client->QueuePacket(packet->serialize());
  1505. safe_delete(packet);
  1506. }
  1507. else {
  1508. if (recipe_book)
  1509. client->Message(CHANNEL_NARRATIVE, "You have already learned all you can from this item.");
  1510. safe_delete(recipe_book);
  1511. }
  1512. }
  1513. }
  1514. else
  1515. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown unique item ID: %s", sep->arg[0]);
  1516. }
  1517. break;
  1518. }
  1519. case COMMAND_SUMMONITEM: {
  1520. if (sep && sep->IsNumber(0)) {
  1521. int32 item_id = atol(sep->arg[0]);
  1522. int32 quantity = 1;
  1523. if (sep->arg[1] && sep->IsNumber(1))
  1524. quantity = atoi(sep->arg[1]);
  1525. if (sep->arg[2] && strncasecmp(sep->arg[2], "bank", 4) == 0) {
  1526. client->AddItemToBank(item_id,quantity);
  1527. }
  1528. else {
  1529. client->AddItem(item_id, quantity);
  1530. }
  1531. }
  1532. else {
  1533. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} [quantity] or");
  1534. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} {quantity} [location] where location = bank");
  1535. }
  1536. break;
  1537. }
  1538. case COMMAND_COLLECTION_ADDITEM: {
  1539. // takes 2 params: collection_id, slot
  1540. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  1541. Item *item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(atoul(sep->arg[1]));
  1542. if (item)
  1543. client->HandleCollectionAddItem(atoul(sep->arg[0]), item);
  1544. else
  1545. LogWrite(COLLECTION__ERROR, 0, "Collect", "Error in 'COMMAND_COLLECTION_ADDITEM'. Unable to get item from player '%s' at index %u", client->GetPlayer()->GetName(), atoul(sep->arg[0]));
  1546. }
  1547. else
  1548. LogWrite(COLLECTION__ERROR, 0, "Collect", "Received command 'COMMAND_COLLECTION_ADDITEM' with unhandeled argument types");
  1549. break;
  1550. }
  1551. case COMMAND_COLLECTION_FILTER_MATCHITEM: {
  1552. // takes 1 param: slot
  1553. printf("COMMAND_COLLECTION_FILTER_MATCHITEM:\n");
  1554. int i = 0;
  1555. while (sep->arg[i] && strlen(sep->arg[i]) > 0) {
  1556. printf("\t%u: %s\n", i, sep->arg[i]);
  1557. i++;
  1558. }
  1559. break;
  1560. }
  1561. case COMMAND_WAYPOINT: {
  1562. bool success = false;
  1563. if (sep && sep->IsNumber(0) && sep->IsNumber(1) && sep->IsNumber(2)) {
  1564. if (!client->ShowPathToTarget(atof(sep->arg[0]), atof(sep->arg[1]), atof(sep->arg[2]), 0))
  1565. client->Message(CHANNEL_COLOR_RED, "Invalid coordinates given");
  1566. }
  1567. else if ( client->GetAdminStatus() > 100 && cmdTarget ) {
  1568. if (!client->ShowPathToTarget(cmdTarget->GetX(), cmdTarget->GetY(), cmdTarget->GetZ(), 0))
  1569. client->Message(CHANNEL_COLOR_RED, "Invalid coordinates given");
  1570. }
  1571. else {
  1572. client->ClearWaypoint();
  1573. client->Message(CHANNEL_COLOR_YELLOW, "Usage: /waypoint x y z");
  1574. }
  1575. break;
  1576. }
  1577. case COMMAND_WHO:{
  1578. const char* who = 0;
  1579. if(sep && sep->arg[0]){
  1580. //cout << "Who query: \n";
  1581. who = sep->argplus[0];
  1582. //cout << who << endl;
  1583. }
  1584. zone_list.ProcessWhoQuery(who, client);
  1585. break;
  1586. }
  1587. case COMMAND_SELECT_JUNCTION:{
  1588. 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__);
  1589. int32 choice = 0;
  1590. if(sep && sep->arg[0] && sep->IsNumber(0))
  1591. choice = atoul(sep->arg[0]);
  1592. if(client->GetPlayer()->GetHP() == 0){ //dead and this is a revive request
  1593. client->HandlePlayerRevive(choice);
  1594. }
  1595. break;
  1596. }
  1597. case COMMAND_SPAWN_MOVE: {
  1598. if (cmdTarget && cmdTarget->IsPlayer() == false) {
  1599. PacketStruct* packet = configReader.getStruct("WS_MoveObjectMode", client->GetVersion());
  1600. if (packet) {
  1601. float unknown2_3 = 0;
  1602. int8 placement_mode = 0;
  1603. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::DEFAULT);
  1604. if (sep && sep->arg[0][0]) {
  1605. if (strcmp(sep->arg[0], "wall") == 0) {
  1606. placement_mode = 2;
  1607. unknown2_3 = 150;
  1608. }
  1609. else if (strcmp(sep->arg[0], "ceiling") == 0)
  1610. placement_mode = 1;
  1611. else if (strcmp(sep->arg[0], "openheading") == 0 && cmdTarget->IsWidget())
  1612. {
  1613. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "[PlacementMode] WIDGET OPEN HEADING MODE");
  1614. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::OPEN_HEADING);
  1615. }
  1616. else if (strcmp(sep->arg[0], "closeheading") == 0 && cmdTarget->IsWidget())
  1617. {
  1618. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "[PlacementMode] WIDGET CLOSE HEADING MODE");
  1619. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::CLOSE_HEADING);
  1620. }
  1621. else if (strcmp(sep->arg[0], "myloc") == 0)
  1622. {
  1623. if (cmdTarget->GetSpawnLocationPlacementID() < 1) {
  1624. client->Message(CHANNEL_COLOR_YELLOW, "[PlacementMode] Spawn %s cannot be moved it is not assigned a spawn location placement id.", cmdTarget->GetName());
  1625. safe_delete(packet);
  1626. break;
  1627. }
  1628. cmdTarget->SetX(client->GetPlayer()->GetX(), true);
  1629. cmdTarget->SetY(client->GetPlayer()->GetY(), true);
  1630. cmdTarget->SetZ(client->GetPlayer()->GetZ(), true);
  1631. cmdTarget->SetHeading(client->GetPlayer()->GetHeading(), true);
  1632. if (database.UpdateSpawnLocationSpawns(cmdTarget))
  1633. client->Message(CHANNEL_COLOR_YELLOW, "[PlacementMode] Spawn %s placed at your location. Updated spawn_location_placement for spawn.", cmdTarget->GetName());
  1634. safe_delete(packet);
  1635. break;
  1636. }
  1637. }
  1638. packet->setDataByName("placement_mode", placement_mode);
  1639. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget));
  1640. packet->setDataByName("model_type", cmdTarget->GetModelType());
  1641. packet->setDataByName("unknown", 1); //size
  1642. packet->setDataByName("unknown2", 1); //size 2
  1643. packet->setDataByName("unknown2", .5, 1); //size 3
  1644. packet->setDataByName("unknown2", 3, 2);
  1645. packet->setDataByName("unknown2", unknown2_3, 3);
  1646. packet->setDataByName("max_distance", 500);
  1647. packet->setDataByName("CoEunknown", 0xFFFFFFFF);
  1648. client->QueuePacket(packet->serialize());
  1649. safe_delete(packet);
  1650. }
  1651. }
  1652. else {
  1653. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /spawn move (wall OR ceiling)");
  1654. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Moves a spawn anywhere you like. Optionally wall/ceiling can be provided to place wall/ceiling items.");
  1655. }
  1656. break;
  1657. }
  1658. case COMMAND_HAIL:{
  1659. Spawn* spawn = cmdTarget;
  1660. if(spawn && spawn->GetTargetable())
  1661. {
  1662. char tmp[75] = {0};
  1663. sprintf(tmp, "Hail, %s", spawn->GetName());
  1664. bool show_bubble = true;
  1665. if (spawn->IsNPC())
  1666. show_bubble = false;
  1667. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp, HEAR_SPAWN_DISTANCE, 0, show_bubble);
  1668. if(spawn->IsPlayer() == false && spawn->GetDistance(client->GetPlayer()) < 30){
  1669. if(spawn->IsNPC() && ((NPC*)spawn)->EngagedInCombat())
  1670. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED_BUSY, client->GetPlayer());
  1671. else
  1672. spawn->ProcessMovement();
  1673. LogWrite(MISC__TODO, 0, "Check", "ProcessMovement has been called");
  1674. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED, client->GetPlayer());
  1675. }
  1676. }
  1677. else {
  1678. string tmp = "Hail";
  1679. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp.c_str(), HEAR_SPAWN_DISTANCE, 0, true);
  1680. }
  1681. break;
  1682. }
  1683. case COMMAND_SAY:{
  1684. if (sep && sep->arg[0][0]) {
  1685. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, sep->argplus[0], HEAR_SPAWN_DISTANCE);
  1686. if (cmdTarget && !(cmdTarget->IsPlayer()))
  1687. client->GetCurrentZone()->CallSpawnScript(cmdTarget, SPAWN_SCRIPT_HEAR_SAY, client->GetPlayer(), sep->argplus[0]);
  1688. }
  1689. else
  1690. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /say {message}");
  1691. break;
  1692. }
  1693. case COMMAND_TELL:{
  1694. if(sep && sep->arg[0] && sep->argplus[1]){
  1695. if(!zone_list.HandleGlobalChatMessage(client, sep->arg[0], CHANNEL_PRIVATE_TELL, sep->argplus[1]))
  1696. client->Message(CHANNEL_COLOR_RED,"Unable to find client %s",sep->arg[0]);
  1697. }else
  1698. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /tell {character_name} {message}");
  1699. break;
  1700. }
  1701. case COMMAND_SHOUT:{
  1702. if(sep && sep->arg[0][0])
  1703. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SHOUT, sep->argplus[0]);
  1704. else
  1705. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /shout {message}");
  1706. break;
  1707. }
  1708. case COMMAND_AUCTION:{
  1709. if(sep && sep->arg[0][0])
  1710. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_AUCTION, sep->argplus[0]);
  1711. else
  1712. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /auction {message}");
  1713. break;
  1714. }
  1715. case COMMAND_OOC:{
  1716. //For now ooc will be the global chat channel, eventually when we create more channels we will create a global chat channel
  1717. if(sep && sep->arg[0][0])
  1718. zone_list.HandleGlobalChatMessage(client, 0, CHANNEL_OUT_OF_CHARACTER, sep->argplus[0]);
  1719. else
  1720. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /ooc {message}");
  1721. break;
  1722. }
  1723. case COMMAND_EMOTE:{
  1724. if(sep && sep->arg[0][0])
  1725. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_EMOTE, sep->argplus[0]);
  1726. else
  1727. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /emote {action}");
  1728. break;
  1729. }
  1730. case COMMAND_RACE:{
  1731. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  1732. if(sep->arg[1][0] && sep->IsNumber(1)){
  1733. client->GetPlayer()->GetInfoStruct()->race = atoi(sep->arg[1]);
  1734. client->GetPlayer()->SetRace(atoi(sep->arg[1]));
  1735. client->UpdateTimeStampFlag ( RACE_UPDATE_FLAG );
  1736. client->GetPlayer()->SetCharSheetChanged(true);
  1737. }
  1738. client->GetPlayer()->SetModelType(atoi(sep->arg[0]));
  1739. //EQ2Packet* outapp = client->GetPlayer()->spawn_update_packet(client->GetPlayer(), client->GetVersion(), client->GetPlayer()->GetFeatures());
  1740. //client->QueuePacket(outapp);
  1741. }
  1742. else{
  1743. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /race {race type id} {race id}");
  1744. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "{race id} is optional");
  1745. }
  1746. break;
  1747. }
  1748. case COMMAND_BANK_DEPOSIT:{
  1749. if(client->GetBanker() && sep && sep->arg[0]){
  1750. int64 amount = 0;
  1751. string deposit = string(sep->arg[0]);
  1752. amount = atoi64(deposit.c_str());
  1753. client->BankDeposit(amount);
  1754. }
  1755. break;
  1756. }
  1757. case COMMAND_BANK_WITHDRAWAL:{
  1758. if(client->GetBanker() && sep && sep->arg[0] && sep->IsNumber(0)){
  1759. int64 amount = 0;
  1760. string deposit = string(sep->arg[0]);
  1761. amount = atoi64(deposit.c_str());
  1762. client->BankWithdrawal(amount);
  1763. }
  1764. break;
  1765. }
  1766. case COMMAND_BANK_CANCEL:{
  1767. Spawn* banker = cmdTarget;
  1768. client->Bank(banker, true);
  1769. break;
  1770. }
  1771. case COMMAND_BANK:{
  1772. LogWrite(PLAYER__DEBUG, 0, "Players", "Open Player Personal Bank...");
  1773. Spawn* banker = cmdTarget;
  1774. client->Bank(banker);
  1775. break;
  1776. }
  1777. case COMMAND_GUILD_BANK:{
  1778. LogWrite(GUILD__DEBUG, 0, "Guilds", "Open Guild Bank...");
  1779. //Spawn* banker = client->GetPlayer()->GetTarget();
  1780. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will eventually open the guild bank!");
  1781. break;
  1782. }
  1783. case COMMAND_START_MAIL: {
  1784. client->SetMailTransaction(cmdTarget);
  1785. client->SendMailList();
  1786. break;
  1787. }
  1788. case COMMAND_CANCEL_MAIL: {
  1789. client->SetMailTransaction(0);
  1790. break;
  1791. }
  1792. case COMMAND_GET_MAIL_MESSAGE: {
  1793. if (sep && sep->arg[0] && sep->IsNumber(0))
  1794. client->DisplayMailMessage(atoul(sep->arg[0]));
  1795. break;
  1796. }
  1797. case COMMAND_ADD_MAIL_PLAT: {
  1798. if (sep && sep->arg[0] && sep->IsNumber(0))
  1799. client->AddMailCoin(0, 0, 0, atoul(sep->arg[0]));
  1800. break;
  1801. }
  1802. case COMMAND_ADD_MAIL_GOLD: {
  1803. if (sep && sep->arg[0] && sep->IsNumber(0))
  1804. client->AddMailCoin(0, 0, atoul(sep->arg[0]));
  1805. break;
  1806. }
  1807. case COMMAND_ADD_MAIL_SILVER: {
  1808. if (sep && sep->arg[0] && sep->IsNumber(0))
  1809. client->AddMailCoin(0, atoul(sep->arg[0]));
  1810. break;
  1811. }
  1812. case COMMAND_ADD_MAIL_COPPER: {
  1813. if (sep && sep->arg[0] && sep->IsNumber(0))
  1814. client->AddMailCoin(atoul(sep->arg[0]));
  1815. break;
  1816. }
  1817. case COMMAND_SET_MAIL_ITEM: {
  1818. LogWrite(MISC__TODO, 1, "TODO", " received set_mail_item\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1819. if (sep && sep->arg[0]) LogWrite(COMMAND__DEBUG, 0, "Command", "%s\n", sep->argplus[0]);
  1820. break;
  1821. }
  1822. case COMMAND_REMOVE_MAIL_PLAT: {
  1823. if (sep && sep->arg[0] && sep->IsNumber(0))
  1824. client->RemoveMailCoin(0, 0, 0, atoul(sep->arg[0]));
  1825. break;
  1826. }
  1827. case COMMAND_REMOVE_MAIL_GOLD: {
  1828. if (sep && sep->arg[0] && sep->IsNumber(0))
  1829. client->RemoveMailCoin(0, 0, atoul(sep->arg[0]));
  1830. break;
  1831. }
  1832. case COMMAND_REMOVE_MAIL_SILVER: {
  1833. if (sep && sep->arg[0] && sep->IsNumber(0))
  1834. client->RemoveMailCoin(0, atoul(sep->arg[0]));
  1835. break;
  1836. }
  1837. case COMMAND_REMOVE_MAIL_COPPER: {
  1838. if (sep && sep->arg[0] && sep->IsNumber(0))
  1839. client->RemoveMailCoin(atoul(sep->arg[0]));
  1840. break;
  1841. }
  1842. case COMMAND_TAKE_MAIL_ATTACHMENTS: {
  1843. if (sep && sep->arg[0] && sep->IsNumber(0))
  1844. client->TakeMailAttachments(atoul(sep->arg[0]));
  1845. break;
  1846. }
  1847. case COMMAND_CANCEL_SEND_MAIL: {
  1848. client->CancelSendMail();
  1849. break;
  1850. }
  1851. case COMMAND_DELETE_MAIL_MESSAGE: {
  1852. if (sep && sep->arg[0] && sep->IsNumber(0))
  1853. client->DeleteMail(atoul(sep->arg[0]), true);
  1854. break;
  1855. }
  1856. case COMMAND_REPORT_SPAM: {
  1857. LogWrite(MISC__TODO, 1, "TODO", " received reportspam\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1858. if (sep && sep->arg[0]) LogWrite(COMMAND__DEBUG, 0, "Command", "%s\n", sep->argplus[0]);
  1859. break;
  1860. }
  1861. case COMMAND_KILL:{
  1862. Spawn* dead = 0;
  1863. if (sep && sep->arg[0] && strncasecmp(sep->arg[0],"self",4)==0){
  1864. dead=client->GetPlayer();
  1865. client->GetPlayer()->SetHP(0);
  1866. client->GetPlayer()->KillSpawn(dead);
  1867. }else{
  1868. dead= cmdTarget;
  1869. if(dead && dead->IsPlayer() == false){
  1870. dead->SetHP(0);
  1871. if(sep && sep->arg[0] && sep->IsNumber(0) && atoi(sep->arg[0]) == 1)
  1872. client->GetCurrentZone()->RemoveSpawn(dead, true);
  1873. else
  1874. client->GetPlayer()->KillSpawn(dead);
  1875. }else{
  1876. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /kill (self)");
  1877. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Kills currently selected non-player target.");
  1878. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Optionally, self may be used to kill yourself");
  1879. }
  1880. }
  1881. break;
  1882. }
  1883. case COMMAND_LEVEL:{
  1884. if(sep && sep->arg[ndx][0] && sep->IsNumber(0)){
  1885. int16 new_level = atoi(sep->arg[ndx]);
  1886. if (!client->GetPlayer()->CheckLevelStatus(new_level))
  1887. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have the required status to level up anymore!");
  1888. else {
  1889. if (new_level < 1)
  1890. new_level = 1;
  1891. if (new_level > 255)
  1892. new_level = 255;
  1893. client->ChangeLevel(client->GetPlayer()->GetLevel(), new_level);
  1894. }
  1895. }else
  1896. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /level {new_level}");
  1897. break;
  1898. }
  1899. case COMMAND_SIT: {
  1900. LogWrite(MISC__TODO, 1, "TODO", " Send update packet to all clients\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1901. if(client->GetPlayer()->GetHP() > 0){
  1902. client->QueuePacket(new EQ2Packet(OP_SitMsg, 0, 0));
  1903. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You sit down.");
  1904. client->GetPlayer()->set_character_flag(CF_IS_SITTING);
  1905. }
  1906. break;
  1907. }
  1908. case COMMAND_STAND: {
  1909. LogWrite(MISC__TODO, 1, "TODO", " Send update packet to all clients\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1910. if(client->GetPlayer()->GetHP() > 0){
  1911. client->QueuePacket(new EQ2Packet(OP_StandMsg, 0, 0));
  1912. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You stand up.");
  1913. client->GetPlayer()->reset_character_flag(CF_IS_SITTING);
  1914. }
  1915. break;
  1916. }
  1917. case COMMAND_CLASS:{
  1918. if(sep && sep->arg[ndx][0]){
  1919. client->GetPlayer()->SetPlayerAdventureClass(atoi(sep->arg[ndx]));
  1920. client->UpdateTimeStampFlag ( CLASS_UPDATE_FLAG );
  1921. }else
  1922. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /class {class_id}");
  1923. break;
  1924. }
  1925. case COMMAND_GENDER:{
  1926. if(sep && sep->arg[ndx][0]){
  1927. client->GetPlayer()->GetInfoStruct()->gender = atoi(sep->arg[ndx]);
  1928. client->GetPlayer()->SetCharSheetChanged(true);
  1929. client->UpdateTimeStampFlag ( GENDER_UPDATE_FLAG );
  1930. }else{
  1931. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /gender {new_gender_id}");
  1932. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Male: 1");
  1933. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Female: 2");
  1934. }
  1935. break;
  1936. }
  1937. case COMMAND_FLYMODE:{
  1938. if(sep && sep->arg[0] && sep->IsNumber(0)){
  1939. PrintSep(sep, "COMMAND_FLYMODE");
  1940. int8 val = atoi(sep->arg[0]);
  1941. ClientPacketFunctions::SendFlyMode(client, val);
  1942. }
  1943. else{
  1944. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage ON: /flymode 1");
  1945. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage OFF: /flymode 0");
  1946. }
  1947. break;
  1948. }
  1949. case COMMAND_LOOT_LIST:{
  1950. Spawn* spawn = cmdTarget;
  1951. if(spawn && spawn->IsEntity()){
  1952. if (sep && sep->arg[0]) {
  1953. if (!spawn->GetDatabaseID())
  1954. {
  1955. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn has no database id to assign to loottables.");
  1956. break;
  1957. }
  1958. else if (!spawn->IsNPC())
  1959. {
  1960. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "these /loot list [add/remove/clearall] sub-commands are only designed for an NPC.");
  1961. break;
  1962. }
  1963. bool reloadLoot = false;
  1964. if (!stricmp(sep->arg[0], "remove") && sep->arg[1] && sep->IsNumber(1))
  1965. {
  1966. int32 loottable_id = atoul(sep->arg[1]);
  1967. if (loottable_id > 0 && database.RemoveSpawnLootTable(spawn, loottable_id))
  1968. {
  1969. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u loot table %u removed.", spawn->GetDatabaseID(), loottable_id);
  1970. reloadLoot = true;
  1971. }
  1972. else
  1973. client->Message(CHANNEL_COLOR_YELLOW, "/loot list remove [loottableid] - could not match any spawn_id entries against loottable_id %u.", loottable_id);
  1974. }
  1975. else if (!stricmp(sep->arg[0], "add") && sep->arg[1] && sep->IsNumber(1))
  1976. {
  1977. int32 loottable_id = atoul(sep->arg[1]);
  1978. if (loottable_id > 0)
  1979. {
  1980. database.AddLootTableToSpawn(spawn, loottable_id);
  1981. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u loot table %u added.", spawn->GetDatabaseID(), loottable_id);
  1982. reloadLoot = true;
  1983. }
  1984. else
  1985. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list add [loottableid] - cannot add a loottable id of 0.");
  1986. }
  1987. else if (!stricmp(sep->arg[0], "clearall"))
  1988. {
  1989. if (database.RemoveSpawnLootTable(spawn, 0))
  1990. {
  1991. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn loot tables removed.");
  1992. reloadLoot = true;
  1993. }
  1994. else
  1995. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list clearall - could not match any spawn_id entries in loottable_id.");
  1996. }
  1997. else
  1998. {
  1999. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list argument not supported.");
  2000. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list add [loottableid] - add new loottable to spawn");
  2001. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list remove [loottableid] - remove existing loottable from spawn");
  2002. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list clearall - remove all loottables from spawn");
  2003. break;
  2004. }
  2005. if (reloadLoot)
  2006. {
  2007. database.LoadSpawnLoot(spawn->GetZone(), spawn);
  2008. if (spawn->IsNPC())
  2009. {
  2010. Entity* ent = (Entity*)spawn;
  2011. ent->SetLootCoins(0);
  2012. ent->ClearLootList();
  2013. spawn->GetZone()->AddLoot((NPC*)spawn);
  2014. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u active loot purged and reloaded.", spawn->GetDatabaseID());
  2015. }
  2016. }
  2017. break; // nothing further this is the end of these sub commands
  2018. }
  2019. else
  2020. {
  2021. vector<int32> loot_list = client->GetCurrentZone()->GetSpawnLootList(spawn->GetDatabaseID(), spawn->GetZone()->GetZoneID(), spawn->GetLevel(), race_types_list.GetRaceType(spawn->GetModelType()));
  2022. if (loot_list.size() > 0) {
  2023. client->Message(CHANNEL_COLOR_YELLOW, "%s belongs to the following loot lists: ", spawn->GetName());
  2024. vector<int32>::iterator list_itr;
  2025. LootTable* table = 0;
  2026. for (list_itr = loot_list.begin(); list_itr != loot_list.end(); list_itr++) {
  2027. table = client->GetCurrentZone()->GetLootTable(*list_itr);
  2028. if (table)
  2029. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", *list_itr, table->name.c_str());
  2030. }
  2031. }
  2032. client->Message(CHANNEL_COLOR_YELLOW, "Coins being carried: %u", spawn->GetLootCoins());
  2033. vector<Item*>* items = spawn->GetLootItems();
  2034. if (items) {
  2035. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is carrying the following items: ");
  2036. vector<Item*>::iterator itr;
  2037. Item* item = 0;
  2038. for (itr = items->begin(); itr != items->end(); itr++) {
  2039. item = *itr;
  2040. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", item->details.item_id, item->name.c_str());
  2041. }
  2042. }
  2043. else
  2044. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is not carrying any items.");
  2045. }
  2046. }
  2047. break;
  2048. }
  2049. case COMMAND_LOOT_SETCOIN:{
  2050. Spawn* spawn = cmdTarget;
  2051. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2052. spawn->SetLootCoins(atoul(sep->arg[0]));
  2053. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully set coins.");
  2054. }
  2055. else
  2056. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot setcoin {amount}");
  2057. break;
  2058. }
  2059. case COMMAND_LOOT_ADDITEM:{
  2060. Spawn* spawn = cmdTarget;
  2061. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2062. int16 charges = 1;
  2063. if(sep->arg[1] && sep->IsNumber(1))
  2064. charges = atoi(sep->arg[1]);
  2065. spawn->AddLootItem(atoul(sep->arg[0]), charges);
  2066. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully added item.");
  2067. }
  2068. else
  2069. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot additem {item_id}");
  2070. break;
  2071. }
  2072. case COMMAND_LOOT_REMOVEITEM:{
  2073. Spawn* spawn = cmdTarget;
  2074. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2075. spawn->LootItem(atoul(sep->arg[0]));
  2076. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully removed item.");
  2077. }
  2078. else
  2079. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot removeitem {item_id}");
  2080. break;
  2081. }
  2082. case COMMAND_LOOT_CORPSE:
  2083. case COMMAND_DISARM:
  2084. case COMMAND_LOOT:{
  2085. if (cmdTarget && ((Entity*)cmdTarget)->IsNPC() && cmdTarget->Alive())
  2086. {
  2087. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is not dead.");
  2088. break;
  2089. }
  2090. if(cmdTarget && cmdTarget->IsEntity()){
  2091. if (cmdTarget->GetDistance(client->GetPlayer()) <= rule_manager.GetGlobalRule(R_Loot, LootRadius)->GetFloat()){
  2092. if (!rule_manager.GetGlobalRule(R_Loot, AutoDisarmChest)->GetBool() && command->handler == COMMAND_DISARM )
  2093. client->OpenChest(cmdTarget, true);
  2094. else
  2095. client->Loot(cmdTarget, rule_manager.GetGlobalRule(R_Loot, AutoDisarmChest)->GetBool());
  2096. if (!(cmdTarget)->HasLoot()){
  2097. if (((Entity*)cmdTarget)->IsNPC())
  2098. client->GetCurrentZone()->RemoveDeadSpawn(cmdTarget);
  2099. }
  2100. }
  2101. else
  2102. client->Message(CHANNEL_COLOR_YELLOW, "You are too far away to interact with that");
  2103. }
  2104. else if(!cmdTarget || cmdTarget->GetHP() > 0)
  2105. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid target.");
  2106. break;
  2107. }
  2108. case COMMAND_RELOADSPAWNSCRIPTS:{
  2109. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spawn Scripts....");
  2110. if (lua_interface)
  2111. lua_interface->SetSpawnScriptsReloading(true);
  2112. world.ResetSpawnScripts();
  2113. database.LoadSpawnScriptData();
  2114. if(lua_interface) {
  2115. lua_interface->DestroySpawnScripts();
  2116. lua_interface->SetSpawnScriptsReloading(false);
  2117. }
  2118. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Success!");
  2119. break;
  2120. }
  2121. case COMMAND_RELOADREGIONSCRIPTS:{
  2122. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Region Scripts....");
  2123. if(lua_interface) {
  2124. lua_interface->DestroyRegionScripts();
  2125. }
  2126. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Success!");
  2127. break;
  2128. }
  2129. case COMMAND_RELOADLUASYSTEM:{
  2130. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Attempting to reload entire LUA system....");
  2131. map<Client*, int32> debug_clients = lua_interface->GetDebugClients();
  2132. safe_delete(lua_interface);
  2133. lua_interface = new LuaInterface();
  2134. if(lua_interface)
  2135. lua_interface->SetSpawnScriptsReloading(true);
  2136. if(lua_interface && debug_clients.size() > 0){
  2137. map<Client*, int32>::iterator itr;
  2138. for(itr = debug_clients.begin(); itr != debug_clients .end(); itr++){
  2139. if(lua_interface)
  2140. lua_interface->UpdateDebugClients(itr->first);
  2141. }
  2142. }
  2143. world.ResetSpawnScripts();
  2144. database.LoadSpawnScriptData();
  2145. world.ResetZoneScripts();
  2146. database.LoadZoneScriptData();
  2147. int32 quest_count = database.LoadQuests();
  2148. zone_list.DeleteSpellProcess();
  2149. master_spell_list.Reload();
  2150. int32 spell_count = 0;
  2151. if(lua_interface) {
  2152. lua_interface->DestroySpawnScripts();
  2153. lua_interface->DestroySpells();
  2154. spell_count = database.LoadSpellScriptData();
  2155. lua_interface->SetSpawnScriptsReloading(false);
  2156. }
  2157. zone_list.LoadSpellProcess();
  2158. client->Message(CHANNEL_COLOR_YELLOW, "Successfully loaded %u spell(s), %u quest(s).", spell_count, quest_count);
  2159. break;
  2160. }
  2161. case COMMAND_DECLINE_QUEST:{
  2162. int32 quest_id = 0;
  2163. if(sep && sep->arg[0] && sep->IsNumber(0))
  2164. quest_id = atoul(sep->arg[0]);
  2165. if(quest_id > 0){
  2166. Quest* quest = client->GetPendingQuest(quest_id);
  2167. if(quest){
  2168. client->RemovePendingQuest(quest);
  2169. if(lua_interface)
  2170. lua_interface->CallQuestFunction(quest, "Declined", client->GetPlayer());
  2171. safe_delete(quest);
  2172. client->GetCurrentZone()->SendQuestUpdates(client);
  2173. }
  2174. }
  2175. break;
  2176. }
  2177. case COMMAND_DELETE_QUEST:{
  2178. int32 quest_id = 0;
  2179. if(sep && sep->arg[0] && sep->IsNumber(0))
  2180. quest_id = atoul(sep->arg[0]);
  2181. if(quest_id > 0){
  2182. if(lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0) {
  2183. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  2184. if (quest)
  2185. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  2186. }
  2187. client->RemovePlayerQuest(quest_id);
  2188. client->GetCurrentZone()->SendQuestUpdates(client);
  2189. }
  2190. break;
  2191. }
  2192. case COMMAND_ACCEPT_QUEST:{
  2193. int32 quest_id = 0;
  2194. if(sep && sep->arg[0] && sep->IsNumber(0))
  2195. quest_id = atoul(sep->arg[0]);
  2196. if(quest_id > 0){
  2197. client->AcceptQuest(quest_id);
  2198. }
  2199. break;
  2200. }
  2201. case COMMAND_NAME:{
  2202. if(sep && sep->arg[ndx][0]){
  2203. memset(client->GetPlayer()->GetInfoStruct()->name, 0, 40);
  2204. strncpy(client->GetPlayer()->GetInfoStruct()->name, sep->arg[ndx], 39);
  2205. client->GetPlayer()->SetCharSheetChanged(true);
  2206. }else
  2207. client->Message(CHANNEL_COLOR_YELLOW,"Usage: /name {new_name}");
  2208. break;
  2209. }
  2210. case COMMAND_GROUPSAY:{
  2211. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  2212. if(sep && sep->arg[0] && gmi)
  2213. world.GetGroupManager()->GroupChatMessage(gmi->group_id, client->GetPlayer(), sep->argplus[0]);
  2214. break;
  2215. }
  2216. case COMMAND_GROUPINVITE: {
  2217. Entity* target = 0;
  2218. Client* target_client = 0;
  2219. if (client->GetPlayer()->GetGroupMemberInfo() && !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  2220. client->SimpleMessage(CHANNEL_COMMANDS, "You must be the group leader to invite.");
  2221. return;
  2222. }
  2223. // name provided with command so it has to be a player, npc not supported here
  2224. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0){
  2225. target_client = zone_list.GetClientByCharName(sep->arg[0]);
  2226. if (target_client) {
  2227. if (!target_client->IsConnected() || !target_client->IsReadyForSpawns())
  2228. target = 0;
  2229. else
  2230. target = target_client->GetPlayer();
  2231. }
  2232. }
  2233. // if name was not provided use the players target, npc or player supported here
  2234. if (!target && client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  2235. target = (Entity*)client->GetPlayer()->GetTarget();
  2236. if (target->IsPlayer()) {
  2237. target_client = client->GetCurrentZone()->GetClientBySpawn(target);
  2238. }
  2239. }
  2240. int8 result = world.GetGroupManager()->Invite(client->GetPlayer(), target);
  2241. if (result == 0) {
  2242. client->Message(CHANNEL_COMMANDS, "You invite %s to group with you.", target->GetName());
  2243. if (target_client) {
  2244. PacketStruct* packet = configReader.getStruct("WS_ReceiveOffer", target_client->GetVersion());
  2245. if (packet) {
  2246. packet->setDataByName("type", 1);
  2247. packet->setDataByName("name", client->GetPlayer()->GetName());
  2248. packet->setDataByName("unknown2", 1);
  2249. target_client->QueuePacket(packet->serialize());
  2250. safe_delete(packet);
  2251. }
  2252. }
  2253. }
  2254. else if (result == 1)
  2255. client->SimpleMessage(CHANNEL_COMMANDS, "That player is already in a group.");
  2256. else if (result == 2)
  2257. client->SimpleMessage(CHANNEL_COMMANDS, "That player has been invited to another group.");
  2258. else if (result == 3)
  2259. client->SimpleMessage(CHANNEL_COMMANDS, "Your group is already full.");
  2260. else if (result == 4)
  2261. client->SimpleMessage(CHANNEL_COMMANDS, "You have a pending invitation, cancel it first.");
  2262. else if (result == 5)
  2263. client->SimpleMessage(CHANNEL_COMMANDS, "You cannot invite yourself!");
  2264. else if (result == 6)
  2265. client->SimpleMessage(CHANNEL_COMMANDS, "Could not locate the player.");
  2266. else
  2267. client->SimpleMessage(CHANNEL_COMMANDS, "Group invite failed, unknown error!");
  2268. break;
  2269. }
  2270. case COMMAND_GROUPDISBAND: {
  2271. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  2272. if (gmi) { // TODO: Leader check
  2273. // world.GetGroupManager()->SimpleGroupMessage(gmi->group_id, "Your group has been disbanded.");
  2274. world.GetGroupManager()->RemoveGroup(gmi->group_id);
  2275. }
  2276. break;
  2277. }
  2278. case COMMAND_GROUP_LEAVE: {
  2279. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  2280. if (gmi) {
  2281. int32 group_id = gmi->group_id;
  2282. world.GetGroupManager()->RemoveGroupMember(group_id, client->GetPlayer());
  2283. if (!world.GetGroupManager()->IsGroupIDValid(group_id)) {
  2284. // leader->Message(CHANNEL_COLOR_GROUP, "%s has left the group.", client->GetPlayer()->GetName());
  2285. }
  2286. else {
  2287. world.GetGroupManager()->GroupMessage(group_id, "%s has left the group.", client->GetPlayer()->GetName());
  2288. }
  2289. client->SimpleMessage(CHANNEL_GROUP_CHAT, "You have left the group");
  2290. }
  2291. break;
  2292. }
  2293. case COMMAND_FRIEND_ADD:{
  2294. string name = "";
  2295. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2296. name = database.GetPlayerName(sep->arg[0]);
  2297. else if(cmdTarget && cmdTarget->IsPlayer())
  2298. name = string(cmdTarget->GetName());
  2299. if(name.length() > 0){
  2300. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  2301. if(client->GetPlayer()->IsIgnored(name.c_str())){
  2302. client->GetPlayer()->RemoveIgnore(name.c_str());
  2303. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  2304. client->SendChatRelationship(3, name.c_str());
  2305. }
  2306. client->GetPlayer()->AddFriend(name.c_str(), true);
  2307. client->SendChatRelationship(0, name.c_str());
  2308. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added friend: %s", name.c_str());
  2309. if(zone_list.GetClientByCharName(name))
  2310. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Friend: %s has logged in.", name.c_str());
  2311. }
  2312. else
  2313. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot be more friendly towards yourself!");
  2314. }
  2315. else
  2316. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  2317. break;
  2318. }
  2319. case COMMAND_FRIEND_REMOVE:{
  2320. string name = "";
  2321. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2322. name = database.GetPlayerName(sep->arg[0]);
  2323. else if(cmdTarget && cmdTarget->IsPlayer())
  2324. name = string(cmdTarget->GetName());
  2325. if(name.length() > 0){
  2326. client->GetPlayer()->RemoveFriend(name.c_str());
  2327. client->SendChatRelationship(1, name.c_str());
  2328. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  2329. }
  2330. else
  2331. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  2332. break;
  2333. }
  2334. case COMMAND_FRIENDS:{
  2335. break;
  2336. }
  2337. case COMMAND_IGNORE_ADD:{
  2338. string name = "";
  2339. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2340. name = database.GetPlayerName(sep->arg[0]);
  2341. else if(cmdTarget && cmdTarget->IsPlayer())
  2342. name = string(cmdTarget->GetName());
  2343. if(name.length() > 0){
  2344. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  2345. if(client->GetPlayer()->IsFriend(name.c_str())){
  2346. client->GetPlayer()->RemoveFriend(name.c_str());
  2347. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  2348. client->SendChatRelationship(1, name.c_str());
  2349. }
  2350. client->GetPlayer()->AddIgnore(name.c_str(), true);
  2351. client->SendChatRelationship(2, name.c_str());
  2352. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added ignore: %s", name.c_str());
  2353. }
  2354. else
  2355. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot ignore yourself!");
  2356. }
  2357. else
  2358. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  2359. break;
  2360. }
  2361. case COMMAND_IGNORE_REMOVE:{
  2362. string name = "";
  2363. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2364. name = database.GetPlayerName(sep->arg[0]);
  2365. else if(cmdTarget && cmdTarget->IsPlayer())
  2366. name = string(cmdTarget->GetName());
  2367. if(name.length() > 0){
  2368. client->GetPlayer()->RemoveIgnore(name.c_str());
  2369. client->SendChatRelationship(3, name.c_str());
  2370. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  2371. }
  2372. break;
  2373. }
  2374. case COMMAND_IGNORES:{
  2375. break;
  2376. }
  2377. case COMMAND_GROUP_KICK:{
  2378. Entity* kicked = 0;
  2379. Client* kicked_client = 0;
  2380. int32 group_id = 0;
  2381. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader)
  2382. return;
  2383. LogWrite(MISC__TODO, 0, "TODO", "Add a check to see if the client using the command (COMMAND_GROUP_KICK) is the group leader");
  2384. if (sep && sep->arg[0]) {
  2385. kicked_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  2386. if (kicked_client)
  2387. kicked = kicked_client->GetPlayer();
  2388. }
  2389. else if (cmdTarget && cmdTarget->IsEntity()) {
  2390. kicked = (Entity*)cmdTarget;
  2391. }
  2392. group_id = client->GetPlayer()->GetGroupMemberInfo()->group_id;
  2393. bool send_kicked_message = world.GetGroupManager()->GetGroupSize(group_id) > 2;
  2394. if (kicked)
  2395. world.GetGroupManager()->RemoveGroupMember(group_id, kicked);
  2396. if(send_kicked_message)
  2397. world.GetGroupManager()->GroupMessage(group_id, "%s was kicked from the group.", kicked->GetName());
  2398. else
  2399. client->Message(CHANNEL_GROUP_CHAT, "You kicked %s from the group", kicked->GetName());
  2400. if (kicked_client)
  2401. kicked_client->SimpleMessage(CHANNEL_GROUP_CHAT, "You were kicked from the group");
  2402. break;
  2403. }
  2404. case COMMAND_GROUP_MAKE_LEADER:{
  2405. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  2406. client->SimpleMessage(CHANNEL_COMMANDS, "You are not a group leader.");
  2407. return;
  2408. }
  2409. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 1) {
  2410. Client* new_leader = zone_list.GetClientByCharName(sep->arg[0]);
  2411. if (new_leader) {
  2412. if (client->GetPlayer()->IsGroupMember(new_leader->GetPlayer())) {
  2413. world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, new_leader->GetPlayer());
  2414. }
  2415. }
  2416. else
  2417. client->SimpleMessage(CHANNEL_COMMANDS, "Unable to find the given player.");
  2418. }
  2419. else if (cmdTarget && cmdTarget->IsPlayer())
  2420. world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, (Entity*)cmdTarget);
  2421. else
  2422. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to change group leader.");
  2423. break;
  2424. }
  2425. case COMMAND_GROUP_ACCEPT_INVITE: {
  2426. if(sep && sep->arg[0] && strcmp(sep->arg[0], "group") == 0) {
  2427. int8 result = world.GetGroupManager()->AcceptInvite(client->GetPlayer());
  2428. if (result == 0)
  2429. client->SimpleMessage(CHANNEL_GROUP_CHAT, "You have joined the group.");
  2430. else if (result == 1)
  2431. client->SimpleMessage(CHANNEL_GROUP_CHAT, "You do not have a pending invite.");
  2432. else if (result == 2)
  2433. client->SimpleMessage(CHANNEL_GROUP_CHAT, "Unable to join group - could not find leader.");
  2434. else
  2435. client->SimpleMessage(CHANNEL_GROUP_CHAT, "Unable to join group - unknown error.");
  2436. }
  2437. break;
  2438. }
  2439. case COMMAND_GROUP_DECLINE_INVITE: {
  2440. if(sep && sep->arg[0] && strcmp(sep->arg[0], "group") == 0) {
  2441. world.GetGroupManager()->DeclineInvite(client->GetPlayer()); // TODO: Add message to leader
  2442. }
  2443. break;
  2444. }
  2445. case COMMAND_SUMMON:{
  2446. char* search_name = 0;
  2447. if(sep && sep->arg[0][0])
  2448. search_name = sep->arg[0];
  2449. if(!search_name && !cmdTarget){
  2450. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /summon [name]");
  2451. 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.");
  2452. }
  2453. else{
  2454. if(!client->Summon(search_name))
  2455. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  2456. }
  2457. break;
  2458. }
  2459. case COMMAND_GOTO:{
  2460. const char* search_name = 0;
  2461. if(sep && sep->arg[0][0])
  2462. search_name = sep->argplus[0];
  2463. if(!search_name && !cmdTarget){
  2464. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /goto [name]");
  2465. 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.");
  2466. }
  2467. else{
  2468. if(!client->GotoSpawn(search_name))
  2469. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  2470. }
  2471. break;
  2472. }
  2473. case COMMAND_MOVE:{
  2474. bool success = false;
  2475. try{
  2476. if(sep && sep->arg[2][0] && sep->IsNumber(0) && sep->IsNumber(1) && sep->IsNumber(2)){
  2477. EQ2Packet* app = client->GetPlayer()->Move(atof(sep->arg[0]), atof(sep->arg[1]), atof(sep->arg[2]), client->GetVersion());
  2478. if(app){
  2479. client->QueuePacket(app);
  2480. success = true;
  2481. }
  2482. }
  2483. }
  2484. catch(...){}
  2485. if(!success){
  2486. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /move x y z");
  2487. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Moves the client to the given coordinates.");
  2488. }
  2489. break;
  2490. }
  2491. case COMMAND_SETTIME:{
  2492. if(sep && sep->arg[0]){
  2493. sscanf (sep->arg[0], "%d:%d", &world.GetWorldTimeStruct()->hour, &world.GetWorldTimeStruct()->minute);
  2494. if(sep->arg[1] && sep->IsNumber(1))
  2495. world.GetWorldTimeStruct()->month = atoi(sep->arg[1]) - 1; //zero based indexes
  2496. if(sep->arg[2] && sep->IsNumber(2))
  2497. world.GetWorldTimeStruct()->day = atoi(sep->arg[2]) - 1; //zero based indexes
  2498. if(sep->arg[3] && sep->IsNumber(3))
  2499. world.GetWorldTimeStruct()->year = atoi(sep->arg[3]);
  2500. client->GetCurrentZone()->SendTimeUpdateToAllClients();
  2501. }
  2502. else{
  2503. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /settime [hour:minute] (month) (day) (year)");
  2504. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Example: /settime 8:30");
  2505. }
  2506. break;
  2507. }
  2508. case COMMAND_VERSION:{
  2509. client->Message(CHANNEL_COLOR_YELLOW,"%s %s", EQ2EMU_MODULE, CURRENT_VERSION);
  2510. client->Message(CHANNEL_COLOR_YELLOW,"Last Compiled on %s %s", COMPILE_DATE, COMPILE_TIME);
  2511. break;
  2512. }
  2513. case COMMAND_ZONE:{
  2514. int32 instanceID = 0;
  2515. string zone;
  2516. int32 zone_id = 0;
  2517. bool listSearch = false;
  2518. bool isInstance = false;
  2519. ZoneServer* zsZone = 0;
  2520. if(sep && sep->arg[0][0])
  2521. {
  2522. if(strncasecmp(sep->arg[0], "list", 4) == 0)
  2523. listSearch = true;
  2524. else if(strncasecmp(sep->arg[0], "active", 6) == 0)
  2525. {
  2526. zone_list.SendZoneList(client);
  2527. break;
  2528. }
  2529. else if(strncasecmp(sep->arg[0], "instance", 6) == 0)
  2530. {
  2531. if(sep->IsNumber(1))
  2532. instanceID = atol(sep->arg[1]);
  2533. }
  2534. else if(strncasecmp(sep->arg[0], "lock", 4) == 0)
  2535. {
  2536. PrintSep(sep, "ZONE LOCK");
  2537. if(sep->IsNumber(1))
  2538. zsZone = zone_list.Get(atoul(sep->arg[1]), false);
  2539. else
  2540. zsZone = zone_list.Get(sep->arg[1], false);
  2541. if( zsZone )
  2542. {
  2543. zsZone->SetZoneLockState(true);
  2544. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now locked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  2545. }
  2546. else
  2547. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be locked.", sep->arg[1]);
  2548. break;
  2549. }
  2550. else if(strncasecmp(sep->arg[0], "unlock", 6) == 0)
  2551. {
  2552. PrintSep(sep, "ZONE UNLOCK");
  2553. if(sep->IsNumber(1))
  2554. zsZone = zone_list.Get(atoul(sep->arg[1]), false);
  2555. else
  2556. zsZone = zone_list.Get(sep->arg[1], false);
  2557. if( zsZone )
  2558. {
  2559. zsZone->SetZoneLockState(false);
  2560. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now unlocked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  2561. }
  2562. else
  2563. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be unlocked.", sep->arg[1]);
  2564. break;
  2565. }
  2566. else
  2567. {
  2568. if(sep->IsNumber(0))
  2569. {
  2570. zone_id = atoul(sep->arg[0]);
  2571. string zonename = database.GetZoneName(zone_id);
  2572. if(zonename.length() > 0)
  2573. zone = zonename;
  2574. }
  2575. else
  2576. zone = sep->arg[0];
  2577. }
  2578. if(instanceID > 0)
  2579. {
  2580. ZoneServer* zsInstance = zone_list.GetByInstanceID(instanceID);
  2581. if(zsInstance != NULL)
  2582. {
  2583. instanceID = zsInstance->GetInstanceID();
  2584. zone = zsInstance->GetZoneName();
  2585. zone_id = zsInstance->GetZoneID();
  2586. isInstance = true;
  2587. }
  2588. }
  2589. }
  2590. if(!listSearch)
  2591. {
  2592. if(zone.length() == 0)
  2593. client->Message(CHANNEL_COLOR_RED, "Error: Invalid Zone");
  2594. else if(instanceID != client->GetCurrentZone()->GetInstanceID() ||
  2595. zone_id != client->GetCurrentZone()->GetZoneID())
  2596. {
  2597. const char* zonestr = zone.c_str();
  2598. if(database.VerifyZone(zonestr))
  2599. {
  2600. if(client->CheckZoneAccess(zonestr))
  2601. {
  2602. client->Message(CHANNEL_COLOR_YELLOW,"Zoning to %s...", zonestr);
  2603. if(isInstance)
  2604. client->Zone(instanceID,true,true);
  2605. else
  2606. client->Zone(zonestr);
  2607. }
  2608. }
  2609. else
  2610. client->Message(CHANNEL_COLOR_RED, "Error: Zone '%s' not found. To get a list type /zone list", zonestr);
  2611. }
  2612. else
  2613. client->Message(CHANNEL_COLOR_RED, "Error: You are already in that zone!");
  2614. }
  2615. else
  2616. {
  2617. const char* name = 0;
  2618. if(sep && sep->arg[1][0])
  2619. {
  2620. map<int32, string>* zone_names;
  2621. name = sep->argplus[1];
  2622. sint16 status = client->GetAdminStatus();
  2623. if( status > 0 )
  2624. {
  2625. client->SimpleMessage(CHANNEL_COLOR_RED, "ADMIN MODE");
  2626. zone_names = database.GetZoneList(name, true);
  2627. }
  2628. else
  2629. zone_names = database.GetZoneList(name);
  2630. if(!zone_names)
  2631. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No zones found.");
  2632. else
  2633. {
  2634. map<int32, string>::iterator itr;
  2635. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  2636. for(itr = zone_names->begin(); itr != zone_names->end(); itr++)
  2637. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  2638. safe_delete(zone_names);
  2639. }
  2640. }
  2641. else
  2642. {
  2643. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone [zone name]");
  2644. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone list [partial zone name]");
  2645. }
  2646. }
  2647. break;
  2648. }
  2649. case COMMAND_USE: {
  2650. Spawn* target = cmdTarget;
  2651. if (target->IsWidget())
  2652. ((Widget*)target)->HandleUse(client, "use");
  2653. break;
  2654. }
  2655. case COMMAND_OPEN: {
  2656. Spawn* target = cmdTarget;
  2657. if (target->IsWidget())
  2658. ((Widget*)target)->HandleUse(client, "Open", WIDGET_TYPE_DOOR);
  2659. break;
  2660. }
  2661. case COMMAND_CASTSPELL: {
  2662. if (sep && sep->arg[0] && sep->IsNumber(0))
  2663. {
  2664. int8 tier = 1;
  2665. if (sep->arg[1] && sep->IsNumber(1))
  2666. tier = atoul(sep->arg[1]);
  2667. int32 spellid = atoul(sep->arg[0]);
  2668. Spell* spell = master_spell_list.GetSpell(spellid, tier);
  2669. if (spell)
  2670. {
  2671. client->Message(CHANNEL_COLOR_RED, "Casting spell %u.", spellid);
  2672. SpellProcess* spellProcess = 0;
  2673. // Get the current zones spell process
  2674. spellProcess = client->GetCurrentZone()->GetSpellProcess();
  2675. spellProcess->CastInstant(spell, (Entity*)client->GetPlayer(), (cmdTarget && cmdTarget->IsEntity()) ? (Entity*)cmdTarget : (Entity*)client->GetPlayer());
  2676. }
  2677. else
  2678. {
  2679. client->Message(CHANNEL_COLOR_RED, "Could not find spell %u.",spellid);
  2680. }
  2681. }
  2682. else if (sep && sep->arg[0])
  2683. {
  2684. database.FindSpell(client, (char*)sep->argplus[0]);
  2685. }
  2686. else
  2687. {
  2688. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellid] (tier=1) - Cast Spell with specified spell id, tier is optional, default of 1.");
  2689. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellname] - Find spells wildcard match with a partial spell name");
  2690. }
  2691. break;
  2692. }
  2693. case COMMAND_KNOWLEDGEWINDOWSORT: {
  2694. if (client->GetVersion() <= 546)
  2695. break;
  2696. if (sep && sep->GetArgNumber() == 4)
  2697. {
  2698. int32 book = atoul(sep->arg[0]); // 0 - spells, 1 - combat, 2 - abilities, 3 - tradeskill
  2699. int32 sort_by = atoul(sep->arg[1]); // 0 - alpha, 1 - level, 2 - category
  2700. int32 order = atoul(sep->arg[2]); // 0 - ascending, 1 - descending
  2701. int32 pattern = atoul(sep->arg[3]); // 0 - zigzag, 1 - down, 2 - across
  2702. int32 maxlvlonly = atoul(sep->arg[4]); // 0 - zigzag, 1 - down, 2 - across
  2703. client->GetPlayer()->ResortSpellBook(sort_by, order, pattern, maxlvlonly, book);
  2704. ClientPacketFunctions::SendSkillSlotMappings(client);
  2705. }
  2706. else
  2707. {
  2708. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /knowledgewindow_sort [book] [sort_by] [order] [pattern]");
  2709. }
  2710. break;
  2711. }
  2712. case COMMAND_MOVE_ITEM:
  2713. {
  2714. int32 id = 0;
  2715. if (sep->IsNumber(0))
  2716. id = atoul(sep->arg[0]);
  2717. Spawn* spawn = 0;
  2718. if (id == 0)
  2719. {
  2720. spawn = cmdTarget;
  2721. }
  2722. else
  2723. spawn = client->GetCurrentZone()->GetSpawnFromUniqueItemID(id);
  2724. if (!spawn || !client->HasOwnerOrEditAccess() || !spawn->GetPickupItemID())
  2725. break;
  2726. client->SendMoveObjectMode(spawn, 0);
  2727. break;
  2728. }
  2729. case COMMAND_PICKUP:
  2730. {
  2731. int32 id = 0;
  2732. if (sep->IsNumber(0))
  2733. id = atoul(sep->arg[0]);
  2734. Spawn* spawn = 0;
  2735. if (id == 0)
  2736. {
  2737. spawn = cmdTarget;
  2738. }
  2739. else
  2740. spawn = client->GetCurrentZone()->GetSpawnFromUniqueItemID(id);
  2741. if (!spawn || !client->HasOwnerOrEditAccess() || !spawn->GetPickupItemID())
  2742. break;
  2743. client->AddItem(spawn->GetPickupItemID(), 1);
  2744. Query query;
  2745. 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());
  2746. if (database.RemoveSpawnFromSpawnLocation(spawn)) {
  2747. client->GetCurrentZone()->RemoveSpawn(spawn, true, true);
  2748. }
  2749. // we had a UI Window displayed, update the house items
  2750. if ( id > 0 )
  2751. client->GetCurrentZone()->SendHouseItems(client);
  2752. break;
  2753. }
  2754. case COMMAND_HOUSE_DEPOSIT:
  2755. {
  2756. PrintSep(sep, "COMMAND_HOUSE_DEPOSIT");
  2757. // arg0 = ??? (set to 3)
  2758. // arg1 = coin (in copper)
  2759. // arg2 = status? (not implemented yet)
  2760. PlayerHouse* ph = world.GetPlayerHouseByInstanceID(client->GetCurrentZone()->GetInstanceID());
  2761. if (ph && sep && sep->IsNumber(1))
  2762. {
  2763. int64 outVal = strtoull(sep->arg[1], NULL, 0);
  2764. if (client->GetPlayer()->RemoveCoins(outVal))
  2765. {
  2766. char query[256];
  2767. map<string,Deposit>::iterator itr = ph->depositsMap.find(string(client->GetPlayer()->GetName()));
  2768. if (itr != ph->depositsMap.end())
  2769. {
  2770. 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());
  2771. }
  2772. else
  2773. 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);
  2774. if (database.RunQuery(query, strnlen(query, 256)))
  2775. {
  2776. ph->escrow_coins += outVal;
  2777. database.UpdateHouseEscrow(ph->house_id, ph->instance_id, ph->escrow_coins);
  2778. database.LoadDeposits(ph);
  2779. client->PlaySound("coin_cha_ching");
  2780. HouseZone* hz = world.GetHouseZone(ph->house_id);
  2781. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  2782. }
  2783. else
  2784. {
  2785. client->GetPlayer()->AddCoins(outVal);
  2786. client->SimpleMessage(CHANNEL_COLOR_RED, "Deposit failed!");
  2787. }
  2788. }
  2789. }
  2790. break;
  2791. }
  2792. case COMMAND_HOUSE:
  2793. {
  2794. if (sep && sep->IsNumber(0))
  2795. {
  2796. int32 unique_id = atoi(sep->arg[0]);
  2797. PlayerHouse* ph = world.GetPlayerHouseByUniqueID(unique_id);
  2798. HouseZone* hz = 0;
  2799. if (ph)
  2800. hz = world.GetHouseZone(ph->house_id);
  2801. // there is a arg[1] that is true/false, but not sure what it is for investigate more later
  2802. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  2803. }
  2804. else if (client->GetCurrentZone()->GetInstanceType() != 0)
  2805. {
  2806. // inside a house or something? Send the access window
  2807. PlayerHouse* ph = world.GetPlayerHouseByInstanceID(client->GetCurrentZone()->GetInstanceID());
  2808. HouseZone* hz = 0;
  2809. if ( ph )
  2810. hz = world.GetHouseZone(ph->house_id);
  2811. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  2812. client->GetCurrentZone()->SendHouseItems(client);
  2813. }
  2814. break;
  2815. }
  2816. case COMMAND_HOUSE_UI:
  2817. {
  2818. if (sep && sep->IsNumber(0) && client->GetCurrentZone()->GetInstanceType() == Instance_Type::NONE)
  2819. {
  2820. int32 unique_id = atoi(sep->arg[0]);
  2821. PlayerHouse* ph = world.GetPlayerHouseByUniqueID(unique_id);
  2822. HouseZone* hz = 0;
  2823. if ( ph )
  2824. hz = world.GetHouseZone(ph->house_id);
  2825. // there is a arg[1] that is true/false, but not sure what it is for investigate more later
  2826. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, 0);
  2827. }
  2828. break;
  2829. }
  2830. case COMMAND_PLACE_HOUSE_ITEM: {
  2831. if (sep && sep->IsNumber(0))
  2832. {
  2833. int32 uniqueid = atoi(sep->arg[0]);
  2834. Item* item = client->GetPlayer()->item_list.GetItemFromUniqueID(uniqueid);
  2835. //Item* item = player->GetEquipmentList()->GetItem(slot);
  2836. if (item && item->IsHouseItem())
  2837. {
  2838. if (!client->HasOwnerOrEditAccess())
  2839. {
  2840. client->SimpleMessage(CHANNEL_COLOR_RED, "This is not your home!");
  2841. break;
  2842. }
  2843. else if (!item->generic_info.appearance_id)
  2844. {
  2845. 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);
  2846. break;
  2847. }
  2848. if (client->GetTempPlacementSpawn())
  2849. {
  2850. Spawn* tmp = client->GetTempPlacementSpawn();
  2851. client->GetCurrentZone()->RemoveSpawn(tmp);
  2852. client->SetTempPlacementSpawn(nullptr);
  2853. }
  2854. Spawn* spawn = new Object();
  2855. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  2856. spawn->SetID(Spawn::NextID());
  2857. spawn->SetX(client->GetPlayer()->GetX());
  2858. spawn->SetY(client->GetPlayer()->GetY());
  2859. spawn->SetZ(client->GetPlayer()->GetZ());
  2860. spawn->SetHeading(client->GetPlayer()->GetHeading());
  2861. spawn->SetSpawnOrigX(spawn->GetX());
  2862. spawn->SetSpawnOrigY(spawn->GetY());
  2863. spawn->SetSpawnOrigZ(spawn->GetZ());
  2864. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  2865. spawn->appearance.targetable = 1;
  2866. spawn->appearance.activity_status = ACTIVITY_STATUS_SOLID;
  2867. spawn->appearance.race = item && item->generic_info.appearance_id ? item->generic_info.appearance_id : 1472;
  2868. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  2869. spawn->SetModelType(item && item->generic_info.appearance_id ? item->generic_info.appearance_id : 1472);
  2870. spawn->SetZone(client->GetCurrentZone());
  2871. client->GetCurrentZone()->SendSpawn(spawn, client);
  2872. client->SetTempPlacementSpawn(spawn);
  2873. client->SetPlacementUniqueItemID(uniqueid);
  2874. client->SendMoveObjectMode(spawn, 0);
  2875. }
  2876. }
  2877. break;
  2878. }
  2879. case COMMAND_GM:
  2880. {
  2881. if (sep->arg[0] && sep->arg[1])
  2882. {
  2883. bool onOff = (strcmp(sep->arg[1], "on") == 0);
  2884. if (strcmp(sep->arg[0], "vision") == 0)
  2885. {
  2886. client->GetPlayer()->SetGMVision(onOff);
  2887. #if defined(__GNUC__)
  2888. database.insertCharacterProperty(client, CHAR_PROPERTY_GMVISION, (onOff) ? (char*)"1" : (char*)"0");
  2889. #else
  2890. database.insertCharacterProperty(client, CHAR_PROPERTY_GMVISION, (onOff) ? "1" : "0");
  2891. #endif
  2892. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  2893. if (onOff)
  2894. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Vision Enabled!");
  2895. else
  2896. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Vision Disabled!");
  2897. }
  2898. else if (strcmp(sep->arg[0], "regiondebug") == 0)
  2899. {
  2900. client->SetRegionDebug(onOff);
  2901. #if defined(__GNUC__)
  2902. database.insertCharacterProperty(client, CHAR_PROPERTY_REGIONDEBUG, (onOff) ? (char*)"1" : (char*)"0");
  2903. #else
  2904. database.insertCharacterProperty(client, CHAR_PROPERTY_REGIONDEBUG, (onOff) ? "1" : "0");
  2905. #endif
  2906. if (onOff)
  2907. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Region Debug Enabled!");
  2908. else
  2909. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Region Debug Disabled!");
  2910. }
  2911. else if (strcmp(sep->arg[0], "luadebug") == 0)
  2912. {
  2913. client->SetLuaDebugClient(onOff);
  2914. #if defined(__GNUC__)
  2915. database.insertCharacterProperty(client, CHAR_PROPERTY_LUADEBUG, (onOff) ? (char*)"1" : (char*)"0");
  2916. #else
  2917. database.insertCharacterProperty(client, CHAR_PROPERTY_LUADEBUG, (onOff) ? "1" : "0");
  2918. #endif
  2919. if (onOff)
  2920. {
  2921. if (lua_interface)
  2922. lua_interface->UpdateDebugClients(client);
  2923. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will now receive LUA error messages.");
  2924. }
  2925. else
  2926. {
  2927. if (lua_interface)
  2928. lua_interface->RemoveDebugClients(client);
  2929. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will no longer receive LUA error messages.");
  2930. }
  2931. }
  2932. }
  2933. break;
  2934. }
  2935. case COMMAND_ATTACK:
  2936. case COMMAND_AUTO_ATTACK:{
  2937. int8 type = 1;
  2938. Player* player = client->GetPlayer();
  2939. if(!player)
  2940. break;
  2941. bool incombat = player->EngagedInCombat();
  2942. if(sep && sep->arg[0] && sep->IsNumber(0))
  2943. type = atoi(sep->arg[0]);
  2944. if(client->GetPlayer()->GetHP() == 0){
  2945. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  2946. break;
  2947. }
  2948. if(type == 0){
  2949. if(incombat)
  2950. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You stop fighting.");
  2951. player->InCombat(false);
  2952. player->InCombat(false, true);
  2953. player->SetRangeAttack(false);
  2954. }
  2955. else {
  2956. if(type == 2){
  2957. player->InCombat(false);
  2958. if(incombat && player->GetRangeAttack()){
  2959. player->SetRangeAttack(false);
  2960. player->InCombat(false, true);
  2961. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You stop fighting.");
  2962. }
  2963. else{
  2964. player->SetRangeAttack(true);
  2965. player->InCombat(true, true);
  2966. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You start fighting.");
  2967. }
  2968. }
  2969. else {
  2970. player->InCombat(false, true);
  2971. player->SetRangeAttack(false);
  2972. player->InCombat(true);
  2973. if(!incombat)
  2974. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You start fighting.");
  2975. }
  2976. /*else
  2977. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You cannot attack that!");*/
  2978. }
  2979. player->SetCharSheetChanged(true);
  2980. break;
  2981. }
  2982. case COMMAND_DEPOP:{
  2983. bool allow_respawns = false;
  2984. if(sep && sep->arg[0] && sep->IsNumber(0)){
  2985. if(atoi(sep->arg[0]) == 1)
  2986. allow_respawns = true;
  2987. }
  2988. client->GetCurrentZone()->Depop(allow_respawns);
  2989. break;
  2990. }
  2991. case COMMAND_REPOP:{
  2992. client->GetCurrentZone()->Depop(false, true);
  2993. break;
  2994. }
  2995. case COMMAND_BUYBACK:{
  2996. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  2997. // 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
  2998. int64 id = atoi64(sep->arg[0]);
  2999. // get the first int32, the item id
  3000. //int32 item_id = (int32)id;
  3001. // get the second int32, the unique id
  3002. int32 unique_id = (int32)(id>>32);
  3003. int8 quantity = atoi(sep->arg[1]);
  3004. if(quantity == 255)
  3005. quantity = 1;
  3006. client->BuyBack(unique_id, quantity);
  3007. }
  3008. break;
  3009. }
  3010. case COMMAND_MERCHANT_BUY:{
  3011. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  3012. int32 item_id = atoul(sep->arg[0]);
  3013. int8 quantity = atoi(sep->arg[1]);
  3014. client->BuyItem(item_id, quantity);
  3015. }
  3016. else
  3017. Command_SendMerchantWindow(client, sep);
  3018. break;
  3019. }
  3020. case COMMAND_MERCHANT_SELL:{
  3021. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  3022. // 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
  3023. int64 id = atoi64(sep->arg[0]);
  3024. // get the first int32, the item id
  3025. int32 item_id = (int32)id;
  3026. // get the second int32, the unique id
  3027. int32 unique_id = (int32)(id>>32);
  3028. int8 quantity = atoi(sep->arg[1]);
  3029. LogWrite(MERCHANT__DEBUG, 0, "Merchant", "Selling Item: Item Id = %ul, unique id = %ul, Quantity = %i", item_id, unique_id, quantity);
  3030. client->SellItem(item_id, quantity, unique_id);
  3031. }
  3032. break;
  3033. }
  3034. case COMMAND_MENDER_REPAIR: {
  3035. if (sep && sep->arg[0] && sep->IsNumber(0))
  3036. client->RepairItem(atoul(sep->arg[0]));
  3037. break;
  3038. }
  3039. case COMMAND_MENDER_REPAIR_ALL: {
  3040. client->RepairAllItems();
  3041. break;
  3042. }
  3043. case COMMAND_CANCEL_MERCHANT:{
  3044. client->SetMerchantTransaction(0);
  3045. break;
  3046. }
  3047. case COMMAND_START_MERCHANT:{
  3048. break;
  3049. }
  3050. case COMMAND_INVULNERABLE:{
  3051. sint8 val = -1;
  3052. if(sep && sep->arg[0] && sep->IsNumber(0)){
  3053. val = atoi(sep->arg[0]);
  3054. //devn00b: Fix for linux builds
  3055. #if defined(__GNUC__)
  3056. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? (char*) "1" : (char*) "0");
  3057. #else
  3058. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  3059. #endif
  3060. // database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  3061. client->GetPlayer()->SetInvulnerable(val==1);
  3062. if(client->GetPlayer()->GetInvulnerable())
  3063. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are now invulnerable!");
  3064. else
  3065. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are no longer invulnerable!");
  3066. }
  3067. if(val == -1)
  3068. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /invulnerable [0/1]");
  3069. break;
  3070. }
  3071. case COMMAND_REPAIR: {
  3072. Spawn* spawn = cmdTarget;
  3073. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR) {
  3074. client->SendHailCommand(spawn);
  3075. client->SetMerchantTransaction(spawn);
  3076. client->SendRepairList();
  3077. }
  3078. break;
  3079. }
  3080. case COMMAND_LOTTO: {
  3081. Spawn* spawn = cmdTarget;
  3082. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_LOTTO) {
  3083. client->SetMerchantTransaction(spawn);
  3084. client->ShowLottoWindow();
  3085. }
  3086. break;
  3087. }
  3088. case COMMAND_ACCEPT_REWARD:{
  3089. int32 unknown = 0;
  3090. int32 selectable_item_id = 0;
  3091. //Quest *quest = 0;
  3092. Collection *collection = 0;
  3093. /* no idea what the first argument is for (faction maybe?)
  3094. if the reward has a selectable item reward, it's sent as the second argument
  3095. if neither of these are included in the reward, there is no sep
  3096. 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
  3097. only 1 quest or collection reward may be displayed at a time */
  3098. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  3099. unknown = atoul(sep->arg[0]);
  3100. selectable_item_id = atoul(sep->arg[1]);
  3101. }
  3102. //if ((quest = player->GetPendingQuestReward()))
  3103. // client->AcceptQuestRewards(quest, selectable_item_id);
  3104. /* the below needs to go away eventually and be redone */
  3105. int32 item_id = 0;
  3106. if(sep && sep->arg[0][0] && sep->IsNumber(0))
  3107. item_id = atoul(sep->arg[0]);
  3108. Quest* quest = client->GetPendingQuestAcceptance(item_id);
  3109. if(quest){
  3110. client->AcceptQuestReward(quest, item_id);
  3111. break;
  3112. }
  3113. bool collectedItems = false;
  3114. if (collection = player->GetPendingCollectionReward())
  3115. client->AcceptCollectionRewards(collection, selectable_item_id);
  3116. else if (client->GetPlayer()->HasPendingItemRewards()) {
  3117. vector<Item*> items = client->GetPlayer()->GetPendingItemRewards();
  3118. if (items.size() > 0) {
  3119. collectedItems = true;
  3120. for (int i = 0; i < items.size(); i++) {
  3121. client->GetPlayer()->AddItem(new Item(items[i]));
  3122. }
  3123. client->GetPlayer()->ClearPendingItemRewards();
  3124. }
  3125. map<int32, Item*> selectable_item = client->GetPlayer()->GetPendingSelectableItemReward(item_id);
  3126. if (selectable_item.size() > 0) {
  3127. collectedItems = true;
  3128. map<int32, Item*>::iterator itr;
  3129. for (itr = selectable_item.begin(); itr != selectable_item.end(); itr++) {
  3130. client->GetPlayer()->AddItem(new Item(itr->second));
  3131. client->GetPlayer()->ClearPendingSelectableItemRewards(itr->first);
  3132. }
  3133. }
  3134. }
  3135. if (collectedItems) {
  3136. EQ2Packet* outapp = client->GetPlayer()->SendInventoryUpdate(client->GetVersion());
  3137. if (outapp)
  3138. client->QueuePacket(outapp);
  3139. }
  3140. else
  3141. LogWrite(COMMAND__ERROR, 0, "Command", "Error in COMMAND_ACCEPT_REWARD. No pending quest or collection reward was found (unknown=%u).", unknown);
  3142. break;
  3143. }
  3144. case COMMAND_BUY_FROM_BROKER:{
  3145. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  3146. int32 item_id = atoul(sep->arg[0]);
  3147. int16 quantity = atoul(sep->arg[1]);
  3148. client->AddItem(item_id, quantity);
  3149. }
  3150. break;
  3151. }
  3152. case COMMAND_SEARCH_STORES_PAGE:{
  3153. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  3154. int32 page = atoul(sep->arg[0]);
  3155. client->SearchStore(page);
  3156. }
  3157. break;
  3158. }
  3159. case COMMAND_SEARCH_STORES:{
  3160. if(sep && sep->arg[0][0]){
  3161. const char* values = sep->argplus[0];
  3162. if(values){
  3163. map<string, string> str_values = TranslateBrokerRequest(values);
  3164. vector<Item*>* items = master_item_list.GetItems(str_values);
  3165. if(items){
  3166. client->SetItemSearch(items);
  3167. client->SearchStore(0);
  3168. }
  3169. }
  3170. }
  3171. break;
  3172. }
  3173. case COMMAND_LUADEBUG:{
  3174. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "start") == 0){
  3175. client->SetLuaDebugClient(true);
  3176. if(lua_interface)
  3177. lua_interface->UpdateDebugClients(client);
  3178. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will now receive LUA error messages.");
  3179. }
  3180. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "stop") == 0){
  3181. client->SetLuaDebugClient(false);
  3182. if(lua_interface)
  3183. lua_interface->RemoveDebugClients(client);
  3184. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will no longer receive LUA error messages.");
  3185. }
  3186. else{
  3187. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /luadebug {start | stop}");
  3188. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will allow you to receive lua debug messages normally seen only in the console.");
  3189. }
  3190. break;
  3191. }
  3192. case COMMAND_SPAWN_GROUP:
  3193. {
  3194. Spawn* target = cmdTarget;
  3195. if(target && target->IsPlayer() == false)
  3196. {
  3197. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "create") == 0)
  3198. {
  3199. if(target->GetSpawnLocationPlacementID() > 0)
  3200. {
  3201. if(sep->arg[1] && !sep->IsNumber(1) && strlen(sep->arg[1]) > 0)
  3202. {
  3203. int32 id = database.CreateSpawnGroup(target, sep->arg[1]);
  3204. if(id > 0)
  3205. client->Message(CHANNEL_COLOR_YELLOW, "Successfully created new spawn group with id: %u", id);
  3206. else
  3207. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error creating group, check console for details.");
  3208. target->SetSpawnGroupID(id);
  3209. target->AddSpawnToGroup(target);
  3210. }
  3211. else
  3212. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group create [name]");
  3213. }
  3214. else
  3215. 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.");
  3216. }
  3217. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "add") == 0)
  3218. {
  3219. if(sep->arg[1] && sep->IsNumber(1))
  3220. {
  3221. int32 group_id = atoul(sep->arg[1]);
  3222. Spawn* leader = client->GetCurrentZone()->GetSpawnGroup(group_id);
  3223. if(leader)
  3224. {
  3225. leader->AddSpawnToGroup(target);
  3226. target->SetSpawnGroupID(group_id);
  3227. if(database.SpawnGroupAddSpawn(target, group_id))
  3228. client->Message(CHANNEL_COLOR_YELLOW, "Successfully added '%s' to group id: %u", target->GetName(), group_id);
  3229. else
  3230. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error adding spawn to group, check console for details.");
  3231. }
  3232. else
  3233. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No spawns found in the current zone for that spawn group, be sure to use '/spawn group create' first!");
  3234. }
  3235. else
  3236. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group add [group id]");
  3237. }
  3238. else if(target->GetSpawnGroupID() == 0)
  3239. {
  3240. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That spawn is not in a group!");
  3241. }
  3242. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "remove") == 0)
  3243. {
  3244. int32 group_id = target->GetSpawnGroupID();
  3245. target->RemoveSpawnFromGroup();
  3246. if(database.SpawnGroupRemoveSpawn(target, group_id))
  3247. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed '%s' from group id: %u", target->GetName(), group_id);
  3248. else
  3249. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing spawn from group, check console for details.");
  3250. }
  3251. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "associate") == 0)
  3252. {
  3253. int32 group_id = target->GetSpawnGroupID();
  3254. if(sep->arg[1] && sep->IsNumber(1))
  3255. {
  3256. if(database.SpawnGroupAddAssociation(group_id, atoul(sep->arg[1])))
  3257. client->Message(CHANNEL_COLOR_YELLOW, "Successfully associated group id %u with group id %u", group_id, atoul(sep->arg[1]));
  3258. else
  3259. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error associating groups, check console for details.");
  3260. }
  3261. else
  3262. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Allows you to spawn only one associated group at once. Syntax: /spawn group associate [other group id]");
  3263. }
  3264. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "deassociate") == 0)
  3265. {
  3266. int32 group_id = target->GetSpawnGroupID();
  3267. if(sep->arg[1] && sep->IsNumber(1))
  3268. {
  3269. if(database.SpawnGroupRemoveAssociation(group_id, atoul(sep->arg[1])))
  3270. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed association between group id %u and group id %u", group_id, atoul(sep->arg[1]));
  3271. else
  3272. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing group associations, check console for details.");
  3273. }
  3274. else
  3275. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Removes previous group associations. Syntax: /spawn group deassociate [other group id]");
  3276. }
  3277. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "chance") == 0)
  3278. {
  3279. if(sep->arg[1] && sep->IsNumber(1))
  3280. {
  3281. if(database.SetGroupSpawnChance(target->GetSpawnGroupID(), atof(sep->arg[1])))
  3282. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set group spawn chance to %f for group id: %u", atof(sep->arg[1]), target->GetSpawnGroupID());
  3283. else
  3284. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error setting group spawn chance, check console for details.");
  3285. }
  3286. else
  3287. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group chance [group's spawn chance percentage]");
  3288. }
  3289. else
  3290. {
  3291. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command allows you to modify spawn groups.");
  3292. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group [create/add/remove/chance/associate/deassociate]");
  3293. }
  3294. }
  3295. else
  3296. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select a valid spawn to use this command.");
  3297. break;
  3298. }
  3299. case COMMAND_SPAWN_COMBINE:{
  3300. Spawn* spawn = cmdTarget;
  3301. float radius = 0;
  3302. bool failed = true;
  3303. if(spawn && !spawn->IsPlayer() && sep && sep->arg[0] && sep->arg[0][0]){
  3304. failed = false;
  3305. if(spawn->GetSpawnGroupID() > 0){
  3306. 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.");
  3307. }
  3308. else if(sep->IsNumber(0)){
  3309. radius = atof(sep->arg[0]);
  3310. client->CombineSpawns(radius, spawn);
  3311. }
  3312. else{
  3313. if(strncasecmp(sep->arg[0], "add", 3) == 0){
  3314. client->AddCombineSpawn(spawn);
  3315. }
  3316. else if(strncasecmp(sep->arg[0], "remove", 6) == 0){
  3317. client->RemoveCombineSpawn(spawn);
  3318. }
  3319. else if(strncasecmp(sep->arg[0], "save", 4) == 0){
  3320. const char* name = 0;
  3321. if(sep->arg[1] && sep->arg[1][0])
  3322. name = sep->argplus[1];
  3323. client->SaveCombineSpawns(name);
  3324. }
  3325. else
  3326. failed = true;
  3327. }
  3328. }
  3329. if(failed){
  3330. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command combines several spawns into a single spawn group.");
  3331. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn combine [radius/add/remove/save]");
  3332. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Ex: /spawn combine 1, /spawn combine save (spawn group name)");
  3333. }
  3334. break;
  3335. }
  3336. case COMMAND_SPAWN_CREATE:{
  3337. Spawn* spawn = 0;
  3338. if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "object", 6) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  3339. spawn = new Object();
  3340. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3341. }
  3342. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "groundspawn", 11) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  3343. spawn = new GroundSpawn();
  3344. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3345. }
  3346. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "sign", 4) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  3347. spawn = new Sign();
  3348. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3349. }
  3350. else if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "npc", 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  3351. spawn = new NPC();
  3352. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3353. spawn->appearance.pos.collision_radius = 32;
  3354. spawn->secondary_command_list_id = 0;
  3355. spawn->primary_command_list_id = 0;
  3356. spawn->appearance.display_name = 1;
  3357. spawn->appearance.show_level = 1;
  3358. spawn->appearance.attackable = 1;
  3359. }
  3360. else{
  3361. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn create [spawn type] [race type] [class type] [level] [name] (difficulty) (size)");
  3362. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are required except difficulty and size. Valid types are Object, NPC, Sign, or GroundSpawn");
  3363. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn create npc 203 1 50 'Lady Vox' 1 32");
  3364. break;
  3365. }
  3366. spawn->SetID(Spawn::NextID());
  3367. spawn->SetX(client->GetPlayer()->GetX());
  3368. spawn->SetY(client->GetPlayer()->GetY());
  3369. spawn->SetZ(client->GetPlayer()->GetZ());
  3370. spawn->SetHeading(client->GetPlayer()->GetHeading());
  3371. spawn->SetSpawnOrigX(spawn->GetX());
  3372. spawn->SetSpawnOrigY(spawn->GetY());
  3373. spawn->SetSpawnOrigZ(spawn->GetZ());
  3374. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  3375. spawn->appearance.targetable = 1;
  3376. spawn->appearance.race = 255;
  3377. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  3378. spawn->SetModelType(atoi(sep->arg[1]));
  3379. spawn->SetAdventureClass(atoi(sep->arg[2]));
  3380. spawn->SetLevel(atoi(sep->arg[3]));
  3381. spawn->SetName(sep->arg[4]);
  3382. if(sep->arg[5][0] && sep->IsNumber(5))
  3383. spawn->SetEncounterLevel(atoi(sep->arg[5]));
  3384. if(sep->arg[6][0] && sep->IsNumber(6))
  3385. spawn->size = atoi(sep->arg[6]);
  3386. if(spawn->GetTotalHP() == 0){
  3387. spawn->SetTotalHP(25*spawn->GetLevel() + 1);
  3388. spawn->SetHP(25*spawn->GetLevel() + 1);
  3389. }
  3390. if(spawn->GetTotalPower() == 0){
  3391. spawn->SetTotalPower(25*spawn->GetLevel() + 1);
  3392. spawn->SetPower(25*spawn->GetLevel() + 1);
  3393. }
  3394. client->GetCurrentZone()->AddSpawn(spawn);
  3395. break;
  3396. }
  3397. case COMMAND_SPAWN_EQUIPMENT:{
  3398. Spawn* spawn = cmdTarget;
  3399. if(spawn && sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1) && spawn->IsEntity()){
  3400. int8 slot = atoi(sep->arg[0]);
  3401. int16 type = atoi(sep->arg[1]);
  3402. int8 red = 0;
  3403. int8 green = 0;
  3404. int8 blue = 0;
  3405. int8 h_red = 0;
  3406. int8 h_green = 0;
  3407. int8 h_blue = 0;
  3408. if(sep->arg[2])
  3409. red = atoi(sep->arg[2]);
  3410. if(sep->arg[3])
  3411. green = atoi(sep->arg[3]);
  3412. if(sep->arg[4])
  3413. blue = atoi(sep->arg[4]);
  3414. if(sep->arg[5])
  3415. h_red = atoi(sep->arg[5]);
  3416. if(sep->arg[6])
  3417. h_green = atoi(sep->arg[6]);
  3418. if(sep->arg[7])
  3419. h_blue = atoi(sep->arg[7]);
  3420. ((Entity*)spawn)->SetEquipment(slot, type, red, green, blue, h_red, h_green, h_blue);
  3421. database.SaveNPCAppearanceEquipment(spawn->GetDatabaseID() , slot, type, red, green, blue, h_red, h_green, h_blue);
  3422. }
  3423. else{
  3424. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn equipment [slot] [appearance id] (red) (green) (blue) (highlight red) (hgreen) (hblue)");
  3425. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn's equipment. ");
  3426. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Slot is 0-24, Appearance ID from appearances table, Colors are 0-255");
  3427. }
  3428. break;
  3429. }
  3430. case COMMAND_SPAWN_DETAILS: {
  3431. Spawn* spawn = cmdTarget;
  3432. if (sep && sep->arg[0][0]) {
  3433. if (cmdTarget)
  3434. {
  3435. if (ToLower(string(sep->arg[0])) == "los")
  3436. {
  3437. bool hasLOS = client->GetPlayer()->CheckLoS(cmdTarget);
  3438. if (hasLOS)
  3439. client->Message(CHANNEL_COLOR_YELLOW, "You have line of sight with %s", spawn->GetName());
  3440. else
  3441. client->Message(CHANNEL_COLOR_RED, "You DO NOT have line of sight with %s", spawn->GetName());
  3442. break;
  3443. }
  3444. else if (ToLower(string(sep->arg[0])) == "bestz")
  3445. {
  3446. glm::vec3 targPos(cmdTarget->GetX(), cmdTarget->GetZ(), cmdTarget->GetY());
  3447. float bestZ = client->GetPlayer()->FindDestGroundZ(targPos, cmdTarget->GetYOffset());
  3448. client->Message(CHANNEL_COLOR_YELLOW, "Best Z for %s is %f", spawn->GetName(), bestZ);
  3449. break;
  3450. }
  3451. else if (ToLower(string(sep->arg[0])) == "inwater")
  3452. {
  3453. if (cmdTarget->GetRegionMap() == nullptr)
  3454. client->SimpleMessage(CHANNEL_COLOR_RED, "No water map for zone.");
  3455. else
  3456. {
  3457. bool inWater = cmdTarget->InWater();
  3458. client->Message(CHANNEL_COLOR_YELLOW, "%s is %s.", cmdTarget->GetName(), inWater ? "in water" : "out of water");
  3459. }
  3460. break;
  3461. }
  3462. else if (ToLower(string(sep->arg[0])) == "inlava")
  3463. {
  3464. if (cmdTarget->GetRegionMap() == nullptr)
  3465. client->SimpleMessage(CHANNEL_COLOR_RED, "No region map for zone.");
  3466. else
  3467. {
  3468. bool inLava = cmdTarget->InLava();
  3469. client->Message(CHANNEL_COLOR_YELLOW, "%s is %s.", cmdTarget->GetName(), inLava ? "in lava" : "out of lava");
  3470. }
  3471. break;
  3472. }
  3473. else if (ToLower(string(sep->arg[0])) == "regions")
  3474. {
  3475. glm::vec3 targPos(cmdTarget->GetX(), cmdTarget->GetY(), cmdTarget->GetZ());
  3476. if (cmdTarget->GetRegionMap() == nullptr)
  3477. client->SimpleMessage(CHANNEL_COLOR_RED, "No region map for zone.");
  3478. else
  3479. {
  3480. cmdTarget->GetRegionMap()->IdentifyRegionsInGrid(client, targPos);
  3481. }
  3482. break;
  3483. }
  3484. else if (ToLower(string(sep->arg[0])) == "pathto")
  3485. {
  3486. break;
  3487. }
  3488. else if (ToLower(string(sep->arg[0])) == "pathfrom")
  3489. {
  3490. break;
  3491. }
  3492. }
  3493. if (sep->IsNumber(0))
  3494. {
  3495. float radius = atof(sep->arg[0]);
  3496. if (!client->GetCurrentZone()->SendRadiusSpawnInfo(client, radius))
  3497. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No results in the radius were found.");
  3498. break;
  3499. }
  3500. }
  3501. if (spawn) {
  3502. const char* type = "NPC";
  3503. if (spawn->IsObject())
  3504. type = "Object";
  3505. else if (spawn->IsSign())
  3506. type = "Sign";
  3507. else if (spawn->IsWidget())
  3508. type = "Widget";
  3509. else if (spawn->IsGroundSpawn())
  3510. type = "GroundSpawn";
  3511. client->Message(CHANNEL_COLOR_YELLOW, "Name: %s, %s ID: %u", spawn->GetName(), type, spawn->GetDatabaseID());
  3512. client->Message(CHANNEL_COLOR_YELLOW, "Last Name: %s, Sub-Title: %s, Prefix: %s, Suffix: %s", spawn->GetLastName(), spawn->GetSubTitle(), spawn->GetPrefixTitle(), spawn->GetSuffixTitle());
  3513. client->Message(CHANNEL_COLOR_YELLOW, "Spawn Location ID: %u, Spawn Group ID: %u", spawn->GetSpawnLocationID(), spawn->GetSpawnGroupID());
  3514. client->Message(CHANNEL_COLOR_YELLOW, "Faction ID: %u, Merchant ID: %u, Transporter ID: %u", spawn->GetFactionID(), spawn->GetMerchantID(), spawn->GetTransporterID());
  3515. client->Message(CHANNEL_COLOR_YELLOW, "Grid ID: %u", spawn->GetLocation());
  3516. client->Message(CHANNEL_COLOR_YELLOW, "Race: %i, Class: %i, Gender: %i", spawn->GetRace(), spawn->GetAdventureClass(), spawn->GetGender());
  3517. client->Message(CHANNEL_COLOR_YELLOW, "Level: %i, HP: %u, Power: %u", spawn->GetLevel(), spawn->GetHP(), spawn->GetPower());
  3518. 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());
  3519. client->Message(CHANNEL_COLOR_YELLOW, "Collision Radius: %i, Size: %i, Difficulty: %i, Heroic: %i", spawn->GetCollisionRadius(), spawn->GetSize(), spawn->GetEncounterLevel(), spawn->GetHeroic());
  3520. client->Message(CHANNEL_COLOR_YELLOW, "Targetable: %i, Show Name: %i, Attackable: %i, Show Level: %i", spawn->GetTargetable(), spawn->GetShowName(), spawn->GetAttackable(), spawn->GetShowLevel());
  3521. client->Message(CHANNEL_COLOR_YELLOW, "Show Command Icon: %i, Display Hand Icon: %i", spawn->GetShowCommandIcon(), spawn->GetShowHandIcon());
  3522. if (spawn->IsEntity()) {
  3523. 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());
  3524. 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());
  3525. }
  3526. client->Message(CHANNEL_COLOR_YELLOW, "Model Type: %i, Soga Race Type: %i", spawn->GetModelType(), spawn->GetSogaModelType());
  3527. client->Message(CHANNEL_COLOR_YELLOW, "Primary Command Type: %u, Secondary Command Type: %u", spawn->GetPrimaryCommandListID(), spawn->GetSecondaryCommandListID());
  3528. 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());
  3529. 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);
  3530. if (spawn->IsNPC())
  3531. client->Message(CHANNEL_COLOR_YELLOW, "Randomize: %u", ((NPC*)spawn)->GetRandomize());
  3532. string details;
  3533. details += "\\#0000FFName: " + string(spawn->GetName()) + "\n";
  3534. details += "Type: " + string(type) + "\n";
  3535. details += "ID: " + to_string(spawn->GetDatabaseID()) + "\n";
  3536. details += "Last Name: " + string(spawn->GetLastName()) + "\n";
  3537. details += "Sub-Title: " + string(spawn->GetSubTitle()) + "\n";
  3538. details += "Prefix: " + string(spawn->GetPrefixTitle()) + "\n";
  3539. details += "Suffix: " + string(spawn->GetSuffixTitle()) + "\n";
  3540. details += "Race: " + to_string(spawn->GetRace()) + "\n";
  3541. details += "Class: " + to_string(spawn->GetAdventureClass()) + "\n";
  3542. details += "Gender: " + to_string(spawn->GetGender()) + "\n";
  3543. details += "Level: " + to_string(spawn->GetLevel()) + "\n";
  3544. details += "HP: " + to_string(spawn->GetHP()) + "\n";
  3545. details += "Power: " + to_string(spawn->GetPower()) + "\n";
  3546. details += "Difficulty: " + to_string(spawn->GetEncounterLevel()) + "\n";
  3547. details += "Heroic: " + to_string(spawn->GetHeroic()) + "\n";
  3548. details += "Group ID: " + to_string(spawn->GetSpawnGroupID()) + "\n";
  3549. details += "Faction ID: " + to_string(spawn->GetFactionID()) + "\n";
  3550. details += "Merchant ID: " + to_string(spawn->GetMerchantID()) + "\n";
  3551. details += "Transport ID: " + to_string(spawn->GetTransporterID()) + "\n";
  3552. details += "Location ID: " + to_string(spawn->GetSpawnLocationID()) + "\n";
  3553. char x[16];
  3554. sprintf(x, "%.2f", spawn->GetX());
  3555. char y[16];
  3556. sprintf(y, "%.2f", spawn->GetY());
  3557. char z[16];
  3558. sprintf(z, "%.2f", spawn->GetZ());
  3559. details += "Location: " + string(x) + ", " + string(y) + ", " + string(z) + "\n";
  3560. string details2;
  3561. details2 += "Heading: " + to_string(spawn->GetHeading()) + "\n";
  3562. details2 += "Grid ID: " + to_string(spawn->GetLocation()) + "\n";
  3563. details2 += "Size: " + to_string(spawn->GetSize()) + "\n";
  3564. details2 += "Collision Radius: " + to_string(spawn->GetCollisionRadius()) + "\n";
  3565. details2 += "Respawn Time: " + to_string(spawn->GetRespawnTime()) + "\n";
  3566. details2 += "Targetable: " + to_string(spawn->GetTargetable()) + "\n";
  3567. details2 += "Show Name: " + to_string(spawn->GetShowName()) + "\n";
  3568. details2 += "Attackable: " + to_string(spawn->GetAttackable()) + "\n";
  3569. details2 += "Show Level: " + to_string(spawn->GetShowLevel()) + "\n";
  3570. details2 += "Show Command Icon: " + to_string(spawn->GetShowCommandIcon()) + "\n";
  3571. details2 += "Display Hand Icon: " + to_string(spawn->GetShowHandIcon()) + "\n";
  3572. details2 += "Model Type: " + to_string(spawn->GetModelType()) + "\n";
  3573. details2 += "Soga Race Type: " + to_string(spawn->GetSogaModelType()) + "\n";
  3574. details2 += "Primary Command ID: " + to_string(spawn->GetPrimaryCommandListID()) + "\n";
  3575. details2 += "Secondary Cmd ID: " + to_string(spawn->GetSecondaryCommandListID()) + "\n";
  3576. details2 += "Visual State: " + to_string(spawn->GetVisualState()) + "\n";
  3577. details2 += "Action State: " + to_string(spawn->GetActionState()) + "\n";
  3578. details2 += "Mood State: " + to_string(spawn->GetMoodState()) + "\n";
  3579. details2 += "Initial State: " + to_string(spawn->GetInitialState()) + "\n";
  3580. details2 += "Activity Status: " + to_string(spawn->GetActivityStatus()) + "\n";
  3581. details2 += "Emote State: " + to_string(spawn->GetEmoteState()) + "\n";
  3582. string details3;
  3583. details3 += "Pitch: " + to_string(spawn->GetPitch()) + "\n";
  3584. details3 += "Roll: " + to_string(spawn->GetRoll()) + "\n";
  3585. details3 += "Hide Hood: " + to_string(spawn->appearance.hide_hood) + "\n";
  3586. string details4;
  3587. if (spawn->IsEntity()) {
  3588. details4 += "Facial Hair Type: " + to_string(((Entity*)spawn)->GetFacialHairType()) + "\n";
  3589. details4 += "Hair Type: " + to_string(((Entity*)spawn)->GetHairType()) + "\n";
  3590. details4 += "Chest Type: " + to_string(((Entity*)spawn)->GetChestType()) + "\n";
  3591. details4 += "Legs Type: " + to_string(((Entity*)spawn)->GetLegsType()) + "\n";
  3592. details4 += "Soga Facial Hair Type: " + to_string(((Entity*)spawn)->GetSogaFacialHairType()) + "\n";
  3593. details4 += "Soga Hair Type: " + to_string(((Entity*)spawn)->GetSogaHairType()) + "\n";
  3594. details4 += "Wing Type: " + to_string(((Entity*)spawn)->GetWingType()) + "\n";
  3595. if (spawn->IsNPC()) {
  3596. details4 += "\nRandomize: " + to_string(((NPC*)spawn)->GetRandomize()) + "\n";
  3597. }
  3598. }
  3599. string title = string(spawn->GetName()) + "(" + to_string(spawn->GetDatabaseID()) + ")";
  3600. client->SendShowBook(client->GetPlayer(), title, 4, details, details2, details3, details4);
  3601. }
  3602. else {
  3603. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn details (radius)");
  3604. 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.");
  3605. }
  3606. break;
  3607. }
  3608. case COMMAND_SPAWN_TARGET:{
  3609. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  3610. int32 spawn_id = atoul(sep->arg[0]);
  3611. int16 response = client->GetCurrentZone()->SetSpawnTargetable(spawn_id);
  3612. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  3613. }
  3614. else if(sep && sep->arg[0][0] && sep->arg[1][0] && sep->IsNumber(1) && ToLower(string(sep->arg[0])) == "radius"){
  3615. float distance = atof(sep->arg[1]);
  3616. int16 response = client->GetCurrentZone()->SetSpawnTargetable(client->GetPlayer(), distance);
  3617. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  3618. }
  3619. else{
  3620. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn target [spawn id]");
  3621. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn as targetable. Used to change a spawn if it was set to untargetable.");
  3622. }
  3623. break;
  3624. }
  3625. case COMMAND_SPAWN_SET:
  3626. {
  3627. Spawn* spawn = cmdTarget;
  3628. sint16 set_type = -1;
  3629. string type_str;
  3630. if (spawn)
  3631. {
  3632. // check if parameters are (location or list or not player and not a 2nd param), and that there is at least 1 value
  3633. 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)
  3634. {
  3635. // set the type, which will be 0 if location or list or invalid
  3636. set_type = spawn_set_values[ToLower(string(sep->arg[0]))];
  3637. }
  3638. if(set_type > 0)
  3639. {
  3640. // check if spawn set is NOT a char update, or not location, or isn't a number
  3641. 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)
  3642. {
  3643. client->SimpleMessage(CHANNEL_COLOR_RED, "Invalid value for set command.");
  3644. }
  3645. else
  3646. {
  3647. string name = string(spawn->GetName());
  3648. if(SetSpawnCommand(client, spawn, set_type, sep->argplus[1]))
  3649. {
  3650. if (set_type == SPAWN_SET_VALUE_EXPANSION_FLAG || set_type == SPAWN_SET_VALUE_HOLIDAY_FLAG)
  3651. {
  3652. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "A /reload spawns is required to properly update the spawns with the xpack/holiday flag.");
  3653. }
  3654. else if (set_type == SPAWN_SET_VALUE_NAME)
  3655. {
  3656. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "New name will not be effective until zone reload.");
  3657. }
  3658. else if (set_type == SPAWN_SET_SKIN_COLOR)
  3659. {
  3660. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set skin_color to R G B: %s.", sep->argplus[1]);
  3661. }
  3662. else if(set_type == SPAWN_SET_VALUE_LOCATION)
  3663. {
  3664. spawn->SetLocation(client->GetPlayer()->GetLocation());
  3665. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set '%s' to '%u' for spawn '%s'", sep->arg[0], client->GetPlayer()->GetLocation(), name.c_str());
  3666. }
  3667. else
  3668. {
  3669. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set '%s' to '%s' for spawn '%s'", sep->arg[0], sep->arg[1], name.c_str());
  3670. }
  3671. switch (set_type)
  3672. {
  3673. case SPAWN_SET_VALUE_EXPANSION_FLAG:
  3674. case SPAWN_SET_VALUE_HOLIDAY_FLAG:
  3675. case SPAWN_SET_VALUE_FACTION:
  3676. {
  3677. // not applicable
  3678. break;
  3679. }
  3680. default:
  3681. {
  3682. client->GetCurrentZone()->ApplySetSpawnCommand(client, spawn, set_type, sep->argplus[1]);
  3683. break;
  3684. }
  3685. }
  3686. 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))
  3687. {
  3688. if(spawn->GetSpawnLocationID() > 0 && database.UpdateSpawnLocationSpawns(spawn))
  3689. {
  3690. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information.");
  3691. }
  3692. else if(spawn->GetSpawnLocationID() > 0)
  3693. {
  3694. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn information, see console window for details.");
  3695. }
  3696. }
  3697. else
  3698. {
  3699. if(spawn->GetDatabaseID() > 0 && database.SaveSpawnInfo(spawn))
  3700. {
  3701. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully saved spawn.");
  3702. }
  3703. else if(spawn->GetDatabaseID() > 0)
  3704. {
  3705. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn, see console window for details.");
  3706. }
  3707. }
  3708. }
  3709. }
  3710. }
  3711. else if(set_type == 0)
  3712. {
  3713. // /spawn set list - lists all possible attributes that can be changed with this command, 10 per line.
  3714. map<string, int8>::iterator itr;
  3715. int i=0;
  3716. string list;
  3717. for(itr = spawn_set_values.begin(); itr != spawn_set_values.end(); itr++, i++)
  3718. {
  3719. if(i==10)
  3720. {
  3721. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  3722. i = 0;
  3723. }
  3724. if(i>0)
  3725. {
  3726. list.append(", ").append(itr->first);
  3727. }
  3728. else
  3729. {
  3730. list = itr->first;
  3731. }
  3732. }
  3733. if(list.length() > 0)
  3734. {
  3735. // if 1 or more, display in client.
  3736. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  3737. }
  3738. }
  3739. else
  3740. {
  3741. // syntax fail
  3742. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn set [type] [value]");
  3743. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used to change various settings for the targeted NPC or Object.");
  3744. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "For a list of changeable settings use /spawn set list");
  3745. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Note: /spawn set location does not require a value. The client's current location is used.");
  3746. }
  3747. }
  3748. break;
  3749. }
  3750. case COMMAND_SPAWN_REMOVE:{
  3751. Spawn* spawn = cmdTarget;
  3752. if(spawn && !spawn->IsPlayer()){
  3753. if(spawn->GetSpawnLocationID() > 0){
  3754. if(database.RemoveSpawnFromSpawnLocation(spawn)){
  3755. client->GetCurrentZone()->RemoveSpawn(spawn, true, false);
  3756. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully removed spawn from zone");
  3757. }
  3758. else
  3759. client->SimpleMessage(CHANNEL_COLOR_RED, "Error removing spawn, see console window for details.");
  3760. }
  3761. else
  3762. client->SimpleMessage(CHANNEL_COLOR_RED, "This spawn does not have a spawn group associated with it");
  3763. }
  3764. else{
  3765. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn remove");
  3766. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for removing the targeted NPC or Object from the zone.");
  3767. }
  3768. break;
  3769. }
  3770. case COMMAND_SPAWN_LIST:{
  3771. if(sep && sep->arg[0][0]){
  3772. vector<string>* results = database.GetSpawnNameList(sep->argplus[0]);
  3773. vector<string>::iterator itr;
  3774. if(results){
  3775. for(itr=results->begin();itr!=results->end();itr++){
  3776. client->SimpleMessage(CHANNEL_COLOR_YELLOW, (*itr).c_str());
  3777. }
  3778. safe_delete(results);
  3779. }
  3780. else
  3781. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found. ");
  3782. }
  3783. else{
  3784. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn list [name]");
  3785. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Name can be a partial match.");
  3786. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn list Qeynos Guard");
  3787. }
  3788. break;
  3789. }
  3790. case COMMAND_SPAWN_ADD:{
  3791. Spawn* spawn = cmdTarget;
  3792. if(spawn && sep && sep->arg[1][0] && (sep->IsNumber(0) || strncasecmp(sep->arg[0], "new", 3) == 0)){
  3793. if(spawn->GetSpawnLocationID() > 0){
  3794. client->Message(CHANNEL_COLOR_RED, "This spawn already has a spawn group id of %u, use /spawn remove to reassign it", spawn->GetSpawnLocationID());
  3795. break;
  3796. }
  3797. if(spawn->GetDatabaseID() == 0){
  3798. if(database.SaveSpawnInfo(spawn)) {
  3799. char spawn_type[32];
  3800. memset(spawn_type, 0, sizeof(spawn_type));
  3801. if (spawn->IsNPC())
  3802. strncpy(spawn_type, "NPC", sizeof(spawn_type) - 1);
  3803. else if (spawn->IsObject())
  3804. strncpy(spawn_type, "Object", sizeof(spawn_type) - 1);
  3805. else if (spawn->IsSign())
  3806. strncpy(spawn_type, "Sign", sizeof(spawn_type) - 1);
  3807. else if (spawn->IsGroundSpawn())
  3808. strncpy(spawn_type, "GroundSpawn", sizeof(spawn_type) - 1);
  3809. else
  3810. strncpy(spawn_type, "Unknown", sizeof(spawn_type) - 1);
  3811. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information with a %s id of %u", spawn_type, spawn->GetDatabaseID());
  3812. }
  3813. else
  3814. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn information, see console window for details.");
  3815. }
  3816. int32 spawn_group_id = 0;
  3817. if(strncasecmp(sep->arg[0], "new", 3) == 0)
  3818. spawn_group_id = database.GetNextSpawnLocation();
  3819. else
  3820. spawn_group_id = atol(sep->arg[0]);
  3821. int8 percent = 100;
  3822. if(sep->arg[2] && sep->IsNumber(2))
  3823. percent = atoi(sep->arg[2]);
  3824. spawn->SetSpawnLocationID(spawn_group_id);
  3825. float x_offset = database.GetSpawnLocationPlacementOffsetX(spawn->GetSpawnLocationID());
  3826. float y_offset = database.GetSpawnLocationPlacementOffsetY(spawn->GetSpawnLocationID());
  3827. float z_offset = database.GetSpawnLocationPlacementOffsetZ(spawn->GetSpawnLocationID());
  3828. if(database.SaveSpawnEntry(spawn, sep->arg[1], percent, x_offset, y_offset, z_offset))
  3829. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn location with a spawn group of %u", spawn->GetSpawnLocationID());
  3830. else
  3831. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn location, see console window for details.");
  3832. }
  3833. else{
  3834. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn add [spawn group id] [spawn group name] (percentage)");
  3835. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for adding the targeted NPC or Object to the database.");
  3836. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can substitute new for [spawn group id] to create a new one.");
  3837. }
  3838. break;
  3839. }
  3840. case COMMAND_SPAWN:{
  3841. int32 id = 0;
  3842. Spawn* spawn = 0;
  3843. if(sep && sep->arg[0] && sep->IsNumber(0)){
  3844. id = atol(sep->arg[0]);
  3845. spawn = client->GetCurrentZone()->GetSpawn(id);
  3846. }
  3847. if(id > 0 && spawn && spawn->appearance.name[0] == 0)
  3848. id = 0;
  3849. if(!id || !spawn){
  3850. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn [spawn id] (x) (y) (z) (heading) (location)");
  3851. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are optional except the id. The spawn id must be in the database.");
  3852. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn 1 0 0 0 0");
  3853. safe_delete(sep);
  3854. return;
  3855. }
  3856. if(sep && sep->arg[1][0]){
  3857. float x = atof(sep->arg[1]);
  3858. spawn->appearance.pos.X = x;
  3859. }
  3860. else
  3861. spawn->SetX(client->GetPlayer()->GetX(), false);
  3862. if(sep && sep->arg[2][0]){
  3863. float y = atof(sep->arg[2]);
  3864. spawn->appearance.pos.Y = y;
  3865. }
  3866. else
  3867. spawn->SetY(client->GetPlayer()->GetY(), false);
  3868. if(sep && sep->arg[3][0]){
  3869. float z = atof(sep->arg[3]);
  3870. spawn->appearance.pos.Z = z;
  3871. }
  3872. else
  3873. spawn->SetZ(client->GetPlayer()->GetZ(), false);
  3874. if(sep && sep->arg[4][0]){
  3875. float heading = atof(sep->arg[4]);
  3876. spawn->SetHeading(heading);
  3877. }
  3878. else
  3879. spawn->SetHeading(client->GetPlayer()->GetHeading(), false);
  3880. spawn->SetSpawnOrigX(spawn->GetX());
  3881. spawn->SetSpawnOrigY(spawn->GetY());
  3882. spawn->SetSpawnOrigZ(spawn->GetZ());
  3883. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  3884. if(sep && sep->arg[5][0])
  3885. spawn->appearance.pos.grid_id = atol(sep->arg[5]);
  3886. else
  3887. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  3888. if(spawn->IsNPC() && spawn->GetTotalHP() == 0){
  3889. spawn->SetTotalHP(spawn->GetLevel() * 15);
  3890. spawn->SetHP(spawn->GetTotalHP());
  3891. }
  3892. if(spawn->GetTotalPower() == 0){
  3893. spawn->SetTotalPower(spawn->GetLevel() * 15);
  3894. spawn->SetPower(spawn->GetTotalPower());
  3895. }
  3896. const char* script = world.GetSpawnScript(id);
  3897. if(script && lua_interface && lua_interface->GetSpawnScript(script) != 0)
  3898. spawn->SetSpawnScript(string(script));
  3899. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_PRESPAWN);
  3900. client->GetCurrentZone()->AddSpawn(spawn);
  3901. if(spawn->IsNPC())
  3902. spawn->GetZone()->AddLoot((NPC*)spawn);
  3903. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_SPAWN);
  3904. LogWrite(COMMAND__INFO, 0, "Command", "Received spawn command - Parms: %s", command_parms->data.c_str());
  3905. break;
  3906. }
  3907. case COMMAND_ADMINFLAG:
  3908. {
  3909. if(sep && sep->arg[0]){
  3910. sint16 tmp_status = database.GetCharacterAdminStatus(sep->arg[0]);
  3911. sint16 new_status = atoi(sep->arg[1]);
  3912. if(tmp_status == -10)
  3913. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character does not exist.");
  3914. else if(tmp_status >= client->GetAdminStatus())
  3915. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character has same or higher level status.");
  3916. else if (new_status > client->GetAdminStatus())
  3917. client->SimpleMessage(CHANNEL_ERROR, "Unable to flag character. Reason: New status is higher then your status.");
  3918. else{
  3919. Client* client2 = client->GetCurrentZone()->GetClientByName(sep->arg[0]);
  3920. if (!client2)
  3921. client2 = zone_list.GetClientByCharName(sep->arg[0]);
  3922. if(database.UpdateAdminStatus(sep->arg[0],new_status)) {
  3923. client->Message(CHANNEL_COLOR_YELLOW,"Character status updated to %i for %s.",new_status,sep->arg[0]);
  3924. if (client2) {
  3925. client2->SetAdminStatus(new_status);
  3926. client2->Message(CHANNEL_COLOR_YELLOW, "%s has set your admin status to %i.", client->GetPlayer()->GetName(), new_status);
  3927. }
  3928. }
  3929. else
  3930. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Unknown reason.");
  3931. }
  3932. }else{
  3933. sint16 status = database.GetCharacterAdminStatus(client->GetPlayer()->GetName());
  3934. if(status != client->GetAdminStatus())
  3935. {
  3936. client->Message(CHANNEL_COLOR_YELLOW,"Flag status was changed from %i to %i.",status,client->GetAdminStatus());
  3937. client->SetAdminStatus(status);
  3938. }
  3939. else
  3940. {
  3941. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /flag {name} {new_status}");
  3942. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Standard User: 0");
  3943. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Admin User: 100");
  3944. }
  3945. }
  3946. break;
  3947. }
  3948. case COMMAND_CANNEDEMOTE:{
  3949. client->GetCurrentZone()->HandleEmote(client, command_parms->data);
  3950. break;
  3951. }
  3952. case COMMAND_BROADCAST: {
  3953. if (sep && sep->arg[0])
  3954. zone_list.HandleGlobalBroadcast(sep->argplus[0]);
  3955. else
  3956. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /broadcast {message}");
  3957. break;
  3958. }
  3959. case COMMAND_ANNOUNCE: {
  3960. if (sep && sep->arg[0])
  3961. zone_list.HandleGlobalAnnouncement(sep->argplus[0]);
  3962. else
  3963. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /announce {message}");
  3964. break;
  3965. }
  3966. case COMMAND_RELOAD_ITEMS:{
  3967. LogWrite(COMMAND__INFO, 0, "Command", "Reloading items..");
  3968. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Started Reloading items (this might take a few minutes...)");
  3969. database.ReloadItemList();
  3970. database.LoadMerchantInformation();
  3971. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Finished Reloading items.");
  3972. break;
  3973. }
  3974. case COMMAND_ENABLE_ABILITY_QUE:{
  3975. EQ2Packet* app = client->GetPlayer()->GetSpellBookUpdatePacket(client->GetVersion());
  3976. if(app)
  3977. client->QueuePacket(app);
  3978. break;
  3979. }
  3980. case COMMAND_ITEMSEARCH:{
  3981. PacketStruct* packet = configReader.getStruct("WS_StartBroker", client->GetVersion());
  3982. if (packet) {
  3983. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  3984. //packet->setDataByName("unknown", 1);
  3985. packet->setDataByName("unknown2", 5, 0);
  3986. packet->setDataByName("unknown2", 20, 1);
  3987. packet->setDataByName("unknown2", 58, 3);
  3988. packet->setDataByName("unknown2", 40, 4);
  3989. client->QueuePacket(packet->serialize());
  3990. PacketStruct* packet2 = configReader.getStruct("WS_BrokerBags", client->GetVersion());
  3991. if (packet2) {
  3992. packet2->setDataByName("char_id", client->GetCharacterID());
  3993. client->QueuePacket(packet2->serialize()); //send this for now, needed to properly clear data
  3994. safe_delete(packet2);
  3995. }
  3996. safe_delete(packet);
  3997. }
  3998. break;
  3999. }
  4000. case COMMAND_ANIMTEST:{
  4001. PacketStruct* command_packet = configReader.getStruct("WS_CannedEmote", client->GetVersion());
  4002. if(command_packet){
  4003. int32 id = client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer());
  4004. if (cmdTarget)
  4005. id = client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget);
  4006. command_packet->setDataByName ( "spawn_id" , id);
  4007. int animID = 1;
  4008. if(sep && sep->arg[0] && sep->IsNumber(0))
  4009. animID = atoi(sep->arg[0]);
  4010. VisualState* vs = NULL;
  4011. if(animID == 0)
  4012. {
  4013. vs = visual_states.FindVisualState(sep->arg[0]);
  4014. }
  4015. char msg[128];
  4016. sprintf(msg,"Animation Test ID: %i",animID);
  4017. command_packet->setMediumStringByName ( "emote_msg" , msg );
  4018. if(vs != NULL)
  4019. command_packet->setDataByName ( "anim_type", vs->GetID ( ) );
  4020. else
  4021. command_packet->setDataByName ( "anim_type", animID );
  4022. command_packet->setDataByName ( "unknown0", 0 );
  4023. EQ2Packet* outapp = command_packet->serialize();
  4024. client->QueuePacket(outapp);
  4025. safe_delete(command_packet);
  4026. }
  4027. break;
  4028. }
  4029. case COMMAND_KICK:
  4030. {
  4031. if( sep == 0 || sep->arg[0] == 0)
  4032. {
  4033. client->SimpleMessage(CHANNEL_COLOR_RED, "/kick [name]");
  4034. }
  4035. else
  4036. {
  4037. Client* kickClient = zone_list.GetClientByCharName(string(sep->arg[0]));
  4038. if ( kickClient == client )
  4039. {
  4040. client->Message(CHANNEL_COLOR_RED, "You can't kick yourself!");
  4041. break;
  4042. }
  4043. else if(kickClient != NULL)
  4044. {
  4045. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  4046. if ( maxStatus >= client->GetAdminStatus( ) || kickClient->GetAdminStatus() >= client->GetAdminStatus() )
  4047. {
  4048. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  4049. break;
  4050. }
  4051. client->Message(CHANNEL_COLOR_RED, "Kicking %s...",sep->arg[0]);
  4052. kickClient->Disconnect();
  4053. }
  4054. else
  4055. {
  4056. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  4057. }
  4058. }
  4059. break;
  4060. }
  4061. case COMMAND_LOCK:
  4062. {
  4063. if( sep != NULL && sep->arg[0] != NULL && sep->IsNumber(0)){
  4064. int worldLocked = atoi(sep->arg[0]);
  4065. net.world_locked = worldLocked;
  4066. if ( worldLocked )
  4067. client->Message(CHANNEL_COLOR_YELLOW,"World server has been locked.");
  4068. else
  4069. client->Message(CHANNEL_COLOR_YELLOW,"World server has been unlocked.");
  4070. }
  4071. else
  4072. client->SimpleMessage(CHANNEL_COLOR_RED, "/lock [0/1]");
  4073. break;
  4074. }
  4075. case COMMAND_BAN:{
  4076. if( sep == 0 || sep->arg[0] == 0 || (sep->arg[1][0] != 0 && !sep->IsNumber(1) ) )
  4077. {
  4078. client->SimpleMessage(CHANNEL_COLOR_RED, "/ban [name] [permanent:0/1]");
  4079. }
  4080. else
  4081. {
  4082. Client* kickClient = zone_list.GetClientByCharName(sep->arg[0]);
  4083. if ( kickClient == client )
  4084. {
  4085. client->Message(CHANNEL_COLOR_RED, "You can't ban yourself!");
  4086. break;
  4087. }
  4088. else if(kickClient != NULL)
  4089. {
  4090. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  4091. if ( maxStatus > client->GetAdminStatus( ) ||
  4092. client->GetAdminStatus ( ) > kickClient->GetAdminStatus ( ) )
  4093. {
  4094. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  4095. break;
  4096. }
  4097. client->Message(CHANNEL_COLOR_RED, "Kicking & Banning %s...",sep->arg[0]);
  4098. int perm = atol(sep->arg[1]);
  4099. if ( perm == 1 )
  4100. database.UpdateAdminStatus(sep->arg[0],-2);
  4101. else
  4102. database.UpdateAdminStatus(sep->arg[0],-1);
  4103. kickClient->Disconnect();
  4104. }
  4105. else
  4106. {
  4107. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  4108. }
  4109. }
  4110. break;
  4111. }
  4112. case COMMAND_SET_COMBAT_VOICE:{
  4113. int32 value = 0;
  4114. if(sep && sep->arg[0] && sep->IsNumber(0))
  4115. value = atoi(sep->arg[0]);
  4116. client->GetPlayer()->SetCombatVoice(value);
  4117. break;
  4118. }
  4119. case COMMAND_SET_EMOTE_VOICE:{
  4120. int32 value = 0;
  4121. if(sep && sep->arg[0] && sep->IsNumber(0))
  4122. value = atoi(sep->arg[0]);
  4123. client->GetPlayer()->SetEmoteVoice(value);
  4124. break;
  4125. }
  4126. case COMMAND_GIVEITEM:{
  4127. if(sep && sep->arg[0][0] && sep->arg[0][1] && sep->IsNumber(1)){
  4128. Client* itemToClient = zone_list.GetClientByCharName(sep->arg[0]);
  4129. if ( itemToClient == NULL )
  4130. client->Message(CHANNEL_COLOR_YELLOW,"Could not find %s.",sep->arg[0]);
  4131. else
  4132. {
  4133. int32 item_id = atol(sep->arg[1]);
  4134. client->Message(CHANNEL_COLOR_YELLOW,"Gave %s item id %i.",sep->arg[0],item_id);
  4135. itemToClient->AddItem(item_id);
  4136. }
  4137. }
  4138. else
  4139. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /giveitem [name] [item_id]");
  4140. break;
  4141. }
  4142. case COMMAND_REPORT_BUG : { Command_ReportBug(client, sep); break; }
  4143. case COMMAND_INVENTORY : { Command_Inventory(client, sep, command); break; }
  4144. case COMMAND_WEAPONSTATS : { Command_WeaponStats(client); break; }
  4145. case COMMAND_SKILL :
  4146. case COMMAND_SKILL_ADD :
  4147. case COMMAND_SKILL_REMOVE :
  4148. case COMMAND_SKILL_LIST : { Command_Skills(client, sep, command->handler); break; }
  4149. case COMMAND_ZONE_SET : { Command_ZoneSet(client, sep); break; }
  4150. case COMMAND_ZONE_DETAILS : { Command_ZoneDetails(client, sep); break; }
  4151. case COMMAND_ENTITYCOMMAND :
  4152. case COMMAND_ENTITYCOMMAND_LIST : { Command_EntityCommand(client, sep, command->handler); break; }
  4153. case COMMAND_MERCHANT :
  4154. case COMMAND_MERCHANT_LIST : { Command_Merchant(client, sep, command->handler); break; }
  4155. case COMMAND_APPEARANCE :
  4156. case COMMAND_APPEARANCE_LIST : { Command_Appearance(client, sep, command->handler); break; }
  4157. case COMMAND_TRACK : { Command_Track(client); break; }
  4158. case COMMAND_DISTANCE : { Command_Distance(client); break; }
  4159. case COMMAND_INSPECT_PLAYER : { Command_InspectPlayer(client, sep); break; }
  4160. case COMMAND_ZONE_SAFE : { Command_ZoneSafeCoords(client, sep); break; }
  4161. case COMMAND_GUILDSAY : { Command_GuildSay(client, sep); break; }
  4162. case COMMAND_OFFICERSAY : { Command_OfficerSay(client, sep); break; }
  4163. case COMMAND_SET_GUILD_MEMBER_NOTE : { Command_SetGuildMemberNote(client, sep); break; }
  4164. case COMMAND_SET_GUILD_OFFICER_NOTE : { Command_SetGuildOfficerNote(client, sep); break; }
  4165. case COMMAND_GUILD : { Command_Guild(client, sep); break; }
  4166. case COMMAND_CREATE_GUILD : { Command_CreateGuild(client); break; }
  4167. case COMMAND_GUILDS : { Command_Guilds(client); break; }
  4168. case COMMAND_GUILDS_ADD : { Command_GuildsAdd(client, sep); break; }
  4169. case COMMAND_GUILDS_CREATE : { Command_GuildsCreate(client, sep); break; }
  4170. case COMMAND_GUILDS_DELETE : { Command_GuildsDelete(client, sep); break; }
  4171. case COMMAND_GUILDS_LIST : { Command_GuildsList(client); break; }
  4172. case COMMAND_GUILDS_REMOVE : { Command_GuildsRemove(client, sep); break; }
  4173. case COMMAND_CLAIM : { Command_Claim(client, sep); break; }
  4174. case COMMAND_CLEAR_ALL_QUEUED : { Command_ClearAllQueued(client); break; }
  4175. case COMMAND_LOCATION : { Command_Location(client); break; }
  4176. case COMMAND_LOCATION_ADD : { Command_LocationAdd(client, sep); break; }
  4177. case COMMAND_LOCATION_CREATE : { Command_LocationCreate(client, sep); break; }
  4178. case COMMAND_LOCATION_DELETE : { Command_LocationDelete(client, sep); break; }
  4179. case COMMAND_LOCATION_LIST : { Command_LocationList(client, sep); break; }
  4180. case COMMAND_LOCATION_REMOVE : { Command_LocationRemove(client, sep); break; }
  4181. case COMMAND_GRID : { Command_Grid(client); break; }
  4182. case COMMAND_TRY_ON : { Command_TryOn(client, sep); break; }
  4183. case COMMAND_IRC : { Command_IRC(client, sep); break; }
  4184. case COMMAND_RANDOMIZE : { Command_Randomize(client, sep); break; }
  4185. case COMMAND_AFK : { Command_AFK(client, sep); break; }
  4186. case COMMAND_SHOW_CLOAK : { Command_ShowCloak(client, sep); break; }
  4187. case COMMAND_SHOW_HELM : { Command_ShowHelm(client, sep); break; }
  4188. case COMMAND_SHOW_HOOD : { Command_ShowHood(client, sep); break; }
  4189. case COMMAND_SHOW_HOOD_OR_HELM : { Command_ShowHoodHelm(client, sep); break; }
  4190. case COMMAND_SHOW_RANGED : { Command_ShowRanged(client, sep); break; }
  4191. case COMMAND_STOP_DRINKING : { Command_StopDrinking(client); break; }
  4192. case COMMAND_STOP_EATING : { Command_StopEating(client); break; }
  4193. case COMMAND_TOGGLE_ANONYMOUS : { Command_Toggle_Anonymous(client); break; }
  4194. case COMMAND_TOGGLE_AUTOCONSUME : { Command_Toggle_AutoConsume(client, sep); break; }
  4195. case COMMAND_TOGGLE_BONUS_EXP : { Command_Toggle_BonusXP(client); break; }
  4196. case COMMAND_TOGGLE_COMBAT_EXP : { Command_Toggle_CombatXP(client); break; }
  4197. case COMMAND_TOGGLE_GM_HIDE : { Command_Toggle_GMHide(client); break; }
  4198. case COMMAND_TOGGLE_GM_VANISH : { Command_Toggle_GMVanish(client); break; }
  4199. case COMMAND_TOGGLE_ILLUSIONS : { Command_Toggle_Illusions(client, sep); break; }
  4200. case COMMAND_TOGGLE_LFG : { Command_Toggle_LFG(client); break; }
  4201. case COMMAND_TOGGLE_LFW : { Command_Toggle_LFW(client); break; }
  4202. case COMMAND_TOGGLE_QUEST_EXP : { Command_Toggle_QuestXP(client); break; }
  4203. case COMMAND_TOGGLE_ROLEPLAYING : { Command_Toggle_Roleplaying(client); break; }
  4204. case COMMAND_TOGGLE_DUELS : { Command_Toggle_Duels(client); break; }
  4205. case COMMAND_TOGGLE_TRADES : { Command_Toggle_Trades(client); break; }
  4206. case COMMAND_TOGGLE_GUILDS : { Command_Toggle_Guilds(client); break; }
  4207. case COMMAND_TOGGLE_GROUPS : { Command_Toggle_Groups(client); break; }
  4208. case COMMAND_TOGGLE_RAIDS : { Command_Toggle_Raids(client); break; }
  4209. case COMMAND_TOGGLE_LON : { Command_Toggle_LON(client); break; }
  4210. case COMMAND_TOGGLE_VCINVITE : { Command_Toggle_VoiceChat(client); break; }
  4211. case COMMAND_CANCEL_MAINTAINED : { Command_CancelMaintained(client, sep); break; }
  4212. case COMMAND_MOTD : { Command_MOTD(client); break; }
  4213. case COMMAND_RANDOM : { Command_Random(client, sep); break; }
  4214. case COMMAND_CREATE : { Command_Create(client, sep); break; }
  4215. case COMMAND_CREATEFROMRECIPE : { Command_CreateFromRecipe(client, sep); break; }
  4216. case COMMAND_TITLE : { Command_Title(client); break; }
  4217. case COMMAND_TITLE_LIST : { Command_TitleList(client); break; }
  4218. case COMMAND_TITLE_SETPREFIX : { Command_TitleSetPrefix(client, sep); break; }
  4219. case COMMAND_TITLE_SETSUFFIX : { Command_TitleSetSuffix(client, sep); break; }
  4220. case COMMAND_TITLE_FIX : { Command_TitleFix(client, sep); break; }
  4221. case COMMAND_LANGUAGES : { Command_Languages(client, sep); break; }
  4222. case COMMAND_SET_LANGUAGE : { Command_SetLanguage(client, sep); break; }
  4223. case COMMAND_FOLLOW : { Command_Follow(client, sep); break; }
  4224. case COMMAND_STOP_FOLLOW : { Command_StopFollow(client, sep); break; }
  4225. case COMMAND_LASTNAME : { Command_LastName(client, sep); break; }
  4226. case COMMAND_CONFIRMLASTNAME : { Command_ConfirmLastName(client, sep); break; }
  4227. case COMMAND_PET : { Command_Pet(client, sep); break; }
  4228. case COMMAND_PETNAME : { Command_PetName(client, sep); break; }
  4229. case COMMAND_NAME_PET : { Command_NamePet(client, sep); break; }
  4230. case COMMAND_RENAME : { Command_Rename(client, sep); break; }
  4231. case COMMAND_CONFIRMRENAME : { Command_ConfirmRename(client, sep); break; }
  4232. case COMMAND_PETOPTIONS : { Command_PetOptions(client, sep); break; }
  4233. case COMMAND_START_TRADE : { Command_TradeStart(client, sep); break; }
  4234. case COMMAND_ACCEPT_TRADE : { Command_TradeAccept(client, sep); break; }
  4235. case COMMAND_REJECT_TRADE : { Command_TradeReject(client, sep); break; }
  4236. case COMMAND_CANCEL_TRADE : { Command_TradeCancel(client, sep); break; }
  4237. case COMMAND_SET_TRADE_COIN : { Command_TradeSetCoin(client, sep); break; }
  4238. case COMMAND_ADD_TRADE_COPPER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_COPPER); break; }
  4239. case COMMAND_ADD_TRADE_SILVER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_SILVER); break; }
  4240. case COMMAND_ADD_TRADE_GOLD : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_GOLD); break; }
  4241. case COMMAND_ADD_TRADE_PLAT : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_PLAT); break; }
  4242. case COMMAND_REMOVE_TRADE_COPPER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_COPPER); break; }
  4243. case COMMAND_REMOVE_TRADE_SILVER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_SILVER); break; }
  4244. case COMMAND_REMOVE_TRADE_GOLD : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_GOLD); break; }
  4245. case COMMAND_REMOVE_TRADE_PLAT : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_PLAT); break; }
  4246. case COMMAND_ADD_TRADE_ITEM : { Command_TradeAddItem(client, sep); break; }
  4247. case COMMAND_REMOVE_TRADE_ITEM : { Command_TradeRemoveItem(client, sep); break; }
  4248. case COMMAND_ACCEPT_ADVANCEMENT : { Command_AcceptAdvancement(client, sep); break; }
  4249. case COMMAND_DUEL : { Command_Duel(client, sep); break; }
  4250. case COMMAND_DUELBET : { Command_DuelBet(client, sep); break; }
  4251. case COMMAND_DUEL_ACCEPT : { Command_DuelAccept(client, sep); break; }
  4252. case COMMAND_DUEL_DECLINE : { Command_DuelDecline(client, sep); break; }
  4253. case COMMAND_DUEL_SURRENDER : { Command_DuelSurrender(client, sep); break; }
  4254. case COMMAND_DUEL_TOGGLE : { Command_DuelToggle(client, sep); break; }
  4255. case COMMAND_SPAWN_TEMPLATE : { Command_SpawnTemplate(client, sep); break; }
  4256. case COMMAND_MODIFY : { Command_Modify(client); break; }
  4257. case COMMAND_MODIFY_CHARACTER : { Command_ModifyCharacter(client, sep); break; }
  4258. case COMMAND_MODIFY_QUEST : { Command_ModifyQuest(client, sep); break; }
  4259. case COMMAND_MODIFY_FACTION : { Command_ModifyFaction(client, sep); break; }
  4260. case COMMAND_MODIFY_GUILD : { Command_ModifyGuild(client, sep); break; }
  4261. case COMMAND_MODIFY_ITEM : { Command_ModifyItem(client, sep); break; }
  4262. case COMMAND_MODIFY_SKILL : { Command_ModifySkill(client, sep); break; }
  4263. case COMMAND_MODIFY_SPAWN : { Command_ModifySpawn(client, sep); break; }
  4264. case COMMAND_MODIFY_SPELL : { Command_ModifySpell(client, sep); break; }
  4265. case COMMAND_MODIFY_ZONE : { Command_ModifyZone(client, sep); break; }
  4266. case COMMAND_JOIN_CHANNEL : { Command_JoinChannel(client, sep); break;}
  4267. case COMMAND_JOIN_CHANNEL_FROM_LOAD: { Command_JoinChannelFromLoad(client, sep); break;}
  4268. case COMMAND_TELL_CHANNEL : { Command_TellChannel(client, sep); break;}
  4269. case COMMAND_LEAVE_CHANNEL : { Command_LeaveChannel(client, sep); break;}
  4270. case COMMAND_WHO_CHANNEL : { Command_WhoChannel(client, sep); break;}
  4271. case COMMAND_RAIN : { Command_Rain(client, sep); break; }
  4272. case COMMAND_WIND : { Command_Wind(client, sep); break; }
  4273. case COMMAND_WEATHER : { Command_Weather(client, sep); break; }
  4274. case COMMAND_FROM_MERCHANT : { Command_SendMerchantWindow(client, sep); break; }
  4275. case COMMAND_TO_MERCHANT : { Command_SendMerchantWindow(client, sep, true); break; }
  4276. case COMMAND_SELECT : { Command_Select(client, sep); break; }
  4277. case COMMAND_SMP : { Command_StationMarketPlace(client, sep); break; }
  4278. case COMMAND_CONSUME_FOOD : { Command_ConsumeFood(client, sep); break; }
  4279. case COMMAND_AQUAMAN : { Command_Aquaman(client, sep); break; }
  4280. case COMMAND_ATTUNE_INV : { Command_Attune_Inv(client, sep); break; }
  4281. case COMMAND_PLAYER : { Command_Player(client, sep); break; }
  4282. case COMMAND_PLAYER_COINS : { Command_Player_Coins(client, sep); break; }
  4283. case COMMAND_RESET_ZONE_TIMER : { Command_Reset_Zone_Timer(client, sep); break; }
  4284. case COMMAND_ACHIEVEMENT_ADD : { Command_AchievementAdd(client, sep); break; }
  4285. case COMMAND_EDITOR : { Command_Editor(client, sep); break; }
  4286. case COMMAND_ACCEPT_RESURRECTION: { Command_AcceptResurrection(client, sep); break; }
  4287. case COMMAND_DECLINE_RESURRECTION:{ Command_DeclineResurrection(client, sep); break; }
  4288. case COMMAND_TEST : { Command_Test(client, command_parms); break; }
  4289. case COMMAND_SPEED : { Command_Speed(client, sep); break; }
  4290. case COMMAND_BOT : { Command_Bot(client, sep); break; }
  4291. case COMMAND_BOT_CREATE : { Command_Bot_Create(client, sep); break; }
  4292. case COMMAND_BOT_CUSTOMIZE : { Command_Bot_Customize(client, sep); break; }
  4293. case COMMAND_BOT_SPAWN : { Command_Bot_Spawn(client, sep); break; }
  4294. case COMMAND_BOT_LIST : { Command_Bot_List(client, sep); break; }
  4295. case COMMAND_BOT_INV : { Command_Bot_Inv(client, sep); break; }
  4296. case COMMAND_BOT_SETTINGS : { Command_Bot_Settings(client, sep); break; }
  4297. case COMMAND_BOT_HELP : { Command_Bot_Help(client, sep); break; }
  4298. case GET_AA_XML : { Get_AA_Xml(client, sep); break; }
  4299. case ADD_AA : { Add_AA(client, sep); break; }
  4300. case COMMIT_AA_PROFILE : { Commit_AA_Profile(client, sep); break; }
  4301. case BEGIN_AA_PROFILE : { Begin_AA_Profile(client, sep); break; }
  4302. case BACK_AA : { Back_AA(client, sep); break; }
  4303. case REMOVE_AA : { Remove_AA(client, sep); break; }
  4304. case SWITCH_AA_PROFILE : { Switch_AA_Profile(client, sep); break; }
  4305. case CANCEL_AA_PROFILE : { Cancel_AA_Profile(client, sep); break; }
  4306. case SAVE_AA_PROFILE : { Save_AA_Profile(client, sep); break; }
  4307. case COMMAND_TARGETITEM : { Command_TargetItem(client, sep); break; }
  4308. case COMMAND_FINDSPAWN: { Command_FindSpawn(client, sep); break; }
  4309. default:
  4310. {
  4311. LogWrite(COMMAND__WARNING, 0, "Command", "Unhandled command: %s", command->command.data.c_str());
  4312. break;
  4313. }
  4314. }
  4315. safe_delete(sep);
  4316. }
  4317. /******************** New COMMAND Handler Functions ********************/
  4318. /*
  4319. Started breaking apart the huge switch() for commands into sepErate
  4320. functions so it is easier to locate the blocks of code by command
  4321. -- JA 2012.03.03
  4322. */
  4323. // sample function header
  4324. /*
  4325. Function:
  4326. Purpose :
  4327. Params :
  4328. Dev :
  4329. Example :
  4330. */
  4331. //void Commands::Command()
  4332. //{
  4333. //}
  4334. /*
  4335. Function: Command_AcceptAdvancement()
  4336. Purpose : Player accepts a new advancement option
  4337. Params : Spell ID
  4338. Dev : Jabantiz
  4339. */
  4340. void Commands::Command_AcceptAdvancement(Client* client, Seperator* sep)
  4341. {
  4342. Player *player = client->GetPlayer();
  4343. if (sep && sep->IsSet(0)) {
  4344. TraitData* trait = master_trait_list.GetTrait(atoul(sep->arg[0]));
  4345. // Check to see if this is a trait or grandmaster training (traits are always new spells, training is always upgrades)
  4346. if (!player->HasSpell(trait->spellID, 0, true))
  4347. {
  4348. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  4349. player->AddSpellBookEntry(trait->spellID, trait->tier, player->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  4350. }
  4351. else
  4352. {
  4353. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  4354. int8 old_slot = player->GetSpellSlot(spell->GetSpellID());
  4355. player->RemoveSpellBookEntry(spell->GetSpellID());
  4356. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  4357. player->UnlockSpell(spell);
  4358. client->SendSpellUpdate(spell);
  4359. }
  4360. // Spell book update
  4361. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  4362. client->QueuePacket(master_trait_list.GetTraitListPacket(client));
  4363. }
  4364. }
  4365. /*
  4366. Function:
  4367. Purpose :
  4368. Params :
  4369. Dev :
  4370. Example :
  4371. */
  4372. void Commands::Command_AFK(Client* client, Seperator* sep)
  4373. {
  4374. Player* player = client->GetPlayer();
  4375. player->toggle_character_flag(CF_AFK);
  4376. client->Message(CHANNEL_COLOR_YELLOW,"You are %s afk.", client->GetPlayer()->get_character_flag(CF_AFK)?"now":"no longer");
  4377. if (player->get_character_flag(CF_AFK))
  4378. {
  4379. LogWrite(MISC__TODO, 1, "TODO", "player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_AFK); <-- need to find this");
  4380. /*player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_AFK); <-- need to find this */
  4381. if (sep && sep->argplus[0])
  4382. player->SetAwayMessage("I am away from the keyboard, " + string(sep->argplus[0]));
  4383. else
  4384. player->SetAwayMessage("Sorry, I am A.F.K. (Away From Keyboard)");
  4385. string message = string(player->GetName()) + " is going afk.";
  4386. Spawn* target = player->GetTarget();
  4387. if (target && target != player)
  4388. {
  4389. message = string(player->GetName()) + " tells " + string(target->GetName()) + " that ";
  4390. player->GetGender() == 1 ? message += "he" : message += "she";
  4391. message += " is going afk.";
  4392. }
  4393. player->GetZone()->SimpleMessage(CHANNEL_COLOR_YELLOW, message.c_str(), player, 30);
  4394. }
  4395. /*else
  4396. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_AFK); <-- need to find this */
  4397. }
  4398. /*
  4399. Function: Command_Appearance()
  4400. Purpose : Handles /appearance commands
  4401. Params : list
  4402. Dev : Scatman
  4403. Example : /appearance list
  4404. */
  4405. void Commands::Command_Appearance(Client* client, Seperator* sep, int handler)
  4406. {
  4407. if( handler == COMMAND_APPEARANCE )
  4408. {
  4409. // /appearance command by itself shows help (to be extended)
  4410. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  4411. return;
  4412. }
  4413. else if( handler == COMMAND_APPEARANCE_LIST )
  4414. {
  4415. // /appearance list command expects "name" param
  4416. if (sep && sep->arg[0])
  4417. {
  4418. const char* appearance_name = sep->argplus[0];
  4419. client->Message(CHANNEL_COLOR_YELLOW, "Listing appearances like '%s':", appearance_name);
  4420. vector<int16>* appearances = database.GetAppearanceIDsLikeName(string(appearance_name));
  4421. if (appearances)
  4422. {
  4423. vector<int16>::iterator itr;
  4424. for (itr = appearances->begin(); itr != appearances->end(); itr++)
  4425. {
  4426. int16 id = *itr;
  4427. string name = database.GetAppearanceName(id);
  4428. if (ToLower(name).find(ToLower(string(appearance_name))) < 0xFFFFFFFF)
  4429. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", name.c_str(), id);
  4430. }
  4431. safe_delete(appearances);
  4432. }
  4433. }
  4434. else // no param
  4435. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  4436. }
  4437. }
  4438. /*
  4439. Function: Command_Claim()
  4440. Purpose :
  4441. Params :
  4442. Dev :
  4443. Example :
  4444. */
  4445. void Commands::Command_Claim(Client* client, Seperator* sep)
  4446. {
  4447. if (sep && sep->arg[0] && sep->IsNumber(0))
  4448. {
  4449. LogWrite(MISC__TODO, 1, "TODO", "On Scatman's TODO list!\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  4450. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "On Scatman's TODO :)");
  4451. }
  4452. else
  4453. client->ShowClaimWindow();
  4454. }
  4455. /*
  4456. Function: Command_ClearAllQueued()
  4457. Purpose :
  4458. Params :
  4459. Dev :
  4460. Example :
  4461. */
  4462. void Commands::Command_ClearAllQueued(Client* client)
  4463. {
  4464. ZoneServer* zone = client->GetPlayer()->GetZone();
  4465. if (zone && zone->GetSpellProcess())
  4466. zone->GetSpellProcess()->RemoveSpellFromQueue(client->GetPlayer());
  4467. }
  4468. /*
  4469. Function: Command_CancelMaintained()
  4470. Purpose : Cancels maintained spells
  4471. Params : Maintained Spell Index
  4472. Dev : Zcoretri
  4473. Example : /cancel_maintained 1 - would cancel the spell in slot 1 of Maintained Spells list
  4474. */
  4475. void Commands::Command_CancelMaintained(Client* client, Seperator* sep)
  4476. {
  4477. if (sep && sep->arg[0] && sep->IsNumber(0))
  4478. {
  4479. int32 spell_index = atoul(sep->arg[0]);
  4480. MaintainedEffects mEffects = client->GetPlayer()->GetInfoStruct()->maintained_effects[spell_index];
  4481. //Spell* spell = master_spell_list.GetSpell(mEffects.spell_id, mEffects.tier);
  4482. // if (spell && spell->GetSpellData()->friendly_spell) -- NOTE::You can cancel hostile maintained spells,
  4483. // just not spelleffects/dets - Foof
  4484. //{
  4485. if (!client->GetPlayer()->GetZone()->GetSpellProcess()->DeleteCasterSpell(mEffects.spell, "canceled"))
  4486. client->Message(CHANNEL_COLOR_RED, "The maintained spell could not be cancelled.");
  4487. // }
  4488. //else
  4489. //client->Message(CHANNEL_COLOR_RED, "You can only cancel friendly spells!");
  4490. }
  4491. }
  4492. /*
  4493. Function: Command_Create()
  4494. Purpose : Handler for starting Tradeskilling table
  4495. Params :
  4496. Dev : Zcoretri
  4497. Example :
  4498. */
  4499. void Commands::Command_Create(Client* client, Seperator* sep)
  4500. {
  4501. PrintSep(sep, "COMMAND_CREATE");
  4502. client->SendRecipeList();
  4503. client->ShowRecipeBook();
  4504. }
  4505. void Commands::Command_CreateFromRecipe(Client* client, Seperator* sep)
  4506. {
  4507. PrintSep(sep, "COMMAND_CREATEFROMRECIPE");
  4508. if (sep && sep->arg[0] && sep->IsNumber(0))
  4509. ClientPacketFunctions::SendCreateFromRecipe(client, atoul(sep->arg[0]));
  4510. }
  4511. /*
  4512. Function: Command_Distance()
  4513. Purpose : Displays distance from targeted spawn
  4514. Params :
  4515. Dev : Scatman
  4516. Example : /distance
  4517. */
  4518. void Commands::Command_Distance(Client* client)
  4519. {
  4520. Spawn* target = client->GetPlayer()->GetTarget();
  4521. if (target)
  4522. client->Message(CHANNEL_COLOR_YELLOW, "Your distance from %s is %f", target->GetName(), client->GetPlayer()->GetDistance(target));
  4523. else
  4524. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must have a spawn targeted to use /distance");
  4525. }
  4526. /*
  4527. Function: Command_Duel()
  4528. Purpose : Handle the /duel commands - not yet implemented
  4529. Params : unknown
  4530. Dev :
  4531. Example :
  4532. */
  4533. void Commands::Command_Duel(Client* client, Seperator* sep)
  4534. {
  4535. PrintSep(sep, "COMMAND_DUEL");
  4536. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Command");
  4537. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4538. }
  4539. /*
  4540. Function: Command_DuelBet()
  4541. Purpose : Handle the /duel commands - not yet implemented
  4542. Params : unknown
  4543. Dev :
  4544. Example :
  4545. */
  4546. void Commands::Command_DuelBet(Client* client, Seperator* sep)
  4547. {
  4548. PrintSep(sep, "COMMAND_DUELBET");
  4549. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Bet Command");
  4550. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4551. }
  4552. /*
  4553. Function: Command_DuelAccept()
  4554. Purpose : Handle the /duel commands - not yet implemented
  4555. Params : unknown
  4556. Dev :
  4557. Example :
  4558. */
  4559. void Commands::Command_DuelAccept(Client* client, Seperator* sep)
  4560. {
  4561. PrintSep(sep, "COMMAND_DUEL_ACCEPT");
  4562. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Accept Duel Command");
  4563. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4564. }
  4565. /*
  4566. Function: Command_DuelDecline()
  4567. Purpose : Handle the /duel commands - not yet implemented
  4568. Params : unknown
  4569. Dev :
  4570. Example :
  4571. */
  4572. void Commands::Command_DuelDecline(Client* client, Seperator* sep)
  4573. {
  4574. PrintSep(sep, "COMMAND_DUEL_DECLINE");
  4575. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Decline Duel Request Command");
  4576. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4577. }
  4578. /*
  4579. Function: Command_DuelSurrender()
  4580. Purpose : Handle the /duel commands - not yet implemented
  4581. Params : unknown
  4582. Dev :
  4583. Example :
  4584. */
  4585. void Commands::Command_DuelSurrender(Client* client, Seperator* sep)
  4586. {
  4587. PrintSep(sep, "COMMAND_DUEL_SURRENDER");
  4588. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Surrender Duel Command");
  4589. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4590. // JA, just messin around ;)
  4591. char surrender[64];
  4592. sprintf(surrender, "%s surrendered like a cowardly dog!", client->GetPlayer()->GetName());
  4593. zone_list.HandleGlobalAnnouncement(surrender);
  4594. }
  4595. /*
  4596. Function: Command_DuelToggle()
  4597. Purpose : Handle the /duel commands - not yet implemented
  4598. Params : unknown
  4599. Dev :
  4600. Example :
  4601. */
  4602. void Commands::Command_DuelToggle(Client* client, Seperator* sep)
  4603. {
  4604. PrintSep(sep, "COMMAND_DUEL");
  4605. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Commands");
  4606. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4607. }
  4608. /*
  4609. Function:
  4610. Purpose :
  4611. Params :
  4612. Dev :
  4613. Example :
  4614. */
  4615. void Commands::Command_EntityCommand(Client* client, Seperator* sep, int handler)
  4616. {
  4617. if( handler == COMMAND_ENTITYCOMMAND )
  4618. {
  4619. // /entitycommand command by itself shows help (to be extended)
  4620. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  4621. return;
  4622. }
  4623. else if( handler == COMMAND_ENTITYCOMMAND_LIST )
  4624. {
  4625. // /entitycommand list command expects "name" param
  4626. if (sep && sep->arg[0])
  4627. {
  4628. const char* entity_command_name = sep->argplus[0];
  4629. client->Message(CHANNEL_COLOR_YELLOW, "Listing entity commands like '%s':", entity_command_name);
  4630. map<int32, vector<EntityCommand*>*>* entity_command_list_all = client->GetCurrentZone()->GetEntityCommandListAll();
  4631. map<int32, vector<EntityCommand*>*>::iterator itr;
  4632. for (itr = entity_command_list_all->begin(); itr != entity_command_list_all->end(); itr++)
  4633. {
  4634. vector<EntityCommand*>* entity_command_list = itr->second;
  4635. vector<EntityCommand*>::iterator itr2;
  4636. for (itr2 = entity_command_list->begin(); itr2 != entity_command_list->end(); itr2++)
  4637. {
  4638. EntityCommand* entity_command = *itr2;
  4639. if (ToLower(entity_command->name).find(ToLower(string(entity_command_name))) < 0xFFFFFFFF)
  4640. 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);
  4641. }
  4642. }
  4643. }
  4644. else // no command name
  4645. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  4646. }
  4647. }
  4648. /*
  4649. Function: Command_Follow()
  4650. Purpose : Handle the /follow command - not yet implemented
  4651. Params :
  4652. Dev :
  4653. Example :
  4654. */
  4655. void Commands::Command_Follow(Client* client, Seperator* sep)
  4656. {
  4657. PrintSep(sep, "COMMAND_FOLLOW");
  4658. // flag to toggle if the players target is in the players group
  4659. bool targetInGroup = false;
  4660. // get a pointer to the players group
  4661. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  4662. // If the player has a group and has a target
  4663. if (gmi && client->GetPlayer()->GetTarget()) {
  4664. deque<GroupMemberInfo*>::iterator itr;
  4665. world.GetGroupManager()->GroupLock(__FUNCTION__, __LINE__);
  4666. PlayerGroup* group = world.GetGroupManager()->GetGroup(gmi->group_id);
  4667. if (group)
  4668. {
  4669. group->MGroupMembers.readlock(__FUNCTION__, __LINE__);
  4670. deque<GroupMemberInfo*>* members = group->GetMembers();
  4671. // Loop through the group members
  4672. for (itr = members->begin(); itr != members->end(); itr++) {
  4673. // If a group member matches a target
  4674. if ((*itr)->member == client->GetPlayer()->GetTarget()) {
  4675. // toggle the flag and break the loop
  4676. targetInGroup = true;
  4677. break;
  4678. }
  4679. }
  4680. group->MGroupMembers.releasereadlock(__FUNCTION__, __LINE__);
  4681. }
  4682. world.GetGroupManager()->ReleaseGroupLock(__FUNCTION__, __LINE__);
  4683. }
  4684. if (targetInGroup) {
  4685. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  4686. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You start to follow %s.", client->GetPlayer()->GetTarget()->GetName());
  4687. client->GetPlayer()->SetFollowTarget(client->GetPlayer()->GetTarget());
  4688. client->GetPlayer()->info_changed = true;
  4689. client->GetPlayer()->changed = true;
  4690. }
  4691. else
  4692. client->Message(CHANNEL_NARRATIVE, "You must first select a group member to follow.");
  4693. }
  4694. /*
  4695. Function: Command_StopFollow()
  4696. Purpose : Handle the /stop_follow command - not yet implemented
  4697. Params :
  4698. Dev :
  4699. Example :
  4700. */
  4701. void Commands::Command_StopFollow(Client* client, Seperator* sep)
  4702. {
  4703. PrintSep(sep, "COMMAND_STOP_FOLLOW");
  4704. if (client->GetPlayer()->GetFollowTarget()) {
  4705. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  4706. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You are no longer following %s", client->GetPlayer()->GetFollowTarget()->GetName());
  4707. client->GetPlayer()->SetFollowTarget(0);
  4708. client->GetPlayer()->info_changed = true;
  4709. client->GetPlayer()->changed = true;
  4710. }
  4711. }
  4712. #include "../Zone/SPGrid.h"
  4713. /*
  4714. Function: Command_Grid()
  4715. Purpose : Show player's current Grid ID
  4716. Params :
  4717. Dev : Scatman
  4718. Example : /grid
  4719. */
  4720. void Commands::Command_Grid(Client* client)
  4721. {
  4722. client->Message(CHANNEL_COLOR_YELLOW, "Your Grid ID is %u", client->GetPlayer()->appearance.pos.grid_id);
  4723. if (client->GetPlayer()->GetMap() != nullptr) {
  4724. int32 grid = client->GetPlayer()->GetMap()->GetGrid()->GetGridID(client->GetPlayer());
  4725. client->Message(CHANNEL_COLOR_YELLOW, "SPGrid result is %u", grid);
  4726. }
  4727. }
  4728. /*
  4729. Function: Command_Guild()
  4730. Purpose : Handler for all UI-related guild commands
  4731. Dev : Scatman
  4732. */
  4733. void Commands::Command_Guild(Client* client, Seperator* sep)
  4734. {
  4735. Guild* guild = client->GetPlayer()->GetGuild();
  4736. if (sep && sep->GetMaxArgNum() > 0 && sep->arg[0])
  4737. {
  4738. const char* command = sep->arg[0];
  4739. int32 length = strlen(command);
  4740. LogWrite(COMMAND__DEBUG, 0, "Command", "Guild Command: %s", command);
  4741. if (strncmp(command, "rank_name", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && guild)
  4742. guild->SetRankName(atoi(sep->arg[1]), sep->argplus[2]);
  4743. else if (strncmp(command, "rank_permission", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  4744. guild->SetPermission(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  4745. else if (strncmp(command, "filter_event", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  4746. guild->SetEventFilter(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  4747. else if (strncmp(command, "kick", length) == 0 && sep->arg[1] && guild)
  4748. guild->KickGuildMember(client, sep->arg[1]);
  4749. else if (strncmp(command, "demote", length) == 0 && sep->arg[1] && guild)
  4750. guild->DemoteGuildMember(client, sep->arg[1]);
  4751. else if (strncmp(command, "promote", length) == 0 && sep->arg[1] && guild)
  4752. guild->PromoteGuildMember(client, sep->arg[1]);
  4753. else if (strncmp(command, "points", length) == 0 && guild)
  4754. {
  4755. if (sep->arg[1] && strncmp(sep->arg[1], "add", length) == 0)
  4756. {
  4757. if (sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  4758. {
  4759. float points = atof(sep->arg[2]);
  4760. const char* option = sep->arg[3];
  4761. const char* comment = sep->argplus[4];
  4762. if (strncmp(option, "all", strlen(option)) == 0)
  4763. guild->AddPointsToAll(client, points, comment);
  4764. else if (strncmp(option, "online", strlen(option)) == 0)
  4765. guild->AddPointsToAllOnline(client, points, comment);
  4766. else if (strncmp(option, "group", strlen(option)) == 0)
  4767. guild->AddPointsToGroup(client, points, comment);
  4768. else if (strncmp(option, "raid", strlen(option)) == 0)
  4769. guild->AddPointsToRaid(client, points, comment);
  4770. else
  4771. guild->AddPointsToGuildMember(client, points, option, comment);
  4772. }
  4773. }
  4774. else if (sep->arg[1] && strncmp(sep->arg[1], "view", strlen(sep->arg[1])) == 0 && sep->arg[2])
  4775. guild->ViewGuildMemberPoints(client, sep->arg[2]);
  4776. else
  4777. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild points command: %s", sep->argplus[0]);
  4778. }
  4779. else if (strncmp(command, "motd", length) == 0 && sep->arg[1] && guild)
  4780. guild->SetMOTD(sep->argplus[1]);
  4781. else if (strncmp(command, "recruiting", length) == 0 && guild)
  4782. {
  4783. if (sep->arg[1])
  4784. {
  4785. const char* option = sep->arg[1];
  4786. if (strncmp(option, "short_text", strlen(option)) == 0 && sep->arg[2])
  4787. guild->SetRecruitingShortDesc(sep->argplus[2]);
  4788. else if (strncmp(option, "long_text", strlen(option)) == 0 && sep->arg[2])
  4789. guild->SetRecruitingFullDesc(sep->argplus[2]);
  4790. else if (strncmp(option, "flag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  4791. guild->SetRecruitingFlag(atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  4792. else if (strncmp(option, "min_level", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  4793. guild->SetRecruitingMinLevel(atoi(sep->arg[2]));
  4794. else if (strncmp(option, "playstyle", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  4795. guild->SetRecruitingPlayStyle(atoi(sep->arg[2]));
  4796. else if (strncmp(option, "tag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && sep->IsNumber(3))
  4797. guild->SetRecruitingDescTag(atoi(sep->arg[2]), atoi(sep->arg[3]));
  4798. else if (strncmp(command, "recruiting", strlen(option)) == 0)
  4799. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_RECRUITING_FOR_GUILD, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  4800. else
  4801. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  4802. }
  4803. else
  4804. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  4805. }
  4806. else if (strncmp(command, "notify_online", length) == 0 && sep->arg[1] && guild)
  4807. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_NOTIFY_LOGINS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  4808. else if (strncmp(command, "event_privacy", length) == 0 && sep->arg[1] && guild)
  4809. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_DONT_GENERATE_EVENTS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  4810. else if (strncmp(command, "recruiter", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  4811. guild->SetGuildRecruiter(client, sep->arg[1], strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  4812. else if (strncmp(command, "recruiter_description", length) == 0 && sep->arg[1] && guild)
  4813. guild->SetGuildRecruiterDescription(client, sep->argplus[1]);
  4814. else if (strncmp(command, "lock_event", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  4815. guild->LockGuildEvent(atoul(sep->arg[1]), strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  4816. else if (strncmp(command, "delete_event", length) == 0 && sep->arg[1] && guild)
  4817. guild->DeleteGuildEvent(atoul(sep->arg[1]));
  4818. else if (strncmp(command, "invite", length) == 0 && guild)
  4819. {
  4820. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  4821. guild->InvitePlayer(client, sep->arg[1]);
  4822. else
  4823. {
  4824. Spawn* target = client->GetPlayer()->GetTarget();
  4825. if (target)
  4826. {
  4827. if (target->IsPlayer())
  4828. guild->InvitePlayer(client, target->GetName());
  4829. else
  4830. client->Message(CHANNEL_NARRATIVE, "%s is not a player.", target->GetName());
  4831. }
  4832. }
  4833. }
  4834. else if (strncmp(command, "accept", length) == 0)
  4835. {
  4836. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  4837. if (pgi && pgi->guild && pgi->invited_by)
  4838. pgi->guild->AddNewGuildMember(client, pgi->invited_by->GetName());
  4839. client->SetPendingGuildInvite(0);
  4840. }
  4841. else if (strncmp(command, "decline", length) == 0)
  4842. {
  4843. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  4844. if (pgi && pgi->guild && pgi->invited_by)
  4845. {
  4846. Client* client_inviter = pgi->invited_by->GetZone()->GetClientBySpawn(pgi->invited_by);
  4847. if (client_inviter)
  4848. client_inviter->Message(CHANNEL_NARRATIVE, "%s has declined your invitation to join %s.", client->GetPlayer()->GetName(), pgi->guild->GetName());
  4849. }
  4850. client->SetPendingGuildInvite(0);
  4851. }
  4852. else if (strncmp(command, "create", length) == 0 && sep->arg[1])
  4853. {
  4854. const char* guild_name = sep->argplus[1];
  4855. if (!guild_list.GetGuild(guild_name))
  4856. world.CreateGuild(guild_name, client, client->GetPlayer()->GetGroupMemberInfo() ? client->GetPlayer()->GetGroupMemberInfo()->group_id : 0);
  4857. else
  4858. client->SimpleMessage(CHANNEL_NARRATIVE, "A guild with that name already exists.");
  4859. }
  4860. else if (strncmp(command, "search", length) == 0)
  4861. client->ShowGuildSearchWindow();
  4862. else if (strncmp(command, "recruiting_details", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  4863. {
  4864. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  4865. if (to_guild)
  4866. to_guild->SendGuildRecruitingDetails(client);
  4867. }
  4868. else if (strncmp(command, "recruiting_image", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  4869. {
  4870. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  4871. if (to_guild)
  4872. to_guild->SendGuildRecruitingImages(client);
  4873. }
  4874. else if (strncmp(command, "recruiter_adventure_class", length) == 0)
  4875. {
  4876. if (sep->arg[1])
  4877. {
  4878. const char* option = sep->arg[1];
  4879. if (strncmp(option, "toggle", strlen(option)) == 0)
  4880. guild->ToggleGuildRecruiterAdventureClass(client);
  4881. }
  4882. else
  4883. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiter_adventure_class command: '%s'", sep->argplus[0]);
  4884. }
  4885. else if (strncmp(command, "display_heraldry", length) == 0)
  4886. {
  4887. // JA: not sure this is right...
  4888. client->GetPlayer()->toggle_character_flag(CF_SHOW_GUILD_HERALDRY);
  4889. client->GetPlayer()->SetCharSheetChanged(true);
  4890. }
  4891. else
  4892. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild command: '%s'", sep->argplus[0]);
  4893. }
  4894. }
  4895. /*
  4896. Function: Command_GuildCreate()
  4897. Purpose : Display's in-game Guild Creation window
  4898. Dev : Scatman
  4899. */
  4900. void Commands::Command_CreateGuild(Client* client)
  4901. {
  4902. client->SendGuildCreateWindow();
  4903. }
  4904. /*
  4905. Function: Command_SetGuildOfficerNote()
  4906. Purpose :
  4907. Dev : Scatman
  4908. */
  4909. void Commands::Command_SetGuildOfficerNote(Client* client, Seperator* sep)
  4910. {
  4911. if (sep && sep->arg[0] && sep->arg[1])
  4912. {
  4913. Guild* guild = client->GetPlayer()->GetGuild();
  4914. if (guild)
  4915. guild->SetGuildOfficerNote(sep->arg[0], sep->argplus[1]);
  4916. }
  4917. }
  4918. /*
  4919. Function: Command_SetGuildMemberNote()
  4920. Purpose :
  4921. Dev : Scatman
  4922. */
  4923. void Commands::Command_SetGuildMemberNote(Client* client, Seperator* sep)
  4924. {
  4925. if (sep && sep->arg[0] && sep->arg[1])
  4926. {
  4927. Guild* guild = client->GetPlayer()->GetGuild();
  4928. if (guild)
  4929. guild->SetGuildMemberNote(sep->arg[0], sep->argplus[1]);
  4930. }
  4931. }
  4932. /*
  4933. Function: Command_GuildSay()
  4934. Purpose :
  4935. Dev : Scatman
  4936. */
  4937. void Commands::Command_GuildSay(Client* client, Seperator* sep)
  4938. {
  4939. Guild* guild = client->GetPlayer()->GetGuild();
  4940. if (guild)
  4941. {
  4942. if (sep && sep->arg[0])
  4943. guild->HandleGuildSay(client, sep->argplus[0]);
  4944. }
  4945. else
  4946. client->SimpleMessage(CHANNEL_NARRATIVE, "You are not a member of a guild");
  4947. }
  4948. /*
  4949. Function: Command_OfficerSay()
  4950. Purpose :
  4951. Dev : Scatman
  4952. */
  4953. void Commands::Command_OfficerSay(Client* client, Seperator* sep)
  4954. {
  4955. Guild* guild = client->GetPlayer()->GetGuild();
  4956. if (guild)
  4957. {
  4958. if (sep && sep->arg[0])
  4959. guild->HandleOfficerSay(client, sep->argplus[0]);
  4960. }
  4961. else
  4962. client->SimpleMessage(CHANNEL_NARRATIVE, "You are not a member of a guild");
  4963. }
  4964. /*
  4965. Function: Command_Guilds()
  4966. Purpose : Shows help for /guild command
  4967. Params :
  4968. Dev : Scatman
  4969. Example :
  4970. */
  4971. void Commands::Command_Guilds(Client* client)
  4972. {
  4973. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds [create|delete|add|remove|list]");
  4974. }
  4975. /*
  4976. Function: Command_GuildsAdd()
  4977. Purpose : Add's players to a guild
  4978. Params : guild_name|guild_id, player name
  4979. Dev : Scatman
  4980. Example : /guilds add 1 Admin = adds player Admin to guild_id 1
  4981. */
  4982. void Commands::Command_GuildsAdd(Client* client, Seperator* sep)
  4983. {
  4984. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  4985. {
  4986. Guild* guild = 0;
  4987. bool found = true;
  4988. if (sep->IsNumber(0))
  4989. {
  4990. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  4991. if (!guild)
  4992. {
  4993. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  4994. found = false;
  4995. }
  4996. }
  4997. else
  4998. {
  4999. guild = guild_list.GetGuild(sep->arg[0]);
  5000. if (!guild)
  5001. {
  5002. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  5003. found = false;
  5004. }
  5005. }
  5006. if (found)
  5007. {
  5008. Client* to_client = 0;
  5009. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  5010. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  5011. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  5012. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  5013. if (to_client)
  5014. guild->InvitePlayer(client, to_client->GetPlayer()->GetName());
  5015. else
  5016. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  5017. }
  5018. }
  5019. else
  5020. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds add [guild name|guild id] (player name).");
  5021. }
  5022. /*
  5023. Function: Command_GuildsCreate()
  5024. Purpose : Creates a guild
  5025. Params : guild_name, player_name (optional)
  5026. Dev : Scatman
  5027. Example : /guilds create [guild name] (player name)
  5028. */
  5029. void Commands::Command_GuildsCreate(Client* client, Seperator* sep)
  5030. {
  5031. if (sep && sep->arg[0])
  5032. {
  5033. const char* guild_name = sep->arg[0];
  5034. if (!guild_list.GetGuild(guild_name))
  5035. {
  5036. bool ret = false;
  5037. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  5038. {
  5039. Client* to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  5040. if (to_client)
  5041. {
  5042. world.CreateGuild(guild_name, to_client);
  5043. ret = true;
  5044. }
  5045. else
  5046. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player with name '%s'", sep->arg[1]);
  5047. }
  5048. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  5049. {
  5050. Client* to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  5051. if (to_client)
  5052. {
  5053. world.CreateGuild(guild_name, to_client);
  5054. ret = true;
  5055. }
  5056. }
  5057. else
  5058. {
  5059. world.CreateGuild(guild_name);
  5060. ret = true;
  5061. }
  5062. if (ret)
  5063. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully created.", guild_name);
  5064. else
  5065. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the guild.");
  5066. }
  5067. else
  5068. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' already exists.", guild_name);
  5069. }
  5070. else
  5071. 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.");
  5072. }
  5073. /*
  5074. Function: Command_GuildsDelete()
  5075. Purpose : Delete's a guild
  5076. Params : guild name
  5077. Dev : Scatman
  5078. Example : /guilds delete Test
  5079. */
  5080. void Commands::Command_GuildsDelete(Client* client, Seperator* sep)
  5081. {
  5082. if (sep && sep->arg[0])
  5083. {
  5084. Guild* guild = 0;
  5085. bool found = true;
  5086. if (sep->IsNumber(0))
  5087. {
  5088. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  5089. if (!guild)
  5090. {
  5091. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  5092. found = false;
  5093. }
  5094. }
  5095. else
  5096. {
  5097. guild = guild_list.GetGuild(sep->arg[0]);
  5098. if (!guild)
  5099. {
  5100. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  5101. found = false;
  5102. }
  5103. }
  5104. if (found)
  5105. {
  5106. guild->RemoveAllGuildMembers();
  5107. database.DeleteGuild(guild);
  5108. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully deleted.", guild->GetName());
  5109. guild_list.RemoveGuild(guild, true);
  5110. }
  5111. }
  5112. else
  5113. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds delete [guild name].");
  5114. }
  5115. /*
  5116. Function: Command_GuildsList()
  5117. Purpose : Lists current guilds on server
  5118. Params :
  5119. Dev : Scatman
  5120. Example : /guilds list
  5121. */
  5122. void Commands::Command_GuildsList(Client* client)
  5123. {
  5124. MutexMap<int32, Guild*>* guilds = guild_list.GetGuilds();
  5125. MutexMap<int32, Guild*>::iterator itr = guilds->begin();
  5126. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Guild List:");
  5127. if (guilds->size() == 0)
  5128. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "None.");
  5129. else {
  5130. while (itr.Next()) {
  5131. Guild* guild = itr.second;
  5132. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", guild->GetID(), guild->GetName());
  5133. }
  5134. }
  5135. }
  5136. /*
  5137. Function: Command_GuildsRemove()
  5138. Purpose : Removes a player from a guild
  5139. Params : guild name|guild id, player name
  5140. Dev : Scatman
  5141. Example : /guilds remove 1 Admin = removes Admin from guild 1
  5142. */
  5143. void Commands::Command_GuildsRemove(Client* client, Seperator* sep)
  5144. {
  5145. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  5146. {
  5147. Guild* guild = 0;
  5148. bool found = true;
  5149. if (sep->IsNumber(0))
  5150. {
  5151. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  5152. if (!guild)
  5153. {
  5154. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  5155. found = false;
  5156. }
  5157. }
  5158. else
  5159. {
  5160. guild = guild_list.GetGuild(sep->arg[0]);
  5161. if (!guild)
  5162. {
  5163. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  5164. found = false;
  5165. }
  5166. }
  5167. if (found)
  5168. {
  5169. Client* to_client = 0;
  5170. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  5171. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  5172. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  5173. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  5174. if (to_client)
  5175. {
  5176. Player* to_player = to_client->GetPlayer();
  5177. if (to_player->GetGuild())
  5178. {
  5179. if (to_player->GetGuild() == guild)
  5180. {
  5181. guild->KickGuildMember(client, to_player->GetName());
  5182. }
  5183. else
  5184. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in the guild '%s'.", to_player->GetName(), guild->GetName());
  5185. }
  5186. else
  5187. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in a guild.", to_player->GetName());
  5188. }
  5189. else
  5190. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  5191. }
  5192. }
  5193. else
  5194. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds remove [guild name|guild id] (player name).");
  5195. }
  5196. /*
  5197. Function: Command_InspectPlayer()
  5198. Purpose : Handle the Inspect functions
  5199. Params : Client to inspect
  5200. Dev : Scatman
  5201. Example : /inspect Scatman
  5202. */
  5203. void Commands::Command_InspectPlayer(Client* client, Seperator* sep)
  5204. {
  5205. if (sep && sep->arg[0])
  5206. {
  5207. Client* inspect_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  5208. if (inspect_client)
  5209. client->InspectPlayer(inspect_client->GetPlayer());
  5210. }
  5211. else
  5212. {
  5213. Spawn* target = client->GetPlayer()->GetTarget();
  5214. if (target && target->IsPlayer())
  5215. client->InspectPlayer((Player*)target);
  5216. }
  5217. }
  5218. /*
  5219. Function: Command_Inventory()
  5220. Purpose : Handle changes in player inventory
  5221. Params : <TBD>
  5222. Dev : All
  5223. Example : /inventory delete item_id
  5224. */
  5225. void Commands::Command_Inventory(Client* client, Seperator* sep, EQ2_RemoteCommandString* command)
  5226. {
  5227. PrintSep(sep, "Command_Inventory"); // temp to figure out the params
  5228. Player* player = client->GetPlayer();
  5229. if(sep && sep->arg[0][0])
  5230. {
  5231. LogWrite(COMMAND__INFO, 0, "Command", "command: %s", command->command.data.c_str());
  5232. if(client->GetPlayer()->GetHP() == 0)
  5233. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  5234. else if(sep->arg[1][0] && strncasecmp("destroy", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  5235. {
  5236. int16 index = atoi(sep->arg[1]);
  5237. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  5238. if(item)
  5239. {
  5240. if(item->GetItemScript() && lua_interface)
  5241. lua_interface->RunItemScript(item->GetItemScript(), "destroyed", item, client->GetPlayer());
  5242. int32 bag_id = item->details.inv_slot_id;
  5243. database.DeleteItem(client->GetCharacterID(), item, 0);
  5244. client->GetPlayer()->item_list.DestroyItem(index);
  5245. EQ2Packet* outapp = client->GetPlayer()->SendInventoryUpdate(client->GetVersion());
  5246. client->QueuePacket(outapp);
  5247. outapp = client->GetPlayer()->SendBagUpdate(bag_id, client->GetVersion());
  5248. if (outapp)
  5249. client->QueuePacket(outapp);
  5250. }
  5251. }
  5252. 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))
  5253. {
  5254. int16 from_index = atoi(sep->arg[1]);
  5255. sint16 to_slot = atoi(sep->arg[2]);
  5256. sint32 bag_id = atol(sep->arg[3]);
  5257. int8 charges = atoi(sep->arg[4]);
  5258. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(from_index);
  5259. if(bag_id == -4 && !client->GetPlayer()->item_list.SharedBankAddAllowed(item))
  5260. {
  5261. client->SimpleMessage(CHANNEL_COLOR_RED, "That item (or an item inside) cannot be shared.");
  5262. return;
  5263. }
  5264. sint32 old_inventory_id = 0;
  5265. if(item)
  5266. old_inventory_id = item->details.inv_slot_id;
  5267. //autobank
  5268. if (bag_id == -3 && to_slot == -1)
  5269. {
  5270. if (player->HasFreeBankSlot())
  5271. to_slot = player->FindFreeBankSlot();
  5272. else
  5273. {
  5274. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free bank slots.");
  5275. return;
  5276. }
  5277. }
  5278. //auto inventory
  5279. if (bag_id == 0 && to_slot == -1)
  5280. {
  5281. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  5282. {
  5283. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free slots.");
  5284. return;
  5285. }
  5286. }
  5287. EQ2Packet* outapp = client->GetPlayer()->MoveInventoryItem(bag_id, from_index, (int8)to_slot, charges, client->GetVersion());
  5288. client->QueuePacket(outapp);
  5289. //removed from bag send update
  5290. if(old_inventory_id > 0 && item && item->details.inv_slot_id != old_inventory_id)
  5291. {
  5292. outapp = client->GetPlayer()->SendBagUpdate(old_inventory_id, client->GetVersion());
  5293. if(outapp)
  5294. client->QueuePacket(outapp);
  5295. }
  5296. if(item && item->details.inv_slot_id > 0 && item->details.inv_slot_id != old_inventory_id)
  5297. {
  5298. outapp = client->GetPlayer()->SendBagUpdate(item->details.inv_slot_id, client->GetVersion());
  5299. if(outapp)
  5300. client->QueuePacket(outapp);
  5301. }
  5302. }
  5303. else if(sep->arg[1][0] && strncasecmp("equip", sep->arg[0], 5) == 0 && sep->IsNumber(1))
  5304. {
  5305. if(client->GetPlayer()->EngagedInCombat())
  5306. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not equip items while in combat.");
  5307. else
  5308. {
  5309. int16 index = atoi(sep->arg[1]);
  5310. int8 slot_id = 255;
  5311. if(sep->arg[2][0] && sep->IsNumber(2))
  5312. slot_id = atoi(sep->arg[2]);
  5313. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), slot_id);
  5314. EQ2Packet* outapp = 0;
  5315. for(int32 i=0;i<packets.size();i++)
  5316. {
  5317. outapp = packets[i];
  5318. if(outapp)
  5319. client->QueuePacket(outapp);
  5320. }
  5321. client->GetPlayer()->ChangePrimaryWeapon();
  5322. client->GetPlayer()->ChangeSecondaryWeapon();
  5323. client->GetPlayer()->ChangeRangedWeapon();
  5324. EQ2Packet* characterSheetPackets = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion());
  5325. client->QueuePacket(characterSheetPackets);
  5326. }
  5327. }
  5328. else if (sep->arg[1][0] && strncasecmp("unpack", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  5329. {
  5330. if (client->GetPlayer()->EngagedInCombat())
  5331. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unpack items while in combat.");
  5332. else {
  5333. int16 index = atoi(sep->arg[1]);
  5334. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  5335. if (item) {
  5336. // client->GetPlayer()->item_list.DestroyItem(index);
  5337. if (item->item_sets.size() > 0) {
  5338. for (int32 i = 0; i < item->item_sets.size(); i++) {
  5339. ItemSet* set = item->item_sets[i];
  5340. if (set->item_stack_size == 0)
  5341. set->item_stack_size += 1;
  5342. client->AddItem(set->item_id, set->item_stack_size);
  5343. }
  5344. }
  5345. }
  5346. client->RemoveItem(item, 1);
  5347. }
  5348. }
  5349. else if(sep->arg[1][0] && strncasecmp("unequip", sep->arg[0], 7) == 0 && sep->IsNumber(1))
  5350. {
  5351. if(client->GetPlayer()->EngagedInCombat())
  5352. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unequip items while in combat.");
  5353. else
  5354. {
  5355. int16 index = atoi(sep->arg[1]);
  5356. sint32 bag_id = -999;
  5357. int8 to_slot = 255;
  5358. if(sep->arg[3][0])
  5359. {
  5360. if(sep->IsNumber(2))
  5361. bag_id = atol(sep->arg[2]);
  5362. if(sep->IsNumber(3))
  5363. to_slot = atoi(sep->arg[3]);
  5364. }
  5365. vector<EQ2Packet*> packets = client->GetPlayer()->UnequipItem(index, bag_id, to_slot, client->GetVersion());
  5366. EQ2Packet* outapp = 0;
  5367. for(int32 i=0;i<packets.size();i++)
  5368. {
  5369. outapp = packets[i];
  5370. if(outapp)
  5371. client->QueuePacket(outapp);
  5372. }
  5373. client->GetPlayer()->ChangePrimaryWeapon();
  5374. client->GetPlayer()->ChangeSecondaryWeapon();
  5375. client->GetPlayer()->ChangeRangedWeapon();
  5376. EQ2Packet* characterSheetPackets = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion());
  5377. client->QueuePacket(characterSheetPackets);
  5378. }
  5379. }
  5380. else if(sep->arg[2][0] && strncasecmp("swap_equip", sep->arg[0], 10) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  5381. {
  5382. LogWrite(MISC__TODO, 1, "TODO", " fix this, need to get how live does it\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  5383. int16 index1 = atoi(sep->arg[1]);
  5384. int16 index2 = atoi(sep->arg[2]);
  5385. EQ2Packet* outapp = client->GetPlayer()->SwapEquippedItems(index1, index2, client->GetVersion());
  5386. if(outapp)
  5387. client->QueuePacket(outapp);
  5388. else
  5389. {
  5390. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to swap items");
  5391. return;
  5392. }
  5393. }
  5394. else if (sep->arg[2][0] && strncasecmp("pop", sep->arg[0], 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  5395. {
  5396. sint16 to_slot = atoi(sep->arg[1]);
  5397. sint32 bag_id = atoi(sep->arg[2]);
  5398. Item* item = client->GetPlayer()->item_list.GetOverflowItem();
  5399. if (item) {
  5400. //auto inventory
  5401. if (bag_id == 0 && to_slot == -1)
  5402. {
  5403. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  5404. {
  5405. client->SimpleMessage(CHANNEL_ERROR, "You do not have any free slots.");
  5406. return;
  5407. }
  5408. // Set the slot for the item
  5409. item->details.inv_slot_id = bag_id;
  5410. item->details.slot_id = to_slot;
  5411. // Flag the item so it gets saved in its new location
  5412. item->save_needed = true;
  5413. // Add the item to its new location
  5414. player->item_list.AddItem(item);
  5415. // Remove the item from the overflow list
  5416. player->item_list.RemoveOverflowItem(item);
  5417. // Send the inventory update packet
  5418. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5419. return;
  5420. }
  5421. else if (bag_id == -3 && to_slot == -1) {
  5422. // Auto Bank
  5423. if (!player->item_list.GetFirstFreeBankSlot(&bag_id, &to_slot)) {
  5424. client->SimpleMessage(CHANNEL_STATUS, "You do not have any free bank slots.");
  5425. return;
  5426. }
  5427. item->details.inv_slot_id = bag_id;
  5428. item->details.slot_id = to_slot;
  5429. item->save_needed = true;
  5430. player->item_list.AddItem(item);
  5431. player->item_list.RemoveOverflowItem(item);
  5432. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5433. }
  5434. else if (bag_id == -4) {
  5435. // Shared Bank
  5436. if (!player->item_list.SharedBankAddAllowed(item)) {
  5437. client->SimpleMessage(CHANNEL_STATUS, "That item (or an item inside) cannot be shared.");
  5438. return;
  5439. }
  5440. Item* tmp_item = player->item_list.GetItem(-4, to_slot);
  5441. if (tmp_item) {
  5442. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  5443. return;
  5444. }
  5445. else {
  5446. item->details.inv_slot_id = bag_id;
  5447. item->details.slot_id = to_slot;
  5448. item->save_needed = true;
  5449. player->item_list.AddItem(item);
  5450. player->item_list.RemoveOverflowItem(item);
  5451. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5452. return;
  5453. }
  5454. }
  5455. else {
  5456. // Try to get an item from the given bag id and slot id
  5457. Item* tmp_item = player->item_list.GetItem(bag_id, to_slot);
  5458. // Check to see if we got an item, if we do send an error,
  5459. // if we don't put the overflow item into this slot
  5460. if (tmp_item) {
  5461. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  5462. }
  5463. else {
  5464. item->details.inv_slot_id = bag_id;
  5465. item->details.slot_id = to_slot;
  5466. item->save_needed = true;
  5467. player->item_list.AddItem(item);
  5468. player->item_list.RemoveOverflowItem(item);
  5469. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5470. return;
  5471. }
  5472. }
  5473. }
  5474. }
  5475. }
  5476. else
  5477. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /inventory {destroy|move|equip|unequip|swap_equip|pop} {item_id} [to_slot] [bag_id]");
  5478. }
  5479. /*
  5480. Function: Command_IRC()
  5481. Purpose : Handle the IRC functions
  5482. Params : IRC Commands
  5483. Dev : Scatman
  5484. Example : /irc say #Channel Hello World!
  5485. */
  5486. void Commands::Command_IRC(Client* client, Seperator* sep)
  5487. {
  5488. if (!rule_manager.GetGlobalRule(R_World, IRCEnabled)->GetBool()) {
  5489. client->SimpleMessage(CHANNEL_STATUS, "IRC is currently disabled on this server");
  5490. return;
  5491. }
  5492. if (sep && sep->arg[0][0]) {
  5493. if (strcasecmp(sep->arg[0], "say") == 0) {
  5494. if (sep->arg[1][0] && sep->arg[2][0]) {
  5495. if (sep->IsNumber(sep->arg[1]))
  5496. irc.Say(client, atoul(sep->arg[1]), sep->argplus[2]);
  5497. else
  5498. irc.Say(client, sep->arg[1], sep->argplus[2]);
  5499. }
  5500. else
  5501. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc say <channel name | channel index> <message>");
  5502. }
  5503. else if (strcasecmp(sep->arg[0], "join") == 0) {
  5504. if (sep->arg[1][0])
  5505. irc.JoinChannel(client, sep->arg[1]);
  5506. else
  5507. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc join <channel name>");
  5508. }
  5509. else if (strcasecmp(sep->arg[0], "leave") == 0) {
  5510. if (sep->arg[1][0])
  5511. irc.LeaveChannel(client, sep->arg[1]);
  5512. else
  5513. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc leave <channel name>");
  5514. }
  5515. else if (strcasecmp(sep->arg[0], "list") == 0)
  5516. irc.ListChannels(client);
  5517. else if (strcasecmp(sep->arg[0], "connect") == 0) {
  5518. if (sep->arg[1][0] && sep->arg[2][0] && sep->IsNumber(2))
  5519. irc.ConnectToServer(client, sep->arg[1], atoi(sep->arg[2]), sep->arg[3]);
  5520. else
  5521. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc connect <host> <port> (nick)");
  5522. }
  5523. else if (strcasecmp(sep->arg[0], "disconnect") == 0)
  5524. irc.DisconnectFromServer(client);
  5525. else
  5526. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown IRC command.");
  5527. }
  5528. else
  5529. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown IRC command.");
  5530. }
  5531. /*
  5532. Function: Command_Languages()
  5533. Purpose : Show's languages the player knows
  5534. Params :
  5535. Dev : Zcoretri
  5536. Example :
  5537. */
  5538. void Commands::Command_Languages(Client* client, Seperator* sep)
  5539. {
  5540. list<Language*>* languages = client->GetPlayer()->GetPlayerLanguages()->GetAllLanguages();
  5541. list<Language*>::iterator itr;
  5542. Language* language;
  5543. client->Message(CHANNEL_NARRATIVE, "You know the following languages:");
  5544. for(itr = languages->begin(); itr != languages->end(); itr++)
  5545. {
  5546. language = *itr;
  5547. client->Message(CHANNEL_NARRATIVE, "%s", language->GetName());
  5548. }
  5549. }
  5550. /*
  5551. Function: Command_SetLanguage()
  5552. Purpose : Handles language commands
  5553. Params : Language ID
  5554. Dev : Zcoretri
  5555. Example :
  5556. */
  5557. void Commands::Command_SetLanguage(Client* client, Seperator* sep)
  5558. {
  5559. Player* player = client->GetPlayer();
  5560. if (sep && sep->arg[0])
  5561. {
  5562. if(!sep->IsNumber(0))
  5563. {
  5564. //String passed in
  5565. const char* value = sep->arg[0];
  5566. if(strncasecmp(value, "Common", strlen(value)) == 0)
  5567. {
  5568. database.SaveCharacterCurrentLang(0, client->GetCharacterID(), client);
  5569. client->SendLanguagesUpdate(0);
  5570. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", value);
  5571. }
  5572. else
  5573. {
  5574. if(player->HasLanguage(value))
  5575. {
  5576. Language* language = player->GetPlayerLanguages()->GetLanguageByName(value);
  5577. database.SaveCharacterCurrentLang(language->GetID(), client->GetCharacterID(), client);
  5578. client->SendLanguagesUpdate(language->GetID());
  5579. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", language->GetName());
  5580. }
  5581. else
  5582. client->Message(CHANNEL_NARRATIVE, "You do not know how to speak %s", value);
  5583. }
  5584. }
  5585. else
  5586. {
  5587. //Number passed in
  5588. int32 id = atoul(sep->arg[0]);
  5589. if(player->HasLanguage(id))
  5590. {
  5591. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  5592. database.SaveCharacterCurrentLang(id, client->GetCharacterID(), client);
  5593. client->SendLanguagesUpdate(id);
  5594. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", language->GetName());
  5595. }
  5596. else
  5597. {
  5598. Language* language = master_languages_list.GetLanguage(id);
  5599. client->Message(CHANNEL_NARRATIVE, "You do not know how to speak %s", language->GetName());
  5600. }
  5601. }
  5602. }
  5603. else
  5604. {
  5605. //No value was passed in
  5606. int32 id = database.GetCharacterCurrentLang(client->GetCharacterID(), player);
  5607. if(id > 0)
  5608. {
  5609. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  5610. client->Message(CHANNEL_NARRATIVE, "You are currently speaking %s ", language->GetName());
  5611. }
  5612. else
  5613. client->Message(CHANNEL_NARRATIVE, "You are currently speaking Common");
  5614. }
  5615. }
  5616. /*
  5617. Function: Command_LastName()
  5618. Purpose : Sets player surname
  5619. Params : Name text
  5620. Dev : theFoof
  5621. Example :
  5622. */
  5623. void Commands::Command_LastName(Client* client, Seperator* sep)
  5624. {
  5625. if (!client)
  5626. return;
  5627. if (sep && sep->arg[0])
  5628. {
  5629. if (!client->GetPlayer()->get_character_flag(CF_ENABLE_CHANGE_LASTNAME)){
  5630. client->Message(CHANNEL_COLOR_YELLOW, "You must be atleast level %i to change your last name.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  5631. return;
  5632. }
  5633. client->RemovePendingLastName();
  5634. uchar* checkname = (uchar*)sep->arg[0];
  5635. bool valid_name = true;
  5636. for (int32 i = 0; i < strlen(sep->arg[0]); i++) {
  5637. if (!alpha_check(checkname[i])) {
  5638. valid_name = false;
  5639. break;
  5640. }
  5641. }
  5642. if (!valid_name) {
  5643. client->Message(CHANNEL_COLOR_YELLOW, "Your last name can only contain letters.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  5644. return;
  5645. }
  5646. string last_name = (string)sep->arg[0];
  5647. int8 max_length = rule_manager.GetGlobalRule(R_Player, MaxLastNameLength)->GetInt8();
  5648. int8 min_length = rule_manager.GetGlobalRule(R_Player, MinLastNameLength)->GetInt8();
  5649. if (last_name.length() <= max_length && last_name.length() >= min_length){
  5650. client->SetPendingLastName(last_name);
  5651. client->SendLastNameConfirmation();
  5652. }
  5653. else
  5654. client->Message(CHANNEL_COLOR_YELLOW, "Your last name must be between %i and %i characters long.", min_length, max_length);
  5655. }
  5656. }
  5657. /*
  5658. Function: Command_ConfirmLastName()
  5659. Purpose : Confirms setting of player surname
  5660. Params : Name text
  5661. Dev : theFoof
  5662. Example :
  5663. */
  5664. void Commands::Command_ConfirmLastName(Client* client, Seperator* sep)
  5665. {
  5666. if (!client)
  5667. return;
  5668. string* name = client->GetPendingLastName();
  5669. if (name){
  5670. Player* player = client->GetPlayer();
  5671. player->SetLastName(name->c_str(), false);
  5672. client->SendTitleUpdate();
  5673. player->SetCharSheetChanged(true);
  5674. client->RemovePendingLastName();
  5675. }
  5676. }
  5677. /*
  5678. Function: Command_Location()
  5679. Purpose : Display's Help for /location commands
  5680. Params :
  5681. Dev : Scatman
  5682. Example : /location = show's help for command
  5683. */
  5684. void Commands::Command_Location(Client* client)
  5685. {
  5686. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Valid /location commands are:");
  5687. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location create [name] (include y). Include y defaults to false");
  5688. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location add [location id]");
  5689. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location remove [location point id]");
  5690. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location delete [location id]");
  5691. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location list [locations|points] [location id if points used]");
  5692. }
  5693. /*
  5694. Function: Command_LocationAdd()
  5695. Purpose : Add's a location to an existing location config
  5696. Params : location_id
  5697. Dev : Scatman
  5698. Example : /location add {location_id}
  5699. */
  5700. void Commands::Command_LocationAdd(Client* client, Seperator* sep)
  5701. {
  5702. if (sep && sep->arg[0] && sep->IsNumber(0))
  5703. {
  5704. int32 location_id = atoul(sep->arg[0]);
  5705. float x = client->GetPlayer()->GetX();
  5706. float y = client->GetPlayer()->GetY();
  5707. float z = client->GetPlayer()->GetZ();
  5708. if (database.AddLocationPoint(location_id, x, y, z))
  5709. client->Message(CHANNEL_COLOR_YELLOW, "Point (%f, %f, %f) was successfully added to location %u", x, y, z, location_id);
  5710. else
  5711. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist. Use /location create to create one", location_id);
  5712. }
  5713. else
  5714. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location add [location id]");
  5715. }
  5716. /*
  5717. Function: Command_LocationCreate()
  5718. Purpose : Creates a new location config
  5719. Params : location name, 0/1 for include_y (optional)
  5720. Dev : Scatman
  5721. Example : /location create Test 1 = creates a new location named Test with include_y True
  5722. */
  5723. void Commands::Command_LocationCreate(Client* client, Seperator* sep)
  5724. {
  5725. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  5726. {
  5727. const char* name = sep->arg[0];
  5728. bool include_y = false;
  5729. if (sep->arg[1] && sep->IsNumber(1) && atoi(sep->arg[1]) > 0)
  5730. include_y = true;
  5731. int32 location_id = database.CreateLocation(client->GetPlayer()->GetZone()->GetZoneID(), client->GetPlayer()->appearance.pos.grid_id, name, include_y);
  5732. if (location_id > 0)
  5733. client->Message(CHANNEL_COLOR_YELLOW, "Location '%s' was successfully created with location id %u", name, location_id);
  5734. else
  5735. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the requested location");
  5736. }
  5737. else
  5738. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location create [name] (include_y). Include y defaults to false");
  5739. }
  5740. /*
  5741. Function: Command_LocationDelete()
  5742. Purpose : Delete's a location config and all it's location points
  5743. Params : location_id
  5744. Dev : Scatman
  5745. Example : /location delete {location_id}
  5746. */
  5747. void Commands::Command_LocationDelete(Client* client, Seperator* sep)
  5748. {
  5749. if (sep && sep->arg[0] && sep->IsNumber(0))
  5750. {
  5751. int32 location_id = atoul(sep->arg[0]);
  5752. if (database.DeleteLocation(location_id))
  5753. client->Message(CHANNEL_COLOR_YELLOW, "Location id %u and all its points were successfully deleted", location_id);
  5754. else
  5755. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist", location_id);
  5756. }
  5757. else
  5758. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location delete [location id]");
  5759. }
  5760. /*
  5761. Function: Command_LocationList()
  5762. Purpose : Display's a list of location points
  5763. Params : location_id
  5764. Dev : Scatman
  5765. Example : /location list {location_id}
  5766. */
  5767. void Commands::Command_LocationList(Client* client, Seperator* sep)
  5768. {
  5769. if (sep && sep->arg[0])
  5770. {
  5771. const char* option = sep->arg[0];
  5772. if (strncmp(option, "locations", strlen(option)) == 0)
  5773. database.ListLocations(client);
  5774. else if (strncmp(option, "points", strlen(option)) == 0 && sep->arg[1] && sep->IsNumber(1))
  5775. {
  5776. int32 location_id = atoul(sep->arg[1]);
  5777. database.ListLocationPoints(client, location_id);
  5778. }
  5779. else
  5780. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  5781. }
  5782. else
  5783. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  5784. }
  5785. /*
  5786. Function: Command_LocationRemove()
  5787. Purpose : Removes a single location point from a location config
  5788. Params : location_point_id (gotten from /location list {id})
  5789. Dev : Scatman
  5790. Example : /location remove 1 = will remove location_point_id 1
  5791. */
  5792. void Commands::Command_LocationRemove(Client* client, Seperator* sep)
  5793. {
  5794. if (sep && sep->arg[0] && sep->IsNumber(0))
  5795. {
  5796. int32 location_point_id = atoul(sep->arg[0]);
  5797. if (database.DeleteLocationPoint(location_point_id))
  5798. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Location point was successfully deleted");
  5799. else
  5800. client->Message(CHANNEL_COLOR_YELLOW, "Location point with ID %u does not exist", location_point_id);
  5801. }
  5802. else
  5803. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location remove [location point id]");
  5804. }
  5805. /*
  5806. Function: Command_Merchant()
  5807. Purpose : Handles Merchant commands
  5808. Params : list
  5809. Dev : Scatman
  5810. Example : /merchant list
  5811. */
  5812. void Commands::Command_Merchant(Client* client, Seperator* sep, int handler)
  5813. {
  5814. if( handler == COMMAND_MERCHANT )
  5815. {
  5816. // /merchant command by itself shows help (to be extended)
  5817. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  5818. return;
  5819. }
  5820. else if( handler == COMMAND_MERCHANT_LIST )
  5821. {
  5822. // /merchant list command expects "description" param
  5823. if (sep && sep->arg[0])
  5824. {
  5825. const char* merchant_description = sep->argplus[0];
  5826. client->Message(CHANNEL_COLOR_YELLOW, "Listing merchants like '%s':", merchant_description);
  5827. map<int32, MerchantInfo*>* merchant_info = world.GetMerchantInfo();
  5828. map<int32, MerchantInfo*>::iterator itr;
  5829. for (itr = merchant_info->begin(); itr != merchant_info->end(); itr++)
  5830. {
  5831. string description = database.GetMerchantDescription(itr->first);
  5832. if (ToLower(description).find(ToLower(string(merchant_description))) < 0xFFFFFFFF)
  5833. client->Message(CHANNEL_COLOR_YELLOW, "Merchant ID: %u, Description: %s", itr->first, description.c_str());
  5834. }
  5835. }
  5836. else // no description
  5837. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  5838. }
  5839. }
  5840. /*
  5841. Function: Command_Modify()
  5842. Purpose : to replace our other "set" commands
  5843. Params : System = the system to modify, Action = the action to perform, Target = what to change (target, or index)
  5844. Dev : John Adams
  5845. Example : /modify spell set name "Aegolism III"
  5846. */
  5847. void Commands::Command_Modify(Client* client)
  5848. {
  5849. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /modify [system] [action] [field] [value] {target|id}");
  5850. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Systems: character, faction, guild, item, skill, spawn, spell, zone");
  5851. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Actions: set, create, delete, add, remove");
  5852. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Value : field name in the table being modified");
  5853. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target : modify current target, or specified {system} ID");
  5854. }
  5855. /*
  5856. Function: Command_ModifySpawn()
  5857. Purpose : replace "spawn set" commands
  5858. Params : Action : the action to perform (or special handler)
  5859. : Field : the DB field to change
  5860. : Value : what to set the value to
  5861. : Target : what object to change (my target, or spawn_id)
  5862. Dev : John Adams
  5863. Example : /modify spawn set name "Lady Vox"
  5864. :
  5865. Note : Special Handlers, like "zoneto" for Signs
  5866. : /modify spawn zoneto
  5867. : Will set a sign's zone x/y/z to my current coords
  5868. */
  5869. void Commands::Command_ModifySpawn(Client* client, Seperator* sep)
  5870. {
  5871. PrintSep(sep, "COMMAND_MODIFY");
  5872. // need at least 2 args for a valid command
  5873. if( sep && sep->arg[1] )
  5874. {
  5875. // JA: just a quick implementation because I need it :)
  5876. if (strcmp(sep->arg[0], "zoneto") == 0)
  5877. {
  5878. if( sep->IsNumber(1) )
  5879. {
  5880. int32 spawn_id = atoul(sep->arg[1]);
  5881. float x_coord = client->GetPlayer()->GetX();
  5882. float y_coord = client->GetPlayer()->GetY();
  5883. float z_coord = client->GetPlayer()->GetZ();
  5884. float h_coord = client->GetPlayer()->GetHeading();
  5885. database.SaveSignZoneToCoords(spawn_id, x_coord, y_coord, z_coord, h_coord);
  5886. }
  5887. else
  5888. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify spawn zoneto spawn_id - sets spawn_id to your coords");
  5889. }
  5890. }
  5891. else
  5892. Command_Modify(client);
  5893. }
  5894. /*
  5895. Function: Command_ModifyCharacter()
  5896. Purpose : to replace our other "set" commands
  5897. Params : Action : Add, Remove
  5898. : Field : copper, silver, gold, plat
  5899. : Value : min 1, max unlimited
  5900. : Target : Self, Player
  5901. Dev : Cynnar
  5902. Example : /modify character add gold 50
  5903. : /modify character remove silver 25
  5904. */
  5905. void Commands::Command_ModifyCharacter(Client* client, Seperator* sep)
  5906. {
  5907. PrintSep(sep, "COMMAND_MODIFY");
  5908. int64 value = 0;
  5909. Player* player = client->GetPlayer();
  5910. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  5911. player = (Player*)player->GetTarget();
  5912. // need at least 2 args for a valid command
  5913. if( sep && sep->arg[1] )
  5914. {
  5915. if (strcmp(sep->arg[0], "add") == 0)
  5916. {
  5917. if (strcmp(sep->arg[1], "copper") == 0)
  5918. {
  5919. value = atoi64(sep->arg[2]);
  5920. player->AddCoins(value);
  5921. if (client->GetPlayer() == player)
  5922. {
  5923. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu copper coin%s", value, (value > 1 ? "s" : ""));
  5924. }
  5925. else {
  5926. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu copper coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  5927. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu copper coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  5928. }
  5929. }
  5930. else if (strcmp(sep->arg[1], "silver") == 0)
  5931. {
  5932. value = atoi64(sep->arg[2]) * 100;
  5933. player->AddCoins(value);
  5934. if (client->GetPlayer() == player)
  5935. {
  5936. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu silver coin%s", value / 100, (value > 1 ? "s" : ""));
  5937. }
  5938. else {
  5939. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu silver coin%s", player->GetName(), value / 100, (value > 1 ? "s" : ""));
  5940. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu silver coin%s", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  5941. }
  5942. }
  5943. else if (strcmp(sep->arg[1], "gold") == 0)
  5944. {
  5945. value = atoi64(sep->arg[2]) * 10000;
  5946. player->AddCoins(value);
  5947. if (client->GetPlayer() == player)
  5948. {
  5949. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu gold coin%s", value / 10000, (value > 1 ? "s" : ""));
  5950. }
  5951. else {
  5952. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu gold coin%s", player->GetName(), value / 10000, (value > 1 ? "s" : ""));
  5953. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu gold coin%s", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  5954. }
  5955. }
  5956. else if (strcmp(sep->arg[1], "plat") == 0)
  5957. {
  5958. value = atoi64(sep->arg[2]) * 1000000;
  5959. player->AddCoins(value);
  5960. if (client->GetPlayer() == player)
  5961. {
  5962. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu platinum coin%s", value / 1000000, (value > 1 ? "s" : ""));
  5963. }
  5964. else {
  5965. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu platinum coin%s", player->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  5966. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu platinum coin%s", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  5967. }
  5968. }
  5969. else
  5970. {
  5971. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  5972. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  5973. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  5974. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character add copper 20");
  5975. }
  5976. }
  5977. else if (strcmp(sep->arg[0], "remove") == 0)
  5978. {
  5979. if (strcmp(sep->arg[1], "copper") == 0)
  5980. {
  5981. value = atoi64(sep->arg[2]);
  5982. player->RemoveCoins(value);
  5983. if (client->GetPlayer() == player)
  5984. {
  5985. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from yourself", value, (value > 1 ? "s" : ""));
  5986. }
  5987. else {
  5988. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from %s", value, (value > 1 ? "s" : ""), player->GetName());
  5989. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu copper coin%s from you", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  5990. }
  5991. }
  5992. else if (strcmp(sep->arg[1], "silver") == 0)
  5993. {
  5994. value = atoi64(sep->arg[2]) * 100;
  5995. player->RemoveCoins(value);
  5996. if (client->GetPlayer() == player)
  5997. {
  5998. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from yourself", value / 100, (value > 1 ? "s" : ""));
  5999. }
  6000. else {
  6001. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from %s", value / 100, (value > 1 ? "s" : ""), player->GetName());
  6002. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu silver coin%s from you", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  6003. }
  6004. }
  6005. else if (strcmp(sep->arg[1], "gold") == 0)
  6006. {
  6007. value = atoi64(sep->arg[2]) * 10000;
  6008. player->RemoveCoins(value);
  6009. if (client->GetPlayer() == player)
  6010. {
  6011. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from yourself", value / 10000, (value > 1 ? "s" : ""));
  6012. }
  6013. else {
  6014. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from %s", value / 10000, (value > 1 ? "s" : ""), player->GetName());
  6015. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu gold coin%s from you", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  6016. }
  6017. }
  6018. else if (strcmp(sep->arg[1], "plat") == 0)
  6019. {
  6020. value = atoi64(sep->arg[2]) * 1000000;
  6021. player->RemoveCoins(value);
  6022. if (client->GetPlayer() == player)
  6023. {
  6024. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from yourself", value / 1000000, (value > 1 ? "s" : ""));
  6025. }
  6026. else {
  6027. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from %s", value / 1000000, (value > 1 ? "s" : ""), player->GetName());
  6028. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu platinum coin%s from you", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  6029. }
  6030. }
  6031. else
  6032. {
  6033. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  6034. }
  6035. }
  6036. else if (strcmp(sep->arg[0], "set") == 0) {
  6037. if (strcmp(sep->arg[1], "tslevel") == 0) {
  6038. int8 level = atoi(sep->arg[2]);
  6039. if (level > 0 && level < 256) {
  6040. if (player) {
  6041. if (client->GetPlayer() == player)
  6042. client->ChangeTSLevel(player->GetTSLevel(), level);
  6043. else
  6044. player->GetZone()->GetClientBySpawn(player)->ChangeTSLevel(player->GetTSLevel(), level);
  6045. }
  6046. }
  6047. else
  6048. client->SimpleMessage(CHANNEL_ERROR, "Level must be between 1 - 255");
  6049. }
  6050. else if (strcmp(sep->arg[1], "tsclass") == 0) {
  6051. int8 tsclass = atoi(sep->arg[2]);
  6052. player->SetTradeskillClass(tsclass);
  6053. player->GetInfoStruct()->tradeskill_class1 = classes.GetTSBaseClass(player->GetTradeskillClass());
  6054. player->GetInfoStruct()->tradeskill_class2 = classes.GetSecondaryTSBaseClass(player->GetTradeskillClass());
  6055. player->GetInfoStruct()->tradeskill_class3 = player->GetTradeskillClass();
  6056. player->SetCharSheetChanged(true);
  6057. }
  6058. }
  6059. }
  6060. else
  6061. {
  6062. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  6063. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  6064. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  6065. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  6066. }
  6067. }
  6068. void Commands::Command_ModifyFaction(Client* client, Seperator* sep)
  6069. {
  6070. PrintSep(sep, "COMMAND_MODIFY");
  6071. // need at least 2 args for a valid command
  6072. if( sep && sep->arg[1] )
  6073. {
  6074. }
  6075. else
  6076. Command_Modify(client);
  6077. }
  6078. void Commands::Command_ModifyGuild(Client* client, Seperator* sep)
  6079. {
  6080. PrintSep(sep, "COMMAND_MODIFY");
  6081. // need at least 2 args for a valid command
  6082. if( sep && sep->arg[1] )
  6083. {
  6084. }
  6085. else
  6086. Command_Modify(client);
  6087. }
  6088. void Commands::Command_ModifyItem(Client* client, Seperator* sep)
  6089. {
  6090. PrintSep(sep, "COMMAND_MODIFY");
  6091. // need at least 2 args for a valid command
  6092. if( sep && sep->arg[1] )
  6093. {
  6094. }
  6095. else
  6096. Command_Modify(client);
  6097. }
  6098. /*
  6099. Function: Command_ModifyQuest()
  6100. Purpose : to list players quest and completed quests
  6101. Params : Action : list, completed
  6102. : Target : Self, Player
  6103. Dev : Cynnar
  6104. Example : /modify quest list
  6105. : /modify quest completed
  6106. */
  6107. void Commands::Command_ModifyQuest(Client* client, Seperator* sep)
  6108. {
  6109. PrintSep(sep, "COMMAND_MODIFY");
  6110. int64 value = 0;
  6111. Player* player = client->GetPlayer();
  6112. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  6113. player = (Player*)player->GetTarget();
  6114. // need at least 2 args for a valid command
  6115. if (sep && sep->arg[1])
  6116. {
  6117. if (strcmp(sep->arg[0], "list") == 0)
  6118. {
  6119. map<int32, Quest*>* quests = player->GetPlayerQuests();
  6120. map<int32, Quest*>::iterator itr;
  6121. client->Message(CHANNEL_COLOR_YELLOW, "%s's Quest List:.", client->GetPlayer()->GetName());
  6122. if (quests->size() == 0)
  6123. client->Message(CHANNEL_COLOR_YELLOW, "%s has no quests.", client->GetPlayer()->GetName());
  6124. else
  6125. {
  6126. for (itr = quests->begin(); itr != quests->end(); itr++)
  6127. {
  6128. Quest* quest = itr->second;
  6129. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  6130. }
  6131. }
  6132. }
  6133. else if (strcmp(sep->arg[0], "completed") == 0)
  6134. {
  6135. map<int32, Quest*>* quests = player->GetCompletedPlayerQuests();
  6136. map<int32, Quest*>::iterator itr;
  6137. client->Message(CHANNEL_COLOR_YELLOW, "%s's Completed Quest List:.", client->GetPlayer()->GetName());
  6138. if (quests->size() == 0)
  6139. client->Message(CHANNEL_COLOR_YELLOW, "%s has no completed quests.", client->GetPlayer()->GetName());
  6140. else
  6141. {
  6142. for (itr = quests->begin(); itr != quests->end(); itr++)
  6143. {
  6144. Quest* quest = itr->second;
  6145. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  6146. }
  6147. }
  6148. }
  6149. // Add in a progress step, and a LogWrite() for tracking GM Commands.
  6150. // LogWrite(LUA__DEBUG, 0, "LUA", "Quest: %s, function: %s", quest->GetName(), function);
  6151. else if (strcmp(sep->arg[0], "remove") == 0)
  6152. {
  6153. int32 quest_id = 0;
  6154. if (sep && sep->arg[1] && sep->IsNumber(1))
  6155. quest_id = atoul(sep->arg[1]);
  6156. if (quest_id > 0)
  6157. {
  6158. if (lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0)
  6159. {
  6160. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  6161. if (quest)
  6162. if (client->GetPlayer() == player)
  6163. {
  6164. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been removed from your journal", quest->GetName());
  6165. }
  6166. else
  6167. {
  6168. client->Message(CHANNEL_COLOR_YELLOW, "You have removed the quest %s from %s's journal", quest->GetName(), player->GetName());
  6169. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s has removed the quest %s from your journal", client->GetPlayer()->GetName(), quest->GetName());
  6170. }
  6171. LogWrite(COMMAND__INFO, 0, "GM Command", "%s removed the quest %s from %s", client->GetPlayer()->GetName(), quest->GetName(), player->GetName());
  6172. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  6173. }
  6174. client->RemovePlayerQuest(quest_id);
  6175. client->GetCurrentZone()->SendQuestUpdates(client);
  6176. }
  6177. }
  6178. else if (strcmp(sep->arg[0], "advance") == 0)
  6179. {
  6180. int32 quest_id = 0;
  6181. int32 step = 0;
  6182. if (sep && sep->arg[1] && sep->IsNumber(1))
  6183. {
  6184. quest_id = atoul(sep->arg[1]);
  6185. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  6186. if (sep && sep->arg[2] && sep->IsNumber(1))
  6187. {
  6188. step = atoul(sep->arg[2]);
  6189. if (quest_id > 0 && step > 0)
  6190. {
  6191. if (player && player->IsPlayer() && quest_id > 0 && step > 0 && (player->player_quests.count(quest_id) > 0))
  6192. {
  6193. if (client)
  6194. {
  6195. client->AddPendingQuestUpdate(quest_id, step);
  6196. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been advanced one step.", quest->GetName());
  6197. LogWrite(COMMAND__INFO, 0, "GM Command", "%s advanced the quest %s one step", client->GetPlayer()->GetName(), quest->GetName());
  6198. }
  6199. }
  6200. }
  6201. else
  6202. {
  6203. client->Message(CHANNEL_COLOR_RED, "Quest ID and Step Number must be greater than 0!");
  6204. }
  6205. }
  6206. else
  6207. {
  6208. client->Message(CHANNEL_COLOR_RED, "Step Number must be a number!");
  6209. }
  6210. }
  6211. else
  6212. {
  6213. client->Message(CHANNEL_COLOR_RED, "Quest ID must be a number!");
  6214. }
  6215. }
  6216. else
  6217. {
  6218. Command_Modify(client);
  6219. }
  6220. }
  6221. else
  6222. {
  6223. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify quest [action] [quest id] [step number]");
  6224. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: list, completed, remove, advance");
  6225. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest list");
  6226. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest remove 156");
  6227. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest advance 50 1");
  6228. }
  6229. }
  6230. void Commands::Command_ModifySkill(Client* client, Seperator* sep)
  6231. {
  6232. PrintSep(sep, "COMMAND_MODIFY");
  6233. // need at least 2 args for a valid command
  6234. if( sep && sep->arg[1] )
  6235. {
  6236. if (strcmp(sep->arg[0], "add") == 0) {
  6237. const char* skill_name = sep->argplus[1];
  6238. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6239. if (skill) {
  6240. Player* player = 0;
  6241. Client* to_client = 0;
  6242. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  6243. player = (Player*)client->GetPlayer()->GetTarget();
  6244. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  6245. }
  6246. else {
  6247. player = client->GetPlayer();
  6248. to_client = client;
  6249. }
  6250. if (player)
  6251. {
  6252. if (!player->GetSkills()->HasSkill(skill->skill_id))
  6253. {
  6254. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  6255. if (to_client == client) {
  6256. client->Message(CHANNEL_STATUS, "Added skill '%s'.", skill_name);
  6257. }
  6258. else {
  6259. client->Message(CHANNEL_STATUS, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  6260. to_client->Message(CHANNEL_STATUS, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  6261. }
  6262. }
  6263. else
  6264. client->Message(CHANNEL_STATUS, "%s already has the skill '%s'.", to_client == client ? "You" : player->GetName(), skill_name);
  6265. }
  6266. }
  6267. else
  6268. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  6269. }
  6270. else if (strcmp(sep->arg[0], "remove") == 0) {
  6271. const char* skill_name = sep->argplus[1];
  6272. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6273. if (skill) {
  6274. Player* player = 0;
  6275. Client* to_client = 0;
  6276. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  6277. player = (Player*)client->GetPlayer()->GetTarget();
  6278. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  6279. }
  6280. else {
  6281. player = client->GetPlayer();
  6282. to_client = client;
  6283. }
  6284. if (player)
  6285. {
  6286. if (player->GetSkills()->HasSkill(skill->skill_id))
  6287. {
  6288. player->RemoveSkillFromDB(skill, true);
  6289. if (client == to_client) {
  6290. client->Message(CHANNEL_STATUS, "Removed skill '%s'.", skill_name);
  6291. }
  6292. else {
  6293. client->Message(CHANNEL_STATUS, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  6294. to_client->Message(CHANNEL_STATUS, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  6295. }
  6296. }
  6297. else {
  6298. if (client == to_client)
  6299. client->Message(CHANNEL_STATUS, "You do not have the skill '%s'.", skill_name);
  6300. else
  6301. client->Message(CHANNEL_STATUS, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  6302. }
  6303. }
  6304. }
  6305. else
  6306. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  6307. }
  6308. else if (strcmp(sep->arg[0], "set") == 0) {
  6309. if (!sep->IsNumber(2)) {
  6310. client->Message(CHANNEL_STATUS, "The last parameter must be a number.");
  6311. return;
  6312. }
  6313. const char* skill_name = sep->arg[1];
  6314. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6315. if (skill) {
  6316. int16 val = atoi(sep->arg[2]);
  6317. Player* player = 0;
  6318. Client* to_client = 0;
  6319. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  6320. player = (Player*)client->GetPlayer()->GetTarget();
  6321. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  6322. }
  6323. else {
  6324. player = client->GetPlayer();
  6325. to_client = client;
  6326. }
  6327. if (player)
  6328. {
  6329. if (player->GetSkills()->HasSkill(skill->skill_id)) {
  6330. player->GetSkills()->SetSkill(skill->skill_id, val);
  6331. if (client != to_client)
  6332. client->Message(CHANNEL_STATUS, "You set %s's '%s' skill to %i.", player->GetName(), skill_name, val);
  6333. to_client->Message(CHANNEL_STATUS, "Your '%s' skill has been set to %i.", skill_name, val);
  6334. }
  6335. else {
  6336. client->Message(CHANNEL_STATUS, "Target does not have the skill '%s'.", skill_name);
  6337. }
  6338. }
  6339. }
  6340. else {
  6341. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  6342. }
  6343. }
  6344. else {
  6345. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  6346. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  6347. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  6348. }
  6349. }
  6350. else {
  6351. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  6352. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  6353. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  6354. }
  6355. }
  6356. void Commands::Command_ModifySpell(Client* client, Seperator* sep)
  6357. {
  6358. PrintSep(sep, "COMMAND_MODIFY");
  6359. // need at least 2 args for a valid command
  6360. if( sep && sep->arg[1] )
  6361. {
  6362. }
  6363. else
  6364. Command_Modify(client);
  6365. }
  6366. void Commands::Command_ModifyZone(Client* client, Seperator* sep)
  6367. {
  6368. PrintSep(sep, "COMMAND_MODIFY");
  6369. // need at least 2 args for a valid command
  6370. if( sep && sep->arg[1] )
  6371. {
  6372. }
  6373. else
  6374. Command_Modify(client);
  6375. }
  6376. /*
  6377. Function: Command_MOTD()
  6378. Purpose : Displays server MOTD
  6379. Params :
  6380. Dev : LethalEncounter
  6381. Example : /motd
  6382. */
  6383. void Commands::Command_MOTD(Client* client)
  6384. {
  6385. if (client)
  6386. ClientPacketFunctions::SendMOTD(client);
  6387. }
  6388. /*
  6389. Function: Command_Pet()
  6390. Purpose : Handle Pet {Command} commands
  6391. Params : attack, backoff, preserve_master, preserve_self, follow, stay, getlost
  6392. Dev :
  6393. Example : /pet preserve_master
  6394. */
  6395. void Commands::Command_Pet(Client* client, Seperator* sep)
  6396. {
  6397. PrintSep(sep, "COMMAND_PET");
  6398. //LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Pet Commands");
  6399. //client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6400. if (!sep || !sep->arg[0])
  6401. return; // should have sep->arg[0] filled
  6402. if (strcmp(sep->arg[0], "hide") == 0) {
  6403. // doing /pet hide will toggle the hide status on all the pets that can be hidden
  6404. Entity* pet = client->GetPlayer()->GetDeityPet();
  6405. if (pet) {
  6406. if (pet->IsPrivateSpawn())
  6407. client->GetPlayer()->HideDeityPet(false);
  6408. else
  6409. client->GetPlayer()->HideDeityPet(true);
  6410. }
  6411. pet = client->GetPlayer()->GetCosmeticPet();
  6412. if (pet) {
  6413. if (pet->IsPrivateSpawn())
  6414. client->GetPlayer()->HideCosmeticPet(false);
  6415. else
  6416. client->GetPlayer()->HideCosmeticPet(true);
  6417. }
  6418. return;
  6419. }
  6420. // below is for all combat pets
  6421. if (!client->GetPlayer()->HasPet()) {
  6422. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a pet.");
  6423. return;
  6424. }
  6425. if (strcmp(sep->arg[0], "stay") == 0) {
  6426. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to stay.");
  6427. client->GetPlayer()->GetInfoStruct()->pet_movement = 1;
  6428. client->GetPlayer()->SetCharSheetChanged(true);
  6429. if (client->GetPlayer()->GetPet())
  6430. client->GetPlayer()->GetPet()->following = false;
  6431. if (client->GetPlayer()->GetCharmedPet())
  6432. client->GetPlayer()->GetCharmedPet()->following = false;
  6433. }
  6434. else if (strcmp(sep->arg[0], "follow") == 0) {
  6435. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to follow.");
  6436. client->GetPlayer()->GetInfoStruct()->pet_movement = 2;
  6437. client->GetPlayer()->SetCharSheetChanged(true);
  6438. }
  6439. else if (strcmp(sep->arg[0], "preserve_master") == 0) {
  6440. if (client->GetPlayer()->GetInfoStruct()->pet_behavior & 1) {
  6441. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect you.");
  6442. client->GetPlayer()->GetInfoStruct()->pet_behavior -= 1;
  6443. }
  6444. else {
  6445. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect you.");
  6446. client->GetPlayer()->GetInfoStruct()->pet_behavior += 1;
  6447. }
  6448. client->GetPlayer()->SetCharSheetChanged(true);
  6449. }
  6450. else if (strcmp(sep->arg[0], "preserve_self") == 0) {
  6451. if (client->GetPlayer()->GetInfoStruct()->pet_behavior & 2) {
  6452. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect itself.");
  6453. client->GetPlayer()->GetInfoStruct()->pet_behavior -= 2;
  6454. }
  6455. else {
  6456. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect itself.");
  6457. client->GetPlayer()->GetInfoStruct()->pet_behavior += 2;
  6458. }
  6459. client->GetPlayer()->SetCharSheetChanged(true);
  6460. }
  6461. else if (strcmp(sep->arg[0], "backoff") == 0) {
  6462. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to back down.");
  6463. if (client->GetPlayer()->GetPet())
  6464. ((NPC*)client->GetPlayer()->GetPet())->Brain()->ClearHate();
  6465. if (client->GetPlayer()->GetCharmedPet())
  6466. ((NPC*)client->GetPlayer()->GetCharmedPet())->Brain()->ClearHate();
  6467. client->GetPlayer()->GetInfoStruct()->pet_behavior = 0;
  6468. client->GetPlayer()->SetCharSheetChanged(true);
  6469. }
  6470. else if (strcmp(sep->arg[0], "attack") == 0) {
  6471. if (client->GetPlayer()->HasTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  6472. if (client->GetPlayer()->AttackAllowed((Entity*)client->GetPlayer()->GetTarget())){
  6473. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to attack your target.");
  6474. if (client->GetPlayer()->GetPet())
  6475. client->GetPlayer()->GetPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  6476. if (client->GetPlayer()->GetCharmedPet())
  6477. client->GetPlayer()->GetCharmedPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  6478. }
  6479. else
  6480. client->Message(CHANNEL_COLOR_YELLOW, "You can not attack that.");
  6481. }
  6482. else
  6483. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a target.");
  6484. }
  6485. else if (strcmp(sep->arg[0], "getlost") == 0) {
  6486. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetPet());
  6487. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetCharmedPet());
  6488. client->Message(CHANNEL_COLOR_YELLOW, "You tell your pet to get lost.");
  6489. }
  6490. else
  6491. client->Message(CHANNEL_COLOR_YELLOW, "Unknown pet command.");
  6492. }
  6493. /*
  6494. Function: Command_PetName()
  6495. Purpose : Pet your name (???)
  6496. Params :
  6497. Dev :
  6498. Example :
  6499. */
  6500. void Commands::Command_PetName(Client* client, Seperator* sep)
  6501. {
  6502. PrintSep(sep, "COMMAND_PETNAME");
  6503. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Pet Name Command");
  6504. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6505. }
  6506. /*
  6507. Function: Command_NamePet()
  6508. Purpose : Name your pet
  6509. Params :
  6510. Dev :
  6511. Example :
  6512. */
  6513. void Commands::Command_NamePet(Client* client, Seperator* sep)
  6514. {
  6515. PrintSep(sep, "COMMAND_NAME_PET");
  6516. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Name Pet Command");
  6517. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6518. }
  6519. /*
  6520. Function: Command_Rename()
  6521. Purpose : Renames existing pet
  6522. Params :
  6523. Dev :
  6524. Example :
  6525. */
  6526. void Commands::Command_Rename(Client* client, Seperator* sep)
  6527. {
  6528. PrintSep(sep, "COMMAND_RENAME");
  6529. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Rename Pet Command");
  6530. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6531. }
  6532. /*
  6533. Function: Command_ConfirmRename()
  6534. Purpose : Confirms renaming your pet
  6535. Params :
  6536. Dev :
  6537. Example :
  6538. */
  6539. void Commands::Command_ConfirmRename(Client* client, Seperator* sep)
  6540. {
  6541. PrintSep(sep, "COMMAND_CONFIRMRENAME");
  6542. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Confirm Rename Pet Command");
  6543. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6544. }
  6545. /*
  6546. Function: Command_PetOptions()
  6547. Purpose : Sets various pet options
  6548. Params :
  6549. Dev :
  6550. Example :
  6551. */
  6552. void Commands::Command_PetOptions(Client* client, Seperator* sep)
  6553. {
  6554. PrintSep(sep, "COMMAND_PETOPTIONS");
  6555. Player* player = client->GetPlayer();
  6556. Spawn* target = player->GetTarget();
  6557. if (!target)
  6558. return;
  6559. if (target == player->GetPet())
  6560. client->SendPetOptionsWindow(player->GetPet()->GetName());
  6561. else if (target == player->GetCharmedPet())
  6562. client->SendPetOptionsWindow(player->GetCharmedPet()->GetName());
  6563. else if (target == player->GetCosmeticPet())
  6564. client->SendPetOptionsWindow(player->GetCosmeticPet()->GetName(), 0);
  6565. else if (target == player->GetDeityPet())
  6566. client->SendPetOptionsWindow(player->GetDeityPet()->GetName(), 0);
  6567. }
  6568. /*
  6569. Function: Command_Random()
  6570. Purpose : Handles /random dice roll in-game
  6571. Params : 1-100
  6572. Dev : Scatman
  6573. Example : /randon 1 100
  6574. */
  6575. void Commands::Command_Random(Client* client, Seperator* sep)
  6576. {
  6577. char message[256] = {0};
  6578. if (sep)
  6579. {
  6580. if (sep->GetArgNumber() == 0 && sep->IsNumber(0))
  6581. 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])));
  6582. else if (sep->GetArgNumber() > 0 && sep->IsNumber(0) && sep->IsNumber(1))
  6583. 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])));
  6584. else
  6585. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  6586. }
  6587. else
  6588. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  6589. client->GetPlayer()->GetZone()->HandleChatMessage(0, 0, CHANNEL_EMOTE, message);
  6590. }
  6591. /*
  6592. Function: Command_Randomize()
  6593. Purpose : Sets randomize (appearance) values for NPCs
  6594. Params : Attrib Name
  6595. Dev : Scatman
  6596. Example : /randomize gender 1 -- will randomize the NPCs gender (male/female)
  6597. */
  6598. void Commands::Command_Randomize(Client* client, Seperator* sep)
  6599. {
  6600. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  6601. if (target)
  6602. {
  6603. if (target->IsNPC())
  6604. {
  6605. if (sep && sep->arg[0] && !sep->IsNumber(0))
  6606. {
  6607. const char* value = sep->arg[0];
  6608. if (strncasecmp(value, "show", strlen(value)) == 0)
  6609. {
  6610. client->DisplayRandomizeFeatures(target->GetRandomize());
  6611. }
  6612. else
  6613. {
  6614. if (sep->arg[1] && sep->IsNumber(1))
  6615. {
  6616. int8 option = atoi(sep->arg[1]);
  6617. if (option == 0 || option == 1)
  6618. {
  6619. int32 feature = 0;
  6620. char feature_text[32] = {0};
  6621. if (strncasecmp(value, "gender", strlen(value)) == 0) {
  6622. feature = RANDOMIZE_GENDER;
  6623. strncpy(feature_text, "gender", sizeof(feature_text) - 1);
  6624. }
  6625. else if (strncasecmp(value, "race", strlen(value)) == 0) {
  6626. feature = RANDOMIZE_RACE;
  6627. strncpy(feature_text, "race", sizeof(feature_text) - 1);
  6628. }
  6629. else if (strncasecmp(value, "model", strlen(value)) == 0) {
  6630. feature = RANDOMIZE_MODEL_TYPE;
  6631. strncpy(feature_text, "model", sizeof(feature_text) - 1);
  6632. }
  6633. else if (strncasecmp(value, "facial_hair", strlen(value)) == 0) {
  6634. feature = RANDOMIZE_FACIAL_HAIR_TYPE;
  6635. strncpy(feature_text, "facial hair", sizeof(feature_text) - 1);
  6636. }
  6637. else if (strncasecmp(value, "hair", strlen(value)) == 0) {
  6638. feature = RANDOMIZE_HAIR_TYPE;
  6639. strncpy(feature_text, "hair", sizeof(feature_text) - 1);
  6640. }
  6641. else if (strncasecmp(value, "wing", strlen(value)) == 0) {
  6642. feature = RANDOMIZE_WING_TYPE;
  6643. strncpy(feature_text, "wings", sizeof(feature_text) - 1);
  6644. }
  6645. else if (strncasecmp(value, "cheek", strlen(value)) == 0) {
  6646. feature = RANDOMIZE_CHEEK_TYPE;
  6647. strncpy(feature_text, "cheeks", sizeof(feature_text) - 1);
  6648. }
  6649. else if (strncasecmp(value, "chin", strlen(value)) == 0) {
  6650. feature = RANDOMIZE_CHIN_TYPE;
  6651. strncpy(feature_text, "chin", sizeof(feature_text) - 1);
  6652. }
  6653. else if (strncasecmp(value, "ear", strlen(value)) == 0) {
  6654. feature = RANDOMIZE_EAR_TYPE;
  6655. strncpy(feature_text, "ears", sizeof(feature_text) - 1);
  6656. }
  6657. else if (strncasecmp(value, "eye_brow", strlen(value)) == 0) {
  6658. feature = RANDOMIZE_EYE_BROW_TYPE;
  6659. strncpy(feature_text, "eye brows", sizeof(feature_text) - 1);
  6660. }
  6661. else if (strncasecmp(value, "eye", strlen(value)) == 0) {
  6662. feature = RANDOMIZE_EYE_TYPE;
  6663. strncpy(feature_text, "eyes", sizeof(feature_text) - 1);
  6664. }
  6665. else if (strncasecmp(value, "lip", strlen(value)) == 0) {
  6666. feature = RANDOMIZE_LIP_TYPE;
  6667. strncpy(feature_text, "lips", sizeof(feature_text) - 1);
  6668. }
  6669. else if (strncasecmp(value, "nose", strlen(value)) == 0) {
  6670. feature = RANDOMIZE_NOSE_TYPE;
  6671. strncpy(feature_text, "nose", sizeof(feature_text) - 1);
  6672. }
  6673. else if (strncasecmp(value, "eye_color", strlen(value)) == 0) {
  6674. feature = RANDOMIZE_EYE_COLOR;
  6675. strncpy(feature_text, "eye color", sizeof(feature_text) - 1);
  6676. }
  6677. else if (strncasecmp(value, "hair_color", strlen(value)) == 0) {
  6678. feature = RANDOMIZE_HAIR_TYPE_COLOR;
  6679. strncpy(feature_text, "hair color", sizeof(feature_text) - 1);
  6680. }
  6681. else if (strncasecmp(value, "hair_color1", strlen(value)) == 0) {
  6682. feature = RANDOMIZE_HAIR_COLOR1;
  6683. strncpy(feature_text, "hair color1", sizeof(feature_text) - 1);
  6684. }
  6685. else if (strncasecmp(value, "hair_color2", strlen(value)) == 0) {
  6686. feature = RANDOMIZE_HAIR_COLOR2;
  6687. strncpy(feature_text, "hair color2", sizeof(feature_text) - 1);
  6688. }
  6689. else if (strncasecmp(value, "hair_highlight", strlen(value)) == 0) {
  6690. feature = RANDOMIZE_HAIR_HIGHLIGHT;
  6691. strncpy(feature_text, "hair highlights", sizeof(feature_text) - 1);
  6692. }
  6693. else if (strncasecmp(value, "facial_hair_color", strlen(value)) == 0) {
  6694. feature = RANDOMIZE_HAIR_FACE_COLOR;
  6695. strncpy(feature_text, "facial hair color", sizeof(feature_text) - 1);
  6696. }
  6697. else if (strncasecmp(value, "facial_hair_color_highlight", strlen(value)) == 0) {
  6698. feature = RANDOMIZE_HAIR_FACE_HIGHLIGHT_COLOR;
  6699. strncpy(feature_text, "facial hair color highlights", sizeof(feature_text) - 1);
  6700. }
  6701. else if (strncasecmp(value, "hair_color_highlight", strlen(value)) == 0) {
  6702. feature = RANDOMIZE_HAIR_TYPE_HIGHLIGHT_COLOR;
  6703. strncpy(feature_text, "hair color highlights", sizeof(feature_text) - 1);
  6704. }
  6705. else if (strncasecmp(value, "skin_color", strlen(value)) == 0) {
  6706. feature = RANDOMIZE_SKIN_COLOR;
  6707. strncpy(feature_text, "skin color", sizeof(feature_text) - 1);
  6708. }
  6709. else if (strncasecmp(value, "wing_color1", strlen(value)) == 0) {
  6710. feature = RANDOMIZE_WING_COLOR1;
  6711. strncpy(feature_text, "wing color1", sizeof(feature_text) - 1);
  6712. }
  6713. else if (strncasecmp(value, "wing_color2", strlen(value)) == 0) {
  6714. feature = RANDOMIZE_WING_COLOR2;
  6715. strncpy(feature_text, "wing color2", sizeof(feature_text) - 1);
  6716. }
  6717. else {
  6718. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is not a valid feature to randomize.", value);
  6719. 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'.");
  6720. }
  6721. if (feature > 0) {
  6722. if (option == 1) {
  6723. if (target->GetRandomize() & feature)
  6724. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is already set to randomly generate their %s.", target->GetName(), feature_text);
  6725. else {
  6726. target->AddRandomize(feature);
  6727. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(feature);
  6728. database.UpdateRandomize(target->GetDatabaseID(), feature);
  6729. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will now generate their %s randomly.", target->GetName(), feature_text);
  6730. }
  6731. }
  6732. else {
  6733. if (target->GetRandomize() & feature) {
  6734. target->AddRandomize(-feature);
  6735. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(-feature);
  6736. database.UpdateRandomize(target->GetDatabaseID(), -feature);
  6737. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will no longer generate their %s randomly.", target->GetName(), feature_text);
  6738. }
  6739. else
  6740. client->Message(CHANNEL_COLOR_YELLOW, "'%s' already does not randomly generate their %s.", target->GetName(), feature_text);
  6741. }
  6742. }
  6743. }
  6744. else
  6745. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  6746. }
  6747. else
  6748. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  6749. }
  6750. }
  6751. else {
  6752. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /randomize [show | [feature [1|0]]");
  6753. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "'show' will display current configured features");
  6754. 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'.");
  6755. }
  6756. }
  6757. else
  6758. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "The target you wish to randomize must be an NPC.");
  6759. }
  6760. else
  6761. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select the target you wish to randomize.");
  6762. }
  6763. /*
  6764. Function: Command_ShowCloak()
  6765. Purpose : Character Settings combo box for Show Cloak
  6766. Params : true/false
  6767. Dev : John Adams
  6768. Example :
  6769. */
  6770. void Commands::Command_ShowCloak(Client* client, Seperator* sep)
  6771. {
  6772. Player* player = client->GetPlayer();
  6773. if (sep && sep->arg[0])
  6774. {
  6775. const char* value = sep->arg[0];
  6776. if (strncasecmp(value, "true", strlen(value)) == 0)
  6777. {
  6778. player->set_character_flag(CF_SHOW_CLOAK);
  6779. player->reset_character_flag(CF2_SHOW_RANGED);
  6780. }
  6781. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6782. player->reset_character_flag(CF_SHOW_CLOAK);
  6783. else
  6784. {
  6785. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6786. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6787. }
  6788. }
  6789. }
  6790. /*
  6791. Function: Command_ShowHelm()
  6792. Purpose : Character Settings combo box for Show Helm
  6793. Params : true/false
  6794. Dev : John Adams
  6795. Example :
  6796. */
  6797. void Commands::Command_ShowHelm(Client* client, Seperator* sep)
  6798. {
  6799. Player* player = client->GetPlayer();
  6800. if (sep && sep->arg[0])
  6801. {
  6802. const char* value = sep->arg[0];
  6803. if (strncasecmp(value, "true", strlen(value)) == 0)
  6804. {
  6805. player->reset_character_flag(CF_HIDE_HELM);
  6806. player->set_character_flag(CF_HIDE_HOOD);
  6807. }
  6808. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6809. player->set_character_flag(CF_HIDE_HELM);
  6810. else
  6811. {
  6812. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6813. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6814. }
  6815. }
  6816. }
  6817. /*
  6818. Function: Command_ShowHood()
  6819. Purpose : Character Settings combo box for Show Hood
  6820. Params : true/false
  6821. Dev : John Adams
  6822. Example :
  6823. */
  6824. void Commands::Command_ShowHood(Client* client, Seperator* sep)
  6825. {
  6826. Player* player = client->GetPlayer();
  6827. if (sep && sep->arg[0])
  6828. {
  6829. const char* value = sep->arg[0];
  6830. if (strncasecmp(value, "true", strlen(value)) == 0)
  6831. {
  6832. player->reset_character_flag(CF_HIDE_HOOD);
  6833. player->set_character_flag(CF_HIDE_HELM);
  6834. }
  6835. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6836. player->set_character_flag(CF_HIDE_HOOD);
  6837. else
  6838. {
  6839. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6840. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6841. }
  6842. }
  6843. }
  6844. /*
  6845. Function: Command_ShowHoodHelm()
  6846. Purpose : Character Settings combo box for Show Helm or Hood
  6847. Params : true/false
  6848. Dev : John Adams
  6849. Example :
  6850. */
  6851. void Commands::Command_ShowHoodHelm(Client* client, Seperator* sep)
  6852. {
  6853. Player* player = client->GetPlayer();
  6854. if (sep && sep->arg[0])
  6855. {
  6856. const char* value = sep->arg[0];
  6857. if (strncasecmp(value, "true", strlen(value)) == 0)
  6858. {
  6859. player->reset_character_flag(CF_HIDE_HOOD);
  6860. player->reset_character_flag(CF_HIDE_HELM);
  6861. }
  6862. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6863. {
  6864. // don't think we ever wind up in here...
  6865. player->set_character_flag(CF_HIDE_HOOD);
  6866. player->set_character_flag(CF_HIDE_HELM);
  6867. }
  6868. else
  6869. {
  6870. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6871. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6872. }
  6873. }
  6874. }
  6875. /*
  6876. Function: Command_ShowRanged()
  6877. Purpose : Character Settings combo box for Show Ranged weapon
  6878. Params : true/false
  6879. Dev : John Adams
  6880. Example :
  6881. */
  6882. void Commands::Command_ShowRanged(Client* client, Seperator* sep)
  6883. {
  6884. Player* player = client->GetPlayer();
  6885. if (sep && sep->arg[0])
  6886. {
  6887. const char* value = sep->arg[0];
  6888. if (strncasecmp(value, "true", strlen(value)) == 0)
  6889. {
  6890. player->set_character_flag(CF2_SHOW_RANGED);
  6891. player->reset_character_flag(CF_SHOW_CLOAK);
  6892. }
  6893. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6894. player->reset_character_flag(CF2_SHOW_RANGED);
  6895. else
  6896. {
  6897. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6898. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6899. }
  6900. }
  6901. }
  6902. /*
  6903. Function:
  6904. Purpose :
  6905. Params :
  6906. Dev :
  6907. Example :
  6908. */
  6909. void Commands::Command_Skills(Client* client, Seperator* sep, int handler)
  6910. {
  6911. Player* player = 0;
  6912. Client* to_client = 0;
  6913. if(client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  6914. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  6915. switch(handler)
  6916. {
  6917. case COMMAND_SKILL:
  6918. {
  6919. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill [add|remove|list] [skill name]");
  6920. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to add/remove skills for that player.");
  6921. break;
  6922. }
  6923. case COMMAND_SKILL_ADD:
  6924. {
  6925. if (sep && sep->arg[0])
  6926. {
  6927. const char* skill_name = sep->argplus[0];
  6928. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6929. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // add skill to your target, if target is not you
  6930. {
  6931. player = to_client->GetPlayer();
  6932. if (player)
  6933. {
  6934. if (!player->GetSkills()->HasSkill(skill->skill_id))
  6935. {
  6936. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  6937. client->Message(CHANNEL_COLOR_YELLOW, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  6938. to_client->Message(CHANNEL_COLOR_YELLOW, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  6939. }
  6940. else
  6941. client->Message(CHANNEL_COLOR_YELLOW, "%s already has the skill '%s'.", player->GetName(), skill_name);
  6942. }
  6943. }
  6944. else if (skill) // add skill to yourself
  6945. {
  6946. player = client->GetPlayer();
  6947. if (player)
  6948. {
  6949. if (!player->GetSkills()->HasSkill(skill->skill_id))
  6950. {
  6951. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  6952. client->Message(CHANNEL_COLOR_YELLOW, "Added skill '%s'.", skill_name);
  6953. }
  6954. else
  6955. client->Message(CHANNEL_COLOR_YELLOW, "You already have the skill '%s'.", skill_name);
  6956. }
  6957. }
  6958. else
  6959. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  6960. }
  6961. else
  6962. {
  6963. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill add [skill name]");
  6964. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  6965. }
  6966. break;
  6967. }
  6968. case COMMAND_SKILL_REMOVE:
  6969. {
  6970. if (sep && sep->arg[0])
  6971. {
  6972. const char* skill_name = sep->argplus[0];
  6973. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6974. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // remove skill from your target, if target is not you
  6975. {
  6976. player = to_client->GetPlayer();
  6977. if (player)
  6978. {
  6979. if (player->GetSkills()->HasSkill(skill->skill_id))
  6980. {
  6981. player->RemoveSkillFromDB(skill, true);
  6982. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  6983. to_client->Message(CHANNEL_COLOR_YELLOW, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  6984. }
  6985. else
  6986. client->Message(CHANNEL_COLOR_YELLOW, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  6987. }
  6988. }
  6989. else if(skill) // remove skill from yourself
  6990. {
  6991. Player* player = client->GetPlayer();
  6992. if (player)
  6993. {
  6994. if (player->GetSkills()->HasSkill(skill->skill_id))
  6995. {
  6996. player->RemoveSkillFromDB(skill, true);
  6997. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s'.", skill_name);
  6998. }
  6999. else
  7000. client->Message(CHANNEL_COLOR_YELLOW, "You do not have the skill '%s'.", skill_name);
  7001. }
  7002. }
  7003. else
  7004. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  7005. }
  7006. else
  7007. {
  7008. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill remove [skill name]");
  7009. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  7010. }
  7011. break;
  7012. }
  7013. case COMMAND_SKILL_LIST:
  7014. {
  7015. if (sep && sep->arg[0])
  7016. {
  7017. const char* skill_name = sep->argplus[0];
  7018. client->Message(CHANNEL_COLOR_YELLOW, "Listing skills like '%s':", skill_name);
  7019. map<int32, Skill*>* skills = master_skill_list.GetAllSkills();
  7020. map<int32, Skill*>::iterator itr;
  7021. if (skills && skills->size() > 0)
  7022. {
  7023. for (itr = skills->begin(); itr != skills->end(); itr++)
  7024. {
  7025. Skill* skill = itr->second;
  7026. string current_skill_name = ::ToLower(string(skill->name.data.c_str()));
  7027. if (current_skill_name.find(::ToLower(string(skill_name))) < 0xFFFFFFFF)
  7028. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", skill->name.data.c_str(), skill->skill_id);
  7029. }
  7030. }
  7031. }
  7032. else
  7033. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill list [skill name]");
  7034. break;
  7035. }
  7036. }
  7037. }
  7038. /*
  7039. Function: Command_SpawnTemplate()
  7040. Purpose : Create or Use defined Spawn Templates
  7041. Params : create, save, rempve, list
  7042. Dev : John Adams
  7043. Example : /spawn template create "Test"
  7044. */
  7045. void Commands::Command_SpawnTemplate(Client* client, Seperator* sep)
  7046. {
  7047. if (sep == NULL || sep->arg[0] == NULL)
  7048. {
  7049. 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.");
  7050. return;
  7051. }
  7052. // got params, continue
  7053. const char * template_cmd = sep->arg[0];
  7054. if (strncasecmp(template_cmd, "list", strlen(template_cmd)) == 0)
  7055. {
  7056. if (!sep->IsSet(1))
  7057. {
  7058. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /spawn template list [name|location_id]");
  7059. 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.");
  7060. return;
  7061. }
  7062. map<int32, string>* template_names = 0;
  7063. if (sep->IsNumber(1))
  7064. {
  7065. int32 location_id = 0;
  7066. location_id = atoi(sep->arg[1]);
  7067. template_names = database.GetSpawnTemplateListByID(location_id);
  7068. }
  7069. else
  7070. {
  7071. const char* name = 0;
  7072. name = sep->argplus[1];
  7073. template_names = database.GetSpawnTemplateListByName(name);
  7074. }
  7075. if(!template_names)
  7076. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No templates found.");
  7077. else
  7078. {
  7079. map<int32, string>::iterator itr;
  7080. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  7081. for(itr = template_names->begin(); itr != template_names->end(); itr++)
  7082. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  7083. safe_delete(template_names);
  7084. }
  7085. }
  7086. else if (strncasecmp(template_cmd, "save", strlen(template_cmd)) == 0)
  7087. {
  7088. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  7089. if ( target && (target->IsNPC() || target->IsObject() || target->IsSign() || target->IsWidget() || target->IsGroundSpawn()) )
  7090. {
  7091. if (sep && sep->arg[1][0] && !sep->IsNumber(1))
  7092. {
  7093. // first, lookup to see if template name already exists
  7094. const char* name = 0;
  7095. name = sep->argplus[1];
  7096. map<int32, string>* template_names = database.GetSpawnTemplateListByName(name);
  7097. if(!template_names)
  7098. {
  7099. int32 new_template_id = database.SaveSpawnTemplate(target->GetSpawnLocationID(), name);
  7100. if( new_template_id > 0 )
  7101. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template '%s' added for spawn '%s' (%u) as TemplateID: %u", name, target->GetName(), target->GetSpawnLocationID(), new_template_id);
  7102. else
  7103. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' for spawn '%s' (%u).", name, target->GetName(), target->GetSpawnLocationID());
  7104. }
  7105. else
  7106. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' - Already exists!", name);
  7107. }
  7108. else
  7109. client->Message(CHANNEL_COLOR_RED, "ERROR: Saving a new spawn template requires a valid template name!");
  7110. }
  7111. else
  7112. client->Message(CHANNEL_COLOR_RED, "ERROR: You must target the spawn you wish to save as a template!");
  7113. }
  7114. else if (strncasecmp(template_cmd, "remove", strlen(template_cmd)) == 0)
  7115. {
  7116. if (sep && sep->arg[1][0] && sep->IsNumber(1))
  7117. {
  7118. int32 template_id = 0;
  7119. template_id = atoi(sep->arg[1]);
  7120. if (database.RemoveSpawnTemplate(template_id))
  7121. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template ID: %u successfully removed.", template_id);
  7122. else
  7123. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to remove spawn template ID: %u", template_id);
  7124. }
  7125. else
  7126. client->Message(CHANNEL_COLOR_RED, "ERROR: Removing a spawn template requires a valid template ID!");
  7127. }
  7128. // Renamed create to spawn
  7129. else if (strncasecmp(template_cmd, "spawn", strlen(template_cmd)) == 0)
  7130. {
  7131. if (sep && sep->arg[1][0])
  7132. {
  7133. int32 new_location = 0;
  7134. if (sep->IsNumber(1))
  7135. {
  7136. int32 template_id = 0;
  7137. template_id = atoi(sep->arg[1]);
  7138. new_location = database.CreateSpawnFromTemplateByID(client, template_id);
  7139. if( new_location > 0 )
  7140. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template ID: %u", new_location, template_id);
  7141. else
  7142. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template ID: %u", template_id);
  7143. }
  7144. else
  7145. {
  7146. const char* name = 0;
  7147. name = sep->argplus[1];
  7148. new_location = database.CreateSpawnFromTemplateByName(client, name);
  7149. if( new_location > 0 )
  7150. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template: '%s'", new_location, name);
  7151. else
  7152. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template: '%s'", name);
  7153. }
  7154. }
  7155. else
  7156. client->Message(CHANNEL_COLOR_RED, "ERROR: Spawning a new spawn location requires a valid template name or ID!");
  7157. }
  7158. else
  7159. client->Message(CHANNEL_COLOR_RED, "ERROR: Unknown /spawn template command.");
  7160. }
  7161. void Commands::Command_Speed(Client* client, Seperator* sep) {
  7162. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  7163. float new_speed = atof(sep->arg[0]);
  7164. if (new_speed > 0.0f)
  7165. {
  7166. client->GetPlayer()->SetSpeed(new_speed, true);
  7167. client->GetPlayer()->SetCharSheetChanged(true);
  7168. database.insertCharacterProperty(client, CHAR_PROPERTY_SPEED, sep->arg[0]);
  7169. client->Message(CHANNEL_STATUS, "Setting speed to %.2f.", new_speed);
  7170. }
  7171. else
  7172. client->Message(CHANNEL_STATUS, "Invalid speed provided %s.", sep->arg[0]);
  7173. }
  7174. else{
  7175. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /speed {new speed value}");
  7176. }
  7177. }
  7178. /*
  7179. Function: Command_StationMarketPlace()
  7180. Purpose : just trying to eat the console spam for now
  7181. Params :
  7182. Dev : John
  7183. */
  7184. void Commands::Command_StationMarketPlace(Client* client, Seperator* sep)
  7185. {
  7186. PrintSep(sep, "COMMAND_SMP");
  7187. // This will reduce the spam from once every 10 sec to once every 30 sec,
  7188. // can't seem to reduce it any more get rid of it completely...
  7189. if (sep && strcmp(sep->arg[0], "gkw") == 0) {
  7190. PacketStruct* packet = configReader.getStruct("WS_MarketFundsUpdate", client->GetVersion());
  7191. if (packet) {
  7192. packet->setDataByName("account_id", client->GetAccountID());
  7193. packet->setDataByName("character_id", client->GetCharacterID());
  7194. packet->setDataByName("unknown1", 1, 5);
  7195. packet->setDataByName("unknown1", 26, 6);
  7196. packet->setDataByName("unknown2", 0xFFFFFFFF);
  7197. packet->setDataByName("unknown3", 248, 1);
  7198. client->QueuePacket(packet->serialize());
  7199. }
  7200. safe_delete(packet);
  7201. }
  7202. }
  7203. /*
  7204. Function: Command_StopDrinking()
  7205. Purpose : Stops player from auto-consuming drink
  7206. Params :
  7207. Dev : Zcoretri
  7208. Example : /stopdrinking
  7209. */
  7210. void Commands::Command_StopDrinking(Client* client)
  7211. {
  7212. client->GetPlayer()->reset_character_flag(CF_DRINK_AUTO_CONSUME);
  7213. client->Message(CHANNEL_COLOR_YELLOW,"You stop drinking your current drink.");
  7214. }
  7215. /*
  7216. Function: Command_StopEating()
  7217. Purpose : Stops player from auto-consuming food
  7218. Params :
  7219. Dev : Zcoretri
  7220. Example : /stopeating
  7221. */
  7222. void Commands::Command_StopEating(Client* client)
  7223. {
  7224. client->GetPlayer()->reset_character_flag(CF_FOOD_AUTO_CONSUME);
  7225. client->Message(CHANNEL_COLOR_YELLOW,"You stop eating your current food.");
  7226. }
  7227. /*
  7228. Function: Command_Title()
  7229. Purpose : Help for /title command
  7230. Params : n/a
  7231. Dev : Zcoretri
  7232. Example : /title
  7233. */
  7234. void Commands::Command_Title(Client* client)
  7235. {
  7236. client->Message(CHANNEL_COLOR_YELLOW, "Available subcommands: list, setprefix <index>, setsuffix <index>, fix");
  7237. }
  7238. /*
  7239. Function: Command_TitleList()
  7240. Purpose : List available titles for player
  7241. Params : n/a
  7242. Dev : Zcoretri
  7243. Example : /title list
  7244. */
  7245. void Commands::Command_TitleList(Client* client)
  7246. {
  7247. list<Title*>* titles = client->GetPlayer()->GetPlayerTitles()->GetAllTitles();
  7248. list<Title*>::iterator itr;
  7249. Title* title;
  7250. int16 i = 0;
  7251. client->Message(CHANNEL_NARRATIVE, "Listing available titles:");
  7252. for(itr = titles->begin(); itr != titles->end(); itr++)
  7253. {
  7254. title = *itr;
  7255. client->Message(CHANNEL_NARRATIVE, "%i: type=[%s] title=[%s]", i, title->GetPrefix() ? "Prefix":"Suffix", title->GetName());
  7256. i++;
  7257. }
  7258. }
  7259. /*
  7260. Function: Command_TitleSetPrefix()
  7261. Purpose : Set Prefix title for player
  7262. Params : Title ID
  7263. Dev : Zcoretri
  7264. Example : /title setprefix 1
  7265. */
  7266. void Commands::Command_TitleSetPrefix(Client* client, Seperator* sep)
  7267. {
  7268. if (sep && sep->arg[0] && sep->IsNumber(0))
  7269. {
  7270. int32 index = atoul(sep->arg[0]);
  7271. database.SaveCharPrefixIndex(index, client->GetCharacterID(), client);
  7272. client->SendTitleUpdate();
  7273. }
  7274. }
  7275. /*
  7276. Function: Command_TitleSetSuffix()
  7277. Purpose : Set Suffix title for player
  7278. Params : Title ID
  7279. Dev : Zcoretri
  7280. Example : /title setsuffix 1
  7281. */
  7282. void Commands::Command_TitleSetSuffix(Client* client, Seperator* sep)
  7283. {
  7284. if (sep && sep->arg[0] && sep->IsNumber(0))
  7285. {
  7286. int32 index = atoul(sep->arg[0]);
  7287. database.SaveCharSuffixIndex(index, client->GetCharacterID(), client);
  7288. client->SendTitleUpdate();
  7289. }
  7290. }
  7291. /*
  7292. Function: Command_TitleFix()
  7293. Purpose : Fix title for player (???)
  7294. Params :
  7295. Dev : Zcoretri
  7296. Example :
  7297. */
  7298. void Commands::Command_TitleFix(Client* client, Seperator* sep)
  7299. {
  7300. PrintSep(sep, "COMMAND_TITLE_FIX");
  7301. LogWrite(MISC__TODO, 1, "Titles", "TODO-Command: TITLE_FIX");
  7302. }
  7303. /*
  7304. Function: Command_Toggle_Anonymous()
  7305. Purpose : Toggles player Anonymous
  7306. Params :
  7307. Dev : paulgh
  7308. Example : /anon
  7309. */
  7310. void Commands::Command_Toggle_Anonymous(Client* client)
  7311. {
  7312. Player* player = client->GetPlayer();
  7313. player->toggle_character_flag(CF_ANONYMOUS);
  7314. client->Message(CHANNEL_COLOR_YELLOW,"You are %s anonymous.", player->get_character_flag(CF_ANONYMOUS)?"now":"no longer");
  7315. if (player->get_character_flag(CF_ANONYMOUS))
  7316. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ANONYMOUS);
  7317. else
  7318. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ANONYMOUS);
  7319. }
  7320. /*
  7321. Function: Command_Toggle_AutoConsume()
  7322. Purpose : Toggles player food/drink auto consume
  7323. Params : unknown
  7324. Dev : paulgh
  7325. Example : /set_auto_consume
  7326. */
  7327. void Commands::Command_Toggle_AutoConsume(Client* client, Seperator* sep)
  7328. {
  7329. Player* player = client->GetPlayer();
  7330. if (sep && sep->arg[0])
  7331. PrintSep(sep, "COMMAND_SET_AUTO_CONSUME");
  7332. if (sep && sep->arg[0] && sep->IsNumber(0))
  7333. {
  7334. int8 slot = atoi(sep->arg[0]);
  7335. int8 flag = atoi(sep->arg[1]);
  7336. if (client->GetVersion() <= 283) {
  7337. slot += 4;
  7338. }
  7339. else if (client->GetVersion() <= 546) {
  7340. slot += 2;
  7341. }
  7342. if (slot == EQ2_FOOD_SLOT)
  7343. {
  7344. player->toggle_character_flag(CF_FOOD_AUTO_CONSUME);
  7345. player->SetCharSheetChanged(true);
  7346. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  7347. if (flag == 1)
  7348. client->Message(CHANNEL_NARRATIVE, "You decide to eat immediately whenever you become hungry.");
  7349. else
  7350. client->Message(CHANNEL_NARRATIVE, "You decide to ignore the hunger.");
  7351. }
  7352. else
  7353. {
  7354. player->toggle_character_flag(CF_DRINK_AUTO_CONSUME);
  7355. player->SetCharSheetChanged(true);
  7356. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  7357. if (flag == 1)
  7358. client->Message(CHANNEL_NARRATIVE, "You decide to drink immediately whenever you become thirsty.");
  7359. else
  7360. client->Message(CHANNEL_NARRATIVE, "You decide to ignore the thirst.");
  7361. }
  7362. }
  7363. }
  7364. /*
  7365. Function: Command_Toggle_BonusXP()
  7366. Purpose : Toggles player Bonus XP
  7367. Params :
  7368. Dev : John Adams
  7369. Example : /disable_char_bonus_exp
  7370. */
  7371. void Commands::Command_Toggle_BonusXP(Client* client)
  7372. {
  7373. Player* player = client->GetPlayer();
  7374. player->toggle_character_flag(CF2_CHARACTER_BONUS_EXPERIENCE_ENABLED);
  7375. player->SetCharSheetChanged(true);
  7376. }
  7377. /*
  7378. Function: Command_Toggle_CombatXP()
  7379. Purpose : Toggles player Adventure XP
  7380. Params :
  7381. Dev : John Adams
  7382. Example : /disable_combat_exp
  7383. */
  7384. void Commands::Command_Toggle_CombatXP(Client* client)
  7385. {
  7386. Player* player = client->GetPlayer();
  7387. player->toggle_character_flag(CF_COMBAT_EXPERIENCE_ENABLED);
  7388. player->SetCharSheetChanged(true);
  7389. }
  7390. /*
  7391. Function: Command_Toggle_GMHide()
  7392. Purpose : Toggles hiding player GM status
  7393. Params :
  7394. Dev : Scatman
  7395. Example : /gm_hide
  7396. */
  7397. void Commands::Command_Toggle_GMHide(Client* client)
  7398. {
  7399. Player* player = client->GetPlayer();
  7400. player->toggle_character_flag(CF_HIDE_STATUS);
  7401. client->Message(CHANNEL_COLOR_YELLOW,"You are %s hiding your GM status.", player->get_character_flag(CF_HIDE_STATUS)?"now":"no longer");
  7402. }
  7403. /*
  7404. Function: Command_Toggle_GMVanish()
  7405. Purpose : Toggles hiding GM players from /who searches
  7406. Params :
  7407. Dev : Scatman
  7408. Example : /gm_vanish
  7409. */
  7410. void Commands::Command_Toggle_GMVanish(Client* client)
  7411. {
  7412. Player* player = client->GetPlayer();
  7413. player->toggle_character_flag(CF_GM_HIDDEN);
  7414. client->Message(CHANNEL_COLOR_YELLOW,"You are %s invisible to who queries.", player->get_character_flag(CF_GM_HIDDEN)?"now":"no longer");
  7415. }
  7416. /*
  7417. Function: Command_Toggle_Illusions()
  7418. Purpose : Toggles player illusion form
  7419. Params : not sure sep is needed, testing
  7420. Dev : paulgh
  7421. Example : /hide_illusions
  7422. */
  7423. void Commands::Command_Toggle_Illusions(Client* client, Seperator* sep)
  7424. {
  7425. if (sep && sep->arg[0])
  7426. PrintSep(sep, "COMMAND_TOGGLE_ILLUSIONS");
  7427. client->GetPlayer()->toggle_character_flag(CF_SHOW_ILLUSION);
  7428. }
  7429. /*
  7430. Function: Command_Toggle_LFG()
  7431. Purpose : Toggles player LFG Flag
  7432. Params :
  7433. Dev : paulgh
  7434. Example : /lfg
  7435. */
  7436. void Commands::Command_Toggle_LFG(Client* client)
  7437. {
  7438. Player* player = client->GetPlayer();
  7439. player->toggle_character_flag(CF_LFG);
  7440. client->Message(CHANNEL_COLOR_YELLOW,"You are %s LFG.", player->get_character_flag(CF_LFG)?"now":"no longer");
  7441. if (player->get_character_flag(CF_LFG))
  7442. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFG);
  7443. else
  7444. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFG);
  7445. }
  7446. /*
  7447. Function: Command_Toggle_LFW()
  7448. Purpose : Toggles player LFW Flag
  7449. Params :
  7450. Dev : paulgh
  7451. Example : /lfw
  7452. */
  7453. void Commands::Command_Toggle_LFW(Client* client)
  7454. {
  7455. Player* player = client->GetPlayer();
  7456. player->toggle_character_flag(CF_LFW);
  7457. client->Message(CHANNEL_COLOR_YELLOW,"You %s looking for work.", player->get_character_flag(CF_LFW)?"let others know you are":"stop");
  7458. if (player->get_character_flag(CF_LFW))
  7459. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFW);
  7460. else
  7461. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFW);
  7462. }
  7463. /*
  7464. Function: Command_Toggle_QuestXP()
  7465. Purpose : Toggles player Quest XP
  7466. Params :
  7467. Dev : John Adams
  7468. Example : /disable_quest_exp
  7469. */
  7470. void Commands::Command_Toggle_QuestXP(Client* client)
  7471. {
  7472. Player* player = client->GetPlayer();
  7473. player->toggle_character_flag(CF_QUEST_EXPERIENCE_ENABLED);
  7474. player->SetCharSheetChanged(true);
  7475. }
  7476. /*
  7477. Function: Command_Toggle_Roleplaying()
  7478. Purpose : Toggles player Roleplaying flag
  7479. Params :
  7480. Dev : paulgh
  7481. Example : /role
  7482. */
  7483. void Commands::Command_Toggle_Roleplaying(Client* client)
  7484. {
  7485. Player* player = client->GetPlayer();
  7486. player->toggle_character_flag(CF_ROLEPLAYING);
  7487. client->Message(CHANNEL_COLOR_YELLOW,"You are %s roleplaying.", player->get_character_flag(CF_ROLEPLAYING)?"now":"no longer");
  7488. if (player->get_character_flag(CF_ROLEPLAYING))
  7489. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ROLEPLAYING);
  7490. else
  7491. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ROLEPLAYING);
  7492. }
  7493. void Commands::Command_Toggle_Duels(Client* client)
  7494. {
  7495. Player* player = client->GetPlayer();
  7496. player->toggle_character_flag(CF_ALLOW_DUEL_INVITES);
  7497. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting duel invites.", player->get_character_flag(CF_ALLOW_DUEL_INVITES)?"now":"no longer");
  7498. }
  7499. void Commands::Command_Toggle_Trades(Client* client)
  7500. {
  7501. Player* player = client->GetPlayer();
  7502. player->toggle_character_flag(CF_ALLOW_TRADE_INVITES);
  7503. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting trade invites.", player->get_character_flag(CF_ALLOW_TRADE_INVITES)?"now":"no longer");
  7504. }
  7505. void Commands::Command_Toggle_Guilds(Client* client)
  7506. {
  7507. Player* player = client->GetPlayer();
  7508. player->toggle_character_flag(CF_ALLOW_GUILD_INVITES);
  7509. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting guild invites.", player->get_character_flag(CF_ALLOW_GUILD_INVITES)?"now":"no longer");
  7510. }
  7511. void Commands::Command_Toggle_Groups(Client* client)
  7512. {
  7513. Player* player = client->GetPlayer();
  7514. player->toggle_character_flag(CF_ALLOW_GROUP_INVITES);
  7515. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting group invites.", player->get_character_flag(CF_ALLOW_GROUP_INVITES)?"now":"no longer");
  7516. }
  7517. void Commands::Command_Toggle_Raids(Client* client)
  7518. {
  7519. Player* player = client->GetPlayer();
  7520. player->toggle_character_flag(CF_ALLOW_RAID_INVITES);
  7521. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting raid invites.", player->get_character_flag(CF_ALLOW_RAID_INVITES)?"now":"no longer");
  7522. }
  7523. void Commands::Command_Toggle_LON(Client* client)
  7524. {
  7525. Player* player = client->GetPlayer();
  7526. player->toggle_character_flag(CF2_ALLOW_LON_INVITES);
  7527. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting LoN invites.", player->get_character_flag(CF2_ALLOW_LON_INVITES)?"now":"no longer");
  7528. }
  7529. void Commands::Command_Toggle_VoiceChat(Client* client)
  7530. {
  7531. Player* player = client->GetPlayer();
  7532. player->toggle_character_flag(CF2_ALLOW_VOICE_INVITES);
  7533. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting voice chat invites.", player->get_character_flag(CF2_ALLOW_VOICE_INVITES)?"now":"no longer");
  7534. }
  7535. /*
  7536. Function: Command_TradeStart()
  7537. Purpose : Starts item/coin trade between players
  7538. Params :
  7539. Dev :
  7540. Example :
  7541. */
  7542. #include "../Trade.h"
  7543. void Commands::Command_TradeStart(Client* client, Seperator* sep)
  7544. {
  7545. PrintSep(sep, "COMMAND_START_TRADE");
  7546. Entity* trader = client->GetPlayer();
  7547. Entity* trader2 = 0;
  7548. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7549. Spawn* spawn = client->GetPlayer()->GetSpawnWithPlayerID(atoi(sep->arg[0]));
  7550. if (spawn) {
  7551. if (spawn->IsEntity())
  7552. trader2 = (Entity*)spawn;
  7553. }
  7554. }
  7555. else if (client->GetPlayer()->GetTarget()) {
  7556. if (client->GetPlayer()->GetTarget()->IsEntity())
  7557. trader2 = (Entity*)client->GetPlayer()->GetTarget();
  7558. }
  7559. // can only trade with player or bots
  7560. if (trader && trader2) {
  7561. if (trader == trader2) {
  7562. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade with yourself.");
  7563. }
  7564. else if (trader2->IsPlayer() || trader2->IsBot()) {
  7565. LogWrite(PLAYER__ERROR, 0, "Trade", "creating trade");
  7566. if (trader->trade)
  7567. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are already trading.");
  7568. else if (trader2->trade)
  7569. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is already trading.");
  7570. else {
  7571. Trade* trade = new Trade(trader, trader2);
  7572. trader->trade = trade;
  7573. trader2->trade = trade;
  7574. }
  7575. }
  7576. else {
  7577. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can only trade with another player or a bot.");
  7578. }
  7579. }
  7580. else
  7581. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to find target");
  7582. }
  7583. /*
  7584. Function: Command_Track()
  7585. Purpose : Starts/Stops Tracking for a player
  7586. Params :
  7587. Dev : Scatman
  7588. Example : /track
  7589. */
  7590. void Commands::Command_Track(Client* client)
  7591. {
  7592. if (!client->GetPlayer()->GetIsTracking())
  7593. client->GetPlayer()->GetZone()->AddPlayerTracking(client->GetPlayer());
  7594. else
  7595. client->GetPlayer()->GetZone()->RemovePlayerTracking(client->GetPlayer(), TRACKING_STOP);
  7596. }
  7597. /*
  7598. Function: Command_TradeAccept()
  7599. Purpose : Accepts item/coin trade between players
  7600. Params :
  7601. Dev :
  7602. Example :
  7603. */
  7604. void Commands::Command_TradeAccept(Client* client, Seperator* sep)
  7605. {
  7606. PrintSep(sep, "COMMAND_ACCEPT_TRADE");
  7607. Trade* trade = client->GetPlayer()->trade;
  7608. if (trade) {
  7609. bool trade_complete = trade->SetTradeAccepted(client->GetPlayer());
  7610. if (trade_complete)
  7611. safe_delete(trade);
  7612. }
  7613. else
  7614. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7615. }
  7616. /*
  7617. Function: Command_TradeReject()
  7618. Purpose : Rejects item/coin trade between players
  7619. Params :
  7620. Dev :
  7621. Example :
  7622. */
  7623. void Commands::Command_TradeReject(Client* client, Seperator* sep)
  7624. {
  7625. PrintSep(sep, "COMMAND_REJECT_TRADE");
  7626. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Reject Player Trading");
  7627. client->Message(CHANNEL_COLOR_YELLOW, "You cannot trade with other players (Not Implemented)");
  7628. }
  7629. /*
  7630. Function: Command_TradeCancel()
  7631. Purpose : Cancels item/coin trade between players
  7632. Params :
  7633. Dev :
  7634. Example :
  7635. */
  7636. void Commands::Command_TradeCancel(Client* client, Seperator* sep)
  7637. {
  7638. PrintSep(sep, "COMMAND_CANCEL_TRADE");
  7639. Trade* trade = client->GetPlayer()->trade;
  7640. if (trade) {
  7641. trade->CancelTrade(client->GetPlayer());
  7642. safe_delete(trade);
  7643. }
  7644. else
  7645. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7646. }
  7647. /*
  7648. Function: Command_TradeSetCoin()
  7649. Purpose : Sets coin trade between players
  7650. Params :
  7651. Dev :
  7652. Example :
  7653. */
  7654. void Commands::Command_TradeSetCoin(Client* client, Seperator* sep)
  7655. {
  7656. PrintSep(sep, "COMMAND_SET_TRADE_COIN");
  7657. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Set Trade Coin");
  7658. client->Message(CHANNEL_COLOR_YELLOW, "You cannot trade with other players (Not Implemented)");
  7659. }
  7660. /*
  7661. Function: Command_TradeAddCoin()
  7662. Purpose : Adds coin to trade between players
  7663. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  7664. Dev :
  7665. Example :
  7666. */
  7667. void Commands::Command_TradeAddCoin(Client* client, Seperator* sep, int handler)
  7668. {
  7669. PrintSep(sep, "COMMAND_ADD_TRADE_{coin type}");
  7670. Trade* trade = client->GetPlayer()->trade;
  7671. if (trade) {
  7672. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7673. int32 amount = atoi(sep->arg[0]);
  7674. int64 val = 0;
  7675. switch (handler) {
  7676. case COMMAND_ADD_TRADE_COPPER:
  7677. {
  7678. val = amount;
  7679. trade->AddCoinToTrade(client->GetPlayer(), val);
  7680. break;
  7681. }
  7682. case COMMAND_ADD_TRADE_SILVER:
  7683. {
  7684. val = amount * 100;
  7685. trade->AddCoinToTrade(client->GetPlayer(), val);
  7686. break;
  7687. }
  7688. case COMMAND_ADD_TRADE_GOLD:
  7689. {
  7690. val = amount * 10000;
  7691. trade->AddCoinToTrade(client->GetPlayer(), val);
  7692. break;
  7693. }
  7694. case COMMAND_ADD_TRADE_PLAT:
  7695. {
  7696. val = amount * 1000000;
  7697. trade->AddCoinToTrade(client->GetPlayer(), val);
  7698. break;
  7699. }
  7700. default:
  7701. {
  7702. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  7703. break;
  7704. }
  7705. }
  7706. }
  7707. else
  7708. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount.");
  7709. }
  7710. else
  7711. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7712. }
  7713. /*
  7714. Function: Command_TradeRemoveCoin()
  7715. Purpose : Removes coin from trade between players
  7716. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  7717. Dev :
  7718. Example :
  7719. */
  7720. void Commands::Command_TradeRemoveCoin(Client* client, Seperator* sep, int handler)
  7721. {
  7722. PrintSep(sep, "COMMAND_REMOVE_TRADE_{coin type}");
  7723. Trade* trade = client->GetPlayer()->trade;
  7724. if (trade) {
  7725. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7726. int32 amount = atoi(sep->arg[0]);
  7727. int64 val = 0;
  7728. switch (handler) {
  7729. case COMMAND_REMOVE_TRADE_COPPER:
  7730. {
  7731. val = amount;
  7732. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7733. break;
  7734. }
  7735. case COMMAND_REMOVE_TRADE_SILVER:
  7736. {
  7737. val = amount * 100;
  7738. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7739. break;
  7740. }
  7741. case COMMAND_REMOVE_TRADE_GOLD:
  7742. {
  7743. val = amount * 10000;
  7744. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7745. break;
  7746. }
  7747. case COMMAND_REMOVE_TRADE_PLAT:
  7748. {
  7749. val = amount * 1000000;
  7750. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7751. break;
  7752. }
  7753. default:
  7754. {
  7755. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  7756. break;
  7757. }
  7758. }
  7759. }
  7760. else
  7761. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount");
  7762. }
  7763. else
  7764. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7765. }
  7766. /*
  7767. Function: Command_TradeAddItem()
  7768. Purpose : Adds item to trade between players
  7769. Params :
  7770. Dev :
  7771. Example :
  7772. */
  7773. void Commands::Command_TradeAddItem(Client* client, Seperator* sep)
  7774. {
  7775. PrintSep(sep, "COMMAND_ADD_TRADE_ITEM");
  7776. /*
  7777. arg[0] = item index
  7778. arg[1] = slot
  7779. arg[2] = quantity
  7780. */
  7781. if (!client->GetPlayer()->trade) {
  7782. LogWrite(PLAYER__ERROR, 0, "Trade", "Player is not currently trading.");
  7783. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7784. return;
  7785. }
  7786. if (sep && sep->IsSet(0) && sep->IsNumber(0) && sep->IsSet(1) && sep->IsNumber(1) && sep->IsSet(2) && sep->IsNumber(2)) {
  7787. Item* item = 0;
  7788. int32 index = atoi(sep->arg[0]);
  7789. item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(index);
  7790. if (item) {
  7791. int8 result = client->GetPlayer()->trade->AddItemToTrade(client->GetPlayer(), item, atoi(sep->arg[2]), atoi(sep->arg[1]));
  7792. if (result == 1)
  7793. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Item is already being traded.");
  7794. else if (result == 2)
  7795. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade NO-TRADE items.");
  7796. else if (result == 3)
  7797. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade HEIRLOOM items.");
  7798. else if (result == 255)
  7799. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown error trying to add the item to the trade...");
  7800. }
  7801. else {
  7802. LogWrite(PLAYER__ERROR, 0, "Trade", "Unable to get an item for the player (%s) from the index (%u)", client->GetPlayer()->GetName(), index);
  7803. client->Message(CHANNEL_ERROR, "Unable to find item at index %u", index);
  7804. }
  7805. }
  7806. else
  7807. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  7808. }
  7809. /*
  7810. Function: Command_TradeRemoveItem()
  7811. Purpose : Removes item from trade between players
  7812. Params :
  7813. Dev :
  7814. Example :
  7815. */
  7816. void Commands::Command_TradeRemoveItem(Client* client, Seperator* sep)
  7817. {
  7818. PrintSep(sep, "COMMAND_REMOVE_TRADE_ITEM");
  7819. /*
  7820. arg[0] = trade window slot
  7821. */
  7822. Trade* trade = client->GetPlayer()->trade;
  7823. if (trade) {
  7824. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7825. trade->RemoveItemFromTrade(client->GetPlayer(), atoi(sep->arg[0]));
  7826. }
  7827. else
  7828. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  7829. }
  7830. else
  7831. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7832. }
  7833. void Commands::Command_TryOn(Client* client, Seperator* sep)
  7834. {
  7835. Item *item = 0;
  7836. sint32 crc;
  7837. if (sep) {
  7838. // 1096+ sends more info so need to do a version check so older clients (SF) still work
  7839. if (client->GetVersion() < 1096) {
  7840. if (sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2))
  7841. {
  7842. item = master_item_list.GetItem(atoul(sep->arg[1]));
  7843. crc = atol(sep->arg[2]);
  7844. }
  7845. }
  7846. else {
  7847. // From the broker and links in chat
  7848. if (strcmp(sep->arg[0], "crc") == 0) {
  7849. if (sep->IsNumber(2) && sep->IsNumber(3)) {
  7850. item = master_item_list.GetItem(atoul(sep->arg[2]));
  7851. crc = atol(sep->arg[3]);
  7852. }
  7853. }
  7854. // From inventory
  7855. if (strcmp(sep->arg[0], "dbid") == 0) {
  7856. if (sep->IsNumber(2) && sep->IsNumber(4)) {
  7857. item = master_item_list.GetItem(atoul(sep->arg[2]));
  7858. crc = atol(sep->arg[4]);
  7859. }
  7860. }
  7861. }
  7862. if (item)
  7863. client->ShowDressingRoom(item, crc);
  7864. }
  7865. }
  7866. void Commands::Command_JoinChannel(Client * client, Seperator *sep) {
  7867. const char *channel_name, *password = NULL;
  7868. if (sep == NULL || !sep->IsSet(0)) {
  7869. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /joinchannel <channel name> [password]");
  7870. return;
  7871. }
  7872. channel_name = sep->arg[0];
  7873. if (sep->IsSet(1))
  7874. password = sep->arg[1];
  7875. if (!chat.ChannelExists(channel_name) && !chat.CreateChannel(channel_name, password)) {
  7876. client->Message(CHANNEL_COLOR_RED, "Unable to create channel '%s'.", channel_name);
  7877. return;
  7878. }
  7879. if (chat.IsInChannel(client, channel_name)) {
  7880. client->Message(CHANNEL_NARRATIVE, "You are already in '%s'.", channel_name);
  7881. return;
  7882. }
  7883. if (chat.HasPassword(channel_name)) {
  7884. if (password == NULL) {
  7885. client->Message(CHANNEL_NARRATIVE, "Unable to join '%s': That channel is password protected.", channel_name);
  7886. return;
  7887. }
  7888. if (!chat.PasswordMatches(channel_name, password)) {
  7889. client->Message(CHANNEL_NARRATIVE, "Unable to join '%s': The password is not correc.t", channel_name);
  7890. return;
  7891. }
  7892. }
  7893. if (!chat.JoinChannel(client, channel_name))
  7894. client->Message(CHANNEL_COLOR_RED, "There was an internal error preventing you from joining '%s'.", channel_name);
  7895. }
  7896. void Commands::Command_JoinChannelFromLoad(Client * client, Seperator *sep) {
  7897. printf("ScatDebug: Received 'joinfromchannel', using the same function as 'joinchannel' (not sure what the difference is)\n");
  7898. Command_JoinChannel(client, sep);
  7899. }
  7900. void Commands::Command_TellChannel(Client *client, Seperator *sep) {
  7901. if (sep == NULL || !sep->IsSet(0) || !sep->IsSet(1)) {
  7902. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /tellchannel <channel name> <message>");
  7903. PrintSep(sep, "tellchannel");
  7904. return;
  7905. }
  7906. chat.TellChannel(client, sep->arg[0], sep->argplus[1]);
  7907. }
  7908. void Commands::Command_Test(Client* client, EQ2_16BitString* command_parms) {
  7909. Seperator* sep = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  7910. if (sep->IsSet(0)) {
  7911. if (atoi(sep->arg[0]) == 1) {
  7912. PacketStruct* packet2 = configReader.getStruct("WS_SpellGainedMsg", client->GetVersion());
  7913. if (packet2) {
  7914. packet2->setDataByName("spell_type", 2);
  7915. packet2->setDataByName("spell_id", 8308);
  7916. packet2->setDataByName("spell_name", "Sprint");
  7917. packet2->setDataByName("add_silently", 0);
  7918. packet2->setDataByName("tier", 1);
  7919. packet2->setDataByName("blah1", 1);
  7920. packet2->setDataByName("blah2", 1);
  7921. EQ2Packet* outapp = packet2->serialize();
  7922. DumpPacket(outapp);
  7923. client->QueuePacket(outapp);
  7924. safe_delete(packet2);
  7925. }
  7926. }
  7927. else if (atoi(sep->arg[0]) == 2) {
  7928. PacketStruct* packet2 = configReader.getStruct("WS_GuildUpdate", client->GetVersion());
  7929. if (packet2) {
  7930. packet2->setDataByName("guild_name", "Test");
  7931. packet2->setDataByName("guild_motd", "Test MOTD");
  7932. packet2->setDataByName("guild_id", 1234);
  7933. packet2->setDataByName("guild_level", 1);
  7934. packet2->setDataByName("unknown", 2);
  7935. packet2->setDataByName("unknown2", 3);
  7936. packet2->setDataByName("exp_current", 1);
  7937. packet2->setDataByName("exp_to_next_level", 4);
  7938. EQ2Packet* outapp = packet2->serialize();
  7939. DumpPacket(outapp);
  7940. client->QueuePacket(outapp);
  7941. safe_delete(packet2);
  7942. }
  7943. }
  7944. else if (atoi(sep->arg[0]) == 3) {
  7945. PacketStruct* packet2 = configReader.getStruct("WS_JoinGuildNotify", client->GetVersion());
  7946. if (packet2) {
  7947. packet2->setDataByName("guild_id", 1234);
  7948. packet2->setDataByName("character_id", 1);
  7949. packet2->setDataByName("account_id", 2);
  7950. packet2->setDataByName("guild_level", 1);
  7951. packet2->setDataByName("name", "Test");
  7952. packet2->setDataByName("unknown2", 0);
  7953. packet2->setDataByName("unknown3", 1);
  7954. packet2->setDataByName("adventure_class", 6);
  7955. packet2->setDataByName("adventure_level", 7);
  7956. packet2->setDataByName("tradeskill_class", 4);
  7957. packet2->setDataByName("tradeskill_level", 5);
  7958. packet2->setDataByName("rank", 0);
  7959. packet2->setDataByName("member_flags", 2);
  7960. packet2->setDataByName("join_date", 1591112273);
  7961. packet2->setDataByName("guild_status", 2);
  7962. packet2->setDataByName("last_login", 1591132273);
  7963. packet2->setDataByName("recruiter_id", 1);
  7964. packet2->setDataByName("points", 2345);
  7965. packet2->setDataByName("note", "note");
  7966. packet2->setMediumStringByName("officer_note", "O note");
  7967. packet2->setMediumStringByName("zone", "Blah");
  7968. EQ2Packet* outapp = packet2->serialize();
  7969. DumpPacket(outapp);
  7970. client->QueuePacket(outapp);
  7971. safe_delete(packet2);
  7972. }
  7973. }
  7974. else if (atoi(sep->arg[0]) == 5) {
  7975. int16 offset = atoi(sep->arg[1]);
  7976. int32 value1 = atol(sep->arg[2]);
  7977. EQ2Packet* outapp = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion(), offset, value1);
  7978. client->QueuePacket(outapp);
  7979. }
  7980. else if (atoi(sep->arg[0]) == 6) {
  7981. Spawn* spawn = client->GetPlayer()->GetTarget();
  7982. if (!spawn)
  7983. spawn = client->GetPlayer();
  7984. else if (spawn->IsEntity())
  7985. ((Entity*)spawn)->SetSpeed(atof(sep->arg[4]));
  7986. spawn->RunToLocation(atof(sep->arg[1]), atof(sep->arg[2]), atof(sep->arg[3]));
  7987. }
  7988. else if (atoi(sep->arg[0]) == 7) {
  7989. int32 id = 0;
  7990. Spawn* spawn = client->GetCurrentZone()->GetSpawn(7720001);
  7991. if (spawn) {
  7992. spawn->SetX(client->GetPlayer()->GetX() + .5, false);
  7993. spawn->SetY(client->GetPlayer()->GetY(), false);
  7994. spawn->SetZ(client->GetPlayer()->GetZ() + .5, false);
  7995. float heading = client->GetPlayer()->GetHeading() + 180;
  7996. if (heading > 360)
  7997. heading -= 360;
  7998. spawn->SetLevel(5);
  7999. spawn->SetAdventureClass(4);
  8000. spawn->SetHeading(heading, false);
  8001. spawn->SetSpawnOrigX(spawn->GetX());
  8002. spawn->SetSpawnOrigY(spawn->GetY());
  8003. spawn->SetSpawnOrigZ(spawn->GetZ());
  8004. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  8005. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  8006. spawn->appearance.targetable = 1;
  8007. if (spawn->IsNPC() && spawn->GetTotalHP() == 0) {
  8008. spawn->SetTotalHP(spawn->GetLevel() * 15);
  8009. spawn->SetHP(spawn->GetTotalHP());
  8010. }
  8011. if (spawn->GetTotalPower() == 0) {
  8012. spawn->SetTotalPower(spawn->GetLevel() * 15);
  8013. spawn->SetPower(spawn->GetTotalPower());
  8014. }
  8015. int16 offset = atoi(sep->arg[1]);
  8016. int32 value1 = atol(sep->arg[2]);
  8017. sprintf(spawn->appearance.name, "Offset %i", offset);
  8018. EQ2Packet* ret = spawn->spawn_serialize(client->GetPlayer(), client->GetVersion(), offset, value1);
  8019. DumpPacket(ret);
  8020. client->QueuePacket(ret);
  8021. }
  8022. }
  8023. else if (atoi(sep->arg[0]) == 8) {
  8024. int32 id = atoi(sep->arg[1]);
  8025. Spawn* spawn = client->GetCurrentZone()->GetSpawn(id);
  8026. if (spawn) {
  8027. spawn->SetX(client->GetPlayer()->GetX() + .5, false);
  8028. spawn->SetY(client->GetPlayer()->GetY(), false);
  8029. spawn->SetZ(client->GetPlayer()->GetZ() + .5, false);
  8030. float heading = client->GetPlayer()->GetHeading() + 180;
  8031. if (heading > 360)
  8032. heading -= 360;
  8033. spawn->SetLevel(5);
  8034. spawn->SetAdventureClass(4);
  8035. spawn->SetHeading(heading, false);
  8036. spawn->SetSpawnOrigX(spawn->GetX());
  8037. spawn->SetSpawnOrigY(spawn->GetY());
  8038. spawn->SetSpawnOrigZ(spawn->GetZ());
  8039. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  8040. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  8041. spawn->appearance.targetable = 1;
  8042. if (spawn->IsNPC() && spawn->GetTotalHP() == 0) {
  8043. spawn->SetTotalHP(spawn->GetLevel() * 15);
  8044. spawn->SetHP(spawn->GetTotalHP());
  8045. }
  8046. if (spawn->GetTotalPower() == 0) {
  8047. spawn->SetTotalPower(spawn->GetLevel() * 15);
  8048. spawn->SetPower(spawn->GetTotalPower());
  8049. }
  8050. int16 offset = atoi(sep->arg[2]);
  8051. int16 offset2 = atoi(sep->arg[3]);
  8052. int32 value1 = atol(sep->arg[4]);
  8053. int16 offset3 = 0;
  8054. int16 offset4 = 0;
  8055. int32 value2 = 0;
  8056. if (sep->IsSet(7)) {
  8057. offset3 = atoi(sep->arg[5]);
  8058. offset4 = atoi(sep->arg[6]);
  8059. value2 = atol(sep->arg[7]);
  8060. }
  8061. sprintf(spawn->appearance.name, "Offset %i to %i", offset, offset2);
  8062. spawn->AddPrimaryEntityCommand("attack", 10000, "attack","", 0, 0);
  8063. EQ2Packet* ret = spawn->spawn_serialize(client->GetPlayer(), client->GetVersion(), offset, value1, offset2, offset3, offset4, value2);
  8064. DumpPacket(ret);
  8065. client->QueuePacket(ret);
  8066. }
  8067. }
  8068. else if (atoi(sep->arg[0]) == 9) {
  8069. PacketStruct* packet2 = configReader.getStruct("WS_DeathWindow", client->GetVersion());
  8070. if (packet2) {
  8071. packet2->setArrayLengthByName("location_count", 1);
  8072. packet2->setArrayDataByName("location_ida", 1234);
  8073. packet2->setArrayDataByName("unknown2a", 3);
  8074. packet2->setArrayDataByName("zone_name", "Queen's Colony");
  8075. packet2->setArrayDataByName("location_name", "Myrrin's Tower");
  8076. packet2->setArrayDataByName("distance", 134);
  8077. EQ2Packet* app = packet2->serialize();
  8078. if (sep->IsSet(2)) {
  8079. int8 offset = atoi(sep->arg[1]);
  8080. uchar* ptr2 = app->pBuffer;
  8081. ptr2 += offset;
  8082. if (sep->IsNumber(2)) {
  8083. int32 value1 = atol(sep->arg[2]);
  8084. if (value1 > 0xFFFF)
  8085. memcpy(ptr2, (uchar*)&value1, 4);
  8086. else if (value1 > 0xFF)
  8087. memcpy(ptr2, (uchar*)&value1, 2);
  8088. else
  8089. memcpy(ptr2, (uchar*)&value1, 1);
  8090. }
  8091. else {
  8092. int8 len = strlen(sep->arg[2]);
  8093. memcpy(ptr2, (uchar*)&len, 1);
  8094. ptr2 += 1;
  8095. memcpy(ptr2, sep->arg[2], len);
  8096. }
  8097. }
  8098. DumpPacket(app);
  8099. client->QueuePacket(app);
  8100. safe_delete(packet2);
  8101. }
  8102. }
  8103. else if (atoi(sep->arg[0]) == 10) {
  8104. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalUpdate", client->GetVersion());
  8105. if (packet2) {
  8106. packet2->setArrayLengthByName("num_quests", 1);
  8107. packet2->setArrayDataByName("active", 1);
  8108. packet2->setArrayDataByName("name", "Tasks aboard the Far Journey");
  8109. packet2->setArrayDataByName("quest_type", "Hallmark");
  8110. packet2->setArrayDataByName("quest_zone", "Hallmark");
  8111. packet2->setArrayDataByName("journal_updated", 1);
  8112. packet2->setArrayDataByName("quest_id", 524);
  8113. packet2->setArrayDataByName("day", 19);
  8114. packet2->setArrayDataByName("month", 6);
  8115. packet2->setArrayDataByName("year", 20);
  8116. packet2->setArrayDataByName("level", 2);
  8117. packet2->setArrayDataByName("encounter_level", 4);
  8118. packet2->setArrayDataByName("difficulty", 3);
  8119. packet2->setArrayDataByName("visible", 1);
  8120. packet2->setDataByName("visible_quest_id", 524);
  8121. packet2->setDataByName("player_crc", 2900677088);
  8122. packet2->setDataByName("player_name", "LethalEncounter");
  8123. EQ2Packet* app = packet2->serialize();
  8124. if (sep->IsSet(2)) {
  8125. int8 offset = atoi(sep->arg[1]);
  8126. uchar* ptr2 = app->pBuffer;
  8127. ptr2 += offset;
  8128. if (sep->IsNumber(2)) {
  8129. int32 value1 = atol(sep->arg[2]);
  8130. if (value1 > 0xFFFF)
  8131. memcpy(ptr2, (uchar*)&value1, 4);
  8132. else if (value1 > 0xFF)
  8133. memcpy(ptr2, (uchar*)&value1, 2);
  8134. else
  8135. memcpy(ptr2, (uchar*)&value1, 1);
  8136. }
  8137. else {
  8138. int8 len = strlen(sep->arg[2]);
  8139. memcpy(ptr2, (uchar*)&len, 1);
  8140. ptr2 += 1;
  8141. memcpy(ptr2, sep->arg[2], len);
  8142. }
  8143. }
  8144. DumpPacket(app);
  8145. client->QueuePacket(app);
  8146. safe_delete(packet2);
  8147. }
  8148. }
  8149. else if (atoi(sep->arg[0]) == 11) {
  8150. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalReply", client->GetVersion());
  8151. if (packet2) {
  8152. packet2->setDataByName("quest_id", 524);
  8153. packet2->setDataByName("player_crc", 2900677088);
  8154. packet2->setDataByName("name", "Tasks aboard the Far Journey");
  8155. packet2->setDataByName("description", "I completed all the tasks assigned to me by Captain Varlos aboard the Far Journey");
  8156. packet2->setDataByName("type", "Hallmark");
  8157. packet2->setDataByName("complete_header", "To complete this quest, I must do the following tasks:");
  8158. packet2->setDataByName("day", 19);
  8159. packet2->setDataByName("month", 6);
  8160. packet2->setDataByName("year", 20);
  8161. packet2->setDataByName("level", 1);
  8162. packet2->setDataByName("encounter_level", 1);
  8163. packet2->setDataByName("difficulty", 1);
  8164. packet2->setDataByName("time_obtained", Timer::GetUnixTimeStamp());
  8165. //packet2->setDataByName("timer_start", Timer::GetUnixTimeStamp());
  8166. //packet2->setDataByName("timer_duration", 300);
  8167. //packet2->setDataByName("timer_running", 1);
  8168. packet2->setArrayLengthByName("task_groups_completed", 9);
  8169. packet2->setArrayLengthByName("num_task_groups", 10);
  8170. packet2->setArrayDataByName("task_group", "I spoke to Waulon as Captain Varlos had asked of me.");
  8171. packet2->setArrayDataByName("task_group", "I found Waulon's hat in one of the boxes.", 1);
  8172. packet2->setArrayDataByName("task_group", "I returned Waulon's hat.", 2);
  8173. packet2->setArrayDataByName("task_group", "I have spoken to Ingrid.", 3);
  8174. packet2->setArrayDataByName("task_group", "I purchased a Shard of Luclin.", 4);
  8175. packet2->setArrayDataByName("task_group", "I gave the Shard of Luclin to Ingrid.", 5);
  8176. packet2->setArrayDataByName("task_group", "I have spoken to Captain Varlos.", 6);
  8177. packet2->setArrayDataByName("task_group", "I killed the rats that Captain Varlos requested.", 7);
  8178. packet2->setArrayDataByName("task_group", "Captain Varlos has ordered you to kill the escaped goblin.", 8);
  8179. packet2->setArrayDataByName("task_group", "I killed the escaped goblin.", 9);
  8180. /*packet2->setSubArrayLengthByName("num_tasks", 1);
  8181. packet2->setSubArrayDataByName("task", "I need to talk to Garven Tralk");
  8182. packet2->setSubArrayLengthByName("num_updates", 1);
  8183. packet2->setSubArrayDataByName("update_currentval", 0);
  8184. packet2->setSubArrayDataByName("update_maxval", 1);
  8185. packet2->setSubArrayDataByName("icon", 11);
  8186. */
  8187. packet2->setArrayDataByName("waypoint", 0xFFFFFFFF);
  8188. packet2->setDataByName("journal_updated", 1);
  8189. packet2->setDataByName("bullets", 1);
  8190. EQ2Packet* app = packet2->serialize();
  8191. if (sep->IsSet(2)) {
  8192. int16 offset = atoi(sep->arg[1]);
  8193. uchar* ptr2 = app->pBuffer;
  8194. ptr2 += offset;
  8195. if (sep->IsNumber(2)) {
  8196. int32 value1 = atol(sep->arg[2]);
  8197. if (value1 > 0xFFFF)
  8198. memcpy(ptr2, (uchar*)&value1, 4);
  8199. else if (value1 > 0xFF)
  8200. memcpy(ptr2, (uchar*)&value1, 2);
  8201. else
  8202. memcpy(ptr2, (uchar*)&value1, 1);
  8203. }
  8204. else {
  8205. int16 len = strlen(sep->arg[2]);
  8206. memcpy(ptr2, (uchar*)&len, 2);
  8207. ptr2 += 2;
  8208. memcpy(ptr2, sep->arg[2], len);
  8209. }
  8210. }
  8211. DumpPacket(app);
  8212. client->QueuePacket(app);
  8213. safe_delete(packet2);
  8214. }
  8215. }
  8216. else if (atoi(sep->arg[0]) == 12) {
  8217. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalReply", client->GetVersion());
  8218. if (packet2) {
  8219. packet2->setDataByName("quest_id", 524);
  8220. packet2->setDataByName("player_crc", 2900677088);
  8221. packet2->setDataByName("name", "Archetype Selection");
  8222. packet2->setDataByName("description", "I have reported my profession to Garven Tralk.");
  8223. packet2->setDataByName("type", "Hallmark");
  8224. packet2->setDataByName("complete_header", "To complete this quest, I must do the following tasks:");
  8225. packet2->setDataByName("day", 19);
  8226. packet2->setDataByName("month", 6);
  8227. packet2->setDataByName("year", 20);
  8228. packet2->setDataByName("level", 2);
  8229. packet2->setDataByName("encounter_level", 4);
  8230. packet2->setDataByName("difficulty", 3);
  8231. packet2->setDataByName("time_obtained", Timer::GetUnixTimeStamp());
  8232. packet2->setDataByName("timer_start", Timer::GetUnixTimeStamp());
  8233. packet2->setDataByName("timer_duration", 300);
  8234. packet2->setDataByName("timer_running", 1);
  8235. packet2->setArrayLengthByName("task_groups_completed", 0);
  8236. packet2->setArrayLengthByName("num_task_groups", 1);
  8237. packet2->setArrayDataByName("task_group", "I need to talk to Garven Tralk");
  8238. packet2->setSubArrayLengthByName("num_tasks", 1);
  8239. packet2->setSubArrayDataByName("task", "I need to talk to Garven Tralk");
  8240. packet2->setSubArrayLengthByName("num_updates", 1);
  8241. packet2->setSubArrayDataByName("update_currentval", 0);
  8242. packet2->setSubArrayDataByName("update_maxval", 1);
  8243. packet2->setSubArrayDataByName("icon", 11);
  8244. packet2->setArrayDataByName("waypoint", 0xFFFFFFFF);
  8245. packet2->setDataByName("journal_updated", 1);
  8246. packet2->setSubstructDataByName("reward_data", "unknown1", 255);
  8247. packet2->setSubstructDataByName("reward_data", "reward", "Quest Reward!");
  8248. packet2->setSubstructDataByName("reward_data", "unknown2", 0x3f);
  8249. packet2->setSubstructDataByName("reward_data", "coin", 150);
  8250. packet2->setSubstructDataByName("reward_data", "status_points", 5);
  8251. packet2->setSubstructDataByName("reward_data", "exp_bonus", 10);
  8252. packet2->setSubstructArrayLengthByName("reward_data", "num_rewards", 1);
  8253. packet2->setSubstructArrayDataByName("reward_data", "reward_id", 123);
  8254. Item* item = master_item_list.GetItem(152755);
  8255. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8256. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  8257. /*packet2->setSubstructDataByName("item", "unique_id", 567);
  8258. packet2->setSubstructDataByName("item", "broker_item_id", 0xFFFFFFFFFFFFFFFF);
  8259. packet2->setSubstructDataByName("item", "icon", 0xe7);
  8260. packet2->setSubstructDataByName("item", "tier", 4);
  8261. packet2->setSubstructDataByName("item", "flags", 0x60);
  8262. packet2->setSubstructArrayLengthByName("item", "stat_count", 1);
  8263. packet2->setSubstructDataByName("item", "stat_type", 1);
  8264. packet2->setSubstructDataByName("item", "stat_subtype", 2);
  8265. packet2->setSubstructDataByName("item", "value", 3);
  8266. packet2->setSubstructDataByName("item", "condition", 100);
  8267. packet2->setSubstructDataByName("item", "weight", 1);
  8268. packet2->setSubstructDataByName("item", "skill_req1", 0xacafa99e);
  8269. packet2->setSubstructDataByName("item", "skill_req2", 0xacafa99e);
  8270. packet2->setSubstructDataByName("item", "skill_min", 1);
  8271. packet2->setSubstructArrayLengthByName("item", "class_count", 3);
  8272. packet2->setSubstructDataByName("item", "adventure_class", 1);
  8273. packet2->setSubstructDataByName("item", "adventure_class", 11, 0, 1);
  8274. packet2->setSubstructDataByName("item", "adventure_class", 0x1f, 0, 2);
  8275. packet2->setSubstructDataByName("item", "tradeskill_class", 255);
  8276. packet2->setSubstructDataByName("item", "tradeskill_class", 255, 0, 1);
  8277. packet2->setSubstructDataByName("item", "tradeskill_class", 255, 0, 2);
  8278. packet2->setSubstructDataByName("item", "level", 0x1e);
  8279. packet2->setSubstructDataByName("item", "level", 100, 0, 1);
  8280. packet2->setSubstructDataByName("item", "level", 100, 0, 2);
  8281. packet2->setSubstructDataByName("item_footer", "name", "Footman Gloves");*/
  8282. //packet2->PrintPacket();
  8283. EQ2Packet* app = packet2->serialize();
  8284. if (sep->IsSet(2)) {
  8285. int16 offset = atoi(sep->arg[1]);
  8286. uchar* ptr2 = app->pBuffer;
  8287. ptr2 += offset;
  8288. if (sep->IsNumber(2)) {
  8289. int32 value1 = atol(sep->arg[2]);
  8290. if (value1 > 0xFFFF)
  8291. memcpy(ptr2, (uchar*)&value1, 4);
  8292. else if (value1 > 0xFF)
  8293. memcpy(ptr2, (uchar*)&value1, 2);
  8294. else
  8295. memcpy(ptr2, (uchar*)&value1, 1);
  8296. }
  8297. else {
  8298. int16 len = strlen(sep->arg[2]);
  8299. memcpy(ptr2, (uchar*)&len, 2);
  8300. ptr2 += 2;
  8301. memcpy(ptr2, sep->arg[2], len);
  8302. }
  8303. }
  8304. DumpPacket(app);
  8305. client->QueuePacket(app);
  8306. safe_delete(packet2);
  8307. }
  8308. }
  8309. else if (atoi(sep->arg[0]) == 13) {
  8310. PacketStruct* packet2 = configReader.getStruct("WS_OnScreenMsg", client->GetVersion());
  8311. if (packet2 && sep->IsSet(7)) {
  8312. packet2->setDataByName("unknown", atoi(sep->arg[1]));
  8313. char blah[128];
  8314. sprintf(blah, "\\#6EFF6EYou get better at \12\\#C8FFC8%s\\#6EFF6E! (7/15)", sep->arg[2]);
  8315. packet2->setDataByName("text", blah);
  8316. packet2->setDataByName("message_type", sep->arg[3]);
  8317. packet2->setDataByName("size", atof(sep->arg[4]));
  8318. packet2->setDataByName("red", atoi(sep->arg[5]));
  8319. packet2->setDataByName("green", atoi(sep->arg[6]));
  8320. packet2->setDataByName("blue", atoi(sep->arg[7]));
  8321. EQ2Packet* app = packet2->serialize();
  8322. DumpPacket(app);
  8323. client->QueuePacket(app);
  8324. safe_delete(packet2);
  8325. }
  8326. }
  8327. else if (atoi(sep->arg[0]) == 14) {
  8328. PacketStruct* packet2 = configReader.getStruct("WS_InstructionWindow", client->GetVersion());
  8329. if (packet2 && sep->IsSet(3)) {
  8330. packet2->setDataByName("open_seconds_min", atof(sep->arg[1]));
  8331. packet2->setDataByName("open_seconds_max", atof(sep->arg[2]));
  8332. packet2->setDataByName("voice_sync", atoi(sep->arg[3]));
  8333. 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.");
  8334. packet2->setDataByName("voice", "voiceover/english/narrator/boat_06p_tutorial02/narrator_001_63779ca0.mp3");
  8335. packet2->setArrayLengthByName("num_goals", 1);
  8336. //packet2->setArrayDataByName("goal_text", )
  8337. packet2->setSubArrayLengthByName("num_tasks", 1);
  8338. packet2->setSubArrayDataByName("task_text", "continue");
  8339. packet2->setDataByName("complete_sound", "click");
  8340. packet2->setDataByName("signal", "introduction");
  8341. packet2->setDataByName("voice_key1", 0xcda65173);
  8342. packet2->setDataByName("voice_key2", 0x984bfc6d);
  8343. EQ2Packet* app = packet2->serialize();
  8344. DumpPacket(app);
  8345. client->QueuePacket(app);
  8346. safe_delete(packet2);
  8347. packet2 = configReader.getStruct("WS_ShowWindow", client->GetVersion());
  8348. packet2->setDataByName("window", "MainHUD.StartMenu");
  8349. packet2->setDataByName("show", 1);
  8350. app = packet2->serialize();
  8351. DumpPacket(app);
  8352. client->QueuePacket(app);
  8353. safe_delete(packet2);
  8354. packet2 = configReader.getStruct("WS_FlashWindow", client->GetVersion());
  8355. packet2->setDataByName("window", "MainHUD.StartMenu.help");
  8356. packet2->setDataByName("flash_seconds", 10);
  8357. app = packet2->serialize();
  8358. DumpPacket(app);
  8359. client->QueuePacket(app);
  8360. safe_delete(packet2);
  8361. }
  8362. }
  8363. else if (atoi(sep->arg[0]) == 15) {
  8364. PacketStruct* packet2 = configReader.getStruct("WS_UpdateLoot", client->GetVersion());
  8365. if (packet2) {
  8366. packet2->setArrayLengthByName("loot_count", 1);
  8367. packet2->setArrayDataByName("name", "Test");
  8368. packet2->setArrayDataByName("item_id", 1234);
  8369. packet2->setArrayDataByName("count", 1);
  8370. packet2->setArrayDataByName("icon", 258);
  8371. packet2->setArrayDataByName("ability_id", 0xFFFFFFFF);
  8372. Spawn* spawn = client->GetPlayer()->GetTarget();
  8373. if (spawn)
  8374. packet2->setDataByName("object_id", client->GetPlayer()->GetIDWithPlayerSpawn(spawn));
  8375. packet2->setDataByName("unknown3", 1);
  8376. packet2->setDataByName("unknown4", 1);
  8377. packet2->setDataByName("unknown5", 60);
  8378. EQ2Packet* app = packet2->serialize();
  8379. DumpPacket(app);
  8380. client->QueuePacket(app);
  8381. safe_delete(packet2);
  8382. }
  8383. }
  8384. else if (atoi(sep->arg[0]) == 16 && sep->IsNumber(1)) {
  8385. char blah[32];
  8386. sprintf(blah, "Testing: %i", atoi(sep->arg[1]));
  8387. client->SimpleMessage(atoi(sep->arg[1]), blah);
  8388. }
  8389. else if (atoi(sep->arg[0]) == 17 && sep->IsNumber(2)) {
  8390. if (sep->IsSet(2)) {
  8391. int16 offset = atoi(sep->arg[1]);
  8392. if (sep->IsNumber(2)) {
  8393. int32 value1 = atol(sep->arg[2]);
  8394. client->QueuePacket(client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion(), offset, value1));
  8395. cout << "Sent" << endl;
  8396. }
  8397. }
  8398. }
  8399. else if (atoi(sep->arg[0]) == 18) {
  8400. PacketStruct* packet2 = configReader.getStruct("WS_QuestRewardPackMsg", client->GetVersion());
  8401. if (packet2) {
  8402. packet2->setSubstructDataByName("reward_data", "unknown1", 255);
  8403. packet2->setSubstructDataByName("reward_data", "reward", "Quest Reward!");
  8404. packet2->setSubstructDataByName("reward_data", "coin", 150);
  8405. packet2->setSubstructDataByName("reward_data", "status_points", 5);
  8406. packet2->setSubstructDataByName("reward_data", "exp_bonus", 10);
  8407. packet2->setSubstructArrayLengthByName("reward_data", "num_rewards", 4);
  8408. Item* item = new Item(master_item_list.GetItem(36212));
  8409. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8410. item->stack_count = 20;
  8411. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  8412. safe_delete(item);
  8413. item = new Item(master_item_list.GetItem(36685));
  8414. item->stack_count = 20;
  8415. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8416. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 1, 0, -1);
  8417. safe_delete(item);
  8418. item = master_item_list.GetItem(1414);
  8419. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8420. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 2, 0, -1);
  8421. item = master_item_list.GetItem(75057);
  8422. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8423. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 3, 0, -1);
  8424. EQ2Packet* app = packet2->serialize();
  8425. if (sep->IsSet(2)) {
  8426. int16 offset = atoi(sep->arg[1]);
  8427. uchar* ptr2 = app->pBuffer;
  8428. ptr2 += offset;
  8429. if (sep->IsNumber(2)) {
  8430. int32 value1 = atol(sep->arg[2]);
  8431. if (value1 > 0xFFFF)
  8432. memcpy(ptr2, (uchar*)&value1, 4);
  8433. else if (value1 > 0xFF)
  8434. memcpy(ptr2, (uchar*)&value1, 2);
  8435. else
  8436. memcpy(ptr2, (uchar*)&value1, 1);
  8437. }
  8438. else {
  8439. int16 len = strlen(sep->arg[2]);
  8440. memcpy(ptr2, (uchar*)&len, 2);
  8441. ptr2 += 2;
  8442. memcpy(ptr2, sep->arg[2], len);
  8443. }
  8444. }
  8445. DumpPacket(app);
  8446. client->QueuePacket(app);
  8447. safe_delete(packet2);
  8448. }
  8449. }
  8450. else if (atoi(sep->arg[0]) == 19) {
  8451. PacketStruct* packet2 = configReader.getStruct("WS_UpdateLoot", client->GetVersion());
  8452. Spawn* spawn = client->GetPlayer()->GetTarget();
  8453. if (packet2 && spawn) {
  8454. Item* item = master_item_list.GetItem(130053);
  8455. packet2->setArrayLengthByName("loot_count", 1);
  8456. packet2->setArrayDataByName("loot_id", item->details.item_id);
  8457. packet2->setArrayDataByName("unknown2", 1);
  8458. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, 2, true);
  8459. packet2->setDataByName("display", 1);
  8460. packet2->setDataByName("unknown2b", 1);
  8461. packet2->setDataByName("unknown3", 0x3c);
  8462. packet2->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(spawn));
  8463. packet2->PrintPacket();
  8464. EQ2Packet* app = packet2->serialize();
  8465. if (sep->IsSet(2)) {
  8466. int16 offset = atoi(sep->arg[1]);
  8467. int16 offset2 = 0;
  8468. int32 value1 = 0;
  8469. if (sep->IsSet(3)) {
  8470. offset2 = atoi(sep->arg[2]);
  8471. value1 = atol(sep->arg[3]);
  8472. }
  8473. else
  8474. value1 = atol(sep->arg[2]);
  8475. int16 offset3 = 0;
  8476. int16 offset4 = 0;
  8477. int32 value2 = 0;
  8478. if (sep->IsSet(6)) {
  8479. offset3 = atoi(sep->arg[4]);
  8480. offset4 = atoi(sep->arg[5]);
  8481. value2 = atol(sep->arg[6]);
  8482. }
  8483. offset--;
  8484. if (offset2 > 0 && offset2 >= offset) {
  8485. offset2--;
  8486. uchar* ptr2 = app->pBuffer;
  8487. ptr2 += offset;
  8488. for (int i = offset; i <= offset2; i++) {
  8489. if (value1 > 0xFFFF) {
  8490. memcpy(ptr2, (uchar*)&value1, 4);
  8491. i += 3;
  8492. ptr2 += 3;
  8493. }
  8494. else if (value1 > 0xFF) {
  8495. memcpy(ptr2, (uchar*)&value1, 2);
  8496. i++;
  8497. ptr2++;
  8498. }
  8499. else
  8500. memcpy(ptr2, (uchar*)&value1, 1);
  8501. ptr2++;
  8502. }
  8503. }
  8504. if (offset4 > 0 && offset4 >= offset3) {
  8505. offset3--;
  8506. offset4--;
  8507. uchar* ptr2 = app->pBuffer;
  8508. ptr2 += offset3;
  8509. for (int i = offset3; i <= offset4; i++) {
  8510. if (value2 > 0xFFFF) {
  8511. memcpy(ptr2, (uchar*)&value2, 4);
  8512. i += 3;
  8513. ptr2 += 3;
  8514. }
  8515. else if (value2 > 0xFF) {
  8516. memcpy(ptr2, (uchar*)&value2, 2);
  8517. i++;
  8518. ptr2++;
  8519. }
  8520. else
  8521. memcpy(ptr2, (uchar*)&value2, 1);
  8522. ptr2++;
  8523. }
  8524. }
  8525. }
  8526. DumpPacket(app);
  8527. client->QueuePacket(app);
  8528. safe_delete(packet2);
  8529. }
  8530. }
  8531. else if (atoi(sep->arg[0]) == 21) {
  8532. PacketStruct* packet2 = configReader.getStruct("WS_OfferQuest", client->GetVersion());
  8533. if (packet2) {
  8534. packet2->setDataByName("unknown0", 255);
  8535. packet2->setDataByName("reward", "New Quest");
  8536. packet2->setDataByName("title", "Title");
  8537. packet2->setDataByName("description", "description");
  8538. packet2->setDataByName("quest_difficulty", 3);
  8539. packet2->setDataByName("unknown1", 5);
  8540. packet2->setDataByName("level", 3);
  8541. packet2->setDataByName("coin", 150);
  8542. packet2->setDataByName("status_points", 5);
  8543. packet2->setDataByName("exp_bonus", 10);
  8544. packet2->setArrayLengthByName("num_rewards", 1);
  8545. Item* item = new Item(master_item_list.GetItem(36212));
  8546. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8547. item->stack_count = 20;
  8548. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  8549. safe_delete(item);
  8550. char accept[35] = { 0 };
  8551. char decline[35] = { 0 };
  8552. sprintf(accept, "q_accept_pending_quest %u", 0);
  8553. sprintf(decline, "q_deny_pending_quest %u", 0);
  8554. packet2->setDataByName("accept_command", accept);
  8555. packet2->setDataByName("decline_command", decline);
  8556. EQ2Packet* app = packet2->serialize();
  8557. if (sep->IsSet(2)) {
  8558. int16 offset = atoi(sep->arg[1]);
  8559. uchar* ptr2 = app->pBuffer;
  8560. ptr2 += offset;
  8561. if (sep->IsNumber(2)) {
  8562. int32 value1 = atol(sep->arg[2]);
  8563. if (value1 > 0xFFFF)
  8564. memcpy(ptr2, (uchar*)&value1, 4);
  8565. else if (value1 > 0xFF)
  8566. memcpy(ptr2, (uchar*)&value1, 2);
  8567. else
  8568. memcpy(ptr2, (uchar*)&value1, 1);
  8569. }
  8570. DumpPacket(app);
  8571. client->QueuePacket(app);
  8572. safe_delete(packet2);
  8573. }
  8574. }
  8575. }
  8576. else if (atoi(sep->arg[0]) == 22) { //same as 21, but 8bit string
  8577. PacketStruct* packet2 = configReader.getStruct("WS_OfferQuest", client->GetVersion());
  8578. if (packet2) {
  8579. packet2->setDataByName("unknown0", 255);
  8580. packet2->setDataByName("reward", "New Quest");
  8581. packet2->setDataByName("title", "Title");
  8582. packet2->setDataByName("description", "description");
  8583. packet2->setDataByName("quest_difficulty", 3);
  8584. packet2->setDataByName("unknown1", 5);
  8585. packet2->setDataByName("level", 3);
  8586. packet2->setDataByName("coin", 150);
  8587. packet2->setDataByName("status_points", 5);
  8588. packet2->setDataByName("exp_bonus", 10);
  8589. packet2->setArrayLengthByName("num_rewards", 1);
  8590. Item* item = new Item(master_item_list.GetItem(36212));
  8591. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8592. item->stack_count = 20;
  8593. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  8594. safe_delete(item);
  8595. char accept[35] = { 0 };
  8596. char decline[35] = { 0 };
  8597. sprintf(accept, "q_accept_pending_quest %u", 0);
  8598. sprintf(decline, "q_deny_pending_quest %u", 0);
  8599. packet2->setDataByName("accept_command", accept);
  8600. packet2->setDataByName("decline_command", decline);
  8601. EQ2Packet* app = packet2->serialize();
  8602. if (sep->IsSet(2)) {
  8603. int16 offset = atoi(sep->arg[1]);
  8604. uchar* ptr2 = app->pBuffer;
  8605. ptr2 += offset;
  8606. if (sep->IsNumber(2)) {
  8607. int32 value1 = atol(sep->arg[2]);
  8608. if (value1 > 0xFFFF)
  8609. memcpy(ptr2, (uchar*)&value1, 4);
  8610. else if (value1 > 0xFF)
  8611. memcpy(ptr2, (uchar*)&value1, 2);
  8612. else
  8613. memcpy(ptr2, (uchar*)&value1, 1);
  8614. }
  8615. else {
  8616. int8 len = strlen(sep->arg[2]);
  8617. memcpy(ptr2, (uchar*)&len, 1);
  8618. ptr2 += 1;
  8619. memcpy(ptr2, sep->arg[2], len);
  8620. }
  8621. }
  8622. DumpPacket(app);
  8623. client->QueuePacket(app);
  8624. safe_delete(packet2);
  8625. }
  8626. }
  8627. else if (atoi(sep->arg[0]) == 23) {
  8628. if (client->GetPlayer()->GetTarget()) {
  8629. PacketStruct* packet2 = configReader.getStruct("WS_UpdateMerchant", client->GetVersion());
  8630. if (packet2) {
  8631. Spawn* target = client->GetPlayer()->GetTarget();
  8632. packet2->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(target));
  8633. Item* item = new Item(master_item_list.GetItem(12565));
  8634. int8 i = 0;
  8635. packet2->setArrayLengthByName("num_items", 1);
  8636. packet2->setArrayDataByName("item_name", item->name.c_str(), i);
  8637. packet2->setArrayDataByName("item_id", item->details.item_id, i);
  8638. packet2->setArrayDataByName("stack_size", item->stack_count, i);
  8639. packet2->setArrayDataByName("icon", item->details.icon, i);
  8640. int8 tmp_level = 0;
  8641. if (item->generic_info.adventure_default_level > 0)
  8642. tmp_level = item->generic_info.adventure_default_level;
  8643. else
  8644. tmp_level = item->generic_info.tradeskill_default_level;
  8645. packet2->setArrayDataByName("level", tmp_level, i);
  8646. packet2->setArrayDataByName("tier", item->details.tier, i);
  8647. packet2->setArrayDataByName("item_id2", item->details.item_id, i);
  8648. int8 item_difficulty = client->GetPlayer()->GetArrowColor(tmp_level);
  8649. if (item_difficulty != ARROW_COLOR_WHITE && item_difficulty != ARROW_COLOR_RED && item_difficulty != ARROW_COLOR_GRAY)
  8650. item_difficulty = ARROW_COLOR_WHITE;
  8651. item_difficulty -= 6;
  8652. if (item_difficulty < 0)
  8653. item_difficulty *= -1;
  8654. packet2->setArrayDataByName("item_difficulty", item_difficulty, i);
  8655. packet2->setArrayDataByName("quantity", 2, i);
  8656. packet2->setArrayDataByName("unknown5", 255, i);
  8657. packet2->setArrayDataByName("stack_size2", item->stack_count, i);
  8658. packet2->setArrayDataByName("description", item->description.c_str(), i);
  8659. packet2->setDataByName("type", 2);
  8660. EQ2Packet* app = packet2->serialize();
  8661. if (sep->IsSet(2)) {
  8662. int16 offset = atoi(sep->arg[1]);
  8663. uchar* ptr2 = app->pBuffer;
  8664. ptr2 += offset;
  8665. if (sep->IsNumber(2)) {
  8666. int32 value1 = atol(sep->arg[2]);
  8667. if (value1 > 0xFFFF)
  8668. memcpy(ptr2, (uchar*)&value1, 4);
  8669. else if (value1 > 0xFF)
  8670. memcpy(ptr2, (uchar*)&value1, 2);
  8671. else
  8672. memcpy(ptr2, (uchar*)&value1, 1);
  8673. }
  8674. else {
  8675. int8 len = strlen(sep->arg[2]);
  8676. memcpy(ptr2, (uchar*)&len, 1);
  8677. ptr2 += 1;
  8678. memcpy(ptr2, sep->arg[2], len);
  8679. }
  8680. }
  8681. DumpPacket(app);
  8682. client->QueuePacket(app);
  8683. safe_delete(packet2);
  8684. }
  8685. }
  8686. }
  8687. else if (atoi(sep->arg[0]) == 24) {
  8688. PacketStruct* packet2 = configReader.getStruct("WS_EnableGameEvent", client->GetVersion());
  8689. if (packet2) {
  8690. if (sep->IsSet(2)) {
  8691. packet2->setDataByName("event_name", sep->arg[1]);
  8692. packet2->setDataByName("enabled", atoi(sep->arg[2]));
  8693. EQ2Packet* app = packet2->serialize();
  8694. DumpPacket(app);
  8695. client->QueuePacket(app);
  8696. safe_delete(packet2);
  8697. }
  8698. }
  8699. }
  8700. else if (atoi(sep->arg[0]) == 25) {
  8701. if (sep->IsSet(1)) {
  8702. Widget* new_spawn = new Widget();
  8703. int32 id = atoul(sep->arg[1]);
  8704. new_spawn->SetWidgetID(id);
  8705. EQ2Packet* ret = new_spawn->serialize(client->GetPlayer(), client->GetVersion());
  8706. client->QueuePacket(ret);
  8707. int8 index = client->GetPlayer()->GetIndexForSpawn(new_spawn);
  8708. PacketStruct* packet2 = configReader.getStruct("WS_DestroyGhostCmd", client->GetVersion());
  8709. if (packet2) {
  8710. packet2->setDataByName("spawn_index", index);
  8711. packet2->setDataByName("delete", 1);
  8712. EQ2Packet* app = packet2->serialize();
  8713. client->QueuePacket(app);
  8714. safe_delete(packet2);
  8715. }
  8716. }
  8717. }
  8718. else if (atoi(sep->arg[0]) == 26) {
  8719. if (sep->IsSet(4)) {
  8720. Widget* new_spawn = new Widget();
  8721. int32 id = atoul(sep->arg[1]);
  8722. new_spawn->SetWidgetID(id);
  8723. float x = atof(sep->arg[2]);
  8724. float y = atof(sep->arg[3]);
  8725. float z = atof(sep->arg[4]);
  8726. new_spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  8727. new_spawn->SetWidgetX(x);
  8728. new_spawn->SetWidgetY(y);
  8729. new_spawn->SetWidgetZ(z);
  8730. new_spawn->SetX(x);
  8731. new_spawn->SetY(y);
  8732. new_spawn->SetZ(z);
  8733. EQ2Packet* ret = new_spawn->serialize(client->GetPlayer(), client->GetVersion());
  8734. client->QueuePacket(ret);
  8735. }
  8736. }
  8737. else if (atoi(sep->arg[0]) == 27) {
  8738. Spawn* target = client->GetPlayer()->GetTarget();
  8739. PacketStruct* packet2 = configReader.getStruct("WS_HearSimpleDamage", client->GetVersion());
  8740. if (packet2 && target && sep->IsSet(2)) {
  8741. packet2->setSubstructDataByName("header", "defender", client->GetPlayer()->GetIDWithPlayerSpawn(target));
  8742. packet2->setSubstructDataByName("header", "defender_proxy", client->GetPlayer()->GetIDWithPlayerSpawn(target));
  8743. packet2->setSubstructDataByName("header", "attacker", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  8744. packet2->setArrayLengthByName("num_dmg", 1);
  8745. packet2->setArrayDataByName("damage_type", atoi(sep->arg[1]));
  8746. packet2->setArrayDataByName("damage", atoi(sep->arg[2]));
  8747. packet2->setDataByName("spell", 1);
  8748. packet2->setDataByName("spell_name", "Testing");
  8749. EQ2Packet* app = packet2->serialize();
  8750. if (sep->IsSet(4)) {
  8751. int16 offset = atoi(sep->arg[3]);
  8752. uchar* ptr2 = app->pBuffer;
  8753. ptr2 += offset;
  8754. if (sep->IsNumber(4)) {
  8755. int32 value1 = atol(sep->arg[4]);
  8756. if (value1 > 0xFFFF)
  8757. memcpy(ptr2, (uchar*)&value1, 4);
  8758. else if (value1 > 0xFF)
  8759. memcpy(ptr2, (uchar*)&value1, 2);
  8760. else
  8761. memcpy(ptr2, (uchar*)&value1, 1);
  8762. }
  8763. else {
  8764. int8 len = strlen(sep->arg[4]);
  8765. memcpy(ptr2, (uchar*)&len, 1);
  8766. ptr2 += 1;
  8767. memcpy(ptr2, sep->arg[4], len);
  8768. }
  8769. }
  8770. if (sep->IsSet(6)) {
  8771. int16 offset = atoi(sep->arg[5]);
  8772. uchar* ptr2 = app->pBuffer;
  8773. ptr2 += offset;
  8774. if (sep->IsNumber(6)) {
  8775. int32 value1 = atol(sep->arg[6]);
  8776. if (value1 > 0xFFFF)
  8777. memcpy(ptr2, (uchar*)&value1, 4);
  8778. else if (value1 > 0xFF)
  8779. memcpy(ptr2, (uchar*)&value1, 2);
  8780. else
  8781. memcpy(ptr2, (uchar*)&value1, 1);
  8782. }
  8783. else {
  8784. int8 len = strlen(sep->arg[6]);
  8785. memcpy(ptr2, (uchar*)&len, 1);
  8786. ptr2 += 1;
  8787. memcpy(ptr2, sep->arg[6], len);
  8788. }
  8789. }
  8790. DumpPacket(app);
  8791. client->QueuePacket(app);
  8792. safe_delete(packet2);
  8793. }
  8794. }
  8795. }
  8796. else {
  8797. PacketStruct* packet2 = configReader.getStruct("WS_ExamineSpellInfo", client->GetVersion());
  8798. if (packet2) {
  8799. packet2->setSubstructDataByName("info_header", "show_name", 1);
  8800. packet2->setSubstructDataByName("info_header", "unknown", 7);
  8801. packet2->setSubstructDataByName("info_header", "unknown2", 1);
  8802. packet2->setSubstructDataByName("info_header", "unknown3", 1);
  8803. packet2->setSubstructDataByName("info_header", "unknown4", 1);
  8804. packet2->setSubstructDataByName("info_header", "unknown5", 1);
  8805. packet2->setSubstructDataByName("info_header", "unknown6", "Testing");
  8806. packet2->setSubstructDataByName("info_header", "unknown7", "Testing");
  8807. packet2->setSubstructDataByName("info_header", "unknown8", 66);
  8808. packet2->setSubstructDataByName("info_header", "title", "Blah Title Blah");
  8809. packet2->setSubstructDataByName("info_header", "title_text", "Blah Blah");
  8810. packet2->setSubstructDataByName("info_header", "title_text2", "Blah Blah2");
  8811. packet2->setSubstructDataByName("info_header", "show_popup", 1);
  8812. packet2->setSubstructDataByName("info_header", "packettype", 3);
  8813. packet2->setSubstructDataByName("spell_info", "skill_name", "Testing");
  8814. packet2->setSubstructDataByName("spell_info", "level", 19);
  8815. packet2->setSubstructDataByName("spell_info", "tier", 1);
  8816. packet2->setSubstructDataByName("spell_info", "health_cost", 5);
  8817. packet2->setSubstructDataByName("spell_info", "min_class_skill_req", 3);
  8818. packet2->setSubstructDataByName("spell_info", "mana_cost", 6);
  8819. packet2->setSubstructDataByName("spell_info", "req_concentration", 7);
  8820. packet2->setSubstructDataByName("spell_info", "cast_time", 200);
  8821. packet2->setSubstructDataByName("spell_info", "recovery", 220);
  8822. packet2->setSubstructDataByName("spell_info", "recast", 280);
  8823. packet2->setSubstructDataByName("spell_info", "beneficial", 1);
  8824. packet2->setSubstructDataByName("spell_info", "maintained", 1);
  8825. packet2->setSubstructDataByName("spell_info", "spell_book_type", 1);
  8826. packet2->setSubstructDataByName("spell_info", "quality", 3);
  8827. packet2->setSubstructDataByName("spell_info", "test_1a", 1);
  8828. packet2->setSubstructDataByName("spell_info", "test_1b", 1);
  8829. packet2->setSubstructDataByName("spell_info", "test_1c", 1);
  8830. packet2->setSubstructDataByName("spell_info", "test_1d", 1);
  8831. packet2->setSubstructDataByName("spell_info", "test_2a", 2);
  8832. packet2->setSubstructDataByName("spell_info", "test_2b", 2);
  8833. packet2->setSubstructDataByName("spell_info", "test_2c", 2);
  8834. packet2->setSubstructDataByName("spell_info", "test_2d", 2);
  8835. packet2->setSubstructDataByName("spell_info", "test_3", 3);
  8836. packet2->setSubstructDataByName("spell_info", "test_4", 4);
  8837. packet2->setSubstructDataByName("spell_info", "test_5", 5);
  8838. packet2->setSubstructDataByName("spell_info", "test_6", 6);
  8839. packet2->setSubstructDataByName("spell_info", "min_class_skill_req", 1);
  8840. packet2->setSubstructDataByName("spell_info", "min_class_skill_rec", 30123);
  8841. packet2->setSubstructDataByName("spell_info", "num_reagents", 1);
  8842. packet2->setSubstructArrayLengthByName("spell_info", "num_reagents", 1);
  8843. packet2->setArrayDataByName("reagent", "Alcohol");
  8844. packet2->setArrayDataByName("consumed", "123");
  8845. packet2->setSubstructDataByName("spell_info", "class_skill", 52);
  8846. packet2->setSubstructDataByName("spell_info", "id", 8308);
  8847. packet2->setSubstructDataByName("spell_info", "icon", 303);
  8848. packet2->setSubstructDataByName("spell_info", "icon2", 0xFFFF);
  8849. packet2->setSubstructDataByName("spell_info", "icontype", 317);
  8850. packet2->setSubstructDataByName("spell_info", "type", 2);
  8851. packet2->setSubstructDataByName("spell_info", "spell_text_color", 255);
  8852. packet2->setSubstructDataByName("spell_info", "duration1", 600);
  8853. packet2->setSubstructDataByName("spell_info", "duration2", 600);
  8854. packet2->setSubstructDataByName("spell_info", "name", "Sprint");
  8855. packet2->setSubstructDataByName("spell_info", "description", "Test description");
  8856. EQ2Packet* outapp = packet2->serialize();
  8857. DumpPacket(outapp);
  8858. client->QueuePacket(outapp);
  8859. safe_delete(packet2);
  8860. }
  8861. }
  8862. return;
  8863. PacketStruct* p = configReader.getStruct("WS_EqTargetItemCmd", client->GetVersion());
  8864. if (!p) return;
  8865. //Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  8866. //client->GetCurrentZone()->SendSpellFailedPacket(client, atoi(sep2->arg[0]));
  8867. //}
  8868. /*Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  8869. if (sep2 && sep2->arg[0] && sep2->IsNumber(0)) {
  8870. client->SetPendingFlightPath(atoi(sep2->arg[0]));
  8871. PacketStruct* packet = configReader.getStruct("WS_ReadyForTakeOff", client->GetVersion());
  8872. if (packet) {
  8873. client->QueuePacket(packet->serialize());
  8874. safe_delete(packet);
  8875. }
  8876. }*/
  8877. /*if (client->GetCurrentZone()->Grid != nullptr) {
  8878. int32 numFaces = 0;
  8879. int32 numGrids = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.size();
  8880. client->Message(CHANNEL_COLOR_YELLOW, "Num grids in cell: %u", numGrids);
  8881. map<int32, vector<Face*> >::iterator itr;
  8882. for (itr = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.begin(); itr != client->GetPlayer()->Cell_Info.CurrentCell->FaceList.end(); itr++)
  8883. numFaces += (*itr).second.size();
  8884. client->Message(CHANNEL_COLOR_YELLOW, "Num faces in cell: %u", numFaces);
  8885. }*/
  8886. //uchar blah[] = {
  8887. // 1208 - OP_EQUpdateStoreCmd
  8888. // /*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
  8889. // /*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
  8890. // 1193 - -- OP_ClientCmdMsg::OP_EqUpdateMerchantCmd --
  8891. // /*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
  8892. /*};
  8893. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  8894. int8 val = 0;
  8895. int16 pos = 0;
  8896. int idx = 0;
  8897. while(sep2 && sep2->arg[idx+1] && sep2->IsNumber(idx) && sep2->IsNumber(idx+1)){
  8898. pos = atoi(sep2->arg[idx]);
  8899. val = atoi(sep2->arg[idx+1]);
  8900. memset(blah+pos, val, 1);
  8901. idx+=2;
  8902. }
  8903. DumpPacket(blah, sizeof(blah));
  8904. client->QueuePacket(new EQ2Packet(OP_GroupCreatedMsg , blah, sizeof(blah)));*/
  8905. if (client->GetPlayer()->GetTarget()) {
  8906. PacketStruct* packet = configReader.getStruct("WS_SetControlGhost", client->GetVersion());
  8907. if (packet) {
  8908. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  8909. packet->setDataByName("size", 0);
  8910. packet->setDataByName("unknown2", 0);
  8911. EQ2Packet* app = packet->serialize();
  8912. client->QueuePacket(app);
  8913. safe_delete(packet);
  8914. }
  8915. PacketStruct* set_pov = configReader.getStruct("WS_SetPOVGhostCmd", client->GetVersion());
  8916. if (set_pov) {
  8917. set_pov->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  8918. EQ2Packet* app_pov = set_pov->serialize();
  8919. client->QueuePacket(app_pov);
  8920. safe_delete(set_pov);
  8921. }
  8922. }
  8923. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  8924. PacketStruct* packet = configReader.getStruct("WS_OpenCharCust", client->GetVersion());
  8925. if (packet) {
  8926. if (sep2 && sep2->arg[0] && sep2->IsNumber(0))
  8927. packet->setDataByName("Type", atoi(sep2->arg[0]));
  8928. else
  8929. packet->setDataByName("Type", 2);
  8930. if (sep2 && sep2->arg[1] && sep2->IsNumber(1))
  8931. packet->setDataByName("race_id", atoi(sep2->arg[1]));
  8932. else
  8933. packet->setDataByName("race_id", 0);
  8934. if (sep2 && sep2->arg[2] && sep2->IsNumber(2))
  8935. packet->setDataByName("gender", atoi(sep2->arg[2]));
  8936. else
  8937. packet->setDataByName("gender", 2);
  8938. if (sep2 && sep2->arg[3] && sep2->IsNumber(3))
  8939. packet->setDataByName("unknown", atoi(sep2->arg[3]), 0);
  8940. else
  8941. packet->setDataByName("unknown", 0, 0);
  8942. if (sep2 && sep2->arg[4] && sep2->IsNumber(4))
  8943. packet->setDataByName("unknown", atoi(sep2->arg[4]), 1);
  8944. else
  8945. packet->setDataByName("unknown", 0, 1);
  8946. if (sep2 && sep2->arg[5] && sep2->IsNumber(5))
  8947. packet->setDataByName("unknown", atoi(sep2->arg[5]), 2);
  8948. else
  8949. packet->setDataByName("unknown", 0, 2);
  8950. client->QueuePacket(packet->serialize());
  8951. }
  8952. safe_delete(packet);
  8953. safe_delete(sep2);
  8954. }
  8955. void Commands::Command_LeaveChannel(Client *client, Seperator *sep) {
  8956. const char *channel_name;
  8957. if (sep == NULL || !sep->IsSet(0)) {
  8958. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /leavechat <channel name>");
  8959. PrintSep(sep);
  8960. return;
  8961. }
  8962. channel_name = sep->arg[0];
  8963. if (!chat.IsInChannel(client, channel_name))
  8964. client->Message(CHANNEL_NARRATIVE, "Unable to leave '%s': You are not in the channel.", channel_name);
  8965. else if (!chat.LeaveChannel(client, channel_name))
  8966. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an internal error preventing you from leaving that channel MUAHAHA");
  8967. }
  8968. /*
  8969. Function:
  8970. Purpose :
  8971. Params :
  8972. Dev :
  8973. Example :
  8974. */
  8975. void Commands::Command_WeaponStats(Client* client)
  8976. {
  8977. Player* player = client->GetPlayer();
  8978. Item* primary = player->GetEquipmentList()->GetItem(EQ2_PRIMARY_SLOT);
  8979. Item* secondary = player->GetEquipmentList()->GetItem(EQ2_SECONDARY_SLOT);
  8980. Item* ranged = player->GetEquipmentList()->GetItem(EQ2_RANGE_SLOT);
  8981. client->SimpleMessage(0, "Primary:");
  8982. if (primary) {
  8983. client->Message(0, "Name: %s", primary->name.c_str());
  8984. client->Message(0, "Base Damage: %u - %u", primary->weapon_info->damage_low3, primary->weapon_info->damage_high3);
  8985. client->Message(0, "Actual Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  8986. client->Message(0, "Actual Delay: %u", player->GetPrimaryWeaponDelay());
  8987. client->Message(0, "Proc Percent: %d%%", 0);
  8988. client->Message(0, "Procs Per Minute: %d", 0);
  8989. }
  8990. else {
  8991. client->SimpleMessage(0, "Name: fist");
  8992. client->Message(0, "Base Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  8993. client->Message(0, "Actual Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  8994. client->Message(0, "Actual Delay: %d", player->GetPrimaryWeaponDelay() * 0.1);
  8995. client->Message(0, "Proc Percent: %d%%", 0);
  8996. client->Message(0, "Procs Per Minute: %d", 0);
  8997. }
  8998. client->SimpleMessage(0, " ");
  8999. client->SimpleMessage(0, " ");
  9000. if (secondary) {
  9001. client->SimpleMessage(0, "Secondary:");
  9002. client->Message(0, "Name: %s", secondary->name.c_str());
  9003. client->Message(0, "Base Damage: %u - %u", secondary->weapon_info->damage_low3, secondary->weapon_info->damage_high3);
  9004. client->Message(0, "Actual Damage: %u - %u", player->GetSecondaryWeaponMinDamage(), player->GetSecondaryWeaponMaxDamage());
  9005. client->Message(0, "Actual Delay: %d", player->GetSecondaryWeaponDelay() * 0.1);
  9006. client->Message(0, "Proc Percent: %d%%", 0);
  9007. client->Message(0, "Procs Per Minute: %d", 0);
  9008. client->SimpleMessage(0, " ");
  9009. client->SimpleMessage(0, " ");
  9010. }
  9011. client->SimpleMessage(0, "Ranged:");
  9012. if (ranged) {
  9013. client->Message(0, "Name: %s", ranged->name.c_str());
  9014. client->Message(0, "Base Damage: %u - %u", ranged->ranged_info->weapon_info.damage_low3, ranged->ranged_info->weapon_info.damage_high3);
  9015. client->Message(0, "Actual Damage: %u - %u", player->GetRangedWeaponMinDamage(), player->GetRangedWeaponMaxDamage());
  9016. client->Message(0, "Actual Delay: %d", player->GetRangeWeaponDelay() * 0.1);
  9017. client->Message(0, "Proc Percent: %d%%", 0);
  9018. client->Message(0, "Procs Per Minute: %d", 0);
  9019. }
  9020. else
  9021. client->SimpleMessage(0, "None");
  9022. }
  9023. void Commands::Command_WhoChannel(Client *client, Seperator *sep) {
  9024. const char *channel_name;
  9025. if (sep == NULL || !sep->IsSet(0)) {
  9026. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /chatwho <channel name>");
  9027. return;
  9028. }
  9029. channel_name = sep->arg[0];
  9030. if (!chat.ChannelExists(channel_name))
  9031. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That channel does not exist!");
  9032. else
  9033. chat.SendChannelUserList(client, channel_name);
  9034. }
  9035. void Commands::Command_ZoneSafeCoords(Client *client, Seperator *sep)
  9036. {
  9037. ZoneServer* zone = 0;
  9038. int32 zone_id = client->GetPlayer()->GetZone()->GetZoneID();
  9039. if (zone_id > 0)
  9040. {
  9041. zone = zone_list.Get(zone_id, false);
  9042. if (zone)
  9043. {
  9044. zone->SetSafeX(client->GetPlayer()->GetX());
  9045. zone->SetSafeY(client->GetPlayer()->GetY());
  9046. zone->SetSafeZ(client->GetPlayer()->GetZ());
  9047. zone->SetSafeHeading(client->GetPlayer()->GetHeading());
  9048. if( database.SaveZoneSafeCoords(zone_id, zone->GetSafeX(), zone->GetSafeY(), zone->GetSafeZ(), zone->GetSafeHeading()) )
  9049. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Zone safe coordinates updated!");
  9050. else
  9051. client->SimpleMessage(CHANNEL_COLOR_RED, "FAILED to update zone safe coordinates!");
  9052. }
  9053. }
  9054. }
  9055. /*
  9056. Function:
  9057. Purpose :
  9058. Params :
  9059. Dev :
  9060. Example :
  9061. */
  9062. void Commands::Command_ZoneDetails(Client* client, Seperator* sep)
  9063. {
  9064. ZoneInfo* zone_info = new ZoneInfo;
  9065. if (sep && sep->arg[0])
  9066. {
  9067. if (sep->IsNumber(0))
  9068. zone_info->id = atoi(sep->arg[0]);
  9069. else
  9070. zone_info->id = database.GetZoneID(sep->arg[0]);
  9071. if (zone_info->id > 0)
  9072. {
  9073. database.LoadZoneInfo(zone_info);
  9074. 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);
  9075. 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);
  9076. 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);
  9077. 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);
  9078. 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);
  9079. 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);
  9080. 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);
  9081. client->Message(CHANNEL_COLOR_YELLOW, "zone_type: %s", zone_info->zone_type);
  9082. client->Message(CHANNEL_COLOR_YELLOW, "lua_script: %s", zone_info->lua_script);
  9083. client->Message(CHANNEL_COLOR_YELLOW, "zone_motd: %s", zone_info->zone_motd);
  9084. }
  9085. else
  9086. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  9087. }
  9088. else
  9089. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone details [zone id|zone name]");
  9090. safe_delete(zone_info);
  9091. }
  9092. /*
  9093. Function:
  9094. Purpose :
  9095. Params :
  9096. Dev :
  9097. Example :
  9098. */
  9099. void Commands::Command_ZoneSet(Client* client, Seperator* sep)
  9100. {
  9101. if (sep && sep->arg[0] && sep->arg[1] && sep->arg[2])
  9102. {
  9103. ZoneServer* zone = 0;
  9104. int32 zone_id = 0;
  9105. if (sep->IsNumber(0) && atoi(sep->arg[0]) > 0)
  9106. {
  9107. zone_id = atoi(sep->arg[0]);
  9108. zone = zone_list.Get(atoi(sep->arg[0]), false);
  9109. }
  9110. else
  9111. {
  9112. zone_id = database.GetZoneID(sep->arg[0]);
  9113. if (zone_id > 0)
  9114. zone = zone_list.Get(sep->arg[0], false);
  9115. }
  9116. if (zone_id > 0)
  9117. {
  9118. if (zone_set_values.count(string(sep->arg[1])) > 0)
  9119. SetZoneCommand(client, zone_id, zone, zone_set_values[sep->arg[1]], sep->arg[2]);
  9120. else
  9121. client->Message(CHANNEL_COLOR_YELLOW, "The attribute '%s' is not valid.", sep->arg[1]);
  9122. }
  9123. else
  9124. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  9125. }
  9126. else
  9127. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone set [zone id|zone name] [attribute] [value]");
  9128. }
  9129. void Commands::Command_Rain(Client* client, Seperator* sep) {
  9130. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  9131. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /rain <float>");
  9132. return;
  9133. }
  9134. client->Message(CHANNEL_COLOR_YELLOW,"Setting rain to %.2f", atof(sep->arg[0]));
  9135. client->GetCurrentZone()->SetRain(atof(sep->arg[0]));
  9136. client->GetCurrentZone()->SetCurrentWeather(atof(sep->arg[0]));
  9137. }
  9138. void Commands::Command_Wind(Client* client, Seperator* sep) {
  9139. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  9140. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /wind <float>");
  9141. return;
  9142. }
  9143. client->Message(CHANNEL_COLOR_YELLOW, "Setting wind to %.2f", atof(sep->arg[0]));
  9144. client->GetCurrentZone()->SetWind(atof(sep->arg[0]));
  9145. }
  9146. void Commands::Command_SendMerchantWindow(Client* client, Seperator* sep, bool sell) {
  9147. Spawn* spawn = client->GetPlayer()->GetTarget();
  9148. if(spawn) {
  9149. client->SetMerchantTransaction(spawn);
  9150. if (spawn->GetMerchantID() > 0 && spawn->IsClientInMerchantLevelRange(client)){
  9151. client->SendHailCommand(spawn);
  9152. //MerchantFactionMultiplier* multiplier = world.GetMerchantMultiplier(spawn->GetMerchantID());
  9153. //if(!multiplier || (multiplier && client->GetPlayer()->GetFactions()->GetFactionValue(multiplier->faction_id) >= multiplier->faction_min)){
  9154. client->SendBuyMerchantList(sell);
  9155. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY))
  9156. client->SendSellMerchantList(sell);
  9157. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY_BACK))
  9158. client->SendBuyBackList(sell);
  9159. PacketStruct* packet = configReader.getStruct("WS_UpdateMerchant", client->GetVersion());
  9160. if (packet) {
  9161. packet->setDataByName("spawn_id", 0xFFFFFFFF);
  9162. packet->setDataByName("type", 16);
  9163. EQ2Packet* outapp = packet->serialize();
  9164. if (outapp)
  9165. client->QueuePacket(outapp);
  9166. safe_delete(packet);
  9167. }
  9168. }
  9169. if (spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR)
  9170. client->SendRepairList();
  9171. }
  9172. // client->SimpleMessage(CHANNEL_COLOR_RED, "Your faction is too low to use this merchant.");
  9173. }
  9174. void Commands::Command_Weather(Client* client, Seperator* sep)
  9175. {
  9176. //PrintSep(sep, "Weather");
  9177. if( sep && sep->arg[0] )
  9178. {
  9179. ZoneServer* zsZone = client->GetCurrentZone();
  9180. const char* value = sep->arg[0];
  9181. // process single-param commands first
  9182. if( strncasecmp(value, "details", strlen(value)) == 0 )
  9183. {
  9184. client->Message(CHANNEL_COLOR_YELLOW, "Weather Details for zone %s: ", zsZone->GetZoneName());
  9185. client->Message(CHANNEL_COLOR_YELLOW, "enabled: %i, allowed: %i, type: %i, frequency: %u", zsZone->isWeatherEnabled(), zsZone->isWeatherAllowed(), zsZone->GetWeatherType(), zsZone->GetWeatherFrequency());
  9186. client->Message(CHANNEL_COLOR_YELLOW, "severity: %.2f = %.2f, current: %.2f", zsZone->GetWeatherMinSeverity(), zsZone->GetWeatherMaxSeverity(), zsZone->GetCurrentWeather());
  9187. client->Message(CHANNEL_COLOR_YELLOW, "pattern: %i, chance: %i, amount: %.2f, offset: %.2f", zsZone->GetWeatherPattern(), zsZone->GetWeatherChance(), zsZone->GetWeatherChangeAmount(), zsZone->GetWeatherDynamicOffset());
  9188. }
  9189. else if( strncasecmp(value, "process", strlen(value)) == 0 )
  9190. {
  9191. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  9192. zsZone->ProcessWeather();
  9193. }
  9194. else if( strncasecmp(value, "reset", strlen(value)) == 0 )
  9195. {
  9196. zsZone->SetWeatherType(rule_manager.GetGlobalRule(R_Zone, WeatherType)->GetInt8());
  9197. zsZone->SetWeatherFrequency(rule_manager.GetGlobalRule(R_Zone, WeatherChangeFrequency)->GetInt32());
  9198. zsZone->SetWeatherMinSeverity(rule_manager.GetGlobalRule(R_Zone, MinWeatherSeverity)->GetFloat());
  9199. zsZone->SetWeatherMaxSeverity(rule_manager.GetGlobalRule(R_Zone, MaxWeatherSeverity)->GetFloat());
  9200. zsZone->SetCurrentWeather(zsZone->GetWeatherMinSeverity());
  9201. zsZone->SetWeatherPattern(1);
  9202. zsZone->SetWeatherChance(rule_manager.GetGlobalRule(R_Zone, WeatherChangeChance)->GetInt8());
  9203. zsZone->SetWeatherChangeAmount(rule_manager.GetGlobalRule(R_Zone, WeatherChangePerInterval)->GetFloat());
  9204. zsZone->SetWeatherDynamicOffset(rule_manager.GetGlobalRule(R_Zone, WeatherDynamicMaxOffset)->GetFloat());
  9205. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  9206. zsZone->ProcessWeather();
  9207. }
  9208. // process commands with params
  9209. if( sep->arg[1] )
  9210. {
  9211. if( strncasecmp(value, "enable", strlen(value)) == 0 && sep->IsNumber(1) )
  9212. zsZone->SetWeatherEnabled( ( atoi(sep->arg[1]) == 1 ) ? true : false );
  9213. else if( strncasecmp(value, "type", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 3) )
  9214. zsZone->SetWeatherType(atoi(sep->arg[1]));
  9215. else if( strncasecmp(value, "frequency", strlen(value)) == 0 && sep->IsNumber(1))
  9216. zsZone->SetWeatherFrequency( atoul(sep->arg[1]) );
  9217. else if( strncasecmp(value, "range", strlen(value)) == 0 && sep->IsNumber(1) && sep->IsNumber(2) ) {
  9218. zsZone->SetWeatherMinSeverity(atof(sep->arg[1]));
  9219. zsZone->SetWeatherMaxSeverity(atof(sep->arg[2]));
  9220. zsZone->SetRain(zsZone->GetWeatherMinSeverity());
  9221. }
  9222. else if( strncasecmp(value, "current", strlen(value)) == 0 && sep->IsNumber(1) ) {
  9223. zsZone->SetCurrentWeather(atof(sep->arg[1]));
  9224. zsZone->SetRain(zsZone->GetCurrentWeather());
  9225. }
  9226. else if( strncasecmp(value, "pattern", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 2) )
  9227. zsZone->SetWeatherPattern( atoi(sep->arg[1]) );
  9228. else if( strncasecmp(value, "chance", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 100) )
  9229. zsZone->SetWeatherChance( atoi(sep->arg[1]) );
  9230. else if( strncasecmp(value, "amount", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  9231. zsZone->SetWeatherChangeAmount( atof(sep->arg[1]) );
  9232. else if( strncasecmp(value, "offset", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  9233. zsZone->SetWeatherDynamicOffset( atof(sep->arg[1]) );
  9234. }
  9235. }
  9236. else
  9237. {
  9238. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /weather [command] [param]");
  9239. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: enable (0|1), type (0-3), frequency (sec), range|current (0.0 - 1.0)");
  9240. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: details, process, pattern (0|1), chance (%), amount (float), offset (float)");
  9241. return;
  9242. }
  9243. }
  9244. void Commands::Command_Select(Client* client, Seperator* sep) {
  9245. if (sep && sep->arg[1]) {
  9246. Spawn* spawn = client->GetPlayer()->GetTarget();
  9247. if (spawn && strlen(sep->arg[1]) > 0)
  9248. client->GetCurrentZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_CUSTOM, client->GetPlayer(), sep->arg[1]);
  9249. }
  9250. }
  9251. /*
  9252. Function: Command_ConsumeFood()
  9253. Purpose : Consume Food/Drink and apply mods
  9254. Params : Slot ID - EQ2_FOOD_SLOT 22, EQ2_DRINK_SLOT 23
  9255. Dev : Zcoretri
  9256. Example : /consume_food 22
  9257. */
  9258. void Commands::Command_ConsumeFood(Client* client, Seperator* sep) {
  9259. if (sep && sep->arg[0] && sep->IsNumber(0))
  9260. {
  9261. Player* player = client->GetPlayer();
  9262. int8 slot = atoi(sep->arg[0]);
  9263. Item* item = player->GetEquipmentList()->GetItem(slot);
  9264. if(item) {
  9265. LogWrite(MISC__INFO, 1, "Command", "ItemID: %u, ItemName: %s ItemCount: %i ", item->details.item_id, item->name.c_str(), item->details.count);
  9266. if(item->GetItemScript() && lua_interface){
  9267. lua_interface->RunItemScript(item->GetItemScript(), "cast", item, client->GetPlayer());
  9268. if (slot == 22)
  9269. client->Message(CHANNEL_NARRATIVE, "You eat a %s.", item->name.c_str());
  9270. else
  9271. client->Message(CHANNEL_NARRATIVE, "You drink a %s.", item->name.c_str());
  9272. }
  9273. }
  9274. if (item->details.count > 1) {
  9275. item->details.count -= 1;
  9276. item->save_needed = true;
  9277. }
  9278. else {
  9279. player->GetEquipmentList()->RemoveItem(slot, true);
  9280. database.DeleteItem(player->GetCharacterID(), item, "EQUIPPED");
  9281. }
  9282. client->GetPlayer()->SetCharSheetChanged(true);
  9283. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  9284. }
  9285. }
  9286. void Commands::Command_Aquaman(Client* client, Seperator* sep) {
  9287. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  9288. if (atoi(sep->arg[0]) == 1) {
  9289. client->GetPlayer()->GetInfoStruct()->vision = 4;
  9290. client->GetPlayer()->GetInfoStruct()->breathe_underwater = 1;
  9291. client->GetPlayer()->SetCharSheetChanged(true);
  9292. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Maybe you ought to stick to the shallow end until you know how to swim.");
  9293. }
  9294. else {
  9295. client->GetPlayer()->GetInfoStruct()->vision = 0;
  9296. client->GetPlayer()->GetInfoStruct()->breathe_underwater = 0;
  9297. client->GetPlayer()->SetCharSheetChanged(true);
  9298. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Aquaman mode turned off.");
  9299. }
  9300. }
  9301. else
  9302. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /aquaman [0|1]");
  9303. }
  9304. void Commands::Command_ReportBug(Client* client, Seperator* sep)
  9305. {
  9306. if(sep)
  9307. {
  9308. string data;
  9309. if(sep->arg[0]){
  9310. data = string(sep->arg[0]);
  9311. }
  9312. for(int i=1;i<sep->GetMaxArgNum();i++){
  9313. if(sep->arg[i])
  9314. data.append(" ").append(sep->arg[i]);
  9315. }
  9316. const char* target_name = 0;
  9317. int32 spawn_id = 0;
  9318. if(client->GetPlayer()->GetTarget())
  9319. {
  9320. target_name = client->GetPlayer()->GetTarget()->GetName();
  9321. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  9322. }
  9323. else
  9324. target_name = "N/A";
  9325. LogWrite(COMMAND__DEBUG, 1, "Command", "%s", data.c_str());
  9326. if(world.ReportBug(data, client->GetPlayer()->GetName(), client->GetAccountID(), target_name, spawn_id, client->GetCurrentZone()->GetZoneID()))
  9327. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully submitted bug.");
  9328. else
  9329. client->SimpleMessage(CHANNEL_COLOR_RED, "Error submitting bug.");
  9330. }
  9331. }
  9332. void Commands::Command_Attune_Inv(Client* client, Seperator* sep) {
  9333. PrintSep(sep, "Command_Attune_Inv");
  9334. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  9335. // Get the item index from the first parameter
  9336. int16 index = atoi(sep->arg[0]);
  9337. // Check to see if this is a valid item index for the player, if not exit out of the function
  9338. if (client->GetPlayer()->item_list.indexed_items.count(index) == 0) {
  9339. LogWrite(ITEM__DEBUG, 0, "Items", "%s has no item with an index of %i", client->GetPlayer()->GetName(), index);
  9340. return;
  9341. }
  9342. // Get the item
  9343. Item* item = client->GetPlayer()->item_list.indexed_items[index];
  9344. if(item) {
  9345. // Valid item lets check to make sure this item is attunable, if not return out
  9346. if (!item->CheckFlag(ATTUNEABLE)) {
  9347. LogWrite(ITEM__DEBUG, 0, "Items", "attune_inv called for an item that is not attunable (%s)", item->name.c_str());
  9348. return;
  9349. }
  9350. // Remove the attunable flag
  9351. item->generic_info.item_flags -= ATTUNEABLE;
  9352. // Set the attuned flag
  9353. item->generic_info.item_flags += ATTUNED;
  9354. // Flag this item for saving
  9355. item->save_needed = true;
  9356. client->QueuePacket(item->serialize(client->GetVersion(), false, client->GetPlayer()));
  9357. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), -1);
  9358. EQ2Packet* outapp = 0;
  9359. for (int32 i=0;i<packets.size();i++) {
  9360. outapp = packets[i];
  9361. if(outapp)
  9362. client->QueuePacket(outapp);
  9363. }
  9364. }
  9365. }
  9366. }
  9367. void Commands::Command_Reset_Zone_Timer(Client* client, Seperator* sep) {
  9368. PrintSep(sep, "Command_Reset_Zone_Timer");
  9369. /*if (sep && sep->arg[0] && sep->IsNumber(0)) {
  9370. int32 db_id = atoul(sep->arg[0]);
  9371. InstanceData* data = client->GetPlayer()->GetCharacterInstances().FindInstanceByDBID(db_id);
  9372. if (data) {
  9373. // TODO: add a check to timers to ensure it can be reset
  9374. // Delete the character from the instance
  9375. database.DeleteCharacterFromInstance(client->GetPlayer()->GetCharacterID(), data->instance_id);
  9376. data->instance_id = 0;
  9377. // Update the success time and set to 0 so the player can enter it again
  9378. database.UpdateCharacterInstance(client->GetPlayer()->GetCharacterID(), data->zone_name, 0, 1, 0);
  9379. data->last_success_timestamp = 0;
  9380. }
  9381. }*/
  9382. }
  9383. void Commands::Command_Player(Client* client, Seperator* sep) {
  9384. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player syntax --");
  9385. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins");
  9386. }
  9387. void Commands::Command_Player_Coins(Client* client, Seperator* sep) {
  9388. // /player coins add 10
  9389. // /player coins add plat 10
  9390. Player* player = client->GetPlayer();
  9391. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  9392. player = (Player*)player->GetTarget();
  9393. if (sep && sep->arg[0] && sep->arg[1]) {
  9394. const char* action = sep->arg[0];
  9395. int64 value = 0;
  9396. if (strncasecmp(action, "add", strlen(action)) == 0) {
  9397. if (sep->IsNumber(1)) {
  9398. value = atoi64(sep->arg[1]);
  9399. player->AddCoins(value);
  9400. if (client->GetPlayer() == player)
  9401. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  9402. else {
  9403. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  9404. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  9405. }
  9406. return;
  9407. }
  9408. else if (sep->arg[2] && sep->IsNumber(2)) {
  9409. const char* type = sep->arg[1];
  9410. if (strncasecmp(type, "copper", strlen(type)) == 0) {
  9411. value = atoi64(sep->arg[2]);
  9412. }
  9413. else if (strncasecmp(type, "silver", strlen(type)) == 0) {
  9414. value = atoi64(sep->arg[2]) * 100;
  9415. }
  9416. else if (strncasecmp(type, "gold", strlen(type)) == 0) {
  9417. value = atoi64(sep->arg[2]) * 10000;
  9418. }
  9419. else if (strncasecmp(type, "plat", strlen(type)) == 0) {
  9420. value = atoi64(sep->arg[2]) * 1000000;
  9421. }
  9422. player->AddCoins(value);
  9423. if (client->GetPlayer() == player)
  9424. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  9425. else {
  9426. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  9427. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  9428. }
  9429. return;
  9430. }
  9431. }
  9432. }
  9433. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player coins syntax --");
  9434. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add [value] - adds the given number of coins to the player");
  9435. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add copper [value] - adds the given amount of copper to the player");
  9436. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add silver [value] - adds the given amount of silver to the player");
  9437. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add gold [value] - adds the given amount of gold to the player");
  9438. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add plat [value] - adds the given amount of platinum to the player");
  9439. }
  9440. void Commands::Command_AchievementAdd(Client* client, Seperator* sep) {
  9441. PrintSep(sep, "ACHIEVEMENT_ADD");
  9442. if (sep && sep->IsSet(0)) {
  9443. int32 spell_id = atoul(sep->arg[1]);
  9444. int8 spell_tier = 0;
  9445. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  9446. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  9447. // addspellbookentry here
  9448. if (spell_tier >= data->maxRank) {
  9449. return;
  9450. }
  9451. if (!spell_tier) {
  9452. spell_tier = 1;
  9453. }
  9454. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  9455. {
  9456. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  9457. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  9458. client->GetPlayer()->UnlockSpell(spell);
  9459. client->SendSpellUpdate(spell);
  9460. }
  9461. else
  9462. {
  9463. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1);
  9464. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  9465. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  9466. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  9467. client->GetPlayer()->UnlockSpell(spell);
  9468. client->SendSpellUpdate(spell);
  9469. }
  9470. // cast spell here
  9471. if (!spell_tier)
  9472. spell_tier = 1;
  9473. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  9474. if (spell) {
  9475. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  9476. }
  9477. }
  9478. else {
  9479. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  9480. }
  9481. master_aa_list.DisplayAA(client, 0, 0);
  9482. }
  9483. void Commands::Command_Editor(Client* client, Seperator* sep) {
  9484. PacketStruct* packet = configReader.getStruct("WS_ChoiceWindow", client->GetVersion());
  9485. if (packet) {
  9486. string url = string(rule_manager.GetGlobalRule(R_World, EditorURL)->GetString());
  9487. if (rule_manager.GetGlobalRule(R_World, EditorOfficialServer)->GetBool()) {
  9488. char command[255];
  9489. url = "browser " + url;
  9490. int32 spawn_id = 0;
  9491. int32 zone_id = 0;
  9492. string type;
  9493. if (client->GetCurrentZone())
  9494. zone_id = client->GetCurrentZone()->GetZoneID();
  9495. if (client->GetPlayer()->GetTarget()) {
  9496. Spawn* target = client->GetPlayer()->GetTarget();
  9497. if (target->IsWidget())
  9498. type = "widgets";
  9499. else if (target->IsSign())
  9500. type = "signs";
  9501. else if (target->IsObject())
  9502. type = "objects";
  9503. else if (target->IsNPC())
  9504. type = "npcs";
  9505. else if (target->IsGroundSpawn())
  9506. type = "ground";
  9507. else
  9508. type = "spawn";
  9509. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  9510. }
  9511. sprintf(command, url.c_str(), zone_id, type.c_str(), spawn_id);
  9512. packet->setDataByName("accept_command", command);
  9513. }
  9514. else if (rule_manager.GetGlobalRule(R_World, EditorIncludeID)->GetBool()) {
  9515. char command[255];
  9516. url = "browser " + url;
  9517. if (client->GetPlayer()->GetTarget())
  9518. sprintf(command, url.c_str(), client->GetPlayer()->GetTarget()->GetDatabaseID());
  9519. packet->setDataByName("accept_command", command);
  9520. }
  9521. else {
  9522. string command = "browser " + url;
  9523. packet->setDataByName("accept_command", command.c_str());
  9524. }
  9525. packet->setDataByName("text", "Open the web editor?");
  9526. packet->setDataByName("accept_text", "Open");
  9527. packet->setDataByName("cancel_text", "Cancel");
  9528. // No clue if we even need the following 2 unknowns, just added them so the packet matches what live sends
  9529. packet->setDataByName("unknown2", 50);
  9530. packet->setDataByName("unknown4", 1);
  9531. client->QueuePacket(packet->serialize());
  9532. safe_delete(packet);
  9533. }
  9534. }
  9535. void Commands::Command_AcceptResurrection(Client* client, Seperator* sep) {
  9536. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  9537. return;
  9538. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  9539. if(client->GetCurrentRez()->active)
  9540. client->AcceptResurrection();
  9541. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  9542. }
  9543. void Commands::Command_DeclineResurrection(Client* client, Seperator* sep) {
  9544. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  9545. return;
  9546. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  9547. if(client->GetCurrentRez()->active)
  9548. client->GetCurrentRez()->should_delete = true;
  9549. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  9550. }
  9551. void Commands::Switch_AA_Profile(Client* client, Seperator* sep) {
  9552. PrintSep(sep, "Switch_AA_Profile");
  9553. if (sep && sep->IsSet(0)) {
  9554. string type = sep->arg[0];
  9555. int8 newtemplate = atoul(sep->arg[1]);
  9556. master_aa_list.DisplayAA(client, newtemplate, 1);
  9557. }
  9558. }
  9559. void Commands::Get_AA_Xml(Client* client, Seperator* sep) {
  9560. PrintSep(sep, "Get_AA_Xml");
  9561. if (sep && sep->IsSet(0)) {
  9562. string tabnum = sep->arg[0];
  9563. string spellid = sep->arg[1];
  9564. }
  9565. }
  9566. void Commands::Add_AA(Client* client, Seperator* sep) {
  9567. PrintSep(sep, "Add_AA");
  9568. if (sep && sep->IsSet(0)) {
  9569. int32 spell_id = atoul(sep->arg[1]);
  9570. int8 spell_tier = 0;
  9571. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  9572. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  9573. // addspellbookentry here
  9574. if (spell_tier >= data->maxRank) {
  9575. return;
  9576. }
  9577. if (!spell_tier) {
  9578. spell_tier = 1;
  9579. }
  9580. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  9581. {
  9582. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  9583. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  9584. client->GetPlayer()->UnlockSpell(spell);
  9585. client->SendSpellUpdate(spell);
  9586. }
  9587. else
  9588. {
  9589. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1 );
  9590. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  9591. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  9592. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  9593. client->GetPlayer()->UnlockSpell(spell);
  9594. client->SendSpellUpdate(spell);
  9595. }
  9596. // cast spell here
  9597. if (!spell_tier)
  9598. spell_tier = 1;
  9599. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  9600. if (spell) {
  9601. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  9602. }
  9603. }
  9604. else {
  9605. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  9606. }
  9607. master_aa_list.DisplayAA(client, 0, 0);
  9608. }
  9609. void Commands::Commit_AA_Profile(Client* client, Seperator* sep) {
  9610. PrintSep(sep, "Commit_AA_Profile");
  9611. if (sep && sep->IsSet(0)) {
  9612. }
  9613. }
  9614. void Commands::Begin_AA_Profile(Client* client, Seperator* sep) {
  9615. PrintSep(sep, "Begin_AA_Profile");
  9616. if (sep && sep->IsSet(0)) {
  9617. master_aa_list.DisplayAA(client, 100, 2);
  9618. }
  9619. }
  9620. void Commands::Back_AA(Client* client, Seperator* sep) {
  9621. if (sep && sep->IsSet(0)) {
  9622. PrintSep(sep, "Back_AA");
  9623. }
  9624. }
  9625. void Commands::Remove_AA(Client* client, Seperator* sep) {
  9626. if (sep && sep->IsSet(0)) {
  9627. PrintSep(sep, "Remove_AA");
  9628. }
  9629. }
  9630. void Commands::Cancel_AA_Profile(Client* client, Seperator* sep) {
  9631. MasterAAList master_aa_list;
  9632. PrintSep(sep, "Cancel_AA_Profile");
  9633. master_aa_list.DisplayAA(client, 0, 0);
  9634. }
  9635. void Commands::Save_AA_Profile(Client* client, Seperator* sep) {
  9636. if (sep && sep->IsSet(0)) {
  9637. PrintSep(sep, "Save_AA_Profile");
  9638. }
  9639. }
  9640. void Commands::Command_TargetItem(Client* client, Seperator* sep) {
  9641. if (!sep || sep->GetArgNumber() < 1 || !client->GetPlayer()) return;
  9642. if (!sep->IsNumber(0)) return;
  9643. int32 request_id = atoul(sep->arg[0]);
  9644. if (!sep->IsNumber(1)) return;
  9645. sint32 item_id = atoi(sep->arg[1]);
  9646. if (client->IsCurrentTransmuteID(request_id)) {
  9647. Transmute::HandleItemResponse(client, client->GetPlayer(), request_id, reinterpret_cast<int32&>(item_id));
  9648. }
  9649. else if (client->IsCurrentTransmuteID(item_id)) {
  9650. if (!sep->IsSet(2)) return;
  9651. if (sep->IsNumber(2) && atoi(sep->arg[2]) == 1) {
  9652. Transmute::HandleConfirmResponse(client, client->GetPlayer(), reinterpret_cast<int32&>(item_id));
  9653. }
  9654. }
  9655. }
  9656. void Commands::Command_FindSpawn(Client* client, Seperator* sep) {
  9657. if(sep)
  9658. client->GetCurrentZone()->FindSpawn(client, (char*)sep->argplus[0]);
  9659. }