Commands.cpp 365 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197
  1. /*
  2. EQ2Emulator: Everquest II Server Emulator
  3. Copyright (C) 2007 EQ2EMulator Development Team (http://www.eq2emulator.net)
  4. This file is part of EQ2Emulator.
  5. EQ2Emulator is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. EQ2Emulator is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with EQ2Emulator. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #include <sys/types.h>
  17. #include "Commands.h"
  18. #include "../ClientPacketFunctions.h"
  19. #include "../../common/version.h"
  20. #include "../../common/seperator.h"
  21. #include "../../common/servertalk.h"
  22. #include "../WorldDatabase.h"
  23. #include "../World.h"
  24. #include "../../common/ConfigReader.h"
  25. #include "../VisualStates.h"
  26. #include "../../common/debug.h"
  27. #include "../LuaInterface.h"
  28. #include "../Quests.h"
  29. #include "../client.h"
  30. #include "../NPC.h"
  31. #include "../Guilds/Guild.h"
  32. #include "../SpellProcess.h"
  33. #include "../Tradeskills/Tradeskills.h"
  34. #include "../../common/Log.h"
  35. #include "../../common/MiscFunctions.h"
  36. #include "../Languages.h"
  37. #include "../IRC/IRC.h"
  38. #include "../Traits/Traits.h"
  39. #include "../Chat/Chat.h"
  40. #include "../Rules/Rules.h"
  41. #include "../AltAdvancement/AltAdvancement.h"
  42. #include "../RaceTypes/RaceTypes.h"
  43. #include "../classes.h"
  44. #include "../Transmute.h"
  45. #include "../Zone/SPGrid.h"
  46. extern WorldDatabase database;
  47. extern MasterSpellList master_spell_list;
  48. extern MasterTraitList master_trait_list;
  49. extern MasterRecipeList master_recipe_list;
  50. extern MasterRecipeBookList master_recipebook_list;
  51. extern World world;
  52. extern ClientList client_list;
  53. extern ConfigReader configReader;
  54. extern VisualStates visual_states;
  55. extern ZoneList zone_list;
  56. extern LuaInterface* lua_interface;
  57. extern MasterQuestList master_quest_list;
  58. extern MasterCollectionList master_collection_list;
  59. extern MasterSkillList master_skill_list;
  60. extern MasterFactionList master_faction_list;
  61. extern GuildList guild_list;
  62. extern MasterLanguagesList master_languages_list;
  63. extern IRC irc;
  64. extern Chat chat;
  65. extern RuleManager rule_manager;
  66. extern MasterAAList master_aa_list;
  67. extern MasterRaceTypeList race_types_list;
  68. extern Classes classes;
  69. //devn00b: Fix for linux builds since we dont use stricmp we use strcasecmp
  70. #if defined(__GNUC__)
  71. #define stricmp strcasecmp
  72. #define strnicmp strncasecmp
  73. #endif
  74. EQ2Packet* RemoteCommands::serialize(){
  75. buffer.clear();
  76. vector<EQ2_RemoteCommandString>::iterator command_list;
  77. buffer.append((char*)&num_commands, sizeof(int16));
  78. for( command_list = commands.begin(); command_list != commands.end(); command_list++ ) {
  79. AddDataCommand(&(*command_list));
  80. }
  81. EQ2Packet* app = new EQ2Packet(OP_SetRemoteCmdsMsg, (uchar*)buffer.c_str(), buffer.length() + 1);
  82. return app;
  83. }
  84. Commands::Commands(){
  85. remote_commands = new RemoteCommands();
  86. spawn_set_values["list"] = SPAWN_SET_VALUE_LIST;
  87. spawn_set_values["name"] = SPAWN_SET_VALUE_NAME;
  88. spawn_set_values["level"] = SPAWN_SET_VALUE_LEVEL; // TODO: Fix this, min_level, max_level
  89. spawn_set_values["difficulty"] = SPAWN_SET_VALUE_DIFFICULTY;
  90. spawn_set_values["model_type"] = SPAWN_SET_VALUE_MODEL_TYPE;
  91. spawn_set_values["class"] = SPAWN_SET_VALUE_CLASS;
  92. spawn_set_values["gender"] = SPAWN_SET_VALUE_GENDER;
  93. spawn_set_values["show_name"] = SPAWN_SET_VALUE_SHOW_NAME;
  94. spawn_set_values["attackable"] = SPAWN_SET_VALUE_ATTACKABLE;
  95. spawn_set_values["show_level"] = SPAWN_SET_VALUE_SHOW_LEVEL;
  96. spawn_set_values["targetable"] = SPAWN_SET_VALUE_TARGETABLE;
  97. spawn_set_values["show_command_icon"] = SPAWN_SET_VALUE_SHOW_COMMAND_ICON;
  98. spawn_set_values["display_hand_icon"] = SPAWN_SET_VALUE_HAND_ICON;
  99. spawn_set_values["hair_type"] = SPAWN_SET_VALUE_HAIR_TYPE;
  100. spawn_set_values["facial_hair_type"] = SPAWN_SET_VALUE_FACIAL_HAIR_TYPE;
  101. spawn_set_values["wing_type"] = SPAWN_SET_VALUE_WING_TYPE;
  102. spawn_set_values["chest_type"] = SPAWN_SET_VALUE_CHEST_TYPE;
  103. spawn_set_values["legs_type"] = SPAWN_SET_VALUE_LEGS_TYPE;
  104. spawn_set_values["soga_hair_type"] = SPAWN_SET_VALUE_SOGA_HAIR_TYPE;
  105. spawn_set_values["soga_facial_hair_type"] = SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE;
  106. spawn_set_values["soga_model_type"] = SPAWN_SET_VALUE_SOGA_MODEL_TYPE;
  107. spawn_set_values["size"] = SPAWN_SET_VALUE_SIZE;
  108. spawn_set_values["hp"] = SPAWN_SET_VALUE_HP;
  109. spawn_set_values["power"] = SPAWN_SET_VALUE_POWER;
  110. spawn_set_values["heroic"] = SPAWN_SET_VALUE_HEROIC;
  111. spawn_set_values["respawn"] = SPAWN_SET_VALUE_RESPAWN;
  112. spawn_set_values["x"] = SPAWN_SET_VALUE_X;
  113. spawn_set_values["y"] = SPAWN_SET_VALUE_Y;
  114. spawn_set_values["z"] = SPAWN_SET_VALUE_Z;
  115. spawn_set_values["heading"] = SPAWN_SET_VALUE_HEADING;
  116. spawn_set_values["location"] = SPAWN_SET_VALUE_LOCATION;
  117. spawn_set_values["command_primary"] = SPAWN_SET_VALUE_COMMAND_PRIMARY;
  118. spawn_set_values["command_secondary"] = SPAWN_SET_VALUE_COMMAND_SECONDARY;
  119. spawn_set_values["visual_state"] = SPAWN_SET_VALUE_VISUAL_STATE;
  120. spawn_set_values["action_state"] = SPAWN_SET_VALUE_ACTION_STATE;
  121. spawn_set_values["mood_state"] = SPAWN_SET_VALUE_MOOD_STATE;
  122. spawn_set_values["initial_state"] = SPAWN_SET_VALUE_INITIAL_STATE;
  123. spawn_set_values["activity_state"] = SPAWN_SET_VALUE_ACTIVITY_STATE;
  124. spawn_set_values["collision_radius"] = SPAWN_SET_VALUE_COLLISION_RADIUS;
  125. spawn_set_values["faction"] = SPAWN_SET_VALUE_FACTION;
  126. spawn_set_values["spawn_script"] = SPAWN_SET_VALUE_SPAWN_SCRIPT;
  127. spawn_set_values["spawnentry_script"] = SPAWN_SET_VALUE_SPAWNENTRY_SCRIPT;
  128. spawn_set_values["spawnlocation_script"] = SPAWN_SET_VALUE_SPAWNLOCATION_SCRIPT;
  129. spawn_set_values["sub_title"] = SPAWN_SET_VALUE_SUB_TITLE;
  130. spawn_set_values["expire"] = SPAWN_SET_VALUE_EXPIRE;
  131. spawn_set_values["expire_offset"] = SPAWN_SET_VALUE_EXPIRE_OFFSET;
  132. spawn_set_values["x_offset"] = SPAWN_SET_VALUE_X_OFFSET;
  133. spawn_set_values["y_offset"] = SPAWN_SET_VALUE_Y_OFFSET;
  134. spawn_set_values["z_offset"] = SPAWN_SET_VALUE_Z_OFFSET;
  135. spawn_set_values["device_id"] = SPAWN_SET_VALUE_DEVICE_ID;
  136. spawn_set_values["pitch"] = SPAWN_SET_VALUE_PITCH;
  137. spawn_set_values["roll"] = SPAWN_SET_VALUE_ROLL;
  138. spawn_set_values["hide_hood"] = SPAWN_SET_VALUE_HIDE_HOOD;
  139. spawn_set_values["emote_state"] = SPAWN_SET_VALUE_EMOTE_STATE;
  140. spawn_set_values["icon"] = SPAWN_SET_VALUE_ICON;
  141. spawn_set_values["prefix"] = SPAWN_SET_VALUE_PREFIX;
  142. spawn_set_values["suffix"] = SPAWN_SET_VALUE_SUFFIX;
  143. spawn_set_values["lastname"] = SPAWN_SET_VALUE_LASTNAME;
  144. spawn_set_values["expansion_flag"] = SPAWN_SET_VALUE_EXPANSION_FLAG;
  145. spawn_set_values["holiday_flag"] = SPAWN_SET_VALUE_HOLIDAY_FLAG;
  146. spawn_set_values["merchant_min_level"] = SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL;
  147. spawn_set_values["merchant_max_level"] = SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL;
  148. zone_set_values["expansion_id"] = ZONE_SET_VALUE_EXPANSION_ID;
  149. zone_set_values["name"] = ZONE_SET_VALUE_NAME;
  150. zone_set_values["file"] = ZONE_SET_VALUE_FILE ;
  151. zone_set_values["description"] = ZONE_SET_VALUE_DESCRIPTION;
  152. zone_set_values["safe_x"] = ZONE_SET_VALUE_SAFE_X;
  153. zone_set_values["safe_y"] = ZONE_SET_VALUE_SAFE_Y;
  154. zone_set_values["safe_z"] = ZONE_SET_VALUE_SAFE_Z;
  155. zone_set_values["underworld"] = ZONE_SET_VALUE_UNDERWORLD;
  156. zone_set_values["min_recommended"] = ZONE_SET_VALUE_MIN_RECOMMENDED;
  157. zone_set_values["max_recommended"] = ZONE_SET_VALUE_MAX_RECOMMENDED;
  158. zone_set_values["zone_type"] = ZONE_SET_VALUE_ZONE_TYPE;
  159. zone_set_values["always_loaded"] = ZONE_SET_VALUE_ALWAYS_LOADED;
  160. zone_set_values["city_zone"] = ZONE_SET_VALUE_CITY_ZONE;
  161. zone_set_values["weather_allowed"] = ZONE_SET_VALUE_WEATHER_ALLOWED;
  162. zone_set_values["min_status"] = ZONE_SET_VALUE_MIN_STATUS;
  163. zone_set_values["min_level"] = ZONE_SET_VALUE_MIN_LEVEL;
  164. zone_set_values["start_zone"] = ZONE_SET_VALUE_START_ZONE;
  165. zone_set_values["instance_type"] = ZONE_SET_VALUE_INSTANCE_TYPE;
  166. zone_set_values["default_reenter_time"] = ZONE_SET_VALUE_DEFAULT_REENTER_TIME;
  167. zone_set_values["default_reset_time"] = ZONE_SET_VALUE_DEFAULT_RESET_TIME;
  168. zone_set_values["default_lockout_time"] = ZONE_SET_VALUE_DEFAULT_LOCKOUT_TIME;
  169. zone_set_values["force_group_to_zone"] = ZONE_SET_VALUE_FORCE_GROUP_TO_ZONE;
  170. zone_set_values["lua_script"] = ZONE_SET_VALUE_LUA_SCRIPT;
  171. zone_set_values["shutdown_timer"] = ZONE_SET_VALUE_SHUTDOWN_TIMER;
  172. zone_set_values["zone_motd"] = ZONE_SET_VALUE_ZONE_MOTD;
  173. }
  174. Commands::~Commands() {
  175. safe_delete(remote_commands);
  176. }
  177. int32 Commands::GetSpawnSetType(string val){
  178. if(spawn_set_values.count(val) > 0)
  179. return spawn_set_values[val];
  180. return 0xFFFFFFFF;
  181. }
  182. bool Commands::SetSpawnCommand(Client* client, Spawn* target, int8 type, const char* value, bool send_update, bool temporary, string* temp_value){
  183. if(!target)
  184. return false;
  185. int32 val = 0;
  186. try{
  187. if(type != SPAWN_SET_VALUE_NAME && !(type >= SPAWN_SET_VALUE_SPAWN_SCRIPT && type <= SPAWN_SET_VALUE_SUB_TITLE) && !(type >= SPAWN_SET_VALUE_PREFIX && type <= SPAWN_SET_VALUE_EXPANSION_FLAG || type == SPAWN_SET_VALUE_HOLIDAY_FLAG))
  188. val = atoul(value);
  189. }
  190. catch(...){
  191. if(client)
  192. client->Message(CHANNEL_COLOR_RED, "Invalid numeric spawn value: %s", value);
  193. return false;
  194. }
  195. if(temporary && temp_value){
  196. char tmp[128] = {0};
  197. switch(type){
  198. case SPAWN_SET_VALUE_NAME:{
  199. sprintf(tmp, "%s", target->GetName());
  200. target->SetName(value);
  201. client->GetCurrentZone()->SendUpdateTitles(target);
  202. break;
  203. }
  204. case SPAWN_SET_VALUE_X_OFFSET:
  205. {
  206. sprintf(tmp, "%f", target->GetXOffset());
  207. target->SetXOffset(float(val));
  208. break;
  209. }
  210. case SPAWN_SET_VALUE_Y_OFFSET:
  211. {
  212. sprintf(tmp, "%f", target->GetYOffset());
  213. target->SetYOffset(float(val));
  214. break;
  215. }
  216. case SPAWN_SET_VALUE_Z_OFFSET:
  217. {
  218. sprintf(tmp, "%f", target->GetZOffset());
  219. target->SetZOffset(float(val));
  220. break;
  221. }
  222. case SPAWN_SET_VALUE_EXPIRE: {
  223. sprintf(tmp, "%u", target->GetExpireTime());
  224. target->SetExpireTime(val);
  225. break;
  226. }
  227. case SPAWN_SET_VALUE_EXPIRE_OFFSET: {
  228. sprintf(tmp, "%u", target->GetExpireOffsetTime());
  229. target->SetExpireOffsetTime(val);
  230. break;
  231. }
  232. case SPAWN_SET_VALUE_SUB_TITLE: {
  233. sprintf(tmp, "%s", target->GetSubTitle());
  234. target->SetSubTitle(value);
  235. client->GetCurrentZone()->SendUpdateTitles(target);
  236. break;
  237. }
  238. case SPAWN_SET_VALUE_LEVEL:{
  239. sprintf(tmp, "%i", target->GetLevel());
  240. target->SetLevel(val, send_update);
  241. break;
  242. }
  243. case SPAWN_SET_VALUE_DIFFICULTY:{
  244. sprintf(tmp, "%i", target->GetEncounterLevel());
  245. target->SetEncounterLevel(val, send_update);
  246. break;
  247. }
  248. case SPAWN_SET_VALUE_MODEL_TYPE:{
  249. sprintf(tmp, "%i", target->GetModelType());
  250. target->SetModelType(val, send_update);
  251. break;
  252. }
  253. case SPAWN_SET_VALUE_CLASS:{
  254. sprintf(tmp, "%i", target->GetAdventureClass());
  255. target->SetAdventureClass(val, send_update);
  256. break;
  257. }
  258. case SPAWN_SET_VALUE_GENDER:{
  259. sprintf(tmp, "%i", target->GetGender());
  260. target->SetGender(val, send_update);
  261. break;
  262. }
  263. case SPAWN_SET_VALUE_SHOW_NAME:{
  264. sprintf(tmp, "%i", target->GetShowName());
  265. target->SetShowName(val, send_update);
  266. break;
  267. }
  268. case SPAWN_SET_VALUE_ATTACKABLE:{
  269. sprintf(tmp, "%i", target->GetAttackable());
  270. target->SetAttackable(val, send_update);
  271. break;
  272. }
  273. case SPAWN_SET_VALUE_SHOW_LEVEL:{
  274. sprintf(tmp, "%i", target->GetShowLevel());
  275. target->SetShowLevel(val, send_update);
  276. break;
  277. }
  278. case SPAWN_SET_VALUE_TARGETABLE:{
  279. sprintf(tmp, "%i", target->GetTargetable());
  280. target->SetTargetable(val, send_update);
  281. break;
  282. }
  283. case SPAWN_SET_VALUE_SHOW_COMMAND_ICON:{
  284. sprintf(tmp, "%i", target->GetShowCommandIcon());
  285. target->SetShowCommandIcon(val, send_update);
  286. break;
  287. }
  288. case SPAWN_SET_VALUE_HAND_ICON:{
  289. sprintf(tmp, "%i", target->GetShowHandIcon());
  290. target->SetShowHandIcon(val, send_update);
  291. break;
  292. }
  293. case SPAWN_SET_VALUE_HAIR_TYPE:{
  294. if(target->IsEntity()){
  295. sprintf(tmp, "%i", ((Entity*)target)->GetHairType());
  296. ((Entity*)target)->SetHairType(val, send_update);
  297. }
  298. break;
  299. }
  300. case SPAWN_SET_VALUE_FACIAL_HAIR_TYPE:{
  301. if(target->IsEntity()){
  302. sprintf(tmp, "%i", ((Entity*)target)->GetHairType());
  303. ((Entity*)target)->SetHairType(val, send_update);
  304. }
  305. break;
  306. }
  307. case SPAWN_SET_VALUE_WING_TYPE:{
  308. if(target->IsEntity()){
  309. sprintf(tmp, "%i", ((Entity*)target)->GetWingType());
  310. ((Entity*)target)->SetWingType(val, send_update);
  311. }
  312. break;
  313. }
  314. case SPAWN_SET_VALUE_CHEST_TYPE:{
  315. if(target->IsEntity()){
  316. sprintf(tmp, "%i", ((Entity*)target)->GetChestType());
  317. ((Entity*)target)->SetChestType(val, send_update);
  318. }
  319. break;
  320. }
  321. case SPAWN_SET_VALUE_LEGS_TYPE:{
  322. if(target->IsEntity()){
  323. sprintf(tmp, "%i", ((Entity*)target)->GetLegsType());
  324. ((Entity*)target)->SetLegsType(val, send_update);
  325. }
  326. break;
  327. }
  328. case SPAWN_SET_VALUE_SOGA_HAIR_TYPE:{
  329. if(target->IsEntity()){
  330. sprintf(tmp, "%i", ((Entity*)target)->GetSogaHairType());
  331. ((Entity*)target)->SetSogaHairType(val, send_update);
  332. }
  333. break;
  334. }
  335. case SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE:{
  336. if(target->IsEntity()){
  337. sprintf(tmp, "%i", ((Entity*)target)->GetSogaFacialHairType());
  338. ((Entity*)target)->SetSogaFacialHairType(val, send_update);
  339. }
  340. break;
  341. }
  342. case SPAWN_SET_VALUE_SOGA_MODEL_TYPE:{
  343. sprintf(tmp, "%i", target->GetSogaModelType());
  344. target->SetSogaModelType(val, send_update);
  345. break;
  346. }
  347. case SPAWN_SET_VALUE_SIZE:{
  348. sprintf(tmp, "%i", target->GetSize());
  349. target->SetSize(val, send_update);
  350. break;
  351. }
  352. case SPAWN_SET_VALUE_HP:{
  353. sprintf(tmp, "%i", target->GetHP());
  354. target->SetHP(val, send_update);
  355. break;
  356. }
  357. case SPAWN_SET_VALUE_POWER:{
  358. sprintf(tmp, "%i", target->GetPower());
  359. target->SetPower(val, send_update);
  360. break;
  361. }
  362. case SPAWN_SET_VALUE_HEROIC:{
  363. sprintf(tmp, "%i", target->GetHeroic());
  364. target->SetHeroic(val, send_update);
  365. break;
  366. }
  367. case SPAWN_SET_VALUE_RESPAWN:{
  368. sprintf(tmp, "%u", target->GetRespawnTime());
  369. target->SetRespawnTime(val);
  370. break;
  371. }
  372. case SPAWN_SET_VALUE_X:{
  373. sprintf(tmp, "%f", target->GetX());
  374. target->SetX(atof(value), send_update);
  375. break;
  376. }
  377. case SPAWN_SET_VALUE_Y:{
  378. sprintf(tmp, "%f", target->GetY());
  379. target->SetY(atof(value), send_update);
  380. break;
  381. }
  382. case SPAWN_SET_VALUE_Z:{
  383. sprintf(tmp, "%f", target->GetZ());
  384. target->SetZ(atof(value), send_update);
  385. break;
  386. }
  387. case SPAWN_SET_VALUE_HEADING:{
  388. sprintf(tmp, "%f", target->GetHeading());
  389. target->SetHeading(atof(value) + 360, send_update);
  390. break;
  391. }
  392. case SPAWN_SET_VALUE_VISUAL_STATE:{
  393. sprintf(tmp, "%i", target->GetVisualState());
  394. target->SetVisualState(val, send_update);
  395. break;
  396. }
  397. case SPAWN_SET_VALUE_ACTION_STATE:{
  398. sprintf(tmp, "%i", target->GetActionState());
  399. target->SetActionState(val, send_update);
  400. break;
  401. }
  402. case SPAWN_SET_VALUE_MOOD_STATE:{
  403. sprintf(tmp, "%i", target->GetMoodState());
  404. target->SetMoodState(val, send_update);
  405. break;
  406. }
  407. case SPAWN_SET_VALUE_INITIAL_STATE:{
  408. sprintf(tmp, "%i", target->GetInitialState());
  409. target->SetInitialState(val, send_update);
  410. break;
  411. }
  412. case SPAWN_SET_VALUE_ACTIVITY_STATE:{
  413. sprintf(tmp, "%i", target->GetActivityStatus());
  414. target->SetActivityStatus(val, send_update);
  415. break;
  416. }
  417. case SPAWN_SET_VALUE_COLLISION_RADIUS:{
  418. sprintf(tmp, "%i", target->GetCollisionRadius());
  419. target->SetCollisionRadius(val, send_update);
  420. break;
  421. }
  422. case SPAWN_SET_VALUE_DEVICE_ID: {
  423. if (target->IsObject()) {
  424. sprintf(tmp, "%i", ((Object*)target)->GetDeviceID());
  425. ((Object*)target)->SetDeviceID(val);
  426. }
  427. break;
  428. }
  429. case SPAWN_SET_VALUE_PITCH: {
  430. sprintf(tmp, "%f", target->GetPitch());
  431. target->SetPitch(atof(value), send_update);
  432. break;
  433. }
  434. case SPAWN_SET_VALUE_ROLL: {
  435. sprintf(tmp, "%f", target->GetRoll());
  436. target->SetRoll(atof(value), send_update);
  437. break;
  438. }
  439. case SPAWN_SET_VALUE_HIDE_HOOD: {
  440. sprintf(tmp, "%i", target->appearance.hide_hood);
  441. target->SetHideHood(val);
  442. break;
  443. }
  444. case SPAWN_SET_VALUE_EMOTE_STATE: {
  445. sprintf(tmp, "%i", target->appearance.emote_state);
  446. target->SetEmoteState(val);
  447. break;
  448. }
  449. case SPAWN_SET_VALUE_ICON: {
  450. sprintf(tmp, "%i", target->GetIconValue());
  451. target->SetIcon(val);
  452. break;
  453. }
  454. case SPAWN_SET_VALUE_PREFIX: {
  455. sprintf(tmp, "%s", target->GetPrefixTitle());
  456. target->SetPrefixTitle(value);
  457. client->GetCurrentZone()->SendUpdateTitles(target);
  458. break;
  459. }
  460. case SPAWN_SET_VALUE_SUFFIX: {
  461. sprintf(tmp, "%s", target->GetSuffixTitle());
  462. target->SetSuffixTitle(value);
  463. client->GetCurrentZone()->SendUpdateTitles(target);
  464. break;
  465. }
  466. case SPAWN_SET_VALUE_LASTNAME: {
  467. sprintf(tmp, "%s", target->GetLastName());
  468. target->SetLastName(value);
  469. client->GetCurrentZone()->SendUpdateTitles(target);
  470. break;
  471. }
  472. case SPAWN_SET_VALUE_EXPANSION_FLAG:
  473. case SPAWN_SET_VALUE_HOLIDAY_FLAG: {
  474. // nothing to do must reload spawns
  475. break;
  476. }
  477. case SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL: {
  478. sprintf(tmp, "%i", target->GetMerchantMinLevel());
  479. target->SetMerchantLevelRange(atoul(value), target->GetMerchantMaxLevel());
  480. break;
  481. }
  482. case SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL: {
  483. sprintf(tmp, "%i", target->GetMerchantMaxLevel());
  484. target->SetMerchantLevelRange(target->GetMerchantMinLevel(), atoul(value));
  485. break;
  486. }
  487. *temp_value = string(tmp);
  488. }
  489. }
  490. else{
  491. switch(type){
  492. case SPAWN_SET_VALUE_MERCHANT_MIN_LEVEL: {
  493. target->SetMerchantLevelRange(atoul(value), target->GetMerchantMaxLevel());
  494. break;
  495. }
  496. case SPAWN_SET_VALUE_MERCHANT_MAX_LEVEL: {
  497. target->SetMerchantLevelRange(target->GetMerchantMinLevel(), atoul(value));
  498. break;
  499. }
  500. case SPAWN_SET_VALUE_EXPANSION_FLAG: {
  501. if (target->GetDatabaseID() > 0)
  502. {
  503. char query[256];
  504. snprintf(query, 256, "update spawn set expansion_flag=%i where id=%i", atoul(value), target->GetDatabaseID());
  505. if (database.RunQuery(query, strnlen(query, 256)))
  506. {
  507. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  508. }
  509. }
  510. break;
  511. }
  512. case SPAWN_SET_VALUE_HOLIDAY_FLAG: {
  513. if (target->GetDatabaseID() > 0)
  514. {
  515. char query[256];
  516. snprintf(query, 256, "update spawn set holiday_flag=%i where id=%i", atoul(value), target->GetDatabaseID());
  517. if (database.RunQuery(query, strnlen(query, 256)))
  518. {
  519. client->Message(CHANNEL_COLOR_RED, "Ran query:%s", query);
  520. }
  521. }
  522. break;
  523. }
  524. case SPAWN_SET_VALUE_NAME:{
  525. target->SetName(value);
  526. client->GetCurrentZone()->SendUpdateTitles(target);
  527. break;
  528. }
  529. case SPAWN_SET_VALUE_SUB_TITLE: {
  530. target->SetSubTitle(value);
  531. client->GetCurrentZone()->SendUpdateTitles(target);
  532. break;
  533. }
  534. case SPAWN_SET_VALUE_X_OFFSET:
  535. {
  536. target->SetXOffset(atof(value));
  537. break;
  538. }
  539. case SPAWN_SET_VALUE_Y_OFFSET:
  540. {
  541. target->SetYOffset(atof(value));
  542. break;
  543. }
  544. case SPAWN_SET_VALUE_Z_OFFSET:
  545. {
  546. target->SetZOffset(atof(value));
  547. break;
  548. }
  549. case SPAWN_SET_VALUE_EXPIRE: {
  550. target->SetExpireTime(val);
  551. break;
  552. }
  553. case SPAWN_SET_VALUE_EXPIRE_OFFSET: {
  554. target->SetExpireOffsetTime(val);
  555. break;
  556. }
  557. case SPAWN_SET_VALUE_LEVEL:{
  558. target->SetLevel(val, send_update);
  559. break;
  560. }
  561. case SPAWN_SET_VALUE_DIFFICULTY:{
  562. target->SetEncounterLevel(val, send_update);
  563. break;
  564. }
  565. case SPAWN_SET_VALUE_MODEL_TYPE:{
  566. target->SetModelType(val, send_update);
  567. break;
  568. }
  569. case SPAWN_SET_VALUE_CLASS:{
  570. target->SetAdventureClass(val, send_update);
  571. break;
  572. }
  573. case SPAWN_SET_VALUE_GENDER:{
  574. target->SetGender(val, send_update);
  575. break;
  576. }
  577. case SPAWN_SET_VALUE_SHOW_NAME:{
  578. target->SetShowName(val, send_update);
  579. break;
  580. }
  581. case SPAWN_SET_VALUE_ATTACKABLE:{
  582. target->SetAttackable(val, send_update);
  583. break;
  584. }
  585. case SPAWN_SET_VALUE_SHOW_LEVEL:{
  586. target->SetShowLevel(val, send_update);
  587. break;
  588. }
  589. case SPAWN_SET_VALUE_TARGETABLE:{
  590. target->SetTargetable(val, send_update);
  591. break;
  592. }
  593. case SPAWN_SET_VALUE_SHOW_COMMAND_ICON:{
  594. target->SetShowCommandIcon(val, send_update);
  595. break;
  596. }
  597. case SPAWN_SET_VALUE_HAND_ICON:{
  598. target->SetShowHandIcon(val, send_update);
  599. break;
  600. }
  601. case SPAWN_SET_VALUE_HAIR_TYPE:{
  602. if(target->IsEntity())
  603. ((Entity*)target)->SetHairType(val, send_update);
  604. break;
  605. }
  606. case SPAWN_SET_VALUE_FACIAL_HAIR_TYPE:{
  607. if(target->IsEntity())
  608. ((Entity*)target)->SetHairType(val, send_update);
  609. break;
  610. }
  611. case SPAWN_SET_VALUE_WING_TYPE:{
  612. if(target->IsEntity())
  613. ((Entity*)target)->SetWingType(val, send_update);
  614. break;
  615. }
  616. case SPAWN_SET_VALUE_CHEST_TYPE:{
  617. if(target->IsEntity())
  618. ((Entity*)target)->SetChestType(val, send_update);
  619. break;
  620. }
  621. case SPAWN_SET_VALUE_LEGS_TYPE:{
  622. if(target->IsEntity())
  623. ((Entity*)target)->SetLegsType(val, send_update);
  624. break;
  625. }
  626. case SPAWN_SET_VALUE_SOGA_HAIR_TYPE:{
  627. if(target->IsEntity())
  628. ((Entity*)target)->SetSogaHairType(val, send_update);
  629. break;
  630. }
  631. case SPAWN_SET_VALUE_SOGA_FACIAL_HAIR_TYPE:{
  632. if(target->IsEntity())
  633. ((Entity*)target)->SetSogaFacialHairType(val, send_update);
  634. break;
  635. }
  636. case SPAWN_SET_VALUE_SOGA_MODEL_TYPE:{
  637. target->SetSogaModelType(val, send_update);
  638. break;
  639. }
  640. case SPAWN_SET_VALUE_SIZE:{
  641. target->SetSize(val, send_update);
  642. break;
  643. }
  644. case SPAWN_SET_VALUE_HP:{
  645. target->SetHP(val, send_update);
  646. break;
  647. }
  648. case SPAWN_SET_VALUE_POWER:{
  649. target->SetPower(val, send_update);
  650. break;
  651. }
  652. case SPAWN_SET_VALUE_HEROIC:{
  653. target->SetHeroic(val, send_update);
  654. break;
  655. }
  656. case SPAWN_SET_VALUE_RESPAWN:{
  657. target->SetRespawnTime(val);
  658. break;
  659. }
  660. case SPAWN_SET_VALUE_X:{
  661. target->SetX(atof(value), send_update);
  662. target->SetSpawnOrigX(target->GetX());
  663. break;
  664. }
  665. case SPAWN_SET_VALUE_Y:{
  666. target->SetY(atof(value), send_update);
  667. target->SetSpawnOrigY(target->GetY());
  668. break;
  669. }
  670. case SPAWN_SET_VALUE_Z:{
  671. target->SetZ(atof(value), send_update);
  672. target->SetSpawnOrigZ(target->GetZ());
  673. break;
  674. }
  675. case SPAWN_SET_VALUE_HEADING:{
  676. target->SetHeading(atof(value), send_update);
  677. target->SetSpawnOrigHeading(target->GetHeading());
  678. break;
  679. }
  680. case SPAWN_SET_VALUE_COMMAND_PRIMARY:{
  681. ZoneServer* zone = target->GetZone();
  682. if (!zone)
  683. zone = client->GetCurrentZone();
  684. if(zone->GetEntityCommandList(val))
  685. target->SetPrimaryCommands(zone->GetEntityCommandList(val));
  686. target->primary_command_list_id = val;
  687. break;
  688. }
  689. case SPAWN_SET_VALUE_COMMAND_SECONDARY:{
  690. ZoneServer* zone = target->GetZone();
  691. if (!zone)
  692. zone = client->GetCurrentZone();
  693. if (zone->GetEntityCommandList(val))
  694. target->SetSecondaryCommands(zone->GetEntityCommandList(val));
  695. target->secondary_command_list_id = val;
  696. break;
  697. }
  698. case SPAWN_SET_VALUE_VISUAL_STATE:{
  699. target->SetVisualState(val, send_update);
  700. break;
  701. }
  702. case SPAWN_SET_VALUE_ACTION_STATE:{
  703. target->SetActionState(val, send_update);
  704. break;
  705. }
  706. case SPAWN_SET_VALUE_MOOD_STATE:{
  707. target->SetMoodState(val, send_update);
  708. break;
  709. }
  710. case SPAWN_SET_VALUE_INITIAL_STATE:{
  711. target->SetInitialState(val, send_update);
  712. break;
  713. }
  714. case SPAWN_SET_VALUE_ACTIVITY_STATE:{
  715. target->SetActivityStatus(val, send_update);
  716. break;
  717. }
  718. case SPAWN_SET_VALUE_COLLISION_RADIUS:{
  719. target->SetCollisionRadius(val, send_update);
  720. break;
  721. }
  722. case SPAWN_SET_VALUE_FACTION:{
  723. ZoneServer* zone = target->GetZone();
  724. if (!zone)
  725. zone = client->GetCurrentZone();
  726. target->faction_id = val;
  727. zone->RemoveDeadEnemyList(target);
  728. if(target->IsNPC())
  729. zone->AddEnemyList((NPC*)target);
  730. break;
  731. }
  732. case SPAWN_SET_VALUE_DEVICE_ID:{
  733. if (target->IsObject())
  734. ((Object*)target)->SetDeviceID(val);
  735. break;
  736. }
  737. case SPAWN_SET_VALUE_PITCH: {
  738. target->SetPitch(atof(value), send_update);
  739. target->SetSpawnOrigPitch(atof(value));
  740. break;
  741. }
  742. case SPAWN_SET_VALUE_ROLL: {
  743. target->SetRoll(atof(value), send_update);
  744. target->SetSpawnOrigRoll(atof(value));
  745. break;
  746. }
  747. case SPAWN_SET_VALUE_HIDE_HOOD: {
  748. target->SetHideHood(val);
  749. break;
  750. }
  751. case SPAWN_SET_VALUE_EMOTE_STATE: {
  752. target->SetEmoteState(val);
  753. break;
  754. }
  755. case SPAWN_SET_VALUE_ICON: {
  756. target->SetIcon(val);
  757. break;
  758. }
  759. case SPAWN_SET_VALUE_PREFIX: {
  760. target->SetPrefixTitle(value);
  761. client->GetCurrentZone()->SendUpdateTitles(target);
  762. break;
  763. }
  764. case SPAWN_SET_VALUE_SUFFIX: {
  765. target->SetSuffixTitle(value);
  766. client->GetCurrentZone()->SendUpdateTitles(target);
  767. break;
  768. }
  769. case SPAWN_SET_VALUE_LASTNAME: {
  770. target->SetLastName(value);
  771. client->GetCurrentZone()->SendUpdateTitles(target);
  772. break;
  773. }
  774. case SPAWN_SET_VALUE_SPAWN_SCRIPT:{
  775. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  776. if(client){
  777. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  778. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawn_script 'SpawnScripts/example.lua'");
  779. }
  780. return false;
  781. }
  782. else if(!database.UpdateSpawnScriptData(target->GetDatabaseID(), 0, 0, value))
  783. return false;
  784. else{
  785. if(!world.GetSpawnLocationScript(target->GetSpawnLocationID()))
  786. target->SetSpawnScript(value);
  787. }
  788. break;
  789. }
  790. case SPAWN_SET_VALUE_SPAWNLOCATION_SCRIPT:{
  791. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  792. if(client){
  793. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  794. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawnlocation_script 'SpawnScripts/example.lua'");
  795. }
  796. return false;
  797. }
  798. else if(!database.UpdateSpawnScriptData(0, target->GetSpawnLocationID(), 0, value))
  799. return false;
  800. else{
  801. if(!world.GetSpawnEntryScript(target->GetSpawnEntryID()))
  802. target->SetSpawnScript(value);
  803. }
  804. break;
  805. }
  806. case SPAWN_SET_VALUE_SPAWNENTRY_SCRIPT:{
  807. if(lua_interface && lua_interface->GetSpawnScript(value) == 0){
  808. if(client){
  809. client->Message(CHANNEL_COLOR_RED, "Invalid Spawn Script file. Be sure you give the absolute path.");
  810. client->Message(CHANNEL_COLOR_RED, "Example: /spawn set spawnentry_script 'SpawnScripts/example.lua'");
  811. }
  812. return false;
  813. }
  814. else if(!database.UpdateSpawnScriptData(0, 0, target->GetSpawnEntryID(), value))
  815. return false;
  816. else
  817. target->SetSpawnScript(value);
  818. break;
  819. }
  820. }
  821. }
  822. return true;
  823. }
  824. /* The zone object will be NULL if the zone is not currently running. We pass both of these in so we can update
  825. the database fields always and also update the zone in memory if it's running. */
  826. bool Commands::SetZoneCommand(Client* client, int32 zone_id, ZoneServer* zone, int8 type, const char* value) {
  827. if (client && zone_id > 0 && type > 0 && value) {
  828. sint32 int_value = 0;
  829. float float_value = 0;
  830. if (type == ZONE_SET_VALUE_SAFE_X || type == ZONE_SET_VALUE_SAFE_Y || type == ZONE_SET_VALUE_SAFE_Z || type == ZONE_SET_VALUE_UNDERWORLD) {
  831. try {
  832. float_value = atof(value);
  833. }
  834. catch (...) {
  835. client->Message(CHANNEL_COLOR_RED, "Error converting '%s' to a float value", value);
  836. return false;
  837. }
  838. }
  839. else if (type != ZONE_SET_VALUE_NAME && type != ZONE_SET_VALUE_FILE && type != ZONE_SET_VALUE_DESCRIPTION && type != ZONE_SET_VALUE_ZONE_TYPE && type != ZONE_SET_VALUE_LUA_SCRIPT && type != ZONE_SET_VALUE_ZONE_MOTD) {
  840. try {
  841. int_value = atoi(value);
  842. }
  843. catch (...) {
  844. client->Message(CHANNEL_COLOR_RED, "Error converting '%s' to an integer value", value);
  845. return false;
  846. }
  847. }
  848. switch (type) {
  849. case ZONE_SET_VALUE_EXPANSION_ID: {
  850. break;
  851. }
  852. case ZONE_SET_VALUE_NAME: {
  853. if (zone)
  854. zone->SetZoneName(const_cast<char*>(value));
  855. database.SaveZoneInfo(zone_id, "name", value);
  856. break;
  857. }
  858. case ZONE_SET_VALUE_FILE: {
  859. if (zone)
  860. zone->SetZoneFile(const_cast<char*>(value));
  861. database.SaveZoneInfo(zone_id, "file", value);
  862. break;
  863. }
  864. case ZONE_SET_VALUE_DESCRIPTION: {
  865. if (zone)
  866. zone->SetZoneDescription(const_cast<char*>(value));
  867. database.SaveZoneInfo(zone_id, "description", value);
  868. break;
  869. }
  870. case ZONE_SET_VALUE_SAFE_X: {
  871. if (zone)
  872. zone->SetSafeX(float_value);
  873. database.SaveZoneInfo(zone_id, "safe_x", float_value);
  874. break;
  875. }
  876. case ZONE_SET_VALUE_SAFE_Y: {
  877. if (zone)
  878. zone->SetSafeY(float_value);
  879. database.SaveZoneInfo(zone_id, "safe_y", float_value);
  880. break;
  881. }
  882. case ZONE_SET_VALUE_SAFE_Z: {
  883. if (zone)
  884. zone->SetSafeZ(float_value);
  885. database.SaveZoneInfo(zone_id, "safe_z", float_value);
  886. break;
  887. }
  888. case ZONE_SET_VALUE_UNDERWORLD: {
  889. if (zone)
  890. zone->SetUnderWorld(float_value);
  891. database.SaveZoneInfo(zone_id, "underworld", float_value);
  892. break;
  893. }
  894. case ZONE_SET_VALUE_MIN_RECOMMENDED: {
  895. break;
  896. }
  897. case ZONE_SET_VALUE_MAX_RECOMMENDED: {
  898. break;
  899. }
  900. case ZONE_SET_VALUE_ZONE_TYPE: {
  901. break;
  902. }
  903. case ZONE_SET_VALUE_ALWAYS_LOADED: {
  904. if (zone)
  905. zone->SetAlwaysLoaded(int_value == 1);
  906. database.SaveZoneInfo(zone_id, "always_loaded", int_value);
  907. break;
  908. }
  909. case ZONE_SET_VALUE_CITY_ZONE: {
  910. if (zone)
  911. zone->SetCityZone(int_value == 1);
  912. database.SaveZoneInfo(zone_id, "city_zone", int_value);
  913. break;
  914. }
  915. case ZONE_SET_VALUE_WEATHER_ALLOWED: {
  916. if (zone)
  917. zone->SetWeatherAllowed(int_value == 1);
  918. database.SaveZoneInfo(zone_id, "weather_allowed", int_value);
  919. break;
  920. }
  921. case ZONE_SET_VALUE_MIN_STATUS: {
  922. if (zone)
  923. zone->SetMinimumStatus(int_value);
  924. database.SaveZoneInfo(zone_id, "min_status", int_value);
  925. break;
  926. }
  927. case ZONE_SET_VALUE_MIN_LEVEL: {
  928. if (zone)
  929. zone->SetMinimumLevel(int_value);
  930. database.SaveZoneInfo(zone_id, "min_level", int_value);
  931. break;
  932. }
  933. case ZONE_SET_VALUE_MAX_LEVEL: {
  934. if (zone)
  935. zone->SetMaximumLevel(int_value);
  936. database.SaveZoneInfo(zone_id, "max_level", int_value);
  937. break;
  938. }
  939. case ZONE_SET_VALUE_START_ZONE: {
  940. database.SaveZoneInfo(zone_id, "start_zone", int_value);
  941. break;
  942. }
  943. case ZONE_SET_VALUE_INSTANCE_TYPE: {
  944. if (zone)
  945. zone->SetInstanceType(int_value);
  946. database.SaveZoneInfo(zone_id, "instance_type", int_value);
  947. break;
  948. }
  949. case ZONE_SET_VALUE_DEFAULT_REENTER_TIME: {
  950. if (zone)
  951. zone->SetDefaultReenterTime(int_value);
  952. database.SaveZoneInfo(zone_id, "default_reenter_time", int_value);
  953. break;
  954. }
  955. case ZONE_SET_VALUE_DEFAULT_RESET_TIME: {
  956. if (zone)
  957. zone->SetDefaultResetTime(int_value);
  958. database.SaveZoneInfo(zone_id, "default_reset_time", int_value);
  959. break;
  960. }
  961. case ZONE_SET_VALUE_DEFAULT_LOCKOUT_TIME: {
  962. if (zone)
  963. zone->SetDefaultLockoutTime(int_value);
  964. database.SaveZoneInfo(zone_id, "default_lockout_time", int_value);
  965. break;
  966. }
  967. case ZONE_SET_VALUE_FORCE_GROUP_TO_ZONE: {
  968. if (zone)
  969. zone->SetForceGroupZoneOption(int_value);
  970. database.SaveZoneInfo(zone_id, "force_group_to_zone", int_value);
  971. break;
  972. }
  973. case ZONE_SET_VALUE_LUA_SCRIPT: {
  974. if (lua_interface && lua_interface->GetZoneScript(value) == 0) {
  975. client->Message(CHANNEL_COLOR_RED, "Invalid Zone Script file. Be sure you give the absolute path.");
  976. client->Message(CHANNEL_COLOR_RED, "Example: /zone set lua_script 'ZoneScripts/QueensColony.lua'");
  977. return false;
  978. }
  979. else {
  980. world.AddZoneScript(zone_id, const_cast<char*>(value));
  981. database.SaveZoneInfo(zone_id, "lua_script", value);
  982. }
  983. break;
  984. }
  985. case ZONE_SET_VALUE_SHUTDOWN_TIMER: {
  986. if (zone)
  987. zone->SetShutdownTimer(int_value);
  988. database.SaveZoneInfo(zone_id, "shutdown_timer", int_value);
  989. break;
  990. }
  991. case ZONE_SET_VALUE_ZONE_MOTD: {
  992. if (zone)
  993. zone->SetZoneMOTD(string(value));
  994. database.SaveZoneInfo(zone_id, "zone_motd", value);
  995. break;
  996. }
  997. default: {
  998. client->Message(CHANNEL_COLOR_RED, "Invalid zone attribute %i", type);
  999. return false;
  1000. }
  1001. }
  1002. }
  1003. else {
  1004. if (client)
  1005. client->SimpleMessage(CHANNEL_COLOR_RED, "An error occured saving new zone data.");
  1006. return false;
  1007. }
  1008. return true;
  1009. }
  1010. void Commands::Process(int32 index, EQ2_16BitString* command_parms, Client* client, Spawn* targetOverride) {
  1011. if (index >= remote_commands->commands.size()) {
  1012. LogWrite(COMMAND__ERROR, 0, "Command", "Error, command handler of %u was requested, but max handler is %u", index, remote_commands->commands.size());
  1013. return;
  1014. }
  1015. Spawn* cmdTarget = targetOverride ? targetOverride : client->GetPlayer()->GetTarget();
  1016. EQ2_RemoteCommandString* parent_command = 0;
  1017. EQ2_RemoteCommandString* command = &remote_commands->commands[index];
  1018. Seperator* sep = 0;
  1019. if (command_parms->size > 0) {
  1020. sep = new Seperator(command_parms->data.c_str(), ' ', 10, 500, true);
  1021. if (sep && sep->arg[0] && remote_commands->validSubCommand(command->command.data, string(sep->arg[0]))) {
  1022. parent_command = command;
  1023. command = &(remote_commands->subcommands[command->command.data][string(sep->arg[0])]);
  1024. safe_delete(sep);
  1025. if (command_parms->data.length() > (command->command.data.length() + 1))
  1026. sep = new Seperator(command_parms->data.c_str() + (command->command.data.length() + 1), ' ', 10, 500, true);
  1027. LogWrite(COMMAND__DEBUG, 1, "Command", "Handler: %u, COMMAND: '%s', SUBCOMMAND: '%s'", index, parent_command->command.data.c_str(), command->command.data.c_str());
  1028. }
  1029. else
  1030. LogWrite(COMMAND__DEBUG, 1, "Command", "Handler: %u, COMMAND: '%s'", index, command->command.data.c_str());
  1031. }
  1032. int ndx = 0;
  1033. if (command->required_status > client->GetAdminStatus())
  1034. {
  1035. LogWrite(COMMAND__ERROR, 0, "Command", "Player '%s' (%u) needs status %i to use command: %s", client->GetPlayer()->GetName(), client->GetAccountID(), command->required_status, command->command.data.c_str());
  1036. safe_delete(sep);
  1037. client->SimpleMessage(3, "Error: Your status is insufficient for this command.");
  1038. return;
  1039. }
  1040. Player* player = client->GetPlayer();
  1041. LogWrite(COMMAND__DEBUG, 0, "Command", "Player '%s' (%u), Command: %s", player->GetName(), client->GetAccountID(), command->command.data.c_str());
  1042. switch (command->handler) {
  1043. case COMMAND_RELOAD: {
  1044. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reload commands:");
  1045. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload structs");
  1046. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload items");
  1047. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload luasystem");
  1048. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spawnscripts");
  1049. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spells");
  1050. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload quests");
  1051. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload spawns");
  1052. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload groundspawns");
  1053. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload zonescripts");
  1054. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload entity_commands");
  1055. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload factions");
  1056. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload mail");
  1057. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload guilds");
  1058. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload locations");
  1059. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload rules");
  1060. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload transporters");
  1061. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload startabilities");
  1062. break;
  1063. }
  1064. case COMMAND_RELOADSTRUCTS: {
  1065. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Structs...");
  1066. configReader.ReloadStructs();
  1067. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1068. break;
  1069. }
  1070. case COMMAND_RELOAD_QUESTS: {
  1071. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Quests...");
  1072. master_quest_list.Reload();
  1073. client_list.ReloadQuests();
  1074. zone_list.ReloadClientQuests();
  1075. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1076. break;
  1077. }
  1078. case COMMAND_RELOAD_SPAWNS: {
  1079. client->GetCurrentZone()->ReloadSpawns();
  1080. break;
  1081. }
  1082. case COMMAND_RELOAD_SPELLS: {
  1083. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spells...");
  1084. zone_list.DeleteSpellProcess();
  1085. master_spell_list.Reload();
  1086. if (lua_interface)
  1087. lua_interface->ReloadSpells();
  1088. zone_list.LoadSpellProcess();
  1089. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1090. break;
  1091. }
  1092. case COMMAND_RELOAD_GROUNDSPAWNS: {
  1093. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Groundspawn Entries...");
  1094. client->GetCurrentZone()->DeleteGroundSpawnItems();
  1095. client->GetCurrentZone()->LoadGroundSpawnEntries();
  1096. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1097. break;
  1098. }
  1099. case COMMAND_RELOAD_ZONESCRIPTS: {
  1100. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Zone Scripts...");
  1101. world.ResetZoneScripts();
  1102. database.LoadZoneScriptData();
  1103. if (lua_interface)
  1104. lua_interface->DestroyZoneScripts();
  1105. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1106. break;
  1107. }
  1108. case COMMAND_RELOAD_ENTITYCOMMANDS: {
  1109. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Entity Commands...");
  1110. client->GetCurrentZone()->ClearEntityCommands();
  1111. database.LoadEntityCommands(client->GetCurrentZone());
  1112. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1113. break;
  1114. }
  1115. case COMMAND_RELOAD_FACTIONS: {
  1116. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Factions...");
  1117. master_faction_list.Clear();
  1118. database.LoadFactionList();
  1119. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1120. break;
  1121. }
  1122. case COMMAND_RELOAD_MAIL: {
  1123. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Mail...");
  1124. zone_list.ReloadMail();
  1125. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1126. break;
  1127. }
  1128. case COMMAND_RELOAD_GUILDS: {
  1129. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Guilds...");
  1130. world.ReloadGuilds();
  1131. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1132. break;
  1133. }
  1134. case COMMAND_RELOAD_LOCATIONS: {
  1135. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Locations...");
  1136. client->GetPlayer()->GetZone()->RemoveLocationGrids();
  1137. database.LoadLocationGrids(client->GetPlayer()->GetZone());
  1138. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1139. break;
  1140. }
  1141. case COMMAND_RELOAD_RULES: {
  1142. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Rules...");
  1143. database.LoadRuleSets(true);
  1144. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1145. break;
  1146. }
  1147. case COMMAND_RELOAD_TRANSPORTERS: {
  1148. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Transporters in your current zone...");
  1149. database.LoadTransporters(client->GetCurrentZone());
  1150. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1151. break;
  1152. }
  1153. case COMMAND_RELOAD_STARTABILITIES: {
  1154. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Starting Skills/Spells...");
  1155. world.PurgeStartingLists();
  1156. world.LoadStartingLists();
  1157. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
  1158. break;
  1159. }
  1160. case COMMAND_READ: {
  1161. if (sep && sep->arg[1][0] && sep->IsNumber(1)) {
  1162. if (strcmp(sep->arg[0], "read") == 0) {
  1163. int32 item_index = atol(sep->arg[1]);
  1164. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  1165. if (item) {
  1166. Spawn* spawn = cmdTarget;
  1167. client->SendShowBook(client->GetPlayer(), item->name, item->book_pages);
  1168. break;
  1169. }
  1170. }
  1171. }
  1172. break;
  1173. }
  1174. case COMMAND_USEABILITY:{
  1175. if (sep && sep->arg[0][0] && sep->IsNumber(0)) {
  1176. if (client->GetPlayer()->GetHP() == 0) {
  1177. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot do that right now.");
  1178. }
  1179. else {
  1180. int32 spell_id = atoul(sep->arg[0]);
  1181. int8 spell_tier = 0;
  1182. if (sep->arg[1][0] && sep->IsNumber(1))
  1183. spell_tier = atoi(sep->arg[1]);
  1184. else
  1185. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  1186. if (!spell_tier)
  1187. spell_tier = 1;
  1188. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  1189. if (spell) {
  1190. 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)
  1191. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), cmdTarget, true, true);
  1192. else
  1193. {
  1194. if (cmdTarget)
  1195. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), cmdTarget);
  1196. else
  1197. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  1198. }
  1199. }
  1200. }
  1201. }
  1202. else if (cmdTarget && cmdTarget->IsWidget())
  1203. {
  1204. Widget* widget = (Widget*)cmdTarget;
  1205. widget->HandleUse(client, "use", WIDGET_TYPE_DOOR);
  1206. }
  1207. else
  1208. {
  1209. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /useability {spell_id} [spell_tier]");
  1210. }
  1211. break;
  1212. }
  1213. case COMMAND_INFO:{
  1214. if(sep && sep->arg[1][0] && sep->IsNumber(1)){
  1215. if(strcmp(sep->arg[0], "inventory") == 0){
  1216. int32 item_index = atol(sep->arg[1]);
  1217. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(item_index);
  1218. if(item){
  1219. if (item->IsCollectable() && client->SendCollectionsForItem(item))
  1220. break;
  1221. EQ2Packet* app = item->serialize(client->GetVersion(), (!item->GetItemScript() || !lua_interface), client->GetPlayer());
  1222. //DumpPacket(app);
  1223. client->QueuePacket(app);
  1224. if(item->GetItemScript() && lua_interface)
  1225. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  1226. else if(item->generic_info.offers_quest_id > 0){ //leave the current functionality in place if it doesnt have an item script
  1227. Quest* quest = master_quest_list.GetQuest(item->generic_info.offers_quest_id);
  1228. if(quest && client->GetPlayer()->GetCompletedQuest(item->generic_info.offers_quest_id) == 0 && client->GetPlayer()->GetQuest(item->generic_info.offers_quest_id) == 0)
  1229. client->AddPendingQuest(quest);
  1230. }
  1231. }
  1232. else
  1233. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Index: %u", item_index);
  1234. }
  1235. else if(strcmp(sep->arg[0], "equipment") == 0){
  1236. int32 item_index = atol(sep->arg[1]);
  1237. Item* item = client->GetPlayer()->GetEquipmentList()->GetItem(item_index);
  1238. if(item){
  1239. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1240. client->QueuePacket(app);
  1241. if(item->GetItemScript() && lua_interface)
  1242. lua_interface->RunItemScript(item->GetItemScript(), "examined", item, client->GetPlayer());
  1243. }
  1244. else
  1245. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Index: %u", item_index);
  1246. }
  1247. 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){
  1248. int32 item_id = atoul(sep->arg[1]);
  1249. Item* item = master_item_list.GetItem(item_id);
  1250. if(item){
  1251. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1252. client->QueuePacket(app);
  1253. }
  1254. else
  1255. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Item ID: %u", item_id);
  1256. }
  1257. else if (strcmp(sep->arg[0], "spell") == 0) {
  1258. sint32 spell_id = atol(sep->arg[1]);
  1259. int8 tier = atoi(sep->arg[3]);
  1260. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, tier, client, true, 0x2A);
  1261. if (outapp)
  1262. client->QueuePacket(outapp);
  1263. else
  1264. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  1265. }
  1266. else if (strcmp(sep->arg[0], "achievement") == 0) {
  1267. sint32 spell_id = atol(sep->arg[2]);
  1268. int8 group = atoi(sep->arg[1]);
  1269. AltAdvanceData* data = 0;
  1270. SpellBookEntry* spellentry = 0;
  1271. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  1272. LogWrite(COMMAND__ERROR, 0, "Command", "AA Spell ID and/or Tier, ID: %u, Group: %i", spell_id, group);
  1273. EQ2Packet* outapp = master_spell_list.GetAASpellPacket(spell_id, tier, client, true, 0x45);
  1274. if (outapp)
  1275. client->QueuePacket(outapp);
  1276. else
  1277. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, group);
  1278. }
  1279. else if (strcmp(sep->arg[0], "spellbook") == 0) {
  1280. sint32 spell_id = atol(sep->arg[1]);
  1281. int8 tier = atoi(sep->arg[2]);
  1282. EQ2Packet* outapp = master_spell_list.GetSpellPacket(spell_id, tier, client, true, 0x2A);
  1283. if (outapp)
  1284. client->QueuePacket(outapp);
  1285. else
  1286. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID and/or Tier, ID: %u, Tier: %i", spell_id, tier);
  1287. }
  1288. else if (strcmp(sep->arg[0], "recipe") == 0) {
  1289. sint32 recipe_id = atol(sep->arg[1]);
  1290. EQ2Packet* outapp = master_recipe_list.GetRecipePacket(recipe_id, client, true, 0x2C);
  1291. if(outapp)
  1292. client->QueuePacket(outapp);
  1293. else
  1294. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Recipe ID: %u", recipe_id);
  1295. }
  1296. else if (strcmp(sep->arg[0], "maintained") ==0) {
  1297. int32 slot = atol(sep->arg[1]);
  1298. int32 spell_id = atol(sep->arg[2]);
  1299. LogWrite(COMMAND__DEBUG, 5, "Command", "Unknown Spell ID - Slot: %u unknown: %u", slot, spell_id);
  1300. //int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  1301. MaintainedEffects* info = client->GetPlayer()->GetMaintainedSpellBySlot(slot);
  1302. EQ2Packet* outapp = master_spell_list.GetSpellPacket(info->spell_id, info->tier, client, true, 0x00);
  1303. if(outapp)
  1304. client->QueuePacket(outapp);
  1305. else
  1306. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID: %u", spell_id);
  1307. }
  1308. else if (strcmp(sep->arg[0], "effect") == 0) {
  1309. int32 spell_id = atol(sep->arg[1]);
  1310. LogWrite(COMMAND__DEBUG, 5, "Command", "Unknown Spell ID: %u", spell_id);
  1311. int8 tier = client->GetPlayer()->GetSpellTier(spell_id);
  1312. int8 type = 0;
  1313. if (client->GetVersion() <= 283)
  1314. type = 1;
  1315. EQ2Packet* outapp = master_spell_list.GetSpecialSpellPacket(spell_id, tier, client, true, type);
  1316. if (outapp){
  1317. client->QueuePacket(outapp);
  1318. }
  1319. else
  1320. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown Spell ID: %u", spell_id);
  1321. }
  1322. }
  1323. else if (sep && strcmp(sep->arg[0], "overflow") == 0) {
  1324. Item* item = player->item_list.GetOverflowItem();
  1325. if(item) {
  1326. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  1327. client->QueuePacket(app);
  1328. }
  1329. else
  1330. LogWrite(COMMAND__ERROR, 0,"Command", "Unable to retrieve an overflow item.");
  1331. }
  1332. else
  1333. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /info {inventory|equipment|spell} {id}");
  1334. break;
  1335. }
  1336. case COMMAND_USE_EQUIPPED_ITEM:{
  1337. if (sep && sep->arg[0] && sep->IsNumber(0)){
  1338. int32 slot_id = atoul(sep->arg[0]);
  1339. Item* item = player->GetEquipmentList()->GetItem(slot_id);
  1340. if (item && item->generic_info.usable && item->GetItemScript())
  1341. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player);
  1342. }
  1343. break;
  1344. }
  1345. case COMMAND_USE_ITEM: {
  1346. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  1347. int32 item_index = atoul(sep->arg[0]);
  1348. Item* item = player->item_list.GetItemFromIndex(item_index);
  1349. if (item && item->GetItemScript()) {
  1350. if (item->generic_info.max_charges == 0 || item->generic_info.max_charges == 0xFFFF)
  1351. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player);
  1352. else {
  1353. if (item->generic_info.display_charges > 0) {
  1354. lua_interface->RunItemScript(item->GetItemScript(), "used", item, player);
  1355. item->generic_info.display_charges -= 1;
  1356. item->save_needed = true;
  1357. client->QueuePacket(item->serialize(client->GetVersion(), false, client->GetPlayer()));
  1358. }
  1359. }
  1360. }
  1361. }
  1362. break;
  1363. }
  1364. case COMMAND_SCRIBE_SCROLL_ITEM: {
  1365. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  1366. Item* item = player->item_list.GetItemFromUniqueID(atoul(sep->arg[0]));
  1367. if (item) {
  1368. LogWrite(ITEM__DEBUG, 0, "Items", "ITEM ID: %u", item->details.item_id);
  1369. if(item->generic_info.item_type == 6) {
  1370. Spell* spell = master_spell_list.GetSpell(item->skill_info->spell_id, item->skill_info->spell_tier);
  1371. int8 old_slot = 0;
  1372. if (spell) {
  1373. if (!player->HasSpell(spell->GetSpellID(), spell->GetSpellTier(), true)) {
  1374. old_slot = player->GetSpellSlot(spell->GetSpellID());
  1375. player->RemoveSpellBookEntry(spell->GetSpellID());
  1376. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  1377. player->UnlockSpell(spell);
  1378. client->SendSpellUpdate(spell);
  1379. database.DeleteItem(client->GetCharacterID(), item, 0);
  1380. player->item_list.RemoveItem(item, true);
  1381. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  1382. client->QueuePacket(player->SendInventoryUpdate(client->GetVersion()));
  1383. }
  1384. }
  1385. else
  1386. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown spell ID: %u and tier: %u", item->skill_info->spell_id, item->skill_info->spell_tier);
  1387. }
  1388. else if(item->generic_info.item_type == 7){
  1389. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Scribing recipe book %s (%u) for player %s.", item->name.c_str(), item->details.item_id, player->GetName());
  1390. Recipe* recipe_book = new Recipe(master_recipebook_list.GetRecipeBooks(item->details.item_id));
  1391. // if valid recipe book and the player doesn't have it
  1392. if (recipe_book && recipe_book->GetLevel() > client->GetPlayer()->GetTSLevel()) {
  1393. client->Message(CHANNEL_COLOR_WHITE, "Your tradeskill level is not high enough to scribe this book.");
  1394. safe_delete(recipe_book);
  1395. }
  1396. else if (recipe_book && !(client->GetPlayer()->GetRecipeBookList()->HasRecipeBook(item->details.item_id))) {
  1397. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Valid recipe book that the player doesn't have");
  1398. // Add recipe book to the players list
  1399. client->GetPlayer()->GetRecipeBookList()->AddRecipeBook(recipe_book);
  1400. // Get a list of all recipes this book contains
  1401. vector<Recipe*>* book_recipes = master_recipe_list.GetRecipes(recipe_book->GetBookName());
  1402. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "%i recipes found for %s book", book_recipes->size(), recipe_book->GetBookName());
  1403. // Create the packet to send to update the players recipe list
  1404. PacketStruct* packet = 0;
  1405. if (client->GetRecipeListSent()) {
  1406. packet = configReader.getStruct("WS_RecipeList", client->GetVersion());
  1407. if (packet)
  1408. packet->setArrayLengthByName("num_recipes", book_recipes->size());
  1409. }
  1410. // loop through the list
  1411. vector<Recipe*>::iterator itr;
  1412. int16 i = 0;
  1413. for (itr = book_recipes->begin(); itr != book_recipes->end(); itr++) {
  1414. // check to see if the player already has this recipe some how
  1415. if (!client->GetPlayer()->GetRecipeList()->GetRecipe((*itr)->GetID())) {
  1416. // Player doesn't already have this recipe so lets add it
  1417. Recipe* recipe = new Recipe(master_recipe_list.GetRecipe((*itr)->GetID()));
  1418. client->GetPlayer()->GetRecipeList()->AddRecipe(recipe);
  1419. database.SavePlayerRecipe(client->GetPlayer(), recipe->GetID());
  1420. client->Message(CHANNEL_COLOR_WHITE, "Recipe: \"%s\" put in recipe book.", recipe->GetName());
  1421. if (packet && client->GetRecipeListSent()) {
  1422. packet->setArrayDataByName("id", recipe->GetID(), i);
  1423. packet->setArrayDataByName("tier", recipe->GetTier(), i);
  1424. packet->setArrayDataByName("level", recipe->GetLevel(), i);
  1425. packet->setArrayDataByName("icon", recipe->GetIcon(), i);
  1426. packet->setArrayDataByName("classes", recipe->GetClasses(), i);
  1427. packet->setArrayDataByName("skill", recipe->GetSkill(), i);
  1428. packet->setArrayDataByName("technique", recipe->GetTechnique(), i);
  1429. packet->setArrayDataByName("knowledge", recipe->GetKnowledge(), i);
  1430. packet->setArrayDataByName("unknown2", recipe->GetUnknown2(), i);
  1431. packet->setArrayDataByName("recipe_name", recipe->GetName(), i);
  1432. packet->setArrayDataByName("recipe_book", recipe->GetBook(), i);
  1433. packet->setArrayDataByName("unknown3", recipe->GetUnknown3(), i);
  1434. i++;
  1435. }
  1436. }
  1437. }
  1438. LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Done adding recipes");
  1439. database.SavePlayerRecipeBook(client->GetPlayer(), recipe_book->GetBookID());
  1440. database.DeleteItem(client->GetCharacterID(), item, 0);
  1441. client->GetPlayer()->item_list.RemoveItem(item, true);
  1442. client->QueuePacket(client->GetPlayer()->SendInventoryUpdate(client->GetVersion()));
  1443. if (packet && client->GetRecipeListSent())
  1444. client->QueuePacket(packet->serialize());
  1445. safe_delete(packet);
  1446. }
  1447. else {
  1448. if (recipe_book)
  1449. client->Message(CHANNEL_COLOR_WHITE, "You have already learned all you can from this item.");
  1450. safe_delete(recipe_book);
  1451. }
  1452. }
  1453. }
  1454. else
  1455. LogWrite(COMMAND__ERROR, 0, "Command", "Unknown unique item ID: %s", sep->arg[0]);
  1456. }
  1457. break;
  1458. }
  1459. case COMMAND_SUMMONITEM: {
  1460. if (sep && sep->IsNumber(0)) {
  1461. int32 item_id = atol(sep->arg[0]);
  1462. int32 quantity = 1;
  1463. if (sep->arg[1] && sep->IsNumber(1))
  1464. quantity = atoi(sep->arg[1]);
  1465. if (sep->arg[2] && strncasecmp(sep->arg[2], "bank", 4) == 0) {
  1466. client->AddItemToBank(item_id,quantity);
  1467. }
  1468. else {
  1469. client->AddItem(item_id, quantity);
  1470. }
  1471. }
  1472. else {
  1473. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} [quantity] or");
  1474. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /summonitem {item_id} {quantity} [location] where location = bank");
  1475. }
  1476. break;
  1477. }
  1478. case COMMAND_COLLECTION_ADDITEM: {
  1479. // takes 2 params: collection_id, slot
  1480. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  1481. Item *item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(atoul(sep->arg[1]));
  1482. if (item)
  1483. client->HandleCollectionAddItem(atoul(sep->arg[0]), item);
  1484. else
  1485. 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]));
  1486. }
  1487. else
  1488. LogWrite(COLLECTION__ERROR, 0, "Collect", "Received command 'COMMAND_COLLECTION_ADDITEM' with unhandeled argument types");
  1489. break;
  1490. }
  1491. case COMMAND_COLLECTION_FILTER_MATCHITEM: {
  1492. // takes 1 param: slot
  1493. printf("COMMAND_COLLECTION_FILTER_MATCHITEM:\n");
  1494. int i = 0;
  1495. while (sep->arg[i] && strlen(sep->arg[i]) > 0) {
  1496. printf("\t%u: %s\n", i, sep->arg[i]);
  1497. i++;
  1498. }
  1499. break;
  1500. }
  1501. case COMMAND_WHO:{
  1502. const char* who = 0;
  1503. if(sep && sep->arg[0]){
  1504. //cout << "Who query: \n";
  1505. who = sep->argplus[0];
  1506. //cout << who << endl;
  1507. }
  1508. zone_list.ProcessWhoQuery(who, client);
  1509. break;
  1510. }
  1511. case COMMAND_SELECT_JUNCTION:{
  1512. 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__);
  1513. int32 choice = 0;
  1514. if(sep && sep->arg[0] && sep->IsNumber(0))
  1515. choice = atoul(sep->arg[0]);
  1516. if(client->GetPlayer()->GetHP() == 0){ //dead and this is a revive request
  1517. client->HandlePlayerRevive(choice);
  1518. }
  1519. break;
  1520. }
  1521. case COMMAND_SPAWN_MOVE: {
  1522. if (cmdTarget && cmdTarget->IsPlayer() == false) {
  1523. PacketStruct* packet = configReader.getStruct("WS_MoveObjectMode", client->GetVersion());
  1524. if (packet) {
  1525. float unknown2_3 = 0;
  1526. int8 placement_mode = 0;
  1527. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::DEFAULT);
  1528. if (sep && sep->arg[0][0]) {
  1529. if (strcmp(sep->arg[0], "wall") == 0) {
  1530. placement_mode = 2;
  1531. unknown2_3 = 150;
  1532. }
  1533. else if (strcmp(sep->arg[0], "ceiling") == 0)
  1534. placement_mode = 1;
  1535. else if (strcmp(sep->arg[0], "openheading") == 0 && cmdTarget->IsWidget())
  1536. {
  1537. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "[PlacementMode] WIDGET OPEN HEADING MODE");
  1538. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::OPEN_HEADING);
  1539. }
  1540. else if (strcmp(sep->arg[0], "closeheading") == 0 && cmdTarget->IsWidget())
  1541. {
  1542. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "[PlacementMode] WIDGET CLOSE HEADING MODE");
  1543. client->SetSpawnPlacementMode(Client::ServerSpawnPlacementMode::CLOSE_HEADING);
  1544. }
  1545. else if (strcmp(sep->arg[0], "myloc") == 0)
  1546. {
  1547. if (cmdTarget->GetSpawnLocationPlacementID() < 1) {
  1548. client->Message(CHANNEL_COLOR_YELLOW, "[PlacementMode] Spawn %s cannot be moved it is not assigned a spawn location placement id.", cmdTarget->GetName());
  1549. safe_delete(packet);
  1550. break;
  1551. }
  1552. cmdTarget->SetX(client->GetPlayer()->GetX(), true);
  1553. cmdTarget->SetY(client->GetPlayer()->GetY(), true);
  1554. cmdTarget->SetZ(client->GetPlayer()->GetZ(), true);
  1555. cmdTarget->SetHeading(client->GetPlayer()->GetHeading(), true);
  1556. if (database.UpdateSpawnLocationSpawns(cmdTarget))
  1557. client->Message(CHANNEL_COLOR_YELLOW, "[PlacementMode] Spawn %s placed at your location. Updated spawn_location_placement for spawn.", cmdTarget->GetName());
  1558. safe_delete(packet);
  1559. break;
  1560. }
  1561. }
  1562. packet->setDataByName("placement_mode", placement_mode);
  1563. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget));
  1564. packet->setDataByName("model_type", cmdTarget->GetModelType());
  1565. packet->setDataByName("unknown", 1); //size
  1566. packet->setDataByName("unknown2", 1); //size 2
  1567. packet->setDataByName("unknown2", .5, 1); //size 3
  1568. packet->setDataByName("unknown2", 3, 2);
  1569. packet->setDataByName("unknown2", unknown2_3, 3);
  1570. packet->setDataByName("max_distance", 500);
  1571. packet->setDataByName("CoEunknown", 0xFFFFFFFF);
  1572. client->QueuePacket(packet->serialize());
  1573. safe_delete(packet);
  1574. }
  1575. }
  1576. else {
  1577. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /spawn move (wall OR ceiling)");
  1578. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Moves a spawn anywhere you like. Optionally wall/ceiling can be provided to place wall/ceiling items.");
  1579. }
  1580. break;
  1581. }
  1582. case COMMAND_HAIL:{
  1583. Spawn* spawn = cmdTarget;
  1584. if(spawn && spawn->GetTargetable())
  1585. {
  1586. char tmp[75] = {0};
  1587. sprintf(tmp, "Hail, %s", spawn->GetName());
  1588. bool show_bubble = true;
  1589. if (spawn->IsNPC())
  1590. show_bubble = false;
  1591. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp, HEAR_SPAWN_DISTANCE, 0, show_bubble);
  1592. if(spawn->IsPlayer() == false && spawn->GetDistance(client->GetPlayer()) < 30){
  1593. if(spawn->IsNPC() && ((NPC*)spawn)->EngagedInCombat())
  1594. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED_BUSY, client->GetPlayer());
  1595. else
  1596. spawn->ProcessMovement();
  1597. LogWrite(MISC__TODO, 0, "Check", "ProcessMovement has been called");
  1598. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_HAILED, client->GetPlayer());
  1599. }
  1600. }
  1601. else {
  1602. string tmp = "Hail";
  1603. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, tmp.c_str(), HEAR_SPAWN_DISTANCE, 0, true);
  1604. }
  1605. break;
  1606. }
  1607. case COMMAND_SAY:{
  1608. if (sep && sep->arg[0][0]) {
  1609. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SAY, sep->argplus[0], HEAR_SPAWN_DISTANCE);
  1610. if (cmdTarget && !(cmdTarget->IsPlayer()))
  1611. client->GetCurrentZone()->CallSpawnScript(cmdTarget, SPAWN_SCRIPT_HEAR_SAY, client->GetPlayer(), sep->argplus[0]);
  1612. }
  1613. else
  1614. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /say {message}");
  1615. break;
  1616. }
  1617. case COMMAND_TELL:{
  1618. if(sep && sep->arg[0] && sep->argplus[1]){
  1619. if(!zone_list.HandleGlobalChatMessage(client, sep->arg[0], CHANNEL_TELL, sep->argplus[1]))
  1620. client->Message(CHANNEL_COLOR_RED,"Unable to find client %s",sep->arg[0]);
  1621. }else
  1622. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /tell {character_name} {message}");
  1623. break;
  1624. }
  1625. case COMMAND_SHOUT:{
  1626. if(sep && sep->arg[0][0])
  1627. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_SHOUT, sep->argplus[0]);
  1628. else
  1629. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /shout {message}");
  1630. break;
  1631. }
  1632. case COMMAND_AUCTION:{
  1633. if(sep && sep->arg[0][0])
  1634. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_AUCTION, sep->argplus[0]);
  1635. else
  1636. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /auction {message}");
  1637. break;
  1638. }
  1639. case COMMAND_OOC:{
  1640. //For now ooc will be the global chat channel, eventually when we create more channels we will create a global chat channel
  1641. if(sep && sep->arg[0][0])
  1642. zone_list.HandleGlobalChatMessage(client, 0, CHANNEL_OOC, sep->argplus[0]);
  1643. else
  1644. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /ooc {message}");
  1645. break;
  1646. }
  1647. case COMMAND_EMOTE:{
  1648. if(sep && sep->arg[0][0])
  1649. client->GetCurrentZone()->HandleChatMessage(client->GetPlayer(), 0, CHANNEL_EMOTE, sep->argplus[0]);
  1650. else
  1651. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /emote {action}");
  1652. break;
  1653. }
  1654. case COMMAND_RACE:{
  1655. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  1656. if(sep->arg[1][0] && sep->IsNumber(1)){
  1657. client->GetPlayer()->GetInfoStruct()->race = atoi(sep->arg[1]);
  1658. client->GetPlayer()->SetRace(atoi(sep->arg[1]));
  1659. client->UpdateTimeStampFlag ( RACE_UPDATE_FLAG );
  1660. client->GetPlayer()->SetCharSheetChanged(true);
  1661. }
  1662. client->GetPlayer()->SetModelType(atoi(sep->arg[0]));
  1663. //EQ2Packet* outapp = client->GetPlayer()->spawn_update_packet(client->GetPlayer(), client->GetVersion(), client->GetPlayer()->GetFeatures());
  1664. //client->QueuePacket(outapp);
  1665. }
  1666. else{
  1667. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /race {race type id} {race id}");
  1668. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "{race id} is optional");
  1669. }
  1670. break;
  1671. }
  1672. case COMMAND_BANK_DEPOSIT:{
  1673. if(client->GetBanker() && sep && sep->arg[0]){
  1674. int64 amount = 0;
  1675. string deposit = string(sep->arg[0]);
  1676. amount = atoi64(deposit.c_str());
  1677. client->BankDeposit(amount);
  1678. }
  1679. break;
  1680. }
  1681. case COMMAND_BANK_WITHDRAWAL:{
  1682. if(client->GetBanker() && sep && sep->arg[0] && sep->IsNumber(0)){
  1683. int64 amount = 0;
  1684. string deposit = string(sep->arg[0]);
  1685. amount = atoi64(deposit.c_str());
  1686. client->BankWithdrawal(amount);
  1687. }
  1688. break;
  1689. }
  1690. case COMMAND_BANK_CANCEL:{
  1691. Spawn* banker = cmdTarget;
  1692. client->Bank(banker, true);
  1693. break;
  1694. }
  1695. case COMMAND_BANK:{
  1696. LogWrite(PLAYER__DEBUG, 0, "Players", "Open Player Personal Bank...");
  1697. Spawn* banker = cmdTarget;
  1698. client->Bank(banker);
  1699. break;
  1700. }
  1701. case COMMAND_GUILD_BANK:{
  1702. LogWrite(GUILD__DEBUG, 0, "Guilds", "Open Guild Bank...");
  1703. //Spawn* banker = client->GetPlayer()->GetTarget();
  1704. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will eventually open the guild bank!");
  1705. break;
  1706. }
  1707. case COMMAND_START_MAIL: {
  1708. client->SetMailTransaction(cmdTarget);
  1709. client->SendMailList();
  1710. break;
  1711. }
  1712. case COMMAND_CANCEL_MAIL: {
  1713. client->SetMailTransaction(0);
  1714. break;
  1715. }
  1716. case COMMAND_GET_MAIL_MESSAGE: {
  1717. if (sep && sep->arg[0] && sep->IsNumber(0))
  1718. client->DisplayMailMessage(atoul(sep->arg[0]));
  1719. break;
  1720. }
  1721. case COMMAND_ADD_MAIL_PLAT: {
  1722. if (sep && sep->arg[0] && sep->IsNumber(0))
  1723. client->AddMailCoin(0, 0, 0, atoul(sep->arg[0]));
  1724. break;
  1725. }
  1726. case COMMAND_ADD_MAIL_GOLD: {
  1727. if (sep && sep->arg[0] && sep->IsNumber(0))
  1728. client->AddMailCoin(0, 0, atoul(sep->arg[0]));
  1729. break;
  1730. }
  1731. case COMMAND_ADD_MAIL_SILVER: {
  1732. if (sep && sep->arg[0] && sep->IsNumber(0))
  1733. client->AddMailCoin(0, atoul(sep->arg[0]));
  1734. break;
  1735. }
  1736. case COMMAND_ADD_MAIL_COPPER: {
  1737. if (sep && sep->arg[0] && sep->IsNumber(0))
  1738. client->AddMailCoin(atoul(sep->arg[0]));
  1739. break;
  1740. }
  1741. case COMMAND_SET_MAIL_ITEM: {
  1742. LogWrite(MISC__TODO, 1, "TODO", " received set_mail_item\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1743. if (sep && sep->arg[0]) LogWrite(COMMAND__DEBUG, 0, "Command", "%s\n", sep->argplus[0]);
  1744. break;
  1745. }
  1746. case COMMAND_REMOVE_MAIL_PLAT: {
  1747. if (sep && sep->arg[0] && sep->IsNumber(0))
  1748. client->RemoveMailCoin(0, 0, 0, atoul(sep->arg[0]));
  1749. break;
  1750. }
  1751. case COMMAND_REMOVE_MAIL_GOLD: {
  1752. if (sep && sep->arg[0] && sep->IsNumber(0))
  1753. client->RemoveMailCoin(0, 0, atoul(sep->arg[0]));
  1754. break;
  1755. }
  1756. case COMMAND_REMOVE_MAIL_SILVER: {
  1757. if (sep && sep->arg[0] && sep->IsNumber(0))
  1758. client->RemoveMailCoin(0, atoul(sep->arg[0]));
  1759. break;
  1760. }
  1761. case COMMAND_REMOVE_MAIL_COPPER: {
  1762. if (sep && sep->arg[0] && sep->IsNumber(0))
  1763. client->RemoveMailCoin(atoul(sep->arg[0]));
  1764. break;
  1765. }
  1766. case COMMAND_TAKE_MAIL_ATTACHMENTS: {
  1767. if (sep && sep->arg[0] && sep->IsNumber(0))
  1768. client->TakeMailAttachments(atoul(sep->arg[0]));
  1769. break;
  1770. }
  1771. case COMMAND_CANCEL_SEND_MAIL: {
  1772. client->CancelSendMail();
  1773. break;
  1774. }
  1775. case COMMAND_DELETE_MAIL_MESSAGE: {
  1776. if (sep && sep->arg[0] && sep->IsNumber(0))
  1777. client->DeleteMail(atoul(sep->arg[0]), true);
  1778. break;
  1779. }
  1780. case COMMAND_REPORT_SPAM: {
  1781. LogWrite(MISC__TODO, 1, "TODO", " received reportspam\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1782. if (sep && sep->arg[0]) LogWrite(COMMAND__DEBUG, 0, "Command", "%s\n", sep->argplus[0]);
  1783. break;
  1784. }
  1785. case COMMAND_KILL:{
  1786. Spawn* dead = 0;
  1787. if (sep && sep->arg[0] && strncasecmp(sep->arg[0],"self",4)==0){
  1788. dead=client->GetPlayer();
  1789. client->GetPlayer()->SetHP(0);
  1790. client->GetPlayer()->KillSpawn(dead);
  1791. }else{
  1792. dead= cmdTarget;
  1793. if(dead && dead->IsPlayer() == false){
  1794. dead->SetHP(0);
  1795. if(sep && sep->arg[0] && sep->IsNumber(0) && atoi(sep->arg[0]) == 1)
  1796. client->GetCurrentZone()->RemoveSpawn(false, dead, true);
  1797. else
  1798. client->GetPlayer()->KillSpawn(dead);
  1799. }else{
  1800. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /kill (self)");
  1801. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Kills currently selected non-player target.");
  1802. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Optionally, self may be used to kill yourself");
  1803. }
  1804. }
  1805. break;
  1806. }
  1807. case COMMAND_LEVEL:{
  1808. if(sep && sep->arg[ndx][0] && sep->IsNumber(0)){
  1809. int16 new_level = atoi(sep->arg[ndx]);
  1810. if (!client->GetPlayer()->CheckLevelStatus(new_level))
  1811. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have the required status to level up anymore!");
  1812. else {
  1813. if (new_level < 1)
  1814. new_level = 1;
  1815. if (new_level > 255)
  1816. new_level = 255;
  1817. client->ChangeLevel(client->GetPlayer()->GetLevel(), new_level);
  1818. client->GetPlayer()->SetXP(1);
  1819. client->GetPlayer()->SetNeededXP();
  1820. }
  1821. }else
  1822. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /level {new_level}");
  1823. break;
  1824. }
  1825. case COMMAND_SIT: {
  1826. LogWrite(MISC__TODO, 1, "TODO", " Send update packet to all clients\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1827. if(client->GetPlayer()->GetHP() > 0){
  1828. client->QueuePacket(new EQ2Packet(OP_SitMsg, 0, 0));
  1829. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You sit down.");
  1830. client->GetPlayer()->set_character_flag(CF_IS_SITTING);
  1831. }
  1832. break;
  1833. }
  1834. case COMMAND_STAND: {
  1835. LogWrite(MISC__TODO, 1, "TODO", " Send update packet to all clients\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  1836. if(client->GetPlayer()->GetHP() > 0){
  1837. client->QueuePacket(new EQ2Packet(OP_StandMsg, 0, 0));
  1838. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"You stand up.");
  1839. client->GetPlayer()->reset_character_flag(CF_IS_SITTING);
  1840. }
  1841. break;
  1842. }
  1843. case COMMAND_CLASS:{
  1844. if(sep && sep->arg[ndx][0]){
  1845. client->GetPlayer()->SetPlayerAdventureClass(atoi(sep->arg[ndx]));
  1846. client->UpdateTimeStampFlag ( CLASS_UPDATE_FLAG );
  1847. }else
  1848. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /class {class_id}");
  1849. break;
  1850. }
  1851. case COMMAND_GENDER:{
  1852. if(sep && sep->arg[ndx][0]){
  1853. client->GetPlayer()->GetInfoStruct()->gender = atoi(sep->arg[ndx]);
  1854. client->GetPlayer()->SetCharSheetChanged(true);
  1855. client->UpdateTimeStampFlag ( GENDER_UPDATE_FLAG );
  1856. }else{
  1857. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /gender {new_gender_id}");
  1858. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Male: 1");
  1859. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Female: 2");
  1860. }
  1861. break;
  1862. }
  1863. case COMMAND_FLYMODE:{
  1864. if(sep && sep->arg[0] && sep->IsNumber(0)){
  1865. PrintSep(sep, "COMMAND_FLYMODE");
  1866. int8 val = atoi(sep->arg[0]);
  1867. ClientPacketFunctions::SendFlyMode(client, val);
  1868. }
  1869. else{
  1870. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage ON: /flymode 1");
  1871. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage OFF: /flymode 0");
  1872. }
  1873. break;
  1874. }
  1875. case COMMAND_LOOT_LIST:{
  1876. Spawn* spawn = cmdTarget;
  1877. if(spawn && spawn->IsEntity()){
  1878. if (sep && sep->arg[0]) {
  1879. if (!spawn->GetDatabaseID())
  1880. {
  1881. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn has no database id to assign to loottables.");
  1882. break;
  1883. }
  1884. else if (!spawn->IsNPC())
  1885. {
  1886. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "these /loot list [add/remove/clearall] sub-commands are only designed for an NPC.");
  1887. break;
  1888. }
  1889. bool reloadLoot = false;
  1890. if (!stricmp(sep->arg[0], "remove") && sep->arg[1] && sep->IsNumber(1))
  1891. {
  1892. int32 loottable_id = atoul(sep->arg[1]);
  1893. if (loottable_id > 0 && database.RemoveSpawnLootTable(spawn, loottable_id))
  1894. {
  1895. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u loot table %u removed.", spawn->GetDatabaseID(), loottable_id);
  1896. reloadLoot = true;
  1897. }
  1898. else
  1899. client->Message(CHANNEL_COLOR_YELLOW, "/loot list remove [loottableid] - could not match any spawn_id entries against loottable_id %u.", loottable_id);
  1900. }
  1901. else if (!stricmp(sep->arg[0], "add") && sep->arg[1] && sep->IsNumber(1))
  1902. {
  1903. int32 loottable_id = atoul(sep->arg[1]);
  1904. if (loottable_id > 0)
  1905. {
  1906. database.AddLootTableToSpawn(spawn, loottable_id);
  1907. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u loot table %u added.", spawn->GetDatabaseID(), loottable_id);
  1908. reloadLoot = true;
  1909. }
  1910. else
  1911. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list add [loottableid] - cannot add a loottable id of 0.");
  1912. }
  1913. else if (!stricmp(sep->arg[0], "clearall"))
  1914. {
  1915. if (database.RemoveSpawnLootTable(spawn, 0))
  1916. {
  1917. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn loot tables removed.");
  1918. reloadLoot = true;
  1919. }
  1920. else
  1921. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list clearall - could not match any spawn_id entries in loottable_id.");
  1922. }
  1923. else
  1924. {
  1925. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list argument not supported.");
  1926. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list add [loottableid] - add new loottable to spawn");
  1927. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list remove [loottableid] - remove existing loottable from spawn");
  1928. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/loot list clearall - remove all loottables from spawn");
  1929. break;
  1930. }
  1931. if (reloadLoot)
  1932. {
  1933. database.LoadSpawnLoot(spawn->GetZone(), spawn);
  1934. if (spawn->IsNPC())
  1935. {
  1936. Entity* ent = (Entity*)spawn;
  1937. ent->SetLootCoins(0);
  1938. ent->ClearLootList();
  1939. spawn->GetZone()->AddLoot((NPC*)spawn);
  1940. client->Message(CHANNEL_COLOR_YELLOW, "Spawn %u active loot purged and reloaded.", spawn->GetDatabaseID());
  1941. }
  1942. }
  1943. break; // nothing further this is the end of these sub commands
  1944. }
  1945. else
  1946. {
  1947. vector<int32> loot_list = client->GetCurrentZone()->GetSpawnLootList(spawn->GetDatabaseID(), spawn->GetZone()->GetZoneID(), spawn->GetLevel(), race_types_list.GetRaceType(spawn->GetModelType()));
  1948. if (loot_list.size() > 0) {
  1949. client->Message(CHANNEL_COLOR_YELLOW, "%s belongs to the following loot lists: ", spawn->GetName());
  1950. vector<int32>::iterator list_itr;
  1951. LootTable* table = 0;
  1952. for (list_itr = loot_list.begin(); list_itr != loot_list.end(); list_itr++) {
  1953. table = client->GetCurrentZone()->GetLootTable(*list_itr);
  1954. if (table)
  1955. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", *list_itr, table->name.c_str());
  1956. }
  1957. }
  1958. client->Message(CHANNEL_COLOR_YELLOW, "Coins being carried: %u", spawn->GetLootCoins());
  1959. vector<Item*>* items = spawn->GetLootItems();
  1960. if (items) {
  1961. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is carrying the following items: ");
  1962. vector<Item*>::iterator itr;
  1963. Item* item = 0;
  1964. for (itr = items->begin(); itr != items->end(); itr++) {
  1965. item = *itr;
  1966. client->Message(CHANNEL_COLOR_YELLOW, "%u - %s", item->details.item_id, item->name.c_str());
  1967. }
  1968. }
  1969. else
  1970. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Spawn is not carrying any items.");
  1971. }
  1972. }
  1973. break;
  1974. }
  1975. case COMMAND_LOOT_SETCOIN:{
  1976. Spawn* spawn = cmdTarget;
  1977. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  1978. spawn->SetLootCoins(atoul(sep->arg[0]));
  1979. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully set coins.");
  1980. }
  1981. else
  1982. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot setcoin {amount}");
  1983. break;
  1984. }
  1985. case COMMAND_LOOT_ADDITEM:{
  1986. Spawn* spawn = cmdTarget;
  1987. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  1988. int16 charges = 1;
  1989. if(sep->arg[1] && sep->IsNumber(1))
  1990. charges = atoi(sep->arg[1]);
  1991. spawn->AddLootItem(atoul(sep->arg[0]), charges);
  1992. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully added item.");
  1993. }
  1994. else
  1995. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot additem {item_id}");
  1996. break;
  1997. }
  1998. case COMMAND_LOOT_REMOVEITEM:{
  1999. Spawn* spawn = cmdTarget;
  2000. if(spawn && spawn->IsEntity() && sep && sep->arg[0] && sep->IsNumber(0)){
  2001. spawn->LootItem(atoul(sep->arg[0]));
  2002. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully removed item.");
  2003. }
  2004. else
  2005. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /loot removeitem {item_id}");
  2006. break;
  2007. }
  2008. case COMMAND_LOOT_CORPSE:
  2009. case COMMAND_DISARM:
  2010. case COMMAND_LOOT:{
  2011. if (cmdTarget && ((Entity*)cmdTarget)->IsNPC() && cmdTarget->Alive())
  2012. {
  2013. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is not dead.");
  2014. break;
  2015. }
  2016. if(cmdTarget && cmdTarget->IsEntity()){
  2017. if (cmdTarget->GetDistance(client->GetPlayer()) <= rule_manager.GetGlobalRule(R_Loot, LootRadius)->GetFloat()){
  2018. if (!rule_manager.GetGlobalRule(R_Loot, AutoDisarmChest)->GetBool() && command->handler == COMMAND_DISARM )
  2019. client->OpenChest(cmdTarget, true);
  2020. else
  2021. client->Loot(cmdTarget, rule_manager.GetGlobalRule(R_Loot, AutoDisarmChest)->GetBool());
  2022. if (!(cmdTarget)->HasLoot()){
  2023. if (((Entity*)cmdTarget)->IsNPC())
  2024. client->GetCurrentZone()->RemoveDeadSpawn(cmdTarget);
  2025. }
  2026. }
  2027. else
  2028. client->Message(CHANNEL_COLOR_YELLOW, "You are too far away to interact with that");
  2029. }
  2030. else if(!cmdTarget || cmdTarget->GetHP() > 0)
  2031. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid target.");
  2032. break;
  2033. }
  2034. case COMMAND_RELOADSPAWNSCRIPTS:{
  2035. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spawn Scripts....");
  2036. if (lua_interface)
  2037. lua_interface->SetSpawnScriptsReloading(true);
  2038. world.ResetSpawnScripts();
  2039. database.LoadSpawnScriptData();
  2040. if(lua_interface) {
  2041. lua_interface->DestroySpawnScripts();
  2042. lua_interface->SetSpawnScriptsReloading(false);
  2043. }
  2044. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Success!");
  2045. break;
  2046. }
  2047. case COMMAND_RELOADLUASYSTEM:{
  2048. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Attempting to reload entire LUA system....");
  2049. map<Client*, int32> debug_clients = lua_interface->GetDebugClients();
  2050. safe_delete(lua_interface);
  2051. lua_interface = new LuaInterface();
  2052. if(lua_interface)
  2053. lua_interface->SetSpawnScriptsReloading(true);
  2054. if(lua_interface && debug_clients.size() > 0){
  2055. map<Client*, int32>::iterator itr;
  2056. for(itr = debug_clients.begin(); itr != debug_clients .end(); itr++){
  2057. if(lua_interface)
  2058. lua_interface->UpdateDebugClients(itr->first);
  2059. }
  2060. }
  2061. world.ResetSpawnScripts();
  2062. database.LoadSpawnScriptData();
  2063. world.ResetZoneScripts();
  2064. database.LoadZoneScriptData();
  2065. int32 quest_count = database.LoadQuests();
  2066. zone_list.DeleteSpellProcess();
  2067. master_spell_list.Reload();
  2068. int32 spell_count = 0;
  2069. if(lua_interface) {
  2070. lua_interface->DestroySpawnScripts();
  2071. lua_interface->DestroySpells();
  2072. spell_count = database.LoadSpellScriptData();
  2073. lua_interface->SetSpawnScriptsReloading(false);
  2074. }
  2075. zone_list.LoadSpellProcess();
  2076. client->Message(CHANNEL_COLOR_YELLOW, "Successfully loaded %u spell(s), %u quest(s).", spell_count, quest_count);
  2077. break;
  2078. }
  2079. case COMMAND_DECLINE_QUEST:{
  2080. int32 quest_id = 0;
  2081. if(sep && sep->arg[0] && sep->IsNumber(0))
  2082. quest_id = atoul(sep->arg[0]);
  2083. if(quest_id > 0){
  2084. Quest* quest = client->GetPendingQuest(quest_id);
  2085. if(quest){
  2086. client->RemovePendingQuest(quest);
  2087. if(lua_interface)
  2088. lua_interface->CallQuestFunction(quest, "Declined", client->GetPlayer());
  2089. safe_delete(quest);
  2090. client->GetCurrentZone()->SendQuestUpdates(client);
  2091. }
  2092. }
  2093. break;
  2094. }
  2095. case COMMAND_DELETE_QUEST:{
  2096. int32 quest_id = 0;
  2097. if(sep && sep->arg[0] && sep->IsNumber(0))
  2098. quest_id = atoul(sep->arg[0]);
  2099. if(quest_id > 0){
  2100. if(lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0) {
  2101. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  2102. if (quest)
  2103. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  2104. }
  2105. client->RemovePlayerQuest(quest_id);
  2106. client->GetCurrentZone()->SendQuestUpdates(client);
  2107. }
  2108. break;
  2109. }
  2110. case COMMAND_ACCEPT_QUEST:{
  2111. int32 quest_id = 0;
  2112. if(sep && sep->arg[0] && sep->IsNumber(0))
  2113. quest_id = atoul(sep->arg[0]);
  2114. if(quest_id > 0){
  2115. client->AcceptQuest(quest_id);
  2116. }
  2117. break;
  2118. }
  2119. case COMMAND_NAME:{
  2120. if(sep && sep->arg[ndx][0]){
  2121. memset(client->GetPlayer()->GetInfoStruct()->name, 0, 40);
  2122. strncpy(client->GetPlayer()->GetInfoStruct()->name, sep->arg[ndx], 39);
  2123. client->GetPlayer()->SetCharSheetChanged(true);
  2124. }else
  2125. client->Message(CHANNEL_COLOR_YELLOW,"Usage: /name {new_name}");
  2126. break;
  2127. }
  2128. case COMMAND_GROUPSAY:{
  2129. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  2130. if(sep && sep->arg[0] && gmi)
  2131. world.GetGroupManager()->GroupChatMessage(gmi->group_id, client->GetPlayer(), sep->argplus[0]);
  2132. break;
  2133. }
  2134. case COMMAND_GROUPINVITE: {
  2135. Entity* target = 0;
  2136. Client* target_client = 0;
  2137. if (client->GetPlayer()->GetGroupMemberInfo() && !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  2138. client->SimpleMessage(CHANNEL_COMMANDS, "You must be the group leader to invite.");
  2139. return;
  2140. }
  2141. // name provided with command so it has to be a player, npc not supported here
  2142. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0){
  2143. target_client = zone_list.GetClientByCharName(sep->arg[0]);
  2144. if (target_client) {
  2145. if (!target_client->IsConnected() || !target_client->IsReadyForSpawns())
  2146. target = 0;
  2147. else
  2148. target = target_client->GetPlayer();
  2149. }
  2150. }
  2151. // if name was not provided use the players target, npc or player supported here
  2152. if (!target && client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  2153. target = (Entity*)client->GetPlayer()->GetTarget();
  2154. if (target->IsPlayer()) {
  2155. target_client = client->GetCurrentZone()->GetClientBySpawn(target);
  2156. }
  2157. }
  2158. int8 result = world.GetGroupManager()->Invite(client->GetPlayer(), target);
  2159. if (result == 0) {
  2160. client->Message(CHANNEL_COMMANDS, "You invite %s to group with you.", target->GetName());
  2161. if (target_client) {
  2162. PacketStruct* packet = configReader.getStruct("WS_ReceiveOffer", target_client->GetVersion());
  2163. if (packet) {
  2164. packet->setDataByName("type", 1);
  2165. packet->setDataByName("name", client->GetPlayer()->GetName());
  2166. packet->setDataByName("unknown2", 1);
  2167. target_client->QueuePacket(packet->serialize());
  2168. safe_delete(packet);
  2169. }
  2170. }
  2171. }
  2172. else if (result == 1)
  2173. client->SimpleMessage(CHANNEL_COMMANDS, "That player is already in a group.");
  2174. else if (result == 2)
  2175. client->SimpleMessage(CHANNEL_COMMANDS, "That player has been invited to another group.");
  2176. else if (result == 3)
  2177. client->SimpleMessage(CHANNEL_COMMANDS, "Your group is already full.");
  2178. else if (result == 4)
  2179. client->SimpleMessage(CHANNEL_COMMANDS, "You have a pending invitation, cancel it first.");
  2180. else if (result == 5)
  2181. client->SimpleMessage(CHANNEL_COMMANDS, "You cannot invite yourself!");
  2182. else if (result == 6)
  2183. client->SimpleMessage(CHANNEL_COMMANDS, "Could not locate the player.");
  2184. else
  2185. client->SimpleMessage(CHANNEL_COMMANDS, "Group invite failed, unknown error!");
  2186. break;
  2187. }
  2188. case COMMAND_GROUPDISBAND: {
  2189. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  2190. if (gmi) { // TODO: Leader check
  2191. // world.GetGroupManager()->SimpleGroupMessage(gmi->group_id, "Your group has been disbanded.");
  2192. world.GetGroupManager()->RemoveGroup(gmi->group_id);
  2193. }
  2194. break;
  2195. }
  2196. case COMMAND_GROUP_LEAVE: {
  2197. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  2198. if (gmi) {
  2199. int32 group_id = gmi->group_id;
  2200. world.GetGroupManager()->RemoveGroupMember(group_id, client->GetPlayer());
  2201. if (!world.GetGroupManager()->IsGroupIDValid(group_id)) {
  2202. // leader->Message(CHANNEL_COLOR_GROUP, "%s has left the group.", client->GetPlayer()->GetName());
  2203. }
  2204. else {
  2205. world.GetGroupManager()->GroupMessage(group_id, "%s has left the group.", client->GetPlayer()->GetName());
  2206. }
  2207. client->SimpleMessage(CHANNEL_COLOR_GROUP, "You have left the group");
  2208. }
  2209. break;
  2210. }
  2211. case COMMAND_FRIEND_ADD:{
  2212. string name = "";
  2213. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2214. name = database.GetPlayerName(sep->arg[0]);
  2215. else if(cmdTarget && cmdTarget->IsPlayer())
  2216. name = string(cmdTarget->GetName());
  2217. if(name.length() > 0){
  2218. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  2219. if(client->GetPlayer()->IsIgnored(name.c_str())){
  2220. client->GetPlayer()->RemoveIgnore(name.c_str());
  2221. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  2222. client->SendChatRelationship(3, name.c_str());
  2223. }
  2224. client->GetPlayer()->AddFriend(name.c_str(), true);
  2225. client->SendChatRelationship(0, name.c_str());
  2226. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added friend: %s", name.c_str());
  2227. if(zone_list.GetClientByCharName(name))
  2228. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Friend: %s has logged in.", name.c_str());
  2229. }
  2230. else
  2231. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot be more friendly towards yourself!");
  2232. }
  2233. else
  2234. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  2235. break;
  2236. }
  2237. case COMMAND_FRIEND_REMOVE:{
  2238. string name = "";
  2239. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2240. name = database.GetPlayerName(sep->arg[0]);
  2241. else if(cmdTarget && cmdTarget->IsPlayer())
  2242. name = string(cmdTarget->GetName());
  2243. if(name.length() > 0){
  2244. client->GetPlayer()->RemoveFriend(name.c_str());
  2245. client->SendChatRelationship(1, name.c_str());
  2246. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  2247. }
  2248. else
  2249. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  2250. break;
  2251. }
  2252. case COMMAND_FRIENDS:{
  2253. break;
  2254. }
  2255. case COMMAND_IGNORE_ADD:{
  2256. string name = "";
  2257. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2258. name = database.GetPlayerName(sep->arg[0]);
  2259. else if(cmdTarget && cmdTarget->IsPlayer())
  2260. name = string(cmdTarget->GetName());
  2261. if(name.length() > 0){
  2262. if(strcmp(name.c_str(), client->GetPlayer()->GetName()) != 0){
  2263. if(client->GetPlayer()->IsFriend(name.c_str())){
  2264. client->GetPlayer()->RemoveFriend(name.c_str());
  2265. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed friend: %s", name.c_str());
  2266. client->SendChatRelationship(1, name.c_str());
  2267. }
  2268. client->GetPlayer()->AddIgnore(name.c_str(), true);
  2269. client->SendChatRelationship(2, name.c_str());
  2270. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Added ignore: %s", name.c_str());
  2271. }
  2272. else
  2273. client->SimpleMessage(CHANNEL_COLOR_RED, "You cannot ignore yourself!");
  2274. }
  2275. else
  2276. client->SimpleMessage(CHANNEL_COLOR_CHAT_RELATIONSHIP, "That character does not exist.");
  2277. break;
  2278. }
  2279. case COMMAND_IGNORE_REMOVE:{
  2280. string name = "";
  2281. if(sep && sep->arg[0] && strlen(sep->arg[0]) > 1)
  2282. name = database.GetPlayerName(sep->arg[0]);
  2283. else if(cmdTarget && cmdTarget->IsPlayer())
  2284. name = string(cmdTarget->GetName());
  2285. if(name.length() > 0){
  2286. client->GetPlayer()->RemoveIgnore(name.c_str());
  2287. client->SendChatRelationship(3, name.c_str());
  2288. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "Removed ignore: %s", name.c_str());
  2289. }
  2290. break;
  2291. }
  2292. case COMMAND_IGNORES:{
  2293. break;
  2294. }
  2295. case COMMAND_GROUP_KICK:{
  2296. Entity* kicked = 0;
  2297. Client* kicked_client = 0;
  2298. int32 group_id = 0;
  2299. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader)
  2300. return;
  2301. LogWrite(MISC__TODO, 0, "TODO", "Add a check to see if the client using the command (COMMAND_GROUP_KICK) is the group leader");
  2302. if (sep && sep->arg[0]) {
  2303. kicked_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  2304. if (kicked_client)
  2305. kicked = kicked_client->GetPlayer();
  2306. }
  2307. else if (cmdTarget && cmdTarget->IsEntity()) {
  2308. kicked = (Entity*)cmdTarget;
  2309. }
  2310. group_id = client->GetPlayer()->GetGroupMemberInfo()->group_id;
  2311. bool send_kicked_message = world.GetGroupManager()->GetGroupSize(group_id) > 2;
  2312. if (kicked)
  2313. world.GetGroupManager()->RemoveGroupMember(group_id, kicked);
  2314. if(send_kicked_message)
  2315. world.GetGroupManager()->GroupMessage(group_id, "%s was kicked from the group.", kicked->GetName());
  2316. else
  2317. client->Message(CHANNEL_COLOR_GROUP, "You kicked %s from the group", kicked->GetName());
  2318. if (kicked_client)
  2319. kicked_client->SimpleMessage(CHANNEL_COLOR_GROUP, "You were kicked from the group");
  2320. break;
  2321. }
  2322. case COMMAND_GROUP_MAKE_LEADER:{
  2323. if (!client->GetPlayer()->GetGroupMemberInfo() || !client->GetPlayer()->GetGroupMemberInfo()->leader) {
  2324. client->SimpleMessage(CHANNEL_COMMANDS, "You are not a group leader.");
  2325. return;
  2326. }
  2327. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 1) {
  2328. Client* new_leader = zone_list.GetClientByCharName(sep->arg[0]);
  2329. if (new_leader) {
  2330. if (client->GetPlayer()->IsGroupMember(new_leader->GetPlayer())) {
  2331. world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, new_leader->GetPlayer());
  2332. }
  2333. }
  2334. else
  2335. client->SimpleMessage(CHANNEL_COMMANDS, "Unable to find the given player.");
  2336. }
  2337. else if (cmdTarget && cmdTarget->IsPlayer())
  2338. world.GetGroupManager()->MakeLeader(client->GetPlayer()->GetGroupMemberInfo()->group_id, (Entity*)cmdTarget);
  2339. else
  2340. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to change group leader.");
  2341. break;
  2342. }
  2343. case COMMAND_GROUP_ACCEPT_INVITE: {
  2344. if(sep && sep->arg[0] && strcmp(sep->arg[0], "group") == 0) {
  2345. int8 result = world.GetGroupManager()->AcceptInvite(client->GetPlayer());
  2346. if (result == 0)
  2347. client->SimpleMessage(CHANNEL_GROUP, "You have joined the group.");
  2348. else if (result == 1)
  2349. client->SimpleMessage(CHANNEL_GROUP, "You do not have a pending invite.");
  2350. else if (result == 2)
  2351. client->SimpleMessage(CHANNEL_GROUP, "Unable to join group - could not find leader.");
  2352. else
  2353. client->SimpleMessage(CHANNEL_GROUP, "Unable to join group - unknown error.");
  2354. }
  2355. break;
  2356. }
  2357. case COMMAND_GROUP_DECLINE_INVITE: {
  2358. if(sep && sep->arg[0] && strcmp(sep->arg[0], "group") == 0) {
  2359. world.GetGroupManager()->DeclineInvite(client->GetPlayer()); // TODO: Add message to leader
  2360. }
  2361. break;
  2362. }
  2363. case COMMAND_SUMMON:{
  2364. char* search_name = 0;
  2365. if(sep && sep->arg[0][0])
  2366. search_name = sep->arg[0];
  2367. if(!search_name && !cmdTarget){
  2368. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /summon [name]");
  2369. 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.");
  2370. }
  2371. else{
  2372. if(!client->Summon(search_name))
  2373. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  2374. }
  2375. break;
  2376. }
  2377. case COMMAND_GOTO:{
  2378. const char* search_name = 0;
  2379. if(sep && sep->arg[0][0])
  2380. search_name = sep->argplus[0];
  2381. if(!search_name && !cmdTarget){
  2382. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /goto [name]");
  2383. 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.");
  2384. }
  2385. else{
  2386. if(!client->GotoSpawn(search_name))
  2387. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found.");
  2388. }
  2389. break;
  2390. }
  2391. case COMMAND_MOVE:{
  2392. bool success = false;
  2393. try{
  2394. if(sep && sep->arg[2][0] && sep->IsNumber(0) && sep->IsNumber(1) && sep->IsNumber(2)){
  2395. EQ2Packet* app = client->GetPlayer()->Move(atof(sep->arg[0]), atof(sep->arg[1]), atof(sep->arg[2]), client->GetVersion());
  2396. if(app){
  2397. client->QueuePacket(app);
  2398. success = true;
  2399. }
  2400. }
  2401. }
  2402. catch(...){}
  2403. if(!success){
  2404. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /move x y z");
  2405. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Moves the client to the given coordinates.");
  2406. }
  2407. break;
  2408. }
  2409. case COMMAND_SETTIME:{
  2410. if(sep && sep->arg[0]){
  2411. sscanf (sep->arg[0], "%d:%d", &world.GetWorldTimeStruct()->hour, &world.GetWorldTimeStruct()->minute);
  2412. if(sep->arg[1] && sep->IsNumber(1))
  2413. world.GetWorldTimeStruct()->month = atoi(sep->arg[1]) - 1; //zero based indexes
  2414. if(sep->arg[2] && sep->IsNumber(2))
  2415. world.GetWorldTimeStruct()->day = atoi(sep->arg[2]) - 1; //zero based indexes
  2416. if(sep->arg[3] && sep->IsNumber(3))
  2417. world.GetWorldTimeStruct()->year = atoi(sep->arg[3]);
  2418. client->GetCurrentZone()->SendTimeUpdateToAllClients();
  2419. }
  2420. else{
  2421. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /settime [hour:minute] (month) (day) (year)");
  2422. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Example: /settime 8:30");
  2423. }
  2424. break;
  2425. }
  2426. case COMMAND_VERSION:{
  2427. client->Message(CHANNEL_COLOR_YELLOW,"%s %s", EQ2EMU_MODULE, CURRENT_VERSION);
  2428. client->Message(CHANNEL_COLOR_YELLOW,"Last Compiled on %s %s", COMPILE_DATE, COMPILE_TIME);
  2429. break;
  2430. }
  2431. case COMMAND_ZONE:{
  2432. string* zonename = 0;
  2433. int32 instanceID = 0;
  2434. const char* zone = 0;
  2435. int32 zone_id = 0;
  2436. bool listSearch = false;
  2437. bool isInstance = false;
  2438. ZoneServer* zsZone = 0;
  2439. if(sep && sep->arg[0][0])
  2440. {
  2441. if(strncasecmp(sep->arg[0], "list", 4) == 0)
  2442. listSearch = true;
  2443. else if(strncasecmp(sep->arg[0], "active", 6) == 0)
  2444. {
  2445. zone_list.SendZoneList(client);
  2446. break;
  2447. }
  2448. else if(strncasecmp(sep->arg[0], "instance", 6) == 0)
  2449. {
  2450. if(sep->IsNumber(1))
  2451. instanceID = atol(sep->arg[1]);
  2452. }
  2453. else if(strncasecmp(sep->arg[0], "lock", 4) == 0)
  2454. {
  2455. PrintSep(sep, "ZONE LOCK");
  2456. if(sep->IsNumber(1))
  2457. zsZone = zone_list.Get(atoul(sep->arg[1]), false);
  2458. else
  2459. zsZone = zone_list.Get(sep->arg[1], false);
  2460. if( zsZone )
  2461. {
  2462. zsZone->SetZoneLockState(true);
  2463. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now locked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  2464. }
  2465. else
  2466. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be locked.", sep->arg[1]);
  2467. break;
  2468. }
  2469. else if(strncasecmp(sep->arg[0], "unlock", 6) == 0)
  2470. {
  2471. PrintSep(sep, "ZONE UNLOCK");
  2472. if(sep->IsNumber(1))
  2473. zsZone = zone_list.Get(atoul(sep->arg[1]), false);
  2474. else
  2475. zsZone = zone_list.Get(sep->arg[1], false);
  2476. if( zsZone )
  2477. {
  2478. zsZone->SetZoneLockState(false);
  2479. client->Message(CHANNEL_COLOR_YELLOW, "Zone %s (%u) is now unlocked.", zsZone->GetZoneName(), zsZone->GetZoneID());
  2480. }
  2481. else
  2482. client->Message(CHANNEL_COLOR_RED, "Zone %s is not running and cannot be unlocked.", sep->arg[1]);
  2483. break;
  2484. }
  2485. else
  2486. {
  2487. if(sep->IsNumber(0))
  2488. {
  2489. zone_id = atoul(sep->arg[0]);
  2490. zonename = database.GetZoneName(zone_id);
  2491. if(zonename)
  2492. zone = zonename->c_str();
  2493. }
  2494. else
  2495. zone = sep->arg[0];
  2496. }
  2497. if(instanceID > 0)
  2498. {
  2499. ZoneServer* zsInstance = zone_list.GetByInstanceID(instanceID);
  2500. if(zsInstance != NULL)
  2501. {
  2502. instanceID = zsInstance->GetInstanceID();
  2503. zone = zsInstance->GetZoneName();
  2504. zone_id = zsInstance->GetZoneID();
  2505. isInstance = true;
  2506. }
  2507. }
  2508. }
  2509. if(!listSearch)
  2510. {
  2511. if(!zone)
  2512. client->Message(CHANNEL_COLOR_RED, "Error: Invalid Zone");
  2513. else if(instanceID != client->GetCurrentZone()->GetInstanceID() ||
  2514. zone_id != client->GetCurrentZone()->GetZoneID())
  2515. {
  2516. if(database.VerifyZone(zone))
  2517. {
  2518. if(client->CheckZoneAccess(zone))
  2519. {
  2520. client->Message(CHANNEL_COLOR_YELLOW,"Zoning to %s...", zone);
  2521. if(isInstance)
  2522. client->Zone(instanceID,true,true);
  2523. else
  2524. client->Zone(zone);
  2525. }
  2526. }
  2527. else
  2528. client->Message(CHANNEL_COLOR_RED, "Error: Zone '%s' not found. To get a list type /zone list", zone);
  2529. }
  2530. else
  2531. client->Message(CHANNEL_COLOR_RED, "Error: You are already in that zone!");
  2532. }
  2533. else
  2534. {
  2535. const char* name = 0;
  2536. if(sep && sep->arg[1][0])
  2537. {
  2538. map<int32, string>* zone_names;
  2539. name = sep->argplus[1];
  2540. sint16 status = client->GetAdminStatus();
  2541. if( status > 0 )
  2542. {
  2543. client->SimpleMessage(CHANNEL_COLOR_RED, "ADMIN MODE");
  2544. zone_names = database.GetZoneList(name, true);
  2545. }
  2546. else
  2547. zone_names = database.GetZoneList(name);
  2548. if(!zone_names)
  2549. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No zones found.");
  2550. else
  2551. {
  2552. map<int32, string>::iterator itr;
  2553. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  2554. for(itr = zone_names->begin(); itr != zone_names->end(); itr++)
  2555. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  2556. safe_delete(zone_names);
  2557. }
  2558. }
  2559. else
  2560. {
  2561. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone [zone name]");
  2562. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /zone list [partial zone name]");
  2563. }
  2564. }
  2565. safe_delete(zonename);
  2566. break;
  2567. }
  2568. case COMMAND_USE: {
  2569. Spawn* target = cmdTarget;
  2570. if (target->IsWidget())
  2571. ((Widget*)target)->HandleUse(client, "use");
  2572. break;
  2573. }
  2574. case COMMAND_OPEN: {
  2575. Spawn* target = cmdTarget;
  2576. if (target->IsWidget())
  2577. ((Widget*)target)->HandleUse(client, "Open", WIDGET_TYPE_DOOR);
  2578. break;
  2579. }
  2580. case COMMAND_CASTSPELL: {
  2581. if (sep && sep->arg[0] && sep->IsNumber(0))
  2582. {
  2583. int8 tier = 1;
  2584. if (sep->arg[1] && sep->IsNumber(1))
  2585. tier = atoul(sep->arg[1]);
  2586. int32 spellid = atoul(sep->arg[0]);
  2587. Spell* spell = master_spell_list.GetSpell(spellid, tier);
  2588. if (spell)
  2589. {
  2590. client->Message(CHANNEL_COLOR_RED, "Casting spell %u.", spellid);
  2591. SpellProcess* spellProcess = 0;
  2592. // Get the current zones spell process
  2593. spellProcess = client->GetCurrentZone()->GetSpellProcess();
  2594. spellProcess->CastInstant(spell, (Entity*)client->GetPlayer(), (cmdTarget && cmdTarget->IsEntity()) ? (Entity*)cmdTarget : (Entity*)client->GetPlayer());
  2595. }
  2596. else
  2597. {
  2598. client->Message(CHANNEL_COLOR_RED, "Could not find spell %u.",spellid);
  2599. }
  2600. }
  2601. else if (sep && sep->arg[0])
  2602. {
  2603. database.FindSpell(client, (char*)sep->argplus[0]);
  2604. }
  2605. else
  2606. {
  2607. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellid] (tier=1) - Cast Spell with specified spell id, tier is optional, default of 1.");
  2608. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /castspell [spellname] - Find spells wildcard match with a partial spell name");
  2609. }
  2610. break;
  2611. }
  2612. case COMMAND_KNOWLEDGEWINDOWSORT: {
  2613. if (client->GetVersion() <= 546)
  2614. break;
  2615. if (sep && sep->GetArgNumber() == 4)
  2616. {
  2617. int32 book = atoul(sep->arg[0]); // 0 - spells, 1 - combat, 2 - abilities, 3 - tradeskill
  2618. int32 sort_by = atoul(sep->arg[1]); // 0 - alpha, 1 - level, 2 - category
  2619. int32 order = atoul(sep->arg[2]); // 0 - ascending, 1 - descending
  2620. int32 pattern = atoul(sep->arg[3]); // 0 - zigzag, 1 - down, 2 - across
  2621. int32 maxlvlonly = atoul(sep->arg[4]); // 0 - zigzag, 1 - down, 2 - across
  2622. client->GetPlayer()->ResortSpellBook(sort_by, order, pattern, maxlvlonly, book);
  2623. ClientPacketFunctions::SendSkillSlotMappings(client);
  2624. }
  2625. else
  2626. {
  2627. client->Message(CHANNEL_COLOR_YELLOW, "Syntax: /knowledgewindow_sort [book] [sort_by] [order] [pattern]");
  2628. }
  2629. break;
  2630. }
  2631. case COMMAND_MOVE_ITEM:
  2632. {
  2633. int32 id = 0;
  2634. if (sep->IsNumber(0))
  2635. id = atoul(sep->arg[0]);
  2636. Spawn* spawn = 0;
  2637. if (id == 0)
  2638. {
  2639. spawn = cmdTarget;
  2640. }
  2641. else
  2642. spawn = client->GetCurrentZone()->GetSpawnFromUniqueItemID(id);
  2643. if (!spawn || !client->HasOwnerOrEditAccess() || !spawn->GetPickupItemID())
  2644. break;
  2645. client->SendMoveObjectMode(spawn, 0);
  2646. break;
  2647. }
  2648. case COMMAND_PICKUP:
  2649. {
  2650. int32 id = 0;
  2651. if (sep->IsNumber(0))
  2652. id = atoul(sep->arg[0]);
  2653. Spawn* spawn = 0;
  2654. if (id == 0)
  2655. {
  2656. spawn = cmdTarget;
  2657. }
  2658. else
  2659. spawn = client->GetCurrentZone()->GetSpawnFromUniqueItemID(id);
  2660. if (!spawn || !client->HasOwnerOrEditAccess() || !spawn->GetPickupItemID())
  2661. break;
  2662. client->AddItem(spawn->GetPickupItemID(), 1);
  2663. Query query;
  2664. 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());
  2665. if (database.RemoveSpawnFromSpawnLocation(spawn)) {
  2666. client->GetCurrentZone()->RemoveSpawn(false, spawn, true, true);
  2667. }
  2668. // we had a UI Window displayed, update the house items
  2669. if ( id > 0 )
  2670. client->GetCurrentZone()->SendHouseItems(client);
  2671. break;
  2672. }
  2673. case COMMAND_HOUSE_DEPOSIT:
  2674. {
  2675. PrintSep(sep, "COMMAND_HOUSE_DEPOSIT");
  2676. // arg0 = ??? (set to 3)
  2677. // arg1 = coin (in copper)
  2678. // arg2 = status? (not implemented yet)
  2679. PlayerHouse* ph = world.GetPlayerHouseByInstanceID(client->GetCurrentZone()->GetInstanceID());
  2680. if (ph && sep && sep->IsNumber(1))
  2681. {
  2682. int64 outVal = strtoull(sep->arg[1], NULL, 0);
  2683. if (client->GetPlayer()->RemoveCoins(outVal))
  2684. {
  2685. char query[256];
  2686. map<string,Deposit>::iterator itr = ph->depositsMap.find(string(client->GetPlayer()->GetName()));
  2687. if (itr != ph->depositsMap.end())
  2688. {
  2689. snprintf(query, 256, "update character_house_deposits set timestamp = %u, amount = amount + %I64u, last_amount = %I64u where house_id = %u and instance_id = %u and name='%s'", Timer::GetUnixTimeStamp(), outVal, outVal, ph->house_id, ph->instance_id, client->GetPlayer()->GetName());
  2690. }
  2691. else
  2692. snprintf(query, 256, "insert into character_house_deposits set timestamp = %u, house_id = %u, instance_id = %u, name='%s', amount = %I64u", Timer::GetUnixTimeStamp(), ph->house_id, ph->instance_id, client->GetPlayer()->GetName(), outVal);
  2693. if (database.RunQuery(query, strnlen(query, 256)))
  2694. {
  2695. ph->escrow_coins += outVal;
  2696. database.UpdateHouseEscrow(ph->house_id, ph->instance_id, ph->escrow_coins);
  2697. database.LoadDeposits(ph);
  2698. client->PlaySound("coin_cha_ching");
  2699. HouseZone* hz = world.GetHouseZone(ph->house_id);
  2700. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  2701. }
  2702. else
  2703. {
  2704. client->GetPlayer()->AddCoins(outVal);
  2705. client->SimpleMessage(CHANNEL_COLOR_RED, "Deposit failed!");
  2706. }
  2707. }
  2708. }
  2709. break;
  2710. }
  2711. case COMMAND_HOUSE:
  2712. {
  2713. if (sep && sep->IsNumber(0))
  2714. {
  2715. int32 unique_id = atoi(sep->arg[0]);
  2716. PlayerHouse* ph = world.GetPlayerHouseByUniqueID(unique_id);
  2717. HouseZone* hz = 0;
  2718. if (ph)
  2719. hz = world.GetHouseZone(ph->house_id);
  2720. // there is a arg[1] that is true/false, but not sure what it is for investigate more later
  2721. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  2722. }
  2723. else if (client->GetCurrentZone()->GetInstanceType() != 0)
  2724. {
  2725. // inside a house or something? Send the access window
  2726. PlayerHouse* ph = world.GetPlayerHouseByInstanceID(client->GetCurrentZone()->GetInstanceID());
  2727. HouseZone* hz = 0;
  2728. if ( ph )
  2729. hz = world.GetHouseZone(ph->house_id);
  2730. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, client->GetPlayer()->GetID());
  2731. client->GetCurrentZone()->SendHouseItems(client);
  2732. }
  2733. break;
  2734. }
  2735. case COMMAND_HOUSE_UI:
  2736. {
  2737. if (sep && sep->IsNumber(0) && client->GetCurrentZone()->GetInstanceType() == Instance_Type::NONE)
  2738. {
  2739. int32 unique_id = atoi(sep->arg[0]);
  2740. PlayerHouse* ph = world.GetPlayerHouseByUniqueID(unique_id);
  2741. HouseZone* hz = 0;
  2742. if ( ph )
  2743. hz = world.GetHouseZone(ph->house_id);
  2744. // there is a arg[1] that is true/false, but not sure what it is for investigate more later
  2745. ClientPacketFunctions::SendBaseHouseWindow(client, hz, ph, 0);
  2746. }
  2747. break;
  2748. }
  2749. case COMMAND_PLACE_HOUSE_ITEM: {
  2750. if (sep && sep->IsNumber(0))
  2751. {
  2752. int32 uniqueid = atoi(sep->arg[0]);
  2753. Item* item = client->GetPlayer()->item_list.GetItemFromUniqueID(uniqueid);
  2754. //Item* item = player->GetEquipmentList()->GetItem(slot);
  2755. if (item && item->IsHouseItem())
  2756. {
  2757. if (!client->HasOwnerOrEditAccess())
  2758. {
  2759. client->SimpleMessage(CHANNEL_COLOR_RED, "This is not your home!");
  2760. break;
  2761. }
  2762. else if (!item->generic_info.appearance_id)
  2763. {
  2764. 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);
  2765. break;
  2766. }
  2767. if (client->GetTempPlacementSpawn())
  2768. {
  2769. Spawn* tmp = client->GetTempPlacementSpawn();
  2770. client->GetCurrentZone()->RemoveSpawn(false, tmp);
  2771. delete tmp;
  2772. client->SetTempPlacementSpawn(nullptr);
  2773. }
  2774. Spawn* spawn = new Object();
  2775. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  2776. spawn->SetID(Spawn::NextID());
  2777. spawn->SetX(client->GetPlayer()->GetX());
  2778. spawn->SetY(client->GetPlayer()->GetY());
  2779. spawn->SetZ(client->GetPlayer()->GetZ());
  2780. spawn->SetHeading(client->GetPlayer()->GetHeading());
  2781. spawn->SetSpawnOrigX(spawn->GetX());
  2782. spawn->SetSpawnOrigY(spawn->GetY());
  2783. spawn->SetSpawnOrigZ(spawn->GetZ());
  2784. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  2785. spawn->appearance.targetable = 1;
  2786. spawn->appearance.activity_status = ACTIVITY_STATUS_SOLID;
  2787. spawn->appearance.race = item && item->generic_info.appearance_id ? item->generic_info.appearance_id : 1472;
  2788. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  2789. spawn->SetModelType(item && item->generic_info.appearance_id ? item->generic_info.appearance_id : 1472);
  2790. spawn->SetZone(client->GetCurrentZone());
  2791. client->GetCurrentZone()->SendSpawn(spawn, client);
  2792. client->SetTempPlacementSpawn(spawn);
  2793. client->SetPlacementUniqueItemID(uniqueid);
  2794. client->SendMoveObjectMode(spawn, 0);
  2795. }
  2796. }
  2797. break;
  2798. }
  2799. case COMMAND_GM:
  2800. {
  2801. if (sep->arg[0] && sep->arg[1])
  2802. {
  2803. bool onOff = (strcmp(sep->arg[1], "on") == 0);
  2804. if (strcmp(sep->arg[0], "vision") == 0)
  2805. {
  2806. client->GetPlayer()->SetGMVision(onOff);
  2807. #if defined(__GNUC__)
  2808. database.insertCharacterProperty(client, CHAR_PROPERTY_GMVISION, (onOff) ? (char*)"1" : (char*)"0");
  2809. #else
  2810. database.insertCharacterProperty(client, CHAR_PROPERTY_GMVISION, (onOff) ? "1" : "0");
  2811. #endif
  2812. client->GetCurrentZone()->SendAllSpawnsForVisChange(client, false);
  2813. if (onOff)
  2814. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Vision Enabled!");
  2815. else
  2816. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "GM Vision Disabled!");
  2817. }
  2818. else if (strcmp(sep->arg[0], "luadebug") == 0)
  2819. {
  2820. client->SetLuaDebugClient(onOff);
  2821. #if defined(__GNUC__)
  2822. database.insertCharacterProperty(client, CHAR_PROPERTY_LUADEBUG, (onOff) ? (char*)"1" : (char*)"0");
  2823. #else
  2824. database.insertCharacterProperty(client, CHAR_PROPERTY_LUADEBUG, (onOff) ? "1" : "0");
  2825. #endif
  2826. if (onOff)
  2827. {
  2828. if (lua_interface)
  2829. lua_interface->UpdateDebugClients(client);
  2830. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will now receive LUA error messages.");
  2831. }
  2832. else
  2833. {
  2834. if (lua_interface)
  2835. lua_interface->RemoveDebugClients(client);
  2836. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will no longer receive LUA error messages.");
  2837. }
  2838. }
  2839. }
  2840. break;
  2841. }
  2842. case COMMAND_ATTACK:
  2843. case COMMAND_AUTO_ATTACK:{
  2844. int8 type = 1;
  2845. Player* player = client->GetPlayer();
  2846. if(!player)
  2847. break;
  2848. bool incombat = player->EngagedInCombat();
  2849. if(sep && sep->arg[0] && sep->IsNumber(0))
  2850. type = atoi(sep->arg[0]);
  2851. if(client->GetPlayer()->GetHP() == 0){
  2852. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  2853. break;
  2854. }
  2855. if(type == 0){
  2856. if(incombat)
  2857. client->SimpleMessage(CHANNEL_COLOR_COMBAT, "You stop fighting.");
  2858. player->InCombat(false);
  2859. player->InCombat(false, true);
  2860. player->SetRangeAttack(false);
  2861. }
  2862. else {
  2863. if(type == 2){
  2864. player->InCombat(false);
  2865. if(incombat && player->GetRangeAttack()){
  2866. player->SetRangeAttack(false);
  2867. player->InCombat(false, true);
  2868. client->SimpleMessage(CHANNEL_COLOR_COMBAT, "You stop fighting.");
  2869. }
  2870. else{
  2871. player->SetRangeAttack(true);
  2872. player->InCombat(true, true);
  2873. client->SimpleMessage(CHANNEL_COLOR_COMBAT, "You start fighting.");
  2874. }
  2875. }
  2876. else {
  2877. player->InCombat(false, true);
  2878. player->SetRangeAttack(false);
  2879. player->InCombat(true);
  2880. if(!incombat)
  2881. client->SimpleMessage(CHANNEL_COLOR_COMBAT, "You start fighting.");
  2882. }
  2883. /*else
  2884. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You cannot attack that!");*/
  2885. }
  2886. player->SetCharSheetChanged(true);
  2887. break;
  2888. }
  2889. case COMMAND_DEPOP:{
  2890. bool allow_respawns = false;
  2891. if(sep && sep->arg[0] && sep->IsNumber(0)){
  2892. if(atoi(sep->arg[0]) == 1)
  2893. allow_respawns = true;
  2894. }
  2895. client->GetCurrentZone()->Depop(allow_respawns);
  2896. break;
  2897. }
  2898. case COMMAND_REPOP:{
  2899. client->GetCurrentZone()->Depop(false, true);
  2900. break;
  2901. }
  2902. case COMMAND_BUYBACK:{
  2903. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  2904. // 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
  2905. int64 id = atoi64(sep->arg[0]);
  2906. // get the first int32, the item id
  2907. //int32 item_id = (int32)id;
  2908. // get the second int32, the unique id
  2909. int32 unique_id = (int32)(id>>32);
  2910. int8 quantity = atoi(sep->arg[1]);
  2911. if(quantity == 255)
  2912. quantity = 1;
  2913. client->BuyBack(unique_id, quantity);
  2914. }
  2915. break;
  2916. }
  2917. case COMMAND_MERCHANT_BUY:{
  2918. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  2919. int32 item_id = atoul(sep->arg[0]);
  2920. int8 quantity = atoi(sep->arg[1]);
  2921. client->BuyItem(item_id, quantity);
  2922. }
  2923. break;
  2924. }
  2925. case COMMAND_MERCHANT_SELL:{
  2926. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  2927. // 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
  2928. int64 id = atoi64(sep->arg[0]);
  2929. // get the first int32, the item id
  2930. int32 item_id = (int32)id;
  2931. // get the second int32, the unique id
  2932. int32 unique_id = (int32)(id>>32);
  2933. int8 quantity = atoi(sep->arg[1]);
  2934. LogWrite(MERCHANT__DEBUG, 0, "Merchant", "Selling Item: Item Id = %ul, unique id = %ul, Quantity = %i", item_id, unique_id, quantity);
  2935. client->SellItem(item_id, quantity, unique_id);
  2936. }
  2937. break;
  2938. }
  2939. case COMMAND_MENDER_REPAIR: {
  2940. if (sep && sep->arg[0] && sep->IsNumber(0))
  2941. client->RepairItem(atoul(sep->arg[0]));
  2942. break;
  2943. }
  2944. case COMMAND_MENDER_REPAIR_ALL: {
  2945. client->RepairAllItems();
  2946. break;
  2947. }
  2948. case COMMAND_CANCEL_MERCHANT:{
  2949. client->SetMerchantTransaction(0);
  2950. break;
  2951. }
  2952. case COMMAND_START_MERCHANT:{
  2953. break;
  2954. }
  2955. case COMMAND_INVULNERABLE:{
  2956. sint8 val = -1;
  2957. if(sep && sep->arg[0] && sep->IsNumber(0)){
  2958. val = atoi(sep->arg[0]);
  2959. //devn00b: Fix for linux builds
  2960. #if defined(__GNUC__)
  2961. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? (char*) "1" : (char*) "0");
  2962. #else
  2963. database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  2964. #endif
  2965. // database.insertCharacterProperty(client, CHAR_PROPERTY_INVUL, (val == 1) ? "1" : "0");
  2966. client->GetPlayer()->SetInvulnerable(val==1);
  2967. if(client->GetPlayer()->GetInvulnerable())
  2968. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are now invulnerable!");
  2969. else
  2970. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are no longer invulnerable!");
  2971. }
  2972. if(val == -1)
  2973. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /invulnerable [0/1]");
  2974. break;
  2975. }
  2976. case COMMAND_REPAIR: {
  2977. Spawn* spawn = cmdTarget;
  2978. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR) {
  2979. client->SendHailCommand(spawn);
  2980. client->SetMerchantTransaction(spawn);
  2981. client->SendRepairList();
  2982. }
  2983. break;
  2984. }
  2985. case COMMAND_LOTTO: {
  2986. Spawn* spawn = cmdTarget;
  2987. if (spawn && spawn->GetMerchantType() & MERCHANT_TYPE_LOTTO) {
  2988. client->SetMerchantTransaction(spawn);
  2989. client->ShowLottoWindow();
  2990. }
  2991. break;
  2992. }
  2993. case COMMAND_ACCEPT_REWARD:{
  2994. int32 unknown = 0;
  2995. int32 selectable_item_id = 0;
  2996. //Quest *quest = 0;
  2997. Collection *collection = 0;
  2998. /* no idea what the first argument is for (faction maybe?)
  2999. if the reward has a selectable item reward, it's sent as the second argument
  3000. if neither of these are included in the reward, there is no sep
  3001. 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
  3002. only 1 quest or collection reward may be displayed at a time */
  3003. if (sep && sep->arg[0] && sep->arg[1] && sep->IsNumber(0) && sep->IsNumber(1)) {
  3004. unknown = atoul(sep->arg[0]);
  3005. selectable_item_id = atoul(sep->arg[1]);
  3006. }
  3007. //if ((quest = player->GetPendingQuestReward()))
  3008. // client->AcceptQuestRewards(quest, selectable_item_id);
  3009. /* the below needs to go away eventually and be redone */
  3010. int32 item_id = 0;
  3011. if(sep && sep->arg[0][0] && sep->IsNumber(0))
  3012. item_id = atoul(sep->arg[0]);
  3013. Quest* quest = client->GetPendingQuestAcceptance(item_id);
  3014. if(quest){
  3015. client->AcceptQuestReward(quest, item_id);
  3016. break;
  3017. }
  3018. if (collection = player->GetPendingCollectionReward())
  3019. client->AcceptCollectionRewards(collection, selectable_item_id);
  3020. else
  3021. LogWrite(COMMAND__ERROR, 0, "Command", "Error in COMMAND_ACCEPT_REWARD. No pending quest or collection reward was found (unknown=%u).", unknown);
  3022. break;
  3023. }
  3024. case COMMAND_BUY_FROM_BROKER:{
  3025. if(sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1)){
  3026. int32 item_id = atoul(sep->arg[0]);
  3027. int16 quantity = atoul(sep->arg[1]);
  3028. client->AddItem(item_id, quantity);
  3029. }
  3030. break;
  3031. }
  3032. case COMMAND_SEARCH_STORES_PAGE:{
  3033. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  3034. int32 page = atoul(sep->arg[0]);
  3035. client->SearchStore(page);
  3036. }
  3037. break;
  3038. }
  3039. case COMMAND_SEARCH_STORES:{
  3040. if(sep && sep->arg[0][0]){
  3041. const char* values = sep->argplus[0];
  3042. if(values){
  3043. map<string, string> str_values = TranslateBrokerRequest(values);
  3044. vector<Item*>* items = master_item_list.GetItems(str_values);
  3045. if(items){
  3046. client->SetItemSearch(items);
  3047. client->SearchStore(0);
  3048. }
  3049. }
  3050. }
  3051. break;
  3052. }
  3053. case COMMAND_LUADEBUG:{
  3054. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "start") == 0){
  3055. client->SetLuaDebugClient(true);
  3056. if(lua_interface)
  3057. lua_interface->UpdateDebugClients(client);
  3058. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will now receive LUA error messages.");
  3059. }
  3060. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "stop") == 0){
  3061. client->SetLuaDebugClient(false);
  3062. if(lua_interface)
  3063. lua_interface->RemoveDebugClients(client);
  3064. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You will no longer receive LUA error messages.");
  3065. }
  3066. else{
  3067. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /luadebug {start | stop}");
  3068. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will allow you to receive lua debug messages normally seen only in the console.");
  3069. }
  3070. break;
  3071. }
  3072. case COMMAND_SPAWN_GROUP:
  3073. {
  3074. Spawn* target = cmdTarget;
  3075. if(target && target->IsPlayer() == false)
  3076. {
  3077. if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "create") == 0)
  3078. {
  3079. if(target->GetSpawnLocationPlacementID() > 0)
  3080. {
  3081. if(sep->arg[1] && !sep->IsNumber(1) && strlen(sep->arg[1]) > 0)
  3082. {
  3083. int32 id = database.CreateSpawnGroup(target, sep->arg[1]);
  3084. if(id > 0)
  3085. client->Message(CHANNEL_COLOR_YELLOW, "Successfully created new spawn group with id: %u", id);
  3086. else
  3087. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error creating group, check console for details.");
  3088. target->SetSpawnGroupID(id);
  3089. target->AddSpawnToGroup(target);
  3090. }
  3091. else
  3092. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group create [name]");
  3093. }
  3094. else
  3095. 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.");
  3096. }
  3097. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "add") == 0)
  3098. {
  3099. if(sep->arg[1] && sep->IsNumber(1))
  3100. {
  3101. int32 group_id = atoul(sep->arg[1]);
  3102. Spawn* leader = client->GetCurrentZone()->GetSpawnGroup(group_id);
  3103. if(leader)
  3104. {
  3105. leader->AddSpawnToGroup(target);
  3106. target->SetSpawnGroupID(group_id);
  3107. if(database.SpawnGroupAddSpawn(target, group_id))
  3108. client->Message(CHANNEL_COLOR_YELLOW, "Successfully added '%s' to group id: %u", target->GetName(), group_id);
  3109. else
  3110. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error adding spawn to group, check console for details.");
  3111. }
  3112. else
  3113. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No spawns found in the current zone for that spawn group, be sure to use '/spawn group create' first!");
  3114. }
  3115. else
  3116. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group add [group id]");
  3117. }
  3118. else if(target->GetSpawnGroupID() == 0)
  3119. {
  3120. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That spawn is not in a group!");
  3121. }
  3122. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "remove") == 0)
  3123. {
  3124. int32 group_id = target->GetSpawnGroupID();
  3125. target->RemoveSpawnFromGroup();
  3126. if(database.SpawnGroupRemoveSpawn(target, group_id))
  3127. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed '%s' from group id: %u", target->GetName(), group_id);
  3128. else
  3129. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing spawn from group, check console for details.");
  3130. }
  3131. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "associate") == 0)
  3132. {
  3133. int32 group_id = target->GetSpawnGroupID();
  3134. if(sep->arg[1] && sep->IsNumber(1))
  3135. {
  3136. if(database.SpawnGroupAddAssociation(group_id, atoul(sep->arg[1])))
  3137. client->Message(CHANNEL_COLOR_YELLOW, "Successfully associated group id %u with group id %u", group_id, atoul(sep->arg[1]));
  3138. else
  3139. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error associating groups, check console for details.");
  3140. }
  3141. else
  3142. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Allows you to spawn only one associated group at once. Syntax: /spawn group associate [other group id]");
  3143. }
  3144. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "deassociate") == 0)
  3145. {
  3146. int32 group_id = target->GetSpawnGroupID();
  3147. if(sep->arg[1] && sep->IsNumber(1))
  3148. {
  3149. if(database.SpawnGroupRemoveAssociation(group_id, atoul(sep->arg[1])))
  3150. client->Message(CHANNEL_COLOR_YELLOW, "Successfully removed association between group id %u and group id %u", group_id, atoul(sep->arg[1]));
  3151. else
  3152. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error removing group associations, check console for details.");
  3153. }
  3154. else
  3155. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Removes previous group associations. Syntax: /spawn group deassociate [other group id]");
  3156. }
  3157. else if(sep && sep->arg[0][0] && strcmp(sep->arg[0], "chance") == 0)
  3158. {
  3159. if(sep->arg[1] && sep->IsNumber(1))
  3160. {
  3161. if(database.SetGroupSpawnChance(target->GetSpawnGroupID(), atof(sep->arg[1])))
  3162. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set group spawn chance to %f for group id: %u", atof(sep->arg[1]), target->GetSpawnGroupID());
  3163. else
  3164. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Error setting group spawn chance, check console for details.");
  3165. }
  3166. else
  3167. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group chance [group's spawn chance percentage]");
  3168. }
  3169. else
  3170. {
  3171. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command allows you to modify spawn groups.");
  3172. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn group [create/add/remove/chance/associate/deassociate]");
  3173. }
  3174. }
  3175. else
  3176. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select a valid spawn to use this command.");
  3177. break;
  3178. }
  3179. case COMMAND_SPAWN_COMBINE:{
  3180. Spawn* spawn = cmdTarget;
  3181. float radius = 0;
  3182. bool failed = true;
  3183. if(spawn && !spawn->IsPlayer() && sep && sep->arg[0] && sep->arg[0][0]){
  3184. failed = false;
  3185. if(spawn->GetSpawnGroupID() > 0){
  3186. 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.");
  3187. }
  3188. else if(sep->IsNumber(0)){
  3189. radius = atof(sep->arg[0]);
  3190. client->CombineSpawns(radius, spawn);
  3191. }
  3192. else{
  3193. if(strncasecmp(sep->arg[0], "add", 3) == 0){
  3194. client->AddCombineSpawn(spawn);
  3195. }
  3196. else if(strncasecmp(sep->arg[0], "remove", 6) == 0){
  3197. client->RemoveCombineSpawn(spawn);
  3198. }
  3199. else if(strncasecmp(sep->arg[0], "save", 4) == 0){
  3200. const char* name = 0;
  3201. if(sep->arg[1] && sep->arg[1][0])
  3202. name = sep->argplus[1];
  3203. client->SaveCombineSpawns(name);
  3204. }
  3205. else
  3206. failed = true;
  3207. }
  3208. }
  3209. if(failed){
  3210. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command combines several spawns into a single spawn group.");
  3211. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Syntax: /spawn combine [radius/add/remove/save]");
  3212. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Ex: /spawn combine 1, /spawn combine save (spawn group name)");
  3213. }
  3214. break;
  3215. }
  3216. case COMMAND_SPAWN_CREATE:{
  3217. Spawn* spawn = 0;
  3218. if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "object", 6) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  3219. spawn = new Object();
  3220. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3221. }
  3222. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "groundspawn", 11) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  3223. spawn = new GroundSpawn();
  3224. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3225. }
  3226. else if (sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "sign", 4) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) {
  3227. spawn = new Sign();
  3228. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3229. }
  3230. else if(sep && sep->arg[4][0] && strncasecmp(sep->arg[0], "npc", 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)){
  3231. spawn = new NPC();
  3232. memset(&spawn->appearance, 0, sizeof(spawn->appearance));
  3233. spawn->appearance.pos.collision_radius = 32;
  3234. spawn->secondary_command_list_id = 0;
  3235. spawn->primary_command_list_id = 0;
  3236. spawn->appearance.display_name = 1;
  3237. spawn->appearance.show_level = 1;
  3238. spawn->appearance.attackable = 1;
  3239. }
  3240. else{
  3241. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn create [spawn type] [race type] [class type] [level] [name] (difficulty) (size)");
  3242. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are required except difficulty and size. Valid types are Object, NPC, Sign, or GroundSpawn");
  3243. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn create npc 203 1 50 'Lady Vox' 1 32");
  3244. break;
  3245. }
  3246. spawn->SetID(Spawn::NextID());
  3247. spawn->SetX(client->GetPlayer()->GetX());
  3248. spawn->SetY(client->GetPlayer()->GetY());
  3249. spawn->SetZ(client->GetPlayer()->GetZ());
  3250. spawn->SetHeading(client->GetPlayer()->GetHeading());
  3251. spawn->SetSpawnOrigX(spawn->GetX());
  3252. spawn->SetSpawnOrigY(spawn->GetY());
  3253. spawn->SetSpawnOrigZ(spawn->GetZ());
  3254. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  3255. spawn->appearance.targetable = 1;
  3256. spawn->appearance.race = 255;
  3257. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  3258. spawn->SetModelType(atoi(sep->arg[1]));
  3259. spawn->SetAdventureClass(atoi(sep->arg[2]));
  3260. spawn->SetLevel(atoi(sep->arg[3]));
  3261. spawn->SetName(sep->arg[4]);
  3262. if(sep->arg[5][0] && sep->IsNumber(5))
  3263. spawn->SetEncounterLevel(atoi(sep->arg[5]));
  3264. if(sep->arg[6][0] && sep->IsNumber(6))
  3265. spawn->size = atoi(sep->arg[6]);
  3266. if(spawn->GetTotalHP() == 0){
  3267. spawn->SetTotalHP(25*spawn->GetLevel() + 1);
  3268. spawn->SetHP(25*spawn->GetLevel() + 1);
  3269. }
  3270. if(spawn->GetTotalPower() == 0){
  3271. spawn->SetTotalPower(25*spawn->GetLevel() + 1);
  3272. spawn->SetPower(25*spawn->GetLevel() + 1);
  3273. }
  3274. client->GetCurrentZone()->AddSpawn(spawn);
  3275. break;
  3276. }
  3277. case COMMAND_SPAWN_EQUIPMENT:{
  3278. Spawn* spawn = cmdTarget;
  3279. if(spawn && sep && sep->arg[1][0] && sep->IsNumber(0) && sep->IsNumber(1) && spawn->IsEntity()){
  3280. int8 slot = atoi(sep->arg[0]);
  3281. int16 type = atoi(sep->arg[1]);
  3282. int8 red = 0;
  3283. int8 green = 0;
  3284. int8 blue = 0;
  3285. int8 h_red = 0;
  3286. int8 h_green = 0;
  3287. int8 h_blue = 0;
  3288. if(sep->arg[2])
  3289. red = atoi(sep->arg[2]);
  3290. if(sep->arg[3])
  3291. green = atoi(sep->arg[3]);
  3292. if(sep->arg[4])
  3293. blue = atoi(sep->arg[4]);
  3294. if(sep->arg[5])
  3295. h_red = atoi(sep->arg[5]);
  3296. if(sep->arg[6])
  3297. h_green = atoi(sep->arg[6]);
  3298. if(sep->arg[7])
  3299. h_blue = atoi(sep->arg[7]);
  3300. ((Entity*)spawn)->SetEquipment(slot, type, red, green, blue, h_red, h_green, h_blue);
  3301. database.SaveNPCAppearanceEquipment(spawn->GetDatabaseID() , slot, type, red, green, blue, h_red, h_green, h_blue);
  3302. }
  3303. else{
  3304. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn equipment [slot] [appearance id] (red) (green) (blue) (highlight red) (hgreen) (hblue)");
  3305. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn's equipment. ");
  3306. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Slot is 0-24, Appearance ID from appearances table, Colors are 0-255");
  3307. }
  3308. break;
  3309. }
  3310. case COMMAND_SPAWN_DETAILS: {
  3311. Spawn* spawn = cmdTarget;
  3312. if (sep && sep->arg[0][0]) {
  3313. if (cmdTarget)
  3314. {
  3315. if (ToLower(string(sep->arg[0])) == "los")
  3316. {
  3317. bool hasLOS = client->GetPlayer()->CheckLoS(cmdTarget);
  3318. if (hasLOS)
  3319. client->Message(CHANNEL_COLOR_YELLOW, "You have line of sight with %s", spawn->GetName());
  3320. else
  3321. client->Message(CHANNEL_COLOR_RED, "You DO NOT have line of sight with %s", spawn->GetName());
  3322. break;
  3323. }
  3324. else if (ToLower(string(sep->arg[0])) == "bestz")
  3325. {
  3326. glm::vec3 targPos(cmdTarget->GetX(), cmdTarget->GetZ(), cmdTarget->GetY());
  3327. float bestZ = client->GetPlayer()->FindDestGroundZ(targPos, cmdTarget->GetYOffset());
  3328. client->Message(CHANNEL_COLOR_YELLOW, "Best Z for %s is %f", spawn->GetName(), bestZ);
  3329. break;
  3330. }
  3331. else if (ToLower(string(sep->arg[0])) == "pathto")
  3332. {
  3333. break;
  3334. }
  3335. else if (ToLower(string(sep->arg[0])) == "pathfrom")
  3336. {
  3337. break;
  3338. }
  3339. }
  3340. if (sep->IsNumber(0))
  3341. {
  3342. float radius = atof(sep->arg[0]);
  3343. if (!client->GetCurrentZone()->SendRadiusSpawnInfo(client, radius))
  3344. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No results in the radius were found.");
  3345. break;
  3346. }
  3347. }
  3348. if (spawn) {
  3349. const char* type = "NPC";
  3350. if (spawn->IsObject())
  3351. type = "Object";
  3352. else if (spawn->IsSign())
  3353. type = "Sign";
  3354. else if (spawn->IsWidget())
  3355. type = "Widget";
  3356. else if (spawn->IsGroundSpawn())
  3357. type = "GroundSpawn";
  3358. client->Message(CHANNEL_COLOR_YELLOW, "Name: %s, %s ID: %u", spawn->GetName(), type, spawn->GetDatabaseID());
  3359. client->Message(CHANNEL_COLOR_YELLOW, "Last Name: %s, Sub-Title: %s, Prefix: %s, Suffix: %s", spawn->GetLastName(), spawn->GetSubTitle(), spawn->GetPrefixTitle(), spawn->GetSuffixTitle());
  3360. client->Message(CHANNEL_COLOR_YELLOW, "Spawn Location ID: %u, Spawn Group ID: %u", spawn->GetSpawnLocationID(), spawn->GetSpawnGroupID());
  3361. client->Message(CHANNEL_COLOR_YELLOW, "Faction ID: %u, Merchant ID: %u, Transporter ID: %u", spawn->GetFactionID(), spawn->GetMerchantID(), spawn->GetTransporterID());
  3362. client->Message(CHANNEL_COLOR_YELLOW, "Grid ID: %u", spawn->GetLocation());
  3363. client->Message(CHANNEL_COLOR_YELLOW, "Race: %i, Class: %i, Gender: %i", spawn->GetRace(), spawn->GetAdventureClass(), spawn->GetGender());
  3364. client->Message(CHANNEL_COLOR_YELLOW, "Level: %i, HP: %u, Power: %u", spawn->GetLevel(), spawn->GetHP(), spawn->GetPower());
  3365. 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());
  3366. client->Message(CHANNEL_COLOR_YELLOW, "Collision Radius: %i, Size: %i, Difficulty: %i, Heroic: %i", spawn->GetCollisionRadius(), spawn->GetSize(), spawn->GetEncounterLevel(), spawn->GetHeroic());
  3367. client->Message(CHANNEL_COLOR_YELLOW, "Targetable: %i, Show Name: %i, Attackable: %i, Show Level: %i", spawn->GetTargetable(), spawn->GetShowName(), spawn->GetAttackable(), spawn->GetShowLevel());
  3368. client->Message(CHANNEL_COLOR_YELLOW, "Show Command Icon: %i, Display Hand Icon: %i", spawn->GetShowCommandIcon(), spawn->GetShowHandIcon());
  3369. if (spawn->IsEntity()) {
  3370. 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());
  3371. 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());
  3372. }
  3373. client->Message(CHANNEL_COLOR_YELLOW, "Model Type: %i, Soga Race Type: %i", spawn->GetModelType(), spawn->GetSogaModelType());
  3374. client->Message(CHANNEL_COLOR_YELLOW, "Primary Command Type: %u, Secondary Command Type: %u", spawn->GetPrimaryCommandListID(), spawn->GetSecondaryCommandListID());
  3375. 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());
  3376. 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);
  3377. if (spawn->IsNPC())
  3378. client->Message(CHANNEL_COLOR_YELLOW, "Randomize: %u", ((NPC*)spawn)->GetRandomize());
  3379. string details;
  3380. details += "\\#0000FFName: " + string(spawn->GetName()) + "\n";
  3381. details += "Type: " + string(type) + "\n";
  3382. details += "ID: " + to_string(spawn->GetDatabaseID()) + "\n";
  3383. details += "Last Name: " + string(spawn->GetLastName()) + "\n";
  3384. details += "Sub-Title: " + string(spawn->GetSubTitle()) + "\n";
  3385. details += "Prefix: " + string(spawn->GetPrefixTitle()) + "\n";
  3386. details += "Suffix: " + string(spawn->GetSuffixTitle()) + "\n";
  3387. details += "Race: " + to_string(spawn->GetRace()) + "\n";
  3388. details += "Class: " + to_string(spawn->GetAdventureClass()) + "\n";
  3389. details += "Gender: " + to_string(spawn->GetGender()) + "\n";
  3390. details += "Level: " + to_string(spawn->GetLevel()) + "\n";
  3391. details += "HP: " + to_string(spawn->GetHP()) + "\n";
  3392. details += "Power: " + to_string(spawn->GetPower()) + "\n";
  3393. details += "Difficulty: " + to_string(spawn->GetEncounterLevel()) + "\n";
  3394. details += "Heroic: " + to_string(spawn->GetHeroic()) + "\n";
  3395. details += "Group ID: " + to_string(spawn->GetSpawnGroupID()) + "\n";
  3396. details += "Faction ID: " + to_string(spawn->GetFactionID()) + "\n";
  3397. details += "Merchant ID: " + to_string(spawn->GetMerchantID()) + "\n";
  3398. details += "Transport ID: " + to_string(spawn->GetTransporterID()) + "\n";
  3399. details += "Location ID: " + to_string(spawn->GetSpawnLocationID()) + "\n";
  3400. char x[16];
  3401. sprintf(x, "%.2f", spawn->GetX());
  3402. char y[16];
  3403. sprintf(y, "%.2f", spawn->GetY());
  3404. char z[16];
  3405. sprintf(z, "%.2f", spawn->GetZ());
  3406. details += "Location: " + string(x) + ", " + string(y) + ", " + string(z) + "\n";
  3407. string details2;
  3408. details2 += "Heading: " + to_string(spawn->GetHeading()) + "\n";
  3409. details2 += "Grid ID: " + to_string(spawn->GetLocation()) + "\n";
  3410. details2 += "Size: " + to_string(spawn->GetSize()) + "\n";
  3411. details2 += "Collision Radius: " + to_string(spawn->GetCollisionRadius()) + "\n";
  3412. details2 += "Respawn Time: " + to_string(spawn->GetRespawnTime()) + "\n";
  3413. details2 += "Targetable: " + to_string(spawn->GetTargetable()) + "\n";
  3414. details2 += "Show Name: " + to_string(spawn->GetShowName()) + "\n";
  3415. details2 += "Attackable: " + to_string(spawn->GetAttackable()) + "\n";
  3416. details2 += "Show Level: " + to_string(spawn->GetShowLevel()) + "\n";
  3417. details2 += "Show Command Icon: " + to_string(spawn->GetShowCommandIcon()) + "\n";
  3418. details2 += "Display Hand Icon: " + to_string(spawn->GetShowHandIcon()) + "\n";
  3419. details2 += "Model Type: " + to_string(spawn->GetModelType()) + "\n";
  3420. details2 += "Soga Race Type: " + to_string(spawn->GetSogaModelType()) + "\n";
  3421. details2 += "Primary Command ID: " + to_string(spawn->GetPrimaryCommandListID()) + "\n";
  3422. details2 += "Secondary Cmd ID: " + to_string(spawn->GetSecondaryCommandListID()) + "\n";
  3423. details2 += "Visual State: " + to_string(spawn->GetVisualState()) + "\n";
  3424. details2 += "Action State: " + to_string(spawn->GetActionState()) + "\n";
  3425. details2 += "Mood State: " + to_string(spawn->GetMoodState()) + "\n";
  3426. details2 += "Initial State: " + to_string(spawn->GetInitialState()) + "\n";
  3427. details2 += "Activity Status: " + to_string(spawn->GetActivityStatus()) + "\n";
  3428. details2 += "Emote State: " + to_string(spawn->GetEmoteState()) + "\n";
  3429. string details3;
  3430. details3 += "Pitch: " + to_string(spawn->GetPitch()) + "\n";
  3431. details3 += "Roll: " + to_string(spawn->GetRoll()) + "\n";
  3432. details3 += "Hide Hood: " + to_string(spawn->appearance.hide_hood) + "\n";
  3433. string details4;
  3434. if (spawn->IsEntity()) {
  3435. details4 += "Facial Hair Type: " + to_string(((Entity*)spawn)->GetFacialHairType()) + "\n";
  3436. details4 += "Hair Type: " + to_string(((Entity*)spawn)->GetHairType()) + "\n";
  3437. details4 += "Chest Type: " + to_string(((Entity*)spawn)->GetChestType()) + "\n";
  3438. details4 += "Legs Type: " + to_string(((Entity*)spawn)->GetLegsType()) + "\n";
  3439. details4 += "Soga Facial Hair Type: " + to_string(((Entity*)spawn)->GetSogaFacialHairType()) + "\n";
  3440. details4 += "Soga Hair Type: " + to_string(((Entity*)spawn)->GetSogaHairType()) + "\n";
  3441. details4 += "Wing Type: " + to_string(((Entity*)spawn)->GetWingType()) + "\n";
  3442. if (spawn->IsNPC()) {
  3443. details4 += "\nRandomize: " + to_string(((NPC*)spawn)->GetRandomize()) + "\n";
  3444. }
  3445. }
  3446. string title = string(spawn->GetName()) + "(" + to_string(spawn->GetDatabaseID()) + ")";
  3447. client->SendShowBook(client->GetPlayer(), title, 4, details, details2, details3, details4);
  3448. }
  3449. else {
  3450. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn details (radius)");
  3451. 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.");
  3452. }
  3453. break;
  3454. }
  3455. case COMMAND_SPAWN_TARGET:{
  3456. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  3457. int32 spawn_id = atoul(sep->arg[0]);
  3458. int16 response = client->GetCurrentZone()->SetSpawnTargetable(spawn_id);
  3459. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  3460. }
  3461. else if(sep && sep->arg[0][0] && sep->arg[1][0] && sep->IsNumber(1) && ToLower(string(sep->arg[0])) == "radius"){
  3462. float distance = atof(sep->arg[1]);
  3463. int16 response = client->GetCurrentZone()->SetSpawnTargetable(client->GetPlayer(), distance);
  3464. client->Message(CHANNEL_COLOR_YELLOW, "%i spawn(s) in the current zone were reset to targetable.", response);
  3465. }
  3466. else{
  3467. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn target [spawn id]");
  3468. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This will set the given spawn as targetable. Used to change a spawn if it was set to untargetable.");
  3469. }
  3470. break;
  3471. }
  3472. case COMMAND_SPAWN_SET:
  3473. {
  3474. Spawn* spawn = cmdTarget;
  3475. sint16 set_type = -1;
  3476. string type_str;
  3477. if (spawn)
  3478. {
  3479. // check if parameters are (location or list or not player and not a 2nd param), and that there is at least 1 value
  3480. 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)
  3481. {
  3482. // set the type, which will be 0 if location or list or invalid
  3483. set_type = spawn_set_values[ToLower(string(sep->arg[0]))];
  3484. }
  3485. if(set_type > 0)
  3486. {
  3487. // check if spawn set is NOT a char update, or not location, or isn't a number
  3488. 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)
  3489. {
  3490. client->SimpleMessage(CHANNEL_COLOR_RED, "Invalid value for set command.");
  3491. }
  3492. else
  3493. {
  3494. string name = string(spawn->GetName());
  3495. if(SetSpawnCommand(client, spawn, set_type, sep->arg[1]))
  3496. {
  3497. if (set_type == SPAWN_SET_VALUE_EXPANSION_FLAG || set_type == SPAWN_SET_VALUE_HOLIDAY_FLAG)
  3498. {
  3499. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "A /reload spawns is required to properly update the spawns with the xpack/holiday flag.");
  3500. }
  3501. else if(set_type == SPAWN_SET_VALUE_NAME)
  3502. {
  3503. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "New name will not be effective until zone reload.");
  3504. }
  3505. else if(set_type == SPAWN_SET_VALUE_LOCATION)
  3506. {
  3507. spawn->SetLocation(client->GetPlayer()->GetLocation());
  3508. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set '%s' to '%u' for spawn '%s'", sep->arg[0], client->GetPlayer()->GetLocation(), name.c_str());
  3509. }
  3510. else
  3511. {
  3512. client->Message(CHANNEL_COLOR_YELLOW, "Successfully set '%s' to '%s' for spawn '%s'", sep->arg[0], sep->arg[1], name.c_str());
  3513. }
  3514. switch (set_type)
  3515. {
  3516. case SPAWN_SET_VALUE_EXPANSION_FLAG:
  3517. case SPAWN_SET_VALUE_HOLIDAY_FLAG:
  3518. case SPAWN_SET_VALUE_FACTION:
  3519. {
  3520. // not applicable
  3521. break;
  3522. }
  3523. default:
  3524. {
  3525. client->GetCurrentZone()->ApplySetSpawnCommand(client, spawn, set_type, sep->arg[1]);
  3526. break;
  3527. }
  3528. }
  3529. 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))
  3530. {
  3531. if(spawn->GetSpawnLocationID() > 0 && database.UpdateSpawnLocationSpawns(spawn))
  3532. {
  3533. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information.");
  3534. }
  3535. else if(spawn->GetSpawnLocationID() > 0)
  3536. {
  3537. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn information, see console window for details.");
  3538. }
  3539. }
  3540. else
  3541. {
  3542. if(spawn->GetDatabaseID() > 0 && database.SaveSpawnInfo(spawn))
  3543. {
  3544. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully saved spawn.");
  3545. }
  3546. else if(spawn->GetDatabaseID() > 0)
  3547. {
  3548. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Error saving spawn, see console window for details.");
  3549. }
  3550. }
  3551. }
  3552. }
  3553. }
  3554. else if(set_type == 0)
  3555. {
  3556. // /spawn set list - lists all possible attributes that can be changed with this command, 10 per line.
  3557. map<string, int8>::iterator itr;
  3558. int i=0;
  3559. string list;
  3560. for(itr = spawn_set_values.begin(); itr != spawn_set_values.end(); itr++, i++)
  3561. {
  3562. if(i==10)
  3563. {
  3564. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  3565. i = 0;
  3566. }
  3567. if(i>0)
  3568. {
  3569. list.append(", ").append(itr->first);
  3570. }
  3571. else
  3572. {
  3573. list = itr->first;
  3574. }
  3575. }
  3576. if(list.length() > 0)
  3577. {
  3578. // if 1 or more, display in client.
  3579. client->SimpleMessage(CHANNEL_COLOR_YELLOW, list.c_str());
  3580. }
  3581. }
  3582. else
  3583. {
  3584. // syntax fail
  3585. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn set [type] [value]");
  3586. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used to change various settings for the targeted NPC or Object.");
  3587. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "For a list of changeable settings use /spawn set list");
  3588. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Note: /spawn set location does not require a value. The client's current location is used.");
  3589. }
  3590. }
  3591. break;
  3592. }
  3593. case COMMAND_SPAWN_REMOVE:{
  3594. Spawn* spawn = cmdTarget;
  3595. if(spawn && !spawn->IsPlayer()){
  3596. if(spawn->GetSpawnLocationID() > 0){
  3597. if(database.RemoveSpawnFromSpawnLocation(spawn)){
  3598. client->GetCurrentZone()->RemoveSpawn(false, spawn, true, false);
  3599. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully removed spawn from zone");
  3600. }
  3601. else
  3602. client->SimpleMessage(CHANNEL_COLOR_RED, "Error removing spawn, see console window for details.");
  3603. }
  3604. else
  3605. client->SimpleMessage(CHANNEL_COLOR_RED, "This spawn does not have a spawn group associated with it");
  3606. }
  3607. else{
  3608. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn remove");
  3609. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for removing the targeted NPC or Object from the zone.");
  3610. }
  3611. break;
  3612. }
  3613. case COMMAND_SPAWN_LIST:{
  3614. if(sep && sep->arg[0][0]){
  3615. vector<string>* results = database.GetSpawnNameList(sep->argplus[0]);
  3616. vector<string>::iterator itr;
  3617. if(results){
  3618. for(itr=results->begin();itr!=results->end();itr++){
  3619. client->SimpleMessage(CHANNEL_COLOR_YELLOW, (*itr).c_str());
  3620. }
  3621. safe_delete(results);
  3622. }
  3623. else
  3624. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No matches found. ");
  3625. }
  3626. else{
  3627. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn list [name]");
  3628. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Name can be a partial match.");
  3629. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn list Qeynos Guard");
  3630. }
  3631. break;
  3632. }
  3633. case COMMAND_SPAWN_ADD:{
  3634. Spawn* spawn = cmdTarget;
  3635. if(spawn && sep && sep->arg[1][0] && (sep->IsNumber(0) || strncasecmp(sep->arg[0], "new", 3) == 0)){
  3636. if(spawn->GetSpawnLocationID() > 0){
  3637. client->Message(CHANNEL_COLOR_RED, "This spawn already has a spawn group id of %u, use /spawn remove to reassign it", spawn->GetSpawnLocationID());
  3638. break;
  3639. }
  3640. if(spawn->GetDatabaseID() == 0){
  3641. if(database.SaveSpawnInfo(spawn)) {
  3642. char spawn_type[32];
  3643. memset(spawn_type, 0, sizeof(spawn_type));
  3644. if (spawn->IsNPC())
  3645. strncpy(spawn_type, "NPC", sizeof(spawn_type) - 1);
  3646. else if (spawn->IsObject())
  3647. strncpy(spawn_type, "Object", sizeof(spawn_type) - 1);
  3648. else if (spawn->IsSign())
  3649. strncpy(spawn_type, "Sign", sizeof(spawn_type) - 1);
  3650. else if (spawn->IsGroundSpawn())
  3651. strncpy(spawn_type, "GroundSpawn", sizeof(spawn_type) - 1);
  3652. else
  3653. strncpy(spawn_type, "Unknown", sizeof(spawn_type) - 1);
  3654. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn information with a %s id of %u", spawn_type, spawn->GetDatabaseID());
  3655. }
  3656. else
  3657. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn information, see console window for details.");
  3658. }
  3659. int32 spawn_group_id = 0;
  3660. if(strncasecmp(sep->arg[0], "new", 3) == 0)
  3661. spawn_group_id = database.GetNextSpawnLocation();
  3662. else
  3663. spawn_group_id = atol(sep->arg[0]);
  3664. int8 percent = 100;
  3665. if(sep->arg[2] && sep->IsNumber(2))
  3666. percent = atoi(sep->arg[2]);
  3667. spawn->SetSpawnLocationID(spawn_group_id);
  3668. float x_offset = database.GetSpawnLocationPlacementOffsetX(spawn->GetSpawnLocationID());
  3669. float y_offset = database.GetSpawnLocationPlacementOffsetY(spawn->GetSpawnLocationID());
  3670. float z_offset = database.GetSpawnLocationPlacementOffsetZ(spawn->GetSpawnLocationID());
  3671. if(database.SaveSpawnEntry(spawn, sep->arg[1], percent, x_offset, y_offset, z_offset))
  3672. client->Message(CHANNEL_COLOR_YELLOW, "Successfully saved spawn location with a spawn group of %u", spawn->GetSpawnLocationID());
  3673. else
  3674. client->SimpleMessage(CHANNEL_COLOR_RED, "Error saving spawn location, see console window for details.");
  3675. }
  3676. else{
  3677. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn add [spawn group id] [spawn group name] (percentage)");
  3678. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for adding the targeted NPC or Object to the database.");
  3679. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can substitute new for [spawn group id] to create a new one.");
  3680. }
  3681. break;
  3682. }
  3683. case COMMAND_SPAWN:{
  3684. int32 id = 0;
  3685. Spawn* spawn = 0;
  3686. if(sep && sep->arg[0] && sep->IsNumber(0)){
  3687. id = atol(sep->arg[0]);
  3688. spawn = client->GetCurrentZone()->GetSpawn(id);
  3689. }
  3690. if(id > 0 && spawn && spawn->appearance.name[0] == 0)
  3691. id = 0;
  3692. if(!id || !spawn){
  3693. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn [spawn id] (x) (y) (z) (heading) (location)");
  3694. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "All parameters are optional except the id. The spawn id must be in the database.");
  3695. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Ex: /spawn 1 0 0 0 0");
  3696. safe_delete(sep);
  3697. return;
  3698. }
  3699. if(sep && sep->arg[1][0]){
  3700. float x = atof(sep->arg[1]);
  3701. spawn->appearance.pos.X = x;
  3702. }
  3703. else
  3704. spawn->SetX(client->GetPlayer()->GetX(), false);
  3705. if(sep && sep->arg[2][0]){
  3706. float y = atof(sep->arg[2]);
  3707. spawn->appearance.pos.Y = y;
  3708. }
  3709. else
  3710. spawn->SetY(client->GetPlayer()->GetY(), false);
  3711. if(sep && sep->arg[3][0]){
  3712. float z = atof(sep->arg[3]);
  3713. spawn->appearance.pos.Z = z;
  3714. }
  3715. else
  3716. spawn->SetZ(client->GetPlayer()->GetZ(), false);
  3717. if(sep && sep->arg[4][0]){
  3718. float heading = atof(sep->arg[4]);
  3719. spawn->SetHeading(heading);
  3720. }
  3721. else
  3722. spawn->SetHeading(client->GetPlayer()->GetHeading(), false);
  3723. spawn->SetSpawnOrigX(spawn->GetX());
  3724. spawn->SetSpawnOrigY(spawn->GetY());
  3725. spawn->SetSpawnOrigZ(spawn->GetZ());
  3726. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  3727. if(sep && sep->arg[5][0])
  3728. spawn->appearance.pos.grid_id = atol(sep->arg[5]);
  3729. else
  3730. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  3731. if(spawn->IsNPC() && spawn->GetTotalHP() == 0){
  3732. spawn->SetTotalHP(spawn->GetLevel() * 15);
  3733. spawn->SetHP(spawn->GetTotalHP());
  3734. }
  3735. if(spawn->GetTotalPower() == 0){
  3736. spawn->SetTotalPower(spawn->GetLevel() * 15);
  3737. spawn->SetPower(spawn->GetTotalPower());
  3738. }
  3739. const char* script = world.GetSpawnScript(id);
  3740. if(script && lua_interface && lua_interface->GetSpawnScript(script) != 0)
  3741. spawn->SetSpawnScript(string(script));
  3742. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_PRESPAWN);
  3743. client->GetCurrentZone()->AddSpawn(spawn);
  3744. if(spawn->IsNPC())
  3745. spawn->GetZone()->AddLoot((NPC*)spawn);
  3746. spawn->GetZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_SPAWN);
  3747. LogWrite(COMMAND__INFO, 0, "Command", "Received spawn command - Parms: %s", command_parms->data.c_str());
  3748. break;
  3749. }
  3750. case COMMAND_ADMINFLAG:
  3751. {
  3752. if(sep && sep->arg[0]){
  3753. sint16 tmp_status = database.GetCharacterAdminStatus(sep->arg[0]);
  3754. sint16 new_status = atoi(sep->arg[1]);
  3755. if(tmp_status == -10)
  3756. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character does not exist.");
  3757. else if(tmp_status >= client->GetAdminStatus())
  3758. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Reason: Character has same or higher level status.");
  3759. else if (new_status > client->GetAdminStatus())
  3760. client->SimpleMessage(CHANNEL_ERROR, "Unable to flag character. Reason: New status is higher then your status.");
  3761. else{
  3762. Client* client2 = client->GetCurrentZone()->GetClientByName(sep->arg[0]);
  3763. if (!client2)
  3764. client2 = zone_list.GetClientByCharName(sep->arg[0]);
  3765. if(database.UpdateAdminStatus(sep->arg[0],new_status)) {
  3766. client->Message(CHANNEL_COLOR_YELLOW,"Character status updated to %i for %s.",new_status,sep->arg[0]);
  3767. if (client2) {
  3768. client2->SetAdminStatus(new_status);
  3769. client2->Message(CHANNEL_COLOR_YELLOW, "%s has set your admin status to %i.", client->GetPlayer()->GetName(), new_status);
  3770. }
  3771. }
  3772. else
  3773. client->SimpleMessage(CHANNEL_ERROR,"Unable to flag character. Unknown reason.");
  3774. }
  3775. }else{
  3776. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /flag {name} {new_status}");
  3777. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Standard User: 0");
  3778. client->SimpleMessage(CHANNEL_COLOR_YELLOW," Admin User: 100");
  3779. }
  3780. break;
  3781. }
  3782. case COMMAND_CANNEDEMOTE:{
  3783. client->GetCurrentZone()->HandleEmote(client, command_parms->data);
  3784. break;
  3785. }
  3786. case COMMAND_BROADCAST: {
  3787. if (sep && sep->arg[0])
  3788. zone_list.HandleGlobalBroadcast(sep->argplus[0]);
  3789. else
  3790. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /broadcast {message}");
  3791. break;
  3792. }
  3793. case COMMAND_ANNOUNCE: {
  3794. if (sep && sep->arg[0])
  3795. zone_list.HandleGlobalAnnouncement(sep->argplus[0]);
  3796. else
  3797. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /announce {message}");
  3798. break;
  3799. }
  3800. case COMMAND_RELOAD_ITEMS:{
  3801. LogWrite(COMMAND__INFO, 0, "Command", "Reloading items..");
  3802. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Started Reloading items (this might take a few minutes...)");
  3803. database.ReloadItemList();
  3804. database.LoadMerchantInformation();
  3805. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Finished Reloading items.");
  3806. break;
  3807. }
  3808. case COMMAND_ENABLE_ABILITY_QUE:{
  3809. EQ2Packet* app = client->GetPlayer()->GetSpellBookUpdatePacket(client->GetVersion());
  3810. if(app)
  3811. client->QueuePacket(app);
  3812. break;
  3813. }
  3814. case COMMAND_ITEMSEARCH:{
  3815. PacketStruct* packet = configReader.getStruct("WS_StartBroker", client->GetVersion());
  3816. if (packet) {
  3817. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  3818. //packet->setDataByName("unknown", 1);
  3819. packet->setDataByName("unknown2", 5, 0);
  3820. packet->setDataByName("unknown2", 20, 1);
  3821. packet->setDataByName("unknown2", 58, 3);
  3822. packet->setDataByName("unknown2", 40, 4);
  3823. client->QueuePacket(packet->serialize());
  3824. PacketStruct* packet2 = configReader.getStruct("WS_BrokerBags", client->GetVersion());
  3825. if (packet2) {
  3826. packet2->setDataByName("char_id", client->GetCharacterID());
  3827. client->QueuePacket(packet2->serialize()); //send this for now, needed to properly clear data
  3828. safe_delete(packet2);
  3829. }
  3830. safe_delete(packet);
  3831. }
  3832. break;
  3833. }
  3834. case COMMAND_ANIMTEST:{
  3835. PacketStruct* command_packet = configReader.getStruct("WS_CannedEmote", client->GetVersion());
  3836. if(command_packet){
  3837. int32 id = client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer());
  3838. if (cmdTarget)
  3839. id = client->GetPlayer()->GetIDWithPlayerSpawn(cmdTarget);
  3840. command_packet->setDataByName ( "spawn_id" , id);
  3841. int animID = 1;
  3842. if(sep && sep->arg[0] && sep->IsNumber(0))
  3843. animID = atoi(sep->arg[0]);
  3844. VisualState* vs = NULL;
  3845. if(animID == 0)
  3846. {
  3847. vs = visual_states.FindVisualState(sep->arg[0]);
  3848. }
  3849. char msg[128];
  3850. sprintf(msg,"Animation Test ID: %i",animID);
  3851. command_packet->setMediumStringByName ( "emote_msg" , msg );
  3852. if(vs != NULL)
  3853. command_packet->setDataByName ( "anim_type", vs->GetID ( ) );
  3854. else
  3855. command_packet->setDataByName ( "anim_type", animID );
  3856. command_packet->setDataByName ( "unknown0", 0 );
  3857. EQ2Packet* outapp = command_packet->serialize();
  3858. client->QueuePacket(outapp);
  3859. safe_delete(command_packet);
  3860. }
  3861. break;
  3862. }
  3863. case COMMAND_KICK:
  3864. {
  3865. if( sep == 0 || sep->arg[0] == 0)
  3866. {
  3867. client->SimpleMessage(CHANNEL_COLOR_RED, "/kick [name]");
  3868. }
  3869. else
  3870. {
  3871. Client* kickClient = zone_list.GetClientByCharName(string(sep->arg[0]));
  3872. if ( kickClient == client )
  3873. {
  3874. client->Message(CHANNEL_COLOR_RED, "You can't kick yourself!");
  3875. break;
  3876. }
  3877. else if(kickClient != NULL)
  3878. {
  3879. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  3880. if ( maxStatus >= client->GetAdminStatus( ) || kickClient->GetAdminStatus() >= client->GetAdminStatus() )
  3881. {
  3882. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  3883. break;
  3884. }
  3885. client->Message(CHANNEL_COLOR_RED, "Kicking %s...",sep->arg[0]);
  3886. kickClient->Disconnect();
  3887. }
  3888. else
  3889. {
  3890. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  3891. }
  3892. }
  3893. break;
  3894. }
  3895. case COMMAND_LOCK:
  3896. {
  3897. if( sep != NULL && sep->arg[0] != NULL && sep->IsNumber(0)){
  3898. int worldLocked = atoi(sep->arg[0]);
  3899. net.world_locked = worldLocked;
  3900. if ( worldLocked )
  3901. client->Message(CHANNEL_COLOR_YELLOW,"World server has been locked.");
  3902. else
  3903. client->Message(CHANNEL_COLOR_YELLOW,"World server has been unlocked.");
  3904. }
  3905. else
  3906. client->SimpleMessage(CHANNEL_COLOR_RED, "/lock [0/1]");
  3907. break;
  3908. }
  3909. case COMMAND_BAN:{
  3910. if( sep == 0 || sep->arg[0] == 0 || (sep->arg[1][0] != 0 && !sep->IsNumber(1) ) )
  3911. {
  3912. client->SimpleMessage(CHANNEL_COLOR_RED, "/ban [name] [permanent:0/1]");
  3913. }
  3914. else
  3915. {
  3916. Client* kickClient = zone_list.GetClientByCharName(sep->arg[0]);
  3917. if ( kickClient == client )
  3918. {
  3919. client->Message(CHANNEL_COLOR_RED, "You can't ban yourself!");
  3920. break;
  3921. }
  3922. else if(kickClient != NULL)
  3923. {
  3924. sint16 maxStatus = database.GetHighestCharacterAdminStatus(kickClient->GetAccountID());
  3925. if ( maxStatus > client->GetAdminStatus( ) ||
  3926. client->GetAdminStatus ( ) > kickClient->GetAdminStatus ( ) )
  3927. {
  3928. client->Message(CHANNEL_COLOR_RED,"Don't even think about it...");
  3929. break;
  3930. }
  3931. client->Message(CHANNEL_COLOR_RED, "Kicking & Banning %s...",sep->arg[0]);
  3932. int perm = atol(sep->arg[1]);
  3933. if ( perm == 1 )
  3934. database.UpdateAdminStatus(sep->arg[0],-2);
  3935. else
  3936. database.UpdateAdminStatus(sep->arg[0],-1);
  3937. kickClient->Disconnect();
  3938. }
  3939. else
  3940. {
  3941. client->Message(CHANNEL_COLOR_RED, "Could not find %s.",sep->arg[0]);
  3942. }
  3943. }
  3944. break;
  3945. }
  3946. case COMMAND_SET_COMBAT_VOICE:{
  3947. int32 value = 0;
  3948. if(sep && sep->arg[0] && sep->IsNumber(0))
  3949. value = atoi(sep->arg[0]);
  3950. client->GetPlayer()->SetCombatVoice(value);
  3951. break;
  3952. }
  3953. case COMMAND_SET_EMOTE_VOICE:{
  3954. int32 value = 0;
  3955. if(sep && sep->arg[0] && sep->IsNumber(0))
  3956. value = atoi(sep->arg[0]);
  3957. client->GetPlayer()->SetEmoteVoice(value);
  3958. break;
  3959. }
  3960. case COMMAND_GIVEITEM:{
  3961. if(sep && sep->arg[0][0] && sep->arg[0][1] && sep->IsNumber(1)){
  3962. Client* itemToClient = zone_list.GetClientByCharName(sep->arg[0]);
  3963. if ( itemToClient == NULL )
  3964. client->Message(CHANNEL_COLOR_YELLOW,"Could not find %s.",sep->arg[0]);
  3965. else
  3966. {
  3967. int32 item_id = atol(sep->arg[1]);
  3968. client->Message(CHANNEL_COLOR_YELLOW,"Gave %s item id %i.",sep->arg[0],item_id);
  3969. itemToClient->AddItem(item_id);
  3970. }
  3971. }
  3972. else
  3973. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /giveitem [name] [item_id]");
  3974. break;
  3975. }
  3976. case COMMAND_REPORT_BUG : { Command_ReportBug(client, sep); break; }
  3977. case COMMAND_INVENTORY : { Command_Inventory(client, sep, command); break; }
  3978. case COMMAND_WEAPONSTATS : { Command_WeaponStats(client); break; }
  3979. case COMMAND_SKILL :
  3980. case COMMAND_SKILL_ADD :
  3981. case COMMAND_SKILL_REMOVE :
  3982. case COMMAND_SKILL_LIST : { Command_Skills(client, sep, command->handler); break; }
  3983. case COMMAND_ZONE_SET : { Command_ZoneSet(client, sep); break; }
  3984. case COMMAND_ZONE_DETAILS : { Command_ZoneDetails(client, sep); break; }
  3985. case COMMAND_ENTITYCOMMAND :
  3986. case COMMAND_ENTITYCOMMAND_LIST : { Command_EntityCommand(client, sep, command->handler); break; }
  3987. case COMMAND_MERCHANT :
  3988. case COMMAND_MERCHANT_LIST : { Command_Merchant(client, sep, command->handler); break; }
  3989. case COMMAND_APPEARANCE :
  3990. case COMMAND_APPEARANCE_LIST : { Command_Appearance(client, sep, command->handler); break; }
  3991. case COMMAND_TRACK : { Command_Track(client); break; }
  3992. case COMMAND_DISTANCE : { Command_Distance(client); break; }
  3993. case COMMAND_INSPECT_PLAYER : { Command_InspectPlayer(client, sep); break; }
  3994. case COMMAND_ZONE_SAFE : { Command_ZoneSafeCoords(client, sep); break; }
  3995. case COMMAND_GUILDSAY : { Command_GuildSay(client, sep); break; }
  3996. case COMMAND_OFFICERSAY : { Command_OfficerSay(client, sep); break; }
  3997. case COMMAND_SET_GUILD_MEMBER_NOTE : { Command_SetGuildMemberNote(client, sep); break; }
  3998. case COMMAND_SET_GUILD_OFFICER_NOTE : { Command_SetGuildOfficerNote(client, sep); break; }
  3999. case COMMAND_GUILD : { Command_Guild(client, sep); break; }
  4000. case COMMAND_CREATE_GUILD : { Command_CreateGuild(client); break; }
  4001. case COMMAND_GUILDS : { Command_Guilds(client); break; }
  4002. case COMMAND_GUILDS_ADD : { Command_GuildsAdd(client, sep); break; }
  4003. case COMMAND_GUILDS_CREATE : { Command_GuildsCreate(client, sep); break; }
  4004. case COMMAND_GUILDS_DELETE : { Command_GuildsDelete(client, sep); break; }
  4005. case COMMAND_GUILDS_LIST : { Command_GuildsList(client); break; }
  4006. case COMMAND_GUILDS_REMOVE : { Command_GuildsRemove(client, sep); break; }
  4007. case COMMAND_CLAIM : { Command_Claim(client, sep); break; }
  4008. case COMMAND_CLEAR_ALL_QUEUED : { Command_ClearAllQueued(client); break; }
  4009. case COMMAND_LOCATION : { Command_Location(client); break; }
  4010. case COMMAND_LOCATION_ADD : { Command_LocationAdd(client, sep); break; }
  4011. case COMMAND_LOCATION_CREATE : { Command_LocationCreate(client, sep); break; }
  4012. case COMMAND_LOCATION_DELETE : { Command_LocationDelete(client, sep); break; }
  4013. case COMMAND_LOCATION_LIST : { Command_LocationList(client, sep); break; }
  4014. case COMMAND_LOCATION_REMOVE : { Command_LocationRemove(client, sep); break; }
  4015. case COMMAND_GRID : { Command_Grid(client); break; }
  4016. case COMMAND_TRY_ON : { Command_TryOn(client, sep); break; }
  4017. case COMMAND_IRC : { Command_IRC(client, sep); break; }
  4018. case COMMAND_RANDOMIZE : { Command_Randomize(client, sep); break; }
  4019. case COMMAND_AFK : { Command_AFK(client, sep); break; }
  4020. case COMMAND_SHOW_CLOAK : { Command_ShowCloak(client, sep); break; }
  4021. case COMMAND_SHOW_HELM : { Command_ShowHelm(client, sep); break; }
  4022. case COMMAND_SHOW_HOOD : { Command_ShowHood(client, sep); break; }
  4023. case COMMAND_SHOW_HOOD_OR_HELM : { Command_ShowHoodHelm(client, sep); break; }
  4024. case COMMAND_SHOW_RANGED : { Command_ShowRanged(client, sep); break; }
  4025. case COMMAND_STOP_DRINKING : { Command_StopDrinking(client); break; }
  4026. case COMMAND_STOP_EATING : { Command_StopEating(client); break; }
  4027. case COMMAND_TOGGLE_ANONYMOUS : { Command_Toggle_Anonymous(client); break; }
  4028. case COMMAND_TOGGLE_AUTOCONSUME : { Command_Toggle_AutoConsume(client, sep); break; }
  4029. case COMMAND_TOGGLE_BONUS_EXP : { Command_Toggle_BonusXP(client); break; }
  4030. case COMMAND_TOGGLE_COMBAT_EXP : { Command_Toggle_CombatXP(client); break; }
  4031. case COMMAND_TOGGLE_GM_HIDE : { Command_Toggle_GMHide(client); break; }
  4032. case COMMAND_TOGGLE_GM_VANISH : { Command_Toggle_GMVanish(client); break; }
  4033. case COMMAND_TOGGLE_ILLUSIONS : { Command_Toggle_Illusions(client, sep); break; }
  4034. case COMMAND_TOGGLE_LFG : { Command_Toggle_LFG(client); break; }
  4035. case COMMAND_TOGGLE_LFW : { Command_Toggle_LFW(client); break; }
  4036. case COMMAND_TOGGLE_QUEST_EXP : { Command_Toggle_QuestXP(client); break; }
  4037. case COMMAND_TOGGLE_ROLEPLAYING : { Command_Toggle_Roleplaying(client); break; }
  4038. case COMMAND_TOGGLE_DUELS : { Command_Toggle_Duels(client); break; }
  4039. case COMMAND_TOGGLE_TRADES : { Command_Toggle_Trades(client); break; }
  4040. case COMMAND_TOGGLE_GUILDS : { Command_Toggle_Guilds(client); break; }
  4041. case COMMAND_TOGGLE_GROUPS : { Command_Toggle_Groups(client); break; }
  4042. case COMMAND_TOGGLE_RAIDS : { Command_Toggle_Raids(client); break; }
  4043. case COMMAND_TOGGLE_LON : { Command_Toggle_LON(client); break; }
  4044. case COMMAND_TOGGLE_VCINVITE : { Command_Toggle_VoiceChat(client); break; }
  4045. case COMMAND_CANCEL_MAINTAINED : { Command_CancelMaintained(client, sep); break; }
  4046. case COMMAND_MOTD : { Command_MOTD(client); break; }
  4047. case COMMAND_RANDOM : { Command_Random(client, sep); break; }
  4048. case COMMAND_CREATE : { Command_Create(client, sep); break; }
  4049. case COMMAND_CREATEFROMRECIPE : { Command_CreateFromRecipe(client, sep); break; }
  4050. case COMMAND_TITLE : { Command_Title(client); break; }
  4051. case COMMAND_TITLE_LIST : { Command_TitleList(client); break; }
  4052. case COMMAND_TITLE_SETPREFIX : { Command_TitleSetPrefix(client, sep); break; }
  4053. case COMMAND_TITLE_SETSUFFIX : { Command_TitleSetSuffix(client, sep); break; }
  4054. case COMMAND_TITLE_FIX : { Command_TitleFix(client, sep); break; }
  4055. case COMMAND_LANGUAGES : { Command_Languages(client, sep); break; }
  4056. case COMMAND_SET_LANGUAGE : { Command_SetLanguage(client, sep); break; }
  4057. case COMMAND_FOLLOW : { Command_Follow(client, sep); break; }
  4058. case COMMAND_STOP_FOLLOW : { Command_StopFollow(client, sep); break; }
  4059. case COMMAND_LASTNAME : { Command_LastName(client, sep); break; }
  4060. case COMMAND_CONFIRMLASTNAME : { Command_ConfirmLastName(client, sep); break; }
  4061. case COMMAND_PET : { Command_Pet(client, sep); break; }
  4062. case COMMAND_PETNAME : { Command_PetName(client, sep); break; }
  4063. case COMMAND_NAME_PET : { Command_NamePet(client, sep); break; }
  4064. case COMMAND_RENAME : { Command_Rename(client, sep); break; }
  4065. case COMMAND_CONFIRMRENAME : { Command_ConfirmRename(client, sep); break; }
  4066. case COMMAND_PETOPTIONS : { Command_PetOptions(client, sep); break; }
  4067. case COMMAND_START_TRADE : { Command_TradeStart(client, sep); break; }
  4068. case COMMAND_ACCEPT_TRADE : { Command_TradeAccept(client, sep); break; }
  4069. case COMMAND_REJECT_TRADE : { Command_TradeReject(client, sep); break; }
  4070. case COMMAND_CANCEL_TRADE : { Command_TradeCancel(client, sep); break; }
  4071. case COMMAND_SET_TRADE_COIN : { Command_TradeSetCoin(client, sep); break; }
  4072. case COMMAND_ADD_TRADE_COPPER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_COPPER); break; }
  4073. case COMMAND_ADD_TRADE_SILVER : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_SILVER); break; }
  4074. case COMMAND_ADD_TRADE_GOLD : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_GOLD); break; }
  4075. case COMMAND_ADD_TRADE_PLAT : { Command_TradeAddCoin(client, sep, COMMAND_ADD_TRADE_PLAT); break; }
  4076. case COMMAND_REMOVE_TRADE_COPPER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_COPPER); break; }
  4077. case COMMAND_REMOVE_TRADE_SILVER: { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_SILVER); break; }
  4078. case COMMAND_REMOVE_TRADE_GOLD : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_GOLD); break; }
  4079. case COMMAND_REMOVE_TRADE_PLAT : { Command_TradeRemoveCoin(client, sep, COMMAND_REMOVE_TRADE_PLAT); break; }
  4080. case COMMAND_ADD_TRADE_ITEM : { Command_TradeAddItem(client, sep); break; }
  4081. case COMMAND_REMOVE_TRADE_ITEM : { Command_TradeRemoveItem(client, sep); break; }
  4082. case COMMAND_ACCEPT_ADVANCEMENT : { Command_AcceptAdvancement(client, sep); break; }
  4083. case COMMAND_DUEL : { Command_Duel(client, sep); break; }
  4084. case COMMAND_DUELBET : { Command_DuelBet(client, sep); break; }
  4085. case COMMAND_DUEL_ACCEPT : { Command_DuelAccept(client, sep); break; }
  4086. case COMMAND_DUEL_DECLINE : { Command_DuelDecline(client, sep); break; }
  4087. case COMMAND_DUEL_SURRENDER : { Command_DuelSurrender(client, sep); break; }
  4088. case COMMAND_DUEL_TOGGLE : { Command_DuelToggle(client, sep); break; }
  4089. case COMMAND_SPAWN_TEMPLATE : { Command_SpawnTemplate(client, sep); break; }
  4090. case COMMAND_MODIFY : { Command_Modify(client); break; }
  4091. case COMMAND_MODIFY_CHARACTER : { Command_ModifyCharacter(client, sep); break; }
  4092. case COMMAND_MODIFY_QUEST : { Command_ModifyQuest(client, sep); break; }
  4093. case COMMAND_MODIFY_FACTION : { Command_ModifyFaction(client, sep); break; }
  4094. case COMMAND_MODIFY_GUILD : { Command_ModifyGuild(client, sep); break; }
  4095. case COMMAND_MODIFY_ITEM : { Command_ModifyItem(client, sep); break; }
  4096. case COMMAND_MODIFY_SKILL : { Command_ModifySkill(client, sep); break; }
  4097. case COMMAND_MODIFY_SPAWN : { Command_ModifySpawn(client, sep); break; }
  4098. case COMMAND_MODIFY_SPELL : { Command_ModifySpell(client, sep); break; }
  4099. case COMMAND_MODIFY_ZONE : { Command_ModifyZone(client, sep); break; }
  4100. case COMMAND_JOIN_CHANNEL : { Command_JoinChannel(client, sep); break;}
  4101. case COMMAND_JOIN_CHANNEL_FROM_LOAD: { Command_JoinChannelFromLoad(client, sep); break;}
  4102. case COMMAND_TELL_CHANNEL : { Command_TellChannel(client, sep); break;}
  4103. case COMMAND_LEAVE_CHANNEL : { Command_LeaveChannel(client, sep); break;}
  4104. case COMMAND_WHO_CHANNEL : { Command_WhoChannel(client, sep); break;}
  4105. case COMMAND_RAIN : { Command_Rain(client, sep); break; }
  4106. case COMMAND_WIND : { Command_Wind(client, sep); break; }
  4107. case COMMAND_WEATHER : { Command_Weather(client, sep); break; }
  4108. case COMMAND_FROM_MERCHANT : { Command_SendMerchantWindow(client, sep); break; }
  4109. case COMMAND_TO_MERCHANT : { Command_SendMerchantWindow(client, sep, true); break; }
  4110. case COMMAND_SELECT : { Command_Select(client, sep); break; }
  4111. case COMMAND_SMP : { Command_StationMarketPlace(client, sep); break; }
  4112. case COMMAND_CONSUME_FOOD : { Command_ConsumeFood(client, sep); break; }
  4113. case COMMAND_AQUAMAN : { Command_Aquaman(client, sep); break; }
  4114. case COMMAND_ATTUNE_INV : { Command_Attune_Inv(client, sep); break; }
  4115. case COMMAND_PLAYER : { Command_Player(client, sep); break; }
  4116. case COMMAND_PLAYER_COINS : { Command_Player_Coins(client, sep); break; }
  4117. case COMMAND_RESET_ZONE_TIMER : { Command_Reset_Zone_Timer(client, sep); break; }
  4118. case COMMAND_ACHIEVEMENT_ADD : { Command_AchievementAdd(client, sep); break; }
  4119. case COMMAND_EDITOR : { Command_Editor(client, sep); break; }
  4120. case COMMAND_ACCEPT_RESURRECTION: { Command_AcceptResurrection(client, sep); break; }
  4121. case COMMAND_DECLINE_RESURRECTION:{ Command_DeclineResurrection(client, sep); break; }
  4122. case COMMAND_TEST : { Command_Test(client, command_parms); break; }
  4123. case COMMAND_SPEED : { Command_Speed(client, sep); break; }
  4124. case COMMAND_BOT : { Command_Bot(client, sep); break; }
  4125. case COMMAND_BOT_CREATE : { Command_Bot_Create(client, sep); break; }
  4126. case COMMAND_BOT_CUSTOMIZE : { Command_Bot_Customize(client, sep); break; }
  4127. case COMMAND_BOT_SPAWN : { Command_Bot_Spawn(client, sep); break; }
  4128. case COMMAND_BOT_LIST : { Command_Bot_List(client, sep); break; }
  4129. case COMMAND_BOT_INV : { Command_Bot_Inv(client, sep); break; }
  4130. case COMMAND_BOT_SETTINGS : { Command_Bot_Settings(client, sep); break; }
  4131. case COMMAND_BOT_HELP : { Command_Bot_Help(client, sep); break; }
  4132. case GET_AA_XML : { Get_AA_Xml(client, sep); break; }
  4133. case ADD_AA : { Add_AA(client, sep); break; }
  4134. case COMMIT_AA_PROFILE : { Commit_AA_Profile(client, sep); break; }
  4135. case BEGIN_AA_PROFILE : { Begin_AA_Profile(client, sep); break; }
  4136. case BACK_AA : { Back_AA(client, sep); break; }
  4137. case REMOVE_AA : { Remove_AA(client, sep); break; }
  4138. case SWITCH_AA_PROFILE : { Switch_AA_Profile(client, sep); break; }
  4139. case CANCEL_AA_PROFILE : { Cancel_AA_Profile(client, sep); break; }
  4140. case SAVE_AA_PROFILE : { Save_AA_Profile(client, sep); break; }
  4141. case COMMAND_TARGETITEM : { Command_TargetItem(client, sep); break; }
  4142. case COMMAND_FINDSPAWN: { Command_FindSpawn(client, sep); break; }
  4143. default:
  4144. {
  4145. LogWrite(COMMAND__WARNING, 0, "Command", "Unhandled command: %s", command->command.data.c_str());
  4146. break;
  4147. }
  4148. }
  4149. safe_delete(sep);
  4150. }
  4151. /******************** New COMMAND Handler Functions ********************/
  4152. /*
  4153. Started breaking apart the huge switch() for commands into sepErate
  4154. functions so it is easier to locate the blocks of code by command
  4155. -- JA 2012.03.03
  4156. */
  4157. // sample function header
  4158. /*
  4159. Function:
  4160. Purpose :
  4161. Params :
  4162. Dev :
  4163. Example :
  4164. */
  4165. //void Commands::Command()
  4166. //{
  4167. //}
  4168. /*
  4169. Function: Command_AcceptAdvancement()
  4170. Purpose : Player accepts a new advancement option
  4171. Params : Spell ID
  4172. Dev : Jabantiz
  4173. */
  4174. void Commands::Command_AcceptAdvancement(Client* client, Seperator* sep)
  4175. {
  4176. Player *player = client->GetPlayer();
  4177. if (sep && sep->IsSet(0)) {
  4178. TraitData* trait = master_trait_list.GetTrait(atoul(sep->arg[0]));
  4179. // Check to see if this is a trait or grandmaster training (traits are always new spells, training is always upgrades)
  4180. if (!player->HasSpell(trait->spellID, 0, true))
  4181. {
  4182. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  4183. player->AddSpellBookEntry(trait->spellID, trait->tier, player->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  4184. }
  4185. else
  4186. {
  4187. Spell* spell = master_spell_list.GetSpell(trait->spellID, trait->tier);
  4188. int8 old_slot = player->GetSpellSlot(spell->GetSpellID());
  4189. player->RemoveSpellBookEntry(spell->GetSpellID());
  4190. player->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  4191. player->UnlockSpell(spell);
  4192. client->SendSpellUpdate(spell);
  4193. }
  4194. // Spell book update
  4195. client->QueuePacket(player->GetSpellBookUpdatePacket(client->GetVersion()));
  4196. client->QueuePacket(master_trait_list.GetTraitListPacket(client));
  4197. }
  4198. }
  4199. /*
  4200. Function:
  4201. Purpose :
  4202. Params :
  4203. Dev :
  4204. Example :
  4205. */
  4206. void Commands::Command_AFK(Client* client, Seperator* sep)
  4207. {
  4208. Player* player = client->GetPlayer();
  4209. player->toggle_character_flag(CF_AFK);
  4210. client->Message(CHANNEL_COLOR_YELLOW,"You are %s afk.", client->GetPlayer()->get_character_flag(CF_AFK)?"now":"no longer");
  4211. if (player->get_character_flag(CF_AFK))
  4212. {
  4213. LogWrite(MISC__TODO, 1, "TODO", "player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_AFK); <-- need to find this");
  4214. /*player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_AFK); <-- need to find this */
  4215. if (sep && sep->argplus[0])
  4216. player->SetAwayMessage("I am away from the keyboard, " + string(sep->argplus[0]));
  4217. else
  4218. player->SetAwayMessage("Sorry, I am A.F.K. (Away From Keyboard)");
  4219. string message = string(player->GetName()) + " is going afk.";
  4220. Spawn* target = player->GetTarget();
  4221. if (target && target != player)
  4222. {
  4223. message = string(player->GetName()) + " tells " + string(target->GetName()) + " that ";
  4224. player->GetGender() == 1 ? message += "he" : message += "she";
  4225. message += " is going afk.";
  4226. }
  4227. player->GetZone()->SimpleMessage(CHANNEL_COLOR_YELLOW, message.c_str(), player, 30);
  4228. }
  4229. /*else
  4230. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_AFK); <-- need to find this */
  4231. }
  4232. /*
  4233. Function: Command_Appearance()
  4234. Purpose : Handles /appearance commands
  4235. Params : list
  4236. Dev : Scatman
  4237. Example : /appearance list
  4238. */
  4239. void Commands::Command_Appearance(Client* client, Seperator* sep, int handler)
  4240. {
  4241. if( handler == COMMAND_APPEARANCE )
  4242. {
  4243. // /appearance command by itself shows help (to be extended)
  4244. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  4245. return;
  4246. }
  4247. else if( handler == COMMAND_APPEARANCE_LIST )
  4248. {
  4249. // /appearance list command expects "name" param
  4250. if (sep && sep->arg[0])
  4251. {
  4252. const char* appearance_name = sep->argplus[0];
  4253. client->Message(CHANNEL_COLOR_YELLOW, "Listing appearances like '%s':", appearance_name);
  4254. vector<int16>* appearances = database.GetAppearanceIDsLikeName(string(appearance_name));
  4255. if (appearances)
  4256. {
  4257. vector<int16>::iterator itr;
  4258. for (itr = appearances->begin(); itr != appearances->end(); itr++)
  4259. {
  4260. int16 id = *itr;
  4261. string name = database.GetAppearanceName(id);
  4262. if (ToLower(name).find(ToLower(string(appearance_name))) < 0xFFFFFFFF)
  4263. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", name.c_str(), id);
  4264. }
  4265. safe_delete(appearances);
  4266. }
  4267. }
  4268. else // no param
  4269. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /appearance list [appearance name]");
  4270. }
  4271. }
  4272. /*
  4273. Function: Command_Claim()
  4274. Purpose :
  4275. Params :
  4276. Dev :
  4277. Example :
  4278. */
  4279. void Commands::Command_Claim(Client* client, Seperator* sep)
  4280. {
  4281. if (sep && sep->arg[0] && sep->IsNumber(0))
  4282. {
  4283. LogWrite(MISC__TODO, 1, "TODO", "On Scatman's TODO list!\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  4284. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "On Scatman's TODO :)");
  4285. }
  4286. else
  4287. client->ShowClaimWindow();
  4288. }
  4289. /*
  4290. Function: Command_ClearAllQueued()
  4291. Purpose :
  4292. Params :
  4293. Dev :
  4294. Example :
  4295. */
  4296. void Commands::Command_ClearAllQueued(Client* client)
  4297. {
  4298. ZoneServer* zone = client->GetPlayer()->GetZone();
  4299. if (zone && zone->GetSpellProcess())
  4300. zone->GetSpellProcess()->RemoveSpellFromQueue(client->GetPlayer());
  4301. }
  4302. /*
  4303. Function: Command_CancelMaintained()
  4304. Purpose : Cancels maintained spells
  4305. Params : Maintained Spell Index
  4306. Dev : Zcoretri
  4307. Example : /cancel_maintained 1 - would cancel the spell in slot 1 of Maintained Spells list
  4308. */
  4309. void Commands::Command_CancelMaintained(Client* client, Seperator* sep)
  4310. {
  4311. if (sep && sep->arg[0] && sep->IsNumber(0))
  4312. {
  4313. int32 spell_index = atoul(sep->arg[0]);
  4314. MaintainedEffects mEffects = client->GetPlayer()->GetInfoStruct()->maintained_effects[spell_index];
  4315. //Spell* spell = master_spell_list.GetSpell(mEffects.spell_id, mEffects.tier);
  4316. // if (spell && spell->GetSpellData()->friendly_spell) -- NOTE::You can cancel hostile maintained spells,
  4317. // just not spelleffects/dets - Foof
  4318. //{
  4319. if (!client->GetPlayer()->GetZone()->GetSpellProcess()->DeleteCasterSpell(mEffects.spell))
  4320. client->Message(CHANNEL_COLOR_RED, "The maintained spell could not be cancelled.");
  4321. // }
  4322. //else
  4323. //client->Message(CHANNEL_COLOR_RED, "You can only cancel friendly spells!");
  4324. }
  4325. }
  4326. /*
  4327. Function: Command_Create()
  4328. Purpose : Handler for starting Tradeskilling table
  4329. Params :
  4330. Dev : Zcoretri
  4331. Example :
  4332. */
  4333. void Commands::Command_Create(Client* client, Seperator* sep)
  4334. {
  4335. PrintSep(sep, "COMMAND_CREATE");
  4336. client->SendRecipeList();
  4337. client->ShowRecipeBook();
  4338. }
  4339. void Commands::Command_CreateFromRecipe(Client* client, Seperator* sep)
  4340. {
  4341. PrintSep(sep, "COMMAND_CREATEFROMRECIPE");
  4342. if (sep && sep->arg[0] && sep->IsNumber(0))
  4343. ClientPacketFunctions::SendCreateFromRecipe(client, atoul(sep->arg[0]));
  4344. }
  4345. /*
  4346. Function: Command_Distance()
  4347. Purpose : Displays distance from targeted spawn
  4348. Params :
  4349. Dev : Scatman
  4350. Example : /distance
  4351. */
  4352. void Commands::Command_Distance(Client* client)
  4353. {
  4354. Spawn* target = client->GetPlayer()->GetTarget();
  4355. if (target)
  4356. client->Message(CHANNEL_COLOR_YELLOW, "Your distance from %s is %f", target->GetName(), client->GetPlayer()->GetDistance(target));
  4357. else
  4358. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must have a spawn targeted to use /distance");
  4359. }
  4360. /*
  4361. Function: Command_Duel()
  4362. Purpose : Handle the /duel commands - not yet implemented
  4363. Params : unknown
  4364. Dev :
  4365. Example :
  4366. */
  4367. void Commands::Command_Duel(Client* client, Seperator* sep)
  4368. {
  4369. PrintSep(sep, "COMMAND_DUEL");
  4370. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Command");
  4371. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4372. }
  4373. /*
  4374. Function: Command_DuelBet()
  4375. Purpose : Handle the /duel commands - not yet implemented
  4376. Params : unknown
  4377. Dev :
  4378. Example :
  4379. */
  4380. void Commands::Command_DuelBet(Client* client, Seperator* sep)
  4381. {
  4382. PrintSep(sep, "COMMAND_DUELBET");
  4383. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Bet Command");
  4384. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4385. }
  4386. /*
  4387. Function: Command_DuelAccept()
  4388. Purpose : Handle the /duel commands - not yet implemented
  4389. Params : unknown
  4390. Dev :
  4391. Example :
  4392. */
  4393. void Commands::Command_DuelAccept(Client* client, Seperator* sep)
  4394. {
  4395. PrintSep(sep, "COMMAND_DUEL_ACCEPT");
  4396. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Accept Duel Command");
  4397. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4398. }
  4399. /*
  4400. Function: Command_DuelDecline()
  4401. Purpose : Handle the /duel commands - not yet implemented
  4402. Params : unknown
  4403. Dev :
  4404. Example :
  4405. */
  4406. void Commands::Command_DuelDecline(Client* client, Seperator* sep)
  4407. {
  4408. PrintSep(sep, "COMMAND_DUEL_DECLINE");
  4409. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Decline Duel Request Command");
  4410. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4411. }
  4412. /*
  4413. Function: Command_DuelSurrender()
  4414. Purpose : Handle the /duel commands - not yet implemented
  4415. Params : unknown
  4416. Dev :
  4417. Example :
  4418. */
  4419. void Commands::Command_DuelSurrender(Client* client, Seperator* sep)
  4420. {
  4421. PrintSep(sep, "COMMAND_DUEL_SURRENDER");
  4422. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Surrender Duel Command");
  4423. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4424. // JA, just messin around ;)
  4425. char surrender[64];
  4426. sprintf(surrender, "%s surrendered like a cowardly dog!", client->GetPlayer()->GetName());
  4427. zone_list.HandleGlobalAnnouncement(surrender);
  4428. }
  4429. /*
  4430. Function: Command_DuelToggle()
  4431. Purpose : Handle the /duel commands - not yet implemented
  4432. Params : unknown
  4433. Dev :
  4434. Example :
  4435. */
  4436. void Commands::Command_DuelToggle(Client* client, Seperator* sep)
  4437. {
  4438. PrintSep(sep, "COMMAND_DUEL");
  4439. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Duel Commands");
  4440. client->Message(CHANNEL_COLOR_YELLOW, "You cannot duel other players (Not Implemented)");
  4441. }
  4442. /*
  4443. Function:
  4444. Purpose :
  4445. Params :
  4446. Dev :
  4447. Example :
  4448. */
  4449. void Commands::Command_EntityCommand(Client* client, Seperator* sep, int handler)
  4450. {
  4451. if( handler == COMMAND_ENTITYCOMMAND )
  4452. {
  4453. // /entitycommand command by itself shows help (to be extended)
  4454. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  4455. return;
  4456. }
  4457. else if( handler == COMMAND_ENTITYCOMMAND_LIST )
  4458. {
  4459. // /entitycommand list command expects "name" param
  4460. if (sep && sep->arg[0])
  4461. {
  4462. const char* entity_command_name = sep->argplus[0];
  4463. client->Message(CHANNEL_COLOR_YELLOW, "Listing entity commands like '%s':", entity_command_name);
  4464. map<int32, vector<EntityCommand*>*>* entity_command_list_all = client->GetCurrentZone()->GetEntityCommandListAll();
  4465. map<int32, vector<EntityCommand*>*>::iterator itr;
  4466. for (itr = entity_command_list_all->begin(); itr != entity_command_list_all->end(); itr++)
  4467. {
  4468. vector<EntityCommand*>* entity_command_list = itr->second;
  4469. vector<EntityCommand*>::iterator itr2;
  4470. for (itr2 = entity_command_list->begin(); itr2 != entity_command_list->end(); itr2++)
  4471. {
  4472. EntityCommand* entity_command = *itr2;
  4473. if (ToLower(entity_command->name).find(ToLower(string(entity_command_name))) < 0xFFFFFFFF)
  4474. 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);
  4475. }
  4476. }
  4477. }
  4478. else // no command name
  4479. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /entity_command list [entity command name]");
  4480. }
  4481. }
  4482. /*
  4483. Function: Command_Follow()
  4484. Purpose : Handle the /follow command - not yet implemented
  4485. Params :
  4486. Dev :
  4487. Example :
  4488. */
  4489. void Commands::Command_Follow(Client* client, Seperator* sep)
  4490. {
  4491. PrintSep(sep, "COMMAND_FOLLOW");
  4492. // flag to toggle if the players target is in the players group
  4493. bool targetInGroup = false;
  4494. // get a pointer to the players group
  4495. GroupMemberInfo* gmi = client->GetPlayer()->GetGroupMemberInfo();
  4496. // If the player has a group and has a target
  4497. if (gmi && client->GetPlayer()->GetTarget()) {
  4498. deque<GroupMemberInfo*>::iterator itr;
  4499. world.GetGroupManager()->GroupLock(__FUNCTION__, __LINE__);
  4500. deque<GroupMemberInfo*>* members = world.GetGroupManager()->GetGroupMembers(gmi->group_id);
  4501. // Loop through the group members
  4502. for (itr = members->begin(); itr != members->end(); itr++) {
  4503. // If a group member matches a target
  4504. if ((*itr)->member == client->GetPlayer()->GetTarget()) {
  4505. // toggle the flag and break the loop
  4506. targetInGroup = true;
  4507. break;
  4508. }
  4509. }
  4510. world.GetGroupManager()->ReleaseGroupLock(__FUNCTION__, __LINE__);
  4511. }
  4512. if (targetInGroup) {
  4513. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  4514. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You start to follow %s.", client->GetPlayer()->GetTarget()->GetName());
  4515. client->GetPlayer()->SetFollowTarget(client->GetPlayer()->GetTarget());
  4516. client->GetPlayer()->info_changed = true;
  4517. client->GetPlayer()->changed = true;
  4518. }
  4519. else
  4520. client->Message(CHANNEL_COLOR_WHITE, "You must first select a group member to follow.");
  4521. }
  4522. /*
  4523. Function: Command_StopFollow()
  4524. Purpose : Handle the /stop_follow command - not yet implemented
  4525. Params :
  4526. Dev :
  4527. Example :
  4528. */
  4529. void Commands::Command_StopFollow(Client* client, Seperator* sep)
  4530. {
  4531. PrintSep(sep, "COMMAND_STOP_FOLLOW");
  4532. if (client->GetPlayer()->GetFollowTarget()) {
  4533. // CHANNEL_COLOR_CHAT_RELATIONSHIP = 4, which matches the value in logs
  4534. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You are no longer following %s", client->GetPlayer()->GetFollowTarget()->GetName());
  4535. client->GetPlayer()->SetFollowTarget(0);
  4536. client->GetPlayer()->info_changed = true;
  4537. client->GetPlayer()->changed = true;
  4538. }
  4539. }
  4540. #include "../Zone/SPGrid.h"
  4541. /*
  4542. Function: Command_Grid()
  4543. Purpose : Show player's current Grid ID
  4544. Params :
  4545. Dev : Scatman
  4546. Example : /grid
  4547. */
  4548. void Commands::Command_Grid(Client* client)
  4549. {
  4550. client->Message(CHANNEL_COLOR_YELLOW, "Your Grid ID is %u", client->GetPlayer()->appearance.pos.grid_id);
  4551. if (client->GetCurrentZone()->Grid != nullptr) {
  4552. int32 grid = client->GetCurrentZone()->Grid->GetGridID(client->GetPlayer());
  4553. client->Message(CHANNEL_COLOR_YELLOW, "SPGrid result is %u", grid);
  4554. }
  4555. }
  4556. /*
  4557. Function: Command_Guild()
  4558. Purpose : Handler for all UI-related guild commands
  4559. Dev : Scatman
  4560. */
  4561. void Commands::Command_Guild(Client* client, Seperator* sep)
  4562. {
  4563. Guild* guild = client->GetPlayer()->GetGuild();
  4564. if (sep && sep->GetMaxArgNum() > 0 && sep->arg[0])
  4565. {
  4566. const char* command = sep->arg[0];
  4567. int32 length = strlen(command);
  4568. LogWrite(COMMAND__DEBUG, 0, "Command", "Guild Command: %s", command);
  4569. if (strncmp(command, "rank_name", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && guild)
  4570. guild->SetRankName(atoi(sep->arg[1]), sep->argplus[2]);
  4571. else if (strncmp(command, "rank_permission", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  4572. guild->SetPermission(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  4573. else if (strncmp(command, "filter_event", length) == 0 && sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && guild)
  4574. guild->SetEventFilter(atoi(sep->arg[1]), atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  4575. else if (strncmp(command, "kick", length) == 0 && sep->arg[1] && guild)
  4576. guild->KickGuildMember(client, sep->arg[1]);
  4577. else if (strncmp(command, "demote", length) == 0 && sep->arg[1] && guild)
  4578. guild->DemoteGuildMember(client, sep->arg[1]);
  4579. else if (strncmp(command, "promote", length) == 0 && sep->arg[1] && guild)
  4580. guild->PromoteGuildMember(client, sep->arg[1]);
  4581. else if (strncmp(command, "points", length) == 0 && guild)
  4582. {
  4583. if (sep->arg[1] && strncmp(sep->arg[1], "add", length) == 0)
  4584. {
  4585. if (sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  4586. {
  4587. float points = atof(sep->arg[2]);
  4588. const char* option = sep->arg[3];
  4589. const char* comment = sep->argplus[4];
  4590. if (strncmp(option, "all", strlen(option)) == 0)
  4591. guild->AddPointsToAll(client, points, comment);
  4592. else if (strncmp(option, "online", strlen(option)) == 0)
  4593. guild->AddPointsToAllOnline(client, points, comment);
  4594. else if (strncmp(option, "group", strlen(option)) == 0)
  4595. guild->AddPointsToGroup(client, points, comment);
  4596. else if (strncmp(option, "raid", strlen(option)) == 0)
  4597. guild->AddPointsToRaid(client, points, comment);
  4598. else
  4599. guild->AddPointsToGuildMember(client, points, option, comment);
  4600. }
  4601. }
  4602. else if (sep->arg[1] && strncmp(sep->arg[1], "view", strlen(sep->arg[1])) == 0 && sep->arg[2])
  4603. guild->ViewGuildMemberPoints(client, sep->arg[2]);
  4604. else
  4605. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild points command: %s", sep->argplus[0]);
  4606. }
  4607. else if (strncmp(command, "motd", length) == 0 && sep->arg[1] && guild)
  4608. guild->SetMOTD(sep->argplus[1]);
  4609. else if (strncmp(command, "recruiting", length) == 0 && guild)
  4610. {
  4611. if (sep->arg[1])
  4612. {
  4613. const char* option = sep->arg[1];
  4614. if (strncmp(option, "short_text", strlen(option)) == 0 && sep->arg[2])
  4615. guild->SetRecruitingShortDesc(sep->argplus[2]);
  4616. else if (strncmp(option, "long_text", strlen(option)) == 0 && sep->arg[2])
  4617. guild->SetRecruitingFullDesc(sep->argplus[2]);
  4618. else if (strncmp(option, "flag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3])
  4619. guild->SetRecruitingFlag(atoi(sep->arg[2]), strncmp(sep->arg[3], "true", 4) == 0 ? 1 : 0);
  4620. else if (strncmp(option, "min_level", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  4621. guild->SetRecruitingMinLevel(atoi(sep->arg[2]));
  4622. else if (strncmp(option, "playstyle", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2))
  4623. guild->SetRecruitingPlayStyle(atoi(sep->arg[2]));
  4624. else if (strncmp(option, "tag", strlen(option)) == 0 && sep->arg[2] && sep->IsNumber(2) && sep->arg[3] && sep->IsNumber(3))
  4625. guild->SetRecruitingDescTag(atoi(sep->arg[2]), atoi(sep->arg[3]));
  4626. else if (strncmp(command, "recruiting", strlen(option)) == 0)
  4627. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_RECRUITING_FOR_GUILD, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  4628. else
  4629. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  4630. }
  4631. else
  4632. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiting command: %s", sep->argplus[0]);
  4633. }
  4634. else if (strncmp(command, "notify_online", length) == 0 && sep->arg[1] && guild)
  4635. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_NOTIFY_LOGINS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  4636. else if (strncmp(command, "event_privacy", length) == 0 && sep->arg[1] && guild)
  4637. guild->ChangeMemberFlag(client, GUILD_MEMBER_FLAGS_DONT_GENERATE_EVENTS, strncmp(sep->arg[1], "true", 4) == 0 ? 1 : 0);
  4638. else if (strncmp(command, "recruiter", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  4639. guild->SetGuildRecruiter(client, sep->arg[1], strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  4640. else if (strncmp(command, "recruiter_description", length) == 0 && sep->arg[1] && guild)
  4641. guild->SetGuildRecruiterDescription(client, sep->argplus[1]);
  4642. else if (strncmp(command, "lock_event", length) == 0 && sep->arg[1] && sep->arg[2] && guild)
  4643. guild->LockGuildEvent(atoul(sep->arg[1]), strncmp(sep->arg[2], "true", 4) == 0 ? true : false);
  4644. else if (strncmp(command, "delete_event", length) == 0 && sep->arg[1] && guild)
  4645. guild->DeleteGuildEvent(atoul(sep->arg[1]));
  4646. else if (strncmp(command, "invite", length) == 0 && guild)
  4647. {
  4648. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  4649. guild->InvitePlayer(client, sep->arg[1]);
  4650. else
  4651. {
  4652. Spawn* target = client->GetPlayer()->GetTarget();
  4653. if (target)
  4654. {
  4655. if (target->IsPlayer())
  4656. guild->InvitePlayer(client, target->GetName());
  4657. else
  4658. client->Message(CHANNEL_COLOR_WHITE, "%s is not a player.", target->GetName());
  4659. }
  4660. }
  4661. }
  4662. else if (strncmp(command, "accept", length) == 0)
  4663. {
  4664. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  4665. if (pgi && pgi->guild && pgi->invited_by)
  4666. pgi->guild->AddNewGuildMember(client, pgi->invited_by->GetName());
  4667. client->SetPendingGuildInvite(0);
  4668. }
  4669. else if (strncmp(command, "decline", length) == 0)
  4670. {
  4671. PendingGuildInvite* pgi = client->GetPendingGuildInvite();
  4672. if (pgi && pgi->guild && pgi->invited_by)
  4673. {
  4674. Client* client_inviter = pgi->invited_by->GetZone()->GetClientBySpawn(pgi->invited_by);
  4675. if (client_inviter)
  4676. client_inviter->Message(CHANNEL_COLOR_WHITE, "%s has declined your invitation to join %s.", client->GetPlayer()->GetName(), pgi->guild->GetName());
  4677. }
  4678. client->SetPendingGuildInvite(0);
  4679. }
  4680. else if (strncmp(command, "create", length) == 0 && sep->arg[1])
  4681. {
  4682. const char* guild_name = sep->argplus[1];
  4683. if (!guild_list.GetGuild(guild_name))
  4684. world.CreateGuild(guild_name, client, client->GetPlayer()->GetGroupMemberInfo() ? client->GetPlayer()->GetGroupMemberInfo()->group_id : 0);
  4685. else
  4686. client->SimpleMessage(CHANNEL_COLOR_WHITE, "A guild with that name already exists.");
  4687. }
  4688. else if (strncmp(command, "search", length) == 0)
  4689. client->ShowGuildSearchWindow();
  4690. else if (strncmp(command, "recruiting_details", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  4691. {
  4692. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  4693. if (to_guild)
  4694. to_guild->SendGuildRecruitingDetails(client);
  4695. }
  4696. else if (strncmp(command, "recruiting_image", length) == 0 && sep->arg[1] && sep->IsNumber(1))
  4697. {
  4698. Guild* to_guild = guild_list.GetGuild(atoul(sep->arg[1]));
  4699. if (to_guild)
  4700. to_guild->SendGuildRecruitingImages(client);
  4701. }
  4702. else if (strncmp(command, "recruiter_adventure_class", length) == 0)
  4703. {
  4704. if (sep->arg[1])
  4705. {
  4706. const char* option = sep->arg[1];
  4707. if (strncmp(option, "toggle", strlen(option)) == 0)
  4708. guild->ToggleGuildRecruiterAdventureClass(client);
  4709. }
  4710. else
  4711. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild recruiter_adventure_class command: '%s'", sep->argplus[0]);
  4712. }
  4713. else if (strncmp(command, "display_heraldry", length) == 0)
  4714. {
  4715. // JA: not sure this is right...
  4716. client->GetPlayer()->toggle_character_flag(CF_SHOW_GUILD_HERALDRY);
  4717. client->GetPlayer()->SetCharSheetChanged(true);
  4718. }
  4719. else
  4720. LogWrite(COMMAND__ERROR, 0, "Command", "Unhandled guild command: '%s'", sep->argplus[0]);
  4721. }
  4722. }
  4723. /*
  4724. Function: Command_GuildCreate()
  4725. Purpose : Display's in-game Guild Creation window
  4726. Dev : Scatman
  4727. */
  4728. void Commands::Command_CreateGuild(Client* client)
  4729. {
  4730. client->SendGuildCreateWindow();
  4731. }
  4732. /*
  4733. Function: Command_SetGuildOfficerNote()
  4734. Purpose :
  4735. Dev : Scatman
  4736. */
  4737. void Commands::Command_SetGuildOfficerNote(Client* client, Seperator* sep)
  4738. {
  4739. if (sep && sep->arg[0] && sep->arg[1])
  4740. {
  4741. Guild* guild = client->GetPlayer()->GetGuild();
  4742. if (guild)
  4743. guild->SetGuildOfficerNote(sep->arg[0], sep->argplus[1]);
  4744. }
  4745. }
  4746. /*
  4747. Function: Command_SetGuildMemberNote()
  4748. Purpose :
  4749. Dev : Scatman
  4750. */
  4751. void Commands::Command_SetGuildMemberNote(Client* client, Seperator* sep)
  4752. {
  4753. if (sep && sep->arg[0] && sep->arg[1])
  4754. {
  4755. Guild* guild = client->GetPlayer()->GetGuild();
  4756. if (guild)
  4757. guild->SetGuildMemberNote(sep->arg[0], sep->argplus[1]);
  4758. }
  4759. }
  4760. /*
  4761. Function: Command_GuildSay()
  4762. Purpose :
  4763. Dev : Scatman
  4764. */
  4765. void Commands::Command_GuildSay(Client* client, Seperator* sep)
  4766. {
  4767. Guild* guild = client->GetPlayer()->GetGuild();
  4768. if (guild)
  4769. {
  4770. if (sep && sep->arg[0])
  4771. guild->HandleGuildSay(client, sep->argplus[0]);
  4772. }
  4773. else
  4774. client->SimpleMessage(CHANNEL_COLOR_WHITE, "You are not a member of a guild");
  4775. }
  4776. /*
  4777. Function: Command_OfficerSay()
  4778. Purpose :
  4779. Dev : Scatman
  4780. */
  4781. void Commands::Command_OfficerSay(Client* client, Seperator* sep)
  4782. {
  4783. Guild* guild = client->GetPlayer()->GetGuild();
  4784. if (guild)
  4785. {
  4786. if (sep && sep->arg[0])
  4787. guild->HandleOfficerSay(client, sep->argplus[0]);
  4788. }
  4789. else
  4790. client->SimpleMessage(CHANNEL_COLOR_WHITE, "You are not a member of a guild");
  4791. }
  4792. /*
  4793. Function: Command_Guilds()
  4794. Purpose : Shows help for /guild command
  4795. Params :
  4796. Dev : Scatman
  4797. Example :
  4798. */
  4799. void Commands::Command_Guilds(Client* client)
  4800. {
  4801. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds [create|delete|add|remove|list]");
  4802. }
  4803. /*
  4804. Function: Command_GuildsAdd()
  4805. Purpose : Add's players to a guild
  4806. Params : guild_name|guild_id, player name
  4807. Dev : Scatman
  4808. Example : /guilds add 1 Admin = adds player Admin to guild_id 1
  4809. */
  4810. void Commands::Command_GuildsAdd(Client* client, Seperator* sep)
  4811. {
  4812. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  4813. {
  4814. Guild* guild = 0;
  4815. bool found = true;
  4816. if (sep->IsNumber(0))
  4817. {
  4818. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  4819. if (!guild)
  4820. {
  4821. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  4822. found = false;
  4823. }
  4824. }
  4825. else
  4826. {
  4827. guild = guild_list.GetGuild(sep->arg[0]);
  4828. if (!guild)
  4829. {
  4830. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  4831. found = false;
  4832. }
  4833. }
  4834. if (found)
  4835. {
  4836. Client* to_client = 0;
  4837. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  4838. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  4839. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  4840. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  4841. if (to_client)
  4842. guild->InvitePlayer(client, to_client->GetPlayer()->GetName());
  4843. else
  4844. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  4845. }
  4846. }
  4847. else
  4848. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds add [guild name|guild id] (player name).");
  4849. }
  4850. /*
  4851. Function: Command_GuildsCreate()
  4852. Purpose : Creates a guild
  4853. Params : guild_name, player_name (optional)
  4854. Dev : Scatman
  4855. Example : /guilds create [guild name] (player name)
  4856. */
  4857. void Commands::Command_GuildsCreate(Client* client, Seperator* sep)
  4858. {
  4859. if (sep && sep->arg[0])
  4860. {
  4861. const char* guild_name = sep->arg[0];
  4862. if (!guild_list.GetGuild(guild_name))
  4863. {
  4864. bool ret = false;
  4865. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  4866. {
  4867. Client* to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  4868. if (to_client)
  4869. {
  4870. world.CreateGuild(guild_name, to_client);
  4871. ret = true;
  4872. }
  4873. else
  4874. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player with name '%s'", sep->arg[1]);
  4875. }
  4876. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  4877. {
  4878. Client* to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  4879. if (to_client)
  4880. {
  4881. world.CreateGuild(guild_name, to_client);
  4882. ret = true;
  4883. }
  4884. }
  4885. else
  4886. {
  4887. world.CreateGuild(guild_name);
  4888. ret = true;
  4889. }
  4890. if (ret)
  4891. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully created.", guild_name);
  4892. else
  4893. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the guild.");
  4894. }
  4895. else
  4896. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' already exists.", guild_name);
  4897. }
  4898. else
  4899. 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.");
  4900. }
  4901. /*
  4902. Function: Command_GuildsDelete()
  4903. Purpose : Delete's a guild
  4904. Params : guild name
  4905. Dev : Scatman
  4906. Example : /guilds delete Test
  4907. */
  4908. void Commands::Command_GuildsDelete(Client* client, Seperator* sep)
  4909. {
  4910. if (sep && sep->arg[0])
  4911. {
  4912. Guild* guild = 0;
  4913. bool found = true;
  4914. if (sep->IsNumber(0))
  4915. {
  4916. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  4917. if (!guild)
  4918. {
  4919. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  4920. found = false;
  4921. }
  4922. }
  4923. else
  4924. {
  4925. guild = guild_list.GetGuild(sep->arg[0]);
  4926. if (!guild)
  4927. {
  4928. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  4929. found = false;
  4930. }
  4931. }
  4932. if (found)
  4933. {
  4934. guild->RemoveAllGuildMembers();
  4935. database.DeleteGuild(guild);
  4936. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' was successfully deleted.", guild->GetName());
  4937. guild_list.RemoveGuild(guild, true);
  4938. }
  4939. }
  4940. else
  4941. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds delete [guild name].");
  4942. }
  4943. /*
  4944. Function: Command_GuildsList()
  4945. Purpose : Lists current guilds on server
  4946. Params :
  4947. Dev : Scatman
  4948. Example : /guilds list
  4949. */
  4950. void Commands::Command_GuildsList(Client* client)
  4951. {
  4952. MutexMap<int32, Guild*>* guilds = guild_list.GetGuilds();
  4953. MutexMap<int32, Guild*>::iterator itr = guilds->begin();
  4954. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Guild List:");
  4955. if (guilds->size() == 0)
  4956. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "None.");
  4957. else {
  4958. while (itr.Next()) {
  4959. Guild* guild = itr.second;
  4960. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", guild->GetID(), guild->GetName());
  4961. }
  4962. }
  4963. }
  4964. /*
  4965. Function: Command_GuildsRemove()
  4966. Purpose : Removes a player from a guild
  4967. Params : guild name|guild id, player name
  4968. Dev : Scatman
  4969. Example : /guilds remove 1 Admin = removes Admin from guild 1
  4970. */
  4971. void Commands::Command_GuildsRemove(Client* client, Seperator* sep)
  4972. {
  4973. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  4974. {
  4975. Guild* guild = 0;
  4976. bool found = true;
  4977. if (sep->IsNumber(0))
  4978. {
  4979. guild = guild_list.GetGuild(atoul(sep->arg[0]));
  4980. if (!guild)
  4981. {
  4982. client->Message(CHANNEL_COLOR_YELLOW, "Guild with ID %u does not exist.", atoul(sep->arg[0]));
  4983. found = false;
  4984. }
  4985. }
  4986. else
  4987. {
  4988. guild = guild_list.GetGuild(sep->arg[0]);
  4989. if (!guild)
  4990. {
  4991. client->Message(CHANNEL_COLOR_YELLOW, "Guild '%s' does not exist.", sep->arg[0]);
  4992. found = false;
  4993. }
  4994. }
  4995. if (found)
  4996. {
  4997. Client* to_client = 0;
  4998. if (sep->arg[1] && strlen(sep->arg[1]) > 0)
  4999. to_client = zone_list.GetClientByCharName(string(sep->arg[1]));
  5000. else if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  5001. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  5002. if (to_client)
  5003. {
  5004. Player* to_player = to_client->GetPlayer();
  5005. if (to_player->GetGuild())
  5006. {
  5007. if (to_player->GetGuild() == guild)
  5008. {
  5009. guild->KickGuildMember(client, to_player->GetName());
  5010. }
  5011. else
  5012. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in the guild '%s'.", to_player->GetName(), guild->GetName());
  5013. }
  5014. else
  5015. client->Message(CHANNEL_COLOR_YELLOW, "%s is not in a guild.", to_player->GetName());
  5016. }
  5017. else
  5018. client->Message(CHANNEL_COLOR_YELLOW, "Could not find player '%s' to invite to the guild.", sep->arg[1]);
  5019. }
  5020. }
  5021. else
  5022. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /guilds remove [guild name|guild id] (player name).");
  5023. }
  5024. /*
  5025. Function: Command_InspectPlayer()
  5026. Purpose : Handle the Inspect functions
  5027. Params : Client to inspect
  5028. Dev : Scatman
  5029. Example : /inspect Scatman
  5030. */
  5031. void Commands::Command_InspectPlayer(Client* client, Seperator* sep)
  5032. {
  5033. if (sep && sep->arg[0])
  5034. {
  5035. Client* inspect_client = zone_list.GetClientByCharName(string(sep->arg[0]));
  5036. if (inspect_client)
  5037. client->InspectPlayer(inspect_client->GetPlayer());
  5038. }
  5039. else
  5040. {
  5041. Spawn* target = client->GetPlayer()->GetTarget();
  5042. if (target && target->IsPlayer())
  5043. client->InspectPlayer((Player*)target);
  5044. }
  5045. }
  5046. /*
  5047. Function: Command_Inventory()
  5048. Purpose : Handle changes in player inventory
  5049. Params : <TBD>
  5050. Dev : All
  5051. Example : /inventory delete item_id
  5052. */
  5053. void Commands::Command_Inventory(Client* client, Seperator* sep, EQ2_RemoteCommandString* command)
  5054. {
  5055. PrintSep(sep, "Command_Inventory"); // temp to figure out the params
  5056. Player* player = client->GetPlayer();
  5057. if(sep && sep->arg[0][0])
  5058. {
  5059. LogWrite(COMMAND__INFO, 0, "Command", "command: %s", command->command.data.c_str());
  5060. if(client->GetPlayer()->GetHP() == 0)
  5061. client->SimpleMessage(CHANNEL_COLOR_RED,"You cannot do that right now.");
  5062. else if(sep->arg[1][0] && strncasecmp("destroy", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  5063. {
  5064. int16 index = atoi(sep->arg[1]);
  5065. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  5066. if(item)
  5067. {
  5068. if(item->GetItemScript() && lua_interface)
  5069. lua_interface->RunItemScript(item->GetItemScript(), "destroyed", item, client->GetPlayer());
  5070. int32 bag_id = item->details.inv_slot_id;
  5071. database.DeleteItem(client->GetCharacterID(), item, 0);
  5072. client->GetPlayer()->item_list.DestroyItem(index);
  5073. EQ2Packet* outapp = client->GetPlayer()->SendInventoryUpdate(client->GetVersion());
  5074. client->QueuePacket(outapp);
  5075. outapp = client->GetPlayer()->SendBagUpdate(bag_id, client->GetVersion());
  5076. if (outapp)
  5077. client->QueuePacket(outapp);
  5078. }
  5079. }
  5080. 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))
  5081. {
  5082. int16 from_index = atoi(sep->arg[1]);
  5083. sint16 to_slot = atoi(sep->arg[2]);
  5084. sint32 bag_id = atol(sep->arg[3]);
  5085. int8 charges = atoi(sep->arg[4]);
  5086. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(from_index);
  5087. if(bag_id == -4 && !client->GetPlayer()->item_list.SharedBankAddAllowed(item))
  5088. {
  5089. client->SimpleMessage(CHANNEL_COLOR_RED, "That item (or an item inside) cannot be shared.");
  5090. return;
  5091. }
  5092. sint32 old_inventory_id = 0;
  5093. if(item)
  5094. old_inventory_id = item->details.inv_slot_id;
  5095. //autobank
  5096. if (bag_id == -3 && to_slot == -1)
  5097. {
  5098. if (player->HasFreeBankSlot())
  5099. to_slot = player->FindFreeBankSlot();
  5100. else
  5101. {
  5102. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free bank slots.");
  5103. return;
  5104. }
  5105. }
  5106. //auto inventory
  5107. if (bag_id == 0 && to_slot == -1)
  5108. {
  5109. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  5110. {
  5111. client->SimpleMessage(CHANNEL_COLOR_RED, "You do not have any free slots.");
  5112. return;
  5113. }
  5114. }
  5115. EQ2Packet* outapp = client->GetPlayer()->MoveInventoryItem(bag_id, from_index, (int8)to_slot, charges, client->GetVersion());
  5116. client->QueuePacket(outapp);
  5117. //removed from bag send update
  5118. if(old_inventory_id > 0 && item && item->details.inv_slot_id != old_inventory_id)
  5119. {
  5120. outapp = client->GetPlayer()->SendBagUpdate(old_inventory_id, client->GetVersion());
  5121. if(outapp)
  5122. client->QueuePacket(outapp);
  5123. }
  5124. if(item && item->details.inv_slot_id > 0 && item->details.inv_slot_id != old_inventory_id)
  5125. {
  5126. outapp = client->GetPlayer()->SendBagUpdate(item->details.inv_slot_id, client->GetVersion());
  5127. if(outapp)
  5128. client->QueuePacket(outapp);
  5129. }
  5130. }
  5131. else if(sep->arg[1][0] && strncasecmp("equip", sep->arg[0], 5) == 0 && sep->IsNumber(1))
  5132. {
  5133. if(client->GetPlayer()->EngagedInCombat())
  5134. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not equip items while in combat.");
  5135. else
  5136. {
  5137. int16 index = atoi(sep->arg[1]);
  5138. int8 slot_id = 255;
  5139. if(sep->arg[2][0] && sep->IsNumber(2))
  5140. slot_id = atoi(sep->arg[2]);
  5141. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), slot_id);
  5142. EQ2Packet* outapp = 0;
  5143. for(int32 i=0;i<packets.size();i++)
  5144. {
  5145. outapp = packets[i];
  5146. if(outapp)
  5147. client->QueuePacket(outapp);
  5148. }
  5149. client->GetPlayer()->ChangePrimaryWeapon();
  5150. client->GetPlayer()->ChangeSecondaryWeapon();
  5151. client->GetPlayer()->ChangeRangedWeapon();
  5152. EQ2Packet* characterSheetPackets = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion());
  5153. client->QueuePacket(characterSheetPackets);
  5154. }
  5155. }
  5156. else if (sep->arg[1][0] && strncasecmp("unpack", sep->arg[0], 6) == 0 && sep->IsNumber(1))
  5157. {
  5158. if (client->GetPlayer()->EngagedInCombat())
  5159. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unpack items while in combat.");
  5160. else {
  5161. int16 index = atoi(sep->arg[1]);
  5162. Item* item = client->GetPlayer()->item_list.GetItemFromIndex(index);
  5163. if (item) {
  5164. // client->GetPlayer()->item_list.DestroyItem(index);
  5165. if (item->item_sets.size() > 0) {
  5166. for (int32 i = 0; i < item->item_sets.size(); i++) {
  5167. ItemSet* set = item->item_sets[i];
  5168. if (set->item_stack_size == 0)
  5169. set->item_stack_size += 1;
  5170. client->AddItem(set->item_id, set->item_stack_size);
  5171. }
  5172. }
  5173. }
  5174. client->RemoveItem(item, 1);
  5175. }
  5176. }
  5177. else if(sep->arg[1][0] && strncasecmp("unequip", sep->arg[0], 7) == 0 && sep->IsNumber(1))
  5178. {
  5179. if(client->GetPlayer()->EngagedInCombat())
  5180. client->SimpleMessage(CHANNEL_COLOR_RED, "You may not unequip items while in combat.");
  5181. else
  5182. {
  5183. int16 index = atoi(sep->arg[1]);
  5184. sint32 bag_id = -999;
  5185. int8 to_slot = 255;
  5186. if(sep->arg[3][0])
  5187. {
  5188. if(sep->IsNumber(2))
  5189. bag_id = atol(sep->arg[2]);
  5190. if(sep->IsNumber(3))
  5191. to_slot = atoi(sep->arg[3]);
  5192. }
  5193. vector<EQ2Packet*> packets = client->GetPlayer()->UnequipItem(index, bag_id, to_slot, client->GetVersion());
  5194. EQ2Packet* outapp = 0;
  5195. for(int32 i=0;i<packets.size();i++)
  5196. {
  5197. outapp = packets[i];
  5198. if(outapp)
  5199. client->QueuePacket(outapp);
  5200. }
  5201. client->GetPlayer()->ChangePrimaryWeapon();
  5202. client->GetPlayer()->ChangeSecondaryWeapon();
  5203. client->GetPlayer()->ChangeRangedWeapon();
  5204. EQ2Packet* characterSheetPackets = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion());
  5205. client->QueuePacket(characterSheetPackets);
  5206. }
  5207. }
  5208. else if(sep->arg[2][0] && strncasecmp("swap_equip", sep->arg[0], 10) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  5209. {
  5210. LogWrite(MISC__TODO, 1, "TODO", " fix this, need to get how live does it\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  5211. int16 index1 = atoi(sep->arg[1]);
  5212. int16 index2 = atoi(sep->arg[2]);
  5213. EQ2Packet* outapp = client->GetPlayer()->SwapEquippedItems(index1, index2, client->GetVersion());
  5214. if(outapp)
  5215. client->QueuePacket(outapp);
  5216. else
  5217. {
  5218. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to swap items");
  5219. return;
  5220. }
  5221. }
  5222. else if (sep->arg[2][0] && strncasecmp("pop", sep->arg[0], 3) == 0 && sep->IsNumber(1) && sep->IsNumber(2))
  5223. {
  5224. sint16 to_slot = atoi(sep->arg[1]);
  5225. sint32 bag_id = atoi(sep->arg[2]);
  5226. Item* item = client->GetPlayer()->item_list.GetOverflowItem();
  5227. if (item) {
  5228. //auto inventory
  5229. if (bag_id == 0 && to_slot == -1)
  5230. {
  5231. if (!player->item_list.GetFirstFreeSlot(&bag_id, &to_slot))
  5232. {
  5233. client->SimpleMessage(CHANNEL_ERROR, "You do not have any free slots.");
  5234. return;
  5235. }
  5236. // Set the slot for the item
  5237. item->details.inv_slot_id = bag_id;
  5238. item->details.slot_id = to_slot;
  5239. // Flag the item so it gets saved in its new location
  5240. item->save_needed = true;
  5241. // Add the item to its new location
  5242. player->item_list.AddItem(item);
  5243. // Remove the item from the overflow list
  5244. player->item_list.RemoveOverflowItem(item);
  5245. // Send the inventory update packet
  5246. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5247. return;
  5248. }
  5249. else if (bag_id == -3 && to_slot == -1) {
  5250. // Auto Bank
  5251. if (!player->item_list.GetFirstFreeBankSlot(&bag_id, &to_slot)) {
  5252. client->SimpleMessage(CHANNEL_STATUS, "You do not have any free bank slots.");
  5253. return;
  5254. }
  5255. item->details.inv_slot_id = bag_id;
  5256. item->details.slot_id = to_slot;
  5257. item->save_needed = true;
  5258. player->item_list.AddItem(item);
  5259. player->item_list.RemoveOverflowItem(item);
  5260. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5261. }
  5262. else if (bag_id == -4) {
  5263. // Shared Bank
  5264. if (!player->item_list.SharedBankAddAllowed(item)) {
  5265. client->SimpleMessage(CHANNEL_STATUS, "That item (or an item inside) cannot be shared.");
  5266. return;
  5267. }
  5268. Item* tmp_item = player->item_list.GetItem(-4, to_slot);
  5269. if (tmp_item) {
  5270. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  5271. return;
  5272. }
  5273. else {
  5274. item->details.inv_slot_id = bag_id;
  5275. item->details.slot_id = to_slot;
  5276. item->save_needed = true;
  5277. player->item_list.AddItem(item);
  5278. player->item_list.RemoveOverflowItem(item);
  5279. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5280. return;
  5281. }
  5282. }
  5283. else {
  5284. // Try to get an item from the given bag id and slot id
  5285. Item* tmp_item = player->item_list.GetItem(bag_id, to_slot);
  5286. // Check to see if we got an item, if we do send an error,
  5287. // if we don't put the overflow item into this slot
  5288. if (tmp_item) {
  5289. client->SimpleMessage(CHANNEL_STATUS, "You can not place an overflow item into an occupied slot");
  5290. }
  5291. else {
  5292. item->details.inv_slot_id = bag_id;
  5293. item->details.slot_id = to_slot;
  5294. item->save_needed = true;
  5295. player->item_list.AddItem(item);
  5296. player->item_list.RemoveOverflowItem(item);
  5297. client->QueuePacket(player->item_list.serialize(player, client->GetVersion()));
  5298. return;
  5299. }
  5300. }
  5301. }
  5302. }
  5303. }
  5304. else
  5305. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /inventory {destroy|move|equip|unequip|swap_equip|pop} {item_id} [to_slot] [bag_id]");
  5306. }
  5307. /*
  5308. Function: Command_IRC()
  5309. Purpose : Handle the IRC functions
  5310. Params : IRC Commands
  5311. Dev : Scatman
  5312. Example : /irc say #Channel Hello World!
  5313. */
  5314. void Commands::Command_IRC(Client* client, Seperator* sep)
  5315. {
  5316. if (!rule_manager.GetGlobalRule(R_World, IRCEnabled)->GetBool()) {
  5317. client->SimpleMessage(CHANNEL_STATUS, "IRC is currently disabled on this server");
  5318. return;
  5319. }
  5320. if (sep && sep->arg[0][0]) {
  5321. if (strcasecmp(sep->arg[0], "say") == 0) {
  5322. if (sep->arg[1][0] && sep->arg[2][0]) {
  5323. if (sep->IsNumber(sep->arg[1]))
  5324. irc.Say(client, atoul(sep->arg[1]), sep->argplus[2]);
  5325. else
  5326. irc.Say(client, sep->arg[1], sep->argplus[2]);
  5327. }
  5328. else
  5329. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc say <channel name | channel index> <message>");
  5330. }
  5331. else if (strcasecmp(sep->arg[0], "join") == 0) {
  5332. if (sep->arg[1][0])
  5333. irc.JoinChannel(client, sep->arg[1]);
  5334. else
  5335. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc join <channel name>");
  5336. }
  5337. else if (strcasecmp(sep->arg[0], "leave") == 0) {
  5338. if (sep->arg[1][0])
  5339. irc.LeaveChannel(client, sep->arg[1]);
  5340. else
  5341. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc leave <channel name>");
  5342. }
  5343. else if (strcasecmp(sep->arg[0], "list") == 0)
  5344. irc.ListChannels(client);
  5345. else if (strcasecmp(sep->arg[0], "connect") == 0) {
  5346. if (sep->arg[1][0] && sep->arg[2][0] && sep->IsNumber(2))
  5347. irc.ConnectToServer(client, sep->arg[1], atoi(sep->arg[2]), sep->arg[3]);
  5348. else
  5349. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc connect <host> <port> (nick)");
  5350. }
  5351. else if (strcasecmp(sep->arg[0], "disconnect") == 0)
  5352. irc.DisconnectFromServer(client);
  5353. else
  5354. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown IRC command.");
  5355. }
  5356. else
  5357. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown IRC command.");
  5358. }
  5359. /*
  5360. Function: Command_Languages()
  5361. Purpose : Show's languages the player knows
  5362. Params :
  5363. Dev : Zcoretri
  5364. Example :
  5365. */
  5366. void Commands::Command_Languages(Client* client, Seperator* sep)
  5367. {
  5368. list<Language*>* languages = client->GetPlayer()->GetPlayerLanguages()->GetAllLanguages();
  5369. list<Language*>::iterator itr;
  5370. Language* language;
  5371. client->Message(CHANNEL_COLOR_WHITE, "You know the following languages:");
  5372. for(itr = languages->begin(); itr != languages->end(); itr++)
  5373. {
  5374. language = *itr;
  5375. client->Message(CHANNEL_COLOR_WHITE, "%s", language->GetName());
  5376. }
  5377. }
  5378. /*
  5379. Function: Command_SetLanguage()
  5380. Purpose : Handles language commands
  5381. Params : Language ID
  5382. Dev : Zcoretri
  5383. Example :
  5384. */
  5385. void Commands::Command_SetLanguage(Client* client, Seperator* sep)
  5386. {
  5387. Player* player = client->GetPlayer();
  5388. if (sep && sep->arg[0])
  5389. {
  5390. if(!sep->IsNumber(0))
  5391. {
  5392. //String passed in
  5393. const char* value = sep->arg[0];
  5394. if(strncasecmp(value, "Common", strlen(value)) == 0)
  5395. {
  5396. database.SaveCharacterCurrentLang(0, client->GetCharacterID(), client);
  5397. client->SendLanguagesUpdate(0);
  5398. client->Message(CHANNEL_COLOR_WHITE, "You are now speaking %s", value);
  5399. }
  5400. else
  5401. {
  5402. if(player->HasLanguage(value))
  5403. {
  5404. Language* language = player->GetPlayerLanguages()->GetLanguageByName(value);
  5405. database.SaveCharacterCurrentLang(language->GetID(), client->GetCharacterID(), client);
  5406. client->SendLanguagesUpdate(language->GetID());
  5407. client->Message(CHANNEL_COLOR_WHITE, "You are now speaking %s", language->GetName());
  5408. }
  5409. else
  5410. client->Message(CHANNEL_COLOR_WHITE, "You do not know how to speak %s", value);
  5411. }
  5412. }
  5413. else
  5414. {
  5415. //Number passed in
  5416. int32 id = atoul(sep->arg[0]);
  5417. if(player->HasLanguage(id))
  5418. {
  5419. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  5420. database.SaveCharacterCurrentLang(id, client->GetCharacterID(), client);
  5421. client->SendLanguagesUpdate(id);
  5422. client->Message(CHANNEL_COLOR_WHITE, "You are now speaking %s", language->GetName());
  5423. }
  5424. else
  5425. {
  5426. Language* language = master_languages_list.GetLanguage(id);
  5427. client->Message(CHANNEL_COLOR_WHITE, "You do not know how to speak %s", language->GetName());
  5428. }
  5429. }
  5430. }
  5431. else
  5432. {
  5433. //No value was passed in
  5434. int32 id = database.GetCharacterCurrentLang(client->GetCharacterID(), player);
  5435. if(id > 0)
  5436. {
  5437. Language* language = player->GetPlayerLanguages()->GetLanguage(id);
  5438. client->Message(CHANNEL_COLOR_WHITE, "You are currently speaking %s ", language->GetName());
  5439. }
  5440. else
  5441. client->Message(CHANNEL_COLOR_WHITE, "You are currently speaking Common");
  5442. }
  5443. }
  5444. /*
  5445. Function: Command_LastName()
  5446. Purpose : Sets player surname
  5447. Params : Name text
  5448. Dev : theFoof
  5449. Example :
  5450. */
  5451. void Commands::Command_LastName(Client* client, Seperator* sep)
  5452. {
  5453. if (!client)
  5454. return;
  5455. if (sep && sep->arg[0])
  5456. {
  5457. if (!client->GetPlayer()->get_character_flag(CF_ENABLE_CHANGE_LASTNAME)){
  5458. client->Message(CHANNEL_COLOR_YELLOW, "You must be atleast level %i to change your last name.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  5459. return;
  5460. }
  5461. client->RemovePendingLastName();
  5462. uchar* checkname = (uchar*)sep->arg[0];
  5463. bool valid_name = true;
  5464. for (int32 i = 0; i < strlen(sep->arg[0]); i++) {
  5465. if (!alpha_check(checkname[i])) {
  5466. valid_name = false;
  5467. break;
  5468. }
  5469. }
  5470. if (!valid_name) {
  5471. client->Message(CHANNEL_COLOR_YELLOW, "Your last name can only contain letters.", rule_manager.GetGlobalRule(R_Player, MinLastNameLevel)->GetInt8());
  5472. return;
  5473. }
  5474. string last_name = (string)sep->arg[0];
  5475. int8 max_length = rule_manager.GetGlobalRule(R_Player, MaxLastNameLength)->GetInt8();
  5476. int8 min_length = rule_manager.GetGlobalRule(R_Player, MinLastNameLength)->GetInt8();
  5477. if (last_name.length() <= max_length && last_name.length() >= min_length){
  5478. client->SetPendingLastName(last_name);
  5479. client->SendLastNameConfirmation();
  5480. }
  5481. else
  5482. client->Message(CHANNEL_COLOR_YELLOW, "Your last name must be between %i and %i characters long.", min_length, max_length);
  5483. }
  5484. }
  5485. /*
  5486. Function: Command_ConfirmLastName()
  5487. Purpose : Confirms setting of player surname
  5488. Params : Name text
  5489. Dev : theFoof
  5490. Example :
  5491. */
  5492. void Commands::Command_ConfirmLastName(Client* client, Seperator* sep)
  5493. {
  5494. if (!client)
  5495. return;
  5496. string* name = client->GetPendingLastName();
  5497. if (name){
  5498. Player* player = client->GetPlayer();
  5499. player->SetLastName(name->c_str(), false);
  5500. client->SendTitleUpdate();
  5501. player->SetCharSheetChanged(true);
  5502. client->RemovePendingLastName();
  5503. }
  5504. }
  5505. /*
  5506. Function: Command_Location()
  5507. Purpose : Display's Help for /location commands
  5508. Params :
  5509. Dev : Scatman
  5510. Example : /location = show's help for command
  5511. */
  5512. void Commands::Command_Location(Client* client)
  5513. {
  5514. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Valid /location commands are:");
  5515. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location create [name] (include y). Include y defaults to false");
  5516. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location add [location id]");
  5517. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location remove [location point id]");
  5518. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location delete [location id]");
  5519. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/location list [locations|points] [location id if points used]");
  5520. }
  5521. /*
  5522. Function: Command_LocationAdd()
  5523. Purpose : Add's a location to an existing location config
  5524. Params : location_id
  5525. Dev : Scatman
  5526. Example : /location add {location_id}
  5527. */
  5528. void Commands::Command_LocationAdd(Client* client, Seperator* sep)
  5529. {
  5530. if (sep && sep->arg[0] && sep->IsNumber(0))
  5531. {
  5532. int32 location_id = atoul(sep->arg[0]);
  5533. float x = client->GetPlayer()->GetX();
  5534. float y = client->GetPlayer()->GetY();
  5535. float z = client->GetPlayer()->GetZ();
  5536. if (database.AddLocationPoint(location_id, x, y, z))
  5537. client->Message(CHANNEL_COLOR_YELLOW, "Point (%f, %f, %f) was successfully added to location %u", x, y, z, location_id);
  5538. else
  5539. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist. Use /location create to create one", location_id);
  5540. }
  5541. else
  5542. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location add [location id]");
  5543. }
  5544. /*
  5545. Function: Command_LocationCreate()
  5546. Purpose : Creates a new location config
  5547. Params : location name, 0/1 for include_y (optional)
  5548. Dev : Scatman
  5549. Example : /location create Test 1 = creates a new location named Test with include_y True
  5550. */
  5551. void Commands::Command_LocationCreate(Client* client, Seperator* sep)
  5552. {
  5553. if (sep && sep->arg[0] && strlen(sep->arg[0]) > 0)
  5554. {
  5555. const char* name = sep->arg[0];
  5556. bool include_y = false;
  5557. if (sep->arg[1] && sep->IsNumber(1) && atoi(sep->arg[1]) > 0)
  5558. include_y = true;
  5559. int32 location_id = database.CreateLocation(client->GetPlayer()->GetZone()->GetZoneID(), client->GetPlayer()->appearance.pos.grid_id, name, include_y);
  5560. if (location_id > 0)
  5561. client->Message(CHANNEL_COLOR_YELLOW, "Location '%s' was successfully created with location id %u", name, location_id);
  5562. else
  5563. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an error creating the requested location");
  5564. }
  5565. else
  5566. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location create [name] (include_y). Include y defaults to false");
  5567. }
  5568. /*
  5569. Function: Command_LocationDelete()
  5570. Purpose : Delete's a location config and all it's location points
  5571. Params : location_id
  5572. Dev : Scatman
  5573. Example : /location delete {location_id}
  5574. */
  5575. void Commands::Command_LocationDelete(Client* client, Seperator* sep)
  5576. {
  5577. if (sep && sep->arg[0] && sep->IsNumber(0))
  5578. {
  5579. int32 location_id = atoul(sep->arg[0]);
  5580. if (database.DeleteLocation(location_id))
  5581. client->Message(CHANNEL_COLOR_YELLOW, "Location id %u and all its points were successfully deleted", location_id);
  5582. else
  5583. client->Message(CHANNEL_COLOR_YELLOW, "A location with ID %u does not exist", location_id);
  5584. }
  5585. else
  5586. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location delete [location id]");
  5587. }
  5588. /*
  5589. Function: Command_LocationList()
  5590. Purpose : Display's a list of location points
  5591. Params : location_id
  5592. Dev : Scatman
  5593. Example : /location list {location_id}
  5594. */
  5595. void Commands::Command_LocationList(Client* client, Seperator* sep)
  5596. {
  5597. if (sep && sep->arg[0])
  5598. {
  5599. const char* option = sep->arg[0];
  5600. if (strncmp(option, "locations", strlen(option)) == 0)
  5601. database.ListLocations(client);
  5602. else if (strncmp(option, "points", strlen(option)) == 0 && sep->arg[1] && sep->IsNumber(1))
  5603. {
  5604. int32 location_id = atoul(sep->arg[1]);
  5605. database.ListLocationPoints(client, location_id);
  5606. }
  5607. else
  5608. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  5609. }
  5610. else
  5611. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Useage: /location list [locations|points] [location ID if points used]");
  5612. }
  5613. /*
  5614. Function: Command_LocationRemove()
  5615. Purpose : Removes a single location point from a location config
  5616. Params : location_point_id (gotten from /location list {id})
  5617. Dev : Scatman
  5618. Example : /location remove 1 = will remove location_point_id 1
  5619. */
  5620. void Commands::Command_LocationRemove(Client* client, Seperator* sep)
  5621. {
  5622. if (sep && sep->arg[0] && sep->IsNumber(0))
  5623. {
  5624. int32 location_point_id = atoul(sep->arg[0]);
  5625. if (database.DeleteLocationPoint(location_point_id))
  5626. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Location point was successfully deleted");
  5627. else
  5628. client->Message(CHANNEL_COLOR_YELLOW, "Location point with ID %u does not exist", location_point_id);
  5629. }
  5630. else
  5631. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /location remove [location point id]");
  5632. }
  5633. /*
  5634. Function: Command_Merchant()
  5635. Purpose : Handles Merchant commands
  5636. Params : list
  5637. Dev : Scatman
  5638. Example : /merchant list
  5639. */
  5640. void Commands::Command_Merchant(Client* client, Seperator* sep, int handler)
  5641. {
  5642. if( handler == COMMAND_MERCHANT )
  5643. {
  5644. // /merchant command by itself shows help (to be extended)
  5645. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  5646. return;
  5647. }
  5648. else if( handler == COMMAND_MERCHANT_LIST )
  5649. {
  5650. // /merchant list command expects "description" param
  5651. if (sep && sep->arg[0])
  5652. {
  5653. const char* merchant_description = sep->argplus[0];
  5654. client->Message(CHANNEL_COLOR_YELLOW, "Listing merchants like '%s':", merchant_description);
  5655. map<int32, MerchantInfo*>* merchant_info = world.GetMerchantInfo();
  5656. map<int32, MerchantInfo*>::iterator itr;
  5657. for (itr = merchant_info->begin(); itr != merchant_info->end(); itr++)
  5658. {
  5659. string description = database.GetMerchantDescription(itr->first);
  5660. if (ToLower(description).find(ToLower(string(merchant_description))) < 0xFFFFFFFF)
  5661. client->Message(CHANNEL_COLOR_YELLOW, "Merchant ID: %u, Description: %s", itr->first, description.c_str());
  5662. }
  5663. }
  5664. else // no description
  5665. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /merchant list [merchant description]");
  5666. }
  5667. }
  5668. /*
  5669. Function: Command_Modify()
  5670. Purpose : to replace our other "set" commands
  5671. Params : System = the system to modify, Action = the action to perform, Target = what to change (target, or index)
  5672. Dev : John Adams
  5673. Example : /modify spell set name "Aegolism III"
  5674. */
  5675. void Commands::Command_Modify(Client* client)
  5676. {
  5677. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /modify [system] [action] [field] [value] {target|id}");
  5678. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Systems: character, faction, guild, item, skill, spawn, spell, zone");
  5679. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Actions: set, create, delete, add, remove");
  5680. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Value : field name in the table being modified");
  5681. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target : modify current target, or specified {system} ID");
  5682. }
  5683. /*
  5684. Function: Command_ModifySpawn()
  5685. Purpose : replace "spawn set" commands
  5686. Params : Action : the action to perform (or special handler)
  5687. : Field : the DB field to change
  5688. : Value : what to set the value to
  5689. : Target : what object to change (my target, or spawn_id)
  5690. Dev : John Adams
  5691. Example : /modify spawn set name "Lady Vox"
  5692. :
  5693. Note : Special Handlers, like "zoneto" for Signs
  5694. : /modify spawn zoneto
  5695. : Will set a sign's zone x/y/z to my current coords
  5696. */
  5697. void Commands::Command_ModifySpawn(Client* client, Seperator* sep)
  5698. {
  5699. PrintSep(sep, "COMMAND_MODIFY");
  5700. // need at least 2 args for a valid command
  5701. if( sep && sep->arg[1] )
  5702. {
  5703. // JA: just a quick implementation because I need it :)
  5704. if (strcmp(sep->arg[0], "zoneto") == 0)
  5705. {
  5706. if( sep->IsNumber(1) )
  5707. {
  5708. int32 spawn_id = atoul(sep->arg[1]);
  5709. float x_coord = client->GetPlayer()->GetX();
  5710. float y_coord = client->GetPlayer()->GetY();
  5711. float z_coord = client->GetPlayer()->GetZ();
  5712. float h_coord = client->GetPlayer()->GetHeading();
  5713. database.SaveSignZoneToCoords(spawn_id, x_coord, y_coord, z_coord, h_coord);
  5714. }
  5715. else
  5716. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify spawn zoneto spawn_id - sets spawn_id to your coords");
  5717. }
  5718. }
  5719. else
  5720. Command_Modify(client);
  5721. }
  5722. /*
  5723. Function: Command_ModifyCharacter()
  5724. Purpose : to replace our other "set" commands
  5725. Params : Action : Add, Remove
  5726. : Field : copper, silver, gold, plat
  5727. : Value : min 1, max unlimited
  5728. : Target : Self, Player
  5729. Dev : Cynnar
  5730. Example : /modify character add gold 50
  5731. : /modify character remove silver 25
  5732. */
  5733. void Commands::Command_ModifyCharacter(Client* client, Seperator* sep)
  5734. {
  5735. PrintSep(sep, "COMMAND_MODIFY");
  5736. int64 value = 0;
  5737. Player* player = client->GetPlayer();
  5738. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  5739. player = (Player*)player->GetTarget();
  5740. // need at least 2 args for a valid command
  5741. if( sep && sep->arg[1] )
  5742. {
  5743. if (strcmp(sep->arg[0], "add") == 0)
  5744. {
  5745. if (strcmp(sep->arg[1], "copper") == 0)
  5746. {
  5747. value = atoi64(sep->arg[2]);
  5748. player->AddCoins(value);
  5749. if (client->GetPlayer() == player)
  5750. {
  5751. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu copper coin%s", value, (value > 1 ? "s" : ""));
  5752. }
  5753. else {
  5754. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu copper coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  5755. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu copper coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  5756. }
  5757. }
  5758. else if (strcmp(sep->arg[1], "silver") == 0)
  5759. {
  5760. value = atoi64(sep->arg[2]) * 100;
  5761. player->AddCoins(value);
  5762. if (client->GetPlayer() == player)
  5763. {
  5764. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu silver coin%s", value / 100, (value > 1 ? "s" : ""));
  5765. }
  5766. else {
  5767. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu silver coin%s", player->GetName(), value / 100, (value > 1 ? "s" : ""));
  5768. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu silver coin%s", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  5769. }
  5770. }
  5771. else if (strcmp(sep->arg[1], "gold") == 0)
  5772. {
  5773. value = atoi64(sep->arg[2]) * 10000;
  5774. player->AddCoins(value);
  5775. if (client->GetPlayer() == player)
  5776. {
  5777. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu gold coin%s", value / 10000, (value > 1 ? "s" : ""));
  5778. }
  5779. else {
  5780. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu gold coin%s", player->GetName(), value / 10000, (value > 1 ? "s" : ""));
  5781. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu gold coin%s", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  5782. }
  5783. }
  5784. else if (strcmp(sep->arg[1], "plat") == 0)
  5785. {
  5786. value = atoi64(sep->arg[2]) * 1000000;
  5787. player->AddCoins(value);
  5788. if (client->GetPlayer() == player)
  5789. {
  5790. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu platinum coin%s", value / 1000000, (value > 1 ? "s" : ""));
  5791. }
  5792. else {
  5793. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu platinum coin%s", player->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  5794. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu platinum coin%s", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  5795. }
  5796. }
  5797. else
  5798. {
  5799. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  5800. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  5801. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  5802. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character add copper 20");
  5803. }
  5804. }
  5805. else if (strcmp(sep->arg[0], "remove") == 0)
  5806. {
  5807. if (strcmp(sep->arg[1], "copper") == 0)
  5808. {
  5809. value = atoi64(sep->arg[2]);
  5810. player->RemoveCoins(value);
  5811. if (client->GetPlayer() == player)
  5812. {
  5813. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from yourself", value, (value > 1 ? "s" : ""));
  5814. }
  5815. else {
  5816. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu copper coin%s from %s", value, (value > 1 ? "s" : ""), player->GetName());
  5817. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu copper coin%s from you", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  5818. }
  5819. }
  5820. else if (strcmp(sep->arg[1], "silver") == 0)
  5821. {
  5822. value = atoi64(sep->arg[2]) * 100;
  5823. player->RemoveCoins(value);
  5824. if (client->GetPlayer() == player)
  5825. {
  5826. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from yourself", value / 100, (value > 1 ? "s" : ""));
  5827. }
  5828. else {
  5829. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu silver coin%s from %s", value / 100, (value > 1 ? "s" : ""), player->GetName());
  5830. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu silver coin%s from you", client->GetPlayer()->GetName(), value / 100, (value > 1 ? "s" : ""));
  5831. }
  5832. }
  5833. else if (strcmp(sep->arg[1], "gold") == 0)
  5834. {
  5835. value = atoi64(sep->arg[2]) * 10000;
  5836. player->RemoveCoins(value);
  5837. if (client->GetPlayer() == player)
  5838. {
  5839. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from yourself", value / 10000, (value > 1 ? "s" : ""));
  5840. }
  5841. else {
  5842. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu gold coin%s from %s", value / 10000, (value > 1 ? "s" : ""), player->GetName());
  5843. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu gold coin%s from you", client->GetPlayer()->GetName(), value / 10000, (value > 1 ? "s" : ""));
  5844. }
  5845. }
  5846. else if (strcmp(sep->arg[1], "plat") == 0)
  5847. {
  5848. value = atoi64(sep->arg[2]) * 1000000;
  5849. player->RemoveCoins(value);
  5850. if (client->GetPlayer() == player)
  5851. {
  5852. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from yourself", value / 1000000, (value > 1 ? "s" : ""));
  5853. }
  5854. else {
  5855. client->Message(CHANNEL_COLOR_YELLOW, "You take %llu platinum coin%s from %s", value / 1000000, (value > 1 ? "s" : ""), player->GetName());
  5856. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s takes %llu platinum coin%s from you", client->GetPlayer()->GetName(), value / 1000000, (value > 1 ? "s" : ""));
  5857. }
  5858. }
  5859. else
  5860. {
  5861. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  5862. }
  5863. }
  5864. else if (strcmp(sep->arg[0], "set") == 0) {
  5865. if (strcmp(sep->arg[1], "tslevel") == 0) {
  5866. int8 level = atoi(sep->arg[2]);
  5867. if (level > 0 && level < 256) {
  5868. if (player) {
  5869. if (client->GetPlayer() == player)
  5870. client->ChangeTSLevel(player->GetTSLevel(), level);
  5871. else
  5872. player->GetZone()->GetClientBySpawn(player)->ChangeTSLevel(player->GetTSLevel(), level);
  5873. }
  5874. }
  5875. else
  5876. client->SimpleMessage(CHANNEL_ERROR, "Level must be between 1 - 255");
  5877. }
  5878. else if (strcmp(sep->arg[1], "tsclass") == 0) {
  5879. int8 tsclass = atoi(sep->arg[2]);
  5880. player->SetTradeskillClass(tsclass);
  5881. player->GetInfoStruct()->tradeskill_class1 = classes.GetTSBaseClass(player->GetTradeskillClass());
  5882. player->GetInfoStruct()->tradeskill_class2 = classes.GetSecondaryTSBaseClass(player->GetTradeskillClass());
  5883. player->GetInfoStruct()->tradeskill_class3 = player->GetTradeskillClass();
  5884. player->SetCharSheetChanged(true);
  5885. }
  5886. }
  5887. }
  5888. else
  5889. {
  5890. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify character [action] [field] [value]");
  5891. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: add, remove");
  5892. client->SimpleMessage(CHANNEL_COLOR_RED, "Value : copper, silver, gold, plat");
  5893. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify character remove gold 15");
  5894. }
  5895. }
  5896. void Commands::Command_ModifyFaction(Client* client, Seperator* sep)
  5897. {
  5898. PrintSep(sep, "COMMAND_MODIFY");
  5899. // need at least 2 args for a valid command
  5900. if( sep && sep->arg[1] )
  5901. {
  5902. }
  5903. else
  5904. Command_Modify(client);
  5905. }
  5906. void Commands::Command_ModifyGuild(Client* client, Seperator* sep)
  5907. {
  5908. PrintSep(sep, "COMMAND_MODIFY");
  5909. // need at least 2 args for a valid command
  5910. if( sep && sep->arg[1] )
  5911. {
  5912. }
  5913. else
  5914. Command_Modify(client);
  5915. }
  5916. void Commands::Command_ModifyItem(Client* client, Seperator* sep)
  5917. {
  5918. PrintSep(sep, "COMMAND_MODIFY");
  5919. // need at least 2 args for a valid command
  5920. if( sep && sep->arg[1] )
  5921. {
  5922. }
  5923. else
  5924. Command_Modify(client);
  5925. }
  5926. /*
  5927. Function: Command_ModifyQuest()
  5928. Purpose : to list players quest and completed quests
  5929. Params : Action : list, completed
  5930. : Target : Self, Player
  5931. Dev : Cynnar
  5932. Example : /modify quest list
  5933. : /modify quest completed
  5934. */
  5935. void Commands::Command_ModifyQuest(Client* client, Seperator* sep)
  5936. {
  5937. PrintSep(sep, "COMMAND_MODIFY");
  5938. int64 value = 0;
  5939. Player* player = client->GetPlayer();
  5940. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  5941. player = (Player*)player->GetTarget();
  5942. // need at least 2 args for a valid command
  5943. if (sep && sep->arg[1])
  5944. {
  5945. if (strcmp(sep->arg[0], "list") == 0)
  5946. {
  5947. map<int32, Quest*>* quests = player->GetPlayerQuests();
  5948. map<int32, Quest*>::iterator itr;
  5949. client->Message(CHANNEL_COLOR_YELLOW, "%s's Quest List:.", client->GetPlayer()->GetName());
  5950. if (quests->size() == 0)
  5951. client->Message(CHANNEL_COLOR_YELLOW, "%s has no quests.", client->GetPlayer()->GetName());
  5952. else
  5953. {
  5954. for (itr = quests->begin(); itr != quests->end(); itr++)
  5955. {
  5956. Quest* quest = itr->second;
  5957. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  5958. }
  5959. }
  5960. }
  5961. else if (strcmp(sep->arg[0], "completed") == 0)
  5962. {
  5963. map<int32, Quest*>* quests = player->GetCompletedPlayerQuests();
  5964. map<int32, Quest*>::iterator itr;
  5965. client->Message(CHANNEL_COLOR_YELLOW, "%s's Completed Quest List:.", client->GetPlayer()->GetName());
  5966. if (quests->size() == 0)
  5967. client->Message(CHANNEL_COLOR_YELLOW, "%s has no completed quests.", client->GetPlayer()->GetName());
  5968. else
  5969. {
  5970. for (itr = quests->begin(); itr != quests->end(); itr++)
  5971. {
  5972. Quest* quest = itr->second;
  5973. client->Message(CHANNEL_COLOR_YELLOW, "%u) %s", itr->first, quest->GetName());
  5974. }
  5975. }
  5976. }
  5977. // Add in a progress step, and a LogWrite() for tracking GM Commands.
  5978. // LogWrite(LUA__DEBUG, 0, "LUA", "Quest: %s, function: %s", quest->GetName(), function);
  5979. else if (strcmp(sep->arg[0], "remove") == 0)
  5980. {
  5981. int32 quest_id = 0;
  5982. if (sep && sep->arg[1] && sep->IsNumber(1))
  5983. quest_id = atoul(sep->arg[1]);
  5984. if (quest_id > 0)
  5985. {
  5986. if (lua_interface && client->GetPlayer()->player_quests.count(quest_id) > 0)
  5987. {
  5988. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  5989. if (quest)
  5990. if (client->GetPlayer() == player)
  5991. {
  5992. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been removed from your journal", quest->GetName());
  5993. }
  5994. else
  5995. {
  5996. client->Message(CHANNEL_COLOR_YELLOW, "You have removed the quest %s from %s's journal", quest->GetName(), player->GetName());
  5997. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s has removed the quest %s from your journal", client->GetPlayer()->GetName(), quest->GetName());
  5998. }
  5999. LogWrite(COMMAND__INFO, 0, "GM Command", "%s removed the quest %s from %s", client->GetPlayer()->GetName(), quest->GetName(), player->GetName());
  6000. lua_interface->CallQuestFunction(quest, "Deleted", client->GetPlayer());
  6001. }
  6002. client->RemovePlayerQuest(quest_id);
  6003. client->GetCurrentZone()->SendQuestUpdates(client);
  6004. }
  6005. }
  6006. else if (strcmp(sep->arg[0], "advance") == 0)
  6007. {
  6008. int32 quest_id = 0;
  6009. int32 step = 0;
  6010. if (sep && sep->arg[1] && sep->IsNumber(1))
  6011. {
  6012. quest_id = atoul(sep->arg[1]);
  6013. Quest* quest = client->GetPlayer()->player_quests[quest_id];
  6014. if (sep && sep->arg[2] && sep->IsNumber(1))
  6015. {
  6016. step = atoul(sep->arg[2]);
  6017. if (quest_id > 0 && step > 0)
  6018. {
  6019. if (player && player->IsPlayer() && quest_id > 0 && step > 0 && (player->player_quests.count(quest_id) > 0))
  6020. {
  6021. if (client)
  6022. {
  6023. client->AddPendingQuestUpdate(quest_id, step);
  6024. client->Message(CHANNEL_COLOR_YELLOW, "The quest %s has been advanced one step.", quest->GetName());
  6025. LogWrite(COMMAND__INFO, 0, "GM Command", "%s advanced the quest %s one step", client->GetPlayer()->GetName(), quest->GetName());
  6026. }
  6027. }
  6028. }
  6029. else
  6030. {
  6031. client->Message(CHANNEL_COLOR_RED, "Quest ID and Step Number must be greater than 0!");
  6032. }
  6033. }
  6034. else
  6035. {
  6036. client->Message(CHANNEL_COLOR_RED, "Step Number must be a number!");
  6037. }
  6038. }
  6039. else
  6040. {
  6041. client->Message(CHANNEL_COLOR_RED, "Quest ID must be a number!");
  6042. }
  6043. }
  6044. else
  6045. {
  6046. Command_Modify(client);
  6047. }
  6048. }
  6049. else
  6050. {
  6051. client->SimpleMessage(CHANNEL_COLOR_RED, "Usage: /modify quest [action] [quest id] [step number]");
  6052. client->SimpleMessage(CHANNEL_COLOR_RED, "Actions: list, completed, remove, advance");
  6053. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest list");
  6054. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest remove 156");
  6055. client->SimpleMessage(CHANNEL_COLOR_RED, "Example: /modify quest advance 50 1");
  6056. }
  6057. }
  6058. void Commands::Command_ModifySkill(Client* client, Seperator* sep)
  6059. {
  6060. PrintSep(sep, "COMMAND_MODIFY");
  6061. // need at least 2 args for a valid command
  6062. if( sep && sep->arg[1] )
  6063. {
  6064. if (strcmp(sep->arg[0], "add") == 0) {
  6065. const char* skill_name = sep->argplus[1];
  6066. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6067. if (skill) {
  6068. Player* player = 0;
  6069. Client* to_client = 0;
  6070. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  6071. player = (Player*)client->GetPlayer()->GetTarget();
  6072. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  6073. }
  6074. else {
  6075. player = client->GetPlayer();
  6076. to_client = client;
  6077. }
  6078. if (player)
  6079. {
  6080. if (!player->GetSkills()->HasSkill(skill->skill_id))
  6081. {
  6082. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  6083. if (to_client == client) {
  6084. client->Message(CHANNEL_STATUS, "Added skill '%s'.", skill_name);
  6085. }
  6086. else {
  6087. client->Message(CHANNEL_STATUS, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  6088. to_client->Message(CHANNEL_STATUS, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  6089. }
  6090. }
  6091. else
  6092. client->Message(CHANNEL_STATUS, "%s already has the skill '%s'.", to_client == client ? "You" : player->GetName(), skill_name);
  6093. }
  6094. }
  6095. else
  6096. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  6097. }
  6098. else if (strcmp(sep->arg[0], "remove") == 0) {
  6099. const char* skill_name = sep->argplus[1];
  6100. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6101. if (skill) {
  6102. Player* player = 0;
  6103. Client* to_client = 0;
  6104. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  6105. player = (Player*)client->GetPlayer()->GetTarget();
  6106. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  6107. }
  6108. else {
  6109. player = client->GetPlayer();
  6110. to_client = client;
  6111. }
  6112. if (player)
  6113. {
  6114. if (player->GetSkills()->HasSkill(skill->skill_id))
  6115. {
  6116. player->RemoveSkillFromDB(skill, true);
  6117. if (client == to_client) {
  6118. client->Message(CHANNEL_STATUS, "Removed skill '%s'.", skill_name);
  6119. }
  6120. else {
  6121. client->Message(CHANNEL_STATUS, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  6122. to_client->Message(CHANNEL_STATUS, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  6123. }
  6124. }
  6125. else {
  6126. if (client == to_client)
  6127. client->Message(CHANNEL_STATUS, "You do not have the skill '%s'.", skill_name);
  6128. else
  6129. client->Message(CHANNEL_STATUS, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  6130. }
  6131. }
  6132. }
  6133. else
  6134. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  6135. }
  6136. else if (strcmp(sep->arg[0], "set") == 0) {
  6137. if (!sep->IsNumber(2)) {
  6138. client->Message(CHANNEL_STATUS, "The last parameter must be a number.");
  6139. return;
  6140. }
  6141. const char* skill_name = sep->arg[1];
  6142. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6143. if (skill) {
  6144. int16 val = atoi(sep->arg[2]);
  6145. Player* player = 0;
  6146. Client* to_client = 0;
  6147. if (client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer()) {
  6148. player = (Player*)client->GetPlayer()->GetTarget();
  6149. to_client = client->GetCurrentZone()->GetClientBySpawn(player);
  6150. }
  6151. else {
  6152. player = client->GetPlayer();
  6153. to_client = client;
  6154. }
  6155. if (player)
  6156. {
  6157. if (player->GetSkills()->HasSkill(skill->skill_id)) {
  6158. player->GetSkills()->SetSkill(skill->skill_id, val);
  6159. if (client != to_client)
  6160. client->Message(CHANNEL_STATUS, "You set %s's '%s' skill to %i.", player->GetName(), skill_name, val);
  6161. to_client->Message(CHANNEL_STATUS, "Your '%s' skill has been set to %i.", skill_name, val);
  6162. }
  6163. else {
  6164. client->Message(CHANNEL_STATUS, "Target does not have the skill '%s'.", skill_name);
  6165. }
  6166. }
  6167. }
  6168. else {
  6169. client->Message(CHANNEL_STATUS, "The skill '%s' does not exist.", skill_name);
  6170. }
  6171. }
  6172. else {
  6173. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  6174. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  6175. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  6176. }
  6177. }
  6178. else {
  6179. client->SimpleMessage(CHANNEL_STATUS, "Usage: /modify skill [action] [skill]");
  6180. client->SimpleMessage(CHANNEL_STATUS, "Actions: add, remove, set");
  6181. client->SimpleMessage(CHANNEL_STATUS, "Example: /modify skill add parry");
  6182. }
  6183. }
  6184. void Commands::Command_ModifySpell(Client* client, Seperator* sep)
  6185. {
  6186. PrintSep(sep, "COMMAND_MODIFY");
  6187. // need at least 2 args for a valid command
  6188. if( sep && sep->arg[1] )
  6189. {
  6190. }
  6191. else
  6192. Command_Modify(client);
  6193. }
  6194. void Commands::Command_ModifyZone(Client* client, Seperator* sep)
  6195. {
  6196. PrintSep(sep, "COMMAND_MODIFY");
  6197. // need at least 2 args for a valid command
  6198. if( sep && sep->arg[1] )
  6199. {
  6200. }
  6201. else
  6202. Command_Modify(client);
  6203. }
  6204. /*
  6205. Function: Command_MOTD()
  6206. Purpose : Displays server MOTD
  6207. Params :
  6208. Dev : LethalEncounter
  6209. Example : /motd
  6210. */
  6211. void Commands::Command_MOTD(Client* client)
  6212. {
  6213. if (client)
  6214. ClientPacketFunctions::SendMOTD(client);
  6215. }
  6216. /*
  6217. Function: Command_Pet()
  6218. Purpose : Handle Pet {Command} commands
  6219. Params : attack, backoff, preserve_master, preserve_self, follow, stay, getlost
  6220. Dev :
  6221. Example : /pet preserve_master
  6222. */
  6223. void Commands::Command_Pet(Client* client, Seperator* sep)
  6224. {
  6225. PrintSep(sep, "COMMAND_PET");
  6226. //LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Pet Commands");
  6227. //client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6228. if (!sep || !sep->arg[0])
  6229. return; // should have sep->arg[0] filled
  6230. if (strcmp(sep->arg[0], "hide") == 0) {
  6231. // doing /pet hide will toggle the hide status on all the pets that can be hidden
  6232. Entity* pet = client->GetPlayer()->GetDeityPet();
  6233. if (pet) {
  6234. if (pet->IsPrivateSpawn())
  6235. client->GetPlayer()->HideDeityPet(false);
  6236. else
  6237. client->GetPlayer()->HideDeityPet(true);
  6238. }
  6239. pet = client->GetPlayer()->GetCosmeticPet();
  6240. if (pet) {
  6241. if (pet->IsPrivateSpawn())
  6242. client->GetPlayer()->HideCosmeticPet(false);
  6243. else
  6244. client->GetPlayer()->HideCosmeticPet(true);
  6245. }
  6246. return;
  6247. }
  6248. // below is for all combat pets
  6249. if (!client->GetPlayer()->HasPet()) {
  6250. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a pet.");
  6251. return;
  6252. }
  6253. if (strcmp(sep->arg[0], "stay") == 0) {
  6254. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to stay.");
  6255. client->GetPlayer()->GetInfoStruct()->pet_movement = 1;
  6256. client->GetPlayer()->SetCharSheetChanged(true);
  6257. if (client->GetPlayer()->GetPet())
  6258. client->GetPlayer()->GetPet()->following = false;
  6259. if (client->GetPlayer()->GetCharmedPet())
  6260. client->GetPlayer()->GetCharmedPet()->following = false;
  6261. }
  6262. else if (strcmp(sep->arg[0], "follow") == 0) {
  6263. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to follow.");
  6264. client->GetPlayer()->GetInfoStruct()->pet_movement = 2;
  6265. client->GetPlayer()->SetCharSheetChanged(true);
  6266. }
  6267. else if (strcmp(sep->arg[0], "preserve_master") == 0) {
  6268. if (client->GetPlayer()->GetInfoStruct()->pet_behavior & 1) {
  6269. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect you.");
  6270. client->GetPlayer()->GetInfoStruct()->pet_behavior -= 1;
  6271. }
  6272. else {
  6273. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect you.");
  6274. client->GetPlayer()->GetInfoStruct()->pet_behavior += 1;
  6275. }
  6276. client->GetPlayer()->SetCharSheetChanged(true);
  6277. }
  6278. else if (strcmp(sep->arg[0], "preserve_self") == 0) {
  6279. if (client->GetPlayer()->GetInfoStruct()->pet_behavior & 2) {
  6280. client->Message(CHANNEL_COLOR_YELLOW, "Your pet will no longer protect itself.");
  6281. client->GetPlayer()->GetInfoStruct()->pet_behavior -= 2;
  6282. }
  6283. else {
  6284. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to protect itself.");
  6285. client->GetPlayer()->GetInfoStruct()->pet_behavior += 2;
  6286. }
  6287. client->GetPlayer()->SetCharSheetChanged(true);
  6288. }
  6289. else if (strcmp(sep->arg[0], "backoff") == 0) {
  6290. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to back down.");
  6291. if (client->GetPlayer()->GetPet())
  6292. ((NPC*)client->GetPlayer()->GetPet())->Brain()->ClearHate();
  6293. if (client->GetPlayer()->GetCharmedPet())
  6294. ((NPC*)client->GetPlayer()->GetCharmedPet())->Brain()->ClearHate();
  6295. client->GetPlayer()->GetInfoStruct()->pet_behavior = 0;
  6296. client->GetPlayer()->SetCharSheetChanged(true);
  6297. }
  6298. else if (strcmp(sep->arg[0], "attack") == 0) {
  6299. if (client->GetPlayer()->HasTarget() && client->GetPlayer()->GetTarget()->IsEntity()) {
  6300. if (client->GetPlayer()->AttackAllowed((Entity*)client->GetPlayer()->GetTarget())){
  6301. client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to attack your target.");
  6302. if (client->GetPlayer()->GetPet())
  6303. client->GetPlayer()->GetPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  6304. if (client->GetPlayer()->GetCharmedPet())
  6305. client->GetPlayer()->GetCharmedPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1);
  6306. }
  6307. else
  6308. client->Message(CHANNEL_COLOR_YELLOW, "You can not attack that.");
  6309. }
  6310. else
  6311. client->Message(CHANNEL_COLOR_YELLOW, "You do not have a target.");
  6312. }
  6313. else if (strcmp(sep->arg[0], "getlost") == 0) {
  6314. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetPet());
  6315. client->GetPlayer()->DismissPet((NPC*)client->GetPlayer()->GetCharmedPet());
  6316. client->Message(CHANNEL_COLOR_YELLOW, "You tell your pet to get lost.");
  6317. }
  6318. else
  6319. client->Message(CHANNEL_COLOR_YELLOW, "Unknown pet command.");
  6320. }
  6321. /*
  6322. Function: Command_PetName()
  6323. Purpose : Pet your name (???)
  6324. Params :
  6325. Dev :
  6326. Example :
  6327. */
  6328. void Commands::Command_PetName(Client* client, Seperator* sep)
  6329. {
  6330. PrintSep(sep, "COMMAND_PETNAME");
  6331. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Pet Name Command");
  6332. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6333. }
  6334. /*
  6335. Function: Command_NamePet()
  6336. Purpose : Name your pet
  6337. Params :
  6338. Dev :
  6339. Example :
  6340. */
  6341. void Commands::Command_NamePet(Client* client, Seperator* sep)
  6342. {
  6343. PrintSep(sep, "COMMAND_NAME_PET");
  6344. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Name Pet Command");
  6345. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6346. }
  6347. /*
  6348. Function: Command_Rename()
  6349. Purpose : Renames existing pet
  6350. Params :
  6351. Dev :
  6352. Example :
  6353. */
  6354. void Commands::Command_Rename(Client* client, Seperator* sep)
  6355. {
  6356. PrintSep(sep, "COMMAND_RENAME");
  6357. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Rename Pet Command");
  6358. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6359. }
  6360. /*
  6361. Function: Command_ConfirmRename()
  6362. Purpose : Confirms renaming your pet
  6363. Params :
  6364. Dev :
  6365. Example :
  6366. */
  6367. void Commands::Command_ConfirmRename(Client* client, Seperator* sep)
  6368. {
  6369. PrintSep(sep, "COMMAND_CONFIRMRENAME");
  6370. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Confirm Rename Pet Command");
  6371. client->Message(CHANNEL_COLOR_YELLOW, "Pets are not yet implemented.");
  6372. }
  6373. /*
  6374. Function: Command_PetOptions()
  6375. Purpose : Sets various pet options
  6376. Params :
  6377. Dev :
  6378. Example :
  6379. */
  6380. void Commands::Command_PetOptions(Client* client, Seperator* sep)
  6381. {
  6382. PrintSep(sep, "COMMAND_PETOPTIONS");
  6383. Player* player = client->GetPlayer();
  6384. Spawn* target = player->GetTarget();
  6385. if (!target)
  6386. return;
  6387. if (target == player->GetPet())
  6388. client->SendPetOptionsWindow(player->GetPet()->GetName());
  6389. else if (target == player->GetCharmedPet())
  6390. client->SendPetOptionsWindow(player->GetCharmedPet()->GetName());
  6391. else if (target == player->GetCosmeticPet())
  6392. client->SendPetOptionsWindow(player->GetCosmeticPet()->GetName(), 0);
  6393. else if (target == player->GetDeityPet())
  6394. client->SendPetOptionsWindow(player->GetDeityPet()->GetName(), 0);
  6395. }
  6396. /*
  6397. Function: Command_Random()
  6398. Purpose : Handles /random dice roll in-game
  6399. Params : 1-100
  6400. Dev : Scatman
  6401. Example : /randon 1 100
  6402. */
  6403. void Commands::Command_Random(Client* client, Seperator* sep)
  6404. {
  6405. char message[256] = {0};
  6406. if (sep)
  6407. {
  6408. if (sep->GetArgNumber() == 0 && sep->IsNumber(0))
  6409. 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])));
  6410. else if (sep->GetArgNumber() > 0 && sep->IsNumber(0) && sep->IsNumber(1))
  6411. 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])));
  6412. else
  6413. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  6414. }
  6415. else
  6416. sprintf(message, "Random: %s rolls from 1 to 100 on the magic dice...and scores a %i!", client->GetPlayer()->GetName(), MakeRandomInt(1, 100));
  6417. client->GetPlayer()->GetZone()->HandleChatMessage(0, 0, CHANNEL_EMOTE, message);
  6418. }
  6419. /*
  6420. Function: Command_Randomize()
  6421. Purpose : Sets randomize (appearance) values for NPCs
  6422. Params : Attrib Name
  6423. Dev : Scatman
  6424. Example : /randomize gender 1 -- will randomize the NPCs gender (male/female)
  6425. */
  6426. void Commands::Command_Randomize(Client* client, Seperator* sep)
  6427. {
  6428. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  6429. if (target)
  6430. {
  6431. if (target->IsNPC())
  6432. {
  6433. if (sep && sep->arg[0] && !sep->IsNumber(0))
  6434. {
  6435. const char* value = sep->arg[0];
  6436. if (strncasecmp(value, "show", strlen(value)) == 0)
  6437. {
  6438. client->DisplayRandomizeFeatures(target->GetRandomize());
  6439. }
  6440. else
  6441. {
  6442. if (sep->arg[1] && sep->IsNumber(1))
  6443. {
  6444. int8 option = atoi(sep->arg[1]);
  6445. if (option == 0 || option == 1)
  6446. {
  6447. int32 feature = 0;
  6448. char feature_text[32] = {0};
  6449. if (strncasecmp(value, "gender", strlen(value)) == 0) {
  6450. feature = RANDOMIZE_GENDER;
  6451. strncpy(feature_text, "gender", sizeof(feature_text) - 1);
  6452. }
  6453. else if (strncasecmp(value, "race", strlen(value)) == 0) {
  6454. feature = RANDOMIZE_RACE;
  6455. strncpy(feature_text, "race", sizeof(feature_text) - 1);
  6456. }
  6457. else if (strncasecmp(value, "model", strlen(value)) == 0) {
  6458. feature = RANDOMIZE_MODEL_TYPE;
  6459. strncpy(feature_text, "model", sizeof(feature_text) - 1);
  6460. }
  6461. else if (strncasecmp(value, "facial_hair", strlen(value)) == 0) {
  6462. feature = RANDOMIZE_FACIAL_HAIR_TYPE;
  6463. strncpy(feature_text, "facial hair", sizeof(feature_text) - 1);
  6464. }
  6465. else if (strncasecmp(value, "hair", strlen(value)) == 0) {
  6466. feature = RANDOMIZE_HAIR_TYPE;
  6467. strncpy(feature_text, "hair", sizeof(feature_text) - 1);
  6468. }
  6469. else if (strncasecmp(value, "wing", strlen(value)) == 0) {
  6470. feature = RANDOMIZE_WING_TYPE;
  6471. strncpy(feature_text, "wings", sizeof(feature_text) - 1);
  6472. }
  6473. else if (strncasecmp(value, "cheek", strlen(value)) == 0) {
  6474. feature = RANDOMIZE_CHEEK_TYPE;
  6475. strncpy(feature_text, "cheeks", sizeof(feature_text) - 1);
  6476. }
  6477. else if (strncasecmp(value, "chin", strlen(value)) == 0) {
  6478. feature = RANDOMIZE_CHIN_TYPE;
  6479. strncpy(feature_text, "chin", sizeof(feature_text) - 1);
  6480. }
  6481. else if (strncasecmp(value, "ear", strlen(value)) == 0) {
  6482. feature = RANDOMIZE_EAR_TYPE;
  6483. strncpy(feature_text, "ears", sizeof(feature_text) - 1);
  6484. }
  6485. else if (strncasecmp(value, "eye_brow", strlen(value)) == 0) {
  6486. feature = RANDOMIZE_EYE_BROW_TYPE;
  6487. strncpy(feature_text, "eye brows", sizeof(feature_text) - 1);
  6488. }
  6489. else if (strncasecmp(value, "eye", strlen(value)) == 0) {
  6490. feature = RANDOMIZE_EYE_TYPE;
  6491. strncpy(feature_text, "eyes", sizeof(feature_text) - 1);
  6492. }
  6493. else if (strncasecmp(value, "lip", strlen(value)) == 0) {
  6494. feature = RANDOMIZE_LIP_TYPE;
  6495. strncpy(feature_text, "lips", sizeof(feature_text) - 1);
  6496. }
  6497. else if (strncasecmp(value, "nose", strlen(value)) == 0) {
  6498. feature = RANDOMIZE_NOSE_TYPE;
  6499. strncpy(feature_text, "nose", sizeof(feature_text) - 1);
  6500. }
  6501. else if (strncasecmp(value, "eye_color", strlen(value)) == 0) {
  6502. feature = RANDOMIZE_EYE_COLOR;
  6503. strncpy(feature_text, "eye color", sizeof(feature_text) - 1);
  6504. }
  6505. else if (strncasecmp(value, "hair_color", strlen(value)) == 0) {
  6506. feature = RANDOMIZE_HAIR_TYPE_COLOR;
  6507. strncpy(feature_text, "hair color", sizeof(feature_text) - 1);
  6508. }
  6509. else if (strncasecmp(value, "hair_color1", strlen(value)) == 0) {
  6510. feature = RANDOMIZE_HAIR_COLOR1;
  6511. strncpy(feature_text, "hair color1", sizeof(feature_text) - 1);
  6512. }
  6513. else if (strncasecmp(value, "hair_color2", strlen(value)) == 0) {
  6514. feature = RANDOMIZE_HAIR_COLOR2;
  6515. strncpy(feature_text, "hair color2", sizeof(feature_text) - 1);
  6516. }
  6517. else if (strncasecmp(value, "hair_highlight", strlen(value)) == 0) {
  6518. feature = RANDOMIZE_HAIR_HIGHLIGHT;
  6519. strncpy(feature_text, "hair highlights", sizeof(feature_text) - 1);
  6520. }
  6521. else if (strncasecmp(value, "facial_hair_color", strlen(value)) == 0) {
  6522. feature = RANDOMIZE_HAIR_FACE_COLOR;
  6523. strncpy(feature_text, "facial hair color", sizeof(feature_text) - 1);
  6524. }
  6525. else if (strncasecmp(value, "facial_hair_color_highlight", strlen(value)) == 0) {
  6526. feature = RANDOMIZE_HAIR_FACE_HIGHLIGHT_COLOR;
  6527. strncpy(feature_text, "facial hair color highlights", sizeof(feature_text) - 1);
  6528. }
  6529. else if (strncasecmp(value, "hair_color_highlight", strlen(value)) == 0) {
  6530. feature = RANDOMIZE_HAIR_TYPE_HIGHLIGHT_COLOR;
  6531. strncpy(feature_text, "hair color highlights", sizeof(feature_text) - 1);
  6532. }
  6533. else if (strncasecmp(value, "skin_color", strlen(value)) == 0) {
  6534. feature = RANDOMIZE_SKIN_COLOR;
  6535. strncpy(feature_text, "skin color", sizeof(feature_text) - 1);
  6536. }
  6537. else if (strncasecmp(value, "wing_color1", strlen(value)) == 0) {
  6538. feature = RANDOMIZE_WING_COLOR1;
  6539. strncpy(feature_text, "wing color1", sizeof(feature_text) - 1);
  6540. }
  6541. else if (strncasecmp(value, "wing_color2", strlen(value)) == 0) {
  6542. feature = RANDOMIZE_WING_COLOR2;
  6543. strncpy(feature_text, "wing color2", sizeof(feature_text) - 1);
  6544. }
  6545. else {
  6546. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is not a valid feature to randomize.", value);
  6547. 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'.");
  6548. }
  6549. if (feature > 0) {
  6550. if (option == 1) {
  6551. if (target->GetRandomize() & feature)
  6552. client->Message(CHANNEL_COLOR_YELLOW, "'%s' is already set to randomly generate their %s.", target->GetName(), feature_text);
  6553. else {
  6554. target->AddRandomize(feature);
  6555. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(feature);
  6556. database.UpdateRandomize(target->GetDatabaseID(), feature);
  6557. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will now generate their %s randomly.", target->GetName(), feature_text);
  6558. }
  6559. }
  6560. else {
  6561. if (target->GetRandomize() & feature) {
  6562. target->AddRandomize(-feature);
  6563. ((NPC*)client->GetCurrentZone()->GetSpawn(target->GetDatabaseID()))->AddRandomize(-feature);
  6564. database.UpdateRandomize(target->GetDatabaseID(), -feature);
  6565. client->Message(CHANNEL_COLOR_YELLOW, "'%s' will no longer generate their %s randomly.", target->GetName(), feature_text);
  6566. }
  6567. else
  6568. client->Message(CHANNEL_COLOR_YELLOW, "'%s' already does not randomly generate their %s.", target->GetName(), feature_text);
  6569. }
  6570. }
  6571. }
  6572. else
  6573. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  6574. }
  6575. else
  6576. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must specify either a 1(on) or 0(off) as the second parameter.");
  6577. }
  6578. }
  6579. else {
  6580. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /randomize [show | [feature [1|0]]");
  6581. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "'show' will display current configured features");
  6582. 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'.");
  6583. }
  6584. }
  6585. else
  6586. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "The target you wish to randomize must be an NPC.");
  6587. }
  6588. else
  6589. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You must select the target you wish to randomize.");
  6590. }
  6591. /*
  6592. Function: Command_ShowCloak()
  6593. Purpose : Character Settings combo box for Show Cloak
  6594. Params : true/false
  6595. Dev : John Adams
  6596. Example :
  6597. */
  6598. void Commands::Command_ShowCloak(Client* client, Seperator* sep)
  6599. {
  6600. Player* player = client->GetPlayer();
  6601. if (sep && sep->arg[0])
  6602. {
  6603. const char* value = sep->arg[0];
  6604. if (strncasecmp(value, "true", strlen(value)) == 0)
  6605. {
  6606. player->set_character_flag(CF_SHOW_CLOAK);
  6607. player->reset_character_flag(CF2_SHOW_RANGED);
  6608. }
  6609. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6610. player->reset_character_flag(CF_SHOW_CLOAK);
  6611. else
  6612. {
  6613. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6614. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6615. }
  6616. }
  6617. }
  6618. /*
  6619. Function: Command_ShowHelm()
  6620. Purpose : Character Settings combo box for Show Helm
  6621. Params : true/false
  6622. Dev : John Adams
  6623. Example :
  6624. */
  6625. void Commands::Command_ShowHelm(Client* client, Seperator* sep)
  6626. {
  6627. Player* player = client->GetPlayer();
  6628. if (sep && sep->arg[0])
  6629. {
  6630. const char* value = sep->arg[0];
  6631. if (strncasecmp(value, "true", strlen(value)) == 0)
  6632. {
  6633. player->reset_character_flag(CF_HIDE_HELM);
  6634. player->set_character_flag(CF_HIDE_HOOD);
  6635. }
  6636. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6637. player->set_character_flag(CF_HIDE_HELM);
  6638. else
  6639. {
  6640. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6641. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6642. }
  6643. }
  6644. }
  6645. /*
  6646. Function: Command_ShowHood()
  6647. Purpose : Character Settings combo box for Show Hood
  6648. Params : true/false
  6649. Dev : John Adams
  6650. Example :
  6651. */
  6652. void Commands::Command_ShowHood(Client* client, Seperator* sep)
  6653. {
  6654. Player* player = client->GetPlayer();
  6655. if (sep && sep->arg[0])
  6656. {
  6657. const char* value = sep->arg[0];
  6658. if (strncasecmp(value, "true", strlen(value)) == 0)
  6659. {
  6660. player->reset_character_flag(CF_HIDE_HOOD);
  6661. player->set_character_flag(CF_HIDE_HELM);
  6662. }
  6663. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6664. player->set_character_flag(CF_HIDE_HOOD);
  6665. else
  6666. {
  6667. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6668. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6669. }
  6670. }
  6671. }
  6672. /*
  6673. Function: Command_ShowHoodHelm()
  6674. Purpose : Character Settings combo box for Show Helm or Hood
  6675. Params : true/false
  6676. Dev : John Adams
  6677. Example :
  6678. */
  6679. void Commands::Command_ShowHoodHelm(Client* client, Seperator* sep)
  6680. {
  6681. Player* player = client->GetPlayer();
  6682. if (sep && sep->arg[0])
  6683. {
  6684. const char* value = sep->arg[0];
  6685. if (strncasecmp(value, "true", strlen(value)) == 0)
  6686. {
  6687. player->reset_character_flag(CF_HIDE_HOOD);
  6688. player->reset_character_flag(CF_HIDE_HELM);
  6689. }
  6690. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6691. {
  6692. // don't think we ever wind up in here...
  6693. player->set_character_flag(CF_HIDE_HOOD);
  6694. player->set_character_flag(CF_HIDE_HELM);
  6695. }
  6696. else
  6697. {
  6698. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6699. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6700. }
  6701. }
  6702. }
  6703. /*
  6704. Function: Command_ShowRanged()
  6705. Purpose : Character Settings combo box for Show Ranged weapon
  6706. Params : true/false
  6707. Dev : John Adams
  6708. Example :
  6709. */
  6710. void Commands::Command_ShowRanged(Client* client, Seperator* sep)
  6711. {
  6712. Player* player = client->GetPlayer();
  6713. if (sep && sep->arg[0])
  6714. {
  6715. const char* value = sep->arg[0];
  6716. if (strncasecmp(value, "true", strlen(value)) == 0)
  6717. {
  6718. player->set_character_flag(CF2_SHOW_RANGED);
  6719. player->reset_character_flag(CF_SHOW_CLOAK);
  6720. }
  6721. else if (strncasecmp(value, "false", strlen(value)) == 0)
  6722. player->reset_character_flag(CF2_SHOW_RANGED);
  6723. else
  6724. {
  6725. client->Message(CHANNEL_COLOR_YELLOW, "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6726. LogWrite(COMMAND__WARNING, 0, "Command", "Not supposed to be here! Please /bug this: Error in %s (%u)", __FUNCTION__, __LINE__);
  6727. }
  6728. }
  6729. }
  6730. /*
  6731. Function:
  6732. Purpose :
  6733. Params :
  6734. Dev :
  6735. Example :
  6736. */
  6737. void Commands::Command_Skills(Client* client, Seperator* sep, int handler)
  6738. {
  6739. Player* player = 0;
  6740. Client* to_client = 0;
  6741. if(client->GetPlayer()->GetTarget() && client->GetPlayer()->GetTarget()->IsPlayer())
  6742. to_client = client->GetPlayer()->GetTarget()->GetZone()->GetClientBySpawn(client->GetPlayer()->GetTarget());
  6743. switch(handler)
  6744. {
  6745. case COMMAND_SKILL:
  6746. {
  6747. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill [add|remove|list] [skill name]");
  6748. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to add/remove skills for that player.");
  6749. break;
  6750. }
  6751. case COMMAND_SKILL_ADD:
  6752. {
  6753. if (sep && sep->arg[0])
  6754. {
  6755. const char* skill_name = sep->argplus[0];
  6756. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6757. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // add skill to your target, if target is not you
  6758. {
  6759. player = to_client->GetPlayer();
  6760. if (player)
  6761. {
  6762. if (!player->GetSkills()->HasSkill(skill->skill_id))
  6763. {
  6764. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  6765. client->Message(CHANNEL_COLOR_YELLOW, "You gave skill '%s' to player '%s'.", skill_name, player->GetName());
  6766. to_client->Message(CHANNEL_COLOR_YELLOW, "%s gave you skill '%s'.", client->GetPlayer()->GetName(), skill_name);
  6767. }
  6768. else
  6769. client->Message(CHANNEL_COLOR_YELLOW, "%s already has the skill '%s'.", player->GetName(), skill_name);
  6770. }
  6771. }
  6772. else if (skill) // add skill to yourself
  6773. {
  6774. player = client->GetPlayer();
  6775. if (player)
  6776. {
  6777. if (!player->GetSkills()->HasSkill(skill->skill_id))
  6778. {
  6779. player->AddSkill(skill->skill_id, 1, player->GetLevel() * 5, true);
  6780. client->Message(CHANNEL_COLOR_YELLOW, "Added skill '%s'.", skill_name);
  6781. }
  6782. else
  6783. client->Message(CHANNEL_COLOR_YELLOW, "You already have the skill '%s'.", skill_name);
  6784. }
  6785. }
  6786. else
  6787. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  6788. }
  6789. else
  6790. {
  6791. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill add [skill name]");
  6792. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  6793. }
  6794. break;
  6795. }
  6796. case COMMAND_SKILL_REMOVE:
  6797. {
  6798. if (sep && sep->arg[0])
  6799. {
  6800. const char* skill_name = sep->argplus[0];
  6801. Skill* skill = master_skill_list.GetSkillByName(skill_name);
  6802. if (skill && to_client && !(client->GetPlayer() == to_client->GetPlayer())) // remove skill from your target, if target is not you
  6803. {
  6804. player = to_client->GetPlayer();
  6805. if (player)
  6806. {
  6807. if (player->GetSkills()->HasSkill(skill->skill_id))
  6808. {
  6809. player->RemoveSkillFromDB(skill, true);
  6810. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s' from player %s.", skill_name, player->GetName());
  6811. to_client->Message(CHANNEL_COLOR_YELLOW, "%s has removed skill '%s' from you.", client->GetPlayer()->GetName(), skill_name);
  6812. }
  6813. else
  6814. client->Message(CHANNEL_COLOR_YELLOW, "Player '%s' does not have the skill '%s'.", player->GetName(), skill_name);
  6815. }
  6816. }
  6817. else if(skill) // remove skill from yourself
  6818. {
  6819. Player* player = client->GetPlayer();
  6820. if (player)
  6821. {
  6822. if (player->GetSkills()->HasSkill(skill->skill_id))
  6823. {
  6824. player->RemoveSkillFromDB(skill, true);
  6825. client->Message(CHANNEL_COLOR_YELLOW, "Removed skill '%s'.", skill_name);
  6826. }
  6827. else
  6828. client->Message(CHANNEL_COLOR_YELLOW, "You do not have the skill '%s'.", skill_name);
  6829. }
  6830. }
  6831. else
  6832. client->Message(CHANNEL_COLOR_YELLOW, "The skill '%s' does not exist.", skill_name);
  6833. }
  6834. else
  6835. {
  6836. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill remove [skill name]");
  6837. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Target player to give skill to that player.");
  6838. }
  6839. break;
  6840. }
  6841. case COMMAND_SKILL_LIST:
  6842. {
  6843. if (sep && sep->arg[0])
  6844. {
  6845. const char* skill_name = sep->argplus[0];
  6846. client->Message(CHANNEL_COLOR_YELLOW, "Listing skills like '%s':", skill_name);
  6847. map<int32, Skill*>* skills = master_skill_list.GetAllSkills();
  6848. map<int32, Skill*>::iterator itr;
  6849. if (skills && skills->size() > 0)
  6850. {
  6851. for (itr = skills->begin(); itr != skills->end(); itr++)
  6852. {
  6853. Skill* skill = itr->second;
  6854. string current_skill_name = ::ToLower(string(skill->name.data.c_str()));
  6855. if (current_skill_name.find(::ToLower(string(skill_name))) < 0xFFFFFFFF)
  6856. client->Message(CHANNEL_COLOR_YELLOW, "%s (%u)", skill->name.data.c_str(), skill->skill_id);
  6857. }
  6858. }
  6859. }
  6860. else
  6861. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /skill list [skill name]");
  6862. break;
  6863. }
  6864. }
  6865. }
  6866. /*
  6867. Function: Command_SpawnTemplate()
  6868. Purpose : Create or Use defined Spawn Templates
  6869. Params : create, save, rempve, list
  6870. Dev : John Adams
  6871. Example : /spawn template create "Test"
  6872. */
  6873. void Commands::Command_SpawnTemplate(Client* client, Seperator* sep)
  6874. {
  6875. if (sep == NULL || sep->arg[0] == NULL)
  6876. {
  6877. 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.");
  6878. return;
  6879. }
  6880. // got params, continue
  6881. const char * template_cmd = sep->arg[0];
  6882. if (strncasecmp(template_cmd, "list", strlen(template_cmd)) == 0)
  6883. {
  6884. if (!sep->IsSet(1))
  6885. {
  6886. client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /spawn template list [name|location_id]");
  6887. 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.");
  6888. return;
  6889. }
  6890. map<int32, string>* template_names = 0;
  6891. if (sep->IsNumber(1))
  6892. {
  6893. int32 location_id = 0;
  6894. location_id = atoi(sep->arg[1]);
  6895. template_names = database.GetSpawnTemplateListByID(location_id);
  6896. }
  6897. else
  6898. {
  6899. const char* name = 0;
  6900. name = sep->argplus[1];
  6901. template_names = database.GetSpawnTemplateListByName(name);
  6902. }
  6903. if(!template_names)
  6904. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "No templates found.");
  6905. else
  6906. {
  6907. map<int32, string>::iterator itr;
  6908. client->SimpleMessage(CHANNEL_COLOR_YELLOW," ID Name: ");
  6909. for(itr = template_names->begin(); itr != template_names->end(); itr++)
  6910. client->Message(CHANNEL_COLOR_YELLOW,"%03lu %s", itr->first, itr->second.c_str());
  6911. safe_delete(template_names);
  6912. }
  6913. }
  6914. else if (strncasecmp(template_cmd, "save", strlen(template_cmd)) == 0)
  6915. {
  6916. NPC* target = (NPC*)client->GetPlayer()->GetTarget();
  6917. if ( target && (target->IsNPC() || target->IsObject() || target->IsSign() || target->IsWidget() || target->IsGroundSpawn()) )
  6918. {
  6919. if (sep && sep->arg[1][0] && !sep->IsNumber(1))
  6920. {
  6921. // first, lookup to see if template name already exists
  6922. const char* name = 0;
  6923. name = sep->argplus[1];
  6924. map<int32, string>* template_names = database.GetSpawnTemplateListByName(name);
  6925. if(!template_names)
  6926. {
  6927. int32 new_template_id = database.SaveSpawnTemplate(target->GetSpawnLocationID(), name);
  6928. if( new_template_id > 0 )
  6929. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template '%s' added for spawn '%s' (%u) as TemplateID: %u", name, target->GetName(), target->GetSpawnLocationID(), new_template_id);
  6930. else
  6931. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' for spawn '%s' (%u).", name, target->GetName(), target->GetSpawnLocationID());
  6932. }
  6933. else
  6934. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to add new template '%s' - Already exists!", name);
  6935. }
  6936. else
  6937. client->Message(CHANNEL_COLOR_RED, "ERROR: Saving a new spawn template requires a valid template name!");
  6938. }
  6939. else
  6940. client->Message(CHANNEL_COLOR_RED, "ERROR: You must target the spawn you wish to save as a template!");
  6941. }
  6942. else if (strncasecmp(template_cmd, "remove", strlen(template_cmd)) == 0)
  6943. {
  6944. if (sep && sep->arg[1][0] && sep->IsNumber(1))
  6945. {
  6946. int32 template_id = 0;
  6947. template_id = atoi(sep->arg[1]);
  6948. if (database.RemoveSpawnTemplate(template_id))
  6949. client->Message(CHANNEL_COLOR_YELLOW, "Spawn template ID: %u successfully removed.", template_id);
  6950. else
  6951. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to remove spawn template ID: %u", template_id);
  6952. }
  6953. else
  6954. client->Message(CHANNEL_COLOR_RED, "ERROR: Removing a spawn template requires a valid template ID!");
  6955. }
  6956. // Renamed create to spawn
  6957. else if (strncasecmp(template_cmd, "spawn", strlen(template_cmd)) == 0)
  6958. {
  6959. if (sep && sep->arg[1][0])
  6960. {
  6961. int32 new_location = 0;
  6962. if (sep->IsNumber(1))
  6963. {
  6964. int32 template_id = 0;
  6965. template_id = atoi(sep->arg[1]);
  6966. new_location = database.CreateSpawnFromTemplateByID(client, template_id);
  6967. if( new_location > 0 )
  6968. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template ID: %u", new_location, template_id);
  6969. else
  6970. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template ID: %u", template_id);
  6971. }
  6972. else
  6973. {
  6974. const char* name = 0;
  6975. name = sep->argplus[1];
  6976. new_location = database.CreateSpawnFromTemplateByName(client, name);
  6977. if( new_location > 0 )
  6978. client->Message(CHANNEL_COLOR_YELLOW, "New spawn location %u created from template: '%s'", new_location, name);
  6979. else
  6980. client->Message(CHANNEL_COLOR_RED, "ERROR: Failed to spawn the new spawn location from template: '%s'", name);
  6981. }
  6982. }
  6983. else
  6984. client->Message(CHANNEL_COLOR_RED, "ERROR: Spawning a new spawn location requires a valid template name or ID!");
  6985. }
  6986. else
  6987. client->Message(CHANNEL_COLOR_RED, "ERROR: Unknown /spawn template command.");
  6988. }
  6989. void Commands::Command_Speed(Client* client, Seperator* sep) {
  6990. if(sep && sep->arg[0][0] && sep->IsNumber(0)){
  6991. float new_speed = atof(sep->arg[0]);
  6992. if (new_speed > 0.0f)
  6993. {
  6994. client->GetPlayer()->SetSpeed(new_speed, true);
  6995. client->GetPlayer()->SetCharSheetChanged(true);
  6996. database.insertCharacterProperty(client, CHAR_PROPERTY_SPEED, sep->arg[0]);
  6997. client->Message(CHANNEL_STATUS, "Setting speed to %.2f.", new_speed);
  6998. }
  6999. else
  7000. client->Message(CHANNEL_STATUS, "Invalid speed provided %s.", sep->arg[0]);
  7001. }
  7002. else{
  7003. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /speed {new speed value}");
  7004. }
  7005. }
  7006. /*
  7007. Function: Command_StationMarketPlace()
  7008. Purpose : just trying to eat the console spam for now
  7009. Params :
  7010. Dev : John
  7011. */
  7012. void Commands::Command_StationMarketPlace(Client* client, Seperator* sep)
  7013. {
  7014. PrintSep(sep, "COMMAND_SMP");
  7015. // This will reduce the spam from once every 10 sec to once every 30 sec,
  7016. // can't seem to reduce it any more get rid of it completely...
  7017. if (sep && strcmp(sep->arg[0], "gkw") == 0) {
  7018. PacketStruct* packet = configReader.getStruct("WS_MarketFundsUpdate", client->GetVersion());
  7019. if (packet) {
  7020. packet->setDataByName("account_id", client->GetAccountID());
  7021. packet->setDataByName("character_id", client->GetCharacterID());
  7022. packet->setDataByName("unknown1", 1, 5);
  7023. packet->setDataByName("unknown1", 26, 6);
  7024. packet->setDataByName("unknown2", 0xFFFFFFFF);
  7025. packet->setDataByName("unknown3", 248, 1);
  7026. client->QueuePacket(packet->serialize());
  7027. }
  7028. safe_delete(packet);
  7029. }
  7030. }
  7031. /*
  7032. Function: Command_StopDrinking()
  7033. Purpose : Stops player from auto-consuming drink
  7034. Params :
  7035. Dev : Zcoretri
  7036. Example : /stopdrinking
  7037. */
  7038. void Commands::Command_StopDrinking(Client* client)
  7039. {
  7040. client->GetPlayer()->reset_character_flag(CF_DRINK_AUTO_CONSUME);
  7041. client->Message(CHANNEL_COLOR_YELLOW,"You stop drinking your current drink.");
  7042. }
  7043. /*
  7044. Function: Command_StopEating()
  7045. Purpose : Stops player from auto-consuming food
  7046. Params :
  7047. Dev : Zcoretri
  7048. Example : /stopeating
  7049. */
  7050. void Commands::Command_StopEating(Client* client)
  7051. {
  7052. client->GetPlayer()->reset_character_flag(CF_FOOD_AUTO_CONSUME);
  7053. client->Message(CHANNEL_COLOR_YELLOW,"You stop eating your current food.");
  7054. }
  7055. /*
  7056. Function: Command_Title()
  7057. Purpose : Help for /title command
  7058. Params : n/a
  7059. Dev : Zcoretri
  7060. Example : /title
  7061. */
  7062. void Commands::Command_Title(Client* client)
  7063. {
  7064. client->Message(CHANNEL_COLOR_YELLOW, "Available subcommands: list, setprefix <index>, setsuffix <index>, fix");
  7065. }
  7066. /*
  7067. Function: Command_TitleList()
  7068. Purpose : List available titles for player
  7069. Params : n/a
  7070. Dev : Zcoretri
  7071. Example : /title list
  7072. */
  7073. void Commands::Command_TitleList(Client* client)
  7074. {
  7075. list<Title*>* titles = client->GetPlayer()->GetPlayerTitles()->GetAllTitles();
  7076. list<Title*>::iterator itr;
  7077. Title* title;
  7078. int16 i = 0;
  7079. client->Message(CHANNEL_COLOR_WHITE, "Listing available titles:");
  7080. for(itr = titles->begin(); itr != titles->end(); itr++)
  7081. {
  7082. title = *itr;
  7083. client->Message(CHANNEL_COLOR_WHITE, "%i: type=[%s] title=[%s]", i, title->GetPrefix() ? "Prefix":"Suffix", title->GetName());
  7084. i++;
  7085. }
  7086. }
  7087. /*
  7088. Function: Command_TitleSetPrefix()
  7089. Purpose : Set Prefix title for player
  7090. Params : Title ID
  7091. Dev : Zcoretri
  7092. Example : /title setprefix 1
  7093. */
  7094. void Commands::Command_TitleSetPrefix(Client* client, Seperator* sep)
  7095. {
  7096. if (sep && sep->arg[0] && sep->IsNumber(0))
  7097. {
  7098. int32 index = atoul(sep->arg[0]);
  7099. database.SaveCharPrefixIndex(index, client->GetCharacterID(), client);
  7100. client->SendTitleUpdate();
  7101. }
  7102. }
  7103. /*
  7104. Function: Command_TitleSetSuffix()
  7105. Purpose : Set Suffix title for player
  7106. Params : Title ID
  7107. Dev : Zcoretri
  7108. Example : /title setsuffix 1
  7109. */
  7110. void Commands::Command_TitleSetSuffix(Client* client, Seperator* sep)
  7111. {
  7112. if (sep && sep->arg[0] && sep->IsNumber(0))
  7113. {
  7114. int32 index = atoul(sep->arg[0]);
  7115. database.SaveCharSuffixIndex(index, client->GetCharacterID(), client);
  7116. client->SendTitleUpdate();
  7117. }
  7118. }
  7119. /*
  7120. Function: Command_TitleFix()
  7121. Purpose : Fix title for player (???)
  7122. Params :
  7123. Dev : Zcoretri
  7124. Example :
  7125. */
  7126. void Commands::Command_TitleFix(Client* client, Seperator* sep)
  7127. {
  7128. PrintSep(sep, "COMMAND_TITLE_FIX");
  7129. LogWrite(MISC__TODO, 1, "Titles", "TODO-Command: TITLE_FIX");
  7130. }
  7131. /*
  7132. Function: Command_Toggle_Anonymous()
  7133. Purpose : Toggles player Anonymous
  7134. Params :
  7135. Dev : paulgh
  7136. Example : /anon
  7137. */
  7138. void Commands::Command_Toggle_Anonymous(Client* client)
  7139. {
  7140. Player* player = client->GetPlayer();
  7141. player->toggle_character_flag(CF_ANONYMOUS);
  7142. client->Message(CHANNEL_COLOR_YELLOW,"You are %s anonymous.", player->get_character_flag(CF_ANONYMOUS)?"now":"no longer");
  7143. if (player->get_character_flag(CF_ANONYMOUS))
  7144. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ANONYMOUS);
  7145. else
  7146. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ANONYMOUS);
  7147. }
  7148. /*
  7149. Function: Command_Toggle_AutoConsume()
  7150. Purpose : Toggles player food/drink auto consume
  7151. Params : unknown
  7152. Dev : paulgh
  7153. Example : /set_auto_consume
  7154. */
  7155. void Commands::Command_Toggle_AutoConsume(Client* client, Seperator* sep)
  7156. {
  7157. Player* player = client->GetPlayer();
  7158. if (sep && sep->arg[0])
  7159. PrintSep(sep, "COMMAND_SET_AUTO_CONSUME");
  7160. if (sep && sep->arg[0] && sep->IsNumber(0))
  7161. {
  7162. int8 slot = atoi(sep->arg[0]);
  7163. int8 flag = atoi(sep->arg[1]);
  7164. if (slot == EQ2_FOOD_SLOT)
  7165. {
  7166. player->toggle_character_flag(CF_FOOD_AUTO_CONSUME);
  7167. player->SetCharSheetChanged(true);
  7168. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  7169. if (flag == 1)
  7170. client->Message(CHANNEL_COLOR_WHITE, "You decide to eat immediately whenever you become hungry.");
  7171. else
  7172. client->Message(CHANNEL_COLOR_WHITE, "You decide to ignore the hunger.");
  7173. }
  7174. else
  7175. {
  7176. player->toggle_character_flag(CF_DRINK_AUTO_CONSUME);
  7177. player->SetCharSheetChanged(true);
  7178. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  7179. if (flag == 1)
  7180. client->Message(CHANNEL_COLOR_WHITE, "You decide to drink immediately whenever you become thirsty.");
  7181. else
  7182. client->Message(CHANNEL_COLOR_WHITE, "You decide to ignore the thirst.");
  7183. }
  7184. }
  7185. }
  7186. /*
  7187. Function: Command_Toggle_BonusXP()
  7188. Purpose : Toggles player Bonus XP
  7189. Params :
  7190. Dev : John Adams
  7191. Example : /disable_char_bonus_exp
  7192. */
  7193. void Commands::Command_Toggle_BonusXP(Client* client)
  7194. {
  7195. Player* player = client->GetPlayer();
  7196. player->toggle_character_flag(CF2_CHARACTER_BONUS_EXPERIENCE_ENABLED);
  7197. player->SetCharSheetChanged(true);
  7198. }
  7199. /*
  7200. Function: Command_Toggle_CombatXP()
  7201. Purpose : Toggles player Adventure XP
  7202. Params :
  7203. Dev : John Adams
  7204. Example : /disable_combat_exp
  7205. */
  7206. void Commands::Command_Toggle_CombatXP(Client* client)
  7207. {
  7208. Player* player = client->GetPlayer();
  7209. player->toggle_character_flag(CF_COMBAT_EXPERIENCE_ENABLED);
  7210. player->SetCharSheetChanged(true);
  7211. }
  7212. /*
  7213. Function: Command_Toggle_GMHide()
  7214. Purpose : Toggles hiding player GM status
  7215. Params :
  7216. Dev : Scatman
  7217. Example : /gm_hide
  7218. */
  7219. void Commands::Command_Toggle_GMHide(Client* client)
  7220. {
  7221. Player* player = client->GetPlayer();
  7222. player->toggle_character_flag(CF_HIDE_STATUS);
  7223. client->Message(CHANNEL_COLOR_YELLOW,"You are %s hiding your GM status.", player->get_character_flag(CF_HIDE_STATUS)?"now":"no longer");
  7224. }
  7225. /*
  7226. Function: Command_Toggle_GMVanish()
  7227. Purpose : Toggles hiding GM players from /who searches
  7228. Params :
  7229. Dev : Scatman
  7230. Example : /gm_vanish
  7231. */
  7232. void Commands::Command_Toggle_GMVanish(Client* client)
  7233. {
  7234. Player* player = client->GetPlayer();
  7235. player->toggle_character_flag(CF_GM_HIDDEN);
  7236. client->Message(CHANNEL_COLOR_YELLOW,"You are %s invisible to who queries.", player->get_character_flag(CF_GM_HIDDEN)?"now":"no longer");
  7237. }
  7238. /*
  7239. Function: Command_Toggle_Illusions()
  7240. Purpose : Toggles player illusion form
  7241. Params : not sure sep is needed, testing
  7242. Dev : paulgh
  7243. Example : /hide_illusions
  7244. */
  7245. void Commands::Command_Toggle_Illusions(Client* client, Seperator* sep)
  7246. {
  7247. if (sep && sep->arg[0])
  7248. PrintSep(sep, "COMMAND_TOGGLE_ILLUSIONS");
  7249. client->GetPlayer()->toggle_character_flag(CF_SHOW_ILLUSION);
  7250. }
  7251. /*
  7252. Function: Command_Toggle_LFG()
  7253. Purpose : Toggles player LFG Flag
  7254. Params :
  7255. Dev : paulgh
  7256. Example : /lfg
  7257. */
  7258. void Commands::Command_Toggle_LFG(Client* client)
  7259. {
  7260. Player* player = client->GetPlayer();
  7261. player->toggle_character_flag(CF_LFG);
  7262. client->Message(CHANNEL_COLOR_YELLOW,"You are %s LFG.", player->get_character_flag(CF_LFG)?"now":"no longer");
  7263. if (player->get_character_flag(CF_LFG))
  7264. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFG);
  7265. else
  7266. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFG);
  7267. }
  7268. /*
  7269. Function: Command_Toggle_LFW()
  7270. Purpose : Toggles player LFW Flag
  7271. Params :
  7272. Dev : paulgh
  7273. Example : /lfw
  7274. */
  7275. void Commands::Command_Toggle_LFW(Client* client)
  7276. {
  7277. Player* player = client->GetPlayer();
  7278. player->toggle_character_flag(CF_LFW);
  7279. client->Message(CHANNEL_COLOR_YELLOW,"You %s looking for work.", player->get_character_flag(CF_LFW)?"let others know you are":"stop");
  7280. if (player->get_character_flag(CF_LFW))
  7281. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_LFW);
  7282. else
  7283. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_LFW);
  7284. }
  7285. /*
  7286. Function: Command_Toggle_QuestXP()
  7287. Purpose : Toggles player Quest XP
  7288. Params :
  7289. Dev : John Adams
  7290. Example : /disable_quest_exp
  7291. */
  7292. void Commands::Command_Toggle_QuestXP(Client* client)
  7293. {
  7294. Player* player = client->GetPlayer();
  7295. player->toggle_character_flag(CF_QUEST_EXPERIENCE_ENABLED);
  7296. player->SetCharSheetChanged(true);
  7297. }
  7298. /*
  7299. Function: Command_Toggle_Roleplaying()
  7300. Purpose : Toggles player Roleplaying flag
  7301. Params :
  7302. Dev : paulgh
  7303. Example : /role
  7304. */
  7305. void Commands::Command_Toggle_Roleplaying(Client* client)
  7306. {
  7307. Player* player = client->GetPlayer();
  7308. player->toggle_character_flag(CF_ROLEPLAYING);
  7309. client->Message(CHANNEL_COLOR_YELLOW,"You are %s roleplaying.", player->get_character_flag(CF_ROLEPLAYING)?"now":"no longer");
  7310. if (player->get_character_flag(CF_ROLEPLAYING))
  7311. player->SetActivityStatus(player->GetActivityStatus() + ACTIVITY_STATUS_ROLEPLAYING);
  7312. else
  7313. player->SetActivityStatus(player->GetActivityStatus() - ACTIVITY_STATUS_ROLEPLAYING);
  7314. }
  7315. void Commands::Command_Toggle_Duels(Client* client)
  7316. {
  7317. Player* player = client->GetPlayer();
  7318. player->toggle_character_flag(CF_ALLOW_DUEL_INVITES);
  7319. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting duel invites.", player->get_character_flag(CF_ALLOW_DUEL_INVITES)?"now":"no longer");
  7320. }
  7321. void Commands::Command_Toggle_Trades(Client* client)
  7322. {
  7323. Player* player = client->GetPlayer();
  7324. player->toggle_character_flag(CF_ALLOW_TRADE_INVITES);
  7325. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting trade invites.", player->get_character_flag(CF_ALLOW_TRADE_INVITES)?"now":"no longer");
  7326. }
  7327. void Commands::Command_Toggle_Guilds(Client* client)
  7328. {
  7329. Player* player = client->GetPlayer();
  7330. player->toggle_character_flag(CF_ALLOW_GUILD_INVITES);
  7331. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting guild invites.", player->get_character_flag(CF_ALLOW_GUILD_INVITES)?"now":"no longer");
  7332. }
  7333. void Commands::Command_Toggle_Groups(Client* client)
  7334. {
  7335. Player* player = client->GetPlayer();
  7336. player->toggle_character_flag(CF_ALLOW_GROUP_INVITES);
  7337. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting group invites.", player->get_character_flag(CF_ALLOW_GROUP_INVITES)?"now":"no longer");
  7338. }
  7339. void Commands::Command_Toggle_Raids(Client* client)
  7340. {
  7341. Player* player = client->GetPlayer();
  7342. player->toggle_character_flag(CF_ALLOW_RAID_INVITES);
  7343. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting raid invites.", player->get_character_flag(CF_ALLOW_RAID_INVITES)?"now":"no longer");
  7344. }
  7345. void Commands::Command_Toggle_LON(Client* client)
  7346. {
  7347. Player* player = client->GetPlayer();
  7348. player->toggle_character_flag(CF2_ALLOW_LON_INVITES);
  7349. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting LoN invites.", player->get_character_flag(CF2_ALLOW_LON_INVITES)?"now":"no longer");
  7350. }
  7351. void Commands::Command_Toggle_VoiceChat(Client* client)
  7352. {
  7353. Player* player = client->GetPlayer();
  7354. player->toggle_character_flag(CF2_ALLOW_VOICE_INVITES);
  7355. client->Message(CHANNEL_COLOR_YELLOW,"You are %s accepting voice chat invites.", player->get_character_flag(CF2_ALLOW_VOICE_INVITES)?"now":"no longer");
  7356. }
  7357. /*
  7358. Function: Command_TradeStart()
  7359. Purpose : Starts item/coin trade between players
  7360. Params :
  7361. Dev :
  7362. Example :
  7363. */
  7364. #include "../Trade.h"
  7365. void Commands::Command_TradeStart(Client* client, Seperator* sep)
  7366. {
  7367. PrintSep(sep, "COMMAND_START_TRADE");
  7368. Entity* trader = client->GetPlayer();
  7369. Entity* trader2 = 0;
  7370. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7371. Spawn* spawn = client->GetPlayer()->GetSpawnWithPlayerID(atoi(sep->arg[0]));
  7372. if (spawn) {
  7373. if (spawn->IsEntity())
  7374. trader2 = (Entity*)spawn;
  7375. }
  7376. }
  7377. else if (client->GetPlayer()->GetTarget()) {
  7378. if (client->GetPlayer()->GetTarget()->IsEntity())
  7379. trader2 = (Entity*)client->GetPlayer()->GetTarget();
  7380. }
  7381. // can only trade with player or bots
  7382. if (trader && trader2) {
  7383. if (trader == trader2) {
  7384. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade with yourself.");
  7385. }
  7386. else if (trader2->IsPlayer() || trader2->IsBot()) {
  7387. LogWrite(PLAYER__ERROR, 0, "Trade", "creating trade");
  7388. if (trader->trade)
  7389. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are already trading.");
  7390. else if (trader2->trade)
  7391. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Your target is already trading.");
  7392. else {
  7393. Trade* trade = new Trade(trader, trader2);
  7394. trader->trade = trade;
  7395. trader2->trade = trade;
  7396. }
  7397. }
  7398. else {
  7399. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can only trade with another player or a bot.");
  7400. }
  7401. }
  7402. else
  7403. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unable to find target");
  7404. }
  7405. /*
  7406. Function: Command_Track()
  7407. Purpose : Starts/Stops Tracking for a player
  7408. Params :
  7409. Dev : Scatman
  7410. Example : /track
  7411. */
  7412. void Commands::Command_Track(Client* client)
  7413. {
  7414. if (!client->GetPlayer()->GetIsTracking())
  7415. client->GetPlayer()->GetZone()->AddPlayerTracking(client->GetPlayer());
  7416. else
  7417. client->GetPlayer()->GetZone()->RemovePlayerTracking(client->GetPlayer(), TRACKING_STOP);
  7418. }
  7419. /*
  7420. Function: Command_TradeAccept()
  7421. Purpose : Accepts item/coin trade between players
  7422. Params :
  7423. Dev :
  7424. Example :
  7425. */
  7426. void Commands::Command_TradeAccept(Client* client, Seperator* sep)
  7427. {
  7428. PrintSep(sep, "COMMAND_ACCEPT_TRADE");
  7429. Trade* trade = client->GetPlayer()->trade;
  7430. if (trade) {
  7431. bool trade_complete = trade->SetTradeAccepted(client->GetPlayer());
  7432. if (trade_complete)
  7433. safe_delete(trade);
  7434. }
  7435. else
  7436. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7437. }
  7438. /*
  7439. Function: Command_TradeReject()
  7440. Purpose : Rejects item/coin trade between players
  7441. Params :
  7442. Dev :
  7443. Example :
  7444. */
  7445. void Commands::Command_TradeReject(Client* client, Seperator* sep)
  7446. {
  7447. PrintSep(sep, "COMMAND_REJECT_TRADE");
  7448. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Reject Player Trading");
  7449. client->Message(CHANNEL_COLOR_YELLOW, "You cannot trade with other players (Not Implemented)");
  7450. }
  7451. /*
  7452. Function: Command_TradeCancel()
  7453. Purpose : Cancels item/coin trade between players
  7454. Params :
  7455. Dev :
  7456. Example :
  7457. */
  7458. void Commands::Command_TradeCancel(Client* client, Seperator* sep)
  7459. {
  7460. PrintSep(sep, "COMMAND_CANCEL_TRADE");
  7461. Trade* trade = client->GetPlayer()->trade;
  7462. if (trade) {
  7463. trade->CancelTrade(client->GetPlayer());
  7464. safe_delete(trade);
  7465. }
  7466. else
  7467. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7468. }
  7469. /*
  7470. Function: Command_TradeSetCoin()
  7471. Purpose : Sets coin trade between players
  7472. Params :
  7473. Dev :
  7474. Example :
  7475. */
  7476. void Commands::Command_TradeSetCoin(Client* client, Seperator* sep)
  7477. {
  7478. PrintSep(sep, "COMMAND_SET_TRADE_COIN");
  7479. LogWrite(MISC__TODO, 1, "Command", "TODO-Command: Set Trade Coin");
  7480. client->Message(CHANNEL_COLOR_YELLOW, "You cannot trade with other players (Not Implemented)");
  7481. }
  7482. /*
  7483. Function: Command_TradeAddCoin()
  7484. Purpose : Adds coin to trade between players
  7485. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  7486. Dev :
  7487. Example :
  7488. */
  7489. void Commands::Command_TradeAddCoin(Client* client, Seperator* sep, int handler)
  7490. {
  7491. PrintSep(sep, "COMMAND_ADD_TRADE_{coin type}");
  7492. Trade* trade = client->GetPlayer()->trade;
  7493. if (trade) {
  7494. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7495. int32 amount = atoi(sep->arg[0]);
  7496. int64 val = 0;
  7497. switch (handler) {
  7498. case COMMAND_ADD_TRADE_COPPER:
  7499. {
  7500. val = amount;
  7501. trade->AddCoinToTrade(client->GetPlayer(), val);
  7502. break;
  7503. }
  7504. case COMMAND_ADD_TRADE_SILVER:
  7505. {
  7506. val = amount * 100;
  7507. trade->AddCoinToTrade(client->GetPlayer(), val);
  7508. break;
  7509. }
  7510. case COMMAND_ADD_TRADE_GOLD:
  7511. {
  7512. val = amount * 10000;
  7513. trade->AddCoinToTrade(client->GetPlayer(), val);
  7514. break;
  7515. }
  7516. case COMMAND_ADD_TRADE_PLAT:
  7517. {
  7518. val = amount * 1000000;
  7519. trade->AddCoinToTrade(client->GetPlayer(), val);
  7520. break;
  7521. }
  7522. default:
  7523. {
  7524. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  7525. break;
  7526. }
  7527. }
  7528. }
  7529. else
  7530. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount.");
  7531. }
  7532. else
  7533. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7534. }
  7535. /*
  7536. Function: Command_TradeRemoveCoin()
  7537. Purpose : Removes coin from trade between players
  7538. Params : Passes "handler" through so we can process copper, silver, gold and plat in the same function
  7539. Dev :
  7540. Example :
  7541. */
  7542. void Commands::Command_TradeRemoveCoin(Client* client, Seperator* sep, int handler)
  7543. {
  7544. PrintSep(sep, "COMMAND_REMOVE_TRADE_{coin type}");
  7545. Trade* trade = client->GetPlayer()->trade;
  7546. if (trade) {
  7547. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7548. int32 amount = atoi(sep->arg[0]);
  7549. int64 val = 0;
  7550. switch (handler) {
  7551. case COMMAND_REMOVE_TRADE_COPPER:
  7552. {
  7553. val = amount;
  7554. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7555. break;
  7556. }
  7557. case COMMAND_REMOVE_TRADE_SILVER:
  7558. {
  7559. val = amount * 100;
  7560. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7561. break;
  7562. }
  7563. case COMMAND_REMOVE_TRADE_GOLD:
  7564. {
  7565. val = amount * 10000;
  7566. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7567. break;
  7568. }
  7569. case COMMAND_REMOVE_TRADE_PLAT:
  7570. {
  7571. val = amount * 1000000;
  7572. trade->RemoveCoinFromTrade(client->GetPlayer(), val);
  7573. break;
  7574. }
  7575. default:
  7576. {
  7577. LogWrite(COMMAND__ERROR, 0, "Command", "No coin type specified in func: '%s', line %u", __FUNCTION__, __LINE__);
  7578. break;
  7579. }
  7580. }
  7581. }
  7582. else
  7583. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid coin amount");
  7584. }
  7585. else
  7586. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7587. }
  7588. /*
  7589. Function: Command_TradeAddItem()
  7590. Purpose : Adds item to trade between players
  7591. Params :
  7592. Dev :
  7593. Example :
  7594. */
  7595. void Commands::Command_TradeAddItem(Client* client, Seperator* sep)
  7596. {
  7597. PrintSep(sep, "COMMAND_ADD_TRADE_ITEM");
  7598. /*
  7599. arg[0] = item index
  7600. arg[1] = slot
  7601. arg[2] = quantity
  7602. */
  7603. if (!client->GetPlayer()->trade) {
  7604. LogWrite(PLAYER__ERROR, 0, "Trade", "Player is not currently trading.");
  7605. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7606. return;
  7607. }
  7608. if (sep && sep->IsSet(0) && sep->IsNumber(0) && sep->IsSet(1) && sep->IsNumber(1) && sep->IsSet(2) && sep->IsNumber(2)) {
  7609. Item* item = 0;
  7610. int32 index = atoi(sep->arg[0]);
  7611. item = client->GetPlayer()->GetPlayerItemList()->GetItemFromIndex(index);
  7612. if (item) {
  7613. int8 result = client->GetPlayer()->trade->AddItemToTrade(client->GetPlayer(), item, atoi(sep->arg[2]), atoi(sep->arg[1]));
  7614. if (result == 1)
  7615. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Item is already being traded.");
  7616. else if (result == 2)
  7617. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade NO-TRADE items.");
  7618. else if (result == 3)
  7619. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade HEIRLOOM items.");
  7620. else if (result == 255)
  7621. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown error trying to add the item to the trade...");
  7622. }
  7623. else {
  7624. LogWrite(PLAYER__ERROR, 0, "Trade", "Unable to get an item for the player (%s) from the index (%u)", client->GetPlayer()->GetName(), index);
  7625. client->Message(CHANNEL_ERROR, "Unable to find item at index %u", index);
  7626. }
  7627. }
  7628. else
  7629. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  7630. }
  7631. /*
  7632. Function: Command_TradeRemoveItem()
  7633. Purpose : Removes item from trade between players
  7634. Params :
  7635. Dev :
  7636. Example :
  7637. */
  7638. void Commands::Command_TradeRemoveItem(Client* client, Seperator* sep)
  7639. {
  7640. PrintSep(sep, "COMMAND_REMOVE_TRADE_ITEM");
  7641. /*
  7642. arg[0] = trade window slot
  7643. */
  7644. Trade* trade = client->GetPlayer()->trade;
  7645. if (trade) {
  7646. if (sep && sep->IsSet(0) && sep->IsNumber(0)) {
  7647. trade->RemoveItemFromTrade(client->GetPlayer(), atoi(sep->arg[0]));
  7648. }
  7649. else
  7650. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Invalid item.");
  7651. }
  7652. else
  7653. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not currently trading.");
  7654. }
  7655. void Commands::Command_TryOn(Client* client, Seperator* sep)
  7656. {
  7657. Item *item = 0;
  7658. sint32 crc;
  7659. if (sep) {
  7660. // 1096+ sends more info so need to do a version check so older clients (SF) still work
  7661. if (client->GetVersion() < 1096) {
  7662. if (sep->arg[1] && sep->IsNumber(1) && sep->arg[2] && sep->IsNumber(2))
  7663. {
  7664. item = master_item_list.GetItem(atoul(sep->arg[1]));
  7665. crc = atol(sep->arg[2]);
  7666. }
  7667. }
  7668. else {
  7669. // From the broker and links in chat
  7670. if (strcmp(sep->arg[0], "crc") == 0) {
  7671. if (sep->IsNumber(2) && sep->IsNumber(3)) {
  7672. item = master_item_list.GetItem(atoul(sep->arg[2]));
  7673. crc = atol(sep->arg[3]);
  7674. }
  7675. }
  7676. // From inventory
  7677. if (strcmp(sep->arg[0], "dbid") == 0) {
  7678. if (sep->IsNumber(2) && sep->IsNumber(4)) {
  7679. item = master_item_list.GetItem(atoul(sep->arg[2]));
  7680. crc = atol(sep->arg[4]);
  7681. }
  7682. }
  7683. }
  7684. if (item)
  7685. client->ShowDressingRoom(item, crc);
  7686. }
  7687. }
  7688. void Commands::Command_JoinChannel(Client * client, Seperator *sep) {
  7689. const char *channel_name, *password = NULL;
  7690. if (sep == NULL || !sep->IsSet(0)) {
  7691. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /joinchannel <channel name> [password]");
  7692. return;
  7693. }
  7694. channel_name = sep->arg[0];
  7695. if (sep->IsSet(1))
  7696. password = sep->arg[1];
  7697. if (!chat.ChannelExists(channel_name) && !chat.CreateChannel(channel_name, password)) {
  7698. client->Message(CHANNEL_COLOR_RED, "Unable to create channel '%s'.", channel_name);
  7699. return;
  7700. }
  7701. if (chat.IsInChannel(client, channel_name)) {
  7702. client->Message(CHANNEL_COLOR_WHITE, "You are already in '%s'.", channel_name);
  7703. return;
  7704. }
  7705. if (chat.HasPassword(channel_name)) {
  7706. if (password == NULL) {
  7707. client->Message(CHANNEL_COLOR_WHITE, "Unable to join '%s': That channel is password protected.", channel_name);
  7708. return;
  7709. }
  7710. if (!chat.PasswordMatches(channel_name, password)) {
  7711. client->Message(CHANNEL_COLOR_WHITE, "Unable to join '%s': The password is not correc.t", channel_name);
  7712. return;
  7713. }
  7714. }
  7715. if (!chat.JoinChannel(client, channel_name))
  7716. client->Message(CHANNEL_COLOR_RED, "There was an internal error preventing you from joining '%s'.", channel_name);
  7717. }
  7718. void Commands::Command_JoinChannelFromLoad(Client * client, Seperator *sep) {
  7719. printf("ScatDebug: Received 'joinfromchannel', using the same function as 'joinchannel' (not sure what the difference is)\n");
  7720. Command_JoinChannel(client, sep);
  7721. }
  7722. void Commands::Command_TellChannel(Client *client, Seperator *sep) {
  7723. if (sep == NULL || !sep->IsSet(0) || !sep->IsSet(1)) {
  7724. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /tellchannel <channel name> <message>");
  7725. PrintSep(sep, "tellchannel");
  7726. return;
  7727. }
  7728. chat.TellChannel(client, sep->arg[0], sep->argplus[1]);
  7729. }
  7730. void Commands::Command_Test(Client* client, EQ2_16BitString* command_parms) {
  7731. Seperator* sep = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  7732. if (sep->IsSet(0)) {
  7733. if (atoi(sep->arg[0]) == 1) {
  7734. PacketStruct* packet2 = configReader.getStruct("WS_SpellGainedMsg", client->GetVersion());
  7735. if (packet2) {
  7736. packet2->setDataByName("spell_type", 2);
  7737. packet2->setDataByName("spell_id", 8308);
  7738. packet2->setDataByName("spell_name", "Sprint");
  7739. packet2->setDataByName("add_silently", 0);
  7740. packet2->setDataByName("tier", 1);
  7741. packet2->setDataByName("blah1", 1);
  7742. packet2->setDataByName("blah2", 1);
  7743. EQ2Packet* outapp = packet2->serialize();
  7744. DumpPacket(outapp);
  7745. client->QueuePacket(outapp);
  7746. safe_delete(packet2);
  7747. }
  7748. }
  7749. else if (atoi(sep->arg[0]) == 2) {
  7750. PacketStruct* packet2 = configReader.getStruct("WS_GuildUpdate", client->GetVersion());
  7751. if (packet2) {
  7752. packet2->setDataByName("guild_name", "Test");
  7753. packet2->setDataByName("guild_motd", "Test MOTD");
  7754. packet2->setDataByName("guild_id", 1234);
  7755. packet2->setDataByName("guild_level", 1);
  7756. packet2->setDataByName("unknown", 2);
  7757. packet2->setDataByName("unknown2", 3);
  7758. packet2->setDataByName("exp_current", 1);
  7759. packet2->setDataByName("exp_to_next_level", 4);
  7760. EQ2Packet* outapp = packet2->serialize();
  7761. DumpPacket(outapp);
  7762. client->QueuePacket(outapp);
  7763. safe_delete(packet2);
  7764. }
  7765. }
  7766. else if (atoi(sep->arg[0]) == 3) {
  7767. PacketStruct* packet2 = configReader.getStruct("WS_JoinGuildNotify", client->GetVersion());
  7768. if (packet2) {
  7769. packet2->setDataByName("guild_id", 1234);
  7770. packet2->setDataByName("character_id", 1);
  7771. packet2->setDataByName("account_id", 2);
  7772. packet2->setDataByName("guild_level", 1);
  7773. packet2->setDataByName("name", "Test");
  7774. packet2->setDataByName("unknown2", 0);
  7775. packet2->setDataByName("unknown3", 1);
  7776. packet2->setDataByName("adventure_class", 6);
  7777. packet2->setDataByName("adventure_level", 7);
  7778. packet2->setDataByName("tradeskill_class", 4);
  7779. packet2->setDataByName("tradeskill_level", 5);
  7780. packet2->setDataByName("rank", 0);
  7781. packet2->setDataByName("member_flags", 2);
  7782. packet2->setDataByName("join_date", 1591112273);
  7783. packet2->setDataByName("guild_status", 2);
  7784. packet2->setDataByName("last_login", 1591132273);
  7785. packet2->setDataByName("recruiter_id", 1);
  7786. packet2->setDataByName("points", 2345);
  7787. packet2->setDataByName("note", "note");
  7788. packet2->setMediumStringByName("officer_note", "O note");
  7789. packet2->setMediumStringByName("zone", "Blah");
  7790. EQ2Packet* outapp = packet2->serialize();
  7791. DumpPacket(outapp);
  7792. client->QueuePacket(outapp);
  7793. safe_delete(packet2);
  7794. }
  7795. }
  7796. else if (atoi(sep->arg[0]) == 5) {
  7797. client->GetPlayer()->GetTarget();
  7798. int16 offset = atoi(sep->arg[2]);
  7799. int32 value1 = atol(sep->arg[4]);
  7800. EQ2Packet* outapp = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion(), offset, value1);
  7801. client->QueuePacket(outapp);
  7802. }
  7803. else if (atoi(sep->arg[0]) == 6) {
  7804. Spawn* spawn = client->GetPlayer()->GetTarget();
  7805. if (!spawn)
  7806. spawn = client->GetPlayer();
  7807. else if (spawn->IsEntity())
  7808. ((Entity*)spawn)->SetSpeed(atof(sep->arg[4]));
  7809. spawn->RunToLocation(atof(sep->arg[1]), atof(sep->arg[2]), atof(sep->arg[3]));
  7810. }
  7811. else if (atoi(sep->arg[0]) == 7) {
  7812. int32 id = 0;
  7813. Spawn* spawn = client->GetCurrentZone()->GetSpawn(7720001);
  7814. if (spawn) {
  7815. spawn->SetX(client->GetPlayer()->GetX() + .5, false);
  7816. spawn->SetY(client->GetPlayer()->GetY(), false);
  7817. spawn->SetZ(client->GetPlayer()->GetZ() + .5, false);
  7818. float heading = client->GetPlayer()->GetHeading() + 180;
  7819. if (heading > 360)
  7820. heading -= 360;
  7821. spawn->SetLevel(5);
  7822. spawn->SetAdventureClass(4);
  7823. spawn->SetHeading(heading, false);
  7824. spawn->SetSpawnOrigX(spawn->GetX());
  7825. spawn->SetSpawnOrigY(spawn->GetY());
  7826. spawn->SetSpawnOrigZ(spawn->GetZ());
  7827. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  7828. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  7829. spawn->appearance.targetable = 1;
  7830. if (spawn->IsNPC() && spawn->GetTotalHP() == 0) {
  7831. spawn->SetTotalHP(spawn->GetLevel() * 15);
  7832. spawn->SetHP(spawn->GetTotalHP());
  7833. }
  7834. if (spawn->GetTotalPower() == 0) {
  7835. spawn->SetTotalPower(spawn->GetLevel() * 15);
  7836. spawn->SetPower(spawn->GetTotalPower());
  7837. }
  7838. int16 offset = atoi(sep->arg[1]);
  7839. int32 value1 = atol(sep->arg[2]);
  7840. sprintf(spawn->appearance.name, "Offset %i", offset);
  7841. EQ2Packet* ret = spawn->spawn_serialize(client->GetPlayer(), client->GetVersion(), offset, value1);
  7842. DumpPacket(ret);
  7843. client->QueuePacket(ret);
  7844. }
  7845. }
  7846. else if (atoi(sep->arg[0]) == 8) {
  7847. int32 id = atoi(sep->arg[1]);
  7848. Spawn* spawn = client->GetCurrentZone()->GetSpawn(id);
  7849. if (spawn) {
  7850. spawn->SetX(client->GetPlayer()->GetX() + .5, false);
  7851. spawn->SetY(client->GetPlayer()->GetY(), false);
  7852. spawn->SetZ(client->GetPlayer()->GetZ() + .5, false);
  7853. float heading = client->GetPlayer()->GetHeading() + 180;
  7854. if (heading > 360)
  7855. heading -= 360;
  7856. spawn->SetLevel(5);
  7857. spawn->SetAdventureClass(4);
  7858. spawn->SetHeading(heading, false);
  7859. spawn->SetSpawnOrigX(spawn->GetX());
  7860. spawn->SetSpawnOrigY(spawn->GetY());
  7861. spawn->SetSpawnOrigZ(spawn->GetZ());
  7862. spawn->SetSpawnOrigHeading(spawn->GetHeading());
  7863. spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  7864. spawn->appearance.targetable = 1;
  7865. if (spawn->IsNPC() && spawn->GetTotalHP() == 0) {
  7866. spawn->SetTotalHP(spawn->GetLevel() * 15);
  7867. spawn->SetHP(spawn->GetTotalHP());
  7868. }
  7869. if (spawn->GetTotalPower() == 0) {
  7870. spawn->SetTotalPower(spawn->GetLevel() * 15);
  7871. spawn->SetPower(spawn->GetTotalPower());
  7872. }
  7873. int16 offset = atoi(sep->arg[2]);
  7874. int16 offset2 = atoi(sep->arg[3]);
  7875. int32 value1 = atol(sep->arg[4]);
  7876. int16 offset3 = 0;
  7877. int16 offset4 = 0;
  7878. int32 value2 = 0;
  7879. if (sep->IsSet(7)) {
  7880. offset3 = atoi(sep->arg[5]);
  7881. offset4 = atoi(sep->arg[6]);
  7882. value2 = atol(sep->arg[7]);
  7883. }
  7884. sprintf(spawn->appearance.name, "Offset %i to %i", offset, offset2);
  7885. EQ2Packet* ret = spawn->spawn_serialize(client->GetPlayer(), client->GetVersion(), offset, value1, offset2, offset3, offset4, value2);
  7886. DumpPacket(ret);
  7887. client->QueuePacket(ret);
  7888. }
  7889. }
  7890. else if (atoi(sep->arg[0]) == 9) {
  7891. Item* item = master_item_list.GetItem(70007);
  7892. EQ2Packet* app = item->serialize(client->GetVersion(), true, client->GetPlayer());
  7893. if (sep->IsSet(2)) {
  7894. int8 offset = atoi(sep->arg[1]);
  7895. uchar* ptr2 = app->pBuffer;
  7896. ptr2 += offset;
  7897. if (sep->IsNumber(2)) {
  7898. int32 value1 = atol(sep->arg[2]);
  7899. if (value1 > 0xFFFF)
  7900. memcpy(ptr2, (uchar*)&value1, 4);
  7901. else if (value1 > 0xFF)
  7902. memcpy(ptr2, (uchar*)&value1, 2);
  7903. else
  7904. memcpy(ptr2, (uchar*)&value1, 1);
  7905. }
  7906. else {
  7907. int8 len = strlen(sep->arg[2]);
  7908. memcpy(ptr2, (uchar*)&len, 1);
  7909. ptr2 += 1;
  7910. memcpy(ptr2, sep->arg[2], len);
  7911. }
  7912. }
  7913. if (sep->IsSet(4)) {
  7914. int8 offset = atoi(sep->arg[3]);
  7915. uchar* ptr2 = app->pBuffer;
  7916. ptr2 += offset;
  7917. if (sep->IsNumber(4)) {
  7918. int32 value1 = atol(sep->arg[4]);
  7919. if (value1 > 0xFFFF)
  7920. memcpy(ptr2, (uchar*)&value1, 4);
  7921. else if (value1 > 0xFF)
  7922. memcpy(ptr2, (uchar*)&value1, 2);
  7923. else
  7924. memcpy(ptr2, (uchar*)&value1, 1);
  7925. }
  7926. else {
  7927. int8 len = strlen(sep->arg[4]);
  7928. memcpy(ptr2, (uchar*)&len, 1);
  7929. ptr2 += 1;
  7930. memcpy(ptr2, sep->arg[4], len);
  7931. }
  7932. }
  7933. DumpPacket(app);
  7934. client->QueuePacket(app);
  7935. }
  7936. else if (atoi(sep->arg[0]) == 10) {
  7937. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalUpdate", client->GetVersion());
  7938. if (packet2) {
  7939. packet2->setArrayLengthByName("num_quests", 1);
  7940. packet2->setArrayDataByName("active", 1);
  7941. packet2->setArrayDataByName("name", "Archetype Selection");
  7942. packet2->setArrayDataByName("quest_type", "Hallmark");
  7943. packet2->setArrayDataByName("quest_zone", "Hallmark");
  7944. packet2->setArrayDataByName("journal_updated", 1);
  7945. packet2->setArrayDataByName("quest_id", 5);
  7946. packet2->setArrayDataByName("day", 19);
  7947. packet2->setArrayDataByName("month", 6);
  7948. packet2->setArrayDataByName("year", 20);
  7949. packet2->setArrayDataByName("level", 2);
  7950. packet2->setArrayDataByName("encounter_level", 4);
  7951. packet2->setArrayDataByName("difficulty", 3);
  7952. packet2->setArrayDataByName("visible", 1);
  7953. packet2->setDataByName("visible_quest_id", 5);
  7954. packet2->setDataByName("player_crc", 2900677088);
  7955. packet2->setDataByName("player_name", "LethalEncounter");
  7956. EQ2Packet* app = packet2->serialize();
  7957. if (sep->IsSet(2)) {
  7958. int8 offset = atoi(sep->arg[1]);
  7959. uchar* ptr2 = app->pBuffer;
  7960. ptr2 += offset;
  7961. if (sep->IsNumber(2)) {
  7962. int32 value1 = atol(sep->arg[2]);
  7963. if (value1 > 0xFFFF)
  7964. memcpy(ptr2, (uchar*)&value1, 4);
  7965. else if (value1 > 0xFF)
  7966. memcpy(ptr2, (uchar*)&value1, 2);
  7967. else
  7968. memcpy(ptr2, (uchar*)&value1, 1);
  7969. }
  7970. else {
  7971. int8 len = strlen(sep->arg[2]);
  7972. memcpy(ptr2, (uchar*)&len, 1);
  7973. ptr2 += 1;
  7974. memcpy(ptr2, sep->arg[2], len);
  7975. }
  7976. }
  7977. DumpPacket(app);
  7978. client->QueuePacket(app);
  7979. safe_delete(packet2);
  7980. }
  7981. }
  7982. else if (atoi(sep->arg[0]) == 11) {
  7983. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalReply", client->GetVersion());
  7984. if (packet2) {
  7985. packet2->setDataByName("quest_id", 5);
  7986. packet2->setDataByName("player_crc", 2900677088);
  7987. packet2->setDataByName("name", "Archetype Selection");
  7988. packet2->setDataByName("description", "I have reported my profession to Garven Tralk");
  7989. packet2->setDataByName("type", "Hallmark");
  7990. packet2->setDataByName("complete_header", "To complete this quest, I must do the following tasks:");
  7991. packet2->setDataByName("day", 19);
  7992. packet2->setDataByName("month", 6);
  7993. packet2->setDataByName("year", 20);
  7994. packet2->setDataByName("level", 2);
  7995. packet2->setDataByName("encounter_level", 4);
  7996. packet2->setDataByName("difficulty", 3);
  7997. packet2->setDataByName("time_obtained", Timer::GetUnixTimeStamp());
  7998. packet2->setDataByName("timer_start", Timer::GetUnixTimeStamp());
  7999. packet2->setDataByName("timer_duration", 300);
  8000. packet2->setDataByName("timer_running", 1);
  8001. packet2->setArrayLengthByName("task_groups_completed", 0);
  8002. packet2->setArrayLengthByName("num_task_groups", 1);
  8003. packet2->setArrayDataByName("task_group", "I need to talk to Garven Tralk");
  8004. packet2->setSubArrayLengthByName("num_tasks", 1);
  8005. packet2->setSubArrayDataByName("task", "I need to talk to Garven Tralk");
  8006. packet2->setSubArrayLengthByName("num_updates", 1);
  8007. packet2->setSubArrayDataByName("update_currentval", 0);
  8008. packet2->setSubArrayDataByName("update_maxval", 1);
  8009. packet2->setSubArrayDataByName("icon", 11);
  8010. packet2->setArrayDataByName("waypoint", 0xFFFFFFFF);
  8011. packet2->setDataByName("journal_updated", 1);
  8012. EQ2Packet* app = packet2->serialize();
  8013. if (sep->IsSet(2)) {
  8014. int16 offset = atoi(sep->arg[1]);
  8015. uchar* ptr2 = app->pBuffer;
  8016. ptr2 += offset;
  8017. if (sep->IsNumber(2)) {
  8018. int32 value1 = atol(sep->arg[2]);
  8019. if (value1 > 0xFFFF)
  8020. memcpy(ptr2, (uchar*)&value1, 4);
  8021. else if (value1 > 0xFF)
  8022. memcpy(ptr2, (uchar*)&value1, 2);
  8023. else
  8024. memcpy(ptr2, (uchar*)&value1, 1);
  8025. }
  8026. else {
  8027. int16 len = strlen(sep->arg[2]);
  8028. memcpy(ptr2, (uchar*)&len, 2);
  8029. ptr2 += 2;
  8030. memcpy(ptr2, sep->arg[2], len);
  8031. }
  8032. }
  8033. DumpPacket(app);
  8034. client->QueuePacket(app);
  8035. safe_delete(packet2);
  8036. }
  8037. }
  8038. else if (atoi(sep->arg[0]) == 12) {
  8039. PacketStruct* packet2 = configReader.getStruct("WS_QuestJournalReply", client->GetVersion());
  8040. if (packet2) {
  8041. packet2->setDataByName("quest_id", 5);
  8042. packet2->setDataByName("player_crc", 2900677088);
  8043. packet2->setDataByName("name", "Archetype Selection");
  8044. packet2->setDataByName("description", "I have reported my profession to Garven Tralk.");
  8045. packet2->setDataByName("type", "Hallmark");
  8046. packet2->setDataByName("complete_header", "To complete this quest, I must do the following tasks:");
  8047. packet2->setDataByName("day", 19);
  8048. packet2->setDataByName("month", 6);
  8049. packet2->setDataByName("year", 20);
  8050. packet2->setDataByName("level", 2);
  8051. packet2->setDataByName("encounter_level", 4);
  8052. packet2->setDataByName("difficulty", 3);
  8053. packet2->setDataByName("time_obtained", Timer::GetUnixTimeStamp());
  8054. packet2->setDataByName("timer_start", Timer::GetUnixTimeStamp());
  8055. packet2->setDataByName("timer_duration", 300);
  8056. packet2->setDataByName("timer_running", 1);
  8057. packet2->setArrayLengthByName("task_groups_completed", 0);
  8058. packet2->setArrayLengthByName("num_task_groups", 1);
  8059. packet2->setArrayDataByName("task_group", "I need to talk to Garven Tralk");
  8060. packet2->setSubArrayLengthByName("num_tasks", 1);
  8061. packet2->setSubArrayDataByName("task", "I need to talk to Garven Tralk");
  8062. packet2->setSubArrayLengthByName("num_updates", 1);
  8063. packet2->setSubArrayDataByName("update_currentval", 0);
  8064. packet2->setSubArrayDataByName("update_maxval", 1);
  8065. packet2->setSubArrayDataByName("icon", 11);
  8066. packet2->setArrayDataByName("waypoint", 0xFFFFFFFF);
  8067. packet2->setDataByName("journal_updated", 1);
  8068. packet2->setSubstructDataByName("reward_data", "unknown1", 255);
  8069. packet2->setSubstructDataByName("reward_data", "reward", "Quest Reward!");
  8070. packet2->setSubstructDataByName("reward_data", "unknown2", 0x3f);
  8071. packet2->setSubstructDataByName("reward_data", "coin", 150);
  8072. packet2->setSubstructDataByName("reward_data", "status_points", 5);
  8073. packet2->setSubstructDataByName("reward_data", "exp_bonus", 10);
  8074. packet2->setSubstructArrayLengthByName("reward_data", "num_rewards", 1);
  8075. packet2->setSubstructArrayDataByName("reward_data", "reward_id", 123);
  8076. Item* item = master_item_list.GetItem(152755);
  8077. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8078. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  8079. /*packet2->setSubstructDataByName("item", "unique_id", 567);
  8080. packet2->setSubstructDataByName("item", "broker_item_id", 0xFFFFFFFFFFFFFFFF);
  8081. packet2->setSubstructDataByName("item", "icon", 0xe7);
  8082. packet2->setSubstructDataByName("item", "tier", 4);
  8083. packet2->setSubstructDataByName("item", "flags", 0x60);
  8084. packet2->setSubstructArrayLengthByName("item", "stat_count", 1);
  8085. packet2->setSubstructDataByName("item", "stat_type", 1);
  8086. packet2->setSubstructDataByName("item", "stat_subtype", 2);
  8087. packet2->setSubstructDataByName("item", "value", 3);
  8088. packet2->setSubstructDataByName("item", "condition", 100);
  8089. packet2->setSubstructDataByName("item", "weight", 1);
  8090. packet2->setSubstructDataByName("item", "skill_req1", 0xacafa99e);
  8091. packet2->setSubstructDataByName("item", "skill_req2", 0xacafa99e);
  8092. packet2->setSubstructDataByName("item", "skill_min", 1);
  8093. packet2->setSubstructArrayLengthByName("item", "class_count", 3);
  8094. packet2->setSubstructDataByName("item", "adventure_class", 1);
  8095. packet2->setSubstructDataByName("item", "adventure_class", 11, 0, 1);
  8096. packet2->setSubstructDataByName("item", "adventure_class", 0x1f, 0, 2);
  8097. packet2->setSubstructDataByName("item", "tradeskill_class", 255);
  8098. packet2->setSubstructDataByName("item", "tradeskill_class", 255, 0, 1);
  8099. packet2->setSubstructDataByName("item", "tradeskill_class", 255, 0, 2);
  8100. packet2->setSubstructDataByName("item", "level", 0x1e);
  8101. packet2->setSubstructDataByName("item", "level", 100, 0, 1);
  8102. packet2->setSubstructDataByName("item", "level", 100, 0, 2);
  8103. packet2->setSubstructDataByName("item_footer", "name", "Footman Gloves");*/
  8104. //packet2->PrintPacket();
  8105. EQ2Packet* app = packet2->serialize();
  8106. if (sep->IsSet(2)) {
  8107. int16 offset = atoi(sep->arg[1]);
  8108. uchar* ptr2 = app->pBuffer;
  8109. ptr2 += offset;
  8110. if (sep->IsNumber(2)) {
  8111. int32 value1 = atol(sep->arg[2]);
  8112. if (value1 > 0xFFFF)
  8113. memcpy(ptr2, (uchar*)&value1, 4);
  8114. else if (value1 > 0xFF)
  8115. memcpy(ptr2, (uchar*)&value1, 2);
  8116. else
  8117. memcpy(ptr2, (uchar*)&value1, 1);
  8118. }
  8119. else {
  8120. int16 len = strlen(sep->arg[2]);
  8121. memcpy(ptr2, (uchar*)&len, 2);
  8122. ptr2 += 2;
  8123. memcpy(ptr2, sep->arg[2], len);
  8124. }
  8125. }
  8126. DumpPacket(app);
  8127. client->QueuePacket(app);
  8128. safe_delete(packet2);
  8129. }
  8130. }
  8131. else if (atoi(sep->arg[0]) == 13) {
  8132. PacketStruct* packet2 = configReader.getStruct("WS_OnScreenMsg", client->GetVersion());
  8133. if (packet2 && sep->IsSet(7)) {
  8134. packet2->setDataByName("unknown", atoi(sep->arg[1]));
  8135. char blah[128];
  8136. sprintf(blah, "\\#6EFF6EYou get better at \12\\#C8FFC8%s\\#6EFF6E! (7/15)", sep->arg[2]);
  8137. packet2->setDataByName("text", blah);
  8138. packet2->setDataByName("message_type", sep->arg[3]);
  8139. packet2->setDataByName("size", atof(sep->arg[4]));
  8140. packet2->setDataByName("red", atoi(sep->arg[5]));
  8141. packet2->setDataByName("green", atoi(sep->arg[6]));
  8142. packet2->setDataByName("blue", atoi(sep->arg[7]));
  8143. EQ2Packet* app = packet2->serialize();
  8144. DumpPacket(app);
  8145. client->QueuePacket(app);
  8146. safe_delete(packet2);
  8147. }
  8148. }
  8149. else if (atoi(sep->arg[0]) == 14) {
  8150. PacketStruct* packet2 = configReader.getStruct("WS_InstructionWindow", client->GetVersion());
  8151. if (packet2 && sep->IsSet(3)) {
  8152. packet2->setDataByName("open_seconds_min", atof(sep->arg[1]));
  8153. packet2->setDataByName("open_seconds_max", atof(sep->arg[2]));
  8154. packet2->setDataByName("voice_sync", atoi(sep->arg[3]));
  8155. 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.");
  8156. packet2->setDataByName("voice", "voiceover/english/narrator/boat_06p_tutorial02/narrator_001_63779ca0.mp3");
  8157. packet2->setArrayLengthByName("num_goals", 1);
  8158. //packet2->setArrayDataByName("goal_text", )
  8159. packet2->setSubArrayLengthByName("num_tasks", 1);
  8160. packet2->setSubArrayDataByName("task_text", "continue");
  8161. packet2->setDataByName("complete_sound", "click");
  8162. packet2->setDataByName("signal", "introduction");
  8163. packet2->setDataByName("voice_key1", 0xcda65173);
  8164. packet2->setDataByName("voice_key2", 0x984bfc6d);
  8165. EQ2Packet* app = packet2->serialize();
  8166. DumpPacket(app);
  8167. client->QueuePacket(app);
  8168. safe_delete(packet2);
  8169. packet2 = configReader.getStruct("WS_ShowWindow", client->GetVersion());
  8170. packet2->setDataByName("window", "MainHUD.StartMenu");
  8171. packet2->setDataByName("show", 1);
  8172. app = packet2->serialize();
  8173. DumpPacket(app);
  8174. client->QueuePacket(app);
  8175. safe_delete(packet2);
  8176. packet2 = configReader.getStruct("WS_FlashWindow", client->GetVersion());
  8177. packet2->setDataByName("window", "MainHUD.StartMenu.help");
  8178. packet2->setDataByName("flash_seconds", 10);
  8179. app = packet2->serialize();
  8180. DumpPacket(app);
  8181. client->QueuePacket(app);
  8182. safe_delete(packet2);
  8183. }
  8184. }
  8185. else if (atoi(sep->arg[0]) == 15) {
  8186. PacketStruct* packet2 = configReader.getStruct("WS_UpdateLoot", client->GetVersion());
  8187. if (packet2) {
  8188. packet2->setArrayLengthByName("loot_count", 1);
  8189. packet2->setArrayDataByName("name", "Test");
  8190. packet2->setArrayDataByName("item_id", 1234);
  8191. packet2->setArrayDataByName("count", 1);
  8192. packet2->setArrayDataByName("icon", 258);
  8193. packet2->setArrayDataByName("ability_id", 0xFFFFFFFF);
  8194. Spawn* spawn = client->GetPlayer()->GetTarget();
  8195. if (spawn)
  8196. packet2->setDataByName("object_id", client->GetPlayer()->GetIDWithPlayerSpawn(spawn));
  8197. packet2->setDataByName("unknown3", 1);
  8198. packet2->setDataByName("unknown4", 1);
  8199. packet2->setDataByName("unknown5", 60);
  8200. EQ2Packet* app = packet2->serialize();
  8201. DumpPacket(app);
  8202. client->QueuePacket(app);
  8203. safe_delete(packet2);
  8204. }
  8205. }
  8206. else if (atoi(sep->arg[0]) == 16 && sep->IsNumber(1)) {
  8207. char blah[32];
  8208. sprintf(blah, "Testing: %i", atoi(sep->arg[1]));
  8209. client->SimpleMessage(atoi(sep->arg[1]), blah);
  8210. }
  8211. else if (atoi(sep->arg[0]) == 17 && sep->IsNumber(2)) {
  8212. if (sep->IsSet(2)) {
  8213. int16 offset = atoi(sep->arg[1]);
  8214. if (sep->IsNumber(2)) {
  8215. int32 value1 = atol(sep->arg[2]);
  8216. client->QueuePacket(client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion(), offset, value1));
  8217. cout << "Sent" << endl;
  8218. }
  8219. }
  8220. }
  8221. else if (atoi(sep->arg[0]) == 18) {
  8222. PacketStruct* packet2 = configReader.getStruct("WS_QuestRewardPackMsg", client->GetVersion());
  8223. if (packet2) {
  8224. packet2->setSubstructDataByName("reward_data", "unknown1", 255);
  8225. packet2->setSubstructDataByName("reward_data", "reward", "Quest Reward!");
  8226. packet2->setSubstructDataByName("reward_data", "coin", 150);
  8227. packet2->setSubstructDataByName("reward_data", "status_points", 5);
  8228. packet2->setSubstructDataByName("reward_data", "exp_bonus", 10);
  8229. packet2->setSubstructArrayLengthByName("reward_data", "num_rewards", 4);
  8230. Item* item = new Item(master_item_list.GetItem(36212));
  8231. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8232. item->stack_count = 20;
  8233. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  8234. safe_delete(item);
  8235. item = new Item(master_item_list.GetItem(36685));
  8236. item->stack_count = 20;
  8237. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8238. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 1, 0, -1);
  8239. safe_delete(item);
  8240. item = master_item_list.GetItem(1414);
  8241. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8242. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 2, 0, -1);
  8243. item = master_item_list.GetItem(75057);
  8244. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8245. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 3, 0, -1);
  8246. EQ2Packet* app = packet2->serialize();
  8247. if (sep->IsSet(2)) {
  8248. int16 offset = atoi(sep->arg[1]);
  8249. uchar* ptr2 = app->pBuffer;
  8250. ptr2 += offset;
  8251. if (sep->IsNumber(2)) {
  8252. int32 value1 = atol(sep->arg[2]);
  8253. if (value1 > 0xFFFF)
  8254. memcpy(ptr2, (uchar*)&value1, 4);
  8255. else if (value1 > 0xFF)
  8256. memcpy(ptr2, (uchar*)&value1, 2);
  8257. else
  8258. memcpy(ptr2, (uchar*)&value1, 1);
  8259. }
  8260. else {
  8261. int16 len = strlen(sep->arg[2]);
  8262. memcpy(ptr2, (uchar*)&len, 2);
  8263. ptr2 += 2;
  8264. memcpy(ptr2, sep->arg[2], len);
  8265. }
  8266. }
  8267. DumpPacket(app);
  8268. client->QueuePacket(app);
  8269. safe_delete(packet2);
  8270. }
  8271. }
  8272. else if (atoi(sep->arg[0]) == 19) {
  8273. PacketStruct* packet2 = configReader.getStruct("WS_UpdateLoot", client->GetVersion());
  8274. Spawn* spawn = client->GetPlayer()->GetTarget();
  8275. if (packet2 && spawn) {
  8276. Item* item = master_item_list.GetItem(130053);
  8277. packet2->setArrayLengthByName("loot_count", 1);
  8278. packet2->setArrayDataByName("loot_id", item->details.item_id);
  8279. packet2->setArrayDataByName("unknown2", 1);
  8280. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, 2, true);
  8281. packet2->setDataByName("display", 1);
  8282. packet2->setDataByName("unknown2b", 1);
  8283. packet2->setDataByName("unknown3", 0x3c);
  8284. packet2->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(spawn));
  8285. packet2->PrintPacket();
  8286. EQ2Packet* app = packet2->serialize();
  8287. if (sep->IsSet(2)) {
  8288. int16 offset = atoi(sep->arg[1]);
  8289. int16 offset2 = 0;
  8290. int32 value1 = 0;
  8291. if (sep->IsSet(3)) {
  8292. offset2 = atoi(sep->arg[2]);
  8293. value1 = atol(sep->arg[3]);
  8294. }
  8295. else
  8296. value1 = atol(sep->arg[2]);
  8297. int16 offset3 = 0;
  8298. int16 offset4 = 0;
  8299. int32 value2 = 0;
  8300. if (sep->IsSet(6)) {
  8301. offset3 = atoi(sep->arg[4]);
  8302. offset4 = atoi(sep->arg[5]);
  8303. value2 = atol(sep->arg[6]);
  8304. }
  8305. offset--;
  8306. if (offset2 > 0 && offset2 >= offset) {
  8307. offset2--;
  8308. uchar* ptr2 = app->pBuffer;
  8309. ptr2 += offset;
  8310. for (int i = offset; i <= offset2; i++) {
  8311. if (value1 > 0xFFFF) {
  8312. memcpy(ptr2, (uchar*)&value1, 4);
  8313. i += 3;
  8314. ptr2 += 3;
  8315. }
  8316. else if (value1 > 0xFF) {
  8317. memcpy(ptr2, (uchar*)&value1, 2);
  8318. i++;
  8319. ptr2++;
  8320. }
  8321. else
  8322. memcpy(ptr2, (uchar*)&value1, 1);
  8323. ptr2++;
  8324. }
  8325. }
  8326. if (offset4 > 0 && offset4 >= offset3) {
  8327. offset3--;
  8328. offset4--;
  8329. uchar* ptr2 = app->pBuffer;
  8330. ptr2 += offset3;
  8331. for (int i = offset3; i <= offset4; i++) {
  8332. if (value2 > 0xFFFF) {
  8333. memcpy(ptr2, (uchar*)&value2, 4);
  8334. i += 3;
  8335. ptr2 += 3;
  8336. }
  8337. else if (value2 > 0xFF) {
  8338. memcpy(ptr2, (uchar*)&value2, 2);
  8339. i++;
  8340. ptr2++;
  8341. }
  8342. else
  8343. memcpy(ptr2, (uchar*)&value2, 1);
  8344. ptr2++;
  8345. }
  8346. }
  8347. }
  8348. DumpPacket(app);
  8349. client->QueuePacket(app);
  8350. safe_delete(packet2);
  8351. }
  8352. }
  8353. else if (atoi(sep->arg[0]) == 21) {
  8354. PacketStruct* packet2 = configReader.getStruct("WS_OfferQuest", client->GetVersion());
  8355. if (packet2) {
  8356. packet2->setDataByName("unknown0", 255);
  8357. packet2->setDataByName("reward", "New Quest");
  8358. packet2->setDataByName("title", "Title");
  8359. packet2->setDataByName("description", "description");
  8360. packet2->setDataByName("quest_difficulty", 3);
  8361. packet2->setDataByName("unknown1", 5);
  8362. packet2->setDataByName("level", 3);
  8363. packet2->setDataByName("coin", 150);
  8364. packet2->setDataByName("status_points", 5);
  8365. packet2->setDataByName("exp_bonus", 10);
  8366. packet2->setArrayLengthByName("num_rewards", 1);
  8367. Item* item = new Item(master_item_list.GetItem(36212));
  8368. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8369. item->stack_count = 20;
  8370. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  8371. safe_delete(item);
  8372. char accept[35] = { 0 };
  8373. char decline[35] = { 0 };
  8374. sprintf(accept, "q_accept_pending_quest %u", 0);
  8375. sprintf(decline, "q_deny_pending_quest %u", 0);
  8376. packet2->setDataByName("accept_command", accept);
  8377. packet2->setDataByName("decline_command", decline);
  8378. EQ2Packet* app = packet2->serialize();
  8379. if (sep->IsSet(2)) {
  8380. int16 offset = atoi(sep->arg[1]);
  8381. uchar* ptr2 = app->pBuffer;
  8382. ptr2 += offset;
  8383. if (sep->IsNumber(2)) {
  8384. int32 value1 = atol(sep->arg[2]);
  8385. if (value1 > 0xFFFF)
  8386. memcpy(ptr2, (uchar*)&value1, 4);
  8387. else if (value1 > 0xFF)
  8388. memcpy(ptr2, (uchar*)&value1, 2);
  8389. else
  8390. memcpy(ptr2, (uchar*)&value1, 1);
  8391. }
  8392. DumpPacket(app);
  8393. client->QueuePacket(app);
  8394. safe_delete(packet2);
  8395. }
  8396. }
  8397. }
  8398. else if (atoi(sep->arg[0]) == 22) { //same as 21, but 8bit string
  8399. PacketStruct* packet2 = configReader.getStruct("WS_OfferQuest", client->GetVersion());
  8400. if (packet2) {
  8401. packet2->setDataByName("unknown0", 255);
  8402. packet2->setDataByName("reward", "New Quest");
  8403. packet2->setDataByName("title", "Title");
  8404. packet2->setDataByName("description", "description");
  8405. packet2->setDataByName("quest_difficulty", 3);
  8406. packet2->setDataByName("unknown1", 5);
  8407. packet2->setDataByName("level", 3);
  8408. packet2->setDataByName("coin", 150);
  8409. packet2->setDataByName("status_points", 5);
  8410. packet2->setDataByName("exp_bonus", 10);
  8411. packet2->setArrayLengthByName("num_rewards", 1);
  8412. Item* item = new Item(master_item_list.GetItem(36212));
  8413. packet2->setArrayDataByName("reward_id", item->details.item_id);
  8414. item->stack_count = 20;
  8415. packet2->setItemArrayDataByName("item", item, client->GetPlayer(), 0, 0, -1);
  8416. safe_delete(item);
  8417. char accept[35] = { 0 };
  8418. char decline[35] = { 0 };
  8419. sprintf(accept, "q_accept_pending_quest %u", 0);
  8420. sprintf(decline, "q_deny_pending_quest %u", 0);
  8421. packet2->setDataByName("accept_command", accept);
  8422. packet2->setDataByName("decline_command", decline);
  8423. EQ2Packet* app = packet2->serialize();
  8424. if (sep->IsSet(2)) {
  8425. int16 offset = atoi(sep->arg[1]);
  8426. uchar* ptr2 = app->pBuffer;
  8427. ptr2 += offset;
  8428. if (sep->IsNumber(2)) {
  8429. int32 value1 = atol(sep->arg[2]);
  8430. if (value1 > 0xFFFF)
  8431. memcpy(ptr2, (uchar*)&value1, 4);
  8432. else if (value1 > 0xFF)
  8433. memcpy(ptr2, (uchar*)&value1, 2);
  8434. else
  8435. memcpy(ptr2, (uchar*)&value1, 1);
  8436. }
  8437. else {
  8438. int8 len = strlen(sep->arg[2]);
  8439. memcpy(ptr2, (uchar*)&len, 1);
  8440. ptr2 += 1;
  8441. memcpy(ptr2, sep->arg[2], len);
  8442. }
  8443. }
  8444. DumpPacket(app);
  8445. client->QueuePacket(app);
  8446. safe_delete(packet2);
  8447. }
  8448. }
  8449. else if (atoi(sep->arg[0]) == 23) {
  8450. if (client->GetPlayer()->GetTarget()) {
  8451. PacketStruct* packet2 = configReader.getStruct("WS_UpdateMerchant", client->GetVersion());
  8452. if (packet2) {
  8453. Spawn* target = client->GetPlayer()->GetTarget();
  8454. packet2->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(target));
  8455. Item* item = new Item(master_item_list.GetItem(12565));
  8456. int8 i = 0;
  8457. packet2->setArrayLengthByName("num_items", 1);
  8458. packet2->setArrayDataByName("item_name", item->name.c_str(), i);
  8459. packet2->setArrayDataByName("item_id", item->details.item_id, i);
  8460. packet2->setArrayDataByName("stack_size", item->stack_count, i);
  8461. packet2->setArrayDataByName("icon", item->details.icon, i);
  8462. int8 tmp_level = 0;
  8463. if (item->generic_info.adventure_default_level > 0)
  8464. tmp_level = item->generic_info.adventure_default_level;
  8465. else
  8466. tmp_level = item->generic_info.tradeskill_default_level;
  8467. packet2->setArrayDataByName("level", tmp_level, i);
  8468. packet2->setArrayDataByName("tier", item->details.tier, i);
  8469. packet2->setArrayDataByName("item_id2", item->details.item_id, i);
  8470. int8 item_difficulty = client->GetPlayer()->GetArrowColor(tmp_level);
  8471. if (item_difficulty != ARROW_COLOR_WHITE && item_difficulty != ARROW_COLOR_RED && item_difficulty != ARROW_COLOR_GRAY)
  8472. item_difficulty = ARROW_COLOR_WHITE;
  8473. item_difficulty -= 6;
  8474. if (item_difficulty < 0)
  8475. item_difficulty *= -1;
  8476. packet2->setArrayDataByName("item_difficulty", item_difficulty, i);
  8477. packet2->setArrayDataByName("quantity", 2, i);
  8478. packet2->setArrayDataByName("unknown5", 255, i);
  8479. packet2->setArrayDataByName("stack_size2", item->stack_count, i);
  8480. packet2->setArrayDataByName("description", item->description.c_str(), i);
  8481. packet2->setDataByName("type", 2);
  8482. EQ2Packet* app = packet2->serialize();
  8483. if (sep->IsSet(2)) {
  8484. int16 offset = atoi(sep->arg[1]);
  8485. uchar* ptr2 = app->pBuffer;
  8486. ptr2 += offset;
  8487. if (sep->IsNumber(2)) {
  8488. int32 value1 = atol(sep->arg[2]);
  8489. if (value1 > 0xFFFF)
  8490. memcpy(ptr2, (uchar*)&value1, 4);
  8491. else if (value1 > 0xFF)
  8492. memcpy(ptr2, (uchar*)&value1, 2);
  8493. else
  8494. memcpy(ptr2, (uchar*)&value1, 1);
  8495. }
  8496. else {
  8497. int8 len = strlen(sep->arg[2]);
  8498. memcpy(ptr2, (uchar*)&len, 1);
  8499. ptr2 += 1;
  8500. memcpy(ptr2, sep->arg[2], len);
  8501. }
  8502. }
  8503. DumpPacket(app);
  8504. client->QueuePacket(app);
  8505. safe_delete(packet2);
  8506. }
  8507. }
  8508. }
  8509. else if (atoi(sep->arg[0]) == 24) {
  8510. PacketStruct* packet2 = configReader.getStruct("WS_EnableGameEvent", client->GetVersion());
  8511. if (packet2) {
  8512. if (sep->IsSet(2)) {
  8513. packet2->setDataByName("event_name", sep->arg[1]);
  8514. packet2->setDataByName("enabled", atoi(sep->arg[2]));
  8515. EQ2Packet* app = packet2->serialize();
  8516. DumpPacket(app);
  8517. client->QueuePacket(app);
  8518. safe_delete(packet2);
  8519. }
  8520. }
  8521. }
  8522. else if (atoi(sep->arg[0]) == 25) {
  8523. if (sep->IsSet(1)) {
  8524. Widget* new_spawn = new Widget();
  8525. int32 id = atoul(sep->arg[1]);
  8526. new_spawn->SetWidgetID(id);
  8527. EQ2Packet* ret = new_spawn->serialize(client->GetPlayer(), client->GetVersion());
  8528. client->QueuePacket(ret);
  8529. int8 index = client->GetPlayer()->GetIndexForSpawn(new_spawn);
  8530. PacketStruct* packet2 = configReader.getStruct("WS_DestroyGhostCmd", client->GetVersion());
  8531. if (packet2) {
  8532. packet2->setDataByName("spawn_index", index);
  8533. packet2->setDataByName("delete", 1);
  8534. EQ2Packet* app = packet2->serialize();
  8535. client->QueuePacket(app);
  8536. safe_delete(packet2);
  8537. }
  8538. }
  8539. }
  8540. else if (atoi(sep->arg[0]) == 26) {
  8541. if (sep->IsSet(4)) {
  8542. Widget* new_spawn = new Widget();
  8543. int32 id = atoul(sep->arg[1]);
  8544. new_spawn->SetWidgetID(id);
  8545. float x = atof(sep->arg[2]);
  8546. float y = atof(sep->arg[3]);
  8547. float z = atof(sep->arg[4]);
  8548. new_spawn->appearance.pos.grid_id = client->GetPlayer()->appearance.pos.grid_id;
  8549. new_spawn->SetWidgetX(x);
  8550. new_spawn->SetWidgetY(y);
  8551. new_spawn->SetWidgetZ(z);
  8552. new_spawn->SetX(x);
  8553. new_spawn->SetY(y);
  8554. new_spawn->SetZ(z);
  8555. EQ2Packet* ret = new_spawn->serialize(client->GetPlayer(), client->GetVersion());
  8556. client->QueuePacket(ret);
  8557. }
  8558. }
  8559. else if (atoi(sep->arg[0]) == 27) {
  8560. Spawn* target = client->GetPlayer()->GetTarget();
  8561. PacketStruct* packet2 = configReader.getStruct("WS_HearSimpleDamage", client->GetVersion());
  8562. if (packet2 && target && sep->IsSet(2)) {
  8563. packet2->setSubstructDataByName("header", "defender", client->GetPlayer()->GetIDWithPlayerSpawn(target));
  8564. packet2->setSubstructDataByName("header", "defender_proxy", client->GetPlayer()->GetIDWithPlayerSpawn(target));
  8565. packet2->setSubstructDataByName("header", "attacker", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()));
  8566. packet2->setArrayLengthByName("num_dmg", 1);
  8567. packet2->setArrayDataByName("damage_type", atoi(sep->arg[1]));
  8568. packet2->setArrayDataByName("damage", atoi(sep->arg[2]));
  8569. packet2->setDataByName("spell", 1);
  8570. packet2->setDataByName("spell_name", "Testing");
  8571. EQ2Packet* app = packet2->serialize();
  8572. if (sep->IsSet(4)) {
  8573. int16 offset = atoi(sep->arg[3]);
  8574. uchar* ptr2 = app->pBuffer;
  8575. ptr2 += offset;
  8576. if (sep->IsNumber(4)) {
  8577. int32 value1 = atol(sep->arg[4]);
  8578. if (value1 > 0xFFFF)
  8579. memcpy(ptr2, (uchar*)&value1, 4);
  8580. else if (value1 > 0xFF)
  8581. memcpy(ptr2, (uchar*)&value1, 2);
  8582. else
  8583. memcpy(ptr2, (uchar*)&value1, 1);
  8584. }
  8585. else {
  8586. int8 len = strlen(sep->arg[4]);
  8587. memcpy(ptr2, (uchar*)&len, 1);
  8588. ptr2 += 1;
  8589. memcpy(ptr2, sep->arg[4], len);
  8590. }
  8591. }
  8592. if (sep->IsSet(6)) {
  8593. int16 offset = atoi(sep->arg[5]);
  8594. uchar* ptr2 = app->pBuffer;
  8595. ptr2 += offset;
  8596. if (sep->IsNumber(6)) {
  8597. int32 value1 = atol(sep->arg[6]);
  8598. if (value1 > 0xFFFF)
  8599. memcpy(ptr2, (uchar*)&value1, 4);
  8600. else if (value1 > 0xFF)
  8601. memcpy(ptr2, (uchar*)&value1, 2);
  8602. else
  8603. memcpy(ptr2, (uchar*)&value1, 1);
  8604. }
  8605. else {
  8606. int8 len = strlen(sep->arg[6]);
  8607. memcpy(ptr2, (uchar*)&len, 1);
  8608. ptr2 += 1;
  8609. memcpy(ptr2, sep->arg[6], len);
  8610. }
  8611. }
  8612. DumpPacket(app);
  8613. client->QueuePacket(app);
  8614. safe_delete(packet2);
  8615. }
  8616. }
  8617. }
  8618. else {
  8619. PacketStruct* packet2 = configReader.getStruct("WS_ExamineSpellInfo", client->GetVersion());
  8620. if (packet2) {
  8621. packet2->setSubstructDataByName("info_header", "show_name", 1);
  8622. packet2->setSubstructDataByName("info_header", "unknown", 7);
  8623. packet2->setSubstructDataByName("info_header", "unknown2", 1);
  8624. packet2->setSubstructDataByName("info_header", "unknown3", 1);
  8625. packet2->setSubstructDataByName("info_header", "unknown4", 1);
  8626. packet2->setSubstructDataByName("info_header", "unknown5", 1);
  8627. packet2->setSubstructDataByName("info_header", "unknown6", "Testing");
  8628. packet2->setSubstructDataByName("info_header", "unknown7", "Testing");
  8629. packet2->setSubstructDataByName("info_header", "unknown8", 66);
  8630. packet2->setSubstructDataByName("info_header", "title", "Blah Title Blah");
  8631. packet2->setSubstructDataByName("info_header", "title_text", "Blah Blah");
  8632. packet2->setSubstructDataByName("info_header", "title_text2", "Blah Blah2");
  8633. packet2->setSubstructDataByName("info_header", "show_popup", 1);
  8634. packet2->setSubstructDataByName("info_header", "packettype", 3);
  8635. packet2->setSubstructDataByName("spell_info", "skill_name", "Testing");
  8636. packet2->setSubstructDataByName("spell_info", "level", 19);
  8637. packet2->setSubstructDataByName("spell_info", "tier", 1);
  8638. packet2->setSubstructDataByName("spell_info", "health_cost", 5);
  8639. packet2->setSubstructDataByName("spell_info", "min_class_skill_req", 3);
  8640. packet2->setSubstructDataByName("spell_info", "mana_cost", 6);
  8641. packet2->setSubstructDataByName("spell_info", "req_concentration", 7);
  8642. packet2->setSubstructDataByName("spell_info", "cast_time", 200);
  8643. packet2->setSubstructDataByName("spell_info", "recovery", 220);
  8644. packet2->setSubstructDataByName("spell_info", "recast", 280);
  8645. packet2->setSubstructDataByName("spell_info", "beneficial", 1);
  8646. packet2->setSubstructDataByName("spell_info", "maintained", 1);
  8647. packet2->setSubstructDataByName("spell_info", "spell_book_type", 1);
  8648. packet2->setSubstructDataByName("spell_info", "quality", 3);
  8649. packet2->setSubstructDataByName("spell_info", "test_1a", 1);
  8650. packet2->setSubstructDataByName("spell_info", "test_1b", 1);
  8651. packet2->setSubstructDataByName("spell_info", "test_1c", 1);
  8652. packet2->setSubstructDataByName("spell_info", "test_1d", 1);
  8653. packet2->setSubstructDataByName("spell_info", "test_2a", 2);
  8654. packet2->setSubstructDataByName("spell_info", "test_2b", 2);
  8655. packet2->setSubstructDataByName("spell_info", "test_2c", 2);
  8656. packet2->setSubstructDataByName("spell_info", "test_2d", 2);
  8657. packet2->setSubstructDataByName("spell_info", "test_3", 3);
  8658. packet2->setSubstructDataByName("spell_info", "test_4", 4);
  8659. packet2->setSubstructDataByName("spell_info", "test_5", 5);
  8660. packet2->setSubstructDataByName("spell_info", "test_6", 6);
  8661. packet2->setSubstructDataByName("spell_info", "min_class_skill_req", 1);
  8662. packet2->setSubstructDataByName("spell_info", "min_class_skill_rec", 30123);
  8663. packet2->setSubstructDataByName("spell_info", "num_reagents", 1);
  8664. packet2->setSubstructArrayLengthByName("spell_info", "num_reagents", 1);
  8665. packet2->setArrayDataByName("reagent", "Alcohol");
  8666. packet2->setArrayDataByName("consumed", "123");
  8667. packet2->setSubstructDataByName("spell_info", "class_skill", 52);
  8668. packet2->setSubstructDataByName("spell_info", "id", 8308);
  8669. packet2->setSubstructDataByName("spell_info", "icon", 303);
  8670. packet2->setSubstructDataByName("spell_info", "icon2", 0xFFFF);
  8671. packet2->setSubstructDataByName("spell_info", "icontype", 317);
  8672. packet2->setSubstructDataByName("spell_info", "type", 2);
  8673. packet2->setSubstructDataByName("spell_info", "spell_text_color", 255);
  8674. packet2->setSubstructDataByName("spell_info", "duration1", 600);
  8675. packet2->setSubstructDataByName("spell_info", "duration2", 600);
  8676. packet2->setSubstructDataByName("spell_info", "name", "Sprint");
  8677. packet2->setSubstructDataByName("spell_info", "description", "Test description");
  8678. EQ2Packet* outapp = packet2->serialize();
  8679. DumpPacket(outapp);
  8680. client->QueuePacket(outapp);
  8681. safe_delete(packet2);
  8682. }
  8683. }
  8684. return;
  8685. PacketStruct* p = configReader.getStruct("WS_EqTargetItemCmd", client->GetVersion());
  8686. if (!p) return;
  8687. //Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  8688. //client->GetCurrentZone()->SendSpellFailedPacket(client, atoi(sep2->arg[0]));
  8689. //}
  8690. /*Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  8691. if (sep2 && sep2->arg[0] && sep2->IsNumber(0)) {
  8692. client->SetPendingFlightPath(atoi(sep2->arg[0]));
  8693. PacketStruct* packet = configReader.getStruct("WS_ReadyForTakeOff", client->GetVersion());
  8694. if (packet) {
  8695. client->QueuePacket(packet->serialize());
  8696. safe_delete(packet);
  8697. }
  8698. }*/
  8699. /*if (client->GetCurrentZone()->Grid != nullptr) {
  8700. int32 numFaces = 0;
  8701. int32 numGrids = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.size();
  8702. client->Message(CHANNEL_COLOR_YELLOW, "Num grids in cell: %u", numGrids);
  8703. map<int32, vector<Face*> >::iterator itr;
  8704. for (itr = client->GetPlayer()->Cell_Info.CurrentCell->FaceList.begin(); itr != client->GetPlayer()->Cell_Info.CurrentCell->FaceList.end(); itr++)
  8705. numFaces += (*itr).second.size();
  8706. client->Message(CHANNEL_COLOR_YELLOW, "Num faces in cell: %u", numFaces);
  8707. }*/
  8708. //uchar blah[] = {
  8709. // 1208 - OP_EQUpdateStoreCmd
  8710. // /*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
  8711. // /*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
  8712. // 1193 - -- OP_ClientCmdMsg::OP_EqUpdateMerchantCmd --
  8713. // /*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
  8714. /*};
  8715. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  8716. int8 val = 0;
  8717. int16 pos = 0;
  8718. int idx = 0;
  8719. while(sep2 && sep2->arg[idx+1] && sep2->IsNumber(idx) && sep2->IsNumber(idx+1)){
  8720. pos = atoi(sep2->arg[idx]);
  8721. val = atoi(sep2->arg[idx+1]);
  8722. memset(blah+pos, val, 1);
  8723. idx+=2;
  8724. }
  8725. DumpPacket(blah, sizeof(blah));
  8726. client->QueuePacket(new EQ2Packet(OP_GroupCreatedMsg , blah, sizeof(blah)));*/
  8727. if (client->GetPlayer()->GetTarget()) {
  8728. PacketStruct* packet = configReader.getStruct("WS_SetControlGhost", client->GetVersion());
  8729. if (packet) {
  8730. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  8731. packet->setDataByName("size", 0);
  8732. packet->setDataByName("unknown2", 0);
  8733. EQ2Packet* app = packet->serialize();
  8734. client->QueuePacket(app);
  8735. safe_delete(packet);
  8736. }
  8737. PacketStruct* set_pov = configReader.getStruct("WS_SetPOVGhostCmd", client->GetVersion());
  8738. if (set_pov) {
  8739. set_pov->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(client->GetPlayer()->GetTarget()));
  8740. EQ2Packet* app_pov = set_pov->serialize();
  8741. client->QueuePacket(app_pov);
  8742. safe_delete(set_pov);
  8743. }
  8744. }
  8745. Seperator* sep2 = new Seperator(command_parms->data.c_str(), ' ', 50, 500, true);
  8746. PacketStruct* packet = configReader.getStruct("WS_OpenCharCust", client->GetVersion());
  8747. if (packet) {
  8748. if (sep2 && sep2->arg[0] && sep2->IsNumber(0))
  8749. packet->setDataByName("Type", atoi(sep2->arg[0]));
  8750. else
  8751. packet->setDataByName("Type", 2);
  8752. if (sep2 && sep2->arg[1] && sep2->IsNumber(1))
  8753. packet->setDataByName("race_id", atoi(sep2->arg[1]));
  8754. else
  8755. packet->setDataByName("race_id", 0);
  8756. if (sep2 && sep2->arg[2] && sep2->IsNumber(2))
  8757. packet->setDataByName("gender", atoi(sep2->arg[2]));
  8758. else
  8759. packet->setDataByName("gender", 2);
  8760. if (sep2 && sep2->arg[3] && sep2->IsNumber(3))
  8761. packet->setDataByName("unknown", atoi(sep2->arg[3]), 0);
  8762. else
  8763. packet->setDataByName("unknown", 0, 0);
  8764. if (sep2 && sep2->arg[4] && sep2->IsNumber(4))
  8765. packet->setDataByName("unknown", atoi(sep2->arg[4]), 1);
  8766. else
  8767. packet->setDataByName("unknown", 0, 1);
  8768. if (sep2 && sep2->arg[5] && sep2->IsNumber(5))
  8769. packet->setDataByName("unknown", atoi(sep2->arg[5]), 2);
  8770. else
  8771. packet->setDataByName("unknown", 0, 2);
  8772. client->QueuePacket(packet->serialize());
  8773. }
  8774. safe_delete(packet);
  8775. safe_delete(sep2);
  8776. }
  8777. void Commands::Command_LeaveChannel(Client *client, Seperator *sep) {
  8778. const char *channel_name;
  8779. if (sep == NULL || !sep->IsSet(0)) {
  8780. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /leavechat <channel name>");
  8781. PrintSep(sep);
  8782. return;
  8783. }
  8784. channel_name = sep->arg[0];
  8785. if (!chat.IsInChannel(client, channel_name))
  8786. client->Message(CHANNEL_COLOR_WHITE, "Unable to leave '%s': You are not in the channel.", channel_name);
  8787. else if (!chat.LeaveChannel(client, channel_name))
  8788. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "There was an internal error preventing you from leaving that channel MUAHAHA");
  8789. }
  8790. /*
  8791. Function:
  8792. Purpose :
  8793. Params :
  8794. Dev :
  8795. Example :
  8796. */
  8797. void Commands::Command_WeaponStats(Client* client)
  8798. {
  8799. Player* player = client->GetPlayer();
  8800. Item* primary = player->GetEquipmentList()->GetItem(EQ2_PRIMARY_SLOT);
  8801. Item* secondary = player->GetEquipmentList()->GetItem(EQ2_SECONDARY_SLOT);
  8802. Item* ranged = player->GetEquipmentList()->GetItem(EQ2_RANGE_SLOT);
  8803. client->SimpleMessage(0, "Primary:");
  8804. if (primary) {
  8805. client->Message(0, "Name: %s", primary->name.c_str());
  8806. client->Message(0, "Base Damage: %u - %u", primary->weapon_info->damage_low3, primary->weapon_info->damage_high3);
  8807. client->Message(0, "Actual Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  8808. client->Message(0, "Actual Delay: %u", player->GetPrimaryWeaponDelay());
  8809. client->Message(0, "Proc Percent: %d%%", 0);
  8810. client->Message(0, "Procs Per Minute: %d", 0);
  8811. }
  8812. else {
  8813. client->SimpleMessage(0, "Name: fist");
  8814. client->Message(0, "Base Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  8815. client->Message(0, "Actual Damage: %u - %u", player->GetPrimaryWeaponMinDamage(), player->GetPrimaryWeaponMaxDamage());
  8816. client->Message(0, "Actual Delay: %d", player->GetPrimaryWeaponDelay() * 0.1);
  8817. client->Message(0, "Proc Percent: %d%%", 0);
  8818. client->Message(0, "Procs Per Minute: %d", 0);
  8819. }
  8820. client->SimpleMessage(0, " ");
  8821. client->SimpleMessage(0, " ");
  8822. if (secondary) {
  8823. client->SimpleMessage(0, "Secondary:");
  8824. client->Message(0, "Name: %s", secondary->name.c_str());
  8825. client->Message(0, "Base Damage: %u - %u", secondary->weapon_info->damage_low3, secondary->weapon_info->damage_high3);
  8826. client->Message(0, "Actual Damage: %u - %u", player->GetSecondaryWeaponMinDamage(), player->GetSecondaryWeaponMaxDamage());
  8827. client->Message(0, "Actual Delay: %d", player->GetSecondaryWeaponDelay() * 0.1);
  8828. client->Message(0, "Proc Percent: %d%%", 0);
  8829. client->Message(0, "Procs Per Minute: %d", 0);
  8830. client->SimpleMessage(0, " ");
  8831. client->SimpleMessage(0, " ");
  8832. }
  8833. client->SimpleMessage(0, "Ranged:");
  8834. if (ranged) {
  8835. client->Message(0, "Name: %s", ranged->name.c_str());
  8836. client->Message(0, "Base Damage: %u - %u", ranged->ranged_info->weapon_info.damage_low3, ranged->ranged_info->weapon_info.damage_high3);
  8837. client->Message(0, "Actual Damage: %u - %u", player->GetRangedWeaponMinDamage(), player->GetRangedWeaponMaxDamage());
  8838. client->Message(0, "Actual Delay: %d", player->GetRangeWeaponDelay() * 0.1);
  8839. client->Message(0, "Proc Percent: %d%%", 0);
  8840. client->Message(0, "Procs Per Minute: %d", 0);
  8841. }
  8842. else
  8843. client->SimpleMessage(0, "None");
  8844. }
  8845. void Commands::Command_WhoChannel(Client *client, Seperator *sep) {
  8846. const char *channel_name;
  8847. if (sep == NULL || !sep->IsSet(0)) {
  8848. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /chatwho <channel name>");
  8849. return;
  8850. }
  8851. channel_name = sep->arg[0];
  8852. if (!chat.ChannelExists(channel_name))
  8853. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "That channel does not exist!");
  8854. else
  8855. chat.SendChannelUserList(client, channel_name);
  8856. }
  8857. void Commands::Command_ZoneSafeCoords(Client *client, Seperator *sep)
  8858. {
  8859. ZoneServer* zone = 0;
  8860. int32 zone_id = client->GetPlayer()->GetZone()->GetZoneID();
  8861. if (zone_id > 0)
  8862. {
  8863. zone = zone_list.Get(zone_id, false);
  8864. if (zone)
  8865. {
  8866. zone->SetSafeX(client->GetPlayer()->GetX());
  8867. zone->SetSafeY(client->GetPlayer()->GetY());
  8868. zone->SetSafeZ(client->GetPlayer()->GetZ());
  8869. zone->SetSafeHeading(client->GetPlayer()->GetHeading());
  8870. if( database.SaveZoneSafeCoords(zone_id, zone->GetSafeX(), zone->GetSafeY(), zone->GetSafeZ(), zone->GetSafeHeading()) )
  8871. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Zone safe coordinates updated!");
  8872. else
  8873. client->SimpleMessage(CHANNEL_COLOR_RED, "FAILED to update zone safe coordinates!");
  8874. }
  8875. }
  8876. }
  8877. /*
  8878. Function:
  8879. Purpose :
  8880. Params :
  8881. Dev :
  8882. Example :
  8883. */
  8884. void Commands::Command_ZoneDetails(Client* client, Seperator* sep)
  8885. {
  8886. ZoneInfo* zone_info = new ZoneInfo;
  8887. if (sep && sep->arg[0])
  8888. {
  8889. if (sep->IsNumber(0))
  8890. zone_info->id = atoi(sep->arg[0]);
  8891. else
  8892. zone_info->id = database.GetZoneID(sep->arg[0]);
  8893. if (zone_info->id > 0)
  8894. {
  8895. database.LoadZoneInfo(zone_info);
  8896. 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);
  8897. 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);
  8898. 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);
  8899. 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);
  8900. 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);
  8901. 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);
  8902. 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);
  8903. client->Message(CHANNEL_COLOR_YELLOW, "zone_type: %s", zone_info->zone_type);
  8904. client->Message(CHANNEL_COLOR_YELLOW, "lua_script: %s", zone_info->lua_script);
  8905. client->Message(CHANNEL_COLOR_YELLOW, "zone_motd: %s", zone_info->zone_motd);
  8906. }
  8907. else
  8908. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  8909. }
  8910. else
  8911. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone details [zone id|zone name]");
  8912. safe_delete(zone_info);
  8913. }
  8914. /*
  8915. Function:
  8916. Purpose :
  8917. Params :
  8918. Dev :
  8919. Example :
  8920. */
  8921. void Commands::Command_ZoneSet(Client* client, Seperator* sep)
  8922. {
  8923. if (sep && sep->arg[0] && sep->arg[1] && sep->arg[2])
  8924. {
  8925. ZoneServer* zone = 0;
  8926. int32 zone_id = 0;
  8927. if (sep->IsNumber(0) && atoi(sep->arg[0]) > 0)
  8928. {
  8929. zone_id = atoi(sep->arg[0]);
  8930. zone = zone_list.Get(atoi(sep->arg[0]), false);
  8931. }
  8932. else
  8933. {
  8934. zone_id = database.GetZoneID(sep->arg[0]);
  8935. if (zone_id > 0)
  8936. zone = zone_list.Get(sep->arg[0], false);
  8937. }
  8938. if (zone_id > 0)
  8939. {
  8940. if (zone_set_values.count(string(sep->arg[1])) > 0)
  8941. SetZoneCommand(client, zone_id, zone, zone_set_values[sep->arg[1]], sep->arg[2]);
  8942. else
  8943. client->Message(CHANNEL_COLOR_YELLOW, "The attribute '%s' is not valid.", sep->arg[1]);
  8944. }
  8945. else
  8946. client->Message(CHANNEL_COLOR_YELLOW, "The zone name or ID '%s' does not exist.", sep->arg[0]);
  8947. }
  8948. else
  8949. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /zone set [zone id|zone name] [attribute] [value]");
  8950. }
  8951. void Commands::Command_Rain(Client* client, Seperator* sep) {
  8952. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  8953. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /rain <float>");
  8954. return;
  8955. }
  8956. client->Message(CHANNEL_COLOR_YELLOW,"Setting rain to %.2f", atof(sep->arg[0]));
  8957. client->GetCurrentZone()->SetRain(atof(sep->arg[0]));
  8958. client->GetCurrentZone()->SetCurrentWeather(atof(sep->arg[0]));
  8959. }
  8960. void Commands::Command_Wind(Client* client, Seperator* sep) {
  8961. if (sep == NULL || !sep->IsSet(0) || !sep->IsNumber(0)) {
  8962. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /wind <float>");
  8963. return;
  8964. }
  8965. client->Message(CHANNEL_COLOR_YELLOW, "Setting wind to %.2f", atof(sep->arg[0]));
  8966. client->GetCurrentZone()->SetWind(atof(sep->arg[0]));
  8967. }
  8968. void Commands::Command_SendMerchantWindow(Client* client, Seperator* sep, bool sell) {
  8969. Spawn* spawn = client->GetPlayer()->GetTarget();
  8970. if(spawn) {
  8971. client->SetMerchantTransaction(spawn);
  8972. if (spawn->GetMerchantID() > 0 && spawn->IsClientInMerchantLevelRange(client)){
  8973. client->SendHailCommand(spawn);
  8974. //MerchantFactionMultiplier* multiplier = world.GetMerchantMultiplier(spawn->GetMerchantID());
  8975. //if(!multiplier || (multiplier && client->GetPlayer()->GetFactions()->GetFactionValue(multiplier->faction_id) >= multiplier->faction_min)){
  8976. client->SendBuyMerchantList(sell);
  8977. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY))
  8978. client->SendSellMerchantList(sell);
  8979. if(!(spawn->GetMerchantType() & MERCHANT_TYPE_NO_BUY_BACK))
  8980. client->SendBuyBackList(sell);
  8981. PacketStruct* packet = configReader.getStruct("WS_UpdateMerchant", client->GetVersion());
  8982. if (packet) {
  8983. packet->setDataByName("spawn_id", 0xFFFFFFFF);
  8984. packet->setDataByName("type", 16);
  8985. EQ2Packet* outapp = packet->serialize();
  8986. if (outapp)
  8987. client->QueuePacket(outapp);
  8988. safe_delete(packet);
  8989. }
  8990. }
  8991. if (spawn->GetMerchantType() & MERCHANT_TYPE_REPAIR)
  8992. client->SendRepairList();
  8993. }
  8994. // client->SimpleMessage(CHANNEL_COLOR_RED, "Your faction is too low to use this merchant.");
  8995. }
  8996. void Commands::Command_Weather(Client* client, Seperator* sep)
  8997. {
  8998. //PrintSep(sep, "Weather");
  8999. if( sep && sep->arg[0] )
  9000. {
  9001. ZoneServer* zsZone = client->GetCurrentZone();
  9002. const char* value = sep->arg[0];
  9003. // process single-param commands first
  9004. if( strncasecmp(value, "details", strlen(value)) == 0 )
  9005. {
  9006. client->Message(CHANNEL_COLOR_YELLOW, "Weather Details for zone %s: ", zsZone->GetZoneName());
  9007. client->Message(CHANNEL_COLOR_YELLOW, "enabled: %i, allowed: %i, type: %i, frequency: %u", zsZone->isWeatherEnabled(), zsZone->isWeatherAllowed(), zsZone->GetWeatherType(), zsZone->GetWeatherFrequency());
  9008. client->Message(CHANNEL_COLOR_YELLOW, "severity: %.2f = %.2f, current: %.2f", zsZone->GetWeatherMinSeverity(), zsZone->GetWeatherMaxSeverity(), zsZone->GetCurrentWeather());
  9009. client->Message(CHANNEL_COLOR_YELLOW, "pattern: %i, chance: %i, amount: %.2f, offset: %.2f", zsZone->GetWeatherPattern(), zsZone->GetWeatherChance(), zsZone->GetWeatherChangeAmount(), zsZone->GetWeatherDynamicOffset());
  9010. }
  9011. else if( strncasecmp(value, "process", strlen(value)) == 0 )
  9012. {
  9013. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  9014. zsZone->ProcessWeather();
  9015. }
  9016. else if( strncasecmp(value, "reset", strlen(value)) == 0 )
  9017. {
  9018. zsZone->SetWeatherType(rule_manager.GetGlobalRule(R_Zone, WeatherType)->GetInt8());
  9019. zsZone->SetWeatherFrequency(rule_manager.GetGlobalRule(R_Zone, WeatherChangeFrequency)->GetInt32());
  9020. zsZone->SetWeatherMinSeverity(rule_manager.GetGlobalRule(R_Zone, MinWeatherSeverity)->GetFloat());
  9021. zsZone->SetWeatherMaxSeverity(rule_manager.GetGlobalRule(R_Zone, MaxWeatherSeverity)->GetFloat());
  9022. zsZone->SetCurrentWeather(zsZone->GetWeatherMinSeverity());
  9023. zsZone->SetWeatherPattern(1);
  9024. zsZone->SetWeatherChance(rule_manager.GetGlobalRule(R_Zone, WeatherChangeChance)->GetInt8());
  9025. zsZone->SetWeatherChangeAmount(rule_manager.GetGlobalRule(R_Zone, WeatherChangePerInterval)->GetFloat());
  9026. zsZone->SetWeatherDynamicOffset(rule_manager.GetGlobalRule(R_Zone, WeatherDynamicMaxOffset)->GetFloat());
  9027. zsZone->SetWeatherLastChangedTime(Timer::GetUnixTimeStamp() - zsZone->GetWeatherFrequency());
  9028. zsZone->ProcessWeather();
  9029. }
  9030. // process commands with params
  9031. if( sep->arg[1] )
  9032. {
  9033. if( strncasecmp(value, "enable", strlen(value)) == 0 && sep->IsNumber(1) )
  9034. zsZone->SetWeatherEnabled( ( atoi(sep->arg[1]) == 1 ) ? true : false );
  9035. else if( strncasecmp(value, "type", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 3) )
  9036. zsZone->SetWeatherType(atoi(sep->arg[1]));
  9037. else if( strncasecmp(value, "frequency", strlen(value)) == 0 && sep->IsNumber(1))
  9038. zsZone->SetWeatherFrequency( atoul(sep->arg[1]) );
  9039. else if( strncasecmp(value, "range", strlen(value)) == 0 && sep->IsNumber(1) && sep->IsNumber(2) ) {
  9040. zsZone->SetWeatherMinSeverity(atof(sep->arg[1]));
  9041. zsZone->SetWeatherMaxSeverity(atof(sep->arg[2]));
  9042. zsZone->SetRain(zsZone->GetWeatherMinSeverity());
  9043. }
  9044. else if( strncasecmp(value, "current", strlen(value)) == 0 && sep->IsNumber(1) ) {
  9045. zsZone->SetCurrentWeather(atof(sep->arg[1]));
  9046. zsZone->SetRain(zsZone->GetCurrentWeather());
  9047. }
  9048. else if( strncasecmp(value, "pattern", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 2) )
  9049. zsZone->SetWeatherPattern( atoi(sep->arg[1]) );
  9050. else if( strncasecmp(value, "chance", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 100) )
  9051. zsZone->SetWeatherChance( atoi(sep->arg[1]) );
  9052. else if( strncasecmp(value, "amount", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  9053. zsZone->SetWeatherChangeAmount( atof(sep->arg[1]) );
  9054. else if( strncasecmp(value, "offset", strlen(value)) == 0 && sep->IsNumber(1) && (atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 1) )
  9055. zsZone->SetWeatherDynamicOffset( atof(sep->arg[1]) );
  9056. }
  9057. }
  9058. else
  9059. {
  9060. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /weather [command] [param]");
  9061. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: enable (0|1), type (0-3), frequency (sec), range|current (0.0 - 1.0)");
  9062. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Commands: details, process, pattern (0|1), chance (%), amount (float), offset (float)");
  9063. return;
  9064. }
  9065. }
  9066. void Commands::Command_Select(Client* client, Seperator* sep) {
  9067. if (sep && sep->arg[1]) {
  9068. Spawn* spawn = client->GetPlayer()->GetTarget();
  9069. if (spawn && strlen(sep->arg[1]) > 0)
  9070. client->GetCurrentZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_CUSTOM, client->GetPlayer(), sep->arg[1]);
  9071. }
  9072. }
  9073. /*
  9074. Function: Command_ConsumeFood()
  9075. Purpose : Consume Food/Drink and apply mods
  9076. Params : Slot ID - EQ2_FOOD_SLOT 22, EQ2_DRINK_SLOT 23
  9077. Dev : Zcoretri
  9078. Example : /consume_food 22
  9079. */
  9080. void Commands::Command_ConsumeFood(Client* client, Seperator* sep) {
  9081. if (sep && sep->arg[0] && sep->IsNumber(0))
  9082. {
  9083. Player* player = client->GetPlayer();
  9084. int8 slot = atoi(sep->arg[0]);
  9085. Item* item = player->GetEquipmentList()->GetItem(slot);
  9086. if(item) {
  9087. LogWrite(MISC__INFO, 1, "Command", "ItemID: %u, ItemName: %s ItemCount: %i ", item->details.item_id, item->name.c_str(), item->details.count);
  9088. if(item->GetItemScript() && lua_interface){
  9089. lua_interface->RunItemScript(item->GetItemScript(), "cast", item, client->GetPlayer());
  9090. if (slot == 22)
  9091. client->Message(CHANNEL_COLOR_WHITE, "You eat a %s.", item->name.c_str());
  9092. else
  9093. client->Message(CHANNEL_COLOR_WHITE, "You drink a %s.", item->name.c_str());
  9094. }
  9095. }
  9096. if (item->details.count > 1) {
  9097. item->details.count -= 1;
  9098. item->save_needed = true;
  9099. }
  9100. else {
  9101. player->GetEquipmentList()->RemoveItem(slot, true);
  9102. database.DeleteItem(player->GetCharacterID(), item, "EQUIPPED");
  9103. }
  9104. client->GetPlayer()->SetCharSheetChanged(true);
  9105. client->QueuePacket(player->GetEquipmentList()->serialize(client->GetVersion(), player));
  9106. }
  9107. }
  9108. void Commands::Command_Aquaman(Client* client, Seperator* sep) {
  9109. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  9110. if (atoi(sep->arg[0]) == 1) {
  9111. client->GetPlayer()->GetInfoStruct()->vision = 4;
  9112. client->GetPlayer()->GetInfoStruct()->breathe_underwater = 1;
  9113. client->GetPlayer()->SetCharSheetChanged(true);
  9114. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Maybe you ought to stick to the shallow end until you know how to swim.");
  9115. }
  9116. else {
  9117. client->GetPlayer()->GetInfoStruct()->vision = 0;
  9118. client->GetPlayer()->GetInfoStruct()->breathe_underwater = 0;
  9119. client->GetPlayer()->SetCharSheetChanged(true);
  9120. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Aquaman mode turned off.");
  9121. }
  9122. }
  9123. else
  9124. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /aquaman [0|1]");
  9125. }
  9126. void Commands::Command_ReportBug(Client* client, Seperator* sep)
  9127. {
  9128. if(sep)
  9129. {
  9130. string data;
  9131. if(sep->arg[0]){
  9132. data = string(sep->arg[0]);
  9133. }
  9134. for(int i=1;i<sep->GetMaxArgNum();i++){
  9135. if(sep->arg[i])
  9136. data.append(" ").append(sep->arg[i]);
  9137. }
  9138. const char* target_name = 0;
  9139. int32 spawn_id = 0;
  9140. if(client->GetPlayer()->GetTarget())
  9141. {
  9142. target_name = client->GetPlayer()->GetTarget()->GetName();
  9143. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  9144. }
  9145. else
  9146. target_name = "N/A";
  9147. LogWrite(COMMAND__DEBUG, 1, "Command", "%s", data.c_str());
  9148. if(world.ReportBug(data, client->GetPlayer()->GetName(), client->GetAccountID(), target_name, spawn_id, client->GetCurrentZone()->GetZoneID()))
  9149. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully submitted bug.");
  9150. else
  9151. client->SimpleMessage(CHANNEL_COLOR_RED, "Error submitting bug.");
  9152. }
  9153. }
  9154. void Commands::Command_Attune_Inv(Client* client, Seperator* sep) {
  9155. PrintSep(sep, "Command_Attune_Inv");
  9156. if (sep && sep->arg[0] && sep->IsNumber(0)) {
  9157. // Get the item index from the first parameter
  9158. int16 index = atoi(sep->arg[0]);
  9159. // Check to see if this is a valid item index for the player, if not exit out of the function
  9160. if (client->GetPlayer()->item_list.indexed_items.count(index) == 0) {
  9161. LogWrite(ITEM__DEBUG, 0, "Items", "%s has no item with an index of %i", client->GetPlayer()->GetName(), index);
  9162. return;
  9163. }
  9164. // Get the item
  9165. Item* item = client->GetPlayer()->item_list.indexed_items[index];
  9166. if(item) {
  9167. // Valid item lets check to make sure this item is attunable, if not return out
  9168. if (!item->CheckFlag(ATTUNEABLE)) {
  9169. LogWrite(ITEM__DEBUG, 0, "Items", "attune_inv called for an item that is not attunable (%s)", item->name.c_str());
  9170. return;
  9171. }
  9172. // Remove the attunable flag
  9173. item->generic_info.item_flags -= ATTUNEABLE;
  9174. // Set the attuned flag
  9175. item->generic_info.item_flags += ATTUNED;
  9176. // Flag this item for saving
  9177. item->save_needed = true;
  9178. client->QueuePacket(item->serialize(client->GetVersion(), false, client->GetPlayer()));
  9179. vector<EQ2Packet*> packets = client->GetPlayer()->EquipItem(index, client->GetVersion(), -1);
  9180. EQ2Packet* outapp = 0;
  9181. for (int32 i=0;i<packets.size();i++) {
  9182. outapp = packets[i];
  9183. if(outapp)
  9184. client->QueuePacket(outapp);
  9185. }
  9186. }
  9187. }
  9188. }
  9189. void Commands::Command_Reset_Zone_Timer(Client* client, Seperator* sep) {
  9190. PrintSep(sep, "Command_Reset_Zone_Timer");
  9191. /*if (sep && sep->arg[0] && sep->IsNumber(0)) {
  9192. int32 db_id = atoul(sep->arg[0]);
  9193. InstanceData* data = client->GetPlayer()->GetCharacterInstances().FindInstanceByDBID(db_id);
  9194. if (data) {
  9195. // TODO: add a check to timers to ensure it can be reset
  9196. // Delete the character from the instance
  9197. database.DeleteCharacterFromInstance(client->GetPlayer()->GetCharacterID(), data->instance_id);
  9198. data->instance_id = 0;
  9199. // Update the success time and set to 0 so the player can enter it again
  9200. database.UpdateCharacterInstance(client->GetPlayer()->GetCharacterID(), data->zone_name, 0, 1, 0);
  9201. data->last_success_timestamp = 0;
  9202. }
  9203. }*/
  9204. }
  9205. void Commands::Command_Player(Client* client, Seperator* sep) {
  9206. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player syntax --");
  9207. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins");
  9208. }
  9209. void Commands::Command_Player_Coins(Client* client, Seperator* sep) {
  9210. // /player coins add 10
  9211. // /player coins add plat 10
  9212. Player* player = client->GetPlayer();
  9213. if (player->HasTarget() && player->GetTarget()->IsPlayer())
  9214. player = (Player*)player->GetTarget();
  9215. if (sep && sep->arg[0] && sep->arg[1]) {
  9216. const char* action = sep->arg[0];
  9217. int64 value = 0;
  9218. if (strncasecmp(action, "add", strlen(action)) == 0) {
  9219. if (sep->IsNumber(1)) {
  9220. value = atoi64(sep->arg[1]);
  9221. player->AddCoins(value);
  9222. if (client->GetPlayer() == player)
  9223. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  9224. else {
  9225. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  9226. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  9227. }
  9228. return;
  9229. }
  9230. else if (sep->arg[2] && sep->IsNumber(2)) {
  9231. const char* type = sep->arg[1];
  9232. if (strncasecmp(type, "copper", strlen(type)) == 0) {
  9233. value = atoi64(sep->arg[2]);
  9234. }
  9235. else if (strncasecmp(type, "silver", strlen(type)) == 0) {
  9236. value = atoi64(sep->arg[2]) * 100;
  9237. }
  9238. else if (strncasecmp(type, "gold", strlen(type)) == 0) {
  9239. value = atoi64(sep->arg[2]) * 10000;
  9240. }
  9241. else if (strncasecmp(type, "plat", strlen(type)) == 0) {
  9242. value = atoi64(sep->arg[2]) * 1000000;
  9243. }
  9244. player->AddCoins(value);
  9245. if (client->GetPlayer() == player)
  9246. client->Message(CHANNEL_COLOR_YELLOW, "You give yourself %llu coin%s", value, (value > 1 ? "s" : ""));
  9247. else {
  9248. client->Message(CHANNEL_COLOR_YELLOW, "You give %s %llu coin%s", player->GetName(), value, (value > 1 ? "s" : ""));
  9249. client->GetCurrentZone()->GetClientBySpawn(player)->Message(CHANNEL_COLOR_YELLOW, "%s gave you %llu coin%s", client->GetPlayer()->GetName(), value, (value > 1 ? "s" : ""));
  9250. }
  9251. return;
  9252. }
  9253. }
  9254. }
  9255. client->SimpleMessage(CHANNEL_COLOR_YELLOW, " -- /player coins syntax --");
  9256. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add [value] - adds the given number of coins to the player");
  9257. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add copper [value] - adds the given amount of copper to the player");
  9258. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add silver [value] - adds the given amount of silver to the player");
  9259. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add gold [value] - adds the given amount of gold to the player");
  9260. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/player coins add plat [value] - adds the given amount of platinum to the player");
  9261. }
  9262. void Commands::Command_AchievementAdd(Client* client, Seperator* sep) {
  9263. PrintSep(sep, "ACHIEVEMENT_ADD");
  9264. if (sep && sep->IsSet(0)) {
  9265. int32 spell_id = atoul(sep->arg[1]);
  9266. int8 spell_tier = 0;
  9267. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  9268. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  9269. // addspellbookentry here
  9270. if (spell_tier >= data->maxRank) {
  9271. return;
  9272. }
  9273. if (!spell_tier) {
  9274. spell_tier = 1;
  9275. }
  9276. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  9277. {
  9278. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  9279. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  9280. client->GetPlayer()->UnlockSpell(spell);
  9281. client->SendSpellUpdate(spell);
  9282. }
  9283. else
  9284. {
  9285. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1);
  9286. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  9287. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  9288. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  9289. client->GetPlayer()->UnlockSpell(spell);
  9290. client->SendSpellUpdate(spell);
  9291. }
  9292. // cast spell here
  9293. if (!spell_tier)
  9294. spell_tier = 1;
  9295. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  9296. if (spell) {
  9297. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  9298. }
  9299. }
  9300. else {
  9301. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  9302. }
  9303. master_aa_list.DisplayAA(client, 0, 0);
  9304. }
  9305. void Commands::Command_Editor(Client* client, Seperator* sep) {
  9306. PacketStruct* packet = configReader.getStruct("WS_ChoiceWindow", client->GetVersion());
  9307. if (packet) {
  9308. string url = string(rule_manager.GetGlobalRule(R_World, EditorURL)->GetString());
  9309. if (rule_manager.GetGlobalRule(R_World, EditorOfficialServer)->GetBool()) {
  9310. char command[255];
  9311. url = "browser " + url;
  9312. int32 spawn_id = 0;
  9313. int32 zone_id = 0;
  9314. string type;
  9315. if (client->GetCurrentZone())
  9316. zone_id = client->GetCurrentZone()->GetZoneID();
  9317. if (client->GetPlayer()->GetTarget()) {
  9318. Spawn* target = client->GetPlayer()->GetTarget();
  9319. if (target->IsWidget())
  9320. type = "widgets";
  9321. else if (target->IsSign())
  9322. type = "signs";
  9323. else if (target->IsObject())
  9324. type = "objects";
  9325. else if (target->IsNPC())
  9326. type = "npcs";
  9327. else if (target->IsGroundSpawn())
  9328. type = "ground";
  9329. else
  9330. type = "spawn";
  9331. spawn_id = client->GetPlayer()->GetTarget()->GetDatabaseID();
  9332. }
  9333. sprintf(command, url.c_str(), zone_id, type.c_str(), spawn_id);
  9334. packet->setDataByName("accept_command", command);
  9335. }
  9336. else if (rule_manager.GetGlobalRule(R_World, EditorIncludeID)->GetBool()) {
  9337. char command[255];
  9338. url = "browser " + url;
  9339. if (client->GetPlayer()->GetTarget())
  9340. sprintf(command, url.c_str(), client->GetPlayer()->GetTarget()->GetDatabaseID());
  9341. packet->setDataByName("accept_command", command);
  9342. }
  9343. else {
  9344. string command = "browser " + url;
  9345. packet->setDataByName("accept_command", command.c_str());
  9346. }
  9347. packet->setDataByName("text", "Open the web editor?");
  9348. packet->setDataByName("accept_text", "Open");
  9349. packet->setDataByName("cancel_text", "Cancel");
  9350. // No clue if we even need the following 2 unknowns, just added them so the packet matches what live sends
  9351. packet->setDataByName("unknown2", 50);
  9352. packet->setDataByName("unknown4", 1);
  9353. client->QueuePacket(packet->serialize());
  9354. safe_delete(packet);
  9355. }
  9356. }
  9357. void Commands::Command_AcceptResurrection(Client* client, Seperator* sep) {
  9358. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  9359. return;
  9360. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  9361. if(client->GetCurrentRez()->active)
  9362. client->AcceptResurrection();
  9363. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  9364. }
  9365. void Commands::Command_DeclineResurrection(Client* client, Seperator* sep) {
  9366. if(!client || !sep || client->GetPlayer()->GetID() != atoul(sep->arg[0]))
  9367. return;
  9368. client->GetResurrectMutex()->writelock(__FUNCTION__, __LINE__);
  9369. if(client->GetCurrentRez()->active)
  9370. client->GetCurrentRez()->should_delete = true;
  9371. client->GetResurrectMutex()->releasewritelock(__FUNCTION__, __LINE__);
  9372. }
  9373. void Commands::Switch_AA_Profile(Client* client, Seperator* sep) {
  9374. PrintSep(sep, "Switch_AA_Profile");
  9375. if (sep && sep->IsSet(0)) {
  9376. string type = sep->arg[0];
  9377. int8 newtemplate = atoul(sep->arg[1]);
  9378. master_aa_list.DisplayAA(client, newtemplate, 1);
  9379. }
  9380. }
  9381. void Commands::Get_AA_Xml(Client* client, Seperator* sep) {
  9382. PrintSep(sep, "Get_AA_Xml");
  9383. if (sep && sep->IsSet(0)) {
  9384. string tabnum = sep->arg[0];
  9385. string spellid = sep->arg[1];
  9386. }
  9387. }
  9388. void Commands::Add_AA(Client* client, Seperator* sep) {
  9389. PrintSep(sep, "Add_AA");
  9390. if (sep && sep->IsSet(0)) {
  9391. int32 spell_id = atoul(sep->arg[1]);
  9392. int8 spell_tier = 0;
  9393. spell_tier = client->GetPlayer()->GetSpellTier(spell_id);
  9394. AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
  9395. // addspellbookentry here
  9396. if (spell_tier >= data->maxRank) {
  9397. return;
  9398. }
  9399. if (!spell_tier) {
  9400. spell_tier = 1;
  9401. }
  9402. if (!client->GetPlayer()->HasSpell(spell_id, 0, true))
  9403. {
  9404. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  9405. client->GetPlayer()->AddSpellBookEntry(spell_id, 1, client->GetPlayer()->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  9406. client->GetPlayer()->UnlockSpell(spell);
  9407. client->SendSpellUpdate(spell);
  9408. }
  9409. else
  9410. {
  9411. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier + 1 );
  9412. int8 old_slot = client->GetPlayer()->GetSpellSlot(spell->GetSpellID());
  9413. client->GetPlayer()->RemoveSpellBookEntry(spell->GetSpellID());
  9414. client->GetPlayer()->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), old_slot, spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
  9415. client->GetPlayer()->UnlockSpell(spell);
  9416. client->SendSpellUpdate(spell);
  9417. }
  9418. // cast spell here
  9419. if (!spell_tier)
  9420. spell_tier = 1;
  9421. Spell* spell = master_spell_list.GetSpell(spell_id, spell_tier);
  9422. if (spell) {
  9423. client->GetCurrentZone()->ProcessSpell(spell, client->GetPlayer(), client->GetPlayer());
  9424. }
  9425. }
  9426. else {
  9427. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /useability {spell_id} [spell_tier]");
  9428. }
  9429. master_aa_list.DisplayAA(client, 0, 0);
  9430. }
  9431. void Commands::Commit_AA_Profile(Client* client, Seperator* sep) {
  9432. PrintSep(sep, "Commit_AA_Profile");
  9433. if (sep && sep->IsSet(0)) {
  9434. }
  9435. }
  9436. void Commands::Begin_AA_Profile(Client* client, Seperator* sep) {
  9437. PrintSep(sep, "Begin_AA_Profile");
  9438. if (sep && sep->IsSet(0)) {
  9439. master_aa_list.DisplayAA(client, 100, 2);
  9440. }
  9441. }
  9442. void Commands::Back_AA(Client* client, Seperator* sep) {
  9443. if (sep && sep->IsSet(0)) {
  9444. PrintSep(sep, "Back_AA");
  9445. }
  9446. }
  9447. void Commands::Remove_AA(Client* client, Seperator* sep) {
  9448. if (sep && sep->IsSet(0)) {
  9449. PrintSep(sep, "Remove_AA");
  9450. }
  9451. }
  9452. void Commands::Cancel_AA_Profile(Client* client, Seperator* sep) {
  9453. MasterAAList master_aa_list;
  9454. PrintSep(sep, "Cancel_AA_Profile");
  9455. master_aa_list.DisplayAA(client, 0, 0);
  9456. }
  9457. void Commands::Save_AA_Profile(Client* client, Seperator* sep) {
  9458. if (sep && sep->IsSet(0)) {
  9459. PrintSep(sep, "Save_AA_Profile");
  9460. }
  9461. }
  9462. void Commands::Command_TargetItem(Client* client, Seperator* sep) {
  9463. if (!sep || sep->GetArgNumber() < 1 || !client->GetPlayer()) return;
  9464. if (!sep->IsNumber(0)) return;
  9465. int32 request_id = atoul(sep->arg[0]);
  9466. if (!sep->IsNumber(1)) return;
  9467. sint32 item_id = atoi(sep->arg[1]);
  9468. if (client->IsCurrentTransmuteID(request_id)) {
  9469. Transmute::HandleItemResponse(client, client->GetPlayer(), request_id, reinterpret_cast<int32&>(item_id));
  9470. }
  9471. else if (client->IsCurrentTransmuteID(item_id)) {
  9472. if (!sep->IsSet(2)) return;
  9473. if (sep->IsNumber(2) && atoi(sep->arg[2]) == 1) {
  9474. Transmute::HandleConfirmResponse(client, client->GetPlayer(), reinterpret_cast<int32&>(item_id));
  9475. }
  9476. }
  9477. }
  9478. void Commands::Command_FindSpawn(Client* client, Seperator* sep) {
  9479. client->GetCurrentZone()->FindSpawn(client, (char*)sep->argplus[0]);
  9480. }