Commands.cpp 393 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944
  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. spawn_set_values["aaxp_rewards"] = SPAWN_SET_AAXP_REWARDS;
  150. spawn_set_values["hair_color1"] = SPAWN_SET_HAIR_COLOR1;
  151. spawn_set_values["hair_color2"] = SPAWN_SET_HAIR_COLOR2;
  152. spawn_set_values["hair_type_color"] = SPAWN_SET_HAIR_TYPE_COLOR;
  153. spawn_set_values["hair_face_color"] = SPAWN_SET_HAIR_FACE_COLOR;
  154. spawn_set_values["hair_type_highlight_color"] = SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR;
  155. spawn_set_values["face_hairlight_color"] = SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR;
  156. spawn_set_values["hair_highlight"] = SPAWN_SET_HAIR_HIGHLIGHT;
  157. spawn_set_values["model_color"] = SPAWN_SET_MODEL_COLOR;
  158. spawn_set_values["eye_color"] = SPAWN_SET_EYE_COLOR;
  159. spawn_set_values["soga_skin_color"] = SPAWN_SET_SOGA_SKIN_COLOR;
  160. spawn_set_values["soga_hair_color1"] = SPAWN_SET_SOGA_HAIR_COLOR1;
  161. spawn_set_values["soga_hair_color2"] = SPAWN_SET_SOGA_HAIR_COLOR2;
  162. spawn_set_values["soga_hair_type_color"] = SPAWN_SET_SOGA_HAIR_TYPE_COLOR;
  163. spawn_set_values["soga_hair_face_color"] = SPAWN_SET_SOGA_HAIR_FACE_COLOR;
  164. spawn_set_values["soga_hair_type_highlight_color"] = SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR;
  165. spawn_set_values["soga_face_hairlight_color"] = SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR;
  166. spawn_set_values["soga_hair_highlight"] = SPAWN_SET_SOGA_HAIR_HIGHLIGHT;
  167. spawn_set_values["soga_model_color"] = SPAWN_SET_SOGA_MODEL_COLOR;
  168. spawn_set_values["soga_eye_color"] = SPAWN_SET_SOGA_EYE_COLOR;
  169. zone_set_values["expansion_id"] = ZONE_SET_VALUE_EXPANSION_ID;
  170. zone_set_values["name"] = ZONE_SET_VALUE_NAME;
  171. zone_set_values["file"] = ZONE_SET_VALUE_FILE ;
  172. zone_set_values["description"] = ZONE_SET_VALUE_DESCRIPTION;
  173. zone_set_values["safe_x"] = ZONE_SET_VALUE_SAFE_X;
  174. zone_set_values["safe_y"] = ZONE_SET_VALUE_SAFE_Y;
  175. zone_set_values["safe_z"] = ZONE_SET_VALUE_SAFE_Z;
  176. zone_set_values["underworld"] = ZONE_SET_VALUE_UNDERWORLD;
  177. zone_set_values["min_recommended"] = ZONE_SET_VALUE_MIN_RECOMMENDED;
  178. zone_set_values["max_recommended"] = ZONE_SET_VALUE_MAX_RECOMMENDED;
  179. zone_set_values["zone_type"] = ZONE_SET_VALUE_ZONE_TYPE;
  180. zone_set_values["always_loaded"] = ZONE_SET_VALUE_ALWAYS_LOADED;
  181. zone_set_values["city_zone"] = ZONE_SET_VALUE_CITY_ZONE;
  182. zone_set_values["weather_allowed"] = ZONE_SET_VALUE_WEATHER_ALLOWED;
  183. zone_set_values["min_status"] = ZONE_SET_VALUE_MIN_STATUS;
  184. zone_set_values["min_level"] = ZONE_SET_VALUE_MIN_LEVEL;
  185. zone_set_values["start_zone"] = ZONE_SET_VALUE_START_ZONE;
  186. zone_set_values["instance_type"] = ZONE_SET_VALUE_INSTANCE_TYPE;
  187. zone_set_values["default_reenter_time"] = ZONE_SET_VALUE_DEFAULT_REENTER_TIME;
  188. zone_set_values["default_reset_time"] = ZONE_SET_VALUE_DEFAULT_RESET_TIME;
  189. zone_set_values["default_lockout_time"] = ZONE_SET_VALUE_DEFAULT_LOCKOUT_TIME;
  190. zone_set_values["force_group_to_zone"] = ZONE_SET_VALUE_FORCE_GROUP_TO_ZONE;
  191. zone_set_values["lua_script"] = ZONE_SET_VALUE_LUA_SCRIPT;
  192. zone_set_values["shutdown_timer"] = ZONE_SET_VALUE_SHUTDOWN_TIMER;
  193. zone_set_values["zone_motd"] = ZONE_SET_VALUE_ZONE_MOTD;
  194. }
  195. Commands::~Commands() {
  196. safe_delete(remote_commands);
  197. }
  198. int32 Commands::GetSpawnSetType(string val){
  199. if(spawn_set_values.count(val) > 0)
  200. return spawn_set_values[val];
  201. return 0xFFFFFFFF;
  202. }
  203. bool Commands::SetSpawnCommand(Client* client, Spawn* target, int8 type, const char* value, bool send_update, bool temporary, string* temp_value){
  204. if(!target)
  205. return false;
  206. int32 val = 0;
  207. try{
  208. if(type != SPAWN_SET_VALUE_NAME &&
  209. !(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))
  210. {
  211. switch(type)
  212. {
  213. case SPAWN_SET_SKIN_COLOR:
  214. case SPAWN_SET_HAIR_COLOR1:
  215. case SPAWN_SET_HAIR_COLOR2:
  216. case SPAWN_SET_HAIR_TYPE_COLOR:
  217. case SPAWN_SET_HAIR_FACE_COLOR:
  218. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  219. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  220. case SPAWN_SET_HAIR_HIGHLIGHT:
  221. case SPAWN_SET_EYE_COLOR:
  222. case SPAWN_SET_SOGA_SKIN_COLOR:
  223. case SPAWN_SET_SOGA_HAIR_COLOR1:
  224. case SPAWN_SET_SOGA_HAIR_COLOR2:
  225. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  226. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  227. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  228. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  229. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  230. case SPAWN_SET_SOGA_EYE_COLOR:
  231. // ignore these are colors can't pass as a integer value
  232. break;
  233. default:
  234. val = atoul(value);
  235. }
  236. }
  237. }
  238. catch(...){
  239. if(client)
  240. client->Message(CHANNEL_COLOR_RED, "Invalid numeric spawn value: %s", value);
  241. return false;
  242. }
  243. if(temporary){
  244. char tmp[128] = {0};
  245. switch(type){
  246. case SPAWN_SET_VALUE_NAME:{
  247. sprintf(tmp, "%s", target->GetName());
  248. target->SetName(value);
  249. if(target->GetZone())
  250. target->GetZone()->SendUpdateTitles(target);
  251. break;
  252. }
  253. case SPAWN_SET_VALUE_X_OFFSET:
  254. {
  255. sprintf(tmp, "%f", target->GetXOffset());
  256. target->SetXOffset(float(val));
  257. break;
  258. }
  259. case SPAWN_SET_VALUE_Y_OFFSET:
  260. {
  261. sprintf(tmp, "%f", target->GetYOffset());
  262. target->SetYOffset(float(val));
  263. break;
  264. }
  265. case SPAWN_SET_VALUE_Z_OFFSET:
  266. {
  267. sprintf(tmp, "%f", target->GetZOffset());
  268. target->SetZOffset(float(val));
  269. break;
  270. }
  271. case SPAWN_SET_VALUE_EXPIRE: {
  272. sprintf(tmp, "%u", target->GetExpireTime());
  273. target->SetExpireTime(val);
  274. break;
  275. }
  276. case SPAWN_SET_VALUE_EXPIRE_OFFSET: {
  277. sprintf(tmp, "%u", target->GetExpireOffsetTime());
  278. target->SetExpireOffsetTime(val);
  279. break;
  280. }
  281. case SPAWN_SET_VALUE_SUB_TITLE: {
  282. sprintf(tmp, "%s", target->GetSubTitle());
  283. target->SetSubTitle(value);
  284. if(target->GetZone())
  285. target->GetZone()->SendUpdateTitles(target);
  286. break;
  287. }
  288. case SPAWN_SET_VALUE_LEVEL:{
  289. sprintf(tmp, "%i", target->GetLevel());
  290. target->SetLevel(val, send_update);
  291. break;
  292. }
  293. case SPAWN_SET_VALUE_DIFFICULTY:{
  294. sprintf(tmp, "%i", target->GetEncounterLevel());
  295. target->SetEncounterLevel(val, send_update);
  296. break;
  297. }
  298. case SPAWN_SET_VALUE_MODEL_TYPE:{
  299. sprintf(tmp, "%i", target->GetModelType());
  300. target->SetModelType(val, send_update);
  301. break;
  302. }
  303. case SPAWN_SET_VALUE_CLASS:{
  304. sprintf(tmp, "%i", target->GetAdventureClass());
  305. target->SetAdventureClass(val, send_update);
  306. break;
  307. }
  308. case SPAWN_SET_VALUE_GENDER:{
  309. sprintf(tmp, "%i", target->GetGender());
  310. target->SetGender(val, send_update);
  311. break;
  312. }
  313. case SPAWN_SET_VALUE_SHOW_NAME:{
  314. sprintf(tmp, "%i", target->GetShowName());
  315. target->SetShowName(val, send_update);
  316. break;
  317. }
  318. case SPAWN_SET_VALUE_ATTACKABLE:{
  319. sprintf(tmp, "%i", target->GetAttackable());
  320. target->SetAttackable(val, send_update);
  321. break;
  322. }
  323. case SPAWN_SET_VALUE_SHOW_LEVEL:{
  324. sprintf(tmp, "%i", target->GetShowLevel());
  325. target->SetShowLevel(val, send_update);
  326. break;
  327. }
  328. case SPAWN_SET_VALUE_TARGETABLE:{
  329. sprintf(tmp, "%i", target->GetTargetable());
  330. target->SetTargetable(val, send_update);
  331. break;
  332. }
  333. case SPAWN_SET_VALUE_SHOW_COMMAND_ICON:{
  334. sprintf(tmp, "%i", target->GetShowCommandIcon());
  335. target->SetShowCommandIcon(val, send_update);
  336. break;
  337. }
  338. case SPAWN_SET_VALUE_HAND_ICON:{
  339. sprintf(tmp, "%i", target->GetShowHandIcon());
  340. target->SetShowHandIcon(val, send_update);
  341. break;
  342. }
  343. case SPAWN_SET_VALUE_HAIR_TYPE:{
  344. if(target->IsEntity()){
  345. sprintf(tmp, "%i", ((Entity*)target)->GetHairType());
  346. ((Entity*)target)->SetHairType(val, send_update);
  347. }
  348. break;
  349. }
  350. case SPAWN_SET_VALUE_FACIAL_HAIR_TYPE:{
  351. if(target->IsEntity()){
  352. sprintf(tmp, "%i", ((Entity*)target)->GetFacialHairType());
  353. ((Entity*)target)->SetFacialHairType(val, send_update);
  354. }
  355. break;
  356. }
  357. case SPAWN_SET_VALUE_WING_TYPE:{
  358. if(target->IsEntity()){
  359. sprintf(tmp, "%i", ((Entity*)target)->GetWingType());
  360. ((Entity*)target)->SetWingType(val, send_update);
  361. }
  362. break;
  363. }
  364. case SPAWN_SET_VALUE_CHEST_TYPE:{
  365. if(target->IsEntity()){
  366. sprintf(tmp, "%i", ((Entity*)target)->GetChestType());
  367. ((Entity*)target)->SetChestType(val, send_update);
  368. }
  369. break;
  370. }
  371. case SPAWN_SET_VALUE_LEGS_TYPE:{
  372. if(target->IsEntity()){
  373. sprintf(tmp, "%i", ((Entity*)target)->GetLegsType());
  374. ((Entity*)target)->SetLegsType(val, send_update);
  375. }
  376. break;
  377. }
  378. case SPAWN_SET_VALUE_SOGA_HAIR_TYPE:{
  379. if(target->IsEntity()){
  380. sprintf(tmp, "%i", ((Entity*)target)->GetSogaHairType());
  381. ((Entity*)target)->SetSogaHairType(val, send_update);
  382. }
  383. break;
  384. }
  385. case SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE:{
  386. if(target->IsEntity()){
  387. sprintf(tmp, "%i", ((Entity*)target)->GetSogaFacialHairType());
  388. ((Entity*)target)->SetSogaFacialHairType(val, send_update);
  389. }
  390. break;
  391. }
  392. case SPAWN_SET_VALUE_SOGA_MODEL_TYPE:{
  393. sprintf(tmp, "%i", target->GetSogaModelType());
  394. target->SetSogaModelType(val, send_update);
  395. break;
  396. }
  397. case SPAWN_SET_VALUE_SIZE:{
  398. sprintf(tmp, "%i", target->GetSize());
  399. target->SetSize(val, send_update);
  400. break;
  401. }
  402. case SPAWN_SET_VALUE_HP:{
  403. sprintf(tmp, "%i", target->GetHP());
  404. target->SetHP(val, send_update);
  405. break;
  406. }
  407. case SPAWN_SET_VALUE_POWER:{
  408. sprintf(tmp, "%i", target->GetPower());
  409. target->SetPower(val, send_update);
  410. break;
  411. }
  412. case SPAWN_SET_VALUE_HEROIC:{
  413. sprintf(tmp, "%i", target->GetHeroic());
  414. target->SetHeroic(val, send_update);
  415. break;
  416. }
  417. case SPAWN_SET_VALUE_RESPAWN:{
  418. sprintf(tmp, "%u", target->GetRespawnTime());
  419. target->SetRespawnTime(val);
  420. break;
  421. }
  422. case SPAWN_SET_VALUE_X:{
  423. sprintf(tmp, "%f", target->GetX());
  424. target->SetX(atof(value), send_update);
  425. break;
  426. }
  427. case SPAWN_SET_VALUE_Y:{
  428. sprintf(tmp, "%f", target->GetY());
  429. target->SetY(atof(value), send_update);
  430. break;
  431. }
  432. case SPAWN_SET_VALUE_Z:{
  433. sprintf(tmp, "%f", target->GetZ());
  434. target->SetZ(atof(value), send_update);
  435. break;
  436. }
  437. case SPAWN_SET_VALUE_HEADING:{
  438. sprintf(tmp, "%f", target->GetHeading());
  439. target->SetHeading(atof(value) + 360, send_update);
  440. break;
  441. }
  442. case SPAWN_SET_VALUE_VISUAL_STATE:{
  443. sprintf(tmp, "%i", target->GetVisualState());
  444. target->SetVisualState(val, send_update);
  445. break;
  446. }
  447. case SPAWN_SET_VALUE_ACTION_STATE:{
  448. sprintf(tmp, "%i", target->GetActionState());
  449. target->SetActionState(val, send_update);
  450. break;
  451. }
  452. case SPAWN_SET_VALUE_MOOD_STATE:{
  453. sprintf(tmp, "%i", target->GetMoodState());
  454. target->SetMoodState(val, send_update);
  455. break;
  456. }
  457. case SPAWN_SET_VALUE_INITIAL_STATE:{
  458. sprintf(tmp, "%i", target->GetInitialState());
  459. target->SetInitialState(val, send_update);
  460. break;
  461. }
  462. case SPAWN_SET_VALUE_ACTIVITY_STATE:{
  463. sprintf(tmp, "%i", target->GetActivityStatus());
  464. target->SetActivityStatus(val, send_update);
  465. break;
  466. }
  467. case SPAWN_SET_VALUE_COLLISION_RADIUS:{
  468. sprintf(tmp, "%i", target->GetCollisionRadius());
  469. target->SetCollisionRadius(val, send_update);
  470. break;
  471. }
  472. case SPAWN_SET_VALUE_DEVICE_ID: {
  473. if (target->IsObject()) {
  474. sprintf(tmp, "%i", ((Object*)target)->GetDeviceID());
  475. ((Object*)target)->SetDeviceID(val);
  476. }
  477. break;
  478. }
  479. case SPAWN_SET_VALUE_PITCH: {
  480. sprintf(tmp, "%f", target->GetPitch());
  481. target->SetPitch(atof(value), send_update);
  482. break;
  483. }
  484. case SPAWN_SET_VALUE_ROLL: {
  485. sprintf(tmp, "%f", target->GetRoll());
  486. target->SetRoll(atof(value), send_update);
  487. break;
  488. }
  489. case SPAWN_SET_VALUE_HIDE_HOOD: {
  490. sprintf(tmp, "%i", target->appearance.hide_hood);
  491. target->SetHideHood(val);
  492. break;
  493. }
  494. case SPAWN_SET_VALUE_EMOTE_STATE: {
  495. sprintf(tmp, "%i", target->appearance.emote_state);
  496. target->SetEmoteState(val);
  497. break;
  498. }
  499. case SPAWN_SET_VALUE_ICON: {
  500. sprintf(tmp, "%i", target->GetIconValue());
  501. target->SetIcon(val);
  502. break;
  503. }
  504. case SPAWN_SET_VALUE_PREFIX: {
  505. sprintf(tmp, "%s", target->GetPrefixTitle());
  506. target->SetPrefixTitle(value);
  507. if(target->GetZone())
  508. target->GetZone()->SendUpdateTitles(target);
  509. break;
  510. }
  511. case SPAWN_SET_VALUE_SUFFIX: {
  512. sprintf(tmp, "%s", target->GetSuffixTitle());
  513. target->SetSuffixTitle(value);
  514. if(target->GetZone())
  515. target->GetZone()->SendUpdateTitles(target);
  516. break;
  517. }
  518. case SPAWN_SET_VALUE_LASTNAME: {
  519. sprintf(tmp, "%s", target->GetLastName());
  520. target->SetLastName(value);
  521. if(target->GetZone())
  522. target->GetZone()->SendUpdateTitles(target);
  523. break;
  524. }
  525. case SPAWN_SET_VALUE_EXPANSION_FLAG:
  526. case SPAWN_SET_VALUE_HOLIDAY_FLAG: {
  527. // nothing to do must reload spawns
  528. break;
  529. }
  530. case SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL: {
  531. sprintf(tmp, "%i", target->GetMerchantMinLevel());
  532. target->SetMerchantLevelRange(atoul(value), target->GetMerchantMaxLevel());
  533. break;
  534. }
  535. case SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL: {
  536. sprintf(tmp, "%i", target->GetMerchantMaxLevel());
  537. target->SetMerchantLevelRange(target->GetMerchantMinLevel(), atoul(value));
  538. break;
  539. }
  540. case SPAWN_SET_VALUE_FACTION:{
  541. sprintf(tmp, "%i", target->faction_id);
  542. ZoneServer* zone = target->GetZone();
  543. if (!zone && client)
  544. zone = client->GetCurrentZone();
  545. target->faction_id = atoul(value);
  546. if(zone)
  547. {
  548. zone->RemoveDeadEnemyList(target);
  549. if(target->IsNPC())
  550. zone->AddEnemyList((NPC*)target);
  551. }
  552. break;
  553. }
  554. case SPAWN_SET_SKIN_COLOR:
  555. case SPAWN_SET_HAIR_COLOR1:
  556. case SPAWN_SET_HAIR_COLOR2:
  557. case SPAWN_SET_HAIR_TYPE_COLOR:
  558. case SPAWN_SET_HAIR_FACE_COLOR:
  559. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  560. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  561. case SPAWN_SET_HAIR_HIGHLIGHT:
  562. case SPAWN_SET_MODEL_COLOR:
  563. case SPAWN_SET_EYE_COLOR:
  564. case SPAWN_SET_SOGA_SKIN_COLOR:
  565. case SPAWN_SET_SOGA_HAIR_COLOR1:
  566. case SPAWN_SET_SOGA_HAIR_COLOR2:
  567. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  568. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  569. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  570. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  571. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  572. case SPAWN_SET_SOGA_MODEL_COLOR:
  573. case SPAWN_SET_SOGA_EYE_COLOR:
  574. {
  575. if (target->IsEntity())
  576. {
  577. Seperator* skinsep = new Seperator(value, ' ', 3, 500, true);
  578. if (skinsep->IsNumber(0) && skinsep->IsNumber(1) && skinsep->IsNumber(2))
  579. {
  580. EQ2_Color clr;
  581. clr.red = atoul(skinsep->arg[0]);
  582. clr.green = atoul(skinsep->arg[1]);
  583. clr.blue = atoul(skinsep->arg[2]);
  584. switch(type)
  585. {
  586. case SPAWN_SET_SKIN_COLOR:
  587. ((Entity*)target)->SetSkinColor(clr);
  588. break;
  589. case SPAWN_SET_HAIR_COLOR1:
  590. ((Entity*)target)->SetHairColor1(clr);
  591. break;
  592. case SPAWN_SET_HAIR_COLOR2:
  593. ((Entity*)target)->SetHairColor2(clr);
  594. break;
  595. case SPAWN_SET_HAIR_TYPE_COLOR:
  596. ((Entity*)target)->SetHairColor(clr);
  597. break;
  598. case SPAWN_SET_HAIR_FACE_COLOR:
  599. ((Entity*)target)->SetFacialHairColor(clr);
  600. break;
  601. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  602. ((Entity*)target)->SetHairTypeHighlightColor(clr);
  603. break;
  604. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  605. ((Entity*)target)->SetFacialHairHighlightColor(clr);
  606. break;
  607. case SPAWN_SET_HAIR_HIGHLIGHT:
  608. ((Entity*)target)->SetHairHighlightColor(clr);
  609. break;
  610. case SPAWN_SET_MODEL_COLOR:
  611. ((Entity*)target)->SetModelColor(clr);
  612. break;
  613. case SPAWN_SET_EYE_COLOR:
  614. ((Entity*)target)->SetEyeColor(clr);
  615. break;
  616. case SPAWN_SET_SOGA_SKIN_COLOR:
  617. ((Entity*)target)->SetSogaSkinColor(clr);
  618. break;
  619. case SPAWN_SET_SOGA_HAIR_COLOR1:
  620. ((Entity*)target)->SetSogaHairColor1(clr);
  621. break;
  622. case SPAWN_SET_SOGA_HAIR_COLOR2:
  623. ((Entity*)target)->SetSogaHairColor2(clr);
  624. break;
  625. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  626. ((Entity*)target)->SetSogaHairColor(clr);
  627. break;
  628. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  629. ((Entity*)target)->SetSogaFacialHairColor(clr);
  630. break;
  631. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  632. ((Entity*)target)->SetSogaHairTypeHighlightColor(clr);
  633. break;
  634. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  635. ((Entity*)target)->SetSogaFacialHairHighlightColor(clr);
  636. break;
  637. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  638. ((Entity*)target)->SetSogaHairHighlightColor(clr);
  639. break;
  640. case SPAWN_SET_SOGA_MODEL_COLOR:
  641. ((Entity*)target)->SetSogaModelColor(clr);
  642. break;
  643. case SPAWN_SET_SOGA_EYE_COLOR:
  644. ((Entity*)target)->SetSogaEyeColor(clr);
  645. break;
  646. }
  647. }
  648. safe_delete(skinsep);
  649. }
  650. break;
  651. }
  652. case SPAWN_SET_AAXP_REWARDS: {
  653. target->SetAAXPRewards(atoul(value));
  654. break;
  655. }
  656. if(temp_value)
  657. *temp_value = string(tmp);
  658. }
  659. }
  660. else{
  661. switch(type){
  662. case SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL: {
  663. target->SetMerchantLevelRange(atoul(value), target->GetMerchantMaxLevel());
  664. break;
  665. }
  666. case SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL: {
  667. target->SetMerchantLevelRange(target->GetMerchantMinLevel(), atoul(value));
  668. break;
  669. }
  670. case SPAWN_SET_VALUE_EXPANSION_FLAG: {
  671. if (target->GetDatabaseID() > 0)
  672. {
  673. char query[256];
  674. snprintf(query, 256, "update spawn set expansion_flag=%u where id=%i", atoul(value), target->GetDatabaseID());
  675. if (database.RunQuery(query, strnlen(query, 256)))
  676. {
  677. if(client)
  678. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  679. }
  680. }
  681. break;
  682. }
  683. case SPAWN_SET_VALUE_HOLIDAY_FLAG: {
  684. if (target->GetDatabaseID() > 0)
  685. {
  686. char query[256];
  687. snprintf(query, 256, "update spawn set holiday_flag=%u where id=%i", atoul(value), target->GetDatabaseID());
  688. if (database.RunQuery(query, strnlen(query, 256)))
  689. {
  690. if(client)
  691. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  692. }
  693. }
  694. break;
  695. }
  696. case SPAWN_SET_AAXP_REWARDS: {
  697. if (target->GetDatabaseID() > 0)
  698. {
  699. char query[256];
  700. snprintf(query, 256, "update spawn set aaxp_rewards=%u where id=%i", atoul(value), target->GetDatabaseID());
  701. if (database.RunQuery(query, strnlen(query, 256)))
  702. {
  703. if(client)
  704. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  705. }
  706. }
  707. break;
  708. }
  709. case SPAWN_SET_VALUE_NAME:{
  710. target->SetName(value);
  711. if(target->GetZone())
  712. target->GetZone()->SendUpdateTitles(target);
  713. break;
  714. }
  715. case SPAWN_SET_VALUE_SUB_TITLE: {
  716. target->SetSubTitle(value);
  717. if(target->GetZone())
  718. target->GetZone()->SendUpdateTitles(target);
  719. break;
  720. }
  721. case SPAWN_SET_VALUE_X_OFFSET:
  722. {
  723. target->SetXOffset(atof(value));
  724. break;
  725. }
  726. case SPAWN_SET_VALUE_Y_OFFSET:
  727. {
  728. target->SetYOffset(atof(value));
  729. break;
  730. }
  731. case SPAWN_SET_VALUE_Z_OFFSET:
  732. {
  733. target->SetZOffset(atof(value));
  734. break;
  735. }
  736. case SPAWN_SET_VALUE_EXPIRE: {
  737. target->SetExpireTime(val);
  738. break;
  739. }
  740. case SPAWN_SET_VALUE_EXPIRE_OFFSET: {
  741. target->SetExpireOffsetTime(val);
  742. break;
  743. }
  744. case SPAWN_SET_VALUE_LEVEL:{
  745. target->SetLevel(val, send_update);
  746. break;
  747. }
  748. case SPAWN_SET_VALUE_DIFFICULTY:{
  749. target->SetEncounterLevel(val, send_update);
  750. break;
  751. }
  752. case SPAWN_SET_VALUE_MODEL_TYPE:{
  753. target->SetModelType(val, send_update);
  754. break;
  755. }
  756. case SPAWN_SET_VALUE_CLASS:{
  757. target->SetAdventureClass(val, send_update);
  758. break;
  759. }
  760. case SPAWN_SET_VALUE_GENDER:{
  761. target->SetGender(val, send_update);
  762. break;
  763. }
  764. case SPAWN_SET_VALUE_SHOW_NAME:{
  765. target->SetShowName(val, send_update);
  766. break;
  767. }
  768. case SPAWN_SET_VALUE_ATTACKABLE:{
  769. target->SetAttackable(val, send_update);
  770. break;
  771. }
  772. case SPAWN_SET_VALUE_SHOW_LEVEL:{
  773. target->SetShowLevel(val, send_update);
  774. break;
  775. }
  776. case SPAWN_SET_VALUE_TARGETABLE:{
  777. target->SetTargetable(val, send_update);
  778. break;
  779. }
  780. case SPAWN_SET_VALUE_SHOW_COMMAND_ICON:{
  781. target->SetShowCommandIcon(val, send_update);
  782. break;
  783. }
  784. case SPAWN_SET_VALUE_HAND_ICON:{
  785. target->SetShowHandIcon(val, send_update);
  786. break;
  787. }
  788. case SPAWN_SET_VALUE_HAIR_TYPE:{
  789. if(target->IsEntity())
  790. ((Entity*)target)->SetHairType(val, send_update);
  791. break;
  792. }
  793. case SPAWN_SET_VALUE_FACIAL_HAIR_TYPE:{
  794. if(target->IsEntity())
  795. ((Entity*)target)->SetFacialHairType(val, send_update);
  796. break;
  797. }
  798. case SPAWN_SET_VALUE_WING_TYPE:{
  799. if(target->IsEntity())
  800. ((Entity*)target)->SetWingType(val, send_update);
  801. break;
  802. }
  803. case SPAWN_SET_VALUE_CHEST_TYPE:{
  804. if(target->IsEntity())
  805. ((Entity*)target)->SetChestType(val, send_update);
  806. break;
  807. }
  808. case SPAWN_SET_VALUE_LEGS_TYPE:{
  809. if(target->IsEntity())
  810. ((Entity*)target)->SetLegsType(val, send_update);
  811. break;
  812. }
  813. case SPAWN_SET_VALUE_SOGA_HAIR_TYPE:{
  814. if(target->IsEntity())
  815. ((Entity*)target)->SetSogaHairType(val, send_update);
  816. break;
  817. }
  818. case SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE:{
  819. if(target->IsEntity())
  820. ((Entity*)target)->SetSogaFacialHairType(val, send_update);
  821. break;
  822. }
  823. case SPAWN_SET_VALUE_SOGA_MODEL_TYPE:{
  824. target->SetSogaModelType(val, send_update);
  825. break;
  826. }
  827. case SPAWN_SET_VALUE_SIZE:{
  828. target->SetSize(val, send_update);
  829. break;
  830. }
  831. case SPAWN_SET_VALUE_HP:{
  832. target->SetHP(val, send_update);
  833. break;
  834. }
  835. case SPAWN_SET_VALUE_POWER:{
  836. target->SetPower(val, send_update);
  837. break;
  838. }
  839. case SPAWN_SET_VALUE_HEROIC:{
  840. target->SetHeroic(val, send_update);
  841. break;
  842. }
  843. case SPAWN_SET_VALUE_RESPAWN:{
  844. target->SetRespawnTime(val);
  845. break;
  846. }
  847. case SPAWN_SET_VALUE_X:{
  848. target->SetX(atof(value), send_update);
  849. target->SetSpawnOrigX(target->GetX());
  850. break;
  851. }
  852. case SPAWN_SET_VALUE_Y:{
  853. target->SetY(atof(value), send_update);
  854. target->SetSpawnOrigY(target->GetY());
  855. break;
  856. }
  857. case SPAWN_SET_VALUE_Z:{
  858. target->SetZ(atof(value), send_update);
  859. target->SetSpawnOrigZ(target->GetZ());
  860. break;
  861. }
  862. case SPAWN_SET_VALUE_HEADING:{
  863. target->SetHeading(atof(value), send_update);
  864. target->SetSpawnOrigHeading(target->GetHeading());
  865. break;
  866. }
  867. case SPAWN_SET_VALUE_COMMAND_PRIMARY:{
  868. ZoneServer* zone = target->GetZone();
  869. if (!zone && client)
  870. zone = client->GetCurrentZone();
  871. if(zone && zone->GetEntityCommandList(val))
  872. target->SetPrimaryCommands(zone->GetEntityCommandList(val));
  873. target->primary_command_list_id = val;
  874. break;
  875. }
  876. case SPAWN_SET_VALUE_COMMAND_SECONDARY:{
  877. ZoneServer* zone = target->GetZone();
  878. if (!zone && client)
  879. zone = client->GetCurrentZone();
  880. if (zone && zone->GetEntityCommandList(val))
  881. target->SetSecondaryCommands(zone->GetEntityCommandList(val));
  882. target->secondary_command_list_id = val;
  883. break;
  884. }
  885. case SPAWN_SET_VALUE_VISUAL_STATE:{
  886. target->SetVisualState(val, send_update);
  887. break;
  888. }
  889. case SPAWN_SET_VALUE_ACTION_STATE:{
  890. target->SetActionState(val, send_update);
  891. break;
  892. }
  893. case SPAWN_SET_VALUE_MOOD_STATE:{
  894. target->SetMoodState(val, send_update);
  895. break;
  896. }
  897. case SPAWN_SET_VALUE_INITIAL_STATE:{
  898. target->SetInitialState(val, send_update);
  899. break;
  900. }
  901. case SPAWN_SET_VALUE_ACTIVITY_STATE:{
  902. target->SetActivityStatus(val, send_update);
  903. break;
  904. }
  905. case SPAWN_SET_VALUE_COLLISION_RADIUS:{
  906. target->SetCollisionRadius(val, send_update);
  907. break;
  908. }
  909. case SPAWN_SET_VALUE_FACTION:{
  910. ZoneServer* zone = target->GetZone();
  911. if (!zone && client)
  912. zone = client->GetCurrentZone();
  913. target->faction_id = val;
  914. if(zone)
  915. {
  916. zone->RemoveDeadEnemyList(target);
  917. if(target->IsNPC())
  918. zone->AddEnemyList((NPC*)target);
  919. }
  920. break;
  921. }
  922. case SPAWN_SET_VALUE_DEVICE_ID:{
  923. if (target->IsObject())
  924. ((Object*)target)->SetDeviceID(val);
  925. break;
  926. }
  927. case SPAWN_SET_VALUE_PITCH: {
  928. target->SetPitch(atof(value), send_update);
  929. target->SetSpawnOrigPitch(atof(value));
  930. break;
  931. }
  932. case SPAWN_SET_VALUE_ROLL: {
  933. target->SetRoll(atof(value), send_update);
  934. target->SetSpawnOrigRoll(atof(value));
  935. break;
  936. }
  937. case SPAWN_SET_VALUE_HIDE_HOOD: {
  938. target->SetHideHood(val);
  939. break;
  940. }
  941. case SPAWN_SET_VALUE_EMOTE_STATE: {
  942. target->SetEmoteState(val);
  943. break;
  944. }
  945. case SPAWN_SET_VALUE_ICON: {
  946. target->SetIcon(val);
  947. break;
  948. }
  949. case SPAWN_SET_VALUE_PREFIX: {
  950. target->SetPrefixTitle(value);
  951. if(target->GetZone())
  952. target->GetZone()->SendUpdateTitles(target);
  953. break;
  954. }
  955. case SPAWN_SET_VALUE_SUFFIX: {
  956. target->SetSuffixTitle(value);
  957. if(target->GetZone())
  958. target->GetZone()->SendUpdateTitles(target);
  959. break;
  960. }
  961. case SPAWN_SET_VALUE_LASTNAME: {
  962. target->SetLastName(value);
  963. if(target->GetZone())
  964. target->GetZone()->SendUpdateTitles(target);
  965. break;
  966. }
  967. case SPAWN_SET_VALUE_SPAWN_SCRIPT:{
  968. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  969. if(client){
  970. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  971. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawn_script 'SpawnScripts/example.lua'");
  972. }
  973. return false;
  974. }
  975. else if(!database.UpdateSpawnScriptData(target->GetDatabaseID(), 0, 0, value))
  976. return false;
  977. else{
  978. if(!world.GetSpawnLocationScript(target->GetSpawnLocationID()))
  979. target->SetSpawnScript(value);
  980. }
  981. break;
  982. }
  983. case SPAWN_SET_VALUE_SPAWNLOCATION_SCRIPT:{
  984. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  985. if(client){
  986. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  987. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawnlocation_script 'SpawnScripts/example.lua'");
  988. }
  989. return false;
  990. }
  991. else if(!database.UpdateSpawnScriptData(0, target->GetSpawnLocationID(), 0, value))
  992. return false;
  993. else{
  994. if(!world.GetSpawnEntryScript(target->GetSpawnEntryID()))
  995. target->SetSpawnScript(value);
  996. }
  997. break;
  998. }
  999. case SPAWN_SET_VALUE_SPAWNENTRY_SCRIPT:{
  1000. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  1001. if(client){
  1002. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  1003. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawnentry_script 'SpawnScripts/example.lua'");
  1004. }
  1005. return false;
  1006. }
  1007. else if(!database.UpdateSpawnScriptData(0, 0, target->GetSpawnEntryID(), value))
  1008. return false;
  1009. else
  1010. target->SetSpawnScript(value);
  1011. break;
  1012. }
  1013. case SPAWN_SET_SKIN_COLOR:
  1014. case SPAWN_SET_HAIR_COLOR1:
  1015. case SPAWN_SET_HAIR_COLOR2:
  1016. case SPAWN_SET_HAIR_TYPE_COLOR:
  1017. case SPAWN_SET_HAIR_FACE_COLOR:
  1018. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  1019. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  1020. case SPAWN_SET_HAIR_HIGHLIGHT:
  1021. case SPAWN_SET_MODEL_COLOR:
  1022. case SPAWN_SET_EYE_COLOR:
  1023. case SPAWN_SET_SOGA_SKIN_COLOR:
  1024. case SPAWN_SET_SOGA_HAIR_COLOR1:
  1025. case SPAWN_SET_SOGA_HAIR_COLOR2:
  1026. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  1027. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  1028. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  1029. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  1030. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  1031. case SPAWN_SET_SOGA_MODEL_COLOR:
  1032. case SPAWN_SET_SOGA_EYE_COLOR: {
  1033. if (target->IsNPC())
  1034. {
  1035. Seperator* skinsep = new Seperator(value, ' ', 3, 500, true);
  1036. if (skinsep->IsNumber(0) && skinsep->IsNumber(1) && skinsep->IsNumber(2))
  1037. {
  1038. EQ2_Color clr;
  1039. clr.red = atoul(skinsep->arg[0]);
  1040. clr.green = atoul(skinsep->arg[1]);
  1041. clr.blue = atoul(skinsep->arg[2]);
  1042. Query replaceSkinQuery;
  1043. string fieldName("");
  1044. switch(type)
  1045. {
  1046. case SPAWN_SET_SKIN_COLOR:
  1047. ((Entity*)target)->SetSkinColor(clr);
  1048. fieldName.append("skin_color");
  1049. break;
  1050. case SPAWN_SET_HAIR_COLOR1:
  1051. ((Entity*)target)->SetHairColor1(clr);
  1052. fieldName.append("hair_color1");
  1053. break;
  1054. case SPAWN_SET_HAIR_COLOR2:
  1055. ((Entity*)target)->SetHairColor2(clr);
  1056. fieldName.append("hair_color2");
  1057. break;
  1058. case SPAWN_SET_HAIR_TYPE_COLOR:
  1059. ((Entity*)target)->SetHairColor(clr);
  1060. fieldName.append("hair_type_color");
  1061. break;
  1062. case SPAWN_SET_HAIR_FACE_COLOR:
  1063. ((Entity*)target)->SetFacialHairColor(clr);
  1064. fieldName.append("hair_face_color");
  1065. break;
  1066. case SPAWN_SET_HAIR_TYPE_HIGHLIGHT_COLOR:
  1067. ((Entity*)target)->SetHairTypeHighlightColor(clr);
  1068. fieldName.append("hair_type_highlight_color");
  1069. break;
  1070. case SPAWN_SET_HAIR_FACE_HIGHLIGHT_COLOR:
  1071. ((Entity*)target)->SetFacialHairHighlightColor(clr);
  1072. fieldName.append("hair_face_highlight_color");
  1073. break;
  1074. case SPAWN_SET_HAIR_HIGHLIGHT:
  1075. ((Entity*)target)->SetHairHighlightColor(clr);
  1076. fieldName.append("hair_highlight");
  1077. break;
  1078. case SPAWN_SET_MODEL_COLOR:
  1079. ((Entity*)target)->SetModelColor(clr);
  1080. fieldName.append("model_color");
  1081. break;
  1082. case SPAWN_SET_EYE_COLOR:
  1083. ((Entity*)target)->SetEyeColor(clr);
  1084. fieldName.append("eye_color");
  1085. break;
  1086. case SPAWN_SET_SOGA_SKIN_COLOR:
  1087. ((Entity*)target)->SetSogaSkinColor(clr);
  1088. fieldName.append("soga_skin_color");
  1089. break;
  1090. case SPAWN_SET_SOGA_HAIR_COLOR1:
  1091. ((Entity*)target)->SetSogaHairColor1(clr);
  1092. fieldName.append("soga_hair_color1");
  1093. break;
  1094. case SPAWN_SET_SOGA_HAIR_COLOR2:
  1095. ((Entity*)target)->SetSogaHairColor2(clr);
  1096. fieldName.append("soga_hair_color2");
  1097. break;
  1098. case SPAWN_SET_SOGA_HAIR_TYPE_COLOR:
  1099. ((Entity*)target)->SetSogaHairColor(clr);
  1100. fieldName.append("soga_hair_type_color");
  1101. break;
  1102. case SPAWN_SET_SOGA_HAIR_FACE_COLOR:
  1103. ((Entity*)target)->SetSogaFacialHairColor(clr);
  1104. fieldName.append("soga_hair_face_color");
  1105. break;
  1106. case SPAWN_SET_SOGA_HAIR_TYPE_HIGHLIGHT_COLOR:
  1107. ((Entity*)target)->SetSogaHairTypeHighlightColor(clr);
  1108. fieldName.append("soga_hair_type_highlight_color");
  1109. break;
  1110. case SPAWN_SET_SOGA_HAIR_FACE_HIGHLIGHT_COLOR:
  1111. ((Entity*)target)->SetSogaFacialHairHighlightColor(clr);
  1112. fieldName.append("soga_hair_face_highlight_color");
  1113. break;
  1114. case SPAWN_SET_SOGA_HAIR_HIGHLIGHT:
  1115. ((Entity*)target)->SetSogaHairHighlightColor(clr);
  1116. fieldName.append("soga_hair_highlight");
  1117. break;
  1118. case SPAWN_SET_SOGA_MODEL_COLOR:
  1119. ((Entity*)target)->SetSogaModelColor(clr);
  1120. fieldName.append("soga_model_color");
  1121. break;
  1122. case SPAWN_SET_SOGA_EYE_COLOR:
  1123. ((Entity*)target)->SetSogaEyeColor(clr);
  1124. fieldName.append("soga_eye_color");
  1125. break;
  1126. }
  1127. replaceSkinQuery.AddQueryAsync(0, &database, Q_DELETE, "delete from npc_appearance where spawn_id=%u and type='%s'", target->GetDatabaseID(), fieldName.c_str());
  1128. replaceSkinQuery.AddQueryAsync(0, &database, Q_INSERT, "insert into npc_appearance set spawn_id=%u, type='%s', red=%u, green=%u, blue=%u", target->GetDatabaseID(), fieldName.c_str(), clr.red, clr.green, clr.blue);
  1129. }
  1130. safe_delete(skinsep);
  1131. }
  1132. break;
  1133. }
  1134. }
  1135. }
  1136. return true;
  1137. }
  1138. /* The zone object will be NULL if the zone is not currently running. We pass both of these in so we can update
  1139. the database fields always and also update the zone in memory if it's running. */
  1140. bool Commands::SetZoneCommand(Client* client, int32 zone_id, ZoneServer* zone, int8 type, const char* value) {
  1141. if (client && zone_id > 0 && type > 0 && value) {
  1142. sint32 int_value = 0;
  1143. float float_value = 0;
  1144. if (type == ZONE_SET_VALUE_SAFE_X || type == ZONE_SET_VALUE_SAFE_Y || type == ZONE_SET_VALUE_SAFE_Z || type == ZONE_SET_VALUE_UNDERWORLD) {
  1145. try {
  1146. float_value = atof(value);
  1147. }
  1148. catch (...) {
  1149. client->Message(CHANNEL_COLOR_RED, "Error converting '%s' to a float value", value);
  1150. return false;
  1151. }
  1152. }
  1153. 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) {
  1154. try {
  1155. int_value = atoi(value);
  1156. }
  1157. catch (...) {
  1158. client->Message(CHANNEL_COLOR_RED, "Error converting '%s' to an integer value", value);
  1159. return false;
  1160. }
  1161. }
  1162. switch (type) {
  1163. case ZONE_SET_VALUE_EXPANSION_ID: {
  1164. break;
  1165. }
  1166. case ZONE_SET_VALUE_NAME: {
  1167. if (zone)
  1168. zone->SetZoneName(const_cast<char*>(value));
  1169. database.SaveZoneInfo(zone_id, "name", value);
  1170. break;
  1171. }
  1172. case ZONE_SET_VALUE_FILE: {
  1173. if (zone)
  1174. zone->SetZoneFile(const_cast<char*>(value));
  1175. database.SaveZoneInfo(zone_id, "file", value);
  1176. break;
  1177. }
  1178. case ZONE_SET_VALUE_DESCRIPTION: {
  1179. if (zone)
  1180. zone->SetZoneDescription(const_cast<char*>(value));
  1181. database.SaveZoneInfo(zone_id, "description", value);
  1182. break;
  1183. }
  1184. case ZONE_SET_VALUE_SAFE_X: {
  1185. if (zone)
  1186. zone->SetSafeX(float_value);
  1187. database.SaveZoneInfo(zone_id, "safe_x", float_value);
  1188. break;
  1189. }
  1190. case ZONE_SET_VALUE_SAFE_Y: {
  1191. if (zone)
  1192. zone->SetSafeY(float_value);
  1193. database.SaveZoneInfo(zone_id, "safe_y", float_value);
  1194. break;
  1195. }
  1196. case ZONE_SET_VALUE_SAFE_Z: {
  1197. if (zone)
  1198. zone->SetSafeZ(float_value);
  1199. database.SaveZoneInfo(zone_id, "safe_z", float_value);
  1200. break;
  1201. }
  1202. case ZONE_SET_VALUE_UNDERWORLD: {
  1203. if (zone)
  1204. zone->SetUnderWorld(float_value);
  1205. database.SaveZoneInfo(zone_id, "underworld", float_value);
  1206. break;
  1207. }
  1208. case ZONE_SET_VALUE_MIN_RECOMMENDED: {
  1209. break;
  1210. }
  1211. case ZONE_SET_VALUE_MAX_RECOMMENDED: {
  1212. break;
  1213. }
  1214. case ZONE_SET_VALUE_ZONE_TYPE: {
  1215. break;
  1216. }
  1217. case ZONE_SET_VALUE_ALWAYS_LOADED: {
  1218. if (zone)
  1219. zone->SetAlwaysLoaded(int_value == 1);
  1220. database.SaveZoneInfo(zone_id, "always_loaded", int_value);
  1221. break;
  1222. }
  1223. case ZONE_SET_VALUE_CITY_ZONE: {
  1224. if (zone)
  1225. zone->SetCityZone(int_value == 1);
  1226. database.SaveZoneInfo(zone_id, "city_zone", int_value);
  1227. break;
  1228. }
  1229. case ZONE_SET_VALUE_WEATHER_ALLOWED: {
  1230. if (zone)
  1231. zone->SetWeatherAllowed(int_value == 1);
  1232. database.SaveZoneInfo(zone_id, "weather_allowed", int_value);
  1233. break;
  1234. }
  1235. case ZONE_SET_VALUE_MIN_STATUS: {
  1236. if (zone)
  1237. zone->SetMinimumStatus(int_value);
  1238. database.SaveZoneInfo(zone_id, "min_status", int_value);
  1239. break;
  1240. }
  1241. case ZONE_SET_VALUE_MIN_LEVEL: {
  1242. if (zone)
  1243. zone->SetMinimumLevel(int_value);
  1244. database.SaveZoneInfo(zone_id, "min_level", int_value);
  1245. break;
  1246. }
  1247. case ZONE_SET_VALUE_MAX_LEVEL: {
  1248. if (zone)
  1249. zone->SetMaximumLevel(int_value);
  1250. database.SaveZoneInfo(zone_id, "max_level", int_value);
  1251. break;
  1252. }
  1253. case ZONE_SET_VALUE_START_ZONE: {
  1254. database.SaveZoneInfo(zone_id, "start_zone", int_value);
  1255. break;
  1256. }
  1257. case ZONE_SET_VALUE_INSTANCE_TYPE: {
  1258. if (zone)
  1259. zone->SetInstanceType(int_value);
  1260. database.SaveZoneInfo(zone_id, "instance_type", int_value);
  1261. break;
  1262. }
  1263. case ZONE_SET_VALUE_DEFAULT_REENTER_TIME: {
  1264. if (zone)
  1265. zone->SetDefaultReenterTime(int_value);
  1266. database.SaveZoneInfo(zone_id, "default_reenter_time", int_value);
  1267. break;
  1268. }
  1269. case ZONE_SET_VALUE_DEFAULT_RESET_TIME: {
  1270. if (zone)
  1271. zone->SetDefaultResetTime(int_value);
  1272. database.SaveZoneInfo(zone_id, "default_reset_time", int_value);
  1273. break;
  1274. }
  1275. case ZONE_SET_VALUE_DEFAULT_LOCKOUT_TIME: {
  1276. if (zone)
  1277. zone->SetDefaultLockoutTime(int_value);
  1278. database.SaveZoneInfo(zone_id, "default_lockout_time", int_value);
  1279. break;
  1280. }
  1281. case ZONE_SET_VALUE_FORCE_GROUP_TO_ZONE: {
  1282. if (zone)
  1283. zone->SetForceGroupZoneOption(int_value);
  1284. database.SaveZoneInfo(zone_id, "force_group_to_zone", int_value);
  1285. break;
  1286. }
  1287. case ZONE_SET_VALUE_LUA_SCRIPT: {
  1288. if (lua_interface && lua_interface->GetZoneScript(value) == 0) {
  1289. client->Message(CHANNEL_COLOR_RED, "Invalid Zone Script file. Be sure you give the absolute path.");
  1290. client->Message(CHANNEL_COLOR_RED, "Example: /zone set lua_script 'ZoneScripts/QueensColony.lua'");
  1291. return false;
  1292. }
  1293. else {
  1294. world.AddZoneScript(zone_id, const_cast<char*>(value));
  1295. database.SaveZoneInfo(zone_id, "lua_script", value);
  1296. }
  1297. break;
  1298. }
  1299. case ZONE_SET_VALUE_SHUTDOWN_TIMER: {
  1300. if (zone)
  1301. zone->SetShutdownTimer(int_value);
  1302. database.SaveZoneInfo(zone_id, "shutdown_timer", int_value);
  1303. break;
  1304. }
  1305. case ZONE_SET_VALUE_ZONE_MOTD: {
  1306. if (zone)
  1307. zone->SetZoneMOTD(string(value));
  1308. database.SaveZoneInfo(zone_id, "zone_motd", value);
  1309. break;
  1310. }
  1311. default: {
  1312. client->Message(CHANNEL_COLOR_RED, "Invalid zone attribute %i", type);
  1313. return false;
  1314. }
  1315. }
  1316. }
  1317. else {
  1318. if (client)
  1319. client->SimpleMessage(CHANNEL_COLOR_RED, "An error occured saving new zone data.");
  1320. return false;
  1321. }
  1322. return true;
  1323. }
  1324. void Commands::Process(int32 index, EQ2_16BitString* command_parms, Client* client, Spawn* targetOverride) {
  1325. if (index >= remote_commands->commands.size()) {
  1326. LogWrite(COMMAND__ERROR, 0, "Command", "Error, command handler of %u was requested, but max handler is %u", index, remote_commands->commands.size());
  1327. return;
  1328. }
  1329. Spawn* cmdTarget = targetOverride ? targetOverride : client->GetPlayer()->GetTarget();
  1330. EQ2_RemoteCommandString* parent_command = 0;
  1331. EQ2_RemoteCommandString* command = &remote_commands->commands[index];
  1332. Seperator* sep = 0;
  1333. if (command_parms->size > 0) {
  1334. sep = new Seperator(command_parms->data.c_str(), ' ', 10, 500, true);
  1335. if (sep && sep->arg[0] && remote_commands->validSubCommand(command->command.data, string(sep->arg[0]))) {
  1336. parent_command = command;
  1337. command = &(remote_commands->subcommands[command->command.data][string(sep->arg[0])]);
  1338. safe_delete(sep);
  1339. if (command_parms->data.length() > (command->command.data.length() + 1))
  1340. sep = new Seperator(command_parms->data.c_str() + (command->command.data.length() + 1), ' ', 10, 500, true);
  1341. LogWrite(COMMAND__DEBUG, 1, "Command", "Handler: %u, COMMAND: '%s', SUBCOMMAND: '%s'", index, parent_command->command.data.c_str(), command->command.data.c_str());
  1342. }
  1343. else
  1344. LogWrite(COMMAND__DEBUG, 1, "Command", "Handler: %u, COMMAND: '%s'", index, command->command.data.c_str());
  1345. }
  1346. int ndx = 0;
  1347. if (command->required_status > client->GetAdminStatus())
  1348. {
  1349. 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());
  1350. safe_delete(sep);
  1351. client->SimpleMessage(3, "Error: Your status is insufficient for this command.");
  1352. return;
  1353. }
  1354. Player* player = client->GetPlayer();
  1355. LogWrite(COMMAND__DEBUG, 0, "Command", "Player '%s' (%u), Command: %s", player->GetName(), client->GetAccountID(), command->command.data.c_str());
  1356. switch (command->handler) {
  1357. case COMMAND_RELOAD: {
  1358. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reload commands:");
  1359. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload structs");
  1360. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload items");
  1361. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload luasystem");
  1362. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spawnscripts");
  1363. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spells");
  1364. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload quests");
  1365. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spawns");
  1366. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload groundspawns");
  1367. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload zonescripts");
  1368. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload entity_commands");
  1369. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload factions");
  1370. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload mail");
  1371. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload guilds");
  1372. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload locations");
  1373. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload rules");
  1374. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload transporters");
  1375. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload startabilities");
  1376. break;
  1377. }
  1378. case COMMAND_RELOADSTRUCTS: {
  1379. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Structs...");
  1380. world.SetReloadingSubsystem("Structs");
  1381. configReader.ReloadStructs();
  1382. world.RemoveReloadingSubSystem("Structs");
  1383. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1384. break;
  1385. }
  1386. case COMMAND_RELOAD_QUESTS: {
  1387. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Quests...");
  1388. world.SetReloadingSubsystem("Quests");
  1389. master_quest_list.Reload();
  1390. client_list.ReloadQuests();
  1391. zone_list.ReloadClientQuests();
  1392. world.RemoveReloadingSubSystem("Quests");
  1393. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1394. break;
  1395. }
  1396. case COMMAND_RELOAD_SPAWNS: {
  1397. client->GetCurrentZone()->ReloadSpawns();
  1398. break;
  1399. }
  1400. case COMMAND_RELOAD_SPELLS: {
  1401. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spells...");
  1402. world.SetReloadingSubsystem("Spells");
  1403. zone_list.DeleteSpellProcess();
  1404. master_spell_list.Reload();
  1405. if (lua_interface)
  1406. lua_interface->ReloadSpells();
  1407. zone_list.LoadSpellProcess();
  1408. world.RemoveReloadingSubSystem("Spells");
  1409. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1410. break;
  1411. }
  1412. case COMMAND_RELOAD_GROUNDSPAWNS: {
  1413. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Groundspawn Entries...");
  1414. world.SetReloadingSubsystem("GroundSpawns");
  1415. client->GetCurrentZone()->DeleteGroundSpawnItems();
  1416. client->GetCurrentZone()->LoadGroundSpawnEntries();
  1417. world.RemoveReloadingSubSystem("GroundSpawns");
  1418. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1419. break;
  1420. }
  1421. case COMMAND_RELOAD_ZONESCRIPTS: {
  1422. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Zone Scripts...");
  1423. world.SetReloadingSubsystem("ZoneScripts");
  1424. world.ResetZoneScripts();
  1425. database.LoadZoneScriptData();
  1426. if (lua_interface)
  1427. lua_interface->DestroyZoneScripts();
  1428. world.RemoveReloadingSubSystem("ZoneScripts");
  1429. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1430. break;
  1431. }
  1432. case COMMAND_RELOAD_ENTITYCOMMANDS: {
  1433. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Entity Commands...");
  1434. world.SetReloadingSubsystem("EntityCommands");
  1435. client->GetCurrentZone()->ClearEntityCommands();
  1436. database.LoadEntityCommands(client->GetCurrentZone());
  1437. world.RemoveReloadingSubSystem("EntityCommands");
  1438. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1439. break;
  1440. }
  1441. case COMMAND_RELOAD_FACTIONS: {
  1442. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Factions...");
  1443. world.SetReloadingSubsystem("Factions");
  1444. master_faction_list.Clear();
  1445. database.LoadFactionList();
  1446. world.RemoveReloadingSubSystem("Factions");
  1447. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1448. break;
  1449. }
  1450. case COMMAND_RELOAD_MAIL: {
  1451. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Mail...");
  1452. zone_list.ReloadMail();
  1453. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1454. break;
  1455. }
  1456. case COMMAND_RELOAD_GUILDS: {
  1457. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Guilds...");
  1458. world.ReloadGuilds();
  1459. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1460. break;
  1461. }
  1462. case COMMAND_RELOAD_LOCATIONS: {
  1463. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Locations...");
  1464. client->GetPlayer()->GetZone()->RemoveLocationGrids();
  1465. database.LoadLocationGrids(client->GetPlayer()->GetZone());
  1466. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1467. break;
  1468. }
  1469. case COMMAND_RELOAD_RULES: {
  1470. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Rules...");
  1471. database.LoadRuleSets(true);
  1472. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1473. break;
  1474. }
  1475. case COMMAND_RELOAD_TRANSPORTERS: {
  1476. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Transporters in your current zone...");
  1477. database.LoadTransporters(client->GetCurrentZone());
  1478. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1479. break;
  1480. }
  1481. case COMMAND_RELOAD_STARTABILITIES: {
  1482. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Starting Skills/Spells...");
  1483. world.PurgeStartingLists();
  1484. world.LoadStartingLists();
  1485. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1486. break;
  1487. }
  1488. case COMMAND_READ: {
  1489. if (sep && sep->arg[1][0] && sep->IsNumber(1)) {
  1490. if (strcmp(sep->arg[0], "read") == 0) {
  1491. int32 item_index = atol(sep->arg[1]);
  1492. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  1493. if (item) {
  1494. Spawn* spawn = cmdTarget;
  1495. client->SendShowBook(client->GetPlayer(), item->name, item->book_pages);
  1496. break;
  1497. }
  1498. }
  1499. }
  1500. break;
  1501. }
  1502. case COMMAND_USEABILITY:{
  1503. if (sep && sep->arg[0][0] && sep->IsNumber(0)) {
  1504. if (client->GetPlayer()->GetHP() == 0) {
  1505. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot do that right now.");
  1506. }
  1507. else {
  1508. int32 spell_id = atoul(sep->arg[0]);
  1509. int8 spell_tier = 0;
  1510. if (sep->arg[1][0] && sep->IsNumber(1))
  1511. spell_tier = atoi(sep->arg[1]);
  1512. else
  1513. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  1514. if (!spell_tier)
  1515. spell_tier = 1;
  1516. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  1517. if (spell) {
  1518. 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)
  1519. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), cmdTarget, true, true);
  1520. else
  1521. {
  1522. if (cmdTarget)
  1523. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), cmdTarget);
  1524. else
  1525. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  1526. }
  1527. }
  1528. }
  1529. }
  1530. else if (cmdTarget && cmdTarget->IsWidget())
  1531. {
  1532. Widget* widget = (Widget*)cmdTarget;
  1533. widget->HandleUse(client, "use", WIDGET_TYPE_DOOR);
  1534. }
  1535. else
  1536. {
  1537. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /useability {spell_id} [spell_tier]");
  1538. }
  1539. break;
  1540. }
  1541. case COMMAND_INFO:{
  1542. if(sep && sep->arg[1][0] && sep->IsNumber(1)){
  1543. if(strcmp(sep->arg[0], "inventory") == 0){
  1544. int32 item_index = atol(sep->arg[1]);
  1545. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  1546. if(item){
  1547. if (item->IsCollectable() && client->SendCollectionsForItem(item))
  1548. break;
  1549. EQ2Packet* app = item->serialize(client->GetVersion(), (!item->GetItemScript() || !lua_interface), client->GetPlayer());
  1550. //DumpPacket(app);
  1551. client->QueuePacket(app);
  1552. if(item->GetItemScript() && lua_interface)
  1553. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  1554. else if(item->generic_info.offers_quest_id > 0){ //leave the current functionality in place if it doesnt have an item script
  1555. Quest* quest = master_quest_list.GetQuest(item->generic_info.offers_quest_id, false);
  1556. if(quest && client->GetPlayer()->GetCompletedQuest(item->generic_info.offers_quest_id) == 0 && client->GetPlayer()->GetQuest(item->generic_info.offers_quest_id) == 0)
  1557. client->AddPendingQuest(new Quest(quest)); // copy quest since we pulled the master quest to see if it existed or not
  1558. }
  1559. }
  1560. else
  1561. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Index: %u", item_index);
  1562. }
  1563. else if(strcmp(sep->arg[0], "equipment") == 0){
  1564. int32 item_index = atol(sep->arg[1]);
  1565. Item* item = client->GetPlayer()->GetEquipmentList()->GetItem(item_index);
  1566. if(item){
  1567. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1568. client->QueuePacket(app);
  1569. if(item->GetItemScript() && lua_interface)
  1570. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  1571. }
  1572. else
  1573. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Index: %u", item_index);
  1574. }
  1575. else if(strcmp(sep->arg[0], "appearance") == 0){
  1576. int32 item_index = atol(sep->arg[1]);
  1577. Item* item = client->GetPlayer()->GetAppearanceEquipmentList()->GetItem(item_index);
  1578. if(item){
  1579. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1580. client->QueuePacket(app);
  1581. if(item->GetItemScript() && lua_interface)
  1582. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  1583. }
  1584. else
  1585. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Index: %u", item_index);
  1586. }
  1587. 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){
  1588. int32 item_id = atoul(sep->arg[1]);
  1589. Item* item = master_item_list.GetItem(item_id);
  1590. if(item){
  1591. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1592. client->QueuePacket(app);
  1593. }
  1594. else
  1595. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Item ID: %u", item_id);
  1596. }
  1597. else if (strcmp(sep->arg[0], "spell") == 0) {
  1598. sint32 spell_id = atol(sep->arg[1]);
  1599. int8 tier = atoi(sep->arg[3]);
  1600. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, tier, client, true, 0x2A);
  1601. if (outapp)
  1602. client->QueuePacket(outapp);
  1603. else
  1604. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  1605. }
  1606. else if (strcmp(sep->arg[0], "achievement") == 0) {
  1607. sint32 spell_id = atol(sep->arg[2]);
  1608. int8 group = atoi(sep->arg[1]);
  1609. AltAdvanceData* data = 0;
  1610. SpellBookEntry* spellentry = 0;
  1611. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  1612. LogWrite(COMMAND__ERROR, 0, "Command", "AA Spell ID and/or Tier, ID: %u, Group: %i", spell_id, group);
  1613. EQ2Packet* outapp = master_spell_list.GetAASpellPacket(spell_id, tier, client, true, 0x45);
  1614. if (outapp)
  1615. client->QueuePacket(outapp);
  1616. else
  1617. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, group);
  1618. }
  1619. else if (strcmp(sep->arg[0], "spellbook") == 0) {
  1620. sint32 spell_id = atol(sep->arg[1]);
  1621. int32 tier = atoi(sep->arg[2]);
  1622. if (tier > 255) {
  1623. SpellBookEntry* ent = client->GetPlayer()->GetSpellBookSpell(spell_id);
  1624. if (ent)
  1625. tier = ent->tier;
  1626. }
  1627. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, (int8)tier, client, true, 0x2A);
  1628. if (outapp)
  1629. client->QueuePacket(outapp);
  1630. else
  1631. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  1632. }
  1633. else if (strcmp(sep->arg[0], "recipe") == 0) {
  1634. sint32 recipe_id = atol(sep->arg[1]);
  1635. EQ2Packet* outapp = master_recipe_list.GetRecipePacket(recipe_id, client, true, 0x2C);
  1636. if(outapp)
  1637. client->QueuePacket(outapp);
  1638. else
  1639. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Recipe ID: %u", recipe_id);
  1640. }
  1641. else if (strcmp(sep->arg[0], "maintained") ==0) {
  1642. int32 slot = atol(sep->arg[1]);
  1643. int32 spell_id = atol(sep->arg[2]);
  1644. LogWrite(COMMAND__DEBUG, 5, "Command", "Unknown Spell ID - Slot: %u unknown: %u", slot, spell_id);
  1645. //int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  1646. MaintainedEffects* info = client->GetPlayer()->GetMaintainedSpellBySlot(slot);
  1647. EQ2Packet* outapp = master_spell_list.GetSpellPacket(info->spell_id, info->tier, client, true, 0x00);
  1648. if(outapp)
  1649. client->QueuePacket(outapp);
  1650. else
  1651. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID: %u", spell_id);
  1652. }
  1653. else if (strcmp(sep->arg[0], "effect") == 0) {
  1654. int32 spell_id = atol(sep->arg[1]);
  1655. LogWrite(COMMAND__DEBUG, 5, "Command", "Unknown Spell ID: %u", spell_id);
  1656. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  1657. int8 type = 0;
  1658. if (client->GetVersion() <= 546)
  1659. type = 1;
  1660. EQ2Packet* outapp = master_spell_list.GetSpecialSpellPacket(spell_id, tier, client, true, type);
  1661. if (outapp){
  1662. client->QueuePacket(outapp);
  1663. }
  1664. else
  1665. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID: %u", spell_id);
  1666. }
  1667. }
  1668. else if (sep && strcmp(sep->arg[0], "overflow") == 0) {
  1669. Item* item = player->item_list.GetOverflowItem();
  1670. if(item) {
  1671. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1672. client->QueuePacket(app);
  1673. }
  1674. else
  1675. LogWrite(COMMAND__ERROR, 0,"Command", "Unable to retrieve an overflow item.");
  1676. }
  1677. else
  1678. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /info {inventory|equipment|spell} {id}");
  1679. break;
  1680. }
  1681. case COMMAND_USE_EQUIPPED_ITEM:{
  1682. if (sep && sep->arg[0] && sep->IsNumber(0)){
  1683. int32 slot_id = atoul(sep->arg[0]);
  1684. Item* item = player->GetEquipmentList()->GetItem(slot_id);
  1685. if (item && item->generic_info.usable && item->GetItemScript())
  1686. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player);
  1687. }
  1688. break;
  1689. }
  1690. case COMMAND_USE_ITEM: {
  1691. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  1692. int32 item_index = atoul(sep->arg[0]);
  1693. Item* item = player->item_list.GetItemFromIndex(item_index);
  1694. if (item && item->GetItemScript()) {
  1695. if (item->generic_info.max_charges == 0 || item->generic_info.max_charges == 0xFFFF)
  1696. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player);
  1697. else {
  1698. if (item->generic_info.display_charges > 0) {
  1699. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player);
  1700. item->generic_info.display_charges -= 1;
  1701. item->save_needed = true;
  1702. client->QueuePacket(item->serialize(client->GetVersion(), false, client->GetPlayer()));
  1703. }
  1704. else
  1705. 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);
  1706. }
  1707. }
  1708. }
  1709. break;
  1710. }
  1711. case COMMAND_SCRIBE_SCROLL_ITEM: {
  1712. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  1713. Item* item = player->item_list.GetItemFromUniqueID(atoul(sep->arg[0]));
  1714. if (item) {
  1715. LogWrite(ITEM__DEBUG, 0, "Items", "ITEM ID: %u", item->details.item_id);
  1716. if(item->generic_info.item_type == 6) {
  1717. Spell* spell = master_spell_list.GetSpell(item->skill_info->spell_id, item->skill_info->spell_tier);
  1718. int8 old_slot = 0;
  1719. if (spell) {
  1720. int16 tier_up = player->GetTierUp(spell->GetSpellTier());
  1721. if (rule_manager.GetGlobalRule(R_Spells, RequirePreviousTierScribe)->GetInt8() && !player->HasSpell(spell->GetSpellID(), tier_up, false, true))
  1722. client->SimpleMessage(CHANNEL_COLOR_RED, "You have not scribed the required previous version of this ability.");
  1723. else if (!player->HasSpell(spell->GetSpellID(), spell->GetSpellTier(), true)) {
  1724. old_slot = player->GetSpellSlot(spell->GetSpellID());
  1725. player->RemoveSpellBookEntry(spell->GetSpellID());
  1726. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  1727. player->UnlockSpell(spell);
  1728. client->SendSpellUpdate(spell);
  1729. database.DeleteItem(client->GetCharacterID(), item, 0);
  1730. player->item_list.RemoveItem(item, true);
  1731. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  1732. client->QueuePacket(player->SendInventoryUpdate(client->GetVersion()));
  1733. // force purge client cache and display updated spell for hover over
  1734. EQ2Packet* app = spell->SerializeSpell(client, false, false);
  1735. client->QueuePacket(app);
  1736. }
  1737. }
  1738. else
  1739. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown spell ID: %u and tier: %u", item->skill_info->spell_id, item->skill_info->spell_tier);
  1740. }
  1741. else if(item->generic_info.item_type == 7){
  1742. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Scribing recipe book %s (%u) for player %s.", item->name.c_str(), item->details.item_id, player->GetName());
  1743. Recipe* recipe_book = new Recipe(master_recipebook_list.GetRecipeBooks(item->details.item_id));
  1744. // if valid recipe book and the player doesn't have it
  1745. if (recipe_book && recipe_book->GetLevel() > client->GetPlayer()->GetTSLevel()) {
  1746. client->Message(CHANNEL_NARRATIVE, "Your tradeskill level is not high enough to scribe this book.");
  1747. safe_delete(recipe_book);
  1748. }
  1749. else if (recipe_book && !(client->GetPlayer()->GetRecipeBookList()->HasRecipeBook(item->details.item_id))) {
  1750. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Valid recipe book that the player doesn't have");
  1751. // Add recipe book to the players list
  1752. client->GetPlayer()->GetRecipeBookList()->AddRecipeBook(recipe_book);
  1753. // Get a list of all recipes this book contains
  1754. vector<Recipe*>* book_recipes = master_recipe_list.GetRecipes(recipe_book->GetBookName());
  1755. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "%i recipes found for %s book", book_recipes->size(), recipe_book->GetBookName());
  1756. // Create the packet to send to update the players recipe list
  1757. PacketStruct* packet = 0;
  1758. if (client->GetRecipeListSent()) {
  1759. packet = configReader.getStruct("WS_RecipeList", client->GetVersion());
  1760. if (packet)
  1761. packet->setArrayLengthByName("num_recipes", book_recipes->size());
  1762. }
  1763. // loop through the list
  1764. vector<Recipe*>::iterator itr;
  1765. int16 i = 0;
  1766. for (itr = book_recipes->begin(); itr != book_recipes->end(); itr++) {
  1767. // check to see if the player already has this recipe some how
  1768. if (!client->GetPlayer()->GetRecipeList()->GetRecipe((*itr)->GetID())) {
  1769. // Player doesn't already have this recipe so lets add it
  1770. Recipe* recipe = new Recipe(master_recipe_list.GetRecipe((*itr)->GetID()));
  1771. client->GetPlayer()->GetRecipeList()->AddRecipe(recipe);
  1772. database.SavePlayerRecipe(client->GetPlayer(), recipe->GetID());
  1773. client->Message(CHANNEL_NARRATIVE, "Recipe: \"%s\" put in recipe book.", recipe->GetName());
  1774. if (packet && client->GetRecipeListSent()) {
  1775. packet->setArrayDataByName("id", recipe->GetID(), i);
  1776. packet->setArrayDataByName("tier", recipe->GetTier(), i);
  1777. packet->setArrayDataByName("level", recipe->GetLevel(), i);
  1778. packet->setArrayDataByName("icon", recipe->GetIcon(), i);
  1779. packet->setArrayDataByName("classes", recipe->GetClasses(), i);
  1780. packet->setArrayDataByName("skill", recipe->GetSkill(), i);
  1781. packet->setArrayDataByName("technique", recipe->GetTechnique(), i);
  1782. packet->setArrayDataByName("knowledge", recipe->GetKnowledge(), i);
  1783. packet->setArrayDataByName("unknown2", recipe->GetUnknown2(), i);
  1784. packet->setArrayDataByName("recipe_name", recipe->GetName(), i);
  1785. packet->setArrayDataByName("recipe_book", recipe->GetBook(), i);
  1786. packet->setArrayDataByName("unknown3", recipe->GetUnknown3(), i);
  1787. i++;
  1788. }
  1789. }
  1790. }
  1791. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Done adding recipes");
  1792. database.SavePlayerRecipeBook(client->GetPlayer(), recipe_book->GetBookID());
  1793. database.DeleteItem(client->GetCharacterID(), item, 0);
  1794. client->GetPlayer()->item_list.RemoveItem(item, true);
  1795. client->QueuePacket(client->GetPlayer()->SendInventoryUpdate(client->GetVersion()));
  1796. if (packet && client->GetRecipeListSent())
  1797. client->QueuePacket(packet->serialize());
  1798. safe_delete(packet);
  1799. }
  1800. else {
  1801. if (recipe_book)
  1802. client->Message(CHANNEL_NARRATIVE, "You have already learned all you can from this item.");
  1803. safe_delete(recipe_book);
  1804. }
  1805. }
  1806. }
  1807. else
  1808. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown unique item ID: %s", sep->arg[0]);
  1809. }
  1810. break;
  1811. }
  1812. case COMMAND_SUMMONITEM: {
  1813. if (sep && sep->IsNumber(0)) {
  1814. int32 item_id = atol(sep->arg[0]);
  1815. int32 quantity = 1;
  1816. if (sep->arg[1] && sep->IsNumber(1))
  1817. quantity = atoi(sep->arg[1]);
  1818. if (sep->arg[2] && strncasecmp(sep->arg[2], "bank", 4) == 0) {
  1819. client->AddItemToBank(item_id,quantity);
  1820. }
  1821. else {
  1822. client->AddItem(item_id, quantity);
  1823. }
  1824. }
  1825. else {
  1826. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} [quantity] or");
  1827. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} {quantity} [location] where location = bank");
  1828. }
  1829. break;
  1830. }
  1831. case COMMAND_COLLECTION_ADDITEM: {
  1832. // takes 2 params: collection_id, slot
  1833. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  1834. Item *item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(atoul(sep->arg[1]));
  1835. if (item)
  1836. client->HandleCollectionAddItem(atoul(sep->arg[0]), item);
  1837. else
  1838. 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]));
  1839. }
  1840. else
  1841. LogWrite(COLLECTION__ERROR, 0, "Collect", "Received command 'COMMAND_COLLECTION_ADDITEM' with unhandeled argument types");
  1842. break;
  1843. }
  1844. case COMMAND_COLLECTION_FILTER_MATCHITEM: {
  1845. // takes 1 param: slot
  1846. printf("COMMAND_COLLECTION_FILTER_MATCHITEM:\n");
  1847. int i = 0;
  1848. while (sep->arg[i] && strlen(sep->arg[i]) > 0) {
  1849. printf("\t%u: %s\n", i, sep->arg[i]);
  1850. i++;
  1851. }
  1852. break;
  1853. }
  1854. case COMMAND_WAYPOINT: {
  1855. bool success = false;
  1856. client->ClearWaypoint();
  1857. if (sep && sep->IsNumber(0) && sep->IsNumber(1) && sep->IsNumber(2)) {
  1858. if (!client->ShowPathToTarget(atof(sep->arg[0]), atof(sep->arg[1]), atof(sep->arg[2]), 0))
  1859. client->Message(CHANNEL_COLOR_RED, "Invalid coordinates given");
  1860. }
  1861. else if ( client->GetAdminStatus() > 100 && cmdTarget ) {
  1862. if (!client->ShowPathToTarget(cmdTarget->GetX(), cmdTarget->GetY(), cmdTarget->GetZ(), 0))
  1863. client->Message(CHANNEL_COLOR_RED, "Invalid coordinates given");
  1864. }
  1865. else {
  1866. client->Message(CHANNEL_COLOR_YELLOW, "Usage: /waypoint x y z");
  1867. }
  1868. break;
  1869. }
  1870. case COMMAND_WHO:{
  1871. const char* who = 0;
  1872. if(sep && sep->arg[0]){
  1873. //cout << "Who query: \n";
  1874. who = sep->argplus[0];
  1875. //cout << who << endl;
  1876. }
  1877. zone_list.ProcessWhoQuery(who, client);
  1878. break;
  1879. }
  1880. case COMMAND_SELECT_JUNCTION:{
  1881. 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__);
  1882. int32 choice = 0;
  1883. if(sep && sep->arg[0] && sep->IsNumber(0))
  1884. choice = atoul(sep->arg[0]);
  1885. if(client->GetPlayer()->GetHP() == 0){ //dead and this is a revive request
  1886. client->HandlePlayerRevive(choice);
  1887. }
  1888. break;
  1889. }
  1890. case COMMAND_SPAWN_MOVE: {
  1891. if (cmdTarget && cmdTarget->IsPlayer() == false) {
  1892. PacketStruct* packet = configReader.getStruct("WS_MoveObjectMode", client->GetVersion());
  1893. if (packet) {
  1894. float unknown2_3 = 0;
  1895. int8 placement_mode = 0;
  1896. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::DEFAULT);
  1897. if (sep && sep->arg[0][0]) {
  1898. if (strcmp(sep->arg[0], "wall") == 0) {
  1899. placement_mode = 2;
  1900. unknown2_3 = 150;
  1901. }
  1902. else if (strcmp(sep->arg[0], "ceiling") == 0)
  1903. placement_mode = 1;
  1904. else if (strcmp(sep->arg[0], "openheading") == 0 && cmdTarget->IsWidget())
  1905. {
  1906. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "[PlacementMode] WIDGET OPEN HEADING MODE");
  1907. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::OPEN_HEADING);
  1908. }
  1909. else if (strcmp(sep->arg[0], "closeheading") == 0 && cmdTarget->IsWidget())
  1910. {
  1911. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "[PlacementMode] WIDGET CLOSE HEADING MODE");
  1912. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::CLOSE_HEADING);
  1913. }
  1914. else if (strcmp(sep->arg[0], "myloc") == 0)
  1915. {
  1916. if (cmdTarget->GetSpawnLocationPlacementID() < 1) {
  1917. client->Message(CHANNEL_COLOR_YELLOW, "[PlacementMode] Spawn %s cannot be moved it is not assigned a spawn location placement id.", cmdTarget->GetName());
  1918. safe_delete(packet);
  1919. break;
  1920. }
  1921. cmdTarget->SetX(client->GetPlayer()->GetX(), true);
  1922. cmdTarget->SetY(client->GetPlayer()->GetY(), true);
  1923. cmdTarget->SetZ(client->GetPlayer()->GetZ(), true);
  1924. cmdTarget->SetHeading(client->GetPlayer()->GetHeading(), true);
  1925. if (database.UpdateSpawnLocationSpawns(cmdTarget))
  1926. client->Message(CHANNEL_COLOR_YELLOW, "[PlacementMode] Spawn %s placed at your location. Updated spawn_location_placement for spawn.", cmdTarget->GetName());
  1927. safe_delete(packet);
  1928. break;
  1929. }
  1930. }
  1931. packet->setDataByName("placement_mode", placement_mode);
  1932. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget));
  1933. packet->setDataByName("model_type", cmdTarget->GetModelType());
  1934. packet->setDataByName("unknown", 1); //size
  1935. packet->setDataByName("unknown2", 1); //size 2
  1936. packet->setDataByName("unknown2", .5, 1); //size 3
  1937. packet->setDataByName("unknown2", 3, 2);
  1938. packet->setDataByName("unknown2", unknown2_3, 3);
  1939. packet->setDataByName("max_distance", 500);
  1940. packet->setDataByName("CoEunknown", 0xFFFFFFFF);
  1941. client->QueuePacket(packet->serialize());
  1942. safe_delete(packet);
  1943. }
  1944. }
  1945. else {
  1946. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /spawn move (wall OR ceiling)");
  1947. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Moves a spawn anywhere you like. Optionally wall/ceiling can be provided to place wall/ceiling items.");
  1948. }
  1949. break;
  1950. }
  1951. case COMMAND_HAIL:{
  1952. Spawn* spawn = cmdTarget;
  1953. if(spawn && spawn->GetTargetable())
  1954. {
  1955. char tmp[75] = {0};
  1956. sprintf(tmp, "Hail, %s", spawn->GetName());
  1957. bool show_bubble = true;
  1958. if (spawn->IsNPC())
  1959. show_bubble = false;
  1960. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp, HEAR_SPAWN_DISTANCE, 0, show_bubble);
  1961. if(spawn->IsPlayer() == false && spawn->GetDistance(client->GetPlayer()) < rule_manager.GetGlobalRule(R_Spawn, HailDistance)->GetInt32()){
  1962. if(spawn->IsNPC() && ((NPC*)spawn)->EngagedInCombat())
  1963. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED_BUSY, client->GetPlayer());
  1964. else
  1965. {
  1966. bool pauseRunback = false;
  1967. // prime runback as the heading or anything can be altered when hailing succeeds
  1968. if(spawn->IsNPC() && (spawn->HasMovementLoop() || spawn->HasMovementLocations()))
  1969. {
  1970. ((NPC*)spawn)->StartRunback();
  1971. pauseRunback = true;
  1972. }
  1973. if(spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED, client->GetPlayer()) && pauseRunback)
  1974. spawn->PauseMovement(rule_manager.GetGlobalRule(R_Spawn, HailMovementPause)->GetInt32());
  1975. else if(spawn->IsNPC() && pauseRunback)
  1976. ((NPC*)spawn)->ClearRunback();
  1977. }
  1978. }
  1979. }
  1980. else {
  1981. string tmp = "Hail";
  1982. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp.c_str(), HEAR_SPAWN_DISTANCE, 0, true);
  1983. }
  1984. break;
  1985. }
  1986. case COMMAND_SAY:{
  1987. if (sep && sep->arg[0][0]) {
  1988. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, sep->argplus[0], HEAR_SPAWN_DISTANCE);
  1989. if (cmdTarget && !(cmdTarget->IsPlayer()))
  1990. client->GetCurrentZone()->CallSpawnScript(cmdTarget, SPAWN_SCRIPT_HEAR_SAY, client->GetPlayer(), sep->argplus[0]);
  1991. }
  1992. else
  1993. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /say {message}");
  1994. break;
  1995. }
  1996. case COMMAND_TELL:{
  1997. if(sep && sep->arg[0] && sep->argplus[1]){
  1998. if(!zone_list.HandleGlobalChatMessage(client, sep->arg[0], CHANNEL_PRIVATE_TELL, sep->argplus[1]))
  1999. client->Message(CHANNEL_COLOR_RED,"Unable to find client %s",sep->arg[0]);
  2000. }else
  2001. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /tell {character_name} {message}");
  2002. break;
  2003. }
  2004. case COMMAND_SHOUT:{
  2005. if(sep && sep->arg[0][0])
  2006. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SHOUT, sep->argplus[0]);
  2007. else
  2008. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /shout {message}");
  2009. break;
  2010. }
  2011. case COMMAND_AUCTION:{
  2012. if(sep && sep->arg[0][0])
  2013. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_AUCTION, sep->argplus[0]);
  2014. else
  2015. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /auction {message}");
  2016. break;
  2017. }
  2018. case COMMAND_OOC:{
  2019. //For now ooc will be the global chat channel, eventually when we create more channels we will create a global chat channel
  2020. if(sep && sep->arg[0][0])
  2021. zone_list.HandleGlobalChatMessage(client, 0, CHANNEL_OUT_OF_CHARACTER, sep->argplus[0]);
  2022. else
  2023. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /ooc {message}");
  2024. break;
  2025. }
  2026. case COMMAND_EMOTE:{
  2027. if(sep && sep->arg[0][0])
  2028. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_EMOTE, sep->argplus[0]);
  2029. else
  2030. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /emote {action}");
  2031. break;
  2032. }
  2033. case COMMAND_RACE:{
  2034. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  2035. if(sep->arg[1][0] && sep->IsNumber(1)){
  2036. client->GetPlayer()->GetInfoStruct()->set_race(atoi(sep->arg[1]));
  2037. client->GetPlayer()->SetRace(atoi(sep->arg[1]));
  2038. client->UpdateTimeStampFlag ( RACE_UPDATE_FLAG );
  2039. client->GetPlayer()->SetCharSheetChanged(true);
  2040. }
  2041. client->GetPlayer()->SetModelType(atoi(sep->arg[0]));
  2042. //EQ2Packet* outapp = client->GetPlayer()->spawn_update_packet(client->GetPlayer(), client->GetVersion(), client->GetPlayer()->GetFeatures());
  2043. //client->QueuePacket(outapp);
  2044. }
  2045. else{
  2046. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /race {race type id} {race id}");
  2047. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "{race id} is optional");
  2048. }
  2049. break;
  2050. }
  2051. case COMMAND_BANK_DEPOSIT:{
  2052. if(client->GetBanker() && sep && sep->arg[0]){
  2053. int64 amount = 0;
  2054. string deposit = string(sep->arg[0]);
  2055. amount = atoi64(deposit.c_str());
  2056. client->BankDeposit(amount);
  2057. }
  2058. break;
  2059. }
  2060. case COMMAND_BANK_WITHDRAWAL:{
  2061. if(client->GetBanker() && sep && sep->arg[0] && sep->IsNumber(0)){
  2062. int64 amount = 0;
  2063. string deposit = string(sep->arg[0]);
  2064. amount = atoi64(deposit.c_str());
  2065. client->BankWithdrawal(amount);
  2066. }
  2067. break;
  2068. }
  2069. case COMMAND_BANK_CANCEL:{
  2070. Spawn* banker = cmdTarget;
  2071. client->Bank(banker, true);
  2072. break;
  2073. }
  2074. case COMMAND_BANK:{
  2075. LogWrite(PLAYER__DEBUG, 0, "Players", "Open Player Personal Bank...");
  2076. Spawn* banker = cmdTarget;
  2077. client->Bank(banker);
  2078. break;
  2079. }
  2080. case COMMAND_GUILD_BANK:{
  2081. LogWrite(GUILD__DEBUG, 0, "Guilds", "Open Guild Bank...");
  2082. //Spawn* banker = client->GetPlayer()->GetTarget();
  2083. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will eventually open the guild bank!");
  2084. break;
  2085. }
  2086. case COMMAND_START_MAIL: {
  2087. client->SetMailTransaction(cmdTarget);
  2088. client->SendMailList();
  2089. break;
  2090. }
  2091. case COMMAND_CANCEL_MAIL: {
  2092. client->SetMailTransaction(0);
  2093. break;
  2094. }
  2095. case COMMAND_GET_MAIL_MESSAGE: {
  2096. if (sep && sep->arg[0] && sep->IsNumber(0))
  2097. client->DisplayMailMessage(atoul(sep->arg[0]));
  2098. break;
  2099. }
  2100. case COMMAND_ADD_MAIL_PLAT: {
  2101. if (sep && sep->arg[0] && sep->IsNumber(0))
  2102. client->AddMailCoin(0, 0, 0, atoul(sep->arg[0]));
  2103. break;
  2104. }
  2105. case COMMAND_ADD_MAIL_GOLD: {
  2106. if (sep && sep->arg[0] && sep->IsNumber(0))
  2107. client->AddMailCoin(0, 0, atoul(sep->arg[0]));
  2108. break;
  2109. }
  2110. case COMMAND_ADD_MAIL_SILVER: {
  2111. if (sep && sep->arg[0] && sep->IsNumber(0))
  2112. client->AddMailCoin(0, atoul(sep->arg[0]));
  2113. break;
  2114. }
  2115. case COMMAND_ADD_MAIL_COPPER: {
  2116. if (sep && sep->arg[0] && sep->IsNumber(0))
  2117. client->AddMailCoin(atoul(sep->arg[0]));
  2118. break;
  2119. }
  2120. case COMMAND_SET_MAIL_ITEM: {
  2121. if(sep && sep->IsNumber(0) && sep->IsNumber(2))
  2122. {
  2123. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(atoul(sep->arg[0]));
  2124. if(item)
  2125. {
  2126. int16 quantity = atoul(sep->arg[1]);
  2127. if(item->CheckFlag(NO_TRADE) || item->CheckFlag(ATTUNED) || item->CheckFlag(ARTIFACT) || item->CheckFlag2(HEIRLOOM))
  2128. {
  2129. return;
  2130. }
  2131. if(item->IsBag())
  2132. {
  2133. vector<Item*>* bag_items = player->GetPlayerItemList()->GetItemsInBag(item);
  2134. if(bag_items && bag_items->size() > 0)
  2135. {
  2136. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot mail a bag with items inside it.");
  2137. safe_delete(bag_items);
  2138. return;
  2139. }
  2140. safe_delete(bag_items);
  2141. }
  2142. Item* itemtoadd = item;
  2143. if(quantity > 0)
  2144. {
  2145. if(quantity > item->details.count)
  2146. return;
  2147. Item* tmpItem = new Item(item);
  2148. tmpItem->details.count = quantity;
  2149. itemtoadd = tmpItem;
  2150. }
  2151. if(client->AddMailItem(itemtoadd))
  2152. {
  2153. client->RemoveItem(item, quantity, true);
  2154. }
  2155. }
  2156. }
  2157. break;
  2158. }
  2159. case COMMAND_REMOVE_MAIL_PLAT: {
  2160. if (sep && sep->arg[0] && sep->IsNumber(0))
  2161. client->RemoveMailCoin(0, 0, 0, atoul(sep->arg[0]));
  2162. break;
  2163. }
  2164. case COMMAND_REMOVE_MAIL_GOLD: {
  2165. if (sep && sep->arg[0] && sep->IsNumber(0))
  2166. client->RemoveMailCoin(0, 0, atoul(sep->arg[0]));
  2167. break;
  2168. }
  2169. case COMMAND_REMOVE_MAIL_SILVER: {
  2170. if (sep && sep->arg[0] && sep->IsNumber(0))
  2171. client->RemoveMailCoin(0, atoul(sep->arg[0]));
  2172. break;
  2173. }
  2174. case COMMAND_REMOVE_MAIL_COPPER: {
  2175. if (sep && sep->arg[0] && sep->IsNumber(0))
  2176. client->RemoveMailCoin(atoul(sep->arg[0]));
  2177. break;
  2178. }
  2179. case COMMAND_TAKE_MAIL_ATTACHMENTS: {
  2180. if (sep && sep->arg[0] && sep->IsNumber(0))
  2181. client->TakeMailAttachments(atoul(sep->arg[0]));
  2182. break;
  2183. }
  2184. case COMMAND_CANCEL_SEND_MAIL: {
  2185. client->ResetSendMail();
  2186. break;
  2187. }
  2188. case COMMAND_DELETE_MAIL_MESSAGE: {
  2189. if (sep && sep->arg[0] && sep->IsNumber(0))
  2190. client->DeleteMail(atoul(sep->arg[0]), true);
  2191. break;
  2192. }
  2193. case COMMAND_REPORT_SPAM: {
  2194. LogWrite(MISC__TODO, 1, "TODO", " received reportspam\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  2195. if (sep && sep->arg[0]) LogWrite(COMMAND__DEBUG, 0, "Command", "%s\n", sep->argplus[0]);
  2196. break;
  2197. }
  2198. case COMMAND_KILL:{
  2199. Spawn* dead = 0;
  2200. if (sep && sep->arg[0] && strncasecmp(sep->arg[0],"self",4)==0){
  2201. dead=client->GetPlayer();
  2202. client->GetPlayer()->SetHP(0);
  2203. client->GetPlayer()->KillSpawn(dead);
  2204. }else{
  2205. dead= cmdTarget;
  2206. if(dead && dead->IsPlayer() == false){
  2207. dead->SetHP(0);
  2208. if(sep && sep->arg[0] && sep->IsNumber(0) && atoi(sep->arg[0]) == 1)
  2209. client->GetCurrentZone()->RemoveSpawn(dead, true);
  2210. else
  2211. client->GetPlayer()->KillSpawn(dead);
  2212. }else{
  2213. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /kill (self)");
  2214. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Kills currently selected non-player target.");
  2215. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Optionally, self may be used to kill yourself");
  2216. }
  2217. }
  2218. break;
  2219. }
  2220. case COMMAND_LEVEL:{
  2221. if(sep && sep->arg[ndx][0] && sep->IsNumber(0)){
  2222. int16 new_level = atoi(sep->arg[ndx]);
  2223. if (!client->GetPlayer()->CheckLevelStatus(new_level))
  2224. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have the required status to level up anymore!");
  2225. else {
  2226. if (new_level < 1)
  2227. new_level = 1;
  2228. if (new_level > 255)
  2229. new_level = 255;
  2230. client->ChangeLevel(client->GetPlayer()->GetLevel(), new_level);
  2231. }
  2232. }else
  2233. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /level {new_level}");
  2234. break;
  2235. }
  2236. case COMMAND_SIT: {
  2237. LogWrite(MISC__TODO, 1, "TODO", " Send update packet to all clients\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  2238. if(client->GetPlayer()->GetHP() > 0){
  2239. client->QueuePacket(new EQ2Packet(OP_SitMsg, 0, 0));
  2240. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You sit down.");
  2241. client->GetPlayer()->set_character_flag(CF_IS_SITTING);
  2242. }
  2243. break;
  2244. }
  2245. case COMMAND_STAND: {
  2246. LogWrite(MISC__TODO, 1, "TODO", " Send update packet to all clients\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  2247. if(client->GetPlayer()->GetHP() > 0){
  2248. client->QueuePacket(new EQ2Packet(OP_StandMsg, 0, 0));
  2249. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You stand up.");
  2250. client->GetPlayer()->reset_character_flag(CF_IS_SITTING);
  2251. }
  2252. break;
  2253. }
  2254. case COMMAND_CLASS:{
  2255. if(sep && sep->arg[ndx][0]){
  2256. client->GetPlayer()->SetPlayerAdventureClass(atoi(sep->arg[ndx]));
  2257. client->UpdateTimeStampFlag ( CLASS_UPDATE_FLAG );
  2258. }else
  2259. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /class {class_id}");
  2260. break;
  2261. }
  2262. case COMMAND_GENDER:{
  2263. if(sep && sep->arg[ndx][0]){
  2264. client->GetPlayer()->GetInfoStruct()->set_gender(atoi(sep->arg[ndx]));
  2265. client->GetPlayer()->SetCharSheetChanged(true);
  2266. client->UpdateTimeStampFlag ( GENDER_UPDATE_FLAG );
  2267. }else{
  2268. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /gender {new_gender_id}");
  2269. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Male: 1");
  2270. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Female: 2");
  2271. }
  2272. break;
  2273. }
  2274. case COMMAND_FLYMODE:{
  2275. if(sep && sep->arg[0] && sep->IsNumber(0)){
  2276. PrintSep(sep, "COMMAND_FLYMODE");
  2277. int8 val = atoi(sep->arg[0]);
  2278. ClientPacketFunctions::SendFlyMode(client, val);
  2279. }
  2280. else{
  2281. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage ON: /flymode 1");
  2282. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage OFF: /flymode 0");
  2283. }
  2284. break;
  2285. }
  2286. case COMMAND_LOOT_LIST:{
  2287. Spawn* spawn = cmdTarget;
  2288. if(spawn && spawn->IsEntity()){
  2289. if (sep && sep->arg[0]) {
  2290. if (!spawn->GetDatabaseID())
  2291. {
  2292. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn has no database id to assign to loottables.");
  2293. break;
  2294. }
  2295. else if (!spawn->IsNPC())
  2296. {
  2297. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "these /loot list [add/remove/clearall] sub-commands are only designed for an NPC.");
  2298. break;
  2299. }
  2300. bool reloadLoot = false;
  2301. if (!stricmp(sep->arg[0], "remove") && sep->arg[1] && sep->IsNumber(1))
  2302. {
  2303. int32 loottable_id = atoul(sep->arg[1]);
  2304. if (loottable_id > 0 && database.RemoveSpawnLootTable(spawn, loottable_id))
  2305. {
  2306. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u loot table %u removed.", spawn->GetDatabaseID(), loottable_id);
  2307. reloadLoot = true;
  2308. }
  2309. else
  2310. client->Message(CHANNEL_COLOR_YELLOW, "/loot list remove [loottableid] - could not match any spawn_id entries against loottable_id %u.", loottable_id);
  2311. }
  2312. else if (!stricmp(sep->arg[0], "add") && sep->arg[1] && sep->IsNumber(1))
  2313. {
  2314. int32 loottable_id = atoul(sep->arg[1]);
  2315. if (loottable_id > 0)
  2316. {
  2317. database.AddLootTableToSpawn(spawn, loottable_id);
  2318. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u loot table %u added.", spawn->GetDatabaseID(), loottable_id);
  2319. reloadLoot = true;
  2320. }
  2321. else
  2322. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list add [loottableid] - cannot add a loottable id of 0.");
  2323. }
  2324. else if (!stricmp(sep->arg[0], "clearall"))
  2325. {
  2326. if (database.RemoveSpawnLootTable(spawn, 0))
  2327. {
  2328. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn loot tables removed.");
  2329. reloadLoot = true;
  2330. }
  2331. else
  2332. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list clearall - could not match any spawn_id entries in loottable_id.");
  2333. }
  2334. else
  2335. {
  2336. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list argument not supported.");
  2337. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list add [loottableid] - add new loottable to spawn");
  2338. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list remove [loottableid] - remove existing loottable from spawn");
  2339. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list clearall - remove all loottables from spawn");
  2340. break;
  2341. }
  2342. if (reloadLoot)
  2343. {
  2344. database.LoadSpawnLoot(spawn->GetZone(), spawn);
  2345. if (spawn->IsNPC())
  2346. {
  2347. Entity* ent = (Entity*)spawn;
  2348. ent->SetLootCoins(0);
  2349. ent->ClearLootList();
  2350. spawn->GetZone()->AddLoot((NPC*)spawn);
  2351. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u active loot purged and reloaded.", spawn->GetDatabaseID());
  2352. }
  2353. }
  2354. break; // nothing further this is the end of these sub commands
  2355. }
  2356. else
  2357. {
  2358. vector<int32> loot_list = client->GetCurrentZone()->GetSpawnLootList(spawn->GetDatabaseID(), spawn->GetZone()->GetZoneID(), spawn->GetLevel(), race_types_list.GetRaceType(spawn->GetModelType()), spawn);
  2359. if (loot_list.size() > 0) {
  2360. client->Message(CHANNEL_COLOR_YELLOW, "%s belongs to the following loot lists: ", spawn->GetName());
  2361. vector<int32>::iterator list_itr;
  2362. LootTable* table = 0;
  2363. for (list_itr = loot_list.begin(); list_itr != loot_list.end(); list_itr++) {
  2364. table = client->GetCurrentZone()->GetLootTable(*list_itr);
  2365. if (table)
  2366. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", *list_itr, table->name.c_str());
  2367. }
  2368. }
  2369. client->Message(CHANNEL_COLOR_YELLOW, "Coins being carried: %u", spawn->GetLootCoins());
  2370. vector<Item*>* items = spawn->GetLootItems();
  2371. if (items) {
  2372. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is carrying the following items: ");
  2373. vector<Item*>::iterator itr;
  2374. Item* item = 0;
  2375. for (itr = items->begin(); itr != items->end(); itr++) {
  2376. item = *itr;
  2377. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", item->details.item_id, item->name.c_str());
  2378. }
  2379. }
  2380. else
  2381. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is not carrying any items.");
  2382. }
  2383. }
  2384. break;
  2385. }
  2386. case COMMAND_LOOT_SETCOIN:{
  2387. Spawn* spawn = cmdTarget;
  2388. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2389. spawn->SetLootCoins(atoul(sep->arg[0]));
  2390. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully set coins.");
  2391. }
  2392. else
  2393. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot setcoin {amount}");
  2394. break;
  2395. }
  2396. case COMMAND_LOOT_ADDITEM:{
  2397. Spawn* spawn = cmdTarget;
  2398. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2399. int16 charges = 1;
  2400. if(sep->arg[1] && sep->IsNumber(1))
  2401. charges = atoi(sep->arg[1]);
  2402. spawn->AddLootItem(atoul(sep->arg[0]), charges);
  2403. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully added item.");
  2404. }
  2405. else
  2406. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot additem {item_id}");
  2407. break;
  2408. }
  2409. case COMMAND_LOOT_REMOVEITEM:{
  2410. Spawn* spawn = cmdTarget;
  2411. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2412. Item* item = spawn->LootItem(atoul(sep->arg[0]));
  2413. safe_delete(item);
  2414. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully removed item.");
  2415. }
  2416. else
  2417. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot removeitem {item_id}");
  2418. break;
  2419. }
  2420. case COMMAND_LOOT_CORPSE:
  2421. case COMMAND_DISARM:
  2422. case COMMAND_LOOT:{
  2423. if (cmdTarget && ((Entity*)cmdTarget)->IsNPC() && cmdTarget->Alive())
  2424. {
  2425. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is not dead.");
  2426. break;
  2427. }
  2428. if(cmdTarget && cmdTarget->IsEntity()){
  2429. if (cmdTarget->GetDistance(client->GetPlayer()) <= rule_manager.GetGlobalRule(R_Loot, LootRadius)->GetFloat()){
  2430. if (!rule_manager.GetGlobalRule(R_Loot, AutoDisarmChest)->GetBool() && command->handler == COMMAND_DISARM )
  2431. client->OpenChest(cmdTarget, true);
  2432. else
  2433. client->Loot(cmdTarget, rule_manager.GetGlobalRule(R_Loot, AutoDisarmChest)->GetBool());
  2434. if (!(cmdTarget)->HasLoot()){
  2435. if (((Entity*)cmdTarget)->IsNPC())
  2436. client->GetCurrentZone()->RemoveDeadSpawn(cmdTarget);
  2437. }
  2438. }
  2439. else
  2440. client->Message(CHANNEL_COLOR_YELLOW, "You are too far away to interact with that");
  2441. }
  2442. else if(!cmdTarget || cmdTarget->GetHP() > 0)
  2443. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid target.");
  2444. break;
  2445. }
  2446. case COMMAND_RELOADSPAWNSCRIPTS:{
  2447. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spawn Scripts....");
  2448. if (lua_interface)
  2449. lua_interface->SetSpawnScriptsReloading(true);
  2450. world.ResetSpawnScripts();
  2451. database.LoadSpawnScriptData();
  2452. if(lua_interface) {
  2453. lua_interface->DestroySpawnScripts();
  2454. lua_interface->SetSpawnScriptsReloading(false);
  2455. }
  2456. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Success!");
  2457. break;
  2458. }
  2459. case COMMAND_RELOADREGIONSCRIPTS:{
  2460. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Region Scripts....");
  2461. if(lua_interface) {
  2462. lua_interface->DestroyRegionScripts();
  2463. }
  2464. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Success!");
  2465. break;
  2466. }
  2467. case COMMAND_RELOADLUASYSTEM:{
  2468. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Attempting to reload entire LUA system....");
  2469. map<Client*, int32> debug_clients = lua_interface->GetDebugClients();
  2470. safe_delete(lua_interface);
  2471. lua_interface = new LuaInterface();
  2472. if(lua_interface)
  2473. lua_interface->SetSpawnScriptsReloading(true);
  2474. if(lua_interface && debug_clients.size() > 0){
  2475. map<Client*, int32>::iterator itr;
  2476. for(itr = debug_clients.begin(); itr != debug_clients .end(); itr++){
  2477. if(lua_interface)
  2478. lua_interface->UpdateDebugClients(itr->first);
  2479. }
  2480. }
  2481. world.ResetSpawnScripts();
  2482. database.LoadSpawnScriptData();
  2483. world.ResetZoneScripts();
  2484. database.LoadZoneScriptData();
  2485. int32 quest_count = database.LoadQuests();
  2486. zone_list.DeleteSpellProcess();
  2487. master_spell_list.Reload();
  2488. int32 spell_count = 0;
  2489. if(lua_interface) {
  2490. lua_interface->DestroySpawnScripts();
  2491. lua_interface->DestroySpells();
  2492. spell_count = database.LoadSpellScriptData();
  2493. lua_interface->SetSpawnScriptsReloading(false);
  2494. }
  2495. zone_list.LoadSpellProcess();
  2496. client->Message(CHANNEL_COLOR_YELLOW, "Successfully loaded %u spell(s), %u quest(s).", spell_count, quest_count);
  2497. break;
  2498. }
  2499. case COMMAND_DECLINE_QUEST:{
  2500. int32 quest_id = 0;
  2501. if(sep && sep->arg[0] && sep->IsNumber(0))
  2502. quest_id = atoul(sep->arg[0]);
  2503. if(quest_id > 0){
  2504. Quest* quest = client->GetPendingQuest(quest_id);
  2505. if(quest){
  2506. client->RemovePendingQuest(quest);
  2507. if(lua_interface)
  2508. lua_interface->CallQuestFunction(quest, "Declined", client->GetPlayer());
  2509. safe_delete(quest);
  2510. client->GetCurrentZone()->SendQuestUpdates(client);
  2511. }
  2512. }
  2513. break;
  2514. }
  2515. case COMMAND_DELETE_QUEST:{
  2516. int32 quest_id = 0;
  2517. if(sep && sep->arg[0] && sep->IsNumber(0))
  2518. quest_id = atoul(sep->arg[0]);
  2519. if(quest_id > 0){
  2520. if(lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0) {
  2521. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  2522. if (quest)
  2523. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  2524. }
  2525. client->RemovePlayerQuest(quest_id);
  2526. client->GetCurrentZone()->SendQuestUpdates(client);
  2527. }
  2528. break;
  2529. }
  2530. case COMMAND_ACCEPT_QUEST:{
  2531. int32 quest_id = 0;
  2532. if(sep && sep->arg[0] && sep->IsNumber(0))
  2533. quest_id = atoul(sep->arg[0]);
  2534. if(quest_id > 0){
  2535. client->AcceptQuest(quest_id);
  2536. }
  2537. break;
  2538. }
  2539. case COMMAND_NAME:{
  2540. if(sep && sep->arg[ndx][0]){
  2541. client->GetPlayer()->GetInfoStruct()->set_name(std::string(sep->arg[ndx]).substr(0,39));
  2542. client->GetPlayer()->SetCharSheetChanged(true);
  2543. }else
  2544. client->Message(CHANNEL_COLOR_YELLOW,"Usage: /name {new_name}");
  2545. break;
  2546. }
  2547. case COMMAND_GROUPSAY:{
  2548. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  2549. if(sep && sep->arg[0] && gmi)
  2550. world.GetGroupManager()->GroupChatMessage(gmi->group_id, client->GetPlayer(), sep->argplus[0]);
  2551. break;
  2552. }
  2553. case COMMAND_GROUPINVITE: {
  2554. Entity* target = 0;
  2555. Client* target_client = 0;
  2556. if (client->GetPlayer()->GetGroupMemberInfo() && !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  2557. client->SimpleMessage(CHANNEL_COMMANDS, "You must be the group leader to invite.");
  2558. return;
  2559. }
  2560. // name provided with command so it has to be a player, npc not supported here
  2561. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0){
  2562. target_client = zone_list.GetClientByCharName(sep->arg[0]);
  2563. if (target_client) {
  2564. if (!target_client->IsConnected() || !target_client->IsReadyForSpawns())
  2565. target = 0;
  2566. else
  2567. target = target_client->GetPlayer();
  2568. }
  2569. }
  2570. // if name was not provided use the players target, npc or player supported here
  2571. if (!target && client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  2572. target = (Entity*)client->GetPlayer()->GetTarget();
  2573. if (target->IsPlayer()) {
  2574. target_client = client->GetCurrentZone()->GetClientBySpawn(target);
  2575. }
  2576. }
  2577. int8 result = world.GetGroupManager()->Invite(client->GetPlayer(), target);
  2578. if (result == 0) {
  2579. client->Message(CHANNEL_COMMANDS, "You invite %s to group with you.", target->GetName());
  2580. if (target_client) {
  2581. PacketStruct* packet = configReader.getStruct("WS_ReceiveOffer", target_client->GetVersion());
  2582. if (packet) {
  2583. packet->setDataByName("type", 1);
  2584. packet->setDataByName("name", client->GetPlayer()->GetName());
  2585. packet->setDataByName("unknown2", 1);
  2586. target_client->QueuePacket(packet->serialize());
  2587. safe_delete(packet);
  2588. }
  2589. }
  2590. }
  2591. else if (result == 1)
  2592. client->SimpleMessage(CHANNEL_COMMANDS, "That player is already in a group.");
  2593. else if (result == 2)
  2594. client->SimpleMessage(CHANNEL_COMMANDS, "That player has been invited to another group.");
  2595. else if (result == 3)
  2596. client->SimpleMessage(CHANNEL_COMMANDS, "Your group is already full.");
  2597. else if (result == 4)
  2598. client->SimpleMessage(CHANNEL_COMMANDS, "You have a pending invitation, cancel it first.");
  2599. else if (result == 5)
  2600. client->SimpleMessage(CHANNEL_COMMANDS, "You cannot invite yourself!");
  2601. else if (result == 6)
  2602. client->SimpleMessage(CHANNEL_COMMANDS, "Could not locate the player.");
  2603. else
  2604. client->SimpleMessage(CHANNEL_COMMANDS, "Group invite failed, unknown error!");
  2605. break;
  2606. }
  2607. case COMMAND_GROUPDISBAND: {
  2608. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  2609. if (gmi) { // TODO: Leader check
  2610. // world.GetGroupManager()->SimpleGroupMessage(gmi->group_id, "Your group has been disbanded.");
  2611. world.GetGroupManager()->RemoveGroup(gmi->group_id);
  2612. }
  2613. break;
  2614. }
  2615. case COMMAND_GROUP_LEAVE: {
  2616. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  2617. if (gmi) {
  2618. int32 group_id = gmi->group_id;
  2619. world.GetGroupManager()->RemoveGroupMember(group_id, client->GetPlayer());
  2620. if (!world.GetGroupManager()->IsGroupIDValid(group_id)) {
  2621. // leader->Message(CHANNEL_COLOR_GROUP, "%s has left the group.", client->GetPlayer()->GetName());
  2622. }
  2623. else {
  2624. world.GetGroupManager()->GroupMessage(group_id, "%s has left the group.", client->GetPlayer()->GetName());
  2625. }
  2626. client->SimpleMessage(CHANNEL_GROUP_CHAT, "You have left the group");
  2627. }
  2628. break;
  2629. }
  2630. case COMMAND_FRIEND_ADD:{
  2631. string name = "";
  2632. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2633. name = database.GetPlayerName(sep->arg[0]);
  2634. else if(cmdTarget && cmdTarget->IsPlayer())
  2635. name = string(cmdTarget->GetName());
  2636. if(name.length() > 0){
  2637. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  2638. if(client->GetPlayer()->IsIgnored(name.c_str())){
  2639. client->GetPlayer()->RemoveIgnore(name.c_str());
  2640. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  2641. client->SendChatRelationship(3, name.c_str());
  2642. }
  2643. client->GetPlayer()->AddFriend(name.c_str(), true);
  2644. client->SendChatRelationship(0, name.c_str());
  2645. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added friend: %s", name.c_str());
  2646. if(zone_list.GetClientByCharName(name))
  2647. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Friend: %s has logged in.", name.c_str());
  2648. }
  2649. else
  2650. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot be more friendly towards yourself!");
  2651. }
  2652. else
  2653. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  2654. break;
  2655. }
  2656. case COMMAND_FRIEND_REMOVE:{
  2657. string name = "";
  2658. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2659. name = database.GetPlayerName(sep->arg[0]);
  2660. else if(cmdTarget && cmdTarget->IsPlayer())
  2661. name = string(cmdTarget->GetName());
  2662. if(name.length() > 0){
  2663. client->GetPlayer()->RemoveFriend(name.c_str());
  2664. client->SendChatRelationship(1, name.c_str());
  2665. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  2666. }
  2667. else
  2668. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  2669. break;
  2670. }
  2671. case COMMAND_FRIENDS:{
  2672. break;
  2673. }
  2674. case COMMAND_IGNORE_ADD:{
  2675. string name = "";
  2676. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2677. name = database.GetPlayerName(sep->arg[0]);
  2678. else if(cmdTarget && cmdTarget->IsPlayer())
  2679. name = string(cmdTarget->GetName());
  2680. if(name.length() > 0){
  2681. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  2682. if(client->GetPlayer()->IsFriend(name.c_str())){
  2683. client->GetPlayer()->RemoveFriend(name.c_str());
  2684. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  2685. client->SendChatRelationship(1, name.c_str());
  2686. }
  2687. client->GetPlayer()->AddIgnore(name.c_str(), true);
  2688. client->SendChatRelationship(2, name.c_str());
  2689. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added ignore: %s", name.c_str());
  2690. }
  2691. else
  2692. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot ignore yourself!");
  2693. }
  2694. else
  2695. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  2696. break;
  2697. }
  2698. case COMMAND_IGNORE_REMOVE:{
  2699. string name = "";
  2700. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2701. name = database.GetPlayerName(sep->arg[0]);
  2702. else if(cmdTarget && cmdTarget->IsPlayer())
  2703. name = string(cmdTarget->GetName());
  2704. if(name.length() > 0){
  2705. client->GetPlayer()->RemoveIgnore(name.c_str());
  2706. client->SendChatRelationship(3, name.c_str());
  2707. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  2708. }
  2709. break;
  2710. }
  2711. case COMMAND_IGNORES:{
  2712. break;
  2713. }
  2714. case COMMAND_GROUP_KICK:{
  2715. Entity* kicked = 0;
  2716. Client* kicked_client = 0;
  2717. int32 group_id = 0;
  2718. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader)
  2719. return;
  2720. LogWrite(MISC__TODO, 0, "TODO", "Add a check to see if the client using the command (COMMAND_GROUP_KICK) is the group leader");
  2721. if (sep && sep->arg[0]) {
  2722. kicked_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  2723. if (kicked_client)
  2724. kicked = kicked_client->GetPlayer();
  2725. }
  2726. else if (cmdTarget && cmdTarget->IsEntity()) {
  2727. kicked = (Entity*)cmdTarget;
  2728. }
  2729. group_id = client->GetPlayer()->GetGroupMemberInfo()->group_id;
  2730. bool send_kicked_message = world.GetGroupManager()->GetGroupSize(group_id) > 2;
  2731. if (kicked)
  2732. world.GetGroupManager()->RemoveGroupMember(group_id, kicked);
  2733. if(send_kicked_message)
  2734. world.GetGroupManager()->GroupMessage(group_id, "%s was kicked from the group.", kicked->GetName());
  2735. else
  2736. client->Message(CHANNEL_GROUP_CHAT, "You kicked %s from the group", kicked->GetName());
  2737. if (kicked_client)
  2738. kicked_client->SimpleMessage(CHANNEL_GROUP_CHAT, "You were kicked from the group");
  2739. break;
  2740. }
  2741. case COMMAND_GROUP_MAKE_LEADER:{
  2742. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  2743. client->SimpleMessage(CHANNEL_COMMANDS, "You are not a group leader.");
  2744. return;
  2745. }
  2746. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 1) {
  2747. Client* new_leader = zone_list.GetClientByCharName(sep->arg[0]);
  2748. if (new_leader) {
  2749. if (client->GetPlayer()->IsGroupMember(new_leader->GetPlayer())) {
  2750. world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, new_leader->GetPlayer());
  2751. }
  2752. }
  2753. else
  2754. client->SimpleMessage(CHANNEL_COMMANDS, "Unable to find the given player.");
  2755. }
  2756. else if (cmdTarget && cmdTarget->IsPlayer())
  2757. world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, (Entity*)cmdTarget);
  2758. else
  2759. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to change group leader.");
  2760. break;
  2761. }
  2762. case COMMAND_GROUP_ACCEPT_INVITE: {
  2763. if(sep && sep->arg[0] && strcmp(sep->arg[0], "group") == 0) {
  2764. int8 result = world.GetGroupManager()->AcceptInvite(client->GetPlayer());
  2765. if (result == 0)
  2766. client->SimpleMessage(CHANNEL_GROUP_CHAT, "You have joined the group.");
  2767. else if (result == 1)
  2768. client->SimpleMessage(CHANNEL_GROUP_CHAT, "You do not have a pending invite.");
  2769. else if (result == 2)
  2770. client->SimpleMessage(CHANNEL_GROUP_CHAT, "Unable to join group - could not find leader.");
  2771. else
  2772. client->SimpleMessage(CHANNEL_GROUP_CHAT, "Unable to join group - unknown error.");
  2773. }
  2774. break;
  2775. }
  2776. case COMMAND_GROUP_DECLINE_INVITE: {
  2777. if(sep && sep->arg[0] && strcmp(sep->arg[0], "group") == 0) {
  2778. world.GetGroupManager()->DeclineInvite(client->GetPlayer()); // TODO: Add message to leader
  2779. }
  2780. break;
  2781. }
  2782. case COMMAND_SUMMON:{
  2783. char* search_name = 0;
  2784. if(sep && sep->arg[0][0])
  2785. search_name = sep->arg[0];
  2786. if(!search_name && !cmdTarget){
  2787. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /summon [name]");
  2788. 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.");
  2789. }
  2790. else{
  2791. if(!client->Summon(search_name))
  2792. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  2793. }
  2794. break;
  2795. }
  2796. case COMMAND_GOTO:{
  2797. const char* search_name = 0;
  2798. if(sep && sep->arg[0][0])
  2799. search_name = sep->argplus[0];
  2800. if(!search_name && !cmdTarget){
  2801. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /goto [name]");
  2802. 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.");
  2803. }
  2804. else{
  2805. if(!client->GotoSpawn(search_name))
  2806. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  2807. }
  2808. break;
  2809. }
  2810. case COMMAND_MOVE:{
  2811. bool success = false;
  2812. try{
  2813. if(sep && sep->arg[2][0] && sep->IsNumber(0) && sep->IsNumber(1) && sep->IsNumber(2)){
  2814. EQ2Packet* app = client->GetPlayer()->Move(atof(sep->arg[0]), atof(sep->arg[1]), atof(sep->arg[2]), client->GetVersion());
  2815. if(app){
  2816. client->QueuePacket(app);
  2817. success = true;
  2818. }
  2819. }
  2820. }
  2821. catch(...){}
  2822. if(!success){
  2823. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /move x y z");
  2824. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Moves the client to the given coordinates.");
  2825. }
  2826. break;
  2827. }
  2828. case COMMAND_SETTIME:{
  2829. if(sep && sep->arg[0]){
  2830. sscanf (sep->arg[0], "%d:%d", &world.GetWorldTimeStruct()->hour, &world.GetWorldTimeStruct()->minute);
  2831. if(sep->arg[1] && sep->IsNumber(1))
  2832. world.GetWorldTimeStruct()->month = atoi(sep->arg[1]) - 1; //zero based indexes
  2833. if(sep->arg[2] && sep->IsNumber(2))
  2834. world.GetWorldTimeStruct()->day = atoi(sep->arg[2]) - 1; //zero based indexes
  2835. if(sep->arg[3] && sep->IsNumber(3))
  2836. world.GetWorldTimeStruct()->year = atoi(sep->arg[3]);
  2837. client->GetCurrentZone()->SendTimeUpdateToAllClients();
  2838. }
  2839. else{
  2840. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /settime [hour:minute] (month) (day) (year)");
  2841. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Example: /settime 8:30");
  2842. }
  2843. break;
  2844. }
  2845. case COMMAND_VERSION:{
  2846. client->Message(CHANNEL_COLOR_YELLOW,"%s %s", EQ2EMU_MODULE, CURRENT_VERSION);
  2847. client->Message(CHANNEL_COLOR_YELLOW,"Last Compiled on %s %s", COMPILE_DATE, COMPILE_TIME);
  2848. break;
  2849. }
  2850. case COMMAND_ZONE:{
  2851. int32 instanceID = 0;
  2852. string zone;
  2853. int32 zone_id = 0;
  2854. bool listSearch = false;
  2855. bool isInstance = false;
  2856. ZoneServer* zsZone = 0;
  2857. if(sep && sep->arg[0][0])
  2858. {
  2859. if(strncasecmp(sep->arg[0], "list", 4) == 0)
  2860. listSearch = true;
  2861. else if(strncasecmp(sep->arg[0], "active", 6) == 0)
  2862. {
  2863. zone_list.SendZoneList(client);
  2864. break;
  2865. }
  2866. else if(strncasecmp(sep->arg[0], "instance", 6) == 0)
  2867. {
  2868. if(sep->IsNumber(1))
  2869. instanceID = atol(sep->arg[1]);
  2870. }
  2871. else if(strncasecmp(sep->arg[0], "lock", 4) == 0)
  2872. {
  2873. PrintSep(sep, "ZONE LOCK");
  2874. if(sep->IsNumber(1))
  2875. zsZone = zone_list.Get(atoul(sep->arg[1]), false);
  2876. else
  2877. zsZone = zone_list.Get(sep->arg[1], false);
  2878. if( zsZone )
  2879. {
  2880. zsZone->SetZoneLockState(true);
  2881. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now locked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  2882. }
  2883. else
  2884. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be locked.", sep->arg[1]);
  2885. break;
  2886. }
  2887. else if(strncasecmp(sep->arg[0], "unlock", 6) == 0)
  2888. {
  2889. PrintSep(sep, "ZONE UNLOCK");
  2890. if(sep->IsNumber(1))
  2891. zsZone = zone_list.Get(atoul(sep->arg[1]), false);
  2892. else
  2893. zsZone = zone_list.Get(sep->arg[1], false);
  2894. if( zsZone )
  2895. {
  2896. zsZone->SetZoneLockState(false);
  2897. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now unlocked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  2898. }
  2899. else
  2900. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be unlocked.", sep->arg[1]);
  2901. break;
  2902. }
  2903. else
  2904. {
  2905. if(sep->IsNumber(0))
  2906. {
  2907. zone_id = atoul(sep->arg[0]);
  2908. string zonename = database.GetZoneName(zone_id);
  2909. if(zonename.length() > 0)
  2910. zone = zonename;
  2911. }
  2912. else
  2913. zone = sep->arg[0];
  2914. }
  2915. if(instanceID > 0)
  2916. {
  2917. ZoneServer* zsInstance = zone_list.GetByInstanceID(instanceID);
  2918. if(zsInstance != NULL)
  2919. {
  2920. instanceID = zsInstance->GetInstanceID();
  2921. zone = zsInstance->GetZoneName();
  2922. zone_id = zsInstance->GetZoneID();
  2923. isInstance = true;
  2924. }
  2925. }
  2926. }
  2927. if(!listSearch)
  2928. {
  2929. if(zone.length() == 0)
  2930. client->Message(CHANNEL_COLOR_RED, "Error: Invalid Zone");
  2931. else if(instanceID != client->GetCurrentZone()->GetInstanceID() ||
  2932. zone_id != client->GetCurrentZone()->GetZoneID())
  2933. {
  2934. const char* zonestr = zone.c_str();
  2935. if(database.VerifyZone(zonestr))
  2936. {
  2937. if(client->CheckZoneAccess(zonestr))
  2938. {
  2939. client->Message(CHANNEL_COLOR_YELLOW,"Zoning to %s...", zonestr);
  2940. if(isInstance)
  2941. client->Zone(instanceID,true,true);
  2942. else
  2943. client->Zone(zonestr);
  2944. }
  2945. }
  2946. else
  2947. client->Message(CHANNEL_COLOR_RED, "Error: Zone '%s' not found. To get a list type /zone list", zonestr);
  2948. }
  2949. else
  2950. client->Message(CHANNEL_COLOR_RED, "Error: You are already in that zone!");
  2951. }
  2952. else
  2953. {
  2954. const char* name = 0;
  2955. if(sep && sep->arg[1][0])
  2956. {
  2957. map<int32, string>* zone_names;
  2958. name = sep->argplus[1];
  2959. sint16 status = client->GetAdminStatus();
  2960. if( status > 0 )
  2961. {
  2962. client->SimpleMessage(CHANNEL_COLOR_RED, "ADMIN MODE");
  2963. zone_names = database.GetZoneList(name, true);
  2964. }
  2965. else
  2966. zone_names = database.GetZoneList(name);
  2967. if(!zone_names)
  2968. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No zones found.");
  2969. else
  2970. {
  2971. map<int32, string>::iterator itr;
  2972. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  2973. for(itr = zone_names->begin(); itr != zone_names->end(); itr++)
  2974. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  2975. safe_delete(zone_names);
  2976. }
  2977. }
  2978. else
  2979. {
  2980. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone [zone name]");
  2981. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone list [partial zone name]");
  2982. }
  2983. }
  2984. break;
  2985. }
  2986. case COMMAND_USE: {
  2987. Spawn* target = cmdTarget;
  2988. if (target && target->IsWidget())
  2989. ((Widget*)target)->HandleUse(client, "use");
  2990. break;
  2991. }
  2992. case COMMAND_OPEN: {
  2993. Spawn* target = cmdTarget;
  2994. if (target && target->IsWidget())
  2995. ((Widget*)target)->HandleUse(client, "Open", WIDGET_TYPE_DOOR);
  2996. break;
  2997. }
  2998. case COMMAND_CASTSPELL: {
  2999. if (sep && sep->arg[0] && sep->IsNumber(0))
  3000. {
  3001. int8 tier = 1;
  3002. if (sep->arg[1] && sep->IsNumber(1))
  3003. tier = atoul(sep->arg[1]);
  3004. int8 self = 1;
  3005. if (sep->arg[1] && sep->IsNumber(2))
  3006. {
  3007. self = atoul(sep->arg[2]);
  3008. if(self != 1 && !cmdTarget->IsEntity())
  3009. {
  3010. client->Message(CHANNEL_COLOR_RED, "Target is not an entity required to cast non-self spell.");
  3011. self = 1;
  3012. }
  3013. }
  3014. int32 spellid = atoul(sep->arg[0]);
  3015. Spell* spell = master_spell_list.GetSpell(spellid, tier);
  3016. if (spell)
  3017. {
  3018. client->Message(CHANNEL_COLOR_RED, "Casting spell %u.", spellid);
  3019. SpellProcess* spellProcess = 0;
  3020. // Get the current zones spell process
  3021. spellProcess = client->GetCurrentZone()->GetSpellProcess();
  3022. spellProcess->CastInstant(spell, (!cmdTarget || self == 1) ? (Entity*)client->GetPlayer() : (Entity*)cmdTarget, (cmdTarget && cmdTarget->IsEntity()) ? (Entity*)cmdTarget : (Entity*)client->GetPlayer());
  3023. }
  3024. else
  3025. {
  3026. client->Message(CHANNEL_COLOR_RED, "Could not find spell %u.",spellid);
  3027. }
  3028. }
  3029. else if (sep && sep->arg[0])
  3030. {
  3031. database.FindSpell(client, (char*)sep->argplus[0]);
  3032. }
  3033. else
  3034. {
  3035. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellid] (tier=1) - Cast Spell with specified spell id, tier is optional, default of 1.");
  3036. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellname] - Find spells wildcard match with a partial spell name");
  3037. }
  3038. break;
  3039. }
  3040. case COMMAND_KNOWLEDGEWINDOWSORT: {
  3041. if (client->GetVersion() <= 546)
  3042. break;
  3043. if (sep && sep->GetArgNumber() == 4)
  3044. {
  3045. int32 book = atoul(sep->arg[0]); // 0 - spells, 1 - combat, 2 - abilities, 3 - tradeskill
  3046. int32 sort_by = atoul(sep->arg[1]); // 0 - alpha, 1 - level, 2 - category
  3047. int32 order = atoul(sep->arg[2]); // 0 - ascending, 1 - descending
  3048. int32 pattern = atoul(sep->arg[3]); // 0 - zigzag, 1 - down, 2 - across
  3049. int32 maxlvlonly = atoul(sep->arg[4]); // 0 - zigzag, 1 - down, 2 - across
  3050. client->GetPlayer()->ResortSpellBook(sort_by, order, pattern, maxlvlonly, book);
  3051. ClientPacketFunctions::SendSkillSlotMappings(client);
  3052. }
  3053. else
  3054. {
  3055. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /knowledgewindow_sort [book] [sort_by] [order] [pattern]");
  3056. }
  3057. break;
  3058. }
  3059. case COMMAND_MOVE_ITEM:
  3060. {
  3061. int32 id = 0;
  3062. if (sep->IsNumber(0))
  3063. id = atoul(sep->arg[0]);
  3064. Spawn* spawn = 0;
  3065. if (id == 0)
  3066. {
  3067. spawn = cmdTarget;
  3068. }
  3069. else
  3070. spawn = client->GetCurrentZone()->GetSpawnFromUniqueItemID(id);
  3071. if (!spawn || !client->HasOwnerOrEditAccess() || !spawn->GetPickupItemID())
  3072. break;
  3073. client->SendMoveObjectMode(spawn, 0);
  3074. break;
  3075. }
  3076. case COMMAND_PICKUP:
  3077. {
  3078. int32 id = 0;
  3079. if (sep->IsNumber(0))
  3080. id = atoul(sep->arg[0]);
  3081. Spawn* spawn = 0;
  3082. if (id == 0)
  3083. {
  3084. spawn = cmdTarget;
  3085. }
  3086. else
  3087. spawn = client->GetCurrentZone()->GetSpawnFromUniqueItemID(id);
  3088. if (!spawn || !client->HasOwnerOrEditAccess() || !spawn->GetPickupItemID())
  3089. break;
  3090. client->AddItem(spawn->GetPickupItemID(), 1);
  3091. Query query;
  3092. 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());
  3093. if (database.RemoveSpawnFromSpawnLocation(spawn)) {
  3094. client->GetCurrentZone()->RemoveSpawn(spawn, true, true);
  3095. }
  3096. // we had a UI Window displayed, update the house items
  3097. if ( id > 0 )
  3098. client->GetCurrentZone()->SendHouseItems(client);
  3099. break;
  3100. }
  3101. case COMMAND_HOUSE_DEPOSIT:
  3102. {
  3103. PrintSep(sep, "COMMAND_HOUSE_DEPOSIT");
  3104. // arg0 = ??? (set to 3)
  3105. // arg1 = coin (in copper)
  3106. // arg2 = status? (not implemented yet)
  3107. PlayerHouse* ph = world.GetPlayerHouseByInstanceID(client->GetCurrentZone()->GetInstanceID());
  3108. if (ph && sep && sep->IsNumber(1))
  3109. {
  3110. int64 outValCoin = strtoull(sep->arg[1], NULL, 0);
  3111. int32 outValStatus = 0;
  3112. if(sep->IsNumber(2))
  3113. {
  3114. outValStatus = strtoull(sep->arg[2], NULL, 0);
  3115. if(outValStatus > client->GetPlayer()->GetInfoStruct()->get_status_points())
  3116. outValStatus = 0; // cheat check
  3117. }
  3118. if ((!outValCoin && outValStatus) || client->GetPlayer()->RemoveCoins(outValCoin))
  3119. {
  3120. if(outValStatus)
  3121. client->GetPlayer()->GetInfoStruct()->subtract_status_points(outValStatus);
  3122. char query[256];
  3123. map<string,Deposit>::iterator itr = ph->depositsMap.find(string(client->GetPlayer()->GetName()));
  3124. if (itr != ph->depositsMap.end())
  3125. {
  3126. snprintf(query, 256, "update character_house_deposits set timestamp = %u, amount = amount + %I64u, last_amount = %I64u, status = status + %u, last_status = %u where house_id = %u and instance_id = %u and name='%s'", Timer::GetUnixTimeStamp(), outValCoin, outValCoin, outValStatus, outValStatus, ph->house_id, ph->instance_id, client->GetPlayer()->GetName());
  3127. }
  3128. else
  3129. snprintf(query, 256, "insert into character_house_deposits set timestamp = %u, house_id = %u, instance_id = %u, name='%s', amount = %I64u, status = %u", Timer::GetUnixTimeStamp(), ph->house_id, ph->instance_id, client->GetPlayer()->GetName(), outValCoin, outValStatus);
  3130. if (database.RunQuery(query, strnlen(query, 256)))
  3131. {
  3132. ph->escrow_coins += outValCoin;
  3133. ph->escrow_status += outValStatus;
  3134. database.UpdateHouseEscrow(ph->house_id, ph->instance_id, ph->escrow_coins, ph->escrow_status);
  3135. database.LoadDeposits(ph);
  3136. client->PlaySound("coin_cha_ching");
  3137. HouseZone* hz = world.GetHouseZone(ph->house_id);
  3138. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  3139. }
  3140. else
  3141. {
  3142. if(outValCoin)
  3143. client->GetPlayer()->AddCoins(outValCoin);
  3144. if(outValStatus)
  3145. client->GetPlayer()->GetInfoStruct()->add_status_points(outValStatus);
  3146. client->SimpleMessage(CHANNEL_COLOR_RED, "Deposit failed!");
  3147. }
  3148. }
  3149. }
  3150. break;
  3151. }
  3152. case COMMAND_HOUSE:
  3153. {
  3154. if (sep && sep->IsNumber(0))
  3155. {
  3156. int32 unique_id = atoi(sep->arg[0]);
  3157. PlayerHouse* ph = world.GetPlayerHouseByUniqueID(unique_id);
  3158. HouseZone* hz = 0;
  3159. if (ph)
  3160. hz = world.GetHouseZone(ph->house_id);
  3161. // there is a arg[1] that is true/false, but not sure what it is for investigate more later
  3162. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  3163. }
  3164. else if (client->GetCurrentZone()->GetInstanceType() != 0)
  3165. {
  3166. // inside a house or something? Send the access window
  3167. PlayerHouse* ph = world.GetPlayerHouseByInstanceID(client->GetCurrentZone()->GetInstanceID());
  3168. HouseZone* hz = 0;
  3169. if ( ph )
  3170. hz = world.GetHouseZone(ph->house_id);
  3171. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  3172. client->GetCurrentZone()->SendHouseItems(client);
  3173. }
  3174. break;
  3175. }
  3176. case COMMAND_HOUSE_UI:
  3177. {
  3178. if (sep && sep->IsNumber(0) && client->GetCurrentZone()->GetInstanceType() == Instance_Type::NONE)
  3179. {
  3180. int32 unique_id = atoi(sep->arg[0]);
  3181. PlayerHouse* ph = world.GetPlayerHouseByUniqueID(unique_id);
  3182. HouseZone* hz = 0;
  3183. if ( ph )
  3184. hz = world.GetHouseZone(ph->house_id);
  3185. // there is a arg[1] that is true/false, but not sure what it is for investigate more later
  3186. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, 0);
  3187. }
  3188. break;
  3189. }
  3190. case COMMAND_PLACE_HOUSE_ITEM: {
  3191. if (sep && sep->IsNumber(0))
  3192. {
  3193. int32 uniqueid = atoi(sep->arg[0]);
  3194. Item* item = client->GetPlayer()->item_list.GetItemFromUniqueID(uniqueid);
  3195. //Item* item = player->GetEquipmentList()->GetItem(slot);
  3196. if (item && item->IsHouseItem())
  3197. {
  3198. if (!client->HasOwnerOrEditAccess())
  3199. {
  3200. client->SimpleMessage(CHANNEL_COLOR_RED, "This is not your home!");
  3201. break;
  3202. }
  3203. else if (!item->generic_info.appearance_id)
  3204. {
  3205. 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);
  3206. break;
  3207. }
  3208. if (client->GetTempPlacementSpawn())
  3209. {
  3210. Spawn* tmp = client->GetTempPlacementSpawn();
  3211. client->GetCurrentZone()->RemoveSpawn(tmp);
  3212. client->SetTempPlacementSpawn(nullptr);
  3213. }
  3214. Spawn* spawn = new Object();
  3215. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3216. spawn->SetID(Spawn::NextID());
  3217. spawn->SetX(client->GetPlayer()->GetX());
  3218. spawn->SetY(client->GetPlayer()->GetY());
  3219. spawn->SetZ(client->GetPlayer()->GetZ());
  3220. spawn->SetHeading(client->GetPlayer()->GetHeading());
  3221. spawn->SetSpawnOrigX(spawn->GetX());
  3222. spawn->SetSpawnOrigY(spawn->GetY());
  3223. spawn->SetSpawnOrigZ(spawn->GetZ());
  3224. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  3225. spawn->appearance.targetable = 1;
  3226. spawn->appearance.activity_status = ACTIVITY_STATUS_SOLID;
  3227. spawn->appearance.race = item && item->generic_info.appearance_id ? item->generic_info.appearance_id : 1472;
  3228. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  3229. spawn->SetModelType(item && item->generic_info.appearance_id ? item->generic_info.appearance_id : 1472);
  3230. spawn->SetZone(client->GetCurrentZone());
  3231. client->GetCurrentZone()->SendSpawn(spawn, client);
  3232. client->SetTempPlacementSpawn(spawn);
  3233. client->SetPlacementUniqueItemID(uniqueid);
  3234. client->SendMoveObjectMode(spawn, 0);
  3235. }
  3236. }
  3237. break;
  3238. }
  3239. case COMMAND_GM:
  3240. {
  3241. if (sep && sep->arg[0] && sep->arg[1])
  3242. {
  3243. bool onOff = (strcmp(sep->arg[1], "on") == 0);
  3244. if (strcmp(sep->arg[0], "vision") == 0)
  3245. {
  3246. client->GetPlayer()->SetGMVision(onOff);
  3247. #if defined(__GNUC__)
  3248. database.insertCharacterProperty(client, CHAR_PROPERTY_GMVISION, (onOff) ? (char*)"1" : (char*)"0");
  3249. #else
  3250. database.insertCharacterProperty(client, CHAR_PROPERTY_GMVISION, (onOff) ? "1" : "0");
  3251. #endif
  3252. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  3253. if (onOff)
  3254. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Vision Enabled!");
  3255. else
  3256. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Vision Disabled!");
  3257. }
  3258. else if (strcmp(sep->arg[0], "regiondebug") == 0)
  3259. {
  3260. client->SetRegionDebug(onOff);
  3261. #if defined(__GNUC__)
  3262. database.insertCharacterProperty(client, CHAR_PROPERTY_REGIONDEBUG, (onOff) ? (char*)"1" : (char*)"0");
  3263. #else
  3264. database.insertCharacterProperty(client, CHAR_PROPERTY_REGIONDEBUG, (onOff) ? "1" : "0");
  3265. #endif
  3266. if (onOff)
  3267. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Region Debug Enabled!");
  3268. else
  3269. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Region Debug Disabled!");
  3270. }
  3271. else if (strcmp(sep->arg[0], "luadebug") == 0)
  3272. {
  3273. client->SetLuaDebugClient(onOff);
  3274. #if defined(__GNUC__)
  3275. database.insertCharacterProperty(client, CHAR_PROPERTY_LUADEBUG, (onOff) ? (char*)"1" : (char*)"0");
  3276. #else
  3277. database.insertCharacterProperty(client, CHAR_PROPERTY_LUADEBUG, (onOff) ? "1" : "0");
  3278. #endif
  3279. if (onOff)
  3280. {
  3281. if (lua_interface)
  3282. lua_interface->UpdateDebugClients(client);
  3283. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will now receive LUA error messages.");
  3284. }
  3285. else
  3286. {
  3287. if (lua_interface)
  3288. lua_interface->RemoveDebugClients(client);
  3289. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will no longer receive LUA error messages.");
  3290. }
  3291. }
  3292. }
  3293. break;
  3294. }
  3295. case COMMAND_ATTACK:
  3296. case COMMAND_AUTO_ATTACK:{
  3297. int8 type = 1;
  3298. Player* player = client->GetPlayer();
  3299. if(!player)
  3300. break;
  3301. bool incombat = player->EngagedInCombat();
  3302. if(sep && sep->arg[0] && sep->IsNumber(0))
  3303. type = atoi(sep->arg[0]);
  3304. if(client->GetPlayer()->GetHP() == 0){
  3305. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  3306. break;
  3307. }
  3308. if(type == 0){
  3309. if(incombat)
  3310. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You stop fighting.");
  3311. player->StopCombat(type);
  3312. }
  3313. else {
  3314. if(type == 2){
  3315. player->InCombat(false);
  3316. if(incombat && player->GetRangeAttack()){
  3317. player->StopCombat(type);
  3318. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You stop fighting.");
  3319. }
  3320. else{
  3321. player->SetRangeAttack(true);
  3322. player->InCombat(true, true);
  3323. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You start fighting.");
  3324. }
  3325. }
  3326. else {
  3327. player->InCombat(false, true);
  3328. player->SetRangeAttack(false);
  3329. player->InCombat(true);
  3330. if(!incombat)
  3331. client->SimpleMessage(CHANNEL_GENERAL_COMBAT, "You start fighting.");
  3332. }
  3333. /*else
  3334. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You cannot attack that!");*/
  3335. }
  3336. player->SetCharSheetChanged(true);
  3337. break;
  3338. }
  3339. case COMMAND_DEPOP:{
  3340. bool allow_respawns = false;
  3341. if(sep && sep->arg[0] && sep->IsNumber(0)){
  3342. if(atoi(sep->arg[0]) == 1)
  3343. allow_respawns = true;
  3344. }
  3345. client->GetCurrentZone()->Depop(allow_respawns);
  3346. break;
  3347. }
  3348. case COMMAND_REPOP:{
  3349. client->GetCurrentZone()->Depop(false, true);
  3350. break;
  3351. }
  3352. case COMMAND_BUYBACK:{
  3353. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  3354. // 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
  3355. int64 id = atoi64(sep->arg[0]);
  3356. // get the first int32, the item id
  3357. //int32 item_id = (int32)id;
  3358. // get the second int32, the unique id
  3359. int32 unique_id = (int32)(id>>32);
  3360. int8 quantity = atoi(sep->arg[1]);
  3361. if(quantity == 255)
  3362. quantity = 1;
  3363. client->BuyBack(unique_id, quantity);
  3364. }
  3365. break;
  3366. }
  3367. case COMMAND_MERCHANT_BUY:{
  3368. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  3369. int32 item_id = atoul(sep->arg[0]);
  3370. int8 quantity = atoi(sep->arg[1]);
  3371. client->BuyItem(item_id, quantity);
  3372. }
  3373. else
  3374. Command_SendMerchantWindow(client, sep);
  3375. break;
  3376. }
  3377. case COMMAND_MERCHANT_SELL:{
  3378. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  3379. // 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
  3380. int64 id = atoi64(sep->arg[0]);
  3381. // get the first int32, the item id
  3382. int32 item_id = (int32)id;
  3383. // get the second int32, the unique id
  3384. int32 unique_id = (int32)(id>>32);
  3385. int8 quantity = atoi(sep->arg[1]);
  3386. LogWrite(MERCHANT__DEBUG, 0, "Merchant", "Selling Item: Item Id = %ul, unique id = %ul, Quantity = %i", item_id, unique_id, quantity);
  3387. client->SellItem(item_id, quantity, unique_id);
  3388. }
  3389. break;
  3390. }
  3391. case COMMAND_MENDER_REPAIR: {
  3392. if (sep && sep->arg[0] && sep->IsNumber(0))
  3393. client->RepairItem(atoul(sep->arg[0]));
  3394. break;
  3395. }
  3396. case COMMAND_MENDER_REPAIR_ALL: {
  3397. client->RepairAllItems();
  3398. break;
  3399. }
  3400. case COMMAND_CANCEL_MERCHANT:{
  3401. client->SetMerchantTransaction(0);
  3402. break;
  3403. }
  3404. case COMMAND_START_MERCHANT:{
  3405. break;
  3406. }
  3407. case COMMAND_INVULNERABLE:{
  3408. sint8 val = -1;
  3409. if(sep && sep->arg[0] && sep->IsNumber(0)){
  3410. val = atoi(sep->arg[0]);
  3411. //devn00b: Fix for linux builds
  3412. #if defined(__GNUC__)
  3413. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? (char*) "1" : (char*) "0");
  3414. #else
  3415. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  3416. #endif
  3417. // database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  3418. client->GetPlayer()->SetInvulnerable(val==1);
  3419. if(client->GetPlayer()->GetInvulnerable())
  3420. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are now invulnerable!");
  3421. else
  3422. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are no longer invulnerable!");
  3423. }
  3424. if(val == -1)
  3425. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /invulnerable [0/1]");
  3426. break;
  3427. }
  3428. case COMMAND_REPAIR: {
  3429. Spawn* spawn = cmdTarget;
  3430. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR) {
  3431. client->SendHailCommand(spawn);
  3432. client->SetMerchantTransaction(spawn);
  3433. client->SendRepairList();
  3434. }
  3435. break;
  3436. }
  3437. case COMMAND_LOTTO: {
  3438. Spawn* spawn = cmdTarget;
  3439. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_LOTTO) {
  3440. client->SetMerchantTransaction(spawn);
  3441. client->ShowLottoWindow();
  3442. }
  3443. break;
  3444. }
  3445. case COMMAND_ACCEPT_REWARD:{
  3446. int32 unknown = 0;
  3447. int32 selectable_item_id = 0;
  3448. //Quest *quest = 0;
  3449. Collection *collection = 0;
  3450. /* no idea what the first argument is for (faction maybe?)
  3451. if the reward has a selectable item reward, it's sent as the second argument
  3452. if neither of these are included in the reward, there is no sep
  3453. 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
  3454. only 1 quest or collection reward may be displayed at a time */
  3455. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  3456. unknown = atoul(sep->arg[0]);
  3457. selectable_item_id = atoul(sep->arg[1]);
  3458. }
  3459. //if ((quest = player->GetPendingQuestReward()))
  3460. // client->AcceptQuestRewards(quest, selectable_item_id);
  3461. /* the below needs to go away eventually and be redone */
  3462. int32 item_id = 0;
  3463. if(sep && sep->arg[0][0] && sep->IsNumber(0))
  3464. item_id = atoul(sep->arg[0]);
  3465. Quest* quest = client->GetPendingQuestAcceptance(item_id);
  3466. if(quest){
  3467. client->AcceptQuestReward(quest, item_id);
  3468. break;
  3469. }
  3470. bool collectedItems = false;
  3471. if (collection = player->GetPendingCollectionReward())
  3472. {
  3473. client->AcceptCollectionRewards(collection, selectable_item_id);
  3474. collectedItems = true;
  3475. }
  3476. else if (client->GetPlayer()->HasPendingItemRewards()) {
  3477. vector<Item*> items = client->GetPlayer()->GetPendingItemRewards();
  3478. if (items.size() > 0) {
  3479. collectedItems = true;
  3480. for (int i = 0; i < items.size(); i++) {
  3481. client->GetPlayer()->AddItem(new Item(items[i]));
  3482. }
  3483. client->GetPlayer()->ClearPendingItemRewards();
  3484. }
  3485. map<int32, Item*> selectable_item = client->GetPlayer()->GetPendingSelectableItemReward(item_id);
  3486. if (selectable_item.size() > 0) {
  3487. collectedItems = true;
  3488. map<int32, Item*>::iterator itr;
  3489. for (itr = selectable_item.begin(); itr != selectable_item.end(); itr++) {
  3490. client->GetPlayer()->AddItem(new Item(itr->second));
  3491. client->GetPlayer()->ClearPendingSelectableItemRewards(itr->first);
  3492. }
  3493. }
  3494. }
  3495. if (collectedItems) {
  3496. EQ2Packet* outapp = client->GetPlayer()->SendInventoryUpdate(client->GetVersion());
  3497. if (outapp)
  3498. client->QueuePacket(outapp);
  3499. }
  3500. else
  3501. LogWrite(COMMAND__ERROR, 0, "Command", "Error in COMMAND_ACCEPT_REWARD. No pending quest or collection reward was found (unknown=%u).", unknown);
  3502. break;
  3503. }
  3504. case COMMAND_BUY_FROM_BROKER:{
  3505. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  3506. int32 item_id = atoul(sep->arg[0]);
  3507. int16 quantity = atoul(sep->arg[1]);
  3508. client->AddItem(item_id, quantity);
  3509. }
  3510. break;
  3511. }
  3512. case COMMAND_SEARCH_STORES_PAGE:{
  3513. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  3514. int32 page = atoul(sep->arg[0]);
  3515. client->SearchStore(page);
  3516. }
  3517. break;
  3518. }
  3519. case COMMAND_SEARCH_STORES:{
  3520. if(sep && sep->arg[0][0]){
  3521. const char* values = sep->argplus[0];
  3522. if(values){
  3523. LogWrite(ITEM__WARNING, 0, "Item", "SearchStores: %s", values);
  3524. map<string, string> str_values = TranslateBrokerRequest(values);
  3525. vector<Item*>* items = master_item_list.GetItems(str_values);
  3526. if(items){
  3527. client->SetItemSearch(items);
  3528. client->SearchStore(0);
  3529. }
  3530. }
  3531. }
  3532. break;
  3533. }
  3534. case COMMAND_LUADEBUG:{
  3535. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "start") == 0){
  3536. client->SetLuaDebugClient(true);
  3537. if(lua_interface)
  3538. lua_interface->UpdateDebugClients(client);
  3539. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will now receive LUA error messages.");
  3540. }
  3541. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "stop") == 0){
  3542. client->SetLuaDebugClient(false);
  3543. if(lua_interface)
  3544. lua_interface->RemoveDebugClients(client);
  3545. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will no longer receive LUA error messages.");
  3546. }
  3547. else{
  3548. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /luadebug {start | stop}");
  3549. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will allow you to receive lua debug messages normally seen only in the console.");
  3550. }
  3551. break;
  3552. }
  3553. case COMMAND_SPAWN_GROUP:
  3554. {
  3555. Spawn* target = cmdTarget;
  3556. if(target && target->IsPlayer() == false)
  3557. {
  3558. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "create") == 0)
  3559. {
  3560. if(target->GetSpawnLocationPlacementID() > 0)
  3561. {
  3562. if(sep->arg[1] && !sep->IsNumber(1) && strlen(sep->arg[1]) > 0)
  3563. {
  3564. int32 id = database.CreateSpawnGroup(target, sep->arg[1]);
  3565. if(id > 0)
  3566. client->Message(CHANNEL_COLOR_YELLOW, "Successfully created new spawn group with id: %u", id);
  3567. else
  3568. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error creating group, check console for details.");
  3569. target->SetSpawnGroupID(id);
  3570. target->AddSpawnToGroup(target);
  3571. }
  3572. else
  3573. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group create [name]");
  3574. }
  3575. else
  3576. 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.");
  3577. }
  3578. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "add") == 0)
  3579. {
  3580. if(sep->arg[1] && sep->IsNumber(1))
  3581. {
  3582. int32 group_id = atoul(sep->arg[1]);
  3583. Spawn* leader = client->GetCurrentZone()->GetSpawnGroup(group_id);
  3584. if(leader)
  3585. {
  3586. leader->AddSpawnToGroup(target);
  3587. target->SetSpawnGroupID(group_id);
  3588. if(database.SpawnGroupAddSpawn(target, group_id))
  3589. client->Message(CHANNEL_COLOR_YELLOW, "Successfully added '%s' to group id: %u", target->GetName(), group_id);
  3590. else
  3591. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error adding spawn to group, check console for details.");
  3592. }
  3593. else
  3594. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No spawns found in the current zone for that spawn group, be sure to use '/spawn group create' first!");
  3595. }
  3596. else
  3597. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group add [group id]");
  3598. }
  3599. else if(target->GetSpawnGroupID() == 0)
  3600. {
  3601. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That spawn is not in a group!");
  3602. }
  3603. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "remove") == 0)
  3604. {
  3605. int32 group_id = target->GetSpawnGroupID();
  3606. target->RemoveSpawnFromGroup();
  3607. if(database.SpawnGroupRemoveSpawn(target, group_id))
  3608. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed '%s' from group id: %u", target->GetName(), group_id);
  3609. else
  3610. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing spawn from group, check console for details.");
  3611. }
  3612. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "associate") == 0)
  3613. {
  3614. int32 group_id = target->GetSpawnGroupID();
  3615. if(sep->arg[1] && sep->IsNumber(1))
  3616. {
  3617. if(database.SpawnGroupAddAssociation(group_id, atoul(sep->arg[1])))
  3618. client->Message(CHANNEL_COLOR_YELLOW, "Successfully associated group id %u with group id %u", group_id, atoul(sep->arg[1]));
  3619. else
  3620. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error associating groups, check console for details.");
  3621. }
  3622. else
  3623. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Allows you to spawn only one associated group at once. Syntax: /spawn group associate [other group id]");
  3624. }
  3625. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "deassociate") == 0)
  3626. {
  3627. int32 group_id = target->GetSpawnGroupID();
  3628. if(sep->arg[1] && sep->IsNumber(1))
  3629. {
  3630. if(database.SpawnGroupRemoveAssociation(group_id, atoul(sep->arg[1])))
  3631. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed association between group id %u and group id %u", group_id, atoul(sep->arg[1]));
  3632. else
  3633. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing group associations, check console for details.");
  3634. }
  3635. else
  3636. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Removes previous group associations. Syntax: /spawn group deassociate [other group id]");
  3637. }
  3638. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "chance") == 0)
  3639. {
  3640. if(sep->arg[1] && sep->IsNumber(1))
  3641. {
  3642. if(database.SetGroupSpawnChance(target->GetSpawnGroupID(), atof(sep->arg[1])))
  3643. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set group spawn chance to %f for group id: %u", atof(sep->arg[1]), target->GetSpawnGroupID());
  3644. else
  3645. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error setting group spawn chance, check console for details.");
  3646. }
  3647. else
  3648. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group chance [group's spawn chance percentage]");
  3649. }
  3650. else
  3651. {
  3652. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command allows you to modify spawn groups.");
  3653. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group [create/add/remove/chance/associate/deassociate]");
  3654. }
  3655. }
  3656. else
  3657. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select a valid spawn to use this command.");
  3658. break;
  3659. }
  3660. case COMMAND_SPAWN_COMBINE:{
  3661. Spawn* spawn = cmdTarget;
  3662. float radius = 0;
  3663. bool failed = true;
  3664. if(spawn && !spawn->IsPlayer() && sep && sep->arg[0] && sep->arg[0][0]){
  3665. failed = false;
  3666. if(spawn->GetSpawnGroupID() > 0){
  3667. 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.");
  3668. }
  3669. else if(sep->IsNumber(0)){
  3670. radius = atof(sep->arg[0]);
  3671. client->CombineSpawns(radius, spawn);
  3672. }
  3673. else{
  3674. if(strncasecmp(sep->arg[0], "add", 3) == 0){
  3675. client->AddCombineSpawn(spawn);
  3676. }
  3677. else if(strncasecmp(sep->arg[0], "remove", 6) == 0){
  3678. client->RemoveCombineSpawn(spawn);
  3679. }
  3680. else if(strncasecmp(sep->arg[0], "save", 4) == 0){
  3681. const char* name = 0;
  3682. if(sep->arg[1] && sep->arg[1][0])
  3683. name = sep->argplus[1];
  3684. client->SaveCombineSpawns(name);
  3685. }
  3686. else
  3687. failed = true;
  3688. }
  3689. }
  3690. if(failed){
  3691. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command combines several spawns into a single spawn group.");
  3692. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn combine [radius/add/remove/save]");
  3693. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Ex: /spawn combine 1, /spawn combine save (spawn group name)");
  3694. }
  3695. break;
  3696. }
  3697. case COMMAND_SPAWN_CREATE:{
  3698. Spawn* spawn = 0;
  3699. if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "object", 6) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  3700. spawn = new Object();
  3701. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3702. }
  3703. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "groundspawn", 11) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  3704. spawn = new GroundSpawn();
  3705. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3706. }
  3707. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "sign", 4) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  3708. spawn = new Sign();
  3709. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3710. }
  3711. else if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "npc", 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  3712. spawn = new NPC();
  3713. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3714. spawn->appearance.pos.collision_radius = 32;
  3715. spawn->secondary_command_list_id = 0;
  3716. spawn->primary_command_list_id = 0;
  3717. spawn->appearance.display_name = 1;
  3718. spawn->appearance.show_level = 1;
  3719. spawn->appearance.attackable = 1;
  3720. }
  3721. else{
  3722. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn create [spawn type] [race type] [class type] [level] [name] (difficulty) (size)");
  3723. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are required except difficulty and size. Valid types are Object, NPC, Sign, or GroundSpawn");
  3724. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn create npc 203 1 50 'Lady Vox' 1 32");
  3725. break;
  3726. }
  3727. spawn->SetID(Spawn::NextID());
  3728. spawn->SetX(client->GetPlayer()->GetX());
  3729. spawn->SetY(client->GetPlayer()->GetY());
  3730. spawn->SetZ(client->GetPlayer()->GetZ());
  3731. spawn->SetHeading(client->GetPlayer()->GetHeading());
  3732. spawn->SetSpawnOrigX(spawn->GetX());
  3733. spawn->SetSpawnOrigY(spawn->GetY());
  3734. spawn->SetSpawnOrigZ(spawn->GetZ());
  3735. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  3736. if(spawn->IsSign())
  3737. {
  3738. ((Sign*)spawn)->SetSignType(SIGN_TYPE_GENERIC);
  3739. ((Sign*)spawn)->SetSignDistance(20.0f);
  3740. ((Sign*)spawn)->SetIncludeLocation(1);
  3741. ((Sign*)spawn)->SetIncludeHeading(1);
  3742. ((Sign*)spawn)->SetInitialState(1);
  3743. ((Sign*)spawn)->SetSignTitle(sep->arg[4]);
  3744. ((Sign*)spawn)->SetActivityStatus(64);
  3745. spawn->appearance.race = 0;
  3746. spawn->SetLevel(0);
  3747. spawn->SetHP(0);
  3748. spawn->SetTotalHP(0);
  3749. spawn->SetPower(0);
  3750. spawn->SetTotalPower(0);
  3751. spawn->SetEncounterLevel(0);
  3752. spawn->SetTargetable(0);
  3753. spawn->SetSogaModelType(0);
  3754. spawn->SetCollisionRadius(19);
  3755. ((Sign*)spawn)->SetWidgetX(client->GetPlayer()->GetX());
  3756. ((Sign*)spawn)->SetWidgetY(client->GetPlayer()->GetY());
  3757. ((Sign*)spawn)->SetWidgetZ(client->GetPlayer()->GetZ());
  3758. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  3759. spawn->appearance.model_type = atoul(sep->arg[1]);
  3760. }
  3761. else
  3762. {
  3763. spawn->appearance.targetable = 1;
  3764. spawn->appearance.race = 255;
  3765. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  3766. spawn->SetModelType(atoi(sep->arg[1]));
  3767. spawn->SetAdventureClass(atoi(sep->arg[2]));
  3768. spawn->SetLevel(atoi(sep->arg[3]));
  3769. spawn->SetName(sep->arg[4]);
  3770. if(sep->arg[5][0] && sep->IsNumber(5))
  3771. spawn->SetEncounterLevel(atoi(sep->arg[5]));
  3772. if(sep->arg[6][0] && sep->IsNumber(6))
  3773. spawn->size = atoi(sep->arg[6]);
  3774. if(spawn->GetTotalHP() == 0){
  3775. spawn->SetTotalHP(25*spawn->GetLevel() + 1);
  3776. spawn->SetHP(25*spawn->GetLevel() + 1);
  3777. }
  3778. if(spawn->GetTotalPower() == 0){
  3779. spawn->SetTotalPower(25*spawn->GetLevel() + 1);
  3780. spawn->SetPower(25*spawn->GetLevel() + 1);
  3781. }
  3782. }
  3783. client->GetCurrentZone()->AddSpawn(spawn);
  3784. break;
  3785. }
  3786. case COMMAND_SPAWN_EQUIPMENT:{
  3787. Spawn* spawn = cmdTarget;
  3788. if(spawn && sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1) && spawn->IsEntity()){
  3789. int8 slot = atoi(sep->arg[0]);
  3790. int16 type = atoi(sep->arg[1]);
  3791. int8 red = 0;
  3792. int8 green = 0;
  3793. int8 blue = 0;
  3794. int8 h_red = 0;
  3795. int8 h_green = 0;
  3796. int8 h_blue = 0;
  3797. if(sep->arg[2])
  3798. red = atoi(sep->arg[2]);
  3799. if(sep->arg[3])
  3800. green = atoi(sep->arg[3]);
  3801. if(sep->arg[4])
  3802. blue = atoi(sep->arg[4]);
  3803. if(sep->arg[5])
  3804. h_red = atoi(sep->arg[5]);
  3805. if(sep->arg[6])
  3806. h_green = atoi(sep->arg[6]);
  3807. if(sep->arg[7])
  3808. h_blue = atoi(sep->arg[7]);
  3809. ((Entity*)spawn)->SetEquipment(slot, type, red, green, blue, h_red, h_green, h_blue);
  3810. database.SaveNPCAppearanceEquipment(spawn->GetDatabaseID() , slot, type, red, green, blue, h_red, h_green, h_blue);
  3811. }
  3812. else{
  3813. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn equipment [slot] [appearance id] (red) (green) (blue) (highlight red) (hgreen) (hblue)");
  3814. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn's equipment. ");
  3815. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Slot is 0-24, Appearance ID from appearances table, Colors are 0-255");
  3816. }
  3817. break;
  3818. }
  3819. case COMMAND_SPAWN_DETAILS: {
  3820. Spawn* spawn = cmdTarget;
  3821. if (sep && sep->arg[0][0]) {
  3822. if (cmdTarget)
  3823. {
  3824. if (ToLower(string(sep->arg[0])) == "los")
  3825. {
  3826. bool hasLOS = client->GetPlayer()->CheckLoS(cmdTarget);
  3827. if (hasLOS)
  3828. client->Message(CHANNEL_COLOR_YELLOW, "You have line of sight with %s", spawn->GetName());
  3829. else
  3830. client->Message(CHANNEL_COLOR_RED, "You DO NOT have line of sight with %s", spawn->GetName());
  3831. break;
  3832. }
  3833. else if (ToLower(string(sep->arg[0])) == "bestz")
  3834. {
  3835. glm::vec3 targPos(cmdTarget->GetX(), cmdTarget->GetZ(), cmdTarget->GetY());
  3836. float bestZ = client->GetPlayer()->FindDestGroundZ(targPos, cmdTarget->GetYOffset());
  3837. client->Message(CHANNEL_COLOR_YELLOW, "Best Z for %s is %f", spawn->GetName(), bestZ);
  3838. break;
  3839. }
  3840. else if (ToLower(string(sep->arg[0])) == "inwater")
  3841. {
  3842. if (cmdTarget->GetRegionMap() == nullptr)
  3843. client->SimpleMessage(CHANNEL_COLOR_RED, "No water map for zone.");
  3844. else
  3845. {
  3846. bool inWater = cmdTarget->InWater();
  3847. client->Message(CHANNEL_COLOR_YELLOW, "%s is %s.", cmdTarget->GetName(), inWater ? "in water" : "out of water");
  3848. }
  3849. break;
  3850. }
  3851. else if (ToLower(string(sep->arg[0])) == "inlava")
  3852. {
  3853. if (cmdTarget->GetRegionMap() == nullptr)
  3854. client->SimpleMessage(CHANNEL_COLOR_RED, "No region map for zone.");
  3855. else
  3856. {
  3857. bool inLava = cmdTarget->InLava();
  3858. client->Message(CHANNEL_COLOR_YELLOW, "%s is %s.", cmdTarget->GetName(), inLava ? "in lava" : "out of lava");
  3859. }
  3860. break;
  3861. }
  3862. else if (ToLower(string(sep->arg[0])) == "regions")
  3863. {
  3864. glm::vec3 targPos(cmdTarget->GetX(), cmdTarget->GetY(), cmdTarget->GetZ());
  3865. if (cmdTarget->GetRegionMap() == nullptr)
  3866. client->SimpleMessage(CHANNEL_COLOR_RED, "No region map for zone.");
  3867. else
  3868. {
  3869. cmdTarget->GetRegionMap()->IdentifyRegionsInGrid(client, targPos);
  3870. }
  3871. break;
  3872. }
  3873. else if (ToLower(string(sep->arg[0])) == "behind")
  3874. {
  3875. bool isBehind = client->GetPlayer()->BehindTarget(cmdTarget);
  3876. client->Message(CHANNEL_COLOR_YELLOW, "%s %s.", isBehind ? "YOU are behind" : "YOU are NOT behind", cmdTarget->GetName());
  3877. break;
  3878. }
  3879. else if (ToLower(string(sep->arg[0])) == "infront")
  3880. {
  3881. bool isBehind = client->GetPlayer()->InFrontSpawn(cmdTarget, client->GetPlayer()->GetX(), client->GetPlayer()->GetZ());
  3882. client->Message(CHANNEL_COLOR_YELLOW, "%s %s.", isBehind ? "YOU are infront of" : "YOU are NOT infront of", cmdTarget->GetName());
  3883. break;
  3884. }
  3885. else if (ToLower(string(sep->arg[0])) == "flank")
  3886. {
  3887. bool isFlanking = client->GetPlayer()->FlankingTarget(cmdTarget);
  3888. client->Message(CHANNEL_COLOR_YELLOW, "%s is %s.", isFlanking ? "YOU are flanking" : "YOU are NOT flanking", cmdTarget->GetName());
  3889. break;
  3890. }
  3891. }
  3892. if (sep->IsNumber(0))
  3893. {
  3894. float radius = atof(sep->arg[0]);
  3895. if (!client->GetCurrentZone()->SendRadiusSpawnInfo(client, radius))
  3896. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No results in the radius were found.");
  3897. break;
  3898. }
  3899. }
  3900. if (spawn) {
  3901. const char* type = "NPC";
  3902. if (spawn->IsObject())
  3903. type = "Object";
  3904. else if (spawn->IsSign())
  3905. type = "Sign";
  3906. else if (spawn->IsWidget())
  3907. type = "Widget";
  3908. else if (spawn->IsGroundSpawn())
  3909. type = "GroundSpawn";
  3910. client->Message(CHANNEL_COLOR_YELLOW, "Name: %s, %s ID: %u", spawn->GetName(), type, spawn->GetDatabaseID());
  3911. client->Message(CHANNEL_COLOR_YELLOW, "Last Name: %s, Sub-Title: %s, Prefix: %s, Suffix: %s", spawn->GetLastName(), spawn->GetSubTitle(), spawn->GetPrefixTitle(), spawn->GetSuffixTitle());
  3912. client->Message(CHANNEL_COLOR_YELLOW, "Spawn Location ID: %u, Spawn Group ID: %u", spawn->GetSpawnLocationID(), spawn->GetSpawnGroupID());
  3913. client->Message(CHANNEL_COLOR_YELLOW, "Faction ID: %u, Merchant ID: %u, Transporter ID: %u", spawn->GetFactionID(), spawn->GetMerchantID(), spawn->GetTransporterID());
  3914. client->Message(CHANNEL_COLOR_YELLOW, "Grid ID: %u", spawn->GetLocation());
  3915. client->Message(CHANNEL_COLOR_YELLOW, "Race: %i, Class: %i, Gender: %i", spawn->GetRace(), spawn->GetAdventureClass(), spawn->GetGender());
  3916. client->Message(CHANNEL_COLOR_YELLOW, "Level: %i, HP: %u, Power: %u", spawn->GetLevel(), spawn->GetHP(), spawn->GetPower());
  3917. 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());
  3918. client->Message(CHANNEL_COLOR_YELLOW, "Collision Radius: %i, Size: %i, Difficulty: %i, Heroic: %i", spawn->GetCollisionRadius(), spawn->GetSize(), spawn->GetEncounterLevel(), spawn->GetHeroic());
  3919. client->Message(CHANNEL_COLOR_YELLOW, "Targetable: %i, Show Name: %i, Attackable: %i, Show Level: %i", spawn->GetTargetable(), spawn->GetShowName(), spawn->GetAttackable(), spawn->GetShowLevel());
  3920. client->Message(CHANNEL_COLOR_YELLOW, "Show Command Icon: %i, Display Hand Icon: %i", spawn->GetShowCommandIcon(), spawn->GetShowHandIcon());
  3921. if (spawn->IsEntity()) {
  3922. 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());
  3923. 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());
  3924. }
  3925. client->Message(CHANNEL_COLOR_YELLOW, "Model Type: %i, Soga Race Type: %i", spawn->GetModelType(), spawn->GetSogaModelType());
  3926. client->Message(CHANNEL_COLOR_YELLOW, "Primary Command Type: %u, Secondary Command Type: %u", spawn->GetPrimaryCommandListID(), spawn->GetSecondaryCommandListID());
  3927. 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());
  3928. 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);
  3929. if (spawn->IsNPC())
  3930. client->Message(CHANNEL_COLOR_YELLOW, "Randomize: %u", ((NPC*)spawn)->GetRandomize());
  3931. string details;
  3932. details += "\\#0000FFName: " + string(spawn->GetName()) + "\n";
  3933. details += "Type: " + string(type) + "\n";
  3934. details += "ID: " + to_string(spawn->GetDatabaseID()) + "\n";
  3935. details += "Last Name: " + string(spawn->GetLastName()) + "\n";
  3936. details += "Sub-Title: " + string(spawn->GetSubTitle()) + "\n";
  3937. details += "Prefix: " + string(spawn->GetPrefixTitle()) + "\n";
  3938. details += "Suffix: " + string(spawn->GetSuffixTitle()) + "\n";
  3939. details += "Race: " + to_string(spawn->GetRace()) + "\n";
  3940. details += "Class: " + to_string(spawn->GetAdventureClass()) + "\n";
  3941. details += "Gender: " + to_string(spawn->GetGender()) + "\n";
  3942. details += "Level: " + to_string(spawn->GetLevel()) + "\n";
  3943. details += "HP: " + to_string(spawn->GetHP()) + "\n";
  3944. details += "Power: " + to_string(spawn->GetPower()) + "\n";
  3945. details += "Difficulty: " + to_string(spawn->GetEncounterLevel()) + "\n";
  3946. details += "Heroic: " + to_string(spawn->GetHeroic()) + "\n";
  3947. details += "Group ID: " + to_string(spawn->GetSpawnGroupID()) + "\n";
  3948. details += "Faction ID: " + to_string(spawn->GetFactionID()) + "\n";
  3949. details += "Merchant ID: " + to_string(spawn->GetMerchantID()) + "\n";
  3950. details += "Transport ID: " + to_string(spawn->GetTransporterID()) + "\n";
  3951. details += "Location ID: " + to_string(spawn->GetSpawnLocationID()) + "\n";
  3952. char x[16];
  3953. sprintf(x, "%.2f", spawn->GetX());
  3954. char y[16];
  3955. sprintf(y, "%.2f", spawn->GetY());
  3956. char z[16];
  3957. sprintf(z, "%.2f", spawn->GetZ());
  3958. details += "Location: " + string(x) + ", " + string(y) + ", " + string(z) + "\n";
  3959. string details2;
  3960. details2 += "Heading: " + to_string(spawn->GetHeading()) + "\n";
  3961. details2 += "Grid ID: " + to_string(spawn->GetLocation()) + "\n";
  3962. details2 += "Size: " + to_string(spawn->GetSize()) + "\n";
  3963. details2 += "Collision Radius: " + to_string(spawn->GetCollisionRadius()) + "\n";
  3964. details2 += "Respawn Time: " + to_string(spawn->GetRespawnTime()) + "\n";
  3965. details2 += "Targetable: " + to_string(spawn->GetTargetable()) + "\n";
  3966. details2 += "Show Name: " + to_string(spawn->GetShowName()) + "\n";
  3967. details2 += "Attackable: " + to_string(spawn->GetAttackable()) + "\n";
  3968. details2 += "Show Level: " + to_string(spawn->GetShowLevel()) + "\n";
  3969. details2 += "Show Command Icon: " + to_string(spawn->GetShowCommandIcon()) + "\n";
  3970. details2 += "Display Hand Icon: " + to_string(spawn->GetShowHandIcon()) + "\n";
  3971. details2 += "Model Type: " + to_string(spawn->GetModelType()) + "\n";
  3972. details2 += "Soga Race Type: " + to_string(spawn->GetSogaModelType()) + "\n";
  3973. details2 += "Primary Command ID: " + to_string(spawn->GetPrimaryCommandListID()) + "\n";
  3974. details2 += "Secondary Cmd ID: " + to_string(spawn->GetSecondaryCommandListID()) + "\n";
  3975. details2 += "Visual State: " + to_string(spawn->GetVisualState()) + "\n";
  3976. details2 += "Action State: " + to_string(spawn->GetActionState()) + "\n";
  3977. details2 += "Mood State: " + to_string(spawn->GetMoodState()) + "\n";
  3978. details2 += "Initial State: " + to_string(spawn->GetInitialState()) + "\n";
  3979. details2 += "Activity Status: " + to_string(spawn->GetActivityStatus()) + "\n";
  3980. details2 += "Emote State: " + to_string(spawn->GetEmoteState()) + "\n";
  3981. string details3;
  3982. details3 += "Pitch: " + to_string(spawn->GetPitch()) + "\n";
  3983. details3 += "Roll: " + to_string(spawn->GetRoll()) + "\n";
  3984. details3 += "Hide Hood: " + to_string(spawn->appearance.hide_hood) + "\n";
  3985. details3 += "Speed: " + to_string(spawn->GetSpeed()) + "\n";
  3986. details3 += "BaseSpeed: " + to_string(spawn->GetBaseSpeed()) + "\n";
  3987. if(spawn->IsEntity())
  3988. {
  3989. Entity* ent = (Entity*)spawn;
  3990. details3 += "STR / STRBase: " + to_string(ent->GetInfoStruct()->get_str()) + " / " + to_string(ent->GetInfoStruct()->get_str_base()) + "\n";
  3991. details3 += "AGI / AGIBase: " + to_string(ent->GetInfoStruct()->get_agi()) + " / " + to_string(ent->GetInfoStruct()->get_agi_base()) + "\n";
  3992. details3 += "STA / STABase: " + to_string(ent->GetInfoStruct()->get_sta()) + " / " + to_string(ent->GetInfoStruct()->get_sta_base()) + "\n";
  3993. details3 += "INT / INTBase: " + to_string(ent->GetInfoStruct()->get_intel()) + " / " + to_string(ent->GetInfoStruct()->get_intel_base()) + "\n";
  3994. details3 += "WIS / WISBase: " + to_string(ent->GetInfoStruct()->get_wis()) + " / " + to_string(ent->GetInfoStruct()->get_wis_base()) + "\n";
  3995. }
  3996. string details4;
  3997. if (spawn->IsEntity()) {
  3998. details4 += "Facial Hair Type: " + to_string(((Entity*)spawn)->GetFacialHairType()) + "\n";
  3999. details4 += "Hair Type: " + to_string(((Entity*)spawn)->GetHairType()) + "\n";
  4000. details4 += "Chest Type: " + to_string(((Entity*)spawn)->GetChestType()) + "\n";
  4001. details4 += "Legs Type: " + to_string(((Entity*)spawn)->GetLegsType()) + "\n";
  4002. details4 += "Soga Facial Hair Type: " + to_string(((Entity*)spawn)->GetSogaFacialHairType()) + "\n";
  4003. details4 += "Soga Hair Type: " + to_string(((Entity*)spawn)->GetSogaHairType()) + "\n";
  4004. details4 += "Wing Type: " + to_string(((Entity*)spawn)->GetWingType()) + "\n";
  4005. if (spawn->IsNPC()) {
  4006. details4 += "\nRandomize: " + to_string(((NPC*)spawn)->GetRandomize()) + "\n";
  4007. }
  4008. const char* spawnScriptMsg = (spawn->GetSpawnScript() && strlen(spawn->GetSpawnScript())>0) ? spawn->GetSpawnScript() : "Not Set";
  4009. details4 += "\nSpawnScript: " + std::string(spawnScriptMsg) + "\n";
  4010. }
  4011. string title = string(spawn->GetName()) + "(" + to_string(spawn->GetDatabaseID()) + ")";
  4012. client->SendShowBook(client->GetPlayer(), title, 4, details, details2, details3, details4);
  4013. }
  4014. else {
  4015. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn details (radius)");
  4016. 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.");
  4017. }
  4018. break;
  4019. }
  4020. case COMMAND_SPAWN_TARGET:{
  4021. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  4022. int32 spawn_id = atoul(sep->arg[0]);
  4023. int16 response = client->GetCurrentZone()->SetSpawnTargetable(spawn_id);
  4024. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  4025. }
  4026. else if(sep && sep->arg[0][0] && sep->arg[1][0] && sep->IsNumber(1) && ToLower(string(sep->arg[0])) == "radius"){
  4027. float distance = atof(sep->arg[1]);
  4028. int16 response = client->GetCurrentZone()->SetSpawnTargetable(client->GetPlayer(), distance);
  4029. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  4030. }
  4031. else{
  4032. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn target [spawn id]");
  4033. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn as targetable. Used to change a spawn if it was set to untargetable.");
  4034. }
  4035. break;
  4036. }
  4037. case COMMAND_SPAWN_SET:
  4038. {
  4039. Spawn* spawn = cmdTarget;
  4040. sint16 set_type = -1;
  4041. string type_str;
  4042. if (spawn)
  4043. {
  4044. // check if parameters are (location or list or not player and not a 2nd param), and that there is at least 1 value
  4045. 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)
  4046. {
  4047. // set the type, which will be 0 if location or list or invalid
  4048. set_type = spawn_set_values[ToLower(string(sep->arg[0]))];
  4049. }
  4050. if(set_type > 0)
  4051. {
  4052. // check if spawn set is NOT a char update, or not location, or isn't a number
  4053. 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)
  4054. {
  4055. client->SimpleMessage(CHANNEL_COLOR_RED, "Invalid value for set command.");
  4056. }
  4057. else
  4058. {
  4059. string name = string(spawn->GetName());
  4060. if(SetSpawnCommand(client, spawn, set_type, sep->argplus[1]))
  4061. {
  4062. if (set_type == SPAWN_SET_VALUE_EXPANSION_FLAG || set_type == SPAWN_SET_VALUE_HOLIDAY_FLAG)
  4063. {
  4064. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "A /reload spawns is required to properly update the spawns with the xpack/holiday flag.");
  4065. }
  4066. else if (set_type == SPAWN_SET_VALUE_NAME)
  4067. {
  4068. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "New name will not be effective until zone reload.");
  4069. }
  4070. else if (set_type == SPAWN_SET_SKIN_COLOR || (set_type >= SPAWN_SET_HAIR_COLOR1 && set_type <= SPAWN_SET_SOGA_EYE_COLOR))
  4071. {
  4072. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set color field to R G B: %s.", sep->argplus[1]);
  4073. }
  4074. else if(set_type == SPAWN_SET_VALUE_LOCATION)
  4075. {
  4076. spawn->SetLocation(client->GetPlayer()->GetLocation());
  4077. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set '%s' to '%u' for spawn '%s'", sep->arg[0], client->GetPlayer()->GetLocation(), name.c_str());
  4078. }
  4079. else
  4080. {
  4081. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set '%s' to '%s' for spawn '%s'", sep->arg[0], sep->arg[1], name.c_str());
  4082. }
  4083. switch (set_type)
  4084. {
  4085. case SPAWN_SET_VALUE_EXPANSION_FLAG:
  4086. case SPAWN_SET_VALUE_HOLIDAY_FLAG:
  4087. case SPAWN_SET_VALUE_FACTION:
  4088. case SPAWN_SET_AAXP_REWARDS:
  4089. {
  4090. // not applicable already ran db command
  4091. break;
  4092. }
  4093. default:
  4094. {
  4095. client->GetCurrentZone()->ApplySetSpawnCommand(client, spawn, set_type, sep->argplus[1]);
  4096. break;
  4097. }
  4098. }
  4099. 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))
  4100. {
  4101. if(spawn->GetSpawnLocationID() > 0 && database.UpdateSpawnLocationSpawns(spawn))
  4102. {
  4103. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information.");
  4104. }
  4105. else if(spawn->GetSpawnLocationID() > 0)
  4106. {
  4107. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn information, see console window for details.");
  4108. }
  4109. }
  4110. else
  4111. {
  4112. if(spawn->GetDatabaseID() > 0 && database.SaveSpawnInfo(spawn))
  4113. {
  4114. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully saved spawn.");
  4115. }
  4116. else if(spawn->GetDatabaseID() > 0)
  4117. {
  4118. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn, see console window for details.");
  4119. }
  4120. }
  4121. }
  4122. }
  4123. }
  4124. else if(set_type == 0)
  4125. {
  4126. // /spawn set list - lists all possible attributes that can be changed with this command, 10 per line.
  4127. map<string, int8>::iterator itr;
  4128. int i=0;
  4129. string list;
  4130. for(itr = spawn_set_values.begin(); itr != spawn_set_values.end(); itr++, i++)
  4131. {
  4132. if(i==10)
  4133. {
  4134. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  4135. i = 0;
  4136. }
  4137. if(i>0)
  4138. {
  4139. list.append(", ").append(itr->first);
  4140. }
  4141. else
  4142. {
  4143. list = itr->first;
  4144. }
  4145. }
  4146. if(list.length() > 0)
  4147. {
  4148. // if 1 or more, display in client.
  4149. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  4150. }
  4151. }
  4152. else
  4153. {
  4154. // syntax fail
  4155. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn set [type] [value]");
  4156. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used to change various settings for the targeted NPC or Object.");
  4157. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "For a list of changeable settings use /spawn set list");
  4158. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Note: /spawn set location does not require a value. The client's current location is used.");
  4159. }
  4160. }
  4161. break;
  4162. }
  4163. case COMMAND_SPAWN_REMOVE:{
  4164. Spawn* spawn = cmdTarget;
  4165. if(spawn && !spawn->IsPlayer()){
  4166. if(spawn->GetSpawnLocationID() > 0){
  4167. if(database.RemoveSpawnFromSpawnLocation(spawn)){
  4168. client->GetCurrentZone()->RemoveSpawn(spawn, true, false);
  4169. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully removed spawn from zone");
  4170. }
  4171. else
  4172. client->SimpleMessage(CHANNEL_COLOR_RED, "Error removing spawn, see console window for details.");
  4173. }
  4174. else
  4175. client->SimpleMessage(CHANNEL_COLOR_RED, "This spawn does not have a spawn group associated with it");
  4176. }
  4177. else{
  4178. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn remove");
  4179. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for removing the targeted NPC or Object from the zone.");
  4180. }
  4181. break;
  4182. }
  4183. case COMMAND_SPAWN_LIST:{
  4184. if(sep && sep->arg[0][0]){
  4185. vector<string>* results = database.GetSpawnNameList(sep->argplus[0]);
  4186. vector<string>::iterator itr;
  4187. if(results){
  4188. for(itr=results->begin();itr!=results->end();itr++){
  4189. client->SimpleMessage(CHANNEL_COLOR_YELLOW, (*itr).c_str());
  4190. }
  4191. safe_delete(results);
  4192. }
  4193. else
  4194. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found. ");
  4195. }
  4196. else{
  4197. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn list [name]");
  4198. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Name can be a partial match.");
  4199. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn list Qeynos Guard");
  4200. }
  4201. break;
  4202. }
  4203. case COMMAND_SPAWN_ADD:{
  4204. Spawn* spawn = cmdTarget;
  4205. if(spawn && sep && sep->arg[1][0] && (sep->IsNumber(0) || strncasecmp(sep->arg[0], "new", 3) == 0)){
  4206. if(spawn->GetSpawnLocationID() > 0){
  4207. client->Message(CHANNEL_COLOR_RED, "This spawn already has a spawn group id of %u, use /spawn remove to reassign it", spawn->GetSpawnLocationID());
  4208. break;
  4209. }
  4210. if(spawn->GetDatabaseID() == 0){
  4211. if(database.SaveSpawnInfo(spawn)) {
  4212. char spawn_type[32];
  4213. memset(spawn_type, 0, sizeof(spawn_type));
  4214. if (spawn->IsNPC())
  4215. strncpy(spawn_type, "NPC", sizeof(spawn_type) - 1);
  4216. else if (spawn->IsObject())
  4217. strncpy(spawn_type, "Object", sizeof(spawn_type) - 1);
  4218. else if (spawn->IsSign())
  4219. strncpy(spawn_type, "Sign", sizeof(spawn_type) - 1);
  4220. else if (spawn->IsGroundSpawn())
  4221. strncpy(spawn_type, "GroundSpawn", sizeof(spawn_type) - 1);
  4222. else
  4223. strncpy(spawn_type, "Unknown", sizeof(spawn_type) - 1);
  4224. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information with a %s id of %u", spawn_type, spawn->GetDatabaseID());
  4225. }
  4226. else
  4227. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn information, see console window for details.");
  4228. }
  4229. int32 spawn_group_id = 0;
  4230. if(strncasecmp(sep->arg[0], "new", 3) == 0)
  4231. spawn_group_id = database.GetNextSpawnLocation();
  4232. else
  4233. spawn_group_id = atol(sep->arg[0]);
  4234. int8 percent = 100;
  4235. if(sep->arg[2] && sep->IsNumber(2))
  4236. percent = atoi(sep->arg[2]);
  4237. spawn->SetSpawnLocationID(spawn_group_id);
  4238. float x_offset = database.GetSpawnLocationPlacementOffsetX(spawn->GetSpawnLocationID());
  4239. float y_offset = database.GetSpawnLocationPlacementOffsetY(spawn->GetSpawnLocationID());
  4240. float z_offset = database.GetSpawnLocationPlacementOffsetZ(spawn->GetSpawnLocationID());
  4241. if(database.SaveSpawnEntry(spawn, sep->arg[1], percent, x_offset, y_offset, z_offset))
  4242. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn location with a spawn group of %u", spawn->GetSpawnLocationID());
  4243. else
  4244. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn location, see console window for details.");
  4245. }
  4246. else{
  4247. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn add [spawn group id] [spawn group name] (percentage)");
  4248. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for adding the targeted NPC or Object to the database.");
  4249. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can substitute new for [spawn group id] to create a new one.");
  4250. }
  4251. break;
  4252. }
  4253. case COMMAND_SPAWN:{
  4254. int32 id = 0;
  4255. Spawn* spawn = 0;
  4256. if(sep && sep->arg[0] && sep->IsNumber(0)){
  4257. id = atol(sep->arg[0]);
  4258. spawn = client->GetCurrentZone()->GetSpawn(id);
  4259. }
  4260. if(id > 0 && spawn && spawn->appearance.name[0] == 0)
  4261. id = 0;
  4262. if(!id || !spawn){
  4263. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn [spawn id] (x) (y) (z) (heading) (location)");
  4264. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are optional except the id. The spawn id must be in the database.");
  4265. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn 1 0 0 0 0");
  4266. safe_delete(sep);
  4267. return;
  4268. }
  4269. if(sep && sep->arg[1][0]){
  4270. float x = atof(sep->arg[1]);
  4271. spawn->appearance.pos.X = x;
  4272. }
  4273. else
  4274. spawn->SetX(client->GetPlayer()->GetX(), false);
  4275. if(sep && sep->arg[2][0]){
  4276. float y = atof(sep->arg[2]);
  4277. spawn->appearance.pos.Y = y;
  4278. }
  4279. else
  4280. spawn->SetY(client->GetPlayer()->GetY(), false);
  4281. if(sep && sep->arg[3][0]){
  4282. float z = atof(sep->arg[3]);
  4283. spawn->appearance.pos.Z = z;
  4284. }
  4285. else
  4286. spawn->SetZ(client->GetPlayer()->GetZ(), false);
  4287. if(sep && sep->arg[4][0]){
  4288. float heading = atof(sep->arg[4]);
  4289. spawn->SetHeading(heading);
  4290. }
  4291. else
  4292. spawn->SetHeading(client->GetPlayer()->GetHeading(), false);
  4293. spawn->SetSpawnOrigX(spawn->GetX());
  4294. spawn->SetSpawnOrigY(spawn->GetY());
  4295. spawn->SetSpawnOrigZ(spawn->GetZ());
  4296. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  4297. if(sep && sep->arg[5][0])
  4298. spawn->appearance.pos.grid_id = atol(sep->arg[5]);
  4299. else
  4300. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  4301. if(spawn->IsNPC() && spawn->GetTotalHP() == 0){
  4302. spawn->SetTotalHP(spawn->GetLevel() * 15);
  4303. spawn->SetHP(spawn->GetTotalHP());
  4304. }
  4305. if(spawn->GetTotalPower() == 0){
  4306. spawn->SetTotalPower(spawn->GetLevel() * 15);
  4307. spawn->SetPower(spawn->GetTotalPower());
  4308. }
  4309. const char* script = world.GetSpawnScript(id);
  4310. if(script && lua_interface && lua_interface->GetSpawnScript(script) != 0)
  4311. spawn->SetSpawnScript(string(script));
  4312. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_PRESPAWN);
  4313. client->GetCurrentZone()->AddSpawn(spawn);
  4314. if(spawn->IsNPC())
  4315. spawn->GetZone()->AddLoot((NPC*)spawn);
  4316. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_SPAWN);
  4317. LogWrite(COMMAND__INFO, 0, "Command", "Received spawn command - Parms: %s", command_parms->data.c_str());
  4318. break;
  4319. }
  4320. case COMMAND_ADMINFLAG:
  4321. {
  4322. if(sep && sep->arg[0]){
  4323. sint16 tmp_status = database.GetCharacterAdminStatus(sep->arg[0]);
  4324. sint16 new_status = atoi(sep->arg[1]);
  4325. if(tmp_status == -10)
  4326. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character does not exist.");
  4327. else if(tmp_status >= client->GetAdminStatus())
  4328. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character has same or higher level status.");
  4329. else if (new_status > client->GetAdminStatus())
  4330. client->SimpleMessage(CHANNEL_ERROR, "Unable to flag character. Reason: New status is higher then your status.");
  4331. else{
  4332. Client* client2 = client->GetCurrentZone()->GetClientByName(sep->arg[0]);
  4333. if (!client2)
  4334. client2 = zone_list.GetClientByCharName(sep->arg[0]);
  4335. if(database.UpdateAdminStatus(sep->arg[0],new_status)) {
  4336. client->Message(CHANNEL_COLOR_YELLOW,"Character status updated to %i for %s.",new_status,sep->arg[0]);
  4337. if (client2) {
  4338. client2->SetAdminStatus(new_status);
  4339. client2->Message(CHANNEL_COLOR_YELLOW, "%s has set your admin status to %i.", client->GetPlayer()->GetName(), new_status);
  4340. }
  4341. }
  4342. else
  4343. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Unknown reason.");
  4344. }
  4345. }else{
  4346. sint16 status = database.GetCharacterAdminStatus(client->GetPlayer()->GetName());
  4347. if(status != client->GetAdminStatus())
  4348. {
  4349. client->Message(CHANNEL_COLOR_YELLOW,"Flag status was changed from %i to %i.",status,client->GetAdminStatus());
  4350. client->SetAdminStatus(status);
  4351. }
  4352. else
  4353. {
  4354. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /flag {name} {new_status}");
  4355. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Standard User: 0");
  4356. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Admin User: 100");
  4357. }
  4358. }
  4359. break;
  4360. }
  4361. case COMMAND_CANNEDEMOTE:{
  4362. client->GetCurrentZone()->HandleEmote(client, command_parms->data);
  4363. break;
  4364. }
  4365. case COMMAND_BROADCAST: {
  4366. if (sep && sep->arg[0])
  4367. zone_list.HandleGlobalBroadcast(sep->argplus[0]);
  4368. else
  4369. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /broadcast {message}");
  4370. break;
  4371. }
  4372. case COMMAND_ANNOUNCE: {
  4373. if (sep && sep->arg[0])
  4374. zone_list.HandleGlobalAnnouncement(sep->argplus[0]);
  4375. else
  4376. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /announce {message}");
  4377. break;
  4378. }
  4379. case COMMAND_RELOAD_ITEMS:{
  4380. LogWrite(COMMAND__INFO, 0, "Command", "Reloading items..");
  4381. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Started Reloading items (this might take a few minutes...)");
  4382. database.ReloadItemList();
  4383. database.LoadMerchantInformation();
  4384. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Finished Reloading items.");
  4385. break;
  4386. }
  4387. case COMMAND_ENABLE_ABILITY_QUE:{
  4388. EQ2Packet* app = client->GetPlayer()->GetSpellBookUpdatePacket(client->GetVersion());
  4389. if(app)
  4390. client->QueuePacket(app);
  4391. break;
  4392. }
  4393. case COMMAND_ITEMSEARCH:
  4394. case COMMAND_FROMBROKER:{
  4395. PacketStruct* packet = configReader.getStruct("WS_StartBroker", client->GetVersion());
  4396. if (packet) {
  4397. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  4398. //packet->setDataByName("unknown", 1);
  4399. packet->setDataByName("unknown2", 5, 0);
  4400. packet->setDataByName("unknown2", 20, 1);
  4401. packet->setDataByName("unknown2", 58, 3);
  4402. packet->setDataByName("unknown2", 40, 4);
  4403. client->QueuePacket(packet->serialize());
  4404. PacketStruct* packet2 = configReader.getStruct("WS_BrokerBags", client->GetVersion());
  4405. if (packet2) {
  4406. packet2->setDataByName("char_id", client->GetCharacterID());
  4407. client->QueuePacket(packet2->serialize()); //send this for now, needed to properly clear data
  4408. safe_delete(packet2);
  4409. }
  4410. safe_delete(packet);
  4411. }
  4412. break;
  4413. }
  4414. case COMMAND_ANIMTEST:{
  4415. PacketStruct* command_packet = configReader.getStruct("WS_CannedEmote", client->GetVersion());
  4416. if(command_packet){
  4417. int32 id = client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer());
  4418. if (cmdTarget)
  4419. id = client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget);
  4420. command_packet->setDataByName ( "spawn_id" , id);
  4421. int animID = 1;
  4422. if(sep && sep->arg[0] && sep->IsNumber(0))
  4423. animID = atoi(sep->arg[0]);
  4424. VisualState* vs = NULL;
  4425. if(animID == 0)
  4426. {
  4427. vs = visual_states.FindVisualState(sep->arg[0]);
  4428. }
  4429. char msg[128];
  4430. sprintf(msg,"Animation Test ID: %i",animID);
  4431. command_packet->setMediumStringByName ( "emote_msg" , msg );
  4432. if(vs != NULL)
  4433. command_packet->setDataByName ( "anim_type", vs->GetID ( ) );
  4434. else
  4435. command_packet->setDataByName ( "anim_type", animID );
  4436. command_packet->setDataByName ( "unknown0", 0 );
  4437. EQ2Packet* outapp = command_packet->serialize();
  4438. client->QueuePacket(outapp);
  4439. safe_delete(command_packet);
  4440. }
  4441. break;
  4442. }
  4443. case COMMAND_KICK:
  4444. {
  4445. if( sep == 0 || sep->arg[0] == 0)
  4446. {
  4447. client->SimpleMessage(CHANNEL_COLOR_RED, "/kick [name]");
  4448. }
  4449. else
  4450. {
  4451. Client* kickClient = zone_list.GetClientByCharName(string(sep->arg[0]));
  4452. if ( kickClient == client )
  4453. {
  4454. client->Message(CHANNEL_COLOR_RED, "You can't kick yourself!");
  4455. break;
  4456. }
  4457. else if(kickClient != NULL)
  4458. {
  4459. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  4460. if ( maxStatus >= client->GetAdminStatus( ) || kickClient->GetAdminStatus() >= client->GetAdminStatus() )
  4461. {
  4462. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  4463. break;
  4464. }
  4465. client->Message(CHANNEL_COLOR_RED, "Kicking %s...",sep->arg[0]);
  4466. kickClient->Disconnect();
  4467. }
  4468. else
  4469. {
  4470. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  4471. }
  4472. }
  4473. break;
  4474. }
  4475. case COMMAND_LOCK:
  4476. {
  4477. if( sep != NULL && sep->arg[0] != NULL && sep->IsNumber(0)){
  4478. int worldLocked = atoi(sep->arg[0]);
  4479. net.world_locked = worldLocked;
  4480. if ( worldLocked )
  4481. client->Message(CHANNEL_COLOR_YELLOW,"World server has been locked.");
  4482. else
  4483. client->Message(CHANNEL_COLOR_YELLOW,"World server has been unlocked.");
  4484. }
  4485. else
  4486. client->SimpleMessage(CHANNEL_COLOR_RED, "/lock [0/1]");
  4487. break;
  4488. }
  4489. case COMMAND_BAN:{
  4490. if( sep == 0 || sep->arg[0] == 0 || (sep->arg[1][0] != 0 && !sep->IsNumber(1) ) )
  4491. {
  4492. client->SimpleMessage(CHANNEL_COLOR_RED, "/ban [name] [permanent:0/1]");
  4493. }
  4494. else
  4495. {
  4496. Client* kickClient = zone_list.GetClientByCharName(sep->arg[0]);
  4497. if ( kickClient == client )
  4498. {
  4499. client->Message(CHANNEL_COLOR_RED, "You can't ban yourself!");
  4500. break;
  4501. }
  4502. else if(kickClient != NULL)
  4503. {
  4504. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  4505. if ( maxStatus > client->GetAdminStatus( ) ||
  4506. client->GetAdminStatus ( ) > kickClient->GetAdminStatus ( ) )
  4507. {
  4508. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  4509. break;
  4510. }
  4511. client->Message(CHANNEL_COLOR_RED, "Kicking & Banning %s...",sep->arg[0]);
  4512. int perm = atol(sep->arg[1]);
  4513. if ( perm == 1 )
  4514. database.UpdateAdminStatus(sep->arg[0],-2);
  4515. else
  4516. database.UpdateAdminStatus(sep->arg[0],-1);
  4517. kickClient->Disconnect();
  4518. }
  4519. else
  4520. {
  4521. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  4522. }
  4523. }
  4524. break;
  4525. }
  4526. case COMMAND_SET_COMBAT_VOICE:{
  4527. int32 value = 0;
  4528. if(sep && sep->arg[0] && sep->IsNumber(0))
  4529. value = atoi(sep->arg[0]);
  4530. client->GetPlayer()->SetCombatVoice(value);
  4531. break;
  4532. }
  4533. case COMMAND_SET_EMOTE_VOICE:{
  4534. int32 value = 0;
  4535. if(sep && sep->arg[0] && sep->IsNumber(0))
  4536. value = atoi(sep->arg[0]);
  4537. client->GetPlayer()->SetEmoteVoice(value);
  4538. break;
  4539. }
  4540. case COMMAND_GIVEITEM:{
  4541. if(sep && sep->arg[0][0] && sep->arg[0][1] && sep->IsNumber(1)){
  4542. Client* itemToClient = zone_list.GetClientByCharName(sep->arg[0]);
  4543. if ( itemToClient == NULL )
  4544. client->Message(CHANNEL_COLOR_YELLOW,"Could not find %s.",sep->arg[0]);
  4545. else
  4546. {
  4547. int32 item_id = atol(sep->arg[1]);
  4548. client->Message(CHANNEL_COLOR_YELLOW,"Gave %s item id %i.",sep->arg[0],item_id);
  4549. itemToClient->AddItem(item_id);
  4550. }
  4551. }
  4552. else
  4553. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /giveitem [name] [item_id]");
  4554. break;
  4555. }
  4556. case COMMAND_REPORT_BUG : { Command_ReportBug(client, sep); break; }
  4557. case COMMAND_INVENTORY : { Command_Inventory(client, sep, command); break; }
  4558. case COMMAND_WEAPONSTATS : { Command_WeaponStats(client); break; }
  4559. case COMMAND_SKILL :
  4560. case COMMAND_SKILL_ADD :
  4561. case COMMAND_SKILL_REMOVE :
  4562. case COMMAND_SKILL_LIST : { Command_Skills(client, sep, command->handler); break; }
  4563. case COMMAND_ZONE_SET : { Command_ZoneSet(client, sep); break; }
  4564. case COMMAND_ZONE_DETAILS : { Command_ZoneDetails(client, sep); break; }
  4565. case COMMAND_ENTITYCOMMAND :
  4566. case COMMAND_ENTITYCOMMAND_LIST : { Command_EntityCommand(client, sep, command->handler); break; }
  4567. case COMMAND_MERCHANT :
  4568. case COMMAND_MERCHANT_LIST : { Command_Merchant(client, sep, command->handler); break; }
  4569. case COMMAND_APPEARANCE :
  4570. case COMMAND_APPEARANCE_LIST : { Command_Appearance(client, sep, command->handler); break; }
  4571. case COMMAND_TRACK : { Command_Track(client); break; }
  4572. case COMMAND_DISTANCE : { Command_Distance(client); break; }
  4573. case COMMAND_INSPECT_PLAYER : { Command_InspectPlayer(client, sep); break; }
  4574. case COMMAND_ZONE_SAFE : { Command_ZoneSafeCoords(client, sep); break; }
  4575. case COMMAND_GUILDSAY : { Command_GuildSay(client, sep); break; }
  4576. case COMMAND_OFFICERSAY : { Command_OfficerSay(client, sep); break; }
  4577. case COMMAND_SET_GUILD_MEMBER_NOTE : { Command_SetGuildMemberNote(client, sep); break; }
  4578. case COMMAND_SET_GUILD_OFFICER_NOTE : { Command_SetGuildOfficerNote(client, sep); break; }
  4579. case COMMAND_GUILD : { Command_Guild(client, sep); break; }
  4580. case COMMAND_CREATE_GUILD : { Command_CreateGuild(client); break; }
  4581. case COMMAND_GUILDS : { Command_Guilds(client); break; }
  4582. case COMMAND_GUILDS_ADD : { Command_GuildsAdd(client, sep); break; }
  4583. case COMMAND_GUILDS_CREATE : { Command_GuildsCreate(client, sep); break; }
  4584. case COMMAND_GUILDS_DELETE : { Command_GuildsDelete(client, sep); break; }
  4585. case COMMAND_GUILDS_LIST : { Command_GuildsList(client); break; }
  4586. case COMMAND_GUILDS_REMOVE : { Command_GuildsRemove(client, sep); break; }
  4587. case COMMAND_CLAIM : { Command_Claim(client, sep); break; }
  4588. case COMMAND_CLEAR_ALL_QUEUED : { Command_ClearAllQueued(client); break; }
  4589. case COMMAND_LOCATION : { Command_Location(client); break; }
  4590. case COMMAND_LOCATION_ADD : { Command_LocationAdd(client, sep); break; }
  4591. case COMMAND_LOCATION_CREATE : { Command_LocationCreate(client, sep); break; }
  4592. case COMMAND_LOCATION_DELETE : { Command_LocationDelete(client, sep); break; }
  4593. case COMMAND_LOCATION_LIST : { Command_LocationList(client, sep); break; }
  4594. case COMMAND_LOCATION_REMOVE : { Command_LocationRemove(client, sep); break; }
  4595. case COMMAND_GRID : { Command_Grid(client); break; }
  4596. case COMMAND_TRY_ON : { Command_TryOn(client, sep); break; }
  4597. case COMMAND_IRC : { Command_IRC(client, sep); break; }
  4598. case COMMAND_RANDOMIZE : { Command_Randomize(client, sep); break; }
  4599. case COMMAND_AFK : { Command_AFK(client, sep); break; }
  4600. case COMMAND_SHOW_CLOAK : { Command_ShowCloak(client, sep); break; }
  4601. case COMMAND_SHOW_HELM : { Command_ShowHelm(client, sep); break; }
  4602. case COMMAND_SHOW_HOOD : { Command_ShowHood(client, sep); break; }
  4603. case COMMAND_SHOW_HOOD_OR_HELM : { Command_ShowHoodHelm(client, sep); break; }
  4604. case COMMAND_SHOW_RANGED : { Command_ShowRanged(client, sep); break; }
  4605. case COMMAND_STOP_DRINKING : { Command_StopDrinking(client); break; }
  4606. case COMMAND_STOP_EATING : { Command_StopEating(client); break; }
  4607. case COMMAND_TOGGLE_ANONYMOUS : { Command_Toggle_Anonymous(client); break; }
  4608. case COMMAND_TOGGLE_AUTOCONSUME : { Command_Toggle_AutoConsume(client, sep); break; }
  4609. case COMMAND_TOGGLE_BONUS_EXP : { Command_Toggle_BonusXP(client); break; }
  4610. case COMMAND_TOGGLE_COMBAT_EXP : { Command_Toggle_CombatXP(client); break; }
  4611. case COMMAND_TOGGLE_GM_HIDE : { Command_Toggle_GMHide(client); break; }
  4612. case COMMAND_TOGGLE_GM_VANISH : { Command_Toggle_GMVanish(client); break; }
  4613. case COMMAND_TOGGLE_ILLUSIONS : { Command_Toggle_Illusions(client, sep); break; }
  4614. case COMMAND_TOGGLE_LFG : { Command_Toggle_LFG(client); break; }
  4615. case COMMAND_TOGGLE_LFW : { Command_Toggle_LFW(client); break; }
  4616. case COMMAND_TOGGLE_QUEST_EXP : { Command_Toggle_QuestXP(client); break; }
  4617. case COMMAND_TOGGLE_ROLEPLAYING : { Command_Toggle_Roleplaying(client); break; }
  4618. case COMMAND_TOGGLE_DUELS : { Command_Toggle_Duels(client); break; }
  4619. case COMMAND_TOGGLE_TRADES : { Command_Toggle_Trades(client); break; }
  4620. case COMMAND_TOGGLE_GUILDS : { Command_Toggle_Guilds(client); break; }
  4621. case COMMAND_TOGGLE_GROUPS : { Command_Toggle_Groups(client); break; }
  4622. case COMMAND_TOGGLE_RAIDS : { Command_Toggle_Raids(client); break; }
  4623. case COMMAND_TOGGLE_LON : { Command_Toggle_LON(client); break; }
  4624. case COMMAND_TOGGLE_VCINVITE : { Command_Toggle_VoiceChat(client); break; }
  4625. case COMMAND_CANCEL_MAINTAINED : { Command_CancelMaintained(client, sep); break; }
  4626. case COMMAND_MOTD : { Command_MOTD(client); break; }
  4627. case COMMAND_RANDOM : { Command_Random(client, sep); break; }
  4628. case COMMAND_CREATE : { Command_Create(client, sep); break; }
  4629. case COMMAND_CREATEFROMRECIPE : { Command_CreateFromRecipe(client, sep); break; }
  4630. case COMMAND_TITLE : { Command_Title(client); break; }
  4631. case COMMAND_TITLE_LIST : { Command_TitleList(client); break; }
  4632. case COMMAND_TITLE_SETPREFIX : { Command_TitleSetPrefix(client, sep); break; }
  4633. case COMMAND_TITLE_SETSUFFIX : { Command_TitleSetSuffix(client, sep); break; }
  4634. case COMMAND_TITLE_FIX : { Command_TitleFix(client, sep); break; }
  4635. case COMMAND_LANGUAGES : { Command_Languages(client, sep); break; }
  4636. case COMMAND_SET_LANGUAGE : { Command_SetLanguage(client, sep); break; }
  4637. case COMMAND_FOLLOW : { Command_Follow(client, sep); break; }
  4638. case COMMAND_STOP_FOLLOW : { Command_StopFollow(client, sep); break; }
  4639. case COMMAND_LASTNAME : { Command_LastName(client, sep); break; }
  4640. case COMMAND_CONFIRMLASTNAME : { Command_ConfirmLastName(client, sep); break; }
  4641. case COMMAND_PET : { Command_Pet(client, sep); break; }
  4642. case COMMAND_PETNAME : { Command_PetName(client, sep); break; }
  4643. case COMMAND_NAME_PET : { Command_NamePet(client, sep); break; }
  4644. case COMMAND_RENAME : { Command_Rename(client, sep); break; }
  4645. case COMMAND_CONFIRMRENAME : { Command_ConfirmRename(client, sep); break; }
  4646. case COMMAND_PETOPTIONS : { Command_PetOptions(client, sep); break; }
  4647. case COMMAND_START_TRADE : { Command_TradeStart(client, sep); break; }
  4648. case COMMAND_ACCEPT_TRADE : { Command_TradeAccept(client, sep); break; }
  4649. case COMMAND_REJECT_TRADE : { Command_TradeReject(client, sep); break; }
  4650. case COMMAND_CANCEL_TRADE : { Command_TradeCancel(client, sep); break; }
  4651. case COMMAND_SET_TRADE_COIN : { Command_TradeSetCoin(client, sep); break; }
  4652. case COMMAND_ADD_TRADE_COPPER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_COPPER); break; }
  4653. case COMMAND_ADD_TRADE_SILVER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_SILVER); break; }
  4654. case COMMAND_ADD_TRADE_GOLD : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_GOLD); break; }
  4655. case COMMAND_ADD_TRADE_PLAT : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_PLAT); break; }
  4656. case COMMAND_REMOVE_TRADE_COPPER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_COPPER); break; }
  4657. case COMMAND_REMOVE_TRADE_SILVER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_SILVER); break; }
  4658. case COMMAND_REMOVE_TRADE_GOLD : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_GOLD); break; }
  4659. case COMMAND_REMOVE_TRADE_PLAT : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_PLAT); break; }
  4660. case COMMAND_ADD_TRADE_ITEM : { Command_TradeAddItem(client, sep); break; }
  4661. case COMMAND_REMOVE_TRADE_ITEM : { Command_TradeRemoveItem(client, sep); break; }
  4662. case COMMAND_ACCEPT_ADVANCEMENT : { Command_AcceptAdvancement(client, sep); break; }
  4663. case COMMAND_DUEL : { Command_Duel(client, sep); break; }
  4664. case COMMAND_DUELBET : { Command_DuelBet(client, sep); break; }
  4665. case COMMAND_DUEL_ACCEPT : { Command_DuelAccept(client, sep); break; }
  4666. case COMMAND_DUEL_DECLINE : { Command_DuelDecline(client, sep); break; }
  4667. case COMMAND_DUEL_SURRENDER : { Command_DuelSurrender(client, sep); break; }
  4668. case COMMAND_DUEL_TOGGLE : { Command_DuelToggle(client, sep); break; }
  4669. case COMMAND_SPAWN_TEMPLATE : { Command_SpawnTemplate(client, sep); break; }
  4670. case COMMAND_MODIFY : { Command_Modify(client); break; }
  4671. case COMMAND_MODIFY_CHARACTER : { Command_ModifyCharacter(client, sep); break; }
  4672. case COMMAND_MODIFY_QUEST : { Command_ModifyQuest(client, sep); break; }
  4673. case COMMAND_MODIFY_FACTION : { Command_ModifyFaction(client, sep); break; }
  4674. case COMMAND_MODIFY_GUILD : { Command_ModifyGuild(client, sep); break; }
  4675. case COMMAND_MODIFY_ITEM : { Command_ModifyItem(client, sep); break; }
  4676. case COMMAND_MODIFY_SKILL : { Command_ModifySkill(client, sep); break; }
  4677. case COMMAND_MODIFY_SPAWN : { Command_ModifySpawn(client, sep); break; }
  4678. case COMMAND_MODIFY_SPELL : { Command_ModifySpell(client, sep); break; }
  4679. case COMMAND_MODIFY_ZONE : { Command_ModifyZone(client, sep); break; }
  4680. case COMMAND_JOIN_CHANNEL : { Command_JoinChannel(client, sep); break;}
  4681. case COMMAND_JOIN_CHANNEL_FROM_LOAD: { Command_JoinChannelFromLoad(client, sep); break;}
  4682. case COMMAND_TELL_CHANNEL : { Command_TellChannel(client, sep); break;}
  4683. case COMMAND_LEAVE_CHANNEL : { Command_LeaveChannel(client, sep); break;}
  4684. case COMMAND_WHO_CHANNEL : { Command_WhoChannel(client, sep); break;}
  4685. case COMMAND_RAIN : { Command_Rain(client, sep); break; }
  4686. case COMMAND_WIND : { Command_Wind(client, sep); break; }
  4687. case COMMAND_WEATHER : { Command_Weather(client, sep); break; }
  4688. case COMMAND_FROM_MERCHANT : { Command_SendMerchantWindow(client, sep); break; }
  4689. case COMMAND_TO_MERCHANT : { Command_SendMerchantWindow(client, sep, true); break; }
  4690. case COMMAND_SELECT : { Command_Select(client, sep); break; }
  4691. case COMMAND_SMP : { Command_StationMarketPlace(client, sep); break; }
  4692. case COMMAND_CONSUME_FOOD : { Command_ConsumeFood(client, sep); break; }
  4693. case COMMAND_AQUAMAN : { Command_Aquaman(client, sep); break; }
  4694. case COMMAND_ATTUNE_INV : { Command_Attune_Inv(client, sep); break; }
  4695. case COMMAND_PLAYER : { Command_Player(client, sep); break; }
  4696. case COMMAND_PLAYER_COINS : { Command_Player_Coins(client, sep); break; }
  4697. case COMMAND_RESET_ZONE_TIMER : { Command_Reset_Zone_Timer(client, sep); break; }
  4698. case COMMAND_ACHIEVEMENT_ADD : { Command_AchievementAdd(client, sep); break; }
  4699. case COMMAND_EDITOR : { Command_Editor(client, sep); break; }
  4700. case COMMAND_ACCEPT_RESURRECTION: { Command_AcceptResurrection(client, sep); break; }
  4701. case COMMAND_DECLINE_RESURRECTION:{ Command_DeclineResurrection(client, sep); break; }
  4702. case COMMAND_TEST : { Command_Test(client, command_parms); break; }
  4703. case COMMAND_SPEED : { Command_Speed(client, sep); break; }
  4704. case COMMAND_BOT : { Command_Bot(client, sep); break; }
  4705. case COMMAND_BOT_CREATE : { Command_Bot_Create(client, sep); break; }
  4706. case COMMAND_BOT_CUSTOMIZE : { Command_Bot_Customize(client, sep); break; }
  4707. case COMMAND_BOT_SPAWN : { Command_Bot_Spawn(client, sep); break; }
  4708. case COMMAND_BOT_LIST : { Command_Bot_List(client, sep); break; }
  4709. case COMMAND_BOT_INV : { Command_Bot_Inv(client, sep); break; }
  4710. case COMMAND_BOT_SETTINGS : { Command_Bot_Settings(client, sep); break; }
  4711. case COMMAND_BOT_HELP : { Command_Bot_Help(client, sep); break; }
  4712. case GET_AA_XML : { Get_AA_Xml(client, sep); break; }
  4713. case ADD_AA : { Add_AA(client, sep); break; }
  4714. case COMMIT_AA_PROFILE : { Commit_AA_Profile(client, sep); break; }
  4715. case BEGIN_AA_PROFILE : { Begin_AA_Profile(client, sep); break; }
  4716. case BACK_AA : { Back_AA(client, sep); break; }
  4717. case REMOVE_AA : { Remove_AA(client, sep); break; }
  4718. case SWITCH_AA_PROFILE : { Switch_AA_Profile(client, sep); break; }
  4719. case CANCEL_AA_PROFILE : { Cancel_AA_Profile(client, sep); break; }
  4720. case SAVE_AA_PROFILE : { Save_AA_Profile(client, sep); break; }
  4721. case COMMAND_TARGETITEM : { Command_TargetItem(client, sep); break; }
  4722. case COMMAND_FINDSPAWN: { Command_FindSpawn(client, sep); break; }
  4723. case COMMAND_MOVECHARACTER: { Command_MoveCharacter(client, sep); break; }
  4724. case COMMAND_CRAFTITEM: {
  4725. Item* item = 0;
  4726. if (sep && sep->IsNumber(0)) {
  4727. int32 item_id = atol(sep->arg[0]);
  4728. int32 quantity = 1;
  4729. if (sep->arg[1] && sep->IsNumber(1))
  4730. quantity = atoi(sep->arg[1]);
  4731. item = new Item(master_item_list.GetItem(item_id));
  4732. if (!item) {
  4733. LogWrite(TRADESKILL__ERROR, 0, "CraftItem", "Item (%u) not found.", item_id);
  4734. }
  4735. else {
  4736. item->details.count = quantity;
  4737. // use CHANNEL_COLOR_CHAT_RELATIONSHIP as that is the same value (4) as it is in a log for this message
  4738. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You created %s.", item->CreateItemLink(client->GetVersion()).c_str());
  4739. client->AddItem(item);
  4740. //Check for crafting quest updates
  4741. int8 update_amt = 0;
  4742. if (item->stack_count > 1)
  4743. update_amt = 1;
  4744. else
  4745. update_amt = quantity;
  4746. client->GetPlayer()->CheckQuestsCraftUpdate(item, update_amt);
  4747. }
  4748. }
  4749. else {
  4750. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /craftitem {item_id} [quantity] ");
  4751. }
  4752. break;
  4753. }
  4754. default:
  4755. {
  4756. LogWrite(COMMAND__WARNING, 0, "Command", "Unhandled command: %s", command->command.data.c_str());
  4757. break;
  4758. }
  4759. }
  4760. safe_delete(sep);
  4761. }
  4762. /******************** New COMMAND Handler Functions ********************/
  4763. /*
  4764. Started breaking apart the huge switch() for commands into sepErate
  4765. functions so it is easier to locate the blocks of code by command
  4766. -- JA 2012.03.03
  4767. */
  4768. // sample function header
  4769. /*
  4770. Function:
  4771. Purpose :
  4772. Params :
  4773. Dev :
  4774. Example :
  4775. */
  4776. //void Commands::Command()
  4777. //{
  4778. //}
  4779. /*
  4780. Function: Command_AcceptAdvancement()
  4781. Purpose : Player accepts a new advancement option
  4782. Params : Spell ID
  4783. Dev : Jabantiz
  4784. */
  4785. void Commands::Command_AcceptAdvancement(Client* client, Seperator* sep)
  4786. {
  4787. Player *player = client->GetPlayer();
  4788. if (sep && sep->IsSet(0)) {
  4789. TraitData* trait = master_trait_list.GetTrait(atoul(sep->arg[0]));
  4790. // Check to see if this is a trait or grandmaster training (traits are always new spells, training is always upgrades)
  4791. if (!player->HasSpell(trait->spellID, 0, true))
  4792. {
  4793. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  4794. player->AddSpellBookEntry(trait->spellID, trait->tier, player->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  4795. }
  4796. else
  4797. {
  4798. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  4799. int8 old_slot = player->GetSpellSlot(spell->GetSpellID());
  4800. player->RemoveSpellBookEntry(spell->GetSpellID());
  4801. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  4802. player->UnlockSpell(spell);
  4803. client->SendSpellUpdate(spell);
  4804. }
  4805. // Spell book update
  4806. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  4807. client->QueuePacket(master_trait_list.GetTraitListPacket(client));
  4808. }
  4809. }
  4810. /*
  4811. Function:
  4812. Purpose :
  4813. Params :
  4814. Dev :
  4815. Example :
  4816. */
  4817. void Commands::Command_AFK(Client* client, Seperator* sep)
  4818. {
  4819. Player* player = client->GetPlayer();
  4820. player->toggle_character_flag(CF_AFK);
  4821. client->Message(CHANNEL_COLOR_YELLOW,"You are %s afk.", client->GetPlayer()->get_character_flag(CF_AFK)?"now":"no longer");
  4822. if (player->get_character_flag(CF_AFK))
  4823. {
  4824. LogWrite(MISC__TODO, 1, "TODO", "player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_AFK); <-- need to find this");
  4825. /*player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_AFK); <-- need to find this */
  4826. if (sep && sep->argplus[0])
  4827. player->SetAwayMessage("I am away from the keyboard, " + string(sep->argplus[0]));
  4828. else
  4829. player->SetAwayMessage("Sorry, I am A.F.K. (Away From Keyboard)");
  4830. string message = string(player->GetName()) + " is going afk.";
  4831. Spawn* target = player->GetTarget();
  4832. if (target && target != player)
  4833. {
  4834. message = string(player->GetName()) + " tells " + string(target->GetName()) + " that ";
  4835. player->GetGender() == 1 ? message += "he" : message += "she";
  4836. message += " is going afk.";
  4837. }
  4838. player->GetZone()->SimpleMessage(CHANNEL_COLOR_YELLOW, message.c_str(), player, 30);
  4839. }
  4840. /*else
  4841. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_AFK); <-- need to find this */
  4842. }
  4843. /*
  4844. Function: Command_Appearance()
  4845. Purpose : Handles /appearance commands
  4846. Params : list
  4847. Dev : Scatman
  4848. Example : /appearance list
  4849. */
  4850. void Commands::Command_Appearance(Client* client, Seperator* sep, int handler)
  4851. {
  4852. if( handler == COMMAND_APPEARANCE )
  4853. {
  4854. // /appearance command by itself shows help (to be extended)
  4855. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  4856. return;
  4857. }
  4858. else if( handler == COMMAND_APPEARANCE_LIST )
  4859. {
  4860. // /appearance list command expects "name" param
  4861. if (sep && sep->arg[0])
  4862. {
  4863. const char* appearance_name = sep->argplus[0];
  4864. client->Message(CHANNEL_COLOR_YELLOW, "Listing appearances like '%s':", appearance_name);
  4865. vector<int16>* appearances = database.GetAppearanceIDsLikeName(string(appearance_name));
  4866. if (appearances)
  4867. {
  4868. vector<int16>::iterator itr;
  4869. for (itr = appearances->begin(); itr != appearances->end(); itr++)
  4870. {
  4871. int16 id = *itr;
  4872. string name = database.GetAppearanceName(id);
  4873. if (ToLower(name).find(ToLower(string(appearance_name))) < 0xFFFFFFFF)
  4874. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", name.c_str(), id);
  4875. }
  4876. safe_delete(appearances);
  4877. }
  4878. }
  4879. else // no param
  4880. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  4881. }
  4882. }
  4883. /*
  4884. Function: Command_Claim()
  4885. Purpose :
  4886. Params :
  4887. Dev :
  4888. Example :
  4889. */
  4890. void Commands::Command_Claim(Client* client, Seperator* sep)
  4891. {
  4892. if (sep && sep->arg[0] && sep->IsNumber(0))
  4893. {
  4894. LogWrite(MISC__TODO, 1, "TODO", "On Scatman's TODO list!\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  4895. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "On Scatman's TODO :)");
  4896. }
  4897. else
  4898. client->ShowClaimWindow();
  4899. }
  4900. /*
  4901. Function: Command_ClearAllQueued()
  4902. Purpose :
  4903. Params :
  4904. Dev :
  4905. Example :
  4906. */
  4907. void Commands::Command_ClearAllQueued(Client* client)
  4908. {
  4909. ZoneServer* zone = client->GetPlayer()->GetZone();
  4910. if (zone && zone->GetSpellProcess())
  4911. zone->GetSpellProcess()->RemoveSpellFromQueue(client->GetPlayer());
  4912. }
  4913. /*
  4914. Function: Command_CancelMaintained()
  4915. Purpose : Cancels maintained spells
  4916. Params : Maintained Spell Index
  4917. Dev : Zcoretri
  4918. Example : /cancel_maintained 1 - would cancel the spell in slot 1 of Maintained Spells list
  4919. */
  4920. void Commands::Command_CancelMaintained(Client* client, Seperator* sep)
  4921. {
  4922. if (sep && sep->arg[0] && sep->IsNumber(0))
  4923. {
  4924. int32 spell_index = atoul(sep->arg[0]);
  4925. MaintainedEffects mEffects = client->GetPlayer()->GetInfoStruct()->maintained_effects[spell_index];
  4926. //Spell* spell = master_spell_list.GetSpell(mEffects.spell_id, mEffects.tier);
  4927. // if (spell && spell->GetSpellData()->friendly_spell) -- NOTE::You can cancel hostile maintained spells,
  4928. // just not spelleffects/dets - Foof
  4929. //{
  4930. if (!client->GetPlayer()->GetZone()->GetSpellProcess()->DeleteCasterSpell(mEffects.spell, "canceled"))
  4931. client->Message(CHANNEL_COLOR_RED, "The maintained spell could not be cancelled.");
  4932. // }
  4933. //else
  4934. //client->Message(CHANNEL_COLOR_RED, "You can only cancel friendly spells!");
  4935. }
  4936. }
  4937. /*
  4938. Function: Command_Create()
  4939. Purpose : Handler for starting Tradeskilling table
  4940. Params :
  4941. Dev : Zcoretri
  4942. Example :
  4943. */
  4944. void Commands::Command_Create(Client* client, Seperator* sep)
  4945. {
  4946. PrintSep(sep, "COMMAND_CREATE");
  4947. client->SendRecipeList();
  4948. client->ShowRecipeBook();
  4949. }
  4950. void Commands::Command_CreateFromRecipe(Client* client, Seperator* sep)
  4951. {
  4952. PrintSep(sep, "COMMAND_CREATEFROMRECIPE");
  4953. if (sep && sep->arg[0] && sep->IsNumber(0))
  4954. ClientPacketFunctions::SendCreateFromRecipe(client, atoul(sep->arg[0]));
  4955. }
  4956. /*
  4957. Function: Command_Distance()
  4958. Purpose : Displays distance from targeted spawn
  4959. Params :
  4960. Dev : Scatman
  4961. Example : /distance
  4962. */
  4963. void Commands::Command_Distance(Client* client)
  4964. {
  4965. Spawn* target = client->GetPlayer()->GetTarget();
  4966. if (target)
  4967. client->Message(CHANNEL_COLOR_YELLOW, "Your distance from %s is %f", target->GetName(), client->GetPlayer()->GetDistance(target));
  4968. else
  4969. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must have a spawn targeted to use /distance");
  4970. }
  4971. /*
  4972. Function: Command_Duel()
  4973. Purpose : Handle the /duel commands - not yet implemented
  4974. Params : unknown
  4975. Dev :
  4976. Example :
  4977. */
  4978. void Commands::Command_Duel(Client* client, Seperator* sep)
  4979. {
  4980. PrintSep(sep, "COMMAND_DUEL");
  4981. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Command");
  4982. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4983. }
  4984. /*
  4985. Function: Command_DuelBet()
  4986. Purpose : Handle the /duel commands - not yet implemented
  4987. Params : unknown
  4988. Dev :
  4989. Example :
  4990. */
  4991. void Commands::Command_DuelBet(Client* client, Seperator* sep)
  4992. {
  4993. PrintSep(sep, "COMMAND_DUELBET");
  4994. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Bet Command");
  4995. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4996. }
  4997. /*
  4998. Function: Command_DuelAccept()
  4999. Purpose : Handle the /duel commands - not yet implemented
  5000. Params : unknown
  5001. Dev :
  5002. Example :
  5003. */
  5004. void Commands::Command_DuelAccept(Client* client, Seperator* sep)
  5005. {
  5006. PrintSep(sep, "COMMAND_DUEL_ACCEPT");
  5007. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Accept Duel Command");
  5008. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5009. }
  5010. /*
  5011. Function: Command_DuelDecline()
  5012. Purpose : Handle the /duel commands - not yet implemented
  5013. Params : unknown
  5014. Dev :
  5015. Example :
  5016. */
  5017. void Commands::Command_DuelDecline(Client* client, Seperator* sep)
  5018. {
  5019. PrintSep(sep, "COMMAND_DUEL_DECLINE");
  5020. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Decline Duel Request Command");
  5021. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5022. }
  5023. /*
  5024. Function: Command_DuelSurrender()
  5025. Purpose : Handle the /duel commands - not yet implemented
  5026. Params : unknown
  5027. Dev :
  5028. Example :
  5029. */
  5030. void Commands::Command_DuelSurrender(Client* client, Seperator* sep)
  5031. {
  5032. PrintSep(sep, "COMMAND_DUEL_SURRENDER");
  5033. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Surrender Duel Command");
  5034. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5035. // JA, just messin around ;)
  5036. char surrender[64];
  5037. sprintf(surrender, "%s surrendered like a cowardly dog!", client->GetPlayer()->GetName());
  5038. zone_list.HandleGlobalAnnouncement(surrender);
  5039. }
  5040. /*
  5041. Function: Command_DuelToggle()
  5042. Purpose : Handle the /duel commands - not yet implemented
  5043. Params : unknown
  5044. Dev :
  5045. Example :
  5046. */
  5047. void Commands::Command_DuelToggle(Client* client, Seperator* sep)
  5048. {
  5049. PrintSep(sep, "COMMAND_DUEL");
  5050. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Commands");
  5051. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  5052. }
  5053. /*
  5054. Function:
  5055. Purpose :
  5056. Params :
  5057. Dev :
  5058. Example :
  5059. */
  5060. void Commands::Command_EntityCommand(Client* client, Seperator* sep, int handler)
  5061. {
  5062. if( handler == COMMAND_ENTITYCOMMAND )
  5063. {
  5064. // /entitycommand command by itself shows help (to be extended)
  5065. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  5066. return;
  5067. }
  5068. else if( handler == COMMAND_ENTITYCOMMAND_LIST )
  5069. {
  5070. // /entitycommand list command expects "name" param
  5071. if (sep && sep->arg[0])
  5072. {
  5073. const char* entity_command_name = sep->argplus[0];
  5074. client->Message(CHANNEL_COLOR_YELLOW, "Listing entity commands like '%s':", entity_command_name);
  5075. map<int32, vector<EntityCommand*>*>* entity_command_list_all = client->GetCurrentZone()->GetEntityCommandListAll();
  5076. map<int32, vector<EntityCommand*>*>::iterator itr;
  5077. for (itr = entity_command_list_all->begin(); itr != entity_command_list_all->end(); itr++)
  5078. {
  5079. vector<EntityCommand*>* entity_command_list = itr->second;
  5080. vector<EntityCommand*>::iterator itr2;
  5081. for (itr2 = entity_command_list->begin(); itr2 != entity_command_list->end(); itr2++)
  5082. {
  5083. EntityCommand* entity_command = *itr2;
  5084. if (ToLower(entity_command->name).find(ToLower(string(entity_command_name))) < 0xFFFFFFFF)
  5085. 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);
  5086. }
  5087. }
  5088. }
  5089. else // no command name
  5090. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  5091. }
  5092. }
  5093. /*
  5094. Function: Command_Follow()
  5095. Purpose : Handle the /follow command - not yet implemented
  5096. Params :
  5097. Dev :
  5098. Example :
  5099. */
  5100. void Commands::Command_Follow(Client* client, Seperator* sep)
  5101. {
  5102. PrintSep(sep, "COMMAND_FOLLOW");
  5103. // flag to toggle if the players target is in the players group
  5104. bool targetInGroup = false;
  5105. // get a pointer to the players group
  5106. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  5107. // If the player has a group and has a target
  5108. if (gmi && client->GetPlayer()->GetTarget()) {
  5109. deque<GroupMemberInfo*>::iterator itr;
  5110. world.GetGroupManager()->GroupLock(__FUNCTION__, __LINE__);
  5111. PlayerGroup* group = world.GetGroupManager()->GetGroup(gmi->group_id);
  5112. if (group)
  5113. {
  5114. group->MGroupMembers.readlock(__FUNCTION__, __LINE__);
  5115. deque<GroupMemberInfo*>* members = group->GetMembers();
  5116. // Loop through the group members
  5117. for (itr = members->begin(); itr != members->end(); itr++) {
  5118. // If a group member matches a target
  5119. if ((*itr)->member == client->GetPlayer()->GetTarget()) {
  5120. // toggle the flag and break the loop
  5121. targetInGroup = true;
  5122. break;
  5123. }
  5124. }
  5125. group->MGroupMembers.releasereadlock(__FUNCTION__, __LINE__);
  5126. }
  5127. world.GetGroupManager()->ReleaseGroupLock(__FUNCTION__, __LINE__);
  5128. }
  5129. if (targetInGroup) {
  5130. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  5131. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You start to follow %s.", client->GetPlayer()->GetTarget()->GetName());
  5132. client->GetPlayer()->SetFollowTarget(client->GetPlayer()->GetTarget());
  5133. client->GetPlayer()->info_changed = true;
  5134. client->GetPlayer()->changed = true;
  5135. }
  5136. else
  5137. client->Message(CHANNEL_NARRATIVE, "You must first select a group member to follow.");
  5138. }
  5139. /*
  5140. Function: Command_StopFollow()
  5141. Purpose : Handle the /stop_follow command - not yet implemented
  5142. Params :
  5143. Dev :
  5144. Example :
  5145. */
  5146. void Commands::Command_StopFollow(Client* client, Seperator* sep)
  5147. {
  5148. PrintSep(sep, "COMMAND_STOP_FOLLOW");
  5149. if (client->GetPlayer()->GetFollowTarget()) {
  5150. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  5151. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You are no longer following %s", client->GetPlayer()->GetFollowTarget()->GetName());
  5152. client->GetPlayer()->SetFollowTarget(0);
  5153. client->GetPlayer()->info_changed = true;
  5154. client->GetPlayer()->changed = true;
  5155. }
  5156. }
  5157. #include "../Zone/SPGrid.h"
  5158. /*
  5159. Function: Command_Grid()
  5160. Purpose : Show player's current Grid ID
  5161. Params :
  5162. Dev : Scatman
  5163. Example : /grid
  5164. */
  5165. void Commands::Command_Grid(Client* client)
  5166. {
  5167. client->Message(CHANNEL_COLOR_YELLOW, "Your Grid ID is %u", client->GetPlayer()->appearance.pos.grid_id);
  5168. if (client->GetPlayer()->GetMap() != nullptr) {
  5169. int32 grid = client->GetPlayer()->GetMap()->GetGrid()->GetGridID(client->GetPlayer());
  5170. client->Message(CHANNEL_COLOR_YELLOW, "SPGrid result is %u", grid);
  5171. }
  5172. }
  5173. /*
  5174. Function: Command_Guild()
  5175. Purpose : Handler for all UI-related guild commands
  5176. Dev : Scatman
  5177. */
  5178. void Commands::Command_Guild(Client* client, Seperator* sep)
  5179. {
  5180. Guild* guild = client->GetPlayer()->GetGuild();
  5181. if (sep && sep->GetMaxArgNum() > 0 && sep->arg[0])
  5182. {
  5183. const char* command = sep->arg[0];
  5184. int32 length = strlen(command);
  5185. LogWrite(COMMAND__DEBUG, 0, "Command", "Guild Command: %s", command);
  5186. if (strncmp(command, "rank_name", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && guild)
  5187. guild->SetRankName(atoi(sep->arg[1]), sep->argplus[2]);
  5188. else if (strncmp(command, "rank_permission", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  5189. guild->SetPermission(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  5190. else if (strncmp(command, "filter_event", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  5191. guild->SetEventFilter(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  5192. else if (strncmp(command, "kick", length) == 0 && sep->arg[1] && guild)
  5193. guild->KickGuildMember(client, sep->arg[1]);
  5194. else if (strncmp(command, "demote", length) == 0 && sep->arg[1] && guild)
  5195. guild->DemoteGuildMember(client, sep->arg[1]);
  5196. else if (strncmp(command, "promote", length) == 0 && sep->arg[1] && guild)
  5197. guild->PromoteGuildMember(client, sep->arg[1]);
  5198. else if (strncmp(command, "points", length) == 0 && guild)
  5199. {
  5200. if (sep->arg[1] && strncmp(sep->arg[1], "add", length) == 0)
  5201. {
  5202. if (sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  5203. {
  5204. float points = atof(sep->arg[2]);
  5205. const char* option = sep->arg[3];
  5206. const char* comment = sep->argplus[4];
  5207. if (strncmp(option, "all", strlen(option)) == 0)
  5208. guild->AddPointsToAll(client, points, comment);
  5209. else if (strncmp(option, "online", strlen(option)) == 0)
  5210. guild->AddPointsToAllOnline(client, points, comment);
  5211. else if (strncmp(option, "group", strlen(option)) == 0)
  5212. guild->AddPointsToGroup(client, points, comment);
  5213. else if (strncmp(option, "raid", strlen(option)) == 0)
  5214. guild->AddPointsToRaid(client, points, comment);
  5215. else
  5216. guild->AddPointsToGuildMember(client, points, option, comment);
  5217. }
  5218. }
  5219. else if (sep->arg[1] && strncmp(sep->arg[1], "view", strlen(sep->arg[1])) == 0 && sep->arg[2])
  5220. guild->ViewGuildMemberPoints(client, sep->arg[2]);
  5221. else
  5222. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild points command: %s", sep->argplus[0]);
  5223. }
  5224. else if (strncmp(command, "motd", length) == 0 && sep->arg[1] && guild)
  5225. guild->SetMOTD(sep->argplus[1]);
  5226. else if (strncmp(command, "recruiting", length) == 0 && guild)
  5227. {
  5228. if (sep->arg[1])
  5229. {
  5230. const char* option = sep->arg[1];
  5231. if (strncmp(option, "short_text", strlen(option)) == 0 && sep->arg[2])
  5232. guild->SetRecruitingShortDesc(sep->argplus[2]);
  5233. else if (strncmp(option, "long_text", strlen(option)) == 0 && sep->arg[2])
  5234. guild->SetRecruitingFullDesc(sep->argplus[2]);
  5235. else if (strncmp(option, "flag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  5236. guild->SetRecruitingFlag(atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  5237. else if (strncmp(option, "min_level", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  5238. guild->SetRecruitingMinLevel(atoi(sep->arg[2]));
  5239. else if (strncmp(option, "playstyle", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  5240. guild->SetRecruitingPlayStyle(atoi(sep->arg[2]));
  5241. else if (strncmp(option, "tag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && sep->IsNumber(3))
  5242. guild->SetRecruitingDescTag(atoi(sep->arg[2]), atoi(sep->arg[3]));
  5243. else if (strncmp(command, "recruiting", strlen(option)) == 0)
  5244. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_RECRUITING_FOR_GUILD, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  5245. else
  5246. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  5247. }
  5248. else
  5249. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  5250. }
  5251. else if (strncmp(command, "notify_online", length) == 0 && sep->arg[1] && guild)
  5252. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_NOTIFY_LOGINS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  5253. else if (strncmp(command, "event_privacy", length) == 0 && sep->arg[1] && guild)
  5254. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_DONT_GENERATE_EVENTS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  5255. else if (strncmp(command, "recruiter", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  5256. guild->SetGuildRecruiter(client, sep->arg[1], strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  5257. else if (strncmp(command, "recruiter_description", length) == 0 && sep->arg[1] && guild)
  5258. guild->SetGuildRecruiterDescription(client, sep->argplus[1]);
  5259. else if (strncmp(command, "lock_event", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  5260. guild->LockGuildEvent(atoul(sep->arg[1]), strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  5261. else if (strncmp(command, "delete_event", length) == 0 && sep->arg[1] && guild)
  5262. guild->DeleteGuildEvent(atoul(sep->arg[1]));
  5263. else if (strncmp(command, "invite", length) == 0 && guild)
  5264. {
  5265. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  5266. guild->InvitePlayer(client, sep->arg[1]);
  5267. else
  5268. {
  5269. Spawn* target = client->GetPlayer()->GetTarget();
  5270. if (target)
  5271. {
  5272. if (target->IsPlayer())
  5273. guild->InvitePlayer(client, target->GetName());
  5274. else
  5275. client->Message(CHANNEL_NARRATIVE, "%s is not a player.", target->GetName());
  5276. }
  5277. }
  5278. }
  5279. else if (strncmp(command, "accept", length) == 0)
  5280. {
  5281. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  5282. if (pgi && pgi->guild && pgi->invited_by)
  5283. pgi->guild->AddNewGuildMember(client, pgi->invited_by->GetName());
  5284. client->SetPendingGuildInvite(0);
  5285. }
  5286. else if (strncmp(command, "decline", length) == 0)
  5287. {
  5288. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  5289. if (pgi && pgi->guild && pgi->invited_by)
  5290. {
  5291. Client* client_inviter = pgi->invited_by->GetZone()->GetClientBySpawn(pgi->invited_by);
  5292. if (client_inviter)
  5293. client_inviter->Message(CHANNEL_NARRATIVE, "%s has declined your invitation to join %s.", client->GetPlayer()->GetName(), pgi->guild->GetName());
  5294. }
  5295. client->SetPendingGuildInvite(0);
  5296. }
  5297. else if (strncmp(command, "create", length) == 0 && sep->arg[1])
  5298. {
  5299. const char* guild_name = sep->argplus[1];
  5300. if (!guild_list.GetGuild(guild_name))
  5301. world.CreateGuild(guild_name, client, client->GetPlayer()->GetGroupMemberInfo() ? client->GetPlayer()->GetGroupMemberInfo()->group_id : 0);
  5302. else
  5303. client->SimpleMessage(CHANNEL_NARRATIVE, "A guild with that name already exists.");
  5304. }
  5305. else if (strncmp(command, "search", length) == 0)
  5306. client->ShowGuildSearchWindow();
  5307. else if (strncmp(command, "recruiting_details", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  5308. {
  5309. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  5310. if (to_guild)
  5311. to_guild->SendGuildRecruitingDetails(client);
  5312. }
  5313. else if (strncmp(command, "recruiting_image", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  5314. {
  5315. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  5316. if (to_guild)
  5317. to_guild->SendGuildRecruitingImages(client);
  5318. }
  5319. else if (strncmp(command, "recruiter_adventure_class", length) == 0)
  5320. {
  5321. if (sep->arg[1])
  5322. {
  5323. const char* option = sep->arg[1];
  5324. if (strncmp(option, "toggle", strlen(option)) == 0)
  5325. guild->ToggleGuildRecruiterAdventureClass(client);
  5326. }
  5327. else
  5328. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiter_adventure_class command: '%s'", sep->argplus[0]);
  5329. }
  5330. else if (strncmp(command, "display_heraldry", length) == 0)
  5331. {
  5332. // JA: not sure this is right...
  5333. client->GetPlayer()->toggle_character_flag(CF_SHOW_GUILD_HERALDRY);
  5334. client->GetPlayer()->SetCharSheetChanged(true);
  5335. }
  5336. else
  5337. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild command: '%s'", sep->argplus[0]);
  5338. }
  5339. }
  5340. /*
  5341. Function: Command_GuildCreate()
  5342. Purpose : Display's in-game Guild Creation window
  5343. Dev : Scatman
  5344. */
  5345. void Commands::Command_CreateGuild(Client* client)
  5346. {
  5347. client->SendGuildCreateWindow();
  5348. }
  5349. /*
  5350. Function: Command_SetGuildOfficerNote()
  5351. Purpose :
  5352. Dev : Scatman
  5353. */
  5354. void Commands::Command_SetGuildOfficerNote(Client* client, Seperator* sep)
  5355. {
  5356. if (sep && sep->arg[0] && sep->arg[1])
  5357. {
  5358. Guild* guild = client->GetPlayer()->GetGuild();
  5359. if (guild)
  5360. guild->SetGuildOfficerNote(sep->arg[0], sep->argplus[1]);
  5361. }
  5362. }
  5363. /*
  5364. Function: Command_SetGuildMemberNote()
  5365. Purpose :
  5366. Dev : Scatman
  5367. */
  5368. void Commands::Command_SetGuildMemberNote(Client* client, Seperator* sep)
  5369. {
  5370. if (sep && sep->arg[0] && sep->arg[1])
  5371. {
  5372. Guild* guild = client->GetPlayer()->GetGuild();
  5373. if (guild)
  5374. guild->SetGuildMemberNote(sep->arg[0], sep->argplus[1]);
  5375. }
  5376. }
  5377. /*
  5378. Function: Command_GuildSay()
  5379. Purpose :
  5380. Dev : Scatman
  5381. */
  5382. void Commands::Command_GuildSay(Client* client, Seperator* sep)
  5383. {
  5384. Guild* guild = client->GetPlayer()->GetGuild();
  5385. if (guild)
  5386. {
  5387. if (sep && sep->arg[0])
  5388. guild->HandleGuildSay(client, sep->argplus[0]);
  5389. }
  5390. else
  5391. client->SimpleMessage(CHANNEL_NARRATIVE, "You are not a member of a guild");
  5392. }
  5393. /*
  5394. Function: Command_OfficerSay()
  5395. Purpose :
  5396. Dev : Scatman
  5397. */
  5398. void Commands::Command_OfficerSay(Client* client, Seperator* sep)
  5399. {
  5400. Guild* guild = client->GetPlayer()->GetGuild();
  5401. if (guild)
  5402. {
  5403. if (sep && sep->arg[0])
  5404. guild->HandleOfficerSay(client, sep->argplus[0]);
  5405. }
  5406. else
  5407. client->SimpleMessage(CHANNEL_NARRATIVE, "You are not a member of a guild");
  5408. }
  5409. /*
  5410. Function: Command_Guilds()
  5411. Purpose : Shows help for /guild command
  5412. Params :
  5413. Dev : Scatman
  5414. Example :
  5415. */
  5416. void Commands::Command_Guilds(Client* client)
  5417. {
  5418. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds [create|delete|add|remove|list]");
  5419. }
  5420. /*
  5421. Function: Command_GuildsAdd()
  5422. Purpose : Add's players to a guild
  5423. Params : guild_name|guild_id, player name
  5424. Dev : Scatman
  5425. Example : /guilds add 1 Admin = adds player Admin to guild_id 1
  5426. */
  5427. void Commands::Command_GuildsAdd(Client* client, Seperator* sep)
  5428. {
  5429. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  5430. {
  5431. Guild* guild = 0;
  5432. bool found = true;
  5433. if (sep->IsNumber(0))
  5434. {
  5435. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  5436. if (!guild)
  5437. {
  5438. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  5439. found = false;
  5440. }
  5441. }
  5442. else
  5443. {
  5444. guild = guild_list.GetGuild(sep->arg[0]);
  5445. if (!guild)
  5446. {
  5447. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  5448. found = false;
  5449. }
  5450. }
  5451. if (found)
  5452. {
  5453. Client* to_client = 0;
  5454. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  5455. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  5456. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  5457. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  5458. if (to_client)
  5459. guild->InvitePlayer(client, to_client->GetPlayer()->GetName());
  5460. else
  5461. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  5462. }
  5463. }
  5464. else
  5465. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds add [guild name|guild id] (player name).");
  5466. }
  5467. /*
  5468. Function: Command_GuildsCreate()
  5469. Purpose : Creates a guild
  5470. Params : guild_name, player_name (optional)
  5471. Dev : Scatman
  5472. Example : /guilds create [guild name] (player name)
  5473. */
  5474. void Commands::Command_GuildsCreate(Client* client, Seperator* sep)
  5475. {
  5476. if (sep && sep->arg[0])
  5477. {
  5478. const char* guild_name = sep->arg[0];
  5479. if (!guild_list.GetGuild(guild_name))
  5480. {
  5481. bool ret = false;
  5482. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  5483. {
  5484. Client* to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  5485. if (to_client)
  5486. {
  5487. world.CreateGuild(guild_name, to_client);
  5488. ret = true;
  5489. }
  5490. else
  5491. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player with name '%s'", sep->arg[1]);
  5492. }
  5493. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  5494. {
  5495. Client* to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  5496. if (to_client)
  5497. {
  5498. world.CreateGuild(guild_name, to_client);
  5499. ret = true;
  5500. }
  5501. }
  5502. else
  5503. {
  5504. world.CreateGuild(guild_name);
  5505. ret = true;
  5506. }
  5507. if (ret)
  5508. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully created.", guild_name);
  5509. else
  5510. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the guild.");
  5511. }
  5512. else
  5513. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' already exists.", guild_name);
  5514. }
  5515. else
  5516. 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.");
  5517. }
  5518. /*
  5519. Function: Command_GuildsDelete()
  5520. Purpose : Delete's a guild
  5521. Params : guild name
  5522. Dev : Scatman
  5523. Example : /guilds delete Test
  5524. */
  5525. void Commands::Command_GuildsDelete(Client* client, Seperator* sep)
  5526. {
  5527. if (sep && sep->arg[0])
  5528. {
  5529. Guild* guild = 0;
  5530. bool found = true;
  5531. if (sep->IsNumber(0))
  5532. {
  5533. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  5534. if (!guild)
  5535. {
  5536. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  5537. found = false;
  5538. }
  5539. }
  5540. else
  5541. {
  5542. guild = guild_list.GetGuild(sep->arg[0]);
  5543. if (!guild)
  5544. {
  5545. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  5546. found = false;
  5547. }
  5548. }
  5549. if (found)
  5550. {
  5551. guild->RemoveAllGuildMembers();
  5552. database.DeleteGuild(guild);
  5553. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully deleted.", guild->GetName());
  5554. guild_list.RemoveGuild(guild, true);
  5555. }
  5556. }
  5557. else
  5558. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds delete [guild name].");
  5559. }
  5560. /*
  5561. Function: Command_GuildsList()
  5562. Purpose : Lists current guilds on server
  5563. Params :
  5564. Dev : Scatman
  5565. Example : /guilds list
  5566. */
  5567. void Commands::Command_GuildsList(Client* client)
  5568. {
  5569. MutexMap<int32, Guild*>* guilds = guild_list.GetGuilds();
  5570. MutexMap<int32, Guild*>::iterator itr = guilds->begin();
  5571. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Guild List:");
  5572. if (guilds->size() == 0)
  5573. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "None.");
  5574. else {
  5575. while (itr.Next()) {
  5576. Guild* guild = itr.second;
  5577. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", guild->GetID(), guild->GetName());
  5578. }
  5579. }
  5580. }
  5581. /*
  5582. Function: Command_GuildsRemove()
  5583. Purpose : Removes a player from a guild
  5584. Params : guild name|guild id, player name
  5585. Dev : Scatman
  5586. Example : /guilds remove 1 Admin = removes Admin from guild 1
  5587. */
  5588. void Commands::Command_GuildsRemove(Client* client, Seperator* sep)
  5589. {
  5590. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  5591. {
  5592. Guild* guild = 0;
  5593. bool found = true;
  5594. if (sep->IsNumber(0))
  5595. {
  5596. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  5597. if (!guild)
  5598. {
  5599. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  5600. found = false;
  5601. }
  5602. }
  5603. else
  5604. {
  5605. guild = guild_list.GetGuild(sep->arg[0]);
  5606. if (!guild)
  5607. {
  5608. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  5609. found = false;
  5610. }
  5611. }
  5612. if (found)
  5613. {
  5614. Client* to_client = 0;
  5615. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  5616. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  5617. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  5618. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  5619. if (to_client)
  5620. {
  5621. Player* to_player = to_client->GetPlayer();
  5622. if (to_player->GetGuild())
  5623. {
  5624. if (to_player->GetGuild() == guild)
  5625. {
  5626. guild->KickGuildMember(client, to_player->GetName());
  5627. }
  5628. else
  5629. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in the guild '%s'.", to_player->GetName(), guild->GetName());
  5630. }
  5631. else
  5632. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in a guild.", to_player->GetName());
  5633. }
  5634. else
  5635. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  5636. }
  5637. }
  5638. else
  5639. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds remove [guild name|guild id] (player name).");
  5640. }
  5641. /*
  5642. Function: Command_InspectPlayer()
  5643. Purpose : Handle the Inspect functions
  5644. Params : Client to inspect
  5645. Dev : Scatman
  5646. Example : /inspect Scatman
  5647. */
  5648. void Commands::Command_InspectPlayer(Client* client, Seperator* sep)
  5649. {
  5650. if (sep && sep->arg[0])
  5651. {
  5652. Client* inspect_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  5653. if (inspect_client)
  5654. client->InspectPlayer(inspect_client->GetPlayer());
  5655. }
  5656. else
  5657. {
  5658. Spawn* target = client->GetPlayer()->GetTarget();
  5659. if (target && target->IsPlayer())
  5660. client->InspectPlayer((Player*)target);
  5661. }
  5662. }
  5663. /*
  5664. Function: Command_Inventory()
  5665. Purpose : Handle changes in player inventory
  5666. Params : <TBD>
  5667. Dev : All
  5668. Example : /inventory delete item_id
  5669. */
  5670. void Commands::Command_Inventory(Client* client, Seperator* sep, EQ2_RemoteCommandString* command)
  5671. {
  5672. PrintSep(sep, "Command_Inventory"); // temp to figure out the params
  5673. Player* player = client->GetPlayer();
  5674. if(sep && sep->arg[0][0])
  5675. {
  5676. LogWrite(COMMAND__INFO, 0, "Command", "command: %s", sep->argplus[0]);
  5677. if(client->GetPlayer()->GetHP() == 0)
  5678. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  5679. else if(sep->arg[1][0] && strncasecmp("destroy", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  5680. {
  5681. int16 index = atoi(sep->arg[1]);
  5682. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  5683. if(item)
  5684. {
  5685. if(item->GetItemScript() && lua_interface)
  5686. lua_interface->RunItemScript(item->GetItemScript(), "destroyed", item, client->GetPlayer());
  5687. int32 bag_id = item->details.inv_slot_id;
  5688. database.DeleteItem(client->GetCharacterID(), item, 0);
  5689. client->GetPlayer()->item_list.DestroyItem(index);
  5690. EQ2Packet* outapp = client->GetPlayer()->SendInventoryUpdate(client->GetVersion());
  5691. client->QueuePacket(outapp);
  5692. outapp = client->GetPlayer()->SendBagUpdate(bag_id, client->GetVersion());
  5693. if (outapp)
  5694. client->QueuePacket(outapp);
  5695. }
  5696. }
  5697. 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))
  5698. {
  5699. int16 from_index = atoi(sep->arg[1]);
  5700. sint16 to_slot = atoi(sep->arg[2]);
  5701. sint32 bag_id = atol(sep->arg[3]);
  5702. int8 charges = atoi(sep->arg[4]);
  5703. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(from_index);
  5704. if(bag_id == -4 && !client->GetPlayer()->item_list.SharedBankAddAllowed(item))
  5705. {
  5706. client->SimpleMessage(CHANNEL_COLOR_RED, "That item (or an item inside) cannot be shared.");
  5707. return;
  5708. }
  5709. sint32 old_inventory_id = 0;
  5710. if(item)
  5711. old_inventory_id = item->details.inv_slot_id;
  5712. //autobank
  5713. if (bag_id == -3 && to_slot == -1)
  5714. {
  5715. if (player->HasFreeBankSlot())
  5716. to_slot = player->FindFreeBankSlot();
  5717. else
  5718. {
  5719. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free bank slots.");
  5720. return;
  5721. }
  5722. }
  5723. //auto inventory
  5724. if (bag_id == 0 && to_slot == -1)
  5725. {
  5726. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  5727. {
  5728. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free slots.");
  5729. return;
  5730. }
  5731. }
  5732. EQ2Packet* outapp = client->GetPlayer()->MoveInventoryItem(bag_id, from_index, (int8)to_slot, charges, 0, client->GetVersion());
  5733. client->QueuePacket(outapp);
  5734. //removed from bag send update
  5735. if(old_inventory_id > 0 && item && item->details.inv_slot_id != old_inventory_id)
  5736. {
  5737. outapp = client->GetPlayer()->SendBagUpdate(old_inventory_id, client->GetVersion());
  5738. if(outapp)
  5739. client->QueuePacket(outapp);
  5740. }
  5741. if(item && item->details.inv_slot_id > 0 && item->details.inv_slot_id != old_inventory_id)
  5742. {
  5743. outapp = client->GetPlayer()->SendBagUpdate(item->details.inv_slot_id, client->GetVersion());
  5744. if(outapp)
  5745. client->QueuePacket(outapp);
  5746. }
  5747. }
  5748. else if(sep->arg[1][0] && strncasecmp("equip", sep->arg[0], 5) == 0 && sep->IsNumber(1))
  5749. {
  5750. if(client->GetPlayer()->EngagedInCombat())
  5751. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not equip items while in combat.");
  5752. else
  5753. {
  5754. int16 index = atoi(sep->arg[1]);
  5755. int8 slot_id = 255;
  5756. int8 unk3 = 0;
  5757. int8 appearance_equip = 0;
  5758. if(sep->arg[2][0] && sep->IsNumber(2))
  5759. slot_id = atoi(sep->arg[2]);
  5760. if(sep->arg[3][0] && sep->IsNumber(3))
  5761. unk3 = atoul(sep->arg[3]);
  5762. if(sep->arg[4][0] && sep->IsNumber(4))
  5763. appearance_equip = atoul(sep->arg[4]);
  5764. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), appearance_equip, slot_id);
  5765. EQ2Packet* outapp = 0;
  5766. for(int32 i=0;i<packets.size();i++)
  5767. {
  5768. outapp = packets[i];
  5769. if(outapp)
  5770. client->QueuePacket(outapp);
  5771. }
  5772. client->GetPlayer()->ChangePrimaryWeapon();
  5773. client->GetPlayer()->ChangeSecondaryWeapon();
  5774. client->GetPlayer()->ChangeRangedWeapon();
  5775. EQ2Packet* characterSheetPackets = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion());
  5776. client->QueuePacket(characterSheetPackets);
  5777. }
  5778. }
  5779. else if (sep->arg[1][0] && strncasecmp("unpack", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  5780. {
  5781. if (client->GetPlayer()->EngagedInCombat())
  5782. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unpack items while in combat.");
  5783. else {
  5784. int16 index = atoi(sep->arg[1]);
  5785. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  5786. if (item) {
  5787. // client->GetPlayer()->item_list.DestroyItem(index);
  5788. if (item->item_sets.size() > 0) {
  5789. for (int32 i = 0; i < item->item_sets.size(); i++) {
  5790. ItemSet* set = item->item_sets[i];
  5791. if (set->item_stack_size == 0)
  5792. set->item_stack_size += 1;
  5793. client->AddItem(set->item_id, set->item_stack_size);
  5794. }
  5795. }
  5796. }
  5797. client->RemoveItem(item, 1);
  5798. }
  5799. }
  5800. else if(sep->arg[1][0] && strncasecmp("unequip", sep->arg[0], 7) == 0 && sep->IsNumber(1))
  5801. {
  5802. if(client->GetPlayer()->EngagedInCombat())
  5803. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unequip items while in combat.");
  5804. else
  5805. {
  5806. int16 index = atoi(sep->arg[1]);
  5807. sint32 bag_id = -999;
  5808. int8 to_slot = 255;
  5809. if(sep->arg[3][0])
  5810. {
  5811. if(sep->IsNumber(2))
  5812. bag_id = atol(sep->arg[2]);
  5813. if(sep->IsNumber(3))
  5814. to_slot = atoi(sep->arg[3]);
  5815. }
  5816. sint8 unk4 = 0;
  5817. int8 appearance_equip = 0;
  5818. if(sep->arg[4][0] && sep->IsNumber(4))
  5819. unk4 = atoi(sep->arg[4]);
  5820. if(sep->arg[5][0] && sep->IsNumber(5))
  5821. appearance_equip = atoul(sep->arg[5]);
  5822. vector<EQ2Packet*> packets = client->GetPlayer()->UnequipItem(index, bag_id, to_slot, client->GetVersion(), appearance_equip);
  5823. EQ2Packet* outapp = 0;
  5824. for(int32 i=0;i<packets.size();i++)
  5825. {
  5826. outapp = packets[i];
  5827. if(outapp)
  5828. client->QueuePacket(outapp);
  5829. }
  5830. client->GetPlayer()->ChangePrimaryWeapon();
  5831. client->GetPlayer()->ChangeSecondaryWeapon();
  5832. client->GetPlayer()->ChangeRangedWeapon();
  5833. EQ2Packet* characterSheetPackets = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion());
  5834. client->QueuePacket(characterSheetPackets);
  5835. }
  5836. }
  5837. else if(sep->arg[2][0] && strncasecmp("swap_equip", sep->arg[0], 10) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  5838. {
  5839. LogWrite(MISC__TODO, 1, "TODO", " fix this, need to get how live does it\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  5840. int16 index1 = atoi(sep->arg[1]);
  5841. int16 index2 = atoi(sep->arg[2]);
  5842. int8 type = 0;
  5843. if(sep->IsNumber(3))
  5844. type = atoul(sep->arg[3]); // type 0 is combat, 3 = appearance
  5845. EQ2Packet* outapp = client->GetPlayer()->SwapEquippedItems(index1, index2, client->GetVersion(), type);
  5846. if(outapp)
  5847. client->QueuePacket(outapp);
  5848. else
  5849. {
  5850. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to swap items");
  5851. return;
  5852. }
  5853. }
  5854. else if (sep->arg[2][0] && strncasecmp("pop", sep->arg[0], 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  5855. {
  5856. sint16 to_slot = atoi(sep->arg[1]);
  5857. sint32 bag_id = atoi(sep->arg[2]);
  5858. Item* item = client->GetPlayer()->item_list.GetOverflowItem();
  5859. if (item) {
  5860. //auto inventory
  5861. if (bag_id == 0 && to_slot == -1)
  5862. {
  5863. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  5864. {
  5865. client->SimpleMessage(CHANNEL_ERROR, "You do not have any free slots.");
  5866. return;
  5867. }
  5868. // Set the slot for the item
  5869. item->details.inv_slot_id = bag_id;
  5870. item->details.slot_id = to_slot;
  5871. // Flag the item so it gets saved in its new location
  5872. item->save_needed = true;
  5873. // Add the item to its new location
  5874. player->item_list.AddItem(item);
  5875. // Remove the item from the overflow list
  5876. player->item_list.RemoveOverflowItem(item);
  5877. // Send the inventory update packet
  5878. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5879. return;
  5880. }
  5881. else if (bag_id == -3 && to_slot == -1) {
  5882. // Auto Bank
  5883. if (!player->item_list.GetFirstFreeBankSlot(&bag_id, &to_slot)) {
  5884. client->SimpleMessage(CHANNEL_STATUS, "You do not have any free bank slots.");
  5885. return;
  5886. }
  5887. item->details.inv_slot_id = bag_id;
  5888. item->details.slot_id = to_slot;
  5889. item->save_needed = true;
  5890. player->item_list.AddItem(item);
  5891. player->item_list.RemoveOverflowItem(item);
  5892. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5893. }
  5894. else if (bag_id == -4) {
  5895. // Shared Bank
  5896. if (!player->item_list.SharedBankAddAllowed(item)) {
  5897. client->SimpleMessage(CHANNEL_STATUS, "That item (or an item inside) cannot be shared.");
  5898. return;
  5899. }
  5900. Item* tmp_item = player->item_list.GetItem(-4, to_slot);
  5901. if (tmp_item) {
  5902. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  5903. return;
  5904. }
  5905. else {
  5906. item->details.inv_slot_id = bag_id;
  5907. item->details.slot_id = to_slot;
  5908. item->save_needed = true;
  5909. player->item_list.AddItem(item);
  5910. player->item_list.RemoveOverflowItem(item);
  5911. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5912. return;
  5913. }
  5914. }
  5915. else {
  5916. // Try to get an item from the given bag id and slot id
  5917. Item* tmp_item = player->item_list.GetItem(bag_id, to_slot);
  5918. // Check to see if we got an item, if we do send an error,
  5919. // if we don't put the overflow item into this slot
  5920. if (tmp_item) {
  5921. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  5922. }
  5923. else {
  5924. item->details.inv_slot_id = bag_id;
  5925. item->details.slot_id = to_slot;
  5926. item->save_needed = true;
  5927. player->item_list.AddItem(item);
  5928. player->item_list.RemoveOverflowItem(item);
  5929. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5930. return;
  5931. }
  5932. }
  5933. }
  5934. }
  5935. else if(sep->arg[2][0] && strncasecmp("nosale", sep->arg[0], 6) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  5936. {
  5937. sint64 data = strtoull(sep->arg[1], NULL, 0);
  5938. int32 character_item_id = (int32) (data >> 32);
  5939. int32 item_id = (int32) (data & 0xffffffffL);
  5940. int8 sale_setting = atoi(sep->arg[2]);
  5941. Item* item = client->GetPlayer()->item_list.GetItemFromUniqueID(character_item_id);
  5942. if(item)
  5943. {
  5944. item->no_sale = sale_setting;
  5945. item->save_needed = true;
  5946. client->SendSellMerchantList();
  5947. }
  5948. }
  5949. }
  5950. else
  5951. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /inventory {destroy|move|equip|unequip|swap_equip|pop} {item_id} [to_slot] [bag_id]");
  5952. }
  5953. /*
  5954. Function: Command_IRC()
  5955. Purpose : Handle the IRC functions
  5956. Params : IRC Commands
  5957. Dev : Scatman
  5958. Example : /irc say #Channel Hello World!
  5959. */
  5960. void Commands::Command_IRC(Client* client, Seperator* sep)
  5961. {
  5962. if (!rule_manager.GetGlobalRule(R_World, IRCEnabled)->GetBool()) {
  5963. client->SimpleMessage(CHANNEL_STATUS, "IRC is currently disabled on this server");
  5964. return;
  5965. }
  5966. if (sep && sep->arg[0][0]) {
  5967. if (strcasecmp(sep->arg[0], "say") == 0) {
  5968. if (sep->arg[1][0] && sep->arg[2][0]) {
  5969. if (sep->IsNumber(sep->arg[1]))
  5970. irc.Say(client, atoul(sep->arg[1]), sep->argplus[2]);
  5971. else
  5972. irc.Say(client, sep->arg[1], sep->argplus[2]);
  5973. }
  5974. else
  5975. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc say <channel name | channel index> <message>");
  5976. }
  5977. else if (strcasecmp(sep->arg[0], "join") == 0) {
  5978. if (sep->arg[1][0])
  5979. irc.JoinChannel(client, sep->arg[1]);
  5980. else
  5981. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc join <channel name>");
  5982. }
  5983. else if (strcasecmp(sep->arg[0], "leave") == 0) {
  5984. if (sep->arg[1][0])
  5985. irc.LeaveChannel(client, sep->arg[1]);
  5986. else
  5987. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc leave <channel name>");
  5988. }
  5989. else if (strcasecmp(sep->arg[0], "list") == 0)
  5990. irc.ListChannels(client);
  5991. else if (strcasecmp(sep->arg[0], "connect") == 0) {
  5992. if (sep->arg[1][0] && sep->arg[2][0] && sep->IsNumber(2))
  5993. irc.ConnectToServer(client, sep->arg[1], atoi(sep->arg[2]), sep->arg[3]);
  5994. else
  5995. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc connect <host> <port> (nick)");
  5996. }
  5997. else if (strcasecmp(sep->arg[0], "disconnect") == 0)
  5998. irc.DisconnectFromServer(client);
  5999. else
  6000. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown IRC command.");
  6001. }
  6002. else
  6003. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown IRC command.");
  6004. }
  6005. /*
  6006. Function: Command_Languages()
  6007. Purpose : Show's languages the player knows
  6008. Params :
  6009. Dev : Zcoretri
  6010. Example :
  6011. */
  6012. void Commands::Command_Languages(Client* client, Seperator* sep)
  6013. {
  6014. list<Language*>* languages = client->GetPlayer()->GetPlayerLanguages()->GetAllLanguages();
  6015. list<Language*>::iterator itr;
  6016. Language* language;
  6017. client->Message(CHANNEL_NARRATIVE, "You know the following languages:");
  6018. for(itr = languages->begin(); itr != languages->end(); itr++)
  6019. {
  6020. language = *itr;
  6021. client->Message(CHANNEL_NARRATIVE, "%s", language->GetName());
  6022. }
  6023. }
  6024. /*
  6025. Function: Command_SetLanguage()
  6026. Purpose : Handles language commands
  6027. Params : Language ID
  6028. Dev : Zcoretri
  6029. Example :
  6030. */
  6031. void Commands::Command_SetLanguage(Client* client, Seperator* sep)
  6032. {
  6033. Player* player = client->GetPlayer();
  6034. if (sep && sep->arg[0])
  6035. {
  6036. if(!sep->IsNumber(0))
  6037. {
  6038. //String passed in
  6039. const char* value = sep->arg[0];
  6040. if(strncasecmp(value, "Common", strlen(value)) == 0)
  6041. {
  6042. database.SaveCharacterCurrentLang(0, client->GetCharacterID(), client);
  6043. client->SendLanguagesUpdate(0);
  6044. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", value);
  6045. }
  6046. else
  6047. {
  6048. if(player->HasLanguage(value))
  6049. {
  6050. Language* language = player->GetPlayerLanguages()->GetLanguageByName(value);
  6051. database.SaveCharacterCurrentLang(language->GetID(), client->GetCharacterID(), client);
  6052. client->SendLanguagesUpdate(language->GetID());
  6053. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", language->GetName());
  6054. }
  6055. else
  6056. client->Message(CHANNEL_NARRATIVE, "You do not know how to speak %s", value);
  6057. }
  6058. }
  6059. else
  6060. {
  6061. //Number passed in
  6062. int32 id = atoul(sep->arg[0]);
  6063. if(player->HasLanguage(id))
  6064. {
  6065. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  6066. database.SaveCharacterCurrentLang(id, client->GetCharacterID(), client);
  6067. client->SendLanguagesUpdate(id);
  6068. client->Message(CHANNEL_NARRATIVE, "You are now speaking %s", language->GetName());
  6069. }
  6070. else
  6071. {
  6072. Language* language = master_languages_list.GetLanguage(id);
  6073. client->Message(CHANNEL_NARRATIVE, "You do not know how to speak %s", language->GetName());
  6074. }
  6075. }
  6076. }
  6077. else
  6078. {
  6079. //No value was passed in
  6080. int32 id = database.GetCharacterCurrentLang(client->GetCharacterID(), player);
  6081. if(id > 0)
  6082. {
  6083. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  6084. client->Message(CHANNEL_NARRATIVE, "You are currently speaking %s ", language->GetName());
  6085. }
  6086. else
  6087. client->Message(CHANNEL_NARRATIVE, "You are currently speaking Common");
  6088. }
  6089. }
  6090. /*
  6091. Function: Command_LastName()
  6092. Purpose : Sets player surname
  6093. Params : Name text
  6094. Dev : theFoof
  6095. Example :
  6096. */
  6097. void Commands::Command_LastName(Client* client, Seperator* sep)
  6098. {
  6099. if (!client)
  6100. return;
  6101. if (sep && sep->arg[0])
  6102. {
  6103. if (!client->GetPlayer()->get_character_flag(CF_ENABLE_CHANGE_LASTNAME)){
  6104. client->Message(CHANNEL_COLOR_YELLOW, "You must be atleast level %i to change your last name.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  6105. return;
  6106. }
  6107. client->RemovePendingLastName();
  6108. uchar* checkname = (uchar*)sep->arg[0];
  6109. bool valid_name = true;
  6110. for (int32 i = 0; i < strlen(sep->arg[0]); i++) {
  6111. if (!alpha_check(checkname[i])) {
  6112. valid_name = false;
  6113. break;
  6114. }
  6115. }
  6116. if (!valid_name) {
  6117. client->Message(CHANNEL_COLOR_YELLOW, "Your last name can only contain letters.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  6118. return;
  6119. }
  6120. string last_name = (string)sep->arg[0];
  6121. int8 max_length = rule_manager.GetGlobalRule(R_Player, MaxLastNameLength)->GetInt8();
  6122. int8 min_length = rule_manager.GetGlobalRule(R_Player, MinLastNameLength)->GetInt8();
  6123. if (last_name.length() <= max_length && last_name.length() >= min_length){
  6124. client->SetPendingLastName(last_name);
  6125. client->SendLastNameConfirmation();
  6126. }
  6127. else
  6128. client->Message(CHANNEL_COLOR_YELLOW, "Your last name must be between %i and %i characters long.", min_length, max_length);
  6129. }
  6130. }
  6131. /*
  6132. Function: Command_ConfirmLastName()
  6133. Purpose : Confirms setting of player surname
  6134. Params : Name text
  6135. Dev : theFoof
  6136. Example :
  6137. */
  6138. void Commands::Command_ConfirmLastName(Client* client, Seperator* sep)
  6139. {
  6140. if (!client)
  6141. return;
  6142. string* name = client->GetPendingLastName();
  6143. if (name){
  6144. Player* player = client->GetPlayer();
  6145. player->SetLastName(name->c_str(), false);
  6146. client->SendTitleUpdate();
  6147. player->SetCharSheetChanged(true);
  6148. client->RemovePendingLastName();
  6149. }
  6150. }
  6151. /*
  6152. Function: Command_Location()
  6153. Purpose : Display's Help for /location commands
  6154. Params :
  6155. Dev : Scatman
  6156. Example : /location = show's help for command
  6157. */
  6158. void Commands::Command_Location(Client* client)
  6159. {
  6160. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Valid /location commands are:");
  6161. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location create [name] (include y). Include y defaults to false");
  6162. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location add [location id]");
  6163. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location remove [location point id]");
  6164. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location delete [location id]");
  6165. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location list [locations|points] [location id if points used]");
  6166. }
  6167. /*
  6168. Function: Command_LocationAdd()
  6169. Purpose : Add's a location to an existing location config
  6170. Params : location_id
  6171. Dev : Scatman
  6172. Example : /location add {location_id}
  6173. */
  6174. void Commands::Command_LocationAdd(Client* client, Seperator* sep)
  6175. {
  6176. if (sep && sep->arg[0] && sep->IsNumber(0))
  6177. {
  6178. int32 location_id = atoul(sep->arg[0]);
  6179. float x = client->GetPlayer()->GetX();
  6180. float y = client->GetPlayer()->GetY();
  6181. float z = client->GetPlayer()->GetZ();
  6182. if (database.AddLocationPoint(location_id, x, y, z))
  6183. client->Message(CHANNEL_COLOR_YELLOW, "Point (%f, %f, %f) was successfully added to location %u", x, y, z, location_id);
  6184. else
  6185. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist. Use /location create to create one", location_id);
  6186. }
  6187. else
  6188. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location add [location id]");
  6189. }
  6190. /*
  6191. Function: Command_LocationCreate()
  6192. Purpose : Creates a new location config
  6193. Params : location name, 0/1 for include_y (optional)
  6194. Dev : Scatman
  6195. Example : /location create Test 1 = creates a new location named Test with include_y True
  6196. */
  6197. void Commands::Command_LocationCreate(Client* client, Seperator* sep)
  6198. {
  6199. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  6200. {
  6201. const char* name = sep->arg[0];
  6202. bool include_y = false;
  6203. if (sep->arg[1] && sep->IsNumber(1) && atoi(sep->arg[1]) > 0)
  6204. include_y = true;
  6205. int32 location_id = database.CreateLocation(client->GetPlayer()->GetZone()->GetZoneID(), client->GetPlayer()->appearance.pos.grid_id, name, include_y);
  6206. if (location_id > 0)
  6207. client->Message(CHANNEL_COLOR_YELLOW, "Location '%s' was successfully created with location id %u", name, location_id);
  6208. else
  6209. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the requested location");
  6210. }
  6211. else
  6212. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location create [name] (include_y). Include y defaults to false");
  6213. }
  6214. /*
  6215. Function: Command_LocationDelete()
  6216. Purpose : Delete's a location config and all it's location points
  6217. Params : location_id
  6218. Dev : Scatman
  6219. Example : /location delete {location_id}
  6220. */
  6221. void Commands::Command_LocationDelete(Client* client, Seperator* sep)
  6222. {
  6223. if (sep && sep->arg[0] && sep->IsNumber(0))
  6224. {
  6225. int32 location_id = atoul(sep->arg[0]);
  6226. if (database.DeleteLocation(location_id))
  6227. client->Message(CHANNEL_COLOR_YELLOW, "Location id %u and all its points were successfully deleted", location_id);
  6228. else
  6229. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist", location_id);
  6230. }
  6231. else
  6232. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location delete [location id]");
  6233. }
  6234. /*
  6235. Function: Command_LocationList()
  6236. Purpose : Display's a list of location points
  6237. Params : location_id
  6238. Dev : Scatman
  6239. Example : /location list {location_id}
  6240. */
  6241. void Commands::Command_LocationList(Client* client, Seperator* sep)
  6242. {
  6243. if (sep && sep->arg[0])
  6244. {
  6245. const char* option = sep->arg[0];
  6246. if (strncmp(option, "locations", strlen(option)) == 0)
  6247. database.ListLocations(client);
  6248. else if (strncmp(option, "points", strlen(option)) == 0 && sep->arg[1] && sep->IsNumber(1))
  6249. {
  6250. int32 location_id = atoul(sep->arg[1]);
  6251. database.ListLocationPoints(client, location_id);
  6252. }
  6253. else
  6254. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  6255. }
  6256. else
  6257. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  6258. }
  6259. /*
  6260. Function: Command_LocationRemove()
  6261. Purpose : Removes a single location point from a location config
  6262. Params : location_point_id (gotten from /location list {id})
  6263. Dev : Scatman
  6264. Example : /location remove 1 = will remove location_point_id 1
  6265. */
  6266. void Commands::Command_LocationRemove(Client* client, Seperator* sep)
  6267. {
  6268. if (sep && sep->arg[0] && sep->IsNumber(0))
  6269. {
  6270. int32 location_point_id = atoul(sep->arg[0]);
  6271. if (database.DeleteLocationPoint(location_point_id))
  6272. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Location point was successfully deleted");
  6273. else
  6274. client->Message(CHANNEL_COLOR_YELLOW, "Location point with ID %u does not exist", location_point_id);
  6275. }
  6276. else
  6277. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location remove [location point id]");
  6278. }
  6279. /*
  6280. Function: Command_Merchant()
  6281. Purpose : Handles Merchant commands
  6282. Params : list
  6283. Dev : Scatman
  6284. Example : /merchant list
  6285. */
  6286. void Commands::Command_Merchant(Client* client, Seperator* sep, int handler)
  6287. {
  6288. if( handler == COMMAND_MERCHANT )
  6289. {
  6290. // /merchant command by itself shows help (to be extended)
  6291. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  6292. return;
  6293. }
  6294. else if( handler == COMMAND_MERCHANT_LIST )
  6295. {
  6296. // /merchant list command expects "description" param
  6297. if (sep && sep->arg[0])
  6298. {
  6299. const char* merchant_description = sep->argplus[0];
  6300. client->Message(CHANNEL_COLOR_YELLOW, "Listing merchants like '%s':", merchant_description);
  6301. map<int32, MerchantInfo*>* merchant_info = world.GetMerchantInfo();
  6302. map<int32, MerchantInfo*>::iterator itr;
  6303. for (itr = merchant_info->begin(); itr != merchant_info->end(); itr++)
  6304. {
  6305. string description = database.GetMerchantDescription(itr->first);
  6306. if (ToLower(description).find(ToLower(string(merchant_description))) < 0xFFFFFFFF)
  6307. client->Message(CHANNEL_COLOR_YELLOW, "Merchant ID: %u, Description: %s", itr->first, description.c_str());
  6308. }
  6309. }
  6310. else // no description
  6311. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  6312. }
  6313. }
  6314. /*
  6315. Function: Command_Modify()
  6316. Purpose : to replace our other "set" commands
  6317. Params : System = the system to modify, Action = the action to perform, Target = what to change (target, or index)
  6318. Dev : John Adams
  6319. Example : /modify spell set name "Aegolism III"
  6320. */
  6321. void Commands::Command_Modify(Client* client)
  6322. {
  6323. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /modify [system] [action] [field] [value] {target|id}");
  6324. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Systems: character, faction, guild, item, skill, spawn, spell, zone");
  6325. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Actions: set, create, delete, add, remove");
  6326. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Value : field name in the table being modified");
  6327. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target : modify current target, or specified {system} ID");
  6328. }
  6329. /*
  6330. Function: Command_ModifySpawn()
  6331. Purpose : replace "spawn set" commands
  6332. Params : Action : the action to perform (or special handler)
  6333. : Field : the DB field to change
  6334. : Value : what to set the value to
  6335. : Target : what object to change (my target, or spawn_id)
  6336. Dev : John Adams
  6337. Example : /modify spawn set name "Lady Vox"
  6338. :
  6339. Note : Special Handlers, like "zoneto" for Signs
  6340. : /modify spawn zoneto
  6341. : Will set a sign's zone x/y/z to my current coords
  6342. */
  6343. void Commands::Command_ModifySpawn(Client* client, Seperator* sep)
  6344. {
  6345. PrintSep(sep, "COMMAND_MODIFY");
  6346. // need at least 2 args for a valid command
  6347. if( sep && sep->arg[1] )
  6348. {
  6349. // JA: just a quick implementation because I need it :)
  6350. if (strcmp(sep->arg[0], "zoneto") == 0)
  6351. {
  6352. if( sep->IsNumber(1) )
  6353. {
  6354. int32 spawn_id = atoul(sep->arg[1]);
  6355. float x_coord = client->GetPlayer()->GetX();
  6356. float y_coord = client->GetPlayer()->GetY();
  6357. float z_coord = client->GetPlayer()->GetZ();
  6358. float h_coord = client->GetPlayer()->GetHeading();
  6359. database.SaveSignZoneToCoords(spawn_id, x_coord, y_coord, z_coord, h_coord);
  6360. }
  6361. else
  6362. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify spawn zoneto spawn_id - sets spawn_id to your coords");
  6363. }
  6364. }
  6365. else
  6366. Command_Modify(client);
  6367. }
  6368. /*
  6369. Function: Command_ModifyCharacter()
  6370. Purpose : to replace our other "set" commands
  6371. Params : Action : Add, Remove
  6372. : Field : copper, silver, gold, plat
  6373. : Value : min 1, max unlimited
  6374. : Target : Self, Player
  6375. Dev : Cynnar
  6376. Example : /modify character add gold 50
  6377. : /modify character remove silver 25
  6378. */
  6379. void Commands::Command_ModifyCharacter(Client* client, Seperator* sep)
  6380. {
  6381. PrintSep(sep, "COMMAND_MODIFY");
  6382. int64 value = 0;
  6383. Player* player = client->GetPlayer();
  6384. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  6385. player = (Player*)player->GetTarget();
  6386. // need at least 2 args for a valid command
  6387. if( sep && sep->arg[1] )
  6388. {
  6389. if (strcmp(sep->arg[0], "add") == 0)
  6390. {
  6391. if (strcmp(sep->arg[1], "copper") == 0)
  6392. {
  6393. value = atoi64(sep->arg[2]);
  6394. player->AddCoins(value);
  6395. if (client->GetPlayer() == player)
  6396. {
  6397. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu copper coin%s", value, (value > 1 ? "s" : ""));
  6398. }
  6399. else {
  6400. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu copper coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  6401. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu copper coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  6402. }
  6403. }
  6404. else if (strcmp(sep->arg[1], "silver") == 0)
  6405. {
  6406. value = atoi64(sep->arg[2]) * 100;
  6407. player->AddCoins(value);
  6408. if (client->GetPlayer() == player)
  6409. {
  6410. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu silver coin%s", value / 100, (value > 1 ? "s" : ""));
  6411. }
  6412. else {
  6413. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu silver coin%s", player->GetName(), value / 100, (value > 1 ? "s" : ""));
  6414. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu silver coin%s", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  6415. }
  6416. }
  6417. else if (strcmp(sep->arg[1], "gold") == 0)
  6418. {
  6419. value = atoi64(sep->arg[2]) * 10000;
  6420. player->AddCoins(value);
  6421. if (client->GetPlayer() == player)
  6422. {
  6423. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu gold coin%s", value / 10000, (value > 1 ? "s" : ""));
  6424. }
  6425. else {
  6426. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu gold coin%s", player->GetName(), value / 10000, (value > 1 ? "s" : ""));
  6427. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu gold coin%s", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  6428. }
  6429. }
  6430. else if (strcmp(sep->arg[1], "plat") == 0)
  6431. {
  6432. value = atoi64(sep->arg[2]) * 1000000;
  6433. player->AddCoins(value);
  6434. if (client->GetPlayer() == player)
  6435. {
  6436. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu platinum coin%s", value / 1000000, (value > 1 ? "s" : ""));
  6437. }
  6438. else {
  6439. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu platinum coin%s", player->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  6440. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu platinum coin%s", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  6441. }
  6442. }
  6443. else
  6444. {
  6445. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  6446. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  6447. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  6448. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character add copper 20");
  6449. }
  6450. }
  6451. else if (strcmp(sep->arg[0], "remove") == 0)
  6452. {
  6453. if (strcmp(sep->arg[1], "copper") == 0)
  6454. {
  6455. value = atoi64(sep->arg[2]);
  6456. player->RemoveCoins(value);
  6457. if (client->GetPlayer() == player)
  6458. {
  6459. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from yourself", value, (value > 1 ? "s" : ""));
  6460. }
  6461. else {
  6462. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from %s", value, (value > 1 ? "s" : ""), player->GetName());
  6463. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu copper coin%s from you", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  6464. }
  6465. }
  6466. else if (strcmp(sep->arg[1], "silver") == 0)
  6467. {
  6468. value = atoi64(sep->arg[2]) * 100;
  6469. player->RemoveCoins(value);
  6470. if (client->GetPlayer() == player)
  6471. {
  6472. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from yourself", value / 100, (value > 1 ? "s" : ""));
  6473. }
  6474. else {
  6475. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from %s", value / 100, (value > 1 ? "s" : ""), player->GetName());
  6476. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu silver coin%s from you", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  6477. }
  6478. }
  6479. else if (strcmp(sep->arg[1], "gold") == 0)
  6480. {
  6481. value = atoi64(sep->arg[2]) * 10000;
  6482. player->RemoveCoins(value);
  6483. if (client->GetPlayer() == player)
  6484. {
  6485. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from yourself", value / 10000, (value > 1 ? "s" : ""));
  6486. }
  6487. else {
  6488. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from %s", value / 10000, (value > 1 ? "s" : ""), player->GetName());
  6489. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu gold coin%s from you", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  6490. }
  6491. }
  6492. else if (strcmp(sep->arg[1], "plat") == 0)
  6493. {
  6494. value = atoi64(sep->arg[2]) * 1000000;
  6495. player->RemoveCoins(value);
  6496. if (client->GetPlayer() == player)
  6497. {
  6498. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from yourself", value / 1000000, (value > 1 ? "s" : ""));
  6499. }
  6500. else {
  6501. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from %s", value / 1000000, (value > 1 ? "s" : ""), player->GetName());
  6502. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu platinum coin%s from you", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  6503. }
  6504. }
  6505. else
  6506. {
  6507. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  6508. }
  6509. }
  6510. else if (strcmp(sep->arg[0], "set") == 0) {
  6511. if (strcmp(sep->arg[1], "tslevel") == 0) {
  6512. int8 level = atoi(sep->arg[2]);
  6513. if (level > 0 && level < 256) {
  6514. if (player) {
  6515. if (client->GetPlayer() == player)
  6516. client->ChangeTSLevel(player->GetTSLevel(), level);
  6517. else
  6518. player->GetZone()->GetClientBySpawn(player)->ChangeTSLevel(player->GetTSLevel(), level);
  6519. }
  6520. }
  6521. else
  6522. client->SimpleMessage(CHANNEL_ERROR, "Level must be between 1 - 255");
  6523. }
  6524. else if (strcmp(sep->arg[1], "tsclass") == 0) {
  6525. int8 tsclass = atoi(sep->arg[2]);
  6526. player->SetTradeskillClass(tsclass);
  6527. player->GetInfoStruct()->set_tradeskill_class1(classes.GetTSBaseClass(player->GetTradeskillClass()));
  6528. player->GetInfoStruct()->set_tradeskill_class2(classes.GetSecondaryTSBaseClass(player->GetTradeskillClass()));
  6529. player->GetInfoStruct()->set_tradeskill_class3(player->GetTradeskillClass());
  6530. player->SetCharSheetChanged(true);
  6531. }
  6532. }
  6533. }
  6534. else
  6535. {
  6536. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  6537. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  6538. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  6539. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  6540. }
  6541. }
  6542. void Commands::Command_ModifyFaction(Client* client, Seperator* sep)
  6543. {
  6544. PrintSep(sep, "COMMAND_MODIFY");
  6545. // need at least 2 args for a valid command
  6546. if( sep && sep->arg[1] )
  6547. {
  6548. }
  6549. else
  6550. Command_Modify(client);
  6551. }
  6552. void Commands::Command_ModifyGuild(Client* client, Seperator* sep)
  6553. {
  6554. PrintSep(sep, "COMMAND_MODIFY");
  6555. // need at least 2 args for a valid command
  6556. if( sep && sep->arg[1] )
  6557. {
  6558. }
  6559. else
  6560. Command_Modify(client);
  6561. }
  6562. void Commands::Command_ModifyItem(Client* client, Seperator* sep)
  6563. {
  6564. PrintSep(sep, "COMMAND_MODIFY");
  6565. // need at least 2 args for a valid command
  6566. if( sep && sep->arg[1] )
  6567. {
  6568. }
  6569. else
  6570. Command_Modify(client);
  6571. }
  6572. /*
  6573. Function: Command_ModifyQuest()
  6574. Purpose : to list players quest and completed quests
  6575. Params : Action : list, completed
  6576. : Target : Self, Player
  6577. Dev : Cynnar
  6578. Example : /modify quest list
  6579. : /modify quest completed
  6580. */
  6581. void Commands::Command_ModifyQuest(Client* client, Seperator* sep)
  6582. {
  6583. PrintSep(sep, "COMMAND_MODIFY");
  6584. int64 value = 0;
  6585. Player* player = client->GetPlayer();
  6586. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  6587. player = (Player*)player->GetTarget();
  6588. // need at least 2 args for a valid command
  6589. if (sep && sep->arg[1])
  6590. {
  6591. if (strcmp(sep->arg[0], "list") == 0)
  6592. {
  6593. map<int32, Quest*>* quests = player->GetPlayerQuests();
  6594. map<int32, Quest*>::iterator itr;
  6595. client->Message(CHANNEL_COLOR_YELLOW, "%s's Quest List:.", client->GetPlayer()->GetName());
  6596. if (quests->size() == 0)
  6597. client->Message(CHANNEL_COLOR_YELLOW, "%s has no quests.", client->GetPlayer()->GetName());
  6598. else
  6599. {
  6600. for (itr = quests->begin(); itr != quests->end(); itr++)
  6601. {
  6602. Quest* quest = itr->second;
  6603. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  6604. }
  6605. }
  6606. }
  6607. else if (strcmp(sep->arg[0], "completed") == 0)
  6608. {
  6609. map<int32, Quest*>* quests = player->GetCompletedPlayerQuests();
  6610. map<int32, Quest*>::iterator itr;
  6611. client->Message(CHANNEL_COLOR_YELLOW, "%s's Completed Quest List:.", client->GetPlayer()->GetName());
  6612. if (quests->size() == 0)
  6613. client->Message(CHANNEL_COLOR_YELLOW, "%s has no completed quests.", client->GetPlayer()->GetName());
  6614. else
  6615. {
  6616. for (itr = quests->begin(); itr != quests->end(); itr++)
  6617. {
  6618. Quest* quest = itr->second;
  6619. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  6620. }
  6621. }
  6622. }
  6623. // Add in a progress step, and a LogWrite() for tracking GM Commands.
  6624. // LogWrite(LUA__DEBUG, 0, "LUA", "Quest: %s, function: %s", quest->GetName(), function);
  6625. else if (strcmp(sep->arg[0], "remove") == 0)
  6626. {
  6627. int32 quest_id = 0;
  6628. if (sep && sep->arg[1] && sep->IsNumber(1))
  6629. quest_id = atoul(sep->arg[1]);
  6630. if (quest_id > 0)
  6631. {
  6632. if (lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0)
  6633. {
  6634. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  6635. if (quest)
  6636. if (client->GetPlayer() == player)
  6637. {
  6638. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been removed from your journal", quest->GetName());
  6639. }
  6640. else
  6641. {
  6642. client->Message(CHANNEL_COLOR_YELLOW, "You have removed the quest %s from %s's journal", quest->GetName(), player->GetName());
  6643. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s has removed the quest %s from your journal", client->GetPlayer()->GetName(), quest->GetName());
  6644. }
  6645. LogWrite(COMMAND__INFO, 0, "GM Command", "%s removed the quest %s from %s", client->GetPlayer()->GetName(), quest->GetName(), player->GetName());
  6646. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  6647. }
  6648. client->RemovePlayerQuest(quest_id);
  6649. client->GetCurrentZone()->SendQuestUpdates(client);
  6650. }
  6651. }
  6652. else if (strcmp(sep->arg[0], "advance") == 0)
  6653. {
  6654. int32 quest_id = 0;
  6655. int32 step = 0;
  6656. if (sep && sep->arg[1] && sep->IsNumber(1))
  6657. {
  6658. quest_id = atoul(sep->arg[1]);
  6659. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  6660. if (sep && sep->arg[2] && sep->IsNumber(1))
  6661. {
  6662. step = atoul(sep->arg[2]);
  6663. if (quest_id > 0 && step > 0)
  6664. {
  6665. if (player && player->IsPlayer() && quest_id > 0 && step > 0 && (player->player_quests.count(quest_id) > 0))
  6666. {
  6667. if (client)
  6668. {
  6669. client->AddPendingQuestUpdate(quest_id, step);
  6670. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been advanced one step.", quest->GetName());
  6671. LogWrite(COMMAND__INFO, 0, "GM Command", "%s advanced the quest %s one step", client->GetPlayer()->GetName(), quest->GetName());
  6672. }
  6673. }
  6674. }
  6675. else
  6676. {
  6677. client->Message(CHANNEL_COLOR_RED, "Quest ID and Step Number must be greater than 0!");
  6678. }
  6679. }
  6680. else
  6681. {
  6682. client->Message(CHANNEL_COLOR_RED, "Step Number must be a number!");
  6683. }
  6684. }
  6685. else
  6686. {
  6687. client->Message(CHANNEL_COLOR_RED, "Quest ID must be a number!");
  6688. }
  6689. }
  6690. else
  6691. {
  6692. Command_Modify(client);
  6693. }
  6694. }
  6695. else
  6696. {
  6697. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify quest [action] [quest id] [step number]");
  6698. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: list, completed, remove, advance");
  6699. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest list");
  6700. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest remove 156");
  6701. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest advance 50 1");
  6702. }
  6703. }
  6704. void Commands::Command_ModifySkill(Client* client, Seperator* sep)
  6705. {
  6706. PrintSep(sep, "COMMAND_MODIFY");
  6707. // need at least 2 args for a valid command
  6708. if( sep && sep->arg[1] )
  6709. {
  6710. if (strcmp(sep->arg[0], "add") == 0) {
  6711. const char* skill_name = sep->argplus[1];
  6712. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6713. if (skill) {
  6714. Player* player = 0;
  6715. Client* to_client = 0;
  6716. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  6717. player = (Player*)client->GetPlayer()->GetTarget();
  6718. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  6719. }
  6720. else {
  6721. player = client->GetPlayer();
  6722. to_client = client;
  6723. }
  6724. if (player)
  6725. {
  6726. if (!player->GetSkills()->HasSkill(skill->skill_id))
  6727. {
  6728. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  6729. if (to_client == client) {
  6730. client->Message(CHANNEL_STATUS, "Added skill '%s'.", skill_name);
  6731. }
  6732. else {
  6733. client->Message(CHANNEL_STATUS, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  6734. to_client->Message(CHANNEL_STATUS, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  6735. }
  6736. }
  6737. else
  6738. client->Message(CHANNEL_STATUS, "%s already has the skill '%s'.", to_client == client ? "You" : player->GetName(), skill_name);
  6739. }
  6740. }
  6741. else
  6742. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  6743. }
  6744. else if (strcmp(sep->arg[0], "remove") == 0) {
  6745. const char* skill_name = sep->argplus[1];
  6746. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6747. if (skill) {
  6748. Player* player = 0;
  6749. Client* to_client = 0;
  6750. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  6751. player = (Player*)client->GetPlayer()->GetTarget();
  6752. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  6753. }
  6754. else {
  6755. player = client->GetPlayer();
  6756. to_client = client;
  6757. }
  6758. if (player)
  6759. {
  6760. if (player->GetSkills()->HasSkill(skill->skill_id))
  6761. {
  6762. player->RemoveSkillFromDB(skill, true);
  6763. if (client == to_client) {
  6764. client->Message(CHANNEL_STATUS, "Removed skill '%s'.", skill_name);
  6765. }
  6766. else {
  6767. client->Message(CHANNEL_STATUS, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  6768. to_client->Message(CHANNEL_STATUS, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  6769. }
  6770. }
  6771. else {
  6772. if (client == to_client)
  6773. client->Message(CHANNEL_STATUS, "You do not have the skill '%s'.", skill_name);
  6774. else
  6775. client->Message(CHANNEL_STATUS, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  6776. }
  6777. }
  6778. }
  6779. else
  6780. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  6781. }
  6782. else if (strcmp(sep->arg[0], "set") == 0) {
  6783. if (!sep->IsNumber(2)) {
  6784. client->Message(CHANNEL_STATUS, "The last parameter must be a number.");
  6785. return;
  6786. }
  6787. const char* skill_name = sep->arg[1];
  6788. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6789. if (skill) {
  6790. int16 val = atoi(sep->arg[2]);
  6791. Player* player = 0;
  6792. Client* to_client = 0;
  6793. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  6794. player = (Player*)client->GetPlayer()->GetTarget();
  6795. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  6796. }
  6797. else {
  6798. player = client->GetPlayer();
  6799. to_client = client;
  6800. }
  6801. if (player)
  6802. {
  6803. if (player->GetSkills()->HasSkill(skill->skill_id)) {
  6804. player->GetSkills()->SetSkill(skill->skill_id, val);
  6805. if (client != to_client)
  6806. client->Message(CHANNEL_STATUS, "You set %s's '%s' skill to %i.", player->GetName(), skill_name, val);
  6807. to_client->Message(CHANNEL_STATUS, "Your '%s' skill has been set to %i.", skill_name, val);
  6808. }
  6809. else {
  6810. client->Message(CHANNEL_STATUS, "Target does not have the skill '%s'.", skill_name);
  6811. }
  6812. }
  6813. }
  6814. else {
  6815. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  6816. }
  6817. }
  6818. else {
  6819. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  6820. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  6821. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  6822. }
  6823. }
  6824. else {
  6825. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  6826. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  6827. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  6828. }
  6829. }
  6830. void Commands::Command_ModifySpell(Client* client, Seperator* sep)
  6831. {
  6832. PrintSep(sep, "COMMAND_MODIFY");
  6833. // need at least 2 args for a valid command
  6834. if( sep && sep->arg[1] )
  6835. {
  6836. }
  6837. else
  6838. Command_Modify(client);
  6839. }
  6840. void Commands::Command_ModifyZone(Client* client, Seperator* sep)
  6841. {
  6842. PrintSep(sep, "COMMAND_MODIFY");
  6843. // need at least 2 args for a valid command
  6844. if( sep && sep->arg[1] )
  6845. {
  6846. }
  6847. else
  6848. Command_Modify(client);
  6849. }
  6850. /*
  6851. Function: Command_MOTD()
  6852. Purpose : Displays server MOTD
  6853. Params :
  6854. Dev : LethalEncounter
  6855. Example : /motd
  6856. */
  6857. void Commands::Command_MOTD(Client* client)
  6858. {
  6859. if (client)
  6860. ClientPacketFunctions::SendMOTD(client);
  6861. }
  6862. /*
  6863. Function: Command_Pet()
  6864. Purpose : Handle Pet {Command} commands
  6865. Params : attack, backoff, preserve_master, preserve_self, follow, stay, getlost
  6866. Dev :
  6867. Example : /pet preserve_master
  6868. */
  6869. void Commands::Command_Pet(Client* client, Seperator* sep)
  6870. {
  6871. PrintSep(sep, "COMMAND_PET");
  6872. //LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Pet Commands");
  6873. //client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6874. if (!sep || !sep->arg[0])
  6875. return; // should have sep->arg[0] filled
  6876. if (strcmp(sep->arg[0], "hide") == 0) {
  6877. // doing /pet hide will toggle the hide status on all the pets that can be hidden
  6878. Entity* pet = client->GetPlayer()->GetDeityPet();
  6879. if (pet) {
  6880. if (pet->IsPrivateSpawn())
  6881. client->GetPlayer()->HideDeityPet(false);
  6882. else
  6883. client->GetPlayer()->HideDeityPet(true);
  6884. }
  6885. pet = client->GetPlayer()->GetCosmeticPet();
  6886. if (pet) {
  6887. if (pet->IsPrivateSpawn())
  6888. client->GetPlayer()->HideCosmeticPet(false);
  6889. else
  6890. client->GetPlayer()->HideCosmeticPet(true);
  6891. }
  6892. return;
  6893. }
  6894. // below is for all combat pets
  6895. if (!client->GetPlayer()->HasPet()) {
  6896. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a pet.");
  6897. return;
  6898. }
  6899. if (strcmp(sep->arg[0], "stay") == 0) {
  6900. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to stay.");
  6901. client->GetPlayer()->GetInfoStruct()->set_pet_movement(1);
  6902. client->GetPlayer()->SetCharSheetChanged(true);
  6903. if (client->GetPlayer()->GetPet())
  6904. client->GetPlayer()->GetPet()->following = false;
  6905. if (client->GetPlayer()->GetCharmedPet())
  6906. client->GetPlayer()->GetCharmedPet()->following = false;
  6907. }
  6908. else if (strcmp(sep->arg[0], "follow") == 0) {
  6909. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to follow.");
  6910. client->GetPlayer()->GetInfoStruct()->set_pet_movement(2);
  6911. client->GetPlayer()->SetCharSheetChanged(true);
  6912. }
  6913. else if (strcmp(sep->arg[0], "preserve_master") == 0) {
  6914. if (client->GetPlayer()->GetInfoStruct()->get_pet_behavior() & 1) {
  6915. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect you.");
  6916. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()-1);
  6917. }
  6918. else {
  6919. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect you.");
  6920. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()+1);
  6921. }
  6922. client->GetPlayer()->SetCharSheetChanged(true);
  6923. }
  6924. else if (strcmp(sep->arg[0], "preserve_self") == 0) {
  6925. if (client->GetPlayer()->GetInfoStruct()->get_pet_behavior() & 2) {
  6926. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect itself.");
  6927. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()-2);
  6928. }
  6929. else {
  6930. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect itself.");
  6931. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(client->GetPlayer()->GetInfoStruct()->get_pet_behavior()+2);
  6932. }
  6933. client->GetPlayer()->SetCharSheetChanged(true);
  6934. }
  6935. else if (strcmp(sep->arg[0], "backoff") == 0) {
  6936. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to back down.");
  6937. if (client->GetPlayer()->GetPet())
  6938. ((NPC*)client->GetPlayer()->GetPet())->Brain()->ClearHate();
  6939. if (client->GetPlayer()->GetCharmedPet())
  6940. ((NPC*)client->GetPlayer()->GetCharmedPet())->Brain()->ClearHate();
  6941. client->GetPlayer()->GetInfoStruct()->set_pet_behavior(0);
  6942. client->GetPlayer()->SetCharSheetChanged(true);
  6943. }
  6944. else if (strcmp(sep->arg[0], "attack") == 0) {
  6945. if (client->GetPlayer()->HasTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  6946. if (client->GetPlayer()->AttackAllowed((Entity*)client->GetPlayer()->GetTarget())){
  6947. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to attack your target.");
  6948. if (client->GetPlayer()->GetPet())
  6949. client->GetPlayer()->GetPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  6950. if (client->GetPlayer()->GetCharmedPet())
  6951. client->GetPlayer()->GetCharmedPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  6952. }
  6953. else
  6954. client->Message(CHANNEL_COLOR_YELLOW, "You can not attack that.");
  6955. }
  6956. else
  6957. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a target.");
  6958. }
  6959. else if (strcmp(sep->arg[0], "getlost") == 0) {
  6960. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetPet());
  6961. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetCharmedPet());
  6962. client->Message(CHANNEL_COLOR_YELLOW, "You tell your pet to get lost.");
  6963. }
  6964. else
  6965. client->Message(CHANNEL_COLOR_YELLOW, "Unknown pet command.");
  6966. }
  6967. /*
  6968. Function: Command_PetName()
  6969. Purpose : Pet your name (???)
  6970. Params :
  6971. Dev :
  6972. Example :
  6973. */
  6974. void Commands::Command_PetName(Client* client, Seperator* sep)
  6975. {
  6976. PrintSep(sep, "COMMAND_PETNAME");
  6977. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Pet Name Command");
  6978. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6979. }
  6980. /*
  6981. Function: Command_NamePet()
  6982. Purpose : Name your pet
  6983. Params :
  6984. Dev :
  6985. Example :
  6986. */
  6987. void Commands::Command_NamePet(Client* client, Seperator* sep)
  6988. {
  6989. PrintSep(sep, "COMMAND_NAME_PET");
  6990. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Name Pet Command");
  6991. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6992. }
  6993. /*
  6994. Function: Command_Rename()
  6995. Purpose : Renames existing pet
  6996. Params :
  6997. Dev :
  6998. Example :
  6999. */
  7000. void Commands::Command_Rename(Client* client, Seperator* sep)
  7001. {
  7002. PrintSep(sep, "COMMAND_RENAME");
  7003. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Rename Pet Command");
  7004. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7005. }
  7006. /*
  7007. Function: Command_ConfirmRename()
  7008. Purpose : Confirms renaming your pet
  7009. Params :
  7010. Dev :
  7011. Example :
  7012. */
  7013. void Commands::Command_ConfirmRename(Client* client, Seperator* sep)
  7014. {
  7015. PrintSep(sep, "COMMAND_CONFIRMRENAME");
  7016. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Confirm Rename Pet Command");
  7017. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  7018. }
  7019. /*
  7020. Function: Command_PetOptions()
  7021. Purpose : Sets various pet options
  7022. Params :
  7023. Dev :
  7024. Example :
  7025. */
  7026. void Commands::Command_PetOptions(Client* client, Seperator* sep)
  7027. {
  7028. PrintSep(sep, "COMMAND_PETOPTIONS");
  7029. Player* player = client->GetPlayer();
  7030. Spawn* target = player->GetTarget();
  7031. if (!target)
  7032. return;
  7033. if (target == player->GetPet())
  7034. client->SendPetOptionsWindow(player->GetPet()->GetName());
  7035. else if (target == player->GetCharmedPet())
  7036. client->SendPetOptionsWindow(player->GetCharmedPet()->GetName());
  7037. else if (target == player->GetCosmeticPet())
  7038. client->SendPetOptionsWindow(player->GetCosmeticPet()->GetName(), 0);
  7039. else if (target == player->GetDeityPet())
  7040. client->SendPetOptionsWindow(player->GetDeityPet()->GetName(), 0);
  7041. }
  7042. /*
  7043. Function: Command_Random()
  7044. Purpose : Handles /random dice roll in-game
  7045. Params : 1-100
  7046. Dev : Scatman
  7047. Example : /randon 1 100
  7048. */
  7049. void Commands::Command_Random(Client* client, Seperator* sep)
  7050. {
  7051. char message[256] = {0};
  7052. if (sep)
  7053. {
  7054. if (sep->GetArgNumber() == 0 && sep->IsNumber(0))
  7055. 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])));
  7056. else if (sep->GetArgNumber() > 0 && sep->IsNumber(0) && sep->IsNumber(1))
  7057. 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])));
  7058. else
  7059. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  7060. }
  7061. else
  7062. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  7063. client->GetPlayer()->GetZone()->HandleChatMessage(0, 0, CHANNEL_EMOTE, message);
  7064. }
  7065. /*
  7066. Function: Command_Randomize()
  7067. Purpose : Sets randomize (appearance) values for NPCs
  7068. Params : Attrib Name
  7069. Dev : Scatman
  7070. Example : /randomize gender 1 -- will randomize the NPCs gender (male/female)
  7071. */
  7072. void Commands::Command_Randomize(Client* client, Seperator* sep)
  7073. {
  7074. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  7075. if (target)
  7076. {
  7077. if (target->IsNPC())
  7078. {
  7079. if (sep && sep->arg[0] && !sep->IsNumber(0))
  7080. {
  7081. const char* value = sep->arg[0];
  7082. if (strncasecmp(value, "show", strlen(value)) == 0)
  7083. {
  7084. client->DisplayRandomizeFeatures(target->GetRandomize());
  7085. }
  7086. else
  7087. {
  7088. if (sep->arg[1] && sep->IsNumber(1))
  7089. {
  7090. int8 option = atoi(sep->arg[1]);
  7091. if (option == 0 || option == 1)
  7092. {
  7093. int32 feature = 0;
  7094. char feature_text[32] = {0};
  7095. if (strncasecmp(value, "gender", strlen(value)) == 0) {
  7096. feature = RANDOMIZE_GENDER;
  7097. strncpy(feature_text, "gender", sizeof(feature_text) - 1);
  7098. }
  7099. else if (strncasecmp(value, "race", strlen(value)) == 0) {
  7100. feature = RANDOMIZE_RACE;
  7101. strncpy(feature_text, "race", sizeof(feature_text) - 1);
  7102. }
  7103. else if (strncasecmp(value, "model", strlen(value)) == 0) {
  7104. feature = RANDOMIZE_MODEL_TYPE;
  7105. strncpy(feature_text, "model", sizeof(feature_text) - 1);
  7106. }
  7107. else if (strncasecmp(value, "facial_hair", strlen(value)) == 0) {
  7108. feature = RANDOMIZE_FACIAL_HAIR_TYPE;
  7109. strncpy(feature_text, "facial hair", sizeof(feature_text) - 1);
  7110. }
  7111. else if (strncasecmp(value, "hair", strlen(value)) == 0) {
  7112. feature = RANDOMIZE_HAIR_TYPE;
  7113. strncpy(feature_text, "hair", sizeof(feature_text) - 1);
  7114. }
  7115. else if (strncasecmp(value, "wing", strlen(value)) == 0) {
  7116. feature = RANDOMIZE_WING_TYPE;
  7117. strncpy(feature_text, "wings", sizeof(feature_text) - 1);
  7118. }
  7119. else if (strncasecmp(value, "cheek", strlen(value)) == 0) {
  7120. feature = RANDOMIZE_CHEEK_TYPE;
  7121. strncpy(feature_text, "cheeks", sizeof(feature_text) - 1);
  7122. }
  7123. else if (strncasecmp(value, "chin", strlen(value)) == 0) {
  7124. feature = RANDOMIZE_CHIN_TYPE;
  7125. strncpy(feature_text, "chin", sizeof(feature_text) - 1);
  7126. }
  7127. else if (strncasecmp(value, "ear", strlen(value)) == 0) {
  7128. feature = RANDOMIZE_EAR_TYPE;
  7129. strncpy(feature_text, "ears", sizeof(feature_text) - 1);
  7130. }
  7131. else if (strncasecmp(value, "eye_brow", strlen(value)) == 0) {
  7132. feature = RANDOMIZE_EYE_BROW_TYPE;
  7133. strncpy(feature_text, "eye brows", sizeof(feature_text) - 1);
  7134. }
  7135. else if (strncasecmp(value, "eye", strlen(value)) == 0) {
  7136. feature = RANDOMIZE_EYE_TYPE;
  7137. strncpy(feature_text, "eyes", sizeof(feature_text) - 1);
  7138. }
  7139. else if (strncasecmp(value, "lip", strlen(value)) == 0) {
  7140. feature = RANDOMIZE_LIP_TYPE;
  7141. strncpy(feature_text, "lips", sizeof(feature_text) - 1);
  7142. }
  7143. else if (strncasecmp(value, "nose", strlen(value)) == 0) {
  7144. feature = RANDOMIZE_NOSE_TYPE;
  7145. strncpy(feature_text, "nose", sizeof(feature_text) - 1);
  7146. }
  7147. else if (strncasecmp(value, "eye_color", strlen(value)) == 0) {
  7148. feature = RANDOMIZE_EYE_COLOR;
  7149. strncpy(feature_text, "eye color", sizeof(feature_text) - 1);
  7150. }
  7151. else if (strncasecmp(value, "hair_color", strlen(value)) == 0) {
  7152. feature = RANDOMIZE_HAIR_TYPE_COLOR;
  7153. strncpy(feature_text, "hair color", sizeof(feature_text) - 1);
  7154. }
  7155. else if (strncasecmp(value, "hair_color1", strlen(value)) == 0) {
  7156. feature = RANDOMIZE_HAIR_COLOR1;
  7157. strncpy(feature_text, "hair color1", sizeof(feature_text) - 1);
  7158. }
  7159. else if (strncasecmp(value, "hair_color2", strlen(value)) == 0) {
  7160. feature = RANDOMIZE_HAIR_COLOR2;
  7161. strncpy(feature_text, "hair color2", sizeof(feature_text) - 1);
  7162. }
  7163. else if (strncasecmp(value, "hair_highlight", strlen(value)) == 0) {
  7164. feature = RANDOMIZE_HAIR_HIGHLIGHT;
  7165. strncpy(feature_text, "hair highlights", sizeof(feature_text) - 1);
  7166. }
  7167. else if (strncasecmp(value, "facial_hair_color", strlen(value)) == 0) {
  7168. feature = RANDOMIZE_HAIR_FACE_COLOR;
  7169. strncpy(feature_text, "facial hair color", sizeof(feature_text) - 1);
  7170. }
  7171. else if (strncasecmp(value, "facial_hair_color_highlight", strlen(value)) == 0) {
  7172. feature = RANDOMIZE_HAIR_FACE_HIGHLIGHT_COLOR;
  7173. strncpy(feature_text, "facial hair color highlights", sizeof(feature_text) - 1);
  7174. }
  7175. else if (strncasecmp(value, "hair_color_highlight", strlen(value)) == 0) {
  7176. feature = RANDOMIZE_HAIR_TYPE_HIGHLIGHT_COLOR;
  7177. strncpy(feature_text, "hair color highlights", sizeof(feature_text) - 1);
  7178. }
  7179. else if (strncasecmp(value, "skin_color", strlen(value)) == 0) {
  7180. feature = RANDOMIZE_SKIN_COLOR;
  7181. strncpy(feature_text, "skin color", sizeof(feature_text) - 1);
  7182. }
  7183. else if (strncasecmp(value, "wing_color1", strlen(value)) == 0) {
  7184. feature = RANDOMIZE_WING_COLOR1;
  7185. strncpy(feature_text, "wing color1", sizeof(feature_text) - 1);
  7186. }
  7187. else if (strncasecmp(value, "wing_color2", strlen(value)) == 0) {
  7188. feature = RANDOMIZE_WING_COLOR2;
  7189. strncpy(feature_text, "wing color2", sizeof(feature_text) - 1);
  7190. }
  7191. else {
  7192. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is not a valid feature to randomize.", value);
  7193. 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'.");
  7194. }
  7195. if (feature > 0) {
  7196. if (option == 1) {
  7197. if (target->GetRandomize() & feature)
  7198. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is already set to randomly generate their %s.", target->GetName(), feature_text);
  7199. else {
  7200. target->AddRandomize(feature);
  7201. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(feature);
  7202. database.UpdateRandomize(target->GetDatabaseID(), feature);
  7203. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will now generate their %s randomly.", target->GetName(), feature_text);
  7204. }
  7205. }
  7206. else {
  7207. if (target->GetRandomize() & feature) {
  7208. target->AddRandomize(-feature);
  7209. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(-feature);
  7210. database.UpdateRandomize(target->GetDatabaseID(), -feature);
  7211. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will no longer generate their %s randomly.", target->GetName(), feature_text);
  7212. }
  7213. else
  7214. client->Message(CHANNEL_COLOR_YELLOW, "'%s' already does not randomly generate their %s.", target->GetName(), feature_text);
  7215. }
  7216. }
  7217. }
  7218. else
  7219. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  7220. }
  7221. else
  7222. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  7223. }
  7224. }
  7225. else {
  7226. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /randomize [show | [feature [1|0]]");
  7227. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "'show' will display current configured features");
  7228. 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'.");
  7229. }
  7230. }
  7231. else
  7232. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "The target you wish to randomize must be an NPC.");
  7233. }
  7234. else
  7235. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select the target you wish to randomize.");
  7236. }
  7237. /*
  7238. Function: Command_ShowCloak()
  7239. Purpose : Character Settings combo box for Show Cloak
  7240. Params : true/false
  7241. Dev : John Adams
  7242. Example :
  7243. */
  7244. void Commands::Command_ShowCloak(Client* client, Seperator* sep)
  7245. {
  7246. Player* player = client->GetPlayer();
  7247. if (sep && sep->arg[0])
  7248. {
  7249. const char* value = sep->arg[0];
  7250. if (strncasecmp(value, "true", strlen(value)) == 0)
  7251. {
  7252. player->set_character_flag(CF_SHOW_CLOAK);
  7253. player->reset_character_flag(CF2_SHOW_RANGED);
  7254. }
  7255. else if (strncasecmp(value, "false", strlen(value)) == 0)
  7256. player->reset_character_flag(CF_SHOW_CLOAK);
  7257. else
  7258. {
  7259. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7260. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7261. }
  7262. }
  7263. }
  7264. /*
  7265. Function: Command_ShowHelm()
  7266. Purpose : Character Settings combo box for Show Helm
  7267. Params : true/false
  7268. Dev : John Adams
  7269. Example :
  7270. */
  7271. void Commands::Command_ShowHelm(Client* client, Seperator* sep)
  7272. {
  7273. Player* player = client->GetPlayer();
  7274. if (sep && sep->arg[0])
  7275. {
  7276. const char* value = sep->arg[0];
  7277. if (strncasecmp(value, "true", strlen(value)) == 0)
  7278. {
  7279. player->reset_character_flag(CF_HIDE_HELM);
  7280. player->set_character_flag(CF_HIDE_HOOD);
  7281. }
  7282. else if (strncasecmp(value, "false", strlen(value)) == 0)
  7283. player->set_character_flag(CF_HIDE_HELM);
  7284. else
  7285. {
  7286. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7287. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7288. }
  7289. }
  7290. }
  7291. /*
  7292. Function: Command_ShowHood()
  7293. Purpose : Character Settings combo box for Show Hood
  7294. Params : true/false
  7295. Dev : John Adams
  7296. Example :
  7297. */
  7298. void Commands::Command_ShowHood(Client* client, Seperator* sep)
  7299. {
  7300. Player* player = client->GetPlayer();
  7301. if (sep && sep->arg[0])
  7302. {
  7303. const char* value = sep->arg[0];
  7304. if (strncasecmp(value, "true", strlen(value)) == 0)
  7305. {
  7306. player->reset_character_flag(CF_HIDE_HOOD);
  7307. player->set_character_flag(CF_HIDE_HELM);
  7308. }
  7309. else if (strncasecmp(value, "false", strlen(value)) == 0)
  7310. player->set_character_flag(CF_HIDE_HOOD);
  7311. else
  7312. {
  7313. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7314. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7315. }
  7316. }
  7317. }
  7318. /*
  7319. Function: Command_ShowHoodHelm()
  7320. Purpose : Character Settings combo box for Show Helm or Hood
  7321. Params : true/false
  7322. Dev : John Adams
  7323. Example :
  7324. */
  7325. void Commands::Command_ShowHoodHelm(Client* client, Seperator* sep)
  7326. {
  7327. Player* player = client->GetPlayer();
  7328. if (sep && sep->arg[0])
  7329. {
  7330. const char* value = sep->arg[0];
  7331. if (strncasecmp(value, "true", strlen(value)) == 0)
  7332. {
  7333. player->reset_character_flag(CF_HIDE_HOOD);
  7334. player->reset_character_flag(CF_HIDE_HELM);
  7335. }
  7336. else if (strncasecmp(value, "false", strlen(value)) == 0)
  7337. {
  7338. // don't think we ever wind up in here...
  7339. player->set_character_flag(CF_HIDE_HOOD);
  7340. player->set_character_flag(CF_HIDE_HELM);
  7341. }
  7342. else
  7343. {
  7344. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7345. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7346. }
  7347. }
  7348. }
  7349. /*
  7350. Function: Command_ShowRanged()
  7351. Purpose : Character Settings combo box for Show Ranged weapon
  7352. Params : true/false
  7353. Dev : John Adams
  7354. Example :
  7355. */
  7356. void Commands::Command_ShowRanged(Client* client, Seperator* sep)
  7357. {
  7358. Player* player = client->GetPlayer();
  7359. if (sep && sep->arg[0])
  7360. {
  7361. const char* value = sep->arg[0];
  7362. if (strncasecmp(value, "true", strlen(value)) == 0)
  7363. {
  7364. player->set_character_flag(CF2_SHOW_RANGED);
  7365. player->reset_character_flag(CF_SHOW_CLOAK);
  7366. }
  7367. else if (strncasecmp(value, "false", strlen(value)) == 0)
  7368. player->reset_character_flag(CF2_SHOW_RANGED);
  7369. else
  7370. {
  7371. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7372. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  7373. }
  7374. }
  7375. }
  7376. /*
  7377. Function:
  7378. Purpose :
  7379. Params :
  7380. Dev :
  7381. Example :
  7382. */
  7383. void Commands::Command_Skills(Client* client, Seperator* sep, int handler)
  7384. {
  7385. Player* player = 0;
  7386. Client* to_client = 0;
  7387. if(client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  7388. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  7389. switch(handler)
  7390. {
  7391. case COMMAND_SKILL:
  7392. {
  7393. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill [add|remove|list] [skill name]");
  7394. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to add/remove skills for that player.");
  7395. break;
  7396. }
  7397. case COMMAND_SKILL_ADD:
  7398. {
  7399. if (sep && sep->arg[0])
  7400. {
  7401. const char* skill_name = sep->argplus[0];
  7402. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  7403. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // add skill to your target, if target is not you
  7404. {
  7405. player = to_client->GetPlayer();
  7406. if (player)
  7407. {
  7408. if (!player->GetSkills()->HasSkill(skill->skill_id))
  7409. {
  7410. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  7411. client->Message(CHANNEL_COLOR_YELLOW, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  7412. to_client->Message(CHANNEL_COLOR_YELLOW, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  7413. }
  7414. else
  7415. client->Message(CHANNEL_COLOR_YELLOW, "%s already has the skill '%s'.", player->GetName(), skill_name);
  7416. }
  7417. }
  7418. else if (skill) // add skill to yourself
  7419. {
  7420. player = client->GetPlayer();
  7421. if (player)
  7422. {
  7423. if (!player->GetSkills()->HasSkill(skill->skill_id))
  7424. {
  7425. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  7426. client->Message(CHANNEL_COLOR_YELLOW, "Added skill '%s'.", skill_name);
  7427. }
  7428. else
  7429. client->Message(CHANNEL_COLOR_YELLOW, "You already have the skill '%s'.", skill_name);
  7430. }
  7431. }
  7432. else
  7433. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  7434. }
  7435. else
  7436. {
  7437. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill add [skill name]");
  7438. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  7439. }
  7440. break;
  7441. }
  7442. case COMMAND_SKILL_REMOVE:
  7443. {
  7444. if (sep && sep->arg[0])
  7445. {
  7446. const char* skill_name = sep->argplus[0];
  7447. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  7448. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // remove skill from your target, if target is not you
  7449. {
  7450. player = to_client->GetPlayer();
  7451. if (player)
  7452. {
  7453. if (player->GetSkills()->HasSkill(skill->skill_id))
  7454. {
  7455. player->RemoveSkillFromDB(skill, true);
  7456. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  7457. to_client->Message(CHANNEL_COLOR_YELLOW, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  7458. }
  7459. else
  7460. client->Message(CHANNEL_COLOR_YELLOW, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  7461. }
  7462. }
  7463. else if(skill) // remove skill from yourself
  7464. {
  7465. Player* player = client->GetPlayer();
  7466. if (player)
  7467. {
  7468. if (player->GetSkills()->HasSkill(skill->skill_id))
  7469. {
  7470. player->RemoveSkillFromDB(skill, true);
  7471. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s'.", skill_name);
  7472. }
  7473. else
  7474. client->Message(CHANNEL_COLOR_YELLOW, "You do not have the skill '%s'.", skill_name);
  7475. }
  7476. }
  7477. else
  7478. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  7479. }
  7480. else
  7481. {
  7482. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill remove [skill name]");
  7483. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  7484. }
  7485. break;
  7486. }
  7487. case COMMAND_SKILL_LIST:
  7488. {
  7489. if (sep && sep->arg[0])
  7490. {
  7491. const char* skill_name = sep->argplus[0];
  7492. client->Message(CHANNEL_COLOR_YELLOW, "Listing skills like '%s':", skill_name);
  7493. map<int32, Skill*>* skills = master_skill_list.GetAllSkills();
  7494. map<int32, Skill*>::iterator itr;
  7495. if (skills && skills->size() > 0)
  7496. {
  7497. for (itr = skills->begin(); itr != skills->end(); itr++)
  7498. {
  7499. Skill* skill = itr->second;
  7500. string current_skill_name = ::ToLower(string(skill->name.data.c_str()));
  7501. if (current_skill_name.find(::ToLower(string(skill_name))) < 0xFFFFFFFF)
  7502. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", skill->name.data.c_str(), skill->skill_id);
  7503. }
  7504. }
  7505. }
  7506. else
  7507. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill list [skill name]");
  7508. break;
  7509. }
  7510. }
  7511. }
  7512. /*
  7513. Function: Command_SpawnTemplate()
  7514. Purpose : Create or Use defined Spawn Templates
  7515. Params : create, save, rempve, list
  7516. Dev : John Adams
  7517. Example : /spawn template create "Test"
  7518. */
  7519. void Commands::Command_SpawnTemplate(Client* client, Seperator* sep)
  7520. {
  7521. if (sep == NULL || sep->arg[0] == NULL)
  7522. {
  7523. 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.");
  7524. return;
  7525. }
  7526. // got params, continue
  7527. const char * template_cmd = sep->arg[0];
  7528. if (strncasecmp(template_cmd, "list", strlen(template_cmd)) == 0)
  7529. {
  7530. if (!sep->IsSet(1))
  7531. {
  7532. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /spawn template list [name|location_id]");
  7533. 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.");
  7534. return;
  7535. }
  7536. map<int32, string>* template_names = 0;
  7537. if (sep->IsNumber(1))
  7538. {
  7539. int32 location_id = 0;
  7540. location_id = atoi(sep->arg[1]);
  7541. template_names = database.GetSpawnTemplateListByID(location_id);
  7542. }
  7543. else
  7544. {
  7545. const char* name = 0;
  7546. name = sep->argplus[1];
  7547. template_names = database.GetSpawnTemplateListByName(name);
  7548. }
  7549. if(!template_names)
  7550. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No templates found.");
  7551. else
  7552. {
  7553. map<int32, string>::iterator itr;
  7554. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  7555. for(itr = template_names->begin(); itr != template_names->end(); itr++)
  7556. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  7557. safe_delete(template_names);
  7558. }
  7559. }
  7560. else if (strncasecmp(template_cmd, "save", strlen(template_cmd)) == 0)
  7561. {
  7562. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  7563. if ( target && (target->IsNPC() || target->IsObject() || target->IsSign() || target->IsWidget() || target->IsGroundSpawn()) )
  7564. {
  7565. if (sep && sep->arg[1][0] && !sep->IsNumber(1))
  7566. {
  7567. // first, lookup to see if template name already exists
  7568. const char* name = 0;
  7569. name = sep->argplus[1];
  7570. map<int32, string>* template_names = database.GetSpawnTemplateListByName(name);
  7571. if(!template_names)
  7572. {
  7573. int32 new_template_id = database.SaveSpawnTemplate(target->GetSpawnLocationID(), name);
  7574. if( new_template_id > 0 )
  7575. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template '%s' added for spawn '%s' (%u) as TemplateID: %u", name, target->GetName(), target->GetSpawnLocationID(), new_template_id);
  7576. else
  7577. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' for spawn '%s' (%u).", name, target->GetName(), target->GetSpawnLocationID());
  7578. }
  7579. else
  7580. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' - Already exists!", name);
  7581. }
  7582. else
  7583. client->Message(CHANNEL_COLOR_RED, "ERROR: Saving a new spawn template requires a valid template name!");
  7584. }
  7585. else
  7586. client->Message(CHANNEL_COLOR_RED, "ERROR: You must target the spawn you wish to save as a template!");
  7587. }
  7588. else if (strncasecmp(template_cmd, "remove", strlen(template_cmd)) == 0)
  7589. {
  7590. if (sep && sep->arg[1][0] && sep->IsNumber(1))
  7591. {
  7592. int32 template_id = 0;
  7593. template_id = atoi(sep->arg[1]);
  7594. if (database.RemoveSpawnTemplate(template_id))
  7595. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template ID: %u successfully removed.", template_id);
  7596. else
  7597. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to remove spawn template ID: %u", template_id);
  7598. }
  7599. else
  7600. client->Message(CHANNEL_COLOR_RED, "ERROR: Removing a spawn template requires a valid template ID!");
  7601. }
  7602. // Renamed create to spawn
  7603. else if (strncasecmp(template_cmd, "spawn", strlen(template_cmd)) == 0)
  7604. {
  7605. if (sep && sep->arg[1][0])
  7606. {
  7607. int32 new_location = 0;
  7608. if (sep->IsNumber(1))
  7609. {
  7610. int32 template_id = 0;
  7611. template_id = atoi(sep->arg[1]);
  7612. new_location = database.CreateSpawnFromTemplateByID(client, template_id);
  7613. if( new_location > 0 )
  7614. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template ID: %u", new_location, template_id);
  7615. else
  7616. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template ID: %u", template_id);
  7617. }
  7618. else
  7619. {
  7620. const char* name = 0;
  7621. name = sep->argplus[1];
  7622. new_location = database.CreateSpawnFromTemplateByName(client, name);
  7623. if( new_location > 0 )
  7624. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template: '%s'", new_location, name);
  7625. else
  7626. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template: '%s'", name);
  7627. }
  7628. }
  7629. else
  7630. client->Message(CHANNEL_COLOR_RED, "ERROR: Spawning a new spawn location requires a valid template name or ID!");
  7631. }
  7632. else
  7633. client->Message(CHANNEL_COLOR_RED, "ERROR: Unknown /spawn template command.");
  7634. }
  7635. void Commands::Command_Speed(Client* client, Seperator* sep) {
  7636. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  7637. float new_speed = atof(sep->arg[0]);
  7638. if (new_speed > 0.0f)
  7639. {
  7640. client->GetPlayer()->SetSpeed(new_speed, true);
  7641. client->GetPlayer()->SetCharSheetChanged(true);
  7642. database.insertCharacterProperty(client, CHAR_PROPERTY_SPEED, sep->arg[0]);
  7643. client->Message(CHANNEL_STATUS, "Setting speed to %.2f.", new_speed);
  7644. }
  7645. else
  7646. client->Message(CHANNEL_STATUS, "Invalid speed provided %s.", sep->arg[0]);
  7647. }
  7648. else{
  7649. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /speed {new speed value}");
  7650. }
  7651. }
  7652. /*
  7653. Function: Command_StationMarketPlace()
  7654. Purpose : just trying to eat the console spam for now
  7655. Params :
  7656. Dev : John
  7657. */
  7658. void Commands::Command_StationMarketPlace(Client* client, Seperator* sep)
  7659. {
  7660. PrintSep(sep, "COMMAND_SMP");
  7661. // This will reduce the spam from once every 10 sec to once every 30 sec,
  7662. // can't seem to reduce it any more get rid of it completely...
  7663. if (sep && strcmp(sep->arg[0], "gkw") == 0) {
  7664. PacketStruct* packet = configReader.getStruct("WS_MarketFundsUpdate", client->GetVersion());
  7665. if (packet) {
  7666. packet->setDataByName("account_id", client->GetAccountID());
  7667. packet->setDataByName("character_id", client->GetCharacterID());
  7668. packet->setDataByName("unknown1", 1, 5);
  7669. packet->setDataByName("unknown1", 26, 6);
  7670. packet->setDataByName("unknown2", 0xFFFFFFFF);
  7671. packet->setDataByName("unknown3", 248, 1);
  7672. client->QueuePacket(packet->serialize());
  7673. }
  7674. safe_delete(packet);
  7675. }
  7676. }
  7677. /*
  7678. Function: Command_StopDrinking()
  7679. Purpose : Stops player from auto-consuming drink
  7680. Params :
  7681. Dev : Zcoretri
  7682. Example : /stopdrinking
  7683. */
  7684. void Commands::Command_StopDrinking(Client* client)
  7685. {
  7686. client->GetPlayer()->reset_character_flag(CF_DRINK_AUTO_CONSUME);
  7687. client->Message(CHANNEL_COLOR_YELLOW,"You stop drinking your current drink.");
  7688. }
  7689. /*
  7690. Function: Command_StopEating()
  7691. Purpose : Stops player from auto-consuming food
  7692. Params :
  7693. Dev : Zcoretri
  7694. Example : /stopeating
  7695. */
  7696. void Commands::Command_StopEating(Client* client)
  7697. {
  7698. client->GetPlayer()->reset_character_flag(CF_FOOD_AUTO_CONSUME);
  7699. client->Message(CHANNEL_COLOR_YELLOW,"You stop eating your current food.");
  7700. }
  7701. /*
  7702. Function: Command_Title()
  7703. Purpose : Help for /title command
  7704. Params : n/a
  7705. Dev : Zcoretri
  7706. Example : /title
  7707. */
  7708. void Commands::Command_Title(Client* client)
  7709. {
  7710. client->Message(CHANNEL_COLOR_YELLOW, "Available subcommands: list, setprefix <index>, setsuffix <index>, fix");
  7711. }
  7712. /*
  7713. Function: Command_TitleList()
  7714. Purpose : List available titles for player
  7715. Params : n/a
  7716. Dev : Zcoretri
  7717. Example : /title list
  7718. */
  7719. void Commands::Command_TitleList(Client* client)
  7720. {
  7721. // must call release read lock before leaving function on GetPlayerTitles
  7722. vector<Title*>* titles = client->GetPlayer()->GetPlayerTitles()->GetAllTitles();
  7723. vector<Title*>::iterator itr;
  7724. Title* title;
  7725. sint32 i = 0;
  7726. client->Message(CHANNEL_NARRATIVE, "Listing available titles:");
  7727. for(itr = titles->begin(); itr != titles->end(); itr++)
  7728. {
  7729. title = *itr;
  7730. client->Message(CHANNEL_NARRATIVE, "%i: type=[%s] title=[%s]", i, title->GetPrefix() ? "Prefix":"Suffix", title->GetName());
  7731. i++;
  7732. }
  7733. client->GetPlayer()->GetPlayerTitles()->ReleaseReadLock();
  7734. }
  7735. /*
  7736. Function: Command_TitleSetPrefix()
  7737. Purpose : Set Prefix title for player
  7738. Params : Title ID
  7739. Dev : Zcoretri
  7740. Example : /title setprefix 1
  7741. */
  7742. void Commands::Command_TitleSetPrefix(Client* client, Seperator* sep)
  7743. {
  7744. if (sep && sep->arg[0] && sep->IsNumber(0))
  7745. {
  7746. sint32 index = atoul(sep->arg[0]);
  7747. if(index > -1)
  7748. {
  7749. Title* title = client->GetPlayer()->GetPlayerTitles()->GetTitle(index);
  7750. if(!title)
  7751. {
  7752. client->Message(CHANNEL_COLOR_RED, "Missing index %i to set title", index);
  7753. return;
  7754. }
  7755. else if(!title->GetPrefix())
  7756. {
  7757. client->Message(CHANNEL_COLOR_RED, "%s is not a prefix.", title->GetName());
  7758. return;
  7759. }
  7760. }
  7761. else // make sure client doesn't pass some bogus negative index
  7762. index = -1;
  7763. database.SaveCharPrefixIndex(index, client->GetCharacterID());
  7764. client->SendTitleUpdate();
  7765. }
  7766. }
  7767. /*
  7768. Function: Command_TitleSetSuffix()
  7769. Purpose : Set Suffix title for player
  7770. Params : Title ID
  7771. Dev : Zcoretri
  7772. Example : /title setsuffix 1
  7773. */
  7774. void Commands::Command_TitleSetSuffix(Client* client, Seperator* sep)
  7775. {
  7776. if (sep && sep->arg[0] && sep->IsNumber(0))
  7777. {
  7778. sint32 index = atoul(sep->arg[0]);
  7779. if(index > -1)
  7780. {
  7781. Title* title = client->GetPlayer()->GetPlayerTitles()->GetTitle(index);
  7782. if(!title)
  7783. {
  7784. client->Message(CHANNEL_COLOR_RED, "Missing index %i to set title", index);
  7785. return;
  7786. }
  7787. else if(title->GetPrefix())
  7788. {
  7789. client->Message(CHANNEL_COLOR_RED, "%s is not a suffix.", title->GetName());
  7790. return;
  7791. }
  7792. }
  7793. else // make sure client doesn't pass some bogus negative index
  7794. index = -1;
  7795. database.SaveCharSuffixIndex(index, client->GetCharacterID());
  7796. client->SendTitleUpdate();
  7797. }
  7798. }
  7799. /*
  7800. Function: Command_TitleFix()
  7801. Purpose : Fix title for player (???)
  7802. Params :
  7803. Dev : Zcoretri
  7804. Example :
  7805. */
  7806. void Commands::Command_TitleFix(Client* client, Seperator* sep)
  7807. {
  7808. PrintSep(sep, "COMMAND_TITLE_FIX");
  7809. LogWrite(MISC__TODO, 1, "Titles", "TODO-Command: TITLE_FIX");
  7810. }
  7811. /*
  7812. Function: Command_Toggle_Anonymous()
  7813. Purpose : Toggles player Anonymous
  7814. Params :
  7815. Dev : paulgh
  7816. Example : /anon
  7817. */
  7818. void Commands::Command_Toggle_Anonymous(Client* client)
  7819. {
  7820. Player* player = client->GetPlayer();
  7821. player->toggle_character_flag(CF_ANONYMOUS);
  7822. client->Message(CHANNEL_COLOR_YELLOW,"You are %s anonymous.", player->get_character_flag(CF_ANONYMOUS)?"now":"no longer");
  7823. if (player->get_character_flag(CF_ANONYMOUS))
  7824. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ANONYMOUS);
  7825. else
  7826. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ANONYMOUS);
  7827. }
  7828. /*
  7829. Function: Command_Toggle_AutoConsume()
  7830. Purpose : Toggles player food/drink auto consume
  7831. Params : unknown
  7832. Dev : paulgh
  7833. Example : /set_auto_consume
  7834. */
  7835. void Commands::Command_Toggle_AutoConsume(Client* client, Seperator* sep)
  7836. {
  7837. Player* player = client->GetPlayer();
  7838. if (sep && sep->arg[0])
  7839. PrintSep(sep, "COMMAND_SET_AUTO_CONSUME");
  7840. if (sep && sep->arg[0] && sep->IsNumber(0))
  7841. {
  7842. int8 slot = atoi(sep->arg[0]);
  7843. int8 flag = atoi(sep->arg[1]);
  7844. if (client->GetVersion() <= 283) {
  7845. slot += 4;
  7846. }
  7847. else if (client->GetVersion() <= 546) {
  7848. slot += 2;
  7849. }
  7850. if (slot == EQ2_FOOD_SLOT)
  7851. {
  7852. player->toggle_character_flag(CF_FOOD_AUTO_CONSUME);
  7853. player->SetCharSheetChanged(true);
  7854. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  7855. if (flag == 1)
  7856. client->Message(CHANNEL_NARRATIVE, "You decide to eat immediately whenever you become hungry.");
  7857. else
  7858. {
  7859. client->Message(CHANNEL_NARRATIVE, "You decide to ignore the hunger.");
  7860. return;
  7861. }
  7862. }
  7863. else
  7864. {
  7865. player->toggle_character_flag(CF_DRINK_AUTO_CONSUME);
  7866. player->SetCharSheetChanged(true);
  7867. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  7868. if (flag == 1)
  7869. client->Message(CHANNEL_NARRATIVE, "You decide to drink immediately whenever you become thirsty.");
  7870. else
  7871. {
  7872. client->Message(CHANNEL_NARRATIVE, "You decide to ignore the thirst.");
  7873. return;
  7874. }
  7875. }
  7876. if(slot == 22 && player->GetSpellEffectBySpellType(SPELL_TYPE_FOOD))
  7877. return;
  7878. else if (player->GetSpellEffectBySpellType(SPELL_TYPE_DRINK))
  7879. return;
  7880. Item* item = player->GetEquipmentList()->GetItem(slot);
  7881. if(item)
  7882. client->ConsumeFoodDrink(item, slot);
  7883. }
  7884. }
  7885. /*
  7886. Function: Command_Toggle_BonusXP()
  7887. Purpose : Toggles player Bonus XP
  7888. Params :
  7889. Dev : John Adams
  7890. Example : /disable_char_bonus_exp
  7891. */
  7892. void Commands::Command_Toggle_BonusXP(Client* client)
  7893. {
  7894. Player* player = client->GetPlayer();
  7895. player->toggle_character_flag(CF2_CHARACTER_BONUS_EXPERIENCE_ENABLED);
  7896. player->SetCharSheetChanged(true);
  7897. }
  7898. /*
  7899. Function: Command_Toggle_CombatXP()
  7900. Purpose : Toggles player Adventure XP
  7901. Params :
  7902. Dev : John Adams
  7903. Example : /disable_combat_exp
  7904. */
  7905. void Commands::Command_Toggle_CombatXP(Client* client)
  7906. {
  7907. Player* player = client->GetPlayer();
  7908. player->toggle_character_flag(CF_COMBAT_EXPERIENCE_ENABLED);
  7909. player->SetCharSheetChanged(true);
  7910. }
  7911. /*
  7912. Function: Command_Toggle_GMHide()
  7913. Purpose : Toggles hiding player GM status
  7914. Params :
  7915. Dev : Scatman
  7916. Example : /gm_hide
  7917. */
  7918. void Commands::Command_Toggle_GMHide(Client* client)
  7919. {
  7920. Player* player = client->GetPlayer();
  7921. player->toggle_character_flag(CF_HIDE_STATUS);
  7922. client->Message(CHANNEL_COLOR_YELLOW,"You are %s hiding your GM status.", player->get_character_flag(CF_HIDE_STATUS)?"now":"no longer");
  7923. }
  7924. /*
  7925. Function: Command_Toggle_GMVanish()
  7926. Purpose : Toggles hiding GM players from /who searches
  7927. Params :
  7928. Dev : Scatman
  7929. Example : /gm_vanish
  7930. */
  7931. void Commands::Command_Toggle_GMVanish(Client* client)
  7932. {
  7933. Player* player = client->GetPlayer();
  7934. player->toggle_character_flag(CF_GM_HIDDEN);
  7935. client->Message(CHANNEL_COLOR_YELLOW,"You are %s invisible to who queries.", player->get_character_flag(CF_GM_HIDDEN)?"now":"no longer");
  7936. }
  7937. /*
  7938. Function: Command_Toggle_Illusions()
  7939. Purpose : Toggles player illusion form
  7940. Params : not sure sep is needed, testing
  7941. Dev : paulgh
  7942. Example : /hide_illusions
  7943. */
  7944. void Commands::Command_Toggle_Illusions(Client* client, Seperator* sep)
  7945. {
  7946. if (sep && sep->arg[0])
  7947. PrintSep(sep, "COMMAND_TOGGLE_ILLUSIONS");
  7948. client->GetPlayer()->toggle_character_flag(CF_SHOW_ILLUSION);
  7949. }
  7950. /*
  7951. Function: Command_Toggle_LFG()
  7952. Purpose : Toggles player LFG Flag
  7953. Params :
  7954. Dev : paulgh
  7955. Example : /lfg
  7956. */
  7957. void Commands::Command_Toggle_LFG(Client* client)
  7958. {
  7959. Player* player = client->GetPlayer();
  7960. player->toggle_character_flag(CF_LFG);
  7961. client->Message(CHANNEL_COLOR_YELLOW,"You are %s LFG.", player->get_character_flag(CF_LFG)?"now":"no longer");
  7962. if (player->get_character_flag(CF_LFG))
  7963. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFG);
  7964. else
  7965. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFG);
  7966. }
  7967. /*
  7968. Function: Command_Toggle_LFW()
  7969. Purpose : Toggles player LFW Flag
  7970. Params :
  7971. Dev : paulgh
  7972. Example : /lfw
  7973. */
  7974. void Commands::Command_Toggle_LFW(Client* client)
  7975. {
  7976. Player* player = client->GetPlayer();
  7977. player->toggle_character_flag(CF_LFW);
  7978. client->Message(CHANNEL_COLOR_YELLOW,"You %s looking for work.", player->get_character_flag(CF_LFW)?"let others know you are":"stop");
  7979. if (player->get_character_flag(CF_LFW))
  7980. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFW);
  7981. else
  7982. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFW);
  7983. }
  7984. /*
  7985. Function: Command_Toggle_QuestXP()
  7986. Purpose : Toggles player Quest XP
  7987. Params :
  7988. Dev : John Adams
  7989. Example : /disable_quest_exp
  7990. */
  7991. void Commands::Command_Toggle_QuestXP(Client* client)
  7992. {
  7993. Player* player = client->GetPlayer();
  7994. player->toggle_character_flag(CF_QUEST_EXPERIENCE_ENABLED);
  7995. player->SetCharSheetChanged(true);
  7996. }
  7997. /*
  7998. Function: Command_Toggle_Roleplaying()
  7999. Purpose : Toggles player Roleplaying flag
  8000. Params :
  8001. Dev : paulgh
  8002. Example : /role
  8003. */
  8004. void Commands::Command_Toggle_Roleplaying(Client* client)
  8005. {
  8006. Player* player = client->GetPlayer();
  8007. player->toggle_character_flag(CF_ROLEPLAYING);
  8008. client->Message(CHANNEL_COLOR_YELLOW,"You are %s roleplaying.", player->get_character_flag(CF_ROLEPLAYING)?"now":"no longer");
  8009. if (player->get_character_flag(CF_ROLEPLAYING))
  8010. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ROLEPLAYING);
  8011. else
  8012. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ROLEPLAYING);
  8013. }
  8014. void Commands::Command_Toggle_Duels(Client* client)
  8015. {
  8016. Player* player = client->GetPlayer();
  8017. player->toggle_character_flag(CF_ALLOW_DUEL_INVITES);
  8018. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting duel invites.", player->get_character_flag(CF_ALLOW_DUEL_INVITES)?"now":"no longer");
  8019. }
  8020. void Commands::Command_Toggle_Trades(Client* client)
  8021. {
  8022. Player* player = client->GetPlayer();
  8023. player->toggle_character_flag(CF_ALLOW_TRADE_INVITES);
  8024. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting trade invites.", player->get_character_flag(CF_ALLOW_TRADE_INVITES)?"now":"no longer");
  8025. }
  8026. void Commands::Command_Toggle_Guilds(Client* client)
  8027. {
  8028. Player* player = client->GetPlayer();
  8029. player->toggle_character_flag(CF_ALLOW_GUILD_INVITES);
  8030. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting guild invites.", player->get_character_flag(CF_ALLOW_GUILD_INVITES)?"now":"no longer");
  8031. }
  8032. void Commands::Command_Toggle_Groups(Client* client)
  8033. {
  8034. Player* player = client->GetPlayer();
  8035. player->toggle_character_flag(CF_ALLOW_GROUP_INVITES);
  8036. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting group invites.", player->get_character_flag(CF_ALLOW_GROUP_INVITES)?"now":"no longer");
  8037. }
  8038. void Commands::Command_Toggle_Raids(Client* client)
  8039. {
  8040. Player* player = client->GetPlayer();
  8041. player->toggle_character_flag(CF_ALLOW_RAID_INVITES);
  8042. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting raid invites.", player->get_character_flag(CF_ALLOW_RAID_INVITES)?"now":"no longer");
  8043. }
  8044. void Commands::Command_Toggle_LON(Client* client)
  8045. {
  8046. Player* player = client->GetPlayer();
  8047. player->toggle_character_flag(CF2_ALLOW_LON_INVITES);
  8048. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting LoN invites.", player->get_character_flag(CF2_ALLOW_LON_INVITES)?"now":"no longer");
  8049. }
  8050. void Commands::Command_Toggle_VoiceChat(Client* client)
  8051. {
  8052. Player* player = client->GetPlayer();
  8053. player->toggle_character_flag(CF2_ALLOW_VOICE_INVITES);
  8054. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting voice chat invites.", player->get_character_flag(CF2_ALLOW_VOICE_INVITES)?"now":"no longer");
  8055. }
  8056. /*
  8057. Function: Command_TradeStart()
  8058. Purpose : Starts item/coin trade between players
  8059. Params :
  8060. Dev :
  8061. Example :
  8062. */
  8063. #include "../Trade.h"
  8064. void Commands::Command_TradeStart(Client* client, Seperator* sep)
  8065. {
  8066. PrintSep(sep, "COMMAND_START_TRADE");
  8067. Entity* trader = client->GetPlayer();
  8068. Entity* trader2 = 0;
  8069. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  8070. Spawn* spawn = client->GetPlayer()->GetSpawnWithPlayerID(atoi(sep->arg[0]));
  8071. if (spawn) {
  8072. if (spawn->IsEntity())
  8073. trader2 = (Entity*)spawn;
  8074. }
  8075. }
  8076. else if (client->GetPlayer()->GetTarget()) {
  8077. if (client->GetPlayer()->GetTarget()->IsEntity())
  8078. trader2 = (Entity*)client->GetPlayer()->GetTarget();
  8079. }
  8080. // can only trade with player or bots
  8081. if (trader && trader2) {
  8082. if (trader == trader2) {
  8083. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade with yourself.");
  8084. }
  8085. else if (trader2->IsPlayer() || trader2->IsBot()) {
  8086. LogWrite(PLAYER__ERROR, 0, "Trade", "creating trade");
  8087. if (trader->trade)
  8088. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are already trading.");
  8089. else if (trader2->trade)
  8090. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is already trading.");
  8091. else {
  8092. Trade* trade = new Trade(trader, trader2);
  8093. trader->trade = trade;
  8094. trader2->trade = trade;
  8095. }
  8096. }
  8097. else {
  8098. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can only trade with another player or a bot.");
  8099. }
  8100. }
  8101. else
  8102. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to find target");
  8103. }
  8104. /*
  8105. Function: Command_Track()
  8106. Purpose : Starts/Stops Tracking for a player
  8107. Params :
  8108. Dev : Scatman
  8109. Example : /track
  8110. */
  8111. void Commands::Command_Track(Client* client)
  8112. {
  8113. if (!client->GetPlayer()->GetIsTracking())
  8114. client->GetPlayer()->GetZone()->AddPlayerTracking(client->GetPlayer());
  8115. else
  8116. client->GetPlayer()->GetZone()->RemovePlayerTracking(client->GetPlayer(), TRACKING_STOP);
  8117. }
  8118. /*
  8119. Function: Command_TradeAccept()
  8120. Purpose : Accepts item/coin trade between players
  8121. Params :
  8122. Dev :
  8123. Example :
  8124. */
  8125. void Commands::Command_TradeAccept(Client* client, Seperator* sep)
  8126. {
  8127. PrintSep(sep, "COMMAND_ACCEPT_TRADE");
  8128. Trade* trade = client->GetPlayer()->trade;
  8129. if (trade) {
  8130. bool trade_complete = trade->SetTradeAccepted(client->GetPlayer());
  8131. if (trade_complete)
  8132. safe_delete(trade);
  8133. }
  8134. else
  8135. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8136. }
  8137. /*
  8138. Function: Command_TradeReject()
  8139. Purpose : Rejects item/coin trade between players
  8140. Params :
  8141. Dev :
  8142. Example :
  8143. */
  8144. void Commands::Command_TradeReject(Client* client, Seperator* sep)
  8145. {
  8146. PrintSep(sep, "COMMAND_REJECT_TRADE");
  8147. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Reject Player Trading");
  8148. client->Message(CHANNEL_COLOR_YELLOW, "You cannot trade with other players (Not Implemented)");
  8149. }
  8150. /*
  8151. Function: Command_TradeCancel()
  8152. Purpose : Cancels item/coin trade between players
  8153. Params :
  8154. Dev :
  8155. Example :
  8156. */
  8157. void Commands::Command_TradeCancel(Client* client, Seperator* sep)
  8158. {
  8159. PrintSep(sep, "COMMAND_CANCEL_TRADE");
  8160. Trade* trade = client->GetPlayer()->trade;
  8161. if (trade) {
  8162. trade->CancelTrade(client->GetPlayer());
  8163. safe_delete(trade);
  8164. }
  8165. else
  8166. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8167. }
  8168. /*
  8169. Function: Command_TradeSetCoin()
  8170. Purpose : Sets coin trade between players
  8171. Params :
  8172. Dev :
  8173. Example :
  8174. */
  8175. void Commands::Command_TradeSetCoin(Client* client, Seperator* sep)
  8176. {
  8177. PrintSep(sep, "COMMAND_SET_TRADE_COIN");
  8178. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Set Trade Coin");
  8179. client->Message(CHANNEL_COLOR_YELLOW, "You cannot trade with other players (Not Implemented)");
  8180. }
  8181. /*
  8182. Function: Command_TradeAddCoin()
  8183. Purpose : Adds coin to trade between players
  8184. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  8185. Dev :
  8186. Example :
  8187. */
  8188. void Commands::Command_TradeAddCoin(Client* client, Seperator* sep, int handler)
  8189. {
  8190. PrintSep(sep, "COMMAND_ADD_TRADE_{coin type}");
  8191. Trade* trade = client->GetPlayer()->trade;
  8192. if (trade) {
  8193. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  8194. int32 amount = atoi(sep->arg[0]);
  8195. int64 val = 0;
  8196. switch (handler) {
  8197. case COMMAND_ADD_TRADE_COPPER:
  8198. {
  8199. val = amount;
  8200. trade->AddCoinToTrade(client->GetPlayer(), val);
  8201. break;
  8202. }
  8203. case COMMAND_ADD_TRADE_SILVER:
  8204. {
  8205. val = amount * 100;
  8206. trade->AddCoinToTrade(client->GetPlayer(), val);
  8207. break;
  8208. }
  8209. case COMMAND_ADD_TRADE_GOLD:
  8210. {
  8211. val = amount * 10000;
  8212. trade->AddCoinToTrade(client->GetPlayer(), val);
  8213. break;
  8214. }
  8215. case COMMAND_ADD_TRADE_PLAT:
  8216. {
  8217. val = amount * 1000000;
  8218. trade->AddCoinToTrade(client->GetPlayer(), val);
  8219. break;
  8220. }
  8221. default:
  8222. {
  8223. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  8224. break;
  8225. }
  8226. }
  8227. }
  8228. else
  8229. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount.");
  8230. }
  8231. else
  8232. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8233. }
  8234. /*
  8235. Function: Command_TradeRemoveCoin()
  8236. Purpose : Removes coin from trade between players
  8237. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  8238. Dev :
  8239. Example :
  8240. */
  8241. void Commands::Command_TradeRemoveCoin(Client* client, Seperator* sep, int handler)
  8242. {
  8243. PrintSep(sep, "COMMAND_REMOVE_TRADE_{coin type}");
  8244. Trade* trade = client->GetPlayer()->trade;
  8245. if (trade) {
  8246. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  8247. int32 amount = atoi(sep->arg[0]);
  8248. int64 val = 0;
  8249. switch (handler) {
  8250. case COMMAND_REMOVE_TRADE_COPPER:
  8251. {
  8252. val = amount;
  8253. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  8254. break;
  8255. }
  8256. case COMMAND_REMOVE_TRADE_SILVER:
  8257. {
  8258. val = amount * 100;
  8259. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  8260. break;
  8261. }
  8262. case COMMAND_REMOVE_TRADE_GOLD:
  8263. {
  8264. val = amount * 10000;
  8265. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  8266. break;
  8267. }
  8268. case COMMAND_REMOVE_TRADE_PLAT:
  8269. {
  8270. val = amount * 1000000;
  8271. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  8272. break;
  8273. }
  8274. default:
  8275. {
  8276. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  8277. break;
  8278. }
  8279. }
  8280. }
  8281. else
  8282. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount");
  8283. }
  8284. else
  8285. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8286. }
  8287. /*
  8288. Function: Command_TradeAddItem()
  8289. Purpose : Adds item to trade between players
  8290. Params :
  8291. Dev :
  8292. Example :
  8293. */
  8294. void Commands::Command_TradeAddItem(Client* client, Seperator* sep)
  8295. {
  8296. PrintSep(sep, "COMMAND_ADD_TRADE_ITEM");
  8297. /*
  8298. arg[0] = item index
  8299. arg[1] = slot
  8300. arg[2] = quantity
  8301. */
  8302. if (!client->GetPlayer()->trade) {
  8303. LogWrite(PLAYER__ERROR, 0, "Trade", "Player is not currently trading.");
  8304. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8305. return;
  8306. }
  8307. if (sep && sep->IsSet(0) && sep->IsNumber(0) && sep->IsSet(1) && sep->IsNumber(1) && sep->IsSet(2) && sep->IsNumber(2)) {
  8308. Item* item = 0;
  8309. int32 index = atoi(sep->arg[0]);
  8310. item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(index);
  8311. if (item) {
  8312. int8 result = client->GetPlayer()->trade->AddItemToTrade(client->GetPlayer(), item, atoi(sep->arg[2]), atoi(sep->arg[1]));
  8313. if (result == 1)
  8314. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Item is already being traded.");
  8315. else if (result == 2)
  8316. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade NO-TRADE items.");
  8317. else if (result == 3)
  8318. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade HEIRLOOM items.");
  8319. else if (result == 255)
  8320. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown error trying to add the item to the trade...");
  8321. }
  8322. else {
  8323. LogWrite(PLAYER__ERROR, 0, "Trade", "Unable to get an item for the player (%s) from the index (%u)", client->GetPlayer()->GetName(), index);
  8324. client->Message(CHANNEL_ERROR, "Unable to find item at index %u", index);
  8325. }
  8326. }
  8327. else
  8328. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  8329. }
  8330. /*
  8331. Function: Command_TradeRemoveItem()
  8332. Purpose : Removes item from trade between players
  8333. Params :
  8334. Dev :
  8335. Example :
  8336. */
  8337. void Commands::Command_TradeRemoveItem(Client* client, Seperator* sep)
  8338. {
  8339. PrintSep(sep, "COMMAND_REMOVE_TRADE_ITEM");
  8340. /*
  8341. arg[0] = trade window slot
  8342. */
  8343. Trade* trade = client->GetPlayer()->trade;
  8344. if (trade) {
  8345. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  8346. trade->RemoveItemFromTrade(client->GetPlayer(), atoi(sep->arg[0]));
  8347. }
  8348. else
  8349. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  8350. }
  8351. else
  8352. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  8353. }
  8354. void Commands::Command_TryOn(Client* client, Seperator* sep)
  8355. {
  8356. Item *item = 0;
  8357. sint32 crc;
  8358. if (sep) {
  8359. // 1096+ sends more info so need to do a version check so older clients (SF) still work
  8360. if (client->GetVersion() < 1096) {
  8361. if (sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2))
  8362. {
  8363. item = master_item_list.GetItem(atoul(sep->arg[1]));
  8364. crc = atol(sep->arg[2]);
  8365. }
  8366. }
  8367. else {
  8368. // From the broker and links in chat
  8369. if (strcmp(sep->arg[0], "crc") == 0) {
  8370. if (sep->IsNumber(2) && sep->IsNumber(3)) {
  8371. item = master_item_list.GetItem(atoul(sep->arg[2]));
  8372. crc = atol(sep->arg[3]);
  8373. }
  8374. }
  8375. // From inventory
  8376. if (strcmp(sep->arg[0], "dbid") == 0) {
  8377. if (sep->IsNumber(2) && sep->IsNumber(4)) {
  8378. item = master_item_list.GetItem(atoul(sep->arg[2]));
  8379. crc = atol(sep->arg[4]);
  8380. }
  8381. }
  8382. }
  8383. if (item)
  8384. client->ShowDressingRoom(item, crc);
  8385. }
  8386. }
  8387. void Commands::Command_JoinChannel(Client * client, Seperator *sep) {
  8388. const char *channel_name, *password = NULL;
  8389. if (sep == NULL || !sep->IsSet(0)) {
  8390. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /joinchannel <channel name> [password]");
  8391. return;
  8392. }
  8393. channel_name = sep->arg[0];
  8394. if (sep->IsSet(1))
  8395. password = sep->arg[1];
  8396. if (!chat.ChannelExists(channel_name) && !chat.CreateChannel(channel_name, password)) {
  8397. client->Message(CHANNEL_COLOR_RED, "Unable to create channel '%s'.", channel_name);
  8398. return;
  8399. }
  8400. if (chat.IsInChannel(client, channel_name)) {
  8401. client->Message(CHANNEL_NARRATIVE, "You are already in '%s'.", channel_name);
  8402. return;
  8403. }
  8404. if (chat.HasPassword(channel_name)) {
  8405. if (password == NULL) {
  8406. client->Message(CHANNEL_NARRATIVE, "Unable to join '%s': That channel is password protected.", channel_name);
  8407. return;
  8408. }
  8409. if (!chat.PasswordMatches(channel_name, password)) {
  8410. client->Message(CHANNEL_NARRATIVE, "Unable to join '%s': The password is not correc.t", channel_name);
  8411. return;
  8412. }
  8413. }
  8414. if (!chat.JoinChannel(client, channel_name))
  8415. client->Message(CHANNEL_COLOR_RED, "There was an internal error preventing you from joining '%s'.", channel_name);
  8416. }
  8417. void Commands::Command_JoinChannelFromLoad(Client * client, Seperator *sep) {
  8418. printf("ScatDebug: Received 'joinfromchannel', using the same function as 'joinchannel' (not sure what the difference is)\n");
  8419. Command_JoinChannel(client, sep);
  8420. }
  8421. void Commands::Command_TellChannel(Client *client, Seperator *sep) {
  8422. if (sep == NULL || !sep->IsSet(0) || !sep->IsSet(1)) {
  8423. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /tellchannel <channel name> <message>");
  8424. PrintSep(sep, "tellchannel");
  8425. return;
  8426. }
  8427. chat.TellChannel(client, sep->arg[0], sep->argplus[1]);
  8428. }
  8429. void Commands::Command_Test(Client* client, EQ2_16BitString* command_parms) {
  8430. Seperator* sep = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  8431. if (sep->IsSet(0)) {
  8432. if (atoi(sep->arg[0]) == 1) {
  8433. PacketStruct* packet2 = configReader.getStruct("WS_SpellGainedMsg", client->GetVersion());
  8434. if (packet2) {
  8435. packet2->setDataByName("spell_type", 2);
  8436. packet2->setDataByName("spell_id", 8308);
  8437. packet2->setDataByName("spell_name", "Sprint");
  8438. packet2->setDataByName("add_silently", 0);
  8439. packet2->setDataByName("tier", 1);
  8440. packet2->setDataByName("blah1", 1);
  8441. packet2->setDataByName("blah2", 1);
  8442. EQ2Packet* outapp = packet2->serialize();
  8443. DumpPacket(outapp);
  8444. client->QueuePacket(outapp);
  8445. safe_delete(packet2);
  8446. }
  8447. }
  8448. else if (atoi(sep->arg[0]) == 2) {
  8449. PacketStruct* packet2 = configReader.getStruct("WS_GuildUpdate", client->GetVersion());
  8450. if (packet2) {
  8451. packet2->setDataByName("guild_name", "Test");
  8452. packet2->setDataByName("guild_motd", "Test MOTD");
  8453. packet2->setDataByName("guild_id", 1234);
  8454. packet2->setDataByName("guild_level", 1);
  8455. packet2->setDataByName("unknown", 2);
  8456. packet2->setDataByName("unknown2", 3);
  8457. packet2->setDataByName("exp_current", 1);
  8458. packet2->setDataByName("exp_to_next_level", 4);
  8459. EQ2Packet* outapp = packet2->serialize();
  8460. DumpPacket(outapp);
  8461. client->QueuePacket(outapp);
  8462. safe_delete(packet2);
  8463. }
  8464. }
  8465. else if (atoi(sep->arg[0]) == 3) {
  8466. PacketStruct* packet2 = configReader.getStruct("WS_JoinGuildNotify", client->GetVersion());
  8467. if (packet2) {
  8468. packet2->setDataByName("guild_id", 1234);
  8469. packet2->setDataByName("character_id", 1);
  8470. packet2->setDataByName("account_id", 2);
  8471. packet2->setDataByName("guild_level", 1);
  8472. packet2->setDataByName("name", "Test");
  8473. packet2->setDataByName("unknown2", 0);
  8474. packet2->setDataByName("unknown3", 1);
  8475. packet2->setDataByName("adventure_class", 6);
  8476. packet2->setDataByName("adventure_level", 7);
  8477. packet2->setDataByName("tradeskill_class", 4);
  8478. packet2->setDataByName("tradeskill_level", 5);
  8479. packet2->setDataByName("rank", 0);
  8480. packet2->setDataByName("member_flags", 2);
  8481. packet2->setDataByName("join_date", 1591112273);
  8482. packet2->setDataByName("guild_status", 2);
  8483. packet2->setDataByName("last_login", 1591132273);
  8484. packet2->setDataByName("recruiter_id", 1);
  8485. packet2->setDataByName("points", 2345);
  8486. packet2->setDataByName("note", "note");
  8487. packet2->setMediumStringByName("officer_note", "O note");
  8488. packet2->setMediumStringByName("zone", "Blah");
  8489. EQ2Packet* outapp = packet2->serialize();
  8490. DumpPacket(outapp);
  8491. client->QueuePacket(outapp);
  8492. safe_delete(packet2);
  8493. }
  8494. }
  8495. else if (atoi(sep->arg[0]) == 5) {
  8496. int16 offset = atoi(sep->arg[1]);
  8497. int32 value1 = atol(sep->arg[2]);
  8498. EQ2Packet* outapp = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion(), offset, value1);
  8499. client->QueuePacket(outapp);
  8500. }
  8501. else if (atoi(sep->arg[0]) == 6) {
  8502. Spawn* spawn = client->GetPlayer()->GetTarget();
  8503. if (!spawn)
  8504. spawn = client->GetPlayer();
  8505. else if (spawn->IsEntity())
  8506. ((Entity*)spawn)->SetSpeed(atof(sep->arg[4]));
  8507. spawn->RunToLocation(atof(sep->arg[1]), atof(sep->arg[2]), atof(sep->arg[3]));
  8508. }
  8509. else if (atoi(sep->arg[0]) == 7) {
  8510. int32 id = 0;
  8511. Spawn* spawn = client->GetCurrentZone()->GetSpawn(7720001);
  8512. if (spawn) {
  8513. spawn->SetX(client->GetPlayer()->GetX() + .5, false);
  8514. spawn->SetY(client->GetPlayer()->GetY(), false);
  8515. spawn->SetZ(client->GetPlayer()->GetZ() + .5, false);
  8516. float heading = client->GetPlayer()->GetHeading() + 180;
  8517. if (heading > 360)
  8518. heading -= 360;
  8519. spawn->SetLevel(5);
  8520. spawn->SetAdventureClass(4);
  8521. spawn->SetHeading(heading, false);
  8522. spawn->SetSpawnOrigX(spawn->GetX());
  8523. spawn->SetSpawnOrigY(spawn->GetY());
  8524. spawn->SetSpawnOrigZ(spawn->GetZ());
  8525. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  8526. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  8527. spawn->appearance.targetable = 1;
  8528. if (spawn->IsNPC() && spawn->GetTotalHP() == 0) {
  8529. spawn->SetTotalHP(spawn->GetLevel() * 15);
  8530. spawn->SetHP(spawn->GetTotalHP());
  8531. }
  8532. if (spawn->GetTotalPower() == 0) {
  8533. spawn->SetTotalPower(spawn->GetLevel() * 15);
  8534. spawn->SetPower(spawn->GetTotalPower());
  8535. }
  8536. int16 offset = atoi(sep->arg[1]);
  8537. int32 value1 = atol(sep->arg[2]);
  8538. sprintf(spawn->appearance.name, "Offset %i", offset);
  8539. EQ2Packet* ret = spawn->spawn_serialize(client->GetPlayer(), client->GetVersion(), offset, value1);
  8540. DumpPacket(ret);
  8541. client->QueuePacket(ret);
  8542. }
  8543. }
  8544. else if (atoi(sep->arg[0]) == 8) {
  8545. int32 id = atoi(sep->arg[1]);
  8546. Spawn* spawn = client->GetCurrentZone()->GetSpawn(id);
  8547. if (spawn) {
  8548. spawn->SetX(client->GetPlayer()->GetX() + .5, false);
  8549. spawn->SetY(client->GetPlayer()->GetY(), false);
  8550. spawn->SetZ(client->GetPlayer()->GetZ() + .5, false);
  8551. float heading = client->GetPlayer()->GetHeading() + 180;
  8552. if (heading > 360)
  8553. heading -= 360;
  8554. spawn->SetLevel(5);
  8555. spawn->SetAdventureClass(4);
  8556. spawn->SetHeading(heading, false);
  8557. spawn->SetSpawnOrigX(spawn->GetX());
  8558. spawn->SetSpawnOrigY(spawn->GetY());
  8559. spawn->SetSpawnOrigZ(spawn->GetZ());
  8560. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  8561. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  8562. spawn->appearance.targetable = 1;
  8563. if (spawn->IsNPC() && spawn->GetTotalHP() == 0) {
  8564. spawn->SetTotalHP(spawn->GetLevel() * 15);
  8565. spawn->SetHP(spawn->GetTotalHP());
  8566. }
  8567. if (spawn->GetTotalPower() == 0) {
  8568. spawn->SetTotalPower(spawn->GetLevel() * 15);
  8569. spawn->SetPower(spawn->GetTotalPower());
  8570. }
  8571. int16 offset = atoi(sep->arg[2]);
  8572. int16 offset2 = atoi(sep->arg[3]);
  8573. int32 value1 = atol(sep->arg[4]);
  8574. int16 offset3 = 0;
  8575. int16 offset4 = 0;
  8576. int32 value2 = 0;
  8577. if (sep->IsSet(7)) {
  8578. offset3 = atoi(sep->arg[5]);
  8579. offset4 = atoi(sep->arg[6]);
  8580. value2 = atol(sep->arg[7]);
  8581. }
  8582. sprintf(spawn->appearance.name, "Offset %i to %i", offset, offset2);
  8583. spawn->AddPrimaryEntityCommand("attack", 10000, "attack","", 0, 0);
  8584. EQ2Packet* ret = spawn->spawn_serialize(client->GetPlayer(), client->GetVersion(), offset, value1, offset2, offset3, offset4, value2);
  8585. DumpPacket(ret);
  8586. client->QueuePacket(ret);
  8587. }
  8588. }
  8589. else if (atoi(sep->arg[0]) == 9) {
  8590. PacketStruct* packet2 = configReader.getStruct("WS_DeathWindow", client->GetVersion());
  8591. if (packet2) {
  8592. packet2->setArrayLengthByName("location_count", 1);
  8593. packet2->setArrayDataByName("location_ida", 1234);
  8594. packet2->setArrayDataByName("unknown2a", 3);
  8595. packet2->setArrayDataByName("zone_name", "Queen's Colony");
  8596. packet2->setArrayDataByName("location_name", "Myrrin's Tower");
  8597. packet2->setArrayDataByName("distance", 134);
  8598. EQ2Packet* app = packet2->serialize();
  8599. if (sep->IsSet(2)) {
  8600. int8 offset = atoi(sep->arg[1]);
  8601. uchar* ptr2 = app->pBuffer;
  8602. ptr2 += offset;
  8603. if (sep->IsNumber(2)) {
  8604. int32 value1 = atol(sep->arg[2]);
  8605. if (value1 > 0xFFFF)
  8606. memcpy(ptr2, (uchar*)&value1, 4);
  8607. else if (value1 > 0xFF)
  8608. memcpy(ptr2, (uchar*)&value1, 2);
  8609. else
  8610. memcpy(ptr2, (uchar*)&value1, 1);
  8611. }
  8612. else {
  8613. int8 len = strlen(sep->arg[2]);
  8614. memcpy(ptr2, (uchar*)&len, 1);
  8615. ptr2 += 1;
  8616. memcpy(ptr2, sep->arg[2], len);
  8617. }
  8618. }
  8619. DumpPacket(app);
  8620. client->QueuePacket(app);
  8621. safe_delete(packet2);
  8622. }
  8623. }
  8624. else if (atoi(sep->arg[0]) == 10) {
  8625. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalUpdate", client->GetVersion());
  8626. if (packet2) {
  8627. packet2->setArrayLengthByName("num_quests", 1);
  8628. packet2->setArrayDataByName("active", 1);
  8629. packet2->setArrayDataByName("name", "Tasks aboard the Far Journey");
  8630. packet2->setArrayDataByName("quest_type", "Hallmark");
  8631. packet2->setArrayDataByName("quest_zone", "Hallmark");
  8632. packet2->setArrayDataByName("journal_updated", 1);
  8633. packet2->setArrayDataByName("quest_id", 524);
  8634. packet2->setArrayDataByName("day", 19);
  8635. packet2->setArrayDataByName("month", 6);
  8636. packet2->setArrayDataByName("year", 20);
  8637. packet2->setArrayDataByName("level", 2);
  8638. packet2->setArrayDataByName("encounter_level", 4);
  8639. packet2->setArrayDataByName("difficulty", 3);
  8640. packet2->setArrayDataByName("visible", 1);
  8641. packet2->setDataByName("visible_quest_id", 524);
  8642. packet2->setDataByName("player_crc", 2900677088);
  8643. packet2->setDataByName("player_name", "LethalEncounter");
  8644. EQ2Packet* app = packet2->serialize();
  8645. if (sep->IsSet(2)) {
  8646. int8 offset = atoi(sep->arg[1]);
  8647. uchar* ptr2 = app->pBuffer;
  8648. ptr2 += offset;
  8649. if (sep->IsNumber(2)) {
  8650. int32 value1 = atol(sep->arg[2]);
  8651. if (value1 > 0xFFFF)
  8652. memcpy(ptr2, (uchar*)&value1, 4);
  8653. else if (value1 > 0xFF)
  8654. memcpy(ptr2, (uchar*)&value1, 2);
  8655. else
  8656. memcpy(ptr2, (uchar*)&value1, 1);
  8657. }
  8658. else {
  8659. int8 len = strlen(sep->arg[2]);
  8660. memcpy(ptr2, (uchar*)&len, 1);
  8661. ptr2 += 1;
  8662. memcpy(ptr2, sep->arg[2], len);
  8663. }
  8664. }
  8665. DumpPacket(app);
  8666. client->QueuePacket(app);
  8667. safe_delete(packet2);
  8668. }
  8669. }
  8670. else if (atoi(sep->arg[0]) == 11) {
  8671. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalReply", client->GetVersion());
  8672. if (packet2) {
  8673. packet2->setDataByName("quest_id", 524);
  8674. packet2->setDataByName("player_crc", 2900677088);
  8675. packet2->setDataByName("name", "Tasks aboard the Far Journey");
  8676. packet2->setDataByName("description", "I completed all the tasks assigned to me by Captain Varlos aboard the Far Journey");
  8677. packet2->setDataByName("type", "Hallmark");
  8678. packet2->setDataByName("complete_header", "To complete this quest, I must do the following tasks:");
  8679. packet2->setDataByName("day", 19);
  8680. packet2->setDataByName("month", 6);
  8681. packet2->setDataByName("year", 20);
  8682. packet2->setDataByName("level", 1);
  8683. packet2->setDataByName("encounter_level", 1);
  8684. packet2->setDataByName("difficulty", 1);
  8685. packet2->setDataByName("time_obtained", Timer::GetUnixTimeStamp());
  8686. //packet2->setDataByName("timer_start", Timer::GetUnixTimeStamp());
  8687. //packet2->setDataByName("timer_duration", 300);
  8688. //packet2->setDataByName("timer_running", 1);
  8689. packet2->setArrayLengthByName("task_groups_completed", 9);
  8690. packet2->setArrayLengthByName("num_task_groups", 10);
  8691. packet2->setArrayDataByName("task_group", "I spoke to Waulon as Captain Varlos had asked of me.");
  8692. packet2->setArrayDataByName("task_group", "I found Waulon's hat in one of the boxes.", 1);
  8693. packet2->setArrayDataByName("task_group", "I returned Waulon's hat.", 2);
  8694. packet2->setArrayDataByName("task_group", "I have spoken to Ingrid.", 3);
  8695. packet2->setArrayDataByName("task_group", "I purchased a Shard of Luclin.", 4);
  8696. packet2->setArrayDataByName("task_group", "I gave the Shard of Luclin to Ingrid.", 5);
  8697. packet2->setArrayDataByName("task_group", "I have spoken to Captain Varlos.", 6);
  8698. packet2->setArrayDataByName("task_group", "I killed the rats that Captain Varlos requested.", 7);
  8699. packet2->setArrayDataByName("task_group", "Captain Varlos has ordered you to kill the escaped goblin.", 8);
  8700. packet2->setArrayDataByName("task_group", "I killed the escaped goblin.", 9);
  8701. /*packet2->setSubArrayLengthByName("num_tasks", 1);
  8702. packet2->setSubArrayDataByName("task", "I need to talk to Garven Tralk");
  8703. packet2->setSubArrayLengthByName("num_updates", 1);
  8704. packet2->setSubArrayDataByName("update_currentval", 0);
  8705. packet2->setSubArrayDataByName("update_maxval", 1);
  8706. packet2->setSubArrayDataByName("icon", 11);
  8707. */
  8708. packet2->setArrayDataByName("waypoint", 0xFFFFFFFF);
  8709. packet2->setDataByName("journal_updated", 1);
  8710. packet2->setDataByName("bullets", 1);
  8711. EQ2Packet* app = packet2->serialize();
  8712. if (sep->IsSet(2)) {
  8713. int16 offset = atoi(sep->arg[1]);
  8714. uchar* ptr2 = app->pBuffer;
  8715. ptr2 += offset;
  8716. if (sep->IsNumber(2)) {
  8717. int32 value1 = atol(sep->arg[2]);
  8718. if (value1 > 0xFFFF)
  8719. memcpy(ptr2, (uchar*)&value1, 4);
  8720. else if (value1 > 0xFF)
  8721. memcpy(ptr2, (uchar*)&value1, 2);
  8722. else
  8723. memcpy(ptr2, (uchar*)&value1, 1);
  8724. }
  8725. else {
  8726. int16 len = strlen(sep->arg[2]);
  8727. memcpy(ptr2, (uchar*)&len, 2);
  8728. ptr2 += 2;
  8729. memcpy(ptr2, sep->arg[2], len);
  8730. }
  8731. }
  8732. DumpPacket(app);
  8733. client->QueuePacket(app);
  8734. safe_delete(packet2);
  8735. }
  8736. }
  8737. else if (atoi(sep->arg[0]) == 12) {
  8738. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalReply", client->GetVersion());
  8739. if (packet2) {
  8740. packet2->setDataByName("quest_id", 524);
  8741. packet2->setDataByName("player_crc", 2900677088);
  8742. packet2->setDataByName("name", "Archetype Selection");
  8743. packet2->setDataByName("description", "I have reported my profession to Garven Tralk.");
  8744. packet2->setDataByName("type", "Hallmark");
  8745. packet2->setDataByName("complete_header", "To complete this quest, I must do the following tasks:");
  8746. packet2->setDataByName("day", 19);
  8747. packet2->setDataByName("month", 6);
  8748. packet2->setDataByName("year", 20);
  8749. packet2->setDataByName("level", 2);
  8750. packet2->setDataByName("encounter_level", 4);
  8751. packet2->setDataByName("difficulty", 3);
  8752. packet2->setDataByName("time_obtained", Timer::GetUnixTimeStamp());
  8753. packet2->setDataByName("timer_start", Timer::GetUnixTimeStamp());
  8754. packet2->setDataByName("timer_duration", 300);
  8755. packet2->setDataByName("timer_running", 1);
  8756. packet2->setArrayLengthByName("task_groups_completed", 0);
  8757. packet2->setArrayLengthByName("num_task_groups", 1);
  8758. packet2->setArrayDataByName("task_group", "I need to talk to Garven Tralk");
  8759. packet2->setSubArrayLengthByName("num_tasks", 1);
  8760. packet2->setSubArrayDataByName("task", "I need to talk to Garven Tralk");
  8761. packet2->setSubArrayLengthByName("num_updates", 1);
  8762. packet2->setSubArrayDataByName("update_currentval", 0);
  8763. packet2->setSubArrayDataByName("update_maxval", 1);
  8764. packet2->setSubArrayDataByName("icon", 11);
  8765. packet2->setArrayDataByName("waypoint", 0xFFFFFFFF);
  8766. packet2->setDataByName("journal_updated", 1);
  8767. packet2->setSubstructDataByName("reward_data", "unknown1", 255);
  8768. packet2->setSubstructDataByName("reward_data", "reward", "Quest Reward!");
  8769. packet2->setSubstructDataByName("reward_data", "unknown2", 0x3f);
  8770. packet2->setSubstructDataByName("reward_data", "coin", 150);
  8771. packet2->setSubstructDataByName("reward_data", "status_points", 5);
  8772. packet2->setSubstructDataByName("reward_data", "exp_bonus", 10);
  8773. packet2->setSubstructArrayLengthByName("reward_data", "num_rewards", 1);
  8774. packet2->setSubstructArrayDataByName("reward_data", "reward_id", 123);
  8775. Item* item = master_item_list.GetItem(152755);
  8776. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8777. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  8778. /*packet2->setSubstructDataByName("item", "unique_id", 567);
  8779. packet2->setSubstructDataByName("item", "broker_item_id", 0xFFFFFFFFFFFFFFFF);
  8780. packet2->setSubstructDataByName("item", "icon", 0xe7);
  8781. packet2->setSubstructDataByName("item", "tier", 4);
  8782. packet2->setSubstructDataByName("item", "flags", 0x60);
  8783. packet2->setSubstructArrayLengthByName("item", "stat_count", 1);
  8784. packet2->setSubstructDataByName("item", "stat_type", 1);
  8785. packet2->setSubstructDataByName("item", "stat_subtype", 2);
  8786. packet2->setSubstructDataByName("item", "value", 3);
  8787. packet2->setSubstructDataByName("item", "condition", 100);
  8788. packet2->setSubstructDataByName("item", "weight", 1);
  8789. packet2->setSubstructDataByName("item", "skill_req1", 0xacafa99e);
  8790. packet2->setSubstructDataByName("item", "skill_req2", 0xacafa99e);
  8791. packet2->setSubstructDataByName("item", "skill_min", 1);
  8792. packet2->setSubstructArrayLengthByName("item", "class_count", 3);
  8793. packet2->setSubstructDataByName("item", "adventure_class", 1);
  8794. packet2->setSubstructDataByName("item", "adventure_class", 11, 0, 1);
  8795. packet2->setSubstructDataByName("item", "adventure_class", 0x1f, 0, 2);
  8796. packet2->setSubstructDataByName("item", "tradeskill_class", 255);
  8797. packet2->setSubstructDataByName("item", "tradeskill_class", 255, 0, 1);
  8798. packet2->setSubstructDataByName("item", "tradeskill_class", 255, 0, 2);
  8799. packet2->setSubstructDataByName("item", "level", 0x1e);
  8800. packet2->setSubstructDataByName("item", "level", 100, 0, 1);
  8801. packet2->setSubstructDataByName("item", "level", 100, 0, 2);
  8802. packet2->setSubstructDataByName("item_footer", "name", "Footman Gloves");*/
  8803. //packet2->PrintPacket();
  8804. EQ2Packet* app = packet2->serialize();
  8805. if (sep->IsSet(2)) {
  8806. int16 offset = atoi(sep->arg[1]);
  8807. uchar* ptr2 = app->pBuffer;
  8808. ptr2 += offset;
  8809. if (sep->IsNumber(2)) {
  8810. int32 value1 = atol(sep->arg[2]);
  8811. if (value1 > 0xFFFF)
  8812. memcpy(ptr2, (uchar*)&value1, 4);
  8813. else if (value1 > 0xFF)
  8814. memcpy(ptr2, (uchar*)&value1, 2);
  8815. else
  8816. memcpy(ptr2, (uchar*)&value1, 1);
  8817. }
  8818. else {
  8819. int16 len = strlen(sep->arg[2]);
  8820. memcpy(ptr2, (uchar*)&len, 2);
  8821. ptr2 += 2;
  8822. memcpy(ptr2, sep->arg[2], len);
  8823. }
  8824. }
  8825. DumpPacket(app);
  8826. client->QueuePacket(app);
  8827. safe_delete(packet2);
  8828. }
  8829. }
  8830. else if (atoi(sep->arg[0]) == 13) {
  8831. PacketStruct* packet2 = configReader.getStruct("WS_OnScreenMsg", client->GetVersion());
  8832. if (packet2 && sep->IsSet(7)) {
  8833. packet2->setDataByName("unknown", atoi(sep->arg[1]));
  8834. char blah[128];
  8835. sprintf(blah, "\\#6EFF6EYou get better at \12\\#C8FFC8%s\\#6EFF6E! (7/15)", sep->arg[2]);
  8836. packet2->setDataByName("text", blah);
  8837. packet2->setDataByName("message_type", sep->arg[3]);
  8838. packet2->setDataByName("size", atof(sep->arg[4]));
  8839. packet2->setDataByName("red", atoi(sep->arg[5]));
  8840. packet2->setDataByName("green", atoi(sep->arg[6]));
  8841. packet2->setDataByName("blue", atoi(sep->arg[7]));
  8842. EQ2Packet* app = packet2->serialize();
  8843. DumpPacket(app);
  8844. client->QueuePacket(app);
  8845. safe_delete(packet2);
  8846. }
  8847. }
  8848. else if (atoi(sep->arg[0]) == 14) {
  8849. PacketStruct* packet2 = configReader.getStruct("WS_InstructionWindow", client->GetVersion());
  8850. if (packet2 && sep->IsSet(3)) {
  8851. packet2->setDataByName("open_seconds_min", atof(sep->arg[1]));
  8852. packet2->setDataByName("open_seconds_max", atof(sep->arg[2]));
  8853. packet2->setDataByName("voice_sync", atoi(sep->arg[3]));
  8854. 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.");
  8855. packet2->setDataByName("voice", "voiceover/english/narrator/boat_06p_tutorial02/narrator_001_63779ca0.mp3");
  8856. packet2->setArrayLengthByName("num_goals", 1);
  8857. //packet2->setArrayDataByName("goal_text", )
  8858. packet2->setSubArrayLengthByName("num_tasks", 1);
  8859. packet2->setSubArrayDataByName("task_text", "continue");
  8860. packet2->setDataByName("complete_sound", "click");
  8861. packet2->setDataByName("signal", "introduction");
  8862. packet2->setDataByName("voice_key1", 0xcda65173);
  8863. packet2->setDataByName("voice_key2", 0x984bfc6d);
  8864. EQ2Packet* app = packet2->serialize();
  8865. DumpPacket(app);
  8866. client->QueuePacket(app);
  8867. safe_delete(packet2);
  8868. packet2 = configReader.getStruct("WS_ShowWindow", client->GetVersion());
  8869. packet2->setDataByName("window", "MainHUD.StartMenu");
  8870. packet2->setDataByName("show", 1);
  8871. app = packet2->serialize();
  8872. DumpPacket(app);
  8873. client->QueuePacket(app);
  8874. safe_delete(packet2);
  8875. packet2 = configReader.getStruct("WS_FlashWindow", client->GetVersion());
  8876. packet2->setDataByName("window", "MainHUD.StartMenu.help");
  8877. packet2->setDataByName("flash_seconds", 10);
  8878. app = packet2->serialize();
  8879. DumpPacket(app);
  8880. client->QueuePacket(app);
  8881. safe_delete(packet2);
  8882. }
  8883. }
  8884. else if (atoi(sep->arg[0]) == 15) {
  8885. PacketStruct* packet2 = configReader.getStruct("WS_UpdateLoot", client->GetVersion());
  8886. if (packet2) {
  8887. packet2->setArrayLengthByName("loot_count", 1);
  8888. packet2->setArrayDataByName("name", "Test");
  8889. packet2->setArrayDataByName("item_id", 1234);
  8890. packet2->setArrayDataByName("count", 1);
  8891. packet2->setArrayDataByName("icon", 258);
  8892. packet2->setArrayDataByName("ability_id", 0xFFFFFFFF);
  8893. Spawn* spawn = client->GetPlayer()->GetTarget();
  8894. if (spawn)
  8895. packet2->setDataByName("object_id", client->GetPlayer()->GetIDWithPlayerSpawn(spawn));
  8896. packet2->setDataByName("unknown3", 1);
  8897. packet2->setDataByName("unknown4", 1);
  8898. packet2->setDataByName("unknown5", 60);
  8899. EQ2Packet* app = packet2->serialize();
  8900. DumpPacket(app);
  8901. client->QueuePacket(app);
  8902. safe_delete(packet2);
  8903. }
  8904. }
  8905. else if (atoi(sep->arg[0]) == 16 && sep->IsNumber(1)) {
  8906. char blah[32];
  8907. sprintf(blah, "Testing: %i", atoi(sep->arg[1]));
  8908. client->SimpleMessage(atoi(sep->arg[1]), blah);
  8909. }
  8910. else if (atoi(sep->arg[0]) == 17 && sep->IsNumber(2)) {
  8911. if (sep->IsSet(2)) {
  8912. int16 offset = atoi(sep->arg[1]);
  8913. if (sep->IsNumber(2)) {
  8914. int32 value1 = atol(sep->arg[2]);
  8915. client->QueuePacket(client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion(), offset, value1));
  8916. cout << "Sent" << endl;
  8917. }
  8918. }
  8919. }
  8920. else if (atoi(sep->arg[0]) == 18) {
  8921. PacketStruct* packet2 = configReader.getStruct("WS_QuestRewardPackMsg", client->GetVersion());
  8922. if (packet2) {
  8923. packet2->setSubstructDataByName("reward_data", "unknown1", 255);
  8924. packet2->setSubstructDataByName("reward_data", "reward", "Quest Reward!");
  8925. packet2->setSubstructDataByName("reward_data", "coin", 150);
  8926. packet2->setSubstructDataByName("reward_data", "status_points", 5);
  8927. packet2->setSubstructDataByName("reward_data", "exp_bonus", 10);
  8928. packet2->setSubstructArrayLengthByName("reward_data", "num_rewards", 4);
  8929. Item* item = new Item(master_item_list.GetItem(36212));
  8930. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8931. item->stack_count = 20;
  8932. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  8933. safe_delete(item);
  8934. item = new Item(master_item_list.GetItem(36685));
  8935. item->stack_count = 20;
  8936. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8937. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 1, 0, -1);
  8938. safe_delete(item);
  8939. item = master_item_list.GetItem(1414);
  8940. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8941. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 2, 0, -1);
  8942. item = master_item_list.GetItem(75057);
  8943. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8944. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 3, 0, -1);
  8945. EQ2Packet* app = packet2->serialize();
  8946. if (sep->IsSet(2)) {
  8947. int16 offset = atoi(sep->arg[1]);
  8948. uchar* ptr2 = app->pBuffer;
  8949. ptr2 += offset;
  8950. if (sep->IsNumber(2)) {
  8951. int32 value1 = atol(sep->arg[2]);
  8952. if (value1 > 0xFFFF)
  8953. memcpy(ptr2, (uchar*)&value1, 4);
  8954. else if (value1 > 0xFF)
  8955. memcpy(ptr2, (uchar*)&value1, 2);
  8956. else
  8957. memcpy(ptr2, (uchar*)&value1, 1);
  8958. }
  8959. else {
  8960. int16 len = strlen(sep->arg[2]);
  8961. memcpy(ptr2, (uchar*)&len, 2);
  8962. ptr2 += 2;
  8963. memcpy(ptr2, sep->arg[2], len);
  8964. }
  8965. }
  8966. DumpPacket(app);
  8967. client->QueuePacket(app);
  8968. safe_delete(packet2);
  8969. }
  8970. }
  8971. else if (atoi(sep->arg[0]) == 19) {
  8972. PacketStruct* packet2 = configReader.getStruct("WS_UpdateLoot", client->GetVersion());
  8973. Spawn* spawn = client->GetPlayer()->GetTarget();
  8974. if (packet2 && spawn) {
  8975. Item* item = master_item_list.GetItem(130053);
  8976. packet2->setArrayLengthByName("loot_count", 1);
  8977. packet2->setArrayDataByName("loot_id", item->details.item_id);
  8978. packet2->setArrayDataByName("unknown2", 1);
  8979. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, 2, true);
  8980. packet2->setDataByName("display", 1);
  8981. packet2->setDataByName("unknown2b", 1);
  8982. packet2->setDataByName("unknown3", 0x3c);
  8983. packet2->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(spawn));
  8984. packet2->PrintPacket();
  8985. EQ2Packet* app = packet2->serialize();
  8986. if (sep->IsSet(2)) {
  8987. int16 offset = atoi(sep->arg[1]);
  8988. int16 offset2 = 0;
  8989. int32 value1 = 0;
  8990. if (sep->IsSet(3)) {
  8991. offset2 = atoi(sep->arg[2]);
  8992. value1 = atol(sep->arg[3]);
  8993. }
  8994. else
  8995. value1 = atol(sep->arg[2]);
  8996. int16 offset3 = 0;
  8997. int16 offset4 = 0;
  8998. int32 value2 = 0;
  8999. if (sep->IsSet(6)) {
  9000. offset3 = atoi(sep->arg[4]);
  9001. offset4 = atoi(sep->arg[5]);
  9002. value2 = atol(sep->arg[6]);
  9003. }
  9004. offset--;
  9005. if (offset2 > 0 && offset2 >= offset) {
  9006. offset2--;
  9007. uchar* ptr2 = app->pBuffer;
  9008. ptr2 += offset;
  9009. for (int i = offset; i <= offset2; i++) {
  9010. if (value1 > 0xFFFF) {
  9011. memcpy(ptr2, (uchar*)&value1, 4);
  9012. i += 3;
  9013. ptr2 += 3;
  9014. }
  9015. else if (value1 > 0xFF) {
  9016. memcpy(ptr2, (uchar*)&value1, 2);
  9017. i++;
  9018. ptr2++;
  9019. }
  9020. else
  9021. memcpy(ptr2, (uchar*)&value1, 1);
  9022. ptr2++;
  9023. }
  9024. }
  9025. if (offset4 > 0 && offset4 >= offset3) {
  9026. offset3--;
  9027. offset4--;
  9028. uchar* ptr2 = app->pBuffer;
  9029. ptr2 += offset3;
  9030. for (int i = offset3; i <= offset4; i++) {
  9031. if (value2 > 0xFFFF) {
  9032. memcpy(ptr2, (uchar*)&value2, 4);
  9033. i += 3;
  9034. ptr2 += 3;
  9035. }
  9036. else if (value2 > 0xFF) {
  9037. memcpy(ptr2, (uchar*)&value2, 2);
  9038. i++;
  9039. ptr2++;
  9040. }
  9041. else
  9042. memcpy(ptr2, (uchar*)&value2, 1);
  9043. ptr2++;
  9044. }
  9045. }
  9046. }
  9047. DumpPacket(app);
  9048. client->QueuePacket(app);
  9049. safe_delete(packet2);
  9050. }
  9051. }
  9052. else if (atoi(sep->arg[0]) == 21) {
  9053. PacketStruct* packet2 = configReader.getStruct("WS_OfferQuest", client->GetVersion());
  9054. if (packet2) {
  9055. packet2->setDataByName("unknown0", 255);
  9056. packet2->setDataByName("reward", "New Quest");
  9057. packet2->setDataByName("title", "Title");
  9058. packet2->setDataByName("description", "description");
  9059. packet2->setDataByName("quest_difficulty", 3);
  9060. packet2->setDataByName("unknown1", 5);
  9061. packet2->setDataByName("level", 3);
  9062. packet2->setDataByName("coin", 150);
  9063. packet2->setDataByName("status_points", 5);
  9064. packet2->setDataByName("exp_bonus", 10);
  9065. packet2->setArrayLengthByName("num_rewards", 1);
  9066. Item* item = new Item(master_item_list.GetItem(36212));
  9067. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9068. item->stack_count = 20;
  9069. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  9070. safe_delete(item);
  9071. char accept[35] = { 0 };
  9072. char decline[35] = { 0 };
  9073. sprintf(accept, "q_accept_pending_quest %u", 0);
  9074. sprintf(decline, "q_deny_pending_quest %u", 0);
  9075. packet2->setDataByName("accept_command", accept);
  9076. packet2->setDataByName("decline_command", decline);
  9077. EQ2Packet* app = packet2->serialize();
  9078. if (sep->IsSet(2)) {
  9079. int16 offset = atoi(sep->arg[1]);
  9080. uchar* ptr2 = app->pBuffer;
  9081. ptr2 += offset;
  9082. if (sep->IsNumber(2)) {
  9083. int32 value1 = atol(sep->arg[2]);
  9084. if (value1 > 0xFFFF)
  9085. memcpy(ptr2, (uchar*)&value1, 4);
  9086. else if (value1 > 0xFF)
  9087. memcpy(ptr2, (uchar*)&value1, 2);
  9088. else
  9089. memcpy(ptr2, (uchar*)&value1, 1);
  9090. }
  9091. DumpPacket(app);
  9092. client->QueuePacket(app);
  9093. safe_delete(packet2);
  9094. }
  9095. }
  9096. }
  9097. else if (atoi(sep->arg[0]) == 22) { //same as 21, but 8bit string
  9098. PacketStruct* packet2 = configReader.getStruct("WS_OfferQuest", client->GetVersion());
  9099. if (packet2) {
  9100. packet2->setDataByName("unknown0", 255);
  9101. packet2->setDataByName("reward", "New Quest");
  9102. packet2->setDataByName("title", "Title");
  9103. packet2->setDataByName("description", "description");
  9104. packet2->setDataByName("quest_difficulty", 3);
  9105. packet2->setDataByName("unknown1", 5);
  9106. packet2->setDataByName("level", 3);
  9107. packet2->setDataByName("coin", 150);
  9108. packet2->setDataByName("status_points", 5);
  9109. packet2->setDataByName("exp_bonus", 10);
  9110. packet2->setArrayLengthByName("num_rewards", 1);
  9111. Item* item = new Item(master_item_list.GetItem(36212));
  9112. packet2->setArrayDataByName("reward_id", item->details.item_id);
  9113. item->stack_count = 20;
  9114. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  9115. safe_delete(item);
  9116. char accept[35] = { 0 };
  9117. char decline[35] = { 0 };
  9118. sprintf(accept, "q_accept_pending_quest %u", 0);
  9119. sprintf(decline, "q_deny_pending_quest %u", 0);
  9120. packet2->setDataByName("accept_command", accept);
  9121. packet2->setDataByName("decline_command", decline);
  9122. EQ2Packet* app = packet2->serialize();
  9123. if (sep->IsSet(2)) {
  9124. int16 offset = atoi(sep->arg[1]);
  9125. uchar* ptr2 = app->pBuffer;
  9126. ptr2 += offset;
  9127. if (sep->IsNumber(2)) {
  9128. int32 value1 = atol(sep->arg[2]);
  9129. if (value1 > 0xFFFF)
  9130. memcpy(ptr2, (uchar*)&value1, 4);
  9131. else if (value1 > 0xFF)
  9132. memcpy(ptr2, (uchar*)&value1, 2);
  9133. else
  9134. memcpy(ptr2, (uchar*)&value1, 1);
  9135. }
  9136. else {
  9137. int8 len = strlen(sep->arg[2]);
  9138. memcpy(ptr2, (uchar*)&len, 1);
  9139. ptr2 += 1;
  9140. memcpy(ptr2, sep->arg[2], len);
  9141. }
  9142. }
  9143. DumpPacket(app);
  9144. client->QueuePacket(app);
  9145. safe_delete(packet2);
  9146. }
  9147. }
  9148. else if (atoi(sep->arg[0]) == 23) {
  9149. if (client->GetPlayer()->GetTarget()) {
  9150. PacketStruct* packet2 = configReader.getStruct("WS_UpdateMerchant", client->GetVersion());
  9151. if (packet2) {
  9152. Spawn* target = client->GetPlayer()->GetTarget();
  9153. packet2->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(target));
  9154. Item* item = new Item(master_item_list.GetItem(12565));
  9155. int8 i = 0;
  9156. packet2->setArrayLengthByName("num_items", 1);
  9157. packet2->setArrayDataByName("item_name", item->name.c_str(), i);
  9158. packet2->setArrayDataByName("item_id", item->details.item_id, i);
  9159. packet2->setArrayDataByName("stack_size", item->stack_count, i);
  9160. packet2->setArrayDataByName("icon", item->details.icon, i);
  9161. int8 tmp_level = 0;
  9162. if (item->generic_info.adventure_default_level > 0)
  9163. tmp_level = item->generic_info.adventure_default_level;
  9164. else
  9165. tmp_level = item->generic_info.tradeskill_default_level;
  9166. packet2->setArrayDataByName("level", tmp_level, i);
  9167. packet2->setArrayDataByName("tier", item->details.tier, i);
  9168. packet2->setArrayDataByName("item_id2", item->details.item_id, i);
  9169. int8 item_difficulty = client->GetPlayer()->GetArrowColor(tmp_level);
  9170. if (item_difficulty != ARROW_COLOR_WHITE && item_difficulty != ARROW_COLOR_RED && item_difficulty != ARROW_COLOR_GRAY)
  9171. item_difficulty = ARROW_COLOR_WHITE;
  9172. item_difficulty -= 6;
  9173. if (item_difficulty < 0)
  9174. item_difficulty *= -1;
  9175. packet2->setArrayDataByName("item_difficulty", item_difficulty, i);
  9176. packet2->setArrayDataByName("quantity", 2, i);
  9177. packet2->setArrayDataByName("unknown5", 255, i);
  9178. packet2->setArrayDataByName("stack_size2", item->stack_count, i);
  9179. packet2->setArrayDataByName("description", item->description.c_str(), i);
  9180. packet2->setDataByName("type", 2);
  9181. EQ2Packet* app = packet2->serialize();
  9182. if (sep->IsSet(2)) {
  9183. int16 offset = atoi(sep->arg[1]);
  9184. uchar* ptr2 = app->pBuffer;
  9185. ptr2 += offset;
  9186. if (sep->IsNumber(2)) {
  9187. int32 value1 = atol(sep->arg[2]);
  9188. if (value1 > 0xFFFF)
  9189. memcpy(ptr2, (uchar*)&value1, 4);
  9190. else if (value1 > 0xFF)
  9191. memcpy(ptr2, (uchar*)&value1, 2);
  9192. else
  9193. memcpy(ptr2, (uchar*)&value1, 1);
  9194. }
  9195. else {
  9196. int8 len = strlen(sep->arg[2]);
  9197. memcpy(ptr2, (uchar*)&len, 1);
  9198. ptr2 += 1;
  9199. memcpy(ptr2, sep->arg[2], len);
  9200. }
  9201. }
  9202. DumpPacket(app);
  9203. client->QueuePacket(app);
  9204. safe_delete(packet2);
  9205. }
  9206. }
  9207. }
  9208. else if (atoi(sep->arg[0]) == 24) {
  9209. PacketStruct* packet2 = configReader.getStruct("WS_EnableGameEvent", client->GetVersion());
  9210. if (packet2) {
  9211. if (sep->IsSet(2)) {
  9212. packet2->setDataByName("event_name", sep->arg[1]);
  9213. packet2->setDataByName("enabled", atoi(sep->arg[2]));
  9214. EQ2Packet* app = packet2->serialize();
  9215. DumpPacket(app);
  9216. client->QueuePacket(app);
  9217. safe_delete(packet2);
  9218. }
  9219. }
  9220. }
  9221. else if (atoi(sep->arg[0]) == 25) {
  9222. if (sep->IsSet(1)) {
  9223. Widget* new_spawn = new Widget();
  9224. int32 id = atoul(sep->arg[1]);
  9225. new_spawn->SetWidgetID(id);
  9226. EQ2Packet* ret = new_spawn->serialize(client->GetPlayer(), client->GetVersion());
  9227. client->QueuePacket(ret);
  9228. int8 index = client->GetPlayer()->GetIndexForSpawn(new_spawn);
  9229. PacketStruct* packet2 = configReader.getStruct("WS_DestroyGhostCmd", client->GetVersion());
  9230. if (packet2) {
  9231. packet2->setDataByName("spawn_index", index);
  9232. packet2->setDataByName("delete", 1);
  9233. EQ2Packet* app = packet2->serialize();
  9234. client->QueuePacket(app);
  9235. safe_delete(packet2);
  9236. }
  9237. }
  9238. }
  9239. else if (atoi(sep->arg[0]) == 26) {
  9240. if (sep->IsSet(4)) {
  9241. Widget* new_spawn = new Widget();
  9242. int32 id = atoul(sep->arg[1]);
  9243. new_spawn->SetWidgetID(id);
  9244. float x = atof(sep->arg[2]);
  9245. float y = atof(sep->arg[3]);
  9246. float z = atof(sep->arg[4]);
  9247. new_spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  9248. new_spawn->SetWidgetX(x);
  9249. new_spawn->SetWidgetY(y);
  9250. new_spawn->SetWidgetZ(z);
  9251. new_spawn->SetX(x);
  9252. new_spawn->SetY(y);
  9253. new_spawn->SetZ(z);
  9254. EQ2Packet* ret = new_spawn->serialize(client->GetPlayer(), client->GetVersion());
  9255. client->QueuePacket(ret);
  9256. }
  9257. }
  9258. else if (atoi(sep->arg[0]) == 27) {
  9259. Spawn* target = client->GetPlayer()->GetTarget();
  9260. PacketStruct* packet2 = configReader.getStruct("WS_HearSimpleDamage", client->GetVersion());
  9261. if (packet2 && target && sep->IsSet(2)) {
  9262. packet2->setSubstructDataByName("header", "defender", client->GetPlayer()->GetIDWithPlayerSpawn(target));
  9263. packet2->setSubstructDataByName("header", "defender_proxy", client->GetPlayer()->GetIDWithPlayerSpawn(target));
  9264. packet2->setSubstructDataByName("header", "attacker", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  9265. packet2->setArrayLengthByName("num_dmg", 1);
  9266. packet2->setArrayDataByName("damage_type", atoi(sep->arg[1]));
  9267. packet2->setArrayDataByName("damage", atoi(sep->arg[2]));
  9268. packet2->setDataByName("spell", 1);
  9269. packet2->setDataByName("spell_name", "Testing");
  9270. EQ2Packet* app = packet2->serialize();
  9271. if (sep->IsSet(4)) {
  9272. int16 offset = atoi(sep->arg[3]);
  9273. uchar* ptr2 = app->pBuffer;
  9274. ptr2 += offset;
  9275. if (sep->IsNumber(4)) {
  9276. int32 value1 = atol(sep->arg[4]);
  9277. if (value1 > 0xFFFF)
  9278. memcpy(ptr2, (uchar*)&value1, 4);
  9279. else if (value1 > 0xFF)
  9280. memcpy(ptr2, (uchar*)&value1, 2);
  9281. else
  9282. memcpy(ptr2, (uchar*)&value1, 1);
  9283. }
  9284. else {
  9285. int8 len = strlen(sep->arg[4]);
  9286. memcpy(ptr2, (uchar*)&len, 1);
  9287. ptr2 += 1;
  9288. memcpy(ptr2, sep->arg[4], len);
  9289. }
  9290. }
  9291. if (sep->IsSet(6)) {
  9292. int16 offset = atoi(sep->arg[5]);
  9293. uchar* ptr2 = app->pBuffer;
  9294. ptr2 += offset;
  9295. if (sep->IsNumber(6)) {
  9296. int32 value1 = atol(sep->arg[6]);
  9297. if (value1 > 0xFFFF)
  9298. memcpy(ptr2, (uchar*)&value1, 4);
  9299. else if (value1 > 0xFF)
  9300. memcpy(ptr2, (uchar*)&value1, 2);
  9301. else
  9302. memcpy(ptr2, (uchar*)&value1, 1);
  9303. }
  9304. else {
  9305. int8 len = strlen(sep->arg[6]);
  9306. memcpy(ptr2, (uchar*)&len, 1);
  9307. ptr2 += 1;
  9308. memcpy(ptr2, sep->arg[6], len);
  9309. }
  9310. }
  9311. DumpPacket(app);
  9312. client->QueuePacket(app);
  9313. safe_delete(packet2);
  9314. }
  9315. }
  9316. }
  9317. else {
  9318. PacketStruct* packet2 = configReader.getStruct("WS_ExamineSpellInfo", client->GetVersion());
  9319. if (packet2) {
  9320. packet2->setSubstructDataByName("info_header", "show_name", 1);
  9321. packet2->setSubstructDataByName("info_header", "unknown", 7);
  9322. packet2->setSubstructDataByName("info_header", "unknown2", 1);
  9323. packet2->setSubstructDataByName("info_header", "unknown3", 1);
  9324. packet2->setSubstructDataByName("info_header", "unknown4", 1);
  9325. packet2->setSubstructDataByName("info_header", "unknown5", 1);
  9326. packet2->setSubstructDataByName("info_header", "unknown6", "Testing");
  9327. packet2->setSubstructDataByName("info_header", "unknown7", "Testing");
  9328. packet2->setSubstructDataByName("info_header", "unknown8", 66);
  9329. packet2->setSubstructDataByName("info_header", "title", "Blah Title Blah");
  9330. packet2->setSubstructDataByName("info_header", "title_text", "Blah Blah");
  9331. packet2->setSubstructDataByName("info_header", "title_text2", "Blah Blah2");
  9332. packet2->setSubstructDataByName("info_header", "show_popup", 1);
  9333. packet2->setSubstructDataByName("info_header", "packettype", 3);
  9334. packet2->setSubstructDataByName("spell_info", "skill_name", "Testing");
  9335. packet2->setSubstructDataByName("spell_info", "level", 19);
  9336. packet2->setSubstructDataByName("spell_info", "tier", 1);
  9337. packet2->setSubstructDataByName("spell_info", "health_cost", 5);
  9338. packet2->setSubstructDataByName("spell_info", "min_class_skill_req", 3);
  9339. packet2->setSubstructDataByName("spell_info", "mana_cost", 6);
  9340. packet2->setSubstructDataByName("spell_info", "req_concentration", 7);
  9341. packet2->setSubstructDataByName("spell_info", "cast_time", 200);
  9342. packet2->setSubstructDataByName("spell_info", "recovery", 220);
  9343. packet2->setSubstructDataByName("spell_info", "recast", 280);
  9344. packet2->setSubstructDataByName("spell_info", "beneficial", 1);
  9345. packet2->setSubstructDataByName("spell_info", "maintained", 1);
  9346. packet2->setSubstructDataByName("spell_info", "spell_book_type", 1);
  9347. packet2->setSubstructDataByName("spell_info", "quality", 3);
  9348. packet2->setSubstructDataByName("spell_info", "test_1a", 1);
  9349. packet2->setSubstructDataByName("spell_info", "test_1b", 1);
  9350. packet2->setSubstructDataByName("spell_info", "test_1c", 1);
  9351. packet2->setSubstructDataByName("spell_info", "test_1d", 1);
  9352. packet2->setSubstructDataByName("spell_info", "test_2a", 2);
  9353. packet2->setSubstructDataByName("spell_info", "test_2b", 2);
  9354. packet2->setSubstructDataByName("spell_info", "test_2c", 2);
  9355. packet2->setSubstructDataByName("spell_info", "test_2d", 2);
  9356. packet2->setSubstructDataByName("spell_info", "test_3", 3);
  9357. packet2->setSubstructDataByName("spell_info", "test_4", 4);
  9358. packet2->setSubstructDataByName("spell_info", "test_5", 5);
  9359. packet2->setSubstructDataByName("spell_info", "test_6", 6);
  9360. packet2->setSubstructDataByName("spell_info", "min_class_skill_req", 1);
  9361. packet2->setSubstructDataByName("spell_info", "min_class_skill_rec", 30123);
  9362. packet2->setSubstructDataByName("spell_info", "num_reagents", 1);
  9363. packet2->setSubstructArrayLengthByName("spell_info", "num_reagents", 1);
  9364. packet2->setArrayDataByName("reagent", "Alcohol");
  9365. packet2->setArrayDataByName("consumed", "123");
  9366. packet2->setSubstructDataByName("spell_info", "class_skill", 52);
  9367. packet2->setSubstructDataByName("spell_info", "id", 8308);
  9368. packet2->setSubstructDataByName("spell_info", "icon", 303);
  9369. packet2->setSubstructDataByName("spell_info", "icon2", 0xFFFF);
  9370. packet2->setSubstructDataByName("spell_info", "icontype", 317);
  9371. packet2->setSubstructDataByName("spell_info", "type", 2);
  9372. packet2->setSubstructDataByName("spell_info", "spell_text_color", 255);
  9373. packet2->setSubstructDataByName("spell_info", "duration1", 600);
  9374. packet2->setSubstructDataByName("spell_info", "duration2", 600);
  9375. packet2->setSubstructDataByName("spell_info", "name", "Sprint");
  9376. packet2->setSubstructDataByName("spell_info", "description", "Test description");
  9377. EQ2Packet* outapp = packet2->serialize();
  9378. DumpPacket(outapp);
  9379. client->QueuePacket(outapp);
  9380. safe_delete(packet2);
  9381. }
  9382. }
  9383. return;
  9384. PacketStruct* p = configReader.getStruct("WS_EqTargetItemCmd", client->GetVersion());
  9385. if (!p) return;
  9386. //Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  9387. //client->GetCurrentZone()->SendSpellFailedPacket(client, atoi(sep2->arg[0]));
  9388. //}
  9389. /*Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  9390. if (sep2 && sep2->arg[0] && sep2->IsNumber(0)) {
  9391. client->SetPendingFlightPath(atoi(sep2->arg[0]));
  9392. PacketStruct* packet = configReader.getStruct("WS_ReadyForTakeOff", client->GetVersion());
  9393. if (packet) {
  9394. client->QueuePacket(packet->serialize());
  9395. safe_delete(packet);
  9396. }
  9397. }*/
  9398. /*if (client->GetCurrentZone()->Grid != nullptr) {
  9399. int32 numFaces = 0;
  9400. int32 numGrids = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.size();
  9401. client->Message(CHANNEL_COLOR_YELLOW, "Num grids in cell: %u", numGrids);
  9402. map<int32, vector<Face*> >::iterator itr;
  9403. for (itr = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.begin(); itr != client->GetPlayer()->Cell_Info.CurrentCell->FaceList.end(); itr++)
  9404. numFaces += (*itr).second.size();
  9405. client->Message(CHANNEL_COLOR_YELLOW, "Num faces in cell: %u", numFaces);
  9406. }*/
  9407. //uchar blah[] = {
  9408. // 1208 - OP_EQUpdateStoreCmd
  9409. // /*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
  9410. // /*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
  9411. // 1193 - -- OP_ClientCmdMsg::OP_EqUpdateMerchantCmd --
  9412. // /*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
  9413. /*};
  9414. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  9415. int8 val = 0;
  9416. int16 pos = 0;
  9417. int idx = 0;
  9418. while(sep2 && sep2->arg[idx+1] && sep2->IsNumber(idx) && sep2->IsNumber(idx+1)){
  9419. pos = atoi(sep2->arg[idx]);
  9420. val = atoi(sep2->arg[idx+1]);
  9421. memset(blah+pos, val, 1);
  9422. idx+=2;
  9423. }
  9424. DumpPacket(blah, sizeof(blah));
  9425. client->QueuePacket(new EQ2Packet(OP_GroupCreatedMsg , blah, sizeof(blah)));*/
  9426. if (client->GetPlayer()->GetTarget()) {
  9427. PacketStruct* packet = configReader.getStruct("WS_SetControlGhost", client->GetVersion());
  9428. if (packet) {
  9429. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  9430. packet->setDataByName("size", 0);
  9431. packet->setDataByName("unknown2", 0);
  9432. EQ2Packet* app = packet->serialize();
  9433. client->QueuePacket(app);
  9434. safe_delete(packet);
  9435. }
  9436. PacketStruct* set_pov = configReader.getStruct("WS_SetPOVGhostCmd", client->GetVersion());
  9437. if (set_pov) {
  9438. set_pov->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  9439. EQ2Packet* app_pov = set_pov->serialize();
  9440. client->QueuePacket(app_pov);
  9441. safe_delete(set_pov);
  9442. }
  9443. }
  9444. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  9445. PacketStruct* packet = configReader.getStruct("WS_OpenCharCust", client->GetVersion());
  9446. if (packet) {
  9447. if (sep2 && sep2->arg[0] && sep2->IsNumber(0))
  9448. packet->setDataByName("Type", atoi(sep2->arg[0]));
  9449. else
  9450. packet->setDataByName("Type", 2);
  9451. if (sep2 && sep2->arg[1] && sep2->IsNumber(1))
  9452. packet->setDataByName("race_id", atoi(sep2->arg[1]));
  9453. else
  9454. packet->setDataByName("race_id", 0);
  9455. if (sep2 && sep2->arg[2] && sep2->IsNumber(2))
  9456. packet->setDataByName("gender", atoi(sep2->arg[2]));
  9457. else
  9458. packet->setDataByName("gender", 2);
  9459. if (sep2 && sep2->arg[3] && sep2->IsNumber(3))
  9460. packet->setDataByName("unknown", atoi(sep2->arg[3]), 0);
  9461. else
  9462. packet->setDataByName("unknown", 0, 0);
  9463. if (sep2 && sep2->arg[4] && sep2->IsNumber(4))
  9464. packet->setDataByName("unknown", atoi(sep2->arg[4]), 1);
  9465. else
  9466. packet->setDataByName("unknown", 0, 1);
  9467. if (sep2 && sep2->arg[5] && sep2->IsNumber(5))
  9468. packet->setDataByName("unknown", atoi(sep2->arg[5]), 2);
  9469. else
  9470. packet->setDataByName("unknown", 0, 2);
  9471. client->QueuePacket(packet->serialize());
  9472. }
  9473. safe_delete(packet);
  9474. safe_delete(sep2);
  9475. }
  9476. void Commands::Command_LeaveChannel(Client *client, Seperator *sep) {
  9477. const char *channel_name;
  9478. if (sep == NULL || !sep->IsSet(0)) {
  9479. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /leavechat <channel name>");
  9480. PrintSep(sep);
  9481. return;
  9482. }
  9483. channel_name = sep->arg[0];
  9484. if (!chat.IsInChannel(client, channel_name))
  9485. client->Message(CHANNEL_NARRATIVE, "Unable to leave '%s': You are not in the channel.", channel_name);
  9486. else if (!chat.LeaveChannel(client, channel_name))
  9487. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an internal error preventing you from leaving that channel MUAHAHA");
  9488. }
  9489. /*
  9490. Function:
  9491. Purpose :
  9492. Params :
  9493. Dev :
  9494. Example :
  9495. */
  9496. void Commands::Command_WeaponStats(Client* client)
  9497. {
  9498. Player* player = client->GetPlayer();
  9499. Item* primary = player->GetEquipmentList()->GetItem(EQ2_PRIMARY_SLOT);
  9500. Item* secondary = player->GetEquipmentList()->GetItem(EQ2_SECONDARY_SLOT);
  9501. Item* ranged = player->GetEquipmentList()->GetItem(EQ2_RANGE_SLOT);
  9502. client->SimpleMessage(0, "Primary:");
  9503. if (primary) {
  9504. client->Message(0, "Name: %s", primary->name.c_str());
  9505. client->Message(0, "Base Damage: %u - %u", primary->weapon_info->damage_low3, primary->weapon_info->damage_high3);
  9506. client->Message(0, "Actual Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  9507. client->Message(0, "Actual Delay: %u", player->GetPrimaryWeaponDelay());
  9508. client->Message(0, "Proc Percent: %d%%", 0);
  9509. client->Message(0, "Procs Per Minute: %d", 0);
  9510. }
  9511. else {
  9512. client->SimpleMessage(0, "Name: fist");
  9513. client->Message(0, "Base Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  9514. client->Message(0, "Actual Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  9515. client->Message(0, "Actual Delay: %d", player->GetPrimaryWeaponDelay() * 0.1);
  9516. client->Message(0, "Proc Percent: %d%%", 0);
  9517. client->Message(0, "Procs Per Minute: %d", 0);
  9518. }
  9519. client->SimpleMessage(0, " ");
  9520. client->SimpleMessage(0, " ");
  9521. if (secondary) {
  9522. client->SimpleMessage(0, "Secondary:");
  9523. client->Message(0, "Name: %s", secondary->name.c_str());
  9524. client->Message(0, "Base Damage: %u - %u", secondary->weapon_info->damage_low3, secondary->weapon_info->damage_high3);
  9525. client->Message(0, "Actual Damage: %u - %u", player->GetSecondaryWeaponMinDamage(), player->GetSecondaryWeaponMaxDamage());
  9526. client->Message(0, "Actual Delay: %d", player->GetSecondaryWeaponDelay() * 0.1);
  9527. client->Message(0, "Proc Percent: %d%%", 0);
  9528. client->Message(0, "Procs Per Minute: %d", 0);
  9529. client->SimpleMessage(0, " ");
  9530. client->SimpleMessage(0, " ");
  9531. }
  9532. client->SimpleMessage(0, "Ranged:");
  9533. if (ranged) {
  9534. client->Message(0, "Name: %s", ranged->name.c_str());
  9535. client->Message(0, "Base Damage: %u - %u", ranged->ranged_info->weapon_info.damage_low3, ranged->ranged_info->weapon_info.damage_high3);
  9536. client->Message(0, "Actual Damage: %u - %u", player->GetRangedWeaponMinDamage(), player->GetRangedWeaponMaxDamage());
  9537. client->Message(0, "Actual Delay: %d", player->GetRangeWeaponDelay() * 0.1);
  9538. client->Message(0, "Proc Percent: %d%%", 0);
  9539. client->Message(0, "Procs Per Minute: %d", 0);
  9540. }
  9541. else
  9542. client->SimpleMessage(0, "None");
  9543. }
  9544. void Commands::Command_WhoChannel(Client *client, Seperator *sep) {
  9545. const char *channel_name;
  9546. if (sep == NULL || !sep->IsSet(0)) {
  9547. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /chatwho <channel name>");
  9548. return;
  9549. }
  9550. channel_name = sep->arg[0];
  9551. if (!chat.ChannelExists(channel_name))
  9552. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That channel does not exist!");
  9553. else
  9554. chat.SendChannelUserList(client, channel_name);
  9555. }
  9556. void Commands::Command_ZoneSafeCoords(Client *client, Seperator *sep)
  9557. {
  9558. ZoneServer* zone = 0;
  9559. int32 zone_id = client->GetPlayer()->GetZone()->GetZoneID();
  9560. if (zone_id > 0)
  9561. {
  9562. zone = zone_list.Get(zone_id, false);
  9563. if (zone)
  9564. {
  9565. zone->SetSafeX(client->GetPlayer()->GetX());
  9566. zone->SetSafeY(client->GetPlayer()->GetY());
  9567. zone->SetSafeZ(client->GetPlayer()->GetZ());
  9568. zone->SetSafeHeading(client->GetPlayer()->GetHeading());
  9569. if( database.SaveZoneSafeCoords(zone_id, zone->GetSafeX(), zone->GetSafeY(), zone->GetSafeZ(), zone->GetSafeHeading()) )
  9570. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Zone safe coordinates updated!");
  9571. else
  9572. client->SimpleMessage(CHANNEL_COLOR_RED, "FAILED to update zone safe coordinates!");
  9573. }
  9574. }
  9575. }
  9576. /*
  9577. Function:
  9578. Purpose :
  9579. Params :
  9580. Dev :
  9581. Example :
  9582. */
  9583. void Commands::Command_ZoneDetails(Client* client, Seperator* sep)
  9584. {
  9585. ZoneInfo* zone_info = new ZoneInfo;
  9586. if (sep && sep->arg[0])
  9587. {
  9588. if (sep->IsNumber(0))
  9589. zone_info->id = atoi(sep->arg[0]);
  9590. else
  9591. zone_info->id = database.GetZoneID(sep->arg[0]);
  9592. if (zone_info->id > 0)
  9593. {
  9594. database.LoadZoneInfo(zone_info);
  9595. 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);
  9596. 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);
  9597. 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);
  9598. 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);
  9599. 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);
  9600. 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);
  9601. 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);
  9602. client->Message(CHANNEL_COLOR_YELLOW, "zone_type: %s, sky_file: %s", zone_info->zone_type, zone_info->sky_file);
  9603. client->Message(CHANNEL_COLOR_YELLOW, "lua_script: %s", zone_info->lua_script);
  9604. client->Message(CHANNEL_COLOR_YELLOW, "zone_motd: %s", zone_info->zone_motd);
  9605. }
  9606. else
  9607. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  9608. }
  9609. else
  9610. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone details [zone id|zone name]");
  9611. safe_delete(zone_info);
  9612. }
  9613. /*
  9614. Function:
  9615. Purpose :
  9616. Params :
  9617. Dev :
  9618. Example :
  9619. */
  9620. void Commands::Command_ZoneSet(Client* client, Seperator* sep)
  9621. {
  9622. if (sep && sep->arg[0] && sep->arg[1] && sep->arg[2])
  9623. {
  9624. ZoneServer* zone = 0;
  9625. int32 zone_id = 0;
  9626. if (sep->IsNumber(0) && atoi(sep->arg[0]) > 0)
  9627. {
  9628. zone_id = atoi(sep->arg[0]);
  9629. zone = zone_list.Get(atoi(sep->arg[0]), false);
  9630. }
  9631. else
  9632. {
  9633. zone_id = database.GetZoneID(sep->arg[0]);
  9634. if (zone_id > 0)
  9635. zone = zone_list.Get(sep->arg[0], false);
  9636. }
  9637. if (zone_id > 0)
  9638. {
  9639. if (zone_set_values.count(string(sep->arg[1])) > 0)
  9640. SetZoneCommand(client, zone_id, zone, zone_set_values[sep->arg[1]], sep->arg[2]);
  9641. else
  9642. client->Message(CHANNEL_COLOR_YELLOW, "The attribute '%s' is not valid.", sep->arg[1]);
  9643. }
  9644. else
  9645. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  9646. }
  9647. else
  9648. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone set [zone id|zone name] [attribute] [value]");
  9649. }
  9650. void Commands::Command_Rain(Client* client, Seperator* sep) {
  9651. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  9652. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /rain <float>");
  9653. return;
  9654. }
  9655. client->Message(CHANNEL_COLOR_YELLOW,"Setting rain to %.2f", atof(sep->arg[0]));
  9656. client->GetCurrentZone()->SetRain(atof(sep->arg[0]));
  9657. client->GetCurrentZone()->SetCurrentWeather(atof(sep->arg[0]));
  9658. }
  9659. void Commands::Command_Wind(Client* client, Seperator* sep) {
  9660. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  9661. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /wind <float>");
  9662. return;
  9663. }
  9664. client->Message(CHANNEL_COLOR_YELLOW, "Setting wind to %.2f", atof(sep->arg[0]));
  9665. client->GetCurrentZone()->SetWind(atof(sep->arg[0]));
  9666. }
  9667. void Commands::Command_SendMerchantWindow(Client* client, Seperator* sep, bool sell) {
  9668. Spawn* spawn = client->GetPlayer()->GetTarget();
  9669. if(spawn) {
  9670. client->SetMerchantTransaction(spawn);
  9671. if (spawn->GetMerchantID() > 0 && spawn->IsClientInMerchantLevelRange(client)){
  9672. client->SendHailCommand(spawn);
  9673. //MerchantFactionMultiplier* multiplier = world.GetMerchantMultiplier(spawn->GetMerchantID());
  9674. //if(!multiplier || (multiplier && client->GetPlayer()->GetFactions()->GetFactionValue(multiplier->faction_id) >= multiplier->faction_min)){
  9675. client->SendBuyMerchantList(sell);
  9676. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY))
  9677. client->SendSellMerchantList(sell);
  9678. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY_BACK))
  9679. client->SendBuyBackList(sell);
  9680. PacketStruct* packet = configReader.getStruct("WS_UpdateMerchant", client->GetVersion());
  9681. if (packet) {
  9682. packet->setDataByName("spawn_id", 0xFFFFFFFF);
  9683. packet->setDataByName("type", 16);
  9684. EQ2Packet* outapp = packet->serialize();
  9685. if (outapp)
  9686. client->QueuePacket(outapp);
  9687. safe_delete(packet);
  9688. }
  9689. }
  9690. if (spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR)
  9691. client->SendRepairList();
  9692. }
  9693. // client->SimpleMessage(CHANNEL_COLOR_RED, "Your faction is too low to use this merchant.");
  9694. }
  9695. void Commands::Command_Weather(Client* client, Seperator* sep)
  9696. {
  9697. //PrintSep(sep, "Weather");
  9698. if( sep && sep->arg[0] )
  9699. {
  9700. ZoneServer* zsZone = client->GetCurrentZone();
  9701. const char* value = sep->arg[0];
  9702. // process single-param commands first
  9703. if( strncasecmp(value, "details", strlen(value)) == 0 )
  9704. {
  9705. client->Message(CHANNEL_COLOR_YELLOW, "Weather Details for zone %s: ", zsZone->GetZoneName());
  9706. client->Message(CHANNEL_COLOR_YELLOW, "enabled: %i, allowed: %i, type: %i, frequency: %u", zsZone->isWeatherEnabled(), zsZone->isWeatherAllowed(), zsZone->GetWeatherType(), zsZone->GetWeatherFrequency());
  9707. client->Message(CHANNEL_COLOR_YELLOW, "severity: %.2f = %.2f, current: %.2f", zsZone->GetWeatherMinSeverity(), zsZone->GetWeatherMaxSeverity(), zsZone->GetCurrentWeather());
  9708. client->Message(CHANNEL_COLOR_YELLOW, "pattern: %i, chance: %i, amount: %.2f, offset: %.2f", zsZone->GetWeatherPattern(), zsZone->GetWeatherChance(), zsZone->GetWeatherChangeAmount(), zsZone->GetWeatherDynamicOffset());
  9709. }
  9710. else if( strncasecmp(value, "process", strlen(value)) == 0 )
  9711. {
  9712. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  9713. zsZone->ProcessWeather();
  9714. }
  9715. else if( strncasecmp(value, "reset", strlen(value)) == 0 )
  9716. {
  9717. zsZone->SetWeatherType(rule_manager.GetGlobalRule(R_Zone, WeatherType)->GetInt8());
  9718. zsZone->SetWeatherFrequency(rule_manager.GetGlobalRule(R_Zone, WeatherChangeFrequency)->GetInt32());
  9719. zsZone->SetWeatherMinSeverity(rule_manager.GetGlobalRule(R_Zone, MinWeatherSeverity)->GetFloat());
  9720. zsZone->SetWeatherMaxSeverity(rule_manager.GetGlobalRule(R_Zone, MaxWeatherSeverity)->GetFloat());
  9721. zsZone->SetCurrentWeather(zsZone->GetWeatherMinSeverity());
  9722. zsZone->SetWeatherPattern(1);
  9723. zsZone->SetWeatherChance(rule_manager.GetGlobalRule(R_Zone, WeatherChangeChance)->GetInt8());
  9724. zsZone->SetWeatherChangeAmount(rule_manager.GetGlobalRule(R_Zone, WeatherChangePerInterval)->GetFloat());
  9725. zsZone->SetWeatherDynamicOffset(rule_manager.GetGlobalRule(R_Zone, WeatherDynamicMaxOffset)->GetFloat());
  9726. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  9727. zsZone->ProcessWeather();
  9728. }
  9729. // process commands with params
  9730. if( sep->arg[1] )
  9731. {
  9732. if( strncasecmp(value, "enable", strlen(value)) == 0 && sep->IsNumber(1) )
  9733. zsZone->SetWeatherEnabled( ( atoi(sep->arg[1]) == 1 ) ? true : false );
  9734. else if( strncasecmp(value, "type", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 3) )
  9735. zsZone->SetWeatherType(atoi(sep->arg[1]));
  9736. else if( strncasecmp(value, "frequency", strlen(value)) == 0 && sep->IsNumber(1))
  9737. zsZone->SetWeatherFrequency( atoul(sep->arg[1]) );
  9738. else if( strncasecmp(value, "range", strlen(value)) == 0 && sep->IsNumber(1) && sep->IsNumber(2) ) {
  9739. zsZone->SetWeatherMinSeverity(atof(sep->arg[1]));
  9740. zsZone->SetWeatherMaxSeverity(atof(sep->arg[2]));
  9741. zsZone->SetRain(zsZone->GetWeatherMinSeverity());
  9742. }
  9743. else if( strncasecmp(value, "current", strlen(value)) == 0 && sep->IsNumber(1) ) {
  9744. zsZone->SetCurrentWeather(atof(sep->arg[1]));
  9745. zsZone->SetRain(zsZone->GetCurrentWeather());
  9746. }
  9747. else if( strncasecmp(value, "pattern", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 2) )
  9748. zsZone->SetWeatherPattern( atoi(sep->arg[1]) );
  9749. else if( strncasecmp(value, "chance", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 100) )
  9750. zsZone->SetWeatherChance( atoi(sep->arg[1]) );
  9751. else if( strncasecmp(value, "amount", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  9752. zsZone->SetWeatherChangeAmount( atof(sep->arg[1]) );
  9753. else if( strncasecmp(value, "offset", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  9754. zsZone->SetWeatherDynamicOffset( atof(sep->arg[1]) );
  9755. }
  9756. }
  9757. else
  9758. {
  9759. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /weather [command] [param]");
  9760. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: enable (0|1), type (0-3), frequency (sec), range|current (0.0 - 1.0)");
  9761. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: details, process, pattern (0|1), chance (%), amount (float), offset (float)");
  9762. return;
  9763. }
  9764. }
  9765. void Commands::Command_Select(Client* client, Seperator* sep) {
  9766. if (sep && sep->arg[1]) {
  9767. Spawn* spawn = client->GetPlayer()->GetTarget();
  9768. if (spawn && strlen(sep->arg[1]) > 0)
  9769. client->GetCurrentZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_CUSTOM, client->GetPlayer(), sep->arg[1]);
  9770. }
  9771. }
  9772. /*
  9773. Function: Command_ConsumeFood()
  9774. Purpose : Consume Food/Drink and apply mods
  9775. Params : Slot ID - EQ2_FOOD_SLOT 22, EQ2_DRINK_SLOT 23
  9776. Dev : Zcoretri
  9777. Example : /consume_food 22
  9778. */
  9779. void Commands::Command_ConsumeFood(Client* client, Seperator* sep) {
  9780. if (sep && sep->arg[0] && sep->IsNumber(0))
  9781. {
  9782. Player* player = client->GetPlayer();
  9783. int8 slot = atoi(sep->arg[0]);
  9784. Item* item = player->GetEquipmentList()->GetItem(slot);
  9785. if(slot == 22 && player->GetSpellEffectBySpellType(SPELL_TYPE_FOOD))
  9786. {
  9787. client->Message(CHANNEL_NARRATIVE, "If you ate anymore you would explode!");
  9788. return;
  9789. }
  9790. else if (player->GetSpellEffectBySpellType(SPELL_TYPE_DRINK))
  9791. {
  9792. client->Message(CHANNEL_NARRATIVE, "If you drank anymore you would explode!");
  9793. return;
  9794. }
  9795. client->ConsumeFoodDrink(item, slot);
  9796. }
  9797. }
  9798. void Commands::Command_Aquaman(Client* client, Seperator* sep) {
  9799. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  9800. if (atoi(sep->arg[0]) == 1) {
  9801. client->GetPlayer()->GetInfoStruct()->set_vision(4);
  9802. client->GetPlayer()->GetInfoStruct()->set_breathe_underwater(1);
  9803. client->GetPlayer()->SetCharSheetChanged(true);
  9804. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Maybe you ought to stick to the shallow end until you know how to swim.");
  9805. }
  9806. else {
  9807. client->GetPlayer()->GetInfoStruct()->set_vision(0);
  9808. client->GetPlayer()->GetInfoStruct()->set_breathe_underwater(0);
  9809. client->GetPlayer()->SetCharSheetChanged(true);
  9810. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Aquaman mode turned off.");
  9811. }
  9812. }
  9813. else
  9814. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /aquaman [0|1]");
  9815. }
  9816. void Commands::Command_ReportBug(Client* client, Seperator* sep)
  9817. {
  9818. if(sep)
  9819. {
  9820. string data;
  9821. if(sep->arg[0]){
  9822. data = string(sep->arg[0]);
  9823. }
  9824. for(int i=1;i<sep->GetMaxArgNum();i++){
  9825. if(sep->arg[i])
  9826. data.append(" ").append(sep->arg[i]);
  9827. }
  9828. const char* target_name = 0;
  9829. int32 spawn_id = 0;
  9830. if(client->GetPlayer()->GetTarget())
  9831. {
  9832. target_name = client->GetPlayer()->GetTarget()->GetName();
  9833. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  9834. }
  9835. else
  9836. target_name = "N/A";
  9837. LogWrite(COMMAND__DEBUG, 1, "Command", "%s", data.c_str());
  9838. if(world.ReportBug(data, client->GetPlayer()->GetName(), client->GetAccountID(), target_name, spawn_id, client->GetCurrentZone()->GetZoneID()))
  9839. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully submitted bug.");
  9840. else
  9841. client->SimpleMessage(CHANNEL_COLOR_RED, "Error submitting bug.");
  9842. }
  9843. }
  9844. void Commands::Command_Attune_Inv(Client* client, Seperator* sep) {
  9845. PrintSep(sep, "Command_Attune_Inv");
  9846. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  9847. // Get the item index from the first parameter
  9848. int16 index = atoi(sep->arg[0]);
  9849. // Check to see if this is a valid item index for the player, if not exit out of the function
  9850. if (client->GetPlayer()->item_list.indexed_items.count(index) == 0) {
  9851. LogWrite(ITEM__DEBUG, 0, "Items", "%s has no item with an index of %i", client->GetPlayer()->GetName(), index);
  9852. return;
  9853. }
  9854. // Get the item
  9855. Item* item = client->GetPlayer()->item_list.indexed_items[index];
  9856. if(item) {
  9857. // Valid item lets check to make sure this item is attunable, if not return out
  9858. if (!item->CheckFlag(ATTUNEABLE)) {
  9859. LogWrite(ITEM__DEBUG, 0, "Items", "attune_inv called for an item that is not attunable (%s)", item->name.c_str());
  9860. return;
  9861. }
  9862. // Remove the attunable flag
  9863. item->generic_info.item_flags -= ATTUNEABLE;
  9864. // Set the attuned flag
  9865. item->generic_info.item_flags += ATTUNED;
  9866. // Flag this item for saving
  9867. item->save_needed = true;
  9868. client->QueuePacket(item->serialize(client->GetVersion(), false, client->GetPlayer()));
  9869. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), 0, -1); // appearance type??
  9870. EQ2Packet* outapp = 0;
  9871. for (int32 i=0;i<packets.size();i++) {
  9872. outapp = packets[i];
  9873. if(outapp)
  9874. client->QueuePacket(outapp);
  9875. }
  9876. }
  9877. }
  9878. }
  9879. void Commands::Command_Reset_Zone_Timer(Client* client, Seperator* sep) {
  9880. PrintSep(sep, "Command_Reset_Zone_Timer");
  9881. /*if (sep && sep->arg[0] && sep->IsNumber(0)) {
  9882. int32 db_id = atoul(sep->arg[0]);
  9883. InstanceData* data = client->GetPlayer()->GetCharacterInstances().FindInstanceByDBID(db_id);
  9884. if (data) {
  9885. // TODO: add a check to timers to ensure it can be reset
  9886. // Delete the character from the instance
  9887. database.DeleteCharacterFromInstance(client->GetPlayer()->GetCharacterID(), data->instance_id);
  9888. data->instance_id = 0;
  9889. // Update the success time and set to 0 so the player can enter it again
  9890. database.UpdateCharacterInstance(client->GetPlayer()->GetCharacterID(), data->zone_name, 0, 1, 0);
  9891. data->last_success_timestamp = 0;
  9892. }
  9893. }*/
  9894. }
  9895. void Commands::Command_Player(Client* client, Seperator* sep) {
  9896. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player syntax --");
  9897. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins");
  9898. }
  9899. void Commands::Command_Player_Coins(Client* client, Seperator* sep) {
  9900. // /player coins add 10
  9901. // /player coins add plat 10
  9902. Player* player = client->GetPlayer();
  9903. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  9904. player = (Player*)player->GetTarget();
  9905. if (sep && sep->arg[0] && sep->arg[1]) {
  9906. const char* action = sep->arg[0];
  9907. int64 value = 0;
  9908. if (strncasecmp(action, "add", strlen(action)) == 0) {
  9909. if (sep->IsNumber(1)) {
  9910. value = atoi64(sep->arg[1]);
  9911. player->AddCoins(value);
  9912. if (client->GetPlayer() == player)
  9913. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  9914. else {
  9915. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  9916. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  9917. }
  9918. return;
  9919. }
  9920. else if (sep->arg[2] && sep->IsNumber(2)) {
  9921. const char* type = sep->arg[1];
  9922. if (strncasecmp(type, "copper", strlen(type)) == 0) {
  9923. value = atoi64(sep->arg[2]);
  9924. }
  9925. else if (strncasecmp(type, "silver", strlen(type)) == 0) {
  9926. value = atoi64(sep->arg[2]) * 100;
  9927. }
  9928. else if (strncasecmp(type, "gold", strlen(type)) == 0) {
  9929. value = atoi64(sep->arg[2]) * 10000;
  9930. }
  9931. else if (strncasecmp(type, "plat", strlen(type)) == 0) {
  9932. value = atoi64(sep->arg[2]) * 1000000;
  9933. }
  9934. player->AddCoins(value);
  9935. if (client->GetPlayer() == player)
  9936. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  9937. else {
  9938. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  9939. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  9940. }
  9941. return;
  9942. }
  9943. }
  9944. }
  9945. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player coins syntax --");
  9946. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add [value] - adds the given number of coins to the player");
  9947. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add copper [value] - adds the given amount of copper to the player");
  9948. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add silver [value] - adds the given amount of silver to the player");
  9949. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add gold [value] - adds the given amount of gold to the player");
  9950. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add plat [value] - adds the given amount of platinum to the player");
  9951. }
  9952. void Commands::Command_AchievementAdd(Client* client, Seperator* sep) {
  9953. PrintSep(sep, "ACHIEVEMENT_ADD");
  9954. if (sep && sep->IsSet(0)) {
  9955. int32 spell_id = atoul(sep->arg[1]);
  9956. int8 spell_tier = 0;
  9957. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  9958. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  9959. // addspellbookentry here
  9960. if (spell_tier >= data->maxRank) {
  9961. return;
  9962. }
  9963. if (!spell_tier) {
  9964. spell_tier = 1;
  9965. }
  9966. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  9967. {
  9968. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  9969. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  9970. client->GetPlayer()->UnlockSpell(spell);
  9971. client->SendSpellUpdate(spell);
  9972. }
  9973. else
  9974. {
  9975. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1);
  9976. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  9977. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  9978. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  9979. client->GetPlayer()->UnlockSpell(spell);
  9980. client->SendSpellUpdate(spell);
  9981. }
  9982. // cast spell here
  9983. if (!spell_tier)
  9984. spell_tier = 1;
  9985. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  9986. if (spell) {
  9987. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  9988. }
  9989. }
  9990. else {
  9991. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  9992. }
  9993. master_aa_list.DisplayAA(client, 0, 0);
  9994. }
  9995. void Commands::Command_Editor(Client* client, Seperator* sep) {
  9996. PacketStruct* packet = configReader.getStruct("WS_ChoiceWindow", client->GetVersion());
  9997. if (packet) {
  9998. string url = string(rule_manager.GetGlobalRule(R_World, EditorURL)->GetString());
  9999. if (rule_manager.GetGlobalRule(R_World, EditorOfficialServer)->GetBool()) {
  10000. char command[255];
  10001. url = "browser " + url;
  10002. int32 spawn_id = 0;
  10003. int32 zone_id = 0;
  10004. string type;
  10005. if (client->GetCurrentZone())
  10006. zone_id = client->GetCurrentZone()->GetZoneID();
  10007. if (client->GetPlayer()->GetTarget()) {
  10008. Spawn* target = client->GetPlayer()->GetTarget();
  10009. if (target->IsWidget())
  10010. type = "widgets";
  10011. else if (target->IsSign())
  10012. type = "signs";
  10013. else if (target->IsObject())
  10014. type = "objects";
  10015. else if (target->IsNPC())
  10016. type = "npcs";
  10017. else if (target->IsGroundSpawn())
  10018. type = "ground";
  10019. else
  10020. type = "spawn";
  10021. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  10022. }
  10023. sprintf(command, url.c_str(), zone_id, type.c_str(), spawn_id);
  10024. packet->setDataByName("accept_command", command);
  10025. }
  10026. else if (rule_manager.GetGlobalRule(R_World, EditorIncludeID)->GetBool()) {
  10027. char command[255];
  10028. url = "browser " + url;
  10029. if (client->GetPlayer()->GetTarget())
  10030. sprintf(command, url.c_str(), client->GetPlayer()->GetTarget()->GetDatabaseID());
  10031. packet->setDataByName("accept_command", command);
  10032. }
  10033. else {
  10034. string command = "browser " + url;
  10035. packet->setDataByName("accept_command", command.c_str());
  10036. }
  10037. packet->setDataByName("text", "Open the web editor?");
  10038. packet->setDataByName("accept_text", "Open");
  10039. packet->setDataByName("cancel_text", "Cancel");
  10040. // No clue if we even need the following 2 unknowns, just added them so the packet matches what live sends
  10041. packet->setDataByName("unknown2", 50);
  10042. packet->setDataByName("unknown4", 1);
  10043. client->QueuePacket(packet->serialize());
  10044. safe_delete(packet);
  10045. }
  10046. }
  10047. void Commands::Command_AcceptResurrection(Client* client, Seperator* sep) {
  10048. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  10049. return;
  10050. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  10051. if(client->GetCurrentRez()->active)
  10052. client->AcceptResurrection();
  10053. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  10054. }
  10055. void Commands::Command_DeclineResurrection(Client* client, Seperator* sep) {
  10056. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  10057. return;
  10058. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  10059. if(client->GetCurrentRez()->active)
  10060. client->GetCurrentRez()->should_delete = true;
  10061. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  10062. }
  10063. void Commands::Switch_AA_Profile(Client* client, Seperator* sep) {
  10064. PrintSep(sep, "Switch_AA_Profile");
  10065. if (sep && sep->IsSet(0)) {
  10066. string type = sep->arg[0];
  10067. int8 newtemplate = atoul(sep->arg[1]);
  10068. master_aa_list.DisplayAA(client, newtemplate, 1);
  10069. }
  10070. }
  10071. void Commands::Get_AA_Xml(Client* client, Seperator* sep) {
  10072. PrintSep(sep, "Get_AA_Xml");
  10073. if (sep && sep->IsSet(0)) {
  10074. string tabnum = sep->arg[0];
  10075. string spellid = sep->arg[1];
  10076. }
  10077. }
  10078. void Commands::Add_AA(Client* client, Seperator* sep) {
  10079. PrintSep(sep, "Add_AA");
  10080. if (sep && sep->IsSet(0)) {
  10081. int32 spell_id = atoul(sep->arg[1]);
  10082. int8 spell_tier = 0;
  10083. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  10084. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  10085. // addspellbookentry here
  10086. if(!data) {
  10087. LogWrite(COMMAND__ERROR, 0, "Command", "Error in Add_AA no data for spell_id %u spell_tier %u", spell_id, spell_tier);
  10088. return;
  10089. }
  10090. if (spell_tier >= data->maxRank) {
  10091. LogWrite(COMMAND__ERROR, 0, "Command", "Error in Add_AA spell_tier %u >= maxRank %u", spell_tier, data->maxRank);
  10092. return;
  10093. }
  10094. if (!spell_tier) {
  10095. spell_tier = 1;
  10096. }
  10097. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  10098. {
  10099. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  10100. if(spell)
  10101. {
  10102. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  10103. client->GetPlayer()->UnlockSpell(spell);
  10104. client->SendSpellUpdate(spell);
  10105. }
  10106. }
  10107. else
  10108. {
  10109. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1 );
  10110. if(spell)
  10111. {
  10112. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  10113. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  10114. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  10115. client->GetPlayer()->UnlockSpell(spell);
  10116. client->SendSpellUpdate(spell);
  10117. }
  10118. }
  10119. // cast spell here
  10120. if (!spell_tier)
  10121. spell_tier = 1;
  10122. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  10123. if (spell) {
  10124. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  10125. }
  10126. }
  10127. else {
  10128. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  10129. }
  10130. master_aa_list.DisplayAA(client, 0, 0);
  10131. }
  10132. void Commands::Commit_AA_Profile(Client* client, Seperator* sep) {
  10133. PrintSep(sep, "Commit_AA_Profile");
  10134. if (sep && sep->IsSet(0)) {
  10135. }
  10136. }
  10137. void Commands::Begin_AA_Profile(Client* client, Seperator* sep) {
  10138. PrintSep(sep, "Begin_AA_Profile");
  10139. if (sep && sep->IsSet(0)) {
  10140. master_aa_list.DisplayAA(client, 100, 2);
  10141. }
  10142. }
  10143. void Commands::Back_AA(Client* client, Seperator* sep) {
  10144. if (sep && sep->IsSet(0)) {
  10145. PrintSep(sep, "Back_AA");
  10146. }
  10147. }
  10148. void Commands::Remove_AA(Client* client, Seperator* sep) {
  10149. if (sep && sep->IsSet(0)) {
  10150. PrintSep(sep, "Remove_AA");
  10151. }
  10152. }
  10153. void Commands::Cancel_AA_Profile(Client* client, Seperator* sep) {
  10154. MasterAAList master_aa_list;
  10155. PrintSep(sep, "Cancel_AA_Profile");
  10156. master_aa_list.DisplayAA(client, 0, 0);
  10157. }
  10158. void Commands::Save_AA_Profile(Client* client, Seperator* sep) {
  10159. if (sep && sep->IsSet(0)) {
  10160. PrintSep(sep, "Save_AA_Profile");
  10161. }
  10162. }
  10163. void Commands::Command_TargetItem(Client* client, Seperator* sep) {
  10164. if (!sep || sep->GetArgNumber() < 1 || !client->GetPlayer()) return;
  10165. if (!sep->IsNumber(0)) return;
  10166. int32 request_id = atoul(sep->arg[0]);
  10167. if (!sep->IsNumber(1)) return;
  10168. sint32 item_id = atoi(sep->arg[1]);
  10169. if (client->IsCurrentTransmuteID(request_id)) {
  10170. Transmute::HandleItemResponse(client, client->GetPlayer(), request_id, reinterpret_cast<int32&>(item_id));
  10171. }
  10172. else if (client->IsCurrentTransmuteID(item_id)) {
  10173. if (!sep->IsSet(2)) return;
  10174. if (sep->IsNumber(2) && atoi(sep->arg[2]) == 1) {
  10175. Transmute::HandleConfirmResponse(client, client->GetPlayer(), reinterpret_cast<int32&>(item_id));
  10176. }
  10177. }
  10178. }
  10179. void Commands::Command_FindSpawn(Client* client, Seperator* sep) {
  10180. if(sep)
  10181. client->GetCurrentZone()->FindSpawn(client, (char*)sep->argplus[0]);
  10182. }
  10183. void Commands::Command_MoveCharacter(Client* client, Seperator* sep) {
  10184. if(sep && sep->arg[0][0] && sep->arg[1][0])
  10185. {
  10186. char* name = sep->arg[0];
  10187. char* zoneName = sep->arg[1];
  10188. char query[256];
  10189. snprintf(query, 256, "UPDATE characters c, zones z set c.x = z.safe_x, c.y = z.safe_y, c.z = z.safe_z, c.heading = z.safe_heading, c.current_zone_id = z.id where c.name = '%s' and z.name='%s'", name, zoneName);
  10190. if (database.RunQuery(query, strnlen(query, 256)))
  10191. {
  10192. client->Message(CHANNEL_COLOR_YELLOW, "Ran query:%s", query);
  10193. }
  10194. else
  10195. client->Message(CHANNEL_COLOR_RED, "Query FAILED to run: %s", query);
  10196. }
  10197. }